svharness 0.14.17 → 0.15.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +84 -13
  2. package/auto/auto-harness-detail-design.md +2476 -0
  3. package/auto/auto_/345/212/237/350/203/275/345/256/236/347/216/260_8c2115ba.plan.md +118 -0
  4. package/auto/commands/auto-harness.mjs +248 -0
  5. package/auto/design-problem.md +663 -0
  6. package/auto/design-problem2.md +731 -0
  7. package/auto/design-revision-plan.md +570 -0
  8. package/auto/skills/svharness/SKILL.md +445 -0
  9. package/auto/templates/auto.config.example.yaml +46 -0
  10. package/auto/templates/phase-prompts/S10-wiki.md +14 -0
  11. package/auto/templates/phase-prompts/S40-requirements.md +15 -0
  12. package/auto/templates/phase-prompts/S50-specs.md +15 -0
  13. package/auto/templates/phase-prompts/S60-references.md +22 -0
  14. package/auto/templates/phase-prompts/S65-agent-env.md +14 -0
  15. package/auto/templates/phase-prompts/S70-runtime-assets.md +19 -0
  16. package/auto/templates/phase-prompts/S80-seed-memory.md +13 -0
  17. package/auto/templates/phase-prompts/S85-review.md +29 -0
  18. package/auto/templates/phase-prompts/optimize-implement.md +13 -0
  19. package/auto/templates/phase-prompts/optimize-plan.md +18 -0
  20. package/auto/templates/review-rubric.yaml +104 -0
  21. package/dist/commands/auto.js +66 -0
  22. package/dist/commands/doctor/check-specs-depth.js +2 -19
  23. package/dist/commands/doctor/check-specs.js +9 -3
  24. package/dist/commands/doctor/spec-layers-shared.js +9 -0
  25. package/dist/commands/doctor/spec-layers.js +31 -0
  26. package/dist/commands/init.js +12 -0
  27. package/dist/commands/shell-integration.js +22 -28
  28. package/dist/commands/wizard.js +9 -0
  29. package/dist/config/index.js +2 -1
  30. package/dist/config/merge-options.js +34 -0
  31. package/dist/config/normalize.js +52 -0
  32. package/dist/core/build-project-entry.js +2 -0
  33. package/dist/core/cli-input-declarations.js +1 -1
  34. package/dist/core/state.js +1 -0
  35. package/dist/index.js +52 -5
  36. package/dist/lib/acp-client.js +54 -0
  37. package/dist/lib/agent-launcher.js +4 -22
  38. package/dist/lib/auto-assets.js +19 -0
  39. package/dist/lib/auto-finalize.js +32 -0
  40. package/dist/lib/auto-materials-prep.js +230 -0
  41. package/dist/lib/auto-optimize.js +88 -0
  42. package/dist/lib/auto-orchestrator.js +131 -0
  43. package/dist/lib/auto-review.js +102 -0
  44. package/dist/lib/auto-state.js +37 -0
  45. package/dist/lib/cost-tracker.js +52 -0
  46. package/dist/lib/gate-checker.js +62 -0
  47. package/dist/lib/harness-resolver.js +36 -0
  48. package/dist/lib/launch-script-path.js +24 -0
  49. package/dist/lib/phase-deps.js +43 -0
  50. package/dist/lib/phase-prompt-loader.js +25 -0
  51. package/dist/lib/phase-runner.js +164 -0
  52. package/dist/lib/ps-codechat-alias.js +183 -0
  53. package/dist/lib/review-parser.js +75 -0
  54. package/dist/lib/score-aggregator.js +47 -0
  55. package/dist/types/auto-types.js +2 -0
  56. package/dist/utils/validate-args.js +17 -0
  57. package/dist/utils/yaml-safe-string.js +15 -0
  58. package/docs/standalone-codechat-ps1.md +5 -1
  59. package/package.json +3 -1
  60. package/scripts/postinstall.js +2 -2
  61. package/scripts/preuninstall.js +45 -0
  62. package/templates/_shared/build-rules/harness-build-rule-pre-seal-review.md +16 -4
  63. package/templates/_shared/build-skills/harness-build-skill-pre-seal-review.md +140 -93
  64. package/templates/_shared/meta/AGENTS_BUILD.md.ejs +3 -3
  65. package/templates/_shared/meta/README.md.ejs +4 -0
  66. package/templates/_shared/meta/harness.yaml.ejs +5 -0
  67. package/templates/_shared/tasks/templates/README.md +1 -1
  68. package/templates/codechat/Start-CodeChat.ps1 +498 -359
  69. package/templates/documents/build-rules/harness-build-rule-specs-schema.md +32 -0
  70. package/templates/documents/meta/README.md.ejs +29 -0
  71. package/templates/documents/meta/harness.yaml.ejs +71 -0
  72. package/templates/documents/meta/task_list.md.ejs +26 -0
  73. package/templates/documents/skeleton/agent-env/review-profiles/documents.yaml +15 -0
  74. package/templates/svharness.config.example.yaml +1 -0
  75. package/dist/commands/references-apply-skills.js +0 -47
