@paradow/ledge 0.34.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 (36) hide show
  1. package/dist/cli/index.js +39003 -39
  2. package/dist/cli/{chunk-IWY7DSSO.js → reduceWorker.js} +749 -1188
  3. package/package.json +4 -1
  4. package/dist/cli/action-K42H5BDA.js +0 -27
  5. package/dist/cli/attach-KEE4A5YP.js +0 -87
  6. package/dist/cli/bridge-X327AZY4.js +0 -70
  7. package/dist/cli/chunk-25RVT5MR.js +0 -623
  8. package/dist/cli/chunk-3OJCWJAA.js +0 -144
  9. package/dist/cli/chunk-4OYVM4MT.js +0 -49
  10. package/dist/cli/chunk-4TCSADFR.js +0 -252
  11. package/dist/cli/chunk-53ISXX2R.js +0 -39
  12. package/dist/cli/chunk-54KF5RBY.js +0 -17
  13. package/dist/cli/chunk-7NHQGP6J.js +0 -95
  14. package/dist/cli/chunk-G7XPEVCG.js +0 -118
  15. package/dist/cli/chunk-KPDTYX7F.js +0 -60
  16. package/dist/cli/chunk-OLLQBK6N.js +0 -41
  17. package/dist/cli/chunk-RPH773TY.js +0 -6
  18. package/dist/cli/chunk-RX5CJ7YH.js +0 -43
  19. package/dist/cli/chunk-T547FLQN.js +0 -128
  20. package/dist/cli/chunk-U67V476Y.js +0 -35
  21. package/dist/cli/chunk-UJ2WBGLW.js +0 -305
  22. package/dist/cli/chunk-ULOMKEB6.js +0 -85
  23. package/dist/cli/chunk-V4XKKL6K.js +0 -205
  24. package/dist/cli/daemon-RO43S3S5.js +0 -11449
  25. package/dist/cli/decide-KZFYL3HY.js +0 -59
  26. package/dist/cli/handover-BWNMI2RA.js +0 -17
  27. package/dist/cli/hook-ZLWXI5EQ.js +0 -473
  28. package/dist/cli/launch-GCX7TXOH.js +0 -28
  29. package/dist/cli/send-SXZAPVRH.js +0 -19
  30. package/dist/cli/setup-TJ32FMVJ.js +0 -38
  31. package/dist/cli/status-YDVRES4E.js +0 -28
  32. package/dist/cli/task-TUSOVJK7.js +0 -19
  33. package/dist/cli/tui-TCVIRZCQ.js +0 -19348
  34. package/dist/cli/uninstall-QO7YMSLA.js +0 -162
  35. package/dist/cli/version-BAYSYWFP.js +0 -7
  36. package/dist/cli/who-6AZYSP7T.js +0 -12
@@ -1,162 +0,0 @@
1
- import {
2
- BIN_MARK,
3
- SERVICE,
4
- execRunner,
5
- stopDetachedDaemon
6
- } from "./chunk-UJ2WBGLW.js";
7
- import "./chunk-T547FLQN.js";
8
- import "./chunk-54KF5RBY.js";
9
- import {
10
- paths
11
- } from "./chunk-53ISXX2R.js";
12
- import "./chunk-U67V476Y.js";
13
-
14
- // src/cli/uninstall.ts
15
- import { readFile, writeFile, rename, rm, lstat, realpath } from "fs/promises";
16
- import { homedir } from "os";
17
- import { join } from "path";
18
- var LEDGE_HOOK = /^ledge hook (?:(?:codex|cursor) )?[A-Za-z]+$/;
19
- var isObject = (v) => !!v && typeof v === "object" && !Array.isArray(v);
20
- function prune(config, file, keep) {
21
- if (!isObject(config)) throw new Error(`${file} root is not an object, not modified`);
22
- if (config.hooks === void 0) return { settings: config, removed: 0 };
23
- if (!isObject(config.hooks)) throw new Error(`${file} "hooks" is not an object, not modified`);
24
- const hooks = {};
25
- let removed = 0;
26
- for (const [ev, list] of Object.entries(config.hooks)) {
27
- if (!Array.isArray(list)) throw new Error(`${file} hooks.${ev} is not an array, not modified`);
28
- const kept = [];
29
- for (const entry of list) {
30
- const next = keep(entry);
31
- if (next === null) removed++;
32
- else {
33
- if (next !== entry) removed++;
34
- kept.push(next);
35
- }
36
- }
37
- if (kept.length || !list.length) hooks[ev] = kept;
38
- }
39
- const { hooks: _drop, ...rest } = config;
40
- return { settings: Object.keys(hooks).length ? { ...rest, hooks } : rest, removed };
41
- }
42
- function removeClaudeHooks(settings, file = "settings.json") {
43
- return prune(settings, file, (entry) => {
44
- if (!isObject(entry) || !Array.isArray(entry.hooks)) return entry;
45
- const others = entry.hooks.filter((h) => !(isObject(h) && typeof h.command === "string" && LEDGE_HOOK.test(h.command)));
46
- if (others.length === entry.hooks.length) return entry;
47
- return others.length ? { ...entry, hooks: others } : null;
48
- });
49
- }
50
- function removeCursorHooks(config) {
51
- return prune(config, "hooks.json", (entry) => isObject(entry) && typeof entry.command === "string" && LEDGE_HOOK.test(entry.command) ? null : entry);
52
- }
53
- async function pruneJsonFile(path, remove, name) {
54
- let raw;
55
- try {
56
- raw = await readFile(path, "utf8");
57
- } catch (e) {
58
- if (e.code === "ENOENT") return null;
59
- throw e;
60
- }
61
- let current;
62
- try {
63
- current = JSON.parse(raw);
64
- } catch {
65
- throw new Error(`${name} is not valid JSON, not modified`);
66
- }
67
- const { settings, removed } = remove(current);
68
- if (!removed) return 0;
69
- const tmp = `${path}.ledge-${process.pid}.tmp`;
70
- await writeFile(tmp, JSON.stringify(settings, null, 2) + "\n");
71
- await rename(tmp, path);
72
- return removed;
73
- }
74
- async function removeService(opts = {}) {
75
- const out = [];
76
- const run = opts.run ?? execRunner;
77
- const unit = join(opts.unitDir ?? join(homedir(), ".config", "systemd", "user"), SERVICE);
78
- let present = true;
79
- try {
80
- await lstat(unit);
81
- } catch {
82
- present = false;
83
- }
84
- if (present) {
85
- const r = await run("systemctl", ["--user", "disable", "--now", SERVICE]);
86
- if (r.code !== 0) out.push(`systemctl --user disable --now ${SERVICE} failed (${r.stderr.trim() || `exit ${r.code}`}), removing the unit anyway`);
87
- await rm(unit, { force: true });
88
- await run("systemctl", ["--user", "daemon-reload"]);
89
- out.push(`${SERVICE} stopped and removed`);
90
- } else out.push(`${SERVICE} not installed`);
91
- const pid = await stopDetachedDaemon(opts.pidFile ?? paths().pid);
92
- if (pid !== null) out.push(`detached daemon (pid ${pid}) stopped`);
93
- return out;
94
- }
95
- async function runningSessions(run, socket) {
96
- const r = await run("tmux", ["-L", socket, "list-sessions", "-F", "#{session_name}"]);
97
- return r.code === 0 ? r.stdout.split("\n").filter(Boolean).length : 0;
98
- }
99
- async function removeLink(link, script) {
100
- try {
101
- const st = await lstat(link);
102
- if (st.isFile() ? !(await readFile(link, "utf8")).startsWith(BIN_MARK) : !st.isSymbolicLink() || await realpath(link) !== await realpath(script)) return false;
103
- } catch {
104
- return false;
105
- }
106
- await rm(link, { force: true });
107
- return true;
108
- }
109
- function uninstallArgs(args) {
110
- return args.every((a) => a === "--purge") && args.length <= 1 ? { purge: args.length === 1 } : null;
111
- }
112
- async function runUninstall(opts = {}) {
113
- const lines = [];
114
- let ok = true;
115
- const step = async (f) => {
116
- try {
117
- await f();
118
- } catch (e) {
119
- ok = false;
120
- lines.push(`error: ${e.message}`);
121
- }
122
- };
123
- const run = opts.run ?? execRunner;
124
- const files = [
125
- ["Claude Code", opts.settingsPath ?? join(homedir(), ".claude", "settings.json"), (c) => removeClaudeHooks(c, "settings.json")],
126
- ["Codex", join(opts.codexDir ?? process.env.CODEX_HOME ?? join(homedir(), ".codex"), "hooks.json"), (c) => removeClaudeHooks(c, "hooks.json")],
127
- ["Cursor Agent", join(opts.cursorDir ?? join(homedir(), ".cursor"), "hooks.json"), removeCursorHooks]
128
- ];
129
- for (const [agent, path, remove] of files) {
130
- await step(async () => {
131
- const n = await pruneJsonFile(path, remove, `${agent} ${path}`);
132
- lines.push(n === null ? `${agent}: ${path} missing, nothing to remove` : n ? `${agent}: ${n} Ledge hook${n > 1 ? "s" : ""} removed from ${path}` : `${agent}: no Ledge hook in ${path}`);
133
- });
134
- }
135
- if (opts.service ?? true) await step(async () => {
136
- lines.push(...await removeService({ unitDir: opts.unitDir, run }));
137
- });
138
- await step(async () => {
139
- const n = await runningSessions(run, opts.tmuxSocket ?? "ledge");
140
- if (n) lines.push(`${n} session${n > 1 ? "s" : ""} still running on Ledge's tmux server, left alone: \`tmux -L ${opts.tmuxSocket ?? "ledge"} kill-server\` ends ${n > 1 ? "them" : "it"}`);
141
- });
142
- const dir = paths().dir;
143
- if (opts.purge) await step(async () => {
144
- await rm(dir, { recursive: true, force: true });
145
- lines.push(`${dir} removed`);
146
- });
147
- else lines.push(`${dir} kept (session journal and log): \`ledge uninstall --purge\` removes it`);
148
- const script = opts.script ?? process.argv[1];
149
- const link = opts.link ?? join(homedir(), ".local", "bin", "ledge");
150
- if (script) await step(async () => {
151
- if (await removeLink(link, script)) lines.push(`${link} removed`);
152
- });
153
- lines.push(ok ? "Ledge is uninstalled from WSL. On Windows: Settings > Apps > Installed apps > Ledge > Uninstall." : "Uninstall finished with errors, see above.");
154
- return { lines, ok };
155
- }
156
- export {
157
- removeClaudeHooks,
158
- removeCursorHooks,
159
- removeService,
160
- runUninstall,
161
- uninstallArgs
162
- };
@@ -1,7 +0,0 @@
1
- import {
2
- LEDGE_VERSION
3
- } from "./chunk-RPH773TY.js";
4
- import "./chunk-U67V476Y.js";
5
- export {
6
- LEDGE_VERSION
7
- };
@@ -1,12 +0,0 @@
1
- import {
2
- formatWho,
3
- printWho
4
- } from "./chunk-RX5CJ7YH.js";
5
- import "./chunk-7NHQGP6J.js";
6
- import "./chunk-IWY7DSSO.js";
7
- import "./chunk-53ISXX2R.js";
8
- import "./chunk-U67V476Y.js";
9
- export {
10
- formatWho,
11
- printWho
12
- };