@zmice/zc 0.2.5 → 0.2.7

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 (103) hide show
  1. package/README.md +98 -11
  2. package/dist/cli/__tests__/platform.test.js +215 -2
  3. package/dist/cli/__tests__/platform.test.js.map +1 -1
  4. package/dist/cli/__tests__/surface.test.js +52 -0
  5. package/dist/cli/__tests__/surface.test.js.map +1 -1
  6. package/dist/cli/__tests__/team.test.d.ts +2 -0
  7. package/dist/cli/__tests__/team.test.d.ts.map +1 -0
  8. package/dist/cli/__tests__/team.test.js +29 -0
  9. package/dist/cli/__tests__/team.test.js.map +1 -0
  10. package/dist/cli/__tests__/upstream.test.js +4 -0
  11. package/dist/cli/__tests__/upstream.test.js.map +1 -1
  12. package/dist/cli/platform.d.ts +11 -3
  13. package/dist/cli/platform.d.ts.map +1 -1
  14. package/dist/cli/platform.js +216 -54
  15. package/dist/cli/platform.js.map +1 -1
  16. package/dist/cli/team.d.ts.map +1 -1
  17. package/dist/cli/team.js +114 -4
  18. package/dist/cli/team.js.map +1 -1
  19. package/dist/cli/upstream.d.ts +1 -0
  20. package/dist/cli/upstream.d.ts.map +1 -1
  21. package/dist/cli/upstream.js +84 -5
  22. package/dist/cli/upstream.js.map +1 -1
  23. package/dist/node_modules/@zmice/platform-core/dist/index.d.ts +37 -3
  24. package/dist/node_modules/@zmice/platform-core/dist/index.d.ts.map +1 -1
  25. package/dist/node_modules/@zmice/platform-core/dist/index.js +68 -0
  26. package/dist/node_modules/@zmice/platform-core/dist/index.js.map +1 -1
  27. package/dist/node_modules/@zmice/platform-core/dist/index.test.js +44 -1
  28. package/dist/node_modules/@zmice/platform-core/dist/index.test.js.map +1 -1
  29. package/dist/runtime/__tests__/worktree-manager.test.js +63 -1
  30. package/dist/runtime/__tests__/worktree-manager.test.js.map +1 -1
  31. package/dist/runtime/worktree-manager.d.ts +26 -1
  32. package/dist/runtime/worktree-manager.d.ts.map +1 -1
  33. package/dist/runtime/worktree-manager.js +126 -12
  34. package/dist/runtime/worktree-manager.js.map +1 -1
  35. package/dist/team/__tests__/orchestrator.test.js +40 -0
  36. package/dist/team/__tests__/orchestrator.test.js.map +1 -1
  37. package/dist/team/__tests__/planner.test.d.ts +2 -0
  38. package/dist/team/__tests__/planner.test.d.ts.map +1 -0
  39. package/dist/team/__tests__/planner.test.js +43 -0
  40. package/dist/team/__tests__/planner.test.js.map +1 -0
  41. package/dist/team/__tests__/task-queue.test.js +18 -0
  42. package/dist/team/__tests__/task-queue.test.js.map +1 -1
  43. package/dist/team/orchestrator.d.ts +2 -1
  44. package/dist/team/orchestrator.d.ts.map +1 -1
  45. package/dist/team/orchestrator.js +29 -10
  46. package/dist/team/orchestrator.js.map +1 -1
  47. package/dist/team/planner.d.ts +27 -0
  48. package/dist/team/planner.d.ts.map +1 -0
  49. package/dist/team/planner.js +120 -0
  50. package/dist/team/planner.js.map +1 -0
  51. package/dist/team/task-queue.d.ts +3 -0
  52. package/dist/team/task-queue.d.ts.map +1 -1
  53. package/dist/team/task-queue.js +11 -2
  54. package/dist/team/task-queue.js.map +1 -1
  55. package/package.json +2 -2
  56. package/vendor/node_modules/@zmice/platform-core/dist/index.d.ts +37 -3
  57. package/vendor/node_modules/@zmice/platform-core/dist/index.d.ts.map +1 -1
  58. package/vendor/node_modules/@zmice/platform-core/dist/index.js +68 -0
  59. package/vendor/node_modules/@zmice/platform-core/dist/index.js.map +1 -1
  60. package/vendor/node_modules/@zmice/platform-core/dist/index.test.js +44 -1
  61. package/vendor/node_modules/@zmice/platform-core/dist/index.test.js.map +1 -1
  62. package/vendor/packages/platform-claude/dist/index.d.ts.map +1 -1
  63. package/vendor/packages/platform-claude/dist/index.js +12 -70
  64. package/vendor/packages/platform-claude/dist/index.js.map +1 -1
  65. package/vendor/packages/platform-codex/dist/generate.d.ts +1 -1
  66. package/vendor/packages/platform-codex/dist/generate.d.ts.map +1 -1
  67. package/vendor/packages/platform-codex/dist/generate.js +1 -1
  68. package/vendor/packages/platform-codex/dist/generate.js.map +1 -1
  69. package/vendor/packages/platform-codex/dist/index.d.ts +15 -1
  70. package/vendor/packages/platform-codex/dist/index.d.ts.map +1 -1
  71. package/vendor/packages/platform-codex/dist/index.js +320 -47
  72. package/vendor/packages/platform-codex/dist/index.js.map +1 -1
  73. package/vendor/packages/platform-codex/dist/index.test.js +113 -5
  74. package/vendor/packages/platform-codex/dist/index.test.js.map +1 -1
  75. package/vendor/packages/platform-opencode/dist/index.d.ts.map +1 -1
  76. package/vendor/packages/platform-opencode/dist/index.js +15 -81
  77. package/vendor/packages/platform-opencode/dist/index.js.map +1 -1
  78. package/vendor/packages/platform-qwen/dist/index.d.ts.map +1 -1
  79. package/vendor/packages/platform-qwen/dist/index.js +28 -84
  80. package/vendor/packages/platform-qwen/dist/index.js.map +1 -1
  81. package/vendor/packages/toolkit/src/content/agents/architect/body.md +8 -0
  82. package/vendor/packages/toolkit/src/content/agents/code-reviewer/body.md +10 -0
  83. package/vendor/packages/toolkit/src/content/agents/product-owner/body.md +8 -0
  84. package/vendor/packages/toolkit/src/content/commands/plan-review/body.md +3 -1
  85. package/vendor/packages/toolkit/src/content/commands/start/body.md +51 -2
  86. package/vendor/packages/toolkit/src/content/commands/start/meta.yaml +2 -2
  87. package/vendor/packages/toolkit/src/content/skills/branch-finish-and-cleanup/body.md +17 -0
  88. package/vendor/packages/toolkit/src/content/skills/browser-qa-testing/body.md +77 -520
  89. package/vendor/packages/toolkit/src/content/skills/ci-cd-and-automation/body.md +56 -387
  90. package/vendor/packages/toolkit/src/content/skills/code-review-and-quality/body.md +10 -0
  91. package/vendor/packages/toolkit/src/content/skills/code-simplification/body.md +55 -301
  92. package/vendor/packages/toolkit/src/content/skills/context-engineering/body.md +10 -0
  93. package/vendor/packages/toolkit/src/content/skills/continuous-learning/body.md +66 -331
  94. package/vendor/packages/toolkit/src/content/skills/multi-perspective-review/body.md +30 -1
  95. package/vendor/packages/toolkit/src/content/skills/parallel-agent-dispatch/body.md +79 -317
  96. package/vendor/packages/toolkit/src/content/skills/performance-optimization/body.md +60 -330
  97. package/vendor/packages/toolkit/src/content/skills/planning-and-task-breakdown/body.md +35 -0
  98. package/vendor/packages/toolkit/src/content/skills/sdd-tdd-workflow/body.md +66 -342
  99. package/vendor/packages/toolkit/src/content/skills/sprint-retrospective/body.md +66 -303
  100. package/vendor/packages/toolkit/src/content/skills/team-orchestration/body.md +81 -327
  101. package/vendor/packages/toolkit/src/content/skills/test-driven-development/body.md +50 -346
  102. package/vendor/packages/toolkit/src/content/skills/using-agent-skills/body.md +26 -2
  103. package/vendor/references/upstreams.yaml +5 -0
