repo-harness 0.4.1 → 0.4.3

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 (135) hide show
  1. package/AGENTS.md +1 -1
  2. package/CLAUDE.md +1 -1
  3. package/README.es.md +2 -2
  4. package/README.fr.md +2 -2
  5. package/README.ja.md +2 -2
  6. package/README.md +98 -51
  7. package/README.zh-CN.md +58 -39
  8. package/SKILL.md +2 -1
  9. package/assets/hooks/AGENTS.md +36 -0
  10. package/assets/hooks/CLAUDE.md +36 -0
  11. package/assets/hooks/anti-simplification.sh +4 -22
  12. package/assets/hooks/codex.hooks.template.json +6 -0
  13. package/assets/hooks/first-principles-guard.sh +72 -0
  14. package/assets/hooks/post-edit-guard.sh +4 -2
  15. package/assets/hooks/session-start-context.sh +30 -5
  16. package/assets/hooks/settings.template.json +6 -0
  17. package/assets/hooks/stop-orchestrator.sh +32 -1
  18. package/assets/hooks/subagent-return-channel-guard.sh +107 -0
  19. package/assets/partials/04-project-structure.partial.md +4 -4
  20. package/assets/partials/05-workflow.partial.md +6 -6
  21. package/assets/partials/08-orchestration.partial.md +7 -6
  22. package/assets/partials-agents/02-operating-mode.partial.md +4 -4
  23. package/assets/partials-agents/03-orchestration.partial.md +3 -2
  24. package/assets/partials-agents/04-task-protocol.partial.md +4 -4
  25. package/assets/partials-agents/06-quality-safety.partial.md +2 -2
  26. package/assets/reference-configs/agentic-development-flow.md +8 -6
  27. package/assets/reference-configs/document-generation.md +2 -1
  28. package/assets/reference-configs/external-tooling.md +11 -10
  29. package/assets/reference-configs/global-working-rules.md +18 -1
  30. package/assets/reference-configs/handoff-protocol.md +8 -7
  31. package/assets/reference-configs/harness-overview.md +25 -5
  32. package/assets/reference-configs/heartbeat-triage.md +5 -5
  33. package/assets/reference-configs/hook-operations.md +17 -7
  34. package/assets/reference-configs/sprint-contracts.md +10 -8
  35. package/assets/skill-commands/manifest.json +9 -2
  36. package/assets/skill-commands/repo-harness-architecture/SKILL.md +1 -1
  37. package/assets/skill-commands/repo-harness-check/SKILL.md +7 -7
  38. package/assets/skill-commands/repo-harness-deploy/SKILL.md +1 -1
  39. package/assets/skill-commands/repo-harness-handoff/SKILL.md +1 -1
  40. package/assets/skill-commands/repo-harness-init/SKILL.md +1 -1
  41. package/assets/skill-commands/repo-harness-plan/SKILL.md +2 -2
  42. package/assets/skill-commands/repo-harness-prd/SKILL.md +35 -0
  43. package/assets/skill-commands/repo-harness-ship/SKILL.md +3 -3
  44. package/assets/skill-commands/repo-harness-sprint/SKILL.md +21 -12
  45. package/assets/skill-version.json +10 -2
  46. package/assets/skills/claude-review/SKILL.md +8 -1
  47. package/assets/skills/codex-review/SKILL.md +8 -1
  48. package/assets/templates/contract.template.md +1 -1
  49. package/assets/templates/helpers/archive-workflow.sh +7 -1
  50. package/assets/templates/helpers/capture-plan.sh +7 -1
  51. package/assets/templates/helpers/check-agent-tooling.sh +11 -5
  52. package/assets/templates/helpers/check-brain-manifest.sh +12 -1
  53. package/assets/templates/helpers/check-skill-version.ts +3 -1
  54. package/assets/templates/helpers/check-task-workflow.sh +179 -37
  55. package/assets/templates/helpers/contract-worktree.sh +2 -0
  56. package/assets/templates/helpers/ensure-task-workflow.sh +186 -4
  57. package/assets/templates/helpers/heartbeat-triage.sh +51 -7
  58. package/assets/templates/helpers/inspect-project-state.ts +1 -1
  59. package/assets/templates/helpers/new-plan.sh +7 -1
  60. package/assets/templates/helpers/new-spec.sh +7 -1
  61. package/assets/templates/helpers/new-sprint.sh +11 -8
  62. package/assets/templates/helpers/plan-to-todo.sh +7 -1
  63. package/assets/templates/helpers/prepare-handoff.sh +7 -1
  64. package/assets/templates/helpers/refresh-current-status.sh +2 -1
  65. package/assets/templates/helpers/ship-worktrees.sh +2 -0
  66. package/assets/templates/helpers/sprint-backlog.sh +32 -16
  67. package/assets/templates/helpers/switch-plan.sh +7 -1
  68. package/assets/templates/helpers/verify-sprint.sh +7 -1
  69. package/assets/templates/helpers/workflow-contract.ts +19 -1
  70. package/assets/templates/plan.template.md +2 -2
  71. package/assets/templates/prd.template.md +165 -0
  72. package/assets/templates/sprint.template.md +8 -5
  73. package/assets/workflow-contract.v1.json +115 -47
  74. package/package.json +1 -2
  75. package/scripts/archive-workflow.sh +7 -1
  76. package/scripts/capture-plan.sh +7 -1
  77. package/scripts/check-agent-tooling.sh +11 -5
  78. package/scripts/check-brain-manifest.sh +12 -1
  79. package/scripts/check-npm-release.sh +3 -0
  80. package/scripts/check-skill-version.ts +3 -1
  81. package/scripts/check-task-workflow.sh +179 -37
  82. package/scripts/contract-worktree.sh +2 -0
  83. package/scripts/create-project-dirs.sh +3 -45
  84. package/scripts/ensure-task-workflow.sh +186 -4
  85. package/scripts/heartbeat-triage.sh +51 -7
  86. package/scripts/init-project.sh +2 -11
  87. package/scripts/inspect-project-state.ts +1 -1
  88. package/scripts/lib/project-init-lib.sh +353 -52
  89. package/scripts/migrate-project-template.sh +154 -27
  90. package/scripts/new-plan.sh +7 -1
  91. package/scripts/new-spec.sh +7 -1
  92. package/scripts/new-sprint.sh +11 -8
  93. package/scripts/plan-to-todo.sh +7 -1
  94. package/scripts/prepare-handoff.sh +7 -1
  95. package/scripts/refresh-current-status.sh +2 -1
  96. package/scripts/ship-worktrees.sh +2 -0
  97. package/scripts/sprint-backlog.sh +32 -16
  98. package/scripts/switch-plan.sh +7 -1
  99. package/scripts/verify-sprint.sh +7 -1
  100. package/scripts/workflow-contract.ts +19 -1
  101. package/src/cli/commands/docs.ts +103 -0
  102. package/src/cli/commands/doctor.ts +73 -0
  103. package/src/cli/commands/global-runtime.ts +3 -0
  104. package/src/cli/commands/init-hook.ts +602 -0
  105. package/src/cli/commands/init.ts +11 -0
  106. package/src/cli/commands/status.ts +1 -1
  107. package/src/cli/hook/route-registry.ts +7 -1
  108. package/src/cli/hook/runtime.ts +1 -0
  109. package/src/cli/index.ts +8 -1
  110. package/src/cli/installer/targets/claude.ts +1 -1
  111. package/src/cli/installer/targets/codex.ts +1 -1
  112. package/assets/reference-configs/AGENTS.md +0 -13
  113. package/assets/reference-configs/CLAUDE.md +0 -13
  114. package/docs/reference-configs/AGENTS.md +0 -13
  115. package/docs/reference-configs/CLAUDE.md +0 -13
  116. package/docs/reference-configs/agentic-development-flow.md +0 -82
  117. package/docs/reference-configs/ai-workflows.md +0 -14
  118. package/docs/reference-configs/changelog-versioning.md +0 -13
  119. package/docs/reference-configs/coding-standards.md +0 -14
  120. package/docs/reference-configs/development-protocol.md +0 -21
  121. package/docs/reference-configs/document-generation.md +0 -36
  122. package/docs/reference-configs/evaluator-rubric.md +0 -19
  123. package/docs/reference-configs/external-tooling.md +0 -328
  124. package/docs/reference-configs/git-strategy.md +0 -14
  125. package/docs/reference-configs/global-working-rules.md +0 -47
  126. package/docs/reference-configs/handoff-protocol.md +0 -40
  127. package/docs/reference-configs/harness-overview.md +0 -75
  128. package/docs/reference-configs/heartbeat-triage.md +0 -57
  129. package/docs/reference-configs/hook-operations.md +0 -86
  130. package/docs/reference-configs/loop-engine-cutover-gate.md +0 -39
  131. package/docs/reference-configs/loop-engine-nl-decision-table.md +0 -137
  132. package/docs/reference-configs/release-deploy.md +0 -40
  133. package/docs/reference-configs/spa-day-protocol.md +0 -14
  134. package/docs/reference-configs/sprint-contracts.md +0 -63
  135. package/docs/reference-configs/workflow-orchestration.md +0 -14
