agy-ext-swarm 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 AGY Ext Swarm Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,179 @@
1
- # Temporary Holding Version
1
+ # AGY Ext Swarm — External Multi-CLI Agent Swarm Plugin for Antigravity
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ > **[中文文档](./README.zh-CN.md)** | English
4
+
5
+ An open-source Antigravity (AGY) plugin that lets Antigravity act as the **Coordinator** (architect, task splitter, diff reviewer, and merger) while orchestrating external headless coding CLI workers across **`dsh` (DeepSeek Harness)**, **Claude Code (`claude`)**, **OpenAI Codex (`codex`)**, **Gemini CLI (`gemini`)**, or **any custom CLI command** over a shared message board.
6
+
7
+ ![AGY Ext Swarm Side-Pane Preview](./assets/preview.svg)
8
+
9
+ ## Key Capabilities
10
+
11
+ - **Zero-Setup AI Auto-Delegation (`rules/AGENTS.md`)**: Includes an always-on plugin rule that guides Antigravity to automatically compose and launch CLI squads for multi-module coding, batch tasks, broad research, or cross-review without manual squad setup—while staying out of the way for small single-file edits or when disabled.
12
+ - **Pluggable External CLI Providers & One-Click Presets**: Auto-detects available CLIs across macOS, Linux, and Windows (`PATH`/`PATHEXT`), with one-click templates for popular coding CLIs (**OpenCode**, **Aider**, **Qwen Code**, **Goose**) plus inline `custom_command` or `providers.json`.
13
+ - **Interactive UI Commander & Settings**: Create swarms, launch workers (with `depends_on` DAG dependencies), start Multi-CLI Arenas, apply Team Playbook Templates, configure CLI binaries/models/pricing, and preview/merge worktrees directly from the side-pane UI.
14
+ - **Deterministic DAG Orchestration (`depends_on`)**: Downstream workers queue as `blocked`, ignore premature `@all` / peer wakes, unlock automatically with upstream diffs & board summaries once dependencies succeed, and fail safely without deadlock if upstream breaks.
15
+ - **Zero-Side-Effect Conflict Preview & Safe Merge (`ext_swarm_merge`)**: Uses `git merge-tree --write-tree` to detect conflicts without touching the working tree, then merges cleanly via `squash`, `cherry-pick`, or `merge` with automatic abort-on-error and optional worktree cleanup.
16
+ - **Multi-CLI Arena & Cross-Vendor Auto Review**: Race 2+ CLI backends in parallel isolated worktrees (`ext_swarm_arena`), compare commits/diff/tokens side by side, and trigger another CLI vendor to perform a read-only audit (`ext_swarm_cross_review`).
17
+ - **Reusable Team Templates (`templates.json`)**: Ships with built-in playbooks (`feature-squad`, `bug-hunt`, `doc-and-test`) merged with global/repo `templates.json`.
18
+ - **Shared Message Board, Timeouts & Watchdog**: Append-only `board.jsonl` with `@name`, `@group`, `@all`, `@coordinator`, `max_hops`, hard `turn_timeout_seconds`, and silence `stall_timeout_seconds` watchdog.
19
+ - **Session Resume & In-Place Switch / Retry**: Captures `sessionId` / `thread_id` across follow-up wakes and lets you retry failed workers or switch their `provider` / `model` in place while preserving their existing `git worktree` and branch.
20
+ - **Git Worktree Isolation, Colored Diff Drawer & Auto Verify**: Parallel writers run in isolated `git worktree` branches (`ext-swarm/<swarmId>/<worker>`); optional `allowed_files` whitelists check out-of-scope edits mechanically, `auto_verify: true` deterministically runs `verify_commands` host-side after each turn, and the Workers tab includes a full colored Git Diff drawer.
21
+ - **Unified Token, Cache & Cost Telemetry + Markdown Export**: Tracks **AGY Main Model** and **External CLI Workers** side-by-side (`cacheRead / (input + cacheRead)`), calculates optional estimated costs when model rates are set, and supports exporting full Markdown post-mortem reports (`ext_swarm_export`) or cleaning up historical swarms (`ext_swarm_delete`).
22
+ - **Bilingual Side-Pane MCP App (`中 / EN`)**: Interactive Board, curved Bezier Graph & Replay scrubber (with DAG edges), Workers Commander + Event/Diff/Merge Drawers, Usage Dashboard, and Settings Center.
23
+
24
+ ## Supported CLI Providers
25
+
26
+ | Provider ID | CLI Command | Session Resume | Streaming Events | Notes |
27
+ | --- | --- | --- | --- | --- |
28
+ | `dsh` | `dsh` (`$DSH_BIN`) | `--session-id` | NDJSON (`--json`) | Supports `--patch` per-worker model overrides via `cordis.patch.yml`. |
29
+ | `claude` | `claude` (`$CLAUDE_BIN`) | `--resume` | `stream-json` | Maps permission presets to `plan` / `acceptEdits` / `--dangerously-skip-permissions`. |
30
+ | `codex` | `codex` (`$CODEX_BIN`) | `exec resume` | JSONL (`--json`) | Runs `codex exec` / `codex exec resume` with `--sandbox`. |
31
+ | `gemini` | `gemini` (`$GEMINI_BIN`) | `--resume` | `stream-json` | Runs `gemini -p --output-format stream-json`. |
32
+ | `custom` / `<id>` | Any executable | Optional `resumeArgs` | `text` or `ndjson` | Inline via `custom_command` or defined in `providers.json`. |
33
+
34
+ ### Auto-Detection & `providers.json`
35
+
36
+ When `default_provider` is omitted in `ext_swarm_create`, AGY Ext Swarm automatically picks:
37
+ 1. `"defaultProvider"` from `<repo_root>/.agy-ext-swarm/providers.json` or `${PLUGIN_DATA}/providers.json`, if set;
38
+ 2. Otherwise the first built-in CLI found on `PATH` (`dsh` -> `claude` -> `codex` -> `gemini`);
39
+ 3. Otherwise the first available custom provider.
40
+
41
+ Example `providers.json`:
42
+
43
+ ```json
44
+ {
45
+ "defaultProvider": "my-agent",
46
+ "providers": {
47
+ "my-agent": {
48
+ "displayName": "My Local Coding CLI",
49
+ "command": "my-agent-cli",
50
+ "args": ["--cwd", "{{cwd}}", "--model", "{{model}}", "-p", "{{prompt}}"],
51
+ "resumeArgs": ["--cwd", "{{cwd}}", "--resume", "{{sessionId}}", "-p", "{{prompt}}"],
52
+ "promptMode": "arg",
53
+ "outputFormat": "text",
54
+ "defaultModel": "default",
55
+ "models": ["default", "fast"]
56
+ }
57
+ }
58
+ }
59
+ ```
60
+
61
+ Supported template variables in `args` / `resumeArgs`:
62
+ `{{prompt}}`, `{{model}}`, `{{cwd}}`, `{{sessionId}}`, `{{permissionMode}}`, `{{workerName}}`, `{{swarmDir}}`, `{{gitCommonDir}}`, `{{boardCli}}`.
63
+
64
+ ## Installation & Build
65
+
66
+ The repository ships **zero-dependency self-contained runtime bundles** (`server/dist/index.mjs` and `server/dist/board.html`, requiring no `node_modules` or `pnpm` at runtime). Choose any of the following installation methods:
67
+
68
+ ### 1. For `agy` CLI Users (Direct Repository Install)
69
+
70
+ ```bash
71
+ agy plugin install https://github.com/ycuwq/agy-ext-swarm
72
+ ```
73
+
74
+ ### 2. For Antigravity Desktop App Users — `npx` One-Command Install (Recommended, Cross-Platform)
75
+
76
+ Requires only `Node.js >= 20` (no `git`, `pnpm`, or `agy` CLI needed). Automatically copies the self-contained plugin into `~/.gemini/config/plugins/agy-ext-swarm` while preserving `.data/` across upgrades:
77
+
78
+ ```bash
79
+ npx -y agy-ext-swarm install
80
+ ```
81
+
82
+ Useful management commands:
83
+ ```bash
84
+ npx -y agy-ext-swarm status # Inspect install path, version, and bundle health
85
+ npx -y agy-ext-swarm install --workspace # Install into ./.agents/plugins for team/repo sharing
86
+ npx -y agy-ext-swarm uninstall # Uninstall the global plugin
87
+ ```
88
+
89
+ ### 3. GitHub Release One-Liners & Offline Archives (No `npm` Required)
90
+
91
+ - **macOS / Linux**:
92
+ ```bash
93
+ curl -fsSL https://raw.githubusercontent.com/ycuwq/agy-ext-swarm/main/scripts/install.sh | bash
94
+ ```
95
+ - **Windows (PowerShell)**:
96
+ ```powershell
97
+ irm https://raw.githubusercontent.com/ycuwq/agy-ext-swarm/main/scripts/install.ps1 | iex
98
+ ```
99
+ - **Manual Offline Install**: Download `agy-ext-swarm.tar.gz` or `agy-ext-swarm.zip` from [GitHub Releases](https://github.com/ycuwq/agy-ext-swarm/releases) and extract the `agy-ext-swarm/` folder into `~/.gemini/config/plugins/` (or `.agents/plugins/`). No `pnpm install` step is needed.
100
+
101
+ ### 4. From Source (Contributors & Local Development)
102
+
103
+ ```bash
104
+ git clone https://github.com/ycuwq/agy-ext-swarm.git
105
+ cd agy-ext-swarm
106
+ node scripts/install.mjs # Symlink/junction from git checkout (--copy for standalone copy, --build to rebuild)
107
+ ```
108
+
109
+ Manual build:
110
+ ```bash
111
+ cd agy-ext-swarm/server
112
+ pnpm install
113
+ pnpm build
114
+ ```
115
+
116
+ Requirements: `Node.js >= 20`, `git` (`>= 2.38` recommended for `git merge-tree --write-tree`), and at least one CLI provider (`dsh`, `claude`, `codex`, `gemini`, or a custom command).
117
+
118
+ ### Notes on `dsh` Profile Isolation
119
+
120
+ If using `dsh`, never modify `~/.dsh/profiles/desktop` (locked by the desktop client). Configure your chosen `headless` (or custom) profile via `dsh` (and ensure any desired model catalog entries are populated in `~/.dsh/profiles/<profile>/cordis.patch.yml` or configured in the **Settings** tab / `providers.json`). Nothing is vendor-hardcoded in `agy-ext-swarm`; when no profile model is detected or configured, `dsh` runs with its own CLI defaults.
121
+
122
+ ## MCP Tools (40 Total: 18 Model + 22 App-Only)
123
+
124
+ ### Model Tools (18)
125
+ - `ext_swarm_providers`: Inspect available built-in & custom CLI providers, binary status, active multi-CLI pool (`activePool`), role routing policy (`routingPolicy`), and resolved `defaultProvider`.
126
+ - `ext_swarm_models`: Query models for a provider (`cordis.patch.yml` `lastCatalog` for `dsh`, or `providers.json` config for others).
127
+ - `ext_swarm_create`: Create a swarm anchored at `repo_root` (supports `default_provider`, multi-select `active_providers` working pool, `routing_policy` with writer/reader pools & `auto_failover`, `coordinator_conversation_id`, `turn_timeout_seconds`, `stall_timeout_seconds`).
128
+ - `ext_swarm_add`: Spawn one worker, a multi-CLI fan-out (`providers: [...]` without `tasks`), or a `tasks` sharded pool rotated across `providers` / Swarm `routing_policy` (with `models_by_provider`, `workspace`, `permission_mode`, `allowed_files`, `verify_commands`, `auto_verify`, `depends_on` DAG, and `arena_group`).
129
+ - `ext_swarm_post`: Post as `coordinator` and wake `@mentioned` workers (excludes `killed` and `blocked` workers).
130
+ - `ext_swarm_read`: Read board messages after `since`.
131
+ - `ext_swarm_status`: Inspect workers, diffs, `outOfScopeFiles`, `lastVerifyResults`, and `coordinatorUsage`.
132
+ - `ext_swarm_wait`: Wait 1–90s for `any_post`, `mentions_coordinator`, `all_idle`, or `worker_done` (with blocked-dependency deadlock safety).
133
+ - `ext_swarm_update_worker`: Switch a waiting/failed worker's `provider` or `model` and/or retry in place keeping its worktree intact.
134
+ - `ext_swarm_merge`: Zero-side-effect `git merge-tree` conflict preview (`action: "preview"`) and safe branch merge (`action: "apply"`, modes `squash` | `cherry-pick` | `merge`).
135
+ - `ext_swarm_arena`: Spawn 2+ CLI providers/models side by side in isolated worktrees on the same task for comparison.
136
+ - `ext_swarm_cross_review`: Auto-select (or specify) a different CLI vendor to run a read-only code review of a worker's diff/output.
137
+ - `ext_swarm_templates`: List built-in and custom team playbook templates (from global & repo `templates.json`).
138
+ - `ext_swarm_apply_template`: Instantiate a DAG team playbook (optionally creating a new swarm) with `{{goal}}` injection.
139
+ - `ext_swarm_kill`: Terminate worker(s) or `all`, optionally removing temporary worktrees.
140
+ - `ext_swarm_delete`: Terminate remaining processes, clean up worktrees/branches, and delete a historical swarm record.
141
+ - `ext_swarm_export`: Generate a Markdown post-mortem report (workers, token/cache stats, optional costs, diffs, and full board transcript).
142
+ - `ext_swarm_open_board`: Open the live side-pane / global MCP App UI.
143
+
144
+ ### App-Only Tools (22)
145
+ - `app_get_snapshot`, `app_post_message`, `app_kill_worker`, `app_get_worker_log`, `app_get_worker_diff`, `app_retry_worker`, `app_bind_conversation`, `app_set_ui_prefs`, `app_get_provider_config`, `app_save_provider_config`, `app_test_provider`, `app_delete_swarm`, `app_export_swarm`, `app_preview_merge`, `app_merge_worker`, `app_create_swarm`, `app_add_worker`, `app_start_arena`, `app_cross_review`, `app_get_templates`, `app_save_template`, `app_apply_template`.
146
+
147
+ ## Contributing & Security
148
+
149
+ - See [CONTRIBUTING.md](./CONTRIBUTING.md) and [SECURITY.md](./SECURITY.md).
150
+
151
+ ## Privacy & Security
152
+
153
+ - Main-model usage telemetry reads local Antigravity `transcript.jsonl` files in **strictly read-only mode** and never mutates Antigravity logs or sends telemetry anywhere externally.
154
+ - External CLI workers run locally on your machine under their configured sandbox flags (`read-only`, `workspace-write`, `danger-full-access`).
155
+
156
+ ## Customizing the Side-Pane UI
157
+
158
+ The UI compiles into a self-contained single-file HTML bundle (`server/dist/board.html`) from:
159
+ - `server/ui/index.html`
160
+ - `server/ui/styles.css` (uses Antigravity host theme tokens)
161
+ - `server/ui/app.ts` & `server/ui/i18n.ts` (`zh` / `en` dictionaries)
162
+
163
+ After editing:
164
+ ```bash
165
+ cd server && pnpm typecheck && pnpm build
166
+ ```
167
+ Then refresh/restart `agy-ext-swarm_ext_swarm` in Antigravity MCP settings (or set `EXT_SWARM_APP_HTML` during UI iteration).
168
+
169
+ ## Tests
170
+
171
+ ```bash
172
+ cd server
173
+ pnpm test:providers # Offline multi-provider, parser, and i18n verification (zero API tokens)
174
+ pnpm test:smoke # Live dsh E2E smoke test
175
+ ```
176
+
177
+ ## License
178
+
179
+ [MIT](./LICENSE)
@@ -0,0 +1,175 @@
1
+ # AGY Ext Swarm — Antigravity 外部多 CLI 协作集群插件
2
+
3
+ > **[English](./README.md)** | 中文文档
4
+
5
+ 一个独立开源的 Antigravity(AGY)插件:由 Antigravity 担任 **Coordinator(架构设计 / 任务拆解 / Diff 审查 / 合入把关)**,在共享消息板上并行调度本机多种外部无头编码 CLI 执行器——内置支持 **`dsh`(DeepSeek Harness)**、**Claude Code(`claude`)**、**OpenAI Codex(`codex`)**、**Gemini CLI(`gemini`)**,并支持通过配置或内联参数接入**任意自定义 CLI 命令**。
6
+
7
+ ![AGY Ext Swarm 侧边栏预览](./assets/preview.svg)
8
+
9
+ ## 核心能力
10
+
11
+ - **免手动配置、AI 主动自动调用(`rules/AGENTS.md`)**:内置插件级常驻规则与自动编队策略,当识别到多模块并行开发、批量分片任务、只读代码调研或交叉审查时,Antigravity 会自动探测可用 CLI 并按预设/工作池直接建群派活;日常小改动或禁用插件时零打扰、自动回退。
12
+ - **可插拔外部 CLI 后端与一键预设模板**:全面兼容 macOS、Linux 与 Windows(支持 `PATHEXT` 与 `.cmd`/`.bat`),内置 **OpenCode**、**Aider**、**Qwen Code**、**Goose** 等常见开源 CLI 一键预设,以及 `custom_command` / `providers.json` 任意拓展。
13
+ - **侧边栏交互式控制台(Commander Bar)与配置中心**:无需手写工具调用或 JSON,直接在执行器页签一键新建 Swarm、启动执行器(含 DAG 前置依赖)、发起多模型 Arena 擂台、套用团队编排模板,以及管理 CLI 后端与单价估算。
14
+ - **确定性 DAG 前置依赖调度(`depends_on`)**:带依赖的执行器初始进入 `blocked` 状态并屏蔽 `@all` 等提前唤醒,上游全部成功后自动注入改动摘要并释放入队;上游失败或被终止时自动级联止损,防止 `wait` 死等。
15
+ - **零副作用冲突预检与安全合入(`ext_swarm_merge`)**:通过 `git merge-tree --write-tree` 零副作用预检分支冲突,支持按 `squash`(默认)、`cherry-pick` 或 `merge` 安全合入,冲突/失败自动回滚并支持可选清理 worktree。
16
+ - **多 CLI Arena 同题竞技与跨厂商自动审查**:使用不同 CLI / 模型在隔离 worktree 并行作答(`ext_swarm_arena`),在侧边栏横向对比提交数、改动文件与 Token,并一键调用另一家模型只读交叉审查(`ext_swarm_cross_review`)。
17
+ - **可复用团队编排模板(`templates.json`)**:内置 `feature-squad`、`bug-hunt`、`doc-and-test` 模板,并与全局及仓库级 `.agy-ext-swarm/templates.json` 合并。
18
+ - **共享消息板、超时与无心跳看门狗**:追加式 `board.jsonl` 协作,内置 `max_hops` 自主跳数熔断、硬超时(`turn_timeout_seconds`)与静默卡死看门狗(`stall_timeout_seconds`)。
19
+ - **会话持久化续跑与原位换模接力**:支持复用 `sessionId` / `thread_id`,并可在保留原 `git worktree` 与分支的情况下对 `waiting` / `failed` 执行器原地换模或重试。
20
+ - **Git Worktree 隔离、彩色 Diff 抽屉与机械验证**:`allowed_files` 白名单守卫每轮自动核查越界改动;支持 `auto_verify: true` 由宿主确定性执行 `verify_commands`;内置彩色 Git Diff 抽屉。
21
+ - **主模型 + 外部集群统一监控与 Markdown 战报导出**:并排统计新增输入、缓存读取与标准输入缓存命中率,支持可选模型单价成本估算,以及一键导出 Markdown 复盘报告与清理历史 Swarm。
22
+
23
+ ## 支持的 CLI 执行器后端
24
+
25
+ | Provider ID | CLI 命令 | 会话续跑 | 流式事件 | 说明 |
26
+ | --- | --- | --- | --- | --- |
27
+ | `dsh` | `dsh`(`$DSH_BIN`) | `--session-id` | NDJSON(`--json`) | 支持读取 `cordis.patch.yml` 并按执行器通过 `--patch` 指定模型。 |
28
+ | `claude` | `claude`(`$CLAUDE_BIN`) | `--resume` | `stream-json` | 自动映射权限预设到 `plan` / `acceptEdits` / `--dangerously-skip-permissions`。 |
29
+ | `codex` | `codex`(`$CODEX_BIN`) | `exec resume` | JSONL(`--json`) | 调用 `codex exec` / `codex exec resume` 并传递 `--sandbox`。 |
30
+ | `gemini` | `gemini`(`$GEMINI_BIN`) | `--resume` | `stream-json` | 调用 `gemini -p --output-format stream-json`。 |
31
+ | `custom` / `<id>` | 任意可执行命令 | 可选 `resumeArgs` | `text` 或 `ndjson` | 可通过 `custom_command` 内联传入或在 `providers.json` 登记。 |
32
+
33
+ ### 自动探测与 `providers.json` 配置
34
+
35
+ 在 `ext_swarm_create` 未显式传 `default_provider` 时,插件按以下优先级自动选择默认后端:
36
+ 1. 若 `<repo_root>/.agy-ext-swarm/providers.json` 或 `${PLUGIN_DATA}/providers.json` 中设置了 `"defaultProvider"`,优先使用;
37
+ 2. 否则按 `dsh` → `claude` → `codex` → `gemini` 顺序选择本机 `PATH` 中第一个可用的内置 CLI;
38
+ 3. 再否则选择第一个可用的自定义 CLI。
39
+
40
+ `providers.json` 配置示例:
41
+
42
+ ```json
43
+ {
44
+ "defaultProvider": "my-agent",
45
+ "providers": {
46
+ "my-agent": {
47
+ "displayName": "我的本地编程 CLI",
48
+ "command": "my-agent-cli",
49
+ "args": ["--cwd", "{{cwd}}", "--model", "{{model}}", "-p", "{{prompt}}"],
50
+ "resumeArgs": ["--cwd", "{{cwd}}", "--resume", "{{sessionId}}", "-p", "{{prompt}}"],
51
+ "promptMode": "arg",
52
+ "outputFormat": "text",
53
+ "defaultModel": "default",
54
+ "models": ["default", "fast"]
55
+ }
56
+ }
57
+ }
58
+ ```
59
+
60
+ `args` 与 `resumeArgs` 支持的模板变量:
61
+ `{{prompt}}`、`{{model}}`、`{{cwd}}`、`{{sessionId}}`、`{{permissionMode}}`、`{{workerName}}`、`{{swarmDir}}`、`{{gitCommonDir}}`、`{{boardCli}}`。
62
+
63
+ ## 安装与构建
64
+
65
+ 仓库已内嵌**零运行时依赖的单文件产物**(`server/dist/index.mjs` 与 `server/dist/board.html`,无需安装 `node_modules` 或 `pnpm`),支持以下四种安装方式:
66
+
67
+ ### 1. 已安装 `agy` CLI 的用户(一行命令直装仓库)
68
+
69
+ ```bash
70
+ agy plugin install https://github.com/ycuwq/agy-ext-swarm
71
+ ```
72
+
73
+ ### 2. 仅使用 Antigravity 桌面 App 的用户 — `npx` 一键安装(推荐,跨平台)
74
+
75
+ 无需 `git`、`pnpm` 或 `agy` CLI,自动将自包含插件文件复制到 `~/.gemini/config/plugins/agy-ext-swarm`(升级时保留 `.data/`):
76
+
77
+ ```bash
78
+ npx -y agy-ext-swarm install
79
+ ```
80
+
81
+ 常用管理命令:
82
+ ```bash
83
+ npx -y agy-ext-swarm status # 查看安装路径、版本与产物健康状态
84
+ npx -y agy-ext-swarm install --workspace # 安装到当前项目的 .agents/plugins/(团队共享)
85
+ npx -y agy-ext-swarm uninstall # 卸载全局插件
86
+ ```
87
+
88
+ ### 3. GitHub Release 一键安装 / 离线压缩包(无需 `npm`)
89
+
90
+ - **macOS / Linux**:
91
+ ```bash
92
+ curl -fsSL https://raw.githubusercontent.com/ycuwq/agy-ext-swarm/main/scripts/install.sh | bash
93
+ ```
94
+ - **Windows (PowerShell)**:
95
+ ```powershell
96
+ irm https://raw.githubusercontent.com/ycuwq/agy-ext-swarm/main/scripts/install.ps1 | iex
97
+ ```
98
+ - **手动离线安装**:从 [GitHub Releases](https://github.com/ycuwq/agy-ext-swarm/releases) 下载 `agy-ext-swarm.tar.gz` 或 `agy-ext-swarm.zip`,解压后将 `agy-ext-swarm/` 目录放入 `~/.gemini/config/plugins/`(或项目 `.agents/plugins/`),无需运行 `pnpm install`。
99
+
100
+ ### 4. 从源码安装与开发构建(贡献者适用)
101
+
102
+ ```bash
103
+ git clone https://github.com/ycuwq/agy-ext-swarm.git
104
+ cd agy-ext-swarm
105
+ node scripts/install.mjs # 源码目录默认建软链/junction(加 --copy 复制独立产物,加 --build 强制重编)
106
+ ```
107
+
108
+ 手动构建:
109
+ ```bash
110
+ cd agy-ext-swarm/server
111
+ pnpm install
112
+ pnpm build
113
+ ```
114
+
115
+ 环境要求:`Node.js >= 20`、`git`(推荐 `>= 2.38` 以支持 `git merge-tree --write-tree`),以及至少一个目标 CLI(`dsh`、`claude`、`codex`、`gemini` 或自定义命令)。
116
+
117
+ ### `dsh` Profile 隔离提醒
118
+
119
+ 若使用 `dsh`,严禁修改 `~/.dsh/profiles/desktop`(由桌面客户端独占锁定),自动化默认运行于 `headless`(或你在网页配置页指定的 profile)。插件内不硬编码任何模型供应商或默认模型名称;若在 `~/.dsh/profiles/<profile>/cordis.patch.yml` 中配置了 `agent-default-model` / `lastCatalog`,插件会自动读取并允许在看板「配置」页一键导入;若未检测到或未配置,则会直接交由 `dsh` 默认行为执行。
120
+
121
+ ## MCP 工具列表(共 40 个:18 模型工具 + 22 UI 专用工具)
122
+
123
+ ### 模型侧工具(18 个)
124
+ - `ext_swarm_providers`:查看内置与自定义的 CLI Provider 列表、本地可用状态、全局多选工作 CLI 池(`activePool`)、角色路由策略(`routingPolicy`)及自动识别出的 `defaultProvider`。
125
+ - `ext_swarm_models`:按 `provider` 查询模型(`dsh` 读取 `cordis.patch.yml` 的 `lastCatalog`,其他后端读取配置列表)。
126
+ - `ext_swarm_create`:创建 Swarm(支持 `default_provider`、多选工作 CLI 池 `active_providers`、读写分工与故障自动降级策略 `routing_policy`、`coordinator_conversation_id`、`turn_timeout_seconds`、`stall_timeout_seconds`)。
127
+ - `ext_swarm_add`:启动单个执行器、多 CLI 并行镜像(传多选 `providers` 且无 `tasks`)或 `tasks` 分片池(自动按 `providers` 或工作池轮询/按读写角色分配后端,并支持 `models_by_provider`、`workspace`、`permission_mode`、`allowed_files`、`verify_commands`、`auto_verify`、`depends_on` DAG 依赖与 `arena_group`)。
128
+ - `ext_swarm_post`:以 `coordinator` 身份发帖唤醒被 `@` 的执行器(不会提前唤醒 `blocked` 或 `killed` 成员)。
129
+ - `ext_swarm_read`:增量读取消息板。
130
+ - `ext_swarm_status`:查看成员状态、Diff、越界文件、`lastVerifyResults` 及主模型用量汇总。
131
+ - `ext_swarm_wait`:在 1–90 秒内等待新消息、`@coordinator`、全部空闲或指定执行器完工(内置依赖死锁保护)。
132
+ - `ext_swarm_update_worker`:为 `waiting`/`failed` 执行器原地更换 `provider`/`model` 或直接重试续跑,保留原 worktree 与分支。
133
+ - `ext_swarm_merge`:使用 `git merge-tree` 执行零副作用冲突预检(`action: "preview"`)或安全合入(`action: "apply"`,支持 `squash` / `cherry-pick` / `merge`)。
134
+ - `ext_swarm_arena`:同题多 CLI/模型在隔离 worktree 中并行开发,生成分组横向擂台。
135
+ - `ext_swarm_cross_review`:自动挑选(或指定)另一厂商 CLI 对目标执行器的改动与消息执行只读交叉审查。
136
+ - `ext_swarm_templates`:查询合并内置、全局与仓库级 `.agy-ext-swarm/templates.json` 的团队编排模板。
137
+ - `ext_swarm_apply_template`:按 DAG 拓扑顺序一键实例化整套团队编排(可选自动建群并注入 `{{goal}}`)。
138
+ - `ext_swarm_kill`:终止执行器或 `all`,可选清理临时 worktree 与分支。
139
+ - `ext_swarm_delete`:终止残留进程、清理 worktree/分支并彻底删除历史 Swarm 记录。
140
+ - `ext_swarm_export`:生成 Markdown 复盘战报(含成员状态、Token/缓存、可选成本估算与完整消息轨迹)。
141
+ - `ext_swarm_open_board`:打开侧边栏 / 全局 MCP App 看板。
142
+
143
+ ### UI 专用工具(22 个)
144
+ - `app_get_snapshot`、`app_post_message`、`app_kill_worker`、`app_get_worker_log`、`app_get_worker_diff`、`app_retry_worker`、`app_bind_conversation`、`app_set_ui_prefs`、`app_get_provider_config`、`app_save_provider_config`、`app_test_provider`、`app_delete_swarm`、`app_export_swarm`、`app_preview_merge`、`app_merge_worker`、`app_create_swarm`、`app_add_worker`、`app_start_arena`、`app_cross_review`、`app_get_templates`、`app_save_template`、`app_apply_template`。
145
+
146
+ ## 贡献与安全
147
+
148
+ - 请参阅 [CONTRIBUTING.md](./CONTRIBUTING.md) 与 [SECURITY.md](./SECURITY.md)。
149
+
150
+ ## 隐私与安全边界
151
+
152
+ - 主模型用量统计仅在本地**只读读取** Antigravity `transcript.jsonl`,不会写入或修改任何宿主日志,也不会向任何外部服务器上报数据。
153
+ - 外部 CLI 执行器完全在本地按设定的权限模式(`read-only`、`workspace-write`、`danger-full-access`)运行。
154
+
155
+ ## 自定义侧边栏 UI
156
+
157
+ UI 源码位于 `server/ui/`(`index.html`、`styles.css`、`app.ts`、`i18n.ts`),修改后执行:
158
+
159
+ ```bash
160
+ cd server && pnpm typecheck && pnpm build
161
+ ```
162
+
163
+ 然后在 Antigravity MCP 设置中刷新 `agy-ext-swarm_ext_swarm`(调试时可设 `EXT_SWARM_APP_HTML` 指向 `server/dist/board.html`)。
164
+
165
+ ## 测试
166
+
167
+ ```bash
168
+ cd server
169
+ pnpm test:providers # 离线验证多 Provider、事件解析器与中英文偏好持久化(零额度消耗)
170
+ pnpm test:smoke # 真实 dsh 端到端冒烟测试
171
+ ```
172
+
173
+ ## 开源协议
174
+
175
+ [MIT](./LICENSE)
@@ -0,0 +1,17 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 128" width="128" height="128" fill="none">
2
+ <!-- Outer subtle badge ring with ~10% margin -->
3
+ <rect x="14" y="14" width="100" height="100" rx="24" fill="#182032" stroke="#3B82F6" stroke-width="4" />
4
+ <!-- Connection links -->
5
+ <path d="M64 36 L40 54 L40 78 L64 94 L88 78 L88 54 Z" stroke="#60A5FA" stroke-width="3.5" stroke-linejoin="round" />
6
+ <path d="M64 36 L64 64 M40 54 L64 64 M88 54 L64 64 M40 78 L64 64 M88 78 L64 64 M64 94 L64 64" stroke="#93C5FD" stroke-width="2.5" stroke-linecap="round" opacity="0.85" />
7
+ <!-- Worker nodes -->
8
+ <circle cx="64" cy="36" r="7" fill="#38BDF8" stroke="#F8FAFC" stroke-width="2.5" />
9
+ <circle cx="40" cy="54" r="6.5" fill="#34D399" stroke="#F8FAFC" stroke-width="2.5" />
10
+ <circle cx="88" cy="54" r="6.5" fill="#34D399" stroke="#F8FAFC" stroke-width="2.5" />
11
+ <circle cx="40" cy="78" r="6.5" fill="#A78BFA" stroke="#F8FAFC" stroke-width="2.5" />
12
+ <circle cx="88" cy="78" r="6.5" fill="#A78BFA" stroke="#F8FAFC" stroke-width="2.5" />
13
+ <circle cx="64" cy="94" r="7" fill="#FBBF24" stroke="#F8FAFC" stroke-width="2.5" />
14
+ <!-- Coordinator hub -->
15
+ <circle cx="64" cy="64" r="10.5" fill="#2563EB" stroke="#FFFFFF" stroke-width="3" />
16
+ <circle cx="64" cy="64" r="3.5" fill="#FFFFFF" />
17
+ </svg>
@@ -0,0 +1,125 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 920 540" width="920" height="540">
2
+ <defs>
3
+ <linearGradient id="bg" x1="0" y1="0" x2="1" y2="1">
4
+ <stop offset="0%" stop-color="#0b0f16" />
5
+ <stop offset="100%" stop-color="#111827" />
6
+ </linearGradient>
7
+ <linearGradient id="accent" x1="0" y1="0" x2="1" y2="0">
8
+ <stop offset="0%" stop-color="#3b82f6" />
9
+ <stop offset="100%" stop-color="#8b5cf6" />
10
+ </linearGradient>
11
+ </defs>
12
+ <rect width="920" height="540" rx="14" fill="url(#bg)" stroke="#243045" stroke-width="1.5" />
13
+
14
+ <!-- Topbar -->
15
+ <rect x="0" y="0" width="920" height="56" rx="14" fill="#131922" />
16
+ <rect x="0" y="42" width="920" height="14" fill="#131922" />
17
+ <line x1="0" y1="56" x2="920" y2="56" stroke="#232d3f" stroke-width="1" />
18
+ <rect x="0" y="55" width="920" height="2" fill="url(#accent)" opacity="0.7" />
19
+ <polygon points="28,16 37,21 37,33 28,38 19,33 19,21" fill="none" stroke="#60a5fa" stroke-width="2" />
20
+ <circle cx="28" cy="27" r="2.8" fill="#60a5fa" />
21
+ <text x="48" y="32" font-family="system-ui,-apple-system,sans-serif" font-size="14" font-weight="700" fill="#f3f4f6">AGY Ext Swarm</text>
22
+ <rect x="172" y="18" width="66" height="20" rx="10" fill="rgba(16,185,129,0.16)" />
23
+ <circle cx="184" cy="28" r="3.5" fill="#10b981" />
24
+ <text x="193" y="32" font-family="system-ui,sans-serif" font-size="11" font-weight="600" fill="#34d399">2 active</text>
25
+ <text x="260" y="32" font-family="ui-monospace,monospace" font-size="11" fill="#9ca3af">Workers 142.8k (hit 68.4%) · Coordinator 24.1k</text>
26
+ <rect x="758" y="16" width="58" height="24" rx="6" fill="#1f2937" stroke="#374151" />
27
+ <text x="774" y="32" font-family="system-ui,sans-serif" font-size="11" fill="#d1d5db">Export</text>
28
+ <rect x="824" y="16" width="72" height="24" rx="6" fill="#2563eb" />
29
+ <text x="836" y="32" font-family="system-ui,sans-serif" font-size="11" font-weight="600" fill="#ffffff">中 / EN</text>
30
+
31
+ <!-- Tabs -->
32
+ <text x="26" y="84" font-family="system-ui,sans-serif" font-size="12" fill="#9ca3af">Board</text>
33
+ <text x="90" y="84" font-family="system-ui,sans-serif" font-size="12" fill="#9ca3af">Graph &amp; Replay</text>
34
+ <text x="206" y="84" font-family="system-ui,sans-serif" font-size="12" font-weight="700" fill="#60a5fa">Workers (3)</text>
35
+ <rect x="204" y="92" width="74" height="2.5" rx="1.2" fill="#3b82f6" />
36
+ <text x="304" y="84" font-family="system-ui,sans-serif" font-size="12" fill="#9ca3af">Usage (68%)</text>
37
+ <text x="404" y="84" font-family="system-ui,sans-serif" font-size="12" fill="#9ca3af">Settings</text>
38
+ <line x1="20" y1="95" x2="900" y2="95" stroke="#1e293b" stroke-width="1" />
39
+
40
+ <!-- Commander Bar -->
41
+ <rect x="24" y="108" width="96" height="26" rx="6" fill="#1e293b" stroke="#334155" />
42
+ <text x="34" y="125" font-family="system-ui,sans-serif" font-size="11" fill="#e2e8f0">+ Create Swarm</text>
43
+ <rect x="128" y="108" width="92" height="26" rx="6" fill="#2563eb" />
44
+ <text x="140" y="125" font-family="system-ui,sans-serif" font-size="11" font-weight="600" fill="#ffffff">+ Add Worker</text>
45
+ <rect x="228" y="108" width="76" height="26" rx="6" fill="#1e293b" stroke="#334155" />
46
+ <text x="240" y="125" font-family="system-ui,sans-serif" font-size="11" fill="#e2e8f0">⚔ Arena</text>
47
+ <rect x="312" y="108" width="92" height="26" rx="6" fill="#1e293b" stroke="#334155" />
48
+ <text x="324" y="125" font-family="system-ui,sans-serif" font-size="11" fill="#e2e8f0">📋 Templates</text>
49
+
50
+ <!-- Left Column: Arena Table + Worker Cards -->
51
+ <rect x="24" y="146" width="536" height="114" rx="10" fill="#131922" stroke="#243045" />
52
+ <text x="38" y="166" font-family="system-ui,sans-serif" font-size="12" font-weight="700" fill="#f3f4f6">⚔ Arena Comparison: arena-auth</text>
53
+ <text x="38" y="188" font-family="system-ui,sans-serif" font-size="10.5" fill="#9ca3af">WORKER</text>
54
+ <text x="148" y="188" font-family="system-ui,sans-serif" font-size="10.5" fill="#9ca3af">CLI</text>
55
+ <text x="234" y="188" font-family="system-ui,sans-serif" font-size="10.5" fill="#9ca3af">STATUS</text>
56
+ <text x="320" y="188" font-family="system-ui,sans-serif" font-size="10.5" fill="#9ca3af">DIFF</text>
57
+ <text x="396" y="188" font-family="system-ui,sans-serif" font-size="10.5" fill="#9ca3af">TOKENS</text>
58
+ <text x="470" y="188" font-family="system-ui,sans-serif" font-size="10.5" fill="#9ca3af">ACTIONS</text>
59
+ <line x1="36" y1="195" x2="548" y2="195" stroke="#1f2937" />
60
+ <text x="38" y="214" font-family="ui-monospace,monospace" font-size="11" fill="#e5e7eb">arena-dsh</text>
61
+ <text x="148" y="214" font-family="ui-monospace,monospace" font-size="11" fill="#93c5fd">dsh</text>
62
+ <text x="234" y="214" font-family="system-ui,sans-serif" font-size="11" fill="#34d399">waiting</text>
63
+ <text x="320" y="214" font-family="ui-monospace,monospace" font-size="11" fill="#d1d5db">2c / 4f</text>
64
+ <text x="396" y="214" font-family="ui-monospace,monospace" font-size="11" fill="#d1d5db">48.2k</text>
65
+ <rect x="468" y="200" width="46" height="18" rx="4" fill="#1e293b" stroke="#334155" />
66
+ <text x="476" y="213" font-family="system-ui,sans-serif" font-size="10" fill="#e2e8f0">Merge</text>
67
+ <text x="38" y="242" font-family="ui-monospace,monospace" font-size="11" fill="#e5e7eb">arena-claude</text>
68
+ <text x="148" y="242" font-family="ui-monospace,monospace" font-size="11" fill="#c4b5fd">claude</text>
69
+ <text x="234" y="242" font-family="system-ui,sans-serif" font-size="11" fill="#34d399">waiting</text>
70
+ <text x="320" y="242" font-family="ui-monospace,monospace" font-size="11" fill="#d1d5db">1c / 3f</text>
71
+ <text x="396" y="242" font-family="ui-monospace,monospace" font-size="11" fill="#d1d5db">51.6k</text>
72
+ <rect x="468" y="228" width="52" height="18" rx="4" fill="#1e293b" stroke="#334155" />
73
+ <text x="476" y="241" font-family="system-ui,sans-serif" font-size="10" fill="#e2e8f0">Review</text>
74
+
75
+ <!-- Worker Card with Merge Preview -->
76
+ <rect x="24" y="272" width="536" height="244" rx="10" fill="#131922" stroke="#243045" />
77
+ <circle cx="42" cy="294" r="4.5" fill="#10b981" />
78
+ <text x="54" y="298" font-family="system-ui,sans-serif" font-size="13" font-weight="700" fill="#f9fafb">impl</text>
79
+ <rect x="92" y="284" width="36" height="18" rx="4" fill="rgba(59,130,246,0.16)" />
80
+ <text x="100" y="297" font-family="ui-monospace,monospace" font-size="10" fill="#60a5fa">dsh</text>
81
+ <rect x="136" y="284" width="66" height="18" rx="9" fill="rgba(16,185,129,0.16)" />
82
+ <text x="148" y="297" font-family="system-ui,sans-serif" font-size="10" fill="#34d399">waiting</text>
83
+ <rect x="210" y="284" width="120" height="18" rx="9" fill="#1f2937" />
84
+ <text x="220" y="297" font-family="ui-monospace,monospace" font-size="10" fill="#9ca3af">ext-swarm/s1/impl</text>
85
+ <rect x="38" y="314" width="508" height="10" rx="5" fill="#1e293b" />
86
+ <rect x="38" y="314" width="348" height="10" rx="5" fill="#10b981" />
87
+ <rect x="386" y="314" width="76" height="10" rx="0" fill="#3b82f6" />
88
+ <text x="38" y="340" font-family="system-ui,sans-serif" font-size="11" fill="#9ca3af">Tokens: 43.0k · Input cache hit: 72.1%</text>
89
+ <rect x="38" y="356" width="508" height="104" rx="6" fill="#1b2330" stroke="#2c3a4f" />
90
+ <text x="50" y="376" font-family="ui-monospace,monospace" font-size="11" font-weight="600" fill="#f3f4f6">Merge Worktree: ext-swarm/s1/impl → main</text>
91
+ <rect x="50" y="386" width="484" height="24" rx="4" fill="rgba(16,185,129,0.14)" />
92
+ <text x="60" y="402" font-family="system-ui,sans-serif" font-size="11" fill="#34d399">Clean merge ready (2 commit(s) ahead, 4 file(s) changed)</text>
93
+ <text x="50" y="432" font-family="system-ui,sans-serif" font-size="11" fill="#d1d5db">Mode: squash (single commit) · ☑ Remove worktree &amp; branch</text>
94
+ <rect x="438" y="422" width="96" height="24" rx="5" fill="#2563eb" />
95
+ <text x="451" y="438" font-family="system-ui,sans-serif" font-size="11" font-weight="600" fill="#ffffff">Confirm Merge</text>
96
+ <rect x="38" y="476" width="84" height="24" rx="5" fill="#1e293b" stroke="#334155" />
97
+ <text x="50" y="492" font-family="system-ui,sans-serif" font-size="11" fill="#e2e8f0">Events</text>
98
+ <rect x="130" y="476" width="72" height="24" rx="5" fill="#1e293b" stroke="#334155" />
99
+ <text x="148" y="492" font-family="system-ui,sans-serif" font-size="11" fill="#e2e8f0">Diff</text>
100
+ <rect x="210" y="476" width="82" height="24" rx="5" fill="#1e293b" stroke="#334155" />
101
+ <text x="228" y="492" font-family="system-ui,sans-serif" font-size="11" fill="#e2e8f0">Review</text>
102
+
103
+ <!-- Right Column: DAG Topology Preview -->
104
+ <rect x="576" y="146" width="320" height="370" rx="10" fill="#131922" stroke="#243045" />
105
+ <text x="594" y="170" font-family="system-ui,sans-serif" font-size="12" font-weight="700" fill="#f3f4f6">DAG Dependencies &amp; Topology</text>
106
+ <line x1="736" y1="226" x2="648" y2="306" stroke="#3b82f6" stroke-width="1.8" />
107
+ <line x1="736" y1="226" x2="824" y2="306" stroke="#3b82f6" stroke-width="1.8" stroke-dasharray="4 3" />
108
+ <line x1="648" y1="336" x2="736" y2="416" stroke="#fbbf24" stroke-width="1.6" stroke-dasharray="3 4" />
109
+ <line x1="824" y1="336" x2="736" y2="416" stroke="#fbbf24" stroke-width="1.6" stroke-dasharray="3 4" />
110
+
111
+ <rect x="676" y="200" width="120" height="32" rx="16" fill="#0b0f16" stroke="#3b82f6" stroke-width="2" />
112
+ <text x="703" y="220" font-family="system-ui,sans-serif" font-size="11.5" font-weight="600" fill="#f3f4f6">coordinator</text>
113
+
114
+ <rect x="594" y="306" width="108" height="32" rx="16" fill="#0b0f16" stroke="#10b981" stroke-width="2" />
115
+ <text x="633" y="326" font-family="system-ui,sans-serif" font-size="11.5" font-weight="600" fill="#f3f4f6">impl</text>
116
+
117
+ <rect x="770" y="306" width="108" height="32" rx="16" fill="#0b0f16" stroke="#fbbf24" stroke-width="2" />
118
+ <text x="789" y="326" font-family="system-ui,sans-serif" font-size="11.5" font-weight="600" fill="#f3f4f6">tester (blocked)</text>
119
+
120
+ <rect x="668" y="416" width="136" height="32" rx="16" fill="#0b0f16" stroke="#fbbf24" stroke-width="2" />
121
+ <text x="688" y="436" font-family="system-ui,sans-serif" font-size="11.5" font-weight="600" fill="#f3f4f6">reviewer (blocked)</text>
122
+
123
+ <text x="594" y="486" font-family="system-ui,sans-serif" font-size="11" fill="#9ca3af">Upstream diffs &amp; board summary auto-injected</text>
124
+ <text x="594" y="502" font-family="system-ui,sans-serif" font-size="11" fill="#9ca3af">when dependencies finish cleanly.</text>
125
+ </svg>