@moretea-labs/forge 1.6.0 → 1.7.1

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 (469) hide show
  1. package/AGENTS.md +4 -0
  2. package/CHANGELOG.md +39 -0
  3. package/CLAUDE.md +4 -0
  4. package/README.md +2 -2
  5. package/README.zh-CN.md +1 -1
  6. package/SKILL.md +2 -2
  7. package/THIRD_PARTY_NOTICES.md +1 -1
  8. package/agents/openai.yaml +1 -1
  9. package/assets/hooks/hook-input.sh +11 -8
  10. package/assets/hooks/lib/session-state.sh +10 -7
  11. package/assets/hooks/lib/workflow-state.sh +13 -177
  12. package/assets/hooks/post-tool-observer.sh +8 -2
  13. package/assets/hooks/prompt-guard.sh +5 -81
  14. package/assets/hooks/session-start-context.sh +56 -1
  15. package/assets/partials/05-workflow.partial.md +1 -1
  16. package/assets/partials-agents/02-operating-mode.partial.md +2 -0
  17. package/assets/partials-agents/03-orchestration.partial.md +1 -1
  18. package/assets/plugin-registry.v1.json +3 -3
  19. package/assets/reference-configs/document-generation.md +1 -1
  20. package/assets/reference-configs/harness-overview.md +1 -1
  21. package/assets/reference-configs/sprint-contracts.md +3 -3
  22. package/assets/skill-version.json +2 -2
  23. package/assets/templates/contract.template.md +2 -7
  24. package/assets/templates/helpers/capture-plan.sh +2 -2
  25. package/assets/templates/helpers/check-architecture-sync.sh +17 -0
  26. package/assets/templates/helpers/check-task-workflow.sh +4 -4
  27. package/assets/templates/helpers/contract-worktree.sh +1 -21
  28. package/assets/templates/helpers/ensure-task-workflow.sh +11 -36
  29. package/assets/templates/helpers/inspect-project-state.ts +8 -6
  30. package/assets/templates/helpers/migrate-project-template.sh +22 -45
  31. package/assets/templates/helpers/migrate-workflow-docs.ts +9 -7
  32. package/assets/templates/helpers/new-plan.sh +1 -1
  33. package/assets/templates/helpers/plan-to-todo.sh +12 -37
  34. package/assets/templates/helpers/ship-worktrees.sh +2 -29
  35. package/assets/templates/helpers/verify-contract.sh +1 -111
  36. package/assets/templates/helpers/verify-sprint.sh +3 -180
  37. package/assets/templates/helpers/workflow-contract.ts +5 -1
  38. package/assets/templates/plan.template.md +1 -1
  39. package/assets/templates/review.template.md +9 -34
  40. package/assets/workflow-contract.v1.json +10 -19
  41. package/docs/README.md +10 -10
  42. package/docs/architecture/CURRENT.md +178 -0
  43. package/docs/architecture/EVOLUTION.md +42 -0
  44. package/docs/architecture/current/README.md +4 -156
  45. package/docs/architecture/decisions/20260803-release-identity-binding-and-exit-policy.md +2 -2
  46. package/docs/architecture/decisions/20260823-immediate-controller-relay.md +53 -0
  47. package/docs/architecture/decisions/20260826-browser-runtime-v2.md +73 -0
  48. package/docs/architecture/history/README.md +7 -0
  49. package/docs/architecture/{chatgpt-handoff-facade.md → history/chatgpt-handoff-facade.md} +4 -0
  50. package/docs/architecture/{global-hook-runtime.md → history/global-hook-runtime.md} +7 -3
  51. package/docs/architecture/{ios-semantic-automation-provider-v2.md → history/ios-semantic-automation-provider-v2.md} +6 -2
  52. package/docs/architecture/history.md +3 -34
  53. package/docs/architecture/index.md +15 -98
  54. package/docs/architecture/modules/controller-runtime/transport-lifecycle.md +1 -1
  55. package/docs/architecture/reviews/2026-08-22-semantic-harness-convergence-acceptance.md +39 -0
  56. package/docs/architecture/versions/1.6.md +38 -0
  57. package/docs/architecture/versions/1.7.md +41 -0
  58. package/docs/forge-chatgpt-browser-engine.md +2 -2
  59. package/docs/forge-chatgpt-mcp-setup.md +4 -28
  60. package/docs/forge-chatgpt-supervised-automation.md +3 -3
  61. package/docs/forge-github-issue-launcher.md +1 -1
  62. package/docs/forge-plugin-management.md +1 -1
  63. package/docs/forge-runtime-self-healing-loop.md +1 -1
  64. package/docs/operations/controller-browser-plugin.md +26 -6
  65. package/docs/operations/controller-performance-and-502.md +143 -0
  66. package/docs/operations/controller-reliability-runbook.md +1 -1
  67. package/docs/operations/features.md +2 -2
  68. package/docs/operations/github-repository.md +1 -1
  69. package/docs/operations/homebrew.md +2 -2
  70. package/docs/operations/mcp-tool-exposure.md +5 -3
  71. package/docs/wiki/Architecture.md +6 -6
  72. package/docs/wiki/Implementation.md +2 -2
  73. package/docs/wiki/Integrations.md +2 -2
  74. package/docs/wiki/Work-Lifecycle.md +1 -1
  75. package/package.json +33 -11
  76. package/scripts/activate-source-baseline.ts +17 -13
  77. package/scripts/architecture-event.ts +2 -820
  78. package/scripts/architecture-queue.sh +2 -645
  79. package/scripts/archive-architecture-request.sh +2 -242
  80. package/scripts/archive-workflow.sh +1 -291
  81. package/scripts/benchmark-background-check-overlap.ts +228 -0
  82. package/scripts/benchmark-mcp-host.sh +117 -0
  83. package/scripts/benchmark-mcp-transport.ts +170 -0
  84. package/scripts/benchmark-quality-harness.ts +146 -0
  85. package/scripts/benchmark-route-session-concurrency.ts +207 -6
  86. package/scripts/benchmark-thin-harness-mcp-e2e.ts +7 -1
  87. package/scripts/benchmark-typescript-navigation.ts +186 -0
  88. package/scripts/benchmark-work-efficiency.ts +334 -0
  89. package/scripts/capability-config.ts +2 -392
  90. package/scripts/capability-resolver.ts +2 -503
  91. package/scripts/capture-plan.sh +1 -332
  92. package/scripts/check-agent-tooling.sh +2 -1558
  93. package/scripts/check-architecture-sync.sh +2 -371
  94. package/scripts/check-brain-manifest.sh +2 -253
  95. package/scripts/check-context-files.sh +2 -47
  96. package/scripts/check-deploy-sql-order.sh +2 -115
  97. package/scripts/check-mcp-compatibility.ts +14 -0
  98. package/scripts/check-runtime-architecture.mjs +349 -79
  99. package/scripts/check-skill-version.ts +3 -191
  100. package/scripts/check-source-duplication.mjs +61 -0
  101. package/scripts/check-stable-baseline.ts +92 -0
  102. package/scripts/check-task-sync.sh +2 -63
  103. package/scripts/check-task-workflow.sh +2 -1000
  104. package/scripts/codex-handoff-resume.sh +2 -267
  105. package/scripts/context-contract-sync.sh +2 -514
  106. package/scripts/contract-run.ts +2 -463
  107. package/scripts/contract-worktree.sh +1 -722
  108. package/scripts/ensure-task-workflow.sh +1 -1225
  109. package/scripts/host-temporary-cloud-mcp-e2e.sh +265 -0
  110. package/scripts/inspect-project-state.ts +4 -279
  111. package/scripts/install-standalone-recovery.ts +24 -0
  112. package/scripts/lib/project-init-lib.sh +22 -46
  113. package/scripts/lib/run-forge-helper.sh +19 -0
  114. package/scripts/lib/run-forge-helper.ts +26 -0
  115. package/scripts/migrate-project-template.sh +1 -1189
  116. package/scripts/migrate-workflow-docs.ts +4 -412
  117. package/scripts/new-plan.sh +1 -180
  118. package/scripts/new-spec.sh +1 -47
  119. package/scripts/new-sprint.sh +1 -46
  120. package/scripts/plan-to-todo.sh +1 -796
  121. package/scripts/prepare-codex-handoff.sh +2 -201
  122. package/scripts/prepare-handoff.sh +1 -78
  123. package/scripts/refresh-current-status.sh +2 -467
  124. package/scripts/run-governed-gate.ts +5 -1
  125. package/scripts/select-agent-context-blocks.sh +2 -64
  126. package/scripts/ship-worktrees.sh +1 -558
  127. package/scripts/smoke-ios-physical-device.ts +4 -2
  128. package/scripts/smoke-runtime-recovery.ts +1 -35
  129. package/scripts/smoke-schedule-engine.ts +1 -20
  130. package/scripts/sprint-backlog.sh +1 -834
  131. package/scripts/stage-runtime-release.ts +2 -1
  132. package/scripts/summarize-failures.sh +2 -123
  133. package/scripts/switch-plan.sh +1 -150
  134. package/scripts/sync-brain-docs.sh +2 -379
  135. package/scripts/sync-generated-authority.mjs +175 -0
  136. package/scripts/verify-contract.sh +2 -703
  137. package/scripts/verify-forge-runtime.sh +0 -1
  138. package/scripts/verify-sprint.sh +1 -677
  139. package/scripts/workflow-contract.ts +4 -205
  140. package/scripts/workstream-sync.sh +2 -261
  141. package/src/cli/agent-jobs/executor-health.ts +1 -1
  142. package/src/cli/commands/init-hook.ts +3 -3
  143. package/src/cli/commands/mcp.ts +9 -5
  144. package/src/cli/commands/plugin.ts +12 -3
  145. package/src/cli/commands/recovery.ts +25 -3
  146. package/src/cli/commands/runtime.ts +55 -3
  147. package/src/cli/commands/security.ts +12 -1
  148. package/src/cli/commands/setup-profile.ts +31 -21
  149. package/src/cli/controller/check-runner.ts +113 -5
  150. package/src/cli/controller/composite-result.ts +1 -1
  151. package/src/cli/controller/context/focus.ts +51 -0
  152. package/src/cli/controller/context/instruction-context.ts +114 -0
  153. package/src/cli/controller/context/known-paths.ts +76 -0
  154. package/src/cli/controller/context/query-planning.ts +110 -0
  155. package/src/cli/controller/context/rule-resolution.ts +532 -0
  156. package/src/cli/controller/context/source-materializer.ts +278 -0
  157. package/src/cli/controller/context/structural.ts +16 -0
  158. package/src/cli/controller/context/types.ts +286 -0
  159. package/src/cli/controller/context-pack.ts +828 -487
  160. package/src/cli/controller/launch-agents.ts +77 -2
  161. package/src/cli/controller/operational-plan.ts +2 -2
  162. package/src/cli/controller/work-mode.ts +6 -4
  163. package/src/cli/editing/edit-session.ts +60 -7
  164. package/src/cli/github/contracts.ts +16 -0
  165. package/src/cli/github/github.ts +135 -16
  166. package/src/cli/github/session.ts +2 -1
  167. package/src/cli/installer/managed-entries.ts +15 -1
  168. package/src/cli/local-bridge/console-automations.ts +54 -78
  169. package/src/cli/local-bridge/console-view-models.ts +1 -35
  170. package/src/cli/local-bridge/facade-api.ts +37 -264
  171. package/src/cli/local-bridge/frontend/src/App.tsx +3 -3
  172. package/src/cli/local-bridge/frontend/src/features/automations/AutomationsView.tsx +23 -13
  173. package/src/cli/local-bridge/frontend/src/features/capabilities/CapabilitiesView.tsx +37 -4
  174. package/src/cli/local-bridge/frontend/src/features/overview/OverviewView.tsx +6 -4
  175. package/src/cli/local-bridge/frontend/src/lib/api.ts +1 -6
  176. package/src/cli/local-bridge/frontend/src/lib/routes.ts +1 -1
  177. package/src/cli/local-bridge/frontend/src/shell/Sidebar.tsx +2 -2
  178. package/src/cli/local-bridge/frontend/src/styles.css +1 -1
  179. package/src/cli/local-bridge/frontend/src/types.ts +5 -8
  180. package/src/cli/local-bridge/job-store.ts +1 -490
  181. package/src/cli/local-bridge/server.ts +2 -515
  182. package/src/cli/local-bridge/ui-dist/app.css +1 -1
  183. package/src/cli/local-bridge/ui-dist/app.js +3703 -3757
  184. package/src/cli/mcp/auth.ts +5 -5
  185. package/src/cli/mcp/instructions.ts +3 -2
  186. package/src/cli/mcp/legacy-tool-service.ts +10 -222
  187. package/src/cli/mcp/multi-repository.ts +16 -5
  188. package/src/cli/mcp/oauth.ts +175 -26
  189. package/src/cli/mcp/post-finalize-work-attribution.ts +150 -0
  190. package/src/cli/mcp/repository-tools.ts +282 -146
  191. package/src/cli/mcp/server.ts +586 -116
  192. package/src/cli/mcp/tool-capability-cache.ts +1 -1
  193. package/src/cli/mcp/tool-contract.ts +14 -0
  194. package/src/cli/mcp/toolset-selection.ts +1 -1
  195. package/src/cli/mcp/toolset.ts +44 -7
  196. package/src/cli/mcp/transports/http.ts +124 -14
  197. package/src/cli/mcp/transports/session-registry.ts +43 -5
  198. package/src/cli/mcp/types.ts +3 -3
  199. package/src/cli/repositories/command-classifier.ts +103 -21
  200. package/src/cli/repositories/command-executor.ts +78 -526
  201. package/src/cli/repositories/command-process.ts +108 -0
  202. package/src/cli/repositories/command-scope.ts +99 -41
  203. package/src/cli/repositories/controller-home.ts +7 -8
  204. package/src/cli/repositories/git-command-executor.ts +2 -0
  205. package/src/cli/repositories/locks.ts +53 -16
  206. package/src/cli/repositories/repository-snapshot.ts +124 -0
  207. package/src/cli/repositories/selected-path-actions.ts +17 -9
  208. package/src/cli/repositories/structured-git.ts +118 -6
  209. package/src/cli/repository/inspector.ts +563 -65
  210. package/src/cli/repository/session-cache.ts +58 -17
  211. package/src/cli/v81-entry.ts +1 -4
  212. package/src/effects/fs-transaction.ts +85 -17
  213. package/src/runtime/context/codegraph-read-provider.ts +233 -2
  214. package/src/runtime/context/codegraph-sidecar.cjs +74 -40
  215. package/src/runtime/context/generic-lsp-provider.ts +355 -0
  216. package/src/runtime/context/lsp-client.ts +283 -0
  217. package/src/runtime/context/semantic-navigation-contract.ts +61 -0
  218. package/src/runtime/context/semantic-navigation.ts +223 -0
  219. package/src/runtime/context/swift-navigation.ts +565 -0
  220. package/src/runtime/context/typescript-navigation.ts +226 -0
  221. package/src/runtime/control-plane/dispatch-priority.ts +28 -0
  222. package/src/runtime/control-plane/execution/direct-edit-work-completion.ts +48 -16
  223. package/src/runtime/control-plane/execution/edit-validation-coordinator.ts +86 -24
  224. package/src/runtime/control-plane/execution/repository-work-attribution.ts +106 -0
  225. package/src/runtime/control-plane/execution/retained-work-resume.ts +203 -0
  226. package/src/runtime/control-plane/execution/session-store.ts +18 -0
  227. package/src/runtime/control-plane/execution/verification-evidence.ts +58 -3
  228. package/src/runtime/control-plane/execution/work-completion-authority.ts +58 -0
  229. package/src/runtime/control-plane/execution/work-evidence-policy.ts +200 -0
  230. package/src/runtime/control-plane/execution/work-execution-support.ts +386 -0
  231. package/src/runtime/control-plane/execution/work-finalization-service.ts +1913 -0
  232. package/src/runtime/control-plane/execution/work-handle-authority.ts +96 -0
  233. package/src/runtime/control-plane/execution/work-handle-store.ts +27 -2
  234. package/src/runtime/control-plane/execution/work-lifecycle-audit.ts +258 -0
  235. package/src/runtime/control-plane/execution/work-operation-service.ts +468 -0
  236. package/src/runtime/control-plane/execution/work-path-scope.ts +37 -0
  237. package/src/runtime/control-plane/execution/work-preparation-service.ts +479 -0
  238. package/src/runtime/control-plane/execution/work-process-evidence.ts +129 -0
  239. package/src/runtime/control-plane/execution/work-remote-delivery.ts +215 -0
  240. package/src/runtime/control-plane/execution/work-task-receipt.ts +22 -18
  241. package/src/runtime/control-plane/execution/work-terminal-cleanup.ts +156 -11
  242. package/src/runtime/control-plane/execution/work-validation-reconciler.ts +22 -14
  243. package/src/runtime/control-plane/execution/work-verification-context.ts +56 -0
  244. package/src/runtime/control-plane/execution/work-verification-service.ts +388 -0
  245. package/src/runtime/control-plane/execution/work-verification-snapshot.ts +90 -9
  246. package/src/runtime/control-plane/facade/capability-registry.ts +129 -25
  247. package/src/runtime/control-plane/facade/controller-round-relay.ts +1118 -0
  248. package/src/runtime/control-plane/facade/controller-session-store.ts +302 -12
  249. package/src/runtime/control-plane/facade/goal-workloop-access.ts +17 -1
  250. package/src/runtime/control-plane/facade/goal-workloop.ts +928 -190
  251. package/src/runtime/control-plane/facade/index.ts +3 -0
  252. package/src/runtime/control-plane/facade/plan-contract-store.ts +275 -42
  253. package/src/runtime/control-plane/facade/repository-work-admission.ts +147 -0
  254. package/src/runtime/control-plane/facade/requirement-authority.ts +83 -0
  255. package/src/runtime/control-plane/facade/semantic-admission.ts +205 -0
  256. package/src/runtime/control-plane/facade/suggested-actions.ts +5 -1
  257. package/src/runtime/control-plane/facade/types.ts +90 -10
  258. package/src/runtime/control-plane/facade/work-contract-store.ts +157 -261
  259. package/src/runtime/control-plane/facade/work-state-machine.ts +250 -0
  260. package/src/runtime/control-plane/generated-cache-retention.ts +271 -0
  261. package/src/runtime/control-plane/global-scheduler/config.ts +44 -0
  262. package/src/runtime/control-plane/global-scheduler/dispatch-capacity.ts +80 -0
  263. package/src/runtime/control-plane/global-scheduler/durable-admission.ts +46 -0
  264. package/src/runtime/control-plane/global-scheduler/maintenance.ts +152 -0
  265. package/src/runtime/control-plane/global-scheduler/projection-refresh.ts +84 -0
  266. package/src/runtime/control-plane/global-scheduler/reconciliation.ts +3 -3
  267. package/src/runtime/control-plane/global-scheduler/scheduler.ts +278 -543
  268. package/src/runtime/control-plane/global-scheduler/source-scan.ts +59 -0
  269. package/src/runtime/control-plane/global-scheduler/state.ts +88 -0
  270. package/src/runtime/control-plane/global-scheduler/worker-attachment.ts +57 -0
  271. package/src/runtime/control-plane/global-scheduler/worker-exit-decision.ts +38 -0
  272. package/src/runtime/control-plane/global-scheduler/worker-exit-reconciler.ts +175 -0
  273. package/src/runtime/control-plane/global-scheduler/worker-launch.ts +111 -0
  274. package/src/runtime/control-plane/global-scheduler/worker-lifecycle-store.ts +64 -0
  275. package/src/runtime/control-plane/global-scheduler/worker-lifecycle.ts +150 -0
  276. package/src/runtime/control-plane/global-scheduler/worker-process.ts +119 -0
  277. package/src/runtime/control-plane/global-scheduler/worker-stderr.ts +60 -0
  278. package/src/runtime/control-plane/launcher/chatgpt-work-binding-store.ts +63 -0
  279. package/src/runtime/control-plane/launcher/chatgpt-work-continuation.ts +365 -117
  280. package/src/runtime/control-plane/launcher/launch-reservation-store.ts +89 -0
  281. package/src/runtime/control-plane/launcher/thin-launcher.ts +244 -11
  282. package/src/runtime/control-plane/persistence/controller-home-migration.ts +487 -0
  283. package/src/runtime/control-plane/persistence/requirement-store.ts +0 -12
  284. package/src/runtime/control-plane/persistence/sqlite-store.ts +33 -2
  285. package/src/runtime/control-plane/release-retention.ts +62 -2
  286. package/src/runtime/control-plane/repo-actor/registry.ts +4 -2
  287. package/src/runtime/control-plane/routing/route-policy.ts +24 -21
  288. package/src/runtime/control-plane/routing/workspace-admission.ts +70 -0
  289. package/src/runtime/control-plane/runtime-status-client.ts +0 -2
  290. package/src/runtime/diagnostics/mcp-timing.ts +13 -0
  291. package/src/runtime/diagnostics/mcp-transport-benchmark.ts +129 -0
  292. package/src/runtime/diagnostics/performance.ts +24 -1
  293. package/src/runtime/evidence/event-ledger.ts +1 -1
  294. package/src/runtime/evidence/process-check-execution.ts +18 -0
  295. package/src/runtime/execution/jobs/child-reference.ts +6 -2
  296. package/src/runtime/execution/jobs/store.ts +58 -4
  297. package/src/runtime/execution/jobs/types.ts +1 -1
  298. package/src/runtime/execution/managed-workspace.ts +203 -1
  299. package/src/runtime/execution/process-runtime/check-facade.ts +51 -4
  300. package/src/runtime/execution/process-runtime/check-result.ts +88 -0
  301. package/src/runtime/execution/process-runtime/check-runner-sidecar.ts +7 -1
  302. package/src/runtime/execution/process-runtime/check-scheduling.ts +114 -0
  303. package/src/runtime/execution/process-runtime/command-facade.ts +367 -40
  304. package/src/runtime/execution/process-runtime/gc.ts +38 -6
  305. package/src/runtime/execution/process-runtime/lightweight-managed.ts +1201 -0
  306. package/src/runtime/execution/process-runtime/persisted-check.ts +51 -5
  307. package/src/runtime/execution/process-runtime/resource-claims.ts +10 -6
  308. package/src/runtime/execution/process-runtime/runtime.ts +53 -3
  309. package/src/runtime/execution/process-runtime/store.ts +1 -0
  310. package/src/runtime/execution/process-runtime/types.ts +4 -12
  311. package/src/runtime/execution/thin-harness/async-process.ts +12 -2
  312. package/src/runtime/execution/thin-harness/search-worker.ts +54 -5
  313. package/src/runtime/execution/work-activity.ts +21 -0
  314. package/src/runtime/execution/workers/executor.ts +18 -61
  315. package/src/runtime/gateway/mcp/execution-tools.ts +35 -1852
  316. package/src/runtime/gateway/mcp/legacy-ios-tool-adapter.ts +61 -0
  317. package/src/runtime/gateway/mcp/process-tools.ts +83 -37
  318. package/src/runtime/gateway/mcp/router.ts +186 -84
  319. package/src/runtime/gateway/mcp/runtime-tool-definitions.ts +565 -0
  320. package/src/runtime/gateway/mcp/runtime-tools.ts +2378 -1947
  321. package/src/runtime/plugins/app-store-connect-adapter.ts +216 -47
  322. package/src/runtime/plugins/browser-adapter.ts +2662 -829
  323. package/src/runtime/plugins/browser-automation-service.ts +10 -0
  324. package/src/runtime/plugins/browser-handoff-host.ts +2 -25
  325. package/src/runtime/plugins/browser-handoff.ts +110 -5
  326. package/src/runtime/plugins/browser-macos-bridge.ts +701 -63
  327. package/src/runtime/plugins/browser-manifest-surface.ts +603 -0
  328. package/src/runtime/plugins/browser-native-session-service.ts +222 -0
  329. package/src/runtime/plugins/browser-node-bridge.ts +6 -34
  330. package/src/runtime/plugins/browser-provider-registry.ts +109 -0
  331. package/src/runtime/plugins/browser-runtime-contract.ts +154 -0
  332. package/src/runtime/plugins/browser-runtime.ts +193 -0
  333. package/src/runtime/plugins/browser-session-authority.ts +332 -0
  334. package/src/runtime/plugins/browser-session-store.ts +121 -0
  335. package/src/runtime/plugins/browser-session-types.ts +98 -0
  336. package/src/runtime/plugins/capability-authorization-grants.ts +354 -0
  337. package/src/runtime/plugins/desktop-operator-registration.ts +10 -4
  338. package/src/runtime/plugins/external-adapter.ts +358 -3
  339. package/src/runtime/plugins/external-unix-socket.ts +7 -1
  340. package/src/runtime/plugins/first-party-registry.ts +2 -0
  341. package/src/runtime/plugins/github-adapter.ts +125 -0
  342. package/src/runtime/plugins/ios/agent-device-provider.ts +1 -1
  343. package/src/runtime/plugins/ios/agent-device-typed-provider.ts +52 -9
  344. package/src/runtime/plugins/ios/remote-xpc-hid.ts +1171 -0
  345. package/src/runtime/plugins/ios-adapter.ts +106 -16
  346. package/src/runtime/plugins/ios-agent-device.ts +234 -64
  347. package/src/runtime/plugins/ios-physical-device.ts +1143 -392
  348. package/src/runtime/plugins/lightweight-action.ts +153 -0
  349. package/src/runtime/plugins/local-system-adapter.ts +123 -6
  350. package/src/runtime/plugins/macos-capability-broker.ts +47 -9
  351. package/src/runtime/plugins/plugin-action-sidecar.ts +59 -0
  352. package/src/runtime/plugins/plugin-management-adapter.ts +49 -8
  353. package/src/runtime/plugins/resend-adapter.ts +1 -1
  354. package/src/runtime/plugins/store.ts +330 -33
  355. package/src/runtime/plugins/types.ts +38 -3
  356. package/src/runtime/plugins/xiaohongshu-publish.ts +515 -0
  357. package/src/runtime/projections/git-status-sampler.ts +16 -16
  358. package/src/runtime/projections/materialized-view.ts +28 -10
  359. package/src/runtime/recovery/maintenance-executor.ts +426 -25
  360. package/src/runtime/root/mcp-transport.ts +180 -10
  361. package/src/runtime/root/package-connector-service.ts +230 -10
  362. package/src/runtime/root/package-runtime-release.ts +143 -17
  363. package/src/runtime/root/package-runtime-service.ts +461 -22
  364. package/src/runtime/root/release-manifest.ts +144 -18
  365. package/src/runtime/root/release-materialize.ts +125 -32
  366. package/src/runtime/root/release-store.ts +48 -11
  367. package/src/runtime/root/runtime.ts +23 -5
  368. package/src/runtime/root/service.ts +100 -29
  369. package/src/runtime/root/types.ts +12 -0
  370. package/src/runtime/safe-tooling/ios-development.ts +321 -63
  371. package/src/runtime/shared/trusted-executable.ts +62 -0
  372. package/src/runtime/shared/trusted-node-executable.ts +48 -0
  373. package/src/runtime/standalone-recovery/core.ts +1079 -240
  374. package/src/runtime/standalone-recovery/entry.ts +100 -24
  375. package/src/runtime/standalone-recovery/installer.ts +20 -4
  376. package/src/runtime/standalone-recovery/service-labels.ts +2 -0
  377. package/src/runtime/standalone-recovery/watchdog-heartbeat.ts +160 -0
  378. package/src/runtime/workflow/schedules/browser-probe.ts +81 -3
  379. package/src/runtime/workflow/schedules/engine.ts +364 -202
  380. package/src/runtime/workflow/schedules/github-issue-watch.ts +158 -0
  381. package/src/runtime/workflow/schedules/settlement.ts +64 -17
  382. package/src/runtime/workflow/schedules/store.ts +209 -19
  383. package/src/runtime/workflow/schedules/types.ts +2 -4
  384. package/src/runtime/workflow/schedules/work-continuation.ts +26 -13
  385. package/src/testing/test-governance.ts +8 -40
  386. package/assets/reference-configs/heartbeat-triage.md +0 -57
  387. package/assets/templates/helpers/harness-trace-grade.sh +0 -150
  388. package/assets/templates/helpers/heartbeat-triage.sh +0 -361
  389. package/assets/templates/helpers/maintenance-triage.sh +0 -167
  390. package/docs/architecture/current/approved-target-architecture.zh-CN.md +0 -1501
  391. package/docs/architecture/current/architecture-invariants.md +0 -331
  392. package/docs/architecture/current/automation-and-schedule-engine.md +0 -459
  393. package/docs/architecture/current/codegraph-context-provider.md +0 -238
  394. package/docs/architecture/current/control-plane-authority-inventory.md +0 -94
  395. package/docs/architecture/current/controller-repository-decoupling.md +0 -148
  396. package/docs/architecture/current/dispatch-and-agent-strategy.md +0 -373
  397. package/docs/architecture/current/entity-model.md +0 -612
  398. package/docs/architecture/current/external-plugin-governance.md +0 -396
  399. package/docs/architecture/current/failure-recovery.md +0 -447
  400. package/docs/architecture/current/governance.md +0 -213
  401. package/docs/architecture/current/human-interaction-plane.md +0 -87
  402. package/docs/architecture/current/implementation-status.md +0 -128
  403. package/docs/architecture/current/job-and-run-lifecycle.md +0 -413
  404. package/docs/architecture/current/legacy-governance.md +0 -58
  405. package/docs/architecture/current/local-workspace-target-grants.md +0 -70
  406. package/docs/architecture/current/migration-roadmap.md +0 -105
  407. package/docs/architecture/current/multi-repository-execution.md +0 -371
  408. package/docs/architecture/current/operations-runbook.md +0 -45
  409. package/docs/architecture/current/peer-supercontroller-runtime.md +0 -32
  410. package/docs/architecture/current/personal-assistant-plugin-baseline.md +0 -206
  411. package/docs/architecture/current/repository-access-modes.md +0 -102
  412. package/docs/architecture/current/route-policy.md +0 -15
  413. package/docs/architecture/current/route-session-concurrency.md +0 -85
  414. package/docs/architecture/current/runtime-architecture-simplification.md +0 -214
  415. package/docs/architecture/current/runtime-directory-map.md +0 -49
  416. package/docs/architecture/current/runtime-health-and-resource-lifecycle.md +0 -85
  417. package/docs/architecture/current/scheduler-and-resource-claims.md +0 -422
  418. package/docs/architecture/current/session-aware-execution-and-authorization.md +0 -77
  419. package/docs/architecture/current/system-overview.md +0 -169
  420. package/docs/architecture/current/target-requirements-traceability.md +0 -202
  421. package/docs/architecture/current/thin-harness-governance-policy.md +0 -32
  422. package/docs/architecture/current/thin-harness-v1.md +0 -321
  423. package/docs/architecture/current/verification-and-release-gates.md +0 -391
  424. package/docs/forge-autonomous-goal-loop.md +0 -9
  425. package/docs/forge-provider-configuration.md +0 -7
  426. package/docs/operations/chatgpt-personal-assistant-runtime.md +0 -93
  427. package/docs/operations/gmail-assistant-routines.md +0 -186
  428. package/docs/operations/personal-assistant-operator-guide.md +0 -61
  429. package/docs/operations/provider-configuration.md +0 -31
  430. package/scripts/harness-trace-grade.sh +0 -150
  431. package/scripts/heartbeat-triage.sh +0 -361
  432. package/scripts/maintenance-triage.sh +0 -167
  433. package/src/cli/local-bridge/frontend/src/features/settings/SettingsView.tsx +0 -2
  434. package/src/cli/repositories/goal-registry.ts +0 -239
  435. package/src/runtime/assistant/action-proposals.ts +0 -279
  436. package/src/runtime/assistant/intent.ts +0 -395
  437. package/src/runtime/assistant/model-provider.ts +0 -460
  438. package/src/runtime/assistant/openapi.ts +0 -223
  439. package/src/runtime/assistant/policy.ts +0 -89
  440. package/src/runtime/assistant/readiness.ts +0 -258
  441. package/src/runtime/assistant/routine-runtime.ts +0 -477
  442. package/src/runtime/assistant/schedule-binding.ts +0 -171
  443. package/src/runtime/assistant/standing-grants.ts +0 -375
  444. package/src/runtime/assistant/store.ts +0 -243
  445. package/src/runtime/assistant/types.ts +0 -135
  446. package/src/runtime/control-plane/goal-loop/config-facade.ts +0 -700
  447. package/src/runtime/control-plane/goal-loop/config-store.ts +0 -570
  448. package/src/runtime/control-plane/goal-loop/config-types.ts +0 -213
  449. package/src/runtime/control-plane/goal-loop/executor-router.ts +0 -109
  450. package/src/runtime/control-plane/goal-loop/failure-taxonomy.ts +0 -149
  451. package/src/runtime/control-plane/goal-loop/goal-contract-store.ts +0 -304
  452. package/src/runtime/control-plane/goal-loop/goal-loop-engine.ts +0 -1001
  453. package/src/runtime/control-plane/goal-loop/handoff-packet.ts +0 -160
  454. package/src/runtime/control-plane/goal-loop/index.ts +0 -13
  455. package/src/runtime/control-plane/goal-loop/local-tools.ts +0 -290
  456. package/src/runtime/control-plane/goal-loop/policy-gates.ts +0 -203
  457. package/src/runtime/control-plane/goal-loop/provider-dispatch.ts +0 -93
  458. package/src/runtime/control-plane/goal-loop/provider-registry.ts +0 -545
  459. package/src/runtime/control-plane/goal-loop/types.ts +0 -378
  460. package/src/runtime/control-plane/startup-recovery.ts +0 -198
  461. package/src/runtime/gateway/mcp/resource-policy.ts +0 -186
  462. package/src/runtime/personal-assistant/gmail-triage-manager.ts +0 -231
  463. package/src/runtime/personal-assistant/reporting-runtime.ts +0 -344
  464. package/src/runtime/personal-assistant/triage-runtime.ts +0 -748
  465. package/src/runtime/workflow/findings/store.ts +0 -204
  466. package/src/runtime/workflow/findings/types.ts +0 -58
  467. package/src/runtime/workflow/portfolio/engine.ts +0 -20
  468. package/src/runtime/workflow/portfolio/store.ts +0 -185
  469. package/src/runtime/workflow/portfolio/types.ts +0 -29
