codehere 0.5.1-alpha → 0.5.3-alpha

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 (375) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +126 -102
  3. package/dist/application/agents/execution-agent.js +2 -2
  4. package/dist/application/agents/multi-agent-orchestrator.d.ts +0 -1
  5. package/dist/application/agents/multi-agent-orchestrator.d.ts.map +1 -1
  6. package/dist/application/agents/multi-agent-orchestrator.js +2 -9
  7. package/dist/application/agents/multi-agent-orchestrator.js.map +1 -1
  8. package/dist/application/agents/planning-agent.d.ts.map +1 -1
  9. package/dist/application/agents/planning-agent.js +11 -15
  10. package/dist/application/agents/planning-agent.js.map +1 -1
  11. package/dist/application/services/context-importer.d.ts +71 -0
  12. package/dist/application/services/context-importer.d.ts.map +1 -0
  13. package/dist/application/services/context-importer.js +436 -0
  14. package/dist/application/services/context-importer.js.map +1 -0
  15. package/dist/application/services/context-manager.d.ts +132 -0
  16. package/dist/application/services/context-manager.d.ts.map +1 -0
  17. package/dist/application/services/context-manager.js +369 -0
  18. package/dist/application/services/context-manager.js.map +1 -0
  19. package/dist/application/services/dependency-container.d.ts.map +1 -1
  20. package/dist/application/services/dependency-container.js +7 -5
  21. package/dist/application/services/dependency-container.js.map +1 -1
  22. package/dist/application/services/intelligent-router.d.ts +8 -5
  23. package/dist/application/services/intelligent-router.d.ts.map +1 -1
  24. package/dist/application/services/intelligent-router.js +78 -82
  25. package/dist/application/services/intelligent-router.js.map +1 -1
  26. package/dist/application/services/token-counting-service.d.ts +87 -0
  27. package/dist/application/services/token-counting-service.d.ts.map +1 -0
  28. package/dist/application/services/token-counting-service.js +196 -0
  29. package/dist/application/services/token-counting-service.js.map +1 -0
  30. package/dist/application/use-cases/ask-question-use-case.d.ts.map +1 -1
  31. package/dist/application/use-cases/ask-question-use-case.js +109 -21
  32. package/dist/application/use-cases/ask-question-use-case.js.map +1 -1
  33. package/dist/application/use-cases/edit-file-use-case.d.ts.map +1 -1
  34. package/dist/application/use-cases/edit-file-use-case.js +19 -0
  35. package/dist/application/use-cases/edit-file-use-case.js.map +1 -1
  36. package/dist/application/use-cases/planning-use-case.d.ts +1 -14
  37. package/dist/application/use-cases/planning-use-case.d.ts.map +1 -1
  38. package/dist/application/use-cases/planning-use-case.js +2 -109
  39. package/dist/application/use-cases/planning-use-case.js.map +1 -1
  40. package/dist/chat.d.ts.map +1 -1
  41. package/dist/chat.js +6 -17
  42. package/dist/chat.js.map +1 -1
  43. package/dist/domain/entities/conversation-context.d.ts +245 -0
  44. package/dist/domain/entities/conversation-context.d.ts.map +1 -0
  45. package/dist/domain/entities/conversation-context.js +50 -0
  46. package/dist/domain/entities/conversation-context.js.map +1 -0
  47. package/dist/domain/entities/memory.d.ts.map +1 -1
  48. package/dist/domain/interfaces/context-repository.interface.d.ts +71 -0
  49. package/dist/domain/interfaces/context-repository.interface.d.ts.map +1 -0
  50. package/dist/domain/interfaces/context-repository.interface.js +10 -0
  51. package/dist/domain/interfaces/context-repository.interface.js.map +1 -0
  52. package/dist/domain/services/query-intent-classifier.d.ts.map +1 -1
  53. package/dist/domain/services/query-intent-classifier.js +37 -23
  54. package/dist/domain/services/query-intent-classifier.js.map +1 -1
  55. package/dist/embed.d.ts.map +1 -1
  56. package/dist/embed.js +8 -3
  57. package/dist/embed.js.map +1 -1
  58. package/dist/index.js +267 -143
  59. package/dist/index.js.map +1 -1
  60. package/dist/infrastructure/ai/cohere-ai-service.d.ts.map +1 -1
  61. package/dist/infrastructure/ai/cohere-ai-service.js +14 -5
  62. package/dist/infrastructure/ai/cohere-ai-service.js.map +1 -1
  63. package/dist/infrastructure/ai/provider-ai-service.d.ts.map +1 -1
  64. package/dist/infrastructure/ai/provider-ai-service.js +64 -14
  65. package/dist/infrastructure/ai/provider-ai-service.js.map +1 -1
  66. package/dist/infrastructure/config/config-manager.d.ts +78 -9
  67. package/dist/infrastructure/config/config-manager.d.ts.map +1 -1
  68. package/dist/infrastructure/config/config-manager.js +127 -9
  69. package/dist/infrastructure/config/config-manager.js.map +1 -1
  70. package/dist/infrastructure/context/conversation-context.d.ts +39 -12
  71. package/dist/infrastructure/context/conversation-context.d.ts.map +1 -1
  72. package/dist/infrastructure/context/conversation-context.js +91 -4
  73. package/dist/infrastructure/context/conversation-context.js.map +1 -1
  74. package/dist/infrastructure/context/direct-context-provider.d.ts +18 -0
  75. package/dist/infrastructure/context/direct-context-provider.d.ts.map +1 -0
  76. package/dist/infrastructure/context/direct-context-provider.js +222 -0
  77. package/dist/infrastructure/context/direct-context-provider.js.map +1 -0
  78. package/dist/infrastructure/context/git-context-provider.d.ts +30 -0
  79. package/dist/infrastructure/context/git-context-provider.d.ts.map +1 -0
  80. package/dist/infrastructure/context/git-context-provider.js +140 -0
  81. package/dist/infrastructure/context/git-context-provider.js.map +1 -0
  82. package/dist/infrastructure/context/project-context-loader.d.ts +35 -0
  83. package/dist/infrastructure/context/project-context-loader.d.ts.map +1 -0
  84. package/dist/infrastructure/context/project-context-loader.js +184 -0
  85. package/dist/infrastructure/context/project-context-loader.js.map +1 -0
  86. package/dist/infrastructure/cost/cost-tracker.d.ts.map +1 -1
  87. package/dist/infrastructure/cost/cost-tracker.js +3 -2
  88. package/dist/infrastructure/cost/cost-tracker.js.map +1 -1
  89. package/dist/infrastructure/cost/session-token-tracker.d.ts +68 -0
  90. package/dist/infrastructure/cost/session-token-tracker.d.ts.map +1 -0
  91. package/dist/infrastructure/cost/session-token-tracker.js +178 -0
  92. package/dist/infrastructure/cost/session-token-tracker.js.map +1 -0
  93. package/dist/infrastructure/index.d.ts +1 -0
  94. package/dist/infrastructure/index.d.ts.map +1 -1
  95. package/dist/infrastructure/index.js +1 -2
  96. package/dist/infrastructure/index.js.map +1 -1
  97. package/dist/infrastructure/observability/execution-tracer.d.ts +21 -0
  98. package/dist/infrastructure/observability/execution-tracer.d.ts.map +1 -1
  99. package/dist/infrastructure/observability/execution-tracer.js +157 -4
  100. package/dist/infrastructure/observability/execution-tracer.js.map +1 -1
  101. package/dist/infrastructure/protocols/a2a-metadata.js +1 -1
  102. package/dist/infrastructure/protocols/mcp-oauth.js +1 -1
  103. package/dist/infrastructure/providers/cohere-provider.d.ts +1 -2
  104. package/dist/infrastructure/providers/cohere-provider.d.ts.map +1 -1
  105. package/dist/infrastructure/providers/cohere-provider.js +44 -42
  106. package/dist/infrastructure/providers/cohere-provider.js.map +1 -1
  107. package/dist/infrastructure/providers/fake-provider.d.ts.map +1 -1
  108. package/dist/infrastructure/providers/fake-provider.js +8 -0
  109. package/dist/infrastructure/providers/fake-provider.js.map +1 -1
  110. package/dist/infrastructure/providers/local-llm-provider.d.ts.map +1 -1
  111. package/dist/infrastructure/providers/local-llm-provider.js +8 -2
  112. package/dist/infrastructure/providers/local-llm-provider.js.map +1 -1
  113. package/dist/infrastructure/providers/openai-provider.d.ts.map +1 -1
  114. package/dist/infrastructure/providers/openai-provider.js +40 -7
  115. package/dist/infrastructure/providers/openai-provider.js.map +1 -1
  116. package/dist/infrastructure/providers/openrouter-provider.d.ts.map +1 -1
  117. package/dist/infrastructure/providers/openrouter-provider.js +13 -7
  118. package/dist/infrastructure/providers/openrouter-provider.js.map +1 -1
  119. package/dist/infrastructure/security/enhanced-security-gate.d.ts +13 -0
  120. package/dist/infrastructure/security/enhanced-security-gate.d.ts.map +1 -1
  121. package/dist/infrastructure/security/enhanced-security-gate.js +56 -1
  122. package/dist/infrastructure/security/enhanced-security-gate.js.map +1 -1
  123. package/dist/infrastructure/security/input-validator.d.ts +17 -0
  124. package/dist/infrastructure/security/input-validator.d.ts.map +1 -1
  125. package/dist/infrastructure/security/input-validator.js +140 -25
  126. package/dist/infrastructure/security/input-validator.js.map +1 -1
  127. package/dist/infrastructure/storage/embeddings-path.d.ts.map +1 -1
  128. package/dist/infrastructure/storage/embeddings-path.js +14 -4
  129. package/dist/infrastructure/storage/embeddings-path.js.map +1 -1
  130. package/dist/infrastructure/storage/memory-stream-service.d.ts.map +1 -1
  131. package/dist/infrastructure/storage/memory-stream-service.js +58 -88
  132. package/dist/infrastructure/storage/memory-stream-service.js.map +1 -1
  133. package/dist/infrastructure/storage/plan-repository.d.ts.map +1 -1
  134. package/dist/infrastructure/storage/plan-repository.js +4 -5
  135. package/dist/infrastructure/storage/plan-repository.js.map +1 -1
  136. package/dist/infrastructure/storage/sqlite-context-repository.d.ts +95 -0
  137. package/dist/infrastructure/storage/sqlite-context-repository.d.ts.map +1 -0
  138. package/dist/infrastructure/storage/sqlite-context-repository.js +467 -0
  139. package/dist/infrastructure/storage/sqlite-context-repository.js.map +1 -0
  140. package/dist/infrastructure/storage/sqlite-decision-repository.d.ts.map +1 -1
  141. package/dist/infrastructure/storage/sqlite-decision-repository.js +4 -8
  142. package/dist/infrastructure/storage/sqlite-decision-repository.js.map +1 -1
  143. package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.d.ts.map +1 -1
  144. package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.js +4 -8
  145. package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.js.map +1 -1
  146. package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.d.ts.map +1 -1
  147. package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.js +4 -8
  148. package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.js.map +1 -1
  149. package/dist/infrastructure/storage/sqlite-memory-repository.d.ts.map +1 -1
  150. package/dist/infrastructure/storage/sqlite-memory-repository.js +4 -8
  151. package/dist/infrastructure/storage/sqlite-memory-repository.js.map +1 -1
  152. package/dist/infrastructure/storage/sqlite-pattern-repository.d.ts.map +1 -1
  153. package/dist/infrastructure/storage/sqlite-pattern-repository.js +4 -8
  154. package/dist/infrastructure/storage/sqlite-pattern-repository.js.map +1 -1
  155. package/dist/infrastructure/storage/task-repository.d.ts +0 -1
  156. package/dist/infrastructure/storage/task-repository.d.ts.map +1 -1
  157. package/dist/infrastructure/storage/task-repository.js +2 -13
  158. package/dist/infrastructure/storage/task-repository.js.map +1 -1
  159. package/dist/infrastructure/ux/cli-style-guide.d.ts +105 -0
  160. package/dist/infrastructure/ux/cli-style-guide.d.ts.map +1 -0
  161. package/dist/infrastructure/ux/cli-style-guide.js +220 -0
  162. package/dist/infrastructure/ux/cli-style-guide.js.map +1 -0
  163. package/dist/infrastructure/ux/progress-indicator.d.ts +49 -10
  164. package/dist/infrastructure/ux/progress-indicator.d.ts.map +1 -1
  165. package/dist/infrastructure/ux/progress-indicator.js +112 -9
  166. package/dist/infrastructure/ux/progress-indicator.js.map +1 -1
  167. package/dist/infrastructure/validation/agent-feedback.d.ts +14 -1
  168. package/dist/infrastructure/validation/agent-feedback.d.ts.map +1 -1
  169. package/dist/infrastructure/validation/agent-feedback.js +57 -3
  170. package/dist/infrastructure/validation/agent-feedback.js.map +1 -1
  171. package/dist/parallel-processor.d.ts.map +1 -1
  172. package/dist/parallel-processor.js +39 -11
  173. package/dist/parallel-processor.js.map +1 -1
  174. package/dist/presentation/cli/commands/ask-command.d.ts +1 -2
  175. package/dist/presentation/cli/commands/ask-command.d.ts.map +1 -1
  176. package/dist/presentation/cli/commands/ask-command.js +66 -150
  177. package/dist/presentation/cli/commands/ask-command.js.map +1 -1
  178. package/dist/presentation/cli/commands/audit-command.d.ts +13 -0
  179. package/dist/presentation/cli/commands/audit-command.d.ts.map +1 -0
  180. package/dist/presentation/cli/commands/audit-command.js +96 -0
  181. package/dist/presentation/cli/commands/audit-command.js.map +1 -0
  182. package/dist/presentation/cli/commands/config-command.d.ts.map +1 -1
  183. package/dist/presentation/cli/commands/config-command.js +2 -14
  184. package/dist/presentation/cli/commands/config-command.js.map +1 -1
  185. package/dist/presentation/cli/commands/context-command.d.ts +32 -0
  186. package/dist/presentation/cli/commands/context-command.d.ts.map +1 -0
  187. package/dist/presentation/cli/commands/context-command.js +295 -0
  188. package/dist/presentation/cli/commands/context-command.js.map +1 -0
  189. package/dist/presentation/cli/commands/context-helper.d.ts +16 -0
  190. package/dist/presentation/cli/commands/context-helper.d.ts.map +1 -0
  191. package/dist/presentation/cli/commands/context-helper.js +88 -0
  192. package/dist/presentation/cli/commands/context-helper.js.map +1 -0
  193. package/dist/presentation/cli/commands/decision-command.js +6 -23
  194. package/dist/presentation/cli/commands/decision-command.js.map +1 -1
  195. package/dist/presentation/cli/commands/fix-command.d.ts.map +1 -1
  196. package/dist/presentation/cli/commands/fix-command.js +19 -23
  197. package/dist/presentation/cli/commands/fix-command.js.map +1 -1
  198. package/dist/presentation/cli/commands/help-command.d.ts.map +1 -1
  199. package/dist/presentation/cli/commands/help-command.js +1 -21
  200. package/dist/presentation/cli/commands/help-command.js.map +1 -1
  201. package/dist/presentation/cli/commands/orchestrate-command.d.ts +0 -1
  202. package/dist/presentation/cli/commands/orchestrate-command.d.ts.map +1 -1
  203. package/dist/presentation/cli/commands/orchestrate-command.js +19 -126
  204. package/dist/presentation/cli/commands/orchestrate-command.js.map +1 -1
  205. package/dist/presentation/cli/commands/plan-command.d.ts +0 -1
  206. package/dist/presentation/cli/commands/plan-command.d.ts.map +1 -1
  207. package/dist/presentation/cli/commands/plan-command.js +42 -132
  208. package/dist/presentation/cli/commands/plan-command.js.map +1 -1
  209. package/dist/presentation/cli/commands/react-command.d.ts.map +1 -1
  210. package/dist/presentation/cli/commands/react-command.js +1 -5
  211. package/dist/presentation/cli/commands/react-command.js.map +1 -1
  212. package/dist/presentation/cli/commands/review-command.d.ts.map +1 -1
  213. package/dist/presentation/cli/commands/review-command.js +2 -21
  214. package/dist/presentation/cli/commands/review-command.js.map +1 -1
  215. package/dist/presentation/cli/commands/smart-command.d.ts +3 -0
  216. package/dist/presentation/cli/commands/smart-command.d.ts.map +1 -1
  217. package/dist/presentation/cli/commands/smart-command.js +127 -93
  218. package/dist/presentation/cli/commands/smart-command.js.map +1 -1
  219. package/dist/presentation/cli/commands/status-command.d.ts.map +1 -1
  220. package/dist/presentation/cli/commands/status-command.js +1 -5
  221. package/dist/presentation/cli/commands/status-command.js.map +1 -1
  222. package/dist/presentation/cli/commands/trust-command.d.ts +28 -0
  223. package/dist/presentation/cli/commands/trust-command.d.ts.map +1 -0
  224. package/dist/presentation/cli/commands/trust-command.js +301 -0
  225. package/dist/presentation/cli/commands/trust-command.js.map +1 -0
  226. package/dist/presentation/cli/error-display.d.ts.map +1 -1
  227. package/dist/presentation/cli/error-display.js +17 -75
  228. package/dist/presentation/cli/error-display.js.map +1 -1
  229. package/dist/search.d.ts.map +1 -1
  230. package/dist/search.js +5 -18
  231. package/dist/search.js.map +1 -1
  232. package/dist/session.d.ts.map +1 -1
  233. package/dist/session.js +221 -57
  234. package/dist/session.js.map +1 -1
  235. package/dist/token-optimizer.d.ts.map +1 -1
  236. package/dist/token-optimizer.js +6 -1
  237. package/dist/token-optimizer.js.map +1 -1
  238. package/dist/tools/bash.d.ts.map +1 -1
  239. package/dist/tools/bash.js +0 -3
  240. package/dist/tools/bash.js.map +1 -1
  241. package/dist/tools/git-tool.js +7 -7
  242. package/dist/tools/git-tool.js.map +1 -1
  243. package/dist/ui.d.ts +0 -5
  244. package/dist/ui.d.ts.map +1 -1
  245. package/dist/ui.js +0 -19
  246. package/dist/ui.js.map +1 -1
  247. package/dist/utils/provider-check.d.ts +21 -0
  248. package/dist/utils/provider-check.d.ts.map +1 -0
  249. package/dist/utils/provider-check.js +124 -0
  250. package/dist/utils/provider-check.js.map +1 -0
  251. package/package.json +16 -13
  252. package/dist/application/agents/documentation-agent.d.ts +0 -24
  253. package/dist/application/agents/documentation-agent.d.ts.map +0 -1
  254. package/dist/application/agents/documentation-agent.js +0 -399
  255. package/dist/application/agents/documentation-agent.js.map +0 -1
  256. package/dist/application/agents/product-requirements-agent.d.ts +0 -21
  257. package/dist/application/agents/product-requirements-agent.d.ts.map +0 -1
  258. package/dist/application/agents/product-requirements-agent.js +0 -247
  259. package/dist/application/agents/product-requirements-agent.js.map +0 -1
  260. package/dist/application/reasoning/multi-model-planning-strategy.d.ts +0 -21
  261. package/dist/application/reasoning/multi-model-planning-strategy.d.ts.map +0 -1
  262. package/dist/application/reasoning/multi-model-planning-strategy.js +0 -158
  263. package/dist/application/reasoning/multi-model-planning-strategy.js.map +0 -1
  264. package/dist/application/reasoning/reasoning-config.d.ts +0 -15
  265. package/dist/application/reasoning/reasoning-config.d.ts.map +0 -1
  266. package/dist/application/reasoning/reasoning-config.js +0 -50
  267. package/dist/application/reasoning/reasoning-config.js.map +0 -1
  268. package/dist/application/reasoning/reasoning-orchestrator.d.ts +0 -18
  269. package/dist/application/reasoning/reasoning-orchestrator.d.ts.map +0 -1
  270. package/dist/application/reasoning/reasoning-orchestrator.js +0 -170
  271. package/dist/application/reasoning/reasoning-orchestrator.js.map +0 -1
  272. package/dist/application/reasoning/reasoning-strategy.interface.d.ts +0 -24
  273. package/dist/application/reasoning/reasoning-strategy.interface.d.ts.map +0 -1
  274. package/dist/application/reasoning/reasoning-strategy.interface.js +0 -6
  275. package/dist/application/reasoning/reasoning-strategy.interface.js.map +0 -1
  276. package/dist/application/reasoning/role-provider-resolver.d.ts +0 -36
  277. package/dist/application/reasoning/role-provider-resolver.d.ts.map +0 -1
  278. package/dist/application/reasoning/role-provider-resolver.js +0 -74
  279. package/dist/application/reasoning/role-provider-resolver.js.map +0 -1
  280. package/dist/application/reasoning/simple-planning-strategy.d.ts +0 -22
  281. package/dist/application/reasoning/simple-planning-strategy.d.ts.map +0 -1
  282. package/dist/application/reasoning/simple-planning-strategy.js +0 -217
  283. package/dist/application/reasoning/simple-planning-strategy.js.map +0 -1
  284. package/dist/application/reasoning/types.d.ts +0 -65
  285. package/dist/application/reasoning/types.d.ts.map +0 -1
  286. package/dist/application/reasoning/types.js +0 -6
  287. package/dist/application/reasoning/types.js.map +0 -1
  288. package/dist/application/reasoning/validator-strategy.d.ts +0 -56
  289. package/dist/application/reasoning/validator-strategy.d.ts.map +0 -1
  290. package/dist/application/reasoning/validator-strategy.js +0 -103
  291. package/dist/application/reasoning/validator-strategy.js.map +0 -1
  292. package/dist/domain/entities/documentation.d.ts +0 -35
  293. package/dist/domain/entities/documentation.d.ts.map +0 -1
  294. package/dist/domain/entities/documentation.js +0 -6
  295. package/dist/domain/entities/documentation.js.map +0 -1
  296. package/dist/domain/entities/product-requirements.d.ts +0 -50
  297. package/dist/domain/entities/product-requirements.d.ts.map +0 -1
  298. package/dist/domain/entities/product-requirements.js +0 -6
  299. package/dist/domain/entities/product-requirements.js.map +0 -1
  300. package/dist/domain/interfaces/agent.interface.d.ts +0 -15
  301. package/dist/domain/interfaces/agent.interface.d.ts.map +0 -1
  302. package/dist/domain/interfaces/agent.interface.js +0 -6
  303. package/dist/domain/interfaces/agent.interface.js.map +0 -1
  304. package/dist/infrastructure/ai/fake-ai-service.d.ts +0 -22
  305. package/dist/infrastructure/ai/fake-ai-service.d.ts.map +0 -1
  306. package/dist/infrastructure/ai/fake-ai-service.js +0 -59
  307. package/dist/infrastructure/ai/fake-ai-service.js.map +0 -1
  308. package/dist/infrastructure/completion/completion-generator.d.ts +0 -42
  309. package/dist/infrastructure/completion/completion-generator.d.ts.map +0 -1
  310. package/dist/infrastructure/completion/completion-generator.js +0 -184
  311. package/dist/infrastructure/completion/completion-generator.js.map +0 -1
  312. package/dist/infrastructure/security/network-guard.d.ts +0 -8
  313. package/dist/infrastructure/security/network-guard.d.ts.map +0 -1
  314. package/dist/infrastructure/security/network-guard.js +0 -70
  315. package/dist/infrastructure/security/network-guard.js.map +0 -1
  316. package/dist/infrastructure/security/offline.d.ts +0 -16
  317. package/dist/infrastructure/security/offline.d.ts.map +0 -1
  318. package/dist/infrastructure/security/offline.js +0 -24
  319. package/dist/infrastructure/security/offline.js.map +0 -1
  320. package/dist/infrastructure/storage/sqljs-init.d.ts +0 -8
  321. package/dist/infrastructure/storage/sqljs-init.d.ts.map +0 -1
  322. package/dist/infrastructure/storage/sqljs-init.js +0 -23
  323. package/dist/infrastructure/storage/sqljs-init.js.map +0 -1
  324. package/dist/infrastructure/ux/hitl-review-portal.d.ts +0 -47
  325. package/dist/infrastructure/ux/hitl-review-portal.d.ts.map +0 -1
  326. package/dist/infrastructure/ux/hitl-review-portal.js +0 -228
  327. package/dist/infrastructure/ux/hitl-review-portal.js.map +0 -1
  328. package/dist/infrastructure/ux/meta-query.d.ts +0 -9
  329. package/dist/infrastructure/ux/meta-query.d.ts.map +0 -1
  330. package/dist/infrastructure/ux/meta-query.js +0 -63
  331. package/dist/infrastructure/ux/meta-query.js.map +0 -1
  332. package/dist/infrastructure/ux/proportional-friction.d.ts +0 -73
  333. package/dist/infrastructure/ux/proportional-friction.d.ts.map +0 -1
  334. package/dist/infrastructure/ux/proportional-friction.js +0 -200
  335. package/dist/infrastructure/ux/proportional-friction.js.map +0 -1
  336. package/dist/infrastructure/ux/repo-fingerprint.d.ts +0 -10
  337. package/dist/infrastructure/ux/repo-fingerprint.d.ts.map +0 -1
  338. package/dist/infrastructure/ux/repo-fingerprint.js +0 -55
  339. package/dist/infrastructure/ux/repo-fingerprint.js.map +0 -1
  340. package/dist/infrastructure/validation/feedback-stats.d.ts +0 -99
  341. package/dist/infrastructure/validation/feedback-stats.d.ts.map +0 -1
  342. package/dist/infrastructure/validation/feedback-stats.js +0 -173
  343. package/dist/infrastructure/validation/feedback-stats.js.map +0 -1
  344. package/dist/infrastructure/validation/trust-config.d.ts +0 -27
  345. package/dist/infrastructure/validation/trust-config.d.ts.map +0 -1
  346. package/dist/infrastructure/validation/trust-config.js +0 -113
  347. package/dist/infrastructure/validation/trust-config.js.map +0 -1
  348. package/dist/presentation/cli/commands/memory-command.d.ts +0 -17
  349. package/dist/presentation/cli/commands/memory-command.d.ts.map +0 -1
  350. package/dist/presentation/cli/commands/memory-command.js +0 -252
  351. package/dist/presentation/cli/commands/memory-command.js.map +0 -1
  352. package/dist/presentation/cli/keyboard-shortcuts.d.ts +0 -27
  353. package/dist/presentation/cli/keyboard-shortcuts.d.ts.map +0 -1
  354. package/dist/presentation/cli/keyboard-shortcuts.js +0 -77
  355. package/dist/presentation/cli/keyboard-shortcuts.js.map +0 -1
  356. package/dist/test_cohere.d.ts +0 -2
  357. package/dist/test_cohere.d.ts.map +0 -1
  358. package/dist/test_cohere.js +0 -68
  359. package/dist/test_cohere.js.map +0 -1
  360. package/dist/test_env.d.ts +0 -2
  361. package/dist/test_env.d.ts.map +0 -1
  362. package/dist/test_env.js +0 -24
  363. package/dist/test_env.js.map +0 -1
  364. package/dist/test_retrieval.d.ts +0 -2
  365. package/dist/test_retrieval.d.ts.map +0 -1
  366. package/dist/test_retrieval.js +0 -84
  367. package/dist/test_retrieval.js.map +0 -1
  368. package/dist/tools/bash.d 2.ts +0 -53
  369. package/dist/tools/bash.js 2.map +0 -1
  370. package/dist/tools/edit 2.js +0 -235
  371. package/dist/tools/edit.d.ts 2.map +0 -1
  372. package/dist/utils/logger.d.ts +0 -34
  373. package/dist/utils/logger.d.ts.map +0 -1
  374. package/dist/utils/logger.js +0 -56
  375. package/dist/utils/logger.js.map +0 -1
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ import { config } from 'dotenv';
4
4
  import { join, dirname } from 'path';