package/README.md CHANGED
@@ -35,6 +35,9 @@ svharness wizard
35
35
  # 配置文件驱动(团队模板 / CI)
36
36
  svharness build --config svharness.config.yaml --yes
37
37
 
38
+ # 全自动模式 —— 资料整理 → 构建 → 审查 → 优化,支持断点续跑
39
+ svharness auto --work-dir . --auto-approve -y
40
+
38
41
  # 一行式 —— 跳过交互,直接生成
39
42
  svharness build --harness-name my-app --arch android-compose --agent qoder --yes
40
43
 
@@ -60,6 +63,8 @@ svharness start-agent --work-dir .
60
63
 
61
64
  **`svharness wizard`**:分步 TUI,支持同时填写**文件路径**与**说明文字**(如 `requirementsNote`),结束时可选「立即执行 / 仅保存配置 / 保存并执行」。
62
65
 
66
+ **`svharness auto`**:无人值守构建入口。工作目录可以是已有 `<name>-harness/`(从 `.harness-build-state.yaml` 断点续跑),也可以是资料包根(自动检测 `baseline/`、`requirements/`、`references/`、`extra-skills/` 后先执行 build)。配置示例见 `auto/templates/auto.config.example.yaml`。
67
+
63
68
  生成完成后,在你的 Agent IDE 中说:
64
69
  - "运行 harness-build-skills-main"或"harness-build-skill-orchestrator"即可开始逐步填充内容;
65
70
  - 构建完成后在目标项目中说"应用 harness-apply-skills-main 完成 xxx 功能开发"即可调用 harness。
@@ -235,6 +240,7 @@ svharness wizard
235
240
  | 字段 | 说明 |
236
241
  |------|------|
237
242
  | `requirementsNote` | 需求文档业务说明 |
243
+ | `goal` | harness 构建目的(写入 harness 目录) |
238
244
  | `referencesNote` | 参考资料说明 |
239
245
  | `extraSkillsNote` | 额外 skills/rules 说明 |
240
246
 
@@ -270,7 +276,8 @@ svharness build \
270
276
  | `--save-config [path]` | 可选 | build 成功后把参数写入配置文件 | — |
271
277
  | `--harness-name <name>` | ✅ 必填* | harness 名称;可在 `build.harnessName` 中提供 | — |
272
278
  | `--name <name>` | ⚠️ 已废弃别名 | 等同 `--harness-name`,下个 minor 版本移除 | — |
273
- | `--arch <arch>` | 可选 | 架构模板:`android-compose` / `android-xml` / `cpp` / `web-react` / `python` | `android-compose` |
279
+ | `--arch <arch>` | 可选 | 架构模板:`android-compose` / `android-xml` / `cpp` / `web-react` / `python` / `documents` | `android-compose` |
280
+ | `--goal <text>` | 可选 | harness 构建目的(1–2 句话,写入 `harness.yaml` 与 state;最多 500 字符) | — |
274
281
  | `--agent <agent>` | 可选 | 目标 Agent IDE:`codechat` / `qoder` / `cursor` / `claude-code` / `opencode` / `codex` / `generic` | `codechat` |
275
282
  | `--baseline <path\|url>` | 可选 | 基线来源:本地目录 **或** git 仓库 URL | — |
276
283
  | `--requirements <path>` | 可选 | 需求输入路径(文件或目录);build 阶段**扁平**拷贝到 `requirements/raw/`(不保留源目录里的 `assets/raw/converted_md` 等嵌套),随后自动 convert 到 `requirements/md/`(失败仅告警,不中断 build) | — |
@@ -733,11 +740,13 @@ svharness start-agent --work-dir ~/projects/my-app
733
740
 
734
741
  #### 平台说明
735
742
 
736
- | 平台 | spawn 模式 | 右键菜单 |
737
- |------|------------|----------|
743
+ | 平台 | spawn 模式 | 右键菜单 / PowerShell 别名 |
744
+ |------|------------|----------------------------|
738
745
  | Windows | `shell: true` | 支持(`svharness shell`) |
