codehere 0.1.0 → 0.2.0
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.
Potentially problematic release.
This version of codehere might be problematic. Click here for more details.
- package/README.md +51 -25
- package/dist/agents/base.d.ts +107 -0
- package/dist/agents/base.d.ts.map +1 -0
- package/dist/agents/base.js +101 -0
- package/dist/agents/base.js.map +1 -0
- package/dist/agents/orchestrator-model-driven.d.ts +41 -0
- package/dist/agents/orchestrator-model-driven.d.ts.map +1 -0
- package/dist/agents/orchestrator-model-driven.js +141 -0
- package/dist/agents/orchestrator-model-driven.js.map +1 -0
- package/dist/agents/react-orchestrator-agent.d.ts +15 -0
- package/dist/agents/react-orchestrator-agent.d.ts.map +1 -0
- package/dist/agents/react-orchestrator-agent.js +54 -0
- package/dist/agents/react-orchestrator-agent.js.map +1 -0
- package/dist/application/agents/execution-agent.d.ts +68 -0
- package/dist/application/agents/execution-agent.d.ts.map +1 -0
- package/dist/application/agents/execution-agent.js +299 -0
- package/dist/application/agents/execution-agent.js.map +1 -0
- package/dist/application/agents/multi-agent-orchestrator.d.ts +64 -0
- package/dist/application/agents/multi-agent-orchestrator.d.ts.map +1 -0
- package/dist/application/agents/multi-agent-orchestrator.js +209 -0
- package/dist/application/agents/multi-agent-orchestrator.js.map +1 -0
- package/dist/application/agents/planning-agent.d.ts +61 -0
- package/dist/application/agents/planning-agent.d.ts.map +1 -0
- package/dist/application/agents/planning-agent.js +357 -0
- package/dist/application/agents/planning-agent.js.map +1 -0
- package/dist/application/agents/validation-agent.d.ts +64 -0
- package/dist/application/agents/validation-agent.d.ts.map +1 -0
- package/dist/application/agents/validation-agent.js +182 -0
- package/dist/application/agents/validation-agent.js.map +1 -0
- package/dist/application/architectures/plan-and-act.d.ts +94 -0
- package/dist/application/architectures/plan-and-act.d.ts.map +1 -0
- package/dist/application/architectures/plan-and-act.js +242 -0
- package/dist/application/architectures/plan-and-act.js.map +1 -0
- package/dist/application/index.d.ts +12 -0
- package/dist/application/index.d.ts.map +1 -0
- package/dist/application/index.js +12 -0
- package/dist/application/index.js.map +1 -0
- package/dist/application/services/agent-factory.d.ts +9 -0
- package/dist/application/services/agent-factory.d.ts.map +1 -0
- package/dist/application/services/agent-factory.js +28 -0
- package/dist/application/services/agent-factory.js.map +1 -0
- package/dist/application/services/dependency-container.d.ts +140 -0
- package/dist/application/services/dependency-container.d.ts.map +1 -0
- package/dist/application/services/dependency-container.js +402 -0
- package/dist/application/services/dependency-container.js.map +1 -0
- package/dist/application/services/git-context-service.d.ts +30 -0
- package/dist/application/services/git-context-service.d.ts.map +1 -0
- package/dist/application/services/git-context-service.js +83 -0
- package/dist/application/services/git-context-service.js.map +1 -0
- package/dist/application/services/intelligent-router.d.ts +74 -0
- package/dist/application/services/intelligent-router.d.ts.map +1 -0
- package/dist/application/services/intelligent-router.js +711 -0
- package/dist/application/services/intelligent-router.js.map +1 -0
- package/dist/application/services/tool-executor-service.d.ts +14 -0
- package/dist/application/services/tool-executor-service.d.ts.map +1 -0
- package/dist/application/services/tool-executor-service.js +94 -0
- package/dist/application/services/tool-executor-service.js.map +1 -0
- package/dist/application/use-cases/ask-question-use-case.d.ts +36 -0
- package/dist/application/use-cases/ask-question-use-case.d.ts.map +1 -0
- package/dist/application/use-cases/ask-question-use-case.js +150 -0
- package/dist/application/use-cases/ask-question-use-case.js.map +1 -0
- package/dist/application/use-cases/edit-file-use-case.d.ts +76 -0
- package/dist/application/use-cases/edit-file-use-case.d.ts.map +1 -0
- package/dist/application/use-cases/edit-file-use-case.js +685 -0
- package/dist/application/use-cases/edit-file-use-case.js.map +1 -0
- package/dist/application/use-cases/explain-file-use-case.d.ts +21 -0
- package/dist/application/use-cases/explain-file-use-case.d.ts.map +1 -0
- package/dist/application/use-cases/explain-file-use-case.js +50 -0
- package/dist/application/use-cases/explain-file-use-case.js.map +1 -0
- package/dist/application/use-cases/index-codebase-use-case.d.ts +46 -0
- package/dist/application/use-cases/index-codebase-use-case.d.ts.map +1 -0
- package/dist/application/use-cases/index-codebase-use-case.js +113 -0
- package/dist/application/use-cases/index-codebase-use-case.js.map +1 -0
- package/dist/application/use-cases/planning-use-case.d.ts +46 -0
- package/dist/application/use-cases/planning-use-case.d.ts.map +1 -0
- package/dist/application/use-cases/planning-use-case.js +267 -0
- package/dist/application/use-cases/planning-use-case.js.map +1 -0
- package/dist/application/use-cases/react-orchestration-use-case.d.ts +51 -0
- package/dist/application/use-cases/react-orchestration-use-case.d.ts.map +1 -0
- package/dist/application/use-cases/react-orchestration-use-case.js +325 -0
- package/dist/application/use-cases/react-orchestration-use-case.js.map +1 -0
- package/dist/application/use-cases/reflexion-use-case.d.ts +24 -0
- package/dist/application/use-cases/reflexion-use-case.d.ts.map +1 -0
- package/dist/application/use-cases/reflexion-use-case.js +30 -0
- package/dist/application/use-cases/reflexion-use-case.js.map +1 -0
- package/dist/application/workflows/deterministic-workflows.d.ts +61 -0
- package/dist/application/workflows/deterministic-workflows.d.ts.map +1 -0
- package/dist/application/workflows/deterministic-workflows.js +189 -0
- package/dist/application/workflows/deterministic-workflows.js.map +1 -0
- package/dist/cache.d.ts.map +1 -1
- package/dist/cache.js +1 -3
- package/dist/cache.js.map +1 -1
- package/dist/chat.js +10 -10
- package/dist/chat.js.map +1 -1
- package/dist/docs.d.ts.map +1 -1
- package/dist/docs.js +1 -2
- package/dist/docs.js.map +1 -1
- package/dist/domain/entities/code-chunk.d.ts +26 -0
- package/dist/domain/entities/code-chunk.d.ts.map +1 -0
- package/dist/domain/entities/code-chunk.js +6 -0
- package/dist/domain/entities/code-chunk.js.map +1 -0
- package/dist/domain/entities/decision.d.ts +37 -0
- package/dist/domain/entities/decision.d.ts.map +1 -0
- package/dist/domain/entities/decision.js +9 -0
- package/dist/domain/entities/decision.js.map +1 -0
- package/dist/domain/entities/edit.d.ts +35 -0
- package/dist/domain/entities/edit.d.ts.map +1 -0
- package/dist/domain/entities/edit.js +6 -0
- package/dist/domain/entities/edit.js.map +1 -0
- package/dist/domain/entities/knowledge-node.d.ts +83 -0
- package/dist/domain/entities/knowledge-node.d.ts.map +1 -0
- package/dist/domain/entities/knowledge-node.js +9 -0
- package/dist/domain/entities/knowledge-node.js.map +1 -0
- package/dist/domain/entities/knowledge-preservation.d.ts +42 -0
- package/dist/domain/entities/knowledge-preservation.d.ts.map +1 -0
- package/dist/domain/entities/knowledge-preservation.js +10 -0
- package/dist/domain/entities/knowledge-preservation.js.map +1 -0
- package/dist/domain/entities/memory.d.ts +36 -0
- package/dist/domain/entities/memory.d.ts.map +1 -0
- package/dist/domain/entities/memory.js +6 -0
- package/dist/domain/entities/memory.js.map +1 -0
- package/dist/domain/entities/pattern.d.ts +49 -0
- package/dist/domain/entities/pattern.d.ts.map +1 -0
- package/dist/domain/entities/pattern.js +7 -0
- package/dist/domain/entities/pattern.js.map +1 -0
- package/dist/domain/entities/plan.d.ts +42 -0
- package/dist/domain/entities/plan.d.ts.map +1 -0
- package/dist/domain/entities/plan.js +6 -0
- package/dist/domain/entities/plan.js.map +1 -0
- package/dist/domain/entities/query.d.ts +17 -0
- package/dist/domain/entities/query.d.ts.map +1 -0
- package/dist/domain/entities/query.js +6 -0
- package/dist/domain/entities/query.js.map +1 -0
- package/dist/domain/index.d.ts +16 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +19 -0
- package/dist/domain/index.js.map +1 -0
- package/dist/domain/interfaces/ai-service.interface.d.ts +62 -0
- package/dist/domain/interfaces/ai-service.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/ai-service.interface.js +6 -0
- package/dist/domain/interfaces/ai-service.interface.js.map +1 -0
- package/dist/domain/interfaces/code-analyzer.interface.d.ts +38 -0
- package/dist/domain/interfaces/code-analyzer.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/code-analyzer.interface.js +6 -0
- package/dist/domain/interfaces/code-analyzer.interface.js.map +1 -0
- package/dist/domain/interfaces/decision-repository.interface.d.ts +51 -0
- package/dist/domain/interfaces/decision-repository.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/decision-repository.interface.js +9 -0
- package/dist/domain/interfaces/decision-repository.interface.js.map +1 -0
- package/dist/domain/interfaces/embedding-repository.interface.d.ts +28 -0
- package/dist/domain/interfaces/embedding-repository.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/embedding-repository.interface.js +6 -0
- package/dist/domain/interfaces/embedding-repository.interface.js.map +1 -0
- package/dist/domain/interfaces/knowledge-graph-repository.interface.d.ts +91 -0
- package/dist/domain/interfaces/knowledge-graph-repository.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/knowledge-graph-repository.interface.js +9 -0
- package/dist/domain/interfaces/knowledge-graph-repository.interface.js.map +1 -0
- package/dist/domain/interfaces/knowledge-preservation-repository.interface.d.ts +50 -0
- package/dist/domain/interfaces/knowledge-preservation-repository.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/knowledge-preservation-repository.interface.js +8 -0
- package/dist/domain/interfaces/knowledge-preservation-repository.interface.js.map +1 -0
- package/dist/domain/interfaces/memory-repository.interface.d.ts +49 -0
- package/dist/domain/interfaces/memory-repository.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/memory-repository.interface.js +6 -0
- package/dist/domain/interfaces/memory-repository.interface.js.map +1 -0
- package/dist/domain/interfaces/pattern-repository.interface.d.ts +48 -0
- package/dist/domain/interfaces/pattern-repository.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/pattern-repository.interface.js +6 -0
- package/dist/domain/interfaces/pattern-repository.interface.js.map +1 -0
- package/dist/domain/interfaces/verification-service.interface.d.ts +20 -0
- package/dist/domain/interfaces/verification-service.interface.d.ts.map +1 -0
- package/dist/domain/interfaces/verification-service.interface.js +6 -0
- package/dist/domain/interfaces/verification-service.interface.js.map +1 -0
- package/dist/domain/services/codebase-detector.d.ts +18 -0
- package/dist/domain/services/codebase-detector.d.ts.map +1 -0
- package/dist/domain/services/codebase-detector.js +91 -0
- package/dist/domain/services/codebase-detector.js.map +1 -0
- package/dist/domain/services/cross-team-pattern-sharing.d.ts +65 -0
- package/dist/domain/services/cross-team-pattern-sharing.d.ts.map +1 -0
- package/dist/domain/services/cross-team-pattern-sharing.js +125 -0
- package/dist/domain/services/cross-team-pattern-sharing.js.map +1 -0
- package/dist/domain/services/decision-recorder.d.ts +76 -0
- package/dist/domain/services/decision-recorder.d.ts.map +1 -0
- package/dist/domain/services/decision-recorder.js +223 -0
- package/dist/domain/services/decision-recorder.js.map +1 -0
- package/dist/domain/services/decision-retriever.d.ts +75 -0
- package/dist/domain/services/decision-retriever.d.ts.map +1 -0
- package/dist/domain/services/decision-retriever.js +133 -0
- package/dist/domain/services/decision-retriever.js.map +1 -0
- package/dist/domain/services/graded-memory-activation.d.ts +37 -0
- package/dist/domain/services/graded-memory-activation.d.ts.map +1 -0
- package/dist/domain/services/graded-memory-activation.js +69 -0
- package/dist/domain/services/graded-memory-activation.js.map +1 -0
- package/dist/domain/services/knowledge-access.d.ts +63 -0
- package/dist/domain/services/knowledge-access.d.ts.map +1 -0
- package/dist/domain/services/knowledge-access.js +132 -0
- package/dist/domain/services/knowledge-access.js.map +1 -0
- package/dist/domain/services/knowledge-extractor.d.ts +54 -0
- package/dist/domain/services/knowledge-extractor.d.ts.map +1 -0
- package/dist/domain/services/knowledge-extractor.js +247 -0
- package/dist/domain/services/knowledge-extractor.js.map +1 -0
- package/dist/domain/services/knowledge-graph-builder.d.ts +70 -0
- package/dist/domain/services/knowledge-graph-builder.d.ts.map +1 -0
- package/dist/domain/services/knowledge-graph-builder.js +268 -0
- package/dist/domain/services/knowledge-graph-builder.js.map +1 -0
- package/dist/domain/services/knowledge-graph-query.d.ts +69 -0
- package/dist/domain/services/knowledge-graph-query.d.ts.map +1 -0
- package/dist/domain/services/knowledge-graph-query.js +187 -0
- package/dist/domain/services/knowledge-graph-query.js.map +1 -0
- package/dist/domain/services/memory-retriever.d.ts +30 -0
- package/dist/domain/services/memory-retriever.d.ts.map +1 -0
- package/dist/domain/services/memory-retriever.js +82 -0
- package/dist/domain/services/memory-retriever.js.map +1 -0
- package/dist/domain/services/memory-synthesizer.d.ts +57 -0
- package/dist/domain/services/memory-synthesizer.d.ts.map +1 -0
- package/dist/domain/services/memory-synthesizer.js +91 -0
- package/dist/domain/services/memory-synthesizer.js.map +1 -0
- package/dist/domain/services/pattern-extractor.d.ts +108 -0
- package/dist/domain/services/pattern-extractor.d.ts.map +1 -0
- package/dist/domain/services/pattern-extractor.js +442 -0
- package/dist/domain/services/pattern-extractor.js.map +1 -0
- package/dist/domain/services/query-intent-classifier.d.ts +16 -0
- package/dist/domain/services/query-intent-classifier.d.ts.map +1 -0
- package/dist/domain/services/query-intent-classifier.js +140 -0
- package/dist/domain/services/query-intent-classifier.js.map +1 -0
- package/dist/domain/services/react-loop.d.ts +44 -0
- package/dist/domain/services/react-loop.d.ts.map +1 -0
- package/dist/domain/services/react-loop.js +110 -0
- package/dist/domain/services/react-loop.js.map +1 -0
- package/dist/edit.d.ts +0 -12
- package/dist/edit.d.ts.map +1 -1
- package/dist/edit.js +76 -351
- package/dist/edit.js.map +1 -1
- package/dist/embed.d.ts +0 -4
- package/dist/embed.d.ts.map +1 -1
- package/dist/embed.js +100 -174
- package/dist/embed.js.map +1 -1
- package/dist/error-handler.d.ts +1 -0
- package/dist/error-handler.d.ts.map +1 -1
- package/dist/error-handler.js +46 -3
- package/dist/error-handler.js.map +1 -1
- package/dist/index.js +228 -231
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/ai/cohere-ai-service.d.ts +54 -0
- package/dist/infrastructure/ai/cohere-ai-service.d.ts.map +1 -0
- package/dist/infrastructure/ai/cohere-ai-service.js +547 -0
- package/dist/infrastructure/ai/cohere-ai-service.js.map +1 -0
- package/dist/infrastructure/ai/command-r-evaluation.d.ts +42 -0
- package/dist/infrastructure/ai/command-r-evaluation.d.ts.map +1 -0
- package/dist/infrastructure/ai/command-r-evaluation.js +206 -0
- package/dist/infrastructure/ai/command-r-evaluation.js.map +1 -0
- package/dist/infrastructure/ai/model-config.d.ts +47 -0
- package/dist/infrastructure/ai/model-config.d.ts.map +1 -0
- package/dist/infrastructure/ai/model-config.js +84 -0
- package/dist/infrastructure/ai/model-config.js.map +1 -0
- package/dist/infrastructure/cache/embedding-cache.d.ts +46 -0
- package/dist/infrastructure/cache/embedding-cache.d.ts.map +1 -0
- package/dist/infrastructure/cache/embedding-cache.js +104 -0
- package/dist/infrastructure/cache/embedding-cache.js.map +1 -0
- package/dist/infrastructure/chunking/ast-code-chunker.d.ts +12 -0
- package/dist/infrastructure/chunking/ast-code-chunker.d.ts.map +1 -0
- package/dist/infrastructure/chunking/ast-code-chunker.js +19 -0
- package/dist/infrastructure/chunking/ast-code-chunker.js.map +1 -0
- package/dist/infrastructure/chunking/code-aware-chunker.d.ts +63 -0
- package/dist/infrastructure/chunking/code-aware-chunker.d.ts.map +1 -0
- package/dist/infrastructure/chunking/code-aware-chunker.js +397 -0
- package/dist/infrastructure/chunking/code-aware-chunker.js.map +1 -0
- package/dist/infrastructure/config/config-manager.d.ts +79 -0
- package/dist/infrastructure/config/config-manager.d.ts.map +1 -0
- package/dist/infrastructure/config/config-manager.js +162 -0
- package/dist/infrastructure/config/config-manager.js.map +1 -0
- package/dist/infrastructure/cost/cost-tracker.d.ts +90 -0
- package/dist/infrastructure/cost/cost-tracker.d.ts.map +1 -0
- package/dist/infrastructure/cost/cost-tracker.js +353 -0
- package/dist/infrastructure/cost/cost-tracker.js.map +1 -0
- package/dist/infrastructure/file-scanner/file-scanner.d.ts +31 -0
- package/dist/infrastructure/file-scanner/file-scanner.d.ts.map +1 -0
- package/dist/infrastructure/file-scanner/file-scanner.js +106 -0
- package/dist/infrastructure/file-scanner/file-scanner.js.map +1 -0
- package/dist/infrastructure/governance/nist-ai-rmf.d.ts +107 -0
- package/dist/infrastructure/governance/nist-ai-rmf.d.ts.map +1 -0
- package/dist/infrastructure/governance/nist-ai-rmf.js +294 -0
- package/dist/infrastructure/governance/nist-ai-rmf.js.map +1 -0
- package/dist/infrastructure/governance/policy-as-code.d.ts +90 -0
- package/dist/infrastructure/governance/policy-as-code.d.ts.map +1 -0
- package/dist/infrastructure/governance/policy-as-code.js +244 -0
- package/dist/infrastructure/governance/policy-as-code.js.map +1 -0
- package/dist/infrastructure/governance/prompt-to-code-lineage.d.ts +138 -0
- package/dist/infrastructure/governance/prompt-to-code-lineage.d.ts.map +1 -0
- package/dist/infrastructure/governance/prompt-to-code-lineage.js +241 -0
- package/dist/infrastructure/governance/prompt-to-code-lineage.js.map +1 -0
- package/dist/infrastructure/index.d.ts +7 -0
- package/dist/infrastructure/index.d.ts.map +1 -0
- package/dist/infrastructure/index.js +7 -0
- package/dist/infrastructure/index.js.map +1 -0
- package/dist/infrastructure/observability/execution-tracer.d.ts +105 -0
- package/dist/infrastructure/observability/execution-tracer.d.ts.map +1 -0
- package/dist/infrastructure/observability/execution-tracer.js +190 -0
- package/dist/infrastructure/observability/execution-tracer.js.map +1 -0
- package/dist/infrastructure/observability/prompt-versioner.d.ts +67 -0
- package/dist/infrastructure/observability/prompt-versioner.d.ts.map +1 -0
- package/dist/infrastructure/observability/prompt-versioner.js +145 -0
- package/dist/infrastructure/observability/prompt-versioner.js.map +1 -0
- package/dist/infrastructure/protocols/a2a-metadata.d.ts +278 -0
- package/dist/infrastructure/protocols/a2a-metadata.d.ts.map +1 -0
- package/dist/infrastructure/protocols/a2a-metadata.js +137 -0
- package/dist/infrastructure/protocols/a2a-metadata.js.map +1 -0
- package/dist/infrastructure/protocols/a2a-protocol.d.ts +132 -0
- package/dist/infrastructure/protocols/a2a-protocol.d.ts.map +1 -0
- package/dist/infrastructure/protocols/a2a-protocol.js +314 -0
- package/dist/infrastructure/protocols/a2a-protocol.js.map +1 -0
- package/dist/infrastructure/protocols/mcp-oauth.d.ts +91 -0
- package/dist/infrastructure/protocols/mcp-oauth.d.ts.map +1 -0
- package/dist/infrastructure/protocols/mcp-oauth.js +184 -0
- package/dist/infrastructure/protocols/mcp-oauth.js.map +1 -0
- package/dist/infrastructure/protocols/mcp-server.d.ts +126 -0
- package/dist/infrastructure/protocols/mcp-server.d.ts.map +1 -0
- package/dist/infrastructure/protocols/mcp-server.js +333 -0
- package/dist/infrastructure/protocols/mcp-server.js.map +1 -0
- package/dist/infrastructure/protocols/streaming-handler.d.ts +57 -0
- package/dist/infrastructure/protocols/streaming-handler.d.ts.map +1 -0
- package/dist/infrastructure/protocols/streaming-handler.js +103 -0
- package/dist/infrastructure/protocols/streaming-handler.js.map +1 -0
- package/dist/infrastructure/security/ai-sast-scanner.d.ts +55 -0
- package/dist/infrastructure/security/ai-sast-scanner.d.ts.map +1 -0
- package/dist/infrastructure/security/ai-sast-scanner.js +163 -0
- package/dist/infrastructure/security/ai-sast-scanner.js.map +1 -0
- package/dist/infrastructure/security/docker-sandbox.d.ts +57 -0
- package/dist/infrastructure/security/docker-sandbox.d.ts.map +1 -0
- package/dist/infrastructure/security/docker-sandbox.js +178 -0
- package/dist/infrastructure/security/docker-sandbox.js.map +1 -0
- package/dist/infrastructure/security/enhanced-security-gate.d.ts +51 -0
- package/dist/infrastructure/security/enhanced-security-gate.d.ts.map +1 -0
- package/dist/infrastructure/security/enhanced-security-gate.js +92 -0
- package/dist/infrastructure/security/enhanced-security-gate.js.map +1 -0
- package/dist/infrastructure/security/input-validator.d.ts +33 -0
- package/dist/infrastructure/security/input-validator.d.ts.map +1 -0
- package/dist/infrastructure/security/input-validator.js +152 -0
- package/dist/infrastructure/security/input-validator.js.map +1 -0
- package/dist/infrastructure/security/license-scanner.d.ts +55 -0
- package/dist/infrastructure/security/license-scanner.d.ts.map +1 -0
- package/dist/infrastructure/security/license-scanner.js +167 -0
- package/dist/infrastructure/security/license-scanner.js.map +1 -0
- package/dist/infrastructure/security/provider-bias-detector.d.ts +53 -0
- package/dist/infrastructure/security/provider-bias-detector.d.ts.map +1 -0
- package/dist/infrastructure/security/provider-bias-detector.js +164 -0
- package/dist/infrastructure/security/provider-bias-detector.js.map +1 -0
- package/dist/infrastructure/security/sandbox-executor.d.ts +34 -0
- package/dist/infrastructure/security/sandbox-executor.d.ts.map +1 -0
- package/dist/infrastructure/security/sandbox-executor.js +64 -0
- package/dist/infrastructure/security/sandbox-executor.js.map +1 -0
- package/dist/infrastructure/storage/memory-stream-service.d.ts +47 -0
- package/dist/infrastructure/storage/memory-stream-service.d.ts.map +1 -0
- package/dist/infrastructure/storage/memory-stream-service.js +204 -0
- package/dist/infrastructure/storage/memory-stream-service.js.map +1 -0
- package/dist/infrastructure/storage/sqlite-decision-repository.d.ts +29 -0
- package/dist/infrastructure/storage/sqlite-decision-repository.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite-decision-repository.js +232 -0
- package/dist/infrastructure/storage/sqlite-decision-repository.js.map +1 -0
- package/dist/infrastructure/storage/sqlite-embedding-repository.d.ts +24 -0
- package/dist/infrastructure/storage/sqlite-embedding-repository.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite-embedding-repository.js +162 -0
- package/dist/infrastructure/storage/sqlite-embedding-repository.js.map +1 -0
- package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.d.ts +41 -0
- package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.js +417 -0
- package/dist/infrastructure/storage/sqlite-knowledge-graph-repository.js.map +1 -0
- package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.d.ts +29 -0
- package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.js +230 -0
- package/dist/infrastructure/storage/sqlite-knowledge-preservation-repository.js.map +1 -0
- package/dist/infrastructure/storage/sqlite-memory-repository.d.ts +40 -0
- package/dist/infrastructure/storage/sqlite-memory-repository.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite-memory-repository.js +229 -0
- package/dist/infrastructure/storage/sqlite-memory-repository.js.map +1 -0
- package/dist/infrastructure/storage/sqlite-pattern-repository.d.ts +25 -0
- package/dist/infrastructure/storage/sqlite-pattern-repository.d.ts.map +1 -0
- package/dist/infrastructure/storage/sqlite-pattern-repository.js +249 -0
- package/dist/infrastructure/storage/sqlite-pattern-repository.js.map +1 -0
- package/dist/infrastructure/ux/appropriate-friction.d.ts +77 -0
- package/dist/infrastructure/ux/appropriate-friction.d.ts.map +1 -0
- package/dist/infrastructure/ux/appropriate-friction.js +213 -0
- package/dist/infrastructure/ux/appropriate-friction.js.map +1 -0
- package/dist/infrastructure/ux/bi-directional-learning.d.ts +109 -0
- package/dist/infrastructure/ux/bi-directional-learning.d.ts.map +1 -0
- package/dist/infrastructure/ux/bi-directional-learning.js +200 -0
- package/dist/infrastructure/ux/bi-directional-learning.js.map +1 -0
- package/dist/infrastructure/ux/expectation-management.d.ts +65 -0
- package/dist/infrastructure/ux/expectation-management.d.ts.map +1 -0
- package/dist/infrastructure/ux/expectation-management.js +193 -0
- package/dist/infrastructure/ux/expectation-management.js.map +1 -0
- package/dist/infrastructure/ux/hitl-validation.d.ts +104 -0
- package/dist/infrastructure/ux/hitl-validation.d.ts.map +1 -0
- package/dist/infrastructure/ux/hitl-validation.js +211 -0
- package/dist/infrastructure/ux/hitl-validation.js.map +1 -0
- package/dist/infrastructure/ux/progressive-disclosure.d.ts +84 -0
- package/dist/infrastructure/ux/progressive-disclosure.d.ts.map +1 -0
- package/dist/infrastructure/ux/progressive-disclosure.js +235 -0
- package/dist/infrastructure/ux/progressive-disclosure.js.map +1 -0
- package/dist/infrastructure/ux/team-standards.d.ts +94 -0
- package/dist/infrastructure/ux/team-standards.d.ts.map +1 -0
- package/dist/infrastructure/ux/team-standards.js +196 -0
- package/dist/infrastructure/ux/team-standards.js.map +1 -0
- package/dist/infrastructure/verification/verification-service.d.ts +12 -0
- package/dist/infrastructure/verification/verification-service.d.ts.map +1 -0
- package/dist/infrastructure/verification/verification-service.js +47 -0
- package/dist/infrastructure/verification/verification-service.js.map +1 -0
- package/dist/infrastructure/xai/attention-visualizer.d.ts +73 -0
- package/dist/infrastructure/xai/attention-visualizer.d.ts.map +1 -0
- package/dist/infrastructure/xai/attention-visualizer.js +174 -0
- package/dist/infrastructure/xai/attention-visualizer.js.map +1 -0
- package/dist/infrastructure/xai/cot-visualizer.d.ts +105 -0
- package/dist/infrastructure/xai/cot-visualizer.d.ts.map +1 -0
- package/dist/infrastructure/xai/cot-visualizer.js +239 -0
- package/dist/infrastructure/xai/cot-visualizer.js.map +1 -0
- package/dist/infrastructure/xai/decision-tree-log.d.ts +104 -0
- package/dist/infrastructure/xai/decision-tree-log.d.ts.map +1 -0
- package/dist/infrastructure/xai/decision-tree-log.js +216 -0
- package/dist/infrastructure/xai/decision-tree-log.js.map +1 -0
- package/dist/infrastructure/xai/interactive-xai.d.ts +106 -0
- package/dist/infrastructure/xai/interactive-xai.d.ts.map +1 -0
- package/dist/infrastructure/xai/interactive-xai.js +262 -0
- package/dist/infrastructure/xai/interactive-xai.js.map +1 -0
- package/dist/infrastructure/xai/uncertainty-quantifier.d.ts +80 -0
- package/dist/infrastructure/xai/uncertainty-quantifier.d.ts.map +1 -0
- package/dist/infrastructure/xai/uncertainty-quantifier.js +201 -0
- package/dist/infrastructure/xai/uncertainty-quantifier.js.map +1 -0
- package/dist/intelligent-retrieval.d.ts.map +1 -1
- package/dist/intelligent-retrieval.js +8 -1
- package/dist/intelligent-retrieval.js.map +1 -1
- package/dist/intent/classifier.d.ts +6 -0
- package/dist/intent/classifier.d.ts.map +1 -0
- package/dist/intent/classifier.js +2 -0
- package/dist/intent/classifier.js.map +1 -0
- package/dist/intent/context.d.ts +4 -0
- package/dist/intent/context.d.ts.map +1 -0
- package/dist/intent/context.js +2 -0
- package/dist/intent/context.js.map +1 -0
- package/dist/iterative-refinement.d.ts.map +1 -1
- package/dist/iterative-refinement.js +20 -3
- package/dist/iterative-refinement.js.map +1 -1
- package/dist/learning.d.ts.map +1 -1
- package/dist/learning.js +1 -2
- package/dist/learning.js.map +1 -1
- package/dist/monitoring.d.ts.map +1 -1
- package/dist/monitoring.js +1 -2
- package/dist/monitoring.js.map +1 -1
- package/dist/parallel-processor.d.ts +3 -2
- package/dist/parallel-processor.d.ts.map +1 -1
- package/dist/parallel-processor.js +183 -56
- package/dist/parallel-processor.js.map +1 -1
- package/dist/presentation/cli/commands/ask-command.d.ts +8 -0
- package/dist/presentation/cli/commands/ask-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/ask-command.js +133 -0
- package/dist/presentation/cli/commands/ask-command.js.map +1 -0
- package/dist/presentation/cli/commands/config-command.d.ts +9 -0
- package/dist/presentation/cli/commands/config-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/config-command.js +123 -0
- package/dist/presentation/cli/commands/config-command.js.map +1 -0
- package/dist/presentation/cli/commands/cost-command.d.ts +8 -0
- package/dist/presentation/cli/commands/cost-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/cost-command.js +191 -0
- package/dist/presentation/cli/commands/cost-command.js.map +1 -0
- package/dist/presentation/cli/commands/decision-command.d.ts +12 -0
- package/dist/presentation/cli/commands/decision-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/decision-command.js +207 -0
- package/dist/presentation/cli/commands/decision-command.js.map +1 -0
- package/dist/presentation/cli/commands/help-command.d.ts +9 -0
- package/dist/presentation/cli/commands/help-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/help-command.js +281 -0
- package/dist/presentation/cli/commands/help-command.js.map +1 -0
- package/dist/presentation/cli/commands/knowledge-command.d.ts +13 -0
- package/dist/presentation/cli/commands/knowledge-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/knowledge-command.js +129 -0
- package/dist/presentation/cli/commands/knowledge-command.js.map +1 -0
- package/dist/presentation/cli/commands/learning-dashboard-command.d.ts +8 -0
- package/dist/presentation/cli/commands/learning-dashboard-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/learning-dashboard-command.js +183 -0
- package/dist/presentation/cli/commands/learning-dashboard-command.js.map +1 -0
- package/dist/presentation/cli/commands/orchestrate-command.d.ts +8 -0
- package/dist/presentation/cli/commands/orchestrate-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/orchestrate-command.js +112 -0
- package/dist/presentation/cli/commands/orchestrate-command.js.map +1 -0
- package/dist/presentation/cli/commands/plan-command.d.ts +8 -0
- package/dist/presentation/cli/commands/plan-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/plan-command.js +114 -0
- package/dist/presentation/cli/commands/plan-command.js.map +1 -0
- package/dist/presentation/cli/commands/react-command.d.ts +8 -0
- package/dist/presentation/cli/commands/react-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/react-command.js +99 -0
- package/dist/presentation/cli/commands/react-command.js.map +1 -0
- package/dist/presentation/cli/commands/setup-command.d.ts +10 -0
- package/dist/presentation/cli/commands/setup-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/setup-command.js +231 -0
- package/dist/presentation/cli/commands/setup-command.js.map +1 -0
- package/dist/presentation/cli/commands/smart-command.d.ts +6 -0
- package/dist/presentation/cli/commands/smart-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/smart-command.js +212 -0
- package/dist/presentation/cli/commands/smart-command.js.map +1 -0
- package/dist/presentation/cli/commands/trace-command.d.ts +8 -0
- package/dist/presentation/cli/commands/trace-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/trace-command.js +125 -0
- package/dist/presentation/cli/commands/trace-command.js.map +1 -0
- package/dist/presentation/cli/commands/undo-command.d.ts +8 -0
- package/dist/presentation/cli/commands/undo-command.d.ts.map +1 -0
- package/dist/presentation/cli/commands/undo-command.js +141 -0
- package/dist/presentation/cli/commands/undo-command.js.map +1 -0
- package/dist/presentation/cli/error-display.d.ts +23 -0
- package/dist/presentation/cli/error-display.d.ts.map +1 -0
- package/dist/presentation/cli/error-display.js +122 -0
- package/dist/presentation/cli/error-display.js.map +1 -0
- package/dist/refactor.d.ts.map +1 -1
- package/dist/refactor.js +2 -4
- package/dist/refactor.js.map +1 -1
- package/dist/search.d.ts.map +1 -1
- package/dist/search.js +2 -63
- package/dist/search.js.map +1 -1
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +52 -3
- package/dist/session.js.map +1 -1
- package/dist/testgen.d.ts.map +1 -1
- package/dist/testgen.js +1 -2
- package/dist/testgen.js.map +1 -1
- package/dist/tools/bash.d.ts +53 -0
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/bash.js +213 -0
- package/dist/tools/bash.js.map +1 -0
- package/dist/tools/edit.d.ts +48 -0
- package/dist/tools/edit.d.ts.map +1 -0
- package/dist/tools/edit.js +235 -0
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/executor.d.ts +29 -0
- package/dist/tools/executor.d.ts.map +1 -0
- package/dist/tools/executor.js +153 -0
- package/dist/tools/executor.js.map +1 -0
- package/dist/tools/git-tool.d.ts +87 -0
- package/dist/tools/git-tool.d.ts.map +1 -0
- package/dist/tools/git-tool.js +292 -0
- package/dist/tools/git-tool.js.map +1 -0
- package/dist/tools/parser.d.ts +33 -0
- package/dist/tools/parser.d.ts.map +1 -0
- package/dist/tools/parser.js +158 -0
- package/dist/tools/parser.js.map +1 -0
- package/dist/tools/registry.d.ts +74 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +302 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/search.d.ts +41 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +100 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/ui.d.ts.map +1 -1
- package/dist/ui.js +4 -2
- package/dist/ui.js.map +1 -1
- package/dist/utils/check-api-status.d.ts +12 -0
- package/dist/utils/check-api-status.d.ts.map +1 -0
- package/dist/utils/check-api-status.js +82 -0
- package/dist/utils/check-api-status.js.map +1 -0
- package/dist/utils/diff-parser.d.ts +22 -0
- package/dist/utils/diff-parser.d.ts.map +1 -0
- package/dist/utils/diff-parser.js +160 -0
- package/dist/utils/diff-parser.js.map +1 -0
- package/dist/utils/logger.d.ts +34 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +56 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/version.d.ts +21 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +52 -0
- package/dist/utils/version.js.map +1 -0
- package/dist/verification/backup.d.ts +30 -0
- package/dist/verification/backup.d.ts.map +1 -0
- package/dist/verification/backup.js +238 -0
- package/dist/verification/backup.js.map +1 -0
- package/dist/verification/compiler.d.ts +20 -0
- package/dist/verification/compiler.d.ts.map +1 -0
- package/dist/verification/compiler.js +228 -0
- package/dist/verification/compiler.js.map +1 -0
- package/dist/verification/index.d.ts +59 -0
- package/dist/verification/index.d.ts.map +1 -0
- package/dist/verification/index.js +273 -0
- package/dist/verification/index.js.map +1 -0
- package/dist/verification/test-runner.d.ts +27 -0
- package/dist/verification/test-runner.d.ts.map +1 -0
- package/dist/verification/test-runner.js +379 -0
- package/dist/verification/test-runner.js.map +1 -0
- package/package.json +39 -14
- package/ARCHITECTURE.md +0 -240
- package/CHANGELOG.md +0 -44
- package/CONTRIBUTING.md +0 -171
- package/dist/benchmark.d.ts +0 -39
- package/dist/benchmark.d.ts.map +0 -1
- package/dist/benchmark.js +0 -195
- package/dist/benchmark.js.map +0 -1
- package/dist/scaffold.d.ts +0 -14
- package/dist/scaffold.d.ts.map +0 -1
- package/dist/scaffold.js +0 -85
- package/dist/scaffold.js.map +0 -1
- package/templates/next-page/app/layout.tsx +0 -19
- package/templates/next-page/app/page.tsx +0 -10
- package/templates/next-page/package.json +0 -22
- package/templates/node-api/index.js +0 -57
- package/templates/node-api/package.json +0 -13
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Infrastructure: Cost Tracker
|
|
3
|
+
* Tracks API costs per operation and provides budget alerts
|
|
4
|
+
*
|
|
5
|
+
* IMPORTANT: This is a LOCAL ESTIMATE based on token counts and pricing.
|
|
6
|
+
* It does NOT sync with actual Cohere billing dashboard.
|
|
7
|
+
* Use `codehere cost reset` to reset for new billing period.
|
|
8
|
+
*
|
|
9
|
+
* Clean Architecture: Infrastructure Layer
|
|
10
|
+
* Strategic: Provides cost visibility and budget alerts (local estimate only)
|
|
11
|
+
*/
|
|
12
|
+
export interface CostRecord {
|
|
13
|
+
id: string;
|
|
14
|
+
timestamp: number;
|
|
15
|
+
operation: string;
|
|
16
|
+
operationType: 'chat' | 'embed' | 'rerank' | 'other';
|
|
17
|
+
model?: string;
|
|
18
|
+
inputTokens?: number;
|
|
19
|
+
outputTokens?: number;
|
|
20
|
+
cost: number;
|
|
21
|
+
runId?: string;
|
|
22
|
+
metadata?: Record<string, any>;
|
|
23
|
+
}
|
|
24
|
+
export interface CostSummary {
|
|
25
|
+
totalCost: number;
|
|
26
|
+
operationCount: number;
|
|
27
|
+
byOperation: Record<string, {
|
|
28
|
+
count: number;
|
|
29
|
+
cost: number;
|
|
30
|
+
}>;
|
|
31
|
+
byModel: Record<string, {
|
|
32
|
+
count: number;
|
|
33
|
+
cost: number;
|
|
34
|
+
}>;
|
|
35
|
+
dailyCost: number;
|
|
36
|
+
monthlyCost: number;
|
|
37
|
+
}
|
|
38
|
+
export declare class CostTracker {
|
|
39
|
+
private db;
|
|
40
|
+
private dbPath;
|
|
41
|
+
private budgetLimit;
|
|
42
|
+
private alertThreshold;
|
|
43
|
+
constructor(budgetLimit?: number | null, alertThreshold?: number);
|
|
44
|
+
private getDb;
|
|
45
|
+
private saveDb;
|
|
46
|
+
/**
|
|
47
|
+
* Calculate cost for an operation
|
|
48
|
+
*/
|
|
49
|
+
calculateCost(operationType: 'chat' | 'embed' | 'rerank' | 'other', model?: string, inputTokens?: number, outputTokens?: number): number;
|
|
50
|
+
/**
|
|
51
|
+
* Record a cost
|
|
52
|
+
*/
|
|
53
|
+
recordCost(record: Omit<CostRecord, 'id' | 'timestamp'>): Promise<void>;
|
|
54
|
+
/**
|
|
55
|
+
* Get cost summary
|
|
56
|
+
*/
|
|
57
|
+
getSummary(timeRange?: {
|
|
58
|
+
start: number;
|
|
59
|
+
end: number;
|
|
60
|
+
}): Promise<CostSummary>;
|
|
61
|
+
/**
|
|
62
|
+
* Get costs for a specific run
|
|
63
|
+
*/
|
|
64
|
+
getRunCosts(runId: string): Promise<CostRecord[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Check budget and alert if threshold exceeded
|
|
67
|
+
* NOTE: This does NOT block API calls - it only warns
|
|
68
|
+
*/
|
|
69
|
+
private checkBudget;
|
|
70
|
+
/**
|
|
71
|
+
* Get current budget status
|
|
72
|
+
*/
|
|
73
|
+
getBudgetStatus(): Promise<{
|
|
74
|
+
spent: number;
|
|
75
|
+
limit: number | null;
|
|
76
|
+
remaining: number | null;
|
|
77
|
+
percentage: number | null;
|
|
78
|
+
alert: boolean;
|
|
79
|
+
}>;
|
|
80
|
+
/**
|
|
81
|
+
* Get budget limit
|
|
82
|
+
*/
|
|
83
|
+
getBudgetLimit(): number | null;
|
|
84
|
+
/**
|
|
85
|
+
* Reset costs (for testing or new billing period)
|
|
86
|
+
*/
|
|
87
|
+
resetCosts(): Promise<void>;
|
|
88
|
+
}
|
|
89
|
+
export declare function getCostTracker(budgetLimit?: number | null): CostTracker;
|
|
90
|
+
//# sourceMappingURL=cost-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost-tracker.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/cost/cost-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAUH,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;IACrD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,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AM,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IAiDvD;;;OAGG;YACW,WAAW;IAqBzB;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC;QAC/B,KAAK,EAAE,MAAM,CAAC;QACd,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,KAAK,EAAE,OAAO,CAAC;KAChB,CAAC;IA0BF;;OAEG;IACH,cAAc,IAAI,MAAM,GAAG,IAAI;IAI/B;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAKlC;AAKD,wBAAgB,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,CAQvE"}
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Infrastructure: Cost Tracker
|
|
3
|
+
* Tracks API costs per operation and provides budget alerts
|
|
4
|
+
*
|
|
5
|
+
* IMPORTANT: This is a LOCAL ESTIMATE based on token counts and pricing.
|
|
6
|
+
* It does NOT sync with actual Cohere billing dashboard.
|
|
7
|
+
* Use `codehere cost reset` to reset for new billing period.
|
|
8
|
+
*
|
|
9
|
+
* Clean Architecture: Infrastructure Layer
|
|
10
|
+
* Strategic: Provides cost visibility and budget alerts (local estimate only)
|
|
11
|
+
*/
|
|
12
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
|
|
13
|
+
import { join, dirname } from 'path';
|
|
14
|
+
import { fileURLToPath } from 'url';
|
|
15
|
+
import initSqlJs from 'sql.js';
|
|
16
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
17
|
+
const __dirname = dirname(__filename);
|
|
18
|
+
// Cohere pricing (as of 2024, update as needed)
|
|
19
|
+
// These are approximate - check Cohere pricing page for exact rates
|
|
20
|
+
const PRICING = {
|
|
21
|
+
'command-r-plus': {
|
|
22
|
+
input: 0.000003, // $3 per 1M input tokens
|
|
23
|
+
output: 0.000015, // $15 per 1M output tokens
|
|
24
|
+
},
|
|
25
|
+
'command-r': {
|
|
26
|
+
input: 0.0000005, // $0.5 per 1M input tokens
|
|
27
|
+
output: 0.0000015, // $1.5 per 1M output tokens
|
|
28
|
+
},
|
|
29
|
+
'embed-english-v3.0': {
|
|
30
|
+
input: 0.0000001, // $0.1 per 1M tokens
|
|
31
|
+
output: 0,
|
|
32
|
+
},
|
|
33
|
+
'rerank-english-v3': {
|
|
34
|
+
input: 0.000001, // $1 per 1M tokens
|
|
35
|
+
output: 0,
|
|
36
|
+
},
|
|
37
|
+
'default': {
|
|
38
|
+
input: 0.000003, // Conservative default
|
|
39
|
+
output: 0.000015,
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
export class CostTracker {
|
|
43
|
+
db = null;
|
|
44
|
+
dbPath;
|
|
45
|
+
budgetLimit; // null = no budget limit
|
|
46
|
+
alertThreshold; // Alert at 80% of budget
|
|
47
|
+
constructor(budgetLimit, alertThreshold = 0.8) {
|
|
48
|
+
const agentDir = join(__dirname, '../../..');
|
|
49
|
+
const dataDir = join(agentDir, 'data');
|
|
50
|
+
if (!existsSync(dataDir)) {
|
|
51
|
+
mkdirSync(dataDir, { recursive: true });
|
|
52
|
+
}
|
|
53
|
+
this.dbPath = join(dataDir, 'costs.sqlite');
|
|
54
|
+
// Only set budget if explicitly provided via env var or parameter
|
|
55
|
+
// null = no budget tracking (default)
|
|
56
|
+
if (budgetLimit !== undefined) {
|
|
57
|
+
this.budgetLimit = (budgetLimit !== null && budgetLimit > 0) ? budgetLimit : null;
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
const envBudget = process.env.COHERE_BUDGET_LIMIT;
|
|
61
|
+
this.budgetLimit = envBudget ? parseFloat(envBudget) : null;
|
|
62
|
+
if (this.budgetLimit !== null && this.budgetLimit <= 0) {
|
|
63
|
+
this.budgetLimit = null;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
this.alertThreshold = alertThreshold;
|
|
67
|
+
}
|
|
68
|
+
async getDb() {
|
|
69
|
+
if (this.db)
|
|
70
|
+
return this.db;
|
|
71
|
+
const SQL = await initSqlJs();
|
|
72
|
+
const dbDir = dirname(this.dbPath);
|
|
73
|
+
if (!existsSync(dbDir)) {
|
|
74
|
+
mkdirSync(dbDir, { recursive: true });
|
|
75
|
+
}
|
|
76
|
+
if (existsSync(this.dbPath)) {
|
|
77
|
+
const buffer = readFileSync(this.dbPath);
|
|
78
|
+
this.db = new SQL.Database(buffer);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
this.db = new SQL.Database();
|
|
82
|
+
}
|
|
83
|
+
// Initialize schema
|
|
84
|
+
this.db.run(`
|
|
85
|
+
CREATE TABLE IF NOT EXISTS costs (
|
|
86
|
+
id TEXT PRIMARY KEY,
|
|
87
|
+
timestamp INTEGER NOT NULL,
|
|
88
|
+
operation TEXT NOT NULL,
|
|
89
|
+
operation_type TEXT NOT NULL,
|
|
90
|
+
model TEXT,
|
|
91
|
+
input_tokens INTEGER,
|
|
92
|
+
output_tokens INTEGER,
|
|
93
|
+
cost REAL NOT NULL,
|
|
94
|
+
run_id TEXT,
|
|
95
|
+
metadata TEXT
|
|
96
|
+
);
|
|
97
|
+
`);
|
|
98
|
+
// Create indices (sql.js doesn't support CREATE INDEX IF NOT EXISTS, so we'll handle errors)
|
|
99
|
+
try {
|
|
100
|
+
this.db.run('CREATE INDEX idx_timestamp ON costs(timestamp);');
|
|
101
|
+
}
|
|
102
|
+
catch { }
|
|
103
|
+
try {
|
|
104
|
+
this.db.run('CREATE INDEX idx_operation ON costs(operation);');
|
|
105
|
+
}
|
|
106
|
+
catch { }
|
|
107
|
+
try {
|
|
108
|
+
this.db.run('CREATE INDEX idx_run_id ON costs(run_id);');
|
|
109
|
+
}
|
|
110
|
+
catch { }
|
|
111
|
+
return this.db;
|
|
112
|
+
}
|
|
113
|
+
async saveDb() {
|
|
114
|
+
if (!this.db)
|
|
115
|
+
return;
|
|
116
|
+
const buffer = this.db.export();
|
|
117
|
+
writeFileSync(this.dbPath, buffer);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Calculate cost for an operation
|
|
121
|
+
*/
|
|
122
|
+
calculateCost(operationType, model = 'default', inputTokens, outputTokens) {
|
|
123
|
+
const pricing = PRICING[model] || PRICING.default;
|
|
124
|
+
let cost = 0;
|
|
125
|
+
if (operationType === 'chat') {
|
|
126
|
+
const inputCost = (inputTokens || 0) * pricing.input;
|
|
127
|
+
const outputCost = (outputTokens || 0) * pricing.output;
|
|
128
|
+
cost = inputCost + outputCost;
|
|
129
|
+
}
|
|
130
|
+
else if (operationType === 'embed') {
|
|
131
|
+
cost = (inputTokens || 0) * pricing.input;
|
|
132
|
+
}
|
|
133
|
+
else if (operationType === 'rerank') {
|
|
134
|
+
cost = (inputTokens || 0) * pricing.input;
|
|
135
|
+
}
|
|
136
|
+
return cost;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Record a cost
|
|
140
|
+
*/
|
|
141
|
+
async recordCost(record) {
|
|
142
|
+
const db = await this.getDb();
|
|
143
|
+
const id = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
144
|
+
const timestamp = Date.now();
|
|
145
|
+
db.run(`
|
|
146
|
+
INSERT INTO costs (id, timestamp, operation, operation_type, model, input_tokens, output_tokens, cost, run_id, metadata)
|
|
147
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
148
|
+
`, [
|
|
149
|
+
id,
|
|
150
|
+
timestamp,
|
|
151
|
+
record.operation,
|
|
152
|
+
record.operationType,
|
|
153
|
+
record.model || null,
|
|
154
|
+
record.inputTokens || null,
|
|
155
|
+
record.outputTokens || null,
|
|
156
|
+
record.cost,
|
|
157
|
+
record.runId || null,
|
|
158
|
+
record.metadata ? JSON.stringify(record.metadata) : null
|
|
159
|
+
]);
|
|
160
|
+
await this.saveDb();
|
|
161
|
+
// Check budget and alert if needed
|
|
162
|
+
await this.checkBudget();
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Get cost summary
|
|
166
|
+
*/
|
|
167
|
+
async getSummary(timeRange) {
|
|
168
|
+
const db = await this.getDb();
|
|
169
|
+
let query = `
|
|
170
|
+
SELECT
|
|
171
|
+
operation,
|
|
172
|
+
operation_type,
|
|
173
|
+
model,
|
|
174
|
+
COUNT(*) as count,
|
|
175
|
+
SUM(cost) as total_cost
|
|
176
|
+
FROM costs
|
|
177
|
+
`;
|
|
178
|
+
const params = [];
|
|
179
|
+
if (timeRange) {
|
|
180
|
+
query += ' WHERE timestamp >= ? AND timestamp <= ?';
|
|
181
|
+
params.push(timeRange.start, timeRange.end);
|
|
182
|
+
}
|
|
183
|
+
query += ' GROUP BY operation, operation_type, model';
|
|
184
|
+
const stmt = db.prepare(query);
|
|
185
|
+
if (params.length > 0) {
|
|
186
|
+
stmt.bind(params);
|
|
187
|
+
}
|
|
188
|
+
const rows = [];
|
|
189
|
+
while (stmt.step()) {
|
|
190
|
+
const row = stmt.getAsObject();
|
|
191
|
+
rows.push({
|
|
192
|
+
operation: row.operation,
|
|
193
|
+
operation_type: row.operation_type,
|
|
194
|
+
model: row.model,
|
|
195
|
+
count: row.count,
|
|
196
|
+
total_cost: row.total_cost,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
stmt.free();
|
|
200
|
+
const byOperation = {};
|
|
201
|
+
const byModel = {};
|
|
202
|
+
let totalCost = 0;
|
|
203
|
+
let operationCount = 0;
|
|
204
|
+
rows.forEach(row => {
|
|
205
|
+
totalCost += row.total_cost;
|
|
206
|
+
operationCount += row.count;
|
|
207
|
+
if (!byOperation[row.operation]) {
|
|
208
|
+
byOperation[row.operation] = { count: 0, cost: 0 };
|
|
209
|
+
}
|
|
210
|
+
byOperation[row.operation].count += row.count;
|
|
211
|
+
byOperation[row.operation].cost += row.total_cost;
|
|
212
|
+
const modelKey = row.model || 'default';
|
|
213
|
+
if (!byModel[modelKey]) {
|
|
214
|
+
byModel[modelKey] = { count: 0, cost: 0 };
|
|
215
|
+
}
|
|
216
|
+
byModel[modelKey].count += row.count;
|
|
217
|
+
byModel[modelKey].cost += row.total_cost;
|
|
218
|
+
});
|
|
219
|
+
// Calculate daily and monthly costs
|
|
220
|
+
const now = Date.now();
|
|
221
|
+
const oneDayAgo = now - (24 * 60 * 60 * 1000);
|
|
222
|
+
const oneMonthAgo = now - (30 * 24 * 60 * 60 * 1000);
|
|
223
|
+
const dailyStmt = db.prepare('SELECT SUM(cost) as total FROM costs WHERE timestamp >= ?');
|
|
224
|
+
dailyStmt.bind([oneDayAgo]);
|
|
225
|
+
dailyStmt.step();
|
|
226
|
+
const dailyRow = dailyStmt.getAsObject();
|
|
227
|
+
dailyStmt.free();
|
|
228
|
+
const monthlyStmt = db.prepare('SELECT SUM(cost) as total FROM costs WHERE timestamp >= ?');
|
|
229
|
+
monthlyStmt.bind([oneMonthAgo]);
|
|
230
|
+
monthlyStmt.step();
|
|
231
|
+
const monthlyRow = monthlyStmt.getAsObject();
|
|
232
|
+
monthlyStmt.free();
|
|
233
|
+
return {
|
|
234
|
+
totalCost,
|
|
235
|
+
operationCount,
|
|
236
|
+
byOperation,
|
|
237
|
+
byModel,
|
|
238
|
+
dailyCost: dailyRow.total || 0,
|
|
239
|
+
monthlyCost: monthlyRow.total || 0,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Get costs for a specific run
|
|
244
|
+
*/
|
|
245
|
+
async getRunCosts(runId) {
|
|
246
|
+
const db = await this.getDb();
|
|
247
|
+
const stmt = db.prepare('SELECT * FROM costs WHERE run_id = ? ORDER BY timestamp');
|
|
248
|
+
stmt.bind([runId]);
|
|
249
|
+
const rows = [];
|
|
250
|
+
while (stmt.step()) {
|
|
251
|
+
const row = stmt.getAsObject();
|
|
252
|
+
rows.push({
|
|
253
|
+
id: row.id,
|
|
254
|
+
timestamp: row.timestamp,
|
|
255
|
+
operation: row.operation,
|
|
256
|
+
operation_type: row.operation_type,
|
|
257
|
+
model: row.model,
|
|
258
|
+
input_tokens: row.input_tokens,
|
|
259
|
+
output_tokens: row.output_tokens,
|
|
260
|
+
cost: row.cost,
|
|
261
|
+
run_id: row.run_id,
|
|
262
|
+
metadata: row.metadata,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
stmt.free();
|
|
266
|
+
return rows.map(row => ({
|
|
267
|
+
id: row.id,
|
|
268
|
+
timestamp: row.timestamp,
|
|
269
|
+
operation: row.operation,
|
|
270
|
+
operationType: row.operation_type,
|
|
271
|
+
model: row.model || undefined,
|
|
272
|
+
inputTokens: row.input_tokens || undefined,
|
|
273
|
+
outputTokens: row.output_tokens || undefined,
|
|
274
|
+
cost: row.cost,
|
|
275
|
+
runId: row.run_id || undefined,
|
|
276
|
+
metadata: row.metadata ? JSON.parse(row.metadata) : undefined,
|
|
277
|
+
}));
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Check budget and alert if threshold exceeded
|
|
281
|
+
* NOTE: This does NOT block API calls - it only warns
|
|
282
|
+
*/
|
|
283
|
+
async checkBudget() {
|
|
284
|
+
// Only check budget if limit is set
|
|
285
|
+
if (this.budgetLimit === null || this.budgetLimit <= 0) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
const summary = await this.getSummary();
|
|
289
|
+
const percentage = (summary.totalCost / this.budgetLimit) * 100;
|
|
290
|
+
const threshold = this.budgetLimit * this.alertThreshold;
|
|
291
|
+
if (summary.totalCost >= threshold && summary.totalCost < this.budgetLimit) {
|
|
292
|
+
console.warn(`⚠️ Budget Alert (LOCAL ESTIMATE ONLY): $${summary.totalCost.toFixed(4)} / $${this.budgetLimit} (${percentage.toFixed(1)}%)`);
|
|
293
|
+
console.warn(` This is a LOCAL ESTIMATE - check https://dashboard.cohere.com for actual usage`);
|
|
294
|
+
console.warn(` API calls will continue. Run 'codehere cost reset' to reset local tracking.`);
|
|
295
|
+
}
|
|
296
|
+
else if (summary.totalCost >= this.budgetLimit) {
|
|
297
|
+
console.warn(`⚠️ Budget Exceeded (LOCAL ESTIMATE ONLY): $${summary.totalCost.toFixed(4)} / $${this.budgetLimit}`);
|
|
298
|
+
console.warn(` This is a LOCAL ESTIMATE - check https://dashboard.cohere.com for actual usage`);
|
|
299
|
+
console.warn(` API calls will continue. Run 'codehere cost reset' to reset local tracking.`);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Get current budget status
|
|
304
|
+
*/
|
|
305
|
+
async getBudgetStatus() {
|
|
306
|
+
const summary = await this.getSummary();
|
|
307
|
+
if (this.budgetLimit === null || this.budgetLimit <= 0) {
|
|
308
|
+
return {
|
|
309
|
+
spent: summary.totalCost,
|
|
310
|
+
limit: null,
|
|
311
|
+
remaining: null,
|
|
312
|
+
percentage: null,
|
|
313
|
+
alert: false,
|
|
314
|
+
};
|
|
315
|
+
}
|
|
316
|
+
const remaining = Math.max(0, this.budgetLimit - summary.totalCost);
|
|
317
|
+
const percentage = (summary.totalCost / this.budgetLimit) * 100;
|
|
318
|
+
const alert = summary.totalCost >= (this.budgetLimit * this.alertThreshold);
|
|
319
|
+
return {
|
|
320
|
+
spent: summary.totalCost,
|
|
321
|
+
limit: this.budgetLimit,
|
|
322
|
+
remaining,
|
|
323
|
+
percentage,
|
|
324
|
+
alert,
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* Get budget limit
|
|
329
|
+
*/
|
|
330
|
+
getBudgetLimit() {
|
|
331
|
+
return this.budgetLimit;
|
|
332
|
+
}
|
|
333
|
+
/**
|
|
334
|
+
* Reset costs (for testing or new billing period)
|
|
335
|
+
*/
|
|
336
|
+
async resetCosts() {
|
|
337
|
+
const db = await this.getDb();
|
|
338
|
+
db.run('DELETE FROM costs');
|
|
339
|
+
await this.saveDb();
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
// Singleton instance
|
|
343
|
+
let costTrackerInstance = null;
|
|
344
|
+
export function getCostTracker(budgetLimit) {
|
|
345
|
+
if (!costTrackerInstance) {
|
|
346
|
+
// Only set budget if explicitly provided via env var or parameter
|
|
347
|
+
// null = no budget tracking (default behavior)
|
|
348
|
+
const budget = budgetLimit ?? (process.env.COHERE_BUDGET_LIMIT ? parseFloat(process.env.COHERE_BUDGET_LIMIT) : null);
|
|
349
|
+
costTrackerInstance = new CostTracker(budget);
|
|
350
|
+
}
|
|
351
|
+
return costTrackerInstance;
|
|
352
|
+
}
|
|
353
|
+
//# sourceMappingURL=cost-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cost-tracker.js","sourceRoot":"","sources":["../../../src/infrastructure/cost/cost-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AACpC,OAAO,SAAuB,MAAM,QAAQ,CAAC;AAE7C,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAwBtC,gDAAgD;AAChD,oEAAoE;AACpE,MAAM,OAAO,GAAG;IACd,gBAAgB,EAAE;QAChB,KAAK,EAAE,QAAQ,EAAE,yBAAyB;QAC1C,MAAM,EAAE,QAAQ,EAAE,2BAA2B;KAC9C;IACD,WAAW,EAAE;QACX,KAAK,EAAE,SAAS,EAAE,2BAA2B;QAC7C,MAAM,EAAE,SAAS,EAAE,4BAA4B;KAChD;IACD,oBAAoB,EAAE;QACpB,KAAK,EAAE,SAAS,EAAE,qBAAqB;QACvC,MAAM,EAAE,CAAC;KACV;IACD,mBAAmB,EA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C;QACzB,kEAAkE;QAClE,+CAA+C;QAC/C,MAAM,MAAM,GAAG,WAAW,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACrH,mBAAmB,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;IAChD,CAAC;IACD,OAAO,mBAAmB,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Infrastructure: File Scanner
|
|
3
|
+
* Scans repository for code files to index
|
|
4
|
+
*/
|
|
5
|
+
import type { IFileScanner } from '../../application/use-cases/index-codebase-use-case.js';
|
|
6
|
+
export declare class FileScanner implements IFileScanner {
|
|
7
|
+
private readonly CODE_EXTENSIONS;
|
|
8
|
+
private readonly DOC_EXTENSIONS;
|
|
9
|
+
private readonly IGNORE_PATTERNS;
|
|
10
|
+
/**
|
|
11
|
+
* Scan repository for code files
|
|
12
|
+
*/
|
|
13
|
+
scan(repoPath: string): Promise<string[]>;
|
|
14
|
+
/**
|
|
15
|
+
* Recursively scan directory
|
|
16
|
+
*/
|
|
17
|
+
private scanDirectory;
|
|
18
|
+
/**
|
|
19
|
+
* Check if file should be ignored
|
|
20
|
+
*/
|
|
21
|
+
private shouldIgnore;
|
|
22
|
+
/**
|
|
23
|
+
* Check if file is a code file
|
|
24
|
+
*/
|
|
25
|
+
private isCodeFile;
|
|
26
|
+
/**
|
|
27
|
+
* Check if file is a documentation file
|
|
28
|
+
*/
|
|
29
|
+
private isDocFile;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=file-scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-scanner.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/file-scanner/file-scanner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wDAAwD,CAAC;AAE3F,qBAAa,WAAY,YAAW,YAAY;IAC9C,OAAO,CAAC,QAAQ,CAAC,eAAe,CAI7B;IAEH,OAAO,CAAC,QAAQ,CAAC,cAAc,CAE5B;IAEH,OAAO,CAAC,QAAQ,CAAC,eAAe,CAgB9B;IAEF;;OAEG;IACG,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAU/C;;OAEG;IACH,OAAO,CAAC,aAAa;IA+BrB;;OAEG;IACH,OAAO,CAAC,YAAY;IAgBpB;;OAEG;IACH,OAAO,CAAC,UAAU;IAKlB;;OAEG;IACH,OAAO,CAAC,SAAS;CAIlB"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Infrastructure: File Scanner
|
|
3
|
+
* Scans repository for code files to index
|
|
4
|
+
*/
|
|
5
|
+
import { readdirSync, statSync, existsSync } from 'fs';
|
|
6
|
+
import { join, extname } from 'path';
|
|
7
|
+
export class FileScanner {
|
|
8
|
+
CODE_EXTENSIONS = new Set([
|
|
9
|
+
'.ts', '.tsx', '.js', '.jsx', '.py', '.java', '.go', '.rs',
|
|
10
|
+
'.cpp', '.c', '.h', '.hpp', '.cs', '.rb', '.php', '.swift',
|
|
11
|
+
'.kt', '.scala', '.clj', '.sh', '.bash', '.zsh',
|
|
12
|
+
]);
|
|
13
|
+
DOC_EXTENSIONS = new Set([
|
|
14
|
+
'.md', '.txt', '.rst', '.adoc',
|
|
15
|
+
]);
|
|
16
|
+
IGNORE_PATTERNS = [
|
|
17
|
+
/^node_modules$/,
|
|
18
|
+
/^\.git$/,
|
|
19
|
+
/^\.next$/,
|
|
20
|
+
/^\.nuxt$/,
|
|
21
|
+
/^dist$/,
|
|
22
|
+
/^build$/,
|
|
23
|
+
/^\.build$/,
|
|
24
|
+
/^coverage$/,
|
|
25
|
+
/^\.coverage$/,
|
|
26
|
+
/^\.venv$/,
|
|
27
|
+
/^venv$/,
|
|
28
|
+
/^\.env$/,
|
|
29
|
+
/^\.DS_Store$/,
|
|
30
|
+
/^\.vscode$/,
|
|
31
|
+
/^\.idea$/,
|
|
32
|
+
];
|
|
33
|
+
/**
|
|
34
|
+
* Scan repository for code files
|
|
35
|
+
*/
|
|
36
|
+
async scan(repoPath) {
|
|
37
|
+
if (!existsSync(repoPath)) {
|
|
38
|
+
throw new Error(`Repository path does not exist: ${repoPath}`);
|
|
39
|
+
}
|
|
40
|
+
const files = [];
|
|
41
|
+
this.scanDirectory(repoPath, repoPath, files);
|
|
42
|
+
return files;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Recursively scan directory
|
|
46
|
+
*/
|
|
47
|
+
scanDirectory(dirPath, basePath, files) {
|
|
48
|
+
try {
|
|
49
|
+
const entries = readdirSync(dirPath);
|
|
50
|
+
for (const entry of entries) {
|
|
51
|
+
const fullPath = join(dirPath, entry);
|
|
52
|
+
const relativePath = fullPath.replace(basePath + '/', '').replace(basePath, '');
|
|
53
|
+
// Skip ignored patterns
|
|
54
|
+
if (this.shouldIgnore(entry, relativePath)) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
const stat = statSync(fullPath);
|
|
58
|
+
if (stat.isDirectory()) {
|
|
59
|
+
// Recursively scan subdirectories
|
|
60
|
+
this.scanDirectory(fullPath, basePath, files);
|
|
61
|
+
}
|
|
62
|
+
else if (stat.isFile()) {
|
|
63
|
+
// Check if file is code or documentation
|
|
64
|
+
if (this.isCodeFile(entry) || this.isDocFile(entry)) {
|
|
65
|
+
files.push(fullPath);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
// Skip directories we can't read (permissions, etc.)
|
|
72
|
+
console.warn(`Warning: Could not scan directory ${dirPath}:`, error instanceof Error ? error.message : String(error));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Check if file should be ignored
|
|
77
|
+
*/
|
|
78
|
+
shouldIgnore(filename, relativePath) {
|
|
79
|
+
// Check ignore patterns
|
|
80
|
+
for (const pattern of this.IGNORE_PATTERNS) {
|
|
81
|
+
if (pattern.test(filename) || pattern.test(relativePath)) {
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// Ignore hidden files (except .env.example, .gitignore, etc.)
|
|
86
|
+
if (filename.startsWith('.') && !['.env.example', '.gitignore', '.eslintrc', '.prettierrc'].includes(filename)) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Check if file is a code file
|
|
93
|
+
*/
|
|
94
|
+
isCodeFile(filename) {
|
|
95
|
+
const ext = extname(filename).toLowerCase();
|
|
96
|
+
return this.CODE_EXTENSIONS.has(ext);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Check if file is a documentation file
|
|
100
|
+
*/
|
|
101
|
+
isDocFile(filename) {
|
|
102
|
+
const ext = extname(filename).toLowerCase();
|
|
103
|
+
return this.DOC_EXTENSIONS.has(ext);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=file-scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-scanner.js","sourceRoot":"","sources":["../../../src/infrastructure/file-scanner/file-scanner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAGrC,MAAM,OAAO,WAAW;IACL,eAAe,GAAG,IAAI,GAAG,CAAC;QACzC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK;QAC1D,M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