5
5
  import { fileURLToPath } from 'url';
6
6
  import { existsSync } from 'fs';
7
+ import { indexRepositoryParallel } from './embed.js';
7
8
  import { executeAskCommand } from './presentation/cli/commands/ask-command.js';
8
9
  import { executeReactCommand } from './presentation/cli/commands/react-command.js';
9
10
  import { executeSmartCommand } from './presentation/cli/commands/smart-command.js';
@@ -12,6 +13,7 @@ import { executeSetupCommand } from './presentation/cli/commands/setup-command.j
12
13
  import { executeConfigCommand } from './presentation/cli/commands/config-command.js';
13
14
  import { executeHelpCommand } from './presentation/cli/commands/help-command.js';
14
15
  import { initLogFile, logEntry } from './log.js';
16
+ import { checkProviderConfiguration, displayProviderError } from './utils/provider-check.js';
15
17
  import { performHealthCheck, formatHealthStatus, getMetrics } from './monitoring.js';
16
18
  import { refactorMultiFile, findFilesByPattern } from './refactor.js';
17
19
  import { getGitStatus, formatGitStatus, getAllGitDiffs, analyzeDiff, getGitDiff } from './git.js';
@@ -21,6 +23,9 @@ import { executeDocsCommand } from './presentation/cli/commands/docs-command.js'
21
23
  import { executeProductCommand } from './presentation/cli/commands/product-command.js';
