repo-harness 0.1.4 → 0.1.5

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 (67) hide show
  1. package/README.md +6 -5
  2. package/README.zh-CN.md +1 -1
  3. package/SKILL.md +2 -1
  4. package/assets/hooks/codex.hooks.template.json +1 -1
  5. package/assets/hooks/lib/workflow-state.sh +51 -1
  6. package/assets/hooks/run-hook.sh +22 -0
  7. package/assets/hooks/session-start-context.sh +16 -1
  8. package/assets/hooks/settings.template.json +1 -1
  9. package/assets/hooks/stop-orchestrator.sh +140 -0
  10. package/assets/initializer-question-pack.v4.json +26 -8
  11. package/assets/plan-map.json +1 -1
  12. package/assets/project-structures/ai-native-collaborative-editor.txt +25 -0
  13. package/assets/reference-configs/agentic-development-flow.md +3 -2
  14. package/assets/reference-configs/external-tooling.md +1 -1
  15. package/assets/reference-configs/harness-overview.md +2 -2
  16. package/assets/reference-configs/hook-operations.md +14 -0
  17. package/assets/skill-commands/manifest.json +11 -4
  18. package/assets/skill-commands/repo-harness-autoplan/SKILL.md +14 -7
  19. package/assets/skill-commands/repo-harness-ship/SKILL.md +26 -0
  20. package/assets/templates/helpers/architecture-event.ts +2 -1
  21. package/assets/templates/helpers/archive-workflow.sh +53 -1
  22. package/assets/templates/helpers/capability-resolver.ts +2 -1
  23. package/assets/templates/helpers/capture-plan.sh +29 -1
  24. package/assets/templates/helpers/check-task-workflow.sh +32 -2
  25. package/assets/templates/helpers/codex-handoff-resume.sh +52 -2
  26. package/assets/templates/helpers/context-contract-sync.sh +2 -1
  27. package/assets/templates/helpers/contract-worktree.sh +49 -2
  28. package/assets/templates/helpers/ensure-task-workflow.sh +4 -2
  29. package/assets/templates/helpers/migrate-project-template.sh +1 -1
  30. package/assets/templates/helpers/plan-to-todo.sh +69 -3
  31. package/assets/templates/helpers/prepare-codex-handoff.sh +84 -1
  32. package/assets/templates/helpers/select-agent-context-blocks.sh +4 -3
  33. package/assets/templates/helpers/ship-worktrees.sh +559 -0
  34. package/assets/workflow-contract.v1.json +2 -0
  35. package/docs/reference-configs/agentic-development-flow.md +3 -3
  36. package/docs/reference-configs/external-tooling.md +1 -1
  37. package/docs/reference-configs/handoff-protocol.md +8 -7
  38. package/docs/reference-configs/harness-overview.md +2 -2
  39. package/docs/reference-configs/hook-operations.md +5 -0
  40. package/package.json +1 -1
  41. package/scripts/architecture-event.ts +2 -1
  42. package/scripts/archive-workflow.sh +53 -1
  43. package/scripts/capability-resolver.ts +2 -1
  44. package/scripts/capture-plan.sh +29 -1
  45. package/scripts/check-brain-manifest.sh +127 -70
  46. package/scripts/check-skill-version.ts +2 -3
  47. package/scripts/check-task-workflow.sh +32 -2
  48. package/scripts/codex-handoff-resume.sh +52 -2
  49. package/scripts/context-contract-sync.sh +2 -1
  50. package/scripts/contract-worktree.sh +49 -2
  51. package/scripts/create-project-dirs.sh +2 -2
  52. package/scripts/ensure-task-workflow.sh +4 -2
  53. package/scripts/init-project.sh +6 -6
  54. package/scripts/lib/project-init-lib.sh +72 -27
  55. package/scripts/migrate-project-template.sh +3 -3
  56. package/scripts/plan-to-todo.sh +69 -3
  57. package/scripts/prepare-codex-handoff.sh +84 -1
  58. package/scripts/repo-harness.sh +2 -2
  59. package/scripts/select-agent-context-blocks.sh +4 -3
  60. package/scripts/setup-plugins.sh +1 -1
  61. package/scripts/ship-worktrees.sh +559 -0
  62. package/scripts/sync-brain-docs.sh +83 -165
  63. package/src/cli/commands/status.ts +1 -1
  64. package/src/cli/hook/route-registry.ts +1 -1
  65. package/src/cli/hook/runtime.ts +37 -2
  66. package/src/cli/index.ts +1 -1
  67. package/src/cli/installer/targets/codex.ts +39 -3
package/README.md CHANGED
@@ -121,11 +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.4` package publishes the
124
+ tracked separately as the `5.x` model line. The `0.1.5` package publishes the
125
125
  renamed `repo-harness` CLI, user-level Claude/Codex hook adapter bootstrap,
126
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
127
+ task artifact naming, `REPO_HARNESS_*` runtime aliases, repo-harness generated
128
+ markers, Waza runtime skill sync, `diagram-design` sync, and the release gate
129
+ used by maintainers before npm publish. When working from a source
129
130
  checkout instead of npm, run:
130
131
 
131
132
  ```bash
@@ -250,7 +251,7 @@ Most common guards:
250
251
 
251
252
  ## Current Release
252
253
 
