@wrongstack/tools 0.309.0 → 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 (67) hide show
  1. package/dist/_regex.d.ts +6 -34
  2. package/dist/audit.js +3 -3
  3. package/dist/bash.js +4 -4
  4. package/dist/builtin.js +3020 -1680
  5. package/dist/codebase-index/binary-frame.d.ts +57 -8
  6. package/dist/codebase-index/codebase-incoming-calls-tool.d.ts +6 -0
  7. package/dist/codebase-index/codebase-outgoing-calls-tool.d.ts +6 -0
  8. package/dist/codebase-index/codebase-search-tool.d.ts +15 -5
  9. package/dist/codebase-index/index-service.d.ts +3 -19
  10. package/dist/codebase-index/index.js +2784 -1464
  11. package/dist/codebase-index/indexer.d.ts +3 -0
  12. package/dist/codebase-index/parser-batch.d.ts +53 -0
  13. package/dist/codebase-index/parser-dispatch.d.ts +32 -0
  14. package/dist/codebase-index/parser-output.d.ts +14 -0
  15. package/dist/codebase-index/parser-worker-pool.d.ts +57 -4
  16. package/dist/codebase-index/parser-worker-script.d.ts +5 -2
  17. package/dist/codebase-index/parser-worker-script.js +4042 -0
  18. package/dist/codebase-index/project-server-cache.d.ts +16 -0
  19. package/dist/codebase-index/project-server-client.d.ts +2 -2
  20. package/dist/codebase-index/project-server-query-cache.d.ts +88 -0
  21. package/dist/codebase-index/project-server.js +2846 -1308
  22. package/dist/codebase-index/py-parser.d.ts +5 -0
  23. package/dist/codebase-index/schema.d.ts +14 -1
  24. package/dist/codebase-index/sqlite-runtime.d.ts +2 -2
  25. package/dist/codebase-index/tree-sitter/queries.d.ts +30 -3
  26. package/dist/codebase-index/tree-sitter/visitor.d.ts +2 -1
  27. package/dist/codebase-index/vector-search.d.ts +12 -0
  28. package/dist/codebase-index/wal-maintenance.d.ts +58 -0
  29. package/dist/codebase-index/worker-protocol/contracts.d.ts +44 -0
  30. package/dist/codebase-index/worker-protocol.d.ts +17 -1
  31. package/dist/codebase-index/worker.js +2300 -1020
  32. package/dist/codebase-index/writer-admin.d.ts +11 -0
  33. package/dist/codebase-index/writer-helpers.d.ts +31 -1
  34. package/dist/codebase-index/writer-mutations.d.ts +0 -6
  35. package/dist/codebase-index/writer-schema.d.ts +2 -2
  36. package/dist/codebase-index/writer.d.ts +15 -0
  37. package/dist/edit.js +2511 -1203
  38. package/dist/exec.js +8 -6
  39. package/dist/format.js +3 -3
  40. package/dist/git.js +6 -0
  41. package/dist/grep.js +5 -124
  42. package/dist/index.js +3016 -1739
  43. package/dist/install.js +3 -3
  44. package/dist/json.js +5 -124
  45. package/dist/kanban.js +130 -0
  46. package/dist/languages/index.js +3 -3
  47. package/dist/lint.js +3 -3
  48. package/dist/logs.js +5 -121
  49. package/dist/outdated.js +3 -3
  50. package/dist/pack.js +3020 -1680
  51. package/dist/patch.js +2524 -1216
  52. package/dist/plan.js +106 -0
  53. package/dist/process-registry.js +1 -1
  54. package/dist/read.js +2506 -1198
  55. package/dist/replace.js +2487 -1295
  56. package/dist/search.js +6 -2
  57. package/dist/session-kanban.js +24 -16
  58. package/dist/task.js +106 -0
  59. package/dist/test.js +3 -3
  60. package/dist/todo.js +106 -0
  61. package/dist/tool-tier.d.ts +11 -0
  62. package/dist/tool-tier.js +3028 -1680
  63. package/dist/tree.js +14 -3
  64. package/dist/typecheck.js +3 -3
  65. package/dist/win32.js +5 -5
  66. package/dist/write.js +2513 -1205
  67. package/package.json +5 -4
