memax-cli 0.0.1 → 0.1.0-alpha.2

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.
Files changed (80) hide show
  1. package/dist/commands/auth.d.ts +6 -0
  2. package/dist/commands/auth.d.ts.map +1 -0
  3. package/dist/commands/auth.js +62 -0
  4. package/dist/commands/auth.js.map +1 -0
  5. package/dist/commands/config.d.ts +3 -0
  6. package/dist/commands/config.d.ts.map +1 -0
  7. package/dist/commands/config.js +24 -0
  8. package/dist/commands/config.js.map +1 -0
  9. package/dist/commands/delete.d.ts +4 -0
  10. package/dist/commands/delete.d.ts.map +1 -0
  11. package/dist/commands/delete.js +17 -0
  12. package/dist/commands/delete.js.map +1 -0
  13. package/dist/commands/hook.d.ts +2 -0
  14. package/dist/commands/hook.d.ts.map +1 -0
  15. package/dist/commands/hook.js +189 -0
  16. package/dist/commands/hook.js.map +1 -0
  17. package/dist/commands/list.d.ts +8 -0
  18. package/dist/commands/list.d.ts.map +1 -0
  19. package/dist/commands/list.js +23 -0
  20. package/dist/commands/list.js.map +1 -0
  21. package/dist/commands/login.d.ts +4 -0
  22. package/dist/commands/login.d.ts.map +1 -0
  23. package/dist/commands/login.js +126 -0
  24. package/dist/commands/login.js.map +1 -0
  25. package/dist/commands/mcp.d.ts +3 -0
  26. package/dist/commands/mcp.d.ts.map +1 -0
  27. package/dist/commands/mcp.js +208 -0
  28. package/dist/commands/mcp.js.map +1 -0
  29. package/dist/commands/push.d.ts +11 -0
  30. package/dist/commands/push.d.ts.map +1 -0
  31. package/dist/commands/push.js +64 -0
  32. package/dist/commands/push.js.map +1 -0
  33. package/dist/commands/recall.d.ts +12 -0
  34. package/dist/commands/recall.d.ts.map +1 -0
  35. package/dist/commands/recall.js +106 -0
  36. package/dist/commands/recall.js.map +1 -0
  37. package/dist/commands/show.d.ts +2 -0
  38. package/dist/commands/show.d.ts.map +1 -0
  39. package/dist/commands/show.js +29 -0
  40. package/dist/commands/show.js.map +1 -0
  41. package/dist/commands/sync.d.ts +11 -0
  42. package/dist/commands/sync.d.ts.map +1 -0
  43. package/dist/commands/sync.js +321 -0
  44. package/dist/commands/sync.js.map +1 -0
  45. package/dist/index.d.ts +3 -0
  46. package/dist/index.d.ts.map +1 -0
  47. package/dist/index.js +121 -0
  48. package/dist/index.js.map +1 -0
  49. package/dist/lib/api.d.ts +4 -0
  50. package/dist/lib/api.d.ts.map +1 -0
  51. package/dist/lib/api.js +95 -0
  52. package/dist/lib/api.js.map +1 -0
  53. package/dist/lib/config.d.ts +10 -0
  54. package/dist/lib/config.d.ts.map +1 -0
  55. package/dist/lib/config.js +49 -0
  56. package/dist/lib/config.js.map +1 -0
  57. package/dist/lib/credentials.d.ts +11 -0
  58. package/dist/lib/credentials.d.ts.map +1 -0
  59. package/dist/lib/credentials.js +36 -0
  60. package/dist/lib/credentials.js.map +1 -0
  61. package/package.json +39 -4
  62. package/src/commands/auth.ts +92 -0
  63. package/src/commands/config.ts +27 -0
  64. package/src/commands/delete.ts +20 -0
  65. package/src/commands/hook.ts +243 -0
  66. package/src/commands/list.ts +38 -0
  67. package/src/commands/login.ts +159 -0
  68. package/src/commands/mcp.ts +282 -0
  69. package/src/commands/push.ts +82 -0
  70. package/src/commands/recall.ts +160 -0
  71. package/src/commands/show.ts +35 -0
  72. package/src/commands/sync.ts +403 -0
  73. package/src/index.ts +167 -0
  74. package/src/lib/api.ts +110 -0
  75. package/src/lib/config.ts +61 -0
  76. package/src/lib/credentials.ts +42 -0
  77. package/tsconfig.json +9 -0
  78. package/LICENSE +0 -24
  79. package/README.md +0 -2
  80. package/bin/memax.js +0 -13