package/AGENTS.md CHANGED
@@ -6,7 +6,7 @@ This repository self-hosts the `repo-harness` contract; the former `repo-harness
6
6
 
7
7
  - `tasks/current.md` for the tracked current-status snapshot derived from workflow artifacts
8
8
  - `tasks/todos.md` for deferred medium/long-term goals, not active execution checklists
9
- - `plans/prds/` for program-level sprint PRDs and ordered backlogs, operated by `scripts/sprint-backlog.sh` (Sprint = program layer; task contracts stay the execution slices)
9
+ - `plans/prds/` for upper-layer PRDs; `plans/sprints/` for ordered sprint backlogs operated through `scripts/sprint-backlog.sh` (installed implementations live under `.ai/harness/scripts/`; task contracts stay the execution slices)
10
10
  - `.ai/context/capabilities.json` for the capability registry and longest-prefix context boundaries
11
11
  - `tasks/workstreams/` for capability long-running workstreams that project durable progress into local contracts
12
12
  - `tasks/lessons.md` for correction-derived rules
package/CLAUDE.md CHANGED
@@ -6,7 +6,7 @@ This repository self-hosts the `repo-harness` contract; the former `repo-harness
6
6
 
7
7
  - `tasks/current.md` for the tracked current-status snapshot derived from workflow artifacts
8
8
  - `tasks/todos.md` for deferred medium/long-term goals, not active execution checklists
9
- - `plans/prds/` for program-level sprint PRDs and ordered backlogs, operated by `scripts/sprint-backlog.sh` (Sprint = program layer; task contracts stay the execution slices)
9
+ - `plans/prds/` for upper-layer PRDs; `plans/sprints/` for ordered sprint backlogs operated through `scripts/sprint-backlog.sh` (installed implementations live under `.ai/harness/scripts/`; task contracts stay the execution slices)
10
10
  - `.ai/context/capabilities.json` for the capability registry and longest-prefix context boundaries
11
11
  - `tasks/workstreams/` for capability long-running workstreams that project durable progress into local contracts
12
12
  - `tasks/lessons.md` for correction-derived rules
package/README.es.md CHANGED
@@ -345,8 +345,8 @@ Guards habituales:
345
345
 
346
346
  ## Release actual
347
347
 
348
- - npm package: `repo-harness@0.4.1`
349
- - Generated workflow stamp: `repo-harness@0.4.1+template@0.4.1`
348
+ - npm package: `repo-harness@0.4.3`
349
+ - Generated workflow stamp: `repo-harness@0.4.3+template@0.4.3`
350
350
  - GitHub repository: `Ancienttwo/repo-harness`
