@wrongstack/tools 0.273.1 → 0.275.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.
Files changed (44) hide show
  1. package/dist/audit.js +57 -19
  2. package/dist/audit.js.map +1 -1
  3. package/dist/bash.js +166 -83
  4. package/dist/bash.js.map +1 -1
  5. package/dist/builtin.js +669 -189
  6. package/dist/builtin.js.map +1 -1
  7. package/dist/circuit-breaker.js +1 -0
  8. package/dist/circuit-breaker.js.map +1 -1
  9. package/dist/codebase-index/index.js +24 -16
  10. package/dist/codebase-index/index.js.map +1 -1
  11. package/dist/codebase-index/worker.js +24 -16
  12. package/dist/codebase-index/worker.js.map +1 -1
  13. package/dist/edit.js +1 -1
  14. package/dist/edit.js.map +1 -1
  15. package/dist/exec.js +136 -38
  16. package/dist/exec.js.map +1 -1
  17. package/dist/fetch.js +9 -1
  18. package/dist/fetch.js.map +1 -1
  19. package/dist/format.js +57 -19
  20. package/dist/format.js.map +1 -1
  21. package/dist/glob.js +61 -11
  22. package/dist/glob.js.map +1 -1
  23. package/dist/grep.js +92 -39
  24. package/dist/grep.js.map +1 -1
  25. package/dist/index.d.ts +37 -1
  26. package/dist/index.js +680 -200
  27. package/dist/index.js.map +1 -1
  28. package/dist/install.js +65 -19
  29. package/dist/install.js.map +1 -1
  30. package/dist/lint.js +57 -19
  31. package/dist/lint.js.map +1 -1
  32. package/dist/pack.js +667 -188
  33. package/dist/pack.js.map +1 -1
  34. package/dist/process-registry.d.ts +30 -0
  35. package/dist/process-registry.js +57 -19
  36. package/dist/process-registry.js.map +1 -1
  37. package/dist/search.js.map +1 -1
  38. package/dist/test.js +57 -19
  39. package/dist/test.js.map +1 -1
  40. package/dist/typecheck.js +57 -19
  41. package/dist/typecheck.js.map +1 -1
  42. package/dist/write.js +2 -2
  43. package/dist/write.js.map +1 -1
  44. package/package.json +2 -2
