@wrongstack/tools 0.286.0 → 0.287.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/README.md +2 -2
- package/dist/_edit-match.d.ts.map +1 -1
- package/dist/batch-tool-use.d.ts +1 -1
- package/dist/batch-tool-use.d.ts.map +1 -1
- package/dist/batch-tool-use.js +26 -8
- package/dist/batch-tool-use.js.map +2 -2
- package/dist/browser/index.js +1 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/types.d.ts +1 -1
- package/dist/browser/types.d.ts.map +1 -1
- package/dist/builtin.js +544 -118
- package/dist/builtin.js.map +4 -4
- package/dist/codebase-index/go-parser.d.ts.map +1 -1
- package/dist/codebase-index/index.js +190 -96
- package/dist/codebase-index/index.js.map +4 -4
- package/dist/codebase-index/py-parser.d.ts.map +1 -1
- package/dist/codebase-index/rs-parser.d.ts.map +1 -1
- package/dist/codebase-index/worker.js +188 -94
- package/dist/codebase-index/worker.js.map +4 -4
- package/dist/edit.d.ts.map +1 -1
- package/dist/edit.js +36 -12
- package/dist/edit.js.map +3 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +818 -125
- package/dist/index.js.map +4 -4
- package/dist/kanban.d.ts +7 -2
- package/dist/kanban.d.ts.map +1 -1
- package/dist/kanban.js +158 -19
- package/dist/kanban.js.map +4 -4
- package/dist/next-steps.d.ts +6 -2
- package/dist/next-steps.d.ts.map +1 -1
- package/dist/next-steps.js +3 -3
- package/dist/next-steps.js.map +2 -2
- package/dist/pack.js +544 -118
- package/dist/pack.js.map +4 -4
- package/dist/plan.d.ts.map +1 -1
- package/dist/plan.js +154 -4
- package/dist/plan.js.map +4 -4
- package/dist/session-kanban.d.ts +38 -0
- package/dist/session-kanban.d.ts.map +1 -0
- package/dist/session-kanban.js +489 -0
- package/dist/session-kanban.js.map +7 -0
- package/dist/task.d.ts.map +1 -1
- package/dist/task.js +163 -4
- package/dist/task.js.map +4 -4
- package/dist/todo.d.ts.map +1 -1
- package/dist/todo.js +155 -7
- package/dist/todo.js.map +4 -4
- package/dist/tool-icon-map.d.ts.map +1 -1
- package/dist/tool-icons.d.ts.map +1 -1
- package/dist/tool-icons.js +7 -1
- package/dist/tool-icons.js.map +2 -2
- package/package.json +7 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"py-parser.d.ts","sourceRoot":"","sources":["../../src/codebase-index/py-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"py-parser.d.ts","sourceRoot":"","sources":["../../src/codebase-index/py-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,KAAK,EAAE,WAAW,EAAyB,UAAU,EAAE,MAAM,aAAa,CAAC;AAIlF,wBAAsB,YAAY,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CASlH;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rs-parser.d.ts","sourceRoot":"","sources":["../../src/codebase-index/rs-parser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"rs-parser.d.ts","sourceRoot":"","sources":["../../src/codebase-index/rs-parser.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,WAAW,EAAyB,UAAU,EAAE,MAAM,aAAa,CAAC;AAGlF,wBAAsB,YAAY,CAAC,IAAI,EAAE;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,UAAU,CAAC;CAClB,GAAG,OAAO,CAAC,WAAW,CAAC,CAWvB;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -3,8 +3,8 @@ import { parentPort } from "node:worker_threads";
|
|
|
3
3
|
|
|
4
4
|
// src/codebase-index/indexer.ts
|
|
5
5
|
import { expectDefined as expectDefined5 } from "@wrongstack/core";
|
|
6
|
-
import * as
|
|
7
|
-
import * as
|
|
6
|
+
import * as fs7 from "node:fs/promises";
|
|
7
|
+
import * as path8 from "node:path";
|
|
8
8
|
import { compileGlob as compileGlob2 } from "@wrongstack/core";
|
|
9
9
|
|
|
10
10
|
// src/codebase-index/writer.ts
|
|
@@ -1116,8 +1116,34 @@ function detectLang(file) {
|
|
|
1116
1116
|
// src/codebase-index/go-parser.ts
|
|
1117
1117
|
import { spawn } from "node:child_process";
|
|
1118
1118
|
import * as os from "node:os";
|
|
1119
|
+
import * as path3 from "node:path";
|
|
1120
|
+
import * as fs3 from "node:fs/promises";
|
|
1121
|
+
|
|
1122
|
+
// src/_win32-resolve.ts
|
|
1123
|
+
import * as fs2 from "node:fs";
|
|
1119
1124
|
import * as path2 from "node:path";
|
|
1120
|
-
|
|
1125
|
+
function resolveWin32Command(cmd) {
|
|
1126
|
+
if (process.platform !== "win32") return cmd;
|
|
1127
|
+
if (cmd.includes("/") || cmd.includes("\\") || path2.extname(cmd.replace(/\//g, "\\"))) {
|
|
1128
|
+
return cmd;
|
|
1129
|
+
}
|
|
1130
|
+
const pathext = (process.env["PATHEXT"] ?? ".COM;.EXE;.BAT;.CMD;.VBS;.JS;.WS;.MSC").toLowerCase().split(";");
|
|
1131
|
+
const pathDirs = (process.env["PATH"] ?? "").split(path2.delimiter);
|
|
1132
|
+
for (const dir of pathDirs) {
|
|
1133
|
+
const base = path2.join(dir, cmd);
|
|
1134
|
+
for (const ext of pathext) {
|
|
1135
|
+
const full = `${base}${ext}`;
|
|
1136
|
+
try {
|
|
1137
|
+
fs2.accessSync(full, fs2.constants.X_OK);
|
|
1138
|
+
return full;
|
|
1139
|
+
} catch {
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
return cmd;
|
|
1144
|
+
}
|
|
1145
|
+
|
|
1146
|
+
// src/codebase-index/go-parser.ts
|
|
1121
1147
|
async function parseSymbols2(opts) {
|
|
1122
1148
|
const { file, content, lang } = opts;
|
|
1123
1149
|
try {
|
|
@@ -1418,31 +1444,46 @@ func formatType(t ast.Expr) string {
|
|
|
1418
1444
|
}
|
|
1419
1445
|
`;
|
|
1420
1446
|
async function syncGoParse(filePath, content, lang) {
|
|
1421
|
-
const tmpDir = await
|
|
1447
|
+
const tmpDir = await fs3.mkdtemp(path3.join(os.tmpdir(), "ws-go-parse-"));
|
|
1422
1448
|
try {
|
|
1423
|
-
const scriptPath =
|
|
1424
|
-
await
|
|
1425
|
-
const
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1449
|
+
const scriptPath = path3.join(tmpDir, "parse.go");
|
|
1450
|
+
await fs3.writeFile(scriptPath, GO_PARSE_SCRIPT, "utf8");
|
|
1451
|
+
const goBinary = resolveWin32Command("go");
|
|
1452
|
+
const goResult = await new Promise(
|
|
1453
|
+
(resolve2, reject) => {
|
|
1454
|
+
let settled = false;
|
|
1455
|
+
const proc = spawn(goBinary, ["run", scriptPath], {
|
|
1456
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
1457
|
+
windowsHide: true
|
|
1458
|
+
});
|
|
1459
|
+
proc.on("error", (err) => {
|
|
1460
|
+
if (settled) return;
|
|
1461
|
+
settled = true;
|
|
1462
|
+
reject(err);
|
|
1463
|
+
});
|
|
1464
|
+
let stdout2 = "";
|
|
1465
|
+
proc.stdout?.on("data", (chunk) => {
|
|
1466
|
+
stdout2 += chunk.toString();
|
|
1467
|
+
});
|
|
1468
|
+
proc.stderr?.resume();
|
|
1469
|
+
proc.stdin?.write(content);
|
|
1470
|
+
proc.stdin?.end();
|
|
1471
|
+
const timer = setTimeout(() => {
|
|
1472
|
+
if (settled) return;
|
|
1473
|
+
settled = true;
|
|
1441
1474
|
proc.kill("SIGKILL");
|
|
1442
1475
|
reject(new Error("timeout"));
|
|
1443
|
-
}, 15e3)
|
|
1444
|
-
|
|
1445
|
-
|
|
1476
|
+
}, 15e3);
|
|
1477
|
+
timer.unref?.();
|
|
1478
|
+
proc.on("close", (code2) => {
|
|
1479
|
+
if (settled) return;
|
|
1480
|
+
settled = true;
|
|
1481
|
+
clearTimeout(timer);
|
|
1482
|
+
resolve2({ code: code2, stdout: stdout2 });
|
|
1483
|
+
});
|
|
1484
|
+
}
|
|
1485
|
+
);
|
|
1486
|
+
const { code, stdout } = goResult;
|
|
1446
1487
|
if (code !== 0 || !stdout.trim()) {
|
|
1447
1488
|
return { file: filePath, lang, symbols: [], mtimeMs: Date.now() };
|
|
1448
1489
|
}
|
|
@@ -1464,15 +1505,15 @@ async function syncGoParse(filePath, content, lang) {
|
|
|
1464
1505
|
} catch {
|
|
1465
1506
|
return { file: filePath, lang, symbols: [], mtimeMs: Date.now() };
|
|
1466
1507
|
} finally {
|
|
1467
|
-
await
|
|
1508
|
+
await fs3.rm(tmpDir, { recursive: true, force: true });
|
|
1468
1509
|
}
|
|
1469
1510
|
}
|
|
1470
1511
|
|
|
1471
1512
|
// src/codebase-index/py-parser.ts
|
|
1472
|
-
import { spawn as spawn2 } from "node:child_process";
|
|
1473
|
-
import * as
|
|
1513
|
+
import { spawn as spawn2, spawnSync } from "node:child_process";
|
|
1514
|
+
import * as fs4 from "node:fs/promises";
|
|
1474
1515
|
import * as os2 from "node:os";
|
|
1475
|
-
import * as
|
|
1516
|
+
import * as path4 from "node:path";
|
|
1476
1517
|
async function parseSymbols3(opts) {
|
|
1477
1518
|
const { file, content, lang } = opts;
|
|
1478
1519
|
try {
|
|
@@ -1684,36 +1725,74 @@ visitor.visit(tree)
|
|
|
1684
1725
|
|
|
1685
1726
|
print(json.dumps([s.to_dict() for s in syms]))
|
|
1686
1727
|
`;
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1728
|
+
function resolvePython() {
|
|
1729
|
+
const candidates = process.platform === "win32" ? ["python3", "python", "py"] : ["python3", "python"];
|
|
1730
|
+
for (const name of candidates) {
|
|
1731
|
+
const resolved = resolveWin32Command(name);
|
|
1732
|
+
const result = spawnSync(resolved, ["--version"], {
|
|
1733
|
+
stdio: "pipe",
|
|
1734
|
+
timeout: 5e3
|
|
1735
|
+
});
|
|
1736
|
+
if (result.error) continue;
|
|
1737
|
+
if (result.status !== 0) continue;
|
|
1738
|
+
return resolved;
|
|
1739
|
+
}
|
|
1740
|
+
return null;
|
|
1741
|
+
}
|
|
1742
|
+
function spawnPyParser(pyBinary, scriptPath, filePath, content) {
|
|
1743
|
+
return new Promise((resolve2, reject) => {
|
|
1744
|
+
let settled = false;
|
|
1745
|
+
const proc = spawn2(pyBinary, [scriptPath, filePath], {
|
|
1697
1746
|
stdio: ["pipe", "pipe", "pipe"],
|
|
1698
1747
|
windowsHide: true
|
|
1699
1748
|
});
|
|
1749
|
+
proc.on("error", (err) => {
|
|
1750
|
+
if (settled) return;
|
|
1751
|
+
settled = true;
|
|
1752
|
+
reject(err);
|
|
1753
|
+
});
|
|
1700
1754
|
proc.stdin?.write(content);
|
|
1701
1755
|
proc.stdin?.end();
|
|
1702
1756
|
let stdout = "";
|
|
1703
1757
|
proc.stdout?.on("data", (chunk) => {
|
|
1704
1758
|
stdout += chunk.toString();
|
|
1705
1759
|
});
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
)
|
|
1716
|
-
|
|
1760
|
+
proc.stderr?.resume();
|
|
1761
|
+
const timer = setTimeout(() => {
|
|
1762
|
+
if (settled) return;
|
|
1763
|
+
settled = true;
|
|
1764
|
+
proc.kill("SIGKILL");
|
|
1765
|
+
reject(new Error("timeout"));
|
|
1766
|
+
}, 15e3);
|
|
1767
|
+
timer.unref?.();
|
|
1768
|
+
proc.on("close", (code) => {
|
|
1769
|
+
if (settled) return;
|
|
1770
|
+
settled = true;
|
|
1771
|
+
clearTimeout(timer);
|
|
1772
|
+
resolve2({ code, stdout });
|
|
1773
|
+
});
|
|
1774
|
+
});
|
|
1775
|
+
}
|
|
1776
|
+
var _cachedScriptPath = null;
|
|
1777
|
+
var _cachedPyBinary = null;
|
|
1778
|
+
async function syncPyParse(filePath, content, lang) {
|
|
1779
|
+
try {
|
|
1780
|
+
if (!_cachedScriptPath) {
|
|
1781
|
+
const tmpDir = path4.join(os2.tmpdir(), "ws-py-parse");
|
|
1782
|
+
await fs4.mkdir(tmpDir, { recursive: true });
|
|
1783
|
+
_cachedScriptPath = path4.join(tmpDir, "parse.py");
|
|
1784
|
+
await fs4.writeFile(_cachedScriptPath, PY_PARSE_SCRIPT, "utf8");
|
|
1785
|
+
}
|
|
1786
|
+
if (!_cachedPyBinary) {
|
|
1787
|
+
_cachedPyBinary = resolvePython();
|
|
1788
|
+
if (!_cachedPyBinary) return { file: filePath, lang, symbols: [], mtimeMs: Date.now() };
|
|
1789
|
+
}
|
|
1790
|
+
const { code, stdout } = await spawnPyParser(
|
|
1791
|
+
_cachedPyBinary,
|
|
1792
|
+
_cachedScriptPath,
|
|
1793
|
+
filePath,
|
|
1794
|
+
content
|
|
1795
|
+
);
|
|
1717
1796
|
if (code !== 0 || !stdout.trim()) {
|
|
1718
1797
|
return { file: filePath, lang, symbols: [], mtimeMs: Date.now() };
|
|
1719
1798
|
}
|
|
@@ -1740,8 +1819,8 @@ async function syncPyParse(filePath, content, lang) {
|
|
|
1740
1819
|
// src/codebase-index/rs-parser.ts
|
|
1741
1820
|
import { expectDefined as expectDefined2 } from "@wrongstack/core";
|
|
1742
1821
|
import { execFileSync, spawn as spawn3 } from "node:child_process";
|
|
1743
|
-
import * as
|
|
1744
|
-
import * as
|
|
1822
|
+
import * as fs5 from "node:fs/promises";
|
|
1823
|
+
import * as path5 from "node:path";
|
|
1745
1824
|
async function parseSymbols4(opts) {
|
|
1746
1825
|
const { file, content, lang } = opts;
|
|
1747
1826
|
const nativeAvailable = checkNativeParser();
|
|
@@ -1754,7 +1833,7 @@ async function parseSymbols4(opts) {
|
|
|
1754
1833
|
function checkNativeParser() {
|
|
1755
1834
|
try {
|
|
1756
1835
|
execFileSync("rustc", ["--version"], { stdio: "pipe", windowsHide: true });
|
|
1757
|
-
const toolsDir =
|
|
1836
|
+
const toolsDir = path5.join(process.cwd(), "tools");
|
|
1758
1837
|
try {
|
|
1759
1838
|
execFileSync(
|
|
1760
1839
|
"cargo",
|
|
@@ -1764,7 +1843,7 @@ function checkNativeParser() {
|
|
|
1764
1843
|
"--format-version",
|
|
1765
1844
|
"1",
|
|
1766
1845
|
"--manifest-path",
|
|
1767
|
-
|
|
1846
|
+
path5.join(toolsDir, "Cargo.toml")
|
|
1768
1847
|
],
|
|
1769
1848
|
{ stdio: "pipe", windowsHide: true }
|
|
1770
1849
|
);
|
|
@@ -1778,34 +1857,49 @@ function checkNativeParser() {
|
|
|
1778
1857
|
}
|
|
1779
1858
|
async function tryNativeParse(file, content) {
|
|
1780
1859
|
try {
|
|
1781
|
-
const toolsDir =
|
|
1782
|
-
const crateDir =
|
|
1783
|
-
const tmpFile =
|
|
1784
|
-
await
|
|
1785
|
-
const
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1860
|
+
const toolsDir = path5.join(process.cwd(), "tools");
|
|
1861
|
+
const crateDir = path5.join(toolsDir, "syn-parser");
|
|
1862
|
+
const tmpFile = path5.join(crateDir, "src", "input.rs");
|
|
1863
|
+
await fs5.writeFile(tmpFile, content, "utf8");
|
|
1864
|
+
const cargoBinary = resolveWin32Command("cargo");
|
|
1865
|
+
const result = await new Promise(
|
|
1866
|
+
(resolve2, reject) => {
|
|
1867
|
+
let settled = false;
|
|
1868
|
+
const proc = spawn3(
|
|
1869
|
+
cargoBinary,
|
|
1870
|
+
["run", "--manifest-path", path5.join(toolsDir, "Cargo.toml")],
|
|
1871
|
+
{
|
|
1872
|
+
cwd: process.cwd(),
|
|
1873
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
1874
|
+
windowsHide: true
|
|
1875
|
+
}
|
|
1876
|
+
);
|
|
1877
|
+
proc.on("error", (err) => {
|
|
1878
|
+
if (settled) return;
|
|
1879
|
+
settled = true;
|
|
1880
|
+
reject(err);
|
|
1881
|
+
});
|
|
1882
|
+
let stdout2 = "";
|
|
1883
|
+
proc.stdout?.on("data", (chunk) => {
|
|
1884
|
+
stdout2 += chunk.toString();
|
|
1885
|
+
});
|
|
1886
|
+
proc.stderr?.resume();
|
|
1887
|
+
const timer = setTimeout(() => {
|
|
1888
|
+
if (settled) return;
|
|
1889
|
+
settled = true;
|
|
1804
1890
|
proc.kill("SIGKILL");
|
|
1805
1891
|
reject(new Error("timeout"));
|
|
1806
|
-
}, 15e3)
|
|
1807
|
-
|
|
1808
|
-
|
|
1892
|
+
}, 15e3);
|
|
1893
|
+
timer.unref?.();
|
|
1894
|
+
proc.on("close", (c) => {
|
|
1895
|
+
if (settled) return;
|
|
1896
|
+
settled = true;
|
|
1897
|
+
clearTimeout(timer);
|
|
1898
|
+
resolve2({ code: c, stdout: stdout2 });
|
|
1899
|
+
});
|
|
1900
|
+
}
|
|
1901
|
+
);
|
|
1902
|
+
const { code, stdout } = result;
|
|
1809
1903
|
if (code === 0 && stdout.trim()) {
|
|
1810
1904
|
const symbols = JSON.parse(stdout.trim());
|
|
1811
1905
|
return {
|
|
@@ -1888,7 +1982,7 @@ function regexParse(opts) {
|
|
|
1888
1982
|
|
|
1889
1983
|
// src/codebase-index/json-parser.ts
|
|
1890
1984
|
import { expectDefined as expectDefined3 } from "@wrongstack/core";
|
|
1891
|
-
import * as
|
|
1985
|
+
import * as path6 from "node:path";
|
|
1892
1986
|
function parseSymbols5(opts) {
|
|
1893
1987
|
const { file, content, lang } = opts;
|
|
1894
1988
|
try {
|
|
@@ -1900,7 +1994,7 @@ function parseSymbols5(opts) {
|
|
|
1900
1994
|
function regexParse2(opts) {
|
|
1901
1995
|
const { file, content, lang } = opts;
|
|
1902
1996
|
const symbols = [];
|
|
1903
|
-
const basename2 =
|
|
1997
|
+
const basename2 = path6.basename(file).toLowerCase();
|
|
1904
1998
|
const isPackageJson = basename2 === "package.json";
|
|
1905
1999
|
const isTsconfig = basename2 === "tsconfig.json" || basename2 === "tsconfig.build.json";
|
|
1906
2000
|
const isJsonSchema = content.includes("$schema") || content.includes("$id") || content.includes("$ref");
|
|
@@ -1926,11 +2020,11 @@ function regexParse2(opts) {
|
|
|
1926
2020
|
const line = lineFromOffset(offset);
|
|
1927
2021
|
symbols.push(
|
|
1928
2022
|
makeSymbol({
|
|
1929
|
-
name:
|
|
2023
|
+
name: path6.basename(file),
|
|
1930
2024
|
kind: "object",
|
|
1931
2025
|
line,
|
|
1932
2026
|
col: 0,
|
|
1933
|
-
signature: `"${
|
|
2027
|
+
signature: `"${path6.basename(file)}" = { ... }`,
|
|
1934
2028
|
file,
|
|
1935
2029
|
lang
|
|
1936
2030
|
})
|
|
@@ -2241,8 +2335,8 @@ function makeSymbol2(opts) {
|
|
|
2241
2335
|
}
|
|
2242
2336
|
|
|
2243
2337
|
// src/codebase-index/gitignore.ts
|
|
2244
|
-
import * as
|
|
2245
|
-
import * as
|
|
2338
|
+
import * as fs6 from "node:fs/promises";
|
|
2339
|
+
import * as path7 from "node:path";
|
|
2246
2340
|
import { compileGlob } from "@wrongstack/core";
|
|
2247
2341
|
function globBody(glob) {
|
|
2248
2342
|
return compileGlob(glob).source.replace(/^\^/, "").replace(/\$$/, "");
|
|
@@ -2288,7 +2382,7 @@ function compileGitignore(lines) {
|
|
|
2288
2382
|
async function loadGitignoreMatcher(projectRoot) {
|
|
2289
2383
|
let lines = [];
|
|
2290
2384
|
try {
|
|
2291
|
-
const raw = await
|
|
2385
|
+
const raw = await fs6.readFile(path7.join(projectRoot, ".gitignore"), "utf8");
|
|
2292
2386
|
lines = raw.split("\n");
|
|
2293
2387
|
} catch {
|
|
2294
2388
|
}
|
|
@@ -2346,21 +2440,21 @@ async function findSourceFiles(projectRoot, ignore, isGitIgnored, signal) {
|
|
|
2346
2440
|
}
|
|
2347
2441
|
let entries;
|
|
2348
2442
|
try {
|
|
2349
|
-
entries = await
|
|
2443
|
+
entries = await fs7.readdir(dir, { withFileTypes: true });
|
|
2350
2444
|
} catch {
|
|
2351
2445
|
return;
|
|
2352
2446
|
}
|
|
2353
2447
|
dirCount++;
|
|
2354
2448
|
for (const e of entries) {
|
|
2355
2449
|
if (ignoreSet.has(e.name)) continue;
|
|
2356
|
-
const full =
|
|
2357
|
-
const rel =
|
|
2450
|
+
const full = path8.join(dir, e.name);
|
|
2451
|
+
const rel = path8.relative(projectRoot, full).replace(/\\/g, "/");
|
|
2358
2452
|
if (e.isDirectory()) {
|
|
2359
2453
|
if (isGitIgnored(rel, true)) continue;
|
|
2360
2454
|
await walk(full);
|
|
2361
2455
|
} else if (e.isFile()) {
|
|
2362
2456
|
if (isGitIgnored(rel, false)) continue;
|
|
2363
|
-
const ext =
|
|
2457
|
+
const ext = path8.extname(e.name);
|
|
2364
2458
|
for (const { ext: extName, pat } of globs) {
|
|
2365
2459
|
if (ext === extName && (pat.test(rel) || pat.test(e.name))) {
|
|
2366
2460
|
results.push(full);
|
|
@@ -2416,7 +2510,7 @@ async function runIndexerWithStore(store, opts) {
|
|
|
2416
2510
|
let files;
|
|
2417
2511
|
let discoveredFiles = null;
|
|
2418
2512
|
if (opts.files && opts.files.length > 0) {
|
|
2419
|
-
files = opts.files.map((f) =>
|
|
2513
|
+
files = opts.files.map((f) => path8.resolve(projectRoot, f)).filter((f) => !isGitIgnored(path8.relative(projectRoot, f).replace(/\\/g, "/"), false));
|
|
2420
2514
|
} else {
|
|
2421
2515
|
files = await findSourceFiles(projectRoot, ignore, isGitIgnored, signal);
|
|
2422
2516
|
discoveredFiles = new Set(files);
|
|
@@ -2446,7 +2540,7 @@ async function runIndexerWithStore(store, opts) {
|
|
|
2446
2540
|
batchFiles.map(async (file) => {
|
|
2447
2541
|
let stat2;
|
|
2448
2542
|
try {
|
|
2449
|
-
stat2 = await
|
|
2543
|
+
stat2 = await fs7.stat(file, statOpts);
|
|
2450
2544
|
} catch (e) {
|
|
2451
2545
|
if (isAbortError(e)) throw e;
|
|
2452
2546
|
return { file, stat: null, lang: "", parsed: null, error: `stat error: ${e instanceof Error ? e.message : String(e)}` };
|
|
@@ -2460,7 +2554,7 @@ async function runIndexerWithStore(store, opts) {
|
|
|
2460
2554
|
}
|
|
2461
2555
|
let content;
|
|
2462
2556
|
try {
|
|
2463
|
-
content = await
|
|
2557
|
+
content = await fs7.readFile(file, { encoding: "utf8", signal });
|
|
2464
2558
|
} catch (e) {
|
|
2465
2559
|
if (isAbortError(e)) throw e;
|
|
2466
2560
|
return { file, stat: stat2, lang, parsed: null, error: `read error: ${e instanceof Error ? e.message : String(e)}` };
|