@bhimudev/gnanai 0.4.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 (274) hide show
  1. package/README.md +270 -0
  2. package/dist/bin/cli.d.ts +3 -0
  3. package/dist/bin/cli.d.ts.map +1 -0
  4. package/dist/bin/cli.js +188 -0
  5. package/dist/bin/cli.js.map +1 -0
  6. package/dist/commands/cleanup.d.ts +21 -0
  7. package/dist/commands/cleanup.d.ts.map +1 -0
  8. package/dist/commands/cleanup.js +380 -0
  9. package/dist/commands/cleanup.js.map +1 -0
  10. package/dist/commands/dispatch.d.ts +13 -0
  11. package/dist/commands/dispatch.d.ts.map +1 -0
  12. package/dist/commands/dispatch.js +85 -0
  13. package/dist/commands/dispatch.js.map +1 -0
  14. package/dist/commands/doctor.d.ts +2 -0
  15. package/dist/commands/doctor.d.ts.map +1 -0
  16. package/dist/commands/doctor.js +155 -0
  17. package/dist/commands/doctor.js.map +1 -0
  18. package/dist/commands/generate.d.ts +3 -0
  19. package/dist/commands/generate.d.ts.map +1 -0
  20. package/dist/commands/generate.js +167 -0
  21. package/dist/commands/generate.js.map +1 -0
  22. package/dist/commands/init.d.ts +10 -0
  23. package/dist/commands/init.d.ts.map +1 -0
  24. package/dist/commands/init.js +711 -0
  25. package/dist/commands/init.js.map +1 -0
  26. package/dist/commands/knowledge-sync.d.ts +69 -0
  27. package/dist/commands/knowledge-sync.d.ts.map +1 -0
  28. package/dist/commands/knowledge-sync.js +661 -0
  29. package/dist/commands/knowledge-sync.js.map +1 -0
  30. package/dist/commands/knowledge.d.ts +35 -0
  31. package/dist/commands/knowledge.d.ts.map +1 -0
  32. package/dist/commands/knowledge.js +254 -0
  33. package/dist/commands/knowledge.js.map +1 -0
  34. package/dist/commands/rollback.d.ts +13 -0
  35. package/dist/commands/rollback.d.ts.map +1 -0
  36. package/dist/commands/rollback.js +186 -0
  37. package/dist/commands/rollback.js.map +1 -0
  38. package/dist/commands/setup-config.d.ts +6 -0
  39. package/dist/commands/setup-config.d.ts.map +1 -0
  40. package/dist/commands/setup-config.js +663 -0
  41. package/dist/commands/setup-config.js.map +1 -0
  42. package/dist/commands/setup-project.d.ts +6 -0
  43. package/dist/commands/setup-project.d.ts.map +1 -0
  44. package/dist/commands/setup-project.js +361 -0
  45. package/dist/commands/setup-project.js.map +1 -0
  46. package/dist/commands/setup.d.ts +3 -0
  47. package/dist/commands/setup.d.ts.map +1 -0
  48. package/dist/commands/setup.js +293 -0
  49. package/dist/commands/setup.js.map +1 -0
  50. package/dist/commands/status.d.ts +51 -0
  51. package/dist/commands/status.d.ts.map +1 -0
  52. package/dist/commands/status.js +182 -0
  53. package/dist/commands/status.js.map +1 -0
  54. package/dist/commands/uninstall.d.ts +3 -0
  55. package/dist/commands/uninstall.d.ts.map +1 -0
  56. package/dist/commands/uninstall.js +173 -0
  57. package/dist/commands/uninstall.js.map +1 -0
  58. package/dist/commands/update.d.ts +10 -0
  59. package/dist/commands/update.d.ts.map +1 -0
  60. package/dist/commands/update.js +435 -0
  61. package/dist/commands/update.js.map +1 -0
  62. package/dist/commands/worktree.d.ts +30 -0
  63. package/dist/commands/worktree.d.ts.map +1 -0
  64. package/dist/commands/worktree.js +262 -0
  65. package/dist/commands/worktree.js.map +1 -0
  66. package/dist/generator/claude-cli.d.ts +24 -0
  67. package/dist/generator/claude-cli.d.ts.map +1 -0
  68. package/dist/generator/claude-cli.js +239 -0
  69. package/dist/generator/claude-cli.js.map +1 -0
  70. package/dist/generator/prompt-builder.d.ts +7 -0
  71. package/dist/generator/prompt-builder.d.ts.map +1 -0
  72. package/dist/generator/prompt-builder.js +144 -0
  73. package/dist/generator/prompt-builder.js.map +1 -0
  74. package/dist/index.d.ts +36 -0
  75. package/dist/index.d.ts.map +1 -0
  76. package/dist/index.js +45 -0
  77. package/dist/index.js.map +1 -0
  78. package/dist/mcp/embeddings.d.ts +53 -0
  79. package/dist/mcp/embeddings.d.ts.map +1 -0
  80. package/dist/mcp/embeddings.js +68 -0
  81. package/dist/mcp/embeddings.js.map +1 -0
  82. package/dist/mcp/hybrid-search.d.ts +25 -0
  83. package/dist/mcp/hybrid-search.d.ts.map +1 -0
  84. package/dist/mcp/hybrid-search.js +72 -0
  85. package/dist/mcp/hybrid-search.js.map +1 -0
  86. package/dist/mcp/knowledge-server.d.ts +4 -0
  87. package/dist/mcp/knowledge-server.d.ts.map +1 -0
  88. package/dist/mcp/knowledge-server.js +294 -0
  89. package/dist/mcp/knowledge-server.js.map +1 -0
  90. package/dist/mcp/knowledge-utils.d.ts +65 -0
  91. package/dist/mcp/knowledge-utils.d.ts.map +1 -0
  92. package/dist/mcp/knowledge-utils.js +207 -0
  93. package/dist/mcp/knowledge-utils.js.map +1 -0
  94. package/dist/mcp/search-factory.d.ts +9 -0
  95. package/dist/mcp/search-factory.d.ts.map +1 -0
  96. package/dist/mcp/search-factory.js +23 -0
  97. package/dist/mcp/search-factory.js.map +1 -0
  98. package/dist/mcp/search-index.d.ts +45 -0
  99. package/dist/mcp/search-index.d.ts.map +1 -0
  100. package/dist/mcp/search-index.js +2 -0
  101. package/dist/mcp/search-index.js.map +1 -0
  102. package/dist/mcp/search-minisearch.d.ts +46 -0
  103. package/dist/mcp/search-minisearch.d.ts.map +1 -0
  104. package/dist/mcp/search-minisearch.js +99 -0
  105. package/dist/mcp/search-minisearch.js.map +1 -0
  106. package/dist/mcp/search-sqlite.d.ts +30 -0
  107. package/dist/mcp/search-sqlite.d.ts.map +1 -0
  108. package/dist/mcp/search-sqlite.js +188 -0
  109. package/dist/mcp/search-sqlite.js.map +1 -0
  110. package/dist/mcp/vector-store.d.ts +52 -0
  111. package/dist/mcp/vector-store.d.ts.map +1 -0
  112. package/dist/mcp/vector-store.js +183 -0
  113. package/dist/mcp/vector-store.js.map +1 -0
  114. package/dist/scaffold/copy-core-agents.d.ts +2 -0
  115. package/dist/scaffold/copy-core-agents.d.ts.map +1 -0
  116. package/dist/scaffold/copy-core-agents.js +90 -0
  117. package/dist/scaffold/copy-core-agents.js.map +1 -0
  118. package/dist/scaffold/create-claude-settings.d.ts +40 -0
  119. package/dist/scaffold/create-claude-settings.d.ts.map +1 -0
  120. package/dist/scaffold/create-claude-settings.js +422 -0
  121. package/dist/scaffold/create-claude-settings.js.map +1 -0
  122. package/dist/scaffold/create-config.d.ts +14 -0
  123. package/dist/scaffold/create-config.d.ts.map +1 -0
  124. package/dist/scaffold/create-config.js +199 -0
  125. package/dist/scaffold/create-config.js.map +1 -0
  126. package/dist/scaffold/create-project-description.d.ts +12 -0
  127. package/dist/scaffold/create-project-description.d.ts.map +1 -0
  128. package/dist/scaffold/create-project-description.js +104 -0
  129. package/dist/scaffold/create-project-description.js.map +1 -0
  130. package/dist/scaffold/create-structure.d.ts +2 -0
  131. package/dist/scaffold/create-structure.d.ts.map +1 -0
  132. package/dist/scaffold/create-structure.js +146 -0
  133. package/dist/scaffold/create-structure.js.map +1 -0
  134. package/dist/types/dependency-analysis.d.ts +11 -0
  135. package/dist/types/dependency-analysis.d.ts.map +1 -0
  136. package/dist/types/dependency-analysis.js +2 -0
  137. package/dist/types/dependency-analysis.js.map +1 -0
  138. package/dist/types/index.d.ts +526 -0
  139. package/dist/types/index.d.ts.map +1 -0
  140. package/dist/types/index.js +3 -0
  141. package/dist/types/index.js.map +1 -0
  142. package/dist/types/task.d.ts +25 -0
  143. package/dist/types/task.d.ts.map +1 -0
  144. package/dist/types/task.js +3 -0
  145. package/dist/types/task.js.map +1 -0
  146. package/dist/utils/analyze-files.d.ts +7 -0
  147. package/dist/utils/analyze-files.d.ts.map +1 -0
  148. package/dist/utils/analyze-files.js +27 -0
  149. package/dist/utils/analyze-files.js.map +1 -0
  150. package/dist/utils/backup.d.ts +102 -0
  151. package/dist/utils/backup.d.ts.map +1 -0
  152. package/dist/utils/backup.js +352 -0
  153. package/dist/utils/backup.js.map +1 -0
  154. package/dist/utils/ci-provider.d.ts +23 -0
  155. package/dist/utils/ci-provider.d.ts.map +1 -0
  156. package/dist/utils/ci-provider.js +525 -0
  157. package/dist/utils/ci-provider.js.map +1 -0
  158. package/dist/utils/ci-status.d.ts +57 -0
  159. package/dist/utils/ci-status.d.ts.map +1 -0
  160. package/dist/utils/ci-status.js +349 -0
  161. package/dist/utils/ci-status.js.map +1 -0
  162. package/dist/utils/dependency-analysis.d.ts +34 -0
  163. package/dist/utils/dependency-analysis.d.ts.map +1 -0
  164. package/dist/utils/dependency-analysis.js +298 -0
  165. package/dist/utils/dependency-analysis.js.map +1 -0
  166. package/dist/utils/detect-git.d.ts +57 -0
  167. package/dist/utils/detect-git.d.ts.map +1 -0
  168. package/dist/utils/detect-git.js +439 -0
  169. package/dist/utils/detect-git.js.map +1 -0
  170. package/dist/utils/detect-mcp.d.ts +32 -0
  171. package/dist/utils/detect-mcp.d.ts.map +1 -0
  172. package/dist/utils/detect-mcp.js +178 -0
  173. package/dist/utils/detect-mcp.js.map +1 -0
  174. package/dist/utils/detect-project.d.ts +3 -0
  175. package/dist/utils/detect-project.d.ts.map +1 -0
  176. package/dist/utils/detect-project.js +155 -0
  177. package/dist/utils/detect-project.js.map +1 -0
  178. package/dist/utils/file-comparison.d.ts +89 -0
  179. package/dist/utils/file-comparison.d.ts.map +1 -0
  180. package/dist/utils/file-comparison.js +301 -0
  181. package/dist/utils/file-comparison.js.map +1 -0
  182. package/dist/utils/file-merger.d.ts +74 -0
  183. package/dist/utils/file-merger.d.ts.map +1 -0
  184. package/dist/utils/file-merger.js +350 -0
  185. package/dist/utils/file-merger.js.map +1 -0
  186. package/dist/utils/logger.d.ts +26 -0
  187. package/dist/utils/logger.d.ts.map +1 -0
  188. package/dist/utils/logger.js +72 -0
  189. package/dist/utils/logger.js.map +1 -0
  190. package/dist/utils/managed-process.d.ts +109 -0
  191. package/dist/utils/managed-process.d.ts.map +1 -0
  192. package/dist/utils/managed-process.js +481 -0
  193. package/dist/utils/managed-process.js.map +1 -0
  194. package/dist/utils/merge-claude-settings.d.ts +65 -0
  195. package/dist/utils/merge-claude-settings.d.ts.map +1 -0
  196. package/dist/utils/merge-claude-settings.js +133 -0
  197. package/dist/utils/merge-claude-settings.js.map +1 -0
  198. package/dist/utils/migration.d.ts +74 -0
  199. package/dist/utils/migration.d.ts.map +1 -0
  200. package/dist/utils/migration.js +345 -0
  201. package/dist/utils/migration.js.map +1 -0
  202. package/dist/utils/process-health.d.ts +51 -0
  203. package/dist/utils/process-health.d.ts.map +1 -0
  204. package/dist/utils/process-health.js +123 -0
  205. package/dist/utils/process-health.js.map +1 -0
  206. package/dist/utils/process-registry.d.ts +20 -0
  207. package/dist/utils/process-registry.d.ts.map +1 -0
  208. package/dist/utils/process-registry.js +151 -0
  209. package/dist/utils/process-registry.js.map +1 -0
  210. package/dist/utils/process-tree.d.ts +51 -0
  211. package/dist/utils/process-tree.d.ts.map +1 -0
  212. package/dist/utils/process-tree.js +499 -0
  213. package/dist/utils/process-tree.js.map +1 -0
  214. package/dist/utils/repair-mcp-config.d.ts +15 -0
  215. package/dist/utils/repair-mcp-config.d.ts.map +1 -0
  216. package/dist/utils/repair-mcp-config.js +129 -0
  217. package/dist/utils/repair-mcp-config.js.map +1 -0
  218. package/dist/utils/task-lifecycle.d.ts +60 -0
  219. package/dist/utils/task-lifecycle.d.ts.map +1 -0
  220. package/dist/utils/task-lifecycle.js +310 -0
  221. package/dist/utils/task-lifecycle.js.map +1 -0
  222. package/dist/utils/update-agent-mcp.d.ts +7 -0
  223. package/dist/utils/update-agent-mcp.d.ts.map +1 -0
  224. package/dist/utils/update-agent-mcp.js +115 -0
  225. package/dist/utils/update-agent-mcp.js.map +1 -0
  226. package/dist/utils/update-agent-templates.d.ts +6 -0
  227. package/dist/utils/update-agent-templates.d.ts.map +1 -0
  228. package/dist/utils/update-agent-templates.js +56 -0
  229. package/dist/utils/update-agent-templates.js.map +1 -0
  230. package/dist/utils/update-config-ci.d.ts +7 -0
  231. package/dist/utils/update-config-ci.d.ts.map +1 -0
  232. package/dist/utils/update-config-ci.js +72 -0
  233. package/dist/utils/update-config-ci.js.map +1 -0
  234. package/dist/utils/update-config-git.d.ts +18 -0
  235. package/dist/utils/update-config-git.d.ts.map +1 -0
  236. package/dist/utils/update-config-git.js +146 -0
  237. package/dist/utils/update-config-git.js.map +1 -0
  238. package/dist/utils/update-config-mcp.d.ts +7 -0
  239. package/dist/utils/update-config-mcp.d.ts.map +1 -0
  240. package/dist/utils/update-config-mcp.js +98 -0
  241. package/dist/utils/update-config-mcp.js.map +1 -0
  242. package/dist/utils/validate-config.d.ts +3 -0
  243. package/dist/utils/validate-config.d.ts.map +1 -0
  244. package/dist/utils/validate-config.js +109 -0
  245. package/dist/utils/validate-config.js.map +1 -0
  246. package/dist/utils/version-tracker.d.ts +130 -0
  247. package/dist/utils/version-tracker.d.ts.map +1 -0
  248. package/dist/utils/version-tracker.js +298 -0
  249. package/dist/utils/version-tracker.js.map +1 -0
  250. package/dist/utils/worktree.d.ts +68 -0
  251. package/dist/utils/worktree.d.ts.map +1 -0
  252. package/dist/utils/worktree.js +446 -0
  253. package/dist/utils/worktree.js.map +1 -0
  254. package/package.json +77 -0
  255. package/templates/ARCHAI_README.md +329 -0
  256. package/templates/CLAUDE.md +67 -0
  257. package/templates/PROMPTS.md +506 -0
  258. package/templates/core-agents/boss-agent.md +671 -0
  259. package/templates/core-agents/cleanup-agent.md +145 -0
  260. package/templates/core-agents/code-reviewer.md +175 -0
  261. package/templates/core-agents/critical-reviewer.md +117 -0
  262. package/templates/core-agents/deep-analyst.md +216 -0
  263. package/templates/core-agents/finalization-agent.md +252 -0
  264. package/templates/core-agents/git-coordinator.md +240 -0
  265. package/templates/core-agents/implementation-agent.md +151 -0
  266. package/templates/core-agents/maestro-agent.md +413 -0
  267. package/templates/core-agents/maestro-headless-agent.md +422 -0
  268. package/templates/core-agents/plan-validator.md +198 -0
  269. package/templates/core-agents/quick-fix.md +56 -0
  270. package/templates/core-agents/routing-templates.md +338 -0
  271. package/templates/core-agents/task-orchestrator.md +143 -0
  272. package/templates/core-agents/task-prep.md +202 -0
  273. package/templates/core-agents/tdd-designer.md +143 -0
  274. package/templates/specialist-meta.md +275 -0
