@codelia/cli 0.1.71 → 0.1.74
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/index.cjs +90 -20
- package/dist/index.js +91 -21
- package/package.json +10 -10
package/dist/index.cjs
CHANGED
|
@@ -1049,8 +1049,10 @@ var writeAtifFromSessionJsonl = async ({
|
|
|
1049
1049
|
const records = await readSessionJsonl(sessionLogPath);
|
|
1050
1050
|
const trajectory = sessionRecordsToAtif(records, runId);
|
|
1051
1051
|
await (0, import_promises.mkdir)(import_node_path2.default.dirname(outPath), { recursive: true });
|
|
1052
|
-
|
|
1052
|
+
const tempPath = `${outPath}.tmp-${process.pid}-${Date.now()}`;
|
|
1053
|
+
await (0, import_promises.writeFile)(tempPath, `${JSON.stringify(trajectory, null, 2)}
|
|
1053
1054
|
`, "utf8");
|
|
1055
|
+
await (0, import_promises.rename)(tempPath, outPath);
|
|
1054
1056
|
return trajectory;
|
|
1055
1057
|
};
|
|
1056
1058
|
|
|
@@ -1062,7 +1064,7 @@ var import_node_path3 = __toESM(require("path"), 1);
|
|
|
1062
1064
|
var import_storage3 = require("@codelia/storage");
|
|
1063
1065
|
|
|
1064
1066
|
// src/version.ts
|
|
1065
|
-
var CLI_VERSION = "0.1.
|
|
1067
|
+
var CLI_VERSION = "0.1.74".trim().length > 0 ? "0.1.74" : "0.0.0";
|
|
1066
1068
|
|
|
1067
1069
|
// src/tui/launcher.ts
|
|
1068
1070
|
var resolveTuiBinaryName = (platform) => platform === "win32" ? "codelia-tui.exe" : "codelia-tui";
|
|
@@ -1366,10 +1368,29 @@ var summarizeProgressEvent = (event) => {
|
|
|
1366
1368
|
};
|
|
1367
1369
|
var isRpcResponse = (value) => typeof value === "object" && value !== null && "jsonrpc" in value && "id" in value && !value.method;
|
|
1368
1370
|
var isRpcNotification = (value) => typeof value === "object" && value !== null && "jsonrpc" in value && "method" in value && !value.id;
|
|
1371
|
+
var writePromptModeAtif = async ({
|
|
1372
|
+
atifOut,
|
|
1373
|
+
sessionLogPath,
|
|
1374
|
+
runId
|
|
1375
|
+
}) => {
|
|
1376
|
+
if (!atifOut) {
|
|
1377
|
+
return "skipped";
|
|
1378
|
+
}
|
|
1379
|
+
if (!sessionLogPath || !runId) {
|
|
1380
|
+
throw new Error("CODELIA_ATIF_OUT was set but session log path is missing");
|
|
1381
|
+
}
|
|
1382
|
+
await writeAtifFromSessionJsonl({
|
|
1383
|
+
sessionLogPath,
|
|
1384
|
+
runId,
|
|
1385
|
+
outPath: atifOut
|
|
1386
|
+
});
|
|
1387
|
+
return "written";
|
|
1388
|
+
};
|
|
1369
1389
|
var runPromptMode = async (options) => {
|
|
1370
1390
|
const emitProgressToStderr = envTruthy(
|
|
1371
1391
|
process.env.CODELIA_PROMPT_PROGRESS_STDERR
|
|
1372
1392
|
);
|
|
1393
|
+
const atifOut = process.env.CODELIA_ATIF_OUT?.trim();
|
|
1373
1394
|
const runtimeEnv = resolveRuntimeEnvForTui(process.env);
|
|
1374
1395
|
const runtimeCmd = runtimeEnv.CODELIA_RUNTIME_CMD ?? process.execPath;
|
|
1375
1396
|
const runtimeArgsValue = runtimeEnv.CODELIA_RUNTIME_ARGS ?? "packages/runtime/src/index.ts";
|
|
@@ -1390,6 +1411,8 @@ var runPromptMode = async (options) => {
|
|
|
1390
1411
|
let finalText = "";
|
|
1391
1412
|
let terminalStatus = null;
|
|
1392
1413
|
let terminalMessage;
|
|
1414
|
+
let atifWritten = false;
|
|
1415
|
+
let atifWriteInFlight = null;
|
|
1393
1416
|
const pendingResponses = /* @__PURE__ */ new Map();
|
|
1394
1417
|
let startupFailure = null;
|
|
1395
1418
|
const failPending = (error) => {
|
|
@@ -1416,6 +1439,53 @@ var runPromptMode = async (options) => {
|
|
|
1416
1439
|
if (!wrote) {
|
|
1417
1440
|
}
|
|
1418
1441
|
};
|
|
1442
|
+
const writeAtifOnce = async () => {
|
|
1443
|
+
if (atifWritten) {
|
|
1444
|
+
return "written";
|
|
1445
|
+
}
|
|
1446
|
+
atifWriteInFlight ??= writePromptModeAtif({
|
|
1447
|
+
atifOut,
|
|
1448
|
+
sessionLogPath,
|
|
1449
|
+
runId
|
|
1450
|
+
});
|
|
1451
|
+
const result = await atifWriteInFlight;
|
|
1452
|
+
if (result === "written") {
|
|
1453
|
+
atifWritten = true;
|
|
1454
|
+
}
|
|
1455
|
+
return result;
|
|
1456
|
+
};
|
|
1457
|
+
const signalNumbers = {
|
|
1458
|
+
SIGHUP: 1,
|
|
1459
|
+
SIGINT: 2,
|
|
1460
|
+
SIGTERM: 15
|
|
1461
|
+
};
|
|
1462
|
+
const handledSignals = Object.keys(signalNumbers);
|
|
1463
|
+
const handleTerminationSignal = (signal) => {
|
|
1464
|
+
void (async () => {
|
|
1465
|
+
try {
|
|
1466
|
+
await writeAtifOnce();
|
|
1467
|
+
} catch (error) {
|
|
1468
|
+
console.error(
|
|
1469
|
+
`Failed to write partial ATIF trajectory on ${signal}: ${error instanceof Error ? error.message : String(error)}`
|
|
1470
|
+
);
|
|
1471
|
+
} finally {
|
|
1472
|
+
if (!child.killed) {
|
|
1473
|
+
child.kill(signal);
|
|
1474
|
+
}
|
|
1475
|
+
process.exit(
|
|
1476
|
+
128 + (signalNumbers[signal] ?? 1)
|
|
1477
|
+
);
|
|
1478
|
+
}
|
|
1479
|
+
})();
|
|
1480
|
+
};
|
|
1481
|
+
for (const signal of handledSignals) {
|
|
1482
|
+
process.once(signal, handleTerminationSignal);
|
|
1483
|
+
}
|
|
1484
|
+
const cleanupSignalHandlers = () => {
|
|
1485
|
+
for (const signal of handledSignals) {
|
|
1486
|
+
process.removeListener(signal, handleTerminationSignal);
|
|
1487
|
+
}
|
|
1488
|
+
};
|
|
1419
1489
|
const maybeTrackRunLifecycle = (value) => {
|
|
1420
1490
|
if (!isRpcNotification(value)) return;
|
|
1421
1491
|
if (value.method === "run.status") {
|
|
@@ -1548,6 +1618,7 @@ var runPromptMode = async (options) => {
|
|
|
1548
1618
|
}, 50);
|
|
1549
1619
|
});
|
|
1550
1620
|
} catch (error) {
|
|
1621
|
+
cleanupSignalHandlers();
|
|
1551
1622
|
console.error(
|
|
1552
1623
|
`Prompt run failed: ${error instanceof Error ? error.message : String(error)}`
|
|
1553
1624
|
);
|
|
@@ -1558,30 +1629,29 @@ var runPromptMode = async (options) => {
|
|
|
1558
1629
|
}
|
|
1559
1630
|
}
|
|
1560
1631
|
if (terminalStatus === "completed") {
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
sessionLogPath,
|
|
1570
|
-
runId,
|
|
1571
|
-
outPath: atifOut
|
|
1572
|
-
});
|
|
1573
|
-
} catch (error) {
|
|
1574
|
-
console.error(
|
|
1575
|
-
`Failed to write ATIF trajectory: ${error instanceof Error ? error.message : String(error)}`
|
|
1576
|
-
);
|
|
1577
|
-
return 1;
|
|
1578
|
-
}
|
|
1632
|
+
try {
|
|
1633
|
+
await writeAtifOnce();
|
|
1634
|
+
} catch (error) {
|
|
1635
|
+
cleanupSignalHandlers();
|
|
1636
|
+
console.error(
|
|
1637
|
+
`Failed to write ATIF trajectory: ${error instanceof Error ? error.message : String(error)}`
|
|
1638
|
+
);
|
|
1639
|
+
return 1;
|
|
1579
1640
|
}
|
|
1641
|
+
cleanupSignalHandlers();
|
|
1580
1642
|
if (finalText.trim().length > 0) {
|
|
1581
1643
|
console.log(finalText);
|
|
1582
1644
|
}
|
|
1583
1645
|
return 0;
|
|
1584
1646
|
}
|
|
1647
|
+
try {
|
|
1648
|
+
await writeAtifOnce();
|
|
1649
|
+
} catch (error) {
|
|
1650
|
+
console.error(
|
|
1651
|
+
`Failed to write partial ATIF trajectory: ${error instanceof Error ? error.message : String(error)}`
|
|
1652
|
+
);
|
|
1653
|
+
}
|
|
1654
|
+
cleanupSignalHandlers();
|
|
1585
1655
|
if (terminalMessage) {
|
|
1586
1656
|
console.error(terminalMessage);
|
|
1587
1657
|
}
|
package/dist/index.js
CHANGED
|
@@ -823,7 +823,7 @@ var runMcpCommand = async (values) => {
|
|
|
823
823
|
import { spawn as spawn3 } from "child_process";
|
|
824
824
|
|
|
825
825
|
// src/atif.ts
|
|
826
|
-
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
826
|
+
import { mkdir, readFile, rename, writeFile } from "fs/promises";
|
|
827
827
|
import path2 from "path";
|
|
828
828
|
var asRecord = (value) => typeof value === "object" && value !== null ? value : null;
|
|
829
829
|
var asString = (value) => typeof value === "string" && value.trim().length > 0 ? value : void 0;
|
|
@@ -1033,8 +1033,10 @@ var writeAtifFromSessionJsonl = async ({
|
|
|
1033
1033
|
const records = await readSessionJsonl(sessionLogPath);
|
|
1034
1034
|
const trajectory = sessionRecordsToAtif(records, runId);
|
|
1035
1035
|
await mkdir(path2.dirname(outPath), { recursive: true });
|
|
1036
|
-
|
|
1036
|
+
const tempPath = `${outPath}.tmp-${process.pid}-${Date.now()}`;
|
|
1037
|
+
await writeFile(tempPath, `${JSON.stringify(trajectory, null, 2)}
|
|
1037
1038
|
`, "utf8");
|
|
1039
|
+
await rename(tempPath, outPath);
|
|
1038
1040
|
return trajectory;
|
|
1039
1041
|
};
|
|
1040
1042
|
|
|
@@ -1046,7 +1048,7 @@ import path3 from "path";
|
|
|
1046
1048
|
import { ensureStorageDirs, resolveStoragePaths as resolveStoragePaths2 } from "@codelia/storage";
|
|
1047
1049
|
|
|
1048
1050
|
// src/version.ts
|
|
1049
|
-
var CLI_VERSION = "0.1.
|
|
1051
|
+
var CLI_VERSION = "0.1.74".trim().length > 0 ? "0.1.74" : "0.0.0";
|
|
1050
1052
|
|
|
1051
1053
|
// src/tui/launcher.ts
|
|
1052
1054
|
var resolveTuiBinaryName = (platform) => platform === "win32" ? "codelia-tui.exe" : "codelia-tui";
|
|
@@ -1350,10 +1352,29 @@ var summarizeProgressEvent = (event) => {
|
|
|
1350
1352
|
};
|
|
1351
1353
|
var isRpcResponse = (value) => typeof value === "object" && value !== null && "jsonrpc" in value && "id" in value && !value.method;
|
|
1352
1354
|
var isRpcNotification = (value) => typeof value === "object" && value !== null && "jsonrpc" in value && "method" in value && !value.id;
|
|
1355
|
+
var writePromptModeAtif = async ({
|
|
1356
|
+
atifOut,
|
|
1357
|
+
sessionLogPath,
|
|
1358
|
+
runId
|
|
1359
|
+
}) => {
|
|
1360
|
+
if (!atifOut) {
|
|
1361
|
+
return "skipped";
|
|
1362
|
+
}
|
|
1363
|
+
if (!sessionLogPath || !runId) {
|
|
1364
|
+
throw new Error("CODELIA_ATIF_OUT was set but session log path is missing");
|
|
1365
|
+
}
|
|
1366
|
+
await writeAtifFromSessionJsonl({
|
|
1367
|
+
sessionLogPath,
|
|
1368
|
+
runId,
|
|
1369
|
+
outPath: atifOut
|
|
1370
|
+
});
|
|
1371
|
+
return "written";
|
|
1372
|
+
};
|
|
1353
1373
|
var runPromptMode = async (options) => {
|
|
1354
1374
|
const emitProgressToStderr = envTruthy(
|
|
1355
1375
|
process.env.CODELIA_PROMPT_PROGRESS_STDERR
|
|
1356
1376
|
);
|
|
1377
|
+
const atifOut = process.env.CODELIA_ATIF_OUT?.trim();
|
|
1357
1378
|
const runtimeEnv = resolveRuntimeEnvForTui(process.env);
|
|
1358
1379
|
const runtimeCmd = runtimeEnv.CODELIA_RUNTIME_CMD ?? process.execPath;
|
|
1359
1380
|
const runtimeArgsValue = runtimeEnv.CODELIA_RUNTIME_ARGS ?? "packages/runtime/src/index.ts";
|
|
@@ -1374,6 +1395,8 @@ var runPromptMode = async (options) => {
|
|
|
1374
1395
|
let finalText = "";
|
|
1375
1396
|
let terminalStatus = null;
|
|
1376
1397
|
let terminalMessage;
|
|
1398
|
+
let atifWritten = false;
|
|
1399
|
+
let atifWriteInFlight = null;
|
|
1377
1400
|
const pendingResponses = /* @__PURE__ */ new Map();
|
|
1378
1401
|
let startupFailure = null;
|
|
1379
1402
|
const failPending = (error) => {
|
|
@@ -1400,6 +1423,53 @@ var runPromptMode = async (options) => {
|
|
|
1400
1423
|
if (!wrote) {
|
|
1401
1424
|
}
|
|
1402
1425
|
};
|
|
1426
|
+
const writeAtifOnce = async () => {
|
|
1427
|
+
if (atifWritten) {
|
|
1428
|
+
return "written";
|
|
1429
|
+
}
|
|
1430
|
+
atifWriteInFlight ??= writePromptModeAtif({
|
|
1431
|
+
atifOut,
|
|
1432
|
+
sessionLogPath,
|
|
1433
|
+
runId
|
|
1434
|
+
});
|
|
1435
|
+
const result = await atifWriteInFlight;
|
|
1436
|
+
if (result === "written") {
|
|
1437
|
+
atifWritten = true;
|
|
1438
|
+
}
|
|
1439
|
+
return result;
|
|
1440
|
+
};
|
|
1441
|
+
const signalNumbers = {
|
|
1442
|
+
SIGHUP: 1,
|
|
1443
|
+
SIGINT: 2,
|
|
1444
|
+
SIGTERM: 15
|
|
1445
|
+
};
|
|
1446
|
+
const handledSignals = Object.keys(signalNumbers);
|
|
1447
|
+
const handleTerminationSignal = (signal) => {
|
|
1448
|
+
void (async () => {
|
|
1449
|
+
try {
|
|
1450
|
+
await writeAtifOnce();
|
|
1451
|
+
} catch (error) {
|
|
1452
|
+
console.error(
|
|
1453
|
+
`Failed to write partial ATIF trajectory on ${signal}: ${error instanceof Error ? error.message : String(error)}`
|
|
1454
|
+
);
|
|
1455
|
+
} finally {
|
|
1456
|
+
if (!child.killed) {
|
|
1457
|
+
child.kill(signal);
|
|
1458
|
+
}
|
|
1459
|
+
process.exit(
|
|
1460
|
+
128 + (signalNumbers[signal] ?? 1)
|
|
1461
|
+
);
|
|
1462
|
+
}
|
|
1463
|
+
})();
|
|
1464
|
+
};
|
|
1465
|
+
for (const signal of handledSignals) {
|
|
1466
|
+
process.once(signal, handleTerminationSignal);
|
|
1467
|
+
}
|
|
1468
|
+
const cleanupSignalHandlers = () => {
|
|
1469
|
+
for (const signal of handledSignals) {
|
|
1470
|
+
process.removeListener(signal, handleTerminationSignal);
|
|
1471
|
+
}
|
|
1472
|
+
};
|
|
1403
1473
|
const maybeTrackRunLifecycle = (value) => {
|
|
1404
1474
|
if (!isRpcNotification(value)) return;
|
|
1405
1475
|
if (value.method === "run.status") {
|
|
@@ -1532,6 +1602,7 @@ var runPromptMode = async (options) => {
|
|
|
1532
1602
|
}, 50);
|
|
1533
1603
|
});
|
|
1534
1604
|
} catch (error) {
|
|
1605
|
+
cleanupSignalHandlers();
|
|
1535
1606
|
console.error(
|
|
1536
1607
|
`Prompt run failed: ${error instanceof Error ? error.message : String(error)}`
|
|
1537
1608
|
);
|
|
@@ -1542,30 +1613,29 @@ var runPromptMode = async (options) => {
|
|
|
1542
1613
|
}
|
|
1543
1614
|
}
|
|
1544
1615
|
if (terminalStatus === "completed") {
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
sessionLogPath,
|
|
1554
|
-
runId,
|
|
1555
|
-
outPath: atifOut
|
|
1556
|
-
});
|
|
1557
|
-
} catch (error) {
|
|
1558
|
-
console.error(
|
|
1559
|
-
`Failed to write ATIF trajectory: ${error instanceof Error ? error.message : String(error)}`
|
|
1560
|
-
);
|
|
1561
|
-
return 1;
|
|
1562
|
-
}
|
|
1616
|
+
try {
|
|
1617
|
+
await writeAtifOnce();
|
|
1618
|
+
} catch (error) {
|
|
1619
|
+
cleanupSignalHandlers();
|
|
1620
|
+
console.error(
|
|
1621
|
+
`Failed to write ATIF trajectory: ${error instanceof Error ? error.message : String(error)}`
|
|
1622
|
+
);
|
|
1623
|
+
return 1;
|
|
1563
1624
|
}
|
|
1625
|
+
cleanupSignalHandlers();
|
|
1564
1626
|
if (finalText.trim().length > 0) {
|
|
1565
1627
|
console.log(finalText);
|
|
1566
1628
|
}
|
|
1567
1629
|
return 0;
|
|
1568
1630
|
}
|
|
1631
|
+
try {
|
|
1632
|
+
await writeAtifOnce();
|
|
1633
|
+
} catch (error) {
|
|
1634
|
+
console.error(
|
|
1635
|
+
`Failed to write partial ATIF trajectory: ${error instanceof Error ? error.message : String(error)}`
|
|
1636
|
+
);
|
|
1637
|
+
}
|
|
1638
|
+
cleanupSignalHandlers();
|
|
1569
1639
|
if (terminalMessage) {
|
|
1570
1640
|
console.error(terminalMessage);
|
|
1571
1641
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codelia/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.74",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20 <25"
|
|
@@ -19,19 +19,19 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@codelia/config-loader": "0.1.
|
|
23
|
-
"@codelia/protocol": "0.1.
|
|
24
|
-
"@codelia/runtime": "0.1.
|
|
25
|
-
"@codelia/storage": "0.1.
|
|
22
|
+
"@codelia/config-loader": "0.1.74",
|
|
23
|
+
"@codelia/protocol": "0.1.74",
|
|
24
|
+
"@codelia/runtime": "0.1.74",
|
|
25
|
+
"@codelia/storage": "0.1.74",
|
|
26
26
|
"cac": "^6.7.14",
|
|
27
27
|
"zod": "^4.3.6"
|
|
28
28
|
},
|
|
29
29
|
"optionalDependencies": {
|
|
30
|
-
"@codelia/tui-darwin-arm64": "0.1.
|
|
31
|
-
"@codelia/tui-darwin-x64": "0.1.
|
|
32
|
-
"@codelia/tui-linux-arm64": "0.1.
|
|
33
|
-
"@codelia/tui-linux-x64": "0.1.
|
|
34
|
-
"@codelia/tui-win32-x64": "0.1.
|
|
30
|
+
"@codelia/tui-darwin-arm64": "0.1.74",
|
|
31
|
+
"@codelia/tui-darwin-x64": "0.1.74",
|
|
32
|
+
"@codelia/tui-linux-arm64": "0.1.74",
|
|
33
|
+
"@codelia/tui-linux-x64": "0.1.74",
|
|
34
|
+
"@codelia/tui-win32-x64": "0.1.74"
|
|
35
35
|
},
|
|
36
36
|
"overrides": {
|
|
37
37
|
"gaxios": "7.1.4"
|