@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
@@ -4,6 +4,22 @@ export declare class GenerationLruCache<T> {
4
4
  private readonly entries;
5
5
  constructor(maxEntries: number);
6
6
  get(key: string, generation: number): T | undefined;
7
+ /**
8
+ * Read an entry regardless of which generation wrote it, without touching
9
+ * LRU recency. Used by the project server to serve a previous-generation
10
+ * (stale) answer while an index refresh is publishing — the caller marks the
11
+ * response `stale` instead of failing the read.
12
+ */
13
+ peek(key: string): T | undefined;
14
+ /**
15
+ * Like {@link peek} but exposes the entry's generation, so the stale-read
16
+ * policy can bound how far a preserved entry may lag the publishing
17
+ * generation before it is too old to serve.
18
+ */
19
+ peekEntry(key: string): {
20
+ generation: number;
21
+ value: T;
22
+ } | undefined;
7
23
  set(key: string, generation: number, value: T): T;
8
24
  clear(): void;
9
25
  get size(): number;
@@ -1,6 +1,6 @@
1
+ import { getProjectIndexServerConnectionState, isProjectIndexServerAvailable, onProjectIndexServerConnectionStateChange, type ProjectIndexDaemonAvailability, type ProjectIndexServerClientHealth, type ProjectIndexServerConnectionState, type ProjectIndexServerConnectionStatus, type ProjectIndexServerShutdownResult, type ProjectServerCallOptions, projectIndexServerExpectedBuildId, resolveProjectIndexDaemonAvailability } from './project-server-client-state.js';
1
2
  import type { OpName, OpShapes } from './worker-protocol.js';
2
- import { type ProjectServerCallOptions, type ProjectIndexServerShutdownResult, type ProjectIndexServerConnectionStatus, type ProjectIndexServerClientHealth, type ProjectIndexServerConnectionState, type ProjectIndexDaemonAvailability, resolveProjectIndexDaemonAvailability, projectIndexServerExpectedBuildId, isProjectIndexServerAvailable, getProjectIndexServerConnectionState, onProjectIndexServerConnectionStateChange } from './project-server-client-state.js';
3
- export { type ProjectServerCallOptions, type ProjectIndexServerShutdownResult, type ProjectIndexServerConnectionStatus, type ProjectIndexServerClientHealth, type ProjectIndexServerConnectionState, type ProjectIndexDaemonAvailability, resolveProjectIndexDaemonAvailability, projectIndexServerExpectedBuildId, isProjectIndexServerAvailable, getProjectIndexServerConnectionState, onProjectIndexServerConnectionStateChange, };
3
+ export { getProjectIndexServerConnectionState, isProjectIndexServerAvailable, onProjectIndexServerConnectionStateChange, type ProjectIndexDaemonAvailability, type ProjectIndexServerClientHealth, type ProjectIndexServerConnectionState, type ProjectIndexServerConnectionStatus, type ProjectIndexServerShutdownResult, type ProjectServerCallOptions, projectIndexServerExpectedBuildId, resolveProjectIndexDaemonAvailability, };
4
4
  export declare function callProjectIndexServer<O extends OpName>(op: O, args: OpShapes[O]['args'], options: ProjectServerCallOptions): Promise<OpShapes[O]['result']>;
5
5
  export declare function ensureProjectIndexServer(options: {
6
6
  projectRoot: string;
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Read/completion policy for the detached project server's query caches.
3
+ *
4
+ * The server used to refuse every read for the duration of an index refresh
5
+ * and wipe all query caches on every completion (including single-file
6
+ * incremental runs). Together that made search/graph/stats unavailable both
7
+ * during a refresh and on the first reads after each incremental edit.
8
+ *
9
+ * The policy here instead:
10
+ *
11
+ * - **During a refresh** a cache HIT from any generation is served with a
12
+ * `stale: true` marker. A miss still refuses: read ops share the server's
13
+ * single pooled SQLite connection with the in-flight write transaction, so
14
+ * loading fresh mid-run would be a dirty read of uncommitted rows, not a
15
+ * merely-outdated read.
16
+ * - **On completion of an incremental run** the caches are kept. Entries are
17
+ * re-tagged with the new generation as they are recomputed; surviving
18
+ * previous-generation entries are what the next refresh's stale-serve
19
+ * window hits. `stats` still refuses during a refresh — it is the progress
20
+ * poll, and a cached pre-run answer would read as "finished with old
21
+ * numbers".
22
+ * - **On completion of a full/forced run** (or a failed run whose
23
+ * transaction may have rolled back the visible generation) all caches are
24
+ * cleared.
25
+ */
26
+ import type { IncomingCallsResult, OutgoingCallsResult } from './index-service.js';
27
+ import { GenerationLruCache } from './project-server-cache.js';
28
+ import type { CodeMapGraph, IndexStats, SearchResult } from './schema.js';
29
+ /** The error the server answers a read it cannot serve with. */
30
+ export declare function indexRefreshInProgressError(currentFile: number, totalFiles: number): Error;
31
+ /**
32
+ * The slice of index activity a read decision needs. Structurally compatible
33
+ * with the server's `ProjectIndexServerActivity`, so the live activity object
34
+ * can be passed directly.
35
+ */
36
+ export interface RefreshState {
37
+ generation: number;
38
+ indexing: boolean;
39
+ currentFile: number;
40
+ totalFiles: number;
41
+ }
42
+ /**
43
+ * How many completed generations a preserved cache entry may lag the
44
+ * publishing one and still be served stale during a refresh.
45
+ *
46
+ * Targeted runs preserve caches across completions, and generation only
47
+ * grows — an entry that survives many runs without being recomputed gets
48
+ * progressively older (a search answer from before several edits). Beyond
49
+ * this bound the entry is treated as too old to be useful and the read
50
+ * falls back to the refresh refusal, exactly like a cache miss.
51
+ */
52
+ export declare const MAX_STALE_GENERATION_LAG = 2;
53
+ /**
54
+ * One read against a generation cache under the stale-serve policy.
55
+ *
56
+ * - Refreshing + hit within {@link MAX_STALE_GENERATION_LAG} generations →
57
+ * `{ value, stale: true }` from `peekEntry`.
58
+ * - Refreshing + miss (or entry older than the bound) → throws
59
+ * `IndexRefreshInProgressError` (a fresh load would read uncommitted rows
60
+ * through the shared pooled connection).
61
+ * - Idle + hit → `{ value, stale: false }`; idle + miss → `load()` and cache.
62
+ */
63
+ export declare function staleAwareRead<T>(cache: GenerationLruCache<T>, key: string, refresh: RefreshState, load: () => T): {
64
+ value: T;
65
+ stale: boolean;
66
+ };
67
+ /** The project server's generation-scoped read caches, as a unit. */
68
+ export declare class ServerQueryCaches {
69
+ /**
70
+ * Search answer (rows + total) keyed by the serialized query args. Rows and
71
+ * count are cached as ONE value: separate caches would let one half hit and
72
+ * the other miss, and a mid-refresh miss load would be a dirty read.
73
+ */
74
+ readonly searchCache: GenerationLruCache<{
75
+ results: SearchResult[];
76
+ total: number;
77
+ }>;
78
+ readonly statsCache: GenerationLruCache<IndexStats>;
79
+ readonly packageGraphCache: GenerationLruCache<CodeMapGraph>;
80
+ readonly fileGraphCache: GenerationLruCache<CodeMapGraph>;
81
+ readonly symbolGraphCache: GenerationLruCache<CodeMapGraph>;
82
+ readonly incomingCallsCache: GenerationLruCache<IncomingCallsResult>;
83
+ readonly outgoingCallsCache: GenerationLruCache<OutgoingCallsResult>;
84
+ clear(): void;
85
+ /** Cache sizes for the health snapshot. */
86
+ sizes(): Record<string, number>;
87
+ }
88
+ //# sourceMappingURL=project-server-query-cache.d.ts.map