@pdxxxx/braidAlways-on orchestration (fan-out) policy for OpenCode, Grok Build, and Claude Code
0
391
34.8
生态多维模型
26 天前
2026-07-24
快速安装与配置
opencode.json写入当前项目的 opencode.json,只对这个仓库生效。
opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@pdxxxx/braid@0.1.2"]
}写入 ~/.config/opencode/opencode.json,对所有项目生效。
~/.config/opencode/opencode.json
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["@pdxxxx/braid@0.1.2"]
}若你要在本地改造这个插件,先装到项目里再从本地路径引用。
shell
pnpm add -D @pdxxxx/braidopencode 启动时会通过内嵌运行时自动加载 npm 依赖并缓存至本地目录,无需手动在全局环境执行安装。
Coding agents: open
README_FOR_AGENTS.mdand install Braid for the current host in one shot.
Braid
Always-on orchestration for OpenCode, Grok Build, and Claude Code.
Split independent work. Fan out same turn. Weave the results.
Soft policy · zero runtime deps
Why Braid?
Agent hosts can already run multiple subagents. Most sessions still serialize independent work: explore → implement → verify, one after another.
Braid injects a short orchestration policy every turn so the primary agent behaves like an orchestrator:
- Split independent units
- Start them in the same turn (OpenCode/Claude: Task · Grok:
spawn_subagent) - Join, then synthesize
It does not invent a multi-agent runtime. It amplifies each host’s existing tools.
Default mode is full. You do not need /braid full after every new session or compaction — policy re-injects automatically while mode ≠ off. Use /braid only to change mode.
user message
│
▼
primary agent ←── Braid inject
│
├─ subagent A ──┐
├─ subagent B ──┼─ same turn
└─ subagent C ──┘
│
▼
summary → user
Hosts
| Host | Surface | Fan-out tool |
|---|---|---|
| OpenCode | .opencode/plugins/braid.mjs |
Task / @mention |
| Grok Build | grok-plugin/ |
spawn_subagent |
| Claude Code | claude-plugin/ |
Task |
Shared mode state: ~/.config/braid/mode
Legacy OpenCode file still read: ~/.config/opencode/.braid-active
Install
Remote install assumes the GitHub repo is public: pdxxxx/braid.
Agents: use README_FOR_AGENTS.md.
OpenCode (remote)
# After npm publish:
npm install @pdxxxx/braid
# Or install from GitHub (no npm publish required):
npm install github:pdxxxx/braid
{
"plugin": ["@pdxxxx/braid"]
}
OpenCode resolves the package entry (.opencode/plugins/braid.mjs) at startup.
OpenCode (local / this repository)
Plugins under .opencode/plugins/ load automatically in this repo.
Optional pin:
{
"plugin": ["./.opencode/plugins/braid.mjs"]
}
Sample: examples/opencode.json
Grok Build (remote)
# Install only the Grok plugin subtree from the monorepo:
grok plugin install pdxxxx/braid#grok-plugin --trust
# pin optional:
# grok plugin install pdxxxx/braid@v0.1.2#grok-plugin --trust
grok plugin enable braid
Requires Node.js on PATH (hooks run node …mjs).--trust is required for hooks to run.
Grok Build (local)
grok plugin install ./grok-plugin --trust
grok plugin enable braid
grok plugin validate ./grok-plugin
After upgrades, reinstall so new hooks (e.g. SessionStart) are copied.
Claude Code (remote)
Marketplace manifest: .claude-plugin/marketplace.json (plugin source ./claude-plugin).
/plugin marketplace add pdxxxx/braid
/plugin install braid@braid
Desktop app without /plugin: add marketplace from repository URL https://github.com/pdxxxx/braid, then install braid.
Requires Node.js on PATH.
Claude Code (local)
/plugin marketplace add <absolute-or-relative-path-to-this-repo>
/plugin install braid@braid
Or enable the claude-plugin/ folder via the Claude plugin UI.
Modes
| Mode | Behavior |
|---|---|
full (default) |
≥2 independent units → same-turn fan-out required |
lite |
Prefer fan-out; suggestion only |
off |
No inject |
/braid lite
/braid full
/braid off
/braid → full
- Mode is written immediately; injection of the new mode applies on the next turn.
- No re-arm: missing state file =
full; session start / compact / each prompt re-injects while mode ≠off.
State file (one line):
| OS | Path |
|---|---|
| Unix / default | ~/.config/braid/mode |
| Windows | %USERPROFILE%\.config\braid\mode |
| XDG | $XDG_CONFIG_HOME/braid/mode |
| Legacy (read fallback) | ~/.config/opencode/.braid-active |
What gets injected
When mode ≠ off:
- You are the orchestrator — do not solo multi-unit work
- Split units (explore / implement / verify / research, …)
- Start multiple subagents in the same turn; wait; synthesize
- Serialize only when there is a real dependency
- Intensity follows
full/lite
OpenCode hooks
| Hook | Behavior |
|---|---|
experimental.chat.system.transform |
Push policy into system |
command.execute.before |
Persist /braid mode |
experimental.session.compacting |
Re-push policy into compaction context |
tool.execute.before |
Under full, soft-log when task runs — never hard-blocks |
Grok Build hooks
| Event | Behavior |
|---|---|
SessionStart |
Re-inject policy (default full; no slash needed) |
UserPromptSubmit |
Persist /braid; re-inject policy |
PreCompact |
Re-push policy |
PreToolUse (spawn_subagent / Task) |
Soft stderr under full — never denies |
Claude Code hooks
| Event | Behavior |
|---|---|
SessionStart (startup|resume|clear|compact) |
Re-inject policy |
UserPromptSubmit |
Persist /braid; re-inject every turn |
PreToolUse (Task) |
Soft stderr under full — never denies |
Honesty limits
- Soft policy only — weak models may still serialize
- No hard concurrency quota
- Does not spawn agents or replace host Task /
spawn_subagentUI - Inject depends on host honoring hook
additionalContext
Develop
npm test
# → node --test tests/braid.test.mjs
lib/braid-core.mjs # shared core (sync to plugin lib/ copies)
.opencode/plugins/braid.mjs # OpenCode entry
.opencode/command/braid.md
grok-plugin/ # Grok Build plugin root
claude-plugin/ # Claude Code plugin root
examples/opencode.json
tests/braid.test.mjs
When editing core, update lib/braid-core.mjs, grok-plugin/lib/, and claude-plugin/lib/ (tests enforce identical content).
License
MIT © pdxxxx
Weave independent threads. Don’t pull them one by one.