@elhu/pit 0.1.1
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/LICENSE +21 -0
- package/README.md +380 -0
- package/dist/adapters/claude-code.d.ts +70 -0
- package/dist/adapters/claude-code.d.ts.map +1 -0
- package/dist/adapters/claude-code.js +166 -0
- package/dist/adapters/claude-code.js.map +1 -0
- package/dist/adapters/index.d.ts +16 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +49 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/opencode.d.ts +53 -0
- package/dist/adapters/opencode.d.ts.map +1 -0
- package/dist/adapters/opencode.js +120 -0
- package/dist/adapters/opencode.js.map +1 -0
- package/dist/adapters/process-utils.d.ts +29 -0
- package/dist/adapters/process-utils.d.ts.map +1 -0
- package/dist/adapters/process-utils.js +96 -0
- package/dist/adapters/process-utils.js.map +1 -0
- package/dist/adapters/types.d.ts +41 -0
- package/dist/adapters/types.d.ts.map +1 -0
- package/dist/adapters/types.js +6 -0
- package/dist/adapters/types.js.map +1 -0
- package/dist/assets.generated.d.ts +13 -0
- package/dist/assets.generated.d.ts.map +1 -0
- package/dist/assets.generated.js +162 -0
- package/dist/assets.generated.js.map +1 -0
- package/dist/beads.d.ts +85 -0
- package/dist/beads.d.ts.map +1 -0
- package/dist/beads.js +120 -0
- package/dist/beads.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +39 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/add.d.ts +10 -0
- package/dist/commands/add.d.ts.map +1 -0
- package/dist/commands/add.js +58 -0
- package/dist/commands/add.js.map +1 -0
- package/dist/commands/cleanup.d.ts +13 -0
- package/dist/commands/cleanup.d.ts.map +1 -0
- package/dist/commands/cleanup.js +174 -0
- package/dist/commands/cleanup.js.map +1 -0
- package/dist/commands/daemon.d.ts +3 -0
- package/dist/commands/daemon.d.ts.map +1 -0
- package/dist/commands/daemon.js +162 -0
- package/dist/commands/daemon.js.map +1 -0
- package/dist/commands/init.d.ts +20 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +125 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/install-keybinding.d.ts +61 -0
- package/dist/commands/install-keybinding.d.ts.map +1 -0
- package/dist/commands/install-keybinding.js +138 -0
- package/dist/commands/install-keybinding.js.map +1 -0
- package/dist/commands/install-status.d.ts +35 -0
- package/dist/commands/install-status.d.ts.map +1 -0
- package/dist/commands/install-status.js +115 -0
- package/dist/commands/install-status.js.map +1 -0
- package/dist/commands/log.d.ts +7 -0
- package/dist/commands/log.d.ts.map +1 -0
- package/dist/commands/log.js +60 -0
- package/dist/commands/log.js.map +1 -0
- package/dist/commands/pause.d.ts +12 -0
- package/dist/commands/pause.d.ts.map +1 -0
- package/dist/commands/pause.js +47 -0
- package/dist/commands/pause.js.map +1 -0
- package/dist/commands/resume.d.ts +12 -0
- package/dist/commands/resume.d.ts.map +1 -0
- package/dist/commands/resume.js +59 -0
- package/dist/commands/resume.js.map +1 -0
- package/dist/commands/shared.d.ts +7 -0
- package/dist/commands/shared.d.ts.map +1 -0
- package/dist/commands/shared.js +56 -0
- package/dist/commands/shared.js.map +1 -0
- package/dist/commands/start.d.ts +12 -0
- package/dist/commands/start.d.ts.map +1 -0
- package/dist/commands/start.js +274 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/status.d.ts +24 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +101 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/stop.d.ts +11 -0
- package/dist/commands/stop.d.ts.map +1 -0
- package/dist/commands/stop.js +52 -0
- package/dist/commands/stop.js.map +1 -0
- package/dist/commands/teardown.d.ts +15 -0
- package/dist/commands/teardown.d.ts.map +1 -0
- package/dist/commands/teardown.js +72 -0
- package/dist/commands/teardown.js.map +1 -0
- package/dist/config.d.ts +58 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +129 -0
- package/dist/config.js.map +1 -0
- package/dist/daemon/client.d.ts +38 -0
- package/dist/daemon/client.d.ts.map +1 -0
- package/dist/daemon/client.js +254 -0
- package/dist/daemon/client.js.map +1 -0
- package/dist/daemon/context.d.ts +63 -0
- package/dist/daemon/context.d.ts.map +1 -0
- package/dist/daemon/context.js +14 -0
- package/dist/daemon/context.js.map +1 -0
- package/dist/daemon/handlers.d.ts +79 -0
- package/dist/daemon/handlers.d.ts.map +1 -0
- package/dist/daemon/handlers.js +1260 -0
- package/dist/daemon/handlers.js.map +1 -0
- package/dist/daemon/index.d.ts +6 -0
- package/dist/daemon/index.d.ts.map +1 -0
- package/dist/daemon/index.js +7 -0
- package/dist/daemon/index.js.map +1 -0
- package/dist/daemon/lifecycle.d.ts +56 -0
- package/dist/daemon/lifecycle.d.ts.map +1 -0
- package/dist/daemon/lifecycle.js +341 -0
- package/dist/daemon/lifecycle.js.map +1 -0
- package/dist/daemon/protocol.d.ts +174 -0
- package/dist/daemon/protocol.d.ts.map +1 -0
- package/dist/daemon/protocol.js +3 -0
- package/dist/daemon/protocol.js.map +1 -0
- package/dist/daemon/recovery.d.ts +37 -0
- package/dist/daemon/recovery.d.ts.map +1 -0
- package/dist/daemon/recovery.js +197 -0
- package/dist/daemon/recovery.js.map +1 -0
- package/dist/daemon/server.d.ts +31 -0
- package/dist/daemon/server.d.ts.map +1 -0
- package/dist/daemon/server.js +294 -0
- package/dist/daemon/server.js.map +1 -0
- package/dist/daemon/socket.d.ts +18 -0
- package/dist/daemon/socket.d.ts.map +1 -0
- package/dist/daemon/socket.js +36 -0
- package/dist/daemon/socket.js.map +1 -0
- package/dist/daemon/state.d.ts +60 -0
- package/dist/daemon/state.d.ts.map +1 -0
- package/dist/daemon/state.js +156 -0
- package/dist/daemon/state.js.map +1 -0
- package/dist/daemon/systemd.d.ts +19 -0
- package/dist/daemon/systemd.d.ts.map +1 -0
- package/dist/daemon/systemd.js +131 -0
- package/dist/daemon/systemd.js.map +1 -0
- package/dist/hooks/claude-code-hook.d.ts +32 -0
- package/dist/hooks/claude-code-hook.d.ts.map +1 -0
- package/dist/hooks/claude-code-hook.js +112 -0
- package/dist/hooks/claude-code-hook.js.map +1 -0
- package/dist/instructions-template.d.ts +9 -0
- package/dist/instructions-template.d.ts.map +1 -0
- package/dist/instructions-template.js +123 -0
- package/dist/instructions-template.js.map +1 -0
- package/dist/logger.d.ts +25 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +44 -0
- package/dist/logger.js.map +1 -0
- package/dist/loop.d.ts +88 -0
- package/dist/loop.d.ts.map +1 -0
- package/dist/loop.js +161 -0
- package/dist/loop.js.map +1 -0
- package/dist/orchestrator-instructions-template.d.ts +13 -0
- package/dist/orchestrator-instructions-template.d.ts.map +1 -0
- package/dist/orchestrator-instructions-template.js +147 -0
- package/dist/orchestrator-instructions-template.js.map +1 -0
- package/dist/output.d.ts +12 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +25 -0
- package/dist/output.js.map +1 -0
- package/dist/plugin/pit.js +57 -0
- package/dist/session.d.ts +55 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +135 -0
- package/dist/session.js.map +1 -0
- package/dist/setup.d.ts +92 -0
- package/dist/setup.d.ts.map +1 -0
- package/dist/setup.js +382 -0
- package/dist/setup.js.map +1 -0
- package/dist/shell-quote.d.ts +16 -0
- package/dist/shell-quote.d.ts.map +1 -0
- package/dist/shell-quote.js +18 -0
- package/dist/shell-quote.js.map +1 -0
- package/dist/signals.d.ts +17 -0
- package/dist/signals.d.ts.map +1 -0
- package/dist/signals.js +26 -0
- package/dist/signals.js.map +1 -0
- package/dist/state-machine.d.ts +74 -0
- package/dist/state-machine.d.ts.map +1 -0
- package/dist/state-machine.js +153 -0
- package/dist/state-machine.js.map +1 -0
- package/dist/tmux.d.ts +101 -0
- package/dist/tmux.d.ts.map +1 -0
- package/dist/tmux.js +208 -0
- package/dist/tmux.js.map +1 -0
- package/dist/worktree.d.ts +33 -0
- package/dist/worktree.d.ts.map +1 -0
- package/dist/worktree.js +116 -0
- package/dist/worktree.js.map +1 -0
- package/package.json +66 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import * as cp from "node:child_process";
|
|
2
|
+
import { printOutput, printError } from "../output.js";
|
|
3
|
+
/**
|
|
4
|
+
* Promise wrapper for cp.execFile.
|
|
5
|
+
* Called lazily so vi.mock can replace cp.execFile before the first call.
|
|
6
|
+
*/
|
|
7
|
+
function execFileAsync(file, args) {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
cp.execFile(file, args, (err, stdout, stderr) => {
|
|
10
|
+
if (err) {
|
|
11
|
+
reject(err);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
resolve({ stdout: String(stdout), stderr: String(stderr) });
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
// Core logic (exported for testability)
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
const SEGMENT = "#{@pit-status}";
|
|
23
|
+
/**
|
|
24
|
+
* Append #{@pit-status} to the tmux server's global status-right option.
|
|
25
|
+
*
|
|
26
|
+
* Steps:
|
|
27
|
+
* 1. Read the current status-right value via `tmux show-options -gv status-right`.
|
|
28
|
+
* 2. If #{@pit-status} is already present, return { status: "already_installed" }.
|
|
29
|
+
* 3. Append ` #{@pit-status}` (with a space separator, or no separator if empty).
|
|
30
|
+
* 4. Set the new value via `tmux set-option -g status-right "<new_value>"`.
|
|
31
|
+
* 5. Return { status: "installed", previous, current }.
|
|
32
|
+
*
|
|
33
|
+
* Corner cases:
|
|
34
|
+
* - tmux not running: show-options throws → propagate with friendly error message.
|
|
35
|
+
* - status-right is empty/unset: set to #{@pit-status} with no leading space.
|
|
36
|
+
* - status-right already contains #{@pit-status}: idempotent, return already_installed.
|
|
37
|
+
* - Special characters (quotes, #): use execFileAsync args array to avoid shell injection.
|
|
38
|
+
*
|
|
39
|
+
* Note: set-option -g is SERVER-GLOBAL (applies to all sessions on this server).
|
|
40
|
+
* #{@pit-status} evaluates to empty string when the @pit-status option is unset,
|
|
41
|
+
* so it is invisible when pit isn't running.
|
|
42
|
+
*/
|
|
43
|
+
export async function installStatus() {
|
|
44
|
+
// 1. Read the current status-right value
|
|
45
|
+
let current;
|
|
46
|
+
try {
|
|
47
|
+
const { stdout } = await execFileAsync("tmux", ["show-options", "-gv", "status-right"]);
|
|
48
|
+
current = stdout.trimEnd();
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
const msg = err.stderr ?? err.message ?? "";
|
|
52
|
+
// Distinguish "tmux not running" from "unknown option" (unset value)
|
|
53
|
+
if (msg.includes("no server running") ||
|
|
54
|
+
msg.includes("error connecting") ||
|
|
55
|
+
msg.includes("can't connect")) {
|
|
56
|
+
throw new Error("tmux server not running. Start tmux first.", { cause: err });
|
|
57
|
+
}
|
|
58
|
+
// unknown option or similar — treat as empty
|
|
59
|
+
current = "";
|
|
60
|
+
}
|
|
61
|
+
// 2. Idempotency check
|
|
62
|
+
if (current.includes(SEGMENT)) {
|
|
63
|
+
return {
|
|
64
|
+
status: "already_installed",
|
|
65
|
+
segment: SEGMENT,
|
|
66
|
+
note: `#{@pit-status} is already present in status-right. No changes made.`,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
// 3. Build new value
|
|
70
|
+
const newValue = current.length === 0 ? SEGMENT : `${current} ${SEGMENT}`;
|
|
71
|
+
// 4. Apply via execFileAsync (no shell interpolation — safe for special chars)
|
|
72
|
+
await execFileAsync("tmux", ["set-option", "-g", "status-right", newValue]);
|
|
73
|
+
// 5. Return result
|
|
74
|
+
return {
|
|
75
|
+
status: "installed",
|
|
76
|
+
segment: SEGMENT,
|
|
77
|
+
previous: current,
|
|
78
|
+
current: newValue,
|
|
79
|
+
note: `Appended ${SEGMENT} to status-right (server-global). ${SEGMENT} evaluates to empty string when pit is not running, so it is invisible until pit starts. To persist across tmux restarts, add to tmux.conf: set-option -g status-right "${newValue}"`,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
// Command registration
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
export function registerInstallStatus(program) {
|
|
86
|
+
program
|
|
87
|
+
.command("install-status")
|
|
88
|
+
.description("Append #{@pit-status} to the tmux status bar (server-global status-right option)")
|
|
89
|
+
.action(async (_opts, cmd) => {
|
|
90
|
+
const pretty = (cmd.parent?.opts()).pretty ?? false;
|
|
91
|
+
try {
|
|
92
|
+
const result = await installStatus();
|
|
93
|
+
if (pretty) {
|
|
94
|
+
if (result.status === "already_installed") {
|
|
95
|
+
process.stdout.write(`Already installed: ${result.segment} is already in status-right.\n`);
|
|
96
|
+
process.stdout.write(`Note: ${result.note}\n`);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
process.stdout.write(`Installed: ${result.segment} appended to status-right.\n`);
|
|
100
|
+
process.stdout.write(`Previous: ${result.previous}\n`);
|
|
101
|
+
process.stdout.write(`Current: ${result.current}\n`);
|
|
102
|
+
process.stdout.write(`\nNote: ${result.note}\n`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
printOutput(result, false);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
printError({ error: `Failed to install status segment: ${err.message}` }, pretty);
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=install-status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install-status.js","sourceRoot":"","sources":["../../src/commands/install-status.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAEzC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,cA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0,0 +1,60 @@
|
|
|
1
|
+
import * as crypto from "node:crypto";
|
|
2
|
+
import { getClientOrFail } from "./shared.js";
|
|
3
|
+
import { printError } from "../output.js";
|
|
4
|
+
export function registerLog(program) {
|
|
5
|
+
program
|
|
6
|
+
.command("log <epic>")
|
|
7
|
+
.description("Show log output for an epic")
|
|
8
|
+
.option("--lines <n>", "Number of lines to show", "50")
|
|
9
|
+
.option("--raw", "Show raw log output")
|
|
10
|
+
.action(async (epic, opts, cmd) => {
|
|
11
|
+
const pretty = (cmd.parent?.opts()).pretty ?? false;
|
|
12
|
+
// Validate --lines value
|
|
13
|
+
const linesNum = parseInt(opts.lines, 10);
|
|
14
|
+
if (!Number.isInteger(linesNum) || linesNum < 1) {
|
|
15
|
+
printError({ error: `invalid --lines value: must be >= 1` }, pretty);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const client = await getClientOrFail({ tmuxSession: "pit" });
|
|
20
|
+
try {
|
|
21
|
+
const response = await client.send({
|
|
22
|
+
id: crypto.randomUUID(),
|
|
23
|
+
method: "log",
|
|
24
|
+
params: {
|
|
25
|
+
epic,
|
|
26
|
+
lines: linesNum,
|
|
27
|
+
raw: opts.raw ?? false,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const result = response;
|
|
31
|
+
if (!result.success) {
|
|
32
|
+
printError({ error: result.error?.message || "Log command failed" }, pretty);
|
|
33
|
+
process.exit(1);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
const logResult = result.result;
|
|
37
|
+
if (!logResult) {
|
|
38
|
+
printError({ error: "No result returned from daemon" }, pretty);
|
|
39
|
+
process.exit(1);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
// --raw or --pretty: print raw terminal text with no JSON wrapper
|
|
43
|
+
if (opts.raw ?? pretty) {
|
|
44
|
+
process.stdout.write(logResult.output);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
// Transform to legacy format
|
|
48
|
+
const legacyOutput = {
|
|
49
|
+
epic: logResult.epic,
|
|
50
|
+
content: logResult.output,
|
|
51
|
+
};
|
|
52
|
+
console.log(JSON.stringify(legacyOutput));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
client.close();
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/commands/log.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAO1C,MAAM,UAAU,WAAW,CAAC,OAAgB;IAC1C,OAAO;SACJ,OAAO,CAAC,YAAY,CAAC;SACrB,WAAW,CAAC,6BAA6B,CAAC;SAC1C,MAAM,CAAC,aAAa,EAAE,yBAAyB,EAAE,IAAI,CAAC;SACtD,MAAM,CAAC,OAAO,EAAE,qBAAqB,CAAC;SACtC,MAAM,CAAC,KAAK,EAAE,IAAY,EAAE,IAAsC,EAAE,GAAY,EAAE,EAAE;QACnF,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAA2B,CAAA,CAAC,MAAM,IAAI,KAAK,CAAC;QAE5E,yBAAyB;QACzB,MAAM,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAC1C,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;YAChD,UAAU,CAAC,EAAE,KAAK,EAAE,qCAAqC,EAAE,EAAE,MAAM,CAAC,CAAC;YACrE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAChB,OAAO;QACT,CAAC;QA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,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
export interface PauseOutput {
|
|
3
|
+
epic: string;
|
|
4
|
+
previousState: string;
|
|
5
|
+
currentState: "paused";
|
|
6
|
+
}
|
|
7
|
+
export interface PauseTimeoutOutput {
|
|
8
|
+
epic: string;
|
|
9
|
+
warning: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function registerPause(program: Command): void;
|
|
12
|
+
//# sourceMappingURL=pause.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pause.d.ts","sourceRoot":"","sources":["../../src/commands/pause.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,QAAQ,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAkDpD"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as crypto from "node:crypto";
|
|
2
|
+
import { getClientOrFail } from "./shared.js";
|
|
3
|
+
import { printError, printOutput } from "../output.js";
|
|
4
|
+
export function registerPause(program) {
|
|
5
|
+
program
|
|
6
|
+
.command("pause <epic>")
|
|
7
|
+
.description("Pause a running epic")
|
|
8
|
+
.action(async (epic, _opts, cmd) => {
|
|
9
|
+
const pretty = (cmd.parent?.opts()).pretty ?? false;
|
|
10
|
+
const client = await getClientOrFail({ tmuxSession: "pit" });
|
|
11
|
+
try {
|
|
12
|
+
const response = await client.send({
|
|
13
|
+
id: crypto.randomUUID(),
|
|
14
|
+
method: "pause",
|
|
15
|
+
params: { epic },
|
|
16
|
+
});
|
|
17
|
+
const result = response;
|
|
18
|
+
if (!result.success) {
|
|
19
|
+
printError({ error: result.error?.message || "Pause failed" }, pretty);
|
|
20
|
+
process.exit(1);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const pauseResult = result.result;
|
|
24
|
+
if (!pauseResult) {
|
|
25
|
+
printError({ error: "No result returned from daemon" }, pretty);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
if (pretty) {
|
|
30
|
+
process.stdout.write(`Paused epic ${pauseResult.epic} (${pauseResult.previousState} → ${pauseResult.newState})\n`);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// Transform to legacy format
|
|
34
|
+
const legacyOutput = {
|
|
35
|
+
epic: pauseResult.epic,
|
|
36
|
+
previousState: pauseResult.previousState,
|
|
37
|
+
currentState: pauseResult.newState,
|
|
38
|
+
};
|
|
39
|
+
printOutput(legacyOutput, false);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
client.close();
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=pause.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pause.js","sourceRoot":"","sources":["../../src/commands/pause.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAavD,MAAM,UAAU,aAAa,CAAC,OAAgB;IAC5C,OAAO;SACJ,OAAO,CAAC,cAAc,CAAC;SACvB,WAAW,CAAC,sBAAsB,CAAC;SACnC,MAAM,CAAC,KAAK,EAAE,IAAY,EAAE,KAA8B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AE,WAAW,CAAC,QAAQ;iBACnC,CAAC;gBACF,WAAW,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
export interface ResumeOutput {
|
|
3
|
+
epic: string;
|
|
4
|
+
previousState: "paused";
|
|
5
|
+
currentState: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ResumeTimeoutOutput {
|
|
8
|
+
epic: string;
|
|
9
|
+
warning: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function registerResume(program: Command): void;
|
|
12
|
+
//# sourceMappingURL=resume.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resume.d.ts","sourceRoot":"","sources":["../../src/commands/resume.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAMzC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,QAAQ,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA6DrD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as crypto from "node:crypto";
|
|
2
|
+
import { getClientOrFail } from "./shared.js";
|
|
3
|
+
import { printError, printOutput } from "../output.js";
|
|
4
|
+
export function registerResume(program) {
|
|
5
|
+
program
|
|
6
|
+
.command("resume <epic>")
|
|
7
|
+
.description("Resume a paused epic")
|
|
8
|
+
.option("--message <text>", "Message to send to the agent")
|
|
9
|
+
.action(async (epic, opts, cmd) => {
|
|
10
|
+
const pretty = (cmd.parent?.opts()).pretty ?? false;
|
|
11
|
+
const client = await getClientOrFail({ tmuxSession: "pit" });
|
|
12
|
+
try {
|
|
13
|
+
const response = await client.send({
|
|
14
|
+
id: crypto.randomUUID(),
|
|
15
|
+
method: "resume",
|
|
16
|
+
params: {
|
|
17
|
+
epic,
|
|
18
|
+
...(opts.message && opts.message.length > 0 ? { message: opts.message } : {}),
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
const result = response;
|
|
22
|
+
if (!result.success) {
|
|
23
|
+
printError({ error: result.error?.message || "Resume failed" }, pretty);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
const resumeResult = result.result;
|
|
28
|
+
if (!resumeResult) {
|
|
29
|
+
printError({ error: "No result returned from daemon" }, pretty);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (pretty) {
|
|
34
|
+
if (resumeResult.warning) {
|
|
35
|
+
process.stdout.write(`Warning: ${resumeResult.warning}\n`);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
process.stdout.write(`Resumed epic ${resumeResult.epic} (${resumeResult.previousState} → ${resumeResult.newState})\n`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// Transform to legacy format
|
|
43
|
+
const legacyOutput = {
|
|
44
|
+
epic: resumeResult.epic,
|
|
45
|
+
previousState: resumeResult.previousState,
|
|
46
|
+
currentState: resumeResult.newState,
|
|
47
|
+
};
|
|
48
|
+
if (resumeResult.warning) {
|
|
49
|
+
legacyOutput.currentState = resumeResult.warning;
|
|
50
|
+
}
|
|
51
|
+
printOutput(legacyOutput, false);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
client.close();
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=resume.js.map
|
|
@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AAC;gBACxE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAChB,OAAO;YACT,CAAC;YAED,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;YACnC,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,UAAU,CAAC,EAAE,KAAK,EAAE,gCAAgC,EAAE,EAAE,MAAM,CAAC,CAAC;gBAChE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAChB,OAAO;YACT,CAAC;YACD,IAAI,MAAM,EAAE,CAAC;gBACX,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;oBACzB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,YAAY,CAAC,OAAO,IAAI,CAAC,CAAC;gBAC7D,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAClB,gBAAgB,YAAY,CAAC,IAAI,KAAK,YAAY,CAAC,aAAa,MAAM,YAAY,CAAC,QAAQ,KAAK,CACjG,CAAC;gBACJ,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,6BAA6B;gBAC7B,MAAM,YAAY,GAAiB;oBACjC,IAAI,EAAE,YAAY,CAAC,IAAI;oBACvB,aAAa,EAAE,YAAY,CAAC,aAAa;oBACzC,YAAY,EAAE,YAAY,CAAC,QAAQ;iBACpC,CAAC;gBACF,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;oBACzB,YAAY,CAAC,YAAY,GAAG,YAAY,CAAC,OAAO,CAAC;gBACnD,CAAC;gBACD,WAAW,CAAC,YAAY,EAAE,KAAK,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { DaemonClientConnection } from "../daemon/client.js";
|
|
2
|
+
export declare function resolveProjectRoot(): Promise<string>;
|
|
3
|
+
export declare function getClientOrFail(options: {
|
|
4
|
+
tmuxSession?: string;
|
|
5
|
+
pretty?: boolean;
|
|
6
|
+
}): Promise<DaemonClientConnection>;
|
|
7
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/commands/shared.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAIlE,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,CAAC,CAG1D;AAED,wBAAsB,eAAe,CAAC,OAAO,EAAE;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,GAAG,OAAO,CAAC,sBAAsB,CAAC,CAyClC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { promisify } from "node:util";
|
|
3
|
+
import { discoverDaemon, connectWithRetry, DaemonConnectionError, } from "../daemon/client.js";
|
|
4
|
+
const execFileAsync = promisify(execFile);
|
|
5
|
+
export async function resolveProjectRoot() {
|
|
6
|
+
const { stdout } = await execFileAsync("git", ["rev-parse", "--show-toplevel"]);
|
|
7
|
+
return stdout.trim();
|
|
8
|
+
}
|
|
9
|
+
export async function getClientOrFail(options) {
|
|
10
|
+
const projectRoot = await resolveProjectRoot();
|
|
11
|
+
const info = await discoverDaemon(projectRoot, options.tmuxSession ?? "pit");
|
|
12
|
+
if (!info.running) {
|
|
13
|
+
printError("No active session. Run pit start first.", options.pretty);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
try {
|
|
17
|
+
return await connectWithRetry(info.socketPath);
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
if (err instanceof Error && err.name === "DaemonVersionError") {
|
|
21
|
+
const versionErr = err;
|
|
22
|
+
printError(`Daemon version ${versionErr.daemonVersion} incompatible with CLI ${versionErr.clientVersion}. ` +
|
|
23
|
+
`Run: pit daemon restart`, options.pretty);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
}
|
|
26
|
+
if (err instanceof DaemonConnectionError) {
|
|
27
|
+
if (err.code === "CONNECTION_REFUSED") {
|
|
28
|
+
printError("Daemon not responding (may have crashed). Try: pit daemon start", options.pretty);
|
|
29
|
+
// Clean up stale socket file
|
|
30
|
+
await cleanupStaleSocket(info.socketPath);
|
|
31
|
+
}
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
// For other errors, just print and exit
|
|
35
|
+
printError(`Failed to connect to daemon: ${err instanceof Error ? err.message : "Unknown error"}`, options.pretty);
|
|
36
|
+
process.exit(1);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function printError(message, pretty = false) {
|
|
40
|
+
if (pretty) {
|
|
41
|
+
console.error(`Error: ${message}`);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
console.error(JSON.stringify({ error: message }));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
async function cleanupStaleSocket(socketPath) {
|
|
48
|
+
try {
|
|
49
|
+
const { unlink } = await import("node:fs/promises");
|
|
50
|
+
await unlink(socketPath);
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
// Ignore cleanup errors
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=shared.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/commands/shared.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,cAAc,EACd,gBAAgB,EAEhB,qBAAqB,GACtB,MAAM,qBAAqB,CAAC;AAG7B,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AA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C5C,CAAC;YACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;QAED,wCAAwC;QACxC,UAAU,CACR,gCAAgC,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,EAAE,EACtF,OAAO,CAAC,MAAM,CACf,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,SAAS,UAAU,CAAC,OAAe,EAAE,MAAM,GAAG,KAAK;IACjD,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,CAAC,KAAK,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC;IACrC,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IACpD,CAAC;AACH,CAAC;AAED,KAAK,UAAU,kBAAkB,CAAC,UAAkB;IAClD,IAAI,CAAC;QACH,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,MAAM,CAAC,kBAAkB,CAAC,CAAC;QACpD,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,wBAAwB;IAC1B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
/**
|
|
3
|
+
* Parse `--epic-model` entries (`<epic>=<model>`) into a `Record<string, string>`.
|
|
4
|
+
*
|
|
5
|
+
* - Splits on the **first** `=` only (model names may contain `=`).
|
|
6
|
+
* - Missing `=` → calls `onError` with a descriptive message.
|
|
7
|
+
* - Epic not in `validEpics` → logs a warning and skips.
|
|
8
|
+
* - Duplicate epic → last value wins (natural from iteration order).
|
|
9
|
+
*/
|
|
10
|
+
export declare function parseEpicModels(entries: string[], validEpics: string[], onError?: (msg: string) => never): Record<string, string>;
|
|
11
|
+
export declare function registerStart(program: Command): void;
|
|
12
|
+
//# sourceMappingURL=start.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"start.d.ts","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA2BzC;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,EAAE,EACjB,UAAU,EAAE,MAAM,EAAE,EACpB,OAAO,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,KAEzB,GACA,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAsBxB;AAsED,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAiMpD"}
|