@wrongstack/tools 0.273.1 → 0.274.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/builtin.js +166 -70
- package/dist/builtin.js.map +1 -1
- package/dist/codebase-index/index.js +24 -16
- package/dist/codebase-index/index.js.map +1 -1
- package/dist/codebase-index/worker.js +24 -16
- package/dist/codebase-index/worker.js.map +1 -1
- package/dist/glob.js +61 -11
- package/dist/glob.js.map +1 -1
- package/dist/grep.js +92 -39
- package/dist/grep.js.map +1 -1
- package/dist/index.js +166 -70
- package/dist/index.js.map +1 -1
- package/dist/pack.js +166 -70
- package/dist/pack.js.map +1 -1
- package/package.json +2 -2
|
@@ -405,6 +405,8 @@ var IndexStore = class {
|
|
|
405
405
|
this.db.exec("CREATE INDEX IF NOT EXISTS idx_s_kind ON symbols(kind)");
|
|
406
406
|
this.db.exec("CREATE INDEX IF NOT EXISTS idx_s_lang ON symbols(lang)");
|
|
407
407
|
this.db.exec("CREATE INDEX IF NOT EXISTS idx_s_file ON symbols(file)");
|
|
408
|
+
this.db.exec("CREATE INDEX IF NOT EXISTS idx_s_lang_kind ON symbols(lang, kind)");
|
|
409
|
+
this.db.exec("CREATE INDEX IF NOT EXISTS idx_s_file_fk ON symbols(file_fk)");
|
|
408
410
|
this.db.exec(`
|
|
409
411
|
CREATE TABLE IF NOT EXISTS refs (
|
|
410
412
|
id INTEGER PRIMARY KEY,
|
|
@@ -1317,9 +1319,9 @@ async function syncGoParse(filePath, content, lang) {
|
|
|
1317
1319
|
}
|
|
1318
1320
|
}
|
|
1319
1321
|
async function parseSymbols3(opts) {
|
|
1320
|
-
const { file, lang } = opts;
|
|
1322
|
+
const { file, content, lang } = opts;
|
|
1321
1323
|
try {
|
|
1322
|
-
return await syncPyParse(file, lang);
|
|
1324
|
+
return await syncPyParse(file, content, lang);
|
|
1323
1325
|
} catch {
|
|
1324
1326
|
return { file, lang, symbols: [], mtimeMs: Date.now() };
|
|
1325
1327
|
}
|
|
@@ -1387,8 +1389,7 @@ syms = []
|
|
|
1387
1389
|
errors = []
|
|
1388
1390
|
|
|
1389
1391
|
try:
|
|
1390
|
-
|
|
1391
|
-
source = f.read()
|
|
1392
|
+
source = sys.stdin.read()
|
|
1392
1393
|
tree = ast.parse(source, filename=sys.argv[1])
|
|
1393
1394
|
except Exception as e:
|
|
1394
1395
|
errors.append(str(e))
|
|
@@ -1528,16 +1529,21 @@ visitor.visit(tree)
|
|
|
1528
1529
|
|
|
1529
1530
|
print(json.dumps([s.to_dict() for s in syms]))
|
|
1530
1531
|
`;
|
|
1531
|
-
|
|
1532
|
+
var _cachedScriptPath = null;
|
|
1533
|
+
async function syncPyParse(filePath, content, lang) {
|
|
1532
1534
|
try {
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1535
|
+
if (!_cachedScriptPath) {
|
|
1536
|
+
const tmpDir = path4.join(os.tmpdir(), "ws-py-parse");
|
|
1537
|
+
await fs6.mkdir(tmpDir, { recursive: true });
|
|
1538
|
+
_cachedScriptPath = path4.join(tmpDir, "parse.py");
|
|
1539
|
+
await fs6.writeFile(_cachedScriptPath, PY_PARSE_SCRIPT, "utf8");
|
|
1540
|
+
}
|
|
1541
|
+
const proc = spawn("python", [_cachedScriptPath, filePath], {
|
|
1538
1542
|
stdio: ["pipe", "pipe", "pipe"],
|
|
1539
1543
|
windowsHide: true
|
|
1540
1544
|
});
|
|
1545
|
+
proc.stdin?.write(content);
|
|
1546
|
+
proc.stdin?.end();
|
|
1541
1547
|
let stdout = "";
|
|
1542
1548
|
proc.stdout?.on("data", (chunk) => {
|
|
1543
1549
|
stdout += chunk.toString();
|
|
@@ -2204,7 +2210,7 @@ async function parseFile(file, content, lang) {
|
|
|
2204
2210
|
case "go":
|
|
2205
2211
|
return parseSymbols2({ file, content, lang: "go" });
|
|
2206
2212
|
case "py":
|
|
2207
|
-
return parseSymbols3({ file, lang: "py" });
|
|
2213
|
+
return parseSymbols3({ file, content, lang: "py" });
|
|
2208
2214
|
case "rs":
|
|
2209
2215
|
return parseSymbols4({ file, content, lang: "rs" });
|
|
2210
2216
|
case "json":
|
|
@@ -2235,10 +2241,12 @@ async function runIndexerWithStore(store, opts) {
|
|
|
2235
2241
|
let symbolsIndexed = 0;
|
|
2236
2242
|
const isGitIgnored = await loadGitignoreMatcher(projectRoot);
|
|
2237
2243
|
let files;
|
|
2244
|
+
let discoveredFiles = null;
|
|
2238
2245
|
if (opts.files && opts.files.length > 0) {
|
|
2239
2246
|
files = opts.files.map((f) => path4.resolve(projectRoot, f)).filter((f) => !isGitIgnored(path4.relative(projectRoot, f).replace(/\\/g, "/"), false));
|
|
2240
2247
|
} else {
|
|
2241
2248
|
files = await findSourceFiles(projectRoot, ignore, isGitIgnored, signal);
|
|
2249
|
+
discoveredFiles = new Set(files);
|
|
2242
2250
|
}
|
|
2243
2251
|
if (langs && langs.length > 0) {
|
|
2244
2252
|
const langSet = new Set(langs);
|
|
@@ -2356,11 +2364,11 @@ async function runIndexerWithStore(store, opts) {
|
|
|
2356
2364
|
filesIndexed++;
|
|
2357
2365
|
}
|
|
2358
2366
|
}
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
|
|
2367
|
+
if (discoveredFiles) {
|
|
2368
|
+
for (const [file_] of existingMeta) {
|
|
2369
|
+
if (!discoveredFiles.has(file_)) {
|
|
2370
|
+
store.deleteFile(file_);
|
|
2371
|
+
}
|
|
2364
2372
|
}
|
|
2365
2373
|
}
|
|
2366
2374
|
const durationMs = Date.now() - startMs;
|