codehere 0.2.2 → 0.3.0-rc.10
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.
- package/README.md +88 -68
- package/dist/domain/entities/task.js +4 -4
- package/dist/error-handler.js +4 -9
- package/dist/index.js +261 -1224
- package/dist/infrastructure/config/product-context.js +7 -6
- package/dist/infrastructure/hooks/claude-sdk-hook.js +348 -72
- package/dist/infrastructure/observability/execution-tracer.js +11 -6
- package/dist/infrastructure/orchestration/agent-adapter.js +13 -0
- package/dist/infrastructure/orchestration/agent-installer.js +101 -0
- package/dist/infrastructure/orchestration/agents-config-seed.js +56 -0
- package/dist/infrastructure/orchestration/aider-adapter.js +319 -0
- package/dist/infrastructure/orchestration/artifacts-extractor.js +175 -0
- package/dist/infrastructure/orchestration/claude-code-adapter.js +352 -0
- package/dist/infrastructure/orchestration/codex-adapter.js +310 -0
- package/dist/infrastructure/orchestration/conductor-adapter.js +340 -0
- package/dist/infrastructure/orchestration/generic-cli-adapter.js +553 -0
- package/dist/infrastructure/orchestration/opencode-adapter.js +275 -0
- package/dist/infrastructure/orchestration/progress-aggregator.js +189 -0
- package/dist/infrastructure/orchestration/readiness.js +106 -0
- package/dist/infrastructure/orchestration/session-manager.js +278 -0
- package/dist/infrastructure/orchestration/session-persistence.js +109 -0
- package/dist/infrastructure/protocols/mcp-helpers.js +10 -30
- package/dist/infrastructure/protocols/mcp-server-impl.js +359 -21
- package/dist/infrastructure/protocols/probe-port.js +36 -0
- package/dist/infrastructure/protocols/ui-page.js +1827 -0
- package/dist/infrastructure/security/file-collection.js +115 -0
- package/dist/infrastructure/security/trust-scorer.js +301 -56
- package/dist/infrastructure/storage/task-repository.js +8 -7
- package/dist/monitoring.js +9 -38
- package/dist/presentation/cli/commands/help-command.js +96 -139
- package/dist/presentation/cli/commands/hook-command.js +17 -24
- package/dist/presentation/cli/commands/report-command.js +59 -72
- package/dist/presentation/cli/commands/setup-command.js +4 -4
- package/dist/presentation/cli/commands/status-command.js +321 -30
- package/dist/presentation/cli/commands/trust-command.js +84 -72
- package/dist/presentation/cli/error-display.js +17 -21
- package/dist/presentation/cli/repl.js +474 -0
- package/dist/ui.js +11 -11
- package/package.json +24 -62
- package/dist/agents/base.js +0 -101
- package/dist/agents/orchestrator-model-driven.js +0 -141
- package/dist/agents/react-orchestrator-agent.js +0 -54
- package/dist/application/agents/execution-agent.js +0 -508
- package/dist/application/agents/multi-agent-orchestrator.js +0 -295
- package/dist/application/agents/planning-agent.js +0 -433
- package/dist/application/agents/validation-agent.js +0 -317
- package/dist/application/architectures/plan-and-act.js +0 -242
- package/dist/application/index.js +0 -12
- package/dist/application/services/agent-factory.js +0 -28
- package/dist/application/services/dependency-container.js +0 -596
- package/dist/application/services/git-context-service.js +0 -83
- package/dist/application/services/intelligent-router.js +0 -934
- package/dist/application/services/tool-executor-service.js +0 -94
- package/dist/application/use-cases/ask-question-use-case.js +0 -338
- package/dist/application/use-cases/edit-file-use-case.js +0 -830
- package/dist/application/use-cases/explain-file-use-case.js +0 -50
- package/dist/application/use-cases/index-codebase-use-case.js +0 -113
- package/dist/application/use-cases/planning-use-case.js +0 -276
- package/dist/application/use-cases/react-orchestration-use-case.js +0 -329
- package/dist/application/use-cases/reflexion-use-case.js +0 -30
- package/dist/application/workflows/deterministic-workflows.js +0 -189
- package/dist/ast-parser.js +0 -331
- package/dist/cache.js +0 -180
- package/dist/chat.js +0 -251
- package/dist/code-analysis.js +0 -327
- package/dist/context.js +0 -187
- package/dist/docs.js +0 -146
- package/dist/domain/entities/code-chunk.js +0 -6
- package/dist/domain/entities/decision.js +0 -9
- package/dist/domain/entities/edit.js +0 -6
- package/dist/domain/entities/knowledge-node.js +0 -9
- package/dist/domain/entities/knowledge-preservation.js +0 -10
- package/dist/domain/entities/memory.js +0 -6
- package/dist/domain/entities/pattern.js +0 -7
- package/dist/domain/entities/plan.js +0 -6
- package/dist/domain/entities/query.js +0 -6
- package/dist/domain/errors/embeddings-not-found-error.js +0 -13
- package/dist/domain/index.js +0 -19
- package/dist/domain/interfaces/ai-service.interface.js +0 -6
- package/dist/domain/interfaces/code-analyzer.interface.js +0 -6
- package/dist/domain/interfaces/decision-repository.interface.js +0 -9
- package/dist/domain/interfaces/embedding-repository.interface.js +0 -6
- package/dist/domain/interfaces/knowledge-graph-repository.interface.js +0 -9
- package/dist/domain/interfaces/knowledge-preservation-repository.interface.js +0 -8
- package/dist/domain/interfaces/memory-repository.interface.js +0 -6
- package/dist/domain/interfaces/pattern-repository.interface.js +0 -6
- package/dist/domain/interfaces/verification-service.interface.js +0 -6
- package/dist/domain/services/cross-team-pattern-sharing.js +0 -125
- package/dist/domain/services/decision-recorder.js +0 -223
- package/dist/domain/services/decision-retriever.js +0 -133
- package/dist/domain/services/environment-mode-manager.js +0 -22
- package/dist/domain/services/graded-memory-activation.js +0 -69
- package/dist/domain/services/knowledge-access.js +0 -132
- package/dist/domain/services/knowledge-extractor.js +0 -247
- package/dist/domain/services/knowledge-graph-builder.js +0 -268
- package/dist/domain/services/knowledge-graph-query.js +0 -187
- package/dist/domain/services/memory-retriever.js +0 -82
- package/dist/domain/services/memory-synthesizer.js +0 -91
- package/dist/domain/services/pattern-extractor.js +0 -442
- package/dist/domain/services/query-intent-classifier.js +0 -140
- package/dist/domain/services/react-loop.js +0 -186
- package/dist/domain/services/risk-tier-detector.js +0 -78
- package/dist/edit.js +0 -319
- package/dist/embed.js +0 -459
- package/dist/formatter.js +0 -168
- package/dist/git.js +0 -198
- package/dist/infrastructure/ai/cohere-ai-service.js +0 -607
- package/dist/infrastructure/ai/command-r-evaluation.js +0 -206
- package/dist/infrastructure/ai/model-config.js +0 -84
- package/dist/infrastructure/ai/provider-ai-service.js +0 -477
- package/dist/infrastructure/cache/embedding-cache.js +0 -175
- package/dist/infrastructure/cache/query-result-cache.js +0 -66
- package/dist/infrastructure/cache/response-cache.js +0 -48
- package/dist/infrastructure/cache/security-scan-cache.js +0 -47
- package/dist/infrastructure/chunking/ast-code-chunker.js +0 -19
- package/dist/infrastructure/chunking/code-aware-chunker.js +0 -397
- package/dist/infrastructure/context/context-compressor.js +0 -329
- package/dist/infrastructure/context/conversation-context.js +0 -128
- package/dist/infrastructure/context/session-manager.js +0 -94
- package/dist/infrastructure/cost/cost-tracker.js +0 -360
- package/dist/infrastructure/file-scanner/file-scanner.js +0 -106
- package/dist/infrastructure/governance/nist-ai-rmf.js +0 -292
- package/dist/infrastructure/governance/policy-as-code.js +0 -258
- package/dist/infrastructure/governance/prompt-to-code-lineage.js +0 -239
- package/dist/infrastructure/index.js +0 -7
- package/dist/infrastructure/observability/prompt-versioner.js +0 -145
- package/dist/infrastructure/protocols/a2a-metadata.js +0 -137
- package/dist/infrastructure/protocols/a2a-protocol.js +0 -314
- package/dist/infrastructure/protocols/mcp-oauth.js +0 -184
- package/dist/infrastructure/protocols/mcp-server.js +0 -333
- package/dist/infrastructure/protocols/streaming-handler.js +0 -103
- package/dist/infrastructure/providers/cohere-provider.js +0 -444
- package/dist/infrastructure/providers/fake-provider.js +0 -130
- package/dist/infrastructure/providers/local-llm-provider.js +0 -330
- package/dist/infrastructure/providers/model-config.types.js +0 -9
- package/dist/infrastructure/providers/model-provider.interface.js +0 -8
- package/dist/infrastructure/providers/openai-provider.js +0 -413
- package/dist/infrastructure/providers/openrouter-provider.js +0 -399
- package/dist/infrastructure/providers/operation-provider-resolver.js +0 -105
- package/dist/infrastructure/providers/provider-config-loader.js +0 -120
- package/dist/infrastructure/providers/provider-registry.js +0 -88
- package/dist/infrastructure/safety/pattern-detector.js +0 -133
- package/dist/infrastructure/security/ai-sast-scanner.js +0 -290
- package/dist/infrastructure/security/docker-sandbox.js +0 -178
- package/dist/infrastructure/security/enhanced-security-gate.js +0 -151
- package/dist/infrastructure/security/license-scanner.js +0 -167
- package/dist/infrastructure/security/provider-bias-detector.js +0 -164
- package/dist/infrastructure/security/sandbox-executor.js +0 -64
- package/dist/infrastructure/serialization/toon-serializer.js +0 -119
- package/dist/infrastructure/storage/memory-stream-service.js +0 -204
- package/dist/infrastructure/storage/plan-repository.js +0 -96
- package/dist/infrastructure/storage/sqlite-decision-repository.js +0 -232
- package/dist/infrastructure/storage/sqlite-embedding-repository.js +0 -311
- package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.js +0 -417
- package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.js +0 -230
- package/dist/infrastructure/storage/sqlite-memory-repository.js +0 -229
- package/dist/infrastructure/storage/sqlite-pattern-repository.js +0 -249
- package/dist/infrastructure/storage/task-helpers.js +0 -197
- package/dist/infrastructure/telemetry/telemetry-service.js +0 -167
- package/dist/infrastructure/ux/appropriate-friction.js +0 -213
- package/dist/infrastructure/ux/bi-directional-learning.js +0 -337
- package/dist/infrastructure/ux/capability-boundaries.js +0 -42
- package/dist/infrastructure/ux/comprehensive-formatter.js +0 -117
- package/dist/infrastructure/ux/contextual-feature-discovery.js +0 -10
- package/dist/infrastructure/ux/expectation-management.js +0 -327
- package/dist/infrastructure/ux/feature-discovery.js +0 -14
- package/dist/infrastructure/ux/feedback-prompt.js +0 -45
- package/dist/infrastructure/ux/hitl-validation.js +0 -297
- package/dist/infrastructure/ux/progress-indicator.js +0 -116
- package/dist/infrastructure/ux/progressive-disclosure.js +0 -236
- package/dist/infrastructure/ux/review-checkpoint.js +0 -72
- package/dist/infrastructure/ux/staged-feature-intro.js +0 -24
- package/dist/infrastructure/ux/stream-markdown.js +0 -151
- package/dist/infrastructure/ux/syntax-highlighter.js +0 -91
- package/dist/infrastructure/ux/team-standards.js +0 -196
- package/dist/infrastructure/ux/transparency.js +0 -71
- package/dist/infrastructure/validation/agent-feedback.js +0 -55
- package/dist/infrastructure/validation/agent-validation-helper.js +0 -137
- package/dist/infrastructure/validation/review-handler.js +0 -40
- package/dist/infrastructure/validation/summary-aggregator.js +0 -70
- package/dist/infrastructure/validation/summary-extractor.js +0 -45
- package/dist/infrastructure/validation/trace-summary.js +0 -52
- package/dist/infrastructure/verification/verification-service.js +0 -47
- package/dist/infrastructure/xai/attention-visualizer.js +0 -172
- package/dist/infrastructure/xai/cot-visualizer.js +0 -283
- package/dist/infrastructure/xai/decision-tree-log.js +0 -212
- package/dist/infrastructure/xai/interactive-xai.js +0 -260
- package/dist/infrastructure/xai/uncertainty-quantifier.js +0 -198
- package/dist/intelligent-retrieval.js +0 -272
- package/dist/intent/classifier.js +0 -2
- package/dist/intent/context.js +0 -2
- package/dist/iterative-refinement.js +0 -189
- package/dist/learning.js +0 -232
- package/dist/log.js +0 -31
- package/dist/migrate.js +0 -133
- package/dist/parallel-processor.js +0 -534
- package/dist/planner.js +0 -198
- package/dist/policy.js +0 -26
- package/dist/presentation/cli/commands/ask-command.js +0 -314
- package/dist/presentation/cli/commands/cost-command.js +0 -191
- package/dist/presentation/cli/commands/decision-command.js +0 -207
- package/dist/presentation/cli/commands/docs-command.js +0 -25
- package/dist/presentation/cli/commands/fix-command.js +0 -53
- package/dist/presentation/cli/commands/knowledge-command.js +0 -129
- package/dist/presentation/cli/commands/learning-dashboard-command.js +0 -183
- package/dist/presentation/cli/commands/models-command.js +0 -194
- package/dist/presentation/cli/commands/orchestrate-command.js +0 -207
- package/dist/presentation/cli/commands/plan-command.js +0 -246
- package/dist/presentation/cli/commands/product-command.js +0 -199
- package/dist/presentation/cli/commands/react-command.js +0 -181
- package/dist/presentation/cli/commands/review-command.js +0 -154
- package/dist/presentation/cli/commands/run-command.js +0 -188
- package/dist/presentation/cli/commands/smart-command.js +0 -395
- package/dist/presentation/cli/commands/suggest-command.js +0 -138
- package/dist/presentation/cli/commands/trace-command.js +0 -129
- package/dist/presentation/cli/commands/undo-command.js +0 -150
- package/dist/query-optimizer.js +0 -205
- package/dist/refactor.js +0 -116
- package/dist/review.js +0 -206
- package/dist/search.js +0 -163
- package/dist/session.js +0 -704
- package/dist/task-verification.js +0 -336
- package/dist/testgen.js +0 -166
- package/dist/token-optimizer.js +0 -277
- package/dist/tools/bash.js +0 -213
- package/dist/tools/edit.js +0 -235
- package/dist/tools/executor.js +0 -153
- package/dist/tools/git-tool.js +0 -292
- package/dist/tools/parser.js +0 -158
- package/dist/tools/registry.js +0 -302
- package/dist/tools/search.js +0 -100
- package/dist/types.js +0 -2
- package/dist/utils/check-api-status.js +0 -100
- package/dist/utils/diff-parser.js +0 -162
- package/dist/verification/backup.js +0 -259
- package/dist/verification/compiler.js +0 -264
- package/dist/verification/index.js +0 -273
- package/dist/verification/test-runner.js +0 -379
|
@@ -1,395 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI Command: Smart Router
|
|
3
|
-
* Intelligent routing - user just types what they want
|
|
4
|
-
*/
|
|
5
|
-
import { IntelligentRouter } from '../../../application/services/intelligent-router.js';
|
|
6
|
-
import { colors, sectionHeader, formatNumber, formatPath, createTable, success, error, warning, newline, symbols, } from '../../../ui.js';
|
|
7
|
-
import { executionTracer } from '../../../infrastructure/observability/execution-tracer.js';
|
|
8
|
-
import { displayError } from '../error-display.js';
|
|
9
|
-
import { trackCommand, shouldShowFeatureDiscovery, markFeatureDiscoveryShown, } from '../../../infrastructure/ux/feature-discovery.js';
|
|
10
|
-
import { summaryExtractor } from '../../../infrastructure/validation/summary-extractor.js';
|
|
11
|
-
import { reviewHandler } from '../../../infrastructure/validation/review-handler.js';
|
|
12
|
-
export async function executeSmartCommand(query, options = {}) {
|
|
13
|
-
// Capability Boundaries: Check for unsupported operations
|
|
14
|
-
try {
|
|
15
|
-
const { CapabilityBoundaryDetector, displayCapabilityBoundary } = await import('../../../infrastructure/ux/capability-boundaries.js');
|
|
16
|
-
const detector = new CapabilityBoundaryDetector();
|
|
17
|
-
const boundary = detector.detectUnsupported(query);
|
|
18
|
-
if (boundary) {
|
|
19
|
-
displayCapabilityBoundary(boundary);
|
|
20
|
-
return; // Don't proceed with unsupported operation
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
catch {
|
|
24
|
-
// Capability boundary check failed - continue anyway (non-blocking)
|
|
25
|
-
}
|
|
26
|
-
// Use dependency container to get memory-aware router
|
|
27
|
-
const { container } = await import('../../../application/services/dependency-container.js');
|
|
28
|
-
const router = new IntelligentRouter(undefined, // Use default QueryIntentClassifier
|
|
29
|
-
container.aiService, container.memoryStreamService);
|
|
30
|
-
// Compact header
|
|
31
|
-
console.log(colors.cyan('codehere') + colors.dim(' ▸ ') + query);
|
|
32
|
-
newline();
|
|
33
|
-
// Start execution tracing and track start time for summary statistics
|
|
34
|
-
const startTime = Date.now();
|
|
35
|
-
const runId = executionTracer.startRun('smart-route', {
|
|
36
|
-
query,
|
|
37
|
-
codebaseId: process.cwd(),
|
|
38
|
-
});
|
|
39
|
-
// No verbose spinner - atomic interaction
|
|
40
|
-
try {
|
|
41
|
-
// Get conversation context for this session
|
|
42
|
-
const { conversationContextManager } = await import('../../../infrastructure/context/conversation-context.js');
|
|
43
|
-
const { sessionManager } = await import('../../../infrastructure/context/session-manager.js');
|
|
44
|
-
const sessionId = sessionManager.getSessionId(process.cwd());
|
|
45
|
-
const history = conversationContextManager.getHistory(sessionId, 5);
|
|
46
|
-
const result = await router.route({
|
|
47
|
-
query,
|
|
48
|
-
context: {
|
|
49
|
-
currentDirectory: process.cwd(),
|
|
50
|
-
conversationHistory: history.map(turn => ({
|
|
51
|
-
query: turn.query,
|
|
52
|
-
response: turn.response,
|
|
53
|
-
timestamp: typeof turn.timestamp === 'string' ? Date.parse(turn.timestamp) : turn.timestamp,
|
|
54
|
-
})),
|
|
55
|
-
sessionId,
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
// Calculate execution time for summary
|
|
59
|
-
const executionTime = ((Date.now() - startTime) / 1000).toFixed(2);
|
|
60
|
-
// Handle review if --review flag is set (only for destructive actions)
|
|
61
|
-
if (options.review && (result.action === 'edit' || result.action === 'plan')) {
|
|
62
|
-
const summarySource = summaryExtractor.extractFromRouting(result);
|
|
63
|
-
if (summarySource) {
|
|
64
|
-
const decision = await reviewHandler.requestReview(summarySource.summary);
|
|
65
|
-
if (!decision.approved) {
|
|
66
|
-
console.log(warning('Operation cancelled by user.'));
|
|
67
|
-
newline();
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
// User approved - continue with display
|
|
71
|
-
newline();
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
console.log(warning('⚠️ No summary available for review. Continuing without review.'));
|
|
75
|
-
newline();
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
// Display result based on action type
|
|
79
|
-
const { formatMarkdownForTerminal } = await import('../../../infrastructure/ux/stream-markdown.js');
|
|
80
|
-
const { formatContent } = await import('../../../infrastructure/ux/comprehensive-formatter.js');
|
|
81
|
-
switch (result.action) {
|
|
82
|
-
case 'ask':
|
|
83
|
-
console.log(formatMarkdownForTerminal(result.message || 'No answer generated'));
|
|
84
|
-
console.log(colors.dim(` ${executionTime}s`));
|
|
85
|
-
newline();
|
|
86
|
-
break;
|
|
87
|
-
case 'explain':
|
|
88
|
-
// Atomic: Just show the explanation
|
|
89
|
-
if (result.result) {
|
|
90
|
-
const explainResult = result.result;
|
|
91
|
-
console.log(formatMarkdownForTerminal(explainResult.explanation || ''));
|
|
92
|
-
}
|
|
93
|
-
newline();
|
|
94
|
-
break;
|
|
95
|
-
case 'edit':
|
|
96
|
-
console.log('');
|
|
97
|
-
sectionHeader('Edit Result');
|
|
98
|
-
console.log('');
|
|
99
|
-
newline();
|
|
100
|
-
if (result.success) {
|
|
101
|
-
const editResult = result.result;
|
|
102
|
-
// Display license warnings if present (Enhanced Security - License Scanning)
|
|
103
|
-
if (editResult?.licenseFindings && editResult.licenseFindings.length > 0) {
|
|
104
|
-
sectionHeader('License Scan');
|
|
105
|
-
const criticalFindings = editResult.licenseFindings.filter((f) => f.severity === 'critical' || f.severity === 'high');
|
|
106
|
-
if (criticalFindings.length > 0) {
|
|
107
|
-
console.log(warning(`⚠️ ${criticalFindings.length} license issue${criticalFindings.length !== 1 ? 's' : ''} found:`));
|
|
108
|
-
criticalFindings.slice(0, 3).forEach((finding) => {
|
|
109
|
-
console.log(colors.yellow(` • ${finding.license} license detected in ${finding.filepath || 'code'}`));
|
|
110
|
-
if (finding.message) {
|
|
111
|
-
console.log(colors.dim(` ${finding.message}`));
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
if (criticalFindings.length > 3) {
|
|
115
|
-
console.log(colors.dim(` ... and ${criticalFindings.length - 3} more`));
|
|
116
|
-
}
|
|
117
|
-
newline();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
// Display provider bias warnings if present (Enhanced Security - Provider Bias Detection)
|
|
121
|
-
if (editResult?.providerBiasFindings && editResult.providerBiasFindings.length > 0) {
|
|
122
|
-
sectionHeader('Provider Bias Detection');
|
|
123
|
-
const criticalFindings = editResult.providerBiasFindings.filter((f) => f.severity === 'critical' || f.severity === 'high');
|
|
124
|
-
if (criticalFindings.length > 0) {
|
|
125
|
-
console.log(warning(`⚠️ ${criticalFindings.length} vendor lock-in risk${criticalFindings.length !== 1 ? 's' : ''} detected:`));
|
|
126
|
-
criticalFindings.slice(0, 3).forEach((finding) => {
|
|
127
|
-
console.log(colors.yellow(` • ${finding.provider} provider detected`));
|
|
128
|
-
if (finding.message) {
|
|
129
|
-
console.log(colors.dim(` ${finding.message}`));
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
if (criticalFindings.length > 3) {
|
|
133
|
-
console.log(colors.dim(` ... and ${criticalFindings.length - 3} more`));
|
|
134
|
-
}
|
|
135
|
-
newline();
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
console.log(success('Edit applied'));
|
|
139
|
-
if (editResult?.edit?.filepath) {
|
|
140
|
-
console.log(colors.dim(`File: ${formatPath(editResult.edit.filepath)}`));
|
|
141
|
-
}
|
|
142
|
-
if (editResult?.edit?.linesAdded || editResult?.edit?.linesRemoved) {
|
|
143
|
-
const changesTable = createTable(['Metric', 'Value'], [
|
|
144
|
-
['Lines Added', formatNumber(editResult.edit.linesAdded || 0)],
|
|
145
|
-
['Lines Removed', formatNumber(editResult.edit.linesRemoved || 0)],
|
|
146
|
-
['Execution Time', `${executionTime}s`],
|
|
147
|
-
]);
|
|
148
|
-
console.log(changesTable.toString());
|
|
149
|
-
newline();
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
// Use centralized error display
|
|
154
|
-
const errorMessage = result.error || 'Edit failed';
|
|
155
|
-
displayError(new Error(errorMessage), {
|
|
156
|
-
operation: 'edit',
|
|
157
|
-
query: query,
|
|
158
|
-
filepath: result.result?.edit?.filepath,
|
|
159
|
-
showSuggestions: true,
|
|
160
|
-
});
|
|
161
|
-
// Display security/license findings even on failure
|
|
162
|
-
const editResult = result.result;
|
|
163
|
-
if (editResult?.licenseFindings && editResult.licenseFindings.length > 0) {
|
|
164
|
-
newline();
|
|
165
|
-
sectionHeader('License Scan');
|
|
166
|
-
editResult.licenseFindings.slice(0, 3).forEach((finding) => {
|
|
167
|
-
console.log(colors.yellow(`⚠️ ${finding.license} license: ${finding.message || 'License conflict detected'}`));
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
if (editResult?.providerBiasFindings && editResult.providerBiasFindings.length > 0) {
|
|
171
|
-
newline();
|
|
172
|
-
sectionHeader('Provider Bias Detection');
|
|
173
|
-
editResult.providerBiasFindings.slice(0, 3).forEach((finding) => {
|
|
174
|
-
console.log(colors.yellow(`⚠️ ${finding.provider} provider: ${finding.message || 'Vendor lock-in risk detected'}`));
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
if (editResult?.reflection) {
|
|
178
|
-
newline();
|
|
179
|
-
sectionHeader('Learning');
|
|
180
|
-
// Use comprehensive formatter for consistent formatting
|
|
181
|
-
const { formatReflection } = await import('../../../infrastructure/ux/comprehensive-formatter.js');
|
|
182
|
-
const formatted = formatReflection(editResult.reflection);
|
|
183
|
-
console.log(formatted);
|
|
184
|
-
newline();
|
|
185
|
-
}
|
|
186
|
-
newline();
|
|
187
|
-
console.log(colors.dim(`Execution Time: ${executionTime}s`));
|
|
188
|
-
}
|
|
189
|
-
console.log('');
|
|
190
|
-
newline();
|
|
191
|
-
break;
|
|
192
|
-
case 'react':
|
|
193
|
-
// Atomic: Just show the final answer, not reasoning steps
|
|
194
|
-
if (result.result) {
|
|
195
|
-
const reactResult = result.result;
|
|
196
|
-
// Only show answer, not verbose reasoning steps
|
|
197
|
-
const formattedReact = formatContent(result.message || reactResult.answer || 'Processing complete', { indent: 0, maxWidth: 76 });
|
|
198
|
-
console.log(formattedReact);
|
|
199
|
-
}
|
|
200
|
-
newline();
|
|
201
|
-
break;
|
|
202
|
-
case 'plan':
|
|
203
|
-
if (result.result) {
|
|
204
|
-
const planResult = result.result;
|
|
205
|
-
// Check if it's from orchestrator (has execution/validation) or just planning
|
|
206
|
-
if (planResult.plan) {
|
|
207
|
-
console.log('');
|
|
208
|
-
console.log(colors.bold('Plan'));
|
|
209
|
-
console.log('');
|
|
210
|
-
newline();
|
|
211
|
-
console.log(colors.bold('Goal:') + ' ' + colors.cyan(planResult.plan.goal || query));
|
|
212
|
-
if (planResult.plan.metadata?.complexity) {
|
|
213
|
-
console.log(colors.dim(`Complexity: ${planResult.plan.metadata.complexity}`));
|
|
214
|
-
}
|
|
215
|
-
if (planResult.plan.metadata?.estimatedDuration) {
|
|
216
|
-
console.log(colors.dim(`Estimated Duration: ${planResult.plan.metadata.estimatedDuration} minutes`));
|
|
217
|
-
}
|
|
218
|
-
newline();
|
|
219
|
-
if (planResult.plan.subPlans && planResult.plan.subPlans.length > 0) {
|
|
220
|
-
console.log(colors.bold('Sub-Plans:'));
|
|
221
|
-
planResult.plan.subPlans.forEach((subPlan, i) => {
|
|
222
|
-
const statusIconMap = {
|
|
223
|
-
pending: '○',
|
|
224
|
-
in_progress: '⟳',
|
|
225
|
-
completed: '✓',
|
|
226
|
-
failed: '✗',
|
|
227
|
-
};
|
|
228
|
-
const statusIcon = statusIconMap[subPlan.status] || '○';
|
|
229
|
-
console.log(` ${statusIcon} [${subPlan.type || 'task'}] ${subPlan.description || 'Sub-plan ' + (i + 1)}`);
|
|
230
|
-
if (subPlan.dependencies && subPlan.dependencies.length > 0) {
|
|
231
|
-
console.log(colors.dim(` Depends on: ${subPlan.dependencies.join(', ')}`));
|
|
232
|
-
}
|
|
233
|
-
if (subPlan.estimatedSteps) {
|
|
234
|
-
console.log(colors.dim(` Estimated steps: ${subPlan.estimatedSteps}`));
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
newline();
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
// Show execution results if from orchestrator
|
|
241
|
-
if (planResult.execution) {
|
|
242
|
-
console.log('');
|
|
243
|
-
console.log(colors.bold('Execution Results'));
|
|
244
|
-
console.log('');
|
|
245
|
-
newline();
|
|
246
|
-
console.log(colors.bold(`Completed: ${planResult.execution.completedSubPlans || 0}/${planResult.execution.totalSubPlans || 0} sub-plans`));
|
|
247
|
-
console.log(colors.bold(`Result: ${planResult.execution.overallSuccess ? 'Succeeded' : 'Failed'}`));
|
|
248
|
-
newline();
|
|
249
|
-
if (planResult.execution.results && planResult.execution.results.length > 0) {
|
|
250
|
-
planResult.execution.results.forEach((execResult) => {
|
|
251
|
-
const icon = execResult.success ? symbols.success : symbols.error;
|
|
252
|
-
const color = execResult.success ? colors.green : colors.red;
|
|
253
|
-
console.log(`${color(icon)} ${execResult.subPlanId || 'Sub-plan'}: ${execResult.success ? 'Success' : 'Failed'}${execResult.duration ? ` (${execResult.duration}ms)` : ''}`);
|
|
254
|
-
if (execResult.error) {
|
|
255
|
-
console.log(colors.dim(` Error: ${execResult.error}`));
|
|
256
|
-
}
|
|
257
|
-
});
|
|
258
|
-
newline();
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
// Show validation results if available
|
|
262
|
-
if (planResult.validation) {
|
|
263
|
-
console.log('');
|
|
264
|
-
console.log(colors.bold('Validation Results'));
|
|
265
|
-
console.log('');
|
|
266
|
-
newline();
|
|
267
|
-
if (planResult.validation.qualityScore !== undefined) {
|
|
268
|
-
console.log(colors.bold(`Quality Score: ${planResult.validation.qualityScore}/100`));
|
|
269
|
-
}
|
|
270
|
-
if (planResult.validation.compilationSuccess !== undefined) {
|
|
271
|
-
console.log(`Compilation: ${planResult.validation.compilationSuccess ? success('Pass') : error('Fail')}`);
|
|
272
|
-
}
|
|
273
|
-
if (planResult.validation.testsPassed !== undefined) {
|
|
274
|
-
console.log(`Tests: ${planResult.validation.testsPassed ? success('Pass') : error('Fail')}`);
|
|
275
|
-
}
|
|
276
|
-
if (planResult.validation.testResults) {
|
|
277
|
-
const tr = planResult.validation.testResults;
|
|
278
|
-
console.log(colors.dim(`Test Results: ${tr.passed || 0} passed, ${tr.failed || 0} failed, ${tr.total || 0} total`));
|
|
279
|
-
}
|
|
280
|
-
newline();
|
|
281
|
-
}
|
|
282
|
-
// Show final message
|
|
283
|
-
if (result.success) {
|
|
284
|
-
console.log('');
|
|
285
|
-
console.log(success(result.message || 'Plan finished'));
|
|
286
|
-
console.log('');
|
|
287
|
-
}
|
|
288
|
-
else {
|
|
289
|
-
// Use centralized error display
|
|
290
|
-
const errorMessage = result.message || result.error || 'Plan failed';
|
|
291
|
-
displayError(new Error(errorMessage), {
|
|
292
|
-
operation: 'plan',
|
|
293
|
-
query: query,
|
|
294
|
-
showSuggestions: true,
|
|
295
|
-
});
|
|
296
|
-
}
|
|
297
|
-
newline();
|
|
298
|
-
}
|
|
299
|
-
else {
|
|
300
|
-
console.log('');
|
|
301
|
-
console.log(colors.bold('Plan'));
|
|
302
|
-
console.log('');
|
|
303
|
-
newline();
|
|
304
|
-
console.log(result.message || 'Planning in progress...');
|
|
305
|
-
newline();
|
|
306
|
-
}
|
|
307
|
-
break;
|
|
308
|
-
case 'index':
|
|
309
|
-
console.log(warning(result.message || 'Indexing required'));
|
|
310
|
-
break;
|
|
311
|
-
default:
|
|
312
|
-
console.log(result.message || 'Processing...');
|
|
313
|
-
}
|
|
314
|
-
// Atomic interaction: No summary table for better UX
|
|
315
|
-
// Summary statistics are tracked internally but not displayed
|
|
316
|
-
// Track command usage for feature discovery
|
|
317
|
-
trackCommand('smart');
|
|
318
|
-
// Contextual Feature Discovery: Show relevant features based on query (Task 2.2)
|
|
319
|
-
const { shouldShowContextualSuggestion } = await import('../../../infrastructure/ux/contextual-feature-discovery.js');
|
|
320
|
-
const contextualSuggestion = shouldShowContextualSuggestion(query, 'smart');
|
|
321
|
-
if (contextualSuggestion) {
|
|
322
|
-
newline();
|
|
323
|
-
console.log('');
|
|
324
|
-
console.log(colors.bold(`💡 ${contextualSuggestion.reason}`));
|
|
325
|
-
console.log(colors.dim(` Try: ${colors.cyan(contextualSuggestion.command)}`));
|
|
326
|
-
console.log(colors.dim(` ${contextualSuggestion.description}`));
|
|
327
|
-
console.log('');
|
|
328
|
-
newline();
|
|
329
|
-
}
|
|
330
|
-
else {
|
|
331
|
-
// Show milestone-based feature discovery if appropriate
|
|
332
|
-
const discovery = shouldShowFeatureDiscovery('smart');
|
|
333
|
-
if (discovery) {
|
|
334
|
-
newline();
|
|
335
|
-
console.log('');
|
|
336
|
-
console.log(colors.bold(`💡 ${discovery.message}`));
|
|
337
|
-
discovery.features.forEach(feature => {
|
|
338
|
-
console.log(colors.dim(` • ${colors.cyan(feature.name)}: ${feature.description}`));
|
|
339
|
-
console.log(colors.dim(` ${colors.cyan(feature.command)}`));
|
|
340
|
-
});
|
|
341
|
-
console.log('');
|
|
342
|
-
newline();
|
|
343
|
-
markFeatureDiscoveryShown(discovery.id);
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
// Store conversation turn for future reference resolution
|
|
347
|
-
try {
|
|
348
|
-
const { conversationContextManager } = await import('../../../infrastructure/context/conversation-context.js');
|
|
349
|
-
const { sessionManager } = await import('../../../infrastructure/context/session-manager.js');
|
|
350
|
-
const sessionId = sessionManager.getSessionId(process.cwd());
|
|
351
|
-
const response = result.message || result.error || 'Processing complete';
|
|
352
|
-
const entities = conversationContextManager.extractEntities(query);
|
|
353
|
-
conversationContextManager.addTurn(sessionId, query, response, entities, result.intent);
|
|
354
|
-
}
|
|
355
|
-
catch (error) {
|
|
356
|
-
// Don't fail if conversation tracking fails
|
|
357
|
-
}
|
|
358
|
-
// Task 6.1: Explicit Feedback Mechanisms - Prompt for feedback after operation
|
|
359
|
-
try {
|
|
360
|
-
const { promptForFeedback, storeFeedback, displayFeedbackConfirmation } = await import('../../../infrastructure/ux/feedback-prompt.js');
|
|
361
|
-
const learningSystem = container.biDirectionalLearning;
|
|
362
|
-
const userId = process.env.USER || 'default-user';
|
|
363
|
-
const feedback = await promptForFeedback('smart-route', {
|
|
364
|
-
query,
|
|
365
|
-
sessionId: executionTracer.getCurrentRunId() || undefined,
|
|
366
|
-
});
|
|
367
|
-
if (feedback) {
|
|
368
|
-
storeFeedback(learningSystem, userId, feedback, {
|
|
369
|
-
operation: 'smart-route',
|
|
370
|
-
query,
|
|
371
|
-
sessionId: executionTracer.getCurrentRunId() || undefined,
|
|
372
|
-
});
|
|
373
|
-
displayFeedbackConfirmation(feedback);
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
catch (feedbackError) {
|
|
377
|
-
// Don't fail the command if feedback collection fails
|
|
378
|
-
// Just log silently
|
|
379
|
-
}
|
|
380
|
-
newline();
|
|
381
|
-
}
|
|
382
|
-
catch (err) {
|
|
383
|
-
const { displayError } = await import('../error-display.js');
|
|
384
|
-
displayError(err, {
|
|
385
|
-
operation: 'smart-route',
|
|
386
|
-
query,
|
|
387
|
-
showSuggestions: true,
|
|
388
|
-
});
|
|
389
|
-
throw err;
|
|
390
|
-
}
|
|
391
|
-
finally {
|
|
392
|
-
executionTracer.endRun();
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
//# sourceMappingURL=smart-command.js.map
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI Command: Suggest
|
|
3
|
-
* Read-only assistant mode - Q&A, explanations
|
|
4
|
-
*
|
|
5
|
-
* Phase 1: v0.5.0-alpha.0
|
|
6
|
-
*/
|
|
7
|
-
import { container } from '../../../application/services/dependency-container.js';
|
|
8
|
-
import { colors, sectionHeader, success, warning, info, newline, createBanner, createSpinner, isMinimalStyle, printMinimalHeader, printSafetyNote, printContextSummary, } from '../../../ui.js';
|
|
9
|
-
import { cleanResponse } from '../../../formatter.js';
|
|
10
|
-
import { executionTracer } from '../../../infrastructure/observability/execution-tracer.js';
|
|
11
|
-
import { findCodebaseRoot } from '../../../domain/services/codebase-detector.js';
|
|
12
|
-
import { displayError } from '../error-display.js';
|
|
13
|
-
import { createSuggestTask } from '../../../infrastructure/storage/task-helpers.js';
|
|
14
|
-
import { getCurrentEnvironmentMode } from '../../../domain/services/environment-mode-manager.js';
|
|
15
|
-
import { RiskTier } from '../../../domain/entities/task.js';
|
|
16
|
-
export async function executeSuggestCommand(query, options) {
|
|
17
|
-
const startTime = Date.now();
|
|
18
|
-
// Start execution tracing
|
|
19
|
-
const codebaseInfo = findCodebaseRoot(process.cwd());
|
|
20
|
-
const runId = executionTracer.startRun('suggest', {
|
|
21
|
-
query,
|
|
22
|
-
codebaseId: codebaseInfo?.codebaseId,
|
|
23
|
-
});
|
|
24
|
-
try {
|
|
25
|
-
const minimal = isMinimalStyle();
|
|
26
|
-
if (minimal) {
|
|
27
|
-
printMinimalHeader('suggest', query);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
console.log(createBanner('Suggest', 'Read-only assistant mode'));
|
|
31
|
-
newline();
|
|
32
|
-
// Display query
|
|
33
|
-
console.log(colors.bold('Query:'));
|
|
34
|
-
console.log(colors.cyan(' ' + query));
|
|
35
|
-
if (options?.file) {
|
|
36
|
-
console.log(colors.dim(` File: ${options.file}`));
|
|
37
|
-
}
|
|
38
|
-
newline();
|
|
39
|
-
// Show environment mode and risk tier (advisory)
|
|
40
|
-
const environment = getCurrentEnvironmentMode();
|
|
41
|
-
const riskTier = RiskTier.T1; // Suggest is always T1 (read-only)
|
|
42
|
-
if (environment !== 'local' || riskTier !== RiskTier.T1) {
|
|
43
|
-
console.log(info(`Environment: ${environment.toUpperCase()} | Risk: ${riskTier.toUpperCase()}`));
|
|
44
|
-
newline();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
// Check if embeddings exist for this repository (skip check if using fake AI for testing)
|
|
48
|
-
if (process.env.CODEHERE_FAKE_AI !== '1') {
|
|
49
|
-
const embeddingRepo = container.getEmbeddingRepository(process.cwd());
|
|
50
|
-
const hasEmbeddings = await embeddingRepo.hasEmbeddings();
|
|
51
|
-
if (!hasEmbeddings) {
|
|
52
|
-
newline();
|
|
53
|
-
console.error(colors.red('No embeddings found for this repository.'));
|
|
54
|
-
newline();
|
|
55
|
-
console.log('Run:');
|
|
56
|
-
console.log(colors.cyan(' codehere index'));
|
|
57
|
-
console.log('');
|
|
58
|
-
console.log('then re-run this command.');
|
|
59
|
-
newline();
|
|
60
|
-
executionTracer.endRun();
|
|
61
|
-
process.exit(1);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
// Use AskQuestionUseCase (same as ask command, but with task tracking)
|
|
65
|
-
// Use per-repo embedding repository for codebase isolation
|
|
66
|
-
const askUseCase = container.getAskQuestionUseCase(process.cwd());
|
|
67
|
-
const spinner = createSpinner('Analyzing codebase...');
|
|
68
|
-
spinner.start();
|
|
69
|
-
try {
|
|
70
|
-
const response = await askUseCase.execute({
|
|
71
|
-
query,
|
|
72
|
-
maxResults: 15,
|
|
73
|
-
});
|
|
74
|
-
spinner.stop();
|
|
75
|
-
// Display answer
|
|
76
|
-
if (minimal) {
|
|
77
|
-
console.log(colors.bold('Answer:'));
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
sectionHeader('Answer');
|
|
81
|
-
}
|
|
82
|
-
console.log(cleanResponse(response.answer));
|
|
83
|
-
newline();
|
|
84
|
-
// Show context
|
|
85
|
-
if (response.chunks && response.chunks.length > 0) {
|
|
86
|
-
const files = response.chunks.map(c => c.filepath);
|
|
87
|
-
if (minimal) {
|
|
88
|
-
printContextSummary(files);
|
|
89
|
-
}
|
|
90
|
-
else {
|
|
91
|
-
sectionHeader('Context');
|
|
92
|
-
response.chunks.slice(0, 5).forEach((chunk, idx) => {
|
|
93
|
-
console.log(colors.dim(`${idx + 1}. ${chunk.filepath}:${chunk.lineStart || '?'}-${chunk.lineEnd || '?'}`));
|
|
94
|
-
});
|
|
95
|
-
if (response.chunks.length > 5) {
|
|
96
|
-
console.log(colors.dim(` ... and ${response.chunks.length - 5} more`));
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
newline();
|
|
100
|
-
}
|
|
101
|
-
// Show uncertainty if available (advisory) - only in verbose
|
|
102
|
-
if (!minimal && response.uncertainty && response.uncertainty.combined.value > 0.3) {
|
|
103
|
-
const confidence = (1 - response.uncertainty.combined.value) * 100;
|
|
104
|
-
console.log(warning(`Confidence: ${confidence.toFixed(0)}% - Answer may be incomplete`));
|
|
105
|
-
newline();
|
|
106
|
-
}
|
|
107
|
-
// Create task (non-blocking, silent failure)
|
|
108
|
-
await createSuggestTask({
|
|
109
|
-
query,
|
|
110
|
-
filePath: options?.file,
|
|
111
|
-
codebaseInfo,
|
|
112
|
-
runId: runId || 'unknown',
|
|
113
|
-
}).catch(() => {
|
|
114
|
-
// Silent failure - task creation is optional
|
|
115
|
-
});
|
|
116
|
-
if (minimal) {
|
|
117
|
-
printSafetyNote();
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
const duration = Date.now() - startTime;
|
|
121
|
-
console.log(success(`✓ Completed in ${(duration / 1000).toFixed(2)}s`));
|
|
122
|
-
}
|
|
123
|
-
newline();
|
|
124
|
-
}
|
|
125
|
-
catch (error) {
|
|
126
|
-
spinner.stop();
|
|
127
|
-
throw error;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
catch (err) {
|
|
131
|
-
displayError(err);
|
|
132
|
-
process.exit(1);
|
|
133
|
-
}
|
|
134
|
-
finally {
|
|
135
|
-
executionTracer.endRun();
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
//# sourceMappingURL=suggest-command.js.map
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* CLI Command: Trace
|
|
3
|
-
* View execution traces and reproduce runs
|
|
4
|
-
*
|
|
5
|
-
* Clean Architecture: Presentation Layer
|
|
6
|
-
*/
|
|
7
|
-
import { executionTracer } from '../../../infrastructure/observability/execution-tracer.js';
|
|
8
|
-
import { colors, sectionHeader, success, error, warning, info, newline, createBanner, createTable, } from '../../../ui.js';
|
|
9
|
-
import { displayError } from '../error-display.js';
|
|
10
|
-
export async function executeTraceCommand(action, runId) {
|
|
11
|
-
console.log(createBanner('Execution Tracing', 'Observability and reproducibility'));
|
|
12
|
-
newline();
|
|
13
|
-
try {
|
|
14
|
-
switch (action) {
|
|
15
|
-
case 'show': {
|
|
16
|
-
if (!runId) {
|
|
17
|
-
console.log(error('Run ID is required for "show" action'));
|
|
18
|
-
console.log(info('Usage: codehere trace show <runId>'));
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
await showTrace(runId);
|
|
22
|
-
break;
|
|
23
|
-
}
|
|
24
|
-
case 'reproduce': {
|
|
25
|
-
if (!runId) {
|
|
26
|
-
console.log(error('Run ID is required for "reproduce" action'));
|
|
27
|
-
console.log(info('Usage: codehere trace reproduce <runId>'));
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
await reproduceTrace(runId);
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
case 'list': {
|
|
34
|
-
await listTraces();
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
default:
|
|
38
|
-
console.log(error(`Unknown action: ${action}`));
|
|
39
|
-
console.log(info('Available actions: show, reproduce, list'));
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
catch (err) {
|
|
43
|
-
displayError(err, {
|
|
44
|
-
operation: `trace-${action}`,
|
|
45
|
-
showSuggestions: true,
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
async function showTrace(runId) {
|
|
50
|
-
const run = executionTracer.getRun(runId);
|
|
51
|
-
if (!run) {
|
|
52
|
-
console.log(error(`Run ${runId} not found`));
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
console.log(sectionHeader('Run Details'));
|
|
56
|
-
console.log(colors.bold(`Run ID: ${run.runId}`));
|
|
57
|
-
console.log(`Operation: ${run.operation}`);
|
|
58
|
-
console.log(`Query: ${run.query || 'N/A'}`);
|
|
59
|
-
console.log(`Start Time: ${new Date(run.startTime).toISOString()}`);
|
|
60
|
-
if (run.endTime) {
|
|
61
|
-
const duration = run.endTime - run.startTime;
|
|
62
|
-
console.log(`End Time: ${new Date(run.endTime).toISOString()}`);
|
|
63
|
-
console.log(`Duration: ${(duration / 1000).toFixed(2)}s`);
|
|
64
|
-
}
|
|
65
|
-
if (run.codebaseId) {
|
|
66
|
-
console.log(`Codebase: ${run.codebaseId}`);
|
|
67
|
-
}
|
|
68
|
-
newline();
|
|
69
|
-
console.log(sectionHeader('Traces'));
|
|
70
|
-
console.log(`Total traces: ${run.traces.length}`);
|
|
71
|
-
newline();
|
|
72
|
-
if (run.traces.length > 0) {
|
|
73
|
-
const tableData = run.traces.map((trace, index) => [
|
|
74
|
-
String(index + 1),
|
|
75
|
-
trace.operationType,
|
|
76
|
-
trace.operationName,
|
|
77
|
-
new Date(trace.timestamp).toISOString(),
|
|
78
|
-
trace.duration ? `${(trace.duration / 1000).toFixed(2)}s` : 'N/A',
|
|
79
|
-
trace.error ? colors.red('Error') : colors.green('Success'),
|
|
80
|
-
]);
|
|
81
|
-
const table = createTable(['#', 'Type', 'Operation', 'Timestamp', 'Duration', 'Status'], tableData);
|
|
82
|
-
console.log(table);
|
|
83
|
-
newline();
|
|
84
|
-
// Show errors if any
|
|
85
|
-
const errors = run.traces.filter(t => t.error);
|
|
86
|
-
if (errors.length > 0) {
|
|
87
|
-
console.log(sectionHeader('Errors'));
|
|
88
|
-
errors.forEach((trace, index) => {
|
|
89
|
-
console.log(colors.bold(`\nError ${index + 1}: ${trace.operationName}`));
|
|
90
|
-
console.log(colors.red(` ${trace.error.message}`));
|
|
91
|
-
if (trace.error.stack) {
|
|
92
|
-
console.log(colors.dim(` ${trace.error.stack.split('\n').slice(0, 3).join('\n ')}`));
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
newline();
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
async function reproduceTrace(runId) {
|
|
100
|
-
console.log(sectionHeader('Reproducing Run'));
|
|
101
|
-
console.log(colors.dim(`Run ID: ${runId}`));
|
|
102
|
-
newline();
|
|
103
|
-
try {
|
|
104
|
-
await executionTracer.reproduceRun(runId);
|
|
105
|
-
console.log(success('Run reproduction completed'));
|
|
106
|
-
}
|
|
107
|
-
catch (err) {
|
|
108
|
-
displayError(err, {
|
|
109
|
-
operation: 'trace-reproduce',
|
|
110
|
-
showSuggestions: true,
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
async function listTraces() {
|
|
115
|
-
console.log(sectionHeader('Recent Runs'));
|
|
116
|
-
const runs = executionTracer.listRecentRuns(20);
|
|
117
|
-
if (runs.length === 0) {
|
|
118
|
-
console.log(warning('No recent runs found'));
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
const tableData = runs.map(run => [
|
|
122
|
-
run.runId.substring(0, 8) + '...',
|
|
123
|
-
run.operation,
|
|
124
|
-
new Date(run.timestamp).toISOString(),
|
|
125
|
-
]);
|
|
126
|
-
const table = createTable(['Run ID', 'Operation', 'Timestamp'], tableData);
|
|
127
|
-
console.log(table);
|
|
128
|
-
}
|
|
129
|
-
//# sourceMappingURL=trace-command.js.map
|