@mneme-ai/mcp 1.1.0 → 1.2.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/index.d.ts.map +1 -1
- package/dist/index.js +45 -344
- package/dist/index.js.map +1 -1
- package/dist/tools/_capabilities.d.ts +14 -0
- package/dist/tools/_capabilities.d.ts.map +1 -0
- package/dist/tools/_capabilities.js +77 -0
- package/dist/tools/_capabilities.js.map +1 -0
- package/dist/tools/_registry.d.ts +16 -0
- package/dist/tools/_registry.d.ts.map +1 -0
- package/dist/tools/_registry.js +57 -0
- package/dist/tools/_registry.js.map +1 -0
- package/dist/tools/_runtime.d.ts +32 -0
- package/dist/tools/_runtime.d.ts.map +1 -0
- package/dist/tools/_runtime.js +78 -0
- package/dist/tools/_runtime.js.map +1 -0
- package/dist/tools/_smart_do.d.ts +14 -0
- package/dist/tools/_smart_do.d.ts.map +1 -0
- package/dist/tools/_smart_do.js +49 -0
- package/dist/tools/_smart_do.js.map +1 -0
- package/dist/tools/_types.d.ts +70 -0
- package/dist/tools/_types.d.ts.map +1 -0
- package/dist/tools/_types.js +34 -0
- package/dist/tools/_types.js.map +1 -0
- package/dist/tools/audit.d.ts +9 -0
- package/dist/tools/audit.d.ts.map +1 -0
- package/dist/tools/audit.js +233 -0
- package/dist/tools/audit.js.map +1 -0
- package/dist/tools/forensics.d.ts +7 -0
- package/dist/tools/forensics.d.ts.map +1 -0
- package/dist/tools/forensics.js +189 -0
- package/dist/tools/forensics.js.map +1 -0
- package/dist/tools/insights.d.ts +7 -0
- package/dist/tools/insights.d.ts.map +1 -0
- package/dist/tools/insights.js +40 -0
- package/dist/tools/insights.js.map +1 -0
- package/dist/tools/lab.d.ts +7 -0
- package/dist/tools/lab.d.ts.map +1 -0
- package/dist/tools/lab.js +93 -0
- package/dist/tools/lab.js.map +1 -0
- package/dist/tools/memory.d.ts +10 -0
- package/dist/tools/memory.d.ts.map +1 -0
- package/dist/tools/memory.js +451 -0
- package/dist/tools/memory.js.map +1 -0
- package/dist/tools/meta.d.ts +7 -0
- package/dist/tools/meta.d.ts.map +1 -0
- package/dist/tools/meta.js +20 -0
- package/dist/tools/meta.js.map +1 -0
- package/dist/tools/people.d.ts +10 -0
- package/dist/tools/people.d.ts.map +1 -0
- package/dist/tools/people.js +73 -0
- package/dist/tools/people.js.map +1 -0
- package/dist/tools/quality.d.ts +6 -0
- package/dist/tools/quality.d.ts.map +1 -0
- package/dist/tools/quality.js +57 -0
- package/dist/tools/quality.js.map +1 -0
- package/dist/tools/quant.d.ts +7 -0
- package/dist/tools/quant.d.ts.map +1 -0
- package/dist/tools/quant.js +26 -0
- package/dist/tools/quant.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP runtime — built once at server start, reused for every tool call.
|
|
3
|
+
*
|
|
4
|
+
* The previous monolithic index.ts opened the store + embedder inline.
|
|
5
|
+
* Extracting it lets every tool file import {ToolRuntime} cleanly without
|
|
6
|
+
* each one re-instantiating the database connection.
|
|
7
|
+
*/
|
|
8
|
+
import type { ToolRuntime } from "./_types.js";
|
|
9
|
+
export declare function buildRuntime(cwd: string): Promise<ToolRuntime>;
|
|
10
|
+
/** Build a passthrough handler that spawns the CLI command, parses --json, and
|
|
11
|
+
* wraps the result in a generic wisdom envelope. Use this for tools whose
|
|
12
|
+
* logic lives entirely in the CLI; the wisdom field is generic but accurate. */
|
|
13
|
+
export declare function passthroughHandler(cliCommand: string, argMap: (args: Record<string, unknown>) => string[], options?: {
|
|
14
|
+
wisdom: (data: unknown) => string;
|
|
15
|
+
followUp?: string[];
|
|
16
|
+
confidence?: "high" | "medium" | "low";
|
|
17
|
+
}): (rt: ToolRuntime, args: Record<string, unknown>) => Promise<{
|
|
18
|
+
data: unknown;
|
|
19
|
+
wisdom: string;
|
|
20
|
+
followUp: string[];
|
|
21
|
+
confidence: {
|
|
22
|
+
level: "high" | "medium" | "low";
|
|
23
|
+
};
|
|
24
|
+
}>;
|
|
25
|
+
/** Spawn `mneme <command> [...args]` as a child process and parse its --json
|
|
26
|
+
* output. Used by category files for tools whose logic lives in the CLI
|
|
27
|
+
* layer rather than the core API. Returns parsed JSON or throws on
|
|
28
|
+
* non-zero exit / parse failure. */
|
|
29
|
+
export declare function runCliJson(cwd: string, command: string, cliArgs?: string[], opts?: {
|
|
30
|
+
timeoutMs?: number;
|
|
31
|
+
}): Promise<unknown>;
|
|
32
|
+
//# sourceMappingURL=_runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_runtime.d.ts","sourceRoot":"","sources":["../../src/tools/_runtime.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/C,wBAAsB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAapE;AAED;;iFAEiF;AACjF,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,EAAE,EACnD,OAAO,GAAE;IAAE,MAAM,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAA;CAExG,IAEa,IAAI,WAAW,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;;;;;;;GAS7D;AAED;;;qCAGqC;AACrC,wBAAsB,UAAU,CAC9B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,MAAM,EAAO,EACtB,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GAChC,OAAO,CAAC,OAAO,CAAC,CA+BlB"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP runtime — built once at server start, reused for every tool call.
|
|
3
|
+
*
|
|
4
|
+
* The previous monolithic index.ts opened the store + embedder inline.
|
|
5
|
+
* Extracting it lets every tool file import {ToolRuntime} cleanly without
|
|
6
|
+
* each one re-instantiating the database connection.
|
|
7
|
+
*/
|
|
8
|
+
import { existsSync, mkdirSync } from "node:fs";
|
|
9
|
+
import { join } from "node:path";
|
|
10
|
+
import { git, store } from "@mneme-ai/core";
|
|
11
|
+
import { resolveEmbedder } from "@mneme-ai/embeddings";
|
|
12
|
+
export async function buildRuntime(cwd) {
|
|
13
|
+
if (!(await git.isGitRepo(cwd))) {
|
|
14
|
+
throw new Error(`Mneme MCP: not in a git repo (${cwd}).`);
|
|
15
|
+
}
|
|
16
|
+
const meta = await git.getRepoMeta(cwd);
|
|
17
|
+
const dbDir = join(meta.rootPath, ".mneme");
|
|
18
|
+
if (!existsSync(dbDir))
|
|
19
|
+
mkdirSync(dbDir, { recursive: true });
|
|
20
|
+
const dbPath = join(dbDir, "mneme.db");
|
|
21
|
+
const s = new store.MnemeStore(dbPath);
|
|
22
|
+
const embedder = await resolveEmbedder({ provider: "auto" });
|
|
23
|
+
return { cwd, meta, store: s, embedder };
|
|
24
|
+
}
|
|
25
|
+
/** Build a passthrough handler that spawns the CLI command, parses --json, and
|
|
26
|
+
* wraps the result in a generic wisdom envelope. Use this for tools whose
|
|
27
|
+
* logic lives entirely in the CLI; the wisdom field is generic but accurate. */
|
|
28
|
+
export function passthroughHandler(cliCommand, argMap, options = {
|
|
29
|
+
wisdom: () => "Result returned. AI should summarize key fields for the user.",
|
|
30
|
+
}) {
|
|
31
|
+
return async (rt, args) => {
|
|
32
|
+
const data = await runCliJson(rt.meta.rootPath, cliCommand, argMap(args));
|
|
33
|
+
return {
|
|
34
|
+
data,
|
|
35
|
+
wisdom: options.wisdom(data),
|
|
36
|
+
followUp: options.followUp ?? [],
|
|
37
|
+
confidence: { level: options.confidence ?? "medium" },
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/** Spawn `mneme <command> [...args]` as a child process and parse its --json
|
|
42
|
+
* output. Used by category files for tools whose logic lives in the CLI
|
|
43
|
+
* layer rather than the core API. Returns parsed JSON or throws on
|
|
44
|
+
* non-zero exit / parse failure. */
|
|
45
|
+
export async function runCliJson(cwd, command, cliArgs = [], opts = {}) {
|
|
46
|
+
const { spawn } = await import("node:child_process");
|
|
47
|
+
return await new Promise((resolve, reject) => {
|
|
48
|
+
const child = spawn("mneme", [command, ...cliArgs, "--json"], {
|
|
49
|
+
cwd,
|
|
50
|
+
shell: process.platform === "win32",
|
|
51
|
+
});
|
|
52
|
+
let stdout = "";
|
|
53
|
+
let stderr = "";
|
|
54
|
+
child.stdout?.on("data", (b) => (stdout += String(b)));
|
|
55
|
+
child.stderr?.on("data", (b) => (stderr += String(b)));
|
|
56
|
+
const timer = setTimeout(() => {
|
|
57
|
+
child.kill();
|
|
58
|
+
reject(new Error(`mneme ${command} timed out after ${opts.timeoutMs ?? 60000}ms`));
|
|
59
|
+
}, opts.timeoutMs ?? 60_000);
|
|
60
|
+
child.on("close", (code) => {
|
|
61
|
+
clearTimeout(timer);
|
|
62
|
+
if (code !== 0) {
|
|
63
|
+
return reject(new Error(`mneme ${command} exited ${code}: ${stderr.slice(0, 500)}`));
|
|
64
|
+
}
|
|
65
|
+
try {
|
|
66
|
+
resolve(JSON.parse(stdout));
|
|
67
|
+
}
|
|
68
|
+
catch (err) {
|
|
69
|
+
reject(new Error(`mneme ${command} returned non-JSON: ${err.message}`));
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
child.on("error", (err) => {
|
|
73
|
+
clearTimeout(timer);
|
|
74
|
+
reject(err);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=_runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_runtime.js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ACvD,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,KAAK,CAAC,IAAI,EAAE,CAAC;YACb,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,OAAO,oBAAoB,IAAI,CAAC,SAAS,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC;QACrF,CAAC,EAAE,IAAI,CAAC,SAAS,IAAI,MAAM,CAAC,CAAC;QAC7B,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;YACzB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,IAAI,IAAI,KAAK,CAAC,EAAE,CAAC;gBACf,OAAO,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,OAAO,WAAW,IAAI,KAAK,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;YACvF,CAAC;YACD,IAAI,CAAC;gBACH,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;YAC9B,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,CAAC,IAAI,KAAK,CAAC,SAAS,OAAO,uBAAwB,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YACrF,CAAC;QACH,CAAC,CAAC,CAAC;QACH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACxB,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mneme.smart_do — the FALLBACK DISPATCHER.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the existing `mneme do "<intent>"` smart-dispatcher. When the AI
|
|
5
|
+
* student can't match the user's request to a specific tool in the catalog,
|
|
6
|
+
* it can fall back here: hand the natural-language intent to Mneme, and
|
|
7
|
+
* Mneme's smart-dispatcher routes it to the appropriate command.
|
|
8
|
+
*
|
|
9
|
+
* Net effect: even niche or unmodelled use cases reach the right command,
|
|
10
|
+
* so the user never feels "AI couldn't help me with that."
|
|
11
|
+
*/
|
|
12
|
+
import type { MnemeTool } from "./_types.js";
|
|
13
|
+
export declare const smartDoTool: MnemeTool;
|
|
14
|
+
//# sourceMappingURL=_smart_do.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_smart_do.d.ts","sourceRoot":"","sources":["../../src/tools/_smart_do.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,eAAO,MAAM,WAAW,EAAE,SAqCzB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mneme.smart_do — the FALLBACK DISPATCHER.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the existing `mneme do "<intent>"` smart-dispatcher. When the AI
|
|
5
|
+
* student can't match the user's request to a specific tool in the catalog,
|
|
6
|
+
* it can fall back here: hand the natural-language intent to Mneme, and
|
|
7
|
+
* Mneme's smart-dispatcher routes it to the appropriate command.
|
|
8
|
+
*
|
|
9
|
+
* Net effect: even niche or unmodelled use cases reach the right command,
|
|
10
|
+
* so the user never feels "AI couldn't help me with that."
|
|
11
|
+
*/
|
|
12
|
+
import { runCliJson } from "./_runtime.js";
|
|
13
|
+
export const smartDoTool = {
|
|
14
|
+
name: "mneme.smart_do",
|
|
15
|
+
category: "meta",
|
|
16
|
+
description: "Fallback dispatcher — give it a NATURAL-LANGUAGE intent, it routes to the appropriate Mneme command and runs it. " +
|
|
17
|
+
"Use this WHEN no specific tool from `mneme.capabilities` matches the user's request, or when the user's intent " +
|
|
18
|
+
"spans multiple commands. Equivalent to running `mneme do '<intent>'` from the CLI. Prefer specific tools when " +
|
|
19
|
+
"possible — this dispatcher is slower because it runs an additional planning step.",
|
|
20
|
+
triggers: [
|
|
21
|
+
"do something I haven't named explicitly",
|
|
22
|
+
"I want X but I don't know which tool",
|
|
23
|
+
],
|
|
24
|
+
inputSchema: {
|
|
25
|
+
type: "object",
|
|
26
|
+
properties: {
|
|
27
|
+
intent: { type: "string", description: "Natural-language description of what the user wants" },
|
|
28
|
+
},
|
|
29
|
+
required: ["intent"],
|
|
30
|
+
},
|
|
31
|
+
handler: async (rt, args) => {
|
|
32
|
+
const intent = String(args["intent"] ?? "");
|
|
33
|
+
if (!intent) {
|
|
34
|
+
return {
|
|
35
|
+
data: {},
|
|
36
|
+
wisdom: "smart_do requires an `intent` string.",
|
|
37
|
+
confidence: { level: "low" },
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
const data = await runCliJson(rt.meta.rootPath, "do", [intent]);
|
|
41
|
+
return {
|
|
42
|
+
data,
|
|
43
|
+
wisdom: "smart_do routed the intent to Mneme's smart-dispatcher. The data shows which command was chosen + its result.",
|
|
44
|
+
followUp: [],
|
|
45
|
+
confidence: { level: "medium" },
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=_smart_do.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_smart_do.js","sourceRoot":"","sources":["../../src/tools/_smart_do.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,CAAC,MAAM,WAAW,GAAc;IACpC,IAAI,EAAE,gBAAgB;IACtB,QAAQ,EAAE,MAAM;IAChB,WAAW,EACT,mHAAmH;QACnH,iHAAiH;QACjH,gHAAgH;QAChH,mFAAmF;IACrF,QAAQ,EAAE;QACR,yCAAyC;QACzC,sCAAsC;KACvC;IACD,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,qDAAqD,EAAE;SAC/F;QACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;KACrB;IACD,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE;QAC1B,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO;gBACL,IAAI,EAAE,EAAE;gBACR,MAAM,EAAE,uCAAuC;gBAC/C,UAAU,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE;aAC7B,CAAC;QACJ,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QAChE,OAAO;YACL,IAAI;YACJ,MAAM,EACJ,+GAA+G;YACjH,QAAQ,EAAE,EAAE;YACZ,UAAU,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE;SAChC,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tool type system — the contract every Mneme tool implements.
|
|
3
|
+
*
|
|
4
|
+
* Design principle: every response carries WISDOM, not just data. AI clients
|
|
5
|
+
* shouldn't need to interpret raw JSON — Mneme pre-digests each finding into
|
|
6
|
+
* a 1-3 sentence narrative the AI can quote (or paraphrase) directly to the
|
|
7
|
+
* user. Citations live in `data`, the human meaning lives in `wisdom`.
|
|
8
|
+
*/
|
|
9
|
+
import type { Tool, CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
10
|
+
import type { git, store, EmbeddingProvider } from "@mneme-ai/core";
|
|
11
|
+
/** Categories for the syllabus tool — AI student reads this index first
|
|
12
|
+
* and learns what kind of question goes to which group of tools. */
|
|
13
|
+
export type ToolCategory = "memory" | "people" | "audit" | "forensics" | "insights" | "quality" | "quant" | "lab" | "meta";
|
|
14
|
+
/** Wrapped response — every tool returns this shape so AI gets data + wisdom
|
|
15
|
+
* + cross-references in one consistent envelope. */
|
|
16
|
+
export interface ToolResponse<TData = unknown> {
|
|
17
|
+
/** Structured data the AI parses + uses */
|
|
18
|
+
data: TData;
|
|
19
|
+
/** 1-3 sentences in plain English explaining what the data means.
|
|
20
|
+
* AI quotes or paraphrases this when answering the user. */
|
|
21
|
+
wisdom: string;
|
|
22
|
+
/** Tool names the AI might call next for deeper context.
|
|
23
|
+
* Example: after `mneme.people.atrophy` → suggest `mneme.people.passport` */
|
|
24
|
+
followUp?: string[];
|
|
25
|
+
/** Confidence + caveats — when to trust this, when to flag heuristic limits */
|
|
26
|
+
confidence?: {
|
|
27
|
+
level: "high" | "medium" | "low";
|
|
28
|
+
notes?: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Runtime context passed to every handler — single source of truth.
|
|
32
|
+
* Built once per MCP server lifetime, reused across all calls. */
|
|
33
|
+
export interface ToolRuntime {
|
|
34
|
+
cwd: string;
|
|
35
|
+
meta: Awaited<ReturnType<typeof git.getRepoMeta>>;
|
|
36
|
+
store: store.MnemeStore;
|
|
37
|
+
embedder: EmbeddingProvider;
|
|
38
|
+
}
|
|
39
|
+
/** A Mneme tool definition — one per CLI command we expose via MCP.
|
|
40
|
+
*
|
|
41
|
+
* description: write it like a good lesson title — *include WHEN to use + examples*.
|
|
42
|
+
* AI tool selection is mostly description-matching; vague descriptions = wrong picks.
|
|
43
|
+
*
|
|
44
|
+
* triggers: example user phrases that should fire this tool. The AI doesn't
|
|
45
|
+
* see triggers directly, but we use them in the syllabus + as anchor for
|
|
46
|
+
* description quality reviews. */
|
|
47
|
+
export interface MnemeTool<TArgs = Record<string, unknown>, TData = unknown> {
|
|
48
|
+
/** MCP tool name — must match `^mneme\.[a-z_]+\.[a-z_]+$` for grouping */
|
|
49
|
+
name: string;
|
|
50
|
+
/** Category for the capabilities syllabus */
|
|
51
|
+
category: ToolCategory;
|
|
52
|
+
/** Rich description: 2-4 sentences. Include WHEN to use + 2-3 example user
|
|
53
|
+
* phrases this should match. The AI picks tools by matching user intent
|
|
54
|
+
* to descriptions, so be specific. */
|
|
55
|
+
description: string;
|
|
56
|
+
/** Example user queries that should trigger this tool. Used for
|
|
57
|
+
* syllabus generation + description-quality review. */
|
|
58
|
+
triggers: string[];
|
|
59
|
+
/** JSON Schema for input parameters */
|
|
60
|
+
inputSchema: Tool["inputSchema"];
|
|
61
|
+
/** Async handler — receives runtime + parsed args */
|
|
62
|
+
handler: (runtime: ToolRuntime, args: TArgs) => Promise<ToolResponse<TData>>;
|
|
63
|
+
}
|
|
64
|
+
/** Convert a wrapped tool response into MCP's expected CallToolResult.
|
|
65
|
+
* We serialise the entire envelope (data + wisdom + followUp + confidence)
|
|
66
|
+
* so the AI sees the full picture in one shot. */
|
|
67
|
+
export declare function toCallResult(r: ToolResponse): CallToolResult;
|
|
68
|
+
/** Convert a thrown error into MCP's expected error result */
|
|
69
|
+
export declare function toErrorResult(message: string): CallToolResult;
|
|
70
|
+
//# sourceMappingURL=_types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_types.d.ts","sourceRoot":"","sources":["../../src/tools/_types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAC/E,OAAO,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAEpE;qEACqE;AACrE,MAAM,MAAM,YAAY,GACpB,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,WAAW,GACX,UAAU,GACV,SAAS,GACT,OAAO,GACP,KAAK,GACL,MAAM,CAAC;AAEX;qDACqD;AACrD,MAAM,WAAW,YAAY,CAAC,KAAK,GAAG,OAAO;IAC3C,2CAA2C;IAC3C,IAAI,EAAE,KAAK,CAAC;IACZ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ool implements.
|
|
3
|
+
*
|
|
4
|
+
* Design principle: every response carries WISDOM, not just data. AI clients
|
|
5
|
+
* shouldn't need to interpret raw JSON — Mneme pre-digests each finding into
|
|
6
|
+
* a 1-3 sentence narrative the AI can quote (or paraphrase) directly to the
|
|
7
|
+
* user. Citations live in `data`, the human meaning lives in `wisdom`.
|
|
8
|
+
*/
|
|
9
|
+
/** Convert a wrapped tool response into MCP's expected CallToolResult.
|
|
10
|
+
* We serialise the entire envelope (data + wisdom + followUp + confidence)
|
|
11
|
+
* so the AI sees the full picture in one shot. */
|
|
12
|
+
export function toCallResult(r) {
|
|
13
|
+
return {
|
|
14
|
+
content: [
|
|
15
|
+
{
|
|
16
|
+
type: "text",
|
|
17
|
+
text: JSON.stringify({
|
|
18
|
+
data: r.data,
|
|
19
|
+
wisdom: r.wisdom,
|
|
20
|
+
followUp: r.followUp ?? [],
|
|
21
|
+
confidence: r.confidence ?? { level: "medium" },
|
|
22
|
+
}, null, 2),
|
|
23
|
+
},
|
|
24
|
+
],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/** Convert a thrown error into MCP's expected error result */
|
|
28
|
+
export function toErrorResult(message) {
|
|
29
|
+
return {
|
|
30
|
+
isError: true,
|
|
31
|
+
content: [{ type: "text", text: message }],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=_types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_types.js","sourceRoot":"","sources":["../../src/tools/_types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAuEH;;mDAEmD;AACnD,MAAM,UAAU,YAAY,CAAC,CAAe;IAC1C,OAAO;QACL,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAClB;oBACE,IAAI,EAAE,CAAC,CAAC,IAAI;oBACZ,MAAM,EAAE,CAAC,CAAC,MAAM;oBAChB,QAAQ,EAAE,CAAC,CAAC,QAAQ,IAAI,EAAE;oBAC1B,UAAU,EAAE,CAAC,CAAC,UAAU,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE;iBAChD,EACD,IAAI,EACJ,CAAC,CACF;aACF;SACF;KACF,CAAC;AACJ,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,aAAa,CAAC,OAAe;IAC3C,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;KAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Session Audit — the trust certificate for every AI-driven commit.
|
|
3
|
+
*
|
|
4
|
+
* Vendor-neutral. Works against any AI tool whose commits land in `git log`.
|
|
5
|
+
* Each tool here is a different "mode" of the audit pipeline.
|
|
6
|
+
*/
|
|
7
|
+
import type { MnemeTool } from "./_types.js";
|
|
8
|
+
export declare const auditTools: MnemeTool[];
|
|
9
|
+
//# sourceMappingURL=audit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.d.ts","sourceRoot":"","sources":["../../src/tools/audit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,eAAO,MAAM,UAAU,EAAE,SAAS,EAsOjC,CAAC"}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AI Session Audit — the trust certificate for every AI-driven commit.
|
|
3
|
+
*
|
|
4
|
+
* Vendor-neutral. Works against any AI tool whose commits land in `git log`.
|
|
5
|
+
* Each tool here is a different "mode" of the audit pipeline.
|
|
6
|
+
*/
|
|
7
|
+
import { runCliJson } from "./_runtime.js";
|
|
8
|
+
export const auditTools = [
|
|
9
|
+
{
|
|
10
|
+
name: "mneme.audit.baseline",
|
|
11
|
+
category: "audit",
|
|
12
|
+
description: "Snapshot the repo's behavior, types, perf, and sample-command outputs BEFORE letting an AI work on it. " +
|
|
13
|
+
"Stores the snapshot in .mneme/audit-baseline.json for later certify-time comparison. " +
|
|
14
|
+
"Use this WHEN: user is about to start an AI-driven coding session and wants a 'before' snapshot to grade against.",
|
|
15
|
+
triggers: [
|
|
16
|
+
"snapshot before AI works",
|
|
17
|
+
"audit baseline",
|
|
18
|
+
"เก็บ baseline ก่อน AI ทำงาน",
|
|
19
|
+
],
|
|
20
|
+
inputSchema: { type: "object", properties: {} },
|
|
21
|
+
handler: async (rt) => {
|
|
22
|
+
const data = await runCliJson(rt.meta.rootPath, "audit", ["--baseline"]);
|
|
23
|
+
return {
|
|
24
|
+
data,
|
|
25
|
+
wisdom: "Baseline captured. Ask user to let their AI work, then run mneme.audit.certify when done to compare.",
|
|
26
|
+
followUp: ["mneme.audit.trace", "mneme.audit.certify"],
|
|
27
|
+
confidence: { level: "high" },
|
|
28
|
+
};
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "mneme.audit.trace",
|
|
33
|
+
category: "audit",
|
|
34
|
+
description: "After AI worked: capture the diff + detect WHICH AI tool produced the commit (Claude Code · Cursor · Codex · Devin · ...). " +
|
|
35
|
+
"Use this WHEN user asks: 'what did the AI just change?', 'which AI tool wrote this commit?', 'show me the AI session trace'.",
|
|
36
|
+
triggers: [
|
|
37
|
+
"what did the AI change?",
|
|
38
|
+
"which AI tool wrote this?",
|
|
39
|
+
"audit trace",
|
|
40
|
+
],
|
|
41
|
+
inputSchema: { type: "object", properties: {} },
|
|
42
|
+
handler: async (rt) => {
|
|
43
|
+
const data = await runCliJson(rt.meta.rootPath, "audit", ["--trace"]);
|
|
44
|
+
return {
|
|
45
|
+
data,
|
|
46
|
+
wisdom: "Trace captured. Use mneme.audit.verify next to check whether the AI's commit message matches the actual diff.",
|
|
47
|
+
followUp: ["mneme.audit.verify", "mneme.audit.certify"],
|
|
48
|
+
confidence: { level: "high" },
|
|
49
|
+
};
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "mneme.audit.verify",
|
|
54
|
+
category: "audit",
|
|
55
|
+
description: "Leviathan-style narrative-vs-reality check: does the AI's commit message ACTUALLY match the diff? " +
|
|
56
|
+
"Catches AI gaslighting (e.g. 'no change to db.ts' but the diff has 3 lines in db.ts). " +
|
|
57
|
+
"Use this WHEN user asks: 'is the AI lying about its changes?', 'verify the commit narrative', 'AI gaslight check'.",
|
|
58
|
+
triggers: [
|
|
59
|
+
"is the AI lying?",
|
|
60
|
+
"verify commit narrative",
|
|
61
|
+
"AI gaslight check",
|
|
62
|
+
],
|
|
63
|
+
inputSchema: { type: "object", properties: {} },
|
|
64
|
+
handler: async (rt) => {
|
|
65
|
+
const data = await runCliJson(rt.meta.rootPath, "audit", ["--verify"]);
|
|
66
|
+
return {
|
|
67
|
+
data,
|
|
68
|
+
wisdom: "Verification complete. If contradictions are found, escalate to mneme.audit.certify for the full trust certificate.",
|
|
69
|
+
followUp: ["mneme.audit.certify"],
|
|
70
|
+
confidence: { level: "high" },
|
|
71
|
+
};
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "mneme.audit.certify",
|
|
76
|
+
category: "audit",
|
|
77
|
+
description: "The flagship: 5-axis trust certificate for an AI commit (behavioral parity · API contract · test pass rate · perf · narrative match). " +
|
|
78
|
+
"Plus forensic axes (TIME / FILES / STYLE / SIZE). Returns PASS / WARN / FAIL with structured findings. " +
|
|
79
|
+
"Use this WHEN user asks: 'is this commit safe?', 'grade the AI's homework', 'CI gate the AI commit', " +
|
|
80
|
+
"'final trust certificate', 'should I merge this?'.",
|
|
81
|
+
triggers: [
|
|
82
|
+
"grade the AI commit",
|
|
83
|
+
"is this commit safe to merge?",
|
|
84
|
+
"trust certificate",
|
|
85
|
+
"audit certify",
|
|
86
|
+
],
|
|
87
|
+
inputSchema: {
|
|
88
|
+
type: "object",
|
|
89
|
+
properties: {
|
|
90
|
+
explain: { type: "boolean", description: "Add plain-English narrative summary" },
|
|
91
|
+
strict: { type: "boolean", description: "Treat skipped axes as fail (compliance mode)" },
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
handler: async (rt, args) => {
|
|
95
|
+
const cliArgs = ["--certify"];
|
|
96
|
+
if (args["explain"])
|
|
97
|
+
cliArgs.push("--explain");
|
|
98
|
+
if (args["strict"])
|
|
99
|
+
cliArgs.push("--strict");
|
|
100
|
+
const data = await runCliJson(rt.meta.rootPath, "audit", cliArgs);
|
|
101
|
+
const verdict = data?.verdict ?? "unknown";
|
|
102
|
+
const wisdom = verdict === "PASS"
|
|
103
|
+
? "AI commit PASSED all 5 axes — safe to merge."
|
|
104
|
+
: verdict === "WARN"
|
|
105
|
+
? "AI commit has WARNINGS — review the flagged axes before merging."
|
|
106
|
+
: verdict === "FAIL"
|
|
107
|
+
? "AI commit FAILED — do NOT merge until issues are resolved. See findings array for details."
|
|
108
|
+
: "Audit completed; check the data field for the verdict.";
|
|
109
|
+
return {
|
|
110
|
+
data,
|
|
111
|
+
wisdom,
|
|
112
|
+
followUp: verdict !== "PASS" ? ["mneme.audit.report", "mneme.forensics.vulns"] : [],
|
|
113
|
+
confidence: { level: "high" },
|
|
114
|
+
};
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
name: "mneme.audit.report",
|
|
119
|
+
category: "audit",
|
|
120
|
+
description: "Generate a Markdown audit-trail report (SOX / SOC2 / EU AI Act 2026 compliant) of the most recent AI session. " +
|
|
121
|
+
"Use this WHEN user asks: 'export audit report', 'compliance trail', 'markdown for the auditor'.",
|
|
122
|
+
triggers: [
|
|
123
|
+
"compliance audit report",
|
|
124
|
+
"markdown audit trail",
|
|
125
|
+
"export for SOC2",
|
|
126
|
+
],
|
|
127
|
+
inputSchema: {
|
|
128
|
+
type: "object",
|
|
129
|
+
properties: {
|
|
130
|
+
outPath: { type: "string", description: "Where to write the markdown" },
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
handler: async (rt, args) => {
|
|
134
|
+
const cliArgs = ["--report"];
|
|
135
|
+
if (args["outPath"])
|
|
136
|
+
cliArgs.push("--out", String(args["outPath"]));
|
|
137
|
+
const data = await runCliJson(rt.meta.rootPath, "audit", cliArgs);
|
|
138
|
+
return {
|
|
139
|
+
data,
|
|
140
|
+
wisdom: `Markdown report generated. Compliance-ready for SOX / SOC2 / EU AI Act 2026.`,
|
|
141
|
+
followUp: [],
|
|
142
|
+
confidence: { level: "high" },
|
|
143
|
+
};
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: "mneme.audit.deps",
|
|
148
|
+
category: "audit",
|
|
149
|
+
description: "Cross-check this repo's dependencies against OSV.dev — known CVEs and GHSA advisories per package. " +
|
|
150
|
+
"Use this WHEN user asks: 'are our deps safe?', 'CVE scan', 'OSV check', 'security audit of dependencies', " +
|
|
151
|
+
"'do we have vulnerable packages?'.",
|
|
152
|
+
triggers: [
|
|
153
|
+
"scan dependencies for CVEs",
|
|
154
|
+
"OSV check",
|
|
155
|
+
"are our deps safe?",
|
|
156
|
+
],
|
|
157
|
+
inputSchema: { type: "object", properties: {} },
|
|
158
|
+
handler: async (rt) => {
|
|
159
|
+
const data = await runCliJson(rt.meta.rootPath, "deps", ["audit"]);
|
|
160
|
+
const advisories = data?.advisories?.length ?? 0;
|
|
161
|
+
const wisdom = advisories === 0
|
|
162
|
+
? "No known CVEs or GHSAs in current dependency tree."
|
|
163
|
+
: `${advisories} advisor${advisories === 1 ? "y" : "ies"} found across the dependency tree. Check the data.advisories array for severity + fixed-in versions.`;
|
|
164
|
+
return {
|
|
165
|
+
data,
|
|
166
|
+
wisdom,
|
|
167
|
+
followUp: advisories > 0 ? ["mneme.forensics.vulns"] : [],
|
|
168
|
+
confidence: { level: "high" },
|
|
169
|
+
};
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
name: "mneme.audit.conscience",
|
|
174
|
+
category: "audit",
|
|
175
|
+
description: "Risk-score a PR against the repo's own history of regrets, hotfixes, and reverts. " +
|
|
176
|
+
"Use this WHEN user asks: 'is this PR risky based on history?', 'conscience review of these files', " +
|
|
177
|
+
"'historical risk score for the changes'.",
|
|
178
|
+
triggers: [
|
|
179
|
+
"PR risk based on history",
|
|
180
|
+
"conscience review",
|
|
181
|
+
"ตรวจ PR ตามประวัติ",
|
|
182
|
+
],
|
|
183
|
+
inputSchema: {
|
|
184
|
+
type: "object",
|
|
185
|
+
properties: {
|
|
186
|
+
files: { type: "array", items: { type: "string" }, description: "File paths to review" },
|
|
187
|
+
dualJury: { type: "boolean", description: "Run with dual-jury (more conservative)" },
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
handler: async (rt, args) => {
|
|
191
|
+
const files = args["files"] ?? [];
|
|
192
|
+
const cliArgs = files.length ? files : [];
|
|
193
|
+
if (args["dualJury"])
|
|
194
|
+
cliArgs.push("--dual-jury");
|
|
195
|
+
const data = await runCliJson(rt.meta.rootPath, "conscience", cliArgs);
|
|
196
|
+
const risk = data?.risk ?? "unknown";
|
|
197
|
+
const wisdom = `Conscience risk verdict: ${risk}. Based on similar past changes in this repo.`;
|
|
198
|
+
return {
|
|
199
|
+
data,
|
|
200
|
+
wisdom,
|
|
201
|
+
followUp: risk === "HIGH" ? ["mneme.insights.premortem", "mneme.audit.certify"] : [],
|
|
202
|
+
confidence: { level: "medium" },
|
|
203
|
+
};
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: "mneme.audit.ledger",
|
|
208
|
+
category: "audit",
|
|
209
|
+
description: "Tamper-evident audit log of all AI-driven commits with HMAC + Ed25519 signatures. SOX / SOC2 ready. " +
|
|
210
|
+
"Use this WHEN user asks: 'show audit log', 'tamper-evident trail', 'all AI sessions in this repo'.",
|
|
211
|
+
triggers: [
|
|
212
|
+
"audit log of AI sessions",
|
|
213
|
+
"tamper-evident trail",
|
|
214
|
+
],
|
|
215
|
+
inputSchema: {
|
|
216
|
+
type: "object",
|
|
217
|
+
properties: {
|
|
218
|
+
since: { type: "string", description: "ISO date — only entries since" },
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
handler: async (rt, args) => {
|
|
222
|
+
const cliArgs = args["since"] ? ["--since", String(args["since"])] : [];
|
|
223
|
+
const data = await runCliJson(rt.meta.rootPath, "ledger", cliArgs);
|
|
224
|
+
return {
|
|
225
|
+
data,
|
|
226
|
+
wisdom: "Audit ledger entries returned. Each entry is HMAC-chained + Ed25519-signed for tamper-evidence.",
|
|
227
|
+
followUp: ["mneme.audit.report"],
|
|
228
|
+
confidence: { level: "high" },
|
|
229
|
+
};
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
];
|
|
233
|
+
//# sourceMappingURL=audit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/tools/audit.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG3C,MAAM,CAAC,MAAM,UAAU,GAAgB;IACrC;QACE,IAAI,EAAE,sBAAsB;QAC5B,QAAQ,EAAE,OAAO;QACjB,WAAW,EACT,yGAAyG;YACzG,uFAAuF;YACvF,mHAAmH;QACrH,QAAQ,EAAE;YACR,0BAA0B;YAC1B,gBAAgB;YAChB,6BAA6B;SAC9B;QACD,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,EAAE;QAC/C,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE;YACpB,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,OAAO,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;YACzE,OAAO;gBACL,IAAI;gBACJ,MAAM,EAAE,sGAAsG;gBAC9G,QAAQ,EAAE,CAAC,mBA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QAAQ,EAAE,OAAO,CAAC,CAAC;YACnE,OAAO;gBACL,IAAI;gBACJ,MAAM,EAAE,iGAAiG;gBACzG,QAAQ,EAAE,CAAC,oBAAoB,CAAC;gBAChC,UAAU,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE;aAC9B,CAAC;QACJ,CAAC;KACF;CACF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Forensics — applied forensic science for code: Bayesian author attribution,
|
|
3
|
+
* stack-aware vuln hunt, insider-threat anomaly, ENFSI verbal scale.
|
|
4
|
+
*/
|
|
5
|
+
import type { MnemeTool } from "./_types.js";
|
|
6
|
+
export declare const forensicsTools: MnemeTool[];
|
|
7
|
+
//# sourceMappingURL=forensics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"forensics.d.ts","sourceRoot":"","sources":["../../src/tools/forensics.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,eAAO,MAAM,cAAc,EAAE,SAAS,EA2LrC,CAAC"}
|