@@ -1,367 +1,102 @@
1
1
  # Continuous Learning
2
2
 
3
- ## Overview
3
+ ## 角色定位
4
4
 
5
- 将开发会话转化为可复用知识。通过 hooks 自动观察工具使用、用户纠正和错误修复模式,提取为原子化的"本能"(instinct),并随时间演化为正式的技能和命令。
5
+ 把一次会话中的可复用经验提炼成可审查、可回滚的学习项。它服务于长期协作质量,不是默认打开的遥测系统,也不是跨会话记忆的自动授权入口。
6
6
 
7
- **核心模式:观察(Observe)→ 提取(Extract)→ 持久化(Persist)→ 演化(Evolve)**
7
+ 核心模式:观察 提炼 → 验证 → 持久化 → 演化。
8
8
 
9
- ## When to Use
9
+ ## 何时使用
10
10
 
11
- - 启用自动学习(配置 hooks)
12
- - 手动触发会话模式提取(`/learn`)
13
- - 审查和管理已学习的 instincts
14
- - 将高频 instincts 演化为正式 skills/commands
15
- - Sprint 回顾时自动触发学习提取(`/retro` 集成)
11
+ - 用户明确要求 `/learn` 或复盘当前会话。
12
+ - 多次出现同一纠正、错误修复路径或项目约定。
13
+ - Sprint retrospective 需要沉淀可复用经验。
14
+ - 需要把高频经验升级成 skill、command 或项目规则。
16
15
 
