@pi-unipi/workflow 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/commands.ts CHANGED
@@ -192,6 +192,13 @@ const COMMANDS: WorkflowCommand[] = [
192
192
  skillName: "scan-issues",
193
193
  argumentHint: "<scope>",
194
194
  },
195
+ {
196
+ name: WORKFLOW_COMMANDS.AUTO,
197
+ description:
198
+ "Full pipeline — brainstorm → plan → work → review → merge",
199
+ skillName: "auto",
200
+ argumentHint: "<description> plan:<file> specs:<file>",
201
+ },
195
202
  ];
196
203
 
197
204
  /**
@@ -207,29 +214,41 @@ export function registerWorkflowCommands(
207
214
  pi.registerCommand(fullCommand, {
208
215
  description: cmd.description,
209
216
  getArgumentCompletions: (prefix: string) => {
217
+ let items: { value: string; label: string; description: string }[] | null = null;
218
+
210
219
  // Plan command: suggest spec files
211
220
  if (cmd.name === WORKFLOW_COMMANDS.PLAN) {
212
- return suggestSpecFiles(prefix);
221
+ items = suggestSpecFiles(prefix);
213
222
  }
214
223
 
215
224
  // Work command: suggest plan files
216
225
  if (cmd.name === WORKFLOW_COMMANDS.WORK) {
217
- return suggestPlanFiles(prefix);
226
+ items = suggestPlanFiles(prefix);
218
227
  }
219
228
 
220
229
  // Review-work command: suggest plan files
221
230
  if (cmd.name === WORKFLOW_COMMANDS.REVIEW_WORK) {
222
- return suggestPlanFiles(prefix);
231
+ items = suggestPlanFiles(prefix);
223
232
  }
224
233
 
225
234
  // Worktree merge: suggest existing worktrees
226
235
  if (cmd.name === WORKFLOW_COMMANDS.WORKTREE_MERGE) {
227
- return suggestWorktrees();
236
+ items = suggestWorktrees();
228
237
  }
229
238
 
230
239
  // Worktree create: suggest existing worktrees as reference
231
240
  if (cmd.name === WORKFLOW_COMMANDS.WORKTREE_CREATE) {
232
- return suggestWorktrees();
241
+ items = suggestWorktrees();
242
+ }
243
+
244
+ // Auto command: suggest plan files
245
+ if (cmd.name === WORKFLOW_COMMANDS.AUTO) {
246
+ items = suggestPlanFiles(prefix);
247
+ }
248
+
249
+ // Defensive: filter out any items with non-string value
250
+ if (items) {
251
+ return items.filter((item) => typeof item.value === "string");
233
252
  }
234
253
 
235
254
  // Other commands: no dynamic completions (free-text args)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-unipi/workflow",
3
- "version": "0.1.7",
3
+ "version": "0.1.8",
4
4
  "description": "Structured development workflow commands for Pi coding agent",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -33,7 +33,7 @@
33
33
  "access": "public"
34
34
  },
35
35
  "dependencies": {
36
- "@pi-unipi/core": "^0.1.0"
36
+ "@pi-unipi/core": "^0.1.6"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@mariozechner/pi-ai": "*",
@@ -0,0 +1,166 @@
1
+ ---
2
+ name: auto
3
+ description: "Full pipeline — brainstorm → plan → work → review → merge. One command, end to end."
4
+ ---
5
+
6
+ # Auto Pipeline
7
+
8
+ Run the complete development pipeline from idea to merged code.
9
+
10
+ ## Command Format
11
+
12
+ ```
13
+ /unipi:auto <description>(optional) plan:<path>(optional) specs:<path>(optional)
14
+ ```
15
+
16
+ - `description` — what to build (triggers brainstorm first)
17
+ - `plan:<path>` — existing plan to execute (skips brainstorm + plan, starts at work)
18
+ - `specs:<path>` — existing spec to plan from (skips brainstorm, starts at plan)
19
+ - No args → ask user what to do
20
+
21
+ ## Pipeline Stages
22
+
23
+ ```
24
+ brainstorm → plan → work → review → merge
25
+ ```
26
+
27
+ Each stage hands off to the next automatically. User can intervene at any gate.
28
+
29
+ ---
30
+
31
+ ## Phase 1: Determine Entry Point
32
+
33
+ Based on args:
34
+
35
+ **If `description` provided (no plan/specs):**
36
+ → Start at brainstorm. Full pipeline.
37
+
38
+ **If `specs:<path>` provided (no plan):**
39
+ → Start at plan. Skip brainstorm.
40
+
41
+ **If `plan:<path>` provided:**
42
+ → Start at work. Skip brainstorm + plan.
43
+
44
+ **If no args:**
45
+ → Ask user:
46
+ 1. "What do you want to build?" → brainstorm
47
+ 2. "I have a spec, plan from it" → provide spec path
48
+ 3. "I have a plan, execute it" → provide plan path
49
+ 4. "I have a plan, just review + merge" → provide plan path
50
+
51
+ **Exit:** Entry point determined. Pipeline scope clear.
52
+
53
+ ---
54
+
55
+ ## Phase 2: Brainstorm (if needed)
56
+
57
+ 1. Load brainstorm skill content
58
+ 2. Run full brainstorm flow — explore, question, design, write spec
59
+ 3. Wait for user approval at design gate
60
+ 4. On approval → proceed to plan
61
+
62
+ **Gate:** User must approve design before continuing.
63
+
64
+ ---
65
+
66
+ ## Phase 3: Plan (if needed)
67
+
68
+ 1. Load plan skill content
69
+ 2. Create implementation plan from spec
70
+ 3. Present plan to user
71
+ 4. On approval → proceed to work
72
+
73
+ **Gate:** User must approve plan before continuing.
74
+
75
+ ---
76
+
77
+ ## Phase 4: Work (if needed)
78
+
79
+ 1. Read `workbranch` from plan frontmatter
80
+ 2. If `workbranch` non-empty → create worktree, work within it
81
+ 3. If `workbranch` empty → work directly on main branch
82
+ 4. Load work skill content
83
+ 5. Execute all tasks in the plan
84
+ 6. Commit incrementally
85
+ 7. On completion → proceed to review
86
+
87
+ **Gate:** All tasks must complete. If blocked → stop and ask.
88
+
89
+ ---
90
+
91
+ ## Phase 5: Review
92
+
93
+ 1. Load review-work skill content
94
+ 2. Read `workbranch` from plan — switch to branch if set, else review on main
95
+ 3. Check task completion against acceptance criteria
96
+ 4. Run codebase checks (lint, type check, test, build)
97
+ 5. Write reviewer remarks to plan
98
+
99
+ **If review passes:** → proceed to merge (or skip if on main)
100
+ **If review fails:** → go back to work (Phase 4) with failure context
101
+
102
+ **Gate:** All checks must pass. Reviewer remarks must say Done.
103
+
104
+ ---
105
+
106
+ ## Phase 6: Merge (if worktree)
107
+
108
+ If `workbranch` was set (worktree):
109
+ 1. Load worktree-merge skill content
110
+ 2. Merge worktree branch back to main
111
+ 3. Clean up worktree and branch
112
+ 4. Run final verification on main
113
+
114
+ If `workbranch` was empty (main branch):
115
+ → Skip merge — changes already on main.
116
+
117
+ **Exit:** Code on main. Worktree cleaned (if applicable).
118
+
119
+ ---
120
+
121
+ ## Phase 7: Summary
122
+
123
+ Report pipeline results:
124
+
125
+ ```
126
+ Pipeline Complete: {topic}
127
+
128
+ ✓ Brainstorm — {spec-path}
129
+ ✓ Plan — {plan-path}
130
+ ✓ Work — {N} tasks completed on {branch or "main"}
131
+ ✓ Review — all checks passed
132
+ ✓ Merge — {merged to main, worktree cleaned or "already on main"}
133
+
134
+ Artifacts:
135
+ - Spec: .unipi/docs/specs/{spec}
136
+ - Plan: .unipi/docs/plans/{plan}
137
+ ```
138
+
139
+ Suggest next steps:
140
+ - `/unipi:consolidate` — save learnings
141
+ - `/unipi:scan-issues` — deeper code review
142
+ - `/unipi:document` — generate docs
143
+
144
+ ---
145
+
146
+ ## Interruption Handling
147
+
148
+ If any phase fails or user interrupts:
149
+
150
+ 1. Record current phase and progress
151
+ 2. Suggest resuming from the failed phase
152
+ 3. Don't lose context — spec/plan/progress preserved
153
+
154
+ Example:
155
+ > "Pipeline paused at review phase. 3/5 tasks complete, tests failing.
156
+ > Resume with: `/unipi:auto plan:<plan-path>`"
157
+
158
+ ---
159
+
160
+ ## Notes
161
+
162
+ - Each phase loads its skill content dynamically
163
+ - Gates between phases ensure user oversight
164
+ - Pipeline is resumable — can restart from any phase
165
+ - Worktree isolation protects main branch (skipped for small tasks — work directly on main)
166
+ - Auto command has `full` sandbox — all tools available
@@ -56,8 +56,20 @@ Committed to current branch.
56
56
  2. If concerns: raise with user before proceeding
57
57
  3. If `string(greedy)` provided: use it to scope planning (e.g., "focus on auth only")
58
58
  4. Ask clarifying questions if needed (one at a time)
59
+ 5. **Ask about work branch:**
59
60
 
60
- **Exit:** No blockers. Ready to plan.
61
+ > "Where should this work happen?"
62
+ >
63
+ > 1. **Main branch** — work directly on main (small/medium tasks, low risk)
64
+ > 2. **New branch** — isolated worktree (larger tasks, risky changes)
65
+ >
66
+ > If "New branch": "What branch name? (e.g., `feat/auth`, or press enter for auto-naming based on spec topic)"
67
+
68
+ Record the decision:
69
+ - Main branch → `workbranch:` will be empty in plan frontmatter
70
+ - New branch → `workbranch: {branch-name}` in plan frontmatter (auto-generate `feat/{topic}` if not provided)
71
+
72
+ **Exit:** No blockers. Branch strategy decided. Ready to plan.
61
73
 
62
74
  ---
63
75
 
@@ -70,7 +82,7 @@ Structure the plan with heart of gold style:
70
82
  title: "{Topic} — Implementation Plan"
71
83
  type: plan
72
84
  date: YYYY-MM-DD
73
- workbranch: {branch-name or empty if on main}
85
+ workbranch: {branch-name} # empty string = work on main branch
74
86
  specs:
75
87
  - path/to/spec.md
76
88
  ---
@@ -170,15 +182,19 @@ Do NOT re-read or re-edit the spec checkboxes — Phase 4 already wrote them.
170
182
  Present plan summary to user. Then ask:
171
183
 
172
184
  1. **Proceed to /unipi:work** — Start implementing in a worktree
173
- 2. **Revise plan** — Adjust tasks or scope
174
- 3. **Done for now** — Return later
185
+ 2. **Proceed to /unipi:auto** — Run full pipeline (work → review → merge)
186
+ 3. **Revise plan** — Adjust tasks or scope
187
+ 4. **Done for now** — Return later
175
188
 
176
- If user selects "Proceed to /unipi:work", suggest:
177
- ```
178
- /unipi:work worktree:feat/<branch-name> specs:YYYY-MM-DD-<topic>-plan
179
- ```
189
+ If user selects "Proceed to /unipi:work":
190
+ - **Worktree branch** → suggest: `/unipi:work worktree:<branch-name> specs:YYYY-MM-DD-<topic>-plan`
191
+ - **Main branch** → suggest: `/unipi:work specs:YYYY-MM-DD-<topic>-plan` (no worktree arg)
192
+
193
+ If user selects "Proceed to /unipi:auto":
194
+ - **Worktree branch** → suggest: `/unipi:auto plan:YYYY-MM-DD-<topic>-plan.md`
195
+ - **Main branch** → suggest: `/unipi:auto plan:YYYY-MM-DD-<topic>-plan.md` (same — auto reads workbranch from plan)
180
196
 
181
- Recommend starting a **new session** for work it will switch pi's internal worktree.
197
+ Recommend starting a **new session** for work if using a worktree.
182
198
 
183
199
  ---
184
200
 
@@ -9,7 +9,7 @@ Review what was built, verify task completion, run codebase checks, add reviewer
9
9
 
10
10
  ## Boundaries
11
11
 
12
- **This skill MAY:** read codebase, run checks (lint, build, test, docker), write reviewer remarks to plan docs.
12
+ **This skill MAY:** read codebase, run checks (lint, build, test, docker), write reviewer remarks to plan docs, run bash for git operations (checkout worktree branch).
13
13
  **This skill MAY NOT:** edit code, implement features, create new files.
14
14
 
15
15
  ## Command Format
@@ -112,17 +112,37 @@ Followed by description explaining the status.
112
112
  Based on review results:
113
113
 
114
114
  **If all tasks done and checks pass:**
115
- > "All tasks complete and verified. Ready to consolidate."
115
+
116
+ *If `workbranch` is set (worktree):*
117
+ > "All tasks complete and verified. Ready to merge back to main."
118
+ ```
119
+ /unipi:worktree-merge
120
+ ```
121
+
122
+ *If `workbranch` is empty (main branch):*
123
+ > "All tasks complete and verified. Changes already on main — no merge needed."
124
+ ```
125
+ /unipi:consolidate
126
+ ```
127
+
128
+ Either way, user can consolidate learnings:
116
129
  ```
117
130
  /unipi:consolidate
118
131
  ```
119
132
 
120
133
  **If tasks incomplete or checks fail:**
121
134
  > "Tasks remaining and/or checks failing. Continue work?"
135
+
136
+ *If `workbranch` is set:*
122
137
  ```
123
138
  /unipi:work worktree:<branch> specs:<plan-path>
124
139
  ```
125
140
 
141
+ *If `workbranch` is empty (main):*
142
+ ```
143
+ /unipi:work specs:<plan-path>
144
+ ```
145
+
126
146
  **If scoped review complete:**
127
147
  > "Scoped review complete. Run full review or continue work?"
128
148
  ```
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: work
3
- description: "Execute plan — implement in worktree, test, commit on done. Resumable across sessions."
3
+ description: "Execute plan — implement tasks, test, commit on done. Works in worktree or on main branch. Resumable."
4
4
  ---
5
5
 
6
6
  # Executing Plans
@@ -9,8 +9,12 @@ Load plan, review critically, execute tasks, commit when complete.
9
9
 
10
10
  ## Boundaries
11
11
 
12
- **This skill MAY:** read/write code in worktree, read/write `.unipi/docs/`, run tests, commit, create worktree.
13
- **This skill MAY NOT:** modify files outside worktree, merge branches, deploy.
12
+ **This skill MAY:** read/write code, read/write `.unipi/docs/`, run tests, commit, create worktree.
13
+ **This skill MAY NOT:** merge branches, deploy.
14
+
15
+ **Worktree vs Main:**
16
+ - If `workbranch` in plan → work within worktree directory
17
+ - If `workbranch` empty → work directly on main branch (current directory)
14
18
 
15
19
  ## Command Format
16
20
 
@@ -25,32 +29,36 @@ Load plan, review critically, execute tasks, commit when complete.
25
29
 
26
30
  ## Sandbox
27
31
 
28
- - **Read/Write:** full access within worktree directory
32
+ - **Read/Write:** full access within worktree (or project root if on main)
29
33
  - **Write:** `.unipi/docs/` for progress tracking
30
- - **Cannot:** modify files outside worktree
31
34
 
32
35
  ---
33
36
 
34
37
  ## Phase 1: Resolve Args
35
38
 
36
- If args not provided, ask user interactively:
37
-
38
- 1. **Worktree:**
39
- - "Do you want to work on current branch or create a worktree?"
40
- - If worktree: "What branch name?" (suggest based on spec topic)
41
- - Create worktree if not exists
42
- - **After creating/confirming worktree:** write `workbranch: {branch-name}` to the plan file frontmatter
43
-
44
- 2. **Specs:**
45
- - List available plans in `.unipi/docs/plans/`
46
- - "Which plan(s) to execute?"
39
+ 1. **Specs:**
40
+ - If `specs:` arg provided, read those plan files
41
+ - If not, list available plans in `.unipi/docs/plans/` and ask user
47
42
  - Can select multiple
48
43
 
44
+ 2. **Read `workbranch` from plan frontmatter:**
45
+ - If `workbranch:` is **non-empty** → use that branch/worktree
46
+ - If worktree arg also provided → use worktree arg (override)
47
+ - Create worktree if not exists: `git worktree add .unipi/worktrees/{branch} -b {branch}`
48
+ - Work within worktree directory
49
+ - If `workbranch:` is **empty or missing** → work on current branch (main)
50
+ - No worktree creation needed
51
+ - Edit files directly in project root
52
+ - If neither plan nor args specify branch → ask user:
53
+ > "Where should this work happen?"
54
+ > 1. Current branch (main)
55
+ > 2. New worktree (provide branch name)
56
+
49
57
  3. **Scope:**
50
58
  - If `string(greedy)` provided, use to scope tasks
51
59
  - Otherwise execute all incomplete tasks
52
60
 
53
- **Exit:** Worktree set, plan(s) loaded, scope defined.
61
+ **Exit:** Branch/worktree resolved. Plan(s) loaded. Scope defined.
54
62
 
55
63
  ---
56
64
 
@@ -134,17 +142,22 @@ When all tasks are `completed:`:
134
142
 
135
143
  1. Run final verification (tests, lint, build)
136
144
  2. Commit all remaining changes
137
- 3. Inform user:
138
-
139
- > "All tasks complete. Worktree: `feat/<branch>`. Recommend reviewing before merge."
145
+ 3. Inform user based on branch strategy:
140
146
 
141
- Suggest next step:
147
+ **If working in worktree:**
148
+ > "All tasks complete. Worktree: `{branch}`. Recommend reviewing before merge."
142
149
  ```
143
150
  /unipi:review-work plan:<plan-path>
144
151
  ```
145
-
146
152
  **Recommend starting a new session** for review.
147
153
 
154
+ **If working on main branch:**
155
+ > "All tasks complete. All changes committed directly on main."
156
+ ```
157
+ /unipi:review-work plan:<plan-path>
158
+ ```
159
+ No merge needed — changes already on main.
160
+
148
161
  ---
149
162
 
150
163
  ## Resumability
@@ -161,6 +174,7 @@ If user provides scope string, only execute matching tasks.
161
174
 
162
175
  ## Notes
163
176
 
164
- - Agent reads plan regardlessly on start — finds what's incomplete
165
- - Worktree isolation: changes don't affect main branch until merge
177
+ - Agent reads plan on start — finds what's incomplete
178
+ - Worktree: changes don't affect main branch until merge (skip for small tasks)
179
+ - Main branch: changes committed directly, no merge needed
166
180
  - Each worktree session is independent — no coordination with other worktrees
@@ -7,6 +7,8 @@ description: "Merge worktree branches back to main. Gathers context from specs/p
7
7
 
8
8
  Merge completed worktree branches into main. Gather context from docs before merging.
9
9
 
10
+ **Note:** Only needed when work was done in a worktree (plan `workbranch` set). If work was on main branch directly, skip this — changes already on main.
11
+
10
12
  ## Process
11
13
 
12
14
  ### Phase 1: Gather Context