Skip to content

roman-ryzenadvanced/fusion-zcode-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Fusion β€” Hybrid Smart Multi-Model AI Orchestration for ZCode

License: MIT ZCode Plugin MCP Version PRs Welcome

Let multiple AI models collaborate on a single task β€” automatically.

Fusion brings OpenRouter-style model ensemble routing to ZCode. It analyzes your task in real time and selects the best fusion strategy: 🀝 Consensus Β· πŸ”— Sequential Β· 🎯 Specialist Β· πŸ›‘οΈ Fallback.


πŸ“– Table of Contents

  1. What is Fusion?
  2. Why Fusion? (With vs Without)
  3. The Four Fusion Modes
  4. Visual Walkthrough
  5. Quick Start
  6. Configuration
  7. Usage Examples
  8. MCP API Reference
  9. Architecture
  10. How We Built It
  11. Replicate This Setup
  12. Use Cases
  13. FAQ
  14. Contributing
  15. License

🎯 What is Fusion?

Fusion is a ZCode plugin that orchestrates multiple AI models on a single task. Instead of relying on one model for everything, Fusion dynamically selects and combines models based on what the task actually needs.

Inspired by OpenRouter's Fusion, Fusion brings the same multi-model intelligence directly into your coding agent β€” so the right models collaborate on the right parts of your work.

In one sentence: Fusion reads your task, picks the best model combination, and synthesizes their outputs into one better answer.

Key Capabilities

  • 🧠 Auto task analysis β€” Detects complexity, domain, and reliability needs
  • πŸ”€ Four fusion strategies β€” Consensus, Sequential, Specialist, Fallback
  • πŸ”Œ MCP server included β€” Exposes analyze_task, execute_fusion, get_models
  • 🧩 Skill-based fallback β€” Works even without the MCP server running
  • βš™οΈ Fully configurable β€” Bring your own models via env vars
  • πŸ” Zero secrets in code β€” All credentials via environment variables

πŸ†š Why Fusion? (With vs Without)

Scenario 😩 Without Fusion πŸš€ With Fusion
Architecture decision One model's opinion, no cross-check 3 models reach consensus, disagreements surfaced
Multi-step feature build Manual handoffs, lost context Automatic pipeline: design β†’ code β†’ review
Debugging a tricky bug Stuck with one model's blind spots Coding specialists attack from multiple angles
Production-critical code Hope the single model gets it right Fallback chain guarantees a result
Cost optimization Always uses the most expensive model Right-sized model per subtask
Creative brainstorming Single creative voice Diverse models, richer ideas
Research / analysis One source of reasoning Multi-perspective synthesis

The bottom line: Fusion trades a little latency for a lot more reliability, breadth, and quality.


🌈 The Four Fusion Modes

Fusion picks one of four strategies automatically. You can also force a mode if you prefer.

🀝 1. Consensus Mode

β€œMany minds are better than one.”

  • Trigger words: compare, evaluate, trade-offs, pros/cons, should we, perspectives
  • Models: Analysis specialists (o1, o3, Claude-3-Opus, GPT-4)
  • How: Queries 2–3 models in parallel, then synthesizes agreement and surfaces disagreements.

πŸ”— 2. Sequential Mode

β€œThink it, build it, review it.”

  • Trigger words: build, implement, create, then, step, first, next
  • Models: Pipelined β€” reasoning β†’ coding β†’ review
  • How: Each model refines the previous one's output (e.g., design β†’ implement β†’ critique).

🎯 3. Specialist Mode

β€œRight tool for the job.”

  • Coding triggers: code, function, script, debug, bug, python, react, api
  • Analysis triggers: analyze, research, explain, architecture, strategy
  • Creative triggers: creative, brainstorm, write, design, idea, tagline
  • How: Routes to the domain-optimized model pool.

πŸ›‘οΈ 4. Fallback Mode

β€œNever let the user down.”

  • Trigger: Reliability-critical tasks, or when no other pattern matches
  • How: Tries the primary model; on failure/timeout, automatically moves to backups.

