@supersession/sup 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/README.md +61 -0
- package/dist/cli.d.ts +14 -0
- package/dist/cli.js +385 -0
- package/dist/cli.js.map +1 -0
- package/dist/cloud.d.ts +33 -0
- package/dist/cloud.js +72 -0
- package/dist/cloud.js.map +1 -0
- package/dist/config.d.ts +10 -0
- package/dist/config.js +36 -0
- package/dist/config.js.map +1 -0
- package/dist/discover.d.ts +14 -0
- package/dist/discover.js +44 -0
- package/dist/discover.js.map +1 -0
- package/dist/distill/smart.d.ts +30 -0
- package/dist/distill/smart.js +108 -0
- package/dist/distill/smart.js.map +1 -0
- package/dist/distill/template.d.ts +58 -0
- package/dist/distill/template.js +127 -0
- package/dist/distill/template.js.map +1 -0
- package/dist/engine.d.ts +24 -0
- package/dist/engine.js +42 -0
- package/dist/engine.js.map +1 -0
- package/dist/health.d.ts +35 -0
- package/dist/health.js +133 -0
- package/dist/health.js.map +1 -0
- package/dist/import.d.ts +27 -0
- package/dist/import.js +129 -0
- package/dist/import.js.map +1 -0
- package/dist/llm.d.ts +23 -0
- package/dist/llm.js +90 -0
- package/dist/llm.js.map +1 -0
- package/dist/mcp.d.ts +13 -0
- package/dist/mcp.js +115 -0
- package/dist/mcp.js.map +1 -0
- package/dist/nsf.d.ts +75 -0
- package/dist/nsf.js +14 -0
- package/dist/nsf.js.map +1 -0
- package/dist/parsers/chat-export.d.ts +21 -0
- package/dist/parsers/chat-export.js +107 -0
- package/dist/parsers/chat-export.js.map +1 -0
- package/dist/parsers/claude-code.d.ts +24 -0
- package/dist/parsers/claude-code.js +193 -0
- package/dist/parsers/claude-code.js.map +1 -0
- package/dist/redact.d.ts +24 -0
- package/dist/redact.js +65 -0
- package/dist/redact.js.map +1 -0
- package/dist/tools.d.ts +37 -0
- package/dist/tools.js +67 -0
- package/dist/tools.js.map +1 -0
- package/dist/writers/brief-markdown.d.ts +12 -0
- package/dist/writers/brief-markdown.js +83 -0
- package/dist/writers/brief-markdown.js.map +1 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Supersession
|
|
2
|
+
|
|
3
|
+
**Your AI coding session, superseded — hand it off to any tool and keep going.**
|
|
4
|
+
|
|
5
|
+
Hit your Claude Code limit mid-task? Switching machines? Handing work to a
|
|
6
|
+
teammate? `sup` reads your current session, distills it into a repo-grounded
|
|
7
|
+
continuation brief, and writes it in the format the next tool expects — so the
|
|
8
|
+
new agent continues instead of restarting.
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm i -g @supersession/sup
|
|
12
|
+
|
|
13
|
+
# your long session got dumb (context rot)? start fresh WITHOUT losing the arc:
|
|
14
|
+
sup status # session health: size + rot signals
|
|
15
|
+
sup refresh # fresh window, full arc — distills the complete on-disk
|
|
16
|
+
# transcript, not the degraded live window like /compact
|
|
17
|
+
|
|
18
|
+
# hit your Claude Code limit mid-task? continue in another tool:
|
|
19
|
+
sup codex # writes AGENTS.md; Codex picks up where Claude left off
|
|
20
|
+
sup preview codex # see the exact brief first — writes nothing
|
|
21
|
+
|
|
22
|
+
# plan on your phone in ChatGPT, build on your machine:
|
|
23
|
+
sup import chat.json claude
|
|
24
|
+
|
|
25
|
+
sup list # what session sup sees for this directory
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## How it works
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
discover → parse → redact → distill → write
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
1. **discover** — find the current directory's latest session
|
|
35
|
+
2. **parse** — into the Neutral Session Format (NSF), a tool-agnostic shape
|
|
36
|
+
3. **redact** — strip API keys / secrets locally before anything moves
|
|
37
|
+
4. **distill** — a continuation brief: goal, files touched (checked against the
|
|
38
|
+
live repo), commands run, recent turns verbatim, next step
|
|
39
|
+
5. **write** — the target tool's native kickoff file (`AGENTS.md`,
|
|
40
|
+
`CLAUDE.local.md`, `GEMINI.md`)
|
|
41
|
+
|
|
42
|
+
Every handoff prints a **fidelity report**: what carried verbatim, what was
|
|
43
|
+
summarized, what was dropped, how many secrets were redacted. Lossy on purpose,
|
|
44
|
+
never silently.
|
|
45
|
+
|
|
46
|
+
## Status
|
|
47
|
+
|
|
48
|
+
v0.1 — local handoff engine. Source parser: Claude Code (verified). Targets:
|
|
49
|
+
Codex, Gemini, Claude Code. Cloud vault, web-chat import, teams, and more
|
|
50
|
+
parsers are on the roadmap (see `SPEC.md`).
|
|
51
|
+
|
|
52
|
+
## Develop
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pnpm install
|
|
56
|
+
pnpm test # unit tests with a schema-faithful fixture
|
|
57
|
+
pnpm build # tsc -> dist/
|
|
58
|
+
pnpm dev list # run the CLI from source
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
MIT.
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `sup` — Supersession CLI.
|
|
4
|
+
*
|
|
5
|
+
* v1 commands (local, no cloud):
|
|
6
|
+
* sup <tool> hand off the current session to <tool>
|
|
7
|
+
* sup preview <tool> show the exact brief that would be written (no write)
|
|
8
|
+
* sup list show sessions found for this directory
|
|
9
|
+
* sup --help
|
|
10
|
+
*
|
|
11
|
+
* Pipeline: discover -> parse -> redact -> distill -> write. Every step is a
|
|
12
|
+
* separate module; this file just wires them and owns user-facing output.
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,385 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `sup` — Supersession CLI.
|
|
4
|
+
*
|
|
5
|
+
* v1 commands (local, no cloud):
|
|
6
|
+
* sup <tool> hand off the current session to <tool>
|
|
7
|
+
* sup preview <tool> show the exact brief that would be written (no write)
|
|
8
|
+
* sup list show sessions found for this directory
|
|
9
|
+
* sup --help
|
|
10
|
+
*
|
|
11
|
+
* Pipeline: discover -> parse -> redact -> distill -> write. Every step is a
|
|
12
|
+
* separate module; this file just wires them and owns user-facing output.
|
|
13
|
+
*/
|
|
14
|
+
import { writeFileSync, existsSync } from "node:fs";
|
|
15
|
+
import { join } from "node:path";
|
|
16
|
+
import pc from "picocolors";
|
|
17
|
+
import { findClaudeCodeSession } from "./discover.js";
|
|
18
|
+
import { parseClaudeCode } from "./parsers/claude-code.js";
|
|
19
|
+
import { redactSession } from "./redact.js";
|
|
20
|
+
import { requireSession, distillSession } from "./engine.js";
|
|
21
|
+
import { resolveTool, TOOLS } from "./tools.js";
|
|
22
|
+
import { loadConfig, saveConfig } from "./config.js";
|
|
23
|
+
import { whoami, pushSession, listSessions, pullSession, claimHandle, handoffTo, listInbox } from "./cloud.js";
|
|
24
|
+
import { importFromUrl, importFromFile, ImportError } from "./import.js";
|
|
25
|
+
import { assessSession } from "./health.js";
|
|
26
|
+
const SOURCE_LABEL = "Claude Code";
|
|
27
|
+
function die(msg) {
|
|
28
|
+
console.error(pc.red(`✗ ${msg}`));
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
function printFidelity(brief) {
|
|
32
|
+
const f = brief.fidelity;
|
|
33
|
+
console.log(pc.bold("\n Fidelity report"));
|
|
34
|
+
const modeLabel = brief.mode === "smart"
|
|
35
|
+
? pc.green("smart distill (LLM decisions + dead-ends)")
|
|
36
|
+
: pc.dim("template distill (grounded facts only)");
|
|
37
|
+
console.log(` mode: ${modeLabel}`);
|
|
38
|
+
if (brief.mode === "smart") {
|
|
39
|
+
console.log(` ${pc.green("✓")} ${brief.decisions?.length ?? 0} decisions, ${brief.deadEnds?.length ?? 0} dead-ends extracted`);
|
|
40
|
+
}
|
|
41
|
+
console.log(` ${pc.green("✓")} ${f.verbatimTurns} turns carried verbatim`);
|
|
42
|
+
if (f.compressedTurns > 0)
|
|
43
|
+
console.log(` ${pc.yellow("~")} ${f.compressedTurns} earlier turns summarized to headline state`);
|
|
44
|
+
if (f.secretsRedacted > 0)
|
|
45
|
+
console.log(` ${pc.green("✓")} ${f.secretsRedacted} secret(s) redacted before writing`);
|
|
46
|
+
if (f.droppedNotes.length) {
|
|
47
|
+
const total = f.droppedNotes.reduce((n, d) => n + d.count, 0);
|
|
48
|
+
console.log(` ${pc.dim("·")} ${pc.dim(`${total} non-conversational records dropped:`)}`);
|
|
49
|
+
for (const d of f.droppedNotes)
|
|
50
|
+
console.log(pc.dim(` ${d.count}× ${d.reason}`));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Build a brief for the current directory's latest Claude Code session.
|
|
55
|
+
* Uses smart (LLM) distill when a key is configured, unless forceTemplate.
|
|
56
|
+
*/
|
|
57
|
+
/** Distill an already-parsed NSF, logging the distiller note to the CLI. */
|
|
58
|
+
async function distillFrom(parsed, forceTemplate) {
|
|
59
|
+
const { brief, note } = await distillSession(parsed, forceTemplate);
|
|
60
|
+
if (note)
|
|
61
|
+
console.log(pc.dim(`· ${note}`));
|
|
62
|
+
return brief;
|
|
63
|
+
}
|
|
64
|
+
/** Parse the current directory's latest Claude Code session, or die. */
|
|
65
|
+
function currentSession() {
|
|
66
|
+
try {
|
|
67
|
+
return requireSession(process.cwd());
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
die(e instanceof Error ? e.message : String(e));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async function buildBrief(forceTemplate) {
|
|
74
|
+
return { brief: await distillFrom(currentSession(), forceTemplate) };
|
|
75
|
+
}
|
|
76
|
+
async function cmdHandoff(toolId, opts) {
|
|
77
|
+
const tool = resolveTool(toolId);
|
|
78
|
+
if (!tool) {
|
|
79
|
+
const known = Object.keys(TOOLS).join(", ");
|
|
80
|
+
die(`Unknown tool "${toolId}". Supported: ${known}`);
|
|
81
|
+
}
|
|
82
|
+
if (!tool.writeTarget)
|
|
83
|
+
die(`Tool "${toolId}" cannot yet receive handoffs.`);
|
|
84
|
+
if (!tool.verified) {
|
|
85
|
+
console.log(pc.yellow(`⚠ ${tool.label}'s session format is not yet verified — receiving a handoff works, ` +
|
|
86
|
+
`but reading FROM it is not supported yet.`));
|
|
87
|
+
}
|
|
88
|
+
const { brief } = await buildBrief(opts.template);
|
|
89
|
+
const target = tool.writeTarget(brief, SOURCE_LABEL);
|
|
90
|
+
if (opts.preview) {
|
|
91
|
+
console.log(pc.dim(`# Would write to ${target.file}:\n`));
|
|
92
|
+
console.log(target.body);
|
|
93
|
+
printFidelity(brief);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
const outPath = join(process.cwd(), target.file);
|
|
97
|
+
writeFileSync(outPath, target.body, "utf8");
|
|
98
|
+
console.log(pc.green(`\n✓ Handed off to ${tool.label}`));
|
|
99
|
+
console.log(` Wrote ${pc.bold(target.file)} (${brief.files.length} files, ${brief.commands.length} commands captured)`);
|
|
100
|
+
printFidelity(brief);
|
|
101
|
+
console.log(pc.bold(`\n Continue with:`));
|
|
102
|
+
console.log(` ${pc.cyan(target.launchHint)}\n`);
|
|
103
|
+
}
|
|
104
|
+
function cmdList() {
|
|
105
|
+
const cwd = process.cwd();
|
|
106
|
+
const found = findClaudeCodeSession(cwd);
|
|
107
|
+
if (!found) {
|
|
108
|
+
console.log(pc.dim(`No sessions found for ${cwd}`));
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const parsed = parseClaudeCode(found.filePath);
|
|
112
|
+
console.log(pc.bold(`Latest session for this directory:`));
|
|
113
|
+
console.log(` tool: ${found.tool}`);
|
|
114
|
+
console.log(` file: ${found.filePath}`);
|
|
115
|
+
console.log(` turns: ${parsed.turns.length}`);
|
|
116
|
+
console.log(` files: ${parsed.filesTouched.length} touched`);
|
|
117
|
+
console.log(` branch: ${parsed.provenance.gitBranch ?? "—"}`);
|
|
118
|
+
}
|
|
119
|
+
/** Distill an NSF and write the target tool's kickoff file. Shared by pull/import. */
|
|
120
|
+
async function writeHandoff(nsf, toolId, sourceLabel) {
|
|
121
|
+
const tool = resolveTool(toolId);
|
|
122
|
+
if (!tool?.writeTarget)
|
|
123
|
+
die(`Unknown or unsupported tool "${toolId}". Try: ${Object.keys(TOOLS).join(", ")}`);
|
|
124
|
+
const brief = await distillFrom(nsf, false);
|
|
125
|
+
const target = tool.writeTarget(brief, sourceLabel);
|
|
126
|
+
writeFileSync(join(process.cwd(), target.file), target.body, "utf8");
|
|
127
|
+
console.log(` Wrote ${pc.bold(target.file)}`);
|
|
128
|
+
printFidelity(brief);
|
|
129
|
+
console.log(pc.bold(`\n Continue with:`));
|
|
130
|
+
console.log(` ${pc.cyan(target.launchHint)}\n`);
|
|
131
|
+
return brief;
|
|
132
|
+
}
|
|
133
|
+
async function cmdImport(source, toolId) {
|
|
134
|
+
if (!source || !toolId)
|
|
135
|
+
die("Usage: sup import <chatgpt-link | export.json> <tool>\n e.g. sup import chat.json claude");
|
|
136
|
+
let nsf;
|
|
137
|
+
const isUrl = /^https?:\/\//i.test(source);
|
|
138
|
+
try {
|
|
139
|
+
if (isUrl) {
|
|
140
|
+
console.log(pc.dim(`· Importing from ${source} …`));
|
|
141
|
+
nsf = await importFromUrl(source);
|
|
142
|
+
}
|
|
143
|
+
else if (existsSync(source)) {
|
|
144
|
+
nsf = importFromFile(source, "chatgpt");
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
die(`Not a URL and no such file: ${source}`);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch (e) {
|
|
151
|
+
if (e instanceof ImportError)
|
|
152
|
+
die(e.message);
|
|
153
|
+
throw e;
|
|
154
|
+
}
|
|
155
|
+
const label = nsf.provenance.tool === "chatgpt" ? "ChatGPT" : nsf.provenance.tool;
|
|
156
|
+
console.log(pc.green(`✓ Imported ${nsf.turns.length} messages from ${label}`));
|
|
157
|
+
await writeHandoff(nsf, toolId, label);
|
|
158
|
+
}
|
|
159
|
+
function printHealth(session) {
|
|
160
|
+
const h = assessSession(session);
|
|
161
|
+
const k = (n) => `${Math.round(n / 1000)}k`;
|
|
162
|
+
console.log(pc.bold("Session quality") + pc.dim(" (measured from the transcript — not a guess at model IQ)"));
|
|
163
|
+
console.log(` turns: ${h.turns}`);
|
|
164
|
+
console.log(` size: ≈${k(h.estTokens)} tokens in the window`);
|
|
165
|
+
console.log(` live signal: ≈${k(h.signalTokens)} tokens of actual reasoning (${Math.round((1 - h.noiseRatio) * 100)}%)`);
|
|
166
|
+
if (h.compactions > 0)
|
|
167
|
+
console.log(` compactions: ${h.compactions} lossy summary layer(s)`);
|
|
168
|
+
if (h.staleRefs.length > 0)
|
|
169
|
+
console.log(` stale refs: ${h.staleRefs.length} file(s) changed/gone since discussed`);
|
|
170
|
+
if (h.signals.length === 0) {
|
|
171
|
+
console.log(pc.green(`\n ✓ healthy — mostly signal, no rot indicators`));
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
console.log("");
|
|
175
|
+
for (const s of h.signals) {
|
|
176
|
+
const mark = s.level === "warn" ? pc.yellow("⚠") : pc.dim("·");
|
|
177
|
+
console.log(` ${mark} ${s.detail}`);
|
|
178
|
+
}
|
|
179
|
+
if (h.suggestRefresh) {
|
|
180
|
+
const wasted = h.estTokens - h.signalTokens;
|
|
181
|
+
console.log(pc.bold(`\n → This session carries ≈${k(h.estTokens)} tokens but only ~${k(h.signalTokens)} of live signal.`));
|
|
182
|
+
console.log(` ${pc.cyan("sup refresh")} rebuilds from the signal and drops ~${k(wasted)} tokens of noise.`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function cmdStatus() {
|
|
186
|
+
printHealth(currentSession());
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Refresh: continue THIS tool's work in a brand-new session. Same engine as a
|
|
190
|
+
* handoff, but the target is the source tool — and the distill reads the full
|
|
191
|
+
* on-disk transcript, including turns the tool's own compaction already
|
|
192
|
+
* dropped from its live window.
|
|
193
|
+
*/
|
|
194
|
+
async function cmdRefresh(opts) {
|
|
195
|
+
const parsed = currentSession();
|
|
196
|
+
const health = assessSession(parsed);
|
|
197
|
+
if (health.suggestRefresh) {
|
|
198
|
+
console.log(pc.yellow(`⚠ Rot signals detected — good call refreshing:`));
|
|
199
|
+
for (const s of health.signals.filter((x) => x.level === "warn"))
|
|
200
|
+
console.log(pc.dim(` ${s.detail}`));
|
|
201
|
+
}
|
|
202
|
+
const brief = await distillFrom(parsed, opts.template);
|
|
203
|
+
const tool = resolveTool(parsed.provenance.tool);
|
|
204
|
+
const target = tool.writeTarget(brief, `${tool.label} (previous session)`);
|
|
205
|
+
writeFileSync(join(process.cwd(), target.file), target.body, "utf8");
|
|
206
|
+
console.log(pc.green(`\n✓ Session distilled for a fresh start`));
|
|
207
|
+
console.log(` Wrote ${pc.bold(target.file)} — full arc, clean window`);
|
|
208
|
+
printFidelity(brief);
|
|
209
|
+
console.log(pc.bold(`\n Start fresh with:`));
|
|
210
|
+
console.log(` ${pc.cyan(target.launchHint)}\n`);
|
|
211
|
+
}
|
|
212
|
+
async function cmdHandle(name) {
|
|
213
|
+
if (!name)
|
|
214
|
+
die("Usage: sup handle <name> (claim your @handle, e.g. sup handle maria)");
|
|
215
|
+
const handle = await claimHandle(name.replace(/^@/, ""));
|
|
216
|
+
console.log(pc.green(`✓ Your handle is now ${pc.bold("@" + handle)}`));
|
|
217
|
+
console.log(pc.dim(` Teammates send you sessions with: sup handoff @${handle}`));
|
|
218
|
+
}
|
|
219
|
+
async function cmdHandoffTo(handle) {
|
|
220
|
+
if (!handle)
|
|
221
|
+
die("Usage: sup handoff @teammate");
|
|
222
|
+
// Push the current session, then hand it to the teammate.
|
|
223
|
+
const parsed = currentSession();
|
|
224
|
+
const { session } = redactSession(parsed);
|
|
225
|
+
const { id } = await pushSession(session);
|
|
226
|
+
const { to } = await handoffTo(handle, id);
|
|
227
|
+
console.log(pc.green(`✓ Handed off your session to ${pc.bold(to)}`));
|
|
228
|
+
console.log(pc.dim(` They'll see it with: sup inbox → sup accept <tool>`));
|
|
229
|
+
}
|
|
230
|
+
async function cmdInbox() {
|
|
231
|
+
const inbox = await listInbox();
|
|
232
|
+
if (inbox.length === 0) {
|
|
233
|
+
console.log(pc.dim("Inbox empty — no sessions handed to you yet."));
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
console.log(pc.bold("Inbox — sessions handed to you"));
|
|
237
|
+
inbox.forEach((s, i) => {
|
|
238
|
+
const from = s.from_handle ? `@${s.from_handle}` : "someone";
|
|
239
|
+
const mark = i === 0 ? pc.cyan("→") : " ";
|
|
240
|
+
console.log(` ${mark} ${from.padEnd(14)} ${s.source_tool}, ${s.turns} turns ${pc.dim(s.id)}`);
|
|
241
|
+
});
|
|
242
|
+
console.log(pc.dim(`\n Accept the newest with: sup accept <tool>`));
|
|
243
|
+
}
|
|
244
|
+
async function cmdAccept(toolId) {
|
|
245
|
+
if (!toolId)
|
|
246
|
+
die("Usage: sup accept <tool> (take the newest inbox session into <tool>)");
|
|
247
|
+
const inbox = await listInbox();
|
|
248
|
+
if (inbox.length === 0)
|
|
249
|
+
die("Inbox empty — nothing to accept.");
|
|
250
|
+
const latest = inbox[0];
|
|
251
|
+
const nsf = await pullSession(latest.id);
|
|
252
|
+
const from = latest.from_handle ? `@${latest.from_handle}` : "a teammate";
|
|
253
|
+
console.log(pc.green(`✓ Accepted session from ${from}`));
|
|
254
|
+
await writeHandoff(nsf, toolId, `${from}'s session`);
|
|
255
|
+
}
|
|
256
|
+
function cmdLogin(token) {
|
|
257
|
+
if (!token)
|
|
258
|
+
die("Usage: sup login <token> (get one at https://supersession.app)");
|
|
259
|
+
const cfg = loadConfig();
|
|
260
|
+
saveConfig({ ...cfg, token: token });
|
|
261
|
+
console.log(pc.green(`✓ Logged in. Token saved to ~/.supersession/config.json`));
|
|
262
|
+
console.log(pc.dim(` gateway: ${cfg.gatewayUrl}`));
|
|
263
|
+
}
|
|
264
|
+
async function cmdWhoami() {
|
|
265
|
+
const acct = await whoami();
|
|
266
|
+
console.log(pc.bold("Account"));
|
|
267
|
+
console.log(` id: ${acct.id}`);
|
|
268
|
+
console.log(` email: ${acct.email ?? "—"}`);
|
|
269
|
+
console.log(` plan: ${acct.plan === "free" ? acct.plan : pc.green(acct.plan)}`);
|
|
270
|
+
console.log(` credits: ${acct.credits}`);
|
|
271
|
+
}
|
|
272
|
+
async function cmdPush() {
|
|
273
|
+
const parsed = currentSession();
|
|
274
|
+
// Redact before it ever leaves the machine.
|
|
275
|
+
const { session, hits } = redactSession(parsed);
|
|
276
|
+
const { id, bytes } = await pushSession(session);
|
|
277
|
+
console.log(pc.green(`✓ Pushed session ${pc.bold(id)} (${session.turns.length} turns, ${bytes} bytes)`));
|
|
278
|
+
if (hits > 0)
|
|
279
|
+
console.log(pc.dim(` ${hits} secret(s) redacted before upload`));
|
|
280
|
+
console.log(pc.dim(` Pull it on another machine with: sup pull <tool>`));
|
|
281
|
+
}
|
|
282
|
+
async function cmdPull(toolId) {
|
|
283
|
+
if (!toolId)
|
|
284
|
+
die("Usage: sup pull <tool> (e.g. sup pull codex)");
|
|
285
|
+
const tool = resolveTool(toolId);
|
|
286
|
+
if (!tool?.writeTarget)
|
|
287
|
+
die(`Unknown or unsupported tool "${toolId}".`);
|
|
288
|
+
const sessions = await listSessions();
|
|
289
|
+
if (sessions.length === 0)
|
|
290
|
+
die("No sessions in your cloud vault yet. Run `sup push` first.");
|
|
291
|
+
const latest = sessions[0];
|
|
292
|
+
const nsf = await pullSession(latest.id);
|
|
293
|
+
console.log(pc.green(`✓ Pulled ${latest.id} and handed off to ${tool.label}`));
|
|
294
|
+
await writeHandoff(nsf, toolId, SOURCE_LABEL);
|
|
295
|
+
}
|
|
296
|
+
function cmdHelp() {
|
|
297
|
+
console.log(`${pc.bold("supersession")} — hand off your AI coding session to any tool.
|
|
298
|
+
|
|
299
|
+
${pc.bold("Usage")}
|
|
300
|
+
sup refresh Continue THIS tool in a fresh session — full arc,
|
|
301
|
+
clean context window (beats /compact: distills the
|
|
302
|
+
complete on-disk transcript, not the degraded window)
|
|
303
|
+
sup status Session health: size + context-rot signals
|
|
304
|
+
sup <tool> Hand off this directory's latest session to <tool>
|
|
305
|
+
sup preview <tool> Show the brief that would be written (writes nothing)
|
|
306
|
+
sup import <src> <tool> Import a ChatGPT/Claude chat (link or export.json)
|
|
307
|
+
and hand it off to a coding tool
|
|
308
|
+
sup list Show the session found for this directory
|
|
309
|
+
sup --help This help
|
|
310
|
+
|
|
311
|
+
${pc.bold("Cloud (Pro)")}
|
|
312
|
+
sup login <token> Save your token (get one at https://supersession.app)
|
|
313
|
+
sup whoami Show account + credits
|
|
314
|
+
sup push Upload this directory's session to your vault
|
|
315
|
+
sup pull <tool> Fetch your latest vault session, hand off to <tool>
|
|
316
|
+
|
|
317
|
+
${pc.bold("Team handoff (Pro)")}
|
|
318
|
+
sup handle <name> Claim your @handle
|
|
319
|
+
sup handoff @user Send your current session to a teammate
|
|
320
|
+
sup inbox Sessions teammates handed to you
|
|
321
|
+
sup accept <tool> Take the newest inbox session into <tool>
|
|
322
|
+
|
|
323
|
+
${pc.bold("Flags")}
|
|
324
|
+
--template Force template distill (skip the LLM decisions layer)
|
|
325
|
+
|
|
326
|
+
${pc.bold("Smart distill")}
|
|
327
|
+
Set ANTHROPIC_API_KEY or OPENAI_API_KEY to extract decisions + dead-ends.
|
|
328
|
+
Without a key, sup uses grounded template distill (files, commands, turns).
|
|
329
|
+
|
|
330
|
+
${pc.bold("Tools")}
|
|
331
|
+
${Object.values(TOOLS)
|
|
332
|
+
.map((t) => ` ${t.id.padEnd(12)} ${t.label}${t.verified ? "" : pc.dim(" (receive-only for now)")}`)
|
|
333
|
+
.join("\n")}
|
|
334
|
+
|
|
335
|
+
${pc.bold("Example")}
|
|
336
|
+
${pc.dim("# hit your Claude Code limit mid-task, then:")}
|
|
337
|
+
sup codex
|
|
338
|
+
`);
|
|
339
|
+
}
|
|
340
|
+
async function main(argv) {
|
|
341
|
+
const all = argv.slice(2);
|
|
342
|
+
// Global flags, stripped before command parsing.
|
|
343
|
+
const template = all.includes("--template");
|
|
344
|
+
const args = all.filter((a) => a !== "--template");
|
|
345
|
+
if (args.length === 0 || args[0] === "--help" || args[0] === "-h")
|
|
346
|
+
return cmdHelp();
|
|
347
|
+
const [cmd, ...rest] = args;
|
|
348
|
+
switch (cmd) {
|
|
349
|
+
case "list":
|
|
350
|
+
return cmdList();
|
|
351
|
+
case "status":
|
|
352
|
+
return cmdStatus();
|
|
353
|
+
case "refresh":
|
|
354
|
+
return cmdRefresh({ template });
|
|
355
|
+
case "login":
|
|
356
|
+
return cmdLogin(rest[0]);
|
|
357
|
+
case "whoami":
|
|
358
|
+
return cmdWhoami();
|
|
359
|
+
case "push":
|
|
360
|
+
return cmdPush();
|
|
361
|
+
case "pull":
|
|
362
|
+
return cmdPull(rest[0]);
|
|
363
|
+
case "import":
|
|
364
|
+
return cmdImport(rest[0], rest[1]);
|
|
365
|
+
case "handle":
|
|
366
|
+
return cmdHandle(rest[0]);
|
|
367
|
+
case "handoff":
|
|
368
|
+
return cmdHandoffTo(rest[0]);
|
|
369
|
+
case "inbox":
|
|
370
|
+
return cmdInbox();
|
|
371
|
+
case "accept":
|
|
372
|
+
return cmdAccept(rest[0]);
|
|
373
|
+
case "preview": {
|
|
374
|
+
const toolId = rest[0];
|
|
375
|
+
if (!toolId)
|
|
376
|
+
die("Usage: sup preview <tool>");
|
|
377
|
+
return cmdHandoff(toolId, { preview: true, template });
|
|
378
|
+
}
|
|
379
|
+
default:
|
|
380
|
+
// Bare `sup <tool>` = handoff.
|
|
381
|
+
return cmdHandoff(cmd, { preview: false, template });
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
main(process.argv).catch((e) => die(e instanceof Error ? e.message : String(e)));
|
|
385
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";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AAS,CAAC,CAAC,CAAC;YACf,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACvB,IAAI,CAAC,MAAM;gBAAE,GAAG,CAAC,2BAA2B,CAAC,CAAC;YAC9C,OAAO,UAAU,CAAC,MAAO,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC1D,CAAC;QACD;YACE,+BAA+B;YAC/B,OAAO,UAAU,CAAC,GAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC;AAED,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/cloud.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin client for the Supersession cloud API. Fetch-only; the CLI owns all
|
|
3
|
+
* user-facing output, this just does typed requests + honest errors.
|
|
4
|
+
*/
|
|
5
|
+
import type { NsfSession } from "./nsf.js";
|
|
6
|
+
export interface Account {
|
|
7
|
+
id: string;
|
|
8
|
+
email: string | null;
|
|
9
|
+
handle: string | null;
|
|
10
|
+
plan: string;
|
|
11
|
+
credits: number | "unlimited";
|
|
12
|
+
}
|
|
13
|
+
export interface SessionRef {
|
|
14
|
+
id: string;
|
|
15
|
+
source_tool: string;
|
|
16
|
+
cwd: string | null;
|
|
17
|
+
git_branch: string | null;
|
|
18
|
+
turns: number;
|
|
19
|
+
from_handle?: string | null;
|
|
20
|
+
created_at: number;
|
|
21
|
+
}
|
|
22
|
+
export declare function whoami(): Promise<Account>;
|
|
23
|
+
export declare function pushSession(nsf: NsfSession): Promise<{
|
|
24
|
+
id: string;
|
|
25
|
+
bytes: number;
|
|
26
|
+
}>;
|
|
27
|
+
export declare function listSessions(): Promise<SessionRef[]>;
|
|
28
|
+
export declare function pullSession(id: string): Promise<NsfSession>;
|
|
29
|
+
export declare function claimHandle(handle: string): Promise<string>;
|
|
30
|
+
export declare function handoffTo(toHandle: string, sessionId: string): Promise<{
|
|
31
|
+
to: string;
|
|
32
|
+
}>;
|
|
33
|
+
export declare function listInbox(): Promise<SessionRef[]>;
|
package/dist/cloud.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin client for the Supersession cloud API. Fetch-only; the CLI owns all
|
|
3
|
+
* user-facing output, this just does typed requests + honest errors.
|
|
4
|
+
*/
|
|
5
|
+
import { loadConfig } from "./config.js";
|
|
6
|
+
class CloudError extends Error {
|
|
7
|
+
}
|
|
8
|
+
function requireToken() {
|
|
9
|
+
const { gatewayUrl, token } = loadConfig();
|
|
10
|
+
if (!token)
|
|
11
|
+
throw new CloudError("Not logged in. Run: sup login <token>");
|
|
12
|
+
return { url: gatewayUrl, token };
|
|
13
|
+
}
|
|
14
|
+
async function req(path, init = {}) {
|
|
15
|
+
const { url, token } = requireToken();
|
|
16
|
+
const res = await fetch(`${url}${path}`, {
|
|
17
|
+
...init,
|
|
18
|
+
headers: {
|
|
19
|
+
authorization: `Bearer ${token}`,
|
|
20
|
+
"content-type": "application/json",
|
|
21
|
+
...(init.headers ?? {}),
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
const text = await res.text();
|
|
25
|
+
const body = text ? JSON.parse(text) : {};
|
|
26
|
+
if (!res.ok) {
|
|
27
|
+
throw new CloudError(body.error ? `${body.error}${body.upgrade ? ` — upgrade: ${body.upgrade}` : ""}` : `HTTP ${res.status}`);
|
|
28
|
+
}
|
|
29
|
+
return body;
|
|
30
|
+
}
|
|
31
|
+
export async function whoami() {
|
|
32
|
+
const { user } = await req("/v1/me");
|
|
33
|
+
return user;
|
|
34
|
+
}
|
|
35
|
+
export async function pushSession(nsf) {
|
|
36
|
+
return req("/v1/sessions", {
|
|
37
|
+
method: "POST",
|
|
38
|
+
body: JSON.stringify({
|
|
39
|
+
nsf,
|
|
40
|
+
source_tool: nsf.provenance.tool,
|
|
41
|
+
cwd: nsf.provenance.cwd,
|
|
42
|
+
git_branch: nsf.provenance.gitBranch,
|
|
43
|
+
turns: nsf.turns.length,
|
|
44
|
+
}),
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
export async function listSessions() {
|
|
48
|
+
const { sessions } = await req("/v1/sessions");
|
|
49
|
+
return sessions;
|
|
50
|
+
}
|
|
51
|
+
export async function pullSession(id) {
|
|
52
|
+
const { nsf } = await req(`/v1/sessions/${id}`);
|
|
53
|
+
return nsf;
|
|
54
|
+
}
|
|
55
|
+
export async function claimHandle(handle) {
|
|
56
|
+
const res = await req("/v1/handle", {
|
|
57
|
+
method: "POST",
|
|
58
|
+
body: JSON.stringify({ handle }),
|
|
59
|
+
});
|
|
60
|
+
return res.handle;
|
|
61
|
+
}
|
|
62
|
+
export async function handoffTo(toHandle, sessionId) {
|
|
63
|
+
return req("/v1/handoff", {
|
|
64
|
+
method: "POST",
|
|
65
|
+
body: JSON.stringify({ toHandle, sessionId }),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
export async function listInbox() {
|
|
69
|
+
const { inbox } = await req("/v1/inbox");
|
|
70
|
+
return inbox;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=cloud.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud.js","sourceRoot":"","sources":["../src/cloud.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAoBzC,MAAM,UAAW,SAAQ,KAAK;CAAG;AAEjC,SAAS,YAAY;IACnB,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,GAAG,UAAU,EAAE,CAAC;IAC3C,IAAI,CAAC,KAAK;QAAE,M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C;IAClE,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI config: token + gateway URL, stored at ~/.supersession/config.json.
|
|
3
|
+
* Written 0600 — it holds a bearer token.
|
|
4
|
+
*/
|
|
5
|
+
export interface Config {
|
|
6
|
+
gatewayUrl: string;
|
|
7
|
+
token?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function loadConfig(): Config;
|
|
10
|
+
export declare function saveConfig(cfg: Config): void;
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI config: token + gateway URL, stored at ~/.supersession/config.json.
|
|
3
|
+
* Written 0600 — it holds a bearer token.
|
|
4
|
+
*/
|
|
5
|
+
import { readFileSync, writeFileSync, mkdirSync, chmodSync } from "node:fs";
|
|
6
|
+
import { homedir } from "node:os";
|
|
7
|
+
import { join } from "node:path";
|
|
8
|
+
// ponytail: live workers.dev URL until the supersession.app custom domain is wired.
|
|
9
|
+
const DEFAULT_GATEWAY = "https://supersession.gozeroing.workers.dev";
|
|
10
|
+
function configPath() {
|
|
11
|
+
return join(homedir(), ".supersession", "config.json");
|
|
12
|
+
}
|
|
13
|
+
export function loadConfig() {
|
|
14
|
+
try {
|
|
15
|
+
const raw = readFileSync(configPath(), "utf8");
|
|
16
|
+
const parsed = JSON.parse(raw);
|
|
17
|
+
return {
|
|
18
|
+
gatewayUrl: process.env.SUPERSESSION_GATEWAY_URL ?? parsed.gatewayUrl ?? DEFAULT_GATEWAY,
|
|
19
|
+
token: process.env.SUPERSESSION_TOKEN ?? parsed.token,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return {
|
|
24
|
+
gatewayUrl: process.env.SUPERSESSION_GATEWAY_URL ?? DEFAULT_GATEWAY,
|
|
25
|
+
token: process.env.SUPERSESSION_TOKEN,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function saveConfig(cfg) {
|
|
30
|
+
const dir = join(homedir(), ".supersession");
|
|
31
|
+
mkdirSync(dir, { recursive: true });
|
|
32
|
+
const path = configPath();
|
|
33
|
+
writeFileSync(path, JSON.stringify(cfg, null, 2), "utf8");
|
|
34
|
+
chmodSync(path, 0o600);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAOjC,oFAAoF;AACpF,MAAM,eAAe,GAAG,4CAA4C,CAAC;AAErE,SAAS,UAAU;IACjB,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,eAAe,EAAE,aAAa,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,UAAU,EAAE,EAAE,MAAM,CAAC,CAAC;QAC/C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAoB,CAAC;QAClD,OAAO;YACL,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,MAAM,CAAC,UAAU,IAAI,eAAe;YACxF,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,MAAM,CAAC,KAAK;SACtD,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;YACL,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB,IAAI,eAAe;YACnE,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB;SAC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