@betterdanlins/ai-memory 0.5.0 → 0.6.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 CHANGED
@@ -44,6 +44,14 @@ An initialized project cannot be initialized again. A newer CLI first uses `upda
44
44
 
45
45
  ## Versions and compatibility
46
46
 
47
+ ### v0.6.0 — actionable memory loading
48
+
49
+ - Turns `user-profile.md` and `feedback.md` from passive import files into core session context. Every session loads the profile, durable collaboration rules, project state, and the latest session entry in a fixed order.
50
+ - Adds an explicit memory write router: confirmed cross-project preferences go to `user-profile.md`, reusable user corrections go to `feedback.md`, project facts stay in project memory, and one-off instructions are not persisted.
51
+ - Forbids inferred personal profiling and credential storage. Sensitive information is omitted by default and requires both an explicit request and confirmation of repository visibility; newer feedback replaces conflicting older rules.
52
+ - Adds task-specific loading routes so agents do not read the whole knowledge base. The architecture methodology is now explicitly loaded only by project inception and feature design.
53
+ - Connects Claude and Codex model-routing skills to their concrete native agent names, removing the implicit tier-to-executor gap.
54
+
47
55
  ### v0.5.0 — managed entry blocks
48
56
 
49
57
  - Wraps the framework-owned sections of generated `AGENTS.md` and `CLAUDE.md` in explicit `ai-memory:managed` markers. Future updates replace only that block and preserve project commands and custom rules outside it.
@@ -90,6 +98,15 @@ npx @betterdanlins/ai-memory@0.5.0 update --yes
90
98
 
91
99
  If `AGENTS.md` or `CLAUDE.md` is still the unchanged v0.4.0 generated version, it migrates automatically. If either unmarked file was customized, dry-run reports `merge`; compare it with a fresh v0.5.0 reference, keep project-specific content in the user block, and retry. Once markers exist, edit only outside `<!-- ai-memory:managed:start/end -->`.
92
100
 
101
+ ### Upgrade from v0.5.0 to v0.6.0
102
+
103
+ ```bash
104
+ npx @betterdanlins/ai-memory@0.6.0 update --dry-run
105
+ npx @betterdanlins/ai-memory@0.6.0 update --yes
106
+ ```
107
+
108
+ The managed sections of `AGENTS.md` / `CLAUDE.md` and unchanged framework files update automatically. Existing `user-profile.md`, `feedback.md`, project state, and feature memory remain user-owned and are never overwritten. The new entry and memory-update protocols start using that existing content immediately; richer profile/feedback starter structures are used only for fresh or still-missing files.
109
+
93
110
  ## What it generates
94
111
 
95
112
  ```
@@ -99,7 +116,7 @@ If `AGENTS.md` or `CLAUDE.md` is still the unchanged v0.4.0 generated version, i
99
116
  ├── config/
100
117
  │ └── model-routing.json # inherit/balanced/quality stage routing; user-owned
101
118
  ├── memory/
102
- │ ├── MEMORY.md # index agents read this first
119
+ │ ├── MEMORY.md # core/on-demand memory loading index
103
120
  │ ├── project-state.md # stack, current version, requirement progress
104
121
  │ ├── session-log.md # rolling log of progress & next steps
105
122
  │ ├── user-profile.md # background, preferences, communication style
@@ -165,6 +182,7 @@ The generator is a small set of focused modules:
165
182
  ## Design principles
166
183
 
167
184
  - **Single source** — content lives only in `.ai/`; `.claude/` and `.agents/` are trigger wrappers.
185
+ - **Actionable scoped memory** — every session loads a small core set; durable user preferences, reusable feedback, project facts, and feature decisions have separate write destinations, while task artifacts remain on-demand.
168
186
  - **Engineering-node memory** — write session-log entries for independently verifiable features/phases, durable decisions, status changes, or tool handoffs, avoiding noise from tiny implementation steps.
169
187
  - **Dual requirement directories** — human draft (`draft/`) → AI final (`final/`) behind a mandatory critic gate.
170
188
  - **Project engineering baseline** — 0-to-1 projects establish language-agnostic system, data, quality-attribute, and deployment baselines once; ordinary features record only deltas.