🎬 Visual Walkthrough

Flow Diagram

                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚   User gives a task   β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β–Ό
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚  Fusion Skill loads   β”‚
                        β”‚  & analyzes the task  β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β–Ό              β–Ό              β–Ό            β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚ Consensusβ”‚  β”‚Sequentialβ”‚  β”‚Specialistβ”‚  β”‚ Fallback β”‚
        β”‚   Mode   β”‚  β”‚   Mode   β”‚  β”‚   Mode   β”‚  β”‚   Mode   β”‚
        β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜
             β”‚              β”‚              β”‚             β”‚
             β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β–Ό
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚  Synthesize outputs   β”‚
                        β”‚  into one final answerβ”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                   β–Ό
                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                        β”‚  Optimized response   β”‚
                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Example: Consensus Mode in Action

User: "What are the trade-offs of microservices vs monolith for a startup?"

πŸ” Fusion analysis:
   β†’ Detected: "trade-offs"  β†’  Mode: CONSENSUS  β†’  Confidence: 0.8
   β†’ Models engaged: o1, Claude-3-Opus, GPT-4

β”Œβ”€ o1 ────────────────────────────────────────────────┐
β”‚ Start with a modular monolith. Microservices add    β”‚
β”‚ operational overhead that early startups can't      β”‚
β”‚ afford. Plan for extraction later.                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€ Claude-3-Opus ─────────────────────────────────────┐
β”‚ Microservices solve team-scaling, not technical     β”‚
β”‚ scaling. Under 10 engineers? Monolith wins. Use     β”‚
β”‚ hexagonal architecture for easy future extraction.  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

β”Œβ”€ GPT-4 ─────────────────────────────────────────────┐
β”‚ Monolith: simpler debugging, single deploy artifact,β”‚
β”‚ shared DB transactions, lower infra cost. Clear win β”‚
β”‚ for startups.                                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🀝 Fusion synthesis:
   βœ… Agreement: Start monolith, design for extraction
   πŸ”€ Nuance: Hexagonal architecture as the bridge
   πŸ“‹ Recommendation: Modular monolith β†’ extract at 10+ engineers

Example: Sequential Mode in Action

User: "Build a React todo component and write unit tests"

πŸ” Fusion analysis:
   β†’ Detected: multi-step ("build" + "and" + "tests")
   β†’ Mode: SEQUENTIAL  β†’  Confidence: 0.75

  Step 1 [Claude-3.5-Sonnet]  β†’ drafted TodoList.jsx
                 β”‚
                 β–Ό
  Step 2 [GPT-4]              β†’ reviewed: added useCallback,
                                memoization, accessibility
                 β”‚
                 β–Ό
  Step 3 [DeepSeek-Coder]     β†’ optimized, added Jest tests,
                                fixed edge cases

πŸ“¦ Final deliverable: production-ready component + tests

⚑ Quick Start

Prerequisites

  • ZCode installed
  • Node.js 18+ (for the MCP server)

Install the Plugin

Option A β€” From this repo (clone & link):

git clone https://github.com/roman-ryzenadvanced/fusion-zcode-plugin.git
cd fusion-zcode-plugin/0.1.0
npm install
npm run build

Then copy the built plugin into your ZCode plugin cache:

# Windows (Git Bash)
cp -r . "/c/Users/$USER/.zcode/cli/plugins/cache/zcode-plugins-official/fusion-plugin/0.1.0/"

# macOS / Linux
cp -r . ~/.zcode/cli/plugins/cache/zcode-plugins-official/fusion-plugin/0.1.0/

Option B β€” Plugin registry (once published):

zcode plugin install fusion-plugin

Enable in ZCode

Add this line to ~/.zcode/cli/config.json under plugins.enabledPlugins:

"fusion-plugin@zcode-plugins-official": true

Restart ZCode. You should now see the fusion skill available. πŸŽ‰

Verify It Works

Ask ZCode something that triggers fusion:

"What are the trade-offs between PostgreSQL and MongoDB for a SaaS app?"