739
746
  | Linux / macOS | `shell: false` | 不支持 |
740
747
 
748
+ Windows 下首次 `start-agent` 会**尽力**写入 PowerShell `codechat` 函数(与 `shell install` 相同逻辑);若未全局安装 svharness,可手动执行 `svharness shell install`。
749
+
741
750
  ### 无需 svharness:独立 PowerShell 启动器
742
751
 
743
752
  未安装 npm / svharness 时,可拷贝 [`templates/codechat/Start-CodeChat.ps1`](templates/codechat/Start-CodeChat.ps1) 到项目 `.claude\`,实现相同的 env 同步与 `run.bat` 解析(含 Android Studio / IDEA 插件路径):
@@ -745,7 +754,12 @@ svharness start-agent --work-dir ~/projects/my-app
745
754
  ```powershell
746
755
  Copy-Item .\templates\codechat\Start-CodeChat.ps1 .\.claude\
747
756
  .\.claude\Start-CodeChat.ps1 # 启动
748
- .\.claude\Start-CodeChat.ps1 -Action InstallMenu # 可选:独立右键菜单
757
+ .\.claude\Start-CodeChat.ps1 -Action Install # 可选:独立右键 + 别名
758
+ .\.claude\Start-CodeChat.ps1 -Action InstallMenu # 仅右键
759
+ .\.claude\Start-CodeChat.ps1 -Action InstallAlias # 仅别名
760
+ .\.claude\Start-CodeChat.ps1 -Action UninstallMenu # 反注册独立右键
761
+ .\.claude\Start-CodeChat.ps1 -Action UninstallAlias # 反注册独立别名
762
+ .\.claude\Start-CodeChat.ps1 -Action Status
749
763
  ```
750
764
 
751
765
  右键菜单使用注册表键 `CodeChatStandaloneAgent`,**不与** `svharness shell install` 冲突;可与 svharness 菜单并存。
@@ -762,24 +776,74 @@ launch_codechat_cli D:\projects\my-app # Windows
762
776
  launch_codechat_cli ~/projects/my-app # Linux
763
777
  ```
764
778
 
765
- ### `shell` —— Windows 右键菜单(v0.16+,仅 win32)
779
+ ### `shell` —— Windows 右键菜单与 PowerShell 别名(v0.16+,仅 win32)
780
+
781
+ 在资源管理器**文件夹空白处**与**文件夹图标**右键增加「在此启动 CodeChat Agent」,并在 PowerShell `$PROFILE` 写入 `codechat` 函数(等价于 `launch_codechat_cli [workdir]`)。**注册与反注册**对右键菜单、本地 stub、PowerShell 别名**一并**处理。
766
782
 
767
- 在资源管理器**文件夹空白处**与**文件夹图标**右键增加「在此启动 CodeChat Agent」,点击后打开 **PowerShell** 窗口并启动 Agent。
783
+ #### 注册
768
784
 
769
785
  ```bash
770
- svharness shell install # 注册(幂等)
771
- svharness shell uninstall # 移除
772
- svharness shell status # 查看 stub / 注册表状态
773
- svharness shell uninstall
774
- npm uninstall -g svharness
786
+ svharness shell install # 注册右键 + 安装 codechat 别名(幂等)
787
+ svharness shell status # 查看是否已完整安装
775
788
  ```
776
789
 
777
- `npm install -g svharness` 在 Windows 上 **默认自动** `shell install`。跳过:
790
+ 注册时会写入:
791
+
792
+ | 项 | 路径 / 键 |
793
+ |----|-----------|
794
+ | 空白处右键 | `HKCU\Software\Classes\Directory\Background\shell\SvharnessLaunchCodeChatAgent` |
795
+ | 文件夹右键 | `HKCU\Software\Classes\Directory\shell\SvharnessLaunchCodeChatAgent` |
796
+ | 启动 stub | `%LOCALAPPDATA%\svharness\bin\launch_codechat_cli.ps1` |
797
+ | 菜单图标 | `%LOCALAPPDATA%\svharness\bin\codechat-agent.ico` |
798
+ | PowerShell 别名 | 当前用户 `$PROFILE` 内 `# >>> codechat >>>` … `# <<< codechat <<<` 块 |
799
+
800
+ `npm install -g svharness` 在 Windows 上 **默认自动** 执行上述注册。跳过:
778
801
 
779
802
  ```bash
780
803
  SVHARNESS_SKIP_SHELL=1 npm install -g svharness
781
804
  ```
782
805
 
