@wrongstack/tools 0.302.2 → 0.305.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 (44) hide show
  1. package/dist/builtin.d.ts +6 -0
  2. package/dist/builtin.js +3213 -686
  3. package/dist/codebase-index/binary-frame.d.ts +43 -0
  4. package/dist/codebase-index/codebase-incoming-calls-tool.d.ts +1 -0
  5. package/dist/codebase-index/codebase-index-tool.d.ts +6 -0
  6. package/dist/codebase-index/codebase-outgoing-calls-tool.d.ts +1 -0
  7. package/dist/codebase-index/content-hash.d.ts +66 -0
  8. package/dist/codebase-index/index.js +1597 -153
  9. package/dist/codebase-index/indexer.d.ts +6 -0
  10. package/dist/codebase-index/parser-worker-pool.d.ts +63 -0
  11. package/dist/codebase-index/parser-worker-script.d.ts +42 -0
  12. package/dist/codebase-index/project-server-protocol.d.ts +2 -0
  13. package/dist/codebase-index/project-server.js +1483 -104
  14. package/dist/codebase-index/schema.d.ts +18 -0
  15. package/dist/codebase-index/tree-sitter/queries.d.ts +48 -0
  16. package/dist/codebase-index/tree-sitter/util.d.ts +31 -0
  17. package/dist/codebase-index/tree-sitter/visitor.d.ts +47 -0
  18. package/dist/codebase-index/tree-sitter-parser.d.ts +58 -0
  19. package/dist/codebase-index/vector-search.d.ts +62 -0
  20. package/dist/codebase-index/worker-protocol.d.ts +2 -0
  21. package/dist/codebase-index/worker.js +1452 -73
  22. package/dist/codebase-index/writer-bulk-insert.d.ts +5 -0
  23. package/dist/codebase-index/writer-graph-reader.d.ts +39 -0
  24. package/dist/codebase-index/writer-schema.d.ts +9 -2
  25. package/dist/codebase-index/writer.d.ts +36 -0
  26. package/dist/index.d.ts +4 -3
  27. package/dist/index.js +3258 -727
  28. package/dist/kanban-contract-actions.d.ts +7 -0
  29. package/dist/kanban-task-inputs.d.ts +16 -2
  30. package/dist/kanban-tool-schema.d.ts +2 -2
  31. package/dist/kanban-tool-types.d.ts +39 -2
  32. package/dist/kanban.js +580 -193
  33. package/dist/pack.js +3212 -686
  34. package/dist/plan.d.ts +4 -1
  35. package/dist/plan.js +2701 -18
  36. package/dist/read.js +1559 -103
  37. package/dist/session-kanban.d.ts +94 -1
  38. package/dist/session-kanban.js +308 -44
  39. package/dist/task.d.ts +5 -4
  40. package/dist/task.js +2825 -138
  41. package/dist/todo.d.ts +10 -1
  42. package/dist/todo.js +2474 -30
  43. package/dist/tool-tier.js +3212 -686
  44. package/package.json +8 -4
@@ -20,6 +20,11 @@ export declare function bulkInsertFtsWithStatement(stmt: PrepareStatement, maxSq
20
20
  id: number;
21
21
  text: string;
22
22
  }>): void;
23
+ export interface BulkVectorRow {
24
+ id: number;
25
+ vector: Uint8Array;
26
+ }
27
+ export declare function bulkInsertVectorsWithStatement(stmt: PrepareStatement, maxSqlVars: number, rows: BulkVectorRow[]): void;
23
28
  export declare function bulkInsertRefsWithStatement(stmt: PrepareStatement, maxSqlVars: number, refs: Ref[]): void;
24
29
  export {};
25
30
  //# sourceMappingURL=writer-bulk-insert.d.ts.map
@@ -25,6 +25,45 @@ export declare function findOutgoingCallsByName(stmt: PrepareStatement, symbolNa
25
25
  unresolvedCount: number;
26
26
  totalMatches: number;
27
27
  };
28
+ /**
29
+ * Transitive incoming-call tree: all symbols that transitively call the target.
30
+ *
31
+ * Anchor: direct callers of the target symbol(s).
32
+ * Recursive: callers of callers, up to `maxDepth` hops.
33
+ *
34
+ * `UNION` (not `UNION ALL`) deduplicates per recursion level, so dependency
35
+ * cycles (A→B→C→A) terminate instead of looping.
36
+ */
37
+ export declare function findTransitiveIncomingCallsByName(stmt: PrepareStatement, symbolName: string, file: string | undefined, limit: number): {
38
+ calls: CallSite[];
39
+ symbolFound: boolean;
40
+ ambiguous: boolean;
41
+ totalMatches: number;
42
+ };
43
+ /**
44
+ * Transitive outgoing-call tree: all symbols that the target transitively calls.
45
+ *
46
+ * Anchor: direct callees of the target symbol(s).
47
+ * Recursive: callees of callees, up to `maxDepth` hops.
48
+ */
49
+ export declare function findTransitiveOutgoingCallsByName(stmt: PrepareStatement, symbolName: string, file: string | undefined, limit: number): {
50
+ calls: CallSite[];
51
+ symbolFound: boolean;
52
+ unresolvedCount: number;
53
+ totalMatches: number;
54
+ };
55
+ /**
56
+ * Compute the set of symbol IDs reachable from a set of seed IDs using a
57
+ * recursive CTE. Replaces the in-memory BFS in `dead-code-scan.ts`.
58
+ *
59
+ * The `UNION` (not `UNION ALL`) deduplication breaks dependency cycles
60
+ * automatically: A→B→C→A terminates after 3 rows.
61
+ *
62
+ * Returns a `Set<number>` of all transitively-reachable symbol IDs (including
63
+ * the seeds themselves). Callers subtract this from the full symbol set to
64
+ * find dead code.
65
+ */
66
+ export declare function findReachableSymbolIds(stmt: PrepareStatement, seedIds: number[]): Set<number>;
28
67
  export declare function findRefsToWithStatement(stmt: PrepareStatement, symbolId: number): Ref[];
