create-harness-vibe-coding 0.8.8 → 0.8.10

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 (82) hide show
  1. package/README-CN.md +8 -2
  2. package/README.md +22 -3
  3. package/docs/images/harness-icon.png +0 -0
  4. package/package.json +3 -1
  5. package/src/generator.js +36 -0
  6. package/src/index.js +72 -4
  7. package/templates/common/.claude/agents/architect.md +31 -31
  8. package/templates/common/.claude/agents/codebase-explorer.md +45 -0
  9. package/templates/common/.claude/agents/docs-researcher.md +41 -41
  10. package/templates/common/.claude/agents/memory-master.md +26 -8
  11. package/templates/common/.claude/agents/reviewer.md +34 -34
  12. package/templates/common/.claude/agents/task-scribe.md +70 -0
  13. package/templates/common/.claude/commands/wf-help.md +9 -5
  14. package/templates/common/.claude/commands/wf-update.md +24 -0
  15. package/templates/common/.claude/rules/ecc/common.md +15 -2
  16. package/templates/common/.claude/settings.json +13 -0
  17. package/templates/common/.claude/skills/subagent-orchestrator/SKILL.md +10 -6
  18. package/templates/common/.claude/skills/wf/SKILL.md +15 -8
  19. package/templates/common/.claude/skills/wf-auto/SKILL.md +3 -2
  20. package/templates/common/.claude/skills/wf-learn/SKILL.md +9 -2
  21. package/templates/common/.claude/skills/wf-max/SKILL.md +26 -8
  22. package/templates/common/.claude/skills/wf-review/SKILL.md +63 -12
  23. package/templates/common/.claude/skills/wf-update/SKILL.md +15 -2
  24. package/templates/common/.codex/hooks.json +17 -0
  25. package/templates/common/.harness-version +93 -48
  26. package/templates/common/.opencode/agents/architect.md +24 -24
  27. package/templates/common/.opencode/agents/codebase-explorer.md +45 -0
  28. package/templates/common/.opencode/agents/docs-researcher.md +34 -34
  29. package/templates/common/.opencode/agents/memory-master.md +26 -8
  30. package/templates/common/.opencode/agents/reviewer.md +27 -27
  31. package/templates/common/.opencode/agents/task-scribe.md +70 -0
  32. package/templates/common/.opencode/commands/wf-auto-spark.md +15 -0
  33. package/templates/common/.opencode/commands/wf-auto.md +15 -0
  34. package/templates/common/.opencode/commands/wf-help.md +9 -5
  35. package/templates/common/.opencode/commands/wf-learn.md +15 -0
  36. package/templates/common/.opencode/commands/wf-max.md +15 -0
  37. package/templates/common/.opencode/commands/wf-readme.md +15 -0
  38. package/templates/common/.opencode/commands/wf-remove.md +15 -0
  39. package/templates/common/.opencode/commands/wf-review.md +15 -0
  40. package/templates/common/.opencode/commands/wf-update.md +24 -0
  41. package/templates/common/.opencode/commands/wf.md +15 -0
  42. package/templates/common/.opencode/plugins/harness-wf-status.mjs +126 -0
  43. package/templates/common/AGENTS.md +2 -29
  44. package/templates/common/CLAUDE.md +35 -6
  45. package/templates/common/Harness/ACCEPTANCE_PROTOCOL.md +2 -2
  46. package/templates/common/{MEMORY.md → Harness/MEMORY.md} +17 -4
  47. package/templates/common/Harness/MEMORY_PROTOCOL.md +80 -30
  48. package/templates/common/Harness/README.md +53 -25
  49. package/templates/common/{SETUP.md → Harness/SETUP.md} +278 -276
  50. package/templates/common/Harness/TASK_ARCHIVE.md +56 -0
  51. package/templates/common/Harness/WF-AUTO-ANGLES.md +1 -1
  52. package/templates/common/Harness/WF-AUTO-SPARK.md +5 -14
  53. package/templates/common/Harness/WF-AUTO.md +22 -84
  54. package/templates/common/Harness/WF-KERNEL.md +189 -0
  55. package/templates/common/Harness/WF-MAX.md +60 -328
  56. package/templates/common/Harness/WF-STATE.md +83 -0
  57. package/templates/common/Harness/WF.md +117 -237
  58. package/templates/common/Harness/agent-workflow.md +2 -2
  59. package/templates/common/Harness/context-loading.md +3 -3
  60. package/templates/common/Harness/dispatch.md +43 -35
  61. package/templates/common/Harness/scripts/archive-tasks.mjs +239 -0
  62. package/templates/common/{scripts → Harness/scripts}/scan-clean.mjs +29 -1
  63. package/templates/common/{scripts → Harness/scripts}/validate-harness.mjs +921 -699
  64. package/templates/common/Harness/scripts/wf-auto-update-prompt.mjs +258 -0
  65. package/templates/common/{scripts → Harness/scripts}/wf-remove.mjs +1 -0
  66. package/templates/common/{scripts → Harness/scripts}/wf-update-check.mjs +163 -52
  67. package/templates/common/Harness/subagents.md +36 -28
  68. package/templates/common/Harness/tasks/_template/PLAN.md +5 -0
  69. package/templates/common/Harness/tasks/_template/STATE.json +23 -0
  70. package/templates/common/README.md +2 -2
  71. package/templates/common/memory/agent-lessons-patterns.md +9 -8
  72. package/templates/common/memory/routes.md +43 -0
  73. package/templates/common/memory/startup-hints.md +32 -0
  74. package/templates/common/memory/tool-usage-reflections.md +9 -8
  75. package/templates/common/memory/user-corrections-preferences.md +11 -9
  76. package/templates/optional/catalog.json +8 -0
  77. package/templates/optional/skills/browser-e2e/.claude/skills/browser-e2e/SKILL.md +42 -42
  78. package/templates/optional/skills/browser-e2e/.opencode/commands/wf-browser.md +15 -0
  79. package/templates/optional/skills/github-pr-review/.claude/skills/github-pr-review/SKILL.md +40 -40
  80. package/templates/optional/skills/python-backend/.claude/skills/python-backend/SKILL.md +40 -40
  81. package/templates/optional/skills/ts-react-frontend/.claude/skills/ts-react-frontend/SKILL.md +43 -43
  82. package/templates/optional/skills/ui-ux-review/.claude/skills/ui-ux-review/SKILL.md +40 -40
