@tianhai/pi-workflow-kit 0.5.3 → 0.7.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 (70) hide show
  1. package/README.md +50 -490
  2. package/docs/developer-usage-guide.md +41 -401
  3. package/docs/oversight-model.md +13 -34
  4. package/docs/plans/2026-04-11-finalizing-merge-options-design.md +33 -0
  5. package/docs/plans/completed/2026-04-11-checkpoint-review-gates-design.md +50 -0
  6. package/docs/plans/completed/2026-04-11-checkpoint-review-gates-implementation.md +98 -0
  7. package/docs/plans/completed/2026-04-11-finalizing-merge-options-design.md +33 -0
  8. package/docs/plans/completed/2026-04-11-finalizing-merge-options-implementation.md +75 -0
  9. package/docs/plans/completed/2026-04-11-workspace-setup-design.md +28 -0
  10. package/docs/plans/completed/2026-04-11-workspace-setup-implementation.md +57 -0
  11. package/docs/workflow-phases.md +32 -46
  12. package/extensions/workflow-guard.ts +67 -0
  13. package/package.json +3 -7
  14. package/skills/brainstorming/SKILL.md +20 -67
  15. package/skills/executing-tasks/SKILL.md +49 -214
  16. package/skills/finalizing/SKILL.md +67 -0
  17. package/skills/writing-plans/SKILL.md +29 -129
  18. package/ROADMAP.md +0 -16
  19. package/agents/code-reviewer.md +0 -18
  20. package/agents/config.ts +0 -5
  21. package/agents/implementer.md +0 -26
  22. package/agents/spec-reviewer.md +0 -13
  23. package/agents/worker.md +0 -17
  24. package/docs/plans/2026-04-10-brainstorming-boundary-enforcement-design.md +0 -60
  25. package/docs/plans/completed/2026-04-09-cleanup-legacy-state-and-enforce-think-phases-design.md +0 -56
  26. package/docs/plans/completed/2026-04-09-cleanup-legacy-state-and-enforce-think-phases-implementation.md +0 -196
  27. package/docs/plans/completed/2026-04-09-workflow-next-autocomplete-design.md +0 -185
  28. package/docs/plans/completed/2026-04-09-workflow-next-autocomplete-implementation.md +0 -334
  29. package/docs/plans/completed/2026-04-09-workflow-next-handoff-state-design.md +0 -251
  30. package/docs/plans/completed/2026-04-09-workflow-next-handoff-state-implementation.md +0 -253
  31. package/extensions/constants.ts +0 -15
  32. package/extensions/lib/logging.ts +0 -138
  33. package/extensions/plan-tracker.ts +0 -508
  34. package/extensions/subagent/agents.ts +0 -144
  35. package/extensions/subagent/concurrency.ts +0 -52
  36. package/extensions/subagent/env.ts +0 -47
  37. package/extensions/subagent/index.ts +0 -1181
  38. package/extensions/subagent/lifecycle.ts +0 -25
  39. package/extensions/subagent/timeout.ts +0 -13
  40. package/extensions/workflow-monitor/debug-monitor.ts +0 -98
  41. package/extensions/workflow-monitor/git.ts +0 -31
  42. package/extensions/workflow-monitor/heuristics.ts +0 -58
  43. package/extensions/workflow-monitor/investigation.ts +0 -52
  44. package/extensions/workflow-monitor/reference-tool.ts +0 -42
  45. package/extensions/workflow-monitor/skip-confirmation.ts +0 -19
  46. package/extensions/workflow-monitor/tdd-monitor.ts +0 -137
  47. package/extensions/workflow-monitor/test-runner.ts +0 -37
  48. package/extensions/workflow-monitor/verification-monitor.ts +0 -61
  49. package/extensions/workflow-monitor/warnings.ts +0 -81
  50. package/extensions/workflow-monitor/workflow-handler.ts +0 -363
  51. package/extensions/workflow-monitor/workflow-next-completions.ts +0 -68
  52. package/extensions/workflow-monitor/workflow-next-state.ts +0 -112
  53. package/extensions/workflow-monitor/workflow-tracker.ts +0 -286
  54. package/extensions/workflow-monitor/workflow-transitions.ts +0 -88
  55. package/extensions/workflow-monitor.ts +0 -909
  56. package/skills/dispatching-parallel-agents/SKILL.md +0 -194
  57. package/skills/receiving-code-review/SKILL.md +0 -196
  58. package/skills/systematic-debugging/SKILL.md +0 -170
  59. package/skills/systematic-debugging/condition-based-waiting-example.ts +0 -158
  60. package/skills/systematic-debugging/condition-based-waiting.md +0 -115
  61. package/skills/systematic-debugging/defense-in-depth.md +0 -122
  62. package/skills/systematic-debugging/find-polluter.sh +0 -63
  63. package/skills/systematic-debugging/reference/rationalizations.md +0 -61
  64. package/skills/systematic-debugging/root-cause-tracing.md +0 -169
  65. package/skills/test-driven-development/SKILL.md +0 -266
  66. package/skills/test-driven-development/reference/examples.md +0 -101
  67. package/skills/test-driven-development/reference/rationalizations.md +0 -67
  68. package/skills/test-driven-development/reference/when-stuck.md +0 -33
  69. package/skills/test-driven-development/testing-anti-patterns.md +0 -299
  70. package/skills/using-git-worktrees/SKILL.md +0 -231
