all-hands-cli 0.1.0

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 (305) hide show
  1. package/.allhands/README.md +75 -0
  2. package/.allhands/agents/compounder.yaml +15 -0
  3. package/.allhands/agents/coordinator.yaml +17 -0
  4. package/.allhands/agents/documentor.yaml +15 -0
  5. package/.allhands/agents/e2e-test-planner.yaml +17 -0
  6. package/.allhands/agents/emergent.yaml +22 -0
  7. package/.allhands/agents/executor.yaml +14 -0
  8. package/.allhands/agents/ideation.yaml +11 -0
  9. package/.allhands/agents/initiative-steering.yaml +19 -0
  10. package/.allhands/agents/judge.yaml +13 -0
  11. package/.allhands/agents/planner.yaml +19 -0
  12. package/.allhands/agents/pr-reviewer.yaml +15 -0
  13. package/.allhands/docs.json +5 -0
  14. package/.allhands/docs.local.json +26 -0
  15. package/.allhands/flows/COMPOUNDING.md +203 -0
  16. package/.allhands/flows/COORDINATION.md +89 -0
  17. package/.allhands/flows/CORE.md +87 -0
  18. package/.allhands/flows/DOCUMENTATION.md +218 -0
  19. package/.allhands/flows/E2E_TEST_PLAN_BUILDING.md +140 -0
  20. package/.allhands/flows/EMERGENT_PLANNING.md +57 -0
  21. package/.allhands/flows/IDEATION_SCOPING.md +154 -0
  22. package/.allhands/flows/INITIATIVE_STEERING.md +110 -0
  23. package/.allhands/flows/JUDGE_REVIEWING.md +79 -0
  24. package/.allhands/flows/PROMPT_TASK_EXECUTION.md +68 -0
  25. package/.allhands/flows/PR_REVIEWING.md +43 -0
  26. package/.allhands/flows/SPEC_PLANNING.md +216 -0
  27. package/.allhands/flows/harness/WRITING_HARNESS_FLOWS.md +27 -0
  28. package/.allhands/flows/harness/WRITING_HARNESS_KNOWLEDGE.md +27 -0
  29. package/.allhands/flows/harness/WRITING_HARNESS_ORCHESTRATION.md +27 -0
  30. package/.allhands/flows/harness/WRITING_HARNESS_SKILLS.md +27 -0
  31. package/.allhands/flows/harness/WRITING_HARNESS_TOOLS.md +27 -0
  32. package/.allhands/flows/harness/WRITING_HARNESS_VALIDATION_TOOLING.md +27 -0
  33. package/.allhands/flows/shared/CODEBASE_UNDERSTANDING.md +72 -0
  34. package/.allhands/flows/shared/CREATE_HARNESS_SPEC.md +48 -0
  35. package/.allhands/flows/shared/CREATE_SPEC.md +41 -0
  36. package/.allhands/flows/shared/CREATE_VALIDATION_TOOLING_SPEC.md +70 -0
  37. package/.allhands/flows/shared/DOCUMENTATION_DISCOVERY.md +123 -0
  38. package/.allhands/flows/shared/DOCUMENTATION_WRITER.md +101 -0
  39. package/.allhands/flows/shared/EMERGENT_REFINEMENT_ANALYSIS.md +76 -0
  40. package/.allhands/flows/shared/EXTERNAL_TECH_GUIDANCE.md +97 -0
  41. package/.allhands/flows/shared/IDEATION_CODEBASE_GROUNDING.md +49 -0
  42. package/.allhands/flows/shared/PLAN_DEEPENING.md +152 -0
  43. package/.allhands/flows/shared/PROMPT_TASKS_CURATION.md +113 -0
  44. package/.allhands/flows/shared/PROMPT_VALIDATION_REVIEW.MD +99 -0
  45. package/.allhands/flows/shared/QUICK_PREMORTEM.md +70 -0
  46. package/.allhands/flows/shared/RESEARCH_GUIDANCE.md +38 -0
  47. package/.allhands/flows/shared/REVIEW_OPTIONS_BREAKDOWN.md +68 -0
  48. package/.allhands/flows/shared/SKILL_EXTRACTION.md +84 -0
  49. package/.allhands/flows/shared/SPEC_FLOW_ANALYSIS.md +119 -0
  50. package/.allhands/flows/shared/TDD_WORKFLOW.md +109 -0
  51. package/.allhands/flows/shared/UTILIZE_VALIDATION_TOOLING.md +84 -0
  52. package/.allhands/flows/shared/WRITING_HARNESS_FLOWS.md +11 -0
  53. package/.allhands/flows/shared/WRITING_HARNESS_MCP_TOOLS.md +84 -0
  54. package/.allhands/flows/shared/jury/ARCHITECTURE_REVIEW.md +91 -0
  55. package/.allhands/flows/shared/jury/BEST_PRACTICES_REVIEW.md +80 -0
  56. package/.allhands/flows/shared/jury/CLAIM_VERIFICATION_REVIEW.md +101 -0
  57. package/.allhands/flows/shared/jury/EXPECTATIONS_FIT_REVIEW.md +78 -0
  58. package/.allhands/flows/shared/jury/MAINTAINABILITY_REVIEW.md +110 -0
  59. package/.allhands/flows/shared/jury/PROMPTS_EXPECTATIONS_FIT.md +74 -0
  60. package/.allhands/flows/shared/jury/PROMPTS_FLOW_ANALYSIS.md +92 -0
  61. package/.allhands/flows/shared/jury/PROMPTS_YAGNI.md +78 -0
  62. package/.allhands/flows/shared/jury/PROMPT_PREMORTEM.md +125 -0
  63. package/.allhands/flows/shared/jury/SECURITY_REVIEW.md +86 -0
  64. package/.allhands/flows/shared/jury/YAGNI_REVIEW.md +82 -0
  65. package/.allhands/flows/wip/DEBUG_INVESTIGATION.md +162 -0
  66. package/.allhands/flows/wip/MEMORY_RECALL.md +62 -0
  67. package/.allhands/harness/ah +131 -0
  68. package/.allhands/harness/package-lock.json +5292 -0
  69. package/.allhands/harness/package.json +52 -0
  70. package/.allhands/harness/src/__tests__/e2e/commands.test.ts +307 -0
  71. package/.allhands/harness/src/__tests__/e2e/event-loop.test.ts +539 -0
  72. package/.allhands/harness/src/__tests__/e2e/hooks.test.ts +427 -0
  73. package/.allhands/harness/src/__tests__/e2e/new-initiative-routing.test.ts +137 -0
  74. package/.allhands/harness/src/__tests__/e2e/run-e2e.ts +109 -0
  75. package/.allhands/harness/src/__tests__/e2e/specs-type.test.ts +210 -0
  76. package/.allhands/harness/src/__tests__/e2e/validation-hooks.test.ts +669 -0
  77. package/.allhands/harness/src/__tests__/e2e/validation-path-consistency.test.ts +354 -0
  78. package/.allhands/harness/src/__tests__/e2e/validation.test.ts +528 -0
  79. package/.allhands/harness/src/__tests__/harness/assertions.ts +318 -0
  80. package/.allhands/harness/src/__tests__/harness/cli-runner.ts +359 -0
  81. package/.allhands/harness/src/__tests__/harness/fixture.ts +384 -0
  82. package/.allhands/harness/src/__tests__/harness/hook-runner.ts +411 -0
  83. package/.allhands/harness/src/__tests__/harness/index.ts +122 -0
  84. package/.allhands/harness/src/cli.ts +36 -0
  85. package/.allhands/harness/src/commands/complexity.ts +177 -0
  86. package/.allhands/harness/src/commands/context7.ts +202 -0
  87. package/.allhands/harness/src/commands/docs.ts +557 -0
  88. package/.allhands/harness/src/commands/hooks.ts +24 -0
  89. package/.allhands/harness/src/commands/index.ts +51 -0
  90. package/.allhands/harness/src/commands/knowledge.ts +382 -0
  91. package/.allhands/harness/src/commands/memories.ts +302 -0
  92. package/.allhands/harness/src/commands/notify.ts +61 -0
  93. package/.allhands/harness/src/commands/oracle.ts +158 -0
  94. package/.allhands/harness/src/commands/perplexity.ts +220 -0
  95. package/.allhands/harness/src/commands/planning.ts +245 -0
  96. package/.allhands/harness/src/commands/schema.ts +73 -0
  97. package/.allhands/harness/src/commands/skills.ts +128 -0
  98. package/.allhands/harness/src/commands/solutions.ts +353 -0
  99. package/.allhands/harness/src/commands/spawn.ts +158 -0
  100. package/.allhands/harness/src/commands/specs.ts +532 -0
  101. package/.allhands/harness/src/commands/tavily.ts +226 -0
  102. package/.allhands/harness/src/commands/tools.ts +579 -0
  103. package/.allhands/harness/src/commands/trace.ts +327 -0
  104. package/.allhands/harness/src/commands/tui.ts +960 -0
  105. package/.allhands/harness/src/commands/validate.ts +143 -0
  106. package/.allhands/harness/src/commands/validation-tools.ts +108 -0
  107. package/.allhands/harness/src/hooks/context.ts +1442 -0
  108. package/.allhands/harness/src/hooks/enforcement.ts +170 -0
  109. package/.allhands/harness/src/hooks/index.ts +54 -0
  110. package/.allhands/harness/src/hooks/lifecycle.ts +229 -0
  111. package/.allhands/harness/src/hooks/notification.ts +104 -0
  112. package/.allhands/harness/src/hooks/observability.ts +551 -0
  113. package/.allhands/harness/src/hooks/session.ts +88 -0
  114. package/.allhands/harness/src/hooks/shared.ts +815 -0
  115. package/.allhands/harness/src/hooks/transcript-parser.ts +208 -0
  116. package/.allhands/harness/src/hooks/validation.ts +617 -0
  117. package/.allhands/harness/src/lib/__tests__/ctags.test.ts +244 -0
  118. package/.allhands/harness/src/lib/__tests__/docs-validation.test.ts +344 -0
  119. package/.allhands/harness/src/lib/__tests__/mcp-runtime.test.ts +190 -0
  120. package/.allhands/harness/src/lib/__tests__/schema.test.ts +861 -0
  121. package/.allhands/harness/src/lib/base-command.ts +198 -0
  122. package/.allhands/harness/src/lib/cli-daemon.ts +343 -0
  123. package/.allhands/harness/src/lib/compaction.ts +313 -0
  124. package/.allhands/harness/src/lib/ctags.ts +497 -0
  125. package/.allhands/harness/src/lib/docs-validation.ts +907 -0
  126. package/.allhands/harness/src/lib/event-loop.ts +662 -0
  127. package/.allhands/harness/src/lib/flows.ts +155 -0
  128. package/.allhands/harness/src/lib/git.ts +276 -0
  129. package/.allhands/harness/src/lib/knowledge-worker.ts +72 -0
  130. package/.allhands/harness/src/lib/knowledge.ts +810 -0
  131. package/.allhands/harness/src/lib/llm.ts +255 -0
  132. package/.allhands/harness/src/lib/mcp-client.ts +432 -0
  133. package/.allhands/harness/src/lib/mcp-daemon.ts +486 -0
  134. package/.allhands/harness/src/lib/mcp-runtime.ts +418 -0
  135. package/.allhands/harness/src/lib/notification.ts +115 -0
  136. package/.allhands/harness/src/lib/opencode/index.ts +70 -0
  137. package/.allhands/harness/src/lib/opencode/profiles.ts +300 -0
  138. package/.allhands/harness/src/lib/opencode/prompts/codesearch.md +98 -0
  139. package/.allhands/harness/src/lib/opencode/prompts/knowledge-aggregator.md +67 -0
  140. package/.allhands/harness/src/lib/opencode/runner.ts +281 -0
  141. package/.allhands/harness/src/lib/oracle.ts +926 -0
  142. package/.allhands/harness/src/lib/planning-utils.ts +150 -0
  143. package/.allhands/harness/src/lib/planning.ts +605 -0
  144. package/.allhands/harness/src/lib/pr-review.ts +225 -0
  145. package/.allhands/harness/src/lib/prompts.ts +522 -0
  146. package/.allhands/harness/src/lib/schema.ts +418 -0
  147. package/.allhands/harness/src/lib/schemas/agent-profile.ts +141 -0
  148. package/.allhands/harness/src/lib/schemas/template-vars.ts +138 -0
  149. package/.allhands/harness/src/lib/session.ts +164 -0
  150. package/.allhands/harness/src/lib/specs.ts +348 -0
  151. package/.allhands/harness/src/lib/tldr.ts +829 -0
  152. package/.allhands/harness/src/lib/tmux.ts +1051 -0
  153. package/.allhands/harness/src/lib/trace-store.ts +714 -0
  154. package/.allhands/harness/src/mcp/__tests__/index.test.ts +46 -0
  155. package/.allhands/harness/src/mcp/_template.ts +47 -0
  156. package/.allhands/harness/src/mcp/filesystem.ts +33 -0
  157. package/.allhands/harness/src/mcp/index.ts +69 -0
  158. package/.allhands/harness/src/mcp/playwright.ts +34 -0
  159. package/.allhands/harness/src/mcp/xcodebuild.ts +29 -0
  160. package/.allhands/harness/src/schemas/docs.schema.json +44 -0
  161. package/.allhands/harness/src/schemas/settings.schema.json +214 -0
  162. package/.allhands/harness/src/tui/actions.ts +227 -0
  163. package/.allhands/harness/src/tui/file-viewer-modal.ts +270 -0
  164. package/.allhands/harness/src/tui/index.ts +1574 -0
  165. package/.allhands/harness/src/tui/modal.ts +232 -0
  166. package/.allhands/harness/src/tui/prompts-pane.ts +186 -0
  167. package/.allhands/harness/src/tui/status-pane.ts +434 -0
  168. package/.allhands/harness/tsconfig.json +22 -0
  169. package/.allhands/harness/vitest.config.ts +13 -0
  170. package/.allhands/pillars.md +33 -0
  171. package/.allhands/principles.md +88 -0
  172. package/.allhands/schemas/alignment.yaml +51 -0
  173. package/.allhands/schemas/documentation.yaml +10 -0
  174. package/.allhands/schemas/prompt.yaml +92 -0
  175. package/.allhands/schemas/skill.yaml +34 -0
  176. package/.allhands/schemas/solution.yaml +131 -0
  177. package/.allhands/schemas/spec.yaml +67 -0
  178. package/.allhands/schemas/validation-suite.yaml +49 -0
  179. package/.allhands/schemas/workflow.yaml +51 -0
  180. package/.allhands/settings.json +57 -0
  181. package/.allhands/skills/claude-code-patterns/SKILL.md +60 -0
  182. package/.allhands/skills/claude-code-patterns/docs/context-hygiene.md +19 -0
  183. package/.allhands/skills/harness-maintenance/SKILL.md +449 -0
  184. package/.allhands/skills/harness-maintenance/references/core-architecture.md +187 -0
  185. package/.allhands/skills/harness-maintenance/references/harness-skills.md +87 -0
  186. package/.allhands/skills/harness-maintenance/references/knowledge-compounding.md +78 -0
  187. package/.allhands/skills/harness-maintenance/references/tools-commands-mcp-hooks.md +115 -0
  188. package/.allhands/skills/harness-maintenance/references/validation-tooling.md +77 -0
  189. package/.allhands/skills/harness-maintenance/references/writing-flows.md +84 -0
  190. package/.allhands/validation/browser-automation.md +109 -0
  191. package/.allhands/validation/xcode-automation.md +195 -0
  192. package/.allhands/workflows/documentation.md +86 -0
  193. package/.allhands/workflows/investigation.md +81 -0
  194. package/.allhands/workflows/milestone.md +91 -0
  195. package/.allhands/workflows/optimization.md +85 -0
  196. package/.allhands/workflows/refactor.md +99 -0
  197. package/.allhands/workflows/triage.md +81 -0
  198. package/.claude/README.md +1 -0
  199. package/.claude/agents/explorer.md +10 -0
  200. package/.claude/agents/researcher.md +11 -0
  201. package/.claude/agents/task-runner.md +8 -0
  202. package/.claude/settings.json +231 -0
  203. package/.env.ai.example +7 -0
  204. package/.github/workflows/npm-publish.yml +69 -0
  205. package/.internal.json +45 -0
  206. package/.tldr/config.json +11 -0
  207. package/.tldrignore +90 -0
  208. package/CLAUDE.md +6 -0
  209. package/README.md +98 -0
  210. package/bin/sync-cli.js +7552 -0
  211. package/concerns.md +7 -0
  212. package/docs/README.md +41 -0
  213. package/docs/agents/README.md +24 -0
  214. package/docs/agents/agent-configuration-system.md +86 -0
  215. package/docs/agents/execution-agents.md +50 -0
  216. package/docs/agents/knowledge-agents.md +61 -0
  217. package/docs/agents/orchestration-agent.md +57 -0
  218. package/docs/agents/planning-agents.md +84 -0
  219. package/docs/agents/quality-review-agents.md +67 -0
  220. package/docs/agents/workflow-agent-orchestration.md +69 -0
  221. package/docs/flows/README.md +44 -0
  222. package/docs/flows/compounding.md +126 -0
  223. package/docs/flows/coordination.md +72 -0
  224. package/docs/flows/core-harness-integration.md +63 -0
  225. package/docs/flows/documentation-orchestration.md +98 -0
  226. package/docs/flows/e2e-test-plan-building.md +83 -0
  227. package/docs/flows/emergent-refinement.md +104 -0
  228. package/docs/flows/flow-authoring-and-mcp-tools.md +89 -0
  229. package/docs/flows/judge-reviewing.md +112 -0
  230. package/docs/flows/plan-deepening-and-research.md +107 -0
  231. package/docs/flows/plan-review-jury.md +114 -0
  232. package/docs/flows/pr-reviewing.md +54 -0
  233. package/docs/flows/prompt-task-execution.md +119 -0
  234. package/docs/flows/spec-planning.md +162 -0
  235. package/docs/flows/type-specific-scoping-flows.md +49 -0
  236. package/docs/flows/validation-and-skills-integration.md +145 -0
  237. package/docs/flows/wip/wip-flows.md +102 -0
  238. package/docs/harness/README.md +23 -0
  239. package/docs/harness/agent-profiles.md +84 -0
  240. package/docs/harness/cli/README.md +24 -0
  241. package/docs/harness/cli/cli-entry-and-command-discovery.md +91 -0
  242. package/docs/harness/cli/docs-command.md +87 -0
  243. package/docs/harness/cli/knowledge-command.md +91 -0
  244. package/docs/harness/cli/minor-cli-commands.md +65 -0
  245. package/docs/harness/cli/oracle-command.md +113 -0
  246. package/docs/harness/cli/planning-command.md +95 -0
  247. package/docs/harness/cli/schema-and-validation-commands.md +154 -0
  248. package/docs/harness/cli/search-commands.md +97 -0
  249. package/docs/harness/cli/spawn-command.md +136 -0
  250. package/docs/harness/cli/specs-command.md +102 -0
  251. package/docs/harness/cli/tools-command.md +122 -0
  252. package/docs/harness/cli/trace-command.md +122 -0
  253. package/docs/harness/cli-daemon.md +92 -0
  254. package/docs/harness/event-loop.md +184 -0
  255. package/docs/harness/hooks/README.md +15 -0
  256. package/docs/harness/hooks/context-hooks.md +96 -0
  257. package/docs/harness/hooks/lifecycle-and-observability-hooks.md +135 -0
  258. package/docs/harness/hooks/validation-hooks.md +97 -0
  259. package/docs/harness/test-harness.md +149 -0
  260. package/docs/harness/tui.md +176 -0
  261. package/docs/memories.md +20 -0
  262. package/docs/solutions/agentic-issues/premature-agent-deletion-tui-action-dependency-20260130.md +49 -0
  263. package/docs/solutions/agentic-issues/ref-anchor-scope-mismatch-skill-references-20260131.md +55 -0
  264. package/docs/solutions/agentic-issues/tautological-tests-routing-20260131.md +52 -0
  265. package/docs/solutions/integration_issue/blocktool-output-format-mismatch-hook-runner-20260130.md +52 -0
  266. package/docs/solutions/integration_issue/dual-validation-path-divergence-schema-20260130.md +66 -0
  267. package/docs/solutions/security-issues/unsanitized-domain-path-join-20260131.md +52 -0
  268. package/docs/solutions/test-failures/event-loop-mock-ordering-checkAgentWindows-20260130.md +63 -0
  269. package/docs/sync-cli/README.md +19 -0
  270. package/docs/sync-cli/cli-entrypoint-and-commands.md +39 -0
  271. package/docs/sync-cli/commands/README.md +11 -0
  272. package/docs/sync-cli/commands/pull-manifest-command.md +36 -0
  273. package/docs/sync-cli/commands/push-command.md +84 -0
  274. package/docs/sync-cli/commands/sync-command.md +71 -0
  275. package/docs/sync-cli/systems/README.md +14 -0
  276. package/docs/sync-cli/systems/git-and-github-integration.md +49 -0
  277. package/docs/sync-cli/systems/interactive-ui.md +43 -0
  278. package/docs/sync-cli/systems/manifest-and-distribution.md +51 -0
  279. package/docs/sync-cli/systems/path-resolution.md +42 -0
  280. package/package.json +46 -0
  281. package/scripts/install-shim.sh +40 -0
  282. package/scripts/pre-pack.sh +25 -0
  283. package/specs/harness-maintenance-skill.spec.md +138 -0
  284. package/specs/roadmap/git-spec-lifecycle-management.spec.md +113 -0
  285. package/specs/sync-init-flag.spec.md +117 -0
  286. package/specs/unified-workflow-orchestration.spec.md +250 -0
  287. package/specs/validation-tooling-practice.spec.md +98 -0
  288. package/specs/workflow-domain-configuration.spec.md +265 -0
  289. package/src/commands/pull-manifest.ts +31 -0
  290. package/src/commands/push.ts +344 -0
  291. package/src/commands/sync.ts +289 -0
  292. package/src/lib/constants.ts +10 -0
  293. package/src/lib/dotfiles.ts +36 -0
  294. package/src/lib/fs-utils.ts +18 -0
  295. package/src/lib/gh.ts +40 -0
  296. package/src/lib/git.ts +63 -0
  297. package/src/lib/gitignore.ts +167 -0
  298. package/src/lib/manifest.ts +121 -0
  299. package/src/lib/marker-sync.ts +39 -0
  300. package/src/lib/paths.ts +38 -0
  301. package/src/lib/target-lines.ts +66 -0
  302. package/src/lib/ui.ts +78 -0
  303. package/src/sync-cli.ts +120 -0
  304. package/target-lines.json +23 -0
  305. package/tsconfig.json +20 -0
