@paradow/ledge 0.16.1 → 0.18.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 (40) hide show
  1. package/README.md +2 -0
  2. package/dist/cli/{attach-5H727FCW.js → attach-I6TTCGNV.js} +12 -7
  3. package/dist/cli/{bridge-LXMOQN6Q.js → bridge-APNFBPNE.js} +2 -2
  4. package/dist/cli/chunk-3EIRKAX7.js +165 -0
  5. package/dist/cli/chunk-3HCID6NW.js +145 -0
  6. package/dist/cli/{chunk-BNKPXSUY.js → chunk-43D6NMYH.js} +1 -1
  7. package/dist/cli/{daemon-DKH63BGV.js → chunk-7IQ6FV2F.js} +6117 -6985
  8. package/dist/cli/{chunk-R5462SQM.js → chunk-7ZAA75HG.js} +2 -1
  9. package/dist/cli/chunk-BVBX222F.js +117 -0
  10. package/dist/cli/{chunk-S4ANPQGA.js → chunk-FQZ3IX6E.js} +2 -2
  11. package/dist/cli/chunk-G6K2NSQS.js +6 -0
  12. package/dist/cli/{chunk-DEXDXDO4.js → chunk-GXFU4XAX.js} +1 -1
  13. package/dist/cli/chunk-HP3G2TYJ.js +1772 -0
  14. package/dist/cli/{chunk-DBSCO3HI.js → chunk-KKNE7BFZ.js} +108 -7
  15. package/dist/cli/{chunk-MQICEVKR.js → chunk-QQZALYNI.js} +38 -12
  16. package/dist/cli/{chunk-H36JD4E3.js → chunk-TRTS24PF.js} +23 -5
  17. package/dist/cli/{chunk-TB47EHML.js → chunk-WCS24ICX.js} +5 -3
  18. package/dist/cli/{chunk-2H5FJH4Q.js → chunk-WJ6YMZTT.js} +2 -2
  19. package/dist/cli/chunk-Y5DJ5INP.js +60 -0
  20. package/dist/cli/{chunk-QJVODYJ5.js → chunk-ZUYOA55W.js} +43 -4
  21. package/dist/cli/daemon-SKC7VKYQ.js +2240 -0
  22. package/dist/cli/handover-UXISKYPS.js +16 -0
  23. package/dist/cli/{hook-LY2YTK5U.js → hook-5UAARBWU.js} +93 -29
  24. package/dist/cli/index.js +45 -12
  25. package/dist/cli/launch-T5FJ42XS.js +34 -0
  26. package/dist/cli/send-NLVR6PL2.js +18 -0
  27. package/dist/cli/{setup-3N2EOJXS.js → setup-EEIXRAMU.js} +4 -4
  28. package/dist/cli/{status-ZQSYXILE.js → status-2OCYHOWZ.js} +3 -3
  29. package/dist/cli/task-AOOWHPMN.js +18 -0
  30. package/dist/cli/team-TVNSVYWW.js +101 -0
  31. package/dist/cli/tui-MQLMUUJB.js +4314 -0
  32. package/dist/cli/{uninstall-W2OMKU3B.js → uninstall-UUN7LIIT.js} +4 -4
  33. package/dist/cli/{version-6BMBIXHN.js → version-AEN2CRT2.js} +1 -1
  34. package/dist/cli/who-52MENZTT.js +11 -0
  35. package/package.json +7 -1
  36. package/dist/cli/chunk-J4ICZEGP.js +0 -6
  37. package/dist/cli/chunk-Q5WWH7FG.js +0 -1423
  38. package/dist/cli/launch-UQEFFPBN.js +0 -27
  39. package/dist/cli/send-EY63XQXI.js +0 -14
  40. package/dist/cli/who-VGIMGQNS.js +0 -11
@@ -17,7 +17,7 @@ function ledgeDir() {
17
17
  }
18
18
  function paths() {
19
19
  const dir = ledgeDir();
20
- return { dir, tmuxConf: join(dir, "tmux.conf"), journal: join(dir, "sessions.json"), log: join(dir, "daemon.log"), pid: join(dir, "daemon.pid"), history: join(dir, "history"), machines: join(dir, "machines.json"), projects: join(dir, "projects.json"), island: join(dir, "island.json"), token: join(dir, "token"), mobile: join(dir, "mobile.json"), mobileSession: join(dir, "mobile-session.json"), mobileKey: join(dir, "mobile-key"), devices: join(dir, "devices.json"), revocations: join(dir, "revocations.json") };
20
+ return { dir, tmuxConf: join(dir, "tmux.conf"), journal: join(dir, "sessions.json"), log: join(dir, "daemon.log"), pid: join(dir, "daemon.pid"), history: join(dir, "history"), mail: join(dir, "mail.json"), tasks: join(dir, "tasks.json"), teams: join(dir, "teams-live.json"), machines: join(dir, "machines.json"), projects: join(dir, "projects.json"), island: join(dir, "island.json"), token: join(dir, "token"), mobile: join(dir, "mobile.json"), mobileSession: join(dir, "mobile-session.json"), mobileKey: join(dir, "mobile-key"), devices: join(dir, "devices.json"), revocations: join(dir, "revocations.json") };
21
21
  }