17
- ## 架构
16
+ 不适用:
18
17
 
19
- ```
20
- 会话活动(工具调用、用户输入、错误修复)
21
-
22
- │ Hooks 自动捕获(100% 可靠,确定性执行)
23
- │ PostToolUse / UserPromptSubmit / Stop
24
-
25
- ┌──────────────────────────────────────────────┐
26
- │ observations.jsonl(本地文件) │
27
- │ 记录:工具调用、用户纠正、错误解决路径 │
28
- │ 项目级:projects/<project-hash>/ │
29
- └──────────────────────────────────────────────┘
30
-
31
- │ /learn 触发模式分析(手动或 Stop hook 提醒)
32
-
33
- ┌──────────────────────────────────────────────┐
34
- │ 模式检测(Pattern Detection) │
35
- │ · 用户纠正 → instinct(0.8+) │
36
- │ · 错误→修复 → instinct(0.6-0.7) │
37
- │ · 重复工作流 → instinct(0.5-0.6) │
38
- │ · 项目约定 → instinct(0.4-0.5) │
39
- └──────────────────────────────────────────────┘
40
-
41
- │ 双层持久化
42
-
43
- ┌──────────────────────────────────────────────┐
44
- │ 本地文件层 │
45
- │ instincts/personal/*.yaml(项目或全局) │
46
- ├──────────────────────────────────────────────┤
47
- │ Agent Memory 层 │
48
- │ 高置信度 instinct → learned_skill_experience │
49
- │ 跨会话智能检索,跨项目共享 │
50
- └──────────────────────────────────────────────┘
51
-
52
- │ /learn evolve — 聚类演化
53
-
54
- ┌──────────────────────────────────────────────┐
55
- │ 演化产物 │
56
- │ · skills/*.md(新技能) │
57
- │ · commands/*.md(新命令) │
58
- │ · 全局 instinct(多项目出现时自动提升) │
59
- └──────────────────────────────────────────────┘
60
- ```
18
+ - 单次偶然偏好。
19
+ - 未经验证的猜测。
20
+ - 敏感信息、凭据、生产数据或私人内容。
21
+ - 用户没有同意的自动跨会话记忆。
22
+
23
+ ## 快速路径
61
24
 
62
- ## Instinct 模型
25
+ 1. 收集本轮会话中可复用的观察,不存大段原始输入输出。
26
+ 2. 区分事实、用户偏好、项目约定和一次性上下文。
27
+ 3. 只提炼“触发条件 → 行动”的原子 instinct。
28
+ 4. 给每条 instinct 标置信心、证据、作用域和失效条件。
29
+ 5. 低置信度只留本地候选;高置信度也要说明为什么可复用。
30
+ 6. 需要写入长期文件或跨会话记忆时,先说明范围并等待用户同意。
31
+ 7. 多次重复后,再考虑演化为正式 skill / command / AGENTS 规则。
63
32
 
