@mcoda/mswarm 0.1.57 → 0.1.61

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 (250) hide show
  1. package/README.md +19 -0
  2. package/dist/codali-executor.d.ts +278 -0
  3. package/dist/codali-executor.d.ts.map +1 -0
  4. package/dist/codali-executor.js +243 -0
  5. package/dist/codali-executor.js.map +1 -0
  6. package/dist/runtime.d.ts +46 -1
  7. package/dist/runtime.d.ts.map +1 -1
  8. package/dist/runtime.js +298 -30
  9. package/dist/runtime.js.map +1 -1
  10. package/dist/server.d.ts.map +1 -1
  11. package/dist/server.js +66 -1
  12. package/dist/server.js.map +1 -1
  13. package/dist/vendor/codali/agents/AgentProtocol.d.ts +287 -0
  14. package/dist/vendor/codali/agents/AgentProtocol.d.ts.map +1 -0
  15. package/dist/vendor/codali/agents/AgentProtocol.js +365 -0
  16. package/dist/vendor/codali/agents/AgentResolver.d.ts +23 -0
  17. package/dist/vendor/codali/agents/AgentResolver.d.ts.map +1 -0
  18. package/dist/vendor/codali/agents/AgentResolver.js +77 -0
  19. package/dist/vendor/codali/agents/PhaseAgentSelector.d.ts +23 -0
  20. package/dist/vendor/codali/agents/PhaseAgentSelector.d.ts.map +1 -0
  21. package/dist/vendor/codali/agents/PhaseAgentSelector.js +287 -0
  22. package/dist/vendor/codali/cli/EvalCommand.d.ts +37 -0
  23. package/dist/vendor/codali/cli/EvalCommand.d.ts.map +1 -0
  24. package/dist/vendor/codali/cli/EvalCommand.js +333 -0
  25. package/dist/vendor/codali/cli/FeedbackCommand.d.ts +22 -0
  26. package/dist/vendor/codali/cli/FeedbackCommand.d.ts.map +1 -0
  27. package/dist/vendor/codali/cli/FeedbackCommand.js +163 -0
  28. package/dist/vendor/codali/cli/RunCommand.d.ts +78 -0
  29. package/dist/vendor/codali/cli/RunCommand.d.ts.map +1 -0
  30. package/dist/vendor/codali/cli/RunCommand.js +2261 -0
  31. package/dist/vendor/codali/cli.d.ts +3 -0
  32. package/dist/vendor/codali/cli.d.ts.map +1 -0
  33. package/dist/vendor/codali/cli.js +109 -0
  34. package/dist/vendor/codali/cognitive/ArchitectPlanner.d.ts +107 -0
  35. package/dist/vendor/codali/cognitive/ArchitectPlanner.d.ts.map +1 -0
  36. package/dist/vendor/codali/cognitive/ArchitectPlanner.js +1726 -0
  37. package/dist/vendor/codali/cognitive/BuilderOutputParser.d.ts +25 -0
  38. package/dist/vendor/codali/cognitive/BuilderOutputParser.d.ts.map +1 -0
  39. package/dist/vendor/codali/cognitive/BuilderOutputParser.js +164 -0
  40. package/dist/vendor/codali/cognitive/BuilderRunner.d.ts +76 -0
  41. package/dist/vendor/codali/cognitive/BuilderRunner.d.ts.map +1 -0
  42. package/dist/vendor/codali/cognitive/BuilderRunner.js +1159 -0
  43. package/dist/vendor/codali/cognitive/ContextAssembler.d.ts +91 -0
  44. package/dist/vendor/codali/cognitive/ContextAssembler.d.ts.map +1 -0
  45. package/dist/vendor/codali/cognitive/ContextAssembler.js +4547 -0
  46. package/dist/vendor/codali/cognitive/ContextBudget.d.ts +19 -0
  47. package/dist/vendor/codali/cognitive/ContextBudget.d.ts.map +1 -0
  48. package/dist/vendor/codali/cognitive/ContextBudget.js +35 -0
  49. package/dist/vendor/codali/cognitive/ContextFileLoader.d.ts +30 -0
  50. package/dist/vendor/codali/cognitive/ContextFileLoader.d.ts.map +1 -0
  51. package/dist/vendor/codali/cognitive/ContextFileLoader.js +307 -0
  52. package/dist/vendor/codali/cognitive/ContextManager.d.ts +47 -0
  53. package/dist/vendor/codali/cognitive/ContextManager.d.ts.map +1 -0
  54. package/dist/vendor/codali/cognitive/ContextManager.js +272 -0
  55. package/dist/vendor/codali/cognitive/ContextRedactor.d.ts +18 -0
  56. package/dist/vendor/codali/cognitive/ContextRedactor.d.ts.map +1 -0
  57. package/dist/vendor/codali/cognitive/ContextRedactor.js +53 -0
  58. package/dist/vendor/codali/cognitive/ContextSelector.d.ts +22 -0
  59. package/dist/vendor/codali/cognitive/ContextSelector.d.ts.map +1 -0
  60. package/dist/vendor/codali/cognitive/ContextSelector.js +431 -0
  61. package/dist/vendor/codali/cognitive/ContextSerializer.d.ts +8 -0
  62. package/dist/vendor/codali/cognitive/ContextSerializer.d.ts.map +1 -0
  63. package/dist/vendor/codali/cognitive/ContextSerializer.js +882 -0
  64. package/dist/vendor/codali/cognitive/ContextStore.d.ts +27 -0
  65. package/dist/vendor/codali/cognitive/ContextStore.d.ts.map +1 -0
  66. package/dist/vendor/codali/cognitive/ContextStore.js +79 -0
  67. package/dist/vendor/codali/cognitive/ContextSummarizer.d.ts +16 -0
  68. package/dist/vendor/codali/cognitive/ContextSummarizer.d.ts.map +1 -0
  69. package/dist/vendor/codali/cognitive/ContextSummarizer.js +45 -0
  70. package/dist/vendor/codali/cognitive/CostEstimator.d.ts +31 -0
  71. package/dist/vendor/codali/cognitive/CostEstimator.d.ts.map +1 -0
  72. package/dist/vendor/codali/cognitive/CostEstimator.js +66 -0
  73. package/dist/vendor/codali/cognitive/CriticEvaluator.d.ts +32 -0
  74. package/dist/vendor/codali/cognitive/CriticEvaluator.d.ts.map +1 -0
  75. package/dist/vendor/codali/cognitive/CriticEvaluator.js +297 -0
  76. package/dist/vendor/codali/cognitive/EvidenceGate.d.ts +9 -0
  77. package/dist/vendor/codali/cognitive/EvidenceGate.d.ts.map +1 -0
  78. package/dist/vendor/codali/cognitive/EvidenceGate.js +75 -0
  79. package/dist/vendor/codali/cognitive/GoldenExampleIndexer.d.ts +12 -0
  80. package/dist/vendor/codali/cognitive/GoldenExampleIndexer.d.ts.map +1 -0
  81. package/dist/vendor/codali/cognitive/GoldenExampleIndexer.js +34 -0
  82. package/dist/vendor/codali/cognitive/GoldenSetStore.d.ts +33 -0
  83. package/dist/vendor/codali/cognitive/GoldenSetStore.d.ts.map +1 -0
  84. package/dist/vendor/codali/cognitive/GoldenSetStore.js +159 -0
  85. package/dist/vendor/codali/cognitive/IntentSignals.d.ts +7 -0
  86. package/dist/vendor/codali/cognitive/IntentSignals.d.ts.map +1 -0
  87. package/dist/vendor/codali/cognitive/IntentSignals.js +285 -0
  88. package/dist/vendor/codali/cognitive/LearningGovernance.d.ts +100 -0
  89. package/dist/vendor/codali/cognitive/LearningGovernance.d.ts.map +1 -0
  90. package/dist/vendor/codali/cognitive/LearningGovernance.js +276 -0
  91. package/dist/vendor/codali/cognitive/MemoryWriteback.d.ts +64 -0
  92. package/dist/vendor/codali/cognitive/MemoryWriteback.d.ts.map +1 -0
  93. package/dist/vendor/codali/cognitive/MemoryWriteback.js +287 -0
  94. package/dist/vendor/codali/cognitive/PatchApplier.d.ts +49 -0
  95. package/dist/vendor/codali/cognitive/PatchApplier.d.ts.map +1 -0
  96. package/dist/vendor/codali/cognitive/PatchApplier.js +199 -0
  97. package/dist/vendor/codali/cognitive/PatchInterpreter.d.ts +35 -0
  98. package/dist/vendor/codali/cognitive/PatchInterpreter.d.ts.map +1 -0
  99. package/dist/vendor/codali/cognitive/PatchInterpreter.js +100 -0
  100. package/dist/vendor/codali/cognitive/PatchOutputNormalizer.d.ts +7 -0
  101. package/dist/vendor/codali/cognitive/PatchOutputNormalizer.d.ts.map +1 -0
  102. package/dist/vendor/codali/cognitive/PatchOutputNormalizer.js +59 -0
  103. package/dist/vendor/codali/cognitive/PostMortemAnalyzer.d.ts +17 -0
  104. package/dist/vendor/codali/cognitive/PostMortemAnalyzer.d.ts.map +1 -0
  105. package/dist/vendor/codali/cognitive/PostMortemAnalyzer.js +131 -0
  106. package/dist/vendor/codali/cognitive/PreferenceExtraction.d.ts +3 -0
  107. package/dist/vendor/codali/cognitive/PreferenceExtraction.d.ts.map +1 -0
  108. package/dist/vendor/codali/cognitive/PreferenceExtraction.js +85 -0
  109. package/dist/vendor/codali/cognitive/Prompts.d.ts +15 -0
  110. package/dist/vendor/codali/cognitive/Prompts.d.ts.map +1 -0
  111. package/dist/vendor/codali/cognitive/Prompts.js +326 -0
  112. package/dist/vendor/codali/cognitive/ProviderRouting.d.ts +16 -0
  113. package/dist/vendor/codali/cognitive/ProviderRouting.d.ts.map +1 -0
  114. package/dist/vendor/codali/cognitive/ProviderRouting.js +24 -0
  115. package/dist/vendor/codali/cognitive/QueryExtraction.d.ts +12 -0
  116. package/dist/vendor/codali/cognitive/QueryExtraction.d.ts.map +1 -0
  117. package/dist/vendor/codali/cognitive/QueryExtraction.js +262 -0
  118. package/dist/vendor/codali/cognitive/RunHistoryIndexer.d.ts +13 -0
  119. package/dist/vendor/codali/cognitive/RunHistoryIndexer.d.ts.map +1 -0
  120. package/dist/vendor/codali/cognitive/RunHistoryIndexer.js +125 -0
  121. package/dist/vendor/codali/cognitive/SmartPipeline.d.ts +92 -0
  122. package/dist/vendor/codali/cognitive/SmartPipeline.d.ts.map +1 -0
  123. package/dist/vendor/codali/cognitive/SmartPipeline.js +4804 -0
  124. package/dist/vendor/codali/cognitive/Types.d.ts +474 -0
  125. package/dist/vendor/codali/cognitive/Types.d.ts.map +1 -0
  126. package/dist/vendor/codali/cognitive/Types.js +7 -0
  127. package/dist/vendor/codali/cognitive/ValidationRunner.d.ts +57 -0
  128. package/dist/vendor/codali/cognitive/ValidationRunner.d.ts.map +1 -0
  129. package/dist/vendor/codali/cognitive/ValidationRunner.js +515 -0
  130. package/dist/vendor/codali/config/Config.d.ts +249 -0
  131. package/dist/vendor/codali/config/Config.d.ts.map +1 -0
  132. package/dist/vendor/codali/config/Config.js +200 -0
  133. package/dist/vendor/codali/config/ConfigLoader.d.ts +56 -0
  134. package/dist/vendor/codali/config/ConfigLoader.d.ts.map +1 -0
  135. package/dist/vendor/codali/config/ConfigLoader.js +1246 -0
  136. package/dist/vendor/codali/docdex/DocdexClient.d.ts +158 -0
  137. package/dist/vendor/codali/docdex/DocdexClient.d.ts.map +1 -0
  138. package/dist/vendor/codali/docdex/DocdexClient.js +785 -0
  139. package/dist/vendor/codali/eval/EvalRunner.d.ts +35 -0
  140. package/dist/vendor/codali/eval/EvalRunner.d.ts.map +1 -0
  141. package/dist/vendor/codali/eval/EvalRunner.js +38 -0
  142. package/dist/vendor/codali/eval/EvalTaskExecutor.d.ts +81 -0
  143. package/dist/vendor/codali/eval/EvalTaskExecutor.d.ts.map +1 -0
  144. package/dist/vendor/codali/eval/EvalTaskExecutor.js +371 -0
  145. package/dist/vendor/codali/eval/GateEvaluator.d.ts +31 -0
  146. package/dist/vendor/codali/eval/GateEvaluator.d.ts.map +1 -0
  147. package/dist/vendor/codali/eval/GateEvaluator.js +134 -0
  148. package/dist/vendor/codali/eval/MetricTypes.d.ts +28 -0
  149. package/dist/vendor/codali/eval/MetricTypes.d.ts.map +1 -0
  150. package/dist/vendor/codali/eval/MetricTypes.js +1 -0
  151. package/dist/vendor/codali/eval/MetricsAggregator.d.ts +4 -0
  152. package/dist/vendor/codali/eval/MetricsAggregator.d.ts.map +1 -0
  153. package/dist/vendor/codali/eval/MetricsAggregator.js +97 -0
  154. package/dist/vendor/codali/eval/RegressionComparator.d.ts +29 -0
  155. package/dist/vendor/codali/eval/RegressionComparator.d.ts.map +1 -0
  156. package/dist/vendor/codali/eval/RegressionComparator.js +155 -0
  157. package/dist/vendor/codali/eval/ReportInputAdapter.d.ts +52 -0
  158. package/dist/vendor/codali/eval/ReportInputAdapter.d.ts.map +1 -0
  159. package/dist/vendor/codali/eval/ReportInputAdapter.js +229 -0
  160. package/dist/vendor/codali/eval/ReportSerializer.d.ts +32 -0
  161. package/dist/vendor/codali/eval/ReportSerializer.d.ts.map +1 -0
  162. package/dist/vendor/codali/eval/ReportSerializer.js +33 -0
  163. package/dist/vendor/codali/eval/ReportStore.d.ts +18 -0
  164. package/dist/vendor/codali/eval/ReportStore.d.ts.map +1 -0
  165. package/dist/vendor/codali/eval/ReportStore.js +96 -0
  166. package/dist/vendor/codali/eval/SuiteLoader.d.ts +12 -0
  167. package/dist/vendor/codali/eval/SuiteLoader.d.ts.map +1 -0
  168. package/dist/vendor/codali/eval/SuiteLoader.js +51 -0
  169. package/dist/vendor/codali/eval/SuiteSchema.d.ts +56 -0
  170. package/dist/vendor/codali/eval/SuiteSchema.d.ts.map +1 -0
  171. package/dist/vendor/codali/eval/SuiteSchema.js +357 -0
  172. package/dist/vendor/codali/index.d.ts +11 -0
  173. package/dist/vendor/codali/index.d.ts.map +1 -0
  174. package/dist/vendor/codali/index.js +5 -0
  175. package/dist/vendor/codali/providers/CodexCliProvider.d.ts +8 -0
  176. package/dist/vendor/codali/providers/CodexCliProvider.d.ts.map +1 -0
  177. package/dist/vendor/codali/providers/CodexCliProvider.js +282 -0
  178. package/dist/vendor/codali/providers/OllamaRemoteProvider.d.ts +8 -0
  179. package/dist/vendor/codali/providers/OllamaRemoteProvider.d.ts.map +1 -0
  180. package/dist/vendor/codali/providers/OllamaRemoteProvider.js +300 -0
  181. package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts +8 -0
  182. package/dist/vendor/codali/providers/OpenAiCompatibleProvider.d.ts.map +1 -0
  183. package/dist/vendor/codali/providers/OpenAiCompatibleProvider.js +192 -0
  184. package/dist/vendor/codali/providers/ProviderRegistry.d.ts +12 -0
  185. package/dist/vendor/codali/providers/ProviderRegistry.d.ts.map +1 -0
  186. package/dist/vendor/codali/providers/ProviderRegistry.js +28 -0
  187. package/dist/vendor/codali/providers/ProviderTypes.d.ts +81 -0
  188. package/dist/vendor/codali/providers/ProviderTypes.d.ts.map +1 -0
  189. package/dist/vendor/codali/providers/ProviderTypes.js +1 -0
  190. package/dist/vendor/codali/runtime/CodaliRuntime.d.ts +189 -0
  191. package/dist/vendor/codali/runtime/CodaliRuntime.d.ts.map +1 -0
  192. package/dist/vendor/codali/runtime/CodaliRuntime.js +1435 -0
  193. package/dist/vendor/codali/runtime/DeepInvestigationErrors.d.ts +39 -0
  194. package/dist/vendor/codali/runtime/DeepInvestigationErrors.d.ts.map +1 -0
  195. package/dist/vendor/codali/runtime/DeepInvestigationErrors.js +57 -0
  196. package/dist/vendor/codali/runtime/RunContext.d.ts +27 -0
  197. package/dist/vendor/codali/runtime/RunContext.d.ts.map +1 -0
  198. package/dist/vendor/codali/runtime/RunContext.js +51 -0
  199. package/dist/vendor/codali/runtime/RunLogQuery.d.ts +48 -0
  200. package/dist/vendor/codali/runtime/RunLogQuery.d.ts.map +1 -0
  201. package/dist/vendor/codali/runtime/RunLogQuery.js +36 -0
  202. package/dist/vendor/codali/runtime/RunLogReader.d.ts +19 -0
  203. package/dist/vendor/codali/runtime/RunLogReader.d.ts.map +1 -0
  204. package/dist/vendor/codali/runtime/RunLogReader.js +361 -0
  205. package/dist/vendor/codali/runtime/RunLogger.d.ts +71 -0
  206. package/dist/vendor/codali/runtime/RunLogger.d.ts.map +1 -0
  207. package/dist/vendor/codali/runtime/RunLogger.js +100 -0
  208. package/dist/vendor/codali/runtime/RunTelemetryTypes.d.ts +117 -0
  209. package/dist/vendor/codali/runtime/RunTelemetryTypes.d.ts.map +1 -0
  210. package/dist/vendor/codali/runtime/RunTelemetryTypes.js +299 -0
  211. package/dist/vendor/codali/runtime/Runner.d.ts +66 -0
  212. package/dist/vendor/codali/runtime/Runner.d.ts.map +1 -0
  213. package/dist/vendor/codali/runtime/Runner.js +215 -0
  214. package/dist/vendor/codali/runtime/StoragePaths.d.ts +3 -0
  215. package/dist/vendor/codali/runtime/StoragePaths.d.ts.map +1 -0
  216. package/dist/vendor/codali/runtime/StoragePaths.js +19 -0
  217. package/dist/vendor/codali/runtime/WorkspaceLock.d.ts +30 -0
  218. package/dist/vendor/codali/runtime/WorkspaceLock.d.ts.map +1 -0
  219. package/dist/vendor/codali/runtime/WorkspaceLock.js +141 -0
  220. package/dist/vendor/codali/session/InstructionLoader.d.ts +14 -0
  221. package/dist/vendor/codali/session/InstructionLoader.d.ts.map +1 -0
  222. package/dist/vendor/codali/session/InstructionLoader.js +107 -0
  223. package/dist/vendor/codali/session/SessionStore.d.ts +81 -0
  224. package/dist/vendor/codali/session/SessionStore.d.ts.map +1 -0
  225. package/dist/vendor/codali/session/SessionStore.js +244 -0
  226. package/dist/vendor/codali/subagents/SubagentOrchestrator.d.ts +68 -0
  227. package/dist/vendor/codali/subagents/SubagentOrchestrator.d.ts.map +1 -0
  228. package/dist/vendor/codali/subagents/SubagentOrchestrator.js +150 -0
  229. package/dist/vendor/codali/tools/ToolRegistry.d.ts +9 -0
  230. package/dist/vendor/codali/tools/ToolRegistry.d.ts.map +1 -0
  231. package/dist/vendor/codali/tools/ToolRegistry.js +293 -0
  232. package/dist/vendor/codali/tools/ToolTypes.d.ts +66 -0
  233. package/dist/vendor/codali/tools/ToolTypes.d.ts.map +1 -0
  234. package/dist/vendor/codali/tools/ToolTypes.js +40 -0
  235. package/dist/vendor/codali/tools/diff/DiffTool.d.ts +3 -0
  236. package/dist/vendor/codali/tools/diff/DiffTool.d.ts.map +1 -0
  237. package/dist/vendor/codali/tools/diff/DiffTool.js +34 -0
  238. package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts +4 -0
  239. package/dist/vendor/codali/tools/docdex/DocdexTools.d.ts.map +1 -0
  240. package/dist/vendor/codali/tools/docdex/DocdexTools.js +490 -0
  241. package/dist/vendor/codali/tools/filesystem/FileTools.d.ts +3 -0
  242. package/dist/vendor/codali/tools/filesystem/FileTools.d.ts.map +1 -0
  243. package/dist/vendor/codali/tools/filesystem/FileTools.js +141 -0
  244. package/dist/vendor/codali/tools/search/SearchTool.d.ts +3 -0
  245. package/dist/vendor/codali/tools/search/SearchTool.d.ts.map +1 -0
  246. package/dist/vendor/codali/tools/search/SearchTool.js +46 -0
  247. package/dist/vendor/codali/tools/shell/ShellTool.d.ts +3 -0
  248. package/dist/vendor/codali/tools/shell/ShellTool.d.ts.map +1 -0
  249. package/dist/vendor/codali/tools/shell/ShellTool.js +104 -0
  250. package/package.json +5 -3
