repo-harness 0.1.3 → 0.1.4

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 (35) hide show
  1. package/AGENTS.md +1 -1
  2. package/CLAUDE.md +1 -1
  3. package/README.md +9 -9
  4. package/README.zh-CN.md +7 -7
  5. package/assets/hooks/lib/workflow-state.sh +55 -12
  6. package/assets/partials/07-footer.partial.md +3 -3
  7. package/assets/partials/08-orchestration.partial.md +1 -1
  8. package/assets/partials-agents/04-task-protocol.partial.md +4 -4
  9. package/assets/partials-agents/06-quality-safety.partial.md +2 -2
  10. package/assets/reference-configs/evaluator-rubric.md +1 -1
  11. package/assets/reference-configs/harness-overview.md +7 -7
  12. package/assets/reference-configs/sprint-contracts.md +2 -2
  13. package/assets/templates/contract.template.md +8 -8
  14. package/assets/templates/helpers/archive-workflow.sh +5 -1
  15. package/assets/templates/helpers/capture-plan.sh +14 -13
  16. package/assets/templates/helpers/codex-handoff-resume.sh +40 -8
  17. package/assets/templates/helpers/contract-worktree.sh +25 -1
  18. package/assets/templates/helpers/ensure-task-workflow.sh +19 -19
  19. package/assets/templates/helpers/new-plan.sh +20 -12
  20. package/assets/templates/helpers/plan-to-todo.sh +48 -17
  21. package/assets/templates/plan.template.md +11 -11
  22. package/docs/reference-configs/evaluator-rubric.md +1 -1
  23. package/docs/reference-configs/harness-overview.md +7 -7
  24. package/docs/reference-configs/sprint-contracts.md +2 -2
  25. package/package.json +1 -1
  26. package/scripts/archive-workflow.sh +5 -1
  27. package/scripts/capture-plan.sh +14 -13
  28. package/scripts/codex-handoff-resume.sh +40 -8
  29. package/scripts/contract-worktree.sh +25 -1
  30. package/scripts/ensure-task-workflow.sh +19 -19
  31. package/scripts/lib/project-init-lib.sh +19 -19
  32. package/scripts/new-plan.sh +20 -12
  33. package/scripts/plan-to-todo.sh +48 -17
  34. package/src/cli/commands/status.ts +1 -1
  35. package/src/cli/index.ts +1 -1
package/AGENTS.md CHANGED
@@ -21,7 +21,7 @@ This repository self-hosts the `repo-harness` contract, formerly `repo-harness-s
21
21
  ## Operating Rules
22
22
 
23
23
  - Sync `tasks/` whenever substantive repo changes are made.
24
- - Use `tasks/notes/<slug>.notes.md` only for non-obvious slice decisions, deviations, tradeoffs, and open questions; do not use notes as durable memory or a task log, and archive/promote them deliberately when the slice closes.
24
+ - Use `tasks/notes/<plan-stem>.notes.md` only for non-obvious slice decisions, deviations, tradeoffs, and open questions; `<plan-stem>` is the active plan filename without `plan-` and `.md` (for example `20260531-0045-governance-workflow`). Do not use notes as durable memory or a task log, and archive/promote them deliberately when the slice closes.
25
25
  - Treat `.ai/hooks/` as the shared repo-local hook implementation; user-level `~/.claude/settings.json` and `~/.codex/hooks.json` are the host adapters.
26
26
  - Keep the umbrella hierarchy explicit: architecture owns stable truth, capability contracts own local agent context, `tasks/workstreams/<domain>/<capability>/` owns durable progress, and `tasks/todo.md` owns only deferred medium/long-term goals with tradeoff and revisit trigger.
27
27
  - Treat `.ai/context/capabilities.json` as the source of truth for capability prefixes; `agent-context-blocks.txt` and nested agent files are compatibility inputs only.
package/CLAUDE.md CHANGED
@@ -21,7 +21,7 @@ This repository self-hosts the `repo-harness` contract, formerly `repo-harness-s
21
21
  ## Operating Rules
22
22
 
23
23
  - Sync `tasks/` whenever substantive repo changes are made.
24
- - Use `tasks/notes/<slug>.notes.md` only for non-obvious slice decisions, deviations, tradeoffs, and open questions; do not use notes as durable memory or a task log, and archive/promote them deliberately when the slice closes.
24
+ - Use `tasks/notes/<plan-stem>.notes.md` only for non-obvious slice decisions, deviations, tradeoffs, and open questions; `<plan-stem>` is the active plan filename without `plan-` and `.md` (for example `20260531-0045-governance-workflow`). Do not use notes as durable memory or a task log, and archive/promote them deliberately when the slice closes.
25
25
  - Treat `.ai/hooks/` as the shared repo-local hook implementation; user-level `~/.claude/settings.json` and `~/.codex/hooks.json` are the host adapters.
26
26
  - Keep the umbrella hierarchy explicit: architecture owns stable truth, capability contracts own local agent context, `tasks/workstreams/<domain>/<capability>/` owns durable progress, and `tasks/todo.md` owns only deferred medium/long-term goals with tradeoff and revisit trigger.
27
27
  - Treat `.ai/context/capabilities.json` as the source of truth for capability prefixes; `agent-context-blocks.txt` and nested agent files are compatibility inputs only.
package/README.md CHANGED
@@ -77,9 +77,9 @@ flowchart TD
77
77
 
78
78
  Approve --> Project["Project plan into execution<br/>capture-plan.sh --execute<br/>or plan-to-todo.sh --plan"]