package/README.zh-CN.md CHANGED
@@ -44,6 +44,14 @@ npx @betterdanlins/ai-memory models configure --profile balanced
44
44
 
45
45
  ## 版本与兼容性
46
46
 
47
+ ### v0.6.0 —— 可执行的记忆加载闭环
48
+
49
+ - 将 `user-profile.md` 和 `feedback.md` 从被动导入文件接入核心会话上下文。每次会话按固定顺序加载用户画像、长期协作规则、项目状态和最新 session 条目。
50
+ - 增加明确的记忆写入路由:已确认的跨项目偏好进入 `user-profile.md`,可复用的用户纠正进入 `feedback.md`,项目事实留在项目记忆,一次性要求不落盘。
51
+ - 禁止推断个人画像和保存凭据。敏感信息默认不写,只有用户明确要求并确认仓库可见性后才能记录;新反馈与旧规则冲突时替换旧规则。
52
+ - 增加按任务加载路由,避免 Agent 一次性读取整个知识库;架构方法论只在项目启动和功能设计时明确加载。
53
+ - Claude 与 Codex 的模型路由 skill 现在显式映射实际原生代理名称,补齐等级到执行者之间的隐式断点。
54
+
47
55
  ### v0.5.0 —— 入口文件受管区块
48
56
 
49
57
  - 为生成的 `AGENTS.md` 和 `CLAUDE.md` 框架区域增加明确的 `ai-memory:managed` 标记。后续升级只替换该区块,区块外的项目命令和自定义规则保持不变。
@@ -90,6 +98,15 @@ npx @betterdanlins/ai-memory@0.5.0 update --yes
90
98
 
91
99
  如果 `AGENTS.md` 或 `CLAUDE.md` 仍是未修改的 v0.4.0 生成版本,会自动迁移。若无标记入口已被定制,dry-run 会报告 `merge`;应对照全新 v0.5.0 参考文件,把项目内容放进 user 区块后重试。标记建立后,只在 `<!-- ai-memory:managed:start/end -->` 之外编辑。
92
100
 
101
+ ### 从 v0.5.0 升级到 v0.6.0
102
+
103
+ ```bash
104
+ npx @betterdanlins/ai-memory@0.6.0 update --dry-run
105
+ npx @betterdanlins/ai-memory@0.6.0 update --yes
106
+ ```
107
+
108
+ `AGENTS.md` / `CLAUDE.md` 的受管区块和未修改的框架文件会自动更新。已有 `user-profile.md`、`feedback.md`、项目状态和 feature 记忆继续属于用户资产,绝不覆盖;新的进场和 memory-update 协议会立即使用已有内容。更完整的画像/反馈初始结构只用于全新项目或仍缺失的文件。
109
+
93
110
  ## 生成什么
94
111
 