29
68
  export declare function findRefsFromWithStatement(stmt: PrepareStatement, symbolId: number): Ref[];
30
69
  export declare function getPackageGraphWithStatement(stmt: PrepareStatement): CodeMapGraph;
@@ -1,5 +1,5 @@
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 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 file_fk TEXT NOT NULL\n );\n";
3
3
  export declare const FILE_INDEX_SQL: readonly ['CREATE INDEX IF NOT EXISTS idx_f_package ON files(package)'];
4
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)'];
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";
@@ -15,5 +15,12 @@ export declare const REFS_INDEX_SQL: readonly ['CREATE INDEX IF NOT EXISTS idx_r
15
15
  export declare const LANG_FAMILY_TABLE_SQL = "\n CREATE TABLE IF NOT EXISTS lang_family (\n lang TEXT PRIMARY KEY,\n family TEXT NOT NULL\n );\n";
16
16
  /** Family value that matches every symbol family, used by language-less refs. */
17
17
  export declare const LANG_FAMILY_WILDCARD = "*";
18
- export declare const SYMBOLS_FTS_SQL = "CREATE VIRTUAL TABLE IF NOT EXISTS symbols_fts USING fts5(text, tokenize = 'unicode61')";
18
+ export declare const SYMBOLS_FTS_SQL = "CREATE VIRTUAL TABLE IF NOT EXISTS symbols_fts USING fts5(text, tokenize = 'trigram')";
19
+ /**
20
+ * Phase 3: stores 384-dimensional float32 embedding vectors for each symbol.
21
+ * Vectors are computed from the symbol's indexable text (name + signature +
22
+ * doc_comment) via the character n-gram hashing embedding in vector-search.ts.
23
+ * One row per symbol, kept in sync via insertSymbols, delete, and clearAll.
24
+ */
25
+ export declare const SYMBOL_VECTORS_TABLE_SQL = "\n CREATE TABLE IF NOT EXISTS symbol_vectors (\n symbol_id INTEGER PRIMARY KEY,\n vector BLOB NOT NULL,\n FOREIGN KEY (symbol_id) REFERENCES symbols(id) ON DELETE CASCADE\n );\n";
19
26
  //# sourceMappingURL=writer-schema.d.ts.map
@@ -12,6 +12,12 @@ export declare class IndexStore {
12
12
  * When false, ranked search falls back to the LIKE + in-process BM25 path.
13
13
  */
14
14
  private ftsAvailable;
15
+ /**
16
+ * Phase 3: true when the `symbol_vectors` table was created successfully.
17
+ * When false, hybrid search skips the vector pass and falls back to FTS5
18
+ * (or LIKE) only.
19
+ */
20
+ private vectorsAvailable;
15
21
  /**
16
22
  * Cache of prepared statements keyed by their SQL text. `DatabaseSync`
17
23
  * compiles SQL on every `.prepare()` call; for the fixed-SQL methods
@@ -286,6 +292,7 @@ export declare class IndexStore {
286
292
  refs: Ref[];
287
293
  mtimeMs: number;
288
294
  symbolCount: number;
295
+ contentHash?: string | undefined;
289
296
  }>, options?: {
290
297
  deleteForFiles?: string[] | undefined;
291
298
  }): IndexSymbol[];
@@ -345,6 +352,35 @@ export declare class IndexStore {
345
352
  unresolvedCount: number;
346
353
  totalMatches: number;
347
354
  };
355
+ /**
356
+ * Transitive incoming-call tree: all symbols that transitively call the
357
+ * target, to an unbounded depth (cycle-safe via SQL UNION deduplication).
358
+ * Used by `codebase-incoming-calls` when the caller wants the full call
359
+ * chain rather than just direct callers.
360
+ */
361
+ findTransitiveIncomingCallsByName(symbolName: string, file?: string, limit?: number): {
362
+ calls: CallSite[];
363
+ symbolFound: boolean;
364
+ ambiguous: boolean;
365
+ totalMatches: number;
366
+ };
367
+ /**
368
+ * Transitive outgoing-call tree: all symbols the target transitively calls.
369
+ * Used by `codebase-outgoing-calls` when the caller wants the full
370
+ * dependency chain rather than just direct callees.
371
+ */
372
+ findTransitiveOutgoingCallsByName(symbolName: string, file?: string, limit?: number): {
373
+ calls: CallSite[];
374
+ symbolFound: boolean;
375
+ unresolvedCount: number;
376
+ totalMatches: number;
377
+ };
378
+ /**
379
+ * Compute the set of symbol IDs reachable from the given seed IDs using a
380
+ * native SQLite recursive CTE. Used by dead-code detection to replace the
381
+ * in-memory BFS.
382
+ */
383
+ findReachableSymbolIds(seedIds: number[]): Set<number>;
348
384
  /**
349
385
  * Find all references TO a given symbol (who calls / uses this symbol?).
350
386
  */
package/dist/index.d.ts CHANGED
@@ -5,10 +5,10 @@ export { auditTool } from './audit.js';
5
5
  export { bashTool } from './bash.js';
6
6
  export { batchToolUseTool } from './batch-tool-use.js';
7
7
  export * from './browser/index.js';
8
- export { builtinTools, OPTIONAL_TOOLS, TIER1_TOOLS, TIER2_TOOLS, TIER3_TOOLS } from './builtin.js';
8
+ export { builtinTools, OFF_ONLY_TOOLS, OPTIONAL_TOOLS, TIER1_TOOLS, TIER2_TOOLS, TIER3_TOOLS, } from './builtin.js';
9
9
  export { CircuitBreaker, type CircuitBreakerConfig, type CircuitBreakerSnapshot, } from './circuit-breaker.js';
10
10
  export type { CircuitSnapshot, CircuitState, CodeMapGraph, DeadCodeScanInput, DeadCodeScanOutput, DeadFile, DeadPackage, DeadSymbol, GraphEdge, GraphNode, ProjectIndexDaemonAvailability, ProjectIndexServerActivity, ProjectIndexServerClientHealth, ProjectIndexServerConnectionState, ProjectIndexServerConnectionStatus, ProjectIndexServerHealth, } from './codebase-index/index.js';
11
- export { CircuitOpenError, cancelPendingReindexes, checkCodebaseIndexServerHealth, resolveProjectIndexDaemonAvailability, codebaseIndexStats, codebaseIndexTool, codebaseSearchTool, codebaseStatsTool, deadCodeScanTool, enqueueReindex, ensureCodebaseIndexServer, fileGraphService, getIndexState, IndexCircuitBreaker, IndexTimeoutError, indexCircuitBreaker, isIndexableFile, isIndexing, isIndexReady, onIndexStateChange, packageGraphService, resetIndexCircuitBreaker, runDeadCodeScan, runStartupIndex, searchCodebaseIndex, shutdownCodebaseIndexHost, shutdownCodebaseIndexServer, symbolGraphService, } from './codebase-index/index.js';
11
+ export { CircuitOpenError, cancelPendingReindexes, checkCodebaseIndexServerHealth, codebaseIndexStats, codebaseIndexTool, codebaseSearchTool, codebaseStatsTool, deadCodeScanTool, enqueueReindex, ensureCodebaseIndexServer, fileGraphService, getIndexState, IndexCircuitBreaker, IndexTimeoutError, indexCircuitBreaker, isIndexableFile, isIndexing, isIndexReady, onIndexStateChange, packageGraphService, resetIndexCircuitBreaker, resolveProjectIndexDaemonAvailability, runDeadCodeScan, runStartupIndex, searchCodebaseIndex, shutdownCodebaseIndexHost, shutdownCodebaseIndexServer, symbolGraphService, } from './codebase-index/index.js';
12
12
  export { designTool } from './design.js';
13
13
  export { diffTool } from './diff.js';
14
14
  export { documentTool } from './document.js';
@@ -43,8 +43,9 @@ export { readTool } from './read.js';
43
43
  export { replaceTool } from './replace.js';
44
44
  export { scaffoldTool } from './scaffold.js';
45
45
  export { searchTool } from './search.js';
46
- export { applySessionKanbanBoardToTodos, applySessionKanbanTaskToSource, attachSessionKanbanMirror, ensureSessionKanbanBoard, hydrateSessionKanban, mirrorSessionPlanToKanban, mirrorSessionTasksToKanban, mirrorSessionTodosToKanban, projectSessionPlanToKanban, projectSessionTasksToKanban, projectSessionTodosToKanban, SESSION_KANBAN_COLUMNS, } from './session-kanban.js';
46
+ export { applySessionKanbanBoardToTodos, applySessionKanbanTaskToSource, attachSessionKanbanMirror, ensureSessionKanbanBoard, hydrateSessionKanban, mirrorSessionPlanToKanban, mirrorSessionTasksToKanban, mirrorSessionTodosToKanban, projectSessionPlanToKanban, projectSessionTasksToKanban, projectSessionTodosToKanban, rebindSessionKanbanTask, SESSION_KANBAN_COLUMNS, } from './session-kanban.js';
47
47
  export { makeSkillTool } from './skill.js';
48
+ export { taskTool } from './task.js';
48
49
  export { testTool } from './test.js';
49
50
  export { todoTool } from './todo.js';
50
51
  export { toolHelpTool } from './tool-help.js';