@@ -362,6 +362,8 @@ var IndexStore = class {
362
362
  this.db.exec("CREATE INDEX IF NOT EXISTS idx_s_kind ON symbols(kind)");
363
363
  this.db.exec("CREATE INDEX IF NOT EXISTS idx_s_lang ON symbols(lang)");
364
364
  this.db.exec("CREATE INDEX IF NOT EXISTS idx_s_file ON symbols(file)");
365
+ this.db.exec("CREATE INDEX IF NOT EXISTS idx_s_lang_kind ON symbols(lang, kind)");
366
+ this.db.exec("CREATE INDEX IF NOT EXISTS idx_s_file_fk ON symbols(file_fk)");
365
367
  this.db.exec(`
366
368
  CREATE TABLE IF NOT EXISTS refs (
367
369
  id INTEGER PRIMARY KEY,
@@ -1274,9 +1276,9 @@ async function syncGoParse(filePath, content, lang) {
1274
1276
  }
1275
1277
  }
1276
1278
  async function parseSymbols3(opts) {
1277
- const { file, lang } = opts;
1279
+ const { file, content, lang } = opts;
1278
1280
  try {
1279
- return await syncPyParse(file, lang);
1281
+ return await syncPyParse(file, content, lang);
1280
1282
  } catch {
1281
1283
  return { file, lang, symbols: [], mtimeMs: Date.now() };
1282
1284
  }
@@ -1344,8 +1346,7 @@ syms = []
1344
1346
  errors = []
1345
1347
 
1346
1348
  try:
1347
- with open(sys.argv[1], "r", encoding="utf-8") as f:
1348
- source = f.read()
1349
+ source = sys.stdin.read()
1349
1350
  tree = ast.parse(source, filename=sys.argv[1])
1350
1351
  except Exception as e:
1351
1352
  errors.append(str(e))
@@ -1485,16 +1486,21 @@ visitor.visit(tree)
1485
1486
 
1486
1487
  print(json.dumps([s.to_dict() for s in syms]))
1487
1488
  `;
1488
- async function syncPyParse(filePath, lang) {
1489
+ var _cachedScriptPath = null;
1490
+ async function syncPyParse(filePath, content, lang) {
1489
1491
  try {
1490
- const tmpDir = path4.join(os.tmpdir(), "ws-py-parse");
1491
- await fs6.mkdir(tmpDir, { recursive: true });
1492
- const scriptPath = path4.join(tmpDir, "parse.py");
1493
- await fs6.writeFile(scriptPath, PY_PARSE_SCRIPT, "utf8");
1494
- const proc = spawn("python", [scriptPath, filePath], {
1492
+ if (!_cachedScriptPath) {
1493
+ const tmpDir = path4.join(os.tmpdir(), "ws-py-parse");
1494
+ await fs6.mkdir(tmpDir, { recursive: true });
1495
+ _cachedScriptPath = path4.join(tmpDir, "parse.py");
1496
+ await fs6.writeFile(_cachedScriptPath, PY_PARSE_SCRIPT, "utf8");
1497
+ }
1498
+ const proc = spawn("python", [_cachedScriptPath, filePath], {
1495
1499
  stdio: ["pipe", "pipe", "pipe"],
1496
1500
  windowsHide: true
1497
1501
  });
1502
+ proc.stdin?.write(content);
1503
+ proc.stdin?.end();
1498
1504
  let stdout = "";
1499
1505
  proc.stdout?.on("data", (chunk) => {
1500
1506
  stdout += chunk.toString();
@@ -2161,7 +2167,7 @@ async function parseFile(file, content, lang) {
2161
2167
  case "go":
2162
2168
  return parseSymbols2({ file, content, lang: "go" });
2163
2169
  case "py":
2164
- return parseSymbols3({ file, lang: "py" });
2170
+ return parseSymbols3({ file, content, lang: "py" });
2165
2171
  case "rs":
2166
2172
  return parseSymbols4({ file, content, lang: "rs" });
2167
2173
  case "json":
@@ -2192,10 +2198,12 @@ async function runIndexerWithStore(store, opts) {
2192
2198
  let symbolsIndexed = 0;
2193
2199
  const isGitIgnored = await loadGitignoreMatcher(projectRoot);
2194
2200
  let files;
2201
+ let discoveredFiles = null;
2195
2202
  if (opts.files && opts.files.length > 0) {
2196
2203
  files = opts.files.map((f) => path4.resolve(projectRoot, f)).filter((f) => !isGitIgnored(path4.relative(projectRoot, f).replace(/\\/g, "/"), false));
2197
2204
  } else {
2198
2205
  files = await findSourceFiles(projectRoot, ignore, isGitIgnored, signal);
2206
+ discoveredFiles = new Set(files);
2199
2207
  }
2200
2208
  if (langs && langs.length > 0) {
2201
2209
  const langSet = new Set(langs);
@@ -2313,11 +2321,11 @@ async function runIndexerWithStore(store, opts) {
2313
2321
  filesIndexed++;
2314
2322
  }
2315
2323
  }
2316
- for (const [file_] of existingMeta) {
2317
- try {
2318
- await fs6.stat(file_);
2319
- } catch {
2320
- store.deleteFile(file_);
2324
+ if (discoveredFiles) {
2325
+ for (const [file_] of existingMeta) {
2326
+ if (!discoveredFiles.has(file_)) {
2327
+ store.deleteFile(file_);
2328
+ }
2321
2329
  }
2322
2330
  }
2323
2331
  const durationMs = Date.now() - startMs;