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