@superpms/memory-cli 0.1.2 → 0.1.4

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/README.md CHANGED
@@ -1,54 +1,504 @@
1
- # @superpms/memory-cli
1
+ # `@superpms/memory-cli`
2
2
 
3
- Memory system CLI manage global layer, will sync, vendor distribution, and Cloud Brain integration.
3
+ `memory` memory system 的命令行工具,用来连接 Cloud Brain、初始化项目、同步 `vendor` `will`,以及管理项目内的 `skill` 和缓存。
4
4
 
5
- ## Install
5
+ ## 功能概览
6
+
7
+ - 登录或注册 Cloud Brain 账号
8
+ - 在当前目录初始化 memory 项目骨架
9
+ - 从 Cloud Brain 拉取最新 `vendor`
10
+ - 将项目中的 `will` 发布到 Cloud Brain,或从 Cloud Brain 拉回本地
11
+ - 订阅他人的 `will` 并拉取订阅内容
12
+ - 查看和卸载项目 `skill`
13
+ - 查看和清理项目缓存
14
+
15
+ ## 环境要求
16
+
17
+ - Node.js `>= 18`
18
+
19
+ ## 安装
6
20
 
7
21
  ```bash
8
22
  npm install -g @superpms/memory-cli
9
23
  ```
10
24
 
11
- ## Quick Start
25
+ 安装后可直接使用:
12
26
 
13
27
  ```bash
14
- # Initialize global layer
15
- memory init --global
28
+ memory --help
29
+ ```
30
+
31
+ ## 核心概念
32
+
33
+ ### 1. Cloud Brain
34
+
35
+ Cloud Brain 是远程服务,负责保存:
36
+
37
+ - 用户账号与 API Key
38
+ - 用户 `will`
39
+ - 订阅关系
40
+ - `vendor` 发布记录
41
+
42
+ ### 2. memory 项目
43
+
44
+ CLI 会把“存在 `memory/start.md` 的目录”识别为 memory 项目根目录。
45
+
46
+ 初始化后的关键目录通常包括:
47
+
48
+ ```text
49
+ your-project/
50
+ ├─ memory/
51
+ │ ├─ start.md
52
+ │ ├─ vendor/
53
+ │ └─ will/current/
54
+ └─ .memory/
55
+ └─ .project/
56
+ ├─ config/
57
+ ├─ cache/
58
+ ├─ global/
59
+ └─ skills/
60
+ ```
61
+
62
+ ### 3. 凭证文件
63
+
64
+ CLI 会把登录信息保存在本地:
65
+
66
+ - 默认路径:`~/.memory-cli/credentials.json`
67
+ - 可通过环境变量 `MEMORY_CREDENTIALS_DIR` 自定义目录
68
+
69
+ 凭证中只保存:
70
+
71
+ - `api_endpoint`
72
+ - `api_key`
73
+ - `user_id`
74
+ - `will_id`
75
+
76
+ ## 快速开始
77
+
78
+ ### 1. 注册或登录
79
+
80
+ 首次连接远程 Cloud Brain 时,建议显式传入 `--endpoint`:
81
+
82
+ ```bash
83
+ memory login register --endpoint=https://memory-brain.dev
84
+ memory login --endpoint=https://memory-brain.dev
85
+ ```
86
+
87
+ 注意:
88
+
89
+ - 登录和注册都要求使用邮箱格式账号
90
+ - 交互式提示现在会要求输入 `Email`
91
+ - 如果本地已经保存过 endpoint,后续可直接执行 `memory login`
92
+ - 如果没有显式指定且本地也没有保存 endpoint,CLI 会回退到 `http://localhost:3900`
93
+
94
+ ### 2. 初始化项目
95
+
96
+ 在你的项目根目录执行:
16
97
 