95
112
  ```
@@ -99,7 +116,7 @@ npx @betterdanlins/ai-memory@0.5.0 update --yes
99
116
  ├── config/
100
117
  │ └── model-routing.json # inherit/balanced/quality 阶段路由;属于用户配置
101
118
  ├── memory/
102
- │ ├── MEMORY.md # 索引 —— agent 进场先读
119
+ │ ├── MEMORY.md # 核心/按需记忆加载索引
103
120
  │ ├── project-state.md # 技术栈、当前版本、需求进度
104
121
  │ ├── session-log.md # 进展与下一步的流水日志
105
122
  │ ├── user-profile.md # 背景、偏好、沟通方式
@@ -165,6 +182,7 @@ AGENTS.md + .agents/ + .codex/# Codex:skills 与分层自定义 agents
165
182
  ## 设计原则
166
183
 
167
184
  - **单一源** —— 正文只在 `.ai/`;`.claude/`、`.agents/` 只是触发包装。
185
+ - **可执行的分域记忆** —— 每次会话只加载小型核心集合;长期用户偏好、可复用反馈、项目事实和功能决策分别写入不同位置,任务产物继续按需加载。
168
186
  - **工程节点记忆** —— 只在可独立验收的功能/阶段、关键决策、状态变化或工具切换时写 session-log,避免细碎步骤制造噪声。
169
187
  - **需求双目录** —— 人工粗稿(`draft/`)→ AI 定稿(`final/`),中间隔一道强制 critic 门。
170
188
  - **项目工程基线** —— 0→1 项目先建立语言无关的系统、数据、质量属性和部署基线;普通功能只记录增量,不重复设计全局架构。
package/bin/cli.js CHANGED
@@ -119,7 +119,7 @@ program
119
119
  if (r.imported.length) for (const d of r.imported) console.log(` 已导入 ${d}`);
120
120
  if (r.fallback.length) for (const d of r.fallback) console.log(` 导入源缺失,使用模板 ${d}`);
121
121
  if (r.skipped.length) for (const d of r.skipped) console.log(` 跳过 ${d}`);
122
- console.log('下一步:打开项目让 agent 读 .ai/memory/MEMORY.md;把项目命令补进 CLAUDE.md/AGENTS.md');
122
+ console.log('下一步:打开项目让 agent 读 .ai/README.md;把项目命令补进 CLAUDE.md/AGENTS.md 的 user 区块。');
123
123
  });
124
124
 
125
125
  const models = program.command('models').description('查看或配置阶段模型路由');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterdanlins/ai-memory",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "AI memory + requirements workflow scaffolder for Claude Code & Codex",
5
5
  "type": "module",
6
6
  "bin": {
@@ -3,6 +3,7 @@ description: 主动总结当前进展并按路由写入 .ai/memory/
3
3
  ---
4
4
 
5
5
  按 `.ai/skills/memory-update.md` 执行:
6
- 1. 读 `.ai/memory/MEMORY.md` 与 `session-log.md`
7
- 2. 追加本次节点条目(时间戳 + 做了什么 + 关键决策 + 下一步)
8
- 3. 需求/里程碑状态有变则更新 `project-state.md` 对应表格行
6
+ 1. 读 `.ai/memory/MEMORY.md` 和本次内容可能写入的目标文件
7
+ 2. 先区分用户级、项目级、功能级或一次性信息,再按写入路由更新
8
+ 3. 只有满足工程节点触发条件时才追加 session-log;不要每次调用都制造流水
9
+ 4. 用户画像只记录明确确认的长期信息,协作规范只记录可复用的明确反馈
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: memory-update
3
- description: Use when completing an independently verifiable feature, phase, or release; making a durable decision; changing requirement/design/delivery status; preserving a cross-session risk; switching tools; or when the user explicitly asks to update memory
3
+ description: Use when completing an independently verifiable feature, phase, or release; making a durable decision; changing requirement/design/delivery status; preserving a cross-session risk; switching tools; the user states a durable preference or corrects agent behavior; or the user explicitly asks to update memory
4
4
  ---
5
5
 
6
6
  读取并严格遵循 `.ai/skills/memory-update.md` 的写入路由与硬性约束执行。
@@ -3,4 +3,4 @@ name: model-routing
3
3
  description: 按项目模型策略路由规划、实现、测试和审查,并在跨模型阶段创建和校验结构化交接。用于准备阶段切换、选择执行代理或验证 handoff。
4
4
  ---
5
5
 
6
- 先读取 `.ai/skills/model-routing.md` 与 `.ai/config/model-routing.json`。风险流程决定阶段,模型路由只选择执行者。跨模型前创建并校验 handoff;失败时停止,不得用对话摘要补缺失输入。
6
+ 先读取 `.ai/skills/model-routing.md` 与 `.ai/config/model-routing.json`。风险流程决定阶段,模型路由只选择执行者。Claude 代理映射:premium 规划=`premium-planner`,premium 实现=`premium-implementer`,standard 实现=`standard-implementer`,economy/standard 测试=`economy-test-worker`/`standard-test-worker`,premium 审查=`premium-reviewer`。跨模型前创建并校验 handoff;失败时停止,不得用对话摘要补缺失输入。
@@ -3,7 +3,7 @@
3
3
  <!-- ai-memory:managed:start -->
4
4
  ## AI 协作框架(ai-memory)
5
5
 
6
- 进场先读 `.ai/memory/MEMORY.md`,随后遵循 `.ai/README.md` 的进场协议。
6
+ 进场先读 `.ai/README.md`,严格按其中的核心记忆与任务路由加载协议执行。
7
7
  本 managed 区块由 ai-memory 更新;项目命令和自定义规则只写到下方 user 区块。
8
8
 
9
9
  - 0→1 项目/首次架构基线/重大重构 → project-inception skill,产物在 `docs/architecture/`;普通功能不要重复触发
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: memory-update
3
- description: Use when completing an independently verifiable feature, phase, or release; making a durable decision; changing requirement/design/delivery status; preserving a cross-session risk; switching tools; or when the user explicitly asks to update memory
3
+ description: Use when completing an independently verifiable feature, phase, or release; making a durable decision; changing requirement/design/delivery status; preserving a cross-session risk; switching tools; the user states a durable preference or corrects agent behavior; or the user explicitly asks to update memory
4
4
  ---
5
5
 
6
6
  读取并严格遵循 `.ai/skills/memory-update.md` 的写入路由与硬性约束执行。
@@ -3,4 +3,4 @@ name: model-routing
3
3
  description: 按项目模型策略路由规划、实现、测试和审查,并在跨模型阶段创建和校验结构化交接。用于准备阶段切换、选择执行代理或验证 handoff。
4
4
  ---
5
5
 
6
- 先读取 `.ai/skills/model-routing.md` 与 `.ai/config/model-routing.json`。风险流程决定阶段,模型路由只选择执行者。跨模型前创建并校验 handoff;失败时停止,不得用对话摘要补缺失输入。
6
+ 先读取 `.ai/skills/model-routing.md` 与 `.ai/config/model-routing.json`。风险流程决定阶段,模型路由只选择执行者。Codex 代理映射:premium 规划=`premium_planner`,premium 实现=`premium_implementer`,standard 实现=`standard_implementer`,economy/standard 测试=`economy_test_worker`/`standard_test_worker`,premium 审查=`premium_reviewer`。跨模型前创建并校验 handoff;失败时停止,不得用对话摘要补缺失输入。
@@ -3,7 +3,7 @@
3
3
  <!-- ai-memory:managed:start -->
4
4
  ## AI 协作框架(ai-memory)
5
5
 
6
- 进场先读 `.ai/memory/MEMORY.md`,随后遵循 `.ai/README.md` 的进场协议。
6
+ 进场先读 `.ai/README.md`,严格按其中的核心记忆与任务路由加载协议执行。
7
7
  本 managed 区块由 ai-memory 更新;项目命令和自定义规则只写到下方 user 区块。
8
8
 
9
9
  - 0→1 项目/首次架构基线/重大重构 → project-inception skill,产物在 `docs/architecture/`;普通功能不要重复触发
@@ -5,10 +5,24 @@
5
5
 
6
6
  ## 进场协议(每次会话开始)
7
7
 
8
- 1. 读 `memory/MEMORY.md`(记忆索引)
9
- 2. 读 `memory/session-log.md` 末尾条目(接上进度)
10
- 3. 按任务类型按需加载 `skills/` 对应方法论
11
- 4. 跨模型阶段先按 `skills/model-routing.md` 创建并校验 handoff,不用对话摘要替代正式输入
8
+ 1. 读 `memory/MEMORY.md`,再依次加载 `user-profile.md` 当前画像、`feedback.md` 当前规则、`project-state.md` 活跃区段与 `session-log.md` 最新条目;历史归档只在追溯时读取。
9
+ 2. 先用核心记忆校准沟通方式、用户长期约束、项目现状和上次进度;文件为空时直接继续,不臆测补全。
10
+ 3. 按任务路由只加载当前需要的方法论和正式产物,禁止一次性读取整个 `.ai/` 与 `docs/`。
11
+ 4. 跨模型阶段先按 `skills/model-routing.md` 创建并校验 handoff,不用对话摘要替代正式输入。
12
+
13
+ 核心记忆只保留当前有效的精简结论;过期偏好应替换,历史 session 应归档,不以无限增长换取“记得更多”。
14
+
15
+ ## 任务加载路由
16
+
17
+ | 任务 | 必读增量 |
18
+ |---|---|
19
+ | 0→1、首次基线、重大重构 | `skills/project-inception.md` + 现有 `docs/architecture/` |
20
+ | 新建/定稿需求 | `skills/requirements-flow.md` + 相关 feature 记忆与需求文档 |
21
+ | M/L 功能 how | `skills/feature-design.md` + final 需求、相关架构基线与 feature 记忆 |
22
+ | 实现或修复 | final 需求、适用设计/计划;跨模型时再读 `skills/model-routing.md` |
23
+ | Review | `skills/code-review.md` + 契约、diff 与验证证据 |
24
+ | 交付/发布 | `skills/delivery-readiness.md` + final 需求、设计、架构基线与差异 |
25
+ | 更新记忆 | `skills/memory-update.md`;按内容归属选择目标文件 |
12
26
 
13
27
  ## 目录
14
28
 
@@ -16,7 +30,7 @@
16
30
  - `config/model-routing.json` — 可选阶段模型策略;默认 `inherit` 不改变旧行为
17
31
  - `memory/` — 记忆层:MEMORY.md 索引、project-state 全景、session-log 流水、user-profile/feedback 用户级记忆、features/ 功能档案
18
32
  - `runs/` — 本地交接清单和阶段回执;默认不进入 Git
19
- - `skills/` — 方法论层:project-inception、requirements-flow、feature-design、delivery-readiness、model-routing、architecture、code-review、critic、memory-update
33
+ - `skills/` — 方法论层:project-inception、requirements-flow、feature-design、delivery-readiness、model-routing、code-review、critic、memory-update
20
34
 
21
35
  ## 与工具专属配置的关系
22
36
 
@@ -1,9 +1,14 @@
1
- # 记忆索引
1
+ # 记忆索引与加载策略
2
2
 
3
- > agent 进场先读本文件,再按需加载指向的文件。一行一条;新增记忆文件必须在此登记。
3
+ > 每次会话先读取核心记忆;任务记忆按需加载。新增记忆文件必须在本索引登记,禁止一次性加载整个目录。
4
4
 
5
- - [项目状态](project-state.md) — 技术栈、当前版本、需求进度、遗留问题
6
- - [Session 日志](session-log.md) — 最新进展、下一步、未落盘决策
7
- - [用户画像](user-profile.md) — 背景、偏好、沟通方式
8
- - [协作规范](feedback.md) — 历史反馈提炼的行为规范
9
- <!-- features/ 功能档案在下方逐行登记 -->
5
+ ## 核心记忆(每次会话)
6
+
7
+ 1. [用户画像](user-profile.md) — 已确认的背景、沟通偏好与长期约束
8
+ 2. [协作规范](feedback.md) — 用户明确反馈沉淀的可执行规则
9
+ 3. [项目状态](project-state.md) 读基本信息、当前需求和遗留问题;归档摘要仅在追溯时读取
10
+ 4. [Session 日志](session-log.md) — 只读最新条目,接续进展与下一步
11
+
12
+ ## 任务记忆(按需)
13
+
14
+ <!-- features/ 功能档案逐行登记;只在任务涉及对应功能时读取 -->
@@ -1,6 +1,15 @@
1
1
  # 协作规范
2
2
 
3
- > 从历史协作反馈中提炼的行为规范,用户级记忆,跨项目可复用。
4
- > 每条写清:规范 + 为什么 + 如何应用。
3
+ > 从用户明确纠正或要求中提炼的跨项目行为规则。只记可重复执行的规则,不记录一次性情绪、项目事实或未经确认的推断。
4
+ > 写入前先去重;新规则与旧规则冲突时,以用户最新明确反馈为准并替换旧规则。
5
+
6
+ ## 规则格式
7
+
8
+ - **规则**:必须/不要做什么
9
+ - 原因:用户为什么提出
10
+ - 应用:何时触发、具体怎么做
11
+ - 来源:YYYY-MM-DD 用户明确反馈
12
+
13
+ ## 当前规则
5
14
 
6
15
  (暂无条目)
@@ -1,13 +1,25 @@
1
1
  # 用户画像
2
2
 
3
- > 用户级记忆,跨项目可复用(init 时可从已有项目导入)。
3
+ > 跨项目复用的用户级记忆。只记录用户明确表达或确认的稳定信息;不从语气、姓名或项目内容推断身份、能力和敏感属性。敏感信息默认不写,密钥和凭据永不写。
4
+ > 保持精简;偏好变化时以最新明确表达为准。仅对当前项目有效的信息写入 `project-state.md`。
4
5
 
5
- ## 背景与角色
6
+ ## 背景与角色(已确认)
6
7
 
7
- (技术背景、当前角色)
8
+ - 技术背景:
9
+ - 当前角色与主要职责:
10
+ - 常用工具或工作环境:
8
11
 
9
- ## 偏好
12
+ ## 沟通与决策偏好
10
13
 
11
- - 沟通语言:
12
- - 回复风格:
13
- - 技术偏好:
14
+ - 默认语言:
15
+ - 回复详细度与表达方式:
16
+ - 可自主执行的范围:
17
+ - 必须先确认的操作:
18
+ - 方案比较与决策方式:
19
+
20
+ ## 长期工程偏好与约束
21
+
22
+ - 质量、速度与成本取舍:
23
+ - 技术或架构偏好:
24
+ - 明确避免的做法:
25
+ - 其他跨项目约束:
@@ -10,7 +10,7 @@
10
10
 
11
11
  ## 流程
12
12
 
13
- 1. 读取 `final/<需求名>.md` 的实现交接,以及相关 `docs/architecture/`、源码和 feature 记忆。
13
+ 1. 读取 `final/<需求名>.md` 的实现交接、`.ai/skills/architecture.md`,以及相关 `docs/architecture/`、源码和 feature 记忆。
14
14
  2. 若需求存在矛盾或阻塞开放问题,退回 requirements-flow;不要用实现假设偷偷补需求。
15
15
  3. 在 `docs/design/vX.Y.Z/<需求名>.md` 按模板形成设计,只填写适用章节,不涉及也要简述原因。
16
16
  4. 为真实边界定义技术接口契约;不要为所有私有函数写文档。
@@ -16,11 +16,21 @@
16
16
 
17
17
  | 内容 | 去处 |
18
18
  |---|---|
19
+ | 用户明确表达的稳定背景、沟通/决策偏好、跨项目约束 | `user-profile.md` 对应字段 |
20
+ | 用户明确纠正且可跨项目复用的 Agent 行为规则 | `feedback.md` 去重后新增或替换 |
19
21
  | 工程节点、当前进度、下一步、阻塞 | `session-log.md` 追加 |
20
22
  | 需求、设计、里程碑或交付状态 | `project-state.md` 对应行 |
21
23
  | 稳定功能决策与契约变化摘要 | `features/<名>.md` |
22
24
  | 新增记忆文件 | `MEMORY.md` 加索引 |
23
25
 
26
+ ## 用户级记忆判定
27
+
28
+ 1. 只记录用户明确说出、确认或纠正的长期信息;不得根据对话风格、代码水平、姓名或项目类型推断画像。
29
+ 2. 先判断作用域:跨项目才进入 `user-profile.md` / `feedback.md`;当前项目事实进入项目状态或 feature 记忆;一次性要求不落盘。
30
+ 3. `user-profile.md` 记录“用户是谁、偏好怎样协作”;`feedback.md` 记录“Agent 以后具体必须怎样做”,不得重复抄写。
31
+ 4. 身份、联系方式、健康、财务等敏感信息默认不写;只有用户明确要求并确认仓库可见性后才允许记录必要的最小范围。密钥、令牌和凭据永不写入。
32
+ 5. 用户撤回或修改偏好时更新旧条目,不并列保留相互冲突的规则。
33
+
24
34
  ## 约束
25
35
 
26
36
  - 写前读取目标文件,只记录增量和新事实,不复制需求/设计/测试输出。
@@ -12,7 +12,7 @@
12
12
 
13
13
  ## 工作流
14
14
 
15
- 1. 读取项目目标、现有代码/文档和 `.ai/memory/project-state.md`。
15
+ 1. 读取项目目标、现有代码/文档、`.ai/memory/project-state.md` 与 `.ai/skills/architecture.md` 的语言无关边界原则。
16
16
  2. 判断是 0→1、新增基线还是重大重构;不适用则停止并转入需求或功能设计流程。
17
17
  3. 只询问会改变架构方向的阻塞信息;非阻塞信息采用保守假设并明确标记。
18
18
  4. 按 `docs/architecture/` 的四份模板建立或增量更新工程基线: