@haaaiawd/loom 0.10.0 → 1.0.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.
Files changed (44) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +87 -52
  3. package/cli/bin/loom.js +285 -99
  4. package/cli/help/concepts.md +93 -72
  5. package/cli/help/doctor.md +71 -121
  6. package/cli/help/loop.md +120 -135
  7. package/cli/help/patch.md +33 -0
  8. package/cli/help/preview.md +2 -1
  9. package/cli/help/version.md +92 -16
  10. package/cli/help/workflow.md +89 -100
  11. package/cli/src/activate.js +302 -73
  12. package/cli/src/diagnostics.js +138 -41
  13. package/cli/src/guide.js +41 -19
  14. package/cli/src/init.js +50 -29
  15. package/cli/src/intent-draft.js +303 -0
  16. package/cli/src/intent-map.js +540 -54
  17. package/cli/src/patch.js +214 -0
  18. package/cli/src/philosophy.js +177 -154
  19. package/cli/src/preview-prompt.md +13 -6
  20. package/cli/src/preview.js +1 -0
  21. package/cli/src/shared/intent-ref.js +38 -0
  22. package/cli/src/shared/proof-reference.js +19 -0
  23. package/cli/src/shared/verification-method.js +32 -0
  24. package/cli/src/verify.js +184 -61
  25. package/cli/src/version.js +5 -4
  26. package/dimensions/PART_DECOMPOSITION.md +42 -203
  27. package/dimensions/SEARCH_METHODOLOGY.md +101 -97
  28. package/dimensions/examples/AGENT_SYSTEM/README.md +1 -1
  29. package/dimensions/examples/CLI_TOOL/README.md +1 -1
  30. package/dimensions/universal/COLLABORATION_PHILOSOPHY.md +28 -77
  31. package/dimensions/universal/ENGINEERING_CREED.md +30 -74
  32. package/dimensions/universal/PRODUCT_PHILOSOPHY.md +32 -70
  33. package/meta/BASELINE.md +91 -276
  34. package/meta/INTENT_LOOP.md +242 -737
  35. package/meta/PHILOSOPHY_WEAVER.md +110 -343
  36. package/meta/ROLE_ACTIVATION.md +103 -267
  37. package/package.json +4 -3
  38. package/roles/architect.md +71 -111
  39. package/roles/forge.md +87 -126
  40. package/roles/keeper.md +99 -223
  41. package/roles/visionary.md +57 -86
  42. package/templates/INTENT_MAP_TEMPLATE.json +24 -10
  43. package/templates/PHILOSOPHY_TEMPLATE.md +44 -75
  44. package/templates/VISION_TEMPLATE.md +44 -67
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 haaaiawd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -8,15 +8,15 @@
8
8
 
9
9
  ## LOOM 是什么
10
10
 
11
- LOOM 是一个**规范驱动开发框架**,核心理念:
11
+ LOOM 是一个**哲学驱动的 Agent 质量框架**,核心理念:
12
12
 
13
- **不写死规范模板,让 Agent 根据项目特征从真实存在的思想体系中织造定制化哲学,作为所有开发角色的共同锚点。**
14
-
15
- LOOM 的核心机制:
16
- 1. **Philosophy Weaver** 根据项目特征织造定制化哲学
17
- 2. **Intent-Driven Loop** 以意图为 loop 单元,验证实现是否忠实于原始意图
18
- 3. **独立 Keeper** 作为子代理验证意图忠实度
19
- 4. **底线内化** 把不可妥协的约束写进哲学,角色激活时强制加载
13
+ **让 Agent 先拥有项目判断,再为当前任务编译专业能力;在可靠完成之上,通过比较与独立证据追求出众。**
14
+
15
+ LOOM 的核心机制:
16
+ 1. **Project Doctrine** 从项目事实中形成长期判断,而不是套用规范模板
17
+ 2. **Intent + Contract** 同时定义可靠完成的底线与可选的质量上限
18
+ 3. **Expertise Compiler** 为当前任务临时组装领域、品味、批评与验证能力
19
+ 4. **Quality Arena + Quality Proof** 用机制不同的候选和独立证据支撑质量提升
20
20
 
21
21
  ---
22
22
 
@@ -26,21 +26,24 @@ LOOM 的核心机制:
26
26
  |---|---|
27
27
  | **哲学** | 项目的价值观和工程原则——为什么存在、什么不做、冲突时谁优先。由 Weaver 从真实思想体系织造,不是模板填空 |
