@haoyiyin/workflow 0.2.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 (223) hide show
  1. package/README.md +168 -0
  2. package/SETUP.md +71 -0
  3. package/SKILL.md +68 -0
  4. package/USAGE.md +152 -0
  5. package/dist/bin/yi-workflow.d.ts +3 -0
  6. package/dist/bin/yi-workflow.d.ts.map +1 -0
  7. package/dist/bin/yi-workflow.js +39 -0
  8. package/dist/bin/yi-workflow.js.map +1 -0
  9. package/dist/src/agents/contracts.d.ts +120 -0
  10. package/dist/src/agents/contracts.d.ts.map +1 -0
  11. package/dist/src/agents/contracts.js +431 -0
  12. package/dist/src/agents/contracts.js.map +1 -0
  13. package/dist/src/agents/dispatcher-enhanced.d.ts +68 -0
  14. package/dist/src/agents/dispatcher-enhanced.d.ts.map +1 -0
  15. package/dist/src/agents/dispatcher-enhanced.js +290 -0
  16. package/dist/src/agents/dispatcher-enhanced.js.map +1 -0
  17. package/dist/src/agents/dispatcher.d.ts +107 -0
  18. package/dist/src/agents/dispatcher.d.ts.map +1 -0
  19. package/dist/src/agents/dispatcher.js +454 -0
  20. package/dist/src/agents/dispatcher.js.map +1 -0
  21. package/dist/src/agents/index.d.ts +11 -0
  22. package/dist/src/agents/index.d.ts.map +1 -0
  23. package/dist/src/agents/index.js +10 -0
  24. package/dist/src/agents/index.js.map +1 -0
  25. package/dist/src/agents/resilience.d.ts +86 -0
  26. package/dist/src/agents/resilience.d.ts.map +1 -0
  27. package/dist/src/agents/resilience.js +183 -0
  28. package/dist/src/agents/resilience.js.map +1 -0
  29. package/dist/src/agents/token-budget.d.ts +47 -0
  30. package/dist/src/agents/token-budget.d.ts.map +1 -0
  31. package/dist/src/agents/token-budget.js +63 -0
  32. package/dist/src/agents/token-budget.js.map +1 -0
  33. package/dist/src/agents/types.d.ts +59 -0
  34. package/dist/src/agents/types.d.ts.map +1 -0
  35. package/dist/src/agents/types.js +5 -0
  36. package/dist/src/agents/types.js.map +1 -0
  37. package/dist/src/guard/main-agent.d.ts +72 -0
  38. package/dist/src/guard/main-agent.d.ts.map +1 -0
  39. package/dist/src/guard/main-agent.js +184 -0
  40. package/dist/src/guard/main-agent.js.map +1 -0
  41. package/dist/src/hooks/builtin/index.d.ts +9 -0
  42. package/dist/src/hooks/builtin/index.d.ts.map +1 -0
  43. package/dist/src/hooks/builtin/index.js +9 -0
  44. package/dist/src/hooks/builtin/index.js.map +1 -0
  45. package/dist/src/hooks/builtin/on-error.d.ts +7 -0
  46. package/dist/src/hooks/builtin/on-error.d.ts.map +1 -0
  47. package/dist/src/hooks/builtin/on-error.js +15 -0
  48. package/dist/src/hooks/builtin/on-error.js.map +1 -0
  49. package/dist/src/hooks/builtin/post-execute.d.ts +7 -0
  50. package/dist/src/hooks/builtin/post-execute.d.ts.map +1 -0
  51. package/dist/src/hooks/builtin/post-execute.js +30 -0
  52. package/dist/src/hooks/builtin/post-execute.js.map +1 -0
  53. package/dist/src/hooks/builtin/post-plan.d.ts +7 -0
  54. package/dist/src/hooks/builtin/post-plan.d.ts.map +1 -0
  55. package/dist/src/hooks/builtin/post-plan.js +15 -0
  56. package/dist/src/hooks/builtin/post-plan.js.map +1 -0
  57. package/dist/src/hooks/builtin/pre-execute.d.ts +7 -0
  58. package/dist/src/hooks/builtin/pre-execute.d.ts.map +1 -0
  59. package/dist/src/hooks/builtin/pre-execute.js +22 -0
  60. package/dist/src/hooks/builtin/pre-execute.js.map +1 -0
  61. package/dist/src/hooks/builtin/pre-plan.d.ts +7 -0
  62. package/dist/src/hooks/builtin/pre-plan.d.ts.map +1 -0
  63. package/dist/src/hooks/builtin/pre-plan.js +19 -0
  64. package/dist/src/hooks/builtin/pre-plan.js.map +1 -0
  65. package/dist/src/hooks/index.d.ts +8 -0
  66. package/dist/src/hooks/index.d.ts.map +1 -0
  67. package/dist/src/hooks/index.js +4 -0
  68. package/dist/src/hooks/index.js.map +1 -0
  69. package/dist/src/hooks/loader.d.ts +16 -0
  70. package/dist/src/hooks/loader.d.ts.map +1 -0
  71. package/dist/src/hooks/loader.js +77 -0
  72. package/dist/src/hooks/loader.js.map +1 -0
  73. package/dist/src/hooks/manager.d.ts +20 -0
  74. package/dist/src/hooks/manager.d.ts.map +1 -0
  75. package/dist/src/hooks/manager.js +76 -0
  76. package/dist/src/hooks/manager.js.map +1 -0
  77. package/dist/src/hooks/types-enhanced.d.ts +30 -0
  78. package/dist/src/hooks/types-enhanced.d.ts.map +1 -0
  79. package/dist/src/hooks/types-enhanced.js +22 -0
  80. package/dist/src/hooks/types-enhanced.js.map +1 -0
  81. package/dist/src/hooks/types.d.ts +27 -0
  82. package/dist/src/hooks/types.d.ts.map +1 -0
  83. package/dist/src/hooks/types.js +2 -0
  84. package/dist/src/hooks/types.js.map +1 -0
  85. package/dist/src/index.d.ts +43 -0
  86. package/dist/src/index.d.ts.map +1 -0
  87. package/dist/src/index.js +41 -0
  88. package/dist/src/index.js.map +1 -0
  89. package/dist/src/persistence/index.d.ts +7 -0
  90. package/dist/src/persistence/index.d.ts.map +1 -0
  91. package/dist/src/persistence/index.js +6 -0
  92. package/dist/src/persistence/index.js.map +1 -0
  93. package/dist/src/persistence/plan-md.d.ts +11 -0
  94. package/dist/src/persistence/plan-md.d.ts.map +1 -0
  95. package/dist/src/persistence/plan-md.js +125 -0
  96. package/dist/src/persistence/plan-md.js.map +1 -0
  97. package/dist/src/persistence/state-md.d.ts +17 -0
  98. package/dist/src/persistence/state-md.d.ts.map +1 -0
  99. package/dist/src/persistence/state-md.js +143 -0
  100. package/dist/src/persistence/state-md.js.map +1 -0
  101. package/dist/src/persistence/types.d.ts +85 -0
  102. package/dist/src/persistence/types.d.ts.map +1 -0
  103. package/dist/src/persistence/types.js +5 -0
  104. package/dist/src/persistence/types.js.map +1 -0
  105. package/dist/src/router/classifier.d.ts +108 -0
  106. package/dist/src/router/classifier.d.ts.map +1 -0
  107. package/dist/src/router/classifier.js +476 -0
  108. package/dist/src/router/classifier.js.map +1 -0
  109. package/dist/src/router/guard.d.ts +128 -0
  110. package/dist/src/router/guard.d.ts.map +1 -0
  111. package/dist/src/router/guard.js +370 -0
  112. package/dist/src/router/guard.js.map +1 -0
  113. package/dist/src/router/index.d.ts +10 -0
  114. package/dist/src/router/index.d.ts.map +1 -0
  115. package/dist/src/router/index.js +8 -0
  116. package/dist/src/router/index.js.map +1 -0
  117. package/dist/src/router/router.d.ts +58 -0
  118. package/dist/src/router/router.d.ts.map +1 -0
  119. package/dist/src/router/router.js +78 -0
  120. package/dist/src/router/router.js.map +1 -0
  121. package/dist/src/router/types.d.ts +100 -0
  122. package/dist/src/router/types.d.ts.map +1 -0
  123. package/dist/src/router/types.js +24 -0
  124. package/dist/src/router/types.js.map +1 -0
  125. package/dist/src/skills/agents-md/index.d.ts +9 -0
  126. package/dist/src/skills/agents-md/index.d.ts.map +1 -0
  127. package/dist/src/skills/agents-md/index.js +28 -0
  128. package/dist/src/skills/agents-md/index.js.map +1 -0
  129. package/dist/src/skills/execute-plan/index.d.ts +141 -0
  130. package/dist/src/skills/execute-plan/index.d.ts.map +1 -0
  131. package/dist/src/skills/execute-plan/index.js +784 -0
  132. package/dist/src/skills/execute-plan/index.js.map +1 -0
  133. package/dist/src/skills/index.d.ts +14 -0
  134. package/dist/src/skills/index.d.ts.map +1 -0
  135. package/dist/src/skills/index.js +10 -0
  136. package/dist/src/skills/index.js.map +1 -0
  137. package/dist/src/skills/quick-task/index.d.ts +75 -0
  138. package/dist/src/skills/quick-task/index.d.ts.map +1 -0
  139. package/dist/src/skills/quick-task/index.js +284 -0
  140. package/dist/src/skills/quick-task/index.js.map +1 -0
  141. package/dist/src/skills/registry.d.ts +15 -0
  142. package/dist/src/skills/registry.d.ts.map +1 -0
  143. package/dist/src/skills/registry.js +44 -0
  144. package/dist/src/skills/registry.js.map +1 -0
  145. package/dist/src/skills/review-diff/index.d.ts +96 -0
  146. package/dist/src/skills/review-diff/index.d.ts.map +1 -0
  147. package/dist/src/skills/review-diff/index.js +316 -0
  148. package/dist/src/skills/review-diff/index.js.map +1 -0
  149. package/dist/src/skills/skill.d.ts +24 -0
  150. package/dist/src/skills/skill.d.ts.map +1 -0
  151. package/dist/src/skills/skill.js +39 -0
  152. package/dist/src/skills/skill.js.map +1 -0
  153. package/dist/src/skills/systematic-debugging/index.d.ts +90 -0
  154. package/dist/src/skills/systematic-debugging/index.d.ts.map +1 -0
  155. package/dist/src/skills/systematic-debugging/index.js +305 -0
  156. package/dist/src/skills/systematic-debugging/index.js.map +1 -0
  157. package/dist/src/skills/tdd/index.d.ts +103 -0
  158. package/dist/src/skills/tdd/index.d.ts.map +1 -0
  159. package/dist/src/skills/tdd/index.js +338 -0
  160. package/dist/src/skills/tdd/index.js.map +1 -0
  161. package/dist/src/skills/to-plan/index-enhanced.d.ts +100 -0
  162. package/dist/src/skills/to-plan/index-enhanced.d.ts.map +1 -0
  163. package/dist/src/skills/to-plan/index-enhanced.js +452 -0
  164. package/dist/src/skills/to-plan/index-enhanced.js.map +1 -0
  165. package/dist/src/skills/to-plan/index.d.ts +131 -0
  166. package/dist/src/skills/to-plan/index.d.ts.map +1 -0
  167. package/dist/src/skills/to-plan/index.js +460 -0
  168. package/dist/src/skills/to-plan/index.js.map +1 -0
  169. package/dist/src/skills/types.d.ts +44 -0
  170. package/dist/src/skills/types.d.ts.map +1 -0
  171. package/dist/src/skills/types.js +2 -0
  172. package/dist/src/skills/types.js.map +1 -0
  173. package/dist/src/state/cleanup.d.ts +22 -0
  174. package/dist/src/state/cleanup.d.ts.map +1 -0
  175. package/dist/src/state/cleanup.js +87 -0
  176. package/dist/src/state/cleanup.js.map +1 -0
  177. package/dist/src/state/index.d.ts +9 -0
  178. package/dist/src/state/index.d.ts.map +1 -0
  179. package/dist/src/state/index.js +5 -0
  180. package/dist/src/state/index.js.map +1 -0
  181. package/dist/src/state/manager.d.ts +15 -0
  182. package/dist/src/state/manager.d.ts.map +1 -0
  183. package/dist/src/state/manager.js +73 -0
  184. package/dist/src/state/manager.js.map +1 -0
  185. package/dist/src/state/persistence.d.ts +13 -0
  186. package/dist/src/state/persistence.d.ts.map +1 -0
  187. package/dist/src/state/persistence.js +68 -0
  188. package/dist/src/state/persistence.js.map +1 -0
  189. package/dist/src/state/types.d.ts +26 -0
  190. package/dist/src/state/types.d.ts.map +1 -0
  191. package/dist/src/state/types.js +2 -0
  192. package/dist/src/state/types.js.map +1 -0
  193. package/dist/src/state/validator.d.ts +12 -0
  194. package/dist/src/state/validator.d.ts.map +1 -0
  195. package/dist/src/state/validator.js +56 -0
  196. package/dist/src/state/validator.js.map +1 -0
  197. package/dist/src/types.d.ts +83 -0
  198. package/dist/src/types.d.ts.map +1 -0
  199. package/dist/src/types.js +5 -0
  200. package/dist/src/types.js.map +1 -0
  201. package/dist/src/utils/compress.d.ts +37 -0
  202. package/dist/src/utils/compress.d.ts.map +1 -0
  203. package/dist/src/utils/compress.js +298 -0
  204. package/dist/src/utils/compress.js.map +1 -0
  205. package/dist/src/utils/git.d.ts +9 -0
  206. package/dist/src/utils/git.d.ts.map +1 -0
  207. package/dist/src/utils/git.js +81 -0
  208. package/dist/src/utils/git.js.map +1 -0
  209. package/dist/src/utils/index.d.ts +7 -0
  210. package/dist/src/utils/index.d.ts.map +1 -0
  211. package/dist/src/utils/index.js +7 -0
  212. package/dist/src/utils/index.js.map +1 -0
  213. package/dist/src/utils/logger.d.ts +6 -0
  214. package/dist/src/utils/logger.d.ts.map +1 -0
  215. package/dist/src/utils/logger.js +19 -0
  216. package/dist/src/utils/logger.js.map +1 -0
  217. package/dist/src/utils/paths.d.ts +12 -0
  218. package/dist/src/utils/paths.d.ts.map +1 -0
  219. package/dist/src/utils/paths.js +44 -0
  220. package/dist/src/utils/paths.js.map +1 -0
  221. package/package.json +76 -0
  222. package/scripts/postinstall.js +69 -0
  223. package/yi-workflow.js +17 -0
