session-preserver 0.1.0 → 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/index.js +28 -1
- package/package.json +21 -5
package/index.js
CHANGED
|
@@ -218,6 +218,31 @@ function render(sess, pairs) {
|
|
|
218
218
|
return head + pairs.map(([r, t]) => `\n## ${r}\n\n${t}\n`).join("");
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
// ---------- open: resume session in its own CLI ----------
|
|
222
|
+
|
|
223
|
+
const RESUME = {
|
|
224
|
+
claude: (sess) => ({ cmd: "claude", args: ["--resume", sess.id.slice(3)], cwd: expandHome(sess.project) }),
|
|
225
|
+
codex: (sess) => ({ cmd: "codex", args: ["resume", sess.id.slice(3)], cwd: expandHome(sess.project) }),
|
|
226
|
+
opencode: (sess) => ({ cmd: "opencode", args: ["--session", sess.id.slice(3)], cwd: expandHome(sess.project) }),
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const expandHome = (p) => p.replace(/^~(?=$|\/)/, os.homedir());
|
|
230
|
+
|
|
231
|
+
function cmdOpen(id) {
|
|
232
|
+
const sess = find(id);
|
|
233
|
+
const { spawnSync } = require("child_process");
|
|
234
|
+
const bin = RESUME[sess.tool](sess);
|
|
235
|
+
const which = spawnSync("which", [bin.cmd]);
|
|
236
|
+
if (which.status !== 0) {
|
|
237
|
+
console.error(`'${bin.cmd}' not on PATH. Install it, or copy context manually with:\n sp summary ${sess.id} | pbcopy`);
|
|
238
|
+
process.exit(1);
|
|
239
|
+
}
|
|
240
|
+
const cwd = bin.cwd && fs.existsSync(bin.cwd) ? bin.cwd : process.cwd();
|
|
241
|
+
console.log(`resuming in ${sess.tool}: ${bin.cmd} ${bin.args.join(" ")} (cwd: ${shortHome(cwd)})`);
|
|
242
|
+
const r = spawnSync(bin.cmd, bin.args, { cwd, stdio: "inherit" });
|
|
243
|
+
process.exit(r.status ?? 0);
|
|
244
|
+
}
|
|
245
|
+
|
|
221
246
|
// ---------- commands ----------
|
|
222
247
|
|
|
223
248
|
function cmdLs(args) {
|
|
@@ -256,6 +281,7 @@ Usage:
|
|
|
256
281
|
session-preserver show <id> [-n N]
|
|
257
282
|
session-preserver summary <id>
|
|
258
283
|
session-preserver path <id>
|
|
284
|
+
session-preserver open <id> resume the session in its own CLI
|
|
259
285
|
|
|
260
286
|
ids accept unique prefixes, e.g. cx:019efd32`);
|
|
261
287
|
process.exit(code);
|
|
@@ -264,7 +290,7 @@ ids accept unique prefixes, e.g. cx:019efd32`);
|
|
|
264
290
|
const argv = process.argv.slice(2);
|
|
265
291
|
if (argv.includes("-h") || argv.includes("--help")) usage(0);
|
|
266
292
|
|
|
267
|
-
const COMMANDS = new Set(["ls", "show", "summary", "path"]);
|
|
293
|
+
const COMMANDS = new Set(["ls", "show", "summary", "path", "open"]);
|
|
268
294
|
let cmd = "ls";
|
|
269
295
|
if (COMMANDS.has(argv[0])) cmd = argv.shift();
|
|
270
296
|
|
|
@@ -287,5 +313,6 @@ if (cmd === "ls") {
|
|
|
287
313
|
const i = argv.indexOf("-n");
|
|
288
314
|
cmdShow(id, i > -1 ? Number(argv[i + 1]) : null);
|
|
289
315
|
} else if (cmd === "summary") cmdSummary(id);
|
|
316
|
+
else if (cmd === "open") cmdOpen(id);
|
|
290
317
|
else if (cmd === "path") console.log(find(id).source);
|
|
291
318
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "session-preserver",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Centralized session history for AI CLIs — Claude Code, Codex, OpenCode. Read-only.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"bin": {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
"bin": {
|
|
7
|
+
"session-preserver": "index.js",
|
|
8
|
+
"sp": "index.js"
|
|
9
|
+
},
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=18"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"index.js",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"keywords": [
|
|
18
|
+
"claude",
|
|
19
|
+
"codex",
|
|
20
|
+
"opencode",
|
|
21
|
+
"ai",
|
|
22
|
+
"cli",
|
|
23
|
+
"history",
|
|
24
|
+
"session"
|
|
25
|
+
]
|
|
10
26
|
}
|