28
28
  | **Intent** | 一个意图单元——不是"做什么"(任务),是"为什么做"(意图)。每个 Intent 有验收契约,Keeper 据此判定实现是否忠实 |
29
- | **Intent Map** | 所有 Intent 的依赖图(JSON)。Architect 绘制,定义拓扑序和依赖关系 |
30
- | **Intent Loop** | 核心循环:Keeper 选 Intent → Forge 实现 → Keeper 验证 → 闭合或修正。每个 Intent 独立走一圈 |
31
- | **Keeper** | 独立验证子代理——不继承 Forge 的实现上下文,从磁盘重新加载意图和契约,判定 passed/deviated/blocked/pending_human |
29
+ | **Intent Map** | 所有 Intent 的依赖图(JSON)。Architect 绘制,定义拓扑序和依赖关系 |
30
+ | **Expertise Pack** | Forge 针对当前任务临时编译的专业认知,不成为永久规则 |
31
+ | **Quality Arena** | 以基线和机制不同候选进行探索、比较、实现与观察 |
32
+ | **Quality Proof** | Keeper 独立验证完成与质量声明,证据不足时不允许宣称提升 |
33
+ | **Intent Loop** | 选择 → 编译专业能力 → 实现/比较 → 独立证明 → 闭合或回流 |
34
+ | **Keeper** | 独立验证角色——不继承 Forge 的解释,从磁盘重新加载意图和契约 |
32
35
  | **底线** | 不可妥协的约束(BASELINE.md 5 条 + 项目特定底线)。角色激活时强制加载,哲学不能覆盖 |
33
36
 
34
37
  ### Intent Loop 怎么跑
35
38
 
36
39
  ```
37
- Keeper 选 Intent(拓扑序第一个 pending 且依赖都 completed 的)
38
-
39
- Keeper 更新 status → in_progress
40
+ Host/Orchestrator 选 Intent(拓扑序第一个 pending 且依赖都 completed 的)
41
+
42
+ Host/Orchestrator 更新 status → in_progress
40
43
 
41
- Forge 实现(加载意图叙事 + 哲学 + 验收契约)
42
-
43
- Keeper 验证(四维度:意图忠实度 / 哲学一致性 / 底线合规 / 验收达成)
44
+ Forge 编译 Expertise Pack,并在需要时运行 Quality Arena
45
+
46
+ Keeper 验证(基础四维;有质量契约时增加 quality_achievement,相对提升时附 Quality Proof)
44
47
 
45
48
  判定结果:
46
49
  passed → status → completed,回到选 Intent
@@ -49,7 +52,9 @@ Keeper 验证(四维度:意图忠实度 / 哲学一致性 / 底线合规 /
49
52
  pending_human → 等用户补充判定(L3 人类反馈,如游戏手感)
50
53
  ```
51
54
 
52
- **Loop 终止**:所有 Intent 的 status 为 completed → 项目阶段完成。
55
+ **Loop 终止**:所有 Intent 的 status 为 completed → 项目阶段完成。
56
+
57
+ 对会变更既有用户或系统状态的 Intent,Architect 设 `continuity_required: true`。它不创建第二份需求文档,而是要求同一份 acceptance 明确“哪些旧状态不得消失”与“旧状态 → 操作 → 新状态”的验证序列。此类 Intent 只有结果、守恒、可复现证据(以及按需的质量证明)同时通过,才允许闭合。
53
58
 
54
59
  ---
55
60
 
@@ -114,26 +119,25 @@ loom activate architect
114
119
  ```
115
120
 
116
121
  **输入**:愿景文档 + 哲学文档
117
- **Architect 会做什么**:设计系统结构 → 绘制 Intent Map(依赖图 + 验收契约 + 哲学锚点)
118
- **产出**:`.loom/v1/02_ARCHITECTURE.md` + `.loom/v1/04_INTENT_MAP.json`
119
- **怎么判断合格**:验收契约具体到可验证(不是"实现正确即可"),依赖关系无环,每个 Intent 有意图叙事引用
122
+ **Architect 会做什么**:设计系统边界 → 绘制 Intent Map 定义完成契约、按需的质量契约与专业能力需求
123
+ **产出**:`.loom/v1/02_ARCHITECTURE.md` + `.loom/v1/04_INTENT_MAP.json`
124
+ **怎么判断合格**:完成契约可观察,质量契约可比较,依赖无环,每个 Intent 有叙事引用
120
125
  **下一步**:进入 Intent Loop
121
126
 
122
127
  ### 步骤 5:进入 Intent Loop
123
128
 
124
129
  ```bash
