codehere 0.3.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 (297) 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 +3 -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 +22 -2
  27. package/dist/application/services/dependency-container.d.ts.map +1 -1
  28. package/dist/application/services/dependency-container.js +144 -6
  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 +19 -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 +125 -46
  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 +16 -1
  40. package/dist/application/use-cases/edit-file-use-case.js.map +1 -1
  41. package/dist/domain/entities/documentation.d.ts +35 -0
  42. package/dist/domain/entities/documentation.d.ts.map +1 -0
  43. package/dist/domain/entities/documentation.js +6 -0
  44. package/dist/domain/entities/documentation.js.map +1 -0
  45. package/dist/domain/entities/product-requirements.d.ts +50 -0
  46. package/dist/domain/entities/product-requirements.d.ts.map +1 -0
  47. package/dist/domain/entities/product-requirements.js +6 -0
  48. package/dist/domain/entities/product-requirements.js.map +1 -0
  49. package/dist/domain/entities/task.d.ts +152 -0
  50. package/dist/domain/entities/task.d.ts.map +1 -0
  51. package/dist/domain/entities/task.js +61 -0
  52. package/dist/domain/entities/task.js.map +1 -0
  53. package/dist/domain/interfaces/agent.interface.d.ts +15 -0
  54. package/dist/domain/interfaces/agent.interface.d.ts.map +1 -0
  55. package/dist/domain/interfaces/agent.interface.js +6 -0
  56. package/dist/domain/interfaces/agent.interface.js.map +1 -0
  57. package/dist/domain/services/environment-mode-manager.d.ts +18 -0
  58. package/dist/domain/services/environment-mode-manager.d.ts.map +1 -0
  59. package/dist/domain/services/environment-mode-manager.js +37 -0
  60. package/dist/domain/services/environment-mode-manager.js.map +1 -0
  61. package/dist/domain/services/risk-tier-detector.d.ts +18 -0
  62. package/dist/domain/services/risk-tier-detector.d.ts.map +1 -0
  63. package/dist/domain/services/risk-tier-detector.js +65 -0
  64. package/dist/domain/services/risk-tier-detector.js.map +1 -0
  65. package/dist/formatter.d.ts.map +1 -1
  66. package/dist/formatter.js +10 -3
  67. package/dist/formatter.js.map +1 -1
  68. package/dist/index.js +103 -129
  69. package/dist/index.js.map +1 -1
  70. package/dist/infrastructure/ai/cohere-ai-service.d.ts.map +1 -1
  71. package/dist/infrastructure/ai/cohere-ai-service.js +15 -2
  72. package/dist/infrastructure/ai/cohere-ai-service.js.map +1 -1
  73. package/dist/infrastructure/ai/fake-ai-service.d.ts +22 -0
  74. package/dist/infrastructure/ai/fake-ai-service.d.ts.map +1 -0
  75. package/dist/infrastructure/ai/fake-ai-service.js +59 -0
  76. package/dist/infrastructure/ai/fake-ai-service.js.map +1 -0
  77. package/dist/infrastructure/ai/provider-ai-service.d.ts +59 -0
  78. package/dist/infrastructure/ai/provider-ai-service.d.ts.map +1 -0
  79. package/dist/infrastructure/ai/provider-ai-service.js +477 -0
  80. package/dist/infrastructure/ai/provider-ai-service.js.map +1 -0
  81. package/dist/infrastructure/cache/embedding-cache.d.ts +13 -1
  82. package/dist/infrastructure/cache/embedding-cache.d.ts.map +1 -1
  83. package/dist/infrastructure/cache/embedding-cache.js +80 -9
  84. package/dist/infrastructure/cache/embedding-cache.js.map +1 -1
  85. package/dist/infrastructure/cache/response-cache.d.ts +86 -0
  86. package/dist/infrastructure/cache/response-cache.d.ts.map +1 -0
  87. package/dist/infrastructure/cache/response-cache.js +224 -0
  88. package/dist/infrastructure/cache/response-cache.js.map +1 -0
  89. package/dist/infrastructure/context/conversation-context.d.ts +58 -0
  90. package/dist/infrastructure/context/conversation-context.d.ts.map +1 -0
  91. package/dist/infrastructure/context/conversation-context.js +170 -0
  92. package/dist/infrastructure/context/conversation-context.js.map +1 -0
  93. package/dist/infrastructure/context/session-manager.d.ts +26 -0
  94. package/dist/infrastructure/context/session-manager.d.ts.map +1 -0
  95. package/dist/infrastructure/context/session-manager.js +98 -0
  96. package/dist/infrastructure/context/session-manager.js.map +1 -0
  97. package/dist/infrastructure/cost/cost-tracker.d.ts +1 -0
  98. package/dist/infrastructure/cost/cost-tracker.d.ts.map +1 -1
  99. package/dist/infrastructure/cost/cost-tracker.js +12 -5
  100. package/dist/infrastructure/cost/cost-tracker.js.map +1 -1
  101. package/dist/infrastructure/governance/nist-ai-rmf.d.ts +6 -8
  102. package/dist/infrastructure/governance/nist-ai-rmf.d.ts.map +1 -1
  103. package/dist/infrastructure/governance/nist-ai-rmf.js +6 -8
  104. package/dist/infrastructure/governance/nist-ai-rmf.js.map +1 -1
  105. package/dist/infrastructure/governance/policy-as-code.d.ts +6 -8
  106. package/dist/infrastructure/governance/policy-as-code.d.ts.map +1 -1
  107. package/dist/infrastructure/governance/policy-as-code.js +6 -8
  108. package/dist/infrastructure/governance/policy-as-code.js.map +1 -1
  109. package/dist/infrastructure/governance/prompt-to-code-lineage.d.ts +7 -9
  110. package/dist/infrastructure/governance/prompt-to-code-lineage.d.ts.map +1 -1
  111. package/dist/infrastructure/governance/prompt-to-code-lineage.js +7 -9
  112. package/dist/infrastructure/governance/prompt-to-code-lineage.js.map +1 -1
  113. package/dist/infrastructure/providers/cohere-provider.d.ts +39 -0
  114. package/dist/infrastructure/providers/cohere-provider.d.ts.map +1 -0
  115. package/dist/infrastructure/providers/cohere-provider.js +359 -0
  116. package/dist/infrastructure/providers/cohere-provider.js.map +1 -0
  117. package/dist/infrastructure/providers/fake-provider.d.ts +43 -0
  118. package/dist/infrastructure/providers/fake-provider.d.ts.map +1 -0
  119. package/dist/infrastructure/providers/fake-provider.js +130 -0
  120. package/dist/infrastructure/providers/fake-provider.js.map +1 -0
  121. package/dist/infrastructure/providers/local-llm-provider.d.ts +49 -0
  122. package/dist/infrastructure/providers/local-llm-provider.d.ts.map +1 -0
  123. package/dist/infrastructure/providers/local-llm-provider.js +330 -0
  124. package/dist/infrastructure/providers/local-llm-provider.js.map +1 -0
  125. package/dist/infrastructure/providers/model-config.types.d.ts +70 -0
  126. package/dist/infrastructure/providers/model-config.types.d.ts.map +1 -0
  127. package/dist/infrastructure/providers/model-config.types.js +9 -0
  128. package/dist/infrastructure/providers/model-config.types.js.map +1 -0
  129. package/dist/infrastructure/providers/model-provider.interface.d.ts +113 -0
  130. package/dist/infrastructure/providers/model-provider.interface.d.ts.map +1 -0
  131. package/dist/infrastructure/providers/model-provider.interface.js +8 -0
  132. package/dist/infrastructure/providers/model-provider.interface.js.map +1 -0
  133. package/dist/infrastructure/providers/openai-provider.d.ts +38 -0
  134. package/dist/infrastructure/providers/openai-provider.d.ts.map +1 -0
  135. package/dist/infrastructure/providers/openai-provider.js +413 -0
  136. package/dist/infrastructure/providers/openai-provider.js.map +1 -0
  137. package/dist/infrastructure/providers/operation-provider-resolver.d.ts +48 -0
  138. package/dist/infrastructure/providers/operation-provider-resolver.d.ts.map +1 -0
  139. package/dist/infrastructure/providers/operation-provider-resolver.js +105 -0
  140. package/dist/infrastructure/providers/operation-provider-resolver.js.map +1 -0
  141. package/dist/infrastructure/providers/provider-config-loader.d.ts +37 -0
  142. package/dist/infrastructure/providers/provider-config-loader.d.ts.map +1 -0
  143. package/dist/infrastructure/providers/provider-config-loader.js +120 -0
  144. package/dist/infrastructure/providers/provider-config-loader.js.map +1 -0
  145. package/dist/infrastructure/providers/provider-registry.d.ts +53 -0
  146. package/dist/infrastructure/providers/provider-registry.d.ts.map +1 -0
  147. package/dist/infrastructure/providers/provider-registry.js +88 -0
  148. package/dist/infrastructure/providers/provider-registry.js.map +1 -0
  149. package/dist/infrastructure/storage/task-helpers.d.ts +58 -0
  150. package/dist/infrastructure/storage/task-helpers.d.ts.map +1 -0
  151. package/dist/infrastructure/storage/task-helpers.js +157 -0
  152. package/dist/infrastructure/storage/task-helpers.js.map +1 -0
  153. package/dist/infrastructure/storage/task-repository.d.ts +67 -0
  154. package/dist/infrastructure/storage/task-repository.d.ts.map +1 -0
  155. package/dist/infrastructure/storage/task-repository.js +205 -0
  156. package/dist/infrastructure/storage/task-repository.js.map +1 -0
  157. package/dist/infrastructure/ux/bi-directional-learning.d.ts +22 -0
  158. package/dist/infrastructure/ux/bi-directional-learning.d.ts.map +1 -1
  159. package/dist/infrastructure/ux/bi-directional-learning.js +144 -7
  160. package/dist/infrastructure/ux/bi-directional-learning.js.map +1 -1
  161. package/dist/infrastructure/ux/capability-boundaries.d.ts +50 -0
  162. package/dist/infrastructure/ux/capability-boundaries.d.ts.map +1 -0
  163. package/dist/infrastructure/ux/capability-boundaries.js +167 -0
  164. package/dist/infrastructure/ux/capability-boundaries.js.map +1 -0
  165. package/dist/infrastructure/ux/comprehensive-formatter.d.ts +63 -0
  166. package/dist/infrastructure/ux/comprehensive-formatter.d.ts.map +1 -0
  167. package/dist/infrastructure/ux/comprehensive-formatter.js +212 -0
  168. package/dist/infrastructure/ux/comprehensive-formatter.js.map +1 -0
  169. package/dist/infrastructure/ux/feedback-prompt.d.ts +42 -0
  170. package/dist/infrastructure/ux/feedback-prompt.d.ts.map +1 -0
  171. package/dist/infrastructure/ux/feedback-prompt.js +181 -0
  172. package/dist/infrastructure/ux/feedback-prompt.js.map +1 -0
  173. package/dist/infrastructure/ux/hitl-review-portal.d.ts.map +1 -1
  174. package/dist/infrastructure/ux/hitl-review-portal.js +4 -1
  175. package/dist/infrastructure/ux/hitl-review-portal.js.map +1 -1
  176. package/dist/infrastructure/ux/hitl-validation.d.ts +35 -0
  177. package/dist/infrastructure/ux/hitl-validation.d.ts.map +1 -1
  178. package/dist/infrastructure/ux/hitl-validation.js +86 -0
  179. package/dist/infrastructure/ux/hitl-validation.js.map +1 -1
  180. package/dist/infrastructure/ux/progress-indicator.d.ts +2 -1
  181. package/dist/infrastructure/ux/progress-indicator.d.ts.map +1 -1
  182. package/dist/infrastructure/ux/progress-indicator.js +13 -3
  183. package/dist/infrastructure/ux/progress-indicator.js.map +1 -1
  184. package/dist/infrastructure/ux/proportional-friction.d.ts +73 -0
  185. package/dist/infrastructure/ux/proportional-friction.d.ts.map +1 -0
  186. package/dist/infrastructure/ux/proportional-friction.js +200 -0
  187. package/dist/infrastructure/ux/proportional-friction.js.map +1 -0
  188. package/dist/infrastructure/validation/agent-feedback.d.ts +115 -0
  189. package/dist/infrastructure/validation/agent-feedback.d.ts.map +1 -0
  190. package/dist/infrastructure/validation/agent-feedback.js +227 -0
  191. package/dist/infrastructure/validation/agent-feedback.js.map +1 -0
  192. package/dist/infrastructure/validation/agent-validation-helper.d.ts +75 -0
  193. package/dist/infrastructure/validation/agent-validation-helper.d.ts.map +1 -0
  194. package/dist/infrastructure/validation/agent-validation-helper.js +88 -0
  195. package/dist/infrastructure/validation/agent-validation-helper.js.map +1 -0
  196. package/dist/infrastructure/validation/feedback-stats.d.ts +99 -0
  197. package/dist/infrastructure/validation/feedback-stats.d.ts.map +1 -0
  198. package/dist/infrastructure/validation/feedback-stats.js +173 -0
  199. package/dist/infrastructure/validation/feedback-stats.js.map +1 -0
  200. package/dist/infrastructure/validation/review-handler.d.ts +54 -0
  201. package/dist/infrastructure/validation/review-handler.d.ts.map +1 -0
  202. package/dist/infrastructure/validation/review-handler.js +206 -0
  203. package/dist/infrastructure/validation/review-handler.js.map +1 -0
  204. package/dist/infrastructure/validation/summary-aggregator.d.ts +42 -0
  205. package/dist/infrastructure/validation/summary-aggregator.d.ts.map +1 -0
  206. package/dist/infrastructure/validation/summary-aggregator.js +156 -0
  207. package/dist/infrastructure/validation/summary-aggregator.js.map +1 -0
  208. package/dist/infrastructure/validation/summary-extractor.d.ts +59 -0
  209. package/dist/infrastructure/validation/summary-extractor.d.ts.map +1 -0
  210. package/dist/infrastructure/validation/summary-extractor.js +102 -0
  211. package/dist/infrastructure/validation/summary-extractor.js.map +1 -0
  212. package/dist/infrastructure/validation/trace-summary.d.ts +72 -0
  213. package/dist/infrastructure/validation/trace-summary.d.ts.map +1 -0
  214. package/dist/infrastructure/validation/trace-summary.js +371 -0
  215. package/dist/infrastructure/validation/trace-summary.js.map +1 -0
  216. package/dist/infrastructure/validation/trust-config.d.ts +27 -0
  217. package/dist/infrastructure/validation/trust-config.d.ts.map +1 -0
  218. package/dist/infrastructure/validation/trust-config.js +113 -0
  219. package/dist/infrastructure/validation/trust-config.js.map +1 -0
  220. package/dist/infrastructure/xai/attention-visualizer.d.ts +6 -8
  221. package/dist/infrastructure/xai/attention-visualizer.d.ts.map +1 -1
  222. package/dist/infrastructure/xai/attention-visualizer.js +6 -8
  223. package/dist/infrastructure/xai/attention-visualizer.js.map +1 -1
  224. package/dist/infrastructure/xai/cot-visualizer.d.ts +6 -9
  225. package/dist/infrastructure/xai/cot-visualizer.d.ts.map +1 -1
  226. package/dist/infrastructure/xai/cot-visualizer.js +6 -9
  227. package/dist/infrastructure/xai/cot-visualizer.js.map +1 -1
  228. package/dist/infrastructure/xai/decision-tree-log.d.ts +6 -10
  229. package/dist/infrastructure/xai/decision-tree-log.d.ts.map +1 -1
  230. package/dist/infrastructure/xai/decision-tree-log.js +6 -10
  231. package/dist/infrastructure/xai/decision-tree-log.js.map +1 -1
  232. package/dist/infrastructure/xai/interactive-xai.d.ts +6 -8
  233. package/dist/infrastructure/xai/interactive-xai.d.ts.map +1 -1
  234. package/dist/infrastructure/xai/interactive-xai.js +6 -8
  235. package/dist/infrastructure/xai/interactive-xai.js.map +1 -1
  236. package/dist/infrastructure/xai/uncertainty-quantifier.d.ts +6 -9
  237. package/dist/infrastructure/xai/uncertainty-quantifier.d.ts.map +1 -1
  238. package/dist/infrastructure/xai/uncertainty-quantifier.js +6 -9
  239. package/dist/infrastructure/xai/uncertainty-quantifier.js.map +1 -1
  240. package/dist/presentation/cli/commands/ask-command.d.ts.map +1 -1
  241. package/dist/presentation/cli/commands/ask-command.js +84 -2
  242. package/dist/presentation/cli/commands/ask-command.js.map +1 -1
  243. package/dist/presentation/cli/commands/docs-command.d.ts +12 -0
  244. package/dist/presentation/cli/commands/docs-command.d.ts.map +1 -0
  245. package/dist/presentation/cli/commands/docs-command.js +196 -0
  246. package/dist/presentation/cli/commands/docs-command.js.map +1 -0
  247. package/dist/presentation/cli/commands/fix-command.d.ts +8 -0
  248. package/dist/presentation/cli/commands/fix-command.d.ts.map +1 -0
  249. package/dist/presentation/cli/commands/fix-command.js +309 -0
  250. package/dist/presentation/cli/commands/fix-command.js.map +1 -0
  251. package/dist/presentation/cli/commands/help-command.d.ts.map +1 -1
  252. package/dist/presentation/cli/commands/help-command.js +2 -0
  253. package/dist/presentation/cli/commands/help-command.js.map +1 -1
  254. package/dist/presentation/cli/commands/orchestrate-command.d.ts +1 -0
  255. package/dist/presentation/cli/commands/orchestrate-command.d.ts.map +1 -1
  256. package/dist/presentation/cli/commands/orchestrate-command.js +53 -0
  257. package/dist/presentation/cli/commands/orchestrate-command.js.map +1 -1
  258. package/dist/presentation/cli/commands/plan-command.d.ts +1 -0
  259. package/dist/presentation/cli/commands/plan-command.d.ts.map +1 -1
  260. package/dist/presentation/cli/commands/plan-command.js +80 -3
  261. package/dist/presentation/cli/commands/plan-command.js.map +1 -1
  262. package/dist/presentation/cli/commands/product-command.d.ts +12 -0
  263. package/dist/presentation/cli/commands/product-command.d.ts.map +1 -0
  264. package/dist/presentation/cli/commands/product-command.js +188 -0
  265. package/dist/presentation/cli/commands/product-command.js.map +1 -0
  266. package/dist/presentation/cli/commands/react-command.d.ts.map +1 -1
  267. package/dist/presentation/cli/commands/react-command.js +3 -1
  268. package/dist/presentation/cli/commands/react-command.js.map +1 -1
  269. package/dist/presentation/cli/commands/review-command.d.ts +14 -0
  270. package/dist/presentation/cli/commands/review-command.d.ts.map +1 -0
  271. package/dist/presentation/cli/commands/review-command.js +22 -0
  272. package/dist/presentation/cli/commands/review-command.js.map +1 -0
  273. package/dist/presentation/cli/commands/run-command.d.ts +15 -0
  274. package/dist/presentation/cli/commands/run-command.d.ts.map +1 -0
  275. package/dist/presentation/cli/commands/run-command.js +29 -0
  276. package/dist/presentation/cli/commands/run-command.js.map +1 -0
  277. package/dist/presentation/cli/commands/smart-command.d.ts +3 -1
  278. package/dist/presentation/cli/commands/smart-command.d.ts.map +1 -1
  279. package/dist/presentation/cli/commands/smart-command.js +92 -6
  280. package/dist/presentation/cli/commands/smart-command.js.map +1 -1
  281. package/dist/presentation/cli/commands/status-command.d.ts +11 -0
  282. package/dist/presentation/cli/commands/status-command.d.ts.map +1 -0
  283. package/dist/presentation/cli/commands/status-command.js +176 -0
  284. package/dist/presentation/cli/commands/status-command.js.map +1 -0
  285. package/dist/presentation/cli/commands/suggest-command.d.ts +13 -0
  286. package/dist/presentation/cli/commands/suggest-command.d.ts.map +1 -0
  287. package/dist/presentation/cli/commands/suggest-command.js +25 -0
  288. package/dist/presentation/cli/commands/suggest-command.js.map +1 -0
  289. package/dist/presentation/cli/error-display.d.ts.map +1 -1
  290. package/dist/presentation/cli/error-display.js +43 -0
  291. package/dist/presentation/cli/error-display.js.map +1 -1
  292. package/dist/session.js +19 -2
  293. package/dist/session.js.map +1 -1
  294. package/dist/ui.d.ts.map +1 -1
  295. package/dist/ui.js +8 -5
  296. package/dist/ui.js.map +1 -1
  297. package/package.json +10 -2
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Provider Layer: Provider Config Loader
3
+ * Loads user-facing provider configuration from JSON files
4
+ *
5
+ * Phase 4G: User-facing provider config files
6
+ */
7
+ import { existsSync, readFileSync } from 'fs';
8
+ import { join, resolve } from 'path';
9
+ import { findCodebaseRoot } from '../../domain/services/codebase-detector.js';
10
+ /**
11
+ * Load provider configuration from file
12
+ *
13
+ * @param options - Optional configuration
14
+ * @param options.cwd - Working directory (defaults to process.cwd())
15
+ * @returns ProviderConfig if file exists and is valid, undefined otherwise
16
+ */
17
+ export function loadProviderConfig(options) {
18
+ const cwd = options?.cwd || process.cwd();
19
+ // Determine config file path
20
+ let configPath;
21
+ // Check for explicit path override
22
+ if (process.env.CODEHERE_PROVIDER_CONFIG_PATH) {
23
+ configPath = resolve(process.env.CODEHERE_PROVIDER_CONFIG_PATH);
24
+ }
25
+ else {
26
+ // Find codebase root
27
+ const codebaseInfo = findCodebaseRoot(cwd);
28
+ if (codebaseInfo) {
29
+ // Default path: .codehere/providers.json
30
+ configPath = join(codebaseInfo.rootPath, '.codehere', 'providers.json');
31
+ }
32
+ else {
33
+ // Fallback to cwd if codebase root not found
34
+ configPath = join(cwd, '.codehere', 'providers.json');
35
+ }
36
+ }
37
+ // If file doesn't exist, return undefined (not an error)
38
+ if (!configPath || !existsSync(configPath)) {
39
+ return undefined;
40
+ }
41
+ try {
42
+ // Read and parse JSON
43
+ const fileContent = readFileSync(configPath, 'utf-8');
44
+ const rawConfig = JSON.parse(fileContent);
45
+ // Validate and normalize config
46
+ return validateAndNormalizeConfig(rawConfig);
47
+ }
48
+ catch (error) {
49
+ // Log warning but don't throw (non-fatal)
50
+ const errorMessage = error instanceof Error ? error.message : String(error);
51
+ console.warn(`[ProviderConfigLoader] Failed to load config from ${configPath}: ${errorMessage}`);
52
+ return undefined;
53
+ }
54
+ }
55
+ /**
56
+ * Validate and normalize raw config object
57
+ * Ignores unknown fields and invalid values gracefully
58
+ */
59
+ function validateAndNormalizeConfig(raw) {
60
+ if (!raw || typeof raw !== 'object') {
61
+ return undefined;
62
+ }
63
+ const config = {};
64
+ const obj = raw;
65
+ // Extract default provider
66
+ if (obj.default !== undefined) {
67
+ if (typeof obj.default === 'string' && obj.default.trim()) {
68
+ config.default = obj.default.trim();
69
+ }
70
+ }
71
+ // Extract operations
72
+ if (obj.operations !== undefined && typeof obj.operations === 'object' && obj.operations !== null) {
73
+ const operations = obj.operations;
74
+ const normalizedOps = {};
75
+ // Known operation types
76
+ const validOperations = ['chat', 'embedding', 'rerank'];
77
+ for (const op of validOperations) {
78
+ if (operations[op] !== undefined) {
79
+ const providerId = operations[op];
80
+ if (typeof providerId === 'string' && providerId.trim()) {
81
+ normalizedOps[op] = providerId.trim();
82
+ }
83
+ }
84
+ }
85
+ // Only set operations if at least one is valid
86
+ if (Object.keys(normalizedOps).length > 0) {
87
+ config.operations = normalizedOps;
88
+ }
89
+ }
90
+ // Return config only if it has at least one meaningful field
91
+ if (config.default || config.operations) {
92
+ return config;
93
+ }
94
+ return undefined;
95
+ }
96
+ /**
97
+ * Convert ProviderConfig to OperationProviderConfig
98
+ * Used to pass config to OperationProviderResolver
99
+ */
100
+ export function configToOperationConfig(config) {
101
+ const operationConfig = {};
102
+ // Set default if present
103
+ if (config.default) {
104
+ operationConfig.default = config.default;
105
+ }
106
+ // Map operations
107
+ if (config.operations) {
108
+ if (config.operations.chat) {
109
+ operationConfig.chat = config.operations.chat;
110
+ }
111
+ if (config.operations.embedding) {
112
+ operationConfig.embedding = config.operations.embedding;
113
+ }
114
+ if (config.operations.rerank) {
115
+ operationConfig.rerank = config.operations.rerank;
116
+ }
117
+ }
118
+ return operationConfig;
119
+ }
120
+ //# sourceMappingURL=provider-config-loader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-config-loader.js","sourceRoot":"","sources":["../../../src/infrastructure/providers/provider-config-loader.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,4CAA4C,CAAC;AAmB9E;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA0B;IAC3D,MAAM,GAAG,GAAG,OAAO,EAAE,GAAG,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IAE1C,6BAA6B;IAC7B,IAAI,UAA8B,CAAC;IAEnC,mCAAmC;IACnC,IAAI,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,CAAC;QAC9C,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IAClE,CAAC;SAAM,CAAC;QACN,qBAAqB;QACrB,MAAM,YAAY,GAAG,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAC3C,IAAI,YAAY,EAAE,CAAC;YACjB,yCAAyC;YACzC,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,WAAW,EAAE,gBAAg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AAM,CAAC,OAAO,CAAC;IAC3C,CAAC;IAED,iBAAiB;IACjB,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACtB,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;YAC3B,eAAe,CAAC,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC;QAChD,CAAC;QACD,IAAI,MAAM,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;YAChC,eAAe,CAAC,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC;QAC1D,CAAC;QACD,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YAC7B,eAAe,CAAC,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC;QACpD,CAAC;IACH,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Provider Layer: ProviderRegistry
3
+ * Central registry for all model providers
4
+ *
5
+ * Phase 4A: Foundation Implementation (No Behavior Change)
6
+ */
7
+ import type { IModelProvider } from './model-provider.interface.js';
8
+ /**
9
+ * Provider Registry
10
+ * Singleton registry for managing model providers
11
+ */
12
+ export declare class ProviderRegistry {
13
+ private static instance;
14
+ private providers;
15
+ private defaultProviderId?;
16
+ /**
17
+ * Get singleton instance
18
+ */
19
+ static getInstance(): ProviderRegistry;
20
+ /**
21
+ * Register a provider
22
+ */
23
+ register(provider: IModelProvider): void;
24
+ /**
25
+ * Get provider by ID
26
+ */
27
+ get(providerId: string): IModelProvider | undefined;
28
+ /**
29
+ * Get default provider
30
+ */
31
+ getDefault(): IModelProvider;
32
+ /**
33
+ * Set default provider
34
+ */
35
+ setDefault(providerId: string): void;
36
+ /**
37
+ * Get all registered providers
38
+ */
39
+ getAll(): IModelProvider[];
40
+ /**
41
+ * Find providers by capability
42
+ */
43
+ findByCapability(capability: keyof import('./model-provider.interface.js').ProviderCapabilities): IModelProvider[];
44
+ /**
45
+ * Check if provider is registered
46
+ */
47
+ has(providerId: string): boolean;
48
+ /**
49
+ * Clear all providers (mainly for testing)
50
+ */
51
+ clear(): void;
52
+ }
53
+ //# sourceMappingURL=provider-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-registry.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/providers/provider-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAEpE;;;GAGG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAiC;IACxD,OAAO,CAAC,SAAS,CAA0C;IAC3D,OAAO,CAAC,iBAAiB,CAAC,CAAS;IAEnC;;OAEG;IACH,MAAM,CAAC,WAAW,IAAI,gBAAgB;IAOtC;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IASxC;;OAEG;IACH,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS;IAInD;;OAEG;IACH,UAAU,IAAI,cAAc;IAW5B;;OAEG;IACH,UAAU,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAOpC;;OAEG;IACH,MAAM,IAAI,cAAc,EAAE;IAI1B;;OAEG;IACH,gBAAgB,CAAC,UAAU,EAAE,MAAM,OAAO,+BAA+B,EAAE,oBAAoB,GAAG,cAAc,EAAE;IAIlH;;OAEG;IACH,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAIhC;;OAEG;IACH,KAAK,IAAI,IAAI;CAId"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Provider Layer: ProviderRegistry
3
+ * Central registry for all model providers
4
+ *
5
+ * Phase 4A: Foundation Implementation (No Behavior Change)
6
+ */
7
+ /**
8
+ * Provider Registry
9
+ * Singleton registry for managing model providers
10
+ */
11
+ export class ProviderRegistry {
12
+ static instance = null;
13
+ providers = new Map();
14
+ defaultProviderId;
15
+ /**
16
+ * Get singleton instance
17
+ */
18
+ static getInstance() {
19
+ if (!ProviderRegistry.instance) {
20
+ ProviderRegistry.instance = new ProviderRegistry();
21
+ }
22
+ return ProviderRegistry.instance;
23
+ }
24
+ /**
25
+ * Register a provider
26
+ */
27
+ register(provider) {
28
+ this.providers.set(provider.id, provider);
29
+ // Auto-set as default if this is the first provider
30
+ if (!this.defaultProviderId) {
31
+ this.defaultProviderId = provider.id;
32
+ }
33
+ }
34
+ /**
35
+ * Get provider by ID
36
+ */
37
+ get(providerId) {
38
+ return this.providers.get(providerId);
39
+ }
40
+ /**
41
+ * Get default provider
42
+ */
43
+ getDefault() {
44
+ if (!this.defaultProviderId) {
45
+ throw new Error('No default provider configured');
46
+ }
47
+ const provider = this.get(this.defaultProviderId);
48
+ if (!provider) {
49
+ throw new Error(`Default provider '${this.defaultProviderId}' not found`);
50
+ }
51
+ return provider;
52
+ }
53
+ /**
54
+ * Set default provider
55
+ */
56
+ setDefault(providerId) {
57
+ if (!this.providers.has(providerId)) {
58
+ throw new Error(`Provider '${providerId}' not registered`);
59
+ }
60
+ this.defaultProviderId = providerId;
61
+ }
62
+ /**
63
+ * Get all registered providers
64
+ */
65
+ getAll() {
66
+ return Array.from(this.providers.values());
67
+ }
68
+ /**
69
+ * Find providers by capability
70
+ */
71
+ findByCapability(capability) {
72
+ return this.getAll().filter(p => p.capabilities[capability]);
73
+ }
74
+ /**
75
+ * Check if provider is registered
76
+ */
77
+ has(providerId) {
78
+ return this.providers.has(providerId);
79
+ }
80
+ /**
81
+ * Clear all providers (mainly for testing)
82
+ */
83
+ clear() {
84
+ this.providers.clear();
85
+ this.defaultProviderId = undefined;
86
+ }
87
+ }
88
+ //# sourceMappingURL=provider-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-registry.js","sourceRoot":"","sources":["../../../src/infrastructure/providers/provider-registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH;;;GAGG;AACH,MAAM,OAAO,gBAA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AAC,aAAa,UAAU,kBAAkB,CAAC,CAAC;QAC7D,CAAC;QACD,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED;;OAEG;IACH,gBAAgB,CAAC,UAA8E;QAC7F,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,UAAkB;QACpB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;IACxC,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACvB,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;IACrC,CAAC"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Infrastructure: Task Helpers
3
+ * Helper functions for creating and updating tasks (non-breaking)
4
+ *
5
+ * Phase 1: v0.5.0-alpha
6
+ * See: docs/ARCHITECTURE/TASK_MODEL.md
7
+ */
8
+ import { TaskStatus, ReviewStatus, type CodehereTask } from '../../domain/entities/task.js';
9
+ import type { CodebaseInfo } from '../../domain/services/codebase-detector.js';
10
+ /**
11
+ * Create task for plan command
12
+ * Non-breaking: silent failure, doesn't affect user workflow
13
+ */
14
+ export declare function createPlanTask(options: {
15
+ goal: string;
16
+ plan: any;
17
+ codebaseInfo: CodebaseInfo | null;
18
+ runId: string;
19
+ }): Promise<string | null>;
20
+ /**
21
+ * Create task for fix/run command
22
+ * Non-breaking: silent failure, doesn't affect user workflow
23
+ */
24
+ export declare function createRunTask(options: {
25
+ goal: string;
26
+ filePath?: string;
27
+ codebaseInfo: CodebaseInfo | null;
28
+ runId: string;
29
+ files?: string[];
30
+ }): Promise<string | null>;
31
+ /**
32
+ * Update task status
33
+ * Non-breaking: silent failure
34
+ */
35
+ export declare function updateTaskStatus(taskId: string | null, status: TaskStatus, updates?: Partial<CodehereTask>): Promise<void>;
36
+ /**
37
+ * Update task with execution results
38
+ * Non-breaking: silent failure
39
+ */
40
+ export declare function updateTaskWithResults(taskId: string | null, results: {
41
+ filesChanged?: string[];
42
+ filesCreated?: string[];
43
+ filesDeleted?: string[];
44
+ testResults?: any;
45
+ sastResults?: any;
46
+ error?: any;
47
+ status: TaskStatus;
48
+ executionCompletedAt?: number;
49
+ executionStartedAt?: number;
50
+ agentFeedbackId?: string;
51
+ traceSummaryId?: string;
52
+ }): Promise<void>;
53
+ /**
54
+ * Update task review status
55
+ * Non-breaking: silent failure
56
+ */
57
+ export declare function updateTaskReview(taskId: string | null, reviewStatus: ReviewStatus, reviewedBy?: string, comments?: string): Promise<void>;
58
+ //# sourceMappingURL=task-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-helpers.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/storage/task-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAY,UAAU,EAA6B,YAAY,EAAE,KAAK,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAIjI,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4CAA4C,CAAC;AAE/E;;;GAGG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE;IAC5C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,GAAG,CAAC;IACV,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CA+BzB;AAED;;;GAGG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,YAAY,GAAG,IAAI,CAAC;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAgCzB;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,MAAM,EAAE,UAAU,EAClB,OAAO,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAC9B,OAAO,CAAC,IAAI,CAAC,CAiBf;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,OAAO,EAAE;IACP,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,KAAK,CAAC,EAAE,GAAG,CAAC;IACZ,MAAM,EAAE,UAAU,CAAC;IACnB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,GACA,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,GAAG,IAAI,EACrB,YAAY,EAAE,YAAY,EAC1B,UAAU,CAAC,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CA0Bf"}
@@ -0,0 +1,157 @@
1
+ /**
2
+ * Infrastructure: Task Helpers
3
+ * Helper functions for creating and updating tasks (non-breaking)
4
+ *
5
+ * Phase 1: v0.5.0-alpha
6
+ * See: docs/ARCHITECTURE/TASK_MODEL.md
7
+ */
8
+ import { getTaskRepository } from './task-repository.js';
9
+ import { TaskMode, TaskStatus, ReviewStatus } from '../../domain/entities/task.js';
10
+ import { getCurrentEnvironmentMode } from '../../domain/services/environment-mode-manager.js';
11
+ import { detectRiskTier, detectRiskTierFromPlan } from '../../domain/services/risk-tier-detector.js';
12
+ import { randomUUID } from 'crypto';
13
+ /**
14
+ * Create task for plan command
15
+ * Non-breaking: silent failure, doesn't affect user workflow
16
+ */
17
+ export async function createPlanTask(options) {
18
+ const { goal, plan, codebaseInfo, runId } = options;
19
+ try {
20
+ const taskRepo = getTaskRepository();
21
+ const environment = getCurrentEnvironmentMode();
22
+ const riskTier = detectRiskTierFromPlan(plan);
23
+ const taskId = `task-${randomUUID()}`;
24
+ await taskRepo.create({
25
+ id: taskId,
26
+ createdAt: Date.now(),
27
+ updatedAt: Date.now(),
28
+ codebaseId: codebaseInfo?.codebaseId || codebaseInfo?.rootPath || process.cwd(),
29
+ cwd: process.cwd(),
30
+ mode: TaskMode.PLAN,
31
+ goal,
32
+ command: 'plan',
33
+ status: TaskStatus.PLANNED,
34
+ riskTier,
35
+ environment,
36
+ planId: plan.id,
37
+ plan: plan, // Store serialized plan
38
+ traceSummaryId: runId,
39
+ });
40
+ return taskId;
41
+ }
42
+ catch {
43
+ // Silent failure - task creation is optional
44
+ return null;
45
+ }
46
+ }
47
+ /**
48
+ * Create task for fix/run command
49
+ * Non-breaking: silent failure, doesn't affect user workflow
50
+ */
51
+ export async function createRunTask(options) {
52
+ const { goal, filePath, codebaseInfo, runId, files = [] } = options;
53
+ try {
54
+ const taskRepo = getTaskRepository();
55
+ const environment = getCurrentEnvironmentMode();
56
+ const riskTier = detectRiskTier(files);
57
+ const taskId = `task-${randomUUID()}`;
58
+ const fullGoal = filePath ? `${goal} (file: ${filePath})` : goal;
59
+ await taskRepo.create({
60
+ id: taskId,
61
+ createdAt: Date.now(),
62
+ updatedAt: Date.now(),
63
+ codebaseId: codebaseInfo?.codebaseId || codebaseInfo?.rootPath || process.cwd(),
64
+ cwd: process.cwd(),
65
+ mode: TaskMode.RUN,
66
+ goal: fullGoal,
67
+ command: filePath ? 'fix' : 'run',
68
+ status: TaskStatus.CREATED,
69
+ riskTier,
70
+ environment,
71
+ filesChanged: files.length > 0 ? files : undefined,
72
+ traceSummaryId: runId,
73
+ });
74
+ return taskId;
75
+ }
76
+ catch {
77
+ // Silent failure - task creation is optional
78
+ return null;
79
+ }
80
+ }
81
+ /**
82
+ * Update task status
83
+ * Non-breaking: silent failure
84
+ */
85
+ export async function updateTaskStatus(taskId, status, updates) {
86
+ if (!taskId)
87
+ return;
88
+ try {
89
+ const taskRepo = getTaskRepository();
90
+ const existing = await taskRepo.getById(taskId);
91
+ if (!existing)
92
+ return;
93
+ await taskRepo.update({
94
+ ...existing,
95
+ ...updates,
96
+ status,
97
+ updatedAt: Date.now(),
98
+ });
99
+ }
100
+ catch {
101
+ // Silent failure
102
+ }
103
+ }
104
+ /**
105
+ * Update task with execution results
106
+ * Non-breaking: silent failure
107
+ */
108
+ export async function updateTaskWithResults(taskId, results) {
109
+ if (!taskId)
110
+ return;
111
+ try {
112
+ const taskRepo = getTaskRepository();
113
+ const existing = await taskRepo.getById(taskId);
114
+ if (!existing)
115
+ return;
116
+ await taskRepo.update({
117
+ ...existing,
118
+ ...results,
119
+ updatedAt: Date.now(),
120
+ });
121
+ }
122
+ catch {
123
+ // Silent failure
124
+ }
125
+ }
126
+ /**
127
+ * Update task review status
128
+ * Non-breaking: silent failure
129
+ */
130
+ export async function updateTaskReview(taskId, reviewStatus, reviewedBy, comments) {
131
+ if (!taskId)
132
+ return;
133
+ try {
134
+ const taskRepo = getTaskRepository();
135
+ const existing = await taskRepo.getById(taskId);
136
+ if (!existing)
137
+ return;
138
+ const newStatus = reviewStatus === ReviewStatus.APPROVED
139
+ ? TaskStatus.APPROVED
140
+ : reviewStatus === ReviewStatus.REJECTED
141
+ ? TaskStatus.REJECTED
142
+ : existing.status;
143
+ await taskRepo.update({
144
+ ...existing,
145
+ reviewStatus,
146
+ reviewedAt: Date.now(),
147
+ reviewedBy,
148
+ reviewComments: comments,
149
+ status: newStatus,
150
+ updatedAt: Date.now(),
151
+ });
152
+ }
153
+ catch {
154
+ // Silent failure
155
+ }
156
+ }
157
+ //# sourceMappingURL=task-helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-helpers.js","sourceRoot":"","sources":["../../../src/infrastructure/storage/task-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAA6B,YAAY,EAAqB,MAAM,+BAA+B,CAAC;AACjI,OAAO,EAAE,yBAAyB,EAAE,MAAM,mDAAmD,CAAC;AAC9F,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAC;AACrG,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGpC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,OAKpC;IACC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAEpD,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,iBAAiB,EAAE,CAAC;QACrC,MAAM,WAAW,GAAG,yBAAyB,EAAE,CAAC;QAChD,MAAM,QAAQ,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;QAE9C,MAAM,MAAM,GAAG,QAAQ,UAAU,EAAE,EAAE,CAAC;QACtC,MAAM,QAAQ,CAAC,MAAM,CAAC;YACpB,EAAE,EAAE,MAAM;YACV,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;YACrB,UAAU,EAAE,YAAY,EAAE,UAAU,IAAI,YAAY,EAAE,QAAQ,IAAI,OAAO,CAAC,GAAG,EAAE;YAC/E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C;YACpB,GAAG,QAAQ;YACX,GAAG,OAAO;YACV,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,iBAAiB;IACnB,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAAqB,EACrB,YAA0B,EAC1B,UAAmB,EACnB,QAAiB;IAEjB,IAAI,CAAC,MAAM;QAAE,OAAO;IAEpB,IAAI,CAAC;QACH,MAAM,QAAQ,GAAG,iBAAiB,EAAE,CAAC;QACrC,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QAChD,IAAI,CAAC,QAAQ;YAAE,OAAO;QAEtB,MAAM,SAAS,GAAG,YAAY,KAAK,YAAY,CAAC,QAAQ;YACtD,CAAC,CAAC,UAAU,CAAC,QAAQ;YACrB,CAAC,CAAC,YAAY,KAAK,YAAY,CAAC,QAAQ;gBACxC,CAAC,CAAC,UAAU,CAAC,QAAQ;gBACrB,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC;QAEpB,MAAM,QAAQ,CAAC,MAAM,CAAC;YACpB,GAAG,QAAQ;YACX,YAAY;YACZ,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;YACtB,UAAU;YACV,cAAc,EAAE,QAAQ;YACxB,MAAM,EAAE,SAAS;YACjB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;SACtB,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,iBAAiB;IACnB,CAAC;AACH,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Infrastructure: Task Repository
3
+ * Task storage and retrieval using JSONL format
4
+ *
5
+ * Phase 1: v0.5.0-alpha
6
+ * See: docs/ARCHITECTURE/TASK_MODEL.md section 3
7
+ */
8
+ import type { CodehereTask } from '../../domain/entities/task.js';
9
+ import { TaskStatus, TaskMode } from '../../domain/entities/task.js';
10
+ export interface TaskRepository {
11
+ create(task: CodehereTask): Promise<void>;
12
+ getById(id: string): Promise<CodehereTask | null>;
13
+ getByStatus(status: TaskStatus): Promise<CodehereTask[]>;
14
+ getByMode(mode: TaskMode): Promise<CodehereTask[]>;
15
+ getRecent(limit: number): Promise<CodehereTask[]>;
16
+ update(task: CodehereTask): Promise<void>;
17
+ getAll(): Promise<CodehereTask[]>;
18
+ }
19
+ /**
20
+ * JSONL-based task repository
21
+ * Stores tasks in .codehere/tasks.jsonl at codebase root
22
+ */
23
+ export declare class JsonlTaskRepository implements TaskRepository {
24
+ private tasksPath;
25
+ private tasksCache;
26
+ private cacheLoaded;
27
+ constructor(customPath?: string);
28
+ /**
29
+ * Load tasks from JSONL file into cache
30
+ * For duplicate IDs, keeps the latest version (by updatedAt)
31
+ */
32
+ private loadTasks;
33
+ /**
34
+ * Create a new task
35
+ */
36
+ create(task: CodehereTask): Promise<void>;
37
+ /**
38
+ * Get task by ID (returns latest version if multiple exist)
39
+ */
40
+ getById(id: string): Promise<CodehereTask | null>;
41
+ /**
42
+ * Get tasks by status
43
+ */
44
+ getByStatus(status: TaskStatus): Promise<CodehereTask[]>;
45
+ /**
46
+ * Get tasks by mode
47
+ */
48
+ getByMode(mode: TaskMode): Promise<CodehereTask[]>;
49
+ /**
50
+ * Get recent tasks (latest updated first)
51
+ */
52
+ getRecent(limit?: number): Promise<CodehereTask[]>;
53
+ /**
54
+ * Get all tasks (latest version of each)
55
+ */
56
+ getAll(): Promise<CodehereTask[]>;
57
+ /**
58
+ * Update existing task
59
+ * Creates a new entry in JSONL (append-only)
60
+ */
61
+ update(task: CodehereTask): Promise<void>;
62
+ }
63
+ /**
64
+ * Get task repository instance
65
+ */
66
+ export declare function getTaskRepository(customPath?: string): TaskRepository;
67
+ //# sourceMappingURL=task-repository.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"task-repository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/storage/task-repository.ts"],"names":[],"m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