agentmemory-cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +198 -0
- package/dist/commands/delete.d.ts +7 -0
- package/dist/commands/delete.d.ts.map +1 -0
- package/dist/commands/delete.js +67 -0
- package/dist/commands/delete.js.map +1 -0
- package/dist/commands/export.d.ts +7 -0
- package/dist/commands/export.d.ts.map +1 -0
- package/dist/commands/export.js +79 -0
- package/dist/commands/export.js.map +1 -0
- package/dist/commands/import.d.ts +6 -0
- package/dist/commands/import.d.ts.map +1 -0
- package/dist/commands/import.js +107 -0
- package/dist/commands/import.js.map +1 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +65 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/list.d.ts +8 -0
- package/dist/commands/list.d.ts.map +1 -0
- package/dist/commands/list.js +55 -0
- package/dist/commands/list.js.map +1 -0
- package/dist/commands/search.d.ts +7 -0
- package/dist/commands/search.d.ts.map +1 -0
- package/dist/commands/search.js +47 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/commands/store.d.ts +8 -0
- package/dist/commands/store.d.ts.map +1 -0
- package/dist/commands/store.js +51 -0
- package/dist/commands/store.js.map +1 -0
- package/dist/commands/sync.d.ts +9 -0
- package/dist/commands/sync.d.ts.map +1 -0
- package/dist/commands/sync.js +90 -0
- package/dist/commands/sync.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +106 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api.d.ts +14 -0
- package/dist/lib/api.d.ts.map +1 -0
- package/dist/lib/api.js +98 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/config.d.ts +13 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +123 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/sync.d.ts +43 -0
- package/dist/lib/sync.d.ts.map +1 -0
- package/dist/lib/sync.js +184 -0
- package/dist/lib/sync.js.map +1 -0
- package/dist/types.d.ts +41 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/package.json +44 -0
- package/src/commands/delete.ts +72 -0
- package/src/commands/export.ts +46 -0
- package/src/commands/import.ts +87 -0
- package/src/commands/init.ts +71 -0
- package/src/commands/list.ts +61 -0
- package/src/commands/search.ts +52 -0
- package/src/commands/store.ts +58 -0
- package/src/commands/sync.ts +102 -0
- package/src/index.ts +114 -0
- package/src/lib/api.ts +139 -0
- package/src/lib/config.ts +95 -0
- package/src/lib/sync.ts +186 -0
- package/src/types.ts +47 -0
- package/tsconfig.json +20 -0
package/README.md
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
# AgentMemory CLI
|
|
2
|
+
|
|
3
|
+
Command-line interface for [AgentMemory](https://agentmemory.cloud) - persistent cloud memory for AI agents.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
### npm (recommended)
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g agentmemory-cli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### npx (no install)
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx agentmemory-cli store "Your memory"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### curl installer
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
curl -fsSL https://agentmemory.cloud/install.sh | bash
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Quick Start
|
|
26
|
+
|
|
27
|
+
1. **Initialize with your API key:**
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
agentmemory init
|
|
31
|
+
# Enter your API key from https://agentmemory.cloud/dashboard
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
2. **Store a memory:**
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
agentmemory store "User prefers dark mode and likes updates at 9 AM"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
3. **Search memories:**
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
agentmemory search "user preferences"
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Commands
|
|
47
|
+
|
|
48
|
+
| Command | Description |
|
|
49
|
+
|---------|-------------|
|
|
50
|
+
| `agentmemory init` | Configure your API key |
|
|
51
|
+
| `agentmemory store <content>` | Store a new memory |
|
|
52
|
+
| `agentmemory search <query>` | Semantic search |
|
|
53
|
+
| `agentmemory list` | List all memories |
|
|
54
|
+
| `agentmemory delete <id>` | Delete a memory |
|
|
55
|
+
| `agentmemory sync` | Sync with local MEMORY.md |
|
|
56
|
+
| `agentmemory export` | Export as JSON |
|
|
57
|
+
| `agentmemory import <file>` | Import from JSON |
|
|
58
|
+
|
|
59
|
+
## Options
|
|
60
|
+
|
|
61
|
+
### Global Options
|
|
62
|
+
|
|
63
|
+
- `--json` - Output as JSON (for scripting)
|
|
64
|
+
- `--help` - Show help
|
|
65
|
+
|
|
66
|
+
### Store Options
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
agentmemory store "content" --category preferences
|
|
70
|
+
agentmemory store "content" --metadata '{"priority": "high"}'
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Search Options
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
agentmemory search "query" --limit 20
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Sync Options
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
agentmemory sync # Bidirectional sync
|
|
83
|
+
agentmemory sync --push # Push local to cloud only
|
|
84
|
+
agentmemory sync --pull # Pull cloud to local only
|
|
85
|
+
agentmemory sync --status # Check sync status
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Configuration
|
|
89
|
+
|
|
90
|
+
Configuration is stored in `~/.agentmemory/config.json`:
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"api_key": "am_xxxxx",
|
|
95
|
+
"api_url": "https://agentmemory.cloud/api",
|
|
96
|
+
"memory_file": "./MEMORY.md"
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Environment Variables
|
|
101
|
+
|
|
102
|
+
You can also use environment variables:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
export AGENTMEMORY_API_KEY=am_xxxxx
|
|
106
|
+
export AGENTMEMORY_API_URL=https://agentmemory.cloud/api
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## MEMORY.md Sync
|
|
110
|
+
|
|
111
|
+
The CLI can sync with a local `MEMORY.md` file, enabling:
|
|
112
|
+
|
|
113
|
+
- **Offline editing** - Edit memories locally, sync later
|
|
114
|
+
- **Backup** - Keep a local copy of all memories
|
|
115
|
+
- **Migration** - Import existing MEMORY.md files
|
|
116
|
+
|
|
117
|
+
### Format
|
|
118
|
+
|
|
119
|
+
```markdown
|
|
120
|
+
# Agent Memory
|
|
121
|
+
|
|
122
|
+
> Last synced: 2026-02-01T12:00:00Z
|
|
123
|
+
> Total memories: 42
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
<!-- id: abc123 -->
|
|
128
|
+
<!-- metadata: {"category": "preferences"} -->
|
|
129
|
+
User prefers dark mode
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
<!-- id: def456 -->
|
|
134
|
+
Another memory here
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
## Examples
|
|
140
|
+
|
|
141
|
+
### Store with metadata
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
agentmemory store "Project deadline is March 15" \
|
|
145
|
+
--category deadline \
|
|
146
|
+
--metadata '{"project": "website-redesign", "priority": "high"}'
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
### Export and backup
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
# Export to file
|
|
153
|
+
agentmemory export --output backup.json --pretty
|
|
154
|
+
|
|
155
|
+
# Export to stdout (for piping)
|
|
156
|
+
agentmemory export > memories-$(date +%Y%m%d).json
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Import memories
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
agentmemory import backup.json
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Scripting with JSON output
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
# Get memories as JSON for processing
|
|
169
|
+
agentmemory list --json | jq '.memories[].content'
|
|
170
|
+
|
|
171
|
+
# Search and process results
|
|
172
|
+
agentmemory search "preferences" --json | jq '.[] | .content'
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## For AI Agents
|
|
176
|
+
|
|
177
|
+
Add to your agent's skill file:
|
|
178
|
+
|
|
179
|
+
```bash
|
|
180
|
+
# Store a memory
|
|
181
|
+
agentmemory store "$MEMORY_CONTENT"
|
|
182
|
+
|
|
183
|
+
# Search before asking
|
|
184
|
+
RESULTS=$(agentmemory search "$QUERY" --json)
|
|
185
|
+
|
|
186
|
+
# Sync at session start
|
|
187
|
+
agentmemory sync --pull
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Support
|
|
191
|
+
|
|
192
|
+
- **Documentation**: https://agentmemory.cloud/docs
|
|
193
|
+
- **Dashboard**: https://agentmemory.cloud/dashboard
|
|
194
|
+
- **Issues**: https://github.com/agentmemory/agentmemory-cli/issues
|
|
195
|
+
|
|
196
|
+
## License
|
|
197
|
+
|
|
198
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.d.ts","sourceRoot":"","sources":["../../src/commands/delete.ts"],"names":[],"mappings":"AAKA,UAAU,aAAa;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAgBD,wBAAsB,aAAa,CACjC,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,IAAI,CAAC,CA4Cf"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.deleteCommand = deleteCommand;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const readline_1 = require("readline");
|
|
9
|
+
const api_js_1 = require("../lib/api.js");
|
|
10
|
+
const config_js_1 = require("../lib/config.js");
|
|
11
|
+
async function confirm(question) {
|
|
12
|
+
const rl = (0, readline_1.createInterface)({
|
|
13
|
+
input: process.stdin,
|
|
14
|
+
output: process.stdout,
|
|
15
|
+
});
|
|
16
|
+
return new Promise((resolve) => {
|
|
17
|
+
rl.question(question, (answer) => {
|
|
18
|
+
rl.close();
|
|
19
|
+
resolve(answer.toLowerCase() === 'y' || answer.toLowerCase() === 'yes');
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
async function deleteCommand(id, options) {
|
|
24
|
+
if (!(0, config_js_1.isConfigured)()) {
|
|
25
|
+
console.log(chalk_1.default.red('ā Not configured. Run "agentmemory init" first.'));
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
// First, get the memory to show what will be deleted
|
|
30
|
+
if (!options.force) {
|
|
31
|
+
try {
|
|
32
|
+
const memory = await (0, api_js_1.getMemory)(id);
|
|
33
|
+
const preview = memory.content.length > 100
|
|
34
|
+
? memory.content.substring(0, 100) + '...'
|
|
35
|
+
: memory.content;
|
|
36
|
+
console.log(chalk_1.default.yellow('\nMemory to delete:'));
|
|
37
|
+
console.log(chalk_1.default.white(` "${preview}"`));
|
|
38
|
+
console.log(chalk_1.default.dim(` Created: ${memory.created_at}\n`));
|
|
39
|
+
const confirmed = await confirm('Are you sure you want to delete this memory? (y/N): ');
|
|
40
|
+
if (!confirmed) {
|
|
41
|
+
console.log(chalk_1.default.dim('Cancelled.'));
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// Memory might not exist, proceed anyway
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
await (0, api_js_1.deleteMemory)(id);
|
|
50
|
+
if (options.json) {
|
|
51
|
+
console.log(JSON.stringify({ success: true, deleted: id }));
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
console.log(chalk_1.default.green('ā
Memory deleted successfully!'));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error instanceof Error) {
|
|
59
|
+
console.log(chalk_1.default.red(`ā Error: ${error.message}`));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
console.log(chalk_1.default.red('ā Unknown error occurred'));
|
|
63
|
+
}
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=delete.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delete.js","sourceRoot":"","sources":["../../src/commands/delete.ts"],"names":[],"mappings":";;;;;AAwBA,sCA+CC;AAvED,kDAA0B;AAC1B,uCAA2C;AAC3C,0CAAwD;AACxD,gDAAgD;AAOhD,KAAK,UAAU,OAAO,CAAC,QAAgB;IACrC,MAAM,EAAE,GAAG,IAAA,0BAAe,EAAC;QACzB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;IAEH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE;YAC/B,EAAE,CAAC,KAAK,EAAE,CA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AAC;oBACrC,OAAO;gBACT,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,yCAAyC;YAC3C,CAAC;QACH,CAAC;QAED,MAAM,IAAA,qBAAY,EAAC,EAAE,CAAC,CAAC;QAEvB,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QAC9D,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,KAAK,CAAC,gCAAgC,CAAC,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,YAAY,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACtD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":"AAKA,UAAU,aAAa;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC,CAmCzE"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.exportCommand = exportCommand;
|
|
40
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const api_js_1 = require("../lib/api.js");
|
|
43
|
+
const config_js_1 = require("../lib/config.js");
|
|
44
|
+
async function exportCommand(options) {
|
|
45
|
+
if (!(0, config_js_1.isConfigured)()) {
|
|
46
|
+
console.log(chalk_1.default.red('ā Not configured. Run "agentmemory init" first.'));
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
try {
|
|
50
|
+
console.log(chalk_1.default.dim('Fetching all memories...'));
|
|
51
|
+
const memories = await (0, api_js_1.getAllMemories)();
|
|
52
|
+
const exportData = {
|
|
53
|
+
exported_at: new Date().toISOString(),
|
|
54
|
+
total_memories: memories.length,
|
|
55
|
+
memories: memories,
|
|
56
|
+
};
|
|
57
|
+
const jsonOutput = options.pretty
|
|
58
|
+
? JSON.stringify(exportData, null, 2)
|
|
59
|
+
: JSON.stringify(exportData);
|
|
60
|
+
if (options.output) {
|
|
61
|
+
fs.writeFileSync(options.output, jsonOutput);
|
|
62
|
+
console.log(chalk_1.default.green(`ā
Exported ${memories.length} memories to ${options.output}`));
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// Output to stdout for piping
|
|
66
|
+
console.log(jsonOutput);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
if (error instanceof Error) {
|
|
71
|
+
console.error(chalk_1.default.red(`ā Error: ${error.message}`));
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
console.error(chalk_1.default.red('ā Unknown error occurred'));
|
|
75
|
+
}
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=export.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/commands/export.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,sCAmCC;AA7CD,kDAA0B;AAC1B,uCAAyB;AACzB,0CAA+C;AAC/C,gDAAgD;AAOzC,KAA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AC,CAAC;QACxD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CAAC,eAAK,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC,CAAC;QACvD,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.d.ts","sourceRoot":"","sources":["../../src/commands/import.ts"],"names":[],"mappings":"AAMA,UAAU,aAAa;IACrB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AASD,wBAAsB,aAAa,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,aAAa,GACrB,OAAO,CAAC,IAAI,CAAC,CAkEf"}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.importCommand = importCommand;
|
|
40
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const api_js_1 = require("../lib/api.js");
|
|
43
|
+
const config_js_1 = require("../lib/config.js");
|
|
44
|
+
async function importCommand(file, options) {
|
|
45
|
+
if (!(0, config_js_1.isConfigured)()) {
|
|
46
|
+
console.log(chalk_1.default.red('ā Not configured. Run "agentmemory init" first.'));
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
// Check if file exists
|
|
50
|
+
if (!fs.existsSync(file)) {
|
|
51
|
+
console.log(chalk_1.default.red(`ā File not found: ${file}`));
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
try {
|
|
55
|
+
const content = fs.readFileSync(file, 'utf-8');
|
|
56
|
+
const data = JSON.parse(content);
|
|
57
|
+
if (!data.memories || !Array.isArray(data.memories)) {
|
|
58
|
+
console.log(chalk_1.default.red('ā Invalid import file format. Expected { memories: [...] }'));
|
|
59
|
+
process.exit(1);
|
|
60
|
+
}
|
|
61
|
+
console.log(chalk_1.default.dim(`Importing ${data.memories.length} memories...`));
|
|
62
|
+
let imported = 0;
|
|
63
|
+
let failed = 0;
|
|
64
|
+
const results = [];
|
|
65
|
+
for (const memory of data.memories) {
|
|
66
|
+
try {
|
|
67
|
+
const result = await (0, api_js_1.storeMemory)(memory.content, memory.metadata);
|
|
68
|
+
results.push(result);
|
|
69
|
+
imported++;
|
|
70
|
+
if (!options.json) {
|
|
71
|
+
process.stdout.write(chalk_1.default.green('.'));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
catch (error) {
|
|
75
|
+
failed++;
|
|
76
|
+
if (!options.json) {
|
|
77
|
+
process.stdout.write(chalk_1.default.red('x'));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
if (options.json) {
|
|
82
|
+
console.log(JSON.stringify({
|
|
83
|
+
success: true,
|
|
84
|
+
imported,
|
|
85
|
+
failed,
|
|
86
|
+
memories: results,
|
|
87
|
+
}, null, 2));
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
console.log('\n');
|
|
91
|
+
console.log(chalk_1.default.green(`ā
Imported ${imported} memories successfully`));
|
|
92
|
+
if (failed > 0) {
|
|
93
|
+
console.log(chalk_1.default.yellow(`ā ļø ${failed} memories failed to import`));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
if (error instanceof Error) {
|
|
99
|
+
console.log(chalk_1.default.red(`ā Error: ${error.message}`));
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
console.log(chalk_1.default.red('ā Unknown error occurred'));
|
|
103
|
+
}
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
//# sourceMappingURL=import.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"import.js","sourceRoot":"","sources":["../../src/commands/import.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiBA,sCAqEC;AAtFD,kDAA0B;AAC1B,uC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C,GAAG,CAAC,YAAY,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACtD,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,0BAA0B,CAAC,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAkBA,wBAAsB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAoDjD"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.initCommand = initCommand;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const readline_1 = require("readline");
|
|
9
|
+
const config_js_1 = require("../lib/config.js");
|
|
10
|
+
async function prompt(question) {
|
|
11
|
+
const rl = (0, readline_1.createInterface)({
|
|
12
|
+
input: process.stdin,
|
|
13
|
+
output: process.stdout,
|
|
14
|
+
});
|
|
15
|
+
return new Promise((resolve) => {
|
|
16
|
+
rl.question(question, (answer) => {
|
|
17
|
+
rl.close();
|
|
18
|
+
resolve(answer.trim());
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
async function initCommand() {
|
|
23
|
+
console.log(chalk_1.default.cyan('\nš§ AgentMemory CLI Setup\n'));
|
|
24
|
+
if ((0, config_js_1.isConfigured)()) {
|
|
25
|
+
const config = (0, config_js_1.loadConfig)();
|
|
26
|
+
console.log(chalk_1.default.yellow('You already have a configuration:'));
|
|
27
|
+
console.log(` API Key: ${config.api_key.substring(0, 10)}...`);
|
|
28
|
+
console.log(` API URL: ${config.api_url}`);
|
|
29
|
+
console.log(` Memory File: ${config.memory_file}\n`);
|
|
30
|
+
const overwrite = await prompt('Do you want to reconfigure? (y/N): ');
|
|
31
|
+
if (overwrite.toLowerCase() !== 'y') {
|
|
32
|
+
console.log(chalk_1.default.green('\nConfiguration unchanged.'));
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
console.log(chalk_1.default.dim('Get your API key from: https://agentmemory.cloud/dashboard\n'));
|
|
37
|
+
// Get API key
|
|
38
|
+
const apiKey = await prompt('Enter your API key (am_xxxxx): ');
|
|
39
|
+
if (!apiKey.startsWith('am_')) {
|
|
40
|
+
console.log(chalk_1.default.red('\nā Invalid API key format. Should start with "am_"'));
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
// Get API URL (with default)
|
|
44
|
+
const defaultUrl = 'https://agentmemory.cloud/api';
|
|
45
|
+
const apiUrlInput = await prompt(`API URL (${defaultUrl}): `);
|
|
46
|
+
const apiUrl = apiUrlInput || defaultUrl;
|
|
47
|
+
// Get memory file path (with default)
|
|
48
|
+
const defaultMemoryFile = './MEMORY.md';
|
|
49
|
+
const memoryFileInput = await prompt(`Local memory file path (${defaultMemoryFile}): `);
|
|
50
|
+
const memoryFile = memoryFileInput || defaultMemoryFile;
|
|
51
|
+
// Save configuration
|
|
52
|
+
(0, config_js_1.saveConfig)({
|
|
53
|
+
api_key: apiKey,
|
|
54
|
+
api_url: apiUrl,
|
|
55
|
+
memory_file: memoryFile,
|
|
56
|
+
});
|
|
57
|
+
console.log(chalk_1.default.green('\nā
Configuration saved!'));
|
|
58
|
+
console.log(chalk_1.default.dim(` Config file: ${(0, config_js_1.getConfigPath)()}\n`));
|
|
59
|
+
console.log(chalk_1.default.cyan('You can now use AgentMemory CLI:'));
|
|
60
|
+
console.log(chalk_1.default.dim(' agentmemory store "Your memory content"'));
|
|
61
|
+
console.log(chalk_1.default.dim(' agentmemory search "query"'));
|
|
62
|
+
console.log(chalk_1.default.dim(' agentmemory list'));
|
|
63
|
+
console.log(chalk_1.default.dim(' agentmemory sync\n'));
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":";;;;;AAkBA,kCAoDC;AAtED,kDAA0B;AAC1B,uCAA2C;AAC3C,gDAAuF;AAEvF,KAAK,UAAU,MAAM,CAAC,QAAgB;IACpC,MAAM,EAAE,GAAG,IAAA,0BAAe,EAAC;QACzB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;IAEH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE;YAC/B,EAAE,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAEM,KAAK,UAAU,WAAW;IAC/B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IAExD,IAAI,IAAA,wBAAY,GAAE,EAAE,CAAC;QACnB,MAAM,MAAM,GAAG,IAAA,sBAAU,GAAE,CAAC;QAC5B,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,mCAAmC,CAAC,CAAC,CAAC;QAC/D,OAAO,CAAC,GAAG,CAAC,cAAc,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC;QAChE,OAAO,CAAC,GAAG,CAAC,cAAc,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QAC5C,OA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IACrD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,mBAAmB,IAAA,yBAAa,GAAE,IAAI,CAAC,CAAC,CAAC;IAE/D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAC,CAAC;IAC5D,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC,CAAC;IACpE,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACvD,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":"AAIA,UAAU,WAAW;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAkDrE"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.listCommand = listCommand;
|
|
7
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
8
|
+
const api_js_1 = require("../lib/api.js");
|
|
9
|
+
const config_js_1 = require("../lib/config.js");
|
|
10
|
+
async function listCommand(options) {
|
|
11
|
+
if (!(0, config_js_1.isConfigured)()) {
|
|
12
|
+
console.log(chalk_1.default.red('ā Not configured. Run "agentmemory init" first.'));
|
|
13
|
+
process.exit(1);
|
|
14
|
+
}
|
|
15
|
+
try {
|
|
16
|
+
const limit = options.limit ? parseInt(options.limit, 10) : 50;
|
|
17
|
+
const offset = options.offset ? parseInt(options.offset, 10) : 0;
|
|
18
|
+
const response = await (0, api_js_1.listMemories)(limit, offset);
|
|
19
|
+
if (options.json) {
|
|
20
|
+
console.log(JSON.stringify(response, null, 2));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (response.memories.length === 0) {
|
|
24
|
+
console.log(chalk_1.default.yellow('No memories found.'));
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
console.log(chalk_1.default.cyan(`\nš Memories (${response.memories.length} of ${response.total}):\n`));
|
|
28
|
+
for (const memory of response.memories) {
|
|
29
|
+
const date = new Date(memory.created_at).toLocaleDateString();
|
|
30
|
+
const preview = memory.content.length > 80
|
|
31
|
+
? memory.content.substring(0, 80) + '...'
|
|
32
|
+
: memory.content;
|
|
33
|
+
console.log(chalk_1.default.green(`⢠`) + chalk_1.default.white(preview));
|
|
34
|
+
console.log(chalk_1.default.dim(` ID: ${memory.id} | Created: ${date}`));
|
|
35
|
+
if (memory.metadata && Object.keys(memory.metadata).length > 0) {
|
|
36
|
+
console.log(chalk_1.default.dim(` Metadata: ${JSON.stringify(memory.metadata)}`));
|
|
37
|
+
}
|
|
38
|
+
console.log();
|
|
39
|
+
}
|
|
40
|
+
if (response.total > response.memories.length + offset) {
|
|
41
|
+
const remaining = response.total - response.memories.length - offset;
|
|
42
|
+
console.log(chalk_1.default.dim(`... and ${remaining} more. Use --offset to paginate.`));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (error instanceof Error) {
|
|
47
|
+
console.log(chalk_1.default.red(`ā Error: ${error.message}`));
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
console.log(chalk_1.default.red('ā Unknown error occurred'));
|
|
51
|
+
}
|
|
52
|
+
process.exit(1);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=list.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../src/commands/list.ts"],"names":[],"mappings":";;;;;AAUA,kCAkDC;AA5DD,kDAA0B;AAC1B,0CAA6C;AAC7C,gDAAgD;AAQzC,KAAK,UAAU,WAAW,CAAC,OAAoB;IACpD,IAAI,CAAC,IAAA,wBAAY,GAAE,EAAE,CAAC;QACpB,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,GAAG,CAAC,iDAAiD,CAAC,CAAC,CAAC;QAC1E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/D,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAEjE,MAAM,QAAQ,GAAG,MAAM,IAAA,qBAAY,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QAEnD,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;YACjB,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAC/C,OAAO;QACT,CAAC;QAED,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO,CAAC,GAAG,CAAC,eAAK,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;YAChD,OAAO;QACT,CAAC;QAED,OAAO,C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