@qlucent/fishi-core 0.15.1 → 0.16.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/dist/index.js CHANGED
@@ -9009,704 +9009,382 @@ if (cmd === 'check') {
9009
9009
  `;
9010
9010
  }
9011
9011
 
9012
- // src/templates/commands/init-command.ts
9013
- function getInitCommand() {
9014
- return `# /fishi-init \u2014 Launch the FISHI Orchestration Pipeline
9012
+ // src/templates/hooks/phase-guard.ts
9013
+ function getPhaseGuardHook() {
9014
+ return `#!/usr/bin/env node
9015
+ // phase-guard.mjs \u2014 FISHI Phase Guard Hook
9016
+ // Runs before Write/Edit to enforce phase-appropriate actions.
9017
+ // Zero dependencies: uses only Node.js built-ins.
9015
9018
 
9016
- ## Description
9017
- The primary entry point for starting a FISHI-managed project. When a user types
9018
- \`/fishi-init Build me a SaaS invoicing platform\`, this command kicks off the full
9019
- multi-phase orchestration pipeline \u2014 from discovery through deployment.
9019
+ import { readFileSync, existsSync } from 'fs';
9020
+ import { join } from 'path';
9020
9021
 
9021
- ## Usage
9022
- \`\`\`
9023
- /fishi-init <project description> # Start a new project with a description
9024
- /fishi-init # Start interactively (asks what to build)
9025
- /fishi-init --resume # Alias for /fishi-resume (pick up where you left off)
9026
- \`\`\`
9022
+ const ROOT = process.env.FISHI_PROJECT_ROOT || process.cwd();
9023
+ const stateFile = join(ROOT, '.fishi', 'state', 'project.yaml');
9027
9024
 
9028
- ## Instructions
9025
+ // Read tool input from stdin
9026
+ let input = '';
9027
+ try {
9028
+ input = readFileSync('/dev/stdin', 'utf-8').trim();
9029
+ } catch {
9030
+ // No stdin available \u2014 allow action
9031
+ process.exit(0);
9032
+ }
9029
9033
 
9030
- You are the **Master Orchestrator**. When the user runs \`/fishi-init\`, you will drive
9031
- the project through **six sequential phases**, each separated by an approval gate.
9032
- Follow these steps exactly, in order. Do NOT skip phases. Do NOT write code yourself.
9034
+ // Parse tool name and arguments
9035
+ let toolName = '';
9036
+ let filePath = '';
9037
+ try {
9038
+ const parsed = JSON.parse(input);
9039
+ toolName = parsed.tool_name || parsed.tool || '';
9040
+ filePath = parsed.file_path || parsed.path || '';
9041
+ } catch {
9042
+ // If not JSON, try to extract from env
9043
+ toolName = process.env.CLAUDE_TOOL_NAME || '';
9044
+ filePath = process.env.CLAUDE_FILE_PATH || '';
9045
+ }
9033
9046
 
9034
- ---
9047
+ // Only guard Write and Edit operations
9048
+ if (!['Write', 'Edit', 'MultiEdit'].includes(toolName)) {
9049
+ process.exit(0);
9050
+ }
9035
9051
 
9036
- ### Phase 0: Project Classification
9037
-
9038
- **Goal:** Determine whether this is greenfield, brownfield, or hybrid before any
9039
- other work begins.
9040
-
9041
- 1. **Check for existing FISHI state.**
9042
- - Read \`.fishi/fishi.yaml\` \u2014 if it exists, this project was previously initialized.
9043
- Warn the user and ask if they want to reinitialize or use \`/fishi-resume\` instead.
9044
- - Read \`.fishi/state/project-classification.yaml\` \u2014 if classification already
9045
- exists, confirm it with the user and skip to Phase 1.
9046
-
9047
- 2. **Classify the project.**
9048
- - Inspect the working directory for existing source code (\`package.json\`,
9049
- \`Cargo.toml\`, \`go.mod\`, \`pyproject.toml\`, \`pom.xml\`, \`.sln\`, etc.).
9050
- - If substantive source code exists \u2192 **brownfield**.
9051
- - If only scaffold or boilerplate exists \u2192 **greenfield**.
9052
- - If user describes adding a feature/module to an existing system \u2192 **hybrid**.
9053
-
9054
- 3. **For brownfield/hybrid projects:**
9055
- - Verify that brownfield analysis has been run (check for
9056
- \`.fishi/analysis/brownfield-report.md\`).
9057
- - If missing, instruct the user to run \`fishi init\` CLI first, which performs
9058
- the codebase analysis. Do NOT proceed without it.
9059
- - Load the brownfield report so you have context on the existing codebase for
9060
- all subsequent phases.
9061
-
9062
- 4. **Persist classification.**
9063
- - Write to \`.fishi/state/project-classification.yaml\`:
9064
- \`\`\`yaml
9065
- type: greenfield | brownfield | hybrid
9066
- classified_at: <ISO-8601 timestamp>
9067
- description: "<user's project description>"
9068
- brownfield_report: <path if applicable>
9069
- \`\`\`
9070
- - Initialize \`.fishi/state/phase.yaml\`:
9071
- \`\`\`yaml
9072
- current_phase: 1
9073
- current_step: discovery
9074
- started_at: <ISO-8601 timestamp>
9075
- project_description: "<user's project description>"
9076
- \`\`\`
9052
+ // Allow writes to FISHI infrastructure files
9053
+ const fishiPaths = ['.fishi/', '.claude/', 'SOUL.md', 'AGENTS.md', 'CLAUDE.md', '.mcp.json', '.gitignore'];
9054
+ if (fishiPaths.some(p => filePath.includes(p))) {
9055
+ process.exit(0);
9056
+ }
9077
9057
 
9078
- 5. **Announce classification to the user.** Confirm the project type and explain
9079
- what comes next. Then proceed immediately to Phase 1.
9058
+ // Read current phase
9059
+ if (!existsSync(stateFile)) {
9060
+ process.exit(0); // No state file \u2014 allow
9061
+ }
9080
9062
 
9081
- ---
9063
+ let phase = 'init';
9064
+ try {
9065
+ const content = readFileSync(stateFile, 'utf-8');
9066
+ const match = content.match(/^phase:\\s*(.+)$/m);
9067
+ if (match) phase = match[1].trim();
9068
+ } catch {
9069
+ process.exit(0);
9070
+ }
9082
9071
 
9083
- ### Phase 1: Discovery & Brainstorming
9072
+ // Phase rules
9073
+ const planningPhases = ['init', 'discovery', 'prd', 'architecture', 'sprint_planning'];
9074
+ const deployPhases = ['deployment', 'deployed'];
9084
9075
 
9085
- **Goal:** Understand what the user wants to build, explore approaches, and produce
9086
- an approved design document.
9076
+ if (planningPhases.includes(phase)) {
9077
+ // Block application code writes during planning phases
9078
+ // Allow: docs, plans, PRDs, markdown, yaml
9079
+ const allowedExtensions = ['.md', '.yaml', '.yml', '.json', '.txt'];
9080
+ const hasAllowedExt = allowedExtensions.some(ext => filePath.endsWith(ext));
9087
9081
 
9088
- 1. **Invoke the brainstorming skill.** Follow the brainstorming process exactly:
9082
+ if (!hasAllowedExt) {
9083
+ console.error(\`[FISHI PHASE GUARD] Blocked: Cannot write application code during "\${phase}" phase.\`);
9084
+ console.error(\` File: \${filePath}\`);
9085
+ console.error(\` Current phase only allows: documentation, plans, and configuration files.\`);
9086
+ console.error(\` To advance: node .fishi/scripts/gate-manager.mjs approve --phase \${phase}\`);
9087
+ process.exit(2); // Exit code 2 = block the action
9088
+ }
9089
+ }
9089
9090
 
9090
- a. **Understand the request.** Read the user's project description carefully.
9091
- Identify ambiguities, unstated assumptions, and missing requirements. For
9092
- brownfield/hybrid projects, cross-reference against the existing codebase
9093
- analysis.
9091
+ if (phase === 'development') {
9092
+ // During development, warn if writing outside a worktree
9093
+ if (!filePath.includes('.trees/') && !filePath.includes('.trees\\\\')) {
9094
+ // Allow package.json, config files at root
9095
+ const rootConfigs = ['package.json', 'tsconfig', '.eslintrc', '.prettierrc', 'next.config', 'vite.config', 'astro.config'];
9096
+ const isRootConfig = rootConfigs.some(c => filePath.includes(c));
9094
9097
 
9095
- b. **Ask clarifying questions ONE AT A TIME.** Do NOT dump a list of questions.
9096
- Ask the single most important question first, wait for the answer, then ask
9097
- the next. Each question should build on previous answers. Aim for 3-7
9098
- questions depending on complexity.
9098
+ if (!isRootConfig) {
9099
+ console.error(\`[FISHI PHASE GUARD] Warning: Writing code outside a worktree.\`);
9100
+ console.error(\` File: \${filePath}\`);
9101
+ console.error(\` Recommended: Create a worktree first:\`);
9102
+ console.error(\` node .fishi/scripts/worktree-manager.mjs create --agent {agent} --task {task} --coordinator dev-lead\`);
9103
+ // Warning only \u2014 don't block (exit 0)
9104
+ }
9105
+ }
9106
+ }
9099
9107
 
9100
- c. **Explore 2-3 alternative approaches.** After gathering enough context,
9101
- present alternatives. For each, clearly state:
9102
- - **Approach:** Brief description
9103
- - **Pros:** What makes it good
9104
- - **Cons:** Risks or downsides
9105
- - **Effort:** Rough estimate (small / medium / large)
9106
- - Ask the user which direction resonates.
9108
+ // Allow everything else
9109
+ process.exit(0);
9110
+ `;
9111
+ }
9107
9112
 
9108
- d. **Present the design in logical sections.** Break it into chunks (data
9109
- model, API surface, user flows, edge cases, testing strategy). Present
9110
- each section and get feedback before moving to the next.
9113
+ // src/templates/commands/init-command.ts
9114
+ function getInitCommand() {
9115
+ return `---
9116
+ name: fishi-init
9117
+ description: Launch the FISHI orchestration pipeline \u2014 start or resume project development
9118
+ allowed-tools: Read, Glob, Grep, Bash, Agent, TodoWrite, WebFetch, WebSearch
9119
+ ---
9111
9120
 
9112
- e. **Get explicit approval.** Summarize the final agreed-upon design and ask:
9113
- "Does this design look good? Should I proceed?"
9114
- Do NOT proceed until you get a clear "yes."
9121
+ # /fishi-init \u2014 FISHI Orchestration Pipeline
9115
9122
 
9116
- 2. **Save the approved design.**
9117
- - Write to \`.fishi/plans/discovery/<feature-name>-design.md\` with:
9118
- - Feature description
9119
- - Requirements (functional and non-functional)
9120
- - Agreed design decisions with rationale
9121
- - Out of scope items
9122
- - Open questions (if any remain)
9123
+ <EXTREMELY-IMPORTANT>
9124
+ You are the Master Orchestrator. Follow these steps IN ORDER. Do NOT skip any step.
9125
+ Do NOT write application code. You DELEGATE everything to specialist agents.
9126
+ </EXTREMELY-IMPORTANT>
9123
9127
 
9124
- 3. **Checkpoint.** Save state to \`.fishi/state/phase.yaml\`:
9125
- \`\`\`yaml
9126
- current_phase: 1
9127
- current_step: gate
9128
- discovery_artifact: .fishi/plans/discovery/<feature-name>-design.md
9129
- \`\`\`
9128
+ ## Step 1: Read Project State
9130
9129
 
9131
- 4. **GATE: Discovery Approval.**
9132
- Present a gate summary to the user:
9133
- \`\`\`
9134
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9135
- GATE 1: Discovery & Design Approval
9136
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9137
- Phase: Discovery & Brainstorming
9138
- Artifact: .fishi/plans/discovery/<name>-design.md
9139
-
9140
- Summary:
9141
- - <what was decided>
9142
- - <key design choices>
9143
- - <trade-offs accepted>
9144
-
9145
- Open items: <any remaining questions>
9146
-
9147
- \u2192 Approve to proceed to PRD creation.
9148
- \u2192 Reject to revise the design.
9149
- \u2192 Skip to bypass this gate (will be logged).
9150
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9151
- \`\`\`
9152
- Wait for the user to respond with \`/fishi-gate approve\`, "approve", "lgtm", or
9153
- similar. If rejected, incorporate feedback and repeat the relevant parts of
9154
- this phase. If skipped, log it and proceed.
9130
+ \`\`\`bash
9131
+ cat .fishi/state/project.yaml
9132
+ cat SOUL.md
9133
+ \`\`\`
9155
9134
 
9156
- Record gate outcome in \`.fishi/state/gates.yaml\`.
9135
+ If phase is NOT "init", resume from the current phase (skip to that phase's section below).
9157
9136
 
9158
- ---
9137
+ ## Step 2: Read Discovery Context
9159
9138
 
9160
- ### Phase 2: PRD Creation
9139
+ If this is a new project:
9140
+ - Read the project description from CLAUDE.md
9141
+ - Understand what the user wants to build
9161
9142
 
9162
- **Goal:** Translate the approved design into a structured Product Requirements
9163
- Document with testable acceptance criteria.
9143
+ ## Step 3: Discovery Phase
9164
9144
 
9165
- 1. **Invoke the prd-creation skill.** Using the approved design from Phase 1:
9145
+ Use TodoWrite to create this checklist:
9146
+ - [ ] Dispatch deep-research-agent to research the domain
9147
+ - [ ] Brainstorm approaches with user (present 2-3 options)
9148
+ - [ ] Analyze existing code (if brownfield)
9149
+ - [ ] Save discovery summary to .fishi/plans/discovery/summary.md
9150
+ - [ ] Update phase to discovery
9166
9151
 
9167
- a. **Read the discovery artifact** from \`.fishi/plans/discovery/\`.
9152
+ Dispatch the research agent:
9153
+ \`\`\`
9154
+ Use the Agent tool:
9155
+ subagent_type: "deep-research-agent"
9156
+ prompt: "Research the domain for this project: [project description].
9157
+ Produce a report covering: industry overview, competitors, user expectations, technical approaches.
9158
+ Save to .fishi/research/domain-analysis.md"
9159
+ \`\`\`
9168
9160
 
9169
- b. **Draft the full PRD** following the PRD template structure:
9170
- - Overview, Problem Statement, Goals & Success Metrics
9171
- - User Stories with acceptance criteria
9172
- - Functional Requirements (P0/P1/P2 priority)
9173
- - Non-Functional Requirements (performance, security, scalability)
9174
- - Technical Constraints
9175
- - Data Requirements
9176
- - API Contracts (high-level)
9177
- - UI/UX Requirements (if applicable)
9178
- - Testing Strategy
9179
- - Risks & Mitigations
9180
- - Timeline & Milestones
9181
- - Open Questions
9161
+ After research completes, brainstorm with the user. Present 2-3 approaches with trade-offs.
9182
9162
 
9183
- c. **Walk through each section with the user.** Present sections incrementally
9184
- and incorporate feedback. Do NOT dump the entire PRD at once.
9163
+ Update phase:
9164
+ \`\`\`bash
9165
+ node .fishi/scripts/phase-runner.mjs set --phase discovery
9166
+ \`\`\`
9185
9167
 
9186
- d. **Flag open questions.** Do not guess \u2014 list what needs user input and ask.
9168
+ <HARD-GATE>
9169
+ STOP HERE. Present discovery findings to the user.
9170
+ Ask: "Do you approve the discovery findings? Say 'approved' or provide feedback."
9171
+ Wait for user response before proceeding.
9172
+ </HARD-GATE>
9187
9173
 
9188
- 2. **Save the PRD.**
9189
- - Write to \`.fishi/plans/prd/YYYY-MM-DD-<topic>-prd.md\`
9190
- - Use today's date for the filename prefix.
9174
+ ## Step 4: PRD Phase
9191
9175
 
9192
- 3. **Checkpoint.** Update \`.fishi/state/phase.yaml\`:
9193
- \`\`\`yaml
9194
- current_phase: 2
9195
- current_step: gate
9196
- prd_artifact: .fishi/plans/prd/YYYY-MM-DD-<topic>-prd.md
9197
- \`\`\`
9176
+ Use TodoWrite:
9177
+ - [ ] Create PRD with all 14 sections
9178
+ - [ ] Save to .fishi/plans/prd/PRD.md
9179
+ - [ ] Create gate for PRD approval
9198
9180
 
9199
- 4. **GATE: PRD Approval.**
9200
- Present a gate summary:
9201
- \`\`\`
9202
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9203
- GATE 2: PRD Approval
9204
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9205
- Phase: PRD Creation
9206
- Artifact: .fishi/plans/prd/<name>-prd.md
9207
-
9208
- Summary:
9209
- - <total user stories>
9210
- - <P0 requirements count> launch blockers
9211
- - <P1 requirements count> important items
9212
- - <MVP scope summary>
9213
-
9214
- Risks: <top 2-3 risks>
9215
- Open items: <count>
9216
-
9217
- \u2192 Approve to proceed to Architecture.
9218
- \u2192 Reject to revise the PRD.
9219
- \u2192 Skip to bypass this gate.
9220
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9221
- \`\`\`
9222
- Wait for approval. Record gate outcome.
9181
+ Create the PRD covering: Overview, Problem, User Stories, Acceptance Criteria, NFRs, Constraints, Metrics, Risks, Timeline, Dependencies, Out of Scope, Questions, Appendix.
9223
9182
 
9224
- ---
9183
+ \`\`\`bash
9184
+ node .fishi/scripts/gate-manager.mjs create --phase prd --description "PRD approval"
9185
+ node .fishi/scripts/phase-runner.mjs set --phase prd
9186
+ \`\`\`
9225
9187
 
9226
- ### Phase 3: Architecture
9188
+ <HARD-GATE>
9189
+ STOP HERE. Present the PRD to the user.
9190
+ Ask: "Do you approve the PRD? Say 'approved' or provide feedback."
9191
+ </HARD-GATE>
9227
9192
 
9228
- **Goal:** Design the technical architecture that satisfies the PRD.
9193
+ ## Step 5: Architecture Phase
9229
9194
 
9230
- 1. **Delegate to planning-lead coordinator.** Send a delegation message:
9231
- \`\`\`
9232
- DELEGATION TO: planning-lead
9233
- PHASE: 3 \u2014 Architecture
9234
- OBJECTIVE: Design the system architecture for the approved PRD. Assign the
9235
- architect-agent to produce: system design, component diagram, tech stack
9236
- with rationale, data models, and API contracts.
9237
- CONSTRAINTS:
9238
- - Must satisfy all P0 requirements from the PRD
9239
- - Must respect technical constraints listed in the PRD
9240
- - For brownfield: must integrate with existing codebase patterns
9241
- INPUT ARTIFACTS:
9242
- - .fishi/plans/prd/<prd-file>.md
9243
- - .fishi/plans/discovery/<design-file>.md
9244
- - .fishi/analysis/brownfield-report.md (if brownfield)
9245
- OUTPUT ARTIFACTS:
9246
- - .fishi/plans/architecture/system-design.md
9247
- - .fishi/plans/architecture/data-model.md
9248
- - .fishi/plans/architecture/api-contracts.md
9249
- - .fishi/plans/architecture/tech-decisions.md
9250
- DEADLINE SIGNAL: All output artifacts complete and internally consistent.
9251
- ESCALATION POLICY: Escalate if tech stack trade-offs need project-level
9252
- judgment, or if PRD requirements conflict with technical feasibility.
9253
- \`\`\`
9195
+ Use TodoWrite:
9196
+ - [ ] Dispatch architect-agent for system design
9197
+ - [ ] Define tech stack, database schema, API design
9198
+ - [ ] Save architecture docs to .fishi/plans/architecture/
9199
+ - [ ] Create gate for architecture approval
9254
9200
 
9255
- 2. **Review architect output.** When planning-lead reports back:
9256
- - Verify all required artifacts exist and are non-empty.
9257
- - Check consistency between artifacts and the PRD.
9258
- - If the architect flagged trade-offs or escalations, make the call and record
9259
- the decision in \`.fishi/state/decisions.yaml\`.
9201
+ Dispatch the architect:
9202
+ \`\`\`
9203
+ Use the Agent tool:
9204
+ subagent_type: "architect-agent"
9205
+ prompt: "Design the system architecture for [project name] based on the PRD at .fishi/plans/prd/PRD.md.
9206
+ Define: tech stack, database schema, API endpoints, component hierarchy, deployment strategy.
9207
+ Save to .fishi/plans/architecture/ARCHITECTURE.md"
9208
+ \`\`\`
9260
9209
 
9261
- 3. **Checkpoint.** Update phase state.
9210
+ \`\`\`bash
9211
+ node .fishi/scripts/gate-manager.mjs create --phase architecture --description "Architecture approval"
9212
+ node .fishi/scripts/phase-runner.mjs set --phase architecture
9213
+ \`\`\`
9262
9214
 
9263
- 4. **GATE: Architecture Approval.**
9264
- Present a gate summary:
9265
- \`\`\`
9266
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9267
- GATE 3: Architecture Approval
9268
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9269
- Phase: Architecture Design
9270
- Artifacts:
9271
- - .fishi/plans/architecture/system-design.md
9272
- - .fishi/plans/architecture/data-model.md
9273
- - .fishi/plans/architecture/api-contracts.md
9274
- - .fishi/plans/architecture/tech-decisions.md
9275
-
9276
- Tech Stack: <summary of chosen technologies>
9277
- Key Decisions:
9278
- - <decision 1 with rationale>
9279
- - <decision 2 with rationale>
9280
-
9281
- \u2192 Approve to proceed to Sprint Planning.
9282
- \u2192 Reject to revise the architecture.
9283
- \u2192 Skip to bypass this gate.
9284
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9285
- \`\`\`
9286
- Wait for approval. Record gate outcome.
9215
+ <HARD-GATE>
9216
+ STOP HERE. Present architecture to user. Wait for approval.
9217
+ </HARD-GATE>
9287
9218
 
9288
- ---
9219
+ ## Step 6: Sprint Planning Phase
9289
9220
 
9290
- ### Phase 4: Sprint Planning
9221
+ Use TodoWrite:
9222
+ - [ ] Break architecture into epics and tasks
9223
+ - [ ] Update taskboard with all tasks
9224
+ - [ ] Assign agents to tasks
9225
+ - [ ] Create sprint plan
9291
9226
 
9292
- **Goal:** Break the approved architecture into implementable sprints with a
9293
- populated TaskBoard.
9227
+ Update the taskboard (\`.fishi/taskboard/board.md\`) with tasks under the Backlog column.
9294
9228
 
9295
- 1. **Delegate to planning-lead coordinator.** Send a delegation message:
9296
- \`\`\`
9297
- DELEGATION TO: planning-lead
9298
- PHASE: 4 \u2014 Sprint Planning
9299
- OBJECTIVE: Decompose the approved architecture into epics, stories, and tasks.
9300
- Assign the planning-agent to create a sprint plan. Populate the TaskBoard.
9301
- Create Sprint 1 with prioritized tasks.
9302
- CONSTRAINTS:
9303
- - Each epic maps to a PRD feature area
9304
- - Tasks must be small enough for a single agent to complete
9305
- - Dependencies between tasks must be explicit
9306
- - Sprint 1 should focus on foundational/infrastructure tasks
9307
- INPUT ARTIFACTS:
9308
- - .fishi/plans/architecture/ (all files)
9309
- - .fishi/plans/prd/<prd-file>.md
9310
- OUTPUT ARTIFACTS:
9311
- - .fishi/taskboard/board.md (main task board)
9312
- - .fishi/taskboard/epics/ (epic files)
9313
- - .fishi/taskboard/sprints/sprint-1.md
9314
- DEADLINE SIGNAL: TaskBoard populated, Sprint 1 defined with task assignments.
9315
- ESCALATION POLICY: Escalate if task decomposition reveals architectural gaps
9316
- or if estimated effort exceeds reasonable sprint capacity.
9317
- \`\`\`
9229
+ \`\`\`bash
9230
+ node .fishi/scripts/gate-manager.mjs create --phase sprint_planning --description "Sprint plan approval"
9231
+ node .fishi/scripts/phase-runner.mjs set --phase sprint_planning
9232
+ \`\`\`
9318
9233
 
9319
- 2. **Cross-validate with dev-lead.** After planning-lead delivers:
9320
- \`\`\`
9321
- DELEGATION TO: dev-lead
9322
- PHASE: 4 \u2014 Sprint Planning (Feasibility Review)
9323
- OBJECTIVE: Review the sprint plan for technical feasibility. Flag any tasks
9324
- that are under-scoped, have missing dependencies, or need clarification.
9325
- INPUT ARTIFACTS:
9326
- - .fishi/taskboard/board.md
9327
- - .fishi/taskboard/sprints/sprint-1.md
9328
- - .fishi/plans/architecture/ (all files)
9329
- OUTPUT ARTIFACTS:
9330
- - Feasibility assessment (inline report)
9331
- DEADLINE SIGNAL: Feasibility confirmed or issues flagged.
9332
- ESCALATION POLICY: Escalate all feasibility concerns.
9333
- \`\`\`
9234
+ <HARD-GATE>
9235
+ STOP HERE. Present sprint plan to user. Wait for approval.
9236
+ </HARD-GATE>
9334
9237
 
9335
- 3. **Resolve any feasibility issues** flagged by dev-lead. If needed, send
9336
- adjustments back to planning-lead.
9238
+ ## Step 7: Development Phase
9337
9239
 
9338
- 4. **Checkpoint.** Update phase state.
9240
+ \`\`\`bash
9241
+ node .fishi/scripts/phase-runner.mjs set --phase development
9242
+ \`\`\`
9339
9243
 
9340
- 5. **GATE: Sprint Plan Approval.**
9341
- Present a gate summary:
9342
- \`\`\`
9343
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9344
- GATE 4: Sprint Plan Approval
9345
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9346
- Phase: Sprint Planning
9347
- Artifacts:
9348
- - .fishi/taskboard/board.md
9349
- - .fishi/taskboard/epics/ (<count> epics)
9350
- - .fishi/taskboard/sprints/sprint-1.md
9351
-
9352
- Epics: <count> epics covering <summary>
9353
- Sprint 1: <task count> tasks
9354
- - <task-1 summary>
9355
- - <task-2 summary>
9356
- - ...
9357
- Estimated sprints total: <count>
9358
-
9359
- \u2192 Approve to begin development.
9360
- \u2192 Reject to revise the sprint plan.
9361
- \u2192 Skip to bypass this gate.
9362
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9363
- \`\`\`
9364
- Wait for approval. Record gate outcome.
9244
+ For EACH task in the sprint:
9365
9245
 
9366
- ---
9246
+ 1. **Create worktree**:
9247
+ \`\`\`bash
9248
+ node .fishi/scripts/worktree-manager.mjs create --agent {agent-name} --task {task-slug} --coordinator dev-lead
9249
+ \`\`\`
9367
9250
 
9368
- ### Phase 5: Development
9251
+ 2. **Lock files**:
9252
+ \`\`\`bash
9253
+ node .fishi/scripts/file-lock-hook.mjs lock --files "{files}" --agent {agent-name} --task {task-slug} --coordinator dev-lead
9254
+ \`\`\`
9369
9255
 
9370
- **Goal:** Implement the planned sprints. This is the core build phase.
9256
+ 3. **Update board**: Move task from Backlog to In Progress in \`.fishi/taskboard/board.md\`
9371
9257
 
9372
- 1. **Delegate sprint execution to dev-lead coordinator.** For each sprint:
9373
- \`\`\`
9374
- DELEGATION TO: dev-lead
9375
- PHASE: 5 \u2014 Development (Sprint N)
9376
- OBJECTIVE: Execute Sprint N. For each task:
9377
- 1. Assign to the appropriate worker agent (backend-agent, frontend-agent,
9378
- fullstack-agent, uiux-agent, etc.)
9379
- 2. Create an isolated git worktree for the worker
9380
- 3. Worker implements using TDD \u2014 write tests first, then implementation
9381
- 4. Worker signals completion
9382
- 5. Dev-lead reviews the work
9383
- 6. Submit to quality-lead for testing and security review
9384
- 7. Generate a PR summary for the completed task
9385
- CONSTRAINTS:
9386
- - Workers must NOT modify files outside their task scope
9387
- - All code must have tests before it can pass review
9388
- - Update TaskBoard status as tasks progress
9389
- INPUT ARTIFACTS:
9390
- - .fishi/taskboard/sprints/sprint-N.md
9391
- - .fishi/plans/architecture/ (all files)
9392
- OUTPUT ARTIFACTS:
9393
- - Completed code in worktree branches
9394
- - Updated .fishi/taskboard/board.md (task statuses)
9395
- - PR summaries for each completed task
9396
- DEADLINE SIGNAL: All sprint tasks completed or explicitly deferred.
9397
- ESCALATION POLICY: Escalate if a task is blocked for more than 2 attempts,
9398
- if scope issues are discovered, or if architectural changes are needed.
9399
- \`\`\`
9258
+ 4. **Dispatch worker**:
9259
+ \`\`\`
9260
+ Use the Agent tool:
9261
+ subagent_type: "{agent-name}"
9262
+ prompt: "You are {agent-name}. Your task: {task description}.
9263
+ Work ONLY in the worktree at: .trees/agent-{agent-name}-{task-slug}/
9264
+ Requirements: {from PRD/architecture}
9265
+ When done:
9266
+ - Commit your changes with: git add -A && git commit -m 'feat: {description}'
9267
+ - Report: FILES_CHANGED, STATUS (success/failed), SUMMARY"
9268
+ \`\`\`
9400
9269
 
9401
- 2. **Delegate quality assurance to quality-lead.** In parallel:
9402
- \`\`\`
9403
- DELEGATION TO: quality-lead
9404
- PHASE: 5 \u2014 Development (Sprint N Quality)
9405
- OBJECTIVE: For each completed task in Sprint N:
9406
- 1. Dispatch testing-agent to verify tests pass and coverage is adequate
9407
- 2. Dispatch security-agent to review for vulnerabilities
9408
- 3. Produce a quality report
9409
- INPUT ARTIFACTS:
9410
- - Completed task branches/worktrees
9411
- - .fishi/plans/architecture/ (for security context)
9412
- OUTPUT ARTIFACTS:
9413
- - .fishi/plans/quality/sprint-N-quality.yaml
9414
- DEADLINE SIGNAL: All tasks reviewed, quality report complete.
9415
- ESCALATION POLICY: Escalate critical security findings or test failures
9416
- that indicate architectural problems.
9417
- \`\`\`
9270
+ 5. **Review**: Dispatch quality-lead to review
9271
+ \`\`\`
9272
+ Use the Agent tool:
9273
+ subagent_type: "quality-lead"
9274
+ prompt: "Review the code in .trees/agent-{agent-name}-{task-slug}/.
9275
+ Check: correctness, tests, security, code quality.
9276
+ Report: APPROVED or ISSUES with details"
9277
+ \`\`\`
9418
9278
 
9419
- 3. **For each completed task \u2014 present a PR gate to the user:**
9420
- \`\`\`
9421
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9422
- GATE 5.X: Code Review \u2014 <Task ID>: <Task Title>
9423
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9424
- Task: <TASK-ID>
9425
- Worker: <agent-name>
9426
- Branch: <worktree branch>
9427
-
9428
- Changes:
9429
- - <file changes summary>
9430
- - <test coverage summary>
9431
-
9432
- Quality: <testing-agent result>
9433
- Security: <security-agent result>
9434
-
9435
- \u2192 Approve to merge to dev branch.
9436
- \u2192 Reject with feedback for rework.
9437
- \u2192 Skip to merge without full review.
9438
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9439
- \`\`\`
9279
+ 6. **Update board**: Move task to Done
9280
+ 7. **Release locks**: \`node .fishi/scripts/file-lock-hook.mjs release --agent {agent-name}\`
9281
+ 8. **Record learnings**: \`node .fishi/scripts/learnings-manager.mjs add-practice --agent {agent-name} --domain {domain} --practice "{learning}"\`
9440
9282
 
9441
- 4. **On task approval:**
9442
- - Merge the worktree branch to the dev branch.
9443
- - Clean up the worktree.
9444
- - Update the TaskBoard (mark task as Done).
9283
+ Repeat for all tasks in the sprint.
9445
9284
 
9446
- 5. **On task rejection:**
9447
- - Relay feedback to dev-lead with specific remediation instructions.
9448
- - Dev-lead re-assigns to the worker for rework.
9449
- - Worker fixes, re-submits for review. Repeat the gate.
9285
+ ## Step 8: Deployment Phase
9450
9286
 
9451
- 6. **After all sprint tasks are complete \u2014 Sprint Review gate:**
9452
- \`\`\`
9453
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9454
- GATE 5.S: Sprint N Review
9455
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9456
- Sprint: N
9457
- Completed: <count> / <total> tasks
9458
- Deferred: <count> tasks (moved to next sprint)
9459
-
9460
- Highlights:
9461
- - <key accomplishment 1>
9462
- - <key accomplishment 2>
9463
-
9464
- Quality Report: .fishi/plans/quality/sprint-N-quality.yaml
9465
- Test Coverage: <percentage>
9466
-
9467
- \u2192 Approve to proceed to next sprint (or deployment if final).
9468
- \u2192 Reject to address issues before moving on.
9469
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9470
- \`\`\`
9287
+ Dispatch ops-lead for deployment setup.
9471
9288
 
9472
- 7. **Repeat for each sprint** until all sprints are complete. Then proceed to
9473
- Phase 6.
9289
+ \`\`\`bash
9290
+ node .fishi/scripts/phase-runner.mjs set --phase deployment
9291
+ \`\`\`
9474
9292
 
9475
- 8. **Checkpoint after every sprint.** Update \`.fishi/state/phase.yaml\` with
9476
- current sprint number and status.
9293
+ <HARD-GATE>
9294
+ STOP. Present deployment plan. Ask user for final approval.
9295
+ </HARD-GATE>
9296
+ `;
9297
+ }
9477
9298
 
9478
- ---
9299
+ // src/templates/commands/status-command.ts
9300
+ function getStatusCommand() {
9301
+ return `# /fishi-status \u2014 Project Status Dashboard
9479
9302
 
9480
- ### Phase 6: Deployment & Delivery
9303
+ ## Description
9304
+ Show a comprehensive overview of project progress by reading FISHI state files directly.
9481
9305
 
9482
- **Goal:** Prepare the project for production \u2014 CI/CD, documentation, security
9483
- audit, and final delivery.
9306
+ ## Instructions
9484
9307
 
9485
- 1. **Delegate to ops-lead coordinator:**
9486
- \`\`\`
9487
- DELEGATION TO: ops-lead
9488
- PHASE: 6 \u2014 Deployment
9489
- OBJECTIVE: Prepare the project for production delivery:
9490
- 1. DevOps agent: Set up CI/CD pipeline, Docker configuration, infrastructure
9491
- as code, environment configuration
9492
- 2. Docs agent: Generate API documentation, update README, create deployment
9493
- guide, write CHANGELOG
9494
- 3. Security agent: Final security audit across the full codebase
9495
- CONSTRAINTS:
9496
- - CI/CD must pass all tests before deployment is possible
9497
- - Documentation must cover setup, configuration, and deployment
9498
- - Security audit must have zero critical/high findings
9499
- INPUT ARTIFACTS:
9500
- - Full codebase on dev branch
9501
- - .fishi/plans/architecture/ (all files)
9502
- - .fishi/plans/prd/<prd-file>.md
9503
- OUTPUT ARTIFACTS:
9504
- - .fishi/plans/delivery/deployment-checklist.md
9505
- - .fishi/plans/delivery/changelog.md
9506
- - .fishi/plans/delivery/security-audit.md
9507
- - CI/CD configuration files
9508
- - Documentation files (README, API docs)
9509
- DEADLINE SIGNAL: All delivery artifacts complete, CI passes, security audit clean.
9510
- ESCALATION POLICY: Escalate critical security findings or CI/CD blockers.
9511
- \`\`\`
9308
+ When the user runs \`/fishi-status\`, execute these steps IN ORDER:
9512
9309
 
9513
- 2. **Final PR Review.** Before presenting to the user, perform the master
9514
- orchestrator's final PR review checklist:
9515
- - **Scope check:** Does the PR implement what the PRD specified? Compare
9516
- against acceptance criteria.
9517
- - **Quality check:** Has quality-lead signed off? Are test results acceptable?
9518
- - **No orphaned work:** Is the TaskBoard fully resolved? No tasks stuck in
9519
- "In Progress" or "Blocked."
9520
- - **Documentation:** Are README, CHANGELOG, and inline docs present?
9521
- - **Clean history:** Is the git history clean and meaningful?
9522
-
9523
- 3. **GATE: Final Delivery Approval.**
9524
- This gate ALWAYS requires explicit user approval, even in economy mode.
9525
- \`\`\`
9526
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9527
- GATE 6: Production Delivery Approval
9528
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9529
- Phase: Deployment & Delivery
9530
-
9531
- Delivery Checklist:
9532
- [x] All PRD acceptance criteria met
9533
- [x] All tests passing
9534
- [x] Security audit clean
9535
- [x] CI/CD pipeline configured
9536
- [x] Documentation complete
9537
- [x] CHANGELOG updated
9538
- [x] TaskBoard fully resolved
9539
-
9540
- Artifacts:
9541
- - .fishi/plans/delivery/deployment-checklist.md
9542
- - .fishi/plans/delivery/changelog.md
9543
- - .fishi/plans/delivery/security-audit.md
9544
-
9545
- Summary:
9546
- - <total features implemented>
9547
- - <total sprints completed>
9548
- - <any deferred items for future work>
9549
-
9550
- \u2192 Approve to finalize and merge to main.
9551
- \u2192 Reject to address remaining issues.
9552
- \u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550
9553
- \`\`\`
9310
+ ### 1. Read Current Phase
9554
9311
 
9555
- 4. **On approval:** Merge dev to main. Tag the release. Congratulate the user.
9312
+ \`\`\`bash
9313
+ cat .fishi/state/project.yaml
9314
+ \`\`\`
9556
9315
 
9557
- ---
9316
+ Display the current phase, sprint number, and project type. Run:
9317
+ \`\`\`bash
9318
+ node .fishi/scripts/phase-runner.mjs current
9319
+ \`\`\`
9558
9320
 
9559
- ## Critical Rules
9560
-
9561
- 1. **The Master Orchestrator NEVER writes code.** You coordinate, delegate,
9562
- review, and present gates. All implementation is done by worker agents
9563
- through their coordinators.
9564
-
9565
- 2. **Every phase has an explicit gate.** Do NOT auto-advance. Wait for user
9566
- approval at each gate. The user can say:
9567
- - "approve" / "lgtm" / \`/fishi-gate approve\` \u2192 proceed
9568
- - "reject" / "changes needed" / \`/fishi-gate reject\` \u2192 revise and re-present
9569
- - "skip" / \`/fishi-gate skip\` \u2192 log as skipped with a warning and proceed
9570
-
9571
- 3. **Progress is checkpointed automatically.** After every phase transition and
9572
- every sprint completion, update \`.fishi/state/phase.yaml\` and create a
9573
- checkpoint in \`.fishi/state/checkpoints/\`. If the session ends mid-flow,
9574
- \`/fishi-resume\` picks up at the last checkpoint.
9575
-
9576
- 4. **Brownfield adaptation.** For brownfield and hybrid projects, every phase
9577
- must account for the existing codebase:
9578
- - Discovery: understand existing patterns before proposing new ones
9579
- - Architecture: integrate with existing architecture, don't replace it
9580
- - Sprint planning: include migration/refactoring tasks where needed
9581
- - Development: workers must follow existing code conventions
9582
- - Deployment: work with existing CI/CD if present
9583
-
9584
- 5. **Single source of truth.** All decisions, phase transitions, gate outcomes,
9585
- and delegation records are persisted in \`.fishi/state/\`. If it is not
9586
- written down, it did not happen.
9587
-
9588
- 6. **Cost awareness.** Respect the cost mode in \`.fishi/fishi.yaml\`:
9589
- - **standard:** Full phase sequence with thorough gates.
9590
- - **economy:** Collapse phases where safe, fewer coordinator round-trips,
9591
- auto-approve low-risk gates (except final delivery gate).
9592
-
9593
- 7. **Error recovery.** If a coordinator fails or produces bad output:
9594
- - Return the artifact with specific feedback. Allow one retry.
9595
- - On second failure, escalate to the user with context and options.
9596
- - Never silently swallow errors.
9321
+ ### 2. Read TaskBoard
9597
9322
 
9598
- ---
9323
+ \`\`\`bash
9324
+ cat .fishi/taskboard/board.md
9325
+ \`\`\`
9599
9326
 
9600
- ## State Files Reference
9327
+ Count tasks per column and display:
9328
+ - Backlog: X tasks
9329
+ - Ready: X tasks
9330
+ - In Progress: X tasks
9331
+ - In Review: X tasks
9332
+ - Done: X tasks
9601
9333
 
9602
- | File | Purpose |
9603
- |------|---------|
9604
- | \`.fishi/state/phase.yaml\` | Current phase and sub-step |
9605
- | \`.fishi/state/project-classification.yaml\` | Greenfield/brownfield/hybrid |
9606
- | \`.fishi/state/gates.yaml\` | Gate outcomes history |
9607
- | \`.fishi/state/decisions.yaml\` | Project-level decisions log |
9608
- | \`.fishi/state/active-agents.yaml\` | Currently active coordinators |
9609
- | \`.fishi/state/delegations.yaml\` | Active delegation tracking |
9610
- | \`.fishi/state/checkpoints/\` | Periodic state snapshots |
9611
- | \`.fishi/plans/discovery/\` | Design documents from Phase 1 |
9612
- | \`.fishi/plans/prd/\` | PRD documents from Phase 2 |
9613
- | \`.fishi/plans/architecture/\` | Architecture artifacts from Phase 3 |
9614
- | \`.fishi/taskboard/\` | Task board, epics, sprints from Phase 4+ |
9615
- | \`.fishi/plans/quality/\` | Quality reports from Phase 5 |
9616
- | \`.fishi/plans/delivery/\` | Deployment artifacts from Phase 6 |
9334
+ Highlight any tasks marked as BLOCKED.
9617
9335
 
9618
- ---
9336
+ ### 3. Read Gate Status
9619
9337
 
9620
- ## Quick Start Example
9338
+ \`\`\`bash
9339
+ cat .fishi/state/gates.yaml
9340
+ \`\`\`
9621
9341
 
9622
- When the user types: \`/fishi-init Build me a SaaS invoicing platform\`
9342
+ Show each gate with its status (pending, approved, rejected, skipped).
9343
+ Flag any pending gates that are blocking progress.
9623
9344
 
9624
- 1. You classify the project (likely greenfield).
9625
- 2. You ask: "What kind of invoicing? B2B, B2C, or both?" (one question at a time)
9626
- 3. You explore approaches (monolith vs microservices, payment providers, etc.)
9627
- 4. You get design approval \u2192 GATE 1
9628
- 5. You create a detailed PRD with acceptance criteria \u2192 GATE 2
9629
- 6. You delegate architecture to planning-lead \u2192 architect produces tech stack,
9630
- data models, API contracts \u2192 GATE 3
9631
- 7. You delegate sprint planning \u2192 epics, stories, tasks, Sprint 1 \u2192 GATE 4
9632
- 8. You delegate Sprint 1 to dev-lead \u2192 workers build in worktrees \u2192 per-task
9633
- PR gates \u2192 Sprint Review gate \u2192 repeat for each sprint
9634
- 9. You delegate deployment to ops-lead \u2192 CI/CD, docs, security audit \u2192 GATE 6
9635
- 10. User approves \u2192 merge to main \u2192 project complete.
9345
+ ### 4. Read Monitor Events
9636
9346
 
9637
- The entire flow is user-guided through gates. Nothing ships without approval.
9638
- `;
9639
- }
9347
+ \`\`\`bash
9348
+ cat .fishi/state/monitor.json
9349
+ \`\`\`
9640
9350
 
9641
- // src/templates/commands/status-command.ts
9642
- function getStatusCommand() {
9643
- return `# /fishi-status \u2014 Project Status
9351
+ Show the 5 most recent events with timestamps.
9644
9352
 
9645
- ## Description
9646
- Show a comprehensive overview of project progress, active agents, and TaskBoard summary.
9353
+ ### 5. Check File Locks
9647
9354
 
9648
- ## Usage
9355
+ \`\`\`bash
9356
+ cat .fishi/state/file-locks.yaml
9649
9357
  \`\`\`
9650
- /fishi-status
9651
- /fishi-status --sprint # Show current sprint details only
9652
- /fishi-status --agents # Show active agent status only
9653
- /fishi-status --verbose # Show full details for all sections
9358
+
9359
+ Show any active file locks and which agent holds them.
9360
+
9361
+ ### 6. Output Format
9362
+
9363
+ Present all information in this format:
9654
9364
  \`\`\`
9365
+ === FISHI Project Status ===
9655
9366
 
9656
- ## Instructions
9367
+ Phase: {current phase} | Sprint: {sprint number}
9368
+ Project: {project name} ({project type})
9657
9369
 
9658
- When the user runs \`/fishi-status\`, gather and display the following:
9370
+ --- TaskBoard ---
9371
+ Backlog: X tasks
9372
+ Ready: X tasks
9373
+ In Progress: X tasks
9374
+ In Review: X tasks
9375
+ Done: X tasks
9659
9376
 
9660
- ### 1. Sprint Summary
9661
- - Read \`.fishi/board.md\` for current sprint info
9662
- - Display:
9663
- - Sprint name and date range
9664
- - Days remaining
9665
- - Story points: planned / completed / remaining
9666
- - Burndown status (on track / behind / ahead)
9667
-
9668
- ### 2. TaskBoard Summary
9669
- - Count tasks by column:
9670
- - Backlog: X tasks
9671
- - Ready: X tasks
9672
- - In Progress: X tasks
9673
- - In Review: X tasks
9674
- - Done: X tasks (this sprint)
9675
- - Highlight any blocked tasks
9676
-
9677
- ### 3. Active Agents
9678
- - Check \`.fishi/agents/\` for active agent state files
9679
- - For each agent, show:
9680
- - Agent role (orchestrator, developer, reviewer, etc.)
9681
- - Current task assignment
9682
- - Status (working, waiting, idle)
9683
- - Last activity timestamp
9684
-
9685
- ### 4. Recent Activity
9686
- - Show last 5 completed tasks
9687
- - Show last 3 commits (if in a git repo)
9688
- - Note any pending gate approvals
9689
-
9690
- ### 5. Output Format
9691
- \`\`\`
9692
- === Project Status ===
9693
-
9694
- Sprint 3: Jan 13 - Jan 24 (4 days remaining)
9695
- Progress: [=========> ] 62% (15/24 pts)
9696
-
9697
- TaskBoard:
9698
- Backlog: 8 tasks
9699
- Ready: 3 tasks
9700
- In Progress: 2 tasks (TASK-041, TASK-044)
9701
- In Review: 1 task (TASK-039)
9702
- Done: 6 tasks
9703
-
9704
- Active Agents: 2
9705
- orchestrator: idle
9706
- developer-1: working on TASK-041
9707
-
9708
- Pending Gates: 1
9709
- GATE-007: Design approval for user notifications
9377
+ --- Gates ---
9378
+ {gate-name}: {status} ({timestamp})
9379
+
9380
+ --- Active Locks ---
9381
+ {file}: locked by {agent} for {task}
9382
+
9383
+ --- Recent Events ---
9384
+ {timestamp}: {event description}
9385
+
9386
+ --- Next Action ---
9387
+ {what should happen next based on current phase and state}
9710
9388
  \`\`\`
9711
9389
  `;
9712
9390
  }
