Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
728 changes: 695 additions & 33 deletions plugins/flow-next/scripts/flowctl.py → .opencode/bin/flowctl.py

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions .opencode/skill/flow-next-export-context/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Build RepoPrompt context and export to a markdown file for use with external LLM
**CRITICAL: flowctl is BUNDLED — NOT installed globally.** `which flowctl` will fail (expected). Always use:
```bash
ROOT="$(git rev-parse --show-toplevel)"
PLUGIN_ROOT="$ROOT/plugins/flow-next"
FLOWCTL="$PLUGIN_ROOT/scripts/flowctl"
OPENCODE_DIR="$ROOT/.opencode"
FLOWCTL="$OPENCODE_DIR/bin/flowctl"
$FLOWCTL <command>
```

Expand All @@ -34,8 +34,8 @@ Examples:

```bash
ROOT="$(git rev-parse --show-toplevel)"
PLUGIN_ROOT="$ROOT/plugins/flow-next"
FLOWCTL="$PLUGIN_ROOT/scripts/flowctl"
OPENCODE_DIR="$ROOT/.opencode"
FLOWCTL="$OPENCODE_DIR/bin/flowctl"
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
```

Expand Down
63 changes: 24 additions & 39 deletions .opencode/skill/flow-next-impl-review/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Conduct a John Carmack-level review of implementation changes on the current bra
**CRITICAL: flowctl is BUNDLED — NOT installed globally.** `which flowctl` will fail (expected). Always use:
```bash
ROOT="$(git rev-parse --show-toplevel)"
PLUGIN_ROOT="$ROOT/plugins/flow-next"
FLOWCTL="$PLUGIN_ROOT/scripts/flowctl"
OPENCODE_DIR="$ROOT/.opencode"
FLOWCTL="$OPENCODE_DIR/bin/flowctl"
```

## Backend Selection
Expand All @@ -42,17 +42,17 @@ If found, use that backend and skip all other detection.

```bash
# Check available backends
HAVE_RP=0
HAVE_RP=0;
if command -v rp-cli >/dev/null 2>&1; then
HAVE_RP=1
HAVE_RP=1;
elif [[ -x /opt/homebrew/bin/rp-cli || -x /usr/local/bin/rp-cli ]]; then
HAVE_RP=1
fi
HAVE_RP=1;
fi;

# Get configured backend
BACKEND="${FLOW_REVIEW_BACKEND:-}"
BACKEND="${FLOW_REVIEW_BACKEND:-}";
if [[ -z "$BACKEND" ]]; then
BACKEND="$($FLOWCTL config get review.backend 2>/dev/null | jq -r '.value // empty')"
BACKEND="$($FLOWCTL config get review.backend --json 2>/dev/null | jq -r '.value // empty')";
fi
```

Expand Down Expand Up @@ -97,11 +97,10 @@ fi
5. **Re-reviews MUST stay in SAME chat** - omit `--new-chat` after first review

**For opencode backend:**
1. Use the task tool with `subagent_type: opencode-reviewer`
2. Provide full diff context (git log + changed files + diff) and focus areas
3. Parse verdict from `<verdict>...` tag
4. If `REVIEW_RECEIPT_PATH` set: write receipt JSON with `mode: "opencode"`
5. **Re-reviews must reuse the same task session**: capture `session_id` from `<task_metadata>` and pass it back via `session_id` on subsequent task tool calls
1. Use the **task tool** with subagent_type `opencode-reviewer`
2. Reviewer gathers context via tools (git diff/log, read files)
3. Parse verdict from reviewer output
4. Extract `session_id` from `<task_metadata>` and reuse it for re-reviews

**For all backends:**
- If `REVIEW_RECEIPT_PATH` set: write receipt after review (any verdict)
Expand All @@ -125,8 +124,8 @@ Reviews all changes on **current branch** vs main/master.

```bash
ROOT="$(git rev-parse --show-toplevel)"
PLUGIN_ROOT="$ROOT/plugins/flow-next"
FLOWCTL="$PLUGIN_ROOT/scripts/flowctl"
OPENCODE_DIR="$ROOT/.opencode"
FLOWCTL="$OPENCODE_DIR/bin/flowctl"
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"
```

Expand All @@ -136,32 +135,18 @@ Run backend detection from SKILL.md above. Then branch:

### OpenCode Backend