package/README-CN.md CHANGED
@@ -5,6 +5,10 @@
5
5
  <img src="https://img.shields.io/github/stars/zingspark/create-harness-vibe-coding?style=social" alt="GitHub stars">
6
6
  </p>
7
7
 
8
+ <p align="center">
9
+ <img src="docs/images/harness-icon.png" alt="Harness 图标" width="112">
10
+ </p>
11
+
8
12
  <h1 align="center">create-harness-vibe-coding</h1>
9
13
  <p align="center">
10
14
  <b>让 AI agent 在真实仓库里先理解,再执行,最后验证。</b><br>
@@ -39,7 +43,8 @@ Agent 读取本 README 后,按项目状态选择安装路径:
39
43
  |---|---|
40
44
  | 新项目 | `npx create-harness-vibe-coding@latest my-project -y` |
41
45
  | 已有项目 | `npx create-harness-vibe-coding@latest my-project . -y --on-conflict skip --json` |
42
- | 已有 `Harness/` | `node Harness/scripts/wf-update-check.mjs`,不要重复安装 |
46
+ | 已有 `Harness/` 且存在 `Harness/scripts/wf-update-check.mjs` | `node Harness/scripts/wf-update-check.mjs --json`,走更新流程,不要重复安装 |
47
+ | 已有 `Harness/` 但缺少 `Harness/scripts/wf-update-check.mjs` | `npx create-harness-vibe-coding@latest my-project . -y --on-conflict skip --json`。然后执行 `node Harness/scripts/wf-update-check.mjs --json` |
43
48
  | 安装或更新完成 | `node Harness/scripts/validate-harness.mjs --strict` |
44
49
 
45
50
  安装后的 instruction:先读取 `CLAUDE.md`、`AGENTS.md`、`Harness/SETUP.md` 和 `Harness/README.md`;遵守项目已有边界;先研究和计划,再修改代码;完成后运行测试、校验和审查,未验证不要声称完成。
@@ -56,7 +61,7 @@ Agent 读取本 README 后,按项目状态选择安装路径:
56
61
  | `/wf-max <任务>` | 任务可拆成多个互不冲突的部分,需要最大并行度 | 在完整 WF 链路上增加 CEO → Manager → Worker 分工和并行波次 | `/wf-max 并行升级前端、后端和文档` |
57
62
  | `/wf-auto` | 希望 Agent 持续自我优化,通过自适应探测选择 | 持续执行优化循环,每轮保留计划、证据和反馈 | `/wf-auto 优化这个项目的稳定性` |
58
63
  | `/wf-auto-spark` | 需要外部灵感、竞品方向或长期路线图 | 搜索外部 spark,绑定 North Star 和里程碑,限制偏离范围 | `/wf-auto-spark 探索产品增长方向` |
59
- | `/wf-review [重点]` | 需要第二意见、跨模型审查或上线前复核 | 调用其他 Agent 做独立审查,并按严重程度反馈 | `/wf-review 重点检查安全和数据丢失` |
64
+ | `/wf-review [重点]` | 需要第二意见、同行审查或上线前复核 | 优先调用可用 peer CLI;没有时使用独立 reviewer 角色,并按严重程度反馈 | `/wf-review 重点检查安全和数据丢失` |
60
65
  | `/wf-learn` | 同类错误反复出现,或一次任务结束后要沉淀经验 | 汇总上下文、记忆和项目经验,形成下一次可复用规则 | `/wf-learn 总结这次返修原因` |
61
66
  | `/wf-browser <任务>` | 浏览器冒烟、E2E、截图、表单或页面验证 | 使用真实浏览器完成操作并提供截图、追踪和验证证据 | `/wf-browser 验证登录和支付流程` |
62
67
  | `/wf-readme <任务>` | README、安装文档、架构图或项目说明需要重写 | 保留事实,整理结构,补充安装和使用说明 | `/wf-readme 优化中文 README` |
