codehere 0.2.2 → 0.3.0-rc.2

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 (235) hide show
  1. package/README.md +88 -68
  2. package/dist/domain/entities/task.js +4 -4
  3. package/dist/error-handler.js +4 -9
  4. package/dist/index.js +253 -1219
  5. package/dist/infrastructure/config/product-context.js +7 -6
  6. package/dist/infrastructure/hooks/claude-sdk-hook.js +348 -72
  7. package/dist/infrastructure/observability/execution-tracer.js +11 -6
  8. package/dist/infrastructure/orchestration/agent-adapter.js +13 -0
  9. package/dist/infrastructure/orchestration/agent-installer.js +101 -0
  10. package/dist/infrastructure/orchestration/agents-config-seed.js +56 -0
  11. package/dist/infrastructure/orchestration/aider-adapter.js +319 -0
  12. package/dist/infrastructure/orchestration/artifacts-extractor.js +175 -0
  13. package/dist/infrastructure/orchestration/claude-code-adapter.js +352 -0
  14. package/dist/infrastructure/orchestration/codex-adapter.js +310 -0
  15. package/dist/infrastructure/orchestration/generic-cli-adapter.js +553 -0
  16. package/dist/infrastructure/orchestration/opencode-adapter.js +275 -0
  17. package/dist/infrastructure/orchestration/progress-aggregator.js +189 -0
  18. package/dist/infrastructure/orchestration/readiness.js +106 -0
  19. package/dist/infrastructure/orchestration/session-manager.js +272 -0
  20. package/dist/infrastructure/orchestration/session-persistence.js +109 -0
  21. package/dist/infrastructure/protocols/mcp-helpers.js +10 -30
  22. package/dist/infrastructure/protocols/mcp-server-impl.js +359 -21
  23. package/dist/infrastructure/protocols/ui-page.js +1827 -0
  24. package/dist/infrastructure/security/file-collection.js +115 -0
  25. package/dist/infrastructure/security/trust-scorer.js +301 -56
  26. package/dist/infrastructure/storage/task-repository.js +8 -7
  27. package/dist/monitoring.js +9 -38
  28. package/dist/presentation/cli/commands/help-command.js +96 -139
  29. package/dist/presentation/cli/commands/hook-command.js +17 -24
  30. package/dist/presentation/cli/commands/report-command.js +59 -72
  31. package/dist/presentation/cli/commands/setup-command.js +4 -4
  32. package/dist/presentation/cli/commands/status-command.js +321 -30
  33. package/dist/presentation/cli/commands/trust-command.js +84 -72
  34. package/dist/presentation/cli/error-display.js +17 -21
  35. package/dist/ui.js +11 -11
  36. package/package.json +24 -62
  37. package/dist/agents/base.js +0 -101
  38. package/dist/agents/orchestrator-model-driven.js +0 -141
  39. package/dist/agents/react-orchestrator-agent.js +0 -54
  40. package/dist/application/agents/execution-agent.js +0 -508
  41. package/dist/application/agents/multi-agent-orchestrator.js +0 -295
  42. package/dist/application/agents/planning-agent.js +0 -433
  43. package/dist/application/agents/validation-agent.js +0 -317
  44. package/dist/application/architectures/plan-and-act.js +0 -242
  45. package/dist/application/index.js +0 -12
  46. package/dist/application/services/agent-factory.js +0 -28
  47. package/dist/application/services/dependency-container.js +0 -596
  48. package/dist/application/services/git-context-service.js +0 -83
  49. package/dist/application/services/intelligent-router.js +0 -934
  50. package/dist/application/services/tool-executor-service.js +0 -94
  51. package/dist/application/use-cases/ask-question-use-case.js +0 -338
  52. package/dist/application/use-cases/edit-file-use-case.js +0 -830
  53. package/dist/application/use-cases/explain-file-use-case.js +0 -50
  54. package/dist/application/use-cases/index-codebase-use-case.js +0 -113
  55. package/dist/application/use-cases/planning-use-case.js +0 -276
  56. package/dist/application/use-cases/react-orchestration-use-case.js +0 -329
  57. package/dist/application/use-cases/reflexion-use-case.js +0 -30
  58. package/dist/application/workflows/deterministic-workflows.js +0 -189
  59. package/dist/ast-parser.js +0 -331
  60. package/dist/cache.js +0 -180
  61. package/dist/chat.js +0 -251
  62. package/dist/code-analysis.js +0 -327
  63. package/dist/context.js +0 -187
  64. package/dist/docs.js +0 -146
  65. package/dist/domain/entities/code-chunk.js +0 -6
  66. package/dist/domain/entities/decision.js +0 -9
  67. package/dist/domain/entities/edit.js +0 -6
  68. package/dist/domain/entities/knowledge-node.js +0 -9
  69. package/dist/domain/entities/knowledge-preservation.js +0 -10
  70. package/dist/domain/entities/memory.js +0 -6
  71. package/dist/domain/entities/pattern.js +0 -7
  72. package/dist/domain/entities/plan.js +0 -6
  73. package/dist/domain/entities/query.js +0 -6
  74. package/dist/domain/errors/embeddings-not-found-error.js +0 -13
  75. package/dist/domain/index.js +0 -19
  76. package/dist/domain/interfaces/ai-service.interface.js +0 -6
  77. package/dist/domain/interfaces/code-analyzer.interface.js +0 -6
  78. package/dist/domain/interfaces/decision-repository.interface.js +0 -9
  79. package/dist/domain/interfaces/embedding-repository.interface.js +0 -6
  80. package/dist/domain/interfaces/knowledge-graph-repository.interface.js +0 -9
  81. package/dist/domain/interfaces/knowledge-preservation-repository.interface.js +0 -8
  82. package/dist/domain/interfaces/memory-repository.interface.js +0 -6
  83. package/dist/domain/interfaces/pattern-repository.interface.js +0 -6
  84. package/dist/domain/interfaces/verification-service.interface.js +0 -6
  85. package/dist/domain/services/cross-team-pattern-sharing.js +0 -125
  86. package/dist/domain/services/decision-recorder.js +0 -223
  87. package/dist/domain/services/decision-retriever.js +0 -133
  88. package/dist/domain/services/environment-mode-manager.js +0 -22
  89. package/dist/domain/services/graded-memory-activation.js +0 -69
  90. package/dist/domain/services/knowledge-access.js +0 -132
  91. package/dist/domain/services/knowledge-extractor.js +0 -247
  92. package/dist/domain/services/knowledge-graph-builder.js +0 -268
  93. package/dist/domain/services/knowledge-graph-query.js +0 -187
  94. package/dist/domain/services/memory-retriever.js +0 -82
  95. package/dist/domain/services/memory-synthesizer.js +0 -91
  96. package/dist/domain/services/pattern-extractor.js +0 -442
  97. package/dist/domain/services/query-intent-classifier.js +0 -140
  98. package/dist/domain/services/react-loop.js +0 -186
  99. package/dist/domain/services/risk-tier-detector.js +0 -78
  100. package/dist/edit.js +0 -319
  101. package/dist/embed.js +0 -459
  102. package/dist/formatter.js +0 -168
  103. package/dist/git.js +0 -198
  104. package/dist/infrastructure/ai/cohere-ai-service.js +0 -607
  105. package/dist/infrastructure/ai/command-r-evaluation.js +0 -206
  106. package/dist/infrastructure/ai/model-config.js +0 -84
  107. package/dist/infrastructure/ai/provider-ai-service.js +0 -477
  108. package/dist/infrastructure/cache/embedding-cache.js +0 -175
  109. package/dist/infrastructure/cache/query-result-cache.js +0 -66
  110. package/dist/infrastructure/cache/response-cache.js +0 -48
  111. package/dist/infrastructure/cache/security-scan-cache.js +0 -47
  112. package/dist/infrastructure/chunking/ast-code-chunker.js +0 -19
  113. package/dist/infrastructure/chunking/code-aware-chunker.js +0 -397
  114. package/dist/infrastructure/context/context-compressor.js +0 -329
  115. package/dist/infrastructure/context/conversation-context.js +0 -128
  116. package/dist/infrastructure/context/session-manager.js +0 -94
  117. package/dist/infrastructure/cost/cost-tracker.js +0 -360
  118. package/dist/infrastructure/file-scanner/file-scanner.js +0 -106
  119. package/dist/infrastructure/governance/nist-ai-rmf.js +0 -292
  120. package/dist/infrastructure/governance/policy-as-code.js +0 -258
  121. package/dist/infrastructure/governance/prompt-to-code-lineage.js +0 -239
  122. package/dist/infrastructure/index.js +0 -7
  123. package/dist/infrastructure/observability/prompt-versioner.js +0 -145
  124. package/dist/infrastructure/protocols/a2a-metadata.js +0 -137
  125. package/dist/infrastructure/protocols/a2a-protocol.js +0 -314
  126. package/dist/infrastructure/protocols/mcp-oauth.js +0 -184
  127. package/dist/infrastructure/protocols/mcp-server.js +0 -333
  128. package/dist/infrastructure/protocols/streaming-handler.js +0 -103
  129. package/dist/infrastructure/providers/cohere-provider.js +0 -444
  130. package/dist/infrastructure/providers/fake-provider.js +0 -130
  131. package/dist/infrastructure/providers/local-llm-provider.js +0 -330
  132. package/dist/infrastructure/providers/model-config.types.js +0 -9
  133. package/dist/infrastructure/providers/model-provider.interface.js +0 -8
  134. package/dist/infrastructure/providers/openai-provider.js +0 -413
  135. package/dist/infrastructure/providers/openrouter-provider.js +0 -399
  136. package/dist/infrastructure/providers/operation-provider-resolver.js +0 -105
  137. package/dist/infrastructure/providers/provider-config-loader.js +0 -120
  138. package/dist/infrastructure/providers/provider-registry.js +0 -88
  139. package/dist/infrastructure/safety/pattern-detector.js +0 -133
  140. package/dist/infrastructure/security/ai-sast-scanner.js +0 -290
  141. package/dist/infrastructure/security/docker-sandbox.js +0 -178
  142. package/dist/infrastructure/security/enhanced-security-gate.js +0 -151
  143. package/dist/infrastructure/security/license-scanner.js +0 -167
  144. package/dist/infrastructure/security/provider-bias-detector.js +0 -164
  145. package/dist/infrastructure/security/sandbox-executor.js +0 -64
  146. package/dist/infrastructure/serialization/toon-serializer.js +0 -119
  147. package/dist/infrastructure/storage/memory-stream-service.js +0 -204
  148. package/dist/infrastructure/storage/plan-repository.js +0 -96
  149. package/dist/infrastructure/storage/sqlite-decision-repository.js +0 -232
  150. package/dist/infrastructure/storage/sqlite-embedding-repository.js +0 -311
  151. package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.js +0 -417
  152. package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.js +0 -230
  153. package/dist/infrastructure/storage/sqlite-memory-repository.js +0 -229
  154. package/dist/infrastructure/storage/sqlite-pattern-repository.js +0 -249
  155. package/dist/infrastructure/storage/task-helpers.js +0 -197
  156. package/dist/infrastructure/telemetry/telemetry-service.js +0 -167
  157. package/dist/infrastructure/ux/appropriate-friction.js +0 -213
  158. package/dist/infrastructure/ux/bi-directional-learning.js +0 -337
  159. package/dist/infrastructure/ux/capability-boundaries.js +0 -42
  160. package/dist/infrastructure/ux/comprehensive-formatter.js +0 -117
  161. package/dist/infrastructure/ux/contextual-feature-discovery.js +0 -10
  162. package/dist/infrastructure/ux/expectation-management.js +0 -327
  163. package/dist/infrastructure/ux/feature-discovery.js +0 -14
  164. package/dist/infrastructure/ux/feedback-prompt.js +0 -45
  165. package/dist/infrastructure/ux/hitl-validation.js +0 -297
  166. package/dist/infrastructure/ux/progress-indicator.js +0 -116
  167. package/dist/infrastructure/ux/progressive-disclosure.js +0 -236
  168. package/dist/infrastructure/ux/review-checkpoint.js +0 -72
  169. package/dist/infrastructure/ux/staged-feature-intro.js +0 -24
  170. package/dist/infrastructure/ux/stream-markdown.js +0 -151
  171. package/dist/infrastructure/ux/syntax-highlighter.js +0 -91
  172. package/dist/infrastructure/ux/team-standards.js +0 -196
  173. package/dist/infrastructure/ux/transparency.js +0 -71
  174. package/dist/infrastructure/validation/agent-feedback.js +0 -55
  175. package/dist/infrastructure/validation/agent-validation-helper.js +0 -137
  176. package/dist/infrastructure/validation/review-handler.js +0 -40
  177. package/dist/infrastructure/validation/summary-aggregator.js +0 -70
  178. package/dist/infrastructure/validation/summary-extractor.js +0 -45
  179. package/dist/infrastructure/validation/trace-summary.js +0 -52
  180. package/dist/infrastructure/verification/verification-service.js +0 -47
  181. package/dist/infrastructure/xai/attention-visualizer.js +0 -172
  182. package/dist/infrastructure/xai/cot-visualizer.js +0 -283
  183. package/dist/infrastructure/xai/decision-tree-log.js +0 -212
  184. package/dist/infrastructure/xai/interactive-xai.js +0 -260
  185. package/dist/infrastructure/xai/uncertainty-quantifier.js +0 -198
  186. package/dist/intelligent-retrieval.js +0 -272
  187. package/dist/intent/classifier.js +0 -2
  188. package/dist/intent/context.js +0 -2
  189. package/dist/iterative-refinement.js +0 -189
  190. package/dist/learning.js +0 -232
  191. package/dist/log.js +0 -31
  192. package/dist/migrate.js +0 -133
  193. package/dist/parallel-processor.js +0 -534
  194. package/dist/planner.js +0 -198
  195. package/dist/policy.js +0 -26
  196. package/dist/presentation/cli/commands/ask-command.js +0 -314
  197. package/dist/presentation/cli/commands/cost-command.js +0 -191
  198. package/dist/presentation/cli/commands/decision-command.js +0 -207
  199. package/dist/presentation/cli/commands/docs-command.js +0 -25
  200. package/dist/presentation/cli/commands/fix-command.js +0 -53
  201. package/dist/presentation/cli/commands/knowledge-command.js +0 -129
  202. package/dist/presentation/cli/commands/learning-dashboard-command.js +0 -183
  203. package/dist/presentation/cli/commands/models-command.js +0 -194
  204. package/dist/presentation/cli/commands/orchestrate-command.js +0 -207
  205. package/dist/presentation/cli/commands/plan-command.js +0 -246
  206. package/dist/presentation/cli/commands/product-command.js +0 -199
  207. package/dist/presentation/cli/commands/react-command.js +0 -181
  208. package/dist/presentation/cli/commands/review-command.js +0 -154
  209. package/dist/presentation/cli/commands/run-command.js +0 -188
  210. package/dist/presentation/cli/commands/smart-command.js +0 -395
  211. package/dist/presentation/cli/commands/suggest-command.js +0 -138
  212. package/dist/presentation/cli/commands/trace-command.js +0 -129
  213. package/dist/presentation/cli/commands/undo-command.js +0 -150
  214. package/dist/query-optimizer.js +0 -205
  215. package/dist/refactor.js +0 -116
  216. package/dist/review.js +0 -206
  217. package/dist/search.js +0 -163
  218. package/dist/session.js +0 -704
  219. package/dist/task-verification.js +0 -336
  220. package/dist/testgen.js +0 -166
  221. package/dist/token-optimizer.js +0 -277
  222. package/dist/tools/bash.js +0 -213
  223. package/dist/tools/edit.js +0 -235
  224. package/dist/tools/executor.js +0 -153
  225. package/dist/tools/git-tool.js +0 -292
  226. package/dist/tools/parser.js +0 -158
  227. package/dist/tools/registry.js +0 -302
  228. package/dist/tools/search.js +0 -100
  229. package/dist/types.js +0 -2
  230. package/dist/utils/check-api-status.js +0 -100
  231. package/dist/utils/diff-parser.js +0 -162
  232. package/dist/verification/backup.js +0 -259
  233. package/dist/verification/compiler.js +0 -264
  234. package/dist/verification/index.js +0 -273
  235. package/dist/verification/test-runner.js +0 -379
