mneme-ai 3.132.0 → 3.134.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/ctx.d.ts +13 -0
- package/dist/commands/ctx.d.ts.map +1 -0
- package/dist/commands/ctx.js +93 -0
- package/dist/commands/ctx.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,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mneme ctx` (v3.134.0) — THE CONTEXT PASSPORT: the cross-agent verified context
|
|
3
|
+
* layer that lives in git (`.mneme/passport/*.jsonl`). Any agent (any vendor)
|
|
4
|
+
* inherits what others learned — screened for poison/injection first — and
|
|
5
|
+
* contributes back, signed. Portable · vendor-neutral · local-first · trustworthy.
|
|
6
|
+
*
|
|
7
|
+
* mneme ctx contribute --kind decision --text "chose X" --cite a1b2c3,src/x.ts:4
|
|
8
|
+
* mneme ctx inherit # the screened, trusted context an agent reads
|
|
9
|
+
* mneme ctx status
|
|
10
|
+
*/
|
|
11
|
+
import type { Command } from "commander";
|
|
12
|
+
export declare function registerCtxCommands(program: Command): void;
|
|
13
|
+
//# sourceMappingURL=ctx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ctx.d.ts","sourceRoot":"","sources":["../../src/commands/ctx.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAezC,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAwC1D"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `mneme ctx` (v3.134.0) — THE CONTEXT PASSPORT: the cross-agent verified context
|
|
3
|
+
* layer that lives in git (`.mneme/passport/*.jsonl`). Any agent (any vendor)
|
|
4
|
+
* inherits what others learned — screened for poison/injection first — and
|
|
5
|
+
* contributes back, signed. Portable · vendor-neutral · local-first · trustworthy.
|
|
6
|
+
*
|
|
7
|
+
* mneme ctx contribute --kind decision --text "chose X" --cite a1b2c3,src/x.ts:4
|
|
8
|
+
* mneme ctx inherit # the screened, trusted context an agent reads
|
|
9
|
+
* mneme ctx status
|
|
10
|
+
*/
|
|
11
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync, readdirSync } from "node:fs";
|
|
12
|
+
import { join } from "node:path";
|
|
13
|
+
import { contextPassport, notary } from "@mneme-ai/core";
|
|
14
|
+
function out(s) { process.stdout.write(s + "\n"); }
|
|
15
|
+
const DIR = () => join(process.cwd(), ".mneme", "passport");
|
|
16
|
+
function readAll() {
|
|
17
|
+
const acc = [];
|
|
18
|
+
const d = DIR();
|
|
19
|
+
try {
|
|
20
|
+
if (!existsSync(d))
|
|
21
|
+
return [];
|
|
22
|
+
for (const f of readdirSync(d)) {
|
|
23
|
+
if (!f.endsWith(".jsonl"))
|
|
24
|
+
continue;
|
|
25
|
+
for (const line of readFileSync(join(d, f), "utf8").split("\n")) {
|
|
26
|
+
if (line.trim()) {
|
|
27
|
+
try {
|
|
28
|
+
acc.push(JSON.parse(line));
|
|
29
|
+
}
|
|
30
|
+
catch { /* skip */ }
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
catch { /* */ }
|
|
36
|
+
return acc;
|
|
37
|
+
}
|
|
38
|
+
export function registerCtxCommands(program) {
|
|
39
|
+
const c = program
|
|
40
|
+
.command("ctx")
|
|
41
|
+
.alias("context-passport")
|
|
42
|
+
.description("🛂 CONTEXT PASSPORT — the cross-agent verified-context layer in git (.mneme/passport). Any agent (any vendor) inherits what others learned (poison-screened first) + contributes back, signed. Portable · vendor-neutral · local-first · trustworthy. TRUST-precision 1.0 — a poisoned/injected entry is NEVER inherited.");
|
|
43
|
+
c.command("contribute")
|
|
44
|
+
.description("append a signed context entry the next agent (any vendor) can inherit")
|
|
45
|
+
.requiredOption("--kind <k>", "decision | finding | dead-end | constraint")
|
|
46
|
+
.requiredOption("--text <t>", "the context to record")
|
|
47
|
+
.option("--cite <list>", "comma-separated commit hashes / file:line that ground it", "")
|
|
48
|
+
.option("--agent <name>", "your agent/tool id", "cli")
|
|
49
|
+
.action((o) => {
|
|
50
|
+
const kind = (["decision", "finding", "dead-end", "constraint"].includes(o.kind) ? o.kind : "finding");
|
|
51
|
+
const cites = o.cite ? o.cite.split(",").map((s) => s.trim()).filter(Boolean) : [];
|
|
52
|
+
const entry = contextPassport.makeEntry(o.agent, kind, o.text, cites, Math.floor(Date.now() / 1000));
|
|
53
|
+
const screen = contextPassport.trustScreen(entry);
|
|
54
|
+
let sig = null;
|
|
55
|
+
try {
|
|
56
|
+
sig = notary.issueReceipt(process.cwd(), { kind: "claim-verdict", subject: `ctx:${entry.kind}:${entry.id}`, payload: { id: entry.id }, includePayload: true });
|
|
57
|
+
}
|
|
58
|
+
catch { /* */ }
|
|
59
|
+
try {
|
|
60
|
+
mkdirSync(DIR(), { recursive: true });
|
|
61
|
+
const f = join(DIR(), o.agent.replace(/[^A-Za-z0-9._-]/g, "_") + ".jsonl");
|
|
62
|
+
const prev = existsSync(f) ? readFileSync(f, "utf8") : "";
|
|
63
|
+
writeFileSync(f, prev + JSON.stringify({ ...entry, sig }) + "\n");
|
|
64
|
+
}
|
|
65
|
+
catch { /* */ }
|
|
66
|
+
out(`🛂 recorded ${entry.kind} (${entry.id}) — ${screen.trust ? "✓ will be inherited as TRUSTED" : "⚠ would be QUARANTINED: " + screen.reason}`);
|
|
67
|
+
out(` commit .mneme/passport so the next agent (any vendor) inherits it.`);
|
|
68
|
+
});
|
|
69
|
+
c.command("inherit")
|
|
70
|
+
.description("the screened, trusted context an agent should read at task start (poison quarantined)")
|
|
71
|
+
.option("--json", "JSON output")
|
|
72
|
+
.action((o) => {
|
|
73
|
+
const r = contextPassport.inheritPassport(readAll());
|
|
74
|
+
if (o.json) {
|
|
75
|
+
out(JSON.stringify(r, null, 2));
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
out(`🛂 CONTEXT PASSPORT — ${r.summary.trusted} trusted · ${r.summary.quarantined} quarantined (of ${r.summary.total})`);
|
|
79
|
+
if (!r.summary.total) {
|
|
80
|
+
out(" (empty — contribute: mneme ctx contribute --kind decision --text \"…\" --cite <commit>)");
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
for (const e of r.trusted.slice(0, 20))
|
|
84
|
+
out(` ✓ [${e.kind}] ${e.text} ⟨${e.agent} · ${e.citations.join(", ")}⟩`);
|
|
85
|
+
for (const q of r.quarantined.slice(0, 8))
|
|
86
|
+
out(` ⚠ QUARANTINED [${q.entry.kind}] ${q.entry.text.slice(0, 56)} — ${q.reason}`);
|
|
87
|
+
});
|
|
88
|
+
c.command("status").description("passport counts").action(() => {
|
|
89
|
+
const r = contextPassport.inheritPassport(readAll());
|
|
90
|
+
out(`🛂 ${r.summary.total} entries · ${r.summary.trusted} trusted · ${r.summary.quarantined} quarantined · dir .mneme/passport`);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=ctx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ctx.js","sourceRoot":"","sources":["../../src/commands/ctx.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAC1F,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAGzD,SAAS,GAAG,CAAC,CAAS,IAAU,OAAO,CA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AC"}
|
|
@@ -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
|
+
});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AAC,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":"AA8MA,wBAAsB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAinNvD"}
|
package/dist/index.js
CHANGED
|
@@ -135,6 +135,8 @@ 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";
|
|
139
|
+
import { registerCtxCommands } from "./commands/ctx.js";
|
|
138
140
|
import { registerMoatCommands } from "./commands/moat.js";
|
|
139
141
|
import { attachRegretOracle } from "./commands/regret.js";
|
|
140
142
|
import { registerTrustCommands } from "./commands/trust.js";
|
|
@@ -4827,6 +4829,8 @@ export async function run(argv) {
|
|
|
4827
4829
|
registerPersonaCommands(program);
|
|
4828
4830
|
registerSeanceCommands(program);
|
|
4829
4831
|
registerBriefCommands(program);
|
|
4832
|
+
registerPrCommentCommands(program);
|
|
4833
|
+
registerCtxCommands(program);
|
|
4830
4834
|
registerMoatCommands(program);
|
|
4831
4835
|
// ─── Trust calibrator (v1.31.0) -- per-subsystem precision/recall/band
|
|
4832
4836
|
registerTrustCommands(program);
|