@wrongstack/tools 0.260.0 → 0.265.1
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/audit.js +154 -10
- package/dist/audit.js.map +1 -1
- package/dist/bash.js +138 -2
- package/dist/bash.js.map +1 -1
- package/dist/batch-tool-use.js +1 -0
- package/dist/batch-tool-use.js.map +1 -1
- package/dist/builtin.d.ts +20 -1
- package/dist/builtin.js +674 -333
- package/dist/builtin.js.map +1 -1
- package/dist/circuit-breaker.d.ts +20 -0
- package/dist/circuit-breaker.js +40 -2
- package/dist/circuit-breaker.js.map +1 -1
- package/dist/codebase-index/index.d.ts +16 -0
- package/dist/codebase-index/index.js +62 -27
- package/dist/codebase-index/index.js.map +1 -1
- package/dist/codebase-index/worker.js +59 -27
- package/dist/codebase-index/worker.js.map +1 -1
- package/dist/diff.js +14 -6
- package/dist/diff.js.map +1 -1
- package/dist/document.js +18 -11
- package/dist/document.js.map +1 -1
- package/dist/edit.js +22 -14
- package/dist/edit.js.map +1 -1
- package/dist/exec.js +140 -3
- package/dist/exec.js.map +1 -1
- package/dist/fetch.d.ts +19 -1
- package/dist/fetch.js +2 -1
- package/dist/fetch.js.map +1 -1
- package/dist/format.js +153 -10
- package/dist/format.js.map +1 -1
- package/dist/git.js +1 -0
- package/dist/git.js.map +1 -1
- package/dist/glob.js +14 -6
- package/dist/glob.js.map +1 -1
- package/dist/grep.js +14 -6
- package/dist/grep.js.map +1 -1
- package/dist/index.d.ts +55 -3
- package/dist/index.js +833 -336
- package/dist/index.js.map +1 -1
- package/dist/install.js +154 -10
- package/dist/install.js.map +1 -1
- package/dist/json.js +2 -0
- package/dist/json.js.map +1 -1
- package/dist/lint.js +153 -10
- package/dist/lint.js.map +1 -1
- package/dist/logs.js +14 -6
- package/dist/logs.js.map +1 -1
- package/dist/memory.js +1 -0
- package/dist/memory.js.map +1 -1
- package/dist/mode.js +1 -0
- package/dist/mode.js.map +1 -1
- package/dist/outdated.js +16 -7
- package/dist/outdated.js.map +1 -1
- package/dist/pack.js +643 -332
- package/dist/pack.js.map +1 -1
- package/dist/patch.js +14 -6
- package/dist/patch.js.map +1 -1
- package/dist/process-registry.d.ts +56 -2
- package/dist/process-registry.js +138 -3
- package/dist/process-registry.js.map +1 -1
- package/dist/read.js +24 -18
- package/dist/read.js.map +1 -1
- package/dist/replace.js +14 -6
- package/dist/replace.js.map +1 -1
- package/dist/scaffold.js +14 -6
- package/dist/scaffold.js.map +1 -1
- package/dist/search.js +3 -3
- package/dist/search.js.map +1 -1
- package/dist/test.js +153 -10
- package/dist/test.js.map +1 -1
- package/dist/todo.js +1 -0
- package/dist/todo.js.map +1 -1
- package/dist/tool-help.js +1 -0
- package/dist/tool-help.js.map +1 -1
- package/dist/tool-icons.d.ts +20 -0
- package/dist/tool-icons.js +130 -0
- package/dist/tool-icons.js.map +1 -0
- package/dist/tool-search.js +1 -0
- package/dist/tool-search.js.map +1 -1
- package/dist/tool-use.js +1 -0
- package/dist/tool-use.js.map +1 -1
- package/dist/tree.js +14 -6
- package/dist/tree.js.map +1 -1
- package/dist/typecheck.js +153 -10
- package/dist/typecheck.js.map +1 -1
- package/dist/write.js +22 -14
- package/dist/write.js.map +1 -1
- package/package.json +6 -2
|
@@ -2,6 +2,7 @@ import { parentPort } from 'node:worker_threads';
|
|
|
2
2
|
import { expectDefined, resolveWstackPaths, compileGlob, truncate } from '@wrongstack/core';
|
|
3
3
|
import * as fs3 from 'node:fs/promises';
|
|
4
4
|
import * as path4 from 'node:path';
|
|
5
|
+
import { toErrorMessage } from '@wrongstack/core/utils';
|
|
5
6
|
import { createRequire } from 'node:module';
|
|
6
7
|
import * as fs from 'node:fs';
|
|
7
8
|
import { writeFileSync, mkdirSync } from 'node:fs';
|
|
@@ -235,7 +236,7 @@ function loadDatabaseSync() {
|
|
|
235
236
|
DatabaseSyncCtor = req("node:sqlite").DatabaseSync;
|
|
236
237
|
} catch (err) {
|
|
237
238
|
throw new Error(
|
|
238
|
-
`The codebase index needs Node's built-in SQLite (node:sqlite), available since Node 22.5. This runtime doesn't provide it: ${
|
|
239
|
+
`The codebase index needs Node's built-in SQLite (node:sqlite), available since Node 22.5. This runtime doesn't provide it: ${toErrorMessage(err)}`
|
|
239
240
|
);
|
|
240
241
|
}
|
|
241
242
|
return DatabaseSyncCtor;
|
|
@@ -681,39 +682,57 @@ var IndexStore = class {
|
|
|
681
682
|
}
|
|
682
683
|
});
|
|
683
684
|
}
|
|
685
|
+
/**
|
|
686
|
+
* Bulk-insert refs for many source symbols in a single transaction.
|
|
687
|
+
*
|
|
688
|
+
* Unlike {@link insertRefs} this does NOT delete per source id — the caller
|
|
689
|
+
* (the indexer) has already cleared stale refs for the file via
|
|
690
|
+
* {@link deleteRefsForFile}, so the per-source DELETE would be redundant work
|
|
691
|
+
* repeated once per symbol. One transaction for the whole file instead of one
|
|
692
|
+
* per symbol turns an O(symbols) transaction count into O(1).
|
|
693
|
+
*
|
|
694
|
+
* Each ref's own {@link Ref.fromId} is used; pass an empty array to no-op.
|
|
695
|
+
*/
|
|
696
|
+
insertRefsBatch(refs) {
|
|
697
|
+
if (refs.length === 0) return;
|
|
698
|
+
this.runWithRetry(() => {
|
|
699
|
+
const stmt = this.db.prepare(
|
|
700
|
+
`INSERT INTO refs(from_id, to_name, to_id, call_type, line)
|
|
701
|
+
VALUES (?, ?, ?, ?, ?)`
|
|
702
|
+
);
|
|
703
|
+
for (const ref of refs) {
|
|
704
|
+
stmt.run(ref.fromId, ref.toName, ref.toId ?? null, ref.callType, ref.line);
|
|
705
|
+
}
|
|
706
|
+
});
|
|
707
|
+
}
|
|
684
708
|
/**
|
|
685
709
|
* Delete all refs whose source symbols are in a given file.
|
|
686
710
|
* Used when re-indexing a file to clear stale refs.
|
|
687
711
|
*/
|
|
688
712
|
deleteRefsForFile(file) {
|
|
689
713
|
this.runWithRetry(() => {
|
|
690
|
-
|
|
691
|
-
"SELECT id FROM symbols WHERE file = ?"
|
|
692
|
-
).
|
|
693
|
-
if (!ids.length) return;
|
|
694
|
-
const placeholders = ids.map(() => "?").join(",");
|
|
695
|
-
this.db.prepare(`DELETE FROM refs WHERE from_id IN (${placeholders})`).run(...ids.map((r) => r.id));
|
|
714
|
+
this.db.prepare(
|
|
715
|
+
"DELETE FROM refs WHERE from_id IN (SELECT id FROM symbols WHERE file = ?)"
|
|
716
|
+
).run(file);
|
|
696
717
|
});
|
|
697
718
|
}
|
|
698
719
|
/**
|
|
699
720
|
* Resolve `to_name` → `to_id` for all refs that have a name but no id.
|
|
700
721
|
* Call this after all symbols have been inserted to fill in cross-references.
|
|
722
|
+
*
|
|
723
|
+
* Single statement: the `to_name IN (SELECT name FROM symbols)` guard restricts
|
|
724
|
+
* the UPDATE to refs that will actually resolve, so `.changes` counts only refs
|
|
725
|
+
* that found a target — matching the previous per-row loop's return value.
|
|
701
726
|
*/
|
|
702
727
|
resolveRefs() {
|
|
703
728
|
return this.runWithRetry(() => {
|
|
704
|
-
const
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
if (first) {
|
|
712
|
-
this.db.prepare("UPDATE refs SET to_id = ? WHERE id = ?").run(first.id, row.id);
|
|
713
|
-
resolved++;
|
|
714
|
-
}
|
|
715
|
-
}
|
|
716
|
-
return resolved;
|
|
729
|
+
const result = this.db.prepare(
|
|
730
|
+
`UPDATE refs SET to_id = (
|
|
731
|
+
SELECT id FROM symbols WHERE name = refs.to_name LIMIT 1
|
|
732
|
+
) WHERE to_id IS NULL AND to_name IS NOT NULL
|
|
733
|
+
AND to_name IN (SELECT name FROM symbols)`
|
|
734
|
+
).run();
|
|
735
|
+
return result.changes ?? 0;
|
|
717
736
|
});
|
|
718
737
|
}
|
|
719
738
|
/**
|
|
@@ -820,7 +839,7 @@ function getSignature(node, sourceFile) {
|
|
|
820
839
|
}
|
|
821
840
|
function getJsDoc(node, sourceFile) {
|
|
822
841
|
const fullText = sourceFile.getFullText();
|
|
823
|
-
const nodePos = node.
|
|
842
|
+
const nodePos = node.getFullStart();
|
|
824
843
|
const comments = ts.getLeadingCommentRanges(fullText, nodePos);
|
|
825
844
|
if (!comments) return "";
|
|
826
845
|
for (const range of comments) {
|
|
@@ -2188,13 +2207,26 @@ async function runIndexerWithStore(store, opts) {
|
|
|
2188
2207
|
symbolsIndexed += count;
|
|
2189
2208
|
langStats[lang] = (langStats[lang] ?? 0) + count;
|
|
2190
2209
|
if (parsed.refs && parsed.refs.length > 0) {
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
if (
|
|
2195
|
-
|
|
2196
|
-
|
|
2210
|
+
const refsByLine = /* @__PURE__ */ new Map();
|
|
2211
|
+
for (const r of parsed.refs) {
|
|
2212
|
+
let arr = refsByLine.get(r.line);
|
|
2213
|
+
if (!arr) {
|
|
2214
|
+
arr = [];
|
|
2215
|
+
refsByLine.set(r.line, arr);
|
|
2197
2216
|
}
|
|
2217
|
+
arr.push(r);
|
|
2218
|
+
}
|
|
2219
|
+
const batch = [];
|
|
2220
|
+
for (const sym of symbolsWithIds) {
|
|
2221
|
+
const symRefs = refsByLine.get(sym.line);
|
|
2222
|
+
if (symRefs) {
|
|
2223
|
+
for (const r of symRefs) {
|
|
2224
|
+
batch.push({ ...r, fromId: sym.id });
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
if (batch.length > 0) {
|
|
2229
|
+
store.insertRefsBatch(batch);
|
|
2198
2230
|
}
|
|
2199
2231
|
}
|
|
2200
2232
|
store.upsertFile({
|