Skip to content

[Epic] PAI-OpenCode v3.0 — The Synthesis Architecture #30

@Steffen025

Description

@Steffen025

Epic: PAI-OpenCode v3.0 — The Synthesis Architecture

🎯 Vision

"Take the concept of the PAI system and synthesize it with OpenCode's unique capabilities"

PAI-OpenCode v3.0 is not a clone of Daniel Miessler's PAI. It is a new synthesis that:

  • Preserves PAI's core philosophy (Algorithm, Skills, Euphoric Surprise)
  • Leverages OpenCode's unique strengths (Dynamic Model Tiers ✅, Lazy Loading, MCP Ecosystem)
  • Establishes its own identity as an OpenCode-First Ambient AI System

🔥 Key Differentiators

✅ Production-Ready Today

  • Model Tiers: Already implemented in custom OpenCode binary (15+ agents configured)
  • Cost Optimization: 60x savings ($1.25/M vs $75/M tokens) via intelligent routing
  • Custom Binary: Uses forked OpenCode with model_tier support (feature/model-tiers branch)

🆕 OpenCode-Native Features (Research-Validated)

Feature Status Action
Lazy Loading ✅ Native Use skill tool, remove 233KB static context
Plugin Events ✅ Native Migrate hooks → events (20+ events available)
MCP Integration ✅ Native Configure skills as MCP servers
Context Compaction ✅ Native Auto-handled by OpenCode
Agent Swarms ❌ Not available Skip (Claude-Code-only feature)

🛡️ Security-First (NEW WP3.5)

  • Prompt Injection Protection: Detection + sanitization layer
  • Input Validation: Pre-processing security guardrails
  • Security Event Logging: Audit trail for all operations
  • Regular Testing: Integration with PromptInjection skill for pentesting

📋 Work Packages (9 Total, 51-73h)

Critical Path

WP1 → WP2 → WP3 → WP3.5 → WP8
WP Name Effort Key Deliverable
WP1 Algorithm v3.7.0 + Model Tiers 8-12h Port Algorithm, integrate existing Model Tier system
WP2 Context Modernization 6-8h 233KB → 20KB using native lazy loading
WP3 Event-Driven Plugins 5-7h Migrate hooks → OpenCode native events
WP3.5 Security Hardening 4-6h Prompt Injection protection, sanitization, logging
WP4 Skill Hierarchy 8-10h 39 skills → 11 PAI v4.0.3 categories
WP5 MCP Configuration 4-6h 3-5 skills as MCP servers (configure, not build)
WP6 Voice Foundation 4-6h WebSocket-ready architecture for future V2V
WP7 Migration & Installer 6-8h v2→v3 script + custom binary installer
WP8 Testing & Release 6-10h Full test suite, beta, v3.0.0 release

Total Critical Path: 51-73 hours
Parallel Work: WP4, WP5, WP6 can run simultaneously after WP1

🏗️ Architecture Changes

Before (v2.x)

233KB static context
Custom context-loader.ts
Hook emulation layer
Flat skill structure (39 skills)
Fixed models per agent

After (v3.0)

~20KB minimal bootstrap (Algorithm + TELOS)
Native OpenCode skill tool
Event-driven plugins (pai-core.ts)
Hierarchical structure (11 categories)
Dynamic Model Tiers (quick/standard/advanced)
Prompt Injection protection
MCP-first skill architecture

🚫 Dropped Features

  • StatusLine: OpenCode TUI limitation → Use Voice notifications
  • Agent Swarms: Not in OpenCode → Use Task tool with subagents
  • Static 233KB Context: Inefficient → Lazy loading
  • Hook Emulation: Technical debt → Native events

🎓 Research Sources

  • DeepWiki Analysis: 6 queries, 100% success (7-11s response time)
  • Fabric Pattern Analysis: Daniel Miessler's PAI v4.0 videos
  • GitHub Research: OpenCode issues #12661, #12711, #7756
  • Production Config: ~/.opencode/opencode.json (15 agents with Model Tiers)

🎯 Success Criteria

  1. ✅ Algorithm v3.7.0 with ISC fully functional
  2. ✅ Initial context <25KB (vs 233KB current)
  3. ✅ Dynamic Model Tier routing working (15+ agents)
  4. ✅ Prompt Injection protection active
  5. ✅ 3+ skills as MCP servers
  6. ✅ Unified event-driven plugin
  7. ✅ All 39 skills in hierarchical structure
  8. ✅ Migration script tested
  9. ✅ Documentation complete
  10. ✅ CI/CD passing

📁 Branches

  • Main Epic Branch: v3.0-rearchitecture
  • WP Branches: v3.0-wp1-algorithm, v3.0-wp2-context, etc.
  • Base Branch: dev (create PRs here)

📚 References

  • Epic Document: docs/epic/EPIC-v3.0-Synthesis-Architecture.md (954 lines)
  • PAI v4.0.3: /Releases/v4.0.3/.claude/ (hierarchical structure)
  • OpenCode Docs: opencode.ai/docs
  • Handoff: .opencode/MEMORY/WORK/2026-02-14_PAI-OpenCode-ReArchitecture_HANDOFF.md

🚀 Next Actions

  1. ✅ Epic approved (this issue)
  2. ⏳ Start WP1: Algorithm v3.7.0 + Model Tier integration
  3. ⏳ DeepWiki follow-up queries if needed
  4. ⏳ Begin work on v3.0-wp1-algorithm branch

This is not a port. This is a synthesis.
Target: PAI-OpenCode v3.0.0

/cc @Steffen025

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions