@letsrebase/verify 0.1.1 → 0.1.2

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.
@@ -62,6 +62,7 @@ import { computeDistribution } from "../src/distribution.mjs";
62
62
  import { computeTechUsage, recordedTechUsageTz } from "../src/tech-usage.mjs";
63
63
  import { computeCodePractices, mergeModelPractices, practicesBlock, recordedPracticesTz } from "../src/practices.mjs";
64
64
  import { DEFAULT_TZ } from "../src/days.mjs";
65
+ import { invocation } from "../src/invocation.mjs";
65
66
 
66
67
  // Friendly Node floor (package.json `engines` is advisory only when invoked
67
68
  // as `node bin/rebase-verify.mjs`). Imports hoist and evaluate before this line
@@ -126,6 +127,8 @@ try {
126
127
  // practices-sample.json, practices.json, practices-detail.json, agent-log.jsonl,
127
128
  // candidate.json, profile.md) lands in ./out, never in the repo root.
128
129
  const OUT_DIR = "out";
130
+ // How to run this tool again, as the person started it (npx, an installed bin, a clone).
131
+ const CMD = invocation();
129
132
  const outPath = () => join(process.cwd(), OUT_DIR);
130
133
  // Created only once logs were found. A `*` .gitignore inside keeps every file in it out of a commit.
131
134
  const ensureOut = () => {
@@ -306,7 +309,7 @@ function writeProfile(out, profile, { print = true } = {}) {
306
309
  if (!print) return;
307
310
  console.log(md);
308
311
  console.log(`Saved: ${OUT_DIR}/candidate.json + ${OUT_DIR}/profile.md`);
309
- console.log(`To send it to rebase when ready: rebase-verify submit`);
312
+ console.log(`To send it to rebase when ready: ${CMD} submit`);
310
313
  }
311
314
 
312
315
  // What the agent run adds to the profile: the answers merged into the practices block, who
@@ -382,7 +385,7 @@ async function cmdGenerate() {
382
385
  writeFileSync(join(out, "narrative-input.json"), JSON.stringify(generated.input, null, 2));
383
386
  console.log(` no narrative yet (no API key, no --narrative-file).`);
384
387
  console.log(` From a clone, inside Claude Code: /rebase-verify (writes ${OUT_DIR}/narrative.json and finalizes)`);
385
- console.log(` Manual: write ${OUT_DIR}/narrative.json, then rebase-verify finalize`);
388
+ console.log(` Manual: write ${OUT_DIR}/narrative.json, then ${CMD} finalize`);
386
389
  return;
387
390
  }
388
391
  if (generated.source === "api") generatedBy = { narrative: API_KEY_PATH };
@@ -424,7 +427,7 @@ async function cmdPrepare() {
424
427
  });
425
428
  writeFileSync(join(out, "narrative-input.json"), JSON.stringify(input, null, 2));
426
429
  console.log(`Wrote ${OUT_DIR}/narrative-input.json.`);
427
- console.log(`Next: write ${OUT_DIR}/narrative.json (rules in the slash command), then rebase-verify finalize`);
430
+ console.log(`Next: write ${OUT_DIR}/narrative.json (rules in the slash command), then ${CMD} finalize`);
428
431
  }
429
432
 
430
433
  // The model's answers, when the person's model wrote out/practices.json: checked
