@mcoda/mswarm 0.1.57 → 0.1.60

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 +266 -0
  3. package/dist/codali-executor.d.ts.map +1 -0
  4. package/dist/codali-executor.js +227 -0
  5. package/dist/codali-executor.js.map +1 -0
  6. package/dist/runtime.d.ts +36 -1
  7. package/dist/runtime.d.ts.map +1 -1
  8. package/dist/runtime.js +219 -30
  9. package/dist/runtime.js.map +1 -1
  10. package/dist/server.d.ts.map +1 -1
  11. package/dist/server.js +54 -0
  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 +113 -0
  137. package/dist/vendor/codali/docdex/DocdexClient.d.ts.map +1 -0
  138. package/dist/vendor/codali/docdex/DocdexClient.js +524 -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 +183 -0
  191. package/dist/vendor/codali/runtime/CodaliRuntime.d.ts.map +1 -0
  192. package/dist/vendor/codali/runtime/CodaliRuntime.js +1363 -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 +263 -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 +32 -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 +453 -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,75 @@
1
+ const toNumber = (value) => {
2
+ if (!Number.isFinite(value))
3
+ return 0;
4
+ return value ?? 0;
5
+ };
6
+ const uniqueStrings = (values) => {
7
+ return Array.from(new Set(values.filter((value) => value.length > 0)));
8
+ };
9
+ const buildRequiredMetrics = (config) => {
10
+ return {
11
+ search_hits: Math.max(0, Math.floor(toNumber(config.minSearchHits))),
12
+ open_or_snippet: Math.max(0, Math.floor(toNumber(config.minOpenOrSnippet))),
13
+ symbols_or_ast: Math.max(0, Math.floor(toNumber(config.minSymbolsOrAst))),
14
+ impact: Math.max(0, Math.floor(toNumber(config.minImpact))),
15
+ warnings: Math.max(0, Math.floor(toNumber(config.maxWarnings))),
16
+ };
17
+ };
18
+ const buildObservedMetrics = (evidence, toolUsage, warnings) => {
19
+ const warningList = uniqueStrings([
20
+ ...(evidence?.warnings ?? []),
21
+ ...(warnings ?? []),
22
+ ]);
23
+ const searchHits = toNumber(evidence?.search_hits);
24
+ const snippetCount = toNumber(evidence?.snippet_count);
25
+ const symbolFiles = toNumber(evidence?.symbol_files);
26
+ const astFiles = toNumber(evidence?.ast_files);
27
+ const impactFiles = toNumber(evidence?.impact_files);
28
+ const impactEdges = toNumber(evidence?.impact_edges);
29
+ const toolOpenOrSnippet = toNumber(toolUsage?.open_or_snippet);
30
+ const toolSymbolsOrAst = toNumber(toolUsage?.symbols_or_ast);
31
+ const toolImpact = toNumber(toolUsage?.impact);
32
+ const metrics = {
33
+ search_hits: searchHits,
34
+ open_or_snippet: Math.max(snippetCount, toolOpenOrSnippet),
35
+ symbols_or_ast: Math.max(symbolFiles + astFiles, toolSymbolsOrAst),
36
+ impact: Math.max(impactFiles, impactEdges, toolImpact),
37
+ warnings: warningList.length,
38
+ };
39
+ return { metrics, warningList, gaps: evidence?.gaps };
40
+ };
41
+ const buildMissingSignals = (observed, required) => {
42
+ const missing = [];
43
+ if (observed.search_hits < required.search_hits)
44
+ missing.push("search_hits");
45
+ if (observed.open_or_snippet < required.open_or_snippet) {
46
+ missing.push("open_or_snippet");
47
+ }
48
+ if (observed.symbols_or_ast < required.symbols_or_ast) {
49
+ missing.push("symbols_or_ast");
50
+ }
51
+ if (observed.impact < required.impact)
52
+ missing.push("impact");
53
+ if (observed.warnings > required.warnings)
54
+ missing.push("warnings");
55
+ return missing;
56
+ };
57
+ export const evaluateEvidenceGate = ({ config, evidence, toolUsage, warnings, }) => {
58
+ const required = buildRequiredMetrics(config);
59
+ const { metrics: observed, warningList, gaps } = buildObservedMetrics(evidence, toolUsage, warnings);
60
+ const missing = buildMissingSignals(observed, required);
61
+ const totalSignals = 5;
62
+ const score = (totalSignals - missing.length) / totalSignals;
63
+ const threshold = 1;
64
+ const status = missing.length === 0 ? "pass" : "fail";
65
+ return {
66
+ status,
67
+ score,
68
+ threshold,
69
+ missing,
70
+ required,
71
+ observed,
72
+ warnings: warningList.length ? warningList : undefined,
73
+ gaps,
74
+ };
75
+ };
@@ -0,0 +1,12 @@
1
+ import type { DocdexClient } from "../docdex/DocdexClient.js";
2
+ export interface GoldenExample {
3
+ intent: string;
4
+ patch: string;
5
+ score?: number;
6
+ }
7
+ export declare class GoldenExampleIndexer {
8
+ private client;
9
+ constructor(client: DocdexClient);
10
+ findExamples(intent: string, limit?: number): Promise<GoldenExample[]>;
11
+ }
12
+ //# sourceMappingURL=GoldenExampleIndexer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GoldenExampleIndexer.d.ts","sourceRoot":"","sources":["../../src/cognitive/GoldenExampleIndexer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAE9D,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,oBAAoB;IACnB,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,YAAY;IAElC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAiCxE"}
@@ -0,0 +1,34 @@
1
+ export class GoldenExampleIndexer {
2
+ constructor(client) {
3
+ this.client = client;
4
+ }
5
+ async findExamples(intent, limit = 3) {
6
+ try {
7
+ // 1. Recall from Repo Memory using the intent
8
+ const result = await this.client.memoryRecall(intent, limit * 3);
9
+ const hits = result.results || [];
10
+ const examples = [];
11
+ for (const hit of hits) {
12
+ if (!hit.content.startsWith("GOLDEN_EXAMPLE"))
13
+ continue;
14
+ // Parse the stored format:
15
+ // GOLDEN_EXAMPLE
16
+ // INTENT: <intent>
17
+ // PATCH: <patch>
18
+ const intentMatch = hit.content.match(/INTENT:\s*(.*?)\nPATCH:/s);
19
+ const patchMatch = hit.content.match(/PATCH:\s*([\s\S]*)$/);
20
+ if (intentMatch && patchMatch) {
21
+ examples.push({
22
+ intent: intentMatch[1].trim(),
23
+ patch: patchMatch[1].trim(),
24
+ score: hit.score
25
+ });
26
+ }
27
+ }
28
+ return examples.slice(0, limit);
29
+ }
30
+ catch {
31
+ return [];
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,33 @@
1
+ export interface GoldenSetEntry {
2
+ intent: string;
3
+ plan_summary: string;
4
+ touched_files: string[];
5
+ review_notes?: string;
6
+ qa_notes?: string;
7
+ patch_summary?: string;
8
+ created_at: string;
9
+ }
10
+ export interface GoldenSetStoreOptions {
11
+ workspaceRoot: string;
12
+ storagePath?: string;
13
+ maxEntries?: number;
14
+ }
15
+ export interface GoldenExampleSummary {
16
+ intent: string;
17
+ patch: string;
18
+ score?: number;
19
+ }
20
+ export declare class GoldenSetStore {
21
+ private workspaceRoot;
22
+ private storagePath;
23
+ private maxEntries;
24
+ constructor(options: GoldenSetStoreOptions);
25
+ private resolveStoragePath;
26
+ private sanitizeEntry;
27
+ load(): Promise<GoldenSetEntry[]>;
28
+ append(entry: Omit<GoldenSetEntry, "created_at"> & {
29
+ created_at?: string;
30
+ }): Promise<GoldenSetEntry[]>;
31
+ findExamples(intent: string, limit?: number): Promise<GoldenExampleSummary[]>;
32
+ }
33
+ //# sourceMappingURL=GoldenSetStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GoldenSetStore.d.ts","sourceRoot":"","sources":["../../src/cognitive/GoldenSetStore.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AA6ED,qBAAa,cAAc;IACzB,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,UAAU,CAAS;gBAEf,OAAO,EAAE,qBAAqB;IAM1C,OAAO,CAAC,kBAAkB;IAS1B,OAAO,CAAC,aAAa;IAYf,IAAI,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC;IAkBjC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAiBtG,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,OAAO,CAAC,oBAAoB,EAAE,CAAC;CAuB/E"}
@@ -0,0 +1,159 @@
1
+ import { promises as fs } from "node:fs";
2
+ import path from "node:path";
3
+ const DEFAULT_STORAGE_PATH = ".mcoda/codali/golden-examples.jsonl";
4
+ const DEFAULT_MAX_ENTRIES = 50;
5
+ const REDACTION_PATTERNS = [
6
+ [/AKIA[0-9A-Z]{16}/g, "[REDACTED_AWS_KEY]"],
7
+ [/\bsk-[A-Za-z0-9]{20,}\b/g, "[REDACTED_TOKEN]"],
8
+ [/Bearer\s+[A-Za-z0-9._-]+/gi, "Bearer [REDACTED]"],
9
+ [/-----BEGIN [^-]+ PRIVATE KEY-----[\s\S]*?-----END [^-]+ PRIVATE KEY-----/g, "[REDACTED_PRIVATE_KEY]"],
10
+ ];
11
+ const normalizeText = (value) => {
12
+ let next = value;
13
+ for (const [pattern, replacement] of REDACTION_PATTERNS) {
14
+ next = next.replace(pattern, replacement);
15
+ }
16
+ return next.trim();
17
+ };
18
+ const tokenize = (value) => {
19
+ const matches = value.toLowerCase().match(/[a-z0-9_./-]{3,}/g);
20
+ return new Set(matches ?? []);
21
+ };
22
+ const scoreEntry = (queryTokens, entryText) => {
23
+ if (queryTokens.size === 0)
24
+ return 0;
25
+ const entryTokens = tokenize(entryText);
26
+ let overlap = 0;
27
+ for (const token of queryTokens) {
28
+ if (entryTokens.has(token))
29
+ overlap += 1;
30
+ }
31
+ return overlap / queryTokens.size;
32
+ };
33
+ const safeParseJson = (line) => {
34
+ try {
35
+ const parsed = JSON.parse(line);
36
+ if (!parsed || typeof parsed !== "object")
37
+ return undefined;
38
+ if (typeof parsed.intent !== "string" || typeof parsed.plan_summary !== "string")
39
+ return undefined;
40
+ return {
41
+ intent: parsed.intent,
42
+ plan_summary: parsed.plan_summary,
43
+ touched_files: Array.isArray(parsed.touched_files)
44
+ ? parsed.touched_files.filter((item) => typeof item === "string")
45
+ : [],
46
+ review_notes: typeof parsed.review_notes === "string" ? parsed.review_notes : undefined,
47
+ qa_notes: typeof parsed.qa_notes === "string" ? parsed.qa_notes : undefined,
48
+ patch_summary: typeof parsed.patch_summary === "string" ? parsed.patch_summary : undefined,
49
+ created_at: typeof parsed.created_at === "string" && parsed.created_at.trim().length > 0
50
+ ? parsed.created_at
51
+ : new Date(0).toISOString(),
52
+ };
53
+ }
54
+ catch {
55
+ return undefined;
56
+ }
57
+ };
58
+ const toPatchSummary = (entry) => {
59
+ const parts = [];
60
+ parts.push(`plan=${entry.plan_summary}`);
61
+ if (entry.touched_files.length > 0) {
62
+ parts.push(`files=${entry.touched_files.join(", ")}`);
63
+ }
64
+ if (entry.review_notes) {
65
+ parts.push(`review=${entry.review_notes}`);
66
+ }
67
+ if (entry.qa_notes) {
68
+ parts.push(`qa=${entry.qa_notes}`);
69
+ }
70
+ if (entry.patch_summary) {
71
+ parts.push(`patch=${entry.patch_summary}`);
72
+ }
73
+ return parts.join(" | ");
74
+ };
75
+ export class GoldenSetStore {
76
+ constructor(options) {
77
+ this.workspaceRoot = path.resolve(options.workspaceRoot);
78
+ this.storagePath = this.resolveStoragePath(options.storagePath ?? DEFAULT_STORAGE_PATH);
79
+ this.maxEntries = options.maxEntries && options.maxEntries > 0 ? Math.floor(options.maxEntries) : DEFAULT_MAX_ENTRIES;
80
+ }
81
+ resolveStoragePath(storagePath) {
82
+ const absolute = path.resolve(this.workspaceRoot, storagePath);
83
+ const relative = path.relative(this.workspaceRoot, absolute);
84
+ if (relative.startsWith("..") || path.isAbsolute(relative)) {
85
+ throw new Error("GoldenSetStore storage path must be inside workspace root");
86
+ }
87
+ return absolute;
88
+ }
89
+ sanitizeEntry(entry) {
90
+ return {
91
+ intent: normalizeText(entry.intent),
92
+ plan_summary: normalizeText(entry.plan_summary),
93
+ touched_files: entry.touched_files.map((item) => item.trim()).filter(Boolean),
94
+ review_notes: entry.review_notes ? normalizeText(entry.review_notes) : undefined,
95
+ qa_notes: entry.qa_notes ? normalizeText(entry.qa_notes) : undefined,
96
+ patch_summary: entry.patch_summary ? normalizeText(entry.patch_summary) : undefined,
97
+ created_at: entry.created_at,
98
+ };
99
+ }
100
+ async load() {
101
+ try {
102
+ const raw = await fs.readFile(this.storagePath, "utf8");
103
+ const entries = raw
104
+ .split(/\r?\n/)
105
+ .map((line) => line.trim())
106
+ .filter(Boolean)
107
+ .map((line) => safeParseJson(line))
108
+ .filter((entry) => Boolean(entry));
109
+ return entries.sort((a, b) => Date.parse(a.created_at) - Date.parse(b.created_at));
110
+ }
111
+ catch (error) {
112
+ if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
113
+ return [];
114
+ }
115
+ throw error;
116
+ }
117
+ }
118
+ async append(entry) {
119
+ const nextEntry = this.sanitizeEntry({
120
+ ...entry,
121
+ created_at: entry.created_at ?? new Date().toISOString(),
122
+ });
123
+ if (!nextEntry.intent || !nextEntry.plan_summary) {
124
+ throw new Error("GoldenSetStore entries require intent and plan_summary");
125
+ }
126
+ const existing = await this.load();
127
+ const all = [...existing, nextEntry];
128
+ const bounded = all.slice(Math.max(0, all.length - this.maxEntries));
129
+ await fs.mkdir(path.dirname(this.storagePath), { recursive: true });
130
+ const payload = bounded.map((item) => JSON.stringify(item)).join("\n");
131
+ await fs.writeFile(this.storagePath, payload.length > 0 ? `${payload}\n` : "", "utf8");
132
+ return bounded;
133
+ }
134
+ async findExamples(intent, limit = 3) {
135
+ const safeLimit = Math.max(1, Math.floor(limit));
136
+ const entries = await this.load();
137
+ if (entries.length === 0)
138
+ return [];
139
+ const queryTokens = tokenize(intent);
140
+ return entries
141
+ .map((entry) => {
142
+ const text = `${entry.intent}\n${entry.plan_summary}\n${entry.touched_files.join(" ")}\n${entry.review_notes ?? ""}\n${entry.qa_notes ?? ""}`;
143
+ const score = scoreEntry(queryTokens, text);
144
+ return {
145
+ intent: entry.intent,
146
+ patch: toPatchSummary(entry),
147
+ score,
148
+ createdAt: Date.parse(entry.created_at),
149
+ };
150
+ })
151
+ .sort((a, b) => {
152
+ if (b.score !== a.score)
153
+ return b.score - a.score;
154
+ return b.createdAt - a.createdAt;
155
+ })
156
+ .slice(0, safeLimit)
157
+ .map((entry) => ({ intent: entry.intent, patch: entry.patch, score: entry.score }));
158
+ }
159
+ }
@@ -0,0 +1,7 @@
1
+ export type IntentBucket = "ui" | "content" | "behavior" | "data" | "testing" | "infra" | "security" | "performance" | "observability";
2
+ export interface IntentSignals {
3
+ intents: IntentBucket[];
4
+ matches: Record<IntentBucket, string[]>;
5
+ }
6
+ export declare const deriveIntentSignals: (request: string) => IntentSignals;
7
+ //# sourceMappingURL=IntentSignals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IntentSignals.d.ts","sourceRoot":"","sources":["../../src/cognitive/IntentSignals.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GACpB,IAAI,GACJ,SAAS,GACT,UAAU,GACV,MAAM,GACN,SAAS,GACT,OAAO,GACP,UAAU,GACV,aAAa,GACb,eAAe,CAAC;AAEpB,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,OAAO,EAAE,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,CAAC,CAAC;CACzC;AAsPD,eAAO,MAAM,mBAAmB,GAAI,SAAS,MAAM,KAAG,aAkDrD,CAAC"}
@@ -0,0 +1,285 @@
1
+ const UI_KEYWORDS = [
2
+ "ui",
3
+ "ux",
4
+ "page",
5
+ "screen",
6
+ "layout",
7
+ "header",
8
+ "hero",
9
+ "navbar",
10
+ "footer",
11
+ "landing",
12
+ "welcome",
13
+ "title",
14
+ "button",
15
+ "style",
16
+ "css",
17
+ "html",
18
+ "markup",
19
+ "template",
20
+ "component",
21
+ "view",
22
+ ];
23
+ const CONTENT_KEYWORDS = [
24
+ "copy",
25
+ "text",
26
+ "label",
27
+ "wording",
28
+ "message",
29
+ "string",
30
+ "content",
31
+ ];
32
+ const BEHAVIOR_KEYWORDS = [
33
+ "logic",
34
+ "behavior",
35
+ "bug",
36
+ "fix",
37
+ "error",
38
+ "crash",
39
+ "api",
40
+ "backend",
41
+ "server",
42
+ "endpoint",
43
+ "route",
44
+ "router",
45
+ "handler",
46
+ "healthz",
47
+ "health",
48
+ "logging",
49
+ "logger",
50
+ "uptime",
51
+ "flow",
52
+ "auth",
53
+ "estimate",
54
+ "estimation",
55
+ "stats",
56
+ "stat",
57
+ "completion",
58
+ "completions",
59
+ "calculate",
60
+ "computed",
61
+ "compute",
62
+ "count",
63
+ "aggregate",
64
+ "summary",
65
+ ];
66
+ const DATA_KEYWORDS = [
67
+ "schema",
68
+ "database",
69
+ "db",
70
+ "model",
71
+ "migration",
72
+ "table",
73
+ "field",
74
+ "column",
75
+ "sql",
76
+ ];
77
+ const TESTING_KEYWORDS = [
78
+ "test",
79
+ "tests",
80
+ "testing",
81
+ "unit",
82
+ "integration",
83
+ "e2e",
84
+ "spec",
85
+ "specs",
86
+ "snapshot",
87
+ "snapshots",
88
+ "golden",
89
+ "approval",
90
+ "assertion",
91
+ "assertions",
92
+ "jest",
93
+ "vitest",
94
+ "mocha",
95
+ "pytest",
96
+ "rspec",
97
+ "junit",
98
+ "xunit",
99
+ "cypress",
100
+ "playwright",
101
+ "fixture",
102
+ "fixtures",
103
+ "mock",
104
+ "mocking",
105
+ "coverage",
106
+ ];
107
+ const INFRA_BASE_KEYWORDS = [
108
+ "infra",
109
+ "infrastructure",
110
+ "ops",
111
+ "devops",
112
+ "ci",
113
+ "cd",
114
+ "pipeline",
115
+ "deploy",
116
+ "deployment",
117
+ "docker",
118
+ "compose",
119
+ "k8s",
120
+ "kubernetes",
121
+ "helm",
122
+ "terraform",
123
+ "ansible",
124
+ "makefile",
125
+ "workflow",
126
+ "runner",
127
+ "github actions",
128
+ "gitlab",
129
+ "gitlab ci",
130
+ "circleci",
131
+ "artifact",
132
+ "registry",
133
+ ];
134
+ const INFRA_CONDITIONAL_KEYWORDS = ["build", "release", "package"];
135
+ const SECURITY_KEYWORDS = [
136
+ "security",
137
+ "secure",
138
+ "auth",
139
+ "authentication",
140
+ "authorization",
141
+ "permission",
142
+ "permissions",
143
+ "rbac",
144
+ "acl",
145
+ "policy",
146
+ "jwt",
147
+ "oauth",
148
+ "sso",
149
+ "csrf",
150
+ "xss",
151
+ "samesite",
152
+ "csp",
153
+ "encrypt",
154
+ "encryption",
155
+ "crypto",
156
+ "secret",
157
+ "secrets",
158
+ "vault",
159
+ "audit",
160
+ "vulnerability",
161
+ "sanitize",
162
+ ];
163
+ const PERFORMANCE_KEYWORDS = [
164
+ "performance",
165
+ "perf",
166
+ "slow",
167
+ "slowdown",
168
+ "latency",
169
+ "throughput",
170
+ "optimize",
171
+ "optimization",
172
+ "cache",
173
+ "caching",
174
+ "cache miss",
175
+ "memo",
176
+ "benchmark",
177
+ "profiling",
178
+ "profile",
179
+ "hot path",
180
+ "n+1",
181
+ "memory",
182
+ "cpu",
183
+ "throttle",
184
+ "rate limit",
185
+ "rate-limit",
186
+ "batch",
187
+ "queue",
188
+ "timeout",
189
+ ];
190
+ const OBSERVABILITY_KEYWORDS = [
191
+ "observability",
192
+ "telemetry",
193
+ "instrument",
194
+ "instrumentation",
195
+ "logging",
196
+ "log",
197
+ "logger",
198
+ "log level",
199
+ "structured logging",
200
+ "metrics",
201
+ "monitor",
202
+ "monitoring",
203
+ "trace",
204
+ "tracing",
205
+ "trace id",
206
+ "span",
207
+ "otel",
208
+ "opentelemetry",
209
+ "sentry",
210
+ "datadog",
211
+ "prometheus",
212
+ "grafana",
213
+ "alert",
214
+ "alerts",
215
+ ];
216
+ const OBSERVABILITY_LOGGING_ONLY = new Set([
217
+ "logging",
218
+ "log",
219
+ "logger",
220
+ "log level",
221
+ "structured logging",
222
+ ]);
223
+ const normalize = (value) => value.toLowerCase().replace(/[^a-z0-9\\s]/g, " ");
224
+ const collectMatches = (text, keywords) => {
225
+ const matches = [];
226
+ for (const keyword of keywords) {
227
+ if (text.includes(keyword))
228
+ matches.push(keyword);
229
+ }
230
+ return matches;
231
+ };
232
+ export const deriveIntentSignals = (request) => {
233
+ const normalized = normalize(request ?? "");
234
+ const uiMatches = collectMatches(normalized, UI_KEYWORDS);
235
+ const contentMatches = collectMatches(normalized, CONTENT_KEYWORDS);
236
+ const behaviorMatches = collectMatches(normalized, BEHAVIOR_KEYWORDS);
237
+ const dataMatches = collectMatches(normalized, DATA_KEYWORDS);
238
+ const testingMatches = collectMatches(normalized, TESTING_KEYWORDS);
239
+ const infraBaseMatches = collectMatches(normalized, INFRA_BASE_KEYWORDS);
240
+ const infraConditionalMatches = collectMatches(normalized, INFRA_CONDITIONAL_KEYWORDS);
241
+ const infraMatches = infraBaseMatches.length > 0
242
+ ? [...infraBaseMatches, ...infraConditionalMatches]
243
+ : infraBaseMatches;
244
+ const securityMatches = collectMatches(normalized, SECURITY_KEYWORDS);
245
+ const performanceMatches = collectMatches(normalized, PERFORMANCE_KEYWORDS);
246
+ const observabilityMatches = collectMatches(normalized, OBSERVABILITY_KEYWORDS);
247
+ const observabilityHasSignal = observabilityMatches.some((match) => !OBSERVABILITY_LOGGING_ONLY.has(match));
248
+ const observabilityFinal = observabilityHasSignal ? observabilityMatches : [];
249
+ const intents = [];
250
+ if (uiMatches.length)
251
+ intents.push("ui");
252
+ if (contentMatches.length)
253
+ intents.push("content");
254
+ if (behaviorMatches.length)
255
+ intents.push("behavior");
256
+ if (dataMatches.length)
257
+ intents.push("data");
258
+ if (testingMatches.length)
259
+ intents.push("testing");
260
+ if (infraMatches.length)
261
+ intents.push("infra");
262
+ if (securityMatches.length)
263
+ intents.push("security");
264
+ if (performanceMatches.length)
265
+ intents.push("performance");
266
+ if (observabilityFinal.length)
267
+ intents.push("observability");
268
+ if (intents.length === 0) {
269
+ intents.push("behavior");
270
+ }
271
+ return {
272
+ intents,
273
+ matches: {
274
+ ui: uiMatches,
275
+ content: contentMatches,
276
+ behavior: behaviorMatches,
277
+ data: dataMatches,
278
+ testing: testingMatches,
279
+ infra: infraMatches,
280
+ security: securityMatches,
281
+ performance: performanceMatches,
282
+ observability: observabilityFinal,
283
+ },
284
+ };
285
+ };