17
- # Check status
98
+ ```bash
99
+ memory init
100
+ ```
101
+
102
+ 它会执行这些动作:
103
+
104
+ - 从 Cloud Brain 下载最新 `vendor`
105
+ - 从模板或最小骨架初始化项目结构
106
+ - 从 Cloud Brain 拉取当前用户的 `will`
107
+
108
+ 如果当前目录已经是 memory 项目,CLI 会直接提示并退出,不会重复初始化。
109
+
110
+ ### 3. 查看当前状态
111
+
112
+ ```bash
18
113
  memory status
114
+ memory login status
115
+ memory version
116
+ ```
117
+
118
+ ## 登录与账号
119
+
120
+ ### 注册
121
+
122
+ ```bash
123
+ memory login register --endpoint=https://memory-brain.dev
124
+ ```
125
+
126
+ 交互式输入:
127
+
128
+ - `Email`
129
+ - `Password`
130
+ - `Display name (optional)`
131
+
132
+ 注册成功后,CLI 会把返回的:
133
+
134
+ - API Key
135
+ - 用户 ID
136
+ - 默认 `will` ID
137
+ - endpoint
138
+
139
+ 一起写入本地凭证。
140
+
141
+ ### 登录
142
+
143
+ ```bash
144
+ memory login --endpoint=<endpoint-url>
145
+ ```
146
+
147
+ 交互式输入:
148
+
149
+ - `Email`
150
+ - `Password`
151
+
152
+ ### 查看登录状态
153
+
154
+ ```bash
155
+ memory login status
156
+ ```
157
+
158
+ 会显示:
159
+
160
+ - 当前登录用户
161
+ - 默认 `will` ID
162
+ - 订阅者数量
163
+ - 当前使用的 Cloud Brain endpoint
164
+
165
+ ### 退出登录
166
+
167
+ ```bash
168
+ memory login logout
169
+ ```
170
+
171
+ 退出后会清空本地 `api_key`、`user_id`、`will_id`,但会保留已经保存的 `api_endpoint`。
172
+
173
+ ## 项目初始化与更新
174
+
175
+ ### 初始化项目
176
+
177
+ ```bash
178
+ memory init
179
+ ```
180
+
181
+ 前置条件:
182
+
183
+ - 已登录 Cloud Brain
184
+ - 当前目录还不是 memory 项目
185
+
186
+ ### 更新 `vendor`
187
+
188
+ ```bash
189
+ memory update
190
+ ```
191
+
192
+ 作用:
193
+
194
+ - 从 Cloud Brain 下载最新 `vendor`
195
+ - 写入当前项目的 `memory/vendor/`
196
+
197
+ 前置条件:
198
+
199
+ - 已登录
200
+ - 当前目录在 memory 项目内
201
+
202
+ ## `will` 命令
203
+
204
+ ### 发布当前项目的 will
205
+
206
+ ```bash
207
+ memory will publish
208
+ ```
209
+
210
+ 作用:
211
+
212
+ - 读取当前项目 `memory/will/current/`
213
+ - 上传到 Cloud Brain
214
+
215
+ ### 从 Cloud Brain 拉取自己的 will
216
+
217
+ ```bash
218
+ memory will pull
219
+ ```
220
+
221
+ ### 查看 will 状态
222
+
223
+ ```bash
224
+ memory will status
225
+ ```
226
+
227
+ 显示:
228
+
229
+ - 本地 `will` 目录是否存在
230
+ - 关键 will 文件数量
231
+ - 当前是否已连接云端
232
+
233
+ ### 查看云端版本历史
234
+
235
+ ```bash
236
+ memory will versions
237
+ ```
238
+
239
+ ### 设置可见性
240
+
241
+ ```bash
242
+ memory will visibility private
243
+ memory will visibility public
244
+ memory will visibility unlisted
245
+ ```
246
+
247
+ ### 订阅别人的 will
248
+
249
+ ```bash
250
+ memory will subscribe <will_id>
251
+ memory will subscribe <will_id> --dimensions=02,03
252
+ memory will subscribe <will_id> --dimensions 02,03
253
+ ```
254
+
255
+ ### 查看我的订阅
256
+
257
+ ```bash
258
+ memory will subscriptions
259
+ ```
260
+
261
+ ### 查看谁订阅了我
19
262
 
20
- # Sync will
21
- memory will push # project → global
22
- memory will pull # global → project
263
+ ```bash
264
+ memory will subscribers
265
+ ```
266
+
267
+ ### 取消订阅
268
+
269
+ ```bash
270
+ memory will unsubscribe <will_id>
271
+ ```
272
+
273
+ ### 拉取订阅内容
274
+
275
+ ```bash
276
+ memory will sub-pull <will_id>
277
+ ```
278
+
279
+ 拉取结果会写入:
280
+
281
+ ```text
282
+ .memory/.project/subscriptions/<will_id>/
283
+ ```
284
+
285
+ 其中包含:
286
+
287
+ - 订阅到的文件
288
+ - `manifest.json`
23
289
 
24
- # Update vendor
25
- memory update # global → current project
26
- memory update --cloud # Cloud Brain → global → project
27
- memory update --cloud --all # → all registered projects
290
+ ### 兼容别名
28
291
 
