@cortexmemory/cli 0.1.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.
Files changed (75) hide show
  1. package/README.md +325 -0
  2. package/dist/commands/conversations.d.ts +16 -0
  3. package/dist/commands/conversations.d.ts.map +1 -0
  4. package/dist/commands/conversations.js +421 -0
  5. package/dist/commands/conversations.js.map +1 -0
  6. package/dist/commands/convex.d.ts +17 -0
  7. package/dist/commands/convex.d.ts.map +1 -0
  8. package/dist/commands/convex.js +442 -0
  9. package/dist/commands/convex.js.map +1 -0
  10. package/dist/commands/db.d.ts +16 -0
  11. package/dist/commands/db.d.ts.map +1 -0
  12. package/dist/commands/db.js +371 -0
  13. package/dist/commands/db.js.map +1 -0
  14. package/dist/commands/dev.d.ts +16 -0
  15. package/dist/commands/dev.d.ts.map +1 -0
  16. package/dist/commands/dev.js +558 -0
  17. package/dist/commands/dev.js.map +1 -0
  18. package/dist/commands/facts.d.ts +17 -0
  19. package/dist/commands/facts.d.ts.map +1 -0
  20. package/dist/commands/facts.js +386 -0
  21. package/dist/commands/facts.js.map +1 -0
  22. package/dist/commands/memory.d.ts +18 -0
  23. package/dist/commands/memory.d.ts.map +1 -0
  24. package/dist/commands/memory.js +486 -0
  25. package/dist/commands/memory.js.map +1 -0
  26. package/dist/commands/setup.d.ts +14 -0
  27. package/dist/commands/setup.d.ts.map +1 -0
  28. package/dist/commands/setup.js +494 -0
  29. package/dist/commands/setup.js.map +1 -0
  30. package/dist/commands/spaces.d.ts +18 -0
  31. package/dist/commands/spaces.d.ts.map +1 -0
  32. package/dist/commands/spaces.js +553 -0
  33. package/dist/commands/spaces.js.map +1 -0
  34. package/dist/commands/users.d.ts +18 -0
  35. package/dist/commands/users.d.ts.map +1 -0
  36. package/dist/commands/users.js +486 -0
  37. package/dist/commands/users.js.map +1 -0
  38. package/dist/index.d.ts +9 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +70 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/types.d.ts +144 -0
  43. package/dist/types.d.ts.map +1 -0
  44. package/dist/types.js +5 -0
  45. package/dist/types.js.map +1 -0
  46. package/dist/utils/__tests__/config.test.d.ts +5 -0
  47. package/dist/utils/__tests__/config.test.d.ts.map +1 -0
  48. package/dist/utils/__tests__/config.test.js +127 -0
  49. package/dist/utils/__tests__/config.test.js.map +1 -0
  50. package/dist/utils/__tests__/formatting.test.d.ts +5 -0
  51. package/dist/utils/__tests__/formatting.test.d.ts.map +1 -0
  52. package/dist/utils/__tests__/formatting.test.js +132 -0
  53. package/dist/utils/__tests__/formatting.test.js.map +1 -0
  54. package/dist/utils/__tests__/validation.test.d.ts +5 -0
  55. package/dist/utils/__tests__/validation.test.d.ts.map +1 -0
  56. package/dist/utils/__tests__/validation.test.js +207 -0
  57. package/dist/utils/__tests__/validation.test.js.map +1 -0
  58. package/dist/utils/client.d.ts +42 -0
  59. package/dist/utils/client.d.ts.map +1 -0
  60. package/dist/utils/client.js +108 -0
  61. package/dist/utils/client.js.map +1 -0
  62. package/dist/utils/config.d.ts +67 -0
  63. package/dist/utils/config.d.ts.map +1 -0
  64. package/dist/utils/config.js +261 -0
  65. package/dist/utils/config.js.map +1 -0
  66. package/dist/utils/formatting.d.ts +81 -0
  67. package/dist/utils/formatting.d.ts.map +1 -0
  68. package/dist/utils/formatting.js +239 -0
  69. package/dist/utils/formatting.js.map +1 -0
  70. package/dist/utils/validation.d.ts +83 -0
  71. package/dist/utils/validation.d.ts.map +1 -0
  72. package/dist/utils/validation.js +243 -0
  73. package/dist/utils/validation.js.map +1 -0
  74. package/package.json +72 -0
  75. package/templates/.cortexrc.template +15 -0