Fusion should kick in and tell you which mode it selected.


βš™οΈ Configuration

Fusion ships with sensible defaults. To customize, set these environment variables (or ZCode user-config values):

Variable Default Purpose
FUSION_MODEL_CODING deepseek-coder,gpt-4,claude-3-5-sonnet Models for coding tasks
FUSION_MODEL_ANALYSIS o1,o3,claude-3-opus,gpt-4 Models for reasoning/analysis
FUSION_MODEL_CREATIVE gpt-4,claude-3-5-sonnet,command-r Models for creative tasks
FUSION_MODEL_VISION gpt-4-vision,claude-3-opus-vision Models for vision tasks
FUSION_API_KEY (empty) API key for your model provider
FUSION_API_BASE https://api.openrouter.ai/api/v1 API base URL

Example shell profile:

export FUSION_API_KEY="your-openrouter-key"
export FUSION_MODEL_CODING="deepseek-coder,gpt-4o,claude-3-5-sonnet"

πŸ§ͺ Usage Examples

Consensus β€” Strategic Decisions

User: "Should we adopt GraphQL over REST for our new product?"
β†’ Fusion queries 3 analysis models, synthesizes a balanced recommendation.

Sequential β€” Feature Builds

User: "Design and implement a rate limiter in Node.js, then review it."
β†’ Pipeline: design (o1) β†’ implement (Claude-3.5) β†’ review (GPT-4).

Specialist β€” Domain Work

User: "Debug this pandas ValueError: ..."
β†’ Routes to coding specialists (DeepSeek-Coder, GPT-4).

Fallback β€” Mission Critical

User: "Generate production-grade JWT auth middleware. Must not fail."
β†’ Primary (Claude-3.5) with automatic failover to backups.

πŸ”Œ MCP API Reference

When the Fusion MCP server is active, these tools are available to the agent:

analyze_task

Analyzes a task and returns the recommended fusion mode + models.

Param Type Required Description
task string βœ… The task text
context string ❌ Optional extra context

Returns: { recommendedMode, recommendedModels, confidence }

execute_fusion

Executes a multi-model fusion task.

Param Type Required Description
task string βœ… The task text
mode string ❌ Force a mode (consensus/sequential/specialist/fallback)
models string[] ❌ Override the model list

get_models

Lists all available models grouped by capability.


πŸ—οΈ Architecture

fusion-zcode-plugin/
β”œβ”€β”€ 0.1.0/
β”‚   β”œβ”€β”€ .zcode-plugin/
β”‚   β”‚   └── plugin.json          # ZCode plugin manifest + user config schema
β”‚   β”œβ”€β”€ skills/fusion/
β”‚   β”‚   └── SKILL.md             # The fusion skill (auto-routing rules)
β”‚   β”œβ”€β”€ src/mcp/
β”‚   β”‚   └── server.ts            # MCP server source (analyze/exec/list)
β”‚   β”œβ”€β”€ package.json             # Dependencies & build scripts
β”‚   └── tsconfig.json            # TypeScript config
β”œβ”€β”€ .github/workflows/
β”‚   └── release.yml              # CI: build + typecheck on push/tag
β”œβ”€β”€ examples/
β”‚   └── consensus-demo.md        # Worked example
β”œβ”€β”€ README.md                    # You are here
β”œβ”€β”€ CHANGELOG.md
β”œβ”€β”€ CONTRIBUTING.md
└── LICENSE

Data flow:

  1. User task β†’ ZCode β†’ Fusion skill triggers
  2. Skill (or MCP analyze_task) classifies the task
  3. Appropriate models are engaged per the selected mode
  4. Outputs are synthesized into a single response
  5. ZCode presents the unified answer to the user

πŸ› οΈ How We Built It

