@unifiedmemory/cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env.example +9 -0
- package/CHANGELOG.md +34 -0
- package/HOOK_SETUP.md +338 -0
- package/LICENSE +51 -0
- package/README.md +220 -0
- package/bin/um-mcp-serve +62 -0
- package/commands/init.js +315 -0
- package/commands/login.js +390 -0
- package/commands/org.js +111 -0
- package/commands/record.js +114 -0
- package/index.js +215 -0
- package/lib/clerk-api.js +172 -0
- package/lib/config.js +39 -0
- package/lib/hooks.js +43 -0
- package/lib/mcp-proxy.js +227 -0
- package/lib/mcp-server.js +284 -0
- package/lib/provider-detector.js +291 -0
- package/lib/token-refresh.js +113 -0
- package/lib/token-storage.js +63 -0
- package/lib/token-validation.js +47 -0
- package/package.json +49 -0
package/.env.example
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Optional: Override Clerk OAuth Configuration
|
|
2
|
+
# By default, the CLI uses the production UnifiedMemory Clerk application
|
|
3
|
+
# Only set these if you're developing/testing with a different Clerk app
|
|
4
|
+
|
|
5
|
+
# CLERK_CLIENT_ID=your_test_clerk_client_id
|
|
6
|
+
# CLERK_DOMAIN=your-test-app.clerk.accounts.dev
|
|
7
|
+
# API_ENDPOINT=http://localhost:8000
|
|
8
|
+
# REDIRECT_URI=http://localhost:3333/callback
|
|
9
|
+
# PORT=3333
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] - 2026-01-06
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Initial release of UnifiedMemory CLI
|
|
12
|
+
- OAuth 2.0 authentication with automatic token refresh
|
|
13
|
+
- `um init` command for one-step project setup
|
|
14
|
+
- `um login` command for manual authentication
|
|
15
|
+
- `um status` command to show auth and project status
|
|
16
|
+
- `um org switch` command to switch between organizations
|
|
17
|
+
- `um mcp serve` command for local MCP server
|
|
18
|
+
- `um note create` command for direct note creation
|
|
19
|
+
- Auto-detection and configuration for 5 AI tools:
|
|
20
|
+
- Claude Code (project-level .mcp.json)
|
|
21
|
+
- Cursor (~/.cursor/mcp.json)
|
|
22
|
+
- Cline (~/.cline/mcp.json)
|
|
23
|
+
- Codex CLI (~/.codex/config.toml)
|
|
24
|
+
- Gemini CLI (~/.gemini/settings.json)
|
|
25
|
+
- Local MCP server with automatic project context detection
|
|
26
|
+
- Secure token storage in ~/.um/auth.json
|
|
27
|
+
- Per-project configuration in .um/config.json
|
|
28
|
+
- Automatic .gitignore updates to exclude .um/ directory
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
- Token refresh not persisting refresh_token during login
|
|
32
|
+
- Status command not detecting project configuration files
|
|
33
|
+
- Improved error messages for token refresh failures
|
|
34
|
+
- Centralized token validation helper prevents duplicate code
|
package/HOOK_SETUP.md
ADDED
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
# UnifiedMemory CLI Hook Integration
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
This document explains how to set up automatic vault recording using Claude Code hooks with the `um note create` CLI command.
|
|
6
|
+
|
|
7
|
+
## Background
|
|
8
|
+
|
|
9
|
+
Claude Code's "prompt" type hooks are not supported outside REPL mode. To work around this limitation, we've implemented a command-style hook that calls the `um note create` CLI command directly.
|
|
10
|
+
|
|
11
|
+
## Components
|
|
12
|
+
|
|
13
|
+
### 1. CLI Command: `um note create`
|
|
14
|
+
|
|
15
|
+
A new CLI command that creates notes in the vault:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
um note create "<summary text>" [options]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
**Options**:
|
|
22
|
+
- `--topic <topic>` - Topic for the note (default: "general")
|
|
23
|
+
- `--source <source>` - Source identifier (default: "um-cli")
|
|
24
|
+
- `--confidence <confidence>` - Confidence score 0-1 (default: "0.7")
|
|
25
|
+
- `--tags <tags>` - Comma-separated tags
|
|
26
|
+
- `--metadata <json>` - Additional metadata as JSON string
|
|
27
|
+
|
|
28
|
+
**Example**:
|
|
29
|
+
```bash
|
|
30
|
+
um note create "Completed implementation of user authentication" \
|
|
31
|
+
--topic "development" \
|
|
32
|
+
--source "manual" \
|
|
33
|
+
--confidence "0.9" \
|
|
34
|
+
--tags "auth,feature,completed"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### 2. Hook Script: `.claude/hooks/post-exit-plan-mode.sh`
|
|
38
|
+
|
|
39
|
+
A shell script that automatically calls `um note create` after exiting plan mode:
|
|
40
|
+
|
|
41
|
+
**Location**: `<project>/.claude/hooks/post-exit-plan-mode.sh`
|
|
42
|
+
|
|
43
|
+
**Requirements**:
|
|
44
|
+
- Must be executable (`chmod +x`)
|
|
45
|
+
- Update the `UM_CLI` path to point to your um-cli installation
|
|
46
|
+
|
|
47
|
+
### 3. Hook Configuration: `.claude/settings.json`
|
|
48
|
+
|
|
49
|
+
Configure Claude Code to run the hook:
|
|
50
|
+
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"hooks": {
|
|
54
|
+
"PostToolUse": [
|
|
55
|
+
{
|
|
56
|
+
"matcher": "ExitPlanMode",
|
|
57
|
+
"hooks": [
|
|
58
|
+
{
|
|
59
|
+
"type": "command",
|
|
60
|
+
"command": "./.claude/hooks/post-exit-plan-mode.sh 'Plan summary: Completed plan mode session'",
|
|
61
|
+
"statusMessage": "Recording plan to vault..."
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
}
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Setup Instructions
|
|
71
|
+
|
|
72
|
+
### Step 1: Install um-cli
|
|
73
|
+
|
|
74
|
+
The `um` CLI should be installed and configured:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
# Authenticate
|
|
78
|
+
um login
|
|
79
|
+
|
|
80
|
+
# Initialize project
|
|
81
|
+
cd <your-project>
|
|
82
|
+
um init
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
This creates:
|
|
86
|
+
- `~/.um/auth.json` - User authentication
|
|
87
|
+
- `.um/config.json` - Project configuration (org_id, project_id)
|
|
88
|
+
|
|
89
|
+
### Step 2: Create Hook Script
|
|
90
|
+
|
|
91
|
+
Create `.claude/hooks/post-exit-plan-mode.sh` in your project:
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
mkdir -p .claude/hooks
|
|
95
|
+
cat > .claude/hooks/post-exit-plan-mode.sh << 'EOF'
|
|
96
|
+
#!/usr/bin/env bash
|
|
97
|
+
set -e
|
|
98
|
+
|
|
99
|
+
SUMMARY="$@"
|
|
100
|
+
if [ -z "$SUMMARY" ]; then
|
|
101
|
+
SUMMARY=$(cat)
|
|
102
|
+
fi
|
|
103
|
+
if [ -z "$SUMMARY" ]; then
|
|
104
|
+
SUMMARY="Plan completed and exited plan mode"
|
|
105
|
+
fi
|
|
106
|
+
|
|
107
|
+
# Update this path to your um-cli installation
|
|
108
|
+
UM_CLI="/path/to/vault/um-cli/index.js"
|
|
109
|
+
|
|
110
|
+
if [ ! -f "$UM_CLI" ]; then
|
|
111
|
+
echo "Error: um CLI not found at $UM_CLI" >&2
|
|
112
|
+
exit 1
|
|
113
|
+
fi
|
|
114
|
+
|
|
115
|
+
node "$UM_CLI" note create "$SUMMARY" \
|
|
116
|
+
--topic "plans" \
|
|
117
|
+
--source "claude-code-hook" \
|
|
118
|
+
--confidence "0.8" \
|
|
119
|
+
--tags "plan,automated" \
|
|
120
|
+
2>&1
|
|
121
|
+
|
|
122
|
+
exit 0
|
|
123
|
+
EOF
|
|
124
|
+
|
|
125
|
+
chmod +x .claude/hooks/post-exit-plan-mode.sh
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Step 3: Configure Hook in Settings
|
|
129
|
+
|
|
130
|
+
Update `.claude/settings.json` (or `.claude/settings.local.json`):
|
|
131
|
+
|
|
132
|
+
```json
|
|
133
|
+
{
|
|
134
|
+
"hooks": {
|
|
135
|
+
"PostToolUse": [
|
|
136
|
+
{
|
|
137
|
+
"matcher": "ExitPlanMode",
|
|
138
|
+
"hooks": [
|
|
139
|
+
{
|
|
140
|
+
"type": "command",
|
|
141
|
+
"command": "./.claude/hooks/post-exit-plan-mode.sh 'Plan summary: Completed plan mode session'",
|
|
142
|
+
"statusMessage": "Recording plan to vault..."
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
]
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Step 4: Test the Setup
|
|
152
|
+
|
|
153
|
+
Test the CLI command manually:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
cd <your-project>
|
|
157
|
+
um note create "Test note from CLI" --topic "testing"
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Test the hook script:
|
|
161
|
+
|
|
162
|
+
```bash
|
|
163
|
+
./.claude/hooks/post-exit-plan-mode.sh "Test note from hook"
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## How It Works
|
|
167
|
+
|
|
168
|
+
### Authentication Flow
|
|
169
|
+
|
|
170
|
+
1. **User Context**: Loaded from `~/.um/auth.json` (created by `um login`)
|
|
171
|
+
- User ID from JWT `decoded.sub`
|
|
172
|
+
- Organization ID from `selectedOrg.id` or fallback to user ID
|
|
173
|
+
|
|
174
|
+
2. **Project Context**: Loaded from `.um/config.json` (created by `um init`)
|
|
175
|
+
- Organization ID
|
|
176
|
+
- Project ID
|
|
177
|
+
- Project name
|
|
178
|
+
|
|
179
|
+
3. **API Call**: The `um note create` command:
|
|
180
|
+
- Builds authentication headers (Authorization, X-Org-Id, X-User-Id)
|
|
181
|
+
- Injects org/proj/user into tool arguments
|
|
182
|
+
- Calls the MCP gateway's `create_note` tool
|
|
183
|
+
- Returns success/failure status
|
|
184
|
+
|
|
185
|
+
### Hook Execution
|
|
186
|
+
|
|
187
|
+
When you exit plan mode in Claude Code:
|
|
188
|
+
|
|
189
|
+
1. Claude Code detects `ExitPlanMode` tool usage
|
|
190
|
+
2. Matches the `PostToolUse` hook with `matcher: "ExitPlanMode"`
|
|
191
|
+
3. Executes the command hook: `.claude/hooks/post-exit-plan-mode.sh`
|
|
192
|
+
4. Hook script calls: `node um-cli/index.js note create "..."`
|
|
193
|
+
5. CLI command creates the note in vault
|
|
194
|
+
6. Success/failure status shown in Claude Code
|
|
195
|
+
|
|
196
|
+
## Troubleshooting
|
|
197
|
+
|
|
198
|
+
### Error: "Not authenticated"
|
|
199
|
+
|
|
200
|
+
```bash
|
|
201
|
+
# Re-authenticate
|
|
202
|
+
um login
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Error: "No project configuration found"
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# Re-initialize project
|
|
209
|
+
cd <your-project>
|
|
210
|
+
um init
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Error: "um CLI not found"
|
|
214
|
+
|
|
215
|
+
Update the `UM_CLI` path in the hook script to point to your installation:
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
UM_CLI="/absolute/path/to/vault/um-cli/index.js"
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Error: Hook not executing
|
|
222
|
+
|
|
223
|
+
1. Ensure the hook script is executable:
|
|
224
|
+
```bash
|
|
225
|
+
chmod +x .claude/hooks/post-exit-plan-mode.sh
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
2. Test the hook manually:
|
|
229
|
+
```bash
|
|
230
|
+
./.claude/hooks/post-exit-plan-mode.sh "Test message"
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
3. Check Claude Code settings are valid JSON
|
|
234
|
+
|
|
235
|
+
### Error: "Tool execution failed"
|
|
236
|
+
|
|
237
|
+
Check authentication headers are being set correctly:
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
# Check auth file exists
|
|
241
|
+
cat ~/.um/auth.json | jq .
|
|
242
|
+
|
|
243
|
+
# Check project config exists
|
|
244
|
+
cat .um/config.json | jq .
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## Customization
|
|
248
|
+
|
|
249
|
+
### Change Hook Trigger
|
|
250
|
+
|
|
251
|
+
Instead of `PostToolUse:ExitPlanMode`, you can trigger on other events:
|
|
252
|
+
|
|
253
|
+
```json
|
|
254
|
+
{
|
|
255
|
+
"hooks": {
|
|
256
|
+
"SessionEnd": [
|
|
257
|
+
{
|
|
258
|
+
"hooks": [
|
|
259
|
+
{
|
|
260
|
+
"type": "command",
|
|
261
|
+
"command": "./.claude/hooks/record-session.sh 'Session summary'",
|
|
262
|
+
"statusMessage": "Recording session to vault..."
|
|
263
|
+
}
|
|
264
|
+
]
|
|
265
|
+
}
|
|
266
|
+
]
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Available hook types:
|
|
272
|
+
- `PreToolUse` - Before any tool execution
|
|
273
|
+
- `PostToolUse` - After any tool execution
|
|
274
|
+
- `PostToolUseFailure` - After tool execution fails
|
|
275
|
+
- `SessionStart` - When session starts
|
|
276
|
+
- `SessionEnd` - When session ends
|
|
277
|
+
- `PreCompact` - Before context summarization
|
|
278
|
+
|
|
279
|
+
### Customize Note Properties
|
|
280
|
+
|
|
281
|
+
Edit the hook script to change topic, source, confidence, or tags:
|
|
282
|
+
|
|
283
|
+
```bash
|
|
284
|
+
node "$UM_CLI" note create "$SUMMARY" \
|
|
285
|
+
--topic "my-custom-topic" \
|
|
286
|
+
--source "my-source" \
|
|
287
|
+
--confidence "0.9" \
|
|
288
|
+
--tags "custom,tags,here" \
|
|
289
|
+
2>&1
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### Add Metadata
|
|
293
|
+
|
|
294
|
+
Pass JSON metadata:
|
|
295
|
+
|
|
296
|
+
```bash
|
|
297
|
+
node "$UM_CLI" note create "$SUMMARY" \
|
|
298
|
+
--metadata '{"branch":"main","commit":"abc123"}' \
|
|
299
|
+
2>&1
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
## Security Notes
|
|
303
|
+
|
|
304
|
+
- Authentication tokens are stored in `~/.um/auth.json` (user-only permissions)
|
|
305
|
+
- Project config in `.um/config.json` contains no secrets (only IDs)
|
|
306
|
+
- The CLI command inherits user's authentication automatically
|
|
307
|
+
- Hook scripts run with the same permissions as Claude Code
|
|
308
|
+
|
|
309
|
+
## Alternatives to Hooks
|
|
310
|
+
|
|
311
|
+
If you don't want automatic recording, you can manually call the CLI:
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
# After exiting plan mode
|
|
315
|
+
um note create "Completed feature X implementation" \
|
|
316
|
+
--topic "development" \
|
|
317
|
+
--confidence "0.9"
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Or ask Claude Code to record notes explicitly:
|
|
321
|
+
|
|
322
|
+
```
|
|
323
|
+
User: Record this plan to the vault
|
|
324
|
+
Claude: [Uses mcp__vault__create_note tool directly]
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
## Files Modified
|
|
328
|
+
|
|
329
|
+
This implementation required the following changes:
|
|
330
|
+
|
|
331
|
+
1. **New file**: `um-cli/commands/record.js` - CLI command implementation
|
|
332
|
+
2. **Modified**: `um-cli/index.js` - Added `note create` command registration
|
|
333
|
+
3. **New file**: `.claude/hooks/post-exit-plan-mode.sh` - Hook script (per-project)
|
|
334
|
+
4. **Modified**: `.claude/settings.json` - Hook configuration (per-project)
|
|
335
|
+
|
|
336
|
+
## Summary
|
|
337
|
+
|
|
338
|
+
This solution bypasses the "prompt hooks not supported outside REPL" limitation by using command-style hooks to call the `um note create` CLI command directly. All authentication infrastructure (schema transformation, parameter injection, headers) works perfectly - the only issue was with Claude Code's hook mechanism, which we've now resolved.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
PROPRIETARY LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Episodic Solutions Limited. All rights reserved.
|
|
4
|
+
|
|
5
|
+
This software and associated documentation files (the "Software") are the proprietary
|
|
6
|
+
property of Episodic Solutions Limited and are protected by copyright law and
|
|
7
|
+
international treaties.
|
|
8
|
+
|
|
9
|
+
NOTICE TO USER: Carefully read the following legal agreement. By downloading, installing,
|
|
10
|
+
copying, or otherwise using the Software, you are agreeing to be bound by the terms of
|
|
11
|
+
this Agreement. If you do not agree to the terms of this Agreement, do not install or
|
|
12
|
+
use the Software.
|
|
13
|
+
|
|
14
|
+
1. LICENSE GRANT
|
|
15
|
+
Subject to the terms of this Agreement, Episodic Solutions Limited grants you a
|
|
16
|
+
non-exclusive, non-transferable, revocable license to use the Software solely for
|
|
17
|
+
your internal business purposes.
|
|
18
|
+
|
|
19
|
+
2. RESTRICTIONS
|
|
20
|
+
You may not:
|
|
21
|
+
- Modify, adapt, translate, reverse engineer, decompile, disassemble, or create
|
|
22
|
+
derivative works based on the Software
|
|
23
|
+
- Remove any proprietary notices, labels, or marks from the Software
|
|
24
|
+
- Rent, lease, loan, sublicense, distribute, or otherwise transfer the Software to
|
|
25
|
+
any third party
|
|
26
|
+
- Use the Software for any purpose other than as expressly permitted herein
|
|
27
|
+
|
|
28
|
+
3. OWNERSHIP
|
|
29
|
+
The Software is licensed, not sold. Episodic Solutions Limited retains all right,
|
|
30
|
+
title, and interest in and to the Software, including all intellectual property rights.
|
|
31
|
+
|
|
32
|
+
4. TERMINATION
|
|
33
|
+
This license is effective until terminated. Your rights under this license will
|
|
34
|
+
terminate automatically without notice if you fail to comply with any term of this
|
|
35
|
+
Agreement.
|
|
36
|
+
|
|
37
|
+
5. DISCLAIMER OF WARRANTIES
|
|
38
|
+
THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR
|
|
39
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
40
|
+
PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
|
|
41
|
+
|
|
42
|
+
6. LIMITATION OF LIABILITY
|
|
43
|
+
IN NO EVENT SHALL EPISODIC SOLUTIONS LIMITED BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
44
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR
|
|
45
|
+
INABILITY TO USE THE SOFTWARE.
|
|
46
|
+
|
|
47
|
+
7. GOVERNING LAW
|
|
48
|
+
This Agreement shall be governed by and construed in accordance with the laws of
|
|
49
|
+
England and Wales, without regard to its conflict of law provisions.
|
|
50
|
+
|
|
51
|
+
For licensing inquiries, please contact: support@unifiedmemory.ai
|
package/README.md
ADDED
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
# UnifiedMemory CLI (`um`)
|
|
2
|
+
|
|
3
|
+
One-command setup for AI code assistant integration with UnifiedMemory.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Install globally
|
|
9
|
+
npm install -g @unifiedmemory/cli
|
|
10
|
+
|
|
11
|
+
# Or run directly with npx
|
|
12
|
+
npx @unifiedmemory/cli init
|
|
13
|
+
|
|
14
|
+
# In your project directory
|
|
15
|
+
um init
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## How It Works
|
|
19
|
+
|
|
20
|
+
UnifiedMemory uses a **local MCP (Model Context Protocol) server** approach:
|
|
21
|
+
|
|
22
|
+
1. **One-time authentication**: `um login` stores your credentials locally in `~/.um/auth.json`
|
|
23
|
+
2. **Project context**: `um init` creates `.um/config.json` in your project directory
|
|
24
|
+
3. **Local MCP server**: AI assistants spawn `um mcp serve` which:
|
|
25
|
+
- Reads authentication from `~/.um/auth.json`
|
|
26
|
+
- Auto-detects project context from `.um/config.json` in current directory
|
|
27
|
+
- Forwards tool calls to UnifiedMemory API with proper authentication
|
|
28
|
+
- Handles token refresh automatically
|
|
29
|
+
|
|
30
|
+
This means:
|
|
31
|
+
- ✅ No tokens stored in AI assistant configuration files
|
|
32
|
+
- ✅ No re-authentication needed
|
|
33
|
+
- ✅ Automatic project context detection based on directory
|
|
34
|
+
- ✅ Works seamlessly across multiple projects
|
|
35
|
+
|
|
36
|
+
## What does `um init` do?
|
|
37
|
+
|
|
38
|
+
1. **Authenticates** you via OAuth (or uses saved session)
|
|
39
|
+
2. **Prompts** for project selection (create new or link existing)
|
|
40
|
+
3. **Creates** `.um/config.json` with org_id and project_id
|
|
41
|
+
4. **Configures** all detected AI tools to use local MCP server
|
|
42
|
+
5. **Ready to use** - just restart your AI assistant!
|
|
43
|
+
|
|
44
|
+
## Features
|
|
45
|
+
|
|
46
|
+
- ✅ OAuth 2.0 authentication with automatic token refresh
|
|
47
|
+
- ✅ Auto-detect and configure AI code assistants
|
|
48
|
+
- ✅ Local MCP server with secure token storage
|
|
49
|
+
- ✅ Multi-project support with automatic context switching
|
|
50
|
+
- ✅ Automatic .gitignore updates
|
|
51
|
+
- ✅ Supports Claude Code, Cursor, Cline, Codex CLI, and Gemini CLI
|
|
52
|
+
|
|
53
|
+
## Commands
|
|
54
|
+
|
|
55
|
+
### `um init`
|
|
56
|
+
Initialize UnifiedMemory in the current project (recommended).
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
um init # Interactive setup
|
|
60
|
+
um init --skip-configure # Skip AI tool configuration
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### `um login`
|
|
64
|
+
Authenticate with UnifiedMemory using OAuth. Opens browser for login.
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
um login
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### `um mcp serve`
|
|
71
|
+
Start MCP server (used internally by AI assistants - you don't need to run this manually).
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
um mcp serve
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### `um status`
|
|
78
|
+
Show authentication status, current organization, and project configuration.
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
um status
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### `um org switch`
|
|
85
|
+
Switch between organizations or personal account.
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
um org switch
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### `um project`
|
|
92
|
+
Manage project configuration (coming soon).
|
|
93
|
+
|
|
94
|
+
### `um configure`
|
|
95
|
+
Configure AI code assistants (coming soon).
|
|
96
|
+
|
|
97
|
+
## Configuration
|
|
98
|
+
|
|
99
|
+
### Environment Variables
|
|
100
|
+
|
|
101
|
+
Create a `.env` file in the CLI directory:
|
|
102
|
+
|
|
103
|
+
```env
|
|
104
|
+
CLERK_CLIENT_ID=your_clerk_client_id
|
|
105
|
+
CLERK_DOMAIN=clear-caiman-45.clerk.accounts.dev
|
|
106
|
+
API_ENDPOINT=https://api.unifiedmemory.ai
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Project Configuration
|
|
110
|
+
|
|
111
|
+
After running `um init`, a `.um/config.json` file is created:
|
|
112
|
+
|
|
113
|
+
```json
|
|
114
|
+
{
|
|
115
|
+
"version": "1.0",
|
|
116
|
+
"org_id": "org_xxx",
|
|
117
|
+
"project_id": "proj_xxx",
|
|
118
|
+
"project_name": "My Project",
|
|
119
|
+
"api_url": "https://api.unifiedmemory.ai",
|
|
120
|
+
"created_at": "2024-12-17T...",
|
|
121
|
+
"mcp_config": {
|
|
122
|
+
"inject_headers": true,
|
|
123
|
+
"auto_context": true
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
This file is automatically added to `.gitignore`.
|
|
129
|
+
|
|
130
|
+
### AI Tool Configuration
|
|
131
|
+
|
|
132
|
+
The CLI automatically detects and configures:
|
|
133
|
+
|
|
134
|
+
- **Claude Code**: `.mcp.json` (project-level)
|
|
135
|
+
- **Cursor**: `~/.cursor/mcp.json`
|
|
136
|
+
- **Cline**: `~/.cline/mcp.json`
|
|
137
|
+
- **Codex CLI**: `~/.codex/config.toml` (TOML format)
|
|
138
|
+
- **Gemini CLI**: `~/.gemini/settings.json`
|
|
139
|
+
|
|
140
|
+
Example MCP configuration (JSON format):
|
|
141
|
+
|
|
142
|
+
```json
|
|
143
|
+
{
|
|
144
|
+
"mcpServers": {
|
|
145
|
+
"vault": {
|
|
146
|
+
"command": "um",
|
|
147
|
+
"args": ["mcp", "serve"]
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Example MCP configuration (TOML format for Codex):
|
|
154
|
+
|
|
155
|
+
```toml
|
|
156
|
+
[mcp_servers.vault]
|
|
157
|
+
command = "um"
|
|
158
|
+
args = ["mcp", "serve"]
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
**Note**: No tokens are stored in configuration files. The local MCP server reads authentication from `~/.um/auth.json` and project context from `.um/config.json` automatically.
|
|
162
|
+
|
|
163
|
+
## Supported AI Tools
|
|
164
|
+
|
|
165
|
+
| Tool | MCP Config | Auto-Detect | Config Format |
|
|
166
|
+
|------|-----------|-------------|---------------|
|
|
167
|
+
| Claude Code | ✅ | ✅ | JSON (project-level) |
|
|
168
|
+
| Cursor | ✅ | ✅ | JSON |
|
|
169
|
+
| Cline | ✅ | ✅ | JSON |
|
|
170
|
+
| Codex CLI | ✅ | ✅ | TOML |
|
|
171
|
+
| Gemini CLI | ✅ | ✅ | JSON |
|
|
172
|
+
|
|
173
|
+
## Development
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Clone the repository
|
|
177
|
+
git clone https://github.com/unifiedmemory/um-cli.git
|
|
178
|
+
cd um-cli
|
|
179
|
+
|
|
180
|
+
# Install dependencies
|
|
181
|
+
npm install
|
|
182
|
+
|
|
183
|
+
# Run locally
|
|
184
|
+
node index.js init
|
|
185
|
+
|
|
186
|
+
# Build standalone binaries
|
|
187
|
+
npm run build
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Architecture
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
AI Tool (Claude/Cursor/Cline/Codex/Gemini)
|
|
194
|
+
↓ stdio (JSON-RPC)
|
|
195
|
+
um mcp serve (local MCP server)
|
|
196
|
+
├─ Reads ~/.um/auth.json (authentication)
|
|
197
|
+
├─ Reads .um/config.json (project context from cwd)
|
|
198
|
+
├─ Validates/refreshes token if expired
|
|
199
|
+
↓ HTTPS with auth headers
|
|
200
|
+
Gateway: https://rose-asp-main-1c0b114.d2.zuplo.dev/mcp
|
|
201
|
+
↓ Forwards with signed headers
|
|
202
|
+
Backend: vault-product
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
**Key Components**:
|
|
206
|
+
- **Authentication**: Clerk OAuth 2.0 with PKCE flow + automatic token refresh
|
|
207
|
+
- **Session Storage**: `~/.um/auth.json` (tokens with refresh capability)
|
|
208
|
+
- **Project Config**: `.um/config.json` (per-directory context)
|
|
209
|
+
- **Provider Detection**: Auto-detect 5 AI tools
|
|
210
|
+
- **MCP Server**: stdio transport proxying to HTTP gateway
|
|
211
|
+
- **Context Auto-Detection**: Project-aware based on working directory
|
|
212
|
+
|
|
213
|
+
## License
|
|
214
|
+
|
|
215
|
+
MIT
|
|
216
|
+
|
|
217
|
+
## Support
|
|
218
|
+
|
|
219
|
+
- GitHub Issues: https://github.com/unifiedmemory/um-cli/issues
|
|
220
|
+
- Documentation: https://docs.unifiedmemory.ai
|