@@ -9778,85 +9456,95 @@ function getGateCommand() {
9778
9456
 
9779
9457
  ## Description
9780
9458
  Manage quality gates \u2014 approve, reject, skip, or list pending gate checks.
9459
+ Gates are the enforcement mechanism that prevents phases from advancing without explicit user approval.
9781
9460
 
9782
9461
  ## Usage
9783
9462
  \`\`\`
9784
- /fishi-gate list # List all pending gates
9785
- /fishi-gate approve <gate-id> # Approve a gate
9786
- /fishi-gate reject <gate-id> # Reject a gate with feedback
9787
- /fishi-gate skip <gate-id> # Skip a gate (requires reason)
9788
- /fishi-gate status <gate-id> # Show details of a specific gate
9463
+ /fishi-gate approve # Approve the current pending gate
9464
+ /fishi-gate reject # Reject the current gate with feedback
9465
+ /fishi-gate skip # Skip the current gate (logged as tech debt)
9466
+ /fishi-gate list # List all gates and their statuses
9467
+ /fishi-gate status # Show the current pending gate details
9789
9468
  \`\`\`
9790
9469
 
9791
9470
  ## Instructions
9792
9471
 
9793
- ### Gate Types
9794
- Gates are quality checkpoints that require human approval before proceeding:
9795
- - **Design Gate**: Approve a design before implementation starts
9796
- - **Code Review Gate**: Approve code changes before merge
9797
- - **Test Gate**: Verify test results before deployment
9798
- - **Deploy Gate**: Approve deployment to production
9799
- - **Architecture Gate**: Approve significant architectural decisions
9472
+ ### /fishi-gate approve
9800
9473
 
9801
- ### /fishi-gate list
9802
- - Read \`.fishi/gates/\` for pending gate files
9803
- - Display each gate with:
9804
- - Gate ID (format: \`GATE-XXX\`)
9805
- - Type (design, code-review, test, deploy, architecture)
9806
- - Description
9807
- - Requesting agent/task
9808
- - Created timestamp
9809
- - Status (pending, approved, rejected, skipped)
9810
-
9811
- ### /fishi-gate approve <gate-id>
9812
- - Mark the gate as approved
9813
- - Record approver and timestamp
9814
- - Notify the waiting agent/task that it can proceed
9815
- - Log the approval in \`.fishi/memory/gate-log.md\`
9816
-
9817
- ### /fishi-gate reject <gate-id>
9818
- - Ask for rejection feedback (what needs to change)
9819
- - Mark the gate as rejected with the feedback
9820
- - Move the related task back to "In Progress"
9821
- - The agent must address the feedback and re-submit the gate
9822
-
9823
- ### /fishi-gate skip <gate-id>
9824
- - Require a reason for skipping
9825
- - Mark the gate as skipped with the reason
9826
- - Log a warning \u2014 skipped gates are tracked as tech debt
9827
- - Allow the blocked work to proceed
9828
-
9829
- ### Gate File Format
9830
- \`\`\`yaml
9831
- id: GATE-007
9832
- type: design
9833
- status: pending
9834
- task: TASK-041
9835
- description: "Design approval for user notification system"
9836
- created: 2025-01-17T14:30:00Z
9837
- artifacts:
9838
- - docs/product/notifications.md
9839
- - docs/api/notifications-api.yaml
9840
- resolution: null
9841
- resolved_at: null
9842
- resolved_by: null
9843
- feedback: null
9474
+ Run the gate approval script and advance to the next phase:
9475
+ \`\`\`bash
9476
+ node .fishi/scripts/gate-manager.mjs approve --phase {current-phase}
9477
+ \`\`\`
9478
+
9479
+ After approval, advance the phase:
9480
+ \`\`\`bash
9481
+ node .fishi/scripts/phase-runner.mjs advance
9482
+ \`\`\`
9483
+
9484
+ Read the updated state to confirm:
9485
+ \`\`\`bash
9486
+ cat .fishi/state/project.yaml
9487
+ cat .fishi/state/gates.yaml
9488
+ \`\`\`
9489
+
9490
+ Display confirmation: "Gate approved. Advanced to phase: {next-phase}"
9491
+
9492
+ ### /fishi-gate reject
9493
+
9494
+ Ask the user for feedback on what needs to change, then:
9495
+ \`\`\`bash
9496
+ node .fishi/scripts/gate-manager.mjs reject --phase {current-phase} --reason "{user feedback}"
9497
+ \`\`\`
9498
+
9499
+ Do NOT advance the phase. The current phase must be reworked.
9500
+ Display: "Gate rejected. Rework needed in phase: {current-phase}. Feedback: {reason}"
9501
+
9502
+ ### /fishi-gate skip
9503
+
9504
+ Require a reason for skipping:
9505
+ \`\`\`bash
9506
+ node .fishi/scripts/gate-manager.mjs skip --phase {current-phase} --reason "{reason}"
9844
9507
  \`\`\`
9845
9508
 
9846
- ### Output Format
9509
+ Advance the phase:
9510
+ \`\`\`bash
9511
+ node .fishi/scripts/phase-runner.mjs advance
9847
9512
  \`\`\`
9848
- === Pending Gates ===
9849
9513
 
9850
- GATE-007 [design] \u2014 Design approval for user notifications
9851
- Task: TASK-041 | Created: Jan 17, 14:30
9852
- Artifacts: docs/product/notifications.md
9514
+ Display a warning: "WARNING: Gate skipped for phase {current-phase}. This is logged as tech debt. Reason: {reason}"
9853
9515
 
9854
- GATE-008 [code-review] \u2014 Auth middleware implementation
9855
- Task: TASK-043 | Created: Jan 17, 16:00
9856
- Artifacts: src/middleware/auth.ts
9516
+ ### /fishi-gate list
9517
+
9518
+ Read all gate data:
9519
+ \`\`\`bash
9520
+ cat .fishi/state/gates.yaml
9521
+ \`\`\`
9857
9522
 
9858
- 2 gates pending approval.
9523
+ Display each gate:
9859
9524
  \`\`\`
9525
+ === Gate History ===
9526
+
9527
+ Phase | Status | Timestamp | Notes
9528
+ ---------------|----------|---------------------|------------------
9529
+ discovery | approved | 2025-01-15 10:30:00 | \u2014
9530
+ prd | approved | 2025-01-16 14:00:00 | \u2014
9531
+ architecture | pending | 2025-01-17 09:00:00 | Awaiting approval
9532
+ sprint_planning| \u2014 | \u2014 | Not yet reached
9533
+ development | \u2014 | \u2014 | Not yet reached
9534
+ deployment | \u2014 | \u2014 | Not yet reached
9535
+
9536
+ Current pending gate: architecture
9537
+ \`\`\`
9538
+
9539
+ ### /fishi-gate status
9540
+
9541
+ Read the current gate details:
9542
+ \`\`\`bash
9543
+ cat .fishi/state/gates.yaml
9544
+ cat .fishi/state/project.yaml
9545
+ \`\`\`
9546
+
9547
+ Show the pending gate with its artifacts and what the user needs to review.
9860
9548
  `;
9861
9549
  }
