npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

opencode-threadweaver

v0.1.8

Published

ThreadWeaver — Multi-Agent Debate Plugin for OpenCode. Grok 4.20-style parallel analysis, cross-critique, and weighted synthesis.

Readme

opencode-threadweaver

Multi-Agent Debate Plugin for OpenCode. Spawns 4-16 specialized agents that independently analyze, cross-critique, revise, and synthesize a weighted final answer.

Install

# In your OpenCode config directory
npm install opencode-threadweaver

Add to opencode.jsonc:

{
  "plugin": [
    "opencode-threadweaver"
  ]
}

How It Works

User Query
    |
    v
Complexity Router  -->  standard (4 agents) or heavy (4 core + up to 12 specialists)
    |
    v
Round 1: PARALLEL ANALYSIS    -- each agent independently analyzes the query
Round 2: CROSS-CRITIQUE       -- agents critique each other's outputs
Round 3: REVISION             -- agents revise based on critiques
    |
    v
SYNTHESIS: Captain merges all outputs with dynamic weights
    |
    v
Result: synthesis + weights + dissents + round details

Core Agents (Standard Mode)

| ID | Role | Focus | |----|------|-------| | captain | Captain | Task decomposition, mediation, final synthesis | | verifier | Verifier | Fact-checking, evidence validation, data verification | | reasoner | Reasoner | Logical analysis, step-by-step reasoning | | creator | Creator | Blind spot detection, alternative perspectives |

Specialist Agents (Heavy Mode)

Activated via sparse activation when the query touches specific domains:

  • Verifier specialists: security, performance, architecture
  • Reasoner specialists: math, algorithms, systems
  • Creator specialists: naming, simplification, alternatives
  • Captain specialists: priorities, risks, communication

Dynamic Weighting

Each agent's contribution is weighted by:

final_weight = normalize(
    selfConfidence * 0.25 +
    crossAgreement * 0.45 +
    domainRelevance * 0.30
)

Consensus (crossAgreement) carries the highest weight -- conclusions agreed upon by multiple agents are prioritized.

Keyword Triggers

The plugin auto-activates when these keywords appear in a message (outside code blocks):

debate | weave | threadweave | multi-perspective

Japanese keywords:

debate | threadweave | weave

Configuration

Create opencode-threadweaver.jsonc in your OpenCode config directory (~/.config/opencode/):

{
  // Model for all debate agents
  "model": "openai/gpt-4o",

  // Per-role model overrides ("*" = default for unspecified roles)
  "roleModels": {
    "captain": "openai/gpt-4o",
    "*": "anthropic/claude-sonnet-4"
  },

  // Number of debate rounds (1-5)
  "debateRounds": 3,

  // Complexity score threshold for heavy mode (1+)
  "heavyThreshold": 5,

  // Force complexity level: "standard" | "heavy" | null (auto)
  "forceComplexity": null,

  // Minimum domain relevance for specialist activation (0-1)
  "activationThreshold": 0.3,

  // Timeout per round (ms)
  "roundTimeoutMs": 120000,

  // Total timeout (ms)
  "totalTimeoutMs": 600000,

  // Disable specific hooks
  "disabled_hooks": [],

  // Concurrency control
  "concurrency": {
    "defaultConcurrency": 4,
    "providerConcurrency": {},
    "modelConcurrency": {}
  }
}

Project-level config can be placed at .opencode/opencode-threadweaver.jsonc (overrides user-level).

Profiles

Define multiple configurations and switch between them via activeProfile or the THREADWEAVER_PROFILE environment variable:

{
  "activeProfile": "cloud",
  "profiles": {
    "cloud": {
      "forceComplexity": "standard",
      "roleModels": { "captain": "openai/gpt-4o", "*": "anthropic/claude-sonnet-4" },
      "debateRounds": 1
    },
    "cloud-heavy": {
      "forceComplexity": "heavy",
      "roleModels": { "captain": "openai/gpt-4o", "*": "anthropic/claude-sonnet-4" },
      "debateRounds": 3
    },
    "local": {
      "forceComplexity": "standard",
      "roleModels": { "captain": "ollama/llama3:70b", "*": "ollama/mistral:7b" },
      "debateRounds": 1
    },
    "local-heavy": {
      "forceComplexity": "heavy",
      "roleModels": { "captain": "ollama/llama3:70b", "*": "ollama/mistral:7b" },
      "debateRounds": 2
    }
  }
}

Switch profiles at runtime:

# Via environment variable (takes priority)
THREADWEAVER_PROFILE=local opencode exec "debate: best caching strategy"

# Or set activeProfile in config for the default

Profile settings are merged on top of any base config values defined outside profiles.

Direct Tool Usage

threadweaver({ query: "Compare React vs Vue for a large-scale enterprise app" })

With options:

threadweaver({
  query: "Security implications of microservices vs monolith",
  complexity: "heavy",
  rounds: 3,
  json: true
})

CLI (non-interactive)

opencode run --format json "debate: React vs Vue"

Output

The tool returns:

  • synthesis -- the final merged answer
  • weights -- per-agent confidence, agreement, and final weight
  • dissents -- topics where agents did not reach consensus
  • round details -- collapsible per-round outputs

JSON mode (json: true) returns the full structured result for pipeline integration.

Architecture

src/
  index.ts                 -- Plugin entry, keyword detector, hooks
  types.ts                 -- All TypeScript type definitions
  complexity-router.ts     -- standard/heavy routing + sparse activation
  roles.ts                 -- 4 core + 12 specialist role definitions
  protocol.ts              -- Debate loop (runThreadWeaver)
  weighting.ts             -- Dynamic weights, confidence extraction, critique parsing
  prompts.ts               -- Round prompt templates
  threadweaver-tool.ts     -- Tool registration + output formatting
  config.ts                -- Config loading (user + project level) + profile resolution
  shared.ts                -- Utilities (sanitizer, concurrency pool, resilience, TtlMap)

Development

bun install
bun test        # 39 tests
bun run build   # outputs to dist/

Gotchas

  • Do NOT export non-function values from the plugin entry point. OpenCode treats all exports as plugin instances and will try to call them. Only export the plugin function and type-only exports.
  • The plugin is standalone -- no dependency on opencode-ultra.
  • All shared utilities (sanitizer, concurrency pool, etc.) are inlined in shared.ts.

License

See LICENSE.md