79
79
  Project --> Active["Active markers<br/>.ai/harness/active-plan<br/>.ai/harness/active-worktree"]
80
- Project --> Contract["Sprint contract<br/>tasks/contracts/task-slug.contract.md"]
81
- Project --> ReviewFile["Review file<br/>tasks/reviews/task-slug.review.md"]
82
- Project --> Notes["Task notes<br/>tasks/notes/task-slug.notes.md"]
80
+ Project --> Contract["Sprint contract<br/>tasks/contracts/YYYYMMDD-HHMM-task-slug.contract.md"]
81
+ Project --> ReviewFile["Review file<br/>tasks/reviews/YYYYMMDD-HHMM-task-slug.review.md"]
82
+ Project --> Notes["Task notes<br/>tasks/notes/YYYYMMDD-HHMM-task-slug.notes.md"]
83
83
 
84
84
  Contract --> WorktreePolicy{"Contract worktree required?"}
85
85
  WorktreePolicy -->|yes| Checkout["Checkout isolated worktree<br/>contract-worktree.sh start --plan<br/>branch codex/task-slug"]
@@ -121,12 +121,12 @@ npx -y repo-harness init
121
121
  ```
122
122
 
123
123
  The npm package release line is `0.1.x`; generated workflow compatibility is
124
- tracked separately as the `5.x` model line. The `0.1.3` package publishes the
124
+ tracked separately as the `5.x` model line. The `0.1.4` package publishes the
125
125
  renamed `repo-harness` CLI, user-level Claude/Codex hook adapter bootstrap,
126
- AI-native scaffold overlays, the typed prompt-guard decision engine, Waza
127
- runtime skill sync, `diagram-design` sync, and the release gate used by
128
- maintainers before npm publish. When working from a source checkout instead of
129
- npm, run:
126
+ AI-native scaffold overlays, the typed prompt-guard decision engine, plan-stem
127
+ task artifact naming, Waza runtime skill sync, `diagram-design` sync, and the
128
+ release gate used by maintainers before npm publish. When working from a source
129
+ checkout instead of npm, run:
130
130
 
131
131
  ```bash
132
132
  git clone https://github.com/Ancienttwo/repo-harness.git ~/Projects/repo-harness
@@ -250,7 +250,7 @@ Most common guards:
250
250
 
251
251
  ## Current Release
252
252
 
253
- - npm package: `repo-harness@0.1.3`
253
+ - npm package: `repo-harness@0.1.4`
254
254
  - Generated workflow compatibility: `5.2.3`
255
255
  - GitHub repository: `Ancienttwo/repo-harness`
256
256
  - Release history: [`docs/CHANGELOG.md`](docs/CHANGELOG.md)
package/README.zh-CN.md CHANGED
@@ -69,9 +69,9 @@ flowchart TD
69
69
 
70
70
  Approve --> Project["投射到执行面<br/>capture-plan.sh --execute<br/>或 plan-to-todo.sh --plan"]
71
71
  Project --> Active["Active markers<br/>.ai/harness/active-plan<br/>.ai/harness/active-worktree"]
72
- Project --> Contract["Sprint contract<br/>tasks/contracts/task-slug.contract.md"]
73
- Project --> ReviewFile["Review file<br/>tasks/reviews/task-slug.review.md"]
74
- Project --> Notes["Task notes<br/>tasks/notes/task-slug.notes.md"]
72
+ Project --> Contract["Sprint contract<br/>tasks/contracts/YYYYMMDD-HHMM-task-slug.contract.md"]
73
+ Project --> ReviewFile["Review file<br/>tasks/reviews/YYYYMMDD-HHMM-task-slug.review.md"]
74
+ Project --> Notes["Task notes<br/>tasks/notes/YYYYMMDD-HHMM-task-slug.notes.md"]
75
75
 
76
76
  Contract --> WorktreePolicy{"是否需要 contract worktree?"}
77
77
  WorktreePolicy -->|是| Checkout["Checkout 隔离 worktree<br/>contract-worktree.sh start --plan<br/>branch codex/task-slug"]
@@ -112,10 +112,10 @@ npx -y repo-harness init
112
112
  ```
113
113
 
114
114
  npm package release line 是 `0.1.x`;生成的 workflow compatibility model line
115
- 单独以 `5.x` 追踪。`repo-harness@0.1.3` 发布的是改名后的 CLI、Claude/Codex
115
+ 单独以 `5.x` 追踪。`repo-harness@0.1.4` 发布的是改名后的 CLI、Claude/Codex
116
116
  user-level hook adapter bootstrap、AI-native scaffold overlays、typed prompt-guard
117
- decision engine、Waza runtime skill sync、`diagram-design` sync,以及 maintainer
118
- 发布 npm 前使用的 release gate。
117
+ decision engine、plan-stem task artifact 命名、Waza runtime skill sync
118
+ `diagram-design` sync,以及 maintainer 发布 npm 前使用的 release gate。
119
119
 
120
120
  如果从源码 checkout 工作:
121
121
 
@@ -235,7 +235,7 @@ hook block 工作时,先看 terminal 里的结构化输出。核心字段是
235
235
 
236
236
  ## 当前 Release
237
237
 
238
- - npm package:`repo-harness@0.1.3`
238
+ - npm package:`repo-harness@0.1.4`
239
239
  - Generated workflow compatibility:`5.2.3`
240
240
  - GitHub repository:`Ancienttwo/repo-harness`
241
241
  - Release history:[`docs/CHANGELOG.md`](docs/CHANGELOG.md)
@@ -275,7 +275,7 @@ get_todo_source_plan() {
275
275
  awk -F': ' '/^\> \*\*Source Plan\*\*:/ {print $2; exit}' tasks/todo.md | xargs
276
276
  }
277
277
 
278
- derive_contract_path() {
278
+ workflow_plan_slug_from_path() {
279
279
  local plan_file="$1"
280
280
  local base slug
281
281
 
@@ -286,7 +286,43 @@ derive_contract_path() {
286
286
  return 1
287
287
  fi
288
288
 
289
- printf 'tasks/contracts/%s.contract.md' "$slug"
289
+ printf '%s' "$slug"
290
+ }
291
+
292
+ workflow_plan_artifact_stem_from_path() {
293
+ local plan_file="$1"
294
+ local base stem
295
+
296
+ base="$(basename "$plan_file")"
297
+ stem="$(printf '%s' "$base" | sed -E 's/^plan-//; s/\.md$//')"
298
+ if [[ "$stem" =~ ^[0-9]{8}-[0-9]{4}-.+ ]]; then
299
+ printf '%s' "$stem"
300
+ return 0
301
+ fi
302
+
303
+ workflow_plan_slug_from_path "$plan_file"
304
+ }
305
+
306
+ workflow_preferred_or_legacy_path() {
307
+ local preferred="$1"
308
+ local legacy="$2"
309
+
310
+ if [[ -f "$preferred" ]] || [[ ! -f "$legacy" ]]; then
311
+ printf '%s' "$preferred"
312
+ else
313
+ printf '%s' "$legacy"
314
+ fi
315
+ }
316
+
317
+ derive_contract_path() {
318
+ local plan_file="$1"
319
+ local stem slug
320
+
321
+ stem="$(workflow_plan_artifact_stem_from_path "$plan_file" || true)"
322
+ slug="$(workflow_plan_slug_from_path "$plan_file" || true)"
323
+ [[ -n "$stem" && -n "$slug" ]] || return 1
324
+
325
+ workflow_preferred_or_legacy_path "tasks/contracts/${stem}.contract.md" "tasks/contracts/${slug}.contract.md"
290
326
  }
291
327
 
292
328
  workflow_plan_slug() {
@@ -296,7 +332,7 @@ workflow_plan_slug() {
296
332
  return 1
297
333
  fi
298
334
 
299
- slug="$(basename "$active_plan" | sed -E 's/^plan-[0-9]{8}-[0-9]{4}-//; s/\.md$//')"
335
+ slug="$(workflow_plan_slug_from_path "$active_plan" || true)"
300
336
  if [[ -n "$slug" ]]; then
301
337
  printf '%s' "$slug"
302
338
  return 0
@@ -930,7 +966,7 @@ workflow_contract_slug() {
930
966
  local active_plan slug
931
967
  active_plan="$(get_active_plan || true)"
932
968
  [[ -n "$active_plan" ]] || return 1
933
- slug="$(basename "$active_plan" | sed -E 's/^plan-[0-9]{8}-[0-9]{4}-//; s/\.md$//')"
969
+ slug="$(workflow_plan_slug_from_path "$active_plan" || true)"
934
970
  [[ -n "$slug" ]] || return 1
935
971
  printf '%s' "$slug"
936
972
  }
@@ -945,18 +981,25 @@ workflow_active_contract() {
945
981
  }
946
982
 
947
983
  workflow_active_review() {
948
- local slug
949
- slug="$(workflow_contract_slug || true)"
950
- [[ -n "$slug" ]] || return 1
951
- printf 'tasks/reviews/%s.review.md' "$slug"
984
+ local active_plan stem slug reviews_dir
985
+ active_plan="$(get_active_plan || true)"
986
+ [[ -n "$active_plan" ]] || return 1
987
+ stem="$(workflow_plan_artifact_stem_from_path "$active_plan" || true)"
988
+ slug="$(workflow_plan_slug_from_path "$active_plan" || true)"
989
+ [[ -n "$stem" && -n "$slug" ]] || return 1
990
+ reviews_dir="$(workflow_repo_relative_path "$(workflow_policy_get '.tasks.reviews_dir' 'tasks/reviews')" 'tasks/reviews' 'tasks/')"
991
+ workflow_preferred_or_legacy_path "${reviews_dir}/${stem}.review.md" "${reviews_dir}/${slug}.review.md"
952
992
  }
953
993
 
954
994
  workflow_active_notes() {
955
- local slug notes_dir
956
- slug="$(workflow_contract_slug || true)"
957
- [[ -n "$slug" ]] || return 1
995
+ local active_plan stem slug notes_dir
996
+ active_plan="$(get_active_plan || true)"
997
+ [[ -n "$active_plan" ]] || return 1
998
+ stem="$(workflow_plan_artifact_stem_from_path "$active_plan" || true)"
999
+ slug="$(workflow_plan_slug_from_path "$active_plan" || true)"
1000
+ [[ -n "$stem" && -n "$slug" ]] || return 1
958
1001
  notes_dir="$(workflow_repo_relative_path "$(workflow_policy_get '.tasks.notes_dir' 'tasks/notes')" 'tasks/notes' 'tasks/')"
959
- printf '%s/%s.notes.md' "$notes_dir" "$slug"
1002
+ workflow_preferred_or_legacy_path "${notes_dir}/${stem}.notes.md" "${notes_dir}/${slug}.notes.md"
960
1003
  }
961
1004
 
962
1005
  workflow_checks_file() {
@@ -14,9 +14,9 @@ CLAUDE.md is a routing card. Keep context minimal and load only what the current
14
14
  |---------|----------------|
15
15
  | Deep codebase investigation | `tasks/research.md` |
16
16
  | Active implementation planning | `plans/plan-*.md` |
17
- | Sprint done definition | `tasks/contracts/<slug>.contract.md` |
18
- | Evaluator verdict | `tasks/reviews/<slug>.review.md` |
19
- | Implementation notes | `tasks/notes/<slug>.notes.md` |
17
+ | Sprint done definition | `tasks/contracts/<plan-stem>.contract.md` |
18
+ | Evaluator verdict | `tasks/reviews/<plan-stem>.review.md` |
19
+ | Implementation notes | `tasks/notes/<plan-stem>.notes.md` |
20
20
  | Latest verification evidence | `.ai/harness/checks/latest.json` |
21
21
  | Historical implementation context | `plans/archive/` and `tasks/archive/` |
22
22
  | Agentic skill routing | `docs/reference-configs/agentic-development-flow.md` |
@@ -36,7 +36,7 @@
36
36
  - Define per-sprint contract files in `tasks/contracts/`.
37
37
  - Verify contract exit criteria before claiming completion.
38
38
  - Require Waza `/check` to produce the matching evaluator review before any done/completed response.
39
- - Use `scripts/verify-contract.sh --contract tasks/contracts/{slug}.contract.md --strict`.
39
+ - Use `scripts/verify-contract.sh --contract tasks/contracts/{plan-stem}.contract.md --strict`.
40
40
 
41
41
  ### 7. Balanced Elegance
42
42
  - Redesign hacky non-trivial fixes before shipping.
@@ -29,16 +29,16 @@ RULES:
29
29
  - Keep multiple active plans in parallel worktrees when tasks diverge; fill workflow inventory before implementation: active plan, owning worktree, contract, review, notes, deferred ledger, checks, runs, scope owner, switching rule, and worktree path
30
30
  - Process annotation notes before implementing
31
31
  - Extract approved plan tasks into tasks/todo.md
32
- - Define task contracts in tasks/contracts/{slug}.contract.md
33
- - Fill tasks/reviews/{slug}.review.md from Waza /check after verification
34
- - Record only non-obvious implementation decisions, deviations, tradeoffs, and open questions in tasks/notes/{slug}.notes.md
32
+ - Define task contracts in tasks/contracts/{plan-stem}.contract.md
33
+ - Fill tasks/reviews/{plan-stem}.review.md from Waza /check after verification
34
+ - Record only non-obvious implementation decisions, deviations, tradeoffs, and open questions in tasks/notes/{plan-stem}.notes.md
35
35
  - Verify contracts before claiming completion
36
36
  - Require review pass before claiming completion
37
37
  - Keep tasks/todo.md limited to deferred medium/long-term goals, with tradeoff and revisit trigger; do not duplicate plan Task Breakdown
38
38
  - Record correction-derived prevention rules in tasks/lessons.md
39
39
  - Distill repeated corrections into tasks/lessons.md instead of keeping them in tasks/todo.md
40
40
  - Capture deep findings and hidden contracts in tasks/research.md
41
- - Keep sprint-level verification notes, behavior diffs, and residual risks in tasks/reviews/{slug}.review.md
41
+ - Keep sprint-level verification notes, behavior diffs, and residual risks in tasks/reviews/{plan-stem}.review.md
42
42
  - Do not use implementation notes as durable memory or task logs; archive them on close and promote only after evidence shows the rule should outlive the sprint
43
43
  - Promote implementation-ready follow-up work into a new plans/plan-{timestamp}-{slug}.md file; keep deferred goals in tasks/todo.md only when intentionally postponed
44
44
  - Treat `.ai/hooks/` as the shared automation entrypoint when repo scripts reference hook-backed workflow checks
@@ -5,8 +5,8 @@
5
5
  - Run impact-based checks: typecheck, tests, lint/build.
6
6
  - Run `bash scripts/check-task-workflow.sh --strict` before claiming the workflow is clean.
7
7
  - Run `bash scripts/verify-contract.sh --contract <active-plan-contract> --strict` before any done/completed response when the active plan has a contract.
8
- - Require the matching `tasks/reviews/<slug>.review.md` to recommend pass before claiming completion.
9
- - Require the matching `tasks/notes/<slug>.notes.md` to capture material implementation decisions before review.
8
+ - Require the matching `tasks/reviews/<plan-stem>.review.md` to recommend pass before claiming completion.
9
+ - Require the matching `tasks/notes/<plan-stem>.notes.md` to capture material implementation decisions before review.
10
10
 
11
11
  ### Safety Rules
12
12
  - Do not silently expand scope beyond approved plan.
@@ -9,7 +9,7 @@
9
9
 
10
10
  ## Repo Role
11
11
 
12
- Keep pass/fail evidence in `tasks/reviews/<slug>.review.md` and
12
+ Keep pass/fail evidence in `tasks/reviews/<plan-stem>.review.md` and
13
13
  `.ai/harness/checks/latest.json`. Use the external rubric for detailed scoring
14
14
  dimensions and review examples.
15
15
 
@@ -5,18 +5,18 @@ This repo uses a shared long-running harness. The durable workflow lives in repo
5
5
  ## Roles
6
6
 
7
7
  - **Planner** updates `docs/spec.md`, researches constraints, and writes or approves `plans/plan-*.md`.
8
- - **Generator** implements only against the active sprint contract and the plan's `## Task Breakdown`, leaving `tasks/todo.md` as a deferred-goal ledger, and records task-local implementation judgments in `tasks/notes/<slug>.notes.md`.
9
- - **Evaluator** runs Waza `/check`, then writes `tasks/reviews/<slug>.review.md` using fresh evidence from `.ai/harness/checks/latest.json` and `.ai/harness/runs/*.json`.
8
+ - **Generator** implements only against the active sprint contract and the plan's `## Task Breakdown`, leaving `tasks/todo.md` as a deferred-goal ledger, and records task-local implementation judgments in `tasks/notes/<plan-stem>.notes.md`.
9
+ - **Evaluator** runs Waza `/check`, then writes `tasks/reviews/<plan-stem>.review.md` using fresh evidence from `.ai/harness/checks/latest.json` and `.ai/harness/runs/*.json`.
10
10
 
