@memnexus-ai/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 (148) hide show
  1. package/.env.example +13 -0
  2. package/.eslintrc.js +24 -0
  3. package/.github/ISSUE_TEMPLATE/phase-1-foundation.md +1078 -0
  4. package/.github/workflows/publish.yml +277 -0
  5. package/.github/workflows/test-app-token.yml +54 -0
  6. package/.npmrc.backup +3 -0
  7. package/.npmrc.example +6 -0
  8. package/.prettierignore +4 -0
  9. package/.prettierrc +8 -0
  10. package/CHANGELOG.md +138 -0
  11. package/PLATFORM_TESTING.md +243 -0
  12. package/README.md +986 -0
  13. package/RELEASE.md +428 -0
  14. package/RELEASE_READINESS.md +253 -0
  15. package/USAGE.md +1373 -0
  16. package/bin/mx.js +2 -0
  17. package/dist/commands/apikeys.d.ts +7 -0
  18. package/dist/commands/apikeys.d.ts.map +1 -0
  19. package/dist/commands/apikeys.js +133 -0
  20. package/dist/commands/apikeys.js.map +1 -0
  21. package/dist/commands/artifacts.d.ts +7 -0
  22. package/dist/commands/artifacts.d.ts.map +1 -0
  23. package/dist/commands/artifacts.js +277 -0
  24. package/dist/commands/artifacts.js.map +1 -0
  25. package/dist/commands/auth.d.ts +7 -0
  26. package/dist/commands/auth.d.ts.map +1 -0
  27. package/dist/commands/auth.js +119 -0
  28. package/dist/commands/auth.js.map +1 -0
  29. package/dist/commands/communities.d.ts +7 -0
  30. package/dist/commands/communities.d.ts.map +1 -0
  31. package/dist/commands/communities.js +137 -0
  32. package/dist/commands/communities.js.map +1 -0
  33. package/dist/commands/config.d.ts +7 -0
  34. package/dist/commands/config.d.ts.map +1 -0
  35. package/dist/commands/config.js +138 -0
  36. package/dist/commands/config.js.map +1 -0
  37. package/dist/commands/conversations.d.ts +7 -0
  38. package/dist/commands/conversations.d.ts.map +1 -0
  39. package/dist/commands/conversations.js +160 -0
  40. package/dist/commands/conversations.js.map +1 -0
  41. package/dist/commands/facts.d.ts +7 -0
  42. package/dist/commands/facts.d.ts.map +1 -0
  43. package/dist/commands/facts.js +298 -0
  44. package/dist/commands/facts.js.map +1 -0
  45. package/dist/commands/graphrag.d.ts +7 -0
  46. package/dist/commands/graphrag.d.ts.map +1 -0
  47. package/dist/commands/graphrag.js +139 -0
  48. package/dist/commands/graphrag.js.map +1 -0
  49. package/dist/commands/memories.d.ts +7 -0
  50. package/dist/commands/memories.d.ts.map +1 -0
  51. package/dist/commands/memories.js +304 -0
  52. package/dist/commands/memories.js.map +1 -0
  53. package/dist/commands/patterns.d.ts +7 -0
  54. package/dist/commands/patterns.d.ts.map +1 -0
  55. package/dist/commands/patterns.js +227 -0
  56. package/dist/commands/patterns.js.map +1 -0
  57. package/dist/commands/system.d.ts +7 -0
  58. package/dist/commands/system.d.ts.map +1 -0
  59. package/dist/commands/system.js +97 -0
  60. package/dist/commands/system.js.map +1 -0
  61. package/dist/commands/topics.d.ts +7 -0
  62. package/dist/commands/topics.d.ts.map +1 -0
  63. package/dist/commands/topics.js +314 -0
  64. package/dist/commands/topics.js.map +1 -0
  65. package/dist/index.d.ts +3 -0
  66. package/dist/index.d.ts.map +1 -0
  67. package/dist/index.js +44 -0
  68. package/dist/index.js.map +1 -0
  69. package/dist/lib/api-client.d.ts +29 -0
  70. package/dist/lib/api-client.d.ts.map +1 -0
  71. package/dist/lib/api-client.js +64 -0
  72. package/dist/lib/api-client.js.map +1 -0
  73. package/dist/lib/auth.d.ts +10 -0
  74. package/dist/lib/auth.d.ts.map +1 -0
  75. package/dist/lib/auth.js +47 -0
  76. package/dist/lib/auth.js.map +1 -0
  77. package/dist/lib/config.d.ts +19 -0
  78. package/dist/lib/config.d.ts.map +1 -0
  79. package/dist/lib/config.js +59 -0
  80. package/dist/lib/config.js.map +1 -0
  81. package/dist/lib/errors.d.ts +7 -0
  82. package/dist/lib/errors.d.ts.map +1 -0
  83. package/dist/lib/errors.js +133 -0
  84. package/dist/lib/errors.js.map +1 -0
  85. package/dist/lib/formatters.d.ts +12 -0
  86. package/dist/lib/formatters.d.ts.map +1 -0
  87. package/dist/lib/formatters.js +103 -0
  88. package/dist/lib/formatters.js.map +1 -0
  89. package/dist/lib/spinner.d.ts +54 -0
  90. package/dist/lib/spinner.d.ts.map +1 -0
  91. package/dist/lib/spinner.js +108 -0
  92. package/dist/lib/spinner.js.map +1 -0
  93. package/dist/lib/validators.d.ts +92 -0
  94. package/dist/lib/validators.d.ts.map +1 -0
  95. package/dist/lib/validators.js +257 -0
  96. package/dist/lib/validators.js.map +1 -0
  97. package/dist/types/index.d.ts +13 -0
  98. package/dist/types/index.d.ts.map +1 -0
  99. package/dist/types/index.js +3 -0
  100. package/dist/types/index.js.map +1 -0
  101. package/docs/README.md +219 -0
  102. package/docs/code-generation-strategy.md +560 -0
  103. package/docs/prd.md +748 -0
  104. package/docs/sync-strategy.md +533 -0
  105. package/jest.config.js +30 -0
  106. package/package.json +67 -0
  107. package/scripts/install-deps.sh +38 -0
  108. package/src/commands/apikeys.ts +144 -0
  109. package/src/commands/artifacts.ts +296 -0
  110. package/src/commands/auth.ts +122 -0
  111. package/src/commands/communities.ts +153 -0
  112. package/src/commands/config.ts +144 -0
  113. package/src/commands/conversations.ts +176 -0
  114. package/src/commands/facts.ts +320 -0
  115. package/src/commands/graphrag.ts +149 -0
  116. package/src/commands/memories.ts +332 -0
  117. package/src/commands/patterns.ts +251 -0
  118. package/src/commands/system.ts +102 -0
  119. package/src/commands/topics.ts +354 -0
  120. package/src/index.ts +43 -0
  121. package/src/lib/api-client.ts +68 -0
  122. package/src/lib/auth.ts +42 -0
  123. package/src/lib/config.ts +68 -0
  124. package/src/lib/errors.ts +143 -0
  125. package/src/lib/formatters.ts +123 -0
  126. package/src/lib/spinner.ts +113 -0
  127. package/src/lib/validators.ts +302 -0
  128. package/src/types/index.ts +17 -0
  129. package/tests/__mocks__/chalk.ts +16 -0
  130. package/tests/__mocks__/cli-table3.ts +37 -0
  131. package/tests/__mocks__/configstore.ts +38 -0
  132. package/tests/commands/apikeys.test.ts +179 -0
  133. package/tests/commands/artifacts.test.ts +194 -0
  134. package/tests/commands/auth.test.ts +120 -0
  135. package/tests/commands/communities.test.ts +154 -0
  136. package/tests/commands/config.test.ts +154 -0
  137. package/tests/commands/conversations.test.ts +136 -0
  138. package/tests/commands/facts.test.ts +210 -0
  139. package/tests/commands/graphrag.test.ts +194 -0
  140. package/tests/commands/memories.test.ts +215 -0
  141. package/tests/commands/patterns.test.ts +201 -0
  142. package/tests/commands/system.test.ts +172 -0
  143. package/tests/commands/topics.test.ts +274 -0
  144. package/tests/lib/auth.test.ts +77 -0
  145. package/tests/lib/config.test.ts +50 -0
  146. package/tests/lib/errors.test.ts +126 -0
  147. package/tests/lib/formatters.test.ts +87 -0
  148. package/tsconfig.json +20 -0