package/README.md ADDED
@@ -0,0 +1,168 @@
1
+ # yi-workflow Skills
2
+
3
+ Production workflow skills for planning, executing, reviewing, debugging, and finishing coding-agent work.
4
+
5
+ ## Simplified Workflow
6
+
7
+ ```text
8
+ Trivial edit: no skill needed — direct edit
9
+ Small task: quick-task
10
+ New project: to-plan → execute-plan (auto verify & finish)
11
+ Existing project: agents-md → to-plan → execute-plan (auto verify & finish)
12
+ ```
13
+
14
+ Use `agents-md` as step 0 only when an existing repository lacks agent instructions such as `AGENTS.md`, `CLAUDE.md`, or `CONTEXT.md`.
15
+
16
+ **Key simplification**: `execute-plan` now includes auto-verification and finish menu. No need to manually run `verify-goal` or `finish-branch`.
17
+
18
+ **Two-step flow**: `/to-plan` → user confirms (Y/Enter) → auto-triggers `/execute-plan` → auto-verify → auto-commit → finish options menu.
19
+
20
+ ## Skills
21
+
22
+ Each skill is a self-contained workflow in `<name>/SKILL.md`. Pi auto-discovers skills from this directory structure.
23
+
24
+ | Skill | Purpose | Trigger |
25
+ |---|---|---|
26
+ | `to-plan/` | Create implementation plan with subagents | `/to-plan` |
27
+ | `execute-plan/` | Execute approved plan with auto-verify and finish menu | `/execute-plan` |
28
+ | `quick-task/` | Handle small tasks with compact plan | `/quick-task` |
29
+ | `review-diff/` | Review diff/branch/PR against plan/spec | `/review-diff` |
30
+ | `tdd/` | Enforce RED/GREEN/REFACTOR | `/tdd` |
31
+ | `systematic-debugging/` | Find root cause before fixes | `/systematic-debugging` |
32
+ | `worktree-start/` | Prepare isolated git workspaces | `/worktree-start` |
33
+ | `agents-md/` | Create/update repo agent instructions | `/agents-md` |
34
+ | `caveman/` | Compress replies into terse prose | `/caveman` |
35
+
36
+ ## Skill Roles
37
+
38
+ | Skill | Role | Trigger |
39
+ |---|---|---|
40
+ | `agents-md` | Create or update repository agent instructions | Repo instruction setup or maintenance |
41
+ | `quick-task` | Run a small scoped task with compact plan and isolated subagent | Small fixes/features that are not trivial |
42
+ | `to-plan` | Explore with subagents and write an implementation plan | User wants a plan, task breakdown, or issue/spec-to-plan |
43
+ | `execute-plan` | Execute an approved plan with implementation subagents | User approves a plan for implementation |
44
+ | `verify-goal` | Verify completed work against plan/spec goals | After execute-plan or when user asks if requirements are met |
45
+ | `tdd` | Enforce RED/GREEN/REFACTOR for behavior changes | Implementation subagents and TDD requests |
46
+ | `review-diff` | Review diffs against plan/spec/task requirements | PR/diff/task review |
47
+ | `systematic-debugging` | Prove root cause before changing code | Failing tests, flaky behavior, regressions |
48
+ | `worktree-start` | Prepare isolated git workspaces | Parallel or risky worktree-based execution |
49
+ | `finish-branch` | Help choose merge/PR/keep/discard/cleanup | Work is implemented and ready to finish |
50
+ | `caveman` | Compress user-facing reports only | User asks for caveman/brief/compressed replies |
51
+ | `reflect` | Capture workflow feedback and turn it into skill improvements | User says "reflect", "反思", "retrospective", or after finish-branch |
52
+
53
+ ## Core Rules
54
+
55
+ | Rule | Applies to |
56
+ |---|---|
57
+ | Top-level skills are manually invoked; do not auto-route based only on broad natural-language triggers | all skills except execute-plan internals |
58
+ | `execute-plan` may autonomously orchestrate subagents only after explicit invocation/approval | `execute-plan` |
59
+ | Default plan path is `.pi/plans/YYYY-MM-DD-<topic>-implementation-plan.md` | `to-plan`, `worktree-start`, `execute-plan` |
60
+ | Plan files are stored in `.pi/plans/` (gitignored) and auto-cleaned after successful execution | `to-plan`, `worktree-start`, `execute-plan` |
61
+ | E2E/raw evidence reports are not committed by default; distill findings into the plan or summary | `to-plan`, `execute-plan`, `review-diff` |
62
+ | Subagent model selection is a blocking user-input gate; ask for the exact selector if unspecified | `to-plan`, `execute-plan` |
63
+ | Do not query/list/guess models and do not fallback to current/default/main model | `to-plan`, `execute-plan` |
64
+ | Exploration for plans must be done by subagents, not the main agent | `to-plan` |
65
+ | After `to-plan` dispatches exploration subagents, the main agent must not read/search repo, source, plan, or workflow-reference files | `to-plan` |
66
+ | Trivial edits need no skill; handle directly. Small scoped tasks use manual `quick-task`; complex work uses full planning | `quick-task`, `to-plan` |
67
+ | Full plans are written to disk; chat output is summary only | `to-plan` |
68
+ | Complex/high-context plans use a plan package instead of one oversized file | `to-plan`, `execute-plan` |
69
+ | Plan-checker gate must pass before Plan Ready | `to-plan` |
70
+ | Execution state is persisted before subagent dispatch and updated through review/integration | `execute-plan` |
71
+ | Goal-backward verification checks task completion against user-visible truths before finish | `verify-goal` |
72
+ | Skill descriptions stay under 180 chars and every skill declares `requires: [...]` | all skills |
73
+ | TDD is required for behavior changes unless the plan marks a valid exception | `execute-plan`, `quick-task`, `tdd` |
74
+ | After dispatching implementation work, the main agent must not read production/test source files or full diffs | `execute-plan`, `review-diff` |
75
+ | Implementation agents must stay scoped to `Owns`/`Reads`; broad codebase exploration is a blocked-task signal | `execute-plan` |
76
+ | Every completed task must have reviewer subagent reports or explicit user-approved waiver recorded in execution state before integration | `execute-plan` |
77
+ | Small-scope review waiver requires ≤2 tasks, ≤3 files, all verifications PASS, no security/auth/data risk, and explicit user approval | `execute-plan` |
78
+ | Main agent token budget target is 30-60K; checkpoint and stop if approaching 100K degraded territory | `execute-plan` |
79
+ | `caveman` is only for user-facing presentation, never precision-critical prompts/evidence | `execute-plan`, `caveman` |
80
+
81
+ ## Progressive Disclosure
82
+
83
+ Each `SKILL.md` stays small and operational. Reusable details live in `references/`.
84
+
85
+ ### Reference Files
86
+
87
+ | Reference | Purpose |
88
+ |---|---|
89
+ | `references/model-selection.md` | Exact model selector gate |
90
+ | `references/to-plan-template.md` | Full saved plan template |
91
+ | `references/to-plan-subagent-prompts.md` | Exploration subagent prompt patterns |
92
+ | `references/to-plan-post-subagent-gate.md` | Post-exploration synthesis checklist |
93
+ | `references/to-plan-quality-gate.md` | Plan-checker gate and task-size thresholds |
94
+ | `references/to-plan-non-negotiables.md` | to-plan structural rules |
95
+ | `references/to-plan-prohibited.md` | to-plan forbidden actions and embargo |
96
+ | `references/to-plan-workflow-details.md` | Expanded step instructions |
97
+ | `references/to-plan-orchestration.md` | Phase-by-phase orchestration guide |
98
+ | `references/execute-plan-token-budget.md` | Token budget tiers and discipline |
99
+ | `references/execute-plan-checkpointing.md` | Checkpoint protocol and hard stop |
100
+ | `references/execute-plan-checkpointing.md` | Checkpoint protocol and hard stop |
101
+ | `references/execute-plan-orchestration.md` | Phase-by-phase orchestration guide |
102
+ | `references/execute-plan-subagent-contract.md` | Implementer prompt/result contract |
103
+ | `references/subagent-lifecycle.md` | Subagent dispatch and validation |
104
+ | `references/execution-state-format.md` | State schema and resume handling |
105
+ | `references/review-gate-protocol.md` | Review decision tree and waiver |
106
+ | `references/execute-plan-non-negotiables.md` | execute-plan structural rules |
107
+ | `references/execute-plan-prohibited.md` | execute-plan forbidden actions |
108
+ | `references/execute-plan-modes.md` | Execution mode classification |
109
+ | `references/tdd-playbook.md` | RED/GREEN/REFACTOR guidance |
110
+ | `references/review-diff-checklist.md` | Review checklist details |
111
+ | `references/review-diff-prohibited.md` | review-diff forbidden actions |
112
+ | `references/debugging-playbook.md` | Root-cause debugging playbook |
113
+ | `references/systematic-debugging-prohibited.md` | debugging forbidden actions |
114
+ | `references/worktree-commands.md` | Worktree command details |
115
+ | `references/worktree-start-prohibited.md` | worktree forbidden actions |
116
+ | `references/finish-branch-commands.md` | Finish/merge/cleanup commands |
117
+ | `references/finish-branch-prohibited.md` | finish-branch forbidden actions |
118
+ | `references/goal-verification-checklist.md` | Goal-backward verification method |
119
+ | `references/agents-md-style.md` | Agent instruction file style |
120
+ | `references/agents-md-prohibited.md` | agents-md forbidden actions |
121
+ | `references/tdd-prohibited.md` | TDD Iron Law and forbidden actions |
122
+
123
+ ## Custom Agents
124
+
125
+ Preferred custom agents in `.pi/agents/` keep heavy role prompts out of main skills:
126
+
127
+ | Agent | Role |
128
+ |---|---|
129
+ | `yi-implementer` | Scoped implementation with TDD and Owns/Reads discipline |
130
+ | `yi-plan-checker` | Read-only plan-quality gate |
131
+ | `yi-spec-reviewer` | Requirement/spec compliance review |
132
+ | `yi-code-reviewer` | Code quality and risk review |
133
+ | `yi-verifier` | Goal-backward verification |
134
+
135
+ ## SKILL.md Maintenance Contract
136
+
137
+ Every `SKILL.md` includes:
138
+
139
+ 1. YAML frontmatter with `description: >-`.
140
+ 2. High-signal description: purpose, triggers, exclusions.
141
+ 3. `## Use / Exclude Matrix`.
142
+ 4. `## Workflow` with numbered steps.
143
+ 5. Every step: `Do:`, `Decide:`, `Produce:`.
144
+ 6. `## Output Spec` with fixed structure.
145
+ 7. `## Error Handling` as table.
146
+ 8. `## References` for delegated details.
147
+
148
+ ## Editing Guidance
149
+
150
+ When changing skills:
151
+
152
+ 1. Update smallest relevant skill first.
153
+ 2. Move repeated policy/templates to `references/`.
154
+ 3. Keep triggers narrow enough to avoid accidental activation.
155
+ 4. Prefer Markdown tables for matrices/rules.
156
+ 5. Avoid vague instructions like "handle edge cases" without enumeration.
157
+ 6. Verify workflow steps remain executable.
158
+ 7. Keep frontmatter descriptions under 180 chars.
159
+
160
+ ## Validation
161
+
162
+ Before considering edits complete:
163
+
164
+ ```bash
165
+ python3 scripts/validate-skills.py
166
+ ```
167
+
168
+ Checks: frontmatter, description length, `requires`, required sections, workflow steps with Do/Decide/Produce, placeholder terms, line count.
package/SETUP.md ADDED
@@ -0,0 +1,71 @@
1
+ # Setup Guide
2
+
3
+ ## Installation
4
+
5
+ ### Global Installation
6
+
7
+ ```bash
8
+ npm install -g yi-workflow
9
+ ```
10
+
11
+ ### Local Installation (per project)
12
+
13
+ ```bash
14
+ npm install --save-dev yi-workflow
15
+ ```
16
+
17
+ ## Configuration
18
+
19
+ ### Package.json Configuration
20
+
21
+ Add to your `package.json`:
22
+
23
+ ```json
24
+ {
25
+ "pi": {
26
+ "skills": [
27
+ "dist/skills/to-plan/index.js",
28
+ "dist/skills/execute-plan/index.js"
29
+ ],
30
+ "hooks": [
31
+ "dist/hooks/builtin/*.js"
32
+ ],
33
+ "config": {
34
+ "planPath": ".pi/plans",
35
+ "statePath": ".pi/yi-workflow/state",
36
+ "autoCleanup": true,
37
+ "autoMerge": true,
38
+ "defaultModel": "haiku",
39
+ "maxConcurrent": 4
40
+ }
41
+ }
42
+ }
43
+ ```
44
+
45
+ ### Initialize Project
46
+
47
+ ```bash
48
+ yi-workflow install
49
+ ```
50
+
51
+ This will:
52
+ - Create `.pi/plans` directory
53
+ - Create `.pi/yi-workflow/state` directory
54
+ - Add `.pi/` to `.gitignore`
55
+ - Update `package.json` with Pi configuration
56
+
57
+ ## Verification
58
+
59
+ ```bash
60
+ # Check configuration
61
+ yi-workflow validate
62
+
63
+ # Check status
64
+ yi-workflow status
65
+ ```
66
+
67
+ ## Environment Requirements
68
+
69
+ - Node.js >= 18.0.0
70
+ - Git repository (recommended)
71
+ - Pi subagents system (optional, for full functionality)
package/SKILL.md ADDED
@@ -0,0 +1,68 @@
1
+ # yi-workflow
2
+
3
+ Plan-based workflow execution with fresh-context subagents.
4
+
5
+ ## When to Use
6
+
7
+ Use this skill when the user wants to:
8
+ - Create a structured plan for complex tasks
9
+ - Execute a plan with parallel waves
10
+ - Review code systematically
11
+ - Debug issues with systematic approach
12
+ - Use TDD (test-driven development)
13
+
14
+ ## Commands
15
+
16
+ All yi-workflow commands are prefixed with `ywf-` to avoid conflicts with PI native commands:
17
+
18
+ ### /ywf-plan <goal>
19
+ Create an execution plan for the given goal.
20
+
21
+ ### /ywf-execute
22
+ Execute the current plan.
23
+
24
+ ### /ywf-task <description>
25
+ Execute a quick task without planning.
26
+
27
+ ### /ywf-tdd <feature>
28
+ Implement feature using TDD approach.
29
+
30
+ ### /ywf-review [target]
31
+ Review code changes.
32
+
33
+ ### /ywf-debug <issue>
34
+ Debug an issue systematically.
35
+
36
+ ### /ywf-status
37
+ Show current workflow status.
38
+
39
+ ### /ywf-resume
40
+ Resume interrupted workflow.
41
+
42
+ ## Workflow
43
+
44
+ 1. **Planning Phase**: Break down goal into tasks with dependencies
45
+ 2. **Execution Phase**: Execute tasks in parallel waves
46
+ 3. **Verification Phase**: Verify results meet acceptance criteria
47
+
48
+ ## Configuration
49
+
50
+ Configuration is read from `package.json` under the `pi.config` key:
51
+
52
+ ```json
53
+ {
54
+ "pi": {
55
+ "config": {
56
+ "planPath": ".pi/plans",
57
+ "statePath": ".pi/yi-workflow/state",
58
+ "defaultModel": "haiku",
59
+ "maxConcurrent": 4
60
+ }
61
+ }
62
+ }
63
+ ```
64
+
65
+ ## State Files
66
+
67
+ - `.pi/state/STATE.md` - Current workflow state
68
+ - `.pi/state/PLAN.md` - Execution plan
package/USAGE.md ADDED
@@ -0,0 +1,152 @@
1
+ # Usage Guide
2
+
3
+ ## Quick Start
4
+
5
+ ### 1. Create a Plan
6
+
7
+ ```bash
8
+ yi-workflow plan "Add user authentication" --description "Implement login/logout with JWT"
9
+ ```
10
+
11
+ This creates a plan at `.pi/plans/YYYY-MM-DD-add-user-authentication-implementation-plan.md`
12
+
13
+ ### 2. Review and Approve
14
+
15
+ Open the plan file and review the tasks.
16
+
17
+ ### 3. Execute the Plan
18
+
19
+ ```bash
20
+ yi-workflow execute .pi/plans/YYYY-MM-DD-add-user-authentication-implementation-plan.md
21
+ ```
22
+
23
+ ## Commands
24
+
25
+ ### plan
26
+
27
+ Create an implementation plan.
28
+
29
+ ```bash
30
+ yi-workflow plan <goal> [options]
31
+
32
+ Options:
33
+ -o, --output <path> Output path for plan
34
+ -d, --description <desc> Additional context
35
+ ```
36
+
37
+ ### execute
38
+
39
+ Execute an approved plan.
40
+
41
+ ```bash
42
+ yi-workflow execute <plan-path> [options]
43
+
44
+ Options:
45
+ -s, --state <id> Resume from state ID
46
+ ```
47
+
48
+ ### validate
49
+
50
+ Validate configuration.
51
+
52
+ ```bash
53
+ yi-workflow validate
54
+ ```
55
+
56
+ ### cleanup
57
+
58
+ Clean up old files.
59
+
60
+ ```bash
61
+ yi-workflow cleanup [options]
62
+
63
+ Options:
64
+ -d, --days <days> Clean files older than N days (default: 7)
65
+ --dry-run Show what would be cleaned
66
+ ```
67
+
68
+ ### status
69
+
70
+ View execution status.
71
+
72
+ ```bash
73
+ yi-workflow status
74
+ ```
75
+
76
+ ### resume
77
+
78
+ Resume execution from state.
79
+
80
+ ```bash
81
+ yi-workflow resume [state-id]
82
+ ```
83
+
84
+ ### install
85
+
86
+ Initialize yi-workflow in current project.
87
+
88
+ ```bash
89
+ yi-workflow install
90
+ ```
91
+
92
+ ## Programmatic Usage
93
+
94
+ ```typescript
95
+ import { createHookManager, createStateManager, toPlanSkill } from 'yi-workflow'
96
+
97
+ const hookManager = createHookManager()
98
+ const stateManager = createStateManager({
99
+ planPath: '.pi/plans',
100
+ statePath: '.pi/yi-workflow/state',
101
+ autoCleanup: true,
102
+ autoMerge: true,
103
+ defaultModel: 'haiku',
104
+ maxConcurrent: 4,
105
+ })
106
+
107
+ const result = await toPlanSkill.execute({
108
+ goal: 'Add user authentication',
109
+ context: 'Implement login/logout with JWT'
110
+ }, {
111
+ config: { /* ... */ },
112
+ state: currentState,
113
+ logger: console
114
+ })
115
+ ```
116
+
117
+ ## Workflow
118
+
119
+ 1. **Plan**: Use `yi-workflow plan` to create a plan
120
+ 2. **Review**: Manually review the generated plan
121
+ 3. **Execute**: Use `yi-workflow execute` to run the plan
122
+ 4. **Verify**: Automatic verification after execution
123
+ 5. **Finish**: Auto-commit, merge, and cleanup
124
+
125
+ ## Hooks
126
+
127
+ Hooks are triggered automatically:
128
+
129
+ - `pre-plan`: Before plan creation
130
+ - `post-plan`: After plan creation
131
+ - `pre-execute`: Before execution
132
+ - `post-execute`: After execution (includes auto-commit)
133
+ - `on-error`: When errors occur
134
+
135
+ ## State Management
136
+
137
+ Execution state is persisted to `.pi/yi-workflow/state/`:
138
+
139
+ - `active/`: Currently running executions
140
+ - `archive/YYYY-MM-DD/`: Completed/failed executions
141
+
142
+ Resume with:
143
+ ```bash
144
+ yi-workflow resume [state-id]
145
+ ```
146
+
147
+ ## Tips
148
+
149
+ - Keep plans in `.pi/plans/` (gitignored by default)
150
+ - Use `--verbose` for detailed logging
151
+ - Set `autoMerge: false` if you prefer manual merging
152
+ - Clean old states regularly with `yi-workflow cleanup`
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=yi-workflow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yi-workflow.d.ts","sourceRoot":"","sources":["../../bin/yi-workflow.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * yi-workflow CLI - Production workflow for coding agents
4
+ */
5
+ import { Command } from 'commander';
6
+ import chalk from 'chalk';
7
+ import { StateMdManager } from '../src/persistence/index.js';
8
+ const program = new Command();
9
+ program
10
+ .name('yi-workflow')
11
+ .description('Two-phase workflow (Plan → Execute) with fresh-context subagents')
12
+ .version('0.2.0');
13
+ // Status command
14
+ program
15
+ .command('status')
16
+ .description('Show workflow status')
17
+ .action(async () => {
18
+ try {
19
+ const stateManager = new StateMdManager();
20
+ const state = await stateManager.readCurrentState();
21
+ console.log(chalk.blue('Workflow Status'));
22
+ console.log(`Phase: ${state.phase}`);
23
+ console.log(`Goal: ${state.goal}`);
24
+ console.log(`Tasks: ${state.completedTasks.length}/${state.totalTasks}`);
25
+ }
26
+ catch {
27
+ console.log(chalk.yellow('No active workflow'));
28
+ }
29
+ });
30
+ // Health check
31
+ program
32
+ .command('health')
33
+ .description('Check system health')
34
+ .action(async () => {
35
+ console.log(chalk.blue('System Health'));
36
+ console.log(chalk.green('✓ All systems operational'));
37
+ });
38
+ program.parse();
39
+ //# sourceMappingURL=yi-workflow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yi-workflow.js","sourceRoot":"","sources":["../../bin/yi-workflow.ts"],"names":[],"mappings":";AACA;;GAEG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,cAAc,EAAiB,MAAM,6BAA6B,CAAA;AAE3E,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAA;AAE7B,OAAO;KACJ,IAAI,CAAC,aAAa,CAAC;KACnB,WAAW,CAAC,kEAAkE,CAAC;KAC/E,OAAO,CAAC,OAAO,CAAC,CAAA;AAEnB,iBAAiB;AACjB,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,sBAAsB,CAAC;KACnC,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,IAAI,CAAC;QACH,MAAM,YAAY,GAAG,IAAI,cAAc,EAAE,CAAA;QACzC,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,gBAAgB,EAAE,CAAA;QACnD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAA;QAC1C,OAAO,CAAC,GAAG,CAAC,UAAU,KAAK,CAAC,KAAK,EAAE,CAAC,CAAA;QACpC,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,CAAC,IAAI,EAAE,CAAC,CAAA;QAClC,OAAO,CAAC,GAAG,CAAC,UAAU,KAAK,CAAC,cAAc,CAAC,MAAM,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC,CAAA;IAC1E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAA;IACjD,CAAC;AACH,CAAC,CAAC,CAAA;AAEJ,eAAe;AACf,OAAO;KACJ,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,qBAAqB,CAAC;KAClC,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAA;IACxC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAC,CAAA;AACvD,CAAC,CAAC,CAAA;AAEJ,OAAO,CAAC,KAAK,EAAE,CAAA"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * Pre-built SubagentContracts for each subagent role.
3
+ *
4
+ * Each factory accepts role-specific parameters and returns a fully-formed
5
+ * SubagentContract ready for dispatch. The contracts encode:
6
+ * - The exact permission set the subagent needs
7
+ * - Which files it may own (modify) vs. read
8
+ * - A structured prompt template
9
+ * - An optional output schema for validation
10
+ */
11
+ import type { SubagentContract } from './types.js';
12
+ export interface ExplorerParams {
13
+ /** What the explorer should search for */
14
+ query: string;
15
+ /** Directories or file patterns to search within */
16
+ searchPaths: string[];
17
+ /** Files the explorer may read (beyond search results) */
18
+ readFiles?: string[];
19
+ /** Specific questions to answer */
20
+ questions?: string[];
21
+ }
22
+ export interface ImplementerParams {
23
+ /** Description of what to implement */
24
+ task: string;
25
+ /** Files the implementer may modify */
26
+ ownedFiles: string[];
27
+ /** Files the implementer may read for context */
28
+ readFiles?: string[];
29
+ /** Test command to run after implementation */
30
+ testCommand?: string;
31
+ /** Constraints or requirements */
32
+ constraints?: string[];
33
+ }
34
+ export interface ReviewerParams {
35
+ /** What to review (PR description, diff summary, etc.) */
36
+ target: string;
37
+ /** Files to review */
38
+ reviewFiles: string[];
39
+ /** Specific areas of concern */
40
+ focusAreas?: string[];
41
+ /** Review criteria */
42
+ criteria?: string[];
43
+ }
44
+ export interface DebuggerParams {
45
+ /** Description of the failure / bug */
46
+ issue: string;
47
+ /** Files likely involved in the bug */
48
+ suspectFiles: string[];
49
+ /** Error messages or stack traces */
50
+ errorOutput?: string;
51
+ /** Steps to reproduce */
52
+ reproSteps?: string[];
53
+ }
54
+ export interface VerifierParams {
55
+ /** The original goal / requirement */
56
+ goal: string;
57
+ /** The plan that was executed */
58
+ plan: string;
59
+ /** Files that were changed */
60
+ changedFiles: string[];
61
+ /** Acceptance criteria */
62
+ acceptanceCriteria: string[];
63
+ }
64
+ export interface ResearcherParams {
65
+ /** Research topic or question */
66
+ topic: string;
67
+ /** Specific questions to answer */
68
+ questions?: string[];
69
+ /** Search scope: technical, business, security, etc. */
70
+ scope?: 'technical' | 'business' | 'security' | 'general';
71
+ /** Maximum results to return */
72
+ maxResults?: number;
73
+ /** Time range for results (e.g., '1y', '6m', '1w') */
74
+ timeRange?: string;
75
+ }
76
+ /**
77
+ * Explorer contract: read-only, searches the codebase to answer questions
78
+ * about structure, dependencies, patterns, or specific implementations.
79
+ */
80
+ export declare function explorerContract(params: ExplorerParams): SubagentContract;
81
+ /**
82
+ * Implementer contract: writes code, runs tests, works in isolation.
83
+ * The implementer owns specific files and may modify them.
84
+ */
85
+ export declare function implementerContract(params: ImplementerParams): SubagentContract;
86
+ /**
87
+ * Reviewer contract: reads code changes and produces a structured review
88
+ * report covering correctness, style, security, and performance.
89
+ */
90
+ export declare function reviewerContract(params: ReviewerParams): SubagentContract;
91
+ /**
92
+ * Debugger contract: analyses failures, identifies root causes, and
93
+ * proposes minimal fixes. Read-only unless explicitly allowed to write.
94
+ */
95
+ export declare function debuggerContract(params: DebuggerParams): SubagentContract;
96
+ /**
97
+ * Verifier contract: goal-backward verification. Checks that the
98
+ * implemented changes actually satisfy the original requirements by
99
+ * working backward from the goal through each acceptance criterion.
100
+ */
101
+ export declare function verifierContract(params: VerifierParams): SubagentContract;
102
+ /**
103
+ * Researcher contract: searches the internet for information on a topic.
104
+ * Returns structured research findings with sources.
105
+ */
106
+ export declare function researcherContract(params: ResearcherParams): SubagentContract;
107
+ export interface WorktreeParams {
108
+ /** Branch name for the new worktree */
109
+ branchName: string;
110
+ /** Base branch to create from (default: main) */
111
+ baseBranch?: string;
112
+ /** Whether to enable full isolation */
113
+ isolation?: boolean;
114
+ }
115
+ /**
116
+ * Worktree contract: Creates isolated git worktrees for parallel work.
117
+ * Replaces the worktree-start skill with a direct subagent dispatch.
118
+ */
119
+ export declare function worktreeContract(params: WorktreeParams): SubagentContract;
120
+ //# sourceMappingURL=contracts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contracts.d.ts","sourceRoot":"","sources":["../../../src/agents/contracts.ts"],"names":[],"mappings":"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"}