64
- 一个 instinct 是最小的学习单元 — 一个触发条件对应一个行动:
33
+ ## Instinct 格式
65
34
 
66
35
  ```yaml
67
- ---
68
- id: prefer-named-exports
69
- trigger: "when creating new TypeScript modules"
70
- action: "Use named exports instead of default exports"
36
+ id: prefer-targeted-verification
37
+ trigger: "when finishing a scoped toolkit content change"
38
+ action: "run toolkit lint and package tests before claiming completion"
71
39
  confidence: 0.8
72
- domain: code-style
73
40
  scope: project
74
- project_id: "a1b2c3d4e5f6"
75
41
  evidence:
76
- - "User corrected default export to named export on 2026-04-10"
77
- - "Observed 4 instances of named export preference in codebase"
78
- created: "2026-04-10T14:30:00Z"
79
- updated: "2026-04-12T09:15:00Z"
80
- ---
42
+ - "User repeatedly asked for evidence before completion"
43
+ expires_when: "project verification policy changes"
81
44
  ```
82
45
 
83
- ### Instinct 属性
84
-
85
- | 属性 | 说明 |
86
- |------|------|
87
- | **id** | 唯一标识符,kebab-case |
88
- | **trigger** | 何时触发此本能 |
89
- | **action** | 具体要做什么 |
90
- | **confidence** | 置信度(0.3=试探性,0.6=中等,0.9=近乎确定) |
91
- | **domain** | 领域标签:code-style / testing / git / debugging / workflow / security / performance |
92
- | **scope** | 作用域:project(默认)/ global |
93
- | **project_id** | 项目 hash(scope=project 时) |
94
- | **evidence** | 支持此 instinct 的观察证据列表 |
95
-
96
- ### 置信度规则
97
-
98
- | 来源 | 初始置信度 | 增长规则 |
99
- |------|-----------|---------|
100
- | 用户纠正 | 0.8 | 每次重复 +0.05,上限 0.95 |
101
- | 错误→修复路径 | 0.6 | 每次观察到 +0.05 |
102
- | 重复工作流 | 0.5 | 3+ 次观察后 +0.1 |
103
- | 项目约定推断 | 0.4 | 需 5+ 次观察确认 |
104
-
105
- **衰减规则:** 如果后续观察与 instinct 矛盾,置信度 -0.1。置信度 <0.3 的 instinct 自动归档。
106
-
107
- ### 作用域决策
108
-
109
- | 模式类型 | 作用域 | 示例 |
110
- |---------|--------|------|
111
- | 语言/框架约定 | project | "使用 React Hooks"、"遵循 Django REST 模式" |
112
- | 文件结构偏好 | project | "测试放在 `__tests__/`"、"组件放在 `src/components/`" |
113
- | 代码风格 | project | "使用函数式风格"、"偏好 dataclasses" |
114
- | 安全实践 | global | "验证用户输入"、"清理 SQL" |
115
- | 通用最佳实践 | global | "先写测试"、"始终处理错误" |
116
- | 工具工作流 | global | "编辑前先搜索"、"写入前先读取" |
117
- | Git 实践 | global | "约定式提交"、"小而专注的提交" |
46
+ 写得下这一段,才说明它足够明确;写不下就不要持久化。
118
47
 
119
- ## Hook 观察层
48
+ ## 作用域判断
120
49
 
121
- ### 工作原理
50
+ | 类型 | 默认作用域 |
51
+ |---|---|
52
+ | 当前仓库验证命令、目录边界、提交习惯 | project |
53
+ | 用户长期偏好,但不含敏感信息 | personal,需确认 |
54
+ | 通用安全实践、证据先于断言 | global candidate,需多次证明 |
55
+ | 一次性任务背景、临时路径、失败日志 | 不持久化 |
122
56
 
123
- Hooks 是确定性的 — 只要事件触发,脚本就一定执行,不受模型理解偏差影响。与 prompt 指令不同,hooks 提供 100% 可靠的观察能力。
57
+ ## 证据质量
124
58
 
