agent-security-scanner-mcp 3.20.0 → 4.0.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.
Files changed (126) hide show
  1. package/README.md +144 -43
  2. package/code-review-agent/.env.example +8 -0
  3. package/code-review-agent/README.md +142 -0
  4. package/code-review-agent/TODO.md +149 -0
  5. package/code-review-agent/bin/cr-agent.ts +313 -0
  6. package/code-review-agent/dist/bin/cr-agent.d.ts +3 -0
  7. package/code-review-agent/dist/bin/cr-agent.d.ts.map +1 -0
  8. package/code-review-agent/dist/bin/cr-agent.js +299 -0
  9. package/code-review-agent/dist/bin/cr-agent.js.map +1 -0
  10. package/code-review-agent/dist/src/analyzer/engine.d.ts +16 -0
  11. package/code-review-agent/dist/src/analyzer/engine.d.ts.map +1 -0
  12. package/code-review-agent/dist/src/analyzer/engine.js +298 -0
  13. package/code-review-agent/dist/src/analyzer/engine.js.map +1 -0
  14. package/code-review-agent/dist/src/analyzer/intent.d.ts +10 -0
  15. package/code-review-agent/dist/src/analyzer/intent.d.ts.map +1 -0
  16. package/code-review-agent/dist/src/analyzer/intent.js +40 -0
  17. package/code-review-agent/dist/src/analyzer/intent.js.map +1 -0
  18. package/code-review-agent/dist/src/analyzer/semantic.d.ts +19 -0
  19. package/code-review-agent/dist/src/analyzer/semantic.d.ts.map +1 -0
  20. package/code-review-agent/dist/src/analyzer/semantic.js +150 -0
  21. package/code-review-agent/dist/src/analyzer/semantic.js.map +1 -0
  22. package/code-review-agent/dist/src/context/assembler.d.ts +16 -0
  23. package/code-review-agent/dist/src/context/assembler.d.ts.map +1 -0
  24. package/code-review-agent/dist/src/context/assembler.js +135 -0
  25. package/code-review-agent/dist/src/context/assembler.js.map +1 -0
  26. package/code-review-agent/dist/src/context/file.d.ts +6 -0
  27. package/code-review-agent/dist/src/context/file.d.ts.map +1 -0
  28. package/code-review-agent/dist/src/context/file.js +139 -0
  29. package/code-review-agent/dist/src/context/file.js.map +1 -0
  30. package/code-review-agent/dist/src/context/project.d.ts +4 -0
  31. package/code-review-agent/dist/src/context/project.d.ts.map +1 -0
  32. package/code-review-agent/dist/src/context/project.js +252 -0
  33. package/code-review-agent/dist/src/context/project.js.map +1 -0
  34. package/code-review-agent/dist/src/graph/dependency.d.ts +11 -0
  35. package/code-review-agent/dist/src/graph/dependency.d.ts.map +1 -0
  36. package/code-review-agent/dist/src/graph/dependency.js +102 -0
  37. package/code-review-agent/dist/src/graph/dependency.js.map +1 -0
  38. package/code-review-agent/dist/src/graph/resolver.d.ts +9 -0
  39. package/code-review-agent/dist/src/graph/resolver.d.ts.map +1 -0
  40. package/code-review-agent/dist/src/graph/resolver.js +124 -0
  41. package/code-review-agent/dist/src/graph/resolver.js.map +1 -0
  42. package/code-review-agent/dist/src/index.d.ts +21 -0
  43. package/code-review-agent/dist/src/index.d.ts.map +1 -0
  44. package/code-review-agent/dist/src/index.js +21 -0
  45. package/code-review-agent/dist/src/index.js.map +1 -0
  46. package/code-review-agent/dist/src/llm/anthropic.d.ts +13 -0
  47. package/code-review-agent/dist/src/llm/anthropic.d.ts.map +1 -0
  48. package/code-review-agent/dist/src/llm/anthropic.js +83 -0
  49. package/code-review-agent/dist/src/llm/anthropic.js.map +1 -0
  50. package/code-review-agent/dist/src/llm/claude-cli.d.ts +13 -0
  51. package/code-review-agent/dist/src/llm/claude-cli.d.ts.map +1 -0
  52. package/code-review-agent/dist/src/llm/claude-cli.js +142 -0
  53. package/code-review-agent/dist/src/llm/claude-cli.js.map +1 -0
  54. package/code-review-agent/dist/src/llm/openai.d.ts +13 -0
  55. package/code-review-agent/dist/src/llm/openai.d.ts.map +1 -0
  56. package/code-review-agent/dist/src/llm/openai.js +78 -0
  57. package/code-review-agent/dist/src/llm/openai.js.map +1 -0
  58. package/code-review-agent/dist/src/llm/provider.d.ts +18 -0
  59. package/code-review-agent/dist/src/llm/provider.d.ts.map +1 -0
  60. package/code-review-agent/dist/src/llm/provider.js +11 -0
  61. package/code-review-agent/dist/src/llm/provider.js.map +1 -0
  62. package/code-review-agent/dist/src/llm/router.d.ts +14 -0
  63. package/code-review-agent/dist/src/llm/router.d.ts.map +1 -0
  64. package/code-review-agent/dist/src/llm/router.js +67 -0
  65. package/code-review-agent/dist/src/llm/router.js.map +1 -0
  66. package/code-review-agent/dist/src/llm/schemas.d.ts +18 -0
  67. package/code-review-agent/dist/src/llm/schemas.d.ts.map +1 -0
  68. package/code-review-agent/dist/src/llm/schemas.js +91 -0
  69. package/code-review-agent/dist/src/llm/schemas.js.map +1 -0
  70. package/code-review-agent/dist/src/types/analysis.d.ts +56 -0
  71. package/code-review-agent/dist/src/types/analysis.d.ts.map +1 -0
  72. package/code-review-agent/dist/src/types/analysis.js +2 -0
  73. package/code-review-agent/dist/src/types/analysis.js.map +1 -0
  74. package/code-review-agent/dist/src/types/config.d.ts +24 -0
  75. package/code-review-agent/dist/src/types/config.d.ts.map +1 -0
  76. package/code-review-agent/dist/src/types/config.js +42 -0
  77. package/code-review-agent/dist/src/types/config.js.map +1 -0
  78. package/code-review-agent/dist/src/types/findings.d.ts +236 -0
  79. package/code-review-agent/dist/src/types/findings.d.ts.map +1 -0
  80. package/code-review-agent/dist/src/types/findings.js +64 -0
  81. package/code-review-agent/dist/src/types/findings.js.map +1 -0
  82. package/code-review-agent/package.json +36 -0
  83. package/code-review-agent/src/analyzer/engine.ts +374 -0
  84. package/code-review-agent/src/analyzer/intent.ts +49 -0
  85. package/code-review-agent/src/analyzer/semantic.ts +222 -0
  86. package/code-review-agent/src/context/assembler.ts +165 -0
  87. package/code-review-agent/src/context/file.ts +145 -0
  88. package/code-review-agent/src/context/project.ts +253 -0
  89. package/code-review-agent/src/graph/dependency.ts +116 -0
  90. package/code-review-agent/src/graph/resolver.ts +138 -0
  91. package/code-review-agent/src/index.ts +58 -0
  92. package/code-review-agent/src/llm/anthropic.ts +106 -0
  93. package/code-review-agent/src/llm/claude-cli.ts +188 -0
  94. package/code-review-agent/src/llm/openai.ts +95 -0
  95. package/code-review-agent/src/llm/provider.ts +33 -0
  96. package/code-review-agent/src/llm/router.ts +86 -0
  97. package/code-review-agent/src/llm/schemas.ts +125 -0
  98. package/code-review-agent/src/types/analysis.ts +62 -0
  99. package/code-review-agent/src/types/config.ts +72 -0
  100. package/code-review-agent/src/types/findings.ts +81 -0
  101. package/code-review-agent/tests/analyzer/engine.test.ts +194 -0
  102. package/code-review-agent/tests/analyzer/intent.test.ts +76 -0
  103. package/code-review-agent/tests/analyzer/semantic.test.ts +131 -0
  104. package/code-review-agent/tests/context/file.test.ts +21 -0
  105. package/code-review-agent/tests/context/project.test.ts +20 -0
  106. package/code-review-agent/tests/fixtures/safe-build-tool/README.md +19 -0
  107. package/code-review-agent/tests/fixtures/safe-build-tool/builder.js +52 -0
  108. package/code-review-agent/tests/fixtures/safe-file-manager/README.md +16 -0
  109. package/code-review-agent/tests/fixtures/safe-file-manager/organizer.py +70 -0
  110. package/code-review-agent/tests/fixtures/vuln-api-server/README.md +17 -0
  111. package/code-review-agent/tests/fixtures/vuln-api-server/server.js +52 -0
  112. package/code-review-agent/tests/fixtures/vuln-ecommerce/README.md +18 -0
  113. package/code-review-agent/tests/fixtures/vuln-ecommerce/checkout.js +63 -0
  114. package/code-review-agent/tests/graph/dependency.test.ts +136 -0
  115. package/code-review-agent/tests/helpers/mock-provider.ts +48 -0
  116. package/code-review-agent/tests/llm/claude-cli.test.ts +251 -0
  117. package/code-review-agent/tests/llm/router.test.ts +77 -0
  118. package/code-review-agent/tests/llm/schemas.test.ts +142 -0
  119. package/code-review-agent/tsconfig.json +20 -0
  120. package/code-review-agent/vitest.config.ts +11 -0
  121. package/index.js +18 -18
  122. package/openclaw.plugin.json +2 -2
  123. package/package.json +13 -3
  124. package/server.json +3 -3
  125. package/src/cli/init-hooks.js +3 -3
  126. package/src/cli/init.js +1 -1
