@memnexus-ai/cli 0.1.1 → 0.1.4
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 +986 -986
- package/bin/mx.js +1 -1
- package/package.json +74 -67
- package/.env.example +0 -13
- package/.eslintrc.js +0 -24
- package/.github/ISSUE_TEMPLATE/phase-1-foundation.md +0 -1078
- package/.github/workflows/publish.yml +0 -277
- package/.github/workflows/test-app-token.yml +0 -54
- package/.npmrc.backup +0 -3
- package/.npmrc.example +0 -6
- package/.prettierignore +0 -4
- package/.prettierrc +0 -8
- package/PLATFORM_TESTING.md +0 -243
- package/RELEASE.md +0 -428
- package/RELEASE_READINESS.md +0 -253
- package/docs/README.md +0 -219
- package/docs/code-generation-strategy.md +0 -560
- package/docs/prd.md +0 -748
- package/docs/sync-strategy.md +0 -533
- package/jest.config.js +0 -30
- package/scripts/install-deps.sh +0 -38
- package/src/commands/apikeys.ts +0 -144
- package/src/commands/artifacts.ts +0 -296
- package/src/commands/auth.ts +0 -122
- package/src/commands/communities.ts +0 -153
- package/src/commands/config.ts +0 -144
- package/src/commands/conversations.ts +0 -176
- package/src/commands/facts.ts +0 -320
- package/src/commands/graphrag.ts +0 -149
- package/src/commands/memories.ts +0 -332
- package/src/commands/patterns.ts +0 -251
- package/src/commands/system.ts +0 -102
- package/src/commands/topics.ts +0 -354
- package/src/index.ts +0 -43
- package/src/lib/api-client.ts +0 -68
- package/src/lib/auth.ts +0 -42
- package/src/lib/config.ts +0 -68
- package/src/lib/errors.ts +0 -143
- package/src/lib/formatters.ts +0 -123
- package/src/lib/spinner.ts +0 -113
- package/src/lib/validators.ts +0 -302
- package/src/types/index.ts +0 -17
- package/tests/__mocks__/chalk.ts +0 -16
- package/tests/__mocks__/cli-table3.ts +0 -37
- package/tests/__mocks__/configstore.ts +0 -38
- package/tests/commands/apikeys.test.ts +0 -179
- package/tests/commands/artifacts.test.ts +0 -194
- package/tests/commands/auth.test.ts +0 -120
- package/tests/commands/communities.test.ts +0 -154
- package/tests/commands/config.test.ts +0 -154
- package/tests/commands/conversations.test.ts +0 -136
- package/tests/commands/facts.test.ts +0 -210
- package/tests/commands/graphrag.test.ts +0 -194
- package/tests/commands/memories.test.ts +0 -215
- package/tests/commands/patterns.test.ts +0 -201
- package/tests/commands/system.test.ts +0 -172
- package/tests/commands/topics.test.ts +0 -274
- package/tests/lib/auth.test.ts +0 -77
- package/tests/lib/config.test.ts +0 -50
- package/tests/lib/errors.test.ts +0 -126
- package/tests/lib/formatters.test.ts +0 -87
- package/tsconfig.json +0 -20
package/README.md
CHANGED
|
@@ -1,986 +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)
|
|
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)
|