11
11
  ## State Flow
12
12
 
13
13
  1. `docs/spec.md` captures stable product intent.
14
14
  2. `plans/plan-*.md` captures a concrete execution approach.
15
- 3. `tasks/contracts/<slug>.contract.md` defines done for the active sprint.
15
+ 3. `tasks/contracts/<plan-stem>.contract.md` defines done for the active sprint.
16
16
  4. `tasks/current.md` is a tracked mainline status snapshot derived from workflow artifacts; it is not a live lock, kanban board, or implementation gate.
17
17
  5. `tasks/todo.md` is the execution projection for the active sprint.
18
- 6. `tasks/notes/<slug>.notes.md` records design decisions, deviations, tradeoffs, open questions, and promotion candidates for this sprint only.
19
- 7. `tasks/reviews/<slug>.review.md` records evaluator judgment.
18
+ 6. `tasks/notes/<plan-stem>.notes.md` records design decisions, deviations, tradeoffs, open questions, and promotion candidates for this sprint only.
19
+ 7. `tasks/reviews/<plan-stem>.review.md` records evaluator judgment.
20
20
  8. `.ai/harness/policy.json` is the machine-readable workflow contract.
21
21
  9. `information_lifecycle` inside `.ai/harness/policy.json` separates notes, raw evidence, reusable assets, advisory memory, and external knowledge.
