mneme-ai 3.131.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.
- package/dist/commands/brief.d.ts +9 -0
- package/dist/commands/brief.d.ts.map +1 -0
- package/dist/commands/brief.js +98 -0
- package/dist/commands/brief.js.map +1 -0
- package/dist/commands/pr-comment.d.ts +11 -0
- package/dist/commands/pr-comment.d.ts.map +1 -0
- package/dist/commands/pr-comment.js +91 -0
- package/dist/commands/pr-comment.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mneme brief` (v3.132.0) — the Context Capsule. Fuse this repo's git history into
|
|
3
|
+
* ONE git-native shared-context object every agent inherits: the team (commit
|
|
4
|
+
* personas), recent decisions, hot files, open TODOs, themes — deterministic, cited,
|
|
5
|
+
* local-first. The Path-A moat: not "memory", but shared CONTEXT for multi-agent teams.
|
|
6
|
+
*/
|
|
7
|
+
import type { Command } from "commander";
|
|
8
|
+
export declare function registerBriefCommands(program: Command): void;
|
|
9
|
+
//# sourceMappingURL=brief.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brief.d.ts","sourceRoot":"","sources":["../../src/commands/brief.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAuBzC,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAsB5D"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mneme brief` (v3.132.0) — the Context Capsule. Fuse this repo's git history into
|
|
3
|
+
* ONE git-native shared-context object every agent inherits: the team (commit
|
|
4
|
+
* personas), recent decisions, hot files, open TODOs, themes — deterministic, cited,
|
|
5
|
+
* local-first. The Path-A moat: not "memory", but shared CONTEXT for multi-agent teams.
|
|
6
|
+
*/
|
|
7
|
+
import { spawnSync } from "node:child_process";
|
|
8
|
+
import { repoBrief } from "@mneme-ai/core";
|
|
9
|
+
function out(s) { process.stdout.write(s + "\n"); }
|
|
10
|
+
function git(args) { const r = spawnSync("git", args, { encoding: "utf8", maxBuffer: 128 * 1024 * 1024 }); return r.status === 0 ? (r.stdout || "") : ""; }
|
|
11
|
+
function readBriefCommits(max = 5000) {
|
|
12
|
+
const US = "\x1f", RS = "\x1e";
|
|
13
|
+
const meta = git(["log", "--no-merges", "-n", String(max), `--format=${RS}%H${US}%an${US}%at${US}%s${US}%b`]);
|
|
14
|
+
const byHash = new Map();
|
|
15
|
+
for (const blk of meta.split(RS)) {
|
|
16
|
+
if (!blk.trim())
|
|
17
|
+
continue;
|
|
18
|
+
const [h, a, t, s, ...r] = blk.split(US);
|
|
19
|
+
if (!h)
|
|
20
|
+
continue;
|
|
21
|
+
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 });
|
|
22
|
+
}
|
|
23
|
+
const ns = git(["log", "--no-merges", "-n", String(max), "--numstat", `--format=${RS}%H`]);
|
|
24
|
+
for (const blk of ns.split(RS)) {
|
|
25
|
+
const lines = blk.split("\n").map((l) => l.trim()).filter(Boolean);
|
|
26
|
+
if (!lines.length)
|
|
27
|
+
continue;
|
|
28
|
+
const rec = byHash.get(lines[0]);
|
|
29
|
+
if (!rec)
|
|
30
|
+
continue;
|
|
31
|
+
for (const l of lines.slice(1)) {
|
|
32
|
+
const m = l.split("\t");
|
|
33
|
+
if (m.length < 3)
|
|
34
|
+
continue;
|
|
35
|
+
rec.churn += (parseInt(m[0], 10) || 0) + (parseInt(m[1], 10) || 0);
|
|
36
|
+
rec.files.push(m[2]);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return [...byHash.values()];
|
|
40
|
+
}
|
|
41
|
+
function todosAtHead() {
|
|
42
|
+
const o = git(["grep", "-nI", "-E", "TODO|FIXME|HACK|XXX", "HEAD", "--", "*.ts", "*.tsx", "*.js", "*.py", "*.go", "*.rs"]);
|
|
43
|
+
const out2 = [];
|
|
44
|
+
for (const l of o.split("\n")) {
|
|
45
|
+
const m = l.match(/^[^:]+:([^:]+):(\d+):(.*)$/);
|
|
46
|
+
if (m)
|
|
47
|
+
out2.push({ file: m[1], line: parseInt(m[2], 10), text: m[3].trim().slice(0, 120) });
|
|
48
|
+
if (out2.length >= 20)
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
return out2;
|
|
52
|
+
}
|
|
53
|
+
export function registerBriefCommands(program) {
|
|
54
|
+
program
|
|
55
|
+
.command("brief")
|
|
56
|
+
.description("🧭 REPO BRIEF (the Context Capsule) — fuse this repo's git history into ONE git-native shared-context object every agent inherits: the team (commit personas) · recent decisions · hot files · open TODOs · themes. Deterministic, cited, tamper-evident, local-first. The Path-A moat: shared CONTEXT for multi-agent teams, not a 'memory product'.")
|
|
57
|
+
.option("--json", "JSON output (the full signed-able brief)")
|
|
58
|
+
.action((opts) => {
|
|
59
|
+
const commits = readBriefCommits();
|
|
60
|
+
if (!commits.length) {
|
|
61
|
+
out("no commits found (run inside a git repo)");
|
|
62
|
+
process.exitCode = 2;
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const repoCommits = parseInt(git(["rev-list", "--count", "HEAD"]).trim(), 10) || commits.length;
|
|
66
|
+
const repo = (git(["config", "--get", "remote.origin.url"]).trim() || "").replace(/^https?:\/\//, "").replace(/\.git$/, "") || "(local)";
|
|
67
|
+
const b = repoBrief.buildRepoBrief(commits, { repo, repoCommits, openTodos: todosAtHead() });
|
|
68
|
+
if (opts.json) {
|
|
69
|
+
out(JSON.stringify(b, null, 2));
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
out(`🧭 REPO BRIEF — ${b.repo}`);
|
|
73
|
+
out(` ${b.reconciled.repoCommits} commits in repo · ${b.reconciled.merges} merge(s) excluded · ${b.reconciled.authoredCommits} authored · ${b.reconciled.contributors} contributors`);
|
|
74
|
+
if (b.themes.length)
|
|
75
|
+
out(`\n 🎯 Focus: ${b.themes.join(" · ")}`);
|
|
76
|
+
if (b.team.length) {
|
|
77
|
+
out(`\n 👥 Team:`);
|
|
78
|
+
for (const t of b.team)
|
|
79
|
+
out(` ${t.tier.padEnd(9)} ${t.archetype.padEnd(16)} ${t.author} (${t.commits} commits)`);
|
|
80
|
+
}
|
|
81
|
+
if (b.decisions.length) {
|
|
82
|
+
out(`\n 💡 Recent decisions:`);
|
|
83
|
+
for (const d of b.decisions.slice(0, 6))
|
|
84
|
+
out(` ${d.hash} ${d.subject}`);
|
|
85
|
+
}
|
|
86
|
+
if (b.hotFiles.length) {
|
|
87
|
+
out(`\n 🔥 Hot files:`);
|
|
88
|
+
for (const h of b.hotFiles.slice(0, 6))
|
|
89
|
+
out(` ${String(h.touches).padStart(3)}× ${h.file}`);
|
|
90
|
+
}
|
|
91
|
+
if (b.openTodos.length) {
|
|
92
|
+
out(`\n 📌 Open TODOs: ${b.openTodos.length} (e.g. ${b.openTodos[0].file}:${b.openTodos[0].line})`);
|
|
93
|
+
}
|
|
94
|
+
out(`\n 🧷 ${b.citations.length} citations · briefId ${b.briefId.slice(0, 16)}…`);
|
|
95
|
+
out(` ${b.note}`);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=brief.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"brief.js","sourceRoot":"","sources":["../../src/commands/brief.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,SAAS,GAAG,CAAC,CAAS,IAAU,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG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SAAS,CAAC,MAAM,wBAAwB,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,CAAC;QACnF,GAAG,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -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,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAE7K,SAAS,WAAW,CAAC,GAAG,GAAG,IAAI;IAC7B,MAAM,EAAE,GAAG,MAAM,EAAE,EAAE,GAAG,MAAM,CAAC;IAC/B,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,KAAK,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,K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,CAAC;gBAAC,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;YAAC,CAAC;YAAC,MAAM,CAAC,CAAC,KAAK,CAAC,CAAC;QAAC,CAAC;QACtG,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QACxE,MAAM,MAAM,GAAG,QAAQ,CAAC,cAAc,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;QAChG,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;YAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;QAAC,CAAC;aACnD,CAAC;YAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAAC,CAAC;QAC9B,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;AACP,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
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
|
@@ -134,6 +134,8 @@ import { registerHpeCommands } from "./commands/hpe.js";
|
|
|
134
134
|
import { registerVericertCommands } from "./commands/vericert.js";
|
|
135
135
|
import { registerPersonaCommands } from "./commands/persona.js";
|
|
136
136
|
import { registerSeanceCommands } from "./commands/seance.js";
|
|
137
|
+
import { registerBriefCommands } from "./commands/brief.js";
|
|
138
|
+
import { registerPrCommentCommands } from "./commands/pr-comment.js";
|
|
137
139
|
import { registerMoatCommands } from "./commands/moat.js";
|
|
138
140
|
import { attachRegretOracle } from "./commands/regret.js";
|
|
139
141
|
import { registerTrustCommands } from "./commands/trust.js";
|
|
@@ -4825,6 +4827,8 @@ export async function run(argv) {
|
|
|
4825
4827
|
registerVericertCommands(program);
|
|
4826
4828
|
registerPersonaCommands(program);
|
|
4827
4829
|
registerSeanceCommands(program);
|
|
4830
|
+
registerBriefCommands(program);
|
|
4831
|
+
registerPrCommentCommands(program);
|
|
4828
4832
|
registerMoatCommands(program);
|
|
4829
4833
|
// ─── Trust calibrator (v1.31.0) -- per-subsystem precision/recall/band
|
|
4830
4834
|
registerTrustCommands(program);
|