@wrongstack/tools 1.0.11 → 1.0.12
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/builtin.js +15 -15
- package/dist/{chunk-GU7TZE6Z.js → chunk-2BCRQAIW.js} +7 -7
- package/dist/{chunk-XRNN44QY.js → chunk-2IRHFHZY.js} +235 -71
- package/dist/{chunk-NEYUPZL6.js → chunk-6D3UIQMF.js} +651 -303
- package/dist/chunk-BJ5LXLKE.js +351 -0
- package/dist/{chunk-C6ZOXNXV.js → chunk-CSS42GRP.js} +2 -2
- package/dist/{chunk-SKRMUHTU.js → chunk-HSLDY55L.js} +41 -8
- package/dist/{chunk-ENE22I5W.js → chunk-K37AKCTN.js} +884 -362
- package/dist/{chunk-DKXMDO5F.js → chunk-K3VX6V5P.js} +3 -3
- package/dist/chunk-OIFY4XNP.js +855 -0
- package/dist/{chunk-7GOE2ZTZ.js → chunk-OMWC2OGT.js} +2 -2
- package/dist/{chunk-IE4KDAOB.js → chunk-OYQE2UNT.js} +3 -3
- package/dist/chunk-R3HR3QI3.js +97 -0
- package/dist/{chunk-XPVYZ2S6.js → chunk-RYLMSGR5.js} +2 -2
- package/dist/{chunk-HYHE4VNA.js → chunk-UMOP3VGK.js} +79 -45
- package/dist/{chunk-6OIEYJM4.js → chunk-VMNWQI4V.js} +2 -2
- package/dist/{chunk-2UVAIS5O.js → chunk-YPSVPCIE.js} +2 -2
- package/dist/{chunk-PWZUHZP7.js → chunk-Z77XMU3U.js} +2 -2
- package/dist/codebase-index/ast-invariant-engine.d.ts +19 -2
- package/dist/codebase-index/atlas-projection.d.ts +19 -0
- package/dist/codebase-index/background-indexer.d.ts +14 -0
- package/dist/codebase-index/circuit-breaker.d.ts +7 -0
- package/dist/codebase-index/codebase-ast-replace-tool.d.ts +1 -1
- package/dist/codebase-index/codebase-impact-analysis-tool.d.ts +6 -0
- package/dist/codebase-index/codebase-invariant-check-tool.d.ts +2 -0
- package/dist/codebase-index/codebase-targeted-test-tool.d.ts +26 -0
- package/dist/codebase-index/dead-code-scan.d.ts +4 -0
- package/dist/codebase-index/go-parser.d.ts +23 -3
- package/dist/codebase-index/graph-rank-pass.d.ts +10 -0
- package/dist/codebase-index/graph-rank.d.ts +8 -0
- package/dist/codebase-index/index.d.ts +1 -1
- package/dist/codebase-index/index.js +9 -9
- package/dist/codebase-index/lsp-kind.d.ts +3 -1
- package/dist/codebase-index/module-resolver.d.ts +21 -1
- package/dist/codebase-index/parser-batch.d.ts +6 -8
- package/dist/codebase-index/parser-output.d.ts +5 -1
- package/dist/codebase-index/parser-worker-script.js +4 -4
- package/dist/codebase-index/project-server-framing.d.ts +1 -17
- package/dist/codebase-index/project-server-watcher.d.ts +6 -0
- package/dist/codebase-index/project-server.js +72 -26
- package/dist/codebase-index/py-parser.d.ts +4 -4
- package/dist/codebase-index/rs-parser.d.ts +7 -0
- package/dist/codebase-index/toolchain-scripts.d.ts +64 -0
- package/dist/codebase-index/tree-sitter/queries.d.ts +14 -0
- package/dist/codebase-index/tree-sitter/util.d.ts +6 -1
- package/dist/codebase-index/tree-sitter-parser.d.ts +7 -0
- package/dist/codebase-index/worker.js +23 -16
- package/dist/codebase-index/writer-refs.d.ts +17 -2
- package/dist/codebase-index/writer-search-helpers.d.ts +9 -0
- package/dist/codebase-index/writer.d.ts +20 -1
- package/dist/edit.js +8 -8
- package/dist/{generic-parser-N2PLGBC2.js → generic-parser-IVWLFKMR.js} +2 -2
- package/dist/go-parser-LWV3L5V7.js +197 -0
- package/dist/index.js +17 -17
- package/dist/json-parser-PERV2JHX.js +204 -0
- package/dist/pack.js +16 -16
- package/dist/parser-dispatch-ZSWCQB6M.js +14 -0
- package/dist/patch.js +8 -8
- package/dist/{py-parser-4PFZYAJ7.js → py-parser-B6D6RGH7.js} +4 -4
- package/dist/read.js +8 -8
- package/dist/replace.js +8 -8
- package/dist/rs-parser-L7SP4GWJ.js +182 -0
- package/dist/tool-tier.js +17 -17
- package/dist/{tree-sitter-parser-GILYQLS4.js → tree-sitter-parser-KU6JF3ZC.js} +6 -4
- package/dist/{ts-parser-7W26YB26.js → ts-parser-PML6QIH7.js} +55 -23
- package/dist/write.js +8 -8
- package/dist/{yaml-parser-DFBC5FWH.js → yaml-parser-7BJN544B.js} +41 -6
- package/package.json +5 -5
- package/dist/chunk-4CE3RKEP.js +0 -390
- package/dist/chunk-KHUCKLOR.js +0 -899
- package/dist/chunk-ZKC5UNGD.js +0 -167
- package/dist/go-parser-Z4H6SR3R.js +0 -474
- package/dist/json-parser-IJD77VL4.js +0 -256
- package/dist/parser-dispatch-WG4DNBHH.js +0 -14
- package/dist/rs-parser-GIWPUA3T.js +0 -81
|
@@ -8,7 +8,12 @@
|
|
|
8
8
|
* identifiers that we extract from arbitrary child nodes whose byte offset
|
|
9
9
|
* we have to translate into 1-based line + 0-based col ourselves.
|
|
10
10
|
*/
|
|
11
|
-
/**
|
|
11
|
+
/**
|
|
12
|
+
* 1-based line, 0-based col (the index schema's convention) for an offset,
|
|
13
|
+
* using binary search over newline offsets. The col used to be 1-based —
|
|
14
|
+
* `index - lastNl` counts the newline itself — so every tree-sitter symbol
|
|
15
|
+
* sat one column right of where every other parser puts it.
|
|
16
|
+
*/
|
|
12
17
|
export declare function lineColAt(offsets: readonly number[], index: number): {
|
|
13
18
|
line: number;
|
|
14
19
|
col: number;
|
|
@@ -64,4 +64,11 @@ export declare function parseTreeSitterAst(opts: {
|
|
|
64
64
|
tree: import('web-tree-sitter').Tree;
|
|
65
65
|
parser: import('web-tree-sitter').Parser;
|
|
66
66
|
} | null>;
|
|
67
|
+
/**
|
|
68
|
+
* The identifier a tree-sitter declaration is named by. C/C++ nest it in a
|
|
69
|
+
* declarator chain (`function_definition` → `function_declarator` →
|
|
70
|
+
* `identifier`); comparing or reporting the OUTER declarator's text yields
|
|
71
|
+
* `add(int a, int b)` instead of `add`.
|
|
72
|
+
*/
|
|
73
|
+
export declare function treeSitterDeclarationName(node: import('web-tree-sitter').Node): string | undefined;
|
|
67
74
|
//# sourceMappingURL=tree-sitter-parser.d.ts.map
|
|
@@ -9,11 +9,11 @@ import {
|
|
|
9
9
|
statsService,
|
|
10
10
|
symbolGraphService,
|
|
11
11
|
vectorSearchService
|
|
12
|
-
} from "../chunk-
|
|
13
|
-
import "../chunk-
|
|
14
|
-
import "../chunk-
|
|
15
|
-
import "../chunk-
|
|
16
|
-
import "../chunk-
|
|
12
|
+
} from "../chunk-6D3UIQMF.js";
|
|
13
|
+
import "../chunk-BJ5LXLKE.js";
|
|
14
|
+
import "../chunk-R3HR3QI3.js";
|
|
15
|
+
import "../chunk-HSLDY55L.js";
|
|
16
|
+
import "../chunk-OIFY4XNP.js";
|
|
17
17
|
import "../chunk-YOHO4DVT.js";
|
|
18
18
|
import "../chunk-XHSHNOAF.js";
|
|
19
19
|
import "../chunk-XZLVJD56.js";
|
|
@@ -78,19 +78,26 @@ port.on("message", (msg) => {
|
|
|
78
78
|
return;
|
|
79
79
|
}
|
|
80
80
|
void dispatch(msg).then(
|
|
81
|
-
(result) =>
|
|
82
|
-
(err) => {
|
|
81
|
+
(result) => {
|
|
83
82
|
try {
|
|
84
|
-
post({
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
ok: false,
|
|
88
|
-
error: err instanceof Error ? err.message : String(err),
|
|
89
|
-
errorName: err instanceof Error ? err.name : void 0
|
|
90
|
-
});
|
|
91
|
-
} catch {
|
|
83
|
+
post({ type: "response", id: msg.id, ok: true, result });
|
|
84
|
+
} catch (err) {
|
|
85
|
+
postError(msg.id, err);
|
|
92
86
|
}
|
|
93
|
-
}
|
|
87
|
+
},
|
|
88
|
+
(err) => postError(msg.id, err)
|
|
94
89
|
);
|
|
95
90
|
});
|
|
91
|
+
function postError(id, err) {
|
|
92
|
+
try {
|
|
93
|
+
post({
|
|
94
|
+
type: "response",
|
|
95
|
+
id,
|
|
96
|
+
ok: false,
|
|
97
|
+
error: err instanceof Error ? err.message : String(err),
|
|
98
|
+
errorName: err instanceof Error ? err.name : void 0
|
|
99
|
+
});
|
|
100
|
+
} catch {
|
|
101
|
+
}
|
|
102
|
+
}
|
|
96
103
|
//# sourceMappingURL=worker.js.map
|
|
@@ -34,15 +34,30 @@ export declare function getAllImportRefsWithStatement(stmtFn: (sql: string) => {
|
|
|
34
34
|
export declare function resolveRefsWithStatement(stmtFn: (sql: string) => {
|
|
35
35
|
run: (...args: (string | number)[]) => unknown;
|
|
36
36
|
}): number;
|
|
37
|
+
/**
|
|
38
|
+
* Importer files holding an import ref whose `to_file` is no longer indexed —
|
|
39
|
+
* the target was deleted or renamed. A watcher run only re-resolves the files
|
|
40
|
+
* it touched, and the importer of a deleted file is not one of them, so these
|
|
41
|
+
* are added to its scope; otherwise the edge to the missing file survives.
|
|
42
|
+
*/
|
|
43
|
+
export declare function getFilesWithDanglingImportsWithStatement(stmtFn: (sql: string) => {
|
|
44
|
+
all: () => unknown[];
|
|
45
|
+
}): string[];
|
|
46
|
+
/**
|
|
47
|
+
* Write module-resolution results. `toFile: null` records "re-resolved, no
|
|
48
|
+
* target": it CLEARS a previous `to_file`. Only resolved entries used to be
|
|
49
|
+
* written, so an import whose target had since been deleted kept pointing at
|
|
50
|
+
* it through every later run, full reindex included.
|
|
51
|
+
*/
|
|
37
52
|
export declare function applyImportResolutionsWithStatement(db: {
|
|
38
53
|
exec: (sql: string) => unknown;
|
|
39
54
|
}, stmtFn: (sql: string) => {
|
|
40
|
-
run: (...args: string[]) => unknown;
|
|
55
|
+
run: (...args: (string | null)[]) => unknown;
|
|
41
56
|
}, runWithRetry: <T>(fn: () => T) => T, maxSqlVars: number, resolutions: ReadonlyArray<{
|
|
42
57
|
fromFile: string;
|
|
43
58
|
lang: string;
|
|
44
59
|
module: string;
|
|
45
|
-
toFile: string;
|
|
60
|
+
toFile: string | null;
|
|
46
61
|
}>): number;
|
|
47
62
|
export declare function resolveRefsForNamesUnsafe(stmtFn: (sql: string) => {
|
|
48
63
|
run: (...args: (string | number)[]) => unknown;
|
|
@@ -36,6 +36,15 @@ export interface WriterSearchRow {
|
|
|
36
36
|
*/
|
|
37
37
|
export declare const SEARCH_CANDIDATE_SCAN_CAP = 5000;
|
|
38
38
|
export declare function normalizeSearchLimit(limit: number | undefined): number | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* The symbol kinds a search may return.
|
|
41
|
+
*
|
|
42
|
+
* `undefined` — no kind constraint. `null` — the filter can match nothing (an
|
|
43
|
+
* LSP kind with no internal equivalent, or a `kind` outside the `lspKind`'s
|
|
44
|
+
* set). Otherwise the allowed kinds. `kind` and `lspKind` INTERSECT: the old
|
|
45
|
+
* code let `lspKind` silently override an explicit `kind`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveKindFilter(filter: WriterSearchFilter | undefined): readonly SymbolKind[] | null | undefined;
|
|
39
48
|
export declare function buildWriterSearchWhere(query: string, filter?: WriterSearchFilter | undefined): {
|
|
40
49
|
where: string;
|
|
41
50
|
values: unknown[];
|
|
@@ -18,6 +18,8 @@ export declare class IndexStore {
|
|
|
18
18
|
private readonly stmtCache;
|
|
19
19
|
private bm25Cache;
|
|
20
20
|
private bm25Dirty;
|
|
21
|
+
/** `PRAGMA data_version` the BM25 cache was built at. */
|
|
22
|
+
private bm25DataVersion;
|
|
21
23
|
private stmt;
|
|
22
24
|
constructor(projectRoot: string, opts?: {
|
|
23
25
|
indexDir?: string | undefined;
|
|
@@ -26,6 +28,12 @@ export declare class IndexStore {
|
|
|
26
28
|
runAtomicIndexUpdate<T>(job: () => Promise<T>): Promise<T>;
|
|
27
29
|
private beginWriteTransaction;
|
|
28
30
|
private commitWriteTransaction;
|
|
31
|
+
/**
|
|
32
|
+
* Never throws: every caller is already propagating the failure that caused
|
|
33
|
+
* the rollback. When SQLite has rolled the transaction back itself (disk
|
|
34
|
+
* full, I/O error) the ROLLBACK fails with "no transaction is active", and
|
|
35
|
+
* that message used to replace the real error.
|
|
36
|
+
*/
|
|
29
37
|
private rollbackWriteTransaction;
|
|
30
38
|
private initSchema;
|
|
31
39
|
private static readonly NEXT_SYMBOL_ID_KEY;
|
|
@@ -50,11 +58,12 @@ export declare class IndexStore {
|
|
|
50
58
|
lang: string;
|
|
51
59
|
module: string;
|
|
52
60
|
}>;
|
|
61
|
+
getFilesWithDanglingImports(): string[];
|
|
53
62
|
applyImportResolutions(resolutions: ReadonlyArray<{
|
|
54
63
|
fromFile: string;
|
|
55
64
|
lang: string;
|
|
56
65
|
module: string;
|
|
57
|
-
toFile: string;
|
|
66
|
+
toFile: string | null;
|
|
58
67
|
}>): number;
|
|
59
68
|
search(query: string, filter?: WriterSearchFilter, opts?: {
|
|
60
69
|
limit?: number | undefined;
|
|
@@ -65,7 +74,16 @@ export declare class IndexStore {
|
|
|
65
74
|
total: number;
|
|
66
75
|
};
|
|
67
76
|
private invalidateBm25;
|
|
77
|
+
/**
|
|
78
|
+
* The corpus is rebuilt when this connection wrote (bm25Dirty) OR another
|
|
79
|
+
* connection committed since it was built. Pooled stores stay open for the
|
|
80
|
+
* life of the host while the project daemon, an inline indexer or another
|
|
81
|
+
* process writes the same database; the dirty flag alone never saw those
|
|
82
|
+
* writes, so short-query results silently dropped every symbol added since.
|
|
83
|
+
*/
|
|
68
84
|
private getOrBuildBm25;
|
|
85
|
+
/** Changes whenever ANOTHER connection commits to this database. */
|
|
86
|
+
private dataVersion;
|
|
69
87
|
getAllIndexable(): Array<{
|
|
70
88
|
id: number;
|
|
71
89
|
text: string;
|
|
@@ -174,6 +192,7 @@ export declare class IndexStore {
|
|
|
174
192
|
file: string;
|
|
175
193
|
kind: SymbolKind;
|
|
176
194
|
line: number;
|
|
195
|
+
scope: string;
|
|
177
196
|
}>;
|
|
178
197
|
/** Declarations in one file, in source order. */
|
|
179
198
|
getFileSymbols(file: string, limit: number): Array<{
|
package/dist/edit.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
editTool
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-OMWC2OGT.js";
|
|
4
4
|
import "./chunk-MSOAX3GC.js";
|
|
5
|
-
import "./chunk-
|
|
6
|
-
import "./chunk-
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
5
|
+
import "./chunk-UMOP3VGK.js";
|
|
6
|
+
import "./chunk-RYLMSGR5.js";
|
|
7
|
+
import "./chunk-6D3UIQMF.js";
|
|
8
|
+
import "./chunk-BJ5LXLKE.js";
|
|
9
|
+
import "./chunk-R3HR3QI3.js";
|
|
10
|
+
import "./chunk-HSLDY55L.js";
|
|
11
|
+
import "./chunk-OIFY4XNP.js";
|
|
12
12
|
import "./chunk-YOHO4DVT.js";
|
|
13
13
|
import "./chunk-XHSHNOAF.js";
|
|
14
14
|
import "./chunk-XZLVJD56.js";
|
|
@@ -3,11 +3,11 @@ import {
|
|
|
3
3
|
GENERIC_MAX_SYMBOLS_DEFAULT,
|
|
4
4
|
parseGeneric,
|
|
5
5
|
parseSymbols
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HSLDY55L.js";
|
|
7
7
|
export {
|
|
8
8
|
GENERIC_MAX_FILE_CHARS,
|
|
9
9
|
GENERIC_MAX_SYMBOLS_DEFAULT,
|
|
10
10
|
parseGeneric,
|
|
11
11
|
parseSymbols
|
|
12
12
|
};
|
|
13
|
-
//# sourceMappingURL=generic-parser-
|
|
13
|
+
//# sourceMappingURL=generic-parser-IVWLFKMR.js.map
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import {
|
|
2
|
+
GO_PARSE_SCRIPT,
|
|
3
|
+
goSpawnOptions,
|
|
4
|
+
parseParserOutput,
|
|
5
|
+
privateScriptPath,
|
|
6
|
+
runToolchainChild,
|
|
7
|
+
toIndexSymbols,
|
|
8
|
+
withSpawnGate
|
|
9
|
+
} from "./chunk-OIFY4XNP.js";
|
|
10
|
+
import {
|
|
11
|
+
detectLang
|
|
12
|
+
} from "./chunk-YOHO4DVT.js";
|
|
13
|
+
import {
|
|
14
|
+
resolveWin32Command
|
|
15
|
+
} from "./chunk-XZLVJD56.js";
|
|
16
|
+
|
|
17
|
+
// src/codebase-index/go-parser.ts
|
|
18
|
+
async function parseSymbols(opts) {
|
|
19
|
+
const { file, content, lang } = opts;
|
|
20
|
+
try {
|
|
21
|
+
const parsed = await withSpawnGate(() => syncGoParse(file, content, lang));
|
|
22
|
+
if (parsed.symbols.length > 0) {
|
|
23
|
+
return parsed;
|
|
24
|
+
}
|
|
25
|
+
const fallback = parseGoWithoutToolchain(file, content, lang);
|
|
26
|
+
return parsed.refs?.length ? { ...fallback, refs: parsed.refs } : fallback;
|
|
27
|
+
} catch {
|
|
28
|
+
return parseGoWithoutToolchain(file, content, lang);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
var GO_FUNC_RE = /^func\s+(?:\(\s*(?:[A-Za-z_]\w*\s+)?\*?\s*([A-Za-z_]\w*)(?:\[[^\]]*\])?\s*\)\s*)?([A-Za-z_]\w*)\s*[[(]/;
|
|
32
|
+
var GO_NAME_LIST_RE = /^([A-Za-z_]\w*(?:\s*,\s*[A-Za-z_]\w*)*)/;
|
|
33
|
+
function maskGoNonCode(src) {
|
|
34
|
+
const blank = (text) => text.replace(/[^\n]/g, " ");
|
|
35
|
+
let out = "";
|
|
36
|
+
let i = 0;
|
|
37
|
+
const n = src.length;
|
|
38
|
+
while (i < n) {
|
|
39
|
+
const c = src[i];
|
|
40
|
+
const next = src[i + 1];
|
|
41
|
+
if (c === "/" && next === "/") {
|
|
42
|
+
const newline = src.indexOf("\n", i);
|
|
43
|
+
const stop = newline === -1 ? n : newline;
|
|
44
|
+
out += blank(src.slice(i, stop));
|
|
45
|
+
i = stop;
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (c === "/" && next === "*") {
|
|
49
|
+
const end = src.indexOf("*/", i + 2);
|
|
50
|
+
const stop = end === -1 ? n : end + 2;
|
|
51
|
+
out += blank(src.slice(i, stop));
|
|
52
|
+
i = stop;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (c === '"' || c === "'" || c === "`") {
|
|
56
|
+
const raw = c === "`";
|
|
57
|
+
let j = i + 1;
|
|
58
|
+
while (j < n && src[j] !== c && (raw || src[j] !== "\n")) {
|
|
59
|
+
j += !raw && src[j] === "\\" ? 2 : 1;
|
|
60
|
+
}
|
|
61
|
+
if (j < n && src[j] === c) {
|
|
62
|
+
out += c + blank(src.slice(i + 1, j)) + c;
|
|
63
|
+
i = j + 1;
|
|
64
|
+
} else {
|
|
65
|
+
const stop = Math.min(j, n);
|
|
66
|
+
out += c + blank(src.slice(i + 1, stop));
|
|
67
|
+
i = stop;
|
|
68
|
+
}
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
out += c;
|
|
72
|
+
i++;
|
|
73
|
+
}
|
|
74
|
+
return out;
|
|
75
|
+
}
|
|
76
|
+
function parseGoWithoutToolchain(filePath, content, lang = "go") {
|
|
77
|
+
const code = maskGoNonCode(content);
|
|
78
|
+
if (!/^\s*package\s+[A-Za-z_]\w*/m.test(code) || hasUnbalancedDelimiters(code)) {
|
|
79
|
+
return { file: filePath, lang, symbols: [], mtimeMs: Date.now() };
|
|
80
|
+
}
|
|
81
|
+
const symbols = [];
|
|
82
|
+
const packageName = code.match(/^\s*package\s+([A-Za-z_]\w*)/m)?.[1] ?? "";
|
|
83
|
+
const qualify = (...parts) => [packageName, ...parts].filter(Boolean).join(".");
|
|
84
|
+
const codeLines = code.split("\n");
|
|
85
|
+
const srcLines = content.split("\n");
|
|
86
|
+
let braces = 0;
|
|
87
|
+
let parens = 0;
|
|
88
|
+
let group = null;
|
|
89
|
+
for (const [idx, line] of codeLines.entries()) {
|
|
90
|
+
const trimmed = line.trimStart();
|
|
91
|
+
const add = (kind, name, scope) => {
|
|
92
|
+
if (name === "_") return;
|
|
93
|
+
addFallbackSymbol(symbols, {
|
|
94
|
+
filePath,
|
|
95
|
+
lang,
|
|
96
|
+
kind,
|
|
97
|
+
name,
|
|
98
|
+
line: idx + 1,
|
|
99
|
+
col: line.length - trimmed.length,
|
|
100
|
+
signature: (srcLines[idx] ?? "").trim(),
|
|
101
|
+
scope
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
if (braces === 0 && parens === 0) {
|
|
105
|
+
group = null;
|
|
106
|
+
const fn = GO_FUNC_RE.exec(trimmed);
|
|
107
|
+
const opener = /^(const|var|type)\s*\(/.exec(trimmed);
|
|
108
|
+
if (fn?.[2]) {
|
|
109
|
+
add(fn[1] ? "method" : "function", fn[2], fn[1] ? qualify(fn[1], fn[2]) : qualify(fn[2]));
|
|
110
|
+
} else if (opener?.[1]) {
|
|
111
|
+
group = opener[1];
|
|
112
|
+
} else {
|
|
113
|
+
const typeDecl = /^type\s+([A-Za-z_]\w*)/.exec(trimmed);
|
|
114
|
+
if (typeDecl?.[1]) add("type", typeDecl[1], packageName);
|
|
115
|
+
const valueDecl = /^(const|var)\s+/.exec(trimmed);
|
|
116
|
+
const names = valueDecl ? GO_NAME_LIST_RE.exec(trimmed.slice(valueDecl[0].length)) : null;
|
|
117
|
+
if (valueDecl?.[1] && names?.[1]) {
|
|
118
|
+
for (const name of names[1].split(",")) {
|
|
119
|
+
add(valueDecl[1], name.trim(), packageName);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
} else if (group && braces === 0 && parens === 1) {
|
|
124
|
+
const names = GO_NAME_LIST_RE.exec(trimmed)?.[1];
|
|
125
|
+
if (names) {
|
|
126
|
+
const members = group === "type" ? [names.split(",")[0] ?? ""] : names.split(",");
|
|
127
|
+
for (const name of members) add(group, name.trim(), packageName);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
for (const ch of line) {
|
|
131
|
+
if (ch === "{") braces++;
|
|
132
|
+
else if (ch === "}") braces--;
|
|
133
|
+
else if (ch === "(") parens++;
|
|
134
|
+
else if (ch === ")") parens--;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return { file: filePath, lang, symbols, mtimeMs: Date.now() };
|
|
138
|
+
}
|
|
139
|
+
function addFallbackSymbol(symbols, opts) {
|
|
140
|
+
symbols.push({
|
|
141
|
+
id: 0,
|
|
142
|
+
lang: opts.lang,
|
|
143
|
+
kind: opts.kind,
|
|
144
|
+
name: opts.name,
|
|
145
|
+
file: opts.filePath,
|
|
146
|
+
line: opts.line,
|
|
147
|
+
col: opts.col,
|
|
148
|
+
signature: opts.signature,
|
|
149
|
+
docComment: "",
|
|
150
|
+
scope: opts.scope,
|
|
151
|
+
text: `${opts.name} ${opts.signature}`.trim()
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
function hasUnbalancedDelimiters(content) {
|
|
155
|
+
const pairs = { "(": ")", "[": "]", "{": "}" };
|
|
156
|
+
const closers = new Set(Object.values(pairs));
|
|
157
|
+
const stack = [];
|
|
158
|
+
for (const ch of content) {
|
|
159
|
+
if (pairs[ch]) {
|
|
160
|
+
stack.push(pairs[ch]);
|
|
161
|
+
} else if (closers.has(ch) && stack.pop() !== ch) {
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return stack.length > 0;
|
|
166
|
+
}
|
|
167
|
+
async function syncGoParse(filePath, content, lang) {
|
|
168
|
+
const empty = { file: filePath, lang, symbols: [], mtimeMs: Date.now() };
|
|
169
|
+
try {
|
|
170
|
+
const scriptPath = await privateScriptPath("ws-go-parse-", "parse.go", GO_PARSE_SCRIPT);
|
|
171
|
+
const result = await runToolchainChild(
|
|
172
|
+
resolveWin32Command("go"),
|
|
173
|
+
["run", scriptPath],
|
|
174
|
+
content,
|
|
175
|
+
15e3,
|
|
176
|
+
goSpawnOptions(scriptPath)
|
|
177
|
+
);
|
|
178
|
+
if (result?.code !== 0 || !result.stdout.trim()) return empty;
|
|
179
|
+
const { symbols, refs } = parseParserOutput(result.stdout, lang);
|
|
180
|
+
return {
|
|
181
|
+
file: filePath,
|
|
182
|
+
lang,
|
|
183
|
+
symbols: toIndexSymbols(symbols, filePath, lang),
|
|
184
|
+
refs,
|
|
185
|
+
mtimeMs: Date.now()
|
|
186
|
+
};
|
|
187
|
+
} catch {
|
|
188
|
+
return empty;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
export {
|
|
192
|
+
detectLang,
|
|
193
|
+
maskGoNonCode,
|
|
194
|
+
parseGoWithoutToolchain,
|
|
195
|
+
parseSymbols
|
|
196
|
+
};
|
|
197
|
+
//# sourceMappingURL=go-parser-LWV3L5V7.js.map
|
package/dist/index.js
CHANGED
|
@@ -46,10 +46,10 @@ import "./chunk-Z6DAKQ3U.js";
|
|
|
46
46
|
import {
|
|
47
47
|
registerBuiltinToolTier,
|
|
48
48
|
selectBuiltinToolsForTier
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-K3VX6V5P.js";
|
|
50
50
|
import {
|
|
51
51
|
builtinToolsPack
|
|
52
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-VMNWQI4V.js";
|
|
53
53
|
import {
|
|
54
54
|
OFF_ONLY_TOOLS,
|
|
55
55
|
OPTIONAL_TOOLS,
|
|
@@ -64,7 +64,7 @@ import {
|
|
|
64
64
|
pwshTool,
|
|
65
65
|
readUrlContentTool,
|
|
66
66
|
securityAstScanTool
|
|
67
|
-
} from "./chunk-
|
|
67
|
+
} from "./chunk-2BCRQAIW.js";
|
|
68
68
|
import {
|
|
69
69
|
discoverE2EProjects,
|
|
70
70
|
e2ePlanTool
|
|
@@ -98,8 +98,8 @@ import {
|
|
|
98
98
|
runDeadCodeScan,
|
|
99
99
|
setContextQueryEmbedder,
|
|
100
100
|
writeProjectAtlas
|
|
101
|
-
} from "./chunk-
|
|
102
|
-
import "./chunk-
|
|
101
|
+
} from "./chunk-K37AKCTN.js";
|
|
102
|
+
import "./chunk-2IRHFHZY.js";
|
|
103
103
|
import {
|
|
104
104
|
designTool
|
|
105
105
|
} from "./chunk-MRXWOOOR.js";
|
|
@@ -131,7 +131,7 @@ import {
|
|
|
131
131
|
} from "./chunk-SPNXDTCJ.js";
|
|
132
132
|
import {
|
|
133
133
|
patchTool
|
|
134
|
-
} from "./chunk-
|
|
134
|
+
} from "./chunk-YPSVPCIE.js";
|
|
135
135
|
import {
|
|
136
136
|
jsonTool
|
|
137
137
|
} from "./chunk-D6RQZMZS.js";
|
|
@@ -174,7 +174,7 @@ import {
|
|
|
174
174
|
import "./chunk-UVYRQKPZ.js";
|
|
175
175
|
import {
|
|
176
176
|
replaceTool
|
|
177
|
-
} from "./chunk-
|
|
177
|
+
} from "./chunk-CSS42GRP.js";
|
|
178
178
|
import {
|
|
179
179
|
globTool
|
|
180
180
|
} from "./chunk-ON6ET5ER.js";
|
|
@@ -284,13 +284,13 @@ import {
|
|
|
284
284
|
} from "./chunk-O2MHULBO.js";
|
|
285
285
|
import {
|
|
286
286
|
readTool
|
|
287
|
-
} from "./chunk-
|
|
287
|
+
} from "./chunk-OYQE2UNT.js";
|
|
288
288
|
import {
|
|
289
289
|
writeTool
|
|
290
|
-
} from "./chunk-
|
|
290
|
+
} from "./chunk-Z77XMU3U.js";
|
|
291
291
|
import {
|
|
292
292
|
editTool
|
|
293
|
-
} from "./chunk-
|
|
293
|
+
} from "./chunk-OMWC2OGT.js";
|
|
294
294
|
import {
|
|
295
295
|
checkSyntax
|
|
296
296
|
} from "./chunk-MSOAX3GC.js";
|
|
@@ -313,8 +313,8 @@ import {
|
|
|
313
313
|
shutdownCodebaseIndexHost,
|
|
314
314
|
shutdownCodebaseIndexServer,
|
|
315
315
|
symbolGraphService
|
|
316
|
-
} from "./chunk-
|
|
317
|
-
import "./chunk-
|
|
316
|
+
} from "./chunk-UMOP3VGK.js";
|
|
317
|
+
import "./chunk-RYLMSGR5.js";
|
|
318
318
|
import {
|
|
319
319
|
CONCEPT_RELATIONS,
|
|
320
320
|
CircuitOpenError,
|
|
@@ -322,11 +322,11 @@ import {
|
|
|
322
322
|
IndexTimeoutError,
|
|
323
323
|
indexCircuitBreaker,
|
|
324
324
|
resetIndexCircuitBreaker
|
|
325
|
-
} from "./chunk-
|
|
326
|
-
import "./chunk-
|
|
327
|
-
import "./chunk-
|
|
328
|
-
import "./chunk-
|
|
329
|
-
import "./chunk-
|
|
325
|
+
} from "./chunk-6D3UIQMF.js";
|
|
326
|
+
import "./chunk-BJ5LXLKE.js";
|
|
327
|
+
import "./chunk-R3HR3QI3.js";
|
|
328
|
+
import "./chunk-HSLDY55L.js";
|
|
329
|
+
import "./chunk-OIFY4XNP.js";
|
|
330
330
|
import "./chunk-YOHO4DVT.js";
|
|
331
331
|
import "./chunk-XHSHNOAF.js";
|
|
332
332
|
import "./chunk-XZLVJD56.js";
|