253
- - npm package: `repo-harness@0.1.4`
254
+ - npm package: `repo-harness@0.1.5`
254
255
  - Generated workflow compatibility: `5.2.3`
255
256
  - GitHub repository: `Ancienttwo/repo-harness`
256
257
  - Release history: [`docs/CHANGELOG.md`](docs/CHANGELOG.md)
@@ -322,7 +323,7 @@ the public surface action-style while sharing the same router, contract, scripts
322
323
  and tests:
323
324
 
324
325
  - Planning and review: `repo-harness-plan`, `repo-harness-review`, `repo-harness-autoplan`
325
- - Repo workflow actions: `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`
326
+ - 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`
326
327
  - Project creation: `repo-harness-scaffold`
327
328
 
328
329
  `repo-harness-init` is for an existing repo; `repo-harness-scaffold` creates a new
package/README.zh-CN.md CHANGED
@@ -264,7 +264,7 @@ hook block 工作时,先看 terminal 里的结构化输出。核心字段是
264
264
  公共 command skill facades 在 `assets/skill-commands/`:
265
265
 
266
266
  - Planning / review:`repo-harness-plan`、`repo-harness-review`、`repo-harness-autoplan`
267
- - Repo workflow actions:`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`
267
+ - 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`
268
268
  - Project creation:`repo-harness-scaffold`
269
269
 
270
270
  `repo-harness-init` 用于已有仓库;`repo-harness-scaffold` 用于创建新项目或模块。
package/SKILL.md CHANGED
@@ -103,7 +103,8 @@ the same engine. Use action-style names for discoverability:
103
103
 
104
104
  - `repo-harness-plan`: interactive planning; no repo mutation by default
105
105
  - `repo-harness-review`: plan review across product, engineering, design, and DevEx
106
- - `repo-harness-autoplan`: automatic plan -> review -> decision summary pipeline
106
+ - `repo-harness-autoplan`: automatic plan -> self-review twice -> implementation -> check -> ship pipeline
107
+ - `repo-harness-ship`: validate finished worktrees, push branches, and create PRs by default
107
108
  - `repo-harness-init`: install or refresh the harness in an existing repo
108
109
  - `repo-harness-scaffold`: create a new project or module scaffold, then attach the harness
109
110
  - `repo-harness-migrate`: migrate legacy workflow docs and stale harness artifacts
@@ -50,7 +50,7 @@
50
50
  "Stop": [
51
51
  {
52
52
  "hooks": [
53
- { "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\" finalize-handoff.sh" }
53
+ { "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\" stop-orchestrator.sh" }
54
54
  ]
55
55
  }
56
56
  ]
@@ -289,7 +289,7 @@ workflow_plan_slug_from_path() {
289
289
  printf '%s' "$slug"
290
290
  }
291
291
 
