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/session.js
CHANGED
|
@@ -1,325 +1,617 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Interactive Session
|
|
3
|
-
*
|
|
2
|
+
* Interactive Session — the main codehere experience
|
|
3
|
+
*
|
|
4
|
+
* Uses raw stdin for live command palette.
|
|
5
|
+
* Pattern copied from test-real.mjs which is verified working.
|
|
4
6
|
*/
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
7
|
+
import { existsSync, readdirSync, readFileSync } from 'fs';
|
|
8
|
+
import { join, basename } from 'path';
|
|
9
|
+
import ora from 'ora';
|
|
10
|
+
import chalk from 'chalk';
|
|
11
|
+
// Brand colors
|
|
12
|
+
const brandBlue = chalk.rgb(74, 144, 226); // #4a90e2
|
|
13
|
+
const brandCoral = chalk.rgb(255, 154, 118); // #ff9a76
|
|
14
|
+
import { chatWithContextStream } from './chat.js';
|
|
15
|
+
import { createMarkdownStream } from './infrastructure/ux/stream-markdown.js';
|
|
9
16
|
import { reviewFile } from './review.js';
|
|
10
17
|
import { planTask, formatPlan } from './planner.js';
|
|
11
18
|
import { IntelligentRouter } from './application/services/intelligent-router.js';
|
|
12
|
-
import { colors,
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
19
|
+
import { colors, error, warning, createCodehereLogo, SLASH_COMMANDS, } from './ui.js';
|
|
20
|
+
import { getVersion } from './utils/version.js';
|
|
21
|
+
const stdin = process.stdin;
|
|
22
|
+
const stdout = process.stdout;
|
|
23
|
+
// Build palette command list from SLASH_COMMANDS
|
|
24
|
+
const PALETTE_CMDS = SLASH_COMMANDS.map(c => ({
|
|
25
|
+
sig: `/${c.name}${c.args ? ' ' + c.args : ''}`,
|
|
26
|
+
name: c.name,
|
|
27
|
+
desc: c.description,
|
|
28
|
+
noKey: c.noKey,
|
|
29
|
+
}));
|
|
30
|
+
// Dynamic: leave room for prompt + header lines
|
|
31
|
+
function maxPalette() {
|
|
32
|
+
const rows = process.stdout.rows || 24;
|
|
33
|
+
return Math.min(rows - 8, 20); // 8 lines reserved for header/prompt/footer
|
|
34
|
+
}
|
|
35
|
+
// ── State detection ─────────────────────────────────────────────────────────
|
|
36
|
+
function detectState() {
|
|
37
|
+
const cwd = process.cwd();
|
|
38
|
+
const name = basename(cwd);
|
|
39
|
+
const settingsPath = join(process.env.HOME || '', '.claude', 'settings.json');
|
|
40
|
+
let hasHooks = false;
|
|
41
|
+
try {
|
|
42
|
+
hasHooks = existsSync(settingsPath) && readFileSync(settingsPath, 'utf-8').includes('codehere');
|
|
43
|
+
}
|
|
44
|
+
catch { }
|
|
45
|
+
const hasApiKey = !!(process.env.ANTHROPIC_API_KEY || process.env.OPENAI_API_KEY || process.env.COHERE_API_KEY);
|
|
46
|
+
const hasEmbeddings = existsSync(join(cwd, '.codehere-cache', 'embeddings.sqlite'));
|
|
47
|
+
const isGitRepo = existsSync(join(cwd, '.git'));
|
|
48
|
+
let fileCount = 0;
|
|
49
|
+
try {
|
|
50
|
+
const count = (dir, d) => {
|
|
51
|
+
if (d > 3)
|
|
52
|
+
return 0;
|
|
53
|
+
let n = 0;
|
|
54
|
+
for (const e of readdirSync(dir, { withFileTypes: true })) {
|
|
55
|
+
if (e.name.startsWith('.') || e.name === 'node_modules' || e.name === 'dist')
|
|
56
|
+
continue;
|
|
57
|
+
if (e.isDirectory())
|
|
58
|
+
n += count(join(dir, e.name), d + 1);
|
|
59
|
+
else
|
|
60
|
+
n++;
|
|
61
|
+
}
|
|
62
|
+
return n;
|
|
63
|
+
};
|
|
64
|
+
fileCount = count(cwd, 0);
|
|
65
|
+
}
|
|
66
|
+
catch { }
|
|
67
|
+
return { name, hasHooks, hasApiKey, hasEmbeddings, isGitRepo, fileCount };
|
|
68
|
+
}
|
|
69
|
+
function printWelcome() {
|
|
70
|
+
const state = detectState();
|
|
71
|
+
const logo = createCodehereLogo();
|
|
72
|
+
const ver = colors.dim(`v${getVersion()}`);
|
|
73
|
+
console.log();
|
|
74
|
+
console.log(` ${logo} ${ver}`);
|
|
75
|
+
console.log();
|
|
76
|
+
const badges = [
|
|
77
|
+
state.hasHooks ? colors.green('● hooks') : colors.dim('○ hooks'),
|
|
78
|
+
state.hasApiKey ? colors.green('● api') : colors.dim('○ api'),
|
|
79
|
+
state.hasEmbeddings ? colors.green('● indexed') : colors.dim('○ indexed'),
|
|
80
|
+
];
|
|
81
|
+
console.log(' ' + badges.join(' '));
|
|
82
|
+
console.log();
|
|
83
|
+
console.log(colors.dim(` ${state.name}`) + colors.dim(` · ${state.isGitRepo ? 'git' : 'dir'} · ${state.fileCount} files`));
|
|
84
|
+
console.log();
|
|
85
|
+
if (!state.hasHooks)
|
|
86
|
+
console.log(' ' + colors.yellow('→') + ' ' + colors.cyan('/hook install') + colors.dim(' to activate safety scanning'));
|
|
87
|
+
else if (!state.hasApiKey)
|
|
88
|
+
console.log(' ' + colors.yellow('→') + ' ' + colors.cyan('codehere setup') + colors.dim(' to add an API key'));
|
|
89
|
+
else if (!state.hasEmbeddings)
|
|
90
|
+
console.log(' ' + colors.yellow('→') + ' Type ' + colors.cyan('/index') + colors.dim(' to enable semantic search'));
|
|
91
|
+
console.log(colors.dim(' Type / for commands, or ask anything'));
|
|
92
|
+
console.log();
|
|
93
|
+
}
|
|
94
|
+
// ── Main session ────────────────────────────────────────────────────────────
|
|
18
95
|
export async function startSession() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
96
|
+
printWelcome();
|
|
97
|
+
// Raw mode
|
|
98
|
+
if (stdin.isTTY)
|
|
99
|
+
stdin.setRawMode(true);
|
|
100
|
+
stdin.resume();
|
|
101
|
+
stdin.setEncoding('utf8');
|
|
102
|
+
const state = { history: [] };
|
|
103
|
+
const historyBuf = [];
|
|
104
|
+
let historyIdx = -1;
|
|
105
|
+
let line = '';
|
|
106
|
+
let selected = 0;
|
|
107
|
+
let pLines = 0;
|
|
108
|
+
let processing = false;
|
|
109
|
+
let escBuf = '';
|
|
110
|
+
let escTimer = null;
|
|
111
|
+
// ── Render: clear from prompt to end of screen, redraw everything ──
|
|
112
|
+
// Key insight: truncate all output lines to terminal width to prevent wrapping,
|
|
113
|
+
// which breaks cursor-up counting.
|
|
114
|
+
const cols = () => stdout.columns || 80;
|
|
115
|
+
function truncate(s, maxWidth) {
|
|
116
|
+
// Strip ANSI to measure visible length, truncate if needed
|
|
117
|
+
const visible = s.replace(/\x1b\[[0-9;]*m/g, '');
|
|
118
|
+
if (visible.length <= maxWidth)
|
|
119
|
+
return s;
|
|
120
|
+
// Truncate by removing chars from the end (keep ANSI structure intact)
|
|
121
|
+
let vis = 0;
|
|
122
|
+
let cut = 0;
|
|
123
|
+
for (let i = 0; i < s.length; i++) {
|
|
124
|
+
if (s[i] === '\x1b') {
|
|
125
|
+
// Skip ANSI sequence
|
|
126
|
+
const end = s.indexOf('m', i);
|
|
127
|
+
if (end !== -1) {
|
|
128
|
+
i = end;
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
vis++;
|
|
133
|
+
if (vis >= maxWidth - 1) {
|
|
134
|
+
cut = i + 1;
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return cut > 0 ? s.slice(0, cut) + '\x1b[0m' : s;
|
|
139
|
+
}
|
|
140
|
+
function render() {
|
|
141
|
+
stdout.write('\r\x1b[J');
|
|
142
|
+
stdout.write(brandBlue('> ') + line);
|
|
143
|
+
if (line.startsWith('/') && !line.includes(' ')) {
|
|
144
|
+
const filter = line.slice(1).toLowerCase();
|
|
145
|
+
const allMatching = PALETTE_CMDS.filter(c => c.name.startsWith(filter));
|
|
146
|
+
const limit = maxPalette();
|
|
147
|
+
const filtered = allMatching.slice(0, limit);
|
|
148
|
+
const overflow = allMatching.length - filtered.length;
|
|
149
|
+
if (filtered.length > 0) {
|
|
150
|
+
const maxLen = Math.max(...filtered.map(c => c.sig.length));
|
|
151
|
+
const w = cols();
|
|
152
|
+
let drawnLines = 0;
|
|
153
|
+
for (let i = 0; i < filtered.length; i++) {
|
|
154
|
+
const c = filtered[i];
|
|
155
|
+
const pad = ' '.repeat(Math.max(1, maxLen - c.sig.length + 2));
|
|
156
|
+
const badge = c.noKey ? colors.dim(' (free)') : '';
|
|
157
|
+
const prefix = i === selected ? brandBlue('▸') : ' ';
|
|
158
|
+
const text = i === selected ? brandBlue(c.sig) : c.sig;
|
|
159
|
+
const row = ` ${prefix} ${text}${pad}${colors.dim(c.desc)}${badge}`;
|
|
160
|
+
stdout.write('\n' + truncate(row, w));
|
|
161
|
+
drawnLines++;
|
|
162
|
+
}
|
|
163
|
+
if (overflow > 0) {
|
|
164
|
+
stdout.write('\n' + colors.dim(` ... +${overflow} more (type to filter)`));
|
|
165
|
+
drawnLines++;
|
|
166
|
+
}
|
|
167
|
+
stdout.write(`\x1b[${drawnLines}A`);
|
|
168
|
+
stdout.write(`\x1b[${line.length + 3}G`);
|
|
169
|
+
pLines = drawnLines;
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
stdout.write('\n' + colors.dim(' No matching commands'));
|
|
173
|
+
stdout.write('\x1b[1A');
|
|
174
|
+
stdout.write(`\x1b[${line.length + 3}G`);
|
|
175
|
+
pLines = 1;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
pLines = 0;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// ── Key handler (synchronous for palette, async exec wrapped separately) ──
|
|
183
|
+
function handle(key) {
|
|
184
|
+
if (processing)
|
|
185
|
+
return;
|
|
186
|
+
// Ctrl+C
|
|
187
|
+
if (key === '\x03') {
|
|
188
|
+
if (line.length > 0) {
|
|
189
|
+
line = '';
|
|
190
|
+
selected = 0;
|
|
191
|
+
stdout.write('\r\x1b[J\n');
|
|
192
|
+
render();
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
stdout.write('\r\x1b[J\n');
|
|
196
|
+
process.exit(0);
|
|
197
|
+
}
|
|
44
198
|
return;
|
|
45
199
|
}
|
|
46
|
-
//
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
|
|
200
|
+
// Ctrl+D
|
|
201
|
+
if (key === '\x04') {
|
|
202
|
+
stdout.write('\r\x1b[J\n' + colors.dim(' See you.') + '\n');
|
|
203
|
+
process.exit(0);
|
|
204
|
+
}
|
|
205
|
+
// Ctrl+L
|
|
206
|
+
if (key === '\x0c') {
|
|
207
|
+
line = '';
|
|
208
|
+
selected = 0;
|
|
209
|
+
stdout.write('\x1b[2J\x1b[H');
|
|
210
|
+
printWelcome();
|
|
211
|
+
render();
|
|
50
212
|
return;
|
|
51
213
|
}
|
|
52
|
-
//
|
|
53
|
-
if (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
214
|
+
// Arrow up
|
|
215
|
+
if (key === '\x1b[A') {
|
|
216
|
+
if (pLines > 0) {
|
|
217
|
+
selected = Math.max(0, selected - 1);
|
|
218
|
+
}
|
|
219
|
+
else if (historyBuf.length > 0 && historyIdx < historyBuf.length - 1) {
|
|
220
|
+
historyIdx++;
|
|
221
|
+
line = historyBuf[historyIdx];
|
|
222
|
+
}
|
|
223
|
+
render();
|
|
57
224
|
return;
|
|
58
225
|
}
|
|
59
|
-
//
|
|
60
|
-
if (
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
226
|
+
// Arrow down
|
|
227
|
+
if (key === '\x1b[B') {
|
|
228
|
+
if (pLines > 0) {
|
|
229
|
+
selected = Math.min(pLines - 1, selected + 1);
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
if (historyIdx > 0) {
|
|
233
|
+
historyIdx--;
|
|
234
|
+
line = historyBuf[historyIdx];
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
historyIdx = -1;
|
|
238
|
+
line = '';
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
render();
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
// Tab
|
|
245
|
+
if (key === '\t' && pLines > 0) {
|
|
246
|
+
const filter = line.slice(1).toLowerCase();
|
|
247
|
+
const filtered = PALETTE_CMDS.filter(c => c.name.startsWith(filter)).slice(0, maxPalette());
|
|
248
|
+
if (filtered[selected]) {
|
|
249
|
+
line = `/${filtered[selected].name} `;
|
|
250
|
+
selected = 0;
|
|
251
|
+
}
|
|
252
|
+
render();
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
// Enter
|
|
256
|
+
if (key === '\r' || key === '\n') {
|
|
257
|
+
// If palette is visible, complete the selected command first
|
|
258
|
+
if (pLines > 0 && line.startsWith('/') && !line.includes(' ')) {
|
|
259
|
+
const filter = line.slice(1).toLowerCase();
|
|
260
|
+
const filtered = PALETTE_CMDS.filter(c => c.name.startsWith(filter)).slice(0, maxPalette());
|
|
261
|
+
if (filtered[selected]) {
|
|
262
|
+
line = `/${filtered[selected].name}`;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
stdout.write('\r\x1b[J\n');
|
|
266
|
+
const trimmed = line.trim();
|
|
267
|
+
if (trimmed) {
|
|
268
|
+
historyBuf.unshift(trimmed);
|
|
269
|
+
historyIdx = -1;
|
|
270
|
+
}
|
|
271
|
+
line = '';
|
|
272
|
+
selected = 0;
|
|
273
|
+
pLines = 0;
|
|
274
|
+
if (!trimmed) {
|
|
275
|
+
render();
|
|
276
|
+
return;
|
|
277
|
+
}
|
|
278
|
+
// Async execution
|
|
279
|
+
processing = true;
|
|
280
|
+
executeInput(trimmed, state).catch(err => {
|
|
281
|
+
console.log(error(' ' + (err instanceof Error ? err.message : String(err))));
|
|
282
|
+
}).finally(() => {
|
|
283
|
+
processing = false;
|
|
284
|
+
stdin.resume();
|
|
285
|
+
stdin.ref();
|
|
286
|
+
if (stdin.isTTY && !stdin.isRaw)
|
|
287
|
+
stdin.setRawMode(true);
|
|
288
|
+
console.log();
|
|
289
|
+
render();
|
|
290
|
+
});
|
|
65
291
|
return;
|
|
66
292
|
}
|
|
67
|
-
//
|
|
68
|
-
|
|
69
|
-
|
|
293
|
+
// Backspace
|
|
294
|
+
if (key === '\x7f' || key === '\b') {
|
|
295
|
+
if (line.length > 0) {
|
|
296
|
+
line = line.slice(0, -1);
|
|
297
|
+
selected = 0;
|
|
298
|
+
render();
|
|
299
|
+
}
|
|
300
|
+
return;
|
|
70
301
|
}
|
|
71
|
-
|
|
72
|
-
|
|
302
|
+
// Ignore escape sequences
|
|
303
|
+
if (key.startsWith('\x1b'))
|
|
304
|
+
return;
|
|
305
|
+
// Regular character
|
|
306
|
+
line += key;
|
|
307
|
+
selected = 0;
|
|
308
|
+
render();
|
|
309
|
+
}
|
|
310
|
+
// ── Initial render ──
|
|
311
|
+
render();
|
|
312
|
+
// ── Stdin with escape buffering ──
|
|
313
|
+
// CRITICAL: raw mode can deliver multiple chars in one data event (fast typing, paste).
|
|
314
|
+
// We must process each character individually, except escape sequences which are multi-byte.
|
|
315
|
+
stdin.on('data', (raw) => {
|
|
316
|
+
if (processing)
|
|
317
|
+
return;
|
|
318
|
+
// If the whole chunk is a known escape sequence, handle it directly
|
|
319
|
+
if (raw.startsWith('\x1b') && raw.length >= 2) {
|
|
320
|
+
handle(raw);
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
// Otherwise iterate character by character
|
|
324
|
+
for (let i = 0; i < raw.length; i++) {
|
|
325
|
+
if (processing)
|
|
326
|
+
return; // stop if a command started executing mid-chunk
|
|
327
|
+
const ch = raw[i];
|
|
328
|
+
if (escBuf.length > 0) {
|
|
329
|
+
escBuf += ch;
|
|
330
|
+
if (escTimer)
|
|
331
|
+
clearTimeout(escTimer);
|
|
332
|
+
if (escBuf.length >= 3) {
|
|
333
|
+
const seq = escBuf;
|
|
334
|
+
escBuf = '';
|
|
335
|
+
handle(seq);
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
escTimer = setTimeout(() => { const seq = escBuf; escBuf = ''; handle(seq); }, 50);
|
|
339
|
+
}
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
if (ch === '\x1b') {
|
|
343
|
+
escBuf = ch;
|
|
344
|
+
escTimer = setTimeout(() => { const seq = escBuf; escBuf = ''; handle(seq); }, 50);
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
handle(ch);
|
|
73
348
|
}
|
|
74
|
-
rl.prompt();
|
|
75
|
-
});
|
|
76
|
-
rl.on('close', () => {
|
|
77
|
-
console.log(newline());
|
|
78
|
-
console.log(colors.dim('Session ended.'));
|
|
79
|
-
process.exit(0);
|
|
80
349
|
});
|
|
81
350
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
351
|
+
// ── Command list (for bare / or help) ──────────────────────────────────────
|
|
352
|
+
function printCommandList() {
|
|
353
|
+
console.log();
|
|
354
|
+
const maxLen = Math.max(...PALETTE_CMDS.map(c => c.sig.length));
|
|
355
|
+
for (const cmd of PALETTE_CMDS) {
|
|
356
|
+
const pad = ' '.repeat(Math.max(1, maxLen - cmd.sig.length + 2));
|
|
357
|
+
const badge = cmd.noKey ? colors.dim(' (free)') : '';
|
|
358
|
+
console.log(` ${colors.cyan(cmd.sig)}${pad}${colors.dim(cmd.desc)}${badge}`);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
// ── Input dispatcher ────────────────────────────────────────────────────────
|
|
362
|
+
async function executeInput(input, state) {
|
|
363
|
+
if (input === '/') {
|
|
364
|
+
printCommandList();
|
|
91
365
|
return;
|
|
92
366
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
367
|
+
if (input.startsWith('/')) {
|
|
368
|
+
const spaceIdx = input.indexOf(' ');
|
|
369
|
+
const cmd = (spaceIdx === -1 ? input.slice(1) : input.slice(1, spaceIdx)).toLowerCase();
|
|
370
|
+
const args = spaceIdx === -1 ? '' : input.slice(spaceIdx + 1).trim();
|
|
371
|
+
await handleSlash(cmd, args, state);
|
|
372
|
+
return;
|
|
97
373
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
await handleFix(file, instruction, rl);
|
|
374
|
+
// Exact keywords for REPL control
|
|
375
|
+
if (/^(exit|quit)$/i.test(input)) {
|
|
376
|
+
console.log(colors.dim(' See you.'));
|
|
377
|
+
process.exit(0);
|
|
103
378
|
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
379
|
+
if (/^(help|\?)$/i.test(input)) {
|
|
380
|
+
printCommandList();
|
|
381
|
+
return;
|
|
107
382
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
383
|
+
if (input.toLowerCase() === 'clear') {
|
|
384
|
+
stdout.write('\x1b[2J\x1b[H');
|
|
385
|
+
return;
|
|
111
386
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
387
|
+
// Bare command names: "trust ." or "status" → same as "/trust ." or "/status"
|
|
388
|
+
// Only match unambiguous commands — skip words that are common English ("help", "fix", "run", "plan", "report", "test")
|
|
389
|
+
const BARE_SAFE = ['trust', 'hook', 'status', 'health', 'setup', 'serve', 'models', 'config', 'index', 'explain', 'review', 'cost', 'undo'];
|
|
390
|
+
const lower = input.toLowerCase();
|
|
391
|
+
const firstWord = lower.split(/\s+/)[0];
|
|
392
|
+
const restArgs = input.slice(firstWord.length).trim();
|
|
393
|
+
if (BARE_SAFE.includes(firstWord)) {
|
|
394
|
+
await handleSlash(firstWord, restArgs, state);
|
|
395
|
+
return;
|
|
115
396
|
}
|
|
397
|
+
// Everything else → AI query (the router decides what to do)
|
|
398
|
+
await handleQuery(input, state);
|
|
116
399
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
switch (command) {
|
|
125
|
-
case 'fix':
|
|
126
|
-
case 'edit': {
|
|
127
|
-
// /fix <file> <instruction>
|
|
128
|
-
const fixParts = args.split(/\s+/);
|
|
129
|
-
if (fixParts.length < 2) {
|
|
130
|
-
console.log(warning('Usage: /fix <file> <instruction>'));
|
|
131
|
-
console.log(colors.dim('Example: /fix src/utils.ts "add error handling"'));
|
|
400
|
+
// ── Slash commands ──────────────────────────────────────────────────────────
|
|
401
|
+
async function handleSlash(cmd, args, state) {
|
|
402
|
+
switch (cmd) {
|
|
403
|
+
case 'ask':
|
|
404
|
+
case 'q':
|
|
405
|
+
if (!args) {
|
|
406
|
+
console.log(colors.dim(' Usage: /ask <question>'));
|
|
132
407
|
return;
|
|
133
408
|
}
|
|
134
|
-
|
|
135
|
-
const instruction = fixParts.slice(1).join(' ');
|
|
136
|
-
await handleFix(file, instruction, rl);
|
|
409
|
+
await handleQuery(args, state);
|
|
137
410
|
break;
|
|
138
|
-
}
|
|
139
411
|
case 'explain':
|
|
140
|
-
case 'e':
|
|
141
|
-
// /explain <file>
|
|
412
|
+
case 'e':
|
|
142
413
|
if (!args) {
|
|
143
|
-
console.log(
|
|
144
|
-
console.log(colors.dim('Example: /explain src/auth.ts'));
|
|
414
|
+
console.log(colors.dim(' Usage: /explain <file>'));
|
|
145
415
|
return;
|
|
146
416
|
}
|
|
147
|
-
await handleExplain(args
|
|
417
|
+
await handleExplain(args);
|
|
418
|
+
break;
|
|
419
|
+
case 'fix':
|
|
420
|
+
case 'edit': {
|
|
421
|
+
const p = args.split(' ');
|
|
422
|
+
if (!p[0]) {
|
|
423
|
+
console.log(colors.dim(' Usage: /fix <file> <instruction>'));
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
await handleFix(p[0], p.slice(1).join(' '));
|
|
148
427
|
break;
|
|
149
428
|
}
|
|
150
429
|
case 'review':
|
|
151
|
-
case 'r': {
|
|
152
|
-
// /review <file>
|
|
153
430
|
if (!args) {
|
|
154
|
-
console.log(
|
|
155
|
-
console.log(colors.dim('Example: /review src/auth.ts'));
|
|
431
|
+
console.log(colors.dim(' Usage: /review <file>'));
|
|
156
432
|
return;
|
|
157
433
|
}
|
|
158
|
-
await handleReview(args
|
|
434
|
+
await handleReview(args);
|
|
159
435
|
break;
|
|
160
|
-
}
|
|
161
436
|
case 'plan':
|
|
162
|
-
case 'p': {
|
|
163
|
-
// /plan <instruction>
|
|
164
437
|
if (!args) {
|
|
165
|
-
console.log(
|
|
166
|
-
console.log(colors.dim('Example: /plan "add user authentication"'));
|
|
438
|
+
console.log(colors.dim(' Usage: /plan <goal>'));
|
|
167
439
|
return;
|
|
168
440
|
}
|
|
169
|
-
await handlePlan(args
|
|
441
|
+
await handlePlan(args);
|
|
442
|
+
break;
|
|
443
|
+
case 'trust': {
|
|
444
|
+
const { executeTrustCommand } = await import('./presentation/cli/commands/trust-command.js');
|
|
445
|
+
await executeTrustCommand(args || undefined);
|
|
170
446
|
break;
|
|
171
447
|
}
|
|
172
|
-
case '
|
|
173
|
-
|
|
174
|
-
|
|
448
|
+
case 'report': {
|
|
449
|
+
const { executeReportCommand } = await import('./presentation/cli/commands/report-command.js');
|
|
450
|
+
await executeReportCommand(args || undefined);
|
|
175
451
|
break;
|
|
176
452
|
}
|
|
177
|
-
case '
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
453
|
+
case 'hook': {
|
|
454
|
+
const { executeHookCommand } = await import('./presentation/cli/commands/hook-command.js');
|
|
455
|
+
await executeHookCommand(args.split(' ')[0] || 'status');
|
|
456
|
+
break;
|
|
457
|
+
}
|
|
458
|
+
case 'status': {
|
|
459
|
+
const { executeStatusCommand } = await import('./presentation/cli/commands/status-command.js');
|
|
460
|
+
await executeStatusCommand({});
|
|
461
|
+
break;
|
|
462
|
+
}
|
|
463
|
+
case 'suggest': {
|
|
464
|
+
const { executeSuggestCommand } = await import('./presentation/cli/commands/suggest-command.js');
|
|
465
|
+
if (!args) {
|
|
466
|
+
console.log(colors.dim(' Usage: /suggest <query>'));
|
|
467
|
+
return;
|
|
182
468
|
}
|
|
183
|
-
|
|
184
|
-
|
|
469
|
+
await executeSuggestCommand(args);
|
|
470
|
+
break;
|
|
471
|
+
}
|
|
472
|
+
case 'test': {
|
|
473
|
+
if (!args) {
|
|
474
|
+
console.log(colors.dim(' Usage: /test <file>'));
|
|
475
|
+
return;
|
|
185
476
|
}
|
|
477
|
+
if (!(await requireKey()))
|
|
478
|
+
return;
|
|
479
|
+
await handleQuery(`Generate tests for ${args}`, state);
|
|
186
480
|
break;
|
|
187
481
|
}
|
|
188
|
-
case '
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
482
|
+
case 'docs': {
|
|
483
|
+
const { executeDocsCommand } = await import('./presentation/cli/commands/docs-command.js');
|
|
484
|
+
await executeDocsCommand((args || 'readme'));
|
|
485
|
+
break;
|
|
486
|
+
}
|
|
487
|
+
case 'refactor': {
|
|
488
|
+
if (!args) {
|
|
489
|
+
console.log(colors.dim(' Usage: /refactor <goal>'));
|
|
490
|
+
return;
|
|
193
491
|
}
|
|
194
|
-
|
|
195
|
-
|
|
492
|
+
if (!(await requireKey()))
|
|
493
|
+
return;
|
|
494
|
+
await handleQuery('Refactor: ' + args, state);
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
case 'orchestrate': {
|
|
498
|
+
const { executeOrchestrateCommand } = await import('./presentation/cli/commands/orchestrate-command.js');
|
|
499
|
+
if (!args) {
|
|
500
|
+
console.log(colors.dim(' Usage: /orchestrate <goal>'));
|
|
501
|
+
return;
|
|
196
502
|
}
|
|
503
|
+
await executeOrchestrateCommand(args, {});
|
|
197
504
|
break;
|
|
198
505
|
}
|
|
199
|
-
case '
|
|
200
|
-
|
|
506
|
+
case 'run': {
|
|
507
|
+
const { executeRunCommand } = await import('./presentation/cli/commands/run-command.js');
|
|
508
|
+
if (!args) {
|
|
509
|
+
console.log(colors.dim(' Usage: /run <goal>'));
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
512
|
+
await executeRunCommand(args, {});
|
|
513
|
+
break;
|
|
514
|
+
}
|
|
515
|
+
case 'git-review': {
|
|
516
|
+
if (!(await requireKey()))
|
|
517
|
+
return;
|
|
518
|
+
await handleQuery('Review the recent git changes in this project', state);
|
|
519
|
+
break;
|
|
520
|
+
}
|
|
521
|
+
case 'index': {
|
|
522
|
+
if (!(await requireKey()))
|
|
523
|
+
return;
|
|
524
|
+
const { indexRepositoryParallel } = await import('./embed.js');
|
|
525
|
+
const spinner = startSpinner('Indexing codebase...');
|
|
201
526
|
try {
|
|
202
|
-
|
|
203
|
-
|
|
527
|
+
await indexRepositoryParallel(process.cwd(), { useCache: true, maxConcurrency: 5 });
|
|
528
|
+
spinner.succeed(colors.green('Index built'));
|
|
204
529
|
}
|
|
205
530
|
catch (err) {
|
|
206
|
-
|
|
531
|
+
spinner.fail(error('Index failed: ' + (err instanceof Error ? err.message : String(err))));
|
|
207
532
|
}
|
|
208
533
|
break;
|
|
209
534
|
}
|
|
210
|
-
case '
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
535
|
+
case 'health': {
|
|
536
|
+
const { performHealthCheck, formatHealthStatus } = await import('./monitoring.js');
|
|
537
|
+
console.log(formatHealthStatus(performHealthCheck()));
|
|
538
|
+
break;
|
|
539
|
+
}
|
|
540
|
+
case 'setup': {
|
|
541
|
+
const { executeSetupCommand } = await import('./presentation/cli/commands/setup-command.js');
|
|
542
|
+
await executeSetupCommand(false);
|
|
543
|
+
break;
|
|
544
|
+
}
|
|
545
|
+
case 'serve': {
|
|
546
|
+
console.log(colors.dim(' MCP server must run in its own process:'));
|
|
547
|
+
console.log(colors.cyan(' codehere serve'));
|
|
548
|
+
break;
|
|
549
|
+
}
|
|
550
|
+
case 'config': {
|
|
551
|
+
const { executeConfigCommand } = await import('./presentation/cli/commands/config-command.js');
|
|
552
|
+
const parts = args.split(' ');
|
|
553
|
+
await executeConfigCommand(parts[0], parts[1], parts[2]);
|
|
554
|
+
break;
|
|
555
|
+
}
|
|
556
|
+
case 'cost': {
|
|
557
|
+
const { executeCostCommand } = await import('./presentation/cli/commands/cost-command.js');
|
|
558
|
+
await executeCostCommand((args || 'status'));
|
|
559
|
+
break;
|
|
560
|
+
}
|
|
561
|
+
case 'models': {
|
|
562
|
+
const { executeModelsCommand } = await import('./presentation/cli/commands/models-command.js');
|
|
563
|
+
await executeModelsCommand({ list: true });
|
|
222
564
|
break;
|
|
223
565
|
}
|
|
224
|
-
case '
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
console.log(createWelcomeMessage());
|
|
228
|
-
newline();
|
|
566
|
+
case 'undo': {
|
|
567
|
+
const { executeUndoCommand } = await import('./presentation/cli/commands/undo-command.js');
|
|
568
|
+
await executeUndoCommand(args ? 'undo' : 'list', args || undefined);
|
|
229
569
|
break;
|
|
230
570
|
}
|
|
571
|
+
case 'clear':
|
|
572
|
+
stdout.write('\x1b[2J\x1b[H');
|
|
573
|
+
break;
|
|
231
574
|
case 'help':
|
|
232
|
-
case '?':
|
|
233
|
-
|
|
234
|
-
showSlashCommandHelp();
|
|
575
|
+
case '?':
|
|
576
|
+
printCommandList();
|
|
235
577
|
break;
|
|
578
|
+
case 'exit':
|
|
579
|
+
case 'quit':
|
|
580
|
+
console.log(colors.dim(' See you.'));
|
|
581
|
+
process.exit(0);
|
|
582
|
+
default: {
|
|
583
|
+
// Fuzzy match: find closest command
|
|
584
|
+
const ALL_CMD_NAMES = PALETTE_CMDS.map(c => c.name);
|
|
585
|
+
const KNOWN = [...ALL_CMD_NAMES, 'q', 'e', 'edit', 'quit'];
|
|
586
|
+
const match = KNOWN.find(k => k.startsWith(cmd));
|
|
587
|
+
if (match) {
|
|
588
|
+
console.log(colors.dim(` Did you mean /${match}?`));
|
|
589
|
+
}
|
|
590
|
+
else {
|
|
591
|
+
console.log(warning(` Unknown: /${cmd}`));
|
|
592
|
+
console.log(colors.dim(' Type / to see commands'));
|
|
593
|
+
}
|
|
236
594
|
}
|
|
237
|
-
default:
|
|
238
|
-
console.log(warning(`Unknown command: /${command}`));
|
|
239
|
-
console.log(colors.dim('Type /help to see available commands'));
|
|
240
595
|
}
|
|
241
596
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
function showSessionCostDisplay() {
|
|
246
|
-
newline();
|
|
247
|
-
console.log(colors.bold('Session Usage'));
|
|
248
|
-
console.log(colors.dim('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
|
|
249
|
-
newline();
|
|
250
|
-
const stats = sessionTokenTracker.getStats();
|
|
251
|
-
const formatTokens = (n) => {
|
|
252
|
-
if (n >= 1000000)
|
|
253
|
-
return `${(n / 1000000).toFixed(2)}M`;
|
|
254
|
-
if (n >= 1000)
|
|
255
|
-
return `${(n / 1000).toFixed(1)}k`;
|
|
256
|
-
return n.toLocaleString();
|
|
257
|
-
};
|
|
258
|
-
// Token display like Claude Code
|
|
259
|
-
console.log(colors.bold(' Tokens'));
|
|
260
|
-
console.log(` Input: ${colors.cyan('↓ ' + formatTokens(stats.inputTokens).padStart(10))}`);
|
|
261
|
-
console.log(` Output: ${colors.green('↑ ' + formatTokens(stats.outputTokens).padStart(10))}`);
|
|
262
|
-
if (stats.cacheReads > 0) {
|
|
263
|
-
console.log(` Cache: ${colors.dim(' ' + formatTokens(stats.cacheReads).padStart(10))}`);
|
|
264
|
-
}
|
|
265
|
-
newline();
|
|
266
|
-
// Cost display
|
|
267
|
-
console.log(colors.bold(' Cost'));
|
|
268
|
-
console.log(` Session: ${colors.yellow('$' + stats.totalCost.toFixed(4))}`);
|
|
269
|
-
newline();
|
|
270
|
-
// Requests count
|
|
271
|
-
const requests = sessionTokenTracker.getRequests();
|
|
272
|
-
console.log(colors.dim(` ${requests.length} API calls this session`));
|
|
273
|
-
newline();
|
|
274
|
-
// Quick summary line (like Claude Code)
|
|
275
|
-
console.log(colors.dim(' ─────────────────────────────'));
|
|
276
|
-
console.log(colors.bold(' ') + sessionTokenTracker.getDisplayString());
|
|
277
|
-
newline();
|
|
597
|
+
// ── Handlers ────────────────────────────────────────────────────────────────
|
|
598
|
+
function startSpinner(text) {
|
|
599
|
+
return ora({ text: colors.dim(text), spinner: 'dots', color: 'cyan' }).start();
|
|
278
600
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
console.log(colors.dim('━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━'));
|
|
286
|
-
newline();
|
|
287
|
-
const commands = [
|
|
288
|
-
['/fix <file> <instruction>', 'Apply AI-generated edit to a file'],
|
|
289
|
-
['/explain <file>', 'Get AI explanation of a file'],
|
|
290
|
-
['/review <file>', 'Review code quality and get suggestions'],
|
|
291
|
-
['/plan <instruction>', 'Create an implementation plan'],
|
|
292
|
-
['/cost', 'Show cost tracking status'],
|
|
293
|
-
['/trust', 'Show agent trust/reliability dashboard'],
|
|
294
|
-
['/undo', 'Undo last edit'],
|
|
295
|
-
['/status', 'Show project status'],
|
|
296
|
-
['/history', 'Show command history'],
|
|
297
|
-
['/clear', 'Clear the screen'],
|
|
298
|
-
['/help', 'Show this help message'],
|
|
299
|
-
];
|
|
300
|
-
commands.forEach(([cmd, desc]) => {
|
|
301
|
-
console.log(` ${colors.cyan(cmd.padEnd(30))} ${colors.dim(desc)}`);
|
|
302
|
-
});
|
|
303
|
-
newline();
|
|
304
|
-
console.log(colors.dim('Tip: You can also just type your question naturally!'));
|
|
305
|
-
console.log(colors.dim('Example: "how does authentication work?"'));
|
|
306
|
-
newline();
|
|
601
|
+
async function requireKey() {
|
|
602
|
+
if (!process.env.ANTHROPIC_API_KEY && !process.env.OPENAI_API_KEY && !process.env.COHERE_API_KEY && process.env.CODEHERE_FAKE_AI !== '1') {
|
|
603
|
+
console.log(warning(' No API key set. Run: codehere setup'));
|
|
604
|
+
return false;
|
|
605
|
+
}
|
|
606
|
+
return true;
|
|
307
607
|
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
*/
|
|
311
|
-
async function handleSmartQuery(query, state, rl) {
|
|
312
|
-
if (!process.env.COHERE_API_KEY) {
|
|
313
|
-
console.error(error('COHERE_API_KEY not found. Please set it in .env file.'));
|
|
608
|
+
async function handleQuery(query, state) {
|
|
609
|
+
if (!(await requireKey()))
|
|
314
610
|
return;
|
|
315
|
-
|
|
316
|
-
process.stdout.write(colors.dim(' Processing...\r'));
|
|
611
|
+
const spinner = startSpinner('Thinking...');
|
|
317
612
|
try {
|
|
318
|
-
// Use memory-aware router
|
|
319
613
|
const { container } = await import('./application/services/dependency-container.js');
|
|
320
|
-
const router = new IntelligentRouter(undefined,
|
|
321
|
-
container.aiService, container.memoryStreamService);
|
|
322
|
-
// Get conversation context for this session
|
|
614
|
+
const router = new IntelligentRouter(undefined, container.aiService, container.memoryStreamService);
|
|
323
615
|
const { conversationContextManager } = await import('./infrastructure/context/conversation-context.js');
|
|
324
616
|
const { sessionManager } = await import('./infrastructure/context/session-manager.js');
|
|
325
617
|
const sessionId = sessionManager.getSessionId(process.cwd());
|
|
@@ -328,266 +620,85 @@ async function handleSmartQuery(query, state, rl) {
|
|
|
328
620
|
query,
|
|
329
621
|
context: {
|
|
330
622
|
currentDirectory: process.cwd(),
|
|
331
|
-
conversationHistory: history.map(
|
|
332
|
-
query: turn.query,
|
|
333
|
-
response: turn.response,
|
|
334
|
-
timestamp: typeof turn.timestamp === 'string' ? Date.parse(turn.timestamp) : turn.timestamp,
|
|
335
|
-
})),
|
|
623
|
+
conversationHistory: history.map(t => ({ query: t.query, response: t.response, timestamp: typeof t.timestamp === 'string' ? Date.parse(t.timestamp) : t.timestamp })),
|
|
336
624
|
sessionId,
|
|
337
625
|
},
|
|
338
626
|
});
|
|
339
|
-
|
|
340
|
-
if (result.success) {
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
627
|
+
spinner.stop();
|
|
628
|
+
if (result.success && result.message) {
|
|
629
|
+
const { formatMarkdownForTerminal } = await import('./infrastructure/ux/stream-markdown.js');
|
|
630
|
+
console.log();
|
|
631
|
+
console.log(formatMarkdownForTerminal(result.message));
|
|
632
|
+
}
|
|
633
|
+
else if (result.error) {
|
|
634
|
+
console.log(error(' ' + result.error));
|
|
346
635
|
}
|
|
347
636
|
else {
|
|
348
|
-
|
|
349
|
-
if (result.error) {
|
|
350
|
-
console.log(error(result.error));
|
|
351
|
-
}
|
|
352
|
-
else if (result.message) {
|
|
353
|
-
console.log(warning(result.message));
|
|
354
|
-
}
|
|
637
|
+
console.log(colors.dim(' No response. Try rephrasing, or run "codehere index" first.'));
|
|
355
638
|
}
|
|
356
|
-
|
|
357
|
-
// Save to history
|
|
358
|
-
const response = result.message || result.error || 'Processed';
|
|
359
|
-
state.history.push({
|
|
360
|
-
command: query,
|
|
361
|
-
response,
|
|
362
|
-
timestamp: new Date().toISOString(),
|
|
363
|
-
});
|
|
364
|
-
// Update conversation context (reuse variables from above)
|
|
639
|
+
state.history.push({ command: query, response: result.message || result.error || '', timestamp: new Date().toISOString() });
|
|
365
640
|
const entities = conversationContextManager.extractEntities(query);
|
|
366
|
-
conversationContextManager.addTurn(sessionId, query,
|
|
641
|
+
conversationContextManager.addTurn(sessionId, query, result.message || '', entities, result.intent);
|
|
367
642
|
}
|
|
368
643
|
catch (err) {
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
/**
|
|
374
|
-
* Handle ask command (legacy - kept for compatibility)
|
|
375
|
-
*/
|
|
376
|
-
async function handleAsk(question, state, rl) {
|
|
377
|
-
if (!process.env.COHERE_API_KEY) {
|
|
378
|
-
console.error(error('COHERE_API_KEY not found. Please set it in .env file.'));
|
|
379
|
-
return;
|
|
380
|
-
}
|
|
381
|
-
// Show thinking indicator
|
|
382
|
-
process.stdout.write(colors.dim(' Thinking...\r'));
|
|
383
|
-
try {
|
|
384
|
-
// NEW: Use intelligent search
|
|
385
|
-
const searchResult = await searchIntelligent(question, {
|
|
386
|
-
baseDir: process.cwd(),
|
|
387
|
-
});
|
|
388
|
-
if (searchResult.chunks.length === 0) {
|
|
389
|
-
console.log(warning('No relevant code found. Run "codehere index" first.'));
|
|
390
|
-
return;
|
|
644
|
+
spinner.stop();
|
|
645
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
646
|
+
if (msg.includes('No embeddings') || msg.includes('not found') || msg.includes('Not found')) {
|
|
647
|
+
console.log(colors.dim(` Couldn't answer that. Try "codehere index" first, or rephrase your question.`));
|
|
391
648
|
}
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
// Show context summary
|
|
395
|
-
const retrievedFiles = [...new Set(searchResult.chunks.map(r => r.filepath))];
|
|
396
|
-
console.log(colors.dim(` Found ${formatNumber(searchResult.chunks.length)} optimized chunks from ${formatNumber(retrievedFiles.length)} file(s)`));
|
|
397
|
-
console.log(colors.dim(` Token reduction: ${formatPercent(searchResult.reductionPercent)}`));
|
|
398
|
-
// Generate response
|
|
399
|
-
process.stdout.write(colors.dim(' Generating response...\r'));
|
|
400
|
-
const response = await chatWithContext(question, searchResult.chunks);
|
|
401
|
-
process.stdout.write(' '.repeat(50) + '\r');
|
|
402
|
-
// Display response (formatted)
|
|
403
|
-
newline();
|
|
404
|
-
const formattedResponse = cleanResponse(response);
|
|
405
|
-
console.log(formattedResponse);
|
|
406
|
-
newline();
|
|
407
|
-
// Save to history
|
|
408
|
-
state.history.push({
|
|
409
|
-
command: question,
|
|
410
|
-
response,
|
|
411
|
-
timestamp: new Date().toISOString(),
|
|
412
|
-
});
|
|
413
|
-
}
|
|
414
|
-
catch (err) {
|
|
415
|
-
process.stdout.write(' '.repeat(50) + '\r');
|
|
416
|
-
throw err;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
/**
|
|
420
|
-
* Handle explain command
|
|
421
|
-
*/
|
|
422
|
-
async function handleExplain(file, rl) {
|
|
423
|
-
if (!process.env.COHERE_API_KEY) {
|
|
424
|
-
console.error(error('COHERE_API_KEY not found.'));
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
process.stdout.write(colors.dim(' Reading file...\r'));
|
|
428
|
-
try {
|
|
429
|
-
const { readFileSync, existsSync } = await import('fs');
|
|
430
|
-
const { join } = await import('path');
|
|
431
|
-
const fullPath = join(process.cwd(), file);
|
|
432
|
-
if (!existsSync(fullPath)) {
|
|
433
|
-
process.stdout.write(' '.repeat(50) + '\r');
|
|
434
|
-
console.error(error(`File not found: ${file}`));
|
|
435
|
-
return;
|
|
649
|
+
else {
|
|
650
|
+
console.log(error(' ' + msg));
|
|
436
651
|
}
|
|
437
|
-
const content = readFileSync(fullPath, 'utf-8');
|
|
438
|
-
process.stdout.write(colors.dim(' Generating explanation...\r'));
|
|
439
|
-
const context = [{
|
|
440
|
-
filepath: file,
|
|
441
|
-
content: content,
|
|
442
|
-
score: 1.0,
|
|
443
|
-
}];
|
|
444
|
-
const question = `Explain this file: ${file}`;
|
|
445
|
-
const response = await chatWithContext(question, context);
|
|
446
|
-
process.stdout.write(' '.repeat(50) + '\r');
|
|
447
|
-
newline();
|
|
448
|
-
console.log(colors.bold(`Explanation for ${file}:`));
|
|
449
|
-
const formattedResponse = cleanResponse(response);
|
|
450
|
-
console.log(formattedResponse);
|
|
451
|
-
newline();
|
|
452
|
-
}
|
|
453
|
-
catch (err) {
|
|
454
|
-
process.stdout.write(' '.repeat(50) + '\r');
|
|
455
|
-
throw err;
|
|
456
652
|
}
|
|
457
653
|
}
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
*/
|
|
461
|
-
async function handleFix(file, instruction, rl) {
|
|
462
|
-
if (!process.env.COHERE_API_KEY) {
|
|
463
|
-
console.error(error('COHERE_API_KEY not found.'));
|
|
654
|
+
async function handleExplain(file) {
|
|
655
|
+
if (!(await requireKey()))
|
|
464
656
|
return;
|
|
465
|
-
|
|
466
|
-
if (!
|
|
467
|
-
console.
|
|
657
|
+
const fullPath = join(process.cwd(), file);
|
|
658
|
+
if (!existsSync(fullPath)) {
|
|
659
|
+
console.log(error(` Not found: ${file}`));
|
|
468
660
|
return;
|
|
469
661
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
newline();
|
|
483
|
-
console.log(error('Edit failed'));
|
|
484
|
-
if (result.error) {
|
|
485
|
-
console.log(colors.red(` ${result.error}`));
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
newline();
|
|
489
|
-
}
|
|
490
|
-
catch (err) {
|
|
491
|
-
process.stdout.write(' '.repeat(50) + '\r');
|
|
492
|
-
throw err;
|
|
493
|
-
}
|
|
662
|
+
const spinner = startSpinner('Reading...');
|
|
663
|
+
const content = readFileSync(fullPath, 'utf-8');
|
|
664
|
+
const context = [{ filepath: file, content, score: 1.0 }];
|
|
665
|
+
spinner.stop();
|
|
666
|
+
console.log();
|
|
667
|
+
const md = createMarkdownStream();
|
|
668
|
+
await chatWithContextStream(`Explain this file: ${file}`, context, (token) => md.write(token));
|
|
669
|
+
md.flush();
|
|
670
|
+
console.log();
|
|
494
671
|
}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
console.error(error('COHERE_API_KEY not found.'));
|
|
672
|
+
async function handleFix(file, hint) {
|
|
673
|
+
if (!(await requireKey()))
|
|
674
|
+
return;
|
|
675
|
+
if (!hint) {
|
|
676
|
+
console.log(colors.dim(' Usage: /fix <file> <what to fix>'));
|
|
501
677
|
return;
|
|
502
678
|
}
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
const review = await reviewFile(file);
|
|
506
|
-
process.stdout.write(' '.repeat(50) + '\r');
|
|
507
|
-
newline();
|
|
508
|
-
console.log(colors.bold(`Review for ${file}:`));
|
|
509
|
-
console.log(`Score: ${review.score}/100`);
|
|
510
|
-
console.log(`Issues: ${review.issues.length}`);
|
|
511
|
-
if (review.issues.length > 0) {
|
|
512
|
-
newline();
|
|
513
|
-
review.issues.slice(0, 5).forEach(issue => {
|
|
514
|
-
const icon = issue.severity === 'error' ? '✗' : issue.severity === 'warning' ? '⚠' : '→';
|
|
515
|
-
console.log(` ${icon} ${issue.message}`);
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
newline();
|
|
519
|
-
}
|
|
520
|
-
catch (err) {
|
|
521
|
-
process.stdout.write(' '.repeat(50) + '\r');
|
|
522
|
-
throw err;
|
|
523
|
-
}
|
|
679
|
+
const { executeFixCommand } = await import('./presentation/cli/commands/fix-command.js');
|
|
680
|
+
await executeFixCommand(file, hint);
|
|
524
681
|
}
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
*/
|
|
528
|
-
async function handlePlan(instruction, rl) {
|
|
529
|
-
if (!process.env.COHERE_API_KEY) {
|
|
530
|
-
console.error(error('COHERE_API_KEY not found.'));
|
|
682
|
+
async function handleReview(file) {
|
|
683
|
+
if (!(await requireKey()))
|
|
531
684
|
return;
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
console.log(
|
|
540
|
-
newline();
|
|
541
|
-
}
|
|
542
|
-
catch (err) {
|
|
543
|
-
process.stdout.write(' '.repeat(50) + '\r');
|
|
544
|
-
throw err;
|
|
685
|
+
const spinner = startSpinner('Reviewing...');
|
|
686
|
+
const review = await reviewFile(file);
|
|
687
|
+
spinner.stop();
|
|
688
|
+
console.log();
|
|
689
|
+
console.log(colors.bold(` ${file}`) + colors.dim(` · ${review.score}/100 · ${review.issues.length} issues`));
|
|
690
|
+
for (const issue of review.issues.slice(0, 5)) {
|
|
691
|
+
const icon = issue.severity === 'error' ? colors.red('✗') : issue.severity === 'warning' ? colors.yellow('!') : colors.dim('·');
|
|
692
|
+
console.log(` ${icon} ${issue.message}`);
|
|
545
693
|
}
|
|
546
694
|
}
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
console.log(
|
|
555
|
-
console.log(colors.cyan(' /explain <file>') + ' Get AI explanation');
|
|
556
|
-
console.log(colors.cyan(' /review <file>') + ' Review code quality');
|
|
557
|
-
console.log(colors.cyan(' /plan <instruction>') + ' Create implementation plan');
|
|
558
|
-
console.log(colors.cyan(' /cost') + ' Show cost tracking');
|
|
559
|
-
console.log(colors.cyan(' /trust') + ' Show trust dashboard');
|
|
560
|
-
console.log(colors.cyan(' /undo') + ' Undo last edit');
|
|
561
|
-
console.log(colors.cyan(' /status') + ' Show project status');
|
|
562
|
-
console.log(colors.cyan(' /history') + ' Show command history');
|
|
563
|
-
console.log(colors.cyan(' /help') + ' Show all commands');
|
|
564
|
-
newline();
|
|
565
|
-
console.log(colors.bold('Quick Commands:'));
|
|
566
|
-
newline();
|
|
567
|
-
console.log(colors.cyan(' <question>') + ' Ask anything about your codebase');
|
|
568
|
-
console.log(colors.cyan(' clear') + ' Clear screen');
|
|
569
|
-
console.log(colors.cyan(' exit') + ' Exit session (or: quit, q)');
|
|
570
|
-
newline();
|
|
571
|
-
console.log(colors.dim('Examples:'));
|
|
572
|
-
console.log(colors.dim(' How does authentication work?'));
|
|
573
|
-
console.log(colors.dim(' /explain src/auth.ts'));
|
|
574
|
-
console.log(colors.dim(' /fix src/utils.js "Add error handling"'));
|
|
575
|
-
newline();
|
|
576
|
-
}
|
|
577
|
-
/**
|
|
578
|
-
* Show keyboard shortcuts (Task 7.5)
|
|
579
|
-
*/
|
|
580
|
-
function showKeyboardShortcuts() {
|
|
581
|
-
newline();
|
|
582
|
-
console.log(colors.bold('Keyboard Shortcuts:'));
|
|
583
|
-
newline();
|
|
584
|
-
console.log(colors.cyan(' ↑/↓') + ' Navigate command history');
|
|
585
|
-
console.log(colors.cyan(' Tab') + ' Autocomplete (when available)');
|
|
586
|
-
console.log(colors.cyan(' Ctrl+C') + ' Cancel current operation');
|
|
587
|
-
console.log(colors.cyan(' Ctrl+D') + ' Exit session');
|
|
588
|
-
console.log(colors.cyan(' Ctrl+L') + ' Clear screen');
|
|
589
|
-
console.log(colors.cyan(' Esc') + ' Cancel current input');
|
|
590
|
-
console.log(colors.cyan(' Enter') + ' Execute command');
|
|
591
|
-
newline();
|
|
695
|
+
async function handlePlan(goal) {
|
|
696
|
+
if (!(await requireKey()))
|
|
697
|
+
return;
|
|
698
|
+
const spinner = startSpinner('Planning...');
|
|
699
|
+
const plan = await planTask(goal);
|
|
700
|
+
spinner.stop();
|
|
701
|
+
console.log();
|
|
702
|
+
console.log(formatPlan(plan));
|
|
592
703
|
}
|
|
593
704
|
//# sourceMappingURL=session.js.map
|