package/README.md ADDED
@@ -0,0 +1,986 @@
1
+ # mx-cli
2
+
3
+ > Command-line interface for MemNexus - Your personal memory and knowledge management system
4
+
5
+ ## Overview
6
+
7
+ `mx-cli` is a powerful command-line tool for interacting with the MemNexus API. It provides comprehensive commands for managing memories, conversations, facts, and more, with support for multiple output formats, interactive modes, and flexible configuration.
8
+
9
+ ## Features
10
+
11
+ - 🔐 **Authentication Management** - Secure API key storage with password masking
12
+ - ⚙️ **Flexible Configuration** - Environment variables and config file support
13
+ - 💾 **Memory Management** - Full CRUD operations for episodic and semantic memories
14
+ - 💬 **Conversation Tracking** - Query and manage conversation history
15
+ - 🧠 **Fact Management** - Create and manage semantic knowledge graphs
16
+ - 🎨 **Topics & Communities** - Graph-based topic clustering and community detection
17
+ - 🔍 **GraphRAG Queries** - Advanced graph-based retrieval augmented generation
18
+ - 📊 **Multiple Output Formats** - JSON, table, and YAML output
19
+ - 🔄 **Interactive Mode** - User-friendly prompts with validation for creating resources
20
+ - 📄 **Pagination Support** - Handle large datasets efficiently
21
+ - ⚡ **Progress Indicators** - Visual feedback for long-running operations
22
+ - ✅ **Comprehensive Testing** - 128 tests with >80% coverage
23
+ - 🛡️ **Input Validation** - Helpful error messages with actionable troubleshooting steps
24
+ - 🎯 **Confirmation Prompts** - Safety checks for destructive operations
25
+
26
+ ## Installation & Setup
27
+
28
+ ### Prerequisites
29
+
30
+ - Node.js 18+ and npm
31
+ - Access to a MemNexus API instance
32
+ - GitHub account with access to the memnexus-ai organization (for GitHub Packages installation)
33
+
34
+ ### Installation Options
35
+
36
+ #### Option 1: Install from GitHub Packages (Recommended)
37
+
38
+ ```bash
39
+ # Configure npm to use GitHub Packages for @memnexus-ai scope
40
+ npm config set @memnexus-ai:registry https://npm.pkg.github.com
41
+
42
+ # Authenticate with GitHub Packages (requires GitHub personal access token with read:packages scope)
43
+ npm login --scope=@memnexus-ai --registry=https://npm.pkg.github.com
44
+
45
+ # Install globally
46
+ npm install -g @memnexus-ai/cli
47
+
48
+ # Verify installation
49
+ mx --version
50
+ ```
51
+
52
+ **Note**: You'll need a GitHub personal access token with `read:packages` scope. Create one at: https://github.com/settings/tokens
53
+
54
+ #### Option 2: Install from Source (Development)
55
+
56
+ ```bash
57
+ # Clone the repository
58
+ cd mx-cli
59
+
60
+ # Install dependencies
61
+ npm install
62
+
63
+ # Build the CLI
64
+ npm run build
65
+
66
+ # Link globally to use 'mx' command
67
+ npm link
68
+
69
+ # Verify installation
70
+ mx --version
71
+ ```
72
+
73
+ ### Configuration
74
+
75
+ You can configure the CLI using either environment variables or the CLI commands.
76
+
77
+ #### Option 1: Using Environment Variables (Recommended)
78
+
79
+ Create a `.env` file in the `mx-cli` directory:
80
+
81
+ ```bash
82
+ # Copy the example file
83
+ cp .env.example .env
84
+
85
+ # Edit .env with your credentials
86
+ # MX_API_URL=http://api.memnexus.ai
87
+ # MX_API_KEY=your-api-key-here
88
+ ```
89
+
90
+ Then load the environment variables:
91
+
92
+ ```bash
93
+ source .env
94
+ ```
95
+
96
+ #### Option 2: Using CLI Commands
97
+
98
+ ```bash
99
+ # Set API URL
100
+ mx config set apiUrl http://api.memnexus.ai
101
+
102
+ # Login with API key
103
+ mx auth login --api-key your-api-key-here
104
+
105
+ # Verify configuration
106
+ mx auth status
107
+ ```
108
+
109
+ ### Environment Variables
110
+
111
+ The following environment variables are supported:
112
+
113
+ | Variable | Description | Default |
114
+ |----------|-------------|---------|
115
+ | `MX_API_URL` | MemNexus API base URL | `https://api.memnexus.io` |
116
+ | `MX_API_KEY` | API authentication key | - |
117
+ | `MX_OUTPUT_FORMAT` | Default output format (json\|table\|yaml) | `table` |
118
+ | `MX_DEFAULT_PAGE_SIZE` | Default pagination size | `20` |
119
+
120
+ ## Quick Start
121
+
122
+ Get up and running with mx-cli in 5 minutes:
123
+
124
+ ```bash
125
+ # 1. Install from GitHub Packages
126
+ npm install -g @memnexus-ai/cli
127
+
128
+ # 2. Configure authentication (interactive mode with password masking)
129
+ mx auth login --interactive
130
+
131
+ # 3. Verify connection
132
+ mx auth status
133
+
134
+ # 4. Create your first memory
135
+ mx memories create --interactive
136
+
137
+ # 5. List your memories
138
+ mx memories list
139
+
140
+ # 6. Search for memories
141
+ mx memories search --query "your search term"
142
+
143
+ # 7. Create a fact (knowledge graph triple)
144
+ mx facts create \
145
+ --subject "mx-cli" \
146
+ --predicate "is_a" \
147
+ --object "CLI tool" \
148
+ --confidence 1.0
149
+
150
+ # 8. Explore other commands
151
+ mx --help
152
+ ```
153
+
154
+ ### Common Workflows
155
+
156
+ #### Daily Memory Capture
157
+
158
+ ```bash
159
+ # Quick memory creation
160
+ mx memories create --content "Meeting notes: discussed Q4 roadmap" \
161
+ --memory-type episodic \
162
+ --topics "work,meetings" \
163
+ --importance 0.8
164
+
165
+ # Search recent memories
166
+ mx memories search --query "Q4 roadmap"
167
+ ```
168
+
169
+ #### Knowledge Graph Building
170
+
171
+ ```bash
172
+ # Create related facts
173
+ mx facts create --subject "TypeScript" --predicate "is_a" --object "Programming Language" --confidence 1.0
174
+ mx facts create --subject "mx-cli" --predicate "built_with" --object "TypeScript" --confidence 1.0
175
+ mx facts create --subject "mx-cli" --predicate "uses" --object "Commander.js" --confidence 1.0
176
+
177
+ # Search facts
178
+ mx facts search --query "TypeScript"
179
+ ```
180
+
181
+ #### Batch Operations with JSON Output
182
+
183
+ ```bash
184
+ # Export all memories to JSON
185
+ mx memories list --format json --limit 1000 > memories.json
186
+
187
+ # Find specific memories and process with jq
188
+ mx memories list --format json | jq '.data[] | select(.importance > 0.8)'
189
+
190
+ # Delete test memories (use with caution!)
191
+ mx memories list --format json | \
192
+ jq -r '.data[] | select(.content | contains("test")) | .id' | \
193
+ while read id; do mx memories delete "$id" --force; done
194
+ ```
195
+
196
+ ## Usage
197
+
198
+ ### Authentication Commands
199
+
200
+ #### Login
201
+
202
+ Store your API key for authentication:
203
+
204
+ ```bash
205
+ # Direct login with API key
206
+ mx auth login --api-key cmk_live_abc123...
207
+
208
+ # Interactive login (prompts for API key with masked input)
209
+ mx auth login --interactive
210
+ ```
211
+
212
+ #### Check Status
213
+
214
+ View current authentication and configuration status:
215
+
216
+ ```bash
217
+ mx auth status
218
+ ```
219
+
220
+ Output:
221
+ ```
222
+ ┌──────────────────┬────────────────────────────┐
223
+ │ Property │ Value │
224
+ ├──────────────────┼────────────────────────────┤
225
+ │ Authentication │ ✓ Configured (via config) │
226
+ │ API URL │ http://api.memnexus.ai │
227
+ │ Output Format │ table │
228
+ └──────────────────┴────────────────────────────┘
229
+ ```
230
+
231
+ #### Logout
232
+
233
+ Remove stored credentials:
234
+
235
+ ```bash
236
+ mx auth logout
237
+ ```
238
+
239
+ ### Configuration Commands
240
+
241
+ #### Get Configuration
242
+
243
+ Retrieve a specific configuration value:
244
+
245
+ ```bash
246
+ # Get API URL
247
+ mx config get apiUrl
248
+
249
+ # Get default output format
250
+ mx config get defaultFormat
251
+ ```
252
+
253
+ #### Set Configuration
254
+
255
+ Update configuration values:
256
+
257
+ ```bash
258
+ # Set API URL
259
+ mx config set apiUrl http://api.memnexus.ai
260
+
261
+ # Set default output format
262
+ mx config set defaultFormat json
263
+
264
+ # Set default page size
265
+ mx config set defaultPageSize 50
266
+ ```
267
+
268
+ #### List All Configuration
269
+
270
+ View all configuration settings and their sources:
271
+
272
+ ```bash
273
+ mx config list
274
+ ```
275
+
276
+ Output shows whether values come from environment variables or config file:
277
+ ```
278
+ ┌─────────────────┬────────────────────────┬────────┐
279
+ │ Key │ Value │ Source │
280
+ ├─────────────────┼────────────────────────┼────────┤
281
+ │ apiUrl │ http://api.memnexus.ai │ config │
282
+ │ defaultFormat │ table │ config │
283
+ │ defaultPageSize │ 20 │ config │
284
+ └─────────────────┴────────────────────────┴────────┘
285
+ ```
286
+
287
+ #### Reset Configuration
288
+
289
+ Reset all settings to defaults:
290
+
291
+ ```bash
292
+ mx config reset
293
+ ```
294
+
295
+ ### Memory Management Commands
296
+
297
+ Memories are the core data structure in MemNexus, representing episodic or semantic information.
298
+
299
+ #### List Memories
300
+
301
+ View all memories with pagination:
302
+
303
+ ```bash
304
+ # List first page (default: 20 items)
305
+ mx memories list
306
+
307
+ # List with custom pagination
308
+ mx memories list --page 0 --limit 10
309
+
310
+ # Output as JSON
311
+ mx memories list --format json
312
+
313
+ # Output as YAML
314
+ mx memories list --format yaml
315
+ ```
316
+
317
+ #### Get a Specific Memory
318
+
319
+ Retrieve detailed information about a memory:
320
+
321
+ ```bash
322
+ # Get memory by ID
323
+ mx memories get 26be666e-7503-40d7-9293-8ffbcdc04dd2
324
+
325
+ # Get as JSON
326
+ mx memories get 26be666e-7503-40d7-9293-8ffbcdc04dd2 --format json
327
+ ```
328
+
329
+ #### Create a Memory
330
+
331
+ Create new memories using direct mode or interactive prompts:
332
+
333
+ ```bash
334
+ # Direct mode - provide all details via flags
335
+ mx memories create \
336
+ --content "Completed Phase 2 of mx-cli implementation" \
337
+ --memory-type episodic \
338
+ --context work \
339
+ --topics "cli,development,milestone" \
340
+ --importance 0.9
341
+
342
+ # Interactive mode - prompts for each field
343
+ mx memories create --interactive
344
+
345
+ # Minimal creation (only content required)
346
+ mx memories create --content "Quick note about something important"
347
+ ```
348
+
349
+ **Options:**
350
+ - `--content <text>` - Memory content (required)
351
+ - `--memory-type <type>` - Type: episodic or semantic
352
+ - `--context <context>` - Context identifier
353
+ - `--topics <topics>` - Comma-separated topics
354
+ - `--importance <number>` - Importance score (0-1)
355
+ - `--interactive` - Interactive mode with prompts
356
+
357
+ #### Update a Memory
358
+
359
+ Modify existing memory fields:
360
+
361
+ ```bash
362
+ # Update content
363
+ mx memories update 26be666e-7503-40d7-9293-8ffbcdc04dd2 \
364
+ --content "Updated content"
365
+
366
+ # Update importance
367
+ mx memories update 26be666e-7503-40d7-9293-8ffbcdc04dd2 \
368
+ --importance 0.95
369
+
370
+ # Update multiple fields
371
+ mx memories update 26be666e-7503-40d7-9293-8ffbcdc04dd2 \
372
+ --content "New content" \
373
+ --topics "updated,tags" \
374
+ --importance 0.8
375
+ ```
376
+
377
+ #### Delete a Memory
378
+
379
+ Remove a memory (with confirmation):
380
+
381
+ ```bash
382
+ # Delete with confirmation prompt
383
+ mx memories delete 26be666e-7503-40d7-9293-8ffbcdc04dd2
384
+
385
+ # Delete without confirmation
386
+ mx memories delete 26be666e-7503-40d7-9293-8ffbcdc04dd2 --force
387
+ ```
388
+
389
+ #### Search Memories
390
+
391
+ Search for memories using semantic or keyword search:
392
+
393
+ ```bash
394
+ # Basic search
395
+ mx memories search --query "Phase 2 implementation"
396
+
397
+ # Search with limit
398
+ mx memories search --query "CLI development" --limit 5
399
+
400
+ # Search with specific mode
401
+ mx memories search --query "testing" --mode unified
402
+
403
+ # Search modes: unified (default), content, facts
404
+ mx memories search --query "authentication" --mode content
405
+ ```
406
+
407
+ ### Conversation Management Commands
408
+
409
+ Query and manage conversation history.
410
+
411
+ #### List Conversations
412
+
413
+ View all conversations:
414
+
415
+ ```bash
416
+ # List conversations
417
+ mx conversations list
418
+
419
+ # With pagination
420
+ mx conversations list --page 0 --limit 10
421
+
422
+ # As JSON
423
+ mx conversations list --format json
424
+ ```
425
+
426
+ #### Get Conversation Details
427
+
428
+ Retrieve a specific conversation:
429
+
430
+ ```bash
431
+ mx conversations get conv_abc123
432
+ ```
433
+
434
+ #### View Conversation Timeline
435
+
436
+ Get chronological message history:
437
+
438
+ ```bash
439
+ mx conversations timeline conv_abc123
440
+ ```
441
+
442
+ #### Search Conversations
443
+
444
+ Search through conversation content:
445
+
446
+ ```bash
447
+ mx conversations search --query "authentication discussion"
448
+ ```
449
+
450
+ #### Find Conversations by Topic
451
+
452
+ Filter conversations by topic:
453
+
454
+ ```bash
455
+ mx conversations by-topic --topic-id topic_123
456
+ ```
457
+
458
+ **Note:** Some conversation endpoints are placeholders and will display a message indicating the feature is coming soon.
459
+
460
+ ### Facts Management Commands
461
+
462
+ Manage semantic facts in knowledge graph format (subject-predicate-object triples).
463
+
464
+ #### List Facts
465
+
466
+ View all facts:
467
+
468
+ ```bash
469
+ # List facts
470
+ mx facts list
471
+
472
+ # With pagination
473
+ mx facts list --page 0 --limit 10
474
+
475
+ # As table (default)
476
+ mx facts list --format table
477
+ ```
478
+
479
+ #### Get a Specific Fact
480
+
481
+ Retrieve detailed information about a fact:
482
+
483
+ ```bash
484
+ mx facts get fact_abc123
485
+ ```
486
+
487
+ #### Create a Fact
488
+
489
+ Create new semantic facts:
490
+
491
+ ```bash
492
+ # Direct mode
493
+ mx facts create \
494
+ --subject "TypeScript" \
495
+ --predicate "is_a" \
496
+ --object "Programming Language" \
497
+ --confidence 1.0
498
+
499
+ # Interactive mode
500
+ mx facts create --interactive
501
+
502
+ # With context and metadata
503
+ mx facts create \
504
+ --subject "mx-cli" \
505
+ --predicate "implements" \
506
+ --object "Commander.js pattern" \
507
+ --confidence 0.95 \
508
+ --context development
509
+ ```
510
+
511
+ **Options:**
512
+ - `--subject <text>` - Fact subject (required)
513
+ - `--predicate <text>` - Relationship/predicate (required)
514
+ - `--object <text>` - Fact object (required)
515
+ - `--confidence <number>` - Confidence score 0-1 (default: 1.0)
516
+ - `--context <context>` - Context identifier
517
+ - `--interactive` - Interactive mode
518
+
519
+ #### Update a Fact
520
+
521
+ Modify existing fact fields:
522
+
523
+ ```bash
524
+ # Update confidence
525
+ mx facts update fact_abc123 --confidence 0.98
526
+
527
+ # Update multiple fields
528
+ mx facts update fact_abc123 \
529
+ --subject "Updated subject" \
530
+ --confidence 0.9
531
+ ```
532
+
533
+ #### Delete a Fact
534
+
535
+ Remove a fact:
536
+
537
+ ```bash
538
+ # With confirmation
539
+ mx facts delete fact_abc123
540
+
541
+ # Without confirmation
542
+ mx facts delete fact_abc123 --force
543
+ ```
544
+
545
+ #### Search Facts
546
+
547
+ Search through facts:
548
+
549
+ ```bash
550
+ # Basic search
551
+ mx facts search --query "TypeScript"
552
+
553
+ # With limit
554
+ mx facts search --query "programming" --limit 10
555
+ ```
556
+
557
+ ### Advanced Commands
558
+
559
+ The CLI includes powerful advanced features for graph analysis, pattern detection, and AI-powered queries.
560
+
561
+ #### Topics Commands
562
+
563
+ Manage and analyze topics in your knowledge graph:
564
+
565
+ ```bash
566
+ # List all topics
567
+ mx topics list
568
+
569
+ # Get topic details
570
+ mx topics get <topic-id>
571
+
572
+ # Merge two topics (with confirmation)
573
+ mx topics merge --source-id <id1> --target-id <id2>
574
+
575
+ # Skip confirmation
576
+ mx topics merge --source-id <id1> --target-id <id2> --force
577
+
578
+ # Discover related topics
579
+ mx topics discover-related --topic-id <id>
580
+
581
+ # Calculate similarity between topics
582
+ mx topics similarity --topic-id-1 <id1> --topic-id-2 <id2>
583
+
584
+ # Find similar topics
585
+ mx topics find-similar --topic-id <id> --threshold 0.7
586
+
587
+ # Cluster topics using algorithms
588
+ mx topics cluster --algorithm kmeans --num-clusters 5
589
+ mx topics cluster --algorithm hierarchical
590
+ mx topics cluster --algorithm dbscan
591
+
592
+ # Detect communities in topic graph
593
+ mx topics detect-communities --algorithm louvain
594
+ mx topics detect-communities --algorithm label-propagation --min-size 3
595
+ ```
596
+
597
+ #### Communities Commands
598
+
599
+ Manage communities detected in your knowledge graph:
600
+
601
+ ```bash
602
+ # List communities
603
+ mx communities list
604
+
605
+ # Get community details
606
+ mx communities get <community-id>
607
+
608
+ # Merge communities (with confirmation)
609
+ mx communities merge --source-id <id1> --target-id <id2>
610
+ ```
611
+
612
+ #### Patterns Commands
613
+
614
+ Compile and manage behavioral patterns from your memories:
615
+
616
+ ```bash
617
+ # Compile patterns from context
618
+ mx patterns compile --context-id <id>
619
+
620
+ # Record feedback on a pattern
621
+ mx patterns feedback --pattern-id <id> --feedback positive
622
+ mx patterns feedback --pattern-id <id> --feedback negative
623
+
624
+ # Set behavioral state
625
+ mx patterns set-state --pattern-id <id> --state active
626
+ mx patterns set-state --pattern-id <id> --state inactive
627
+ ```
628
+
629
+ #### GraphRAG Commands
630
+
631
+ Execute graph-based retrieval augmented generation queries:
632
+
633
+ ```bash
634
+ # Execute GraphRAG query
635
+ mx graphrag query --query "What are the main themes in my work memories?"
636
+
637
+ # Generate explanation for a memory
638
+ mx graphrag explain --memory-id <id>
639
+
640
+ # Query communities
641
+ mx graphrag query-communities --query "technical discussions" --limit 5
642
+ ```
643
+
644
+ #### Artifacts Commands
645
+
646
+ Manage artifacts (files, documents, etc.):
647
+
648
+ ```bash
649
+ # List artifacts
650
+ mx artifacts list
651
+
652
+ # Get artifact details
653
+ mx artifacts get <artifact-id>
654
+
655
+ # Create artifact (interactive mode)
656
+ mx artifacts create --interactive
657
+
658
+ # Create artifact (direct mode)
659
+ mx artifacts create --name "Document" --type "pdf"
660
+
661
+ # Update artifact
662
+ mx artifacts update <id> --name "Updated Name"
663
+
664
+ # Delete artifact (with confirmation)
665
+ mx artifacts delete <id>
666
+
667
+ # Skip confirmation
668
+ mx artifacts delete <id> --force
669
+ ```
670
+
671
+ #### API Keys Commands
672
+
673
+ Manage API keys:
674
+
675
+ ```bash
676
+ # List API keys (metadata only, never shows actual keys)
677
+ mx apikeys list
678
+
679
+ # Create new API key
680
+ mx apikeys create --label "My CLI Key"
681
+
682
+ # Create with expiration
683
+ mx apikeys create --label "Temp Key" --expires-at "2024-12-31T23:59:59Z"
684
+
685
+ # Delete API key (with confirmation)
686
+ mx apikeys delete <key-id>
687
+
688
+ # Skip confirmation
689
+ mx apikeys delete <key-id> --force
690
+ ```
691
+
692
+ #### System Commands
693
+
694
+ Check system health and status:
695
+
696
+ ```bash
697
+ # Check system health
698
+ mx system health
699
+
700
+ # Get system status
701
+ mx system status
702
+
703
+ # List feature flags
704
+ mx system feature-flags
705
+ ```
706
+
707
+ ## Common Options
708
+
709
+ These options are available across multiple commands:
710
+
711
+ ### Output Formats
712
+
713
+ Control how data is displayed:
714
+
715
+ ```bash
716
+ # Table format (default) - human-readable
717
+ mx memories list --format table
718
+
719
+ # JSON format - for scripting and parsing
720
+ mx memories list --format json
721
+
722
+ # YAML format - human-readable structured data
723
+ mx memories list --format yaml
724
+ ```
725
+
726
+ ### Pagination
727
+
728
+ Handle large datasets efficiently:
729
+
730
+ ```bash
731
+ # Default pagination (page 0, 20 items)
732
+ mx memories list
733
+
734
+ # Custom page and limit
735
+ mx memories list --page 2 --limit 50
736
+
737
+ # First 100 items
738
+ mx memories list --page 0 --limit 100
739
+ ```
740
+
741
+ ### Interactive Mode
742
+
743
+ User-friendly prompts for creating resources with validation and helpful hints:
744
+
745
+ ```bash
746
+ # Interactive memory creation
747
+ mx memories create --interactive
748
+
749
+ # Interactive fact creation
750
+ mx facts create --interactive
751
+
752
+ # Interactive artifact creation
753
+ mx artifacts create --interactive
754
+
755
+ # Interactive authentication (with password masking)
756
+ mx auth login --interactive
757
+ ```
758
+
759
+ The interactive mode will prompt you for each field with:
760
+ - Input validation
761
+ - Helpful error messages
762
+ - Default values where applicable
763
+ - Password masking for sensitive inputs
764
+
765
+ ### Force Flag
766
+
767
+ Skip confirmation prompts for destructive operations:
768
+
769
+ ```bash
770
+ # Delete operations
771
+ mx memories delete <id> --force
772
+ mx facts delete <id> --force
773
+ mx artifacts delete <id> --force
774
+ mx apikeys delete <id> --force
775
+
776
+ # Merge operations
777
+ mx topics merge --source-id <id1> --target-id <id2> --force
778
+ mx communities merge --source-id <id1> --target-id <id2> --force
779
+ ```
780
+
781
+ **⚠️ Warning**: Using `--force` skips safety confirmations. Use with caution, especially in production environments.
782
+
783
+ ## Example Workflows
784
+
785
+ ### Complete Setup and First Memory
786
+
787
+ ```bash
788
+ # 1. Build and link the CLI
789
+ cd mx-cli
790
+ npm install
791
+ npm run build
792
+ npm link
793
+
794
+ # 2. Configure using environment variables
795
+ cp .env.example .env
796
+ # Edit .env with your API key and URL
797
+ source .env
798
+
799
+ # 3. Verify authentication
800
+ mx auth status
801
+
802
+ # 4. Create your first memory
803
+ mx memories create \
804
+ --content "Started using mx-cli for memory management" \
805
+ --memory-type episodic \
806
+ --context personal \
807
+ --topics "getting-started,mx-cli" \
808
+ --importance 0.8
809
+
810
+ # 5. List your memories
811
+ mx memories list
812
+
813
+ # 6. Search for memories
814
+ mx memories search --query "getting started"
815
+ ```
816
+
817
+ ### Working with Different Output Formats
818
+
819
+ ```bash
820
+ # Get memory as JSON for scripting
821
+ MEMORY_JSON=$(mx memories get <id> --format json)
822
+
823
+ # List memories as YAML for readability
824
+ mx memories list --format yaml
825
+
826
+ # Export all memories to JSON file
827
+ mx memories list --format json --limit 1000 > memories.json
828
+ ```
829
+
830
+ ### Creating and Linking Facts
831
+
832
+ ```bash
833
+ # Create a fact about a technology
834
+ mx facts create \
835
+ --subject "mx-cli" \
836
+ --predicate "built_with" \
837
+ --object "TypeScript" \
838
+ --confidence 1.0
839
+
840
+ # Create a related fact
841
+ mx facts create \
842
+ --subject "mx-cli" \
843
+ --predicate "uses" \
844
+ --object "Commander.js" \
845
+ --confidence 1.0
846
+
847
+ # Search for related facts
848
+ mx facts search --query "mx-cli"
849
+ ```
850
+
851
+ ### Batch Operations with Shell Scripting
852
+
853
+ ```bash
854
+ # Create multiple memories from a file
855
+ while IFS= read -r line; do
856
+ mx memories create --content "$line" --memory-type episodic
857
+ done < notes.txt
858
+
859
+ # Export all memories with specific topic
860
+ mx memories list --format json | \
861
+ jq '.data[] | select(.topics[] | contains("important"))' > important_memories.json
862
+
863
+ # Delete old test memories (be careful!)
864
+ mx memories list --format json | \
865
+ jq -r '.data[] | select(.content | contains("test")) | .id' | \
866
+ while read id; do
867
+ mx memories delete "$id" --force
868
+ done
869
+ ```
870
+
871
+ ## Help and Documentation
872
+
873
+ Every command has built-in help:
874
+
875
+ ```bash
876
+ # Global help
877
+ mx --help
878
+
879
+ # Command-specific help
880
+ mx memories --help
881
+ mx memories create --help
882
+ mx auth --help
883
+ mx config --help
884
+ ```
885
+
886
+ ## Development
887
+
888
+ ### Running Tests
889
+
890
+ ```bash
891
+ # Run all tests
892
+ npm test
893
+
894
+ # Run tests with coverage
895
+ npm test -- --coverage
896
+
897
+ # Run specific test file
898
+ npm test -- tests/commands/memories.test.ts
899
+ ```
900
+
901
+ ### Linting
902
+
903
+ ```bash
904
+ # Check for linting errors
905
+ npm run lint
906
+
907
+ # Auto-fix linting errors
908
+ npm run lint -- --fix
909
+ ```
910
+
911
+ ### Building
912
+
913
+ ```bash
914
+ # Build TypeScript to JavaScript
915
+ npm run build
916
+
917
+ # Watch mode for development
918
+ npm run build -- --watch
919
+ ```
920
+
921
+ ## Troubleshooting
922
+
923
+ ### Command Not Found
924
+
925
+ If `mx` command is not found after `npm link`:
926
+
927
+ ```bash
928
+ # Check npm global bin path
929
+ npm bin -g
930
+
931
+ # Ensure it's in your PATH
932
+ echo $PATH
933
+
934
+ # Re-link the package
935
+ npm unlink -g @memnexus-ai/cli
936
+ npm link
937
+ ```
938
+
939
+ ### Authentication Errors
940
+
941
+ If you get authentication errors:
942
+
943
+ ```bash
944
+ # Check your auth status
945
+ mx auth status
946
+
947
+ # Verify API key is set
948
+ mx config list
949
+
950
+ # Re-login
951
+ mx auth login --api-key your-api-key-here
952
+ ```
953
+
954
+ ### API Connection Issues
955
+
956
+ If you can't connect to the API:
957
+
958
+ ```bash
959
+ # Verify API URL
960
+ mx config get apiUrl
961
+
962
+ # Test with curl
963
+ curl http://api.memnexus.ai/health
964
+
965
+ # Update API URL if needed
966
+ mx config set apiUrl http://api.memnexus.ai
967
+ ```
968
+
969
+ ## Contributing
970
+
971
+ Contributions are welcome! Please ensure:
972
+
973
+ - All tests pass (`npm test`)
974
+ - Code is linted (`npm run lint`)
975
+ - New features include tests
976
+ - Documentation is updated
977
+
978
+ ## License
979
+
980
+ [Add your license here]
981
+
982
+ ## Support
983
+
984
+ For issues and questions:
985
+ - GitHub Issues: [memnexus-ai/mx-cli](https://github.com/memnexus-ai/mx-cli/issues)
986
+ - Documentation: [docs/prd.md](docs/prd.md)