292
- workflow_plan_artifact_stem_from_path() {
292
+ workflow_plan_original_artifact_stem_from_path() {
293
293
  local plan_file="$1"
294
294
  local base stem
295
295
 
@@ -303,6 +303,56 @@ workflow_plan_artifact_stem_from_path() {
303
303
  workflow_plan_slug_from_path "$plan_file"
304
304
  }
305
305
 
306
+ workflow_is_transient_plan_slug() {
307
+ case "$1" in
308
+ think-plan-[0-9]*|codex-plan-[0-9]*|approved-plan-[0-9]*)
309
+ return 0
310
+ ;;
311
+ esac
312
+ return 1
313
+ }
314
+
315
+ workflow_plan_title_slug_from_file() {
316
+ local plan_file="$1"
317
+ local title slug
318
+
319
+ [[ -f "$plan_file" ]] || return 1
320
+ title="$(awk '
321
+ /^# Plan:[[:space:]]*/ {
322
+ sub(/^# Plan:[[:space:]]*/, "")
323
+ print
324
+ exit
325
+ }
326
+ ' "$plan_file" | xargs)"
327
+ [[ -n "$title" ]] || return 1
328
+
329
+ slug="$(printf '%s' "$title" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g; s/^-+//; s/-+$//; s/-{2,}/-/g')"
330
+ [[ -n "$slug" ]] || return 1
331
+ printf '%s' "$slug"
332
+ }
333
+
334
+ workflow_plan_artifact_stem_from_path() {
335
+ local plan_file="$1"
336
+ local stem stamp slug title_slug
337
+
338
+ stem="$(workflow_plan_original_artifact_stem_from_path "$plan_file" || true)"
339
+ if [[ "$stem" =~ ^[0-9]{8}-[0-9]{4}-.+ ]]; then
340
+ stamp="$(printf '%s' "$stem" | sed -E 's/^([0-9]{8}-[0-9]{4})-.+$/\1/')"
341
+ slug="$(printf '%s' "$stem" | sed -E 's/^[0-9]{8}-[0-9]{4}-//')"
342
+ if workflow_is_transient_plan_slug "$slug"; then
343
+ title_slug="$(workflow_plan_title_slug_from_file "$plan_file" || true)"
344
+ if [[ -n "$title_slug" && "$title_slug" != "$slug" ]]; then
345
+ printf '%s-%s' "$stamp" "$title_slug"
346
+ return 0
347
+ fi
348
+ fi
349
+ printf '%s' "$stem"
350
+ return 0
351
+ fi
352
+
353
+ workflow_plan_slug_from_path "$plan_file"
354
+ }
355
+
306
356
  workflow_preferred_or_legacy_path() {
307
357
  local preferred="$1"
308
358
  local legacy="$2"
@@ -23,6 +23,28 @@ fi
23
23
  export HOOK_REPO_ROOT="$REPO_ROOT"
24
24
  cd "$REPO_ROOT"
25
25
 
26
+ if [[ "${HOOK_HOST:-}" == "codex" && "$HOOK_NAME" == "stop-orchestrator.sh" ]]; then
27
+ tmp_stdout="$(mktemp)"
28
+ tmp_stderr="$(mktemp)"
29
+ if bash "$HOOK_PATH" "$@" >"$tmp_stdout" 2>"$tmp_stderr"; then
30
+ if grep -q '"decision"[[:space:]]*:' "$tmp_stdout"; then
31
+ cat "$tmp_stdout"
32
+ fi
33
+ rm -f "$tmp_stdout" "$tmp_stderr"
34
+ exit 0
35
+ else
36
+ hook_status=$?
37
+ if [[ -s "$tmp_stderr" ]]; then
38
+ cat "$tmp_stderr" >&2
39
+ fi
40
+ if [[ -s "$tmp_stdout" ]]; then
41
+ grep -v '^{"guard":' "$tmp_stdout" >&2 || true
42
+ fi
43
+ rm -f "$tmp_stdout" "$tmp_stderr"
44
+ exit "$hook_status"
45
+ fi
46
+ fi
47
+
26
48
  if [[ "${HOOK_HOST:-}" == "codex" && "$HOOK_NAME" != "session-start-context.sh" ]]; then
27
49
  tmp_stdout="$(mktemp)"
28
50
  tmp_stderr="$(mktemp)"
@@ -13,7 +13,10 @@ resume_file="$(workflow_resume_packet_file)"
13
13
 
14
14
  resume_available() {
15
15
  [[ -f "$resume_file" ]] || return 1
16
- grep -Fq "<!-- generated-by: project-initializer codex-handoff-resume v1 -->" "$resume_file" || return 1
16
+ {
17
+ grep -Fq "<!-- generated-by: repo-harness codex-handoff-resume v1 -->" "$resume_file" ||
18
+ grep -Fq "<!-- generated-by: project-initializer codex-handoff-resume v1 -->" "$resume_file"
19
+ } || return 1
17
20
  grep -Fq "## Resume Prompt" "$resume_file"
18
21
  }
19
22
 
@@ -254,6 +257,14 @@ EOF_CONTEXT
254
257
  fi
255
258
  }
256
259
 
260
+ input_priority_context() {
261
+ cat <<'EOF_CONTEXT'
262
+ # Input Priority
263
+
264
+ If the current user message mentions `# Files mentioned by the user`, `pasted-text.txt`, or an explicit attachment/file path, read those current-input files first. Treat handoff, resume, and `tasks/current.md` as recovery context only.
265
+ EOF_CONTEXT
266
+ }
267
+
257
268
  context=""
258
269
  if resume_current_for_handoff; then
259
270
  if context_budget_active \
@@ -293,6 +304,10 @@ if [[ -n "$current_status_context" ]]; then
293
304
  fi
294
305
  fi
295
306
 
307
+ if [[ -n "$context" ]]; then
308
+ context="$(input_priority_context)"$'\n'"${context}"
309
+ fi
310
+
296
311
  # Cross-review availability for Codex. The dispatcher swallows prompt-guard's
297
312
  # success stdout on Codex, so attach a short reminder only when SessionStart is
298
313
  # already injecting actionable context.
@@ -50,7 +50,7 @@
50
50
  "Stop": [
51
51
  {
52
52
  "hooks": [
53
- { "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\" finalize-handoff.sh" }
53
+ { "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\" stop-orchestrator.sh" }
54
54
  ]
55
55
  }
56
56
  ]
@@ -0,0 +1,140 @@
1
+ #!/bin/bash
2
+ # Stop Orchestrator Hook - Stop
3
+ # Refreshes handoff state and, for pending planning discussions, forces one
4
+ # self-review pass before the agent stops.
5
+
6
+ set -euo pipefail
7
+
8
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
9
+ # shellcheck source=/dev/null
10
+ . "$SCRIPT_DIR/hook-input.sh"
11
+ # shellcheck source=/dev/null
12
+ . "$SCRIPT_DIR/lib/workflow-state.sh"
13
+
14
+ plan_completeness_state_file() {
15
+ workflow_repo_relative_path \
16
+ "$(workflow_policy_get '.planning.completeness_state_file' '.ai/harness/planning/plan-completeness.json')" \
17
+ '.ai/harness/planning/plan-completeness.json' \
18
+ '.ai/harness/'
19
+ }
20
+
21
+ plan_completeness_signature() {
22
+ local kind prompt_slug draft_path source_ref created_at
23
+
24
+ kind="$(workflow_pending_orchestration_field kind 2>/dev/null || true)"
25
+ prompt_slug="$(workflow_pending_orchestration_field prompt_slug 2>/dev/null || true)"
26
+ draft_path="$(workflow_pending_orchestration_field draft_plan_path 2>/dev/null || true)"
27
+ source_ref="$(workflow_pending_orchestration_field source_ref 2>/dev/null || true)"
28
+ created_at="$(workflow_pending_orchestration_field created_at 2>/dev/null || true)"
29
+
30
+ printf '%s|%s|%s|%s|%s' \
31
+ "${kind:-unknown}" \
32
+ "${prompt_slug:-planning}" \
33
+ "${draft_path:-none}" \
34
+ "${source_ref:-none}" \
35
+ "${created_at:-unknown}"
36
+ }
37
+
38
+ plan_completeness_last_signature() {
39
+ local state_file value
40
+ state_file="$(plan_completeness_state_file)"
41
+ [[ -f "$state_file" ]] || return 1
42
+
43
+ if command -v jq >/dev/null 2>&1; then
44
+ value="$(jq -r '.last_signature // empty' "$state_file" 2>/dev/null || true)"
45
+ else
46
+ value="$(
47
+ awk '
48
+ /"last_signature"/ {
49
+ line = $0
50
+ sub(/^[^:]*:[[:space:]]*"/, "", line)
51
+ sub(/"[[:space:]]*,?[[:space:]]*$/, "", line)
52
+ print line
53
+ exit
54
+ }
55
+ ' "$state_file"
56
+ )"
57
+ fi
58
+
59
+ [[ -n "$value" ]] || return 1
60
+ printf '%s' "$value"
61
+ }
62
+
63
+ plan_completeness_record_signature() {
64
+ local signature="$1"
65
+ local state_file
66
+ state_file="$(plan_completeness_state_file)"
67
+ mkdir -p "$(dirname "$state_file")"
68
+
69
+ if command -v jq >/dev/null 2>&1; then
70
+ jq -nc \
71
+ --arg signature "$signature" \
72
+ --arg updated_at "$(date '+%Y-%m-%dT%H:%M:%S%z')" \
73
+ '{version:1,last_signature:$signature,updated_at:$updated_at}' > "$state_file"
74
+ return 0
75
+ fi
76
+
77
+ cat > "$state_file" <<EOF_STATE
78
+ {"version":1,"last_signature":"$(workflow_json_escape "$signature")","updated_at":"$(workflow_json_escape "$(date '+%Y-%m-%dT%H:%M:%S%z')")"}
79
+ EOF_STATE
80
+ }
81
+
82
+ assistant_message_looks_like_plan() {
83
+ local message="$1"
84
+ local length
85
+
86
+ length="$(printf '%s' "$message" | wc -c | tr -d ' ')"
87
+ [[ "${length:-0}" -ge 240 ]] || return 1
88
+
89
+ printf '%s\n' "$message" | grep -qEi \
90
+ '(Approved design summary|Building|Not building|Approach|Key decisions|Unknowns|Task Breakdown|Evidence Contract|P1|P2|P3|plan|design|方案|计划|设计)'
91
+ }
92
+
93
+ emit_stop_block_json() {
94
+ local reason="$1"
95
+
96
+ if command -v jq >/dev/null 2>&1; then
97
+ jq -nc --arg reason "$reason" '{decision:"block",reason:$reason}'
98
+ return 0
99
+ fi
100
+
101
+ printf '{"decision":"block","reason":"%s"}\n' "$(workflow_json_escape "$reason")"
102
+ }
103
+
104
+ refresh_handoff() {
105
+ workflow_write_handoff "session-stop"
106
+ echo "[FinalizeHandoff] Refreshed $(workflow_handoff_file)." >&2
107
+ }
108
+
109
+ should_run_plan_completeness_gate() {
110
+ local stop_active="$1"
111
+ local last_message="$2"
112
+ local active_plan
113
+
114
+ [[ "$stop_active" != "true" ]] || return 1
115
+ workflow_pending_orchestration_is_fresh || return 1
116
+
117
+ # If a repo plan is already active, the normal plan status gates own the next
118
+ # transition. This gate only covers host planning output that still needs
119
+ # capture.
120
+ active_plan="$(get_active_plan || true)"
121
+ [[ -z "$active_plan" || ! -f "$active_plan" ]] || return 1
122
+
123
+ assistant_message_looks_like_plan "$last_message"
124
+ }
125
+
126
+ refresh_handoff
127
+
128
+ stop_hook_active="$(hook_json_get '.stop_hook_active' 'false')"
129
+ last_assistant_message="$(hook_json_get '.last_assistant_message' '')"
130
+
131
+ if should_run_plan_completeness_gate "$stop_hook_active" "$last_assistant_message"; then
132
+ signature="$(plan_completeness_signature)"
133
+ if [[ "$(plan_completeness_last_signature 2>/dev/null || true)" != "$signature" ]]; then
134
+ plan_completeness_record_signature "$signature"
135
+ summary="$(workflow_pending_orchestration_summary)"
136
+ emit_stop_block_json "[PlanCompletenessGate] A first planning answer was produced while pending orchestration is still open: ${summary}
137
+
138
+ Before stopping, run one self-review pass on the plan. Do not implement. Check for missing goal/success criteria, constraints, P1 component map, P2 traced path, P3 decision rationale, fragile assumption, rejected alternative, tests, rollback/failure handling, and no placeholders. If the plan is already complete, say so explicitly and keep the revision concise. Then stop and wait for user approval."
139
+ fi
140
+ fi
@@ -50,7 +50,7 @@
50
50
  "title": "AI-Native Profile",
51
51
  "batch": 2,
52
52
  "questions": [
53
- "Choose AI-native overlay: none (default), chat-agent, runtime-console, product-copilot, workflow-agent, generative-ui-agent, browser-agent, research-agent, coding-agent, enterprise-agent-platform, voice-agent, or sidecar-kernel",
53
+ "Choose AI-native overlay: none (default), chat-agent, collaborative-editor, runtime-console, product-copilot, workflow-agent, generative-ui-agent, browser-agent, research-agent, coding-agent, enterprise-agent-platform, voice-agent, or sidecar-kernel",
54
54
  "Confirm whether generated structure should add AG-UI, assistant-ui or CopilotKit, Bun/Hono gateway, MCP/tool, sidecar, and observability boundaries"
55
55
  ],
56
56
  "required": false
@@ -278,17 +278,35 @@
278
278
  "description": "Ordinary AI chat, RAG, or help assistant inside the selected app plan.",
279
279
  "frontend": "Vite 8 + assistant-ui or the selected plan UI",
280
280
  "runtimeProtocol": "AI SDK UI stream or AG-UI lite",
281
- "backend": "Bun/Hono gateway or existing API boundary",
281
+ "backend": "Bun/Hono gateway or Mastra/Hono runtime behind the existing API boundary",
282
282
  "stateDefault": "TanStack Query + Zustand",
283
283
  "sidecarPolicy": "Python only when the model framework needs it",
284
284
  "uiSchema": "Hardcoded React components",
285
285
  "techStackRows": [
286
286
  "| AI UI | assistant-ui chat surface |",
287
287
  "| Agent stream | AI SDK UI stream or AG-UI lite |",
288
- "| Agent gateway | Bun/Hono or existing API |",
288
+ "| Agent runtime | Bun/Hono by default; Mastra when TS agents need memory, tools, workflows, or evals |",
289
289
  "| Agent state | TanStack Query + Zustand |"
290
290
  ]
291
291
  },
292
+ "collaborative-editor": {
293
+ "label": "Collaborative editor",
294
+ "description": "AI-aware document, CMS, or knowledge workspace with local-first collaboration and explicit sync ownership.",
295
+ "frontend": "Vite 8 + React 19 + Plate + shadcn/ui",
296
+ "runtimeProtocol": "Loro CRDT document events; AI SDK or AG-UI only for user-visible agent runs",
297
+ "backend": "Bun/Hono sync and agent gateway, or existing API boundary",
298
+ "stateDefault": "Loro document state + TanStack Query server cache + Zustand UI state",
299
+ "sidecarPolicy": "None by default; Python or Go sidecars only for extraction, indexing, or heavy sync workers",
300
+ "uiSchema": "Plate node/plugin schema plus app-owned document contracts",
301
+ "projectStructureFile": "assets/project-structures/ai-native-collaborative-editor.txt",
302
+ "techStackRows": [
303
+ "| Editor UI | Plate + shadcn/ui in a Vite 8 React surface |",
304
+ "| Collaboration | Loro CRDT document state and sync contracts |",
305
+ "| Agent runtime | AI SDK or AG-UI only for user-visible assistant/document actions |",
306
+ "| Sync gateway | Bun/Hono or existing API boundary owns persistence and auth |",
307
+ "| State split | Loro for document replicas; TanStack Query for server cache; Zustand for UI chrome |"
308
+ ]
309
+ },
292
310
  "runtime-console": {
293
311
  "label": "Runtime console",
294
312
  "description": "Agent runtime console with trace, replay, prompt playground, approvals, artifacts, and tool-call visibility.",
@@ -332,12 +350,12 @@
332
350
  "runtimeProtocol": "AG-UI",
333
351
  "backend": "Bun/Hono gateway",
334
352
  "stateDefault": "Jotai + Zustand + TanStack Query",
335
- "sidecarPolicy": "LangGraph, Temporal, Inngest, or BullMQ only when execution needs them",
353
+ "sidecarPolicy": "Mastra, LangGraph, Temporal, Inngest, or BullMQ only when execution needs workflow durability or orchestration",
336
354
  "uiSchema": "A2UI optional experiment",
337
355
  "techStackRows": [
338
356
  "| Workflow UI | React Flow/xyflow + Monaco |",
339
357
  "| Agent protocol | AG-UI workflow/run events |",
340
- "| Executor | Bun/Hono gateway with optional workflow engine |",
358
+ "| Executor | Bun/Hono gateway with optional Mastra or durable workflow engine |",
341
359
  "| Agent state | Jotai + Zustand + TanStack Query |"
342
360
  ]
343
361
  },
@@ -444,14 +462,14 @@
444
462
  "runtimeProtocol": "AG-UI when user-visible agent runs exist; MCP/HTTP for sidecars",
445
463
  "backend": "Bun/Hono gateway owns app-facing API",
446
464
  "stateDefault": "TanStack Query + Zustand, plus domain stores as needed",
447
- "sidecarPolicy": "Python for model/eval/data pipelines, Go for workers, Rust for low-latency parsing/indexing/sandboxing",
465
+ "sidecarPolicy": "Python ADK/FastAPI for model/eval/data pipelines, Go/Gin for high-concurrency workers or infra adapters, Rust for low-latency parsing/indexing/sandboxing",
448
466
  "uiSchema": "None by default",
449
467
  "projectStructureFile": "assets/project-structures/ai-native-sidecar-kernel.txt",
450
468
  "techStackRows": [
451
469
  "| App gateway | Bun/Hono owns app-facing API |",
452
470
  "| Sidecar protocol | MCP tools or narrow HTTP jobs |",
453
- "| Python sidecar | Model frameworks, evals, data science |",
454
- "| Go sidecar | High-concurrency workers and infra adapters |",
471
+ "| Python sidecar | Google ADK/FastAPI, model frameworks, evals, data science |",
472
+ "| Go sidecar | Gin workers, Supabase REST adapters, high-concurrency infra jobs |",
455
473
  "| Rust sidecar | Parsing, indexing, sandboxing, native kernels |"
456
474
  ]
457
475
  }