22
22
  10. `agentic_development` inside `.ai/harness/policy.json` captures product, engineering, design, bug-hunt, and review routing.
@@ -41,7 +41,7 @@ This repo uses a shared long-running harness. The durable workflow lives in repo
41
41
  - Use `docs/reference-configs/agentic-development-flow.md` for skill routing and `docs/reference-configs/external-tooling.md` for install/update commands.
42
42
  - Use `docs/reference-configs/global-working-rules.md` as the user-level Claude/Codex rule template; keep repo-local workflow contracts in repo files.
43
43
  - Externalized reference docs are indexed by `.ai/harness/brain-manifest.json` and checked by `scripts/check-brain-manifest.sh`. Valuable repo docs can opt into default-brain mirroring with `sync.direction=repo-to-brain`; `post-edit-guard.sh` then calls `scripts/sync-brain-docs.sh --changed <path>` for that specific file.
44
- - Contract-level execution should run in an isolated `codex/<task-slug>` worktree. Merge back only after the contract is fulfilled, `tasks/reviews/<slug>.review.md` recommends pass, and the target worktree is clean.
44
+ - Contract-level execution should run in an isolated `codex/<task-slug>` worktree. Merge back only after the contract is fulfilled, `tasks/reviews/<plan-stem>.review.md` recommends pass, and the target worktree is clean.
45
45
 
46
46
  ## Documentation Profile
47
47
 
@@ -53,7 +53,7 @@ This repo uses a shared long-running harness. The durable workflow lives in repo
53
53
 
54
54
  ## Information Lifecycle
55
55
 
56
- - Notes: `tasks/notes/<slug>.notes.md` is task-local and auditable. It should not be treated as durable knowledge by default.
56
+ - Notes: `tasks/notes/<plan-stem>.notes.md` is task-local and auditable. It should not be treated as durable knowledge by default.
57
57
  - Current status: `tasks/current.md` is a tracked derived snapshot for orientation only. It must be regenerated from source artifacts and must not contain hand-written kanban/checklist state.
58
58
  - Evidence: `.ai/harness/checks/latest.json` is the current gate, while `.ai/harness/runs/*.json` keeps immutable verification snapshots for later audit.
59
59
  - Memory: `tasks/research.md`, `tasks/lessons.md`, and gbrain are advisory. Current repo state and evidence override summaries.
@@ -28,8 +28,8 @@ Sprint contracts are the repo-local agreement between planner, generator, and ev
28
28
  ## Review Coupling
29
29
 
30
30
  - A contract is not truly done until the matching review file records a passing recommendation.
31
- - `tasks/reviews/<slug>.review.md` should be filled from Waza `/check` after verification and cite the contract, implementation notes, checks file, run snapshot, `## External Acceptance Advice`, and any manual observations.
32
- - `tasks/notes/<slug>.notes.md` captures task-local decisions and should be archived or promoted deliberately, not left as hidden long-term memory.
31
+ - `tasks/reviews/<plan-stem>.review.md` should be filled from Waza `/check` after verification and cite the contract, implementation notes, checks file, run snapshot, `## External Acceptance Advice`, and any manual observations.
32
+ - `tasks/notes/<plan-stem>.notes.md` captures task-local decisions and should be archived or promoted deliberately, not left as hidden long-term memory.
33
33
 