@@ -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,71 +1,57 @@
1
1
  # Workflow Phases
2
2
 
3
- `pi-workflow-kit` tracks four global phases:
3
+ `pi-workflow-kit` has 4 phases. You invoke each one explicitly with `/skill:`.
4
4
 
5
- ```text
5
+ ```
6
6
  brainstorm → plan → execute → finalize
7
7
  ```
8
8
 
9
9
  ## brainstorm
10
10
 
11
- Primary skill: `/skill:brainstorming`
11
+ ```
12
+ /skill:brainstorming
13
+ ```
12
14
 
13
- Purpose:
14
- - explore requirements
15
- - shape the design
16
- - produce a design artifact under `docs/plans/`
15
+ - Explore requirements and shape the design
16
+ - Ask questions one at a time, propose approaches
17
+ - Produce `docs/plans/YYYY-MM-DD-<topic>-design.md`
17
18
 
18
- Write boundary:
19
- - allowed: `docs/plans/`
20
- - discouraged elsewhere; runtime warnings may be injected
19
+ Write boundary: only `docs/plans/` is writable. Source files are hard-blocked.
21
20
 
22
21
  ## plan
23
22
 
24
- Primary skill: `/skill:writing-plans`
23
+ ```
24
+ /skill:writing-plans
25
+ ```
25
26
 
26
- Purpose:
27
- - turn the design into a concrete implementation plan
28
- - define task type (`code` or `non-code`)
29
- - define code-task steps or non-code acceptance criteria
27
+ - Read the design doc
28
+ - Break into bite-sized tasks with TDD scenarios
29
+ - Optionally set up a branch or worktree
30
+ - Produce `docs/plans/YYYY-MM-DD-<topic>-implementation.md`
30
31
 
31
- Write boundary:
32
- - allowed: `docs/plans/`
33
- - discouraged elsewhere; runtime warnings may be injected
32
+ Write boundary: only `docs/plans/` is writable. Source files are hard-blocked.
34
33
 
35
34
  ## execute
36
35
 
37
- Primary skill: `/skill:executing-tasks`
36
+ ```
37
+ /skill:executing-tasks
38
+ ```
38
39
 
39
- Purpose:
40
- - initialize `plan_tracker`
41
- - execute tasks one at a time
42
- - track per-task phase and attempt counts
40
+ - Read the implementation plan
41
+ - Implement tasks one at a time: implement → test → fix → commit
42
+ - Handle code review feedback by verifying criticism before implementing
43
43
 
44
- Per-task phases:
45
- - `define`
46
- - `approve`
47
- - `execute`
48
- - `verify`
49
- - `review`
50
- - `fix`
51
- - terminal states: `complete`, `blocked`
44
+ No write restrictions. All tools available.
52
45
 
53
46
  ## finalize
54
47
 
55
- Primary skill: `/skill:executing-tasks`
56
-
57
- Purpose:
58
- - perform holistic review
59
- - prepare PR / push / cleanup
60
- - archive planning docs
61
- - update README / CHANGELOG / other documentation when needed
62
-
63
- ## Detection signals
48
+ ```
49
+ /skill:finalizing
50
+ ```
64
51
 
65
- The workflow monitor uses a few practical signals:
52
+ - Archive plan docs to `docs/plans/completed/`
53
+ - Update CHANGELOG, README if needed
54
+ - Create PR
55
+ - Clean up worktree if one was used
66
56
 
67
- - skill invocations such as `/skill:brainstorming` or `/skill:writing-plans`
68
- - writes to `docs/plans/*-design.md` and `docs/plans/*-implementation.md`
69
- - `plan_tracker` initialization to enter execute
70
- - all tracked tasks reaching terminal state to mark execute complete
71
- - boundary-prompt acceptance to enter finalize
57
+ No write restrictions. All tools available.
@@ -0,0 +1,67 @@
1
+ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
2
+
3
+ /**
4
+ * Workflow Guard extension.
5
+ *
6
+ * Blocks write/edit outside docs/plans/ during brainstorm and plan phases.
7
+ * You control phases explicitly via /skill: commands — no auto-detection,
8
+ * no state persistence, no prompts.
9
+ */
10
+
11
+ type Phase = "brainstorm" | "plan" | null;
12
+
13
+ const SKILL_TO_PHASE: Record<string, Phase> = {
14
+ brainstorming: "brainstorm",
15
+ "writing-plans": "plan",
16
+ };
17
+
18
+ export function getCurrentPhase(): Phase {
19
+ return phase;
20
+ }
21
+
22
+ let phase: Phase = null;
23
+
24
+ export default function (pi: ExtensionAPI) {
25
+ pi.on("session_start", () => {
26
+ phase = null;
27
+ });
28
+
29
+ pi.on("input", (event) => {
30
+ const text = event.text ?? "";
31
+ for (const [skill, p] of Object.entries(SKILL_TO_PHASE)) {
32
+ if (text.includes(skill)) {
33
+ phase = p;
34
+ return;
35
+ }
36
+ }
37
+ if (
38
+ text.includes("executing-tasks") ||
39
+ text.includes("finalizing")
40
+ ) {
41
+ phase = null;
42
+ }
43
+ });
44
+
45
+ pi.on("tool_call", (event, ctx) => {
46
+ if (!phase) return;
47
+
48
+ if (event.toolName !== "write" && event.toolName !== "edit") return;
49
+
50
+ const filePath = (event.input as { path?: string }).path ?? "";
51
+ if (!filePath) return;
52
+
53
+ if (filePath.startsWith("docs/plans/")) return;
54
+
55
+ if (ctx.hasUI) {
56
+ ctx.ui.notify(
57
+ `Blocked ${event.toolName} to ${filePath} during ${phase} phase. Only docs/plans/ is writable.`,
58
+ "warning",
59
+ );
60
+ }
61
+
62
+ return {
63
+ blocked: true,
64
+ reason: `⚠️ ${phase.toUpperCase()} PHASE: Cannot ${event.toolName} to ${filePath}. Only docs/plans/ is writable during brainstorming and planning.`,
65
+ };
66
+ });
67
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tianhai/pi-workflow-kit",
3
- "version": "0.5.3",
3
+ "version": "0.7.0",
4
4
  "description": "Workflow skills and enforcement extensions for pi",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -18,19 +18,15 @@
18
18
  },