125
- ### 支持的 Hook 事件
59
+ 可用证据:
126
60
 
127
- **核心事件(Qoder + Qwen Code 均支持):**
61
+ - 用户明确纠正。
62
+ - 同一模式在多个任务中重复出现。
63
+ - 修复失败后验证证明某个流程更可靠。
64
+ - 仓库文档、测试或代码约束支持该规则。
128
65
 
129
- | Hook 事件 | 用途 | 触发频率 |
130
- |-----------|------|---------|
131
- | `PostToolUse` | 记录工具调用模式 | 每次工具调用后 |
132
- | `UserPromptSubmit` | 捕获用户纠正和偏好 | 每次用户输入后 |
133
- | `Stop` | 会话结束时触发汇总分析 | 每次 Agent 完成响应 |
66
+ 不可用证据:
134
67
 
135
- **扩展事件(仅 Qwen Code):**
68
+ - 模型自己的感觉。
69
+ - 单次偶然成功。
70
+ - 未读完整输出的命令结果。
71
+ - 涉及秘密、个人数据或生产数据的原文。
136
72
 
137
- | Hook 事件 | 用途 |
138
- |-----------|------|
139
- | `SessionStart` | 会话开始时加载已有 instincts |
140
- | `SessionEnd` | 会话结束时执行完整分析 |
141
- | `SubagentStop` | 子代理完成时记录其行为模式 |
73
+ ## 演化门槛
142
74
 
143
- ### 观察数据格式
144
-
145
- 每条观察记录为一行 JSON(JSONL 格式):
146
-
147
- ```json
148
- {
149
- "timestamp": "2026-04-14T10:30:00Z",
150
- "session_id": "sess_abc123",
151
- "event": "PostToolUse",
152
- "project_id": "a1b2c3d4e5f6",
153
- "tool_name": "Edit",
154
- "tool_input_summary": "Modified src/auth/login.ts: added input validation",
155
- "tool_outcome": "success",
156
- "context": "User had previously corrected missing validation"
157
- }
158
- ```
159
-
160
- **存储不存原始数据 — 只存摘要。** 工具输入和输出可能很大,只提取关键信息。
161
-
162
- ### 文件结构
163
-
164
- ```
165
- ~/.zc/homunculus/
166
- ├── observations.jsonl # 全局观察(无项目时的 fallback)
167
- ├── instincts/
168
- │ ├── personal/ # 全局自动学习的 instincts
169
- │ └── inherited/ # 全局导入的 instincts
170
- ├── projects/
171
- │ ├── a1b2c3d4e5f6/ # 项目 hash(git remote URL)
172
- │ │ ├── project.json # 项目元数据
173
- │ │ ├── observations.jsonl # 项目级观察
174
- │ │ └── instincts/
175
- │ │ └── personal/ # 项目级 instincts
176
- │ └── f6e5d4c3b2a1/ # 另一个项目
177
- │ └── ...
178
- └── projects.json # 项目注册表:hash → name/path/remote
179
- ```
75
+ instinct 升级为正式内容前,检查:
180
76
 
181
- ### 项目检测
77
+ - 是否至少出现多次,或由用户明确要求沉淀。
78
+ - 是否能写成清晰触发条件,而不是宽泛建议。
79
+ - 是否与现有 skill / command 重叠。
80
+ - 是否有验证方式或反例边界。
81
+ - 是否会增加常驻上下文负担。
182
82
 
183
- 系统自动检测当前项目:
83
+ 优先把稳定规则写进已有 skill 或项目文档;只有边界清楚、复用频繁时才新增 skill。
184
84
 
185
- 1. `git remote get-url origin` — hash 后生成可移植项目 ID(同仓库不同机器相同 ID)
186
- 2. `git rev-parse --show-toplevel` — 备选,使用仓库路径(机器特定)
187
- 3. 全局 fallback — 无法检测项目时,观察存入全局作用域
85
+ ## Hook 边界
188
86
 
189
- ## Hook 安装
87
+ Hook / automation 只能作为显式 opt-in 能力:
190
88
 