34
34
  ## Worktree Lifecycle
35
35
 
@@ -5,8 +5,8 @@
5
5
  > **Owner**: {{OWNER}}
6
6
  > **Capability ID**: {{CAPABILITY_ID}}
7
7
  > **Last Updated**: {{TIMESTAMP}}
8
- > **Review File**: `tasks/reviews/{{TASK_SLUG}}.review.md`
9
- > **Notes File**: `tasks/notes/{{TASK_SLUG}}.notes.md`
8
+ > **Review File**: `{{REVIEW_FILE}}`
9
+ > **Notes File**: `{{NOTES_FILE}}`
10
10
 
11
11
  ## Goal
12
12
 
@@ -21,8 +21,8 @@ Describe the exact outcome this task must deliver.
21
21
 
22
22
  - Source plan: `{{PLAN_FILE}}`
23
23
  - Deferred-goal ledger: `tasks/todo.md`
24
- - Review file: `tasks/reviews/{{TASK_SLUG}}.review.md`
25
- - Notes file: `tasks/notes/{{TASK_SLUG}}.notes.md`
24
+ - Review file: `{{REVIEW_FILE}}`
25
+ - Notes file: `{{NOTES_FILE}}`
26
26
  - Checks file: `.ai/harness/checks/latest.json`
27
27
  - Run snapshots: `.ai/harness/runs/`
28
28
  - Scope gate: edit only paths listed under `allowed_paths`; update this contract before widening scope.
@@ -35,9 +35,9 @@ allowed_paths:
35
35
  - docs/spec.md
36
36
  - plans/
37
37
  - tasks/todo.md
38
- - tasks/contracts/{{TASK_SLUG}}.contract.md
39
- - tasks/reviews/{{TASK_SLUG}}.review.md
40
- - tasks/notes/{{TASK_SLUG}}.notes.md
38
+ - {{CONTRACT_FILE}}
39
+ - {{REVIEW_FILE}}
40
+ - {{NOTES_FILE}}
41
41
  - .ai/context/capabilities.json
42
42
  - src/
43
43
  - tests/
@@ -51,7 +51,7 @@ exit_criteria:
51
51
  - docs/spec.md
52
52
  artifacts_exist:
53
53
  - .ai/harness/checks/latest.json
54
- - tasks/notes/{{TASK_SLUG}}.notes.md
54
+ - {{NOTES_FILE}}
55
55
  tests_pass:
56
56
  - path: tests/unit/{{TASK_SLUG}}.test.ts
57
57
  commands_succeed:
@@ -106,6 +106,7 @@ timestamp="$(date +%Y%m%d-%H%M)"
106
106
  timestamp_human="$(date '+%Y-%m-%d %H:%M')"
107
107
  plan_base="$(basename "$plan_file")"
108
108
  slug="$(echo "$plan_base" | sed -E 's/^plan-[0-9]{8}-[0-9]{4}-//; s/\.md$//')"
109
+ artifact_stem="$(printf '%s' "$plan_base" | sed -E 's/^plan-//; s/\.md$//')"
109
110
  parent_run_id="${HOOK_RUN_ID:-${CLAUDE_RUN_ID:-${CODEX_RUN_ID:-run-${timestamp}}}}"
110
111
  todo_source_plan="$(awk -F': ' '/^\> \*\*Source Plan\*\*:/ {print $2; exit}' tasks/todo.md 2>/dev/null | xargs)"
111
112
 
@@ -135,7 +136,10 @@ if [[ -f tasks/todo.md ]] && grep -q '[^[:space:]]' tasks/todo.md; then
135
136
  } > "$archive_todo"
136
137
  fi
137
138
 
138
- notes_file="tasks/notes/${slug}.notes.md"
139
+ notes_file="tasks/notes/${artifact_stem}.notes.md"
140
+ if [[ ! -f "$notes_file" && -f "tasks/notes/${slug}.notes.md" ]]; then
141
+ notes_file="tasks/notes/${slug}.notes.md"
142
+ fi
139
143
  if [[ -f "$notes_file" ]]; then
140
144
  archive_notes="$(unique_archive_path "tasks/archive/notes-${timestamp}-${slug}.md")"