@@ -1,1228 +1,4 @@
1
1
  #!/bin/bash
2
2
  set -euo pipefail
3
-
4
3
  SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5
- if REPO_ROOT="$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null)"; then
6
- cd "$REPO_ROOT"
7
- elif [[ "$SCRIPT_DIR" == */.ai/harness/scripts ]]; then
8
- cd "$SCRIPT_DIR/../../.."
9
- else
10
- cd "$SCRIPT_DIR/.."
11
- fi
12
-
13
- usage() {
14
- cat <<'USAGE_EOF'
15
- Usage: scripts/ensure-task-workflow.sh [--new-plan] [--slug <slug>] [--title <title>]
16
- USAGE_EOF
17
- }
18
-
19
- normalize_slug() {
20
- printf '%s' "$1" | tr '[:upper:]' '[:lower:]' | sed -E 's/[^a-z0-9]+/-/g; s/^-+//; s/-+$//; s/-{2,}/-/g'
21
- }
22
-
23
- ACTIVE_PLAN_MARKER=".ai/harness/active-plan"
24
- LEGACY_ACTIVE_PLAN_MARKER=".claude/.active-plan"
25
-
26
- read_active_plan_marker() {
27
- local marker_file="$1"
28
- local marker_plan
29
-
30
- if [[ -f "$marker_file" ]]; then
31
- marker_plan="$(cat "$marker_file" 2>/dev/null | xargs)"
32
- if [[ -n "$marker_plan" && -f "$marker_plan" ]]; then
33
- printf '%s' "$marker_plan"
34
- return 0
35
- fi
36
- fi
37
-
38
- return 1
39
- }
40
-
41
- get_active_plan() {
42
- read_active_plan_marker "$ACTIVE_PLAN_MARKER" \
43
- || read_active_plan_marker "$LEGACY_ACTIVE_PLAN_MARKER"
44
- }
45
-
46
- ensure_templates() {
47
- mkdir -p .claude/templates
48
-
49
- if [[ ! -f ".claude/templates/spec.template.md" ]]; then
50
- cat > .claude/templates/spec.template.md <<'SPEC_TEMPLATE_EOF'
51
- # Product Spec: {{PROJECT_NAME}}
52
-
53
- > **Status**: Draft
54
- > **Last Updated**: {{TIMESTAMP}}
55
- > **Owner**: Planner
56
-
57
- ## Product Outcome
58
-
59
- Describe the stable user or operator outcome this repo should deliver.
60
-
61
- ## Success Criteria
62
-
63
- - Primary workflow:
64
- - Quality bar:
65
- - Out of scope:
66
-
67
- ## Constraints
68
-
69
- - Technical:
70
- - Compliance:
71
- - Delivery:
72
-
73
- ## Acceptance Scenarios
74
-
75
- - Given
76
- When
77
- Then
78
-
79
- ## Open Questions
80
-
81
- - ...
82
- SPEC_TEMPLATE_EOF
83
- fi
84
-
85
- if [[ ! -f ".claude/templates/research.template.md" ]]; then
86
- cat > .claude/templates/research.template.md <<'RESEARCH_TEMPLATE_EOF'
87
- # {{PROJECT_NAME}} — Research Notes
88
-
89
- > **Last Updated**: {{DATE}}
90
- > **Scope**: (what area of the codebase was researched)
91
- > **Usage**: Store deep codebase findings and hidden contracts here, not in chat-only summaries.
92
-
93
- ## Codebase Map
94
- | File | Purpose | Key Exports |
95
- |------|---------|-------------|
96
-
97
- ## Architecture Observations
98
- ### Patterns & Conventions
99
- ### Implicit Contracts
100
- ### Edge Cases & Intricacies
101
-
102
- ## Technical Debt / Risks
103
-
104
- ## Research Conclusions
105
- ### What to Preserve
106
- ### What to Change
107
- ### Open Questions
108
- RESEARCH_TEMPLATE_EOF
109
- fi
110
-
111
- if [[ ! -f ".claude/templates/prd.template.md" ]]; then
112
- cat > .claude/templates/prd.template.md <<'PRD_TEMPLATE_EOF'
113
- # PRD: {{PRD_TITLE}}
114
-
115
- > **Status**: Draft
116
- > **Slug**: {{PRD_SLUG}}
117
- > **Created**: {{TIMESTAMP}}
118
- > **Updated**: {{TIMESTAMP}}
119
- > **Source Spec**: `docs/spec.md`
120
- > **Tier**: compact
121
-
122
- <!--
123
- PRD tier contract:
124
- - compact: one focused product/tool or fewer than three P0 modules, target 150-300 lines.
125
- - standard: multi-module product, target 300-600 lines and hard cap 800 lines.
126
- - If the PRD would exceed 800 lines, split it into smaller PRDs.
127
- - Output files live in plans/prds/<YYYYMMDD>-<HHMM>-<slug>.prd.md.
128
- - Inline responses should include only the AI Quick-Read Card and file path.
129
- -->
130
-
131
- ## AI Quick-Read Card
132
-
133
- - Problem:
134
- - Users:
135
- - Platform:
136
- - P0 surface:
137
- - Core metric:
138
- - Hard constraint:
139
- - Key risk:
140
- - Unknowns:
141
- - Acceptance scenarios:
142
- - Suggested next step:
143
-
144
- ## Problem
145
-
146
- ### Product Direction
147
-
148
- - Hard Constraints:
149
- - Recommended Defaults:
150
- - Freedoms:
151
-
152
- ### Feasibility Boundary
153
-
154
- - Confirmed:
155
- - [UNKNOWN]:
156
- - [UNVERIFIED]:
157
-
158
- ## Users
159
-
160
- ### Primary Users
161
-
162
- - User:
163
- - Need:
164
- - Success signal:
165
-
166
- ### Secondary Users
167
-
168
- - User:
169
- - Need:
170
- - Success signal:
171
-
172
- ## Success Criteria
173
-
174
- | Metric | Target | Measurement Method | Degradation Threshold |
175
- |---|---:|---|---:|
176
- | Example metric | 95% | Describe how to measure it | 90% |
177
-
178
- ## Acceptance Scenarios
179
-
180
- ### Scenario 1
181
-
182
- - Given:
183
- - When:
184
- - Then:
185
- - Machine-checkable evidence:
186
-
187
- ### Scenario 2
188
-
189
- - Given:
190
- - When:
191
- - Then:
192
- - Machine-checkable evidence:
193
-
194
- ## Non-goals
195
-
196
- -
197
-
198
- ## Module Behaviors (P0)
199
-
200
- ### Module 1
201
-
202
- - Purpose:
203
- - Hard Constraints:
204
- - Recommended Defaults:
205
- - Freedoms:
206
- - Normal path:
207
- - Failure path 1:
208
- - Failure path 2:
209
- - States:
210
- - Empty:
211
- - Loading:
212
- - Ready:
213
- - Error:
214
- - Dependencies:
215
- - Open decisions: None
216
-
217
- ## Data Model
218
-
219
- ```jsonc
220
- {
221
- "version": "1",
222
- "entities": [
223
- {
224
- "id": "example_entity",
225
- "owner": "user", // who owns the data
226
- "fields": {
227
- "id": "string", // stable identifier
228
- "created_at": "datetime" // creation timestamp
229
- }
230
- }
231
- ],
232
- "relationships": []
233
- }
234
- ```
235
-
236
- ## Performance Targets
237
-
238
- | Target | Number | Measurement Method | Degradation Threshold |
239
- |---|---:|---|---:|
240
- | Initial usable response | 2 seconds | Local stopwatch or automated timing | 4 seconds |
241
-
242
- ## Known Unknowns
243
-
244
- | Item | Impact | Resolution Path | Owner |
245
- |---|---|---|---|
246
- | [UNKNOWN] Example unknown | Explain impact | Explain how to resolve | Maintainer |
247
-
248
- ## Developer Handoff
249
-
250
- You are implementing this PRD.
251
-
252
- - Build first:
253
- - Do not reinterpret:
254
- - You may improve:
255
- - Verify with:
256
-
257
- ### Acceptance Scripts
258
-
259
- 1.
260
- 2.
261
- 3.
262
-
263
- ## Adjacent Patterns
264
-
265
- Use this section only in standard tier or when explicitly requested. Prefer adjacent product patterns and common workflow debt. Do not name a competitor, API, platform limit, or package size unless the fact is sourced; otherwise mark it `[UNVERIFIED]`.
266
-
267
- ## Commercialization Notes
268
-
269
- Use only when the request involves pricing, packaging, monetization, or buyer/user separation.
270
-
271
- ## Frontend Perspective
272
-
273
- Use only when the frontend shape affects product behavior, state ownership, accessibility, or implementation risk.
274
-
275
- ## Backend Perspective
276
-
277
- Use only when APIs, persistence, jobs, permissions, or data ownership affect product behavior or implementation risk.
278
- PRD_TEMPLATE_EOF
279
- fi
280
-
281
- if [[ ! -f ".claude/templates/plan.template.md" ]]; then
282
- cat > .claude/templates/plan.template.md <<'PLAN_TEMPLATE_EOF'
283
- # Plan: {{TITLE}}
284
-
285
- > **Status**: Draft
286
- > **Created**: {{TIMESTAMP}}
287
- > **Slug**: {{SLUG}}
288
- > **Spec**: `docs/spec.md`
289
- > **Research**: See `docs/researches/`
290
- > **Task Contract**: `tasks/contracts/{{ARTIFACT_STEM}}.contract.md`
291
- > **Task Review**: `tasks/reviews/{{ARTIFACT_STEM}}.review.md`
292
- > **Implementation Notes**: `tasks/notes/{{ARTIFACT_STEM}}.notes.md`
293
-
294
- ## Agentic Routing
295
- - Selected route:
296
- - Routing reason:
297
- - Due diligence:
298
- - P1 map:
299
- - P2 trace:
300
- - P3 decision rationale:
301
-
302
- ## Workflow Inventory
303
- Complete this inventory before implementation. If any line is unknown, keep the plan in Draft and fill it before projection.
304
-
305
- - Active plan: `{{PLAN_FILE}}`
306
- - Sprint contract: `tasks/contracts/{{ARTIFACT_STEM}}.contract.md`
307
- - Sprint review: `tasks/reviews/{{ARTIFACT_STEM}}.review.md`
308
- - Implementation notes: `tasks/notes/{{ARTIFACT_STEM}}.notes.md`
309
- - Deferred-goal ledger: `tasks/todos.md`
310
- - Current checks: `.ai/harness/checks/latest.json`
311
- - Run snapshots: `.ai/harness/runs/`
312
- - Scope authority: `tasks/contracts/{{ARTIFACT_STEM}}.contract.md` `allowed_paths`
313
- - 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.
314
- - 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}}`.
315
-
316
- ## Approach
317
- ### Strategy
318
- ### Trade-offs
319
- | Option | Pros | Cons | Decision |
320
- |--------|------|------|----------|
321
-
322
- ## Detailed Design
323
- ### File Changes
324
- | File | Action | Description |
325
- |------|--------|-------------|
326
-
327
- ### Code Snippets
328
- ### Data Flow
329
-
330
- ## Risk Assessment
331
- | Risk | Likelihood | Impact | Mitigation |
332
- |------|------------|--------|------------|
333
-
334
- ## Task Contracts
335
- - Contract file: `tasks/contracts/{{ARTIFACT_STEM}}.contract.md`
336
- - Review file: `tasks/reviews/{{ARTIFACT_STEM}}.review.md`
337
- - Implementation notes file: `tasks/notes/{{ARTIFACT_STEM}}.notes.md`
338
- - Template: `.claude/templates/contract.template.md`
339
- - Verification command: `bash scripts/verify-contract.sh --contract tasks/contracts/{{ARTIFACT_STEM}}.contract.md --strict`
340
- - Active plan rule: `.ai/harness/active-plan` is authoritative for this worktree when present; `.ai/harness/active-worktree` records the owning worktree; `.claude/.active-plan` is a legacy fallback during transition. Do not infer active execution from the latest non-archived plan.
341
-
342
- ## Handoff
343
-
344
- - Checks file: `.ai/harness/checks/latest.json`
345
- - Session continuation: `.ai/harness/session/continuation.md`
346
-
347
- ## Evidence Contract
348
-
349
- - **State/progress path**:
350
- - **Verification evidence**:
351
- - **Evaluator rubric**:
352
- - **Stop condition**:
353
- - **Rollback surface**:
354
-
355
- ## Annotations
356
- <!-- [NOTE]: prefixed inline. Claude processes all and revises. -->
357
-
358
- ## Task Breakdown
359
- - [ ] ...
360
- PLAN_TEMPLATE_EOF
361
- fi
362
-
363
- if [[ ! -f ".claude/templates/contract.template.md" ]]; then
364
- cat > .claude/templates/contract.template.md <<'CONTRACT_TEMPLATE_EOF'
365
- # Task Contract: {{TASK_SLUG}}
366
-
367
- > **Status**: Pending
368
- > **Plan**: {{PLAN_FILE}}
369
- > **Task Profile**: {{TASK_PROFILE}}
370
- > **Owner**: {{OWNER}}
371
- > **Capability ID**: {{CAPABILITY_ID}}
372
- > **Last Updated**: {{TIMESTAMP}}
373
- > **Review File**: `{{REVIEW_FILE}}`
374
- > **Notes File**: `{{NOTES_FILE}}`
375
-
376
- ## Goal
377
-
378
- Describe the exact outcome this task must deliver.
379
-
380
- ## Scope
381
-
382
- - In scope:
383
- - Out of scope:
384
-
385
- ## Workflow Inventory
386
-
387
- - Source plan: `{{PLAN_FILE}}`
388
- - Deferred-goal ledger: `tasks/todos.md`
389
- - Review file: `{{REVIEW_FILE}}`
390
- - Notes file: `{{NOTES_FILE}}`
391
- - Checks file: `.ai/harness/checks/latest.json`
392
- - Run snapshots: `.ai/harness/runs/`
393
- - Scope gate: edit only paths listed under `allowed_paths`; update this contract before widening scope.
394
- - Completion gate: `scripts/verify-sprint.sh` must see this contract pass, the review recommend pass, and `## External Acceptance Advice` pass or record a manual override.
395
-
396
- ## Allowed Paths
397
-
398
- ```yaml
399
- allowed_paths:
400
- - plans/
401
- - tasks/todos.md
402
- - {{CONTRACT_FILE}}
403
- - {{REVIEW_FILE}}
404
- - {{NOTES_FILE}}
405
- - .ai/context/capabilities.json
406
- - src/
407
- - tests/
408
- ```
409
-
410
- ## Delegation Contract
411
-
412
- ```yaml
413
- delegation:
414
- budget:
415
- tokens: null
416
- tool_calls: null
417
- wall_time_minutes: null
418
- permission_scope:
419
- mode: inherit_allowed_paths
420
- writable_paths: []
421
- network: inherited
422
- roles:
423
- parent:
424
- mode: narrate_and_gatekeep
425
- purpose: approval_checkpoint_owner
426
- explorer:
427
- mode: read_only
428
- purpose: codebase_research
429
- worker:
430
- mode: edit_within_allowed_paths
431
- purpose: implementation
432
- verifier:
433
- mode: read_only
434
- purpose: exit_criteria_review
435
- ```
436
-
437
- ## Exit Criteria (Machine Verifiable)
438
-
439
- ```yaml
440
- exit_criteria:
441
- files_exist:
442
- - src/modules/{{TASK_SLUG}}/index.ts
443
- - {{NOTES_FILE}}
444
- tests_pass:
445
- - path: tests/unit/{{TASK_SLUG}}.test.ts
446
- commands_succeed:
447
- - bun run typecheck
448
- files_contain:
449
- - path: src/modules/{{TASK_SLUG}}/index.ts
450
- pattern: "export"
451
- ```
452
-
453
- ## Acceptance Notes (Human Review)
454
-
455
- - Functional behavior:
456
- - Edge cases:
457
- - Regression risks:
458
-
459
- ## Rollback Point
460
-
461
- - Commit / checkpoint:
462
- - Revert strategy:
463
- CONTRACT_TEMPLATE_EOF
464
- fi
465
-
466
- if [[ ! -f ".claude/templates/review.template.md" ]]; then
467
- cat > .claude/templates/review.template.md <<'REVIEW_TEMPLATE_EOF'
468
- # Task Review: {{TASK_SLUG}}
469
-
470
- > **Status**: Pending
471
- > **Plan**: {{PLAN_FILE}}
472
- > **Contract**: {{CONTRACT_FILE}}
473
- > **Notes File**: {{NOTES_FILE}}
474
- > **Checks File**: {{CHECKS_FILE}}
475
- > **Last Updated**: {{TIMESTAMP}}
476
- > **Recommendation**: fail
477
-
478
- ## Human Review Card
479
-
480
- - Verdict: pending
481
- - Change type: code-change | docs-only | ledger-closeout | migration | eval-only | delegated-run
482
- - Intended files changed:
483
- - Actual files changed:
484
- - Commands passed:
485
- - External acceptance: unavailable
486
- - Residual risks:
487
- - Reviewer action required: inspect diff and card
488
- - Rollback:
489
-
490
- ## Verification Evidence
491
-
492
- - Forge /review run:
493
- - Commands run:
494
- - Manual checks:
495
- - Supporting artifacts:
496
-
497
- ## External Acceptance Advice
498
-
499
- > **External Acceptance**: unavailable
500
- > **External Reviewer**:
501
- > **External Source**:
502
- > **External Started**:
503
- > **External Completed**:
504
-
505
- - P1 blockers:
506
- - P2 advisories:
507
- - Acceptance checklist:
508
-
509
- ## Scorecard
510
-
511
- | Dimension | Score | Notes |
512
- |-----------|-------|-------|
513
- | Functionality | 0/10 | |
514
- | Product depth | 0/10 | |
515
- | Design quality | 0/10 | |
516
- | Code quality | 0/10 | |
517
-
518
- ## Failing Items
519
-
520
- - ...
521
-
522
- ## Retest Steps
523
-
524
- - Re-run:
525
- - Re-check:
526
-
527
- ## Summary
528
-
529
- - ...
530
- REVIEW_TEMPLATE_EOF
531
- fi
532
-
533
- if [[ ! -f ".claude/templates/implementation-notes.template.md" ]]; then
534
- cat > .claude/templates/implementation-notes.template.md <<'NOTES_TEMPLATE_EOF'
535
- # Implementation Notes: {{TASK_SLUG}}
536
-
537
- > **Status**: Active
538
- > **Plan**: {{PLAN_FILE}}
539
- > **Contract**: {{CONTRACT_FILE}}
540
- > **Review**: {{REVIEW_FILE}}
541
- > **Last Updated**: {{TIMESTAMP}}
542
- > **Lifecycle**: notes
543
-
544
- ## Design Decisions
545
-
546
- - ...
547
-
548
- ## Deviations From Plan Or Spec
549
-
550
- - None recorded.
551
-
552
- ## Tradeoffs Considered
553
-
554
- | Option | Decision | Reason |
555
- |--------|----------|--------|
556
- | ... | ... | ... |
557
-
558
- ## Open Questions
559
-
560
- - None.
561
-
562
- ## Evidence Links
563
-
564
- - Checks: `.ai/harness/checks/latest.json`
565
- - Run snapshots: `.ai/harness/runs/`
566
-
567
- ## Promotion Candidates
568
-
569
- - Promote to `tasks/lessons.md` only after a repeated correction or failure pattern.
570
- - Promote to `docs/researches/` only when it is durable repo knowledge with evidence.
571
- - Promote to harness asset files only after verification across more than one task or fixture.
572
- NOTES_TEMPLATE_EOF
573
- fi
574
- }
575
-
576
- ensure_idle_todo() {
577
- mkdir -p tasks
578
- if [[ ! -f "tasks/todos.md" ]]; then
579
- cat > tasks/todos.md <<'TODO_EOF'
580
- # Deferred Goal Ledger
581
-
582
- > **Status**: Backlog
583
- > **Updated**: (ensure-task-workflow)
584
- > **Scope**: Medium/long-term goals deferred from active plan execution
585
-
586
- Current plan tasks live in the active plan's `## Task Breakdown`.
587
- Do not duplicate that execution checklist here. Record only work intentionally deferred beyond this slice, with the tradeoff and revisit trigger.
588
-
589
- ## Deferred Goals
590
-
591
- | Goal | Why Deferred | Tradeoff | Revisit Trigger |
592
- |------|--------------|----------|-----------------|
593
- | (none) | No deferred medium/long-term goal recorded yet. | Keep the current slice bounded. | Add a row when a real follow-up is postponed. |
594
- TODO_EOF
595
- fi
596
- }
597
-
598
- ensure_current_status_snapshot() {
599
- mkdir -p tasks
600
- if [[ -x "scripts/refresh-current-status.sh" ]]; then
601
- bash "scripts/refresh-current-status.sh" --clear --write --reason "ensure-task-workflow" >/dev/null 2>&1 || true
602
- return 0
603
- fi
604
-
605
- if [[ ! -f "tasks/current.md" ]]; then
606
- cat > tasks/current.md <<'CURRENT_STATUS_EOF'
607
- # Current Status Snapshot
608
-
609
- <!-- generated-by: forge refresh-current-status v1 -->
610
- <!-- updated_at: bootstrap -->
611
- <!-- stale_after: 24h -->
612
-
613
- > **Status**: Idle
614
- > **Updated At**: bootstrap
615
- > **Source Branch**: main
616
- > **Source Commit**: bootstrap
617
- > **Target Branch**: main
618
- > **Stale After**: 24h
619
- > **Reason**: bootstrap
620
- > **Derived From**: active-plan, workstreams, handoff, checks, git status
621
-
622
- This file is a tracked mainline snapshot derived from repo artifacts. It is not a live lock, not a kanban board, and not an implementation gate. If it is stale, read the source artifacts below.
623
- CURRENT_STATUS_EOF
624
- fi
625
- }
626
-
627
- ensure_auxiliary_files() {
628
- mkdir -p plans plans/archive plans/prds plans/sprints tasks/issues tasks/archive tasks/contracts tasks/reviews tasks/notes tasks/workstreams docs/architecture/domains docs/architecture/modules docs/architecture/requests docs/architecture/snapshots docs/architecture/diagrams scripts .ai/context .ai/harness/checks .ai/harness/session .ai/harness/controller/packets .ai/harness/projections .ai/harness/transfers .ai/harness/scripts .ai/harness/failures .ai/harness/security .ai/harness/planning .ai/harness/architecture .ai/harness/worktrees .ai/harness/runs .ai/harness/jobs .ai/harness/local-jobs .ai/harness/controller .ai/harness/edit-sessions
629
-
630
- if [[ ! -f "docs/spec.md" ]]; then
631
- cat > docs/spec.md <<'SPEC_EOF'
632
- # Product Spec
633
-
634
- > **Status**: Draft
635
- > **Owner**: Planner
636
- SPEC_EOF
637
- fi
638
-
639
- if [[ ! -f "tasks/lessons.md" ]]; then
640
- cat > tasks/lessons.md <<'LESSONS_EOF'
641
- # Lessons Learned (Self-Improvement Loop)
642
-
643
- > Capture correction-derived prevention rules here.
644
- > Promote repeated patterns into durable project rules during spa day.
645
-
646
- ## Template
647
- - Date:
648
- - Triggered by correction:
649
- - Mistake pattern:
650
- - Prevention rule:
651
- - Where to apply next time:
652
- LESSONS_EOF
653
- fi
654
-
655
- mkdir -p docs/researches
656
- if [[ ! -f "docs/researches/README.md" ]]; then
657
- cat > docs/researches/README.md <<'RESEARCH_README_EOF'
658
- # Research Reports
659
-
660
- Durable research reports live in this directory as dated Markdown files.
661
-
662
- Use `YYYYMMDD-topic.md` names for new reports. Keep task-local implementation
663
- decisions in `tasks/notes/`, and keep repeated correction-derived rules in
664
- `tasks/lessons.md`.
665
- RESEARCH_README_EOF
666
- fi
667
-
668
- if [[ ! -f ".ai/harness/checks/latest.json" ]]; then
669
- echo "{}" > ".ai/harness/checks/latest.json"
670
- fi
671
-
672
- if [[ ! -f ".ai/harness/session/continuation.md" ]]; then
673
- cat > ".ai/harness/session/continuation.md" <<'HANDOFF_EOF'
674
- # Forge Session Continuation Snapshot
675
-
676
- > **Reason**: bootstrap
677
- HANDOFF_EOF
678
- fi
679
-
680
- if [[ ! -f ".ai/harness/session/resume.md" ]]; then
681
- cat > ".ai/harness/session/resume.md" <<'RESUME_EOF'
682
- # Codex Resume Packet
683
-
684
- > **Reason**: bootstrap
685
- RESUME_EOF
686
- fi
687
-
688
- if [[ ! -f ".ai/harness/events.jsonl" ]]; then
689
- : > ".ai/harness/events.jsonl"
690
- fi
691
-
692
- if [[ ! -f ".ai/harness/architecture/events.jsonl" ]]; then
693
- : > ".ai/harness/architecture/events.jsonl"
694
- fi
695
-
696
- if [[ ! -f ".ai/harness/architecture/.gitkeep" ]]; then
697
- : > ".ai/harness/architecture/.gitkeep"
698
- fi
699
-
700
- if [[ ! -f ".ai/harness/failures/latest.jsonl" ]]; then
701
- : > ".ai/harness/failures/latest.jsonl"
702
- fi
703
-
704
- if [[ ! -f ".ai/harness/security/.gitkeep" ]]; then
705
- : > ".ai/harness/security/.gitkeep"
706
- fi
707
-
708
- if [[ ! -f ".ai/harness/runs/.gitkeep" ]]; then
709
- : > ".ai/harness/runs/.gitkeep"
710
- fi
711
- if [[ ! -f ".ai/harness/worktrees/.gitkeep" ]]; then
712
- : > ".ai/harness/worktrees/.gitkeep"
713
- fi
714
- if [[ ! -f ".ai/harness/jobs/.gitkeep" ]]; then
715
- : > ".ai/harness/jobs/.gitkeep"
716
- fi
717
- if [[ ! -f ".ai/harness/edit-sessions/.gitkeep" ]]; then
718
- : > ".ai/harness/edit-sessions/.gitkeep"
719
- fi
720
-
721
- if [[ ! -f "docs/architecture/requests/.gitkeep" ]]; then
722
- : > "docs/architecture/requests/.gitkeep"
723
- fi
724
-
725
- if [[ ! -f "docs/architecture/snapshots/.gitkeep" ]]; then
726
- : > "docs/architecture/snapshots/.gitkeep"
727
- fi
728
-
729
- if [[ ! -f "docs/architecture/diagrams/.gitkeep" ]]; then
730
- : > "docs/architecture/diagrams/.gitkeep"
731
- fi
732
-
733
- if [[ ! -f "docs/architecture/domains/.gitkeep" ]]; then
734
- : > "docs/architecture/domains/.gitkeep"
735
- fi
736
-
737
- if [[ ! -f "docs/architecture/modules/.gitkeep" ]]; then
738
- : > "docs/architecture/modules/.gitkeep"
739
- fi
740
-
741
- if [[ ! -f "tasks/workstreams/.gitkeep" ]]; then
742
- : > "tasks/workstreams/.gitkeep"
743
- fi
744
-
745
- if [[ ! -f ".ai/context/capabilities.json" ]]; then
746
- cat > ".ai/context/capabilities.json" <<'CAPABILITIES_EOF'
747
- {
748
- "version": 1,
749
- "capabilities": []
750
- }
751
- CAPABILITIES_EOF
752
- fi
753
-
754
- if [[ ! -f "docs/architecture/index.md" ]]; then
755
- cat > "docs/architecture/index.md" <<'ARCHITECTURE_INDEX_EOF'
756
- # Architecture Index
757
-
758
- > Umbrella architecture ledger for current boundaries, drift requests, snapshots, and diagrams.
759
-
760
- ## Current Snapshot
761
-
762
- - Latest snapshot: (none yet)
763
- - Semantic diagram source: (none yet)
764
- - Latest human diagram: (none yet)
765
-
766
- ## Architecture Drift Flow
767
-
768
- - `scripts/architecture-queue.sh` records architecture-sensitive edits as requests.
769
- - `scripts/archive-architecture-request.sh` archives handled requests after an agent records the resolution status and linked artifacts.
770
- - `scripts/context-contract-sync.sh` keeps only the controlled architecture block in functional-block `AGENTS.md` and `CLAUDE.md` files aligned.
771
- - `scripts/workstream-sync.sh` keeps durable multi-session progress under `tasks/workstreams/<domain>/<capability>/` and projects only pointers into local contracts.
772
- - Semantic architecture diagrams live as Mermaid fenced blocks in the relevant module or snapshot Markdown.
773
- - Human-readable architecture diagrams are optional `mermaid` HTML files in `docs/architecture/diagrams/` and should link back to the Markdown semantic source.
774
-
775
- ## Pending Requests
776
-
777
- <!-- BEGIN ARCHITECTURE PENDING REQUESTS -->
778
- - (none)
779
- <!-- END ARCHITECTURE PENDING REQUESTS -->
780
-
781
- ARCHITECTURE_INDEX_EOF
782
- fi
783
-
784
- if [[ ! -f ".ai/harness/policy.json" ]]; then
785
- cat > ".ai/harness/policy.json" <<'POLICY_EOF'
786
- {
787
- "version": 1,
788
- "active_plan": {
789
- "marker_file": ".ai/harness/active-plan",
790
- "legacy_marker_file": ".claude/.active-plan",
791
- "directory": "plans",
792
- "archive_directory": "plans/archive",
793
- "glob": "plan-*.md",
794
- "active_worktree_marker_file": ".ai/harness/active-worktree",
795
- "source_of_truth": "per-worktree explicit marker with active-worktree owner; legacy Claude marker fallback only"
796
- },
797
- "tasks": {
798
- "todo_file": "tasks/todos.md",
799
- "current_status_file": "tasks/current.md",
800
- "lessons_file": "tasks/lessons.md",
801
- "research_dir": "docs/researches",
802
- "workstreams_dir": "tasks/workstreams",
803
- "contracts_dir": "tasks/contracts",
804
- "reviews_dir": "tasks/reviews",
805
- "notes_dir": "tasks/notes"
806
- },
807
- "reference_material": {
808
- "dir": "_ref",
809
- "mode": "external-ignored",
810
- "commit_policy": "never commit _ref contents",
811
- "rule": "use _ref as an occasional ignored external reference checkout cache for upstream/source comparison only; refresh from external sources instead of editing as product code; when it influences a decision, cite the source repo plus commit/tag and path in tasks/notes/ or docs/researches/"
812
- },
813
- "operations": {
814
- "dir": "deploy",
815
- "private_dir": "_ops",
816
- "tracked": ["deploy/README.md", "deploy/scripts/", "deploy/submissions/", "deploy/runbooks/", "deploy/release-checklists/", "deploy/sql/", "deploy/*.md", "deploy/env/.env.example"],
817
- "ignored": ["_ops/"],
818
- "rule": "commit deployment runbooks, submission materials, release checklists, helper scripts, ordered SQL files, and env examples under deploy/; keep deploy SQL in deploy/sql/ with 4-digit ascending prefixes; keep keys, tokens, real env values, provider state, artifacts, logs, and scratch files in ignored _ops/ only"
819
- },
820
- "context": {
821
- "profile": "stable-root-progressive-subdir",
822
- "map_file": ".ai/context/context-map.json",
823
- "capability_registry_file": ".ai/context/capabilities.json",
824
- "capability_resolver": "scripts/capability-resolver.ts",
825
- "capability_match_rule": "longest-prefix; same-length ambiguity fails",
826
- "functional_block_selector": {
827
- "script": "scripts/select-agent-context-blocks.sh",
828
- "config_file": ".ai/context/agent-context-blocks.txt",
829
- "env": "FORGE_CONTEXT_BLOCKS",
830
- "rule": "compatibility selector; capability registry is the source of truth"
831
- }
832
- },
833
- "harness": {
834
- "policy_file": ".ai/harness/policy.json",
835
- "checks_file": ".ai/harness/checks/latest.json",
836
- "failure_log_file": ".ai/harness/failures/latest.jsonl",
837
- "events_file": ".ai/harness/events.jsonl",
838
- "architecture_events_file": ".ai/harness/architecture/events.jsonl",
839
- "runs_dir": ".ai/harness/runs",
840
- "helper_runtime_dir": "scripts",
841
- "helper_compat_dir": "scripts",
842
- "helper_source": "compat-bootstrap"
843
- },
844
- "architecture": {
845
- "index_file": "docs/architecture/index.md",
846
- "requests_dir": "docs/architecture/requests",
847
- "snapshots_dir": "docs/architecture/snapshots",
848
- "diagrams_dir": "docs/architecture/diagrams",
849
- "domains_dir": "docs/architecture/domains",
850
- "modules_dir": "docs/architecture/modules",
851
- "diagram_skill": "mermaid",
852
- "diagram_skill_source": "~/.codex/skills/mermaid",
853
- "vendoring_policy": "do-not-vendor-diagram-skill-assets",
854
- "freshness_gate": "advisory",
855
- "gate_min_severity": "medium",
856
- "pending_card_scope": "capability",
857
- "pending_block_begin": "<!-- BEGIN ARCHITECTURE PENDING REQUESTS -->",
858
- "pending_block_end": "<!-- END ARCHITECTURE PENDING REQUESTS -->",
859
- "queue_script": "scripts/architecture-queue.sh",
860
- "contract_block_begin": "<!-- BEGIN ARCHITECTURE CONTRACT -->",
861
- "contract_block_end": "<!-- END ARCHITECTURE CONTRACT -->",
862
- "rule": "hooks record architecture queue cards and sync controlled local context blocks; agents author semantic snapshots and diagrams"
863
- },
864
- "workstreams": {
865
- "dir": "tasks/workstreams",
866
- "scope": "capability",
867
- "projection": "local-contract-active-pointer-and-current-slice",
868
- "todo_projection": "tasks/todos.md",
869
- "rule": "durable multi-session progress lives under tasks/workstreams/<domain>/<capability>; current plan execution lives in the plan Task Breakdown; tasks/todos.md records deferred goals only"
870
- },
871
- "information_lifecycle": {
872
- "notes": {
873
- "dir": "tasks/notes",
874
- "purpose": "task-local implementation decisions, deviations, tradeoffs, and open questions",
875
- "promotion": "archive on workflow close; promote only repeated or durable findings"
876
- },
877
- "evidence": {
878
- "latest": ".ai/harness/checks/latest.json",
879
- "snapshots_dir": ".ai/harness/runs",
880
- "purpose": "raw verification records used to audit notes, reviews, and future promotion"
881
- },
882
- "assets": {
883
- "sources": [".ai/harness/policy.json", ".ai/harness/workflow-contract.json", ".ai/hooks/", "scripts/", "docs/reference-configs/"],
884
- "promotion_rule": "only promote patterns after verified reuse across tasks or fixtures"
885
- },
886
- "memory": {
887
- "sources": ["docs/researches/", "tasks/lessons.md", "gbrain"],
888
- "rule": "memory is advisory; current repo state and evidence override summaries"
889
- },
890
- "external_knowledge": {
891
- "default_brain_path": "brain/<project>/*",
892
- "project_path": "brain/<project>/*",
893
- "manifest_file": ".ai/harness/brain-manifest.json",
894
- "drift_check": "scripts/check-brain-manifest.sh",
895
- "sync_script": "scripts/sync-brain-docs.sh",
896
- "hook_trigger": "PostToolUse Edit|Write for manifest entries with sync.direction=repo-to-brain",
897
- "rule": "external knowledge stores long-lived explanations, runbooks, and patterns only; repo-local contracts, hooks, scripts, checks, and evidence remain authoritative",
898
- "sync_rule": "only explicitly opted-in repo-to-brain manifest entries may be written to the default brain vault; pointer-only externalized stubs remain check-only"
899
- }
900
- },
901
- "session": {
902
- "continuation_file": ".ai/harness/session/continuation.md",
903
- "resume_file": ".ai/harness/session/resume.md",
904
- "global_resume_dir": "~/.codex/handoffs",
905
- "auto_start_new_session": false,
906
- "authority": "rebuildable-host-session-cache-only"
907
- },
908
- "plan_capture": {
909
- "script": "scripts/capture-plan.sh",
910
- "sources": ["host-plan-mode", "forge-plan"],
911
- "rule": "Forge /plan or host planning mode may capture decision-complete source plans into plans/plan-*.md; migrated lifecycle execution remains owned by Runtime Plan/Work state"
912
- },
913
- "planning": {
914
- "pending_orchestration_file": ".ai/harness/planning/pending.json",
915
- "source_of_truth": "transient host planning bridge only; captured plans are source artifacts, while migrated Runtime Plan/Work lifecycle state is authoritative in the Canonical Runtime"
916
- },
917
- "guards": {
918
- "edit_plan_gate": "advice",
919
- "edit_plan_gate_modes": ["enforce", "advice", "off"],
920
- "rule": "pre-edit-guard advises when implementation lacks an active plan; execution remains available unless a real safety boundary blocks it"
921
- },
922
- "sidecar_research": {
923
- "default": true,
924
- "output_dir": "docs/researches",
925
- "preferred_runners": ["subagent", "codex exec --json", "main-thread trace"],
926
- "spawn_decision": "main agent decides from task breadth, context impact, raw-log volume, and callable runner availability; do not ask the user for spawn confirmation",
927
- "fallback_runner": "main-thread trace",
928
- "main_thread_policy": "if spawning is not worthwhile or no sidecar runner is callable, perform bounded research in the main thread; consume conclusions and evidence paths, not raw logs"
929
- },
930
- "documentation": {
931
- "profile": "minimal-agentic",
932
- "required": ["docs/spec.md", "docs/architecture/index.md"],
933
- "on_demand": ["docs/brief.md", "docs/tech-stack.md", "docs/decisions.md", "docs/architecture.md", "docs/packages.md"],
934
- "reference_configs": ["harness-overview.md", "agentic-development-flow.md", "external-tooling.md", "sprint-contracts.md", "handoff-protocol.md", "document-generation.md", "global-working-rules.md"],
935
- "reference_source": "user-level-runtime-docs",
936
- "reference_stub_marker": "<!-- forge: reference-config-stub v1 -->",
937
- "reference_resolver": "forge docs path <doc-id>",
938
- "rule": "create optional docs only when the agent has concrete repo evidence or the user asks; docs/reference-configs contains repo-local pointer stubs while full generic runtime docs live in the user-level/package forge install"
939
- },
940
- "lsp_profiles": {
941
- "default": "typescript-lsp",
942
- "selection": "functional-block-first",
943
- "rule": "use block-level LSP/tooling hints before broad repo assumptions"
944
- },
945
- "worktree_strategy": {
946
- "auto_on_conflict": true,
947
- "auto_for_contract_tasks": true,
948
- "branch_prefix": "codex/",
949
- "base_branch": "main",
950
- "worktree_dir_template": "../{{repo}}-wt-{{slug}}",
951
- "start_script": "scripts/contract-worktree.sh start --plan <plan-file>",
952
- "finish_script": "scripts/contract-worktree.sh finish",
953
- "cleanup_script": "scripts/contract-worktree.sh cleanup --slug <slug>",
954
- "conflict_signals": [
955
- "dirty_worktree_overlaps_task_files",
956
- "current_branch_not_suitable_for_task",
957
- "existing_changes_unrelated_but_would_block_review",
958
- "task_requires_clean_validation_surface"
959
- ],
960
- "validation_route": "forge:/review",
961
- "merge_back": {
962
- "target": "main",
963
- "requires_clean_check": true,
964
- "preserve_unrelated_changes": true
965
- }
966
- },
967
- "upgrade": {
968
- "strategy_version": 1,
969
- "supported_legacy_versions": ["pre-tasks-first", "tasks-first-without-contract-manifest", "current-v1"],
970
- "action_classes": {
971
- "preserve": "keep user-authored hooks, ignored reference material, private operations state, secrets, and local env files unchanged",
972
- "archive": "move user-authored legacy workflow documents or checklists into archive/research surfaces before refresh",
973
- "reconfigure": "merge managed config defaults without overwriting explicit repo overrides",
974
- "remove": "delete only workflow-contract actions marked ownership=known_generated"
975
- },
976
- "cleanup": {
977
- "source": ".ai/harness/workflow-contract.json#migrations.upgrade.actions",
978
- "remove_only_ownership": "known_generated",
979
- "unknown_files": "preserve-or-archive",
980
- "custom_hooks": "preserve",
981
- "ignored_reference_material": "preserve",
982
- "local_operations_state": "preserve",
983
- "local_secrets": "preserve"
984
- },
985
- "reporting": {
986
- "inspector_field": "upgrade_plan",
987
- "dry_run_required": true
988
- }
989
- },
990
- "profiles": {
991
- "orchestration": "shared-long-running-harness",
992
- "evaluation": "browser-qa",
993
- "handoff": "artifact-aware",
994
- "recovery": "hybrid",
995
- "state": "file-backed"
996
- },
997
- "external_tooling": {
998
- "routing": {
999
- "primary": "forge",
1000
- "optional_complex_helper": "gstack",
1001
- "optional_small_helper": "waza",
1002
- "optional_knowledge_helper": "gbrain"
1003
- },
1004
- "hosts": [
1005
- "claude-code",
1006
- "codex"
1007
- ],
1008
- "mode": "optional-enhancement",
1009
- "detection": "init-migrate",
1010
- "readiness_gate": "scripts/check-agent-tooling.sh --host codex",
1011
- "waza": {
1012
- "source_repo": "tw93/Waza",
1013
- "source_url": "https://github.com/tw93/Waza.git",
1014
- "managed_skills": ["think", "hunt", "check", "health"],
1015
- "primary_host": "codex",
1016
- "codex_primary_path": "~/.codex/skills",
1017
- "staging_cache_path": "~/.agents/skills",
1018
- "sync_mode": "stage-upstream-then-copy-to-codex",
1019
- "host_drift_policy": "report-per-host-version-staging-and-upstream-drift"
1020
- },
1021
- "codex_automation_profile": {
1022
- "required_skills": [],
1023
- "optional_skills": ["health", "check", "mermaid"],
1024
- "mode": "codex-runtime-reference",
1025
- "source": "~/.codex/skills",
1026
- "routes": {
1027
- "workflow_health": "forge:/debug",
1028
- "review_gate": "forge:/review",
1029
- "architecture_diagram": "mermaid-if-installed"
1030
- },
1031
- "vendoring_policy": "do-not-vendor-skill-body"
1032
- },
1033
- "diagram_design": {
1034
- "skill_name": "mermaid",
1035
- "primary_host": "codex",
1036
- "codex_primary_path": "~/.codex/skills/mermaid",
1037
- "sync_mode": "external-installed-skill",
1038
- "vendoring_policy": "do-not-vendor"
1039
- },
1040
- "gbrain": {
1041
- "mcp": "candidate-disabled"
1042
- },
1043
- "codegraph": {
1044
- "package": "@colbymchenry/codegraph",
1045
- "primary_host": "both",
1046
- "install_mode": "target-aware-mcp",
1047
- "codex_config_path": "~/.codex/config.toml",
1048
- "claude_config_path": "~/.claude.json",
1049
- "index_dir": ".codegraph",
1050
- "readiness": "optional-global-cli-mcp; bundled-rh-context-backend-is-runtime-owned",
1051
- "hook_policy": "do-not-block-hooks",
1052
- "install_command": "bun add -g @colbymchenry/codegraph && forge tools configure codegraph --target codex --location global",
1053
- "project_init_command": "codegraph init -i .",
1054
- "sync_command": "codegraph sync .",
1055
- "vendoring_policy": "do-not-add-package-dependency"
1056
- }
1057
- },
1058
- "agentic_development": {
1059
- "routing": {
1060
- "small_bounded_change": "forge:/direct",
1061
- "planning": "forge:/plan",
1062
- "bug_or_regression": "forge:/debug",
1063
- "post_implementation_review": "forge:/review",
1064
- "release": "forge:/release",
1065
- "scale": "forge:/scale"
1066
- },
1067
- "optional_enhancements": {
1068
- "direct": "forge:/direct",
1069
- "plan": "forge:/plan",
1070
- "debug": "forge:/debug",
1071
- "review": "forge:/review",
1072
- "release": "forge:/release",
1073
- "scale": "forge:/scale"
1074
- },
1075
- "due_diligence": {
1076
- "levels": ["P1_GLOBAL_ARCHITECTURE", "P2_DATA_FLOW_TRACE", "P3_DESIGN_DECISION"],
1077
- "explicit_report_required_for": ["forge:/plan", "forge:/debug", "risky_refactor", "deployment", "auth_payment_data", "shared_contract"]
1078
- }
1079
- },
1080
- "enforcement": {
1081
- "worktree_guard": "warn-by-default",
1082
- "verification_gate": "contract-and-review",
1083
- "completion_requires_checks": true
1084
- }
1085
- }
1086
- POLICY_EOF
1087
- fi
1088
-
1089
- if [[ ! -f ".ai/harness/brain-manifest.json" ]]; then
1090
- cat > ".ai/harness/brain-manifest.json" <<'BRAIN_MANIFEST_EOF'
1091
- {
1092
- "version": 1,
1093
- "project": "<project>",
1094
- "mode": "repo-contract-external-knowledge",
1095
- "default_brain_path": "brain/<project>/*",
1096
- "rules": [
1097
- "repo-local contracts, hooks, scripts, checks, and evidence remain authoritative",
1098
- "default brain stores long-lived explanations, runbooks, decisions, references, and patterns",
1099
- "hook runtime may sync explicitly opted-in repo-to-brain entries only; it must not query gbrain, MCP, or unregistered default brain paths"
1100
- ],
1101
- "entries": []
1102
- }
1103
- BRAIN_MANIFEST_EOF
1104
- fi
1105
-
1106
- if [[ ! -f ".ai/context/context-map.json" ]]; then
1107
- cat > ".ai/context/context-map.json" <<'CONTEXT_EOF'
1108
- {
1109
- "version": 1,
1110
- "profile": "stable-root-progressive-subdir",
1111
- "functional_block_selector": {
1112
- "script": "scripts/select-agent-context-blocks.sh",
1113
- "config_file": ".ai/context/agent-context-blocks.txt",
1114
- "env": "FORGE_CONTEXT_BLOCKS",
1115
- "rule": "compatibility selector; capability registry is the source of truth"
1116
- },
1117
- "lsp_profiles": {
1118
- "default": "typescript-lsp",
1119
- "selection": "functional-block-first"
1120
- },
1121
- "root_context_files": [
1122
- "CLAUDE.md",
1123
- "AGENTS.md",
1124
- "docs/spec.md",
1125
- "tasks/current.md",
1126
- "tasks/todos.md",
1127
- "tasks/lessons.md",
1128
- ".ai/context/capabilities.json",
1129
- ".ai/harness/policy.json"
1130
- ],
1131
- "discoverable_contexts": [
1132
- {
1133
- "path": "docs/reference-configs/*.md",
1134
- "priority": "low",
1135
- "char_budget": 900,
1136
- "purpose": "deep-doc"
1137
- },
1138
- {
1139
- "path": "tasks/workstreams/**/*.md",
1140
- "priority": "high",
1141
- "char_budget": 1200,
1142
- "purpose": "capability-workstream"
1143
- }
1144
- ],
1145
- "budgets": {
1146
- "root_total_chars": 12000,
1147
- "per_discoverable_file_chars": 1200
1148
- }
1149
- }
1150
- CONTEXT_EOF
1151
- fi
1152
- }
1153
-
1154
- slug=""
1155
- title=""
1156
- new_plan=0
1157
-
1158
- while [[ $# -gt 0 ]]; do
1159
- case "$1" in
1160
- --new-plan)
1161
- new_plan=1
1162
- shift
1163
- ;;
1164
- --slug)
1165
- [[ -n "${2:-}" ]] || { echo "Error: --slug requires a value" >&2; usage; exit 1; }
1166
- slug="$2"
1167
- shift 2
1168
- ;;
1169
- --title)
1170
- [[ -n "${2:-}" ]] || { echo "Error: --title requires a value" >&2; usage; exit 1; }
1171
- title="$2"
1172
- shift 2
1173
- ;;
1174
- --help|-h)
1175
- usage
1176
- exit 0
1177
- ;;
1178
- *)
1179
- echo "Unknown argument: $1" >&2
1180
- usage
1181
- exit 1
1182
- ;;
1183
- esac
1184
- done
1185
-
1186
- ensure_templates
1187
- ensure_auxiliary_files
1188
- ensure_idle_todo
1189
- ensure_current_status_snapshot
1190
-
1191
- active_plan="$(get_active_plan || true)"
1192
- if [[ -n "$active_plan" && "$new_plan" -eq 0 ]]; then
1193
- echo "Workflow ready. Active plan: $active_plan"
1194
- exit 0
1195
- fi
1196
-
1197
- if [[ ! -f "docs/spec.md" ]]; then
1198
- if [[ -x "scripts/new-spec.sh" ]]; then
1199
- bash "scripts/new-spec.sh"
1200
- fi
1201
- fi
1202
-
1203
- if [[ -z "$slug" ]]; then
1204
- if [[ "$new_plan" -eq 1 ]]; then
1205
- echo "--new-plan requires --slug" >&2
1206
- exit 1
1207
- fi
1208
- echo "Workflow ready. No active plan present."
1209
- echo "Create one with: bash scripts/ensure-task-workflow.sh --slug <slug> --title <title>"
1210
- exit 0
1211
- fi
1212
-
1213
- slug="$(normalize_slug "$slug")"
1214
- if [[ -z "$slug" ]]; then
1215
- echo "Slug is empty after normalization" >&2
1216
- exit 1
1217
- fi
1218
-
1219
- if [[ -z "$title" ]]; then
1220
- title="$slug"
1221
- fi
1222
-
1223
- if [[ -x "scripts/new-plan.sh" ]]; then
1224
- bash "scripts/new-plan.sh" --slug "$slug" --title "$title"
1225
- else
1226
- echo "Missing scripts/new-plan.sh" >&2
1227
- exit 1
1228
- fi
4
+ exec "$SCRIPT_DIR/lib/run-forge-helper.sh" "ensure-task-workflow.sh" "$@"