@xmemo/client 0.4.128 → 0.4.129

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 +313 -313
  3. package/bin/memory-os.js +12 -12
  4. package/package.json +46 -46
  5. package/src/cli.js +2093 -2020
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,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
- # or
24
- xmemo --update
25
- ```
26
-
27
- Both commands run `npm install -g @xmemo/client@latest`. Use
28
- `xmemo update --dry-run` to print the exact command without changing anything.
29
-
30
- ## Commands
31
-
32
- ```bash
33
- xmemo update
34
- xmemo setup codex
35
- xmemo setup codex --yes
36
- xmemo smoke --client codex
37
- xmemo doctor
38
- xmemo discovery show
39
- xmemo setup
40
- xmemo login
41
- xmemo status
42
- xmemo token status
43
- xmemo token add --from-stdin
44
- xmemo env example --shell bash
45
- xmemo mcp list
46
- xmemo mcp config --client generic
47
- xmemo profile status codex
48
- xmemo mcp add cursor --url "https://your-private-service.example"
49
- xmemo privacy
50
- ```
51
-
52
- ## Enterprise privacy and security defaults
53
-
54
- - No telemetry or analytics.
55
- - `xmemo doctor`, `xmemo discovery show`, and `xmemo status` do not send tokens.
56
- - MCP config generated by the CLI references `XMEMO_KEY`; it does not write
57
- token values into project files.
58
- - The CLI generates one stable non-secret `XMEMO_AGENT_INSTANCE_ID` per local
59
- client profile and stores it in user-scoped config outside git.
60
- - `xmemo login` and `xmemo token add` store tokens only in the user-scoped
61
- XMemo CLI credential file outside git; token values are never printed.
62
- - Legacy `xmemo token set` refuses plaintext credential storage unless
63
- `--allow-plaintext` is explicitly provided.
64
- - The npm package uses a `files` whitelist so only `bin`, `src`, `README.md`,
65
- and `LICENSE` are published.
66
-
67
- ## Token flow
68
-
69
- Recommended personal-user flow:
70
-
71
- ```bash
72
- xmemo login
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` 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
+ ```
package/bin/memory-os.js CHANGED
@@ -1,12 +1,12 @@
1
- #!/usr/bin/env node
2
- import { run } from '../src/cli.js';
3
-
4
- const exitCode = await run(process.argv.slice(2), {
5
- env: process.env,
6
- stdin: process.stdin,
7
- stdout: process.stdout,
8
- stderr: process.stderr,
9
- fetch: globalThis.fetch
10
- });
11
-
12
- process.exitCode = exitCode;
1
+ #!/usr/bin/env node
2
+ import { run } from '../src/cli.js';
3
+
4
+ const exitCode = await run(process.argv.slice(2), {
5
+ env: process.env,
6
+ stdin: process.stdin,
7
+ stdout: process.stdout,
8
+ stderr: process.stderr,
9
+ fetch: globalThis.fetch
10
+ });
11
+
12
+ process.exitCode = exitCode;