@wrongstack/tools 0.295.1 → 0.296.3

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 (132) hide show
  1. package/dist/auto-proceed-loop-guard.d.ts +67 -0
  2. package/dist/auto-proceed-loop-guard.d.ts.map +1 -1
  3. package/dist/auto-proceed-loop-guard.js +95 -0
  4. package/dist/auto-proceed-loop-guard.js.map +2 -2
  5. package/dist/bash.js +53 -18
  6. package/dist/bash.js.map +2 -2
  7. package/dist/browser/artifacts.d.ts +2 -0
  8. package/dist/browser/artifacts.d.ts.map +1 -1
  9. package/dist/browser/index.js +58 -7
  10. package/dist/browser/index.js.map +2 -2
  11. package/dist/browser/network-guard-proxy.d.ts.map +1 -1
  12. package/dist/builtin.d.ts +2 -2
  13. package/dist/builtin.d.ts.map +1 -1
  14. package/dist/builtin.js +9516 -7476
  15. package/dist/builtin.js.map +4 -4
  16. package/dist/codebase-index/background-indexer.d.ts +28 -2
  17. package/dist/codebase-index/background-indexer.d.ts.map +1 -1
  18. package/dist/codebase-index/codebase-index-tool.d.ts.map +1 -1
  19. package/dist/codebase-index/dead-code-scan.d.ts +77 -0
  20. package/dist/codebase-index/dead-code-scan.d.ts.map +1 -0
  21. package/dist/codebase-index/index-service.d.ts +4 -3
  22. package/dist/codebase-index/index-service.d.ts.map +1 -1
  23. package/dist/codebase-index/index.d.ts +11 -8
  24. package/dist/codebase-index/index.d.ts.map +1 -1
  25. package/dist/codebase-index/index.js +5217 -3503
  26. package/dist/codebase-index/index.js.map +4 -4
  27. package/dist/codebase-index/indexer.d.ts +2 -0
  28. package/dist/codebase-index/indexer.d.ts.map +1 -1
  29. package/dist/codebase-index/parser-dispatch.d.ts +8 -0
  30. package/dist/codebase-index/parser-dispatch.d.ts.map +1 -0
  31. package/dist/codebase-index/project-server-cache.d.ts +11 -0
  32. package/dist/codebase-index/project-server-cache.d.ts.map +1 -0
  33. package/dist/codebase-index/project-server-client.d.ts +74 -0
  34. package/dist/codebase-index/project-server-client.d.ts.map +1 -0
  35. package/dist/codebase-index/project-server-endpoint.d.ts +24 -0
  36. package/dist/codebase-index/project-server-endpoint.d.ts.map +1 -0
  37. package/dist/codebase-index/project-server-protocol.d.ts +88 -0
  38. package/dist/codebase-index/project-server-protocol.d.ts.map +1 -0
  39. package/dist/codebase-index/project-server.d.ts +11 -0
  40. package/dist/codebase-index/project-server.d.ts.map +1 -0
  41. package/dist/codebase-index/project-server.js +5136 -0
  42. package/dist/codebase-index/project-server.js.map +7 -0
  43. package/dist/codebase-index/refs-extractor.d.ts +1 -0
  44. package/dist/codebase-index/refs-extractor.d.ts.map +1 -1
  45. package/dist/codebase-index/schema.d.ts +11 -0
  46. package/dist/codebase-index/schema.d.ts.map +1 -1
  47. package/dist/codebase-index/sqlite-runtime.d.ts +9 -0
  48. package/dist/codebase-index/sqlite-runtime.d.ts.map +1 -0
  49. package/dist/codebase-index/ts-parser.d.ts +5 -1
  50. package/dist/codebase-index/ts-parser.d.ts.map +1 -1
  51. package/dist/codebase-index/worker-protocol.d.ts +19 -1
  52. package/dist/codebase-index/worker-protocol.d.ts.map +1 -1
  53. package/dist/codebase-index/worker.js +3927 -3413
  54. package/dist/codebase-index/worker.js.map +4 -4
  55. package/dist/codebase-index/writer-admin.d.ts +16 -0
  56. package/dist/codebase-index/writer-admin.d.ts.map +1 -0
  57. package/dist/codebase-index/writer-bulk-insert.d.ts +25 -0
  58. package/dist/codebase-index/writer-bulk-insert.d.ts.map +1 -0
  59. package/dist/codebase-index/writer-graph-helpers.d.ts +52 -0
  60. package/dist/codebase-index/writer-graph-helpers.d.ts.map +1 -0
  61. package/dist/codebase-index/writer-graph-reader.d.ts +11 -0
  62. package/dist/codebase-index/writer-graph-reader.d.ts.map +1 -0
  63. package/dist/codebase-index/writer-helpers.d.ts +15 -0
  64. package/dist/codebase-index/writer-helpers.d.ts.map +1 -0
  65. package/dist/codebase-index/writer-pragmas.d.ts +3 -0
  66. package/dist/codebase-index/writer-pragmas.d.ts.map +1 -0
  67. package/dist/codebase-index/writer-ref-mapper.d.ts +11 -0
  68. package/dist/codebase-index/writer-ref-mapper.d.ts.map +1 -0
  69. package/dist/codebase-index/writer-schema.d.ts +7 -0
  70. package/dist/codebase-index/writer-schema.d.ts.map +1 -0
  71. package/dist/codebase-index/writer-search-helpers.d.ts +28 -0
  72. package/dist/codebase-index/writer-search-helpers.d.ts.map +1 -0
  73. package/dist/codebase-index/writer-store-pool.d.ts +45 -0
  74. package/dist/codebase-index/writer-store-pool.d.ts.map +1 -0
  75. package/dist/codebase-index/writer.d.ts +72 -89
  76. package/dist/codebase-index/writer.d.ts.map +1 -1
  77. package/dist/exec.js +53 -18
  78. package/dist/exec.js.map +2 -2
  79. package/dist/index.d.ts +2 -2
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +9860 -7824
  82. package/dist/index.js.map +4 -4
  83. package/dist/kanban-board-inputs.d.ts +34 -0
  84. package/dist/kanban-board-inputs.d.ts.map +1 -0
  85. package/dist/kanban-decomposition-actions.d.ts +4 -0
  86. package/dist/kanban-decomposition-actions.d.ts.map +1 -0
  87. package/dist/kanban-detail-actions.d.ts +3 -0
  88. package/dist/kanban-detail-actions.d.ts.map +1 -0
  89. package/dist/kanban-presence.d.ts +10 -0
  90. package/dist/kanban-presence.d.ts.map +1 -0
  91. package/dist/kanban-split-task-handler.d.ts +6 -0
  92. package/dist/kanban-split-task-handler.d.ts.map +1 -0
  93. package/dist/kanban-task-inputs.d.ts +73 -0
  94. package/dist/kanban-task-inputs.d.ts.map +1 -0
  95. package/dist/kanban-tool-results.d.ts +14 -0
  96. package/dist/kanban-tool-results.d.ts.map +1 -0
  97. package/dist/kanban-tool-schema.d.ts +5 -0
  98. package/dist/kanban-tool-schema.d.ts.map +1 -0
  99. package/dist/kanban-tool-types.d.ts +135 -0
  100. package/dist/kanban-tool-types.d.ts.map +1 -0
  101. package/dist/kanban.d.ts +2 -146
  102. package/dist/kanban.d.ts.map +1 -1
  103. package/dist/kanban.js +1030 -825
  104. package/dist/kanban.js.map +4 -4
  105. package/dist/pack.js +9515 -7476
  106. package/dist/pack.js.map +4 -4
  107. package/dist/plan.js +2 -2
  108. package/dist/plan.js.map +2 -2
  109. package/dist/process-registry-persistent.d.ts +1 -0
  110. package/dist/process-registry-persistent.d.ts.map +1 -1
  111. package/dist/ps-slash.js +53 -18
  112. package/dist/ps-slash.js.map +2 -2
  113. package/dist/read.d.ts +31 -0
  114. package/dist/read.d.ts.map +1 -1
  115. package/dist/read.js +5434 -78
  116. package/dist/read.js.map +4 -4
  117. package/dist/replace.js +8 -0
  118. package/dist/replace.js.map +2 -2
  119. package/dist/session-kanban.d.ts.map +1 -1
  120. package/dist/session-kanban.js +15 -20
  121. package/dist/session-kanban.js.map +2 -2
  122. package/dist/task.d.ts.map +1 -1
  123. package/dist/task.js +48 -6
  124. package/dist/task.js.map +2 -2
  125. package/dist/todo.d.ts.map +1 -1
  126. package/dist/todo.js +47 -5
  127. package/dist/todo.js.map +2 -2
  128. package/dist/tool-tier.js +9517 -7477
  129. package/dist/tool-tier.js.map +4 -4
  130. package/package.json +5 -5
  131. package/dist/shim/node-sqlite.d.ts +0 -3
  132. package/dist/shim/node-sqlite.d.ts.map +0 -1
