@h-rig/cli 0.0.6-alpha.45 → 0.0.6-alpha.46
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/dist/bin/rig.js +50 -22
- package/dist/src/commands/_connection-state.js +11 -3
- package/dist/src/commands/_doctor-checks.js +51 -7
- package/dist/src/commands/_operator-view.js +53 -7
- package/dist/src/commands/_pi-frontend.js +53 -7
- package/dist/src/commands/_pi-remote-session.js +53 -7
- package/dist/src/commands/_pi-worker-bridge-extension.js +53 -7
- package/dist/src/commands/_preflight.js +51 -7
- package/dist/src/commands/_server-client.js +58 -22
- package/dist/src/commands/_snapshot-upload.js +51 -7
- package/dist/src/commands/connect.js +2 -1
- package/dist/src/commands/doctor.js +51 -7
- package/dist/src/commands/github.js +51 -7
- package/dist/src/commands/inbox.js +51 -7
- package/dist/src/commands/init.js +48 -22
- package/dist/src/commands/inspect.js +51 -7
- package/dist/src/commands/run.js +53 -7
- package/dist/src/commands/server.js +43 -7
- package/dist/src/commands/setup.js +51 -7
- package/dist/src/commands/task-run-driver.js +51 -7
- package/dist/src/commands/task.js +53 -7
- package/dist/src/commands.js +50 -22
- package/dist/src/index.js +50 -22
- package/package.json +6 -6
package/dist/src/index.js
CHANGED
|
@@ -2884,7 +2884,8 @@ function readRepoConnection(projectRoot) {
|
|
|
2884
2884
|
return {
|
|
2885
2885
|
selected,
|
|
2886
2886
|
project: typeof record.project === "string" ? record.project : undefined,
|
|
2887
|
-
linkedAt: typeof record.linkedAt === "string" ? record.linkedAt : undefined
|
|
2887
|
+
linkedAt: typeof record.linkedAt === "string" ? record.linkedAt : undefined,
|
|
2888
|
+
serverProjectRoot: typeof record.serverProjectRoot === "string" && record.serverProjectRoot.trim() ? record.serverProjectRoot.trim() : undefined
|
|
2888
2889
|
};
|
|
2889
2890
|
}
|
|
2890
2891
|
function writeRepoConnection(projectRoot, state) {
|
|
@@ -2895,13 +2896,19 @@ function resolveSelectedConnection(projectRoot, options = {}) {
|
|
|
2895
2896
|
if (!repo)
|
|
2896
2897
|
return null;
|
|
2897
2898
|
if (repo.selected === "local")
|
|
2898
|
-
return { alias: "local", connection: { kind: "local", mode: "auto" } };
|
|
2899
|
+
return { alias: "local", connection: { kind: "local", mode: "auto" }, serverProjectRoot: repo.serverProjectRoot };
|
|
2899
2900
|
const global = readGlobalConnections(options);
|
|
2900
2901
|
const connection = global.connections[repo.selected];
|
|
2901
2902
|
if (!connection) {
|
|
2902
2903
|
throw new CliError2(`Selected Rig server "${repo.selected}" was not found. Run \`rig server list\` or \`rig server use local\`.`, 1);
|
|
2903
2904
|
}
|
|
2904
|
-
return { alias: repo.selected, connection };
|
|
2905
|
+
return { alias: repo.selected, connection, serverProjectRoot: repo.serverProjectRoot };
|
|
2906
|
+
}
|
|
2907
|
+
function writeRepoServerProjectRoot(projectRoot, serverProjectRoot) {
|
|
2908
|
+
const repo = readRepoConnection(projectRoot);
|
|
2909
|
+
if (!repo)
|
|
2910
|
+
return;
|
|
2911
|
+
writeRepoConnection(projectRoot, { ...repo, serverProjectRoot });
|
|
2905
2912
|
}
|
|
2906
2913
|
|
|
2907
2914
|
// packages/cli/src/commands/_server-client.ts
|
|
@@ -2942,17 +2949,21 @@ async function ensureServerForCli(projectRoot) {
|
|
|
2942
2949
|
try {
|
|
2943
2950
|
const selected = resolveSelectedConnection(projectRoot);
|
|
2944
2951
|
if (selected?.connection.kind === "remote") {
|
|
2952
|
+
const authToken = readGitHubBearerTokenForRemote(projectRoot);
|
|
2953
|
+
const serverProjectRoot = selected.serverProjectRoot ?? await backfillRemoteServerProjectRoot(projectRoot, selected.connection.baseUrl, authToken);
|
|
2945
2954
|
return {
|
|
2946
2955
|
baseUrl: selected.connection.baseUrl,
|
|
2947
|
-
authToken
|
|
2948
|
-
connectionKind: "remote"
|
|
2956
|
+
authToken,
|
|
2957
|
+
connectionKind: "remote",
|
|
2958
|
+
serverProjectRoot
|
|
2949
2959
|
};
|
|
2950
2960
|
}
|
|
2951
2961
|
const connection = await ensureLocalRigServerConnection(projectRoot);
|
|
2952
2962
|
return {
|
|
2953
2963
|
baseUrl: connection.baseUrl,
|
|
2954
2964
|
authToken: connection.authToken,
|
|
2955
|
-
connectionKind: "local"
|
|
2965
|
+
connectionKind: "local",
|
|
2966
|
+
serverProjectRoot: resolve11(projectRoot)
|
|
2956
2967
|
};
|
|
2957
2968
|
} catch (error) {
|
|
2958
2969
|
if (error instanceof Error) {
|
|
@@ -2961,6 +2972,28 @@ async function ensureServerForCli(projectRoot) {
|
|
|
2961
2972
|
throw error;
|
|
2962
2973
|
}
|
|
2963
2974
|
}
|
|
2975
|
+
async function backfillRemoteServerProjectRoot(projectRoot, baseUrl, authToken) {
|
|
2976
|
+
const repo = readRepoConnection(projectRoot);
|
|
2977
|
+
const slug = repo?.project?.trim();
|
|
2978
|
+
if (!slug)
|
|
2979
|
+
return null;
|
|
2980
|
+
try {
|
|
2981
|
+
const response = await fetch(`${baseUrl}/api/projects/${encodeURIComponent(slug)}`, {
|
|
2982
|
+
headers: mergeHeaders(undefined, authToken)
|
|
2983
|
+
});
|
|
2984
|
+
if (!response.ok)
|
|
2985
|
+
return null;
|
|
2986
|
+
const payload = await response.json();
|
|
2987
|
+
const project = payload.project && typeof payload.project === "object" && !Array.isArray(payload.project) ? payload.project : null;
|
|
2988
|
+
const checkout = project?.checkout && typeof project.checkout === "object" && !Array.isArray(project.checkout) ? project.checkout : null;
|
|
2989
|
+
const path = typeof checkout?.path === "string" && checkout.path.trim() ? checkout.path.trim() : typeof project?.path === "string" && project.path.trim() ? project.path.trim() : null;
|
|
2990
|
+
if (path)
|
|
2991
|
+
writeRepoServerProjectRoot(projectRoot, path);
|
|
2992
|
+
return path;
|
|
2993
|
+
} catch {
|
|
2994
|
+
return null;
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2964
2997
|
function appendTaskFilterParams(url, filters) {
|
|
2965
2998
|
if (filters.assignee)
|
|
2966
2999
|
url.searchParams.set("assignee", filters.assignee);
|
|
@@ -2995,9 +3028,12 @@ function diagnosticMessage(payload) {
|
|
|
2995
3028
|
}
|
|
2996
3029
|
async function requestServerJson(context, pathname, init = {}) {
|
|
2997
3030
|
const server = await ensureServerForCli(context.projectRoot);
|
|
3031
|
+
const headers = mergeHeaders(init.headers, server.authToken);
|
|
3032
|
+
if (server.serverProjectRoot)
|
|
3033
|
+
headers.set("x-rig-project-root", server.serverProjectRoot);
|
|
2998
3034
|
const response = await fetch(`${server.baseUrl}${pathname}`, {
|
|
2999
3035
|
...init,
|
|
3000
|
-
headers
|
|
3036
|
+
headers
|
|
3001
3037
|
});
|
|
3002
3038
|
const text2 = await response.text();
|
|
3003
3039
|
const payload = text2.trim().length > 0 ? (() => {
|
|
@@ -3104,22 +3140,12 @@ async function switchServerProjectRootViaServer(context, projectRoot, options =
|
|
|
3104
3140
|
if (!switched) {
|
|
3105
3141
|
throw new CliError2(`Rig server did not accept project-root switch to ${projectRoot} before timeout (${lastError instanceof Error ? lastError.message : String(lastError ?? "no response")}).`, 1);
|
|
3106
3142
|
}
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
const record = status;
|
|
3112
|
-
if (record.projectRoot === projectRoot) {
|
|
3113
|
-
return { ok: true, switched, status: record };
|
|
3114
|
-
}
|
|
3115
|
-
lastError = `server projectRoot=${String(record.projectRoot ?? "unknown")}`;
|
|
3116
|
-
}
|
|
3117
|
-
} catch (error) {
|
|
3118
|
-
lastError = error;
|
|
3119
|
-
}
|
|
3120
|
-
await sleep(pollMs);
|
|
3143
|
+
const record = switched && typeof switched === "object" && !Array.isArray(switched) ? switched : {};
|
|
3144
|
+
if (record.ok === true) {
|
|
3145
|
+
writeRepoServerProjectRoot(context.projectRoot, projectRoot);
|
|
3146
|
+
return { ok: true, switched: record };
|
|
3121
3147
|
}
|
|
3122
|
-
throw new CliError2(`Rig server
|
|
3148
|
+
throw new CliError2(`Rig server rejected project-root scope ${projectRoot}: ${String(record.message ?? record.error ?? "unknown error")}`, 1);
|
|
3123
3149
|
}
|
|
3124
3150
|
async function listRunsViaServer(context, options = {}) {
|
|
3125
3151
|
const url = new URL("http://rig.local/api/runs");
|
|
@@ -3251,6 +3277,8 @@ async function buildRunPiEventsWebSocketUrl(context, runId) {
|
|
|
3251
3277
|
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
3252
3278
|
if (server.authToken)
|
|
3253
3279
|
url.searchParams.set("token", server.authToken);
|
|
3280
|
+
if (server.serverProjectRoot)
|
|
3281
|
+
url.searchParams.set("rigProjectRoot", server.serverProjectRoot);
|
|
3254
3282
|
return url.toString();
|
|
3255
3283
|
}
|
|
3256
3284
|
async function submitTaskRunViaServer(context, input) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-rig/cli",
|
|
3
|
-
"version": "0.0.6-alpha.
|
|
3
|
+
"version": "0.0.6-alpha.46",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Rig package",
|
|
6
6
|
"license": "UNLICENSED",
|
|
@@ -23,11 +23,11 @@
|
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@clack/prompts": "^1.2.0",
|
|
26
|
-
"@earendil-works/pi-coding-agent": "npm:@h-rig/pi-coding-agent@0.0.6-alpha.
|
|
27
|
-
"@rig/core": "npm:@h-rig/core@0.0.6-alpha.
|
|
28
|
-
"@rig/runtime": "npm:@h-rig/runtime@0.0.6-alpha.
|
|
29
|
-
"@rig/client": "npm:@h-rig/client@0.0.6-alpha.
|
|
30
|
-
"@rig/server": "npm:@h-rig/server@0.0.6-alpha.
|
|
26
|
+
"@earendil-works/pi-coding-agent": "npm:@h-rig/pi-coding-agent@0.0.6-alpha.46",
|
|
27
|
+
"@rig/core": "npm:@h-rig/core@0.0.6-alpha.46",
|
|
28
|
+
"@rig/runtime": "npm:@h-rig/runtime@0.0.6-alpha.46",
|
|
29
|
+
"@rig/client": "npm:@h-rig/client@0.0.6-alpha.46",
|
|
30
|
+
"@rig/server": "npm:@h-rig/server@0.0.6-alpha.46",
|
|
31
31
|
"picocolors": "^1.1.1"
|
|
32
32
|
}
|
|
33
33
|
}
|