riftri 0.6.0 → 0.6.1

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.
package/lib/client.d.ts CHANGED
@@ -102,18 +102,74 @@ export interface ManagedWorktree {
102
102
  }
103
103
 
104
104
  export interface WorktreeInventory {
105
- schema_version: number;
105
+ schema_version: 1;
106
106
  state_directory: string;
107
+ state_directory_native_hex: string;
107
108
  worktrees: ManagedWorktree[];
109
+ diagnostic_issues: StateDiagnosticIssue[];
108
110
  native_path_encoding: string;
109
111
  }
110
112
 
113
+ export interface StateDiagnosticIssue {
114
+ path: string;
115
+ path_native_hex: string;
116
+ reason: string;
117
+ may_hide_base_reference: boolean;
118
+ }
119
+
120
+ export interface AllStatesManagedWorktree extends ManagedWorktree {
121
+ state_directory: string;
122
+ state_directory_native_hex: string;
123
+ }
124
+
125
+ export interface AllStatesDiagnosticIssue extends StateDiagnosticIssue {
126
+ /** Null for a registration issue that belongs to no usable state directory. */
127
+ state_directory: string | null;
128
+ state_directory_native_hex: string | null;
129
+ }
130
+
131
+ export interface AllStatesWorktreeInventory {
132
+ schema_version: 2;
133
+ scope: "all-registered-states";
134
+ state_directories: {
135
+ path: string;
136
+ path_native_hex: string;
137
+ source: "default" | "registered";
138
+ }[];
139
+ worktrees: AllStatesManagedWorktree[];
140
+ diagnostic_issues: AllStatesDiagnosticIssue[];
141
+ native_path_encoding: string;
142
+ }
143
+
144
+ /** Lifecycle counters; lower bounds when StatusReport.counts_complete is false. */
145
+ export interface StatusOperations {
146
+ active_views: number;
147
+ pending_adds: number;
148
+ completed_removals: number;
149
+ cancelled_removals: number;
150
+ pending_removals: number;
151
+ completed_moves: number;
152
+ cancelled_moves: number;
153
+ pending_moves: number;
154
+ completed_compactions: number;
155
+ cancelled_compactions: number;
156
+ pending_compactions: number;
157
+ completed_prunes: number;
158
+ pending_prunes: number;
159
+ completed_collections: number;
160
+ cancelled_collections: number;
161
+ pending_collections: number;
162
+ coordination_locks: number;
163
+ }
164
+
111
165
  export interface StatusReport {
112
166
  schema_version: number;
113
167
  state_directory: string;
114
168
  bases: unknown[];
115
169
  worktrees: unknown[];
116
- operations: unknown[];
170
+ /** False when unreadable journals make operation counts lower bounds. */
171
+ counts_complete: boolean;
172
+ operations: StatusOperations;
117
173
  diagnostic_issues: unknown[];
118
174
  total_allocated_bytes: number;
119
175
  total_logical_bytes: number;
@@ -183,7 +239,10 @@ export class Riftri {
183
239
 
184
240
  readonly worktree: {
185
241
  add(destination: string, options?: AddOptions): Promise<AddReport>;
186
- list(options?: { allStates?: boolean }): Promise<WorktreeInventory>;
242
+ list(options: { allStates: true }): Promise<AllStatesWorktreeInventory>;
243
+ list(options?: { allStates?: false }): Promise<WorktreeInventory>;
244
+ /** Narrow schema_version when allStates is a runtime boolean. */
245
+ list(options?: { allStates?: boolean }): Promise<WorktreeInventory | AllStatesWorktreeInventory>;
187
246
  /** Refuses a dirty worktree unless `force` is set. */
188
247
  remove(destination: string, options?: { force?: boolean }): Promise<unknown>;
189
248
  move(source: string, destination: string): Promise<unknown>;
package/lib/client.js CHANGED
@@ -31,7 +31,9 @@ const REPORTING = new Set([
31
31
  class RiftriError extends Error {
32
32
  constructor(exitCode, receipt, stderr, signal = null) {
33
33
  super(
34
- receipt?.message ||
34
+ // JSON is not a guarantee of a valid receipt. Coercing an object here
35
+ // can throw inside the child close handler instead of rejecting run().
36
+ (typeof receipt?.message === "string" ? receipt.message : "") ||
35
37
  stderr.trim() ||
36
38
  (signal ? `riftri terminated by ${signal}` : `riftri exited ${exitCode}`),
37
39
  );
@@ -151,7 +153,18 @@ class Riftri {
151
153
  }
152
154
  let stdout = "";
153
155
  let stderr = "";
154
- child.stdout.on("data", (chunk) => (stdout += chunk));
156
+ // Pipe chunks need not end on a UTF-8 character boundary. Let each
157
+ // stream retain incomplete bytes between chunks (and flush at EOF).
158
+ if (json) {
159
+ child.stdout.setEncoding("utf8");
160
+ child.stdout.on("data", (chunk) => (stdout += chunk));
161
+ } else {
162
+ // The API returns null for non-reporting commands. Drain their output
163
+ // without decoding or retaining it, so verbose children cannot grow
164
+ // the host heap in proportion to output that will be discarded.
165
+ child.stdout.resume();
166
+ }
167
+ child.stderr.setEncoding("utf8");
155
168
  child.stderr.on("data", (chunk) => (stderr += chunk));
156
169
  child.on("error", reject);
157
170
  child.on("close", (exitCode, signal) => {
@@ -163,7 +176,7 @@ class Riftri {
163
176
  return;
164
177
  }
165
178
  if (exitCode === EXIT_SUCCESS) {
166
- if (!json || !stdout.trim()) {
179
+ if (!json) {
167
180
  resolve(null);
168
181
  return;
169
182
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "riftri",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Experimental lightweight Git workspaces for parallel development",
5
5
  "license": "MIT",
6
6
  "author": "Assistant UI contributors",
@@ -17,15 +17,19 @@
17
17
  "engines": {
18
18
  "node": ">=18.18"
19
19
  },
20
+ "devDependencies": {
21
+ "@types/node": "18.19.130",
22
+ "typescript": "5.9.3"
23
+ },
20
24
  "optionalDependencies": {
21
- "riftri-darwin-arm64": "0.6.0",
22
- "riftri-darwin-x64": "0.6.0",
23
- "riftri-linux-arm64-gnu": "0.6.0",
24
- "riftri-linux-arm64-musl": "0.6.0",
25
- "riftri-linux-x64-gnu": "0.6.0",
26
- "riftri-linux-x64-musl": "0.6.0",
27
- "riftri-win32-arm64": "0.6.0",
28
- "riftri-win32-x64": "0.6.0"
25
+ "riftri-darwin-arm64": "0.6.1",
26
+ "riftri-darwin-x64": "0.6.1",
27
+ "riftri-linux-arm64-gnu": "0.6.1",
28
+ "riftri-linux-arm64-musl": "0.6.1",
29
+ "riftri-linux-x64-gnu": "0.6.1",
30
+ "riftri-linux-x64-musl": "0.6.1",
31
+ "riftri-win32-arm64": "0.6.1",
32
+ "riftri-win32-x64": "0.6.1"
29
33
  },
30
34
  "repository": {
31
35
  "type": "git",