@xmemo/client 0.4.129 → 0.4.132

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/LICENSE +7 -7
  2. package/README.md +322 -313
  3. package/bin/memory-os.js +12 -12
  4. package/package.json +46 -46
  5. package/src/cli.js +2146 -2093
package/LICENSE CHANGED
@@ -1,7 +1,7 @@
1
- Copyright (c) Yonro.
2
-
3
- All rights reserved.
4
-
5
- This package is published as a client distribution artifact for XMemo.
6
- No license is granted to copy, modify, distribute, sublicense, or use the source
7
- code except as expressly permitted by Yonro in a separate written agreement.
1
+ Copyright (c) Yonro.
2
+
3
+ All rights reserved.
4
+
5
+ This package is published as a client distribution artifact for XMemo.
6
+ No license is granted to copy, modify, distribute, sublicense, or use the source
7
+ code except as expressly permitted by Yonro in a separate written agreement.
package/README.md CHANGED
@@ -1,313 +1,322 @@
1
- # XMemo CLI
2
-
3
- `@xmemo/client` is the privacy-first command line entry point for XMemo client
4
- setup. It is intentionally small: the npm package contains only the CLI and
5
- setup helper code needed on a user's machine.
6
-
7
- `@yonro/xmemo-client` is reserved as a Yonro fallback package. The CLI exposes
8
- `xmemo` as the primary command and keeps `memory-os` as a compatibility alias.
9
-
10
- The XMemo server, database, token registry, deployment files, logs, and
11
- internal scripts are not part of this npm package.
12
-
13
- ## Install
14
-
15
- ```bash
16
- npm install -g @xmemo/client
17
- ```
18
-
19
- Upgrade an existing global install:
20
-
21
- ```bash
22
- xmemo update
23
- ```
24
-
25
- This runs `npm install -g @xmemo/client@latest`. Use `xmemo update --dry-run`
26
- to print the exact command without changing anything.
27
-
28
- ## Commands
29
-
30
- ```bash
31
- xmemo update
32
- xmemo setup codex
33
- xmemo setup codex --yes
34
- xmemo smoke --client codex
35
- xmemo doctor
36
- xmemo discovery show
37
- xmemo setup
38
- xmemo login
39
- xmemo auth status
40
- xmemo status
41
- xmemo token status
42
- xmemo token add --from-stdin
43
- xmemo env example --shell bash
44
- xmemo mcp list
45
- xmemo mcp config --client generic
46
- xmemo profile status codex
47
- xmemo mcp add cursor --url "https://your-private-service.example"
48
- xmemo privacy
49
- ```
50
-
51
- ## Enterprise privacy and security defaults
52
-
53
- - No telemetry or analytics.
54
- - `xmemo doctor`, `xmemo discovery show`, and `xmemo status` do not send tokens.
55
- - MCP config generated by the CLI references `XMEMO_KEY`; it does not write
56
- token values into project files.
57
- - The CLI generates one stable non-secret `XMEMO_AGENT_INSTANCE_ID` per local
58
- client profile and stores it in user-scoped config outside git.
59
- - `xmemo login` and `xmemo token add` store tokens only in the user-scoped
60
- XMemo CLI credential file outside git; token values are never printed.
61
- - Legacy `xmemo token set` refuses plaintext credential storage unless
62
- `--allow-plaintext` is explicitly provided.
63
- - The npm package uses a `files` whitelist so only `bin`, `src`, `README.md`,
64
- and `LICENSE` are published.
65
-
66
- ## Token flow
67
-
68
- Recommended personal-user flow:
69
-
70
- ```bash
71
- xmemo login
72
- xmemo auth status
73
- xmemo token status --verify
74
- ```
75
-
76
- `xmemo login` uses the hosted device-login flow when the service advertises it:
77
- the CLI shows a browser URL and one-time code, the user authorizes in XMemo, and
78
- the CLI stores the issued MCP token in the user-scoped credential file.
79
-
80
- Users who already have a token can configure it directly without shell profiles:
81
-
82
- ```bash
83
- printf '%s\n' 'your-token' | xmemo token add --from-stdin
84
- xmemo token status --verify
85
- ```
86
-
87
- This is the preferred fallback while a hosted service is rolling out device
88
- login. It still avoids project files, MCP config files, logs, and chat
89
- transcripts.
90
-
91
- Tokens should be created by the XMemo website or enterprise console, then
92
- stored with `xmemo login`, `xmemo token add`, a user environment variable, or an
93
- enterprise secret manager:
94
-
95
- ```bash
96
- export XMEMO_KEY="your-token"
97
- ```
98
-
99
- PowerShell:
100
-
101
- ```powershell
102
- [Environment]::SetEnvironmentVariable("XMEMO_KEY", "your-token", "User")
103
- ```
104
-
105
- Do not commit tokens to source control, MCP config files, `.env` files, logs, or
106
- chat transcripts.
107
-
108
- ## Hosted discovery setup
109
-
110
- Hosted setup uses the XMemo public discovery contracts. The CLI reads
111
- secret-free discovery and onboarding status documents, then tells the user where
112
- the API, MCP endpoint, docs, and any server-advertised onboarding links are.
113
-
114
- ```bash
115
- xmemo doctor
116
- xmemo discovery show
117
- xmemo setup
118
- ```
119
-
120
- Discovery requests do not send `XMEMO_KEY` or any Authorization
121
- header. Token creation still happens in the website or enterprise console; the
122
- public service discovery document does not return token values.
123
-
124
- The hosted default service/base URL is `https://xmemo.dev`, so normal users do
125
- not need to type a service address. The MCP endpoint is discovered from that
126
- base URL and written as `https://xmemo.dev/mcp`; `https://mcp.xmemo.dev` is not
127
- the current canonical setup URL. Use `--url <service-url>` or `XMEMO_URL` only
128
- for private, enterprise, or self-hosted deployments. `MEMORY_OS_URL` remains
129
- accepted as a compatibility alias.
130
-
131
- Generate and write a client config from discovery:
132
-
133
- ```bash
134
- xmemo setup codex --yes
135
- xmemo setup codex --url "https://your-private-service.example" --yes
136
- xmemo setup --url "https://your-private-service.example" --client codex --write
137
- xmemo setup --url "https://your-private-service.example" --client cursor --write
138
- ```
139
-
140
- `--write` requires an explicit `--client` so the CLI never performs broad config
141
- writes implicitly. Generated config references `XMEMO_KEY`; it does not embed
142
- the token value. Write-capable client configs also include stable non-secret
143
- agent identity headers where the client format supports them.
144
-
145
- `xmemo setup codex` is the recommended Codex path. Without `--yes` it
146
- previews the Codex MCP config and the project-scoped `AGENTS.md` memory profile.
147
- With `--yes`, it writes the Codex MCP config and installs the profile into the
148
- current project's `AGENTS.md` marker block. Use `--profile-target <path>` to
149
- choose a different project instruction file, or `--no-profile` to configure MCP
150
- only.
151
-
152
- ## MCP setup
153
-
154
- List supported client generators:
155
-
156
- ```bash
157
- xmemo mcp list
158
- ```
159
-
160
- Current write-capable clients:
161
-
162
- ```text
163
- codex ~/.codex/config.toml
164
- cursor ~/.cursor/mcp.json
165
- ```
166
-
167
- For clients without a verified user-scoped write path, generate a read-only
168
- template and apply it manually after review:
169
-
170
- ```bash
171
- xmemo mcp config --client copilot-cli
172
- xmemo mcp config --client generic --base-url "https://your-private-service.example" --json
173
- ```
174
-
175
- Only Codex and Cursor currently have write-capable helpers. Other client writes
176
- should only be added after their official user-scoped config format is verified.
177
-
178
- ### Copilot CLI
179
-
180
- Copilot CLI has `/mcp` management, but it does not currently document a stable
181
- cross-platform user config file path/format for third-party tools to edit
182
- directly. The recommended personal-user path is therefore local proxy mode:
183
-
184
- ```bash
185
- xmemo login
186
- xmemo mcp config --client copilot-cli
187
- xmemo mcp proxy
188
- ```
189
-
190
- The generated Copilot CLI template points at `http://127.0.0.1:8765/mcp` and
191
- does not include token or identity headers. `xmemo mcp proxy` reads the token
192
- saved by `xmemo login` or `xmemo token add --from-stdin`, adds the XMemo bearer
193
- token and local agent identity, then forwards requests to `https://xmemo.dev/mcp`.
194
- If you specifically want the older environment-variable template, run:
195
-
196
- ```bash
197
- xmemo mcp config --client copilot-cli --remote-env
198
- ```
199
-
200
- ### Codex
201
-
202
- Recommended Codex setup:
203
-
204
- ```bash
205
- xmemo setup codex
206
- xmemo setup codex --yes
207
- xmemo smoke --client codex
208
- ```
209
-
210
- `setup codex` is visible and opt-in: the first command previews the writes, and
211
- `--yes` performs them. The MCP config stays in user-scoped Codex config, while
212
- the XMemo Codex behavior profile is installed into the current project's
213
- `AGENTS.md` between these markers:
214
-
215
- ```html
216
- <!-- memory-os:codex-profile:start -->
217
- <!-- memory-os:codex-profile:end -->
218
- ```
219
-
220
- Repeat installs update only that marker block. Remove it with:
221
-
222
- ```bash
223
- xmemo profile uninstall codex
224
- ```
225
-
226
- Advanced: generate a Codex MCP config snippet without touching files:
227
-
228
- ```bash
229
- xmemo mcp add codex --url "$XMEMO_URL"
230
- ```
231
-
232
- Write it to the default Codex config path:
233
-
234
- ```bash
235
- xmemo mcp add codex --url "$XMEMO_URL" --write
236
- ```
237
-
238
- The generated config references `XMEMO_KEY` and does not include the token
239
- value. Codex custom identity headers are not written until the CLI format is
240
- verified to support them.
241
-
242
- Codex MCP-depth checks:
243
-
244
- ```bash
245
- xmemo mcp profile codex
246
- xmemo profile install codex --dry-run
247
- xmemo profile install codex
248
- xmemo profile status codex
249
- xmemo smoke --client codex
250
- ```
251
-
252
- `xmemo mcp profile codex` prints the recommended memory behavior profile:
253
- recall/search at the start of non-trivial tasks, write back high-signal
254
- decisions and fixes, and never store secrets. `xmemo smoke --client codex`
255
- checks the local Codex TOML config for the `memory_os` MCP server,
256
- `bearer_token_env_var = "XMEMO_KEY"`, token presence in the environment, and
257
- absence of embedded token values.
258
-
259
- ### Cursor
260
-
261
- Generate a Cursor MCP config snippet:
262
-
263
- ```bash
264
- xmemo mcp add cursor --url "$XMEMO_URL"
265
- ```
266
-
267
- Merge it into the default Cursor user config path:
268
-
269
- ```bash
270
- xmemo mcp add cursor --url "$XMEMO_URL" --write
271
- ```
272
-
273
- The CLI refuses to overwrite an existing `memory_os` MCP server entry. Edit the
274
- config manually if you need to rotate the endpoint. Cursor configs include
275
- `X-Memory-OS-Agent-ID` and `X-Memory-OS-Agent-Instance-ID`; the instance ID is
276
- non-secret and stored under the user's XMemo CLI config directory.
277
-
278
- ## Release model
279
-
280
- This repository is the source for the `@xmemo/client` npm package. Releases
281
- should be published from GitHub Actions on tags or GitHub Releases, not from a
282
- developer workstation.
283
-
284
- Recommended flow:
285
-
286
- ```text
287
- develop -> test -> tag/release -> GitHub Actions -> npm publish --provenance
288
- ```
289
-
290
- ## Package boundary
291
-
292
- Included in npm:
293
-
294
- ```text
295
- bin/
296
- src/
297
- README.md
298
- LICENSE
299
- ```
300
-
301
- Excluded from npm:
302
-
303
- ```text
304
- .github/
305
- test/
306
- coverage/
307
- server code
308
- database migrations
309
- deployment files
310
- logs
311
- local state
312
- secrets
313
- ```
1
+ # XMemo CLI
2
+
3
+ `@xmemo/client` is the privacy-first command line entry point for XMemo client
4
+ setup. It is intentionally small: the npm package contains only the CLI and
5
+ setup helper code needed on a user's machine.
6
+
7
+ `@yonro/xmemo-client` is reserved as a Yonro fallback package. The CLI exposes
8
+ `xmemo` as the primary command and keeps `memory-os` as a compatibility alias.
9
+
10
+ The XMemo server, database, token registry, deployment files, logs, and
11
+ internal scripts are not part of this npm package.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ npm install -g @xmemo/client
17
+ ```
18
+
19
+ Upgrade an existing global install:
20
+
21
+ ```bash
22
+ xmemo update
23
+ ```
24
+
25
+ This runs `npm install -g @xmemo/client@latest`. Use `xmemo update --dry-run`
26
+ to print the exact command without changing anything.
27
+
28
+ ## Commands
29
+
30
+ ```bash
31
+ xmemo update
32
+ xmemo setup codex
33
+ xmemo setup codex --yes
34
+ xmemo smoke --client codex
35
+ xmemo doctor
36
+ xmemo discovery show
37
+ xmemo setup
38
+ xmemo login
39
+ xmemo auth status
40
+ xmemo status
41
+ xmemo token status
42
+ xmemo token add --from-stdin
43
+ xmemo env example --shell bash
44
+ xmemo mcp list
45
+ xmemo mcp config --client generic
46
+ xmemo profile status codex
47
+ xmemo mcp add cursor --url "https://your-private-service.example"
48
+ xmemo privacy
49
+ ```
50
+
51
+ ## Enterprise privacy and security defaults
52
+
53
+ - No telemetry or analytics.
54
+ - `xmemo doctor`, `xmemo discovery show`, and `xmemo status` do not send tokens.
55
+ - MCP config generated by the CLI references `XMEMO_KEY`; it does not write
56
+ token values into project files.
57
+ - The CLI generates one stable non-secret `XMEMO_AGENT_INSTANCE_ID` per local
58
+ client profile and stores it in user-scoped config outside git.
59
+ - `xmemo login` stores the issued credential in the user-scoped XMemo CLI
60
+ config directory, shows the approved account when the server provides it,
61
+ and does not require extra token configuration afterward.
62
+ - `xmemo token add` remains available for existing tokens and still avoids
63
+ project files, shell history, and printed token values.
64
+ - Legacy `xmemo token set` refuses plaintext credential storage unless
65
+ `--allow-plaintext` is explicitly provided.
66
+ - The npm package uses a `files` whitelist so only `bin`, `src`, `README.md`,
67
+ and `LICENSE` are published.
68
+
69
+ ## Token flow
70
+
71
+ Recommended personal-user flow:
72
+
73
+ ```bash
74
+ xmemo login
75
+ xmemo auth status
76
+ xmemo token status --verify
77
+ ```
78
+
79
+ `xmemo login` uses the hosted device-login flow when the service advertises it:
80
+ the CLI shows a browser URL and one-time code, the user authorizes in XMemo, and
81
+ the CLI stores the issued MCP token in the user-scoped credential file. When the
82
+ service returns approved account metadata, the CLI prints the account label so
83
+ users can confirm which XMemo account was connected. No manual token setup is
84
+ needed after a successful `xmemo login`; `xmemo token status --verify` is only
85
+ an optional connectivity check. The CLI waits for the full browser authorization
86
+ window by default; use `--timeout-ms` only to shorten or extend that approval
87
+ window, and `--http-timeout-ms` only for individual service requests.
88
+
89
+ Users who already have a token can configure it directly without shell profiles:
90
+
91
+ ```bash
92
+ printf '%s\n' 'your-token' | xmemo token add --from-stdin
93
+ xmemo token status --verify
94
+ ```
95
+
96
+ This is the preferred fallback while a hosted service is rolling out device
97
+ login. It still avoids project files, MCP config files, logs, and chat
98
+ transcripts.
99
+
100
+ Tokens should be created by the XMemo website or enterprise console, then
101
+ stored with `xmemo login`, `xmemo token add`, a user environment variable, or an
102
+ enterprise secret manager:
103
+
104
+ ```bash
105
+ export XMEMO_KEY="your-token"
106
+ ```
107
+
108
+ PowerShell:
109
+
110
+ ```powershell
111
+ [Environment]::SetEnvironmentVariable("XMEMO_KEY", "your-token", "User")
112
+ ```
113
+
114
+ Do not commit tokens to source control, MCP config files, `.env` files, logs, or
115
+ chat transcripts.
116
+
117
+ ## Hosted discovery setup
118
+
119
+ Hosted setup uses the XMemo public discovery contracts. The CLI reads
120
+ secret-free discovery and onboarding status documents, then tells the user where
121
+ the API, MCP endpoint, docs, and any server-advertised onboarding links are.
122
+
123
+ ```bash
124
+ xmemo doctor
125
+ xmemo discovery show
126
+ xmemo setup
127
+ ```
128
+
129
+ Discovery requests do not send `XMEMO_KEY` or any Authorization
130
+ header. Token creation still happens in the website or enterprise console; the
131
+ public service discovery document does not return token values.
132
+
133
+ The hosted default service/base URL is `https://xmemo.dev`, so normal users do
134
+ not need to type a service address. The MCP endpoint is discovered from that
135
+ base URL and written as `https://xmemo.dev/mcp`; `https://mcp.xmemo.dev` is not
136
+ the current canonical setup URL. Use `--url <service-url>` or `XMEMO_URL` only
137
+ for private, enterprise, or self-hosted deployments. `MEMORY_OS_URL` remains
138
+ accepted as a compatibility alias.
139
+
140
+ Generate and write a client config from discovery:
141
+
142
+ ```bash
143
+ xmemo setup codex --yes
144
+ xmemo setup codex --url "https://your-private-service.example" --yes
145
+ xmemo setup --url "https://your-private-service.example" --client codex --write
146
+ xmemo setup --url "https://your-private-service.example" --client cursor --write
147
+ ```
148
+
149
+ `--write` requires an explicit `--client` so the CLI never performs broad config
150
+ writes implicitly. Generated config references `XMEMO_KEY`; it does not embed
151
+ the token value. Write-capable client configs also include stable non-secret
152
+ agent identity headers where the client format supports them.
153
+
154
+ `xmemo setup codex` is the recommended Codex path. Without `--yes` it
155
+ previews the Codex MCP config and the project-scoped `AGENTS.md` memory profile.
156
+ With `--yes`, it writes the Codex MCP config and installs the profile into the
157
+ current project's `AGENTS.md` marker block. Use `--profile-target <path>` to
158
+ choose a different project instruction file, or `--no-profile` to configure MCP
159
+ only.
160
+
161
+ ## MCP setup
162
+
163
+ List supported client generators:
164
+
165
+ ```bash
166
+ xmemo mcp list
167
+ ```
168
+
169
+ Current write-capable clients:
170
+
171
+ ```text
172
+ codex ~/.codex/config.toml
173
+ cursor ~/.cursor/mcp.json
174
+ ```
175
+
176
+ For clients without a verified user-scoped write path, generate a read-only
177
+ template and apply it manually after review:
178
+
179
+ ```bash
180
+ xmemo mcp config --client copilot-cli
181
+ xmemo mcp config --client generic --base-url "https://your-private-service.example" --json
182
+ ```
183
+
184
+ Only Codex and Cursor currently have write-capable helpers. Other client writes
185
+ should only be added after their official user-scoped config format is verified.
186
+
187
+ ### Copilot CLI
188
+
189
+ Copilot CLI has `/mcp` management, but it does not currently document a stable
190
+ cross-platform user config file path/format for third-party tools to edit
191
+ directly. The recommended personal-user path is therefore local proxy mode:
192
+
193
+ ```bash
194
+ xmemo login
195
+ xmemo mcp config --client copilot-cli
196
+ xmemo mcp proxy
197
+ ```
198
+
199
+ The generated Copilot CLI template points at `http://127.0.0.1:8765/mcp` and
200
+ does not include token or identity headers. `xmemo mcp proxy` reads the token
201
+ saved by `xmemo login` or `xmemo token add --from-stdin`, adds the XMemo bearer
202
+ token and local agent identity, then forwards requests to `https://xmemo.dev/mcp`.
203
+ If you specifically want the older environment-variable template, run:
204
+
205
+ ```bash
206
+ xmemo mcp config --client copilot-cli --remote-env
207
+ ```
208
+
209
+ ### Codex
210
+
211
+ Recommended Codex setup:
212
+
213
+ ```bash
214
+ xmemo setup codex
215
+ xmemo setup codex --yes
216
+ xmemo smoke --client codex
217
+ ```
218
+
219
+ `setup codex` is visible and opt-in: the first command previews the writes, and
220
+ `--yes` performs them. The MCP config stays in user-scoped Codex config, while
221
+ the XMemo Codex behavior profile is installed into the current project's
222
+ `AGENTS.md` between these markers:
223
+
224
+ ```html
225
+ <!-- memory-os:codex-profile:start -->
226
+ <!-- memory-os:codex-profile:end -->
227
+ ```
228
+
229
+ Repeat installs update only that marker block. Remove it with:
230
+
231
+ ```bash
232
+ xmemo profile uninstall codex
233
+ ```
234
+
235
+ Advanced: generate a Codex MCP config snippet without touching files:
236
+
237
+ ```bash
238
+ xmemo mcp add codex --url "$XMEMO_URL"
239
+ ```
240
+
241
+ Write it to the default Codex config path:
242
+
243
+ ```bash
244
+ xmemo mcp add codex --url "$XMEMO_URL" --write
245
+ ```
246
+
247
+ The generated config references `XMEMO_KEY` and does not include the token
248
+ value. Codex custom identity headers are not written until the CLI format is
249
+ verified to support them.
250
+
251
+ Codex MCP-depth checks:
252
+
253
+ ```bash
254
+ xmemo mcp profile codex
255
+ xmemo profile install codex --dry-run
256
+ xmemo profile install codex
257
+ xmemo profile status codex
258
+ xmemo smoke --client codex
259
+ ```
260
+
261
+ `xmemo mcp profile codex` prints the recommended memory behavior profile:
262
+ recall/search at the start of non-trivial tasks, write back high-signal
263
+ decisions and fixes, and never store secrets. `xmemo smoke --client codex`
264
+ checks the local Codex TOML config for the `memory_os` MCP server,
265
+ `bearer_token_env_var = "XMEMO_KEY"`, token presence in the environment, and
266
+ absence of embedded token values.
267
+
268
+ ### Cursor
269
+
270
+ Generate a Cursor MCP config snippet:
271
+
272
+ ```bash
273
+ xmemo mcp add cursor --url "$XMEMO_URL"
274
+ ```
275
+
276
+ Merge it into the default Cursor user config path:
277
+
278
+ ```bash
279
+ xmemo mcp add cursor --url "$XMEMO_URL" --write
280
+ ```
281
+
282
+ The CLI refuses to overwrite an existing `memory_os` MCP server entry. Edit the
283
+ config manually if you need to rotate the endpoint. Cursor configs include
284
+ `X-Memory-OS-Agent-ID` and `X-Memory-OS-Agent-Instance-ID`; the instance ID is
285
+ non-secret and stored under the user's XMemo CLI config directory.
286
+
287
+ ## Release model
288
+
289
+ This repository is the source for the `@xmemo/client` npm package. Releases
290
+ should be published from GitHub Actions on tags or GitHub Releases, not from a
291
+ developer workstation.
292
+
293
+ Recommended flow:
294
+
295
+ ```text
296
+ develop -> test -> tag/release -> GitHub Actions -> npm publish --provenance
297
+ ```
298
+
299
+ ## Package boundary
300
+
301
+ Included in npm:
302
+
303
+ ```text
304
+ bin/
305
+ src/
306
+ README.md
307
+ LICENSE
308
+ ```
309
+
310
+ Excluded from npm:
311
+
312
+ ```text
313
+ .github/
314
+ test/
315
+ coverage/
316
+ server code
317
+ database migrations
318
+ deployment files
319
+ logs
320
+ local state
321
+ secrets
322
+ ```