repo-harness 0.4.1 → 0.4.2

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 (106) 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 +47 -30
  7. package/README.zh-CN.md +28 -19
  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/codex.hooks.template.json +6 -0
  12. package/assets/hooks/session-start-context.sh +30 -5
  13. package/assets/hooks/settings.template.json +6 -0
  14. package/assets/hooks/subagent-return-channel-guard.sh +107 -0
  15. package/assets/partials/04-project-structure.partial.md +4 -4
  16. package/assets/partials/05-workflow.partial.md +6 -6
  17. package/assets/partials/08-orchestration.partial.md +7 -6
  18. package/assets/partials-agents/02-operating-mode.partial.md +4 -4
  19. package/assets/partials-agents/03-orchestration.partial.md +3 -2
  20. package/assets/partials-agents/04-task-protocol.partial.md +4 -4
  21. package/assets/partials-agents/06-quality-safety.partial.md +2 -2
  22. package/assets/reference-configs/agentic-development-flow.md +8 -6
  23. package/assets/reference-configs/document-generation.md +2 -1
  24. package/assets/reference-configs/external-tooling.md +11 -10
  25. package/assets/reference-configs/harness-overview.md +6 -5
  26. package/assets/reference-configs/heartbeat-triage.md +5 -5
  27. package/assets/reference-configs/hook-operations.md +5 -5
  28. package/assets/reference-configs/sprint-contracts.md +10 -8
  29. package/assets/skill-commands/manifest.json +9 -2
  30. package/assets/skill-commands/repo-harness-architecture/SKILL.md +1 -1
  31. package/assets/skill-commands/repo-harness-check/SKILL.md +7 -7
  32. package/assets/skill-commands/repo-harness-deploy/SKILL.md +1 -1
  33. package/assets/skill-commands/repo-harness-handoff/SKILL.md +1 -1
  34. package/assets/skill-commands/repo-harness-init/SKILL.md +1 -1
  35. package/assets/skill-commands/repo-harness-plan/SKILL.md +2 -2
  36. package/assets/skill-commands/repo-harness-prd/SKILL.md +35 -0
  37. package/assets/skill-commands/repo-harness-ship/SKILL.md +3 -3
  38. package/assets/skill-commands/repo-harness-sprint/SKILL.md +21 -12
  39. package/assets/skill-version.json +6 -2
  40. package/assets/skills/claude-review/SKILL.md +8 -1
  41. package/assets/skills/codex-review/SKILL.md +8 -1
  42. package/assets/templates/contract.template.md +1 -1
  43. package/assets/templates/helpers/archive-workflow.sh +7 -1
  44. package/assets/templates/helpers/capture-plan.sh +7 -1
  45. package/assets/templates/helpers/check-agent-tooling.sh +11 -5
  46. package/assets/templates/helpers/check-brain-manifest.sh +12 -1
  47. package/assets/templates/helpers/check-skill-version.ts +3 -1
  48. package/assets/templates/helpers/check-task-workflow.sh +151 -37
  49. package/assets/templates/helpers/contract-worktree.sh +2 -0
  50. package/assets/templates/helpers/ensure-task-workflow.sh +182 -3
  51. package/assets/templates/helpers/heartbeat-triage.sh +51 -7
  52. package/assets/templates/helpers/inspect-project-state.ts +1 -1
  53. package/assets/templates/helpers/new-plan.sh +7 -1
  54. package/assets/templates/helpers/new-spec.sh +7 -1
  55. package/assets/templates/helpers/new-sprint.sh +11 -8
  56. package/assets/templates/helpers/plan-to-todo.sh +7 -1
  57. package/assets/templates/helpers/prepare-handoff.sh +7 -1
  58. package/assets/templates/helpers/refresh-current-status.sh +2 -1
  59. package/assets/templates/helpers/ship-worktrees.sh +2 -0
  60. package/assets/templates/helpers/sprint-backlog.sh +32 -16
  61. package/assets/templates/helpers/switch-plan.sh +7 -1
  62. package/assets/templates/helpers/verify-sprint.sh +7 -1
  63. package/assets/templates/helpers/workflow-contract.ts +10 -1
  64. package/assets/templates/plan.template.md +2 -2
  65. package/assets/templates/prd.template.md +165 -0
  66. package/assets/templates/sprint.template.md +8 -5
  67. package/assets/workflow-contract.v1.json +106 -47
  68. package/docs/reference-configs/agentic-development-flow.md +8 -6
  69. package/docs/reference-configs/document-generation.md +2 -1
  70. package/docs/reference-configs/external-tooling.md +11 -10
  71. package/docs/reference-configs/harness-overview.md +6 -5
  72. package/docs/reference-configs/heartbeat-triage.md +5 -5
  73. package/docs/reference-configs/hook-operations.md +5 -5
  74. package/docs/reference-configs/sprint-contracts.md +10 -8
  75. package/package.json +1 -1
  76. package/scripts/archive-workflow.sh +7 -1
  77. package/scripts/capture-plan.sh +7 -1
  78. package/scripts/check-agent-tooling.sh +11 -5
  79. package/scripts/check-brain-manifest.sh +12 -1
  80. package/scripts/check-skill-version.ts +3 -1
  81. package/scripts/check-task-workflow.sh +151 -37
  82. package/scripts/contract-worktree.sh +2 -0
  83. package/scripts/create-project-dirs.sh +1 -34
  84. package/scripts/ensure-task-workflow.sh +182 -3
  85. package/scripts/heartbeat-triage.sh +51 -7
  86. package/scripts/inspect-project-state.ts +1 -1
  87. package/scripts/lib/project-init-lib.sh +239 -48
  88. package/scripts/migrate-project-template.sh +154 -27
  89. package/scripts/new-plan.sh +7 -1
  90. package/scripts/new-spec.sh +7 -1
  91. package/scripts/new-sprint.sh +11 -8
  92. package/scripts/plan-to-todo.sh +7 -1
  93. package/scripts/prepare-handoff.sh +7 -1
  94. package/scripts/refresh-current-status.sh +2 -1
  95. package/scripts/ship-worktrees.sh +2 -0
  96. package/scripts/sprint-backlog.sh +32 -16
  97. package/scripts/switch-plan.sh +7 -1
  98. package/scripts/verify-sprint.sh +7 -1
  99. package/scripts/workflow-contract.ts +10 -1
  100. package/src/cli/commands/global-runtime.ts +3 -0
  101. package/src/cli/commands/status.ts +1 -1
  102. package/src/cli/hook/route-registry.ts +7 -1
  103. package/src/cli/hook/runtime.ts +1 -0
  104. package/src/cli/index.ts +1 -1
  105. package/src/cli/installer/targets/claude.ts +1 -1
  106. package/src/cli/installer/targets/codex.ts +1 -1
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.2`
349
+ - Generated workflow stamp: `repo-harness@0.4.2+template@0.4.2`
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.2`
354
+ - Generated workflow stamp : `repo-harness@0.4.2+template@0.4.2`
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.2`
316
+ - Generated workflow stamp:`repo-harness@0.4.2+template@0.4.2`
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,20 @@ 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
+ ## What's New in 0.4.2
38
+
39
+ - **PRD-to-Sprint planning hierarchy.** `repo-harness-prd` now owns
40
+ upper-layer product requirements under `plans/prds/`, while
41
+ `repo-harness-sprint` derives ordered execution backlogs under
42
+ `plans/sprints/*.sprint.md`.
43
+ - **Generated helper runtime isolation.** Downstream installs place real helper
44
+ implementations under `.ai/harness/scripts/` and keep root `scripts/*` as
45
+ compatibility wrappers; this self-host repo remains the source runtime.
46
+ - **Subagent return-channel guard.** Managed hook routes include a guard that
47
+ keeps delegated runs reporting back through the parent session instead of
48
+ bypassing the file-backed contract.
49
+ - **Release path alignment.** PRD/Sprint eval fixtures, workflow checks, and
50
+ command guidance now point at the same installed helper runtime.
52
51
 
53
52
  ## What repo-harness Does
54
53
 
@@ -119,7 +118,8 @@ delegation without changing the file-backed authority model.
119
118
  ```mermaid
120
119
  flowchart TD
121
120
  Program["Program goal or release theme"] --> Sprint{"Sprint layer needed?"}
122
- Sprint -->|yes| SprintDoc["Sprint PRD + backlog<br/>plans/prds/*.prd.md"]
121
+ Sprint -->|yes| PRD["Upper-layer PRD<br/>plans/prds/*.prd.md"]
122
+ PRD --> SprintDoc["Sprint backlog<br/>plans/sprints/*.sprint.md"]
123
123
  SprintDoc --> NextTask["Select next sprint task<br/>sprint-backlog.sh next"]
124
124
  Sprint -->|no| UserTask["User task or planning prompt"]
125
125
  Heartbeat["Heartbeat triage<br/>scripts/heartbeat-triage.sh<br/>.ai/harness/triage/"] --> UserTask
@@ -185,16 +185,17 @@ judgment in Claude-Fable before asking Codex to loop on execution:
185
185
  `plan-eng-review` for engineering plan review. The output should be the
186
186
  development documents that lock product intent, architecture, risks, and the
187
187
  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.
188
+ 2. Turn those documents into an upper-layer PRD under `plans/prds/`, then into
189
+ an ordered sprint backlog under `plans/sprints/` with detailed sub-plans for
190
+ each execution slice.
190
191
  3. In Codex, create a Goal that points at that sprint file. The harness can then
191
192
  project each sprint item through the normal plan -> contract -> worktree ->
192
193
  verification flow.
193
194
 
194
195
  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.
196
+ front-loaded judgment, the PRD remains the upper source of truth, the sprint
197
+ backlog is the durable execution queue, and Codex Goal mode resumes against a
198
+ concrete sprint instead of reinterpreting the original chat.
198
199
 
199
200
  ## First 5 Minutes
200
201
 
@@ -225,11 +226,11 @@ repository to install or refresh workflow files, hook assets, host adapters,
225
226
  skill aliases, and repo-local verification surfaces from the current npm package.
226
227
 
227
228
  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
+ The `0.4.2` package keeps first-run
229
230
  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.
231
+ (`repo-harness update`) while adding the PRD-to-Sprint planning hierarchy,
232
+ isolated generated-project helper runtime, subagent return-channel guard, and
233
+ release-path alignment on top of the `0.4.0` loop-engine surfaces.
233
234
  These sit on top of the renamed `repo-harness` CLI, user-level hook
234
235
  adapter bootstrap, AI-native scaffold overlays, the typed prompt-guard decision
235
236
  engine, plan-stem task artifact naming, `REPO_HARNESS_*` runtime aliases, Waza
@@ -289,7 +290,7 @@ The command should end with `=== Migration Report ===` and summarize:
289
290
  - `Host hook config target: user-level ~/.claude/settings.json and ~/.codex/hooks.json` to show the adapter layer
290
291
  - `Host hook adapters are user-level:` to remind the user to install global adapters and trust `~/.codex/hooks.json`
291
292
  - `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
293
+ - `Helper runtime:` to show `.ai/harness/scripts/*` implementations and `scripts/*` compatibility wrappers after apply
293
294
  - `--- External Tooling ---` to show default gstack/Waza/gbrain routing plus advisory install/update hints
294
295
 
295
296
  ### Next two commands
@@ -380,8 +381,8 @@ Most common guards:
380
381
 
381
382
  ## Current Release
382
383
 
383
- - npm package: `repo-harness@0.4.1`
384
- - Generated workflow stamp: `repo-harness@0.4.1+template@0.4.1`
384
+ - npm package: `repo-harness@0.4.2`
385
+ - Generated workflow stamp: `repo-harness@0.4.2+template@0.4.2`
385
386
  - GitHub repository: `Ancienttwo/repo-harness`
386
387
  - Release history: [`docs/CHANGELOG.md`](docs/CHANGELOG.md)
387
388
 
@@ -431,7 +432,8 @@ Most common guards:
431
432
 
432
433
  ## Acknowledgements and Workflow Influences
433
434
 
434
- `repo-harness` is built around a small set of external skills and repos that
435
+ `repo-harness` is built around a small set of external skills, repos, and agent
436
+ runtimes that
435
437
  proved useful while this project was being designed, debugged, and released.
436
438
  They are acknowledged here because they shaped the workflow contract, but they
437
439
  are not ordinary bundled product dependencies.
@@ -443,6 +445,20 @@ are not ordinary bundled product dependencies.
443
445
  | 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
446
  | `mermaid` | Human-readable architecture and system-flow diagrams when Mermaid is not enough | Runtime-referenced skill, not vendored into generated repos |
445
447
  | 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 |
448
+ | 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 |
449
+
450
+ ### GitHub Contributor Attribution
451
+
452
+ When Codex materially contributes to a commit, use GitHub's standard co-author
453
+ trailer format at the end of the commit message:
454
+
455
+ ```text
456
+ Co-authored-by: codex <codex@openai.com>
457
+ ```
458
+
459
+ Keep this opt-in and visible per commit. Do not bake it into downstream
460
+ repo-harness commit scripts or hooks unless that repo explicitly adopts the same
461
+ policy.
446
462
 
447
463
  ## Action Command Skills
448
464
 
@@ -450,7 +466,8 @@ Source-owned command facades live in `assets/skill-commands/`. They keep host
450
466
  skill discovery compatible while the CLI and hooks own execution:
451
467
 
452
468
  - 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)
469
+ - Product planning layer: `repo-harness-prd` (upper-layer PRDs in `plans/prds/`, evidence-marked unknowns, sprint-consumable sections)
470
+ - Sprint program layer: `repo-harness-sprint` (ordered sprint backlogs in `plans/sprints/`, each row expanded with `$think` before the contract flow)
454
471
  - 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
472
  - Branch project creation command: `repo-harness-scaffold`
456
473
 
package/README.zh-CN.md CHANGED
@@ -23,20 +23,19 @@ 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
+ ## 0.4.2 新特性
27
+
28
+ - **PRD-to-Sprint planning hierarchy。** `repo-harness-prd` 负责
29
+ `plans/prds/` 下的上层产品需求,`repo-harness-sprint` 负责把 PRD 或明确
30
+ slice 推成 `plans/sprints/*.sprint.md` 下的有序执行 backlog。
31
+ - **Generated helper runtime isolation。** 下游安装把真实 helper 实现放到
32
+ `.ai/harness/scripts/`,root `scripts/*` 只保留 compatibility wrappers;
33
+ 自托管源码仓库继续以 root `scripts/` 作为 source runtime
34
+ - **Subagent return-channel guard。** Managed hook routes 增加 return-channel
35
+ guard,要求 delegated runs 回到 parent session 汇报,避免绕过 file-backed
36
+ contract
37
+ - **Release path alignment。** PRD/Sprint eval fixtures、workflow checks 和
38
+ command guidance 现在都指向同一个 installed helper runtime。
40
39
 
41
40
  ## 产品做什么
42
41
 
@@ -192,10 +191,10 @@ npx -y repo-harness update
192
191
  repo-local verification surfaces。
193
192
 
194
193
  npm package 和 generated workflow stamp 现在共用 `0.4.x` release line。
195
- `repo-harness@0.4.1` 继续把首次全局引导(`repo-harness init`)
194
+ `repo-harness@0.4.2` 继续把首次全局引导(`repo-harness init`)
196
195
  和 repo-local 刷新(`repo-harness update`)拆开,并在 `0.4.0` loop-engine
197
- surfaces 之上强化 session-scoped hook statecentral-first hook execution、
198
- workflow-document migration 和 release-gate stability
196
+ surfaces 之上加入 PRD-to-Sprint planning hierarchyisolated generated-project
197
+ helper runtime、subagent return-channel guard 和 release-path alignment
199
198
  这些能力叠加在改名后的 CLI、user-level hook adapter bootstrap、AI-native scaffold overlays、
200
199
  typed prompt-guard decision engine、plan-stem task artifact 命名、`REPO_HARNESS_*`
201
200
  runtime aliases、Waza runtime skill sync,以及 maintainer 发布 npm 前使用的 release gate 之上。
@@ -334,8 +333,8 @@ hook block 工作时,先看 terminal 里的结构化输出。核心字段是
334
333
 
335
334
  ## 当前 Release
336
335
 
337
- - npm package:`repo-harness@0.4.1`
338
- - Generated workflow stamp:`repo-harness@0.4.1+template@0.4.1`
336
+ - npm package:`repo-harness@0.4.2`
337
+ - Generated workflow stamp:`repo-harness@0.4.2+template@0.4.2`
339
338
  - GitHub repository:`Ancienttwo/repo-harness`
340
339
  - Release history:[`docs/CHANGELOG.md`](docs/CHANGELOG.md)
341
340
 
@@ -373,6 +372,16 @@ decision rationale 的要求,来自他的贡献与启发。
373
372
  product discovery、plan/design review、release 文档、knowledge sync 和
374
373
  handoff retrieval 的工作流设计。
375
374
 
375
+ 感谢 OpenAI Codex 作为本仓库主要执行 agent 参与实现、验证和收口。Codex 对某个
376
+ commit 有实质贡献时,GitHub contributor 署名使用显式 trailer:
377
+
378
+ ```text
379
+ Co-authored-by: codex <codex@openai.com>
380
+ ```
381
+
382
+ 这条署名保持逐 commit 显式添加,不把它藏进下游 `repo-harness` commit 脚本或 hook
383
+ 里,除非目标仓库自己采用同样策略。
384
+
376
385
  ## Action Command Skills
377
386
 
378
387
  公共 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 -->
@@ -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": [
@@ -15,6 +15,24 @@ workflow_rotate_events_file ".ai/harness/architecture/events.jsonl" 2>/dev/null
15
15
 
16
16
  resume_file="$(workflow_resume_packet_file)"
17
17
 
18
+ helper_script_path() {
19
+ local helper_name="$1"
20
+ local helper_dir
21
+
22
+ helper_dir="$(workflow_policy_get '.harness.helper_runtime_dir' '.ai/harness/scripts')"
23
+ if [[ -f "$helper_dir/$helper_name" ]]; then
24
+ printf '%s/%s' "$helper_dir" "$helper_name"
25
+ return 0
26
+ fi
27
+
28
+ if [[ -f "scripts/$helper_name" ]]; then
29
+ printf '%s/%s' "scripts" "$helper_name"
30
+ return 0
31
+ fi
32
+
33
+ printf '%s/%s' "$helper_dir" "$helper_name"
34
+ }
35
+
18
36
  resume_available() {
19
37
  [[ -f "$resume_file" ]] || return 1
20
38
  grep -Fq "<!-- generated-by: repo-harness codex-handoff-resume v1 -->" "$resume_file" || return 1
@@ -138,8 +156,10 @@ architecture_queue_pending() {
138
156
  local pending_count="0"
139
157
  local oldest_epoch="" oldest_days="unknown"
140
158
  local now_epoch request detected detected_date detected_epoch
159
+ local queue_script
141
160
 
142
161
  [[ -d "$requests_dir" ]] || return 1
162
+ queue_script="$(helper_script_path "architecture-queue.sh")"
143
163
 
144
164
  now_epoch="$(date '+%s' 2>/dev/null || true)"
145
165
  while IFS= read -r request; do
@@ -168,13 +188,13 @@ architecture_queue_pending() {
168
188
  ${pending_count} capabilities have pending architecture drift (oldest ${oldest_days}). Run:
169
189
 
170
190
  \`\`\`bash
171
- bash scripts/architecture-queue.sh status
191
+ bash ${queue_script} status
172
192
  \`\`\`
173
193
  EOF_CONTEXT
174
194
  }
175
195
 
176
196
  pending_plan_capture_context() {
177
- local active_plan summary draft_path prompt_slug kind source_ref capture_source source_arg
197
+ local active_plan summary draft_path prompt_slug kind source_ref capture_source source_arg capture_script
178
198
 
179
199
  workflow_pending_orchestration_is_fresh || return 1
180
200
  active_plan="$(get_active_plan || true)"
@@ -190,6 +210,7 @@ pending_plan_capture_context() {
190
210
  if [[ -n "$source_ref" ]]; then
191
211
  source_arg=" --source-ref <source-ref>"
192
212
  fi
213
+ capture_script="$(helper_script_path "capture-plan.sh")"
193
214
 
194
215
  cat <<EOF_CONTEXT
195
216
  # Pending Plan Capture
@@ -203,13 +224,13 @@ A host/thread planning discussion is pending capture and no active repo plan is
203
224
  Capture the decision-complete plan body:
204
225
 
205
226
  \`\`\`bash
206
- printf '%s\n' '<decision-complete plan body>' | bash scripts/capture-plan.sh --slug ${prompt_slug:-<slug>} --title <title> --status Draft --source ${capture_source} --orchestration-kind ${capture_source} --route planning${source_arg}
227
+ printf '%s\n' '<decision-complete plan body>' | bash ${capture_script} --slug ${prompt_slug:-<slug>} --title <title> --status Draft --source ${capture_source} --orchestration-kind ${capture_source} --route planning${source_arg}
207
228
  \`\`\`
208
229
 
209
230
  If the user has already approved implementation:
210
231
 
211
232
  \`\`\`bash
212
- printf '%s\n' '<approved plan body>' | bash scripts/capture-plan.sh --slug ${prompt_slug:-<slug>} --title <title> --status Approved --source ${capture_source} --orchestration-kind ${capture_source} --route planning --execute${source_arg}
233
+ printf '%s\n' '<approved plan body>' | bash ${capture_script} --slug ${prompt_slug:-<slug>} --title <title> --status Approved --source ${capture_source} --orchestration-kind ${capture_source} --route planning --execute${source_arg}
213
234
  \`\`\`
214
235
  EOF_CONTEXT
215
236
  }
@@ -276,6 +297,7 @@ EOF_CONTEXT
276
297
  active_sprint_context() {
277
298
  local marker=".ai/harness/sprint/active-sprint"
278
299
  local sprint_file status progress next_task
300
+ local sprint_script capture_script
279
301
 
280
302
  if [[ -f ".ai/harness/policy.json" ]] && command -v jq >/dev/null 2>&1; then
281
303
  marker="$(jq -r '.sprints.active_marker_file // empty' .ai/harness/policy.json 2>/dev/null || true)"
@@ -311,13 +333,16 @@ active_sprint_context() {
311
333
  }
312
334
  END { if (!found) print "(none)" }
313
335
  ' "$sprint_file")"
336
+ sprint_script="$(helper_script_path "sprint-backlog.sh")"
337
+ capture_script="$(helper_script_path "capture-plan.sh")"
314
338
 
315
339
  cat <<EOF_CONTEXT
316
340
  # Active Sprint
317
341
 
318
342
  - Sprint: \`${sprint_file}\` status=${status:-unknown} backlog=${progress}
319
343
  - Next sprint task: ${next_task}
320
- - Rule: run backlog tasks through the existing plan -> contract -> worktree flow (\`scripts/sprint-backlog.sh next\`); \`tasks/todos.md\` stays the deferred-goal ledger.
344
+ - Rule: a Sprint is a long-task container. Use \`\$think\` to expand the next sprint task into a detailed \`plans/plan-*.md\`, then run the existing plan -> contract -> worktree flow. \`tasks/todos.md\` stays the deferred-goal ledger.
345
+ - Entrypoint: inspect with \`${sprint_script} next\`; after \`\$think\` produces an approved plan, capture it with \`${capture_script} --source waza-think --source-ref sprint:${sprint_file}#${next_task}\`.
321
346
  EOF_CONTEXT
322
347
  }
323
348
 
@@ -15,6 +15,12 @@
15
15
  { "type": "command", "command": "repo=$(git rev-parse --show-toplevel 2>/dev/null) || exit 0; 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_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_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": [
@@ -0,0 +1,107 @@
1
+ #!/bin/bash
2
+ # Subagent Return Channel Guard — PreToolUse on Task|Agent|SendUserMessage.
3
+ # Spawned subagents return only their final text to the caller. If they send a
4
+ # report through SendUserMessage, the user may see it but the parent Agent tool
5
+ # result receives only a tiny transition/final text. This guard appends that
6
+ # return-channel contract to spawned agent prompts and blocks subagent
7
+ # SendUserMessage calls that would bypass the caller.
8
+
9
+ set -euo pipefail
10
+
11
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12
+ # shellcheck source=/dev/null
13
+ . "$SCRIPT_DIR/hook-input.sh"
14
+
15
+ hook_read_stdin_once
16
+ input="$HOOK_STDIN_JSON"
17
+ [[ -n "$input" ]] || exit 0
18
+
19
+ CONTRACT_MARKER="[repo-harness:return-channel]"
20
+ CONTRACT_TEXT=$'\n\n[repo-harness:return-channel] Your final text message is the only channel returned to your caller. Put the complete findings/report in final text. Do not call SendUserMessage for report delivery; content sent through SendUserMessage is delivered outside the Agent tool result.'
21
+
22
+ if command -v bun >/dev/null 2>&1; then
23
+ JSON_INPUT="$input" \
24
+ RETURN_CONTRACT_MARKER="$CONTRACT_MARKER" \
25
+ RETURN_CONTRACT_TEXT="$CONTRACT_TEXT" \
26
+ bun -e '
27
+ try {
28
+ const input = JSON.parse(process.env.JSON_INPUT ?? "");
29
+ const toolName = String(input.tool_name ?? "");
30
+ const marker = process.env.RETURN_CONTRACT_MARKER ?? "";
31
+ const contract = process.env.RETURN_CONTRACT_TEXT ?? "";
32
+
33
+ if (toolName === "Task" || toolName === "Agent") {
34
+ const toolInput = input.tool_input;
35
+ if (!toolInput || typeof toolInput !== "object" || Array.isArray(toolInput)) process.exit(0);
36
+ if (typeof toolInput.prompt !== "string" || toolInput.prompt.includes(marker)) process.exit(0);
37
+
38
+ process.stdout.write(JSON.stringify({
39
+ hookSpecificOutput: {
40
+ hookEventName: "PreToolUse",
41
+ permissionDecision: "allow",
42
+ permissionDecisionReason: "subagent-return-channel-guard: delivery contract appended to spawn prompt",
43
+ updatedInput: {
44
+ ...toolInput,
45
+ prompt: toolInput.prompt + contract,
46
+ },
47
+ },
48
+ }) + "\n");
49
+ process.exit(0);
50
+ }
51
+
52
+ if (toolName === "SendUserMessage") {
53
+ const agentId = String(input.agent_id ?? "");
54
+ const transcriptPath = String(input.transcript_path ?? "");
55
+ if (!agentId && !transcriptPath.includes("/subagents/agent-")) process.exit(0);
56
+
57
+ process.stdout.write(JSON.stringify({
58
+ hookSpecificOutput: {
59
+ hookEventName: "PreToolUse",
60
+ permissionDecision: "deny",
61
+ permissionDecisionReason: "subagent-return-channel-guard: SendUserMessage from a spawned subagent does not reach the caller Agent tool result. Put the full report in final text and end the subagent turn.",
62
+ },
63
+ }) + "\n");
64
+ }
65
+ } catch {
66
+ process.exit(0);
67
+ }
68
+ ' 2>/dev/null || true
69
+ exit 0
70
+ fi
71
+
72
+ command -v jq >/dev/null 2>&1 || exit 0
73
+
74
+ tool_name="$(printf '%s' "$input" | jq -r '.tool_name // empty' 2>/dev/null || true)"
75
+ case "$tool_name" in
76
+ Task|Agent)
77
+ printf '%s' "$input" | jq -e '.tool_input | type == "object"' >/dev/null 2>&1 || exit 0
78
+ printf '%s' "$input" | jq -e '.tool_input.prompt | type == "string"' >/dev/null 2>&1 || exit 0
79
+ if printf '%s' "$input" | jq -e --arg marker "$CONTRACT_MARKER" '.tool_input.prompt | contains($marker)' >/dev/null 2>&1; then
80
+ exit 0
81
+ fi
82
+
83
+ printf '%s' "$input" | jq -c --arg contract "$CONTRACT_TEXT" '
84
+ .tool_input as $toolInput
85
+ | {
86
+ hookSpecificOutput: {
87
+ hookEventName: "PreToolUse",
88
+ permissionDecision: "allow",
89
+ permissionDecisionReason: "subagent-return-channel-guard: delivery contract appended to spawn prompt",
90
+ updatedInput: ($toolInput + {prompt: ($toolInput.prompt + $contract)})
91
+ }
92
+ }'
93
+ ;;
94
+ SendUserMessage)
95
+ agent_id="$(printf '%s' "$input" | jq -r '.agent_id // empty' 2>/dev/null || true)"
96
+ transcript_path="$(printf '%s' "$input" | jq -r '.transcript_path // empty' 2>/dev/null || true)"
97
+ [[ -n "$agent_id" || "$transcript_path" == *"/subagents/agent-"* ]] || exit 0
98
+
99
+ jq -nc '{
100
+ hookSpecificOutput: {
101
+ hookEventName: "PreToolUse",
102
+ permissionDecision: "deny",
103
+ permissionDecisionReason: "subagent-return-channel-guard: SendUserMessage from a spawned subagent does not reach the caller Agent tool result. Put the full report in final text and end the subagent turn."
104
+ }
105
+ }'
106
+ ;;
107
+ esac
@@ -44,13 +44,13 @@
44
44
  - Treat `_ref/` as an occasional ignored external reference checkout cache; read or refresh it for comparison, but keep it out of commits and cite repo+commit/tag+path in `tasks/notes/` or `docs/researches/` when it influences a decision.
45
45
  - Treat `deploy/` as the trackable deployment and operations surface for runbooks, submission materials, release checklists, helper scripts, ordered SQL files under `deploy/sql/`, and env examples.
46
46
  - Treat `_ops/` as ignored local operations state for secrets, real env files, provider state, artifacts, logs, and scratch files; do not commit or agent-edit `_ops/*`.
47
- - Treat contract-level execution as worktree-first: `scripts/plan-to-todo.sh --plan <approved-plan>` starts a linked `codex/<slug>` worktree when policy enables it, and `scripts/contract-worktree.sh finish` merges back only after Waza `/check` and sprint verification pass.
48
- - Capture decision-complete Codex Plan mode, Waza `/think`, or `repo-harness-plan` outputs with `scripts/capture-plan.sh --slug <slug> --title <title>` so planning becomes a `plans/` artifact before implementation.
47
+ - Treat contract-level execution as worktree-first: `.ai/harness/scripts/plan-to-todo.sh --plan <approved-plan>` starts a linked `codex/<slug>` worktree when policy enables it, and `.ai/harness/scripts/contract-worktree.sh finish` merges back only after Waza `/check` and sprint verification pass.
48
+ - Capture decision-complete Codex Plan mode, Waza `/think`, or `repo-harness-plan` outputs with `.ai/harness/scripts/capture-plan.sh --slug <slug> --title <title>` so planning becomes a `plans/` artifact before implementation.
49
49
  - Route product discovery to gstack `office-hours`, complex engineering plans to gstack `plan-eng-review`, design plans to gstack `plan-design-review`, and daily small/medium planning, bug hunts, and checks to Waza `/think`, `/hunt`, and `/check`.
50
50
  - Route knowledge sync and handoff retrieval to `gbrain`.
51
- - Register valuable repo-authored docs in `.ai/harness/brain-manifest.json` with `sync.direction=repo-to-brain`; `scripts/sync-brain-docs.sh` and the PostEdit hook mirror only those explicit entries into the default brain vault.
51
+ - Register valuable repo-authored docs in `.ai/harness/brain-manifest.json` with `sync.direction=repo-to-brain`; `.ai/harness/scripts/sync-brain-docs.sh` and the PostEdit hook mirror only those explicit entries into the default brain vault.
52
52
  - Codex automation profile is runtime-referenced, not vendored: required skills are `health`, `check`, and `mermaid` from `~/.codex/skills`.
53
53
  - CodeGraph is required agent readiness for code navigation; keep `.codegraph/` ignored and use it for P1/P2 discovery, not hook correctness.
54
54
  - Treat Waza as Codex-first: `~/.codex/skills` is the Codex runtime source; `~/.agents/skills` is skills CLI staging/cache only.
55
- - Use `docs/reference-configs/agentic-development-flow.md` for routing details and `docs/reference-configs/external-tooling.md` plus `bash scripts/check-agent-tooling.sh --host both --check-updates` for environment checks.
55
+ - Use `docs/reference-configs/agentic-development-flow.md` for routing details and `docs/reference-configs/external-tooling.md` plus `bash .ai/harness/scripts/check-agent-tooling.sh --host both --check-updates` for environment checks.
56
56
  - If repo state conflicts with the task, use an isolated `codex/<task-slug>` worktree, validate with Waza `/check`, and merge back to `main` without unrelated dirty changes.