mneme-ai 3.132.0 → 3.133.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.
@@ -0,0 +1,11 @@
1
+ /**
2
+ * `mneme pr-comment` (v3.133.0) — generate the Mneme PR comment in CI: VERICERT of
3
+ * the PR description + the git-native CONTEXT of every changed file (why it's the
4
+ * way it is, cited) + the author's commit persona. Print markdown; the workflow
5
+ * posts it. Free in your CI on any repo. Exit 2 if the PR description is REJECTED.
6
+ *
7
+ * mneme pr-comment --base origin/main --title "$TITLE" --body "$BODY"
8
+ */
9
+ import type { Command } from "commander";
10
+ export declare function registerPrCommentCommands(program: Command): void;
11
+ //# sourceMappingURL=pr-comment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pr-comment.d.ts","sourceRoot":"","sources":["../../src/commands/pr-comment.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkBzC,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAyBhE"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * `mneme pr-comment` (v3.133.0) — generate the Mneme PR comment in CI: VERICERT of
3
+ * the PR description + the git-native CONTEXT of every changed file (why it's the
4
+ * way it is, cited) + the author's commit persona. Print markdown; the workflow
5
+ * posts it. Free in your CI on any repo. Exit 2 if the PR description is REJECTED.
6
+ *
7
+ * mneme pr-comment --base origin/main --title "$TITLE" --body "$BODY"
8
+ */
9
+ import { spawnSync } from "node:child_process";
10
+ import { readFileSync } from "node:fs";
11
+ import { prReview } from "@mneme-ai/core";
12
+ function out(s) { process.stdout.write(s + "\n"); }
13
+ function git(args) { const r = spawnSync("git", args, { encoding: "utf8", maxBuffer: 128 * 1024 * 1024 }); return r.status === 0 ? (r.stdout || "") : ""; }
14
+ function readCommits(max = 5000) {
15
+ const US = "\x1f", RS = "\x1e";
16
+ const meta = git(["log", "--no-merges", "-n", String(max), `--format=${RS}%H${US}%an${US}%at${US}%s${US}%b`]);
17
+ const byHash = new Map();
18
+ for (const blk of meta.split(RS)) {
19
+ if (!blk.trim())
20
+ continue;
21
+ const [h, a, t, s, ...r] = blk.split(US);
22
+ if (!h)
23
+ continue;
24
+ byHash.set(h.trim(), { hash: h.trim(), author: (a || "").trim(), ts: parseInt(t || "0", 10) || 0, subject: (s || "").trim(), body: (r.join(US) || "").trim(), files: [], churn: 0 });
25
+ }
26
+ const ns = git(["log", "--no-merges", "-n", String(max), "--numstat", `--format=${RS}%H`]);
27
+ for (const blk of ns.split(RS)) {
28
+ const lines = blk.split("\n").map((l) => l.trim()).filter(Boolean);
29
+ if (!lines.length)
30
+ continue;
31
+ const rec = byHash.get(lines[0]);
32
+ if (!rec)
33
+ continue;
34
+ for (const l of lines.slice(1)) {
35
+ const m = l.split("\t");
36
+ if (m.length < 3)
37
+ continue;
38
+ rec.churn += (parseInt(m[0], 10) || 0) + (parseInt(m[1], 10) || 0);
39
+ rec.files.push(m[2]);
40
+ }
41
+ }
42
+ return [...byHash.values()];
43
+ }
44
+ export function registerPrCommentCommands(program) {
45
+ program
46
+ .command("pr-comment")
47
+ .description("🧭 Generate the Mneme PR comment for CI — VERICERT of the PR description + git-native context of every changed file (why it's the way it is, cited) + the author's commit persona. Prints markdown for your workflow to post. Exit 2 if the PR description is REJECTED.")
48
+ .option("--base <ref>", "the PR base branch to diff against", "origin/main")
49
+ .option("--title <t>", "PR title (default: latest commit subject)")
50
+ .option("--body <b>", "PR description ('-' or @file to read from stdin/file)")
51
+ .option("--author <name>", "PR author (default: latest commit author)")
52
+ .option("--json", "JSON output")
53
+ .action((opts) => {
54
+ const commits = readCommits();
55
+ if (!commits.length) {
56
+ out("no commits found (run inside a git repo)");
57
+ process.exitCode = 2;
58
+ return;
59
+ }
60
+ // changed files = diff vs the merge-base with the PR base
61
+ let changed = git(["diff", "--name-only", `${opts.base}...HEAD`]).split("\n").map((s) => s.trim()).filter(Boolean);
62
+ if (!changed.length)
63
+ changed = git(["diff", "--name-only", "HEAD~1...HEAD"]).split("\n").map((s) => s.trim()).filter(Boolean);
64
+ const title = opts.title || git(["log", "-1", "--format=%s"]).trim();
65
+ let body = opts.body || git(["log", "-1", "--format=%b"]).trim();
66
+ if (body === "-") {
67
+ try {
68
+ body = readFileSync(0, "utf8");
69
+ }
70
+ catch {
71
+ body = "";
72
+ }
73
+ }
74
+ else if (body.startsWith("@")) {
75
+ try {
76
+ body = readFileSync(body.slice(1), "utf8");
77
+ }
78
+ catch { /* */ }
79
+ }
80
+ const author = opts.author || git(["log", "-1", "--format=%an"]).trim();
81
+ const review = prReview.buildPrComment({ title, body, changedFiles: changed, commits, author });
82
+ if (opts.json) {
83
+ out(JSON.stringify(review, null, 2));
84
+ }
85
+ else {
86
+ out(review.markdown);
87
+ }
88
+ process.exitCode = review.cert.verdict === "REJECTED" ? 2 : 0;
89
+ });
90
+ }
91
+ //# sourceMappingURL=pr-comment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pr-comment.js","sourceRoot":"","sources":["../../src/commands/pr-comment.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,SAAS,GAAG,CAAC,CAAS,IAAU,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AACjE,SAAS,GAAG,CAAC,IAAc,IAAY,MAAM,CAAC,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,GAAG,IAAI,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAA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src/index.ts"],"names":[],"mappings":"AA4MA,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA+mNvD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA6MA,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAgnNvD"}
package/dist/index.js CHANGED
@@ -135,6 +135,7 @@ import { registerVericertCommands } from "./commands/vericert.js";
135
135
  import { registerPersonaCommands } from "./commands/persona.js";
136
136
  import { registerSeanceCommands } from "./commands/seance.js";
137
137
  import { registerBriefCommands } from "./commands/brief.js";
138
+ import { registerPrCommentCommands } from "./commands/pr-comment.js";
138
139
  import { registerMoatCommands } from "./commands/moat.js";
139
140
  import { attachRegretOracle } from "./commands/regret.js";
140
141
  import { registerTrustCommands } from "./commands/trust.js";
@@ -4827,6 +4828,7 @@ export async function run(argv) {
4827
4828
  registerPersonaCommands(program);
4828
4829
  registerSeanceCommands(program);
4829
4830
  registerBriefCommands(program);
4831
+ registerPrCommentCommands(program);
4830
4832
  registerMoatCommands(program);
4831
4833
  // ─── Trust calibrator (v1.31.0) -- per-subsystem precision/recall/band
4832
4834
  registerTrustCommands(program);