@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
|
@@ -16,6 +16,7 @@ The default is **save, don't submit**. Submitting is a separate, explicit action
|
|
|
16
16
|
```
|
|
17
17
|
node bin/rebase-verify.mjs prepare
|
|
18
18
|
```
|
|
19
|
+
The profile is written in Italian unless the candidate asks for another language: then append `--lang <code>` (`it` or `en`). `finalize` reads the language back from `out/narrative-input.json`.
|
|
19
20
|
If the candidate opted into a local timezone in step 1, append `--tz <zone>` here AND to the `finalize` call in step 6. `prepare` and `finalize` must use the same `--tz`: the sampled sessions in `out/practices-sample.json` and every day and month count are bucketed in that zone, and `finalize` re-reads the logs.
|
|
20
21
|
Show the candidate the line `… representative: …` from the output. This is the auto-selection of representative projects, 3 to 5, adaptive: flagships by significance, plus a 4th/5th slot only when a project adds a new primary type or comparable significance. `--top N` forces a fixed count if the candidate asks.
|
|
21
22
|
|
|
@@ -58,7 +59,7 @@ The default is **save, don't submit**. Submitting is a separate, explicit action
|
|
|
58
59
|
- **No proper names.** No companies, clients, people, products, brands, repositories. Describe each project ONLY by abstract domain and context.
|
|
59
60
|
- Use only the data provided in `out/narrative-input.json`. No invention, no hyperbole.
|
|
60
61
|
- Evidence-based: claims supported by signals (areas, stack, landing, prompts, commits).
|
|
61
|
-
-
|
|
62
|
+
- Write every text in the language `out/narrative-input.json` names in `languageName` (its `language` code is `it` for Italian, `en` for English; Italian unless the candidate passed `--lang`). Dry, readable. Technology, product, library and method names stay as written. Write numbers as plain digits exactly as they appear in the data, with no thousands separator. The JSON keys stay as shown. No emojis, no em dashes.
|
|
62
63
|
- Length: summary ≤ 60 words; cognitive narrative ≤ 130 words; learning summary ≤ 40 words; ai_relationship / intensity / distribution narratives ≤ 50 words each; per-project domain ≤ 60 words; per-project `did` ≤ 60 words.
|
|
63
64
|
- Domains rollup: 3-5 entries. Assign every product in `domainEvidence` to exactly one domain; the summed `products` and `sessions` across domains must not exceed the profile totals (groundedness checks this). Labels abstract, counts only, never names.
|
|
64
65
|
|
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ Node 20.12 or newer, one coding agent installed and signed in (or an Anthropic A
|
|
|
18
18
|
npx @letsrebase/verify
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
On a terminal this starts a short wizard. It lists the sources it found in your logs, asks which coding agent should write the narrative and classify the practices (the default is the tested agent with most sessions in your logs, on that agent's current model), shows a consent note, then runs with live progress. It asks nothing about who you are. Two files come out in `out/`: `profile.md` for humans, `candidate.json` for agents (plus working files described under "Work practices" and "Commands"). The wizard ends with a summary and
|
|
21
|
+
On a terminal this starts a short wizard. It lists the sources it found in your logs, asks which coding agent should write the narrative and classify the practices (the default is the tested agent with most sessions in your logs, on that agent's current model), shows a consent note, then runs with live progress. It asks nothing about who you are. Two files come out in `out/`: `profile.md` for humans, `candidate.json` for agents (plus working files described under "Work practices" and "Commands"). The wizard ends with a summary, a screen that says who receives what and for how long, and one question: send (the first option, so Enter sends) or not. Answering no, or pressing Ctrl-C, sends nothing; you can keep the profile for yourself and send it later with `submit --yes`. Every wait shows a spinner that names its step.
|
|
22
22
|
|
|
23
23
|
To submit later:
|
|
24
24
|
|
|
@@ -183,7 +183,7 @@ If you spot something we should change, [open an issue](https://github.com/letsr
|
|
|
183
183
|
|
|
184
184
|
| | |
|
|
185
185
|
|---|---|
|
|
186
|
-
| `npx @letsrebase/verify` | on a terminal, the wizard: finds your sources, lets you pick the agent and the model, writes and classifies the profile, shows a summary, then
|
|
186
|
+
| `npx @letsrebase/verify` | on a terminal, the wizard: finds your sources, lets you pick the agent and the model, writes and classifies the profile, shows a summary and who receives it, then asks once whether to send |
|
|
187
187
|
| `generate --agent <id> --model <id>` | the same without the wizard, for scripts; add `--yes` to skip every prompt |
|
|
188
188
|
| `generate` *(default)* | full profile, locally; with `ANTHROPIC_API_KEY` set, the key sends the practices sample, and the narrative input unless `--narrative-file` is given, to Anthropic |
|
|
189
189
|
| `prepare` | `out/narrative-input.json`, for writing the narrative manually, and `out/practices-input.json` with `out/practices-sample.json` for the model practices; `finalize` must get the same `--tz` |
|
|
@@ -191,7 +191,7 @@ If you spot something we should change, [open an issue](https://github.com/letsr
|
|
|
191
191
|
| `submit --dry-run` | write the exact outgoing payload to `out/payload-preview.json`, send nothing |
|
|
192
192
|
| `submit --yes` | sign in to rebase in the browser, then send the profile; a person at rebase reviews it |
|
|
193
193
|
|
|
194
|
-
All commands run as `node bin/rebase-verify.mjs <sub>` or as `rebase-verify <sub>` after `npm link`. Common flags: `--top N` (force the project count; default is adaptive 3–5), `--root <dir>`, the per-source roots and opt-outs from the Sources table above, `--hub <url>` (where `submit` sends; default `https://letsrebase.com`, also settable with `REBASE_VERIFY_HUB_URL`; `--hub preview` means `https://preview.letsrebase.com`), `--tz <IANA zone>` (bucket the day and month counts (active days, streak, technology-usage months) in your timezone instead of the UTC default; the zone you choose is recorded in the profile, which is also why UTC is the default: a zone names a place, and nothing location-shaped should leave your machine unless you opt in). Without Claude Code, set `ANTHROPIC_API_KEY` and the narrative goes through the API instead of your subscription, note that on this path the narrative input (project labels, README/CLAUDE.md excerpts, dependency names, commit subjects, sampled prompts) is sent to api.anthropic.com under your own key, before any name-stripping; the tool warns when this happens, and an explicit `--narrative-file` always takes precedence over the key. The subscription and manual paths stay fully local until submit. Details in [PRIVACY.md](PRIVACY.md).
|
|
194
|
+
All commands run as `node bin/rebase-verify.mjs <sub>` or as `rebase-verify <sub>` after `npm link`. Common flags: `--top N` (force the project count; default is adaptive 3–5), `--root <dir>`, the per-source roots and opt-outs from the Sources table above, `--hub <url>` (where `submit` sends; default `https://letsrebase.com`, also settable with `REBASE_VERIFY_HUB_URL`; `--hub preview` means `https://preview.letsrebase.com`), `--lang <code>` (the language the profile is written in: `it` Italian, the default, or `en` English; it sets the language of the model-written prose and of `out/profile.md`, and is recorded as `language` in the profile; the enum codes in the payload stay English), `--tz <IANA zone>` (bucket the day and month counts (active days, streak, technology-usage months) in your timezone instead of the UTC default; the zone you choose is recorded in the profile, which is also why UTC is the default: a zone names a place, and nothing location-shaped should leave your machine unless you opt in). Without Claude Code, set `ANTHROPIC_API_KEY` and the narrative goes through the API instead of your subscription, note that on this path the narrative input (project labels, README/CLAUDE.md excerpts, dependency names, commit subjects, sampled prompts) is sent to api.anthropic.com under your own key, before any name-stripping; the tool warns when this happens, and an explicit `--narrative-file` always takes precedence over the key. The subscription and manual paths stay fully local until submit. Details in [PRIVACY.md](PRIVACY.md).
|
|
195
195
|
|
|
196
196
|
## Tests
|
|
197
197
|
|
package/bin/rebase-verify.mjs
CHANGED
|
@@ -39,28 +39,16 @@
|
|
|
39
39
|
import { homedir } from "node:os";
|
|
40
40
|
import { join } from "node:path";
|
|
41
41
|
import { fileURLToPath } from "node:url";
|
|
42
|
-
import { writeFileSync, existsSync, readFileSync,
|
|
43
|
-
import {
|
|
44
|
-
import
|
|
45
|
-
import { computeFingerprint } from "../src/fingerprint.mjs";
|
|
46
|
-
import { computeForensics } from "../src/forensics.mjs";
|
|
47
|
-
import { buildDigest } from "../src/digest.mjs";
|
|
48
|
-
import { practicesFiles } from "../src/practices-sample.mjs";
|
|
42
|
+
import { writeFileSync, existsSync, readFileSync, rmSync } from "node:fs";
|
|
43
|
+
import { SOURCES, readAllSources } from "../src/sources.mjs";
|
|
44
|
+
import * as pipeline from "../src/pipeline.mjs";
|
|
49
45
|
import { PRACTICES_WARN_WHAT, runPracticesStep } from "../src/practices-llm.mjs";
|
|
50
|
-
import { enrichRepo, describeContextGaps } from "../src/enrich.mjs";
|
|
51
46
|
import { MODEL, anthropicCall, generateNarrative, narrativeInputFor, warnApiKey } from "../src/profile-llm.mjs";
|
|
52
|
-
import { selectRepresentatives, assembleProfile, renderMarkdown, summarizeSources } from "../src/profile.mjs";
|
|
53
47
|
import { resolveHub } from "../src/hub.mjs";
|
|
54
|
-
import { submitProfile, buildPayload } from "../src/submit.mjs";
|
|
55
|
-
import {
|
|
48
|
+
import { submitProfile, buildPayload, sendNotice } from "../src/submit.mjs";
|
|
49
|
+
import { DEFAULT_LANGUAGE, SUPPORTED_LANGUAGES, isSupportedLanguage } from "../src/languages.mjs";
|
|
56
50
|
import { assessGroundedness } from "../src/groundedness.mjs";
|
|
57
|
-
import { assessStructure,
|
|
58
|
-
import { computeAiRelationship } from "../src/ai-relationship.mjs";
|
|
59
|
-
import { computeAgenticLiteracy } from "../src/agentic-literacy.mjs";
|
|
60
|
-
import { computeIntensity } from "../src/intensity.mjs";
|
|
61
|
-
import { computeDistribution } from "../src/distribution.mjs";
|
|
62
|
-
import { computeTechUsage, recordedTechUsageTz } from "../src/tech-usage.mjs";
|
|
63
|
-
import { computeCodePractices, mergeModelPractices, practicesBlock, recordedPracticesTz } from "../src/practices.mjs";
|
|
51
|
+
import { assessStructure, submitBlockers } from "../src/consistency.mjs";
|
|
64
52
|
import { DEFAULT_TZ } from "../src/days.mjs";
|
|
65
53
|
import { invocation } from "../src/invocation.mjs";
|
|
66
54
|
|
|
@@ -123,6 +111,13 @@ try {
|
|
|
123
111
|
process.exit(2);
|
|
124
112
|
}
|
|
125
113
|
|
|
114
|
+
// Validate --lang the same way: the language is the profile's, so it is checked before anything is read.
|
|
115
|
+
const langFlag = flag("lang", DEFAULT_LANGUAGE);
|
|
116
|
+
if (!isSupportedLanguage(langFlag)) {
|
|
117
|
+
console.error(`Invalid --lang "${langFlag}". Expected one of: ${SUPPORTED_LANGUAGES.join(", ")}.`);
|
|
118
|
+
process.exit(2);
|
|
119
|
+
}
|
|
120
|
+
|
|
126
121
|
// Every generated file (narrative-input.json, narrative.json, practices-input.json,
|
|
127
122
|
// practices-sample.json, practices.json, practices-detail.json, agent-log.jsonl,
|
|
128
123
|
// candidate.json, profile.md) lands in ./out, never in the repo root.
|
|
@@ -131,13 +126,7 @@ const OUT_DIR = "out";
|
|
|
131
126
|
const CMD = invocation();
|
|
132
127
|
const outPath = () => join(process.cwd(), OUT_DIR);
|
|
133
128
|
// Created only once logs were found. A `*` .gitignore inside keeps every file in it out of a commit.
|
|
134
|
-
const ensureOut = () =>
|
|
135
|
-
const out = outPath();
|
|
136
|
-
mkdirSync(out, { recursive: true });
|
|
137
|
-
const ignore = join(out, ".gitignore");
|
|
138
|
-
if (!existsSync(ignore)) writeFileSync(ignore, "*\n");
|
|
139
|
-
return out;
|
|
140
|
-
};
|
|
129
|
+
const ensureOut = () => pipeline.ensureOutDir(outPath());
|
|
141
130
|
|
|
142
131
|
// The wizard, the agent runner and their dependencies load only where they are used, so the
|
|
143
132
|
// sub-commands work in a clone that never ran npm ci.
|
|
@@ -168,10 +157,8 @@ const die = (msg, code = 2) => {
|
|
|
168
157
|
process.exit(code);
|
|
169
158
|
};
|
|
170
159
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
const say = (...a) => { if (!QUIET) console.log(...a); };
|
|
174
|
-
const warn = (...a) => { if (!QUIET) console.error(...a); };
|
|
160
|
+
const say = (...a) => console.log(...a);
|
|
161
|
+
const warn = (...a) => console.error(...a);
|
|
175
162
|
|
|
176
163
|
// The agent behind `generate --agent <id>`, checked before any log is read.
|
|
177
164
|
async function resolveAgent() {
|
|
@@ -271,88 +258,38 @@ async function loadProfileInputs() {
|
|
|
271
258
|
return deriveInputs(parsed, ensureOut());
|
|
272
259
|
}
|
|
273
260
|
|
|
274
|
-
//
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
const enrichments = selected.map((p) => enrichRepo(p.cwdRaw));
|
|
292
|
-
const contextGap = describeContextGaps(enrichments);
|
|
293
|
-
if (contextGap) warn(` note: ${contextGap}`);
|
|
294
|
-
const trajectory = buildTrajectory(parsed);
|
|
295
|
-
const aiRelationship = computeAiRelationship(parsed);
|
|
296
|
-
const agenticLiteracy = computeAgenticLiteracy(parsed);
|
|
297
|
-
const intensity = computeIntensity(parsed, { tz });
|
|
298
|
-
const distribution = computeDistribution(projects);
|
|
299
|
-
const techUsage = computeTechUsage(projects, { tz });
|
|
300
|
-
const practices = practicesBlock(computeCodePractices(parsed, { tz })?.items, { tz });
|
|
301
|
-
const sources = summarizeSources(parsed);
|
|
302
|
-
return { parsed, fingerprint, forensics, projects, selected, enrichments, trajectory, aiRelationship, agenticLiteracy, intensity, distribution, techUsage, practices, sources, out };
|
|
261
|
+
// The profile pipeline lives in src/pipeline.mjs, shared with the wizard's worker thread; these
|
|
262
|
+
// bind it to this run's flags and to the terminal.
|
|
263
|
+
const pipelineCtx = () => ({ tz: tzFlag, top: flag("top"), language: langFlag, outDir: OUT_DIR, cmd: CMD, say, warn });
|
|
264
|
+
const deriveInputs = (parsed, out) => pipeline.deriveInputs(parsed, out, pipelineCtx());
|
|
265
|
+
const writePracticesInput = (out, parsed) => pipeline.writePracticesInput(out, parsed, pipelineCtx());
|
|
266
|
+
const assembleWithGroundedness = (args) => pipeline.assembleWithGroundedness(args, pipelineCtx());
|
|
267
|
+
|
|
268
|
+
// Answers that cannot be used stop the step with the reason; nothing is saved.
|
|
269
|
+
function stopOnBadAnswers(fn) {
|
|
270
|
+
try {
|
|
271
|
+
return fn();
|
|
272
|
+
} catch (e) {
|
|
273
|
+
if (!(e instanceof pipeline.PracticesAnswersError)) throw e;
|
|
274
|
+
console.error(e.message);
|
|
275
|
+
process.exit(2);
|
|
276
|
+
}
|
|
303
277
|
}
|
|
278
|
+
const mergePracticesAnswers = (out, codeBlock, classifiedBy) => stopOnBadAnswers(() => pipeline.mergePracticesAnswers(out, codeBlock, classifiedBy, pipelineCtx()));
|
|
279
|
+
const applyAgentRun = (out, codePractices, run) => stopOnBadAnswers(() => pipeline.applyAgentRun(out, codePractices, run, pipelineCtx()));
|
|
304
280
|
|
|
305
|
-
function writeProfile(out, profile
|
|
306
|
-
|
|
307
|
-
const md = renderMarkdown(profile);
|
|
308
|
-
writeFileSync(join(out, "profile.md"), md);
|
|
309
|
-
if (!print) return;
|
|
310
|
-
console.log(md);
|
|
281
|
+
function writeProfile(out, profile) {
|
|
282
|
+
console.log(pipeline.saveProfile(out, profile));
|
|
311
283
|
console.log(`Saved: ${OUT_DIR}/candidate.json + ${OUT_DIR}/profile.md`);
|
|
312
284
|
console.log(`To send it to rebase when ready: ${CMD} submit`);
|
|
313
285
|
}
|
|
314
286
|
|
|
315
|
-
// What the agent run adds to the profile: the answers merged into the practices block, who
|
|
316
|
-
// wrote the narrative. The answers stay in practices-detail.json, so a later finalize never
|
|
317
|
-
// reads them as the slash command's.
|
|
318
|
-
function applyAgentRun(out, codePractices, run) {
|
|
319
|
-
if (run.practicesAnswers) writeFileSync(join(out, "practices.json"), JSON.stringify(run.practicesAnswers, null, 2));
|
|
320
|
-
const practices = run.practicesAnswers ? mergePracticesAnswers(out, codePractices, run.used) : codePractices;
|
|
321
|
-
rmSync(join(out, "practices.json"), { force: true });
|
|
322
|
-
return { practices, narrative: run.narrative, generatedBy: { narrative: run.used } };
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
const narrativeOptionsOf = (i) => ({
|
|
326
|
-
trajectory: i.trajectory,
|
|
327
|
-
aiRelationship: i.aiRelationship,
|
|
328
|
-
agenticLiteracy: i.agenticLiteracy,
|
|
329
|
-
intensity: i.intensity,
|
|
330
|
-
distribution: i.distribution,
|
|
331
|
-
allProjects: i.projects,
|
|
332
|
-
compactionSummaries: i.parsed.compactionSummaries,
|
|
333
|
-
});
|
|
334
|
-
|
|
335
|
-
// The model-classified practices: written only when some are published and
|
|
336
|
-
// there is something to read. Both files stay local; the sample file maps the
|
|
337
|
-
// opaque ids back to real sessions and is never sent.
|
|
338
|
-
function writePracticesInput(out, parsed, tz) {
|
|
339
|
-
// A stale sample from an earlier run must never be read by finalize.
|
|
340
|
-
for (const f of ["practices-input.json", "practices-sample.json", "practices-detail.json", "practices.json"]) rmSync(join(out, f), { force: true });
|
|
341
|
-
const shared = JSON.parse(readFileSync(new URL("../share/practices.json", import.meta.url), "utf8"));
|
|
342
|
-
const practices = (shared.practices ?? []).filter((p) => p.method === "model");
|
|
343
|
-
const files = practicesFiles(parsed, { tz, practices });
|
|
344
|
-
if (!files) return;
|
|
345
|
-
writeFileSync(join(out, "practices-input.json"), JSON.stringify(files.input, null, 2));
|
|
346
|
-
writeFileSync(join(out, "practices-sample.json"), JSON.stringify(files.sample, null, 2));
|
|
347
|
-
say(`Wrote ${OUT_DIR}/practices-input.json (${files.sample.length} sessions of your own messages, for your model to classify) and ${OUT_DIR}/practices-sample.json (local only).`);
|
|
348
|
-
}
|
|
349
|
-
|
|
350
287
|
async function cmdGenerate() {
|
|
351
288
|
const entry = await resolveAgent();
|
|
352
289
|
console.log(`\nrebase-verify generate\n`);
|
|
353
290
|
const { parsed, fingerprint, forensics, projects, selected, enrichments, trajectory, aiRelationship, agenticLiteracy, intensity, distribution, techUsage, practices: codePractices, sources, out } = await loadProfileInputs();
|
|
354
291
|
if (entry) rmSync(join(out, "agent-log.jsonl"), { force: true });
|
|
355
|
-
writePracticesInput(out, parsed
|
|
292
|
+
writePracticesInput(out, parsed);
|
|
356
293
|
const narrativeOptions = {
|
|
357
294
|
trajectory,
|
|
358
295
|
aiRelationship,
|
|
@@ -361,6 +298,7 @@ async function cmdGenerate() {
|
|
|
361
298
|
distribution,
|
|
362
299
|
allProjects: projects,
|
|
363
300
|
compactionSummaries: parsed.compactionSummaries,
|
|
301
|
+
language: langFlag,
|
|
364
302
|
};
|
|
365
303
|
let practices;
|
|
366
304
|
let narrative;
|
|
@@ -398,24 +336,10 @@ async function cmdGenerate() {
|
|
|
398
336
|
}));
|
|
399
337
|
}
|
|
400
338
|
|
|
401
|
-
// Assemble + compute groundedness on the assembled draft + re-assemble with
|
|
402
|
-
// the score embedded. Centralised so generate and finalize share it.
|
|
403
|
-
function assembleWithGroundedness(args) {
|
|
404
|
-
// The raw vocabularyCandidates never enter the profile (they can carry
|
|
405
|
-
// client names), so a narrative that omitted its filtered pick leaves
|
|
406
|
-
// newVocabulary empty. Say so instead of failing silently.
|
|
407
|
-
if (args.narrative && args.trajectory?.vocabularyCandidates?.length && !args.narrative.trajectory?.vocabulary_adopted?.length) {
|
|
408
|
-
warn(` note: the narrative has no trajectory.vocabulary_adopted, newVocabulary stays empty (raw candidates are never used; re-run the narrative step to fill it)`);
|
|
409
|
-
}
|
|
410
|
-
const draft = assembleProfile(args);
|
|
411
|
-
const groundedness = assessGroundedness(draft);
|
|
412
|
-
return assembleProfile({ ...args, groundedness });
|
|
413
|
-
}
|
|
414
|
-
|
|
415
339
|
async function cmdPrepare() {
|
|
416
340
|
console.log(`\nrebase-verify prepare\n`);
|
|
417
341
|
const { parsed, projects, selected, enrichments, trajectory, aiRelationship, agenticLiteracy, intensity, distribution, out } = await loadProfileInputs();
|
|
418
|
-
writePracticesInput(out, parsed
|
|
342
|
+
writePracticesInput(out, parsed);
|
|
419
343
|
const input = narrativeInputFor(selected, enrichments, {
|
|
420
344
|
trajectory,
|
|
421
345
|
aiRelationship,
|
|
@@ -424,35 +348,19 @@ async function cmdPrepare() {
|
|
|
424
348
|
distribution,
|
|
425
349
|
allProjects: projects,
|
|
426
350
|
compactionSummaries: parsed.compactionSummaries,
|
|
351
|
+
language: langFlag,
|
|
427
352
|
});
|
|
428
353
|
writeFileSync(join(out, "narrative-input.json"), JSON.stringify(input, null, 2));
|
|
429
354
|
console.log(`Wrote ${OUT_DIR}/narrative-input.json.`);
|
|
430
355
|
console.log(`Next: write ${OUT_DIR}/narrative.json (rules in the slash command), then ${CMD} finalize`);
|
|
431
356
|
}
|
|
432
357
|
|
|
433
|
-
|
|
434
|
-
// against the sample file written at prepare (never resampled), then merged into
|
|
435
|
-
// the block, with who classified them. A bad or unreadable file stops the step;
|
|
436
|
-
// nothing is saved.
|
|
437
|
-
function mergePracticesAnswers(out, codeBlock, classifiedBy) {
|
|
438
|
-
const answersFile = join(out, "practices.json");
|
|
439
|
-
if (!existsSync(answersFile)) return codeBlock;
|
|
440
|
-
const sampleFile = join(out, "practices-sample.json");
|
|
441
|
-
const fail = (msg) => { console.error(`${msg} Fix it, or delete ${OUT_DIR}/practices.json to leave the model practices out.`); process.exit(2); };
|
|
442
|
-
const read = (file) => { try { return JSON.parse(readFileSync(file, "utf8")); } catch { return undefined; } };
|
|
443
|
-
const sample = read(sampleFile);
|
|
444
|
-
if (!Array.isArray(sample)) fail(`Missing or unreadable ${sampleFile}: run ${CMD} prepare again.`);
|
|
445
|
-
const answers = read(answersFile);
|
|
446
|
-
if (answers === undefined) fail(`${answersFile} is not valid JSON.`);
|
|
447
|
-
const shared = JSON.parse(readFileSync(new URL("../share/practices.json", import.meta.url), "utf8"));
|
|
448
|
-
const ids = (shared.practices ?? []).filter((p) => p.method === "model").map((p) => p.id);
|
|
358
|
+
function preparedLanguage(out) {
|
|
449
359
|
try {
|
|
450
|
-
const
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
return
|
|
454
|
-
} catch (e) {
|
|
455
|
-
return fail(`${answersFile}: ${e.message}.`);
|
|
360
|
+
const code = JSON.parse(readFileSync(join(out, "narrative-input.json"), "utf8")).language;
|
|
361
|
+
return isSupportedLanguage(code) ? code : null;
|
|
362
|
+
} catch {
|
|
363
|
+
return null;
|
|
456
364
|
}
|
|
457
365
|
}
|
|
458
366
|
|
|
@@ -465,6 +373,8 @@ async function cmdFinalize() {
|
|
|
465
373
|
}
|
|
466
374
|
const { parsed, fingerprint, forensics, projects, selected, enrichments, trajectory, aiRelationship, agenticLiteracy, intensity, distribution, techUsage, practices, sources, out } = await loadProfileInputs();
|
|
467
375
|
const merged = mergePracticesAnswers(out, practices, SLASH_COMMAND);
|
|
376
|
+
// The narrative was written in the language `prepare` put in narrative-input.json; an explicit --lang wins.
|
|
377
|
+
const language = has("lang") ? langFlag : preparedLanguage(out) ?? langFlag;
|
|
468
378
|
const { narrative } = await generateNarrative(selected, enrichments, {
|
|
469
379
|
overrideFile: narrativeFile,
|
|
470
380
|
trajectory,
|
|
@@ -474,15 +384,20 @@ async function cmdFinalize() {
|
|
|
474
384
|
distribution,
|
|
475
385
|
allProjects: projects,
|
|
476
386
|
compactionSummaries: parsed.compactionSummaries,
|
|
387
|
+
language,
|
|
477
388
|
});
|
|
478
389
|
writeProfile(out, assembleWithGroundedness({
|
|
390
|
+
language,
|
|
479
391
|
projects, narrative, fingerprint, forensics, trajectory, aiRelationship, agenticLiteracy, intensity, distribution, techUsage, practices: merged, sources,
|
|
480
392
|
generatedBy: { narrative: SLASH_COMMAND },
|
|
481
393
|
manifestHash: fingerprint.manifest.bundleHash,
|
|
482
394
|
}));
|
|
483
395
|
}
|
|
484
396
|
|
|
485
|
-
|
|
397
|
+
// `checkLogs(profile, spin)` and `around(label, fn)` are the wizard's: the pre-flight against the
|
|
398
|
+
// logs runs in its worker and every wait is shown with its own spinner. Without them (the
|
|
399
|
+
// sub-command) the same steps run in place and print their own progress.
|
|
400
|
+
async function cmdSubmit({ yes = false, noticeShown = false, checkLogs = null, around = (_label, fn) => fn({ message() {} }) } = {}) {
|
|
486
401
|
// Profiles live in ./out; fall back to the repo root for profiles
|
|
487
402
|
// generated by a version that still wrote there.
|
|
488
403
|
let profilePath = join(process.cwd(), OUT_DIR, "candidate.json");
|
|
@@ -496,20 +411,11 @@ async function cmdSubmit({ yes = false } = {}) {
|
|
|
496
411
|
}
|
|
497
412
|
const profile = JSON.parse(readFileSync(profilePath, "utf8"));
|
|
498
413
|
const hub = resolveHub(flag("hub"));
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
console.log(` artifact links: ${links}`);
|
|
505
|
-
console.log(`\nYou sign in in the browser first, so rebase knows it is you; no name, email or city is sent with the profile.`);
|
|
506
|
-
console.log(`A person at rebase reads it before it counts. If they approve it, your profile gets «Verificato da rebase»,`);
|
|
507
|
-
console.log(`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.`);
|
|
508
|
-
console.log(`It is kept at most 12 months, and you can delete it from your member area.`);
|
|
509
|
-
console.log(`Controller: Rebase S.r.l. (VAT IT 14971460960). Details: https://letsrebase.com/privacy and PRIVACY.md.`);
|
|
510
|
-
console.log(`NOT sent: raw logs, local repo context, third-party proper names.`);
|
|
511
|
-
console.log(`Repository names (repoLabel) are stripped from the payload before it leaves your machine.`);
|
|
512
|
-
console.log(`Inspect the exact outgoing payload: ${CMD} submit --dry-run`);
|
|
414
|
+
|
|
415
|
+
if (!noticeShown) {
|
|
416
|
+
console.log(`\nrebase-verify submit\n`);
|
|
417
|
+
console.log(sendNotice({ hub, profile, cmd: CMD }).join("\n"));
|
|
418
|
+
}
|
|
513
419
|
|
|
514
420
|
// Pre-flight groundedness: how much of the prose is anchored in the data.
|
|
515
421
|
// Recomputed on the file as it is NOW, not trusted from the embedded score.
|
|
@@ -535,23 +441,14 @@ async function cmdSubmit({ yes = false } = {}) {
|
|
|
535
441
|
console.log(`\nConsistency check`);
|
|
536
442
|
const issues = [...assessStructure(profile).issues];
|
|
537
443
|
let excessClaims = 0;
|
|
538
|
-
|
|
539
|
-
if (flag("project")) root = join(root, flag("project"));
|
|
444
|
+
const root = logsRoot();
|
|
540
445
|
if (existsSync(root)) {
|
|
541
446
|
// Re-derive from the SAME source mix the profile was generated from
|
|
542
447
|
// (see sourceFlags()'s comment for why this must never drift).
|
|
543
|
-
const
|
|
544
|
-
|
|
545
|
-
// profile RECORDED, never the machine zone, so the comparison measures
|
|
546
|
-
// the data, not the bucketing.
|
|
547
|
-
const techTz = recordedTechUsageTz(profile);
|
|
548
|
-
const digest = buildDigest(parsed, { tz: techTz });
|
|
549
|
-
const intensity = computeIntensity(parsed, { tz: profile.intensity?.timezone || DEFAULT_TZ });
|
|
550
|
-
const techUsage = computeTechUsage(digest.projects, { tz: techTz });
|
|
551
|
-
const practices = computeCodePractices(parsed, { tz: recordedPracticesTz(profile) });
|
|
552
|
-
const logs = assessAgainstLogs(profile, digest.projects, { intensity, techUsage, practices });
|
|
448
|
+
const logs = await around("Checking the profile against your logs", (spin) =>
|
|
449
|
+
(checkLogs ?? ((p) => pipeline.checkAgainstLogs(p, { claudeRoot: root, sources: sourceFlags() })))(profile, spin));
|
|
553
450
|
issues.push(...logs.issues);
|
|
554
|
-
excessClaims = logs.excessClaims
|
|
451
|
+
excessClaims = logs.excessClaims;
|
|
555
452
|
for (const w of logs.warnings) console.log(` ~ ${w}`);
|
|
556
453
|
} else {
|
|
557
454
|
console.log(` ~ no logs at ${root}, skipping log re-derivation (pass --root if they live elsewhere)`);
|
|
@@ -620,7 +517,7 @@ async function cmdSubmit({ yes = false } = {}) {
|
|
|
620
517
|
}
|
|
621
518
|
|
|
622
519
|
try {
|
|
623
|
-
const res = await submitProfile(profilePath, { hub: flag("hub") });
|
|
520
|
+
const res = await submitProfile(profilePath, { hub: flag("hub"), around });
|
|
624
521
|
console.log(`\nSent. Your profile is waiting as a draft: a person at rebase will read it before it counts.`);
|
|
625
522
|
if (res.review_url) console.log(`See its status here: ${res.review_url}`);
|
|
626
523
|
} catch (e) {
|
|
@@ -636,11 +533,12 @@ if (sub !== "generate" && (has("agent") || has("model"))) die("--agent and --mod
|
|
|
636
533
|
const interactive = !(argv[0] && !argv[0].startsWith("--")) && process.stdin.isTTY && process.stdout.isTTY && !has("yes");
|
|
637
534
|
|
|
638
535
|
async function cmdWizard() {
|
|
639
|
-
const { wizard, clack, live, agents } = await loadOptional(async () => ({
|
|
536
|
+
const { wizard, clack, live, agents, pipelineClient } = await loadOptional(async () => ({
|
|
640
537
|
wizard: await import("../src/wizard.mjs"),
|
|
641
538
|
clack: await import("@clack/prompts"),
|
|
642
539
|
live: await import("../src/live-status.mjs"),
|
|
643
540
|
agents: await loadAgents(),
|
|
541
|
+
pipelineClient: await import("../src/pipeline-client.mjs"),
|
|
644
542
|
}));
|
|
645
543
|
const rejected = wizard.rejectedFlags(has);
|
|
646
544
|
if (rejected) die(rejected);
|
|
@@ -650,52 +548,51 @@ async function cmdWizard() {
|
|
|
650
548
|
const root = logsRoot();
|
|
651
549
|
const flags = sourceFlags();
|
|
652
550
|
const pkg = JSON.parse(readFileSync(fileURLToPath(new URL("../package.json", import.meta.url)), "utf8"));
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
},
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
summary: profile.summary ?? null,
|
|
694
|
-
};
|
|
551
|
+
// Reading the logs and deriving the profile take seconds of synchronous work: they run in a
|
|
552
|
+
// worker thread, so the main thread only paints the spinner that says which step it is.
|
|
553
|
+
const work = pipelineClient.startPipeline({ claudeRoot: root, sources: flags, out, tz: tzFlag, top: flag("top"), language: langFlag, outDir: OUT_DIR, cmd: CMD });
|
|
554
|
+
const sourceLabel = (id) => SOURCES.find((s) => s.id === id)?.label ?? id;
|
|
555
|
+
// One spinner per wait that submit has, with the step it is on; its last line is the label itself.
|
|
556
|
+
const around = async (label, fn) => {
|
|
557
|
+
const s = clack.spinner();
|
|
558
|
+
s.start(label);
|
|
559
|
+
try {
|
|
560
|
+
const v = await fn({ message: (m) => s.message(m) });
|
|
561
|
+
s.stop(label);
|
|
562
|
+
return v;
|
|
563
|
+
} catch (e) {
|
|
564
|
+
s.error(label);
|
|
565
|
+
throw e;
|
|
566
|
+
}
|
|
567
|
+
};
|
|
568
|
+
const checkLogs = (profile, spin) =>
|
|
569
|
+
work.preflight(profile, {
|
|
570
|
+
onStep: (m) => spin.message(m),
|
|
571
|
+
onProgress: (p) => spin.message(`Reading your logs again: ${sourceLabel(p.source)}, ${p.done} of ${p.total} files`),
|
|
572
|
+
});
|
|
573
|
+
let code;
|
|
574
|
+
try {
|
|
575
|
+
code = await wizard.runWizard({
|
|
576
|
+
ui: { ...clack, live: live.liveStatus },
|
|
577
|
+
out,
|
|
578
|
+
flags: { version: pkg.version, agent: entry?.id, model: flag("model") ?? undefined },
|
|
579
|
+
deps: {
|
|
580
|
+
sources: SOURCES.filter((s) => s.id === "claude-code" || !flags[s.id]?.disabled),
|
|
581
|
+
readSource: (id, o) => work.read(id, o),
|
|
582
|
+
availableAgents: (sessionsBySource) => availableAgents({ sessionsBySource }),
|
|
583
|
+
defaultAgent,
|
|
584
|
+
prepare: (ids, o) => work.prepare(ids, o),
|
|
585
|
+
startAgent: agents.acp.startAgent,
|
|
586
|
+
runWithAgent: agents.run.runWithAgent,
|
|
587
|
+
finish: (run, o) => work.finish(run, o),
|
|
588
|
+
// the profile finish() has just written, read back as submit will read it
|
|
589
|
+
sendNotice: () => sendNotice({ hub: resolveHub(flag("hub")), profile: JSON.parse(readFileSync(join(out, "candidate.json"), "utf8")), cmd: CMD }).join("\n"),
|
|
590
|
+
submit: () => cmdSubmit({ yes: true, noticeShown: true, checkLogs, around }),
|
|
695
591
|
},
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
592
|
+
});
|
|
593
|
+
} finally {
|
|
594
|
+
await work.close();
|
|
595
|
+
}
|
|
699
596
|
process.exit(code);
|
|
700
597
|
}
|
|
701
598
|
|
package/package.json
CHANGED
|
@@ -84,11 +84,13 @@ function extractContent(content) {
|
|
|
84
84
|
return { text, thinkingChars, signatureChars, toolUses, toolResults };
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
export function readClaudeCode(root) {
|
|
87
|
+
export function readClaudeCode(root, { onProgress } = {}) {
|
|
88
88
|
const files = [];
|
|
89
89
|
const records = [];
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
const paths = [...walk(root)];
|
|
92
|
+
for (const [i, path] of paths.entries()) {
|
|
93
|
+
onProgress?.({ done: i, total: paths.length });
|
|
92
94
|
const buf = readFileSync(path);
|
|
93
95
|
const lines = buf.toString("utf8").split("\n").filter((l) => l.trim());
|
|
94
96
|
let malformed = 0;
|
package/src/adapters/codex.mjs
CHANGED
|
@@ -232,7 +232,7 @@ const EMPTY = (root) => ({
|
|
|
232
232
|
stats: { originatorCounts: {}, malformedLines: 0 },
|
|
233
233
|
});
|
|
234
234
|
|
|
235
|
-
export function readCodex(root) {
|
|
235
|
+
export function readCodex(root, { onProgress } = {}) {
|
|
236
236
|
if (!root || !existsSync(root)) return EMPTY(root);
|
|
237
237
|
|
|
238
238
|
const files = [];
|
|
@@ -242,7 +242,9 @@ export function readCodex(root) {
|
|
|
242
242
|
const originatorCounts = {};
|
|
243
243
|
let malformedLinesTotal = 0;
|
|
244
244
|
|
|
245
|
-
|
|
245
|
+
const paths = [...walk(root)];
|
|
246
|
+
for (const [i, path] of paths.entries()) {
|
|
247
|
+
onProgress?.({ done: i, total: paths.length });
|
|
246
248
|
const buf = readFileSync(path);
|
|
247
249
|
const relPath = relative(root, path);
|
|
248
250
|
const lines = buf.toString("utf8").split("\n").filter((l) => l.trim());
|
package/src/adapters/omp.mjs
CHANGED
|
@@ -54,6 +54,6 @@ function isTopLevelSession(relPath) {
|
|
|
54
54
|
return parts.length === 2 && !parts[1].includes("__advisor");
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
export function readOmp(root) {
|
|
58
|
-
return readPiFormat(root, { source: "omp", mapTool: mapOmpTool, includeFile: isTopLevelSession });
|
|
57
|
+
export function readOmp(root, { onProgress } = {}) {
|
|
58
|
+
return readPiFormat(root, { source: "omp", mapTool: mapOmpTool, includeFile: isTopLevelSession, onProgress });
|
|
59
59
|
}
|
package/src/adapters/pi.mjs
CHANGED
|
@@ -235,14 +235,14 @@ const EMPTY = (root, source = "pi") => ({
|
|
|
235
235
|
stats: { malformedLines: 0, projectDirCount: 0 },
|
|
236
236
|
});
|
|
237
237
|
|
|
238
|
-
export function readPi(root) {
|
|
239
|
-
return readPiFormat(root, { source: "pi" });
|
|
238
|
+
export function readPi(root, { onProgress } = {}) {
|
|
239
|
+
return readPiFormat(root, { source: "pi", onProgress });
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
// pi's on-disk format is shared by oh-my-pi (omp), a pi fork. The omp adapter
|
|
243
243
|
// calls this with its own source label, tool-name mapper and file filter; real
|
|
244
244
|
// pi goes through readPi above with the defaults, behaviour unchanged.
|
|
245
|
-
export function readPiFormat(root, { source = "pi", mapTool = piMapTool, includeFile = () => true } = {}) {
|
|
245
|
+
export function readPiFormat(root, { source = "pi", mapTool = piMapTool, includeFile = () => true, onProgress } = {}) {
|
|
246
246
|
if (!root || !existsSync(root)) return EMPTY(root, source);
|
|
247
247
|
|
|
248
248
|
const files = [];
|
|
@@ -253,8 +253,9 @@ export function readPiFormat(root, { source = "pi", mapTool = piMapTool, include
|
|
|
253
253
|
let malformedLinesTotal = 0;
|
|
254
254
|
const projectDirs = new Set();
|
|
255
255
|
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
const paths = [...walk(root)].filter((path) => includeFile(relative(root, path)));
|
|
257
|
+
for (const [i, path] of paths.entries()) {
|
|
258
|
+
onProgress?.({ done: i, total: paths.length });
|
|
258
259
|
const buf = readFileSync(path);
|
|
259
260
|
const relPath = relative(root, path);
|
|
260
261
|
const lines = buf.toString("utf8").split("\n").filter((l) => l.trim());
|
package/src/agents/run.mjs
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// before anything is used. The agent's transcript is removed afterwards.
|
|
5
5
|
import { appendFileSync } from "node:fs";
|
|
6
6
|
import { PRACTICES_WARN_WHAT, classifyPractices } from "../practices-llm.mjs";
|
|
7
|
-
import { MODEL,
|
|
7
|
+
import { MODEL, anthropicCall, narrativeSystem, validateNarrative, warnApiKey } from "../profile-llm.mjs";
|
|
8
8
|
import { AgentAuthError, AgentStartError, ModelNotOfferedError, ToolUseError, startAgent } from "./acp.mjs";
|
|
9
9
|
import { firstJsonObject } from "./json-answer.mjs";
|
|
10
10
|
|
|
@@ -50,7 +50,7 @@ export async function runWithAgent({ agent, model, narrativeInput, practicesInpu
|
|
|
50
50
|
let narrative;
|
|
51
51
|
for (let attempt = 0; !narrative; attempt++) {
|
|
52
52
|
onStatus({ step: "narrative", retry: attempt > 0 });
|
|
53
|
-
const text = await ask(
|
|
53
|
+
const text = await ask(narrativeSystem(narrativeInput.language), JSON.stringify(narrativeInput));
|
|
54
54
|
try {
|
|
55
55
|
narrative = validateNarrative(firstJsonObject(text), agent.id);
|
|
56
56
|
} catch (e) {
|