@wrongstack/tools 0.309.1 → 0.310.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.
Files changed (57) hide show
  1. package/dist/_regex.d.ts +6 -34
  2. package/dist/bash.js +3 -3
  3. package/dist/builtin.js +3011 -1677
  4. package/dist/codebase-index/binary-frame.d.ts +57 -8
  5. package/dist/codebase-index/codebase-incoming-calls-tool.d.ts +6 -0
  6. package/dist/codebase-index/codebase-outgoing-calls-tool.d.ts +6 -0
  7. package/dist/codebase-index/codebase-search-tool.d.ts +15 -5
  8. package/dist/codebase-index/index-service.d.ts +3 -19
  9. package/dist/codebase-index/index.js +2735 -1415
  10. package/dist/codebase-index/indexer.d.ts +3 -0
  11. package/dist/codebase-index/parser-batch.d.ts +53 -0
  12. package/dist/codebase-index/parser-dispatch.d.ts +32 -0
  13. package/dist/codebase-index/parser-output.d.ts +14 -0
  14. package/dist/codebase-index/parser-worker-pool.d.ts +57 -4
  15. package/dist/codebase-index/parser-worker-script.d.ts +5 -2
  16. package/dist/codebase-index/parser-worker-script.js +4042 -0
  17. package/dist/codebase-index/project-server-cache.d.ts +16 -0
  18. package/dist/codebase-index/project-server-client.d.ts +2 -2
  19. package/dist/codebase-index/project-server-query-cache.d.ts +88 -0
  20. package/dist/codebase-index/project-server.js +2846 -1308
  21. package/dist/codebase-index/py-parser.d.ts +5 -0
  22. package/dist/codebase-index/schema.d.ts +14 -1
  23. package/dist/codebase-index/sqlite-runtime.d.ts +2 -2
  24. package/dist/codebase-index/tree-sitter/queries.d.ts +30 -3
  25. package/dist/codebase-index/tree-sitter/visitor.d.ts +2 -1
  26. package/dist/codebase-index/vector-search.d.ts +12 -0
  27. package/dist/codebase-index/wal-maintenance.d.ts +58 -0
  28. package/dist/codebase-index/worker-protocol/contracts.d.ts +44 -0
  29. package/dist/codebase-index/worker-protocol.d.ts +17 -1
  30. package/dist/codebase-index/worker.js +2300 -1020
  31. package/dist/codebase-index/writer-admin.d.ts +11 -0
  32. package/dist/codebase-index/writer-helpers.d.ts +31 -1
  33. package/dist/codebase-index/writer-mutations.d.ts +0 -6
  34. package/dist/codebase-index/writer-schema.d.ts +2 -2
  35. package/dist/codebase-index/writer.d.ts +15 -0
  36. package/dist/edit.js +2511 -1203
  37. package/dist/exec.js +5 -3
  38. package/dist/grep.js +5 -124
  39. package/dist/index.js +3007 -1736
  40. package/dist/json.js +5 -124
  41. package/dist/kanban.js +130 -0
  42. package/dist/logs.js +5 -121
  43. package/dist/pack.js +3011 -1677
  44. package/dist/patch.js +2524 -1216
  45. package/dist/plan.js +106 -0
  46. package/dist/read.js +2506 -1198
  47. package/dist/replace.js +2487 -1295
  48. package/dist/search.js +6 -2
  49. package/dist/session-kanban.js +24 -16
  50. package/dist/task.js +106 -0
  51. package/dist/todo.js +106 -0
  52. package/dist/tool-tier.d.ts +11 -0
  53. package/dist/tool-tier.js +3019 -1677
  54. package/dist/tree.js +14 -3
  55. package/dist/win32.js +3 -3
  56. package/dist/write.js +2513 -1205
  57. package/package.json +5 -4
@@ -9,6 +9,17 @@ export declare function getAllIndexableWithStatement(stmt: PrepareStatement): Ar
9
9
  export declare function getMaxSymbolIdWithStatement(stmt: PrepareStatement): number;
10
10
  export declare function getStatsWithStatement(stmt: PrepareStatement, indexDir: string): IndexStats;
11
11
  export declare function getMetadataWithStatement(stmt: PrepareStatement, key: string): string | undefined;
