展示HN:OpenSwarm – 用于Linear/GitHub的多代理Claude命令行编排器
Show HN: OpenSwarm – Multi‑Agent Claude CLI Orchestrator for Linear/GitHub

原始链接: https://github.com/Intrect-io/OpenSwarm

## OpenSwarm:自主AI代码生成与自动化 OpenSwarm是一个基于Node.js的编排器,利用Claude Code CLI自动化来自Linear issue的代码变更。它作为一个自主代理,管理着Worker(工作者)、Reviewer(审查者)、Tester(测试者)和Documenter(文档编写者)代理的流程,以生成、审查和记录代码。进度报告会发送到Discord,长期记忆则通过LanceDB向量嵌入和知识图谱来维护,用于代码分析。 主要特性包括通过基于cron的系统进行动态任务调度、PR自动改进以及对长期运行进程的监控。用户通过Discord机器人进行交互,提供任务管理、调度和系统监控的命令,以及实时Web仪表盘。 OpenSwarm根据紧急程度对任务进行优先级排序,并智能管理代理的工作流程。它支持英语和韩语,并通过YAML进行配置,并使用Zod模式进行验证。运行它需要Node.js 22+、Claude Code CLI设置、Discord机器人令牌和Linear API密钥。该项目是开源的,并且在GitHub上可用。

## OpenSwarm:自主AI开发团队 OpenSwarm 是一款新的 CLI 工具,旨在利用多个 Claude Code 实例创建一个“AI 开发团队”。由独立开发者 unohee 开发,它直接集成到现有工作流程中,从 Linear 拉取问题并自动化开发流程(Worker、Reviewer、Tester、Documenter)。 主要功能包括通过 LanceDB 和 embeddings 实现长期记忆,代码知识图谱用于影响分析,以及用于监控和控制的 Discord 机器人。目前正驱动着开发者的个人项目,OpenSwarm 甚至可以自动迭代 pull requests。 该项目处于早期阶段,开发者正在寻求关于团队可用性、自主代码代理的潜在故障模式以及针对更大代码库的内存/知识图谱实现改进方面的反馈。 在这里找到仓库并贡献反馈:[https://github.com/Intrect-io/OpenSwarm](https://github.com/Intrect-io/OpenSwarm)
相关文章

原文

Autonomous AI agent orchestrator powered by Claude Code CLI

OpenSwarm orchestrates multiple Claude Code instances as autonomous agents. It picks up Linear issues, runs Worker/Reviewer pair pipelines to produce code changes, reports progress to Discord, and retains long-term memory via LanceDB vector embeddings.

                         ┌──────────────────────────┐
                         │       Linear API          │
                         │   (issues, state, memory) │
                         └─────────────┬────────────┘
                                       │
                 ┌─────────────────────┼─────────────────────┐
                 │                     │                     │
                 v                     v                     v
  ┌──────────────────┐  ┌──────────────────┐  ┌──────────────────┐
  │ AutonomousRunner │  │  DecisionEngine  │  │  TaskScheduler   │
  │ (heartbeat loop) │─>│  (scope guard)   │─>│  (queue + slots) │
  └────────┬─────────┘  └──────────────────┘  └────────┬─────────┘
           │                                            │
           v                                            v
  ┌──────────────────────────────────────────────────────────────┐
  │                      PairPipeline                            │
  │  ┌────────┐   ┌──────────┐   ┌────────┐   ┌─────────────┐  │
  │  │ Worker │──>│ Reviewer │──>│ Tester │──>│ Documenter  │  │
  │  │ (CLI)  │<──│  (CLI)   │   │ (CLI)  │   │   (CLI)     │  │
  │  └────────┘   └──────────┘   └────────┘   └─────────────┘  │
  │       ↕ StuckDetector                                        │
  └──────────────────────────────────────────────────────────────┘
           │                     │                     │
           v                     v                     v
  ┌──────────────┐  ┌──────────────────┐  ┌──────────────────┐
  │  Discord Bot │  │  Memory (LanceDB │  │  Knowledge Graph │
  │  (commands)  │  │  + Xenova E5)    │  │  (code analysis) │
  └──────────────┘  └──────────────────┘  └──────────────────┘
  • Autonomous Pipeline - Cron-driven heartbeat fetches Linear issues, runs Worker/Reviewer pair loops, and updates issue state automatically
  • Worker/Reviewer Pairs - Multi-iteration code generation with automated review, testing, and documentation stages
  • Decision Engine - Scope validation, rate limiting, priority-based task selection, and workflow mapping
  • Cognitive Memory - LanceDB vector store with Xenova/multilingual-e5-base embeddings for long-term recall across sessions
  • Knowledge Graph - Static code analysis, dependency mapping, and impact analysis for smarter task execution
  • Discord Control - Full command interface for monitoring, task dispatch, scheduling, and pair session management
  • Dynamic Scheduling - Cron-based job scheduler with Discord management commands
  • PR Auto-Improvement - Monitors open PRs and iteratively improves them via pair pipeline
  • Long-Running Monitors - Track external processes (training jobs, batch tasks) and report completion
  • Web Dashboard - Real-time status dashboard on port 3847
  • i18n - English and Korean locale support
  • Node.js >= 22
  • Claude Code CLI installed and authenticated (claude -p)
  • Discord Bot token with message content intent
  • Linear API key and team ID
  • GitHub CLI (gh) for CI monitoring (optional)