19
19
  "files": [
20
20
  "extensions/",
21
- "agents/",
22
21
  "skills/",
23
22
  "docs/",
24
23
  "banner.jpg",
25
24
  "LICENSE",
26
- "README.md",
27
- "ROADMAP.md"
25
+ "README.md"
28
26
  ],
29
27
  "pi": {
30
28
  "extensions": [
31
- "extensions/plan-tracker.ts",
32
- "extensions/workflow-monitor.ts",
33
- "extensions/subagent/index.ts"
29
+ "extensions/workflow-guard.ts"
34
30
  ],
35
31
  "skills": [
36
32
  "skills"
@@ -1,78 +1,31 @@
1
1
  ---
2
2
  name: brainstorming
3
- description: "You MUST use this before any creative work - creating features, building components, adding functionality, or modifying behavior. Explores user intent, requirements and design before implementation."
4
- allowed-tools: read bash
3
+ description: "Use this before any creative work creating features, building components, adding functionality, or modifying behavior. Explores intent and design before implementation."
5
4
  ---
6
5
 
7
- > **Related skills:** Consider `/skill:using-git-worktrees` to set up an isolated workspace, then `/skill:writing-plans` for implementation planning.
6
+ # Brainstorming
8
7
 
9
- # Brainstorming Ideas Into Designs
8
+ Read-only exploration. You may **not** edit or create any files except under `docs/plans/`.
10
9
 
11
- > ⚠️ **BOUNDARY — DO NOT VIOLATE**
12
- >
13
- > This skill is **read-only exploration**. You MUST NOT use `edit` or `write` tools.
14
- > The only tools allowed are `read` and `bash` (for investigation only).
15
- >
16
- > - ✅ Read code and docs: yes
17
- > - ✅ Write to `docs/plans/`: yes (design documents only)
18
- > - ❌ Edit or create any other files: **absolutely no**
19
- >
20
- > If you find yourself reaching for `edit` or `write`, **stop**. Present what
21
- > you found as a design section and ask the user to approve it first.
10
+ ## Process
22
11
 
23
- ## Overview
12
+ 1. **Check git state** — run `git status` and `git log --oneline -5`. If there's uncommitted work, ask the user what to do with it first.
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
+ 3. **Explore approaches** — propose 2-3 approaches with trade-offs. Lead with your recommendation.
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. **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.
24
21
 
25
- Help turn ideas into fully formed designs and specs through natural collaborative dialogue.
22
+ ## Principles
26
23
 
27
- Start by understanding the current project context, then ask questions one at a time to refine the idea. Once you understand what you're building, present the design in small sections (200-300 words), checking after each section whether it looks right so far.
24
+ - One question at a time
25
+ - YAGNI — remove unnecessary features
26
+ - Design for testability
27
+ - Always explore alternatives before settling
28
28
 
29
- ## The Process
29
+ ## After the design
30
30
 
31
- **Before anything else check git state:**
32
- - Run `git status` and `git log --oneline -5`
33
- - If on a feature branch with uncommitted or unmerged work, ask the user:
34
- - "You're on `<branch>` with uncommitted changes. Want to finish/merge that first, stash it, or continue here?"
35
- - Require exactly one of: finish prior work, stash, or explicitly continue here
36
- - If the topic is new, suggest creating a new branch before brainstorming
37
-
38
- **Understanding the idea:**
39
- - Check out the current project state first (files, docs, recent commits)
40
- - Check if the codebase or ecosystem already solves this before designing from scratch
41
- - Ask questions one at a time to refine the idea
42
- - Prefer multiple choice questions when possible, but open-ended is fine too
43
- - Only one question per message - if a topic needs more exploration, break it into multiple questions
44
- - Focus on understanding: purpose, constraints, success criteria
45
-
46
- **Exploring approaches:**
47
- - Propose 2-3 different approaches with trade-offs
48
- - Present options conversationally with your recommendation and reasoning
49
- - Lead with your recommended option and explain why
50
-
51
- **Presenting the design:**
52
- - Once you believe you understand what you're building, present the design
53
- - Break it into sections of 200-300 words
54
- - Ask after each section whether it looks right so far
55
- - Cover: architecture, components, data flow, error handling, testing
56
- - Be ready to go back and clarify if something doesn't make sense
57
-
58
- ## After the Design
59
-
60
- **Documentation:**
61
- - Write the validated design to `docs/plans/YYYY-MM-DD-<topic>-design.md`
62
- - Commit the design document to git
63
- - The workflow monitor automatically tracks phase transitions when you invoke skills
64
-
65
- **Implementation (if continuing):**
66
- - Ask: "Ready to set up for implementation?"
67
- - Set up isolated workspace — `/skill:using-git-worktrees` for larger work, or just create a branch for small changes
68
- - Use `/skill:writing-plans` to create detailed implementation plan
69
-
70
- ## Key Principles
71
-
72
- - **One question at a time** - Don't overwhelm with multiple questions
73
- - **Multiple choice preferred** - Easier to answer than open-ended when possible
74
- - **YAGNI ruthlessly** - Remove unnecessary features from all designs
75
- - **Design for testability** - Favor approaches with clear boundaries that are easy to verify with TDD
76
- - **Explore alternatives** - Always propose 2-3 approaches before settling
77
- - **Incremental validation** - Present design in sections, validate each
78
- - **Be flexible** - Go back and clarify when something doesn't make sense
31
+ Ask: "Ready to plan? Run `/skill:writing-plans`"