@nirnex/parser 4.2.0 → 4.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compatibility.d.ts +46 -0
- package/dist/compatibility.d.ts.map +1 -0
- package/dist/compatibility.js +167 -0
- package/dist/compatibility.js.map +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +178 -92
- package/dist/index.js.map +1 -1
- package/package.json +7 -3
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parser compatibility guard for Nirnex.
|
|
3
|
+
*
|
|
4
|
+
* Provides two layers of protection before indexing:
|
|
5
|
+
*
|
|
6
|
+
* 1. SUPPORTED_MATRIX — documents the tested tree-sitter / grammar version pairs.
|
|
7
|
+
* Pairs outside this matrix may work but are not guaranteed.
|
|
8
|
+
*
|
|
9
|
+
* 2. Smoke tests — actually parse a set of representative TypeScript and TSX
|
|
10
|
+
* snippets covering patterns known to appear in real codebases. A passing
|
|
11
|
+
* smoke test proves the native bindings are functional in this environment.
|
|
12
|
+
*
|
|
13
|
+
* Note on hasError: in tree-sitter >= 0.21.x, rootNode.hasError is a *property*
|
|
14
|
+
* (boolean), not a method. Earlier versions exposed it as a function.
|
|
15
|
+
* This module checks rootNode existence, not hasError, to stay version-agnostic.
|
|
16
|
+
*/
|
|
17
|
+
export declare const SUPPORTED_MATRIX: ReadonlyArray<{
|
|
18
|
+
treeSitter: string;
|
|
19
|
+
treeSitterTypescript: string;
|
|
20
|
+
notes?: string;
|
|
21
|
+
}>;
|
|
22
|
+
export interface SmokeTestResult {
|
|
23
|
+
name: string;
|
|
24
|
+
lang: 'typescript' | 'tsx';
|
|
25
|
+
status: 'ok' | 'fail';
|
|
26
|
+
errorMessage?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface CompatibilityResult {
|
|
29
|
+
/** True when ALL smoke tests passed */
|
|
30
|
+
healthy: boolean;
|
|
31
|
+
/** True when the installed version pair is in SUPPORTED_MATRIX */
|
|
32
|
+
inSupportedMatrix: boolean;
|
|
33
|
+
treeSitterVersion?: string;
|
|
34
|
+
treeSitterTypescriptVersion?: string;
|
|
35
|
+
smokeTests: SmokeTestResult[];
|
|
36
|
+
/** Human-readable summary of issues found, empty when healthy */
|
|
37
|
+
issues: string[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Runs the compatibility check synchronously.
|
|
41
|
+
*
|
|
42
|
+
* Uses a dedicated Parser instance so it does not interfere with the shared
|
|
43
|
+
* parser in index.ts.
|
|
44
|
+
*/
|
|
45
|
+
export declare function checkParserCompatibility(): CompatibilityResult;
|
|
46
|
+
//# sourceMappingURL=compatibility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatibility.d.ts","sourceRoot":"","sources":["../src/compatibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAaH,eAAO,MAAM,gBAAgB,EAAE,aAAa,CAAC;IAC3C,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAMA,CAAC;AAqEF,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,YAAY,GAAG,KAAK,CAAC;IAC3B,MAAM,EAAE,IAAI,GAAG,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IAClC,uCAAuC;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,kEAAkE;IAClE,iBAAiB,EAAE,OAAO,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,UAAU,EAAE,eAAe,EAAE,CAAC;IAC9B,iEAAiE;IACjE,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AA6BD;;;;;GAKG;AACH,wBAAgB,wBAAwB,IAAI,mBAAmB,CAgE9D"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parser compatibility guard for Nirnex.
|
|
3
|
+
*
|
|
4
|
+
* Provides two layers of protection before indexing:
|
|
5
|
+
*
|
|
6
|
+
* 1. SUPPORTED_MATRIX — documents the tested tree-sitter / grammar version pairs.
|
|
7
|
+
* Pairs outside this matrix may work but are not guaranteed.
|
|
8
|
+
*
|
|
9
|
+
* 2. Smoke tests — actually parse a set of representative TypeScript and TSX
|
|
10
|
+
* snippets covering patterns known to appear in real codebases. A passing
|
|
11
|
+
* smoke test proves the native bindings are functional in this environment.
|
|
12
|
+
*
|
|
13
|
+
* Note on hasError: in tree-sitter >= 0.21.x, rootNode.hasError is a *property*
|
|
14
|
+
* (boolean), not a method. Earlier versions exposed it as a function.
|
|
15
|
+
* This module checks rootNode existence, not hasError, to stay version-agnostic.
|
|
16
|
+
*/
|
|
17
|
+
import Parser from 'tree-sitter';
|
|
18
|
+
import tsLanguage from 'tree-sitter-typescript';
|
|
19
|
+
import { createRequire } from 'node:module';
|
|
20
|
+
const _req = createRequire(import.meta.url);
|
|
21
|
+
// ─── Supported version matrix ─────────────────────────────────────────────────
|
|
22
|
+
//
|
|
23
|
+
// Add a new entry each time a pair is tested in CI before release.
|
|
24
|
+
// Format: major.minor (patch is ignored — patches should be backward-compatible).
|
|
25
|
+
export const SUPPORTED_MATRIX = [
|
|
26
|
+
{
|
|
27
|
+
treeSitter: '0.21',
|
|
28
|
+
treeSitterTypescript: '0.23',
|
|
29
|
+
notes: 'Tested on Node.js 22, darwin-arm64 and linux-x64',
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
// ─── Smoke-test snippets ──────────────────────────────────────────────────────
|
|
33
|
+
//
|
|
34
|
+
// Each snippet exercises a real pattern seen in production codebases.
|
|
35
|
+
// A snippet is "ok" when tree-sitter returns a rootNode without throwing.
|
|
36
|
+
const SMOKE_TESTS = [
|
|
37
|
+
{
|
|
38
|
+
name: 'ts-basic-types',
|
|
39
|
+
lang: 'typescript',
|
|
40
|
+
src: `export const x: number = 1;
|
|
41
|
+
export function greet(name: string): string { return 'Hello ' + name; }
|
|
42
|
+
type Result<T> = { ok: true; value: T } | { ok: false; error: string };`,
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'ts-satisfies',
|
|
46
|
+
lang: 'typescript',
|
|
47
|
+
src: `const palette = { red: [255, 0, 0] } satisfies Record<string, number[]>;`,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: 'ts-import-type',
|
|
51
|
+
lang: 'typescript',
|
|
52
|
+
src: `import type { Foo } from './foo';
|
|
53
|
+
export type Bar = Foo & { extra: boolean };`,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'tsx-basic-jsx',
|
|
57
|
+
lang: 'tsx',
|
|
58
|
+
src: `export default function Card({ title }: { title: string }) {
|
|
59
|
+
return <div className="card"><h2>{title}</h2></div>;
|
|
60
|
+
}`,
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'tsx-use-client',
|
|
64
|
+
lang: 'tsx',
|
|
65
|
+
src: `'use client';
|
|
66
|
+
import { useState } from 'react';
|
|
67
|
+
export default function Counter() {
|
|
68
|
+
const [n, setN] = useState(0);
|
|
69
|
+
return <button onClick={() => setN(n + 1)}>{n}</button>;
|
|
70
|
+
}`,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'tsx-nextjs-page',
|
|
74
|
+
lang: 'tsx',
|
|
75
|
+
src: `import type { Metadata } from 'next';
|
|
76
|
+
export const metadata: Metadata = { title: 'Home' };
|
|
77
|
+
export default function Page() {
|
|
78
|
+
return <main><h1>Welcome</h1></main>;
|
|
79
|
+
}`,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
name: 'tsx-async-component',
|
|
83
|
+
lang: 'tsx',
|
|
84
|
+
src: `async function fetchData(): Promise<string[]> { return []; }
|
|
85
|
+
export default async function Page() {
|
|
86
|
+
const items = await fetchData();
|
|
87
|
+
return <ul>{items.map(i => <li key={i}>{i}</li>)}</ul>;
|
|
88
|
+
}`,
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
// ─── Helpers ─────────────────────────────────────────────────────────────────
|
|
92
|
+
function readPkgVersion(name) {
|
|
93
|
+
try {
|
|
94
|
+
return _req(`${name}/package.json`).version;
|
|
95
|
+
}
|
|
96
|
+
catch {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/** Matches "0.21.x" pattern against an installed version like "0.21.3" */
|
|
101
|
+
function matchesMajorMinor(installed, matrixEntry) {
|
|
102
|
+
const [iMaj, iMin] = installed.split('.').map(Number);
|
|
103
|
+
const [mMaj, mMin] = matrixEntry.split('.').map(Number);
|
|
104
|
+
return iMaj === mMaj && iMin === mMin;
|
|
105
|
+
}
|
|
106
|
+
function isInSupportedMatrix(ts, tsTs) {
|
|
107
|
+
return SUPPORTED_MATRIX.some((entry) => matchesMajorMinor(ts, entry.treeSitter) &&
|
|
108
|
+
matchesMajorMinor(tsTs, entry.treeSitterTypescript));
|
|
109
|
+
}
|
|
110
|
+
// ─── Main export ──────────────────────────────────────────────────────────────
|
|
111
|
+
/**
|
|
112
|
+
* Runs the compatibility check synchronously.
|
|
113
|
+
*
|
|
114
|
+
* Uses a dedicated Parser instance so it does not interfere with the shared
|
|
115
|
+
* parser in index.ts.
|
|
116
|
+
*/
|
|
117
|
+
export function checkParserCompatibility() {
|
|
118
|
+
const tsVer = readPkgVersion('tree-sitter');
|
|
119
|
+
const tsTsVer = readPkgVersion('tree-sitter-typescript');
|
|
120
|
+
const inSupportedMatrix = tsVer != null && tsTsVer != null
|
|
121
|
+
? isInSupportedMatrix(tsVer, tsTsVer)
|
|
122
|
+
: false;
|
|
123
|
+
const tsLang = tsLanguage;
|
|
124
|
+
const diagParser = new Parser();
|
|
125
|
+
const smokeTests = [];
|
|
126
|
+
for (const test of SMOKE_TESTS) {
|
|
127
|
+
try {
|
|
128
|
+
diagParser.setLanguage(test.lang === 'tsx' ? tsLang.tsx : tsLang.typescript);
|
|
129
|
+
const tree = diagParser.parse(test.src);
|
|
130
|
+
if (!tree || !tree.rootNode)
|
|
131
|
+
throw new Error('parse returned no tree');
|
|
132
|
+
smokeTests.push({ name: test.name, lang: test.lang, status: 'ok' });
|
|
133
|
+
}
|
|
134
|
+
catch (err) {
|
|
135
|
+
smokeTests.push({
|
|
136
|
+
name: test.name,
|
|
137
|
+
lang: test.lang,
|
|
138
|
+
status: 'fail',
|
|
139
|
+
errorMessage: err instanceof Error ? err.message : String(err),
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
const issues = [];
|
|
144
|
+
if (!inSupportedMatrix) {
|
|
145
|
+
const supported = SUPPORTED_MATRIX.map((m) => `tree-sitter@${m.treeSitter}.x + tree-sitter-typescript@${m.treeSitterTypescript}.x`).join(', ');
|
|
146
|
+
issues.push(`Installed pair tree-sitter@${tsVer ?? 'unknown'} + ` +
|
|
147
|
+
`tree-sitter-typescript@${tsTsVer ?? 'unknown'} ` +
|
|
148
|
+
`is outside the tested compatibility matrix (supported: ${supported}). ` +
|
|
149
|
+
`Parse failures may occur on some files.`);
|
|
150
|
+
}
|
|
151
|
+
for (const t of smokeTests) {
|
|
152
|
+
if (t.status === 'fail') {
|
|
153
|
+
issues.push(`Smoke test "${t.name}" (${t.lang}) failed: ${t.errorMessage}. ` +
|
|
154
|
+
`The ${t.lang === 'tsx' ? 'TSX' : 'TypeScript'} grammar may be non-functional in this environment.`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
const healthy = smokeTests.every((t) => t.status === 'ok');
|
|
158
|
+
return {
|
|
159
|
+
healthy,
|
|
160
|
+
inSupportedMatrix,
|
|
161
|
+
treeSitterVersion: tsVer,
|
|
162
|
+
treeSitterTypescriptVersion: tsTsVer,
|
|
163
|
+
smokeTests,
|
|
164
|
+
issues,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=compatibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compatibility.js","sourceRoot":"","sources":["../src/compatibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE5C,iFAAiF;AACjF,EAAE;AACF,mEAAmE;AACnE,kFAAkF;AAElF,MAAM,CAAC,MAAM,gBAAgB,GAIxB;IACH;QACE,UAAU,EAAE,MAAM;QAClB,oBAAoB,EAAE,MAAM;QAC5B,KAAK,EAAE,kDAAkD;KAC1D;CACF,CAAC;AAEF,iFAAiF;AACjF,EAAE;AACF,sEAAsE;AACtE,0EAA0E;AAE1E,MAAM,WAAW,GAIZ;IACH;QACE,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,YAAY;QAClB,GAAG,EAAE;;wEAE+D;KACrE;IACD;QACE,IAAI,EAAE,cAAc;QACpB,IAAI,EAAE,YAAY;QAClB,GAAG,EAAE,0EAA0E;KAChF;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,YAAY;QAClB,GAAG,EAAE;4CACmC;KACzC;IACD;QACE,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,KAAK;QACX,GAAG,EAAE;;EAEP;KACC;IACD;QACE,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,KAAK;QACX,GAAG,EAAE;;;;;EAKP;KACC;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,IAAI,EAAE,KAAK;QACX,GAAG,EAAE;;;;EAIP;KACC;IACD;QACE,IAAI,EAAE,qBAAqB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AC;QACb,MAAM,CAAC,IAAI,CACT,8BAA8B,KAAK,IAAI,SAAS,KAAK;YACrD,0BAA0B,OAAO,IAAI,SAAS,GAAG;YACjD,0DAA0D,SAAS,KAAK;YACxE,yCAAyC,CAC1C,CAAC;IACJ,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;QAC3B,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YACxB,MAAM,CAAC,IAAI,CACT,eAAe,CAAC,CAAC,IAAI,MAAM,CAAC,CAAC,IAAI,aAAa,CAAC,CAAC,YAAY,IAAI;gBAChE,OAAO,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,qDAAqD,CACpG,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM,OAAO,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,IAAI,CAAC,CAAC;IAE3D,OAAO;QACL,OAAO;QACP,iBAAiB;QACjB,iBAAiB,EAAE,KAAK;QACxB,2BAA2B,EAAE,OAAO;QACpC,UAAU;QACV,MAAM;KACP,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,5 +18,32 @@ export interface ParsedModule {
|
|
|
18
18
|
endLine: number;
|
|
19
19
|
}>;
|
|
20
20
|
}
|
|
21
|
+
export type ParseStage = 'read_file' | 'decode_file' | 'select_language' | 'set_language' | 'parse' | 'postprocess_ast';
|
|
22
|
+
export interface ParseFileDiagnostics {
|
|
23
|
+
file: string;
|
|
24
|
+
extension: string;
|
|
25
|
+
size_bytes: number;
|
|
26
|
+
content_sha256?: string;
|
|
27
|
+
char_length?: number;
|
|
28
|
+
has_bom?: boolean;
|
|
29
|
+
has_null_bytes?: boolean;
|
|
30
|
+
newline_style?: 'LF' | 'CRLF' | 'mixed' | 'unknown';
|
|
31
|
+
selected_language?: string;
|
|
32
|
+
grammar_variant?: string;
|
|
33
|
+
language_set?: boolean;
|
|
34
|
+
input_type?: string;
|
|
35
|
+
stage: ParseStage;
|
|
36
|
+
error_name: string;
|
|
37
|
+
error_message: string;
|
|
38
|
+
stack?: string;
|
|
39
|
+
}
|
|
40
|
+
export type ParseFileResult = {
|
|
41
|
+
ok: true;
|
|
42
|
+
module: ParsedModule;
|
|
43
|
+
} | {
|
|
44
|
+
ok: false;
|
|
45
|
+
diagnostics: ParseFileDiagnostics;
|
|
46
|
+
};
|
|
47
|
+
export declare function parseFileWithDiagnostics(filePath: string): ParseFileResult;
|
|
21
48
|
export declare function parseFile(filePath: string): ParsedModule | null;
|
|
22
49
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACrD,OAAO,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IACzD,YAAY,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACvG;AAED,MAAM,MAAM,UAAU,GAClB,WAAW,GACX,aAAa,GACb,iBAAiB,GACjB,cAAc,GACd,OAAO,GACP,iBAAiB,CAAC;AAEtB,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,aAAa,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IACpD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,UAAU,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,eAAe,GACvB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,MAAM,EAAE,YAAY,CAAA;CAAE,GAClC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,WAAW,EAAE,oBAAoB,CAAA;CAAE,CAAC;AAsFrD,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,CA6G1E;AAID,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,YAAY,GAAG,IAAI,CAY/D"}
|
package/dist/index.js
CHANGED
|
@@ -2,115 +2,201 @@ import Parser from 'tree-sitter';
|
|
|
2
2
|
import tsLanguage from 'tree-sitter-typescript';
|
|
3
3
|
import fs from 'node:fs';
|
|
4
4
|
import path from 'node:path';
|
|
5
|
+
import crypto from 'node:crypto';
|
|
5
6
|
const parser = new Parser();
|
|
6
|
-
|
|
7
|
+
// ─── AST traversal (shared) ──────────────────────────────────────────────────
|
|
8
|
+
function traverseAST(tree) {
|
|
9
|
+
const imports = [];
|
|
10
|
+
const exports = [];
|
|
11
|
+
const declarations = [];
|
|
12
|
+
const traverse = (node) => {
|
|
13
|
+
if (node.type === 'import_statement') {
|
|
14
|
+
let source = '';
|
|
15
|
+
const specifiers = [];
|
|
16
|
+
for (const child of node.children) {
|
|
17
|
+
if (child.type === 'string') {
|
|
18
|
+
source = child.text.slice(1, -1);
|
|
19
|
+
}
|
|
20
|
+
else if (child.type === 'import_clause') {
|
|
21
|
+
for (const c of child.children) {
|
|
22
|
+
if (c.type === 'identifier') {
|
|
23
|
+
specifiers.push(c.text);
|
|
24
|
+
}
|
|
25
|
+
else if (c.type === 'named_imports') {
|
|
26
|
+
for (const nc of c.children) {
|
|
27
|
+
if (nc.type === 'import_specifier')
|
|
28
|
+
specifiers.push(nc.text);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (source)
|
|
35
|
+
imports.push({ source, specifiers });
|
|
36
|
+
}
|
|
37
|
+
if (node.type === 'export_statement') {
|
|
38
|
+
let isDefault = false;
|
|
39
|
+
for (const child of node.children) {
|
|
40
|
+
if (child.type === 'default')
|
|
41
|
+
isDefault = true;
|
|
42
|
+
if (child.type === 'export_clause') {
|
|
43
|
+
for (const c of child.children) {
|
|
44
|
+
if (c.type === 'export_specifier')
|
|
45
|
+
exports.push({ name: c.text, isDefault: false });
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (child.type === 'class_declaration' ||
|
|
49
|
+
child.type === 'function_declaration' ||
|
|
50
|
+
child.type === 'lexical_declaration') {
|
|
51
|
+
const nameNode = child.children.find(c => c.type === 'identifier');
|
|
52
|
+
if (nameNode) {
|
|
53
|
+
exports.push({ name: nameNode.text, isDefault });
|
|
54
|
+
}
|
|
55
|
+
else if (child.type === 'lexical_declaration') {
|
|
56
|
+
const declC = child.children.find(c => c.type === 'variable_declarator');
|
|
57
|
+
if (declC) {
|
|
58
|
+
const idNode = declC.children.find(c => c.type === 'identifier');
|
|
59
|
+
if (idNode)
|
|
60
|
+
exports.push({ name: idNode.text, isDefault });
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
if (node.type === 'function_declaration' || node.type === 'class_declaration') {
|
|
67
|
+
const nameNode = node.children.find(c => c.type === 'identifier');
|
|
68
|
+
if (nameNode) {
|
|
69
|
+
declarations.push({
|
|
70
|
+
name: nameNode.text,
|
|
71
|
+
kind: node.type.split('_')[0],
|
|
72
|
+
startLine: node.startPosition.row + 1,
|
|
73
|
+
endLine: node.endPosition.row + 1,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
for (const child of node.children)
|
|
78
|
+
traverse(child);
|
|
79
|
+
};
|
|
80
|
+
traverse(tree.rootNode);
|
|
81
|
+
return { imports, exports, declarations };
|
|
82
|
+
}
|
|
83
|
+
// ─── Stage-aware parse with full diagnostics ────────────────────────────────
|
|
84
|
+
export function parseFileWithDiagnostics(filePath) {
|
|
85
|
+
let stage = 'read_file';
|
|
86
|
+
let size_bytes = 0;
|
|
87
|
+
let content_sha256;
|
|
88
|
+
let char_length;
|
|
89
|
+
let has_bom;
|
|
90
|
+
let has_null_bytes;
|
|
91
|
+
let newline_style;
|
|
92
|
+
let selected_language;
|
|
93
|
+
let language_set = false;
|
|
94
|
+
let input_type;
|
|
7
95
|
try {
|
|
8
96
|
const ext = path.extname(filePath);
|
|
9
97
|
if (!['.ts', '.tsx'].includes(ext)) {
|
|
10
|
-
return
|
|
98
|
+
return {
|
|
99
|
+
ok: false,
|
|
100
|
+
diagnostics: {
|
|
101
|
+
file: filePath,
|
|
102
|
+
extension: ext,
|
|
103
|
+
size_bytes: 0,
|
|
104
|
+
stage: 'select_language',
|
|
105
|
+
error_name: 'UnsupportedExtension',
|
|
106
|
+
error_message: `File extension "${ext}" is not supported by nirnex parser (expected .ts or .tsx)`,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
11
109
|
}
|
|
12
|
-
|
|
110
|
+
// ── Stage: read_file ──────────────────────────────────────────────────
|
|
111
|
+
stage = 'read_file';
|
|
112
|
+
size_bytes = fs.statSync(filePath).size;
|
|
113
|
+
const rawBuffer = fs.readFileSync(filePath);
|
|
114
|
+
// ── Stage: decode_file ────────────────────────────────────────────────
|
|
115
|
+
stage = 'decode_file';
|
|
116
|
+
has_bom = rawBuffer[0] === 0xef && rawBuffer[1] === 0xbb && rawBuffer[2] === 0xbf;
|
|
117
|
+
has_null_bytes = rawBuffer.indexOf(0x00) !== -1;
|
|
118
|
+
content_sha256 = crypto.createHash('sha256').update(rawBuffer).digest('hex').slice(0, 16);
|
|
119
|
+
const content = rawBuffer.toString('utf-8');
|
|
120
|
+
char_length = content.length;
|
|
121
|
+
input_type = typeof content;
|
|
122
|
+
// Newline style detection
|
|
123
|
+
const crlfCount = (content.match(/\r\n/g) ?? []).length;
|
|
124
|
+
const lfCount = (content.match(/(?<!\r)\n/g) ?? []).length;
|
|
125
|
+
if (crlfCount > 0 && lfCount > 0)
|
|
126
|
+
newline_style = 'mixed';
|
|
127
|
+
else if (crlfCount > 0)
|
|
128
|
+
newline_style = 'CRLF';
|
|
129
|
+
else if (lfCount > 0)
|
|
130
|
+
newline_style = 'LF';
|
|
131
|
+
else
|
|
132
|
+
newline_style = 'unknown';
|
|
133
|
+
// ── Stage: select_language ────────────────────────────────────────────
|
|
134
|
+
stage = 'select_language';
|
|
13
135
|
const tsLang = tsLanguage;
|
|
136
|
+
selected_language = ext === '.tsx' ? 'tsx' : 'typescript';
|
|
137
|
+
// ── Stage: set_language ───────────────────────────────────────────────
|
|
138
|
+
stage = 'set_language';
|
|
14
139
|
if (ext === '.tsx') {
|
|
15
140
|
parser.setLanguage(tsLang.tsx);
|
|
16
141
|
}
|
|
17
142
|
else {
|
|
18
143
|
parser.setLanguage(tsLang.typescript);
|
|
19
144
|
}
|
|
145
|
+
language_set = true;
|
|
146
|
+
// ── Stage: parse ──────────────────────────────────────────────────────
|
|
147
|
+
stage = 'parse';
|
|
20
148
|
const tree = parser.parse(content);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const declarations =
|
|
24
|
-
const traverse = (node) => {
|
|
25
|
-
if (node.type === 'import_statement') {
|
|
26
|
-
let source = '';
|
|
27
|
-
const specifiers = [];
|
|
28
|
-
for (const child of node.children) {
|
|
29
|
-
if (child.type === 'string') {
|
|
30
|
-
source = child.text.slice(1, -1);
|
|
31
|
-
}
|
|
32
|
-
else if (child.type === 'import_clause') {
|
|
33
|
-
for (const c of child.children) {
|
|
34
|
-
if (c.type === 'identifier') {
|
|
35
|
-
specifiers.push(c.text);
|
|
36
|
-
}
|
|
37
|
-
else if (c.type === 'named_imports') {
|
|
38
|
-
for (const nc of c.children) {
|
|
39
|
-
if (nc.type === 'import_specifier') {
|
|
40
|
-
specifiers.push(nc.text);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
if (source)
|
|
48
|
-
imports.push({ source, specifiers });
|
|
49
|
-
}
|
|
50
|
-
if (node.type === 'export_statement') {
|
|
51
|
-
let isDefault = false;
|
|
52
|
-
for (const child of node.children) {
|
|
53
|
-
if (child.type === 'default')
|
|
54
|
-
isDefault = true;
|
|
55
|
-
if (child.type === 'export_clause') {
|
|
56
|
-
for (const c of child.children) {
|
|
57
|
-
if (c.type === 'export_specifier')
|
|
58
|
-
exports.push({ name: c.text, isDefault: false });
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
if (child.type === 'class_declaration' || child.type === 'function_declaration' || child.type === 'lexical_declaration') {
|
|
62
|
-
const nameNode = child.children.find(c => c.type === 'identifier');
|
|
63
|
-
if (nameNode) {
|
|
64
|
-
exports.push({ name: nameNode.text, isDefault });
|
|
65
|
-
}
|
|
66
|
-
else if (child.type === 'lexical_declaration') {
|
|
67
|
-
const declC = child.children.find(c => c.type === 'variable_declarator');
|
|
68
|
-
if (declC) {
|
|
69
|
-
const idNode = declC.children.find(c => c.type === 'identifier');
|
|
70
|
-
if (idNode)
|
|
71
|
-
exports.push({ name: idNode.text, isDefault });
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
if (node.type === 'function_declaration' || node.type === 'class_declaration') {
|
|
78
|
-
const nameNode = node.children.find(c => c.type === 'identifier');
|
|
79
|
-
if (nameNode) {
|
|
80
|
-
declarations.push({
|
|
81
|
-
name: nameNode.text,
|
|
82
|
-
kind: node.type.split('_')[0],
|
|
83
|
-
startLine: node.startPosition.row + 1,
|
|
84
|
-
endLine: node.endPosition.row + 1
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
for (const child of node.children)
|
|
89
|
-
traverse(child);
|
|
90
|
-
};
|
|
91
|
-
traverse(tree.rootNode);
|
|
149
|
+
// ── Stage: postprocess_ast ────────────────────────────────────────────
|
|
150
|
+
stage = 'postprocess_ast';
|
|
151
|
+
const { imports, exports, declarations } = traverseAST(tree);
|
|
92
152
|
return {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
153
|
+
ok: true,
|
|
154
|
+
module: {
|
|
155
|
+
path: filePath,
|
|
156
|
+
name: path.basename(filePath),
|
|
157
|
+
language: selected_language,
|
|
158
|
+
loc: content.split('\n').length,
|
|
159
|
+
imports,
|
|
160
|
+
exports,
|
|
161
|
+
declarations,
|
|
162
|
+
},
|
|
100
163
|
};
|
|
101
164
|
}
|
|
102
165
|
catch (error) {
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
166
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
167
|
+
return {
|
|
168
|
+
ok: false,
|
|
169
|
+
diagnostics: {
|
|
170
|
+
file: filePath,
|
|
171
|
+
extension: path.extname(filePath),
|
|
172
|
+
size_bytes,
|
|
173
|
+
content_sha256,
|
|
174
|
+
char_length,
|
|
175
|
+
has_bom,
|
|
176
|
+
has_null_bytes,
|
|
177
|
+
newline_style,
|
|
178
|
+
selected_language,
|
|
179
|
+
grammar_variant: selected_language,
|
|
180
|
+
language_set,
|
|
181
|
+
input_type,
|
|
182
|
+
stage,
|
|
183
|
+
error_name: err.name,
|
|
184
|
+
error_message: err.message,
|
|
185
|
+
stack: err.stack,
|
|
186
|
+
},
|
|
187
|
+
};
|
|
114
188
|
}
|
|
115
189
|
}
|
|
190
|
+
// ─── Backward-compatible wrapper ─────────────────────────────────────────────
|
|
191
|
+
export function parseFile(filePath) {
|
|
192
|
+
const result = parseFileWithDiagnostics(filePath);
|
|
193
|
+
if (result.ok)
|
|
194
|
+
return result.module;
|
|
195
|
+
const d = result.diagnostics;
|
|
196
|
+
// Minimal stderr output — CLI layer writes the full debug log
|
|
197
|
+
process.stderr.write(`[nirnex parser] Failed to parse ${d.file}\n` +
|
|
198
|
+
` extension: ${d.extension} size: ${d.size_bytes} bytes stage: ${d.stage}\n` +
|
|
199
|
+
` reason: ${d.error_message}\n`);
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
116
202
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,UAAU,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src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MAAM,MAAM,GAAG,wBAAwB,CAAC,QAAQ,CAAC,CAAC;IAClD,IAAI,MAAM,CAAC,EAAE;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC;IAEpC,MAAM,CAAC,GAAG,MAAM,CAAC,WAAW,CAAC;IAC7B,8DAA8D;IAC9D,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,mCAAmC,CAAC,CAAC,IAAI,IAAI;QAC7C,gBAAgB,CAAC,CAAC,SAAS,WAAW,CAAC,CAAC,UAAU,kBAAkB,CAAC,CAAC,KAAK,IAAI;QAC/E,aAAa,CAAC,CAAC,aAAa,IAAI,CACjC,CAAC;IACF,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nirnex/parser",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.2",
|
|
4
4
|
"description": "Nirnex parser — Tree-sitter based source code analysis",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
"import": "./dist/index.js",
|
|
11
11
|
"types": "./dist/index.d.ts"
|
|
12
12
|
},
|
|
13
|
+
"./compatibility": {
|
|
14
|
+
"import": "./dist/compatibility.js",
|
|
15
|
+
"types": "./dist/compatibility.d.ts"
|
|
16
|
+
},
|
|
13
17
|
"./dist/*.js": {
|
|
14
18
|
"import": "./dist/*.js",
|
|
15
19
|
"types": "./dist/*.d.ts"
|
|
@@ -34,8 +38,8 @@
|
|
|
34
38
|
},
|
|
35
39
|
"license": "MIT",
|
|
36
40
|
"dependencies": {
|
|
37
|
-
"tree-sitter": "
|
|
38
|
-
"tree-sitter-typescript": "
|
|
41
|
+
"tree-sitter": "0.21.1",
|
|
42
|
+
"tree-sitter-typescript": "0.23.2"
|
|
39
43
|
},
|
|
40
44
|
"devDependencies": {
|
|
41
45
|
"typescript": "^5.4.0"
|