package/README.md ADDED
@@ -0,0 +1,325 @@
1
+ # @cortexmemory/cli
2
+
3
+ CLI tool for managing Cortex Memory deployments, performing administrative tasks, and streamlining development workflows.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Install globally
9
+ npm install -g @cortexmemory/cli
10
+
11
+ # Or use with npx
12
+ npx @cortexmemory/cli <command>
13
+
14
+ # Or install as dev dependency in your project
15
+ npm install --save-dev @cortexmemory/cli
16
+ ```
17
+
18
+ ## Quick Start
19
+
20
+ ```bash
21
+ # Run interactive setup
22
+ cortex setup
23
+
24
+ # Check database statistics
25
+ cortex db stats
26
+
27
+ # List memory spaces
28
+ cortex spaces list
29
+
30
+ # Search memories
31
+ cortex memory search "password" --space agent-1
32
+ ```
33
+
34
+ ## Commands
35
+
36
+ ### Memory Operations
37
+
38
+ ```bash
39
+ # Clear all memories for a user
40
+ cortex memory clear --user user-123 --space agent-1
41
+
42
+ # Clear all memories in a space
43
+ cortex memory clear --space agent-1
44
+
45
+ # List memories
46
+ cortex memory list --space agent-1 [--user user-123] [--limit 50]
47
+
48
+ # Search memories
49
+ cortex memory search "query" --space agent-1
50
+
51
+ # Delete specific memory
52
+ cortex memory delete mem-123 --space agent-1
53
+
54
+ # Export memories
55
+ cortex memory export --space agent-1 --output memories.json
56
+
57
+ # Memory statistics
58
+ cortex memory stats --space agent-1
59
+ ```
60
+
61
+ ### User Management
62
+
63
+ ```bash
64
+ # List all users
65
+ cortex users list [--limit 100]
66
+
67
+ # Get user profile
68
+ cortex users get user-123
69
+
70
+ # Delete user with GDPR cascade deletion
71
+ cortex users delete user-123 --cascade [--dry-run]
72
+
73
+ # Delete multiple users
74
+ cortex users delete-many user-1 user-2 --cascade
75
+
76
+ # Export user data
77
+ cortex users export user-123 --output user-data.json
78
+
79
+ # User statistics
80
+ cortex users stats user-123
81
+ ```
82
+
83
+ ### Memory Spaces
84
+
85
+ ```bash
86
+ # List memory spaces
87
+ cortex spaces list [--type team|personal|project]
88
+
89
+ # Create memory space
90
+ cortex spaces create team-alpha --type team --name "Team Alpha"
91
+
92
+ # Delete memory space with cascade
93
+ cortex spaces delete team-alpha --cascade
94
+
95
+ # Archive space
96
+ cortex spaces archive project-apollo --reason "Completed"
97
+
98
+ # Get space statistics
99
+ cortex spaces stats team-alpha
100
+
101
+ # Manage participants
102
+ cortex spaces participants team-alpha
103
+ cortex spaces add-participant team-alpha --id user-123 --type user
104
+ cortex spaces remove-participant team-alpha --id user-123
105
+ ```
106
+
107
+ ### Facts Operations
108
+
109
+ ```bash
110
+ # List facts
111
+ cortex facts list --space agent-1 [--type preference]
112
+
113
+ # Search facts
114
+ cortex facts search "dark mode" --space agent-1
115
+
116
+ # Delete facts
117
+ cortex facts delete fact-123 --space agent-1
118
+
119
+ # Export facts
120
+ cortex facts export --space agent-1 --output facts.json
121
+ ```
122
+
123
+ ### Conversations
124
+
125
+ ```bash
126
+ # List conversations
127
+ cortex conversations list [--user user-123] [--space agent-1]
128
+
129
+ # Get conversation with messages
130
+ cortex conversations get conv-123
131
+
132
+ # Delete conversation
133
+ cortex conversations delete conv-123
134
+
135
+ # Export conversation
136
+ cortex conversations export conv-123 --output conversation.json
137
+ ```
138
+
139
+ ### Convex Management
140
+
141
+ ```bash
142
+ # Deploy schema updates
143
+ cortex convex deploy [--local|--prod]
144
+
145
+ # Check deployment status
146
+ cortex convex status
147
+
148
+ # View logs
149
+ cortex convex logs [--local|--prod] [--tail]
150
+
151
+ # Update SDK version
152
+ cortex convex update-sdk [--latest|--version 0.12.0]
153
+
154
+ # Sync schema
155
+ cortex convex schema sync
156
+ ```
157
+
158
+ ### Database Operations
159
+
160
+ ```bash
161
+ # Database statistics
162
+ cortex db stats
163
+
164
+ # Clear entire database (dangerous!)
165
+ cortex db clear --confirm "I understand this is irreversible"
166
+
167
+ # Backup database
168
+ cortex db backup --output backup.json
169
+
170
+ # Restore from backup
171
+ cortex db restore --input backup.json [--dry-run]
172
+ ```
173
+
174
+ ### Development Utilities
175
+
176
+ ```bash
177
+ # Seed test data
178
+ cortex dev seed [--users 10] [--memories 100]
179
+
180
+ # Clear test data
181
+ cortex dev clear-test-data
182
+
183
+ # Generate sample data
184
+ cortex dev generate-data --template chatbot
185
+ ```
186
+
187
+ ### Configuration
188
+
189
+ ```bash
190
+ # Interactive setup
191
+ cortex setup
192
+
193
+ # Configure deployment
194
+ cortex config set convex-url https://my-deployment.convex.cloud
195
+ cortex config set convex-key "..."
196
+
197
+ # Show current configuration
198
+ cortex config show
199
+
200
+ # Test connection
201
+ cortex config test
202
+ ```
203
+
204
+ ## Configuration
205
+
206
+ The CLI looks for configuration in the following order (highest priority first):
207
+
208
+ 1. CLI flags: `--url`, `--key`, `--deployment`
209
+ 2. Environment variables: `CONVEX_URL`, `CONVEX_DEPLOY_KEY`
210
+ 3. Project config: `./cortex.config.json`
211
+ 4. User config: `~/.cortexrc`
212
+
213
+ ### Config File Format (~/.cortexrc)
214
+
215
+ ```json
216
+ {
217
+ "deployments": {
218
+ "local": {
219
+ "url": "http://127.0.0.1:3210",
220
+ "deployment": "anonymous:anonymous-cortex-sdk-local"
221
+ },
222
+ "staging": {
223
+ "url": "https://staging.convex.cloud",
224
+ "key": "..."
225
+ },
226
+ "production": {
227
+ "url": "https://prod.convex.cloud",
228
+ "key": "..."
229
+ }
230
+ },
231
+ "default": "local",
232
+ "format": "table",
233
+ "confirmDangerous": true
234
+ }
235
+ ```
236
+
237
+ ## Global Options
238
+
239
+ All commands support these global options:
240
+
241
+ - `-d, --deployment <name>` - Use a named deployment from config
242
+ - `-u, --url <url>` - Override Convex deployment URL
243
+ - `-k, --key <key>` - Override Convex deploy key
244
+ - `-f, --format <format>` - Output format: table, json, csv
245
+ - `-q, --quiet` - Suppress non-essential output
246
+ - `--debug` - Enable debug output
247
+
248
+ ## Safety Features
249
+
250
+ - **Confirmation prompts** for dangerous operations (delete, clear)
251
+ - **Dry-run mode** for previewing changes without executing
252
+ - **Verification** after cascade deletions
253
+ - **Backups** before destructive operations
254
+
255
+ ## Development
256
+
257
+ ### Running Tests
258
+
259
+ Tests run against a real Convex instance (local or managed), using the same environment as the SDK tests.
260
+
261
+ ```bash
262
+ # Run all tests (requires Convex running)
263
+ npm test
264
+
265
+ # Run tests in watch mode
266
+ npm run test:watch
267
+
268
+ # Run with coverage
269
+ npm run test:coverage
270
+
271
+ # Run only unit tests (utilities - no Convex needed)
272
+ npm run test:unit
273
+
274
+ # Run only integration tests (requires Convex)
275
+ npm run test:integration
276
+
277
+ # Type checking
278
+ npm run typecheck
279
+ ```
280
+
281
+ ### Environment Setup
282
+
283
+ Tests use environment variables from the monorepo root:
284
+
285
+ - `.env.test` - Test defaults
286
+ - `.env.local` - Local overrides
287
+
288
+ Key variables:
289
+
290
+ - `LOCAL_CONVEX_URL` - Local Convex URL (e.g., `http://127.0.0.1:3210`)
291
+ - `CONVEX_URL` - Managed Convex URL
292
+ - `CONVEX_TEST_MODE` - `local`, `managed`, or `auto`
293
+
294
+ ### Test Structure
295
+
296
+ ```
297
+ tests/
298
+ ├── env.ts # Environment setup (runs first)
299
+ ├── setup.ts # Test hooks and cleanup
300
+ ├── memory.test.ts # Memory commands integration tests
301
+ ├── users.test.ts # User commands integration tests
302
+ └── spaces.test.ts # Space commands integration tests
303
+
304
+ src/utils/__tests__/
305
+ ├── validation.test.ts # Input validation unit tests
306
+ ├── formatting.test.ts # Output formatting unit tests
307
+ └── config.test.ts # Config management unit tests
308
+ ```
309
+
310
+ ### Building
311
+
312
+ ```bash
313
+ # Build the CLI
314
+ npm run build
315
+
316
+ # Watch mode for development
317
+ npm run dev
318
+
319
+ # Lint
320
+ npm run lint
321
+ ```
322
+
323
+ ## License
324
+
325
+ Apache-2.0
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Conversations Commands
3
+ *
4
+ * Commands for managing conversations:
5
+ * - list: List conversations
6
+ * - get: Get conversation with messages
7
+ * - delete: Delete a conversation
8
+ * - export: Export conversation
9
+ */
10
+ import { Command } from "commander";
11
+ import type { CLIConfig } from "../types.js";
12
+ /**
13
+ * Register conversations commands
14
+ */
15
+ export declare function registerConversationsCommands(program: Command, config: CLIConfig): void;
16
+ //# sourceMappingURL=conversations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../src/commands/conversations.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,KAAK,EAAE,SAAS,EAAgB,MAAM,aAAa,CAAC;AAwB3D;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,SAAS,GAChB,IAAI,CA8eN"}