@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.
Files changed (41) hide show
  1. package/dist/cli/index.js +39003 -46
  2. package/dist/cli/reduceWorker.js +2037 -0
  3. package/dist/ledge-guide.md +26 -49
  4. package/package.json +5 -1
  5. package/dist/cli/action-QW2ZQQBN.js +0 -27
  6. package/dist/cli/attach-ULTYWCJ7.js +0 -74
  7. package/dist/cli/bridge-CSLF7EW6.js +0 -70
  8. package/dist/cli/chunk-3DB3VOMM.js +0 -723
  9. package/dist/cli/chunk-4HXJQEUN.js +0 -118
  10. package/dist/cli/chunk-4VNKZOC2.js +0 -160
  11. package/dist/cli/chunk-6IYPRUQG.js +0 -17
  12. package/dist/cli/chunk-ASYAWVFW.js +0 -95
  13. package/dist/cli/chunk-CCSUP5ZI.js +0 -45
  14. package/dist/cli/chunk-CPERVAPQ.js +0 -232
  15. package/dist/cli/chunk-CSLVBADC.js +0 -60
  16. package/dist/cli/chunk-E3LXONBI.js +0 -6
  17. package/dist/cli/chunk-GXL3X7M7.js +0 -144
  18. package/dist/cli/chunk-HOOHS3MX.js +0 -39
  19. package/dist/cli/chunk-JEGPTNWV.js +0 -270
  20. package/dist/cli/chunk-K7UEKSB2.js +0 -305
  21. package/dist/cli/chunk-NLL2EQJ2.js +0 -94
  22. package/dist/cli/chunk-NWIICISV.js +0 -290
  23. package/dist/cli/chunk-OLLQBK6N.js +0 -41
  24. package/dist/cli/chunk-PZ3F4QH3.js +0 -9758
  25. package/dist/cli/chunk-U67V476Y.js +0 -35
  26. package/dist/cli/chunk-WXE2NOE5.js +0 -2674
  27. package/dist/cli/chunk-XOZD4BP5.js +0 -85
  28. package/dist/cli/daemon-5GT545BB.js +0 -2322
  29. package/dist/cli/decide-PFHHOCFZ.js +0 -59
  30. package/dist/cli/handover-EMO6JT7O.js +0 -17
  31. package/dist/cli/hook-W2BU74H5.js +0 -523
  32. package/dist/cli/launch-LP7YJR5N.js +0 -36
  33. package/dist/cli/send-NEI4X33R.js +0 -19
  34. package/dist/cli/setup-K42IVMHS.js +0 -38
  35. package/dist/cli/status-U2HGGKHF.js +0 -28
  36. package/dist/cli/task-PDDCE23D.js +0 -19
  37. package/dist/cli/team-S3ASP22H.js +0 -205
  38. package/dist/cli/tui-UPMRMCPC.js +0 -19216
  39. package/dist/cli/uninstall-4IMMR55T.js +0 -162
  40. package/dist/cli/version-LUMK3Z3T.js +0 -7
  41. 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
- };