@wrongstack/tools 0.148.0 → 0.155.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/{background-indexer-C2014mH0.d.ts → background-indexer-CtbgPExj.d.ts} +1 -0
- package/dist/builtin.js +30 -8
- package/dist/builtin.js.map +1 -1
- package/dist/codebase-index/index.d.ts +9 -2
- package/dist/codebase-index/index.js +32 -9
- package/dist/codebase-index/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +32 -9
- package/dist/index.js.map +1 -1
- package/dist/pack.js +30 -8
- package/dist/pack.js.map +1 -1
- package/package.json +2 -2
package/dist/pack.js
CHANGED
|
@@ -2748,6 +2748,16 @@ var YIELD_EVERY_N = 50;
|
|
|
2748
2748
|
function yieldEventLoop() {
|
|
2749
2749
|
return new Promise((resolve7) => setImmediate(resolve7));
|
|
2750
2750
|
}
|
|
2751
|
+
function throwIfAborted(signal) {
|
|
2752
|
+
if (!signal?.aborted) return;
|
|
2753
|
+
if (signal.reason instanceof Error) throw signal.reason;
|
|
2754
|
+
throw new Error(
|
|
2755
|
+
typeof signal.reason === "string" ? signal.reason : "Indexing cancelled"
|
|
2756
|
+
);
|
|
2757
|
+
}
|
|
2758
|
+
function isAbortError(err) {
|
|
2759
|
+
return err instanceof DOMException && err.name === "AbortError";
|
|
2760
|
+
}
|
|
2751
2761
|
var DEFAULT_IGNORE = [
|
|
2752
2762
|
"node_modules",
|
|
2753
2763
|
".git",
|
|
@@ -2759,7 +2769,7 @@ var DEFAULT_IGNORE = [
|
|
|
2759
2769
|
"__snapshots__",
|
|
2760
2770
|
".nyc_output"
|
|
2761
2771
|
];
|
|
2762
|
-
async function findSourceFiles(projectRoot, ignore, isGitIgnored) {
|
|
2772
|
+
async function findSourceFiles(projectRoot, ignore, isGitIgnored, signal) {
|
|
2763
2773
|
const results = [];
|
|
2764
2774
|
const ignoreSet = /* @__PURE__ */ new Set([...DEFAULT_IGNORE, ...ignore]);
|
|
2765
2775
|
const globs = [
|
|
@@ -2774,13 +2784,20 @@ async function findSourceFiles(projectRoot, ignore, isGitIgnored) {
|
|
|
2774
2784
|
{ ext: ".yaml", pat: compileGlob("**/*.yaml") },
|
|
2775
2785
|
{ ext: ".yml", pat: compileGlob("**/*.yml") }
|
|
2776
2786
|
];
|
|
2787
|
+
let dirCount = 0;
|
|
2777
2788
|
const walk = async (dir) => {
|
|
2789
|
+
throwIfAborted(signal);
|
|
2790
|
+
if (dirCount > 0 && dirCount % YIELD_EVERY_N === 0) {
|
|
2791
|
+
await yieldEventLoop();
|
|
2792
|
+
throwIfAborted(signal);
|
|
2793
|
+
}
|
|
2778
2794
|
let entries;
|
|
2779
2795
|
try {
|
|
2780
2796
|
entries = await fs13.readdir(dir, { withFileTypes: true });
|
|
2781
2797
|
} catch {
|
|
2782
2798
|
return;
|
|
2783
2799
|
}
|
|
2800
|
+
dirCount++;
|
|
2784
2801
|
for (const e of entries) {
|
|
2785
2802
|
if (ignoreSet.has(e.name)) continue;
|
|
2786
2803
|
const full = path2.join(dir, e.name);
|
|
@@ -2825,7 +2842,7 @@ async function parseFile(file, content, lang) {
|
|
|
2825
2842
|
}
|
|
2826
2843
|
}
|
|
2827
2844
|
async function runIndexer(_ctx, opts) {
|
|
2828
|
-
const { projectRoot, force = false, langs, ignore = [], indexDir } = opts;
|
|
2845
|
+
const { projectRoot, force = false, langs, ignore = [], indexDir, signal } = opts;
|
|
2829
2846
|
const store = new IndexStore(projectRoot, { indexDir });
|
|
2830
2847
|
const startMs = Date.now();
|
|
2831
2848
|
const errors = [];
|
|
@@ -2837,7 +2854,7 @@ async function runIndexer(_ctx, opts) {
|
|
|
2837
2854
|
if (opts.files && opts.files.length > 0) {
|
|
2838
2855
|
files = opts.files.map((f) => path2.resolve(projectRoot, f)).filter((f) => !isGitIgnored(path2.relative(projectRoot, f).replace(/\\/g, "/"), false));
|
|
2839
2856
|
} else {
|
|
2840
|
-
files = await findSourceFiles(projectRoot, ignore, isGitIgnored);
|
|
2857
|
+
files = await findSourceFiles(projectRoot, ignore, isGitIgnored, signal);
|
|
2841
2858
|
}
|
|
2842
2859
|
if (langs && langs.length > 0) {
|
|
2843
2860
|
const langSet = new Set(langs);
|
|
@@ -2856,11 +2873,14 @@ async function runIndexer(_ctx, opts) {
|
|
|
2856
2873
|
_setIndexProgress(fi + 1, files.length);
|
|
2857
2874
|
if (fi > 0 && fi % YIELD_EVERY_N === 0) {
|
|
2858
2875
|
await yieldEventLoop();
|
|
2876
|
+
throwIfAborted(signal);
|
|
2859
2877
|
}
|
|
2860
2878
|
let stat10;
|
|
2861
2879
|
try {
|
|
2862
|
-
|
|
2863
|
-
|
|
2880
|
+
const statOpts = signal ? { signal } : {};
|
|
2881
|
+
stat10 = await fs13.stat(file, statOpts);
|
|
2882
|
+
} catch (e) {
|
|
2883
|
+
if (isAbortError(e)) throw e;
|
|
2864
2884
|
store.deleteFile(file);
|
|
2865
2885
|
continue;
|
|
2866
2886
|
}
|
|
@@ -2878,8 +2898,9 @@ async function runIndexer(_ctx, opts) {
|
|
|
2878
2898
|
store.deleteSymbolsForFile(file);
|
|
2879
2899
|
let content;
|
|
2880
2900
|
try {
|
|
2881
|
-
content = await fs13.readFile(file, "utf8");
|
|
2901
|
+
content = await fs13.readFile(file, { encoding: "utf8", signal });
|
|
2882
2902
|
} catch (e) {
|
|
2903
|
+
if (isAbortError(e)) throw e;
|
|
2883
2904
|
errors.push(`read error: ${file}: ${e instanceof Error ? e.message : String(e)}`);
|
|
2884
2905
|
continue;
|
|
2885
2906
|
}
|
|
@@ -2969,12 +2990,13 @@ var codebaseIndexTool = {
|
|
|
2969
2990
|
}
|
|
2970
2991
|
}
|
|
2971
2992
|
},
|
|
2972
|
-
async execute(input, ctx) {
|
|
2993
|
+
async execute(input, ctx, execOpts) {
|
|
2973
2994
|
const result = await runIndexer(ctx, {
|
|
2974
2995
|
projectRoot: ctx.projectRoot,
|
|
2975
2996
|
force: input.force ?? false,
|
|
2976
2997
|
langs: input.langs,
|
|
2977
|
-
indexDir: codebaseIndexDirOverride(ctx)
|
|
2998
|
+
indexDir: codebaseIndexDirOverride(ctx),
|
|
2999
|
+
signal: execOpts?.signal
|
|
2978
3000
|
});
|
|
2979
3001
|
setIndexReady();
|
|
2980
3002
|
return result;
|