riftri 0.6.0 → 0.6.2
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 +62 -3
- package/lib/client.js +21 -5
- package/lib/platform.js +23 -1
- package/package.json +13 -9
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:
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
|
179
|
+
if (!json) {
|
|
167
180
|
resolve(null);
|
|
168
181
|
return;
|
|
169
182
|
}
|
|
@@ -187,8 +200,11 @@ class Riftri {
|
|
|
187
200
|
// child wrote there first (a hook's output, a Git warning) must not
|
|
188
201
|
// cost the caller the receipt's code and category.
|
|
189
202
|
let receipt = null;
|
|
190
|
-
|
|
191
|
-
for
|
|
203
|
+
// Preserve the full diagnostic fallback without allocating an array
|
|
204
|
+
// and a string entry for every line of a verbose child's output.
|
|
205
|
+
const trimmed = stderr.trimEnd();
|
|
206
|
+
const lastLine = trimmed.slice(trimmed.lastIndexOf("\n") + 1);
|
|
207
|
+
for (const candidate of [lastLine, stderr]) {
|
|
192
208
|
try {
|
|
193
209
|
receipt = JSON.parse(candidate);
|
|
194
210
|
break;
|
package/lib/platform.js
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
const fs = require("node:fs");
|
|
4
4
|
const path = require("node:path");
|
|
5
5
|
|
|
6
|
+
// Kept in step with the ELF release gate and standalone installer by tests.
|
|
7
|
+
const GLIBC_FLOOR = "2.34";
|
|
8
|
+
|
|
6
9
|
const PLATFORM_PACKAGES = Object.freeze({
|
|
7
10
|
"darwin-arm64": "riftri-darwin-arm64",
|
|
8
11
|
"darwin-x64": "riftri-darwin-x64",
|
|
@@ -20,7 +23,22 @@ function detectLinuxLibc(report = process.report) {
|
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
const header = report.getReport()?.header;
|
|
23
|
-
|
|
26
|
+
const version = header?.glibcVersionRuntime;
|
|
27
|
+
if (!version) return "musl";
|
|
28
|
+
const parts = typeof version === "string" && /^(\d+)\.(\d+)(?:\.\d+)?$/.exec(version);
|
|
29
|
+
const [major, minor] = parts ? parts.slice(1, 3).map(Number) : [];
|
|
30
|
+
const [floorMajor, floorMinor] = GLIBC_FLOOR.split(".").map(Number);
|
|
31
|
+
if (!Number.isSafeInteger(major) || !Number.isSafeInteger(minor) ||
|
|
32
|
+
major < floorMajor || (major === floorMajor && minor < floorMinor)) {
|
|
33
|
+
// npm excludes musl optional dependencies on glibc hosts. Do not select
|
|
34
|
+
// an absent package or attempt to execute an incompatible GNU binary.
|
|
35
|
+
throw new Error(
|
|
36
|
+
`Riftri's GNU npm binary requires glibc ${GLIBC_FLOOR} or newer (detected ${version}); ` +
|
|
37
|
+
"use the standalone installer at https://riftri.dev/install.sh for the static musl binary, " +
|
|
38
|
+
"then set RIFTRI_BINARY to its absolute path when using the Node SDK",
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return "gnu";
|
|
24
42
|
}
|
|
25
43
|
|
|
26
44
|
function platformKey(
|
|
@@ -44,6 +62,9 @@ function binaryName(platform = process.platform) {
|
|
|
44
62
|
|
|
45
63
|
function assertUsableBinary(candidate, source) {
|
|
46
64
|
try {
|
|
65
|
+
// Follow executable symlinks, but reject directories and special files
|
|
66
|
+
// that can pass an access check without being runnable binaries.
|
|
67
|
+
if (!fs.statSync(candidate).isFile()) throw new Error("not a regular file");
|
|
47
68
|
fs.accessSync(
|
|
48
69
|
candidate,
|
|
49
70
|
process.platform === "win32" ? fs.constants.F_OK : fs.constants.X_OK,
|
|
@@ -124,6 +145,7 @@ function resolveBinary(options = {}) {
|
|
|
124
145
|
}
|
|
125
146
|
|
|
126
147
|
module.exports = {
|
|
148
|
+
GLIBC_FLOOR,
|
|
127
149
|
PLATFORM_PACKAGES,
|
|
128
150
|
assertCompatiblePackageManifest,
|
|
129
151
|
binaryName,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "riftri",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.2",
|
|
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.
|
|
22
|
-
"riftri-darwin-x64": "0.6.
|
|
23
|
-
"riftri-linux-arm64-gnu": "0.6.
|
|
24
|
-
"riftri-linux-arm64-musl": "0.6.
|
|
25
|
-
"riftri-linux-x64-gnu": "0.6.
|
|
26
|
-
"riftri-linux-x64-musl": "0.6.
|
|
27
|
-
"riftri-win32-arm64": "0.6.
|
|
28
|
-
"riftri-win32-x64": "0.6.
|
|
25
|
+
"riftri-darwin-arm64": "0.6.2",
|
|
26
|
+
"riftri-darwin-x64": "0.6.2",
|
|
27
|
+
"riftri-linux-arm64-gnu": "0.6.2",
|
|
28
|
+
"riftri-linux-arm64-musl": "0.6.2",
|
|
29
|
+
"riftri-linux-x64-gnu": "0.6.2",
|
|
30
|
+
"riftri-linux-x64-musl": "0.6.2",
|
|
31
|
+
"riftri-win32-arm64": "0.6.2",
|
|
32
|
+
"riftri-win32-x64": "0.6.2"
|
|
29
33
|
},
|
|
30
34
|
"repository": {
|
|
31
35
|
"type": "git",
|