12
+ /**
13
+ * P2.5: minimal index summary for search responses. Carries exactly the two
14
+ * fields the search tool's zero-hit heuristic consumes (`totalFiles`,
15
+ * `lastIndexed`) — NOT the full IndexStats — so a zero-hit query answers
16
+ * "is there a persisted index at all?" without a second stats IPC round trip.
17
+ */
18
+ export interface IndexSummary {
19
+ totalFiles: number;
20
+ lastIndexed: number | null;
21
+ }
22
+ export declare function getIndexSummaryWithStatement(stmt: PrepareStatement): IndexSummary;
12
23
  export declare function getFileMetaWithStatement(stmt: PrepareStatement, file: string): FileMeta | null;
13
24
  export declare function getAllFileMetasWithStatement(stmt: PrepareStatement): FileMeta[];
14
25
  export declare function getIndexDbSizeBytes(indexDir: string): number;
@@ -1,5 +1,35 @@
1
- import type { Ref, Symbol as IndexSymbol } from './schema.js';
1
+ import type { Symbol as IndexSymbol, Ref } from './schema.js';
2
2
  export declare function escapeLike(value: string): string;
3
+ /**
4
+ * Split `total` into chunk sizes drawn from a powers-of-two ladder (each ≤
5
+ * `max`), largest first. Example: total=1000, max=450 → [256, 256, 256, 128,
6
+ * 64, 32, 8]. Distinct sizes ≤ log2(max)+1, so the same INSERT statement
7
+ * re-prepares at most ~9 times ever — after that every chunk size is a cache
8
+ * hit. INSERT VALUES rows cannot be padded (padding would insert garbage
9
+ * rows), so variable-size chunks are the only option there — this makes the
10
+ * variability bounded and tiny.
11
+ */
12
+ export declare function ladderChunkSizes(total: number, max: number): number[];
13
+ /**
14
+ * Pad `values` up to the next power-of-two length by repeating `values[0]`,
15
+ * for single-statement IN-lists whose size is caller-determined (not chunked
16
+ * by us). Safe because IN is set semantics: `x IN (a, a, b)` ≡ `x IN (a, b)`.
17
+ * The bind overhead is at most ~2×, and every list length maps to one of
18
+ * ~10 SQL strings instead of one per distinct count.
19
+ */
20
+ export declare function padToInBucket<T>(values: readonly T[]): T[];
21
+ /** Placeholder string with `count` bind markers — `count` should be a bucket. */
22
+ export declare function placeholders(count: number): string;
23
+ /**
24
+ * Chunk plan for IN-list sites (the pad-able counterpart to
25
+ * {@link ladderChunkSizes}). When the whole list fits under `max`, it is ONE
26
+ * chunk — a single statement, exactly like the pre-P4.12 code — and SQL-string
27
+ * stability comes from {@link padToInBucket} instead. Only a list that exceeds
28
+ * `max` is ladder-split, with the ladder capped at the largest power of two ≤
29
+ * max so chunks are already bucket sizes (padding is a no-op on them) and
30
+ * can never pad past the variable budget.
31
+ */
32
+ export declare function inListChunks(total: number, max: number): number[];
3
33
  /** Normalize an indexed or user-supplied file path for comparison. */
4
34
  export declare function posixIndexPath(file: string): string;
