pi-maestro-flow 0.2.0 → 0.3.1

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 (235) hide show
  1. package/README.md +44 -72
  2. package/agents/cross-role-reviewer.md +1 -1
  3. package/agents/impeccable-agent.md +1 -1
  4. package/agents/ralph-executor.md +1 -1
  5. package/agents/team-worker.md +1 -1
  6. package/agents/workflow-analyzer.md +1 -1
  7. package/agents/workflow-codebase-mapper.md +1 -1
  8. package/agents/workflow-collab-planner.md +1 -1
  9. package/agents/workflow-debugger.md +1 -1
  10. package/agents/workflow-executor.md +1 -1
  11. package/agents/workflow-integration-checker.md +1 -1
  12. package/agents/workflow-nyquist-auditor.md +1 -1
  13. package/agents/workflow-phase-researcher.md +1 -1
  14. package/agents/workflow-planner.md +1 -1
  15. package/agents/workflow-project-researcher.md +1 -1
  16. package/agents/workflow-reviewer.md +1 -1
  17. package/agents/workflow-verifier.md +1 -1
  18. package/package.json +18 -4
  19. package/skills/codify-to-knowhow/SKILL.md +1 -1
  20. package/skills/delegation-check/SKILL.md +1 -1
  21. package/skills/domain-add/SKILL.md +5 -5
  22. package/skills/insight-challenge/SKILL.md +1 -1
  23. package/skills/learn-decompose/SKILL.md +4 -4
  24. package/skills/learn-follow/SKILL.md +5 -5
  25. package/skills/learn-investigate/SKILL.md +5 -5
  26. package/skills/learn-second-opinion/SKILL.md +5 -5
  27. package/skills/maestro/SKILL.md +8 -8
  28. package/skills/maestro-amend/SKILL.md +4 -4
  29. package/skills/maestro-analyze/SKILL.md +9 -9
  30. package/skills/maestro-blueprint/SKILL.md +7 -7
  31. package/skills/maestro-brainstorm/SKILL.md +10 -10
  32. package/skills/maestro-collab/SKILL.md +4 -4
  33. package/skills/maestro-companion/SKILL.md +3 -3
  34. package/skills/maestro-composer/SKILL.md +10 -10
  35. package/skills/maestro-execute/SKILL.md +8 -8
  36. package/skills/maestro-fork/SKILL.md +7 -7
  37. package/skills/maestro-grill/SKILL.md +12 -12
  38. package/skills/maestro-guard/SKILL.md +5 -5
  39. package/skills/maestro-help/SKILL.md +3 -3
  40. package/skills/maestro-impeccable/SKILL.md +7 -7
  41. package/skills/maestro-init/SKILL.md +8 -8
  42. package/skills/maestro-merge/SKILL.md +6 -6
  43. package/skills/maestro-milestone-audit/SKILL.md +3 -3
  44. package/skills/maestro-milestone-complete/SKILL.md +8 -8
  45. package/skills/maestro-milestone-release/SKILL.md +9 -9
  46. package/skills/maestro-next/SKILL.md +5 -5
  47. package/skills/maestro-overlay/SKILL.md +19 -19
  48. package/skills/maestro-plan/SKILL.md +8 -8
  49. package/skills/maestro-player/SKILL.md +5 -5
  50. package/skills/maestro-quick/SKILL.md +5 -5
  51. package/skills/maestro-ralph/SKILL.md +15 -15
  52. package/skills/maestro-ralph-cli/SKILL.md +6 -6
  53. package/skills/maestro-ralph-cli-execute/SKILL.md +2 -2
  54. package/skills/maestro-ralph-execute/SKILL.md +4 -4
  55. package/skills/maestro-ralph-v2/SKILL.md +17 -17
  56. package/skills/maestro-roadmap/SKILL.md +7 -7
  57. package/skills/maestro-swarm-workflow/SKILL.md +9 -9
  58. package/skills/maestro-tools-execute/SKILL.md +5 -5
  59. package/skills/maestro-tools-register/SKILL.md +7 -7
  60. package/skills/maestro-ui-codify/SKILL.md +8 -8
  61. package/skills/maestro-universal-workflow/SKILL.md +15 -15
  62. package/skills/maestro-update/SKILL.md +10 -10
  63. package/skills/manage-codebase-rebuild/SKILL.md +4 -4
  64. package/skills/manage-drift-realign/SKILL.md +7 -7
  65. package/skills/manage-harvest/SKILL.md +5 -5
  66. package/skills/manage-issue/SKILL.md +4 -4
  67. package/skills/manage-issue-discover/SKILL.md +7 -7
  68. package/skills/manage-kg-extractors/SKILL.md +3 -3
  69. package/skills/manage-knowhow/SKILL.md +3 -3
  70. package/skills/manage-knowhow-capture/SKILL.md +4 -4
  71. package/skills/manage-knowledge-audit/SKILL.md +5 -5
  72. package/skills/manage-status/SKILL.md +3 -3
  73. package/skills/manage-wiki/SKILL.md +5 -5
  74. package/skills/odyssey-debug/SKILL.md +13 -13
  75. package/skills/odyssey-improve/SKILL.md +15 -15
  76. package/skills/odyssey-planex/SKILL.md +16 -16
  77. package/skills/odyssey-review-test-fix/SKILL.md +11 -11
  78. package/skills/odyssey-ui/SKILL.md +10 -10
  79. package/skills/prompt-generator/SKILL.md +5 -5
  80. package/skills/quality-auto-test/SKILL.md +3 -3
  81. package/skills/quality-debug/SKILL.md +3 -3
  82. package/skills/quality-refactor/SKILL.md +3 -3
  83. package/skills/quality-retrospective/SKILL.md +9 -9
  84. package/skills/quality-review/SKILL.md +4 -4
  85. package/skills/quality-sync/SKILL.md +3 -3
  86. package/skills/quality-test/SKILL.md +4 -4
  87. package/skills/scholar-anti-ai-writing/SKILL.md +1 -1
  88. package/skills/scholar-citation-verify/SKILL.md +1 -1
  89. package/skills/scholar-experiment/SKILL.md +2 -2
  90. package/skills/scholar-ideation/SKILL.md +7 -7
  91. package/skills/scholar-latex-organizer/SKILL.md +1 -1
  92. package/skills/scholar-publish/SKILL.md +3 -3
  93. package/skills/scholar-rebuttal-pro/SKILL.md +3 -3
  94. package/skills/scholar-review/SKILL.md +1 -1
  95. package/skills/scholar-writing/SKILL.md +1 -1
  96. package/skills/security-audit/SKILL.md +2 -2
  97. package/skills/skill-generator/SKILL.md +3 -3
  98. package/skills/skill-iter-tune/SKILL.md +3 -3
  99. package/skills/skill-simplify/SKILL.md +1 -1
  100. package/skills/skill-tuning/SKILL.md +1 -1
  101. package/skills/spec-add/SKILL.md +5 -5
  102. package/skills/spec-load/SKILL.md +3 -3
  103. package/skills/spec-remove/SKILL.md +4 -4
  104. package/skills/spec-setup/SKILL.md +6 -6
  105. package/skills/team-adversarial-swarm/SKILL.md +5 -5
  106. package/skills/team-arch-opt/SKILL.md +2 -2
  107. package/skills/team-brainstorm/SKILL.md +3 -3
  108. package/skills/team-coordinate/SKILL.md +4 -4
  109. package/skills/team-designer/SKILL.md +1 -1
  110. package/skills/team-executor/SKILL.md +3 -3
  111. package/skills/team-frontend/SKILL.md +2 -2
  112. package/skills/team-frontend-debug/SKILL.md +3 -3
  113. package/skills/team-interactive-craft/SKILL.md +2 -2
  114. package/skills/team-issue/SKILL.md +3 -3
  115. package/skills/team-lifecycle-v4/SKILL.md +4 -4
  116. package/skills/team-motion-design/SKILL.md +2 -2
  117. package/skills/team-perf-opt/SKILL.md +3 -3
  118. package/skills/team-planex/SKILL.md +2 -2
  119. package/skills/team-quality-assurance/SKILL.md +3 -3
  120. package/skills/team-review/SKILL.md +3 -3
  121. package/skills/team-roadmap-dev/SKILL.md +3 -3
  122. package/skills/team-swarm/SKILL.md +4 -4
  123. package/skills/team-tech-debt/SKILL.md +2 -2
  124. package/skills/team-testing/SKILL.md +3 -3
  125. package/skills/team-ui-polish/SKILL.md +2 -2
  126. package/skills/team-uidesign/SKILL.md +2 -2
  127. package/skills/team-ultra-analyze/SKILL.md +4 -4
  128. package/skills/team-ux-improve/SKILL.md +3 -3
  129. package/skills/team-visual-a11y/SKILL.md +2 -2
  130. package/skills/workflow-skill-designer/SKILL.md +8 -8
  131. package/templates/business-test-report.json +68 -0
  132. package/templates/config.json +48 -0
  133. package/templates/context.md +16 -0
  134. package/templates/doc-index.json +11 -0
  135. package/templates/index.json +68 -0
  136. package/templates/issue.json +36 -0
  137. package/templates/plan.json +38 -0
  138. package/templates/project.md +60 -0
  139. package/templates/reflection-log.md +20 -0
  140. package/templates/roadmap.md +45 -0
  141. package/templates/scratch-index.json +19 -0
  142. package/templates/search-tool.json +1 -0
  143. package/templates/search-tools.md +47 -0
  144. package/templates/state.json +18 -0
  145. package/templates/task-summary.md +21 -0
  146. package/templates/task.json +89 -0
  147. package/templates/terminology-template.json +22 -0
  148. package/templates/uat.md +21 -0
  149. package/templates/validation.json +31 -0
  150. package/templates/verification.json +37 -0
  151. package/templates/workflow.md +14 -0
  152. package/templates/worktree-scope.json +9 -0
  153. package/templates/worktrees.json +26 -0
  154. package/workflows/agy-instructions.md +156 -0
  155. package/workflows/analyze.md +768 -0
  156. package/workflows/auto-test.md +705 -0
  157. package/workflows/blueprint.md +406 -0
  158. package/workflows/boundary-grill.md +50 -0
  159. package/workflows/brainstorm.md +508 -0
  160. package/workflows/business-test.md +574 -0
  161. package/workflows/chinese-response.md +25 -0
  162. package/workflows/claude-instructions.md +167 -0
  163. package/workflows/codebase-rebuild.md +267 -0
  164. package/workflows/codebase-refresh.md +168 -0
  165. package/workflows/codex-instructions.md +156 -0
  166. package/workflows/coding-philosophy.md +70 -0
  167. package/workflows/command-authoring.md +823 -0
  168. package/workflows/debug.md +409 -0
  169. package/workflows/delegate-usage.md +99 -0
  170. package/workflows/domain-add.md +121 -0
  171. package/workflows/drift-realign.md +396 -0
  172. package/workflows/execute.md +631 -0
  173. package/workflows/explore-usage.md +93 -0
  174. package/workflows/finish-work.md +124 -0
  175. package/workflows/fork.md +162 -0
  176. package/workflows/grill.md +494 -0
  177. package/workflows/harvest.md +478 -0
  178. package/workflows/impeccable.md +168 -0
  179. package/workflows/init.md +157 -0
  180. package/workflows/instruction-authoring-guide.md +97 -0
  181. package/workflows/integration-test.md +186 -0
  182. package/workflows/interview-mechanics.md +8 -0
  183. package/workflows/issue-analyze.md +20 -0
  184. package/workflows/issue-discover.md +238 -0
  185. package/workflows/issue-execute.md +110 -0
  186. package/workflows/issue-gaps-analyze.codex.md +256 -0
  187. package/workflows/issue-gaps-analyze.md +215 -0
  188. package/workflows/issue-plan.md +110 -0
  189. package/workflows/issue.md +338 -0
  190. package/workflows/knowhow.md +429 -0
  191. package/workflows/knowledge-audit.md +355 -0
  192. package/workflows/learn.md +271 -0
  193. package/workflows/maestro-chain-execute.md +20 -0
  194. package/workflows/maestro-link-coordinate.md +114 -0
  195. package/workflows/maestro-super.md +120 -0
  196. package/workflows/maestro.md +501 -0
  197. package/workflows/map.md +74 -0
  198. package/workflows/merge.md +122 -0
  199. package/workflows/milestone-audit.md +155 -0
  200. package/workflows/milestone-complete.md +167 -0
  201. package/workflows/milestone-release.md +82 -0
  202. package/workflows/odyssey-base-codex.md +305 -0
  203. package/workflows/odyssey-base.md +256 -0
  204. package/workflows/overlays.md +109 -0
  205. package/workflows/plan.md +520 -0
  206. package/workflows/quick.md +350 -0
  207. package/workflows/ralph-amend-goal.md +177 -0
  208. package/workflows/refactor.md +87 -0
  209. package/workflows/retrospective.md +471 -0
  210. package/workflows/review.md +448 -0
  211. package/workflows/roadmap-common.md +193 -0
  212. package/workflows/roadmap.md +106 -0
  213. package/workflows/shell-exec-protocol.md +30 -0
  214. package/workflows/skill-authoring.md +265 -0
  215. package/workflows/spec-generate.md +475 -0
  216. package/workflows/specs-add.md +123 -0
  217. package/workflows/specs-load.md +76 -0
  218. package/workflows/specs-remove.md +104 -0
  219. package/workflows/specs-setup.md +316 -0
  220. package/workflows/status.md +149 -0
  221. package/workflows/sync.md +116 -0
  222. package/workflows/tdd.md +255 -0
  223. package/workflows/test-gen.md +226 -0
  224. package/workflows/test.md +385 -0
  225. package/workflows/tools-spec.md +70 -0
  226. package/workflows/ui-codify-extract.md +372 -0
  227. package/workflows/ui-codify-knowhow.md +258 -0
  228. package/workflows/ui-codify-package.md +159 -0
  229. package/workflows/ui-codify.md +227 -0
  230. package/workflows/ui-design.md +393 -0
  231. package/workflows/ui-style.md +201 -0
  232. package/workflows/verify.md +557 -0
  233. package/workflows/wiki-connect.md +153 -0
  234. package/workflows/wiki-digest.md +180 -0
  235. package/workflows/wiki-manage.md +113 -0
