pi-feature-dev 1.2.0 → 1.4.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.
@@ -0,0 +1,57 @@
1
+ # Finalizer worker prompt
2
+
3
+ Use this prompt after all reviews pass. Replace `DEFAULT_BRANCH`,
4
+ `PLAN_FILE_PATH`, `PROGRESS_FILE_PATH`, and `PLAN_EXEC_ROOT` before launch.
5
+
6
+ ```text
7
+ Post-completion finalize step. Organize the branch for merge.
8
+
9
+ Plan file: PLAN_FILE_PATH
10
+ Default branch: DEFAULT_BRANCH
11
+ Progress file: PROGRESS_FILE_PATH
12
+
13
+ STEP 1 - REBASE:
14
+ - Run `git fetch origin`.
15
+ - If `origin/DEFAULT_BRANCH` exists, rebase onto it:
16
+ `git rebase origin/DEFAULT_BRANCH`
17
+ - Otherwise, rebase onto the local default branch:
18
+ `git rebase DEFAULT_BRANCH`
19
+ - If conflicts occur, resolve them and continue when safe.
20
+ - If rebase cannot be completed safely, abort with `git rebase --abort`, report
21
+ the issue, and continue to the report step.
22
+
23
+ STEP 2 - CLEAN UP COMMITS:
24
+ - Inspect commits with `git log --oneline DEFAULT_BRANCH..HEAD`.
25
+ - If there are 5 or more commits, squash related fix commits into their parent
26
+ feature commits when this can be done safely.
27
+ - Keep meaningful boundaries: feature task commits separate from review-fix
28
+ commits.
29
+ - If safe non-interactive cleanup is not practical, leave commits as-is and
30
+ report why.
31
+
32
+ STEP 3 - VERIFY:
33
+ - Run validation commands from the plan file.
34
+ - If the plan does not list exact commands, infer the narrowest relevant
35
+ validation commands from the repository.
36
+ - If validation fails, fix and re-run when the fix is clearly within scope.
37
+
38
+ STEP 4 - LOG PROGRESS:
39
+ - Append:
40
+ `bash PLAN_EXEC_ROOT/scripts/append-progress.sh PROGRESS_FILE_PATH "finalize: completed"`
41
+ - Then pipe details:
42
+ `printf '%s\n' "- rebase: <success/failed/skipped>" "- commits before: <N>, after: <M>" "- squashed: <list or none>" "- validation: <passed/failed>" | bash PLAN_EXEC_ROOT/scripts/append-progress.sh PROGRESS_FILE_PATH`
43
+ - Use only `append-progress.sh` for writing to the progress file.
44
+
45
+ STEP 5 - PLAN DEVIATION ANALYSIS:
46
+ - Read PROGRESS_FILE_PATH in full.
47
+ - Compare it against PLAN_FILE_PATH.
48
+ - Report deviations from the original plan, obstacles or blockers, incomplete
49
+ delivery, cut corners, or review findings that went beyond the original plan.
50
+
51
+ STEP 6 - REPORT:
52
+ Report what was done: number of commits before and after, whether rebase
53
+ succeeded, validation results, and plan deviation analysis.
54
+
55
+ This step is best-effort. If rebase or commit cleanup fails, explain why and
56
+ leave the branch in a coherent state.
57
+ ```
@@ -0,0 +1,58 @@
1
+ # Fixer worker prompt
2
+
3
+ Use this prompt after collecting review findings. Replace `PLAN_FILE_PATH`,
4
+ `PROGRESS_FILE_PATH`, `PLAN_EXEC_ROOT`, and `FINDINGS_LIST` before launch.
5
+
6
+ ```text
7
+ Code review found the following issues. Verify and fix them.
8
+
9
+ Plan file: PLAN_FILE_PATH
10
+ Progress file: PROGRESS_FILE_PATH
11
+
12
+ FINDINGS:
13
+ FINDINGS_LIST
14
+
15
+ STEP 1 - VERIFY:
16
+ For each finding, read the actual code at the specified file and line. Inspect
17
+ enough surrounding context to understand the issue. Classify each finding as:
18
+ - CONFIRMED: real issue, fix it.
19
+ - FALSE POSITIVE: does not exist, is already mitigated, or is outside the
20
+ changed behavior.
21
+
22
+ STEP 2 - FIX:
23
+ - Fix all confirmed issues.
24
+ - Add or update tests when the finding is about behavior, correctness, or a
25
+ regression risk.
26
+ - Keep fixes scoped to the reported issues.
27
+
28
+ STEP 3 - VALIDATE:
29
+ - Run the build, test, lint, typecheck, or validation commands from
30
+ PLAN_FILE_PATH.
31
+ - If the plan does not list exact commands, infer the narrowest relevant
32
+ validation commands from the repository.
33
+ - If anything fails, fix it and re-run validation.
34
+ - Never commit broken code.
35
+
36
+ STEP 4 - COMMIT:
37
+ - Commit fixes only after validation passes:
38
+ `bash PLAN_EXEC_ROOT/scripts/stage-and-commit.sh "fix: address code review findings" <changed-files>`
39
+ - List every changed file explicitly.
40
+ - If all findings are false positives and no files changed, do not create an
41
+ empty commit.
42
+
43
+ STEP 5 - LOG PROGRESS:
44
+ - Pipe details:
45
+ `printf '%s\n' "- confirmed: <list>" "- false positives: <list>" "- fixes: <what changed>" "- validation: <what passed>" | bash PLAN_EXEC_ROOT/scripts/append-progress.sh PROGRESS_FILE_PATH`
46
+ - Use only `append-progress.sh` for writing to the progress file. Do not write to
47
+ the progress file directly.
48
+
49
+ STEP 6 - REPORT:
50
+ Your final response must include a structured summary starting with `FIXES:` on
51
+ its own line, followed by one line per fix or false positive:
52
+
53
+ FIXES:
54
+ - fixed: <file>:<line> - <what was fixed>
55
+ - false positive: <description> - <why discarded>
56
+
57
+ This report is shown to the user. Be specific about what changed.
58
+ ```
@@ -0,0 +1,73 @@
1
+ # Progress file
2
+
3
+ The orchestrator maintains a progress file at `/tmp/progress-<plan-name>.txt`,
4
+ derived from the plan filename stem. The file carries context across task,
5
+ review, fixer, finalizer, and summary phases.
6
+
7
+ ## When to write
8
+
9
+ Use `PLAN_EXEC_ROOT/scripts/append-progress.sh` for all appends. Do not write
10
+ directly to the progress file.
11
+
12
+ At start, `init-progress.sh` writes:
13
+
14
+ ```text
15
+ # progress
16
+ Plan: <plan-file-path>
17
+ Branch: <branch-name>
18
+ Started: <timestamp>
19
+ ---
20
+ ```
21
+
22
+ After each task completes:
23
+
24
+ ```text
25
+ [task] Task N: <title> - completed
26
+ ```
27
+
28
+ After each task fails:
29
+
30
+ ```text
31
+ [task] Task N: <title> - FAILED (retry N)
32
+ ```
33
+
34
+ Before each review phase:
35
+
36
+ ```text
37
+ --- review phase N: <type> ---
38
+ ```
39
+
40
+ After review workers return, before the fixer:
41
+
42
+ ```text
43
+ [review] phase N iteration M findings:
44
+ <full worker output>
45
+ ```
46
+
47
+ After a fixer completes:
48
+
49
+ ```text
50
+ [fixer] phase N iteration M:
51
+ <fixer report>
52
+ ```
53
+
54
+ After finalize:
55
+
56
+ ```text
57
+ [finalize]
58
+ <finalizer report>
59
+ ```
60
+
61
+ At completion:
62
+
63
+ ```text
64
+ ---
65
+ Completed: <timestamp>
66
+ ```
67
+
68
+ ## How to pass it
69
+
70
+ - Pass the progress file path to task, fixer, finalizer, and summary workers.
71
+ - Review workers may read the progress file for context, but must remain
72
+ read-only.
73
+ - The summary worker uses it to derive portable run statistics.
@@ -0,0 +1,104 @@
1
+ # Internal review playbook
2
+
3
+ This file is a playbook for the main orchestrator session, not a worker prompt.
4
+ Replace `DEFAULT_BRANCH`, `PLAN_FILE_PATH`, `PROGRESS_FILE_PATH`,
5
+ `PLAN_EXEC_ROOT`, and `REVIEW_PHASE`, then follow the instructions from the main
6
+ session.
7
+
8
+ All review work must be done by isolated read-only workers. If the host supports
9
+ parallel isolated workers, launch all workers for the phase together. If parallel
10
+ launch is unavailable, run the workers sequentially. Do not review or fix issues
11
+ in the orchestrator session.
12
+
13
+ Each review worker prompt must start with this preamble:
14
+
15
+ ```text
16
+ CRITICAL: You are a READ-ONLY reviewer. Do not run git stash, git checkout, git
17
+ reset, git commit, or any command that modifies the working tree. Other workers
18
+ may run in parallel. Only use read-only commands such as git diff, git log, git
19
+ show, and file reads.
20
+
21
+ Run `git diff DEFAULT_BRANCH...HEAD` to see the full branch diff. Read the
22
+ actual source files for context; do not review from the diff alone.
23
+
24
+ The plan file at PLAN_FILE_PATH describes the goal and requirements.
25
+ The progress file at PROGRESS_FILE_PATH describes previous task and fix work.
26
+ Re-evaluate findings independently. Previous fixes may be incomplete.
27
+
28
+ Tag every finding with severity:
29
+ - CRITICAL: crash, data loss, security vulnerability, race condition, or broken
30
+ core behavior.
31
+ - MAJOR: real correctness issue, missing critical error handling, broken
32
+ contract, or incomplete requirement.
33
+ - MINOR: style, documentation drift, convention mismatch, simplification, or
34
+ optional improvement.
35
+
36
+ Format each finding on its own line:
37
+ `SEVERITY: file:line - description`
38
+
39
+ Report problems only. If you find no issues, report exactly:
40
+ `NO ISSUES FOUND`
41
+ ```
42
+
43
+ ## Comprehensive Mode
44
+
45
+ Used when `REVIEW_PHASE` is `comprehensive`.
46
+
47
+ Launch five read-only workers using these bundled reviewer files:
48
+
49
+ - `PLAN_EXEC_ROOT/references/agents/quality.txt`
50
+ - `PLAN_EXEC_ROOT/references/agents/implementation.txt`
51
+ - `PLAN_EXEC_ROOT/references/agents/testing.txt`
52
+ - `PLAN_EXEC_ROOT/references/agents/simplification.txt`
53
+ - `PLAN_EXEC_ROOT/references/agents/documentation.txt`
54
+
55
+ For each worker, prepend the read-only preamble above to the corresponding
56
+ reviewer file content.
57
+
58
+ After all workers return, produce a strict finding report:
59
+
60
+ - Group findings by severity in this order: `CRITICAL`, `MAJOR`, `MINOR`.
61
+ - Use a heading per severity: `### CRITICAL`, `### MAJOR`, `### MINOR`.
62
+ - Skip severity headings with zero findings.
63
+ - Under each heading, use exactly:
64
+ `- <reviewer-name>: <file:line> - <description>`
65
+ - Preserve reviewer attribution: `quality`, `implementation`, `testing`,
66
+ `simplification`, or `documentation`.
67
+ - If two reviewers report the same file, line, and issue, merge into one bullet
68
+ and join reviewer names with `+`.
69
+ - Do not verify, fix, dismiss, or rewrite findings.
70
+ - Omit reviewers that found nothing.
71
+ - After the bullet list, emit:
72
+ `Total: <N> findings (<C> critical, <M> major, <m> minor)`
73
+
74
+ If all workers report `NO ISSUES FOUND`, emit exactly:
75
+
76
+ ```text
77
+ Comprehensive review: clean - no findings.
78
+ ```
79
+
80
+ ## Critical-Only Mode
81
+
82
+ Used when `REVIEW_PHASE` is `critical`.
83
+
84
+ Launch two read-only workers using these bundled reviewer files:
85
+
86
+ - `PLAN_EXEC_ROOT/references/agents/quality.txt`
87
+ - `PLAN_EXEC_ROOT/references/agents/implementation.txt`
88
+
89
+ For each worker, prepend the read-only preamble above plus this additional
90
+ instruction:
91
+
92
+ ```text
93
+ Report only CRITICAL and MAJOR issues. Ignore MINOR findings, style concerns,
94
+ optional improvements, documentation nits, and simplification opportunities.
95
+ ```
96
+
97
+ After both workers return, produce the same strict finding report as
98
+ comprehensive mode, but include only `CRITICAL` and `MAJOR` sections.
99
+
100
+ If neither worker reports critical or major findings, emit exactly:
101
+
102
+ ```text
103
+ Critical review: clean - no critical/major findings.
104
+ ```
@@ -0,0 +1,82 @@
1
+ # Portable run summary prompt
2
+
3
+ Use this for the read-only summary worker after finalize completes. Replace
4
+ `DEFAULT_BRANCH`, `PLAN_FILE_PATH`, and `PROGRESS_FILE_PATH` before launch.
5
+
6
+ ```text
7
+ You are a read-only summary worker for a plan-exec run that just finished.
8
+ Produce a concise markdown summary from the plan file, progress file, and Git
9
+ state only.
10
+
11
+ Plan file: PLAN_FILE_PATH
12
+ Progress file: PROGRESS_FILE_PATH
13
+ Default branch: DEFAULT_BRANCH
14
+
15
+ READ-ONLY CONSTRAINTS:
16
+ - Do not modify files.
17
+ - Do not edit the plan.
18
+ - Do not commit.
19
+ - Do not read host-specific telemetry logs, token logs, session JSONL files, or
20
+ assistant-internal metadata.
21
+
22
+ STEP 1 - READ RUN STATE:
23
+ - Read PLAN_FILE_PATH.
24
+ - Read PROGRESS_FILE_PATH if it exists.
25
+ - Determine the current branch with `git branch --show-current`.
26
+
27
+ STEP 2 - PLAN PROGRESS:
28
+ - Count completed and remaining checkboxes in task or iteration sections.
29
+ - Identify the final run state from the progress file when possible:
30
+ completed, max-iterations-hit, aborted, or unknown.
31
+ - Count implementation task entries in the progress file when possible.
32
+ - Count review and fixer iterations in the progress file when possible.
33
+
34
+ STEP 3 - GIT STATS:
35
+ Run read-only Git commands:
36
+ - `git diff --shortstat DEFAULT_BRANCH...HEAD`
37
+ - `git diff --stat DEFAULT_BRANCH...HEAD`
38
+ - `git log --oneline DEFAULT_BRANCH..HEAD`
39
+
40
+ If those commands fail because DEFAULT_BRANCH is unavailable, retry against
41
+ `origin/DEFAULT_BRANCH` when it exists. If both fail, report `n/a`.
42
+
43
+ STEP 4 - OUTPUT:
44
+ Emit only this markdown report. Keep it compact.
45
+
46
+ ## Run summary
47
+
48
+ **Branch:** <current branch>
49
+ **Plan:** PLAN_FILE_PATH
50
+ **Final state:** <completed | max-iterations-hit | aborted | unknown>
51
+
52
+ ### Plan progress
53
+
54
+ - Task sections complete: <N>/<M>
55
+ - Remaining unchecked items: <N>
56
+ - Implementation task runs: <N or n/a>
57
+
58
+ ### Review and fixes
59
+
60
+ - Review phase 1 iterations: <N or n/a>
61
+ - Smells review: <clean | fixed | findings | n/a>
62
+ - Critical review: <clean | fixed | findings | n/a>
63
+ - Fixer runs: <N or n/a>
64
+
65
+ ### Branch changes
66
+
67
+ - Commits on branch: <N or n/a>
68
+ - Diff shortstat: <shortstat or n/a>
69
+
70
+ Top files by churn:
71
+ - <file> <stats>
72
+ - <file> <stats>
73
+ - <file> <stats>
74
+
75
+ ### Notable
76
+
77
+ - Rebase/finalize: <summary or n/a>
78
+ - Validation: <summary or n/a>
79
+ - Deviations/blockers: <summary or n/a>
80
+
81
+ If a section has no data, write `n/a` rather than inventing numbers.
82
+ ```
@@ -0,0 +1,57 @@
1
+ # Task worker prompt
2
+
3
+ Use this prompt when spawning each implementation worker. Replace
4
+ `PLAN_FILE_PATH`, `PROGRESS_FILE_PATH`, and `PLAN_EXEC_ROOT` before launch.
5
+
6
+ ```text
7
+ Read the plan file at PLAN_FILE_PATH. Find the FIRST Task section
8
+ (`### Task N:` or `### Iteration N:`) that has uncompleted checkboxes (`[ ]`).
9
+
10
+ If a task section has `[ ]` checkboxes you cannot complete because they require
11
+ manual testing, deployment verification, credentials, or external systems, mark
12
+ them `[x]` with a note like `[x] manual test (skipped - not automatable)` and
13
+ continue.
14
+
15
+ CRITICAL CONSTRAINT: Complete ONE task section per worker run.
16
+ A task section is a `### Task N:` or `### Iteration N:` heading with all
17
+ checkboxes underneath it. Complete all checkboxes in that section, then stop.
18
+ Do not continue to the next section.
19
+
20
+ STEP 1 - IMPLEMENT:
21
+ - Read the plan's Overview, Context, Review Handoff, Development Approach,
22
+ Testing Strategy, and Technical Details sections when present.
23
+ - Implement all items in the current task section.
24
+ - Write or update tests for the implementation.
25
+
26
+ STEP 2 - VALIDATE:
27
+ - Run the test, lint, typecheck, build, or validation commands specified in the
28
+ plan.
29
+ - If the plan does not list exact commands, infer the narrowest relevant
30
+ validation commands from the repository.
31
+ - Fix any failures and repeat validation until it passes.
32
+
33
+ STEP 3 - COMPLETE:
34
+ - Edit PLAN_FILE_PATH and change `[ ]` to `[x]` for every checkbox you completed
35
+ in the current task section.
36
+ - If all task sections are complete and higher-level success criteria checkboxes
37
+ are now satisfied, mark those `[x]` too.
38
+ - Commit all changed files with:
39
+ `bash PLAN_EXEC_ROOT/scripts/stage-and-commit.sh "feat: <brief task description>" file1 file2 ...`
40
+ - List every changed file explicitly, including source files, tests, and the plan
41
+ file.
42
+
43
+ STEP 4 - LOG PROGRESS:
44
+ - Append a header:
45
+ `bash PLAN_EXEC_ROOT/scripts/append-progress.sh PROGRESS_FILE_PATH "task N: <title>"`
46
+ - Then pipe details:
47
+ `printf '%s\n' "- modified: <files>" "- implemented: <what was done>" "- tests: <what tests were added or why skipped>" "- validation: <what commands passed>" | bash PLAN_EXEC_ROOT/scripts/append-progress.sh PROGRESS_FILE_PATH`
48
+ - Use only `append-progress.sh` for writing to the progress file. Do not write to
49
+ the progress file directly.
50
+
51
+ STOP after committing and logging progress.
52
+
53
+ If any phase fails after reasonable fix attempts, log the failure to
54
+ PROGRESS_FILE_PATH and report what failed.
55
+
56
+ One task section per run. After commit and progress log, stop.
57
+ ```
@@ -0,0 +1,23 @@
1
+ #!/bin/bash
2
+ # append to the progress file with timestamp
3
+ # usage: append-progress.sh <progress-file> [message]
4
+ # if message is provided, appends single timestamped line
5
+ # if no message, reads stdin and appends all lines (for multi-line content)
6
+
7
+ set -e
8
+
9
+ if [ $# -lt 1 ]; then
10
+ echo "error: usage: append-progress.sh <file> [message]" >&2
11
+ exit 1
12
+ fi
13
+
14
+ file="$1"
15
+ shift
16
+
17
+ if [ $# -gt 0 ]; then
18
+ # single line with timestamp
19
+ echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" >> "$file"
20
+ else
21
+ # multi-line from stdin
22
+ cat >> "$file"
23
+ fi
@@ -0,0 +1,46 @@
1
+ #!/bin/bash
2
+ # create a feature branch from a plan file name if currently on the default branch
3
+ # usage: create-branch.sh <plan-file-path>
4
+ # exits 0 if a branch was created or an existing feature branch is already active
5
+ # outputs the branch name to stdout
6
+ #
7
+ # strips leading YYYYMMDD- or YYYY-MM-DD- date prefixes from branch names
8
+
9
+ set -e
10
+
11
+ if [ -z "${1:-}" ]; then
12
+ echo "error: plan file path required" >&2
13
+ exit 1
14
+ fi
15
+
16
+ if ! git rev-parse --git-dir >/dev/null 2>&1; then
17
+ echo "error: not a git repository" >&2
18
+ exit 1
19
+ fi
20
+
21
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
22
+
23
+ derive_branch_name() {
24
+ local name
25
+ name=$(basename "$1" .md)
26
+ name=$(echo "$name" | sed 's/^[0-9]\{4\}-\{0,1\}[0-9]\{2\}-\{0,1\}[0-9]\{2\}-//')
27
+ echo "$name"
28
+ }
29
+
30
+ current_branch=$(git branch --show-current)
31
+ default_branch=$(bash "$SCRIPT_DIR/detect-branch.sh")
32
+
33
+ if [ -n "$current_branch" ] && [ "$current_branch" != "$default_branch" ]; then
34
+ echo "$current_branch"
35
+ exit 0
36
+ fi
37
+
38
+ branch_name=$(derive_branch_name "$1")
39
+
40
+ if git show-ref --verify --quiet "refs/heads/$branch_name" 2>/dev/null; then
41
+ git checkout "$branch_name"
42
+ else
43
+ git checkout -b "$branch_name"
44
+ fi
45
+
46
+ echo "$branch_name"
@@ -0,0 +1,32 @@
1
+ #!/bin/bash
2
+ # detect the default branch name of the current Git repository
3
+ # outputs the branch name to stdout
4
+ # avoids network calls when possible
5
+
6
+ set -e
7
+
8
+ if ! git rev-parse --git-dir >/dev/null 2>&1; then
9
+ echo "error: not a git repository" >&2
10
+ exit 1
11
+ fi
12
+
13
+ branch=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed 's@^refs/remotes/origin/@@')
14
+
15
+ if [ -z "$branch" ]; then
16
+ for candidate in main master trunk develop; do
17
+ if git show-ref --verify --quiet "refs/heads/$candidate" 2>/dev/null; then
18
+ branch="$candidate"
19
+ break
20
+ fi
21
+ done
22
+ fi
23
+
24
+ if [ -z "$branch" ]; then
25
+ branch=$(git remote show origin 2>/dev/null | grep 'HEAD branch' | sed 's/.*: //')
26
+ fi
27
+
28
+ if [ -z "$branch" ]; then
29
+ branch="main"
30
+ fi
31
+
32
+ echo "$branch"
@@ -0,0 +1,24 @@
1
+ #!/bin/bash
2
+ # initialize the progress file with a header
3
+ # usage: init-progress.sh <progress-file> <plan-path> <branch-name>
4
+
5
+ set -e
6
+
7
+ file="$1"
8
+ plan="$2"
9
+ branch="$3"
10
+
11
+ if [ -z "$file" ] || [ -z "$plan" ] || [ -z "$branch" ]; then
12
+ echo "error: usage: init-progress.sh <progress-file> <plan-path> <branch-name>" >&2
13
+ exit 1
14
+ fi
15
+
16
+ cat > "$file" <<EOF
17
+ # progress
18
+ Plan: $plan
19
+ Branch: $branch
20
+ Started: $(date '+%Y-%m-%d %H:%M:%S')
21
+ ---
22
+ EOF
23
+
24
+ echo "$file"
@@ -0,0 +1,21 @@
1
+ #!/bin/bash
2
+ # stage explicit files and commit with a message
3
+ # usage: stage-and-commit.sh <message> <file1> [file2 ...]
4
+
5
+ set -e
6
+
7
+ if [ $# -lt 2 ]; then
8
+ echo "error: usage: stage-and-commit.sh <message> <file1> [file2 ...]" >&2
9
+ exit 1
10
+ fi
11
+
12
+ if ! git rev-parse --git-dir >/dev/null 2>&1; then
13
+ echo "error: not a git repository" >&2
14
+ exit 1
15
+ fi
16
+
17
+ msg="$1"
18
+ shift
19
+
20
+ git add -- "$@"
21
+ git commit -m "$msg"