@@ -66,7 +66,7 @@
66
66
  "cloudflareNative": true,
67
67
  "aiNativeOverlayDefaults": {
68
68
  "defaultProfile": "none",
69
- "recommendedProfiles": ["runtime-console", "product-copilot", "chat-agent"]
69
+ "recommendedProfiles": ["runtime-console", "product-copilot", "chat-agent", "collaborative-editor"]
70
70
  },
71
71
  "defaultHarnessProfiles": {
72
72
  "orchestration": "shared-long-running-harness",
@@ -0,0 +1,25 @@
1
+ # AI-native Collaborative Editor Overlay
2
+
3
+ {{PROJECT_NAME}}/
4
+ ├── apps/
5
+ │ └── web/
6
+ │ ├── src/routes/documents.$id.tsx # editor route and document run surface
7
+ │ ├── src/components/editor/ # Plate editor, toolbars, nodes, marks
8
+ │ ├── src/components/assistant/ # document assistant or inline actions
9
+ │ ├── src/collab/loro-doc.ts # Loro document factory and peer identity
10
+ │ ├── src/collab/sync-client.ts # sync transport adapter
11
+ │ └── src/stores/editor-ui-store.ts # bounded Zustand UI chrome only
12
+ ├── services/
13
+ │ └── document-gateway/
14
+ │ ├── src/routes/documents.ts # Bun/Hono document CRUD and auth boundary
15
+ │ ├── src/routes/sync.ts # CRDT sync endpoint
16
+ │ ├── src/routes/agent-actions.ts # AI SDK or AG-UI document actions
17
+ │ └── src/storage/ # snapshots, updates, and audit records
18
+ ├── packages/
19
+ │ └── contracts/
20
+ │ ├── src/documents.ts # document metadata and ACL schemas
21
+ │ ├── src/crdt.ts # Loro update/snapshot contracts
22
+ │ ├── src/editor-nodes.ts # Plate node/plugin contracts
23
+ │ └── src/agent-actions.ts # assistant action input/output schemas
24
+ └── workers/
25
+ └── indexing/ # optional extraction, search, or sync compaction
@@ -24,7 +24,8 @@ migrating, repairing, or verifying this repo-local harness:
24
24
  |-----------|---------|----------|
25
25
  | Decision-complete harness plan | `repo-harness-plan` | Plans only; no repo mutation by default |
26
26
  | Review an existing harness plan | `repo-harness-review` | Product, engineering, design, and DevEx review dimensions |
27
- | Automatic planning pipeline | `repo-harness-autoplan` | Plan -> review -> decision summary with final gates only |
27
+ | Automatic workflow pipeline | `repo-harness-autoplan` | Plan -> two self-review passes -> implementation -> `/check` -> `repo-harness-ship` |
28
+ | Ship finished work | `repo-harness-ship` | Validates finished worktrees, pushes branches, and creates PRs by default |
28
29
  | Add harness to an existing repo | `repo-harness-init` | Uses inspector and migration engine; does not create an app stack |
29
30
  | Create a new app or module scaffold | `repo-harness-scaffold` | Uses plan catalog A-K, then attaches the harness |
30
31
  | Convert legacy workflow surfaces | `repo-harness-migrate` | Archives or preserves user-authored legacy docs |
@@ -61,7 +62,7 @@ work, or shared contracts, report the P1/P2/P3 evidence explicitly.
61
62
  5. Approved plans must include `## Evidence Contract` with state/progress path, verification evidence, evaluator rubric, stop condition, and rollback surface before execution. `capture-plan.sh` supplies this contract for captured planning output.
62
63
  6. Convert approved plans to execution scaffolding with `scripts/plan-to-todo.sh --plan <plan>`; if approval is already explicit, use `scripts/capture-plan.sh --status Approved --execute ...`. The plan's own `## Task Breakdown` remains the execution checklist; `tasks/todo.md` remains a deferred-goal ledger. Contract-level plans are projected into a linked `codex/<slug>` worktree when the policy enables it.
63
64
  7. Use `scripts/refresh-current-status.sh` for an explicit `tasks/current.md` preview or `--write` snapshot. In non-target worktrees, `git show <target>:tasks/current.md` reads the mainline snapshot, but it never replaces source artifacts.
64
- 8. After substantive changes, run project checks and record evidence in `tasks/`. For contract worktrees, run Waza `/check`, start host-aware external acceptance in parallel, fill the review artifact from both verdicts, then run `scripts/contract-worktree.sh finish`.
65
+ 8. After substantive changes, run project checks and record evidence in `tasks/`. For contract worktrees, run Waza `/check`, start host-aware external acceptance in parallel, fill the review artifact from both verdicts, then use `repo-harness-ship` for default PR closeout. It calls `scripts/contract-worktree.sh finish --no-merge`, pushes the `codex/<slug>` branch, and opens a draft PR. Use `repo-harness-ship --local-merge` only when an explicit maintainer workflow wants the older fast-forward merge and cleanup path.
65
66
 
66
67
  ## Passive Plan Capture
67
68
 
@@ -45,7 +45,7 @@ installations.
45
45
 
46
46
  Use `bash scripts/check-agent-tooling.sh` for a read-only tooling report.
47
47
  Init and migration reports run the detector without update checks by default;
48
- set `AGENTIC_DEV_CHECK_TOOLING_UPDATES=1` when that advisory pass should
48
+ set `REPO_HARNESS_CHECK_TOOLING_UPDATES=1` when that advisory pass should
49
49
  also compare upstream versions.
50
50
 
51
51
  Supported flags:
@@ -35,7 +35,7 @@ This repo uses a shared long-running harness. The durable workflow lives in repo
35
35
  - Before implementation, the plan and contract should both expose a concrete workflow inventory so the agent does not rediscover or guess active artifacts.
36
36
  - Implementation should prefer `docs/spec.md`, an approved plan, and an active sprint contract.
37
37
  - Claiming completion should include contract verification evidence, a run snapshot, implementation notes, and a passing Waza `/check` review artifact.
38
- - Stopping a session should refresh `.ai/harness/handoff/current.md` for easier resume.
38
+ - Stopping a session should refresh `.ai/harness/handoff/current.md` for easier resume; while pending planning orchestration is open, Stop may block once to force a plan completeness self-review before execution.
39
39
  - Refresh `tasks/current.md` with `scripts/refresh-current-status.sh --write --reason <reason>` only at explicit lifecycle boundaries or as a deliberate maintainer action; ordinary hooks should not dirty tracked files.
40
40
  - In non-target worktrees, read the target branch snapshot with `git show <target>:tasks/current.md` and verify stale or surprising state against the source artifacts before acting.
41
41
  - Use `docs/reference-configs/agentic-development-flow.md` for skill routing and `docs/reference-configs/external-tooling.md` for install/update commands.
@@ -66,7 +66,7 @@ This repo uses a shared long-running harness. The durable workflow lives in repo
66
66
  - Declare capabilities in `.ai/context/capabilities.json`; each capability owns prefixes, paired contract files, an architecture module, a workstream directory, and local verification hints.
67
67
  - Add selected capabilities with `repo-harness-capability` or `bun scripts/capability-config.ts add --prefix <path>` when the harness already exists and a full init/migrate/upgrade pass would be too broad.
68
68
  - Resolve edited paths through `scripts/capability-resolver.ts match --path <path>`; longest prefix wins and equal-length ambiguity fails.
69
- - Treat `.ai/context/agent-context-blocks.txt`, `PROJECT_INITIALIZER_CONTEXT_BLOCKS`, and existing nested `CLAUDE.md`/`AGENTS.md` files as migration inputs or compatibility fallbacks only.
69
+ - Treat `.ai/context/agent-context-blocks.txt`, `REPO_HARNESS_CONTEXT_BLOCKS`, legacy `PROJECT_INITIALIZER_CONTEXT_BLOCKS`, and existing nested `CLAUDE.md`/`AGENTS.md` files as migration inputs or compatibility fallbacks only.
70
70
  - Selected capabilities receive paired `CLAUDE.md` and `AGENTS.md` files so Claude Code and Codex share the same local contract.
71
71
  - Use `repo-harness capability-context status|request|sync` to keep paired local context files aligned with the registry. The command writes only the controlled `CAPABILITY CONTEXT` block and preserves hand-authored content plus the separate architecture contract block.
72
72
  - `.ai/context/capability-source-map.json` is the optional human-edited source-map manifest for capability positioning and source pointers. Missing entries fall back to registry/architecture/workstream metadata; `--auto-fill-positioning` writes deterministic draft entries explicitly, not from hooks.
@@ -16,12 +16,26 @@ Start with the shortest truth path:
16
16
  3. The route registry selects the ordered `.ai/hooks/*` scripts for that event and route.
17
17
  4. `.ai/hooks/*` is the shared implementation layer and the default place to edit.
18
18
 
19
+ `UserPromptSubmit.default` keeps that same public route, but prompt-guard has a
20
+ split implementation:
21
+
22
+ 1. `repo-harness-hook UserPromptSubmit --route default` dispatches to `.ai/hooks/prompt-guard.sh`.
23
+ 2. `prompt-guard.sh` parses host prompt JSON, reads workflow files, performs capture side effects, runs quality gates, and renders host-safe stdout/stderr.
24
+ 3. For intent plus workflow-state routing, `prompt-guard.sh` calls `repo-harness-hook prompt-guard-decide`.
25
+ 4. The TypeScript decision engine classifies prompt facts, reads state facts from environment variables, and returns one action enum from the explicit decision table.
26
+ 5. `prompt-guard.sh` renders that action as allow, advice, block, capture guidance, execution guidance, or done-gate output.
27
+
19
28
  If you are asking "which hook file should I edit?", default to `.ai/hooks/`.
20
29
  After installing or refreshing `~/.codex/hooks.json`, open Codex Settings and
21
30
  mark the user-level hook config as trusted; otherwise Codex will not execute it.
22
31
  Repo-local `.claude/settings.json` and `.codex/hooks.json` hook adapters are
23
32
  legacy project-level config and should be retired during migration.
24
33
 
34
+ `Stop.default` routes through `stop-orchestrator.sh`. On Codex, dispatcher
35
+ stdout stays quiet for ordinary successful hooks, but valid Stop decision JSON
36
+ is forwarded so Codex can honor a one-shot planning completeness block; success
37
+ stderr such as handoff refresh noise remains suppressed.
38
+
25
39
  ## Hook Failure Playbook
26
40
 
27
41
  When a hook blocks work:
@@ -20,10 +20,17 @@
20
20
  },
