@paradow/ledge 0.34.0 → 0.36.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 +40782 -39
- package/dist/cli/reduceWorker.js +2216 -0
- package/package.json +4 -1
- package/dist/cli/action-K42H5BDA.js +0 -27
- package/dist/cli/attach-KEE4A5YP.js +0 -87
- package/dist/cli/bridge-X327AZY4.js +0 -70
- package/dist/cli/chunk-25RVT5MR.js +0 -623
- package/dist/cli/chunk-3OJCWJAA.js +0 -144
- package/dist/cli/chunk-4OYVM4MT.js +0 -49
- package/dist/cli/chunk-4TCSADFR.js +0 -252
- package/dist/cli/chunk-53ISXX2R.js +0 -39
- package/dist/cli/chunk-54KF5RBY.js +0 -17
- package/dist/cli/chunk-7NHQGP6J.js +0 -95
- package/dist/cli/chunk-G7XPEVCG.js +0 -118
- package/dist/cli/chunk-IWY7DSSO.js +0 -2476
- package/dist/cli/chunk-KPDTYX7F.js +0 -60
- package/dist/cli/chunk-OLLQBK6N.js +0 -41
- package/dist/cli/chunk-RPH773TY.js +0 -6
- package/dist/cli/chunk-RX5CJ7YH.js +0 -43
- package/dist/cli/chunk-T547FLQN.js +0 -128
- package/dist/cli/chunk-U67V476Y.js +0 -35
- package/dist/cli/chunk-UJ2WBGLW.js +0 -305
- package/dist/cli/chunk-ULOMKEB6.js +0 -85
- package/dist/cli/chunk-V4XKKL6K.js +0 -205
- package/dist/cli/daemon-RO43S3S5.js +0 -11449
- package/dist/cli/decide-KZFYL3HY.js +0 -59
- package/dist/cli/handover-BWNMI2RA.js +0 -17
- package/dist/cli/hook-ZLWXI5EQ.js +0 -473
- package/dist/cli/launch-GCX7TXOH.js +0 -28
- package/dist/cli/send-SXZAPVRH.js +0 -19
- package/dist/cli/setup-TJ32FMVJ.js +0 -38
- package/dist/cli/status-YDVRES4E.js +0 -28
- package/dist/cli/task-TUSOVJK7.js +0 -19
- package/dist/cli/tui-TCVIRZCQ.js +0 -19348
- package/dist/cli/uninstall-QO7YMSLA.js +0 -162
- package/dist/cli/version-BAYSYWFP.js +0 -7
- package/dist/cli/who-6AZYSP7T.js +0 -12
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CODEX_HOOK_VAR
|
|
3
|
-
} from "./chunk-4TCSADFR.js";
|
|
4
|
-
import {
|
|
5
|
-
connect
|
|
6
|
-
} from "./chunk-7NHQGP6J.js";
|
|
7
|
-
import {
|
|
8
|
-
LEDGE_GIVER,
|
|
9
|
-
TASK_TEXT_MAX,
|
|
10
|
-
TASK_TITLE_MAX
|
|
11
|
-
} from "./chunk-IWY7DSSO.js";
|
|
12
|
-
|
|
13
|
-
// src/cli/task.ts
|
|
14
|
-
import { randomUUID } from "crypto";
|
|
15
|
-
var TASK_USAGE = `ledge task give <nom> "<titre>" ["<d\xE9tail>"] confier un travail \xE0 une session
|
|
16
|
-
ledge task give ledge "<question>" "<options, recommandation>" une d\xE9cision pour l'utilisateur ; sa r\xE9ponse te r\xE9veille
|
|
17
|
-
ledge task list [--all] tes t\xE2ches (tenues ou confi\xE9es), ouvertes ; --all : closes aussi
|
|
18
|
-
ledge task show <id> une t\xE2che, son d\xE9tail et son historique
|
|
19
|
-
ledge task take <id> la prendre
|
|
20
|
-
ledge task done <id> "<r\xE9sultat>" la terminer, avec ce qui en est sorti (la session qui l'a confi\xE9e est pr\xE9venue)
|
|
21
|
-
ledge task refuse <id> "<raison>" la refuser, ou l'annuler si tu l'as confi\xE9e
|
|
22
|
-
ledge task pass <id> <nom> ["<note>"] la passer \xE0 une autre session`;
|
|
23
|
-
var TASK_MS = 4e3;
|
|
24
|
-
var ID = /^t[0-9a-f]{6}$/;
|
|
25
|
-
function taskArgs(args) {
|
|
26
|
-
const [op, ...rest] = args;
|
|
27
|
-
const id = rest[0] && ID.test(rest[0]) ? rest[0] : void 0;
|
|
28
|
-
const fits = (min, max) => rest.length >= min && rest.length <= max && rest.slice(0, min).every((a) => a.trim() !== "");
|
|
29
|
-
switch (op) {
|
|
30
|
-
case "give":
|
|
31
|
-
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;
|
|
32
|
-
case "list":
|
|
33
|
-
return rest.length === 0 ? { op } : rest.length === 1 && rest[0] === "--all" ? { op, all: true } : void 0;
|
|
34
|
-
case "show":
|
|
35
|
-
case "take":
|
|
36
|
-
return fits(1, 1) && id ? { op, task: id } : void 0;
|
|
37
|
-
case "done":
|
|
38
|
-
return fits(2, 2) && id && rest[1].length <= TASK_TEXT_MAX ? { op, task: id, text: rest[1] } : void 0;
|
|
39
|
-
case "refuse":
|
|
40
|
-
return fits(2, 2) && id && rest[1].length <= TASK_TEXT_MAX ? { op, task: id, text: rest[1] } : void 0;
|
|
41
|
-
case "pass":
|
|
42
|
-
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;
|
|
43
|
-
default:
|
|
44
|
-
return void 0;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
var STATE = { open: "\xE0 prendre", taken: "prise", done: "termin\xE9e", refused: "refus\xE9e", dropped: "abandonn\xE9e" };
|
|
48
|
-
var time = (iso) => iso.slice(0, 16).replace("T", " ");
|
|
49
|
-
function formatTask(t) {
|
|
50
|
-
return [
|
|
51
|
-
`${t.id} \xB7 ${STATE[t.state]} \xB7 de ${t.giverName} \xE0 ${t.ownerName} \xB7 ${time(t.at)}`,
|
|
52
|
-
t.title,
|
|
53
|
-
...t.text ? ["", t.text] : [],
|
|
54
|
-
...t.result ? ["", `${t.state === "done" ? "R\xE9sultat" : "Raison"} : ${t.result}`] : [],
|
|
55
|
-
"",
|
|
56
|
-
"Historique :",
|
|
57
|
-
...t.log.map((l) => ` ${time(l.at)} ${l.by} : ${l.what}`)
|
|
58
|
-
].join("\n");
|
|
59
|
-
}
|
|
60
|
-
async function taskOnClient(client, args, by, ms) {
|
|
61
|
-
const op = taskArgs(args);
|
|
62
|
-
if (!op) return { line: TASK_USAGE, code: 1 };
|
|
63
|
-
if (by === LEDGE_GIVER) return { line: "refus\xE9 : seul Ledge confie une t\xE2che en son nom", code: 1 };
|
|
64
|
-
try {
|
|
65
|
-
client.send({ type: "task.cmd", rid: randomUUID(), by, ...op });
|
|
66
|
-
const r = await client.next("task.result", ms);
|
|
67
|
-
if (r.reason !== void 0) return { line: `refus\xE9 : ${r.reason}`, code: 1 };
|
|
68
|
-
if (op.op === "list") {
|
|
69
|
-
const list = r.tasks ?? [];
|
|
70
|
-
if (!list.length) return { line: op.all ? "aucune t\xE2che" : "aucune t\xE2che ouverte", code: 0 };
|
|
71
|
-
return { line: list.map((t2) => `${t2.id} ${STATE[t2.state].padEnd(10)} ${t2.giverName} \u2192 ${t2.ownerName} ${t2.title}`).join("\n"), code: 0 };
|
|
72
|
-
}
|
|
73
|
-
const t = r.task;
|
|
74
|
-
switch (op.op) {
|
|
75
|
-
case "give":
|
|
76
|
-
return { line: t.owner === LEDGE_GIVER ? `d\xE9cision ${t.id} pos\xE9e \xE0 l'utilisateur (ledge decide) : sa r\xE9ponse t'arrivera comme une t\xE2che termin\xE9e` : `t\xE2che ${t.id} confi\xE9e \xE0 ${t.ownerName} : elle lui arrive \xE0 son prochain moment libre`, code: 0 };
|
|
77
|
-
case "take":
|
|
78
|
-
return { line: `t\xE2che ${t.id} prise`, code: 0 };
|
|
79
|
-
case "done":
|
|
80
|
-
return { line: `t\xE2che ${t.id} termin\xE9e ; Ledge pr\xE9vient ${t.giverName}`, code: 0 };
|
|
81
|
-
case "refuse":
|
|
82
|
-
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 };
|
|
83
|
-
case "pass":
|
|
84
|
-
return { line: `t\xE2che ${t.id} pass\xE9e \xE0 ${t.ownerName}`, code: 0 };
|
|
85
|
-
default:
|
|
86
|
-
return { line: formatTask(t), code: 0 };
|
|
87
|
-
}
|
|
88
|
-
} catch (e) {
|
|
89
|
-
return { line: `pas de r\xE9ponse de Ledge : ${e.message}`, code: 1 };
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
async function runTask(args, opts = {}) {
|
|
93
|
-
if (!taskArgs(args)) return { line: TASK_USAGE, code: args.length ? 1 : 0 };
|
|
94
|
-
const env = opts.env ?? process.env;
|
|
95
|
-
const by = env[CODEX_HOOK_VAR] || env.LEDGE_SESSION;
|
|
96
|
-
if (!by) return { line: "ledge task ne marche que dans une session lanc\xE9e par Ledge", code: 1 };
|
|
97
|
-
const deadline = Date.now() + (opts.timeoutMs ?? TASK_MS);
|
|
98
|
-
const left = () => Math.max(0, deadline - Date.now());
|
|
99
|
-
let client;
|
|
100
|
-
try {
|
|
101
|
-
client = await connect({ port: opts.port, timeoutMs: left() });
|
|
102
|
-
} catch {
|
|
103
|
-
return { line: "daemon not running (start a session with `ledge claude`, or run `ledge daemon`)", code: 1 };
|
|
104
|
-
}
|
|
105
|
-
try {
|
|
106
|
-
return await taskOnClient(client, args, by, left());
|
|
107
|
-
} finally {
|
|
108
|
-
await client.close();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export {
|
|
113
|
-
TASK_USAGE,
|
|
114
|
-
taskArgs,
|
|
115
|
-
formatTask,
|
|
116
|
-
taskOnClient,
|
|
117
|
-
runTask
|
|
118
|
-
};
|