```bash
TASK_ID="${1:-}"
BASE_BRANCH="main"
RECEIPT_PATH="${REVIEW_RECEIPT_PATH:-/tmp/impl-review-receipt.json}"

# Identify changes
git branch --show-current
git log main..HEAD --oneline 2>/dev/null || git log master..HEAD --oneline
git diff main..HEAD --name-only 2>/dev/null || git diff master..HEAD --name-only
DIFF_OUTPUT="$(git diff main..HEAD 2>/dev/null || git diff master..HEAD)"
```

Build a review prompt with:
- Branch + base branch
- Commit list
- Changed files
- Full diff (or a focused diff if huge)
- Focus areas from arguments
- Review criteria (correctness, security, performance, tests, risks)
- Required verdict tag
Use the task tool with subagent_type `opencode-reviewer`.

Run reviewer subagent using the task tool:
- subagent_type: `opencode-reviewer`
- prompt: `<review prompt>`
Prompt must require:
- `git log main..HEAD --oneline`
- `git diff main..HEAD --stat`
- `git diff main..HEAD`
- Read any changed files needed for correctness
- No questions, no code changes, no TodoWrite
- End with `<verdict>SHIP</verdict>` or `<verdict>NEEDS_WORK</verdict>` or `<verdict>MAJOR_RETHINK</verdict>`

Parse verdict from reviewer response (`<verdict>SHIP|NEEDS_WORK|MAJOR_RETHINK</verdict>`).
Parse verdict from the subagent response.
Extract `session_id` from `<task_metadata>` and reuse for re-review.

On NEEDS_WORK: fix code, commit, re-run review (same backend).

