@wrongstack/tools 0.264.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 -11
- 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 +661 -325
- 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 +59 -25
- package/dist/codebase-index/index.js.map +1 -1
- package/dist/codebase-index/worker.js +56 -25
- package/dist/codebase-index/worker.js.map +1 -1
- package/dist/diff.js +14 -7
- package/dist/diff.js.map +1 -1
- package/dist/document.js +14 -8
- package/dist/document.js.map +1 -1
- package/dist/edit.js +21 -15
- package/dist/edit.js.map +1 -1
- package/dist/exec.js +140 -3
- package/dist/exec.js.map +1 -1
- package/dist/fetch.js +1 -0
- package/dist/fetch.js.map +1 -1
- package/dist/format.js +153 -11
- 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 -7
- package/dist/glob.js.map +1 -1
- package/dist/grep.js +14 -7
- package/dist/grep.js.map +1 -1
- package/dist/index.d.ts +55 -3
- package/dist/index.js +819 -325
- package/dist/index.js.map +1 -1
- package/dist/install.js +153 -11
- package/dist/install.js.map +1 -1
- package/dist/json.js +1 -0
- package/dist/json.js.map +1 -1
- package/dist/lint.js +153 -11
- package/dist/lint.js.map +1 -1
- package/dist/logs.js +14 -7
- 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 -8
- package/dist/outdated.js.map +1 -1
- package/dist/pack.js +630 -324
- package/dist/pack.js.map +1 -1
- package/dist/patch.js +14 -7
- 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 +21 -16
- package/dist/read.js.map +1 -1
- package/dist/replace.js +14 -7
- package/dist/replace.js.map +1 -1
- package/dist/scaffold.js +14 -7
- package/dist/scaffold.js.map +1 -1
- package/dist/search.js +1 -0
- package/dist/search.js.map +1 -1
- package/dist/test.js +153 -11
- 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 -7
- package/dist/tree.js.map +1 -1
- package/dist/typecheck.js +153 -11
- package/dist/typecheck.js.map +1 -1
- package/dist/write.js +21 -15
- package/dist/write.js.map +1 -1
- package/package.json +6 -2
|
@@ -682,39 +682,57 @@ var IndexStore = class {
|
|
|
682
682
|
}
|
|
683
683
|
});
|
|
684
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
|
+
}
|
|
685
708
|
/**
|
|
686
709
|
* Delete all refs whose source symbols are in a given file.
|
|
687
710
|
* Used when re-indexing a file to clear stale refs.
|
|
688
711
|
*/
|
|
689
712
|
deleteRefsForFile(file) {
|
|
690
713
|
this.runWithRetry(() => {
|
|
691
|
-
|
|
692
|
-
"SELECT id FROM symbols WHERE file = ?"
|
|
693
|
-
).
|
|
694
|
-
if (!ids.length) return;
|
|
695
|
-
const placeholders = ids.map(() => "?").join(",");
|
|
696
|
-
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);
|
|
697
717
|
});
|
|
698
718
|
}
|
|
699
719
|
/**
|
|
700
720
|
* Resolve `to_name` → `to_id` for all refs that have a name but no id.
|
|
701
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.
|
|
702
726
|
*/
|
|
703
727
|
resolveRefs() {
|
|
704
728
|
return this.runWithRetry(() => {
|
|
705
|
-
const
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
if (first) {
|
|
713
|
-
this.db.prepare("UPDATE refs SET to_id = ? WHERE id = ?").run(first.id, row.id);
|
|
714
|
-
resolved++;
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
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;
|
|
718
736
|
});
|
|
719
737
|
}
|
|
720
738
|
/**
|
|
@@ -2189,13 +2207,26 @@ async function runIndexerWithStore(store, opts) {
|
|
|
2189
2207
|
symbolsIndexed += count;
|
|
2190
2208
|
langStats[lang] = (langStats[lang] ?? 0) + count;
|
|
2191
2209
|
if (parsed.refs && parsed.refs.length > 0) {
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
if (
|
|
2196
|
-
|
|
2197
|
-
|
|
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);
|
|
2198
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);
|
|
2199
2230
|
}
|
|
2200
2231
|
}
|
|
2201
2232
|
store.upsertFile({
|