@@ -0,0 +1,326 @@
1
+ export const ARCHITECT_PROMPT = [
2
+ "ROLE: Technical Architect",
3
+ "TASK: Produce an implementation plan in plain text.",
4
+ "MODE: Plain-text planning only. Do NOT output JSON or DSL contracts.",
5
+ "REQUEST MORE DATA (PROTOCOL):",
6
+ "- If you are unsure or missing information, respond with an AGENT_REQUEST v1 block.",
7
+ "- If the RESEARCH SUMMARY shows missing evidence or gaps, request the missing data before planning.",
8
+ "- You can ask Codali to run Docdex tools (docdex.search, docdex.open, docdex.snippet, docdex.symbols, docdex.ast, docdex.impact, docdex.impact_diagnostics, docdex.tree, docdex.dag_export, docdex.web).",
9
+ "- You can also request file.read, file.list, or file.diff.",
10
+ "CONTEXT NOTES:",
11
+ "- Consult the REPO MEMORY and USER PROFILE sections in the context.",
12
+ "- Review the RESEARCH SUMMARY for tool usage, evidence gaps, and open questions.",
13
+ "- File contents are not included by default; request docdex.open or file.read when needed.",
14
+ "- Use focus files for concrete edits and treat periphery as read-only references.",
15
+ "- If required implementation files do not exist yet, explicitly plan to create them and include those new paths under CREATE FILES.",
16
+ "- In IMPLEMENTATION PLAN steps, include method/object-level responsibilities (what each function/module will do).",
17
+ "- For each existing file in FILES TO TOUCH, include at least one IMPLEMENTATION PLAN step naming that exact file and stating what will change there and what will be added there.",
18
+ "- Do not change requirements/specifications to avoid doing the requested work.",
19
+ "- Do NOT use generic filler lines (for example: \"review files\", \"apply changes\", \"run tests\") unless they also include concrete request nouns and exact targets.",
20
+ "- Every IMPLEMENTATION PLAN line must include request-specific nouns (feature/domain terms from the user request) and concrete implementation detail.",
21
+ "- Every VERIFY line must include request-specific nouns plus a concrete check target (file/module/route/endpoint/screen).",
22
+ "- FILES TO TOUCH must be concrete repo-relative paths. Do NOT output placeholders like \"path/to/file.ts\" or \"unknown\".",
23
+ "- RISK must reference concrete impacted behavior/components for this request; generic risk text is not allowed.",
24
+ "- If specificity is not possible from context, output AGENT_REQUEST v1 instead of generic plan text.",
25
+ "CONSTRAINTS:",
26
+ "- Do NOT output implementation code.",
27
+ "- Use only facts from the provided context bundle.",
28
+ "- Output plain text only (no JSON object contract required).",
29
+ "- Keep the plan concise, concrete, and implementation-ready.",
30
+ "- If a REVISION REQUIRED block is provided, revise the previous plan in-place; do not restart from scratch.",
31
+ "VALID OUTPUT EXAMPLE:",
32
+ "WHAT IS REQUIRED:",
33
+ "- Add uptime log writes for each health probe request.",
34
+ "CURRENT CONTEXT:",
35
+ "- Existing health probe handler lives in src/server/healthz.ts.",
36
+ "FOLDER STRUCTURE:",
37
+ "- src/server/healthz.ts",
38
+ "FILES TO TOUCH:",
39
+ "- src/server/healthz.ts",
40
+ "IMPLEMENTATION PLAN:",
41
+ "- Update src/server/healthz.ts to append uptime log writes for each health probe.",
42
+ "RISK: medium health endpoint latency may increase from sync file writes.",
43
+ "VERIFY:",
44
+ "- Run integration API test for /healthz and confirm uptime log file receives new entries.",
45
+ "INVALID OUTPUT EXAMPLE (DO NOT DO THIS):",
46
+ "- { \"query\": \"How do I implement healthz?\" }",
47
+ "- ```ts ... ```",
48
+ "- \"Review files and apply changes\"",
49
+ "PREFERRED OUTPUT SHAPE (PLAIN TEXT):",
50
+ "WHAT IS REQUIRED:",
51
+ "- <request requirement>",
52
+ "CURRENT CONTEXT:",
53
+ "- <relevant repo facts>",
54
+ "FOLDER STRUCTURE:",
55
+ "- <relevant folders/files>",
56
+ "FILES TO TOUCH:",
57
+ "- <path/to/file>",
58
+ "CREATE FILES:",
59
+ "- <path/to/new-file> (optional)",
60
+ "IMPLEMENTATION PLAN:",
61
+ "- <step 1>",
62
+ "- <step 2>",
63
+ "RISK: <low|medium|high> <brief reason>",
64
+ "VERIFY:",
65
+ "- <verification step>",
66
+ ].join("\n");
67
+ export const ARCHITECT_GBNF = [
68
+ "root ::= ws \"PLAN:\" nl steps \"TARGETS:\" nl targets \"RISK:\" ws risk nl \"VERIFY:\" nl verify ws",
69
+ "steps ::= step+",
70
+ "step ::= ws \"-\" ws text nl",
71
+ "targets ::= target+",
72
+ "target ::= ws \"-\" ws text nl",
73
+ "verify ::= (ws \"-\" ws text nl)*",
74
+ "risk ::= text",
75
+ "text ::= [^\\n]+",
76
+ "ws ::= [ \\t]*",
77
+ "nl ::= \\\"\\\\n\\\" | \\\"\\\\r\\\\n\\\"",
78
+ ].join("\n");
79
+ export const ARCHITECT_REVIEW_PROMPT = [
80
+ "ROLE: Technical Architect",
81
+ "TASK: Review the builder output against the plan and constraints.",
82
+ "REVIEW GOALS:",
83
+ "- Validate that builder output implements the USER REQUEST intent, not only plan formatting.",
84
+ "- If requested behavior is missing, only partially implemented, or replaced with unrelated/static content, return RETRY.",
85
+ "- Keep feedback concrete and file/behavior specific.",
86
+ "CONSTRAINTS:",
87
+ "- Do NOT output implementation code.",
88
+ "- Output plain text only (no JSON, no markdown).",
89
+ "OUTPUT FORMAT (PLAIN TEXT):",
90
+ "STATUS: PASS|RETRY",
91
+ "REASONS:",
92
+ "- <why PASS/RETRY based on request + plan + builder output evidence>",
93
+ "FEEDBACK:",
94
+ "- <actionable fixes if RETRY; optional when PASS>",
95
+ ].join("\n");
96
+ export const ARCHITECT_REVIEW_GBNF = [
97
+ "root ::= ws \"REVIEW:\" nl \"STATUS:\" ws status nl \"REASONS:\" nl reasons \"FEEDBACK:\" nl feedback ws",
98
+ "status ::= \"PASS\" | \"RETRY\"",
99
+ "reasons ::= (ws \"-\" ws text nl)*",
100
+ "feedback ::= (ws \"-\" ws text nl)*",
101
+ "text ::= [^\\n]+",
102
+ "ws ::= [ \\t]*",
103
+ "nl ::= \\\"\\\\n\\\" | \\\"\\\\r\\\\n\\\"",
104
+ ].join("\n");
105
+ export const ARCHITECT_VALIDATE_PROMPT = [
106
+ "ROLE: Technical Architect",
107
+ "TASK: Validate the PROPOSED PLAN against the context and constraints.",
108
+ "CONSTRAINTS:",
109
+ "- Reject generic/filler plan lines and generic risk text; keep request-specific nouns and concrete details.",
110
+ "- Ensure every IMPLEMENTATION PLAN and VERIFY line includes request-specific nouns and concrete targets/checks.",
111
+ "- Ensure FILES TO TOUCH are concrete repo-relative paths (no placeholders or \"unknown\").",
112
+ "- Do NOT output implementation code.",
113
+ "- If the plan is valid, output the EXACT plan as provided in plain-text sections.",
114
+ "- If the plan is invalid or incomplete, output a CORRECTED plan in plain-text sections.",
115
+ "- Use the same section format as the proposed plan.",
116
+ "OUTPUT FORMAT (PLAIN TEXT):",
117
+ "WHAT IS REQUIRED:",
118
+ "- <request requirement>",
119
+ "CURRENT CONTEXT:",
120
+ "- <context facts>",
121
+ "FOLDER STRUCTURE:",
122
+ "- <relevant folders/files>",
123
+ "FILES TO TOUCH:",
124
+ "- <path/to/file>",
125
+ "CREATE FILES:",
126
+ "- <path/to/new-file> (optional)",
127
+ "IMPLEMENTATION PLAN:",
128
+ "- <step 1>",
129
+ "- <step 2>",
130
+ "RISK: <low|medium|high> <brief reason>",
131
+ "VERIFY:",
132
+ "- <verification step>",
133
+ ].join("\n");
134
+ export const ARCHITECT_VALIDATE_GBNF = ARCHITECT_GBNF;
135
+ export const BUILDER_PATCH_GBNF_SEARCH_REPLACE = [
136
+ "root ::= ws object ws",
137
+ "object ::= \"{\" ws \\\"\\\"patches\\\"\\\" ws \":\" ws patch_array ws \"}\"",
138
+ "patch_array ::= \"[\" ws patch (ws \",\" ws patch)* ws \"]\"",
139
+ "patch ::= replace | create | delete",
140
+ "replace ::= \"{\" ws \\\"\\\"action\\\"\\\" ws \":\" ws \\\"\\\"replace\\\"\\\" ws \",\" ws \\\"\\\"file\\\"\\\" ws \":\" ws string ws \",\" ws \\\"\\\"search_block\\\"\\\" ws \":\" ws string ws \",\" ws \\\"\\\"replace_block\\\"\\\" ws \":\" ws string ws \"}\"",
141
+ "create ::= \"{\" ws \\\"\\\"action\\\"\\\" ws \":\" ws \\\"\\\"create\\\"\\\" ws \",\" ws \\\"\\\"file\\\"\\\" ws \":\" ws string ws \",\" ws \\\"\\\"content\\\"\\\" ws \":\" ws string ws \"}\"",
142
+ "delete ::= \"{\" ws \\\"\\\"action\\\"\\\" ws \":\" ws \\\"\\\"delete\\\"\\\" ws \",\" ws \\\"\\\"file\\\"\\\" ws \":\" ws string ws \"}\"",
143
+ "string ::= \"\\\"\" chars \"\\\"\"",
144
+ "chars ::= (char)*",
145
+ "char ::= [^\"\\\\] | \"\\\\\" [\"\\\\/bfnrt] | \"\\\\\" \"u\" hex hex hex hex",
146
+ "hex ::= [0-9a-fA-F]",
147
+ "ws ::= [ \\t\\n\\r]*",
148
+ ].join("\n");
149
+ export const BUILDER_PATCH_GBNF_FILE_WRITES = [
150
+ "root ::= ws object ws",
151
+ "object ::= \"{\" ws \\\"\\\"files\\\"\\\" ws \":\" ws file_array ws (ws \",\" ws \\\"\\\"delete\\\"\\\" ws \":\" ws string_array ws)? \"}\"",
152
+ "file_array ::= \"[\" ws file_entry (ws \",\" ws file_entry)* ws \"]\"",
153
+ "file_entry ::= \"{\" ws \\\"\\\"path\\\"\\\" ws \":\" ws string ws \",\" ws \\\"\\\"content\\\"\\\" ws \":\" ws string ws \"}\"",
154
+ "string_array ::= \"[\" ws (string (ws \",\" ws string)*)? ws \"]\"",
155
+ "string ::= \"\\\"\" chars \"\\\"\"",
156
+ "chars ::= (char)*",
157
+ "char ::= [^\"\\\\] | \"\\\\\" [\"\\\\/bfnrt] | \"\\\\\" \"u\" hex hex hex hex",
158
+ "hex ::= [0-9a-fA-F]",
159
+ "ws ::= [ \\t\\n\\r]*",
160
+ ].join("\n");
161
+ const BUILDER_PROMPT_TOOL_CALLS = [
162
+ "ROLE: Builder",
163
+ "TASK: Implement the plan using tools.",
164
+ "CONTEXT NOTES:",
165
+ "- Respect constraints found in the USER PROFILE and REPO MEMORY.",
166
+ "- Focus files contain full content; periphery files contain interfaces/summaries only.",
167
+ "- Avoid modifying periphery unless the plan explicitly requires it.",
168
+ "- Follow the WRITE POLICY section in the context bundle. Do not edit read-only paths.",
169
+ "- Do not alter requirements/specs to bypass the task; implement the requested change.",
170
+ "CONSTRAINTS:",
171
+ "- Use tools for file changes.",
172
+ "- You can use 'docdex_delegate' to offload simple tasks (docstrings, small tests) to a cheaper model.",
173
+ "- Follow the plan and do not invent files.",
174
+ '- If missing required context, respond with JSON: {"needs_context": true, "queries": ["..."], "files": ["..."], "reason": "..."}',
175
+ "- Respond with a concise summary when done.",
176
+ ].join("\n");
177
+ const BUILDER_PROMPT_FREEFORM = [
178
+ "ROLE: Builder",
179
+ "TASK: Implement the plan with freeform output (no strict schema).",
180
+ "CONTEXT NOTES:",
181
+ "- Respect constraints found in the USER PROFILE and REPO MEMORY.",
182
+ "- Focus files contain full content; periphery files contain interfaces/summaries only.",
183
+ "- Avoid modifying periphery unless the plan explicitly requires it.",
184
+ "- Follow the WRITE POLICY section in the context bundle. Do not edit read-only paths.",
185
+ "- Do not alter requirements/specs to bypass the task; implement the requested change.",
186
+ "CONSTRAINTS:",
187
+ "- Do NOT call tools.",
188
+ "- Do NOT output JSON or YAML.",
189
+ "- Provide a concise change summary and exact code snippets.",
190
+ "- If you propose a file change, include an explicit file path and either a full file or an exact snippet.",
191
+ "- Do not include markdown fences around code blocks.",
192
+ "- If missing required context, explain what is missing in plain text.",
193
+ ].join("\n");
194
+ const BUILDER_PROMPT_PATCH_JSON_SEARCH_REPLACE = [
195
+ "ROLE: Builder",
196
+ "TASK: Implement the plan by emitting a JSON patch payload.",
197
+ "CONTEXT NOTES:",
198
+ "- Respect constraints found in the USER PROFILE and REPO MEMORY.",
199
+ "- Focus files contain full content; periphery files contain interfaces/summaries only.",
200
+ "- Avoid modifying periphery unless the plan explicitly requires it.",
201
+ "- Follow the WRITE POLICY section in the context bundle. Do not edit read-only paths.",
202
+ "- Do not alter requirements/specs to bypass the task; implement the requested change.",
203
+ "CONSTRAINTS:",
204
+ "- Do NOT call tools.",
205
+ "- Respond with JSON only (no prose, no markdown, no code fences).",
206
+ "- Output must be a single JSON object and must start with '{' and end with '}'.",
207
+ "- Do not include top-level keys other than \"patches\".",
208
+ "- Do not include commentary, summaries, plan echoes, or extra metadata.",
209
+ "- Prefer files from the provided context bundle, but you may edit other workspace files if needed and allowed by the WRITE POLICY.",
210
+ "- The plan and context bundle are input-only; do NOT echo or restate them.",
211
+ "- Never use literal placeholder values like \"...\", \"path/to/file\", \"path/to/new\", or \"path/to/old\".",
212
+ "- Never return an empty patches array.",
213
+ '- If missing required context, respond with JSON: {"needs_context": true, "queries": ["..."], "files": ["..."], "reason": "..."}',
214
+ "PATCH SCHEMA:",
215
+ '- Top-level object with key "patches": array.',
216
+ '- Replace entry keys: "action": "replace", "file", "search_block", "replace_block".',
217
+ '- Create entry keys: "action": "create", "file", "content".',
218
+ '- Delete entry keys: "action": "delete", "file".',
219
+ '- Every string value must be concrete and non-empty.',
220
+ ].join("\n");
221
+ const BUILDER_PROMPT_PATCH_JSON_FILE_WRITES = [
222
+ "ROLE: Builder",
223
+ "TASK: Implement the plan by emitting a JSON file-write payload.",
224
+ "CONTEXT NOTES:",
225
+ "- Respect constraints found in the USER PROFILE and REPO MEMORY.",
226
+ "- Focus files contain full content; periphery files contain interfaces/summaries only.",
227
+ "- Avoid modifying periphery unless the plan explicitly requires it.",
228
+ "- Follow the WRITE POLICY section in the context bundle. Do not edit read-only paths.",
229
+ "- Do not alter requirements/specs to bypass the task; implement the requested change.",
230
+ "CONSTRAINTS:",
231
+ "- Do NOT call tools.",
232
+ "- Respond with JSON only (no prose, no markdown, no code fences).",
233
+ "- Output must be a single JSON object and must start with '{' and end with '}'.",
234
+ "- Do not include top-level keys other than \"files\" and optional \"delete\".",
235
+ "- Do not include commentary, summaries, plan echoes, or extra metadata.",
236
+ "- Prefer files from the provided context bundle, but you may edit other workspace files if needed and allowed by the WRITE POLICY.",
237
+ "- The plan and context bundle are input-only; do NOT echo or restate them.",
238
+ "- Never use literal placeholder values like \"...\", \"path/to/file\", \"path/to/new\", or \"path/to/old\".",
239
+ "- Never return an empty files array.",
240
+ '- If missing required context, respond with JSON: {"needs_context": true, "queries": ["..."], "files": ["..."], "reason": "..."}',
241
+ "- Output MUST start with a JSON object that includes a top-level \"files\" array.",
242
+ "- Do not include any extra keys beyond \"files\" and optional \"delete\".",
243
+ "PATCH SCHEMA:",
244
+ '- Top-level object with key "files": array.',
245
+ '- File entry keys: "path": <string>, "content": <string> (both required, non-empty).',
246
+ '- Optional "delete": string array for files to remove.',
247
+ ].join("\n");
248
+ export const buildBuilderPrompt = (mode, patchFormat = "search_replace") => {
249
+ if (mode === "freeform") {
250
+ return BUILDER_PROMPT_FREEFORM;
251
+ }
252
+ if (mode !== "patch_json") {
253
+ return BUILDER_PROMPT_TOOL_CALLS;
254
+ }
255
+ return patchFormat === "file_writes"
256
+ ? BUILDER_PROMPT_PATCH_JSON_FILE_WRITES
257
+ : BUILDER_PROMPT_PATCH_JSON_SEARCH_REPLACE;
258
+ };
259
+ const INTERPRETER_PROMPT_BASE = [
260
+ "ROLE: Patch Interpreter",
261
+ "TASK: Convert the builder output into a JSON patch payload.",
262
+ "CONSTRAINTS:",
263
+ "- Output JSON only (no prose, no markdown, no code fences).",
264
+ "- Do not invent files outside the builder output.",
265
+ "- Do not include explanations.",
266
+ "- Never use literal placeholder values like \"...\" or \"path/to/file\".",
267
+ ].join("\n");
268
+ const INTERPRETER_PROMPT_SEARCH_REPLACE = [
269
+ INTERPRETER_PROMPT_BASE,
270
+ "PATCH SCHEMA:",
271
+ '- Top-level object with key "patches": array.',
272
+ '- Replace entry keys: "action": "replace", "file", "search_block", "replace_block".',
273
+ '- Create entry keys: "action": "create", "file", "content".',
274
+ '- Delete entry keys: "action": "delete", "file".',
275
+ '- Every string value must be concrete and non-empty.',
276
+ ].join("\n");
277
+ const INTERPRETER_PROMPT_FILE_WRITES = [
278
+ INTERPRETER_PROMPT_BASE,
279
+ "PATCH SCHEMA:",
280
+ '- Top-level object with key "files": array.',
281
+ '- File entry keys: "path": <string>, "content": <string> (both required, non-empty).',
282
+ '- Optional "delete": string array for files to remove.',
283
+ ].join("\n");
284
+ const INTERPRETER_RETRY_PROMPT_BASE = [
285
+ "ROLE: Patch Interpreter",
286
+ "TASK: Respond ONLY with valid JSON matching the patch schema.",
287
+ "CONSTRAINTS:",
288
+ "- Output JSON only (no prose, no markdown, no code fences).",
289
+ "- The response must start with '{' or '['.",
290
+ "- Never use literal placeholder values like \"...\" or \"path/to/file\".",
291
+ ].join("\n");
292
+ const INTERPRETER_RETRY_SEARCH_REPLACE = [
293
+ INTERPRETER_RETRY_PROMPT_BASE,
294
+ "PATCH SCHEMA:",
295
+ '- Top-level object with key "patches": array.',
296
+ '- Replace entry keys: "action": "replace", "file", "search_block", "replace_block".',
297
+ '- Create entry keys: "action": "create", "file", "content".',
298
+ '- Delete entry keys: "action": "delete", "file".',
299
+ '- Every string value must be concrete and non-empty.',
300
+ ].join("\n");
301
+ const INTERPRETER_RETRY_FILE_WRITES = [
302
+ INTERPRETER_RETRY_PROMPT_BASE,
303
+ "PATCH SCHEMA:",
304
+ '- Top-level object with key "files": array.',
305
+ '- File entry keys: "path": <string>, "content": <string> (both required, non-empty).',
306
+ '- Optional "delete": string array for files to remove.',
307
+ ].join("\n");
308
+ export const buildInterpreterPrompt = (patchFormat = "search_replace") => patchFormat === "file_writes"
309
+ ? INTERPRETER_PROMPT_FILE_WRITES
310
+ : INTERPRETER_PROMPT_SEARCH_REPLACE;
311
+ export const buildInterpreterRetryPrompt = (patchFormat = "search_replace") => patchFormat === "file_writes"
312
+ ? INTERPRETER_RETRY_FILE_WRITES
313
+ : INTERPRETER_RETRY_SEARCH_REPLACE;
314
+ export const BUILDER_PROMPT = BUILDER_PROMPT_TOOL_CALLS;
315
+ export const CRITIC_PROMPT = [
316
+ "ROLE: Critic",
317
+ "TASK: Validate the implementation against the plan and checks.",
318
+ "CONSTRAINTS:",
319
+ "- Do NOT generate code.",
320
+ "- Report pass/fail with reasons.",
321
+ ].join("\n");
322
+ export const CONTEXT_SUMMARY_PROMPT = [
323
+ "ROLE: Context Summarizer",
324
+ "TASK: Summarize the key technical decisions, constraints, and open questions from this conversation.",
325
+ "OUTPUT: Keep it concise and action-oriented.",
326
+ ].join("\n");
@@ -0,0 +1,16 @@
1
+ import type { ProviderConfig, ProviderResponseFormat } from "../providers/ProviderTypes.js";
2
+ import type { RoutingConfig, RoutingPhaseConfig } from "../config/Config.js";
3
+ export type PipelinePhase = "librarian" | "architect" | "builder" | "critic" | "interpreter";
4
+ export interface ProviderDefaults {
5
+ provider: string;
6
+ config: ProviderConfig;
7
+ }
8
+ export interface RoutedProvider {
9
+ provider: string;
10
+ config: ProviderConfig;
11
+ temperature?: number;
12
+ responseFormat?: ProviderResponseFormat;
13
+ }
14
+ export declare const resolvePhaseRouting: (routing: RoutingConfig | undefined, phase: PipelinePhase) => RoutingPhaseConfig | undefined;
15
+ export declare const buildRoutedProvider: (phase: PipelinePhase, defaults: ProviderDefaults, routing?: RoutingConfig, lockProviderModel?: boolean) => RoutedProvider;
16
+ //# sourceMappingURL=ProviderRouting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProviderRouting.d.ts","sourceRoot":"","sources":["../../src/cognitive/ProviderRouting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC5F,OAAO,KAAK,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE7E,MAAM,MAAM,aAAa,GAAG,WAAW,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,CAAC;AAE7F,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,cAAc,CAAC;CACxB;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,cAAc,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,sBAAsB,CAAC;CACzC;AAgBD,eAAO,MAAM,mBAAmB,GAC9B,SAAS,aAAa,GAAG,SAAS,EAClC,OAAO,aAAa,KACnB,kBAAkB,GAAG,SAA6B,CAAC;AAEtD,eAAO,MAAM,mBAAmB,GAC9B,OAAO,aAAa,EACpB,UAAU,gBAAgB,EAC1B,UAAU,aAAa,EACvB,2BAAyB,KACxB,cAWF,CAAC"}
@@ -0,0 +1,24 @@
1
+ const toResponseFormat = (format, grammar) => {
2
+ if (!format)
3
+ return undefined;
4
+ if (format === "json") {
5
+ return { type: "json" };
6
+ }
7
+ if ((format === "gbnf" || format === "grammar") && grammar) {
8
+ return { type: "gbnf", grammar };
9
+ }
10
+ return undefined;
11
+ };
12
+ export const resolvePhaseRouting = (routing, phase) => routing?.[phase];
13
+ export const buildRoutedProvider = (phase, defaults, routing, lockProviderModel = false) => {
14
+ const phaseConfig = resolvePhaseRouting(routing, phase);
15
+ return {
16
+ provider: lockProviderModel ? defaults.provider : phaseConfig?.provider ?? defaults.provider,
17
+ config: {
18
+ ...defaults.config,
19
+ model: lockProviderModel ? defaults.config.model : phaseConfig?.model ?? defaults.config.model,
20
+ },
21
+ temperature: phaseConfig?.temperature,
22
+ responseFormat: toResponseFormat(phaseConfig?.format, phaseConfig?.grammar),
23
+ };
24
+ };
@@ -0,0 +1,12 @@
1
+ import type { Provider } from "../providers/ProviderTypes.js";
2
+ import type { RunLogger } from "../runtime/RunLogger.js";
3
+ export interface QuerySignals {
4
+ phrases: string[];
5
+ file_tokens: string[];
6
+ keywords: string[];
7
+ keyword_phrases: string[];
8
+ }
9
+ export declare const extractQuerySignals: (input: string) => QuerySignals;
10
+ export declare const extractQueries: (input: string, maxQueries?: number) => string[];
11
+ export declare const expandQueriesWithProvider: (provider: Provider, request: string, baseQueries: string[], maxQueries?: number, temperature?: number, fileHints?: string[], logger?: RunLogger) => Promise<string[]>;
12
+ //# sourceMappingURL=QueryExtraction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"QueryExtraction.d.ts","sourceRoot":"","sources":["../../src/cognitive/QueryExtraction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAmB,MAAM,+BAA+B,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAsGzD,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,eAAe,EAAE,MAAM,EAAE,CAAC;CAC3B;AA4DD,eAAO,MAAM,mBAAmB,GAAI,OAAO,MAAM,KAAG,YAqBnD,CAAC;AAgBF,eAAO,MAAM,cAAc,GAAI,OAAO,MAAM,EAAE,mBAAc,KAAG,MAAM,EAiBpE,CAAC;AAoCF,eAAO,MAAM,yBAAyB,GACpC,UAAU,QAAQ,EAClB,SAAS,MAAM,EACf,aAAa,MAAM,EAAE,EACrB,mBAAc,EACd,cAAc,MAAM,EACpB,YAAY,MAAM,EAAE,EACpB,SAAS,SAAS,KACjB,OAAO,CAAC,MAAM,EAAE,CA4BlB,CAAC"}
@@ -0,0 +1,262 @@
1
+ const STOPWORDS = new Set([
2
+ "the",
3
+ "and",
4
+ "or",
5
+ "a",
6
+ "an",
7
+ "to",
8
+ "for",
9
+ "of",
10
+ "in",
11
+ "on",
12
+ "with",
13
+ "by",
14
+ "from",
15
+ "is",
16
+ "are",
17
+ "be",
18
+ "this",
19
+ "that",
20
+ "these",
21
+ "those",
22
+ "it",
23
+ "its",
24
+ "add",
25
+ "adds",
26
+ "added",
27
+ "adding",
28
+ "change",
29
+ "changes",
30
+ "changed",
31
+ "changing",
32
+ "update",
33
+ "updates",
34
+ "updated",
35
+ "updating",
36
+ "modify",
37
+ "modifies",
38
+ "modified",
39
+ "modifying",
40
+ "make",
41
+ "makes",
42
+ "making",
43
+ "create",
44
+ "creates",
45
+ "created",
46
+ "creating",
47
+ "only",
48
+ "just",
49
+ "please",
50
+ "visible",
51
+ "show",
52
+ "shows",
53
+ "showing",
54
+ "display",
55
+ "displayed",
56
+ "touch",
57
+ "edit",
58
+ "edits",
59
+ "editing",
60
+ "fix",
61
+ "fixes",
62
+ "fixed",
63
+ "fixing",
64
+ "ensure",
65
+ "set",
66
+ "sets",
67
+ "setting",
68
+ "new",
69
+ "develop",
70
+ "develops",
71
+ "developed",
72
+ "developing",
73
+ "engineer",
74
+ "engineering",
75
+ "implement",
76
+ "implements",
77
+ "implemented",
78
+ "implementing",
79
+ "build",
80
+ "builds",
81
+ "building",
82
+ "built",
83
+ ]);
84
+ const FILE_EXTENSIONS = [
85
+ ".ts",
86
+ ".tsx",
87
+ ".js",
88
+ ".jsx",
89
+ ".json",
90
+ ".md",
91
+ ".yml",
92
+ ".yaml",
93
+ ".rs",
94
+ ".py",
95
+ ".go",
96
+ ".java",
97
+ ".cs",
98
+ ];
99
+ const unique = (values) => {
100
+ const seen = new Set();
101
+ const result = [];
102
+ for (const value of values) {
103
+ const normalized = value.trim();
104
+ if (!normalized || seen.has(normalized))
105
+ continue;
106
+ seen.add(normalized);
107
+ result.push(normalized);
108
+ }
109
+ return result;
110
+ };
111
+ const QUERY_EXPANDER_PROMPT = [
112
+ "You generate concise search queries for code and docs lookup.",
113
+ "Return JSON only. Allowed formats:",
114
+ '1) {"queries":["q1","q2"]}',
115
+ '2) ["q1","q2"]',
116
+ "Max 3 queries, short phrases, no commentary.",
117
+ ].join("\n");
118
+ const extractQuotedPhrases = (input) => {
119
+ const phrases = [];
120
+ const regexes = [/`([^`]+)`/g, /"([^"]+)"/g, /'([^']+)'/g];
121
+ for (const regex of regexes) {
122
+ let match;
123
+ while ((match = regex.exec(input)) !== null) {
124
+ const phrase = match[1]?.trim();
125
+ if (phrase)
126
+ phrases.push(phrase);
127
+ }
128
+ }
129
+ return phrases;
130
+ };
131
+ const extractFileTokens = (input) => {
132
+ const tokens = input.split(/\s+/).map((token) => token.replace(/[(),.;:]+$/g, ""));
133
+ return tokens.filter((token) => FILE_EXTENSIONS.some((ext) => token.includes(ext)));
134
+ };
135
+ const extractKeywords = (input) => {
136
+ return input
137
+ .split(/\s+/)
138
+ .map((token) => token.toLowerCase().replace(/[^a-z0-9/_-]/g, ""))
139
+ .filter((token) => token.length >= 3 && !STOPWORDS.has(token));
140
+ };
141
+ const extractKeywordPhrases = (keywords, maxPhrases = 6) => {
142
+ if (keywords.length < 2)
143
+ return [];
144
+ const phrases = [];
145
+ for (let index = 0; index < keywords.length; index += 1) {
146
+ const two = keywords.slice(index, index + 2);
147
+ const three = keywords.slice(index, index + 3);
148
+ if (two.length === 2)
149
+ phrases.push(two.join(" "));
150
+ if (three.length === 3)
151
+ phrases.push(three.join(" "));
152
+ if (phrases.length >= maxPhrases * 2)
153
+ break;
154
+ }
155
+ return unique(phrases).slice(0, Math.max(0, maxPhrases));
156
+ };
157
+ export const extractQuerySignals = (input) => {
158
+ const trimmed = input.trim();
159
+ if (!trimmed) {
160
+ return { phrases: [], file_tokens: [], keywords: [], keyword_phrases: [] };
161
+ }
162
+ const phrases = unique([
163
+ ...extractQuotedPhrases(trimmed),
164
+ ...trimmed
165
+ .split(/[.!?;:]+/g)
166
+ .map((entry) => entry.trim())
167
+ .filter((entry) => entry.length >= 8),
168
+ ]);
169
+ const fileTokens = unique(extractFileTokens(trimmed));
170
+ const keywords = unique(extractKeywords(trimmed));
171
+ const keywordPhrases = extractKeywordPhrases(keywords);
172
+ return {
173
+ phrases,
174
+ file_tokens: fileTokens,
175
+ keywords,
176
+ keyword_phrases: keywordPhrases,
177
+ };
178
+ };
179
+ const buildKeywordFallbackQueries = (request, keywords, maxQueries) => {
180
+ const keyTerms = unique(keywords.filter((token) => token.length >= 4));
181
+ const longPhrase = keyTerms.slice(0, 4).join(" ");
182
+ const corePhrase = keyTerms.slice(0, 2).join(" ");
183
+ const fallback = unique([
184
+ request,
185
+ longPhrase,
186
+ corePhrase,
187
+ ...keyTerms,
188
+ ...keywords,
189
+ ]);
190
+ return fallback.slice(0, Math.max(1, maxQueries));
191
+ };
192
+ export const extractQueries = (input, maxQueries = 3) => {
193
+ const trimmed = input.trim();
194
+ if (!trimmed)
195
+ return [];
196
+ const signals = extractQuerySignals(trimmed);
197
+ const phrases = signals.phrases;
198
+ const fileTokens = signals.file_tokens;
199
+ const keywords = signals.keywords;
200
+ const hasAnchors = phrases.length > 0 || fileTokens.length > 0;
201
+ if (!hasAnchors) {
202
+ return buildKeywordFallbackQueries(trimmed, keywords, maxQueries);
203
+ }
204
+ const combined = unique([trimmed, ...phrases, ...fileTokens, ...signals.keyword_phrases, ...keywords]);
205
+ const limited = combined.slice(0, Math.max(1, maxQueries));
206
+ return limited;
207
+ };
208
+ const parseExpandedQueries = (payload) => {
209
+ if (!payload)
210
+ return [];
211
+ if (Array.isArray(payload)) {
212
+ return payload.map((entry) => String(entry)).filter(Boolean);
213
+ }
214
+ if (typeof payload === "object") {
215
+ const record = payload;
216
+ const queries = record.queries;
217
+ if (Array.isArray(queries)) {
218
+ return queries.map((entry) => String(entry)).filter(Boolean);
219
+ }
220
+ }
221
+ return [];
222
+ };
223
+ const buildQueryMessage = (request, baseQueries, maxQueries, fileHints) => ({
224
+ role: "user",
225
+ content: JSON.stringify({
226
+ request,
227
+ base_queries: baseQueries,
228
+ max_queries: maxQueries,
229
+ file_hints: fileHints ?? [],
230
+ }, null, 2),
231
+ });
232
+ export const expandQueriesWithProvider = async (provider, request, baseQueries, maxQueries = 3, temperature, fileHints, logger) => {
233
+ const messages = [
234
+ { role: "system", content: QUERY_EXPANDER_PROMPT },
235
+ buildQueryMessage(request, baseQueries, maxQueries, fileHints),
236
+ ];
237
+ if (logger) {
238
+ await logger.log("provider_request", {
239
+ provider: provider.name,
240
+ messages,
241
+ responseFormat: { type: "json" },
242
+ temperature,
243
+ });
244
+ }
245
+ const response = await provider.generate({
246
+ messages,
247
+ responseFormat: { type: "json" },
248
+ temperature,
249
+ });
250
+ const content = response.message.content?.trim() ?? "";
251
+ if (!content)
252
+ return baseQueries;
253
+ try {
254
+ const parsed = JSON.parse(content);
255
+ const expanded = parseExpandedQueries(parsed);
256
+ const merged = unique([...baseQueries, ...expanded]);
257
+ return merged.slice(0, Math.max(1, maxQueries));
258
+ }
259
+ catch {
260
+ return baseQueries;
261
+ }
262
+ };
@@ -0,0 +1,13 @@
1
+ import type { DocdexClient } from "../docdex/DocdexClient.js";
2
+ export interface RunHistoryHit {
3
+ intent: string;
4
+ plan: string;
5
+ diff: string;
6
+ score: number;
7
+ }
8
+ export declare class RunHistoryIndexer {
9
+ private client;
10
+ constructor(client: DocdexClient);
11
+ findSimilarRuns(intent: string, limit?: number): Promise<RunHistoryHit[]>;
12
+ }
13
+ //# sourceMappingURL=RunHistoryIndexer.d.ts.map