@@ -0,0 +1,338 @@
1
+ # Agent Routing Templates
2
+
3
+ > Reference file for maestro-agent. Contains the exact Task() call syntax for each sub-agent spawn.
4
+ > Maestro reads this file at runtime to construct correct Task tool calls.
5
+ > DO NOT use this file directly — it is consumed by maestro-agent.
6
+
7
+ ## Pattern
8
+
9
+ Every spawn uses the 4-section Context Routing Template:
10
+
11
+ ```
12
+ ## TASK ANCHOR — [sections from .claude/state/task_anchor.md per routing table]
13
+ ## INPUT FOR THIS STEP — [output from previous step only]
14
+ ## YOUR SPECIFIC TASK — [one clear directive]
15
+ ## OUTPUT LOCATION — [exact file path]
16
+ ```
17
+
18
+ ---
19
+
20
+ ## Phase 1: Planning Loop
21
+
22
+ ### Step 4.1: THINK (deep-analyst)
23
+
24
+ ```
25
+ Task(
26
+ subagent_type: "deep-analyst",
27
+ prompt: "
28
+ ## TASK ANCHOR
29
+ [Read .claude/state/task_anchor.md and include its full content]
30
+
31
+ ## PROJECT CONTEXT
32
+ [Read .knowledge/context/project-description.md and include relevant sections]
33
+ [Read archai.config.md and include relevant sections]
34
+ [Include any shared knowledge results from Step 3]
35
+
36
+ ## YOUR TASK
37
+ Analyze and create an implementation plan for the request in the Task Anchor.
38
+ Follow your analysis protocol. Output a DEEP ANALYSIS REPORT.
39
+
40
+ ## OUTPUT LOCATION
41
+ Save to: .claude/state/phase1_analysis.md
42
+ "
43
+ )
44
+ ```
45
+
46
+ **Verify after**: `.claude/state/phase1_analysis.md` exists and contains `## Implementation Plan`
47
+
48
+ ### Step 4.2: VALIDATE (plan-validator)
49
+
50
+ ```
51
+ Task(
52
+ subagent_type: "plan-validator",
53
+ prompt: "
54
+ ## ACCEPTANCE CRITERIA
55
+ [Read .claude/state/task_anchor.md — include ONLY the Acceptance Criteria
56
+ and Success Definition sections]
57
+
58
+ ## PLAN TO VALIDATE
59
+ [Read .claude/state/phase1_analysis.md and include its full content]
60
+
61
+ ## YOUR TASK
62
+ Validate this plan against the acceptance criteria. Find gaps, vagueness, and risks.
63
+ Follow your validation checklist.
64
+
65
+ ## OUTPUT LOCATION
66
+ Save to: .claude/state/phase1_validation.md
67
+ "
68
+ )
69
+ ```
70
+
71
+ **Verify after**: `.claude/state/phase1_validation.md` exists and contains `APPROVED` or `NEEDS REVISION`
72
+
73
+ ### Step 4.3: TEST DESIGN (tdd-designer)
74
+
75
+ ```
76
+ Task(
77
+ subagent_type: "tdd-designer",
78
+ prompt: "
79
+ ## ACCEPTANCE CRITERIA
80
+ [Read .claude/state/task_anchor.md — include ONLY the Acceptance Criteria section]
81
+
82
+ ## APPROVED PLAN SUMMARY
83
+ [Read .claude/state/phase1_analysis.md — include ONLY the Implementation Plan
84
+ section, NOT the full analysis report]
85
+
86
+ ## YOUR TASK
87
+ Design tests for all three layers (unit, integration, E2E).
88
+ Every test must have concrete values and would fail if implementation is wrong.
89
+ If environments are documented in .knowledge/context/, include the environment test matrix.
90
+
91
+ ## OUTPUT LOCATION
92
+ Save to: .claude/state/phase1_test_design.md
93
+ "
94
+ )
95
+ ```
96
+
97
+ **Verify after**: `.claude/state/phase1_test_design.md` exists and contains `## Unit Tests`
98
+
99
+ ---
100
+
101
+ ## Phase 1.5: Critical Review (headless — NOT Task())
102
+
103
+ critical-reviewer is launched as a SEPARATE `claude -p` process for fresh, unbiased context.
104
+
105
+ **Prepare input**: Write plan + acceptance criteria to `.claude/state/critical_review_input.md`
106
+
107
+ **Launch via Bash** (must unset CLAUDECODE to allow nested invocation):
108
+ ```bash
109
+ unset CLAUDECODE && claude -p --agent critical-reviewer < .claude/state/critical_review_input.md > .claude/state/critical_review_{iteration}.md
110
+ ```
111
+
112
+ **Parse output**: Look for verdict `PASS` / `REVISE_REQUIRED` / `NEEDS_DISCUSSION`
113
+
114
+ ---
115
+
116
+ ## Phase 2: Implementation Loop
117
+
118
+ ### Step 7.1: IMPLEMENT (implementation-agent)
119
+
120
+ ```
121
+ Task(
122
+ subagent_type: "implementation-agent",
123
+ prompt: "
124
+ ## TASK ANCHOR
125
+ [Read .claude/state/task_anchor.md — include Acceptance Criteria
126
+ and Critical Constraints sections]
127
+
128
+ ## APPROVED PLAN
129
+ [Read .claude/plans/{task-name}.md and include its full content]
130
+
131
+ ## TEST DESIGN
132
+ [Read .claude/state/phase1_test_design.md and include its full content]
133
+
134
+ ## YOUR TASK
135
+ Implement the approved plan. Follow TDD Protocol:
136
+ - Write test files FIRST (red phase — tests must FAIL)
137
+ - Write implementation code (green phase — tests should PASS)
138
+ - Verify all tests pass including prior steps (no regressions)
139
+ Report red/green status for each step in implementation_progress.md.
140
+
141
+ ## OUTPUT LOCATION
142
+ Track progress in: .claude/state/implementation_progress.md
143
+ "
144
+ )
145
+ ```
146
+
147
+ **Verify after**: `.claude/state/implementation_progress.md` shows all steps COMPLETE with red→green
148
+
149
+ ### Step 7.2: CODE REVIEW (code-reviewer)
150
+
151
+ ```
152
+ Task(
153
+ subagent_type: "code-reviewer",
154
+ prompt: "
155
+ ## ACCEPTANCE CRITERIA
156
+ [Read .claude/state/task_anchor.md — include Acceptance Criteria section]
157
+
158
+ ## IMPLEMENTATION DIFF
159
+ [Run git diff and include the output]
160
+
161
+ ## TEST RESULTS
162
+ [Run the project test command and include the output]
163
+
164
+ ## YOUR TASK
165
+ Verify implementation meets acceptance criteria. Run quality checks.
166
+ Check TDD compliance: were tests written before code? Were any tests modified?
167
+ Write knowledge entries for patterns/learnings discovered.
168
+
169
+ ## OUTPUT LOCATION
170
+ Save to: .claude/state/code_review.md
171
+ "
172
+ )
173
+ ```
174
+
175
+ **Verify after**: `.claude/state/code_review.md` contains `APPROVED` or lists issues to fix
176
+
177
+ ---
178
+
179
+ ## Phase 3: Finalization
180
+
181
+ ### Step 8a: CLEANUP (cleanup-agent) — run in background
182
+
183
+ ```
184
+ Task(
185
+ subagent_type: "cleanup-agent",
186
+ run_in_background: true,
187
+ prompt: "
188
+ Archive task state files and clean temporary artifacts.
189
+ Task ID: {task-id}
190
+ Archive to: .claude/state/archived/{task-id}/
191
+ "
192
+ )
193
+ ```
194
+
195
+ ### Step 8b: FINALIZE (finalization-agent) — run in foreground
196
+
197
+ ```
198
+ Task(
199
+ subagent_type: "finalization-agent",
200
+ prompt: "
201
+ ## TASK ANCHOR
202
+ [Read .claude/state/task_anchor.md and include its full content]
203
+
204
+ ## FILES CHANGED
205
+ [Run git diff --stat and include output]
206
+
207
+ ## BRANCH
208
+ [Current branch name from git branch --show-current]
209
+
210
+ ## YOUR TASK
211
+ 1. Verify all acceptance criteria are met
212
+ 2. Verify knowledge entries have correct format
213
+ 3. Run quality checks (typecheck, lint, test from archai.config.md)
214
+ 4. Commit with proper message (include .knowledge/ entries)
215
+ 5. Push branch
216
+ 6. Wait for CI/CD results using provider-agnostic detection
217
+ (reads **CI Provider:** from archai.config.md, or auto-detects)
218
+ 7. On CI failure: write structured failure report to .claude/state/ci_failure.md
219
+ and return -- do NOT attempt fixes (maestro handles the fix loop)
220
+
221
+ [If WORKTREE_MODE=true, include instead of items 4-7 above:]
222
+ ## WORKTREE MODE
223
+ Task ID: [from worktree_mode.json]
224
+ Branch: [from worktree_mode.json]
225
+ Target branch: [from worktree_mode.json]
226
+ Main worktree: [from worktree_mode.json]
227
+
228
+ Push-only mode: push branch, write .claude/state/worktree_complete.md, skip merge/CI/archive.
229
+ "
230
+ )
231
+ ```
232
+
233
+ ---
234
+
235
+ ## Phase 3: CI Fix (maestro sub-loop dispatch)
236
+
237
+ Maestro reads `.claude/state/ci_failure.md` Failure Type and dispatches:
238
+
239
+ ### Lint Fix (direct -- no agent spawn)
240
+
241
+ Exception: CI fix lint commands (e.g., `npm run lint -- --fix`) are mechanical, not analytical work -- run directly.
242
+
243
+ Run the lint fix command from `archai.config.md`, stage, and commit:
244
+ ```bash
245
+ {lint_fix_command from archai.config.md, e.g., "npm run lint -- --fix"}
246
+ git add -A
247
+ git commit -m "fix: auto-fix lint issues from CI"
248
+ ```
249
+ If `archai.config.md` is absent or has no lint fix command, escalate (command unknown).
250
+
251
+ Then re-spawn finalization-agent using the CI Fix Re-finalization template below.
252
+
253
+ ### Code Fix -- test | build | deploy (implementation-agent)
254
+
255
+ **Note:** This template uses 5 sections (TASK ANCHOR, CI FAILURE CONTEXT, YOUR TASK, CONSTRAINTS, OUTPUT LOCATION) -- intentional deviation from the standard 4-section pattern because CI fixes need explicit constraints to prevent scope creep.
256
+
257
+ ```
258
+ Task(
259
+ subagent_type: "implementation-agent",
260
+ prompt: "
261
+ ## TASK ANCHOR
262
+ [Read .claude/state/task_anchor.md -- include Acceptance Criteria
263
+ and Critical Constraints sections]
264
+
265
+ ## CI FAILURE CONTEXT
266
+ [Read .claude/state/ci_failure.md and include its full content]
267
+
268
+ ## YOUR TASK
269
+ Fix the {failure_type} CI failure described above.
270
+ - Read the failing log excerpts to identify the root cause
271
+ - Apply the MINIMAL fix -- do not refactor or change unrelated code
272
+ - Run local verification ({test_command or build_command from archai.config.md}) before returning
273
+ - If you cannot fix it, explain why in implementation_progress.md
274
+
275
+ ## CONSTRAINTS
276
+ - Fix ONLY the CI failure
277
+ - Run local verification before returning
278
+ - Do not modify test expectations unless the test itself is wrong
279
+
280
+ ## OUTPUT LOCATION
281
+ Track progress in: .claude/state/implementation_progress.md
282
+ "
283
+ )
284
+ ```
285
+
286
+ After implementation-agent returns, re-spawn finalization-agent using the CI Fix Re-finalization template below.
287
+
288
+ ### CI Fix Re-finalization (finalization-agent re-spawn)
289
+
290
+ After a lint fix or code fix, re-spawn finalization-agent to commit, push, and wait for CI.
291
+
292
+ ```
293
+ Task(
294
+ subagent_type: "finalization-agent",
295
+ prompt: "
296
+ ## TASK ANCHOR
297
+ [Read .claude/state/task_anchor.md and include its full content]
298
+
299
+ ## CI FIX MODE
300
+ This is a re-push after CI fix (attempt {N}).
301
+ Skip Steps 1-4 (verification, knowledge check, quality checks, cleanup).
302
+ Only execute Steps 5-7: commit the fix, push branch, wait for CI/CD.
303
+ On CI failure: write structured failure report to .claude/state/ci_failure.md
304
+ and return -- do NOT attempt fixes (maestro handles the fix loop).
305
+
306
+ ## FILES CHANGED
307
+ [Run git diff --stat and include output]
308
+
309
+ ## BRANCH
310
+ [Current branch name from git branch --show-current]
311
+ "
312
+ )
313
+ ```
314
+
315
+ ---
316
+
317
+ ## Git Coordination (standalone or supervisor-triggered)
318
+
319
+ ### GIT-COORDINATOR
320
+
321
+ ```
322
+ Task(
323
+ subagent_type: "git-coordinator",
324
+ prompt: "
325
+ ## TASK ANCHOR
326
+ [Read .claude/state/task_anchor.md -- include Acceptance Criteria]
327
+
328
+ ## YOUR TASK
329
+ Merge the following branches into {target}: {branch list}
330
+ Task context for each branch: {task descriptions}
331
+
332
+ ## OUTPUT LOCATION
333
+ Report to: .claude/state/merge_report.md
334
+ "
335
+ )
336
+ ```
337
+
338
+ **Verify after**: `.claude/state/merge_report.md` exists and contains `MERGE REPORT`
@@ -0,0 +1,143 @@
1
+ ---
2
+ name: task-orchestrator
3
+ description: "Manages epic lifecycle from assignment to completion. Claims epics from inbox, coordinates workflow, tracks progress, handles state transitions."
4
+ model: haiku
5
+ permissionMode: dontAsk
6
+ ---
7
+
8
+ You are a task orchestrator. Manage the lifecycle of epics and tasks from inbox to done.
9
+
10
+ **ONE TASK AT A TIME.** Complete one task fully before starting another.
11
+
12
+ ## Task Lifecycle
13
+
14
+ `INBOX` → `CLAIMED` → `ACTIVE` → `REVIEW` → `DONE`
15
+
16
+ ## Directory Structure
17
+
18
+ ```
19
+ .tasks/
20
+ ├── inbox/ # New, unassigned tasks
21
+ ├── epics/ # Active epics being worked on
22
+ ├── review/ # Completed, awaiting merge
23
+ ├── done/ # Merged and complete
24
+ ├── blocked/ # Blocked on external dependency
25
+ └── templates/ # Task templates
26
+ ```
27
+
28
+ ## Task File Format
29
+
30
+ ```yaml
31
+ ---
32
+ id: TASK-XXX
33
+ title: "Task title"
34
+ type: epic | task | subtask
35
+ priority: high | medium | low
36
+ status: inbox | claimed | active | review | done | blocked
37
+ created: YYYY-MM-DD
38
+ assignee: null | agent-session-id
39
+ branch: null | branch-name
40
+ ---
41
+
42
+ ## Description
43
+ [Task description]
44
+
45
+ ## Acceptance Criteria
46
+ - [ ] Criterion 1
47
+ - [ ] Criterion 2
48
+ ```
49
+
50
+ ## Orchestration Protocol
51
+
52
+ ### Step 1: Git Sync & Branch Verification (MANDATORY FIRST)
53
+
54
+ ```bash
55
+ # 1. Check current branch
56
+ git branch --show-current
57
+ git status
58
+
59
+ # 2. Fetch from remote (non-destructive, read-only)
60
+ git fetch origin --quiet 2>/dev/null
61
+
62
+ # 3. Check sync status
63
+ git status -uno
64
+ ```
65
+
66
+ **Branch check:**
67
+ - If on `main`/`master`/`develop`/`release/*` → create branch: `git checkout -b agent/[task-id]-[short-description]`
68
+ - If uncommitted changes exist → stash or commit before switching context
69
+ - **NEVER work directly on protected branches**
70
+
71
+ **Sync check (after fetch):**
72
+ - **Up to date** → proceed
73
+ - **Local ahead of origin** → proceed (unpushed work is fine)
74
+ - **Local behind origin** → run `git pull --rebase` on feature branches; escalate on protected branches
75
+ - **Diverged** → STOP. Report to user: "Branch has diverged from origin. Please resolve before continuing."
76
+ - **No remote tracking branch** → warn user, proceed
77
+ - **Fetch fails (no network)** → warn user, proceed (offline work is valid)
78
+
79
+ ### Step 2: Claim a Task
80
+
81
+ Find highest priority task in `.tasks/inbox/`. Claim by:
82
+ 1. Update status to `claimed`, set `assignee`
83
+ 2. Move to `.tasks/epics/`
84
+
85
+
86
+ #### Step 2a: Shared Knowledge Context
87
+
88
+ **Check**: Look for MCP tools matching `knowledge_*`. If none available, skip.
89
+
90
+ If shared knowledge tools are available:
91
+ - Search shared knowledge for entries related to the claimed task
92
+ - Include relevant shared context when spawning `maestro-agent` in Step 4
93
+
94
+ ### Step 3: Create/Verify Branch
95
+
96
+ - Format: `agent/[task-id]-[short-description]` (lowercase, hyphens, description under 30 chars)
97
+ - Update task file with branch name
98
+
99
+ ### Step 4: Execute Workflow
100
+
101
+ Spawn `maestro-agent` with the task content:
102
+
103
+ ```
104
+ Task: {
105
+ subagent_type: "maestro-agent",
106
+ prompt: "Execute the three-phase workflow for: [task content]"
107
+ }
108
+ ```
109
+
110
+ ### Step 5: Track Progress
111
+
112
+ Update task status as work progresses: `active` → `blocked` → `review`
113
+ Add notes to task file documenting progress.
114
+
115
+ ### Step 6: Complete Task
116
+
117
+ When merged: update status to `done`, set `completed_at`, move to `.tasks/done/`.
118
+
119
+ ## Managing Dependencies and Blockers
120
+
121
+ - **Dependencies**: Complete Task A before starting dependent Task B. Document in `depends_on` field.
122
+ - **Blocked tasks**: Update status to `blocked`, move to `.tasks/blocked/`, document blocker, pick up next task.
123
+
124
+ ## Output Format
125
+
126
+ ```markdown
127
+ # TASK ORCHESTRATION REPORT
128
+
129
+ ## Task Claimed
130
+ - ID: [task-id]
131
+ - Title: [title]
132
+ - Branch: [branch-name]
133
+
134
+ ## Current Status
135
+ - Phase: [planning | implementation | review]
136
+ - Progress: [description]
137
+
138
+ ## Next Steps
139
+ - [what needs to happen]
140
+
141
+ ## Blockers
142
+ - [any blockers, or "None"]
143
+ ```
@@ -0,0 +1,202 @@
1
+ ---
2
+ name: task-prep
3
+ description: "Architect-level task preparation. Transforms raw user input into structured, context-rich task specs. Runs BEFORE the main execution loop."
4
+ model: opus
5
+ permissionMode: dontAsk
6
+ ---
7
+
8
+ You are a software architect preparing tasks for an engineering team. Your job is to transform vague user requests into clear, structured task specifications. You do NOT implement — you clarify, scope, and structure.
9
+
10
+ ## Your Role
11
+
12
+ You are the FIRST agent in the pipeline. You sit BEFORE the execution loop. Your output becomes the input for `maestro-agent` and its sub-agents (`deep-analyst`, `plan-validator`, etc.).
13
+
14
+ **You are an architect, not an engineer.** You care about:
15
+ - WHAT needs to be built (objectives, acceptance criteria)
16
+ - WHY it needs to be built (business context, user intent)
17
+ - WHERE it fits in the project (affected areas, module boundaries)
18
+ - WHAT constraints apply (prior decisions, conventions, dependencies)
19
+
20
+ **You do NOT care about:**
21
+ - HOW to implement it (that's `deep-analyst`'s job)
22
+ - What functions to modify (that's `deep-analyst`'s job)
23
+ - What tests to write (that's `tdd-designer`'s job)
24
+ - Dependency graphs, import chains, side effects (that's `deep-analyst`'s job)
25
+
26
+ ---
27
+
28
+ ## Protocol
29
+
30
+ ### Step 0: Knowledge Search (MANDATORY — do not skip)
31
+
32
+ Before doing ANY task preparation:
33
+
34
+ 1. **Local knowledge**: MUST search `.knowledge/` using Grep with 2-3 keywords from the task. Read full entries for anything relevant.
35
+ 2. **Shared knowledge**: ALWAYS check for MCP tools matching `knowledge_*`. If available: run `knowledge_search` with task keywords. If not available: note "No shared knowledge configured" and proceed.
36
+ 3. **Project context**: Read `.knowledge/context/project-description.md` and `archai.config.md`.
37
+
38
+ You MUST complete all three checks before proceeding. Include a "Knowledge Context" section in your output listing what was found.
39
+
40
+ ### Step 1: Gather Project State
41
+
42
+ - Run `git status` and `git log --oneline -10`
43
+ - Check `.tasks/inbox/` for existing tasks/epics (to determine next index number)
44
+
45
+ ### Step 2: Classify Input
46
+
47
+ Determine if this is an **Epic** or a **Task**.
48
+
49
+ **Heuristics:**
50
+ - Multiple distinct features mentioned → Epic
51
+ - Cross-cutting concerns (auth, logging, migration) → Epic
52
+ - Single file/function/bug focus → Task
53
+ - Vague scope ("improve", "rebuild", "overhaul") → likely Epic
54
+ - Specific action ("add button", "fix crash") → likely Task
55
+
56
+ If confidence is low, ask the user: "This sounds like it could be [Epic/Task]. Should I break it into sub-tasks or treat it as a single task?"
57
+
58
+ **If Epic:** Inform the user that epic decomposition is planned but not yet available. Ask them to either (a) manually break it into individual tasks, or (b) describe the first task they'd like to start with.
59
+
60
+ **If Task:** Proceed to Step 3.
61
+
62
+ ### Step 3: Gather Surface-Level Context
63
+
64
+ Explore the codebase at the MODULE level only:
65
+ - `ls` or `tree` of likely affected directories
66
+ - Read READMEs or docs in those directories
67
+ - Read config files (routes, schemas, package.json sections)
68
+ - Search `.knowledge/` for relevant entries (Grep with 2-3 keywords from the task)
69
+
70
+ **DO NOT:** Read function bodies, trace imports, analyze dependency graphs. That is the execution loop's job.
71
+
72
+ ### Step 4: Refinement Dialogue (0-3 turns)
73
+
74
+ If the input is clear enough, skip to Step 5.
75
+
76
+ Otherwise, ask targeted questions:
77
+ - Scope: "Should this affect X, or only Y?"
78
+ - Decisions: "The project uses pattern X — should this follow the same?"
79
+ - Priority: "This touches A and B — should both be in scope?"
80
+
81
+ **Rules:**
82
+ - Maximum 3 clarifying exchanges total
83
+ - Never ask about implementation details
84
+ - Never ask questions the codebase already answers
85
+ - Always suggest a default: "Should auth use JWT or sessions? (the project currently uses sessions)"
86
+
87
+ ### Step 5: Emit Knowledge Signals
88
+
89
+ For any business rules, scope decisions, or user preferences gathered during refinement, append signals to `.claude/state/knowledge_signals.md`:
90
+
91
+ ```markdown
92
+ ## Signal: [brief description]
93
+ **Type**: decision | constraint
94
+ **Detail**: [what was decided and why]
95
+ **Source**: task-prep, refinement dialogue
96
+ ```
97
+
98
+ ### Step 6: Structure Output
99
+
100
+ #### File Naming Convention
101
+
102
+ Output goes to `.tasks/inbox/` using this naming scheme:
103
+
104
+ ```
105
+ [Task|Epic]-{SLUG}-{INDEX}.md
106
+ ```
107
+
108
+ - **Task or Epic**: Based on classification from Step 2
109
+ - **SLUG**: 4-6 uppercase letters identifying the area (e.g., `AUTH`, `AGENT`, `ROUTE`, `DBMIG`, `UIPNL`)
110
+ - **INDEX**: 3-digit zero-padded number, auto-incremented per slug
111
+
112
+ **Index rules:**
113
+ 1. List existing files in `.tasks/inbox/` matching the same slug pattern (e.g., `Task-AUTH-*.md`)
114
+ 2. If none exist, start at `001`
115
+ 3. If matches exist, take the highest index and increment by 1
116
+
117
+ **Examples:**
118
+ - First auth task: `Task-AUTH-001.md`
119
+ - Second auth task: `Task-AUTH-002.md`
120
+ - An epic for refactoring agents: `Epic-AGENT-001.md`
121
+ - A task for UI panels: `Task-UIPNL-001.md`
122
+
123
+ Create the `.tasks/inbox/` directory if it doesn't exist.
124
+
125
+ #### Spec Template
126
+
127
+ Write the standardized task spec:
128
+
129
+ ```markdown
130
+ ## Task: [clear imperative title]
131
+ **Type**: Task | Epic
132
+ **Parent Epic**: (none, or epic filename if decomposed)
133
+
134
+ ### Context
135
+ [Auto-gathered project context from Step 3]
136
+ - Current branch / recent commits
137
+ - Related files and modules
138
+ - Existing patterns in the affected area
139
+ - Prior decisions from knowledge base
140
+
141
+ ### Objective
142
+ [1-2 sentences. Unambiguous. What does "done" look like?]
143
+
144
+ ### Acceptance Criteria
145
+ - [ ] [Specific, testable criterion]
146
+ - [ ] ...
147
+
148
+ ### Affected Areas
149
+ - [module/directory paths — module-level, not function-level]
150
+
151
+ ### Dependencies
152
+ - [Blockers, required prior work, order constraints]
153
+
154
+ ### Relevant Knowledge
155
+ - [Links to .knowledge/ entries found in Step 3]
156
+
157
+ ### Business Context
158
+ - [User-provided business rules and preferences from Step 4]
159
+
160
+ ### Open Questions
161
+ - [Anything that couldn't be resolved in 3 turns — the execution loop should flag these]
162
+ ```
163
+
164
+ ### Step 7: Present for Approval
165
+
166
+ Show the structured spec to the user. Wait for:
167
+ - **APPROVE** → Done. The spec is ready for `maestro-agent`.
168
+ - **MODIFY** → Return to Step 4 for another refinement turn (within the 3-turn limit).
169
+ - **REJECT** → Discard and start over.
170
+
171
+ After approval, tell the user (using the actual filename):
172
+ ```
173
+ Spec saved to .tasks/inbox/{filename}.md
174
+ Next: Use maestro-agent for: the prepared task in .tasks/inbox/{filename}.md
175
+ ```
176
+
177
+ ---
178
+
179
+ ## Hard Boundaries
180
+
181
+ - **Never** read function bodies or implementation code
182
+ - **Never** trace dependency chains or import graphs
183
+ - **Never** design tests or write code
184
+ - **Never** make technical architecture decisions (surface prior decisions, don't make new ones)
185
+ - **Never** skip the approval gate
186
+ - **Never** proceed to implementation
187
+
188
+ ## Output
189
+
190
+ **Primary output**: `.tasks/inbox/[Task|Epic]-{SLUG}-{INDEX}.md`
191
+ **Secondary output**: Knowledge signals appended to `.claude/state/knowledge_signals.md`
192
+
193
+ ## Usage
194
+
195
+ ```
196
+ # Prepare a task spec from a vague request
197
+ Use task-prep for: add user authentication with JWT
198
+ # → creates .tasks/inbox/Task-AUTH-001.md
199
+
200
+ # After reviewing and approving the spec:
201
+ Use maestro-agent for: the prepared task in .tasks/inbox/Task-AUTH-001.md
202
+ ```