dev-memory-cli 0.23.1 → 0.24.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/README.md +27 -32
- package/bin/dev-memory.js +117 -0
- package/lib/dev_memory_session_scan.py +3 -1
- package/lib/maintenance/archive.md +83 -0
- package/lib/maintenance/tidy.md +102 -0
- package/package.json +2 -1
- package/scripts/hooks/_common.py +4 -5
- package/suite-manifest.json +4 -4
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Dev Memory Skill Suite 为 Codex、Claude 等 coding agent 提供跨会话开发
|
|
|
9
9
|
## 核心能力
|
|
10
10
|
|
|
11
11
|
- **会话恢复**:`SessionStart` 自动注入当前 repo + branch 的浓缩记忆和权威文件路径。
|
|
12
|
-
-
|
|
12
|
+
- **后台语义沉淀**:定期读取完整会话,对照已有记忆后执行 append、rewrite、delete 或明确 skip。
|
|
13
13
|
- **纠错优先**:修正旧记忆时定位并改写原 entry,避免同时保留互相冲突的新旧结论。
|
|
14
14
|
- **分支隔离**:同一仓库的不同分支拥有独立工作记忆,可 fork、rename、reset 或归档。
|
|
15
15
|
- **跨分支共享**:稳定规则进入 repo 层;候选知识可在分支完成时提炼上提。
|
|
@@ -17,17 +17,13 @@ Dev Memory Skill Suite 为 Codex、Claude 等 coding agent 提供跨会话开发
|
|
|
17
17
|
- **多仓库工作区**:一个 workspace 下可同时加载多个 repo,并为主仓库保留更完整的上下文。
|
|
18
18
|
- **本地管理面板**:浏览、编辑已存储记忆,预览 SessionStart 注入文本,并查看会话扫描与 token 用量。
|
|
19
19
|
|
|
20
|
-
##
|
|
20
|
+
## 一个常驻 Skill
|
|
21
21
|
|
|
22
22
|
| Skill | 职责 | 适用场景 |
|
|
23
23
|
| --- | --- | --- |
|
|
24
24
|
| `dev-memory-read` | 定位并搜索当前 repo/branch 的权威记忆,只读不写 | 主动恢复既有记忆、查询历史 TODO |
|
|
25
|
-
| `dev-memory-capture` | 写入、改写或删除记忆;同步 Git 派生索引 | 稳定结论沉淀、纠错、阶段 checkpoint |
|
|
26
|
-
| `dev-memory-setup` | 把 `unsorted.md` 中的内容分类合并到结构化文件 | 未分类内容整理、记忆结构初始化 |
|
|
27
|
-
| `dev-memory-tidy` | 批量审查陈旧、重复、错误或模板残留条目,备份后应用 | 结构化记忆校准与清理 |
|
|
28
|
-
| `dev-memory-graduate` | 提炼跨分支知识并归档已完成分支 | 分支收尾与归档 |
|
|
29
25
|
|
|
30
|
-
Skill
|
|
26
|
+
普通开发会话不再常驻 capture/setup/tidy/graduate Skill。会话写入由 session-scan 后台处理;整理和归档由 CLI 临时启动专用维护 Agent,并只把对应维护 prompt 放进那个独立会话。
|
|
31
27
|
|
|
32
28
|
## 安装
|
|
33
29
|
|
|
@@ -44,13 +40,13 @@ npx skills add xluos/dev-memory-skill-suite --list
|
|
|
44
40
|
安装到 Codex 全局:
|
|
45
41
|
|
|
46
42
|
```bash
|
|
47
|
-
npx skills add xluos/dev-memory-skill-suite --skill
|
|
43
|
+
npx skills add xluos/dev-memory-skill-suite --skill dev-memory-read -a codex -g -y
|
|
48
44
|
```
|
|
49
45
|
|
|
50
46
|
安装到检测到的所有 agent:
|
|
51
47
|
|
|
52
48
|
```bash
|
|
53
|
-
npx skills add xluos/dev-memory-skill-suite --all -g -y
|
|
49
|
+
npx skills add xluos/dev-memory-skill-suite --skill dev-memory-read --all -g -y
|
|
54
50
|
```
|
|
55
51
|
|
|
56
52
|
### 安装 CLI 与 Hook
|
|
@@ -85,27 +81,23 @@ dev-memory-cli session-scan status
|
|
|
85
81
|
|
|
86
82
|
## 基本使用
|
|
87
83
|
|
|
88
|
-
|
|
84
|
+
记忆是显式 opt-in。首次使用先初始化,然后由生命周期 hook 恢复、由定期 session-scan 沉淀新会话语义。
|
|
89
85
|
|
|
90
86
|
```bash
|
|
87
|
+
# 为当前 repo + branch 初始化记忆骨架
|
|
88
|
+
dev-memory-cli init
|
|
89
|
+
|
|
91
90
|
# 查看当前仓库和分支对应的记忆路径
|
|
92
91
|
dev-memory-cli read show
|
|
93
92
|
|
|
94
93
|
# 只在当前 repo 的记忆范围内搜索
|
|
95
94
|
dev-memory-cli read search --query "发布流程" --query "回滚"
|
|
96
95
|
|
|
97
|
-
#
|
|
98
|
-
dev-memory-cli
|
|
99
|
-
--kind decision \
|
|
100
|
-
--content "发布前必须先跑完整打包检查"
|
|
101
|
-
|
|
102
|
-
# 写入一条跨分支规则
|
|
103
|
-
dev-memory-cli capture record \
|
|
104
|
-
--kind shared-decision \
|
|
105
|
-
--content "Python 测试优先使用项目虚拟环境"
|
|
96
|
+
# 启动独立整理 Agent(不会把整理 prompt 放进普通开发会话)
|
|
97
|
+
dev-memory-cli maintain tidy
|
|
106
98
|
|
|
107
|
-
#
|
|
108
|
-
dev-memory-cli
|
|
99
|
+
# 启动独立归档 Agent
|
|
100
|
+
dev-memory-cli maintain archive --branch feature/example
|
|
109
101
|
```
|
|
110
102
|
|
|
111
103
|
`read search` 默认搜索当前 branch + repo 共享层。跨分支和归档范围通过 `--scope` 显式指定:
|
|
@@ -115,11 +107,11 @@ dev-memory-cli read search --scope all-branches --query "关键词"
|
|
|
115
107
|
dev-memory-cli read search --scope archived --query "关键词"
|
|
116
108
|
```
|
|
117
109
|
|
|
118
|
-
###
|
|
110
|
+
### 底层写入路由
|
|
119
111
|
|
|
120
112
|

|
|
121
113
|
|
|
122
|
-
`capture record` 支持三种输入方式:
|
|
114
|
+
`capture` 是 session-scan 和维护 Agent 使用的底层写入引擎,同时保留为高级管理 CLI;它不再对应常驻 Skill。`capture record` 支持三种输入方式:
|
|
123
115
|
|
|
124
116
|
- **显式 kind**:调用方明确指定内容语义,直接写目标 section。
|
|
125
117
|
- **自动分类**:`--auto` 根据文本信号判断 decision、risk、glossary;无法明确分类时进入 `unsorted.md`。
|
|
@@ -150,19 +142,18 @@ dev-memory-cli capture rewrite-entry --id <entry-id> --content "修正后的完
|
|
|
150
142
|
dev-memory-cli capture delete-entry --id <entry-id>
|
|
151
143
|
```
|
|
152
144
|
|
|
153
|
-
符合跨分支复用判定的内容会同时进入 `pending-promotion.md
|
|
145
|
+
符合跨分支复用判定的内容会同时进入 `pending-promotion.md`,由归档维护 Agent 在分支收尾阶段审核;候选内容不会直接写入 repo 共享层。
|
|
154
146
|
|
|
155
147
|
### 整理与归档
|
|
156
148
|
|
|
157
|
-
|
|
149
|
+
普通入口只有两个,都会启动独立交互式 Agent:
|
|
158
150
|
|
|
159
|
-
|
|
|
151
|
+
| 命令 | 处理对象 | 结果 |
|
|
160
152
|
| --- | --- | --- |
|
|
161
|
-
| `
|
|
162
|
-
| `
|
|
163
|
-
| `graduate` | 已完成分支的有效记忆 | 上提跨分支知识,并把分支目录移入 `_archived` |
|
|
153
|
+
| `dev-memory-cli maintain tidy` | `unsorted.md` 与已结构化但漂移的内容 | 分类、proposal HTML 审核、备份后 edit/delete/reset |
|
|
154
|
+
| `dev-memory-cli maintain archive` | 已完成分支的有效记忆 | dry-run、上提跨分支知识、确认后移入 `_archived` |
|
|
164
155
|
|
|
165
|
-
`tidy apply` 和 `graduate apply`
|
|
156
|
+
维护 Agent 内部使用 `setup`、`tidy`、`graduate` 等低层子命令。`tidy apply` 和 `graduate apply` 会改变或移动已有记忆,仍然受人工审核和显式确认门禁保护。用 `--print-prompt` 可以只查看将传给独立 Agent 的完整维护指令。
|
|
166
157
|
|
|
167
158
|
### 分支记忆操作
|
|
168
159
|
|
|
@@ -251,7 +242,7 @@ dev-memory-cli workspace show
|
|
|
251
242
|
dev-memory-cli workspace primary <repo-basename>
|
|
252
243
|
```
|
|
253
244
|
|
|
254
|
-
`DEV_MEMORY_PRIMARY_REPO` 可作为临时 override
|
|
245
|
+
`DEV_MEMORY_PRIMARY_REPO` 可作为临时 override。维护命令在 workspace 中应使用 `--repo <repo-path-or-basename>` 明确目标仓库。
|
|
255
246
|
|
|
256
247
|
## 存储结构
|
|
257
248
|
|
|
@@ -327,6 +318,9 @@ dev-memory-cli context injection-preview \
|
|
|
327
318
|
|
|
328
319
|
```text
|
|
329
320
|
dev-memory-cli read <show|search>
|
|
321
|
+
dev-memory-cli init [--repo PATH] [--branch NAME]
|
|
322
|
+
dev-memory-cli maintain <tidy|archive> [--repo PATH] [--branch NAME] [--executor auto|codex|coco]
|
|
323
|
+
# low-level mutation/admin commands:
|
|
330
324
|
dev-memory-cli capture <show|suggest-kind|classify|record|list-entries|find-candidates|rewrite-entry|delete-entry|apply-summary-output|sync-working-tree|record-head>
|
|
331
325
|
dev-memory-cli setup <init|merge-unsorted|mark-completed>
|
|
332
326
|
dev-memory-cli tidy <prepare|apply>
|
|
@@ -360,11 +354,12 @@ dev-memory 的能力边界不包括:
|
|
|
360
354
|
```text
|
|
361
355
|
bin/dev-memory.js # CLI 入口与 Node 侧命令
|
|
362
356
|
lib/dev_memory_*.py # 记忆、分支、会话扫描、整理与归档实现
|
|
357
|
+
lib/maintenance/ # 按需注入独立维护 Agent 的 prompt
|
|
363
358
|
lib/ui-server.js # 本地管理面板服务
|
|
364
359
|
lib/ui-app.html # 管理面板前端
|
|
365
360
|
scripts/hooks/ # 生命周期 hook 实现
|
|
366
361
|
hooks/ # Codex / Claude hook 模板
|
|
367
|
-
skills/
|
|
362
|
+
skills/dev-memory-read/ # 唯一常驻 Skill
|
|
368
363
|
tests/ # Python 测试
|
|
369
364
|
docs/diagrams/ # README 图表及源文件
|
|
370
365
|
```
|
package/bin/dev-memory.js
CHANGED
|
@@ -376,6 +376,112 @@ function commandPySubcommand(name, rawArgs) {
|
|
|
376
376
|
runPython(scriptPath, rawArgs);
|
|
377
377
|
}
|
|
378
378
|
|
|
379
|
+
const MAINTENANCE_MODES = new Set(["tidy", "archive"]);
|
|
380
|
+
const MAINTENANCE_MARKER = "DEV_MEMORY_INTERNAL_MAINTENANCE_AGENT_V1";
|
|
381
|
+
|
|
382
|
+
function maintenanceHelp() {
|
|
383
|
+
process.stdout.write(`Usage:
|
|
384
|
+
dev-memory-cli maintain tidy [--repo PATH] [--branch NAME] [--scope branch|branch+repo]
|
|
385
|
+
[--executor auto|codex|coco] [--model MODEL]
|
|
386
|
+
dev-memory-cli maintain archive [--repo PATH] [--branch NAME]
|
|
387
|
+
[--executor auto|codex|coco] [--model MODEL]
|
|
388
|
+
dev-memory-cli maintain <tidy|archive> --print-prompt [other options]
|
|
389
|
+
|
|
390
|
+
The command starts a dedicated interactive maintenance-agent session. Tidy
|
|
391
|
+
must not apply destructive changes before HTML review; archive must not apply
|
|
392
|
+
before dry-run review and explicit confirmation.
|
|
393
|
+
`);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
function resolveMaintenanceExecutor(requested) {
|
|
397
|
+
const name = requested || process.env.DEV_MEMORY_MAINTENANCE_EXECUTOR || "auto";
|
|
398
|
+
if (!new Set(["auto", "codex", "coco"]).has(name)) {
|
|
399
|
+
fail(`unsupported maintenance executor: ${name}`);
|
|
400
|
+
}
|
|
401
|
+
if (name !== "auto") return name;
|
|
402
|
+
for (const candidate of ["codex", "coco"]) {
|
|
403
|
+
if (commandExists(candidate)) return candidate;
|
|
404
|
+
}
|
|
405
|
+
fail("no maintenance executor found; install codex/coco or use --print-prompt");
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
function buildMaintenancePrompt(mode, options, repoRoot) {
|
|
409
|
+
const promptPath = packageScript("lib", "maintenance", `${mode}.md`);
|
|
410
|
+
if (!fs.existsSync(promptPath)) fail(`missing maintenance prompt: ${promptPath}`);
|
|
411
|
+
const workflow = fs.readFileSync(promptPath, "utf8").trim();
|
|
412
|
+
const cliPath = path.resolve(process.argv[1]);
|
|
413
|
+
const branch = options.branch || "<current-git-branch>";
|
|
414
|
+
const scope = mode === "tidy" ? (options.scope || "branch") : "branch";
|
|
415
|
+
return `${MAINTENANCE_MARKER}
|
|
416
|
+
|
|
417
|
+
你是 dev-memory 的专用维护 Agent。本会话只处理下面指定仓库的记忆维护,不承担普通开发任务。
|
|
418
|
+
|
|
419
|
+
目标仓库:${repoRoot}
|
|
420
|
+
目标分支:${branch}
|
|
421
|
+
维护模式:${mode}
|
|
422
|
+
整理范围:${scope}
|
|
423
|
+
本次必须使用的 CLI:node ${JSON.stringify(cliPath)}
|
|
424
|
+
|
|
425
|
+
不要依赖全局 dev-memory capture/setup/tidy/graduate Skill;完整维护流程已经随本提示提供。
|
|
426
|
+
涉及删除、改写或归档时,必须遵守下面流程中的人工审核和确认门禁。
|
|
427
|
+
|
|
428
|
+
${workflow}
|
|
429
|
+
`;
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
function commandMaintain(rawArgs) {
|
|
433
|
+
const mode = rawArgs[0];
|
|
434
|
+
if (!mode || mode === "--help" || mode === "-h") {
|
|
435
|
+
maintenanceHelp();
|
|
436
|
+
return;
|
|
437
|
+
}
|
|
438
|
+
if (!MAINTENANCE_MODES.has(mode)) {
|
|
439
|
+
fail(`unknown maintenance mode: ${mode}`);
|
|
440
|
+
}
|
|
441
|
+
const { positional, options } = parseArgs(rawArgs.slice(1));
|
|
442
|
+
if (positional.length) fail(`unexpected maintenance argument: ${positional[0]}`);
|
|
443
|
+
const repoRoot = path.resolve(options.repo || process.cwd());
|
|
444
|
+
if (!fs.existsSync(repoRoot) || !fs.statSync(repoRoot).isDirectory()) {
|
|
445
|
+
fail(`maintenance repo does not exist: ${repoRoot}`);
|
|
446
|
+
}
|
|
447
|
+
if (mode === "tidy" && options.scope && !new Set(["branch", "branch+repo"]).has(options.scope)) {
|
|
448
|
+
fail(`unsupported tidy scope: ${options.scope}`);
|
|
449
|
+
}
|
|
450
|
+
const prompt = buildMaintenancePrompt(mode, options, repoRoot);
|
|
451
|
+
if (options["print-prompt"] || options["dry-run"]) {
|
|
452
|
+
process.stdout.write(prompt);
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
const executor = resolveMaintenanceExecutor(options.executor);
|
|
457
|
+
let args;
|
|
458
|
+
if (executor === "codex") {
|
|
459
|
+
const modelArgs = options.model ? ["--model", String(options.model)] : [];
|
|
460
|
+
args = [
|
|
461
|
+
"-C", repoRoot,
|
|
462
|
+
"--sandbox", "danger-full-access",
|
|
463
|
+
"--ask-for-approval", "on-request",
|
|
464
|
+
"--dangerously-bypass-hook-trust",
|
|
465
|
+
...modelArgs,
|
|
466
|
+
prompt,
|
|
467
|
+
];
|
|
468
|
+
} else {
|
|
469
|
+
const modelArgs = options.model ? ["--config", `model=${String(options.model)}`] : [];
|
|
470
|
+
args = ["--permission-mode", "default", ...modelArgs, prompt];
|
|
471
|
+
}
|
|
472
|
+
const result = spawnSync(executor, args, {
|
|
473
|
+
cwd: repoRoot,
|
|
474
|
+
env: {
|
|
475
|
+
...process.env,
|
|
476
|
+
DEV_MEMORY_MAINTENANCE_AGENT: "1",
|
|
477
|
+
DEV_MEMORY_MAINTENANCE_MODE: mode,
|
|
478
|
+
},
|
|
479
|
+
stdio: "inherit",
|
|
480
|
+
});
|
|
481
|
+
if (result.error) fail(`unable to start ${executor}: ${result.error.message}`);
|
|
482
|
+
if (result.status !== 0) process.exit(result.status || 1);
|
|
483
|
+
}
|
|
484
|
+
|
|
379
485
|
function branchScript() {
|
|
380
486
|
return packageScript("lib", "dev_memory_branch.py");
|
|
381
487
|
}
|
|
@@ -692,8 +798,11 @@ function printHelp() {
|
|
|
692
798
|
dev-memory-cli install-hooks --all [--repo PATH] [--global]
|
|
693
799
|
dev-memory-cli ui [--port N] [--host HOST] [--no-open] [--read-only]
|
|
694
800
|
dev-memory-cli workspace <show|primary> [...]
|
|
801
|
+
dev-memory-cli init [--repo PATH] [--branch NAME]
|
|
695
802
|
dev-memory-cli read <show|search> [...]
|
|
803
|
+
dev-memory-cli maintain <tidy|archive> [...] # starts a dedicated interactive agent
|
|
696
804
|
dev-memory-cli context <show|...> [...]
|
|
805
|
+
# Low-level mutation/admin commands used by session-scan and maintenance agents:
|
|
697
806
|
dev-memory-cli capture <record|show|sync-working-tree|record-head|suggest-kind|classify> [...]
|
|
698
807
|
dev-memory-cli setup <init|merge-unsorted|mark-completed> [...]
|
|
699
808
|
dev-memory-cli graduate <dry-run|apply|index> [...]
|
|
@@ -719,6 +828,14 @@ function main() {
|
|
|
719
828
|
commandPySubcommand(command, argv.slice(1));
|
|
720
829
|
return;
|
|
721
830
|
}
|
|
831
|
+
if (command === "init") {
|
|
832
|
+
commandPySubcommand("setup", ["init", ...argv.slice(1)]);
|
|
833
|
+
return;
|
|
834
|
+
}
|
|
835
|
+
if (command === "maintain") {
|
|
836
|
+
commandMaintain(argv.slice(1));
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
722
839
|
if (command === "branch") {
|
|
723
840
|
commandBranch(argv.slice(1));
|
|
724
841
|
return;
|
|
@@ -29,6 +29,8 @@ PLIST_PATH = Path(os.environ.get(
|
|
|
29
29
|
"~/Library/LaunchAgents/com.dev-memory.session-scan.plist",
|
|
30
30
|
)).expanduser()
|
|
31
31
|
INTERNAL_MARKER = "DEV_MEMORY_INTERNAL_SESSION_SUMMARY_V1"
|
|
32
|
+
MAINTENANCE_MARKER = "DEV_MEMORY_INTERNAL_MAINTENANCE_AGENT_V1"
|
|
33
|
+
INTERNAL_MARKERS = (INTERNAL_MARKER, MAINTENANCE_MARKER)
|
|
32
34
|
SUMMARY_MUTATION_FIELDS = (
|
|
33
35
|
"file_map",
|
|
34
36
|
"decisions",
|
|
@@ -360,7 +362,7 @@ def parse_codex_session(path, since_offset=0):
|
|
|
360
362
|
if usage:
|
|
361
363
|
total_usage = usage
|
|
362
364
|
message = _semantic_message(obj)
|
|
363
|
-
if message and
|
|
365
|
+
if message and any(marker in message["text"] for marker in INTERNAL_MARKERS):
|
|
364
366
|
internal_marker = True
|
|
365
367
|
if message and end > since_offset:
|
|
366
368
|
message.update({"start_offset": start, "end_offset": end})
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# 分支记忆归档维护流程
|
|
2
|
+
|
|
3
|
+
目标是把已完成分支中真正跨分支复用的知识提炼到 repo 共享层,然后归档该分支的记忆目录。归档是破坏性显式动作,必须由用户确认。
|
|
4
|
+
|
|
5
|
+
## 硬规则
|
|
6
|
+
|
|
7
|
+
- 始终只处理提示中指定的 repo + branch。
|
|
8
|
+
- 所有命令都使用提示中给出的 CLI 路径,并显式传 `--repo`、必要时传 `--branch`。
|
|
9
|
+
- 禁止跳过 dry-run 直接 apply。
|
|
10
|
+
- 当前分支存在未提交改动、领先默认基线且尚未 merge,或仍在开发时,不得擅自归档;先向用户说明并确认。
|
|
11
|
+
- pending-promotion 只是候选,不是必选。业务专用事实不得上提到 repo 共享层。
|
|
12
|
+
- 上提决策必须保留 Why 与影响范围,并改写成脱离当前分支名称仍可理解的最终事实。
|
|
13
|
+
|
|
14
|
+
## 第一阶段:pre-flight
|
|
15
|
+
|
|
16
|
+
运行:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
<CLI> graduate dry-run --repo <REPO> [--branch <BRANCH>]
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
检查并向用户报告:
|
|
23
|
+
|
|
24
|
+
- `git_status.ahead`
|
|
25
|
+
- `git_status.uncommitted`
|
|
26
|
+
- 默认基线与当前分支
|
|
27
|
+
- `archive_destination`
|
|
28
|
+
- 主审核面 `primary_sources.pending-promotion.md`
|
|
29
|
+
- 主审核面 `primary_sources.decisions.md`
|
|
30
|
+
- 其他 `cross_check_sources` 中可能遗漏的跨分支经验
|
|
31
|
+
|
|
32
|
+
若 pre-flight 暴露未 merge 或未提交状态,停止在确认点,不要继续生成 apply。
|
|
33
|
+
|
|
34
|
+
## 第二阶段:生成 harvest 草案
|
|
35
|
+
|
|
36
|
+
只提炼真正跨分支稳定成立的内容,生成:
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"repo_overview": [
|
|
41
|
+
{"section": "长期目标与边界", "body": "...", "mode": "append"}
|
|
42
|
+
],
|
|
43
|
+
"repo_decisions": [
|
|
44
|
+
{"section": "跨分支通用决策", "body": "...", "mode": "append"}
|
|
45
|
+
],
|
|
46
|
+
"repo_glossary": [
|
|
47
|
+
{"section": "长期有效背景", "body": "...", "mode": "append"},
|
|
48
|
+
{"section": "共享入口", "body": "...", "mode": "append"}
|
|
49
|
+
],
|
|
50
|
+
"notes": "从目标分支提炼",
|
|
51
|
+
"archive": true
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
提炼时:
|
|
56
|
+
|
|
57
|
+
- 去掉当前需求名、临时人员分工、一次性状态和提交流水。
|
|
58
|
+
- 保留通用约束、反直觉风险、长期资料入口和可复用流程。
|
|
59
|
+
- 对照现有 repo 共享记忆去重;旧共享结论失效时应改成最终口径,不能制造两条冲突规则。
|
|
60
|
+
- 默认 `mode=append`,除非已经确认需要更新已有 section。
|
|
61
|
+
|
|
62
|
+
把 harvest 草案完整展示给用户,包括“会上提什么”和“只归档、不做上提什么”。获得明确确认之前禁止 apply。
|
|
63
|
+
|
|
64
|
+
## 第三阶段:apply
|
|
65
|
+
|
|
66
|
+
用户确认草案与归档目标后运行:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
<CLI> graduate apply --repo <REPO> [--branch <BRANCH>] --harvest-file <HARVEST>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
apply 会串行写入 repo 共享层,生成 `archive_summary.md`,并把分支目录移动到 `branches/_archived/<branch>__<date>/`,同时更新 `_archived/INDEX.md`。
|
|
73
|
+
|
|
74
|
+
## 第四阶段:复核
|
|
75
|
+
|
|
76
|
+
完成后必须:
|
|
77
|
+
|
|
78
|
+
1. 读取 `archive_summary.md`。
|
|
79
|
+
2. 运行 `<CLI> graduate index --repo <REPO>` 确认归档索引存在。
|
|
80
|
+
3. 检查原 branch_dir 已移动、archive destination 存在。
|
|
81
|
+
4. 汇总实际上提条目、归档路径和任何跳过项。
|
|
82
|
+
|
|
83
|
+
如果 apply 报 branch 不存在、schema 漂移或并发归档冲突,停止并报告真实错误;不得强行移动目录或手写 INDEX 绕过 CLI。
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
# 记忆整理维护流程
|
|
2
|
+
|
|
3
|
+
目标是把未分类内容归位,并校准已经结构化但陈旧、重复、错误或残留模板的记忆。整理是显式维护任务,不在普通开发会话中自动触发。
|
|
4
|
+
|
|
5
|
+
## 硬规则
|
|
6
|
+
|
|
7
|
+
- 始终只处理提示中指定的单个 repo + branch。
|
|
8
|
+
- 所有命令都使用提示中给出的 CLI 路径,并显式传 `--repo`、必要时传 `--branch`。
|
|
9
|
+
- 未分类内容可以在用户确认分类后 merge;结构化内容的删除和改写必须先生成 HTML review,由用户审核并导出 plan,禁止直接 apply。
|
|
10
|
+
- 不复制 PRD、聊天流水或 Git 历史;只保留下次开发仍有价值的决策、风险、术语、约束、入口与文件导航。
|
|
11
|
+
- `progress.md` 的 `AUTO-GENERATED` 块不得删除或改写。
|
|
12
|
+
|
|
13
|
+
## 第一阶段:处理 unsorted
|
|
14
|
+
|
|
15
|
+
先运行:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
<CLI> setup init --repo <REPO> [--branch <BRANCH>]
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
如果 `unsorted_entries` 非空:
|
|
22
|
+
|
|
23
|
+
1. 把相关条目聚合后给出高置信度分类建议。
|
|
24
|
+
2. 可选 kind:`decision`、`risk`、`glossary`、`source`、`shared-decision`、`shared-context`、`shared-source`、`skip`。
|
|
25
|
+
3. 让用户确认或修正分类;未确认前不要 merge。
|
|
26
|
+
4. 生成 `classifications` plan,并运行 `setup merge-unsorted --plan-file ...`。
|
|
27
|
+
|
|
28
|
+
如果 unsorted 为空,不需要为了修改 `setup_completed` 制造额外步骤;继续结构化整理即可。
|
|
29
|
+
|
|
30
|
+
## 第二阶段:扫描结构化记忆
|
|
31
|
+
|
|
32
|
+
运行:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
<CLI> tidy prepare --repo <REPO> [--branch <BRANCH>] --scope <SCOPE>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`SCOPE` 使用启动提示中的 `branch` 或 `branch+repo`。第一次 prepare 后优先读取输出中的 `annotated_md`,不要只看 stdout 的扁平 entries。它保留了:
|
|
39
|
+
|
|
40
|
+
- entry id
|
|
41
|
+
- block 边界
|
|
42
|
+
- section 结构
|
|
43
|
+
- Why/How 等 orphan paragraph
|
|
44
|
+
- STALE / ORPHAN hints
|
|
45
|
+
|
|
46
|
+
## 第三阶段:生成事项级 proposals
|
|
47
|
+
|
|
48
|
+
把相关条目聚合成约 3~8 个 proposal,每个 proposal 必须包含 `id`、`priority`、`title`、`reason`、`actions`。优先使用粗粒度动作:
|
|
49
|
+
|
|
50
|
+
1. `reset-file`
|
|
51
|
+
2. `delete-section`
|
|
52
|
+
3. `delete-block`
|
|
53
|
+
4. `delete-entries`
|
|
54
|
+
5. `edit-entries`
|
|
55
|
+
|
|
56
|
+
不要把每个 entry 单独做成 proposal。同一原因、同一结果的动作应合并。删除 block 时尽量附带 prepare 输出的 `expected_content_hash`,防止用户中途修改文件后误删。
|
|
57
|
+
|
|
58
|
+
priority 口径:
|
|
59
|
+
|
|
60
|
+
- `P0`:继续保留会误导下一次开发
|
|
61
|
+
- `P1`:强烈建议清理
|
|
62
|
+
- `P2`:建议清理
|
|
63
|
+
- `P3`:可选
|
|
64
|
+
- `P4`:可有可无
|
|
65
|
+
|
|
66
|
+
把 proposals 写入临时 JSON,再次运行:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
<CLI> tidy prepare --repo <REPO> [--branch <BRANCH>] --scope <SCOPE> --proposals-file <FILE>
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## 第四阶段:人工审核门禁
|
|
73
|
+
|
|
74
|
+
把 `review_html` / `open_url` 告诉用户,引导用户逐个选择:
|
|
75
|
+
|
|
76
|
+
- accept:按原方案执行
|
|
77
|
+
- reject:保持不动
|
|
78
|
+
- custom:给出新的处理意见
|
|
79
|
+
|
|
80
|
+
用户审核后从 HTML 导出 plan.json,并把路径交回本会话。没有用户导出的 plan 文件,禁止调用 `tidy apply`。
|
|
81
|
+
|
|
82
|
+
## 第五阶段:apply 与复核
|
|
83
|
+
|
|
84
|
+
用户明确提供已审核 plan 后运行:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
<CLI> tidy apply --repo <REPO> [--branch <BRANCH>] --plan-file <PLAN>
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
apply 会先备份,再按 reset → section → block → entry 的顺序执行。完成后必须读取生成的 `summary_*.md`,核对 accepted/rejected/custom、实际 rewritten/deleted 和 invalid actions。
|
|
91
|
+
|
|
92
|
+
custom proposal 不会自动 apply。根据反馈决定是直接精确改写、解释后再确认、保持不动,还是重新生成 proposals;不要机械重复整轮 prepare。
|
|
93
|
+
|
|
94
|
+
## 完成输出
|
|
95
|
+
|
|
96
|
+
最终向用户说明:
|
|
97
|
+
|
|
98
|
+
- unsorted 分类合并了多少条
|
|
99
|
+
- HTML 审核了多少个 proposal
|
|
100
|
+
- 实际改写、删除、重置的数量
|
|
101
|
+
- 备份和 summary 路径
|
|
102
|
+
- 因漂移校验而跳过的动作
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dev-memory-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "CLI for dev-memory hooks and repo-local setup (formerly @xluos/dev-assets-cli)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
"hooks/*.json",
|
|
29
29
|
"hooks/README.md",
|
|
30
30
|
"lib/*.py",
|
|
31
|
+
"lib/maintenance/*.md",
|
|
31
32
|
"lib/ui-server.js",
|
|
32
33
|
"lib/ui-app.html",
|
|
33
34
|
"lib/assets/*",
|
package/scripts/hooks/_common.py
CHANGED
|
@@ -490,13 +490,12 @@ def _extract_sections(paths, keys, *, repo_newest_first=False):
|
|
|
490
490
|
|
|
491
491
|
def _build_context_from_assets(assets, *, full=True, heading=None, brief_profile="standard"):
|
|
492
492
|
if not assets["branch_dir"].exists():
|
|
493
|
-
#
|
|
494
|
-
#
|
|
495
|
-
# write has happened yet — no need to push setup.
|
|
493
|
+
# Memory is opt-in. A missing branch directory stays silent in
|
|
494
|
+
# workspace briefs; the primary repo gets a concise init hint.
|
|
496
495
|
if heading is None:
|
|
497
496
|
return (
|
|
498
497
|
"当前仓库+分支还没有 dev-memory 记忆。"
|
|
499
|
-
"
|
|
498
|
+
"需要启用时运行 `dev-memory-cli init`;之后由定期 session-scan 沉淀会话语义。"
|
|
500
499
|
)
|
|
501
500
|
return None
|
|
502
501
|
|
|
@@ -617,7 +616,7 @@ def _build_context_from_assets(assets, *, full=True, heading=None, brief_profile
|
|
|
617
616
|
"",
|
|
618
617
|
f"归档分支查询:`grep -r 'KEYWORD' {archive_dir}/` (体量大时派 Task 子 agent)",
|
|
619
618
|
])
|
|
620
|
-
footer_lines.extend(["", "
|
|
619
|
+
footer_lines.extend(["", "新增会话语义由定期 session-scan 沉淀;主动查旧记忆使用 `dev-memory-read`。"])
|
|
621
620
|
parts.append("\n".join(footer_lines))
|
|
622
621
|
|
|
623
622
|
return "\n\n".join(parts)
|
package/suite-manifest.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"suite_name": "dev-memory-skill-suite",
|
|
3
3
|
"skills": [
|
|
4
|
-
"dev-memory-read"
|
|
4
|
+
"dev-memory-read"
|
|
5
|
+
],
|
|
6
|
+
"legacy_skills": [
|
|
5
7
|
"dev-memory-setup",
|
|
6
8
|
"dev-memory-capture",
|
|
7
9
|
"dev-memory-graduate",
|
|
8
|
-
"dev-memory-tidy"
|
|
9
|
-
],
|
|
10
|
-
"legacy_skills": [
|
|
10
|
+
"dev-memory-tidy",
|
|
11
11
|
"branch-context",
|
|
12
12
|
"branch-context-setup",
|
|
13
13
|
"dev-asset-setup",
|