29
- # Cloud Brain
30
- memory login
292
+ 下面两个旧命令仍然兼容:
293
+
294
+ ```bash
295
+ memory will cloud-push
296
+ memory will cloud-pull
297
+ ```
298
+
299
+ 它们分别等价于:
300
+
301
+ ```bash
302
+ memory will publish
303
+ memory will pull
304
+ ```
305
+
306
+ ## `vendor` 命令
307
+
308
+ ### 发布当前项目的 vendor
309
+
310
+ ```bash
31
311
  memory vendor publish --version=1.0.0
312
+ ```
313
+
314
+ 说明:
315
+
316
+ - 从当前项目的 `memory/vendor/` 收集文件
317
+ - 上传到 Cloud Brain
318
+ - 需要已登录
319
+ - 远端接口要求管理员权限
320
+
321
+ 如果未传 `--version`,CLI 会尝试读取:
322
+
323
+ ```text
324
+ memory/vendor/version.json
325
+ ```
326
+
327
+ ### 查看最新发布版本
328
+
329
+ ```bash
330
+ memory vendor latest
331
+ ```
332
+
333
+ ### 查看发布历史
334
+
335
+ ```bash
336
+ memory vendor changelog
337
+ ```
338
+
339
+ ### 下载 `vendor`
340
+
341
+ 下载最新版本:
342
+
343
+ ```bash
32
344
  memory vendor download
33
345
  ```
34
346
 
35
- ## Commands
347
+ 下载指定版本:
348
+
349
+ ```bash
350
+ memory vendor download --version=1.0.0
351
+ ```
352
+
353
+ ## `skill` 命令
354
+
355
+ ### 列出可见 skill
356
+
357
+ ```bash
358
+ memory skill list
359
+ ```
360
+
361
+ 会列出两类:
362
+
363
+ - `memory/vendor/skills` 下的系统 skill
364
+ - `.memory/.project/skills` 下的项目 skill
365
+
366
+ ### 卸载项目 skill
367
+
368
+ ```bash
369
+ memory skill uninstall <skill-name>
370
+ ```
371
+
372
+ 只会删除项目级 skill,不会改动 `vendor` 内置 skill。
373
+
374
+ ## `cache` 命令
375
+
376
+ ### 查看缓存状态
377
+
378
+ ```bash
379
+ memory cache status
380
+ ```
381
+
382
+ 会统计 `.memory/.project/cache/` 下各缓存目录的:
383
+
384
+ - 文件数量
385
+ - 占用空间
386
+
387
+ ### 清理旧缓存
388
+
389
+ 默认清理 30 天前的条目:
390
+
391
+ ```bash
392
+ memory cache clean
393
+ ```
394
+
395
+ 指定保留时间:
396
+
397
+ ```bash
398
+ memory cache clean --older-than=7
399
+ memory cache clean --older-than=30
400
+ ```
401
+
402
+ 当前实现会按“天数”解析这个值。
403
+
404
+ ## `status` 与 `version`
405
+
406
+ ### 查看整体状态
407
+
408
+ ```bash
409
+ memory status
410
+ ```
411
+
412
+ 会显示:
413
+
414
+ - 当前 Cloud Brain 是否已配置
415
+ - 当前用户 ID
416
+ - 当前是否位于 memory 项目内
417
+ - 项目中的 `vendor` / `will` 是否存在
418
+
419
+ ### 查看 CLI 与 vendor 版本
420
+
421
+ ```bash
422
+ memory version
423
+ ```
424
+
425
+ 会显示:
426
+
427
+ - CLI 版本号
428
+ - 当前项目内 `vendor/version.json` 中的版本信息
429
+
430
+ ## 命令速查
431
+
432
+ | 命令 | 说明 |
433
+ | --- | --- |
434
+ | `memory init` | 初始化当前项目的 memory 结构 |
435
+ | `memory login` | 登录 Cloud Brain |
436
+ | `memory login register` | 注册新账号 |
437
+ | `memory login status` | 查看登录状态 |
438
+ | `memory login logout` | 清空登录态 |
439
+ | `memory update` | 下载最新 `vendor` 到当前项目 |
440
+ | `memory will publish` | 发布当前项目的 `will` |
441
+ | `memory will pull` | 从云端拉取自己的 `will` |
442
+ | `memory will status` | 查看本地 `will` 状态 |
443
+ | `memory will versions` | 查看云端 `will` 版本历史 |
444
+ | `memory will visibility <v>` | 设置 `will` 可见性 |
445
+ | `memory will subscribe <id>` | 订阅他人的 `will` |
446
+ | `memory will unsubscribe <id>` | 取消订阅 |
447
+ | `memory will subscriptions` | 查看我的订阅 |
448
+ | `memory will subscribers` | 查看谁订阅了我 |
449
+ | `memory will sub-pull <id>` | 拉取订阅内容 |
450
+ | `memory vendor publish --version=x.y.z` | 发布当前项目的 `vendor` |
451
+ | `memory vendor latest` | 查看云端最新 `vendor` |
452
+ | `memory vendor changelog` | 查看发布历史 |
453
+ | `memory vendor download [--version=x.y.z]` | 下载 `vendor` |
454
+ | `memory skill list` | 查看系统和项目 `skill` |
455
+ | `memory skill uninstall <name>` | 删除项目级 `skill` |
456
+ | `memory cache status` | 查看缓存状态 |
457
+ | `memory cache clean [--older-than=N]` | 清理旧缓存 |
458
+ | `memory status` | 查看整体状态 |
459
+ | `memory version` | 查看 CLI 与当前项目 vendor 版本 |
460
+
461
+ ## 常见问题
462
+
463
+ ### 1. `Not logged in. Run "memory login" first.`
464
+
465
+ 说明当前本地没有有效的 `api_key` 或 `api_endpoint`。
466
+
467
+ 先执行:
468
+
469
+ ```bash
470
+ memory login --endpoint=https://your-cloud-brain.example.com
471
+ ```
472
+
473
+ ### 2. `Not in a memory project. Run "memory init" first.`
474
+
475
+ 说明当前目录及其父目录中都没有:
476
+
477
+ ```text
478
+ memory/start.md
479
+ ```
480
+
481
+ 请切到正确项目目录,或先执行:
482
+
483
+ ```bash
484
+ memory init
485
+ ```
486
+
487
+ ### 3. 登录时报 `ENOTFOUND`
488
+
489
+ 这通常不是 CLI 逻辑问题,而是当前机器 DNS 无法解析你的 Cloud Brain 域名。
490
+
491
+ 可以优先检查:
492
+
493
+ ```bash
494
+ nslookup your-domain.example.com
495
+ ```
496
+
497
+ ### 4. 为什么第一次登录建议带 `--endpoint`
36
498
 