Expand Down
29 changes: 19 additions & 10 deletions .opencode/skill/flow-next-impl-review/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ The reviewer model only sees provided context. RepoPrompt's Builder discovers co
```bash
set -e
ROOT="$(git rev-parse --show-toplevel)"
PLUGIN_ROOT="$ROOT/plugins/flow-next"
FLOWCTL="$PLUGIN_ROOT/scripts/flowctl"
OPENCODE_DIR="$ROOT/.opencode"
FLOWCTL="$OPENCODE_DIR/bin/flowctl"
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null || pwd)"

# Check available backends
Expand All @@ -25,7 +25,7 @@ HAVE_RP=$(which rp-cli >/dev/null 2>&1 && echo 1 || echo 0)
# Get configured backend (priority: env > config)
BACKEND="${FLOW_REVIEW_BACKEND:-}"
if [[ -z "$BACKEND" ]]; then
BACKEND="$($FLOWCTL config get review.backend 2>/dev/null | jq -r '.value // empty' 2>/dev/null || echo "")"
BACKEND="$($FLOWCTL config get review.backend --json 2>/dev/null | jq -r '.value // empty' 2>/dev/null || echo "")"
fi

# Fallback to available (opencode preferred)
Expand Down Expand Up @@ -71,15 +71,24 @@ Include:
- Review criteria (correctness, security, performance, tests, risks)
- Required verdict tag

### Step 3: Execute review
### Step 3: Execute review (subagent)

Use the task tool:
- subagent_type: `opencode-reviewer`
- prompt: `<review prompt>`
Use the **task** tool with subagent_type `opencode-reviewer`. The reviewer must gather context itself via tools, including Flow task/epic specs.

Capture `session_id` from the `<task_metadata>` block in the tool output and reuse it for any re-review by passing `session_id` back into the task tool. This keeps the same subagent chat.
**Task tool call** (example):
```json
{
"description": "Impl review",
"prompt": "You are the OpenCode reviewer. Review current branch vs main. Rules: no questions, no code changes, no TodoWrite. REQUIRED: set FLOWCTL to `.opencode/bin/flowctl`, then run `$FLOWCTL show <TASK_ID> --json` and `$FLOWCTL cat <TASK_ID>`. Then get epic id from task JSON and run `$FLOWCTL show <EPIC_ID> --json` and `$FLOWCTL cat <EPIC_ID>`. REQUIRED: run `git log main..HEAD --oneline` (fallback master), `git diff main..HEAD --stat`, `git diff main..HEAD`. Read any changed files needed for correctness. Then output issues grouped by severity and end with exactly one verdict tag: <verdict>SHIP</verdict> or <verdict>NEEDS_WORK</verdict> or <verdict>MAJOR_RETHINK</verdict>.",
"subagent_type": "opencode-reviewer"
}
```

**After the task completes**:
- Parse `VERDICT` from the subagent output.
- Extract `session_id` from the `<task_metadata>` block (used for re-reviews).

**Output must include** `<verdict>SHIP</verdict>` or `<verdict>NEEDS_WORK</verdict>` or `<verdict>MAJOR_RETHINK</verdict>`.
If `VERDICT` is empty, output `<promise>RETRY</promise>` and stop.

### Step 4: Receipt

Expand All @@ -98,7 +107,7 @@ EOF
If `VERDICT=NEEDS_WORK`:
1. Parse issues from output
2. Fix code, commit, run tests
3. Re-run Step 3 (same backend, same `session_id`)
3. Re-run Step 3 **with the same task session_id** (pass `session_id` to the task tool)
4. Repeat until SHIP

---
Expand Down
81 changes: 45 additions & 36 deletions .opencode/skill/flow-next-interview/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Conduct an extremely thorough interview about a task/spec and write refined deta
**CRITICAL: flowctl is BUNDLED — NOT installed globally.** `which flowctl` will fail (expected). Always use:
```bash
ROOT="$(git rev-parse --show-toplevel)"
PLUGIN_ROOT="$ROOT/plugins/flow-next"
FLOWCTL="$PLUGIN_ROOT/scripts/flowctl"
OPENCODE_DIR="$ROOT/.opencode"
FLOWCTL="$OPENCODE_DIR/bin/flowctl"
$FLOWCTL <command>
```

Expand Down Expand Up @@ -41,8 +41,8 @@ If empty, ask: "What should I interview you about? Give me a Flow ID (e.g., fn-1

```bash
ROOT="$(git rev-parse --show-toplevel)"
PLUGIN_ROOT="$ROOT/plugins/flow-next"
FLOWCTL="$PLUGIN_ROOT/scripts/flowctl"
OPENCODE_DIR="$ROOT/.opencode"
FLOWCTL="$OPENCODE_DIR/bin/flowctl"
```

## Detect Input Type
Expand Down Expand Up @@ -98,42 +98,51 @@ After interview complete, write everything back.

### For Flow Epic ID

1. Create a temp file with the refined epic spec including:
- Clear problem statement
- Technical approach with specifics
- Key decisions made during interview
- Edge cases to handle
- Quick commands section (required)
- Acceptance criteria

2. Update epic spec:
```bash
$FLOWCTL epic set-plan <id> --file <temp-md> --json
```

3. Create/update tasks if interview revealed breakdown:
```bash
$FLOWCTL task create --epic <id> --title "..." --json
$FLOWCTL task set-description <task-id> --file <temp-md> --json
$FLOWCTL task set-acceptance <task-id> --file <temp-md> --json
```
Update epic spec using stdin heredoc (preferred):
```bash
$FLOWCTL epic set-plan <id> --file - --json <<'EOF'
# Epic Title

### For Flow Task ID
## Problem
Clear problem statement

## Approach
Technical approach with specifics, key decisions from interview

## Edge Cases
- Edge case 1
- Edge case 2

1. Write description to temp file with:
- Clear task description
- Technical details from interview
- Edge cases
## Quick commands
```bash
# smoke test command
```

2. Write acceptance to temp file with:
- Checkboxes for acceptance criteria
- Specific, testable conditions
## Acceptance
- [ ] Criterion 1
- [ ] Criterion 2
EOF
```

3. Update task:
```bash
$FLOWCTL task set-description <id> --file <desc-temp.md> --json
$FLOWCTL task set-acceptance <id> --file <acc-temp.md> --json
```
Create/update tasks if interview revealed breakdown:
```bash
$FLOWCTL task create --epic <id> --title "..." --json
# Use set-spec for combined description + acceptance (fewer writes)
$FLOWCTL task set-spec <task-id> --description /tmp/desc.md --acceptance /tmp/acc.md --json
```

### For Flow Task ID

Update task using combined set-spec (preferred) or separate calls:
```bash
# Preferred: combined set-spec (2 writes instead of 4)
$FLOWCTL task set-spec <id> --description /tmp/desc.md --acceptance /tmp/acc.md --json

# Or use stdin for description only:
$FLOWCTL task set-description <id> --file - --json <<'EOF'
Clear task description with technical details and edge cases from interview
EOF
```

### For File Path

Expand Down
Loading
Loading