@@ -8,26 +8,69 @@
8
8
  * - `0x57` ('W') → binary frame: [magic] [uint32 BE length] [MessagePack]
9
9
  * - anything else → the byte is part of a JSON text line terminated by `\n`
10
10
  *
11
- * Negotiation happens during the existing handshake:
12
- * 1. The server's `hello` frame includes `binarySupported: true` (always JSON)
13
- * 2. If the client supports binary, it sends `acceptsBinary: true` in its
14
- * first authenticated request (still JSON, so the server can read it)
15
- * 3. Both sides switch to binary framing for all subsequent frames on that
16
- * socket
11
+ * There is no negotiated mode switch — the receiver sniffs every frame's
12
+ * first byte (see `consume()` in project-server.ts and the client's unified
13
+ * reader), so JSON and binary frames interleave freely on one socket:
14
+ * - the server's `hello` frame advertises `binarySupported: true` (always
15
+ * JSON, so any client can read it);
16
+ * - a client that wants binary simply sends binary frames
17
+ * (opt-in via WRONGSTACK_INDEX_BINARY=1 — the benchmark showed NDJSON is
18
+ * faster for this workload, so it stays the default);
19
+ * - the server answers each request in that request's framing, and latches
20
+ * outbound to binary once a client has sent any binary frame.
17
21
  *
18
- * Backward compatibility: if either side does not advertise binary support,
19
- * the connection stays on newline-delimited JSON. The protocolVersion + buildId
22
+ * Backward compatibility: a JSON-only client never sees a binary byte, and a
23
+ * binary client's frames are self-describing the protocolVersion + buildId
20
24
  * handshake already prevents a binary build from talking to a JSON-only build
21
25
  * of a different version (the buildId changes when the compiled artifact
22
26
  * changes), so there is no protocol ambiguity in practice.
23
27
  */
24
28
  /** Magic byte that prefixes every binary frame. 'W' for WrongStack. */
25
29
  export declare const BINARY_FRAME_MAGIC = 87;
30
+ /**
31
+ * Hard cap on one binary frame's declared payload length for the CLIENT
32
+ * reader (project-server-client.ts). A malformed or hostile peer could
33
+ * claim a 4 GiB frame and stall the reader; this bound is far above any
34
+ * legitimate IPC response.
35
+ *
36
+ * Direction split is deliberate, not an oversight: the server enforces a
37
+ * much tighter inbound cap (MAX_INBOUND_BINARY_FRAME_BYTES, 64 Mi) because
38
+ * requests are small by construction and readable before auth; the client
39
+ * accepts larger frames because server responses (search results, symbol
40
+ * graphs) are the big direction. The two constants are intentionally
41
+ * separate — do not "unify" them: raising the server's inbound ceiling to
42
+ * match would widen the unauthenticated write surface, and lowering the
43
+ * client's read ceiling to match would reject legitimate large responses.
44
+ * Both directions also cap JSON text frames at their own ceilings, so
45
+ * neither framing offers the larger write than the other on its side.
46
+ */
47
+ export declare const MAX_BINARY_FRAME_BYTES: number;
48
+ /**
49
+ * Cap on one INBOUND (client → server) binary frame. Requests are tiny (an
50
+ * op name plus a few arguments; the largest is an explicit reindex file
51
+ * list), and unlike responses this direction is readable before any auth
52
+ * check — a local client could otherwise declare a huge frame and make the
53
+ * server wait for and accumulate it. The check runs the moment the five-byte
54
+ * header is complete, so the connection is destroyed without ever buffering
55
+ * toward the declared length (bytes already delivered in the current socket
56
+ * chunk are freed with the destroyed connection). Matches the JSON request
57
+ * ceiling (PROJECT_INDEX_SERVER_MAX_FRAME_CHARS, 64 Mi) so neither framing
58
+ * offers a larger unauthenticated write than the other.
59
+ */
60
+ export declare const MAX_INBOUND_BINARY_FRAME_BYTES: number;
26
61
  /** True if a byte stream begins with the binary-frame magic. */