9862
9550
 
@@ -9865,7 +9553,7 @@ function getBoardCommand() {
9865
9553
  return `# /fishi-board \u2014 Kanban Board
9866
9554
 
9867
9555
  ## Description
9868
- Display the project kanban board and manage task movement between columns.
9556
+ Display the project kanban board by reading the taskboard state file and presenting tasks grouped by column.
9869
9557
 
9870
9558
  ## Usage
9871
9559
  \`\`\`
@@ -9873,53 +9561,60 @@ Display the project kanban board and manage task movement between columns.
9873
9561
  /fishi-board move <task-id> <column> # Move a task to a column
9874
9562
  /fishi-board add <title> # Quick-add a task to Backlog
9875
9563
  /fishi-board detail <task-id> # Show full task details
9876
- /fishi-board filter <epic-id> # Show tasks for a specific epic
9877
9564
  \`\`\`
9878
9565
 
9879
9566
  ## Instructions
9880
9567
 
9881
9568
  ### /fishi-board (Display)
9882
- - Read \`.fishi/board.md\`
9883
- - Render a visual kanban board:
9884
9569
 
9570
+ Read the taskboard file:
9571
+ \`\`\`bash
9572
+ cat .fishi/taskboard/board.md
9885
9573
  \`\`\`
9886
- === TaskBoard \u2014 Sprint 3 ===
9887
9574
 
9888
- | Backlog (8) | Ready (3) | In Progress (2) | In Review (1) | Done (6) |
9889
- |----------------|----------------|-----------------|----------------|----------------|
9890
- | TASK-045 (3pt) | TASK-043 (5pt) | TASK-041 (3pt) | TASK-039 (5pt) | TASK-038 (2pt) |
9891
- | TASK-046 (2pt) | TASK-044 (3pt) | TASK-042 (5pt) | | TASK-037 (3pt) |
9892
- | TASK-047 (5pt) | TASK-048 (2pt) | | | TASK-036 (5pt) |
9893
- | ... | | | | ... |
9575
+ Also read sprint info for context:
9576
+ \`\`\`bash
9577
+ cat .fishi/state/project.yaml
9894
9578
  \`\`\`
9895
9579
 
9580
+ Parse the board and display tasks grouped by column with counts:
9581
+
9582
+ \`\`\`
9583
+ === TaskBoard \u2014 Sprint {N} ===
9584
+
9585
+ | Backlog ({count}) | Ready ({count}) | In Progress ({count}) | In Review ({count}) | Done ({count}) |
9586
+ |--------------------|-----------------|----------------------|--------------------|--------------------|
9587
+ | {task-id}: {title} | {task-id}: ... | {task-id}: ... | {task-id}: ... | {task-id}: ... |
9588
+ | {task-id}: {title} | | | | {task-id}: ... |
9589
+
9590
+ Total: {total} tasks | Blocked: {blocked count}
9591
+ \`\`\`
9592
+
9593
+ Highlight any BLOCKED tasks with their blocking reason.
9594
+
9896
9595
  ### /fishi-board move <task-id> <column>
9897
- - Valid columns: \`backlog\`, \`ready\`, \`in-progress\`, \`in-review\`, \`done\`
9898
- - Update the task's position in \`.fishi/board.md\`
9899
- - Update the task's timestamp
9900
- - If moving to \`done\`:
9901
- - Update sprint burndown (reduce remaining points)
9902
- - Check if acceptance criteria are defined
9903
- - If moving to \`in-progress\`:
9904
- - Check if an agent is assigned
9596
+
9597
+ Valid columns: backlog, ready, in-progress, in-review, done
9598
+
9599
+ 1. Read the current board: \`cat .fishi/taskboard/board.md\`
9600
+ 2. Move the task to the new column by editing \`.fishi/taskboard/board.md\`
9601
+ 3. If moving to done, verify acceptance criteria are met
9602
+ 4. If moving to in-progress, verify an agent is assigned
9603
+ 5. Display the updated board
9905
9604
 
9906
9605
  ### /fishi-board add <title>
9907
- - Trigger the TaskBoard Ops skill to create a new task
9908
- - Add to the Backlog column by default
9909
- - Prompt for: description, priority, story points, epic
9606
+
9607
+ 1. Read the current board: \`cat .fishi/taskboard/board.md\`
9608
+ 2. Generate a new task ID (next sequential number)
9609
+ 3. Add the task to the Backlog column in \`.fishi/taskboard/board.md\`
9610
+ 4. Ask the user for: description, priority, assigned agent
9611
+ 5. Display the updated board
9910
9612
 
9911
9613
  ### /fishi-board detail <task-id>
9912
- - Show full task details:
9913
- - ID, title, description
9914
- - Status, column, assignee
9915
- - Priority, story points
9916
- - Epic and story references
9917
- - Acceptance criteria
9918
- - Comments and history
9919
-
9920
- ### /fishi-board filter <epic-id>
9921
- - Display the board showing only tasks belonging to the specified epic
9922
- - Show epic progress summary at the top
9614
+
9615
+ 1. Read the board: \`cat .fishi/taskboard/board.md\`
9616
+ 2. Find the task by ID
9617
+ 3. Display full details: ID, title, description, status, assigned agent, priority, acceptance criteria, history
9923
9618
  `;
9924
9619
  }
