@wrongstack/tools 0.285.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 +21 -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/artifacts.d.ts +13 -0
- package/dist/browser/artifacts.d.ts.map +1 -0
- package/dist/browser/index.d.ts +7 -0
- package/dist/browser/index.d.ts.map +1 -0
- package/dist/browser/index.js +1264 -0
- package/dist/browser/index.js.map +7 -0
- package/dist/browser/manager.d.ts +57 -0
- package/dist/browser/manager.d.ts.map +1 -0
- package/dist/browser/network-guard-proxy.d.ts +23 -0
- package/dist/browser/network-guard-proxy.d.ts.map +1 -0
- package/dist/browser/security.d.ts +29 -0
- package/dist/browser/security.d.ts.map +1 -0
- package/dist/browser/tools.d.ts +62 -0
- package/dist/browser/tools.d.ts.map +1 -0
- package/dist/browser/types.d.ts +60 -0
- package/dist/browser/types.d.ts.map +1 -0
- package/dist/builtin.d.ts +4 -3
- package/dist/builtin.d.ts.map +1 -1
- package/dist/builtin.js +2609 -525
- 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/e2e.d.ts +56 -0
- package/dist/e2e.d.ts.map +1 -0
- package/dist/edit.d.ts.map +1 -1
- package/dist/edit.js +36 -12
- package/dist/edit.js.map +3 -3
- package/dist/exec.js +1 -1
- package/dist/exec.js.map +2 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2895 -511
- 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 +2625 -525
- 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/search.d.ts.map +1 -1
- package/dist/search.js +8 -2
- package/dist/search.js.map +2 -2
- 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 +2 -1
- 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 +12 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"go-parser.d.ts","sourceRoot":"","sources":["../../src/codebase-index/go-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;
|
|
1
|
+
{"version":3,"file":"go-parser.d.ts","sourceRoot":"","sources":["../../src/codebase-index/go-parser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAOH,OAAO,KAAK,EAAE,WAAW,EAAyB,UAAU,EAAE,MAAM,aAAa,CAAC;AAIlF,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,CAavB;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -960,14 +960,14 @@ var IndexStore = class {
|
|
|
960
960
|
};
|
|
961
961
|
|
|
962
962
|
// src/codebase-index/background-indexer.ts
|
|
963
|
-
import * as
|
|
963
|
+
import * as fs8 from "node:fs";
|
|
964
964
|
import { fileURLToPath } from "node:url";
|
|
965
965
|
import { Worker } from "node:worker_threads";
|
|
966
966
|
|
|
967
967
|
// src/codebase-index/indexer.ts
|
|
968
968
|
import { expectDefined as expectDefined5 } from "@wrongstack/core";
|
|
969
|
-
import * as
|
|
970
|
-
import * as
|
|
969
|
+
import * as fs7 from "node:fs/promises";
|
|
970
|
+
import * as path8 from "node:path";
|
|
971
971
|
import { compileGlob as compileGlob2 } from "@wrongstack/core";
|
|
972
972
|
|
|
973
973
|
// src/codebase-index/ts-parser.ts
|
|
@@ -1160,8 +1160,34 @@ function detectLang(file) {
|
|
|
1160
1160
|
// src/codebase-index/go-parser.ts
|
|
1161
1161
|
import { spawn } from "node:child_process";
|
|
1162
1162
|
import * as os from "node:os";
|
|
1163
|
+
import * as path3 from "node:path";
|
|
1164
|
+
import * as fs3 from "node:fs/promises";
|
|
1165
|
+
|
|
1166
|
+
// src/_win32-resolve.ts
|
|
1167
|
+
import * as fs2 from "node:fs";
|
|
1163
1168
|
import * as path2 from "node:path";
|
|
1164
|
-
|
|
1169
|
+
function resolveWin32Command(cmd) {
|
|
1170
|
+
if (process.platform !== "win32") return cmd;
|
|
1171
|
+
if (cmd.includes("/") || cmd.includes("\\") || path2.extname(cmd.replace(/\//g, "\\"))) {
|
|
1172
|
+
return cmd;
|
|
1173
|
+
}
|
|
1174
|
+
const pathext = (process.env["PATHEXT"] ?? ".COM;.EXE;.BAT;.CMD;.VBS;.JS;.WS;.MSC").toLowerCase().split(";");
|
|
1175
|
+
const pathDirs = (process.env["PATH"] ?? "").split(path2.delimiter);
|
|
1176
|
+
for (const dir of pathDirs) {
|
|
1177
|
+
const base = path2.join(dir, cmd);
|
|
1178
|
+
for (const ext of pathext) {
|
|
1179
|
+
const full = `${base}${ext}`;
|
|
1180
|
+
try {
|
|
1181
|
+
fs2.accessSync(full, fs2.constants.X_OK);
|
|
1182
|
+
return full;
|
|
1183
|
+
} catch {
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
return cmd;
|
|
1188
|
+
}
|
|
1189
|
+
|
|
1190
|
+
// src/codebase-index/go-parser.ts
|
|
1165
1191
|
async function parseSymbols2(opts) {
|
|
1166
1192
|
const { file, content, lang } = opts;
|
|
1167
1193
|
try {
|
|
@@ -1462,31 +1488,46 @@ func formatType(t ast.Expr) string {
|
|
|
1462
1488
|
}
|
|
1463
1489
|
`;
|
|
1464
1490
|
async function syncGoParse(filePath, content, lang) {
|
|
1465
|
-
const tmpDir = await
|
|
1491
|
+
const tmpDir = await fs3.mkdtemp(path3.join(os.tmpdir(), "ws-go-parse-"));
|
|
1466
1492
|
try {
|
|
1467
|
-
const scriptPath =
|
|
1468
|
-
await
|
|
1469
|
-
const
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1493
|
+
const scriptPath = path3.join(tmpDir, "parse.go");
|
|
1494
|
+
await fs3.writeFile(scriptPath, GO_PARSE_SCRIPT, "utf8");
|
|
1495
|
+
const goBinary = resolveWin32Command("go");
|
|
1496
|
+
const goResult = await new Promise(
|
|
1497
|
+
(resolve2, reject) => {
|
|
1498
|
+
let settled = false;
|
|
1499
|
+
const proc = spawn(goBinary, ["run", scriptPath], {
|
|
1500
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
1501
|
+
windowsHide: true
|
|
1502
|
+
});
|
|
1503
|
+
proc.on("error", (err) => {
|
|
1504
|
+
if (settled) return;
|
|
1505
|
+
settled = true;
|
|
1506
|
+
reject(err);
|
|
1507
|
+
});
|
|
1508
|
+
let stdout2 = "";
|
|
1509
|
+
proc.stdout?.on("data", (chunk) => {
|
|
1510
|
+
stdout2 += chunk.toString();
|
|
1511
|
+
});
|
|
1512
|
+
proc.stderr?.resume();
|
|
1513
|
+
proc.stdin?.write(content);
|
|
1514
|
+
proc.stdin?.end();
|
|
1515
|
+
const timer = setTimeout(() => {
|
|
1516
|
+
if (settled) return;
|
|
1517
|
+
settled = true;
|
|
1485
1518
|
proc.kill("SIGKILL");
|
|
1486
1519
|
reject(new Error("timeout"));
|
|
1487
|
-
}, 15e3)
|
|
1488
|
-
|
|
1489
|
-
|
|
1520
|
+
}, 15e3);
|
|
1521
|
+
timer.unref?.();
|
|
1522
|
+
proc.on("close", (code2) => {
|
|
1523
|
+
if (settled) return;
|
|
1524
|
+
settled = true;
|
|
1525
|
+
clearTimeout(timer);
|
|
1526
|
+
resolve2({ code: code2, stdout: stdout2 });
|
|
1527
|
+
});
|
|
1528
|
+
}
|
|
1529
|
+
);
|
|
1530
|
+
const { code, stdout } = goResult;
|
|
1490
1531
|
if (code !== 0 || !stdout.trim()) {
|
|
1491
1532
|
return { file: filePath, lang, symbols: [], mtimeMs: Date.now() };
|
|
1492
1533
|
}
|
|
@@ -1508,15 +1549,15 @@ async function syncGoParse(filePath, content, lang) {
|
|
|
1508
1549
|
} catch {
|
|
1509
1550
|
return { file: filePath, lang, symbols: [], mtimeMs: Date.now() };
|
|
1510
1551
|
} finally {
|
|
1511
|
-
await
|
|
1552
|
+
await fs3.rm(tmpDir, { recursive: true, force: true });
|
|
1512
1553
|
}
|
|
1513
1554
|
}
|
|
1514
1555
|
|
|
1515
1556
|
// src/codebase-index/py-parser.ts
|
|
1516
|
-
import { spawn as spawn2 } from "node:child_process";
|
|
1517
|
-
import * as
|
|
1557
|
+
import { spawn as spawn2, spawnSync } from "node:child_process";
|
|
1558
|
+
import * as fs4 from "node:fs/promises";
|
|
1518
1559
|
import * as os2 from "node:os";
|
|
1519
|
-
import * as
|
|
1560
|
+
import * as path4 from "node:path";
|
|
1520
1561
|
async function parseSymbols3(opts) {
|
|
1521
1562
|
const { file, content, lang } = opts;
|
|
1522
1563
|
try {
|
|
@@ -1728,36 +1769,74 @@ visitor.visit(tree)
|
|
|
1728
1769
|
|
|
1729
1770
|
print(json.dumps([s.to_dict() for s in syms]))
|
|
1730
1771
|
`;
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1772
|
+
function resolvePython() {
|
|
1773
|
+
const candidates = process.platform === "win32" ? ["python3", "python", "py"] : ["python3", "python"];
|
|
1774
|
+
for (const name of candidates) {
|
|
1775
|
+
const resolved = resolveWin32Command(name);
|
|
1776
|
+
const result = spawnSync(resolved, ["--version"], {
|
|
1777
|
+
stdio: "pipe",
|
|
1778
|
+
timeout: 5e3
|
|
1779
|
+
});
|
|
1780
|
+
if (result.error) continue;
|
|
1781
|
+
if (result.status !== 0) continue;
|
|
1782
|
+
return resolved;
|
|
1783
|
+
}
|
|
1784
|
+
return null;
|
|
1785
|
+
}
|
|
1786
|
+
function spawnPyParser(pyBinary, scriptPath, filePath, content) {
|
|
1787
|
+
return new Promise((resolve2, reject) => {
|
|
1788
|
+
let settled = false;
|
|
1789
|
+
const proc = spawn2(pyBinary, [scriptPath, filePath], {
|
|
1741
1790
|
stdio: ["pipe", "pipe", "pipe"],
|
|
1742
1791
|
windowsHide: true
|
|
1743
1792
|
});
|
|
1793
|
+
proc.on("error", (err) => {
|
|
1794
|
+
if (settled) return;
|
|
1795
|
+
settled = true;
|
|
1796
|
+
reject(err);
|
|
1797
|
+
});
|
|
1744
1798
|
proc.stdin?.write(content);
|
|
1745
1799
|
proc.stdin?.end();
|
|
1746
1800
|
let stdout = "";
|
|
1747
1801
|
proc.stdout?.on("data", (chunk) => {
|
|
1748
1802
|
stdout += chunk.toString();
|
|
1749
1803
|
});
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
)
|
|
1760
|
-
|
|
1804
|
+
proc.stderr?.resume();
|
|
1805
|
+
const timer = setTimeout(() => {
|
|
1806
|
+
if (settled) return;
|
|
1807
|
+
settled = true;
|
|
1808
|
+
proc.kill("SIGKILL");
|
|
1809
|
+
reject(new Error("timeout"));
|
|
1810
|
+
}, 15e3);
|
|
1811
|
+
timer.unref?.();
|
|
1812
|
+
proc.on("close", (code) => {
|
|
1813
|
+
if (settled) return;
|
|
1814
|
+
settled = true;
|
|
1815
|
+
clearTimeout(timer);
|
|
1816
|
+
resolve2({ code, stdout });
|
|
1817
|
+
});
|
|
1818
|
+
});
|
|
1819
|
+
}
|
|
1820
|
+
var _cachedScriptPath = null;
|
|
1821
|
+
var _cachedPyBinary = null;
|
|
1822
|
+
async function syncPyParse(filePath, content, lang) {
|
|
1823
|
+
try {
|
|
1824
|
+
if (!_cachedScriptPath) {
|
|
1825
|
+
const tmpDir = path4.join(os2.tmpdir(), "ws-py-parse");
|
|
1826
|
+
await fs4.mkdir(tmpDir, { recursive: true });
|
|
1827
|
+
_cachedScriptPath = path4.join(tmpDir, "parse.py");
|
|
1828
|
+
await fs4.writeFile(_cachedScriptPath, PY_PARSE_SCRIPT, "utf8");
|
|
1829
|
+
}
|
|
1830
|
+
if (!_cachedPyBinary) {
|
|
1831
|
+
_cachedPyBinary = resolvePython();
|
|
1832
|
+
if (!_cachedPyBinary) return { file: filePath, lang, symbols: [], mtimeMs: Date.now() };
|
|
1833
|
+
}
|
|
1834
|
+
const { code, stdout } = await spawnPyParser(
|
|
1835
|
+
_cachedPyBinary,
|
|
1836
|
+
_cachedScriptPath,
|
|
1837
|
+
filePath,
|
|
1838
|
+
content
|
|
1839
|
+
);
|
|
1761
1840
|
if (code !== 0 || !stdout.trim()) {
|
|
1762
1841
|
return { file: filePath, lang, symbols: [], mtimeMs: Date.now() };
|
|
1763
1842
|
}
|
|
@@ -1784,8 +1863,8 @@ async function syncPyParse(filePath, content, lang) {
|
|
|
1784
1863
|
// src/codebase-index/rs-parser.ts
|
|
1785
1864
|
import { expectDefined as expectDefined2 } from "@wrongstack/core";
|
|
1786
1865
|
import { execFileSync, spawn as spawn3 } from "node:child_process";
|
|
1787
|
-
import * as
|
|
1788
|
-
import * as
|
|
1866
|
+
import * as fs5 from "node:fs/promises";
|
|
1867
|
+
import * as path5 from "node:path";
|
|
1789
1868
|
async function parseSymbols4(opts) {
|
|
1790
1869
|
const { file, content, lang } = opts;
|
|
1791
1870
|
const nativeAvailable = checkNativeParser();
|
|
@@ -1798,7 +1877,7 @@ async function parseSymbols4(opts) {
|
|
|
1798
1877
|
function checkNativeParser() {
|
|
1799
1878
|
try {
|
|
1800
1879
|
execFileSync("rustc", ["--version"], { stdio: "pipe", windowsHide: true });
|
|
1801
|
-
const toolsDir =
|
|
1880
|
+
const toolsDir = path5.join(process.cwd(), "tools");
|
|
1802
1881
|
try {
|
|
1803
1882
|
execFileSync(
|
|
1804
1883
|
"cargo",
|
|
@@ -1808,7 +1887,7 @@ function checkNativeParser() {
|
|
|
1808
1887
|
"--format-version",
|
|
1809
1888
|
"1",
|
|
1810
1889
|
"--manifest-path",
|
|
1811
|
-
|
|
1890
|
+
path5.join(toolsDir, "Cargo.toml")
|
|
1812
1891
|
],
|
|
1813
1892
|
{ stdio: "pipe", windowsHide: true }
|
|
1814
1893
|
);
|
|
@@ -1822,34 +1901,49 @@ function checkNativeParser() {
|
|
|
1822
1901
|
}
|
|
1823
1902
|
async function tryNativeParse(file, content) {
|
|
1824
1903
|
try {
|
|
1825
|
-
const toolsDir =
|
|
1826
|
-
const crateDir =
|
|
1827
|
-
const tmpFile =
|
|
1828
|
-
await
|
|
1829
|
-
const
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1904
|
+
const toolsDir = path5.join(process.cwd(), "tools");
|
|
1905
|
+
const crateDir = path5.join(toolsDir, "syn-parser");
|
|
1906
|
+
const tmpFile = path5.join(crateDir, "src", "input.rs");
|
|
1907
|
+
await fs5.writeFile(tmpFile, content, "utf8");
|
|
1908
|
+
const cargoBinary = resolveWin32Command("cargo");
|
|
1909
|
+
const result = await new Promise(
|
|
1910
|
+
(resolve2, reject) => {
|
|
1911
|
+
let settled = false;
|
|
1912
|
+
const proc = spawn3(
|
|
1913
|
+
cargoBinary,
|
|
1914
|
+
["run", "--manifest-path", path5.join(toolsDir, "Cargo.toml")],
|
|
1915
|
+
{
|
|
1916
|
+
cwd: process.cwd(),
|
|
1917
|
+
stdio: ["pipe", "pipe", "pipe"],
|
|
1918
|
+
windowsHide: true
|
|
1919
|
+
}
|
|
1920
|
+
);
|
|
1921
|
+
proc.on("error", (err) => {
|
|
1922
|
+
if (settled) return;
|
|
1923
|
+
settled = true;
|
|
1924
|
+
reject(err);
|
|
1925
|
+
});
|
|
1926
|
+
let stdout2 = "";
|
|
1927
|
+
proc.stdout?.on("data", (chunk) => {
|
|
1928
|
+
stdout2 += chunk.toString();
|
|
1929
|
+
});
|
|
1930
|
+
proc.stderr?.resume();
|
|
1931
|
+
const timer = setTimeout(() => {
|
|
1932
|
+
if (settled) return;
|
|
1933
|
+
settled = true;
|
|
1848
1934
|
proc.kill("SIGKILL");
|
|
1849
1935
|
reject(new Error("timeout"));
|
|
1850
|
-
}, 15e3)
|
|
1851
|
-
|
|
1852
|
-
|
|
1936
|
+
}, 15e3);
|
|
1937
|
+
timer.unref?.();
|
|
1938
|
+
proc.on("close", (c) => {
|
|
1939
|
+
if (settled) return;
|
|
1940
|
+
settled = true;
|
|
1941
|
+
clearTimeout(timer);
|
|
1942
|
+
resolve2({ code: c, stdout: stdout2 });
|
|
1943
|
+
});
|
|
1944
|
+
}
|
|
1945
|
+
);
|
|
1946
|
+
const { code, stdout } = result;
|
|
1853
1947
|
if (code === 0 && stdout.trim()) {
|
|
1854
1948
|
const symbols = JSON.parse(stdout.trim());
|
|
1855
1949
|
return {
|
|
@@ -1932,7 +2026,7 @@ function regexParse(opts) {
|
|
|
1932
2026
|
|
|
1933
2027
|
// src/codebase-index/json-parser.ts
|
|
1934
2028
|
import { expectDefined as expectDefined3 } from "@wrongstack/core";
|
|
1935
|
-
import * as
|
|
2029
|
+
import * as path6 from "node:path";
|
|
1936
2030
|
function parseSymbols5(opts) {
|
|
1937
2031
|
const { file, content, lang } = opts;
|
|
1938
2032
|
try {
|
|
@@ -1944,7 +2038,7 @@ function parseSymbols5(opts) {
|
|
|
1944
2038
|
function regexParse2(opts) {
|
|
1945
2039
|
const { file, content, lang } = opts;
|
|
1946
2040
|
const symbols = [];
|
|
1947
|
-
const basename2 =
|
|
2041
|
+
const basename2 = path6.basename(file).toLowerCase();
|
|
1948
2042
|
const isPackageJson = basename2 === "package.json";
|
|
1949
2043
|
const isTsconfig = basename2 === "tsconfig.json" || basename2 === "tsconfig.build.json";
|
|
1950
2044
|
const isJsonSchema = content.includes("$schema") || content.includes("$id") || content.includes("$ref");
|
|
@@ -1970,11 +2064,11 @@ function regexParse2(opts) {
|
|
|
1970
2064
|
const line = lineFromOffset(offset);
|
|
1971
2065
|
symbols.push(
|
|
1972
2066
|
makeSymbol({
|
|
1973
|
-
name:
|
|
2067
|
+
name: path6.basename(file),
|
|
1974
2068
|
kind: "object",
|
|
1975
2069
|
line,
|
|
1976
2070
|
col: 0,
|
|
1977
|
-
signature: `"${
|
|
2071
|
+
signature: `"${path6.basename(file)}" = { ... }`,
|
|
1978
2072
|
file,
|
|
1979
2073
|
lang
|
|
1980
2074
|
})
|
|
@@ -2285,8 +2379,8 @@ function makeSymbol2(opts) {
|
|
|
2285
2379
|
}
|
|
2286
2380
|
|
|
2287
2381
|
// src/codebase-index/gitignore.ts
|
|
2288
|
-
import * as
|
|
2289
|
-
import * as
|
|
2382
|
+
import * as fs6 from "node:fs/promises";
|
|
2383
|
+
import * as path7 from "node:path";
|
|
2290
2384
|
import { compileGlob } from "@wrongstack/core";
|
|
2291
2385
|
function globBody(glob) {
|
|
2292
2386
|
return compileGlob(glob).source.replace(/^\^/, "").replace(/\$$/, "");
|
|
@@ -2332,7 +2426,7 @@ function compileGitignore(lines) {
|
|
|
2332
2426
|
async function loadGitignoreMatcher(projectRoot) {
|
|
2333
2427
|
let lines = [];
|
|
2334
2428
|
try {
|
|
2335
|
-
const raw = await
|
|
2429
|
+
const raw = await fs6.readFile(path7.join(projectRoot, ".gitignore"), "utf8");
|
|
2336
2430
|
lines = raw.split("\n");
|
|
2337
2431
|
} catch {
|
|
2338
2432
|
}
|
|
@@ -2390,21 +2484,21 @@ async function findSourceFiles(projectRoot, ignore, isGitIgnored, signal) {
|
|
|
2390
2484
|
}
|
|
2391
2485
|
let entries;
|
|
2392
2486
|
try {
|
|
2393
|
-
entries = await
|
|
2487
|
+
entries = await fs7.readdir(dir, { withFileTypes: true });
|
|
2394
2488
|
} catch {
|
|
2395
2489
|
return;
|
|
2396
2490
|
}
|
|
2397
2491
|
dirCount++;
|
|
2398
2492
|
for (const e of entries) {
|
|
2399
2493
|
if (ignoreSet.has(e.name)) continue;
|
|
2400
|
-
const full =
|
|
2401
|
-
const rel =
|
|
2494
|
+
const full = path8.join(dir, e.name);
|
|
2495
|
+
const rel = path8.relative(projectRoot, full).replace(/\\/g, "/");
|
|
2402
2496
|
if (e.isDirectory()) {
|
|
2403
2497
|
if (isGitIgnored(rel, true)) continue;
|
|
2404
2498
|
await walk(full);
|
|
2405
2499
|
} else if (e.isFile()) {
|
|
2406
2500
|
if (isGitIgnored(rel, false)) continue;
|
|
2407
|
-
const ext =
|
|
2501
|
+
const ext = path8.extname(e.name);
|
|
2408
2502
|
for (const { ext: extName, pat } of globs) {
|
|
2409
2503
|
if (ext === extName && (pat.test(rel) || pat.test(e.name))) {
|
|
2410
2504
|
results.push(full);
|
|
@@ -2460,7 +2554,7 @@ async function runIndexerWithStore(store, opts) {
|
|
|
2460
2554
|
let files;
|
|
2461
2555
|
let discoveredFiles = null;
|
|
2462
2556
|
if (opts.files && opts.files.length > 0) {
|
|
2463
|
-
files = opts.files.map((f) =>
|
|
2557
|
+
files = opts.files.map((f) => path8.resolve(projectRoot, f)).filter((f) => !isGitIgnored(path8.relative(projectRoot, f).replace(/\\/g, "/"), false));
|
|
2464
2558
|
} else {
|
|
2465
2559
|
files = await findSourceFiles(projectRoot, ignore, isGitIgnored, signal);
|
|
2466
2560
|
discoveredFiles = new Set(files);
|
|
@@ -2490,7 +2584,7 @@ async function runIndexerWithStore(store, opts) {
|
|
|
2490
2584
|
batchFiles.map(async (file) => {
|
|
2491
2585
|
let stat2;
|
|
2492
2586
|
try {
|
|
2493
|
-
stat2 = await
|
|
2587
|
+
stat2 = await fs7.stat(file, statOpts);
|
|
2494
2588
|
} catch (e) {
|
|
2495
2589
|
if (isAbortError(e)) throw e;
|
|
2496
2590
|
return { file, stat: null, lang: "", parsed: null, error: `stat error: ${e instanceof Error ? e.message : String(e)}` };
|
|
@@ -2504,7 +2598,7 @@ async function runIndexerWithStore(store, opts) {
|
|
|
2504
2598
|
}
|
|
2505
2599
|
let content;
|
|
2506
2600
|
try {
|
|
2507
|
-
content = await
|
|
2601
|
+
content = await fs7.readFile(file, { encoding: "utf8", signal });
|
|
2508
2602
|
} catch (e) {
|
|
2509
2603
|
if (isAbortError(e)) throw e;
|
|
2510
2604
|
return { file, stat: stat2, lang, parsed: null, error: `read error: ${e instanceof Error ? e.message : String(e)}` };
|
|
@@ -2773,7 +2867,7 @@ function resolveWorkerUrl() {
|
|
|
2773
2867
|
for (const rel of ["./worker.js", "./codebase-index/worker.js"]) {
|
|
2774
2868
|
try {
|
|
2775
2869
|
const url = new URL(rel, import.meta.url);
|
|
2776
|
-
if (url.protocol === "file:" &&
|
|
2870
|
+
if (url.protocol === "file:" && fs8.existsSync(fileURLToPath(url))) return url;
|
|
2777
2871
|
} catch {
|
|
2778
2872
|
}
|
|
2779
2873
|
}
|