22
24
  import { executeStatusCommand } from './presentation/cli/commands/status-command.js';
23
25
  import { executeSuggestCommand } from './presentation/cli/commands/suggest-command.js';
26
+ import { executeCostCommand } from './presentation/cli/commands/cost-command.js';
27
+ import { executeTrustCommand } from './presentation/cli/commands/trust-command.js';
28
+ import { executeContextImportCommand, executeContextExportCommand, executeContextStatsCommand } from './presentation/cli/commands/context-command.js';
24
29
  import { executeRunCommand } from './presentation/cli/commands/run-command.js';
25
30
  import { executeModelsCommand } from './presentation/cli/commands/models-command.js';
26
31
  import { executeReviewCommand } from './presentation/cli/commands/review-command.js';
@@ -29,7 +34,7 @@ import { executeKnowledgeCommand } from './presentation/cli/commands/knowledge-c
29
34
  import { executeLearningDashboardCommand } from './presentation/cli/commands/learning-dashboard-command.js';
30
35
  import { executeTraceCommand } from './presentation/cli/commands/trace-command.js';
31
36
  import { executeUndoCommand } from './presentation/cli/commands/undo-command.js';
32
- import { executeMemoryCommand } from './presentation/cli/commands/memory-command.js';
37
+ import { executeAuditCommand } from './presentation/cli/commands/audit-command.js';
33
38
  import { reviewFile, formatReview } from './review.js';