9925
9620
 
@@ -10285,6 +9980,15 @@ function getSettingsJsonTemplate() {
10285
9980
  command: "node .fishi/scripts/safety-check.mjs"
10286
9981
  }
10287
9982
  ]
9983
+ },
9984
+ {
9985
+ matcher: "Write|Edit",
9986
+ hooks: [
9987
+ {
9988
+ type: "command",
9989
+ command: "node .fishi/scripts/phase-guard.mjs"
9990
+ }
9991
+ ]
10288
9992
  }
10289
9993
  ],
10290
9994
  PostToolUse: [
@@ -10422,136 +10126,245 @@ function getClaudeMdTemplate(options) {
10422
10126
 
10423
10127
  ---
10424
10128
 
10425
- ## 1. FISHI Framework \u2014 Agent Hierarchy
10129
+ <EXTREMELY-IMPORTANT>
10426
10130
 
10427
- This project is orchestrated by **FISHI** (Framework for Intelligent Software Handling and Integration).
10428
- Three layers, strict delegation, no exceptions.
10131
+ ## CRITICAL RULES \u2014 FISHI ORCHESTRATION ENGINE \u2014 YOU MUST FOLLOW THESE
10429
10132
 
10430
- | Layer | Role | Model | Responsibility |
10431
- |-------|------|-------|----------------|
10432
- | **L0** | Master Orchestrator | Opus | Strategy, gate approvals, phase transitions. NEVER writes code. |
10433
- | **L1** | Coordinators | Opus (critical) / Sonnet (routine) | \`planning-lead\`, \`dev-lead\`, \`quality-lead\`, \`ops-lead\` \u2014 own their domain end-to-end. |
10434
- | **L2** | Workers | Sonnet / Haiku | Execute tasks in isolated worktrees. Commit code, run tests, report back. |
10133
+ 1. **READ STATE FIRST.** Before ANY action, read \`.fishi/state/project.yaml\` to know the current phase.
10134
+ 2. **FOLLOW THE PIPELINE.** You are in a phase. Only do work allowed in that phase. Do NOT skip ahead.
10135
+ 3. **DISPATCH AGENTS.** You are the Master Orchestrator. You NEVER write application code directly. Use the Agent tool to dispatch work to specialists.
10136
+ 4. **USE WORKTREES.** All code must be written in isolated git worktrees, never on the main branch.
10137
+ 5. **GATE APPROVALS.** Each phase ends with a gate. STOP and ask the user to approve before advancing.
10138
+ 6. **UPDATE STATE.** After every significant action, update project.yaml, taskboard, and agent memory.
10139
+ 7. **READ SOUL.md.** The SOUL.md file defines absolute boundaries. Read it at session start.
10435
10140
 
10436
- If no existing coordinator fits a task, create one dynamically from \`.fishi/agent-factory/coordinator-template.md\`.
10141
+ ### Anti-Rationalization
10142
+ | Thought | Reality |
10143
+ |---------|---------|
10144
+ | "I'll just write the code quickly" | NO. Dispatch a worker agent. You are the orchestrator. |
10145
+ | "Worktrees are overkill for this" | NO. Every code change goes through a worktree. No exceptions. |
10146
+ | "I'll skip the PRD, it's obvious" | NO. Every project gets a PRD. Even simple ones. |
10147
+ | "I'll update the board later" | NO. Update the board NOW, before and after every task. |
10148
+ | "The user wants speed, skip gates" | NO. Gates exist for quality. Use /fishi-quickstart for speed. |
10149
+ | "I know what to build" | NO. Discovery phase first. Research the domain. |
10150
+
10151
+ </EXTREMELY-IMPORTANT>
10437
10152
 
10438
10153
  ---
10439
10154
 
10440
- ## 2. Mandatory Workflow Pipeline
10155
+ ## How to Dispatch Agents
10441
10156
 
10442
- **Every user request MUST follow this pipeline. No skipping phases.**
10157
+ You MUST use the Agent tool to dispatch work. Here are the exact patterns:
10443
10158
 
10159
+ ### Dispatch a Worker Agent
10444
10160
  \`\`\`
10445
- User Request \u2192 Phase 0 \u2192 Phase 1 \u2192 Phase 2 \u2192 Phase 3 \u2192 Phase 4 \u2192 Phase 5 \u2192 Phase 6
10446
- Init Discover PRD Arch Sprint Develop Deploy
10161
+ Use the Agent tool with:
10162
+ subagent_type: "the-agent-name" (matches .claude/agents/{name}.md)
10163
+ prompt: "You are the {name}. Your task: {specific task description}.
10164
+ Work in the worktree at: .trees/{worktree-name}/
10165
+ When done, commit your changes and report back with:
10166
+ - FILES_CHANGED: list of files
10167
+ - STATUS: success or failed
10168
+ - SUMMARY: what you did"
10447
10169
  \`\`\`
10448
10170
 
10449
- | Phase | Name | Owner | Skill / Agent | Gate |
10450
- |-------|------|-------|---------------|------|
10451
- | 0 | **Init** | Master | Classify ${projectType} project, scaffold \`.fishi/\` | \u2014 |
10452
- | 1 | **Discovery** | planning-lead | \`brainstorming\` skill | User approves discovery summary |
10453
- | 2 | **PRD** | planning-lead | \`prd-creation\` skill | User approves PRD |
10454
- | 3 | **Architecture** | planning-lead | \`architect-agent\` | User approves architecture doc |
10455
- | 4 | **Sprint Planning** | planning-lead | \`planning-agent\` | User approves sprint plan |
10456
- | 5 | **Development** | dev-lead + quality-lead | Workers in worktrees, PR reviews | Per-PR gate approval |
10457
- | 6 | **Deployment** | ops-lead | \`devops-agent\` | User approves deploy |
10171
+ ### Dispatch Research Agent
10172
+ \`\`\`
10173
+ Use the Agent tool with:
10174
+ subagent_type: "deep-research-agent"
10175
+ prompt: "Research {topic} for project ${projectName}.
10176
+ Save findings to .fishi/research/{topic}.md
10177
+ Include: Executive Summary, Key Findings, Recommendations, Sources"
10178
+ \`\`\`
10458
10179
 
10459
- **Rules**:
10460
- - You MUST NOT advance to the next phase without explicit gate approval from the user.
10461
- - Use \`/fishi-init\` or describe what to build to trigger Phase 0.
10462
- - Each gate produces an artifact in \`.fishi/artifacts/\`.
10180
+ ### Dispatch Coordinator
10181
+ \`\`\`
10182
+ Use the Agent tool with:
10183
+ subagent_type: "dev-lead" (or planning-lead, quality-lead, ops-lead)
10184
+ prompt: "You are the {coordinator}. Break down this objective into tasks:
10185
+ {objective description}
10186
+ For each task:
10187
+ 1. Create a worktree: node .fishi/scripts/worktree-manager.mjs create --agent {worker} --task {slug}
10188
+ 2. Dispatch the worker agent with specific instructions
10189
+ 3. Review the output when worker reports back
10190
+ 4. Update taskboard: move task to Review, then Done"
10191
+ \`\`\`
10463
10192
 
10464
10193
  ---
10465
10194
 
10466
- ## 3. Delegation Protocol
10195
+ ## Pipeline Phases
10467
10196
 
10468
- The Master Orchestrator NEVER writes code, tests, configs, or docs directly. ALWAYS delegate:
10197
+ **Current phase is stored in \`.fishi/state/project.yaml\` under \`phase:\`**
10469
10198
 
10470
- | Work Type | Delegate To |
10471
- |-----------|-------------|
10472
- | Discovery, PRD, architecture, sprint planning | \`planning-lead\` |
10473
- | Feature implementation, bug fixes | \`dev-lead\` |
10474
- | Testing, code review, quality gates | \`quality-lead\` |
10475
- | CI/CD, infrastructure, deployment, documentation | \`ops-lead\` |
10199
+ Read it at session start. Only do work allowed in that phase.
10476
10200
 
10477
- Coordinators decompose work into tasks, assign to workers, review output, and report status back to Master.
10201
+ ### Phase 0: Init
10202
+ - **Allowed**: Read files, analyze project, scaffold
10203
+ - **NOT allowed**: Writing application code
10204
+ - **Action**: Classify project type, ensure scaffold is complete
10205
+ - **Advance**: Automatically advance to Phase 1 (Discovery)
10206
+ - **Command**: \`node .fishi/scripts/phase-runner.mjs set --phase discovery\`
10478
10207
 
10479
- ---
10208
+ ### Phase 1: Discovery
10209
+ - **Allowed**: Research, brainstorming, reading existing code
10210
+ - **NOT allowed**: Writing application code
10211
+ - **Owner**: planning-lead
10212
+ - **Actions**:
10213
+ 1. Dispatch deep-research-agent to research the domain
10214
+ 2. Brainstorm with user (Socratic questioning, 2-3 approaches)
10215
+ 3. Analyze existing codebase (if brownfield)
10216
+ 4. Detect MCP needs and install: \`node .fishi/scripts/mcp-manager.mjs detect\`
10217
+ 5. Save discovery summary to \`.fishi/plans/discovery/\`
10218
+ 6. Update phase: \`node .fishi/scripts/phase-runner.mjs set --phase discovery\`
10219
+
10220
+ <HARD-GATE>
10221
+ STOP. Present discovery summary to user. Ask: "Approve discovery to proceed to PRD? /fishi-gate approve"
10222
+ Do NOT proceed to PRD until user explicitly approves.
10223
+ </HARD-GATE>
10224
+
10225
+ ### Phase 2: PRD
10226
+ - **Allowed**: Writing PRD document, requirements gathering
10227
+ - **NOT allowed**: Writing application code
10228
+ - **Owner**: planning-lead
10229
+ - **Actions**:
10230
+ 1. Create PRD with these sections: Overview, Problem Statement, User Stories, Acceptance Criteria, Non-Functional Requirements, Technical Constraints, Success Metrics, Risks, Timeline, Dependencies, Out of Scope, Open Questions, Appendix, Brownfield Analysis (if applicable)
10231
+ 2. Save to \`.fishi/plans/prd/PRD.md\`
10232
+ 3. Create gate: \`node .fishi/scripts/gate-manager.mjs create --phase prd --description "PRD approval"\`
10233
+
10234
+ <HARD-GATE>
10235
+ STOP. Present PRD to user. Ask: "Approve PRD to proceed to Architecture? /fishi-gate approve"
10236
+ Do NOT proceed until user explicitly approves.
10237
+ </HARD-GATE>
10480
10238
 
10481
- ## 4. Worktree Protocol
10239
+ ### Phase 3: Architecture
10240
+ - **Allowed**: System design, tech stack decisions, writing architecture docs
10241
+ - **NOT allowed**: Writing application code
10242
+ - **Owner**: planning-lead + architect-agent
10243
+ - **Actions**:
10244
+ 1. Dispatch architect-agent to design the system
10245
+ 2. Define: tech stack, database schema, API design, component hierarchy, deployment strategy
10246
+ 3. Select integration patterns: \`node .fishi/scripts/patterns.mjs\` (if patterns selected during init)
10247
+ 4. Save to \`.fishi/plans/architecture/\`
10248
+ 5. Create gate: \`node .fishi/scripts/gate-manager.mjs create --phase architecture\`
10249
+
10250
+ <HARD-GATE>
10251
+ STOP. Present architecture to user. Ask: "Approve architecture to proceed to Sprint Planning?"
10252
+ </HARD-GATE>
10482
10253
 
10483
- Every code-producing agent MUST work in an isolated git worktree.
10254
+ ### Phase 4: Sprint Planning
10255
+ - **Allowed**: Creating tasks, updating taskboard, planning sprints
10256
+ - **NOT allowed**: Writing application code
10257
+ - **Owner**: planning-lead + planning-agent
10258
+ - **Actions**:
10259
+ 1. Break architecture into epics, stories, tasks
10260
+ 2. Update taskboard: write tasks to \`.fishi/taskboard/board.md\`
10261
+ 3. Use TodoWrite to create checklist for each sprint
10262
+ 4. Assign tasks to agents (backend-agent, frontend-agent, etc.)
10263
+ 5. Create gate: \`node .fishi/scripts/gate-manager.mjs create --phase sprint_planning\`
10264
+
10265
+ <HARD-GATE>
10266
+ STOP. Present sprint plan to user. Ask: "Approve sprint plan to start development?"
10267
+ </HARD-GATE>
10484
10268
 
10485
- - **Location**: \`.trees/{agent-name}/\`
10486
- - **Branch naming**: \`agent/{coordinator}/{worker}/{task-slug}\`
10487
- - **Workflow**: Worker commits in worktree \u2192 Coordinator reviews \u2192 Master presents PR to user
10488
- - **On approval**: Merge to \`dev\` \u2192 Delete worktree \u2192 Update taskboard
10489
- - **NEVER** push or merge from a worker agent. Only coordinators merge.
10490
- - The \`main\` branch is protected \u2014 merges only after quality-lead approval.
10269
+ ### Phase 5: Development
10270
+ - **Allowed**: Writing code IN WORKTREES ONLY, running tests, code review
10271
+ - **NOT allowed**: Writing code on main branch
10272
+ - **Owner**: dev-lead + quality-lead
10273
+ - **Actions for each task**:
10274
+ 1. **Create worktree**: \`node .fishi/scripts/worktree-manager.mjs create --agent {agent-name} --task {task-slug} --coordinator dev-lead\`
10275
+ 2. **Lock files**: \`node .fishi/scripts/file-lock-hook.mjs lock --files "{file1},{file2}" --agent {agent-name} --task {task-slug} --coordinator dev-lead\`
10276
+ 3. **Dispatch worker**: Use Agent tool with worktree path and task description
10277
+ 4. **Update board**: Move task from Ready \u2192 In Progress
10278
+ 5. **Worker completes**: Worker commits in worktree, reports back
10279
+ 6. **Quality review**: Dispatch quality-lead to review the worktree code
10280
+ 7. **Update board**: Move task to Review \u2192 Done
10281
+ 8. **Release locks**: \`node .fishi/scripts/file-lock-hook.mjs release --agent {agent-name} --task {task-slug}\`
10282
+ 9. **Record learnings**: \`node .fishi/scripts/learnings-manager.mjs add-practice --agent {agent-name} --domain {domain} --practice "{what was learned}"\`
10283
+ 10. **Update memory**: \`node .fishi/scripts/memory-manager.mjs write --agent {agent-name} --key {key} --value "{value}"\`
10284
+
10285
+ ### Phase 6: Deployment
10286
+ - **Allowed**: CI/CD setup, deployment configs, documentation
10287
+ - **Owner**: ops-lead
10288
+ - **Actions**:
10289
+ 1. Dispatch devops-agent for CI/CD setup
10290
+ 2. Dispatch docs-agent for documentation
10291
+ 3. Run security scan: \`npx @qlucent/fishi security scan\`
10292
+ 4. Run design validation: \`npx @qlucent/fishi design validate\`
10293
+ 5. Create gate: \`node .fishi/scripts/gate-manager.mjs create --phase deployment\`
10294
+
10295
+ <HARD-GATE>
10296
+ STOP. Present deployment plan. Ask user to approve final deployment.
10297
+ </HARD-GATE>
10491
10298
 
10492
10299
  ---
10493
10300
 
10494
- ## 5. TaskBoard Protocol
10301
+ ## State Management
10495
10302
 
10496
- All work is tracked in \`.fishi/taskboard/board.md\`.
10303
+ **You MUST update these after every significant action:**
10497
10304
 
10498
- - Coordinators own task management in their domain.
10499
- - Task lifecycle: **Backlog \u2192 Ready \u2192 In Progress \u2192 Review \u2192 Done**
10500
- - Update sprint burndown after every task state change.
10501
- - Blocked tasks: mark \`[BLOCKED: reason]\` and notify coordinator immediately.
10502
- - Check the board BEFORE starting any work. Never work on untracked tasks.
10305
+ | What | How |
10306
+ |------|-----|
10307
+ | Phase | \`node .fishi/scripts/phase-runner.mjs set --phase {phase}\` |
10308
+ | Gate | \`node .fishi/scripts/gate-manager.mjs create/approve/reject --phase {phase}\` |
10309
+ | Taskboard | Edit \`.fishi/taskboard/board.md\` \u2014 move tasks between columns |
10310
+ | Agent memory | \`node .fishi/scripts/memory-manager.mjs write --agent {name} --key {key} --value "{value}"\` |
10311
+ | Learnings | \`node .fishi/scripts/learnings-manager.mjs add-practice/add-mistake --agent {name} --domain {domain}\` |
10312
+ | TODO | Use TodoWrite tool to track current work |
10313
+ | Checkpoint | Auto-saved on session stop (auto-checkpoint hook) |
10314
+ | Monitor | Auto-emitted by hooks (session-start, agent-complete, gate-manager) |
10503
10315
 
10504
10316
  ---
10505
10317
 
10506
- ## 6. State & Resume
10507
-
10508
- FISHI maintains session continuity through state files.
10509
-
10510
- | Event | Action |
10511
- |-------|--------|
10512
- | **Session start** | Read \`.fishi/state/project.yaml\` \u2014 resume current phase and active tasks |
10513
- | **Session stop** | Auto-checkpoint: save phase, active tasks, pending gates to state |
10514
- | **Resume** | Pick up exactly where the previous session ended. Never restart a phase. |
10515
-
10516
- You MUST read state before taking any action. You MUST write state before ending any session.
10318
+ ## Agent Hierarchy
10319
+
10320
+ | Layer | Agent | Model | Role |
10321
+ |-------|-------|-------|------|
10322
+ | **L0** | master-orchestrator | opus | Strategy, delegation, gates. NEVER writes code. |
10323
+ | **L1** | planning-lead | sonnet | Discovery, PRD, architecture, sprint planning |
10324
+ | **L1** | dev-lead | sonnet | Task assignment, worktree management, code review |
10325
+ | **L1** | quality-lead | sonnet | Testing, security audits, quality gates |
10326
+ | **L1** | ops-lead | sonnet | DevOps, docs, deployment |
10327
+ | **L2** | deep-research-agent | opus | Domain research, competitive analysis |
10328
+ | **L2** | architect-agent | opus | System design, tech stack decisions |
10329
+ | **L2** | backend-agent | sonnet | APIs, services, database |
10330
+ | **L2** | frontend-agent | sonnet | UI components, state management |
10331
+ | **L2** | fullstack-agent | sonnet | End-to-end features |
10332
+ | **L2** | testing-agent | sonnet | Unit, integration, E2E tests (TDD) |
10333
+ | **L2** | security-agent | sonnet | OWASP audits, vulnerability scanning |
10334
+ | **L2** | devops-agent | sonnet | CI/CD, infrastructure |
10335
+ | **L2** | docs-agent | haiku | Documentation, API docs |
10336
+ | **Dynamic** | Created from \`.fishi/agent-factory/\` | varies | Specialized agents as needed |
10337
+
10338
+ **To create a dynamic agent**: Read the template from \`.fishi/agent-factory/agent-template.md\`, customize for the task, save to \`.claude/agents/{name}.md\`.
10517
10339
 
10518
10340
  ---
10519
10341
 
10520
- ## 7. Key File Locations
10342
+ ## Key File Locations
10521
10343
 
10522
10344
  | Path | Purpose |
10523
10345
  |------|---------|
10524
- | \`.claude/agents/\` | Agent definitions (markdown + YAML frontmatter) |
10525
- | \`.claude/agents/coordinators/\` | Coordinator agent definitions |
10526
- | \`.claude/skills/\` | Reusable skill definitions |
10527
- | \`.claude/commands/\` | Slash command definitions |
10528
- | \`.claude/settings.json\` | Hook configuration |
10529
- | \`.fishi/state/\` | Project state, checkpoints |
10530
- | \`.fishi/taskboard/\` | Board, backlog, sprints, epics |
10531
- | \`.fishi/artifacts/\` | Gate artifacts (PRDs, arch docs, sprint plans) |
10532
- | \`.fishi/agent-factory/\` | Templates for dynamic agent creation |
10533
- | \`.fishi/scripts/\` | Hook scripts (.mjs) |
10534
- | \`.fishi/logs/\` | Agent execution logs (gitignored) |
10535
- | \`.mcp.json\` | MCP server configuration |
10536
-
10537
- ---
10538
-
10539
- ## 8. Slash Commands
10540
-
10541
- | Command | Description |
10542
- |---------|-------------|
10543
- | \`/fishi-init\` | Initialize project \u2014 classify type, scaffold FISHI structure |
10544
- | \`/fishi-status\` | Show current phase, active tasks, blockers |
10545
- | \`/fishi-board\` | Display the taskboard |
10546
- | \`/fishi-sprint\` | Show current sprint with burndown |
10547
- | \`/fishi-gate\` | Trigger gate review for current phase |
10548
- | \`/fishi-prd\` | Start or resume PRD creation |
10549
- | \`/fishi-resume\` | Resume from last checkpoint |
10550
- | \`/fishi-reset\` | Reset FISHI state (requires confirmation) |
10346
+ | \`SOUL.md\` | Agent boundaries \u2014 READ AT SESSION START |
10347
+ | \`AGENTS.md\` | Per-role action gates |
10348
+ | \`.claude/agents/\` | Agent definitions |
10349
+ | \`.claude/settings.json\` | Hooks + permissions |
10350
+ | \`.fishi/state/project.yaml\` | Current phase, sprint |
10351
+ | \`.fishi/state/gates.yaml\` | Gate approvals |
10352
+ | \`.fishi/state/monitor.json\` | Monitoring events |
10353
+ | \`.fishi/state/file-locks.yaml\` | File lock registry |
10354
+ | \`.fishi/taskboard/board.md\` | Kanban board |
10355
+ | \`.fishi/plans/\` | PRDs, architecture, discovery |
10356
+ | \`.fishi/research/\` | Deep research reports |
10357
+ | \`.fishi/scripts/\` | Hook and utility scripts |
10358
+ | \`.fishi/memory/\` | Agent memory |
10359
+ | \`.fishi/learnings/\` | Best practices + mistakes |
10360
+ | \`.fishi/todos/\` | Per-agent TODO lists |
10361
+ | \`.fishi/agent-factory/\` | Dynamic agent templates |
10362
+ | \`.trees/\` | Git worktrees for agent work |
10363
+ | \`.fishi/sandbox-policy.yaml\` | Sandbox access rules |
10551
10364
 
10552
10365
  ---
10553
10366
 
10554
- ## 9. Coding Conventions
10367
+ ## Coding Conventions
10555
10368
 
10556
10369
  ${conventionsBlock}
10557
10370
  `;
@@ -11574,7 +11387,8 @@ async function generateScaffold(targetDir, options) {
11574
11387
  await write(".fishi/scripts/doc-checker.mjs", getDocCheckerScript());
11575
11388
  await write(".fishi/scripts/monitor-emitter.mjs", getMonitorEmitterScript());
11576
11389
  await write(".fishi/scripts/file-lock-hook.mjs", getFileLockHookScript());
11577
- const hookCount = 17;
11390
+ await write(".fishi/scripts/phase-guard.mjs", getPhaseGuardHook());
11391
+ const hookCount = 18;
11578
11392
  const todoTemplate = (name) => `# TODO \u2014 ${name}
11579
11393
 
11580
11394
  ## Active
@@ -15685,6 +15499,7 @@ export {
15685
15499
  getPatternCategories,
15686
15500
  getPatternsByCategory,
15687
15501
  getPermissionsForRole,
15502
+ getPhaseGuardHook,
15688
15503
  getPhaseRunnerScript,
15689
15504
  getPostEditHook,
15690
15505
  getPrdCommand,