@@ -173,6 +178,7 @@ Harness 把一次模糊请求变成一条可以追踪的路径:
173
178
  | `caveman` | 简洁、低 token 的 agent 行为 | [Caveman](https://github.com/JuliusBrussee/caveman) |
174
179
  | `agent-research` | 文献、产品、依赖和生态研究 | [agent-research-skills](https://github.com/lingzhi227/agent-research-skills) |
175
180
  | `codegraph` | 代码图谱和仓库地图 | [Codegraph](https://github.com/colbymchenry/codegraph) |
181
+ | `grill-me` | 实现前对计划或设计做高压追问 | [Grill Me](https://github.com/mattpocock/skills/tree/main/skills/productivity/grill-me) |
176
182
 
177
183
  ## 验证
178
184
 
package/README.md CHANGED
@@ -5,12 +5,22 @@
5
5
  <img src="https://img.shields.io/github/stars/zingspark/create-harness-vibe-coding?style=social" alt="GitHub stars">
6
6
  </p>
7
7
 
8
+ <p align="center">
9
+ <img src="docs/images/harness-icon.png" alt="Harness icon" width="112">
10
+ </p>
11
+
8
12
  <h1 align="center">create-harness-vibe-coding</h1>
9
13
  <p align="center">
10
14
  <b>An operating contract for reliable AI coding agents.</b><br>
11
15
  <sub>Goals. Context. Loops. Evidence.</sub>
12
16
  </p>
13
17
 
18
+ <p align="center">
19
+ <a href="README-CN.md">Chinese</a> ·
20
+ <a href="https://github.com/zingspark/create-harness-vibe-coding">GitHub</a> ·
21
+ <a href="https://www.npmjs.com/package/create-harness-vibe-coding">npm</a>
22
+ </p>
23
+
14
24
  `create-harness-vibe-coding` is a Node.js CLI that scaffolds a repo-local harness for AI-assisted software development: research, PRD, architecture, task decomposition, implementation, testing, review, recovery, and durable memory.
15
25
 
16
26
  It is not a prompt pack and it does not generate business code. It gives Claude Code, Codex, and compatible agents a shared operating system for long-running work.
@@ -44,7 +54,8 @@ After reading this README, the agent selects the path that matches the project:
44
54
  |---|---|
45
55
  | New project | `npx create-harness-vibe-coding@latest my-project -y` |
46
56
  | Existing project | `npx create-harness-vibe-coding@latest my-project . -y --on-conflict skip --json` |
47
- | Existing `Harness/` | `node Harness/scripts/wf-update-check.mjs`; do not reinstall |
57
+ | Existing `Harness/` with `Harness/scripts/wf-update-check.mjs` | `node Harness/scripts/wf-update-check.mjs --json`; update, do not reinstall |
58
+ | Existing `Harness/` but missing `Harness/scripts/wf-update-check.mjs` | `npx create-harness-vibe-coding@latest my-project . -y --on-conflict skip --json`. Then run `node Harness/scripts/wf-update-check.mjs --json` |
48
59
  | After install or update | `node Harness/scripts/validate-harness.mjs --strict` |
49
60
 
50
61
  After installation, read `CLAUDE.md`, `AGENTS.md`, `Harness/SETUP.md`, and `Harness/README.md`; preserve project boundaries; research and plan before editing; run tests, validation, and review before claiming completion.
@@ -61,7 +72,7 @@ When in doubt, use `/wf-help`. It returns the full command table. Use `/wf` for
61
72
  | `/wf-max <task>` | The task splits into independent work and needs maximum parallelism | Adds CEO → Manager → Worker roles and parallel waves to the full WF chain | `/wf-max upgrade frontend, backend, and docs in parallel` |
62
73
  | `/wf-auto` | You want continuous self-directed optimization with adaptive probe selection | Runs repeated optimization cycles with plans, evidence, and feedback | `/wf-auto improve this project's stability` |
63
74
  | `/wf-auto-spark` | You need external inspiration, competitive direction, or a long-term roadmap | Searches for sparks, anchors work to a North Star and milestones, and guards scope drift | `/wf-auto-spark explore product growth directions` |
64
- | `/wf-review [focus]` | You need a second opinion, cross-model review, or a pre-release check | Runs an independent review and classifies findings by severity | `/wf-review focus on security and data loss` |
75
+ | `/wf-review [focus]` | You need a second opinion, peer review, or a pre-release check | Uses a peer CLI when available, otherwise an independent reviewer role, and classifies findings by severity | `/wf-review focus on security and data loss` |
65
76
  | `/wf-learn` | The same mistakes keep recurring or a completed task needs to become reusable knowledge | Consolidates context, memory, and project lessons | `/wf-learn summarize why this task needed rework` |
66
77
  | `/wf-browser <task>` | Browser smoke tests, E2E, screenshots, forms, or UI verification | Uses a real browser and returns screenshots, traces, and evidence | `/wf-browser verify login and checkout` |
67
78
  | `/wf-readme <task>` | README, install docs, architecture diagrams, or project docs need work | Preserves facts while improving structure, setup, and usage guidance | `/wf-readme improve the Chinese README` |
@@ -141,7 +152,7 @@ Read and follow https://github.com/zingspark/create-harness-vibe-coding exactly
141
152
 
142
153
  The agent-first path previews the target before writing and preserves project-owned files. If you need the detailed CLI contract, the agent can read `Harness/SETUP.md` after setup.
143
154
 
144
- If `Harness/` already exists, use `/wf-update`, `$wf-update`, or `node Harness/scripts/wf-update-check.mjs` instead of reinstalling blindly.
155
+ If `Harness/` already exists, first check whether `Harness/scripts/wf-update-check.mjs` exists. If it does, use `/wf-update`, `$wf-update`, or `node Harness/scripts/wf-update-check.mjs --json` instead of reinstalling blindly. If it is missing, run the safe CLI recovery command from the installation table first, then run the updater.
145
156
 
146
157
  ## Optional workflows
147
158
 
@@ -159,6 +170,14 @@ Ask your agent to add the capability you need:
159
170
 
160
171
  External recommendations are recorded in `Harness/SETUP.md`; they are not auto-installed.
161
172
 
173
+ | Recommendation | Use it for | Source |
174
+ |---|---|---|
175
+ | `superpowers` | Community agent skills and coding workflows | [Superpowers](https://github.com/obra/Superpowers) |
176
+ | `caveman` | Terse, low-token agent behavior | [Caveman](https://github.com/JuliusBrussee/caveman) |
177
+ | `agent-research` | Literature, product, dependency, and ecosystem research | [agent-research-skills](https://github.com/lingzhi227/agent-research-skills) |
178
+ | `codegraph` | Repository graph and architecture mapping | [CodeGraph](https://github.com/colbymchenry/codegraph) |
179
+ | `grill-me` | Relentless plan/design interview before implementation | [Grill Me](https://github.com/mattpocock/skills/tree/main/skills/productivity/grill-me) |
180
+
162
181
  ## Verify
163
182
 
164
183
  ```bash
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-harness-vibe-coding",
3
- "version": "0.8.8",
3
+ "version": "0.8.10",
4
4
  "description": "Scaffold a 0-1 product harness for AI-assisted research, PRD, planning, architecture, build, test, and feedback loops",
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,6 +10,7 @@
10
10
  "bin/",
11
11
  "src/",
12
12
  "templates/",
13
+ "docs/images/harness-icon.png",
13
14
  "docs/images/harness-architecture-light.png",
14
15
  "docs/images/harness-architecture.drawio",
15
16
  "README-CN.md"
@@ -19,6 +20,7 @@
19
20
  "build:version": "node scripts/build-version.mjs",
20
21
  "prepush": "node scripts/pre-push-check.mjs",
21
22
  "test": "node --test tests/*.test.js",
23
+ "test:e2e": "node tests/e2e-wf-scripts.test.mjs",
22
24
  "test:smoke": "node --test tests/cli-smoke.test.js",
23
25
  "pack:smoke": "node --test tests/pack-smoke.test.js"
24
26
  },
package/src/generator.js CHANGED
@@ -254,6 +254,28 @@ function duplicateDests(fileSpecs) {
254
254
  return [...duplicates].sort();
255
255
  }
256
256
 
257
+ /**
258
+ * Walk the directory chain from rootDir down to the parent of absPath.
259
+ * Returns the first ancestor that is a symbolic link, or null if none.
260
+ * Prevents writes from escaping the workspace via symlinked parent dirs
261
+ * (e.g. .claude/, Harness/, .opencode/ pointing outside the project).
262
+ */
263
+ function symlinkInChain(rootDir, absPath) {
264
+ const root = path.resolve(rootDir);
265
+ const target = path.resolve(absPath);
266
+ const rel = path.relative(root, target);
267
+ if (!rel || rel.startsWith("..") || path.isAbsolute(rel)) return null;
268
+ const parts = rel.split(path.sep).filter(Boolean);
269
+ let cur = root;
270
+ for (let i = 0; i < parts.length - 1; i += 1) {
271
+ cur = path.join(cur, parts[i]);
272
+ try {
273
+ if (fs.lstatSync(cur).isSymbolicLink()) return cur;
274
+ } catch (_) { /* directory not created yet */ }
275
+ }
276
+ return null;
277
+ }
278
+
257
279
  function createPlan(resolvedDir, fileSpecs) {
258
280
  const plan = {
259
281
  create: [],
@@ -528,12 +550,20 @@ export function generate({
528
550
  const dirPath = dir === './'
529
551
  ? resolvedDir
530
552
  : path.join(resolvedDir, ...dir.slice(0, -1).split('/'));
553
+ const __slMkdir = symlinkInChain(resolvedDir, dirPath);
554
+ if (__slMkdir) throw new Error(`Cannot create directory ${dir}: symlinked directory in path (${__slMkdir})`);
531
555
  fs.mkdirSync(dirPath, { recursive: true });
532
556
  created.push(dir === './' ? './ (directory)' : `${dir} (directory)`);
533
557
  }
534
558
 
535
559
  for (const file of plan.backup) {
536
560
  const destPath = path.join(resolvedDir, ...file.split('/'));
561
+ const __slBackup = symlinkInChain(resolvedDir, destPath);
562
+ if (__slBackup) throw new Error(`Cannot backup ${file}: symlinked directory in path (${__slBackup})`);
563
+ // Symlink safety: never rename or follow symlinks to avoid path traversal
564
+ if (fs.existsSync(destPath)) {
565
+ try { if (fs.lstatSync(destPath).isSymbolicLink()) throw new Error('Symlink rejected'); } catch (e) { throw new Error(`Cannot backup ${file}: ${e.message}`); }
566
+ }
537
567
  fs.renameSync(destPath, nextBackupPath(destPath));
538
568
  }
539
569
 
@@ -554,6 +584,12 @@ export function generate({
554
584
  }
555
585
  const spec = specsByDest.get(file);
556
586
  const destPath = path.join(resolvedDir, ...file.split('/'));
587
+ const __slWrite = symlinkInChain(resolvedDir, destPath);
588
+ if (__slWrite) throw new Error(`Cannot create/overwrite ${file}: symlinked directory in path (${__slWrite})`);
589
+ // Symlink safety: reject symlinks before writing to prevent path traversal outside workspace
590
+ if (fs.existsSync(destPath)) {
591
+ try { if (fs.lstatSync(destPath).isSymbolicLink()) throw new Error('Symlink rejected'); } catch (e) { throw new Error(`Cannot create/overwrite ${file}: ${e.message}`); }
592
+ }
557
593
  let content = spec.type === 'empty'
558
594
  ? ''
559
595
  : renderTemplate(spec.src, vars);
package/src/index.js CHANGED
@@ -89,6 +89,12 @@ if (generationOptions.json) {
89
89
  const projectName = argName || DEFAULT_NAME;
90
90
  const targetDir = argDir || `./${projectName}`;
91
91
  const scan = scanTarget(targetDir);
92
+ if (needsScaffoldRecovery(scan)) {
93
+ const recovery = createScaffoldRecoveryResult({ projectName, targetDir, options: generationOptions, scan });
94
+ printJsonResult(recovery);
95
+ process.exit(recovery.success ? 0 : 1);
96
+ }
97
+
92
98
  if (scan.hasHarness) {
93
99
  printJsonResult(createUpdateSwitchResult(scan, { json: true }));
94
100
  process.exit(0);
@@ -121,6 +127,10 @@ if (argName || skipPrompts) {
121
127
  targetDir = argDir || `./${projectName}`;
122
128
  const scan = scanTarget(targetDir);
123
129
 
130
+ if (needsScaffoldRecovery(scan)) {
131
+ process.exit(runScaffoldRecovery({ projectName, targetDir, options: generationOptions, scan }));
132
+ }
133
+
124
134
  if (scan.hasHarness) {
125
135
  process.exit(runUpdateSwitch(scan, { json: false }));
126
136
  }
@@ -172,6 +182,10 @@ if (argName || skipPrompts) {
172
182
  const scan = scanTarget(targetDir);
173
183
  printScan(scan);
174
184
 
185
+ if (needsScaffoldRecovery(scan)) {
186
+ process.exit(runScaffoldRecovery({ projectName, targetDir, options: generationOptions, scan }));
187
+ }
188
+
175
189
  if (scan.hasHarness) {
176
190
  process.exit(runUpdateSwitch(scan, { json: false }));
177
191
  }
@@ -439,12 +453,55 @@ function printWarnings(result) {
439
453
  }
440
454
 
441
455
  function printJsonResult(result) {
442
- // Remove `created` array from output — it is already in the plan, avoid duplication
443
- const { created, ...rest } = result;
456
+ // Remove `created` array from output — it is already in the plan, avoid duplication
457
+ const { created, ...rest } = result;
444
458
  console.log(JSON.stringify(rest, null, 2));
445
459
  if (!result.success) {
446
460
  process.exit(1);
447
- }
461
+ }
462
+ }
463
+
464
+ function updateScriptPath(scan) {
465
+ return path.join(scan.resolvedDir, 'Harness', 'scripts', 'wf-update-check.mjs');
466
+ }
467
+
468
+ function missingRecoveryReasons(scan) {
469
+ const reasons = [];
470
+ if (!fs.existsSync(updateScriptPath(scan))) reasons.push('Harness/scripts/wf-update-check.mjs');
471
+ return reasons;
472
+ }
473
+
474
+ function needsScaffoldRecovery(scan) {
475
+ return scan.hasHarness && missingRecoveryReasons(scan).length > 0;
476
+ }
477
+
478
+ function recoveryOptions(options) {
479
+ return {
480
+ ...options,
481
+ onConflict: 'skip',
482
+ };
483
+ }
484
+
485
+ function createScaffoldRecoveryResult({ projectName, targetDir, options, scan }) {
486
+ const reasons = missingRecoveryReasons(scan);
487
+ const recovery = generate({
488
+ projectName,
489
+ targetDir,
490
+ ...recoveryOptions(options),
491
+ });
492
+ recovery.mode = 'recovery';
493
+ recovery.recoveryNote = `Missing ${reasons.join(' and ')}. Re-ran generate with --on-conflict ${recoveryOptions(options).onConflict} to restore missing Harness infrastructure without overwriting existing files.`;
494
+ return recovery;
495
+ }
496
+
497
+ function runScaffoldRecovery({ projectName, targetDir, options, scan }) {
498
+ const reasons = missingRecoveryReasons(scan);
499
+ console.log('');
500
+ console.log(pc.yellow(`Old Harness detected: missing ${reasons.join(' and ')}. Running safe recovery (--on-conflict ${recoveryOptions(options).onConflict}).`));
501
+ const recovery = createScaffoldRecoveryResult({ projectName, targetDir, options, scan });
502
+ printResult(recovery, targetDir);
503
+ if (recovery.success) console.log(pc.green('Recovery complete. Now run: node Harness/scripts/wf-update-check.mjs'));
504
+ return recovery.success ? 0 : 1;
448
505
  }
449
506
 
450
507
  function runUpdateSwitch(scan, { json }) {
@@ -513,8 +570,19 @@ function createUpdateSwitchResult(scan, { json }) {
513
570
  if (!fs.existsSync(scriptPath)) {
514
571
  return {
515
572
  ...base,
516
- error: 'Existing Harness detected, but Harness/scripts/wf-update-check.mjs was not found. Install writes were skipped; inspect the existing Harness before updating manually.',
573
+ success: false,
574
+ error: 'Existing Harness detected, but Harness/scripts/wf-update-check.mjs was not found. The Harness install is incomplete or was created by an older version that did not include the update checker script. Install writes were skipped — no files were overwritten.',
517
575
  errors: ['Harness/scripts/wf-update-check.mjs not found'],
576
+ agent: {
577
+ ...base.agent,
578
+ next: [{
579
+ action: 'recovery',
580
+ reason: 'This Harness install predates the update-checker script.',
581
+ recoveryPath: 'Run npx create-harness-vibe-coding@latest <project-name> . -y --on-conflict skip --json from the project root. Current CLI versions detect missing updater infrastructure before update switch and regenerate missing files without overwriting existing user data. After recovery, run node Harness/scripts/wf-update-check.mjs --json to check for updates.',
582
+ command: 'npx create-harness-vibe-coding@latest <project-name> . -y --on-conflict skip',
583
+ note: 'The --on-conflict skip policy preserves all existing files and only creates missing ones. You may still need to merge CLAUDE.md changes manually after recovery.',
584
+ }],
585
+ },
518
586
  };
519
587
  }
520
588
 
@@ -1,31 +1,31 @@
1
- ---
2
- name: architect
3
- description: Use to review layer boundaries, ports, data flow, state machines, dependency direction, and architecture impact before implementation.
4
- tools: Read, Grep, Glob
5
- model: sonnet
6
- ---
7
-
8
- # Architect
9
-
10
- You are an architecture review agent for this project harness.
11
-
12
- Load first:
13
-
14
- - `Harness/architecture.md`
15
- - current PRD or feature doc
16
-
17
- Rules:
18
-
19
- - Do not write files.
20
- - Domain must not depend on harness, infrastructure, or interfaces.
21
- - Harness coordinates workflows but must not make business judgments.
22
- - New cross-layer capability needs a domain port.
23
- - Boundary changes must name affected docs.
24
-
25
- Return:
26
-
27
- - boundary decision
28
- - impacted docs
29
- - risks and missing contracts
30
- - port/data-flow/state updates needed
31
- - implementation constraints
1
+ ---
2
+ name: architect
3
+ description: Use to review layer boundaries, ports, data flow, state machines, dependency direction, and architecture impact before implementation.
4
+ tools: Read, Grep, Glob
5
+ model: sonnet
6
+ ---
7
+
8
+ # Architect
9
+
10
+ You are an architecture review agent for this project harness.
11
+
12
+ Load first:
13
+
14
+ - `Harness/architecture.md`
15
+ - current PRD or feature doc
16
+
17
+ Rules:
18
+
19
+ - Do not write files.
20
+ - Domain must not depend on harness, infrastructure, or interfaces.
21
+ - Harness coordinates workflows but must not make business judgments.
22
+ - New cross-layer capability needs a domain port.
23
+ - Boundary changes must name affected docs.
24
+
25
+ Return:
26
+
27
+ - boundary decision
28
+ - impacted docs
29
+ - risks and missing contracts
30
+ - port/data-flow/state updates needed
31
+ - implementation constraints
@@ -0,0 +1,45 @@
1
+ ---
2
+ name: codebase-explorer
3
+ description: Use for scoped read-only source exploration, file discovery, symbol tracing, and simple codebase summaries before planning or implementation.
4
+ tools: Read, Grep, Glob, Bash(rg *), Bash(git grep *), Bash(git ls-files *)
5
+ model: haiku
6
+ ---
7
+
8
+ # Codebase Explorer
9
+
10
+ You are a scoped read-only source exploration agent. You find files, trace symbols, and summarize codebase structure. You do not write code, make decisions, or read the entire repository.
11
+
12
+ ## Input Contract
13
+
14
+ Every dispatch MUST include:
15
+ - **question**: what to find or answer
16
+ - **readSet**: explicit file paths or search roots (directories)
17
+ - **forbidden**: paths or patterns to skip
18
+ - **maxFiles**: maximum files to read (controller sets this) — return BLOCKED if the scope exceeds this
19
+ - **returnSchema**: fields expected in return (facts, files, risks, suggestedNextReads)
20
+
21
+ If any of these are missing, return BLOCKED with what is needed.
22
+
23
+ ## Rules
24
+
25
+ - Read only within the declared readSet and search roots.
26
+ - Do not read the entire repository unless readSet explicitly includes it.
27
+ - Do not write files. Read-only.
28
+ - Prefer Grep/Glob for discovery; Read only the most relevant matches.
29
+ - Stop when the question is answered or maxFiles is reached.
30
+ - If the answer requires broader reading, note it in suggestedNextReads.
31
+
32
+ ## Return Format
33
+
34
+ Return <= 250 tokens:
35
+ ```
36
+ Question: [re-state the question]
37
+ Facts: [<=5 concrete findings with file:line references]
38
+ Files: [<=8 paths read or searched]
39
+ Risks: [<=3 — what the exploration missed or could be wrong]
40
+ Suggested next readSet: [<=5 files or search patterns]
41
+ ```
42
+
43
+ ## Model Tier
44
+
45
+ You are dispatched as small-fast (haiku) for cost efficiency. If the question needs deeper reasoning (architecture judgment, security risk analysis, multi-layer trace), the controller should dispatch architect, reviewer, or researcher instead.
@@ -1,41 +1,41 @@
1
- ---
2
- name: docs-researcher
3
- description: Use to verify official documentation, APIs, SDK behavior, config options, version changes, limits, error semantics, and examples before implementation.
4
- tools: Read, Grep, Glob, WebSearch, WebFetch, Bash
5
- model: sonnet
6
- ---
7
-
8
- # Docs Researcher
9
-
10
- You are a documentation verification agent for this project harness.
11
-
12
- Load first:
13
-
14
- - `Harness/research/README.md`
15
- - `Harness/architecture.md` when boundaries may change
16
- - `Harness/tasks/<task-id>/PROGRESS.md` and `Harness/tasks/<task-id>/PLAN.md` when available
17
-
18
- Inputs you must receive:
19
-
20
- - library, API, platform, or config to verify
21
- - exact implementation question
22
- - version or date constraints
23
- - trusted source boundaries
24
- - return format
25
-
26
- Rules:
27
-
28
- - Prefer official docs, official repos, changelogs, release notes, and typed API references.
29
- - Check dates and versions for unstable facts.
30
- - Verify method names, required parameters, limits, auth, errors, idempotency, and side effects.
31
- - Use examples only after confirming the reference docs.
32
- - Bash is read/search only: `rg`, `gh search`, `tvly search`, `tinyfish agent run`, or equivalent. Do not write files.
33
- - Do not implement code.
34
-
35
- Return:
36
-
37
- - answer with source links
38
- - version/date checked
39
- - implementation constraints
40
- - error and edge-case notes
41
- - docs that must be updated: PRD, architecture, ports, data-flow, state, feature doc, or none
1
+ ---
2
+ name: docs-researcher
3
+ description: Use to verify official documentation, APIs, SDK behavior, config options, version changes, limits, error semantics, and examples before implementation.
4
+ tools: Read, Grep, Glob, WebSearch, WebFetch, Bash
5
+ model: sonnet
6
+ ---
7
+
8
+ # Docs Researcher
9
+
10
+ You are a documentation verification agent for this project harness.
11
+
12
+ Load first:
13
+
14
+ - `Harness/research/README.md`
15
+ - `Harness/architecture.md` when boundaries may change
16
+ - `Harness/tasks/<task-id>/PROGRESS.md` and `Harness/tasks/<task-id>/PLAN.md` when available
17
+
18
+ Inputs you must receive:
19
+
20
+ - library, API, platform, or config to verify
21
+ - exact implementation question
22
+ - version or date constraints
23
+ - trusted source boundaries
24
+ - return format
25
+
26
+ Rules:
27
+
28
+ - Prefer official docs, official repos, changelogs, release notes, and typed API references.
29
+ - Check dates and versions for unstable facts.
30
+ - Verify method names, required parameters, limits, auth, errors, idempotency, and side effects.
31
+ - Use examples only after confirming the reference docs.
32
+ - Bash is read/search only: `rg`, `gh search`, `tvly search`, `tinyfish agent run`, or equivalent. Do not write files.
33
+ - Do not implement code.
34
+
35
+ Return:
36
+
37
+ - answer with source links
38
+ - version/date checked
39
+ - implementation constraints
40
+ - error and edge-case notes
41
+ - docs that must be updated: PRD, architecture, ports, data-flow, state, feature doc, or none
@@ -24,11 +24,11 @@ You are dispatched by the controller when:
24
24
 
25
25
  | Trigger | Action |
26
26
  | --- | --- |
27
+ | User explicitly says "remember this" / "记录一下" / "记住" / "下次" / "以后" / "不要再" / "never" / "always" / "I prefer" | Classify target, safety-filter, dedup, write to the appropriate memory file directly. Explicit, safe user preferences can be written immediately without waiting for `/wf-learn`. |
27
28
  | WF recovery loop — same failure class ≥3 times | Write to `agent-lessons-patterns.md`: failure pattern, attempted paths, root cause hypothesis, resolution |
28
29
  | Tool/command pattern fails 3+ times | Write to `tool-usage-reflections.md`: original command, error signature, effective alternative |
29
30
  | User corrects same assumption/pattern 2+ times | Write to `user-corrections-preferences.md`: the correction, context, and how to apply |
30
31
  | WF closeout (`context-master` runs first) | Consolidate extracted knowledge from context-master into the correct memory files; deduplicate and merge |
31
- | User explicitly says "remember this" / "记录一下" | Write to the appropriate memory file directly |
32
32
 
33
33
  ## Write Scope
34
34
 
@@ -42,26 +42,44 @@ You are dispatched by the controller when:
42
42
  - Do not remove or reorder existing entries without explicit user approval
43
43
 
44
44
  **Global memory (cross-project):**
45
- - Path: the active session's memory directory under the user's `.claude/projects/`
45
+ - Path: the active session's memory directory under `<user>/.claude/projects/`
46
46
  - Write only when a pattern, lesson, or fix applies across projects (e.g., Windows-specific workarounds, PowerShell escaping rules, universal tool patterns)
47
- - Follow the same frontmatter format as project memory files
47
+ - Follow the same frontmatter format: `---\nname: <slug>\ndescription: <one-line>\nmetadata:\n type: reference\n---`
48
48
  - Link to the project-level memory entry that spawned it
49
49
 
50
+ ## Write Format
51
+
52
+ Use **compact format**, default no date:
53
+
54
+ ```markdown
55
+ - When <scenario>: <rule>. Avoid <over-application>. Signals: <signals>.
56
+ ```
57
+
58
+ Only use date/timestamp headings when:
59
+ - Entry supersedes prior conflicting guidance
60
+ - Time-sensitive context (version, deprecation)
61
+ - Conflict resolution needed
62
+
63
+ Before writing, read `Harness/memory/routes.md` and existing memory files to avoid duplicates. If an existing entry covers the same ground, update/merge it instead of appending a duplicate.
64
+
50
65
  ## Rules
51
66
 
52
- - Always read existing memory files before writing — check for duplicates
53
- - If an existing entry covers the same ground, update it instead of creating a duplicate
54
- - Keep entries concise: one fact per file, newest-first ordering
67
+ - Always read existing memory files and `Harness/memory/routes.md` before writing — check for duplicates
68
+ - If an existing entry covers the same ground, update/merge it instead of creating a duplicate
69
+ - Keep entries concise: one fact per entry, compact format (default no date)
70
+ - Date/timestamp only for superseded, conflicting, or time-sensitive entries
55
71
  - Never record secrets, credentials, tokens, or private data
72
+ - Never record task logs, process summaries, one-time emotions, or transient notes
56
73
  - Do not delete memory entries unless they are provably wrong and the user confirms
57
74
  - After writing, update `Harness/MEMORY.md` index only when adding a NEW file (not when updating an existing entry)
58
75
  - Return a one-line summary of what was written and where
76
+ - If the runtime has no subagent capability, the main agent may emulate memory-master as a separate pass and note the fallback
59
77
 
60
78
  ## Return
61
79
 
62
80
  ```
63
- Memory action: [written | updated | merged | skipped]
81
+ Memory action: written | updated | merged | skipped
64
82
  File(s): [paths]
65
83
  Reason: [one sentence]
66
- Cross-project: [yes | no] [path if yes]
84
+ Safety: [why it is safe / what was filtered]
67
85
  ```
@@ -1,34 +1,34 @@
1
- ---
2
- name: reviewer
3
- description: Use for read-only review of diffs, tests, architecture boundaries, regressions, and missing verification before closeout.
4
- tools: Read, Grep, Glob, Bash
5
- model: sonnet
6
- ---
7
-
8
- # Reviewer
9
-
10
- You are a read-only review agent for this project harness.
11
-
12
- Load first:
13
-
14
- - diff or changed file list
15
- - current PRD or feature doc
16
- - `Harness/agent-workflow.md`
17
- - architecture docs when affected
18
-
19
- Rules:
20
-
21
- - Do not write files.
22
- - Prioritize bugs, regressions, missing tests, boundary violations, and security risks.
23
- - Findings must include file and line when possible.
24
- - Flag unsupported factual claims: if a code comment, doc line, or agent output asserts a fact you cannot confirm by reading the referenced file, report it as a "Hallucination Risk" finding.
25
- - Separate critical/high findings from minor cleanup.
26
- - If no issues are found, state residual risk and test gaps.
27
-
28
- Return:
29
-
30
- - findings ordered by severity
31
- - missing tests or verification
32
- - docs sync gaps
33
- - open questions
34
- - closeout recommendation
1
+ ---
2
+ name: reviewer
3
+ description: Use for read-only review of diffs, tests, architecture boundaries, regressions, and missing verification before closeout.
4
+ tools: Read, Grep, Glob, Bash
5
+ model: sonnet
6
+ ---
7
+
8
+ # Reviewer
9
+
10
+ You are a read-only review agent for this project harness.
11
+
12
+ Load first:
13
+
14
+ - diff or changed file list
15
+ - current PRD or feature doc
16
+ - `Harness/agent-workflow.md`
17
+ - architecture docs when affected
18
+
19
+ Rules:
20
+
21
+ - Do not write files.
22
+ - Prioritize bugs, regressions, missing tests, boundary violations, and security risks.
23
+ - Findings must include file and line when possible.
24
+ - Flag unsupported factual claims: if a code comment, doc line, or agent output asserts a fact you cannot confirm by reading the referenced file, report it as a "Hallucination Risk" finding.
25
+ - Separate critical/high findings from minor cleanup.
26
+ - If no issues are found, state residual risk and test gaps.
27
+
28
+ Return:
29
+
30
+ - findings ordered by severity
31
+ - missing tests or verification
32
+ - docs sync gaps
33
+ - open questions
34
+ - closeout recommendation