@wrongstack/tools 0.284.1 → 0.285.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/dist/_concurrency.d.ts +16 -0
- package/dist/_concurrency.d.ts.map +1 -0
- package/dist/_danger-detect.d.ts +54 -0
- package/dist/_danger-detect.d.ts.map +1 -0
- package/dist/_edit-match.d.ts +86 -0
- package/dist/_edit-match.d.ts.map +1 -0
- package/dist/_env.d.ts +6 -0
- package/dist/_env.d.ts.map +1 -0
- package/dist/_fetch-guard.d.ts +31 -0
- package/dist/_fetch-guard.d.ts.map +1 -0
- package/dist/_output-spool.d.ts +38 -0
- package/dist/_output-spool.d.ts.map +1 -0
- package/dist/_redact-command.d.ts +6 -0
- package/dist/_redact-command.d.ts.map +1 -0
- package/dist/_regex.d.ts +39 -0
- package/dist/_regex.d.ts.map +1 -0
- package/dist/_session-shell.d.ts +73 -0
- package/dist/_session-shell.d.ts.map +1 -0
- package/dist/_shell-pick.d.ts +158 -0
- package/dist/_shell-pick.d.ts.map +1 -0
- package/dist/_spawn-stream.d.ts +32 -0
- package/dist/_spawn-stream.d.ts.map +1 -0
- package/dist/_syntax-check.d.ts +16 -0
- package/dist/_syntax-check.d.ts.map +1 -0
- package/dist/_util.d.ts +68 -0
- package/dist/_util.d.ts.map +1 -0
- package/dist/_win32-resolve.d.ts +42 -0
- package/dist/_win32-resolve.d.ts.map +1 -0
- package/dist/audit.d.ts +4 -5
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +2743 -28
- package/dist/audit.js.map +7 -1
- package/dist/bash-kill-guard.d.ts +62 -0
- package/dist/bash-kill-guard.d.ts.map +1 -0
- package/dist/bash.d.ts +4 -5
- package/dist/bash.d.ts.map +1 -0
- package/dist/bash.js +59 -30
- package/dist/bash.js.map +7 -1
- package/dist/batch-tool-use.d.ts +4 -5
- package/dist/batch-tool-use.d.ts.map +1 -0
- package/dist/batch-tool-use.js +3 -3
- package/dist/batch-tool-use.js.map +7 -1
- package/dist/builtin.d.ts +7 -9
- package/dist/builtin.d.ts.map +1 -0
- package/dist/builtin.js +5282 -1019
- package/dist/builtin.js.map +7 -1
- package/dist/circuit-breaker.d.ts +4 -5
- package/dist/circuit-breaker.d.ts.map +1 -0
- package/dist/circuit-breaker.js +3 -3
- package/dist/circuit-breaker.js.map +7 -1
- package/dist/codebase-index/background-indexer.d.ts +116 -0
- package/dist/codebase-index/background-indexer.d.ts.map +1 -0
- package/dist/codebase-index/bm25.d.ts +40 -0
- package/dist/codebase-index/bm25.d.ts.map +1 -0
- package/dist/codebase-index/circuit-breaker.d.ts +94 -0
- package/dist/codebase-index/circuit-breaker.d.ts.map +1 -0
- package/dist/codebase-index/codebase-index-tool.d.ts +17 -0
- package/dist/codebase-index/codebase-index-tool.d.ts.map +1 -0
- package/dist/codebase-index/codebase-search-tool.d.ts +43 -0
- package/dist/codebase-index/codebase-search-tool.d.ts.map +1 -0
- package/dist/codebase-index/codebase-stats-tool.d.ts +23 -0
- package/dist/codebase-index/codebase-stats-tool.d.ts.map +1 -0
- package/dist/codebase-index/gitignore.d.ts +22 -0
- package/dist/codebase-index/gitignore.d.ts.map +1 -0
- package/dist/codebase-index/go-parser.d.ts +16 -0
- package/dist/codebase-index/go-parser.d.ts.map +1 -0
- package/dist/codebase-index/index-service.d.ts +25 -0
- package/dist/codebase-index/index-service.d.ts.map +1 -0
- package/dist/codebase-index/index.d.ts +23 -271
- package/dist/codebase-index/index.d.ts.map +1 -0
- package/dist/codebase-index/index.js +136 -68
- package/dist/codebase-index/index.js.map +7 -1
- package/dist/codebase-index/indexer.d.ts +28 -0
- package/dist/codebase-index/indexer.d.ts.map +1 -0
- package/dist/codebase-index/json-parser.d.ts +8 -0
- package/dist/codebase-index/json-parser.d.ts.map +1 -0
- package/dist/codebase-index/lsp-kind.d.ts +53 -0
- package/dist/codebase-index/lsp-kind.d.ts.map +1 -0
- package/dist/codebase-index/py-parser.d.ts +16 -0
- package/dist/codebase-index/py-parser.d.ts.map +1 -0
- package/dist/codebase-index/refs-extractor.d.ts +25 -0
- package/dist/codebase-index/refs-extractor.d.ts.map +1 -0
- package/dist/codebase-index/rs-parser.d.ts +8 -0
- package/dist/codebase-index/rs-parser.d.ts.map +1 -0
- package/dist/codebase-index/schema.d.ts +82 -0
- package/dist/codebase-index/schema.d.ts.map +1 -0
- package/dist/codebase-index/ts-parser.d.ts +30 -0
- package/dist/codebase-index/ts-parser.d.ts.map +1 -0
- package/dist/codebase-index/worker-protocol.d.ts +77 -0
- package/dist/codebase-index/worker-protocol.d.ts.map +1 -0
- package/dist/codebase-index/worker.d.ts +16 -2
- package/dist/codebase-index/worker.d.ts.map +1 -0
- package/dist/codebase-index/worker.js +103 -65
- package/dist/codebase-index/worker.js.map +7 -1
- package/dist/codebase-index/writer.d.ts +189 -0
- package/dist/codebase-index/writer.d.ts.map +1 -0
- package/dist/codebase-index/yaml-parser.d.ts +8 -0
- package/dist/codebase-index/yaml-parser.d.ts.map +1 -0
- package/dist/design.d.ts +38 -0
- package/dist/design.d.ts.map +1 -0
- package/dist/design.js +270 -0
- package/dist/design.js.map +7 -0
- package/dist/diff.d.ts +4 -5
- package/dist/diff.d.ts.map +1 -0
- package/dist/diff.js +14 -12
- package/dist/diff.js.map +7 -1
- package/dist/document.d.ts +4 -5
- package/dist/document.d.ts.map +1 -0
- package/dist/document.js +8 -7
- package/dist/document.js.map +7 -1
- package/dist/edit.d.ts +5 -36
- package/dist/edit.d.ts.map +1 -0
- package/dist/edit.js +28 -16
- package/dist/edit.js.map +7 -1
- package/dist/exec.d.ts +67 -2
- package/dist/exec.d.ts.map +1 -0
- package/dist/exec.js +50 -25
- package/dist/exec.js.map +7 -1
- package/dist/fetch.d.ts +4 -32
- package/dist/fetch.d.ts.map +1 -0
- package/dist/fetch.js +89 -77
- package/dist/fetch.js.map +7 -1
- package/dist/format.d.ts +4 -5
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +2415 -28
- package/dist/format.js.map +7 -1
- package/dist/git.d.ts +4 -5
- package/dist/git.d.ts.map +1 -0
- package/dist/git.js +10 -9
- package/dist/git.js.map +7 -1
- package/dist/glob.d.ts +4 -5
- package/dist/glob.d.ts.map +1 -0
- package/dist/glob.js +15 -12
- package/dist/glob.js.map +7 -1
- package/dist/grep.d.ts +4 -5
- package/dist/grep.d.ts.map +1 -0
- package/dist/grep.js +13 -10
- package/dist/grep.js.map +7 -1
- package/dist/index.d.ts +19 -724
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6088 -1690
- package/dist/index.js.map +7 -1
- package/dist/install.d.ts +4 -5
- package/dist/install.d.ts.map +1 -0
- package/dist/install.js +2680 -31
- package/dist/install.js.map +7 -1
- package/dist/json.d.ts +4 -5
- package/dist/json.d.ts.map +1 -0
- package/dist/json.js +13 -11
- package/dist/json.js.map +7 -1
- package/dist/kanban.d.ts +107 -0
- package/dist/kanban.d.ts.map +1 -0
- package/dist/kanban.js +845 -0
- package/dist/kanban.js.map +7 -0
- package/dist/languages/detect.d.ts +3 -0
- package/dist/languages/detect.d.ts.map +1 -0
- package/dist/languages/diagnostics.d.ts +15 -0
- package/dist/languages/diagnostics.d.ts.map +1 -0
- package/dist/languages/execute-tool.d.ts +34 -0
- package/dist/languages/execute-tool.d.ts.map +1 -0
- package/dist/languages/execute.d.ts +18 -0
- package/dist/languages/execute.d.ts.map +1 -0
- package/dist/languages/index.d.ts +12 -0
- package/dist/languages/index.d.ts.map +1 -0
- package/dist/languages/index.js +4457 -0
- package/dist/languages/index.js.map +7 -0
- package/dist/languages/legacy-bridge.d.ts +29 -0
- package/dist/languages/legacy-bridge.d.ts.map +1 -0
- package/dist/languages/package-tool.d.ts +29 -0
- package/dist/languages/package-tool.d.ts.map +1 -0
- package/dist/languages/plan.d.ts +4 -0
- package/dist/languages/plan.d.ts.map +1 -0
- package/dist/languages/profile-helpers.d.ts +14 -0
- package/dist/languages/profile-helpers.d.ts.map +1 -0
- package/dist/languages/profiles/additional.d.ts +3 -0
- package/dist/languages/profiles/additional.d.ts.map +1 -0
- package/dist/languages/profiles/primary.d.ts +3 -0
- package/dist/languages/profiles/primary.d.ts.map +1 -0
- package/dist/languages/registry.d.ts +11 -0
- package/dist/languages/registry.d.ts.map +1 -0
- package/dist/languages/tool.d.ts +32 -0
- package/dist/languages/tool.d.ts.map +1 -0
- package/dist/languages/types.d.ts +207 -0
- package/dist/languages/types.d.ts.map +1 -0
- package/dist/lint.d.ts +4 -5
- package/dist/lint.d.ts.map +1 -0
- package/dist/lint.js +2415 -27
- package/dist/lint.js.map +7 -1
- package/dist/logs.d.ts +4 -5
- package/dist/logs.d.ts.map +1 -0
- package/dist/logs.js +16 -10
- package/dist/logs.js.map +7 -1
- package/dist/memory.d.ts +7 -8
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +7 -5
- package/dist/memory.js.map +7 -1
- package/dist/mode.d.ts +4 -5
- package/dist/mode.d.ts.map +1 -0
- package/dist/mode.js +3 -3
- package/dist/mode.js.map +7 -1
- package/dist/next-steps.d.ts +5 -6
- package/dist/next-steps.d.ts.map +1 -0
- package/dist/next-steps.js +5 -4
- package/dist/next-steps.js.map +7 -1
- package/dist/outdated.d.ts +4 -5
- package/dist/outdated.d.ts.map +1 -0
- package/dist/outdated.js +4777 -68
- package/dist/outdated.js.map +7 -1
- package/dist/pack.d.ts +3 -6
- package/dist/pack.d.ts.map +1 -0
- package/dist/pack.js +5275 -1019
- package/dist/pack.js.map +7 -1
- package/dist/patch.d.ts +4 -5
- package/dist/patch.d.ts.map +1 -0
- package/dist/patch.js +18 -16
- package/dist/patch.js.map +7 -1
- package/dist/plan.d.ts +55 -0
- package/dist/plan.d.ts.map +1 -0
- package/dist/plan.js +280 -0
- package/dist/plan.js.map +7 -0
- package/dist/process-guardian.d.ts +100 -0
- package/dist/process-guardian.d.ts.map +1 -0
- package/dist/process-registry-persistent.d.ts +121 -0
- package/dist/process-registry-persistent.d.ts.map +1 -0
- package/dist/process-registry.d.ts +13 -17
- package/dist/process-registry.d.ts.map +1 -0
- package/dist/process-registry.js +15 -9
- package/dist/process-registry.js.map +7 -1
- package/dist/ps-slash.d.ts +106 -0
- package/dist/ps-slash.d.ts.map +1 -0
- package/dist/ps-slash.js +1291 -0
- package/dist/ps-slash.js.map +7 -0
- package/dist/read.d.ts +4 -5
- package/dist/read.d.ts.map +1 -0
- package/dist/read.js +13 -11
- package/dist/read.js.map +7 -1
- package/dist/replace.d.ts +4 -5
- package/dist/replace.d.ts.map +1 -0
- package/dist/replace.js +26 -13
- package/dist/replace.js.map +7 -1
- package/dist/scaffold.d.ts +4 -5
- package/dist/scaffold.d.ts.map +1 -0
- package/dist/scaffold.js +16 -14
- package/dist/scaffold.js.map +7 -1
- package/dist/search.d.ts +5 -6
- package/dist/search.d.ts.map +1 -0
- package/dist/search.js +24 -25
- package/dist/search.js.map +7 -1
- package/dist/set-working-dir.d.ts +18 -0
- package/dist/set-working-dir.d.ts.map +1 -0
- package/dist/shim/node-sqlite.d.ts +3 -0
- package/dist/shim/node-sqlite.d.ts.map +1 -0
- package/dist/skill.d.ts +45 -0
- package/dist/skill.d.ts.map +1 -0
- package/dist/skill.js +175 -0
- package/dist/skill.js.map +7 -0
- package/dist/spawn-background.d.ts +80 -0
- package/dist/spawn-background.d.ts.map +1 -0
- package/dist/task.d.ts +35 -0
- package/dist/task.d.ts.map +1 -0
- package/dist/task.js +380 -0
- package/dist/task.js.map +7 -0
- package/dist/test.d.ts +4 -5
- package/dist/test.d.ts.map +1 -0
- package/dist/test.js +2419 -27
- package/dist/test.js.map +7 -1
- package/dist/todo.d.ts +4 -5
- package/dist/todo.d.ts.map +1 -0
- package/dist/todo.js +5 -5
- package/dist/todo.js.map +7 -1
- package/dist/tool-diff.d.ts +16 -17
- package/dist/tool-diff.d.ts.map +1 -0
- package/dist/tool-diff.js +11 -3
- package/dist/tool-diff.js.map +7 -1
- package/dist/tool-help.d.ts +4 -5
- package/dist/tool-help.d.ts.map +1 -0
- package/dist/tool-help.js +3 -3
- package/dist/tool-help.js.map +7 -1
- package/dist/tool-icon-map.d.ts +45 -0
- package/dist/tool-icon-map.d.ts.map +1 -0
- package/dist/tool-icons.d.ts +5 -6
- package/dist/tool-icons.d.ts.map +1 -0
- package/dist/tool-icons.js +16 -4
- package/dist/tool-icons.js.map +7 -1
- package/dist/tool-search.d.ts +4 -5
- package/dist/tool-search.d.ts.map +1 -0
- package/dist/tool-search.js +3 -3
- package/dist/tool-search.js.map +7 -1
- package/dist/tool-summary.d.ts +4 -5
- package/dist/tool-summary.d.ts.map +1 -0
- package/dist/tool-summary.js +5 -3
- package/dist/tool-summary.js.map +7 -1
- package/dist/tool-use.d.ts +4 -5
- package/dist/tool-use.d.ts.map +1 -0
- package/dist/tool-use.js +3 -3
- package/dist/tool-use.js.map +7 -1
- package/dist/tree.d.ts +4 -5
- package/dist/tree.d.ts.map +1 -0
- package/dist/tree.js +11 -9
- package/dist/tree.js.map +7 -1
- package/dist/typecheck.d.ts +4 -5
- package/dist/typecheck.d.ts.map +1 -0
- package/dist/typecheck.js +2416 -28
- package/dist/typecheck.js.map +7 -1
- package/dist/write.d.ts +4 -5
- package/dist/write.d.ts.map +1 -0
- package/dist/write.js +21 -16
- package/dist/write.js.map +7 -1
- package/package.json +34 -6
- package/dist/background-indexer-BeDBxfSh.d.ts +0 -371
- package/dist/exec-2OKoT6tk.d.ts +0 -121
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import { parentPort } from 'node:worker_threads';
|
|
2
|
-
import { expectDefined, resolveWstackPaths, compileGlob, truncate } from '@wrongstack/core';
|
|
3
|
-
import * as fs2 from 'node:fs/promises';
|
|
4
|
-
import * as path4 from 'node:path';
|
|
5
|
-
import { toErrorMessage } from '@wrongstack/core/utils';
|
|
6
|
-
import { createRequire } from 'node:module';
|
|
7
|
-
import * as fs from 'node:fs';
|
|
8
|
-
import * as ts from 'typescript';
|
|
9
|
-
import { execFileSync, spawn } from 'node:child_process';
|
|
10
|
-
import * as os from 'node:os';
|
|
11
|
-
|
|
12
1
|
// src/codebase-index/worker.ts
|
|
2
|
+
import { parentPort } from "node:worker_threads";
|
|
3
|
+
|
|
4
|
+
// src/codebase-index/indexer.ts
|
|
5
|
+
import { expectDefined as expectDefined5 } from "@wrongstack/core";
|
|
6
|
+
import * as fs6 from "node:fs/promises";
|
|
7
|
+
import * as path7 from "node:path";
|
|
8
|
+
import { compileGlob as compileGlob2 } from "@wrongstack/core";
|
|
9
|
+
|
|
10
|
+
// src/codebase-index/writer.ts
|
|
11
|
+
import { expectDefined } from "@wrongstack/core";
|
|
13
12
|
|
|
14
13
|
// src/codebase-index/circuit-breaker.ts
|
|
15
14
|
var LockError = class extends Error {
|
|
@@ -83,7 +82,14 @@ var IndexCircuitBreaker = class {
|
|
|
83
82
|
};
|
|
84
83
|
}
|
|
85
84
|
};
|
|
86
|
-
new IndexCircuitBreaker();
|
|
85
|
+
var indexCircuitBreaker = new IndexCircuitBreaker();
|
|
86
|
+
|
|
87
|
+
// src/codebase-index/writer.ts
|
|
88
|
+
import { toErrorMessage } from "@wrongstack/core/utils";
|
|
89
|
+
import { createRequire } from "node:module";
|
|
90
|
+
import * as fs from "node:fs";
|
|
91
|
+
import * as path from "node:path";
|
|
92
|
+
import { resolveWstackPaths } from "@wrongstack/core";
|
|
87
93
|
|
|
88
94
|
// src/codebase-index/schema.ts
|
|
89
95
|
var SCHEMA_VERSION = 2;
|
|
@@ -325,7 +331,7 @@ var IndexStore = class {
|
|
|
325
331
|
this.indexDir = resolveIndexDir(projectRoot, opts.indexDir);
|
|
326
332
|
fs.mkdirSync(this.indexDir, { recursive: true });
|
|
327
333
|
const Database = loadDatabaseSync();
|
|
328
|
-
this.db = new Database(
|
|
334
|
+
this.db = new Database(path.join(this.indexDir, DB_FILE));
|
|
329
335
|
try {
|
|
330
336
|
this.db.exec("PRAGMA journal_mode = WAL");
|
|
331
337
|
this.db.exec("PRAGMA busy_timeout = 5000");
|
|
@@ -904,7 +910,7 @@ var IndexStore = class {
|
|
|
904
910
|
}));
|
|
905
911
|
}
|
|
906
912
|
sizeBytes() {
|
|
907
|
-
const dbPath =
|
|
913
|
+
const dbPath = path.join(this.indexDir, DB_FILE);
|
|
908
914
|
try {
|
|
909
915
|
return fs.statSync(dbPath).size;
|
|
910
916
|
} catch {
|
|
@@ -919,6 +925,9 @@ var IndexStore = class {
|
|
|
919
925
|
}
|
|
920
926
|
}
|
|
921
927
|
};
|
|
928
|
+
|
|
929
|
+
// src/codebase-index/ts-parser.ts
|
|
930
|
+
import * as ts from "@typescript/typescript6";
|
|
922
931
|
var KIND_MAP = {
|
|
923
932
|
[ts.SyntaxKind.ClassDeclaration]: "class",
|
|
924
933
|
[ts.SyntaxKind.InterfaceDeclaration]: "interface",
|
|
@@ -1103,6 +1112,12 @@ function detectLang(file) {
|
|
|
1103
1112
|
if (idx < 0) return null;
|
|
1104
1113
|
return extToLang(file.slice(idx));
|
|
1105
1114
|
}
|
|
1115
|
+
|
|
1116
|
+
// src/codebase-index/go-parser.ts
|
|
1117
|
+
import { spawn } from "node:child_process";
|
|
1118
|
+
import * as os from "node:os";
|
|
1119
|
+
import * as path2 from "node:path";
|
|
1120
|
+
import * as fs2 from "node:fs/promises";
|
|
1106
1121
|
async function parseSymbols2(opts) {
|
|
1107
1122
|
const { file, content, lang } = opts;
|
|
1108
1123
|
try {
|
|
@@ -1403,9 +1418,9 @@ func formatType(t ast.Expr) string {
|
|
|
1403
1418
|
}
|
|
1404
1419
|
`;
|
|
1405
1420
|
async function syncGoParse(filePath, content, lang) {
|
|
1406
|
-
const tmpDir = await fs2.mkdtemp(
|
|
1421
|
+
const tmpDir = await fs2.mkdtemp(path2.join(os.tmpdir(), "ws-go-parse-"));
|
|
1407
1422
|
try {
|
|
1408
|
-
const scriptPath =
|
|
1423
|
+
const scriptPath = path2.join(tmpDir, "parse.go");
|
|
1409
1424
|
await fs2.writeFile(scriptPath, GO_PARSE_SCRIPT, "utf8");
|
|
1410
1425
|
const proc = spawn("go", ["run", scriptPath], {
|
|
1411
1426
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -1452,6 +1467,12 @@ async function syncGoParse(filePath, content, lang) {
|
|
|
1452
1467
|
await fs2.rm(tmpDir, { recursive: true, force: true });
|
|
1453
1468
|
}
|
|
1454
1469
|
}
|
|
1470
|
+
|
|
1471
|
+
// src/codebase-index/py-parser.ts
|
|
1472
|
+
import { spawn as spawn2 } from "node:child_process";
|
|
1473
|
+
import * as fs3 from "node:fs/promises";
|
|
1474
|
+
import * as os2 from "node:os";
|
|
1475
|
+
import * as path3 from "node:path";
|
|
1455
1476
|
async function parseSymbols3(opts) {
|
|
1456
1477
|
const { file, content, lang } = opts;
|
|
1457
1478
|
try {
|
|
@@ -1667,12 +1688,12 @@ var _cachedScriptPath = null;
|
|
|
1667
1688
|
async function syncPyParse(filePath, content, lang) {
|
|
1668
1689
|
try {
|
|
1669
1690
|
if (!_cachedScriptPath) {
|
|
1670
|
-
const tmpDir =
|
|
1671
|
-
await
|
|
1672
|
-
_cachedScriptPath =
|
|
1673
|
-
await
|
|
1691
|
+
const tmpDir = path3.join(os2.tmpdir(), "ws-py-parse");
|
|
1692
|
+
await fs3.mkdir(tmpDir, { recursive: true });
|
|
1693
|
+
_cachedScriptPath = path3.join(tmpDir, "parse.py");
|
|
1694
|
+
await fs3.writeFile(_cachedScriptPath, PY_PARSE_SCRIPT, "utf8");
|
|
1674
1695
|
}
|
|
1675
|
-
const proc =
|
|
1696
|
+
const proc = spawn2("python", [_cachedScriptPath, filePath], {
|
|
1676
1697
|
stdio: ["pipe", "pipe", "pipe"],
|
|
1677
1698
|
windowsHide: true
|
|
1678
1699
|
});
|
|
@@ -1715,6 +1736,12 @@ async function syncPyParse(filePath, content, lang) {
|
|
|
1715
1736
|
return { file: filePath, lang, symbols: [], mtimeMs: Date.now() };
|
|
1716
1737
|
}
|
|
1717
1738
|
}
|
|
1739
|
+
|
|
1740
|
+
// src/codebase-index/rs-parser.ts
|
|
1741
|
+
import { expectDefined as expectDefined2 } from "@wrongstack/core";
|
|
1742
|
+
import { execFileSync, spawn as spawn3 } from "node:child_process";
|
|
1743
|
+
import * as fs4 from "node:fs/promises";
|
|
1744
|
+
import * as path4 from "node:path";
|
|
1718
1745
|
async function parseSymbols4(opts) {
|
|
1719
1746
|
const { file, content, lang } = opts;
|
|
1720
1747
|
const nativeAvailable = checkNativeParser();
|
|
@@ -1754,8 +1781,8 @@ async function tryNativeParse(file, content) {
|
|
|
1754
1781
|
const toolsDir = path4.join(process.cwd(), "tools");
|
|
1755
1782
|
const crateDir = path4.join(toolsDir, "syn-parser");
|
|
1756
1783
|
const tmpFile = path4.join(crateDir, "src", "input.rs");
|
|
1757
|
-
await
|
|
1758
|
-
const proc =
|
|
1784
|
+
await fs4.writeFile(tmpFile, content, "utf8");
|
|
1785
|
+
const proc = spawn3(
|
|
1759
1786
|
"cargo",
|
|
1760
1787
|
["run", "--manifest-path", path4.join(toolsDir, "Cargo.toml")],
|
|
1761
1788
|
{
|
|
@@ -1816,7 +1843,7 @@ function regexParse(opts) {
|
|
|
1816
1843
|
let hi = lineOffsets.length - 1;
|
|
1817
1844
|
while (lo < hi) {
|
|
1818
1845
|
const mid = lo + hi + 1 >>> 1;
|
|
1819
|
-
if (
|
|
1846
|
+
if (expectDefined2(lineOffsets[mid]) <= offset) lo = mid;
|
|
1820
1847
|
else hi = mid - 1;
|
|
1821
1848
|
}
|
|
1822
1849
|
return lo + 1;
|
|
@@ -1828,12 +1855,12 @@ function regexParse(opts) {
|
|
|
1828
1855
|
for (const pattern of RS_PATTERNS) {
|
|
1829
1856
|
pattern.regex.lastIndex = 0;
|
|
1830
1857
|
for (let match = pattern.regex.exec(content); match !== null; match = pattern.regex.exec(content)) {
|
|
1831
|
-
const name =
|
|
1858
|
+
const name = expectDefined2(match[1]);
|
|
1832
1859
|
const offset = match.index ?? 0;
|
|
1833
1860
|
const line = lineFromOffset(offset);
|
|
1834
1861
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
1835
1862
|
const lineIdx = line - 1;
|
|
1836
|
-
const signature = extractDeclaration(lineIdx);
|
|
1863
|
+
const signature = extractDeclaration(lineIdx, match);
|
|
1837
1864
|
symbols.push({
|
|
1838
1865
|
id: 0,
|
|
1839
1866
|
lang,
|
|
@@ -1858,6 +1885,10 @@ function regexParse(opts) {
|
|
|
1858
1885
|
});
|
|
1859
1886
|
return { file, lang, symbols: deduped, mtimeMs: Date.now() };
|
|
1860
1887
|
}
|
|
1888
|
+
|
|
1889
|
+
// src/codebase-index/json-parser.ts
|
|
1890
|
+
import { expectDefined as expectDefined3 } from "@wrongstack/core";
|
|
1891
|
+
import * as path5 from "node:path";
|
|
1861
1892
|
function parseSymbols5(opts) {
|
|
1862
1893
|
const { file, content, lang } = opts;
|
|
1863
1894
|
try {
|
|
@@ -1869,7 +1900,7 @@ function parseSymbols5(opts) {
|
|
|
1869
1900
|
function regexParse2(opts) {
|
|
1870
1901
|
const { file, content, lang } = opts;
|
|
1871
1902
|
const symbols = [];
|
|
1872
|
-
const basename2 =
|
|
1903
|
+
const basename2 = path5.basename(file).toLowerCase();
|
|
1873
1904
|
const isPackageJson = basename2 === "package.json";
|
|
1874
1905
|
const isTsconfig = basename2 === "tsconfig.json" || basename2 === "tsconfig.build.json";
|
|
1875
1906
|
const isJsonSchema = content.includes("$schema") || content.includes("$id") || content.includes("$ref");
|
|
@@ -1884,22 +1915,22 @@ function regexParse2(opts) {
|
|
|
1884
1915
|
let hi = lineOffsets.length - 1;
|
|
1885
1916
|
while (lo < hi) {
|
|
1886
1917
|
const mid = lo + hi + 1 >>> 1;
|
|
1887
|
-
if (
|
|
1918
|
+
if (expectDefined3(lineOffsets[mid]) <= offset) lo = mid;
|
|
1888
1919
|
else hi = mid - 1;
|
|
1889
1920
|
}
|
|
1890
1921
|
return lo + 1;
|
|
1891
1922
|
}
|
|
1892
1923
|
const rootMatch = content.match(/^\s*\{/m);
|
|
1893
1924
|
if (rootMatch) {
|
|
1894
|
-
const offset =
|
|
1925
|
+
const offset = expectDefined3(rootMatch.index);
|
|
1895
1926
|
const line = lineFromOffset(offset);
|
|
1896
1927
|
symbols.push(
|
|
1897
1928
|
makeSymbol({
|
|
1898
|
-
name:
|
|
1929
|
+
name: path5.basename(file),
|
|
1899
1930
|
kind: "object",
|
|
1900
1931
|
line,
|
|
1901
1932
|
col: 0,
|
|
1902
|
-
signature: `"${
|
|
1933
|
+
signature: `"${path5.basename(file)}" = { ... }`,
|
|
1903
1934
|
file,
|
|
1904
1935
|
lang
|
|
1905
1936
|
})
|
|
@@ -1907,7 +1938,7 @@ function regexParse2(opts) {
|
|
|
1907
1938
|
}
|
|
1908
1939
|
const topLevelKeyRegex = /^\s*"([^"]+)"\s*:/gm;
|
|
1909
1940
|
for (let match = topLevelKeyRegex.exec(content); match !== null; match = topLevelKeyRegex.exec(content)) {
|
|
1910
|
-
const key =
|
|
1941
|
+
const key = expectDefined3(match[1]);
|
|
1911
1942
|
const offset = match.index ?? 0;
|
|
1912
1943
|
const line = lineFromOffset(offset);
|
|
1913
1944
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
@@ -1954,7 +1985,7 @@ function regexParse2(opts) {
|
|
|
1954
1985
|
const defsRegex = /"\$defs"\s*:|"\$defs"\s*:/g;
|
|
1955
1986
|
const defsMatch = defsRegex.exec(content);
|
|
1956
1987
|
if (defsMatch !== null) {
|
|
1957
|
-
const offset =
|
|
1988
|
+
const offset = expectDefined3(defsMatch.index);
|
|
1958
1989
|
const line = lineFromOffset(offset);
|
|
1959
1990
|
symbols.push(
|
|
1960
1991
|
makeSymbol({
|
|
@@ -1979,7 +2010,7 @@ function regexParse2(opts) {
|
|
|
1979
2010
|
for (let match = pat.exec(content); match !== null; match = pat.exec(content)) {
|
|
1980
2011
|
const offset = match.index ?? 0;
|
|
1981
2012
|
const line = lineFromOffset(offset);
|
|
1982
|
-
const key = match[0]?.match(/"([^"]+)"/)?.[1] ??
|
|
2013
|
+
const key = match[0]?.match(/"([^"]+)"/)?.[1] ?? expectDefined3(match[0]);
|
|
1983
2014
|
symbols.push(
|
|
1984
2015
|
makeSymbol({
|
|
1985
2016
|
name: key,
|
|
@@ -1998,12 +2029,12 @@ function regexParse2(opts) {
|
|
|
1998
2029
|
function extractPackageScripts(content, symbols, file, lang, lineOffsets, lineFromOffset) {
|
|
1999
2030
|
const scriptsBlockRegex = /"scripts"\s*:\s*\{([^}]+)\}/g;
|
|
2000
2031
|
for (let match = scriptsBlockRegex.exec(content); match !== null; match = scriptsBlockRegex.exec(content)) {
|
|
2001
|
-
const blockContent =
|
|
2032
|
+
const blockContent = expectDefined3(match[0]);
|
|
2002
2033
|
const blockOffset = match.index ?? 0;
|
|
2003
2034
|
const scriptKeyRegex = /"(\w[\w-]*)"\s*:/g;
|
|
2004
2035
|
for (let scriptMatch = scriptKeyRegex.exec(blockContent); scriptMatch !== null; scriptMatch = scriptKeyRegex.exec(blockContent)) {
|
|
2005
|
-
const key =
|
|
2006
|
-
const keyOffset = blockOffset +
|
|
2036
|
+
const key = expectDefined3(scriptMatch[1]);
|
|
2037
|
+
const keyOffset = blockOffset + expectDefined3(scriptMatch.index);
|
|
2007
2038
|
const line = lineFromOffset(keyOffset);
|
|
2008
2039
|
symbols.push(
|
|
2009
2040
|
makeSymbol({
|
|
@@ -2022,12 +2053,12 @@ function extractPackageScripts(content, symbols, file, lang, lineOffsets, lineFr
|
|
|
2022
2053
|
function extractCompilerOptions(content, symbols, file, lang, lineOffsets, parentLine, lineFromOffset) {
|
|
2023
2054
|
const optsBlockRegex = /"compilerOptions"\s*:\s*\{([^}]+)\}/g;
|
|
2024
2055
|
for (let match = optsBlockRegex.exec(content); match !== null; match = optsBlockRegex.exec(content)) {
|
|
2025
|
-
const blockContent =
|
|
2056
|
+
const blockContent = expectDefined3(match[0]);
|
|
2026
2057
|
const blockOffset = match.index ?? 0;
|
|
2027
2058
|
const optKeyRegex = /"(\w[\w]*)"\s*:/g;
|
|
2028
2059
|
for (let optMatch = optKeyRegex.exec(blockContent); optMatch !== null; optMatch = optKeyRegex.exec(blockContent)) {
|
|
2029
|
-
const key =
|
|
2030
|
-
const keyOffset = blockOffset +
|
|
2060
|
+
const key = expectDefined3(optMatch[1]);
|
|
2061
|
+
const keyOffset = blockOffset + expectDefined3(optMatch.index);
|
|
2031
2062
|
const line = lineFromOffset(keyOffset);
|
|
2032
2063
|
if (line <= parentLine) continue;
|
|
2033
2064
|
symbols.push(
|
|
@@ -2059,6 +2090,9 @@ function makeSymbol(opts) {
|
|
|
2059
2090
|
text: `${opts.name} ${opts.signature}`.trim()
|
|
2060
2091
|
};
|
|
2061
2092
|
}
|
|
2093
|
+
|
|
2094
|
+
// src/codebase-index/yaml-parser.ts
|
|
2095
|
+
import { expectDefined as expectDefined4, truncate } from "@wrongstack/core";
|
|
2062
2096
|
function parseSymbols6(opts) {
|
|
2063
2097
|
const { file, content, lang } = opts;
|
|
2064
2098
|
try {
|
|
@@ -2080,14 +2114,14 @@ function regexParse3(opts) {
|
|
|
2080
2114
|
let hi = lineOffsets.length - 1;
|
|
2081
2115
|
while (lo < hi) {
|
|
2082
2116
|
const mid = lo + hi + 1 >>> 1;
|
|
2083
|
-
if (
|
|
2117
|
+
if (expectDefined4(lineOffsets[mid]) <= offset) lo = mid;
|
|
2084
2118
|
else hi = mid - 1;
|
|
2085
2119
|
}
|
|
2086
2120
|
return lo + 1;
|
|
2087
2121
|
}
|
|
2088
2122
|
const anchorRegex = /&(\w[\w-]*)/g;
|
|
2089
2123
|
for (let match = anchorRegex.exec(content); match !== null; match = anchorRegex.exec(content)) {
|
|
2090
|
-
const name =
|
|
2124
|
+
const name = expectDefined4(match[1]);
|
|
2091
2125
|
const offset = match.index ?? 0;
|
|
2092
2126
|
const line = lineFromOffset(offset);
|
|
2093
2127
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
@@ -2105,7 +2139,7 @@ function regexParse3(opts) {
|
|
|
2105
2139
|
}
|
|
2106
2140
|
const aliasRegex = /\*(\w[\w-]*)/g;
|
|
2107
2141
|
for (let match = aliasRegex.exec(content); match !== null; match = aliasRegex.exec(content)) {
|
|
2108
|
-
const name =
|
|
2142
|
+
const name = expectDefined4(match[1]);
|
|
2109
2143
|
const offset = match.index ?? 0;
|
|
2110
2144
|
const line = lineFromOffset(offset);
|
|
2111
2145
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
@@ -2140,7 +2174,7 @@ function regexParse3(opts) {
|
|
|
2140
2174
|
}
|
|
2141
2175
|
const listItemRegex = /^-(\s+)([^:#\s][^:#\s]*)\s*:/gm;
|
|
2142
2176
|
for (let match = listItemRegex.exec(content); match !== null; match = listItemRegex.exec(content)) {
|
|
2143
|
-
const key =
|
|
2177
|
+
const key = expectDefined4(match[2]);
|
|
2144
2178
|
const offset = match.index ?? 0;
|
|
2145
2179
|
const line = lineFromOffset(offset);
|
|
2146
2180
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
@@ -2160,7 +2194,7 @@ function regexParse3(opts) {
|
|
|
2160
2194
|
}
|
|
2161
2195
|
const blockScalarRegex = /^(\s*)([^:#\s][^:#\s]*)\s*:\s*[|>](\s|$)/gm;
|
|
2162
2196
|
for (let match = blockScalarRegex.exec(content); match !== null; match = blockScalarRegex.exec(content)) {
|
|
2163
|
-
const key =
|
|
2197
|
+
const key = expectDefined4(match[2]);
|
|
2164
2198
|
const offset = match.index ?? 0;
|
|
2165
2199
|
const line = lineFromOffset(offset);
|
|
2166
2200
|
const col = offset - (lineOffsets[line - 1] ?? 0);
|
|
@@ -2205,6 +2239,11 @@ function makeSymbol2(opts) {
|
|
|
2205
2239
|
text: `${opts.name} ${opts.signature}`.trim()
|
|
2206
2240
|
};
|
|
2207
2241
|
}
|
|
2242
|
+
|
|
2243
|
+
// src/codebase-index/gitignore.ts
|
|
2244
|
+
import * as fs5 from "node:fs/promises";
|
|
2245
|
+
import * as path6 from "node:path";
|
|
2246
|
+
import { compileGlob } from "@wrongstack/core";
|
|
2208
2247
|
function globBody(glob) {
|
|
2209
2248
|
return compileGlob(glob).source.replace(/^\^/, "").replace(/\$$/, "");
|
|
2210
2249
|
}
|
|
@@ -2249,7 +2288,7 @@ function compileGitignore(lines) {
|
|
|
2249
2288
|
async function loadGitignoreMatcher(projectRoot) {
|
|
2250
2289
|
let lines = [];
|
|
2251
2290
|
try {
|
|
2252
|
-
const raw = await
|
|
2291
|
+
const raw = await fs5.readFile(path6.join(projectRoot, ".gitignore"), "utf8");
|
|
2253
2292
|
lines = raw.split("\n");
|
|
2254
2293
|
} catch {
|
|
2255
2294
|
}
|
|
@@ -2287,16 +2326,16 @@ async function findSourceFiles(projectRoot, ignore, isGitIgnored, signal) {
|
|
|
2287
2326
|
const results = [];
|
|
2288
2327
|
const ignoreSet = /* @__PURE__ */ new Set([...DEFAULT_IGNORE, ...ignore]);
|
|
2289
2328
|
const globs = [
|
|
2290
|
-
{ ext: ".ts", pat:
|
|
2291
|
-
{ ext: ".tsx", pat:
|
|
2292
|
-
{ ext: ".js", pat:
|
|
2293
|
-
{ ext: ".jsx", pat:
|
|
2294
|
-
{ ext: ".go", pat:
|
|
2295
|
-
{ ext: ".py", pat:
|
|
2296
|
-
{ ext: ".rs", pat:
|
|
2297
|
-
{ ext: ".json", pat:
|
|
2298
|
-
{ ext: ".yaml", pat:
|
|
2299
|
-
{ ext: ".yml", pat:
|
|
2329
|
+
{ ext: ".ts", pat: compileGlob2("**/*.ts") },
|
|
2330
|
+
{ ext: ".tsx", pat: compileGlob2("**/*.tsx") },
|
|
2331
|
+
{ ext: ".js", pat: compileGlob2("**/*.js") },
|
|
2332
|
+
{ ext: ".jsx", pat: compileGlob2("**/*.jsx") },
|
|
2333
|
+
{ ext: ".go", pat: compileGlob2("**/*.go") },
|
|
2334
|
+
{ ext: ".py", pat: compileGlob2("**/*.py") },
|
|
2335
|
+
{ ext: ".rs", pat: compileGlob2("**/*.rs") },
|
|
2336
|
+
{ ext: ".json", pat: compileGlob2("**/*.json") },
|
|
2337
|
+
{ ext: ".yaml", pat: compileGlob2("**/*.yaml") },
|
|
2338
|
+
{ ext: ".yml", pat: compileGlob2("**/*.yml") }
|
|
2300
2339
|
];
|
|
2301
2340
|
let dirCount = 0;
|
|
2302
2341
|
const walk = async (dir) => {
|
|
@@ -2307,21 +2346,21 @@ async function findSourceFiles(projectRoot, ignore, isGitIgnored, signal) {
|
|
|
2307
2346
|
}
|
|
2308
2347
|
let entries;
|
|
2309
2348
|
try {
|
|
2310
|
-
entries = await
|
|
2349
|
+
entries = await fs6.readdir(dir, { withFileTypes: true });
|
|
2311
2350
|
} catch {
|
|
2312
2351
|
return;
|
|
2313
2352
|
}
|
|
2314
2353
|
dirCount++;
|
|
2315
2354
|
for (const e of entries) {
|
|
2316
2355
|
if (ignoreSet.has(e.name)) continue;
|
|
2317
|
-
const full =
|
|
2318
|
-
const rel =
|
|
2356
|
+
const full = path7.join(dir, e.name);
|
|
2357
|
+
const rel = path7.relative(projectRoot, full).replace(/\\/g, "/");
|
|
2319
2358
|
if (e.isDirectory()) {
|
|
2320
2359
|
if (isGitIgnored(rel, true)) continue;
|
|
2321
2360
|
await walk(full);
|
|
2322
2361
|
} else if (e.isFile()) {
|
|
2323
2362
|
if (isGitIgnored(rel, false)) continue;
|
|
2324
|
-
const ext =
|
|
2363
|
+
const ext = path7.extname(e.name);
|
|
2325
2364
|
for (const { ext: extName, pat } of globs) {
|
|
2326
2365
|
if (ext === extName && (pat.test(rel) || pat.test(e.name))) {
|
|
2327
2366
|
results.push(full);
|
|
@@ -2377,7 +2416,7 @@ async function runIndexerWithStore(store, opts) {
|
|
|
2377
2416
|
let files;
|
|
2378
2417
|
let discoveredFiles = null;
|
|
2379
2418
|
if (opts.files && opts.files.length > 0) {
|
|
2380
|
-
files = opts.files.map((f) =>
|
|
2419
|
+
files = opts.files.map((f) => path7.resolve(projectRoot, f)).filter((f) => !isGitIgnored(path7.relative(projectRoot, f).replace(/\\/g, "/"), false));
|
|
2381
2420
|
} else {
|
|
2382
2421
|
files = await findSourceFiles(projectRoot, ignore, isGitIgnored, signal);
|
|
2383
2422
|
discoveredFiles = new Set(files);
|
|
@@ -2407,7 +2446,7 @@ async function runIndexerWithStore(store, opts) {
|
|
|
2407
2446
|
batchFiles.map(async (file) => {
|
|
2408
2447
|
let stat2;
|
|
2409
2448
|
try {
|
|
2410
|
-
stat2 = await
|
|
2449
|
+
stat2 = await fs6.stat(file, statOpts);
|
|
2411
2450
|
} catch (e) {
|
|
2412
2451
|
if (isAbortError(e)) throw e;
|
|
2413
2452
|
return { file, stat: null, lang: "", parsed: null, error: `stat error: ${e instanceof Error ? e.message : String(e)}` };
|
|
@@ -2421,7 +2460,7 @@ async function runIndexerWithStore(store, opts) {
|
|
|
2421
2460
|
}
|
|
2422
2461
|
let content;
|
|
2423
2462
|
try {
|
|
2424
|
-
content = await
|
|
2463
|
+
content = await fs6.readFile(file, { encoding: "utf8", signal });
|
|
2425
2464
|
} catch (e) {
|
|
2426
2465
|
if (isAbortError(e)) throw e;
|
|
2427
2466
|
return { file, stat: stat2, lang, parsed: null, error: `read error: ${e instanceof Error ? e.message : String(e)}` };
|
|
@@ -2439,7 +2478,7 @@ async function runIndexerWithStore(store, opts) {
|
|
|
2439
2478
|
const deleteForFiles = [];
|
|
2440
2479
|
for (let fi = 0; fi < statReadParse.length; fi++) {
|
|
2441
2480
|
const settled = statReadParse[fi];
|
|
2442
|
-
const file =
|
|
2481
|
+
const file = expectDefined5(batchFiles[fi]);
|
|
2443
2482
|
if (settled.status === "rejected") {
|
|
2444
2483
|
const err = settled.reason;
|
|
2445
2484
|
if (err instanceof Error && isAbortError(err)) throw err;
|
|
@@ -2690,4 +2729,3 @@ port.on("message", (msg) => {
|
|
|
2690
2729
|
);
|
|
2691
2730
|
});
|
|
2692
2731
|
//# sourceMappingURL=worker.js.map
|
|
2693
|
-
//# sourceMappingURL=worker.js.map
|