@@ -0,0 +1,78 @@
1
+ import OpenAI from 'openai';
2
+ import { encoding_for_model } from 'tiktoken';
3
+ import { SchemaValidationError } from './provider.js';
4
+ import { zodToOpenAIResponseFormat } from './schemas.js';
5
+ const MAX_RETRIES = 3;
6
+ export class OpenAIProvider {
7
+ client;
8
+ encoder = null;
9
+ modelId;
10
+ providerName = 'openai';
11
+ constructor(apiKey, model) {
12
+ this.client = new OpenAI({ apiKey });
13
+ this.modelId = model ?? 'gpt-4o';
14
+ }
15
+ async chat(messages) {
16
+ const response = await this.client.chat.completions.create({
17
+ model: this.modelId,
18
+ messages: messages.map((m) => ({ role: m.role, content: m.content })),
19
+ max_tokens: 4096,
20
+ });
21
+ return response.choices[0]?.message?.content ?? '';
22
+ }
23
+ async chatStructured(messages, schema, schemaName) {
24
+ const responseFormat = zodToOpenAIResponseFormat(schema, schemaName);
25
+ let lastError = null;
26
+ const conversationMessages = messages.map((m) => ({
27
+ role: m.role,
28
+ content: m.content,
29
+ }));
30
+ for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
31
+ const response = await this.client.chat.completions.create({
32
+ model: this.modelId,
33
+ messages: conversationMessages,
34
+ max_tokens: 8192,
35
+ response_format: responseFormat,
36
+ });
37
+ const content = response.choices[0]?.message?.content;
38
+ if (!content) {
39
+ lastError = new Error('Empty response from OpenAI');
40
+ continue;
41
+ }
42
+ let parsed;
43
+ try {
44
+ parsed = JSON.parse(content);
45
+ }
46
+ catch (e) {
47
+ lastError = e instanceof Error ? e : new Error(String(e));
48
+ continue;
49
+ }
50
+ const result = schema.safeParse(parsed);
51
+ if (result.success) {
52
+ return result.data;
53
+ }
54
+ lastError = new Error(result.error.message);
55
+ conversationMessages.push({
56
+ role: 'assistant',
57
+ content,
58
+ });
59
+ conversationMessages.push({
60
+ role: 'user',
61
+ content: `Schema validation error: ${result.error.message}. Please fix and respond again.`,
62
+ });
63
+ }
64
+ throw new SchemaValidationError(MAX_RETRIES, lastError);
65
+ }
66
+ countTokens(text) {
67
+ try {
68
+ if (!this.encoder) {
69
+ this.encoder = encoding_for_model(this.modelId);
70
+ }
71
+ return this.encoder.encode(text).length;
72
+ }
73
+ catch {
74
+ return Math.ceil(text.length / 4);
75
+ }
76
+ }
77
+ }
78
+ //# sourceMappingURL=openai.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openai.js","sourceRoot":"","sources":["../../../src/llm/openai.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAiB,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE7D,OAAO,EAAsC,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEzD,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB,MAAM,OAAO,cAAc;IACjB,MAAM,CAAS;IACf,OAAO,GAAoB,IAAI,CAAC;IAC/B,OAAO,CAAS;IAChB,YAAY,GAAG,QAAQ,CAAC;IAEjC,YAAY,MAAc,EAAE,KAAc;QACxC,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;QACrC,IAAI,CAAC,OAAO,GAAG,KAAK,IAAI,QAAQ,CAAC;IACnC,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAAuB;QAChC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YACzD,KAAK,EAAE,IAAI,CAAC,OAAO;YACnB,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YACrE,UAAU,EAAE,IAAI;SACjB,CAAC,CAAC;QAEH,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,IAAI,EAAE,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,QAAuB,EACvB,MAAoB,EACpB,UAAkB;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,OAAO,MAAM,CAAC,IAAI,CAAC;YACrB,CAAC;YAED,SAAS,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAE5C,oBAAoB,CAAC,IAAI,CAAC;gBACxB,IAAI,EAAE,WAAoB;gBAC1B,OAAO;aACR,CAAC,CAAC;YACH,oBAAoB,CAAC,IAAI,CAAC;gBACxB,IAAI,EAAE,MAAe;gBACrB,OAAO,EAAE,4BAA4B,MAAM,CAAC,KAAK,CAAC,OAAO,iCAAiC;aAC3F,CAAC,CAAC;QACL,CAAC;QAED,MAAM,IAAI,qBAAqB,CAAC,WAAW,EAAE,SAAU,CAAC,CAAC;IAC3D,CAAC;IAED,WAAW,CAAC,IAAY;QACtB,IAAI,CAAC;YACH,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAClB,IAAI,CAAC,OAAO,GAAG,kBAAkB,CAAC,IAAI,CAAC,OAAmD,CAAC,CAAC;YAC9F,CAAC;YACD,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;QAC1C,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,18 @@
1
+ import type { z } from 'zod';
2
+ export interface ChatMessage {
3
+ role: 'system' | 'user' | 'assistant';
4
+ content: string;
5
+ }
6
+ export interface LLMProvider {
7
+ readonly modelId: string;
8
+ readonly providerName: string;
9
+ chat(messages: ChatMessage[]): Promise<string>;
10
+ chatStructured<T>(messages: ChatMessage[], schema: z.ZodType<T>, schemaName: string): Promise<T>;
11
+ countTokens(text: string): number;
12
+ }
13
+ export declare class SchemaValidationError extends Error {
14
+ readonly attempts: number;
15
+ readonly lastError: Error;
16
+ constructor(attempts: number, lastError: Error);
17
+ }
18
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/llm/provider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,WAAW,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B,IAAI,CAAC,QAAQ,EAAE,WAAW,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAE/C,cAAc,CAAC,CAAC,EACd,QAAQ,EAAE,WAAW,EAAE,EACvB,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EACpB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,CAAC,CAAC,CAAC;IAEd,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CACnC;AAED,qBAAa,qBAAsB,SAAQ,KAAK;aAE5B,QAAQ,EAAE,MAAM;aAChB,SAAS,EAAE,KAAK;gBADhB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,KAAK;CAOnC"}
@@ -0,0 +1,11 @@
1
+ export class SchemaValidationError extends Error {
2
+ attempts;
3
+ lastError;
4
+ constructor(attempts, lastError) {
5
+ super(`Schema validation failed after ${attempts} attempts: ${lastError.message}`);
6
+ this.attempts = attempts;
7
+ this.lastError = lastError;
8
+ this.name = 'SchemaValidationError';
9
+ }
10
+ }
11
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../../src/llm/provider.ts"],"names":[],"mappings":"AAsBA,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAE5B;IACA;IAFlB,YACkB,QAAgB,EAChB,SAAgB;QAEhC,KAAK,CACH,kCAAkC,QAAQ,cAAc,SAAS,CAAC,OAAO,EAAE,CAC5E,CAAC;QALc,aAAQ,GAAR,QAAQ,CAAQ;QAChB,cAAS,GAAT,SAAS,CAAO;QAKhC,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ import type { AnalysisOptions } from '../types/config.js';
2
+ import type { LLMProvider } from './provider.js';
3
+ export declare class ModelRouter {
4
+ private triageProvider;
5
+ private analysisProvider;
6
+ private options;
7
+ constructor(options: AnalysisOptions);
8
+ getTriageProvider(): LLMProvider;
9
+ getAnalysisProvider(): LLMProvider;
10
+ estimateCost(tokens: number, model?: string): number;
11
+ private createProvider;
12
+ private getApiKey;
13
+ }
14
+ //# sourceMappingURL=router.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../../src/llm/router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAI1D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAsBjD,qBAAa,WAAW;IACtB,OAAO,CAAC,cAAc,CAA4B;IAClD,OAAO,CAAC,gBAAgB,CAA4B;IACpD,OAAO,CAAC,OAAO,CAAkB;gBAErB,OAAO,EAAE,eAAe;IAIpC,iBAAiB,IAAI,WAAW;IAShC,mBAAmB,IAAI,WAAW;IASlC,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM;IAOpD,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,SAAS;CAWlB"}
@@ -0,0 +1,67 @@
1
+ import { AnthropicProvider } from './anthropic.js';
2
+ import { ClaudeCliProvider } from './claude-cli.js';
3
+ import { OpenAIProvider } from './openai.js';
4
+ const TRIAGE_MODELS = {
5
+ anthropic: 'claude-haiku-4-5-20251001',
6
+ openai: 'gpt-4o-mini',
7
+ 'claude-cli': 'haiku',
8
+ };
9
+ const ANALYSIS_MODELS = {
10
+ anthropic: 'claude-sonnet-4-20250514',
11
+ openai: 'gpt-4o',
12
+ 'claude-cli': 'sonnet',
13
+ };
14
+ // Approximate USD per million tokens (input + output averaged)
15
+ const COST_PER_MILLION = {
16
+ 'claude-sonnet-4-20250514': 9,
17
+ 'claude-haiku-4-5-20251001': 1.25,
18
+ 'gpt-4o': 7.5,
19
+ 'gpt-4o-mini': 0.3,
20
+ };
21
+ export class ModelRouter {
22
+ triageProvider = null;
23
+ analysisProvider = null;
24
+ options;
25
+ constructor(options) {
26
+ this.options = options;
27
+ }
28
+ getTriageProvider() {
29
+ if (!this.triageProvider) {
30
+ const model = this.options.triageModel ?? TRIAGE_MODELS[this.options.provider];
31
+ this.triageProvider = this.createProvider(model);
32
+ }
33
+ return this.triageProvider;
34
+ }
35
+ getAnalysisProvider() {
36
+ if (!this.analysisProvider) {
37
+ const model = this.options.model ?? ANALYSIS_MODELS[this.options.provider];
38
+ this.analysisProvider = this.createProvider(model);
39
+ }
40
+ return this.analysisProvider;
41
+ }
42
+ estimateCost(tokens, model) {
43
+ const modelId = model ?? this.options.model ?? ANALYSIS_MODELS[this.options.provider];
44
+ const rate = COST_PER_MILLION[modelId] ?? 5;
45
+ return (tokens / 1_000_000) * rate;
46
+ }
47
+ createProvider(model) {
48
+ const provider = this.options.provider;
49
+ if (provider === 'claude-cli') {
50
+ return new ClaudeCliProvider(model);
51
+ }
52
+ const apiKey = this.getApiKey(provider);
53
+ if (provider === 'anthropic') {
54
+ return new AnthropicProvider(apiKey, model);
55
+ }
56
+ return new OpenAIProvider(apiKey, model);
57
+ }
58
+ getApiKey(provider) {
59
+ const envVar = provider === 'anthropic' ? 'ANTHROPIC_API_KEY' : 'OPENAI_API_KEY';
60
+ const key = process.env[envVar];
61
+ if (!key) {
62
+ throw new Error(`Missing API key. Set ${envVar} environment variable or pass it in options.`);
63
+ }
64
+ return key;
65
+ }
66
+ }
67
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,CACb,wBAAwB,MAAM,8CAA8C,CAC7E,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
@@ -0,0 +1,18 @@
1
+ import { z } from 'zod';
2
+ type JsonSchema = Record<string, unknown>;
3
+ export declare function zodToJsonSchema(schema: z.ZodTypeAny): JsonSchema;
4
+ export declare function zodToAnthropicTool(schema: z.ZodTypeAny, name: string, description: string): {
5
+ name: string;
6
+ description: string;
7
+ input_schema: JsonSchema;
8
+ };
9
+ export declare function zodToOpenAIResponseFormat(schema: z.ZodTypeAny, name: string): {
10
+ type: 'json_schema';
11
+ json_schema: {
12
+ name: string;
13
+ strict: boolean;
14
+ schema: JsonSchema;
15
+ };
16
+ };
17
+ export {};
18
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/llm/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,KAAK,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE1C,wBAAgB,eAAe,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,GAAG,UAAU,CAEhE;AAuFD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,CAAC,CAAC,UAAU,EACpB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAClB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,UAAU,CAAC;CAC1B,CAMA;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,CAAC,CAAC,UAAU,EACpB,IAAI,EAAE,MAAM,GACX;IACD,IAAI,EAAE,aAAa,CAAC;IACpB,WAAW,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,UAAU,CAAA;KAAE,CAAC;CACpE,CASA"}
@@ -0,0 +1,91 @@
1
+ export function zodToJsonSchema(schema) {
2
+ return convertType(schema);
3
+ }
4
+ function convertType(schema) {
5
+ const def = schema._def;
6
+ const typeName = def.typeName;
7
+ switch (typeName) {
8
+ case 'ZodString':
9
+ return { type: 'string' };
10
+ case 'ZodNumber': {
11
+ const result = { type: 'number' };
12
+ for (const check of def.checks ?? []) {
13
+ if (check.kind === 'min')
14
+ result.minimum = check.value;
15
+ if (check.kind === 'max')
16
+ result.maximum = check.value;
17
+ }
18
+ return result;
19
+ }
20
+ case 'ZodBoolean':
21
+ return { type: 'boolean' };
22
+ case 'ZodLiteral':
23
+ return { type: typeof def.value, const: def.value };
24
+ case 'ZodEnum':
25
+ return { type: 'string', enum: def.values };
26
+ case 'ZodArray':
27
+ return { type: 'array', items: convertType(def.type) };
28
+ case 'ZodObject': {
29
+ const shape = def.shape();
30
+ const properties = {};
31
+ const required = [];
32
+ for (const [key, value] of Object.entries(shape)) {
33
+ const fieldSchema = value;
34
+ const isOptional = fieldSchema.isOptional();
35
+ properties[key] = convertType(fieldSchema);
36
+ if (!isOptional) {
37
+ required.push(key);
38
+ }
39
+ }
40
+ const result = {
41
+ type: 'object',
42
+ properties,
43
+ additionalProperties: false,
44
+ };
45
+ if (required.length > 0) {
46
+ result.required = required;
47
+ }
48
+ return result;
49
+ }
50
+ case 'ZodOptional':
51
+ return convertType(def.innerType);
52
+ case 'ZodNullable': {
53
+ const inner = convertType(def.innerType);
54
+ return { anyOf: [inner, { type: 'null' }] };
55
+ }
56
+ case 'ZodDefault':
57
+ return convertType(def.innerType);
58
+ case 'ZodEffects':
59
+ return convertType(def.schema);
60
+ case 'ZodUnion': {
61
+ const options = def.options.map(convertType);
62
+ return { anyOf: options };
63
+ }
64
+ case 'ZodRecord':
65
+ return {
66
+ type: 'object',
67
+ additionalProperties: convertType(def.valueType),
68
+ };
69
+ default:
70
+ // Fail loud instead of silently producing invalid schema
71
+ throw new Error(`zodToJsonSchema: unsupported Zod type "${typeName}". Add explicit handling for this type.`);
72
+ }
73
+ }
74
+ export function zodToAnthropicTool(schema, name, description) {
75
+ return {
76
+ name,
77
+ description,
78
+ input_schema: zodToJsonSchema(schema),
79
+ };
80
+ }
81
+ export function zodToOpenAIResponseFormat(schema, name) {
82
+ return {
83
+ type: 'json_schema',
84
+ json_schema: {
85
+ name,
86
+ strict: true,
87
+ schema: zodToJsonSchema(schema),
88
+ },
89
+ };
90
+ }
91
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../src/llm/schemas.ts"],"names":[],"mappings":"AAIA,MAAM,UAAU,eAAe,CAAC,MAAoB;IAClD,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC;AAC7B,CAAC;AAED,SAAS,WAAW,CAAC,MAAoB;IACvC,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC;IACxB,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAkB,CAAC;IAExC,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,WAAW;YACd,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAE5B,KAAK,WAAW,CAAC,CAAC,CAAC;YACjB,MAAM,MAAM,GAAe,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;YAC9C,KAAK,MAAM,KAAK,IAAI,GAAG,CAAC,MAAM,IAAI,EAAE,EAAE,CAAC;gBACrC,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK;oBAAE,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC;gBACvD,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK;oBAAE,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC;YACzD,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QAED,KAAK,YAAY;YACf,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAE7B,KAAK,YAAY;YACf,OAAO,EAAE,IAAI,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WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YACzC,OAAO,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;QAC9C,CAAC;QAED,KAAK,YAAY;YACf,OAAO,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAEpC,KAAK,YAAY;YACf,OAAO,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAEjC,KAAK,UAAU,CAAC,CAAC,CAAC;YAChB,MAAM,OAAO,GAAI,GAAG,CAAC,OAA0B,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YACjE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC;QAC5B,CAAC;QAED,KAAK,WAAW;YACd,OAAO;gBACL,IAAI,EAAE,QAAQ;gBACd,oBAAoB,EAAE,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC;aACjD,CAAC;QAEJ;YACE,yDAAyD;YACzD,MAAM,IAAI,KAAK,CAAC,0CAA0C,QAAQ,yCAAyC,CAAC,CAAC;IACjH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,MAAoB,EACpB,IAAY,EACZ,WAAmB;IAMnB,OAAO;QACL,IAAI;QACJ,WAAW;QACX,YAAY,EAAE,eAAe,CAAC,MAAM,CAAC;KACtC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,MAAoB,EACpB,IAAY;IAKZ,OAAO;QACL,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE;YACX,IAAI;YACJ,MAAM,EAAE,IAAI;YACZ,MAAM,EAAE,eAAe,CAAC,MAAM,CAAC;SAChC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,56 @@
1
+ import type { Finding, IntentProfile, TriageDecision } from './findings.js';
2
+ export interface AnalysisResult {
3
+ findings: Finding[];
4
+ intentProfile: IntentProfile | null;
5
+ fileResults: FileAnalysisResult[];
6
+ stats: AnalysisStats;
7
+ }
8
+ export interface FileAnalysisResult {
9
+ file: string;
10
+ findings: Finding[];
11
+ triageDecision: TriageDecision | null;
12
+ tokensUsed: number;
13
+ skipped: boolean;
14
+ truncated: boolean;
15
+ }
16
+ export interface AnalysisStats {
17
+ filesAnalyzed: number;
18
+ filesSkipped: number;
19
+ totalFindings: number;
20
+ findingsBySeverity: Record<string, number>;
21
+ totalTokensUsed: number;
22
+ estimatedCost: number;
23
+ durationMs: number;
24
+ }
25
+ export interface ProjectContext {
26
+ readme: string;
27
+ packageMeta: Record<string, unknown> | null;
28
+ directoryTree: string;
29
+ envVars: string[];
30
+ hasDockerfile: boolean;
31
+ hasCI: boolean;
32
+ language: string;
33
+ framework: string;
34
+ }
35
+ export interface FileContext {
36
+ filePath: string;
37
+ content: string;
38
+ language: string;
39
+ lineCount: number;
40
+ imports: string[];
41
+ importedBy: string[];
42
+ siblingFiles: string[];
43
+ isTestFile: boolean;
44
+ isConfigFile: boolean;
45
+ isGenerated: boolean;
46
+ }
47
+ export interface DependencyNode {
48
+ file: string;
49
+ imports: string[];
50
+ importedBy: string[];
51
+ }
52
+ export interface DependencyGraph {
53
+ nodes: Map<string, DependencyNode>;
54
+ entryPoints: string[];
55
+ }
56
+ //# sourceMappingURL=analysis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analysis.d.ts","sourceRoot":"","sources":["../../../src/types/analysis.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE5E,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,WAAW,EAAE,kBAAkB,EAAE,CAAC;IAClC,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,EAAE,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AAW,eAAe;IAC9B,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACnC,WAAW,EAAE,MAAM,EAAE,CAAC;CACvB"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=analysis.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analysis.js","sourceRoot":"","sources":["../../../src/types/analysis.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ export interface AnalysisOptions {
2
+ provider: 'anthropic' | 'openai' | 'claude-cli';
3
+ model?: string;
4
+ triageModel?: string;
5
+ confidenceThreshold: number;
6
+ format: 'text' | 'json' | 'sarif';
7
+ verbose: boolean;
8
+ projectRoot: string;
9
+ exclude: string[];
10
+ concurrencyLimit: number;
11
+ maxFileSize: number;
12
+ }
13
+ export interface CRAgentConfig {
14
+ provider?: 'anthropic' | 'openai' | 'claude-cli';
15
+ model?: string;
16
+ triageModel?: string;
17
+ confidenceThreshold?: number;
18
+ exclude?: string[];
19
+ concurrencyLimit?: number;
20
+ maxFileSize?: number;
21
+ }
22
+ export declare function loadConfig(projectRoot: string): CRAgentConfig | null;
23
+ export declare function resolveOptions(cliFlags: Partial<AnalysisOptions>, config: CRAgentConfig | null, env?: Record<string, string | undefined>): AnalysisOptions;
24
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/types/config.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,WAAW,GAAG,QAAQ,GAAG,YAAY,CAAC;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,YAAY,CAAC;IACjD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAaD,wBAAgB,UAAU,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAQpE;AAED,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,OAAO,CAAC,eAAe,CAAC,EAClC,MAAM,EAAE,aAAa,GAAG,IAAI,EAC5B,GAAG,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAe,GACpD,eAAe,CAoBjB"}
@@ -0,0 +1,42 @@
1
+ import * as fs from 'node:fs';
2
+ import * as path from 'node:path';
3
+ const DEFAULTS = {
4
+ provider: 'anthropic',
5
+ confidenceThreshold: 0.7,
6
+ format: 'text',
7
+ verbose: false,
8
+ projectRoot: process.cwd(),
9
+ exclude: ['node_modules', 'dist', 'build', '.git', 'vendor', '__pycache__', '.venv', 'venv', 'env', '.env', 'site-packages', '.tox', '.mypy_cache', '.pytest_cache', 'coverage', '.nyc_output', '.next', 'target'],
10
+ concurrencyLimit: 5,
11
+ maxFileSize: 512 * 1024,
12
+ };
13
+ export function loadConfig(projectRoot) {
14
+ const configPath = path.join(projectRoot, '.cr-agent.json');
15
+ try {
16
+ const raw = fs.readFileSync(configPath, 'utf-8');
17
+ return JSON.parse(raw);
18
+ }
19
+ catch {
20
+ return null;
21
+ }
22
+ }
23
+ export function resolveOptions(cliFlags, config, env = process.env) {
24
+ return {
25
+ provider: cliFlags.provider ??
26
+ config?.provider ??
27
+ env.CR_AGENT_PROVIDER ??
28
+ DEFAULTS.provider,
29
+ model: cliFlags.model ?? config?.model ?? env.CR_AGENT_MODEL ?? undefined,
30
+ triageModel: cliFlags.triageModel ?? config?.triageModel ?? undefined,
31
+ confidenceThreshold: cliFlags.confidenceThreshold ??
32
+ config?.confidenceThreshold ??
33
+ (env.CR_AGENT_CONFIDENCE ? parseFloat(env.CR_AGENT_CONFIDENCE) : DEFAULTS.confidenceThreshold),
34
+ format: cliFlags.format ?? DEFAULTS.format,
35
+ verbose: cliFlags.verbose ?? DEFAULTS.verbose,
36
+ projectRoot: cliFlags.projectRoot ?? DEFAULTS.projectRoot,
37
+ exclude: cliFlags.exclude ?? config?.exclude ?? DEFAULTS.exclude,
38
+ concurrencyLimit: Math.max(1, cliFlags.concurrencyLimit ?? config?.concurrencyLimit ?? DEFAULTS.concurrencyLimit),
39
+ maxFileSize: cliFlags.maxFileSize ?? config?.maxFileSize ?? DEFAULTS.maxFileSize,
40
+ };
41
+ }
42
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/types/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAyBlC,MAAM,QAAQ,GAAoB;IAChC,QAAQ,EAAE,WAAW;IACrB,mBAAmB,EAAE,GAAG;IACxB,MAAM,EAAE,MAAM;IACd,OAAO,EAAE,KAAK;IACd,WAAW,EAAE,OAAO,CAAC,GAAG,EAAE;IAC1B,OAAO,EAAE,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,UAAU,EAAE,aAA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