@letsrebase/verify 0.1.3 → 0.2.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/.claude/commands/rebase-verify.md +2 -1
- package/README.md +3 -3
- package/bin/rebase-verify.mjs +109 -212
- package/package.json +1 -1
- package/src/adapters/claude-code.mjs +4 -2
- package/src/adapters/codex.mjs +4 -2
- package/src/adapters/omp.mjs +2 -2
- package/src/adapters/pi.mjs +6 -5
- package/src/agents/run.mjs +2 -2
- package/src/groundedness.mjs +28 -6
- package/src/hub.mjs +31 -28
- package/src/languages.mjs +250 -0
- package/src/pipeline-client.mjs +56 -0
- package/src/pipeline-worker.mjs +96 -0
- package/src/pipeline.mjs +194 -0
- package/src/profile-llm.mjs +15 -8
- package/src/profile.mjs +80 -89
- package/src/sources.mjs +9 -7
- package/src/submit.mjs +27 -5
- package/src/wizard.mjs +40 -32
package/src/submit.mjs
CHANGED
|
@@ -28,24 +28,46 @@ export function buildPayload(profile) {
|
|
|
28
28
|
return payload;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
//
|
|
32
|
-
|
|
31
|
+
// What the person is told before anything is sent: who receives it, what it holds, what a person at
|
|
32
|
+
// rebase does with it, how long it is kept, what never leaves the machine. One text for the
|
|
33
|
+
// sub-command and for the wizard, so the screen before the last question is the same in both.
|
|
34
|
+
export function sendNotice({ hub, profile, cmd }) {
|
|
35
|
+
const links = (profile.projects || []).filter((p) => p.artifact).length;
|
|
36
|
+
return [
|
|
37
|
+
`About to send to rebase (${hub}):`,
|
|
38
|
+
` profile: ${profile.volume?.sessions} sessions, ${profile.volume?.products} products`,
|
|
39
|
+
` artifact links: ${links}`,
|
|
40
|
+
``,
|
|
41
|
+
`You sign in in the browser first, so rebase knows it is you; no name, email or city is sent with the profile.`,
|
|
42
|
+
`A person at rebase reads it before it counts. If they approve it, your profile gets «Verificato da rebase»,`,
|
|
43
|
+
`companies rebase works with can see its summary, its domains of work and the sectors of its representative projects, next to your name and your card (written by your model, reviewed by you), for example in the talent cloud or when rebase proposes you for a project, and its text is used to write your anonymous card.`,
|
|
44
|
+
`It is kept at most 12 months, and you can delete it from your member area.`,
|
|
45
|
+
`Controller: Rebase S.r.l. (VAT IT 14971460960). Details: https://letsrebase.com/privacy and PRIVACY.md.`,
|
|
46
|
+
`NOT sent: raw logs, local repo context, third-party proper names.`,
|
|
47
|
+
`Repository names (repoLabel) are stripped from the payload before it leaves your machine.`,
|
|
48
|
+
`Inspect the exact outgoing payload: ${cmd} submit --dry-run`,
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Signs in, then posts. `fetchFn`, `open`, `sleep` and `log` are injectable; `around(label, fn)`
|
|
53
|
+
// wraps each wait (the sign-in code, the approval in the browser, the upload) so a caller can show it.
|
|
54
|
+
export async function submitProfile(profilePath, { hub, fetchFn = fetch, around = (_label, fn) => fn(), ...flow } = {}) {
|
|
33
55
|
if (!existsSync(profilePath)) throw new Error(`profile not found: ${profilePath}`);
|
|
34
56
|
// Refuse before signing in: no point asking for a browser round trip for a payload the hub would reject.
|
|
35
57
|
const payload = buildPayload(JSON.parse(readFileSync(profilePath, "utf8")));
|
|
36
58
|
|
|
37
59
|
const base = resolveHub(hub);
|
|
38
|
-
const token = await signIn(base, { fetchFn, ...flow });
|
|
60
|
+
const token = await signIn(base, { fetchFn, around, ...flow });
|
|
39
61
|
|
|
40
62
|
const form = new FormData();
|
|
41
63
|
form.append("profile", new Blob([JSON.stringify(payload)], { type: "application/json" }), "candidate.json");
|
|
42
64
|
let res;
|
|
43
65
|
try {
|
|
44
|
-
res = await fetchFn(`${base}/api/hub/work-profiles`, {
|
|
66
|
+
res = await around("Sending your profile to rebase", () => fetchFn(`${base}/api/hub/work-profiles`, {
|
|
45
67
|
method: "POST",
|
|
46
68
|
headers: { authorization: `Bearer ${token}`, "user-agent": USER_AGENT },
|
|
47
69
|
body: form,
|
|
48
|
-
});
|
|
70
|
+
}));
|
|
49
71
|
} catch (e) {
|
|
50
72
|
throw new Error(`could not reach the hub to send the profile (${e.message}). The sign-in is spent by the first attempt, so run submit again and sign in anew.`);
|
|
51
73
|
}
|
package/src/wizard.mjs
CHANGED
|
@@ -11,7 +11,6 @@ import { AgentAuthError, AgentStartError, ModelNotOfferedError, ToolUseError } f
|
|
|
11
11
|
import { RUN_SYSTEM } from "./agents/run.mjs";
|
|
12
12
|
|
|
13
13
|
const REDRAW_MS = 100;
|
|
14
|
-
const tick = () => new Promise((r) => setImmediate(r));
|
|
15
14
|
const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
16
15
|
const kilo = (n) => (n >= 1000 ? `${(n / 1000).toFixed(1)}k` : String(n));
|
|
17
16
|
|
|
@@ -104,8 +103,11 @@ const NO_AGENT_NOTE = [
|
|
|
104
103
|
/**
|
|
105
104
|
* @param {object} p
|
|
106
105
|
* @param {object} p.ui clack: intro, outro, cancel, note, log, spinner, multiselect, select, confirm, isCancel
|
|
107
|
-
* @param {object} p.deps sources,
|
|
108
|
-
*
|
|
106
|
+
* @param {object} p.deps sources, availableAgents, defaultAgent, startAgent, runWithAgent, submit,
|
|
107
|
+
* sendNotice() -> the text of the screen shown before the question about sending, and the
|
|
108
|
+
* steps that read and compute, all async so the spinner keeps moving while they work:
|
|
109
|
+
* readSource(id, { onProgress }) -> { sessions } | null, prepare(ids, { onStep }) -> { narrativeInput, practicesInput },
|
|
110
|
+
* finish(run, { onStep }) -> { sessions, products, practices, summary }
|
|
109
111
|
* @param {{ version?: string, agent?: string, model?: string }} p.flags
|
|
110
112
|
* @returns {Promise<number>} the process exit code
|
|
111
113
|
*/
|
|
@@ -165,21 +167,23 @@ export async function runWizard({ ui, deps, flags = {}, out, proc = process, now
|
|
|
165
167
|
|
|
166
168
|
ui.intro(`rebase-verify${flags.version ? ` ${flags.version}` : ""}`);
|
|
167
169
|
|
|
168
|
-
// 1. Sources, one spinner each so the counts appear as they finish.
|
|
170
|
+
// 1. Sources, one spinner each so the counts appear as they finish. The reading runs off the
|
|
171
|
+
// main thread (deps.readSource is async), so the spinner keeps moving and shows the files so far.
|
|
169
172
|
const found = [];
|
|
170
173
|
for (const src of deps.sources) {
|
|
171
174
|
const s = ui.spinner();
|
|
172
175
|
s.start(`Reading ${src.label}`);
|
|
173
|
-
|
|
174
|
-
let bundle = null;
|
|
176
|
+
let read = null;
|
|
175
177
|
try {
|
|
176
|
-
|
|
178
|
+
read = await deps.readSource(src.id, {
|
|
179
|
+
onProgress: ({ done, total }) => s.message(`Reading ${src.label} (${done} of ${plural(total, "file")})`),
|
|
180
|
+
});
|
|
177
181
|
} catch {
|
|
178
|
-
|
|
182
|
+
read = null;
|
|
179
183
|
}
|
|
180
|
-
const n =
|
|
181
|
-
s.stop(
|
|
182
|
-
if (n > 0) found.push({ ...src,
|
|
184
|
+
const n = read?.sessions ?? 0;
|
|
185
|
+
s.stop(read ? `${src.label}: ${plural(n, "session")}` : `${src.label}: could not be read`);
|
|
186
|
+
if (n > 0) found.push({ ...src, count: n });
|
|
183
187
|
}
|
|
184
188
|
if (!found.length) {
|
|
185
189
|
ui.cancel("No sessions found in your logs, so there is nothing to build a profile from. Nothing was sent.");
|
|
@@ -198,10 +202,9 @@ export async function runWizard({ ui, deps, flags = {}, out, proc = process, now
|
|
|
198
202
|
const sessionsBySource = Object.fromEntries(found.map((f) => [f.id, f.count]));
|
|
199
203
|
const ps = ui.spinner();
|
|
200
204
|
ps.start("Building your profile from the logs");
|
|
201
|
-
await tick();
|
|
202
205
|
let prepared;
|
|
203
206
|
try {
|
|
204
|
-
prepared = deps.prepare(
|
|
207
|
+
prepared = await deps.prepare(picked.map((f) => f.id), { onStep: (m) => ps.message(`Building your profile: ${m.toLowerCase()}`) });
|
|
205
208
|
} catch (e) {
|
|
206
209
|
ps.error(`Could not build the profile: ${e.message}`);
|
|
207
210
|
return 1;
|
|
@@ -366,7 +369,16 @@ export async function runWizard({ ui, deps, flags = {}, out, proc = process, now
|
|
|
366
369
|
session = null;
|
|
367
370
|
|
|
368
371
|
// 6. The profile.
|
|
369
|
-
const
|
|
372
|
+
const assembling = ui.spinner();
|
|
373
|
+
assembling.start("Assembling your profile");
|
|
374
|
+
let done;
|
|
375
|
+
try {
|
|
376
|
+
done = await deps.finish(result, { onStep: (m) => assembling.message(`Assembling your profile: ${m.toLowerCase()}`) });
|
|
377
|
+
} catch (e) {
|
|
378
|
+
assembling.error("Could not assemble your profile");
|
|
379
|
+
return await fail(e);
|
|
380
|
+
}
|
|
381
|
+
assembling.stop("Your profile is ready");
|
|
370
382
|
const rows = (done.practices ?? []).map((p) => ` ${p.id}: seen in ${p.seen} of ${p.of}`);
|
|
371
383
|
ui.note(
|
|
372
384
|
[
|
|
@@ -378,27 +390,23 @@ export async function runWizard({ ui, deps, flags = {}, out, proc = process, now
|
|
|
378
390
|
].join("\n"),
|
|
379
391
|
"Your profile",
|
|
380
392
|
);
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
if (await cancelled(read)) return 130;
|
|
395
|
-
if (read) break;
|
|
396
|
-
}
|
|
397
|
-
if (next === "submit") {
|
|
393
|
+
// The screen that says who receives what comes first and is never skipped; then one question,
|
|
394
|
+
// whose first and default answer is to send. Anything but that answer (no, Ctrl-C) sends nothing.
|
|
395
|
+
ui.note(deps.sendNotice(), "What leaves your machine, and who receives it");
|
|
396
|
+
const choice = await ui.select({
|
|
397
|
+
message: `Send this profile to rebase? It is what rebase will see (${join(out, "profile.md")}).`,
|
|
398
|
+
options: [
|
|
399
|
+
{ value: "send", label: "Send it to rebase" },
|
|
400
|
+
{ value: "exit", label: "Do not send", hint: "send later with: npx @letsrebase/verify submit --yes" },
|
|
401
|
+
],
|
|
402
|
+
initialValue: "send",
|
|
403
|
+
});
|
|
404
|
+
if (await cancelled(choice)) return 130;
|
|
405
|
+
if (choice === "send") {
|
|
398
406
|
await deps.submit();
|
|
399
407
|
ui.outro("Sent.");
|
|
400
408
|
} else {
|
|
401
|
-
ui.outro("Done. Nothing was sent.");
|
|
409
|
+
ui.outro("Done. Nothing was sent. To send it later: npx @letsrebase/verify submit --yes");
|
|
402
410
|
}
|
|
403
411
|
return 0;
|
|
404
412
|
} finally {
|