27
62
  export declare function isBinaryFrame(firstByte: number): boolean;
28
63
  /**
29
64
  * Encode a message as a binary frame: [magic] [uint32 BE length] [MessagePack].
30
65
  * Returns a single Buffer ready to write to the socket.
66
+ *
67
+ * `undefined`-valued properties are stripped before encoding: MessagePack
68
+ * would encode them as `nil` (arriving as `null`), while the JSON framing
69
+ * drops them entirely — callers must not observe a different payload shape
70
+ * just because they negotiated binary. Plain objects are normalized
71
+ * recursively, and a small allowlist of well-known class instances is
72
+ * converted to deterministic JSON-framing shapes (see normalizeUndefined)
73
+ * so the same payload does not shape-shift between framings.
31
74
  */
32
75
  export declare function encodeBinaryFrame(message: unknown): Buffer;
33
76
  /**
@@ -38,6 +81,12 @@ export declare function decodeBinaryFrame(payload: Uint8Array): unknown;
38
81
  /**
39
82
  * Encode a message as a JSON text frame, terminated by `\n`.
40
83
  * This is the original wire format — kept for fallback and handshake.
84
+ *
85
+ * Parity invariant (bf-2): both framings deliver the SAME normalized tree.
86
+ * JSON.stringify alone silently loses Map/Set/Error/RegExp payloads (`{}`
87
+ * on the wire); routing through the shared normalizer makes a payload's
88
+ * delivered shape independent of which framing carried it. A client that
89
+ * negotiates binary — or fails to — sees identical data.
41
90
  */
42
91
  export declare function encodeJsonFrame(message: unknown): string;
43
92
  //# sourceMappingURL=binary-frame.d.ts.map
