memax-cli 0.1.0-alpha.4 ā 0.1.0-alpha.40
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/assets/skills/memax-memory/SKILL.md +154 -0
- package/dist/commands/agent-sessions.d.ts +62 -0
- package/dist/commands/agent-sessions.d.ts.map +1 -0
- package/dist/commands/agent-sessions.js +1338 -0
- package/dist/commands/agent-sessions.js.map +1 -0
- package/dist/commands/agent-sessions.test.d.ts +2 -0
- package/dist/commands/agent-sessions.test.d.ts.map +1 -0
- package/dist/commands/agent-sessions.test.js +255 -0
- package/dist/commands/agent-sessions.test.js.map +1 -0
- package/dist/commands/agents.d.ts +3 -0
- package/dist/commands/agents.d.ts.map +1 -0
- package/dist/commands/agents.js +36 -0
- package/dist/commands/agents.js.map +1 -0
- package/dist/commands/auth.d.ts +3 -0
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +38 -7
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/capture.d.ts +19 -0
- package/dist/commands/capture.d.ts.map +1 -0
- package/dist/commands/capture.js +69 -0
- package/dist/commands/capture.js.map +1 -0
- package/dist/commands/config.d.ts +2 -0
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +13 -0
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/delete.d.ts +3 -1
- package/dist/commands/delete.d.ts.map +1 -1
- package/dist/commands/delete.js +30 -5
- package/dist/commands/delete.js.map +1 -1
- package/dist/commands/dreams.d.ts +22 -0
- package/dist/commands/dreams.d.ts.map +1 -0
- package/dist/commands/dreams.js +205 -0
- package/dist/commands/dreams.js.map +1 -0
- package/dist/commands/dreams.test.d.ts +2 -0
- package/dist/commands/dreams.test.d.ts.map +1 -0
- package/dist/commands/dreams.test.js +39 -0
- package/dist/commands/dreams.test.js.map +1 -0
- package/dist/commands/hook.d.ts +2 -0
- package/dist/commands/hook.d.ts.map +1 -1
- package/dist/commands/hook.js +6 -0
- package/dist/commands/hook.js.map +1 -1
- package/dist/commands/hub.d.ts +31 -0
- package/dist/commands/hub.d.ts.map +1 -0
- package/dist/commands/hub.js +295 -0
- package/dist/commands/hub.js.map +1 -0
- package/dist/commands/hub.test.d.ts +2 -0
- package/dist/commands/hub.test.d.ts.map +1 -0
- package/dist/commands/hub.test.js +62 -0
- package/dist/commands/hub.test.js.map +1 -0
- package/dist/commands/list.d.ts +8 -1
- package/dist/commands/list.d.ts.map +1 -1
- package/dist/commands/list.js +110 -9
- package/dist/commands/list.js.map +1 -1
- package/dist/commands/list.test.d.ts +2 -0
- package/dist/commands/list.test.d.ts.map +1 -0
- package/dist/commands/list.test.js +14 -0
- package/dist/commands/list.test.js.map +1 -0
- package/dist/commands/login.d.ts +2 -0
- package/dist/commands/login.d.ts.map +1 -1
- package/dist/commands/login.js +50 -19
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +285 -42
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/push.d.ts +6 -1
- package/dist/commands/push.d.ts.map +1 -1
- package/dist/commands/push.js +73 -11
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/recall.d.ts +9 -0
- package/dist/commands/recall.d.ts.map +1 -1
- package/dist/commands/recall.js +206 -39
- package/dist/commands/recall.js.map +1 -1
- package/dist/commands/recall.test.d.ts +2 -0
- package/dist/commands/recall.test.d.ts.map +1 -0
- package/dist/commands/recall.test.js +31 -0
- package/dist/commands/recall.test.js.map +1 -0
- package/dist/commands/setup-hooks.d.ts +12 -0
- package/dist/commands/setup-hooks.d.ts.map +1 -0
- package/dist/commands/setup-hooks.js +193 -0
- package/dist/commands/setup-hooks.js.map +1 -0
- package/dist/commands/setup-instructions.d.ts +21 -0
- package/dist/commands/setup-instructions.d.ts.map +1 -0
- package/dist/commands/setup-instructions.js +172 -0
- package/dist/commands/setup-instructions.js.map +1 -0
- package/dist/commands/setup-mcp.d.ts +14 -0
- package/dist/commands/setup-mcp.d.ts.map +1 -0
- package/dist/commands/setup-mcp.js +288 -0
- package/dist/commands/setup-mcp.js.map +1 -0
- package/dist/commands/setup-types.d.ts +20 -0
- package/dist/commands/setup-types.d.ts.map +1 -0
- package/dist/commands/setup-types.js +60 -0
- package/dist/commands/setup-types.js.map +1 -0
- package/dist/commands/setup.d.ts +8 -1
- package/dist/commands/setup.d.ts.map +1 -1
- package/dist/commands/setup.js +163 -307
- package/dist/commands/setup.js.map +1 -1
- package/dist/commands/show.d.ts +2 -0
- package/dist/commands/show.d.ts.map +1 -1
- package/dist/commands/show.js +25 -13
- package/dist/commands/show.js.map +1 -1
- package/dist/commands/sync.d.ts +47 -2
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +1299 -119
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/sync.test.d.ts +2 -0
- package/dist/commands/sync.test.d.ts.map +1 -0
- package/dist/commands/sync.test.js +130 -0
- package/dist/commands/sync.test.js.map +1 -0
- package/dist/commands/topic.d.ts +32 -0
- package/dist/commands/topic.d.ts.map +1 -0
- package/dist/commands/topic.js +223 -0
- package/dist/commands/topic.js.map +1 -0
- package/dist/commands/topic.test.d.ts +2 -0
- package/dist/commands/topic.test.d.ts.map +1 -0
- package/dist/commands/topic.test.js +114 -0
- package/dist/commands/topic.test.js.map +1 -0
- package/dist/index.js +33 -125
- package/dist/index.js.map +1 -1
- package/dist/lib/client.d.ts +9 -0
- package/dist/lib/client.d.ts.map +1 -0
- package/dist/lib/client.js +77 -0
- package/dist/lib/client.js.map +1 -0
- package/dist/lib/config.d.ts +45 -0
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +74 -1
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/hubs.d.ts +7 -0
- package/dist/lib/hubs.d.ts.map +1 -0
- package/dist/lib/hubs.js +33 -0
- package/dist/lib/hubs.js.map +1 -0
- package/dist/lib/hubs.test.d.ts +2 -0
- package/dist/lib/hubs.test.d.ts.map +1 -0
- package/dist/lib/hubs.test.js +57 -0
- package/dist/lib/hubs.test.js.map +1 -0
- package/dist/lib/project-context.d.ts +56 -0
- package/dist/lib/project-context.d.ts.map +1 -0
- package/dist/lib/project-context.js +231 -0
- package/dist/lib/project-context.js.map +1 -0
- package/dist/lib/project-context.test.d.ts +2 -0
- package/dist/lib/project-context.test.d.ts.map +1 -0
- package/dist/lib/project-context.test.js +75 -0
- package/dist/lib/project-context.test.js.map +1 -0
- package/dist/lib/prompt.d.ts +7 -0
- package/dist/lib/prompt.d.ts.map +1 -0
- package/dist/lib/prompt.js +41 -0
- package/dist/lib/prompt.js.map +1 -0
- package/dist/lib/trash.d.ts +6 -0
- package/dist/lib/trash.d.ts.map +1 -0
- package/dist/lib/trash.js +28 -0
- package/dist/lib/trash.js.map +1 -0
- package/package.json +17 -13
- package/.vscode/mcp.json +0 -8
- package/dist/lib/api.d.ts +0 -4
- package/dist/lib/api.d.ts.map +0 -1
- package/dist/lib/api.js +0 -95
- package/dist/lib/api.js.map +0 -1
- package/src/commands/auth.ts +0 -92
- package/src/commands/config.ts +0 -27
- package/src/commands/delete.ts +0 -20
- package/src/commands/hook.ts +0 -243
- package/src/commands/list.ts +0 -38
- package/src/commands/login.ts +0 -162
- package/src/commands/mcp.ts +0 -357
- package/src/commands/push.ts +0 -82
- package/src/commands/recall.ts +0 -163
- package/src/commands/setup.ts +0 -682
- package/src/commands/show.ts +0 -35
- package/src/commands/sync.ts +0 -403
- package/src/index.ts +0 -192
- package/src/lib/api.ts +0 -110
- package/src/lib/config.ts +0 -61
- package/src/lib/credentials.ts +0 -42
- package/tsconfig.json +0 -9
package/dist/commands/login.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { createServer } from "node:http";
|
|
2
|
-
import {
|
|
2
|
+
import { getActiveHubID } from "../lib/config.js";
|
|
3
|
+
import { getPublicClient } from "../lib/client.js";
|
|
3
4
|
import { saveCredentials } from "../lib/credentials.js";
|
|
4
5
|
export async function loginCommand() {
|
|
5
|
-
const config = loadConfig();
|
|
6
|
-
const apiUrl = config.api_url;
|
|
7
6
|
// Start a temporary local server to receive the OAuth callback
|
|
8
7
|
const port = await findFreePort();
|
|
9
8
|
const callbackUrl = `http://localhost:${port}/callback`;
|
|
@@ -15,13 +14,8 @@ export async function loginCommand() {
|
|
|
15
14
|
if (code) {
|
|
16
15
|
// Exchange the one-time code for tokens via POST
|
|
17
16
|
try {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
headers: { "Content-Type": "application/json" },
|
|
21
|
-
body: JSON.stringify({ code }),
|
|
22
|
-
});
|
|
23
|
-
const json = (await exchangeRes.json());
|
|
24
|
-
if (json.data) {
|
|
17
|
+
const tokens = await getPublicClient().auth.exchangeCode(code);
|
|
18
|
+
if (tokens.access_token) {
|
|
25
19
|
res.writeHead(200, { "Content-Type": "text/html" });
|
|
26
20
|
res.end(`
|
|
27
21
|
<html><body style="font-family: system-ui; display: flex; align-items: center; justify-content: center; height: 100vh; margin: 0;">
|
|
@@ -31,12 +25,12 @@ export async function loginCommand() {
|
|
|
31
25
|
</div>
|
|
32
26
|
</body></html>
|
|
33
27
|
`);
|
|
34
|
-
resolve(
|
|
28
|
+
resolve(tokens);
|
|
35
29
|
}
|
|
36
30
|
else {
|
|
37
31
|
res.writeHead(400, { "Content-Type": "text/html" });
|
|
38
|
-
res.end(
|
|
39
|
-
reject(new Error(
|
|
32
|
+
res.end("<html><body><h2>Login failed</h2><p>Token exchange failed.</p></body></html>");
|
|
33
|
+
reject(new Error("Token exchange failed."));
|
|
40
34
|
}
|
|
41
35
|
}
|
|
42
36
|
catch (err) {
|
|
@@ -58,14 +52,16 @@ export async function loginCommand() {
|
|
|
58
52
|
}
|
|
59
53
|
});
|
|
60
54
|
server.listen(port);
|
|
61
|
-
// Timeout after 2 minutes
|
|
62
|
-
setTimeout(() => {
|
|
55
|
+
// Timeout after 2 minutes ā use unref() so it doesn't keep the process alive
|
|
56
|
+
const timeout = setTimeout(() => {
|
|
63
57
|
server.close();
|
|
58
|
+
server.closeAllConnections();
|
|
64
59
|
reject(new Error("Login timed out ā no callback received within 2 minutes."));
|
|
65
60
|
}, 120_000);
|
|
61
|
+
timeout.unref();
|
|
66
62
|
});
|
|
67
63
|
// Build the GitHub OAuth URL with our local callback as the redirect
|
|
68
|
-
const authUrl =
|
|
64
|
+
const authUrl = getPublicClient().auth.githubLoginURL(callbackUrl);
|
|
69
65
|
console.log("\n Opening browser for GitHub login...\n");
|
|
70
66
|
console.log(` If the browser doesn't open, visit:\n ${authUrl}\n`);
|
|
71
67
|
// Try to open the browser
|
|
@@ -102,20 +98,55 @@ export async function logoutCommand() {
|
|
|
102
98
|
}
|
|
103
99
|
export async function whoamiCommand() {
|
|
104
100
|
const { loadCredentials } = await import("../lib/credentials.js");
|
|
105
|
-
const {
|
|
101
|
+
const { getClient } = await import("../lib/client.js");
|
|
102
|
+
const chalk = (await import("chalk")).default;
|
|
106
103
|
const creds = loadCredentials();
|
|
107
104
|
if (!creds?.access_token) {
|
|
108
105
|
console.log(" Not logged in. Run: memax login\n");
|
|
109
106
|
return;
|
|
110
107
|
}
|
|
111
108
|
try {
|
|
112
|
-
const
|
|
113
|
-
|
|
109
|
+
const me = await getClient().auth.me();
|
|
110
|
+
const u = me.user;
|
|
111
|
+
console.log();
|
|
112
|
+
console.log(` ${chalk.bold(u.display_name || u.name)} ${chalk.dim(`(${u.email})`)}`);
|
|
113
|
+
console.log(` Plan: ${chalk.cyan(u.plan)}`);
|
|
114
|
+
// Active read hub (client-local)
|
|
115
|
+
const activeHubID = getActiveHubID();
|
|
116
|
+
if (me.hubs && me.hubs.length > 0 && activeHubID) {
|
|
117
|
+
const active = me.hubs.find((h) => h.hub.id === activeHubID);
|
|
118
|
+
if (active) {
|
|
119
|
+
const typeTag = active.hub.hub_type === "personal" ? "" : chalk.dim(" (team)");
|
|
120
|
+
console.log(` Read hub: ${active.hub.name}${typeTag}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// Usage this period
|
|
124
|
+
if (me.usage &&
|
|
125
|
+
(me.usage.push_count > 0 ||
|
|
126
|
+
me.usage.recall_count > 0 ||
|
|
127
|
+
me.usage.ask_count > 0)) {
|
|
128
|
+
console.log(` Usage: ${me.usage.push_count} pushes, ${me.usage.recall_count} recalls, ${me.usage.ask_count} asks`);
|
|
129
|
+
}
|
|
130
|
+
console.log();
|
|
114
131
|
}
|
|
115
132
|
catch {
|
|
116
133
|
console.log(" Session expired or invalid. Run: memax login\n");
|
|
117
134
|
}
|
|
118
135
|
}
|
|
136
|
+
export function registerLoginCommands(program) {
|
|
137
|
+
program
|
|
138
|
+
.command("login")
|
|
139
|
+
.description("Log in to Memax via GitHub")
|
|
140
|
+
.action(loginCommand);
|
|
141
|
+
program
|
|
142
|
+
.command("logout")
|
|
143
|
+
.description("Clear saved credentials")
|
|
144
|
+
.action(logoutCommand);
|
|
145
|
+
program
|
|
146
|
+
.command("whoami")
|
|
147
|
+
.description("Show current user")
|
|
148
|
+
.action(whoamiCommand);
|
|
149
|
+
}
|
|
119
150
|
async function findFreePort() {
|
|
120
151
|
return new Promise((resolve) => {
|
|
121
152
|
const server = createServer();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/commands/login.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAc,MAAM,kBAAkB,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAQxD,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,+DAA+D;IAC/D,MAAM,IAAI,GAAG,MAAM,YAAY,EAAE,CAAC;IAClC,MAAM,WAAW,GAAG,oBAAoB,IAAI,WAAW,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K,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/commands/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/commands/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkkBpC,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAUzD"}
|
package/dist/commands/mcp.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
2
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
3
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
-
import {
|
|
5
|
-
function createServer() {
|
|
4
|
+
import { getClient } from "../lib/client.js";
|
|
5
|
+
function createServer(agentId = "") {
|
|
6
6
|
const server = new Server({ name: "memax", version: "0.0.1" }, { capabilities: { tools: {} } });
|
|
7
7
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
8
8
|
tools: [
|
|
@@ -26,6 +26,10 @@ function createServer() {
|
|
|
26
26
|
type: "string",
|
|
27
27
|
description: "Filter by category prefix (e.g. 'core', 'decisions', 'process')",
|
|
28
28
|
},
|
|
29
|
+
project_context: {
|
|
30
|
+
type: "object",
|
|
31
|
+
description: "Current project context for relevance boosting. Keys: repo (git remote URL), project (short name).",
|
|
32
|
+
},
|
|
29
33
|
},
|
|
30
34
|
required: ["query"],
|
|
31
35
|
},
|
|
@@ -45,6 +49,10 @@ function createServer() {
|
|
|
45
49
|
type: "string",
|
|
46
50
|
description: "Optional title (auto-generated if omitted)",
|
|
47
51
|
},
|
|
52
|
+
hint: {
|
|
53
|
+
type: "string",
|
|
54
|
+
description: "Context hint to help AI process this memory (e.g. 'This is my resume', 'Meeting notes from product review'). Improves categorization, summarization, and retrieval.",
|
|
55
|
+
},
|
|
48
56
|
category: {
|
|
49
57
|
type: "string",
|
|
50
58
|
description: "Category (e.g. 'decisions/adr', 'core/architecture'). Auto-detected if omitted.",
|
|
@@ -54,20 +62,32 @@ function createServer() {
|
|
|
54
62
|
items: { type: "string" },
|
|
55
63
|
description: "Tags for the memory",
|
|
56
64
|
},
|
|
65
|
+
project_context: {
|
|
66
|
+
type: "object",
|
|
67
|
+
description: "Project context (auto-detected by CLI). Keys: repo (git remote URL), project (short name), branch.",
|
|
68
|
+
},
|
|
69
|
+
hub_id: {
|
|
70
|
+
type: "string",
|
|
71
|
+
description: "Target hub ID. Required when pushing into a team hub.",
|
|
72
|
+
},
|
|
73
|
+
hub_reason: {
|
|
74
|
+
type: "string",
|
|
75
|
+
description: "Why this belongs in the shared hub. Required when hub_id targets a team hub.",
|
|
76
|
+
},
|
|
57
77
|
},
|
|
58
78
|
required: ["content"],
|
|
59
79
|
},
|
|
60
80
|
},
|
|
61
81
|
{
|
|
62
82
|
name: "memax_get",
|
|
63
|
-
description: "Get the full content of a specific
|
|
83
|
+
description: "Get the full content of a specific memory by ID. " +
|
|
64
84
|
"Use this after memax_recall to read the complete content of a relevant memory.",
|
|
65
85
|
inputSchema: {
|
|
66
86
|
type: "object",
|
|
67
87
|
properties: {
|
|
68
88
|
id: {
|
|
69
89
|
type: "string",
|
|
70
|
-
description: "The
|
|
90
|
+
description: "The memory ID (from memax_recall or memax_search results)",
|
|
71
91
|
},
|
|
72
92
|
},
|
|
73
93
|
required: ["id"],
|
|
@@ -75,9 +95,7 @@ function createServer() {
|
|
|
75
95
|
},
|
|
76
96
|
{
|
|
77
97
|
name: "memax_search",
|
|
78
|
-
description: "List
|
|
79
|
-
"For browsing and structured lookups, not semantic search. " +
|
|
80
|
-
"Use memax_recall for natural language queries instead.",
|
|
98
|
+
description: "List memories filtered by category. Supports pagination ā use cursor from previous response for next page. Returns total count.",
|
|
81
99
|
inputSchema: {
|
|
82
100
|
type: "object",
|
|
83
101
|
properties: {
|
|
@@ -87,7 +105,73 @@ function createServer() {
|
|
|
87
105
|
},
|
|
88
106
|
limit: {
|
|
89
107
|
type: "number",
|
|
90
|
-
description: "Max results to return (default
|
|
108
|
+
description: "Max results to return (default 20, max 50)",
|
|
109
|
+
},
|
|
110
|
+
cursor: {
|
|
111
|
+
type: "string",
|
|
112
|
+
description: "Pagination cursor from previous response (omit for first page)",
|
|
113
|
+
},
|
|
114
|
+
sort: {
|
|
115
|
+
type: "string",
|
|
116
|
+
description: "Sort by: newest (default) or relevant",
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: "memax_forget",
|
|
123
|
+
description: "Delete a memory from the user's Memax knowledge base by ID. " +
|
|
124
|
+
"Use this to remove outdated, incorrect, or duplicate memories.",
|
|
125
|
+
inputSchema: {
|
|
126
|
+
type: "object",
|
|
127
|
+
properties: {
|
|
128
|
+
id: {
|
|
129
|
+
type: "string",
|
|
130
|
+
description: "The memory ID to delete (from memax_recall or memax_search results)",
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
required: ["id"],
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: "memax_capture",
|
|
138
|
+
description: "Capture key decisions, learnings, and context from this session. " +
|
|
139
|
+
"Call at the end of a significant work session to save what was accomplished " +
|
|
140
|
+
"and what should be remembered. Each fact is extracted and stored as a separate searchable memory.",
|
|
141
|
+
inputSchema: {
|
|
142
|
+
type: "object",
|
|
143
|
+
properties: {
|
|
144
|
+
summary: {
|
|
145
|
+
type: "string",
|
|
146
|
+
description: "Brief summary of what was accomplished in this session",
|
|
147
|
+
},
|
|
148
|
+
decisions: {
|
|
149
|
+
type: "array",
|
|
150
|
+
items: { type: "string" },
|
|
151
|
+
description: "Key decisions made (e.g., 'Chose PostgreSQL over MongoDB')",
|
|
152
|
+
},
|
|
153
|
+
learnings: {
|
|
154
|
+
type: "array",
|
|
155
|
+
items: { type: "string" },
|
|
156
|
+
description: "Things learned (e.g., 'pg_trgm is language-agnostic')",
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
required: ["summary"],
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: "memax_topics",
|
|
164
|
+
description: "Browse the user's knowledge topics. Without topic_id: returns full topic tree with memory counts. With topic_id: returns memories in that topic.",
|
|
165
|
+
inputSchema: {
|
|
166
|
+
type: "object",
|
|
167
|
+
properties: {
|
|
168
|
+
topic_id: {
|
|
169
|
+
type: "string",
|
|
170
|
+
description: "Topic ID to browse. Omit for full tree.",
|
|
171
|
+
},
|
|
172
|
+
hub_id: {
|
|
173
|
+
type: "string",
|
|
174
|
+
description: "Hub ID to scope topics.",
|
|
91
175
|
},
|
|
92
176
|
},
|
|
93
177
|
},
|
|
@@ -100,25 +184,31 @@ function createServer() {
|
|
|
100
184
|
case "memax_recall": {
|
|
101
185
|
const typedArgs = args;
|
|
102
186
|
try {
|
|
103
|
-
const result = await
|
|
104
|
-
query: typedArgs.query,
|
|
187
|
+
const result = await getClient().recall(typedArgs.query, {
|
|
105
188
|
limit: typedArgs.limit ?? 5,
|
|
106
189
|
category: typedArgs.category ?? "",
|
|
107
190
|
source: "mcp",
|
|
108
|
-
|
|
191
|
+
workingDir: process.cwd(),
|
|
192
|
+
projectContext: typedArgs.project_context,
|
|
109
193
|
});
|
|
110
|
-
const
|
|
111
|
-
if (
|
|
194
|
+
const memories = result.memories ?? [];
|
|
195
|
+
if (memories.length === 0) {
|
|
112
196
|
return {
|
|
113
197
|
content: [{ type: "text", text: "No results found." }],
|
|
114
198
|
};
|
|
115
199
|
}
|
|
116
|
-
const formatted =
|
|
117
|
-
.map((
|
|
118
|
-
const score = (
|
|
119
|
-
const heading =
|
|
120
|
-
|
|
121
|
-
|
|
200
|
+
const formatted = memories
|
|
201
|
+
.map((m, i) => {
|
|
202
|
+
const score = (m.relevance_score * 100).toFixed(0);
|
|
203
|
+
const heading = m.heading_chain ? ` ā ${m.heading_chain}` : "";
|
|
204
|
+
const parts = [
|
|
205
|
+
`[${i + 1}] ${m.title} [${m.category}, ${score}%, ${m.age}] (id: ${m.id})${heading}`,
|
|
206
|
+
];
|
|
207
|
+
if (m.summary) {
|
|
208
|
+
parts.push(`Summary: ${m.summary}`);
|
|
209
|
+
}
|
|
210
|
+
parts.push(`Relevant excerpt:\n${m.chunk_content}`);
|
|
211
|
+
return parts.join("\n");
|
|
122
212
|
})
|
|
123
213
|
.join("\n\n");
|
|
124
214
|
return { content: [{ type: "text", text: formatted }] };
|
|
@@ -138,18 +228,22 @@ function createServer() {
|
|
|
138
228
|
case "memax_push": {
|
|
139
229
|
const typedArgs = args;
|
|
140
230
|
try {
|
|
141
|
-
const
|
|
142
|
-
content: typedArgs.content,
|
|
231
|
+
const memory = await getClient().push(typedArgs.content, {
|
|
143
232
|
title: typedArgs.title ?? "",
|
|
233
|
+
hint: typedArgs.hint ?? "",
|
|
144
234
|
category: typedArgs.category ?? "",
|
|
145
235
|
tags: typedArgs.tags ?? [],
|
|
146
236
|
source: "mcp",
|
|
237
|
+
sourceAgent: agentId,
|
|
238
|
+
projectContext: typedArgs.project_context,
|
|
239
|
+
hubId: typedArgs.hub_id,
|
|
240
|
+
hubReason: typedArgs.hub_reason,
|
|
147
241
|
});
|
|
148
242
|
return {
|
|
149
243
|
content: [
|
|
150
244
|
{
|
|
151
245
|
type: "text",
|
|
152
|
-
text: `Saved: ${
|
|
246
|
+
text: `Saved: ${memory.title} (id: ${memory.id})`,
|
|
153
247
|
},
|
|
154
248
|
],
|
|
155
249
|
};
|
|
@@ -169,21 +263,21 @@ function createServer() {
|
|
|
169
263
|
case "memax_get": {
|
|
170
264
|
const typedArgs = args;
|
|
171
265
|
try {
|
|
172
|
-
const
|
|
266
|
+
const memory = await getClient().memories.get(typedArgs.id);
|
|
173
267
|
const parts = [
|
|
174
|
-
`# ${
|
|
175
|
-
`Category: ${
|
|
268
|
+
`# ${memory.title}`,
|
|
269
|
+
`Category: ${memory.category} | Source: ${memory.source} | Created: ${memory.created_at}`,
|
|
176
270
|
];
|
|
177
|
-
if (
|
|
178
|
-
parts.push(`Tags: ${
|
|
271
|
+
if (memory.tags?.length > 0) {
|
|
272
|
+
parts.push(`Tags: ${memory.tags.join(", ")}`);
|
|
179
273
|
}
|
|
180
|
-
if (
|
|
181
|
-
parts.push(`Source: ${
|
|
274
|
+
if (memory.source_path) {
|
|
275
|
+
parts.push(`Source: ${memory.source_path}`);
|
|
182
276
|
}
|
|
183
|
-
if (
|
|
184
|
-
parts.push(`\n## Summary\n${
|
|
277
|
+
if (memory.summary) {
|
|
278
|
+
parts.push(`\n## Summary\n${memory.summary}`);
|
|
185
279
|
}
|
|
186
|
-
parts.push(`\n## Content\n${
|
|
280
|
+
parts.push(`\n## Content\n${memory.content}`);
|
|
187
281
|
return {
|
|
188
282
|
content: [{ type: "text", text: parts.join("\n") }],
|
|
189
283
|
};
|
|
@@ -203,20 +297,37 @@ function createServer() {
|
|
|
203
297
|
case "memax_search": {
|
|
204
298
|
const typedArgs = args;
|
|
205
299
|
try {
|
|
206
|
-
const
|
|
207
|
-
|
|
300
|
+
const res = await getClient().memories.list({
|
|
301
|
+
limit: typedArgs.limit ?? 20,
|
|
302
|
+
cursor: typedArgs.cursor,
|
|
303
|
+
sort: typedArgs.sort,
|
|
304
|
+
});
|
|
305
|
+
const memories = res.memories ?? [];
|
|
306
|
+
const total = res.total ?? 0;
|
|
307
|
+
const nextCursor = res.next_cursor ?? "";
|
|
308
|
+
const hasMore = res.has_more ?? false;
|
|
309
|
+
// Client-side category filter (server doesn't filter by category on list)
|
|
310
|
+
let filtered = memories;
|
|
208
311
|
if (typedArgs.category) {
|
|
209
|
-
filtered =
|
|
312
|
+
filtered = memories.filter((m) => m.category.startsWith(typedArgs.category));
|
|
210
313
|
}
|
|
211
|
-
|
|
212
|
-
if (limited.length === 0) {
|
|
314
|
+
if (filtered.length === 0) {
|
|
213
315
|
return {
|
|
214
|
-
content: [
|
|
316
|
+
content: [
|
|
317
|
+
{
|
|
318
|
+
type: "text",
|
|
319
|
+
text: `No memories found. (${total} total in workspace)`,
|
|
320
|
+
},
|
|
321
|
+
],
|
|
215
322
|
};
|
|
216
323
|
}
|
|
217
|
-
|
|
218
|
-
.map((
|
|
324
|
+
let formatted = filtered
|
|
325
|
+
.map((m) => `- ${m.title} [${m.category}] ā ${m.source} (id: ${m.id})`)
|
|
219
326
|
.join("\n");
|
|
327
|
+
formatted += `\n\nShowing ${filtered.length} of ${total} total.`;
|
|
328
|
+
if (hasMore) {
|
|
329
|
+
formatted += ` More available ā pass cursor: "${nextCursor}" to get next page.`;
|
|
330
|
+
}
|
|
220
331
|
return { content: [{ type: "text", text: formatted }] };
|
|
221
332
|
}
|
|
222
333
|
catch (err) {
|
|
@@ -231,6 +342,137 @@ function createServer() {
|
|
|
231
342
|
};
|
|
232
343
|
}
|
|
233
344
|
}
|
|
345
|
+
case "memax_forget": {
|
|
346
|
+
const typedArgs = args;
|
|
347
|
+
if (!typedArgs.id) {
|
|
348
|
+
return {
|
|
349
|
+
content: [
|
|
350
|
+
{ type: "text", text: "Memory ID is required." },
|
|
351
|
+
],
|
|
352
|
+
isError: true,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
try {
|
|
356
|
+
await getClient().memories.delete(typedArgs.id);
|
|
357
|
+
return {
|
|
358
|
+
content: [
|
|
359
|
+
{
|
|
360
|
+
type: "text",
|
|
361
|
+
text: `Forgotten: ${typedArgs.id}`,
|
|
362
|
+
},
|
|
363
|
+
],
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
catch (err) {
|
|
367
|
+
return {
|
|
368
|
+
content: [
|
|
369
|
+
{
|
|
370
|
+
type: "text",
|
|
371
|
+
text: `Forget failed: ${err.message}`,
|
|
372
|
+
},
|
|
373
|
+
],
|
|
374
|
+
isError: true,
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
case "memax_capture": {
|
|
379
|
+
const typedArgs = args;
|
|
380
|
+
if (!typedArgs.summary) {
|
|
381
|
+
return {
|
|
382
|
+
content: [{ type: "text", text: "Summary is required." }],
|
|
383
|
+
isError: true,
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
// Build structured content for the extraction pipeline
|
|
387
|
+
let content = `## Session Summary\n${typedArgs.summary}\n`;
|
|
388
|
+
if (typedArgs.decisions?.length) {
|
|
389
|
+
content += `\n## Decisions Made\n${typedArgs.decisions.map((d) => `- ${d}`).join("\n")}\n`;
|
|
390
|
+
}
|
|
391
|
+
if (typedArgs.learnings?.length) {
|
|
392
|
+
content += `\n## Learnings\n${typedArgs.learnings.map((l) => `- ${l}`).join("\n")}\n`;
|
|
393
|
+
}
|
|
394
|
+
try {
|
|
395
|
+
const memory = await getClient().push(content, {
|
|
396
|
+
title: `Session capture ā ${new Date().toLocaleDateString()}`,
|
|
397
|
+
contentType: "transcript",
|
|
398
|
+
source: "mcp/capture",
|
|
399
|
+
category: "chat/agent",
|
|
400
|
+
});
|
|
401
|
+
return {
|
|
402
|
+
content: [
|
|
403
|
+
{
|
|
404
|
+
type: "text",
|
|
405
|
+
text: `Session captured (id: ${memory.id}). Key facts will be extracted and stored as separate memories.`,
|
|
406
|
+
},
|
|
407
|
+
],
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
catch (err) {
|
|
411
|
+
return {
|
|
412
|
+
content: [
|
|
413
|
+
{
|
|
414
|
+
type: "text",
|
|
415
|
+
text: `Capture failed: ${err.message}`,
|
|
416
|
+
},
|
|
417
|
+
],
|
|
418
|
+
isError: true,
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
case "memax_topics": {
|
|
423
|
+
const typedArgs = args;
|
|
424
|
+
try {
|
|
425
|
+
if (typedArgs.topic_id) {
|
|
426
|
+
// Browse specific topic's memories
|
|
427
|
+
const res = await getClient().topics.listMemories(typedArgs.topic_id);
|
|
428
|
+
const topic = await getClient().topics.get(typedArgs.topic_id);
|
|
429
|
+
const memories = res.memories ?? [];
|
|
430
|
+
let text = `## ${topic.name} (${memories.length} memories)\n\n`;
|
|
431
|
+
for (const [i, m] of memories.entries()) {
|
|
432
|
+
text += `${i + 1}. **${m.title}** [${m.category}] (id: ${m.id})\n`;
|
|
433
|
+
if (m.summary)
|
|
434
|
+
text += ` ${m.summary}\n`;
|
|
435
|
+
}
|
|
436
|
+
if (memories.length === 0)
|
|
437
|
+
text += "No memories in this topic yet.\n";
|
|
438
|
+
return { content: [{ type: "text", text }] };
|
|
439
|
+
}
|
|
440
|
+
// Full topic tree
|
|
441
|
+
const res = await getClient().topics.list(typedArgs.hub_id);
|
|
442
|
+
const topics = res.topics ?? [];
|
|
443
|
+
let text = "## Knowledge Topics\n\n";
|
|
444
|
+
if (topics.length === 0) {
|
|
445
|
+
text +=
|
|
446
|
+
"No topics yet. Push memories and run a dream cycle to auto-organize.\n";
|
|
447
|
+
}
|
|
448
|
+
else {
|
|
449
|
+
for (const t of topics) {
|
|
450
|
+
const indent = t.parent_id ? " " : "";
|
|
451
|
+
text += `${indent}- **${t.name}** (${t.memory_count} memories) [id: ${t.id}]\n`;
|
|
452
|
+
if (t.description)
|
|
453
|
+
text += `${indent} ${t.description}\n`;
|
|
454
|
+
for (const child of t.children) {
|
|
455
|
+
text += ` - **${child.name}** (${child.memory_count} memories) [id: ${child.id}]\n`;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
if (res.unassigned_count > 0) {
|
|
460
|
+
text += `\nš„ **Inbox**: ${res.unassigned_count} unassigned memories\n`;
|
|
461
|
+
}
|
|
462
|
+
return { content: [{ type: "text", text }] };
|
|
463
|
+
}
|
|
464
|
+
catch (err) {
|
|
465
|
+
return {
|
|
466
|
+
content: [
|
|
467
|
+
{
|
|
468
|
+
type: "text",
|
|
469
|
+
text: `Topics failed: ${err.message}`,
|
|
470
|
+
},
|
|
471
|
+
],
|
|
472
|
+
isError: true,
|
|
473
|
+
};
|
|
474
|
+
}
|
|
475
|
+
}
|
|
234
476
|
default:
|
|
235
477
|
return {
|
|
236
478
|
content: [{ type: "text", text: `Unknown tool: ${name}` }],
|
|
@@ -240,8 +482,8 @@ function createServer() {
|
|
|
240
482
|
});
|
|
241
483
|
return server;
|
|
242
484
|
}
|
|
243
|
-
async function mcpServeCommand() {
|
|
244
|
-
const server = createServer();
|
|
485
|
+
async function mcpServeCommand(options) {
|
|
486
|
+
const server = createServer(options.agent ?? "");
|
|
245
487
|
const transport = new StdioServerTransport();
|
|
246
488
|
await server.connect(transport);
|
|
247
489
|
// Keep the process alive ā some agent launchers close stdin early
|
|
@@ -261,6 +503,7 @@ export function registerMcpCommand(program) {
|
|
|
261
503
|
mcp
|
|
262
504
|
.command("serve")
|
|
263
505
|
.description("Start MCP server on stdio")
|
|
506
|
+
.option("--agent <name>", "Agent identity (e.g., claude-code, cursor)")
|
|
264
507
|
.action(mcpServeCommand);
|
|
265
508
|
}
|
|
266
509
|
//# sourceMappingURL=mcp.js.map
|