125
130
  # Keeper 选 Intent 并更新状态
126
- loom activate keeper
127
- loom intent next # 查看下一个可执行 Intent
128
- loom intent update INT-001 --status in_progress
129
-
130
- # Forge 实现
131
- loom activate forge # Forge 加载意图叙事 + 哲学 + 验收契约,实现代码
132
-
133
- # Keeper 验证
134
- loom activate keeper # Keeper 独立验证四维度
135
- loom verify contract INT-001 # 查看验收契约
136
- loom verify write --json-file verification.json # 写入验证记录
131
+ loom intent next # 查看下一个可执行 Intent
132
+ loom intent update INT-001 --status in_progress
133
+
134
+ # Forge 编译专业能力并实现
135
+ loom activate forge --intent INT-001
136
+
137
+ # Keeper 独立形成 Quality Proof
138
+ loom activate keeper --intent INT-001
139
+ loom verify contract INT-001 # 查看验收契约
140
+ loom verify write --json-file verification.json # 写入验证记录
137
141
 
138
142
  # 根据判定结果
139
143
  loom intent update INT-001 --status completed # passed
@@ -160,8 +164,18 @@ preview 是人类总览用的只读投影:哲学、愿景、架构、Intent
160
164
  - 强行打开旧投影:`loom preview --stale`
161
165
 
162
166
  Agent 在用户说"看看进度 / 打开 preview / 看全局"时,先跑 `loom preview status`。
163
-
164
- **CLI 命令一览**:
167
+
168
+ **版本演进三档**:
169
+
170
+ | 档位 | 什么时候用 | LOOM 流程 |
171
+ |---|---|---|
172
+ | Patch | 不触及 Intent,只修 bug / 样式 / 实现细节 | 不走 Intent Loop;跑验证并用 `loom patch record` 记录 |
173
+ | Minor | 新增或修改 Intent,但不改变哲学前提、愿景北极星、架构边界 | 当前版本内变更;相关 Intent 进入 `pending` / `needs_review` |
174
+ | Major | 哲学前提、愿景北极星或架构边界变化 | `loom version new` 创建新版本,全套重跑 |
175
+
176
+ 当前版本全部完成后,运行 `loom guide` 会提示按三档判断,而不是默认开新版本。
177
+
178
+ **CLI 命令一览**:
165
179
 
166
180
  | 命令 | 用途 |
167
181
  |---|---|