21
21
  {
22
22
  "name": "repo-harness-autoplan",
23
- "class": "automated-planning",
24
- "mutatesRepoByDefault": false,
25
- "engine": "plan then review then decision summary",
26
- "summary": "Runs the full planning and review pipeline automatically, surfacing only final decision gates."
23
+ "class": "automated-workflow",
24
+ "mutatesRepoByDefault": true,
25
+ "engine": "plan, two self-review passes, execution, check, then repo-harness-ship",
26
+ "summary": "Runs the full repo-harness workflow automatically and delegates final PR closeout to repo-harness-ship."
27
+ },
28
+ {
29
+ "name": "repo-harness-ship",
30
+ "class": "ship-closeout",
31
+ "mutatesRepoByDefault": true,
32
+ "engine": "ship-worktrees default PR mode",
33
+ "summary": "Validates finished worktrees, commits through finish --no-merge, pushes branches, and creates GitHub PRs by default."
27
34
  },
28
35
  {
29
36
  "name": "repo-harness-init",
@@ -1,19 +1,23 @@
1
1
  ---
2
2
  name: repo-harness-autoplan
3
- description: Fully automated planning pipeline for repo-harness workflow work. Reads repo state and existing docs, drafts a plan, reviews it, and surfaces only final decision gates.
4
- when_to_use: "repo-harness-autoplan, auto plan repo-harness work, automatic review harness plan, run all repo-harness reviews, make the workflow planning decisions"
3
+ description: Full repo-harness workflow orchestrator. Reads repo state, drafts a plan, self-reviews twice, executes the approved plan, runs review/check gates, and delegates final PR closeout to repo-harness-ship.
4
+ when_to_use: "repo-harness-autoplan, auto plan repo-harness work, automatic review harness plan, run all repo-harness reviews, make the workflow planning decisions, full repo-harness workflow"
5
5
  ---
6
6
 
7
7
  # repo-harness-autoplan
8
8
 
9
- Use this command when the user wants the planning and review pipeline handled automatically.
9
+ Use this command when the user wants the whole repo-harness workflow handled automatically.
10
10
 
11
11
  ## Protocol
12
12
 
13
13
  1. Confirm the working repo and inspect state with `bun scripts/inspect-project-state.ts --repo <repo> --format text` when available.
14
14
  2. Draft the action plan with `repo-harness-plan` rules.
15
- 3. Review the draft with `repo-harness-review` rules.
16
- 4. Return the final plan, unresolved taste decisions, and the next action command.
15
+ 3. Run self-review 1, the completeness pass: goal, scope, P1/P2/P3, interfaces, tests, rollback, no placeholders.
16
+ 4. Revise the plan once from the completeness findings.
17
+ 5. Run self-review 2, the adversarial and shipability pass: failing gates, unsafe automation, permission boundaries, 10x breakpoints, and PR closeout readiness.
18
+ 6. Execute the approved plan without re-litigating decisions unless live repo drift makes it unsafe.
19
+ 7. Run Waza `/check` semantics and record the sprint review, external acceptance, and `verify-sprint` evidence.
20
+ 8. Call `repo-harness-ship` for the final default PR closeout.
17
21
 
18
22
  ## Reusable Workflow Packaging Rubric
19
23
 
@@ -34,8 +38,11 @@ or existing command extension:
34
38
 
35
39
  ## Boundaries
36
40
 
37
- - Does not edit files or run mutating scripts by default.
38
- - Never aborts into a long interactive review unless the repo state makes automatic planning unsafe.
41
+ - Mutates repo files by default only after the user explicitly invokes `repo-harness-autoplan`.
42
+ - Runs exactly two plan self-review passes; do not recurse into open-ended self critique.
43
+ - Stops for the user only when the remaining ambiguity would change product intent, safety boundaries, or ship mode.
44
+ - Never aborts into a long interactive review unless the repo state makes automatic workflow execution unsafe.
39
45
  - Surfaces only decisions that materially change scope, risk, or command selection.
40
46
  - Does not create skills, subagents, automations, or command assets until the
41
47
  user approves the plan.
48
+ - Delegates default branch push and PR creation to `repo-harness-ship`; `repo-harness-autoplan` does not merge PRs or publish releases.