@@ -0,0 +1,321 @@
1
+ import chalk from "chalk";
2
+ import { readFileSync, readdirSync, statSync, watch, existsSync, } from "node:fs";
3
+ import { join, relative, extname, resolve, basename } from "node:path";
4
+ import { homedir } from "node:os";
5
+ import { apiPost } from "../lib/api.js";
6
+ const DEFAULT_IGNORE = new Set([
7
+ "node_modules",
8
+ ".git",
9
+ ".next",
10
+ "dist",
11
+ "__pycache__",
12
+ ".env",
13
+ ".env.local",
14
+ ".DS_Store",
15
+ ]);
16
+ const SUPPORTED_EXTENSIONS = new Set([
17
+ ".md",
18
+ ".txt",
19
+ ".ts",
20
+ ".tsx",
21
+ ".js",
22
+ ".jsx",
23
+ ".go",
24
+ ".py",
25
+ ".rs",
26
+ ".yaml",
27
+ ".yml",
28
+ ".json",
29
+ ".toml",
30
+ ".sh",
31
+ ".bash",
32
+ ".zsh",
33
+ ".css",
34
+ ".html",
35
+ ".sql",
36
+ ".graphql",
37
+ ".proto",
38
+ ".dockerfile",
39
+ ]);
40
+ export async function syncAgentMemoryCommand() {
41
+ await syncAgentMemory();
42
+ }
43
+ export async function syncCommand(directory, options) {
44
+ if (options.agentMemory || directory === "agents") {
45
+ await syncAgentMemory();
46
+ return;
47
+ }
48
+ const dir = directory ?? ".";
49
+ const customIgnore = options.ignore
50
+ ? new Set(options.ignore.split(",").map((s) => s.trim()))
51
+ : new Set();
52
+ const ignoreSet = new Set([...DEFAULT_IGNORE, ...customIgnore]);
53
+ console.log(chalk.blue("Scanning"), dir);
54
+ const files = walkDir(dir, ignoreSet);
55
+ if (files.length === 0) {
56
+ console.log(chalk.yellow("No supported files found."));
57
+ return;
58
+ }
59
+ console.log(chalk.gray(`Found ${files.length} files to sync`));
60
+ console.log();
61
+ let pushed = 0;
62
+ let errors = 0;
63
+ for (const file of files) {
64
+ const result = await pushFile(file, options);
65
+ if (result === "pushed")
66
+ pushed++;
67
+ else if (result === "error")
68
+ errors++;
69
+ }
70
+ console.log();
71
+ console.log(chalk.blue(`Synced ${pushed} files`), errors > 0 ? chalk.red(`(${errors} errors)`) : "");
72
+ if (options.watch) {
73
+ const resolvedDir = resolve(dir);
74
+ console.log(chalk.cyan(`\nWatching ${dir} for changes... (Ctrl+C to stop)`));
75
+ let debounceTimer = null;
76
+ const pendingChanges = new Set();
77
+ watch(resolvedDir, { recursive: true }, (_eventType, filename) => {
78
+ if (!filename)
79
+ return;
80
+ const fullPath = join(resolvedDir, filename);
81
+ if (!isSupportedFile(filename) || isIgnored(filename, ignoreSet))
82
+ return;
83
+ pendingChanges.add(fullPath);
84
+ if (debounceTimer)
85
+ clearTimeout(debounceTimer);
86
+ debounceTimer = setTimeout(async () => {
87
+ for (const file of pendingChanges) {
88
+ if (!existsSync(file)) {
89
+ console.log(chalk.gray(" ~"), relative(process.cwd(), file), chalk.gray("[deleted, skipped]"));
90
+ continue;
91
+ }
92
+ await pushFile(file, options);
93
+ }
94
+ pendingChanges.clear();
95
+ }, 500);
96
+ });
97
+ }
98
+ }
99
+ async function pushFile(file, options) {
100
+ try {
101
+ const content = readFileSync(file, "utf-8");
102
+ if (!content.trim())
103
+ return "skipped";
104
+ const relPath = relative(process.cwd(), file);
105
+ const ext = extname(file);
106
+ const contentType = ext === ".md"
107
+ ? "markdown"
108
+ : ext === ".json" || ext === ".yaml" || ext === ".yml"
109
+ ? "structured"
110
+ : "code";
111
+ const note = await apiPost("/v1/notes", {
112
+ content,
113
+ title: relPath,
114
+ category: options.category ?? guessCategory(relPath),
115
+ source: "sync",
116
+ source_path: relPath,
117
+ content_type: contentType,
118
+ });
119
+ console.log(chalk.green(" +"), relPath, chalk.gray(`[${note.category}]`));
120
+ return "pushed";
121
+ }
122
+ catch (err) {
123
+ console.log(chalk.red(" x"), file, chalk.gray(err.message));
124
+ return "error";
125
+ }
126
+ }
127
+ function isSupportedFile(filename) {
128
+ return SUPPORTED_EXTENSIONS.has(extname(filename));
129
+ }
130
+ function isIgnored(filename, ignoreSet) {
131
+ const parts = filename.split(/[/\\]/);
132
+ return parts.some((part) => ignoreSet.has(part) || part.startsWith("."));
133
+ }
134
+ function walkDir(dir, ignore) {
135
+ const files = [];
136
+ function walk(currentDir) {
137
+ let entries;
138
+ try {
139
+ entries = readdirSync(currentDir);
140
+ }
141
+ catch {
142
+ return;
143
+ }
144
+ for (const entry of entries) {
145
+ if (ignore.has(entry) || entry.startsWith("."))
146
+ continue;
147
+ const fullPath = join(currentDir, entry);
148
+ let stat;
149
+ try {
150
+ stat = statSync(fullPath);
151
+ }
152
+ catch {
153
+ continue;
154
+ }
155
+ if (stat.isDirectory()) {
156
+ walk(fullPath);
157
+ }
158
+ else if (stat.isFile() && SUPPORTED_EXTENSIONS.has(extname(entry))) {
159
+ files.push(fullPath);
160
+ }
161
+ }
162
+ }
163
+ walk(dir);
164
+ return files;
165
+ }
166
+ function guessCategory(path) {
167
+ const lower = path.toLowerCase();
168
+ if (lower.includes("adr") || lower.includes("decision"))
169
+ return "decisions/adr";
170
+ if (lower.includes("deploy") || lower.includes("ci"))
171
+ return "process/deploy";
172
+ if (lower.includes("architecture") || lower.includes("design"))
173
+ return "core/architecture";
174
+ if (lower.includes("readme") || lower.includes("docs"))
175
+ return "reference/api";
176
+ if (lower.includes("test"))
177
+ return "reference/api";
178
+ if (lower.includes("config") || lower.includes(".env"))
179
+ return "reference/config";
180
+ return "daily/note";
181
+ }
182
+ function discoverAgentMemoryFiles() {
183
+ const home = homedir();
184
+ const cwd = process.cwd();
185
+ const locations = [];
186
+ // Claude Code global memory
187
+ const claudeMemory = join(home, ".claude", "MEMORY.md");
188
+ locations.push({ label: "~/.claude/MEMORY.md", path: claudeMemory });
189
+ // Claude Code per-project memories: ~/.claude/projects/*/memory/*.md
190
+ const claudeProjectsDir = join(home, ".claude", "projects");
191
+ if (existsSync(claudeProjectsDir)) {
192
+ try {
193
+ for (const project of readdirSync(claudeProjectsDir)) {
194
+ const memoryDir = join(claudeProjectsDir, project, "memory");
195
+ if (existsSync(memoryDir)) {
196
+ try {
197
+ for (const file of readdirSync(memoryDir)) {
198
+ if (file.endsWith(".md")) {
199
+ locations.push({
200
+ label: `~/.claude/projects/${project}/memory/${file}`,
201
+ path: join(memoryDir, file),
202
+ });
203
+ }
204
+ }
205
+ }
206
+ catch {
207
+ // Permission denied or other read error — skip
208
+ }
209
+ }
210
+ }
211
+ }
212
+ catch {
213
+ // Permission denied or other read error — skip
214
+ }
215
+ }
216
+ // Cursor rules (project-level)
217
+ locations.push({ label: "./.cursorrules", path: join(cwd, ".cursorrules") });
218
+ // Cursor scoped rules: .cursor/rules/*.mdc
219
+ const cursorRulesDir = join(cwd, ".cursor", "rules");
220
+ if (existsSync(cursorRulesDir)) {
221
+ try {
222
+ for (const file of readdirSync(cursorRulesDir)) {
223
+ if (file.endsWith(".mdc")) {
224
+ locations.push({
225
+ label: `./.cursor/rules/${file}`,
226
+ path: join(cursorRulesDir, file),
227
+ });
228
+ }
229
+ }
230
+ }
231
+ catch {
232
+ // Skip on error
233
+ }
234
+ }
235
+ // Codex instructions
236
+ locations.push({
237
+ label: "./.codex/instructions.md",
238
+ path: join(cwd, ".codex", "instructions.md"),
239
+ });
240
+ // Generic agent config files in current directory
241
+ locations.push({ label: "./AGENTS.md", path: join(cwd, "AGENTS.md") });
242
+ locations.push({ label: "./CLAUDE.md", path: join(cwd, "CLAUDE.md") });
243
+ return locations;
244
+ }
245
+ function formatFileSize(bytes) {
246
+ if (bytes < 1024)
247
+ return `${bytes} B`;
248
+ return `${(bytes / 1024).toFixed(1)} KB`;
249
+ }
250
+ async function syncAgentMemory() {
251
+ console.log(chalk.blue("Scanning for agent memory files..."));
252
+ console.log();
253
+ const locations = discoverAgentMemoryFiles();
254
+ const found = [];
255
+ const notFound = [];
256
+ for (const loc of locations) {
257
+ if (existsSync(loc.path)) {
258
+ try {
259
+ const stat = statSync(loc.path);
260
+ if (stat.isFile() && stat.size > 0) {
261
+ found.push({ label: loc.label, path: loc.path, size: stat.size });
262
+ }
263
+ else {
264
+ notFound.push(loc.label);
265
+ }
266
+ }
267
+ catch {
268
+ notFound.push(loc.label);
269
+ }
270
+ }
271
+ else {
272
+ notFound.push(loc.label);
273
+ }
274
+ }
275
+ if (found.length === 0) {
276
+ console.log(chalk.yellow("No agent memory files found."));
277
+ return;
278
+ }
279
+ console.log("Found:");
280
+ for (const f of found) {
281
+ console.log(chalk.green(" \u2713"), f.label, chalk.gray(`(${formatFileSize(f.size)})`));
282
+ }
283
+ for (const label of notFound) {
284
+ console.log(chalk.gray(" \u2717"), chalk.gray(label), chalk.gray("(not found)"));
285
+ }
286
+ console.log();
287
+ let synced = 0;
288
+ let unchanged = 0;
289
+ let errors = 0;
290
+ for (const f of found) {
291
+ try {
292
+ const content = readFileSync(f.path, "utf-8");
293
+ if (!content.trim())
294
+ continue;
295
+ const title = basename(f.path);
296
+ await apiPost("/v1/notes", {
297
+ content,
298
+ title,
299
+ source: "sync",
300
+ source_path: f.path,
301
+ content_type: "markdown",
302
+ category: "",
303
+ });
304
+ synced++;
305
+ }
306
+ catch (err) {
307
+ const msg = err.message;
308
+ if (msg.includes("unchanged") ||
309
+ msg.includes("duplicate") ||
310
+ msg.includes("exists")) {
311
+ unchanged++;
312
+ }
313
+ else {
314
+ errors++;
315
+ console.log(chalk.red(" Error syncing"), f.label, chalk.gray(msg));
316
+ }
317
+ }
318
+ }
319
+ console.log(chalk.blue(`Synced ${found.length} files to Memax`), chalk.gray(`(${synced} new, ${unchanged} unchanged${errors > 0 ? `, ${errors} errors` : ""})`));
320
+ }
321
+ //# sourceMappingURL=sync.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/commands/sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,KAAK,EACL,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAWxC,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,cAAc;IACd,MAAM;IACN,OAAO;IACP,MAAM;IACN,aAAa;IACb,MAAM;IACN,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-0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ import { pushCommand } from "./commands/push.js";
4
+ import { recallCommand } from "./commands/recall.js";
5
+ import { listCommand } from "./commands/list.js";
6
+ import { showCommand } from "./commands/show.js";
7
+ import { deleteCommand } from "./commands/delete.js";
8
+ import { syncCommand, syncAgentMemoryCommand } from "./commands/sync.js";
9
+ import { hookCommand } from "./commands/hook.js";
10
+ import { configGetCommand, configSetCommand } from "./commands/config.js";
11
+ import { loginCommand, logoutCommand, whoamiCommand, } from "./commands/login.js";
12
+ import { createKeyCommand, listKeysCommand, revokeKeyCommand, } from "./commands/auth.js";
13
+ import { registerMcpCommand } from "./commands/mcp.js";
14
+ const program = new Command();
15
+ program
16
+ .name("memax")
17
+ .description("Universal context & memory hub for AI agents")
18
+ .version("0.0.1");
19
+ // --- Core commands ---
20
+ program
21
+ .command("push")
22
+ .description("Save knowledge to your Memax workspace")
23
+ .option("-f, --file <path>", "File to push")
24
+ .option("-c, --category <category>", "Category (auto-detected if omitted)")
25
+ .option("-t, --tags <tags>", "Comma-separated tags")
26
+ .option("--title <title>", "Note title")
27
+ .option("--ttl <duration>", "Auto-archive after duration (e.g., 7d, 30d)")
28
+ .option("--stdin", "Read content from stdin")
29
+ .action(pushCommand);
30
+ program
31
+ .command("recall [query]")
32
+ .description("Ask your knowledge a question")
33
+ .option("-c, --category <category>", "Filter by category")
34
+ .option("-t, --tags <tags>", "Filter by tags")
35
+ .option("-l, --limit <n>", "Max results", "5")
36
+ .option("--format <format>", "Output format: text, json", "text")
37
+ .option("--hook", "Output in agent-injectable format")
38
+ .option("--max-tokens <number>", "Maximum tokens to output (approximate)")
39
+ .option("--include-archived", "Include archived notes")
40
+ .action(recallCommand);
41
+ program
42
+ .command("list")
43
+ .description("List your knowledge notes")
44
+ .option("-c, --category <category>", "Filter by category")
45
+ .option("--state <state>", "Filter by state: active, cooling, archived")
46
+ .option("-l, --limit <n>", "Max results", "20")
47
+ .action(listCommand);
48
+ program
49
+ .command("show <id>")
50
+ .description("Show a specific note")
51
+ .action(showCommand);
52
+ program
53
+ .command("delete <id>")
54
+ .description("Delete a note")
55
+ .option("--confirm", "Skip confirmation")
56
+ .action(deleteCommand);
57
+ // --- Sync ---
58
+ const syncCmd = program
59
+ .command("sync [directory]")
60
+ .description("Sync a directory or agent memory to your Memax workspace")
61
+ .option("-w, --watch", "Watch for changes (coming soon)")
62
+ .option("-b, --boundary <level>", "Visibility level: private, team, org", "private")
63
+ .option("-c, --category <category>", "Default category (auto-detected if omitted)")
64
+ .option("--ignore <patterns>", "Comma-separated directories to ignore")
65
+ .option("--agent-memory", "Sync native AI agent memory files (Claude Code, Cursor, Codex)")
66
+ .action(syncCommand);
67
+ syncCmd
68
+ .command("agents")
69
+ .description("Sync native AI agent memory files to Memax")
70
+ .action(syncAgentMemoryCommand);
71
+ // --- Agent hooks ---
72
+ program
73
+ .command("hook <action> <agent>")
74
+ .description("Manage agent hooks (install/uninstall claude-code)")
75
+ .action(hookCommand);
76
+ // --- Auth ---
77
+ program
78
+ .command("login")
79
+ .description("Log in to Memax via GitHub")
80
+ .action(loginCommand);
81
+ program
82
+ .command("logout")
83
+ .description("Clear saved credentials")
84
+ .action(logoutCommand);
85
+ program
86
+ .command("whoami")
87
+ .description("Show current user")
88
+ .action(whoamiCommand);
89
+ // --- API Keys ---
90
+ const authCmd = program
91
+ .command("auth")
92
+ .description("Manage authentication and API keys");
93
+ authCmd
94
+ .command("create-key <name>")
95
+ .description("Create an API key for CI/CD or non-interactive use")
96
+ .option("--expires <days>", "Expire after N days (default: never)")
97
+ .action(createKeyCommand);
98
+ authCmd
99
+ .command("list-keys")
100
+ .description("List your API keys")
101
+ .action(listKeysCommand);
102
+ authCmd
103
+ .command("revoke-key <id>")
104
+ .description("Revoke an API key")
105
+ .action(revokeKeyCommand);
106
+ // --- MCP Server ---
107
+ registerMcpCommand(program);
108
+ // --- Config ---
109
+ const configCmd = program
110
+ .command("config")
111
+ .description("Manage Memax configuration");
112
+ configCmd
113
+ .command("get [key]")
114
+ .description("Get config value (or all values)")
115
+ .action(configGetCommand);
116
+ configCmd
117
+ .command("set <key> <value>")
118
+ .description("Set a config value")
119
+ .action(configSetCommand);
120
+ program.parse();
121
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EACL,YAAY,EACZ,aAAa,EACb,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,OAAO,CAAC;KACb,WAAW,CAAC,8CAA8C,CAAC;KAC3D,OAAO,CAAC,OAAO,CAAC,CAAC;AAEpB,wBAAwB;AAExB,OAAO;KACJ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,OAAO;KACJ,OAAO,CAAC,mBAAmB,CAAC;KAC5B,WAAW,CAAC,oDAAoD,CAAC;KACjE,MAAM,CAAC,kBAAkB,EAAE,sCAAsC,CAAC;KAClE,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAE5B,OAAO;KACJ,OAAO,CAAC,WAAW,CAAC;KACpB,WAAW,CAAC,oBAAoB,CAAC;KACjC,MAAM,CAAC,eAAe,CAAC,CAAC;AAE3B,OAAO;KACJ,OAAO,CAAC,iBAAiB,CAAC;KAC1B,WAAW,CAAC,mBAAmB,CAAC;KAChC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAE5B,qBAAqB;AAErB,kBAAkB,CAAC,OAAO,CAAC,CAAC;AAE5B,iBAAiB;AAEjB,MAAM,SAAS,GAAG,OAAO;KACtB,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,4BAA4B,CAAC,CAAC;AAE7C,SAAS;KACN,OAAO,CAAC,WAAW,CAAC;KACpB,WAAW,CAAC,kCAAkC,CAAC;KAC/C,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAE5B,SAAS;KACN,OAAO,CAAC,mBAAmB,CAAC;KAC5B,WAAW,CAAC,oBAAoB,CAAC;KACjC,MAAM,CAAC,gBAAgB,CAAC,CAAC;AAE5B,OAAO,CAAC,KAAK,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare function apiPost<T>(path: string, body: unknown): Promise<T>;
2
+ export declare function apiGet<T>(path: string): Promise<T>;
3
+ export declare function apiDelete(path: string): Promise<void>;
4
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":"AA0DA,wBAAsB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,CAiBxE;AAED,wBAAsB,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAexD;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAe3D"}
@@ -0,0 +1,95 @@
1
+ import { loadConfig } from "./config.js";
2
+ import { loadCredentials, saveCredentials, isTokenExpired, } from "./credentials.js";
3
+ function getApiUrl() {
4
+ return loadConfig().api_url;
5
+ }
6
+ async function authHeaders() {
7
+ // 1. MEMAX_API_KEY env var takes priority (CI/CD, non-interactive)
8
+ const envKey = process.env.MEMAX_API_KEY;
9
+ if (envKey) {
10
+ return { Authorization: `Bearer ${envKey}` };
11
+ }
12
+ // 2. Stored credentials with auto-refresh
13
+ const creds = loadCredentials();
14
+ if (!creds?.access_token)
15
+ return {};
16
+ if (isTokenExpired() && creds.refresh_token) {
17
+ // Attempt to refresh the access token
18
+ try {
19
+ const url = `${getApiUrl()}/v1/auth/refresh`;
20
+ const res = await fetch(url, {
21
+ method: "POST",
22
+ headers: { "Content-Type": "application/json" },
23
+ body: JSON.stringify({ refresh_token: creds.refresh_token }),
24
+ });
25
+ const json = (await res.json());
26
+ if (json.data) {
27
+ const tokens = json.data;
28
+ saveCredentials({
29
+ access_token: tokens.access_token,
30
+ refresh_token: tokens.refresh_token,
31
+ expires_at: Date.now() + tokens.expires_in * 1000,
32
+ });
33
+ return { Authorization: `Bearer ${tokens.access_token}` };
34
+ }
35
+ }
36
+ catch {
37
+ // Refresh failed — fall through to use stale token (server will reject)
38
+ }
39
+ }
40
+ return { Authorization: `Bearer ${creds.access_token}` };
41
+ }
42
+ export async function apiPost(path, body) {
43
+ const url = `${getApiUrl()}${path}`;
44
+ let res;
45
+ try {
46
+ res = await fetch(url, {
47
+ method: "POST",
48
+ headers: { "Content-Type": "application/json", ...(await authHeaders()) },
49
+ body: JSON.stringify(body),
50
+ });
51
+ }
52
+ catch {
53
+ throw new Error(`Cannot reach API at ${url} — is the server running?`);
54
+ }
55
+ const json = (await res.json());
56
+ if (json.error) {
57
+ throw new Error(json.error.message);
58
+ }
59
+ return json.data;
60
+ }
61
+ export async function apiGet(path) {
62
+ const url = `${getApiUrl()}${path}`;
63
+ let res;
64
+ try {
65
+ res = await fetch(url, {
66
+ headers: { ...(await authHeaders()) },
67
+ });
68
+ }
69
+ catch {
70
+ throw new Error(`Cannot reach API at ${url} — is the server running?`);
71
+ }
72
+ const json = (await res.json());
73
+ if (json.error) {
74
+ throw new Error(json.error.message);
75
+ }
76
+ return json.data;
77
+ }
78
+ export async function apiDelete(path) {
79
+ const url = `${getApiUrl()}${path}`;
80
+ let res;
81
+ try {
82
+ res = await fetch(url, {
83
+ method: "DELETE",
84
+ headers: { ...(await authHeaders()) },
85
+ });
86
+ }
87
+ catch {
88
+ throw new Error(`Cannot reach API at ${url} — is the server running?`);
89
+ }
90
+ const json = (await res.json());
91
+ if (json.error) {
92
+ throw new Error(json.error.message);
93
+ }
94
+ }
95
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/lib/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EACL,eAAe,EACf,eAAe,EACf,cAAc,GACf,MAAM,kBAAkB,CAAC;AAO1B,SAAS,SAAS;IAChB,OAAO,UAAU,EAAE,CAAC,OAAO,CAAC;AAC9B,CAAC;AAED,KAAK,UAAU,WAAW;IACxB,mEAAmE;IACnE,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;IACzC,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,EAAE,aAAa,EAAE,UAAU,MAAM,EAAE,EAAE,CAAC;IAC/C,CAAC;IAED,0CAA0C;IAC1C,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,IAAI,CAAC,KAAK,EAAE,YAAY;QAAE,OAAO,EAAE,CAAC;IAEpC,IAAI,cAAc,EAAE,IAAI,KAAK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I,GAAa,CAAC;IAClB,IAAI,CAAC;QACH,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;YACrB,MAAM,EAAE,QAAQ;YAChB,OAAO,EAAE,EAAE,GAAG,CAAC,MAAM,WAAW,EAAE,CAAC,EAAE;SACtC,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,2BAA2B,CAAC,CAAC;IACzE,CAAC;IACD,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAgB,CAAC;IAC/C,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;AACH,CAAC"}
@@ -0,0 +1,10 @@
1
+ export interface MemaxConfig {
2
+ api_url: string;
3
+ default_hub: string;
4
+ default_boundary: string;
5
+ auto_categorize: boolean;
6
+ }
7
+ export declare function getConfigDir(): string;
8
+ export declare function loadConfig(): MemaxConfig;
9
+ export declare function saveConfig(config: Partial<MemaxConfig>): void;
10
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,OAAO,CAAC;CAC1B;AASD,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,wBAAgB,UAAU,IAAI,WAAW,CAgBxC;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,IAAI,CAiB7D"}
@@ -0,0 +1,49 @@
1
+ import { readFileSync, writeFileSync, mkdirSync, existsSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { homedir } from "node:os";
4
+ const CONFIG_DIR = join(homedir(), ".memax");
5
+ const CONFIG_FILE = join(CONFIG_DIR, "config.json");
6
+ const DEFAULT_CONFIG = {
7
+ api_url: "http://localhost:8080",
8
+ default_hub: "default",
9
+ default_boundary: "private",
10
+ auto_categorize: true,
11
+ };
12
+ export function getConfigDir() {
13
+ return CONFIG_DIR;
14
+ }
15
+ export function loadConfig() {
16
+ // Env var overrides everything
17
+ const envUrl = process.env.MEMAX_API_URL;
18
+ if (!existsSync(CONFIG_FILE)) {
19
+ return envUrl ? { ...DEFAULT_CONFIG, api_url: envUrl } : DEFAULT_CONFIG;
20
+ }
21
+ try {
22
+ const raw = readFileSync(CONFIG_FILE, "utf-8");
23
+ const config = { ...DEFAULT_CONFIG, ...JSON.parse(raw) };
24
+ if (envUrl)
25
+ config.api_url = envUrl;
26
+ return config;
27
+ }
28
+ catch {
29
+ return envUrl ? { ...DEFAULT_CONFIG, api_url: envUrl } : DEFAULT_CONFIG;
30
+ }
31
+ }
32
+ export function saveConfig(config) {
33
+ mkdirSync(CONFIG_DIR, { recursive: true });
34
+ let existing = DEFAULT_CONFIG;
35
+ if (existsSync(CONFIG_FILE)) {
36
+ try {
37
+ existing = {
38
+ ...DEFAULT_CONFIG,
39
+ ...JSON.parse(readFileSync(CONFIG_FILE, "utf-8")),
40
+ };
41
+ }
42
+ catch {
43
+ // ignore parse errors
44
+ }
45
+ }
46
+ const merged = { ...existing, ...config };
47
+ writeFileSync(CONFIG_FILE, JSON.stringify(merged, null, 2) + "\n");
48
+ }
49
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,S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