create-harness-vibe-coding 0.7.2 → 0.8.0

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 +91 -155
  2. package/README.md +200 -177
  3. package/bin/create-harness-vibe-coding.js +2 -2
  4. package/package.json +45 -43
  5. package/src/generator.js +115 -77
  6. package/src/index.js +159 -49
  7. package/src/prompts.js +95 -27
  8. package/templates/common/.claude/agents/architect-manager.md +45 -45
  9. package/templates/common/.claude/agents/context-master.md +77 -77
  10. package/templates/common/.claude/agents/debugger.md +41 -41
  11. package/templates/common/.claude/agents/explore-manager.md +41 -41
  12. package/templates/common/.claude/agents/implement-manager.md +49 -49
  13. package/templates/common/.claude/agents/implementer.md +40 -40
  14. package/templates/common/.claude/agents/memory-master.md +66 -66
  15. package/templates/common/.claude/agents/planner.md +34 -34
  16. package/templates/common/.claude/agents/researcher.md +41 -41
  17. package/templates/common/.claude/agents/review-manager.md +56 -56
  18. package/templates/common/.claude/agents/test-writer.md +38 -38
  19. package/templates/common/.claude/agents/verifier.md +32 -32
  20. package/templates/common/.claude/rules/ecc/common.md +45 -45
  21. package/templates/common/.claude/settings.json +68 -68
  22. package/templates/common/.claude/skills/subagent-orchestrator/SKILL.md +36 -31
  23. package/templates/common/.claude/skills/wf/SKILL.md +36 -0
  24. package/templates/common/.claude/skills/wf-learn/SKILL.md +13 -28
  25. package/templates/common/.claude/skills/wf-max/SKILL.md +24 -88
  26. package/templates/common/.claude/skills/wf-readme/SKILL.md +49 -49
  27. package/templates/common/.claude/skills/wf-remove/SKILL.md +17 -38
  28. package/templates/common/.claude/skills/wf-review/SKILL.md +19 -69
  29. package/templates/common/.claude/skills/wf-update/SKILL.md +19 -61
  30. package/templates/common/.codex/config.toml +2 -2
  31. package/templates/common/.codex/hooks.json +37 -37
  32. package/templates/common/.harness-version +53 -51
  33. package/templates/common/AGENTS.md +30 -30
  34. package/templates/common/CLAUDE.md +94 -94
  35. package/templates/common/{docs/harness → Harness}/PROGRESS.md +17 -17
  36. package/templates/common/{docs → Harness}/README.md +18 -17
  37. package/templates/common/{docs/harness → Harness}/WF-MAX.md +223 -223
  38. package/templates/common/Harness/WF.md +217 -0
  39. package/templates/common/{docs/harness → Harness}/architecture.md +126 -126
  40. package/templates/common/{docs/harness → Harness}/dispatch.md +99 -99
  41. package/templates/common/{docs → Harness}/research/research-results.md +66 -66
  42. package/templates/common/{docs/harness → Harness}/subagents.md +194 -194
  43. package/templates/common/{docs → Harness}/tasks/_template/ARTIFACTS.md +3 -3
  44. package/templates/common/{docs → Harness}/tasks/_template/NOTES.md +3 -3
  45. package/templates/common/{docs → Harness}/tasks/_template/PLAN.md +40 -40
  46. package/templates/common/{docs → Harness}/tasks/_template/PROGRESS.md +29 -29
  47. package/templates/common/MEMORY.md +68 -66
  48. package/templates/common/README.md +44 -37
  49. package/templates/common/SETUP.md +41 -34
  50. package/templates/common/memory/agent-lessons-patterns.md +21 -21
  51. package/templates/common/memory/tool-usage-reflections.md +21 -21
  52. package/templates/common/memory/user-corrections-preferences.md +21 -21
  53. package/templates/common/scripts/scan-clean.mjs +450 -449
  54. package/templates/common/scripts/validate-harness.mjs +56 -34
  55. package/templates/common/scripts/wf-mode-hook.mjs +318 -318
  56. package/templates/common/scripts/wf-remove.mjs +400 -384
  57. package/templates/common/scripts/wf-statusline.ps1 +38 -38
  58. package/templates/common/scripts/wf-statusline.sh +48 -48
  59. package/templates/common/scripts/wf-update-check.mjs +389 -389
  60. package/templates/optional/catalog.json +63 -29
  61. package/templates/optional/skills/browser-e2e/.claude/skills/wf-browser/SKILL.md +194 -194
  62. package/templates/optional/skills/browser-e2e/{docs → Harness}/workflows/browser-e2e.md +75 -75
  63. package/templates/optional/skills/github-pr-review/{docs → Harness}/workflows/github-pr-review.md +28 -28
  64. package/templates/optional/skills/python-backend/{docs → Harness}/workflows/python-backend.md +34 -34
  65. package/templates/optional/skills/ts-react-frontend/{docs → Harness}/workflows/ts-react-frontend.md +35 -35
  66. package/templates/optional/skills/ui-ux-review/{docs → Harness}/workflows/ui-ux-review.md +26 -26
  67. package/templates/common/.claude/commands/wf-learn.md +0 -17
  68. package/templates/common/.claude/commands/wf-max.md +0 -49
  69. package/templates/common/.claude/commands/wf-remove.md +0 -23
  70. package/templates/common/.claude/commands/wf-review.md +0 -25
  71. package/templates/common/.claude/commands/wf-update.md +0 -17
  72. package/templates/common/.claude/commands/wf.md +0 -31
  73. package/templates/common/commands/wf-max.toml +0 -18
  74. package/templates/common/commands/wf-review.toml +0 -15
  75. package/templates/common/docs/harness/WF.md +0 -174
  76. package/templates/optional/skills/browser-e2e/.claude/commands/wf-browser.md +0 -25
  77. /package/templates/common/{docs/harness → Harness}/agent-workflow.md +0 -0
  78. /package/templates/common/{docs/harness → Harness}/context-loading.md +0 -0
  79. /package/templates/common/{docs/harness → Harness}/extension.md +0 -0
  80. /package/templates/common/{docs/harness → Harness}/lifecycle.md +0 -0
  81. /package/templates/common/{docs → Harness}/research/PRD.md +0 -0
  82. /package/templates/common/{docs → Harness}/research/README.md +0 -0
