Skip to content

Pipeline Plan 44

Seth Ford edited this page Feb 13, 2026 · 2 revisions

The plan file is in a sensitive directory. Let me present the plan directly here instead — it's the pipeline's plan stage output.

Implementation Plan: Autonomous PM Agent

Architecture Summary

The PM agent is a new bash module (sw-pm-agent.sh) that sits between daemon issue intake and pipeline execution. It analyzes each issue, produces a team-plan.json with team size/roles/stage config, which the pipeline reads and executes. Disabled by default — zero impact when off; falls back to static templates on failure.

Daemon receives issue
    ├── triage_score_issue() [existing]
    ├── select_pipeline_template() [existing]
    ├── pm_agent_plan() [NEW — if enabled]
    │   ├── _pm_analyze_issue()     → complexity, type, scope, risk
    │   ├── _pm_decide_team_size()  → 1-6 agents
    │   ├── _pm_compose_team()      → roles + focus areas
    │   ├── _pm_configure_stages()  → skip/parallel/iterations
    │   └── writes team-plan.json
    └── daemon_spawn_pipeline()
         └── sw-pipeline.sh --team-plan team-plan.json
              └── reads plan, applies skips, passes team config to sw-loop.sh

Files to Modify

New Files:

File Purpose
scripts/sw-pm-agent.sh ~600 lines — core PM agent module
scripts/sw-pm-agent-test.sh ~800 lines — 33+ test suite

Modified Files:

File Changes
.claude/daemon-config.json Add pm_agent config section (disabled by default)
scripts/sw-daemon.sh Source PM agent, call in daemon_spawn_pipeline(), load config, record outcomes
scripts/sw-pipeline.sh Accept --team-plan, load plan, apply stage skips, pass team config to build loop
scripts/sw-loop.sh Accept --team-plan argument
scripts/sw-self-optimize.sh Add optimize_analyze_team_outcome()
package.json Register test suite #23
.claude/CLAUDE.md Add PM agent to docs tables

Implementation Steps

Step 1-7: sw-pm-agent.sh — New module with:

  • _pm_analyze_issue() — keyword extraction, complexity scoring, type/risk classification, intelligence enrichment
  • _pm_decide_team_size() — decision matrix (complexity × scope × budget × learned weights)
  • _pm_compose_team() — role selection (builder/tester/reviewer/security/performance) with focus areas
  • _pm_configure_stages() — skip compound_quality for simple, skip design for bugfixes, adversarial for high-risk
  • pm_agent_plan() — orchestrator producing team-plan.json
  • pm_agent_record_outcome() / pm_agent_learn() — outcome tracking + exponential-smoothed weight learning

Step 8: Configpm_agent section in daemon-config.json (enabled: false, max_team_size: 6, min_confidence: 0.7)

Step 9: Daemon integration — Source module, call pm_agent_plan() before building pipeline args, pass --team-plan to pipeline, record outcomes on job completion, run learning alongside self-optimize

Step 10-11: Pipeline/Loop integration — Accept --team-plan arg, load plan, apply stage skips, pass agents/roles/iterations to build loop

Step 12: Self-optimize — Team analytics function reading ~/.shipwright/pm-agent/outcomes.jsonl

Step 13-14: Tests + docs — 33+ unit tests across 7 categories, register in package.json, update CLAUDE.md


Task Checklist

  • Task 1: Create sw-pm-agent.sh skeleton (VERSION, helpers, emit_event, CLI dispatch)
  • Task 2: Implement _pm_analyze_issue() — complexity scoring, type detection, keyword extraction
  • Task 3: Implement _pm_decide_team_size() — decision matrix with budget/learning constraints
  • Task 4: Implement _pm_compose_team() — role selection and focus area assignment
  • Task 5: Implement _pm_configure_stages() — stage skip/parallel/iteration decisions
  • Task 6: Implement pm_agent_plan() — main entry assembling team-plan.json
  • Task 7: Implement pm_agent_record_outcome() and pm_agent_learn() — learning system
  • Task 8: Add pm_agent config to .claude/daemon-config.json
  • Task 9: Integrate into sw-daemon.sh — source, spawn call, config loading, outcome recording
  • Task 10: Integrate into sw-pipeline.sh--team-plan, stage skips, build loop config
  • Task 11: Integrate into sw-loop.sh--team-plan argument
  • Task 12: Extend sw-self-optimize.sh — team outcome analytics
  • Task 13: Create sw-pm-agent-test.sh — 33+ tests across 7 categories
  • Task 14: Register test in package.json, update .claude/CLAUDE.md

Testing Approach

Unit tests (sw-pm-agent-test.sh): 33+ tests across issue analysis (6), team sizing (6), composition (5), stage config (5), full plan gen (4), outcome recording (3), learning (4). Isolated temp dirs, mock gh/claude binaries, PASS/FAIL counters.

Integration: Enable pm_agent, create issues of varying complexity, verify team-plan.json output, verify pipeline reads/applies plan, verify fallback on failure, verify learning after 5+ outcomes.

Regression: All 22 existing suites pass (PM agent disabled by default).


Definition of Done

  • sw-pm-agent.sh produces valid team-plan.json for varied issue types
  • Team size varies: simple=1, medium=2, complex=3+
  • Roles match issue characteristics (security label → security role)
  • Stage skips work (compound_quality for simple, design for bugfixes)
  • Fallback to static templates when PM agent fails/disabled
  • All decisions logged via emit_event("pm_agent.*")
  • Outcome recording captures actual vs predicted
  • Learning adjusts weights after 5+ samples
  • Daemon calls PM agent in spawn flow, passes results to pipeline
  • Pipeline reads team plan, applies skips, passes config to loop
  • pm_agent.enabled: false by default — zero impact when off
  • 33+ tests pass in sw-pm-agent-test.sh
  • All 22 existing test suites continue to pass
  • .claude/CLAUDE.md updated

Clone this wiki locally