@unifiedmemory/cli 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.env.example CHANGED
@@ -1,9 +1,30 @@
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
1
+ # UnifiedMemory CLI Configuration
2
+ # Copy this file to .env and fill in your values
4
3
 
5
- # CLERK_CLIENT_ID=your_test_clerk_client_id
6
- # CLERK_DOMAIN=your-test-app.clerk.accounts.dev
7
- # API_ENDPOINT=http://localhost:8000
4
+ # ============================================
5
+ # REQUIRED: Clerk OAuth Configuration
6
+ # ============================================
7
+ # Get these from your Clerk dashboard: https://dashboard.clerk.com
8
+ CLERK_CLIENT_ID=your_clerk_client_id_here
9
+ CLERK_DOMAIN=your-app.clerk.accounts.dev
10
+
11
+ # ============================================
12
+ # REQUIRED: API Configuration
13
+ # ============================================
14
+ # Your UnifiedMemory API gateway URL
15
+ API_ENDPOINT=https://your-api-gateway.zuplo.dev
16
+
17
+ # ============================================
18
+ # OPTIONAL: OAuth Flow Configuration
19
+ # ============================================
20
+ # Customize the OAuth redirect URI and local server port
21
+ # Default values work for most users
8
22
  # REDIRECT_URI=http://localhost:3333/callback
9
23
  # PORT=3333
