@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
@@ -6,6 +6,12 @@ import { IndexStore } from './writer.js';
6
6
  * Re-resolved at the start of each index run so env profile changes apply.
7
7
  */
8
8
  export declare function resolveParallelBatch(): number;
9
+ /**
10
+ * Pool startup is amortized across the complete index run, not one outer
11
+ * batch. Balanced batches are capped at 40 files, so comparing the per-batch
12
+ * parse count with the 500-file threshold made the worker path unreachable.
13
+ */
14
+ export declare function shouldUseParserWorkerPool(candidateFileCount: number, parseBatchCount: number): boolean;
9
15
  interface IndexerOptions {
10
16
  projectRoot: string;
11
17
  files?: string[] | undefined;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Multi-threaded parser worker pool for bulk indexing.
3
+ *
4
+ * Spawns N worker threads (N = CPU cores - 1, clamped to [1, 4]) that share
5
+ * the file-parsing load during startup/full reindex passes. Each worker runs
6
+ * `parser-worker-script.ts`, reads files from disk, parses them via
7
+ * `parseFileContent`, and returns `FileSymbols[]`.
8
+ *
9
+ * The main thread distributes files in round-robin batches, collects results,
10
+ * and performs all SQLite writes via `commitBatch`. Workers never touch the
11
+ * database — single-writer WAL semantics are preserved.
12
+ *
13
+ * The pool is created lazily on first use and terminated on shutdown. Workers
14
+ * are `unref()`'d so they don't keep the process alive.
15
+ */
16
+ import type { FileSymbols, SymbolLang } from './schema.js';
17
+ /** Minimum number of files before the pool is worth spawning. */
18
+ export declare const WORKER_POOL_THRESHOLD = 500;
19
+ export declare class ParserWorkerPool {
20
+ private readonly maxWorkers;
21
+ private workers;
22
+ private nextBatchId;
23
+ private pending;
24
+ private creating;
25
+ private unavailable;
26
+ constructor(maxWorkers?: number);
27
+ /**
28
+ * True if the pool is available for use. Returns false when:
29
+ * - Worker threads aren't supported (sandbox, exotic runtime)
30
+ * - The built worker script can't be found
31
+ * - Pool creation was attempted and failed
32
+ */
33
+ isAvailable(): boolean;
34
+ /**
35
+ * Lazily create the worker pool. Returns true if the pool is ready, false
36
+ * if it's unavailable (caller should fall back to inline parsing).
37
+ */
38
+ ensureReady(): Promise<boolean>;
39
+ /**
40
+ * Parse files in parallel across the worker pool. Returns a flat
41
+ * `FileSymbols[]` in completion order (caller sorts if needed).
42
+ *
43
+ * Content is pre-read by the main thread (for the content-hash check)
44
+ * and passed to workers to avoid a second disk read. Files are
45
+ * distributed round-robin across workers.
46
+ */
47
+ parseFiles(files: ReadonlyArray<{
48
+ file: string;
49
+ content: string;
50
+ lang: SymbolLang;
51
+ }>): Promise<FileSymbols[]>;
52
+ /** Shut down all workers. Safe to call multiple times. */
53
+ shutdown(): Promise<void>;
54
+ private handleMessage;
55
+ private handleError;
56
+ }
57
+ /**
58
+ * Lazily-created process-wide singleton. Returns null when worker threads
59
+ * are unavailable (sandbox, exotic runtime) or the compiled worker script
60
+ * can't be found — callers must fall back to inline parsing in that case.
61
+ */
62
+ export declare function getParserPool(): ParserWorkerPool | null;
63
+ //# sourceMappingURL=parser-worker-pool.d.ts.map
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Parser worker entry point for P5's multi-threaded parser pool.
3
+ *
4
+ * Each worker in the pool runs this script. It receives batches of files,
5
+ * reads them from disk, parses them via the existing `parseFileContent`
6
+ * dispatch (which routes to tree-sitter, the TS compiler, etc.), and returns
7
+ * the parsed `FileSymbols[]` back to the main thread.
8
+ *
9
+ * Workers never touch SQLite — the main thread owns all DB writes via
10
+ * `commitBatch`. This keeps the WAL writer single-threaded and avoids
11
+ * cross-thread `node:sqlite` issues.
12
+ *
13
+ * The worker terminates cleanly when it receives a `{ type: 'shutdown' }`
14
+ * message. If the parent port closes unexpectedly, the worker exits.
15
+ */
16
+ import type { FileSymbols } from './schema.js';
17
+ import type { SymbolLang } from './schema.js';
18
+ export interface ParserWorkerRequest {
19
+ type: 'parse';
20
+ id: number;
21
+ /** Content is pre-read by the main thread for the hash check; passed here
22
+ * to avoid a second disk read in the worker. */
23
+ files: ReadonlyArray<{
24
+ file: string;
25
+ content: string;
26
+ lang: SymbolLang;
27
+ }>;
28
+ }
29
+ export interface ParserWorkerResponse {
30
+ type: 'result';
31
+ id: number;
32
+ results: FileSymbols[];
33
+ errors: ReadonlyArray<{
34
+ file: string;
35
+ error: string;
36
+ }>;
37
+ }
38
+ export interface ParserWorkerShutdown {
39
+ type: 'shutdown';
40
+ }
41
+ export type ParserWorkerInbound = ParserWorkerRequest | ParserWorkerShutdown;
42
+ //# sourceMappingURL=parser-worker-script.d.ts.map
@@ -13,6 +13,8 @@ export interface ProjectIndexServerInfo {
13
13
  indexDir: string;
14
14
  endpoint: string;
15
15
  startedAt: string;
16
+ /** P6: server can switch to binary MessagePack framing after handshake. */
17
+ binarySupported?: boolean;
16
18
  }
17
19
  export interface ProjectIndexServerActivity {
18
20
  indexing: boolean;