@slorenzot/memento-cli 0.1.2 → 0.2.1
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/data/memento.db +0 -0
- package/data/memento.db-shm +0 -0
- package/data/memento.db-wal +0 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +89 -0
- package/dist/index.js.map +1 -0
- package/package.json +19 -17
- package/slorenzot-memento-cli-0.2.0.tgz +0 -0
- package/src/index.ts +91 -1
- package/tsconfig.json +9 -5
- package/dist/CLI.d.ts +0 -11
- package/dist/CLI.d.ts.map +0 -1
- package/dist/CLI.js +0 -173
- package/dist/CLI.js.map +0 -1
- package/src/CLI.test.ts +0 -60
- package/src/CLI.ts +0 -187
package/data/memento.db
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
const commander_1 = require("commander");
|
|
5
|
+
const memento_core_1 = require("@slorenzot/memento-core");
|
|
6
|
+
const dbPath = process.env.MEMENTO_DB_PATH || "./data/memento.db";
|
|
7
|
+
const memory = new memento_core_1.MemoryEngine(dbPath);
|
|
8
|
+
let activeSessionId = null;
|
|
9
|
+
async function getOrCreateSessionId(projectId) {
|
|
10
|
+
if (activeSessionId)
|
|
11
|
+
return activeSessionId;
|
|
12
|
+
const session = await memory.createSession({ projectId, endedAt: null, metadata: {} });
|
|
13
|
+
activeSessionId = session.id;
|
|
14
|
+
return session.id;
|
|
15
|
+
}
|
|
16
|
+
const program = new commander_1.Command();
|
|
17
|
+
program.name("memento").description("Persistent memory system for AI coding agents").version("0.2.0");
|
|
18
|
+
program.command("search <query>").description("Search observations")
|
|
19
|
+
.option("-t, --type <type>", "Filter by type")
|
|
20
|
+
.option("-p, --project <project>", "Filter by project")
|
|
21
|
+
.option("--limit <number>", "Limit results")
|
|
22
|
+
.action(async (query, options) => {
|
|
23
|
+
const result = await memory.search({ query, type: options.type, projectId: options.project, limit: options.limit ? parseInt(options.limit) : undefined });
|
|
24
|
+
console.log(`Found ${result.total} observations:`);
|
|
25
|
+
result.observations.forEach((obs) => { console.log(` [${obs.type}] ${obs.title}\n ${obs.content.substring(0, 100)}...`); });
|
|
26
|
+
memory.close();
|
|
27
|
+
});
|
|
28
|
+
program.command("save <title> <content>").description("Save an observation")
|
|
29
|
+
.option("-t, --type <type>", "Observation type", "note")
|
|
30
|
+
.option("-k, --topic <topic>", "Topic key")
|
|
31
|
+
.option("-p, --project <project>", "Project ID", "default")
|
|
32
|
+
.action(async (title, content, options) => {
|
|
33
|
+
const sessionId = await getOrCreateSessionId(options.project);
|
|
34
|
+
const observation = await memory.createObservation({ sessionId, title, content, type: options.type, topicKey: options.topic || null, projectId: options.project, metadata: {} });
|
|
35
|
+
console.log(`Saved observation: ${observation.uuid}`);
|
|
36
|
+
memory.close();
|
|
37
|
+
});
|
|
38
|
+
program.command("get <id>").description("Get observation by ID")
|
|
39
|
+
.action(async (id) => {
|
|
40
|
+
const observation = await memory.getObservation(parseInt(id));
|
|
41
|
+
if (!observation) {
|
|
42
|
+
console.error("Observation not found");
|
|
43
|
+
memory.close();
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
console.log(`[${observation.type}] ${observation.title}\n${observation.content}\nTopic: ${observation.topicKey || "none"}\nCreated: ${observation.createdAt.toISOString()}`);
|
|
47
|
+
memory.close();
|
|
48
|
+
});
|
|
49
|
+
program.command("update <id>").description("Update observation")
|
|
50
|
+
.option("-t, --title <title>", "New title")
|
|
51
|
+
.option("-c, --content <content>", "New content")
|
|
52
|
+
.option("-k, --topic <topic>", "New topic key")
|
|
53
|
+
.action(async (id, options) => {
|
|
54
|
+
const updates = {};
|
|
55
|
+
if (options.title)
|
|
56
|
+
updates.title = options.title;
|
|
57
|
+
if (options.content)
|
|
58
|
+
updates.content = options.content;
|
|
59
|
+
if (options.topic)
|
|
60
|
+
updates.topicKey = options.topic;
|
|
61
|
+
const observation = await memory.updateObservation(parseInt(id), updates);
|
|
62
|
+
console.log(`Updated observation: ${observation.uuid}`);
|
|
63
|
+
memory.close();
|
|
64
|
+
});
|
|
65
|
+
program.command("delete <id>").description("Delete observation")
|
|
66
|
+
.action(async (id) => {
|
|
67
|
+
await memory.deleteObservation(parseInt(id));
|
|
68
|
+
console.log(`Deleted observation ${id}`);
|
|
69
|
+
memory.close();
|
|
70
|
+
});
|
|
71
|
+
program.command("timeline [project]").description("Show timeline")
|
|
72
|
+
.option("-l, --limit <number>", "Limit results", "20")
|
|
73
|
+
.action(async (project, options) => {
|
|
74
|
+
const result = await memory.search({ projectId: project, limit: parseInt(options.limit) });
|
|
75
|
+
console.log(`Timeline (${result.total} observations):`);
|
|
76
|
+
result.observations.forEach((obs) => { console.log(` ${obs.createdAt.toLocaleDateString()} [${obs.type}] ${obs.title}`); });
|
|
77
|
+
memory.close();
|
|
78
|
+
});
|
|
79
|
+
program.command("stats").description("Show statistics")
|
|
80
|
+
.action(async () => {
|
|
81
|
+
const result = await memory.search({});
|
|
82
|
+
const byType = {};
|
|
83
|
+
result.observations.forEach((obs) => { byType[obs.type] = (byType[obs.type] || 0) + 1; });
|
|
84
|
+
console.log(`Statistics:\n Total observations: ${result.total}\n By type:`);
|
|
85
|
+
Object.entries(byType).forEach(([type, count]) => { console.log(` ${type}: ${count}`); });
|
|
86
|
+
memory.close();
|
|
87
|
+
});
|
|
88
|
+
program.parseAsync(process.argv);
|
|
89
|
+
//# sourceMappingURL=index.js.map
|
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,CAAC;AACjB,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,iBAAiB,CAAC;KACpD,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACvC,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,GAAgB,EAAE,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvG,OAAO,CAAC,GAAG,CAAC,sCAAsC,MAAM,CAAC,KAAK,cAAc,CAAC,CAAC;IAC9E,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7F,MAAM,CAAC,KAAK,EAAE,CAAC;AACjB,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,29 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slorenzot/memento-cli",
|
|
3
|
-
"version": "0.1
|
|
4
|
-
"description": "CLI interface for Memento",
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "CLI interface for Memento memory system",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"memento",
|
|
7
|
+
"memory",
|
|
8
|
+
"cli"
|
|
9
|
+
],
|
|
10
|
+
"license": "CC-BY-NC-ND-4.0",
|
|
11
|
+
"author": "Soulberto Lorenzo",
|
|
12
|
+
"type": "commonjs",
|
|
13
|
+
"main": "dist/index.js",
|
|
14
|
+
"types": "dist/index.d.ts",
|
|
7
15
|
"bin": {
|
|
8
|
-
"memento": "
|
|
16
|
+
"memento": "dist/index.js"
|
|
9
17
|
},
|
|
10
18
|
"scripts": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"typecheck": "bun tsc --noEmit"
|
|
19
|
+
"build": "tsc",
|
|
20
|
+
"start": "node dist/index.js",
|
|
21
|
+
"prepare": "npm run build"
|
|
15
22
|
},
|
|
16
23
|
"dependencies": {
|
|
17
|
-
"@slorenzot/memento-core": "^0.
|
|
18
|
-
"commander": "^12.0.0"
|
|
19
|
-
"ink": "^4.4.1",
|
|
20
|
-
"chalk": "^5.3.0",
|
|
21
|
-
"ora": "^8.0.1",
|
|
22
|
-
"zod": "^3.22.4",
|
|
23
|
-
"dotenv": "^16.4.1"
|
|
24
|
+
"@slorenzot/memento-core": "^0.2.0",
|
|
25
|
+
"commander": "^12.0.0"
|
|
24
26
|
},
|
|
25
27
|
"devDependencies": {
|
|
26
28
|
"@types/node": "^20.11.0",
|
|
27
|
-
"
|
|
29
|
+
"typescript": "^5.3.3"
|
|
28
30
|
}
|
|
29
31
|
}
|
|
Binary file
|
package/src/index.ts
CHANGED
|
@@ -1 +1,91 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { Command } from "commander";
|
|
4
|
+
import { MemoryEngine } from "@slorenzot/memento-core";
|
|
5
|
+
import type { Observation } from "@slorenzot/memento-core";
|
|
6
|
+
|
|
7
|
+
const dbPath = process.env.MEMENTO_DB_PATH || "./data/memento.db";
|
|
8
|
+
const memory = new MemoryEngine(dbPath);
|
|
9
|
+
let activeSessionId: number | null = null;
|
|
10
|
+
|
|
11
|
+
async function getOrCreateSessionId(projectId: string): Promise<number> {
|
|
12
|
+
if (activeSessionId) return activeSessionId;
|
|
13
|
+
const session = await memory.createSession({ projectId, endedAt: null, metadata: {} });
|
|
14
|
+
activeSessionId = session.id;
|
|
15
|
+
return session.id;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const program = new Command();
|
|
19
|
+
program.name("memento").description("Persistent memory system for AI coding agents").version("0.2.0");
|
|
20
|
+
|
|
21
|
+
program.command("search <query>").description("Search observations")
|
|
22
|
+
.option("-t, --type <type>", "Filter by type")
|
|
23
|
+
.option("-p, --project <project>", "Filter by project")
|
|
24
|
+
.option("--limit <number>", "Limit results")
|
|
25
|
+
.action(async (query: string, options: any) => {
|
|
26
|
+
const result = await memory.search({ query, type: options.type, projectId: options.project, limit: options.limit ? parseInt(options.limit) : undefined });
|
|
27
|
+
console.log(`Found ${result.total} observations:`);
|
|
28
|
+
result.observations.forEach((obs: Observation) => { console.log(` [${obs.type}] ${obs.title}\n ${obs.content.substring(0, 100)}...`); });
|
|
29
|
+
memory.close();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
program.command("save <title> <content>").description("Save an observation")
|
|
33
|
+
.option("-t, --type <type>", "Observation type", "note")
|
|
34
|
+
.option("-k, --topic <topic>", "Topic key")
|
|
35
|
+
.option("-p, --project <project>", "Project ID", "default")
|
|
36
|
+
.action(async (title: string, content: string, options: any) => {
|
|
37
|
+
const sessionId = await getOrCreateSessionId(options.project);
|
|
38
|
+
const observation = await memory.createObservation({ sessionId, title, content, type: options.type, topicKey: options.topic || null, projectId: options.project, metadata: {} });
|
|
39
|
+
console.log(`Saved observation: ${observation.uuid}`);
|
|
40
|
+
memory.close();
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
program.command("get <id>").description("Get observation by ID")
|
|
44
|
+
.action(async (id: string) => {
|
|
45
|
+
const observation = await memory.getObservation(parseInt(id));
|
|
46
|
+
if (!observation) { console.error("Observation not found"); memory.close(); return; }
|
|
47
|
+
console.log(`[${observation.type}] ${observation.title}\n${observation.content}\nTopic: ${observation.topicKey || "none"}\nCreated: ${observation.createdAt.toISOString()}`);
|
|
48
|
+
memory.close();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
program.command("update <id>").description("Update observation")
|
|
52
|
+
.option("-t, --title <title>", "New title")
|
|
53
|
+
.option("-c, --content <content>", "New content")
|
|
54
|
+
.option("-k, --topic <topic>", "New topic key")
|
|
55
|
+
.action(async (id: string, options: any) => {
|
|
56
|
+
const updates: any = {};
|
|
57
|
+
if (options.title) updates.title = options.title;
|
|
58
|
+
if (options.content) updates.content = options.content;
|
|
59
|
+
if (options.topic) updates.topicKey = options.topic;
|
|
60
|
+
const observation = await memory.updateObservation(parseInt(id), updates);
|
|
61
|
+
console.log(`Updated observation: ${observation.uuid}`);
|
|
62
|
+
memory.close();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
program.command("delete <id>").description("Delete observation")
|
|
66
|
+
.action(async (id: string) => {
|
|
67
|
+
await memory.deleteObservation(parseInt(id));
|
|
68
|
+
console.log(`Deleted observation ${id}`);
|
|
69
|
+
memory.close();
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
program.command("timeline [project]").description("Show timeline")
|
|
73
|
+
.option("-l, --limit <number>", "Limit results", "20")
|
|
74
|
+
.action(async (project: string, options: any) => {
|
|
75
|
+
const result = await memory.search({ projectId: project, limit: parseInt(options.limit) });
|
|
76
|
+
console.log(`Timeline (${result.total} observations):`);
|
|
77
|
+
result.observations.forEach((obs: Observation) => { console.log(` ${obs.createdAt.toLocaleDateString()} [${obs.type}] ${obs.title}`); });
|
|
78
|
+
memory.close();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
program.command("stats").description("Show statistics")
|
|
82
|
+
.action(async () => {
|
|
83
|
+
const result = await memory.search({});
|
|
84
|
+
const byType: Record<string, number> = {};
|
|
85
|
+
result.observations.forEach((obs: Observation) => { byType[obs.type] = (byType[obs.type] || 0) + 1; });
|
|
86
|
+
console.log(`Statistics:\n Total observations: ${result.total}\n By type:`);
|
|
87
|
+
Object.entries(byType).forEach(([type, count]) => { console.log(` ${type}: ${count}`); });
|
|
88
|
+
memory.close();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
program.parseAsync(process.argv);
|
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "../../tsconfig.json",
|
|
3
2
|
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"module": "Node16",
|
|
5
|
+
"moduleResolution": "Node16",
|
|
4
6
|
"outDir": "./dist",
|
|
5
7
|
"rootDir": "./src",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"forceConsistentCasingInFileNames": true,
|
|
6
12
|
"declaration": true,
|
|
7
13
|
"declarationMap": true,
|
|
8
|
-
"sourceMap": true
|
|
9
|
-
"removeComments": true,
|
|
10
|
-
"types": ["bun-types"]
|
|
14
|
+
"sourceMap": true
|
|
11
15
|
},
|
|
12
16
|
"include": ["src/**/*"],
|
|
13
|
-
"exclude": ["node_modules", "dist", "**/*.test.ts"
|
|
17
|
+
"exclude": ["node_modules", "dist", "**/*.test.ts"]
|
|
14
18
|
}
|
package/dist/CLI.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export declare class CLI {
|
|
2
|
-
private program;
|
|
3
|
-
private memory;
|
|
4
|
-
private activeSessionId;
|
|
5
|
-
constructor(dbPath?: string);
|
|
6
|
-
private setupCommands;
|
|
7
|
-
private getOrCreateSessionId;
|
|
8
|
-
run(argv?: string[]): Promise<void>;
|
|
9
|
-
close(): void;
|
|
10
|
-
}
|
|
11
|
-
//# sourceMappingURL=CLI.d.ts.map
|
package/dist/CLI.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CLI.d.ts","sourceRoot":"","sources":["../src/CLI.ts"],"names":[],"mappings":"AAKA,qBAAa,GAAG;IACd,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,eAAe,CAAuB;gBAElC,MAAM,GAAE,MAA4B;IAMhD,OAAO,CAAC,aAAa;YAsJP,oBAAoB;IAa5B,GAAG,CAAC,IAAI,GAAE,MAAM,EAAiB;IAIvC,KAAK;CAGN"}
|
package/dist/CLI.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CLI = void 0;
|
|
4
|
-
const commander_1 = require("commander");
|
|
5
|
-
const core_1 = require("@memento/core");
|
|
6
|
-
class CLI {
|
|
7
|
-
program;
|
|
8
|
-
memory;
|
|
9
|
-
activeSessionId = null;
|
|
10
|
-
constructor(dbPath = './data/memento.db') {
|
|
11
|
-
this.program = new commander_1.Command();
|
|
12
|
-
this.memory = new core_1.MemoryEngine(dbPath);
|
|
13
|
-
this.setupCommands();
|
|
14
|
-
}
|
|
15
|
-
setupCommands() {
|
|
16
|
-
this.program
|
|
17
|
-
.name('memento')
|
|
18
|
-
.description('Persistent memory system for AI coding agents')
|
|
19
|
-
.version('0.1.0');
|
|
20
|
-
this.program
|
|
21
|
-
.command('setup [agent]')
|
|
22
|
-
.description('Setup configuration for an AI agent')
|
|
23
|
-
.action((agent) => {
|
|
24
|
-
console.log(`Setup for agent: ${agent || 'default'}`);
|
|
25
|
-
console.log('Configuration saved to ~/.memento/config.json');
|
|
26
|
-
});
|
|
27
|
-
this.program
|
|
28
|
-
.command('serve [port]')
|
|
29
|
-
.description('Start API server')
|
|
30
|
-
.option('-d, --db <path>', 'Database path', './data/memento.db')
|
|
31
|
-
.action((port, options) => {
|
|
32
|
-
console.log(`Starting API server on port ${port || 3000}`);
|
|
33
|
-
console.log(`Database: ${options.db}`);
|
|
34
|
-
console.log('Note: API server not implemented in CLI mode');
|
|
35
|
-
});
|
|
36
|
-
this.program
|
|
37
|
-
.command('mcp')
|
|
38
|
-
.description('Start MCP server')
|
|
39
|
-
.option('-d, --db <path>', 'Database path', './data/memento.db')
|
|
40
|
-
.action((options) => {
|
|
41
|
-
console.log(`Starting MCP server`);
|
|
42
|
-
console.log(`Database: ${options.db}`);
|
|
43
|
-
console.log('Note: MCP server not implemented in CLI mode');
|
|
44
|
-
});
|
|
45
|
-
this.program
|
|
46
|
-
.command('search <query>')
|
|
47
|
-
.description('Search observations')
|
|
48
|
-
.option('-t, --type <type>', 'Filter by type')
|
|
49
|
-
.option('-p, --project <project>', 'Filter by project')
|
|
50
|
-
.option('--limit <number>', 'Limit results')
|
|
51
|
-
.action(async (query, options) => {
|
|
52
|
-
const result = await this.memory.search({
|
|
53
|
-
query,
|
|
54
|
-
type: options.type,
|
|
55
|
-
projectId: options.project,
|
|
56
|
-
limit: options.limit ? parseInt(options.limit) : undefined,
|
|
57
|
-
});
|
|
58
|
-
console.log(`Found ${result.total} observations:`);
|
|
59
|
-
result.observations.forEach((obs) => {
|
|
60
|
-
console.log(` [${obs.type}] ${obs.title}`);
|
|
61
|
-
console.log(` ${obs.content.substring(0, 100)}...`);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
this.program
|
|
65
|
-
.command('save <title> <content>')
|
|
66
|
-
.description('Save an observation')
|
|
67
|
-
.option('-t, --type <type>', 'Observation type', 'note')
|
|
68
|
-
.option('-k, --topic <topic>', 'Topic key')
|
|
69
|
-
.option('-p, --project <project>', 'Project ID', 'default')
|
|
70
|
-
.action(async (title, content, options) => {
|
|
71
|
-
const sessionId = await this.getOrCreateSessionId(options.project);
|
|
72
|
-
const observation = await this.memory.createObservation({
|
|
73
|
-
sessionId,
|
|
74
|
-
title,
|
|
75
|
-
content,
|
|
76
|
-
type: options.type,
|
|
77
|
-
topicKey: options.topic || null,
|
|
78
|
-
projectId: options.project,
|
|
79
|
-
metadata: {},
|
|
80
|
-
});
|
|
81
|
-
console.log(`Saved observation: ${observation.uuid}`);
|
|
82
|
-
});
|
|
83
|
-
this.program
|
|
84
|
-
.command('get <id>')
|
|
85
|
-
.description('Get observation by ID')
|
|
86
|
-
.action(async (id) => {
|
|
87
|
-
const observation = await this.memory.getObservation(parseInt(id));
|
|
88
|
-
if (!observation) {
|
|
89
|
-
console.error('Observation not found');
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
console.log(`[${observation.type}] ${observation.title}`);
|
|
93
|
-
console.log(observation.content);
|
|
94
|
-
console.log(`Topic: ${observation.topicKey || 'none'}`);
|
|
95
|
-
console.log(`Created: ${observation.createdAt.toISOString()}`);
|
|
96
|
-
});
|
|
97
|
-
this.program
|
|
98
|
-
.command('update <id>')
|
|
99
|
-
.description('Update observation')
|
|
100
|
-
.option('-t, --title <title>', 'New title')
|
|
101
|
-
.option('-c, --content <content>', 'New content')
|
|
102
|
-
.option('-k, --topic <topic>', 'New topic key')
|
|
103
|
-
.action(async (id, options) => {
|
|
104
|
-
const updates = {};
|
|
105
|
-
if (options.title)
|
|
106
|
-
updates.title = options.title;
|
|
107
|
-
if (options.content)
|
|
108
|
-
updates.content = options.content;
|
|
109
|
-
if (options.topic)
|
|
110
|
-
updates.topicKey = options.topic;
|
|
111
|
-
const observation = await this.memory.updateObservation(parseInt(id), updates);
|
|
112
|
-
console.log(`Updated observation: ${observation.uuid}`);
|
|
113
|
-
});
|
|
114
|
-
this.program
|
|
115
|
-
.command('delete <id>')
|
|
116
|
-
.description('Delete observation')
|
|
117
|
-
.action(async (id) => {
|
|
118
|
-
await this.memory.deleteObservation(parseInt(id));
|
|
119
|
-
console.log(`Deleted observation ${id}`);
|
|
120
|
-
});
|
|
121
|
-
this.program
|
|
122
|
-
.command('timeline [project]')
|
|
123
|
-
.description('Show timeline of observations')
|
|
124
|
-
.option('-l, --limit <number>', 'Limit results', '20')
|
|
125
|
-
.action(async (project, options) => {
|
|
126
|
-
const result = await this.memory.search({
|
|
127
|
-
projectId: project,
|
|
128
|
-
limit: parseInt(options.limit),
|
|
129
|
-
});
|
|
130
|
-
console.log(`Timeline (${result.total} observations):`);
|
|
131
|
-
result.observations.forEach((obs) => {
|
|
132
|
-
const date = obs.createdAt.toLocaleDateString();
|
|
133
|
-
console.log(` ${date} [${obs.type}] ${obs.title}`);
|
|
134
|
-
});
|
|
135
|
-
});
|
|
136
|
-
this.program
|
|
137
|
-
.command('stats')
|
|
138
|
-
.description('Show statistics')
|
|
139
|
-
.action(async () => {
|
|
140
|
-
const result = await this.memory.search({});
|
|
141
|
-
const byType = result.observations.reduce((acc, obs) => {
|
|
142
|
-
acc[obs.type] = (acc[obs.type] || 0) + 1;
|
|
143
|
-
return acc;
|
|
144
|
-
}, {});
|
|
145
|
-
console.log('Statistics:');
|
|
146
|
-
console.log(` Total observations: ${result.total}`);
|
|
147
|
-
console.log(' By type:');
|
|
148
|
-
Object.entries(byType).forEach(([type, count]) => {
|
|
149
|
-
console.log(` ${type}: ${count}`);
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
async getOrCreateSessionId(projectId) {
|
|
154
|
-
if (this.activeSessionId) {
|
|
155
|
-
return this.activeSessionId;
|
|
156
|
-
}
|
|
157
|
-
const session = await this.memory.createSession({
|
|
158
|
-
projectId,
|
|
159
|
-
endedAt: null,
|
|
160
|
-
metadata: {},
|
|
161
|
-
});
|
|
162
|
-
this.activeSessionId = session.id;
|
|
163
|
-
return session.id;
|
|
164
|
-
}
|
|
165
|
-
async run(argv = process.argv) {
|
|
166
|
-
await this.program.parseAsync(argv);
|
|
167
|
-
}
|
|
168
|
-
close() {
|
|
169
|
-
this.memory.close();
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
exports.CLI = CLI;
|
|
173
|
-
//# sourceMappingURL=CLI.js.map
|
package/dist/CLI.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CLI.js","sourceRoot":"","sources":["../src/CLI.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AACpC,wCAA6C;AAI7C,MAAa,GAAG;IACN,OAA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bun:test';
|
|
2
|
-
import { CLI } from './CLI';
|
|
3
|
-
|
|
4
|
-
describe('CLI', () => {
|
|
5
|
-
let cli: CLI;
|
|
6
|
-
let testDbPath: string;
|
|
7
|
-
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
testDbPath = `/tmp/test-cli-${Date.now()}.db`;
|
|
10
|
-
cli = new CLI(testDbPath);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
afterEach(() => {
|
|
14
|
-
cli.close();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('should initialize without errors', () => {
|
|
18
|
-
expect(cli).toBeDefined();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
describe('Commands', () => {
|
|
22
|
-
it('should have all required commands', () => {
|
|
23
|
-
const commands = cli['program'].commands;
|
|
24
|
-
|
|
25
|
-
const commandNames = commands.map((c) => c.name());
|
|
26
|
-
expect(commandNames).toContain('setup');
|
|
27
|
-
expect(commandNames).toContain('serve');
|
|
28
|
-
expect(commandNames).toContain('mcp');
|
|
29
|
-
expect(commandNames).toContain('search');
|
|
30
|
-
expect(commandNames).toContain('save');
|
|
31
|
-
expect(commandNames).toContain('get');
|
|
32
|
-
expect(commandNames).toContain('update');
|
|
33
|
-
expect(commandNames).toContain('delete');
|
|
34
|
-
expect(commandNames).toContain('timeline');
|
|
35
|
-
expect(commandNames).toContain('stats');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('should have proper descriptions', () => {
|
|
39
|
-
const commands = cli['program'].commands;
|
|
40
|
-
|
|
41
|
-
const setupCommand = commands.find((c) => c.name() === 'setup');
|
|
42
|
-
expect(setupCommand).toBeDefined();
|
|
43
|
-
expect(setupCommand?.description()).toContain('Setup');
|
|
44
|
-
|
|
45
|
-
const searchCommand = commands.find((c) => c.name() === 'search');
|
|
46
|
-
expect(searchCommand).toBeDefined();
|
|
47
|
-
expect(searchCommand?.description()).toContain('Search');
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
describe('Session Management', () => {
|
|
52
|
-
it('should create and track active session', async () => {
|
|
53
|
-
const sessionId = await cli['getOrCreateSessionId']('test-project');
|
|
54
|
-
expect(sessionId).toBeDefined();
|
|
55
|
-
|
|
56
|
-
const sameSessionId = await cli['getOrCreateSessionId']('test-project');
|
|
57
|
-
expect(sameSessionId).toBe(sessionId);
|
|
58
|
-
});
|
|
59
|
-
});
|
|
60
|
-
});
|
package/src/CLI.ts
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { Command } from 'commander';
|
|
2
|
-
import { MemoryEngine } from '@slorenzot/memento-core';
|
|
3
|
-
import type { Observation } from '@slorenzot/memento-core';
|
|
4
|
-
|
|
5
|
-
// @ts-ignore
|
|
6
|
-
export class CLI {
|
|
7
|
-
private program: Command;
|
|
8
|
-
private memory: MemoryEngine;
|
|
9
|
-
private activeSessionId: number | null = null;
|
|
10
|
-
|
|
11
|
-
constructor(dbPath: string = './data/memento.db') {
|
|
12
|
-
this.program = new Command();
|
|
13
|
-
this.memory = new MemoryEngine(dbPath);
|
|
14
|
-
this.setupCommands();
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
private setupCommands() {
|
|
18
|
-
this.program
|
|
19
|
-
.name('memento')
|
|
20
|
-
.description('Persistent memory system for AI coding agents')
|
|
21
|
-
.version('0.1.0');
|
|
22
|
-
|
|
23
|
-
this.program
|
|
24
|
-
.command('setup [agent]')
|
|
25
|
-
.description('Setup configuration for an AI agent')
|
|
26
|
-
.action((agent) => {
|
|
27
|
-
console.log(`Setup for agent: ${agent || 'default'}`);
|
|
28
|
-
console.log('Configuration saved to ~/.memento/config.json');
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
this.program
|
|
32
|
-
.command('serve [port]')
|
|
33
|
-
.description('Start API server')
|
|
34
|
-
.option('-d, --db <path>', 'Database path', './data/memento.db')
|
|
35
|
-
.action((port, options) => {
|
|
36
|
-
console.log(`Starting API server on port ${port || 3000}`);
|
|
37
|
-
console.log(`Database: ${options.db}`);
|
|
38
|
-
console.log('Note: API server not implemented in CLI mode');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
this.program
|
|
42
|
-
.command('mcp')
|
|
43
|
-
.description('Start MCP server')
|
|
44
|
-
.option('-d, --db <path>', 'Database path', './data/memento.db')
|
|
45
|
-
.action((options) => {
|
|
46
|
-
console.log(`Starting MCP server`);
|
|
47
|
-
console.log(`Database: ${options.db}`);
|
|
48
|
-
console.log('Note: MCP server not implemented in CLI mode');
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
this.program
|
|
52
|
-
.command('search <query>')
|
|
53
|
-
.description('Search observations')
|
|
54
|
-
.option('-t, --type <type>', 'Filter by type')
|
|
55
|
-
.option('-p, --project <project>', 'Filter by project')
|
|
56
|
-
.option('--limit <number>', 'Limit results')
|
|
57
|
-
.action(async (query, options) => {
|
|
58
|
-
const result = await this.memory.search({
|
|
59
|
-
query,
|
|
60
|
-
type: options.type as Observation['type'] | undefined,
|
|
61
|
-
projectId: options.project as string | undefined,
|
|
62
|
-
limit: options.limit ? parseInt(options.limit as string) : undefined,
|
|
63
|
-
});
|
|
64
|
-
console.log(`Found ${result.total} observations:`);
|
|
65
|
-
result.observations.forEach((obs) => {
|
|
66
|
-
console.log(` [${obs.type}] ${obs.title}`);
|
|
67
|
-
console.log(` ${obs.content.substring(0, 100)}...`);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
this.program
|
|
72
|
-
.command('save <title> <content>')
|
|
73
|
-
.description('Save an observation')
|
|
74
|
-
.option('-t, --type <type>', 'Observation type', 'note')
|
|
75
|
-
.option('-k, --topic <topic>', 'Topic key')
|
|
76
|
-
.option('-p, --project <project>', 'Project ID', 'default')
|
|
77
|
-
.action(async (title, content, options) => {
|
|
78
|
-
const sessionId = await this.getOrCreateSessionId(options.project as string);
|
|
79
|
-
const observation = await this.memory.createObservation({
|
|
80
|
-
sessionId,
|
|
81
|
-
title,
|
|
82
|
-
content,
|
|
83
|
-
type: options.type as Observation['type'],
|
|
84
|
-
topicKey: options.topic || null,
|
|
85
|
-
projectId: options.project as string,
|
|
86
|
-
metadata: {},
|
|
87
|
-
});
|
|
88
|
-
console.log(`Saved observation: ${observation.uuid}`);
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
this.program
|
|
92
|
-
.command('get <id>')
|
|
93
|
-
.description('Get observation by ID')
|
|
94
|
-
.action(async (id) => {
|
|
95
|
-
const observation = await this.memory.getObservation(parseInt(id));
|
|
96
|
-
if (!observation) {
|
|
97
|
-
console.error('Observation not found');
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
console.log(`[${observation.type}] ${observation.title}`);
|
|
101
|
-
console.log(observation.content);
|
|
102
|
-
console.log(`Topic: ${observation.topicKey || 'none'}`);
|
|
103
|
-
console.log(`Created: ${observation.createdAt.toISOString()}`);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
this.program
|
|
107
|
-
.command('update <id>')
|
|
108
|
-
.description('Update observation')
|
|
109
|
-
.option('-t, --title <title>', 'New title')
|
|
110
|
-
.option('-c, --content <content>', 'New content')
|
|
111
|
-
.option('-k, --topic <topic>', 'New topic key')
|
|
112
|
-
.action(async (id, options) => {
|
|
113
|
-
const updates: Partial<Observation> = {};
|
|
114
|
-
if (options.title) updates.title = options.title;
|
|
115
|
-
if (options.content) updates.content = options.content;
|
|
116
|
-
if (options.topic) updates.topicKey = options.topic;
|
|
117
|
-
|
|
118
|
-
const observation = await this.memory.updateObservation(parseInt(id), updates);
|
|
119
|
-
console.log(`Updated observation: ${observation.uuid}`);
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
this.program
|
|
123
|
-
.command('delete <id>')
|
|
124
|
-
.description('Delete observation')
|
|
125
|
-
.action(async (id) => {
|
|
126
|
-
await this.memory.deleteObservation(parseInt(id));
|
|
127
|
-
console.log(`Deleted observation ${id}`);
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
this.program
|
|
131
|
-
.command('timeline [project]')
|
|
132
|
-
.description('Show timeline of observations')
|
|
133
|
-
.option('-l, --limit <number>', 'Limit results', '20')
|
|
134
|
-
.action(async (project, options) => {
|
|
135
|
-
const result = await this.memory.search({
|
|
136
|
-
projectId: project,
|
|
137
|
-
limit: parseInt(options.limit as string),
|
|
138
|
-
});
|
|
139
|
-
console.log(`Timeline (${result.total} observations):`);
|
|
140
|
-
result.observations.forEach((obs) => {
|
|
141
|
-
const date = obs.createdAt.toLocaleDateString();
|
|
142
|
-
console.log(` ${date} [${obs.type}] ${obs.title}`);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
this.program
|
|
147
|
-
.command('stats')
|
|
148
|
-
.description('Show statistics')
|
|
149
|
-
.action(async () => {
|
|
150
|
-
const result = await this.memory.search({});
|
|
151
|
-
const byType = result.observations.reduce(
|
|
152
|
-
(acc, obs) => {
|
|
153
|
-
acc[obs.type] = (acc[obs.type] || 0) + 1;
|
|
154
|
-
return acc;
|
|
155
|
-
},
|
|
156
|
-
{} as Record<string, number>
|
|
157
|
-
);
|
|
158
|
-
console.log('Statistics:');
|
|
159
|
-
console.log(` Total observations: ${result.total}`);
|
|
160
|
-
console.log(' By type:');
|
|
161
|
-
Object.entries(byType).forEach(([type, count]) => {
|
|
162
|
-
console.log(` ${type}: ${count}`);
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
private async getOrCreateSessionId(projectId: string): Promise<number> {
|
|
168
|
-
if (this.activeSessionId) {
|
|
169
|
-
return this.activeSessionId;
|
|
170
|
-
}
|
|
171
|
-
const session = await this.memory.createSession({
|
|
172
|
-
projectId,
|
|
173
|
-
endedAt: null,
|
|
174
|
-
metadata: {},
|
|
175
|
-
});
|
|
176
|
-
this.activeSessionId = session.id;
|
|
177
|
-
return session.id;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
async run(argv: string[] = process.argv) {
|
|
181
|
-
await this.program.parseAsync(argv);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
close() {
|
|
185
|
-
this.memory.close();
|
|
186
|
-
}
|
|
187
|
-
}
|