5
35
  /**
@@ -17,10 +17,4 @@ export declare function deleteSymbolsForFileWithStatement(stmtFn: (sql: string)
17
17
  export declare function deleteFileWithStatement(stmtFn: (sql: string) => ReturnType<DatabaseSync['prepare']>, ftsAvailable: boolean, vectorsAvailable: boolean, invalidateIncomingRefsForFiles: (files: readonly string[]) => Set<string>, resolveRefsForNamesUnsafe: (names: Iterable<string>) => number, file: string): void;
18
18
  export declare function upsertFileWithStatement(stmtFn: (sql: string) => ReturnType<DatabaseSync['prepare']>, meta: FileMeta): void;
19
19
  export declare function setFilePackagesWithStatement(stmtFn: (sql: string) => ReturnType<DatabaseSync['prepare']>, entries: ReadonlyMap<string, string>): void;
20
- export declare function applyImportResolutionsWithStatement(db: DatabaseSync, stmtFn: (sql: string) => ReturnType<DatabaseSync['prepare']>, maxSqlVars: number, resolutions: ReadonlyArray<{
21
- fromFile: string;
22
- lang: string;
23
- module: string;
24
- toFile: string;
25
- }>): number;
26
20
  //# sourceMappingURL=writer-mutations.d.ts.map
@@ -1,7 +1,7 @@
1
1
  export declare const METADATA_TABLE_SQL = "\n CREATE TABLE IF NOT EXISTS metadata (\n key TEXT PRIMARY KEY,\n value TEXT NOT NULL\n );\n";
2
- export declare const CORE_TABLES_SQL = "\n CREATE TABLE IF NOT EXISTS files (\n file TEXT PRIMARY KEY,\n lang TEXT NOT NULL,\n mtime_ms INTEGER NOT NULL,\n -- Phase 2: xxHash64 of the file's UTF-8 bytes. Empty string when the\n -- indexer hasn't populated it yet (legacy rows, schema repaired by\n -- repairMissingColumns). Compared on incremental re-index so that a\n -- touch or branch-switch that leaves content byte-identical skips the\n -- expensive parse phase entirely (refactoring proposal Phase 2).\n content_hash TEXT NOT NULL DEFAULT '',\n symbol_count INTEGER NOT NULL DEFAULT 0,\n last_indexed INTEGER NOT NULL,\n -- Code Atlas grouping label, computed at index time from the ecosystem's\n -- own manifests (package.json, go.mod, Cargo.toml, \u2026). Stored rather than\n -- re-derived per query because the evidence lives on disk, not in the DB.\n package TEXT NOT NULL DEFAULT ''\n );\n CREATE TABLE IF NOT EXISTS symbols (\n id INTEGER PRIMARY KEY,\n lang TEXT NOT NULL,\n kind TEXT NOT NULL,\n name TEXT NOT NULL,\n file TEXT NOT NULL,\n line INTEGER NOT NULL,\n col INTEGER NOT NULL,\n signature TEXT NOT NULL DEFAULT '',\n doc_comment TEXT NOT NULL DEFAULT '',\n scope TEXT NOT NULL DEFAULT '',\n text TEXT NOT NULL DEFAULT '',\n file_fk TEXT NOT NULL\n );\n";
2
+ export declare const CORE_TABLES_SQL = "\n CREATE TABLE IF NOT EXISTS files (\n file TEXT PRIMARY KEY,\n lang TEXT NOT NULL,\n mtime_ms INTEGER NOT NULL,\n -- Phase 2: xxHash64 of the file's UTF-8 bytes. Empty string when the\n -- indexer hasn't populated it yet (legacy rows, schema repaired by\n -- repairMissingColumns). Compared on incremental re-index so that a\n -- touch or branch-switch that leaves content byte-identical skips the\n -- expensive parse phase entirely (refactoring proposal Phase 2).\n content_hash TEXT NOT NULL DEFAULT '',\n symbol_count INTEGER NOT NULL DEFAULT 0,\n last_indexed INTEGER NOT NULL,\n -- Code Atlas grouping label, computed at index time from the ecosystem's\n -- own manifests (package.json, go.mod, Cargo.toml, \u2026). Stored rather than\n -- re-derived per query because the evidence lives on disk, not in the DB.\n package TEXT NOT NULL DEFAULT ''\n );\n CREATE TABLE IF NOT EXISTS symbols (\n id INTEGER PRIMARY KEY,\n lang TEXT NOT NULL,\n kind TEXT NOT NULL,\n name TEXT NOT NULL,\n file TEXT NOT NULL,\n line INTEGER NOT NULL,\n col INTEGER NOT NULL,\n signature TEXT NOT NULL DEFAULT '',\n doc_comment TEXT NOT NULL DEFAULT '',\n scope TEXT NOT NULL DEFAULT '',\n text TEXT NOT NULL DEFAULT ''\n );\n";
3
3
  export declare const FILE_INDEX_SQL: readonly ['CREATE INDEX IF NOT EXISTS idx_f_package ON files(package)'];
4
- export declare const SYMBOL_INDEX_SQL: readonly ['CREATE INDEX IF NOT EXISTS idx_s_name ON symbols(name)', 'CREATE INDEX IF NOT EXISTS idx_s_kind ON symbols(kind)', 'CREATE INDEX IF NOT EXISTS idx_s_lang ON symbols(lang)', 'CREATE INDEX IF NOT EXISTS idx_s_file ON symbols(file)', 'CREATE INDEX IF NOT EXISTS idx_s_lang_kind ON symbols(lang, kind)', 'CREATE INDEX IF NOT EXISTS idx_s_file_fk ON symbols(file_fk)', 'CREATE INDEX IF NOT EXISTS idx_s_name_id ON symbols(name, id)'];
4
+ export declare const SYMBOL_INDEX_SQL: readonly ['CREATE INDEX IF NOT EXISTS idx_s_name ON symbols(name)', 'CREATE INDEX IF NOT EXISTS idx_s_kind ON symbols(kind)', 'CREATE INDEX IF NOT EXISTS idx_s_lang ON symbols(lang)', 'CREATE INDEX IF NOT EXISTS idx_s_file ON symbols(file)', 'CREATE INDEX IF NOT EXISTS idx_s_lang_kind ON symbols(lang, kind)', 'CREATE INDEX IF NOT EXISTS idx_s_name_id ON symbols(name, id)'];
5
5
  export declare const REFS_TABLE_SQL = "\n CREATE TABLE IF NOT EXISTS refs (\n id INTEGER PRIMARY KEY,\n from_id INTEGER NOT NULL,\n to_name TEXT NOT NULL,\n to_id INTEGER,\n call_type TEXT NOT NULL,\n line INTEGER NOT NULL,\n lang TEXT NOT NULL DEFAULT '',\n module TEXT,\n to_file TEXT\n );\n";
6
6
  export declare const REFS_INDEX_SQL: readonly ['CREATE INDEX IF NOT EXISTS idx_r_from ON refs(from_id)', 'CREATE INDEX IF NOT EXISTS idx_r_to_id ON refs(to_id)', 'CREATE INDEX IF NOT EXISTS idx_r_to_name ON refs(to_name)', 'CREATE INDEX IF NOT EXISTS idx_r_call_type ON refs(call_type)', 'CREATE INDEX IF NOT EXISTS idx_r_to_name_lang ON refs(to_name, lang)', 'CREATE INDEX IF NOT EXISTS idx_r_module ON refs(module)', 'CREATE INDEX IF NOT EXISTS idx_r_to_file ON refs(to_file)'];
7
7
  /**
@@ -1,4 +1,5 @@
1
1
  import type { CallSite, CodeMapGraph, FileMeta, IndexStats, Symbol as IndexSymbol, Ref, SearchResult, SymbolKind, SymbolLang } from './schema.js';
2
+ import { type IndexSummary } from './writer-admin.js';
2
3
  import type { WriterSearchFilter } from './writer-search-helpers.js';
3
4
  import { StorePool } from './writer-store-pool.js';
4
5
  export { codebaseIndexDirOverride, resolveIndexDir } from './writer-helpers.js';
@@ -70,6 +71,8 @@ export declare class IndexStore {
70
71
  }>;
71
72
  getMaxSymbolId(): number;
72
73
  getStats(): IndexStats;
74
+ /** P2.5: minimal summary for search-response piggyback (see writer-admin). */
75
+ getIndexSummary(): IndexSummary;
73
76
  setLastIndexed(ts: number): void;
74
77
  getMetadata(key: string): string | undefined;
75
78
  setMetadata(key: string, value: string): void;
@@ -92,6 +95,18 @@ export declare class IndexStore {
92
95
  resolveRefsForNames(names: Iterable<string>): number;
93
96
  replaceEmptyFile(meta: FileMeta): void;
94
97
  optimize(): void;
98
+ /**
99
+ * P4.14: best-effort WAL checkpoint for idle-time maintenance.
100
+ *
101
+ * `wal_autocheckpoint` is PASSIVE and only attempts work after a COMMIT —
102
+ * once writes stop, nothing fires again, so the WAL keeps whatever frames
103
+ * the last burst left. This probes with PASSIVE first (never blocks; busy=1
104
+ * means readers still hold WAL snapshots) and only issues the TRUNCATE —
105
+ * which resets index.db-wal to zero bytes — when the checkpointer can
106
+ * proceed immediately. Callers run this on the daemon's single thread, so
107
+ * never wait on readers here: busy means "retry at the next idle window".
108
+ */
109
+ checkpointWal(): boolean;
95
110
  compactIfNeeded(options?: {
96
111
  minBytes?: number;
97
112
  minFreeRatio?: number;