codehere 0.2.1 → 0.3.0-rc.1

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 +335 -63
  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 +10 -49
  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 +334 -43
  33. package/dist/presentation/cli/commands/trust-command.js +115 -99
  34. package/dist/presentation/cli/error-display.js +17 -21
  35. package/dist/ui.js +17 -12
  36. package/package.json +35 -67
  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 -530
  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 -652
  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,191 +0,0 @@
1
- /**
2
- * CLI Command: Cost
3
- * View API cost tracking and budget status
4
- *
5
- * Clean Architecture: Presentation Layer
6
- */
7
- import { getCostTracker } from '../../../infrastructure/cost/cost-tracker.js';
8
- import { colors, sectionHeader, success, error, warning, info, newline, createBanner, createTable, formatNumber, } from '../../../ui.js';
9
- import { executionTracer } from '../../../infrastructure/observability/execution-tracer.js';
10
- import { findCodebaseRoot } from '../../../domain/services/codebase-detector.js';
11
- export async function executeCostCommand(action, runId) {
12
- // Start execution tracing
13
- const codebaseInfo = findCodebaseRoot(process.cwd());
14
- const traceRunId = executionTracer.startRun('cost', {
15
- codebaseId: codebaseInfo?.rootPath || process.cwd(),
16
- });
17
- try {
18
- console.log(createBanner('Cost Tracking', 'What you\'re spending'));
19
- newline();
20
- const costTracker = getCostTracker();
21
- switch (action) {
22
- case 'status': {
23
- await showBudgetStatus(costTracker);
24
- break;
25
- }
26
- case 'summary': {
27
- await showCostSummary(costTracker);
28
- break;
29
- }
30
- case 'run': {
31
- if (!runId) {
32
- console.log(error('Run ID is required for "run" action'));
33
- console.log(info('Usage: codehere cost run <runId>'));
34
- return;
35
- }
36
- await showRunCosts(costTracker, runId);
37
- break;
38
- }
39
- case 'reset': {
40
- await resetCosts(costTracker);
41
- break;
42
- }
43
- default:
44
- console.log(error(`Unknown action: ${action}`));
45
- console.log(info('Available actions: status, summary, run, reset'));
46
- }
47
- }
48
- catch (err) {
49
- const { displayError } = await import('../error-display.js');
50
- displayError(err, {
51
- operation: `cost-${action}`,
52
- showSuggestions: true,
53
- });
54
- throw err;
55
- }
56
- finally {
57
- executionTracer.endRun();
58
- }
59
- }
60
- async function showBudgetStatus(costTracker) {
61
- const status = await costTracker.getBudgetStatus();
62
- const budgetLimit = costTracker.getBudgetLimit();
63
- sectionHeader('Cost Tracking (LOCAL ESTIMATE)');
64
- newline();
65
- console.log(warning('⚠️ This is a local estimate based on token counts, not your actual billing.'));
66
- console.log(colors.dim(' It does NOT sync with your provider billing dashboard.'));
67
- console.log(colors.dim(' Check your provider dashboard for actual usage.'));
68
- console.log(colors.dim(' Use "codehere cost reset" to reset for new billing period.'));
69
- newline();
70
- if (budgetLimit !== null && budgetLimit > 0 && status.percentage !== null) {
71
- const percentage = status.percentage;
72
- const barLength = 40;
73
- const filled = Math.floor((percentage / 100) * barLength);
74
- const bar = '█'.repeat(filled) + '░'.repeat(barLength - filled);
75
- let barColor = colors.green;
76
- if (percentage >= 100) {
77
- barColor = colors.yellow; // Changed from red to yellow - it's just a warning
78
- }
79
- else if (percentage >= 80) {
80
- barColor = colors.yellow;
81
- }
82
- console.log(colors.bold('Budget Status (Local Estimate Only):'));
83
- console.log(` ${barColor(bar)} ${percentage.toFixed(1)}%`);
84
- newline();
85
- console.log(colors.bold('Details:'));
86
- console.log(` Spent (Estimate): ${colors.cyan(`$${status.spent.toFixed(4)}`)}`);
87
- console.log(` Limit: ${colors.cyan(`$${status.limit.toFixed(2)}`)}`);
88
- console.log(` Remaining: ${colors.cyan(`$${status.remaining.toFixed(4)}`)}`);
89
- newline();
90
- if (status.alert) {
91
- console.log(warning('⚠️ Approaching budget limit (local estimate only)!'));
92
- console.log(colors.dim(' This is a LOCAL ESTIMATE - check https://dashboard.cohere.com for actual usage'));
93
- console.log(colors.dim(' API calls will continue. Run "codehere cost reset" to reset local tracking.'));
94
- newline();
95
- }
96
- if (status.spent >= status.limit) {
97
- console.log(warning('⚠️ Budget exceeded (local estimate only)!'));
98
- console.log(colors.dim(' This is a LOCAL ESTIMATE - check https://dashboard.cohere.com for actual usage'));
99
- console.log(colors.dim(' API calls will continue. Run "codehere cost reset" to reset local tracking.'));
100
- newline();
101
- }
102
- }
103
- else {
104
- console.log(colors.bold('No Budget Limit Set'));
105
- console.log(colors.dim(' Set CODEHERE_BUDGET_LIMIT env var to enable budget tracking.'));
106
- newline();
107
- console.log(colors.bold('Current Usage (Estimate):'));
108
- console.log(` Total: ${colors.cyan(`$${status.spent.toFixed(4)}`)}`);
109
- newline();
110
- }
111
- }
112
- async function showCostSummary(costTracker) {
113
- const summary = await costTracker.getSummary();
114
- sectionHeader('Cost Summary');
115
- newline();
116
- console.log(colors.bold('Total Costs:'));
117
- console.log(` Total: ${colors.cyan(`$${summary.totalCost.toFixed(4)}`)}`);
118
- console.log(` Operations: ${formatNumber(summary.operationCount)}`);
119
- console.log(` Daily: ${colors.cyan(`$${summary.dailyCost.toFixed(4)}`)}`);
120
- console.log(` Monthly: ${colors.cyan(`$${summary.monthlyCost.toFixed(4)}`)}`);
121
- newline();
122
- if (Object.keys(summary.byOperation).length > 0) {
123
- sectionHeader('Cost by Operation');
124
- const operationRows = Object.entries(summary.byOperation)
125
- .sort((a, b) => b[1].cost - a[1].cost)
126
- .map(([operation, data]) => {
127
- const d = data;
128
- return [
129
- operation,
130
- formatNumber(d.count),
131
- `$${d.cost.toFixed(4)}`,
132
- ];
133
- });
134
- const operationTable = createTable(['Operation', 'Count', 'Cost'], operationRows);
135
- console.log(operationTable.toString());
136
- newline();
137
- }
138
- if (Object.keys(summary.byModel).length > 0) {
139
- sectionHeader('Cost by Model');
140
- const modelRows = Object.entries(summary.byModel)
141
- .sort((a, b) => b[1].cost - a[1].cost)
142
- .map(([model, data]) => {
143
- const d = data;
144
- return [
145
- model,
146
- formatNumber(d.count),
147
- `$${d.cost.toFixed(4)}`,
148
- ];
149
- });
150
- const modelTable = createTable(['Model', 'Count', 'Cost'], modelRows);
151
- console.log(modelTable.toString());
152
- newline();
153
- }
154
- }
155
- async function showRunCosts(costTracker, runId) {
156
- const costs = await costTracker.getRunCosts(runId);
157
- if (costs.length === 0) {
158
- console.log(warning(`No costs found for run ${runId}`));
159
- return;
160
- }
161
- sectionHeader(`Costs for Run: ${runId}`);
162
- newline();
163
- const totalCost = costs.reduce((sum, cost) => sum + cost.cost, 0);
164
- const costRows = costs.map((cost) => [
165
- new Date(cost.timestamp).toISOString(),
166
- cost.operation,
167
- cost.model || 'default',
168
- cost.inputTokens ? formatNumber(cost.inputTokens) : 'N/A',
169
- cost.outputTokens ? formatNumber(cost.outputTokens) : 'N/A',
170
- `$${cost.cost.toFixed(6)}`,
171
- ]);
172
- const costTable = createTable(['Timestamp', 'Operation', 'Model', 'Input Tokens', 'Output Tokens', 'Cost'], costRows);
173
- console.log(costTable.toString());
174
- newline();
175
- console.log(colors.bold(`Total Run Cost: ${colors.cyan(`$${totalCost.toFixed(4)}`)}`));
176
- newline();
177
- }
178
- async function resetCosts(costTracker) {
179
- console.log(warning('⚠️ This will delete all LOCAL cost tracking records.'));
180
- console.log(colors.dim(' This does NOT affect your actual Cohere billing.'));
181
- console.log(colors.dim(' Use this to reset local tracking for a new billing period.'));
182
- console.log(colors.dim(' This action cannot be undone.'));
183
- newline();
184
- // In a real implementation, you might want to add a confirmation prompt
185
- // For now, we'll just reset
186
- await costTracker.resetCosts();
187
- console.log(success('Cost tracking reset.'));
188
- console.log(colors.dim(' Note: This is local tracking only. Check Cohere dashboard for actual usage.'));
189
- newline();
190
- }
191
- //# sourceMappingURL=cost-command.js.map
@@ -1,207 +0,0 @@
1
- /**
2
- * CLI Command: Decision
3
- * Record and query architectural/design decisions
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, success, error, info, newline, createBanner, createSpinner, } from '../../../ui.js';
10
- import { executionTracer } from '../../../infrastructure/observability/execution-tracer.js';
11
- export async function executeDecisionCommand(action, args, options = {}) {
12
- // Start execution tracing
13
- const codebasePath = options.codebase || process.cwd();
14
- const codebaseInfo = findCodebaseRoot(codebasePath);
15
- if (!codebaseInfo) {
16
- console.log(error('Can\'t find a codebase here. Are you in a project folder?'));
17
- return;
18
- }
19
- const runId = executionTracer.startRun('decision', {
20
- query: args.join(' '),
21
- codebaseId: codebaseInfo.rootPath,
22
- });
23
- try {
24
- console.log(createBanner('Decision Recording', 'Why you built it this way'));
25
- newline();
26
- const codebaseId = codebaseInfo.codebaseId;
27
- console.log(colors.dim(`Codebase: ${codebaseInfo.rootPath} (${codebaseInfo.type})`));
28
- newline();
29
- const decisionRecorder = container.decisionRecorder;
30
- const decisionRetriever = container.decisionRetriever;
31
- switch (action) {
32
- case 'record': {
33
- await handleRecord(args, codebaseId, decisionRecorder);
34
- break;
35
- }
36
- case 'list': {
37
- await handleList(codebaseId, decisionRetriever, options);
38
- break;
39
- }
40
- case 'query': {
41
- await handleQuery(args.join(' '), codebaseId, decisionRetriever, options);
42
- break;
43
- }
44
- case 'explain': {
45
- await handleExplain(args[0], decisionRetriever);
46
- break;
47
- }
48
- default: {
49
- console.log(error(`Unknown action: ${action}`));
50
- console.log(info('Available actions: record, list, query, explain'));
51
- break;
52
- }
53
- }
54
- }
55
- catch (err) {
56
- const { displayError } = await import('../error-display.js');
57
- displayError(err, {
58
- operation: `decision-${action}`,
59
- showSuggestions: true,
60
- });
61
- throw err;
62
- }
63
- finally {
64
- executionTracer.endRun();
65
- }
66
- }
67
- async function handleRecord(args, codebaseId, decisionRecorder) {
68
- if (args.length === 0) {
69
- console.log(error('Please provide a decision to record'));
70
- console.log(info('Usage: codehere decision record "We chose React because..."'));
71
- return;
72
- }
73
- const decisionText = args.join(' ');
74
- const spinner = createSpinner('Recording decision...');
75
- spinner.start();
76
- try {
77
- // For now, create a simple decision from text
78
- // In the future, we could prompt for more details
79
- const decision = await decisionRecorder.recordDecision({
80
- codebaseId,
81
- type: 'architectural',
82
- title: decisionText.substring(0, 50),
83
- description: decisionText,
84
- rationale: decisionText,
85
- });
86
- spinner.stop();
87
- console.log(success('Decision saved'));
88
- newline();
89
- console.log(colors.bold('Decision ID:'), decision.id);
90
- console.log(colors.bold('Title:'), decision.title);
91
- console.log(colors.dim('Created at:'), decision.createdAt.toISOString());
92
- }
93
- catch (err) {
94
- spinner.stop();
95
- throw err;
96
- }
97
- }
98
- async function handleList(codebaseId, decisionRetriever, options) {
99
- const spinner = createSpinner('Loading decisions...');
100
- spinner.start();
101
- try {
102
- let decisions;
103
- if (options.type) {
104
- decisions = await decisionRetriever.getByType(codebaseId, options.type, options.limit || 20);
105
- }
106
- else {
107
- decisions = await decisionRetriever.getRecent(codebaseId, options.limit || 10);
108
- }
109
- spinner.stop();
110
- if (decisions.length === 0) {
111
- console.log(info('No decisions saved yet'));
112
- return;
113
- }
114
- sectionHeader(`Decisions (${decisions.length})`);
115
- decisions.forEach((decision, i) => {
116
- console.log(colors.bold(`\n${i + 1}. ${decision.title}`));
117
- console.log(colors.dim(` Type: ${decision.type}`));
118
- console.log(colors.dim(` Rationale: ${decision.rationale.substring(0, 100)}...`));
119
- console.log(colors.dim(` Created: ${decision.createdAt.toISOString()}`));
120
- if (decision.id) {
121
- console.log(colors.dim(` ID: ${decision.id.substring(0, 8)}...`));
122
- }
123
- });
124
- }
125
- catch (err) {
126
- spinner.stop();
127
- throw err;
128
- }
129
- }
130
- async function handleQuery(query, codebaseId, decisionRetriever, options) {
131
- if (!query || query.trim().length === 0) {
132
- console.log(error('Please provide a search query'));
133
- console.log(info('Usage: codehere decision query "authentication"'));
134
- return;
135
- }
136
- const spinner = createSpinner('Searching decisions...');
137
- spinner.start();
138
- try {
139
- const result = await decisionRetriever.queryByContext(codebaseId, query.trim(), options.limit || 10);
140
- spinner.stop();
141
- if (result.decisions.length === 0) {
142
- console.log(info('Nothing matches that search'));
143
- return;
144
- }
145
- sectionHeader(`Found ${result.decisions.length} decision(s)`);
146
- if (result.explanation) {
147
- console.log(colors.dim(result.explanation));
148
- newline();
149
- }
150
- result.decisions.forEach((decision, i) => {
151
- console.log(colors.bold(`\n${i + 1}. ${decision.title}`));
152
- console.log(colors.cyan(` ${decision.description}`));
153
- console.log(colors.dim(` Rationale: ${decision.rationale}`));
154
- });
155
- }
156
- catch (err) {
157
- spinner.stop();
158
- throw err;
159
- }
160
- }
161
- async function handleExplain(decisionId, decisionRetriever) {
162
- if (!decisionId || decisionId.trim().length === 0) {
163
- console.log(error('Please provide a decision ID'));
164
- console.log(info('Usage: codehere decision explain <decision-id>'));
165
- return;
166
- }
167
- const spinner = createSpinner('Retrieving decision explanation...');
168
- spinner.start();
169
- try {
170
- const explanation = await decisionRetriever.explainDecision(decisionId.trim());
171
- spinner.stop();
172
- if (!explanation) {
173
- console.log(error('Decision not found'));
174
- return;
175
- }
176
- sectionHeader('Decision Explanation');
177
- console.log(colors.bold('Title:'), explanation.decision.title);
178
- console.log(colors.bold('Type:'), explanation.decision.type);
179
- newline();
180
- console.log(colors.bold('Rationale:'));
181
- console.log(colors.cyan(explanation.rationale));
182
- newline();
183
- if (explanation.context) {
184
- console.log(colors.bold('Context:'));
185
- console.log(colors.dim(explanation.context));
186
- newline();
187
- }
188
- if (explanation.alternatives && explanation.alternatives.length > 0) {
189
- console.log(colors.bold('Alternatives Considered:'));
190
- explanation.alternatives.forEach((alt) => {
191
- console.log(colors.dim(` - ${alt}`));
192
- });
193
- newline();
194
- }
195
- if (explanation.tradeoffs && explanation.tradeoffs.length > 0) {
196
- console.log(colors.bold('Trade-offs:'));
197
- explanation.tradeoffs.forEach((tradeoff) => {
198
- console.log(colors.dim(` - ${tradeoff}`));
199
- });
200
- }
201
- }
202
- catch (err) {
203
- spinner.stop();
204
- throw err;
205
- }
206
- }
207
- //# sourceMappingURL=decision-command.js.map
@@ -1,25 +0,0 @@
1
- /**
2
- * CLI Command: Docs
3
- * Generate documentation (README, API docs) using DocumentationAgent
4
- *
5
- * Phase 1: v0.5.0-alpha.0
6
- */
7
- import { colors, warning, newline } from '../../../ui.js';
8
- import { displayError } from '../error-display.js';
9
- export async function executeDocsCommand(type, options) {
10
- try {
11
- // In alpha, this is a stub
12
- // Can be enhanced later with DocumentationAgent
13
- console.log(warning('Documentation generation is not yet fully implemented in v0.5.0-alpha.0'));
14
- console.log(colors.dim(`Requested type: ${type}`));
15
- if (options?.target) {
16
- console.log(colors.dim(`Target: ${options.target}`));
17
- }
18
- }
19
- catch (err) {
20
- displayError(err);
21
- process.exit(1);
22
- }
23
- newline();
24
- }
25
- //# sourceMappingURL=docs-command.js.map
@@ -1,53 +0,0 @@
1
- /**
2
- * CLI Command: Fix/Edit
3
- * Apply AI-generated code edits to a file with review support
4
- *
5
- * Phase 1: v0.5.0-alpha.0
6
- */
7
- import { container } from '../../../application/services/dependency-container.js';
8
- import { colors, error, success, newline, isMinimalStyle } from '../../../ui.js';
9
- import { displayError } from '../error-display.js';
10
- export async function executeFixCommand(file, instruction, options) {
11
- const minimal = isMinimalStyle();
12
- // Header
13
- if (minimal) {
14
- console.log(colors.cyan('codehere fix') + colors.dim(' ▸ ') + file);
15
- }
16
- else {
17
- console.log(colors.bold('Fix/Edit'));
18
- console.log(colors.dim(`File: ${file}`));
19
- }
20
- console.log(colors.dim(`Instruction: ${instruction}`));
21
- newline();
22
- try {
23
- // Use edit-file-use-case
24
- const editUseCase = container.editFileUseCase;
25
- const result = await editUseCase.execute({
26
- filepath: file,
27
- instruction,
28
- });
29
- if (result.success) {
30
- console.log(colors.bold('Changes:'));
31
- console.log(success(`✓ Applied changes to ${file}`));
32
- if (result.edit) {
33
- console.log(colors.dim(result.edit));
34
- }
35
- newline();
36
- console.log(colors.dim('Note: Changes have been applied. Use "codehere undo" to revert if needed.'));
37
- }
38
- else {
39
- console.log(colors.bold('Result:'));
40
- console.log(error(`✗ Failed to edit ${file}`));
41
- if (result.error) {
42
- console.log(error(result.error));
43
- }
44
- }
45
- }
46
- catch (err) {
47
- console.log(colors.bold('Result:'));
48
- displayError(err);
49
- process.exit(1);
50
- }
51
- newline();
52
- }
53
- //# sourceMappingURL=fix-command.js.map
@@ -1,129 +0,0 @@
1
- /**
2
- * CLI Command: Knowledge
3
- * Query and manage preserved knowledge
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, success, error, warning, info, newline, createBanner, } from '../../../ui.js';
10
- import { executionTracer } from '../../../infrastructure/observability/execution-tracer.js';
11
- export async function executeKnowledgeCommand(action, args, options = {}) {
12
- // Start execution tracing
13
- const codebasePath = options.codebase || process.cwd();
14
- const codebaseInfo = findCodebaseRoot(codebasePath);
15
- if (!codebaseInfo) {
16
- console.log(error('No codebase detected. Please run from a git repository or project directory.'));
17
- return;
18
- }
19
- const runId = executionTracer.startRun('knowledge', {
20
- query: args.join(' '),
21
- codebaseId: codebaseInfo.rootPath,
22
- });
23
- try {
24
- console.log(createBanner('Knowledge', 'What we know about your code'));
25
- newline();
26
- const codebaseId = codebaseInfo.codebaseId;
27
- console.log(colors.dim(`Codebase: ${codebaseInfo.rootPath} (${codebaseInfo.type})`));
28
- newline();
29
- const knowledgeAccess = container.knowledgeAccess;
30
- const knowledgeExtractor = container.knowledgeExtractor;
31
- switch (action) {
32
- case 'query': {
33
- const query = args.join(' ');
34
- if (!query) {
35
- console.log(error('Query required. Usage: codehere knowledge query <search term>'));
36
- return;
37
- }
38
- console.log(colors.bold('Searching knowledge...'));
39
- const knowledge = await knowledgeAccess.query(codebaseId, query, options.limit || 10);
40
- if (knowledge.length === 0) {
41
- console.log(warning('Nothing matches that search.'));
42
- return;
43
- }
44
- console.log(success(`Found ${knowledge.length} knowledge item(s):\n`));
45
- knowledge.forEach((k, i) => {
46
- console.log(colors.bold(`${i + 1}. ${k.title}`));
47
- console.log(colors.dim(` Type: ${k.type}`));
48
- console.log(colors.dim(` Source: ${k.source.type}${k.source.filepath ? ` (${k.source.filepath})` : ''}`));
49
- console.log(` ${k.content.substring(0, 200)}${k.content.length > 200 ? '...' : ''}`);
50
- if (k.relevanceScore) {
51
- console.log(colors.dim(` Relevance: ${(k.relevanceScore * 100).toFixed(0)}%`));
52
- }
53
- newline();
54
- });
55
- break;
56
- }
57
- case 'list': {
58
- const type = options.type;
59
- console.log(colors.bold(type ? `Listing ${type} knowledge...` : 'Listing all knowledge...'));
60
- const knowledge = type
61
- ? await knowledgeAccess.getByType(codebaseId, type, options.limit || 20)
62
- : await knowledgeAccess.query(codebaseId, '', options.limit || 20);
63
- if (knowledge.length === 0) {
64
- console.log(warning('Nothing saved yet.'));
65
- return;
66
- }
67
- console.log(success(`Found ${knowledge.length} knowledge item(s):\n`));
68
- knowledge.forEach((k, i) => {
69
- console.log(colors.bold(`${i + 1}. ${k.title}`));
70
- console.log(colors.dim(` Type: ${k.type} | Extracted: ${k.extractedAt.toLocaleDateString()}`));
71
- console.log(` ${k.content.substring(0, 100)}${k.content.length > 100 ? '...' : ''}`);
72
- newline();
73
- });
74
- break;
75
- }
76
- case 'summary': {
77
- console.log(colors.bold('Generating knowledge summary...'));
78
- const summary = await knowledgeAccess.getSummary(codebaseId);
79
- console.log(sectionHeader('Knowledge Summary'));
80
- console.log(`Total Knowledge: ${summary.totalKnowledge}`);
81
- console.log('\nBy Type:');
82
- Object.entries(summary.byType).forEach(([type, count]) => {
83
- console.log(` ${type}: ${count}`);
84
- });
85
- if (summary.mostAccessed.length > 0) {
86
- console.log('\nMost Accessed:');
87
- summary.mostAccessed.forEach((k, i) => {
88
- console.log(` ${i + 1}. ${k.title}`);
89
- });
90
- }
91
- if (summary.recent.length > 0) {
92
- console.log('\nRecent:');
93
- summary.recent.forEach((k, i) => {
94
- console.log(` ${i + 1}. ${k.title} (${k.extractedAt.toLocaleDateString()})`);
95
- });
96
- }
97
- console.log(`\n${summary.summary}`);
98
- break;
99
- }
100
- case 'extract': {
101
- const filepath = args[0];
102
- if (!filepath) {
103
- console.log(error('Filepath required. Usage: codehere knowledge extract <filepath>'));
104
- return;
105
- }
106
- console.log(colors.bold(`Extracting knowledge from ${filepath}...`));
107
- await knowledgeExtractor.extractFromFile(filepath, codebaseId, codebaseInfo.rootPath);
108
- console.log(success('Knowledge extracted.'));
109
- break;
110
- }
111
- default:
112
- console.log(error(`Unknown action: ${action}`));
113
- console.log(info('Available actions: query, list, summary, extract'));
114
- }
115
- }
116
- catch (err) {
117
- const { displayError } = await import('../error-display.js');
118
- displayError(err, {
119
- operation: `knowledge-${action}`,
120
- showSuggestions: true,
121
- showStack: false,
122
- });
123
- throw err;
124
- }
125
- finally {
126
- executionTracer.endRun();
127
- }
128
- }
129
- //# sourceMappingURL=knowledge-command.js.map