@@ -170,28 +184,48 @@ Agent 在用户说"看看进度 / 打开 preview / 看全局"时,先跑 `loom
170
184
  | `loom guide --dry-run` | 只读诊断当前阶段,不写 heartbeat |
171
185
  | `loom auto on\|off\|status` | AUTO 模式开关 |
172
186
  | `loom activate <role>` | 输出角色激活提示词 |
187
+ | `loom activate <role> --intent <id>` | 输出仅含指定 draft/官方 Intent 的角色上下文 |
173
188
  | `loom preview` | 打开新鲜 HTML 预览;过期时提示重新生成 |
174
189
  | `loom preview status` | 检查 `loom-preview.html` 是否存在、是否新鲜 |
175
190
  | `loom preview --regen` | 输出提示词,让 Agent 重写 HTML 预览 |
176
191
  | `loom preview --stale` | 强行打开过期预览 |
177
- | `loom help <topic>` | 分层指南(workflow\|concepts\|loop\|version\|doctor\|preview) |
192
+ | `loom help <topic>` | 分层指南(workflow\|concepts\|loop\|version\|patch\|doctor\|preview) |
178
193
  | `loom version list` | 列出所有版本(* 标记当前) |
179
194
  | `loom version new` | 创建新版本 + 自动切换(Major 升级) |
180
195
  | `loom version use <v>` | 切换当前版本 |
181
- | `loom version diff <v1> <v2>` | 对比两个版本的文件差异 |
196
+ | `loom version diff <v1> <v2>` | 对比两个版本的文件差异 |
197
+ | `loom patch record --json-file <path>` | 写入权威 Patch JSON 并生成 Markdown 投影 |
198
+ | `loom patch list` | 列出当前版本 Patch |
199
+ | `loom patch get <id>` | 查看单条 Patch |
200
+ | `loom patch validate` | 校验 Patch ledger 和生成投影 |
182
201
  | `loom intent next` | 下一个可执行 Intent |
183
202
  | `loom intent status` | 进度概览 |
184
- | `loom intent get <id>` | Intent 详情 |
185
- | `loom intent narrative <id>` | Intent 意图叙事 |
186
- | `loom intent trace <id>` | Intent 完整追溯链(依赖+验证+哲学+叙事) |
203
+ | `loom intent get <id>` | Intent 详情 |
204
+ | `loom intent add --title <text> [--depends-on <ids>]` | 创建当前版本新增 Intent draft |
205
+ | `loom intent revise <id> --reason <text>` | 创建修订 draft 并报告反向依赖 |
206
+ | `loom intent draft <id>` | 查看 draft |
207
+ | `loom intent finalize <id> [--review <ids> --unaffected <ids>]` | 校验 draft 并原子更新官方 Map/topo_order;修订时必须分类全部下游影响 |
208
+ | `loom intent deprecate <id> --reason <text>` | 只读评估当前版本弃用影响;加 `--confirm` 并完整分类依赖方后原子写入 |
209
+ | `loom intent narrative <id>` | Intent 意图叙事 |
210
+ | `loom intent trace <id>` | Intent 完整追溯链(依赖+验证+哲学+叙事) |
211
+ | `loom intent diff <v1> <v2>` | 按显式 lineage 比较新建、修订、拆分、合并和未映射 Intent |
187
212
  | `loom intent reverse-dep <id>` | 反向依赖(谁依赖这个 Intent) |
188
213
  | `loom intent reverse-ref <anchor>` | 反向哲学引用(哪些 Intent 引用这个锚点) |
189
214
  | `loom intent update <id> --status <s>` | 更新状态(Keeper 用) |
190
- | `loom philosophy get <anchor>` | 加载哲学章节 |
191
- | `loom verify contract <id>` | 获取验收契约 |
192
- | `loom verify write --json-file <path>` | 写入验证记录 |
215
+ | `loom philosophy get <anchor>` | 加载哲学章节 |
216
+ | `loom philosophy impact <anchor>` | 只读返回直接引用该锚点的 Intent 及传递依赖影响 |
217
+ | `loom philosophy revise <anchor> --classification <clarification\|minor\|major> --reason <text>` | 只读评估哲学修订;clarification/minor 加 `--confirm` 和完整分区后写审计 ADR |
218
+ | `loom verify contract <id>` | 获取验收契约 |
219
+ | `loom verify write --json-file <path>` | 写入验证记录 |
220
+ | `loom verify history <ref> --across-versions` | 沿 predecessors 读取各 owning version 的本地验证历史 |
193
221
  | `loom doctor` | 项目健康检查 |
194
- | `loom context` | 上下文摘要(Agent 重启后一条命令获取状态) |
222
+ | `loom context` | 上下文摘要(Agent 重启后一条命令获取状态) |
223
+
224
+ 读命令 `intent get`、`intent narrative`、`intent trace` 和 `verify history` 支持 `v1:INT-003` 形式的跨版本引用;裸 ID 仍指当前版本。历史引用只读。跨版本沿革必须显式写在可选 `lineage.predecessors` 中,同 ID 或同标题不会建立映射,且 lineage 不属于 `depends_on`。
225
+
226
+ 弃用只适用于当前版本中已 `completed` 的 Intent。首次运行 `loom intent deprecate <id> --reason "<why>"` 只返回目标、直接/传递依赖方、各自状态和确认命令,不写文件。确认时用 `--review` 与 `--unaffected` 将所有依赖方恰好分类一次;叶子 Intent 不需要分类参数。弃用记录写入 `lifecycle.deprecation`,目标仍为 `completed`,依赖和契约不被修改。重复确认会明确失败。
227
+
228
+ 哲学修订由 CLI 分析后果和记录审计,不由 CLI 自动改写哲学文本。`philosophy impact` 与未确认的 `philosophy revise` 严格只读。确认 clarification 时全部受影响 Intent 必须归入 `--unaffected`;确认 minor 时可将确需重验的 Intent 归入 `--review`,其中 `completed` 才转为 `needs_review`。两者都不改 acceptance,并在 `03_DECISIONS/PHIL-REV-NNN.md` 记录审计。Major 永不修改当前版本,只返回 `loom version new`。
195
229
 
196
230
  ---
197
231
 
@@ -276,7 +310,7 @@ LOOM/
276
310
  | **Visionary** 远见者 | 产品联合创始人 | 定义愿景,织造意图叙事 | 项目启动 |
277
311
  | **Architect** 建筑师 | 系统建筑师 | 设计系统,绘制 Intent Map | Visionary 完成后 |
278
312
  | **Forge** 锻造师 | 高级工程师 | 在哲学约束下自主实现 | Intent Loop 实现阶段 |
279
- | **Keeper** 守护者 | 产品联合创始人(独立激活) | Intent,验证意图忠实度 | Intent Loop 选择和验证阶段 |
313
+ | **Keeper** 守护者 | 独立验证者(独立激活) | 从磁盘事实验证意图与质量主张 | Intent Loop 验证阶段 |
280
314
 
281
315
  Visionary 和 Keeper **同源但独立**——同一个产品哲学,但 Keeper 是"回溯验证者",作为子代理运行,不继承 Forge 的实现上下文。
282
316
 
@@ -285,7 +319,7 @@ Visionary 和 Keeper **同源但独立**——同一个产品哲学,但 Keeper
285
319
  ## Intent-Driven Loop
286
320
 
287
321
  ```
288
- Keeper 选 Intent → Forge 加载意图链并自主实现 → Keeper 子代理独立验证 → 判定
322
+ Host/Orchestrator 选 Intent → Forge 加载意图链并自主实现 → Keeper 子代理独立验证 → 判定
289
323
  ↑ │
290
324
  │ │
291
325
  └────────────── passed: 闭合,下一个 Intent ──────────────────────────┘
@@ -328,7 +362,8 @@ Agent 在项目中生成的文档结构:
328
362
  ├── 03_DECISIONS/ 架构决策记录
329
363
  ├── 04_INTENT_MAP.json 意图依赖图(DAG)
330
364
  ├── 05_VERIFICATION.md 每个 Intent 的验证契约
331
- ├── 06_CHANGELOG.md 版本变更记录
365
+ ├── 06_CHANGELOG.json Patch 变更记录(唯一权威来源)
366
+ ├── 06_CHANGELOG.md 确定性生成的只读投影
332
367
  └── verifications/ Keeper 的验证记录
333
368
  ├── INT-001.json
334
369
  ├── INT-001.md
@@ -352,8 +387,8 @@ Agent 通过 **CLI 访问** JSON,不直接读文件——省 token、更高效
352
387
  ## 运行流程
353
388
 
354
389
  ```
355
- 1. Philosophy Weaver 织造哲学
356
- 识别项目特征激活哲学维度逐维度搜索/萃取/转译/落地整合冲突 版本锚定
390
+ 1. Weaver 织造 Project Doctrine
391
+ 读取项目事实提炼长期判断按决策未知搜索转译为原则、边界与 Evidence Map
357
392
 
358
393
  2. Visionary 定义愿景
359
394
  → 基于哲学写愿景 → 每个意图带意图叙事 → 识别需要的哲学维度
@@ -361,9 +396,9 @@ Agent 通过 **CLI 访问** JSON,不直接读文件——省 token、更高效
361
396
  3. Architect 设计系统
362
397
  → 基于愿景设计结构 → 绘制 Intent Map → 定义验证契约
363
398
 
364
- 4. Intent Loop
365
- Keeper IntentForge 实现 → Keeper 验证 判定 → 下一个
366
- → 循环直到所有 Intent 闭合
399
+ 4. LOOM Quality Engine
400
+ Forge 编译 Expertise Pack Quality Arena 实现/比较 → Keeper 形成 Quality Proof
401
+ → 循环直到所有 Intent 闭合
367
402
  ```
368
403
 
369
404
  ---
@@ -375,7 +410,7 @@ Agent 通过 **CLI 访问** JSON,不直接读文件——省 token、更高效
375
410
  - [x] `templates/` 起点骨架(3 个模板)
376
411
  - [x] `README.md` 系统总览
377
412
  - [x] `dimensions/SEARCH_METHODOLOGY.md` 检索方法论
378
- - [x] `cli/` CLI 访问层(56 个测试全过)
413
+ - [x] `cli/` CLI 访问层(118 个测试全过)
379
414
  - [ ] `dimensions/` 维度文件(按需填充,Weaver 可自主判断)
380
415
 
381
416
  ---