22
22
  async function ensureLedgeDir() {
23
23
  const p = paths();
@@ -33,6 +33,7 @@ ${TITLE_LINES}`);
33
33
  }
34
34
 
35
35
  export {
36
+ ledgeDir,
36
37
  paths,
37
38
  ensureLedgeDir
38
39
  };
@@ -0,0 +1,117 @@
1
+ import {
2
+ CODEX_HOOK_VAR
3
+ } from "./chunk-TRTS24PF.js";
4
+ import {
5
+ connect
6
+ } from "./chunk-GXFU4XAX.js";
7
+ import {
8
+ LEDGE_GIVER,
9
+ TASK_TEXT_MAX,
10
+ TASK_TITLE_MAX
11
+ } from "./chunk-HP3G2TYJ.js";
12
+
13
+ // src/cli/task.ts
14
+ import { randomUUID } from "crypto";
15
+ var TASK_USAGE = `ledge task give <nom|@r\xF4le> "<titre>" ["<d\xE9tail>"] confier un travail \xE0 une session (@r\xF4le : dans ton \xE9quipe)
16
+ ledge task list [--all] tes t\xE2ches (tenues ou confi\xE9es), ouvertes ; --all : closes aussi
17
+ ledge task show <id> une t\xE2che, son d\xE9tail et son historique
18
+ ledge task take <id> la prendre
19
+ ledge task done <id> ["<r\xE9sultat>"] la terminer (la session qui l'a confi\xE9e est pr\xE9venue)
20
+ ledge task refuse <id> "<raison>" la refuser, ou l'annuler si tu l'as confi\xE9e
21
+ ledge task pass <id> <nom|@r\xF4le> ["<note>"] la passer \xE0 une autre session`;
22
+ var TASK_MS = 4e3;
23
+ var ID = /^t[0-9a-f]{6}$/;
24
+ function taskArgs(args) {
25
+ const [op, ...rest] = args;
26
+ const id = rest[0] && ID.test(rest[0]) ? rest[0] : void 0;
27
+ const fits = (min, max) => rest.length >= min && rest.length <= max && rest.slice(0, min).every((a) => a.trim() !== "");
28
+ switch (op) {
29
+ case "give":
30
+ return fits(2, 3) && rest[1].length <= TASK_TITLE_MAX && (rest[2]?.length ?? 0) <= TASK_TEXT_MAX ? { op, to: rest[0], title: rest[1], ...rest[2] ? { text: rest[2] } : {} } : void 0;
31
+ case "list":
32
+ return rest.length === 0 ? { op } : rest.length === 1 && rest[0] === "--all" ? { op, all: true } : void 0;
33
+ case "show":
34
+ case "take":
35
+ return fits(1, 1) && id ? { op, task: id } : void 0;
36
+ case "done":
37
+ return fits(1, 2) && id && (rest[1]?.length ?? 0) <= TASK_TEXT_MAX ? { op, task: id, ...rest[1] ? { text: rest[1] } : {} } : void 0;
38
+ case "refuse":
39
+ return fits(2, 2) && id && rest[1].length <= TASK_TEXT_MAX ? { op, task: id, text: rest[1] } : void 0;
40
+ case "pass":
41
+ return fits(2, 3) && id && (rest[2]?.length ?? 0) <= TASK_TEXT_MAX ? { op, task: id, to: rest[1], ...rest[2] ? { text: rest[2] } : {} } : void 0;
42
+ default:
43
+ return void 0;
44
+ }
45
+ }
46
+ var STATE = { open: "\xE0 prendre", taken: "prise", done: "termin\xE9e", refused: "refus\xE9e", dropped: "abandonn\xE9e" };
47
+ var time = (iso) => iso.slice(0, 16).replace("T", " ");
48
+ function formatTask(t) {
49
+ return [
50
+ `${t.id} \xB7 ${STATE[t.state]} \xB7 de ${t.giverName} \xE0 ${t.ownerName} \xB7 ${time(t.at)}`,
51
+ t.title,
52
+ ...t.text ? ["", t.text] : [],
53
+ ...t.result ? ["", `${t.state === "done" ? "R\xE9sultat" : "Raison"} : ${t.result}`] : [],
54
+ "",
55
+ "Historique :",
56
+ ...t.log.map((l) => ` ${time(l.at)} ${l.by} : ${l.what}`)
57
+ ].join("\n");
58
+ }
59
+ async function taskOnClient(client, args, by, ms) {
60
+ const op = taskArgs(args);
61
+ if (!op) return { line: TASK_USAGE, code: 1 };
62
+ if (by === LEDGE_GIVER) return { line: "refus\xE9 : seul Ledge confie une t\xE2che en son nom", code: 1 };
63
+ try {
64
+ client.send({ type: "task.cmd", rid: randomUUID(), by, ...op });
65
+ const r = await client.next("task.result", ms);
66
+ if (r.reason !== void 0) return { line: `refus\xE9 : ${r.reason}`, code: 1 };
67
+ if (op.op === "list") {
68
+ const list = r.tasks ?? [];
69
+ if (!list.length) return { line: op.all ? "aucune t\xE2che" : "aucune t\xE2che ouverte", code: 0 };
70
+ return { line: list.map((t2) => `${t2.id} ${STATE[t2.state].padEnd(10)} ${t2.giverName} \u2192 ${t2.ownerName} ${t2.title}`).join("\n"), code: 0 };
71
+ }
72
+ const t = r.task;
73
+ switch (op.op) {
74
+ case "give":
75
+ return { line: `t\xE2che ${t.id} confi\xE9e \xE0 ${t.ownerName} : elle lui arrive \xE0 son prochain moment libre`, code: 0 };
76
+ case "take":
77
+ return { line: `t\xE2che ${t.id} prise`, code: 0 };
78
+ case "done":
79
+ return { line: `t\xE2che ${t.id} termin\xE9e ; Ledge pr\xE9vient ${t.giverName}`, code: 0 };
80
+ case "refuse":
81
+ return { line: t.giver === by ? `t\xE2che ${t.id} annul\xE9e ; Ledge pr\xE9vient ${t.ownerName}` : `t\xE2che ${t.id} refus\xE9e ; Ledge pr\xE9vient ${t.giverName}`, code: 0 };
82
+ case "pass":
83
+ return { line: `t\xE2che ${t.id} pass\xE9e \xE0 ${t.ownerName}`, code: 0 };
84
+ default:
85
+ return { line: formatTask(t), code: 0 };
86
+ }
87
+ } catch (e) {
88
+ return { line: `pas de r\xE9ponse de Ledge : ${e.message}`, code: 1 };
89
+ }
90
+ }
91
+ async function runTask(args, opts = {}) {
92
+ if (!taskArgs(args)) return { line: TASK_USAGE, code: args.length ? 1 : 0 };
93
+ const env = opts.env ?? process.env;
94
+ const by = env[CODEX_HOOK_VAR] || env.LEDGE_SESSION;
95
+ if (!by) return { line: "ledge task ne marche que dans une session lanc\xE9e par Ledge", code: 1 };
96
+ const deadline = Date.now() + (opts.timeoutMs ?? TASK_MS);
97
+ const left = () => Math.max(0, deadline - Date.now());
98
+ let client;
99
+ try {
100
+ client = await connect({ port: opts.port, timeoutMs: left() });
101
+ } catch {
102
+ return { line: "daemon not running (start a session with `ledge claude`, or run `ledge daemon`)", code: 1 };
103
+ }
104
+ try {
105
+ return await taskOnClient(client, args, by, left());
106
+ } finally {
107
+ await client.close();
108
+ }
109
+ }
110
+
111
+ export {
112
+ TASK_USAGE,
113
+ taskArgs,
114
+ formatTask,
115
+ taskOnClient,
116
+ runTask
117
+ };
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  run
3
- } from "./chunk-2H5FJH4Q.js";
3
+ } from "./chunk-WJ6YMZTT.js";
4
4
  import {
5
5
  ensureLedgeDir,
6
6
  paths
7
- } from "./chunk-R5462SQM.js";
7
+ } from "./chunk-7ZAA75HG.js";
8
8
 
9
9
  // src/cli/setup.ts
10
10
  import { readFile as readFile2, writeFile, mkdir, rename, realpath, rm, stat, lstat, readlink } from "fs/promises";
@@ -0,0 +1,6 @@
1
+ // src/version.ts
2
+ var LEDGE_VERSION = true ? "0.18.0" : "0.0.0-dev";
3
+
4
+ export {
5
+ LEDGE_VERSION
6
+ };
@@ -4,7 +4,7 @@ import {
4
4
  SUMMARY_MAX,
5
5
  parseServerMessage,
6
6
  readDaemonToken
7
- } from "./chunk-Q5WWH7FG.js";
7
+ } from "./chunk-HP3G2TYJ.js";
8
8
 
9
9
  // src/client.ts
10
10
  import WebSocket from "ws";