@@ -0,0 +1,355 @@
1
+ # Knowledge Audit Workflow
2
+
3
+ ---
4
+
5
+ ## Prerequisites
6
+
7
+ - `.workflow/` 已初始化(`.workflow/state.json` 存在)
8
+ - 至少一个目标存储有内容:
9
+ - `spec`: `.workflow/specs/*.md` 含 `<spec-entry>`
10
+ - `knowhow`: `maestro wiki list` 非空
11
+ - `artifact`: `.workflow/.{analysis,brainstorm,debug,lite-plan,lite-fix}/` 或 `state.json.artifacts[]` 非空
12
+ - 推荐:`harvest-log.jsonl` 存在(用于追溯 artifact 是否已抽取)
13
+
14
+ ---
15
+
16
+ ## Argument Shape
17
+
18
+ ```
19
+ /manage-knowledge-audit --scope all → 全量审查三存储(交互式)
20
+ /manage-knowledge-audit --scope spec --level P0 → 仅扫 spec 的 P0 问题
21
+ /manage-knowledge-audit --scope artifact --timeline T2,T3 → 仅查 milestone 失效与时间倒挂
22
+ /manage-knowledge-audit --scope all --since 2026-03-01 → 增量审查
23
+ /manage-knowledge-audit --scope spec --milestone M2 → 限定 milestone 上下文
24
+ /manage-knowledge-audit --scope all --report → 仅出报告不动盘
25
+ /manage-knowledge-audit --scope all --dry-run → 完整预演含交互
26
+ /manage-knowledge-audit --scope artifact --purge → 物理擦除(需双重确认)
27
+ ```
28
+
29
+ | Flag | Effect |
30
+ |------|--------|
31
+ | `--scope <type>` | **必选** spec / knowhow / artifact / all |
32
+ | `--level <P0\|P1\|P2>` | 仅展示该优先级(默认 all)|
33
+ | `--timeline <T1..T6>` | 仅运行指定时间线检测(逗号分隔)|
34
+ | `--since <YYYY-MM-DD>` | 仅审查该日期后修改的条目(增量模式)|
35
+ | `--milestone <name>` | 限定到某 milestone 上下文 |
36
+ | `--include-archive` | 把 `artifact_archive[]` 也纳入扫描 |
37
+ | `--interactive` | 三态决策交互(默认开启,除非 `--report`)|
38
+ | `--mark` | 非交互:仅注入 warning 标记,不删 |
39
+ | `--delete` | 非交互:自动软删(移 `.trash/`)|
40
+ | `--purge` | **危险** 物理擦除 artifact,需 `[y/N]` 二次确认 |
41
+ | `--dry-run` | 全流程预演,不写盘 |
42
+ | `--report` | 仅生成报告到 `.workflow/.knowledge-audit/` |
43
+
44
+ 互斥规则:`--purge` 不可与 `--dry-run` 同用;`--purge` 仅对 `--scope artifact|all` 生效。
45
+
46
+ ---
47
+
48
+ ## Stage 1: parse_input
49
+
50
+ ```
51
+ 验证 .workflow/ 存在(否则 E001)。解析参数:
52
+ scope: spec | knowhow | artifact | all (E002 若缺失/非法)
53
+ level: P0 | P1 | P2 | all(默认 all)
54
+ mode: interactive(默认)| mark | delete | purge | dry-run | report
55
+ filters: timeline[], since, milestone, include_archive
56
+
57
+ 互斥校验:
58
+ --purge + --dry-run → E003
59
+ --purge + scope != artifact|all → E004
60
+ --report → 强制覆盖 mode 为 read-only
61
+ 初始化 .workflow/.knowledge-audit/ 目录。
62
+ ```
63
+
64
+ ---
65
+
66
+ ## Stage 2: load_three_stores
67
+
68
+ 按 scope 加载,建立统一对象池:
69
+
70
+ ### 2a. Spec 加载
71
+
72
+ ```
73
+ glob .workflow/specs/*.md
74
+ 解析每个 <spec-entry category=... keywords=... date=... [id=...] [status=...] [supersedes=...]> 块
75
+ → SpecEntry { id?, file, line, category, keywords[], date, status?, supersedes?, content }
76
+ ```
77
+
78
+ 未来 schema 升级后 `id` / `status` / `supersedes` 为一等字段;当前未升级时按 `hash(file+title+date)` 生成 fallback id。
79
+
80
+ ### 2b. Knowhow 加载
81
+
82
+ ```
83
+ maestro wiki list --json → entries[]
84
+ 读 .workflow/knowhow/*.md → 解析 frontmatter
85
+ 合并: KnowhowEntry { slug, type, title, tags[], created_at, last_accessed?, content, code_refs[] }
86
+ ```
87
+
88
+ ### 2c. Artifact 加载
89
+
90
+ ```
91
+ 读 .workflow/state.json → artifacts[], artifact_archive[](若 --include-archive), milestones[]
92
+ glob .workflow/.{analysis,brainstorm,debug,lite-plan,lite-fix}/*/
93
+ 合并: Artifact { id, type, path, milestone?, created_at, completed_at?, mtime, harvested? }
94
+ harvested 通过 join .workflow/harvest/harvest-log.jsonl 的 source_id 字段确定
95
+ ```
96
+
97
+ ### 2d. since/milestone 过滤
98
+
99
+ 应用 `--since` 与 `--milestone` 收敛集合。
100
+
101
+ ---
102
+
103
+ ## Stage 3: build_timeline_index
104
+
105
+ ```
106
+ read state.json.milestones[] → { id: {status: active|completed|abandoned, started_at, ended_at?} }
107
+ for each entry (spec / knowhow / artifact):
108
+ age = today - entry.date_or_mtime
109
+ enclosing_milestone = find_milestone_at(entry.date_or_mtime)
110
+ enclosing_status = milestones[enclosing_milestone].status
111
+ // 用于 F 类(时间线)检测
112
+ build supersedes_graph: SpecEntry.supersedes → 有向图
113
+ build reverse_ref_graph: artifact ← session/spec/wiki 引用反向边
114
+ ```
115
+
116
+ ---
117
+
118
+ ## Stage 4: scenario_detection
119
+
120
+ **并行运行 8 类 detector,按优先级聚合 `AuditFinding[]`。**
121
+
122
+ ### A. 显性矛盾(Spec)
123
+
124
+ | 子类型 | 检测算法 | 优先级 |
125
+ |---|---|---|
126
+ | 行为禁忌冲突 | 同 keywords 簇内 LLM 极性对比(MUST DO vs MUST NOT) | P0 |
127
+ | 阈值冲突 | 正则抽数值 + 关键词聚类,比较区间是否冲突 | P0 |
128
+ | 命名规范冲突 | LLM 聚类 "naming convention" 规则查异 | P1 |
129
+
130
+ ### B. 隐性矛盾(Spec)
131
+
132
+ | 子类型 | 检测算法 | 优先级 |
133
+ |---|---|---|
134
+ | 跨域权衡 | 抽 security/debug/perf 关键词,交叉对抗推理 | P1 |
135
+ | 全局 vs 局部 | arch 文件规则 vs coding 局部规则的范围检测 | P1 |
136
+ | 传递性死锁 | 构建前置/后置条件图,检测环路 | P0 |
137
+ | 错误处理分歧 | 提取 throw/Result/Either 策略一致性 | P1 |
138
+
139
+ ### C. 失效老化(Spec / Knowhow)
140
+
141
+ | 子类型 | 检测算法 | 优先级 |
142
+ |---|---|---|
143
+ | 幽灵代码引用 | 抽 spec/knowhow 中的代码路径,`fs.exists` 校验 | P0 |
144
+ | 依赖版本过期 | 抽提及的库名,对照 `package.json`,LLM 判失效 | P1 |
145
+ | 外部配置违背 | 对照 `tsconfig.json` / `.eslintrc` / `biome.json` | P2 |
146
+ | 静默推翻 | date 排序找出未标 supersedes 的相反条目 | P0 |
147
+
148
+ ### D. 元数据质量(Spec / Knowhow)
149
+
150
+ | 子类型 | 检测算法 | 优先级 |
151
+ |---|---|---|
152
+ | 标签错位 | LLM 评估 keywords 与正文语义相关度 | P2 |
153
+ | 分类错位 | 内容 vs 文件归属语义判定 | P2 |
154
+ | 假规范 | LLM 评估是否可转化为具体 check(actionable)| P2 |
155
+ | 悬空 supersedes | 图遍历,目标 ID 不存在 | P0 |
156
+ | 循环 supersedes | DFS 检测环 | P0 |
157
+ | 状态倒挂 | active 条目依赖 deprecated 条目 | P1 |
158
+
159
+ ### E. Maestro 特化(Spec)
160
+
161
+ | 子类型 | 检测算法 | 优先级 |
162
+ |---|---|---|
163
+ | 项目宪法背离 | 加载 `workflows/impeccable/PRODUCT.md` 作真理对照 | P0 |
164
+ | TUI 原则碰撞 | 检测 "鼠标/hover" 等违反 keyboard sovereignty 的关键词 | P1 |
165
+ | 标签碎片化 | 统计 keywords 频次为 1 的孤儿标签 | P2 |
166
+
167
+ ### F. 时间线产物(Artifact)
168
+
169
+ | 子类型 | 触发条件 | 检测算法 | 优先级 |
170
+ |---|---|---|---|
171
+ | **T1 时间陈旧** | artifact.mtime > 90 天 且 harvested | mtime + harvest-log join | P1 |
172
+ | **T2 milestone 失效** | enclosing_milestone.status ∈ {abandoned, superseded} | state.json 时间线交叉 | P0 |
173
+ | **T3 时间倒挂** | artifact.mtime > parent_session.ended_at | session 元数据对比 | P1 |
174
+ | **T4 孤儿** | reverse_ref_graph 无入边,且 harvest-log 无记录 | 反向引用集为空 | P1 |
175
+ | **T5 跨 milestone 漂移** | 同主题 artifact 在 M1/M2/M3 都有,无 supersedes 链 | keywords 聚类 + date 排序 | P2 |
176
+ | **T6 archive 派生** | source_ref ∈ artifact_archive[] | join state.json.archive | P1 |
177
+
178
+ ### G. Knowhow 特有
179
+
180
+ | 子类型 | 检测算法 | 优先级 |
181
+ |---|---|---|
182
+ | wiki 引用代码不存在 | 抽 code_refs,磁盘校验 | P1 |
183
+ | 与新 spec 矛盾 | 向量相似 >0.85 后 LLM 矛盾判定 | P0 |
184
+ | 长期无访问冷门 | last_accessed > 90 天 | P2 |
185
+ | digest 漂移 | digest.created_at < 引用的原始 entry.mtime | P1 |
186
+
187
+ ### H. Artifact 特有
188
+
189
+ | 子类型 | 检测算法 | 优先级 |
190
+ |---|---|---|
191
+ | 已 graduate 但磁盘残留 | state.json.artifact_archive[].path 在磁盘仍存在 | P1 |
192
+ | milestone abandoned 未清 | milestone.status=abandoned 且 artifact 未归档 | P0 |
193
+ | 长期未引且无 harvest | T4 子集,age > 180 天 | P1 |
194
+ | accumulated_context 重复 spec | state.json.accumulated_context vs spec 语义查重 >70% | P2 |
195
+
196
+ 每个 detector 返回:
197
+ ```
198
+ AuditFinding {
199
+ id: "AUD-{8 hex}",
200
+ store: "spec" | "knowhow" | "artifact",
201
+ category: "A" | "B" | ... | "H",
202
+ subtype: string,
203
+ priority: "P0" | "P1" | "P2",
204
+ target: { file, line?, entry_id? },
205
+ evidence: string,
206
+ recommended_action: "keep" | "deprecate" | "delete" | "purge",
207
+ related_findings: [ids],
208
+ }
209
+ ```
210
+
211
+ 按 P0 → P1 → P2 排序,过滤 `--level`。
212
+
213
+ ---
214
+
215
+ ## Stage 5: interactive_triage
216
+
217
+ 若 `--report` → 跳过。
218
+ 若 `--mark|--delete|--purge` → 非交互应用 recommended_action。
219
+ 否则按 finding 顺序展示三态面板:
220
+
221
+ ```
222
+ [!] Conflict Detected (P0 - Ghost Code Reference)
223
+ Store: spec
224
+ Location: .workflow/specs/coding-conventions.md:42
225
+ Evidence: References non-existent file 'src/auth/legacy-token.ts'
226
+ Recommendation: [d]eprecate
227
+
228
+ Action? [k]eep / [d]eprecate / [D]elete / [s]kip / [a]ll-keep / [q]uit
229
+ > _
230
+ ```
231
+
232
+ **子分支拦截:**
233
+
234
+ | 条件 | 二次确认 |
235
+ |---|---|
236
+ | `[D]elete` 一个 artifact 且 harvest-log 无该 artifact | `This artifact has NO harvest records. Run /manage-harvest first? [Y/n]` |
237
+ | `--purge` 任意 artifact | `WARNING: --purge will permanently destroy {path} from disk. Type the artifact id to confirm:` |
238
+ | `[D]elete` 一个被其他 spec `supersedes` 引用的条目 | `This spec is referenced by N supersedes chains. Deleting will dangle them. Continue? [y/N]` |
239
+
240
+ `[a]ll-keep` 仅作用于当前 finding 的 subtype(不跨子类型)。
241
+
242
+ ---
243
+
244
+ ## Stage 6: backup
245
+
246
+ ```
247
+ mkdir .workflow/.trash/knowledge-audit-{ISO_timestamp}/
248
+ for finding in actionable_findings:
249
+ cp target.file → .trash/{timestamp}/{original_relative_path}
250
+ 也备份 state.json → .trash/{timestamp}/state.json.bak
251
+ 若任一备份失败 → E005,禁止 Stage 7
252
+ ```
253
+
254
+ ---
255
+
256
+ ## Stage 7: apply_actions
257
+
258
+ | Action | 实施 |
259
+ |---|---|
260
+ | `keep` | 写 `audit-log.jsonl` 一条 ignore 记录(防止下次重复 flag)|
261
+ | `supersede` (spec) | `maestro spec supersede <old-sid> --by <new-sid>`(双向链接 + deprecated,保留演化链) |
262
+ | `deprecate` (spec) | Edit 目标文件,把 `<spec-entry ...>` 改为 `<spec-entry ... status="deprecated">`(无替代条目时) |
263
+ | `deprecate` (knowhow) | `maestro wiki edit <slug>` 注入 `status: deprecated` frontmatter |
264
+ | `deprecate` (artifact) | 更新 state.json.artifacts[].status = "deprecated" |
265
+ | `delete` (spec) | Edit 移除整个 `<spec-entry>` 块 |
266
+ | `delete` (knowhow) | `maestro wiki delete <slug>` |
267
+ | `delete` (artifact) | mv artifact_dir → `.workflow/.trash/{timestamp}/` + state.json 移入 `artifact_archive[]` |
268
+ | `purge` (artifact only) | `rm -rf` 物理路径 + state.json 完全移除条目 |
269
+
270
+ **变更 state.json 时**:先写 `state.json.backup-audit-{timestamp}`,再写新版本,re-read 验证 artifacts 计数符合预期。
271
+
272
+ ---
273
+
274
+ ## Stage 8: report
275
+
276
+ 写 `.workflow/.knowledge-audit/audit-report-{date}.md`:
277
+
278
+ ```markdown
279
+ # Knowledge Audit Report — {date}
280
+
281
+ ## Scope
282
+ - Scope: {spec|knowhow|artifact|all}
283
+ - Filters: {level, timeline, since, milestone}
284
+
285
+ ## Detection Summary
286
+ - Total findings: {N} ({P0_count} P0 / {P1_count} P1 / {P2_count} P2)
287
+ - By store: spec {N} / knowhow {N} / artifact {N}
288
+ - By category: A{N} B{N} C{N} D{N} E{N} F{N} G{N} H{N}
289
+
290
+ ## Actions Applied
291
+ | # | Store | Category | Subtype | Target | Action | Status |
292
+ |---|-------|----------|---------|--------|--------|--------|
293
+ | 1 | spec | C-ghost | code-ref| coding-conventions.md:42 | deprecate | OK |
294
+ | 2 | artifact | F-T2 | milestone-dead | .workflow/.analysis/ANL-003/ | delete | OK |
295
+
296
+ ## Skipped (kept by user)
297
+ | Finding | Reason |
298
+ |---------|--------|
299
+ | AUD-abc | User chose keep — marked as ignored |
300
+
301
+ ## Backup
302
+ - Tarball: .workflow/.trash/knowledge-audit-{timestamp}/
303
+ - state.json backup: state.json.backup-audit-{timestamp}
304
+ ```
305
+
306
+ 同时追加结构化条目到 `.workflow/.knowledge-audit/audit-log.jsonl`:
307
+
308
+ ```json
309
+ {
310
+ "audit_id": "AUD-{timestamp}",
311
+ "finding_id": "AUD-{8 hex}",
312
+ "store": "spec",
313
+ "category": "C",
314
+ "subtype": "ghost-code-ref",
315
+ "priority": "P0",
316
+ "target": {"file": "...", "line": 42, "entry_id": "..."},
317
+ "action": "deprecate",
318
+ "applied_at": "<ISO>",
319
+ "backup_path": "..."
320
+ }
321
+ ```
322
+
323
+ 显示摘要:
324
+
325
+ ```
326
+ === AUDIT COMPLETE ===
327
+ Scope: all
328
+
329
+ Findings: 28 total (5 P0 / 12 P1 / 11 P2)
330
+ Spec: 8 deprecated, 2 deleted, 3 kept
331
+ Knowhow: 4 deprecated, 1 deleted, 2 kept
332
+ Artifact: 3 deleted (2 to .trash, 1 purged), 5 kept
333
+
334
+ Report: .workflow/.knowledge-audit/audit-report-2026-05-22.md
335
+ Backup: .workflow/.trash/knowledge-audit-20260522T154500/
336
+
337
+ Next:
338
+ → 抢救未抽取 artifact: /manage-harvest <ids>
339
+ → 验证现状: /spec-load --role implement
340
+ → 复审 wiki 状态: maestro wiki list --status deprecated
341
+ → 周期巡检 (建议): milestone 结束时跑 --scope all --report
342
+ ```
343
+
344
+ ---
345
+
346
+ ### Safety invariants
347
+
348
+ 1. **Deprecate over delete** — 文本存储默认注入 `status=deprecated` 而非物理移除,保留历史上下文
349
+ 2. **Backup before mutate** — Stage 6 失败则禁止 Stage 7;state.json 原子写(备份 → 写新 → re-read 校验)
350
+ 3. **Purge restricted** — `--purge` 仅限 artifact scope;spec/knowhow 永不物理删除(最多 delete 到 `.trash/`)
351
+ 4. **Double confirmation** — `--purge` 需 flag + 交互输入 artifact id 双重确认
352
+ 5. **Rescue before delete** — 删 artifact 前若 harvest-log 无记录,强制提示先跑 `/manage-harvest`
353
+ 6. **No dedup re-run** — audit 不做"是否重复"判断(harvest 负责),只做"是否矛盾/失效/老化"
354
+ 7. **Graceful degradation** — LLM detector 不可用时跳过 B/G 类语义场景,A/D/F 类正则+图算法仍可执行; Stage 8 报告加 partial_audit: true, skipped: [B,G] 并标 [LOW CONFIDENCE]
355
+ 8. **Idempotent** — 同一存储状态下重跑 `--dry-run` 必须输出一致的 finding 集
@@ -0,0 +1,271 @@
1
+ # Learn Workflow
2
+
3
+ Storage:
4
+ - `.workflow/specs/learnings.md` — append-only container of `<spec-entry>` sub-entries (shared with retrospective output)
5
+ - Auto-indexed by WikiIndexer (no manual index required)
6
+
7
+ ---
8
+
9
+ ## Prerequisites
10
+
11
+ - `.workflow/` initialized (`.workflow/state.json` exists). If missing, error E001.
12
+ - The `specs/` directory and `learnings.md` are created on first use; do not require them to exist upfront.
13
+
14
+ ---
15
+
16
+ ## Argument Shape
17
+
18
+ ```
19
+ /manage-learn "<insight text>" → capture, infer category, auto-link phase
20
+ /manage-learn "<insight>" --category pattern --keywords auth,jwt → capture with explicit category and keywords
21
+ /manage-learn list → show recent 20 insights
22
+ /manage-learn list --keywords auth → filtered list
23
+ /manage-learn search <query> → search via maestro wiki search
24
+ /manage-learn show <INS-id> → full insight + linked phase context
25
+ ```
26
+
27
+ | Flag | Effect |
28
+ |------|--------|
29
+ | `--category <name>` | One of: pattern, antipattern, decision, tool, gotcha, technique, tip. Default: inferred (tip mode defaults to `tip`). |
30
+ | `--keywords t1,t2` | Comma-separated keywords. Insight mode implicitly adds `manual`, tip mode implicitly adds `tip`. |
31
+ | `--phase <N>` | Override auto-detected phase link. Use `--phase 0` to force "no phase". |
32
+ | `--confidence <level>` | high / medium / low. Default: medium (insight), low (tip). |
33
+ | `--lens <name>` | Filter by retrospective lens: technical, process, quality, decision, git (list/search only). |
34
+ | `--limit <N>` | List mode row limit (default 20). |
35
+
36
+ ---
37
+
38
+ ## Stage 1: parse_input
39
+
40
+ ```
41
+ Verify .workflow/ exists (else E001). Route by first token:
42
+ "list" → list | "search" → search (next token = query) | "show" → show (next token = INS-id)
43
+ "tip" → tip capture (source="tip", category="tip", confidence="low", implicit keyword "tip")
44
+ else → capture mode (full quoted text = insight body)
45
+ Empty args → AskUserQuestion. Invalid --category → E002.
46
+ ```
47
+
48
+ ---
49
+
50
+ ## Stage 2: capture mode
51
+
52
+ ### Step 2.1: Bootstrap storage
53
+
54
+ ```bash
55
+ SPECS_DIR=".workflow/specs"
56
+ INSIGHTS_FILE="$SPECS_DIR/learnings.md"
57
+
58
+ mkdir -p "$SPECS_DIR"
59
+
60
+ if [ ! -f "$INSIGHTS_FILE" ]; then
61
+ cat > "$INSIGHTS_FILE" << 'EOF'
62
+ ---
63
+ title: "Learning Insights"
64
+ type: spec
65
+ roles: [implement]
66
+ tags: [insights, learning]
67
+ created: $(date -u +%Y-%m-%dT%H:%M:%SZ)
68
+ ---
69
+ # Learning Insights
70
+
71
+ Atomic insights captured during active work.
72
+
73
+ ## Entries
74
+
75
+ EOF
76
+ fi
77
+ ```
78
+
79
+ ### Step 2.2: Generate ID
80
+
81
+ `INS-{8 lowercase hex chars}` from a stable hash of `(insight_text + timestamp)`. Re-running with the same text produces a different id (timestamp differs), so accidental duplicates are still appended — duplicate detection is the user's job at search time.
82
+
83
+ ### Step 2.3: Auto-detect phase link
84
+
85
+ Unless `--phase` is set:
86
+ ```
87
+ From .workflow/state.json artifacts, detect current phase:
88
+ 1. Find first artifact with type=execute, status=in_progress
89
+ 2. Else find first phase without a completed execute artifact
90
+ 3. Resolve phase_slug from matching artifact (fallback: "phase-{N}")
91
+ If no state.json → phase=null, phase_slug=null
92
+ ```
93
+
94
+ If `--phase 0` is passed, force `phase = null, phase_slug = null` regardless.
95
+
96
+ ### Step 2.4: Infer category (if --category not set)
97
+
98
+ Simple keyword heuristics — no LLM call. Match the insight text (lowercased) against keyword sets in priority order:
99
+
100
+ | Category | Keywords (any match wins) |
101
+ |----------|---------------------------|
102
+ | antipattern | "avoid", "don't", "never", "anti-pattern", "antipattern", "bug", "broken", "fails", "wrong" |
103
+ | gotcha | "gotcha", "surprise", "unexpected", "hidden", "easy to miss", "watch out", "footgun" |
104
+ | decision | "decided", "chose", "rationale", "trade-off", "tradeoff", "instead of", "rejected" |
105
+ | tool | "library", "package", "tool", "cli", "framework", "version" |
106
+ | pattern | "pattern", "convention", "always", "should", "use", "prefer", "standardize" |
107
+ | technique | (default fallback) |
108
+
109
+ First match wins. If nothing matches, category = `technique`.
110
+
111
+ ### Step 2.5: Build spec-entry
112
+
113
+ ```
114
+ entry = <spec-entry
115
+ category="{category}"
116
+ keywords="{category},{parsed --keywords values joined by comma}"
117
+ date="{YYYY-MM-DD}"
118
+ id="INS-{hex}"
119
+ source="manual"
120
+ >
121
+
122
+ ### {title: first 80 chars of insight text, truncated on word boundary}
123
+
124
+ {full insight text}
125
+
126
+ - **Phase**: {phase or "none"} ({phase_slug or "—"})
127
+ - **Confidence**: {--confidence value or "medium"}
128
+ - **Tags**: {parsed --keywords values + ["manual"]}
129
+
130
+ </spec-entry>
131
+ ```
132
+
133
+ ### Step 2.6: Persist
134
+
135
+ Append the `<spec-entry>` block to `.workflow/specs/learnings.md`.
136
+
137
+ WikiIndexer auto-indexes the entry — no manual index update required.
138
+
139
+ ### Step 2.7: Confirmation banner
140
+
141
+ Display: ID, category, confidence, tags, phase (+slug if present), title, file path, and hints for `list` / `search` commands.
142
+
143
+ ---
144
+
145
+ ## Stage 3: list mode
146
+
147
+ ### Step 3.1: Read entries
148
+
149
+ Query via `maestro wiki list --type knowhow --role implement --json`. Filter by `--keywords`, `--category`, `--phase`, `--lens` flags. Sort by timestamp descending. Limit to 20 (or `--limit N`).
150
+
151
+ ### Step 3.2: Display table
152
+
153
+ ```
154
+ === KNOWHOW INSIGHTS ({shown}/{total}) ===
155
+
156
+ ID Category Phase Conf Tags Title
157
+ ────────────── ────────── ────── ───── ─────────────────── ────────────────────────────
158
+ INS-a1b2c3d4 pattern 1 high auth,jwt,security JWT refresh tokens must rota...
159
+ INS-b2c3d4e5 gotcha — med redis Redis MULTI not transactional...
160
+ INS-c3d4e5f6 decision 2 high manual,arch Chose Express over Fastify b...
161
+ ...
162
+
163
+ Filters: {active filters or "none"}
164
+
165
+ View: Skill({ skill: "manage-learn", args: "show <INS-id>" })
166
+ Search: Skill({ skill: "manage-learn", args: "search <query>" })
167
+ Capture: Skill({ skill: "manage-learn", args: "<insight text>" })
168
+ ```
169
+
170
+ If empty:
171
+ ```
172
+ No insights yet.
173
+ Capture your first: Skill({ skill: "manage-learn", args: "\"...\"" })
174
+ ```
175
+
176
+ ---
177
+
178
+ ## Stage 4: search mode
179
+
180
+ ### Step 4.1: Validate query
181
+
182
+ Next token after "search". Empty → AskUserQuestion.
183
+
184
+ ### Step 4.2: Search via wiki
185
+
186
+ Execute `maestro wiki search "<query>" --type knowhow --json`. Results are ranked by BM25 relevance. Sort by rank desc, then date desc.
187
+
188
+ ### Step 4.3: Display results
189
+
190
+ ```
191
+ === SEARCH RESULTS for "{query}" — {count} match{es} ===
192
+
193
+ [{INS-id}] [{category}] phase {phase or "—"} ({source})
194
+ {title}
195
+ Tags: {tags}
196
+ Captured: {captured_at}
197
+
198
+ [{INS-id}] ...
199
+ ...
200
+
201
+ View full: Skill({ skill: "manage-learn", args: "show <INS-id>" })
202
+ ```
203
+
204
+ If no matches:
205
+ ```
206
+ No insights match "{query}".
207
+ List all: Skill({ skill: "manage-learn", args: "list" })
208
+ ```
209
+
210
+ ---
211
+
212
+ ## Stage 5: show mode
213
+
214
+ ### Step 5.1: Locate entry
215
+
216
+ Find `<spec-entry>` matching target INS-id in `learnings.md`. Missing arg → E003. Not found → E004.
217
+
218
+ ### Step 5.2: Resolve linked phase context (if any)
219
+
220
+ If `entry.phase_slug` set (parsed from entry content): look up phase directory from `state.json` artifacts, read its `index.json` for title/status, check for `retrospective.md`.
221
+
222
+ ### Step 5.3: Resolve routed artifact (if any)
223
+
224
+ Map `routed_to` → path: `spec` → `.workflow/specs/{id}`, `issue` → `.workflow/issues/issues.jsonl#{id}`, `knowhow` → `.workflow/knowhow/{id}.md`.
225
+
226
+ ### Step 5.4: Display
227
+
228
+ ```
229
+ =========================================
230
+ INSIGHT: {entry.id}
231
+ CATEGORY: {entry.category}
232
+ CONFIDENCE: {entry.confidence}
233
+ SOURCE: {entry.source}{IF entry.lens: " (" + entry.lens + " lens)"}
234
+ =========================================
235
+
236
+ CAPTURED: {entry.date}
237
+ PHASE: {entry.phase or "none"}{IF phase_slug: " (" + phase_slug + ")"}
238
+ TAGS: {entry.keywords}
239
+
240
+ TITLE:
241
+ {entry.title}
242
+
243
+ SUMMARY:
244
+ {entry.content}
245
+
246
+ EVIDENCE:
247
+ {parsed from entry content, or "(none — manual capture)"}
248
+
249
+ ROUTED:
250
+ Target: {entry.routed_to or "none"}
251
+ ID: {entry.routed_id or "—"}
252
+ Path: {routed_path or "—"}
253
+
254
+ {IF phase_context:}
255
+ PHASE CONTEXT:
256
+ Title: {phase_context.title}
257
+ Status: {phase_context.status}
258
+ Retrospective: {phase_context.retrospective_exists ? "yes" : "no"}
259
+ =========================================
260
+ ```
261
+
262
+ ---
263
+
264
+ ## Relationship to other workflows
265
+
266
+ | Workflow | Relationship |
267
+ |----------|--------------|
268
+ | `quality-retrospective` | Producer. Appends `<spec-entry>` to the same `specs/learnings.md` with `source: "retrospective"` and a populated `lens` field. |
269
+ | `manage-knowhow-capture` | Sibling. Captures session state for recovery; `learn` captures timeless insights. Both write to `.workflow/knowhow/` with different prefixes. |
270
+ | `phase-transition` | Reader (informally). Phase-transition's free-form `.workflow/specs/learnings.md` is a distinct file with a different audience; do not merge them. |
271
+ | `maestro-plan` | Future consumer. Should query via `maestro wiki search` or `maestro wiki list --type knowhow --role implement` to inform planning decisions. (Out of scope for this command.) |
@@ -0,0 +1,20 @@
1
+ # Workflow: maestro-chain-execute [DEPRECATED]
2
+
3
+ > **DEPRECATED**: This workflow has been replaced by the unified executor `maestro-ralph-execute`.
4
+ > Both maestro and ralph sessions now use `maestro-ralph-execute` for step execution.
5
+ > This file is kept for reference only and will be removed in a future version.
6
+
7
+ ## Migration
8
+
9
+ - Caller dispatching from `maestro.md` → use `Skill({ skill: "maestro-ralph-execute" })`
10
+ - Resume from session → `Skill({ skill: "maestro-ralph-execute" })` (auto-discovers latest running session via `.workflow/.maestro/*/status.json`)
11
+
12
+ ## References
13
+
14
+ - `~/.maestro/workflows/maestro.md` — coordinator that creates sessions and dispatches to the unified executor
15
+ - `~/.maestro/workflows/maestro-ralph-execute.md` — current canonical executor (handles both maestro static chains and ralph adaptive chains)
16
+
17
+ The unified executor preserves all behaviour previously documented here:
18
+ status.json persistence, TodoWrite dual-tracking, per-step engine selection (`Skill` vs `CLI`),
19
+ context propagation across steps, post-step Gemini analysis for CLI steps,
20
+ and retry/skip/abort on failure.