Fusion was designed to feel native to ZCode while bringing OpenRouter's multi-model philosophy on-device. Here's the journey:

  1. Studied the ecosystem β€” We explored the existing ZCode plugin cache (android-emulator, skill-creator, convex, etc.) to learn the canonical structure: .zcode-plugin/plugin.json manifest, skills/<name>/SKILL.md, optional MCP server in dist/, and package.json for build tooling.

  2. Designed the routing brain β€” We mapped common task phrasings ("compare", "build", "debug", "trade-offs") to fusion modes. This became the lightweight classifier in server.ts.

  3. Built the MCP server β€” Using @modelcontextprotocol/sdk, we exposed three tools (analyze_task, execute_fusion, get_models) over stdio transport so any MCP-aware agent can use them.

  4. Wrote the skill β€” SKILL.md teaches the agent when to use Fusion and how to fall back to skill-based delegation if the MCP server isn't running.

  5. Kept it secret-free β€” All credentials flow through environment variables. The repo contains zero tokens, zero cookies, zero personal data.

  6. Polished for humans β€” Visual diagrams, comparison tables, worked examples, and a friendly tone so anyone (human or agent) can replicate the setup.


🧬 Replicate This Setup

Anyone β€” human or AI agent β€” can reproduce this plugin from scratch:

Step 1 β€” Scaffold the directory

mkdir -p fusion-plugin/0.1.0/{.zcode-plugin,skills/fusion,src/mcp}
cd fusion-plugin/0.1.0

Step 2 β€” Create the manifest (.zcode-plugin/plugin.json)

Declare the plugin name, MCP server command, env wiring, and a userConfig schema. See 0.1.0/.zcode-plugin/plugin.json for the full file.

Step 3 β€” Write the skill (skills/fusion/SKILL.md)

Frontmatter (name, description) controls when the skill triggers. The body explains the four modes and routing rules. Keep it under 500 lines.

Step 4 β€” Implement the MCP server (src/mcp/server.ts)

Use @modelcontextprotocol/sdk to expose tools over stdio. The classifier reads FUSION_MODEL_* env vars and matches task text against pattern lists.

Step 5 β€” Build & install

npm install
npm run build           # outputs dist/mcp/server.js

Copy the 0.1.0/ folder into your ZCode plugin cache and enable it in config.json.

Step 6 β€” Verify

Restart ZCode and trigger the skill with a consensus-style question.

That's it β€” six steps, fully reproducible. πŸŽ‰


πŸ’‘ Use Cases

  • Startups deciding architecture β€” Get multi-model consensus before betting the company.
  • Teams writing production code β€” Fallback mode guarantees a deliverable.
  • Researchers comparing sources β€” Consensus mode surfaces disagreements.
  • Devs debugging β€” Specialist coding models attack from multiple angles.
  • Content creators β€” Creative specialists brainstorm diverse ideas.
  • AI agent builders β€” Use Fusion's MCP tools inside your own agent pipelines.

❓ FAQ

Does Fusion call the models itself? The MCP server plans and classifies. Actual model invocation depends on your provider setup (FUSION_API_KEY / FUSION_API_BASE). The skill also supports delegation to existing ZCode agents when MCP isn't available.

Do I need an OpenRouter account? No. Any OpenAI-compatible endpoint works β€” just set FUSION_API_BASE.

Is it free? The plugin is MIT-licensed and free. Model provider costs apply per your own API usage.

Can I add my own models? Yes β€” set any of the FUSION_MODEL_* env vars with a comma-separated list.

Will it work without the MCP server? Yes. The skill includes fallback delegation instructions so Fusion still adds value via skill-based routing.


🀝 Contributing

Contributions are welcome! See CONTRIBUTING.md.

  1. Fork β†’ branch β†’ commit β†’ PR
  2. Run npm run typecheck before submitting
  3. Never commit secrets β€” use env vars

πŸ“„ License

MIT Β© 2026


⭐ If Fusion makes your ZCode smarter, give the repo a star! ⭐

Made with ❀️ for the ZCode community

About

Fusion - Hybrid Smart Multi-Model AI Orchestration for ZCode. Auto-shifts between Consensus, Sequential, Specialist and Fallback modes.

Topics

Resources

License

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors