@aionlabsai/aion 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.
- package/README.md +41 -0
- package/dist/agents/base-agent.d.ts +27 -0
- package/dist/agents/base-agent.d.ts.map +1 -0
- package/dist/agents/base-agent.js +97 -0
- package/dist/agents/base-agent.js.map +1 -0
- package/dist/agents/developer.d.ts +21 -0
- package/dist/agents/developer.d.ts.map +1 -0
- package/dist/agents/developer.js +51 -0
- package/dist/agents/developer.js.map +1 -0
- package/dist/agents/explain-agent.d.ts +17 -0
- package/dist/agents/explain-agent.d.ts.map +1 -0
- package/dist/agents/explain-agent.js +30 -0
- package/dist/agents/explain-agent.js.map +1 -0
- package/dist/agents/graph-agent.d.ts +21 -0
- package/dist/agents/graph-agent.d.ts.map +1 -0
- package/dist/agents/graph-agent.js +57 -0
- package/dist/agents/graph-agent.js.map +1 -0
- package/dist/agents/investigator.d.ts +21 -0
- package/dist/agents/investigator.d.ts.map +1 -0
- package/dist/agents/investigator.js +48 -0
- package/dist/agents/investigator.js.map +1 -0
- package/dist/agents/planner.d.ts +19 -0
- package/dist/agents/planner.d.ts.map +1 -0
- package/dist/agents/planner.js +43 -0
- package/dist/agents/planner.js.map +1 -0
- package/dist/agents/planner.test.d.ts +2 -0
- package/dist/agents/planner.test.d.ts.map +1 -0
- package/dist/agents/planner.test.js +21 -0
- package/dist/agents/planner.test.js.map +1 -0
- package/dist/agents/qa.d.ts +18 -0
- package/dist/agents/qa.d.ts.map +1 -0
- package/dist/agents/qa.js +44 -0
- package/dist/agents/qa.js.map +1 -0
- package/dist/agents/reviewer.d.ts +19 -0
- package/dist/agents/reviewer.d.ts.map +1 -0
- package/dist/agents/reviewer.js +47 -0
- package/dist/agents/reviewer.js.map +1 -0
- package/dist/agents/scanner.d.ts +19 -0
- package/dist/agents/scanner.d.ts.map +1 -0
- package/dist/agents/scanner.js +30 -0
- package/dist/agents/scanner.js.map +1 -0
- package/dist/agents/synthesizer.d.ts +16 -0
- package/dist/agents/synthesizer.d.ts.map +1 -0
- package/dist/agents/synthesizer.js +97 -0
- package/dist/agents/synthesizer.js.map +1 -0
- package/dist/agents/tests-agent.d.ts +17 -0
- package/dist/agents/tests-agent.d.ts.map +1 -0
- package/dist/agents/tests-agent.js +36 -0
- package/dist/agents/tests-agent.js.map +1 -0
- package/dist/cli/classifier.d.ts +8 -0
- package/dist/cli/classifier.d.ts.map +1 -0
- package/dist/cli/classifier.js +60 -0
- package/dist/cli/classifier.js.map +1 -0
- package/dist/cli/commands/analyze.d.ts +3 -0
- package/dist/cli/commands/analyze.d.ts.map +1 -0
- package/dist/cli/commands/analyze.js +22 -0
- package/dist/cli/commands/analyze.js.map +1 -0
- package/dist/cli/commands/audit.d.ts +3 -0
- package/dist/cli/commands/audit.d.ts.map +1 -0
- package/dist/cli/commands/audit.js +189 -0
- package/dist/cli/commands/audit.js.map +1 -0
- package/dist/cli/commands/churn.d.ts +3 -0
- package/dist/cli/commands/churn.d.ts.map +1 -0
- package/dist/cli/commands/churn.js +76 -0
- package/dist/cli/commands/churn.js.map +1 -0
- package/dist/cli/commands/explain.d.ts +3 -0
- package/dist/cli/commands/explain.d.ts.map +1 -0
- package/dist/cli/commands/explain.js +115 -0
- package/dist/cli/commands/explain.js.map +1 -0
- package/dist/cli/commands/fix.d.ts +3 -0
- package/dist/cli/commands/fix.d.ts.map +1 -0
- package/dist/cli/commands/fix.js +22 -0
- package/dist/cli/commands/fix.js.map +1 -0
- package/dist/cli/commands/graph.d.ts +3 -0
- package/dist/cli/commands/graph.d.ts.map +1 -0
- package/dist/cli/commands/graph.js +311 -0
- package/dist/cli/commands/graph.js.map +1 -0
- package/dist/cli/commands/health.d.ts +3 -0
- package/dist/cli/commands/health.d.ts.map +1 -0
- package/dist/cli/commands/health.js +106 -0
- package/dist/cli/commands/health.js.map +1 -0
- package/dist/cli/commands/memory.d.ts +3 -0
- package/dist/cli/commands/memory.d.ts.map +1 -0
- package/dist/cli/commands/memory.js +199 -0
- package/dist/cli/commands/memory.js.map +1 -0
- package/dist/cli/commands/patterns.d.ts +3 -0
- package/dist/cli/commands/patterns.d.ts.map +1 -0
- package/dist/cli/commands/patterns.js +79 -0
- package/dist/cli/commands/patterns.js.map +1 -0
- package/dist/cli/commands/report.d.ts +3 -0
- package/dist/cli/commands/report.d.ts.map +1 -0
- package/dist/cli/commands/report.js +408 -0
- package/dist/cli/commands/report.js.map +1 -0
- package/dist/cli/commands/review.d.ts +3 -0
- package/dist/cli/commands/review.d.ts.map +1 -0
- package/dist/cli/commands/review.js +21 -0
- package/dist/cli/commands/review.js.map +1 -0
- package/dist/cli/commands/scan.d.ts +3 -0
- package/dist/cli/commands/scan.d.ts.map +1 -0
- package/dist/cli/commands/scan.js +129 -0
- package/dist/cli/commands/scan.js.map +1 -0
- package/dist/cli/interactive.d.ts +3 -0
- package/dist/cli/interactive.d.ts.map +1 -0
- package/dist/cli/interactive.js +115 -0
- package/dist/cli/interactive.js.map +1 -0
- package/dist/cli/menu.d.ts +2 -0
- package/dist/cli/menu.d.ts.map +1 -0
- package/dist/cli/menu.js +208 -0
- package/dist/cli/menu.js.map +1 -0
- package/dist/cli/runtime-options.d.ts +19 -0
- package/dist/cli/runtime-options.d.ts.map +1 -0
- package/dist/cli/runtime-options.js +56 -0
- package/dist/cli/runtime-options.js.map +1 -0
- package/dist/cli/tui.d.ts +11 -0
- package/dist/cli/tui.d.ts.map +1 -0
- package/dist/cli/tui.js +162 -0
- package/dist/cli/tui.js.map +1 -0
- package/dist/cli/ui/renderer.d.ts +15 -0
- package/dist/cli/ui/renderer.d.ts.map +1 -0
- package/dist/cli/ui/renderer.js +129 -0
- package/dist/cli/ui/renderer.js.map +1 -0
- package/dist/core/cost-tracker.d.ts +26 -0
- package/dist/core/cost-tracker.d.ts.map +1 -0
- package/dist/core/cost-tracker.js +71 -0
- package/dist/core/cost-tracker.js.map +1 -0
- package/dist/core/cost-tracker.test.d.ts +2 -0
- package/dist/core/cost-tracker.test.d.ts.map +1 -0
- package/dist/core/cost-tracker.test.js +36 -0
- package/dist/core/cost-tracker.test.js.map +1 -0
- package/dist/core/orchestrator.d.ts +46 -0
- package/dist/core/orchestrator.d.ts.map +1 -0
- package/dist/core/orchestrator.js +67 -0
- package/dist/core/orchestrator.js.map +1 -0
- package/dist/core/pipeline-context.d.ts +18 -0
- package/dist/core/pipeline-context.d.ts.map +1 -0
- package/dist/core/pipeline-context.js +30 -0
- package/dist/core/pipeline-context.js.map +1 -0
- package/dist/core/pipelines/analyze-pipeline.d.ts +4 -0
- package/dist/core/pipelines/analyze-pipeline.d.ts.map +1 -0
- package/dist/core/pipelines/analyze-pipeline.js +69 -0
- package/dist/core/pipelines/analyze-pipeline.js.map +1 -0
- package/dist/core/pipelines/audit-fix-pipeline.d.ts +24 -0
- package/dist/core/pipelines/audit-fix-pipeline.d.ts.map +1 -0
- package/dist/core/pipelines/audit-fix-pipeline.js +79 -0
- package/dist/core/pipelines/audit-fix-pipeline.js.map +1 -0
- package/dist/core/pipelines/audit-pipeline.d.ts +33 -0
- package/dist/core/pipelines/audit-pipeline.d.ts.map +1 -0
- package/dist/core/pipelines/audit-pipeline.js +353 -0
- package/dist/core/pipelines/audit-pipeline.js.map +1 -0
- package/dist/core/pipelines/audit-pipeline.test.d.ts +2 -0
- package/dist/core/pipelines/audit-pipeline.test.d.ts.map +1 -0
- package/dist/core/pipelines/audit-pipeline.test.js +135 -0
- package/dist/core/pipelines/audit-pipeline.test.js.map +1 -0
- package/dist/core/pipelines/fix-pipeline.d.ts +9 -0
- package/dist/core/pipelines/fix-pipeline.d.ts.map +1 -0
- package/dist/core/pipelines/fix-pipeline.js +151 -0
- package/dist/core/pipelines/fix-pipeline.js.map +1 -0
- package/dist/core/pipelines/review-pipeline.d.ts +4 -0
- package/dist/core/pipelines/review-pipeline.d.ts.map +1 -0
- package/dist/core/pipelines/review-pipeline.js +65 -0
- package/dist/core/pipelines/review-pipeline.js.map +1 -0
- package/dist/core/repo-context.d.ts +2 -0
- package/dist/core/repo-context.d.ts.map +1 -0
- package/dist/core/repo-context.js +12 -0
- package/dist/core/repo-context.js.map +1 -0
- package/dist/core/repo-context.test.d.ts +2 -0
- package/dist/core/repo-context.test.d.ts.map +1 -0
- package/dist/core/repo-context.test.js +40 -0
- package/dist/core/repo-context.test.js.map +1 -0
- package/dist/core/runtime-policy.d.ts +35 -0
- package/dist/core/runtime-policy.d.ts.map +1 -0
- package/dist/core/runtime-policy.js +37 -0
- package/dist/core/runtime-policy.js.map +1 -0
- package/dist/core/runtime-policy.test.d.ts +2 -0
- package/dist/core/runtime-policy.test.d.ts.map +1 -0
- package/dist/core/runtime-policy.test.js +27 -0
- package/dist/core/runtime-policy.test.js.map +1 -0
- package/dist/core/state-machine.d.ts +17 -0
- package/dist/core/state-machine.d.ts.map +1 -0
- package/dist/core/state-machine.js +45 -0
- package/dist/core/state-machine.js.map +1 -0
- package/dist/core/task.d.ts +29 -0
- package/dist/core/task.d.ts.map +1 -0
- package/dist/core/task.js +2 -0
- package/dist/core/task.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +75 -0
- package/dist/index.js.map +1 -0
- package/dist/infra/bm25.d.ts +30 -0
- package/dist/infra/bm25.d.ts.map +1 -0
- package/dist/infra/bm25.js +69 -0
- package/dist/infra/bm25.js.map +1 -0
- package/dist/infra/bm25.test.d.ts +2 -0
- package/dist/infra/bm25.test.d.ts.map +1 -0
- package/dist/infra/bm25.test.js +17 -0
- package/dist/infra/bm25.test.js.map +1 -0
- package/dist/infra/chunker.d.ts +20 -0
- package/dist/infra/chunker.d.ts.map +1 -0
- package/dist/infra/chunker.js +165 -0
- package/dist/infra/chunker.js.map +1 -0
- package/dist/infra/chunker.test.d.ts +2 -0
- package/dist/infra/chunker.test.d.ts.map +1 -0
- package/dist/infra/chunker.test.js +33 -0
- package/dist/infra/chunker.test.js.map +1 -0
- package/dist/infra/code-metrics.d.ts +39 -0
- package/dist/infra/code-metrics.d.ts.map +1 -0
- package/dist/infra/code-metrics.js +222 -0
- package/dist/infra/code-metrics.js.map +1 -0
- package/dist/infra/db/database.d.ts +4 -0
- package/dist/infra/db/database.d.ts.map +1 -0
- package/dist/infra/db/database.js +25 -0
- package/dist/infra/db/database.js.map +1 -0
- package/dist/infra/db/evidence-repo.d.ts +4 -0
- package/dist/infra/db/evidence-repo.d.ts.map +1 -0
- package/dist/infra/db/evidence-repo.js +8 -0
- package/dist/infra/db/evidence-repo.js.map +1 -0
- package/dist/infra/db/migrations.d.ts +2 -0
- package/dist/infra/db/migrations.d.ts.map +1 -0
- package/dist/infra/db/migrations.js +10 -0
- package/dist/infra/db/migrations.js.map +1 -0
- package/dist/infra/db/store.d.ts +12 -0
- package/dist/infra/db/store.d.ts.map +1 -0
- package/dist/infra/db/store.js +73 -0
- package/dist/infra/db/store.js.map +1 -0
- package/dist/infra/db/task-repo.d.ts +8 -0
- package/dist/infra/db/task-repo.d.ts.map +1 -0
- package/dist/infra/db/task-repo.js +19 -0
- package/dist/infra/db/task-repo.js.map +1 -0
- package/dist/infra/dep-graph-python.d.ts +3 -0
- package/dist/infra/dep-graph-python.d.ts.map +1 -0
- package/dist/infra/dep-graph-python.js +154 -0
- package/dist/infra/dep-graph-python.js.map +1 -0
- package/dist/infra/dep-graph.d.ts +20 -0
- package/dist/infra/dep-graph.d.ts.map +1 -0
- package/dist/infra/dep-graph.js +102 -0
- package/dist/infra/dep-graph.js.map +1 -0
- package/dist/infra/embeddings.d.ts +19 -0
- package/dist/infra/embeddings.d.ts.map +1 -0
- package/dist/infra/embeddings.js +110 -0
- package/dist/infra/embeddings.js.map +1 -0
- package/dist/infra/evidence-gate.d.ts +11 -0
- package/dist/infra/evidence-gate.d.ts.map +1 -0
- package/dist/infra/evidence-gate.js +21 -0
- package/dist/infra/evidence-gate.js.map +1 -0
- package/dist/infra/evidence-gate.test.d.ts +2 -0
- package/dist/infra/evidence-gate.test.d.ts.map +1 -0
- package/dist/infra/evidence-gate.test.js +36 -0
- package/dist/infra/evidence-gate.test.js.map +1 -0
- package/dist/infra/git-analysis.d.ts +26 -0
- package/dist/infra/git-analysis.d.ts.map +1 -0
- package/dist/infra/git-analysis.js +102 -0
- package/dist/infra/git-analysis.js.map +1 -0
- package/dist/infra/health-score.d.ts +31 -0
- package/dist/infra/health-score.d.ts.map +1 -0
- package/dist/infra/health-score.js +136 -0
- package/dist/infra/health-score.js.map +1 -0
- package/dist/infra/knowledge.d.ts +15 -0
- package/dist/infra/knowledge.d.ts.map +1 -0
- package/dist/infra/knowledge.js +124 -0
- package/dist/infra/knowledge.js.map +1 -0
- package/dist/infra/lang-detect.d.ts +14 -0
- package/dist/infra/lang-detect.d.ts.map +1 -0
- package/dist/infra/lang-detect.js +135 -0
- package/dist/infra/lang-detect.js.map +1 -0
- package/dist/infra/local-qa.d.ts +6 -0
- package/dist/infra/local-qa.d.ts.map +1 -0
- package/dist/infra/local-qa.js +66 -0
- package/dist/infra/local-qa.js.map +1 -0
- package/dist/infra/pattern-detect.d.ts +30 -0
- package/dist/infra/pattern-detect.d.ts.map +1 -0
- package/dist/infra/pattern-detect.js +250 -0
- package/dist/infra/pattern-detect.js.map +1 -0
- package/dist/infra/persona-presets.d.ts +29 -0
- package/dist/infra/persona-presets.d.ts.map +1 -0
- package/dist/infra/persona-presets.js +110 -0
- package/dist/infra/persona-presets.js.map +1 -0
- package/dist/infra/repo-index.d.ts +50 -0
- package/dist/infra/repo-index.d.ts.map +1 -0
- package/dist/infra/repo-index.js +228 -0
- package/dist/infra/repo-index.js.map +1 -0
- package/dist/infra/repo-index.test.d.ts +2 -0
- package/dist/infra/repo-index.test.d.ts.map +1 -0
- package/dist/infra/repo-index.test.js +53 -0
- package/dist/infra/repo-index.test.js.map +1 -0
- package/dist/infra/repo-query.d.ts +11 -0
- package/dist/infra/repo-query.d.ts.map +1 -0
- package/dist/infra/repo-query.js +67 -0
- package/dist/infra/repo-query.js.map +1 -0
- package/dist/infra/repo-query.test.d.ts +2 -0
- package/dist/infra/repo-query.test.d.ts.map +1 -0
- package/dist/infra/repo-query.test.js +34 -0
- package/dist/infra/repo-query.test.js.map +1 -0
- package/dist/infra/sbom.d.ts +16 -0
- package/dist/infra/sbom.d.ts.map +1 -0
- package/dist/infra/sbom.js +111 -0
- package/dist/infra/sbom.js.map +1 -0
- package/dist/infra/semgrep.d.ts +10 -0
- package/dist/infra/semgrep.d.ts.map +1 -0
- package/dist/infra/semgrep.js +122 -0
- package/dist/infra/semgrep.js.map +1 -0
- package/dist/infra/semgrep.test.d.ts +2 -0
- package/dist/infra/semgrep.test.d.ts.map +1 -0
- package/dist/infra/semgrep.test.js +39 -0
- package/dist/infra/semgrep.test.js.map +1 -0
- package/dist/infra/tmux.d.ts +9 -0
- package/dist/infra/tmux.d.ts.map +1 -0
- package/dist/infra/tmux.js +42 -0
- package/dist/infra/tmux.js.map +1 -0
- package/dist/infra/worktree.d.ts +9 -0
- package/dist/infra/worktree.d.ts.map +1 -0
- package/dist/infra/worktree.js +51 -0
- package/dist/infra/worktree.js.map +1 -0
- package/dist/prompts/developer.d.ts +2 -0
- package/dist/prompts/developer.d.ts.map +1 -0
- package/dist/prompts/developer.js +36 -0
- package/dist/prompts/developer.js.map +1 -0
- package/dist/prompts/explain.d.ts +3 -0
- package/dist/prompts/explain.d.ts.map +1 -0
- package/dist/prompts/explain.js +38 -0
- package/dist/prompts/explain.js.map +1 -0
- package/dist/prompts/investigator.d.ts +3 -0
- package/dist/prompts/investigator.d.ts.map +1 -0
- package/dist/prompts/investigator.js +46 -0
- package/dist/prompts/investigator.js.map +1 -0
- package/dist/prompts/planner.d.ts +2 -0
- package/dist/prompts/planner.d.ts.map +1 -0
- package/dist/prompts/planner.js +37 -0
- package/dist/prompts/planner.js.map +1 -0
- package/dist/prompts/qa.d.ts +2 -0
- package/dist/prompts/qa.d.ts.map +1 -0
- package/dist/prompts/qa.js +37 -0
- package/dist/prompts/qa.js.map +1 -0
- package/dist/prompts/reviewer.d.ts +2 -0
- package/dist/prompts/reviewer.d.ts.map +1 -0
- package/dist/prompts/reviewer.js +36 -0
- package/dist/prompts/reviewer.js.map +1 -0
- package/dist/prompts/scanner-domains-infra.d.ts +48 -0
- package/dist/prompts/scanner-domains-infra.d.ts.map +1 -0
- package/dist/prompts/scanner-domains-infra.js +141 -0
- package/dist/prompts/scanner-domains-infra.js.map +1 -0
- package/dist/prompts/scanner.d.ts +10 -0
- package/dist/prompts/scanner.d.ts.map +1 -0
- package/dist/prompts/scanner.js +185 -0
- package/dist/prompts/scanner.js.map +1 -0
- package/dist/prompts/synthesizer.d.ts +2 -0
- package/dist/prompts/synthesizer.d.ts.map +1 -0
- package/dist/prompts/synthesizer.js +36 -0
- package/dist/prompts/synthesizer.js.map +1 -0
- package/dist/providers/cli-provider.d.ts +16 -0
- package/dist/providers/cli-provider.d.ts.map +1 -0
- package/dist/providers/cli-provider.js +145 -0
- package/dist/providers/cli-provider.js.map +1 -0
- package/dist/providers/openrouter-provider.d.ts +8 -0
- package/dist/providers/openrouter-provider.d.ts.map +1 -0
- package/dist/providers/openrouter-provider.js +86 -0
- package/dist/providers/openrouter-provider.js.map +1 -0
- package/dist/providers/sdk-provider.d.ts +6 -0
- package/dist/providers/sdk-provider.d.ts.map +1 -0
- package/dist/providers/sdk-provider.js +0 -0
- package/dist/providers/sdk-provider.js.map +1 -0
- package/dist/providers/types.d.ts +13 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +2 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/schemas/audit.d.ts +278 -0
- package/dist/schemas/audit.d.ts.map +1 -0
- package/dist/schemas/audit.js +37 -0
- package/dist/schemas/audit.js.map +1 -0
- package/dist/schemas/audit.test.d.ts +2 -0
- package/dist/schemas/audit.test.d.ts.map +1 -0
- package/dist/schemas/audit.test.js +41 -0
- package/dist/schemas/audit.test.js.map +1 -0
- package/dist/schemas/evidence.d.ts +48 -0
- package/dist/schemas/evidence.d.ts.map +1 -0
- package/dist/schemas/evidence.js +17 -0
- package/dist/schemas/evidence.js.map +1 -0
- package/dist/schemas/patch.d.ts +25 -0
- package/dist/schemas/patch.d.ts.map +1 -0
- package/dist/schemas/patch.js +10 -0
- package/dist/schemas/patch.js.map +1 -0
- package/dist/schemas/plan.d.ts +69 -0
- package/dist/schemas/plan.d.ts.map +1 -0
- package/dist/schemas/plan.js +17 -0
- package/dist/schemas/plan.js.map +1 -0
- package/dist/schemas/qa.d.ts +28 -0
- package/dist/schemas/qa.d.ts.map +1 -0
- package/dist/schemas/qa.js +11 -0
- package/dist/schemas/qa.js.map +1 -0
- package/dist/schemas/review.d.ts +71 -0
- package/dist/schemas/review.d.ts.map +1 -0
- package/dist/schemas/review.js +16 -0
- package/dist/schemas/review.js.map +1 -0
- package/package.json +51 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export interface DomainConfig {
|
|
2
|
+
title: string;
|
|
3
|
+
grepPatterns: string[];
|
|
4
|
+
instructions: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const INFRA_DOMAIN_CONFIG: {
|
|
7
|
+
infrastructure: {
|
|
8
|
+
title: string;
|
|
9
|
+
grepPatterns: string[];
|
|
10
|
+
instructions: string;
|
|
11
|
+
};
|
|
12
|
+
observability: {
|
|
13
|
+
title: string;
|
|
14
|
+
grepPatterns: string[];
|
|
15
|
+
instructions: string;
|
|
16
|
+
};
|
|
17
|
+
resilience: {
|
|
18
|
+
title: string;
|
|
19
|
+
grepPatterns: string[];
|
|
20
|
+
instructions: string;
|
|
21
|
+
};
|
|
22
|
+
data: {
|
|
23
|
+
title: string;
|
|
24
|
+
grepPatterns: string[];
|
|
25
|
+
instructions: string;
|
|
26
|
+
};
|
|
27
|
+
dependencies: {
|
|
28
|
+
title: string;
|
|
29
|
+
grepPatterns: string[];
|
|
30
|
+
instructions: string;
|
|
31
|
+
};
|
|
32
|
+
compliance: {
|
|
33
|
+
title: string;
|
|
34
|
+
grepPatterns: string[];
|
|
35
|
+
instructions: string;
|
|
36
|
+
};
|
|
37
|
+
multitenancy: {
|
|
38
|
+
title: string;
|
|
39
|
+
grepPatterns: string[];
|
|
40
|
+
instructions: string;
|
|
41
|
+
};
|
|
42
|
+
'prompt-audit': {
|
|
43
|
+
title: string;
|
|
44
|
+
grepPatterns: string[];
|
|
45
|
+
instructions: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
//# sourceMappingURL=scanner-domains-infra.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner-domains-infra.d.ts","sourceRoot":"","sources":["../../src/prompts/scanner-domains-infra.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2I/B,CAAC"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
export const INFRA_DOMAIN_CONFIG = {
|
|
2
|
+
infrastructure: {
|
|
3
|
+
title: 'Infrastructure Scanner',
|
|
4
|
+
grepPatterns: [
|
|
5
|
+
'image:', 'resources:', 'limits:', 'requests:', 'securityContext:',
|
|
6
|
+
'runAsRoot', 'runAsUser', 'privileged:', 'readOnlyRootFilesystem:',
|
|
7
|
+
'livenessProbe', 'readinessProbe', 'startupProbe',
|
|
8
|
+
'latest', 'FROM ', 'RUN apt', 'RUN pip', 'ADD ',
|
|
9
|
+
'replicas:', 'strategy:', 'PodDisruptionBudget', 'NetworkPolicy',
|
|
10
|
+
],
|
|
11
|
+
instructions: `Use Bash and Grep to scan Kubernetes manifests, Dockerfiles, and docker-compose files:
|
|
12
|
+
1. Find Dockerfiles: find . -name "Dockerfile*" | head -20
|
|
13
|
+
2. Find K8s manifests: find . -name "*.yaml" -o -name "*.yml" | xargs grep -l "apiVersion:" 2>/dev/null | head -20
|
|
14
|
+
3. Check for: containers running as root (no runAsNonRoot or runAsUser), missing resource limits/requests, image:latest tags, missing liveness/readiness probes, privileged:true, missing securityContext
|
|
15
|
+
4. In Dockerfiles: ADD instead of COPY, apt-get without pinned versions, missing .dockerignore reference, root USER
|
|
16
|
+
5. docker-compose: find . -name "docker-compose*.yml" | head -5 — check for exposed ports, missing healthchecks, host volume mounts
|
|
17
|
+
Read only the relevant sections (offset/limit). Report file+line for each finding.`,
|
|
18
|
+
},
|
|
19
|
+
observability: {
|
|
20
|
+
title: 'Observability Scanner',
|
|
21
|
+
grepPatterns: [
|
|
22
|
+
'print(', 'console.log', 'logger.', 'logging.',
|
|
23
|
+
'traceid', 'trace_id', 'request_id', 'opentelemetry', 'jaeger',
|
|
24
|
+
'/health', '/ready', '/live', '/metrics',
|
|
25
|
+
'prometheus', 'datadog', 'sentry',
|
|
26
|
+
'except:', 'catch (', 'catch{',
|
|
27
|
+
],
|
|
28
|
+
instructions: `Use Grep and Bash to find observability gaps:
|
|
29
|
+
1. Unstructured logging: grep -rn "print(\\|console.log\\|fmt.Print" --include="*.py" --include="*.ts" --include="*.go" . | grep -v "test\\|spec" | head -30 — log statements without structured fields (no level, no trace_id, no service)
|
|
30
|
+
2. Missing health endpoints: grep -rn "/health\\|/ready\\|/live\\|/ping" --include="*.py" --include="*.ts" . | head -20 — if none found, report missing
|
|
31
|
+
3. Missing metrics: grep -rn "prometheus\\|metrics\\|gauge\\|counter\\|histogram" --include="*.py" --include="*.ts" . | head -10
|
|
32
|
+
4. Exception swallowing without logging: grep -rn "except:\\|catch (" --include="*.py" --include="*.ts" . | head -20 — then Read those sections to confirm no log statement inside
|
|
33
|
+
5. No trace context propagation: grep -rn "trace_id\\|traceparent\\|X-Request-ID" --include="*.py" --include="*.ts" . | head -10
|
|
34
|
+
Report file+line for each confirmed gap.`,
|
|
35
|
+
},
|
|
36
|
+
resilience: {
|
|
37
|
+
title: 'Resilience Scanner',
|
|
38
|
+
grepPatterns: [
|
|
39
|
+
'requests.get(', 'requests.post(', 'fetch(', 'axios.',
|
|
40
|
+
'timeout', 'retry', 'backoff', 'circuit',
|
|
41
|
+
'sleep(', 'time.sleep(', 'setTimeout(',
|
|
42
|
+
'connect(', 'pool', 'max_connections',
|
|
43
|
+
'signal.signal', 'SIGTERM', 'graceful',
|
|
44
|
+
],
|
|
45
|
+
instructions: `Use Grep and Bash to find resilience gaps:
|
|
46
|
+
1. HTTP calls without timeout: grep -rn "requests.get(\\|requests.post(\\|fetch(\\|axios." --include="*.py" --include="*.ts" . | head -30 — then Read those sections to check for timeout parameter
|
|
47
|
+
2. No retry logic: grep -rn "def.*retry\\|backoff\\|tenacity\\|retry(" --include="*.py" . | head -10 — if absent on external calls, report missing
|
|
48
|
+
3. No circuit breaker: grep -rn "circuit\\|hystrix\\|breaker\\|resilience4j" --include="*.py" --include="*.ts" . | head -5
|
|
49
|
+
4. Missing SIGTERM handler: grep -rn "SIGTERM\\|signal.signal\\|graceful" --include="*.py" --include="*.ts" . | head -10
|
|
50
|
+
5. Database connection pool not configured: grep -rn "create_engine\\|pool_size\\|max_overflow\\|pool=" --include="*.py" . | head -10
|
|
51
|
+
6. Unbounded queue/task submission: grep -rn "ThreadPoolExecutor\\|asyncio.create_task\\|celery" --include="*.py" . | head -10 — check for missing max_workers or queue size limits
|
|
52
|
+
Report file+line for each gap confirmed by reading the section.`,
|
|
53
|
+
},
|
|
54
|
+
data: {
|
|
55
|
+
title: 'Data Layer Scanner',
|
|
56
|
+
grepPatterns: [
|
|
57
|
+
'for ', 'forEach(', '.all()', 'SELECT', 'query(',
|
|
58
|
+
'paginate', 'limit', 'offset', 'LIMIT',
|
|
59
|
+
'migrate', 'revision', 'alembic', 'flyway',
|
|
60
|
+
'INDEX', 'CREATE TABLE', 'ALTER TABLE',
|
|
61
|
+
'BEGIN', 'COMMIT', 'transaction', 'session.',
|
|
62
|
+
],
|
|
63
|
+
instructions: `Use Grep and Bash to find data layer issues:
|
|
64
|
+
1. N+1 queries: grep -rn "for.*in.*:$\\|forEach(" --include="*.py" --include="*.ts" . | head -30 — then Read those sections to check if there's a DB call inside the loop
|
|
65
|
+
2. Missing pagination: grep -rn "\.all()\\|\\.find({})" --include="*.py" --include="*.ts" . | head -20 — list endpoints returning all rows without limit
|
|
66
|
+
3. Missing migrations tool: find . -name "alembic.ini" -o -name "flyway.conf" -o -name "liquibase*" | head -5 — if absent, check for raw SQL schema creation
|
|
67
|
+
4. Indexes on foreign keys: grep -rn "ForeignKey\\|REFERENCES\\|foreign_key" --include="*.py" . | head -20 — cross-check with index definitions
|
|
68
|
+
5. Transaction boundaries: grep -rn "session.commit()\\|db.commit()\\|transaction" --include="*.py" . | head -20 — operations that should be atomic but aren't in a transaction
|
|
69
|
+
6. Distributed transaction without saga: grep -rn "requests.post\\|httpx.post" --include="*.py" . | head -10 — external calls inside a transaction block
|
|
70
|
+
Report file+line for each confirmed issue.`,
|
|
71
|
+
},
|
|
72
|
+
dependencies: {
|
|
73
|
+
title: 'Dependencies Scanner',
|
|
74
|
+
grepPatterns: [
|
|
75
|
+
'requirements.txt', 'package.json', 'Pipfile', 'poetry.lock',
|
|
76
|
+
'import ', 'from ', 'require(',
|
|
77
|
+
'password', 'secret', 'api_key', 'token', 'private_key',
|
|
78
|
+
'CORS', 'allow_origins', 'cors(',
|
|
79
|
+
'@app.route', 'app.get(', 'app.post(',
|
|
80
|
+
],
|
|
81
|
+
instructions: `Use Bash and Grep to find dependency and supply chain issues:
|
|
82
|
+
1. Unpinned dependencies: cat requirements.txt 2>/dev/null | grep -v "==" | grep -v "^#" | head -20; cat package.json 2>/dev/null | python3 -c "import sys,json; d=json.load(sys.stdin); [print(k,v) for k,v in {**d.get('dependencies',{}),**d.get('devDependencies',{})}.items() if '^' in str(v) or '~' in str(v) or '*' in str(v)]" 2>/dev/null | head -20
|
|
83
|
+
2. Secrets in source: grep -rn "password\s*=\s*['\"]\\|api_key\s*=\s*['\"]\\|secret\s*=\s*['\"]" --include="*.py" --include="*.ts" --include="*.env" . | grep -v "test\\|example\\|sample" | head -20
|
|
84
|
+
3. CORS misconfigured: grep -rn "allow_origins\\|CORS\\|cors(" --include="*.py" --include="*.ts" . | head -20 — check for wildcard "*"
|
|
85
|
+
4. Rate limiting on auth endpoints: grep -rn "login\\|auth\\|password\\|token" --include="*.py" . | grep "route\\|endpoint\\|@app" | head -10 — then check for rate_limit decorator/middleware nearby
|
|
86
|
+
5. Dependency confusion: find . -name "requirements*.txt" -o -name "package*.json" | xargs grep -l "internal\\|private\\|corp" 2>/dev/null | head -5
|
|
87
|
+
Report file+line for each finding.`,
|
|
88
|
+
},
|
|
89
|
+
compliance: {
|
|
90
|
+
title: 'Compliance Scanner (LGPD/GDPR)',
|
|
91
|
+
grepPatterns: [
|
|
92
|
+
'email', 'cpf', 'cnpj', 'phone', 'telefone', 'nome', 'name',
|
|
93
|
+
'logger', 'logging', 'print(', 'console.log',
|
|
94
|
+
'password', 'senha', 'token',
|
|
95
|
+
'delete', 'DELETE', 'soft_delete', 'is_deleted',
|
|
96
|
+
'created_at', 'expires_at', 'retention',
|
|
97
|
+
],
|
|
98
|
+
instructions: `Use Grep to find LGPD/GDPR compliance gaps:
|
|
99
|
+
1. PII in logs: grep -rn "logger.*email\\|logger.*cpf\\|logger.*phone\\|print.*user\\|log.*password" --include="*.py" --include="*.ts" . | grep -v "test\\|spec" | head -30
|
|
100
|
+
2. PII in error responses: grep -rn "return.*email\\|jsonify.*cpf\\|res.json.*phone" --include="*.py" --include="*.ts" . | head -20 — error handlers returning personal data
|
|
101
|
+
3. No soft delete for user data: grep -rn "DELETE FROM.*user\\|\.delete().*user\\|User\.delete" --include="*.py" --include="*.ts" . | head -10 — hard deletes without audit trail
|
|
102
|
+
4. Missing audit trail: grep -rn "def delete\\|def update\\|def create" --include="*.py" . | head -20 — then Read those sections to check for audit log call
|
|
103
|
+
5. Data retention not enforced: grep -rn "expires_at\\|retention\\|purge\\|cleanup" --include="*.py" . | head -10 — if absent, report missing retention policy
|
|
104
|
+
6. Sensitive data in GET params: grep -rn "request.args.get.*token\\|request.args.get.*password\\|query.*secret" --include="*.py" . | head -10
|
|
105
|
+
Report file+line for each confirmed issue.`,
|
|
106
|
+
},
|
|
107
|
+
multitenancy: {
|
|
108
|
+
title: 'Multi-tenancy Scanner',
|
|
109
|
+
grepPatterns: [
|
|
110
|
+
'tenant_id', 'tenant', 'organization_id', 'org_id',
|
|
111
|
+
'SELECT', 'WHERE', 'filter(', 'query(',
|
|
112
|
+
'cache', 'redis', 'memcache', 'get(', 'set(',
|
|
113
|
+
'request.user', 'current_user', 'g.user',
|
|
114
|
+
],
|
|
115
|
+
instructions: `Use Grep to find multi-tenancy isolation gaps:
|
|
116
|
+
1. Queries without tenant filter: grep -rn "\.query(\\|\.filter(\\|SELECT" --include="*.py" . | head -40 — then Read those sections to check if tenant_id/organization_id is in the filter
|
|
117
|
+
2. Cache keys without tenant prefix: grep -rn "cache.get(\\|redis.get(\\|cache.set(" --include="*.py" --include="*.ts" . | head -20 — check if key includes tenant_id
|
|
118
|
+
3. File paths without tenant isolation: grep -rn "open(\\|os.path\\|upload" --include="*.py" . | head -20 — check if path includes tenant identifier
|
|
119
|
+
4. Background jobs without tenant context: grep -rn "\.delay(\\|\.apply_async(\\|celery" --include="*.py" . | head -10 — tasks that process data without tenant scoping
|
|
120
|
+
5. Admin endpoints without tenant check: grep -rn "@admin\\|is_admin\\|role.*admin" --include="*.py" . | head -10 — verify tenant boundary in admin logic
|
|
121
|
+
Report file+line for each gap confirmed by reading the section.`,
|
|
122
|
+
},
|
|
123
|
+
'prompt-audit': {
|
|
124
|
+
title: 'Prompt Audit Scanner (AI/LLM)',
|
|
125
|
+
grepPatterns: [
|
|
126
|
+
'openai', 'anthropic', 'langchain', 'ChatCompletion', 'messages=',
|
|
127
|
+
'system_prompt', 'user_prompt', 'prompt =', 'f"""', 'f"',
|
|
128
|
+
'model=', 'gpt-', 'claude-', 'temperature=',
|
|
129
|
+
],
|
|
130
|
+
instructions: `Use Grep and Read to find LLM/prompt quality issues:
|
|
131
|
+
1. Prompt injection risks: grep -rn "f\\".*{.*request\\|f\\".*{.*user\\|format.*user_input" --include="*.py" --include="*.ts" . | head -20 — user input directly concatenated into prompts
|
|
132
|
+
2. Hardcoded model names: grep -rn "gpt-4\\|gpt-3\\|claude-2\\|claude-instant" --include="*.py" --include="*.ts" . | head -20 — model names that will become stale
|
|
133
|
+
3. Missing system prompt: grep -rn "messages=\\[{.*role.*user" --include="*.py" . | head -20 — calls with only user role, no system guidance
|
|
134
|
+
4. Very long prompts (>2000 chars): grep -rn '"""' --include="*.py" . | head -20 — then Read those sections to check prompt length
|
|
135
|
+
5. No error handling on LLM calls: grep -rn "\.chat\.completions\.create\\|client\.messages\.create" --include="*.py" --include="*.ts" . | head -20 — check if wrapped in try/except
|
|
136
|
+
6. Duplicate prompts: grep -rn "system_prompt\\|SYSTEM_PROMPT" --include="*.py" --include="*.ts" . | head -20 — same prompt string in multiple files
|
|
137
|
+
7. Tokens not limited: grep -rn "max_tokens\\|max_output_tokens" --include="*.py" --include="*.ts" . | head -10 — calls without token limits
|
|
138
|
+
Report file+line for each confirmed issue.`,
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
//# sourceMappingURL=scanner-domains-infra.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner-domains-infra.js","sourceRoot":"","sources":["../../src/prompts/scanner-domains-infra.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,cAAc,EAAE;QACd,KAAK,EAAE,wBAAwB;QAC/B,YAAY,EAAE;YACZ,QAAQ,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,kBAAkB;YAClE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,yBAAyB;YAClE,eAAe,EAAE,gBAAgB,EAAE,cAAc;YACjD,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM;YAC/C,WAAW,EAAE,WAA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 'testing' | 'performance' | 'bugs' | 'redundancy' | 'infrastructure' | 'observability' | 'resilience' | 'data' | 'dependencies' | 'compliance' | 'multitenancy' | 'prompt-audit';
|
|
2
|
+
export declare const SCAN_DOMAINS: ScanDomain[];
|
|
3
|
+
export type { DomainConfig } from './scanner-domains-infra.js';
|
|
4
|
+
export interface ScannerContext {
|
|
5
|
+
repoSummary?: string;
|
|
6
|
+
depGraph?: string;
|
|
7
|
+
hotspotFiles?: string[];
|
|
8
|
+
}
|
|
9
|
+
export declare function buildScannerPrompt(domain: ScanDomain, scannerIndex: number, totalScanners: number, ctx?: ScannerContext): string;
|
|
10
|
+
//# sourceMappingURL=scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../../src/prompts/scanner.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAClB,UAAU,GACV,gBAAgB,GAChB,cAAc,GACd,SAAS,GACT,aAAa,GACb,MAAM,GACN,YAAY,GACZ,gBAAgB,GAChB,eAAe,GACf,YAAY,GACZ,MAAM,GACN,cAAc,GACd,YAAY,GACZ,cAAc,GACd,cAAc,CAAC;AAEnB,eAAO,MAAM,YAAY,EAAE,UAAU,EAgBpC,CAAC;AAEF,YAAY,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AA8H/D,MAAM,WAAW,cAAc;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,cAAc,GAAG,MAAM,CA2ChI"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
export const SCAN_DOMAINS = [
|
|
2
|
+
'security',
|
|
3
|
+
'bugs',
|
|
4
|
+
'redundancy',
|
|
5
|
+
'error-handling',
|
|
6
|
+
'architecture',
|
|
7
|
+
'testing',
|
|
8
|
+
'performance',
|
|
9
|
+
'infrastructure',
|
|
10
|
+
'observability',
|
|
11
|
+
'resilience',
|
|
12
|
+
'data',
|
|
13
|
+
'dependencies',
|
|
14
|
+
'compliance',
|
|
15
|
+
'multitenancy',
|
|
16
|
+
'prompt-audit',
|
|
17
|
+
];
|
|
18
|
+
import { INFRA_DOMAIN_CONFIG } from './scanner-domains-infra.js';
|
|
19
|
+
const DOMAIN_CONFIG = {
|
|
20
|
+
...INFRA_DOMAIN_CONFIG,
|
|
21
|
+
bugs: {
|
|
22
|
+
title: 'Bug Scanner',
|
|
23
|
+
grepPatterns: [
|
|
24
|
+
'null', 'undefined', 'NaN', 'parseInt(', 'parseFloat(',
|
|
25
|
+
'=== null', '!== null', '== null', '!= null',
|
|
26
|
+
'async ', 'await ', 'Promise.all', 'Promise.race',
|
|
27
|
+
'setTimeout', 'setInterval', 'clearTimeout', 'clearInterval',
|
|
28
|
+
'push(', 'pop(', 'shift(', 'splice(',
|
|
29
|
+
'index', 'length', 'slice(', 'substr(',
|
|
30
|
+
],
|
|
31
|
+
instructions: `Use Grep and Bash to find real logic bugs:
|
|
32
|
+
1. Null/undefined dereference: grep for patterns like ".x" after nullable assignments, optional chaining missing
|
|
33
|
+
2. Off-by-one errors: array index accesses near .length, slice/substr with boundary values
|
|
34
|
+
3. Race conditions: concurrent state mutations, shared mutable state in async flows, unguarded Promise.all
|
|
35
|
+
4. Type coercion bugs: == instead of ===, parseInt without radix, NaN comparisons
|
|
36
|
+
5. Infinite loops or missing exit conditions: loops with external state, missing break
|
|
37
|
+
6. State machine violations: transitions that skip required states, missing guards
|
|
38
|
+
For each finding, Read the relevant section (offset/limit) to confirm it's a real bug, not a false positive.`,
|
|
39
|
+
},
|
|
40
|
+
redundancy: {
|
|
41
|
+
title: 'Redundancy Scanner',
|
|
42
|
+
grepPatterns: [
|
|
43
|
+
'function ', 'const ', 'class ', 'export ',
|
|
44
|
+
'import ', 'require(',
|
|
45
|
+
'if (', 'switch (', 'for (', 'while (',
|
|
46
|
+
],
|
|
47
|
+
instructions: `Use Bash to find redundant and dead code:
|
|
48
|
+
1. Duplicate function names across files: grep -rn "^function \\|^const .*= (" --include="*.ts" --include="*.py" . | awk -F'[: ]' '{print $NF}' | sort | uniq -d | head -20
|
|
49
|
+
2. Exported symbols never imported elsewhere: grep -rn "^export " --include="*.ts" . | grep -v "index.ts" | head -30 — then cross-check with grep for each symbol name
|
|
50
|
+
3. Dead imports: grep -rn "^import " --include="*.ts" . | head -40 — look for modules imported but symbols unused
|
|
51
|
+
4. Similar logic blocks: find functions >20 lines with similar names (e.g., getUser/fetchUser/loadUser) — Read both to compare
|
|
52
|
+
5. Config/constant duplication: grep -rn "const.*=.*['\"]" --include="*.ts" . | sort -t= -k2 | uniq -d -f1 | head -20
|
|
53
|
+
Report only confirmed cases with file+line. Do not speculate.`,
|
|
54
|
+
},
|
|
55
|
+
security: {
|
|
56
|
+
title: 'Security Scanner',
|
|
57
|
+
grepPatterns: [
|
|
58
|
+
'eval(', 'exec(', 'execSync(', 'spawn(',
|
|
59
|
+
'dangerously', 'skip-permissions', 'no-verify',
|
|
60
|
+
'password', 'secret', 'api_key', 'apikey', 'token',
|
|
61
|
+
'process.env', 'SQL', 'query(', 'innerHTML', 'dangerouslySetInnerHTML',
|
|
62
|
+
'child_process', 'shell: true',
|
|
63
|
+
],
|
|
64
|
+
instructions: `Use Grep to search for each of these patterns across the entire codebase.
|
|
65
|
+
For each match, Read only the relevant section (offset/limit) to determine if it's actually a vulnerability.
|
|
66
|
+
Focus on: hardcoded credentials, command injection, SQL injection, XSS, unsafe deserialization, overly broad permissions.
|
|
67
|
+
Skip false positives (e.g., comments, test fixtures).`,
|
|
68
|
+
},
|
|
69
|
+
'error-handling': {
|
|
70
|
+
title: 'Error Handling Scanner',
|
|
71
|
+
grepPatterns: [
|
|
72
|
+
'catch {', 'catch(_)', 'catch (e) {}', 'catch (err) {}',
|
|
73
|
+
'} catch {', 'catch (error) {}',
|
|
74
|
+
'.then(', 'async function', 'await ',
|
|
75
|
+
'Promise.all', 'Promise.race',
|
|
76
|
+
'setTimeout', 'setInterval',
|
|
77
|
+
],
|
|
78
|
+
instructions: `Use Grep to find:
|
|
79
|
+
1. Empty or swallowed catch blocks: "catch {" with no body, or "catch" blocks that don't log/rethrow
|
|
80
|
+
2. Unhandled promise rejections: .then() without .catch()
|
|
81
|
+
3. Async functions with no try/catch around awaits
|
|
82
|
+
4. Missing error propagation (catching then returning undefined)
|
|
83
|
+
Read only the matching sections to confirm issues. Report file+line for each.`,
|
|
84
|
+
},
|
|
85
|
+
architecture: {
|
|
86
|
+
title: 'Architecture Scanner',
|
|
87
|
+
grepPatterns: [
|
|
88
|
+
'import ', 'require(', 'export ', 'export default',
|
|
89
|
+
'class ', 'function ', 'const ', 'TODO', 'FIXME', 'HACK', 'XXX',
|
|
90
|
+
],
|
|
91
|
+
instructions: `Use Bash to run these checks:
|
|
92
|
+
1. Find large files: find . -name "*.ts" -o -name "*.py" -o -name "*.js" | xargs wc -l 2>/dev/null | sort -rn | head -20
|
|
93
|
+
2. Find TODO/FIXME/HACK: grep -rn "TODO\\|FIXME\\|HACK\\|XXX" --include="*.ts" --include="*.py" --include="*.js" . | head -30
|
|
94
|
+
3. Find duplicate function names: grep -rn "^function \\|^const .* = (" --include="*.ts" . | awk -F: '{print $NF}' | sort | uniq -d | head -20
|
|
95
|
+
Then Read the largest/most problematic files (offset/limit, max 100 lines each).
|
|
96
|
+
Report: god classes (>300 lines), deep nesting, duplicated logic, technical debt markers.`,
|
|
97
|
+
},
|
|
98
|
+
testing: {
|
|
99
|
+
title: 'Testing Scanner',
|
|
100
|
+
grepPatterns: [
|
|
101
|
+
'test(', 'it(', 'describe(', 'expect(',
|
|
102
|
+
'.test.', '.spec.', '__tests__',
|
|
103
|
+
'export function', 'export class', 'export const',
|
|
104
|
+
],
|
|
105
|
+
instructions: `Use Bash to check test coverage gaps:
|
|
106
|
+
1. List all source files: find src -name "*.ts" ! -name "*.test.ts" ! -name "*.spec.ts" | sort
|
|
107
|
+
2. List all test files: find . -name "*.test.*" -o -name "*.spec.*" | sort
|
|
108
|
+
3. Cross-reference: which source modules have NO corresponding test file?
|
|
109
|
+
4. Grep for untested exports: grep -rn "^export" src/ --include="*.ts" | grep -v test | head -30
|
|
110
|
+
Report: modules with zero test coverage, critical paths that are untested, TODO test markers.`,
|
|
111
|
+
},
|
|
112
|
+
performance: {
|
|
113
|
+
title: 'Performance Scanner',
|
|
114
|
+
grepPatterns: [
|
|
115
|
+
'readFileSync', 'writeFileSync', 'execSync', 'spawnSync',
|
|
116
|
+
'for (', 'forEach(', 'map(', 'filter(', 'reduce(',
|
|
117
|
+
'await ', 'setTimeout', 'setInterval',
|
|
118
|
+
'JSON.parse', 'JSON.stringify',
|
|
119
|
+
'.length', 'push(', 'concat(',
|
|
120
|
+
],
|
|
121
|
+
instructions: `Use Grep to find:
|
|
122
|
+
1. Sync I/O in async context: readFileSync/writeFileSync/execSync inside async functions
|
|
123
|
+
2. Unbounded loops: for/forEach/map on arrays with no size limit
|
|
124
|
+
3. Repeated JSON.parse/stringify of large objects in hot paths
|
|
125
|
+
4. Missing pagination or limits on data fetches
|
|
126
|
+
5. Memory leaks: event listeners not removed, intervals not cleared
|
|
127
|
+
Read only matching sections (offset/limit 30 lines) to confirm. Report file+line+severity.`,
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
function buildContextBlock(ctx) {
|
|
131
|
+
const parts = [];
|
|
132
|
+
if (ctx.repoSummary)
|
|
133
|
+
parts.push(`## Repository Structure\n${ctx.repoSummary}`);
|
|
134
|
+
if (ctx.depGraph)
|
|
135
|
+
parts.push(`## Dependency Graph\n${ctx.depGraph}`);
|
|
136
|
+
if (ctx.hotspotFiles && ctx.hotspotFiles.length > 0) {
|
|
137
|
+
parts.push(`## High-Coupling Files (read these first — most likely to contain issues)\n${ctx.hotspotFiles.map((f) => `- ${f}`).join('\n')}`);
|
|
138
|
+
}
|
|
139
|
+
return parts.length > 0 ? '\n' + parts.join('\n\n') + '\n' : '';
|
|
140
|
+
}
|
|
141
|
+
export function buildScannerPrompt(domain, scannerIndex, totalScanners, ctx) {
|
|
142
|
+
const cfg = DOMAIN_CONFIG[domain];
|
|
143
|
+
const contextBlock = ctx ? buildContextBlock(ctx) : '';
|
|
144
|
+
return `# ${cfg.title} (${scannerIndex + 1} of ${totalScanners})
|
|
145
|
+
|
|
146
|
+
You are a specialized code auditor. Your ONLY job is to find **${domain}** issues.
|
|
147
|
+
${contextBlock}
|
|
148
|
+
## Allowed Tools
|
|
149
|
+
- Grep — search for patterns across the codebase
|
|
150
|
+
- Bash — run analysis commands (read-only: find, wc, grep, awk, sort)
|
|
151
|
+
- Read — read specific sections of files (max 500 lines at a time using offset/limit)
|
|
152
|
+
- NO Write, Edit, or network tools
|
|
153
|
+
|
|
154
|
+
## Strategy
|
|
155
|
+
${cfg.instructions}
|
|
156
|
+
|
|
157
|
+
## Key patterns to search for
|
|
158
|
+
${cfg.grepPatterns.map((p) => `- \`${p}\``).join('\n')}
|
|
159
|
+
|
|
160
|
+
## Important
|
|
161
|
+
- Do NOT read entire files — use offset/limit to read only relevant sections
|
|
162
|
+
- Do NOT report false positives — confirm each finding before including it
|
|
163
|
+
- If a pattern match is benign (e.g., in a comment or test), skip it
|
|
164
|
+
- Focus on REAL issues with concrete file+line evidence
|
|
165
|
+
- Return at most 15 findings. Prioritize critical/high severity and summarize repeated instances into one finding.
|
|
166
|
+
- Keep each finding and recommendation concise, ideally under 280 characters each.
|
|
167
|
+
|
|
168
|
+
## Output
|
|
169
|
+
Your final response must be ONLY a valid JSON object — no prose, no markdown fences:
|
|
170
|
+
{
|
|
171
|
+
"filesScanned": string[],
|
|
172
|
+
"findings": [
|
|
173
|
+
{
|
|
174
|
+
"file": string,
|
|
175
|
+
"line": number | null,
|
|
176
|
+
"severity": "critical" | "high" | "medium" | "low" | "info",
|
|
177
|
+
"category": "${domain}",
|
|
178
|
+
"finding": string,
|
|
179
|
+
"recommendation": string
|
|
180
|
+
}
|
|
181
|
+
],
|
|
182
|
+
"summary": string
|
|
183
|
+
}`;
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=scanner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.js","sourceRoot":"","sources":["../../src/prompts/scanner.ts"],"names":[],"mappings":"AAiBA,MAAM,CAAC,MAAM,YAAY,GAAiB;IACxC,UAAU;IACV,MAAM;IACN,YAAY;IACZ,gBAAgB;IAChB,cAAc;IACd,SAAS;IACT,aAAa;IACb,gBAAgB;IAChB,eAAe;IACf,YAAY;IACZ,MAAM;IACN,cAAc;IACd,YAAY;IACZ,cAAc;IACd,cAAc;CACf,CAAC;AAIF,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,MAAM,aAAa,GAAqC;IACtD,GAAG,mBAAmB;IACtB,IAAI,EAAE;QACJ,KAAK,EAAE,aAAa;QACpB,YAAY,EAAE;YACZ,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa;YACtD,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS;YAC5C,QAAQ,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc;YACjD,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe;YAC5D,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS;YACpC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS;SACvC;QACD,YAAY,EAAE;;;;;;;6GAO2F;KAC1G;IACD,UAAU,EAAE;QACV,KAAK,EAAE,oBAAoB;QAC3B,YAAY,EAAE;YACZ,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS;YAC1C,SAAS,EAAE,UAAU;YACrB,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,SAAS;SACvC;QACD,YAAY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,CAAC,OAAO,aAAa;;iEAEC,MAAM;EACrE,YAAY;;;;;;;;EAQZ,GAAG,CAAC,YAAY;;;EAGhB,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;;;;;;;;;;;;;;;;;qBAmBjC,MAAM;;;;;;EAMzB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"synthesizer.d.ts","sourceRoot":"","sources":["../../src/prompts/synthesizer.ts"],"names":[],"mappings":"AAAA,wBAAgB,sBAAsB,IAAI,MAAM,CAkC/C"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export function buildSynthesizerPrompt() {
|
|
2
|
+
return `# Role: Synthesizer Agent
|
|
3
|
+
|
|
4
|
+
You are the final step in a multi-agent code audit. You receive findings from multiple scanner agents and produce a unified, prioritized report.
|
|
5
|
+
|
|
6
|
+
## Allowed Tools
|
|
7
|
+
- None — all input is provided in the message
|
|
8
|
+
|
|
9
|
+
## Task
|
|
10
|
+
1. Merge all findings from all scanners
|
|
11
|
+
2. Deduplicate: if two scanners found the same issue in the same file+line, keep only one
|
|
12
|
+
3. Rank by severity: critical → high → medium → low → info
|
|
13
|
+
4. Identify the top 5 priorities the team should act on first
|
|
14
|
+
5. Write a concise executive summary (3-5 sentences)
|
|
15
|
+
|
|
16
|
+
## Output
|
|
17
|
+
Your final response must be ONLY a valid JSON object — no prose, no markdown fences:
|
|
18
|
+
{
|
|
19
|
+
"findings": [
|
|
20
|
+
{
|
|
21
|
+
"file": string,
|
|
22
|
+
"line": number | null,
|
|
23
|
+
"severity": "critical" | "high" | "medium" | "low" | "info",
|
|
24
|
+
"category": "security" | "architecture" | "performance" | "testing" | "error-handling" | "types" | "maintainability" | "token-usage",
|
|
25
|
+
"finding": string,
|
|
26
|
+
"recommendation": string
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"criticalCount": number,
|
|
30
|
+
"highCount": number,
|
|
31
|
+
"totalFiles": number,
|
|
32
|
+
"summary": string,
|
|
33
|
+
"topPriorities": string[]
|
|
34
|
+
}`;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=synthesizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"synthesizer.js","sourceRoot":"","sources":["../../src/prompts/synthesizer.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,sBAAsB;IACpC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCP,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ProviderName } from '../core/runtime-policy.js';
|
|
2
|
+
export type { ProviderRunInput, AgentProvider } from './types.js';
|
|
3
|
+
export declare const AGENT_TOOLS: Record<string, string[]>;
|
|
4
|
+
import type { ProviderRunInput, AgentProvider } from './types.js';
|
|
5
|
+
export declare class ClaudeCliProvider implements AgentProvider {
|
|
6
|
+
readonly name: "claude";
|
|
7
|
+
run(input: ProviderRunInput, onChunk?: (agentName: string, text: string) => void): Promise<string>;
|
|
8
|
+
}
|
|
9
|
+
export declare class CodexCliProvider implements AgentProvider {
|
|
10
|
+
readonly name: "codex";
|
|
11
|
+
run(input: ProviderRunInput, onChunk?: (agentName: string, text: string) => void): Promise<string>;
|
|
12
|
+
}
|
|
13
|
+
export declare function createProvider(name: ProviderName, policy?: {
|
|
14
|
+
openrouterModel?: string;
|
|
15
|
+
}): AgentProvider;
|
|
16
|
+
//# sourceMappingURL=cli-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-provider.d.ts","sourceRoot":"","sources":["../../src/providers/cli-provider.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAiB,MAAM,2BAA2B,CAAC;AAI7E,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAOlE,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAQhD,CAAC;AAKF,OAAO,KAAK,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AA4DlE,qBAAa,iBAAkB,YAAW,aAAa;IACrD,QAAQ,CAAC,IAAI,EAAG,QAAQ,CAAU;IAE5B,GAAG,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;CA+BzG;AAED,qBAAa,gBAAiB,YAAW,aAAa;IACpD,QAAQ,CAAC,IAAI,EAAG,OAAO,CAAU;IAE3B,GAAG,CAAC,KAAK,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;CAyBzG;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,YAAY,EAAE,MAAM,CAAC,EAAE;IAAE,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,aAAa,CAUvG"}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { mkdtempSync, readFileSync, rmSync } from 'fs';
|
|
2
|
+
import { tmpdir } from 'os';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
import { spawn } from 'child_process';
|
|
5
|
+
import { limitChars } from '../core/runtime-policy.js';
|
|
6
|
+
import { SdkProvider } from './sdk-provider.js';
|
|
7
|
+
import { OpenRouterProvider } from './openrouter-provider.js';
|
|
8
|
+
const AGENT_TIMEOUT_MS = 5 * 60 * 1000;
|
|
9
|
+
const USAGE_UNAVAILABLE = '\0usage-unavailable\0';
|
|
10
|
+
const STRUCTURED_RESULT_MAX_CHARS = 200_000;
|
|
11
|
+
// Minimal tool sets per agent role — principle of least privilege
|
|
12
|
+
export const AGENT_TOOLS = {
|
|
13
|
+
planner: ['Read', 'Glob', 'Grep'],
|
|
14
|
+
'investigator-backend': ['Read', 'Glob', 'Grep', 'Bash'],
|
|
15
|
+
'investigator-frontend': ['Read', 'Glob', 'Grep', 'Bash'],
|
|
16
|
+
'investigator-bug-history': ['Read', 'Glob', 'Grep', 'Bash'],
|
|
17
|
+
developer: ['Read', 'Edit', 'Write', 'Bash'],
|
|
18
|
+
reviewer: ['Read', 'Glob', 'Grep'],
|
|
19
|
+
qa: ['Bash', 'Read'],
|
|
20
|
+
};
|
|
21
|
+
const DEFAULT_TOOLS = ['Read', 'Glob', 'Grep'];
|
|
22
|
+
function runProcess(command, args, cwd, agentName, maxOutputChars, onChunk) {
|
|
23
|
+
return new Promise((resolve, reject) => {
|
|
24
|
+
const proc = spawn(command, args, {
|
|
25
|
+
cwd,
|
|
26
|
+
env: process.env,
|
|
27
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
28
|
+
});
|
|
29
|
+
let stdout = '';
|
|
30
|
+
let stderr = '';
|
|
31
|
+
let settled = false;
|
|
32
|
+
const timer = setTimeout(() => {
|
|
33
|
+
if (settled)
|
|
34
|
+
return;
|
|
35
|
+
settled = true;
|
|
36
|
+
proc.kill('SIGTERM');
|
|
37
|
+
reject(new Error(`[${agentName}] ${command} timed out after ${AGENT_TIMEOUT_MS / 1000}s`));
|
|
38
|
+
}, AGENT_TIMEOUT_MS);
|
|
39
|
+
proc.stdout.on('data', (chunk) => {
|
|
40
|
+
const text = chunk.toString();
|
|
41
|
+
stdout += text;
|
|
42
|
+
onChunk?.(agentName, text);
|
|
43
|
+
});
|
|
44
|
+
proc.stderr.on('data', (chunk) => {
|
|
45
|
+
const text = chunk.toString();
|
|
46
|
+
stderr += text;
|
|
47
|
+
onChunk?.(agentName, text);
|
|
48
|
+
});
|
|
49
|
+
proc.on('close', (code) => {
|
|
50
|
+
if (settled)
|
|
51
|
+
return;
|
|
52
|
+
settled = true;
|
|
53
|
+
clearTimeout(timer);
|
|
54
|
+
if (code !== 0 && !stdout.trim()) {
|
|
55
|
+
reject(new Error(`[${agentName}] ${command} exited with code ${code}: ${limitChars(stderr, maxOutputChars)}`));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
resolve(limitChars(stdout, maxOutputChars));
|
|
59
|
+
});
|
|
60
|
+
proc.on('error', (err) => {
|
|
61
|
+
if (settled)
|
|
62
|
+
return;
|
|
63
|
+
settled = true;
|
|
64
|
+
clearTimeout(timer);
|
|
65
|
+
reject(new Error(`[${agentName}] failed to spawn ${command}: ${err.message}`));
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
export class ClaudeCliProvider {
|
|
70
|
+
name = 'claude';
|
|
71
|
+
async run(input, onChunk) {
|
|
72
|
+
const allowedTools = AGENT_TOOLS[input.agentName] ?? DEFAULT_TOOLS;
|
|
73
|
+
const args = [
|
|
74
|
+
'-p', input.userMessage,
|
|
75
|
+
'--output-format', 'json',
|
|
76
|
+
'--model', input.policy.claudeModel,
|
|
77
|
+
'--max-budget-usd', String(input.policy.claudeMaxBudgetUsd),
|
|
78
|
+
'--allowedTools', allowedTools.join(','),
|
|
79
|
+
];
|
|
80
|
+
// Use a large cap for raw so the outer JSON envelope isn't truncated
|
|
81
|
+
const raw = await runProcess('claude', args, input.cwd, input.agentName, 200_000, onChunk);
|
|
82
|
+
onChunk?.(input.agentName, USAGE_UNAVAILABLE);
|
|
83
|
+
try {
|
|
84
|
+
const event = JSON.parse(raw);
|
|
85
|
+
if (event.is_error) {
|
|
86
|
+
const msg = event.result ?? 'unknown';
|
|
87
|
+
if (typeof msg === 'string' && msg.includes('budget')) {
|
|
88
|
+
throw new Error(`[${input.agentName}] budget exceeded ($${input.policy.claudeMaxBudgetUsd}). Use --budget normal or --budget deep for larger tasks.`);
|
|
89
|
+
}
|
|
90
|
+
throw new Error(`[${input.agentName}] claude error: ${msg}`);
|
|
91
|
+
}
|
|
92
|
+
// Truncate only the result content, not the JSON envelope
|
|
93
|
+
if (typeof event.result === 'string') {
|
|
94
|
+
return limitChars(event.result, Math.max(input.policy.maxOutputChars, STRUCTURED_RESULT_MAX_CHARS));
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
if (err instanceof Error && err.message.startsWith(`[${input.agentName}]`))
|
|
99
|
+
throw err;
|
|
100
|
+
}
|
|
101
|
+
return limitChars(raw, input.policy.maxOutputChars);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
export class CodexCliProvider {
|
|
105
|
+
name = 'codex';
|
|
106
|
+
async run(input, onChunk) {
|
|
107
|
+
const tempDir = mkdtempSync(join(tmpdir(), 'ai-runtime-codex-'));
|
|
108
|
+
const outputFile = join(tempDir, 'last-message.txt');
|
|
109
|
+
const prompt = `${input.systemPrompt}\n\n${input.userMessage}`;
|
|
110
|
+
const args = [
|
|
111
|
+
'exec',
|
|
112
|
+
'-C', input.cwd,
|
|
113
|
+
'-m', input.policy.codexModel,
|
|
114
|
+
'-s', 'workspace-write',
|
|
115
|
+
'-a', 'never',
|
|
116
|
+
'--ephemeral',
|
|
117
|
+
'--ignore-rules',
|
|
118
|
+
'--color', 'never',
|
|
119
|
+
'-o', outputFile,
|
|
120
|
+
prompt,
|
|
121
|
+
];
|
|
122
|
+
try {
|
|
123
|
+
await runProcess('codex', args, input.cwd, input.agentName, input.policy.maxOutputChars, onChunk);
|
|
124
|
+
onChunk?.(input.agentName, USAGE_UNAVAILABLE);
|
|
125
|
+
return limitChars(readFileSync(outputFile, 'utf8'), input.policy.maxOutputChars);
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
rmSync(tempDir, { recursive: true, force: true });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
export function createProvider(name, policy) {
|
|
133
|
+
if (name === 'codex')
|
|
134
|
+
return new CodexCliProvider();
|
|
135
|
+
if (name === 'openrouter') {
|
|
136
|
+
const model = policy?.openrouterModel ?? process.env['OPENROUTER_MODEL'] ?? 'moonshotai/kimi-k2';
|
|
137
|
+
return new OpenRouterProvider(model);
|
|
138
|
+
}
|
|
139
|
+
// SDK provider when key is set: enables prompt caching + real streaming
|
|
140
|
+
// Falls back to CLI provider when no key (uses claude CLI session auth)
|
|
141
|
+
if (process.env['ANTHROPIC_API_KEY'])
|
|
142
|
+
return new SdkProvider();
|
|
143
|
+
return new ClaudeCliProvider();
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=cli-provider.js.map
|