codehere 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of codehere might be problematic. Click here for more details.

Files changed (405) hide show
  1. package/README.md +223 -42
  2. package/dist/application/agents/documentation-agent.d.ts +24 -0
  3. package/dist/application/agents/documentation-agent.d.ts.map +1 -0
  4. package/dist/application/agents/documentation-agent.js +399 -0
  5. package/dist/application/agents/documentation-agent.js.map +1 -0
  6. package/dist/application/agents/execution-agent.d.ts +11 -0
  7. package/dist/application/agents/execution-agent.d.ts.map +1 -1
  8. package/dist/application/agents/execution-agent.js +289 -80
  9. package/dist/application/agents/execution-agent.js.map +1 -1
  10. package/dist/application/agents/multi-agent-orchestrator.d.ts +4 -0
  11. package/dist/application/agents/multi-agent-orchestrator.d.ts.map +1 -1
  12. package/dist/application/agents/multi-agent-orchestrator.js +86 -0
  13. package/dist/application/agents/multi-agent-orchestrator.js.map +1 -1
  14. package/dist/application/agents/planning-agent.d.ts +3 -0
  15. package/dist/application/agents/planning-agent.d.ts.map +1 -1
  16. package/dist/application/agents/planning-agent.js +132 -64
  17. package/dist/application/agents/planning-agent.js.map +1 -1
  18. package/dist/application/agents/product-requirements-agent.d.ts +21 -0
  19. package/dist/application/agents/product-requirements-agent.d.ts.map +1 -0
  20. package/dist/application/agents/product-requirements-agent.js +247 -0
  21. package/dist/application/agents/product-requirements-agent.js.map +1 -0
  22. package/dist/application/agents/validation-agent.d.ts +5 -1
  23. package/dist/application/agents/validation-agent.d.ts.map +1 -1
  24. package/dist/application/agents/validation-agent.js +156 -21
  25. package/dist/application/agents/validation-agent.js.map +1 -1
  26. package/dist/application/services/dependency-container.d.ts +25 -2
  27. package/dist/application/services/dependency-container.d.ts.map +1 -1
  28. package/dist/application/services/dependency-container.js +163 -1
  29. package/dist/application/services/dependency-container.js.map +1 -1
  30. package/dist/application/services/intelligent-router.d.ts +13 -0
  31. package/dist/application/services/intelligent-router.d.ts.map +1 -1
  32. package/dist/application/services/intelligent-router.js +300 -87
  33. package/dist/application/services/intelligent-router.js.map +1 -1
  34. package/dist/application/use-cases/ask-question-use-case.d.ts +31 -0
  35. package/dist/application/use-cases/ask-question-use-case.d.ts.map +1 -1
  36. package/dist/application/use-cases/ask-question-use-case.js +254 -55
  37. package/dist/application/use-cases/ask-question-use-case.js.map +1 -1
  38. package/dist/application/use-cases/edit-file-use-case.d.ts.map +1 -1
  39. package/dist/application/use-cases/edit-file-use-case.js +86 -4
  40. package/dist/application/use-cases/edit-file-use-case.js.map +1 -1
  41. package/dist/application/use-cases/planning-use-case.d.ts.map +1 -1
  42. package/dist/application/use-cases/planning-use-case.js +10 -1
  43. package/dist/application/use-cases/planning-use-case.js.map +1 -1
  44. package/dist/application/use-cases/react-orchestration-use-case.d.ts.map +1 -1
  45. package/dist/application/use-cases/react-orchestration-use-case.js +6 -2
  46. package/dist/application/use-cases/react-orchestration-use-case.js.map +1 -1
  47. package/dist/domain/entities/documentation.d.ts +35 -0
  48. package/dist/domain/entities/documentation.d.ts.map +1 -0
  49. package/dist/domain/entities/documentation.js +6 -0
  50. package/dist/domain/entities/documentation.js.map +1 -0
  51. package/dist/domain/entities/product-requirements.d.ts +50 -0
  52. package/dist/domain/entities/product-requirements.d.ts.map +1 -0
  53. package/dist/domain/entities/product-requirements.js +6 -0
  54. package/dist/domain/entities/product-requirements.js.map +1 -0
  55. package/dist/domain/entities/task.d.ts +152 -0
  56. package/dist/domain/entities/task.d.ts.map +1 -0
  57. package/dist/domain/entities/task.js +61 -0
  58. package/dist/domain/entities/task.js.map +1 -0
  59. package/dist/domain/interfaces/agent.interface.d.ts +15 -0
  60. package/dist/domain/interfaces/agent.interface.d.ts.map +1 -0
  61. package/dist/domain/interfaces/agent.interface.js +6 -0
  62. package/dist/domain/interfaces/agent.interface.js.map +1 -0
  63. package/dist/domain/services/environment-mode-manager.d.ts +18 -0
  64. package/dist/domain/services/environment-mode-manager.d.ts.map +1 -0
  65. package/dist/domain/services/environment-mode-manager.js +37 -0
  66. package/dist/domain/services/environment-mode-manager.js.map +1 -0
  67. package/dist/domain/services/react-loop.d.ts +8 -0
  68. package/dist/domain/services/react-loop.d.ts.map +1 -1
  69. package/dist/domain/services/react-loop.js +82 -6
  70. package/dist/domain/services/react-loop.js.map +1 -1
  71. package/dist/domain/services/risk-tier-detector.d.ts +18 -0
  72. package/dist/domain/services/risk-tier-detector.d.ts.map +1 -0
  73. package/dist/domain/services/risk-tier-detector.js +65 -0
  74. package/dist/domain/services/risk-tier-detector.js.map +1 -0
  75. package/dist/formatter.d.ts +2 -2
  76. package/dist/formatter.d.ts.map +1 -1
  77. package/dist/formatter.js +40 -20
  78. package/dist/formatter.js.map +1 -1
  79. package/dist/index.js +218 -125
  80. package/dist/index.js.map +1 -1
  81. package/dist/infrastructure/ai/cohere-ai-service.d.ts +3 -1
  82. package/dist/infrastructure/ai/cohere-ai-service.d.ts.map +1 -1
  83. package/dist/infrastructure/ai/cohere-ai-service.js +65 -5
  84. package/dist/infrastructure/ai/cohere-ai-service.js.map +1 -1
  85. package/dist/infrastructure/ai/fake-ai-service.d.ts +22 -0
  86. package/dist/infrastructure/ai/fake-ai-service.d.ts.map +1 -0
  87. package/dist/infrastructure/ai/fake-ai-service.js +59 -0
  88. package/dist/infrastructure/ai/fake-ai-service.js.map +1 -0
  89. package/dist/infrastructure/ai/provider-ai-service.d.ts +59 -0
  90. package/dist/infrastructure/ai/provider-ai-service.d.ts.map +1 -0
  91. package/dist/infrastructure/ai/provider-ai-service.js +477 -0
  92. package/dist/infrastructure/ai/provider-ai-service.js.map +1 -0
  93. package/dist/infrastructure/cache/embedding-cache.d.ts +13 -1
  94. package/dist/infrastructure/cache/embedding-cache.d.ts.map +1 -1
  95. package/dist/infrastructure/cache/embedding-cache.js +80 -9
  96. package/dist/infrastructure/cache/embedding-cache.js.map +1 -1
  97. package/dist/infrastructure/cache/query-result-cache.d.ts +68 -0
  98. package/dist/infrastructure/cache/query-result-cache.d.ts.map +1 -0
  99. package/dist/infrastructure/cache/query-result-cache.js +138 -0
  100. package/dist/infrastructure/cache/query-result-cache.js.map +1 -0
  101. package/dist/infrastructure/cache/response-cache.d.ts +86 -0
  102. package/dist/infrastructure/cache/response-cache.d.ts.map +1 -0
  103. package/dist/infrastructure/cache/response-cache.js +224 -0
  104. package/dist/infrastructure/cache/response-cache.js.map +1 -0
  105. package/dist/infrastructure/cache/security-scan-cache.d.ts +57 -0
  106. package/dist/infrastructure/cache/security-scan-cache.d.ts.map +1 -0
  107. package/dist/infrastructure/cache/security-scan-cache.js +124 -0
  108. package/dist/infrastructure/cache/security-scan-cache.js.map +1 -0
  109. package/dist/infrastructure/completion/bash-completion.d.ts +8 -0
  110. package/dist/infrastructure/completion/bash-completion.d.ts.map +1 -0
  111. package/dist/infrastructure/completion/bash-completion.js +101 -0
  112. package/dist/infrastructure/completion/bash-completion.js.map +1 -0
  113. package/dist/infrastructure/completion/completion-generator.d.ts +42 -0
  114. package/dist/infrastructure/completion/completion-generator.d.ts.map +1 -0
  115. package/dist/infrastructure/completion/completion-generator.js +184 -0
  116. package/dist/infrastructure/completion/completion-generator.js.map +1 -0
  117. package/dist/infrastructure/completion/fish-completion.d.ts +8 -0
  118. package/dist/infrastructure/completion/fish-completion.d.ts.map +1 -0
  119. package/dist/infrastructure/completion/fish-completion.js +65 -0
  120. package/dist/infrastructure/completion/fish-completion.js.map +1 -0
  121. package/dist/infrastructure/completion/zsh-completion.d.ts +8 -0
  122. package/dist/infrastructure/completion/zsh-completion.d.ts.map +1 -0
  123. package/dist/infrastructure/completion/zsh-completion.js +85 -0
  124. package/dist/infrastructure/completion/zsh-completion.js.map +1 -0
  125. package/dist/infrastructure/context/context-compressor.d.ts +94 -0
  126. package/dist/infrastructure/context/context-compressor.d.ts.map +1 -0
  127. package/dist/infrastructure/context/context-compressor.js +329 -0
  128. package/dist/infrastructure/context/context-compressor.js.map +1 -0
  129. package/dist/infrastructure/context/conversation-context.d.ts +58 -0
  130. package/dist/infrastructure/context/conversation-context.d.ts.map +1 -0
  131. package/dist/infrastructure/context/conversation-context.js +170 -0
  132. package/dist/infrastructure/context/conversation-context.js.map +1 -0
  133. package/dist/infrastructure/context/session-manager.d.ts +26 -0
  134. package/dist/infrastructure/context/session-manager.d.ts.map +1 -0
  135. package/dist/infrastructure/context/session-manager.js +98 -0
  136. package/dist/infrastructure/context/session-manager.js.map +1 -0
  137. package/dist/infrastructure/cost/cost-tracker.d.ts +1 -0
  138. package/dist/infrastructure/cost/cost-tracker.d.ts.map +1 -1
  139. package/dist/infrastructure/cost/cost-tracker.js +12 -5
  140. package/dist/infrastructure/cost/cost-tracker.js.map +1 -1
  141. package/dist/infrastructure/governance/nist-ai-rmf.d.ts +6 -8
  142. package/dist/infrastructure/governance/nist-ai-rmf.d.ts.map +1 -1
  143. package/dist/infrastructure/governance/nist-ai-rmf.js +6 -8
  144. package/dist/infrastructure/governance/nist-ai-rmf.js.map +1 -1
  145. package/dist/infrastructure/governance/policy-as-code.d.ts +6 -8
  146. package/dist/infrastructure/governance/policy-as-code.d.ts.map +1 -1
  147. package/dist/infrastructure/governance/policy-as-code.js +24 -11
  148. package/dist/infrastructure/governance/policy-as-code.js.map +1 -1
  149. package/dist/infrastructure/governance/prompt-to-code-lineage.d.ts +7 -9
  150. package/dist/infrastructure/governance/prompt-to-code-lineage.d.ts.map +1 -1
  151. package/dist/infrastructure/governance/prompt-to-code-lineage.js +7 -9
  152. package/dist/infrastructure/governance/prompt-to-code-lineage.js.map +1 -1
  153. package/dist/infrastructure/observability/execution-tracer.d.ts +5 -2
  154. package/dist/infrastructure/observability/execution-tracer.d.ts.map +1 -1
  155. package/dist/infrastructure/observability/execution-tracer.js +45 -8
  156. package/dist/infrastructure/observability/execution-tracer.js.map +1 -1
  157. package/dist/infrastructure/providers/cohere-provider.d.ts +39 -0
  158. package/dist/infrastructure/providers/cohere-provider.d.ts.map +1 -0
  159. package/dist/infrastructure/providers/cohere-provider.js +359 -0
  160. package/dist/infrastructure/providers/cohere-provider.js.map +1 -0
  161. package/dist/infrastructure/providers/fake-provider.d.ts +43 -0
  162. package/dist/infrastructure/providers/fake-provider.d.ts.map +1 -0
  163. package/dist/infrastructure/providers/fake-provider.js +130 -0
  164. package/dist/infrastructure/providers/fake-provider.js.map +1 -0
  165. package/dist/infrastructure/providers/local-llm-provider.d.ts +49 -0
  166. package/dist/infrastructure/providers/local-llm-provider.d.ts.map +1 -0
  167. package/dist/infrastructure/providers/local-llm-provider.js +330 -0
  168. package/dist/infrastructure/providers/local-llm-provider.js.map +1 -0
  169. package/dist/infrastructure/providers/model-config.types.d.ts +70 -0
  170. package/dist/infrastructure/providers/model-config.types.d.ts.map +1 -0
  171. package/dist/infrastructure/providers/model-config.types.js +9 -0
  172. package/dist/infrastructure/providers/model-config.types.js.map +1 -0
  173. package/dist/infrastructure/providers/model-provider.interface.d.ts +113 -0
  174. package/dist/infrastructure/providers/model-provider.interface.d.ts.map +1 -0
  175. package/dist/infrastructure/providers/model-provider.interface.js +8 -0
  176. package/dist/infrastructure/providers/model-provider.interface.js.map +1 -0
  177. package/dist/infrastructure/providers/openai-provider.d.ts +38 -0
  178. package/dist/infrastructure/providers/openai-provider.d.ts.map +1 -0
  179. package/dist/infrastructure/providers/openai-provider.js +413 -0
  180. package/dist/infrastructure/providers/openai-provider.js.map +1 -0
  181. package/dist/infrastructure/providers/operation-provider-resolver.d.ts +48 -0
  182. package/dist/infrastructure/providers/operation-provider-resolver.d.ts.map +1 -0
  183. package/dist/infrastructure/providers/operation-provider-resolver.js +105 -0
  184. package/dist/infrastructure/providers/operation-provider-resolver.js.map +1 -0
  185. package/dist/infrastructure/providers/provider-config-loader.d.ts +37 -0
  186. package/dist/infrastructure/providers/provider-config-loader.d.ts.map +1 -0
  187. package/dist/infrastructure/providers/provider-config-loader.js +120 -0
  188. package/dist/infrastructure/providers/provider-config-loader.js.map +1 -0
  189. package/dist/infrastructure/providers/provider-registry.d.ts +53 -0
  190. package/dist/infrastructure/providers/provider-registry.d.ts.map +1 -0
  191. package/dist/infrastructure/providers/provider-registry.js +88 -0
  192. package/dist/infrastructure/providers/provider-registry.js.map +1 -0
  193. package/dist/infrastructure/security/ai-sast-scanner.d.ts +4 -0
  194. package/dist/infrastructure/security/ai-sast-scanner.d.ts.map +1 -1
  195. package/dist/infrastructure/security/ai-sast-scanner.js +82 -4
  196. package/dist/infrastructure/security/ai-sast-scanner.js.map +1 -1
  197. package/dist/infrastructure/security/enhanced-security-gate.d.ts +2 -0
  198. package/dist/infrastructure/security/enhanced-security-gate.d.ts.map +1 -1
  199. package/dist/infrastructure/security/enhanced-security-gate.js +74 -15
  200. package/dist/infrastructure/security/enhanced-security-gate.js.map +1 -1
  201. package/dist/infrastructure/storage/plan-repository.d.ts +38 -0
  202. package/dist/infrastructure/storage/plan-repository.d.ts.map +1 -0
  203. package/dist/infrastructure/storage/plan-repository.js +133 -0
  204. package/dist/infrastructure/storage/plan-repository.js.map +1 -0
  205. package/dist/infrastructure/storage/sqlite-embedding-repository.d.ts +11 -0
  206. package/dist/infrastructure/storage/sqlite-embedding-repository.d.ts.map +1 -1
  207. package/dist/infrastructure/storage/sqlite-embedding-repository.js +121 -6
  208. package/dist/infrastructure/storage/sqlite-embedding-repository.js.map +1 -1
  209. package/dist/infrastructure/storage/task-helpers.d.ts +58 -0
  210. package/dist/infrastructure/storage/task-helpers.d.ts.map +1 -0
  211. package/dist/infrastructure/storage/task-helpers.js +157 -0
  212. package/dist/infrastructure/storage/task-helpers.js.map +1 -0
  213. package/dist/infrastructure/storage/task-repository.d.ts +67 -0
  214. package/dist/infrastructure/storage/task-repository.d.ts.map +1 -0
  215. package/dist/infrastructure/storage/task-repository.js +205 -0
  216. package/dist/infrastructure/storage/task-repository.js.map +1 -0
  217. package/dist/infrastructure/ux/bi-directional-learning.d.ts +22 -0
  218. package/dist/infrastructure/ux/bi-directional-learning.d.ts.map +1 -1
  219. package/dist/infrastructure/ux/bi-directional-learning.js +144 -7
  220. package/dist/infrastructure/ux/bi-directional-learning.js.map +1 -1
  221. package/dist/infrastructure/ux/capability-boundaries.d.ts +50 -0
  222. package/dist/infrastructure/ux/capability-boundaries.d.ts.map +1 -0
  223. package/dist/infrastructure/ux/capability-boundaries.js +167 -0
  224. package/dist/infrastructure/ux/capability-boundaries.js.map +1 -0
  225. package/dist/infrastructure/ux/comprehensive-formatter.d.ts +63 -0
  226. package/dist/infrastructure/ux/comprehensive-formatter.d.ts.map +1 -0
  227. package/dist/infrastructure/ux/comprehensive-formatter.js +212 -0
  228. package/dist/infrastructure/ux/comprehensive-formatter.js.map +1 -0
  229. package/dist/infrastructure/ux/contextual-feature-discovery.d.ts +24 -0
  230. package/dist/infrastructure/ux/contextual-feature-discovery.d.ts.map +1 -0
  231. package/dist/infrastructure/ux/contextual-feature-discovery.js +144 -0
  232. package/dist/infrastructure/ux/contextual-feature-discovery.js.map +1 -0
  233. package/dist/infrastructure/ux/expectation-management.d.ts +33 -0
  234. package/dist/infrastructure/ux/expectation-management.d.ts.map +1 -1
  235. package/dist/infrastructure/ux/expectation-management.js +138 -4
  236. package/dist/infrastructure/ux/expectation-management.js.map +1 -1
  237. package/dist/infrastructure/ux/feature-discovery.d.ts +47 -0
  238. package/dist/infrastructure/ux/feature-discovery.d.ts.map +1 -0
  239. package/dist/infrastructure/ux/feature-discovery.js +190 -0
  240. package/dist/infrastructure/ux/feature-discovery.js.map +1 -0
  241. package/dist/infrastructure/ux/feedback-prompt.d.ts +42 -0
  242. package/dist/infrastructure/ux/feedback-prompt.d.ts.map +1 -0
  243. package/dist/infrastructure/ux/feedback-prompt.js +181 -0
  244. package/dist/infrastructure/ux/feedback-prompt.js.map +1 -0
  245. package/dist/infrastructure/ux/hitl-review-portal.d.ts +47 -0
  246. package/dist/infrastructure/ux/hitl-review-portal.d.ts.map +1 -0
  247. package/dist/infrastructure/ux/hitl-review-portal.js +228 -0
  248. package/dist/infrastructure/ux/hitl-review-portal.js.map +1 -0
  249. package/dist/infrastructure/ux/hitl-validation.d.ts +35 -0
  250. package/dist/infrastructure/ux/hitl-validation.d.ts.map +1 -1
  251. package/dist/infrastructure/ux/hitl-validation.js +86 -0
  252. package/dist/infrastructure/ux/hitl-validation.js.map +1 -1
  253. package/dist/infrastructure/ux/progress-indicator.d.ts +55 -0
  254. package/dist/infrastructure/ux/progress-indicator.d.ts.map +1 -0
  255. package/dist/infrastructure/ux/progress-indicator.js +131 -0
  256. package/dist/infrastructure/ux/progress-indicator.js.map +1 -0
  257. package/dist/infrastructure/ux/progressive-disclosure.d.ts.map +1 -1
  258. package/dist/infrastructure/ux/progressive-disclosure.js +2 -1
  259. package/dist/infrastructure/ux/progressive-disclosure.js.map +1 -1
  260. package/dist/infrastructure/ux/proportional-friction.d.ts +73 -0
  261. package/dist/infrastructure/ux/proportional-friction.d.ts.map +1 -0
  262. package/dist/infrastructure/ux/proportional-friction.js +200 -0
  263. package/dist/infrastructure/ux/proportional-friction.js.map +1 -0
  264. package/dist/infrastructure/ux/review-checkpoint.d.ts +35 -0
  265. package/dist/infrastructure/ux/review-checkpoint.d.ts.map +1 -0
  266. package/dist/infrastructure/ux/review-checkpoint.js +119 -0
  267. package/dist/infrastructure/ux/review-checkpoint.js.map +1 -0
  268. package/dist/infrastructure/ux/staged-feature-intro.d.ts +47 -0
  269. package/dist/infrastructure/ux/staged-feature-intro.d.ts.map +1 -0
  270. package/dist/infrastructure/ux/staged-feature-intro.js +144 -0
  271. package/dist/infrastructure/ux/staged-feature-intro.js.map +1 -0
  272. package/dist/infrastructure/ux/syntax-highlighter.d.ts +21 -0
  273. package/dist/infrastructure/ux/syntax-highlighter.d.ts.map +1 -0
  274. package/dist/infrastructure/ux/syntax-highlighter.js +172 -0
  275. package/dist/infrastructure/ux/syntax-highlighter.js.map +1 -0
  276. package/dist/infrastructure/validation/agent-feedback.d.ts +115 -0
  277. package/dist/infrastructure/validation/agent-feedback.d.ts.map +1 -0
  278. package/dist/infrastructure/validation/agent-feedback.js +227 -0
  279. package/dist/infrastructure/validation/agent-feedback.js.map +1 -0
  280. package/dist/infrastructure/validation/agent-validation-helper.d.ts +75 -0
  281. package/dist/infrastructure/validation/agent-validation-helper.d.ts.map +1 -0
  282. package/dist/infrastructure/validation/agent-validation-helper.js +88 -0
  283. package/dist/infrastructure/validation/agent-validation-helper.js.map +1 -0
  284. package/dist/infrastructure/validation/feedback-stats.d.ts +99 -0
  285. package/dist/infrastructure/validation/feedback-stats.d.ts.map +1 -0
  286. package/dist/infrastructure/validation/feedback-stats.js +173 -0
  287. package/dist/infrastructure/validation/feedback-stats.js.map +1 -0
  288. package/dist/infrastructure/validation/review-handler.d.ts +54 -0
  289. package/dist/infrastructure/validation/review-handler.d.ts.map +1 -0
  290. package/dist/infrastructure/validation/review-handler.js +206 -0
  291. package/dist/infrastructure/validation/review-handler.js.map +1 -0
  292. package/dist/infrastructure/validation/summary-aggregator.d.ts +42 -0
  293. package/dist/infrastructure/validation/summary-aggregator.d.ts.map +1 -0
  294. package/dist/infrastructure/validation/summary-aggregator.js +156 -0
  295. package/dist/infrastructure/validation/summary-aggregator.js.map +1 -0
  296. package/dist/infrastructure/validation/summary-extractor.d.ts +59 -0
  297. package/dist/infrastructure/validation/summary-extractor.d.ts.map +1 -0
  298. package/dist/infrastructure/validation/summary-extractor.js +102 -0
  299. package/dist/infrastructure/validation/summary-extractor.js.map +1 -0
  300. package/dist/infrastructure/validation/trace-summary.d.ts +72 -0
  301. package/dist/infrastructure/validation/trace-summary.d.ts.map +1 -0
  302. package/dist/infrastructure/validation/trace-summary.js +371 -0
  303. package/dist/infrastructure/validation/trace-summary.js.map +1 -0
  304. package/dist/infrastructure/validation/trust-config.d.ts +27 -0
  305. package/dist/infrastructure/validation/trust-config.d.ts.map +1 -0
  306. package/dist/infrastructure/validation/trust-config.js +113 -0
  307. package/dist/infrastructure/validation/trust-config.js.map +1 -0
  308. package/dist/infrastructure/xai/attention-visualizer.d.ts +6 -8
  309. package/dist/infrastructure/xai/attention-visualizer.d.ts.map +1 -1
  310. package/dist/infrastructure/xai/attention-visualizer.js +6 -8
  311. package/dist/infrastructure/xai/attention-visualizer.js.map +1 -1
  312. package/dist/infrastructure/xai/cot-visualizer.d.ts +6 -8
  313. package/dist/infrastructure/xai/cot-visualizer.d.ts.map +1 -1
  314. package/dist/infrastructure/xai/cot-visualizer.js +62 -18
  315. package/dist/infrastructure/xai/cot-visualizer.js.map +1 -1
  316. package/dist/infrastructure/xai/decision-tree-log.d.ts +6 -10
  317. package/dist/infrastructure/xai/decision-tree-log.d.ts.map +1 -1
  318. package/dist/infrastructure/xai/decision-tree-log.js +6 -10
  319. package/dist/infrastructure/xai/decision-tree-log.js.map +1 -1
  320. package/dist/infrastructure/xai/interactive-xai.d.ts +6 -8
  321. package/dist/infrastructure/xai/interactive-xai.d.ts.map +1 -1
  322. package/dist/infrastructure/xai/interactive-xai.js +6 -8
  323. package/dist/infrastructure/xai/interactive-xai.js.map +1 -1
  324. package/dist/infrastructure/xai/uncertainty-quantifier.d.ts +6 -9
  325. package/dist/infrastructure/xai/uncertainty-quantifier.d.ts.map +1 -1
  326. package/dist/infrastructure/xai/uncertainty-quantifier.js +6 -9
  327. package/dist/infrastructure/xai/uncertainty-quantifier.js.map +1 -1
  328. package/dist/presentation/cli/commands/ask-command.d.ts.map +1 -1
  329. package/dist/presentation/cli/commands/ask-command.js +152 -13
  330. package/dist/presentation/cli/commands/ask-command.js.map +1 -1
  331. package/dist/presentation/cli/commands/docs-command.d.ts +12 -0
  332. package/dist/presentation/cli/commands/docs-command.d.ts.map +1 -0
  333. package/dist/presentation/cli/commands/docs-command.js +196 -0
  334. package/dist/presentation/cli/commands/docs-command.js.map +1 -0
  335. package/dist/presentation/cli/commands/fix-command.d.ts +8 -0
  336. package/dist/presentation/cli/commands/fix-command.d.ts.map +1 -0
  337. package/dist/presentation/cli/commands/fix-command.js +309 -0
  338. package/dist/presentation/cli/commands/fix-command.js.map +1 -0
  339. package/dist/presentation/cli/commands/help-command.d.ts.map +1 -1
  340. package/dist/presentation/cli/commands/help-command.js +2 -0
  341. package/dist/presentation/cli/commands/help-command.js.map +1 -1
  342. package/dist/presentation/cli/commands/orchestrate-command.d.ts +2 -0
  343. package/dist/presentation/cli/commands/orchestrate-command.d.ts.map +1 -1
  344. package/dist/presentation/cli/commands/orchestrate-command.js +88 -1
  345. package/dist/presentation/cli/commands/orchestrate-command.js.map +1 -1
  346. package/dist/presentation/cli/commands/plan-command.d.ts +1 -0
  347. package/dist/presentation/cli/commands/plan-command.d.ts.map +1 -1
  348. package/dist/presentation/cli/commands/plan-command.js +136 -7
  349. package/dist/presentation/cli/commands/plan-command.js.map +1 -1
  350. package/dist/presentation/cli/commands/product-command.d.ts +12 -0
  351. package/dist/presentation/cli/commands/product-command.d.ts.map +1 -0
  352. package/dist/presentation/cli/commands/product-command.js +188 -0
  353. package/dist/presentation/cli/commands/product-command.js.map +1 -0
  354. package/dist/presentation/cli/commands/react-command.d.ts.map +1 -1
  355. package/dist/presentation/cli/commands/react-command.js +98 -16
  356. package/dist/presentation/cli/commands/react-command.js.map +1 -1
  357. package/dist/presentation/cli/commands/review-command.d.ts +14 -0
  358. package/dist/presentation/cli/commands/review-command.d.ts.map +1 -0
  359. package/dist/presentation/cli/commands/review-command.js +22 -0
  360. package/dist/presentation/cli/commands/review-command.js.map +1 -0
  361. package/dist/presentation/cli/commands/run-command.d.ts +15 -0
  362. package/dist/presentation/cli/commands/run-command.d.ts.map +1 -0
  363. package/dist/presentation/cli/commands/run-command.js +29 -0
  364. package/dist/presentation/cli/commands/run-command.js.map +1 -0
  365. package/dist/presentation/cli/commands/setup-command.d.ts.map +1 -1
  366. package/dist/presentation/cli/commands/setup-command.js +67 -12
  367. package/dist/presentation/cli/commands/setup-command.js.map +1 -1
  368. package/dist/presentation/cli/commands/smart-command.d.ts +3 -1
  369. package/dist/presentation/cli/commands/smart-command.d.ts.map +1 -1
  370. package/dist/presentation/cli/commands/smart-command.js +227 -23
  371. package/dist/presentation/cli/commands/smart-command.js.map +1 -1
  372. package/dist/presentation/cli/commands/status-command.d.ts +11 -0
  373. package/dist/presentation/cli/commands/status-command.d.ts.map +1 -0
  374. package/dist/presentation/cli/commands/status-command.js +176 -0
  375. package/dist/presentation/cli/commands/status-command.js.map +1 -0
  376. package/dist/presentation/cli/commands/suggest-command.d.ts +13 -0
  377. package/dist/presentation/cli/commands/suggest-command.d.ts.map +1 -0
  378. package/dist/presentation/cli/commands/suggest-command.js +25 -0
  379. package/dist/presentation/cli/commands/suggest-command.js.map +1 -0
  380. package/dist/presentation/cli/commands/trace-command.d.ts.map +1 -1
  381. package/dist/presentation/cli/commands/trace-command.js +9 -5
  382. package/dist/presentation/cli/commands/trace-command.js.map +1 -1
  383. package/dist/presentation/cli/commands/undo-command.js +15 -6
  384. package/dist/presentation/cli/commands/undo-command.js.map +1 -1
  385. package/dist/presentation/cli/error-display.d.ts +2 -0
  386. package/dist/presentation/cli/error-display.d.ts.map +1 -1
  387. package/dist/presentation/cli/error-display.js +220 -2
  388. package/dist/presentation/cli/error-display.js.map +1 -1
  389. package/dist/presentation/cli/keyboard-shortcuts.d.ts +27 -0
  390. package/dist/presentation/cli/keyboard-shortcuts.d.ts.map +1 -0
  391. package/dist/presentation/cli/keyboard-shortcuts.js +77 -0
  392. package/dist/presentation/cli/keyboard-shortcuts.js.map +1 -0
  393. package/dist/session.d.ts.map +1 -1
  394. package/dist/session.js +39 -2
  395. package/dist/session.js.map +1 -1
  396. package/dist/ui.d.ts.map +1 -1
  397. package/dist/ui.js +8 -5
  398. package/dist/ui.js.map +1 -1
  399. package/dist/utils/version.js +2 -2
  400. package/dist/verification/backup.d.ts.map +1 -1
  401. package/dist/verification/backup.js +24 -3
  402. package/dist/verification/backup.js.map +1 -1
  403. package/dist/verification/compiler.js +47 -12
  404. package/dist/verification/compiler.js.map +1 -1
  405. package/package.json +10 -2
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Infrastructure: Agent Validation Helper
3
+ * Shared utilities for integrating Validation Layer into agents
4
+ *
5
+ * Provides:
6
+ * - Automatic TraceSummary generation
7
+ * - AgentFeedback recording
8
+ * - Run context tracking
9
+ */
10
+ import { executionTracer } from '../observability/execution-tracer.js';
11
+ import { agentFeedbackManager } from './agent-feedback.js';
12
+ import { traceSummaryFormatter } from './trace-summary.js';
13
+ /**
14
+ * Helper class for agent validation integration
15
+ */
16
+ export class AgentValidationHelper {
17
+ /**
18
+ * Start validation context for an agent operation
19
+ */
20
+ startAgentOperation(agentName, operation, context) {
21
+ const runId = executionTracer.startRun(`${agentName}:${operation}`, {
22
+ query: context?.query,
23
+ codebaseId: context?.codebaseId,
24
+ });
25
+ return {
26
+ runId,
27
+ agentName,
28
+ operation,
29
+ startTime: Date.now(),
30
+ };
31
+ }
32
+ /**
33
+ * Complete agent operation and generate validation artifacts
34
+ */
35
+ async completeAgentOperation(validationContext, result, metadata) {
36
+ // End trace to finalize run context
37
+ executionTracer.endRun();
38
+ // Small delay to ensure file is written
39
+ await new Promise(resolve => setTimeout(resolve, 100));
40
+ // Get finalized run context
41
+ const run = executionTracer.getRun(validationContext.runId);
42
+ const duration = Date.now() - validationContext.startTime;
43
+ // Note: Feedback recording is handled by CLI commands with proper userAction from review decision
44
+ // This helper only creates the validation summary, not the feedback record
45
+ const feedbackId = 'pending-cli-feedback';
46
+ // Create trace summary
47
+ const summary = traceSummaryFormatter.createSummary(run || {
48
+ runId: validationContext.runId,
49
+ startTime: validationContext.startTime,
50
+ endTime: Date.now(),
51
+ operation: validationContext.operation,
52
+ query: metadata.additionalContext?.query,
53
+ codebaseId: metadata.additionalContext?.codebaseId,
54
+ traces: [],
55
+ }, agentFeedbackManager.getFeedbackForRun(validationContext.runId) || undefined, validationContext.agentName);
56
+ // Update summary with metadata if available
57
+ if (metadata.filesChanged) {
58
+ summary.filesChanged = metadata.filesChanged;
59
+ }
60
+ if (metadata.filesCreated) {
61
+ summary.filesCreated = metadata.filesCreated;
62
+ }
63
+ if (metadata.filesDeleted) {
64
+ summary.filesDeleted = metadata.filesDeleted;
65
+ }
66
+ if (metadata.errors) {
67
+ summary.errors = metadata.errors;
68
+ }
69
+ if (metadata.warnings) {
70
+ summary.warnings = metadata.warnings;
71
+ }
72
+ return {
73
+ result,
74
+ summary,
75
+ feedbackId,
76
+ runId: validationContext.runId,
77
+ };
78
+ }
79
+ /**
80
+ * Record a trace during agent operation
81
+ */
82
+ trace(operation) {
83
+ return executionTracer.trace(operation);
84
+ }
85
+ }
86
+ // Singleton instance
87
+ export const agentValidationHelper = new AgentValidationHelper();
88
+ //# sourceMappingURL=agent-validation-helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-validation-helper.js","sourceRoot":"","sources":["../../../src/infrastructure/validation/agent-validation-helper.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAmB3D;;GAEG;AACH,MAAM,OAAO,qBAAqB;IAChC;;OAEG;IACH,mBAAmB,CACjB,SAAiB,EACjB,SAAiB,EACjB,OAGC;QAED,MAAM,KAAK,GAAG,eAAe,CAAC,QAAQ,CAAC,GAAG,SAAS,IAAI,SAAS,EAAE,EAAE;YAClE,KAAK,EAAE,OAAO,EAAE,KAAK;YACrB,UAAU,EAAE,OAAO,EAAE,UAAU;SAChC,CAAC,CAAC;QAEH,OAAO;YACL,KAAK;YACL,SAAS;YACT,SAAS;YACT,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,sBAAsB,CAC1B,iBAAyC,EACzC,MAAS,EACT,QAsBC;QAED,oCAAoC;QACpC,eAAe,CAAC,MAAM,EAAE,CAAC;QAEzB,wCAAwC;QACxC,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO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AI,QAAQ,CAAC,QAAQ,EAAE,CAAC;YACtB,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;QACvC,CAAC;QAED,OAAO;YACL,MAAM;YACN,OAAO;YACP,UAAU;YACV,KAAK,EAAE,iBAAiB,CAAC,KAAK;SAC/B,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,SAQL;QACC,OAAO,eAAe,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IAC1C,CAAC;CACF;AAED,qBAAqB;AACrB,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,qBAAqB,EAAE,CAAC"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Infrastructure: Feedback Statistics Builders
3
+ * Pure functions to compute feedback analytics and status snapshots
4
+ *
5
+ * Clean Architecture: Infrastructure Layer
6
+ * Strategic: Provides machine-readable JSON outputs for CI/dashboards
7
+ */
8
+ import type { TrustConfig } from './trust-config.js';
9
+ export type FeedbackOutcome = 'success' | 'failure' | 'partial_success' | 'cancelled' | 'error';
10
+ export type UserAction = 'approved' | 'rejected' | 'modified' | 'skipped' | 'not_required';
11
+ export interface AgentFeedback {
12
+ feedbackId: string;
13
+ runId: string;
14
+ agentName: string;
15
+ timestamp: number;
16
+ operation: string;
17
+ query?: string;
18
+ outcome: FeedbackOutcome;
19
+ userAction?: UserAction;
20
+ filesChanged?: string[];
21
+ filesCreated?: string[];
22
+ filesDeleted?: string[];
23
+ errors?: string[];
24
+ warnings?: string[];
25
+ validationChecks?: Array<{
26
+ check: string;
27
+ passed: boolean;
28
+ message?: string;
29
+ }>;
30
+ metrics?: {
31
+ tokensUsed?: number;
32
+ duration?: number;
33
+ filesAnalyzed?: number;
34
+ };
35
+ }
36
+ /**
37
+ * JSON output for analyze-feedback script
38
+ */
39
+ export interface FeedbackAnalyticsJson {
40
+ totalRecords: number;
41
+ agents: Array<{
42
+ agentName: string;
43
+ totalRuns: number;
44
+ trustScore: number;
45
+ belowThreshold: boolean;
46
+ threshold: number;
47
+ outcomes: Record<string, number>;
48
+ userActions: Record<string, number>;
49
+ }>;
50
+ operations: Array<{
51
+ operation: string;
52
+ count: number;
53
+ outcomes: Record<string, number>;
54
+ }>;
55
+ }
56
+ /**
57
+ * JSON output for status command
58
+ */
59
+ export interface StatusSnapshotJson {
60
+ totalRecords: number;
61
+ agents: Array<{
62
+ agentName: string;
63
+ success: {
64
+ runs: number;
65
+ total: number;
66
+ };
67
+ trustScore: number;
68
+ threshold: number;
69
+ belowThreshold: boolean;
70
+ }>;
71
+ operations: Array<{
72
+ operation: string;
73
+ runs: number;
74
+ }>;
75
+ }
76
+ /**
77
+ * Build feedback analytics JSON from feedback records and trust config
78
+ */
79
+ export declare function buildFeedbackAnalyticsJson(feedback: AgentFeedback[], trustConfig: TrustConfig): FeedbackAnalyticsJson;
80
+ /**
81
+ * Build status snapshot JSON from feedback records and trust config
82
+ */
83
+ export declare function buildStatusSnapshotJson(feedback: AgentFeedback[], trustConfig: TrustConfig): StatusSnapshotJson;
84
+ /**
85
+ * Result of trust threshold evaluation
86
+ */
87
+ export interface TrustCheckResult {
88
+ offenders: Array<{
89
+ agentName: string;
90
+ trustScore: number;
91
+ threshold: number;
92
+ }>;
93
+ }
94
+ /**
95
+ * Evaluate trust thresholds from analytics JSON
96
+ * Returns agents that are below their configured thresholds
97
+ */
98
+ export declare function evaluateTrustThresholds(analytics: FeedbackAnalyticsJson): TrustCheckResult;
99
+ //# sourceMappingURL=feedback-stats.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feedback-stats.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/validation/feedback-stats.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,SAAS,GAAG,iBAAiB,GAAG,WAAW,GAAG,OAAO,CAAC;AAChG,MAAM,MAAM,UAAU,GAA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CAAC;IACH,UAAU,EAAE,KAAK,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAClC,CAAC,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,KAAK,CAAC;QACZ,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE;YACP,IAAI,EAAE,MAAM,CAAC;YACb,KAAK,EAAE,MAAM,CAAC;SACf,CAAC;QACF,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,cAAc,EAAE,OAAO,CAAC;KACzB,CAAC,CAAC;IACH,UAAU,EAAE,KAAK,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;CACJ;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,aAAa,EAAE,EACzB,WAAW,EAAE,WAAW,GACvB,qBAAqB,CAwGvB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,aAAa,EAAE,EACzB,WAAW,EAAE,WAAW,GACvB,kBAAkB,CAwEpB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,KAAK,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;QAClB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;CACJ;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,qBAAqB,GAAG,gBAAgB,CAmB1F"}
@@ -0,0 +1,173 @@
1
+ /**
2
+ * Infrastructure: Feedback Statistics Builders
3
+ * Pure functions to compute feedback analytics and status snapshots
4
+ *
5
+ * Clean Architecture: Infrastructure Layer
6
+ * Strategic: Provides machine-readable JSON outputs for CI/dashboards
7
+ */
8
+ import { getAgentThreshold } from './trust-config.js';
9
+ /**
10
+ * Build feedback analytics JSON from feedback records and trust config
11
+ */
12
+ export function buildFeedbackAnalyticsJson(feedback, trustConfig) {
13
+ const byAgent = {};
14
+ const byOperationMap = {};
15
+ // Aggregate feedback
16
+ for (const record of feedback) {
17
+ // Aggregate by agent
18
+ if (!byAgent[record.agentName]) {
19
+ byAgent[record.agentName] = {
20
+ totalRuns: 0,
21
+ outcomes: {
22
+ success: 0,
23
+ failure: 0,
24
+ partial_success: 0,
25
+ cancelled: 0,
26
+ error: 0,
27
+ },
28
+ userActions: {
29
+ approved: 0,
30
+ rejected: 0,
31
+ modified: 0,
32
+ skipped: 0,
33
+ not_required: 0,
34
+ },
35
+ };
36
+ }
37
+ const agentStats = byAgent[record.agentName];
38
+ agentStats.totalRuns++;
39
+ agentStats.outcomes[record.outcome] = (agentStats.outcomes[record.outcome] || 0) + 1;
40
+ if (record.userAction) {
41
+ agentStats.userActions[record.userAction] =
42
+ (agentStats.userActions[record.userAction] || 0) + 1;
43
+ }
44
+ // Aggregate by operation
45
+ if (record.operation) {
46
+ if (!byOperationMap[record.operation]) {
47
+ byOperationMap[record.operation] = {
48
+ operation: record.operation,
49
+ count: 0,
50
+ outcomes: {
51
+ success: 0,
52
+ failure: 0,
53
+ partial_success: 0,
54
+ cancelled: 0,
55
+ error: 0,
56
+ },
57
+ };
58
+ }
59
+ const opStats = byOperationMap[record.operation];
60
+ opStats.count++;
61
+ opStats.outcomes[record.outcome] = (opStats.outcomes[record.outcome] || 0) + 1;
62
+ }
63
+ }
64
+ // Calculate trust scores and build agent array
65
+ const agents = Object.entries(byAgent)
66
+ .map(([agentName, stats]) => {
67
+ const approvedSuccessRuns = feedback.filter(f => f.agentName === agentName &&
68
+ f.outcome === 'success' &&
69
+ f.userAction === 'approved').length;
70
+ const trustScore = stats.totalRuns > 0
71
+ ? (approvedSuccessRuns / stats.totalRuns) * 100
72
+ : 0;
73
+ const threshold = getAgentThreshold(trustConfig, agentName);
74
+ const belowThreshold = threshold > 0 && trustScore < threshold;
75
+ return {
76
+ agentName,
77
+ totalRuns: stats.totalRuns,
78
+ trustScore: Math.round(trustScore * 100) / 100, // Round to 2 decimal places
79
+ belowThreshold,
80
+ threshold,
81
+ outcomes: stats.outcomes,
82
+ userActions: stats.userActions,
83
+ };
84
+ })
85
+ .sort((a, b) => b.totalRuns - a.totalRuns);
86
+ // Build operations array
87
+ const operations = Object.values(byOperationMap)
88
+ .sort((a, b) => b.count - a.count);
89
+ return {
90
+ totalRecords: feedback.length,
91
+ agents,
92
+ operations,
93
+ };
94
+ }
95
+ /**
96
+ * Build status snapshot JSON from feedback records and trust config
97
+ */
98
+ export function buildStatusSnapshotJson(feedback, trustConfig) {
99
+ const agentStatsMap = {};
100
+ const operationStatsMap = {};
101
+ // Aggregate feedback
102
+ for (const record of feedback) {
103
+ // Aggregate by agent
104
+ if (!agentStatsMap[record.agentName]) {
105
+ agentStatsMap[record.agentName] = {
106
+ totalRuns: 0,
107
+ successRuns: 0,
108
+ trustScore: 0,
109
+ };
110
+ }
111
+ const stats = agentStatsMap[record.agentName];
112
+ stats.totalRuns++;
113
+ if (record.outcome === 'success') {
114
+ stats.successRuns++;
115
+ }
116
+ // Aggregate by operation
117
+ if (record.operation) {
118
+ operationStatsMap[record.operation] = (operationStatsMap[record.operation] || 0) + 1;
119
+ }
120
+ }
121
+ // Calculate trust scores and build agent array
122
+ const agents = Object.entries(agentStatsMap)
123
+ .map(([agentName, stats]) => {
124
+ const approvedSuccessRuns = feedback.filter(f => f.agentName === agentName &&
125
+ f.outcome === 'success' &&
126
+ f.userAction === 'approved').length;
127
+ const trustScore = stats.totalRuns > 0
128
+ ? (approvedSuccessRuns / stats.totalRuns) * 100
129
+ : 0;
130
+ const threshold = getAgentThreshold(trustConfig, agentName);
131
+ const belowThreshold = threshold > 0 && trustScore < threshold;
132
+ return {
133
+ agentName,
134
+ success: {
135
+ runs: stats.successRuns,
136
+ total: stats.totalRuns,
137
+ },
138
+ trustScore: Math.round(trustScore * 100) / 100, // Round to 2 decimal places
139
+ threshold,
140
+ belowThreshold,
141
+ };
142
+ })
143
+ .sort((a, b) => b.trustScore - a.trustScore);
144
+ // Build operations array
145
+ const operations = Object.entries(operationStatsMap)
146
+ .map(([operation, runs]) => ({ operation, runs }))
147
+ .sort((a, b) => b.runs - a.runs)
148
+ .slice(0, 5); // Top 5 operations
149
+ return {
150
+ totalRecords: feedback.length,
151
+ agents,
152
+ operations,
153
+ };
154
+ }
155
+ /**
156
+ * Evaluate trust thresholds from analytics JSON
157
+ * Returns agents that are below their configured thresholds
158
+ */
159
+ export function evaluateTrustThresholds(analytics) {
160
+ const offenders = [];
161
+ for (const agent of analytics.agents) {
162
+ // Only consider agents with threshold > 0
163
+ if (agent.threshold > 0 && agent.trustScore < agent.threshold) {
164
+ offenders.push({
165
+ agentName: agent.agentName,
166
+ trustScore: agent.trustScore,
167
+ threshold: agent.threshold,
168
+ });
169
+ }
170
+ }
171
+ return { offenders };
172
+ }
173
+ //# sourceMappingURL=feedback-stats.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"feedback-stats.js","sourceRoot":"","sources":["../../../src/infrastructure/validation/feedback-stats.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAyEtD;;GAEG;AACH,MAAM,UAAU,0BAA0B,CACxC,QAAyB,EACzB,WAAwB;IAExB,MAAM,OAAO,GAIR,EAAE,CAAC;IAER,MAAM,cAAc,GAIf,EAAE,CAAC;IAER,qBAAqB;IACrB,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC9B,qBAAqB;QACrB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;YAC/B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG;gBAC1B,SAAS,EAAE,CAAC;g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AI,GAAG,CAAC,CAAC,IAAI,CAAC;SAC/B,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,mBAAmB;IAEnC,OAAO;QACL,YAAY,EAAE,QAAQ,CAAC,MAAM;QAC7B,MAAM;QACN,UAAU;KACX,CAAC;AACJ,CAAC;AAaD;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,SAAgC;IACtE,MAAM,SAAS,GAIV,EAAE,CAAC;IAER,KAAK,MAAM,KAAK,IAAI,SAAS,CAAC,MAAM,EAAE,CAAC;QACrC,0CAA0C;QAC1C,IAAI,KAAK,CAAC,SAAS,GAAG,CAAC,IAAI,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;YAC9D,SAAS,CAAC,IAAI,CAAC;gBACb,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,UAAU,EAAE,KAAK,CAAC,UAAU;gBAC5B,SAAS,EAAE,KAAK,CAAC,SAAS;aAC3B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,CAAC;AACvB,CAAC"}
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Infrastructure: Review Handler
3
+ * Handles --review flag behavior: pause, display summary, ask yes/no
4
+ */
5
+ import type { TraceSummary } from './trace-summary.js';
6
+ export interface ReviewDecision {
7
+ approved: boolean;
8
+ proceed: boolean;
9
+ reason?: string;
10
+ userAction: 'approved' | 'rejected' | 'not_required';
11
+ }
12
+ /**
13
+ * Review Handler
14
+ * Manages the review flow when --review flag is enabled
15
+ */
16
+ export declare class ReviewHandler {
17
+ /**
18
+ * Request user review before proceeding
19
+ */
20
+ requestReview(summary: TraceSummary, options?: {
21
+ timeout?: number;
22
+ defaultAction?: 'approve' | 'reject';
23
+ }): Promise<ReviewDecision>;
24
+ /**
25
+ * Prompt user for approval (yes/no)
26
+ */
27
+ private promptApproval;
28
+ /**
29
+ * Check if review should be required based on summary
30
+ */
31
+ shouldRequireReview(summary: TraceSummary): boolean;
32
+ /**
33
+ * Get review decision - single source of truth for userAction
34
+ *
35
+ * This method is the ONLY place where userAction is determined.
36
+ * All CLI commands must use this method and trust its userAction value.
37
+ *
38
+ * Logic:
39
+ * 1. If reviewRequested === false:
40
+ * → userAction = 'not_required'
41
+ *
42
+ * 2. If reviewRequested === true and shouldReview === false:
43
+ * → userAction = 'approved' (user explicitly requested review, treat as approved)
44
+ *
45
+ * 3. If reviewRequested === true and shouldReview === true:
46
+ * → Call requestReview() which handles:
47
+ * - Interactive mode: prompt user, return 'approved' or 'rejected'
48
+ * - Non-interactive + auto-approve: return 'approved'
49
+ * - Non-interactive + no auto-approve: return 'rejected'
50
+ */
51
+ getReviewDecision(summary: TraceSummary, reviewRequested: boolean): Promise<ReviewDecision>;
52
+ }
53
+ export declare const reviewHandler: ReviewHandler;
54
+ //# sourceMappingURL=review-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review-handler.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/validation/review-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGvD,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,GAAG,UAAU,GAAG,cAAc,CAAC;CACtD;AAED;;;GAGG;AACH,qBAAa,aAAa;IACxB;;OAEG;IACG,aAAa,CACjB,OAAO,EAAE,YAAY,EACrB,OAAO,GAAE;QACP,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,aAAa,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;KACjC,GACL,OAAO,CAAC,cAAc,CAAC;IAkE1B;;OAEG;YACW,cAAc;IAmE5B;;OAEG;IACH,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO;IAwBnD;;;;;;;;;;;;;;;;;;OAkBG;IACG,iBAAiB,CACrB,OAAO,EAAE,YAAY,EACrB,eAAe,EAAE,OAAO,GACvB,OAAO,CAAC,cAAc,CAAC;CAiC3B;AAGD,eAAO,MAAM,aAAa,eAAsB,CAAC"}
@@ -0,0 +1,206 @@
1
+ /**
2
+ * Infrastructure: Review Handler
3
+ * Handles --review flag behavior: pause, display summary, ask yes/no
4
+ */
5
+ import * as readline from 'readline';
6
+ import { colors, newline, separator } from '../../ui.js';
7
+ import { traceSummaryFormatter } from './trace-summary.js';
8
+ /**
9
+ * Review Handler
10
+ * Manages the review flow when --review flag is enabled
11
+ */
12
+ export class ReviewHandler {
13
+ /**
14
+ * Request user review before proceeding
15
+ */
16
+ async requestReview(summary, options = {}) {
17
+ // TODO: Update task review metadata
18
+ // When review is requested: set task.reviewStatus = PENDING
19
+ // When review is completed: set task.reviewStatus, task.reviewedAt, task.reviewComments
20
+ // Update task.status: NEEDS_REVIEW → APPROVED/REJECTED
21
+ // See: docs/ARCHITECTURE/TASK_MODEL.md
22
+ // Display summary
23
+ const summaryText = traceSummaryFormatter.formatSummary(summary);
24
+ console.log('\n' + summaryText);
25
+ newline();
26
+ // Check if we should skip review in non-interactive mode
27
+ if (!process.stdin.isTTY) {
28
+ const autoApprove = process.env.CODEHERE_AUTO_APPROVE === 'true' ||
29
+ process.env.CODEHERE_REVIEW_SKIP === 'true';
30
+ if (autoApprove) {
31
+ console.log(colors.yellow('⚠️ Non-interactive mode: Auto-approving changes (CODEHERE_AUTO_APPROVE=true)'));
32
+ return {
33
+ approved: true,
34
+ proceed: true,
35
+ reason: 'auto-approved (non-interactive mode)',
36
+ userAction: 'approved',
37
+ };
38
+ }
39
+ console.log(colors.red('❌ Non-interactive mode: Review required but cannot prompt for input.'));
40
+ console.log(colors.yellow(' Set CODEHERE_AUTO_APPROVE=true to auto-approve, or run in interactive mode.'));
41
+ return {
42
+ approved: false,
43
+ proceed: false,
44
+ reason: 'non-interactive mode, review required',
45
+ userAction: 'rejected',
46
+ };
47
+ }
48
+ // Prompt for approval
49
+ console.log(separator('─', 80));
50
+ console.log(colors.bold('Review Required'));
51
+ console.log(separator('─', 80));
52
+ if (summary.reviewNeeded.riskLevel) {
53
+ const riskColor = {
54
+ low: colors.cyan,
55
+ medium: colors.yellow,
56
+ high: colors.red,
57
+ critical: colors.red.bold,
58
+ }[summary.reviewNeeded.riskLevel];
59
+ console.log(riskColor(`Risk Level: ${summary.reviewNeeded.riskLevel.toUpperCase()}`));
60
+ newline();
61
+ }
62
+ const decision = await this.promptApproval(options.timeout || 0, options.defaultAction);
63
+ newline();
64
+ if (decision.approved) {
65
+ console.log(colors.green('✓ Changes approved. Proceeding...'));
66
+ }
67
+ else {
68
+ console.log(colors.red('✗ Changes rejected. Cancelling operation.'));
69
+ }
70
+ return decision;
71
+ }
72
+ /**
73
+ * Prompt user for approval (yes/no)
74
+ */
75
+ async promptApproval(timeout = 0, defaultAction) {
76
+ return new Promise((resolve) => {
77
+ const rl = readline.createInterface({
78
+ input: process.stdin,
79
+ output: process.stdout,
80
+ });
81
+ const prompt = () => {
82
+ rl.question(colors.bold('Proceed with these changes? (yes/no): '), (answer) => {
83
+ rl.close();
84
+ const normalized = answer.trim().toLowerCase();
85
+ if (normalized === 'yes' || normalized === 'y') {
86
+ resolve({
87
+ approved: true,
88
+ proceed: true,
89
+ userAction: 'approved',
90
+ });
91
+ }
92
+ else if (normalized === 'no' || normalized === 'n') {
93
+ resolve({
94
+ approved: false,
95
+ proceed: false,
96
+ reason: 'user rejected',
97
+ userAction: 'rejected',
98
+ });
99
+ }
100
+ else {
101
+ // Invalid input, ask again
102
+ console.log(colors.yellow('Please enter "yes" or "no"'));
103
+ prompt();
104
+ }
105
+ });
106
+ };
107
+ // Handle timeout
108
+ if (timeout > 0) {
109
+ setTimeout(() => {
110
+ if (rl) {
111
+ rl.close();
112
+ }
113
+ const action = defaultAction || 'reject';
114
+ resolve({
115
+ approved: action === 'approve',
116
+ proceed: action === 'approve',
117
+ reason: `timeout (default: ${action})`,
118
+ userAction: action === 'approve' ? 'approved' : 'rejected',
119
+ });
120
+ if (action === 'approve') {
121
+ console.log(colors.yellow(`\n⏱ Timeout: Auto-approving (default action: ${action})`));
122
+ }
123
+ else {
124
+ console.log(colors.yellow(`\n⏱ Timeout: Auto-rejecting (default action: ${action})`));
125
+ }
126
+ }, timeout);
127
+ }
128
+ prompt();
129
+ });
130
+ }
131
+ /**
132
+ * Check if review should be required based on summary
133
+ */
134
+ shouldRequireReview(summary) {
135
+ // Always require review if explicitly flagged
136
+ if (summary.reviewNeeded.required) {
137
+ return true;
138
+ }
139
+ // Require review for high/critical risk
140
+ if (summary.reviewNeeded.riskLevel === 'high' || summary.reviewNeeded.riskLevel === 'critical') {
141
+ return true;
142
+ }
143
+ // Require review if files changed
144
+ if (summary.filesChanged.length > 0 || summary.filesCreated.length > 0) {
145
+ return true;
146
+ }
147
+ // Require review if errors occurred
148
+ if (summary.errors && summary.errors.length > 0) {
149
+ return true;
150
+ }
151
+ return false;
152
+ }
153
+ /**
154
+ * Get review decision - single source of truth for userAction
155
+ *
156
+ * This method is the ONLY place where userAction is determined.
157
+ * All CLI commands must use this method and trust its userAction value.
158
+ *
159
+ * Logic:
160
+ * 1. If reviewRequested === false:
161
+ * → userAction = 'not_required'
162
+ *
163
+ * 2. If reviewRequested === true and shouldReview === false:
164
+ * → userAction = 'approved' (user explicitly requested review, treat as approved)
165
+ *
166
+ * 3. If reviewRequested === true and shouldReview === true:
167
+ * → Call requestReview() which handles:
168
+ * - Interactive mode: prompt user, return 'approved' or 'rejected'
169
+ * - Non-interactive + auto-approve: return 'approved'
170
+ * - Non-interactive + no auto-approve: return 'rejected'
171
+ */
172
+ async getReviewDecision(summary, reviewRequested) {
173
+ // Case 1: Review not requested → not_required
174
+ if (!reviewRequested) {
175
+ return {
176
+ approved: true,
177
+ proceed: true,
178
+ userAction: 'not_required',
179
+ };
180
+ }
181
+ // Case 2 & 3: Review was requested - check if it's actually required
182
+ const shouldReview = this.shouldRequireReview(summary);
183
+ if (shouldReview) {
184
+ // Case 3: Review is required - call requestReview which handles auto-approve
185
+ return await this.requestReview(summary);
186
+ }
187
+ else {
188
+ // Case 2: Review was requested but not required (e.g., no file changes)
189
+ // User explicitly passed --review, so treat as approved
190
+ // Note: autoApprove is checked here for logging purposes, but userAction is always 'approved'
191
+ const autoApprove = process.env.CODEHERE_AUTO_APPROVE === 'true' ||
192
+ process.env.CODEHERE_REVIEW_SKIP === 'true';
193
+ return {
194
+ approved: true,
195
+ proceed: true,
196
+ reason: autoApprove
197
+ ? 'review requested but not required, auto-approved'
198
+ : 'review requested but not required',
199
+ userAction: 'approved',
200
+ };
201
+ }
202
+ }
203
+ }
204
+ // Singleton instance
205
+ export const reviewHandler = new ReviewHandler();
206
+ //# sourceMappingURL=review-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"review-handler.js","sourceRoot":"","sources":["../../../src/infrastructure/validation/review-handler.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,QAAQ,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAEzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAS3D;;;GAGG;AACH,MAAM,OAAO,aAAa;IACxB;;OAEG;IACH,KAAK,CAAC,aAAa,CACjB,OAAqB,EACrB,UAGI,EAAE;QAEN,oCAAoC;QACpC,4DAA4D;QAC5D,wFAAwF;QACxF,uDAAuD;QACvD,uCAAuC;QACvC,kBAAkB;QAClB,MAAM,WAAW,GAAG,qBAAqB,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACjE,OAAO,CAAC,GAAG,CAAC,IAAI,GAAG,WAAW,CAAC,CAAC;QAChC,OAAO,EAAE,CAAC;QAEV,yDAAyD;QACzD,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACzB,MAAM,WAA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