34
39
  import { formatLearningInsights, getPerformanceInsights } from './learning.js';
35
40
  import { getCacheStats, clearAllCaches } from './cache.js';
@@ -69,25 +74,31 @@ program
69
74
  program
70
75
  .argument('[query]', 'Your query - Codehere will understand what you need')
71
76
  .option('--review', 'Enable review & feedback capture (used for trust scoring and Validation Mode)')
77
+ .option('--quick', 'Quick mode - work without indexing by reading files directly')
78
+ .option('-c, --continue', 'Continue from previous conversation (session continuity)')
79
+ .option('-m, --model <model>', 'Specify AI model (e.g., gpt-4, claude-3, command-r-plus, llama3)')
72
80
  .action(async (query, options) => {
73
81
  if (query && query.trim()) {
74
82
  // Direct query - use intelligent router
75
83
  initLogFile();
76
- if (!process.env.COHERE_API_KEY) {
77
- newline();
78
- console.error(error('COHERE_API_KEY not found in environment'));
79
- newline();
80
- console.log(colors.bold('Setup Instructions:'));
81
- console.log(' 1. Get your API key from: https://dashboard.cohere.com/api-keys');
82
- console.log(' 2. Create a .env file in your project root:');
83
- console.log(colors.cyan(' echo "COHERE_API_KEY=your_key_here" > .env'));
84
- console.log(' 3. Run the command again');
85
- newline();
84
+ // Check for valid AI provider (supports Cohere, OpenAI, OpenRouter, Local, Fake)
85
+ const providerCheck = checkProviderConfiguration();
86
+ if (!providerCheck.hasValidProvider) {
87
+ displayProviderError(providerCheck);
86
88
  process.exit(1);
87
89
  }
88
90
  try {
89
91
  const opts = program.opts();
90
- await executeSmartCommand(query.trim(), { review: opts.review || false });
92
+ // Set model in environment if specified
93
+ if (opts.model) {
94
+ process.env.CODEHERE_MODEL = opts.model;
95
+ }
96
+ await executeSmartCommand(query.trim(), {
97
+ review: opts.review || false,
98
+ quick: opts.quick || false,
99
+ continue: opts.continue || false,
100
+ model: opts.model,
101
+ });
91
102
  logEntry({
92
103
  timestamp: new Date().toISOString(),
93
104
  command: 'smart',
@@ -195,34 +206,6 @@ program
195
206
  newline();
196
207
  }
197
208
  });
198
- program
199
- .command('memory')
200
- .description('View and manage Codehere\'s operation history (XAI: See what Codehere remembers)')
201
- .option('-l, --list', 'List all memories')
202
- .option('-s, --search <term>', 'Search memories by description or type')
203
- .option('--stats', 'Show memory statistics')
204
- .option('--clear', 'Clear memories (requires --confirm)')
205
- .option('--limit <number>', 'Limit number of results (default: 20)')
206
- .option('--type <type>', 'Filter by memory type (observation, reflection, plan)')
207
- .option('--json', 'Output in JSON format')
208
- .action(async (options) => {
209
- initLogFile();
210
- try {
211
- await executeMemoryCommand({
212
- list: options.list,
213
- search: options.search,
214
- stats: options.stats,
215
- clear: options.clear,
216
- limit: options.limit ? parseInt(options.limit, 10) : undefined,
217
- type: options.type,
218
- json: options.json,
219
- });
220
- }
221
- catch (err) {
222
- displayError(err, { operation: 'memory' });
223
- process.exit(1);
224
- }
225
- });
226
209
  program
227
210
  .command('help')
228
211
  .description('Show help for commands')
@@ -236,37 +219,33 @@ program
236
219
  .option('-r, --repo <path>', 'Repository path (default: current directory)')
237
220
  .action(async (options) => {
238
221
  initLogFile();
239
- // Allow fake AI for testing, or require real API key
240
- if (!process.env.COHERE_API_KEY && process.env.CODEHERE_FAKE_AI !== '1') {
241
- newline();
242
- console.error(error('COHERE_API_KEY not found in environment'));
243
- newline();
244
- console.log(colors.bold('Setup Instructions:'));
245
- console.log(' 1. Get your API key from: https://dashboard.cohere.com/api-keys');
246
- console.log(' 2. Create a .env file in your project root:');
247
- console.log(colors.cyan(' echo "COHERE_API_KEY=your_key_here" > .env'));
248
- console.log(' 3. Run the command again');
249
- console.log('');
250
- console.log(colors.dim('Note: For testing without API calls, set CODEHERE_FAKE_AI=1'));
251
- newline();
222
+ // Check provider configuration (supports all providers)
223
+ const { checkProviderConfiguration, displayProviderError } = await import('./utils/provider-check.js');
224
+ const providerCheck = checkProviderConfiguration();
225
+ if (!providerCheck.hasValidProvider) {
226
+ displayProviderError(providerCheck);
252
227
  process.exit(1);
253
228
  }
254
229
  try {
255
230
  if (isMinimalStyle()) {
256
231
  console.log(colors.cyan('Indexing codebase...'));
257
- newline();
258
232
  }
259
233
  else {
260
234
  console.log(createBanner('Indexing Repository', 'Building semantic search index'));
261
- newline();
262
235
  }
236
+ newline();
263
237
  const repoPath = options.repo || process.cwd();
264
- // NEW: Use parallel indexing with caching (lazy import to prevent cohere-ai loading)
265
- const { indexRepositoryParallel } = await import('./embed.js');
238
+ // Show progress spinner for indexing
239
+ const spinner = createSpinner('Scanning files...');
240
+ spinner.start();
241
+ const startTime = Date.now();
242
+ // NEW: Use parallel indexing with caching
266
243
  await indexRepositoryParallel(repoPath, {
267
244
  useCache: true,
268
245
  maxConcurrency: 5,
269
246
  });
247
+ const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
248
+ spinner.succeed(`Indexed codebase in ${elapsed}s`);
270
249
  logEntry({
271
250
  timestamp: new Date().toISOString(),
272
251
  command: 'index',
@@ -306,42 +285,41 @@ program
306
285
  .command('ask')
307
286
  .description('Ask questions about your codebase using semantic search')
308
287
  .argument('<question>', 'The question to ask about your code')
288
+ .option('--quick', 'Quick mode - work without indexing by reading files directly')
309
289
  .alias('q')
310
- .option('--explain', 'Show explainable AI (XAI) reasoning steps')
311
- .option('--json', 'Output in JSON format')
312
290
  .addHelpText('after', `
313
291
  Examples:
314
292
  $ codehere ask "How does authentication work?"
315
- $ codehere ask "Where is the user login function?" --explain
293
+ $ codehere ask "Where is the user login function?"
316
294
  $ codehere q "Explain the database schema"
295
+ $ codehere ask "What does this project do?" --quick
317
296
 
318
297
  This command will:
319
298
  • Search your indexed codebase for relevant code
320
299
  • Use AI to generate a contextual answer
321
300
  • Show which files were used as context
322
- • Use memories from past interactions (XAI: visible with --explain)
323
-
324
- Options:
325
- --explain Show explainable AI (XAI) reasoning steps
326
301
 
327
- Make sure to run "codehere index" first!
302
+ Make sure to run "codehere index" first (or use --quick to bypass indexing)!
328
303
  `)
329
304
  .action(async (question, options) => {
330
305
  initLogFile();
331
- if (!process.env.COHERE_API_KEY && process.env.CODEHERE_FAKE_AI !== '1') {
332
- newline();
333
- console.error(error('COHERE_API_KEY not found in environment'));
306
+ // Check if any valid provider is configured
307
+ const providerCheck = checkProviderConfiguration();
308
+ if (!providerCheck.hasValidProvider) {
334
309
  newline();
335
- console.log(colors.bold('Setup Instructions:'));
336
- console.log(' 1. Get your API key from: https://dashboard.cohere.com/api-keys');
337
- console.log(' 2. Create a .env file in your project root:');
338
- console.log(colors.cyan(' echo "COHERE_API_KEY=your_key_here" > .env'));
339
- console.log(' 3. Run the command again');
310
+ console.error(error(providerCheck.message));
311
+ if (providerCheck.setupInstructions) {
312
+ newline();
313
+ console.log(colors.bold('Setup Instructions:'));
314
+ providerCheck.setupInstructions.forEach(instruction => {
315
+ console.log(' ' + instruction);
316
+ });
317
+ }
340
318
  newline();
341
319
  process.exit(1);
342
320
  }
343
321
  try {
344
- await executeAskCommand(question, { explain: options?.explain, json: options?.json });
322
+ await executeAskCommand(question, { quick: options.quick });
345
323
  logEntry({
346
324
  timestamp: new Date().toISOString(),
347
325
  command: 'ask',
@@ -388,16 +366,10 @@ Safety policies:
388
366
  `)
389
367
  .action(async (file, instruction, options) => {
390
368
  initLogFile();
391
- if (!process.env.COHERE_API_KEY) {
392
- newline();
393
- console.error(error('COHERE_API_KEY not found in environment'));
394
- newline();
395
- console.log(colors.bold('Setup Instructions:'));
396
- console.log(' 1. Get your API key from: https://dashboard.cohere.com/api-keys');
397
- console.log(' 2. Create a .env file in your project root:');
398
- console.log(colors.cyan(' echo "COHERE_API_KEY=your_key_here" > .env'));
399
- console.log(' 3. Run the command again');
369
+ const providerCheck = checkProviderConfiguration();
370
+ if (!providerCheck.hasValidProvider) {
400
371
  newline();
372
+ displayProviderError(providerCheck);
401
373
  process.exit(1);
402
374
  }
403
375
  try {
@@ -455,16 +427,10 @@ This command will:
455
427
  `)
456
428
  .action(async (file) => {
457
429
  initLogFile();
458
- if (!process.env.COHERE_API_KEY) {
459
- newline();
460
- console.error(error('COHERE_API_KEY not found in environment'));
461
- newline();
462
- console.log(colors.bold('Setup Instructions:'));
463
- console.log(' 1. Get your API key from: https://dashboard.cohere.com/api-keys');
464
- console.log(' 2. Create a .env file in your project root:');
465
- console.log(colors.cyan(' echo "COHERE_API_KEY=your_key_here" > .env'));
466
- console.log(' 3. Run the command again');
430
+ const providerCheck = checkProviderConfiguration();
431
+ if (!providerCheck.hasValidProvider) {
467
432
  newline();
433
+ displayProviderError(providerCheck);
468
434
  process.exit(1);
469
435
  }
470
436
  try {
@@ -588,9 +554,9 @@ program
588
554
  .option('--max-files <number>', 'Maximum files to process', '10')
589
555
  .action(async (pattern, instruction, options) => {
590
556
  initLogFile();
591
- if (!process.env.COHERE_API_KEY) {
592
- newline();
593
- console.error(error('COHERE_API_KEY not found in environment'));
557
+ const providerCheck = checkProviderConfiguration();
558
+ if (!providerCheck.hasValidProvider) {
559
+ displayProviderError(providerCheck);
594
560
  process.exit(1);
595
561
  }
596
562
  try {
@@ -705,28 +671,25 @@ program
705
671
  .argument('<instruction>', 'Complex instruction to plan')
706
672
  .option('-e, --execute', 'Execute the plan after creating it')
707
673
  .option('--review', 'Enable review & feedback capture (used for trust scoring and Validation Mode)')
708
- .option('--json', 'Output in JSON format')
709
674
  .action(async (instruction, options) => {
710
675
  initLogFile();
711
- if (!process.env.COHERE_API_KEY) {
712
- console.error(error('COHERE_API_KEY not found in environment'));
676
+ const providerCheck = checkProviderConfiguration();
677
+ if (!providerCheck.hasValidProvider) {
678
+ displayProviderError(providerCheck);
713
679
  process.exit(1);
714
680
  }
715
681
  try {
716
- // Suppress header in JSON mode
717
- if (!options.json) {
718
- if (isMinimalStyle()) {
719
- printMinimalHeader('plan', instruction);
720
- }
721
- else {
722
- console.log(createBanner('Task Planning', 'Intelligent multi-step execution'));
723
- newline();
724
- console.log(colors.bold('Instruction:') + ' ' + colors.cyan(instruction));
725
- }
682
+ if (isMinimalStyle()) {
683
+ printMinimalHeader('plan', instruction);
684
+ }
685
+ else {
686
+ console.log(createBanner('Task Planning', 'Intelligent multi-step execution'));
726
687
  newline();
688
+ console.log(colors.bold('Instruction:') + ' ' + colors.cyan(instruction));
727
689
  }
690
+ newline();
728
691
  // Use new memory-based planning
729
- await executePlanCommand(instruction, { execute: options.execute, review: options.review, json: options.json });
692
+ await executePlanCommand(instruction, { execute: options.execute, review: options.review });
730
693
  }
731
694
  catch (err) {
732
695
  console.error(error('Error:'), err instanceof Error ? err.message : String(err));
@@ -800,8 +763,9 @@ program
800
763
  .argument('<file>', 'File to review')
801
764
  .action(async (file) => {
802
765
  initLogFile();
803
- if (!process.env.COHERE_API_KEY) {
804
- console.error(error('COHERE_API_KEY not found in environment'));
766
+ const providerCheck = checkProviderConfiguration();
767
+ if (!providerCheck.hasValidProvider) {
768
+ displayProviderError(providerCheck);
805
769
  process.exit(1);
806
770
  }
807
771
  try {
@@ -905,8 +869,9 @@ program
905
869
  .option('--plan-only', 'Only show migration plan, do not execute')
906
870
  .action(async (from, to, options) => {
907
871
  initLogFile();
908
- if (!process.env.COHERE_API_KEY) {
909
- console.error(error('COHERE_API_KEY not found in environment'));
872
+ const providerCheck = checkProviderConfiguration();
873
+ if (!providerCheck.hasValidProvider) {
874
+ displayProviderError(providerCheck);
910
875
  process.exit(1);
911
876
  }
912
877
  try {
@@ -949,8 +914,9 @@ Warning: This command may modify README.md and docs/api.md files.
949
914
  console.error(error(`Unknown command: ${cmd}. Use 'generate' to create documentation.`));
950
915
  process.exit(1);
951
916
  }
952
- if (!process.env.COHERE_API_KEY) {
953
- console.error(error('COHERE_API_KEY not found in environment'));
917
+ const providerCheck = checkProviderConfiguration();
918
+ if (!providerCheck.hasValidProvider) {
919
+ displayProviderError(providerCheck);
954
920
  process.exit(1);
955
921
  }
956
922
  initLogFile();
@@ -985,8 +951,9 @@ Warning: This command may create new files if --output is specified.
985
951
  console.error(error(`Unknown command: ${cmd}. Use 'spec' to generate product requirements.`));
986
952
  process.exit(1);
987
953
  }
988
- if (!process.env.COHERE_API_KEY && process.env.CODEHERE_FAKE_AI !== '1') {
989
- console.error(error('COHERE_API_KEY not found in environment'));
954
+ const providerCheck = checkProviderConfiguration();
955
+ if (!providerCheck.hasValidProvider) {
956
+ displayProviderError(providerCheck);
990
957
  process.exit(1);
991
958
  }
992
959
  initLogFile();
@@ -1019,6 +986,146 @@ program
1019
986
  track: Boolean(options.track),
1020
987
  });
1021
988
  });
989
+ // Cost tracking command - doesn't require API key
990
+ program
991
+ .command('cost')
992
+ .description('View API cost tracking and budget status (local estimates)')
993
+ .argument('[action]', 'Action: status, summary, run, reset', 'status')
994
+ .argument('[runId]', 'Run ID (for "run" action)')
995
+ .action(async (action, runId) => {
996
+ await executeCostCommand(action, runId);
997
+ });
998
+ // Trust dashboard command - shows agent reliability metrics
999
+ program
1000
+ .command('trust')
1001
+ .description('View agent reliability and trust metrics')
1002
+ .argument('[action]', 'Action: status, history, reset', 'status')
1003
+ .option('--json', 'Output in JSON format')
1004
+ .option('--limit <n>', 'Limit history entries', '20')
1005
+ .action(async (action, options) => {
1006
+ await executeTrustCommand(action, {
1007
+ json: options.json,
1008
+ limit: options.limit ? parseInt(options.limit, 10) : undefined,
1009
+ });
1010
+ });
1011
+ // Context continuity commands - import, export, stats
1012
+ // Use addCommand for proper subcommand handling
1013
+ const contextImportCmd = new Command('import')
1014
+ .description('Import conversation context from other AI tools')
1015
+ .requiredOption('--from <source>', 'Import source: claude-code, opencode, cursor, or file')
1016
+ .option('--session <id>', 'Session ID (default: latest)', 'latest')
1017
+ .option('--file <path>', 'File path (required for file import)')
1018
+ .option('--project <path>', 'Project path override')
1019
+ .addHelpText('after', `
1020
+ Examples:
1021
+ $ codehere context import --from claude-code --session latest
1022
+ $ codehere context import --from claude-code --session <session-id>
1023
+ $ codehere context import --from opencode
1024
+ $ codehere context import --from cursor
1025
+ $ codehere context import --from file --file ./context.json
1026
+
1027
+ Context continuity allows you to:
1028
+ • Import conversations from Claude Code, OpenCode, or Cursor
1029
+ • Continue conversations across different AI tools
1030
+ • Preserve context when switching providers
1031
+ `)
1032
+ .action(async function () {
1033
+ initLogFile();
1034
+ try {
1035
+ // Use 'this' context to access command options in Commander.js subcommands
1036
+ const from = this.getOptionValue('from');
1037
+ const session = this.getOptionValue('session') || 'latest';
1038
+ const file = this.getOptionValue('file');
1039
+ const project = this.getOptionValue('project');
1040
+ if (!from) {
1041
+ console.error(error('--from is required for import'));
1042
+ console.log(info('Usage: codehere context import --from <source> [options]'));
1043
+ process.exit(1);
1044
+ }
1045
+ if (from === 'file' && !file) {
1046
+ console.error(error('--file is required when --from=file'));
1047
+ console.log(info('Usage: codehere context import --from file --file <path>'));
1048
+ process.exit(1);
1049
+ }
1050
+ await executeContextImportCommand(from, {
1051
+ session,
1052
+ file,
1053
+ project,
1054
+ });
1055
+ }
1056
+ catch (err) {
1057
+ console.error(error('Error:'), err instanceof Error ? err.message : String(err));
1058
+ process.exit(1);
1059
+ }
1060
+ });
1061
+ const contextCmd = new Command('context')
1062
+ .description('Manage conversation contexts (import, export, stats)')
1063
+ .addCommand(contextImportCmd);
1064
+ const contextExportCmd = new Command('export')
1065
+ .description('Export conversation context to portable format')
1066
+ .option('--session <id>', 'Session ID (default: latest)')
1067
+ .option('--output <path>', 'Output file path')
1068
+ .option('--json', 'Output in JSON format')
1069
+ .addHelpText('after', `
1070
+ Examples:
1071
+ $ codehere context export --session <sessionId> --output ./export.json
1072
+ $ codehere context export --output my-context.json
1073
+ $ codehere context export --session <sessionId> --json
1074
+
1075
+ Exports context to portable JSON format that can be:
1076
+ • Re-imported into Codehere
1077
+ • Shared with team members
1078
+ • Backed up for safekeeping
1079
+ `)
1080
+ .action(async function () {
1081
+ initLogFile();
1082
+ try {
1083
+ const session = this.getOptionValue('session');
1084
+ const output = this.getOptionValue('output');
1085
+ const json = this.getOptionValue('json');
1086
+ await executeContextExportCommand(session, {
1087
+ output,
1088
+ json,
1089
+ });
1090
+ }
1091
+ catch (err) {
1092
+ console.error(error('Error:'), err instanceof Error ? err.message : String(err));
1093
+ process.exit(1);
1094
+ }
1095
+ });
1096
+ contextCmd.addCommand(contextExportCmd);
1097
+ const contextStatsCmd = new Command('stats')
1098
+ .description('View conversation context statistics')
1099
+ .option('--session <id>', 'Session ID (shows all if not specified)')
1100
+ .option('--json', 'Output in JSON format')
1101
+ .addHelpText('after', `
1102
+ Examples:
1103
+ $ codehere context stats
1104
+ $ codehere context stats --session <sessionId>
1105
+ $ codehere context stats --session <sessionId> --json
1106
+
1107
+ Shows:
1108
+ • Message count and token usage
1109
+ • Compaction history
1110
+ • Model and provider information
1111
+ • Project metadata
1112
+ `)
1113
+ .action(async function () {
1114
+ initLogFile();
1115
+ try {
1116
+ const session = this.getOptionValue('session');
1117
+ const json = this.getOptionValue('json');
1118
+ await executeContextStatsCommand(session, {
1119
+ json,
1120
+ });
1121
+ }
1122
+ catch (err) {
1123
+ console.error(error('Error:'), err instanceof Error ? err.message : String(err));
1124
+ process.exit(1);
1125
+ }
1126
+ });
1127
+ contextCmd.addCommand(contextStatsCmd);
1128
+ program.addCommand(contextCmd);
1022
1129
  // Suggest command - Read-only assistant mode
1023
1130
  program
1024
1131
  .command('suggest')
@@ -1038,9 +1145,9 @@ This command:
1038
1145
  `)
1039
1146
  .action(async (query, options) => {
1040
1147
  initLogFile();
1041
- if (!process.env.COHERE_API_KEY) {
1042
- newline();
1043
- console.error(error('COHERE_API_KEY not found in environment'));
1148
+ const providerCheck = checkProviderConfiguration();
1149
+ if (!providerCheck.hasValidProvider) {
1150
+ displayProviderError(providerCheck);
1044
1151
  process.exit(1);
1045
1152
  }
1046
1153
  try {
@@ -1088,9 +1195,9 @@ This command:
1088
1195
  `)
1089
1196
  .action(async (goal, options) => {
1090
1197
  initLogFile();
1091
- if (!process.env.COHERE_API_KEY) {
1092
- newline();
1093
- console.error(error('COHERE_API_KEY not found in environment'));
1198
+ const providerCheck = checkProviderConfiguration();
1199
+ if (!providerCheck.hasValidProvider) {
1200
+ displayProviderError(providerCheck);
1094
1201
  process.exit(1);
1095
1202
  }
1096
1203
  try {
@@ -1168,8 +1275,9 @@ program
1168
1275
  .option('--save', 'Save tests to file')
1169
1276
  .action(async (file, options) => {
1170
1277
  initLogFile();
1171
- if (!process.env.COHERE_API_KEY) {
1172
- console.error(error('COHERE_API_KEY not found in environment'));
1278
+ const providerCheck = checkProviderConfiguration();
1279
+ if (!providerCheck.hasValidProvider) {
1280
+ displayProviderError(providerCheck);
1173
1281
  process.exit(1);
1174
1282
  }
1175
1283
  try {
@@ -1222,20 +1330,10 @@ This command uses ReAct (Reasoning + Acting) pattern:
1222
1330
  `)
1223
1331
  .action(async (query) => {
1224
1332
  initLogFile();
1225
- // Allow fake AI mode without requiring API key
1226
- if (!process.env.COHERE_API_KEY && process.env.CODEHERE_FAKE_AI !== '1') {
1227
- newline();
1228
- console.error(error('COHERE_API_KEY not found in environment'));
1229
- newline();
1230
- console.log(colors.bold('Setup Instructions:'));
1231
- console.log(' 1. Get your API key from: https://dashboard.cohere.com/api-keys');
1232
- console.log(' 2. Create a .env file in your project root:');
1233
- console.log(colors.cyan(' echo "COHERE_API_KEY=your_key_here" > .env'));
1234
- console.log(' 3. Run the command again');
1235
- console.log('');
1236
- console.log('Or use fake AI mode for testing:');
1237
- console.log(colors.cyan(' CODEHERE_FAKE_AI=1 codehere react "your query"'));
1333
+ const providerCheck = checkProviderConfiguration();
1334
+ if (!providerCheck.hasValidProvider) {
1238
1335
  newline();
1336
+ displayProviderError(providerCheck);
1239
1337
  process.exit(1);
1240
1338
  }
1241
1339
  try {
@@ -1254,7 +1352,6 @@ This command uses ReAct (Reasoning + Acting) pattern:
1254
1352
  });
1255
1353
  program
1256
1354
  .command('orchestrate')
1257
- .option('--json', 'Output in JSON format')
1258
1355
  .description('Orchestrate multi-agent workflows (plan, execute, validate)')
1259
1356
  .argument('<goal>', 'The goal to orchestrate')
1260
1357
  .option('-m, --mode <mode>', 'Orchestration mode: plan-only, execute-only, or full', 'full')
@@ -1262,9 +1359,9 @@ program
1262
1359
  .option('--review', 'Enable review & feedback capture (used for trust scoring and Validation Mode)')
1263
1360
  .action(async (goal, options) => {
1264
1361
  initLogFile();
1265
- if (!process.env.COHERE_API_KEY) {
1266
- newline();
1267
- console.error(error('COHERE_API_KEY not found in environment'));
1362
+ const providerCheck = checkProviderConfiguration();
1363
+ if (!providerCheck.hasValidProvider) {
1364
+ displayProviderError(providerCheck);
1268
1365
  process.exit(1);
1269
1366
  }
1270
1367
  try {
@@ -1272,7 +1369,6 @@ program
1272
1369
  mode: options.mode,
1273
1370
  planId: options.planId,
1274
1371
  review: options.review,
1275
- json: options.json,
1276
1372
  });
1277
1373
  logEntry({
1278
1374
  timestamp: new Date().toISOString(),
@@ -1389,6 +1485,34 @@ program
1389
1485
  process.exit(1);
1390
1486
  }
1391
1487
  });
1488
+ // Security audit export command
1489
+ program
1490
+ .command('audit')
1491
+ .description('Security audit trail export for compliance')
1492
+ .argument('<action>', 'Action: export or list')
1493
+ .option('-f, --format <format>', 'Export format: json, jsonl, or csv', 'json')
1494
+ .option('--start-date <date>', 'Start date (ISO 8601 format, e.g., 2025-01-15T00:00:00Z)')
1495
+ .option('--end-date <date>', 'End date (ISO 8601 format, e.g., 2025-01-15T23:59:59Z)')
1496
+ .option('--include-inputs', 'Include input data in export (may contain sensitive data)')
1497
+ .option('--include-outputs', 'Include output data in export (may contain sensitive data)')
1498
+ .option('-o, --output <path>', 'Output file path (default: auto-generated)')
1499
+ .action(async (action, options) => {
1500
+ initLogFile();
1501
+ try {
1502
+ await executeAuditCommand(action, {
1503
+ format: options.format,
1504
+ startDate: options.startDate,
1505
+ endDate: options.endDate,
1506
+ includeInputs: options.includeInputs,
1507
+ includeOutputs: options.includeOutputs,
1508
+ outputPath: options.output,
1509
+ });
1510
+ }
1511
+ catch (err) {
1512
+ console.error(error('Error:'), err instanceof Error ? err.message : String(err));
1513
+ process.exit(1);
1514
+ }
1515
+ });
1392
1516
  // Initialize telemetry and track command
1393
1517
  const telemetry = getTelemetryService();
1394
1518
  // Track command usage (if enabled)