@letsrebase/verify 0.0.0-stage → 0.1.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.
- package/.claude/commands/rebase-verify.md +118 -0
- package/LICENSE +21 -0
- package/PRIVACY.md +113 -0
- package/README.md +209 -2
- package/SECURITY.md +33 -0
- package/bin/rebase-verify.mjs +699 -0
- package/package.json +38 -4
- package/share/practices.json +224 -0
- package/share/tech-labels.json +57 -0
- package/share/tech-lexicon.json +62 -0
- package/src/adapters/claude-code.mjs +225 -0
- package/src/adapters/codex.mjs +476 -0
- package/src/adapters/cursor.mjs +584 -0
- package/src/adapters/kimi.mjs +594 -0
- package/src/adapters/omp.mjs +59 -0
- package/src/adapters/opencode.mjs +439 -0
- package/src/adapters/pi.mjs +414 -0
- package/src/adapters/tool-vocab.mjs +15 -0
- package/src/agent-run.mjs +10 -0
- package/src/agentic-literacy.mjs +211 -0
- package/src/agents/acp.mjs +364 -0
- package/src/agents/json-answer.mjs +72 -0
- package/src/agents/registry.mjs +370 -0
- package/src/agents/run.mjs +131 -0
- package/src/ai-relationship.mjs +95 -0
- package/src/consistency.mjs +357 -0
- package/src/days.mjs +45 -0
- package/src/digest.mjs +501 -0
- package/src/distribution.mjs +54 -0
- package/src/enrich.mjs +118 -0
- package/src/fingerprint.mjs +134 -0
- package/src/forensics.mjs +178 -0
- package/src/groundedness.mjs +347 -0
- package/src/hub.mjs +136 -0
- package/src/intensity.mjs +132 -0
- package/src/live-status.mjs +79 -0
- package/src/practices-llm.mjs +90 -0
- package/src/practices-rules.mjs +295 -0
- package/src/practices-sample.mjs +111 -0
- package/src/practices.mjs +272 -0
- package/src/profile-llm.mjs +249 -0
- package/src/profile.mjs +497 -0
- package/src/redact.mjs +97 -0
- package/src/sources.mjs +91 -0
- package/src/submit.mjs +65 -0
- package/src/system-text.mjs +3 -0
- package/src/tech-usage.mjs +88 -0
- package/src/trajectory.mjs +264 -0
- package/src/wizard.mjs +411 -0
package/src/wizard.mjs
ADDED
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
// The interactive path of `npx @letsrebase/verify`: read the sources, choose an
|
|
2
|
+
// agent and a model, consent, run, show the profile, offer to submit. It holds
|
|
3
|
+
// decisions and copy only; every step that touches the logs, the agents or
|
|
4
|
+
// the disk is injected, and the bin passes the same functions the sub-commands
|
|
5
|
+
// use. `ui` is the @clack/prompts surface.
|
|
6
|
+
import { rmSync } from "node:fs";
|
|
7
|
+
import { basename, join } from "node:path";
|
|
8
|
+
import { AGENT_RUN_MARKER } from "./agent-run.mjs";
|
|
9
|
+
import { spawnSync } from "node:child_process";
|
|
10
|
+
import { AgentAuthError, AgentStartError, ModelNotOfferedError, ToolUseError } from "./agents/acp.mjs";
|
|
11
|
+
import { RUN_SYSTEM } from "./agents/run.mjs";
|
|
12
|
+
|
|
13
|
+
const REDRAW_MS = 100;
|
|
14
|
+
const tick = () => new Promise((r) => setImmediate(r));
|
|
15
|
+
const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
16
|
+
const kilo = (n) => (n >= 1000 ? `${(n / 1000).toFixed(1)}k` : String(n));
|
|
17
|
+
|
|
18
|
+
function money(c) {
|
|
19
|
+
const amount = Number(c?.amount);
|
|
20
|
+
if (!Number.isFinite(amount)) return null;
|
|
21
|
+
return c.currency === "USD" || !c.currency ? `$${amount.toFixed(2)}` : `${amount.toFixed(2)} ${c.currency}`;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The spinner message for a step and what the event stream has reported so far. */
|
|
25
|
+
export function statusLine(status, { chars = 0, tokens = null, cost = null } = {}) {
|
|
26
|
+
const parts = [];
|
|
27
|
+
if (status.step === "narrative") parts.push("Writing the narrative", `${kilo(chars)} chars`);
|
|
28
|
+
else parts.push("Classifying practices", `batch ${status.batch} of ${status.total}${status.retry ? " (again)" : ""}`);
|
|
29
|
+
if (tokens != null) parts.push(`${kilo(tokens)} tokens`);
|
|
30
|
+
const m = cost ? money(cost) : null;
|
|
31
|
+
if (m) parts.push(m);
|
|
32
|
+
return parts.join(" · ");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const downloadNote = (agent) => `Downloads ${agent.download} from npm with npx.`;
|
|
36
|
+
|
|
37
|
+
/** What the person agrees to, in the words of the agent that will run. */
|
|
38
|
+
export function consentText(agent) {
|
|
39
|
+
const lines = [];
|
|
40
|
+
if (agent.kind === "api") {
|
|
41
|
+
lines.push(`These go to the Anthropic API with your key:`);
|
|
42
|
+
} else {
|
|
43
|
+
lines.push(`These go to ${agent.label} and to its model provider:`);
|
|
44
|
+
}
|
|
45
|
+
lines.push(
|
|
46
|
+
`- the narrative input: project labels, README and CLAUDE.md excerpts, lines you added to CLAUDE.md or README over time, dependency names, commit subjects, sampled prompts, topics you researched and up to six compaction summaries;`,
|
|
47
|
+
`- up to 60 sessions × 12 of your own messages, redacted, so the practices can be classified.`,
|
|
48
|
+
``,
|
|
49
|
+
`rebase receives nothing until you choose to submit.`,
|
|
50
|
+
);
|
|
51
|
+
if (agent.download) lines.push(downloadNote(agent));
|
|
52
|
+
if (agent.kind !== "api") lines.push(`A local log of the exchange is written to out/agent-log.jsonl.`);
|
|
53
|
+
if (agent.kind === "api") {
|
|
54
|
+
lines.push(
|
|
55
|
+
`No tools are involved: it is a plain request.`,
|
|
56
|
+
`To stay fully local until submit, stop here, unset ANTHROPIC_API_KEY and use the /rebase-verify slash command instead.`,
|
|
57
|
+
);
|
|
58
|
+
} else if (agent.id === "omp" || agent.id === "claude-code") {
|
|
59
|
+
lines.push(`${agent.label} starts with its tools switched off, and the run stops if it tries to use one.`);
|
|
60
|
+
} else if (agent.id === "codex") {
|
|
61
|
+
lines.push(`${agent.label} runs read-only with an instruction not to use tools, and the run stops if it tries to use one.`);
|
|
62
|
+
} else {
|
|
63
|
+
lines.push(`Whether ${agent.label} lets us switch its tools off is not known. The run stops if it tries to use one, and nothing it wrote is kept.`);
|
|
64
|
+
}
|
|
65
|
+
if (agent.id === "omp" || agent.id === "codex") {
|
|
66
|
+
lines.push(`${agent.label} keeps a transcript of the run; rebase-verify removes it afterwards and never reads it.`);
|
|
67
|
+
}
|
|
68
|
+
return lines.join("\n");
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** The one-line reason the wizard cannot take these flags, or null. They belong to a sub-command. */
|
|
72
|
+
export function rejectedFlags(has) {
|
|
73
|
+
const bad = ["narrative-file", "dry-run"].filter((f) => has(f));
|
|
74
|
+
return bad.length ? `${bad.map((f) => `--${f}`).join(" and ")} ${bad.length > 1 ? "need" : "needs"} a sub-command (generate, finalize or submit); the wizard does not use ${bad.length > 1 ? "them" : "it"}.` : null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Last resort when the process is going down while an agent is alive: the agent runs in its
|
|
78
|
+
// own process group, which a dying parent does not take with it.
|
|
79
|
+
function killGroup(pid) {
|
|
80
|
+
if (!pid) return;
|
|
81
|
+
if (process.platform === "win32") spawnSync("taskkill", ["/pid", String(pid), "/T", "/F"], { windowsHide: true });
|
|
82
|
+
else {
|
|
83
|
+
try {
|
|
84
|
+
process.kill(-pid, "SIGKILL");
|
|
85
|
+
} catch {
|
|
86
|
+
// already gone
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const NO_AGENT_NOTE = [
|
|
92
|
+
`rebase-verify writes your profile with a coding agent you already use,`,
|
|
93
|
+
`and none was found on this machine (and no ANTHROPIC_API_KEY is set).`,
|
|
94
|
+
``,
|
|
95
|
+
`Two ways forward:`,
|
|
96
|
+
`1. Install one of the tested agents, then run this again:`,
|
|
97
|
+
` - oh-my-pi (omp): install omp from https://github.com/can1357/oh-my-pi`,
|
|
98
|
+
` - Claude Code: install Claude Code from https://claude.com/claude-code`,
|
|
99
|
+
` - Codex: install Codex from https://github.com/openai/codex`,
|
|
100
|
+
`2. Or use the /rebase-verify slash command from a clone of the repository,`,
|
|
101
|
+
` inside the agent you use.`,
|
|
102
|
+
].join("\n");
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* @param {object} p
|
|
106
|
+
* @param {object} p.ui clack: intro, outro, cancel, note, log, spinner, multiselect, select, confirm, isCancel
|
|
107
|
+
* @param {object} p.deps sources, readSource, combine, availableAgents, defaultAgent, prepare,
|
|
108
|
+
* startAgent, runWithAgent, finish, submit
|
|
109
|
+
* @param {{ version?: string, agent?: string, model?: string }} p.flags
|
|
110
|
+
* @returns {Promise<number>} the process exit code
|
|
111
|
+
*/
|
|
112
|
+
export async function runWizard({ ui, deps, flags = {}, out, proc = process, now = Date.now }) {
|
|
113
|
+
const ctl = new AbortController();
|
|
114
|
+
const stop = () => ctl.abort();
|
|
115
|
+
const kill = deps.killGroup ?? killGroup;
|
|
116
|
+
// only ever a run dir of ours
|
|
117
|
+
const removeDir = deps.removeDir ?? ((d) => basename(d).startsWith(AGENT_RUN_MARKER) && rmSync(d, { recursive: true, force: true }));
|
|
118
|
+
let agent = null;
|
|
119
|
+
let session = null;
|
|
120
|
+
let runDir = null;
|
|
121
|
+
let pid = null;
|
|
122
|
+
let sessionHandedOver = false;
|
|
123
|
+
let chosenModel;
|
|
124
|
+
|
|
125
|
+
// Closes an agent the wizard still owns, then removes the transcript its session left
|
|
126
|
+
// (best effort). Once the run has the session, the run does both itself.
|
|
127
|
+
const closeSession = async () => {
|
|
128
|
+
if (sessionHandedOver) return;
|
|
129
|
+
try {
|
|
130
|
+
await session?.close();
|
|
131
|
+
} catch {
|
|
132
|
+
// the run's own outcome stays
|
|
133
|
+
}
|
|
134
|
+
session = null;
|
|
135
|
+
if (runDir && agent?.cleanup) {
|
|
136
|
+
try {
|
|
137
|
+
agent.cleanup(runDir);
|
|
138
|
+
} catch {
|
|
139
|
+
// a cleanup that cannot run must not hide the outcome
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
runDir = null;
|
|
143
|
+
};
|
|
144
|
+
// The process is exiting while an agent may be alive (a signal the wizard did not see,
|
|
145
|
+
// an uncaught error): kill its group, remove the run dir and its transcript, synchronously.
|
|
146
|
+
const onExit = () => {
|
|
147
|
+
proc.stdout?.write?.("\x1b[?25h");
|
|
148
|
+
kill(pid);
|
|
149
|
+
if (runDir) {
|
|
150
|
+
try {
|
|
151
|
+
removeDir(runDir);
|
|
152
|
+
} catch {}
|
|
153
|
+
try {
|
|
154
|
+
agent?.cleanup?.(runDir);
|
|
155
|
+
} catch {}
|
|
156
|
+
}
|
|
157
|
+
if (!proc.exitCode) proc.exitCode = 130;
|
|
158
|
+
};
|
|
159
|
+
const cancelled = async (v) => {
|
|
160
|
+
if (!ui.isCancel(v)) return false;
|
|
161
|
+
await closeSession();
|
|
162
|
+
ui.cancel("Stopped. Nothing was sent.");
|
|
163
|
+
return true;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
ui.intro(`rebase-verify${flags.version ? ` ${flags.version}` : ""}`);
|
|
167
|
+
|
|
168
|
+
// 1. Sources, one spinner each so the counts appear as they finish.
|
|
169
|
+
const found = [];
|
|
170
|
+
for (const src of deps.sources) {
|
|
171
|
+
const s = ui.spinner();
|
|
172
|
+
s.start(`Reading ${src.label}`);
|
|
173
|
+
await tick();
|
|
174
|
+
let bundle = null;
|
|
175
|
+
try {
|
|
176
|
+
bundle = deps.readSource(src.id);
|
|
177
|
+
} catch {
|
|
178
|
+
bundle = null;
|
|
179
|
+
}
|
|
180
|
+
const n = bundle?.sessions?.length ?? 0;
|
|
181
|
+
s.stop(bundle ? `${src.label}: ${plural(n, "session")}` : `${src.label}: could not be read`);
|
|
182
|
+
if (n > 0) found.push({ ...src, bundle, count: n });
|
|
183
|
+
}
|
|
184
|
+
if (!found.length) {
|
|
185
|
+
ui.cancel("No sessions found in your logs, so there is nothing to build a profile from. Nothing was sent.");
|
|
186
|
+
return 1;
|
|
187
|
+
}
|
|
188
|
+
const chosen = await ui.multiselect({
|
|
189
|
+
message: "Which sources should the profile be built from?",
|
|
190
|
+
options: found.map((f) => ({ value: f.id, label: f.label, hint: plural(f.count, "session") })),
|
|
191
|
+
initialValues: found.map((f) => f.id),
|
|
192
|
+
required: true,
|
|
193
|
+
});
|
|
194
|
+
if (await cancelled(chosen)) return 130;
|
|
195
|
+
const picked = found.filter((f) => chosen.includes(f.id));
|
|
196
|
+
|
|
197
|
+
// 2. The profile inputs, from the chosen sources only.
|
|
198
|
+
const sessionsBySource = Object.fromEntries(found.map((f) => [f.id, f.count]));
|
|
199
|
+
const ps = ui.spinner();
|
|
200
|
+
ps.start("Building your profile from the logs");
|
|
201
|
+
await tick();
|
|
202
|
+
let prepared;
|
|
203
|
+
try {
|
|
204
|
+
prepared = deps.prepare(deps.combine(picked.map((f) => f.bundle)));
|
|
205
|
+
} catch (e) {
|
|
206
|
+
ps.error(`Could not build the profile: ${e.message}`);
|
|
207
|
+
return 1;
|
|
208
|
+
}
|
|
209
|
+
ps.stop("Profile inputs ready");
|
|
210
|
+
|
|
211
|
+
// 3. Agent.
|
|
212
|
+
const agents = deps.availableAgents(sessionsBySource);
|
|
213
|
+
if (!agents.length) {
|
|
214
|
+
ui.note(NO_AGENT_NOTE, "No coding agent found");
|
|
215
|
+
ui.cancel("Nothing was written or sent.");
|
|
216
|
+
return 1;
|
|
217
|
+
}
|
|
218
|
+
if (flags.agent) {
|
|
219
|
+
agent = agents.find((a) => a.id === flags.agent);
|
|
220
|
+
if (!agent) {
|
|
221
|
+
ui.log.error(`Agent "${flags.agent}" is not installed. Found: ${agents.map((a) => a.id).join(", ")}.`);
|
|
222
|
+
return 2;
|
|
223
|
+
}
|
|
224
|
+
} else {
|
|
225
|
+
const first = deps.defaultAgent(agents);
|
|
226
|
+
const id = await ui.select({
|
|
227
|
+
message: "Which agent should write your profile?",
|
|
228
|
+
options: agents.map((a) => ({
|
|
229
|
+
value: a.id,
|
|
230
|
+
label: a.label,
|
|
231
|
+
hint: `${plural(a.sessions, "session")} in your logs · ${a.tested ? "tested" : "not tested"}${a.download ? ` · ${downloadNote(a).replace(/\.$/, "")}` : ""}`,
|
|
232
|
+
})),
|
|
233
|
+
initialValue: first.id,
|
|
234
|
+
});
|
|
235
|
+
if (await cancelled(id)) return 130;
|
|
236
|
+
agent = agents.find((a) => a.id === id);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// The agent is started once: its models are read from the session the run then uses.
|
|
240
|
+
const fail = async (e) => {
|
|
241
|
+
await closeSession();
|
|
242
|
+
if (e?.name === "AbortError" || ctl.signal.aborted) {
|
|
243
|
+
ui.cancel("Stopped. Nothing was sent.");
|
|
244
|
+
return 130;
|
|
245
|
+
}
|
|
246
|
+
if (e instanceof AgentAuthError) ui.log.error(`${agent.label} is not logged in: ${agent.loginHint}.`);
|
|
247
|
+
else if (e instanceof ToolUseError) ui.log.error("The agent tried to use a tool; nothing it wrote was kept.");
|
|
248
|
+
else if (e instanceof ModelNotOfferedError) ui.log.error(`${agent.label} does not offer model "${chosenModel ?? flags.model}"${e.offered?.length ? `. It offers: ${e.offered.join(", ")}` : ""}.`);
|
|
249
|
+
else if (e instanceof AgentStartError) ui.log.error(`${e.message}.`);
|
|
250
|
+
else ui.log.error(e?.message ?? String(e));
|
|
251
|
+
ui.cancel("Nothing was sent.");
|
|
252
|
+
return 2;
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
const live = { chars: 0, tokens: null, cost: null };
|
|
256
|
+
let paint = () => {};
|
|
257
|
+
const onEvent = (e) => {
|
|
258
|
+
if (e.kind === "started") {
|
|
259
|
+
runDir = e.cwd;
|
|
260
|
+
pid = e.pid ?? null;
|
|
261
|
+
}
|
|
262
|
+
else if (e.kind === "turn-start") live.chars = 0;
|
|
263
|
+
else if (e.kind === "agent_message_chunk" && e.content?.type === "text") live.chars += e.content.text.length;
|
|
264
|
+
else if (e.kind === "usage_update") {
|
|
265
|
+
if (Number.isFinite(e.used)) live.tokens = e.used;
|
|
266
|
+
if (e.cost) live.cost = e.cost;
|
|
267
|
+
} else return;
|
|
268
|
+
paint();
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
proc.on("SIGINT", stop);
|
|
272
|
+
proc.on("SIGTERM", stop);
|
|
273
|
+
proc.on("SIGHUP", stop);
|
|
274
|
+
try {
|
|
275
|
+
let model;
|
|
276
|
+
if (agent.kind === "api") {
|
|
277
|
+
model = flags.model;
|
|
278
|
+
} else {
|
|
279
|
+
const s = ui.live({ onCancel: stop });
|
|
280
|
+
s.start(`Starting ${agent.label}`);
|
|
281
|
+
proc.on("exit", onExit);
|
|
282
|
+
try {
|
|
283
|
+
session = await deps.startAgent(agent.spec({ system: RUN_SYSTEM }), { logFile: `${out}/agent-log.jsonl`, signal: ctl.signal, onEvent });
|
|
284
|
+
} catch (e) {
|
|
285
|
+
s.error(`Could not start ${agent.label}`);
|
|
286
|
+
return await fail(e);
|
|
287
|
+
}
|
|
288
|
+
s.stop(`${agent.label} is ready`);
|
|
289
|
+
const models = session.models ?? [];
|
|
290
|
+
if (flags.model) {
|
|
291
|
+
chosenModel = flags.model;
|
|
292
|
+
if (!models.some((m) => m.id === flags.model)) return await fail(Object.assign(new ModelNotOfferedError(flags.model), { offered: models.map((m) => m.id) }));
|
|
293
|
+
model = flags.model;
|
|
294
|
+
} else if (models.length) {
|
|
295
|
+
const names = models.map((o) => o.name ?? o.id);
|
|
296
|
+
const m = await ui.select({
|
|
297
|
+
message: "Which model?",
|
|
298
|
+
options: models.map((o, i) => {
|
|
299
|
+
const dup = names.filter((n) => n === names[i]).length > 1;
|
|
300
|
+
const hint = [o.id === session.currentModel ? "current" : null, dup ? o.id : null].filter(Boolean).join(" · ");
|
|
301
|
+
return { value: o.id, label: names[i], hint: hint || undefined };
|
|
302
|
+
}),
|
|
303
|
+
initialValue: session.currentModel ?? models[0].id,
|
|
304
|
+
});
|
|
305
|
+
if (await cancelled(m)) return 130;
|
|
306
|
+
model = m;
|
|
307
|
+
chosenModel = m;
|
|
308
|
+
} else {
|
|
309
|
+
ui.log.info(`${agent.label} offers no model choice: its default model will be used.`);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// 4. Consent.
|
|
314
|
+
ui.note(consentText(agent), "Before anything is sent");
|
|
315
|
+
const ok = await ui.confirm({ message: `Send this to ${agent.label} and continue?`, initialValue: true });
|
|
316
|
+
if (await cancelled(ok)) return 130;
|
|
317
|
+
if (!ok) {
|
|
318
|
+
await closeSession();
|
|
319
|
+
ui.cancel("Stopped. Nothing was written or sent.");
|
|
320
|
+
return 0;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// 5. The run, with live status.
|
|
324
|
+
const spin = ui.live({ onCancel: stop });
|
|
325
|
+
spin.start(`Starting the run with ${agent.label}`);
|
|
326
|
+
let status = { step: "narrative" };
|
|
327
|
+
let last = -Infinity;
|
|
328
|
+
paint = () => {
|
|
329
|
+
const t = now();
|
|
330
|
+
if (t - last < REDRAW_MS) return;
|
|
331
|
+
last = t;
|
|
332
|
+
spin.message(statusLine(status, live));
|
|
333
|
+
};
|
|
334
|
+
let result;
|
|
335
|
+
try {
|
|
336
|
+
sessionHandedOver = true;
|
|
337
|
+
result = await deps.runWithAgent({
|
|
338
|
+
agent,
|
|
339
|
+
model,
|
|
340
|
+
narrativeInput: prepared.narrativeInput,
|
|
341
|
+
practicesInput: prepared.practicesInput,
|
|
342
|
+
logFile: `${out}/agent-log.jsonl`,
|
|
343
|
+
signal: ctl.signal,
|
|
344
|
+
warn: () => {},
|
|
345
|
+
session: session ?? undefined,
|
|
346
|
+
runDir: runDir ?? undefined,
|
|
347
|
+
onStatus: (s) => {
|
|
348
|
+
status = s;
|
|
349
|
+
live.chars = 0;
|
|
350
|
+
last = -Infinity;
|
|
351
|
+
paint();
|
|
352
|
+
},
|
|
353
|
+
});
|
|
354
|
+
} catch (e) {
|
|
355
|
+
spin.error(ctl.signal.aborted || e?.name === "AbortError" ? "Stopped" : `${agent.label} could not finish`);
|
|
356
|
+
return await fail(e);
|
|
357
|
+
} finally {
|
|
358
|
+
// the run has closed the agent and removed what it left: nothing for the exit net to do
|
|
359
|
+
proc.off("exit", onExit);
|
|
360
|
+
// from here on Ctrl-C belongs to whatever comes next (the sign-in wait of submit)
|
|
361
|
+
proc.off("SIGINT", stop);
|
|
362
|
+
proc.off("SIGTERM", stop);
|
|
363
|
+
proc.off("SIGHUP", stop);
|
|
364
|
+
}
|
|
365
|
+
spin.stop("The narrative and the practices are ready");
|
|
366
|
+
session = null;
|
|
367
|
+
|
|
368
|
+
// 6. The profile.
|
|
369
|
+
const done = deps.finish(prepared, result);
|
|
370
|
+
const rows = (done.practices ?? []).map((p) => ` ${p.id}: seen in ${p.seen} of ${p.of}`);
|
|
371
|
+
ui.note(
|
|
372
|
+
[
|
|
373
|
+
`${plural(done.sessions, "session")} read, ${plural(done.products, "product")}.`,
|
|
374
|
+
...(done.summary ? [``, done.summary] : []),
|
|
375
|
+
...(rows.length ? [``, `How the work is done (sessions where it was seen):`, ...rows] : []),
|
|
376
|
+
``,
|
|
377
|
+
`Read the full profile: ${join(out, "profile.md")}`,
|
|
378
|
+
].join("\n"),
|
|
379
|
+
"Your profile",
|
|
380
|
+
);
|
|
381
|
+
let next;
|
|
382
|
+
for (;;) {
|
|
383
|
+
next = await ui.select({
|
|
384
|
+
message: "What next?",
|
|
385
|
+
options: [
|
|
386
|
+
{ value: "submit", label: "Send it to rebase now" },
|
|
387
|
+
{ value: "exit", label: "Exit", hint: "send later with: npx @letsrebase/verify submit --yes" },
|
|
388
|
+
],
|
|
389
|
+
initialValue: "exit",
|
|
390
|
+
});
|
|
391
|
+
if (await cancelled(next)) return 130;
|
|
392
|
+
if (next !== "submit") break;
|
|
393
|
+
const read = await ui.confirm({ message: "Have you read out/profile.md? It is what rebase will see.", initialValue: false });
|
|
394
|
+
if (await cancelled(read)) return 130;
|
|
395
|
+
if (read) break;
|
|
396
|
+
}
|
|
397
|
+
if (next === "submit") {
|
|
398
|
+
await deps.submit();
|
|
399
|
+
ui.outro("Sent.");
|
|
400
|
+
} else {
|
|
401
|
+
ui.outro("Done. Nothing was sent.");
|
|
402
|
+
}
|
|
403
|
+
return 0;
|
|
404
|
+
} finally {
|
|
405
|
+
await closeSession();
|
|
406
|
+
proc.off("SIGINT", stop);
|
|
407
|
+
proc.off("SIGTERM", stop);
|
|
408
|
+
proc.off("SIGHUP", stop);
|
|
409
|
+
proc.off("exit", onExit);
|
|
410
|
+
}
|
|
411
|
+
}
|