diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 86bfd2a..c34bae4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,6 +45,12 @@ jobs: pnpm --dir frontend install --frozen-lockfile pnpm --dir frontend build + - name: Debug workspace hygiene check & self-test + shell: pwsh + run: | + node scripts/debug/check.mjs + node --test scripts/debug/debug.test.mjs + - name: Go test & vet shell: pwsh run: | diff --git a/.gitignore b/.gitignore index 857829d..8f0edf4 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,6 @@ Thumbs.db *.log .vscode/ .idea/ + +# Local debugging scratch, work orders, run logs, caches, scratch worktrees +.debug/ diff --git a/AGENTS.md b/AGENTS.md index 5d0d128..266b695 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -12,8 +12,38 @@ ## 存储与产物边界 -1. **大体积文件严禁入库**:便携运行时包、macOS 安装包、`.qcow2` 磁盘与快照一律保存在用户或开发者本地指定的 ``(推荐非系统盘),不得提交到仓库。 -2. **临时文件及时清理**:打包草稿、一次性测试目录使用完后清理,不留在仓库工作区。 +1. **大体积文件严禁入库**:便携运行时包、macOS 安装包、`.qcow2` 磁盘与快照一律保存在用户或开发者本地指定的 ``(推荐非系统盘),不得提交到仓库,也不放入 `.debug/`。 +2. **禁止使用系统临时目录存放任务中间产物**:开发与排查产生的临时脚本、截图、日志、构建/测试缓存与隔离运行产物一律写入仓库根目录的 `.debug/`(已加入 `.gitignore`,严禁提交),不读写系统临时目录(`%TEMP%` / `/tmp`)。 +3. **临时文件及时退役**:任务完成后清理草稿与会话目录;值得长期保留的探针沉淀为正式单元测试(`*_test.go`)或 `scripts/` 下的工具脚本,不留在 `.debug/`。 + +## 调试目录与临时产物纪律(`.debug/`) + +1. **顶层目录白名单**:`.debug/` 顶层只允许 [`scripts/debug/paths.mjs`](scripts/debug/paths.mjs) 声明的 5 个子目录,任何工具与脚本必须写入其中之一,`node scripts/debug/check.mjs` 会拒绝顶层出现其他杂项: + - `.debug/tmp/` — 一次性会话临时产物,由 `scripts/debug/tmp.mjs` 创建、记录属主 PID 并回收。 + - `.debug/work/` — 跨会话工单与交接材料(含 `refs/`、`shots/`、`tmp/` 与 `work.md`),由 `scripts/debug/work.mjs` 管理。 + - `.debug/cache/` — 可由源码树重建的本地工具缓存。 + - `.debug/runs/` — 本地运行输出(日志、抓包、报告、追踪与隔离运行目录)。 + - `.debug/worktrees/` — 临时 Git 工作树,由 `scripts/debug/worktree.mjs` 管理(移除前先解除 Windows Junction / 符号链接,避免误删主树 `frontend/node_modules`)。 +2. **脚本与命令行红线**: + - **禁止在命令行内联长多行脚本**:需要多行脚本时,先写入 `.debug/tmp/`(或所属工单的 `tmp/`)再执行。 + - **作者修改走编辑工具**:新逻辑、文案与规则变更直接通过编辑工具修改;跨文件机械改造(重命名、批量改路径、语法迁移)可将脚本放在 `.debug/tmp/` 运行,执行后通读完整 `git diff` 并通过全部校验,脚本不得编写新逻辑。 +3. **一次性临时目录与工单分工**: + - 范围明确、当前会话可完成的小修改、只读检查和一次性试验直接进行,不建工单;无中间产物时不创建临时目录。 + - 用户显式要求工单,或任务需要跨会话恢复、多人/多 Agent 交接、持续积累验收证据时,再通过 `work.mjs` 建立或复用工单。 + - 一次性产物用 `node scripts/debug/tmp.mjs new