git clone https://github.com/unohee/OpenSwarm.git
cd OpenSwarm
npm install
cp config.example.yaml config.yaml

Create a .env file with required secrets:

DISCORD_TOKEN=your-discord-bot-token
DISCORD_CHANNEL_ID=your-channel-id
LINEAR_API_KEY=your-linear-api-key
LINEAR_TEAM_ID=your-linear-team-id

config.yaml supports environment variable substitution (${VAR} or ${VAR:-default}) and is validated with Zod schemas.

Key Configuration Sections

Section Description
discord Bot token, channel ID, webhook URL
linear API key, team ID
github Repos list for CI monitoring
agents Agent definitions (name, projectPath, heartbeat interval)
autonomous Schedule, pair mode, role models, decomposition settings
prProcessor PR auto-improvement schedule and limits

Each pipeline stage can be configured independently:

autonomous:
  defaultRoles:
    worker:
      model: claude-haiku-4-5-20251001
      escalateModel: claude-sonnet-4-20250514
      escalateAfterIteration: 3
      timeoutMs: 1800000
    reviewer:
      model: claude-haiku-4-5-20251001
      timeoutMs: 600000
    tester:
      enabled: false
    documenter:
      enabled: false
    auditor:
      enabled: false
# Development
npm run dev

# Production
npm run build
npm start

# Background
nohup npm start > openswarm.log 2>&1 &

# Docker
docker compose up -d
src/
├── index.ts                 # Entry point
├── core/                    # Config, service lifecycle, types, event hub
├── agents/                  # Worker, reviewer, tester, documenter, auditor
│   ├── pairPipeline.ts      # Worker → Reviewer → Tester → Documenter pipeline
│   ├── agentBus.ts          # Inter-agent message bus
│   └── cliStreamParser.ts   # Claude CLI output parser
├── orchestration/           # Decision engine, task parser, scheduler, workflow
├── automation/              # Autonomous runner, cron scheduler, PR processor
│   ├── longRunningMonitor.ts# External process monitoring
│   └── runnerState.ts       # Persistent pipeline state
├── memory/                  # LanceDB + Xenova embeddings cognitive memory
├── knowledge/               # Code knowledge graph (scanner, analyzer, graph)
├── discord/                 # Bot core, command handlers, pair session UI
├── linear/                  # Linear SDK wrapper, project updater
├── github/                  # GitHub CLI wrapper for CI monitoring
├── support/                 # Web dashboard, planner, rollback, git tools
├── locale/                  # i18n (en/ko) with prompt templates
└── __tests__/               # Vitest test suite
Command Description
!dev <repo> "<task>" Run a dev task on a repository
!dev list List known repositories
!tasks List running tasks
!cancel <taskId> Cancel a running task
Command Description
!status Agent and system status
!pause <session> Pause autonomous work
!resume <session> Resume autonomous work
!log <session> [lines] View recent output
Command Description
!issues List Linear issues
!issue <id> View issue details
!limits Agent daily execution limits
Command Description
!auto Execution status
!auto start [cron] [--pair] Start autonomous mode
!auto stop Stop autonomous mode
!auto run Trigger immediate heartbeat
!approve / !reject Approve or reject pending task
Command Description
!pair Pair session status
!pair start [taskId] Start a pair session
!pair run <taskId> [project] Direct pair run
!pair stop [sessionId] Stop a pair session
!pair history [n] View session history
!pair stats View pair statistics
Command Description
!schedule List all schedules
!schedule run <name> Run a schedule immediately
!schedule toggle <name> Enable/disable a schedule
!schedule add <name> <path> <interval> "<prompt>" Add a schedule
!schedule remove <name> Remove a schedule
Command Description
!ci GitHub CI failure status
!codex Recent session records
!memory search "<query>" Search cognitive memory
!help Full command reference
Linear (Todo/In Progress)
  → Fetch assigned issues
  → DecisionEngine filters & prioritizes
  → Resolve project path via projectMapper
  → PairPipeline.run()
    → Worker generates code (Claude CLI)
    → Reviewer evaluates (APPROVE/REVISE/REJECT)
    → Loop up to N iterations
    → Optional: Tester → Documenter stages
  → Update Linear issue state (Done/Blocked)
  → Report to Discord
  → Save to cognitive memory

Hybrid retrieval scoring: 0.55 * similarity + 0.20 * importance + 0.15 * recency + 0.10 * frequency

Memory types: belief, strategy, user_model, system_pattern, constraint

Background cognition: decay, consolidation, contradiction detection, and distillation (noise filtering).

Category Technology
Runtime Node.js 22+ (ESM)
Language TypeScript (strict mode)
Build tsc
Agent Execution Claude Code CLI (claude -p) via child_process.spawn
Task Management Linear SDK (@linear/sdk)
Communication Discord.js 14
Vector DB LanceDB + Apache Arrow
Embeddings Xenova/transformers (multilingual-e5-base, 768D)
Scheduling Croner
Config YAML + Zod validation
Linting oxlint
Testing Vitest
Path Description
~/.openswarm/ State directory (memory, codex, metrics, workflows, etc.)
~/.claude/openswarm-*.json Pipeline history and task state
config.yaml Main configuration
dist/ Compiled output

The Docker setup includes volume mounts for ~/.openswarm/ state persistence and .env for secrets.

MIT

联系我们 contact @ memedata.com