@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,38 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BIN_MARK,
|
|
3
|
-
CLAUDE_EVENTS,
|
|
4
|
-
CODEX_EVENTS,
|
|
5
|
-
CURSOR_EVENTS,
|
|
6
|
-
SERVICE,
|
|
7
|
-
execRunner,
|
|
8
|
-
installService,
|
|
9
|
-
isDir,
|
|
10
|
-
mergeClaudeHooks,
|
|
11
|
-
mergeCodexHooks,
|
|
12
|
-
mergeCursorHooks,
|
|
13
|
-
runSetup,
|
|
14
|
-
stopDetachedDaemon,
|
|
15
|
-
systemdUnit,
|
|
16
|
-
writeBin
|
|
17
|
-
} from "./chunk-K7UEKSB2.js";
|
|
18
|
-
import "./chunk-NLL2EQJ2.js";
|
|
19
|
-
import "./chunk-6IYPRUQG.js";
|
|
20
|
-
import "./chunk-HOOHS3MX.js";
|
|
21
|
-
import "./chunk-U67V476Y.js";
|
|
22
|
-
export {
|
|
23
|
-
BIN_MARK,
|
|
24
|
-
CLAUDE_EVENTS,
|
|
25
|
-
CODEX_EVENTS,
|
|
26
|
-
CURSOR_EVENTS,
|
|
27
|
-
SERVICE,
|
|
28
|
-
execRunner,
|
|
29
|
-
installService,
|
|
30
|
-
isDir,
|
|
31
|
-
mergeClaudeHooks,
|
|
32
|
-
mergeCodexHooks,
|
|
33
|
-
mergeCursorHooks,
|
|
34
|
-
runSetup,
|
|
35
|
-
stopDetachedDaemon,
|
|
36
|
-
systemdUnit,
|
|
37
|
-
writeBin
|
|
38
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
connect
|
|
3
|
-
} from "./chunk-ASYAWVFW.js";
|
|
4
|
-
import "./chunk-WXE2NOE5.js";
|
|
5
|
-
import "./chunk-HOOHS3MX.js";
|
|
6
|
-
import "./chunk-U67V476Y.js";
|
|
7
|
-
|
|
8
|
-
// src/cli/status.ts
|
|
9
|
-
async function printStatus(opts = {}) {
|
|
10
|
-
let client;
|
|
11
|
-
try {
|
|
12
|
-
client = await connect({ port: opts.port, timeoutMs: 800 });
|
|
13
|
-
} catch {
|
|
14
|
-
return "daemon not running (start a session with `ledge claude`, or run `ledge daemon`)";
|
|
15
|
-
}
|
|
16
|
-
const snap = await client.next("snapshot");
|
|
17
|
-
await client.close();
|
|
18
|
-
if (snap.sessions.length === 0) return "no sessions";
|
|
19
|
-
const rows = snap.sessions.map((s) => {
|
|
20
|
-
const age = Math.round((Date.now() - Date.parse(s.startedAt)) / 6e4);
|
|
21
|
-
const ask = s.pending ? ` \xB7 ${s.pending.kind}: ${s.pending.text}` : "";
|
|
22
|
-
return `${s.name.padEnd(8)} ${s.tool.padEnd(7)} ${s.state.padEnd(19)} ${s.project.padEnd(28)} ${age}m${ask}${s.source === "hook_only" ? " \xB7 read only" : ""}`;
|
|
23
|
-
});
|
|
24
|
-
return rows.join("\n");
|
|
25
|
-
}
|
|
26
|
-
export {
|
|
27
|
-
printStatus
|
|
28
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
TASK_USAGE,
|
|
3
|
-
formatTask,
|
|
4
|
-
runTask,
|
|
5
|
-
taskArgs,
|
|
6
|
-
taskOnClient
|
|
7
|
-
} from "./chunk-4HXJQEUN.js";
|
|
8
|
-
import "./chunk-JEGPTNWV.js";
|
|
9
|
-
import "./chunk-ASYAWVFW.js";
|
|
10
|
-
import "./chunk-WXE2NOE5.js";
|
|
11
|
-
import "./chunk-HOOHS3MX.js";
|
|
12
|
-
import "./chunk-U67V476Y.js";
|
|
13
|
-
export {
|
|
14
|
-
TASK_USAGE,
|
|
15
|
-
formatTask,
|
|
16
|
-
runTask,
|
|
17
|
-
taskArgs,
|
|
18
|
-
taskOnClient
|
|
19
|
-
};
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DAEMON_DOWN,
|
|
3
|
-
actionArgs,
|
|
4
|
-
callerOf,
|
|
5
|
-
resultLine,
|
|
6
|
-
runOnClient
|
|
7
|
-
} from "./chunk-XOZD4BP5.js";
|
|
8
|
-
import {
|
|
9
|
-
listDefinitions
|
|
10
|
-
} from "./chunk-NWIICISV.js";
|
|
11
|
-
import "./chunk-4VNKZOC2.js";
|
|
12
|
-
import "./chunk-JEGPTNWV.js";
|
|
13
|
-
import {
|
|
14
|
-
connect
|
|
15
|
-
} from "./chunk-ASYAWVFW.js";
|
|
16
|
-
import {
|
|
17
|
-
RoleIdSchema,
|
|
18
|
-
SeatsSchema,
|
|
19
|
-
ToolSchema
|
|
20
|
-
} from "./chunk-WXE2NOE5.js";
|
|
21
|
-
import "./chunk-6IYPRUQG.js";
|
|
22
|
-
import "./chunk-HOOHS3MX.js";
|
|
23
|
-
import "./chunk-U67V476Y.js";
|
|
24
|
-
|
|
25
|
-
// src/cli/team.ts
|
|
26
|
-
import { randomUUID } from "crypto";
|
|
27
|
-
import { resolve } from "path";
|
|
28
|
-
var TEAM_USAGE = `ledge team up <mod\xE8le> [--cwd <dossier>] [--name <nom>] lancer une \xE9quipe d'apr\xE8s .ledge/teams/<mod\xE8le>.yaml
|
|
29
|
-
ledge team up --seat <r\xF4le>[:<outil>]\u2026 [--cwd <dossier>] [--name <nom>] lancer une \xE9quipe de si\xE8ges ad hoc
|
|
30
|
-
ledge team list [--cwd <dossier>] les mod\xE8les, les r\xF4les et les \xE9quipes en cours
|
|
31
|
-
ledge team join <\xE9quipe> <session> <@r\xF4le> faire entrer une session dans une \xE9quipe, \xE0 un r\xF4le
|
|
32
|
-
ledge team leave <\xE9quipe> <session> faire sortir une session d'une \xE9quipe (elle continue)
|
|
33
|
-
ledge team resume <\xE9quipe> reprendre une \xE9quipe au repos
|
|
34
|
-
ledge team dissolve <\xE9quipe> [--close-sessions] --yes dissoudre une \xE9quipe (irr\xE9versible) ; ses sessions restent, ou se ferment
|
|
35
|
-
ledge team save <\xE9quipe> <nom> enregistrer une \xE9quipe en cours comme mod\xE8le
|
|
36
|
-
--json : une ligne JSON, pour un agent ou un script. Une session agent peut se fermer et quitter son \xE9quipe ;
|
|
37
|
-
l'@leader d'une \xE9quipe peut aussi la dissoudre, en retirer un membre ou en fermer une session. Le reste revient \xE0 l'utilisateur.`;
|
|
38
|
-
var UP_MS = 6e4;
|
|
39
|
-
var VERBS = {
|
|
40
|
-
join: { action: "team.join", n: 3, args: ([team, session, role]) => ({ team, session, role: role.replace(/^@/, "") }) },
|
|
41
|
-
leave: { action: "team.leave", n: 2, args: ([team, session]) => ({ team, session }) },
|
|
42
|
-
resume: { action: "team.resume", n: 1, args: ([team]) => ({ team }) },
|
|
43
|
-
dissolve: { action: "team.dissolve", n: 1, args: ([team]) => ({ team }) },
|
|
44
|
-
save: { action: "team.save", n: 2, args: ([team, name]) => ({ team, name }) }
|
|
45
|
-
};
|
|
46
|
-
function seatOf(v) {
|
|
47
|
-
const [role, tool, ...more] = v.split(":");
|
|
48
|
-
if (more.length || !RoleIdSchema.safeParse(role).success || tool !== void 0 && !ToolSchema.safeParse(tool).success) return void 0;
|
|
49
|
-
return { role, ...tool !== void 0 ? { tool } : {} };
|
|
50
|
-
}
|
|
51
|
-
function teamArgs(args) {
|
|
52
|
-
const [op, ...rest] = args;
|
|
53
|
-
const positional = [];
|
|
54
|
-
const seats = [];
|
|
55
|
-
let cwd;
|
|
56
|
-
let name;
|
|
57
|
-
let json = false;
|
|
58
|
-
let yes = false;
|
|
59
|
-
let closeSessions = false;
|
|
60
|
-
for (let i = 0; i < rest.length; i++) {
|
|
61
|
-
const a = rest[i];
|
|
62
|
-
if (a === "--cwd") {
|
|
63
|
-
cwd = rest[++i];
|
|
64
|
-
if (!cwd) return void 0;
|
|
65
|
-
} else if (a === "--name") {
|
|
66
|
-
name = rest[++i];
|
|
67
|
-
if (!name) return void 0;
|
|
68
|
-
} else if (a === "--seat") {
|
|
69
|
-
const s = seatOf(rest[++i] ?? "");
|
|
70
|
-
if (!s) return void 0;
|
|
71
|
-
seats.push(s);
|
|
72
|
-
} else if (a === "--json") json = true;
|
|
73
|
-
else if (a === "--yes") yes = true;
|
|
74
|
-
else if (a === "--close-sessions") closeSessions = true;
|
|
75
|
-
else if (a.startsWith("--")) return void 0;
|
|
76
|
-
else positional.push(a);
|
|
77
|
-
}
|
|
78
|
-
const j = json ? { json: true } : {};
|
|
79
|
-
const where = { ...cwd ? { cwd } : {}, ...name ? { name } : {} };
|
|
80
|
-
if (op === "up" && !yes && !closeSessions) {
|
|
81
|
-
if (positional.length === 1 && !seats.length) return { op, template: positional[0], ...where, ...j };
|
|
82
|
-
if (positional.length === 0 && seats.length && SeatsSchema.safeParse(seats).success) return { op, seats, ...where, ...j };
|
|
83
|
-
return void 0;
|
|
84
|
-
}
|
|
85
|
-
if (op === "list") return positional.length === 0 && !name && !seats.length && !yes && !closeSessions ? { op, ...cwd ? { cwd } : {}, ...j } : void 0;
|
|
86
|
-
const verb = op ? VERBS[op] : void 0;
|
|
87
|
-
if (!verb || positional.length !== verb.n || cwd || name || seats.length || closeSessions && op !== "dissolve") return void 0;
|
|
88
|
-
const parsed = actionArgs(verb.action, verb.args(positional));
|
|
89
|
-
if (!parsed) return void 0;
|
|
90
|
-
return { op: "run", action: verb.action, args: parsed, ...closeSessions ? { closeSessions: true } : {}, ...yes ? { yes: true } : {}, ...j };
|
|
91
|
-
}
|
|
92
|
-
var STATE = { active: "active", resting: "au repos", dissolved: "dissoute" };
|
|
93
|
-
function formatTeam(t, sessions) {
|
|
94
|
-
const byId = new Map(sessions.map((s) => [s.id, s]));
|
|
95
|
-
return [`${t.id} ${t.name} ${STATE[t.state]} ${t.cwd}`, ...t.seats.map((seat) => {
|
|
96
|
-
const s = seat.sessionId ? byId.get(seat.sessionId) : void 0;
|
|
97
|
-
return ` @${seat.role.padEnd(12)} ${s ? `${s.name} (${s.tool}, ${s.state})` : "libre"}`;
|
|
98
|
-
})].join("\n");
|
|
99
|
-
}
|
|
100
|
-
function teamJson(t, sessions) {
|
|
101
|
-
const byId = new Map(sessions.map((s) => [s.id, s]));
|
|
102
|
-
return { ...t, seats: t.seats.map((seat) => {
|
|
103
|
-
const s = seat.sessionId ? byId.get(seat.sessionId) : void 0;
|
|
104
|
-
return { ...seat, ...s ? { session: { name: s.name, tool: s.tool, state: s.state } } : {} };
|
|
105
|
-
}) };
|
|
106
|
-
}
|
|
107
|
-
async function runTeam(args, opts = {}) {
|
|
108
|
-
const parsed = teamArgs(args);
|
|
109
|
-
if (!parsed) return { line: TEAM_USAGE, code: args.length ? 1 : 0 };
|
|
110
|
-
if (parsed.op === "run") return runVerb(parsed, opts.port, callerOf(opts.env ?? process.env));
|
|
111
|
-
const cwd = resolve(opts.cwd ?? process.cwd(), parsed.cwd ?? ".");
|
|
112
|
-
if (parsed.op === "list") {
|
|
113
|
-
const defs = listDefinitions(cwd);
|
|
114
|
-
const lines = [
|
|
115
|
-
"MOD\xC8LES",
|
|
116
|
-
...defs.templates.length ? defs.templates.map((t) => ` ${t.id.padEnd(16)} ${t.name} \xB7 ${t.seats.map((s) => `@${s.role}`).join(" ")} (${t.source})`) : [" aucun (~/.ledge/teams/<id>.yaml)"],
|
|
117
|
-
"",
|
|
118
|
-
"R\xD4LES",
|
|
119
|
-
...defs.roles.length ? defs.roles.map((r) => ` @${r.id.padEnd(15)} ${r.label}${r.tool ? ` \xB7 ${r.tool}` : ""}${r.autonomy && r.autonomy !== "ask" ? ` \xB7 autonomie ${r.autonomy}` : ""} (${r.source})`) : [" aucun (~/.ledge/roles/<id>.md)"],
|
|
120
|
-
...defs.problems.length ? ["", "IGNOR\xC9S", ...defs.problems.map((p) => ` ${p.path} : ${p.reason}`)] : []
|
|
121
|
-
];
|
|
122
|
-
const json = (teams) => ({ line: JSON.stringify({ ...defs, teams }), code: 0 });
|
|
123
|
-
let client2;
|
|
124
|
-
try {
|
|
125
|
-
client2 = await connect({ port: opts.port, timeoutMs: 800 });
|
|
126
|
-
} catch {
|
|
127
|
-
return parsed.json ? json(null) : { line: [...lines, "", "\xC9QUIPES", ` ${DAEMON_DOWN}`].join("\n"), code: 0 };
|
|
128
|
-
}
|
|
129
|
-
try {
|
|
130
|
-
const snapshot = await client2.next("snapshot");
|
|
131
|
-
const teams = (await client2.next("teams").catch(() => ({ teams: [] }))).teams.filter((t) => t.state !== "dissolved");
|
|
132
|
-
if (parsed.json) return json(teams.map((t) => teamJson(t, snapshot.sessions)));
|
|
133
|
-
return { line: [...lines, "", "\xC9QUIPES", ...teams.length ? teams.map((t) => formatTeam(t, snapshot.sessions)) : [" aucune"]].join("\n"), code: 0 };
|
|
134
|
-
} finally {
|
|
135
|
-
await client2.close();
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
let client;
|
|
139
|
-
try {
|
|
140
|
-
client = await connect({ port: opts.port, timeoutMs: 1500 });
|
|
141
|
-
} catch {
|
|
142
|
-
return { line: DAEMON_DOWN, code: 1 };
|
|
143
|
-
}
|
|
144
|
-
try {
|
|
145
|
-
const rid = randomUUID();
|
|
146
|
-
client.send({ type: "team.launch", rid, cwd, ...parsed.template ? { template: parsed.template } : {}, ...parsed.seats ? { seats: parsed.seats } : {}, ...parsed.name ? { name: parsed.name } : {} });
|
|
147
|
-
const r = await Promise.race([client.next("team.launched", UP_MS), client.next("team.failed", UP_MS)]);
|
|
148
|
-
const snapshot = await client.next("snapshot", 500).catch(() => void 0);
|
|
149
|
-
if (r.type === "team.failed") {
|
|
150
|
-
if (parsed.json) return { line: JSON.stringify({ ok: false, reason: r.reason, ...r.team ? { team: teamJson(r.team, snapshot?.sessions ?? []) } : {} }), code: 1 };
|
|
151
|
-
return { line: `refus\xE9 : ${r.reason}${r.team ? `
|
|
152
|
-
${formatTeam(r.team, snapshot?.sessions ?? [])}` : ""}`, code: 1 };
|
|
153
|
-
}
|
|
154
|
-
client.send({ type: "snapshot.request" });
|
|
155
|
-
const fresh = await client.next("snapshot", 1500).catch(() => snapshot);
|
|
156
|
-
if (parsed.json) return { line: JSON.stringify({ ok: true, team: teamJson(r.team, fresh?.sessions ?? []) }), code: 0 };
|
|
157
|
-
return { line: `\xE9quipe ${r.team.name} lanc\xE9e
|
|
158
|
-
${formatTeam(r.team, fresh?.sessions ?? [])}`, code: 0 };
|
|
159
|
-
} catch (e) {
|
|
160
|
-
return { line: `pas de r\xE9ponse de Ledge : ${e.message}`, code: 1 };
|
|
161
|
-
} finally {
|
|
162
|
-
await client.close();
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
async function runVerb(cmd, port, by) {
|
|
166
|
-
let client;
|
|
167
|
-
try {
|
|
168
|
-
client = await connect({ port, timeoutMs: 1500 });
|
|
169
|
-
} catch {
|
|
170
|
-
return { line: DAEMON_DOWN, code: 1 };
|
|
171
|
-
}
|
|
172
|
-
try {
|
|
173
|
-
if (!cmd.closeSessions || !cmd.yes) return resultLine(await runOnClient(client, cmd.action, cmd.args, { by, confirmed: cmd.yes }), cmd.json);
|
|
174
|
-
const snapshot = await client.next("snapshot", 1500);
|
|
175
|
-
const teams = (await client.next("teams", 1500).catch(() => ({ teams: [] }))).teams;
|
|
176
|
-
const asked = await runOnClient(client, cmd.action, cmd.args, { by });
|
|
177
|
-
if (asked.code !== "confirm_required") return resultLine(asked, cmd.json);
|
|
178
|
-
const team = teams.find((t) => t.id === asked.row?.team);
|
|
179
|
-
const live = (team?.seats ?? []).flatMap((seat) => {
|
|
180
|
-
const s = snapshot.sessions.find((x) => x.id === seat.sessionId);
|
|
181
|
-
return s && s.state !== "exited" && s.source !== "hook_only" ? [s] : [];
|
|
182
|
-
});
|
|
183
|
-
const self = live.find((s) => s.id === by?.by);
|
|
184
|
-
const lines = [];
|
|
185
|
-
const step = async (r) => {
|
|
186
|
-
const l = resultLine(r, cmd.json);
|
|
187
|
-
lines.push(l.line);
|
|
188
|
-
return l.code === 0;
|
|
189
|
-
};
|
|
190
|
-
for (const s of live) if (s !== self && !await step(await runOnClient(client, "session.close", { session: s.id }, { by }))) return { line: lines.join("\n"), code: 1 };
|
|
191
|
-
if (!await step(await runOnClient(client, cmd.action, cmd.args, { by, confirmed: true }))) return { line: lines.join("\n"), code: 1 };
|
|
192
|
-
if (self && !await step(await runOnClient(client, "session.close", { session: self.id }, { by }))) return { line: lines.join("\n"), code: 1 };
|
|
193
|
-
return { line: lines.join("\n"), code: 0 };
|
|
194
|
-
} catch (e) {
|
|
195
|
-
return { line: `pas de r\xE9ponse de Ledge : ${e.message}`, code: 1 };
|
|
196
|
-
} finally {
|
|
197
|
-
await client.close();
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
export {
|
|
201
|
-
TEAM_USAGE,
|
|
202
|
-
formatTeam,
|
|
203
|
-
runTeam,
|
|
204
|
-
teamArgs
|
|
205
|
-
};
|