dev-memory-cli 0.22.2 → 0.23.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.
@@ -0,0 +1,84 @@
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。
84
+
@@ -0,0 +1,103 @@
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
+ - 因漂移校验而跳过的动作
103
+
package/lib/ui-app.html CHANGED
@@ -743,7 +743,7 @@ function renderScan() {
743
743
  el("td", { class: "num" }, run.session_count),
744
744
  el("td", { class: "num" }, formatBytes(run.new_bytes)),
745
745
  el("td", { class: "num" }, usage == null ? "未上报" : Number(usage).toLocaleString()),
746
- el("td", null, run.done_count + " 完成 · " + run.failed_count + " 失败 · " + run.skipped_count + " 跳过")
746
+ el("td", null, run.status ? run.status : (run.done_count + " 完成 · " + run.failed_count + " 失败 · " + run.skipped_count + " 跳过"))
747
747
  ));
748
748
  });
749
749
  runTable.appendChild(runBody);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dev-memory-cli",
3
- "version": "0.22.2",
3
+ "version": "0.23.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/*",
@@ -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
- # v2: capture lazy-inits on first write, so branch_dir typically
494
- # exists after any real interaction. Missing here just means no
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
- "下一次 `dev-memory-capture` 写入时会自动 lazy init;现有结论若值得记一笔,直接走 capture。"
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(["", "新决策 / 进展 / 阻塞 → `dev-memory-capture` 写入。"])
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)
@@ -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",