@@ -0,0 +1,16 @@
1
+ import type { DatabaseSync } from 'node:sqlite';
2
+ import type { FileMeta, IndexStats } from './schema.js';
3
+ type Statement = ReturnType<DatabaseSync['prepare']>;
4
+ type PrepareStatement = (sql: string) => Statement;
5
+ export declare function getAllIndexableWithStatement(stmt: PrepareStatement): Array<{
6
+ id: number;
7
+ text: string;
8
+ }>;
9
+ export declare function getMaxSymbolIdWithStatement(stmt: PrepareStatement): number;
10
+ export declare function getStatsWithStatement(stmt: PrepareStatement, indexDir: string): IndexStats;
11
+ export declare function getMetadataWithStatement(stmt: PrepareStatement, key: string): string | undefined;
12
+ export declare function getFileMetaWithStatement(stmt: PrepareStatement, file: string): FileMeta | null;
13
+ export declare function getAllFileMetasWithStatement(stmt: PrepareStatement): FileMeta[];
14
+ export declare function getIndexDbSizeBytes(indexDir: string): number;
15
+ export {};
16
+ //# sourceMappingURL=writer-admin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer-admin.d.ts","sourceRoot":"","sources":["../../src/codebase-index/writer-admin.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAA0B,MAAM,aAAa,CAAC;AAKhF,KAAK,SAAS,GAAG,UAAU,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;AACrD,KAAK,gBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,SAAS,CAAC;AAEnD,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,gBAAgB,GACrB,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAIrC;AAED,wBAAgB,2BAA2B,CAAC,IAAI,EAAE,gBAAgB,GAAG,MAAM,CAK1E;AAED,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CA+B1F;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,gBAAgB,EACtB,GAAG,EAAE,MAAM,GACV,MAAM,GAAG,SAAS,CAKpB;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,gBAAgB,EACtB,IAAI,EAAE,MAAM,GACX,QAAQ,GAAG,IAAI,CAmBjB;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,gBAAgB,GAAG,QAAQ,EAAE,CAgB/E;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAM5D"}
@@ -0,0 +1,25 @@
1
+ import type { DatabaseSync } from 'node:sqlite';
2
+ import type { Ref } from './schema.js';
3
+ type Statement = ReturnType<DatabaseSync['prepare']>;
4
+ type PrepareStatement = (sql: string) => Statement;
5
+ export interface BulkSymbolRow {
6
+ id: number;
7
+ lang: string;
8
+ kind: string;
9
+ name: string;
10
+ file: string;
11
+ line: number;
12
+ col: number;
13
+ signature: string;
14
+ docComment: string;
15
+ scope: string;
16
+ text: string;
17
+ }
18
+ export declare function bulkInsertSymbolsWithStatement(stmt: PrepareStatement, maxSqlVars: number, rows: BulkSymbolRow[]): void;
19
+ export declare function bulkInsertFtsWithStatement(stmt: PrepareStatement, maxSqlVars: number, ftsAvailable: boolean, rows: Array<{
20
+ id: number;
21
+ text: string;
22
+ }>): void;
23
+ export declare function bulkInsertRefsWithStatement(stmt: PrepareStatement, maxSqlVars: number, refs: Ref[]): void;
24
+ export {};
25
+ //# sourceMappingURL=writer-bulk-insert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer-bulk-insert.d.ts","sourceRoot":"","sources":["../../src/codebase-index/writer-bulk-insert.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAEvC,KAAK,SAAS,GAAG,UAAU,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;AACrD,KAAK,gBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,SAAS,CAAC;AAEnD,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,8BAA8B,CAC5C,IAAI,EAAE,gBAAgB,EACtB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,aAAa,EAAE,GACpB,IAAI,CA6BN;AAED,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,gBAAgB,EACtB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,OAAO,EACrB,IAAI,EAAE,KAAK,CAAC;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GACxC,IAAI,CAWN;AAED,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,gBAAgB,EACtB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,GAAG,EAAE,GACV,IAAI,CAeN"}
@@ -0,0 +1,52 @@
1
+ import type { GraphEdge, GraphNode, SymbolLang } from './schema.js';
2
+ /**
3
+ * Derive a monorepo package name from an absolute file path.
4
+ * Handles both `packages/<name>/...` and `apps/<name>/...` layouts.
5
+ */
6
+ export declare function derivePackage(filePath: string): string | undefined;
7
+ export declare function packageFromImport(moduleName: string): string | undefined;
8
+ export declare function buildPackageGraphNodes(fileCounts: Array<{
9
+ file: string;
10
+ n: number;
11
+ }>, files: Array<{
12
+ file: string;
13
+ }>): {
14
+ pkgNodes: Map<string, GraphNode>;
15
+ fileToPkg: Map<string, string>;
16
+ };
17
+ export type WriterFileGraphSymbolRow = {
18
+ file: string;
19
+ id: number;
20
+ name: string;
21
+ kind: string;
22
+ lang: string;
23
+ line: number;
24
+ };
25
+ export declare function buildFileGraphNodeState(pkgSyms: WriterFileGraphSymbolRow[], localFiles: Set<string>): {
26
+ fileNodes: Map<string, GraphNode>;
27
+ symToFile: Map<number, string>;
28
+ fileStats: Map<string, {
29
+ count: number;
30
+ lang: SymbolLang;
31
+ }>;
32
+ ensureFileNode: (file: string) => void;
33
+ };
34
+ export type WriterSymbolGraphRow = {
35
+ id: number;
36
+ name: string;
37
+ kind: string;
38
+ lang: string;
39
+ file: string;
40
+ line: number;
41
+ signature: string;
42
+ scope: string;
43
+ };
44
+ export declare function buildSymbolGraphNodes(symById: Map<number, WriterSymbolGraphRow>, relatedIds: Set<number>, fileFilter: string): GraphNode[];
45
+ export declare function resolveRelativeImport(fromFile: string, moduleName: string, indexedFiles: Set<string>): string | undefined;
46
+ export type WeightedEdgeAccumulator = {
47
+ weight: number;
48
+ types: Map<string, number>;
49
+ };
50
+ export declare function addWeightedEdge(edgeMap: Map<string, WeightedEdgeAccumulator>, source: string | number, target: string | number, callType: string, weight: number): void;
51
+ export declare function materializeWeightedEdges(edgeMap: Map<string, WeightedEdgeAccumulator>, idPrefix: 'pkg' | 'file' | 'sym'): GraphEdge[];
52
+ //# sourceMappingURL=writer-graph-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer-graph-helpers.d.ts","sourceRoot":"","sources":["../../src/codebase-index/writer-graph-helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAY,SAAS,EAAE,SAAS,EAAc,UAAU,EAAE,MAAM,aAAa,CAAC;AAE1F;;;GAGG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAelE;AAED,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIxE;AAED,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,EAC9C,KAAK,EAAE,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,GAC7B;IAAE,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,CAyCtE;AAED,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAA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MAAM,CAAC,CAAC;CAC5B,CAAC;AAEF,wBAAgB,eAAe,CAC7B,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,uBAAuB,CAAC,EAC7C,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,GACb,IAAI,CASN;AAED,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,uBAAuB,CAAC,EAC7C,QAAQ,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAC/B,SAAS,EAAE,CAoBb"}
@@ -0,0 +1,11 @@
1
+ import type { DatabaseSync } from 'node:sqlite';
2
+ import type { CodeMapGraph, Ref } from './schema.js';
3
+ type Statement = ReturnType<DatabaseSync['prepare']>;
4
+ type PrepareStatement = (sql: string) => Statement;
5
+ export declare function findRefsToWithStatement(stmt: PrepareStatement, symbolId: number): Ref[];
6
+ export declare function findRefsFromWithStatement(stmt: PrepareStatement, symbolId: number): Ref[];
7
+ export declare function getPackageGraphWithStatement(stmt: PrepareStatement): CodeMapGraph;
8
+ export declare function getFileGraphWithStatement(stmt: PrepareStatement, packageFilter: string): CodeMapGraph;
9
+ export declare function getSymbolGraphWithStatement(stmt: PrepareStatement, fileFilter: string): CodeMapGraph;
10
+ export {};
11
+ //# sourceMappingURL=writer-graph-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer-graph-reader.d.ts","sourceRoot":"","sources":["../../src/codebase-index/writer-graph-reader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,GAAG,EAAc,MAAM,aAAa,CAAC;AAgBjE,KAAK,SAAS,GAAG,UAAU,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC;AACrD,KAAK,gBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,SAAS,CAAC;AAEnD,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,EAAE,CAMvF;AAED,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,GAAG,EAAE,CAMzF;AAED,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,gBAAgB,GAAG,YAAY,CA4CjF;AAED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,gBAAgB,EACtB,aAAa,EAAE,MAAM,GACpB,YAAY,CAqFd;AAED,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,gBAAgB,EACtB,UAAU,EAAE,MAAM,GACjB,YAAY,CAsDd"}
@@ -0,0 +1,15 @@
1
+ import type { Ref, Symbol as IndexSymbol } from './schema.js';
2
+ export declare function escapeLike(value: string): string;
3
+ export declare function assignRefsToSymbols(refs: Ref[], symbols: IndexSymbol[]): Ref[];
4
+ /**
5
+ * Resolve the per-project index directory. By default it lives under the
6
+ * global project dir (`~/.wrongstack/projects/<hash>/codebase-index`).
7
+ */
8
+ export declare function resolveIndexDir(projectRoot: string, override?: string): string;
9
+ /**
10
+ * Optional index-directory override carried on the run context's `meta` bag.
11
+ */
12
+ export declare function codebaseIndexDirOverride(ctx: {
13
+ meta?: Record<string, unknown>;
14
+ }): string | undefined;
15
+ //# sourceMappingURL=writer-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer-helpers.d.ts","sourceRoot":"","sources":["../../src/codebase-index/writer-helpers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,aAAa,CAAC;AAE9D,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEhD;AAED,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,GAAG,EAAE,CAmB9E;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAE9E;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,GAAG,MAAM,GAAG,SAAS,CAGrB"}
@@ -0,0 +1,3 @@
1
+ import type { DatabaseSync } from 'node:sqlite';
2
+ export declare function applyIndexStorePragmas(db: DatabaseSync): void;
3
+ //# sourceMappingURL=writer-pragmas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer-pragmas.d.ts","sourceRoot":"","sources":["../../src/codebase-index/writer-pragmas.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAe7D"}
@@ -0,0 +1,11 @@
1
+ import type { Ref } from './schema.js';
2
+ export type WriterRefRow = {
3
+ id: number;
4
+ from_id: number;
5
+ to_name: string;
6
+ to_id: number | null;
7
+ call_type: string;
8
+ line: number;
9
+ };
10
+ export declare function mapWriterRefRow(row: WriterRefRow): Ref;
11
+ //# sourceMappingURL=writer-ref-mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer-ref-mapper.d.ts","sourceRoot":"","sources":["../../src/codebase-index/writer-ref-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAgB,eAAe,CAAC,GAAG,EAAE,YAAY,GAAG,GAAG,CAStD"}
@@ -0,0 +1,7 @@
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 );\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
+ 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 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 );\n";
5
+ 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)'];
6
+ export declare const SYMBOLS_FTS_SQL = "CREATE VIRTUAL TABLE IF NOT EXISTS symbols_fts USING fts5(text, tokenize = 'unicode61')";
7
+ //# sourceMappingURL=writer-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer-schema.d.ts","sourceRoot":"","sources":["../../src/codebase-index/writer-schema.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,0GAK9B,CAAC;AAEF,eAAO,MAAM,eAAe,unBAsB3B,CAAC;AAEF,eAAO,MAAM,gBAAgB,YAC3B,wDAAwD,EACxD,wDAAwD,EACxD,wDAAwD,EACxD,wDAAwD,EACxD,mEAAmE,EACnE,8DAA8D,EAC9D,+DAA+D,CACvD,CAAC;AAEX,eAAO,MAAM,cAAc,uNAS1B,CAAC;AAEF,eAAO,MAAM,cAAc,YACzB,wDAAwD,EACxD,uDAAuD,EACvD,2DAA2D,EAC3D,+DAA+D,CACvD,CAAC;AAEX,eAAO,MAAM,eAAe,4FAC+D,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { SearchResult, SymbolKind, SymbolLang } from './schema.js';
2
+ export interface WriterSearchFilter {
3
+ kind?: SymbolKind | undefined;
4
+ lang?: SymbolLang | undefined;
5
+ file?: string | undefined;
6
+ lspKind?: number | undefined;
7
+ }
8
+ export interface WriterSearchRow {
9
+ id: number;
10
+ lang: string;
11
+ kind: string;
12
+ name: string;
13
+ file: string;
14
+ line: number;
15
+ col: number;
16
+ signature: string;
17
+ doc_comment: string;
18
+ text?: string;
19
+ score?: number;
20
+ snippet?: string;
21
+ }
22
+ export declare function normalizeSearchLimit(limit: number | undefined): number | undefined;
23
+ export declare function buildWriterSearchWhere(query: string, filter?: WriterSearchFilter | undefined): {
24
+ where: string;
25
+ values: unknown[];
26
+ } | null;
27
+ export declare function mapWriterSearchRow(row: WriterSearchRow, lspKind: number | undefined, score?: number, snippet?: string): SearchResult;
28
+ //# sourceMappingURL=writer-search-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"writer-search-helpers.d.ts","sourceRoot":"","sources":["../../src/codebase-index/writer-search-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAIxE,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IAC9B,IAAI,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IAC9B,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAIlF;AAED,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,kBAAkB,GAAG,SAAS,GACtC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,OAAO,EAAE,CAAA;CAAE,GAAG,IAAI,CAiC7C;AAED,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,eAAe,EACpB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,KAAK,SAAI,EACT,OAAO,SAAK,GACX,YAAY,CAed"}
@@ -0,0 +1,45 @@
1
+ interface PooledIndexStore {
2
+ close(): void;
3
+ }
4
+ type StoreFactory<TStore extends PooledIndexStore> = (projectRoot: string, opts?: {
5
+ indexDir?: string | undefined;
6
+ }) => TStore;
7
+ /**
8
+ * Warm-connection pool for IndexStore instances.
9
+ *
10
+ * Each (projectRoot, indexDir) pair gets one persisted store. Every read
11
+ * operation (search, stats, graph) acquires the store from the pool instead of
12
+ * opening a fresh SQLite connection, re-parsing the schema, and re-preparing
13
+ * statements. The connection stays warm between calls, subject to
14
+ * {@link DEFAULT_MAX_WARM_STORES}.
15
+ */
16
+ export declare class StorePool<TStore extends PooledIndexStore> {
17
+ private readonly createStore;
18
+ private readonly maxWarmStores;
19
+ private readonly stores;
20
+ private readonly keyByStore;
21
+ private clock;
22
+ constructor(createStore: StoreFactory<TStore>, maxWarmStores?: number);
23
+ private key;
24
+ /** Borrow a store. Creates it on first access for this key. */
25
+ acquire(projectRoot: string, opts?: {
26
+ indexDir?: string | undefined;
27
+ }): TStore;
28
+ /**
29
+ * Return the store to the pool. The connection stays warm for reuse, but the
30
+ * pool may now close the least-recently-used *idle* connection to stay within
31
+ * {@link maxWarmStores}. A store with outstanding refs is never closed.
32
+ */
33
+ release(store: TStore): void;
34
+ private trim;
35
+ /** Close every pooled connection and drain the pool. Call on shutdown. */
36
+ closeAll(): void;
37
+ /** Remove one store from the pool. Used by tests that need isolation. */
38
+ evict(projectRoot: string, indexDir?: string): void;
39
+ /** True when the pool holds a connection for the given key. */
40
+ has(projectRoot: string, indexDir?: string): boolean;
41
+ /** Number of warm connections currently held. */
42
+ get size(): number;
43
+ }
44
+ export {};
45
+ //# sourceMappingURL=writer-store-pool.d.ts.map
@@ -0,0 +1 @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F"}
@@ -1,53 +1,8 @@
1
- import type { FileMeta, IndexStats, Ref, SearchResult, Symbol as IndexSymbol, SymbolKind, SymbolLang, CodeMapGraph } from './schema.js';
2
- /**
3
- * Resolve the per-project index directory. By default it lives under the
4
- * global project dir (`~/.wrongstack/projects/<hash>/codebase-index`),
5
- * matching every other piece of per-project state. Callers may pass an
6
- * explicit `override` (used by tests and any wiring that already resolved the
7
- * path) to avoid touching the real home directory.
8
- */
9
- export declare function resolveIndexDir(projectRoot: string, override?: string): string;
10
- /**
11
- * Optional index-directory override carried on the run context's `meta` bag.
12
- * Production leaves it unset (the index resolves to the global per-project
13
- * dir); tests and bespoke wiring set `meta.codebaseIndexDir` to redirect it.
14
- */
15
- export declare function codebaseIndexDirOverride(ctx: {
16
- meta?: Record<string, unknown>;
17
- }): string | undefined;
18
- /**
19
- * Warm-connection pool for IndexStore instances.
20
- *
21
- * Each (projectRoot, indexDir) pair gets one persisted IndexStore. Every read
22
- * operation (search, stats, graph) acquires the store from the pool instead of
23
- * opening a fresh SQLite connection, re-parsing the schema, and re-preparing
24
- * statements. The connection stays warm between calls — only warm-up cost is
25
- * paid once per project per process lifetime.
26
- *
27
- * In WAL mode, readers coexist with the writer connection, so a single pooled
28
- * connection handles both reads and writes safely. The caller is responsible
29
- * for serializing writes (the host's promise-chain mutex does this); the pool
30
- * itself has no lock because the worker processes one message at a time.
31
- */
32
- export declare class StorePool {
33
- private readonly stores;
34
- private key;
35
- /** Borrow a store. Creates it on first access for this key. */
36
- acquire(projectRoot: string, opts?: {
37
- indexDir?: string | undefined;
38
- }): IndexStore;
39
- /** Return the store to the pool. The connection stays warm for subsequent
40
- * operations on the same (projectRoot, indexDir). */
41
- release(_store: IndexStore): void;
42
- /** Close every pooled connection and drain the pool. Call on shutdown. */
43
- closeAll(): void;
44
- /** Remove one store from the pool. Used by tests that need isolation. */
45
- evict(projectRoot: string, indexDir?: string): void;
46
- /** True when the pool holds a connection for the given key. */
47
- has(projectRoot: string, indexDir?: string): boolean;
48
- }
49
- /** Process-wide singleton pool. */
50
- export declare const indexStorePool: StorePool;
1
+ import type { CodeMapGraph, FileMeta, IndexStats, Symbol as IndexSymbol, Ref, SearchResult, SymbolKind, SymbolLang } from './schema.js';
2
+ import { type WriterSearchFilter } from './writer-search-helpers.js';
3
+ import { StorePool } from './writer-store-pool.js';
4
+ export { codebaseIndexDirOverride, resolveIndexDir } from './writer-helpers.js';
5
+ export { StorePool } from './writer-store-pool.js';
51
6
  export declare class IndexStore {
52
7
  private db;
53
8
  /** Absolute path to this project's index directory. */
@@ -85,23 +40,10 @@ export declare class IndexStore {
85
40
  private bm25Dirty;
86
41
  /** Prepare-once helper: compile `sql` on first use, reuse thereafter. */
87
42
  private stmt;
88
- /**
89
- * Execute a SQLite write operation with automatic retry on lock conflicts.
90
- *
91
- * When another wstack process is holding the write lock the statement first
92
- * waits up to `busy_timeout` ms, then throws SQLITE_BUSY. This wrapper catches
93
- * that error and retries (up to MAX_LOCK_RETRIES) with exponential backoff,
94
- * giving the competing writer time to finish and release the lock.
95
- *
96
- * @param fn The write operation to execute. Can return a value which is
97
- * returned to the caller on success.
98
- * @throws {@link LockError} when all retries are exhausted on a lock conflict
99
- * (non-lock errors always propagate on the first attempt).
100
- */
101
- runWithRetry<T>(fn: () => T): T;
102
43
  constructor(projectRoot: string, opts?: {
103
44
  indexDir?: string | undefined;
104
45
  });
46
+ runWithRetry<T>(fn: () => T): T;
105
47
  private initSchema;
106
48
  private static readonly NEXT_SYMBOL_ID_KEY;
107
49
  /** Stay under typical SQLite SQLITE_MAX_VARIABLE_NUMBER (often 999). */
@@ -117,10 +59,17 @@ export declare class IndexStore {
117
59
  * so concurrent indexers cannot hand out overlapping ranges.
118
60
  */
119
61
  private allocateSymbolIds;
120
- /** Multi-row INSERT for symbols — amortizes prepare/bind overhead in large batches. */
121
- private bulkInsertSymbols;
122
- private bulkInsertFts;
123
- private bulkInsertRefs;
62
+ /**
63
+ * Disconnect inbound refs before their target symbols are replaced and
64
+ * return the affected names for scoped re-resolution.
65
+ *
66
+ * This also repairs a long-standing dangling-id edge case: `refs.to_id` has
67
+ * no physical FK, so deleting a symbol previously left callers pointing at a
68
+ * non-existent row.
69
+ */
70
+ private invalidateIncomingRefsForFiles;
71
+ /** Resolve only refs whose target names may have changed. */
72
+ private resolveRefsForNamesUnsafe;
124
73
  /**
125
74
  * Insert symbols, assigning IDs atomically inside `BEGIN IMMEDIATE` /
126
75
  * `COMMIT`. Id ranges come from the `next_symbol_id` metadata counter
@@ -140,12 +89,7 @@ export declare class IndexStore {
140
89
  upsertFile(meta: FileMeta): void;
141
90
  getFileMeta(file: string): FileMeta | null;
142
91
  getAllFileMetas(): FileMeta[];
143
- search(query: string, filter?: {
144
- kind?: SymbolKind | undefined;
145
- lang?: SymbolLang | undefined;
146
- file?: string | undefined;
147
- lspKind?: number | undefined;
148
- }, opts?: {
92
+ search(query: string, filter?: WriterSearchFilter, opts?: {
149
93
  limit?: number | undefined;
150
94
  }): SearchResult[];
151
95
  /** Shared WHERE builder for {@link search} / empty-query ranked totals. */
@@ -161,12 +105,7 @@ export declare class IndexStore {
161
105
  * `LIKE '%tok%'` recall for the common symbol-search shapes ("user" finds
162
106
  * "users", camelCase-split text makes "complex" find "complexOperation").
163
107
  */
164
- searchRanked(query: string, filter: {
165
- kind?: SymbolKind | undefined;
166
- lang?: SymbolLang | undefined;
167
- file?: string | undefined;
168
- lspKind?: number | undefined;
169
- } | undefined, limit: number): {
108
+ searchRanked(query: string, filter: WriterSearchFilter | undefined, limit: number): {
170
109
  results: SearchResult[];
171
110
  total: number;
172
111
  };
@@ -282,6 +221,7 @@ export declare class IndexStore {
282
221
  * that found a target — matching the previous per-row loop's return value.
283
222
  */
284
223
  resolveRefs(): number;
224
+ resolveRefsForNames(names: Iterable<string>): number;
285
225
  /**
286
226
  * Clear symbols/refs for a file and mark it as indexed with zero symbols.
287
227
  * Used by the indexer for empty-parse results so three writes share one txn.
@@ -289,6 +229,17 @@ export declare class IndexStore {
289
229
  replaceEmptyFile(meta: FileMeta): void;
290
230
  /** Best-effort query planner refresh after a large reindex. */
291
231
  optimize(): void;
232
+ /**
233
+ * Reclaim page churn left by repeated force rebuilds.
234
+ *
235
+ * SQLite's DROP/CREATE path makes rebuilds fast but leaves pages on the
236
+ * freelist. Compact only large, materially sparse databases and only when the
237
+ * caller is already on a full-index maintenance path.
238
+ */
239
+ compactIfNeeded(options?: {
240
+ minBytes?: number;
241
+ minFreeRatio?: number;
242
+ }): boolean;
292
243
  /**
293
244
  * Find all references TO a given symbol (who calls / uses this symbol?).
294
245
  */
@@ -297,15 +248,6 @@ export declare class IndexStore {
297
248
  * Find all references FROM a given symbol (what does this symbol call/use?).
298
249
  */
299
250
  findRefsFrom(symbolId: number): Ref[];
300
- private sizeBytes;
301
- /**
302
- * Derive a monorepo package name from an absolute file path.
303
- * Handles both `packages/<name>/...` (workspace) and `src/<name>/...` layouts.
304
- * Returns `undefined` for files outside any recognisable package structure.
305
- */
306
- private static derivePackage;
307
- private static packageFromImport;
308
- private static resolveRelativeImport;
309
251
  /**
310
252
  * Package-level graph: each workspace package is a node; edges are derived
311
253
  * from cross-package symbol references (a symbol in package A references a
@@ -322,6 +264,47 @@ export declare class IndexStore {
322
264
  * derived from intra-file and cross-file symbol references (who calls whom).
323
265
  */
324
266
  getSymbolGraph(fileFilter: string): CodeMapGraph;
267
+ /**
268
+ * Returns every symbol in the index. Used by dead-code analysis to
269
+ * build the full symbol universe for the reachability scan.
270
+ */
271
+ getAllSymbols(): Array<{
272
+ id: number;
273
+ name: string;
274
+ file: string;
275
+ kind: SymbolKind;
276
+ line: number;
277
+ }>;
278
+ /**
279
+ * Returns every resolved reference (to_id IS NOT NULL). Used by
280
+ * dead-code analysis to build the consumer-ship graph. Refs whose
281
+ * target symbol id is null (unresolved imports) are excluded.
282
+ */
283
+ getAllResolvedRefs(): Array<{
284
+ fromId: number;
285
+ toId: number;
286
+ callType: string;
287
+ }>;
288
+ /**
289
+ * Returns ALL import refs (including unresolved) with their source-file
290
+ * path and resolved target id. Used by the dead-code scan's file-level
291
+ * graph traversal to handle barrel-only entry points where no symbol
292
+ * carries the ref.
293
+ *
294
+ * Refs whose `from_id` doesn't match a known symbol (e.g. pure-barrel
295
+ * files with no declarations) will have `sourceFile === null`.
296
+ */
297
+ getAllImportRefs(): Array<{
298
+ /** Source-file path (null when the owning symbol can't be resolved). */
299
+ sourceFile: string | null;
300
+ toName: string;
301
+ /** Resolved target symbol id (null when the name couldn't be matched). */
302
+ toId: number | null;
303
+ callType: string;
304
+ line: number;
305
+ }>;
325
306
  close(): void;
326
307
  }
308
+ /** Process-wide singleton pool. */
309
+ export declare const indexStorePool: StorePool<IndexStore>;
327
310
  //# sourceMappingURL=writer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../src/codebase-index/writer.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,EACV,QAAQ,EACR,UAAU,EACV,GAAG,EACH,YAAY,EACZ,MAAM,IAAI,WAAW,EACrB,UAAU,EACV,UAAU,EACV,YAAY,EAIb,MAAM,aAAa,CAAC;AA+BrB;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAE9E;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,EAAE;IAC5C,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC,GAAG,MAAM,GAAG,SAAS,CAGrB;AAED;;;;;;;;;;;;;GAaG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiC;IAExD,OAAO,CAAC,GAAG;IAIX,+DAA+D;IAC/D,OAAO,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,GAAG,UAAU,CAQjF;I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,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC,CAID;IAED;;;;;;;;OAQG;IACH,gBAAgB,IAAI,KAAK,CAAC;QACxB,wEAAwE;QACxE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,MAAM,EAAE,MAAM,CAAC;QACf,0EAA0E;QAC1E,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAeD;IAED,KAAK,IAAI,IAAI,CAaZ;CACF;AAED,mCAAmC;AACnC,eAAO,MAAM,cAAc,uBAG1B,CAAC"}
package/dist/exec.js CHANGED
@@ -1316,7 +1316,11 @@ var PersistentProcessRegistry = class {
1316
1316
  cleanupRunning = false;
1317
1317
  isShuttingDown = false;
1318
1318
  onProcessExit = () => {
1319
- void this.syncToPersistent();
1319
+ this.runInBackground(
1320
+ this.syncToPersistent(),
1321
+ "process_registry.exit_sync_failed",
1322
+ "PersistentProcessRegistry: exit sync failed"
1323
+ );
1320
1324
  };
1321
1325
  constructor(baseRegistry) {
1322
1326
  this.instanceId = generateInstanceId();
@@ -1336,6 +1340,11 @@ var PersistentProcessRegistry = class {
1336
1340
  if (!isNodeError(err) || err.code !== "EEXIST") throw err;
1337
1341
  }
1338
1342
  }
1343
+ runInBackground(operation, event, message) {
1344
+ void operation.catch((err) => {
1345
+ emitStructuredLog("warn", event, message, err);
1346
+ });
1347
+ }
1339
1348
  /**
1340
1349
  * Start the heartbeat and periodic cleanup tasks.
1341
1350
  */
@@ -1368,26 +1377,34 @@ var PersistentProcessRegistry = class {
1368
1377
  this.cleanupInterval = null;
1369
1378
  }
1370
1379
  process.off("exit", this.onProcessExit);
1371
- void this.syncToPersistent();
1380
+ this.runInBackground(
1381
+ this.syncToPersistent(),
1382
+ "process_registry.stop_sync_failed",
1383
+ "PersistentProcessRegistry: stop sync failed"
1384
+ );
1372
1385
  }
1373
1386
  /**
1374
1387
  * Register the main WrongStack process as protected.
1375
1388
  */
1376
1389
  registerMainProcess() {
1377
1390
  const mainPid = process.pid;
1378
- this.updatePersistentEntry({
1379
- pid: mainPid,
1380
- name: "wrongstack-main",
1381
- command: process.argv.slice(0, 3).join(" "),
1382
- startedAt: Date.now(),
1383
- lastHeartbeat: Date.now(),
1384
- instanceId: this.instanceId,
1385
- hostname: os2.hostname(),
1386
- protected: true,
1387
- spawnMode: "main",
1388
- parentPid: process.ppid,
1389
- platform: process.platform
1390
- });
1391
+ this.runInBackground(
1392
+ this.updatePersistentEntry({
1393
+ pid: mainPid,
1394
+ name: "wrongstack-main",
1395
+ command: process.argv.slice(0, 3).join(" "),
1396
+ startedAt: Date.now(),
1397
+ lastHeartbeat: Date.now(),
1398
+ instanceId: this.instanceId,
1399
+ hostname: os2.hostname(),
1400
+ protected: true,
1401
+ spawnMode: "main",
1402
+ parentPid: process.ppid,
1403
+ platform: process.platform
1404
+ }),
1405
+ "process_registry.main_register_failed",
1406
+ "PersistentProcessRegistry: failed to register main process"
1407
+ );
1391
1408
  }
1392
1409
  /**
1393
1410
  * Register a spawned child process with the persistent registry.
@@ -1410,7 +1427,11 @@ var PersistentProcessRegistry = class {
1410
1427
  if (sessionId) {
1411
1428
  entry.sessionId = sessionId;
1412
1429
  }
1413
- this.updatePersistentEntry(entry);
1430
+ this.runInBackground(
1431
+ this.updatePersistentEntry(entry),
1432
+ "process_registry.child_register_failed",
1433
+ "PersistentProcessRegistry: failed to register child process"
1434
+ );
1414
1435
  }
1415
1436
  /**
1416
1437
  * Update or add an entry in the persistent registry.
@@ -1454,14 +1475,28 @@ var PersistentProcessRegistry = class {
1454
1475
  heartbeat() {
1455
1476
  if (this.isShuttingDown || this.heartbeatRunning) return;
1456
1477
  this.heartbeatRunning = true;
1457
- void this.syncToPersistent().finally(() => {
1478
+ void this.syncToPersistent().catch((err) => {
1479
+ emitStructuredLog(
1480
+ "warn",
1481
+ "process_registry.heartbeat_failed",
1482
+ "PersistentProcessRegistry: heartbeat failed",
1483
+ err
1484
+ );
1485
+ }).finally(() => {
1458
1486
  this.heartbeatRunning = false;
1459
1487
  });
1460
1488
  }
1461
1489
  cleanup() {
1462
1490
  if (this.isShuttingDown || this.cleanupRunning) return;
1463
1491
  this.cleanupRunning = true;
1464
- void this.cleanupStaleEntries().finally(() => {
1492
+ void this.cleanupStaleEntries().catch((err) => {
1493
+ emitStructuredLog(
1494
+ "warn",
1495
+ "process_registry.periodic_cleanup_failed",
1496
+ "PersistentProcessRegistry: periodic cleanup failed",
1497
+ err
1498
+ );
1499
+ }).finally(() => {
1465
1500
  this.cleanupRunning = false;
1466
1501
  });
1467
1502
  }