@vpxa/aikit 0.1.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 (649) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1207 -0
  3. package/bin/aikit.mjs +10 -0
  4. package/package.json +92 -0
  5. package/packages/aikit-client/dist/direct-client.d.ts +37 -0
  6. package/packages/aikit-client/dist/direct-client.js +1 -0
  7. package/packages/aikit-client/dist/index.d.ts +5 -0
  8. package/packages/aikit-client/dist/index.js +1 -0
  9. package/packages/aikit-client/dist/mcp-client.d.ts +19 -0
  10. package/packages/aikit-client/dist/mcp-client.js +4 -0
  11. package/packages/aikit-client/dist/parsers.d.ts +35 -0
  12. package/packages/aikit-client/dist/parsers.js +2 -0
  13. package/packages/aikit-client/dist/types.d.ts +62 -0
  14. package/packages/aikit-client/dist/types.js +1 -0
  15. package/packages/analyzers/dist/blast-radius-analyzer.d.ts +19 -0
  16. package/packages/analyzers/dist/blast-radius-analyzer.js +6 -0
  17. package/packages/analyzers/dist/dependency-analyzer.d.ts +32 -0
  18. package/packages/analyzers/dist/dependency-analyzer.js +8 -0
  19. package/packages/analyzers/dist/diagram-generator.d.ts +16 -0
  20. package/packages/analyzers/dist/diagram-generator.js +2 -0
  21. package/packages/analyzers/dist/entry-point-analyzer.d.ts +40 -0
  22. package/packages/analyzers/dist/entry-point-analyzer.js +4 -0
  23. package/packages/analyzers/dist/index.d.ts +12 -0
  24. package/packages/analyzers/dist/index.js +1 -0
  25. package/packages/analyzers/dist/knowledge-producer.d.ts +40 -0
  26. package/packages/analyzers/dist/knowledge-producer.js +26 -0
  27. package/packages/analyzers/dist/pattern-analyzer.d.ts +15 -0
  28. package/packages/analyzers/dist/pattern-analyzer.js +2 -0
  29. package/packages/analyzers/dist/regex-call-graph.d.ts +10 -0
  30. package/packages/analyzers/dist/regex-call-graph.js +1 -0
  31. package/packages/analyzers/dist/structure-analyzer.d.ts +19 -0
  32. package/packages/analyzers/dist/structure-analyzer.js +4 -0
  33. package/packages/analyzers/dist/symbol-analyzer.d.ts +14 -0
  34. package/packages/analyzers/dist/symbol-analyzer.js +9 -0
  35. package/packages/analyzers/dist/ts-call-graph.d.ts +29 -0
  36. package/packages/analyzers/dist/ts-call-graph.js +1 -0
  37. package/packages/analyzers/dist/types.d.ts +110 -0
  38. package/packages/analyzers/dist/types.js +1 -0
  39. package/packages/chunker/dist/call-graph-extractor.d.ts +25 -0
  40. package/packages/chunker/dist/call-graph-extractor.js +1 -0
  41. package/packages/chunker/dist/chunker-factory.d.ts +19 -0
  42. package/packages/chunker/dist/chunker-factory.js +1 -0
  43. package/packages/chunker/dist/chunker.interface.d.ts +13 -0
  44. package/packages/chunker/dist/chunker.interface.js +1 -0
  45. package/packages/chunker/dist/code-chunker.d.ts +17 -0
  46. package/packages/chunker/dist/code-chunker.js +11 -0
  47. package/packages/chunker/dist/extractors/call-extractor.d.ts +24 -0
  48. package/packages/chunker/dist/extractors/call-extractor.js +1 -0
  49. package/packages/chunker/dist/extractors/entry-point-detector.d.ts +14 -0
  50. package/packages/chunker/dist/extractors/entry-point-detector.js +1 -0
  51. package/packages/chunker/dist/extractors/import-extractor.d.ts +14 -0
  52. package/packages/chunker/dist/extractors/import-extractor.js +1 -0
  53. package/packages/chunker/dist/extractors/pattern-detector.d.ts +14 -0
  54. package/packages/chunker/dist/extractors/pattern-detector.js +1 -0
  55. package/packages/chunker/dist/extractors/scope-resolver.d.ts +26 -0
  56. package/packages/chunker/dist/extractors/scope-resolver.js +1 -0
  57. package/packages/chunker/dist/extractors/symbol-extractor.d.ts +14 -0
  58. package/packages/chunker/dist/extractors/symbol-extractor.js +3 -0
  59. package/packages/chunker/dist/extractors/types.d.ts +44 -0
  60. package/packages/chunker/dist/extractors/types.js +1 -0
  61. package/packages/chunker/dist/generic-chunker.d.ts +15 -0
  62. package/packages/chunker/dist/generic-chunker.js +5 -0
  63. package/packages/chunker/dist/index.d.ts +19 -0
  64. package/packages/chunker/dist/index.js +1 -0
  65. package/packages/chunker/dist/markdown-chunker.d.ts +17 -0
  66. package/packages/chunker/dist/markdown-chunker.js +3 -0
  67. package/packages/chunker/dist/wasm/languages.d.ts +18 -0
  68. package/packages/chunker/dist/wasm/languages.js +1 -0
  69. package/packages/chunker/dist/wasm/query-executor.d.ts +70 -0
  70. package/packages/chunker/dist/wasm/query-executor.js +1 -0
  71. package/packages/chunker/dist/wasm/runtime.d.ts +44 -0
  72. package/packages/chunker/dist/wasm/runtime.js +1 -0
  73. package/packages/chunker/dist/wasm/types.d.ts +84 -0
  74. package/packages/chunker/dist/wasm/types.js +1 -0
  75. package/packages/chunker/dist/wasm-chunker.d.ts +23 -0
  76. package/packages/chunker/dist/wasm-chunker.js +6 -0
  77. package/packages/chunker/src/queries/go/calls.scm +11 -0
  78. package/packages/chunker/src/queries/go/entry-points.scm +20 -0
  79. package/packages/chunker/src/queries/go/imports.scm +6 -0
  80. package/packages/chunker/src/queries/go/patterns.scm +25 -0
  81. package/packages/chunker/src/queries/go/symbols.scm +26 -0
  82. package/packages/chunker/src/queries/java/calls.scm +10 -0
  83. package/packages/chunker/src/queries/java/entry-points.scm +27 -0
  84. package/packages/chunker/src/queries/java/imports.scm +11 -0
  85. package/packages/chunker/src/queries/java/patterns.scm +27 -0
  86. package/packages/chunker/src/queries/java/symbols.scm +28 -0
  87. package/packages/chunker/src/queries/javascript/calls.scm +21 -0
  88. package/packages/chunker/src/queries/javascript/entry-points.scm +31 -0
  89. package/packages/chunker/src/queries/javascript/imports.scm +32 -0
  90. package/packages/chunker/src/queries/javascript/patterns.scm +28 -0
  91. package/packages/chunker/src/queries/javascript/symbols.scm +52 -0
  92. package/packages/chunker/src/queries/python/calls.scm +11 -0
  93. package/packages/chunker/src/queries/python/entry-points.scm +21 -0
  94. package/packages/chunker/src/queries/python/imports.scm +14 -0
  95. package/packages/chunker/src/queries/python/patterns.scm +25 -0
  96. package/packages/chunker/src/queries/python/symbols.scm +17 -0
  97. package/packages/chunker/src/queries/rust/calls.scm +20 -0
  98. package/packages/chunker/src/queries/rust/entry-points.scm +7 -0
  99. package/packages/chunker/src/queries/rust/imports.scm +26 -0
  100. package/packages/chunker/src/queries/rust/patterns.scm +18 -0
  101. package/packages/chunker/src/queries/rust/symbols.scm +73 -0
  102. package/packages/chunker/src/queries/typescript/calls.scm +21 -0
  103. package/packages/chunker/src/queries/typescript/entry-points.scm +48 -0
  104. package/packages/chunker/src/queries/typescript/imports.scm +35 -0
  105. package/packages/chunker/src/queries/typescript/patterns.scm +47 -0
  106. package/packages/chunker/src/queries/typescript/symbols.scm +79 -0
  107. package/packages/chunker/wasm/tree-sitter-c.wasm +0 -0
  108. package/packages/chunker/wasm/tree-sitter-c_sharp.wasm +0 -0
  109. package/packages/chunker/wasm/tree-sitter-cpp.wasm +0 -0
  110. package/packages/chunker/wasm/tree-sitter-go.wasm +0 -0
  111. package/packages/chunker/wasm/tree-sitter-java.wasm +0 -0
  112. package/packages/chunker/wasm/tree-sitter-javascript.wasm +0 -0
  113. package/packages/chunker/wasm/tree-sitter-kotlin.wasm +0 -0
  114. package/packages/chunker/wasm/tree-sitter-php.wasm +0 -0
  115. package/packages/chunker/wasm/tree-sitter-python.wasm +0 -0
  116. package/packages/chunker/wasm/tree-sitter-ruby.wasm +0 -0
  117. package/packages/chunker/wasm/tree-sitter-rust.wasm +0 -0
  118. package/packages/chunker/wasm/tree-sitter-scala.wasm +0 -0
  119. package/packages/chunker/wasm/tree-sitter-swift.wasm +0 -0
  120. package/packages/chunker/wasm/tree-sitter-typescript.wasm +0 -0
  121. package/packages/chunker/wasm/tree-sitter.wasm +0 -0
  122. package/packages/cli/dist/aikit-init.d.ts +54 -0
  123. package/packages/cli/dist/aikit-init.js +1 -0
  124. package/packages/cli/dist/commands/analyze.d.ts +6 -0
  125. package/packages/cli/dist/commands/analyze.js +2 -0
  126. package/packages/cli/dist/commands/context-cmds.d.ts +6 -0
  127. package/packages/cli/dist/commands/context-cmds.js +1 -0
  128. package/packages/cli/dist/commands/environment.d.ts +6 -0
  129. package/packages/cli/dist/commands/environment.js +1 -0
  130. package/packages/cli/dist/commands/execution.d.ts +6 -0
  131. package/packages/cli/dist/commands/execution.js +1 -0
  132. package/packages/cli/dist/commands/flow.d.ts +6 -0
  133. package/packages/cli/dist/commands/flow.js +1 -0
  134. package/packages/cli/dist/commands/graph.d.ts +6 -0
  135. package/packages/cli/dist/commands/graph.js +6 -0
  136. package/packages/cli/dist/commands/init/adapters.d.ts +28 -0
  137. package/packages/cli/dist/commands/init/adapters.js +1 -0
  138. package/packages/cli/dist/commands/init/config.d.ts +10 -0
  139. package/packages/cli/dist/commands/init/config.js +3 -0
  140. package/packages/cli/dist/commands/init/constants.d.ts +41 -0
  141. package/packages/cli/dist/commands/init/constants.js +1 -0
  142. package/packages/cli/dist/commands/init/curated.d.ts +7 -0
  143. package/packages/cli/dist/commands/init/curated.js +1 -0
  144. package/packages/cli/dist/commands/init/frontmatter.d.ts +54 -0
  145. package/packages/cli/dist/commands/init/frontmatter.js +2 -0
  146. package/packages/cli/dist/commands/init/index.d.ts +36 -0
  147. package/packages/cli/dist/commands/init/index.js +5 -0
  148. package/packages/cli/dist/commands/init/manifest.d.ts +71 -0
  149. package/packages/cli/dist/commands/init/manifest.js +1 -0
  150. package/packages/cli/dist/commands/init/scaffold.d.ts +46 -0
  151. package/packages/cli/dist/commands/init/scaffold.js +1 -0
  152. package/packages/cli/dist/commands/init/templates.d.ts +9 -0
  153. package/packages/cli/dist/commands/init/templates.js +194 -0
  154. package/packages/cli/dist/commands/init/user.d.ts +61 -0
  155. package/packages/cli/dist/commands/init/user.js +5 -0
  156. package/packages/cli/dist/commands/knowledge.d.ts +6 -0
  157. package/packages/cli/dist/commands/knowledge.js +1 -0
  158. package/packages/cli/dist/commands/search.d.ts +6 -0
  159. package/packages/cli/dist/commands/search.js +1 -0
  160. package/packages/cli/dist/commands/system.d.ts +6 -0
  161. package/packages/cli/dist/commands/system.js +4 -0
  162. package/packages/cli/dist/commands/upgrade.d.ts +6 -0
  163. package/packages/cli/dist/commands/upgrade.js +1 -0
  164. package/packages/cli/dist/commands/workspace.d.ts +6 -0
  165. package/packages/cli/dist/commands/workspace.js +1 -0
  166. package/packages/cli/dist/context.d.ts +7 -0
  167. package/packages/cli/dist/context.js +1 -0
  168. package/packages/cli/dist/helpers.d.ts +55 -0
  169. package/packages/cli/dist/helpers.js +5 -0
  170. package/packages/cli/dist/index.d.ts +10 -0
  171. package/packages/cli/dist/index.js +3 -0
  172. package/packages/cli/dist/types.d.ts +9 -0
  173. package/packages/cli/dist/types.js +1 -0
  174. package/packages/core/dist/constants.d.ts +74 -0
  175. package/packages/core/dist/constants.js +1 -0
  176. package/packages/core/dist/content-detector.d.ts +13 -0
  177. package/packages/core/dist/content-detector.js +1 -0
  178. package/packages/core/dist/errors.d.ts +20 -0
  179. package/packages/core/dist/errors.js +1 -0
  180. package/packages/core/dist/global-registry.d.ts +63 -0
  181. package/packages/core/dist/global-registry.js +1 -0
  182. package/packages/core/dist/index.d.ts +7 -0
  183. package/packages/core/dist/index.js +1 -0
  184. package/packages/core/dist/logger.d.ts +32 -0
  185. package/packages/core/dist/logger.js +1 -0
  186. package/packages/core/dist/types.d.ts +133 -0
  187. package/packages/core/dist/types.js +1 -0
  188. package/packages/dashboard/dist/assets/index-BjA4YODs.js +21 -0
  189. package/packages/dashboard/dist/assets/index-BjA4YODs.js.map +1 -0
  190. package/packages/dashboard/dist/assets/index-CHpVij2M.css +1 -0
  191. package/packages/dashboard/dist/index.html +18 -0
  192. package/packages/elicitation/dist/build.d.ts +14 -0
  193. package/packages/elicitation/dist/build.js +1 -0
  194. package/packages/elicitation/dist/fields.d.ts +32 -0
  195. package/packages/elicitation/dist/fields.js +1 -0
  196. package/packages/elicitation/dist/index.d.ts +5 -0
  197. package/packages/elicitation/dist/index.js +1 -0
  198. package/packages/elicitation/dist/normalize.d.ts +15 -0
  199. package/packages/elicitation/dist/normalize.js +1 -0
  200. package/packages/elicitation/dist/types.d.ts +88 -0
  201. package/packages/elicitation/dist/types.js +1 -0
  202. package/packages/embeddings/dist/embedder.interface.d.ts +26 -0
  203. package/packages/embeddings/dist/embedder.interface.js +1 -0
  204. package/packages/embeddings/dist/index.d.ts +3 -0
  205. package/packages/embeddings/dist/index.js +1 -0
  206. package/packages/embeddings/dist/onnx-embedder.d.ts +22 -0
  207. package/packages/embeddings/dist/onnx-embedder.js +1 -0
  208. package/packages/enterprise-bridge/dist/cache.d.ts +28 -0
  209. package/packages/enterprise-bridge/dist/cache.js +1 -0
  210. package/packages/enterprise-bridge/dist/er-client.d.ts +37 -0
  211. package/packages/enterprise-bridge/dist/er-client.js +1 -0
  212. package/packages/enterprise-bridge/dist/evolution-collector.d.ts +62 -0
  213. package/packages/enterprise-bridge/dist/evolution-collector.js +1 -0
  214. package/packages/enterprise-bridge/dist/index.d.ts +8 -0
  215. package/packages/enterprise-bridge/dist/index.js +1 -0
  216. package/packages/enterprise-bridge/dist/policy-store.d.ts +45 -0
  217. package/packages/enterprise-bridge/dist/policy-store.js +1 -0
  218. package/packages/enterprise-bridge/dist/push-adapter.d.ts +23 -0
  219. package/packages/enterprise-bridge/dist/push-adapter.js +1 -0
  220. package/packages/enterprise-bridge/dist/result-merger.d.ts +14 -0
  221. package/packages/enterprise-bridge/dist/result-merger.js +1 -0
  222. package/packages/enterprise-bridge/dist/types.d.ts +81 -0
  223. package/packages/enterprise-bridge/dist/types.js +1 -0
  224. package/packages/flows/dist/adapters/claude-plugin.d.ts +12 -0
  225. package/packages/flows/dist/adapters/claude-plugin.js +1 -0
  226. package/packages/flows/dist/adapters/copilot.d.ts +10 -0
  227. package/packages/flows/dist/adapters/copilot.js +1 -0
  228. package/packages/flows/dist/adapters/index.d.ts +11 -0
  229. package/packages/flows/dist/adapters/index.js +1 -0
  230. package/packages/flows/dist/adapters/native.d.ts +10 -0
  231. package/packages/flows/dist/adapters/native.js +1 -0
  232. package/packages/flows/dist/builtins.d.ts +16 -0
  233. package/packages/flows/dist/builtins.js +1 -0
  234. package/packages/flows/dist/foundation.d.ts +20 -0
  235. package/packages/flows/dist/foundation.js +11 -0
  236. package/packages/flows/dist/git.d.ts +34 -0
  237. package/packages/flows/dist/git.js +1 -0
  238. package/packages/flows/dist/index.d.ts +12 -0
  239. package/packages/flows/dist/index.js +1 -0
  240. package/packages/flows/dist/loader.d.ts +13 -0
  241. package/packages/flows/dist/loader.js +2 -0
  242. package/packages/flows/dist/registry.d.ts +23 -0
  243. package/packages/flows/dist/registry.js +1 -0
  244. package/packages/flows/dist/state-machine.d.ts +23 -0
  245. package/packages/flows/dist/state-machine.js +1 -0
  246. package/packages/flows/dist/symlinks.d.ts +17 -0
  247. package/packages/flows/dist/symlinks.js +1 -0
  248. package/packages/flows/dist/types.d.ts +112 -0
  249. package/packages/flows/dist/types.js +1 -0
  250. package/packages/indexer/dist/file-hasher.d.ts +13 -0
  251. package/packages/indexer/dist/file-hasher.js +1 -0
  252. package/packages/indexer/dist/filesystem-crawler.d.ts +29 -0
  253. package/packages/indexer/dist/filesystem-crawler.js +1 -0
  254. package/packages/indexer/dist/graph-extractor.d.ts +18 -0
  255. package/packages/indexer/dist/graph-extractor.js +1 -0
  256. package/packages/indexer/dist/hash-cache.d.ts +24 -0
  257. package/packages/indexer/dist/hash-cache.js +1 -0
  258. package/packages/indexer/dist/incremental-indexer.d.ts +56 -0
  259. package/packages/indexer/dist/incremental-indexer.js +1 -0
  260. package/packages/indexer/dist/index.d.ts +6 -0
  261. package/packages/indexer/dist/index.js +1 -0
  262. package/packages/present/dist/index.html +709 -0
  263. package/packages/server/dist/api.d.ts +3 -0
  264. package/packages/server/dist/api.js +1 -0
  265. package/packages/server/dist/auto-gc.d.ts +30 -0
  266. package/packages/server/dist/auto-gc.js +1 -0
  267. package/packages/server/dist/completions.d.ts +14 -0
  268. package/packages/server/dist/completions.js +1 -0
  269. package/packages/server/dist/config.d.ts +14 -0
  270. package/packages/server/dist/config.js +1 -0
  271. package/packages/server/dist/cross-workspace.d.ts +43 -0
  272. package/packages/server/dist/cross-workspace.js +1 -0
  273. package/packages/server/dist/curated-manager.d.ts +92 -0
  274. package/packages/server/dist/curated-manager.js +5 -0
  275. package/packages/server/dist/dashboard-static.d.ts +27 -0
  276. package/packages/server/dist/dashboard-static.js +1 -0
  277. package/packages/server/dist/elicitor.d.ts +18 -0
  278. package/packages/server/dist/elicitor.js +1 -0
  279. package/packages/server/dist/index.d.ts +1 -0
  280. package/packages/server/dist/index.js +1 -0
  281. package/packages/server/dist/mcp-logging.d.ts +11 -0
  282. package/packages/server/dist/mcp-logging.js +1 -0
  283. package/packages/server/dist/output-schemas.d.ts +242 -0
  284. package/packages/server/dist/output-schemas.js +1 -0
  285. package/packages/server/dist/prompts.d.ts +13 -0
  286. package/packages/server/dist/prompts.js +13 -0
  287. package/packages/server/dist/replay-interceptor.d.ts +23 -0
  288. package/packages/server/dist/replay-interceptor.js +1 -0
  289. package/packages/server/dist/resource-links.d.ts +34 -0
  290. package/packages/server/dist/resource-links.js +1 -0
  291. package/packages/server/dist/resources/curated-resources.d.ts +13 -0
  292. package/packages/server/dist/resources/curated-resources.js +2 -0
  293. package/packages/server/dist/resources/resource-notifier.d.ts +45 -0
  294. package/packages/server/dist/resources/resource-notifier.js +1 -0
  295. package/packages/server/dist/resources/resources.d.ts +8 -0
  296. package/packages/server/dist/resources/resources.js +2 -0
  297. package/packages/server/dist/sampling.d.ts +41 -0
  298. package/packages/server/dist/sampling.js +2 -0
  299. package/packages/server/dist/server.d.ts +47 -0
  300. package/packages/server/dist/server.js +3 -0
  301. package/packages/server/dist/structured-content-guard.d.ts +26 -0
  302. package/packages/server/dist/structured-content-guard.js +1 -0
  303. package/packages/server/dist/task-manager.d.ts +40 -0
  304. package/packages/server/dist/task-manager.js +1 -0
  305. package/packages/server/dist/tool-metadata.d.ts +38 -0
  306. package/packages/server/dist/tool-metadata.js +1 -0
  307. package/packages/server/dist/tool-prefix.d.ts +12 -0
  308. package/packages/server/dist/tool-prefix.js +1 -0
  309. package/packages/server/dist/tools/analyze.tools.d.ts +14 -0
  310. package/packages/server/dist/tools/analyze.tools.js +8 -0
  311. package/packages/server/dist/tools/audit.tool.d.ts +8 -0
  312. package/packages/server/dist/tools/audit.tool.js +1 -0
  313. package/packages/server/dist/tools/brainstorm.tool.d.ts +7 -0
  314. package/packages/server/dist/tools/brainstorm.tool.js +9 -0
  315. package/packages/server/dist/tools/bridge.tools.d.ts +34 -0
  316. package/packages/server/dist/tools/bridge.tools.js +15 -0
  317. package/packages/server/dist/tools/context.tools.d.ts +15 -0
  318. package/packages/server/dist/tools/context.tools.js +10 -0
  319. package/packages/server/dist/tools/evolution.tools.d.ts +7 -0
  320. package/packages/server/dist/tools/evolution.tools.js +5 -0
  321. package/packages/server/dist/tools/execution.tools.d.ts +14 -0
  322. package/packages/server/dist/tools/execution.tools.js +4 -0
  323. package/packages/server/dist/tools/flow.tools.d.ts +7 -0
  324. package/packages/server/dist/tools/flow.tools.js +1 -0
  325. package/packages/server/dist/tools/forge.tools.d.ts +13 -0
  326. package/packages/server/dist/tools/forge.tools.js +10 -0
  327. package/packages/server/dist/tools/forget.tool.d.ts +8 -0
  328. package/packages/server/dist/tools/forget.tool.js +1 -0
  329. package/packages/server/dist/tools/graph.tool.d.ts +7 -0
  330. package/packages/server/dist/tools/graph.tool.js +5 -0
  331. package/packages/server/dist/tools/infra.tools.d.ts +10 -0
  332. package/packages/server/dist/tools/infra.tools.js +5 -0
  333. package/packages/server/dist/tools/list.tool.d.ts +7 -0
  334. package/packages/server/dist/tools/list.tool.js +2 -0
  335. package/packages/server/dist/tools/lookup.tool.d.ts +7 -0
  336. package/packages/server/dist/tools/lookup.tool.js +3 -0
  337. package/packages/server/dist/tools/manipulation.tools.d.ts +10 -0
  338. package/packages/server/dist/tools/manipulation.tools.js +4 -0
  339. package/packages/server/dist/tools/onboard.tool.d.ts +9 -0
  340. package/packages/server/dist/tools/onboard.tool.js +2 -0
  341. package/packages/server/dist/tools/persistence.tools.d.ts +10 -0
  342. package/packages/server/dist/tools/persistence.tools.js +5 -0
  343. package/packages/server/dist/tools/policy.tools.d.ts +7 -0
  344. package/packages/server/dist/tools/policy.tools.js +3 -0
  345. package/packages/server/dist/tools/present/browser.d.ts +4 -0
  346. package/packages/server/dist/tools/present/browser.js +93 -0
  347. package/packages/server/dist/tools/present/helpers.d.ts +18 -0
  348. package/packages/server/dist/tools/present/helpers.js +1 -0
  349. package/packages/server/dist/tools/present/html.d.ts +18 -0
  350. package/packages/server/dist/tools/present/html.js +5 -0
  351. package/packages/server/dist/tools/present/index.d.ts +2 -0
  352. package/packages/server/dist/tools/present/index.js +1 -0
  353. package/packages/server/dist/tools/present/markdown.d.ts +17 -0
  354. package/packages/server/dist/tools/present/markdown.js +8 -0
  355. package/packages/server/dist/tools/present/templates.d.ts +14 -0
  356. package/packages/server/dist/tools/present/templates.js +472 -0
  357. package/packages/server/dist/tools/present/tool.d.ts +27 -0
  358. package/packages/server/dist/tools/present/tool.js +19 -0
  359. package/packages/server/dist/tools/present-blocks.d.ts +46 -0
  360. package/packages/server/dist/tools/present-blocks.js +27 -0
  361. package/packages/server/dist/tools/present-charts.d.ts +31 -0
  362. package/packages/server/dist/tools/present-charts.js +34 -0
  363. package/packages/server/dist/tools/present-theme.d.ts +14 -0
  364. package/packages/server/dist/tools/present-theme.js +395 -0
  365. package/packages/server/dist/tools/present-utils.d.ts +11 -0
  366. package/packages/server/dist/tools/present-utils.js +1 -0
  367. package/packages/server/dist/tools/present.tool.d.ts +2 -0
  368. package/packages/server/dist/tools/present.tool.js +1 -0
  369. package/packages/server/dist/tools/produce.tool.d.ts +7 -0
  370. package/packages/server/dist/tools/produce.tool.js +4 -0
  371. package/packages/server/dist/tools/read.tool.d.ts +7 -0
  372. package/packages/server/dist/tools/read.tool.js +2 -0
  373. package/packages/server/dist/tools/reindex.tool.d.ts +11 -0
  374. package/packages/server/dist/tools/reindex.tool.js +3 -0
  375. package/packages/server/dist/tools/remember.tool.d.ts +9 -0
  376. package/packages/server/dist/tools/remember.tool.js +4 -0
  377. package/packages/server/dist/tools/replay.tool.d.ts +6 -0
  378. package/packages/server/dist/tools/replay.tool.js +3 -0
  379. package/packages/server/dist/tools/restore.tool.d.ts +6 -0
  380. package/packages/server/dist/tools/restore.tool.js +3 -0
  381. package/packages/server/dist/tools/search.tool.d.ts +11 -0
  382. package/packages/server/dist/tools/search.tool.js +10 -0
  383. package/packages/server/dist/tools/status.tool.d.ts +20 -0
  384. package/packages/server/dist/tools/status.tool.js +3 -0
  385. package/packages/server/dist/tools/update.tool.d.ts +8 -0
  386. package/packages/server/dist/tools/update.tool.js +1 -0
  387. package/packages/server/dist/tools/utility.tools.d.ts +15 -0
  388. package/packages/server/dist/tools/utility.tools.js +13 -0
  389. package/packages/server/dist/version-check.d.ts +32 -0
  390. package/packages/server/dist/version-check.js +1 -0
  391. package/packages/store/dist/graph-store.interface.d.ts +118 -0
  392. package/packages/store/dist/graph-store.interface.js +1 -0
  393. package/packages/store/dist/index.d.ts +6 -0
  394. package/packages/store/dist/index.js +1 -0
  395. package/packages/store/dist/lance-store.d.ts +44 -0
  396. package/packages/store/dist/lance-store.js +1 -0
  397. package/packages/store/dist/sqlite-graph-store.d.ts +45 -0
  398. package/packages/store/dist/sqlite-graph-store.js +58 -0
  399. package/packages/store/dist/store-factory.d.ts +12 -0
  400. package/packages/store/dist/store-factory.js +1 -0
  401. package/packages/store/dist/store.interface.d.ts +54 -0
  402. package/packages/store/dist/store.interface.js +1 -0
  403. package/packages/tools/dist/audit.d.ts +65 -0
  404. package/packages/tools/dist/audit.js +6 -0
  405. package/packages/tools/dist/batch.d.ts +23 -0
  406. package/packages/tools/dist/batch.js +1 -0
  407. package/packages/tools/dist/changelog.d.ts +36 -0
  408. package/packages/tools/dist/changelog.js +2 -0
  409. package/packages/tools/dist/check.d.ts +48 -0
  410. package/packages/tools/dist/check.js +2 -0
  411. package/packages/tools/dist/checkpoint.d.ts +19 -0
  412. package/packages/tools/dist/checkpoint.js +1 -0
  413. package/packages/tools/dist/codemod.d.ts +39 -0
  414. package/packages/tools/dist/codemod.js +2 -0
  415. package/packages/tools/dist/compact.d.ts +41 -0
  416. package/packages/tools/dist/compact.js +3 -0
  417. package/packages/tools/dist/config-extractor.d.ts +9 -0
  418. package/packages/tools/dist/config-extractor.js +7 -0
  419. package/packages/tools/dist/data-transform.d.ts +12 -0
  420. package/packages/tools/dist/data-transform.js +1 -0
  421. package/packages/tools/dist/dead-symbols.d.ts +28 -0
  422. package/packages/tools/dist/dead-symbols.js +2 -0
  423. package/packages/tools/dist/delegate.d.ts +36 -0
  424. package/packages/tools/dist/delegate.js +1 -0
  425. package/packages/tools/dist/diagram-builder.d.ts +9 -0
  426. package/packages/tools/dist/diagram-builder.js +9 -0
  427. package/packages/tools/dist/diff-parse.d.ts +28 -0
  428. package/packages/tools/dist/diff-parse.js +3 -0
  429. package/packages/tools/dist/digest.d.ts +50 -0
  430. package/packages/tools/dist/digest.js +6 -0
  431. package/packages/tools/dist/dogfood-log.d.ts +49 -0
  432. package/packages/tools/dist/dogfood-log.js +2 -0
  433. package/packages/tools/dist/encode.d.ts +16 -0
  434. package/packages/tools/dist/encode.js +1 -0
  435. package/packages/tools/dist/env-info.d.ts +30 -0
  436. package/packages/tools/dist/env-info.js +1 -0
  437. package/packages/tools/dist/eval.d.ts +15 -0
  438. package/packages/tools/dist/eval.js +2 -0
  439. package/packages/tools/dist/evidence-map.d.ts +92 -0
  440. package/packages/tools/dist/evidence-map.js +2 -0
  441. package/packages/tools/dist/file-cache.d.ts +41 -0
  442. package/packages/tools/dist/file-cache.js +3 -0
  443. package/packages/tools/dist/file-summary.d.ts +52 -0
  444. package/packages/tools/dist/file-summary.js +2 -0
  445. package/packages/tools/dist/file-walk.d.ts +6 -0
  446. package/packages/tools/dist/file-walk.js +1 -0
  447. package/packages/tools/dist/find-examples.d.ts +29 -0
  448. package/packages/tools/dist/find-examples.js +3 -0
  449. package/packages/tools/dist/find.d.ts +49 -0
  450. package/packages/tools/dist/find.js +1 -0
  451. package/packages/tools/dist/forge-classify.d.ts +44 -0
  452. package/packages/tools/dist/forge-classify.js +2 -0
  453. package/packages/tools/dist/forge-ground.d.ts +61 -0
  454. package/packages/tools/dist/forge-ground.js +1 -0
  455. package/packages/tools/dist/git-context.d.ts +25 -0
  456. package/packages/tools/dist/git-context.js +3 -0
  457. package/packages/tools/dist/graph-query.d.ts +86 -0
  458. package/packages/tools/dist/graph-query.js +1 -0
  459. package/packages/tools/dist/guide.d.ts +25 -0
  460. package/packages/tools/dist/guide.js +1 -0
  461. package/packages/tools/dist/health.d.ts +16 -0
  462. package/packages/tools/dist/health.js +2 -0
  463. package/packages/tools/dist/http-request.d.ts +25 -0
  464. package/packages/tools/dist/http-request.js +1 -0
  465. package/packages/tools/dist/index.d.ts +57 -0
  466. package/packages/tools/dist/index.js +1 -0
  467. package/packages/tools/dist/lane.d.ts +41 -0
  468. package/packages/tools/dist/lane.js +6 -0
  469. package/packages/tools/dist/measure.d.ts +42 -0
  470. package/packages/tools/dist/measure.js +2 -0
  471. package/packages/tools/dist/onboard-utils.d.ts +12 -0
  472. package/packages/tools/dist/onboard-utils.js +1 -0
  473. package/packages/tools/dist/onboard.d.ts +50 -0
  474. package/packages/tools/dist/onboard.js +18 -0
  475. package/packages/tools/dist/parse-output.d.ts +82 -0
  476. package/packages/tools/dist/parse-output.js +2 -0
  477. package/packages/tools/dist/path-resolver.d.ts +14 -0
  478. package/packages/tools/dist/path-resolver.js +1 -0
  479. package/packages/tools/dist/process-manager.d.ts +20 -0
  480. package/packages/tools/dist/process-manager.js +1 -0
  481. package/packages/tools/dist/queue.d.ts +40 -0
  482. package/packages/tools/dist/queue.js +1 -0
  483. package/packages/tools/dist/regex-test.d.ts +33 -0
  484. package/packages/tools/dist/regex-test.js +1 -0
  485. package/packages/tools/dist/regex-utils.d.ts +8 -0
  486. package/packages/tools/dist/regex-utils.js +1 -0
  487. package/packages/tools/dist/rename.d.ts +31 -0
  488. package/packages/tools/dist/rename.js +2 -0
  489. package/packages/tools/dist/replay.d.ts +59 -0
  490. package/packages/tools/dist/replay.js +4 -0
  491. package/packages/tools/dist/response-envelope.d.ts +43 -0
  492. package/packages/tools/dist/response-envelope.js +1 -0
  493. package/packages/tools/dist/restore-points.d.ts +22 -0
  494. package/packages/tools/dist/restore-points.js +1 -0
  495. package/packages/tools/dist/schema-validate.d.ts +25 -0
  496. package/packages/tools/dist/schema-validate.js +1 -0
  497. package/packages/tools/dist/scope-map.d.ts +51 -0
  498. package/packages/tools/dist/scope-map.js +1 -0
  499. package/packages/tools/dist/snippet.d.ts +35 -0
  500. package/packages/tools/dist/snippet.js +1 -0
  501. package/packages/tools/dist/stash.d.ts +14 -0
  502. package/packages/tools/dist/stash.js +1 -0
  503. package/packages/tools/dist/stratum-card.d.ts +30 -0
  504. package/packages/tools/dist/stratum-card.js +4 -0
  505. package/packages/tools/dist/symbol.d.ts +45 -0
  506. package/packages/tools/dist/symbol.js +3 -0
  507. package/packages/tools/dist/synthesis-engine.d.ts +13 -0
  508. package/packages/tools/dist/synthesis-engine.js +6 -0
  509. package/packages/tools/dist/test-run.d.ts +28 -0
  510. package/packages/tools/dist/test-run.js +2 -0
  511. package/packages/tools/dist/text-utils.d.ts +24 -0
  512. package/packages/tools/dist/text-utils.js +2 -0
  513. package/packages/tools/dist/time-utils.d.ts +20 -0
  514. package/packages/tools/dist/time-utils.js +1 -0
  515. package/packages/tools/dist/trace.d.ts +29 -0
  516. package/packages/tools/dist/trace.js +2 -0
  517. package/packages/tools/dist/truncation.d.ts +33 -0
  518. package/packages/tools/dist/truncation.js +7 -0
  519. package/packages/tools/dist/watch.d.ts +32 -0
  520. package/packages/tools/dist/watch.js +1 -0
  521. package/packages/tools/dist/web-fetch.d.ts +47 -0
  522. package/packages/tools/dist/web-fetch.js +8 -0
  523. package/packages/tools/dist/web-search.d.ts +25 -0
  524. package/packages/tools/dist/web-search.js +1 -0
  525. package/packages/tools/dist/workset.d.ts +47 -0
  526. package/packages/tools/dist/workset.js +1 -0
  527. package/packages/tui/dist/App-DU2KEylW.js +2 -0
  528. package/packages/tui/dist/App.d.ts +13 -0
  529. package/packages/tui/dist/App.js +2 -0
  530. package/packages/tui/dist/CuratedPanel-BIamXLNy.js +2 -0
  531. package/packages/tui/dist/LogPanel-Bo8a8QXB.js +3 -0
  532. package/packages/tui/dist/SearchPanel-CpJGczAc.js +2 -0
  533. package/packages/tui/dist/StatusPanel-BAbUxyqQ.js +2 -0
  534. package/packages/tui/dist/chunk-D6axbAb-.js +2 -0
  535. package/packages/tui/dist/devtools-DMOZMn70.js +7 -0
  536. package/packages/tui/dist/hooks/useKBClient.d.ts +9 -0
  537. package/packages/tui/dist/hooks/useKBClient.js +2 -0
  538. package/packages/tui/dist/hooks/usePolling.d.ts +8 -0
  539. package/packages/tui/dist/hooks/usePolling.js +2 -0
  540. package/packages/tui/dist/index-BXafekwr.d.ts +64 -0
  541. package/packages/tui/dist/index.d.ts +7 -0
  542. package/packages/tui/dist/index.js +2 -0
  543. package/packages/tui/dist/jsx-runtime-y6Gdq5PZ.js +294 -0
  544. package/packages/tui/dist/panels/CuratedPanel.d.ts +7 -0
  545. package/packages/tui/dist/panels/CuratedPanel.js +2 -0
  546. package/packages/tui/dist/panels/LogPanel.d.ts +7 -0
  547. package/packages/tui/dist/panels/LogPanel.js +2 -0
  548. package/packages/tui/dist/panels/SearchPanel.d.ts +7 -0
  549. package/packages/tui/dist/panels/SearchPanel.js +2 -0
  550. package/packages/tui/dist/panels/StatusPanel.d.ts +7 -0
  551. package/packages/tui/dist/panels/StatusPanel.js +2 -0
  552. package/packages/tui/dist/react-D__J1GQe.js +24 -0
  553. package/packages/tui/dist/useKBClient-C35iA4uG.js +2 -0
  554. package/packages/tui/dist/usePolling-BbjnRWgx.js +2 -0
  555. package/scaffold/README.md +192 -0
  556. package/scaffold/adapters/claude-code.mjs +56 -0
  557. package/scaffold/adapters/copilot.mjs +270 -0
  558. package/scaffold/definitions/agents.mjs +189 -0
  559. package/scaffold/definitions/bodies.mjs +487 -0
  560. package/scaffold/definitions/hooks.mjs +43 -0
  561. package/scaffold/definitions/models.mjs +56 -0
  562. package/scaffold/definitions/plugins.mjs +38 -0
  563. package/scaffold/definitions/prompts.mjs +145 -0
  564. package/scaffold/definitions/protocols.mjs +679 -0
  565. package/scaffold/definitions/tools.mjs +229 -0
  566. package/scaffold/flows/aikit-advanced/flow.json +60 -0
  567. package/scaffold/flows/aikit-advanced/skills/execute/SKILL.md +124 -0
  568. package/scaffold/flows/aikit-advanced/skills/plan/SKILL.md +100 -0
  569. package/scaffold/flows/aikit-advanced/skills/spec/SKILL.md +100 -0
  570. package/scaffold/flows/aikit-advanced/skills/task/SKILL.md +99 -0
  571. package/scaffold/flows/aikit-advanced/skills/verify/SKILL.md +122 -0
  572. package/scaffold/flows/aikit-basic/flow.json +36 -0
  573. package/scaffold/flows/aikit-basic/skills/assess/SKILL.md +82 -0
  574. package/scaffold/flows/aikit-basic/skills/implement/SKILL.md +105 -0
  575. package/scaffold/flows/aikit-basic/skills/verify/SKILL.md +96 -0
  576. package/scaffold/general/agents/Architect-Reviewer-Alpha.agent.md +21 -0
  577. package/scaffold/general/agents/Architect-Reviewer-Beta.agent.md +21 -0
  578. package/scaffold/general/agents/Code-Reviewer-Alpha.agent.md +12 -0
  579. package/scaffold/general/agents/Code-Reviewer-Beta.agent.md +12 -0
  580. package/scaffold/general/agents/Debugger.agent.md +34 -0
  581. package/scaffold/general/agents/Documenter.agent.md +53 -0
  582. package/scaffold/general/agents/Explorer.agent.md +63 -0
  583. package/scaffold/general/agents/Frontend.agent.md +29 -0
  584. package/scaffold/general/agents/Implementer.agent.md +33 -0
  585. package/scaffold/general/agents/Orchestrator.agent.md +149 -0
  586. package/scaffold/general/agents/Planner.agent.md +79 -0
  587. package/scaffold/general/agents/README.md +57 -0
  588. package/scaffold/general/agents/Refactor.agent.md +36 -0
  589. package/scaffold/general/agents/Researcher-Alpha.agent.md +20 -0
  590. package/scaffold/general/agents/Researcher-Beta.agent.md +20 -0
  591. package/scaffold/general/agents/Researcher-Delta.agent.md +20 -0
  592. package/scaffold/general/agents/Researcher-Gamma.agent.md +20 -0
  593. package/scaffold/general/agents/Security.agent.md +55 -0
  594. package/scaffold/general/agents/_shared/architect-reviewer-base.md +60 -0
  595. package/scaffold/general/agents/_shared/code-agent-base.md +262 -0
  596. package/scaffold/general/agents/_shared/code-reviewer-base.md +64 -0
  597. package/scaffold/general/agents/_shared/decision-protocol.md +27 -0
  598. package/scaffold/general/agents/_shared/forge-protocol.md +90 -0
  599. package/scaffold/general/agents/_shared/researcher-base.md +101 -0
  600. package/scaffold/general/agents/templates/adr-template.md +28 -0
  601. package/scaffold/general/agents/templates/execution-state.md +26 -0
  602. package/scaffold/general/prompts/ask.prompt.md +21 -0
  603. package/scaffold/general/prompts/debug.prompt.md +25 -0
  604. package/scaffold/general/prompts/design.prompt.md +23 -0
  605. package/scaffold/general/prompts/implement.prompt.md +26 -0
  606. package/scaffold/general/prompts/plan.prompt.md +25 -0
  607. package/scaffold/general/prompts/review.prompt.md +32 -0
  608. package/scaffold/general/skills/adr-skill/SKILL.md +329 -0
  609. package/scaffold/general/skills/adr-skill/assets/templates/adr-madr.md +89 -0
  610. package/scaffold/general/skills/adr-skill/assets/templates/adr-readme.md +20 -0
  611. package/scaffold/general/skills/adr-skill/assets/templates/adr-simple.md +46 -0
  612. package/scaffold/general/skills/adr-skill/references/adr-conventions.md +95 -0
  613. package/scaffold/general/skills/adr-skill/references/examples.md +193 -0
  614. package/scaffold/general/skills/adr-skill/references/review-checklist.md +77 -0
  615. package/scaffold/general/skills/adr-skill/references/template-variants.md +52 -0
  616. package/scaffold/general/skills/adr-skill/scripts/bootstrap_adr.js +259 -0
  617. package/scaffold/general/skills/adr-skill/scripts/new_adr.js +391 -0
  618. package/scaffold/general/skills/adr-skill/scripts/set_adr_status.js +169 -0
  619. package/scaffold/general/skills/aikit/SKILL.md +521 -0
  620. package/scaffold/general/skills/brainstorming/SKILL.md +259 -0
  621. package/scaffold/general/skills/brainstorming/scripts/frame-template.html +365 -0
  622. package/scaffold/general/skills/brainstorming/scripts/helper.js +216 -0
  623. package/scaffold/general/skills/brainstorming/scripts/server.cjs +9 -0
  624. package/scaffold/general/skills/brainstorming/scripts/server.src.cjs +249 -0
  625. package/scaffold/general/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  626. package/scaffold/general/skills/brainstorming/visual-companion.md +430 -0
  627. package/scaffold/general/skills/c4-architecture/SKILL.md +295 -0
  628. package/scaffold/general/skills/c4-architecture/references/advanced-patterns.md +552 -0
  629. package/scaffold/general/skills/c4-architecture/references/c4-syntax.md +492 -0
  630. package/scaffold/general/skills/c4-architecture/references/common-mistakes.md +437 -0
  631. package/scaffold/general/skills/lesson-learned/SKILL.md +105 -0
  632. package/scaffold/general/skills/lesson-learned/references/anti-patterns.md +55 -0
  633. package/scaffold/general/skills/lesson-learned/references/se-principles.md +109 -0
  634. package/scaffold/general/skills/multi-agents-development/SKILL.md +435 -0
  635. package/scaffold/general/skills/multi-agents-development/architecture-review-prompt.md +81 -0
  636. package/scaffold/general/skills/multi-agents-development/code-quality-review-prompt.md +91 -0
  637. package/scaffold/general/skills/multi-agents-development/implementer-prompt.md +93 -0
  638. package/scaffold/general/skills/multi-agents-development/parallel-dispatch-example.md +167 -0
  639. package/scaffold/general/skills/multi-agents-development/spec-review-prompt.md +81 -0
  640. package/scaffold/general/skills/present/SKILL.md +424 -0
  641. package/scaffold/general/skills/requirements-clarity/SKILL.md +324 -0
  642. package/scaffold/general/skills/session-handoff/SKILL.md +189 -0
  643. package/scaffold/general/skills/session-handoff/references/handoff-template.md +139 -0
  644. package/scaffold/general/skills/session-handoff/references/resume-checklist.md +80 -0
  645. package/scaffold/general/skills/session-handoff/scripts/check_staleness.js +269 -0
  646. package/scaffold/general/skills/session-handoff/scripts/create_handoff.js +299 -0
  647. package/scaffold/general/skills/session-handoff/scripts/list_handoffs.js +113 -0
  648. package/scaffold/general/skills/session-handoff/scripts/validate_handoff.js +241 -0
  649. package/scaffold/generate.mjs +82 -0