351
351
  - Release history: [`docs/CHANGELOG.md`](docs/CHANGELOG.md)
352
352
 
package/README.fr.md CHANGED
@@ -350,8 +350,8 @@ Guards courants :
350
350
 
351
351
  ## Release actuelle
352
352
 
353
- - npm package : `repo-harness@0.4.1`
354
- - Generated workflow stamp : `repo-harness@0.4.1+template@0.4.1`
353
+ - npm package : `repo-harness@0.4.3`
354
+ - Generated workflow stamp : `repo-harness@0.4.3+template@0.4.3`
355
355
  - GitHub repository : `Ancienttwo/repo-harness`
356
356
  - Release history : [`docs/CHANGELOG.md`](docs/CHANGELOG.md)
357
357
 
package/README.ja.md CHANGED
@@ -312,8 +312,8 @@ hook がブロックしたときは、まず terminal の構造化された出
312
312
 
313
313
  ## 現在の Release
314
314
 
315
- - npm package:`repo-harness@0.4.1`
316
- - Generated workflow stamp:`repo-harness@0.4.1+template@0.4.1`
315
+ - npm package:`repo-harness@0.4.3`
316
+ - Generated workflow stamp:`repo-harness@0.4.3+template@0.4.3`
317
317
  - GitHub repository:`Ancienttwo/repo-harness`
318
318
  - Release history:[`docs/CHANGELOG.md`](docs/CHANGELOG.md)
319
319
 
package/README.md CHANGED
@@ -34,21 +34,29 @@ This repository now dogfoods its own tasks-first contract. It is both:
34
34
  read a 1KB capability contract or query the index instead of spending thousands of
35
35
  tokens rediscovering structure.
36
36
 
37
- ## What's New in 0.4.1
38
-
39
- - **Session-scoped CodeGraph nudges.** Hook stdin `session_id` now drives the
40
- one-shot CodeGraph route hint, so stale local session files no longer suppress
41
- or repeat guidance across independent Claude/Codex sessions.
42
- - **Central-first hook safety.** Generated and migrated repos stay on the
43
- user-level hook runtime by default; repo-local top-level hook scripts are
44
- pruned unless `.ai/harness/policy.json` explicitly pins `"hook_source": "repo"`.
45
- - **Workflow document migration.** Active workflow docs now use
46
- `tasks/todos.md` for deferred goals and `docs/researches/*.md` for durable
47
- research, with legacy `tasks/todo.md` and `tasks/research.md` treated as
48
- migration inputs.
49
- - **Release-gate stability.** Runtime ignore rules cover transient
50
- `tasks/.current.md.tmp.*` and `.claude/.plan-state/` state, and the default
51
- Bun test timeout matches the release gate budget.
37
+ In an adopted repo, the surface area is intentionally small:
38
+
39
+ | Surface | Purpose |
40
+ | --- | --- |
41
+ | `docs/spec.md` and `docs/reference-configs/` | Shared standards and stable product intent that every agent session can read. |
42
+ | `plans/`, `plans/prds/`, and `plans/sprints/` | Decision-complete work packages before implementation starts. |
43
+ | `tasks/contracts/`, `tasks/reviews/`, and `.ai/harness/checks/` | Scope, verification, and review evidence for proving the work is done. |
44
+ | `.ai/harness/handoff/` and `tasks/current.md` | Session journal and resumable status, derived from workflow artifacts instead of chat memory. |
45
+
46
+ ## What's New in 0.4.3
47
+
48
+ - **Runtime docs lookup.** `repo-harness docs list|path|show` resolves bundled
49
+ runtime/reference docs from the installed package instead of requiring copied
50
+ repo prose.
51
+ - **Init-hook bootstrap audit.** `repo-harness init-hook --json` reports concrete
52
+ Agent actions for missing working rules, adapter drift, stale CLI installs,
53
+ and tooling readiness.
54
+ - **First-principles edit guard.** Managed hook routes now include
55
+ anti-overengineering guidance for implementation edits while keeping the guard
56
+ advisory.
57
+ - **Slimmer generated reference docs.** Generated and migrated repos write
58
+ deterministic `docs/reference-configs/*.md` pointer stubs while `.ai/harness/*`
59
+ and `.ai/context/*` remain local runtime artifacts.
52
60
 
53
61
  ## What repo-harness Does
54
62
 
@@ -119,7 +127,8 @@ delegation without changing the file-backed authority model.
119
127
  ```mermaid
120
128
  flowchart TD
121
129
  Program["Program goal or release theme"] --> Sprint{"Sprint layer needed?"}
122
- Sprint -->|yes| SprintDoc["Sprint PRD + backlog<br/>plans/prds/*.prd.md"]
130
+ Sprint -->|yes| PRD["Upper-layer PRD<br/>plans/prds/*.prd.md"]
131
+ PRD --> SprintDoc["Sprint backlog<br/>plans/sprints/*.sprint.md"]
123
132
  SprintDoc --> NextTask["Select next sprint task<br/>sprint-backlog.sh next"]
124
133
  Sprint -->|no| UserTask["User task or planning prompt"]
125
134
  Heartbeat["Heartbeat triage<br/>scripts/heartbeat-triage.sh<br/>.ai/harness/triage/"] --> UserTask
@@ -185,23 +194,26 @@ judgment in Claude-Fable before asking Codex to loop on execution:
185
194
  `plan-eng-review` for engineering plan review. The output should be the
186
195
  development documents that lock product intent, architecture, risks, and the
187
196
  evidence contract.
188
- 2. Turn those documents into a PRD sprint under `plans/prds/`, with an
189
- ordered backlog and detailed sub-plans for each execution slice.
197
+ 2. Turn those documents into an upper-layer PRD under `plans/prds/`, then into
198
+ an ordered sprint backlog under `plans/sprints/` with detailed sub-plans for
199
+ each execution slice.
190
200
  3. In Codex, create a Goal that points at that sprint file. The harness can then
191
201
  project each sprint item through the normal plan -> contract -> worktree ->
192
202
  verification flow.
193
203
 
194
204
  That handoff keeps long-running loops precise: Claude-Fable owns the broad
195
- front-loaded judgment, the PRD sprint is the durable source of truth, and Codex
196
- Goal mode resumes against a concrete sprint instead of reinterpreting the
197
- original chat.
205
+ front-loaded judgment, the PRD remains the upper source of truth, the sprint
206
+ backlog is the durable execution queue, and Codex Goal mode resumes against a
207
+ concrete sprint instead of reinterpreting the original chat.
198
208
 
199
209
  ## First 5 Minutes
200
210
 
201
211
  This is the fastest path for an AI tooling owner evaluating whether the workflow is
202
- safe to adopt in a real repo.
212
+ safe to adopt in a real repo. It separates the machine-level runtime bootstrap
213
+ from the repo-local contract install, so a dry run can show exactly what will
214
+ change before anything is applied.
203
215
 
204
- ### Initial bootstrap
216
+ ### 1. Bootstrap the host runtime once
205
217
 
206
218
  ```bash
