环境准备

本页讲在本仓库做开发需要什么、怎么装、第一次构建怎么跑。命令以 .codex/skills/project/SKILL.md 的规范命令为准。

前置

  • Node.js:仓库用 Node 24+(开发机上 v24.18.0)。Rspress 文档站点要 Node 20.19+ 或 22.12+。
  • pnpm:固定 pnpm@10.6.4(根 package.jsonpackageManager)。
  • Go通常不需要系统 Go——平台包自带修剪过的 Go SDK(@ttsc/{platform}-{arch}/bin/go),ttsc 的插件构建默认用它(见 go build 缓存)。但跑 Go 单测的脚本(scripts/test-go-*.cjs)会优先用 ~/go-sdk/go/bin 的 Go,其次系统 go,所以本地跑 Go 测试需要一个 Go toolchain 可用。
  • TypeScript:catalog 固定 7.0.1-rc(tsgo)。

安装

pnpm install

这会装工作区全部包的依赖。它不会构建任何东西。

规范命令(来自 project skill)

pnpm install      # 装依赖
pnpm format       # 格式化 (含 gen:flags 与 Go gofmt) — 提交前必跑
pnpm build        # 构建全部平台包 (scripts/build-platforms.cjs)
pnpm test:go      # Go 单测
pnpm test         # 全套 (check:flags + build:current + test:go + typecheck + features)

第一次构建该用 build:current

pnpm build 构建全部七个平台的包,慢。开发与测试用 pnpm build:currentscripts/build-current.cjs),只构建当前平台:

pnpm build:current

它按固定顺序构建:ttsc → @ttsc/banner → @ttsc/lint → @ttsc/unplugin → @ttsc/metro → @ttsc/vscode → 当前平台包 → @ttsc/graph → lint-contributor-demo。平台包必须在 @ttsc/graph 前(graph 构建会跑带 typia 的 ttsc,需要原生二进制)。

沙箱与权限提示(来自 memory)

在沙箱环境里:

  • Git 操作可能因 index.lock 权限错误需要升级权限。
  • cargo/go build 同步 toolchain 时可能需要禁用沙箱。
  • 构建命中 ~/.npm~/.cacheEPERM 时,npm 用 --cache ./.npm-cache、构建命令禁沙箱。
  • 别在测试夹具的 rslib 目录跑 pnpm install/build——会删 git 跟踪的 node_modules

这些是过往运行的经验,可能随环境变化;遇到权限错误时优先怀疑沙箱限制。

验证安装

最小验证:

pnpm build:current
node packages/ttsc/lib/launcher/ttsc.js --version

应打印 ttsc <version> (commit ..., ...)

接下来