@@ -26,6 +26,12 @@ interface IncomingCallsOutput {
26
26
  symbol: string;
27
27
  calls: CallSite[];
28
28
  total: number;
29
+ /**
30
+ * True when the project server served a previous generation's cached
31
+ * answer during a refresh. Results are internally consistent but may lag
32
+ * the files currently being indexed.
33
+ */
34
+ stale?: boolean | undefined;
29
35
  /** Non-empty when the index blocked the query (not ready, indexing, failed). */
30
36
  indexStatus?: string | undefined;
31
37
  /** Advisory note when the symbol was not found in the index. */
@@ -26,6 +26,12 @@ interface OutgoingCallsOutput {
26
26
  symbol: string;
27
27
  calls: CallSite[];
28
28
  total: number;
29
+ /**
30
+ * True when the project server served a previous generation's cached
31
+ * answer during a refresh. Results are internally consistent but may lag
32
+ * the files currently being indexed.
33
+ */
34
+ stale?: boolean | undefined;
29
35
  /** Non-empty when the index blocked the query (not ready, indexing, failed). */
30
36
  indexStatus?: string | undefined;
31
37
  /** Advisory note when the symbol was not found, or unresolved refs exist. */
@@ -4,7 +4,7 @@
4
4
  * Usage: codebase-search({
5
5
  * query: string, // search terms
6
6
  * kind?: string, // class|function|interface|method|const|...
7
- * lang?: string, // ts|tsx|js|jsx|go|py|rs
7
+ * lang?: string, // ts|tsx|js|jsx|go|py|rs|java|ruby|… (derived from EXT_TO_LANG)
8
8
  * file?: string, // filter to a specific file path (substring match)
9
9
  * limit?: number, // max results (default 20, max 100)
10
10
  * })
@@ -16,12 +16,16 @@
16
16
  * slow this tool down but can never freeze the terminal.
17
17
  */
18
18
  import type { Tool } from '@wrongstack/core/types';
19
- import type { SearchResult } from './schema.js';
19
+ import type { SearchResult, SymbolLang } from './schema.js';
20
20
  /**
21
- * Language ids the index understands. Single source for the `lang` enum here
22
- * and the `langs` validation in codebase-index-tool.ts.
21
+ * Language ids the index understands DERIVED from `EXT_TO_LANG`
22
+ * (languages.ts), the same table that decides which files get indexed, so
23
+ * this enum can no longer drift from the indexer's actual coverage (~40
24
+ * languages, including java/ruby/php/swift/md/css/… that the old
25
+ * hand-maintained 9-item list silently rejected). Single source for the
26
+ * `lang` enum here and the `langs` validation in codebase-index-tool.ts.
23
27
  */
24
- export declare const INDEXABLE_LANG_IDS: readonly ['ts', 'tsx', 'js', 'jsx', 'go', 'py', 'rs', 'json', 'yaml'];
28
+ export declare const INDEXABLE_LANG_IDS: readonly SymbolLang[];
25
29
  export declare const codebaseSearchTool: Tool<CodebaseSearchInput, CodebaseSearchOutput>;
26
30
  interface CodebaseSearchInput {
27
31
  query: string;
@@ -41,6 +45,12 @@ interface CodebaseSearchOutput {
41
45
  results: SearchResult[];
42
46
  total: number;
43
47
  query: string;
48
+ /**
49
+ * True when the project server served a previous generation's cached
50
+ * answer during a refresh. Results are internally consistent but may lag
51
+ * the files currently being indexed.
52
+ */
53
+ stale?: boolean | undefined;
44
54
  /** Non-empty when the index blocked the search (not ready, indexing, failed). */
45
55
  indexStatus?: string | undefined;
46
56
  }
@@ -11,7 +11,7 @@
11
11
  * run on one event loop, so a pooled connection is both safe and substantially
12
12
  * cheaper than re-running schema/FTS drift checks for every edited file.
13
13
  */
14
- import type { CallSite, CodeMapGraph, IndexResult, IndexStats } from './schema.js';
14
+ import type { CodeMapGraph, IndexResult, IndexStats } from './schema.js';
15
15
  import type { CallRefsOpArgs, IndexOpArgs, SearchOpArgs, SearchOpResult, StatsOpArgs } from './worker-protocol.js';
16
16
  export interface ServiceHooks {
17
17
  signal?: AbortSignal | undefined;
@@ -33,24 +33,8 @@ export declare function fileGraphService(args: StatsOpArgs & {
33
33
  export declare function symbolGraphService(args: StatsOpArgs & {
34
34
  fileFilter: string;
35
35
  }): CodeMapGraph;
36
- /** Result of an incoming calls query. */
37
- export interface IncomingCallsResult {
38
- calls: CallSite[];
39
- symbolFound: boolean;
40
- /** True when `file` was scoped but the name is ambiguous (other files define it too). */
41
- ambiguous: boolean;
42
- /** Total matching call sites before the limit was applied. */
43
- totalMatches: number;
44
- }
45
- /** Result of an outgoing calls query. */
46
- export interface OutgoingCallsResult {
47
- calls: CallSite[];
48
- symbolFound: boolean;
49
- /** Number of refs whose target could not be resolved (to_id IS NULL). */
50
- unresolvedCount: number;
51
- /** Total matching call sites before the limit was applied. */
52
- totalMatches: number;
53
- }
36
+ import type { IncomingCallsResult, OutgoingCallsResult } from './worker-protocol/contracts.js';
37
+ export type { IncomingCallsResult, OutgoingCallsResult };
54
38
  /** Incoming call sites for a named symbol (who calls/uses this symbol?). */
55
39
  export declare function incomingCallsService(args: CallRefsOpArgs): IncomingCallsResult;
56
40
  /** Outgoing call sites for a named symbol (what does this symbol call/use?). */