24
+
25
+ # ============================================
26
+ # OPTIONAL: Clerk Client Secret
27
+ # ============================================
28
+ # Not required for PKCE flow (recommended)
29
+ # Only set this if specifically instructed
30
+ # CLERK_CLIENT_SECRET=your_clerk_client_secret
package/CHANGELOG.md CHANGED
@@ -5,6 +5,238 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [Unreleased]
9
+
10
+ ### Fixed
11
+
12
+ - **commands/init.js** - Enhanced error handling for 401/403/network errors during project fetching
13
+ - Previously, `um init` would silently suppress authentication errors and show "0 available projects"
14
+ - Now detects specific error types (401 UNAUTHORIZED, 403 FORBIDDEN, network errors, etc.)
15
+ - Validates organization context before making API calls to prevent user_id fallback issues
16
+ - Provides clear error messages with actionable recovery steps (e.g., "Run: um login")
17
+ - Exits gracefully instead of continuing with incorrect state
18
+ - Distinguishes between "legitimately 0 projects" and "failed to fetch projects"
19
+ - Adds `validateOrganizationContext()` helper to detect personal account context
20
+ - Enhanced `fetchProjects()` to return structured error objects instead of empty arrays
21
+ - Enhanced `createProject()` with specific error messages for 401/403/409 status codes
22
+
23
+ - **lib/org-selection-ui.js** - Fixed organization selection prompt not displaying during `um login`
24
+ - Updated prompt type from deprecated `'list'` to `'select'` (inquirer v13 breaking change)
25
+ - Previously, the prompt would show question text but not the visual list of options
26
+ - Users now see a proper interactive list with arrow key navigation
27
+ - Removed debug console.log statements that could interfere with prompt rendering
28
+ - Kept helpful instruction: "💡 Use ↑/↓ arrow keys to navigate, Enter to select"
29
+
30
+ - **commands/init.js** - Converted project selection prompts to arrow key navigation for consistent UX
31
+ - **Create vs Select choice**: Changed from numbered input (type "1" or "2") to arrow key selection
32
+ - **Project list selection**: Changed from numbered input (type project number) to arrow key navigation
33
+ - Added pagination support for long project lists (10 items per page)
34
+ - Removed ~22 lines of manual numbering, validation, and parseInt logic
35
+ - Direct value returns instead of array indexing (cleaner, less error-prone)
36
+ - Consistent with organization selection UX (all selections now use arrow keys)
37
+
38
+ - **commands/init.js** - Added automatic re-authentication on 401 errors (self-healing behavior)
39
+ - Previously, `um init` would fail with "Run: um login" message when token was invalid/expired
40
+ - Now automatically triggers re-authentication when 401 errors occur during project fetch
41
+ - Opens browser for OAuth, gets fresh credentials, and retries the operation
42
+ - Single retry prevents infinite loops, falls back to error message if retry fails
43
+ - Users no longer need to manually run `um login` when their tokens expire
44
+ - Clear progress messages: "Attempting automatic re-authentication...", "✓ Re-authentication successful!"
45
+ - Gracefully handles user cancellation and persistent failures
46
+
47
+ ## [1.1.0] - 2026-01-07
48
+
49
+ ### ♻️ CODE QUALITY (Phase 1: Code Consolidation)
50
+
51
+ This release focuses on code quality improvements, removing duplication, and eliminating dead code. **No breaking changes** - all existing commands work identically.
52
+
53
+ #### Added
54
+
55
+ - **lib/jwt-utils.js** - New centralized JWT utilities module
56
+ - `parseJWT(token)` - Parse JWT tokens
57
+ - `isJWTExpired(decoded, bufferMs)` - Check token expiration
58
+ - `validateJWTStructure(decoded)` - Validate JWT structure
59
+ - `getTimeUntilExpiration(decoded)` - Calculate time until expiration
60
+
61
+ - **lib/org-selection-ui.js** - New shared organization selection UI module
62
+ - `promptOrganizationSelection(memberships, currentOrg, options)` - Interactive org selection
63
+ - `displayOrganizationSelection(selectedOrg)` - Display selection result
64
+
65
+ #### Changed
66
+
67
+ - **commands/login.js** - Removed ~60 lines of duplicate code
68
+ - Now imports `parseJWT` from `lib/jwt-utils.js`
69
+ - Now uses `promptOrganizationSelection` and `displayOrganizationSelection` from `lib/org-selection-ui.js`
70
+
71
+ - **lib/token-refresh.js** - Removed ~15 lines of duplicate code
72
+ - Now imports `parseJWT` from `lib/jwt-utils.js`
73
+
74
+ - **commands/org.js** - Removed ~50 lines of duplicate code
75
+ - Now uses `promptOrganizationSelection` and `displayOrganizationSelection` from `lib/org-selection-ui.js`
76
+
77
+ - **lib/config.js** - Replaced custom .env parser with `dotenv` library
78
+ - Removed ~15 lines of fragile custom parsing code
79
+ - Now uses battle-tested `dotenv` package
80
+
81
+ - **lib/provider-detector.js** - Replaced custom TOML parser with `@iarna/toml` library
82
+ - Removed ~60 lines of custom `parseTOML()` and `generateTOML()` functions
83
+ - Now uses standard `@iarna/toml` package
84
+
85
+ #### Removed
86
+
87
+ - **Dead code from commands/init.js**:
88
+ - `loginWithApiKey()` stub function (never implemented, always returned null)
89
+ - `refreshToken()` stub function (never called, real implementation exists elsewhere)
90
+ - Removed API key login path that never worked
91
+
92
+ - **Stub commands from index.js**:
93
+ - `um project` command (non-functional stub that told users to use `um init`)
94
+ - `um configure` command (non-functional stub that told users to use `um init`)
95
+ - `--device` option on `um login` command (never used in implementation)
96
+
97
+ #### Dependencies
98
+
99
+ - Added `dotenv@^16.3.1` - Industry-standard .env file parsing
100
+ - Added `@iarna/toml@^2.2.5` - Spec-compliant TOML parser
101
+
102
+ #### Code Metrics
103
+
104
+ - **Lines removed**: ~210 lines of duplicate and dead code
105
+ - **New modules**: 2 shared utility modules
106
+ - **Code coverage**: Increased maintainability and reduced technical debt
107
+
108
+ #### Migration Guide
109
+
110
+ **No action required** - This release is 100% backward compatible. All existing commands and workflows continue to work without changes.
111
+
112
+ **Developer Notes**: If you were using the stub commands (`um project`, `um configure`), use `um init` instead as the stubs always instructed.
113
+
114
+ ## [1.0.2] - 2026-01-07
115
+
116
+ ### 🔒 SECURITY FIXES (Phase 0: Critical Security Hardening)
117
+
118
+ This release addresses **5 critical security vulnerabilities** identified during comprehensive security audit. All users should upgrade immediately.
119
+
120
+ #### Fixed
121
+
122
+ 1. **CRITICAL: Insecure Token Storage**
123
+ - **Issue**: Authentication tokens stored with default permissions (644), readable by all users on system
124
+ - **Fix**: Token directory now created with 0700 permissions (owner-only access)
125
+ - **Fix**: Token file (`~/.um/auth.json`) now written with 0600 permissions (owner read/write only)
126
+ - **Impact**: Prevents unauthorized access to OAuth tokens on shared systems
127
+ - **Files**: `lib/token-storage.js`
128
+
129
+ 2. **CRITICAL: Hardcoded Production Credentials**
130
+ - **Issue**: Clerk client ID, domain, and API endpoint hardcoded in source code
131
+ - **Fix**: Removed all hardcoded defaults, now requires environment variables
132
+ - **Fix**: Added `.env.example` template file
133
+ - **Fix**: Implemented actual validation in `validateConfig()` with helpful error messages
134
+ - **Impact**: Credentials can now be rotated without code changes, prevents exposure in git
135
+ - **Files**: `lib/config.js`, `.env.example` (new)
136
+
137
+ 3. **HIGH: Weak CSRF Protection**
138
+ - **Issue**: OAuth state parameter generated using `Math.random()` (predictable)
139
+ - **Fix**: Now uses `crypto.randomBytes(32)` for cryptographically secure random generation
140
+ - **Impact**: Prevents CSRF attacks during OAuth flow
141
+ - **Files**: `commands/login.js`
142
+
143
+ 4. **CRITICAL: Access Tokens in Bash Scripts**
144
+ - **Issue**: `lib/hooks.js` embedded access tokens directly in bash scripts with command injection vulnerability
145
+ - **Fix**: Completely removed hooks.js file and all hook installation code
146
+ - **Impact**: Eliminates token leakage and command injection attack surface
147
+ - **Files**: `lib/hooks.js` (DELETED), `lib/provider-detector.js`
148
+
149
+ 5. **MEDIUM: Token Leakage in Console Logs**
150
+ - **Issue**: Full JWT tokens, previews, and decoded payloads logged to console during login
151
+ - **Fix**: Removed all token logging (lines 228-250 in login.js, line 62 debug logging)
152
+ - **Impact**: Prevents token capture in terminal history, screen recordings, or log files
153
+ - **Files**: `commands/login.js`
154
+
155
+ #### Added
156
+
157
+ - `.env.example` - Template file for required environment variables
158
+ - Comprehensive security documentation in README.md
159
+ - Configuration section in README.md explaining .env setup
160
+ - Enhanced error messages when environment variables are missing
161
+
162
+ #### Changed
163
+
164
+ - **BREAKING**: CLI now requires `.env` file with `CLERK_CLIENT_ID`, `CLERK_DOMAIN`, and `API_ENDPOINT`
165
+ - Token storage file permissions upgraded automatically on next write
166
+ - Validation errors now provide actionable guidance for users
167
+
168
+ #### Removed
169
+
170
+ - `lib/hooks.js` - Entire file deleted due to unfixable security vulnerabilities
171
+ - Claude Code prompt-submit hook installation - Removed from provider detector
172
+ - `BaseProvider.installHook()` method - No longer supported
173
+ - `ClaudeProvider.installHook()` method - No longer supported
174
+ - Console logging of tokens, JWT claims, and raw membership data
175
+
176
+ #### Migration Guide
177
+
178
+ **For Existing Users**:
179
+
180
+ 1. **Create `.env` file** (required):
181
+ ```bash
182
+ cd $(npm root -g)/@unifiedmemory/cli # Or your installation directory
183
+ cp .env.example .env
184
+ # Edit .env with your credentials (see README Configuration section)
185
+ ```
186
+
187
+ 2. **Token permissions auto-upgrade**: Next time you login, token files will automatically get secure permissions
188
+
189
+ 3. **Hooks removed**: If you configured Claude Code hooks, they will no longer work. This feature has been removed for security reasons.
190
+
191
+ **For New Users**: Follow the Configuration section in README.md
192
+
193
+ #### Security Notes
194
+
195
+ - All fixes are backward compatible with existing authentication flows
196
+ - Token refresh continues to work without changes
197
+ - No user data or credentials were compromised
198
+ - Security audit report available in plan file
199
+
200
+ ## [1.0.1] - 2026-01-06
201
+
202
+ ### Added
203
+ - Welcome splash screen with pink Axolotl ASCII art
204
+ - `um welcome` command to display welcome message anytime
205
+ - Automatic welcome display when running `um` without arguments
206
+
207
+ ### BREAKING CHANGES
208
+ - Changed MCP server configuration key from "vault" to "unifiedmemory" for consistency
209
+ - Changed MCP server instance name from "unifiedmemory-vault" to "unifiedmemory"
210
+
211
+ ### Migration Guide
212
+
213
+ If you previously ran `um init` with v1.0.0, you need to update your AI assistant configuration files to rename the server key from "vault" to "unifiedmemory". Choose the instructions below based on which AI assistant(s) you use:
214
+
215
+ **Cursor** (`~/.cursor/mcp.json`):
216
+ - Edit the file and rename `mcpServers.vault` to `mcpServers.unifiedmemory`
217
+ - Keep the same `command` and `args` values
218
+
219
+ **Cline** (`~/.cline/mcp.json`):
220
+ - Edit the file and rename `mcpServers.vault` to `mcpServers.unifiedmemory`
221
+ - Keep the same `command` and `args` values
222
+
223
+ **Codex CLI** (`~/.codex/config.toml`):
224
+ - Edit the file and rename `[mcp_servers.vault]` to `[mcp_servers.unifiedmemory]`
225
+ - Keep the same `command` and `args` values
226
+
227
+ **Gemini CLI** (`~/.gemini/settings.json`):
228
+ - Edit the file and rename `mcpServers.vault` to `mcpServers.unifiedmemory`
229
+ - Keep the same `command` and `args` values
230
+
231
+ **Claude Code** (project-specific):
232
+ - Edit `.mcp.json` in your project: rename `mcpServers.vault` to `mcpServers.unifiedmemory`
233
+ - Edit `.claude/settings.local.json` in your project: update the `enabledMcpjsonServers` array to replace `"vault"` with `"unifiedmemory"`
234
+ - Keep the same `command` and `args` values
235
+
236
+ After updating the configuration files, restart your AI assistant for the changes to take effect.
237
+
238
+ **Note**: If you're doing a fresh installation of v1.0.1, no migration is needed - `um init` will automatically configure the correct server name.
239
+
8
240
  ## [1.0.0] - 2026-01-06
9
241
 
10
242
  ### Added