@backendkit-labs/agent-coding 0.28.5 → 0.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (288) hide show
  1. package/dist/__tests__/context-hooks.test.d.ts +2 -0
  2. package/dist/__tests__/context-hooks.test.d.ts.map +1 -0
  3. package/dist/__tests__/context-hooks.test.js +21 -0
  4. package/dist/__tests__/context-hooks.test.js.map +1 -0
  5. package/dist/__tests__/sandbox.test.js +1 -1
  6. package/dist/__tests__/sandbox.test.js.map +1 -1
  7. package/dist/context-hooks.d.ts +11 -0
  8. package/dist/context-hooks.d.ts.map +1 -0
  9. package/dist/context-hooks.js +23 -0
  10. package/dist/context-hooks.js.map +1 -0
  11. package/dist/context-services.d.ts +12 -0
  12. package/dist/context-services.d.ts.map +1 -0
  13. package/dist/context-services.js +20 -0
  14. package/dist/context-services.js.map +1 -0
  15. package/dist/index.d.ts +5 -1
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +21 -8
  18. package/dist/index.js.map +1 -1
  19. package/dist/orchestration/capability-matrix.d.ts +1 -1
  20. package/dist/orchestration/capability-matrix.d.ts.map +1 -1
  21. package/dist/pipeline/__tests__/AgentEngine.orchestratorFailure.test.d.ts +2 -0
  22. package/dist/pipeline/__tests__/AgentEngine.orchestratorFailure.test.d.ts.map +1 -0
  23. package/dist/pipeline/__tests__/AgentEngine.orchestratorFailure.test.js +42 -0
  24. package/dist/pipeline/__tests__/AgentEngine.orchestratorFailure.test.js.map +1 -0
  25. package/dist/pipeline/__tests__/coding-pipeline-hooks.test.d.ts +2 -0
  26. package/dist/pipeline/__tests__/coding-pipeline-hooks.test.d.ts.map +1 -0
  27. package/dist/pipeline/__tests__/coding-pipeline-hooks.test.js +64 -0
  28. package/dist/pipeline/__tests__/coding-pipeline-hooks.test.js.map +1 -0
  29. package/dist/pipeline/__tests__/engine-brief.test.d.ts +2 -0
  30. package/dist/pipeline/__tests__/engine-brief.test.d.ts.map +1 -0
  31. package/dist/pipeline/__tests__/engine-brief.test.js +159 -0
  32. package/dist/pipeline/__tests__/engine-brief.test.js.map +1 -0
  33. package/dist/pipeline/__tests__/qa-orchestrator.test.d.ts +2 -0
  34. package/dist/pipeline/__tests__/qa-orchestrator.test.d.ts.map +1 -0
  35. package/dist/pipeline/__tests__/qa-orchestrator.test.js +276 -0
  36. package/dist/pipeline/__tests__/qa-orchestrator.test.js.map +1 -0
  37. package/dist/pipeline/coding-pipeline-hooks.d.ts +28 -0
  38. package/dist/pipeline/coding-pipeline-hooks.d.ts.map +1 -0
  39. package/dist/pipeline/coding-pipeline-hooks.js +91 -0
  40. package/dist/pipeline/coding-pipeline-hooks.js.map +1 -0
  41. package/dist/pipeline/index.d.ts +13 -0
  42. package/dist/pipeline/index.d.ts.map +1 -0
  43. package/dist/pipeline/index.js +44 -0
  44. package/dist/pipeline/index.js.map +1 -0
  45. package/dist/pipeline/orchestration/__tests__/agent-id-consistency.test.d.ts +11 -0
  46. package/dist/pipeline/orchestration/__tests__/agent-id-consistency.test.d.ts.map +1 -0
  47. package/dist/pipeline/orchestration/__tests__/agent-id-consistency.test.js +105 -0
  48. package/dist/pipeline/orchestration/__tests__/agent-id-consistency.test.js.map +1 -0
  49. package/dist/pipeline/orchestration/__tests__/fsm-commit-skipped.test.d.ts +2 -0
  50. package/dist/pipeline/orchestration/__tests__/fsm-commit-skipped.test.d.ts.map +1 -0
  51. package/dist/pipeline/orchestration/__tests__/fsm-commit-skipped.test.js +21 -0
  52. package/dist/pipeline/orchestration/__tests__/fsm-commit-skipped.test.js.map +1 -0
  53. package/dist/pipeline/orchestration/__tests__/fsm-critical-path.test.d.ts +9 -0
  54. package/dist/pipeline/orchestration/__tests__/fsm-critical-path.test.d.ts.map +1 -0
  55. package/dist/pipeline/orchestration/__tests__/fsm-critical-path.test.js +101 -0
  56. package/dist/pipeline/orchestration/__tests__/fsm-critical-path.test.js.map +1 -0
  57. package/dist/pipeline/orchestration/__tests__/fsm-rework-and-regression.test.d.ts +2 -0
  58. package/dist/pipeline/orchestration/__tests__/fsm-rework-and-regression.test.d.ts.map +1 -0
  59. package/dist/pipeline/orchestration/__tests__/fsm-rework-and-regression.test.js +54 -0
  60. package/dist/pipeline/orchestration/__tests__/fsm-rework-and-regression.test.js.map +1 -0
  61. package/dist/pipeline/orchestration/__tests__/intent-detector-llm.test.d.ts +2 -0
  62. package/dist/pipeline/orchestration/__tests__/intent-detector-llm.test.d.ts.map +1 -0
  63. package/dist/pipeline/orchestration/__tests__/intent-detector-llm.test.js +57 -0
  64. package/dist/pipeline/orchestration/__tests__/intent-detector-llm.test.js.map +1 -0
  65. package/dist/pipeline/orchestration/__tests__/intent-detector-scores.test.d.ts +9 -0
  66. package/dist/pipeline/orchestration/__tests__/intent-detector-scores.test.d.ts.map +1 -0
  67. package/dist/pipeline/orchestration/__tests__/intent-detector-scores.test.js +43 -0
  68. package/dist/pipeline/orchestration/__tests__/intent-detector-scores.test.js.map +1 -0
  69. package/dist/pipeline/orchestration/__tests__/reflection-cycle.test.d.ts +10 -0
  70. package/dist/pipeline/orchestration/__tests__/reflection-cycle.test.d.ts.map +1 -0
  71. package/dist/pipeline/orchestration/__tests__/reflection-cycle.test.js +264 -0
  72. package/dist/pipeline/orchestration/__tests__/reflection-cycle.test.js.map +1 -0
  73. package/dist/pipeline/orchestration/audit/audit-ci-blocker.d.ts +31 -0
  74. package/dist/pipeline/orchestration/audit/audit-ci-blocker.d.ts.map +1 -0
  75. package/dist/pipeline/orchestration/audit/audit-ci-blocker.js +120 -0
  76. package/dist/pipeline/orchestration/audit/audit-ci-blocker.js.map +1 -0
  77. package/dist/pipeline/orchestration/audit/audit-finding-tracer.d.ts +33 -0
  78. package/dist/pipeline/orchestration/audit/audit-finding-tracer.d.ts.map +1 -0
  79. package/dist/pipeline/orchestration/audit/audit-finding-tracer.js +126 -0
  80. package/dist/pipeline/orchestration/audit/audit-finding-tracer.js.map +1 -0
  81. package/dist/pipeline/orchestration/audit/audit-lessons-learned.d.ts +27 -0
  82. package/dist/pipeline/orchestration/audit/audit-lessons-learned.d.ts.map +1 -0
  83. package/dist/pipeline/orchestration/audit/audit-lessons-learned.js +155 -0
  84. package/dist/pipeline/orchestration/audit/audit-lessons-learned.js.map +1 -0
  85. package/dist/pipeline/orchestration/audit/audit-pending-issues.d.ts +21 -0
  86. package/dist/pipeline/orchestration/audit/audit-pending-issues.d.ts.map +1 -0
  87. package/dist/pipeline/orchestration/audit/audit-pending-issues.js +110 -0
  88. package/dist/pipeline/orchestration/audit/audit-pending-issues.js.map +1 -0
  89. package/dist/pipeline/orchestration/audit/audit-reflection-bridge.d.ts +39 -0
  90. package/dist/pipeline/orchestration/audit/audit-reflection-bridge.d.ts.map +1 -0
  91. package/dist/pipeline/orchestration/audit/audit-reflection-bridge.js +65 -0
  92. package/dist/pipeline/orchestration/audit/audit-reflection-bridge.js.map +1 -0
  93. package/dist/pipeline/orchestration/audit/audit-report-renderer.d.ts +30 -0
  94. package/dist/pipeline/orchestration/audit/audit-report-renderer.d.ts.map +1 -0
  95. package/dist/pipeline/orchestration/audit/audit-report-renderer.js +249 -0
  96. package/dist/pipeline/orchestration/audit/audit-report-renderer.js.map +1 -0
  97. package/dist/pipeline/orchestration/audit/audit-report-version-manager.d.ts +52 -0
  98. package/dist/pipeline/orchestration/audit/audit-report-version-manager.d.ts.map +1 -0
  99. package/dist/pipeline/orchestration/audit/audit-report-version-manager.js +144 -0
  100. package/dist/pipeline/orchestration/audit/audit-report-version-manager.js.map +1 -0
  101. package/dist/pipeline/orchestration/audit/audit-silent-gates-buffer.d.ts +37 -0
  102. package/dist/pipeline/orchestration/audit/audit-silent-gates-buffer.d.ts.map +1 -0
  103. package/dist/pipeline/orchestration/audit/audit-silent-gates-buffer.js +129 -0
  104. package/dist/pipeline/orchestration/audit/audit-silent-gates-buffer.js.map +1 -0
  105. package/dist/pipeline/orchestration/audit/index.d.ts +17 -0
  106. package/dist/pipeline/orchestration/audit/index.d.ts.map +1 -0
  107. package/dist/pipeline/orchestration/audit/index.js +26 -0
  108. package/dist/pipeline/orchestration/audit/index.js.map +1 -0
  109. package/dist/pipeline/orchestration/audit/types.d.ts +79 -0
  110. package/dist/pipeline/orchestration/audit/types.d.ts.map +1 -0
  111. package/dist/pipeline/orchestration/audit/types.js +10 -0
  112. package/dist/pipeline/orchestration/audit/types.js.map +1 -0
  113. package/dist/pipeline/orchestration/audit-reporter.d.ts +133 -0
  114. package/dist/pipeline/orchestration/audit-reporter.d.ts.map +1 -0
  115. package/dist/pipeline/orchestration/audit-reporter.js +322 -0
  116. package/dist/pipeline/orchestration/audit-reporter.js.map +1 -0
  117. package/dist/pipeline/orchestration/config-loader.d.ts +51 -0
  118. package/dist/pipeline/orchestration/config-loader.d.ts.map +1 -0
  119. package/dist/pipeline/orchestration/config-loader.js +215 -0
  120. package/dist/pipeline/orchestration/config-loader.js.map +1 -0
  121. package/dist/pipeline/orchestration/domain-detector.d.ts +36 -0
  122. package/dist/pipeline/orchestration/domain-detector.d.ts.map +1 -0
  123. package/dist/pipeline/orchestration/domain-detector.js +157 -0
  124. package/dist/pipeline/orchestration/domain-detector.js.map +1 -0
  125. package/dist/pipeline/orchestration/fsm.d.ts +92 -0
  126. package/dist/pipeline/orchestration/fsm.d.ts.map +1 -0
  127. package/dist/pipeline/orchestration/fsm.js +243 -0
  128. package/dist/pipeline/orchestration/fsm.js.map +1 -0
  129. package/dist/pipeline/orchestration/gate-resolver.d.ts +52 -0
  130. package/dist/pipeline/orchestration/gate-resolver.d.ts.map +1 -0
  131. package/dist/pipeline/orchestration/gate-resolver.js +120 -0
  132. package/dist/pipeline/orchestration/gate-resolver.js.map +1 -0
  133. package/dist/pipeline/orchestration/index.d.ts +16 -0
  134. package/dist/pipeline/orchestration/index.d.ts.map +1 -0
  135. package/dist/pipeline/orchestration/index.js +32 -0
  136. package/dist/pipeline/orchestration/index.js.map +1 -0
  137. package/dist/pipeline/orchestration/intent-detector.d.ts +37 -0
  138. package/dist/pipeline/orchestration/intent-detector.d.ts.map +1 -0
  139. package/dist/pipeline/orchestration/intent-detector.js +248 -0
  140. package/dist/pipeline/orchestration/intent-detector.js.map +1 -0
  141. package/dist/pipeline/orchestration/keyword-match.d.ts +17 -0
  142. package/dist/pipeline/orchestration/keyword-match.d.ts.map +1 -0
  143. package/dist/pipeline/orchestration/keyword-match.js +26 -0
  144. package/dist/pipeline/orchestration/keyword-match.js.map +1 -0
  145. package/dist/pipeline/orchestration/orchestrator.d.ts +158 -0
  146. package/dist/pipeline/orchestration/orchestrator.d.ts.map +1 -0
  147. package/dist/pipeline/orchestration/orchestrator.js +414 -0
  148. package/dist/pipeline/orchestration/orchestrator.js.map +1 -0
  149. package/dist/pipeline/orchestration/policy-engine.d.ts +54 -0
  150. package/dist/pipeline/orchestration/policy-engine.d.ts.map +1 -0
  151. package/dist/pipeline/orchestration/policy-engine.js +278 -0
  152. package/dist/pipeline/orchestration/policy-engine.js.map +1 -0
  153. package/dist/pipeline/orchestration/risk-scorer.d.ts +38 -0
  154. package/dist/pipeline/orchestration/risk-scorer.d.ts.map +1 -0
  155. package/dist/pipeline/orchestration/risk-scorer.js +145 -0
  156. package/dist/pipeline/orchestration/risk-scorer.js.map +1 -0
  157. package/dist/pipeline/orchestration/task-context.d.ts +205 -0
  158. package/dist/pipeline/orchestration/task-context.d.ts.map +1 -0
  159. package/dist/pipeline/orchestration/task-context.js +162 -0
  160. package/dist/pipeline/orchestration/task-context.js.map +1 -0
  161. package/dist/pipeline/orchestration/types.d.ts +111 -0
  162. package/dist/pipeline/orchestration/types.d.ts.map +1 -0
  163. package/dist/pipeline/orchestration/types.js +37 -0
  164. package/dist/pipeline/orchestration/types.js.map +1 -0
  165. package/dist/pipeline/qa/__tests__/QAService.test.d.ts +2 -0
  166. package/dist/pipeline/qa/__tests__/QAService.test.d.ts.map +1 -0
  167. package/dist/pipeline/qa/__tests__/QAService.test.js +170 -0
  168. package/dist/pipeline/qa/__tests__/QAService.test.js.map +1 -0
  169. package/dist/pipeline/qa/__tests__/QAService.verdict.test.d.ts +2 -0
  170. package/dist/pipeline/qa/__tests__/QAService.verdict.test.d.ts.map +1 -0
  171. package/dist/pipeline/qa/__tests__/QAService.verdict.test.js +39 -0
  172. package/dist/pipeline/qa/__tests__/QAService.verdict.test.js.map +1 -0
  173. package/dist/pipeline/qa/index.d.ts +3 -0
  174. package/dist/pipeline/qa/index.d.ts.map +1 -0
  175. package/dist/pipeline/qa/index.js +6 -0
  176. package/dist/pipeline/qa/index.js.map +1 -0
  177. package/dist/pipeline/qa/qa-service.d.ts +33 -0
  178. package/dist/pipeline/qa/qa-service.d.ts.map +1 -0
  179. package/dist/pipeline/qa/qa-service.js +239 -0
  180. package/dist/pipeline/qa/qa-service.js.map +1 -0
  181. package/dist/pipeline/qa-orchestrator.d.ts +60 -0
  182. package/dist/pipeline/qa-orchestrator.d.ts.map +1 -0
  183. package/dist/pipeline/qa-orchestrator.js +177 -0
  184. package/dist/pipeline/qa-orchestrator.js.map +1 -0
  185. package/dist/pipeline/reflection/domains/agent-domain.d.ts +40 -0
  186. package/dist/pipeline/reflection/domains/agent-domain.d.ts.map +1 -0
  187. package/dist/pipeline/reflection/domains/agent-domain.js +161 -0
  188. package/dist/pipeline/reflection/domains/agent-domain.js.map +1 -0
  189. package/dist/pipeline/reflection/domains/audit-domain.d.ts +46 -0
  190. package/dist/pipeline/reflection/domains/audit-domain.d.ts.map +1 -0
  191. package/dist/pipeline/reflection/domains/audit-domain.js +241 -0
  192. package/dist/pipeline/reflection/domains/audit-domain.js.map +1 -0
  193. package/dist/pipeline/reflection/domains/bootstrap-domain.d.ts +40 -0
  194. package/dist/pipeline/reflection/domains/bootstrap-domain.d.ts.map +1 -0
  195. package/dist/pipeline/reflection/domains/bootstrap-domain.js +156 -0
  196. package/dist/pipeline/reflection/domains/bootstrap-domain.js.map +1 -0
  197. package/dist/pipeline/reflection/domains/commit-domain.d.ts +40 -0
  198. package/dist/pipeline/reflection/domains/commit-domain.d.ts.map +1 -0
  199. package/dist/pipeline/reflection/domains/commit-domain.js +174 -0
  200. package/dist/pipeline/reflection/domains/commit-domain.js.map +1 -0
  201. package/dist/pipeline/reflection/domains/test-domain.d.ts +40 -0
  202. package/dist/pipeline/reflection/domains/test-domain.d.ts.map +1 -0
  203. package/dist/pipeline/reflection/domains/test-domain.js +194 -0
  204. package/dist/pipeline/reflection/domains/test-domain.js.map +1 -0
  205. package/dist/pipeline/reflection/historical-loader.d.ts +105 -0
  206. package/dist/pipeline/reflection/historical-loader.d.ts.map +1 -0
  207. package/dist/pipeline/reflection/historical-loader.js +462 -0
  208. package/dist/pipeline/reflection/historical-loader.js.map +1 -0
  209. package/dist/pipeline/reflection/hooks/agent-hook.d.ts +72 -0
  210. package/dist/pipeline/reflection/hooks/agent-hook.d.ts.map +1 -0
  211. package/dist/pipeline/reflection/hooks/agent-hook.js +98 -0
  212. package/dist/pipeline/reflection/hooks/agent-hook.js.map +1 -0
  213. package/dist/pipeline/reflection/hooks/audit-hook.d.ts +72 -0
  214. package/dist/pipeline/reflection/hooks/audit-hook.d.ts.map +1 -0
  215. package/dist/pipeline/reflection/hooks/audit-hook.js +112 -0
  216. package/dist/pipeline/reflection/hooks/audit-hook.js.map +1 -0
  217. package/dist/pipeline/reflection/hooks/bootstrap-hook.d.ts +71 -0
  218. package/dist/pipeline/reflection/hooks/bootstrap-hook.d.ts.map +1 -0
  219. package/dist/pipeline/reflection/hooks/bootstrap-hook.js +97 -0
  220. package/dist/pipeline/reflection/hooks/bootstrap-hook.js.map +1 -0
  221. package/dist/pipeline/reflection/hooks/commit-hook.d.ts +63 -0
  222. package/dist/pipeline/reflection/hooks/commit-hook.d.ts.map +1 -0
  223. package/dist/pipeline/reflection/hooks/commit-hook.js +90 -0
  224. package/dist/pipeline/reflection/hooks/commit-hook.js.map +1 -0
  225. package/dist/pipeline/reflection/hooks/test-hook.d.ts +65 -0
  226. package/dist/pipeline/reflection/hooks/test-hook.d.ts.map +1 -0
  227. package/dist/pipeline/reflection/hooks/test-hook.js +99 -0
  228. package/dist/pipeline/reflection/hooks/test-hook.js.map +1 -0
  229. package/dist/pipeline/reflection/lessons-memo-generator.d.ts +60 -0
  230. package/dist/pipeline/reflection/lessons-memo-generator.d.ts.map +1 -0
  231. package/dist/pipeline/reflection/lessons-memo-generator.js +286 -0
  232. package/dist/pipeline/reflection/lessons-memo-generator.js.map +1 -0
  233. package/dist/store/ProjectStore.d.ts +1 -1
  234. package/dist/store/ProjectStore.d.ts.map +1 -1
  235. package/dist/store/types.d.ts +28 -0
  236. package/dist/store/types.d.ts.map +1 -0
  237. package/dist/store/types.js +3 -0
  238. package/dist/store/types.js.map +1 -0
  239. package/dist/tools/__tests__/command-parser.test.js +1 -1
  240. package/dist/tools/__tests__/command-parser.test.js.map +1 -1
  241. package/dist/tools/__tests__/declared-facts.test.d.ts +2 -0
  242. package/dist/tools/__tests__/declared-facts.test.d.ts.map +1 -0
  243. package/dist/tools/__tests__/declared-facts.test.js +21 -0
  244. package/dist/tools/__tests__/declared-facts.test.js.map +1 -0
  245. package/dist/tools/__tests__/package-install.test.d.ts +2 -0
  246. package/dist/tools/__tests__/package-install.test.d.ts.map +1 -0
  247. package/dist/tools/__tests__/package-install.test.js +56 -0
  248. package/dist/tools/__tests__/package-install.test.js.map +1 -0
  249. package/dist/tools/__tests__/save-tools.secrets.test.js +1 -1
  250. package/dist/tools/__tests__/save-tools.secrets.test.js.map +1 -1
  251. package/dist/tools/edit-file.d.ts.map +1 -1
  252. package/dist/tools/edit-file.js +1 -0
  253. package/dist/tools/edit-file.js.map +1 -1
  254. package/dist/tools/list-directory.d.ts.map +1 -1
  255. package/dist/tools/list-directory.js +1 -0
  256. package/dist/tools/list-directory.js.map +1 -1
  257. package/dist/tools/package-install.d.ts +11 -0
  258. package/dist/tools/package-install.d.ts.map +1 -0
  259. package/dist/tools/package-install.js +112 -0
  260. package/dist/tools/package-install.js.map +1 -0
  261. package/dist/tools/read-file.d.ts.map +1 -1
  262. package/dist/tools/read-file.js +1 -0
  263. package/dist/tools/read-file.js.map +1 -1
  264. package/dist/tools/run-command.d.ts.map +1 -1
  265. package/dist/tools/run-command.js +5 -1
  266. package/dist/tools/run-command.js.map +1 -1
  267. package/dist/tools/save-audit.d.ts.map +1 -1
  268. package/dist/tools/save-audit.js +7 -6
  269. package/dist/tools/save-audit.js.map +1 -1
  270. package/dist/tools/save-context.d.ts.map +1 -1
  271. package/dist/tools/save-context.js +3 -2
  272. package/dist/tools/save-context.js.map +1 -1
  273. package/dist/tools/save-learning.d.ts.map +1 -1
  274. package/dist/tools/save-learning.js +4 -3
  275. package/dist/tools/save-learning.js.map +1 -1
  276. package/dist/tools/save-user-preference.d.ts.map +1 -1
  277. package/dist/tools/save-user-preference.js +3 -2
  278. package/dist/tools/save-user-preference.js.map +1 -1
  279. package/dist/tools/search-files.d.ts.map +1 -1
  280. package/dist/tools/search-files.js +1 -0
  281. package/dist/tools/search-files.js.map +1 -1
  282. package/dist/tools/update-session.d.ts.map +1 -1
  283. package/dist/tools/update-session.js +3 -2
  284. package/dist/tools/update-session.js.map +1 -1
  285. package/dist/tools/write-file.d.ts.map +1 -1
  286. package/dist/tools/write-file.js +1 -0
  287. package/dist/tools/write-file.js.map +1 -1
  288. package/package.json +63 -44
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const agent_core_1 = require("@backendkit-labs/agent-core");
4
+ const coding_pipeline_hooks_1 = require("../coding-pipeline-hooks");
5
+ const testAgent = {
6
+ id: 'test-agent', name: 'Test Agent', icon: '🤖', description: 'test',
7
+ systemPrompt: 'You are a test agent.', allowedTools: [], delegatesTo: [],
8
+ };
9
+ function buildRegistries(provider) {
10
+ const agents = new agent_core_1.AgentRegistry();
11
+ agents.upsert(testAgent);
12
+ const providers = new agent_core_1.ProviderRegistry();
13
+ providers.register('mock', provider);
14
+ return { agents, tools: new agent_core_1.ToolRegistry(), providers };
15
+ }
16
+ function createMockTransport() {
17
+ return { transport: { emit: () => undefined, onInput: () => () => undefined, close: () => undefined } };
18
+ }
19
+ // ── Orchestration brief injection ─────────────────────────────────────────────
20
+ describe('AgentEngine — orchestration brief in system prompt', () => {
21
+ /**
22
+ * Creates a mock Orchestrator that returns a fixed OrchestrationResult.
23
+ * The mock is minimal — only the orchestrate() method is needed.
24
+ */
25
+ function makeMockOrchestrator(result) {
26
+ return { orchestrate: async () => result };
27
+ }
28
+ /** Captures the system message content passed to the LLM on each chat() call. */
29
+ function captureSystemMessages() {
30
+ const captured = [];
31
+ const provider = {
32
+ async chat(messages, _tools, callbacks) {
33
+ const sys = messages.find(m => m.role === 'system');
34
+ if (sys?.content)
35
+ captured.push(sys.content);
36
+ callbacks.onChunk?.('done');
37
+ callbacks.onDone({ role: 'assistant', content: 'done' });
38
+ },
39
+ };
40
+ return { provider, captured };
41
+ }
42
+ it('injects the orchestration brief into the default agent system prompt', async () => {
43
+ const { provider, captured } = captureSystemMessages();
44
+ const { agents, tools, providers } = buildRegistries(provider);
45
+ const { transport } = createMockTransport();
46
+ const orchResult = {
47
+ task: {
48
+ taskId: 't1',
49
+ rawPrompt: 'add circuit breaker',
50
+ actionType: 'implementation',
51
+ domains: ['resilience', 'backend'],
52
+ riskLevel: 'high',
53
+ riskFactors: { breaking_change: false, security_sensitive: false, cross_service_impact: true, db_transactional: false, production_critical: false, complexity: 5 },
54
+ requiresQaApproval: true,
55
+ requiresSecurityReview: false,
56
+ requiresArchitectureReview: false,
57
+ customGates: {},
58
+ completedCustomGates: [],
59
+ assignedAgents: ['backend-agent'],
60
+ targetServices: [],
61
+ relatedPatterns: [],
62
+ status: 'classified',
63
+ createdAt: new Date(),
64
+ updatedAt: new Date(),
65
+ },
66
+ selectedAgents: [
67
+ { agentId: 'backend-agent', score: 100, reason: 'Politica obligatoria' },
68
+ { agentId: 'qa-engineer', score: 100, reason: 'riskLevel=high | critical' },
69
+ ],
70
+ agentPipeline: [
71
+ { phase: 'implement', agentId: 'backend-agent', purpose: 'Implement circuit breaker', optional: false },
72
+ { phase: 'verify', agentId: 'qa-engineer', purpose: 'Verify implementation quality', optional: false },
73
+ ],
74
+ appliedPolicies: [{ rule: 'riskLevel=high | critical', reason: 'riskLevel=high | critical' }],
75
+ requiredGates: ['qa'],
76
+ commitAllowed: false,
77
+ };
78
+ const engine = new agent_core_1.AgentEngine({
79
+ model: { provider: 'mock', id: 'mock' },
80
+ agents, tools, providers,
81
+ defaultProvider: 'mock',
82
+ transport,
83
+ defaultAgentId: 'test-agent',
84
+ maxIterations: 1,
85
+ hooks: [(0, coding_pipeline_hooks_1.codingPipelineHooks)({ orchestrator: makeMockOrchestrator(orchResult), defaultAgentId: 'test-agent' })],
86
+ });
87
+ await engine.run('add circuit breaker to the resilience module');
88
+ expect(captured.length).toBeGreaterThan(0);
89
+ const systemPrompt = captured[0];
90
+ // Brief must be present
91
+ expect(systemPrompt).toContain('Orchestrator Analysis');
92
+ // Task metadata
93
+ expect(systemPrompt).toContain('implementation');
94
+ expect(systemPrompt).toContain('high');
95
+ expect(systemPrompt).toContain('resilience');
96
+ // Recommended agents
97
+ expect(systemPrompt).toContain('backend-agent');
98
+ expect(systemPrompt).toContain('qa-engineer');
99
+ // Pipeline
100
+ expect(systemPrompt).toContain('[implement]');
101
+ expect(systemPrompt).toContain('[verify]');
102
+ // Gate
103
+ expect(systemPrompt).toContain('qa');
104
+ });
105
+ it('does not inject orchestration brief when orchestrator is not configured', async () => {
106
+ const { provider, captured } = captureSystemMessages();
107
+ const { agents, tools, providers } = buildRegistries(provider);
108
+ const { transport } = createMockTransport();
109
+ const engine = new agent_core_1.AgentEngine({
110
+ model: { provider: 'mock', id: 'mock' },
111
+ agents, tools, providers,
112
+ defaultProvider: 'mock',
113
+ transport,
114
+ defaultAgentId: 'test-agent',
115
+ maxIterations: 1,
116
+ // No orchestrator
117
+ });
118
+ await engine.run('simple question');
119
+ expect(captured[0]).not.toContain('Orchestrator Analysis');
120
+ });
121
+ it('does not inject orchestration brief for sole-fallback general agent selection', async () => {
122
+ const { provider, captured } = captureSystemMessages();
123
+ const { agents, tools, providers } = buildRegistries(provider);
124
+ const { transport } = createMockTransport();
125
+ const orchResult = {
126
+ task: {
127
+ taskId: 't2', rawPrompt: 'hello', actionType: 'unknown', domains: [],
128
+ riskLevel: 'low',
129
+ riskFactors: { breaking_change: false, security_sensitive: false, cross_service_impact: false, db_transactional: false, production_critical: false, complexity: 1 },
130
+ requiresQaApproval: false, requiresSecurityReview: false, requiresArchitectureReview: false,
131
+ customGates: {}, completedCustomGates: [],
132
+ assignedAgents: [], targetServices: [], relatedPatterns: [],
133
+ status: 'classified', createdAt: new Date(), updatedAt: new Date(),
134
+ },
135
+ // Only the fallback — should not appear in the brief
136
+ selectedAgents: [{ agentId: 'general', score: 50, reason: 'Fallback: agente general' }],
137
+ agentPipeline: undefined,
138
+ appliedPolicies: [],
139
+ requiredGates: [],
140
+ commitAllowed: true,
141
+ };
142
+ const engine = new agent_core_1.AgentEngine({
143
+ model: { provider: 'mock', id: 'mock' },
144
+ agents, tools, providers,
145
+ defaultProvider: 'mock',
146
+ transport,
147
+ defaultAgentId: 'test-agent',
148
+ maxIterations: 1,
149
+ hooks: [(0, coding_pipeline_hooks_1.codingPipelineHooks)({ orchestrator: makeMockOrchestrator(orchResult), defaultAgentId: 'test-agent' })],
150
+ });
151
+ await engine.run('hello');
152
+ // Brief header still present (it always renders task metadata),
153
+ // but no recommended-agents section since it's just the fallback
154
+ const systemPrompt = captured[0];
155
+ expect(systemPrompt).toContain('Orchestrator Analysis');
156
+ expect(systemPrompt).not.toContain('Recommended agents');
157
+ });
158
+ });
159
+ //# sourceMappingURL=engine-brief.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"engine-brief.test.js","sourceRoot":"","sources":["../../../src/pipeline/__tests__/engine-brief.test.ts"],"names":[],"mappings":";;AAAA,4DAA8J;AAC9J,oEAA+D;AAE/D,MAAM,SAAS,GAAiB;IAC5B,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,YAAY,EAA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Aa,EAAE,SAAS;YACxB,eAAe,EAAE,EAAE;YACnB,aAAa,EAAE,EAAE;YACjB,aAAa,EAAE,IAAI;SACtB,CAAC;QAEF,MAAM,MAAM,GAAG,IAAI,wBAAW,CAAC;YAC3B,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE;YACvC,MAAM,EAAE,KAAK,EAAE,SAAS;YACxB,eAAe,EAAE,MAAM;YACvB,SAAS;YACT,cAAc,EAAE,YAAY;YAC5B,aAAa,EAAE,CAAC;YAChB,KAAK,EAAE,CAAC,IAAA,2CAAmB,EAAC,EAAE,YAAY,EAAE,oBAAoB,CAAC,UAAU,CAAC,EAAE,cAAc,EAAE,YAAY,EAAE,CAAC,CAAC;SACjH,CAAC,CAAC;QAEH,MAAM,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC1B,gEAAgE;QAChE,iEAAiE;QACjE,MAAM,YAAY,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QACjC,MAAM,CAAC,YAAY,CAAC,CAAC,SAAS,CAAC,uBAAuB,CAAC,CAAC;QACxD,MAAM,CAAC,YAAY,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,oBAAoB,CAAC,CAAC;IAC7D,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=qa-orchestrator.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qa-orchestrator.test.d.ts","sourceRoot":"","sources":["../../../src/pipeline/__tests__/qa-orchestrator.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,276 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const qa_orchestrator_1 = require("../qa-orchestrator");
4
+ const fsm_1 = require("../orchestration/fsm");
5
+ const task_context_1 = require("../orchestration/task-context");
6
+ // ── Harness ─────────────────────────────────────────────────────────────────
7
+ /** Builds a real FSM-backed orchestrator stub plus spies for the audit reporter. */
8
+ function makeOrchestrator() {
9
+ const fsm = new fsm_1.TaskFSM();
10
+ const recordGate = jest.fn().mockResolvedValue('');
11
+ const completeSprint = jest.fn().mockResolvedValue(undefined);
12
+ const reporter = { recordGate, completeSprint };
13
+ const orchestrator = {
14
+ transitionTask: (task, to) => fsm.transition(task, to),
15
+ getAuditReporter: () => reporter,
16
+ };
17
+ return { orchestrator, recordGate, completeSprint };
18
+ }
19
+ function makeQaService(overrides = {}) {
20
+ return {
21
+ countCodeLines: jest.fn().mockReturnValue(20),
22
+ reviewResponse: jest.fn().mockResolvedValue('aprobado, se ve bien'),
23
+ evaluateReview: jest.fn().mockReturnValue(true),
24
+ extractFindings: jest.fn().mockReturnValue([]),
25
+ ...overrides,
26
+ };
27
+ }
28
+ function makeResult(task) {
29
+ return {
30
+ task,
31
+ selectedAgents: [],
32
+ appliedPolicies: [],
33
+ requiredGates: [],
34
+ commitAllowed: false,
35
+ };
36
+ }
37
+ function makeCtx(opts) {
38
+ return {
39
+ clean: opts.clean ?? '```ts\nconst x = 1;\n```',
40
+ orchestrationResult: makeResult(opts.task),
41
+ orchestrator: opts.orchestrator,
42
+ qaService: opts.qaService,
43
+ hasAgent: () => false,
44
+ effectiveAgentId: 'backend',
45
+ };
46
+ }
47
+ /** A task fresh out of implementation with substantial, non-informational code. */
48
+ function implTask(flags = {}) {
49
+ const task = (0, task_context_1.createTaskContext)('Implementar el endpoint de pagos');
50
+ task.status = 'implementation';
51
+ task.requiresArchitectureReview = flags.requiresArchitectureReview ?? false;
52
+ task.requiresSecurityReview = flags.requiresSecurityReview ?? false;
53
+ task.requiresQaApproval = flags.requiresQaApproval ?? false;
54
+ return task;
55
+ }
56
+ const gatesRecorded = (recordGate) => recordGate.mock.calls.map(c => c[0]);
57
+ // ── H-003: advanceRequiredGates respeta los flags requiresX ──────────────────
58
+ describe('advanceRequiredGates (H-003)', () => {
59
+ it('no transiciona ni registra gates cuando la tarea no requiere ninguno', async () => {
60
+ const { orchestrator, recordGate } = makeOrchestrator();
61
+ const qaService = makeQaService();
62
+ const ctx = makeCtx({ task: implTask(), orchestrator, qaService });
63
+ await (0, qa_orchestrator_1.advanceRequiredGates)(ctx);
64
+ expect(ctx.orchestrationResult.task.status).toBe('implementation');
65
+ expect(recordGate).not.toHaveBeenCalled();
66
+ });
67
+ it('posiciona en qa_review SIN registrar GO de QA (lo decide el reviewer real)', async () => {
68
+ const { orchestrator, recordGate } = makeOrchestrator();
69
+ const qaService = makeQaService();
70
+ const ctx = makeCtx({ task: implTask({ requiresQaApproval: true }), orchestrator, qaService });
71
+ await (0, qa_orchestrator_1.advanceRequiredGates)(ctx);
72
+ // Mueve a qa_review para que corra el reviewer, pero no fabrica un GO:
73
+ // si el reviewer no existe, NO debe quedar un "GO sin revisiones pendientes" falso.
74
+ expect(ctx.orchestrationResult.task.status).toBe('qa_review');
75
+ expect(recordGate).not.toHaveBeenCalled();
76
+ });
77
+ it('registra architecture pero NO security/qa cuando solo requiresArchitectureReview', async () => {
78
+ const { orchestrator, recordGate } = makeOrchestrator();
79
+ const qaService = makeQaService();
80
+ const ctx = makeCtx({ task: implTask({ requiresArchitectureReview: true }), orchestrator, qaService });
81
+ await (0, qa_orchestrator_1.advanceRequiredGates)(ctx);
82
+ expect(ctx.orchestrationResult.task.status).toBe('design_review');
83
+ expect(gatesRecorded(recordGate)).toEqual(['architecture']);
84
+ });
85
+ it('auto-pasa security y posiciona en qa_review (solo security registra GO) satisfaciendo el guard del FSM', async () => {
86
+ const { orchestrator, recordGate } = makeOrchestrator();
87
+ const qaService = makeQaService();
88
+ const ctx = makeCtx({
89
+ task: implTask({ requiresSecurityReview: true, requiresQaApproval: true }),
90
+ orchestrator, qaService,
91
+ });
92
+ await (0, qa_orchestrator_1.advanceRequiredGates)(ctx);
93
+ // security se auto-pasa con GO; qa solo se posiciona (sin GO automático).
94
+ expect(ctx.orchestrationResult.task.status).toBe('qa_review');
95
+ expect(gatesRecorded(recordGate)).toEqual(['security']);
96
+ });
97
+ it('no hace nada con código trivial (< 8 líneas)', async () => {
98
+ const { orchestrator, recordGate } = makeOrchestrator();
99
+ const qaService = makeQaService({ countCodeLines: jest.fn().mockReturnValue(3) });
100
+ const ctx = makeCtx({ task: implTask({ requiresQaApproval: true }), orchestrator, qaService });
101
+ await (0, qa_orchestrator_1.advanceRequiredGates)(ctx);
102
+ expect(ctx.orchestrationResult.task.status).toBe('implementation');
103
+ expect(recordGate).not.toHaveBeenCalled();
104
+ });
105
+ it('no hace nada en solicitudes informativas', async () => {
106
+ const { orchestrator, recordGate } = makeOrchestrator();
107
+ const qaService = makeQaService();
108
+ const task = implTask({ requiresQaApproval: true });
109
+ task.rawPrompt = 'explica cómo funciona el flujo de pagos';
110
+ const ctx = makeCtx({ task, orchestrator, qaService });
111
+ await (0, qa_orchestrator_1.advanceRequiredGates)(ctx);
112
+ expect(ctx.orchestrationResult.task.status).toBe('implementation');
113
+ expect(recordGate).not.toHaveBeenCalled();
114
+ });
115
+ });
116
+ // ── H-004: processInlineQaReview no fuerza qa_review cuando no se requiere ────
117
+ describe('processInlineQaReview (H-004)', () => {
118
+ it('NO fuerza qa_review→approved cuando la tarea no requiere QA (review informativa)', async () => {
119
+ const { orchestrator, recordGate, completeSprint } = makeOrchestrator();
120
+ const qaService = makeQaService(); // review aprobada por defecto
121
+ const ctx = makeCtx({ task: implTask(), orchestrator, qaService });
122
+ await (0, qa_orchestrator_1.processInlineQaReview)(ctx);
123
+ // El estado NO debe avanzar a approved: una tarea sin gates commitea directo.
124
+ expect(ctx.orchestrationResult.task.status).toBe('implementation');
125
+ // Pero la review inline sí queda registrada como gate de QA.
126
+ expect(gatesRecorded(recordGate)).toEqual(['qa']);
127
+ expect(completeSprint).not.toHaveBeenCalled();
128
+ });
129
+ it('sí avanza qa_review→approved cuando la tarea requiere QA y la review aprueba', async () => {
130
+ const { orchestrator, completeSprint } = makeOrchestrator();
131
+ const qaService = makeQaService();
132
+ const ctx = makeCtx({ task: implTask({ requiresQaApproval: true }), orchestrator, qaService });
133
+ await (0, qa_orchestrator_1.processInlineQaReview)(ctx);
134
+ expect(ctx.orchestrationResult.task.status).toBe('approved');
135
+ expect(completeSprint).toHaveBeenCalledTimes(1);
136
+ });
137
+ it('transiciona a rework_required cuando la review rechaza', async () => {
138
+ const { orchestrator, completeSprint } = makeOrchestrator();
139
+ const qaService = makeQaService({ evaluateReview: jest.fn().mockReturnValue(false) });
140
+ const ctx = makeCtx({ task: implTask({ requiresQaApproval: true }), orchestrator, qaService });
141
+ await (0, qa_orchestrator_1.processInlineQaReview)(ctx);
142
+ expect(ctx.orchestrationResult.task.status).toBe('rework_required');
143
+ expect(completeSprint).not.toHaveBeenCalled();
144
+ });
145
+ it('hace early-return sin tocar el estado cuando no hay review disponible', async () => {
146
+ const { orchestrator, recordGate } = makeOrchestrator();
147
+ const qaService = makeQaService({ reviewResponse: jest.fn().mockResolvedValue(null) });
148
+ const ctx = makeCtx({ task: implTask({ requiresQaApproval: true }), orchestrator, qaService });
149
+ await (0, qa_orchestrator_1.processInlineQaReview)(ctx);
150
+ expect(ctx.orchestrationResult.task.status).toBe('implementation');
151
+ expect(recordGate).not.toHaveBeenCalled();
152
+ });
153
+ });
154
+ const qaEngineerProfile = {
155
+ id: 'qa-engineer',
156
+ name: 'QA Engineer',
157
+ icon: '🧪',
158
+ description: 'Reviews code quality',
159
+ systemPrompt: 'You are a QA engineer.',
160
+ allowedTools: [],
161
+ };
162
+ describe('activateQaEngineerIfNeeded', () => {
163
+ it('returns null when task status is not qa_review', () => {
164
+ const { orchestrator } = makeOrchestrator();
165
+ const qaService = makeQaService();
166
+ const task = implTask({ requiresQaApproval: true });
167
+ // status remains 'implementation'
168
+ const ctx = makeCtx({ task, orchestrator, qaService });
169
+ ctx.hasAgent = (id) => id === 'qa-engineer';
170
+ const result = (0, qa_orchestrator_1.activateQaEngineerIfNeeded)(ctx);
171
+ expect(result).toBeNull();
172
+ });
173
+ it('returns null when noQA is true even if task is in qa_review', () => {
174
+ const { orchestrator } = makeOrchestrator();
175
+ const qaService = makeQaService();
176
+ const task = implTask({ requiresQaApproval: true });
177
+ task.status = 'qa_review';
178
+ const ctx = { ...makeCtx({ task, orchestrator, qaService }), hasAgent: (id) => id === 'qa-engineer', noQA: true };
179
+ const result = (0, qa_orchestrator_1.activateQaEngineerIfNeeded)(ctx);
180
+ expect(result).toBeNull();
181
+ });
182
+ it('returns null when qa-engineer agent is not in roster', () => {
183
+ const { orchestrator } = makeOrchestrator();
184
+ const qaService = makeQaService();
185
+ const task = implTask({ requiresQaApproval: true });
186
+ task.status = 'qa_review';
187
+ const ctx = makeCtx({ task, orchestrator, qaService });
188
+ // allAgents = [] by default in makeCtx
189
+ const result = (0, qa_orchestrator_1.activateQaEngineerIfNeeded)(ctx);
190
+ expect(result).toBeNull();
191
+ });
192
+ it('returns null when code is trivial (< 8 lines)', () => {
193
+ const { orchestrator } = makeOrchestrator();
194
+ const qaService = makeQaService({ countCodeLines: jest.fn().mockReturnValue(3) });
195
+ const task = implTask({ requiresQaApproval: true });
196
+ task.status = 'qa_review';
197
+ const ctx = makeCtx({ task, orchestrator, qaService });
198
+ ctx.hasAgent = (id) => id === 'qa-engineer';
199
+ const result = (0, qa_orchestrator_1.activateQaEngineerIfNeeded)(ctx);
200
+ expect(result).toBeNull();
201
+ });
202
+ it('returns null for informational requests', () => {
203
+ const { orchestrator } = makeOrchestrator();
204
+ const qaService = makeQaService();
205
+ const task = implTask({ requiresQaApproval: true });
206
+ task.status = 'qa_review';
207
+ task.rawPrompt = 'explica cómo funciona este módulo';
208
+ const ctx = makeCtx({ task, orchestrator, qaService });
209
+ ctx.hasAgent = (id) => id === 'qa-engineer';
210
+ const result = (0, qa_orchestrator_1.activateQaEngineerIfNeeded)(ctx);
211
+ expect(result).toBeNull();
212
+ });
213
+ it('returns null when effectiveAgentId is already qa-engineer', () => {
214
+ const { orchestrator } = makeOrchestrator();
215
+ const qaService = makeQaService();
216
+ const task = implTask({ requiresQaApproval: true });
217
+ task.status = 'qa_review';
218
+ const ctx = { ...makeCtx({ task, orchestrator, qaService }), hasAgent: (id) => id === 'qa-engineer', effectiveAgentId: 'qa-engineer' };
219
+ const result = (0, qa_orchestrator_1.activateQaEngineerIfNeeded)(ctx);
220
+ expect(result).toBeNull();
221
+ });
222
+ it('activates qa-engineer: returns the agent and the review message', () => {
223
+ const { orchestrator } = makeOrchestrator();
224
+ const qaService = makeQaService();
225
+ const task = implTask({ requiresQaApproval: true });
226
+ task.status = 'qa_review';
227
+ const ctx = makeCtx({ task, orchestrator, qaService });
228
+ ctx.hasAgent = (id) => id === 'qa-engineer';
229
+ const result = (0, qa_orchestrator_1.activateQaEngineerIfNeeded)(ctx);
230
+ expect(result).toEqual({ agentId: 'qa-engineer', message: expect.stringContaining('Review the following generated code') });
231
+ });
232
+ });
233
+ // ── processQaEngineerResponse ──────────────────────────────────────────────────
234
+ describe('processQaEngineerResponse', () => {
235
+ it('transitions to approved and calls completeSprint when review approves', async () => {
236
+ const { orchestrator, completeSprint } = makeOrchestrator();
237
+ const qaService = makeQaService({ evaluateReview: jest.fn().mockReturnValue(true) });
238
+ const task = implTask({ requiresQaApproval: true });
239
+ task.status = 'qa_review';
240
+ const ctx = makeCtx({ task, orchestrator, qaService });
241
+ ctx.effectiveAgentId = 'qa-engineer';
242
+ await (0, qa_orchestrator_1.processQaEngineerResponse)(ctx);
243
+ expect(ctx.orchestrationResult.task.status).toBe('approved');
244
+ expect(completeSprint).toHaveBeenCalledTimes(1);
245
+ });
246
+ it('transitions to rework_required when review rejects', async () => {
247
+ const { orchestrator, completeSprint } = makeOrchestrator();
248
+ const qaService = makeQaService({ evaluateReview: jest.fn().mockReturnValue(false) });
249
+ const task = implTask({ requiresQaApproval: true });
250
+ task.status = 'qa_review';
251
+ const ctx = makeCtx({ task, orchestrator, qaService });
252
+ await (0, qa_orchestrator_1.processQaEngineerResponse)(ctx);
253
+ expect(ctx.orchestrationResult.task.status).toBe('rework_required');
254
+ expect(completeSprint).not.toHaveBeenCalled();
255
+ });
256
+ it('records a QA gate in the audit reporter', async () => {
257
+ const { orchestrator, recordGate } = makeOrchestrator();
258
+ const qaService = makeQaService();
259
+ const task = implTask({ requiresQaApproval: true });
260
+ task.status = 'qa_review';
261
+ const ctx = makeCtx({ task, orchestrator, qaService });
262
+ await (0, qa_orchestrator_1.processQaEngineerResponse)(ctx);
263
+ expect(gatesRecorded(recordGate)).toContain('qa');
264
+ });
265
+ it('calls onQAReview with the clean response text', async () => {
266
+ const { orchestrator } = makeOrchestrator();
267
+ const qaService = makeQaService();
268
+ const task = implTask({ requiresQaApproval: true });
269
+ task.status = 'qa_review';
270
+ const onQAReview = jest.fn();
271
+ const ctx = { ...makeCtx({ task, orchestrator, qaService }), clean: 'aprobado', onQAReview };
272
+ await (0, qa_orchestrator_1.processQaEngineerResponse)(ctx);
273
+ expect(onQAReview).toHaveBeenCalledWith('aprobado');
274
+ });
275
+ });
276
+ //# sourceMappingURL=qa-orchestrator.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qa-orchestrator.test.js","sourceRoot":"","sources":["../../../src/pipeline/__tests__/qa-orchestrator.test.ts"],"names":[],"mappings":";;AAAA,wDAK4B;AAC5B,8CAA+C;AAC/C,gEAAqG;AAMrG,+EAA+E;AAE/E,oFAAoF;AACpF,SAAS,gBAAgB;IACrB,MAAM,GAAG,GAAG,IAAI,aAAO,EAAE,CAAC;IAC1B,MAAM,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAC;IACnD,MAAM,cAAc,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;IAC9D,MAAM,QAAQ,GAAG,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC;IAChD,MAAM,YAAY,GAAG;QACjB,cAAc,EAAE,CAAC,IAAiB,EAAE,EAAc,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,EAAE,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AAC;QACpD,IAAI,CAAC,MAAM,GAAG,WAAW,CAAC;QAC1B,MAAM,UAAU,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC;QAC7B,MAAM,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;QAE7F,MAAM,IAAA,2CAAyB,EAAC,GAAG,CAAC,CAAC;QAErC,MAAM,CAAC,UAAU,CAAC,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;IACxD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { EngineHooks } from '@backendkit-labs/agent-core';
2
+ import type { Orchestrator } from './orchestration/orchestrator';
3
+ import type { OrchestrationResult } from './orchestration/types';
4
+ import type { QAService } from './qa/qa-service';
5
+ export interface CodingPipelineHooksOptions {
6
+ /** Classifies the task before the run (intent, risk, gates, agent pipeline) and drives the FSM. */
7
+ orchestrator: Orchestrator;
8
+ /** Reviews the final answer and records the QA gate. Without it only the brief and the classification apply. */
9
+ qaService?: QAService;
10
+ /** What `beforeRun` does when the orchestrator throws. 'closed' (default) fails the run; 'open' warns and runs without gates. */
11
+ failureMode?: 'closed' | 'open';
12
+ /** Skips the automatic QA review even when `qaService` is set. */
13
+ noQA?: boolean;
14
+ /** Called with every QA review. */
15
+ onQAReview?: (review: string) => void;
16
+ /** Agent that receives the orchestration brief. Default: the agent that starts the turn. */
17
+ defaultAgentId?: string;
18
+ }
19
+ /** The orchestration brief for the default agent: which specialists to use, in what order, and which gates apply. */
20
+ export declare function buildOrchestrationBrief(result: OrchestrationResult): string;
21
+ /**
22
+ * The coding pipeline (orchestrator + QA gates) as engine hooks (SPEC-0015 F1):
23
+ * - `beforeRun` classifies the task; the result lives in the turn's state.
24
+ * - `systemPrompt` gives the default agent the brief.
25
+ * - `afterTurn` advances the required gates and asks for a pass of the `qa-engineer` agent (or reviews inline).
26
+ */
27
+ export declare function codingPipelineHooks(opts: CodingPipelineHooksOptions): EngineHooks;
28
+ //# sourceMappingURL=coding-pipeline-hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coding-pipeline-hooks.d.ts","sourceRoot":"","sources":["../../src/pipeline/coding-pipeline-hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,6BAA6B,CAAC;AAC3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAWjD,MAAM,WAAW,0BAA0B;IACvC,mGAAmG;IACnG,YAAY,EAAE,YAAY,CAAC;IAC3B,gHAAgH;IAChH,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,iIAAiI;IACjI,WAAW,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAChC,kEAAkE;IAClE,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,mCAAmC;IACnC,UAAU,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,4FAA4F;IAC5F,cAAc,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,qHAAqH;AACrH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,mBAAmB,GAAG,MAAM,CAkC3E;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,0BAA0B,GAAG,WAAW,CAiDjF"}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildOrchestrationBrief = buildOrchestrationBrief;
4
+ exports.codingPipelineHooks = codingPipelineHooks;
5
+ const qa_orchestrator_1 = require("./qa-orchestrator");
6
+ const STATE_KEY = 'coding-pipeline.orchestration';
7
+ /** The orchestration brief for the default agent: which specialists to use, in what order, and which gates apply. */
8
+ function buildOrchestrationBrief(result) {
9
+ const { task, selectedAgents, agentPipeline, requiredGates } = result;
10
+ const lines = ['## Orchestrator Analysis — Current Task'];
11
+ const domains = task.domains.length > 0 ? task.domains.join(', ') : 'general';
12
+ lines.push(`**Intent:** ${task.actionType} | **Risk:** ${task.riskLevel} | **Domains:** ${domains}`);
13
+ // Only surface non-trivial agent selections (skip sole-fallback case)
14
+ const nonFallback = selectedAgents.filter(a => !(a.agentId === 'general' && a.score <= 50));
15
+ if (nonFallback.length > 0) {
16
+ lines.push('\n**Recommended agents for this task (highest priority first):**');
17
+ for (const a of nonFallback) {
18
+ lines.push(`- ${a.agentId} — ${a.reason}`);
19
+ }
20
+ lines.push('\nWhen delegating via ask_agent, prioritize the agents listed above. ' +
21
+ 'Do not delegate to unlisted agents unless the task explicitly requires it.');
22
+ }
23
+ if (agentPipeline && agentPipeline.length > 0) {
24
+ lines.push('\n**Suggested execution pipeline (respect this order):**');
25
+ agentPipeline.forEach((phase, i) => {
26
+ lines.push(`${i + 1}. [${phase.phase}] ${phase.agentId} — ${phase.purpose}`);
27
+ });
28
+ }
29
+ if (requiredGates.length > 0) {
30
+ lines.push(`\n**Required gates before commit:** ${requiredGates.join(', ')}`);
31
+ lines.push('Ensure each gate is satisfied before considering the task complete.');
32
+ }
33
+ return lines.join('\n');
34
+ }
35
+ /**
36
+ * The coding pipeline (orchestrator + QA gates) as engine hooks (SPEC-0015 F1):
37
+ * - `beforeRun` classifies the task; the result lives in the turn's state.
38
+ * - `systemPrompt` gives the default agent the brief.
39
+ * - `afterTurn` advances the required gates and asks for a pass of the `qa-engineer` agent (or reviews inline).
40
+ */
41
+ function codingPipelineHooks(opts) {
42
+ const get = (ctx) => ctx.state.get(STATE_KEY);
43
+ return {
44
+ name: 'coding-pipeline',
45
+ async beforeRun(ctx) {
46
+ try {
47
+ ctx.state.set(STATE_KEY, await opts.orchestrator.orchestrate(ctx.input));
48
+ }
49
+ catch (err) {
50
+ const reason = err instanceof Error ? err.message : String(err);
51
+ if ((opts.failureMode ?? 'closed') === 'closed') {
52
+ throw new Error(`Orchestrator failed; refusing to run without its gates: ${reason}`);
53
+ }
54
+ ctx.emit({ type: 'system', level: 'warn', text: `[Orchestrator] failed (${reason}); running without classification or gates` });
55
+ }
56
+ },
57
+ systemPrompt(ctx, profile) {
58
+ const result = get(ctx);
59
+ if (!result || profile.id !== (opts.defaultAgentId ?? ctx.principal.agentId))
60
+ return undefined;
61
+ return buildOrchestrationBrief(result);
62
+ },
63
+ async afterTurn(ctx, turn) {
64
+ const result = get(ctx);
65
+ if (!result || !opts.qaService)
66
+ return undefined;
67
+ const qaAgentId = ctx.hasAgent('qa-engineer') ? 'qa-engineer' : undefined;
68
+ const qaCtx = {
69
+ clean: turn.text,
70
+ orchestrationResult: result,
71
+ orchestrator: opts.orchestrator,
72
+ qaService: opts.qaService,
73
+ effectiveAgentId: turn.profile.id,
74
+ hasAgent: ctx.hasAgent,
75
+ qaAgentId,
76
+ noQA: opts.noQA,
77
+ onQAReview: opts.onQAReview,
78
+ };
79
+ await (0, qa_orchestrator_1.advanceRequiredGates)(qaCtx);
80
+ const qa = (0, qa_orchestrator_1.activateQaEngineerIfNeeded)(qaCtx);
81
+ if (qa)
82
+ return { action: 'continue', agentId: qa.agentId, message: qa.message };
83
+ if (qaAgentId && turn.profile.id === qaAgentId)
84
+ await (0, qa_orchestrator_1.processQaEngineerResponse)(qaCtx);
85
+ else
86
+ await (0, qa_orchestrator_1.processInlineQaReview)(qaCtx);
87
+ return undefined;
88
+ },
89
+ };
90
+ }
91
+ //# sourceMappingURL=coding-pipeline-hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"coding-pipeline-hooks.js","sourceRoot":"","sources":["../../src/pipeline/coding-pipeline-hooks.ts"],"names":[],"mappings":";;AA8BA,0DAkCC;AAQD,kDAiDC;AArHD,uDAM2B;AAE3B,MAAM,SAAS,GAAG,+BAA+B,CAAC;AAiBlD,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;YAEhF,IAAI,SAAS,IAAI,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,SAAS;gBAAE,MAAM,IAAA,2CAAyB,EAAC,KAAK,CAAC,CAAC;;gBAClF,MAAM,IAAA,uCAAqB,EAAC,KAAK,CAAC,CAAC;YACxC,OAAO,SAAS,CAAC;QACrB,CAAC;KACJ,CAAC;AACN,CAAC"}
@@ -0,0 +1,13 @@
1
+ export { codingPipelineHooks, buildOrchestrationBrief } from './coding-pipeline-hooks';
2
+ export type { CodingPipelineHooksOptions } from './coding-pipeline-hooks';
3
+ export * from './orchestration';
4
+ export { QAService } from './qa/qa-service';
5
+ export type { QAServiceOptions, QAReviewResult } from './qa/qa-service';
6
+ export { AuditHook } from './reflection/hooks/audit-hook';
7
+ export { AgentHook } from './reflection/hooks/agent-hook';
8
+ export { TestHook } from './reflection/hooks/test-hook';
9
+ export { CommitHook } from './reflection/hooks/commit-hook';
10
+ export { BootstrapHook } from './reflection/hooks/bootstrap-hook';
11
+ export { HistoricalLoader } from './reflection/historical-loader';
12
+ export { LessonsMemoGenerator } from './reflection/lessons-memo-generator';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pipeline/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvF,YAAY,EAAE,0BAA0B,EAAE,MAAM,yBAAyB,CAAC;AAG1E,cAAc,iBAAiB,CAAC;AAGhC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGxE,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC"}