@oxagen/cli 0.4.0 → 0.6.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 (537) hide show
  1. package/README.md +68 -5
  2. package/dist/agent/__tests__/code-graph.test.d.ts +2 -0
  3. package/dist/agent/__tests__/code-graph.test.d.ts.map +1 -0
  4. package/dist/agent/__tests__/code-graph.test.js +83 -0
  5. package/dist/agent/__tests__/code-graph.test.js.map +1 -0
  6. package/dist/agent/__tests__/evaluator.test.d.ts +2 -0
  7. package/dist/agent/__tests__/evaluator.test.d.ts.map +1 -0
  8. package/dist/agent/__tests__/evaluator.test.js +96 -0
  9. package/dist/agent/__tests__/evaluator.test.js.map +1 -0
  10. package/dist/agent/__tests__/fleet-memory.test.d.ts +2 -0
  11. package/dist/agent/__tests__/fleet-memory.test.d.ts.map +1 -0
  12. package/dist/agent/__tests__/fleet-memory.test.js +107 -0
  13. package/dist/agent/__tests__/fleet-memory.test.js.map +1 -0
  14. package/dist/agent/__tests__/fleet-store.test.d.ts +2 -0
  15. package/dist/agent/__tests__/fleet-store.test.d.ts.map +1 -0
  16. package/dist/agent/__tests__/fleet-store.test.js +93 -0
  17. package/dist/agent/__tests__/fleet-store.test.js.map +1 -0
  18. package/dist/agent/__tests__/git-isolation.test.d.ts +2 -0
  19. package/dist/agent/__tests__/git-isolation.test.d.ts.map +1 -0
  20. package/dist/agent/__tests__/git-isolation.test.js +119 -0
  21. package/dist/agent/__tests__/git-isolation.test.js.map +1 -0
  22. package/dist/agent/__tests__/judge.test.d.ts +2 -0
  23. package/dist/agent/__tests__/judge.test.d.ts.map +1 -0
  24. package/dist/agent/__tests__/judge.test.js +135 -0
  25. package/dist/agent/__tests__/judge.test.js.map +1 -0
  26. package/dist/agent/__tests__/loop-errors.test.d.ts +2 -0
  27. package/dist/agent/__tests__/loop-errors.test.d.ts.map +1 -0
  28. package/dist/agent/__tests__/loop-errors.test.js +44 -0
  29. package/dist/agent/__tests__/loop-errors.test.js.map +1 -0
  30. package/dist/agent/__tests__/model-router.test.d.ts +2 -0
  31. package/dist/agent/__tests__/model-router.test.d.ts.map +1 -0
  32. package/dist/agent/__tests__/model-router.test.js +122 -0
  33. package/dist/agent/__tests__/model-router.test.js.map +1 -0
  34. package/dist/agent/__tests__/orchestrator-isolation.test.d.ts +2 -0
  35. package/dist/agent/__tests__/orchestrator-isolation.test.d.ts.map +1 -0
  36. package/dist/agent/__tests__/orchestrator-isolation.test.js +134 -0
  37. package/dist/agent/__tests__/orchestrator-isolation.test.js.map +1 -0
  38. package/dist/agent/__tests__/orchestrator.test.d.ts +2 -0
  39. package/dist/agent/__tests__/orchestrator.test.d.ts.map +1 -0
  40. package/dist/agent/__tests__/orchestrator.test.js +201 -0
  41. package/dist/agent/__tests__/orchestrator.test.js.map +1 -0
  42. package/dist/agent/__tests__/pipeline.test.d.ts +2 -0
  43. package/dist/agent/__tests__/pipeline.test.d.ts.map +1 -0
  44. package/dist/agent/__tests__/pipeline.test.js +226 -0
  45. package/dist/agent/__tests__/pipeline.test.js.map +1 -0
  46. package/dist/agent/__tests__/planner.test.d.ts +2 -0
  47. package/dist/agent/__tests__/planner.test.d.ts.map +1 -0
  48. package/dist/agent/__tests__/planner.test.js +98 -0
  49. package/dist/agent/__tests__/planner.test.js.map +1 -0
  50. package/dist/agent/__tests__/prompt-enhancer.test.d.ts +2 -0
  51. package/dist/agent/__tests__/prompt-enhancer.test.d.ts.map +1 -0
  52. package/dist/agent/__tests__/prompt-enhancer.test.js +107 -0
  53. package/dist/agent/__tests__/prompt-enhancer.test.js.map +1 -0
  54. package/dist/agent/__tests__/trace-format.test.d.ts +2 -0
  55. package/dist/agent/__tests__/trace-format.test.d.ts.map +1 -0
  56. package/dist/agent/__tests__/trace-format.test.js +104 -0
  57. package/dist/agent/__tests__/trace-format.test.js.map +1 -0
  58. package/dist/agent/__tests__/trace-store.test.d.ts +2 -0
  59. package/dist/agent/__tests__/trace-store.test.d.ts.map +1 -0
  60. package/dist/agent/__tests__/trace-store.test.js +113 -0
  61. package/dist/agent/__tests__/trace-store.test.js.map +1 -0
  62. package/dist/agent/code-graph.d.ts +18 -0
  63. package/dist/agent/code-graph.d.ts.map +1 -0
  64. package/dist/agent/code-graph.js +119 -0
  65. package/dist/agent/code-graph.js.map +1 -0
  66. package/dist/agent/env.d.ts +11 -0
  67. package/dist/agent/env.d.ts.map +1 -0
  68. package/dist/agent/env.js +82 -0
  69. package/dist/agent/env.js.map +1 -0
  70. package/dist/agent/evaluator.d.ts +13 -0
  71. package/dist/agent/evaluator.d.ts.map +1 -0
  72. package/dist/agent/evaluator.js +146 -0
  73. package/dist/agent/evaluator.js.map +1 -0
  74. package/dist/agent/fleet/git-isolation.d.ts +142 -0
  75. package/dist/agent/fleet/git-isolation.d.ts.map +1 -0
  76. package/dist/agent/fleet/git-isolation.js +290 -0
  77. package/dist/agent/fleet/git-isolation.js.map +1 -0
  78. package/dist/agent/fleet/memory.d.ts +21 -0
  79. package/dist/agent/fleet/memory.d.ts.map +1 -0
  80. package/dist/agent/fleet/memory.js +129 -0
  81. package/dist/agent/fleet/memory.js.map +1 -0
  82. package/dist/agent/fleet/orchestrator.d.ts +103 -0
  83. package/dist/agent/fleet/orchestrator.d.ts.map +1 -0
  84. package/dist/agent/fleet/orchestrator.js +355 -0
  85. package/dist/agent/fleet/orchestrator.js.map +1 -0
  86. package/dist/agent/fleet/store.d.ts +13 -0
  87. package/dist/agent/fleet/store.d.ts.map +1 -0
  88. package/dist/agent/fleet/store.js +79 -0
  89. package/dist/agent/fleet/store.js.map +1 -0
  90. package/dist/agent/fleet/types.d.ts +105 -0
  91. package/dist/agent/fleet/types.d.ts.map +1 -0
  92. package/dist/agent/fleet/types.js +17 -0
  93. package/dist/agent/fleet/types.js.map +1 -0
  94. package/dist/agent/judge.d.ts +38 -0
  95. package/dist/agent/judge.d.ts.map +1 -0
  96. package/dist/agent/judge.js +170 -0
  97. package/dist/agent/judge.js.map +1 -0
  98. package/dist/agent/loop.d.ts +61 -0
  99. package/dist/agent/loop.d.ts.map +1 -0
  100. package/dist/agent/loop.js +134 -0
  101. package/dist/agent/loop.js.map +1 -0
  102. package/dist/agent/memory.d.ts +14 -0
  103. package/dist/agent/memory.d.ts.map +1 -0
  104. package/dist/agent/memory.js +118 -0
  105. package/dist/agent/memory.js.map +1 -0
  106. package/dist/agent/model-router.d.ts +79 -0
  107. package/dist/agent/model-router.d.ts.map +1 -0
  108. package/dist/agent/model-router.js +141 -0
  109. package/dist/agent/model-router.js.map +1 -0
  110. package/dist/agent/model.d.ts +9 -0
  111. package/dist/agent/model.d.ts.map +1 -0
  112. package/dist/agent/model.js +24 -0
  113. package/dist/agent/model.js.map +1 -0
  114. package/dist/agent/pipeline.d.ts +82 -0
  115. package/dist/agent/pipeline.d.ts.map +1 -0
  116. package/dist/agent/pipeline.js +320 -0
  117. package/dist/agent/pipeline.js.map +1 -0
  118. package/dist/agent/planner.d.ts +16 -0
  119. package/dist/agent/planner.d.ts.map +1 -0
  120. package/dist/agent/planner.js +126 -0
  121. package/dist/agent/planner.js.map +1 -0
  122. package/dist/agent/project-context.d.ts +13 -0
  123. package/dist/agent/project-context.d.ts.map +1 -0
  124. package/dist/agent/project-context.js +66 -0
  125. package/dist/agent/project-context.js.map +1 -0
  126. package/dist/agent/prompt-enhancer.d.ts +37 -0
  127. package/dist/agent/prompt-enhancer.d.ts.map +1 -0
  128. package/dist/agent/prompt-enhancer.js +115 -0
  129. package/dist/agent/prompt-enhancer.js.map +1 -0
  130. package/dist/agent/system-prompt.d.ts +9 -0
  131. package/dist/agent/system-prompt.d.ts.map +1 -0
  132. package/dist/agent/system-prompt.js +38 -0
  133. package/dist/agent/system-prompt.js.map +1 -0
  134. package/dist/agent/tools.d.ts +19 -0
  135. package/dist/agent/tools.d.ts.map +1 -0
  136. package/dist/agent/tools.js +323 -0
  137. package/dist/agent/tools.js.map +1 -0
  138. package/dist/agent/trace-format.d.ts +6 -0
  139. package/dist/agent/trace-format.d.ts.map +1 -0
  140. package/dist/agent/trace-format.js +74 -0
  141. package/dist/agent/trace-format.js.map +1 -0
  142. package/dist/agent/trace-store.d.ts +19 -0
  143. package/dist/agent/trace-store.d.ts.map +1 -0
  144. package/dist/agent/trace-store.js +82 -0
  145. package/dist/agent/trace-store.js.map +1 -0
  146. package/dist/agent/trace.d.ts +121 -0
  147. package/dist/agent/trace.d.ts.map +1 -0
  148. package/dist/agent/trace.js +2 -0
  149. package/dist/agent/trace.js.map +1 -0
  150. package/dist/commands/__tests__/replay.test.d.ts +2 -0
  151. package/dist/commands/__tests__/replay.test.d.ts.map +1 -0
  152. package/dist/commands/__tests__/replay.test.js +76 -0
  153. package/dist/commands/__tests__/replay.test.js.map +1 -0
  154. package/dist/commands/agent.mcp.consent.list.d.ts +3 -0
  155. package/dist/commands/agent.mcp.consent.list.d.ts.map +1 -0
  156. package/dist/commands/agent.mcp.consent.list.js +30 -0
  157. package/dist/commands/agent.mcp.consent.list.js.map +1 -0
  158. package/dist/commands/agent.mcp.consent.resolve.d.ts +3 -0
  159. package/dist/commands/agent.mcp.consent.resolve.d.ts.map +1 -0
  160. package/dist/commands/agent.mcp.consent.resolve.js +34 -0
  161. package/dist/commands/agent.mcp.consent.resolve.js.map +1 -0
  162. package/dist/commands/agent.mcp.delete.d.ts +3 -0
  163. package/dist/commands/agent.mcp.delete.d.ts.map +1 -0
  164. package/dist/commands/agent.mcp.delete.js +27 -0
  165. package/dist/commands/agent.mcp.delete.js.map +1 -0
  166. package/dist/commands/agent.mcp.set_enabled.d.ts +3 -0
  167. package/dist/commands/agent.mcp.set_enabled.d.ts.map +1 -0
  168. package/dist/commands/agent.mcp.set_enabled.js +33 -0
  169. package/dist/commands/agent.mcp.set_enabled.js.map +1 -0
  170. package/dist/commands/agent.skill.load.d.ts +3 -0
  171. package/dist/commands/agent.skill.load.d.ts.map +1 -0
  172. package/dist/commands/agent.skill.load.js +57 -0
  173. package/dist/commands/agent.skill.load.js.map +1 -0
  174. package/dist/commands/audit.log.query.d.ts +3 -0
  175. package/dist/commands/audit.log.query.d.ts.map +1 -0
  176. package/dist/commands/audit.log.query.js +42 -0
  177. package/dist/commands/audit.log.query.js.map +1 -0
  178. package/dist/commands/automation.create.d.ts.map +1 -1
  179. package/dist/commands/automation.create.js +43 -4
  180. package/dist/commands/automation.create.js.map +1 -1
  181. package/dist/commands/automation.disable.d.ts +3 -0
  182. package/dist/commands/automation.disable.d.ts.map +1 -0
  183. package/dist/commands/automation.disable.js +24 -0
  184. package/dist/commands/automation.disable.js.map +1 -0
  185. package/dist/commands/automation.enable.d.ts +3 -0
  186. package/dist/commands/automation.enable.d.ts.map +1 -0
  187. package/dist/commands/automation.enable.js +24 -0
  188. package/dist/commands/automation.enable.js.map +1 -0
  189. package/dist/commands/automation.update.d.ts +3 -0
  190. package/dist/commands/automation.update.d.ts.map +1 -0
  191. package/dist/commands/automation.update.js +42 -0
  192. package/dist/commands/automation.update.js.map +1 -0
  193. package/dist/commands/code.d.ts +14 -0
  194. package/dist/commands/code.d.ts.map +1 -0
  195. package/dist/commands/code.js +100 -0
  196. package/dist/commands/code.js.map +1 -0
  197. package/dist/commands/config.d.ts +2 -0
  198. package/dist/commands/config.d.ts.map +1 -0
  199. package/dist/commands/config.js +66 -0
  200. package/dist/commands/config.js.map +1 -0
  201. package/dist/commands/conversation.files.list.d.ts +3 -0
  202. package/dist/commands/conversation.files.list.d.ts.map +1 -0
  203. package/dist/commands/conversation.files.list.js +39 -0
  204. package/dist/commands/conversation.files.list.js.map +1 -0
  205. package/dist/commands/env.d.ts +19 -0
  206. package/dist/commands/env.d.ts.map +1 -0
  207. package/dist/commands/env.js +64 -0
  208. package/dist/commands/env.js.map +1 -0
  209. package/dist/commands/graph.search.d.ts +10 -0
  210. package/dist/commands/graph.search.d.ts.map +1 -0
  211. package/dist/commands/graph.search.js +25 -0
  212. package/dist/commands/graph.search.js.map +1 -0
  213. package/dist/commands/markdown.generate.d.ts +3 -0
  214. package/dist/commands/markdown.generate.d.ts.map +1 -0
  215. package/dist/commands/markdown.generate.js +37 -0
  216. package/dist/commands/markdown.generate.js.map +1 -0
  217. package/dist/commands/mcp.add.d.ts +13 -0
  218. package/dist/commands/mcp.add.d.ts.map +1 -0
  219. package/dist/commands/mcp.add.js +110 -0
  220. package/dist/commands/mcp.add.js.map +1 -0
  221. package/dist/commands/mcp.auth.d.ts +10 -0
  222. package/dist/commands/mcp.auth.d.ts.map +1 -0
  223. package/dist/commands/mcp.auth.js +132 -0
  224. package/dist/commands/mcp.auth.js.map +1 -0
  225. package/dist/commands/mcp.check.d.ts +10 -0
  226. package/dist/commands/mcp.check.d.ts.map +1 -0
  227. package/dist/commands/mcp.check.js +114 -0
  228. package/dist/commands/mcp.check.js.map +1 -0
  229. package/dist/commands/mcp.list.d.ts +9 -0
  230. package/dist/commands/mcp.list.d.ts.map +1 -0
  231. package/dist/commands/mcp.list.js +93 -0
  232. package/dist/commands/mcp.list.js.map +1 -0
  233. package/dist/commands/mcp.permit.d.ts +12 -0
  234. package/dist/commands/mcp.permit.d.ts.map +1 -0
  235. package/dist/commands/mcp.permit.js +117 -0
  236. package/dist/commands/mcp.permit.js.map +1 -0
  237. package/dist/commands/mcp.remove.d.ts +9 -0
  238. package/dist/commands/mcp.remove.d.ts.map +1 -0
  239. package/dist/commands/mcp.remove.js +65 -0
  240. package/dist/commands/mcp.remove.js.map +1 -0
  241. package/dist/commands/mermaid.generate.d.ts +3 -0
  242. package/dist/commands/mermaid.generate.d.ts.map +1 -0
  243. package/dist/commands/mermaid.generate.js +33 -0
  244. package/dist/commands/mermaid.generate.js.map +1 -0
  245. package/dist/commands/ontology.neighbors.d.ts +3 -0
  246. package/dist/commands/ontology.neighbors.d.ts.map +1 -0
  247. package/dist/commands/ontology.neighbors.js +34 -0
  248. package/dist/commands/ontology.neighbors.js.map +1 -0
  249. package/dist/commands/ontology.query.d.ts +3 -0
  250. package/dist/commands/ontology.query.d.ts.map +1 -0
  251. package/dist/commands/ontology.query.js +36 -0
  252. package/dist/commands/ontology.query.js.map +1 -0
  253. package/dist/commands/plugin.org.install_bulk.js +1 -1
  254. package/dist/commands/plugin.org.install_bulk.js.map +1 -1
  255. package/dist/commands/privacy.erase.d.ts.map +1 -1
  256. package/dist/commands/privacy.erase.js +2 -1
  257. package/dist/commands/privacy.erase.js.map +1 -1
  258. package/dist/commands/privacy.erase.test.d.ts +2 -0
  259. package/dist/commands/privacy.erase.test.d.ts.map +1 -0
  260. package/dist/commands/privacy.erase.test.js +132 -0
  261. package/dist/commands/privacy.erase.test.js.map +1 -0
  262. package/dist/commands/replay.d.ts +5 -0
  263. package/dist/commands/replay.d.ts.map +1 -0
  264. package/dist/commands/replay.js +28 -0
  265. package/dist/commands/replay.js.map +1 -0
  266. package/dist/commands/schema/schema.config.d.ts +3 -0
  267. package/dist/commands/schema/schema.config.d.ts.map +1 -0
  268. package/dist/commands/schema/schema.config.js +34 -0
  269. package/dist/commands/schema/schema.config.js.map +1 -0
  270. package/dist/commands/schema/schema.disable.d.ts +3 -0
  271. package/dist/commands/schema/schema.disable.d.ts.map +1 -0
  272. package/dist/commands/schema/schema.disable.js +22 -0
  273. package/dist/commands/schema/schema.disable.js.map +1 -0
  274. package/dist/commands/schema/schema.enable.d.ts +3 -0
  275. package/dist/commands/schema/schema.enable.d.ts.map +1 -0
  276. package/dist/commands/schema/schema.enable.js +22 -0
  277. package/dist/commands/schema/schema.enable.js.map +1 -0
  278. package/dist/commands/schema/schema.export.d.ts +3 -0
  279. package/dist/commands/schema/schema.export.d.ts.map +1 -0
  280. package/dist/commands/schema/schema.export.js +31 -0
  281. package/dist/commands/schema/schema.export.js.map +1 -0
  282. package/dist/commands/schema/schema.get.d.ts +3 -0
  283. package/dist/commands/schema/schema.get.d.ts.map +1 -0
  284. package/dist/commands/schema/schema.get.js +23 -0
  285. package/dist/commands/schema/schema.get.js.map +1 -0
  286. package/dist/commands/schema/schema.label.d.ts +5 -0
  287. package/dist/commands/schema/schema.label.d.ts.map +1 -0
  288. package/dist/commands/schema/schema.label.js +60 -0
  289. package/dist/commands/schema/schema.label.js.map +1 -0
  290. package/dist/commands/schema/schema.list.d.ts +3 -0
  291. package/dist/commands/schema/schema.list.d.ts.map +1 -0
  292. package/dist/commands/schema/schema.list.js +30 -0
  293. package/dist/commands/schema/schema.list.js.map +1 -0
  294. package/dist/commands/schema/schema.prop.d.ts +5 -0
  295. package/dist/commands/schema/schema.prop.d.ts.map +1 -0
  296. package/dist/commands/schema/schema.prop.js +72 -0
  297. package/dist/commands/schema/schema.prop.js.map +1 -0
  298. package/dist/commands/schema/schema.reconcile.d.ts +10 -0
  299. package/dist/commands/schema/schema.reconcile.d.ts.map +1 -0
  300. package/dist/commands/schema/schema.reconcile.js +65 -0
  301. package/dist/commands/schema/schema.reconcile.js.map +1 -0
  302. package/dist/commands/schema/schema.rel.d.ts +5 -0
  303. package/dist/commands/schema/schema.rel.d.ts.map +1 -0
  304. package/dist/commands/schema/schema.rel.js +65 -0
  305. package/dist/commands/schema/schema.rel.js.map +1 -0
  306. package/dist/commands/schema/schema.version.d.ts +7 -0
  307. package/dist/commands/schema/schema.version.d.ts.map +1 -0
  308. package/dist/commands/schema/schema.version.js +96 -0
  309. package/dist/commands/schema/schema.version.js.map +1 -0
  310. package/dist/commands/secret.d.ts +23 -0
  311. package/dist/commands/secret.d.ts.map +1 -0
  312. package/dist/commands/secret.js +90 -0
  313. package/dist/commands/secret.js.map +1 -0
  314. package/dist/commands/skill.create.d.ts +3 -0
  315. package/dist/commands/skill.create.d.ts.map +1 -0
  316. package/dist/commands/skill.create.js +52 -0
  317. package/dist/commands/skill.create.js.map +1 -0
  318. package/dist/commands/skill.edit.d.ts +3 -0
  319. package/dist/commands/skill.edit.d.ts.map +1 -0
  320. package/dist/commands/skill.edit.js +28 -0
  321. package/dist/commands/skill.edit.js.map +1 -0
  322. package/dist/commands/skill.enable.d.ts +3 -0
  323. package/dist/commands/skill.enable.d.ts.map +1 -0
  324. package/dist/commands/skill.enable.js +31 -0
  325. package/dist/commands/skill.enable.js.map +1 -0
  326. package/dist/commands/skill.export.d.ts +3 -0
  327. package/dist/commands/skill.export.d.ts.map +1 -0
  328. package/dist/commands/skill.export.js +25 -0
  329. package/dist/commands/skill.export.js.map +1 -0
  330. package/dist/commands/skill.metrics.read.d.ts +3 -0
  331. package/dist/commands/skill.metrics.read.d.ts.map +1 -0
  332. package/dist/commands/skill.metrics.read.js +56 -0
  333. package/dist/commands/skill.metrics.read.js.map +1 -0
  334. package/dist/commands/skill.version.activate.d.ts +3 -0
  335. package/dist/commands/skill.version.activate.d.ts.map +1 -0
  336. package/dist/commands/skill.version.activate.js +24 -0
  337. package/dist/commands/skill.version.activate.js.map +1 -0
  338. package/dist/commands/skill.version.get.d.ts +3 -0
  339. package/dist/commands/skill.version.get.d.ts.map +1 -0
  340. package/dist/commands/skill.version.get.js +43 -0
  341. package/dist/commands/skill.version.get.js.map +1 -0
  342. package/dist/commands/skill.version.list.d.ts +3 -0
  343. package/dist/commands/skill.version.list.d.ts.map +1 -0
  344. package/dist/commands/skill.version.list.js +38 -0
  345. package/dist/commands/skill.version.list.js.map +1 -0
  346. package/dist/commands/skill.version.upload.d.ts +3 -0
  347. package/dist/commands/skill.version.upload.d.ts.map +1 -0
  348. package/dist/commands/skill.version.upload.js +28 -0
  349. package/dist/commands/skill.version.upload.js.map +1 -0
  350. package/dist/commands/skill.workspace.install.d.ts +3 -0
  351. package/dist/commands/skill.workspace.install.d.ts.map +1 -0
  352. package/dist/commands/skill.workspace.install.js +52 -0
  353. package/dist/commands/skill.workspace.install.js.map +1 -0
  354. package/dist/commands.test.js +1391 -337
  355. package/dist/commands.test.js.map +1 -1
  356. package/dist/components/DevStatus.d.ts.map +1 -1
  357. package/dist/components/DevStatus.js +3 -2
  358. package/dist/components/DevStatus.js.map +1 -1
  359. package/dist/daemon/client.d.ts +30 -0
  360. package/dist/daemon/client.d.ts.map +1 -0
  361. package/dist/daemon/client.js +97 -0
  362. package/dist/daemon/client.js.map +1 -0
  363. package/dist/daemon/code-graph/builder.d.ts +6 -0
  364. package/dist/daemon/code-graph/builder.d.ts.map +1 -0
  365. package/dist/daemon/code-graph/builder.js +215 -0
  366. package/dist/daemon/code-graph/builder.js.map +1 -0
  367. package/dist/daemon/code-graph/query.d.ts +29 -0
  368. package/dist/daemon/code-graph/query.d.ts.map +1 -0
  369. package/dist/daemon/code-graph/query.js +98 -0
  370. package/dist/daemon/code-graph/query.js.map +1 -0
  371. package/dist/daemon/code-graph/types.d.ts +37 -0
  372. package/dist/daemon/code-graph/types.d.ts.map +1 -0
  373. package/dist/daemon/code-graph/types.js +5 -0
  374. package/dist/daemon/code-graph/types.js.map +1 -0
  375. package/dist/daemon/code-graph/watcher.d.ts +37 -0
  376. package/dist/daemon/code-graph/watcher.d.ts.map +1 -0
  377. package/dist/daemon/code-graph/watcher.js +79 -0
  378. package/dist/daemon/code-graph/watcher.js.map +1 -0
  379. package/dist/daemon/lifecycle.d.ts +6 -0
  380. package/dist/daemon/lifecycle.d.ts.map +1 -0
  381. package/dist/daemon/lifecycle.js +132 -0
  382. package/dist/daemon/lifecycle.js.map +1 -0
  383. package/dist/daemon/protocol.d.ts +113 -0
  384. package/dist/daemon/protocol.d.ts.map +1 -0
  385. package/dist/daemon/protocol.js +16 -0
  386. package/dist/daemon/protocol.js.map +1 -0
  387. package/dist/daemon/server.d.ts +26 -0
  388. package/dist/daemon/server.d.ts.map +1 -0
  389. package/dist/daemon/server.js +168 -0
  390. package/dist/daemon/server.js.map +1 -0
  391. package/dist/index.d.ts +1 -1
  392. package/dist/index.js +262 -310
  393. package/dist/index.js.map +1 -1
  394. package/dist/lib/api.d.ts +5 -0
  395. package/dist/lib/api.d.ts.map +1 -0
  396. package/dist/lib/api.js +52 -0
  397. package/dist/lib/api.js.map +1 -0
  398. package/dist/lib/config.d.ts +3 -0
  399. package/dist/lib/config.d.ts.map +1 -1
  400. package/dist/lib/config.js +16 -3
  401. package/dist/lib/config.js.map +1 -1
  402. package/dist/lib/config.test.js +21 -3
  403. package/dist/lib/config.test.js.map +1 -1
  404. package/dist/lib/differential-context.d.ts +46 -0
  405. package/dist/lib/differential-context.d.ts.map +1 -0
  406. package/dist/lib/differential-context.js +89 -0
  407. package/dist/lib/differential-context.js.map +1 -0
  408. package/dist/lib/resolve.d.ts +3 -0
  409. package/dist/lib/resolve.d.ts.map +1 -0
  410. package/dist/lib/resolve.js +29 -0
  411. package/dist/lib/resolve.js.map +1 -0
  412. package/dist/lib/structured-tool-io.d.ts +31 -0
  413. package/dist/lib/structured-tool-io.d.ts.map +1 -0
  414. package/dist/lib/structured-tool-io.js +56 -0
  415. package/dist/lib/structured-tool-io.js.map +1 -0
  416. package/dist/repl/__tests__/_queue_demo.test.d.ts +2 -0
  417. package/dist/repl/__tests__/_queue_demo.test.d.ts.map +1 -0
  418. package/dist/repl/__tests__/_queue_demo.test.js +40 -0
  419. package/dist/repl/__tests__/_queue_demo.test.js.map +1 -0
  420. package/dist/repl/__tests__/components.test.d.ts +2 -0
  421. package/dist/repl/__tests__/components.test.d.ts.map +1 -0
  422. package/dist/repl/__tests__/components.test.js +38 -0
  423. package/dist/repl/__tests__/components.test.js.map +1 -0
  424. package/dist/repl/__tests__/interactive.queue.test.d.ts +2 -0
  425. package/dist/repl/__tests__/interactive.queue.test.d.ts.map +1 -0
  426. package/dist/repl/__tests__/interactive.queue.test.js +124 -0
  427. package/dist/repl/__tests__/interactive.queue.test.js.map +1 -0
  428. package/dist/repl/components.d.ts +59 -0
  429. package/dist/repl/components.d.ts.map +1 -0
  430. package/dist/repl/components.js +152 -0
  431. package/dist/repl/components.js.map +1 -0
  432. package/dist/repl/interactive.d.ts +12 -0
  433. package/dist/repl/interactive.d.ts.map +1 -0
  434. package/dist/repl/interactive.js +326 -0
  435. package/dist/repl/interactive.js.map +1 -0
  436. package/dist/repl/one-shot.d.ts +9 -0
  437. package/dist/repl/one-shot.d.ts.map +1 -0
  438. package/dist/repl/one-shot.js +83 -0
  439. package/dist/repl/one-shot.js.map +1 -0
  440. package/dist/tui/__tests__/app.test.d.ts +2 -0
  441. package/dist/tui/__tests__/app.test.d.ts.map +1 -0
  442. package/dist/tui/__tests__/app.test.js +136 -0
  443. package/dist/tui/__tests__/app.test.js.map +1 -0
  444. package/dist/tui/__tests__/banner.test.d.ts +2 -0
  445. package/dist/tui/__tests__/banner.test.d.ts.map +1 -0
  446. package/dist/tui/__tests__/banner.test.js +15 -0
  447. package/dist/tui/__tests__/banner.test.js.map +1 -0
  448. package/dist/tui/__tests__/command-form.test.d.ts +2 -0
  449. package/dist/tui/__tests__/command-form.test.d.ts.map +1 -0
  450. package/dist/tui/__tests__/command-form.test.js +96 -0
  451. package/dist/tui/__tests__/command-form.test.js.map +1 -0
  452. package/dist/tui/__tests__/command-tree.test.d.ts +2 -0
  453. package/dist/tui/__tests__/command-tree.test.d.ts.map +1 -0
  454. package/dist/tui/__tests__/command-tree.test.js +55 -0
  455. package/dist/tui/__tests__/command-tree.test.js.map +1 -0
  456. package/dist/tui/__tests__/runner.test.d.ts +2 -0
  457. package/dist/tui/__tests__/runner.test.d.ts.map +1 -0
  458. package/dist/tui/__tests__/runner.test.js +38 -0
  459. package/dist/tui/__tests__/runner.test.js.map +1 -0
  460. package/dist/tui/__tests__/theme.test.d.ts +2 -0
  461. package/dist/tui/__tests__/theme.test.d.ts.map +1 -0
  462. package/dist/tui/__tests__/theme.test.js +11 -0
  463. package/dist/tui/__tests__/theme.test.js.map +1 -0
  464. package/dist/tui/agent-view/activity-feed.d.ts +3 -0
  465. package/dist/tui/agent-view/activity-feed.d.ts.map +1 -0
  466. package/dist/tui/agent-view/activity-feed.js +34 -0
  467. package/dist/tui/agent-view/activity-feed.js.map +1 -0
  468. package/dist/tui/agent-view/budget-bar.d.ts +3 -0
  469. package/dist/tui/agent-view/budget-bar.d.ts.map +1 -0
  470. package/dist/tui/agent-view/budget-bar.js +53 -0
  471. package/dist/tui/agent-view/budget-bar.js.map +1 -0
  472. package/dist/tui/agent-view/compile-panel.d.ts +3 -0
  473. package/dist/tui/agent-view/compile-panel.d.ts.map +1 -0
  474. package/dist/tui/agent-view/compile-panel.js +34 -0
  475. package/dist/tui/agent-view/compile-panel.js.map +1 -0
  476. package/dist/tui/agent-view/index.d.ts +4 -0
  477. package/dist/tui/agent-view/index.d.ts.map +1 -0
  478. package/dist/tui/agent-view/index.js +31 -0
  479. package/dist/tui/agent-view/index.js.map +1 -0
  480. package/dist/tui/agent-view/memory-panel.d.ts +3 -0
  481. package/dist/tui/agent-view/memory-panel.d.ts.map +1 -0
  482. package/dist/tui/agent-view/memory-panel.js +80 -0
  483. package/dist/tui/agent-view/memory-panel.js.map +1 -0
  484. package/dist/tui/agent-view/session-panel.d.ts +3 -0
  485. package/dist/tui/agent-view/session-panel.d.ts.map +1 -0
  486. package/dist/tui/agent-view/session-panel.js +44 -0
  487. package/dist/tui/agent-view/session-panel.js.map +1 -0
  488. package/dist/tui/agent-view/status-bar.d.ts +7 -0
  489. package/dist/tui/agent-view/status-bar.d.ts.map +1 -0
  490. package/dist/tui/agent-view/status-bar.js +22 -0
  491. package/dist/tui/agent-view/status-bar.js.map +1 -0
  492. package/dist/tui/app.d.ts +9 -0
  493. package/dist/tui/app.d.ts.map +1 -0
  494. package/dist/tui/app.js +115 -0
  495. package/dist/tui/app.js.map +1 -0
  496. package/dist/tui/banner.d.ts +5 -0
  497. package/dist/tui/banner.d.ts.map +1 -0
  498. package/dist/tui/banner.js +17 -0
  499. package/dist/tui/banner.js.map +1 -0
  500. package/dist/tui/command-form.d.ts +9 -0
  501. package/dist/tui/command-form.d.ts.map +1 -0
  502. package/dist/tui/command-form.js +76 -0
  503. package/dist/tui/command-form.js.map +1 -0
  504. package/dist/tui/command-tree.d.ts +30 -0
  505. package/dist/tui/command-tree.d.ts.map +1 -0
  506. package/dist/tui/command-tree.js +43 -0
  507. package/dist/tui/command-tree.js.map +1 -0
  508. package/dist/tui/fleet-view/agent-row.d.ts +10 -0
  509. package/dist/tui/fleet-view/agent-row.d.ts.map +1 -0
  510. package/dist/tui/fleet-view/agent-row.js +80 -0
  511. package/dist/tui/fleet-view/agent-row.js.map +1 -0
  512. package/dist/tui/fleet-view/dispatch-input.d.ts +5 -0
  513. package/dist/tui/fleet-view/dispatch-input.d.ts.map +1 -0
  514. package/dist/tui/fleet-view/dispatch-input.js +36 -0
  515. package/dist/tui/fleet-view/dispatch-input.js.map +1 -0
  516. package/dist/tui/fleet-view/fleet-app.d.ts +11 -0
  517. package/dist/tui/fleet-view/fleet-app.d.ts.map +1 -0
  518. package/dist/tui/fleet-view/fleet-app.js +95 -0
  519. package/dist/tui/fleet-view/fleet-app.js.map +1 -0
  520. package/dist/tui/fleet-view/fleet-summary.d.ts +6 -0
  521. package/dist/tui/fleet-view/fleet-summary.d.ts.map +1 -0
  522. package/dist/tui/fleet-view/fleet-summary.js +19 -0
  523. package/dist/tui/fleet-view/fleet-summary.js.map +1 -0
  524. package/dist/tui/fleet-view/index.d.ts +16 -0
  525. package/dist/tui/fleet-view/index.d.ts.map +1 -0
  526. package/dist/tui/fleet-view/index.js +61 -0
  527. package/dist/tui/fleet-view/index.js.map +1 -0
  528. package/dist/tui/runner.d.ts +7 -0
  529. package/dist/tui/runner.d.ts.map +1 -0
  530. package/dist/tui/runner.js +36 -0
  531. package/dist/tui/runner.js.map +1 -0
  532. package/dist/tui/theme.d.ts +8 -0
  533. package/dist/tui/theme.d.ts.map +1 -0
  534. package/dist/tui/theme.js +10 -0
  535. package/dist/tui/theme.js.map +1 -0
  536. package/package.json +12 -7
  537. package/README.html +0 -379
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Prompt evaluator — the cheap front-of-pipeline model call.
3
+ *
4
+ * Before the expensive coding model ever sees a prompt, a small, fast model
5
+ * (Haiku by default) reads it and reports back:
6
+ * - completeness: is this actionable on its own, or is it missing what/where/done?
7
+ * - complexity: how much work / risk / blast-radius does it imply?
8
+ * - a recommended tier for the executor,
9
+ * - the symbols / files / topics worth pulling from the code graph,
10
+ * - a refined prompt with filler removed and intent sharpened (meaning intact),
11
+ * - and its chain of thought.
12
+ *
13
+ * This is what lets the CLI spend Haiku money to decide how to spend Opus money,
14
+ * and to enrich a vague prompt before acting on it. It NEVER blocks a turn: if
15
+ * the model call fails, a transparent heuristic fallback (the deterministic cost
16
+ * router) keeps the pipeline moving.
17
+ */
18
+ import { generateObject } from "ai";
19
+ import { z } from "zod";
20
+ import { classifyTier, modelForTier, accumulateUsage } from "./model-router.js";
21
+ import { emptyUsage } from "./fleet/types.js";
22
+ /** A tier's evaluator-model slug, overridable to track gateway drift. */
23
+ function evaluatorModel(override) {
24
+ return (override ??
25
+ process.env["OXAGEN_LLM_EVALUATOR"] ??
26
+ modelForTier("fast"));
27
+ }
28
+ const evalSchema = z.object({
29
+ completeness: z
30
+ .number()
31
+ .min(0)
32
+ .max(100)
33
+ .describe("0–100. How complete/actionable is the prompt ON ITS OWN? 100 = names what " +
34
+ "to change, where, and how to know it's done. Low = vague or missing key facts."),
35
+ complexity: z
36
+ .number()
37
+ .min(0)
38
+ .max(100)
39
+ .describe("0–100. How much work/risk/blast-radius does this imply? Trivial one-liner ≈ 10; " +
40
+ "multi-file feature ≈ 60; auth/billing/migration/architecture ≈ 90."),
41
+ recommendedTier: z
42
+ .enum(["fast", "balanced", "precise"])
43
+ .describe("Cheapest tier that can do the job: 'fast' mechanical/single-file, 'balanced' " +
44
+ "normal feature work, 'precise' auth/billing/security/migration/architecture."),
45
+ missing: z
46
+ .array(z.string())
47
+ .describe("Specific information the prompt lacks to be fully actionable. Empty if none."),
48
+ contextQueries: z
49
+ .array(z.string())
50
+ .describe("Symbol names, file paths, or short topics worth retrieving from the repo's code " +
51
+ "graph to ground the work (e.g. 'loginUser', 'src/auth/session.ts'). Empty if none."),
52
+ refinedPrompt: z
53
+ .string()
54
+ .describe("The prompt rewritten for the coding agent: remove pleasantries, hedging, and " +
55
+ "redundancy; sharpen the ask. PRESERVE EVERY real requirement and constraint — " +
56
+ "never invent, never drop intent. If the prompt is already tight, return it unchanged."),
57
+ removed: z
58
+ .array(z.string())
59
+ .describe("Phrases removed from the original because they add no value. Empty if none."),
60
+ reasoning: z
61
+ .string()
62
+ .describe("2–4 sentence explanation of the scores and what context will help."),
63
+ });
64
+ const EVALUATOR_SYSTEM = [
65
+ "You are the evaluation stage of an agentic coding system. A coding agent is about",
66
+ "to act on the user's prompt against a real repository. Your job is to triage it.",
67
+ "",
68
+ "Score it honestly:",
69
+ "- completeness: can the agent act on this WITHOUT guessing? Penalize missing files,",
70
+ " undefined terms, and 'fix it' with no symptom. Reward concrete targets and acceptance.",
71
+ "- complexity: estimate the work, risk, and blast radius — not the prompt's length.",
72
+ "",
73
+ "Then help the agent succeed:",
74
+ "- recommendedTier: pick the CHEAPEST tier that can do the job well. Reserve 'precise'",
75
+ " for auth, billing, security, migrations, schema, or architecture.",
76
+ "- contextQueries: name the exact symbols/files/topics the agent should pull from the",
77
+ " code graph so it skips blind exploration. Prefer real identifiers and paths.",
78
+ "- refinedPrompt: rewrite for the agent. Strip filler and contradiction; keep 100% of the",
79
+ " actual intent and every constraint. Do NOT add requirements the user did not state.",
80
+ ].join("\n");
81
+ /**
82
+ * Build the deterministic heuristic evaluation used when the model is unavailable
83
+ * or the call fails. Uses the cost router so the tier is still sensible, and never
84
+ * mutates the prompt (a safe fallback must not risk dropping intent).
85
+ */
86
+ function heuristicEvaluation(prompt, model) {
87
+ const route = classifyTier({ text: prompt });
88
+ const complexity = route.tier === "precise" ? 85 : route.tier === "balanced" ? 55 : 20;
89
+ // Longer, more specific prompts are treated as more complete; very short asks less so.
90
+ const len = prompt.trim().length;
91
+ const completeness = len < 40 ? 45 : len < 160 ? 65 : 80;
92
+ return {
93
+ completeness,
94
+ complexity,
95
+ recommendedTier: route.tier,
96
+ missing: [],
97
+ contextQueries: [],
98
+ refinedPrompt: prompt,
99
+ removed: [],
100
+ reasoning: `Heuristic evaluation (model unavailable): ${route.rationale}.`,
101
+ fallback: true,
102
+ model,
103
+ usage: emptyUsage(),
104
+ };
105
+ }
106
+ /**
107
+ * Evaluate a prompt with the cheap model. Returns the model's structured read, or
108
+ * a heuristic fallback that never throws — the pipeline must always make progress.
109
+ */
110
+ export async function evaluatePrompt(opts) {
111
+ const model = evaluatorModel(opts.model);
112
+ try {
113
+ const { object, usage } = await generateObject({
114
+ model,
115
+ schema: evalSchema,
116
+ system: EVALUATOR_SYSTEM,
117
+ prompt: `Prompt to evaluate:\n${opts.prompt}`,
118
+ abortSignal: opts.signal,
119
+ });
120
+ // A refined prompt that came back empty would silently drop the user's intent —
121
+ // fall back to the original text in that case.
122
+ const refinedPrompt = object.refinedPrompt.trim() || opts.prompt;
123
+ return {
124
+ completeness: clamp(object.completeness),
125
+ complexity: clamp(object.complexity),
126
+ recommendedTier: object.recommendedTier,
127
+ missing: object.missing,
128
+ contextQueries: object.contextQueries,
129
+ refinedPrompt,
130
+ removed: object.removed,
131
+ reasoning: object.reasoning,
132
+ fallback: false,
133
+ model,
134
+ usage: accumulateUsage(emptyUsage(), model, usage),
135
+ };
136
+ }
137
+ catch {
138
+ return heuristicEvaluation(opts.prompt, model);
139
+ }
140
+ }
141
+ function clamp(n) {
142
+ if (Number.isNaN(n))
143
+ return 0;
144
+ return Math.max(0, Math.min(100, Math.round(n)));
145
+ }
146
+ //# sourceMappingURL=evaluator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluator.js","sourceRoot":"","sources":["../../src/agent/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,yEAAyE;AACzE,SAAS,cAAc,CAAC,QAAiB;IACvC,OAAO,CACL,QAAQ;QACR,OAAO,CAAC,GAA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B,MAAM,EAAE,gBAAgB;YACxB,MAAM,EAAE,wBAAwB,IAAI,CAAC,MAAM,EAAE;YAC7C,WAAW,EAAE,IAAI,CAAC,MAAM;SACzB,CAAC,CAAC;QACH,gFAAgF;QAChF,+CAA+C;QAC/C,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC,MAAM,CAAC;QACjE,OAAO;YACL,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,YAAY,CAAC;YACxC,UAAU,EAAE,KAAK,CAAC,MAAM,CAAC,UAAU,CAAC;YACpC,eAAe,EAAE,MAAM,CAAC,eAAe;YACvC,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,cAAc,EAAE,MAAM,CAAC,cAAc;YACrC,aAAa;YACb,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,QAAQ,EAAE,KAAK;YACf,KAAK;YACL,KAAK,EAAE,eAAe,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC;SACnD,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,mBAAmB,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACjD,CAAC;AACH,CAAC;AAED,SAAS,KAAK,CAAC,CAAS;IACtB,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IAC9B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACnD,CAAC"}
@@ -0,0 +1,142 @@
1
+ /** Result of one git invocation. Never throws — the exit code is returned. */
2
+ export interface GitResult {
3
+ stdout: string;
4
+ stderr: string;
5
+ code: number;
6
+ }
7
+ /** Runs git with the given args in `cwd`. Injectable for tests. */
8
+ export type GitRunner = (args: string[], cwd?: string) => Promise<GitResult>;
9
+ /** The real runner: `git <args>` via child_process, rooted at the repo. */
10
+ export declare function defaultGitRunner(repoRoot: string): GitRunner;
11
+ /** Outcome of integrating one task branch into the integration branch. */
12
+ export interface IntegrationResult {
13
+ /** True when the task branch merged cleanly (or had nothing new to merge). */
14
+ ok: boolean;
15
+ /** Integration branch tip after a clean merge. */
16
+ commit?: string;
17
+ /** Conflicting files (relative paths) when `ok` is false. */
18
+ conflicts?: string[];
19
+ /** The task branch that was being integrated. */
20
+ taskBranch: string;
21
+ /** The pinned task tip — always recoverable, even on conflict. */
22
+ taskTip?: string;
23
+ /** True when `rerere` auto-applied a previously-recorded resolution. */
24
+ autoResolved?: boolean;
25
+ }
26
+ /** A pinned atomic commit produced by an agent. */
27
+ export interface Checkpoint {
28
+ taskId: string;
29
+ hash: string;
30
+ /** Durable ref keeping the commit reachable forever. */
31
+ ref: string;
32
+ message: string;
33
+ }
34
+ /**
35
+ * The isolation surface the fleet depends on. {@link WorktreeManager} is the
36
+ * real implementation; tests inject a fake satisfying this interface so the
37
+ * orchestrator's own unit tests never touch git or the filesystem.
38
+ */
39
+ export interface Isolation {
40
+ init(): Promise<void>;
41
+ spawn(taskId: string): Promise<string>;
42
+ checkpoint(taskId: string, message: string): Promise<Checkpoint | null>;
43
+ recordedCommits(taskId: string): readonly Checkpoint[];
44
+ integrate(taskId: string, message?: string): Promise<IntegrationResult>;
45
+ integrationRef(): {
46
+ path: string;
47
+ branch: string;
48
+ } | null;
49
+ dispose(taskId: string, opts?: {
50
+ keep?: boolean;
51
+ }): Promise<void>;
52
+ cleanupAll(): Promise<void>;
53
+ }
54
+ export interface WorktreeManagerOptions {
55
+ /** Any path inside the repo; the real toplevel is resolved in {@link init}. */
56
+ repoRoot: string;
57
+ /** Ref namespace for this fleet run's branches/pins (e.g. the plan id). */
58
+ namespace?: string;
59
+ /** Where worktrees are created (default `<repo>/.oxagen/worktrees`). */
60
+ root?: string;
61
+ /** Inject a fake git for tests; defaults to {@link defaultGitRunner}. */
62
+ git?: GitRunner;
63
+ }
64
+ /**
65
+ * Owns the worktrees, branches, and durability pins for one fleet run.
66
+ *
67
+ * One instance per {@link Fleet}. Methods are safe to call from many concurrent
68
+ * agents: `spawn`/`checkpoint`/`dispose` operate on disjoint worktrees, and
69
+ * `integrate` is serialized internally so two merges never race on the
70
+ * integration branch.
71
+ */
72
+ export declare class WorktreeManager implements Isolation {
73
+ private readonly opts;
74
+ private readonly git;
75
+ private readonly ns;
76
+ private repoRoot;
77
+ private root;
78
+ /** The frozen commit every task branch is cut from. */
79
+ private baseRef;
80
+ /** Lazily-created integration worktree path + branch. */
81
+ private integration;
82
+ private initialized;
83
+ /** Per-task pin sequence + recorded checkpoints (the durability log). */
84
+ private readonly seq;
85
+ private readonly commits;
86
+ /** Worktrees handed out, by task id. */
87
+ private readonly worktrees;
88
+ /** Serializes `integrate` so concurrent finishers can't race the merge. */
89
+ private integrateLock;
90
+ constructor(opts: WorktreeManagerOptions);
91
+ /**
92
+ * Resolve the repo toplevel, freeze the base ref, enable `rerere`, and keep
93
+ * the worktree root out of git's sight. Idempotent.
94
+ */
95
+ init(): Promise<void>;
96
+ /** The frozen base every task fans out from. */
97
+ get base(): string;
98
+ /**
99
+ * Create an isolated worktree for `taskId` and return its path. The agent runs
100
+ * with this as its `cwd`; nothing it does can touch another agent's tree.
101
+ */
102
+ spawn(taskId: string): Promise<string>;
103
+ /**
104
+ * Atomically commit whatever the agent changed in its worktree and pin the
105
+ * commit under `refs/oxagen/agents/<task>/<n>`. Returns the checkpoint, or
106
+ * `null` when the agent changed nothing.
107
+ */
108
+ checkpoint(taskId: string, message: string): Promise<Checkpoint | null>;
109
+ /** Every pinned checkpoint recorded for a task — the durability log. */
110
+ recordedCommits(taskId: string): readonly Checkpoint[];
111
+ /**
112
+ * Merge a task's branch into the integration branch. Serialized so two merges
113
+ * never race. A conflicting merge is aborted (integration tree left clean) and
114
+ * the conflicting files are returned — never a corrupt half-merge.
115
+ */
116
+ integrate(taskId: string, message?: string): Promise<IntegrationResult>;
117
+ private doIntegrate;
118
+ /** The integration branch + its worktree path, once at least one integrate ran. */
119
+ integrationRef(): {
120
+ path: string;
121
+ branch: string;
122
+ } | null;
123
+ /**
124
+ * Remove a task's worktree. Keeps the branch and the `refs/oxagen/agents` pins
125
+ * (so nothing is lost). Pass `keep` to leave the worktree on disk — e.g. after
126
+ * a conflict, so a resolver agent or human can work in it.
127
+ */
128
+ dispose(taskId: string, opts?: {
129
+ keep?: boolean;
130
+ }): Promise<void>;
131
+ /**
132
+ * Tear down every worktree and prune. Keeps the integration branch (the
133
+ * result) and all `refs/oxagen/agents` pins (the durability log).
134
+ */
135
+ cleanupAll(): Promise<void>;
136
+ private ensureIntegration;
137
+ private removeWorktree;
138
+ private withIntegrateLock;
139
+ /** Keep `.oxagen/` out of git's untracked list without touching tracked .gitignore. */
140
+ private excludeWorktreeRoot;
141
+ }
142
+ //# sourceMappingURL=git-isolation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-isolation.d.ts","sourceRoot":"","sources":["../../../src/agent/fleet/git-isolation.ts"],"names":[],"mappings":"AA8CA,8EAA8E;AAC9E,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd;AAED,mEAAmE;AACnE,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;AAE7E,2EAA2E;AAC3E,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,SAAS,CAiB5D;AAED,0EAA0E;AAC1E,MAAM,WAAW,iBAAiB;IAChC,8EAA8E;IAC9E,EAAE,EAAE,OAAO,CAAC;IACZ,kDAAkD;IAClD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,SAAS,CAAC,EA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AI;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAIzD;;;;OAIG;IACG,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,GAAE;QAAE,IAAI,CAAC,EAAE,OAAO,CAAA;KAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAO3E;;;OAGG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;YAWnB,iBAAiB;YAcjB,cAAc;YAKd,iBAAiB;IAS/B,uFAAuF;IACvF,OAAO,CAAC,mBAAmB;CAY5B"}
@@ -0,0 +1,290 @@
1
+ /**
2
+ * Git isolation protocol for the fleet — the safety layer that makes it
3
+ * *physically impossible* for two parallel subagents to clobber each other's
4
+ * files, and that makes it *impossible to lose* any work an agent committed.
5
+ *
6
+ * The original fleet ran every subagent against one shared working tree and
7
+ * tried to avoid collisions with a guess: tasks whose *predicted* `files[]`
8
+ * overlapped were serialized. That guess fails the moment an agent edits a file
9
+ * it didn't predict — two writes interleave and you get a half-written file,
10
+ * before any commit exists to recover from. The fix is not "commit more
11
+ * cleverly", it's isolation: give each agent its own checkout.
12
+ *
13
+ * The model (a correct, minimal version of "branch-per-change, replay-on-merge"):
14
+ *
15
+ * 1. SPAWN — each task gets its own `git worktree` on its own branch, cut
16
+ * from a single frozen base ref. Separate index, separate HEAD,
17
+ * separate files: file-level clobbering is now structurally
18
+ * impossible, not merely discouraged.
19
+ * 2. CHECKPOINT — the agent's changes are committed atomically, and every
20
+ * commit hash is pinned under `refs/oxagen/agents/<task>/<n>`.
21
+ * A pinned commit is content-addressed and immune to branch
22
+ * deletion and `git gc`: work can be orphaned but never lost.
23
+ * 3. INTEGRATE — task branches are merged back into one integration branch
24
+ * *one at a time* (a mutex), with `rerere` enabled. A merge that
25
+ * conflicts is **aborted**, leaving the integration tree clean,
26
+ * and the conflict is *surfaced* (the files are returned) instead
27
+ * of silently corrupting anything. Conflicts are relocated to an
28
+ * explicit, owned step — they are not made to disappear, because
29
+ * for *code* that is impossible in general (two semantically
30
+ * contradictory edits can't both be right).
31
+ * 4. DISPOSE — worktrees and branches are torn down, but the
32
+ * `refs/oxagen/agents/*` pins are kept. `git for-each-ref
33
+ * refs/oxagen/agents` is then a durable log of every atomic
34
+ * change the fleet ever made, recoverable by hash.
35
+ *
36
+ * Git is shelled via {@link GitRunner} (injectable) so the orchestrator's unit
37
+ * tests stay filesystem-free; the real runner uses `node:child_process`,
38
+ * matching the rest of the CLI (no git library dependency).
39
+ */
40
+ import { execFile } from "node:child_process";
41
+ import { mkdirSync, existsSync, readFileSync, appendFileSync } from "node:fs";
42
+ import { join } from "node:path";
43
+ import { promisify } from "node:util";
44
+ const pexec = promisify(execFile);
45
+ /** The real runner: `git <args>` via child_process, rooted at the repo. */
46
+ export function defaultGitRunner(repoRoot) {
47
+ return async (args, cwd) => {
48
+ try {
49
+ const { stdout, stderr } = await pexec("git", args, {
50
+ cwd: cwd ?? repoRoot,
51
+ maxBuffer: 64 * 1024 * 1024,
52
+ });
53
+ return { stdout, stderr, code: 0 };
54
+ }
55
+ catch (e) {
56
+ const err = e;
57
+ return {
58
+ stdout: err.stdout ?? "",
59
+ stderr: err.stderr ?? err.message ?? "",
60
+ code: typeof err.code === "number" ? err.code : 1,
61
+ };
62
+ }
63
+ };
64
+ }
65
+ /** Allowed characters in a branch/path segment derived from a task id. */
66
+ function safeSegment(id) {
67
+ return id.replace(/[^A-Za-z0-9._-]/g, "-").replace(/^-+|-+$/g, "") || "task";
68
+ }
69
+ /**
70
+ * Owns the worktrees, branches, and durability pins for one fleet run.
71
+ *
72
+ * One instance per {@link Fleet}. Methods are safe to call from many concurrent
73
+ * agents: `spawn`/`checkpoint`/`dispose` operate on disjoint worktrees, and
74
+ * `integrate` is serialized internally so two merges never race on the
75
+ * integration branch.
76
+ */
77
+ export class WorktreeManager {
78
+ opts;
79
+ git;
80
+ ns;
81
+ repoRoot;
82
+ root;
83
+ /** The frozen commit every task branch is cut from. */
84
+ baseRef = "";
85
+ /** Lazily-created integration worktree path + branch. */
86
+ integration = null;
87
+ initialized = false;
88
+ /** Per-task pin sequence + recorded checkpoints (the durability log). */
89
+ seq = new Map();
90
+ commits = new Map();
91
+ /** Worktrees handed out, by task id. */
92
+ worktrees = new Map();
93
+ /** Serializes `integrate` so concurrent finishers can't race the merge. */
94
+ integrateLock = Promise.resolve();
95
+ constructor(opts) {
96
+ this.opts = opts;
97
+ this.git = opts.git ?? defaultGitRunner(opts.repoRoot);
98
+ this.ns = safeSegment(opts.namespace ?? "fleet");
99
+ this.repoRoot = opts.repoRoot;
100
+ this.root = opts.root ?? join(opts.repoRoot, ".oxagen", "worktrees");
101
+ }
102
+ /**
103
+ * Resolve the repo toplevel, freeze the base ref, enable `rerere`, and keep
104
+ * the worktree root out of git's sight. Idempotent.
105
+ */
106
+ async init() {
107
+ if (this.initialized)
108
+ return;
109
+ const top = await this.git(["rev-parse", "--show-toplevel"]);
110
+ if (top.code !== 0) {
111
+ throw new Error(`git isolation: not a git repository (${top.stderr.trim()})`);
112
+ }
113
+ this.repoRoot = top.stdout.trim();
114
+ if (!this.opts.root)
115
+ this.root = join(this.repoRoot, ".oxagen", "worktrees");
116
+ const head = await this.git(["rev-parse", "HEAD"]);
117
+ if (head.code !== 0)
118
+ throw new Error(`git isolation: cannot resolve HEAD (${head.stderr.trim()})`);
119
+ this.baseRef = head.stdout.trim();
120
+ // rerere makes repeated conflict resolutions idempotent — a resolver agent
121
+ // (or human) resolves a given conflict once and git replays it thereafter.
122
+ await this.git(["config", "rerere.enabled", "true"]);
123
+ this.excludeWorktreeRoot();
124
+ mkdirSync(this.root, { recursive: true });
125
+ this.initialized = true;
126
+ }
127
+ /** The frozen base every task fans out from. */
128
+ get base() {
129
+ return this.baseRef;
130
+ }
131
+ /**
132
+ * Create an isolated worktree for `taskId` and return its path. The agent runs
133
+ * with this as its `cwd`; nothing it does can touch another agent's tree.
134
+ */
135
+ async spawn(taskId) {
136
+ await this.init();
137
+ const seg = safeSegment(taskId);
138
+ const branch = `fleet/${this.ns}/t/${seg}`;
139
+ const path = join(this.root, this.ns, `t-${seg}`);
140
+ // A re-run may leave a stale worktree/branch behind; clear it first.
141
+ await this.removeWorktree(path);
142
+ await this.git(["branch", "-D", branch]); // ignore "not found"
143
+ const add = await this.git(["worktree", "add", "-b", branch, path, this.baseRef]);
144
+ if (add.code !== 0) {
145
+ throw new Error(`git isolation: worktree add failed for ${taskId}: ${add.stderr.trim()}`);
146
+ }
147
+ this.worktrees.set(taskId, { path, branch });
148
+ return path;
149
+ }
150
+ /**
151
+ * Atomically commit whatever the agent changed in its worktree and pin the
152
+ * commit under `refs/oxagen/agents/<task>/<n>`. Returns the checkpoint, or
153
+ * `null` when the agent changed nothing.
154
+ */
155
+ async checkpoint(taskId, message) {
156
+ const wt = this.worktrees.get(taskId);
157
+ if (!wt)
158
+ throw new Error(`git isolation: no worktree for ${taskId} (call spawn first)`);
159
+ await this.git(["add", "-A"], wt.path);
160
+ const status = await this.git(["status", "--porcelain"], wt.path);
161
+ if (status.code === 0 && status.stdout.trim() === "")
162
+ return null; // nothing changed
163
+ // --no-verify: these are fine-grained per-step commits; the gate runs at
164
+ // integration / CI, not on every micro-commit.
165
+ const commit = await this.git(["commit", "--no-verify", "-m", message], wt.path);
166
+ if (commit.code !== 0) {
167
+ throw new Error(`git isolation: commit failed for ${taskId}: ${commit.stderr.trim()}`);
168
+ }
169
+ const rev = await this.git(["rev-parse", "HEAD"], wt.path);
170
+ const hash = rev.stdout.trim();
171
+ const n = (this.seq.get(taskId) ?? 0) + 1;
172
+ this.seq.set(taskId, n);
173
+ const ref = `refs/oxagen/agents/${safeSegment(taskId)}/${n}`;
174
+ await this.git(["update-ref", ref, hash]); // pin: survives branch deletion + gc
175
+ const cp = { taskId, hash, ref, message };
176
+ const list = this.commits.get(taskId) ?? [];
177
+ list.push(cp);
178
+ this.commits.set(taskId, list);
179
+ return cp;
180
+ }
181
+ /** Every pinned checkpoint recorded for a task — the durability log. */
182
+ recordedCommits(taskId) {
183
+ return this.commits.get(taskId) ?? [];
184
+ }
185
+ /**
186
+ * Merge a task's branch into the integration branch. Serialized so two merges
187
+ * never race. A conflicting merge is aborted (integration tree left clean) and
188
+ * the conflicting files are returned — never a corrupt half-merge.
189
+ */
190
+ integrate(taskId, message) {
191
+ return this.withIntegrateLock(() => this.doIntegrate(taskId, message));
192
+ }
193
+ async doIntegrate(taskId, message) {
194
+ const wt = this.worktrees.get(taskId);
195
+ if (!wt)
196
+ throw new Error(`git isolation: no worktree for ${taskId}`);
197
+ const int = await this.ensureIntegration();
198
+ const msg = message ?? `fleet(${taskId}): integrate`;
199
+ const merge = await this.git(["merge", "--no-ff", "-m", msg, wt.branch], int.path);
200
+ if (merge.code === 0) {
201
+ const tip = await this.git(["rev-parse", "HEAD"], int.path);
202
+ return { ok: true, commit: tip.stdout.trim(), taskBranch: wt.branch };
203
+ }
204
+ // Conflict. rerere may already have replayed a recorded resolution — if no
205
+ // files remain unmerged, commit it and report success.
206
+ const unmerged = await this.git(["diff", "--name-only", "--diff-filter=U"], int.path);
207
+ const conflicts = unmerged.stdout.split("\n").map((l) => l.trim()).filter(Boolean);
208
+ if (conflicts.length === 0) {
209
+ const done = await this.git(["commit", "--no-verify", "--no-edit"], int.path);
210
+ if (done.code === 0) {
211
+ const tip = await this.git(["rev-parse", "HEAD"], int.path);
212
+ return { ok: true, commit: tip.stdout.trim(), taskBranch: wt.branch, autoResolved: true };
213
+ }
214
+ }
215
+ // Real conflict: abort so the integration tree stays clean, and surface it.
216
+ await this.git(["merge", "--abort"], int.path);
217
+ const tip = await this.git(["rev-parse", wt.branch]);
218
+ return { ok: false, conflicts, taskBranch: wt.branch, taskTip: tip.stdout.trim() };
219
+ }
220
+ /** The integration branch + its worktree path, once at least one integrate ran. */
221
+ integrationRef() {
222
+ return this.integration;
223
+ }
224
+ /**
225
+ * Remove a task's worktree. Keeps the branch and the `refs/oxagen/agents` pins
226
+ * (so nothing is lost). Pass `keep` to leave the worktree on disk — e.g. after
227
+ * a conflict, so a resolver agent or human can work in it.
228
+ */
229
+ async dispose(taskId, opts = {}) {
230
+ const wt = this.worktrees.get(taskId);
231
+ if (!wt || opts.keep)
232
+ return;
233
+ await this.removeWorktree(wt.path);
234
+ this.worktrees.delete(taskId);
235
+ }
236
+ /**
237
+ * Tear down every worktree and prune. Keeps the integration branch (the
238
+ * result) and all `refs/oxagen/agents` pins (the durability log).
239
+ */
240
+ async cleanupAll() {
241
+ for (const [id, wt] of this.worktrees) {
242
+ await this.removeWorktree(wt.path);
243
+ this.worktrees.delete(id);
244
+ }
245
+ if (this.integration)
246
+ await this.removeWorktree(this.integration.path);
247
+ await this.git(["worktree", "prune"]);
248
+ }
249
+ // ── internals ────────────────────────────────────────────────────────────
250
+ async ensureIntegration() {
251
+ if (this.integration)
252
+ return this.integration;
253
+ const branch = `fleet/${this.ns}/integration`;
254
+ const path = join(this.root, this.ns, "integration");
255
+ await this.removeWorktree(path);
256
+ await this.git(["branch", "-D", branch]);
257
+ const add = await this.git(["worktree", "add", "-b", branch, path, this.baseRef]);
258
+ if (add.code !== 0) {
259
+ throw new Error(`git isolation: integration worktree failed: ${add.stderr.trim()}`);
260
+ }
261
+ this.integration = { path, branch };
262
+ return this.integration;
263
+ }
264
+ async removeWorktree(path) {
265
+ if (!existsSync(path))
266
+ return;
267
+ await this.git(["worktree", "remove", "--force", path]);
268
+ }
269
+ async withIntegrateLock(fn) {
270
+ const run = this.integrateLock.then(fn, fn);
271
+ this.integrateLock = run.then(() => undefined, () => undefined);
272
+ return run;
273
+ }
274
+ /** Keep `.oxagen/` out of git's untracked list without touching tracked .gitignore. */
275
+ excludeWorktreeRoot() {
276
+ try {
277
+ const exclude = join(this.repoRoot, ".git", "info", "exclude");
278
+ if (!existsSync(exclude))
279
+ return;
280
+ const body = readFileSync(exclude, "utf8");
281
+ if (!body.split("\n").some((l) => l.trim() === ".oxagen/")) {
282
+ appendFileSync(exclude, `${body.endsWith("\n") ? "" : "\n"}.oxagen/\n`);
283
+ }
284
+ }
285
+ catch {
286
+ /* best-effort; isolation still works if we can't write the exclude */
287
+ }
288
+ }
289
+ }
290
+ //# sourceMappingURL=git-isolation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"git-isolation.js","sourceRoot":"","sources":["../../../src/agent/fleet/git-isolation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAC9E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,KAAK,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAYlC,2EAA2E;AAC3E,MAAM,UAAU,gBAAgB,CAAC,QAAgB;IAC/C,OAAO,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QACzB,IAAI,CAAC;YACH,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,KAAK,CAAC,KAAK,EAAE,IAAI,EAAE;gBAClD,GAAG,EAAE,GAAG,IAAI,QAAQ;gBACpB,SAAS,EAAE,EAAE,GAAG,IAAI,GAAG,IAAI;aAC5B,CAAC,CAAC;YACH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;QACrC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,GAAG,GAAG,CAAmF,CAAC;YAChG,OAAO;gBACL,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,EAAE;gBACxB,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,OAAO,IAAI,EAAE;gBACvC,IAAI,EAAE,OAAO,GAAG,CAAC,IAAI,KAAK,Q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AAE,CAAC,SAAS,CAChB,CAAC;QACF,OAAO,GAAiB,CAAC;IAC3B,CAAC;IAED,uFAAuF;IAC/E,mBAAmB;QACzB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;YAC/D,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;gBAAE,OAAO;YACjC,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;YAC3C,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,UAAU,CAAC,EAAE,CAAC;gBAC3D,cAAc,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC;YAC1E,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,sEAAsE;QACxE,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ import type { MemoryRecord } from "./types.js";
2
+ export interface FleetMemory {
3
+ /** Append a weighted lesson. Never throws — recording must not break a run. */
4
+ record(rec: Omit<MemoryRecord, "id" | "createdAt">): void;
5
+ /** Return the most relevant lessons for a query, best first. */
6
+ recall(query: string, opts?: {
7
+ limit?: number;
8
+ files?: string[];
9
+ }): MemoryRecord[];
10
+ /** All records, newest first (for the agents screen memory panel). */
11
+ all(): MemoryRecord[];
12
+ }
13
+ /**
14
+ * Open (or create) the project's fleet memory. Reads are cached in-process and
15
+ * invalidated on every write, so a long-lived REPL/agents screen sees its own
16
+ * appends without re-reading the file each recall.
17
+ */
18
+ export declare function openFleetMemory(cwd: string): FleetMemory;
19
+ /** Render recalled lessons as a compact context block for prompt injection. */
20
+ export declare function formatLessons(records: MemoryRecord[]): string;
21
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/agent/fleet/memory.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAwB/C,MAAM,WAAW,WAAW;IAC1B,+EAA+E;IAC/E,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE,IAAI,GAAG,WAAW,CAAC,GAAG,IAAI,CAAC;IAC1D,gEAAgE;IAChE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,GAAG,YAAY,EAAE,CAAC;IACnF,sEAAsE;IACtE,GAAG,IAAI,YAAY,EAAE,CAAC;CACvB;AAQD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAkExD;AAED,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,CAS7D"}