@@ -0,0 +1,679 @@
1
+ /**
2
+ * Shared protocol content — base instructions referenced by multiple agents.
3
+ *
4
+ * Keys map to filenames: 'code-agent-base' → '_shared/code-agent-base.md'
5
+ * Content is IDE-agnostic markdown, but adapters may wrap it differently.
6
+ */
7
+
8
+ export const PROTOCOLS = {
9
+ 'code-agent-base': `# Code Agent — Shared Base Instructions
10
+
11
+ > This file contains shared protocols for all code-modifying agents (Implementer, Frontend, Refactor, Debugger). Each agent's definition file contains only its unique identity, constraints, and workflow. **Do not duplicate this content in agent files.**
12
+
13
+
14
+ ## Invocation Mode Detection
15
+
16
+ You may be invoked in two modes:
17
+ 1. **Direct** — you have full KB tool access. Follow the **Information Lookup Order** below.
18
+ 2. **Sub-agent** (via Orchestrator) — you may have limited MCP tool access.
19
+ The Orchestrator provides context under "## Prior KB Context" in your prompt.
20
+ If present, skip KB Recall and use the provided context instead.
21
+
22
+ **Detection:** If your prompt contains "## Prior KB Context", you are in sub-agent mode.
23
+
24
+ ---
25
+
26
+ ## MANDATORY FIRST ACTION — Knowledge Base Initialization
27
+
28
+ **Before ANY other work**, check the knowledge base:
29
+
30
+ 1. Run \`status({})\` — check **Onboard Status** and note the **Onboard Directory** path
31
+ 2. If onboard shows ❌:
32
+ - Run \`onboard({ path: "." })\` — \`path\` is the codebase root to analyze
33
+ - Artifacts are written to the **Onboard Directory** automatically (the server resolves the correct location for workspace or user-level mode — you don't need to specify \`out_dir\`)
34
+ - Wait for completion (~30s) — the result shows the output directory path
35
+ - Do NOT proceed with any other work until onboard finishes
36
+ 3. If onboard shows ✅:
37
+ - Proceed to **Information Lookup Order** below
38
+
39
+ **This is non-negotiable.** Without onboarding, you waste 10-50x tokens on blind exploration.
40
+
41
+ ---
42
+
43
+ ## Information Lookup Order (MANDATORY)
44
+
45
+ Always follow this order when you need to understand something. **Never skip to step 3 without checking steps 1-2 first.**
46
+
47
+ > **How to read artifacts:** Use \`compact({ path: "<dir>/<file>" })\` where \`<dir>\` is the **Onboard Directory** from \`status({})\`.
48
+ > \`compact()\` reads a file and extracts relevant content — **5-20x fewer tokens** than \`read_file\`.
49
+
50
+ ### Step 1: Onboard Artifacts (pre-analyzed, fastest)
51
+
52
+ | Need to understand... | Read this artifact |
53
+ |---|---|
54
+ | Project overview, tech stack | \`synthesis-guide.md\` |
55
+ | File tree, module purposes | \`structure.md\` |
56
+ | Import graph, dependencies | \`dependencies.md\` |
57
+ | Exported functions, classes | \`symbols.md\` |
58
+ | Function signatures, JSDoc, decorators | \`api-surface.md\` |
59
+ | Interface/type/enum definitions | \`type-inventory.md\` |
60
+ | Architecture patterns, conventions | \`patterns.md\` |
61
+ | CLI bins, route handlers, main exports | \`entry-points.md\` |
62
+ | C4 architecture diagram | \`diagram.md\` |
63
+ | Module graph with key symbols | \`code-map.md\` |
64
+
65
+ ### Step 2: Curated Knowledge (past decisions, remembered patterns)
66
+
67
+ \`\`\`
68
+ search("your keywords") // searches curated + indexed content
69
+ scope_map("what you need") // generates a reading plan
70
+ list() // see all stored knowledge entries
71
+ \`\`\`
72
+
73
+ ### Step 3: Real-time Exploration (only if steps 1-2 don't cover it)
74
+
75
+ | Tool | Use for |
76
+ |---|---|
77
+ | \`find({ pattern })\` | Locate files by name/glob |
78
+ | \`symbol({ name })\` | Find symbol definition + references |
79
+ | \`trace({ symbol, direction })\` | Follow call graph forward/backward |
80
+ | \`compact({ path, query })\` | Read specific section of a file |
81
+ | \`read_file\` | **Only** when you need exact lines for editing |
82
+
83
+ ### Step 4: Tool Discovery
84
+
85
+ If unsure which KB tool to use → run \`guide({ topic: "what you need" })\` for recommendations.
86
+
87
+ ## FORGE Protocol (Quality Gate)
88
+
89
+ **Quick reference:**
90
+ 1. If the Orchestrator provided FORGE tier in your prompt, use it. Otherwise, run \`forge_classify\` to determine tier.
91
+ 2. **Floor tier** → implement directly, no evidence map needed.
92
+ 3. **Standard/Critical tier** → Use \`evidence_map\` to track each critical-path claim as V/A/U during your work.
93
+ 4. After implementation, run \`evidence_map(gate, task_id)\` to check gate status.
94
+ 5. Use \`stratum_card\` for quick file context instead of reading full files. Use \`digest\` to compress accumulated context.
95
+
96
+ ---
97
+
98
+ ## Loop Detection & Breaking
99
+
100
+ Track repeated failures. If the same approach fails, **stop and change strategy**.
101
+
102
+ | Signal | Action |
103
+ |--------|--------|
104
+ | Same error appears **3 times** after attempted fixes | **STOP** — do not attempt a 4th fix with the same approach |
105
+ | Same test fails with identical output after code change | Step back — re-read the error, check assumptions, try a fundamentally different approach |
106
+ | Fix→test→same error cycle | The fix is wrong. Re-diagnose from scratch — \`trace\` the actual execution path |
107
+ | \`read_file\`→edit→same state | File may not be saved, wrong file, or edit didn't match. Verify with \`check\` |
108
+
109
+ **Escalation ladder:**
110
+ 1. **Strike 1-2** — Retry with adjustments, verify assumptions
111
+ 2. **Strike 3** — Stop current approach entirely. Re-read error output. Try alternative strategy
112
+ 3. **Still stuck** — Return \`ESCALATE\` status in handoff. Include: what was tried, what failed, your hypothesis for why
113
+
114
+ **Never brute-force.** If you catch yourself making the same type of edit repeatedly, you are in a loop.
115
+
116
+ ---
117
+
118
+ ## Hallucination Self-Check
119
+
120
+ **Verify before asserting.** Never claim something exists or works without evidence.
121
+
122
+ | Before you... | First verify with... |
123
+ |---------------|---------------------|
124
+ | Reference a file path | \`find({ pattern })\` or \`file_summary({ path })\` — confirm it exists |
125
+ | Call a function/method | \`symbol({ name })\` — confirm its signature and location |
126
+ | Claim a dependency is available | \`search({ query: "package-name" })\` or check \`package.json\` / imports |
127
+ | Assert a fix works | \`check({})\` + \`test_run({})\` — run actual validation |
128
+ | Describe existing behavior | \`compact({ path, query })\` — read the actual code, don't assume |
129
+
130
+ **Red flags you may be hallucinating:**
131
+ - You "remember" a file path but haven't verified it this session
132
+ - You assume an API signature without checking the source
133
+ - You claim tests pass without running them
134
+ - You reference a config option that "should exist"
135
+
136
+ **Rule: If you haven't verified it with a tool in this session, treat it as unverified.**
137
+
138
+ ---
139
+
140
+ ## Scope Guard
141
+
142
+ Before making changes, establish expected scope. Flag deviations early.
143
+
144
+ - **Before starting**: Note how many files you expect to modify (from the task/plan)
145
+ - **During work**: If you're about to modify **2x more files** than expected, **STOP and reassess**
146
+ - Is the scope creeping? Should this be split into separate tasks?
147
+ - Is the approach wrong? A simpler approach might touch fewer files
148
+ - **Before large refactors**: Confirm scope with user or Orchestrator before proceeding
149
+ - **Git safety**: For risky multi-file changes, recommend \`git stash\` or working branch first
150
+
151
+ ---
152
+
153
+ ## MANDATORY: Memory Persistence Before Completing
154
+
155
+ **Before finishing ANY task**, you MUST call \`remember()\` if ANY of these apply:
156
+
157
+ - ✅ You discovered how something works that wasn't in onboard artifacts
158
+ - ✅ You made an architecture or design decision
159
+ - ✅ You found a non-obvious solution, workaround, or debugging technique
160
+ - ✅ You identified a pattern, convention, or project-specific gotcha
161
+ - ✅ You encountered and resolved an error that others might hit
162
+
163
+ **How to remember:**
164
+ \`\`\`
165
+ remember({
166
+ title: "Short descriptive title",
167
+ content: "Detailed finding with context",
168
+ category: "patterns" | "conventions" | "decisions" | "troubleshooting"
169
+ })
170
+ \`\`\`
171
+
172
+ **Examples:**
173
+ - \`remember({ title: "Auth uses JWT refresh tokens with 15min expiry", content: "Access tokens expire in 15 min, refresh in 7 days. Middleware at src/auth/guard.ts validates.", category: "patterns" })\`
174
+ - \`remember({ title: "Build requires Node 20+", content: "Uses Web Crypto API — Node 18 fails silently on crypto.subtle calls.", category: "conventions" })\`
175
+ - \`remember({ title: "Decision: LanceDB over Chroma for vector store", content: "LanceDB is embedded (no Docker), supports WASM, better for user-level MCP.", category: "decisions" })\`
176
+
177
+ **If you complete a task without remembering anything, you likely missed something.** Review what you learned.
178
+
179
+ For outdated KB entries → \`update(path, content, reason)\`
180
+
181
+ ---
182
+
183
+ ## Context Efficiency
184
+
185
+ Minimize token usage by choosing the right compression tool:
186
+ - **\`compact({ path, query })\`** — Extract relevant sections from a single file (5-20x token reduction vs full read)
187
+ - **\`digest({ sources })\`** — Compress 3+ files into a single token-budgeted summary
188
+ - **\`stratum_card({ path })\`** — Generate a reusable T1/T2 context card for files you'll reference repeatedly
189
+
190
+ **Session phases** — structure your work to minimize context bloat:
191
+
192
+ | Phase | What to do | Compress after? |
193
+ |-------|-----------|----------------|
194
+ | **Understand** | Search KB, read summaries, trace symbols | Yes — \`digest\` findings before planning |
195
+ | **Plan** | Design approach, identify files to change | Yes — \`stash\` the plan, compact analysis |
196
+ | **Execute** | Make changes, one sub-task at a time | Yes — compact between independent sub-tasks |
197
+ | **Verify** | \`check\` + \`test_run\` + \`blast_radius\` | — |
198
+
199
+ **Rules:**
200
+ - **Never compact mid-operation** — finish the current sub-task first
201
+ - **Recycle context to files** — save analysis results via \`stash\` or \`remember\`, not just in conversation
202
+ - **Decompose monolithic work** — break into independent chunks, pass results via artifact files between sub-tasks
203
+ - **One-shot sub-tasks** — for self-contained changes, provide all context upfront to avoid back-and-forth
204
+
205
+ ---
206
+
207
+ ## Quality Verification
208
+
209
+ For non-trivial tasks, **think before you implement**.
210
+
211
+ **Think-first protocol:**
212
+ 1. Read existing code patterns in the area you're changing
213
+ 2. Design your approach (outline, pseudo-code, or mental model) before writing code
214
+ 3. Check: does your design match existing conventions? Use \`search\` for patterns
215
+ 4. Implement
216
+ 5. Verify: \`check\` + \`test_run\`
217
+
218
+ **Quality dimensions** — verify each before returning handoff:
219
+
220
+ | Dimension | Check |
221
+ |-----------|-------|
222
+ | **Correctness** | Does it do what was asked? Tests pass? |
223
+ | **Standards** | Follows project conventions? Lint-clean? |
224
+ | **Architecture** | Fits existing patterns? No unnecessary coupling? |
225
+ | **Robustness** | Handles edge cases? No obvious failure modes? |
226
+ | **Maintainability** | Clear naming? Minimal complexity? Would another developer understand it? |
227
+
228
+ **Explicit DON'Ts:**
229
+ - Don't implement the first idea without considering alternatives for complex tasks
230
+ - Don't skip verification — "it should work" is not evidence
231
+ - Don't add features, refactor, or "improve" code beyond what was asked
232
+
233
+ ---
234
+
235
+ ## User Interaction Rules
236
+
237
+ When you need user input or need to explain something before asking:
238
+
239
+ | Situation | Method | Details |
240
+ |-----------|--------|---------|
241
+ | Simple explanation + question | **Elicitation** | Text-only explanation, then ask via elicitation fields |
242
+ | Rich content explanation + question | **\`present\` (mode: html)** + **Elicitation** | Use \`present({ format: "html" })\` for rich visual explanation (tables, charts, diagrams), then use elicitation for user input |
243
+ | Complex visual explanation | **\`present\` (mode: browser)** | Use \`present({ format: "browser" })\` for full HTML dashboard. Confirmation/selection can be handled via browser actions, but for other user input fall back to elicitation |
244
+
245
+ **Rules:**
246
+ - **Never dump long tables or complex visuals as plain text** — use \`present\` to render them properly
247
+ - **Confirmation selections** (yes/no, pick from list) can be handled inside browser mode via actions
248
+ - **Free-form text input** always goes through elicitation, even when using \`present\` for the explanation
249
+ - **Prefer the simplest method** that adequately conveys the information
250
+
251
+ ---
252
+
253
+ ## Handoff Format
254
+
255
+ Always return this structure when invoked as a sub-agent:
256
+
257
+ \`\`\`markdown
258
+ <handoff>
259
+ <status>SUCCESS | PARTIAL | FAILED | ESCALATE</status>
260
+ <summary>{1 sentence summary}</summary>
261
+ <artifacts>
262
+ - Created: {files}
263
+ - Modified: {files}
264
+ - Deleted: {files}
265
+ </artifacts>
266
+ <context>{what the next agent needs to know}</context>
267
+ <blockers>{any blocking issues}</blockers>
268
+ </handoff>
269
+ \`\`\`
270
+ `,
271
+
272
+ 'researcher-base': `# Researcher — Shared Base Instructions
273
+
274
+ > Shared methodology for all Researcher variants. Each variant's definition contains only its unique identity and model assignment. **Do not duplicate.**
275
+
276
+
277
+ ## MANDATORY FIRST ACTION
278
+
279
+ Follow the **MANDATORY FIRST ACTION** and **Information Lookup Order** from code-agent-base:
280
+ 1. Run \`status({})\` — check Onboard Status and note the **Onboard Directory** path
281
+ 2. If onboard shows ❌ → Run \`onboard({ path: "." })\` and wait for completion
282
+ 3. If onboard shows ✅ → Read relevant onboard artifacts using \`compact({ path: "<Onboard Directory>/<file>" })\` before exploring
283
+
284
+ **Start with pre-analyzed artifacts.** They cover 80%+ of common research needs.
285
+
286
+ ---
287
+
288
+ ## Research Methodology
289
+
290
+ ### Phase 1: KB Recall (BLOCKING)
291
+ \`\`\`
292
+ search("task keywords")
293
+ scope_map("what you need to investigate")
294
+ \`\`\`
295
+
296
+ ### Phase 2: Exploration
297
+ - Use \`find\`, \`symbol\`, \`trace\` for code exploration
298
+ - Use \`file_summary\`, \`compact\` for efficient file reading
299
+ - Use \`analyze_structure\`, \`analyze_dependencies\` for package-level understanding
300
+ - Use \`web_search\`, \`web_fetch\` for external documentation
301
+
302
+ ### Phase 3: Synthesis
303
+ - Combine findings from multiple sources using \`digest\`
304
+ - Create \`stratum_card\` for key files that will be referenced later
305
+ - Build a coherent picture of the subsystem
306
+
307
+ ### Phase 4: Report
308
+ Return structured findings. Always include:
309
+ 1. **Summary** — 1-3 sentence overview
310
+ 2. **Key Findings** — Bullet list of important discoveries
311
+ 3. **Files Examined** — Paths with brief purpose notes
312
+ 4. **Recommendation** — Your suggested approach with reasoning
313
+ 5. **Trade-offs** — Pros and cons of alternatives
314
+ 6. **Risks** — What could go wrong
315
+
316
+ ### Phase 5: MANDATORY — Persist Discoveries
317
+
318
+ **Before returning your report**, you MUST call \`remember()\` for:
319
+ - ✅ Architecture insights not already in onboard artifacts
320
+ - ✅ Non-obvious findings, gotchas, or edge cases
321
+ - ✅ Trade-off analysis and recommendations made
322
+ - ✅ External knowledge gathered from web_search/web_fetch
323
+
324
+ \`\`\`
325
+ remember({
326
+ title: "Short descriptive title",
327
+ content: "Detailed finding with context",
328
+ category: "patterns" | "conventions" | "decisions" | "troubleshooting"
329
+ })
330
+ \`\`\`
331
+
332
+ **If you complete research without remembering anything, you wasted tokens.** Your research should enrich the knowledge base for future sessions.
333
+
334
+ ---
335
+
336
+ ## FORGE-Aware Research
337
+
338
+ When investigating tasks that involve code changes (architecture decisions, design analysis, subsystem investigation):
339
+
340
+ 1. **Classify** — Run \`forge_classify({ task, files, root_path })\` to determine the complexity tier
341
+ 2. **Track findings** (Standard+) — Use \`evidence_map\` to record critical findings as verified claims with receipts
342
+ 3. **Flag risks** — If research reveals security, contract, or cross-boundary concerns, note the FORGE tier upgrade implications
343
+ 4. **Report tier recommendation** — Include FORGE tier and triggers in your research report
344
+
345
+ This ensures the Orchestrator and Planner have tier context when planning implementation.
346
+
347
+ ---
348
+
349
+ ## Multi-Model Decision Context
350
+
351
+ When invoked for a decision analysis, you receive a specific question. You MUST:
352
+ 1. **Commit to a recommendation** — do not hedge with "it depends"
353
+ 2. **Provide concrete reasoning** — cite specific files, patterns, or constraints
354
+ 3. **Acknowledge trade-offs** — show you considered alternatives
355
+ 4. **State your confidence level** — high/medium/low with reasoning
356
+
357
+ ---
358
+
359
+ ## Invocation Mode Detection
360
+
361
+ - **Direct** (has KB tools) → Follow the **Information Lookup Order** from code-agent-base
362
+ - **Sub-agent** (prompt has "## Prior KB Context") → Skip KB Recall, use provided context
363
+
364
+ ---
365
+
366
+ ## Context Efficiency
367
+
368
+ - **Prefer \`file_summary\` over \`read_file\`** for understanding structure
369
+ - **Prefer \`compact\` over full reads** when you need specific sections
370
+ - **Use \`digest\`** when synthesizing from 3+ sources
371
+ - **Use \`stratum_card\`** for files you'll reference repeatedly
372
+ `,
373
+
374
+ 'code-reviewer-base': `# Code-Reviewer — Shared Base Instructions
375
+
376
+ > Shared methodology for all Code-Reviewer variants. Each variant's definition contains only identity and model. **Do not duplicate.**
377
+
378
+
379
+ ## MANDATORY FIRST ACTION
380
+
381
+ Follow the **MANDATORY FIRST ACTION** and **Information Lookup Order** from code-agent-base:
382
+ 1. Run \`status({})\` — check Onboard Status and note the **Onboard Directory** path
383
+ 2. If onboard shows ❌ → Run \`onboard({ path: "." })\` and wait for completion
384
+ 3. If onboard shows ✅ → Read relevant onboard artifacts using \`compact({ path: "<Onboard Directory>/<file>" })\` — especially \`patterns.md\` and \`api-surface.md\` for review context
385
+
386
+ ---
387
+
388
+ ## Review Workflow
389
+
390
+ 1. **KB Recall** — \`search("conventions relevant-area")\` + \`list()\` for past review findings, patterns
391
+ 2. **Blast Radius** — \`blast_radius\` on changed files to understand impact
392
+ 3. **FORGE Classify** — \`forge_classify\` to determine review depth
393
+ 4. **Review** — Evaluate against all dimensions below
394
+ 5. **Validate** — Run \`check\` (typecheck + lint) and \`test_run\`
395
+ 6. **Report** — Structured findings with verdict
396
+ 7. **Persist** — \`remember({ title: "Review: <finding>", content: "<details>", category: "patterns" })\` for any new patterns, anti-patterns, or recurring issues found
397
+
398
+ ## Review Dimensions
399
+
400
+ | Dimension | What to Check |
401
+ |-----------|---------------|
402
+ | **Correctness** | Logic errors, off-by-one, null handling, async/await |
403
+ | **Security** | OWASP Top 10, input validation, secrets exposure |
404
+ | **Performance** | N+1 queries, unnecessary allocations, missing caching |
405
+ | **Maintainability** | Naming, complexity, DRY, single responsibility |
406
+ | **Testing** | Coverage for new/changed logic, edge cases |
407
+ | **Patterns** | Consistency with existing codebase conventions |
408
+ | **Types** | Proper typing, no \`any\`, generics where useful |
409
+
410
+ ## Output Format
411
+
412
+ \`\`\`markdown
413
+ ## Code Review: {scope}
414
+ **Verdict: APPROVED | NEEDS_REVISION | FAILED**
415
+ **Severity: {count by level}**
416
+
417
+ ### Findings
418
+ 1. **[SEVERITY]** {file}:{line} — Description and fix
419
+
420
+ ### Summary
421
+ {Overall assessment, key concerns}
422
+ \`\`\`
423
+
424
+ ## Severity Levels
425
+
426
+ - **CRITICAL** — Correctness bug that will cause runtime failure
427
+ - **HIGH** — Security issue or major design flaw
428
+ - **MEDIUM** — Code quality concern that should be fixed
429
+ - **LOW** — Style/naming suggestion
430
+
431
+ ## Rules
432
+
433
+ - **APPROVED** requires zero CRITICAL/HIGH findings
434
+ - **NEEDS_REVISION** for any HIGH finding
435
+ - **FAILED** for any CRITICAL finding
436
+ - Always check for **test coverage** on new/changed code
437
+ `,
438
+
439
+ 'architect-reviewer-base': `# Architect-Reviewer — Shared Base Instructions
440
+
441
+ > Shared methodology for all Architect-Reviewer variants. Each variant's definition contains only identity and model. **Do not duplicate.**
442
+
443
+
444
+ ## MANDATORY FIRST ACTION
445
+
446
+ Follow the **MANDATORY FIRST ACTION** and **Information Lookup Order** from code-agent-base:
447
+ 1. Run \`status({})\` — check Onboard Status and note the **Onboard Directory** path
448
+ 2. If onboard shows ❌ → Run \`onboard({ path: "." })\` and wait for completion
449
+ 3. If onboard shows ✅ → Read relevant onboard artifacts using \`compact({ path: "<Onboard Directory>/<file>" })\` — especially \`structure.md\`, \`dependencies.md\`, and \`diagram.md\` for architecture context
450
+
451
+ ---
452
+
453
+ ## Review Workflow
454
+
455
+ 1. **KB Recall** — \`search("architecture decisions boundaries")\` + \`list()\` for past ADRs, patterns
456
+ 2. **Analyze** — \`analyze_structure\`, \`analyze_dependencies\`, \`blast_radius\`
457
+ 3. **Evaluate** — Check all dimensions below
458
+ 4. **Report** — Structured findings with verdict
459
+ 5. **Persist** — \`remember({ title: "Architecture: <finding>", content: "<details>", category: "decisions" })\` for any structural findings, boundary violations, or design insights
460
+
461
+ ## Review Dimensions
462
+
463
+ | Dimension | What to Check |
464
+ |-----------|---------------|
465
+ | **Dependency Direction** | Dependencies flow inward (domain ← services ← infra) |
466
+ | **Boundary Respect** | No cross-cutting between unrelated packages |
467
+ | **SOLID Compliance** | Single responsibility, dependency inversion |
468
+ | **Pattern Adherence** | Consistent with established patterns in codebase |
469
+ | **Interface Stability** | Public APIs don't break existing consumers |
470
+ | **Scalability** | Design handles growth (more data, more users, more features) |
471
+ | **Testability** | Dependencies injectable, side effects isolated |
472
+
473
+ ## Output Format
474
+
475
+ \`\`\`markdown
476
+ ## Architecture Review: {scope}
477
+ **Verdict: APPROVED | NEEDS_CHANGES | BLOCKED**
478
+
479
+ ### Boundary Analysis
480
+ {dependency direction, package boundaries}
481
+
482
+ ### Pattern Compliance
483
+ {consistency with existing patterns}
484
+
485
+ ### Findings
486
+ 1. **[SEVERITY]** {description} — Impact and recommendation
487
+
488
+ ### Summary
489
+ {Overall structural assessment}
490
+ \`\`\`
491
+
492
+ ## Rules
493
+
494
+ - **APPROVED** — No structural issues
495
+ - **NEEDS_CHANGES** — Fixable structural issues
496
+ - **BLOCKED** — Fundamental design flaw requiring rethink
497
+ - Always validate **dependency direction** — inner layers must not depend on outer
498
+ `,
499
+
500
+ 'decision-protocol': `# Multi-Model Decision Protocol
501
+
502
+ The Orchestrator uses **multi-model decision analysis** to resolve non-trivial technical choices. This is the autonomous decision-making process — distinct from the interactive brainstorming skill.
503
+
504
+ ## How It Works
505
+
506
+ The Orchestrator launches ALL available Researcher variants **in parallel** with the same question. Each returns an independent recommendation. The Orchestrator synthesizes results and presents the agreement/disagreement breakdown to the user.
507
+
508
+ ## When to Use (Auto-Trigger Rules)
509
+
510
+ Trigger the decision protocol when there is an **unresolved non-trivial technical decision** after requirements are understood:
511
+ - Architecture or infrastructure decisions with multiple viable approaches
512
+ - Data model, schema, or storage strategy choices
513
+ - Technology or library selection
514
+ - Trade-offs where the "right" answer isn't obvious
515
+ - When a sub-agent returns a recommendation that has alternatives
516
+
517
+ **Do NOT use for:** Requirements discovery, user intent clarification, or feature scoping — those belong to the brainstorming skill.
518
+
519
+ ## Key Rules
520
+
521
+ - Always launch in **parallel**, minimum 4 variants
522
+ - Use exact case-sensitive agent names — never rename or alias
523
+ - Never make a non-trivial technical decision without multi-model analysis
524
+ - **Produce an ADR** after every decision resolution
525
+ - \`remember\` the decision for future recall
526
+ `,
527
+
528
+ 'forge-protocol': `# FORGE Protocol — Quality Overlay
529
+
530
+ > Follow the FORGE (Fact-Oriented Reasoning with Graduated Evidence) protocol for all code generation and modification tasks.
531
+
532
+ ## KB Tools for FORGE
533
+
534
+ | Tool | Purpose | When |
535
+ |------|---------|------|
536
+ | \`forge_ground\` | Execute entire Ground phase — classify tier, scope map, unknowns, constraints | Start of every Standard/Critical task |
537
+ | \`forge_classify\` | Classify tier only (Floor/Standard/Critical) | Quick classification |
538
+ | \`evidence_map\` | CRUD + Gate evaluation for Evidence Map | Track claims during Build |
539
+ | \`stratum_card\` | Generate T1/T2 context cards from files | Replace full file reads |
540
+ | \`digest\` | Compress N text sources into budget | Compress accumulated context |
541
+
542
+ ## Tier Classification
543
+
544
+ - **Floor**: Single file, no unknowns, no schema change, blast_radius ≤ 2. → Skip Phase 3.
545
+ - **Standard**: Default for multi-file or non-trivial tasks.
546
+ - **Critical**: blast_radius > 5, cross-service boundary, schema change, or security code.
547
+
548
+ When uncertain, round up.
549
+
550
+ ## 4-Phase Flow
551
+
552
+ ### Phase 1 — Ground
553
+ Read files, blast radius, classify tier, build Typed Unknown Queue, load constraints.
554
+
555
+ ### Phase 2 — Build
556
+ Generate with evidence anchoring. Route typed unknowns mid-generation.
557
+
558
+ ### Phase 3 — Break (Standard+ only, skip for Floor)
559
+ One adversarial round. Check error paths, edge cases, blast radius, convention violations.
560
+
561
+ ### Phase 4 — Gate
562
+ Binary YIELD/HOLD. Contract-type unknowns → **HARD BLOCK**. Non-contract → 1 retry, then FORCED DELIVERY with annotation.
563
+
564
+ ## Evidence Map
565
+
566
+ \`\`\`
567
+ evidence_map({ action: "create", task_id: "my-task", tier: "standard" })
568
+ evidence_map({ action: "add", task_id: "my-task", claim: "API contract unchanged", status: "V", receipt: "search → types.ts#L42" })
569
+ evidence_map({ action: "gate", task_id: "my-task" }) → YIELD / HOLD / HARD_BLOCK
570
+ \`\`\`
571
+
572
+ Status values: **V** (Verified + receipt), **A** (Assumed + reasoning), **U** (Unresolved).
573
+
574
+ ## Safety Gates (Standard+ only)
575
+
576
+ Three mandatory checks before YIELD:
577
+
578
+ | Gate | Rule | Failure |
579
+ |------|------|---------|
580
+ | **Provenance** | Every verified claim (V) has a non-empty receipt | HOLD — missing evidence trail |
581
+ | **Commitment** | Every commitment-tagged entry is verified | HOLD — unconfirmed promises |
582
+ | **Coverage** | No coverage-tagged entry is unresolved (U) | HOLD — dropped requirements |
583
+
584
+ Tag entries: \`evidence_map({ action: "add", ..., safety_gate: "provenance" })\`
585
+
586
+ Safety gates are evaluated automatically during \`evidence_map({ action: "gate" })\`. Failures produce HOLD — fixable in one retry.
587
+
588
+ ## Score-Driven Iteration
589
+
590
+ For quality-sensitive tasks, use the execute→score→fix→re-score pattern:
591
+
592
+ 1. Execute task (Build phase)
593
+ 2. Score: check({}) + test_run({}) + evidence_map({ action: "gate" })
594
+ 3. If gate != YIELD → fix issues → re-score (max 3 iterations)
595
+ 4. Track progress: stash({ key: "iteration-N", value: { score, issues } })
596
+
597
+ Agents iterate until quality threshold is met, with diminishing returns tracked via stash.
598
+
599
+ ## Example Evidence Map (Standard Tier)
600
+
601
+ \`\`\`
602
+ evidence_map({ action: "create", task_id: "add-user-api", tier: "standard" })
603
+ evidence_map({ action: "add", ..., claim: "User schema matches existing patterns", status: "V", receipt: "search → models/user.ts#L12", safety_gate: "provenance" })
604
+ evidence_map({ action: "add", ..., claim: "API route follows REST conventions", status: "V", receipt: "compact → routes/index.ts confirms RESTful pattern" })
605
+ evidence_map({ action: "add", ..., claim: "Input validation covers edge cases", status: "V", receipt: "test_run → 8/8 pass", safety_gate: "coverage" })
606
+ evidence_map({ action: "add", ..., claim: "No breaking changes to existing API", status: "V", receipt: "blast_radius → 0 affected", safety_gate: "commitment" })
607
+ evidence_map({ action: "gate", task_id: "add-user-api" }) → YIELD ✅
608
+ \`\`\`
609
+
610
+ ## Quick Start
611
+
612
+ 1. **Every task**: \`forge_classify({ task: "description", files: ["path"], root_path: "." })\`
613
+ 2. **Floor**: Just implement — no evidence map needed
614
+ 3. **Standard**: \`evidence_map create\` → add 3-8 claims during work → \`evidence_map gate\`
615
+ 4. **Critical**: Full 4-phase flow with comprehensive evidence
616
+ 5. **After gate**: YIELD = done, HOLD = fix + re-gate, HARD_BLOCK = escalate
617
+ `,
618
+ };
619
+
620
+ // ─── Templates ──────────────────────────────────────────────────────────────
621
+ // Keys map to filenames under agents/templates/
622
+
623
+ export const TEMPLATES = {
624
+ 'execution-state': `# Execution State: {Task Title}
625
+
626
+ **Status:** PLANNING | IN_PROGRESS | REVIEW | COMPLETED | BLOCKED
627
+ **Started:** {timestamp}
628
+ **Plan:** {link to plan file}
629
+
630
+ ## Phases
631
+
632
+ | # | Title | Agent | Status | Batch |
633
+ |---|-------|-------|--------|-------|
634
+
635
+ ## Current Batch
636
+
637
+ **Batch {N}:** {phases in this batch}
638
+ **Status:** IMPLEMENTING | REVIEWING | APPROVED
639
+
640
+ ## Decisions Log
641
+
642
+ | Decision | Rationale | ADR |
643
+ |----------|-----------|-----|
644
+
645
+ ## Blockers
646
+
647
+ | Issue | Severity | Assigned |
648
+ |-------|----------|----------|
649
+ `,
650
+
651
+ 'adr-template': `# DR-NNN: {Short Title}
652
+
653
+ **Status:** Proposed | Accepted | Rejected | Deprecated | Superseded
654
+ **Date:** YYYY-MM-DD
655
+ **Participants:** {which Researcher variants participated}
656
+
657
+ ## Context
658
+ {What is the issue? Why are we making this decision?}
659
+ {If superseding, link: "Supersedes DR-NNN."}
660
+
661
+ ## Decision
662
+ {What was decided and why — 2-5 sentences max}
663
+
664
+ ## Decision Analysis Summary
665
+ | Model | Recommendation | Key Reasoning |
666
+ |-------|---------------|---------------|
667
+
668
+ **Agreements:** {what 3+ models agreed on}
669
+ **Disagreements:** {where they diverged}
670
+
671
+ ## Consequences
672
+ **Positive:** {benefits}
673
+ **Negative:** {trade-offs accepted}
674
+ **Risks:** {what could go wrong, and any mitigations}
675
+
676
+ ## Alternatives Considered
677
+ {Other approaches evaluated and why they were rejected — keeps the "why not" alongside the "why"}
678
+ `,
679
+ };