@@ -0,0 +1,449 @@
1
+ ---
2
+ name: harness-maintenance
3
+ description: Domain expertise for maintaining and extending the All Hands harness. Use when working on flows, hooks, commands, agents, schemas, or MCP integrations.
4
+ version: 2.0.0
5
+ globs:
6
+ - ".allhands/flows/**/*.md"
7
+ - ".allhands/agents/*.yaml"
8
+ - ".allhands/schemas/*.yaml"
9
+ - ".allhands/skills/**/*.md"
10
+ - ".allhands/validation/*.md"
11
+ - ".allhands/workflows/**/*.md"
12
+ - ".allhands/harness/src/**/*.ts"
13
+ - ".allhands/harness/src/**/*.json"
14
+ ---
15
+
16
+ # Harness Maintenance
17
+
18
+ <goal>
19
+ Route maintainers to domain-specific harness knowledge. Per **Context is Precious**, agents load only the reference matching their scenario — not the full architecture.
20
+ </goal>
21
+
22
+ <constraints>
23
+ - MUST read `.allhands/principles.md` before any harness modification
24
+ - MUST cite First Principles by name when adding features or changing behavior
25
+ - MUST update the relevant reference doc when making structural changes to the harness
26
+ - MUST validate changes with `ah validate agents` after profile modifications
27
+ - NEVER add complexity without clear first principle justification
28
+ </constraints>
29
+
30
+ ## Start Here
31
+
32
+ Read `.allhands/principles.md` first — it is the single entry point covering all first principles and core philosophy pillars. Every harness change should be motivated by a named principle.
33
+
34
+ ## Reference Routing
35
+
36
+ Use **Scenario** to find the right reference for your task. Use **Trigger** to find which reference to update after a change.
37
+
38
+ ```
39
+ .allhands/
40
+ ├── settings.json # Repository-specific settings (format, validation)
41
+ ├── flows/ # Agent instructions (progressive disclosure)
42
+ ├── agents/ # Agent profiles (YAML spawn configs)
43
+ ├── workflows/ # Workflow domain configs (per-domain knowledge for shared flows)
44
+ ├── skills/ # Domain expertise (patterns, best practices)
45
+ ├── validation/ # Acceptance criteria tooling
46
+ ├── schemas/ # Agent-facing YAML frontmatter schemas
47
+ └── harness/ # CLI implementation
48
+ ├── src/commands/ # Auto-discovered CLI commands
49
+ ├── src/hooks/ # Claude Code lifecycle hooks
50
+ ├── src/lib/ # Core utilities + internal Zod schemas
51
+ ├── src/schemas/ # JSON schemas for settings files
52
+ ├── src/tui/ # Terminal UI implementation
53
+ └── src/platforms/ # Claude Code settings.json
54
+ ```
55
+
56
+ ## Related Skills
57
+
58
+ The `harness-maintenance` and `claude-code-patterns` skills have overlapping globs on `.allhands/` files. When both match:
59
+
60
+ - **harness-maintenance** provides architectural knowledge, maintenance guidance, and routing to domain-specific references — the "why" and "when" of harness changes
61
+ - **claude-code-patterns** provides Claude Code native feature docs, implementation patterns, and API reference — the "how" of building with Claude Code primitives
62
+ - For structural changes to `.allhands/` content files (flows, schemas, skills, validation), **harness-maintenance** is primary
63
+ - For TypeScript implementation in `harness/src/` or Claude Code configs in `.claude/`, **claude-code-patterns** is primary
64
+ - When in doubt, read harness-maintenance first for architectural context, then claude-code-patterns for implementation details
65
+
66
+ ## Cross-Cutting Patterns
67
+
68
+ ### Key Design Patterns
69
+ - **Graceful Degradation**: Every optional dependency (TLDR, pyright, Greptile) has fallback behavior. Never fail the primary operation.
70
+ - **Semantic Validation**: Zod schemas catch config mistakes at spawn time, not runtime. Fail fast with helpful messages.
71
+ - **In-Memory State**: Registry patterns (spawned agents, search contexts) keep TUI in sync without polling.
72
+ - **Motivation-Driven Documentation**: Per **Frontier Models are Capable**, teach agents HOW TO THINK about using a tool — not command catalogs. Commands are discoverable via `--help`; documentation value is in motivations and thinking models.
73
+ - **Token Efficiency**: Read enforcer + context injection + TLDR layers save ~95% on large files.
74
+ - **Iterative Refinement**: Compaction summaries make incomplete work resumable. Per **Prompt Files as Units of Work**, same prompt can be re-run with accumulated learnings.
75
+
76
+ Format config: `enabled`, `command` (default), `patterns` (file-specific overrides).
77
+
78
+ ---
79
+
80
+ ## TUI Lifecycle
81
+
82
+ Per **Context is Precious** and **Prompt Files as Units of Work**, the TUI orchestrates agents with bounded context.
83
+
84
+ ### Structure
85
+ - **Actions Pane (left)**: Agent spawners, toggles (loop, parallel), utilities
86
+ - **Prompts Pane (center)**: Work-in-progress by status (pending, in_progress, done)
87
+ - **Status Pane (right)**: Active agent grid, milestone info, activity log
88
+
89
+ ### Lifecycle
90
+ 1. **Start**: Build semantic index if missing, load state from `.planning/{branch}/status.yaml`
91
+ 2. **Loop**: Render panes, handle input, dispatch actions, poll EventLoop (5s interval)
92
+ 3. **Stop**: Kill spawned agent windows, restore terminal
93
+
94
+ ### EventLoop Daemon
95
+ - Polls Greptile PR feedback, git branch changes, agent window status
96
+ - Runs prompt picker algorithm when loop enabled
97
+ - Non-blocking callbacks notify TUI of state changes
98
+
99
+ ### Dynamic Actions
100
+ Per **Frontier Models are Capable**, actions enable/disable based on state:
101
+ - Planner only enabled if milestone set
102
+ - E2E builder only visible after first prompt done
103
+ - PR action label changes based on review state
104
+
105
+ ---
106
+
107
+ ## Hooks System
108
+
109
+ Per **Context is Precious** and **Agentic Validation Tooling**, hooks bridge Claude Code and harness.
110
+
111
+ ### Categories
112
+
113
+ | Category | Purpose | Key Hooks |
114
+ |----------|---------|-----------|
115
+ | **Context** | Token-efficient context injection | `tldr-inject`, `read-enforcer`, `edit-inject`, `signature` |
116
+ | **Enforcement** | Guide toward appropriate tools | `github-url`, `research-fetch`, `research-search` |
117
+ | **Validation** | Quality gates on edits | `diagnostics`, `schema`, `format` |
118
+ | **Lifecycle** | Handle agent events | `agent-stop`, `agent-compact` |
119
+ | **Notification** | Desktop alerts | `elicitation`, `stop`, `compact` |
120
+ | **Session** | Startup tasks | `tldr-warm` |
121
+
122
+ ### Hook Registration
123
+ - Auto-discovered from `src/hooks/` modules
124
+ - Each exports `register(parent: Command)` function
125
+ - Configured in `.claude/settings.json` as matchers
126
+
127
+ ### Design Rules
128
+ - Graceful degradation: hooks allow tool execution even if analysis fails
129
+ - Enforcement blocks include helpful redirect messages
130
+ - All optional dependencies (TLDR, pyright) have fallback behavior
131
+
132
+ ### Compaction Hook (Critical)
133
+ Per **Knowledge Compounding**, `agent-compact` preserves work:
134
+ 1. Parse agent transcript for session summary
135
+ 2. Get git status (file changes)
136
+ 3. Call oracle to generate summary with decision (CONTINUE/RESTART/BLOCKED)
137
+ 4. Append summary to prompt file (allows re-run with learnings)
138
+ 5. Kill agent window
139
+
140
+ ---
141
+
142
+ ## Schema System
143
+
144
+ ### Agent-Facing Schemas (`schemas/*.yaml`)
145
+ Exposed via `ah schema <type>`. Define frontmatter for harness-managed files:
146
+ - `prompt.yaml` - Prompt file structure
147
+ - `alignment.yaml` - Alignment doc structure
148
+ - `spec.yaml` - Spec structure
149
+ - `skill.yaml` - Skill manifest
150
+ - `validation-suite.yaml` - Validation tooling
151
+ - `solution.yaml` - Solution documentation (`docs/solutions/`)
152
+ - `documentation.yaml` - General documentation (`docs/`)
153
+
154
+ ### Internal Schemas (`harness/src/lib/schemas/*.ts`)
155
+ Zod schemas for harness configuration. NOT exposed to agents:
156
+
157
+ **Template Variables Registry** (`template-vars.ts`)
158
+ - Single source of truth for valid template variables
159
+ - Each has Zod schema + description
160
+ - Variables: `SPEC_PATH`, `ALIGNMENT_PATH`, `MILESTONE_NAME`, `PROMPT_NUMBER`, `BRANCH`, `HYPOTHESIS_DOMAINS`, `SPEC_TYPE`, etc.
161
+
162
+ **Agent Profile Schema** (`agent-profile.ts`)
163
+ - Raw schema (snake_case from YAML) + normalized interface (camelCase)
164
+ - Semantic validation: template vars in `message_template` must match `template_vars` list
165
+ - Pattern validation: `PROMPT_NUMBER` must match `^\d{2}$`
166
+
167
+
168
+ ### Why Zod for Internal
169
+ - Type safety with compile-time checks
170
+ - Runtime validation catches misconfigurations at spawn time
171
+ - Pattern validation enforces format constraints
172
+
173
+ ---
174
+
175
+ ## Agent Profiles
176
+
177
+ Per **Frontier Models are Capable**, profiles define spawn configuration, not behavior.
178
+
179
+ ### Profile Structure (`agents/*.yaml`)
180
+ ```yaml
181
+ name: executor # Agent identifier
182
+ flow: PROMPT_TASK_EXECUTION.md # Flow file in flows/
183
+ prompt_scoped: true # Multiple instances (one per prompt)
184
+ tui_action: executor # TUI button trigger
185
+ tui_label: Executor # Display label
186
+ tui_requires_spec: true
187
+ non_coding: false # Can write code
188
+ message_template: | # Preamble injected before flow
189
+ Your prompt file: ${PROMPT_PATH}
190
+ Alignment doc: ${ALIGNMENT_PATH}
191
+ template_vars: # Required context variables
192
+ - PROMPT_PATH
193
+ - ALIGNMENT_PATH
194
+ ```
195
+
196
+ ### Key Fields
197
+ - **prompt_scoped**: If true, runs multiple instances (executor per prompt)
198
+ - **non_coding**: Hint for agent type (coordinator, judge are true)
199
+ - **message_template**: Uses `${VAR}` interpolation
200
+
201
+ ### Environment Variables Passed
202
+ `AGENT_ID`, `AGENT_TYPE`, `PROMPT_NUMBER`, `MILESTONE_NAME`, `BRANCH`
203
+
204
+ ---
205
+
206
+ ## Hypothesis Domains
207
+
208
+ Per **Quality Engineering**, hypothesis domains define the available work areas for the emergent planner.
209
+
210
+ ### Configuration
211
+
212
+ Defined in `settings.json` under `emergent.hypothesisDomains` (the key name describes the work type, not an agent):
213
+ ```json
214
+ {
215
+ "emergent": {
216
+ "hypothesisDomains": ["testing", "stability", "performance", "feature", "ux", "integration"]
217
+ }
218
+ }
219
+ ```
220
+
221
+ Per **Frontier Models are Capable**, agents understand domain meanings from names alone—no descriptions needed.
222
+
223
+ ### Integration with Agent Spawning
224
+ 1. `buildTemplateContext()` loads domains from `settings.json`
225
+ 2. Domains formatted as `HYPOTHESIS_DOMAINS` template variable
226
+ 3. Emergent planner receives available domains in spawn message
227
+ 4. Planner selects domain and creates `type: emergent` prompts for executors
228
+
229
+ ### Diversification Rule
230
+ Per **Knowledge Compounding**, the emergent planner tracks work types in alignment doc summaries. If prior prompts cluster on one domain, subsequent prompts should diversify by selecting an underrepresented domain.
231
+
232
+ ---
233
+
234
+ ## Workflow Domain Configuration
235
+
236
+ Per **Frontier Models are Capable**, workflow domain configs centralize domain knowledge for consumption by multiple flows rather than duplicating it per-flow.
237
+
238
+ ### Architecture
239
+ - `.allhands/workflows/*.md` — one config per domain (`milestone`, `investigation`, `optimization`, `refactor`, `documentation`, `triage`)
240
+ - Structured **frontmatter** (`planning_depth`, `jury_required`, `max_tangential_hypotheses`, `required_ideation_questions`) provides programmatic flags for flow calibration
241
+ - **Markdown body** contains domain-specific context (vocabulary, gap signals, output sections, planning strategy) — not restatement of flow instructions. Frontmatter flags drive flow bifurcation; body provides domain knowledge for agent discretion
242
+ - Schema validated via `ah schema workflow`
243
+
244
+ ### Template Variable Abstraction
245
+ - `WORKFLOW_DOMAIN_PATH` is the single abstraction boundary — agents receive the resolved path, never raw domain names
246
+ - Resolved in `buildTemplateContext()` from the spec's `initial_workflow_domain` frontmatter field (default: `milestone`)
247
+ - All domain-consuming agents (ideation, planner, emergent, initiative-steering) access configs exclusively through this variable
248
+
249
+ ### Flow Unification
250
+ - Unified `IDEATION_SCOPING.md` replaced 6 separate per-type scoping flows (`IDEATION_SESSION.md`, `INVESTIGATION_SCOPING.md`, etc.)
251
+ - `planning_depth` field (`deep` vs `focused`) drives flow bifurcation — not spec type checks
252
+ - `stage` field on `status.yaml` gates execution (`executing`) and pauses during initiative steering (`steering`)
253
+
254
+ ### Coordinator vs Initiative Steering
255
+
256
+ Both are TUI actions but serve fundamentally different purposes:
257
+
258
+ | Dimension | Coordinator | Initiative Steering |
259
+ |-----------|------------|-------------------|
260
+ | **Scope** | Single-prompt interventions (quick patches, triage, prompt surgery) | Multi-prompt initiative-level replanning |
261
+ | **Trigger** | Reactive — something broke or needs a tweak | Strategic — scope change, blocking issue, quality pivot |
262
+ | **Domain awareness** | Not domain-config-driven | Consumes workflow domain config; can steer with a different domain than the spec's original |
263
+ | **Execution impact** | Does not pause the event loop | Pauses prompt spawning (`stage: 'steering'`) during the session |
264
+ | **Goal changes** | Does not change initiative goals | Can change initiative goals (resets `core_consolidation` to `pending`) |
265
+
266
+ Per **Context is Precious**, the coordinator is lightweight and conversational; initiative steering is heavyweight with research subtasks, a domain-driven interview, and structured alignment doc amendments.
267
+
268
+ ---
269
+
270
+ ## Platform Integration
271
+
272
+ ### Settings Configuration (`.claude/settings.json`)
273
+ Connection point between harness and Claude Code:
274
+
275
+ ```json
276
+ "PreToolUse": [
277
+ {
278
+ "matcher": "Read",
279
+ "hooks": [{
280
+ "type": "command",
281
+ "command": "ah hooks context read-enforcer",
282
+ "timeout": 20
283
+ }]
284
+ }
285
+ ]
286
+ ```
287
+
288
+ ### Hook Events
289
+ - **PreToolUse**: Context injection, enforcement, blocking
290
+ - **PostToolUse**: Diagnostics, validation
291
+ - **SessionStart**: TLDR daemon warm-up
292
+ - **Stop/SessionEnd**: Notifications, cleanup
293
+ - **PreCompact**: Compaction handling
294
+
295
+ ### Permissions
296
+ ```json
297
+ "deny": ["Task(claude-code-guide)", "Task(Explore)", "Task(Plan)"]
298
+ ```
299
+
300
+ ---
301
+
302
+ ## Commands Architecture
303
+
304
+ ### Structure
305
+ - Entry point: `src/cli.ts` (default action launches TUI)
306
+ - Auto-discovers commands from `src/commands/`
307
+ - Each module exports `register(parent: Command)` function
308
+
309
+ ### Core Commands
310
+
311
+ | Command | Domain | First Principle |
312
+ |---------|--------|-----------------|
313
+ | `ah knowledge` | Semantic search | **Context is Precious** |
314
+ | `ah schema` | File structure | **Frontier Models are Capable** |
315
+ | `ah validate` | Quality gates | **Agentic Validation Tooling** |
316
+ | `ah oracle` | LLM inference | **Context is Precious** (saves caller context) |
317
+ | `ah spawn` | Sub-agents | **Context is Precious** (isolated work) |
318
+ | `ah tools` | MCP integration | **Agentic Validation Tooling** |
319
+
320
+ ### Command Design Rules
321
+ - Use `--json` flag for machine-readable output
322
+ - Graceful degradation when optional deps missing
323
+ - Help text explains first principle motivation
324
+
325
+ ---
326
+
327
+ ## Progressive Disclosure
328
+
329
+ Per **Context is Precious**, agents only see what they need when they need it.
330
+
331
+ ### Flow Organization
332
+ - `flows/` root: Agent default flows, disclosed immediately on spawn
333
+ - `flows/shared/`: Progressively disclosed via references in parent flows
334
+ - `flows/shared/jury/`: Specialized review sub-agents
335
+
336
+ ### Flow Referencing
337
+ ```markdown
338
+ - Read `.allhands/flows/shared/SKILL_EXTRACTION.md` and follow its instructions
339
+ ```
340
+
341
+ ### Inputs/Outputs Pattern
342
+ Sub-flows use `<inputs>` and `<outputs>` tags for execution-agnostic subtasks.
343
+
344
+ ---
345
+
346
+ ## Extension Points
347
+
348
+ ### Adding New Hooks
349
+ 1. Create file in `src/hooks/`
350
+ 2. Export `register(parent: Command)` function
351
+ 3. Add matcher to `settings.json`
352
+
353
+ ### Adding New Agents
354
+ 1. Create YAML profile in `agents/`
355
+ 2. Create flow file in `flows/`
356
+ 3. Run `ah validate agents`
357
+
358
+ ### Deleting Agent Profiles
359
+ 1. Check the profile's `tui_action` field value
360
+ 2. Search other profiles for the same `tui_action` value — if multiple profiles share a `tui_action`, they are co-dependencies (e.g., `compounder.yaml` and `documentor.yaml` both have `tui_action: compound`)
361
+ 3. Verify the TUI action handler does not expect multiple agents for that action
362
+ 4. `ah validate agents` and `npx tsc --noEmit` will NOT catch cross-profile `tui_action` dependency breaks — YAML files are outside the TypeScript dependency graph and agent validation is per-profile
363
+
364
+ ### Updating Hypothesis Domains
365
+ 1. Edit available domains in `settings.json` under `emergent.hypothesisDomains`
366
+ 2. Domains are passed to emergent planner via `HYPOTHESIS_DOMAINS` template variable
367
+
368
+ ### Adding New Template Variables
369
+ 1. Add to `TemplateVars` registry in `src/lib/schemas/template-vars.ts`
370
+ 2. Include Zod schema and description
371
+ 3. Wire the variable in `buildTemplateContext()` in [ref:src/lib/tmux.ts:buildTemplateContext] — registration without wiring passes `ah validate agents` but produces empty template values at runtime
372
+
373
+ ### Adding New Schemas
374
+ 1. Create YAML in `schemas/` for agent-facing
375
+ 2. Create Zod schema in `src/lib/schemas/` for internal
376
+
377
+ ### Adding New Commands
378
+ 1. Create file in `src/commands/`
379
+ 2. Export `register(parent: Command)` function
380
+ 3. Document in `README.md`
381
+
382
+ ---
383
+
384
+ ## Key Design Patterns
385
+
386
+ ### Graceful Degradation
387
+ Every optional dependency (TLDR, pyright, Greptile) has fallback behavior. Never fail the primary operation.
388
+
389
+ ### Semantic Validation
390
+ Zod schemas catch config mistakes at spawn time, not runtime. Fail fast with helpful messages.
391
+
392
+ ### In-Memory State
393
+ Registry patterns (spawned agents, search contexts) keep TUI in sync without polling.
394
+
395
+ ### Motivation-Driven Documentation
396
+ Per **Frontier Models are Capable**, harness documentation (validation suites, skills, flows) should teach agents HOW TO THINK about using a tool, not replicate command references. Commands are discoverable via `--help`; documentation value is in motivations, exploration patterns, and thinking models. Avoid prescriptive command catalogs — describe WHY an agent would reach for a tool, and let the model deduce the HOW.
397
+
398
+ ### Token Efficiency
399
+ Read enforcer + context injection + TLDR layers save ~95% on large files.
400
+
401
+ ### Iterative Refinement
402
+ Compaction summaries make incomplete work resumable. Per **Prompt Files as Units of Work**, same prompt can be re-run with accumulated learnings.
403
+
404
+ ### Workflow Constraints
405
+ Dynamic action items prevent invalid operations. Can't run planner without milestone.
406
+
407
+ ---
408
+
409
+ ## Best Practices
410
+
411
+ ### Schema and TypeScript Synchronization
412
+
413
+ Per **Agentic Validation Tooling**, agent-facing YAML schemas and their TypeScript interfaces must stay in sync:
414
+ - `spec.yaml` fields → `SpecFrontmatter` interface in `lib/specs.ts`
415
+ - `alignment.yaml` fields → relevant TypeScript types in `lib/planning.ts`
416
+ - `workflow.yaml` fields → consumed via `parseYaml` in flow-consuming code
417
+
418
+ When adding a new field to any schema YAML, the corresponding TypeScript interface **must** also be updated. Failure to do so causes `parseFrontmatter()` to silently discard unrecognized fields, leading agents to resort to fragile regex-based workarounds.
419
+
420
+ ### Frontmatter Parsing
421
+
422
+ Per **Knowledge Compounding**, agents MUST use `parseFrontmatter()` from `lib/specs.ts` or `parseYaml()` from the `yaml` library for frontmatter field extraction. Raw regex for individual frontmatter fields is prohibited — it does not handle YAML quoting, comments, or multi-line values, and creates duplication when multiple call sites need the same field.
423
+
424
+ ### Template Variable Overrides (`contextOverrides`)
425
+
426
+ Per **Frontier Models are Capable**, `spawnAgentsForAction()` in `tui.ts` accepts an optional `contextOverrides` parameter — a `Record<string, string>` applied via `Object.assign` after `buildTemplateContext()`. Override keys should be known template variable names from the `TemplateVars` registry in `template-vars.ts`.
427
+
428
+ This pattern is used for initiative steering domain selection, where the engineer picks a different workflow domain than the spec's `initial_workflow_domain`. The flow:
429
+ 1. TUI modal presents domain choices (pre-selects spec's current domain)
430
+ 2. User selection produces `{ WORKFLOW_DOMAIN_PATH: resolvedPath }`
431
+ 3. Override replaces the default value from `buildTemplateContext()`
432
+ 4. Spawned agent receives the overridden context
433
+
434
+ ---
435
+
436
+ ## Maintainer Checklist
437
+
438
+ When modifying the harness:
439
+ - [ ] Read `principles.md` first
440
+ - [ ] Identify which First Principle motivates the change
441
+ - [ ] Check for graceful degradation on optional dependencies
442
+ - [ ] Add validation for new configuration
443
+ - [ ] Update relevant reference doc if structural changes made
444
+ - [ ] Run `ah validate agents` after profile changes
445
+ - [ ] Test hook behavior with Claude Code runner
446
+ - [ ] Verify routing table rows match reference files in `references/`
447
+ - [ ] Verify each routing table entry has a corresponding thin flow in `flows/harness/`
448
+ - [ ] Verify cross-domain navigation links in modified reference docs resolve
449
+ - [ ] NEVER run `ah docs validate`/`finalize` on skill references — those commands are scoped to `docs/` only
@@ -0,0 +1,187 @@
1
+ # Core Architecture
2
+
3
+ Per **Context is Precious**, this is the architectural map — how harness components connect and what must be preserved when modifying the system.
4
+
5
+ ## Directory Structure
6
+
7
+ ```
8
+ .allhands/
9
+ ├── settings.json # Repository-specific settings (format, validation)
10
+ ├── flows/ # Agent instructions (progressive disclosure)
11
+ ├── agents/ # Agent profiles (YAML spawn configs)
12
+ ├── workflows/ # Workflow configs (hypothesis domains per workflow type)
13
+ ├── skills/ # Domain expertise (patterns, best practices)
14
+ ├── validation/ # Acceptance criteria tooling
15
+ ├── schemas/ # Agent-facing YAML frontmatter schemas
16
+ └── harness/ # CLI implementation
17
+ ├── src/commands/ # Auto-discovered CLI commands
18
+ ├── src/hooks/ # Claude Code lifecycle hooks
19
+ ├── src/lib/ # Core utilities + internal Zod schemas
20
+ ├── src/schemas/ # JSON schemas for settings files
21
+ ├── src/tui/ # Terminal UI implementation
22
+ └── src/platforms/ # Claude Code settings.json
23
+ ```
24
+
25
+ ## Project Settings
26
+
27
+ **Location:** `.allhands/settings.json` | **Schema:** `.allhands/harness/src/schemas/settings.schema.json`
28
+
29
+ Repository-specific, platform-agnostic configuration. Hooks read this to determine behavior.
30
+
31
+ | Setting | Hook | Purpose |
32
+ |---------|------|---------|
33
+ | `validation.format` | `ah hooks validation format` | Auto-format after Write/Edit |
34
+
35
+ Format config: `enabled`, `command` (default), `patterns` (file-specific overrides).
36
+
37
+ ## TUI Lifecycle
38
+
39
+ Per **Context is Precious** and **Prompt Files as Units of Work**, the TUI orchestrates agents with bounded context.
40
+
41
+ ### Structure
42
+ - **Actions Pane (left)**: Agent spawners, toggles (loop, parallel), utilities
43
+ - **Prompts Pane (center)**: Work-in-progress by status (pending, in_progress, done)
44
+ - **Status Pane (right)**: Active agent grid, milestone info, activity log
45
+
46
+ ### Lifecycle
47
+ 1. **Start**: Build semantic index if missing, load state from `.planning/{branch}/status.yaml`
48
+ 2. **Loop**: Render panes, handle input, dispatch actions, poll EventLoop (5s interval)
49
+ 3. **Stop**: Kill spawned agent windows, restore terminal
50
+
51
+ ### EventLoop Daemon
52
+ - Polls Greptile PR feedback, git branch changes, agent window status
53
+ - Runs prompt picker algorithm when loop enabled
54
+ - Non-blocking callbacks notify TUI of state changes
55
+
56
+ ### Dynamic Actions
57
+ Per **Frontier Models are Capable**, actions enable/disable based on state:
58
+ - Planner only enabled if milestone set
59
+ - E2E builder only visible after first prompt done
60
+ - PR action label changes based on review state
61
+
62
+ ## Schema System
63
+
64
+ ### Agent-Facing Schemas (`schemas/*.yaml`)
65
+ Exposed via `ah schema <type>`. Define frontmatter for harness-managed files:
66
+ - `prompt.yaml` — Prompt file structure
67
+ - `alignment.yaml` — Alignment doc structure
68
+ - `spec.yaml` — Spec structure
69
+ - `skill.yaml` — Skill manifest
70
+ - `validation-suite.yaml` — Validation tooling
71
+ - `solution.yaml` — Solution documentation (`docs/solutions/`)
72
+ - `documentation.yaml` — General documentation (`docs/`)
73
+
74
+ ### Internal Schemas (`.allhands/harness/src/lib/schemas/`)
75
+ Zod schemas for harness configuration. NOT exposed to agents:
76
+
77
+ **Template Variables Registry** (`.allhands/harness/src/lib/schemas/template-vars.ts`)
78
+ - Single source of truth for valid template variables
79
+ - Each has Zod schema + description
80
+ - Variables: `SPEC_PATH`, `ALIGNMENT_PATH`, `MILESTONE_NAME`, `PROMPT_NUMBER`, `BRANCH`, `HYPOTHESIS_DOMAINS`, `SPEC_TYPE`, etc.
81
+
82
+ **Agent Profile Schema** (`.allhands/harness/src/lib/schemas/agent-profile.ts`)
83
+ - Raw schema (snake_case from YAML) + normalized interface (camelCase)
84
+ - Semantic validation: template vars in `message_template` must match `template_vars` list
85
+ - Pattern validation: `PROMPT_NUMBER` must match `^\d{2}$`
86
+
87
+ ### Why Zod for Internal
88
+ - Type safety with compile-time checks
89
+ - Runtime validation catches misconfigurations at spawn time
90
+ - Pattern validation enforces format constraints
91
+
92
+ ## Agent Profiles
93
+
94
+ Per **Frontier Models are Capable**, profiles define spawn configuration, not behavior.
95
+
96
+ ### Profile Structure (`agents/*.yaml`)
97
+ ```yaml
98
+ name: executor # Agent identifier
99
+ flow: PROMPT_TASK_EXECUTION.md # Flow file in flows/
100
+ prompt_scoped: true # Multiple instances (one per prompt)
101
+ tui_action: executor # TUI button trigger
102
+ tui_label: Executor # Display label
103
+ tui_requires_spec: true
104
+ non_coding: false # Can write code
105
+ message_template: | # Preamble injected before flow
106
+ Your prompt file: ${PROMPT_PATH}
107
+ Alignment doc: ${ALIGNMENT_PATH}
108
+ template_vars: # Required context variables
109
+ - PROMPT_PATH
110
+ - ALIGNMENT_PATH
111
+ ```
112
+
113
+ ### Key Fields
114
+ - **prompt_scoped**: If true, runs multiple instances (executor per prompt)
115
+ - **non_coding**: Hint for agent type (coordinator, judge are true)
116
+ - **message_template**: Uses `${VAR}` interpolation
117
+
118
+ ### Environment Variables Passed
119
+ `AGENT_ID`, `AGENT_TYPE`, `PROMPT_NUMBER`, `MILESTONE_NAME`, `BRANCH`
120
+
121
+ ## Hypothesis Domains
122
+
123
+ Per **Quality Engineering**, hypothesis domains define available work areas for the emergent planner.
124
+
125
+ ### Configuration
126
+ Defined in `settings.json` under `emergent.hypothesisDomains`:
127
+ ```json
128
+ {
129
+ "emergent": {
130
+ "hypothesisDomains": ["testing", "stability", "performance", "feature", "ux", "integration"]
131
+ }
132
+ }
133
+ ```
134
+
135
+ Per **Frontier Models are Capable**, agents understand domain meanings from names alone — no descriptions needed.
136
+
137
+ ### Integration with Agent Spawning
138
+ 1. `buildTemplateContext()` loads domains from `settings.json`
139
+ 2. Domains formatted as `HYPOTHESIS_DOMAINS` template variable
140
+ 3. Emergent planner receives available domains in spawn message
141
+ 4. Planner selects domain and creates `type: emergent` prompts for executors
142
+
143
+ ### Diversification Rule
144
+ Per **Knowledge Compounding**, the emergent planner tracks work types in alignment doc summaries. If prior prompts cluster on one domain, subsequent prompts should diversify by selecting an underrepresented domain.
145
+
146
+ ## Platform Integration
147
+
148
+ ### Settings Configuration (`.claude/settings.json`)
149
+ Connection point between harness and Claude Code:
150
+ ```json
151
+ "PreToolUse": [
152
+ {
153
+ "matcher": "Read",
154
+ "hooks": [{
155
+ "type": "command",
156
+ "command": "ah hooks context read-enforcer",
157
+ "timeout": 20
158
+ }]
159
+ }
160
+ ]
161
+ ```
162
+
163
+ ### Permissions
164
+ ```json
165
+ "deny": ["Task(claude-code-guide)", "Task(Explore)", "Task(Plan)"]
166
+ ```
167
+
168
+ ## Extension Points
169
+
170
+ ### Adding New Agents
171
+ 1. Create YAML profile in `agents/`
172
+ 2. Create flow file in `flows/`
173
+ 3. Run `ah validate agents`
174
+
175
+ ### Updating Hypothesis Domains
176
+ 1. Edit available domains in `settings.json` under `emergent.hypothesisDomains`
177
+ 2. Domains are passed to emergent planner via `HYPOTHESIS_DOMAINS` template variable
178
+
179
+ ### Adding New Schemas
180
+ 1. Create YAML in `schemas/` for agent-facing
181
+ 2. Create Zod schema in `.allhands/harness/src/lib/schemas/` for internal
182
+
183
+ ## Related References
184
+
185
+ - [`tools-commands-mcp-hooks.md`](tools-commands-mcp-hooks.md) — When modifying hooks, CLI commands, or MCP server integration
186
+ - [`writing-flows.md`](writing-flows.md) — When changes affect flow directory structure or conventions
187
+ - [`harness-skills.md`](harness-skills.md) — When changes affect skill discovery or the schema system