@@ -1,183 +0,0 @@
1
- /**
2
- * CLI Command: Learning Dashboard
3
- * View patterns learned, knowledge accumulated, cross-team insights
4
- *
5
- * Clean Architecture: Presentation Layer
6
- */
7
- import { container } from '../../../application/services/dependency-container.js';
8
- import { findCodebaseRoot } from '../../../domain/services/codebase-detector.js';
9
- import { colors, sectionHeader, error, warning, info, newline, createBanner, } from '../../../ui.js';
10
- import { executionTracer } from '../../../infrastructure/observability/execution-tracer.js';
11
- export async function executeLearningDashboardCommand(action, codebasePath) {
12
- // Start execution tracing
13
- const detectedPath = codebasePath || process.cwd();
14
- const codebaseInfo = findCodebaseRoot(detectedPath);
15
- if (!codebaseInfo) {
16
- console.log(error('Can\'t find a codebase. Try running from your project folder.'));
17
- return;
18
- }
19
- const runId = executionTracer.startRun('learning-dashboard', {
20
- codebaseId: codebaseInfo.rootPath,
21
- });
22
- try {
23
- console.log(createBanner('Learning Dashboard', 'How your codebase has evolved'));
24
- newline();
25
- const codebaseId = codebaseInfo.codebaseId;
26
- console.log(colors.dim(`Codebase: ${codebaseInfo.rootPath} (${codebaseInfo.type})`));
27
- newline();
28
- switch (action) {
29
- case 'overview': {
30
- await showOverview(codebaseId);
31
- break;
32
- }
33
- case 'patterns': {
34
- await showPatterns(codebaseId);
35
- break;
36
- }
37
- case 'knowledge': {
38
- await showKnowledge(codebaseId);
39
- break;
40
- }
41
- case 'insights': {
42
- await showInsights(codebaseId);
43
- break;
44
- }
45
- default:
46
- console.log(error(`Unknown action: ${action}`));
47
- console.log(info('Available actions: overview, patterns, knowledge, insights'));
48
- }
49
- }
50
- catch (err) {
51
- const { displayError } = await import('../error-display.js');
52
- displayError(err, {
53
- operation: `learning-dashboard-${action}`,
54
- showSuggestions: true,
55
- });
56
- throw err;
57
- }
58
- finally {
59
- executionTracer.endRun();
60
- }
61
- }
62
- async function showOverview(codebaseId) {
63
- console.log(sectionHeader('Learning Overview'));
64
- // Patterns
65
- const patternRepository = container.patternRepository;
66
- const patterns = await patternRepository.findByCodebase(codebaseId);
67
- // Knowledge
68
- const knowledgeAccess = container.knowledgeAccess;
69
- const knowledgeSummary = await knowledgeAccess.getSummary(codebaseId);
70
- // Decisions
71
- const decisionRepository = container.decisionRepository;
72
- const decisions = await decisionRepository.findByCodebase(codebaseId, 10);
73
- // Memory
74
- const memoryRepository = container.memoryRepository;
75
- const memories = await memoryRepository.findRecentByCodebase(codebaseId, 100);
76
- console.log(colors.bold('\nPatterns Learned:'));
77
- console.log(` Total: ${patterns.length}`);
78
- const byType = patterns.reduce((acc, p) => {
79
- acc[p.type] = (acc[p.type] || 0) + 1;
80
- return acc;
81
- }, {});
82
- Object.entries(byType).forEach(([type, count]) => {
83
- console.log(` ${type}: ${count}`);
84
- });
85
- console.log(colors.bold('\nKnowledge Preserved:'));
86
- console.log(` Total: ${knowledgeSummary.totalKnowledge}`);
87
- Object.entries(knowledgeSummary.byType).forEach(([type, count]) => {
88
- console.log(` ${type}: ${count}`);
89
- });
90
- console.log(colors.bold('\nDecisions Recorded:'));
91
- console.log(` Total: ${decisions.length}`);
92
- const byDecisionType = decisions.reduce((acc, d) => {
93
- acc[d.type] = (acc[d.type] || 0) + 1;
94
- return acc;
95
- }, {});
96
- Object.entries(byDecisionType).forEach(([type, count]) => {
97
- const countNum = count;
98
- console.log(` ${type}: ${count}`);
99
- });
100
- console.log(colors.bold('\nMemory Items:'));
101
- console.log(` Recent: ${memories.length}`);
102
- const byMemoryType = memories.reduce((acc, m) => {
103
- acc[m.type] = (acc[m.type] || 0) + 1;
104
- return acc;
105
- }, {});
106
- Object.entries(byMemoryType).forEach(([type, count]) => {
107
- console.log(` ${type}: ${count}`);
108
- });
109
- }
110
- async function showPatterns(codebaseId) {
111
- console.log(sectionHeader('Patterns Learned'));
112
- const patternRepository = container.patternRepository;
113
- const patterns = await patternRepository.findByCodebase(codebaseId);
114
- if (patterns.length === 0) {
115
- console.log(warning('No patterns yet. Index your codebase first.'));
116
- return;
117
- }
118
- // Group by type
119
- const byType = {};
120
- patterns.forEach(p => {
121
- if (!byType[p.type])
122
- byType[p.type] = [];
123
- byType[p.type].push(p);
124
- });
125
- Object.entries(byType).forEach(([type, typePatterns]) => {
126
- console.log(colors.bold(`\n${type.toUpperCase()} (${typePatterns.length}):`));
127
- typePatterns
128
- .sort((a, b) => (b.usageCount || 0) - (a.usageCount || 0))
129
- .slice(0, 10)
130
- .forEach((p, i) => {
131
- console.log(` ${i + 1}. ${p.name}`);
132
- console.log(colors.dim(` ${p.description.substring(0, 80)}...`));
133
- console.log(colors.dim(` Used ${p.usageCount || 0} times`));
134
- });
135
- });
136
- }
137
- async function showKnowledge(codebaseId) {
138
- console.log(sectionHeader('Knowledge Preserved'));
139
- const knowledgeAccess = container.knowledgeAccess;
140
- const summary = await knowledgeAccess.getSummary(codebaseId);
141
- console.log(colors.bold('\nSummary:'));
142
- console.log(` ${summary.summary}`);
143
- if (summary.mostAccessed.length > 0) {
144
- console.log(colors.bold('\nMost Accessed Knowledge:'));
145
- summary.mostAccessed.forEach((k, i) => {
146
- console.log(` ${i + 1}. ${k.title}`);
147
- console.log(colors.dim(` ${k.content.substring(0, 80)}...`));
148
- });
149
- }
150
- if (summary.recent.length > 0) {
151
- console.log(colors.bold('\nRecent Knowledge:'));
152
- summary.recent.forEach((k, i) => {
153
- console.log(` ${i + 1}. ${k.title} (${k.extractedAt.toLocaleDateString()})`);
154
- });
155
- }
156
- }
157
- async function showInsights(codebaseId) {
158
- console.log(sectionHeader('Learning Insights'));
159
- const patternRepository = container.patternRepository;
160
- const patterns = await patternRepository.findByCodebase(codebaseId);
161
- const knowledgeAccess = container.knowledgeAccess;
162
- const knowledgeSummary = await knowledgeAccess.getSummary(codebaseId);
163
- console.log(colors.bold('\nPattern Insights:'));
164
- const mostUsed = patterns
165
- .sort((a, b) => (b.usageCount || 0) - (a.usageCount || 0))
166
- .slice(0, 5);
167
- if (mostUsed.length > 0) {
168
- console.log(' Most reused patterns:');
169
- mostUsed.forEach((p, i) => {
170
- console.log(` ${i + 1}. ${p.name} (${p.usageCount || 0} uses)`);
171
- });
172
- }
173
- console.log(colors.bold('\nKnowledge Insights:'));
174
- console.log(` Knowledge items preserved: ${knowledgeSummary.totalKnowledge}`);
175
- console.log(` Most common types: ${Object.keys(knowledgeSummary.byType).join(', ')}`);
176
- console.log(colors.bold('\nLearning Velocity:'));
177
- const recentPatterns = patterns.filter(p => {
178
- const daysSinceCreation = (Date.now() - p.createdAt.getTime()) / (1000 * 60 * 60 * 24);
179
- return daysSinceCreation <= 7;
180
- });
181
- console.log(` Patterns learned this week: ${recentPatterns.length}`);
182
- }
183
- //# sourceMappingURL=learning-dashboard-command.js.map
@@ -1,194 +0,0 @@
1
- /**
2
- * Models Command
3
- * List, search, and get info about available AI models
4
- */
5
- import { DependencyContainer } from '../../../application/services/dependency-container.js';
6
- import { createBanner, newline, isMinimalStyle } from '../../../ui.js';
7
- import chalk from 'chalk';
8
- export async function executeModelsCommand(options) {
9
- const container = new DependencyContainer();
10
- const registry = container.providerRegistry;
11
- // Show header
12
- if (!isMinimalStyle()) {
13
- console.log(createBanner('AI Models', 'Available models across all providers'));
14
- newline();
15
- }
16
- // List all models
17
- if (options.list || (!options.search && !options.info)) {
18
- await listModels(registry, options.provider, options.json);
19
- return;
20
- }
21
- // Search models
22
- if (options.search) {
23
- await searchModels(registry, options.search, options.provider, options.json);
24
- return;
25
- }
26
- // Get model info
27
- if (options.info) {
28
- await getModelInfo(registry, options.info, options.provider, options.json);
29
- return;
30
- }
31
- }
32
- async function listModels(registry, providerFilter, jsonOutput) {
33
- const allModels = [];
34
- // Get models from all providers
35
- const providers = providerFilter
36
- ? [registry.get(providerFilter)].filter(Boolean)
37
- : Array.from(registry.getAll().values());
38
- for (const provider of providers) {
39
- try {
40
- const models = await provider.getModels();
41
- for (const model of models) {
42
- const capabilities = [];
43
- if (model.capabilities.chat)
44
- capabilities.push('chat');
45
- if (model.capabilities.streaming)
46
- capabilities.push('streaming');
47
- if (model.capabilities.embedding)
48
- capabilities.push('embedding');
49
- if (model.capabilities.rerank)
50
- capabilities.push('rerank');
51
- if (model.capabilities.toolCalling)
52
- capabilities.push('tools');
53
- allModels.push({
54
- id: model.id,
55
- name: model.name,
56
- provider: provider.id,
57
- contextWindow: model.contextWindow,
58
- capabilities,
59
- });
60
- }
61
- }
62
- catch (error) {
63
- // Skip providers that fail
64
- if (!jsonOutput) {
65
- console.warn(chalk.yellow(`⚠️ Failed to get models from ${provider.id}: ${error instanceof Error ? error.message : String(error)}`));
66
- }
67
- }
68
- }
69
- if (jsonOutput) {
70
- console.log(JSON.stringify(allModels, null, 2));
71
- return;
72
- }
73
- // Group by provider
74
- const byProvider = new Map();
75
- for (const model of allModels) {
76
- if (!byProvider.has(model.provider)) {
77
- byProvider.set(model.provider, []);
78
- }
79
- byProvider.get(model.provider).push(model);
80
- }
81
- // Display
82
- for (const [providerId, models] of byProvider.entries()) {
83
- const provider = registry.get(providerId);
84
- const providerName = provider?.name || providerId;
85
- console.log(chalk.bold(`\n${providerName} (${models.length} models):`));
86
- for (const model of models.slice(0, 20)) { // Limit to 20 per provider
87
- const caps = model.capabilities.join(', ');
88
- console.log(` ${chalk.cyan(model.id)} - ${model.name}`);
89
- console.log(` Context: ${model.contextWindow.toLocaleString()} tokens | Capabilities: ${caps}`);
90
- }
91
- if (models.length > 20) {
92
- console.log(chalk.dim(` ... and ${models.length - 20} more models`));
93
- }
94
- }
95
- console.log(chalk.dim(`\nTotal: ${allModels.length} models from ${byProvider.size} providers`));
96
- console.log(chalk.dim('Use "codehere models search <query>" to search, or "codehere models info <model-id>" for details'));
97
- }
98
- async function searchModels(registry, query, providerFilter, jsonOutput) {
99
- const allModels = [];
100
- const providers = providerFilter
101
- ? [registry.get(providerFilter)].filter(Boolean)
102
- : Array.from(registry.getAll().values());
103
- for (const provider of providers) {
104
- try {
105
- const models = await provider.getModels();
106
- for (const model of models) {
107
- const searchText = `${model.id} ${model.name}`.toLowerCase();
108
- if (searchText.includes(query.toLowerCase())) {
109
- const capabilities = [];
110
- if (model.capabilities.chat)
111
- capabilities.push('chat');
112
- if (model.capabilities.streaming)
113
- capabilities.push('streaming');
114
- if (model.capabilities.embedding)
115
- capabilities.push('embedding');
116
- if (model.capabilities.rerank)
117
- capabilities.push('rerank');
118
- if (model.capabilities.toolCalling)
119
- capabilities.push('tools');
120
- allModels.push({
121
- id: model.id,
122
- name: model.name,
123
- provider: provider.id,
124
- contextWindow: model.contextWindow,
125
- capabilities,
126
- });
127
- }
128
- }
129
- }
130
- catch (error) {
131
- // Skip providers that fail
132
- }
133
- }
134
- if (jsonOutput) {
135
- console.log(JSON.stringify(allModels, null, 2));
136
- return;
137
- }
138
- if (allModels.length === 0) {
139
- console.log(chalk.yellow(`No models found matching "${query}"`));
140
- return;
141
- }
142
- console.log(chalk.bold(`Found ${allModels.length} model(s) matching "${query}":\n`));
143
- for (const model of allModels) {
144
- const caps = model.capabilities.join(', ');
145
- console.log(`${chalk.cyan(model.id)} - ${model.name}`);
146
- console.log(` Provider: ${model.provider} | Context: ${model.contextWindow.toLocaleString()} tokens | Capabilities: ${caps}`);
147
- console.log();
148
- }
149
- }
150
- async function getModelInfo(registry, modelId, providerFilter, jsonOutput) {
151
- const providers = providerFilter
152
- ? [registry.get(providerFilter)].filter(Boolean)
153
- : Array.from(registry.getAll().values());
154
- for (const provider of providers) {
155
- try {
156
- const models = await provider.getModels();
157
- const model = models.find((m) => m.id === modelId || m.providerModelId === modelId);
158
- if (model) {
159
- if (jsonOutput) {
160
- console.log(JSON.stringify({
161
- id: model.id,
162
- name: model.name,
163
- provider: provider.id,
164
- providerModelId: model.providerModelId,
165
- contextWindow: model.contextWindow,
166
- capabilities: model.capabilities,
167
- }, null, 2));
168
- }
169
- else {
170
- console.log(chalk.bold(`\nModel: ${model.name}`));
171
- console.log(` ID: ${chalk.cyan(model.id)}`);
172
- console.log(` Provider: ${provider.name} (${provider.id})`);
173
- console.log(` Provider Model ID: ${model.providerModelId}`);
174
- console.log(` Context Window: ${model.contextWindow.toLocaleString()} tokens`);
175
- console.log(` Capabilities:`);
176
- console.log(` - Chat: ${model.capabilities.chat ? '✅' : '❌'}`);
177
- console.log(` - Streaming: ${model.capabilities.streaming ? '✅' : '❌'}`);
178
- console.log(` - Embedding: ${model.capabilities.embedding ? '✅' : '❌'}`);
179
- console.log(` - Rerank: ${model.capabilities.rerank ? '✅' : '❌'}`);
180
- console.log(` - Tool Calling: ${model.capabilities.toolCalling ? '✅' : '❌'}`);
181
- }
182
- return;
183
- }
184
- }
185
- catch (error) {
186
- // Continue searching
187
- }
188
- }
189
- if (!jsonOutput) {
190
- console.log(chalk.red(`Model "${modelId}" not found`));
191
- console.log(chalk.dim('Use "codehere models list" to see all available models'));
192
- }
193
- }
194
- //# sourceMappingURL=models-command.js.map
@@ -1,207 +0,0 @@
1
- /**
2
- * CLI Command: Orchestrate
3
- * Multi-agent orchestration command
4
- */
5
- import { container } from '../../../application/services/dependency-container.js';
6
- import { colors, sectionHeader, success, error, warning, newline, createBanner, createSpinner, isMinimalStyle, printMinimalHeader, } from '../../../ui.js';
7
- import { executionTracer } from '../../../infrastructure/observability/execution-tracer.js';
8
- import { findCodebaseRoot } from '../../../domain/services/codebase-detector.js';
9
- import { getPlanRepository } from '../../../infrastructure/storage/plan-repository.js';
10
- import { displayError } from '../error-display.js';
11
- import { summaryExtractor } from '../../../infrastructure/validation/summary-extractor.js';
12
- import { reviewHandler } from '../../../infrastructure/validation/review-handler.js';
13
- export async function executeOrchestrateCommand(goal, options = {}) {
14
- // Start execution tracing
15
- const codebaseInfo = findCodebaseRoot(process.cwd());
16
- const userId = codebaseInfo?.rootPath || process.cwd() || 'cli-user';
17
- // Progressive Disclosure: Check feature access (orchestrate is advanced feature)
18
- const progressiveDisclosure = container.progressiveDisclosure;
19
- if (progressiveDisclosure) {
20
- const { checkFeatureAccess, displayFeatureAvailability } = await import('../../../infrastructure/ux/staged-feature-intro.js');
21
- const profile = progressiveDisclosure.getUserProfile(userId);
22
- // Use planning feature check since orchestrate builds on planning
23
- const access = checkFeatureAccess(progressiveDisclosure, userId, 'planning');
24
- if (!access.shouldContinue) {
25
- executionTracer.endRun();
26
- return;
27
- }
28
- displayFeatureAvailability('Multi-Agent Orchestration', 'advanced', profile.level);
29
- progressiveDisclosure.recordFeatureUsage(userId, 'planning'); // Record as planning usage
30
- }
31
- const runId = executionTracer.startRun('orchestrate', {
32
- query: goal,
33
- codebaseId: codebaseInfo?.rootPath || process.cwd(),
34
- });
35
- if (isMinimalStyle()) {
36
- printMinimalHeader('orchestrate', goal);
37
- if (options.mode) {
38
- console.log(colors.dim(`Mode: ${options.mode}`));
39
- }
40
- }
41
- else {
42
- console.log(createBanner('Multi-Agent Orchestration', 'Planning → Execution → Validation'));
43
- newline();
44
- console.log(colors.bold('Goal:'));
45
- console.log(colors.cyan(' ' + goal));
46
- console.log(colors.dim(`Mode: ${options.mode || 'full'}`));
47
- newline();
48
- }
49
- const orchestrator = container.multiAgentOrchestrator;
50
- // Load plan from repository if planId provided
51
- let loadedPlan = null;
52
- if (options.planId) {
53
- const planRepository = getPlanRepository();
54
- loadedPlan = await planRepository.get(options.planId);
55
- if (!loadedPlan) {
56
- displayError(new Error(`Plan ${options.planId} not found`), {
57
- operation: 'orchestrate',
58
- query: goal,
59
- showSuggestions: true,
60
- });
61
- process.exit(1);
62
- }
63
- console.log(colors.dim(`Loaded plan: ${loadedPlan.goal} (${loadedPlan.status})`));
64
- newline();
65
- }
66
- const spinner = createSpinner('Orchestrating multi-agent workflow...');
67
- spinner.start();
68
- try {
69
- const result = await orchestrator.orchestrate({
70
- goal: loadedPlan?.goal || goal,
71
- mode: options.mode || 'full',
72
- context: loadedPlan ? { plan: loadedPlan } : undefined,
73
- });
74
- spinner.stop();
75
- newline();
76
- if (result.plan) {
77
- sectionHeader('Generated Plan');
78
- console.log(colors.bold('Goal: ') + result.plan.goal);
79
- console.log(colors.dim(`Plan ID: ${result.plan.id}`));
80
- console.log(colors.dim(`Status: ${result.plan.status}`));
81
- console.log(colors.dim(`Sub-plans: ${result.plan.subPlans.length}`));
82
- newline();
83
- result.plan.subPlans.forEach((subPlan, index) => {
84
- const statusIconMap = {
85
- pending: '○',
86
- in_progress: '⟳',
87
- completed: '✓',
88
- failed: '✗',
89
- };
90
- const statusIcon = statusIconMap[subPlan.status] || '○';
91
- console.log(`${statusIcon} ${colors.bold(`Sub-plan ${index + 1}:`)} ${subPlan.description}`);
92
- console.log(` Type: ${subPlan.type} | Complexity: ${subPlan.estimatedComplexity || 'medium'} | Dependencies: ${subPlan.dependencies.length > 0 ? subPlan.dependencies.join(', ') : 'None'}`);
93
- if (subPlan.error) {
94
- console.log(error(` Error: ${subPlan.error}`));
95
- }
96
- newline();
97
- });
98
- }
99
- if (result.execution) {
100
- sectionHeader('Execution Results');
101
- console.log(colors.bold(`Completed: ${result.execution.completedSubPlans}/${result.execution.totalSubPlans} sub-plans`));
102
- console.log(colors.bold(`Result: ${result.execution.overallSuccess ? 'Succeeded' : 'Failed'}`));
103
- newline();
104
- result.execution.results.forEach((execResult, index) => {
105
- const icon = execResult.success ? '✓' : '✗';
106
- const color = execResult.success ? colors.green : colors.red;
107
- console.log(`${color(icon)} ${execResult.subPlanId}: ${execResult.success ? 'Success' : 'Failed'} (${execResult.duration}ms)`);
108
- if (execResult.error) {
109
- console.log(colors.dim(` Error: ${execResult.error}`));
110
- }
111
- });
112
- newline();
113
- }
114
- if (result.validation) {
115
- sectionHeader('Validation Results');
116
- console.log(colors.bold(`Quality Score: ${result.validation.qualityScore}/100`));
117
- console.log(`Compilation: ${result.validation.compilationSuccess ? success('Pass') : error('Fail')}`);
118
- console.log(`Tests: ${result.validation.testsPassed ? success('Pass') : error('Fail')}`);
119
- if (result.validation.testResults) {
120
- console.log(`Test Results: ${result.validation.testResults.passed} passed, ${result.validation.testResults.failed} failed, ${result.validation.testResults.total} total`);
121
- }
122
- if (result.validation.recommendations.length > 0) {
123
- newline();
124
- console.log(colors.bold('Recommendations:'));
125
- result.validation.recommendations.forEach((rec, i) => {
126
- console.log(`${i + 1}. ${rec}`);
127
- });
128
- }
129
- newline();
130
- }
131
- // Get review decision - single source of truth for userAction
132
- // All CLI commands use this same pattern: getReviewDecision() → use decision.userAction
133
- const reviewRequested = Boolean(options.review);
134
- const summarySource = summaryExtractor.extractFromOrchestration(result);
135
- const decision = summarySource
136
- ? await reviewHandler.getReviewDecision(summarySource.summary, reviewRequested)
137
- : { approved: true, proceed: true, userAction: 'not_required' };
138
- if (!decision.approved) {
139
- console.log(warning('Operation cancelled by user.'));
140
- newline();
141
- // Record feedback for rejection
142
- if (result.compositeSummary) {
143
- const { agentFeedbackManager } = await import('../../../infrastructure/validation/agent-feedback.js');
144
- agentFeedbackManager.recordFeedback({
145
- runId: result.unifiedRunId || runId,
146
- agentName: 'multi-agent-orchestrator',
147
- operation: 'orchestrate',
148
- query: goal,
149
- outcome: 'cancelled',
150
- userAction: decision.userAction,
151
- filesChanged: result.compositeSummary.filesChanged,
152
- filesCreated: result.compositeSummary.filesCreated,
153
- filesDeleted: result.compositeSummary.filesDeleted,
154
- errors: result.compositeSummary.errors,
155
- warnings: result.compositeSummary.warnings,
156
- validationChecks: result.compositeSummary.validationChecks,
157
- metrics: result.compositeSummary.metrics,
158
- });
159
- }
160
- return;
161
- }
162
- // Record feedback with userAction from review decision
163
- if (result.compositeSummary) {
164
- const { agentFeedbackManager } = await import('../../../infrastructure/validation/agent-feedback.js');
165
- agentFeedbackManager.recordFeedback({
166
- runId: result.unifiedRunId || runId,
167
- agentName: 'multi-agent-orchestrator',
168
- operation: 'orchestrate',
169
- query: goal,
170
- outcome: result.success ? 'success' : 'failure',
171
- userAction: decision.userAction,
172
- filesChanged: result.compositeSummary.filesChanged,
173
- filesCreated: result.compositeSummary.filesCreated,
174
- filesDeleted: result.compositeSummary.filesDeleted,
175
- errors: result.compositeSummary.errors,
176
- warnings: result.compositeSummary.warnings,
177
- validationChecks: result.compositeSummary.validationChecks,
178
- metrics: result.compositeSummary.metrics,
179
- });
180
- }
181
- newline();
182
- if (result.success) {
183
- console.log(success(result.message));
184
- }
185
- else {
186
- console.log(error(result.message));
187
- if (result.feedback) {
188
- console.log(warning(`Feedback: ${result.feedback}`));
189
- }
190
- }
191
- newline();
192
- }
193
- catch (err) {
194
- spinner.stop();
195
- const { displayErrorAndExit } = await import('../error-display.js');
196
- displayErrorAndExit(err, {
197
- operation: 'orchestrate',
198
- query: goal,
199
- showSuggestions: true,
200
- exitCode: 1,
201
- });
202
- }
203
- finally {
204
- executionTracer.endRun();
205
- }
206
- }
207
- //# sourceMappingURL=orchestrate-command.js.map