codehere 0.1.1 → 0.2.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.
- package/README.md +68 -329
- package/dist/application/agents/execution-agent.js +4 -30
- package/dist/application/agents/multi-agent-orchestrator.js +0 -1
- package/dist/application/agents/planning-agent.js +79 -199
- package/dist/application/services/dependency-container.js +9 -20
- package/dist/application/services/intelligent-router.js +56 -64
- package/dist/application/use-cases/ask-question-use-case.js +22 -121
- package/dist/application/use-cases/edit-file-use-case.js +171 -160
- package/dist/application/use-cases/react-orchestration-use-case.js +10 -43
- package/dist/chat.js +130 -54
- package/dist/domain/services/query-intent-classifier.js +3 -36
- package/dist/embed.js +61 -74
- package/dist/index.js +1299 -259
- package/dist/infrastructure/ai/cohere-ai-service.js +9 -78
- package/dist/infrastructure/ai/provider-ai-service.js +18 -121
- package/dist/infrastructure/config/config-manager.js +14 -135
- package/dist/infrastructure/config/product-context.js +66 -0
- package/dist/infrastructure/context/conversation-context.js +1 -86
- package/dist/infrastructure/cost/cost-router.js +104 -0
- package/dist/infrastructure/cost/cost-tracker.js +2 -3
- package/dist/infrastructure/governance/policy-as-code.js +2 -1
- package/dist/infrastructure/hooks/claude-sdk-hook.js +253 -0
- package/dist/infrastructure/hooks/session-analyzer.js +111 -0
- package/dist/infrastructure/observability/execution-tracer.js +7 -180
- package/dist/infrastructure/protocols/mcp-helpers.js +45 -0
- package/dist/infrastructure/protocols/mcp-server-impl.js +286 -0
- package/dist/infrastructure/providers/cohere-provider.js +5 -31
- package/dist/infrastructure/providers/fake-provider.js +0 -8
- package/dist/infrastructure/providers/local-llm-provider.js +2 -8
- package/dist/infrastructure/providers/openai-provider.js +5 -37
- package/dist/infrastructure/providers/openrouter-provider.js +3 -11
- package/dist/infrastructure/safety/pattern-detector.js +133 -0
- package/dist/infrastructure/security/ai-sast-scanner.js +62 -13
- package/dist/infrastructure/security/enhanced-security-gate.js +2 -61
- package/dist/infrastructure/security/input-validator.js +29 -146
- package/dist/infrastructure/security/trust-scorer.js +337 -0
- package/dist/infrastructure/storage/embeddings-path.js +4 -14
- package/dist/infrastructure/storage/plan-repository.js +5 -4
- package/dist/infrastructure/storage/sqlite-decision-repository.js +8 -4
- package/dist/infrastructure/storage/sqlite-embedding-repository.js +11 -23
- package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.js +8 -4
- package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.js +8 -4
- package/dist/infrastructure/storage/sqlite-memory-repository.js +8 -4
- package/dist/infrastructure/storage/sqlite-pattern-repository.js +8 -4
- package/dist/infrastructure/ux/stream-markdown.js +151 -0
- package/dist/infrastructure/ux/transparency.js +71 -0
- package/dist/infrastructure/validation/agent-feedback.js +12 -57
- package/dist/monitoring.js +8 -17
- package/dist/parallel-processor.js +50 -122
- package/dist/presentation/cli/commands/ask-command.js +39 -80
- package/dist/presentation/cli/commands/config-command.js +1 -1
- package/dist/presentation/cli/commands/cost-command.js +6 -6
- package/dist/presentation/cli/commands/decision-command.js +5 -5
- package/dist/presentation/cli/commands/fix-command.js +4 -44
- package/dist/presentation/cli/commands/help-command.js +151 -100
- package/dist/presentation/cli/commands/hook-command.js +272 -0
- package/dist/presentation/cli/commands/knowledge-command.js +4 -4
- package/dist/presentation/cli/commands/learning-dashboard-command.js +3 -3
- package/dist/presentation/cli/commands/orchestrate-command.js +6 -48
- package/dist/presentation/cli/commands/plan-command.js +1 -1
- package/dist/presentation/cli/commands/product-command.js +193 -16
- package/dist/presentation/cli/commands/report-command.js +353 -0
- package/dist/presentation/cli/commands/run-command.js +3 -3
- package/dist/presentation/cli/commands/scan-tool-command.js +65 -0
- package/dist/presentation/cli/commands/setup-command.js +34 -81
- package/dist/presentation/cli/commands/smart-command.js +50 -172
- package/dist/presentation/cli/commands/status-command.js +304 -119
- package/dist/presentation/cli/commands/trust-command.js +267 -274
- package/dist/presentation/cli/commands/undo-command.js +2 -2
- package/dist/search.js +37 -67
- package/dist/session.js +595 -484
- package/dist/task-verification.js +4 -4
- package/dist/token-optimizer.js +1 -6
- package/dist/ui.js +132 -16
- package/dist/utils/check-api-status.js +30 -12
- package/dist/utils/diff-parser.js +18 -48
- package/dist/verification/compiler.js +12 -11
- package/package.json +36 -43
- package/dist/agents/base.d.ts +0 -107
- package/dist/agents/base.d.ts.map +0 -1
- package/dist/agents/base.js.map +0 -1
- package/dist/agents/orchestrator-model-driven.d.ts +0 -41
- package/dist/agents/orchestrator-model-driven.d.ts.map +0 -1
- package/dist/agents/orchestrator-model-driven.js.map +0 -1
- package/dist/agents/react-orchestrator-agent.d.ts +0 -15
- package/dist/agents/react-orchestrator-agent.d.ts.map +0 -1
- package/dist/agents/react-orchestrator-agent.js.map +0 -1
- package/dist/application/agents/execution-agent.d.ts +0 -79
- package/dist/application/agents/execution-agent.d.ts.map +0 -1
- package/dist/application/agents/execution-agent.js.map +0 -1
- package/dist/application/agents/multi-agent-orchestrator.d.ts +0 -69
- package/dist/application/agents/multi-agent-orchestrator.d.ts.map +0 -1
- package/dist/application/agents/multi-agent-orchestrator.js.map +0 -1
- package/dist/application/agents/planning-agent.d.ts +0 -65
- package/dist/application/agents/planning-agent.d.ts.map +0 -1
- package/dist/application/agents/planning-agent.js.map +0 -1
- package/dist/application/agents/validation-agent.d.ts +0 -68
- package/dist/application/agents/validation-agent.d.ts.map +0 -1
- package/dist/application/agents/validation-agent.js.map +0 -1
- package/dist/application/architectures/plan-and-act.d.ts +0 -94
- package/dist/application/architectures/plan-and-act.d.ts.map +0 -1
- package/dist/application/architectures/plan-and-act.js.map +0 -1
- package/dist/application/index.d.ts +0 -12
- package/dist/application/index.d.ts.map +0 -1
- package/dist/application/index.js.map +0 -1
- package/dist/application/services/agent-factory.d.ts +0 -9
- package/dist/application/services/agent-factory.d.ts.map +0 -1
- package/dist/application/services/agent-factory.js.map +0 -1
- package/dist/application/services/context-importer.d.ts +0 -71
- package/dist/application/services/context-importer.d.ts.map +0 -1
- package/dist/application/services/context-importer.js +0 -436
- package/dist/application/services/context-importer.js.map +0 -1
- package/dist/application/services/context-manager.d.ts +0 -132
- package/dist/application/services/context-manager.d.ts.map +0 -1
- package/dist/application/services/context-manager.js +0 -369
- package/dist/application/services/context-manager.js.map +0 -1
- package/dist/application/services/dependency-container.d.ts +0 -187
- package/dist/application/services/dependency-container.d.ts.map +0 -1
- package/dist/application/services/dependency-container.js.map +0 -1
- package/dist/application/services/git-context-service.d.ts +0 -30
- package/dist/application/services/git-context-service.d.ts.map +0 -1
- package/dist/application/services/git-context-service.js.map +0 -1
- package/dist/application/services/intelligent-router.d.ts +0 -90
- package/dist/application/services/intelligent-router.d.ts.map +0 -1
- package/dist/application/services/intelligent-router.js.map +0 -1
- package/dist/application/services/token-counting-service.d.ts +0 -87
- package/dist/application/services/token-counting-service.d.ts.map +0 -1
- package/dist/application/services/token-counting-service.js +0 -196
- package/dist/application/services/token-counting-service.js.map +0 -1
- package/dist/application/services/tool-executor-service.d.ts +0 -14
- package/dist/application/services/tool-executor-service.d.ts.map +0 -1
- package/dist/application/services/tool-executor-service.js.map +0 -1
- package/dist/application/use-cases/ask-question-use-case.d.ts +0 -67
- package/dist/application/use-cases/ask-question-use-case.d.ts.map +0 -1
- package/dist/application/use-cases/ask-question-use-case.js.map +0 -1
- package/dist/application/use-cases/edit-file-use-case.d.ts +0 -92
- package/dist/application/use-cases/edit-file-use-case.d.ts.map +0 -1
- package/dist/application/use-cases/edit-file-use-case.js.map +0 -1
- package/dist/application/use-cases/explain-file-use-case.d.ts +0 -21
- package/dist/application/use-cases/explain-file-use-case.d.ts.map +0 -1
- package/dist/application/use-cases/explain-file-use-case.js.map +0 -1
- package/dist/application/use-cases/index-codebase-use-case.d.ts +0 -46
- package/dist/application/use-cases/index-codebase-use-case.d.ts.map +0 -1
- package/dist/application/use-cases/index-codebase-use-case.js.map +0 -1
- package/dist/application/use-cases/planning-use-case.d.ts +0 -46
- package/dist/application/use-cases/planning-use-case.d.ts.map +0 -1
- package/dist/application/use-cases/planning-use-case.js.map +0 -1
- package/dist/application/use-cases/react-orchestration-use-case.d.ts +0 -51
- package/dist/application/use-cases/react-orchestration-use-case.d.ts.map +0 -1
- package/dist/application/use-cases/react-orchestration-use-case.js.map +0 -1
- package/dist/application/use-cases/reflexion-use-case.d.ts +0 -24
- package/dist/application/use-cases/reflexion-use-case.d.ts.map +0 -1
- package/dist/application/use-cases/reflexion-use-case.js.map +0 -1
- package/dist/application/workflows/deterministic-workflows.d.ts +0 -61
- package/dist/application/workflows/deterministic-workflows.d.ts.map +0 -1
- package/dist/application/workflows/deterministic-workflows.js.map +0 -1
- package/dist/ast-parser.d 2.ts +0 -55
- package/dist/ast-parser.d.ts +0 -55
- package/dist/ast-parser.d.ts.map +0 -1
- package/dist/ast-parser.js.map +0 -1
- package/dist/cache.d.ts +0 -45
- package/dist/cache.d.ts.map +0 -1
- package/dist/cache.js.map +0 -1
- package/dist/chat.d.ts +0 -4
- package/dist/chat.d.ts.map +0 -1
- package/dist/chat.js.map +0 -1
- package/dist/code-analysis 2.js +0 -327
- package/dist/code-analysis.d.ts +0 -50
- package/dist/code-analysis.d.ts.map +0 -1
- package/dist/code-analysis.js.map +0 -1
- package/dist/context.d.ts +0 -44
- package/dist/context.d.ts 2.map +0 -1
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js.map +0 -1
- package/dist/docs.d.ts +0 -21
- package/dist/docs.d.ts.map +0 -1
- package/dist/docs.js.map +0 -1
- package/dist/domain/entities/code-chunk.d.ts +0 -26
- package/dist/domain/entities/code-chunk.d.ts.map +0 -1
- package/dist/domain/entities/code-chunk.js.map +0 -1
- package/dist/domain/entities/conversation-context.d.ts +0 -245
- package/dist/domain/entities/conversation-context.d.ts.map +0 -1
- package/dist/domain/entities/conversation-context.js +0 -50
- package/dist/domain/entities/conversation-context.js.map +0 -1
- package/dist/domain/entities/decision.d.ts +0 -37
- package/dist/domain/entities/decision.d.ts.map +0 -1
- package/dist/domain/entities/decision.js.map +0 -1
- package/dist/domain/entities/edit.d.ts +0 -35
- package/dist/domain/entities/edit.d.ts.map +0 -1
- package/dist/domain/entities/edit.js.map +0 -1
- package/dist/domain/entities/knowledge-node.d.ts +0 -83
- package/dist/domain/entities/knowledge-node.d.ts.map +0 -1
- package/dist/domain/entities/knowledge-node.js.map +0 -1
- package/dist/domain/entities/knowledge-preservation.d.ts +0 -42
- package/dist/domain/entities/knowledge-preservation.d.ts.map +0 -1
- package/dist/domain/entities/knowledge-preservation.js.map +0 -1
- package/dist/domain/entities/memory.d.ts +0 -36
- package/dist/domain/entities/memory.d.ts.map +0 -1
- package/dist/domain/entities/memory.js.map +0 -1
- package/dist/domain/entities/pattern.d.ts +0 -49
- package/dist/domain/entities/pattern.d.ts.map +0 -1
- package/dist/domain/entities/pattern.js.map +0 -1
- package/dist/domain/entities/plan.d.ts +0 -42
- package/dist/domain/entities/plan.d.ts.map +0 -1
- package/dist/domain/entities/plan.js.map +0 -1
- package/dist/domain/entities/query.d.ts +0 -17
- package/dist/domain/entities/query.d.ts.map +0 -1
- package/dist/domain/entities/query.js.map +0 -1
- package/dist/domain/entities/task.d.ts +0 -152
- package/dist/domain/entities/task.d.ts.map +0 -1
- package/dist/domain/entities/task.js.map +0 -1
- package/dist/domain/errors/embeddings-not-found-error.d.ts +0 -9
- package/dist/domain/errors/embeddings-not-found-error.d.ts.map +0 -1
- package/dist/domain/errors/embeddings-not-found-error.js.map +0 -1
- package/dist/domain/index.d.ts +0 -16
- package/dist/domain/index.d.ts.map +0 -1
- package/dist/domain/index.js.map +0 -1
- package/dist/domain/interfaces/ai-service.interface.d.ts +0 -72
- package/dist/domain/interfaces/ai-service.interface.d.ts.map +0 -1
- package/dist/domain/interfaces/ai-service.interface.js.map +0 -1
- package/dist/domain/interfaces/code-analyzer.interface.d.ts +0 -38
- package/dist/domain/interfaces/code-analyzer.interface.d.ts.map +0 -1
- package/dist/domain/interfaces/code-analyzer.interface.js.map +0 -1
- package/dist/domain/interfaces/context-repository.interface.d.ts +0 -71
- package/dist/domain/interfaces/context-repository.interface.d.ts.map +0 -1
- package/dist/domain/interfaces/context-repository.interface.js +0 -10
- package/dist/domain/interfaces/context-repository.interface.js.map +0 -1
- package/dist/domain/interfaces/decision-repository.interface.d.ts +0 -51
- package/dist/domain/interfaces/decision-repository.interface.d.ts.map +0 -1
- package/dist/domain/interfaces/decision-repository.interface.js.map +0 -1
- package/dist/domain/interfaces/embedding-repository.interface.d.ts +0 -33
- package/dist/domain/interfaces/embedding-repository.interface.d.ts.map +0 -1
- package/dist/domain/interfaces/embedding-repository.interface.js.map +0 -1
- package/dist/domain/interfaces/knowledge-graph-repository.interface.d.ts +0 -91
- package/dist/domain/interfaces/knowledge-graph-repository.interface.d.ts.map +0 -1
- package/dist/domain/interfaces/knowledge-graph-repository.interface.js.map +0 -1
- package/dist/domain/interfaces/knowledge-preservation-repository.interface.d.ts +0 -50
- package/dist/domain/interfaces/knowledge-preservation-repository.interface.d.ts.map +0 -1
- package/dist/domain/interfaces/knowledge-preservation-repository.interface.js.map +0 -1
- package/dist/domain/interfaces/memory-repository.interface.d.ts +0 -49
- package/dist/domain/interfaces/memory-repository.interface.d.ts.map +0 -1
- package/dist/domain/interfaces/memory-repository.interface.js.map +0 -1
- package/dist/domain/interfaces/pattern-repository.interface.d.ts +0 -48
- package/dist/domain/interfaces/pattern-repository.interface.d.ts.map +0 -1
- package/dist/domain/interfaces/pattern-repository.interface.js.map +0 -1
- package/dist/domain/interfaces/verification-service.interface.d.ts +0 -20
- package/dist/domain/interfaces/verification-service.interface.d.ts.map +0 -1
- package/dist/domain/interfaces/verification-service.interface.js.map +0 -1
- package/dist/domain/services/codebase-detector.d.ts +0 -18
- package/dist/domain/services/codebase-detector.d.ts.map +0 -1
- package/dist/domain/services/codebase-detector.js.map +0 -1
- package/dist/domain/services/cross-team-pattern-sharing.d.ts +0 -65
- package/dist/domain/services/cross-team-pattern-sharing.d.ts.map +0 -1
- package/dist/domain/services/cross-team-pattern-sharing.js.map +0 -1
- package/dist/domain/services/decision-recorder.d.ts +0 -76
- package/dist/domain/services/decision-recorder.d.ts.map +0 -1
- package/dist/domain/services/decision-recorder.js.map +0 -1
- package/dist/domain/services/decision-retriever.d.ts +0 -75
- package/dist/domain/services/decision-retriever.d.ts.map +0 -1
- package/dist/domain/services/decision-retriever.js.map +0 -1
- package/dist/domain/services/environment-mode-manager.d.ts +0 -12
- package/dist/domain/services/environment-mode-manager.d.ts.map +0 -1
- package/dist/domain/services/environment-mode-manager.js.map +0 -1
- package/dist/domain/services/graded-memory-activation.d.ts +0 -37
- package/dist/domain/services/graded-memory-activation.d.ts.map +0 -1
- package/dist/domain/services/graded-memory-activation.js.map +0 -1
- package/dist/domain/services/knowledge-access.d.ts +0 -63
- package/dist/domain/services/knowledge-access.d.ts.map +0 -1
- package/dist/domain/services/knowledge-access.js.map +0 -1
- package/dist/domain/services/knowledge-extractor.d.ts +0 -54
- package/dist/domain/services/knowledge-extractor.d.ts.map +0 -1
- package/dist/domain/services/knowledge-extractor.js.map +0 -1
- package/dist/domain/services/knowledge-graph-builder.d.ts +0 -70
- package/dist/domain/services/knowledge-graph-builder.d.ts.map +0 -1
- package/dist/domain/services/knowledge-graph-builder.js.map +0 -1
- package/dist/domain/services/knowledge-graph-query.d.ts +0 -69
- package/dist/domain/services/knowledge-graph-query.d.ts.map +0 -1
- package/dist/domain/services/knowledge-graph-query.js.map +0 -1
- package/dist/domain/services/memory-retriever.d.ts +0 -30
- package/dist/domain/services/memory-retriever.d.ts.map +0 -1
- package/dist/domain/services/memory-retriever.js.map +0 -1
- package/dist/domain/services/memory-synthesizer.d.ts +0 -57
- package/dist/domain/services/memory-synthesizer.d.ts.map +0 -1
- package/dist/domain/services/memory-synthesizer.js.map +0 -1
- package/dist/domain/services/pattern-extractor.d.ts +0 -108
- package/dist/domain/services/pattern-extractor.d.ts.map +0 -1
- package/dist/domain/services/pattern-extractor.js.map +0 -1
- package/dist/domain/services/query-intent-classifier.d.ts +0 -16
- package/dist/domain/services/query-intent-classifier.d.ts.map +0 -1
- package/dist/domain/services/query-intent-classifier.js.map +0 -1
- package/dist/domain/services/react-loop.d.ts +0 -52
- package/dist/domain/services/react-loop.d.ts.map +0 -1
- package/dist/domain/services/react-loop.js.map +0 -1
- package/dist/domain/services/risk-tier-detector.d.ts +0 -17
- package/dist/domain/services/risk-tier-detector.d.ts.map +0 -1
- package/dist/domain/services/risk-tier-detector.js.map +0 -1
- package/dist/edit.d.ts +0 -26
- package/dist/edit.d.ts 2.map +0 -1
- package/dist/edit.d.ts.map +0 -1
- package/dist/edit.js.map +0 -1
- package/dist/embed.d 2.ts +0 -14
- package/dist/embed.d.ts +0 -14
- package/dist/embed.d.ts.map +0 -1
- package/dist/embed.js.map +0 -1
- package/dist/error-handler.d 2.ts +0 -77
- package/dist/error-handler.d.ts +0 -77
- package/dist/error-handler.d.ts.map +0 -1
- package/dist/error-handler.js.map +0 -1
- package/dist/formatter 2.js +0 -168
- package/dist/formatter.d.ts +0 -25
- package/dist/formatter.d.ts 2.map +0 -1
- package/dist/formatter.d.ts.map +0 -1
- package/dist/formatter.js.map +0 -1
- package/dist/git 2.js +0 -198
- package/dist/git.d 2.ts +0 -55
- package/dist/git.d.ts +0 -55
- package/dist/git.d.ts.map +0 -1
- package/dist/git.js.map +0 -1
- package/dist/index 2.d.ts +0 -16
- package/dist/index 2.d.ts.map +0 -1
- package/dist/index 2.js +0 -429
- package/dist/index 2.js.map +0 -1
- package/dist/index-backup-before-lazy-loading.d.ts +0 -3
- package/dist/index-backup-before-lazy-loading.d.ts.map +0 -1
- package/dist/index-backup-before-lazy-loading.js +0 -1551
- package/dist/index-backup-before-lazy-loading.js.map +0 -1
- package/dist/index.d.ts +0 -16
- package/dist/index.d.ts 2.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js 2.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/infrastructure/ai/cohere-ai-service.d.ts +0 -71
- package/dist/infrastructure/ai/cohere-ai-service.d.ts.map +0 -1
- package/dist/infrastructure/ai/cohere-ai-service.js.map +0 -1
- package/dist/infrastructure/ai/command-r-evaluation.d.ts +0 -42
- package/dist/infrastructure/ai/command-r-evaluation.d.ts.map +0 -1
- package/dist/infrastructure/ai/command-r-evaluation.js.map +0 -1
- package/dist/infrastructure/ai/model-config.d.ts +0 -47
- package/dist/infrastructure/ai/model-config.d.ts.map +0 -1
- package/dist/infrastructure/ai/model-config.js.map +0 -1
- package/dist/infrastructure/ai/provider-ai-service.d.ts +0 -67
- package/dist/infrastructure/ai/provider-ai-service.d.ts.map +0 -1
- package/dist/infrastructure/ai/provider-ai-service.js.map +0 -1
- package/dist/infrastructure/cache/embedding-cache.d.ts +0 -58
- package/dist/infrastructure/cache/embedding-cache.d.ts.map +0 -1
- package/dist/infrastructure/cache/embedding-cache.js.map +0 -1
- package/dist/infrastructure/cache/query-result-cache.d.ts +0 -27
- package/dist/infrastructure/cache/query-result-cache.d.ts.map +0 -1
- package/dist/infrastructure/cache/query-result-cache.js.map +0 -1
- package/dist/infrastructure/cache/response-cache.d.ts +0 -18
- package/dist/infrastructure/cache/response-cache.d.ts.map +0 -1
- package/dist/infrastructure/cache/response-cache.js.map +0 -1
- package/dist/infrastructure/cache/security-scan-cache.d.ts +0 -16
- package/dist/infrastructure/cache/security-scan-cache.d.ts.map +0 -1
- package/dist/infrastructure/cache/security-scan-cache.js.map +0 -1
- package/dist/infrastructure/chunking/ast-code-chunker.d.ts +0 -12
- package/dist/infrastructure/chunking/ast-code-chunker.d.ts.map +0 -1
- package/dist/infrastructure/chunking/ast-code-chunker.js.map +0 -1
- package/dist/infrastructure/chunking/code-aware-chunker.d.ts +0 -63
- package/dist/infrastructure/chunking/code-aware-chunker.d.ts.map +0 -1
- package/dist/infrastructure/chunking/code-aware-chunker.js.map +0 -1
- package/dist/infrastructure/completion/bash-completion.d.ts +0 -7
- package/dist/infrastructure/completion/bash-completion.d.ts.map +0 -1
- package/dist/infrastructure/completion/bash-completion.js.map +0 -1
- package/dist/infrastructure/completion/fish-completion.d.ts +0 -7
- package/dist/infrastructure/completion/fish-completion.d.ts.map +0 -1
- package/dist/infrastructure/completion/fish-completion.js.map +0 -1
- package/dist/infrastructure/completion/zsh-completion.d.ts +0 -7
- package/dist/infrastructure/completion/zsh-completion.d.ts.map +0 -1
- package/dist/infrastructure/completion/zsh-completion.js.map +0 -1
- package/dist/infrastructure/config/config-manager.d.ts +0 -158
- package/dist/infrastructure/config/config-manager.d.ts.map +0 -1
- package/dist/infrastructure/config/config-manager.js.map +0 -1
- package/dist/infrastructure/context/context-compressor.d.ts +0 -94
- package/dist/infrastructure/context/context-compressor.d.ts.map +0 -1
- package/dist/infrastructure/context/context-compressor.js.map +0 -1
- package/dist/infrastructure/context/conversation-context.d.ts +0 -82
- package/dist/infrastructure/context/conversation-context.d.ts.map +0 -1
- package/dist/infrastructure/context/conversation-context.js.map +0 -1
- package/dist/infrastructure/context/direct-context-provider.d.ts +0 -18
- package/dist/infrastructure/context/direct-context-provider.d.ts.map +0 -1
- package/dist/infrastructure/context/direct-context-provider.js +0 -222
- package/dist/infrastructure/context/direct-context-provider.js.map +0 -1
- package/dist/infrastructure/context/git-context-provider.d.ts +0 -30
- package/dist/infrastructure/context/git-context-provider.d.ts.map +0 -1
- package/dist/infrastructure/context/git-context-provider.js +0 -140
- package/dist/infrastructure/context/git-context-provider.js.map +0 -1
- package/dist/infrastructure/context/project-context-loader.d.ts +0 -35
- package/dist/infrastructure/context/project-context-loader.d.ts.map +0 -1
- package/dist/infrastructure/context/project-context-loader.js +0 -184
- package/dist/infrastructure/context/project-context-loader.js.map +0 -1
- package/dist/infrastructure/context/session-manager.d.ts +0 -42
- package/dist/infrastructure/context/session-manager.d.ts.map +0 -1
- package/dist/infrastructure/context/session-manager.js.map +0 -1
- package/dist/infrastructure/cost/cost-tracker.d.ts +0 -91
- package/dist/infrastructure/cost/cost-tracker.d.ts.map +0 -1
- package/dist/infrastructure/cost/cost-tracker.js.map +0 -1
- package/dist/infrastructure/cost/session-token-tracker.d.ts +0 -68
- package/dist/infrastructure/cost/session-token-tracker.d.ts.map +0 -1
- package/dist/infrastructure/cost/session-token-tracker.js +0 -178
- package/dist/infrastructure/cost/session-token-tracker.js.map +0 -1
- package/dist/infrastructure/cost-calculator.d.ts +0 -34
- package/dist/infrastructure/cost-calculator.d.ts.map +0 -1
- package/dist/infrastructure/cost-calculator.js +0 -145
- package/dist/infrastructure/cost-calculator.js.map +0 -1
- package/dist/infrastructure/cost-estimator.d.ts +0 -48
- package/dist/infrastructure/cost-estimator.d.ts.map +0 -1
- package/dist/infrastructure/cost-estimator.js +0 -201
- package/dist/infrastructure/cost-estimator.js.map +0 -1
- package/dist/infrastructure/file-scanner/file-scanner.d.ts +0 -31
- package/dist/infrastructure/file-scanner/file-scanner.d.ts.map +0 -1
- package/dist/infrastructure/file-scanner/file-scanner.js.map +0 -1
- package/dist/infrastructure/governance/nist-ai-rmf.d.ts +0 -105
- package/dist/infrastructure/governance/nist-ai-rmf.d.ts.map +0 -1
- package/dist/infrastructure/governance/nist-ai-rmf.js.map +0 -1
- package/dist/infrastructure/governance/policy-as-code.d.ts +0 -88
- package/dist/infrastructure/governance/policy-as-code.d.ts.map +0 -1
- package/dist/infrastructure/governance/policy-as-code.js.map +0 -1
- package/dist/infrastructure/governance/prompt-to-code-lineage.d.ts +0 -136
- package/dist/infrastructure/governance/prompt-to-code-lineage.d.ts.map +0 -1
- package/dist/infrastructure/governance/prompt-to-code-lineage.js.map +0 -1
- package/dist/infrastructure/index.d.ts +0 -7
- package/dist/infrastructure/index.d.ts.map +0 -1
- package/dist/infrastructure/index.js.map +0 -1
- package/dist/infrastructure/observability/execution-tracer.d.ts +0 -130
- package/dist/infrastructure/observability/execution-tracer.d.ts.map +0 -1
- package/dist/infrastructure/observability/execution-tracer.js.map +0 -1
- package/dist/infrastructure/observability/prompt-versioner.d.ts +0 -67
- package/dist/infrastructure/observability/prompt-versioner.d.ts.map +0 -1
- package/dist/infrastructure/observability/prompt-versioner.js.map +0 -1
- package/dist/infrastructure/protocols/a2a-metadata.d.ts +0 -278
- package/dist/infrastructure/protocols/a2a-metadata.d.ts.map +0 -1
- package/dist/infrastructure/protocols/a2a-metadata.js.map +0 -1
- package/dist/infrastructure/protocols/a2a-protocol.d.ts +0 -132
- package/dist/infrastructure/protocols/a2a-protocol.d.ts.map +0 -1
- package/dist/infrastructure/protocols/a2a-protocol.js.map +0 -1
- package/dist/infrastructure/protocols/mcp-oauth.d.ts +0 -91
- package/dist/infrastructure/protocols/mcp-oauth.d.ts.map +0 -1
- package/dist/infrastructure/protocols/mcp-oauth.js.map +0 -1
- package/dist/infrastructure/protocols/mcp-server.d.ts +0 -126
- package/dist/infrastructure/protocols/mcp-server.d.ts.map +0 -1
- package/dist/infrastructure/protocols/mcp-server.js.map +0 -1
- package/dist/infrastructure/protocols/streaming-handler.d.ts +0 -57
- package/dist/infrastructure/protocols/streaming-handler.d.ts.map +0 -1
- package/dist/infrastructure/protocols/streaming-handler.js.map +0 -1
- package/dist/infrastructure/providers/cohere-provider.d.ts +0 -39
- package/dist/infrastructure/providers/cohere-provider.d.ts.map +0 -1
- package/dist/infrastructure/providers/cohere-provider.js.map +0 -1
- package/dist/infrastructure/providers/fake-provider.d.ts +0 -43
- package/dist/infrastructure/providers/fake-provider.d.ts.map +0 -1
- package/dist/infrastructure/providers/fake-provider.js.map +0 -1
- package/dist/infrastructure/providers/local-llm-provider.d.ts +0 -49
- package/dist/infrastructure/providers/local-llm-provider.d.ts.map +0 -1
- package/dist/infrastructure/providers/local-llm-provider.js.map +0 -1
- package/dist/infrastructure/providers/model-config.types.d.ts +0 -70
- package/dist/infrastructure/providers/model-config.types.d.ts.map +0 -1
- package/dist/infrastructure/providers/model-config.types.js.map +0 -1
- package/dist/infrastructure/providers/model-provider.interface.d.ts +0 -113
- package/dist/infrastructure/providers/model-provider.interface.d.ts.map +0 -1
- package/dist/infrastructure/providers/model-provider.interface.js.map +0 -1
- package/dist/infrastructure/providers/openai-provider.d.ts +0 -38
- package/dist/infrastructure/providers/openai-provider.d.ts.map +0 -1
- package/dist/infrastructure/providers/openai-provider.js.map +0 -1
- package/dist/infrastructure/providers/openrouter-provider.d.ts +0 -42
- package/dist/infrastructure/providers/openrouter-provider.d.ts.map +0 -1
- package/dist/infrastructure/providers/openrouter-provider.js.map +0 -1
- package/dist/infrastructure/providers/operation-provider-resolver.d.ts +0 -48
- package/dist/infrastructure/providers/operation-provider-resolver.d.ts.map +0 -1
- package/dist/infrastructure/providers/operation-provider-resolver.js.map +0 -1
- package/dist/infrastructure/providers/provider-config-loader.d.ts +0 -37
- package/dist/infrastructure/providers/provider-config-loader.d.ts.map +0 -1
- package/dist/infrastructure/providers/provider-config-loader.js.map +0 -1
- package/dist/infrastructure/providers/provider-registry.d.ts +0 -53
- package/dist/infrastructure/providers/provider-registry.d.ts.map +0 -1
- package/dist/infrastructure/providers/provider-registry.js.map +0 -1
- package/dist/infrastructure/security/ai-sast-scanner.d.ts +0 -59
- package/dist/infrastructure/security/ai-sast-scanner.d.ts.map +0 -1
- package/dist/infrastructure/security/ai-sast-scanner.js.map +0 -1
- package/dist/infrastructure/security/docker-sandbox.d.ts +0 -57
- package/dist/infrastructure/security/docker-sandbox.d.ts.map +0 -1
- package/dist/infrastructure/security/docker-sandbox.js.map +0 -1
- package/dist/infrastructure/security/enhanced-security-gate.d.ts +0 -66
- package/dist/infrastructure/security/enhanced-security-gate.d.ts.map +0 -1
- package/dist/infrastructure/security/enhanced-security-gate.js.map +0 -1
- package/dist/infrastructure/security/input-validator.d.ts +0 -46
- package/dist/infrastructure/security/input-validator.d.ts.map +0 -1
- package/dist/infrastructure/security/input-validator.js.map +0 -1
- package/dist/infrastructure/security/license-scanner.d.ts +0 -55
- package/dist/infrastructure/security/license-scanner.d.ts.map +0 -1
- package/dist/infrastructure/security/license-scanner.js.map +0 -1
- package/dist/infrastructure/security/provider-bias-detector.d.ts +0 -53
- package/dist/infrastructure/security/provider-bias-detector.d.ts.map +0 -1
- package/dist/infrastructure/security/provider-bias-detector.js.map +0 -1
- package/dist/infrastructure/security/sandbox-executor.d.ts +0 -34
- package/dist/infrastructure/security/sandbox-executor.d.ts.map +0 -1
- package/dist/infrastructure/security/sandbox-executor.js.map +0 -1
- package/dist/infrastructure/serialization/toon-serializer.d.ts +0 -45
- package/dist/infrastructure/serialization/toon-serializer.d.ts.map +0 -1
- package/dist/infrastructure/serialization/toon-serializer.js.map +0 -1
- package/dist/infrastructure/storage/embeddings-path.d.ts +0 -18
- package/dist/infrastructure/storage/embeddings-path.d.ts.map +0 -1
- package/dist/infrastructure/storage/embeddings-path.js.map +0 -1
- package/dist/infrastructure/storage/memory-stream-service.d.ts +0 -47
- package/dist/infrastructure/storage/memory-stream-service.d.ts.map +0 -1
- package/dist/infrastructure/storage/memory-stream-service.js.map +0 -1
- package/dist/infrastructure/storage/plan-repository.d.ts +0 -40
- package/dist/infrastructure/storage/plan-repository.d.ts.map +0 -1
- package/dist/infrastructure/storage/plan-repository.js.map +0 -1
- package/dist/infrastructure/storage/sqlite-context-repository.d.ts +0 -95
- package/dist/infrastructure/storage/sqlite-context-repository.d.ts.map +0 -1
- package/dist/infrastructure/storage/sqlite-context-repository.js +0 -467
- package/dist/infrastructure/storage/sqlite-context-repository.js.map +0 -1
- package/dist/infrastructure/storage/sqlite-decision-repository.d.ts +0 -29
- package/dist/infrastructure/storage/sqlite-decision-repository.d.ts.map +0 -1
- package/dist/infrastructure/storage/sqlite-decision-repository.js.map +0 -1
- package/dist/infrastructure/storage/sqlite-embedding-repository.d.ts +0 -47
- package/dist/infrastructure/storage/sqlite-embedding-repository.d.ts.map +0 -1
- package/dist/infrastructure/storage/sqlite-embedding-repository.js.map +0 -1
- package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.d.ts +0 -41
- package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.d.ts.map +0 -1
- package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.js.map +0 -1
- package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.d.ts +0 -29
- package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.d.ts.map +0 -1
- package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.js.map +0 -1
- package/dist/infrastructure/storage/sqlite-memory-repository.d.ts +0 -40
- package/dist/infrastructure/storage/sqlite-memory-repository.d.ts.map +0 -1
- package/dist/infrastructure/storage/sqlite-memory-repository.js.map +0 -1
- package/dist/infrastructure/storage/sqlite-pattern-repository.d.ts +0 -25
- package/dist/infrastructure/storage/sqlite-pattern-repository.d.ts.map +0 -1
- package/dist/infrastructure/storage/sqlite-pattern-repository.js.map +0 -1
- package/dist/infrastructure/storage/task-helpers.d.ts +0 -69
- package/dist/infrastructure/storage/task-helpers.d.ts.map +0 -1
- package/dist/infrastructure/storage/task-helpers.js.map +0 -1
- package/dist/infrastructure/storage/task-repository.d.ts +0 -67
- package/dist/infrastructure/storage/task-repository.d.ts.map +0 -1
- package/dist/infrastructure/storage/task-repository.js.map +0 -1
- package/dist/infrastructure/telemetry/telemetry-service.d.ts +0 -74
- package/dist/infrastructure/telemetry/telemetry-service.d.ts.map +0 -1
- package/dist/infrastructure/telemetry/telemetry-service.js.map +0 -1
- package/dist/infrastructure/ux/appropriate-friction.d.ts +0 -77
- package/dist/infrastructure/ux/appropriate-friction.d.ts.map +0 -1
- package/dist/infrastructure/ux/appropriate-friction.js.map +0 -1
- package/dist/infrastructure/ux/bi-directional-learning.d.ts +0 -131
- package/dist/infrastructure/ux/bi-directional-learning.d.ts.map +0 -1
- package/dist/infrastructure/ux/bi-directional-learning.js.map +0 -1
- package/dist/infrastructure/ux/capability-boundaries.d.ts +0 -22
- package/dist/infrastructure/ux/capability-boundaries.d.ts.map +0 -1
- package/dist/infrastructure/ux/capability-boundaries.js.map +0 -1
- package/dist/infrastructure/ux/cli-style-guide.d.ts +0 -105
- package/dist/infrastructure/ux/cli-style-guide.d.ts.map +0 -1
- package/dist/infrastructure/ux/cli-style-guide.js +0 -220
- package/dist/infrastructure/ux/cli-style-guide.js.map +0 -1
- package/dist/infrastructure/ux/comprehensive-formatter.d.ts +0 -21
- package/dist/infrastructure/ux/comprehensive-formatter.d.ts.map +0 -1
- package/dist/infrastructure/ux/comprehensive-formatter.js.map +0 -1
- package/dist/infrastructure/ux/contextual-feature-discovery.d.ts +0 -11
- package/dist/infrastructure/ux/contextual-feature-discovery.d.ts.map +0 -1
- package/dist/infrastructure/ux/contextual-feature-discovery.js.map +0 -1
- package/dist/infrastructure/ux/expectation-management.d.ts +0 -98
- package/dist/infrastructure/ux/expectation-management.d.ts.map +0 -1
- package/dist/infrastructure/ux/expectation-management.js.map +0 -1
- package/dist/infrastructure/ux/feature-discovery.d.ts +0 -17
- package/dist/infrastructure/ux/feature-discovery.d.ts.map +0 -1
- package/dist/infrastructure/ux/feature-discovery.js.map +0 -1
- package/dist/infrastructure/ux/feedback-prompt.d.ts +0 -26
- package/dist/infrastructure/ux/feedback-prompt.d.ts.map +0 -1
- package/dist/infrastructure/ux/feedback-prompt.js.map +0 -1
- package/dist/infrastructure/ux/hitl-validation.d.ts +0 -139
- package/dist/infrastructure/ux/hitl-validation.d.ts.map +0 -1
- package/dist/infrastructure/ux/hitl-validation.js.map +0 -1
- package/dist/infrastructure/ux/progress-indicator.d.ts +0 -53
- package/dist/infrastructure/ux/progress-indicator.d.ts.map +0 -1
- package/dist/infrastructure/ux/progress-indicator.js.map +0 -1
- package/dist/infrastructure/ux/progressive-disclosure.d.ts +0 -84
- package/dist/infrastructure/ux/progressive-disclosure.d.ts.map +0 -1
- package/dist/infrastructure/ux/progressive-disclosure.js.map +0 -1
- package/dist/infrastructure/ux/review-checkpoint.d.ts +0 -37
- package/dist/infrastructure/ux/review-checkpoint.d.ts.map +0 -1
- package/dist/infrastructure/ux/review-checkpoint.js.map +0 -1
- package/dist/infrastructure/ux/staged-feature-intro.d.ts +0 -22
- package/dist/infrastructure/ux/staged-feature-intro.d.ts.map +0 -1
- package/dist/infrastructure/ux/staged-feature-intro.js.map +0 -1
- package/dist/infrastructure/ux/syntax-highlighter.d.ts +0 -20
- package/dist/infrastructure/ux/syntax-highlighter.d.ts.map +0 -1
- package/dist/infrastructure/ux/syntax-highlighter.js.map +0 -1
- package/dist/infrastructure/ux/team-standards.d.ts +0 -94
- package/dist/infrastructure/ux/team-standards.d.ts.map +0 -1
- package/dist/infrastructure/ux/team-standards.js.map +0 -1
- package/dist/infrastructure/validation/agent-feedback.d.ts +0 -57
- package/dist/infrastructure/validation/agent-feedback.d.ts.map +0 -1
- package/dist/infrastructure/validation/agent-feedback.js.map +0 -1
- package/dist/infrastructure/validation/agent-validation-helper.d.ts +0 -75
- package/dist/infrastructure/validation/agent-validation-helper.d.ts.map +0 -1
- package/dist/infrastructure/validation/agent-validation-helper.js.map +0 -1
- package/dist/infrastructure/validation/hallucination-detector.d.ts +0 -121
- package/dist/infrastructure/validation/hallucination-detector.d.ts.map +0 -1
- package/dist/infrastructure/validation/hallucination-detector.js +0 -388
- package/dist/infrastructure/validation/hallucination-detector.js.map +0 -1
- package/dist/infrastructure/validation/review-handler.d.ts +0 -26
- package/dist/infrastructure/validation/review-handler.d.ts.map +0 -1
- package/dist/infrastructure/validation/review-handler.js.map +0 -1
- package/dist/infrastructure/validation/summary-aggregator.d.ts +0 -45
- package/dist/infrastructure/validation/summary-aggregator.d.ts.map +0 -1
- package/dist/infrastructure/validation/summary-aggregator.js.map +0 -1
- package/dist/infrastructure/validation/summary-extractor.d.ts +0 -24
- package/dist/infrastructure/validation/summary-extractor.d.ts.map +0 -1
- package/dist/infrastructure/validation/summary-extractor.js.map +0 -1
- package/dist/infrastructure/validation/trace-summary.d.ts +0 -45
- package/dist/infrastructure/validation/trace-summary.d.ts.map +0 -1
- package/dist/infrastructure/validation/trace-summary.js.map +0 -1
- package/dist/infrastructure/verification/verification-service.d.ts +0 -12
- package/dist/infrastructure/verification/verification-service.d.ts.map +0 -1
- package/dist/infrastructure/verification/verification-service.js.map +0 -1
- package/dist/infrastructure/xai/attention-visualizer.d.ts +0 -71
- package/dist/infrastructure/xai/attention-visualizer.d.ts.map +0 -1
- package/dist/infrastructure/xai/attention-visualizer.js.map +0 -1
- package/dist/infrastructure/xai/cot-visualizer.d.ts +0 -103
- package/dist/infrastructure/xai/cot-visualizer.d.ts.map +0 -1
- package/dist/infrastructure/xai/cot-visualizer.js.map +0 -1
- package/dist/infrastructure/xai/decision-tree-log.d.ts +0 -100
- package/dist/infrastructure/xai/decision-tree-log.d.ts.map +0 -1
- package/dist/infrastructure/xai/decision-tree-log.js.map +0 -1
- package/dist/infrastructure/xai/interactive-xai.d.ts +0 -104
- package/dist/infrastructure/xai/interactive-xai.d.ts.map +0 -1
- package/dist/infrastructure/xai/interactive-xai.js.map +0 -1
- package/dist/infrastructure/xai/uncertainty-quantifier.d.ts +0 -77
- package/dist/infrastructure/xai/uncertainty-quantifier.d.ts.map +0 -1
- package/dist/infrastructure/xai/uncertainty-quantifier.js.map +0 -1
- package/dist/intelligent-retrieval 2.js +0 -272
- package/dist/intelligent-retrieval.d.ts +0 -41
- package/dist/intelligent-retrieval.d.ts 2.map +0 -1
- package/dist/intelligent-retrieval.d.ts.map +0 -1
- package/dist/intelligent-retrieval.js.map +0 -1
- package/dist/intent/classifier.d.ts +0 -6
- package/dist/intent/classifier.d.ts.map +0 -1
- package/dist/intent/classifier.js.map +0 -1
- package/dist/intent/context.d.ts +0 -4
- package/dist/intent/context.d.ts.map +0 -1
- package/dist/intent/context.js.map +0 -1
- package/dist/iterative-refinement.d.ts +0 -31
- package/dist/iterative-refinement.d.ts.map +0 -1
- package/dist/iterative-refinement.js.map +0 -1
- package/dist/learning.d.ts +0 -69
- package/dist/learning.d.ts.map +0 -1
- package/dist/learning.js.map +0 -1
- package/dist/log.d.ts +0 -4
- package/dist/log.d.ts.map +0 -1
- package/dist/log.js 2.map +0 -1
- package/dist/log.js.map +0 -1
- package/dist/migrate.d.ts +0 -33
- package/dist/migrate.d.ts.map +0 -1
- package/dist/migrate.js 2.map +0 -1
- package/dist/migrate.js.map +0 -1
- package/dist/monitoring.d.ts +0 -75
- package/dist/monitoring.d.ts.map +0 -1
- package/dist/monitoring.js.map +0 -1
- package/dist/parallel-processor.d 2.ts +0 -44
- package/dist/parallel-processor.d.ts +0 -44
- package/dist/parallel-processor.d.ts.map +0 -1
- package/dist/parallel-processor.js.map +0 -1
- package/dist/planner.d.ts +0 -47
- package/dist/planner.d.ts.map +0 -1
- package/dist/planner.js.map +0 -1
- package/dist/policy.d 2.ts +0 -3
- package/dist/policy.d.ts +0 -3
- package/dist/policy.d.ts.map +0 -1
- package/dist/policy.js.map +0 -1
- package/dist/presentation/cli/commands/ask-command.d.ts +0 -9
- package/dist/presentation/cli/commands/ask-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/ask-command.js.map +0 -1
- package/dist/presentation/cli/commands/audit-command.d.ts +0 -13
- package/dist/presentation/cli/commands/audit-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/audit-command.js +0 -96
- package/dist/presentation/cli/commands/audit-command.js.map +0 -1
- package/dist/presentation/cli/commands/config-command.d.ts +0 -9
- package/dist/presentation/cli/commands/config-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/config-command.js.map +0 -1
- package/dist/presentation/cli/commands/context-command.d.ts +0 -32
- package/dist/presentation/cli/commands/context-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/context-command.js +0 -295
- package/dist/presentation/cli/commands/context-command.js.map +0 -1
- package/dist/presentation/cli/commands/context-helper.d.ts +0 -16
- package/dist/presentation/cli/commands/context-helper.d.ts.map +0 -1
- package/dist/presentation/cli/commands/context-helper.js +0 -88
- package/dist/presentation/cli/commands/context-helper.js.map +0 -1
- package/dist/presentation/cli/commands/cost-command.d.ts +0 -8
- package/dist/presentation/cli/commands/cost-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/cost-command.js.map +0 -1
- package/dist/presentation/cli/commands/decision-command.d.ts +0 -12
- package/dist/presentation/cli/commands/decision-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/decision-command.js.map +0 -1
- package/dist/presentation/cli/commands/docs-command.d.ts +0 -14
- package/dist/presentation/cli/commands/docs-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/docs-command.js.map +0 -1
- package/dist/presentation/cli/commands/fix-command.d.ts +0 -15
- package/dist/presentation/cli/commands/fix-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/fix-command.js.map +0 -1
- package/dist/presentation/cli/commands/help-command.d.ts +0 -9
- package/dist/presentation/cli/commands/help-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/help-command.js.map +0 -1
- package/dist/presentation/cli/commands/knowledge-command.d.ts +0 -13
- package/dist/presentation/cli/commands/knowledge-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/knowledge-command.js.map +0 -1
- package/dist/presentation/cli/commands/learning-dashboard-command.d.ts +0 -8
- package/dist/presentation/cli/commands/learning-dashboard-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/learning-dashboard-command.js.map +0 -1
- package/dist/presentation/cli/commands/models-command.d.ts +0 -13
- package/dist/presentation/cli/commands/models-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/models-command.js.map +0 -1
- package/dist/presentation/cli/commands/orchestrate-command.d.ts +0 -10
- package/dist/presentation/cli/commands/orchestrate-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/orchestrate-command.js.map +0 -1
- package/dist/presentation/cli/commands/plan-command.d.ts +0 -9
- package/dist/presentation/cli/commands/plan-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/plan-command.js.map +0 -1
- package/dist/presentation/cli/commands/product-command.d.ts +0 -14
- package/dist/presentation/cli/commands/product-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/product-command.js.map +0 -1
- package/dist/presentation/cli/commands/react-command.d.ts +0 -8
- package/dist/presentation/cli/commands/react-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/react-command.js.map +0 -1
- package/dist/presentation/cli/commands/review-command.d.ts +0 -14
- package/dist/presentation/cli/commands/review-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/review-command.js.map +0 -1
- package/dist/presentation/cli/commands/run-command.d.ts +0 -13
- package/dist/presentation/cli/commands/run-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/run-command.js.map +0 -1
- package/dist/presentation/cli/commands/setup-command.d.ts +0 -10
- package/dist/presentation/cli/commands/setup-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/setup-command.js.map +0 -1
- package/dist/presentation/cli/commands/smart-command.d.ts +0 -11
- package/dist/presentation/cli/commands/smart-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/smart-command.js.map +0 -1
- package/dist/presentation/cli/commands/status-command.d.ts +0 -14
- package/dist/presentation/cli/commands/status-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/status-command.js.map +0 -1
- package/dist/presentation/cli/commands/suggest-command.d.ts +0 -11
- package/dist/presentation/cli/commands/suggest-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/suggest-command.js.map +0 -1
- package/dist/presentation/cli/commands/trace-command.d.ts +0 -8
- package/dist/presentation/cli/commands/trace-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/trace-command.js.map +0 -1
- package/dist/presentation/cli/commands/trust-command.d.ts +0 -28
- package/dist/presentation/cli/commands/trust-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/trust-command.js.map +0 -1
- package/dist/presentation/cli/commands/undo-command.d.ts +0 -8
- package/dist/presentation/cli/commands/undo-command.d.ts.map +0 -1
- package/dist/presentation/cli/commands/undo-command.js.map +0 -1
- package/dist/presentation/cli/error-display.d.ts +0 -25
- package/dist/presentation/cli/error-display.d.ts.map +0 -1
- package/dist/presentation/cli/error-display.js.map +0 -1
- package/dist/query-optimizer.d.ts +0 -32
- package/dist/query-optimizer.d.ts.map +0 -1
- package/dist/query-optimizer.js.map +0 -1
- package/dist/refactor.d.ts +0 -27
- package/dist/refactor.d.ts.map +0 -1
- package/dist/refactor.js.map +0 -1
- package/dist/review 2.js +0 -206
- package/dist/review.d.ts +0 -31
- package/dist/review.d.ts.map +0 -1
- package/dist/review.js.map +0 -1
- package/dist/search.d.ts +0 -19
- package/dist/search.d.ts.map +0 -1
- package/dist/search.js 2.map +0 -1
- package/dist/search.js.map +0 -1
- package/dist/session 2.js +0 -593
- package/dist/session.d.ts +0 -17
- package/dist/session.d.ts 2.map +0 -1
- package/dist/session.d.ts.map +0 -1
- package/dist/session.js.map +0 -1
- package/dist/task-verification 2.js +0 -336
- package/dist/task-verification.d.ts +0 -39
- package/dist/task-verification.d.ts 2.map +0 -1
- package/dist/task-verification.d.ts.map +0 -1
- package/dist/task-verification.js.map +0 -1
- package/dist/test-minimal.d.ts +0 -2
- package/dist/test-minimal.d.ts.map +0 -1
- package/dist/test-minimal.js +0 -2
- package/dist/test-minimal.js.map +0 -1
- package/dist/testgen.d.ts +0 -24
- package/dist/testgen.d.ts.map +0 -1
- package/dist/testgen.js 2.map +0 -1
- package/dist/testgen.js.map +0 -1
- package/dist/token-optimizer.d 2.ts +0 -20
- package/dist/token-optimizer.d.ts +0 -20
- package/dist/token-optimizer.d.ts.map +0 -1
- package/dist/token-optimizer.js.map +0 -1
- package/dist/tools/bash.d.ts +0 -53
- package/dist/tools/bash.d.ts.map +0 -1
- package/dist/tools/bash.js.map +0 -1
- package/dist/tools/edit.d.ts +0 -48
- package/dist/tools/edit.d.ts.map +0 -1
- package/dist/tools/edit.js.map +0 -1
- package/dist/tools/executor.d.ts +0 -29
- package/dist/tools/executor.d.ts.map +0 -1
- package/dist/tools/executor.js.map +0 -1
- package/dist/tools/git-tool.d.ts +0 -87
- package/dist/tools/git-tool.d.ts.map +0 -1
- package/dist/tools/git-tool.js.map +0 -1
- package/dist/tools/parser.d.ts +0 -33
- package/dist/tools/parser.d.ts.map +0 -1
- package/dist/tools/parser.js.map +0 -1
- package/dist/tools/registry.d.ts +0 -74
- package/dist/tools/registry.d.ts.map +0 -1
- package/dist/tools/registry.js.map +0 -1
- package/dist/tools/search.d.ts +0 -41
- package/dist/tools/search.d.ts.map +0 -1
- package/dist/tools/search.js.map +0 -1
- package/dist/types.d.ts +0 -36
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/ui.d.ts +0 -60
- package/dist/ui.d.ts 2.map +0 -1
- package/dist/ui.d.ts.map +0 -1
- package/dist/ui.js.map +0 -1
- package/dist/utils/check-api-status.d.ts +0 -12
- package/dist/utils/check-api-status.d.ts.map +0 -1
- package/dist/utils/check-api-status.js.map +0 -1
- package/dist/utils/debug.d.ts +0 -7
- package/dist/utils/debug.d.ts.map +0 -1
- package/dist/utils/debug.js +0 -24
- package/dist/utils/debug.js.map +0 -1
- package/dist/utils/diff-parser.d.ts +0 -22
- package/dist/utils/diff-parser.d.ts.map +0 -1
- package/dist/utils/diff-parser.js.map +0 -1
- package/dist/utils/provider-check.d.ts +0 -21
- package/dist/utils/provider-check.d.ts.map +0 -1
- package/dist/utils/provider-check.js +0 -124
- package/dist/utils/provider-check.js.map +0 -1
- package/dist/utils/version.d.ts +0 -21
- package/dist/utils/version.d.ts.map +0 -1
- package/dist/utils/version.js.map +0 -1
- package/dist/verification/backup.d.ts +0 -30
- package/dist/verification/backup.d.ts.map +0 -1
- package/dist/verification/backup.js.map +0 -1
- package/dist/verification/compiler.d.ts +0 -20
- package/dist/verification/compiler.d.ts.map +0 -1
- package/dist/verification/compiler.js.map +0 -1
- package/dist/verification/index.d.ts +0 -59
- package/dist/verification/index.d.ts.map +0 -1
- package/dist/verification/index.js.map +0 -1
- package/dist/verification/test-runner.d.ts +0 -27
- package/dist/verification/test-runner.d.ts.map +0 -1
- package/dist/verification/test-runner.js.map +0 -1
- package/dist/verify_db.d.ts +0 -2
- package/dist/verify_db.d.ts.map +0 -1
- package/dist/verify_db.js +0 -52
- package/dist/verify_db.js 2.map +0 -1
- package/dist/verify_db.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,23 +1,50 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* CodeHere CLI Entry Point
|
|
4
|
-
*
|
|
5
|
-
* ARCHITECTURE: Lazy Loading Pattern
|
|
6
|
-
* All heavy imports (DB, WASM, storage) are dynamically imported
|
|
7
|
-
* inside action handlers to prevent startup hangs.
|
|
8
|
-
*
|
|
9
|
-
* Only lightweight, pure-JS modules are imported at top-level:
|
|
10
|
-
* - commander: CLI framework
|
|
11
|
-
* - dotenv: Environment variables
|
|
12
|
-
* - path/fs: Node.js built-ins
|
|
13
|
-
* - ui.js: Formatting utilities (no DB/WASM)
|
|
14
|
-
*/
|
|
15
2
|
import { Command } from 'commander';
|
|
16
3
|
import { config } from 'dotenv';
|
|
17
4
|
import { join, dirname } from 'path';
|
|
18
5
|
import { fileURLToPath } from 'url';
|
|
19
|
-
|
|
20
|
-
import {
|
|
6
|
+
import { readFileSync, existsSync } from 'fs';
|
|
7
|
+
import { indexRepositoryParallel } from './embed.js';
|
|
8
|
+
import { executeAskCommand } from './presentation/cli/commands/ask-command.js';
|
|
9
|
+
import { executeReactCommand } from './presentation/cli/commands/react-command.js';
|
|
10
|
+
import { executeSmartCommand } from './presentation/cli/commands/smart-command.js';
|
|
11
|
+
import { executeFixCommand } from './presentation/cli/commands/fix-command.js';
|
|
12
|
+
import { executeSetupCommand } from './presentation/cli/commands/setup-command.js';
|
|
13
|
+
import { executeConfigCommand } from './presentation/cli/commands/config-command.js';
|
|
14
|
+
import { executeHelpCommand } from './presentation/cli/commands/help-command.js';
|
|
15
|
+
import { initLogFile, logEntry } from './log.js';
|
|
16
|
+
import { performHealthCheck, formatHealthStatus, getMetrics } from './monitoring.js';
|
|
17
|
+
import { refactorMultiFile, findFilesByPattern } from './refactor.js';
|
|
18
|
+
import { getGitStatus, formatGitStatus, getAllGitDiffs, analyzeDiff, getGitDiff } from './git.js';
|
|
19
|
+
import { executePlanCommand } from './presentation/cli/commands/plan-command.js';
|
|
20
|
+
import { executeOrchestrateCommand } from './presentation/cli/commands/orchestrate-command.js';
|
|
21
|
+
import { executeDocsCommand } from './presentation/cli/commands/docs-command.js';
|
|
22
|
+
import { executeProductCommand } from './presentation/cli/commands/product-command.js';
|
|
23
|
+
import { executeStatusCommand } from './presentation/cli/commands/status-command.js';
|
|
24
|
+
import { executeSuggestCommand } from './presentation/cli/commands/suggest-command.js';
|
|
25
|
+
import { executeRunCommand } from './presentation/cli/commands/run-command.js';
|
|
26
|
+
import { executeModelsCommand } from './presentation/cli/commands/models-command.js';
|
|
27
|
+
import { executeReviewCommand } from './presentation/cli/commands/review-command.js';
|
|
28
|
+
import { executeHookCommand } from './presentation/cli/commands/hook-command.js';
|
|
29
|
+
import { executeTrustCommand } from './presentation/cli/commands/trust-command.js';
|
|
30
|
+
import { executeReportCommand } from './presentation/cli/commands/report-command.js';
|
|
31
|
+
import { executeScanToolCommand } from './presentation/cli/commands/scan-tool-command.js';
|
|
32
|
+
import { executeDecisionCommand } from './presentation/cli/commands/decision-command.js';
|
|
33
|
+
import { executeCostCommand } from './presentation/cli/commands/cost-command.js';
|
|
34
|
+
import { executeKnowledgeCommand } from './presentation/cli/commands/knowledge-command.js';
|
|
35
|
+
import { executeLearningDashboardCommand } from './presentation/cli/commands/learning-dashboard-command.js';
|
|
36
|
+
import { executeTraceCommand } from './presentation/cli/commands/trace-command.js';
|
|
37
|
+
import { executeUndoCommand } from './presentation/cli/commands/undo-command.js';
|
|
38
|
+
import { reviewFile, formatReview } from './review.js';
|
|
39
|
+
import { formatLearningInsights, getPerformanceInsights } from './learning.js';
|
|
40
|
+
import { getCacheStats, clearAllCaches } from './cache.js';
|
|
41
|
+
import { planMigration, formatMigrationPlan } from './migrate.js';
|
|
42
|
+
import { generateTests, getTestFilePath, saveTests, improveTests } from './testgen.js';
|
|
43
|
+
import { startSession } from './session.js';
|
|
44
|
+
import { cleanResponse } from './formatter.js';
|
|
45
|
+
import { displayError } from './presentation/cli/error-display.js';
|
|
46
|
+
import { getTelemetryService } from './infrastructure/telemetry/telemetry-service.js';
|
|
47
|
+
import { colors, createSpinner, createBanner, createTable, success, error, warning, info, formatPath, formatNumber, sectionHeader, newline, createWelcomeMessage, isMinimalStyle, printMinimalHeader, requireApiKey, hasAnyApiKey, } from './ui.js';
|
|
21
48
|
// Load environment variables - try agent directory first, then current directory
|
|
22
49
|
try {
|
|
23
50
|
const __filename = fileURLToPath(import.meta.url);
|
|
@@ -34,48 +61,25 @@ import { getVersion } from './utils/version.js';
|
|
|
34
61
|
const program = new Command();
|
|
35
62
|
program
|
|
36
63
|
.name('codehere')
|
|
37
|
-
.description('AI
|
|
64
|
+
.description('AI coding agent with built-in safety')
|
|
38
65
|
.version(getVersion())
|
|
39
66
|
.configureHelp({
|
|
40
67
|
helpWidth: 80,
|
|
41
68
|
sortSubcommands: true,
|
|
42
|
-
})
|
|
43
|
-
.addHelpText('beforeAll', () => {
|
|
44
|
-
return createWelcomeMessage();
|
|
45
69
|
});
|
|
46
70
|
// Smart routing: if query provided as argument, route intelligently
|
|
47
71
|
program
|
|
48
72
|
.argument('[query]', 'Your query - Codehere will understand what you need')
|
|
49
|
-
.option('--review', 'Enable review & feedback capture (used for trust scoring and Validation Mode)')
|
|
50
|
-
.option('--quick', 'Quick mode - work without indexing by reading files directly')
|
|
51
|
-
.option('-c, --continue', 'Continue from previous conversation (session continuity)')
|
|
52
|
-
.option('-m, --model <model>', 'Specify AI model (e.g., gpt-4, claude-3, command-r-plus, llama3)')
|
|
53
73
|
.action(async (query, options) => {
|
|
54
74
|
if (query && query.trim()) {
|
|
55
|
-
// Lazy load dependencies
|
|
56
|
-
const { initLogFile, logEntry } = await import('./log.js');
|
|
57
|
-
const { checkProviderConfiguration, displayProviderError } = await import('./utils/provider-check.js');
|
|
58
|
-
const { executeSmartCommand } = await import('./presentation/cli/commands/smart-command.js');
|
|
59
75
|
// Direct query - use intelligent router
|
|
60
76
|
initLogFile();
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (!providerCheck.hasValidProvider) {
|
|
64
|
-
displayProviderError(providerCheck);
|
|
65
|
-
process.exit(1);
|
|
77
|
+
if (!hasAnyApiKey()) {
|
|
78
|
+
requireApiKey();
|
|
66
79
|
}
|
|
67
80
|
try {
|
|
68
81
|
const opts = program.opts();
|
|
69
|
-
|
|
70
|
-
if (opts.model) {
|
|
71
|
-
process.env.CODEHERE_MODEL = opts.model;
|
|
72
|
-
}
|
|
73
|
-
await executeSmartCommand(query.trim(), {
|
|
74
|
-
review: opts.review || false,
|
|
75
|
-
quick: opts.quick || false,
|
|
76
|
-
continue: opts.continue || false,
|
|
77
|
-
model: opts.model,
|
|
78
|
-
});
|
|
82
|
+
await executeSmartCommand(query.trim(), { review: opts.review || false });
|
|
79
83
|
logEntry({
|
|
80
84
|
timestamp: new Date().toISOString(),
|
|
81
85
|
command: 'smart',
|
|
@@ -89,25 +93,52 @@ program
|
|
|
89
93
|
}
|
|
90
94
|
}
|
|
91
95
|
else if (process.stdin.isTTY) {
|
|
92
|
-
//
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
+
// Check if first run — show onboarding
|
|
97
|
+
const codehereDir = join(process.env.HOME || '', '.codehere');
|
|
98
|
+
const settingsPath = join(process.env.HOME || '', '.claude', 'settings.json');
|
|
99
|
+
const hasHooks = existsSync(settingsPath) && readFileSync(settingsPath, 'utf-8').includes('codehere');
|
|
100
|
+
const hasAuditLog = existsSync(join(codehereDir, 'audit', 'hook-events.jsonl'));
|
|
101
|
+
if (!hasHooks && !hasAuditLog) {
|
|
102
|
+
// First run — onboarding
|
|
103
|
+
console.log(createWelcomeMessage());
|
|
104
|
+
newline();
|
|
105
|
+
console.log(colors.bold('Welcome! Let\'s get you set up.'));
|
|
106
|
+
newline();
|
|
107
|
+
console.log(colors.dim(' codehere works in two layers:'));
|
|
108
|
+
newline();
|
|
109
|
+
console.log(colors.bold(' Layer 0 — Safety (no API key, free, instant)'));
|
|
110
|
+
console.log(colors.dim(' Scans every AI write before it runs. Catches injections,'));
|
|
111
|
+
console.log(colors.dim(' hardcoded secrets, destructive ops, and more.'));
|
|
112
|
+
newline();
|
|
113
|
+
console.log(' → Run ' + colors.cyan('codehere hook install') + ' to activate');
|
|
114
|
+
console.log(' → Run ' + colors.cyan('codehere trust .') + ' to scan this project');
|
|
115
|
+
newline();
|
|
116
|
+
console.log(colors.bold(' Layer 1 — Intelligence (needs API key)'));
|
|
117
|
+
console.log(colors.dim(' Ask questions, fix code, plan tasks — all with AI.'));
|
|
118
|
+
console.log(colors.dim(' Works with Anthropic, OpenAI, or Ollama.'));
|
|
119
|
+
newline();
|
|
120
|
+
console.log(' → Run ' + colors.cyan('codehere setup') + ' to configure');
|
|
121
|
+
newline();
|
|
122
|
+
console.log(colors.dim('Most people start with: ') + colors.cyan('codehere hook install'));
|
|
123
|
+
newline();
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
// Returning user — interactive session
|
|
127
|
+
await startSession();
|
|
128
|
+
}
|
|
96
129
|
}
|
|
97
130
|
else {
|
|
98
|
-
// Non-interactive
|
|
131
|
+
// Non-interactive — show quick start
|
|
99
132
|
console.log(createWelcomeMessage());
|
|
100
133
|
newline();
|
|
101
|
-
console.log(colors.bold('
|
|
134
|
+
console.log(colors.bold('Quick start:'));
|
|
102
135
|
newline();
|
|
103
|
-
console.log(colors.cyan(' codehere
|
|
104
|
-
console.log(colors.cyan(' codehere') + '
|
|
105
|
-
console.log(colors.cyan(' codehere
|
|
136
|
+
console.log(colors.cyan(' codehere hook install') + ' Scan every AI write before it runs');
|
|
137
|
+
console.log(colors.cyan(' codehere trust .') + ' Scan your project now (no API key)');
|
|
138
|
+
console.log(colors.cyan(' codehere report') + ' Generate security audit report');
|
|
106
139
|
newline();
|
|
107
|
-
console.log(colors.
|
|
108
|
-
console.log(colors.
|
|
109
|
-
console.log(colors.dim(' codehere "Explain src/auth.ts"'));
|
|
110
|
-
console.log(colors.dim(' codehere "Fix src/utils.ts add error handling"'));
|
|
140
|
+
console.log(colors.bold('With an API key:'));
|
|
141
|
+
console.log(colors.cyan(' codehere "<your query>"') + ' Ask, fix, plan — routes automatically');
|
|
111
142
|
newline();
|
|
112
143
|
console.log(colors.dim('Run "codehere --help" for all commands'));
|
|
113
144
|
newline();
|
|
@@ -118,7 +149,6 @@ program
|
|
|
118
149
|
.description('Interactive setup wizard for first-time users')
|
|
119
150
|
.option('-f, --force', 'Force reconfiguration even if already set up')
|
|
120
151
|
.action(async (options) => {
|
|
121
|
-
const { executeSetupCommand } = await import('./presentation/cli/commands/setup-command.js');
|
|
122
152
|
await executeSetupCommand(options.force || false);
|
|
123
153
|
});
|
|
124
154
|
program
|
|
@@ -128,7 +158,6 @@ program
|
|
|
128
158
|
.argument('[key]', 'Preference key (for get/set)')
|
|
129
159
|
.argument('[value]', 'Preference value (for set)')
|
|
130
160
|
.action(async (action, key, value) => {
|
|
131
|
-
const { executeConfigCommand } = await import('./presentation/cli/commands/config-command.js');
|
|
132
161
|
await executeConfigCommand(action, key, value);
|
|
133
162
|
});
|
|
134
163
|
program
|
|
@@ -140,190 +169,330 @@ program
|
|
|
140
169
|
.option('-p, --provider <provider>', 'Filter by provider (cohere, openai, openrouter, etc.)')
|
|
141
170
|
.option('--json', 'Output in JSON format')
|
|
142
171
|
.action(async (options) => {
|
|
143
|
-
|
|
144
|
-
|
|
172
|
+
initLogFile();
|
|
173
|
+
try {
|
|
174
|
+
await executeModelsCommand({
|
|
175
|
+
list: options.list,
|
|
176
|
+
search: options.search,
|
|
177
|
+
info: options.info,
|
|
178
|
+
provider: options.provider,
|
|
179
|
+
json: options.json,
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
catch (err) {
|
|
183
|
+
console.error(error('Error:'), err instanceof Error ? err.message : String(err));
|
|
184
|
+
process.exit(1);
|
|
185
|
+
}
|
|
145
186
|
});
|
|
146
187
|
program
|
|
147
|
-
.command('
|
|
148
|
-
.description('
|
|
149
|
-
.
|
|
150
|
-
.option('--
|
|
151
|
-
.option('--
|
|
152
|
-
.
|
|
153
|
-
|
|
154
|
-
.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const { indexRepositoryParallel } = await import('./embed.js');
|
|
165
|
-
initLogFile();
|
|
166
|
-
if (isMinimalStyle()) {
|
|
167
|
-
printMinimalHeader('index', repoPath);
|
|
188
|
+
.command('telemetry')
|
|
189
|
+
.description('Manage telemetry settings (opt-in, privacy-first)')
|
|
190
|
+
.option('--enable', 'Enable telemetry')
|
|
191
|
+
.option('--disable', 'Disable telemetry')
|
|
192
|
+
.option('--status', 'Show telemetry status')
|
|
193
|
+
.action(async (options) => {
|
|
194
|
+
const telemetry = getTelemetryService();
|
|
195
|
+
if (options.enable) {
|
|
196
|
+
telemetry.enable();
|
|
197
|
+
console.log(success('Telemetry is on. Appreciate it!'));
|
|
198
|
+
console.log(colors.dim('Data is anonymized and no code/content is transmitted.'));
|
|
199
|
+
newline();
|
|
200
|
+
}
|
|
201
|
+
else if (options.disable) {
|
|
202
|
+
telemetry.disable();
|
|
203
|
+
console.log(success('Telemetry turned off.'));
|
|
204
|
+
newline();
|
|
168
205
|
}
|
|
169
206
|
else {
|
|
170
|
-
console.log(
|
|
207
|
+
console.log(colors.bold('Telemetry Status:'));
|
|
208
|
+
newline();
|
|
209
|
+
console.log(telemetry.isEnabled()
|
|
210
|
+
? success('Enabled (opt-in)')
|
|
211
|
+
: colors.dim('Disabled (set --enable to opt-in)'));
|
|
212
|
+
newline();
|
|
213
|
+
console.log(colors.dim('Telemetry helps us understand usage patterns and improve Codehere.'));
|
|
214
|
+
console.log(colors.dim('All data is anonymized. No code or content is transmitted.'));
|
|
215
|
+
console.log(colors.dim('Enable with: codehere telemetry --enable'));
|
|
171
216
|
newline();
|
|
172
217
|
}
|
|
218
|
+
});
|
|
219
|
+
program
|
|
220
|
+
.command('help')
|
|
221
|
+
.description('Show help for commands')
|
|
222
|
+
.argument('[command]', 'Command name to get help for')
|
|
223
|
+
.option('--all', 'Show all commands (including advanced)')
|
|
224
|
+
.action(async (commandName, options) => {
|
|
225
|
+
if (options?.all && !commandName) {
|
|
226
|
+
// Temporarily unhide all commands and show Commander's built-in help
|
|
227
|
+
for (const cmd of program.commands) {
|
|
228
|
+
cmd._hidden = false;
|
|
229
|
+
}
|
|
230
|
+
program.outputHelp();
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
await executeHelpCommand(commandName);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
program
|
|
237
|
+
.command('index')
|
|
238
|
+
.description('Build embeddings index of the repository')
|
|
239
|
+
.option('-r, --repo <path>', 'Repository path (default: current directory)')
|
|
240
|
+
.action(async (options) => {
|
|
241
|
+
initLogFile();
|
|
242
|
+
// Allow fake AI for testing, or require real API key
|
|
243
|
+
if (!hasAnyApiKey()) {
|
|
244
|
+
requireApiKey();
|
|
245
|
+
}
|
|
173
246
|
try {
|
|
174
|
-
|
|
247
|
+
if (isMinimalStyle()) {
|
|
248
|
+
console.log(colors.cyan('Indexing codebase...'));
|
|
249
|
+
newline();
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
console.log(createBanner('Indexing Repository', 'Building semantic search index'));
|
|
253
|
+
newline();
|
|
254
|
+
}
|
|
255
|
+
const repoPath = options.repo || process.cwd();
|
|
175
256
|
// NEW: Use parallel indexing with caching
|
|
176
257
|
await indexRepositoryParallel(repoPath, {
|
|
177
|
-
useCache:
|
|
178
|
-
maxConcurrency:
|
|
258
|
+
useCache: true,
|
|
259
|
+
maxConcurrency: 5,
|
|
179
260
|
});
|
|
180
|
-
const duration = ((Date.now() - startTime) / 1000).toFixed(2);
|
|
181
|
-
newline();
|
|
182
|
-
console.log(success('✓ Index built successfully'));
|
|
183
|
-
console.log(colors.dim(` Completed in ${duration}s`));
|
|
184
|
-
newline();
|
|
185
|
-
console.log(colors.bold('Next steps:'));
|
|
186
|
-
console.log(colors.cyan(' codehere ask "your question"'));
|
|
187
|
-
console.log(colors.cyan(' codehere "explain the architecture"'));
|
|
188
|
-
newline();
|
|
189
261
|
logEntry({
|
|
190
262
|
timestamp: new Date().toISOString(),
|
|
191
263
|
command: 'index',
|
|
192
264
|
policyStatus: 'allowed',
|
|
193
265
|
});
|
|
266
|
+
newline();
|
|
267
|
+
if (isMinimalStyle()) {
|
|
268
|
+
console.log(success('All indexed. Ready to go.'));
|
|
269
|
+
}
|
|
270
|
+
else {
|
|
271
|
+
console.log(success('All indexed.'));
|
|
272
|
+
}
|
|
273
|
+
process.exit(0);
|
|
194
274
|
}
|
|
195
275
|
catch (err) {
|
|
196
|
-
|
|
276
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
277
|
+
// Check for 401 Unauthorized errors
|
|
278
|
+
if (errorMessage.includes('401') || errorMessage.includes('Unauthorized') || errorMessage.includes('no api key')) {
|
|
279
|
+
newline();
|
|
280
|
+
console.error(error('API key rejected — looks like it might be invalid or expired.'));
|
|
281
|
+
newline();
|
|
282
|
+
console.log(colors.dim(' Check the key is set and still valid:'));
|
|
283
|
+
console.log(colors.cyan(' echo $ANTHROPIC_API_KEY') + colors.dim(' (or whichever provider you\'re using)'));
|
|
284
|
+
console.log(colors.dim(' For testing without API calls: CODEHERE_FAKE_AI=1 codehere index'));
|
|
285
|
+
newline();
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
console.error(error('Error indexing repository:'), errorMessage);
|
|
289
|
+
}
|
|
197
290
|
process.exit(1);
|
|
198
291
|
}
|
|
199
292
|
});
|
|
200
293
|
program
|
|
201
294
|
.command('ask')
|
|
202
|
-
.description('Ask
|
|
203
|
-
.argument('<question>', '
|
|
204
|
-
.
|
|
295
|
+
.description('Ask questions about your codebase using semantic search')
|
|
296
|
+
.argument('<question>', 'The question to ask about your code')
|
|
297
|
+
.alias('q')
|
|
205
298
|
.addHelpText('after', `
|
|
206
299
|
Examples:
|
|
207
300
|
$ codehere ask "How does authentication work?"
|
|
208
|
-
$ codehere ask "Where is the user
|
|
209
|
-
$ codehere
|
|
301
|
+
$ codehere ask "Where is the user login function?"
|
|
302
|
+
$ codehere q "Explain the database schema"
|
|
210
303
|
|
|
211
304
|
This command will:
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
305
|
+
• Search your indexed codebase for relevant code
|
|
306
|
+
• Use AI to generate a contextual answer
|
|
307
|
+
• Show which files were used as context
|
|
215
308
|
|
|
216
|
-
Make sure to run "codehere index" first
|
|
309
|
+
Make sure to run "codehere index" first!
|
|
217
310
|
`)
|
|
218
|
-
.action(async (question
|
|
219
|
-
// Lazy load ALL dependencies inside action handler
|
|
220
|
-
const { initLogFile, logEntry } = await import('./log.js');
|
|
221
|
-
const { executeAskCommand } = await import('./presentation/cli/commands/ask-command.js');
|
|
222
|
-
const { checkProviderConfiguration, displayProviderError } = await import('./utils/provider-check.js');
|
|
311
|
+
.action(async (question) => {
|
|
223
312
|
initLogFile();
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
if (!providerCheck.hasValidProvider) {
|
|
227
|
-
displayProviderError(providerCheck);
|
|
228
|
-
process.exit(1);
|
|
313
|
+
if (!hasAnyApiKey()) {
|
|
314
|
+
requireApiKey();
|
|
229
315
|
}
|
|
230
316
|
try {
|
|
231
|
-
await executeAskCommand(question
|
|
317
|
+
await executeAskCommand(question);
|
|
232
318
|
logEntry({
|
|
233
319
|
timestamp: new Date().toISOString(),
|
|
234
320
|
command: 'ask',
|
|
321
|
+
query: question,
|
|
235
322
|
policyStatus: 'allowed',
|
|
236
323
|
});
|
|
237
324
|
}
|
|
238
325
|
catch (err) {
|
|
239
|
-
const
|
|
240
|
-
|
|
326
|
+
const errMessage = err instanceof Error ? err.message : String(err);
|
|
327
|
+
// If it's a missing embeddings error, exit with 1
|
|
328
|
+
if (errMessage.includes('No embeddings found')) {
|
|
329
|
+
process.exit(1);
|
|
330
|
+
}
|
|
331
|
+
console.error(error('Error:'), errMessage);
|
|
241
332
|
process.exit(1);
|
|
242
333
|
}
|
|
243
334
|
});
|
|
244
|
-
// Additional commands with lazy loading pattern
|
|
245
335
|
program
|
|
246
|
-
.command('
|
|
247
|
-
.description('AI-
|
|
248
|
-
.argument('
|
|
249
|
-
.argument('
|
|
250
|
-
.
|
|
251
|
-
.option('--
|
|
252
|
-
.option('--compare-providers', 'Compare results from multiple providers')
|
|
253
|
-
.option('--dry-run', 'Show proposed changes without applying')
|
|
254
|
-
.option('--show-cost', 'Display cost breakdown per operation')
|
|
336
|
+
.command('fix')
|
|
337
|
+
.description('Apply AI-generated code edits to a file')
|
|
338
|
+
.argument('[file]', 'Path to the file to edit')
|
|
339
|
+
.argument('[instruction]', 'Natural language instruction for the edit')
|
|
340
|
+
.alias('edit')
|
|
341
|
+
.option('--review', 'Enable review & feedback capture (used for trust scoring and Validation Mode)')
|
|
255
342
|
.addHelpText('after', `
|
|
256
343
|
Examples:
|
|
257
|
-
$ codehere
|
|
258
|
-
$ codehere
|
|
259
|
-
$ codehere edit
|
|
260
|
-
$ codehere edit src/config.ts "add new feature" --show-cost
|
|
261
|
-
$ codehere edit src/file.ts "quick fix" --no-verify
|
|
344
|
+
$ codehere fix src/auth.ts "Add error handling for invalid tokens"
|
|
345
|
+
$ codehere fix utils/helpers.js "Rename function foo() to bar()" --review
|
|
346
|
+
$ codehere edit app.js "Add input validation"
|
|
262
347
|
|
|
263
|
-
|
|
264
|
-
•
|
|
265
|
-
•
|
|
266
|
-
•
|
|
267
|
-
•
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
348
|
+
This command will:
|
|
349
|
+
• Generate a unified diff using AI
|
|
350
|
+
• Apply safety policy checks
|
|
351
|
+
• Apply the changes to your file
|
|
352
|
+
• Log the operation for audit
|
|
353
|
+
|
|
354
|
+
Options:
|
|
355
|
+
--review Enable review & feedback capture (used for trust scoring and Validation Mode)
|
|
356
|
+
|
|
357
|
+
Safety policies:
|
|
358
|
+
• Maximum 50 lines changed per edit
|
|
359
|
+
• Cannot edit files in restricted folders (infra/, billing/)
|
|
360
|
+
• Only one file can be edited at a time
|
|
272
361
|
`)
|
|
273
362
|
.action(async (file, instruction, options) => {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
363
|
+
if (!file || !instruction) {
|
|
364
|
+
newline();
|
|
365
|
+
console.log(colors.bold('Usage:') + ' codehere fix <file> "<instruction>"');
|
|
366
|
+
newline();
|
|
367
|
+
console.log('Examples:');
|
|
368
|
+
console.log(colors.cyan(' codehere fix src/auth.ts "add input validation"'));
|
|
369
|
+
console.log(colors.cyan(' codehere fix src/api.js "switch to parameterized queries"'));
|
|
370
|
+
newline();
|
|
281
371
|
process.exit(1);
|
|
282
372
|
}
|
|
373
|
+
initLogFile();
|
|
374
|
+
if (!hasAnyApiKey()) {
|
|
375
|
+
requireApiKey();
|
|
376
|
+
}
|
|
283
377
|
try {
|
|
284
|
-
//
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
378
|
+
// Check if embeddings exist for this repository (skip check if using fake AI for testing)
|
|
379
|
+
if (process.env.CODEHERE_FAKE_AI !== '1') {
|
|
380
|
+
const { container } = await import('./application/services/dependency-container.js');
|
|
381
|
+
const embeddingRepo = container.getEmbeddingRepository(process.cwd());
|
|
382
|
+
const hasEmbeddings = await embeddingRepo.hasEmbeddings();
|
|
383
|
+
if (!hasEmbeddings) {
|
|
384
|
+
newline();
|
|
385
|
+
console.error(colors.red('No embeddings found for this repository.'));
|
|
386
|
+
newline();
|
|
387
|
+
console.log('Run:');
|
|
388
|
+
console.log(colors.cyan(' codehere index'));
|
|
389
|
+
console.log('');
|
|
390
|
+
console.log('then re-run this command.');
|
|
391
|
+
newline();
|
|
392
|
+
process.exit(1);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
await executeFixCommand(file, instruction, { review: options?.review });
|
|
294
396
|
logEntry({
|
|
295
397
|
timestamp: new Date().toISOString(),
|
|
296
|
-
command: '
|
|
398
|
+
command: 'fix',
|
|
399
|
+
query: instruction,
|
|
400
|
+
filepath: file,
|
|
297
401
|
policyStatus: 'allowed',
|
|
298
402
|
});
|
|
299
403
|
}
|
|
300
404
|
catch (err) {
|
|
301
|
-
|
|
405
|
+
displayError(err, {
|
|
406
|
+
operation: 'edit',
|
|
407
|
+
query: instruction,
|
|
408
|
+
filepath: file,
|
|
409
|
+
showSuggestions: true,
|
|
410
|
+
});
|
|
302
411
|
process.exit(1);
|
|
303
412
|
}
|
|
304
413
|
});
|
|
305
414
|
program
|
|
306
|
-
.command('
|
|
307
|
-
.description('AI
|
|
308
|
-
.argument('<file>', '
|
|
309
|
-
.
|
|
310
|
-
.
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
415
|
+
.command('explain')
|
|
416
|
+
.description('Get AI explanation of a code file')
|
|
417
|
+
.argument('<file>', 'Path to the file to explain')
|
|
418
|
+
.alias('e')
|
|
419
|
+
.addHelpText('after', `
|
|
420
|
+
Examples:
|
|
421
|
+
$ codehere explain src/auth.ts
|
|
422
|
+
$ codehere explain utils/helpers.js
|
|
423
|
+
$ codehere e app.js
|
|
424
|
+
|
|
425
|
+
This command will:
|
|
426
|
+
• Read the file content
|
|
427
|
+
• Generate an AI explanation
|
|
428
|
+
• Show file structure, functions, and logic
|
|
429
|
+
`)
|
|
430
|
+
.action(async (file) => {
|
|
315
431
|
initLogFile();
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
displayProviderError(providerCheck);
|
|
319
|
-
process.exit(1);
|
|
432
|
+
if (!hasAnyApiKey()) {
|
|
433
|
+
requireApiKey();
|
|
320
434
|
}
|
|
321
435
|
try {
|
|
322
|
-
|
|
436
|
+
// Check if embeddings exist for this repository (skip check if using fake AI for testing)
|
|
437
|
+
if (process.env.CODEHERE_FAKE_AI !== '1') {
|
|
438
|
+
const { container } = await import('./application/services/dependency-container.js');
|
|
439
|
+
const embeddingRepo = container.getEmbeddingRepository(process.cwd());
|
|
440
|
+
const hasEmbeddings = await embeddingRepo.hasEmbeddings();
|
|
441
|
+
if (!hasEmbeddings) {
|
|
442
|
+
newline();
|
|
443
|
+
console.error(colors.red('No embeddings found for this repository.'));
|
|
444
|
+
newline();
|
|
445
|
+
console.log('Run:');
|
|
446
|
+
console.log(colors.cyan(' codehere index'));
|
|
447
|
+
console.log('');
|
|
448
|
+
console.log('then re-run this command.');
|
|
449
|
+
newline();
|
|
450
|
+
process.exit(1);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
if (isMinimalStyle()) {
|
|
454
|
+
printMinimalHeader('explain', file);
|
|
455
|
+
}
|
|
456
|
+
else {
|
|
457
|
+
console.log(createBanner('Explain File', 'AI-powered code explanation'));
|
|
458
|
+
newline();
|
|
459
|
+
}
|
|
460
|
+
const fullPath = join(process.cwd(), file);
|
|
461
|
+
// Check if file exists
|
|
462
|
+
const { existsSync } = await import('fs');
|
|
463
|
+
if (!existsSync(fullPath)) {
|
|
464
|
+
newline();
|
|
465
|
+
console.error(error(`File not found: ${file}`));
|
|
466
|
+
console.log(info(`Looking for: ${fullPath}`));
|
|
467
|
+
console.log(info('Tip: Use a relative path from your current directory'));
|
|
468
|
+
newline();
|
|
469
|
+
process.exit(1);
|
|
470
|
+
}
|
|
471
|
+
// Use clean architecture
|
|
472
|
+
const { container } = await import('./application/services/dependency-container.js');
|
|
473
|
+
const useCase = container.explainFileUseCase;
|
|
474
|
+
const explainSpinner = createSpinner('Generating explanation...');
|
|
475
|
+
explainSpinner.start();
|
|
476
|
+
const result = await useCase.execute({ filepath: file });
|
|
477
|
+
explainSpinner.stop();
|
|
478
|
+
// File info
|
|
479
|
+
const lines = result.fileContent.split('\n').length;
|
|
480
|
+
const size = (result.fileContent.length / 1024).toFixed(2);
|
|
481
|
+
console.log(colors.bold('File:') + ' ' + formatPath(file));
|
|
482
|
+
console.log(colors.dim(` Lines: ${lines} | Size: ${size} KB`));
|
|
483
|
+
newline();
|
|
484
|
+
// Display explanation with markdown formatting
|
|
485
|
+
sectionHeader('Explanation');
|
|
486
|
+
const { formatMarkdownForTerminal } = await import('./infrastructure/ux/stream-markdown.js');
|
|
487
|
+
console.log(formatMarkdownForTerminal(result.explanation));
|
|
488
|
+
newline();
|
|
323
489
|
logEntry({
|
|
324
490
|
timestamp: new Date().toISOString(),
|
|
325
|
-
command: '
|
|
491
|
+
command: 'explain',
|
|
492
|
+
query: `Explain ${file}`,
|
|
493
|
+
filepath: file,
|
|
326
494
|
policyStatus: 'allowed',
|
|
495
|
+
retrievedFiles: [file],
|
|
327
496
|
});
|
|
328
497
|
}
|
|
329
498
|
catch (err) {
|
|
@@ -331,39 +500,18 @@ program
|
|
|
331
500
|
process.exit(1);
|
|
332
501
|
}
|
|
333
502
|
});
|
|
334
|
-
program
|
|
335
|
-
.command('explain')
|
|
336
|
-
.description('Explain code or architecture in detail')
|
|
337
|
-
.argument('<path>', 'File or directory to explain')
|
|
338
|
-
.option('--depth <n>', 'Depth of explanation (1-3)', '2')
|
|
339
|
-
.action(async (path, options) => {
|
|
340
|
-
const { initLogFile } = await import('./log.js');
|
|
341
|
-
const { executeAskCommand } = await import('./presentation/cli/commands/ask-command.js');
|
|
342
|
-
const { checkProviderConfiguration, displayProviderError } = await import('./utils/provider-check.js');
|
|
343
|
-
initLogFile();
|
|
344
|
-
const providerCheck = checkProviderConfiguration();
|
|
345
|
-
if (!providerCheck.hasValidProvider) {
|
|
346
|
-
displayProviderError(providerCheck);
|
|
347
|
-
process.exit(1);
|
|
348
|
-
}
|
|
349
|
-
const depth = parseInt(options.depth, 10);
|
|
350
|
-
const question = `Explain ${path} in detail (depth: ${depth})`;
|
|
351
|
-
await executeAskCommand(question, { quick: false });
|
|
352
|
-
});
|
|
353
503
|
program
|
|
354
504
|
.command('health')
|
|
355
505
|
.description('Check system health and metrics')
|
|
356
506
|
.option('-m, --metrics', 'Show detailed metrics')
|
|
357
|
-
.action(
|
|
358
|
-
// Lazy load to avoid WASM hang on startup
|
|
359
|
-
const { performHealthCheck, formatHealthStatus, getMetrics } = await import('./monitoring.js');
|
|
507
|
+
.action((options) => {
|
|
360
508
|
const health = performHealthCheck();
|
|
361
509
|
if (isMinimalStyle()) {
|
|
362
510
|
printMinimalHeader('health', '');
|
|
363
511
|
}
|
|
364
512
|
else {
|
|
365
513
|
newline();
|
|
366
|
-
console.log(createBanner('System Health', '
|
|
514
|
+
console.log(createBanner('System Health', 'Quick status check'));
|
|
367
515
|
newline();
|
|
368
516
|
}
|
|
369
517
|
console.log(formatHealthStatus(health));
|
|
@@ -371,67 +519,45 @@ program
|
|
|
371
519
|
newline();
|
|
372
520
|
sectionHeader('Metrics');
|
|
373
521
|
const metrics = getMetrics();
|
|
374
|
-
|
|
522
|
+
const metricsTable = createTable(['Metric', 'Value'], [
|
|
523
|
+
['Total Operations', formatNumber(metrics.operations.total)],
|
|
524
|
+
['Successful', formatNumber(metrics.operations.successful)],
|
|
525
|
+
['Failed', formatNumber(metrics.operations.failed)],
|
|
526
|
+
['Retries', formatNumber(metrics.operations.retries)],
|
|
527
|
+
['Avg Response Time', `${metrics.performance.avgResponseTime.toFixed(2)}ms`],
|
|
528
|
+
['API Calls', formatNumber(metrics.performance.apiCalls)],
|
|
529
|
+
['Cache Hits', formatNumber(metrics.performance.cacheHits)],
|
|
530
|
+
]);
|
|
531
|
+
console.log(metricsTable.toString());
|
|
532
|
+
if (Object.keys(metrics.errors.byType).length > 0) {
|
|
533
|
+
newline();
|
|
534
|
+
sectionHeader('Error Summary');
|
|
535
|
+
const errorTable = createTable(['Error Type', 'Count'], Object.entries(metrics.errors.byType).map(([type, count]) => [
|
|
536
|
+
type,
|
|
537
|
+
formatNumber(count),
|
|
538
|
+
]));
|
|
539
|
+
console.log(errorTable.toString());
|
|
540
|
+
}
|
|
375
541
|
}
|
|
376
542
|
newline();
|
|
377
|
-
|
|
378
|
-
program
|
|
379
|
-
.command('plan')
|
|
380
|
-
.description('Plan and break down complex coding tasks')
|
|
381
|
-
.argument('<goal>', 'Goal or task to plan')
|
|
382
|
-
.option('--review', 'Enable review mode for plan validation')
|
|
383
|
-
.action(async (goal, options) => {
|
|
384
|
-
const { initLogFile } = await import('./log.js');
|
|
385
|
-
const { executePlanCommand } = await import('./presentation/cli/commands/plan-command.js');
|
|
386
|
-
const { checkProviderConfiguration, displayProviderError } = await import('./utils/provider-check.js');
|
|
387
|
-
initLogFile();
|
|
388
|
-
const providerCheck = checkProviderConfiguration();
|
|
389
|
-
if (!providerCheck.hasValidProvider) {
|
|
390
|
-
displayProviderError(providerCheck);
|
|
391
|
-
process.exit(1);
|
|
392
|
-
}
|
|
393
|
-
await executePlanCommand(goal, { review: options.review || false });
|
|
394
|
-
});
|
|
395
|
-
program
|
|
396
|
-
.command('orchestrate')
|
|
397
|
-
.description('Multi-agent orchestration for complex projects')
|
|
398
|
-
.argument('<goal>', 'Project goal')
|
|
399
|
-
.option('--agents <n>', 'Number of agents', '3')
|
|
400
|
-
.option('--review', 'Enable review & feedback capture (used for trust scoring and Validation Mode)')
|
|
401
|
-
.action(async (goal, options) => {
|
|
402
|
-
const { initLogFile } = await import('./log.js');
|
|
403
|
-
const { executeOrchestrateCommand } = await import('./presentation/cli/commands/orchestrate-command.js');
|
|
404
|
-
const { checkProviderConfiguration, displayProviderError } = await import('./utils/provider-check.js');
|
|
405
|
-
initLogFile();
|
|
406
|
-
const providerCheck = checkProviderConfiguration();
|
|
407
|
-
if (!providerCheck.hasValidProvider) {
|
|
408
|
-
displayProviderError(providerCheck);
|
|
543
|
+
if (health.status === 'unhealthy') {
|
|
409
544
|
process.exit(1);
|
|
410
545
|
}
|
|
411
|
-
await executeOrchestrateCommand(goal, {
|
|
412
|
-
review: options.review || false,
|
|
413
|
-
});
|
|
414
546
|
});
|
|
415
|
-
// Remaining commands follow the same lazy loading pattern
|
|
416
547
|
program
|
|
417
548
|
.command('refactor')
|
|
418
|
-
.description('
|
|
419
|
-
.argument('<pattern>', 'File pattern (e.g., src/**/*.ts or
|
|
549
|
+
.description('Refactor multiple files with coordinated changes')
|
|
550
|
+
.argument('<pattern>', 'File pattern (e.g., "src/**/*.ts") or comma-separated files')
|
|
420
551
|
.argument('<instruction>', 'Refactoring instruction')
|
|
421
|
-
.option('--
|
|
422
|
-
.option('--
|
|
552
|
+
.option('--dry-run', 'Show changes without applying')
|
|
553
|
+
.option('--max-files <number>', 'Maximum files to process', '10')
|
|
423
554
|
.action(async (pattern, instruction, options) => {
|
|
424
|
-
const { initLogFile } = await import('./log.js');
|
|
425
|
-
const { checkProviderConfiguration, displayProviderError } = await import('./utils/provider-check.js');
|
|
426
|
-
const { refactorMultiFile, findFilesByPattern } = await import('./refactor.js');
|
|
427
555
|
initLogFile();
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
displayProviderError(providerCheck);
|
|
431
|
-
process.exit(1);
|
|
556
|
+
if (!hasAnyApiKey()) {
|
|
557
|
+
requireApiKey();
|
|
432
558
|
}
|
|
433
559
|
try {
|
|
434
|
-
console.log(createBanner('Multi-File Refactor', '
|
|
560
|
+
console.log(createBanner('Multi-File Refactor', 'Coordinated changes across files'));
|
|
435
561
|
newline();
|
|
436
562
|
// Parse files from pattern
|
|
437
563
|
let files;
|
|
@@ -456,34 +582,948 @@ program
|
|
|
456
582
|
const maxFiles = parseInt(options.maxFiles || '10', 10);
|
|
457
583
|
const result = await refactorMultiFile(files.slice(0, maxFiles), instruction, {
|
|
458
584
|
dryRun: options.dryRun || false,
|
|
585
|
+
maxFiles,
|
|
586
|
+
});
|
|
587
|
+
// Display results
|
|
588
|
+
sectionHeader('Refactoring Results');
|
|
589
|
+
const resultsTable = createTable(['Metric', 'Value'], [
|
|
590
|
+
['Files Processed', formatNumber(files.length)],
|
|
591
|
+
['Files Changed', formatNumber(result.filesChanged.length)],
|
|
592
|
+
['Total Lines Added', formatNumber(result.totalChanges.linesAdded)],
|
|
593
|
+
['Total Lines Removed', formatNumber(result.totalChanges.linesRemoved)],
|
|
594
|
+
['Errors', formatNumber(result.errors.length)],
|
|
595
|
+
]);
|
|
596
|
+
console.log(resultsTable.toString());
|
|
597
|
+
if (result.errors.length > 0) {
|
|
598
|
+
newline();
|
|
599
|
+
sectionHeader('Errors');
|
|
600
|
+
result.errors.forEach(err => {
|
|
601
|
+
console.log(error(`${err.file}: ${err.error}`));
|
|
602
|
+
});
|
|
603
|
+
}
|
|
604
|
+
if (result.filesChanged.length > 0) {
|
|
605
|
+
newline();
|
|
606
|
+
console.log(success(options.dryRun ? 'Refactor planned.' : 'Refactoring done.'));
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
catch (err) {
|
|
610
|
+
console.error(error('Error:'), err instanceof Error ? err.message : String(err));
|
|
611
|
+
process.exit(1);
|
|
612
|
+
}
|
|
613
|
+
});
|
|
614
|
+
program
|
|
615
|
+
.command('git-review')
|
|
616
|
+
.description('Review git changes and suggest improvements')
|
|
617
|
+
.option('-f, --file <file>', 'Review specific file')
|
|
618
|
+
.action((options) => {
|
|
619
|
+
initLogFile();
|
|
620
|
+
try {
|
|
621
|
+
console.log(createBanner('Git Review', 'Git-aware code analysis'));
|
|
622
|
+
newline();
|
|
623
|
+
const status = getGitStatus();
|
|
624
|
+
if (!status.isRepo) {
|
|
625
|
+
console.log(warning('Not a git repository'));
|
|
626
|
+
return;
|
|
627
|
+
}
|
|
628
|
+
console.log(formatGitStatus(status));
|
|
629
|
+
newline();
|
|
630
|
+
if (!status.hasChanges) {
|
|
631
|
+
console.log(info('No changes to review'));
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
// Get diffs
|
|
635
|
+
const diffs = options.file
|
|
636
|
+
? (() => {
|
|
637
|
+
const diff = getGitDiff(options.file);
|
|
638
|
+
return diff ? new Map([[options.file, diff]]) : new Map();
|
|
639
|
+
})()
|
|
640
|
+
: getAllGitDiffs();
|
|
641
|
+
if (diffs.size === 0) {
|
|
642
|
+
console.log(info('No diffs found'));
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
sectionHeader('Change Analysis');
|
|
646
|
+
for (const [file, diff] of diffs.entries()) {
|
|
647
|
+
const analysis = analyzeDiff(diff);
|
|
648
|
+
console.log(colors.bold(file));
|
|
649
|
+
console.log(colors.dim(` ${analysis.summary}`));
|
|
650
|
+
console.log(colors.dim(` Risk: ${analysis.riskLevel.toUpperCase()}`));
|
|
651
|
+
if (analysis.suggestions.length > 0) {
|
|
652
|
+
console.log(colors.yellow(' Suggestions:'));
|
|
653
|
+
analysis.suggestions.forEach(s => {
|
|
654
|
+
console.log(colors.yellow(` - ${s}`));
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
newline();
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
catch (err) {
|
|
661
|
+
console.error(error('Error:'), err instanceof Error ? err.message : String(err));
|
|
662
|
+
process.exit(1);
|
|
663
|
+
}
|
|
664
|
+
});
|
|
665
|
+
program
|
|
666
|
+
.command('plan')
|
|
667
|
+
.description('Plan a complex multi-step task')
|
|
668
|
+
.argument('<instruction>', 'Complex instruction to plan')
|
|
669
|
+
.option('-e, --execute', 'Execute the plan after creating it')
|
|
670
|
+
.option('--review', 'Enable review & feedback capture (used for trust scoring and Validation Mode)')
|
|
671
|
+
.action(async (instruction, options) => {
|
|
672
|
+
initLogFile();
|
|
673
|
+
if (!hasAnyApiKey()) {
|
|
674
|
+
requireApiKey();
|
|
675
|
+
}
|
|
676
|
+
try {
|
|
677
|
+
if (isMinimalStyle()) {
|
|
678
|
+
printMinimalHeader('plan', instruction);
|
|
679
|
+
}
|
|
680
|
+
else {
|
|
681
|
+
console.log(createBanner('Task Planning', 'Intelligent multi-step execution'));
|
|
682
|
+
newline();
|
|
683
|
+
console.log(colors.bold('Instruction:') + ' ' + colors.cyan(instruction));
|
|
684
|
+
}
|
|
685
|
+
newline();
|
|
686
|
+
// Use new memory-based planning
|
|
687
|
+
await executePlanCommand(instruction, { execute: options.execute, review: options.review });
|
|
688
|
+
}
|
|
689
|
+
catch (err) {
|
|
690
|
+
console.error(error('Error:'), err instanceof Error ? err.message : String(err));
|
|
691
|
+
process.exit(1);
|
|
692
|
+
}
|
|
693
|
+
});
|
|
694
|
+
program
|
|
695
|
+
.command('decision')
|
|
696
|
+
.description('Record and query architectural/design decisions')
|
|
697
|
+
.argument('<action>', 'Action: record, list, query, or explain')
|
|
698
|
+
.argument('[args...]', 'Arguments for the action')
|
|
699
|
+
.option('-c, --codebase <path>', 'Codebase path (default: current directory)')
|
|
700
|
+
.option('-t, --type <type>', 'Decision type filter (for list)')
|
|
701
|
+
.option('-l, --limit <number>', 'Limit number of results', '10')
|
|
702
|
+
.action(async (action, args, options) => {
|
|
703
|
+
initLogFile();
|
|
704
|
+
try {
|
|
705
|
+
await executeDecisionCommand(action, args, {
|
|
706
|
+
codebase: options.codebase,
|
|
707
|
+
type: options.type,
|
|
708
|
+
limit: options.limit ? parseInt(options.limit, 10) : undefined,
|
|
709
|
+
});
|
|
710
|
+
}
|
|
711
|
+
catch (err) {
|
|
712
|
+
console.error(error('Error:'), err instanceof Error ? err.message : String(err));
|
|
713
|
+
process.exit(1);
|
|
714
|
+
}
|
|
715
|
+
});
|
|
716
|
+
program
|
|
717
|
+
.command('knowledge')
|
|
718
|
+
.description('Query and manage preserved knowledge from codebase')
|
|
719
|
+
.argument('<action>', 'Action: query, list, summary, or extract')
|
|
720
|
+
.argument('[args...]', 'Arguments for the action')
|
|
721
|
+
.option('-c, --codebase <path>', 'Codebase path (default: current directory)')
|
|
722
|
+
.option('-t, --type <type>', 'Knowledge type filter (for list)')
|
|
723
|
+
.option('--tags <tags>', 'Comma-separated tags (for list)')
|
|
724
|
+
.option('-l, --limit <number>', 'Limit number of results', '10')
|
|
725
|
+
.action(async (action, args, options) => {
|
|
726
|
+
initLogFile();
|
|
727
|
+
try {
|
|
728
|
+
await executeKnowledgeCommand(action, args, {
|
|
729
|
+
codebase: options.codebase,
|
|
730
|
+
type: options.type,
|
|
731
|
+
tags: options.tags ? options.tags.split(',') : undefined,
|
|
732
|
+
limit: options.limit ? parseInt(options.limit, 10) : undefined,
|
|
459
733
|
});
|
|
734
|
+
}
|
|
735
|
+
catch (err) {
|
|
736
|
+
console.error(error('Error:'), err instanceof Error ? err.message : String(err));
|
|
737
|
+
process.exit(1);
|
|
738
|
+
}
|
|
739
|
+
});
|
|
740
|
+
program
|
|
741
|
+
.command('learning')
|
|
742
|
+
.description('Learning dashboard - View patterns, knowledge, and insights')
|
|
743
|
+
.argument('<action>', 'Action: overview, patterns, knowledge, or insights')
|
|
744
|
+
.option('-c, --codebase <path>', 'Codebase path (default: current directory)')
|
|
745
|
+
.action(async (action, options) => {
|
|
746
|
+
initLogFile();
|
|
747
|
+
try {
|
|
748
|
+
await executeLearningDashboardCommand(action, options.codebase);
|
|
749
|
+
}
|
|
750
|
+
catch (err) {
|
|
751
|
+
console.error(error('Error:'), err instanceof Error ? err.message : String(err));
|
|
752
|
+
process.exit(1);
|
|
753
|
+
}
|
|
754
|
+
});
|
|
755
|
+
program
|
|
756
|
+
.command('review-file')
|
|
757
|
+
.description('Automated code review for a file')
|
|
758
|
+
.argument('<file>', 'File to review')
|
|
759
|
+
.action(async (file) => {
|
|
760
|
+
initLogFile();
|
|
761
|
+
if (!hasAnyApiKey()) {
|
|
762
|
+
requireApiKey();
|
|
763
|
+
}
|
|
764
|
+
try {
|
|
765
|
+
if (isMinimalStyle()) {
|
|
766
|
+
console.log(colors.bold(`Review: ${file}`));
|
|
767
|
+
newline();
|
|
768
|
+
}
|
|
769
|
+
else {
|
|
770
|
+
console.log(createBanner('Code Review', 'Automated senior-level analysis'));
|
|
771
|
+
newline();
|
|
772
|
+
}
|
|
773
|
+
const reviewSpinner = createSpinner('Reviewing code...');
|
|
774
|
+
reviewSpinner.start();
|
|
775
|
+
const review = await reviewFile(file);
|
|
776
|
+
reviewSpinner.stop();
|
|
777
|
+
newline();
|
|
778
|
+
if (isMinimalStyle()) {
|
|
779
|
+
console.log(colors.bold('Findings:'));
|
|
780
|
+
console.log(formatReview(review));
|
|
781
|
+
newline();
|
|
782
|
+
console.log(colors.dim(`Score: ${review.score}/100`));
|
|
783
|
+
}
|
|
784
|
+
else {
|
|
785
|
+
console.log(formatReview(review));
|
|
786
|
+
// Display score
|
|
787
|
+
newline();
|
|
788
|
+
sectionHeader('Review Score');
|
|
789
|
+
const scoreTable = createTable(['Metric', 'Value'], [
|
|
790
|
+
['Overall Score', `${review.score}/100`],
|
|
791
|
+
['Errors', formatNumber(review.issues.filter(i => i.severity === 'error').length)],
|
|
792
|
+
['Warnings', formatNumber(review.issues.filter(i => i.severity === 'warning').length)],
|
|
793
|
+
['Info', formatNumber(review.issues.filter(i => i.severity === 'info').length)],
|
|
794
|
+
]);
|
|
795
|
+
console.log(scoreTable.toString());
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
catch (err) {
|
|
799
|
+
console.error(error('Error:'), err instanceof Error ? err.message : String(err));
|
|
800
|
+
process.exit(1);
|
|
801
|
+
}
|
|
802
|
+
});
|
|
803
|
+
program
|
|
804
|
+
.command('learn')
|
|
805
|
+
.description('Show learning insights and performance recommendations')
|
|
806
|
+
.action(() => {
|
|
807
|
+
try {
|
|
808
|
+
console.log(createBanner('Learning Insights', 'What we\'ve learned from your codebase'));
|
|
809
|
+
newline();
|
|
810
|
+
const insights = formatLearningInsights();
|
|
811
|
+
console.log(insights);
|
|
812
|
+
const perfInsights = getPerformanceInsights();
|
|
813
|
+
if (perfInsights.recommendations.length > 0) {
|
|
814
|
+
sectionHeader('Performance Recommendations');
|
|
815
|
+
perfInsights.recommendations.forEach(rec => {
|
|
816
|
+
console.log(info(rec));
|
|
817
|
+
});
|
|
818
|
+
}
|
|
819
|
+
const cacheStats = getCacheStats();
|
|
460
820
|
newline();
|
|
461
|
-
|
|
462
|
-
|
|
821
|
+
sectionHeader('Cache Statistics');
|
|
822
|
+
const cacheTable = createTable(['Metric', 'Value'], [
|
|
823
|
+
['Memory Cache', `${cacheStats.memorySize}/${cacheStats.memoryMaxSize}`],
|
|
824
|
+
['File Cache', formatNumber(cacheStats.fileCacheCount)],
|
|
825
|
+
]);
|
|
826
|
+
console.log(cacheTable.toString());
|
|
463
827
|
}
|
|
464
828
|
catch (err) {
|
|
465
829
|
console.error(error('Error:'), err instanceof Error ? err.message : String(err));
|
|
466
830
|
process.exit(1);
|
|
467
831
|
}
|
|
468
832
|
});
|
|
833
|
+
program
|
|
834
|
+
.command('cache')
|
|
835
|
+
.description('Manage cache')
|
|
836
|
+
.option('--clear', 'Clear all caches')
|
|
837
|
+
.option('--stats', 'Show cache statistics')
|
|
838
|
+
.action((options) => {
|
|
839
|
+
if (options.clear) {
|
|
840
|
+
clearAllCaches();
|
|
841
|
+
console.log(success('All caches cleared'));
|
|
842
|
+
}
|
|
843
|
+
else if (options.stats) {
|
|
844
|
+
const stats = getCacheStats();
|
|
845
|
+
sectionHeader('Cache Statistics');
|
|
846
|
+
const cacheTable = createTable(['Metric', 'Value'], [
|
|
847
|
+
['Memory Cache', `${stats.memorySize}/${stats.memoryMaxSize}`],
|
|
848
|
+
['File Cache', formatNumber(stats.fileCacheCount)],
|
|
849
|
+
]);
|
|
850
|
+
console.log(cacheTable.toString());
|
|
851
|
+
}
|
|
852
|
+
else {
|
|
853
|
+
console.log(info('Use --clear to clear caches or --stats to show statistics'));
|
|
854
|
+
}
|
|
855
|
+
});
|
|
856
|
+
program
|
|
857
|
+
.command('migrate')
|
|
858
|
+
.description('Plan and execute framework migrations')
|
|
859
|
+
.argument('<from>', 'Source framework/version')
|
|
860
|
+
.argument('<to>', 'Target framework/version')
|
|
861
|
+
.option('-f, --files <files...>', 'Specific files to migrate')
|
|
862
|
+
.option('--plan-only', 'Only show migration plan, do not execute')
|
|
863
|
+
.action(async (from, to, options) => {
|
|
864
|
+
initLogFile();
|
|
865
|
+
if (!hasAnyApiKey()) {
|
|
866
|
+
requireApiKey();
|
|
867
|
+
}
|
|
868
|
+
try {
|
|
869
|
+
console.log(createBanner('Migration Assistant', `From ${from} to ${to}`));
|
|
870
|
+
newline();
|
|
871
|
+
const plan = await planMigration(from, to, options.files);
|
|
872
|
+
sectionHeader('Migration Plan');
|
|
873
|
+
console.log(formatMigrationPlan(plan));
|
|
874
|
+
if (!options.planOnly) {
|
|
875
|
+
newline();
|
|
876
|
+
console.log(info('Migration execution coming soon...'));
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
catch (err) {
|
|
880
|
+
console.error(error('Error:'), err instanceof Error ? err.message : String(err));
|
|
881
|
+
process.exit(1);
|
|
882
|
+
}
|
|
883
|
+
});
|
|
884
|
+
// DocumentationAgent-based docs command
|
|
885
|
+
program
|
|
886
|
+
.command('docs')
|
|
887
|
+
.description('Generate documentation using DocumentationAgent')
|
|
888
|
+
.argument('<generate>', 'Command: generate')
|
|
889
|
+
.argument('<type>', 'Documentation type: readme, api, or all')
|
|
890
|
+
.option('--target <dir>', 'Target directory for API docs (default: src)')
|
|
891
|
+
.option('--update-existing', 'Update existing documentation files')
|
|
892
|
+
.option('--output <path>', 'Output path for generated docs')
|
|
893
|
+
.option('--review', 'Enable review & feedback capture (used for trust scoring and Validation Mode)')
|
|
894
|
+
.addHelpText('after', `
|
|
895
|
+
Examples:
|
|
896
|
+
$ codehere docs generate readme
|
|
897
|
+
$ codehere docs generate api --target src
|
|
898
|
+
$ codehere docs generate all --update-existing
|
|
899
|
+
$ codehere docs generate readme --review
|
|
900
|
+
|
|
901
|
+
Warning: This command may modify README.md and docs/api.md files.
|
|
902
|
+
`)
|
|
903
|
+
.action(async (cmd, type, options) => {
|
|
904
|
+
if (cmd !== 'generate') {
|
|
905
|
+
console.error(error(`Unknown command: ${cmd}. Use 'generate' to create documentation.`));
|
|
906
|
+
process.exit(1);
|
|
907
|
+
}
|
|
908
|
+
if (!hasAnyApiKey()) {
|
|
909
|
+
requireApiKey();
|
|
910
|
+
}
|
|
911
|
+
initLogFile();
|
|
912
|
+
await executeDocsCommand(type, {
|
|
913
|
+
target: options.target,
|
|
914
|
+
updateExisting: options.updateExisting,
|
|
915
|
+
outputPath: options.output,
|
|
916
|
+
review: Boolean(options.review),
|
|
917
|
+
});
|
|
918
|
+
});
|
|
919
|
+
// Product brain command — project context for context-aware recommendations
|
|
920
|
+
program
|
|
921
|
+
.command('product')
|
|
922
|
+
.description('Set up product brain — helps trust and report give context-aware recommendations')
|
|
923
|
+
.argument('[subcommand]', 'init | show | set | spec', 'show')
|
|
924
|
+
.argument('[goal]', 'Goal or description (used with spec subcommand)')
|
|
925
|
+
.option('--risk <level>', 'Set risk level: low, medium, high, critical')
|
|
926
|
+
.option('--name <name>', 'Update project name')
|
|
927
|
+
.option('--production', 'Mark as production app')
|
|
928
|
+
.option('--force', 'Re-run init even if already configured')
|
|
929
|
+
.addHelpText('after', `
|
|
930
|
+
Examples:
|
|
931
|
+
$ codehere product init # interactive setup (2 minutes)
|
|
932
|
+
$ codehere product show # display current config
|
|
933
|
+
$ codehere product set --risk high
|
|
934
|
+
`)
|
|
935
|
+
.action(async (subcommand, goal, options) => {
|
|
936
|
+
await executeProductCommand(subcommand, {
|
|
937
|
+
risk: options.risk,
|
|
938
|
+
production: options.production,
|
|
939
|
+
name: goal || options.name,
|
|
940
|
+
force: options.force,
|
|
941
|
+
});
|
|
942
|
+
});
|
|
943
|
+
// Status command
|
|
944
|
+
program
|
|
945
|
+
.command('status')
|
|
946
|
+
.description('Security dashboard — hook activity, blocked calls, cost routing')
|
|
947
|
+
.option('--json', 'Machine-readable JSON')
|
|
948
|
+
.option('--tasks', 'Show recent tasks (experimental)')
|
|
949
|
+
.option('--sessions', 'Show per-session audit trail (multi-agent analysis)')
|
|
950
|
+
.option('--session <id>', 'Drill into a specific session (first 8+ chars of session ID)')
|
|
951
|
+
.option('--trust', 'Include a quick trust scan of the current directory')
|
|
952
|
+
.option('--env', 'Show environment details')
|
|
953
|
+
.option('--track', 'Show command success rates')
|
|
954
|
+
.addHelpText('after', `
|
|
955
|
+
Examples:
|
|
956
|
+
$ codehere status # full dashboard
|
|
957
|
+
$ codehere status --sessions # show per-session breakdown
|
|
958
|
+
$ codehere status --session abc12345 # drill into a specific session
|
|
959
|
+
$ codehere status --json # machine-readable output
|
|
960
|
+
`)
|
|
961
|
+
.action(async (options) => {
|
|
962
|
+
await executeStatusCommand({
|
|
963
|
+
json: Boolean(options.json),
|
|
964
|
+
tasks: Boolean(options.tasks),
|
|
965
|
+
sessions: Boolean(options.sessions),
|
|
966
|
+
session: options.session,
|
|
967
|
+
trust: Boolean(options.trust),
|
|
968
|
+
env: Boolean(options.env),
|
|
969
|
+
track: Boolean(options.track),
|
|
970
|
+
});
|
|
971
|
+
});
|
|
469
972
|
// Suggest command - Read-only assistant mode
|
|
470
973
|
program
|
|
471
974
|
.command('suggest')
|
|
472
975
|
.description('Read-only assistant mode - ask questions and get explanations without making changes')
|
|
473
|
-
.argument('<
|
|
474
|
-
.option('
|
|
475
|
-
.
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
976
|
+
.argument('<query>', 'The question or request')
|
|
977
|
+
.option('--file <file>', 'Focus on a specific file')
|
|
978
|
+
.addHelpText('after', `
|
|
979
|
+
Examples:
|
|
980
|
+
$ codehere suggest "How does authentication work?"
|
|
981
|
+
$ codehere suggest "Explain this function" --file src/auth.ts
|
|
982
|
+
|
|
983
|
+
This command:
|
|
984
|
+
• Searches your codebase for relevant code
|
|
985
|
+
• Provides contextual answers and explanations
|
|
986
|
+
• Does NOT make any changes (read-only mode)
|
|
987
|
+
• Creates a task record for tracking
|
|
988
|
+
`)
|
|
989
|
+
.action(async (query, options) => {
|
|
990
|
+
initLogFile();
|
|
991
|
+
if (!hasAnyApiKey()) {
|
|
992
|
+
requireApiKey();
|
|
993
|
+
}
|
|
994
|
+
try {
|
|
995
|
+
await executeSuggestCommand(query, {
|
|
996
|
+
file: options.file,
|
|
997
|
+
stream: false,
|
|
998
|
+
});
|
|
999
|
+
logEntry({
|
|
1000
|
+
timestamp: new Date().toISOString(),
|
|
1001
|
+
command: 'suggest',
|
|
1002
|
+
query,
|
|
1003
|
+
policyStatus: 'allowed',
|
|
1004
|
+
});
|
|
1005
|
+
}
|
|
1006
|
+
catch (err) {
|
|
1007
|
+
const errMessage = err instanceof Error ? err.message : String(err);
|
|
1008
|
+
// If it's a missing embeddings error, exit with 1 (message already shown)
|
|
1009
|
+
if (errMessage.includes('No embeddings found')) {
|
|
1010
|
+
process.exit(1);
|
|
1011
|
+
}
|
|
1012
|
+
console.error(error('Error:'), errMessage);
|
|
1013
|
+
process.exit(1);
|
|
1014
|
+
}
|
|
1015
|
+
});
|
|
1016
|
+
// Run command - Unified agentic execution
|
|
1017
|
+
program
|
|
1018
|
+
.command('run')
|
|
1019
|
+
.description('Unified agentic execution - execute a task or goal')
|
|
1020
|
+
.argument('<goal>', 'The goal to execute')
|
|
1021
|
+
.option('--task-id <id>', 'Continue execution of an existing task')
|
|
1022
|
+
.option('--file <file>', 'Focus on a specific file')
|
|
1023
|
+
.option('--files <files>', 'Comma-separated list of files to process')
|
|
1024
|
+
.option('--review', 'Enable review before applying changes')
|
|
1025
|
+
.addHelpText('after', `
|
|
1026
|
+
Examples:
|
|
1027
|
+
$ codehere run "Add error handling to the login function"
|
|
1028
|
+
$ codehere run "Refactor authentication module" --file src/auth.ts
|
|
1029
|
+
$ codehere run "Fix bug in payment processing" --task-id task-12345
|
|
1030
|
+
|
|
1031
|
+
This command:
|
|
1032
|
+
• Creates a plan for the goal
|
|
1033
|
+
• Executes the plan step-by-step
|
|
1034
|
+
• Creates/updates task records for tracking
|
|
1035
|
+
• Shows risk tier and environment mode (advisory)
|
|
1036
|
+
`)
|
|
1037
|
+
.action(async (goal, options) => {
|
|
1038
|
+
initLogFile();
|
|
1039
|
+
if (!hasAnyApiKey()) {
|
|
1040
|
+
requireApiKey();
|
|
1041
|
+
}
|
|
1042
|
+
try {
|
|
1043
|
+
const files = options.files ? options.files.split(',').map((f) => f.trim()) : undefined;
|
|
1044
|
+
await executeRunCommand(goal, {
|
|
1045
|
+
taskId: options.taskId,
|
|
1046
|
+
file: options.file,
|
|
1047
|
+
files,
|
|
1048
|
+
review: Boolean(options.review),
|
|
1049
|
+
});
|
|
1050
|
+
logEntry({
|
|
1051
|
+
timestamp: new Date().toISOString(),
|
|
1052
|
+
command: 'run',
|
|
1053
|
+
query: goal,
|
|
1054
|
+
policyStatus: 'allowed',
|
|
1055
|
+
});
|
|
1056
|
+
}
|
|
1057
|
+
catch (err) {
|
|
1058
|
+
console.error(error('Error:'), err instanceof Error ? err.message : String(err));
|
|
1059
|
+
process.exit(1);
|
|
1060
|
+
}
|
|
1061
|
+
});
|
|
1062
|
+
// Review command - Task review interface
|
|
1063
|
+
program
|
|
1064
|
+
.command('review')
|
|
1065
|
+
.description('Review and approve/reject tasks')
|
|
1066
|
+
.argument('[task-id]', 'Task ID to review (omit to list tasks)')
|
|
1067
|
+
.option('--list', 'List tasks needing review')
|
|
1068
|
+
.option('--approve', 'Approve the task')
|
|
1069
|
+
.option('--reject', 'Reject the task')
|
|
1070
|
+
.option('--comment <text>', 'Add a comment to the review')
|
|
1071
|
+
.option('--all', 'Show all completed tasks in list mode')
|
|
1072
|
+
.addHelpText('after', `
|
|
1073
|
+
Examples:
|
|
1074
|
+
$ codehere review --list
|
|
1075
|
+
$ codehere review task-12345
|
|
1076
|
+
$ codehere review task-12345 --approve
|
|
1077
|
+
$ codehere review task-12345 --reject --comment "Security concerns"
|
|
1078
|
+
|
|
1079
|
+
This command:
|
|
1080
|
+
• Lists tasks that need review
|
|
1081
|
+
• Shows task details (files changed, risk tier, etc.)
|
|
1082
|
+
• Allows approving or rejecting tasks
|
|
1083
|
+
• Updates task status and review records
|
|
1084
|
+
`)
|
|
1085
|
+
.action(async (taskId, options) => {
|
|
1086
|
+
initLogFile();
|
|
1087
|
+
try {
|
|
1088
|
+
await executeReviewCommand(taskId, {
|
|
1089
|
+
list: Boolean(options.list),
|
|
1090
|
+
approve: Boolean(options.approve),
|
|
1091
|
+
reject: Boolean(options.reject),
|
|
1092
|
+
comment: options.comment,
|
|
1093
|
+
all: Boolean(options.all),
|
|
1094
|
+
});
|
|
1095
|
+
logEntry({
|
|
1096
|
+
timestamp: new Date().toISOString(),
|
|
1097
|
+
command: 'review',
|
|
1098
|
+
query: taskId,
|
|
1099
|
+
policyStatus: 'allowed',
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1102
|
+
catch (err) {
|
|
1103
|
+
console.error(error('Error:'), err instanceof Error ? err.message : String(err));
|
|
1104
|
+
process.exit(1);
|
|
1105
|
+
}
|
|
1106
|
+
});
|
|
1107
|
+
program
|
|
1108
|
+
.command('test')
|
|
1109
|
+
.description('Generate tests for code')
|
|
1110
|
+
.argument('<file>', 'File to generate tests for')
|
|
1111
|
+
.option('--framework <framework>', 'Test framework (jest, pytest, etc.)')
|
|
1112
|
+
.option('--coverage <type>', 'Coverage type (unit, integration, both)', 'unit')
|
|
1113
|
+
.option('--improve', 'Improve existing test file')
|
|
1114
|
+
.option('--save', 'Save tests to file')
|
|
1115
|
+
.action(async (file, options) => {
|
|
1116
|
+
initLogFile();
|
|
1117
|
+
if (!hasAnyApiKey()) {
|
|
1118
|
+
requireApiKey();
|
|
1119
|
+
}
|
|
1120
|
+
try {
|
|
1121
|
+
console.log(createBanner('Test Generator', 'Comprehensive test generation'));
|
|
1122
|
+
newline();
|
|
1123
|
+
const testSpinner = createSpinner('Generating tests...');
|
|
1124
|
+
testSpinner.start();
|
|
1125
|
+
let tests;
|
|
1126
|
+
if (options.improve) {
|
|
1127
|
+
tests = await improveTests(file);
|
|
1128
|
+
}
|
|
1129
|
+
else {
|
|
1130
|
+
tests = await generateTests(file, {
|
|
1131
|
+
framework: options.framework,
|
|
1132
|
+
coverage: options.coverage,
|
|
1133
|
+
});
|
|
1134
|
+
}
|
|
1135
|
+
testSpinner.stop();
|
|
1136
|
+
newline();
|
|
1137
|
+
sectionHeader('Generated Tests');
|
|
1138
|
+
const formattedTests = cleanResponse(tests);
|
|
1139
|
+
console.log(formattedTests);
|
|
1140
|
+
if (options.save) {
|
|
1141
|
+
const testPath = options.improve ? file : getTestFilePath(file, options.framework);
|
|
1142
|
+
saveTests(testPath, tests);
|
|
1143
|
+
console.log(success(`Tests saved to ${testPath}`));
|
|
1144
|
+
}
|
|
1145
|
+
}
|
|
1146
|
+
catch (err) {
|
|
1147
|
+
console.error(error('Error:'), err instanceof Error ? err.message : String(err));
|
|
1148
|
+
process.exit(1);
|
|
1149
|
+
}
|
|
1150
|
+
});
|
|
1151
|
+
program
|
|
1152
|
+
.command('react')
|
|
1153
|
+
.description('Execute query using ReAct loop (iterative reasoning with tools)')
|
|
1154
|
+
.argument('<query>', 'The query to process with ReAct reasoning')
|
|
1155
|
+
.addHelpText('after', `
|
|
1156
|
+
Examples:
|
|
1157
|
+
$ codehere react "How does authentication work in this codebase?"
|
|
1158
|
+
$ codehere react "Find and explain the user login function"
|
|
1159
|
+
$ codehere react "What files handle API requests?"
|
|
1160
|
+
|
|
1161
|
+
This command uses ReAct (Reasoning + Acting) pattern:
|
|
1162
|
+
• Generates thoughts about the problem
|
|
1163
|
+
• Takes actions (uses tools, searches code)
|
|
1164
|
+
• Observes results
|
|
1165
|
+
• Iterates until solution found
|
|
1166
|
+
• Learns from memory of past experiences
|
|
1167
|
+
`)
|
|
1168
|
+
.action(async (query) => {
|
|
1169
|
+
initLogFile();
|
|
1170
|
+
if (!hasAnyApiKey()) {
|
|
1171
|
+
requireApiKey();
|
|
1172
|
+
}
|
|
1173
|
+
try {
|
|
1174
|
+
await executeReactCommand(query);
|
|
1175
|
+
logEntry({
|
|
1176
|
+
timestamp: new Date().toISOString(),
|
|
1177
|
+
command: 'react',
|
|
1178
|
+
query: query,
|
|
1179
|
+
policyStatus: 'allowed',
|
|
1180
|
+
});
|
|
1181
|
+
}
|
|
1182
|
+
catch (err) {
|
|
1183
|
+
console.error(error('Error:'), err instanceof Error ? err.message : String(err));
|
|
1184
|
+
process.exit(1);
|
|
1185
|
+
}
|
|
1186
|
+
});
|
|
1187
|
+
program
|
|
1188
|
+
.command('orchestrate')
|
|
1189
|
+
.description('Orchestrate multi-agent workflows (plan, execute, validate)')
|
|
1190
|
+
.argument('<goal>', 'The goal to orchestrate')
|
|
1191
|
+
.option('-m, --mode <mode>', 'Orchestration mode: plan-only, execute-only, or full', 'full')
|
|
1192
|
+
.option('-p, --plan-id <planId>', 'Load and execute a previously saved plan by ID')
|
|
1193
|
+
.option('--review', 'Enable review & feedback capture (used for trust scoring and Validation Mode)')
|
|
1194
|
+
.action(async (goal, options) => {
|
|
1195
|
+
initLogFile();
|
|
1196
|
+
if (!hasAnyApiKey()) {
|
|
1197
|
+
requireApiKey();
|
|
1198
|
+
}
|
|
1199
|
+
try {
|
|
1200
|
+
await executeOrchestrateCommand(goal, {
|
|
1201
|
+
mode: options.mode,
|
|
1202
|
+
planId: options.planId,
|
|
1203
|
+
review: options.review,
|
|
1204
|
+
});
|
|
1205
|
+
logEntry({
|
|
1206
|
+
timestamp: new Date().toISOString(),
|
|
1207
|
+
command: 'orchestrate',
|
|
1208
|
+
query: goal,
|
|
1209
|
+
policyStatus: 'allowed',
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
catch (err) {
|
|
1213
|
+
console.error(error('Error:'), err instanceof Error ? err.message : String(err));
|
|
1214
|
+
process.exit(1);
|
|
1215
|
+
}
|
|
1216
|
+
});
|
|
1217
|
+
program
|
|
1218
|
+
.command('trace')
|
|
1219
|
+
.description('View execution traces and reproduce runs')
|
|
1220
|
+
.argument('<action>', 'Action: list, show, or reproduce')
|
|
1221
|
+
.argument('[runId]', 'Run ID (required for show/reproduce)')
|
|
1222
|
+
.action(async (action, runId) => {
|
|
479
1223
|
initLogFile();
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
1224
|
+
try {
|
|
1225
|
+
if (action === 'list') {
|
|
1226
|
+
await executeTraceCommand('list');
|
|
1227
|
+
}
|
|
1228
|
+
else if (action === 'show') {
|
|
1229
|
+
if (!runId) {
|
|
1230
|
+
console.error(error('Run ID is required for "show" action'));
|
|
1231
|
+
console.log(info('Usage: codehere trace show <runId>'));
|
|
1232
|
+
process.exit(1);
|
|
1233
|
+
}
|
|
1234
|
+
await executeTraceCommand('show', runId);
|
|
1235
|
+
}
|
|
1236
|
+
else if (action === 'reproduce') {
|
|
1237
|
+
if (!runId) {
|
|
1238
|
+
console.error(error('Run ID is required for "reproduce" action'));
|
|
1239
|
+
console.log(info('Usage: codehere trace reproduce <runId>'));
|
|
1240
|
+
process.exit(1);
|
|
1241
|
+
}
|
|
1242
|
+
await executeTraceCommand('reproduce', runId);
|
|
1243
|
+
}
|
|
1244
|
+
else {
|
|
1245
|
+
console.error(error(`Unknown action: ${action}`));
|
|
1246
|
+
console.log(info('Available actions: list, show, reproduce'));
|
|
1247
|
+
process.exit(1);
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
catch (err) {
|
|
1251
|
+
console.error(error('Error:'), err instanceof Error ? err.message : String(err));
|
|
483
1252
|
process.exit(1);
|
|
484
1253
|
}
|
|
485
|
-
await executeSuggestCommand(question, {});
|
|
486
1254
|
});
|
|
487
|
-
|
|
1255
|
+
program
|
|
1256
|
+
.command('undo')
|
|
1257
|
+
.description('Undo file changes by restoring from backups')
|
|
1258
|
+
.argument('<action>', 'Action: undo, list, restore')
|
|
1259
|
+
.argument('[filepath]', 'File path (required for undo/list)')
|
|
1260
|
+
.argument('[backupPath]', 'Backup path (required for restore)')
|
|
1261
|
+
.addHelpText('after', `
|
|
1262
|
+
Examples:
|
|
1263
|
+
$ codehere undo undo src/file.ts
|
|
1264
|
+
$ codehere undo list src/file.ts
|
|
1265
|
+
$ codehere undo restore src/file.ts .codehere/backups/file.ts.2024-12-30.backup
|
|
1266
|
+
|
|
1267
|
+
Actions:
|
|
1268
|
+
undo - Restore file from most recent backup
|
|
1269
|
+
list - List all available backups for a file
|
|
1270
|
+
restore - Restore file from a specific backup path
|
|
1271
|
+
`)
|
|
1272
|
+
.action(async (action, filepath, backupPath) => {
|
|
1273
|
+
initLogFile();
|
|
1274
|
+
try {
|
|
1275
|
+
await executeUndoCommand(action, filepath, backupPath);
|
|
1276
|
+
}
|
|
1277
|
+
catch (err) {
|
|
1278
|
+
console.error(error('Error:'), err instanceof Error ? err.message : String(err));
|
|
1279
|
+
process.exit(1);
|
|
1280
|
+
}
|
|
1281
|
+
});
|
|
1282
|
+
// ── trust ─────────────────────────────────────────────────────────────────────
|
|
1283
|
+
program
|
|
1284
|
+
.command('trust')
|
|
1285
|
+
.description('Layer 0 trust score — instant static analysis, zero API calls')
|
|
1286
|
+
.argument('[target]', 'File, directory, or omit to scan current directory')
|
|
1287
|
+
.option('--diff [ref]', 'Score a git diff (default: HEAD)')
|
|
1288
|
+
.option('--badge', 'Output shield badge markdown')
|
|
1289
|
+
.option('--json', 'Output JSON report')
|
|
1290
|
+
.option('--verbose', 'Show all findings with line numbers')
|
|
1291
|
+
.option('--ci', 'CI mode: exit 1 if score < 60')
|
|
1292
|
+
.action(async (target, options) => {
|
|
1293
|
+
try {
|
|
1294
|
+
await executeTrustCommand(target, {
|
|
1295
|
+
diff: options?.diff === true ? 'HEAD' : options?.diff,
|
|
1296
|
+
badge: options?.badge,
|
|
1297
|
+
json: options?.json,
|
|
1298
|
+
verbose: options?.verbose,
|
|
1299
|
+
ci: options?.ci,
|
|
1300
|
+
});
|
|
1301
|
+
}
|
|
1302
|
+
catch (err) {
|
|
1303
|
+
console.error(error('Error:'), err instanceof Error ? err.message : String(err));
|
|
1304
|
+
process.exit(1);
|
|
1305
|
+
}
|
|
1306
|
+
});
|
|
1307
|
+
// ── report ────────────────────────────────────────────────────────────────────
|
|
1308
|
+
program
|
|
1309
|
+
.command('report')
|
|
1310
|
+
.description('Generate a shareable security audit report — narrative, not just a score')
|
|
1311
|
+
.argument('[target]', 'File or directory to audit (default: current directory)')
|
|
1312
|
+
.option('--out <file>', 'Write report to a file (default: print to stdout)')
|
|
1313
|
+
.option('--json', 'Output machine-readable JSON instead of markdown')
|
|
1314
|
+
.option('--simple', 'Plain English output — no jargon, for non-technical stakeholders')
|
|
1315
|
+
.addHelpText('after', `
|
|
1316
|
+
Examples:
|
|
1317
|
+
$ codehere report # audit current dir, print markdown
|
|
1318
|
+
$ codehere report src/ # audit a subdirectory
|
|
1319
|
+
$ codehere report --out report.md # write to file
|
|
1320
|
+
$ codehere report > report.md # pipe to file
|
|
1321
|
+
$ codehere report --json # machine-readable output
|
|
1322
|
+
$ codehere report --simple # plain English for non-technical stakeholders
|
|
1323
|
+
|
|
1324
|
+
The report is a markdown document you can:
|
|
1325
|
+
• Paste directly into a PR description
|
|
1326
|
+
• Commit as a security audit artifact
|
|
1327
|
+
• Include the badge in your README
|
|
1328
|
+
`)
|
|
1329
|
+
.action(async (target, options) => {
|
|
1330
|
+
try {
|
|
1331
|
+
await executeReportCommand(target, {
|
|
1332
|
+
out: options?.out,
|
|
1333
|
+
json: options?.json,
|
|
1334
|
+
simple: options?.simple,
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
catch (err) {
|
|
1338
|
+
console.error(error('Error:'), err instanceof Error ? err.message : String(err));
|
|
1339
|
+
process.exit(1);
|
|
1340
|
+
}
|
|
1341
|
+
});
|
|
1342
|
+
// ── hook ──────────────────────────────────────────────────────────────────────
|
|
1343
|
+
program
|
|
1344
|
+
.command('hook')
|
|
1345
|
+
.description('Manage Claude Agent SDK hook integration (intercepts all tool calls)')
|
|
1346
|
+
.argument('[subcommand]', 'install | uninstall | status | log')
|
|
1347
|
+
.option('--log-only', 'Log events but never block (audit mode)')
|
|
1348
|
+
.option('--block-mode <level>', 'Block threshold: critical (default), high, all')
|
|
1349
|
+
.option('--tail <n>', 'Lines to show in log mode', '20')
|
|
1350
|
+
.option('--debug', 'Verbose debug output')
|
|
1351
|
+
.action(async (subcommand, options) => {
|
|
1352
|
+
try {
|
|
1353
|
+
await executeHookCommand(subcommand, {
|
|
1354
|
+
logOnly: options?.logOnly,
|
|
1355
|
+
blockMode: options?.blockMode,
|
|
1356
|
+
tail: options?.tail ? parseInt(options.tail, 10) : undefined,
|
|
1357
|
+
debug: options?.debug,
|
|
1358
|
+
});
|
|
1359
|
+
}
|
|
1360
|
+
catch (err) {
|
|
1361
|
+
console.error(error('Error:'), err instanceof Error ? err.message : String(err));
|
|
1362
|
+
process.exit(1);
|
|
1363
|
+
}
|
|
1364
|
+
});
|
|
1365
|
+
// ── serve (MCP server) ───────────────────────────────────────────────────────
|
|
1366
|
+
program
|
|
1367
|
+
.command('serve')
|
|
1368
|
+
.description('Start codehere as an MCP server — expose trust tools to Claude Desktop, Cursor, and any MCP client')
|
|
1369
|
+
.option('-p, --port <number>', 'Port to listen on', '3773')
|
|
1370
|
+
.option('--host <host>', 'Host to bind to (default: 127.0.0.1)', '127.0.0.1')
|
|
1371
|
+
.option('--token <token>', 'Require Bearer token for authentication')
|
|
1372
|
+
.option('--show-config', 'Print the MCP config block to add to Claude Desktop / Cursor settings')
|
|
1373
|
+
.action(async (options) => {
|
|
1374
|
+
const port = parseInt(options?.port ?? '3773', 10);
|
|
1375
|
+
const host = options?.host ?? '127.0.0.1';
|
|
1376
|
+
const token = options?.token;
|
|
1377
|
+
if (options?.showConfig) {
|
|
1378
|
+
const config = {
|
|
1379
|
+
mcpServers: {
|
|
1380
|
+
codehere: {
|
|
1381
|
+
url: `http://${host}:${port}/mcp`,
|
|
1382
|
+
...(token ? { headers: { Authorization: `Bearer ${token}` } } : {}),
|
|
1383
|
+
},
|
|
1384
|
+
},
|
|
1385
|
+
};
|
|
1386
|
+
console.log('\nAdd to Claude Desktop or Cursor MCP settings:\n');
|
|
1387
|
+
console.log(JSON.stringify(config, null, 2));
|
|
1388
|
+
newline();
|
|
1389
|
+
console.log(colors.dim('Claude Desktop: ~/Library/Application Support/Claude/claude_desktop_config.json'));
|
|
1390
|
+
console.log(colors.dim('Cursor: Settings > MCP Servers'));
|
|
1391
|
+
newline();
|
|
1392
|
+
return;
|
|
1393
|
+
}
|
|
1394
|
+
try {
|
|
1395
|
+
const { startMCPServer } = await import('./infrastructure/protocols/mcp-server-impl.js');
|
|
1396
|
+
const server = startMCPServer({ port, host, token });
|
|
1397
|
+
newline();
|
|
1398
|
+
console.log(success(`codehere MCP server running`));
|
|
1399
|
+
newline();
|
|
1400
|
+
console.log(colors.bold('Endpoint:') + ` http://${host}:${port}/mcp`);
|
|
1401
|
+
console.log(colors.bold('Health:') + ` http://${host}:${port}/health`);
|
|
1402
|
+
newline();
|
|
1403
|
+
console.log(colors.bold('Tools available:'));
|
|
1404
|
+
console.log(' codehere_trust — score a file or snippet (0-100, no API)');
|
|
1405
|
+
console.log(' codehere_scan — scan text for injection/threats');
|
|
1406
|
+
console.log(' codehere_review — scan a directory, return riskiest files');
|
|
1407
|
+
console.log(' codehere_audit — read hook audit log');
|
|
1408
|
+
newline();
|
|
1409
|
+
console.log(colors.dim(' Run with --show-config to get the MCP client config block'));
|
|
1410
|
+
console.log(colors.dim(' Press Ctrl+C to stop'));
|
|
1411
|
+
newline();
|
|
1412
|
+
// Keep alive
|
|
1413
|
+
process.on('SIGINT', () => {
|
|
1414
|
+
server.close();
|
|
1415
|
+
console.log(colors.dim('\ncodehere MCP server stopped'));
|
|
1416
|
+
process.exit(0);
|
|
1417
|
+
});
|
|
1418
|
+
await new Promise((resolve) => {
|
|
1419
|
+
server.on('close', resolve);
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
catch (err) {
|
|
1423
|
+
console.error(error('Failed to start server:'), err instanceof Error ? err.message : String(err));
|
|
1424
|
+
process.exit(1);
|
|
1425
|
+
}
|
|
1426
|
+
});
|
|
1427
|
+
// ── scan-tool (called by Claude Code hooks system, not users) ─────────────────
|
|
1428
|
+
program
|
|
1429
|
+
.command('scan-tool')
|
|
1430
|
+
.description('Hook handler: reads Claude Code tool event from stdin, outputs block/allow (used by hook system)')
|
|
1431
|
+
.option('--log-only', 'Never block, log only')
|
|
1432
|
+
.option('--block-all', 'Block on any finding, not just critical')
|
|
1433
|
+
.option('--debug', 'Debug output')
|
|
1434
|
+
.action(async (options) => {
|
|
1435
|
+
await executeScanToolCommand({
|
|
1436
|
+
logOnly: options?.logOnly,
|
|
1437
|
+
blockAll: options?.blockAll,
|
|
1438
|
+
debug: options?.debug,
|
|
1439
|
+
});
|
|
1440
|
+
});
|
|
1441
|
+
// Add completion command
|
|
1442
|
+
program
|
|
1443
|
+
.command('completion')
|
|
1444
|
+
.description('Generate shell completion script')
|
|
1445
|
+
.argument('<shell>', 'Shell type: bash, zsh, or fish')
|
|
1446
|
+
.action(async (shell) => {
|
|
1447
|
+
try {
|
|
1448
|
+
switch (shell.toLowerCase()) {
|
|
1449
|
+
case 'bash': {
|
|
1450
|
+
const { generateBashCompletion } = await import('./infrastructure/completion/bash-completion.js');
|
|
1451
|
+
console.log(generateBashCompletion());
|
|
1452
|
+
break;
|
|
1453
|
+
}
|
|
1454
|
+
case 'zsh': {
|
|
1455
|
+
const { generateZshCompletion } = await import('./infrastructure/completion/zsh-completion.js');
|
|
1456
|
+
console.log(generateZshCompletion());
|
|
1457
|
+
break;
|
|
1458
|
+
}
|
|
1459
|
+
case 'fish': {
|
|
1460
|
+
const { generateFishCompletion } = await import('./infrastructure/completion/fish-completion.js');
|
|
1461
|
+
console.log(generateFishCompletion());
|
|
1462
|
+
break;
|
|
1463
|
+
}
|
|
1464
|
+
default:
|
|
1465
|
+
console.error(error(`Unsupported shell: ${shell}`));
|
|
1466
|
+
console.log(info('Supported shells: bash, zsh, fish'));
|
|
1467
|
+
console.log(info('Usage: codehere completion <bash|zsh|fish>'));
|
|
1468
|
+
process.exit(1);
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
catch (err) {
|
|
1472
|
+
displayError(err, {
|
|
1473
|
+
operation: 'completion',
|
|
1474
|
+
showSuggestions: true,
|
|
1475
|
+
});
|
|
1476
|
+
process.exit(1);
|
|
1477
|
+
}
|
|
1478
|
+
});
|
|
1479
|
+
program
|
|
1480
|
+
.command('cost')
|
|
1481
|
+
.description('View API cost tracking and budget status')
|
|
1482
|
+
.argument('[action]', 'Action: status, summary, reset (default: status)')
|
|
1483
|
+
.argument('[run-id]', 'Run ID for detailed breakdown')
|
|
1484
|
+
.action(async (action, runId) => {
|
|
1485
|
+
try {
|
|
1486
|
+
await executeCostCommand(action || 'status', runId);
|
|
1487
|
+
}
|
|
1488
|
+
catch (err) {
|
|
1489
|
+
displayError(err, { operation: 'cost', showSuggestions: true });
|
|
1490
|
+
process.exit(1);
|
|
1491
|
+
}
|
|
1492
|
+
});
|
|
1493
|
+
// Initialize telemetry and track command
|
|
1494
|
+
const telemetry = getTelemetryService();
|
|
1495
|
+
// Track command usage (if enabled)
|
|
1496
|
+
const commandName = process.argv[2] || 'default';
|
|
1497
|
+
if (commandName !== 'telemetry') {
|
|
1498
|
+
telemetry.trackCommand(commandName);
|
|
1499
|
+
}
|
|
1500
|
+
// Check for first run (install tracking)
|
|
1501
|
+
const codebaseRoot = process.cwd();
|
|
1502
|
+
const codehereDir = join(codebaseRoot, '.codehere');
|
|
1503
|
+
if (!existsSync(codehereDir)) {
|
|
1504
|
+
// First run - track install
|
|
1505
|
+
telemetry.track('install', {
|
|
1506
|
+
version: process.env.npm_package_version || 'unknown',
|
|
1507
|
+
os: process.platform,
|
|
1508
|
+
nodeVersion: process.version,
|
|
1509
|
+
});
|
|
1510
|
+
}
|
|
1511
|
+
// Slash command routing: `codehere /ask "..."` → `codehere ask "..."`
|
|
1512
|
+
// Hide non-core commands from default --help (still usable, shown via `help --all`)
|
|
1513
|
+
const CORE_COMMANDS = new Set([
|
|
1514
|
+
'setup', 'index', 'ask', 'fix', 'explain', 'health',
|
|
1515
|
+
'status', 'plan', 'trust', 'report', 'hook', 'serve', 'help',
|
|
1516
|
+
]);
|
|
1517
|
+
for (const cmd of program.commands) {
|
|
1518
|
+
if (!CORE_COMMANDS.has(cmd.name())) {
|
|
1519
|
+
cmd._hidden = true;
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
// Lets users use slash-prefixed commands from the terminal (like Claude Code's /commands)
|
|
1523
|
+
const rawArgs = process.argv.slice(2);
|
|
1524
|
+
if (rawArgs.length > 0 && rawArgs[0].startsWith('/') && rawArgs[0].length > 1) {
|
|
1525
|
+
const stripped = rawArgs[0].slice(1); // remove leading /
|
|
1526
|
+
process.argv.splice(2, 1, stripped); // replace /cmd with cmd in-place
|
|
1527
|
+
}
|
|
488
1528
|
program.parse();
|
|
489
1529
|
//# sourceMappingURL=index.js.map
|