37
- | Command | Description |
38
- |---------|-------------|
39
- | `init --global` | Initialize global memory layer |
40
- | `login` | Authenticate with Cloud Brain |
41
- | `status` | Show current project memory status |
42
- | `will <push\|pull\|sync\|broadcast>` | Will synchronization |
43
- | `will <cloud-push\|cloud-pull>` | Cloud will sync |
44
- | `update [--cloud] [--all]` | Vendor distribution |
45
- | `vendor <publish\|latest\|changelog\|download>` | Cloud vendor management |
46
- | `skill <list\|promote\|demote>` | Skill layer management |
47
- | `cache <status\|clean>` | Cache management |
48
- | `projects` | List registered projects |
49
- | `version` | Show version info |
499
+ 因为首次登录前,本地还没有保存 Cloud Brain 地址。显式传入 `--endpoint` 可以确保登录请求直接打到正确的远端服务。
50
500
 
51
- ## Requirements
501
+ ## 版本信息
52
502
 
53
- - Node.js >= 18
54
- - No external dependencies
503
+ - 当前包版本见 [package.json](./package.json)
504
+ - 当前实现基于 `memory/cli/commands/` 下实际命令行为编写
package/commands/init.mjs CHANGED
@@ -128,7 +128,6 @@ function bootstrapFromTemplates(root, templatesDir) {
128
128
  const agentEntryMap = {
129
129
  'CLAUDE.md': join(root, 'CLAUDE.md'),
130
130
  'AGENTS.md': join(root, 'AGENTS.md'),
131
- 'Agent.md': join(root, 'Agent.md'),
132
131
  '.cursorrules': join(root, '.cursorrules'),
133
132
  };
134
133
  for (const [tplName, destPath] of Object.entries(agentEntryMap)) {
@@ -26,7 +26,7 @@ export default async function login(args) {
26
26
  async function handleLogin(args) {
27
27
  const endpoint = args.find((a) => a.startsWith('--endpoint='))?.split('=')[1];
28
28
 
29
- const username = await prompt('Username: ');
29
+ const username = await prompt('Email: ');
30
30
  const password = await prompt('Password: ');
31
31
 
32
32
  try {
@@ -43,7 +43,7 @@ async function handleLogin(args) {
43
43
  async function handleRegister(args) {
44
44
  const endpoint = args.find((a) => a.startsWith('--endpoint='))?.split('=')[1];
45
45
 
46
- const username = await prompt('Username: ');
46
+ const username = await prompt('Email: ');
47
47
  const password = await prompt('Password: ');
48
48
  const displayName = await prompt('Display name (optional): ');
49
49
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superpms/memory-cli",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "CLI for memory system — global layer, will sync, vendor updates",
5
5
  "type": "module",
6
6
  "bin": {