@ordewell/cli 0.5.2 → 0.5.3
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/main.js +28 -6
- package/package.json +3 -3
package/dist/main.js
CHANGED
|
@@ -390,10 +390,15 @@ var WorkspaceInitNeededError = class extends Error {
|
|
|
390
390
|
}
|
|
391
391
|
workspace;
|
|
392
392
|
};
|
|
393
|
-
var
|
|
393
|
+
var SESSION_PATH = /^\/api\/(?:plans|sessions)\/([^/?]+)/;
|
|
394
|
+
var ApiClient = class _ApiClient {
|
|
395
|
+
/** Where a CLI invocation's sessions live, when a client is built without one: `--workspace`, else the cwd. */
|
|
396
|
+
static defaultWorkspace;
|
|
394
397
|
port;
|
|
395
|
-
|
|
398
|
+
workspace;
|
|
399
|
+
constructor(port, workspace) {
|
|
396
400
|
this.port = port || DEFAULT_PORT;
|
|
401
|
+
this.workspace = workspace ?? _ApiClient.defaultWorkspace ?? process.cwd();
|
|
397
402
|
}
|
|
398
403
|
/**
|
|
399
404
|
* Read at call time rather than at construction: a daemon restarted mid-run
|
|
@@ -403,7 +408,23 @@ var ApiClient = class {
|
|
|
403
408
|
token() {
|
|
404
409
|
return (0, import_core3.readDaemonToken)(this.port);
|
|
405
410
|
}
|
|
406
|
-
|
|
411
|
+
/**
|
|
412
|
+
* A daemon holds only the sessions adopted since it started, so after a
|
|
413
|
+
* restart every session-scoped call answered "Session not found" until the
|
|
414
|
+
* user ran `ordewell sessions load`. The saved session is adopted here
|
|
415
|
+
* instead — idempotent for one the daemon still holds — and the call made
|
|
416
|
+
* once more; a 404 means the first attempt never ran, so the retry cannot
|
|
417
|
+
* act twice.
|
|
418
|
+
*/
|
|
419
|
+
async httpRequest(method, urlPath, body) {
|
|
420
|
+
const res = await this.rawRequest(method, urlPath, body);
|
|
421
|
+
const sessionId = urlPath.match(SESSION_PATH)?.[1];
|
|
422
|
+
const missing = res.status === 404 && res.data?.error === "Session not found";
|
|
423
|
+
if (!missing || !sessionId || urlPath.split("?")[0].endsWith("/load")) return res;
|
|
424
|
+
const adopted2 = await this.rawRequest("POST", `/api/sessions/${sessionId}/load?workspace=${encodeURIComponent(this.workspace)}`);
|
|
425
|
+
return adopted2.status === 200 ? this.rawRequest(method, urlPath, body) : res;
|
|
426
|
+
}
|
|
427
|
+
rawRequest(method, urlPath, body) {
|
|
407
428
|
return new Promise((resolve3, reject) => {
|
|
408
429
|
const url = new URL(urlPath, `http://127.0.0.1:${this.port}`);
|
|
409
430
|
const configuredTimeout = Number.parseInt(process.env.ORDEWELL_HTTP_TIMEOUT_MS || "", 10);
|
|
@@ -1065,7 +1086,7 @@ function isTransient(event) {
|
|
|
1065
1086
|
// src/commands/plan.ts
|
|
1066
1087
|
var import_core6 = require("@ordewell/core");
|
|
1067
1088
|
function planTasks(plan) {
|
|
1068
|
-
return plan
|
|
1089
|
+
return plan ? allTasksOf(plan) : [];
|
|
1069
1090
|
}
|
|
1070
1091
|
function hasCommittedPlan(plan) {
|
|
1071
1092
|
return planTasks(plan).length > 0;
|
|
@@ -1133,7 +1154,7 @@ function printPlan(plan, sessionId, runners2, models) {
|
|
|
1133
1154
|
return rp ? ` (${task.assignedModel.modelLabel} \xB7 ${label})` : ` (${task.assignedModel.modelLabel})`;
|
|
1134
1155
|
};
|
|
1135
1156
|
console.log(`
|
|
1136
|
-
Plan: ${tasks.length} tasks (${aiCount} AI, ${manCount} Manual) \u2014 ${(plan.runners || runners2).join(", ")}`);
|
|
1157
|
+
Plan: ${tasks.length} task${tasks.length === 1 ? "" : "s"} (${aiCount} AI, ${manCount} Manual) \u2014 ${(plan.runners || runners2).join(", ")}`);
|
|
1137
1158
|
console.log(`Session: ${sessionId}
|
|
1138
1159
|
`);
|
|
1139
1160
|
for (const t of tasks) {
|
|
@@ -7210,7 +7231,7 @@ cd into a directory that exists, or pass --workspace <path> naming one that does
|
|
|
7210
7231
|
const targetPort = explicitPort ? resolvePort(subArgs) : await findFreePort();
|
|
7211
7232
|
const { port, owned: ownedAtLaunch } = await ensureDaemonOwned(targetPort, { detached: false });
|
|
7212
7233
|
let owned = ownedAtLaunch;
|
|
7213
|
-
const api = new ApiClient(port);
|
|
7234
|
+
const api = new ApiClient(port, workspace);
|
|
7214
7235
|
const conversationQueue = new ConversationQueue();
|
|
7215
7236
|
let terminal;
|
|
7216
7237
|
const autoMode = process.env.ORDEWELL_AUTONOMOUS_MODE;
|
|
@@ -7358,6 +7379,7 @@ async function main() {
|
|
|
7358
7379
|
console.log(cliVersion());
|
|
7359
7380
|
return;
|
|
7360
7381
|
}
|
|
7382
|
+
ApiClient.defaultWorkspace = flag(argv, "--workspace") || void 0;
|
|
7361
7383
|
const sessionAt = argv.indexOf("--session-id");
|
|
7362
7384
|
if (sessionAt > 0 && argv[sessionAt + 1]) {
|
|
7363
7385
|
argv[sessionAt + 1] = expandSessionId(argv[sessionAt + 1], flag(argv, "--workspace") || process.cwd());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ordewell/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "Ordewell CLI and TUI — plan, run and verify coding-agent tasks from the terminal.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Alessandro Costanzo Ciano",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"typecheck": "tsc --noEmit"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@ordewell/core": "^0.5.
|
|
52
|
-
"@ordewell/web": "^0.5.
|
|
51
|
+
"@ordewell/core": "^0.5.3",
|
|
52
|
+
"@ordewell/web": "^0.5.3",
|
|
53
53
|
"string-width": "^7.2.0",
|
|
54
54
|
"ws": "^8.18.0"
|
|
55
55
|
},
|