@@ -438,7 +441,7 @@ function mergePracticesAnswers(out, codeBlock, classifiedBy) {
438
441
  const fail = (msg) => { console.error(`${msg} Fix it, or delete ${OUT_DIR}/practices.json to leave the model practices out.`); process.exit(2); };
439
442
  const read = (file) => { try { return JSON.parse(readFileSync(file, "utf8")); } catch { return undefined; } };
440
443
  const sample = read(sampleFile);
441
- if (!Array.isArray(sample)) fail(`Missing or unreadable ${sampleFile}: run rebase-verify prepare again.`);
444
+ if (!Array.isArray(sample)) fail(`Missing or unreadable ${sampleFile}: run ${CMD} prepare again.`);
442
445
  const answers = read(answersFile);
443
446
  if (answers === undefined) fail(`${answersFile} is not valid JSON.`);
444
447
  const shared = JSON.parse(readFileSync(new URL("../share/practices.json", import.meta.url), "utf8"));
@@ -457,7 +460,7 @@ async function cmdFinalize() {
457
460
  console.log(`\nrebase-verify finalize\n`);
458
461
  const narrativeFile = flag("narrative-file", join(outPath(), "narrative.json"));
459
462
  if (!existsSync(narrativeFile)) {
460
- console.error(`Missing ${narrativeFile}. Run rebase-verify prepare first, then write ${OUT_DIR}/narrative.json.`);
463
+ console.error(`Missing ${narrativeFile}. Run ${CMD} prepare first, then write ${OUT_DIR}/narrative.json.`);
461
464
  process.exit(2);
462
465
  }
463
466
  const { parsed, fingerprint, forensics, projects, selected, enrichments, trajectory, aiRelationship, agenticLiteracy, intensity, distribution, techUsage, practices, sources, out } = await loadProfileInputs();
@@ -488,7 +491,7 @@ async function cmdSubmit({ yes = false } = {}) {
488
491
  console.log(`(using ./candidate.json from an older run, new runs write to ${OUT_DIR}/)`);
489
492
  }
490
493
  if (!existsSync(profilePath)) {
491
- console.error(`No ${OUT_DIR}/candidate.json yet. Generate the profile first: rebase-verify generate`);
494
+ console.error(`No ${OUT_DIR}/candidate.json yet. Generate the profile first: ${CMD} generate`);
492
495
  process.exit(2);
493
496
  }
494
497
  const profile = JSON.parse(readFileSync(profilePath, "utf8"));
@@ -506,7 +509,7 @@ async function cmdSubmit({ yes = false } = {}) {
506
509
  console.log(`Controller: Rebase S.r.l. (VAT IT 14971460960). Details: https://letsrebase.com/privacy and PRIVACY.md.`);
507
510
  console.log(`NOT sent: raw logs, local repo context, third-party proper names.`);
508
511
  console.log(`Repository names (repoLabel) are stripped from the payload before it leaves your machine.`);
509
- console.log(`Inspect the exact outgoing payload: rebase-verify submit --dry-run`);
512
+ console.log(`Inspect the exact outgoing payload: ${CMD} submit --dry-run`);
510
513
 
511
514
  // Pre-flight groundedness: how much of the prose is anchored in the data.
512
515
  // Recomputed on the file as it is NOW, not trusted from the embedded score.
@@ -565,9 +568,9 @@ async function cmdSubmit({ yes = false } = {}) {
565
568
  console.log(` Claude Code prunes sessions older than its cleanup period (~30 days by default),`);
566
569
  console.log(` and the oldest part of your window aged out after the profile was generated.`);
567
570
  console.log(` Nothing is wrong with what you did: the numbers are just stale.`);
568
- console.log(` Fix: regenerate now and submit right away (rebase-verify generate, or re-run /rebase-verify).`);
571
+ console.log(` Fix: regenerate now and submit right away (${CMD} generate, or re-run /rebase-verify).`);
569
572
  } else {
570
- console.log(` If your logs were pruned since generation, regenerate (rebase-verify generate).`);
573
+ console.log(` If your logs were pruned since generation, regenerate (${CMD} generate).`);
571
574
  }
572
575
  } else {
573
576
  console.log(` structured data is internally consistent and matches your logs`);
@@ -578,15 +581,15 @@ async function cmdSubmit({ yes = false } = {}) {
578
581
  for (const b of blockers) {
579
582
  if (b.kind === "consistency") {
580
583
  console.error(`\nConsistency check failed (${b.count} issue${b.count > 1 ? "s" : ""}). Submission blocked.`);
581
- console.error(`Regenerate the profile (rebase-verify generate) or pass --force to bypass.`);
584
+ console.error(`Regenerate the profile (${CMD} generate) or pass --force to bypass.`);
582
585
  console.error(`Note: the intake re-checks groundedness and these invariants server-side.`);
583
586
  } else if (b.kind === "groundedness-unscored") {
584
587
  console.error(`\nGroundedness could not be scored: the prose has too few checkable anchors for the screen to run. Submission blocked.`);
585
- console.error(`Regenerate the profile (rebase-verify generate) or pass --force to bypass.`);
588
+ console.error(`Regenerate the profile (${CMD} generate) or pass --force to bypass.`);
586
589
  console.error(`Note: the intake flags unscoreable prose server-side as well.`);
587
590
  } else if (b.kind === "groundedness-low") {
588
591
  console.error(`\nGroundedness is low (${b.score}%). Submission blocked.`);
589
- console.error(`Regenerate the profile (rebase-verify generate) or pass --force to bypass.`);
592
+ console.error(`Regenerate the profile (${CMD} generate) or pass --force to bypass.`);
590
593
  }
591
594
  }
592
595
  };
@@ -608,7 +611,7 @@ async function cmdSubmit({ yes = false } = {}) {
608
611
  }
609
612
 
610
613
  if (!(yes || has("yes"))) {
611
- console.log(`\nTo confirm: rebase-verify submit --yes`);
614
+ console.log(`\nTo confirm: ${CMD} submit --yes`);
612
615
  return;
613
616
  }
614
617
  if (blockers.length) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letsrebase/verify",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Work profile: build a tamper-evident, PII-redacted work profile from your coding-agent logs and send it to rebase for review.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,17 @@
1
+ // The command a person types to run rebase-verify again, as they started it this time:
2
+ // npx puts nothing on the PATH and a clone has no `rebase-verify` either, so a hint that
3
+ // says `rebase-verify submit` fails for both.
4
+ import { basename, isAbsolute, relative } from "node:path";
5
+
6
+ export const PACKAGE_NAME = "@letsrebase/verify";
7
+
8
+ export function invocation({ env = process.env, script = process.argv[1] ?? "", cwd = process.cwd() } = {}) {
9
+ // npm exec and npx both set npm_command=exec for the process they start.
10
+ if (env.npm_command === "exec") return `npx ${PACKAGE_NAME}`;
11
+ // An installed package runs through its bin link (or, on Windows, a shim that passes the
12
+ // path inside node_modules): the `rebase-verify` command exists.
13
+ if (basename(script) !== "rebase-verify.mjs" || /[\\/]node_modules[\\/]/.test(script)) return "rebase-verify";
14
+ const rel = relative(cwd, script);
15
+ const path = rel && !rel.startsWith("..") && !isAbsolute(rel) ? rel : script;
16
+ return `node ${/\s/.test(path) ? `"${path}"` : path}`;
17
+ }