@@ -0,0 +1,217 @@
1
+ # WF Mode - Long Task Workflow
2
+
3
+ Use this when work is long, difficult, uncertain, multi-file, multi-agent, or
4
+ user-triggered with `/wf`, `$wf`, `wf mode`, `workflow mode`, or `wk mode`.
5
+
6
+ This is a Ralph-style harness loop: keep moving through evidence, bounded
7
+ exploration, second planning, implementation, review, verification, and recovery
8
+ instead of stalling on the first obstacle.
9
+
10
+ ## Trigger
11
+
12
+ Enter WF mode when any of these are true:
13
+
14
+ - The user explicitly says `/wf`, `$wf`, `wf mode`, `workflow mode`, `wk mode`,
15
+ or asks for the full workflow.
16
+ - The task needs more than one step, more than three files, or more than one
17
+ subsystem.
18
+ - The task needs research, architecture judgment, browser/API validation, or
19
+ migration planning.
20
+ - Confidence in intent, architecture, or implementation is below 95%.
21
+ - The same command, test, tool, or approach fails twice.
22
+ - The user explicitly says `/wf-max [task]`, `$wf-max [task]`, or `wf max` (for
23
+ maximum-parallelism mode, see [WF-MAX.md](WF-MAX.md)).
24
+
25
+ Two distinct trigger classes; do not conflate them:
26
+
27
+ - Explicit invocation (`/wf`, `$wf`, `wf mode`, `workflow mode`, `wk mode`,
28
+ `/wf-max`, `$wf-max`): role fan-out is mandatory and unconditional. File
29
+ count, task size, and subsystem count are irrelevant. A one-file task invoked
30
+ with WF still uses at least three role passes before the second plan.
31
+ - Auto-triggering decides whether the harness enters WF mode on its own. It can
32
+ only escalate into WF, never downgrade an explicit command out of WF.
33
+
34
+ ## Multi-Subagent Requirement
35
+
36
+ WF mode requires multi-subagent orchestration by default.
37
+
38
+ Normative rule: Explicit `/wf`, `$wf`, `wf mode`, `workflow mode`, or `wk mode` MUST use at least 3 distinct role passes before second planning.
39
+
40
+ - Explicit `/wf`, `$wf`, `wf mode`, `workflow mode`, or `wk mode` MUST use at
41
+ least 3 distinct role passes before second planning. Use real subagents when
42
+ the runtime supports them; otherwise emulate those roles as bounded passes and
43
+ record the fallback.
44
+ - Runtime mapping:
45
+ - Claude Code: prefer subagents from `.claude/agents/`.
46
+ - Codex: prefer the available Codex subagent surface; if unavailable, use
47
+ bounded passes with the same roles and evidence contract.
48
+ - Collaboration decision tree (replaces the old "7:3" heuristic with concrete
49
+ conditions):
50
+ - Explicit WF/WK mode -> always multi-role, no exceptions.
51
+ - 3+ files changed -> multi-role at minimum: planner, implementer, reviewer.
52
+ - Cross-layer change -> architect plus implementers plus reviewer.
53
+ - Uncertain scope or approach -> planner plus researcher plus architect.
54
+ - 1-2 files, well-understood, not in WF mode -> solo is acceptable.
55
+ - Repeated failure on the same task -> stop solo and switch to multi-role.
56
+ - Default initial fan-out: `planner`, `researcher` or `docs-researcher`, and
57
+ `architect`. Add `test-writer`, `reviewer`, `debugger`, or `verifier` when
58
+ the phase needs them.
59
+
60
+ ## Exploration Gate
61
+
62
+ - [ ] Controller has not read source files directly; only Harness docs, root
63
+ agent entries, and subagent or bounded-pass returns.
64
+ - [ ] At least 3 distinct role types, each with one specific question.
65
+ - [ ] Role passes were dispatched together when the runtime supports parallel
66
+ dispatch.
67
+ - [ ] Agent count is at least `max(3, ceil(estimated_dirs / 2))`; estimate from
68
+ prompt/docs and run a second wave if returns reveal more.
69
+ - [ ] Fallbacks are recorded in `Harness/tasks/<task-id>/PLAN.md`.
70
+
71
+ For maximum-parallelism mode (write-set coloring, wave dispatch, parallel
72
+ reviewers), use `/wf-max [task]` in Claude Code or `$wf-max [task]` in Codex and
73
+ see [WF-MAX.md](WF-MAX.md).
74
+
75
+ ## WF Loop
76
+
77
+ ```text
78
+ Intake
79
+ -> confidence gate
80
+ -> parallel planner / researcher / docs-researcher / architect roles
81
+ -> synthesis
82
+ -> second plan
83
+ -> test-writer
84
+ -> implementer
85
+ -> reviewers
86
+ -> verifier
87
+ -> if failed: debugger -> review -> e2e/API verification -> loop
88
+ -> close with evidence
89
+ ```
90
+
91
+ ## Intake
92
+
93
+ 1. Read `CLAUDE.md`, `Harness/MEMORY.md`, `Harness/README.md`,
94
+ `Harness/PROGRESS.md`, and the active task capsule if present.
95
+ 2. State the goal, non-goals, confidence level, known risks, and write
96
+ boundaries.
97
+ 3. Ask up to three blocking questions only when the next action cannot reach
98
+ 95% confidence.
99
+ 4. Update `Harness/tasks/<task-id>/PROGRESS.md#Heartbeat` before dispatching
100
+ roles or running long commands.
101
+ 5. Load `Harness/subagents.md` before coordinating multiple roles.
102
+
103
+ ## Exploration
104
+
105
+ Use read-only role passes first. For automatic WF triggers, default to 3-5
106
+ active agents or bounded passes unless the task is clearly small enough for the
107
+ solo exception.
108
+
109
+ | Role | Purpose | Writes |
110
+ | --- | --- | --- |
111
+ | `planner` | map local project facts, commands, app entry points, existing docs, and initial decomposition | none |
112
+ | `researcher` | product, ecosystem, dependency, and external context | none unless returning a docs patch |
113
+ | `docs-researcher` | official docs, SDK/API versions, browser/tool limits | none unless returning a docs patch |
114
+ | `architect` | boundaries, ports, data flow, state impact, migration risks | none unless returning a docs patch |
115
+
116
+ Use local files first. Use web search or official docs only when the decision
117
+ needs current or external evidence. Record tool choice and limitations in
118
+ `Harness/research/research-results.md` or the task plan.
119
+
120
+ ## Subagent Orchestration
121
+
122
+ Use `Harness/subagents.md` as the orchestration methodology and
123
+ `Harness/dispatch.md` as the dispatch table protocol.
124
+
125
+ - The main agent is the controller and owns synthesis, integration, and final
126
+ verification.
127
+ - Subagents are readers and reporters. Only the main agent writes task
128
+ `PROGRESS.md` and `PLAN.md`.
129
+ - Parallelize read-only exploration; serialize writers unless write sets are
130
+ disjoint and isolated.
131
+ - Every role gets a dispatch pack with role, goal, mode, read set, write set,
132
+ forbidden scope, injected docs, evidence, stop condition, and return format.
133
+ - After implementation, run spec review before code-quality or architecture
134
+ review.
135
+ - If subagents are unavailable, emulate the same roles as bounded passes and
136
+ record the fallback.
137
+
138
+ ## Second Plan
139
+
140
+ After exploration, synthesize facts found, assumptions, risks,
141
+ accepted/rejected options, tasks, read/write sets, verification path, and
142
+ rollback or recovery plan.
143
+
144
+ Write the result to `Harness/tasks/<task-id>/PLAN.md` before implementation.
145
+ Update `Harness/tasks/<task-id>/PROGRESS.md#Heartbeat`.
146
+
147
+ ## Build And Review
148
+
149
+ 1. `test-writer` defines a failing test or written manual check first.
150
+ 2. `implementer` changes only the declared write set.
151
+ 3. At least one `reviewer` checks diff, architecture, risks, and missing tests.
152
+ 4. For cross-layer or risky work, run separate reviewers for architecture and
153
+ test adequacy.
154
+ 5. `verifier` runs the declared checks and records exact evidence.
155
+
156
+ ## Browser And API Evidence
157
+
158
+ For browser-visible changes, typecheck/build/unit tests are not enough. Use
159
+ Chrome DevTools, CDP, Playwright, or a documented real-browser run:
160
+
161
+ - start the app and record URL/port
162
+ - click through the critical flow
163
+ - capture frontend console/runtime errors
164
+ - capture failed network requests
165
+ - collect backend logs when the flow crosses an API
166
+ - record screenshot, trace, video, or manual evidence path
167
+
168
+ For API changes, run the project API/integration test path or a documented real
169
+ request against a local service and record request, response, logs, and failure
170
+ behavior.
171
+
172
+ ## Recovery Loop
173
+
174
+ If verification fails:
175
+
176
+ 1. Update `Harness/tasks/<task-id>/PROGRESS.md#Heartbeat` with failure count
177
+ and blocker.
178
+ 2. Dispatch `debugger` with the failing command, error output, and smallest
179
+ relevant files.
180
+ 3. Fix the smallest reproduced failure.
181
+ 4. Run reviewer again.
182
+ 5. Run verifier again.
183
+ 6. Repeat until verified or blocked by missing user input/external state.
184
+
185
+ Before asking the user after repeated failures, run the context-master then
186
+ memory-master learning cycle or use `wf-learn`.
187
+
188
+ ## Heartbeat Protocol
189
+
190
+ Heartbeat is a lightweight recovery protocol, not a background daemon.
191
+
192
+ Update `Harness/tasks/<task-id>/PROGRESS.md#Heartbeat`:
193
+
194
+ - before a long command
195
+ - after a long command
196
+ - before spawning subagents or bounded passes
197
+ - after integrating returns
198
+ - after each failed verification
199
+ - before stopping for user input
200
+
201
+ When context approaches about 85% of the window, run context-master or the
202
+ equivalent bounded pass to append a compression suggestion to the task heartbeat.
203
+
204
+ ## Closeout
205
+
206
+ Close only when:
207
+
208
+ - acceptance criteria are satisfied
209
+ - reviewer has no unresolved critical/high findings
210
+ - test/API/browser evidence is recorded
211
+ - affected Harness docs are synced
212
+ - context-master has analyzed the session and extracted durable knowledge
213
+ - memory-master has consolidated extracted knowledge into `Harness/memory/*`
214
+ - current task PROGRESS.md and PLAN.md are archived under `Harness/tasks/<task-id>/`
215
+ with Phase set to Verified
216
+ - `Harness/PROGRESS.md` task index is updated and Active Task is cleared or set
217
+ to the next task
@@ -1,126 +1,126 @@
1
- # Harness Architecture - create-harness-vibe-coding
2
-
3
- > **Responsibility**: Define the repository structure and scaffold generation boundaries.
4
- > **Does NOT cover**: Generated target-project business architecture.
5
-
6
- ---
7
-
8
- ## 1. Layering Rules
9
-
10
- ```text
11
- bin/
12
- CLI executable shim. Calls src/index.js.
13
-
14
- src/
15
- CLI orchestration and scaffold generation logic.
16
- May read templates/ and write the chosen target directory.
17
-
18
- templates/
19
- Source of generated scaffold assets.
20
- Must stay declarative: markdown, skill files, agent files, scripts, and optional workflow docs.
21
-
22
- Harness/ and .claude/
23
- Dogfood runtime for this repository's own agent work.
24
- Must not be treated as package source unless intentionally copied into templates/.
25
-
26
- tests/
27
- Node test suite for CLI behavior, generator behavior, package contents, and generated harness validation.
28
- ```
29
-
30
- Hard constraints:
31
-
32
- - `templates/common/**` and `templates/optional/**` are the source of generated output.
33
- - Root `Harness/**` is this repository's operating harness; changing it does not change generated projects.
34
- - Generated output paths are normalized by `harnessDest()` in `src/generator.js`.
35
- - Existing-project safety is owned by conflict planning in `src/generator.js`, not by template prose alone.
36
- - Package publication is constrained by `package.json#files`; root dogfood files are not package contents.
37
-
38
- ## 2. Interface Decoupling
39
-
40
- Use interfaces and module boundaries to protect real seams in the generator, not to decorate straightforward code.
41
-
42
- - `src/index.js` owns CLI/user interaction; `src/generator.js` owns planning and file writes.
43
- - Template files are declarative inputs; source code should not depend on root dogfood `Harness/**`.
44
- - Optional catalog structure is the extension contract for presets and optional skills.
45
- - Avoid speculative abstraction: do not add plugin systems, generic runners, extra config layers, or service containers until a real second use or testability boundary exists.
46
- - When a boundary is real, express it with a small data contract and test it through generated output behavior.
47
-
48
- ## 3. State Design
49
-
50
- State in this repo should be explicit, serializable, and owned by one layer.
51
-
52
- - Generator plan state is computed in memory and returned as `plan`/`summary`; file writes consume that plan instead of re-deciding conflicts.
53
- - Filesystem state is authoritative only through existence/type checks and write results.
54
- - Optional selection state comes from CLI flags plus `templates/optional/catalog.json`; do not duplicate it in template prose.
55
- - Release state lives in `package.json`, npm, git tags, and GitHub; document commands in `README.md`, not `CLAUDE.md`.
56
- - Long-running agent work records resumable status in `Harness/tasks/<task-id>/PLAN.md#Heartbeat`.
57
-
58
- ## 4. Core Components
59
-
60
- ### 4.1 CLI Entry
61
-
62
- - **Location**: `bin/create-harness-vibe-coding.js`, `src/index.js`
63
- - **Responsibility**: Parse flags, handle interactive/non-interactive modes, print plans/results, and call the generator.
64
- - **Does NOT handle**: Template walking, conflict classification, or file writing internals.
65
-
66
- ### 4.2 Prompt Layer
67
-
68
- - **Location**: `src/prompts.js`
69
- - **Responsibility**: Ask basic interactive npx questions: project name and target directory.
70
- - **Does NOT handle**: Agent-link install intake. That matrix is read by coding agents from `README.md` and `Harness/SETUP.md`.
71
-
72
- ### 4.3 Generator Core
73
-
74
- - **Location**: `src/generator.js`
75
- - **Responsibility**: Resolve optional selections, map template paths to destination paths, detect conflicts, render templates, register optional workflows, and write files.
76
- - **Critical functions**:
77
- - `harnessDest()` maps legacy template source paths such as `docs/harness/*` into generated root `Harness/*`.
78
- - `createPlan()` and `addFileActions()` classify directories and file actions before writes.
79
- - `registerOptionalContent()` updates generated router/memory docs when optional workflows are selected.
80
-
81
- ### 4.4 Template Assets
82
-
83
- - **Location**: `templates/common/**`, `templates/optional/**`
84
- - **Responsibility**: Define generated `CLAUDE.md`, `AGENTS.md`, `README.md`, `Harness/**`, `.claude/**`, optional skills, and optional workflows.
85
- - **Does NOT handle**: Existing-project decisions. Templates state contracts; generator and agents apply them safely.
86
-
87
- ### 4.5 Validator
88
-
89
- - **Source template**: `templates/common/scripts/validate-harness.mjs`
90
- - **Generated location**: `Harness/scripts/validate-harness.mjs`
91
- - **Responsibility**: Validate required scaffold files, skill/agent registrations, router invariants, optional workflow registrations, and strict project-fact placeholders.
92
-
93
- ### 4.6 Dogfood Runtime
94
-
95
- - **Location**: root `Harness/**`, `.claude/**`, `CLAUDE.md`, `AGENTS.md`, `MEMORY.md`
96
- - **Responsibility**: Govern future AI-agent work in this repository.
97
- - **Does NOT handle**: Changing package output unless edits are made to `templates/**` or source code.
98
-
99
- ## 5. Data Flow
100
-
101
- ```text
102
- CLI args / prompts
103
- -> src/index.js parse and display
104
- -> src/generator.js resolve optional catalog
105
- -> walk templates/common and selected templates/optional
106
- -> harnessDest maps source paths to generated destinations
107
- -> createPlan/addFileActions classify create/skip/backup/overwrite/conflict
108
- -> renderTemplate substitutes projectName
109
- -> registerOptionalContent updates generated Harness router/memory
110
- -> write files or return dry-run/json plan
111
- -> tests and generated validator verify behavior
112
- ```
113
-
114
- ## 6. Architectural Constraints
115
-
116
- - Do not add generated-output behavior by editing only root `Harness/`; edit `templates/common/**` or `templates/optional/**`.
117
- - Do not add user-facing CLI behavior without tests in `tests/cli-smoke.test.js` or `tests/generator.test.js`.
118
- - Do not add required generated files without updating `templates/common/scripts/validate-harness.mjs` and relevant tests.
119
- - Do not write Harness docs into generated `docs/`; `Harness/` is the generated root for harness-owned docs.
120
- - Do not make root `CLAUDE.md` a dumping ground for build commands, architecture, or release process.
121
-
122
- ## 7. Known Follow-Up Risks
123
-
124
- - Interactive confirmation currently happens before full conflict-plan display in interactive mode.
125
- - Some README tests assert exact prose and can be made more structural.
126
- - `subagent-orchestrator` routing priority should continue to be tightened in templates.
1
+ # Harness Architecture - create-harness-vibe-coding
2
+
3
+ > **Responsibility**: Define the repository structure and scaffold generation boundaries.
4
+ > **Does NOT cover**: Generated target-project business architecture.
5
+
6
+ ---
7
+
8
+ ## 1. Layering Rules
9
+
10
+ ```text
11
+ bin/
12
+ CLI executable shim. Calls src/index.js.
13
+
14
+ src/
15
+ CLI orchestration and scaffold generation logic.
16
+ May read templates/ and write the chosen target directory.
17
+
18
+ templates/
19
+ Source of generated scaffold assets.
20
+ Must stay declarative: markdown, skill files, agent files, scripts, and optional workflow docs.
21
+
22
+ Harness/ and .claude/
23
+ Dogfood runtime for this repository's own agent work.
24
+ Must not be treated as package source unless intentionally copied into templates/.
25
+
26
+ tests/
27
+ Node test suite for CLI behavior, generator behavior, package contents, and generated harness validation.
28
+ ```
29
+
30
+ Hard constraints:
31
+
32
+ - `templates/common/**` and `templates/optional/**` are the source of generated output.
33
+ - Root `Harness/**` is this repository's operating harness; changing it does not change generated projects.
34
+ - Generated output paths are normalized by `harnessDest()` in `src/generator.js`.
35
+ - Existing-project safety is owned by conflict planning in `src/generator.js`, not by template prose alone.
36
+ - Package publication is constrained by `package.json#files`; root dogfood files are not package contents.
37
+
38
+ ## 2. Interface Decoupling
39
+
40
+ Use interfaces and module boundaries to protect real seams in the generator, not to decorate straightforward code.
41
+
42
+ - `src/index.js` owns CLI/user interaction; `src/generator.js` owns planning and file writes.
43
+ - Template files are declarative inputs; source code should not depend on root dogfood `Harness/**`.
44
+ - Optional catalog structure is the extension contract for presets and optional skills.
45
+ - Avoid speculative abstraction: do not add plugin systems, generic runners, extra config layers, or service containers until a real second use or testability boundary exists.
46
+ - When a boundary is real, express it with a small data contract and test it through generated output behavior.
47
+
48
+ ## 3. State Design
49
+
50
+ State in this repo should be explicit, serializable, and owned by one layer.
51
+
52
+ - Generator plan state is computed in memory and returned as `plan`/`summary`; file writes consume that plan instead of re-deciding conflicts.
53
+ - Filesystem state is authoritative only through existence/type checks and write results.
54
+ - Optional selection state comes from CLI flags plus `templates/optional/catalog.json`; do not duplicate it in template prose.
55
+ - Release state lives in `package.json`, npm, git tags, and GitHub; document commands in `README.md`, not `CLAUDE.md`.
56
+ - Long-running agent work records resumable status in `Harness/tasks/<task-id>/PLAN.md#Heartbeat`.
57
+
58
+ ## 4. Core Components
59
+
60
+ ### 4.1 CLI Entry
61
+
62
+ - **Location**: `bin/create-harness-vibe-coding.js`, `src/index.js`
63
+ - **Responsibility**: Parse flags, handle interactive/non-interactive modes, print plans/results, and call the generator.
64
+ - **Does NOT handle**: Template walking, conflict classification, or file writing internals.
65
+
66
+ ### 4.2 Prompt Layer
67
+
68
+ - **Location**: `src/prompts.js`
69
+ - **Responsibility**: Ask basic interactive npx questions: project name and target directory.
70
+ - **Does NOT handle**: Agent-link install intake. That matrix is read by coding agents from `README.md` and `Harness/SETUP.md`.
71
+
72
+ ### 4.3 Generator Core
73
+
74
+ - **Location**: `src/generator.js`
75
+ - **Responsibility**: Resolve optional selections, keep Harness-owned template paths under `Harness/**`, detect conflicts, render templates, register optional workflows, and write files.
76
+ - **Critical functions**:
77
+ - `harnessDest()` keeps root entry files at root and Harness-owned files under generated root `Harness/*`.
78
+ - `createPlan()` and `addFileActions()` classify directories and file actions before writes.
79
+ - `registerOptionalContent()` updates generated router/memory docs when optional workflows are selected.
80
+
81
+ ### 4.4 Template Assets
82
+
83
+ - **Location**: `templates/common/**`, `templates/optional/**`
84
+ - **Responsibility**: Define generated `CLAUDE.md`, `AGENTS.md`, `README.md`, `Harness/**`, `.claude/**`, optional skills, and optional workflows.
85
+ - **Does NOT handle**: Existing-project decisions. Templates state contracts; generator and agents apply them safely.
86
+
87
+ ### 4.5 Validator
88
+
89
+ - **Source template**: `templates/common/scripts/validate-harness.mjs`
90
+ - **Generated location**: `Harness/scripts/validate-harness.mjs`
91
+ - **Responsibility**: Validate required scaffold files, skill/agent registrations, router invariants, optional workflow registrations, and strict project-fact placeholders.
92
+
93
+ ### 4.6 Dogfood Runtime
94
+
95
+ - **Location**: root `Harness/**`, `.claude/**`, `CLAUDE.md`, `AGENTS.md`, `MEMORY.md`
96
+ - **Responsibility**: Govern future AI-agent work in this repository.
97
+ - **Does NOT handle**: Changing package output unless edits are made to `templates/**` or source code.
98
+
99
+ ## 5. Data Flow
100
+
101
+ ```text
102
+ CLI args / prompts
103
+ -> src/index.js parse and display
104
+ -> src/generator.js resolve optional catalog
105
+ -> walk templates/common and selected templates/optional
106
+ -> harnessDest maps source paths to generated destinations
107
+ -> createPlan/addFileActions classify create/skip/backup/overwrite/conflict
108
+ -> renderTemplate substitutes projectName
109
+ -> registerOptionalContent updates generated Harness router/memory
110
+ -> write files or return dry-run/json plan
111
+ -> tests and generated validator verify behavior
112
+ ```
113
+
114
+ ## 6. Architectural Constraints
115
+
116
+ - Do not add generated-output behavior by editing only root `Harness/`; edit `templates/common/**` or `templates/optional/**`.
117
+ - Do not add user-facing CLI behavior without tests in `tests/cli-smoke.test.js` or `tests/generator.test.js`.
118
+ - Do not add required generated files without updating `templates/common/scripts/validate-harness.mjs` and relevant tests.
119
+ - Do not write Harness docs into generated `docs/`; `Harness/` is the generated root for harness-owned docs.
120
+ - Do not make root `CLAUDE.md` a dumping ground for build commands, architecture, or release process.
121
+
122
+ ## 7. Known Follow-Up Risks
123
+
124
+ - Interactive confirmation currently happens before full conflict-plan display in interactive mode.
125
+ - Some README tests assert exact prose and can be made more structural.
126
+ - `subagent-orchestrator` routing priority should continue to be tightened in templates.