806
+ **PowerShell 别名用法**(注册后需**新开** PowerShell 窗口才生效):
807
+
808
+ ```powershell
809
+ codechat # 当前目录启动
810
+ codechat D:\projects\my-app # 指定项目根
811
+ ```
812
+
813
+ #### 反注册
814
+
815
+ ```bash
816
+ svharness shell uninstall # 移除右键、stub、图标与 profile 中的 codechat 块
817
+ svharness shell status # 确认「右键菜单完整 / codechat 别名」均为否
818
+ ```
819
+
820
+ 反注册时会删除:
821
+
822
+ | 项 | 说明 |
823
+ |----|------|
824
+ | 上述两个 HKCU 注册表键 | 资源管理器右键菜单项消失(无需重启 Explorer) |
825
+ | `%LOCALAPPDATA%\svharness\bin\` | 删除 stub `.ps1` 与 `.ico` |
826
+ | `$PROFILE` 中的 codechat 块 | 移除 `# >>> codechat >>>` … `# <<< codechat <<<` 整段;**不**删除 profile 文件本身 |
827
+
828
+ 全局卸载 npm 包时,`preuninstall` 会**尽力**自动反注册(与 `shell uninstall` 相同范围):
829
+
830
+ ```bash
831
+ npm uninstall -g svharness
832
+ ```
833
+
834
+ 若自动反注册失败,可手动执行 `svharness shell uninstall`(包仍在时),或自行检查:
835
+
836
+ - 注册表:`reg query HKCU\Software\Classes\Directory\Background\shell\SvharnessLaunchCodeChatAgent` 应报错「找不到」
837
+ - 目录:`%LOCALAPPDATA%\svharness\bin\` 应不存在或为空
838
+ - profile:打开 `$PROFILE`,确认无 `# >>> codechat >>>` 标记块
839
+
840
+ **注意**:`shell uninstall` **仅**移除 svharness 注册的菜单(键名 `SvharnessLaunchCodeChatAgent`)。若曾用独立脚本 [`Start-CodeChat.ps1`](templates/codechat/Start-CodeChat.ps1) 注册过菜单(键名 `CodeChatStandaloneAgent`),需单独反注册:
841
+
842
+ ```powershell
843
+ .\.claude\Start-CodeChat.ps1 -Action UninstallMenu # 独立右键
844
+ .\.claude\Start-CodeChat.ps1 -Action UninstallAlias # 独立别名(若曾 Install / InstallAlias)
845
+ ```
846
+
783
847
  ---
784
848
 
785
849
  ## 架构模板
@@ -793,6 +857,13 @@ SVHARNESS_SKIP_SHELL=1 npm install -g svharness
793
857
  | `cpp` | C++17 + CMake | 5 条 `seed-*.md` | 现代 C++ + CMake 规范 |
794
858
  | `web-react` | TypeScript + React | 5 条 `seed-*.md` | Hooks + 状态管理规范 |
795
859
  | `python` | Python | — | 通用 Python 模板 |
860
+ | `documents` | — | — | 文档型 harness(无代码基线;spec 域为 behavior + interfaces) |
861
+
862
+ ```bash
863
+ # 文档型 harness + 构建目的
864
+ svharness build --harness-name doc-demo --arch documents --agent codechat \
865
+ --goal "车载 CAN 信号协议文档标准化 harness" --yes --force
866
+ ```
796
867
 
797
868
  > **两层叠拷合并**:`_shared/` 先落盘,`<arch>/` 随后覆盖同名文件。
798
869
  > 新增架构只需在 `templates/<new-arch>/skeleton/agent-env/rules/` 下放 3-5 条规则文件,
@@ -1083,7 +1154,7 @@ svharness build --harness-name demo-unknown --arch python --agent codechat `
1083
1154
  - [x] 参数 `--name` → `--harness-name`(保留 `--name` 别名一版本)
1084
1155
  - [x] `--arch` 默认 `android-compose`、`--agent` 默认 `codechat`
1085
1156
  - [x] `build` —— 骨架 + 元文件 + 状态文件 + skill 注入
1086
- - [x] 多架构模板(`android-compose` / `android-xml` / `cpp` / `web-react` / `python`)
1157
+ - [x] 多架构模板(`android-compose` / `android-xml` / `cpp` / `web-react` / `python` / `documents`)
1087
1158
  - [x] `_shared/` + `<arch>/` 两层叠拷合并
1088
1159
  - [x] 每个架构自带 3-5 条规则文件(`.mdc` 格式,`alwaysApply: true` 默认启用)
1089
1160
  - [x] `apply` —— 把已构建好的 harness 绑定到目标项目(默认复制模式,`--clone` 兼容保留)