207
219
  npx -y repo-harness init
@@ -213,27 +225,36 @@ user-level hook adapters, configures Waza runtime skills, persists a brain root
213
225
  under `~/.repo-harness/config.json`, and configures CodeGraph MCP. It does not
214
226
  apply repo-local workflow files to the current directory.
215
227
 
216
- ### Install or refresh a repo-local harness
228
+ For an Agent-owned, read-only bootstrap audit, run `npx -y repo-harness
229
+ init-hook --json` or add `--check-updates` for version advisories. `init-hook`
230
+ is not a runtime hook: it does not write user-level files, install updates, or
231
+ register adapters. It emits `agent_actions` with the reason, risk, target files,
232
+ optional command, and verification surface for the Agent to execute deliberately.
233
+
234
+ ### 2. Preview the repo-local contract
217
235
 
218
236
  ```bash
219
237
  npx -y repo-harness update --dry-run
238
+ ```
239
+
240
+ Run the dry run from the target repository root. It reports the specs, task
241
+ state, helper runtime, hook adapter target, and verification files that would be
242
+ created or refreshed. It should not create an application stack; existing repos
243
+ use `repo-harness update`, while new projects or modules use
244
+ `repo-harness-scaffold`.
245
+
246
+ ### 3. Apply, then prove the workflow
247
+
248
+ ```bash
220
249
  npx -y repo-harness update
250
+ bash scripts/check-task-workflow.sh --strict
251
+ bun test
221
252
  ```
222
253
 
223
- `update` is the existing-repo install and refresh path. Run it from a target
224
- repository to install or refresh workflow files, hook assets, host adapters,
225
- skill aliases, and repo-local verification surfaces from the current npm package.
226
-
227
- The npm package and generated workflow stamp now share the `0.4.x` release line.
228
- The `0.4.1` package keeps first-run
229
- global bootstrap (`repo-harness init`) separate from repo-local refresh
230
- (`repo-harness update`) while hardening session-scoped hook state, central-first
231
- hook execution, workflow-document migration, and release-gate stability on top
232
- of the `0.4.0` loop-engine surfaces.
233
- These sit on top of the renamed `repo-harness` CLI, user-level hook
234
- adapter bootstrap, AI-native scaffold overlays, the typed prompt-guard decision
235
- engine, plan-stem task artifact naming, `REPO_HARNESS_*` runtime aliases, Waza
236
- runtime skill sync, and the maintainer release gate.
254
+ After apply, the repo should have a reviewable file-backed contract rather than
255
+ tool-specific chat setup. Agents should be able to find the stable intent in
256
+ `docs/spec.md`, execution state in `plans/` and `tasks/`, and resume state in
257
+ `.ai/harness/handoff/`.
237
258
 
238
259
  Only maintainers editing the package need a source checkout:
239
260
 
@@ -289,16 +310,9 @@ The command should end with `=== Migration Report ===` and summarize:
289
310
  - `Host hook config target: user-level ~/.claude/settings.json and ~/.codex/hooks.json` to show the adapter layer
290
311
  - `Host hook adapters are user-level:` to remind the user to install global adapters and trust `~/.codex/hooks.json`
291
312
  - `Workflow migration:` to show the repo-local harness surfaces it will create or refresh
292
- - `Helper scripts:` to show the operational toolchain you get after apply
313
+ - `Helper runtime:` to show `.ai/harness/scripts/*` implementations and `scripts/*` compatibility wrappers after apply
293
314
  - `--- External Tooling ---` to show default gstack/Waza/gbrain routing plus advisory install/update hints
294
315
 
295
- ### Next two commands
296
-
297
- ```bash
298
- bash scripts/check-task-workflow.sh --strict
299
- bun test
300
- ```
301
-
302
316
  If the dry-run output looks wrong, stop there and inspect
303
317
  [`docs/reference-configs/hook-operations.md`](docs/reference-configs/hook-operations.md)
304
318
  before applying anything.
@@ -380,8 +394,8 @@ Most common guards:
380
394
 
381
395
  ## Current Release
382
396
 
383
- - npm package: `repo-harness@0.4.1`
384
- - Generated workflow stamp: `repo-harness@0.4.1+template@0.4.1`
397
+ - npm package: `repo-harness@0.4.3`
398
+ - Generated workflow stamp: `repo-harness@0.4.3+template@0.4.3`
385
399
  - GitHub repository: `Ancienttwo/repo-harness`
386
400
  - Release history: [`docs/CHANGELOG.md`](docs/CHANGELOG.md)
387
401
 
@@ -431,7 +445,8 @@ Most common guards:
431
445
 
432
446
  ## Acknowledgements and Workflow Influences
433
447
 
434
- `repo-harness` is built around a small set of external skills and repos that
448
+ `repo-harness` is built around a small set of external skills, repos, and agent
449
+ runtimes that
435
450
  proved useful while this project was being designed, debugged, and released.
436
451
  They are acknowledged here because they shaped the workflow contract, but they
437
452
  are not ordinary bundled product dependencies.
@@ -443,6 +458,20 @@ are not ordinary bundled product dependencies.
443
458
  | gstack skills and `gbrain` by [Garry Tan](https://x.com/garrytan) | Product discovery, plan review, design review, post-ship documentation hygiene, knowledge sync, handoff retrieval, and long-form repo memory | External operator workflow plus optional external CLI/index; advisory by default |
444
459
  | `mermaid` | Human-readable architecture and system-flow diagrams when Mermaid is not enough | Runtime-referenced skill, not vendored into generated repos |
445
460
  | CodeGraph (`@colbymchenry/codegraph`) | Symbol-aware navigation, impact tracing, and readiness checks for this self-host repo | Dev dependency in this repo; generated repos stay global-MCP-first unless policy opts in |
461
+ | OpenAI Codex | Primary execution agent for repo-local implementation, verification, and GitHub contributor attribution when a commit materially includes Codex-authored work | External agent runtime; attribution is an explicit commit trailer, not hidden hook automation |
462
+
463
+ ### GitHub Contributor Attribution
464
+
465
+ When Codex materially contributes to a commit, use GitHub's standard co-author
466
+ trailer format at the end of the commit message:
467
+
468
+ ```text
469
+ Co-authored-by: codex <codex@openai.com>
470
+ ```
471
+
472
+ Keep this opt-in and visible per commit. Do not bake it into downstream
473
+ repo-harness commit scripts or hooks unless that repo explicitly adopts the same
474
+ policy.
446
475
 
447
476
  ## Action Command Skills
448
477
 
@@ -450,7 +479,8 @@ Source-owned command facades live in `assets/skill-commands/`. They keep host
450
479
  skill discovery compatible while the CLI and hooks own execution:
451
480
 
452
481
  - Planning and review: `repo-harness-plan`, `repo-harness-review`, `repo-harness-autoplan`
453
- - Sprint program layer: `repo-harness-sprint` (PRD + ordered backlog in `plans/prds/`, executed task-by-task through the contract flow)
482
+ - Product planning layer: `repo-harness-prd` (upper-layer PRDs in `plans/prds/`, evidence-marked unknowns, sprint-consumable sections)
483
+ - Sprint program layer: `repo-harness-sprint` (ordered sprint backlogs in `plans/sprints/`, each row expanded with `$think` before the contract flow)
454
484
  - Repo workflow actions: `repo-harness-ship`, `repo-harness-init`, `repo-harness-migrate`, `repo-harness-upgrade`, `repo-harness-capability`, `repo-harness-architecture`, `repo-harness-handoff`, `repo-harness-deploy`, `repo-harness-repair`, `repo-harness-check`
455
485
  - Branch project creation command: `repo-harness-scaffold`
456
486
 
@@ -510,6 +540,22 @@ bun scripts/inspect-project-state.ts --repo . --format text
510
540
  bash scripts/migrate-project-template.sh --repo . --dry-run
511
541
  ```
512
542
 
543
+ ### Runtime reference docs
544
+
545
+ Generic repo-harness runtime/reference docs live in the installed package under
546
+ `assets/reference-configs/` and are resolved through the CLI:
547
+
548
+ ```bash
549
+ repo-harness docs list
550
+ repo-harness docs path harness-overview
551
+ repo-harness docs show harness-overview
552
+ ```
553
+
554
+ Generated and migrated repos still keep `docs/reference-configs/*.md`, but
555
+ those files are deterministic pointer stubs. Repo-local workflow state,
556
+ policy, checks, runs, handoff packets, context maps, and helper snapshots stay
557
+ under `.ai/`.
558
+
513
559
  ### Explicit template assembly
514
560
 
515
561
  ```bash
@@ -539,8 +585,9 @@ bun run benchmark:skills --eval repair-agents-task-sync
539
585
  - Plan mapping: `assets/plan-map.json`
540
586
  - Question-pack: `assets/initializer-question-pack.v4.json`
541
587
  - Shared hooks: `assets/hooks/`
588
+ - Runtime reference docs: `assets/reference-configs/` via `repo-harness docs`
542
589
  - Workflow contract: `assets/workflow-contract.v1.json`
543
- - Hook operations reference: `docs/reference-configs/hook-operations.md`
590
+ - Source repo reference docs: `docs/reference-configs/*.md`
544
591
  - Template assembler: `scripts/assemble-template.ts`
545
592
  - Question inference helper: `scripts/initializer-question-pack.ts`
546
593
  - State inspector: `scripts/inspect-project-state.ts`
package/README.zh-CN.md CHANGED
@@ -23,20 +23,27 @@ repo-local workflow 的自托管样例。
23
23
  做渐进式上下文加载:一份小而稳定的 root context(约 12KB),加上只在改到对应文件时才加载的
24
24
  capability 块。agent 读一份 1KB 的 capability 合约或查索引,而不是花上千 token 重新摸清结构。
25
25
 
26
- ## 0.4.1 新特性
27
-
28
- - **Session-scoped CodeGraph 提醒。** Hook stdin 里的 `session_id` 现在会驱动
29
- 一次性 CodeGraph route hint,避免 stale 本地 session 文件跨 Claude/Codex
30
- 会话误抑制或重复提醒。
31
- - **Central-first hook safety。** Generated migrated repos 默认继续使用
32
- user-level hook runtime;只有 `.ai/harness/policy.json` 明确设置
33
- `"hook_source": "repo"` 时,才保留 repo-local top-level hook scripts。
34
- - **Workflow 文档迁移。** Active workflow docs 统一使用 `tasks/todos.md`
35
- 记录 deferred goals,使用 `docs/researches/*.md` 保存 durable research;
36
- legacy `tasks/todo.md` 和 `tasks/research.md` 只作为 migration inputs。
37
- - **Release-gate 稳定性。** Runtime ignore rules 覆盖
38
- `tasks/.current.md.tmp.*` `.claude/.plan-state/` 这类 transient state,
39
- 默认 Bun test timeout 也和 release gate budget 对齐。
26
+ 接入后的仓库只需要理解几个 surface:
27
+
28
+ | Surface | 作用 |
29
+ | --- | --- |
30
+ | `docs/spec.md` 和 `docs/reference-configs/` | 共享标准和稳定产品意图,每个 agent 会话都能读取。 |
31
+ | `plans/`、`plans/prds/`、`plans/sprints/` | 实现前先沉淀 decision-complete work package。 |
32
+ | `tasks/contracts/`、`tasks/reviews/`、`.ai/harness/checks/` | 证明完成所需的 scope、verification 和 review evidence。 |
33
+ | `.ai/harness/handoff/` 和 `tasks/current.md` | session journal 与可恢复状态,从 workflow artifacts 派生,而不是依赖聊天记忆。 |
34
+
35
+ ## 0.4.3 新特性
36
+
37
+ - **Runtime docs lookup。** `repo-harness docs list|path|show` 从已安装 package
38
+ 解析 bundled runtime/reference docs,不再要求把完整 repo prose 复制到下游。
39
+ - **Init-hook bootstrap audit。** `repo-harness init-hook --json` 会把缺失的
40
+ working rules、adapter drift、stale CLI install 和 tooling readiness 汇成
41
+ 具体 Agent actions。
42
+ - **First-principles edit guard。** Managed hook routes 增加实现编辑时的
43
+ anti-overengineering guidance,同时保持 advisory,不把风格判断变成硬拦截。
44
+ - **更轻的 generated reference docs。** 生成和迁移的仓库写入确定性的
45
+ `docs/reference-configs/*.md` pointer stubs,`.ai/harness/*` 和 `.ai/context/*`
46
+ 继续作为 repo-local runtime artifacts。
40
47
 
41
48
  ## 产品做什么
42
49
 
@@ -167,9 +174,11 @@ source of truth,Codex Goal mode 只围绕具体 sprint 恢复和推进,而
167
174
 
168
175
  ## 前 5 分钟
169
176
 
170
- 这是评估一个真实仓库是否适合接入该 workflow 的最快路径。
177
+ 这是评估一个真实仓库是否适合接入该 workflow 的最快路径。它把机器级 runtime
178
+ bootstrap 和 repo-local contract install 分开,所以 dry-run 能先展示会改什么,
179
+ 再决定是否应用。
171
180
 
172
- ### 初次引导
181
+ ### 1. 先做一次 host runtime bootstrap
173
182
 
174
183
  ```bash
175
184
  npx -y repo-harness init
@@ -180,27 +189,34 @@ skill aliases,安装 user-level hook adapters,配置 Waza runtime skills,
180
189
  root 持久化到 `~/.repo-harness/config.json`,并配置 CodeGraph MCP。它不会把当前目录
181
190
  默认迁移成 repo-local workflow。
182
191
 
183
- ### 安装或刷新 repo-local harness
192
+ 如果要让 Agent 做只读 bootstrap audit,运行 `npx -y repo-harness init-hook
193
+ --json`;需要版本提示时加 `--check-updates`。`init-hook` 不是 runtime hook:
194
+ 它不会写 user-level files、安装更新或注册 adapters,只输出带 reason、risk、
195
+ targets、可选 command 和 verification 的 `agent_actions`,由 Agent 再显式执行。
196
+
197
+ ### 2. 预览 repo-local contract
184
198
 
185
199
  ```bash
186
200
  npx -y repo-harness update --dry-run
187
- npx -y repo-harness update
188
201
  ```
189
202
 
190
- `update` 是已有目标仓库的安装和刷新入口。从目标仓库根目录运行它,用当前 npm
191
- 安装或刷新 workflow files、hook assets、host adapters、skill aliases
192
- repo-local verification surfaces。
203
+ 在目标仓库根目录运行 dry-run。它会报告将要创建或刷新的 spec、task state、
204
+ helper runtime、hook adapter target verification files。它不会创建应用技术栈;
205
+ 已有仓库走 `repo-harness update`,新项目或新模块走 `repo-harness-scaffold`。
206
+
207
+ ### 3. 应用后验证 workflow
208
+
209
+ ```bash
210
+ npx -y repo-harness update
211
+ bash scripts/check-task-workflow.sh --strict
212
+ bun test
213
+ ```
193
214
 
194
- npm package generated workflow stamp 现在共用 `0.4.x` release line。
195
- `repo-harness@0.4.1` 继续把首次全局引导(`repo-harness init`)
196
- repo-local 刷新(`repo-harness update`)拆开,并在 `0.4.0` loop-engine
197
- surfaces 之上强化 session-scoped hook state、central-first hook execution、
198
- workflow-document migration 和 release-gate stability。
199
- 这些能力叠加在改名后的 CLI、user-level hook adapter bootstrap、AI-native scaffold overlays、
200
- typed prompt-guard decision engine、plan-stem task artifact 命名、`REPO_HARNESS_*`
201
- runtime aliases、Waza runtime skill sync,以及 maintainer 发布 npm 前使用的 release gate 之上。
215
+ 应用后,目标仓库应该得到一套可审查的 file-backed contract,而不是 tool-specific
216
+ 聊天配置。agent 应该能在 `docs/spec.md` 找到稳定意图,在 `plans/` 和 `tasks/`
217
+ 找到执行状态,在 `.ai/harness/handoff/` 找到可恢复状态。
202
218
 
203
- 只有维护者需要在编辑 package 源码时使用 source checkout:
219
+ 只有维护者编辑 package 源码时才需要 source checkout:
204
220
 
205
221
  ```bash
206
222
  git clone https://github.com/Ancienttwo/repo-harness.git ~/Projects/repo-harness
@@ -254,13 +270,6 @@ npx -y repo-harness update
254
270
  - `Helper scripts:`:应用后会得到的操作工具链
255
271
  - `--- External Tooling ---`:gstack/Waza/gbrain 路由以及 advisory 安装/更新提示
256
272
 
257
- ### 接着跑的两个命令
258
-
259
- ```bash
260
- bash scripts/check-task-workflow.sh --strict
261
- bun test
262
- ```
263
-
264
273
  如果 dry-run 输出不对,先停在这里,阅读
265
274
  [`docs/reference-configs/hook-operations.md`](docs/reference-configs/hook-operations.md)。
266
275
 
@@ -334,8 +343,8 @@ hook block 工作时,先看 terminal 里的结构化输出。核心字段是
334
343
 
335
344
  ## 当前 Release
336
345
 
337
- - npm package:`repo-harness@0.4.1`
338
- - Generated workflow stamp:`repo-harness@0.4.1+template@0.4.1`
346
+ - npm package:`repo-harness@0.4.3`
347
+ - Generated workflow stamp:`repo-harness@0.4.3+template@0.4.3`
339
348
  - GitHub repository:`Ancienttwo/repo-harness`
340
349
  - Release history:[`docs/CHANGELOG.md`](docs/CHANGELOG.md)
341
350
 
@@ -373,6 +382,16 @@ decision rationale 的要求,来自他的贡献与启发。
373
382
  product discovery、plan/design review、release 文档、knowledge sync 和
374
383
  handoff retrieval 的工作流设计。
375
384
 
385
+ 感谢 OpenAI Codex 作为本仓库主要执行 agent 参与实现、验证和收口。Codex 对某个
386
+ commit 有实质贡献时,GitHub contributor 署名使用显式 trailer:
387
+
388
+ ```text
389
+ Co-authored-by: codex <codex@openai.com>
390
+ ```
391
+
392
+ 这条署名保持逐 commit 显式添加,不把它藏进下游 `repo-harness` commit 脚本或 hook
393
+ 里,除非目标仓库自己采用同样策略。
394
+
376
395
  ## Action Command Skills
377
396
 
378
397
  公共 command facades 在 `assets/skill-commands/`;它们保留 host skill discovery
package/SKILL.md CHANGED
@@ -142,7 +142,8 @@ contract files:
142
142
  - `repo-harness-deploy`: check deploy and private operations configuration without publishing or deploying
143
143
  - `repo-harness-repair`: repair broken task sync, hook routing, handoff, context, policy, or helpers
144
144
  - `repo-harness-check`: run verification gates and report release or pre-merge readiness
145
- - `repo-harness-sprint`: plan a program-level sprint (PRD + ordered backlog) and drive backlog tasks through the task-contract flow
145
+ - `repo-harness-prd`: generate an upper-layer PRD in `plans/prds/`
146
+ - `repo-harness-sprint`: plan a sprint backlog in `plans/sprints/` from a PRD or source spec, then expand each row with `$think` before the task-contract flow
146
147
 
147
148
  Internal steps such as `hooks-init`, `docs-init`, and `create-project-dirs` are
148
149
  not public commands. They stay behind `init`, `scaffold`, `migrate`, and
@@ -37,3 +37,39 @@ Owns the runtime-harness-hook-adapters capability boundary declared in .ai/conte
37
37
  - `bun test tests/hook-runtime.test.ts tests/hook-contracts.test.ts tests/workflow-contract.test.ts`
38
38
  - `bash scripts/check-task-workflow.sh --strict`
39
39
  <!-- END CAPABILITY CONTEXT -->
40
+
41
+ <!-- BEGIN ARCHITECTURE CONTRACT -->
42
+ ## Architecture Contract
43
+
44
+ - Functional block: `.ai/hooks`
45
+ - Capability ID: `runtime-harness-hook-adapters`
46
+ - Matched prefix: `.ai/hooks`
47
+ - Architecture domain: `runtime-harness`
48
+ - Architecture capability: `hook-adapters`
49
+ - Architecture module: `docs/architecture/modules/runtime-harness/hook-adapters.md`
50
+ - Last architecture event: 2026-06-13T00:04:13+0800
51
+ - Last changed path: `.ai/hooks/post-tool-observer.sh`
52
+ - Severity: high
53
+ - Change type: workflow-surface
54
+ - Module responsibility: Keep this block aligned with the local boundary described by surrounding human-owned context.
55
+ - Entrypoints: `.ai/hooks`
56
+ - Allowed dependencies: Follow root `AGENTS.md` / `CLAUDE.md` and this local contract.
57
+ - Forbidden dependencies: Do not cross sibling app/service/package boundaries without an architecture snapshot or explicit plan.
58
+ - Runtime path: `.ai/hooks`
59
+ - LSP/tooling profile: `typescript-lsp`
60
+ - Verification: Use root required checks plus local commands recorded in this capability contract.
61
+ - Latest snapshot: `(none yet)`
62
+ - Semantic diagram source: `docs/architecture/modules/runtime-harness/hook-adapters.md`
63
+ - Latest human diagram: `(none yet)`
64
+ - Pending architecture request: `(none)`
65
+
66
+ ## Active Workstreams
67
+
68
+ - (none yet)
69
+
70
+ ## Current Session Projection
71
+
72
+ - Durable progress lives under `tasks/workstreams/runtime-harness/hook-adapters`.
73
+ - `tasks/current.md` is the tracked derived status snapshot; it is not a live lock or task source.
74
+ - `tasks/todos.md` is the deferred-goal ledger; current execution slices stay in the active plan's `## Task Breakdown`.
75
+ <!-- END ARCHITECTURE CONTRACT -->
@@ -37,3 +37,39 @@ Owns the runtime-harness-hook-adapters capability boundary declared in .ai/conte
37
37
  - `bun test tests/hook-runtime.test.ts tests/hook-contracts.test.ts tests/workflow-contract.test.ts`
38
38
  - `bash scripts/check-task-workflow.sh --strict`
39
39
  <!-- END CAPABILITY CONTEXT -->
40
+
41
+ <!-- BEGIN ARCHITECTURE CONTRACT -->
42
+ ## Architecture Contract
43
+
44
+ - Functional block: `.ai/hooks`
45
+ - Capability ID: `runtime-harness-hook-adapters`
46
+ - Matched prefix: `.ai/hooks`
47
+ - Architecture domain: `runtime-harness`
48
+ - Architecture capability: `hook-adapters`
49
+ - Architecture module: `docs/architecture/modules/runtime-harness/hook-adapters.md`
50
+ - Last architecture event: 2026-06-13T00:04:13+0800
51
+ - Last changed path: `.ai/hooks/post-tool-observer.sh`
52
+ - Severity: high
53
+ - Change type: workflow-surface
54
+ - Module responsibility: Keep this block aligned with the local boundary described by surrounding human-owned context.
55
+ - Entrypoints: `.ai/hooks`
56
+ - Allowed dependencies: Follow root `AGENTS.md` / `CLAUDE.md` and this local contract.
57
+ - Forbidden dependencies: Do not cross sibling app/service/package boundaries without an architecture snapshot or explicit plan.
58
+ - Runtime path: `.ai/hooks`
59
+ - LSP/tooling profile: `typescript-lsp`
60
+ - Verification: Use root required checks plus local commands recorded in this capability contract.
61
+ - Latest snapshot: `(none yet)`
62
+ - Semantic diagram source: `docs/architecture/modules/runtime-harness/hook-adapters.md`
63
+ - Latest human diagram: `(none yet)`
64
+ - Pending architecture request: `(none)`
65
+
66
+ ## Active Workstreams
67
+
68
+ - (none yet)
69
+
70
+ ## Current Session Projection
71
+
72
+ - Durable progress lives under `tasks/workstreams/runtime-harness/hook-adapters`.
73
+ - `tasks/current.md` is the tracked derived status snapshot; it is not a live lock or task source.
74
+ - `tasks/todos.md` is the deferred-goal ledger; current execution slices stay in the active plan's `## Task Breakdown`.
75
+ <!-- END ARCHITECTURE CONTRACT -->
@@ -1,30 +1,12 @@
1
1
  #!/bin/bash
2
- # Anti-Simplification Guard PostToolUse on Edit|Write
3
- # Warns when changes suggest compatibility debt or unnecessary branch complexity.
2
+ # Compatibility wrapper for the renamed First-Principles Guard.
4
3
 
5
4
  set -eo pipefail
6
5
 
7
6
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
- # shellcheck source=/dev/null
9
- . "$SCRIPT_DIR/hook-input.sh"
10
7
 
11
- FILE_PATH="$(hook_get_file_path "${1:-}")"
12
- [[ -z "$FILE_PATH" ]] && exit 0
13
-
14
- if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
15
- exit 0
8
+ if [[ -f "$SCRIPT_DIR/first-principles-guard.sh" ]]; then
9
+ exec bash "$SCRIPT_DIR/first-principles-guard.sh" "$@"
16
10
  fi
17
11
 
18
- DIFF_CONTENT="$(git diff -- "$FILE_PATH" 2>/dev/null || true)"
19
- [[ -z "$DIFF_CONTENT" ]] && exit 0
20
-
21
- if echo "$DIFF_CONTENT" | grep -E '^\+.*(legacy|compat|backward|polyfill|shim)' >/dev/null; then
22
- echo "[AntiSimplification] Compatibility-like additions detected in $FILE_PATH"
23
- echo " Prefer clean upgrades and rewrite-over-patch instead of legacy branches."
24
- fi
25
-
26
- branch_additions="$(echo "$DIFF_CONTENT" | grep -E '^\+.*\b(if|else if|switch)\b' | wc -l | tr -d ' ')"
27
- if [[ "$branch_additions" -ge 4 ]]; then
28
- echo "[AntiSimplification] Branch-heavy additions detected in $FILE_PATH ($branch_additions new branch lines)"
29
- echo " Re-check data structures before adding more control-flow branches."
30
- fi
12
+ exit 0
@@ -15,6 +15,12 @@
15
15
  { "type": "command", "command": "repo=$(git rev-parse --show-toplevel 2>/dev/null) || exit 0; HOOK_HOST=codex HOOK_REPO_ROOT=\"$repo\" bash \"$repo/.ai/hooks/run-hook.sh\" worktree-guard.sh", "timeout": 30 },
16
16
  { "type": "command", "command": "repo=$(git rev-parse --show-toplevel 2>/dev/null) || exit 0; HOOK_HOST=codex HOOK_REPO_ROOT=\"$repo\" bash \"$repo/.ai/hooks/run-hook.sh\" pre-edit-guard.sh", "timeout": 30 }
17
17
  ]
18
+ },
19
+ {
20
+ "matcher": "Task|Agent|SendUserMessage",
21
+ "hooks": [
22
+ { "type": "command", "command": "repo=$(git rev-parse --show-toplevel 2>/dev/null) || exit 0; HOOK_HOST=codex HOOK_REPO_ROOT=\"$repo\" bash \"$repo/.ai/hooks/run-hook.sh\" subagent-return-channel-guard.sh", "timeout": 30 }
23
+ ]
18
24
  }
19
25
  ],
20
26
  "PostToolUse": [