191
- ### 快速安装
89
+ - 安装前说明会记录什么、不记录什么、写到哪里。
90
+ - 默认只记录摘要,不记录完整工具输入输出。
91
+ - 支持关闭和清理。
92
+ - 平台事件名和配置方式必须以当前官方能力为准。
192
93
 
193
- 运行安装脚本自动配置 hooks:
94
+ 不要在内容层假设所有平台都支持同样的 hook 事件,也不要把 hook 当成默认运行前提。
194
95
 
195
- **macOS / Linux:**
196
- ```bash
197
- # 自动检测平台并安装
198
- bash skills/continuous-learning/hooks/setup.sh
96
+ ## 推荐输出
199
97
 
200
- # 指定平台适配器(按脚本支持情况选择)
201
- bash skills/continuous-learning/hooks/setup.sh --platform codex
202
- bash skills/continuous-learning/hooks/setup.sh --platform qwen-code
98
+ ```text
99
+ Recommendation: <不记录 / 记录为候选 / 写入项目规则 / 演化为 skill> because <证据、作用域和长期上下文代价>。
203
100
  ```
204
101
 
205
- **Windows (PowerShell 7+):**
206
- ```powershell
207
- # 自动检测平台并安装
208
- .\skills\continuous-learning\hooks\setup.ps1
209
-
210
- # 指定平台适配器(按脚本支持情况选择)
211
- .\skills\continuous-learning\hooks\setup.ps1 -Platform codex
212
- .\skills\continuous-learning\hooks\setup.ps1 -Platform qwen-code
213
-
214
- # 卸载
215
- .\skills\continuous-learning\hooks\setup.ps1 -Uninstall
216
- ```
217
-
218
- ### 手动配置
219
-
220
- 在你所使用平台支持的 hooks / automation 配置文件中接入观察脚本。下面只给出一个通用示意,实际键名和事件名应以目标平台官方文档为准:
221
-
222
- **macOS / Linux:**
223
- ```json
224
- {
225
- "hooks": {
226
- "PostToolUse": [{"matcher": "*", "hooks": [{"type": "command", "command": "~/.zc/hooks/continuous-learning/observe.sh"}]}],
227
- "UserPromptSubmit": [{"hooks": [{"type": "command", "command": "~/.zc/hooks/continuous-learning/observe.sh"}]}],
228
- "PostToolUseFailure": [{"matcher": "*", "hooks": [{"type": "command", "command": "~/.zc/hooks/continuous-learning/observe.sh"}]}],
229
- "Stop": [{"hooks": [{"type": "command", "command": "~/.zc/hooks/continuous-learning/session-end.sh"}]}]
230
- }
231
- }
232
- ```
233
-
234
- **Windows:**
235
- ```json
236
- {
237
- "hooks": {
238
- "PostToolUse": [{"matcher": "*", "hooks": [{"type": "command", "command": "pwsh -NoProfile -File \"~/.zc/hooks/continuous-learning/observe.ps1\""}]}],
239
- "UserPromptSubmit": [{"hooks": [{"type": "command", "command": "pwsh -NoProfile -File \"~/.zc/hooks/continuous-learning/observe.ps1\""}]}],
240
- "PostToolUseFailure": [{"matcher": "*", "hooks": [{"type": "command", "command": "pwsh -NoProfile -File \"~/.zc/hooks/continuous-learning/observe.ps1\""}]}],
241
- "Stop": [{"hooks": [{"type": "command", "command": "pwsh -NoProfile -File \"~/.zc/hooks/continuous-learning/session-end.ps1\""}]}]
242
- }
243
- }
244
- ```
245
-
246
- > **依赖要求**: macOS/Linux 版需要 `jq`,Windows 版使用 PowerShell 内置 JSON 处理,无额外依赖。
247
-
248
- ## 模式检测
249
-
250
- ### 检测类型
251
-
252
- | 模式类型 | 检测方法 | 置信度 |
253
- |---------|---------|--------|
254
- | **用户纠正** | UserPromptSubmit 中检测到"不要..."、"改用..."、纠正性指令 | 0.8+ |
255
- | **错误修复路径** | PostToolUseFailure → 后续成功的工具调用序列 | 0.6-0.7 |
256
- | **重复工作流** | 同一工具调用序列出现 3+ 次 | 0.5-0.6 |
257
- | **项目约定** | 代码风格/结构在多文件中保持一致 | 0.4-0.5 |
258
- | **明确教学** | 用户使用 `/learn save` 手动标记 | 0.9 |
259
-
260
- ### 检测示例
261
-
262
- ```
263
- 观察:用户三次在 Agent 使用 default export 后纠正为 named export
264
-
265
- 提取的 Instinct:
266
- id: prefer-named-exports
267
- trigger: "when creating TypeScript modules"
268
- action: "Use named exports, not default exports"
269
- confidence: 0.85
270
- domain: code-style
271
- scope: project
272
- evidence:
273
- - "User corrected default→named export (2026-04-10 session)"
274
- - "User corrected default→named export (2026-04-11 session)"
275
- - "User corrected default→named export (2026-04-12 session)"
276
- ```
277
-
278
- ## 双层持久化
279
-
280
- ### 本地文件层
281
-
282
- **优势:** 高频写入、低延迟、hooks 直接操作、跨会话持久。
283
-
284
- - `observations.jsonl` — 原始观察,append-only
285
- - `instincts/personal/*.yaml` — 提炼后的 instincts
286
-
287
- ### Agent Memory 层
288
-
289
- **优势:** 智能检索、跨项目共享、会话启动时自动加载。
290
-
291
- 当 instinct 置信度 >= 0.7 时,自动同步到 Agent Memory:
292
-
293
- ```
294
- Memory 存储格式:
295
- category: learned_skill_experience
296
- title: "Instinct: [trigger 摘要]"
297
- content: "[action] — 置信度 [confidence] — 证据: [evidence 摘要]"
298
- keywords: "[domain], instinct, [project_name]"
299
- scope: project | global(对应 instinct 的 scope)
300
- ```
301
-
302
- ### 同步策略
303
-
304
- - **文件 → Memory:** `/learn` 执行时,将高置信度 instincts 写入 Memory
305
- - **Memory → 文件:** 会话启动时,从 Memory 恢复 instincts(如果本地文件丢失)
306
- - **去重:** 使用 instinct ID 作为唯一键
307
-
308
- ## 演化路径
309
-
310
- ### Instinct → Skill/Command
311
-
312
- 当一组相关 instincts 满足以下条件时,可以演化为正式 skill 或 command:
313
-
314
- 1. **聚类条件:** 3+ 个相关 instincts,同一 domain
315
- 2. **置信度条件:** 平均置信度 >= 0.7
316
- 3. **覆盖条件:** instincts 覆盖一个完整的工作流或决策领域
317
-
318
- ### 提升规则(Project → Global)
319
-
320
- 当同一 instinct 在 2+ 个项目中出现且平均置信度 >= 0.8 时,自动提升为全局:
321
-
322
- ```
323
- 项目 A: prefer-explicit-errors (0.85)
324
- 项目 B: prefer-explicit-errors (0.80)
325
-
326
-
327
- 全局: prefer-explicit-errors (0.83) — 自动提升
328
- ```
329
-
330
- ## 命令接口
331
-
332
- | 命令 | 说明 |
333
- |------|------|
334
- | `/learn` | 分析当前会话,提取并展示 instincts |
335
- | `/learn status` | 显示所有 instincts(项目级 + 全局)及置信度 |
336
- | `/learn evolve` | 聚类相关 instincts,建议演化为 skill/command |
337
- | `/learn save [描述]` | 手动创建一个高置信度 instinct |
338
- | `/learn promote [id]` | 将项目级 instinct 提升为全局 |
339
- | `/learn export` | 导出 instincts 为文件 |
340
- | `/learn import [file]` | 从文件导入 instincts |
341
-
342
- ## 与其他技能的衔接
343
-
344
- - **sprint-retrospective** — Retro 的 Phase 7(Knowledge Capture)自动调用 `/learn` 提取本周期学习
345
- - **context-engineering** — 会话启动时自动加载相关 instincts 作为上下文
346
- - **sdd-tdd-workflow** — Phase 5 Reflect 中包含学习提取步骤
347
- - **verification-before-completion** — 验证过程中发现的模式(常见失败原因)自动记录
348
-
349
- ## Red Flags
350
-
351
- - Hook 脚本执行时间 > 2 秒(影响 Agent 响应速度)
352
- - Instincts 数量 > 100 个未清理(信息过载)
353
- - 相互矛盾的 instincts 同时存在(应合并或归档低置信度的)
354
- - 全局 instincts 包含项目特定内容(作用域错误)
355
- - 观察数据无限增长未归档(定期清理 observations.jsonl)
356
- - 跳过 `/learn` 直接手动创建 Memory(绕过置信度评估)
357
-
358
- ## Verification
359
-
360
- 设置完成后确认:
361
-
362
- - [ ] Hook 脚本已安装且有执行权限
363
- - [ ] `~/.zc/homunculus/` 目录结构已创建
364
- - [ ] PostToolUse hook 能正常记录观察(检查 observations.jsonl)
365
- - [ ] `/learn` 命令能正确分析并提取 instincts
366
- - [ ] 高置信度 instincts 已同步到 Agent Memory
367
- - [ ] 项目检测正常工作(检查 project.json)
102
+ 推荐必须说明被放弃的替代方案,例如“只留聊天结论”“写入 AGENTS”“新增 skill”,以及为什么当前选择更合适。
@@ -17,17 +17,45 @@
17
17
  ## 执行步骤
18
18
 
19
19
  1. 用 **产品视角** 检查是否在解决正确问题
20
- 2. 用 **工程视角** 检查架构、状态、失败模式和测试策略
20
+ 2. 用 **工程视角** 检查架构、数据流、状态、失败模式、边界条件、性能和测试策略
21
21
  3. 用 **设计视角** 检查交互、可用性、响应式和无障碍
22
22
  4. 用 **DevEx 视角** 检查计划中的集成成本、配置复杂度、文档前提、学习曲线和维护负担
23
23
  5. 把四个视角发现的问题改写成可执行的修订项、约束或验收标准
24
24
  6. 汇总结论,明确需要修订的点,再决定是否进入实现
25
25
 
26
+ ## 评审产物
27
+
28
+ 评审结果必须能回写到 plan / spec,而不是只形成聊天意见:
29
+
30
+ - `GO / REVISE / NO-GO` 结论
31
+ - 分级发现:`Critical / Warning / Suggestion`
32
+ - 每条发现对应的证据、影响和修订动作
33
+ - 对应的验收标准或验证命令
34
+ - 如果需要提问,最多 1-3 个会改变方案的关键问题
35
+
36
+ ## 推荐结论格式
37
+
38
+ 最终结论必须包含明确推荐和取舍:
39
+
40
+ ```text
41
+ Recommendation: <GO / REVISE / NO-GO + next action> because <specific cross-perspective trade-off>.
42
+ ```
43
+
44
+ 推荐理由至少说明:
45
+
46
+ - 哪个视角的证据最关键
47
+ - 放弃了什么替代方案
48
+ - 接受了什么代价或风险
49
+ - 下一步用什么验证或修订来收敛
50
+
51
+ 如果需要提问,每个问题都要说明它会解锁哪个决策,避免只收集背景信息。
52
+
26
53
  ## 边界说明
27
54
 
28
55
  - 这里的 DevEx 只评估“实现前是否想清楚”,不替代实现后的真实安装和上手走查
29
56
  - 如果代码已经落地,需要确认 getting started、安装链和首次成功路径是否真的成立,转到 `developer-experience-audit`
30
57
  - 不要把这里当成发布前体验签收清单;它的价值是提前暴露盲点,而不是事后补测
58
+ - 不引入重型运行时、遥测、自动升级或跨会话记忆作为评审前提;这些只能作为显式 opt-in 的后续能力讨论
31
59
 
32
60
  ## 成功标准
33
61
 
@@ -36,6 +64,7 @@
36
64
  - 每个视角都有具体 concern,而不是泛泛评价
37
65
  - DevEx 问题被表达为计划假设、约束或验收条件,而不是模糊感受
38
66
  - 最终结论可以明确是 `GO / REVISE / NO-GO`
67
+ - 评审输出能直接变成 plan 修订、任务依赖或验证门禁
39
68
 
40
69
  ## 相关原则
41
70