141
145
  {
@@ -180,6 +180,7 @@ while [[ -f "$plan_file" ]]; do
180
180
  plan_file="plans/plan-${timestamp}-${slug}-v${counter}.md"
181
181
  counter=$((counter + 1))
182
182
  done
183
+ artifact_stem="$(basename "$plan_file" .md | sed -E 's/^plan-//')"
183
184
 
184
185
  tasks="$(extract_task_breakdown "$body" || true)"
185
186
  if [[ -z "$tasks" ]]; then
@@ -197,9 +198,9 @@ cat > "$plan_file" <<PLAN_EOF
197
198
  > **Source Ref**: ${source_ref:-"(none)"}
198
199
  > **Spec**: \`docs/spec.md\`
199
200
  > **Research**: See \`tasks/research.md\`
200
- > **Sprint Contract**: \`tasks/contracts/${slug}.contract.md\`
201
- > **Sprint Review**: \`tasks/reviews/${slug}.review.md\`
202
- > **Implementation Notes**: \`tasks/notes/${slug}.notes.md\`
201
+ > **Sprint Contract**: \`tasks/contracts/${artifact_stem}.contract.md\`
202
+ > **Sprint Review**: \`tasks/reviews/${artifact_stem}.review.md\`
203
+ > **Implementation Notes**: \`tasks/notes/${artifact_stem}.notes.md\`
203
204
 
204
205
  ## Agentic Routing
205
206
  - Selected route: ${route}
@@ -214,13 +215,13 @@ cat > "$plan_file" <<PLAN_EOF
214
215
  Complete this inventory before implementation. If any line is unknown, keep the plan in Draft and fill it before projection.
215
216
 
216
217
  - Active plan: \`${plan_file}\`
217
- - Sprint contract: \`tasks/contracts/${slug}.contract.md\`
218
- - Sprint review: \`tasks/reviews/${slug}.review.md\`
219
- - Implementation notes: \`tasks/notes/${slug}.notes.md\`
218
+ - Sprint contract: \`tasks/contracts/${artifact_stem}.contract.md\`
219
+ - Sprint review: \`tasks/reviews/${artifact_stem}.review.md\`
220
+ - Implementation notes: \`tasks/notes/${artifact_stem}.notes.md\`
220
221
  - Deferred-goal ledger: \`tasks/todo.md\`
221
222
  - Current checks: \`.ai/harness/checks/latest.json\`
222
223
  - Run snapshots: \`.ai/harness/runs/\`
223
- - Scope authority: \`tasks/contracts/${slug}.contract.md\` \`allowed_paths\`
224
+ - Scope authority: \`tasks/contracts/${artifact_stem}.contract.md\` \`allowed_paths\`
224
225
  - Concurrency rule: \`.ai/harness/active-plan\` selects the active plan for this worktree when present; \`.ai/harness/active-worktree\` records the owning worktree; \`.claude/.active-plan\` is a legacy fallback during transition. If another worktree already owns active work, open or switch to the matching worktree instead of serializing unrelated plans.
225
226
  - Execution isolation: approved contract-level work projects through \`scripts/plan-to-todo.sh --plan ${plan_file}\` and may start \`scripts/contract-worktree.sh start --plan ${plan_file}\`.
226
227
 
@@ -251,11 +252,11 @@ See captured planning output.
251
252
  | Captured plan lacks enough detail | Medium | Execution may need clarification | Stop before implementation if the captured output contradicts repo rules or lacks concrete file targets |
252
253
 
253
254
  ## Task Contracts
254
- - Contract file: \`tasks/contracts/${slug}.contract.md\`
255
- - Review file: \`tasks/reviews/${slug}.review.md\`
256
- - Implementation notes file: \`tasks/notes/${slug}.notes.md\`
255
+ - Contract file: \`tasks/contracts/${artifact_stem}.contract.md\`
256
+ - Review file: \`tasks/reviews/${artifact_stem}.review.md\`
257
+ - Implementation notes file: \`tasks/notes/${artifact_stem}.notes.md\`
257
258
  - Template: \`.claude/templates/contract.template.md\`
258
- - Verification command: \`bash scripts/verify-contract.sh --contract tasks/contracts/${slug}.contract.md --strict\`
259
+ - Verification command: \`bash scripts/verify-contract.sh --contract tasks/contracts/${artifact_stem}.contract.md --strict\`
259
260
  - Active plan rule: this captured plan is written to \`.ai/harness/active-plan\`, the owning worktree is written to \`.ai/harness/active-worktree\`, and the plan is mirrored to \`.claude/.active-plan\` unless --no-active is used. Do not infer active execution from the latest non-archived plan.
260
261
 
261
262
  ## Handoff
@@ -265,9 +266,9 @@ See captured planning output.
265
266
 
266
267
  ## Evidence Contract
267
268
 
268
- - **State/progress path**: \`${plan_file}\` task breakdown, \`tasks/todo.md\` deferred-goal ledger, \`tasks/contracts/${slug}.contract.md\`, \`tasks/reviews/${slug}.review.md\`, and \`tasks/notes/${slug}.notes.md\`
269
+ - **State/progress path**: \`${plan_file}\` task breakdown, \`tasks/todo.md\` deferred-goal ledger, \`tasks/contracts/${artifact_stem}.contract.md\`, \`tasks/reviews/${artifact_stem}.review.md\`, and \`tasks/notes/${artifact_stem}.notes.md\`
269
270
  - **Verification evidence**: \`.ai/harness/checks/latest.json\`, \`.ai/harness/runs/\`, and the commands named in the captured planning output
270
- - **Evaluator rubric**: \`tasks/reviews/${slug}.review.md\` must record a passing Waza /check style recommendation
271
+ - **Evaluator rubric**: \`tasks/reviews/${artifact_stem}.review.md\` must record a passing Waza /check style recommendation
271
272
  - **Stop condition**: all task breakdown items are complete, sprint verification passes, and the review recommends pass
272
273
  - **Rollback surface**: before execution remove \`${plan_file}\`; after execution revert branch \`codex/${slug}\` or the generated task artifacts
273
274
 
@@ -100,23 +100,55 @@ latest_plan() {
100
100
  find plans -maxdepth 1 -type f -name 'plan-*.md' 2>/dev/null | sort | tail -1
101
101
  }
102
102
 
103
+ plan_slug_from_path() {
104
+ local plan_file="$1"
105
+ local base slug
106
+ base="$(basename "$plan_file")"
107
+ slug="$(printf '%s' "$base" | sed -E 's/^plan-[0-9]{8}-[0-9]{4}-//; s/\.md$//')"
108
+ printf '%s' "$slug"
109
+ }
110
+
111
+ plan_artifact_stem_from_path() {
112
+ local plan_file="$1"
113
+ local base stem
114
+ base="$(basename "$plan_file")"
115
+ stem="$(printf '%s' "$base" | sed -E 's/^plan-//; s/\.md$//')"
116
+ if [[ "$stem" =~ ^[0-9]{8}-[0-9]{4}-.+ ]]; then
117
+ printf '%s' "$stem"
118
+ else
119
+ plan_slug_from_path "$plan_file"
120
+ fi
121
+ }
122
+
123
+ preferred_or_legacy_path() {
124
+ local preferred="$1"
125
+ local legacy="$2"
126
+ if [[ -f "$preferred" ]] || [[ ! -f "$legacy" ]]; then
127
+ printf '%s' "$preferred"
128
+ else
129
+ printf '%s' "$legacy"
130
+ fi
131
+ }
132
+
103
133
  derive_contract() {
104
134
  local plan_file="$1"
105
- local slug
135
+ local slug stem
106
136
  [[ -n "$plan_file" ]] || return 1
107
- slug="$(basename "$plan_file" | sed -E 's/^plan-[0-9]{8}-[0-9]{4}-//; s/\.md$//')"
108
- [[ -n "$slug" ]] || return 1
109
- printf 'tasks/contracts/%s.contract.md' "$slug"
137
+ slug="$(plan_slug_from_path "$plan_file")"
138
+ stem="$(plan_artifact_stem_from_path "$plan_file")"
139
+ [[ -n "$slug" && -n "$stem" ]] || return 1
140
+ preferred_or_legacy_path "tasks/contracts/${stem}.contract.md" "tasks/contracts/${slug}.contract.md"
110
141
  }
111
142
 
112
143
  derive_notes() {
113
144
  local plan_file="$1"
114
- local slug notes_dir
145
+ local slug stem notes_dir
115
146
  [[ -n "$plan_file" ]] || return 1
116
- slug="$(basename "$plan_file" | sed -E 's/^plan-[0-9]{8}-[0-9]{4}-//; s/\.md$//')"
117
- [[ -n "$slug" ]] || return 1
147
+ slug="$(plan_slug_from_path "$plan_file")"
148
+ stem="$(plan_artifact_stem_from_path "$plan_file")"
149
+ [[ -n "$slug" && -n "$stem" ]] || return 1
118
150
  notes_dir="$(safe_repo_file "$(policy_get '.tasks.notes_dir' 'tasks/notes')" 'tasks/notes' 'tasks/')"
119
- printf '%s/%s.notes.md' "$notes_dir" "$slug"
151
+ preferred_or_legacy_path "${notes_dir}/${stem}.notes.md" "${notes_dir}/${slug}.notes.md"
120
152
  }
121
153
 
122
154
  latest_global_handoff() {
@@ -61,6 +61,18 @@ derive_slug_from_plan() {
61
61
  normalize_slug "${slug:-contract-task}"
62
62
  }
63
63
 
64
+ derive_artifact_stem_from_plan() {
65
+ local plan_file="$1"
66
+ local plan_base stem
67
+ plan_base="$(basename "$plan_file")"
68
+ stem="$(printf '%s' "$plan_base" | sed -E 's/^plan-//; s/\.md$//')"
69
+ if [[ "$stem" =~ ^[0-9]{8}-[0-9]{4}-.+ ]]; then
70
+ printf '%s' "$stem"
71
+ else
72
+ derive_slug_from_plan "$plan_file"
73
+ fi
74
+ }
75
+
64
76
  is_linked_worktree() {
65
77
  local git_dir
66
78
  git_dir="$(git rev-parse --git-dir 2>/dev/null || true)"
@@ -381,7 +393,7 @@ finish_worktree() {
381
393
  exit 1
382
394
  fi
383
395
 
384
- local current_branch slug active_plan contract_file review_file target_worktree
396
+ local current_branch slug active_plan contract_file review_file target_worktree artifact_stem
385
397
  local external_status external_state external_reviewer external_source external_message
386
398
  current_branch="$(git branch --show-current)"
387
399
  [[ -n "$current_branch" ]] || { echo "contract-worktree: detached HEAD is not supported" >&2; exit 1; }
@@ -402,6 +414,18 @@ finish_worktree() {
402
414
  if [[ -z "${active_plan:-}" ]]; then
403
415
  active_plan="$(latest_plan_for_slug "$slug" || true)"
404
416
  fi
417
+ if [[ -n "${active_plan:-}" && -z "${contract_file:-}" ]]; then
418
+ artifact_stem="$(derive_artifact_stem_from_plan "$active_plan")"
419
+ if [[ -f "tasks/contracts/${artifact_stem}.contract.md" ]] || [[ ! -f "tasks/contracts/${slug}.contract.md" ]]; then
420
+ contract_file="tasks/contracts/${artifact_stem}.contract.md"
421
+ fi
422
+ fi
423
+ if [[ -n "${active_plan:-}" && -z "${review_file:-}" ]]; then
424
+ artifact_stem="${artifact_stem:-$(derive_artifact_stem_from_plan "$active_plan")}"
425
+ if [[ -f "tasks/reviews/${artifact_stem}.review.md" ]] || [[ ! -f "tasks/reviews/${slug}.review.md" ]]; then
426
+ review_file="tasks/reviews/${artifact_stem}.review.md"
427
+ fi
428
+ fi
405
429
  contract_file="${contract_file:-tasks/contracts/${slug}.contract.md}"
406
430
  review_file="${review_file:-tasks/reviews/${slug}.review.md}"
407
431