@pi-unipi/workflow 0.1.2 → 0.1.4
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/README.md +6 -7
- package/commands.ts +34 -3
- package/index.ts +12 -3
- package/package.json +1 -1
- package/skills/brainstorm/SKILL.md +1 -0
- package/skills/plan/SKILL.md +19 -14
- package/skills/work/SKILL.md +8 -9
- package/skills/worktree-list/SKILL.md +23 -12
- package/skills/worktree-merge/SKILL.md +10 -2
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @unipi/workflow
|
|
1
|
+
# @pi-unipi/workflow
|
|
2
2
|
|
|
3
3
|
Structured development workflow commands for Pi coding agent.
|
|
4
4
|
|
|
@@ -106,16 +106,15 @@ brainstorm → plan → work → review-work → consolidate
|
|
|
106
106
|
|
|
107
107
|
## Integration
|
|
108
108
|
|
|
109
|
-
- **@unipi/core** — shared constants, events, utilities
|
|
110
|
-
- **@unipi/memory** — memory hooks for consolidate (optional)
|
|
111
|
-
- **@unipi/
|
|
112
|
-
- **@unipi/
|
|
113
|
-
- **@unipi/ralph** — loop integration for long-running tasks (optional)
|
|
109
|
+
- **@pi-unipi/core** — shared constants, events, utilities
|
|
110
|
+
- **@pi-unipi/memory** — memory hooks for consolidate (optional)
|
|
111
|
+
- **@pi-unipi/subagents** — parallel research for gather-context, scan-issues (optional)
|
|
112
|
+
- **@pi-unipi/ralph** — loop integration for long-running tasks (optional)
|
|
114
113
|
|
|
115
114
|
## Installation
|
|
116
115
|
|
|
117
116
|
```bash
|
|
118
|
-
npm install @unipi/workflow
|
|
117
|
+
npm install @pi-unipi/workflow
|
|
119
118
|
```
|
|
120
119
|
|
|
121
120
|
Add to pi settings:
|
package/commands.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
9
9
|
import { readFileSync, readdirSync, existsSync } from "fs";
|
|
10
10
|
import { join, basename } from "path";
|
|
11
|
-
import { UNIPI_PREFIX, WORKFLOW_COMMANDS, getToolsForCommand, getSandboxLevel, type SandboxLevel } from "@unipi/core";
|
|
11
|
+
import { UNIPI_PREFIX, WORKFLOW_COMMANDS, getToolsForCommand, getSandboxLevel, type SandboxLevel } from "@pi-unipi/core";
|
|
12
12
|
|
|
13
13
|
/** Options for command registration */
|
|
14
14
|
export interface WorkflowCommandOptions {
|
|
@@ -54,6 +54,27 @@ function suggestSpecFiles(prefix: string): { value: string; label: string; descr
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Suggest plan files from .unipi/docs/plans/ for work and review-work commands.
|
|
59
|
+
*/
|
|
60
|
+
function suggestPlanFiles(prefix: string): { value: string; label: string; description: string }[] {
|
|
61
|
+
const plansDir = join(process.cwd(), ".unipi", "docs", "plans");
|
|
62
|
+
if (!existsSync(plansDir)) return [];
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
const files = readdirSync(plansDir).filter((f) => f.endsWith(".md"));
|
|
66
|
+
return files
|
|
67
|
+
.filter((f) => !prefix || f.includes(prefix))
|
|
68
|
+
.map((f) => ({
|
|
69
|
+
value: `plan:${f}`,
|
|
70
|
+
label: basename(f, ".md"),
|
|
71
|
+
description: `Plan: ${f}`,
|
|
72
|
+
}));
|
|
73
|
+
} catch {
|
|
74
|
+
return [];
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
57
78
|
/**
|
|
58
79
|
* Suggest existing worktree names for merge/list commands.
|
|
59
80
|
*/
|
|
@@ -96,7 +117,7 @@ const COMMANDS: WorkflowCommand[] = [
|
|
|
96
117
|
description:
|
|
97
118
|
"Execute plan — implement in worktree, test, commit on done",
|
|
98
119
|
skillName: "work",
|
|
99
|
-
argumentHint: "<
|
|
120
|
+
argumentHint: "plan:<file> <description>",
|
|
100
121
|
ralphHint: "Ralph detected. Use /unipi:ralph-start for long-running tasks.",
|
|
101
122
|
},
|
|
102
123
|
{
|
|
@@ -104,7 +125,7 @@ const COMMANDS: WorkflowCommand[] = [
|
|
|
104
125
|
description:
|
|
105
126
|
"Review work — check task completion, run lint/build, mark reviewer remarks",
|
|
106
127
|
skillName: "review-work",
|
|
107
|
-
argumentHint: "<
|
|
128
|
+
argumentHint: "plan:<file> <scope>",
|
|
108
129
|
},
|
|
109
130
|
{
|
|
110
131
|
name: WORKFLOW_COMMANDS.CONSOLIDATE,
|
|
@@ -183,6 +204,16 @@ export function registerWorkflowCommands(
|
|
|
183
204
|
return suggestSpecFiles(prefix);
|
|
184
205
|
}
|
|
185
206
|
|
|
207
|
+
// Work command: suggest plan files
|
|
208
|
+
if (cmd.name === WORKFLOW_COMMANDS.WORK) {
|
|
209
|
+
return suggestPlanFiles(prefix);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Review-work command: suggest plan files
|
|
213
|
+
if (cmd.name === WORKFLOW_COMMANDS.REVIEW_WORK) {
|
|
214
|
+
return suggestPlanFiles(prefix);
|
|
215
|
+
}
|
|
216
|
+
|
|
186
217
|
// Worktree merge: suggest existing worktrees
|
|
187
218
|
if (cmd.name === WORKFLOW_COMMANDS.WORKTREE_MERGE) {
|
|
188
219
|
return suggestWorktrees();
|
package/index.ts
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
initUnipiDirs,
|
|
18
18
|
type SandboxLevel,
|
|
19
19
|
getToolsForLevel,
|
|
20
|
-
} from "@unipi/core";
|
|
20
|
+
} from "@pi-unipi/core";
|
|
21
21
|
import { registerWorkflowCommands } from "./commands.js";
|
|
22
22
|
|
|
23
23
|
/** Package version (read from package.json at load time) */
|
|
@@ -86,7 +86,16 @@ export default function (pi: ExtensionAPI) {
|
|
|
86
86
|
systemPrompt:
|
|
87
87
|
event.systemPrompt +
|
|
88
88
|
base +
|
|
89
|
-
`\nThe write tool is available but restricted to .unipi/docs/specs/ only.\nDo NOT attempt to call blocked tools. Do NOT output tool call XML for them.\nIf the user requests an action that requires a blocked tool, respond that you do not have access.\n</sandbox>`,
|
|
89
|
+
`\nThe write tool is available but restricted to .unipi/docs/specs/ only.\nbash is available ONLY for specific setup use case (e.g., git init, mkdir). Do NOT use bash for reading files or listing directories — use grep, find, ls instead.\nDo NOT attempt to call blocked tools. Do NOT output tool call XML for them.\nIf the user requests an action that requires a blocked tool, respond that you do not have access.\n</sandbox>`,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (currentSandboxLevel === "write_unipi") {
|
|
94
|
+
return {
|
|
95
|
+
systemPrompt:
|
|
96
|
+
event.systemPrompt +
|
|
97
|
+
base +
|
|
98
|
+
`\nWrite tool is restricted to .unipi/docs/ only (specs and plans).\nUse grep, find, ls for file discovery — do NOT guess filenames.\nbash is blocked — use read, write, edit, grep, find, ls only.\nDo NOT attempt to call blocked tools. Do NOT output tool call XML for them.\nIf the user requests an action that requires a blocked tool, respond that you do not have access.\n</sandbox>`,
|
|
90
99
|
};
|
|
91
100
|
}
|
|
92
101
|
|
|
@@ -94,7 +103,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
94
103
|
systemPrompt:
|
|
95
104
|
event.systemPrompt +
|
|
96
105
|
base +
|
|
97
|
-
`\nDo NOT attempt to call blocked tools. Do NOT output tool call XML for them.\nIf the user
|
|
106
|
+
`\nDo NOT attempt to call blocked tools. Do NOT output tool call XML for them.\nIf the user requires an action that requires a blocked tool, respond that you do not have access.\n</sandbox>`,
|
|
98
107
|
};
|
|
99
108
|
});
|
|
100
109
|
|
package/package.json
CHANGED
|
@@ -145,6 +145,7 @@ The `## Implementation Checklist` section uses `- [ ]` markdown checkboxes. Thes
|
|
|
145
145
|
|
|
146
146
|
- **`[ ]` = unplanned** — not yet covered by a plan
|
|
147
147
|
- **`[x]` = planned** — marked when `/unipi:plan` covers this item
|
|
148
|
+
- **`[x]` does NOT mean done** — implementation progress is tracked in the plan file (`unstarted:` / `in-progress:` / `completed:`)
|
|
148
149
|
- Agent MUST fill in checklist items based on the design
|
|
149
150
|
- Each item should be a discrete, implementable task
|
|
150
151
|
- Items should be ordered by dependency (earlier items don't depend on later ones)
|
package/skills/plan/SKILL.md
CHANGED
|
@@ -81,16 +81,19 @@ specs:
|
|
|
81
81
|
|
|
82
82
|
## Tasks
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
1. {Concrete step}
|
|
90
|
-
2. {Concrete step}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
...
|
|
84
|
+
- unstarted: Task 1 — {Task Name}
|
|
85
|
+
- Description: {What needs to be done}
|
|
86
|
+
- Dependencies: {None, or list of tasks}
|
|
87
|
+
- Acceptance Criteria: {How to verify done}
|
|
88
|
+
- Steps:
|
|
89
|
+
1. {Concrete step}
|
|
90
|
+
2. {Concrete step}
|
|
91
|
+
|
|
92
|
+
- unstarted: Task 2 — {Task Name}
|
|
93
|
+
- Description: ...
|
|
94
|
+
- Dependencies: ...
|
|
95
|
+
- Acceptance Criteria: ...
|
|
96
|
+
- Steps: ...
|
|
94
97
|
|
|
95
98
|
## Sequencing
|
|
96
99
|
{Order of execution, dependency graph if complex}
|
|
@@ -129,6 +132,8 @@ After plan is complete:
|
|
|
129
132
|
|
|
130
133
|
This creates the link between brainstorm and plan — plan covers some items, others remain for future plans.
|
|
131
134
|
|
|
135
|
+
**Semantics:** Spec `[x]` means "planned" (covered by a plan). It does NOT mean "done". Implementation progress is tracked in the plan file, not the spec.
|
|
136
|
+
|
|
132
137
|
---
|
|
133
138
|
|
|
134
139
|
## Phase 5: Review Plan
|
|
@@ -138,10 +143,11 @@ Self-check before presenting:
|
|
|
138
143
|
- [ ] Every task has clear acceptance criteria
|
|
139
144
|
- [ ] Dependencies are correct (no circular, no missing)
|
|
140
145
|
- [ ] Steps are bite-sized (agent can follow without guessing)
|
|
141
|
-
- [ ] Brainstorm checkboxes updated correctly
|
|
142
146
|
- [ ] String greedy scope respected (if provided)
|
|
143
147
|
- [ ] Plan is focused enough for single `/unipi:work` session
|
|
144
148
|
|
|
149
|
+
Do NOT re-read or re-edit the spec checkboxes — Phase 4 already wrote them.
|
|
150
|
+
|
|
145
151
|
---
|
|
146
152
|
|
|
147
153
|
## Phase 6: Present & Handoff
|
|
@@ -164,6 +170,5 @@ Recommend starting a **new session** for work — it will switch pi's internal w
|
|
|
164
170
|
## Resumability
|
|
165
171
|
|
|
166
172
|
If user runs `/unipi:plan` on an existing plan:
|
|
167
|
-
1. Read the plan
|
|
168
|
-
2.
|
|
169
|
-
3. Ask user if they want to add tasks, modify existing, or plan new scope
|
|
173
|
+
1. Read the plan — look for `completed:` tasks
|
|
174
|
+
2. Ask user if they want to add tasks, modify existing, or plan new scope
|
package/skills/work/SKILL.md
CHANGED
|
@@ -58,7 +58,7 @@ If args not provided, ask user interactively:
|
|
|
58
58
|
1. Read plan file(s)
|
|
59
59
|
2. Review critically — identify questions or concerns
|
|
60
60
|
3. If concerns: raise with user before starting
|
|
61
|
-
4. Identify
|
|
61
|
+
4. Identify task status: `unstarted:` (pending), `in-progress:` (started), `completed:` (done)
|
|
62
62
|
|
|
63
63
|
**Exit:** Plan reviewed, ready to execute.
|
|
64
64
|
|
|
@@ -66,12 +66,12 @@ If args not provided, ask user interactively:
|
|
|
66
66
|
|
|
67
67
|
## Phase 3: Execute Tasks
|
|
68
68
|
|
|
69
|
-
For each task in order:
|
|
69
|
+
For each `unstarted:` task in order:
|
|
70
70
|
|
|
71
|
-
1.
|
|
71
|
+
1. Change `unstarted:` to `in-progress:` in plan
|
|
72
72
|
2. Follow each step exactly (plan has bite-sized steps)
|
|
73
73
|
3. Run verifications as specified in acceptance criteria
|
|
74
|
-
4.
|
|
74
|
+
4. Change `in-progress:` to `completed:` when complete
|
|
75
75
|
5. Update plan file with progress
|
|
76
76
|
|
|
77
77
|
### When to Stop and Ask
|
|
@@ -107,12 +107,11 @@ Don't wait until end to commit — incremental commits are safer.
|
|
|
107
107
|
|
|
108
108
|
## Phase 5: Complete
|
|
109
109
|
|
|
110
|
-
When all tasks
|
|
110
|
+
When all tasks are `completed:`:
|
|
111
111
|
|
|
112
112
|
1. Run final verification (tests, lint, build)
|
|
113
113
|
2. Commit all remaining changes
|
|
114
|
-
3.
|
|
115
|
-
4. Inform user:
|
|
114
|
+
3. Inform user:
|
|
116
115
|
|
|
117
116
|
> "All tasks complete. Worktree: `feat/<branch>`. Recommend reviewing before merge."
|
|
118
117
|
|
|
@@ -127,9 +126,9 @@ Suggest next step:
|
|
|
127
126
|
|
|
128
127
|
## Resumability
|
|
129
128
|
|
|
130
|
-
If user runs `/unipi:work` and plan has
|
|
129
|
+
If user runs `/unipi:work` and plan has `completed:` or `in-progress:` tasks:
|
|
131
130
|
1. Read plan
|
|
132
|
-
2. Identify first `
|
|
131
|
+
2. Identify first `unstarted:` task
|
|
133
132
|
3. Ask user: "Resume from Task N: {name}?"
|
|
134
133
|
4. Continue from there
|
|
135
134
|
|
|
@@ -9,8 +9,8 @@ List all git worktrees created by unipi.
|
|
|
9
9
|
|
|
10
10
|
## Boundaries
|
|
11
11
|
|
|
12
|
-
**This skill MAY:**
|
|
13
|
-
**This skill MAY NOT:** edit anything, create worktrees, merge branches.
|
|
12
|
+
**This skill MAY:** read filesystem (ls, read), grep for git info.
|
|
13
|
+
**This skill MAY NOT:** edit anything, create worktrees, merge branches, run bash.
|
|
14
14
|
|
|
15
15
|
## Command Format
|
|
16
16
|
|
|
@@ -24,17 +24,27 @@ No arguments. Lists all unipi worktrees.
|
|
|
24
24
|
|
|
25
25
|
## Process
|
|
26
26
|
|
|
27
|
-
### Phase 1:
|
|
27
|
+
### Phase 1: Discover Worktrees
|
|
28
28
|
|
|
29
|
-
1.
|
|
30
|
-
2.
|
|
31
|
-
|
|
32
|
-
-
|
|
33
|
-
|
|
34
|
-
- HEAD commit
|
|
35
|
-
- Whether it has uncommitted changes
|
|
29
|
+
1. `ls .unipi/worktrees/` — list worktree directories
|
|
30
|
+
2. For each directory:
|
|
31
|
+
- Read `.unipi/worktrees/<branch>/.git` file to get gitdir path
|
|
32
|
+
- Check for uncommitted changes: `ls .unipi/worktrees/<branch>/` and read key files
|
|
33
|
+
3. If `.unipi/worktrees/` doesn't exist or is empty → no worktrees
|
|
36
34
|
|
|
37
|
-
|
|
35
|
+
**Exit:** List of worktrees discovered.
|
|
36
|
+
|
|
37
|
+
### Phase 2: Determine Status
|
|
38
|
+
|
|
39
|
+
For each worktree directory:
|
|
40
|
+
|
|
41
|
+
1. Check if `HEAD` file exists in gitdir
|
|
42
|
+
2. Check for modified files by reading directory listing
|
|
43
|
+
3. Determine status:
|
|
44
|
+
- **clean** — no uncommitted changes
|
|
45
|
+
- **dirty** — has uncommitted changes
|
|
46
|
+
|
|
47
|
+
### Phase 3: Present
|
|
38
48
|
|
|
39
49
|
Display in table format:
|
|
40
50
|
|
|
@@ -51,7 +61,7 @@ Worktrees:
|
|
|
51
61
|
If no worktrees:
|
|
52
62
|
> "No unipi worktrees. Create one with `/unipi:worktree-create`"
|
|
53
63
|
|
|
54
|
-
### Phase
|
|
64
|
+
### Phase 4: Suggest Actions
|
|
55
65
|
|
|
56
66
|
Based on state:
|
|
57
67
|
- If dirty worktrees exist → suggest reviewing or committing
|
|
@@ -65,3 +75,4 @@ Based on state:
|
|
|
65
75
|
- Only shows worktrees under `.unipi/worktrees/`
|
|
66
76
|
- Ignores worktrees in other locations
|
|
67
77
|
- Status: `clean` = no uncommitted changes, `dirty` = has changes
|
|
78
|
+
- No bash required — uses ls, read, grep for all discovery
|
|
@@ -46,8 +46,16 @@ For each source branch (in dependency order if specs indicate ordering):
|
|
|
46
46
|
3. **If conflict:**
|
|
47
47
|
- Report which files conflict
|
|
48
48
|
- Reference the spec/plan context: "This branch was working on: <description>"
|
|
49
|
-
-
|
|
50
|
-
|
|
49
|
+
- **Structured conflict resolution:**
|
|
50
|
+
1. **Check finalized plan** — read the plan for this branch, understand intended changes
|
|
51
|
+
2. **Brainstorm resolution** — reason about which changes align with the plan's intent
|
|
52
|
+
3. **Read codebase** — read the conflicting files to understand current state
|
|
53
|
+
4. **Ask user** — present options and ask for final decision (always ask, never force)
|
|
54
|
+
- Options to present:
|
|
55
|
+
- Accept incoming (their changes)
|
|
56
|
+
- Accept current (main branch)
|
|
57
|
+
- Manual merge (describe what each side does, ask user to decide)
|
|
58
|
+
- Skip this branch
|
|
51
59
|
4. **If success:**
|
|
52
60
|
- Remove worktree: `git worktree remove .unipi/worktrees/<branch-name>`
|
|
53
61
|
- Delete branch: `git branch -d <branch>`
|