@paradow/ledge 0.33.0 → 0.35.0
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/cli/index.js +39003 -46
- package/dist/cli/reduceWorker.js +2037 -0
- package/dist/ledge-guide.md +26 -49
- package/package.json +5 -1
- package/dist/cli/action-QW2ZQQBN.js +0 -27
- package/dist/cli/attach-ULTYWCJ7.js +0 -74
- package/dist/cli/bridge-CSLF7EW6.js +0 -70
- package/dist/cli/chunk-3DB3VOMM.js +0 -723
- package/dist/cli/chunk-4HXJQEUN.js +0 -118
- package/dist/cli/chunk-4VNKZOC2.js +0 -160
- package/dist/cli/chunk-6IYPRUQG.js +0 -17
- package/dist/cli/chunk-ASYAWVFW.js +0 -95
- package/dist/cli/chunk-CCSUP5ZI.js +0 -45
- package/dist/cli/chunk-CPERVAPQ.js +0 -232
- package/dist/cli/chunk-CSLVBADC.js +0 -60
- package/dist/cli/chunk-E3LXONBI.js +0 -6
- package/dist/cli/chunk-GXL3X7M7.js +0 -144
- package/dist/cli/chunk-HOOHS3MX.js +0 -39
- package/dist/cli/chunk-JEGPTNWV.js +0 -270
- package/dist/cli/chunk-K7UEKSB2.js +0 -305
- package/dist/cli/chunk-NLL2EQJ2.js +0 -94
- package/dist/cli/chunk-NWIICISV.js +0 -290
- package/dist/cli/chunk-OLLQBK6N.js +0 -41
- package/dist/cli/chunk-PZ3F4QH3.js +0 -9758
- package/dist/cli/chunk-U67V476Y.js +0 -35
- package/dist/cli/chunk-WXE2NOE5.js +0 -2674
- package/dist/cli/chunk-XOZD4BP5.js +0 -85
- package/dist/cli/daemon-5GT545BB.js +0 -2322
- package/dist/cli/decide-PFHHOCFZ.js +0 -59
- package/dist/cli/handover-EMO6JT7O.js +0 -17
- package/dist/cli/hook-W2BU74H5.js +0 -523
- package/dist/cli/launch-LP7YJR5N.js +0 -36
- package/dist/cli/send-NEI4X33R.js +0 -19
- package/dist/cli/setup-K42IVMHS.js +0 -38
- package/dist/cli/status-U2HGGKHF.js +0 -28
- package/dist/cli/task-PDDCE23D.js +0 -19
- package/dist/cli/team-S3ASP22H.js +0 -205
- package/dist/cli/tui-UPMRMCPC.js +0 -19216
- package/dist/cli/uninstall-4IMMR55T.js +0 -162
- package/dist/cli/version-LUMK3Z3T.js +0 -7
- package/dist/cli/who-NM3GPAPJ.js +0 -12
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CODEX_HOOK_VAR
|
|
3
|
-
} from "./chunk-JEGPTNWV.js";
|
|
4
|
-
import {
|
|
5
|
-
connect
|
|
6
|
-
} from "./chunk-ASYAWVFW.js";
|
|
7
|
-
import {
|
|
8
|
-
SESSION_KEY_VAR,
|
|
9
|
-
actionById
|
|
10
|
-
} from "./chunk-WXE2NOE5.js";
|
|
11
|
-
|
|
12
|
-
// src/cli/action.ts
|
|
13
|
-
import { randomUUID } from "crypto";
|
|
14
|
-
var CLOSE_USAGE = "ledge close <session>\u2026 [--json] fermer proprement des sessions (leur conversation reste reprenable)";
|
|
15
|
-
var DAEMON_DOWN = "daemon not running (start a session with `ledge claude`, or run `ledge daemon`)";
|
|
16
|
-
var RUN_MS = 6e4;
|
|
17
|
-
function actionArgs(id, args) {
|
|
18
|
-
const parsed = actionById(id).args.safeParse(args);
|
|
19
|
-
return parsed.success ? args : void 0;
|
|
20
|
-
}
|
|
21
|
-
function callerOf(env) {
|
|
22
|
-
const by = env[CODEX_HOOK_VAR] || env.LEDGE_SESSION;
|
|
23
|
-
const key = env[SESSION_KEY_VAR];
|
|
24
|
-
return by ? { by, ...key ? { key } : {} } : void 0;
|
|
25
|
-
}
|
|
26
|
-
async function runOnClient(client, action, args, opts = {}) {
|
|
27
|
-
const rid = randomUUID();
|
|
28
|
-
const by = opts.by;
|
|
29
|
-
client.send({ type: "action.run", rid, action, args, ...by ? { by: by.by, ...by.key ? { key: by.key } : {} } : {}, ...opts.confirmed ? { confirmed: true } : {} });
|
|
30
|
-
const deadline = Date.now() + (opts.ms ?? RUN_MS);
|
|
31
|
-
for (; ; ) {
|
|
32
|
-
const { type: _t, rid: got, ...r } = await client.next("action.result", Math.max(0, deadline - Date.now()));
|
|
33
|
-
if (got === rid) return r;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
var plain = (s) => s.replace(/\*\*/g, "");
|
|
37
|
-
function resultLine(r, json = false) {
|
|
38
|
-
const ok = r.reason === void 0;
|
|
39
|
-
if (json) return { line: JSON.stringify({ ok, ...r }), code: ok ? 0 : 1 };
|
|
40
|
-
if (ok) return { line: [`fait : ${plain(r.row?.summary ?? r.action)}`, ...r.path ? [`mod\xE8le \xE9crit : ${r.path}`] : []].join("\n"), code: 0 };
|
|
41
|
-
if (r.code === "confirm_required") return { line: `${plain(r.row?.summary ?? r.action)} : irr\xE9versible ; relance avec --yes pour confirmer`, code: 1 };
|
|
42
|
-
return { line: `${r.code === "failed" ? "\xE9chec" : "refus\xE9"} : ${r.reason}`, code: 1 };
|
|
43
|
-
}
|
|
44
|
-
function closeArgs(args) {
|
|
45
|
-
const json = args.includes("--json");
|
|
46
|
-
const sessions = args.filter((a) => a !== "--json");
|
|
47
|
-
if (!sessions.length || sessions.some((s) => s.startsWith("--") || !actionArgs("session.close", { session: s }))) return void 0;
|
|
48
|
-
return { sessions, ...json ? { json: true } : {} };
|
|
49
|
-
}
|
|
50
|
-
async function runClose(args, opts = {}) {
|
|
51
|
-
const parsed = closeArgs(args);
|
|
52
|
-
if (!parsed) return { line: CLOSE_USAGE, code: args.length ? 1 : 0 };
|
|
53
|
-
let client;
|
|
54
|
-
try {
|
|
55
|
-
client = await connect({ port: opts.port, timeoutMs: 1500 });
|
|
56
|
-
} catch {
|
|
57
|
-
return { line: DAEMON_DOWN, code: 1 };
|
|
58
|
-
}
|
|
59
|
-
const by = callerOf(opts.env ?? process.env);
|
|
60
|
-
const lines = [];
|
|
61
|
-
try {
|
|
62
|
-
for (const session of parsed.sessions) {
|
|
63
|
-
const r = resultLine(await runOnClient(client, "session.close", { session }, { by }), parsed.json);
|
|
64
|
-
lines.push(r.line);
|
|
65
|
-
if (r.code) return { line: lines.join("\n"), code: 1 };
|
|
66
|
-
}
|
|
67
|
-
return { line: lines.join("\n"), code: 0 };
|
|
68
|
-
} catch (e) {
|
|
69
|
-
return { line: [...lines, `pas de r\xE9ponse de Ledge : ${e.message}`].join("\n"), code: 1 };
|
|
70
|
-
} finally {
|
|
71
|
-
await client.close();
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export {
|
|
76
|
-
CLOSE_USAGE,
|
|
77
|
-
DAEMON_DOWN,
|
|
78
|
-
RUN_MS,
|
|
79
|
-
actionArgs,
|
|
80
|
-
callerOf,
|
|
81
|
-
runOnClient,
|
|
82
|
-
resultLine,
|
|
83
|
-
closeArgs,
|
|
84
|
-
runClose
|
|
85
|
-
};
|