@tianhai/pi-workflow-kit 0.6.0 → 0.7.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.
- package/README.md +12 -2
- package/docs/plans/2026-04-11-finalizing-merge-options-design.md +33 -0
- package/docs/plans/completed/2026-04-11-checkpoint-review-gates-design.md +50 -0
- package/docs/plans/completed/2026-04-11-checkpoint-review-gates-implementation.md +98 -0
- package/docs/plans/completed/2026-04-11-finalizing-merge-options-design.md +33 -0
- package/docs/plans/completed/2026-04-11-finalizing-merge-options-implementation.md +75 -0
- package/docs/plans/completed/2026-04-11-workspace-setup-design.md +28 -0
- package/docs/plans/completed/2026-04-11-workspace-setup-implementation.md +57 -0
- package/extensions/workflow-guard.ts +12 -7
- package/package.json +1 -1
- package/skills/brainstorming/SKILL.md +5 -1
- package/skills/executing-tasks/SKILL.md +37 -1
- package/skills/finalizing/SKILL.md +41 -7
- package/skills/writing-plans/SKILL.md +15 -6
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ You control each phase explicitly by invoking the skill:
|
|
|
31
31
|
|-------|---------|--------------|
|
|
32
32
|
| **Brainstorm** | `/skill:brainstorming` | Refine your idea into a design doc via collaborative dialogue |
|
|
33
33
|
| **Plan** | `/skill:writing-plans` | Break the design into bite-sized TDD tasks with exact file paths and code |
|
|
34
|
-
| **Execute** | `/skill:executing-tasks` | Implement the plan task-by-task with TDD discipline |
|
|
34
|
+
| **Execute** | `/skill:executing-tasks` | Implement the plan task-by-task with TDD discipline and optional checkpoint review gates |
|
|
35
35
|
| **Finalize** | `/skill:finalizing` | Archive plan docs, update README/CHANGELOG, create PR |
|
|
36
36
|
|
|
37
37
|
During brainstorm and plan, the extension blocks `write`/`edit` outside `docs/plans/`. During execute and finalize, all tools are available.
|
|
@@ -42,7 +42,7 @@ During brainstorm and plan, the extension blocks `write`/`edit` outside `docs/pl
|
|
|
42
42
|
|-------|------:|-------------|
|
|
43
43
|
| `brainstorming` | ~30 | Explore the idea, propose approaches, write design doc |
|
|
44
44
|
| `writing-plans` | ~35 | Break design into tasks with TDD scenarios, set up branch/worktree |
|
|
45
|
-
| `executing-tasks` | ~
|
|
45
|
+
| `executing-tasks` | ~50 | Implement tasks with TDD discipline, checkpoint review gates, handle code review |
|
|
46
46
|
| `finalizing` | ~20 | Archive docs, update changelog, create PR, clean up |
|
|
47
47
|
|
|
48
48
|
### TDD Three-Scenario Model
|
|
@@ -55,6 +55,16 @@ The plan labels each task with its TDD scenario:
|
|
|
55
55
|
| Modifying tested code | Changing existing behavior | Run existing tests first → modify → verify |
|
|
56
56
|
| Trivial | Config, docs, naming | Use judgment |
|
|
57
57
|
|
|
58
|
+
### Checkpoint Review Gates
|
|
59
|
+
|
|
60
|
+
Optionally label tasks with a `checkpoint` to pause for human review:
|
|
61
|
+
|
|
62
|
+
| Checkpoint | When to use | What happens |
|
|
63
|
+
|---|---|---|
|
|
64
|
+
| *(none)* | Trivial tasks, well-understood changes | Auto-advance, no pause |
|
|
65
|
+
| `checkpoint: test` | Test design matters | Pause after failing test, before implementing |
|
|
66
|
+
| `checkpoint: done` | Implementation review matters | Pause after implementation passes tests, before committing |
|
|
67
|
+
|
|
58
68
|
## Architecture
|
|
59
69
|
|
|
60
70
|
```
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Finalizing: Merge Strategy Options
|
|
2
|
+
|
|
3
|
+
## Problem
|
|
4
|
+
|
|
5
|
+
The finalizing skill hard-codes "Create PR" as the only shipping option. In practice, small features often don't need a PR — they can be merged directly back to the parent branch.
|
|
6
|
+
|
|
7
|
+
## Design
|
|
8
|
+
|
|
9
|
+
Add a merge strategy step after updating documentation. The human chooses one of four options:
|
|
10
|
+
|
|
11
|
+
1. **Create PR** — push and open a PR for external review via `gh pr create`
|
|
12
|
+
2. **Rebase & merge** (recommended) — rebase onto parent, fast-forward merge, push parent, delete feature branch. Preserves per-task commit history linearly.
|
|
13
|
+
3. **Squash & merge** — squash all commits into one on parent, push parent, delete feature branch. Clean single-commit history.
|
|
14
|
+
4. **Merge commit** — merge with `--no-ff`, push parent, delete feature branch. Preserves all commits and branch topology.
|
|
15
|
+
|
|
16
|
+
### Flow for options 2–4 (local merge)
|
|
17
|
+
|
|
18
|
+
1. Detect parent branch (compare `main` vs `master`, fall back to `git show-branch`)
|
|
19
|
+
2. Switch to parent branch and pull latest
|
|
20
|
+
3. Execute the chosen merge strategy:
|
|
21
|
+
- Rebase: `git rebase <parent>` on feature branch, then `git merge --ff-only <feature>` on parent
|
|
22
|
+
- Squash: `git merge --squash <feature>` on parent, then `git commit`
|
|
23
|
+
- Merge commit: `git merge --no-ff <feature>` on parent
|
|
24
|
+
4. Push parent to origin
|
|
25
|
+
5. Delete feature branch locally and remotely
|
|
26
|
+
|
|
27
|
+
### Prompting
|
|
28
|
+
|
|
29
|
+
The skill should ask the human which option they prefer, presenting rebase & merge as the default recommendation.
|
|
30
|
+
|
|
31
|
+
## Changes
|
|
32
|
+
|
|
33
|
+
- Update `skills/finalizing/SKILL.md` to replace the hard-coded PR step with the 4-option choice.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Checkpoint Review Gates for Task Execution
|
|
2
|
+
|
|
3
|
+
## Problem
|
|
4
|
+
|
|
5
|
+
Executing-tasks runs through tasks without pausing. There's no way for the human to review tests before implementation, or review implementation before committing. The TDD labels in plans are advisory, not enforceable. There's no configuration for review gates.
|
|
6
|
+
|
|
7
|
+
## Design
|
|
8
|
+
|
|
9
|
+
Add optional `checkpoint` labels to individual tasks in the implementation plan. Executing-tasks pauses at checkpoint boundaries for human review.
|
|
10
|
+
|
|
11
|
+
## Checkpoint labels
|
|
12
|
+
|
|
13
|
+
Each task can optionally include a `checkpoint` label:
|
|
14
|
+
|
|
15
|
+
- **`checkpoint: test`** — pause after writing the failing test, before implementing
|
|
16
|
+
- **`checkpoint: done`** — pause after implementation + tests pass, before committing
|
|
17
|
+
- **No label** — auto-advance, no pause
|
|
18
|
+
|
|
19
|
+
The label is orthogonal to the TDD scenario. A "new feature" task with `checkpoint: test` means: write failing test → pause → implement → run tests → commit. Without a checkpoint, the same task flows straight through.
|
|
20
|
+
|
|
21
|
+
## Who sets checkpoints
|
|
22
|
+
|
|
23
|
+
The agent decides which tasks get checkpoints during plan writing, based on complexity and risk. The user reviews the plan before execution and can add, remove, or change checkpoints.
|
|
24
|
+
|
|
25
|
+
## Changes
|
|
26
|
+
|
|
27
|
+
### writing-plans/SKILL.md
|
|
28
|
+
|
|
29
|
+
Add `checkpoint` as an optional field in the task format section, with the two values and the "no label means auto-advance" rule. Update the TDD table to show how checkpoints interact with each scenario. Add guidance for the agent on when to use each checkpoint value.
|
|
30
|
+
|
|
31
|
+
### executing-tasks/SKILL.md
|
|
32
|
+
|
|
33
|
+
Update the per-task lifecycle to handle checkpoints:
|
|
34
|
+
|
|
35
|
+
- **No checkpoint** — existing flow unchanged
|
|
36
|
+
- **`checkpoint: test`** — write failing test → show diff → pause for review → proceed based on human input → implement → run tests → fix if needed → commit
|
|
37
|
+
- **`checkpoint: done`** — implement → run tests → fix if needed → show diff → pause for review → proceed based on human input → commit
|
|
38
|
+
|
|
39
|
+
The pause is a simple conversation stop — the agent shows what was done and the diff, then waits. The human can say anything: change the test, tweak the implementation, approve, revert, adjust the plan. No rigid menu.
|
|
40
|
+
|
|
41
|
+
Pause message format:
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
⏸ Paused at checkpoint: [test|done] for task [N]
|
|
45
|
+
|
|
46
|
+
**What was done:** [brief summary]
|
|
47
|
+
**Diff:** [show relevant diff]
|
|
48
|
+
|
|
49
|
+
Review and let me know how to proceed.
|
|
50
|
+
```
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Checkpoint Review Gates: Implementation Plan
|
|
2
|
+
|
|
3
|
+
## Tasks
|
|
4
|
+
|
|
5
|
+
### Task 1: Update writing-plans/SKILL.md — add checkpoint field and agent guidance
|
|
6
|
+
|
|
7
|
+
**Scenario:** Trivial (docs)
|
|
8
|
+
|
|
9
|
+
**File:** `skills/writing-plans/SKILL.md`
|
|
10
|
+
|
|
11
|
+
Add a "Checkpoint labels" section after "TDD in the plan" with the optional `checkpoint` field, values, and agent guidance. Also update the TDD table to show how checkpoints interact with each scenario.
|
|
12
|
+
|
|
13
|
+
After the "TDD in the plan" section, add:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
## Checkpoint labels
|
|
17
|
+
|
|
18
|
+
Optionally label each task with a `checkpoint` to require human review before proceeding:
|
|
19
|
+
|
|
20
|
+
| Checkpoint | When to use | What happens during execution |
|
|
21
|
+
|---|---|---|
|
|
22
|
+
| *(none)* | Trivial tasks, well-understood changes | Auto-advance, no pause |
|
|
23
|
+
| **`checkpoint: test`** | Test design matters (API contracts, edge cases, complex behavior) | Pause after writing the failing test, before implementing |
|
|
24
|
+
| **`checkpoint: done`** | Implementation review matters (complex logic, security, performance) | Pause after implementation + tests pass, before committing |
|
|
25
|
+
|
|
26
|
+
Use judgment when assigning checkpoints. Prefer `checkpoint: test` for new features with non-obvious test design. Prefer `checkpoint: done` for tasks where the implementation approach is debatable. Most tasks should not need a checkpoint. The user can adjust checkpoints when reviewing the plan.
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Also update the "Task format" section — after the `git commit` bullet, add:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
- Optional `checkpoint: test` or `checkpoint: done` label
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Commit:** `feat(writing-plans): add checkpoint labels for review gates`
|
|
36
|
+
|
|
37
|
+
### Task 2: Update executing-tasks/SKILL.md — handle checkpoints in per-task lifecycle
|
|
38
|
+
|
|
39
|
+
**Scenario:** Trivial (docs)
|
|
40
|
+
|
|
41
|
+
**File:** `skills/executing-tasks/SKILL.md`
|
|
42
|
+
|
|
43
|
+
Replace the "Per-task lifecycle" section with checkpoint-aware flows. Add a "Checkpoint review" section.
|
|
44
|
+
|
|
45
|
+
Replace the existing "Per-task lifecycle" section with:
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
## Per-task lifecycle
|
|
49
|
+
|
|
50
|
+
Check each task for a `checkpoint` label and follow the appropriate flow:
|
|
51
|
+
|
|
52
|
+
### No checkpoint (auto-advance)
|
|
53
|
+
|
|
54
|
+
1. **Implement** — write the code as described in the plan
|
|
55
|
+
2. **Run tests** — verify the changes work
|
|
56
|
+
3. **Fix if needed** — if tests fail, debug and fix before moving on
|
|
57
|
+
4. **Commit** — `git add` the relevant files and commit with a clear message
|
|
58
|
+
|
|
59
|
+
### checkpoint: test
|
|
60
|
+
|
|
61
|
+
1. **Write the test** — follow the TDD scenario for the task
|
|
62
|
+
2. **Pause for review** — show what was done and the diff, then wait for human input
|
|
63
|
+
3. **Continue** — implement, run tests, fix if needed
|
|
64
|
+
4. **Commit** — `git add` the relevant files and commit with a clear message
|
|
65
|
+
|
|
66
|
+
### checkpoint: done
|
|
67
|
+
|
|
68
|
+
1. **Implement** — write the code as described in the plan
|
|
69
|
+
2. **Run tests** — verify the changes work
|
|
70
|
+
3. **Fix if needed** — if tests fail, debug and fix before moving on
|
|
71
|
+
4. **Pause for review** — show what was done and the diff, then wait for human input
|
|
72
|
+
5. **Commit** — `git add` the relevant files and commit with a clear message
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
After the "TDD discipline" section, add:
|
|
76
|
+
|
|
77
|
+
```
|
|
78
|
+
## Checkpoint review
|
|
79
|
+
|
|
80
|
+
When pausing at a checkpoint, present:
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
⏸ Paused at checkpoint: [test|done] for task [N]
|
|
84
|
+
|
|
85
|
+
**What was done:** [brief summary]
|
|
86
|
+
**Diff:** [show relevant diff]
|
|
87
|
+
|
|
88
|
+
Review and let me know how to proceed.
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Wait for the human to respond. They may:
|
|
92
|
+
- Approve and continue
|
|
93
|
+
- Request changes to the test or implementation
|
|
94
|
+
- Ask to revert the task
|
|
95
|
+
- Adjust the remaining plan
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Commit:** `feat(executing-tasks): add checkpoint review gates`
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Finalizing: Merge Strategy Options
|
|
2
|
+
|
|
3
|
+
## Problem
|
|
4
|
+
|
|
5
|
+
The finalizing skill hard-codes "Create PR" as the only shipping option. In practice, small features often don't need a PR — they can be merged directly back to the parent branch.
|
|
6
|
+
|
|
7
|
+
## Design
|
|
8
|
+
|
|
9
|
+
Add a merge strategy step after updating documentation. The human chooses one of four options:
|
|
10
|
+
|
|
11
|
+
1. **Create PR** — push and open a PR for external review via `gh pr create`
|
|
12
|
+
2. **Rebase & merge** (recommended) — rebase onto parent, fast-forward merge, push parent, delete feature branch. Preserves per-task commit history linearly.
|
|
13
|
+
3. **Squash & merge** — squash all commits into one on parent, push parent, delete feature branch. Clean single-commit history.
|
|
14
|
+
4. **Merge commit** — merge with `--no-ff`, push parent, delete feature branch. Preserves all commits and branch topology.
|
|
15
|
+
|
|
16
|
+
### Flow for options 2–4 (local merge)
|
|
17
|
+
|
|
18
|
+
1. Detect parent branch (compare `main` vs `master`, fall back to `git show-branch`)
|
|
19
|
+
2. Switch to parent branch and pull latest
|
|
20
|
+
3. Execute the chosen merge strategy:
|
|
21
|
+
- Rebase: `git rebase <parent>` on feature branch, then `git merge --ff-only <feature>` on parent
|
|
22
|
+
- Squash: `git merge --squash <feature>` on parent, then `git commit`
|
|
23
|
+
- Merge commit: `git merge --no-ff <feature>` on parent
|
|
24
|
+
4. Push parent to origin
|
|
25
|
+
5. Delete feature branch locally and remotely
|
|
26
|
+
|
|
27
|
+
### Prompting
|
|
28
|
+
|
|
29
|
+
The skill should ask the human which option they prefer, presenting rebase & merge as the default recommendation.
|
|
30
|
+
|
|
31
|
+
## Changes
|
|
32
|
+
|
|
33
|
+
- Update `skills/finalizing/SKILL.md` to replace the hard-coded PR step with the 4-option choice.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# Finalizing: Merge Strategy Options — Implementation Plan
|
|
2
|
+
|
|
3
|
+
## Context
|
|
4
|
+
|
|
5
|
+
Replace the hard-coded "Create PR" step in the finalizing skill with a 4-option merge strategy prompt (Create PR, Rebase & merge, Squash & merge, Merge commit).
|
|
6
|
+
|
|
7
|
+
Design doc: `docs/plans/2026-04-11-finalizing-merge-options-design.md`
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Task 1 — Replace the PR step with a merge strategy prompt
|
|
12
|
+
|
|
13
|
+
**TDD scenario:** Trivial (skill docs, no code to test)
|
|
14
|
+
|
|
15
|
+
**File:** `skills/finalizing/SKILL.md`
|
|
16
|
+
|
|
17
|
+
Replace step 3 ("Create PR") and step 4 ("Clean up") with the new merge strategy section. Keep steps 1 and 2 unchanged.
|
|
18
|
+
|
|
19
|
+
**New content for step 3 onwards:**
|
|
20
|
+
|
|
21
|
+
```markdown
|
|
22
|
+
3. **Choose a merge strategy** — ask the human which option they prefer:
|
|
23
|
+
|
|
24
|
+
1. **Create PR** — push and open a PR for external review:
|
|
25
|
+
```
|
|
26
|
+
git push origin <branch>
|
|
27
|
+
gh pr create --title "feat: <summary>" --body "<task summary>"
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
2. **Rebase & merge** *(recommended)* — rebase onto parent, fast-forward merge, push parent, delete branch:
|
|
31
|
+
```
|
|
32
|
+
parent=$(git show-branch -a 2>/dev/null | grep '\*' | grep -v "$(git branch --show-current)" | head -1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//')
|
|
33
|
+
git checkout "$parent" && git pull
|
|
34
|
+
git checkout - && git rebase "$parent"
|
|
35
|
+
git checkout "$parent" && git merge --ff-only -
|
|
36
|
+
git push origin "$parent"
|
|
37
|
+
git branch -d - && git push origin --delete -
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
3. **Squash & merge** — squash all commits into one on parent, push parent, delete branch:
|
|
41
|
+
```
|
|
42
|
+
parent=$(git show-branch -a 2>/dev/null | grep '\*' | grep -v "$(git branch --show-current)" | head -1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//')
|
|
43
|
+
git checkout "$parent" && git pull
|
|
44
|
+
git merge --squash -
|
|
45
|
+
git commit -m "feat: <summary>"
|
|
46
|
+
git push origin "$parent"
|
|
47
|
+
git branch -d - && git push origin --delete -
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
4. **Merge commit** — merge with `--no-ff`, push parent, delete branch:
|
|
51
|
+
```
|
|
52
|
+
parent=$(git show-branch -a 2>/dev/null | grep '\*' | grep -v "$(git branch --show-current)" | head -1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//')
|
|
53
|
+
git checkout "$parent" && git pull
|
|
54
|
+
git merge --no-ff -m "Merge branch '<branch>'" -
|
|
55
|
+
git push origin "$parent"
|
|
56
|
+
git branch -d - && git push origin --delete -
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
For options 2–4, confirm the detected parent branch with the human before proceeding.
|
|
60
|
+
|
|
61
|
+
4. **Clean up** — if a worktree was used, remove it:
|
|
62
|
+
```
|
|
63
|
+
git worktree remove ../<repo>-<feature-name>
|
|
64
|
+
```
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Commit:** `feat: add merge strategy options to finalizing skill`
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Done
|
|
72
|
+
|
|
73
|
+
The finalizing skill now offers four merge strategies instead of only "Create PR". No code files changed — this is a skill-documentation update only.
|
|
74
|
+
|
|
75
|
+
To verify: read `skills/finalizing/SKILL.md` and confirm it contains all four options with correct commands.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Workspace Setup: Move Branch Creation to Brainstorming
|
|
2
|
+
|
|
3
|
+
## Problem
|
|
4
|
+
|
|
5
|
+
Brainstorming commits the design doc to whatever branch you're on (usually `main`), polluting it. If the idea is scrapped, you have to revert the commit. The implementation branch created later by writing-plans starts from a point after the design commit, which is messy.
|
|
6
|
+
|
|
7
|
+
## Design
|
|
8
|
+
|
|
9
|
+
Move branch/worktree creation from writing-plans into brainstorming. The design doc lands on the feature branch from the start, keeping `main` clean.
|
|
10
|
+
|
|
11
|
+
## Changes
|
|
12
|
+
|
|
13
|
+
### brainstorming/SKILL.md
|
|
14
|
+
|
|
15
|
+
Step 5 changes from writing + committing the design doc on the current branch to:
|
|
16
|
+
|
|
17
|
+
1. Create a feature branch (`git checkout -b <feature-name>`) or worktree (`git worktree add ../<repo>-<feature-name> -b <feature-name>`) for larger features
|
|
18
|
+
2. Write the design doc to `docs/plans/YYYY-MM-DD-<topic>-design.md`
|
|
19
|
+
3. Single commit on the new branch with the design doc
|
|
20
|
+
|
|
21
|
+
Feature name is derived from the topic slug in the design doc filename.
|
|
22
|
+
|
|
23
|
+
### writing-plans/SKILL.md
|
|
24
|
+
|
|
25
|
+
- Remove step 2 ("Set up workspace") entirely
|
|
26
|
+
- Step 1 expands to verify the feature branch/worktree context created by brainstorming
|
|
27
|
+
- Steps renumber: 1→2→3 becomes 1→2
|
|
28
|
+
- Fallback path (no design doc, brainstorming was skipped) still creates a branch itself so writing-plans works standalone
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Workspace Setup: Implementation Plan
|
|
2
|
+
|
|
3
|
+
## Tasks
|
|
4
|
+
|
|
5
|
+
### Task 1: Update brainstorming/SKILL.md — add workspace setup to step 5
|
|
6
|
+
|
|
7
|
+
**Scenario:** Trivial (docs)
|
|
8
|
+
|
|
9
|
+
Replace step 5 with workspace creation + design doc commit.
|
|
10
|
+
|
|
11
|
+
**File:** `skills/brainstorming/SKILL.md`
|
|
12
|
+
|
|
13
|
+
Replace:
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
5. **Write the design doc** — save to `docs/plans/YYYY-MM-DD-<topic>-design.md` and commit.
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
With:
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
5. **Set up workspace & write the design doc** — create a branch for this work. For larger features, use a git worktree for isolation:
|
|
23
|
+
```
|
|
24
|
+
git worktree add ../<repo>-<feature-name> -b <feature-name>
|
|
25
|
+
```
|
|
26
|
+
Save the design doc to `docs/plans/YYYY-MM-DD-<topic>-design.md` and commit on the new branch.
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**Commit:** `refactor(brainstorming): move workspace setup into step 5`
|
|
30
|
+
|
|
31
|
+
### Task 2: Update writing-plans/SKILL.md — remove step 2, expand step 1
|
|
32
|
+
|
|
33
|
+
**Scenario:** Trivial (docs)
|
|
34
|
+
|
|
35
|
+
Remove step 2 ("Set up workspace") entirely. Expand step 1 to verify the feature branch context. Renumber step 3 → 2.
|
|
36
|
+
|
|
37
|
+
**File:** `skills/writing-plans/SKILL.md`
|
|
38
|
+
|
|
39
|
+
Replace:
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
1. **Check for a design doc** — look for `docs/plans/*-design.md`. If one exists, use it as the basis for the plan. If none exists, ask the user to describe what they want to build, read relevant code, and create the plan directly.
|
|
43
|
+
2. **Set up workspace** — create a branch for this work. For larger features, use a git worktree for isolation:
|
|
44
|
+
```
|
|
45
|
+
git worktree add ../<repo>-<feature-name> -b <feature-name>
|
|
46
|
+
```
|
|
47
|
+
3. **Write the implementation plan** — break the design into tasks. Save to `docs/plans/YYYY-MM-DD-<topic>-implementation.md`.
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
With:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
1. **Check for a design doc & workspace** — look for `docs/plans/*-design.md`. If one exists, use it as the basis for the plan. Verify you're on the feature branch (or in its worktree) created during brainstorming. If no design doc exists, ask the user to describe what they want to build, read relevant code, create a branch, and create the plan directly.
|
|
54
|
+
2. **Write the implementation plan** — break the design into tasks. Save to `docs/plans/YYYY-MM-DD-<topic>-implementation.md`.
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Commit:** `refactor(writing-plans): remove workspace setup, verify branch context`
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
1
2
|
import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -28,15 +29,17 @@ export default function (pi: ExtensionAPI) {
|
|
|
28
29
|
|
|
29
30
|
pi.on("input", (event) => {
|
|
30
31
|
const text = event.text ?? "";
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const match = text.match(/^\/skill:([\w-]+)/);
|
|
33
|
+
if (match) {
|
|
34
|
+
const skill = match[1];
|
|
35
|
+
if (skill in SKILL_TO_PHASE) {
|
|
36
|
+
phase = SKILL_TO_PHASE[skill];
|
|
34
37
|
return;
|
|
35
38
|
}
|
|
36
39
|
}
|
|
37
40
|
if (
|
|
38
|
-
text.
|
|
39
|
-
text.
|
|
41
|
+
text.startsWith("/skill:executing-tasks") ||
|
|
42
|
+
text.startsWith("/skill:finalizing")
|
|
40
43
|
) {
|
|
41
44
|
phase = null;
|
|
42
45
|
}
|
|
@@ -50,7 +53,9 @@ export default function (pi: ExtensionAPI) {
|
|
|
50
53
|
const filePath = (event.input as { path?: string }).path ?? "";
|
|
51
54
|
if (!filePath) return;
|
|
52
55
|
|
|
53
|
-
|
|
56
|
+
const absolute = resolve(ctx.cwd, filePath);
|
|
57
|
+
const plansDir = resolve(ctx.cwd, "docs/plans");
|
|
58
|
+
if (absolute.startsWith(plansDir + "/")) return;
|
|
54
59
|
|
|
55
60
|
if (ctx.hasUI) {
|
|
56
61
|
ctx.ui.notify(
|
|
@@ -60,7 +65,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
60
65
|
}
|
|
61
66
|
|
|
62
67
|
return {
|
|
63
|
-
|
|
68
|
+
block: true,
|
|
64
69
|
reason: `⚠️ ${phase.toUpperCase()} PHASE: Cannot ${event.toolName} to ${filePath}. Only docs/plans/ is writable during brainstorming and planning.`,
|
|
65
70
|
};
|
|
66
71
|
});
|
package/package.json
CHANGED
|
@@ -13,7 +13,11 @@ Read-only exploration. You may **not** edit or create any files except under `do
|
|
|
13
13
|
2. **Understand the idea** — read existing code, docs, and recent commits. Ask questions one at a time to refine the idea. Prefer multiple choice when possible.
|
|
14
14
|
3. **Explore approaches** — propose 2-3 approaches with trade-offs. Lead with your recommendation.
|
|
15
15
|
4. **Present the design** — break it into sections of 200-300 words. Check after each section whether it looks right. Cover: architecture, components, data flow, error handling, testing.
|
|
16
|
-
5. **
|
|
16
|
+
5. **Set up workspace & write the design doc** — create a branch for this work. For larger features, use a git worktree for isolation:
|
|
17
|
+
```
|
|
18
|
+
git worktree add ../<repo>-<feature-name> -b <feature-name>
|
|
19
|
+
```
|
|
20
|
+
Save the design doc to `docs/plans/YYYY-MM-DD-<topic>-design.md` and commit on the new branch.
|
|
17
21
|
|
|
18
22
|
## Principles
|
|
19
23
|
|
|
@@ -9,13 +9,30 @@ Implement the plan from `docs/plans/*-implementation.md` task by task.
|
|
|
9
9
|
|
|
10
10
|
## Per-task lifecycle
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
Check each task for a `checkpoint` label and follow the appropriate flow:
|
|
13
|
+
|
|
14
|
+
### No checkpoint (auto-advance)
|
|
13
15
|
|
|
14
16
|
1. **Implement** — write the code as described in the plan
|
|
15
17
|
2. **Run tests** — verify the changes work
|
|
16
18
|
3. **Fix if needed** — if tests fail, debug and fix before moving on
|
|
17
19
|
4. **Commit** — `git add` the relevant files and commit with a clear message
|
|
18
20
|
|
|
21
|
+
### checkpoint: test
|
|
22
|
+
|
|
23
|
+
1. **Write the test** — follow the TDD scenario for the task
|
|
24
|
+
2. **Pause for review** — show what was done and the diff, then wait for human input
|
|
25
|
+
3. **Continue** — implement, run tests, fix if needed
|
|
26
|
+
4. **Commit** — `git add` the relevant files and commit with a clear message
|
|
27
|
+
|
|
28
|
+
### checkpoint: done
|
|
29
|
+
|
|
30
|
+
1. **Implement** — write the code as described in the plan
|
|
31
|
+
2. **Run tests** — verify the changes work
|
|
32
|
+
3. **Fix if needed** — if tests fail, debug and fix before moving on
|
|
33
|
+
4. **Pause for review** — show what was done and the diff, then wait for human input
|
|
34
|
+
5. **Commit** — `git add` the relevant files and commit with a clear message
|
|
35
|
+
|
|
19
36
|
## TDD discipline
|
|
20
37
|
|
|
21
38
|
Follow the TDD scenario from the plan:
|
|
@@ -26,6 +43,25 @@ Follow the TDD scenario from the plan:
|
|
|
26
43
|
|
|
27
44
|
Don't skip tests because "it's obvious." The test is the contract.
|
|
28
45
|
|
|
46
|
+
## Checkpoint review
|
|
47
|
+
|
|
48
|
+
When pausing at a checkpoint, present:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
⏸ Paused at checkpoint: [test|done] for task [N]
|
|
52
|
+
|
|
53
|
+
**What was done:** [brief summary]
|
|
54
|
+
**Diff:** [show relevant diff]
|
|
55
|
+
|
|
56
|
+
Review and let me know how to proceed.
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Wait for the human to respond. They may:
|
|
60
|
+
- Approve and continue
|
|
61
|
+
- Request changes to the test or implementation
|
|
62
|
+
- Ask to revert the task
|
|
63
|
+
- Adjust the remaining plan
|
|
64
|
+
|
|
29
65
|
## Receiving code review
|
|
30
66
|
|
|
31
67
|
When the user shares code review feedback:
|
|
@@ -9,11 +9,12 @@ Ship the completed work.
|
|
|
9
9
|
|
|
10
10
|
## Process
|
|
11
11
|
|
|
12
|
-
1. **Move planning docs** — archive the design and implementation docs:
|
|
12
|
+
1. **Move planning docs** — archive the design and implementation docs, then commit:
|
|
13
13
|
```
|
|
14
14
|
mkdir -p docs/plans/completed
|
|
15
15
|
mv docs/plans/*-design.md docs/plans/completed/
|
|
16
16
|
mv docs/plans/*-implementation.md docs/plans/completed/
|
|
17
|
+
git add docs/plans/completed/ && git commit -m "chore: archive planning docs"
|
|
17
18
|
```
|
|
18
19
|
|
|
19
20
|
2. **Update documentation** — if the API or surface changed:
|
|
@@ -21,13 +22,46 @@ Ship the completed work.
|
|
|
21
22
|
- Update CHANGELOG.md
|
|
22
23
|
- Update any inline docs
|
|
23
24
|
|
|
24
|
-
3. **
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
3. **Choose a merge strategy** — ask the human which option they prefer:
|
|
26
|
+
|
|
27
|
+
1. **Create PR** — push and open a PR for external review:
|
|
28
|
+
```
|
|
29
|
+
git push origin <branch>
|
|
30
|
+
gh pr create --title "feat: <summary>" --body "<task summary>"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
2. **Rebase & merge** *(recommended)* — rebase onto parent, fast-forward merge, push parent, delete branch:
|
|
34
|
+
```
|
|
35
|
+
parent=$(git show-branch -a 2>/dev/null | grep '\*' | grep -v "$(git branch --show-current)" | head -1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//')
|
|
36
|
+
git checkout "$parent" && git pull
|
|
37
|
+
git checkout - && git rebase "$parent"
|
|
38
|
+
git checkout "$parent" && git merge --ff-only -
|
|
39
|
+
git push origin "$parent"
|
|
40
|
+
git branch -d - && git push origin --delete -
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
3. **Squash & merge** — squash all commits into one on parent, push parent, delete branch:
|
|
44
|
+
```
|
|
45
|
+
parent=$(git show-branch -a 2>/dev/null | grep '\*' | grep -v "$(git branch --show-current)" | head -1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//')
|
|
46
|
+
git checkout "$parent" && git pull
|
|
47
|
+
git merge --squash -
|
|
48
|
+
git commit -m "feat: <summary>"
|
|
49
|
+
git push origin "$parent"
|
|
50
|
+
git branch -d - && git push origin --delete -
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
4. **Merge commit** — merge with `--no-ff`, push parent, delete branch:
|
|
54
|
+
```
|
|
55
|
+
parent=$(git show-branch -a 2>/dev/null | grep '\*' | grep -v "$(git branch --show-current)" | head -1 | sed 's/.*\[\(.*\)\].*/\1/' | sed 's/[\^~].*//')
|
|
56
|
+
git checkout "$parent" && git pull
|
|
57
|
+
git merge --no-ff -m "Merge branch '<branch>'" -
|
|
58
|
+
git push origin "$parent"
|
|
59
|
+
git branch -d - && git push origin --delete -
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
For options 2–4, confirm the detected parent branch with the human before proceeding.
|
|
29
63
|
|
|
30
|
-
4. **Clean up** — if a worktree was used, remove it
|
|
64
|
+
4. **Clean up** — if a worktree was used, remove it:
|
|
31
65
|
```
|
|
32
66
|
git worktree remove ../<repo>-<feature-name>
|
|
33
67
|
```
|
|
@@ -9,12 +9,8 @@ Read-only exploration. You may **not** edit or create any files except under `do
|
|
|
9
9
|
|
|
10
10
|
## Process
|
|
11
11
|
|
|
12
|
-
1. **Check for a design doc** — look for `docs/plans/*-design.md`. If one exists, use it as the basis for the plan. If
|
|
13
|
-
2. **
|
|
14
|
-
```
|
|
15
|
-
git worktree add ../<repo>-<feature-name> -b <feature-name>
|
|
16
|
-
```
|
|
17
|
-
3. **Write the implementation plan** — break the design into tasks. Save to `docs/plans/YYYY-MM-DD-<topic>-implementation.md`.
|
|
12
|
+
1. **Check for a design doc & workspace** — look for `docs/plans/*-design.md`. If one exists, use it as the basis for the plan. Verify you're on the feature branch (or in its worktree) created during brainstorming. If no design doc exists, ask the user to describe what they want to build, read relevant code, create a branch, and create the plan directly.
|
|
13
|
+
2. **Write the implementation plan** — break the design into tasks. Save to `docs/plans/YYYY-MM-DD-<topic>-implementation.md`.
|
|
18
14
|
|
|
19
15
|
## Task format
|
|
20
16
|
|
|
@@ -24,6 +20,7 @@ Each task should be 2-5 minutes of work:
|
|
|
24
20
|
- Complete code (not "add validation")
|
|
25
21
|
- Exact commands with expected output
|
|
26
22
|
- `git commit` after each task
|
|
23
|
+
- Optional `checkpoint: test` or `checkpoint: done` label
|
|
27
24
|
|
|
28
25
|
## TDD in the plan
|
|
29
26
|
|
|
@@ -35,6 +32,18 @@ Label each task with its TDD scenario:
|
|
|
35
32
|
| **Modifying tested code** | Changing existing behavior | Run existing tests first → modify → verify they pass → commit |
|
|
36
33
|
| **Trivial** | Config, docs, naming | Use judgment, commit when done |
|
|
37
34
|
|
|
35
|
+
## Checkpoint labels
|
|
36
|
+
|
|
37
|
+
Optionally label each task with a `checkpoint` to require human review before proceeding:
|
|
38
|
+
|
|
39
|
+
| Checkpoint | When to use | What happens during execution |
|
|
40
|
+
|---|---|---|
|
|
41
|
+
| *(none)* | Trivial tasks, well-understood changes | Auto-advance, no pause |
|
|
42
|
+
| **`checkpoint: test`** | Test design matters (API contracts, edge cases, complex behavior) | Pause after writing the failing test, before implementing |
|
|
43
|
+
| **`checkpoint: done`** | Implementation review matters (complex logic, security, performance) | Pause after implementation + tests pass, before committing |
|
|
44
|
+
|
|
45
|
+
Use judgment when assigning checkpoints. Prefer `checkpoint: test` for new features with non-obvious test design. Prefer `checkpoint: done` for tasks where the implementation approach is debatable. Most tasks should not need a checkpoint. The user can adjust checkpoints when reviewing the plan.
|
|
46
|
+
|
|
38
47
|
## After the plan
|
|
39
48
|
|
|
40
49
|
Ask: "Ready to execute? Run `/skill:executing-tasks`"
|