@kevinrabun/judges 3.1.1 → 3.3.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 +19 -12
- package/dist/ast/index.d.ts +13 -3
- package/dist/ast/index.d.ts.map +1 -1
- package/dist/ast/index.js +75 -8
- package/dist/ast/index.js.map +1 -1
- package/dist/ast/tree-sitter-ast.d.ts +34 -0
- package/dist/ast/tree-sitter-ast.d.ts.map +1 -0
- package/dist/ast/tree-sitter-ast.js +955 -0
- package/dist/ast/tree-sitter-ast.js.map +1 -0
- package/dist/evaluators/code-structure.d.ts +3 -3
- package/dist/evaluators/code-structure.js +3 -3
- package/dist/index.js +1 -1
- package/dist/language-patterns.d.ts.map +1 -1
- package/dist/language-patterns.js +8 -0
- package/dist/language-patterns.js.map +1 -1
- package/dist/types.d.ts +1 -1
- package/dist/types.d.ts.map +1 -1
- package/grammars/tree-sitter-c_sharp.wasm +0 -0
- package/grammars/tree-sitter-cpp.wasm +0 -0
- package/grammars/tree-sitter-go.wasm +0 -0
- package/grammars/tree-sitter-java.wasm +0 -0
- package/grammars/tree-sitter-python.wasm +0 -0
- package/grammars/tree-sitter-rust.wasm +0 -0
- package/grammars/tree-sitter-typescript.wasm +0 -0
- package/package.json +13 -2
- package/server.json +2 -2
- package/dist/ast/typescript-ast.d.ts +0 -7
- package/dist/ast/typescript-ast.d.ts.map +0 -1
- package/dist/ast/typescript-ast.js +0 -236
- package/dist/ast/typescript-ast.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Judges Panel
|
|
2
2
|
|
|
3
|
-
An MCP (Model Context Protocol) server that provides a panel of **35 specialized judges** to evaluate AI-generated code — acting as an independent quality gate regardless of which project is being reviewed.
|
|
3
|
+
An MCP (Model Context Protocol) server that provides a panel of **35 specialized judges** to evaluate AI-generated code — acting as an independent quality gate regardless of which project is being reviewed. Combines **deterministic pattern matching & AST analysis** (instant, offline, zero LLM calls) with **LLM-powered deep-review prompts** that let your AI assistant perform expert-persona analysis across all 35 domains.
|
|
4
4
|
|
|
5
5
|
**Highlights:**
|
|
6
6
|
- Includes an **App Builder Workflow (3-step)** demo for release decisions, plain-language risk summaries, and prioritized fixes — see [Try the Demo](#2-try-the-demo).
|
|
@@ -11,7 +11,7 @@ An MCP (Model Context Protocol) server that provides a panel of **35 specialized
|
|
|
11
11
|
[](https://www.npmjs.com/package/@kevinrabun/judges)
|
|
12
12
|
[](https://www.npmjs.com/package/@kevinrabun/judges)
|
|
13
13
|
[](https://opensource.org/licenses/MIT)
|
|
14
|
-
[](https://github.com/KevinRabun/judges/actions)
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
@@ -24,7 +24,7 @@ AI code generators (Copilot, Cursor, Claude, ChatGPT, etc.) write code fast —
|
|
|
24
24
|
| **Scope** | Style + some bugs | Bugs + code smells | Security patterns | **35 domains**: security, cost, compliance, a11y, API design, cloud, UX, … |
|
|
25
25
|
| **AI-generated code focus** | No | No | Partial | **Purpose-built** for AI output failure modes |
|
|
26
26
|
| **Setup** | Config per project | Server + scanner | Cloud or local | **One command**: `npx @kevinrabun/judges eval file.ts` |
|
|
27
|
-
| **Auto-fix patches** | Some | No | No | **47 deterministic patches** —
|
|
27
|
+
| **Auto-fix patches** | Some | No | No | **47 deterministic patches** — instant, offline |
|
|
28
28
|
| **Non-technical output** | No | Dashboard | No | **Plain-language findings** with What/Why/Next |
|
|
29
29
|
| **MCP native** | No | No | No | **Yes** — works inside Copilot, Claude, Cursor |
|
|
30
30
|
| **SARIF output** | No | Yes | Yes | **Yes** — upload to GitHub Code Scanning |
|
|
@@ -367,24 +367,23 @@ This helps keep Copilot feedback aligned with Judges findings.
|
|
|
367
367
|
|
|
368
368
|
The tribunal operates in three layers:
|
|
369
369
|
|
|
370
|
-
1. **Pattern-Based Analysis** — All tools (`evaluate_code`, `evaluate_code_single_judge`, `evaluate_project`, `evaluate_diff`) perform heuristic analysis using regex pattern matching to catch common anti-patterns. This
|
|
370
|
+
1. **Pattern-Based Analysis** — All tools (`evaluate_code`, `evaluate_code_single_judge`, `evaluate_project`, `evaluate_diff`) perform heuristic analysis using regex pattern matching to catch common anti-patterns. This layer is instant, deterministic, and runs entirely offline with zero external API calls.
|
|
371
371
|
|
|
372
|
-
2. **AST-Based Structural Analysis** — The Code Structure judge (`STRUCT-*` rules) uses real Abstract Syntax Tree parsing to measure cyclomatic complexity, nesting depth, function length, parameter count, dead code, and type safety with precision that regex cannot achieve.
|
|
372
|
+
2. **AST-Based Structural Analysis** — The Code Structure judge (`STRUCT-*` rules) uses real Abstract Syntax Tree parsing to measure cyclomatic complexity, nesting depth, function length, parameter count, dead code, and type safety with precision that regex cannot achieve. All supported languages — **TypeScript, JavaScript, Python, Rust, Go, Java, C#, and C++** — are parsed via **tree-sitter WASM grammars** (real syntax trees compiled to WebAssembly, in-process, zero native dependencies). A scope-tracking structural parser is kept as a fallback when WASM grammars are unavailable. No external AST server required.
|
|
373
373
|
|
|
374
|
-
3. **LLM-Powered Deep Analysis (Prompts)** — The server exposes MCP prompts (e.g., `judge-data-security`, `full-tribunal`) that provide each judge's expert persona as a system prompt. When used by an LLM-based client,
|
|
374
|
+
3. **LLM-Powered Deep Analysis (Prompts)** — The server exposes MCP prompts (e.g., `judge-data-security`, `full-tribunal`) that provide each judge's expert persona as a system prompt. When used by an LLM-based client (Copilot, Claude, Cursor, etc.), the host LLM performs deeper, context-aware probabilistic analysis beyond what static patterns can detect. This is where the `systemPrompt` on each judge comes alive — Judges itself makes no LLM calls, but it provides the expert criteria so your AI assistant can act as 35 specialized reviewers.
|
|
375
375
|
|
|
376
376
|
---
|
|
377
377
|
|
|
378
378
|
## Composable by Design
|
|
379
379
|
|
|
380
|
-
Judges Panel
|
|
380
|
+
Judges Panel is a **dual-layer** review system: instant **deterministic tools** (offline, no API keys) for pattern and AST analysis, plus **35 expert-persona MCP prompts** that unlock LLM-powered deep analysis when connected to an AI client. It does not try to be a CVE scanner or a linter. Those capabilities belong in dedicated MCP servers that an AI agent can orchestrate alongside Judges.
|
|
381
381
|
|
|
382
|
-
### Built-in AST Analysis (v2.0.0)
|
|
382
|
+
### Built-in AST Analysis (v2.0.0+)
|
|
383
383
|
|
|
384
384
|
Unlike earlier versions that recommended a separate AST MCP server, Judges Panel now includes **real AST-based structural analysis** out of the box:
|
|
385
385
|
|
|
386
|
-
- **JavaScript
|
|
387
|
-
- **Python, Rust, Go, Java, C#** — Analyzed with a scope-tracking structural parser that counts decision points and nesting levels
|
|
386
|
+
- **TypeScript, JavaScript, Python, Rust, Go, Java, C#, C++** — All parsed with a **unified tree-sitter WASM engine** for full syntax-tree analysis (functions, complexity, nesting, dead code, type safety). Falls back to a scope-tracking structural parser when WASM grammars are unavailable
|
|
388
387
|
|
|
389
388
|
The Code Structure judge (`STRUCT-*`) uses these parsers to accurately measure:
|
|
390
389
|
|
|
@@ -810,8 +809,8 @@ judges/
|
|
|
810
809
|
│ ├── ast/ # AST analysis engine (built-in, no external deps)
|
|
811
810
|
│ │ ├── index.ts # analyzeStructure() — routes to correct parser
|
|
812
811
|
│ │ ├── types.ts # FunctionInfo, CodeStructure interfaces
|
|
813
|
-
│ │ ├──
|
|
814
|
-
│ │ └── structural-parser.ts #
|
|
812
|
+
│ │ ├── tree-sitter-ast.ts # Tree-sitter WASM parser (all 8 languages)
|
|
813
|
+
│ │ └── structural-parser.ts # Fallback scope-tracking parser
|
|
815
814
|
│ ├── evaluators/ # Analysis engine for each judge
|
|
816
815
|
│ │ ├── index.ts # evaluateWithJudge(), evaluateWithTribunal(), evaluateProject(), etc.
|
|
817
816
|
│ │ ├── shared.ts # Scoring, verdict logic, markdown formatters
|
|
@@ -829,6 +828,14 @@ judges/
|
|
|
829
828
|
│ └── demo.ts # Run: npm run demo
|
|
830
829
|
├── tests/
|
|
831
830
|
│ └── judges.test.ts # Run: npm test
|
|
831
|
+
├── grammars/ # Tree-sitter WASM grammar files
|
|
832
|
+
│ ├── tree-sitter-typescript.wasm
|
|
833
|
+
│ ├── tree-sitter-cpp.wasm
|
|
834
|
+
│ ├── tree-sitter-python.wasm
|
|
835
|
+
│ ├── tree-sitter-go.wasm
|
|
836
|
+
│ ├── tree-sitter-rust.wasm
|
|
837
|
+
│ ├── tree-sitter-java.wasm
|
|
838
|
+
│ └── tree-sitter-c_sharp.wasm
|
|
832
839
|
├── server.json # MCP Registry manifest
|
|
833
840
|
├── package.json
|
|
834
841
|
├── tsconfig.json
|
package/dist/ast/index.d.ts
CHANGED
|
@@ -1,16 +1,26 @@
|
|
|
1
1
|
import type { CodeStructure, FunctionInfo } from "./types.js";
|
|
2
2
|
export type { CodeStructure, FunctionInfo };
|
|
3
|
+
export { isTreeSitterAvailable, isTreeSitterReadySync } from "./tree-sitter-ast.js";
|
|
3
4
|
export { analyzeTaintFlows } from "./taint-tracker.js";
|
|
4
5
|
export type { TaintFlow, TaintSourceKind, TaintSinkKind } from "./taint-tracker.js";
|
|
5
6
|
export { analyzeCrossFileTaint } from "./cross-file-taint.js";
|
|
6
7
|
export type { CrossFileTaintFlow } from "./cross-file-taint.js";
|
|
7
8
|
/**
|
|
8
|
-
* Analyse source code structurally.
|
|
9
|
-
* TypeScript
|
|
10
|
-
*
|
|
9
|
+
* Analyse source code structurally. Uses tree-sitter (real AST via WASM) for
|
|
10
|
+
* TypeScript, JavaScript, Python, Rust, Go, Java, C#, and C++ when available,
|
|
11
|
+
* falling back to the lightweight scope-tracking structural parser.
|
|
11
12
|
*
|
|
12
13
|
* Returns function metrics (complexity, nesting, length, params), dead code
|
|
13
14
|
* locations, deep-nesting locations, and type-safety issues.
|
|
14
15
|
*/
|
|
15
16
|
export declare function analyzeStructure(code: string, language: string): CodeStructure;
|
|
17
|
+
/**
|
|
18
|
+
* Async version of analyzeStructure that uses tree-sitter (real AST) for all
|
|
19
|
+
* supported languages when WASM grammars are available.
|
|
20
|
+
* Falls back to the structural parser if tree-sitter is not available.
|
|
21
|
+
*
|
|
22
|
+
* Prefer this over analyzeStructure() when async is acceptable — it ensures
|
|
23
|
+
* tree-sitter grammars are fully loaded before analysis.
|
|
24
|
+
*/
|
|
25
|
+
export declare function analyzeStructureAsync(code: string, language: string): Promise<CodeStructure>;
|
|
16
26
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/ast/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ast/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ast/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE9D,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC;AAG5C,OAAO,EAAE,qBAAqB,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAGpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGpF,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,YAAY,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAahE;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,aAAa,CAsC9E;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAqClG"}
|
package/dist/ast/index.js
CHANGED
|
@@ -1,20 +1,31 @@
|
|
|
1
1
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
2
2
|
// AST Analysis — Unified Entry Point
|
|
3
3
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
4
|
-
// Routes to the
|
|
5
|
-
//
|
|
4
|
+
// Routes to the tree-sitter real-AST parser (WASM) for TypeScript, JavaScript,
|
|
5
|
+
// Python, Rust, Go, Java, C#, and C++ when grammars are available, or the
|
|
6
|
+
// lightweight structural parser as a fallback.
|
|
6
7
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
7
8
|
import { normalizeLanguage } from "../language-patterns.js";
|
|
8
|
-
import { analyzeTypeScript } from "./typescript-ast.js";
|
|
9
9
|
import { analyzeStructurally } from "./structural-parser.js";
|
|
10
|
+
import { isTreeSitterAvailable, isTreeSitterReadySync, analyzeWithTreeSitter, analyzeWithTreeSitterSync, } from "./tree-sitter-ast.js";
|
|
11
|
+
// Re-export tree-sitter availability checks
|
|
12
|
+
export { isTreeSitterAvailable, isTreeSitterReadySync } from "./tree-sitter-ast.js";
|
|
10
13
|
// Re-export taint analysis
|
|
11
14
|
export { analyzeTaintFlows } from "./taint-tracker.js";
|
|
12
15
|
// Re-export cross-file taint analysis
|
|
13
16
|
export { analyzeCrossFileTaint } from "./cross-file-taint.js";
|
|
17
|
+
// ─── Tree-sitter Warm-up ────────────────────────────────────────────────────
|
|
18
|
+
// Pre-initialize tree-sitter on module load so it's ready when needed.
|
|
19
|
+
// This is fire-and-forget; if it fails, analyzeStructure falls back silently.
|
|
20
|
+
const TREE_SITTER_LANGS = ["typescript", "javascript", "python", "rust", "go", "java", "csharp", "cpp"];
|
|
21
|
+
const treeSitterReady = new Map();
|
|
22
|
+
for (const lang of TREE_SITTER_LANGS) {
|
|
23
|
+
treeSitterReady.set(lang, isTreeSitterAvailable(lang));
|
|
24
|
+
}
|
|
14
25
|
/**
|
|
15
|
-
* Analyse source code structurally.
|
|
16
|
-
* TypeScript
|
|
17
|
-
*
|
|
26
|
+
* Analyse source code structurally. Uses tree-sitter (real AST via WASM) for
|
|
27
|
+
* TypeScript, JavaScript, Python, Rust, Go, Java, C#, and C++ when available,
|
|
28
|
+
* falling back to the lightweight scope-tracking structural parser.
|
|
18
29
|
*
|
|
19
30
|
* Returns function metrics (complexity, nesting, length, params), dead code
|
|
20
31
|
* locations, deep-nesting locations, and type-safety issues.
|
|
@@ -22,14 +33,25 @@ export { analyzeCrossFileTaint } from "./cross-file-taint.js";
|
|
|
22
33
|
export function analyzeStructure(code, language) {
|
|
23
34
|
const lang = normalizeLanguage(language);
|
|
24
35
|
switch (lang) {
|
|
25
|
-
case "javascript":
|
|
26
36
|
case "typescript":
|
|
27
|
-
|
|
37
|
+
case "javascript":
|
|
28
38
|
case "python":
|
|
29
39
|
case "rust":
|
|
30
40
|
case "go":
|
|
31
41
|
case "java":
|
|
32
42
|
case "csharp":
|
|
43
|
+
case "cpp":
|
|
44
|
+
// Use tree-sitter (real AST) if WASM runtime + grammar already loaded,
|
|
45
|
+
// otherwise fall back to the lightweight structural parser.
|
|
46
|
+
// parser.parse() is synchronous in web-tree-sitter once initialized.
|
|
47
|
+
if (isTreeSitterReadySync(lang)) {
|
|
48
|
+
try {
|
|
49
|
+
return analyzeWithTreeSitterSync(code, lang);
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
// Tree-sitter failed at runtime — fall back silently
|
|
53
|
+
}
|
|
54
|
+
}
|
|
33
55
|
return analyzeStructurally(code, lang);
|
|
34
56
|
default:
|
|
35
57
|
// Unknown language — return a minimal structure
|
|
@@ -46,4 +68,49 @@ export function analyzeStructure(code, language) {
|
|
|
46
68
|
};
|
|
47
69
|
}
|
|
48
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Async version of analyzeStructure that uses tree-sitter (real AST) for all
|
|
73
|
+
* supported languages when WASM grammars are available.
|
|
74
|
+
* Falls back to the structural parser if tree-sitter is not available.
|
|
75
|
+
*
|
|
76
|
+
* Prefer this over analyzeStructure() when async is acceptable — it ensures
|
|
77
|
+
* tree-sitter grammars are fully loaded before analysis.
|
|
78
|
+
*/
|
|
79
|
+
export async function analyzeStructureAsync(code, language) {
|
|
80
|
+
const lang = normalizeLanguage(language);
|
|
81
|
+
switch (lang) {
|
|
82
|
+
case "typescript":
|
|
83
|
+
case "javascript":
|
|
84
|
+
case "python":
|
|
85
|
+
case "rust":
|
|
86
|
+
case "go":
|
|
87
|
+
case "java":
|
|
88
|
+
case "csharp":
|
|
89
|
+
case "cpp": {
|
|
90
|
+
// Try tree-sitter first (real AST), fall back to structural parser
|
|
91
|
+
const available = await (treeSitterReady.get(lang) ?? Promise.resolve(false));
|
|
92
|
+
if (available) {
|
|
93
|
+
try {
|
|
94
|
+
return await analyzeWithTreeSitter(code, lang);
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
// Tree-sitter failed at runtime — fall back silently
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return analyzeStructurally(code, lang);
|
|
101
|
+
}
|
|
102
|
+
default:
|
|
103
|
+
return {
|
|
104
|
+
language: lang,
|
|
105
|
+
totalLines: code.split("\n").length,
|
|
106
|
+
functions: [],
|
|
107
|
+
fileCyclomaticComplexity: 1,
|
|
108
|
+
maxNestingDepth: 0,
|
|
109
|
+
deadCodeLines: [],
|
|
110
|
+
deepNestLines: [],
|
|
111
|
+
typeAnyLines: [],
|
|
112
|
+
imports: [],
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
}
|
|
49
116
|
//# sourceMappingURL=index.js.map
|
package/dist/ast/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ast/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,qCAAqC;AACrC,gFAAgF;AAChF
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/ast/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,qCAAqC;AACrC,gFAAgF;AAChF,+EAA+E;AAC/E,0EAA0E;AAC1E,+CAA+C;AAC/C,gFAAgF;AAEhF,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC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EAAE,IAAI;gBACd,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM;gBACnC,SAAS,EAAE,EAAE;gBACb,wBAAwB,EAAE,CAAC;gBAC3B,eAAe,EAAE,CAAC;gBAClB,aAAa,EAAE,EAAE;gBACjB,aAAa,EAAE,EAAE;gBACjB,YAAY,EAAE,EAAE;gBAChB,OAAO,EAAE,EAAE;aACZ,CAAC;IACN,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CodeStructure } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Check whether tree-sitter analysis is available for a given language.
|
|
4
|
+
* Must be called (and awaited) before analyzeWithTreeSitter.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isTreeSitterAvailable(lang: string): Promise<boolean>;
|
|
7
|
+
/**
|
|
8
|
+
* Synchronous readiness check — returns true only if tree-sitter's WASM
|
|
9
|
+
* runtime AND the grammar for `lang` have already been loaded into memory.
|
|
10
|
+
* This is safe to call from synchronous code paths; if the async init
|
|
11
|
+
* hasn't finished yet, it simply returns false and the caller falls back
|
|
12
|
+
* to the structural parser.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isTreeSitterReadySync(lang: string): boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Synchronous tree-sitter analysis. Can ONLY be called when
|
|
17
|
+
* isTreeSitterReadySync(lang) returns true (i.e. parser module and grammar
|
|
18
|
+
* are already loaded). parser.parse() is synchronous in web-tree-sitter
|
|
19
|
+
* once the WASM runtime and grammar are in memory.
|
|
20
|
+
*
|
|
21
|
+
* Returns the same CodeStructure interface as analyzeWithTreeSitter.
|
|
22
|
+
* Throws if preconditions are not met.
|
|
23
|
+
*/
|
|
24
|
+
export declare function analyzeWithTreeSitterSync(code: string, language: string): CodeStructure;
|
|
25
|
+
/**
|
|
26
|
+
* Analyse source code using tree-sitter's real syntax tree.
|
|
27
|
+
* Returns the same CodeStructure interface as the TypeScript and
|
|
28
|
+
* structural parsers — but with much higher precision for non-JS/TS languages.
|
|
29
|
+
*
|
|
30
|
+
* IMPORTANT: Call isTreeSitterAvailable(lang) first. If it returns false,
|
|
31
|
+
* fall back to analyzeStructurally().
|
|
32
|
+
*/
|
|
33
|
+
export declare function analyzeWithTreeSitter(code: string, language: string): Promise<CodeStructure>;
|
|
34
|
+
//# sourceMappingURL=tree-sitter-ast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-sitter-ast.d.ts","sourceRoot":"","sources":["../../src/ast/tree-sitter-ast.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,aAAa,EAAgB,MAAM,YAAY,CAAC;AAqG9D;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAK1E;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAE3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,aAAa,CAKvF;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAKlG"}
|