fix: make /exit use graceful shutdown, add /kill for immediate exit

- /exit now calls stopAuto() before exiting to save activity log and clear locks
- Added new /kill command for immediate exit without cleanup
- Fixes issue #132: /exit terminates too abruptly and leaves terminal state dirty
This commit is contained in:
SparkLabScout 2026-03-13 12:29:15 +08:00
parent 6e1e634251
commit 1217e03225

View file

@ -63,9 +63,20 @@ export default function (pi: ExtensionAPI) {
registerGSDCommand(pi);
registerWorktreeCommand(pi);
// ── /exit — kill the process immediately ──────────────────────────────
// ── /exit — graceful exit (cleanup auto-mode, save state) ──────────────
pi.registerCommand("exit", {
description: "Exit GSD immediately",
description: "Exit GSD gracefully (saves auto-mode state)",
handler: async (_ctx) => {
// Gracefully stop auto-mode if running (saves activity log, clears locks)
const { stopAuto } = await import("./auto.js");
await stopAuto(_ctx, pi);
process.exit(0);
},
});
// ── /kill — immediate exit (bypass cleanup) ─────────────────────────────
pi.registerCommand("kill", {
description: "Exit GSD immediately (no cleanup)",
handler: async (_ctx) => {
process.exit(0);
},