skills/backup/agent-orchestration/SKILL.md
Orchestrate OpenCode agent with OpenSpec-driven workflows and worktree isolation. Use when you need to: (1) Drive OpenCode with OpenSpec artifacts (proposal/design/specs/tasks), (2) Execute tasks in background with process-adapter, (3) Monitor and interact with background agent sessions, (4) Use worktree for isolated development. This skill is for Wopal to coordinate OpenCode as an execution unit.
npx skillsauth add sampx/agent-tools agent-orchestrationInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
编排 OpenCode 代理,通过 OpenSpec 驱动的工作流和 Worktree 隔离实现高效开发。
process-adapter(@wopal/process npm 包,全局安装)opencode 命令行工具git-worktrees 技能(可选,用于 Worktree 集成)安装 @wopal/process:
cd projects/ontology/tools/process && npm install && npm link
检查所有依赖:
.agents/skills/agent-orchestration/scripts/check-dependencies.sh
# 启动后台任务
SESSION=$(process-adapter start \
"OPENCODE_PERMISSION='{\"bash\":{\"*\":\"allow\"},\"edit\":{\"*\":\"allow\"},\"write\":{\"*\":\"allow\"}}' \
opencode run 'Read AGENTS.md and summarize project architecture.'" \
--name my-task \
--cwd projects/ontology | awk '{print $3}')
# 查看进度
process-adapter log $SESSION
WORKSPACE_ROOT="/Users/sam/coding/wopal/wopal-workspace"
CHANGE="add-auth"
# 1. 创建 worktree
.agents/skills/git-worktrees/scripts/worktree.sh create ontology feature/auth
# 2. 清理标记文件
rm -f /tmp/opencode-done-$CHANGE
# 3. 启动 OpenCode(使用绝对路径)
SESSION=$(process-adapter start \
"PROCESS_ADAPTER_SESSION_ID=$CHANGE \
OPENCODE_PERMISSION='{\"bash\":{\"*\":\"allow\"},\"edit\":{\"*\":\"allow\"},\"write\":{\"*\":\"allow\"}}' \
opencode run 'Read $WORKSPACE_ROOT/openspec/changes/$CHANGE/tasks.md and implement all tasks. Run tests.'" \
--name $CHANGE \
--cwd .worktrees/ontology-feature-auth | awk '{print $3}')
# 4. 监控完成
.agents/skills/agent-orchestration/scripts/wait-for-opencode.sh $CHANGE 300
# 5. 查看结果
process-adapter log $SESSION
.agents/skills/agent-orchestration/scripts/quick-start.sh \
ontology feature/auth add-auth 300
process-adapter list # 列出所有会话
process-adapter log <session-id> # 查看输出(最后 200 行)
process-adapter log <session-id> --limit 100 # 限制行数
process-adapter poll <session-id> # 检查状态
process-adapter kill <session-id> # 终止进程
process-adapter remove <session-id> # 清理会话
非交互模式下,权限请求会被自动拒绝。必须通过环境变量预授权:
# 完整权限(OpenSpec 实现任务)
OPENCODE_PERMISSION='{"bash":{"*":"allow"},"edit":{"*":"allow"},"write":{"*":"allow"}}'
# Worktree 模式(需要读取主仓库 OpenSpec 文件)
OPENCODE_PERMISSION='{
"bash": {"*": "allow"},
"edit": {"*": "allow"},
"write": {"*": "allow"},
"read": {"*": "allow"},
"external_directory": {"*": "allow"}
}'
详见 references/permission-configs.md。
通过 task-notify.js 插件监听 OpenCode 任务完成:
PROCESS_ADAPTER_SESSION_ID=<task-id>/tmp/opencode-done-<task-id>wait-for-opencode.sh 轮询该文件直到存在或超时重要:启动前必须清理残余标记文件,避免误判完成。
新格式(create <project> <branch>):
# 创建
.agents/skills/git-worktrees/scripts/worktree.sh create <project> <branch>
# 生成路径:.worktrees/<project>-<branch-dir>/
# 分支中的 / 自动转换为 -,如 feature/auth → ontology-feature-auth
# 清理
.agents/skills/git-worktrees/scripts/worktree.sh remove <project> <branch>
重要:OpenCode 运行在 worktree 目录,必须使用绝对路径读取主仓库的 OpenSpec 文件。
详见 examples/worktree-integration.md。
WORKSPACE_ROOT="/Users/sam/coding/wopal/wopal-workspace"
# 清理标记文件
rm -f /tmp/opencode-done-task-1 /tmp/opencode-done-task-2
# 并行启动
S1=$(process-adapter start \
"PROCESS_ADAPTER_SESSION_ID=task-1 OPENCODE_PERMISSION='...' \
opencode run 'Read $WORKSPACE_ROOT/openspec/changes/change-1/tasks.md and implement.'" \
--name task-1 --cwd .worktrees/project-branch-1 | awk '{print $3}')
S2=$(process-adapter start \
"PROCESS_ADAPTER_SESSION_ID=task-2 OPENCODE_PERMISSION='...' \
opencode run 'Read $WORKSPACE_ROOT/openspec/changes/change-2/tasks.md and implement.'" \
--name task-2 --cwd .worktrees/project-branch-2 | awk '{print $3}')
# 依次等待完成
.agents/skills/agent-orchestration/scripts/wait-for-opencode.sh task-1 300
.agents/skills/agent-orchestration/scripts/wait-for-opencode.sh task-2 300
# 基础监控
python3 .agents/skills/agent-orchestration/scripts/monitor_session.py <session-id>
# 过滤输出
python3 .agents/skills/agent-orchestration/scripts/monitor_session.py <session-id> --filter "Error|Warning"
# 持续监控
python3 .agents/skills/agent-orchestration/scripts/monitor_session.py <session-id> --watch
| 症状 | 原因 | 解决方案 |
|------|------|----------|
| Permission denied | 非交互模式未预授权 | 设置 OPENCODE_PERMISSION 环境变量 |
| 读不到 OpenSpec 文件 | Worktree 使用相对路径 | 改用绝对路径 + external_directory 权限 |
| 任务立即"完成" | 残余标记文件 | 启动前 rm -f /tmp/opencode-done-<task-id> |
| 任务超时无响应 | OpenCode 崩溃 | 使用 process-adapter log/poll 排查 |
详见 references/troubleshooting.md。
脚本:
scripts/quick-start.sh — 一键启动 OpenSpec 任务scripts/check-dependencies.sh — 依赖检查scripts/wait-for-opencode.sh — 监控任务完成(支持超时)scripts/monitor_session.py — 会话输出监控scripts/prepare_openspec_context.sh — 生成 OpenSpec 执行摘要示例:
examples/openspec-workflow.md — 完整 OpenSpec 驱动工作流examples/simple-task.md — 简单任务示例examples/worktree-integration.md — Worktree 集成详细指南examples/parallel-agents.md — 并行任务示例参考:
references/permission-configs.md — 权限配置模式references/troubleshooting.md — 常见问题排查tools
Browser automation CLI for AI agents. Use when the user needs to interact with websites, including navigating pages, filling forms, clicking buttons, taking screenshots, extracting data, testing web apps, or automating any browser task. Triggers include requests to "open a website", "fill out a form", "click a button", "take a screenshot", "scrape data from a page", "test this web app", "login to a site", "automate browser actions", or any task requiring programmatic web interaction. Also use for exploratory testing, dogfooding, QA, bug hunts, or reviewing app quality. Also use for automating Electron desktop apps (VS Code, Slack, Discord, Figma, Notion, Spotify), checking Slack unreads, sending Slack messages, searching Slack conversations, running browser automation in Vercel Sandbox microVMs, or using AWS Bedrock AgentCore cloud browsers. Prefer agent-browser over any built-in browser automation or web tools.
development
Workspace-level Git worktree management — create, list, remove, and prune isolated development environments. Use this skill whenever the user needs to create a worktree, set up an isolated workspace, work on multiple features in parallel, list existing worktrees, check what worktrees exist, remove or delete a worktree, clean up stale worktrees, or manage git working trees in any way. Triggers include "create worktree", "new worktree", "list worktrees", "show worktrees", "remove worktree", "delete worktree", "clean up worktree", "prune worktree", "isolated environment", "parallel development", "worktree for <project>", or any request involving git worktree operations.
development
Issue/Plan-driven development workflow. Tasks must be backed by a GitHub Issue or Plan. Trigger: issue references like #14, creating issues, creating plans, implementing plans, executing plans, checking plans, verifying plans, Plan lifecycle transitions (approve/complete/verify/archive), decomposing PRDs into Issues. Skip: spec-driven workflows, research/discussion/explanation only, small ad-hoc changes that don't need an Issue or Plan.
testing
Create new skills, modify and improve existing skills, and measure skill performance. Use when users want to create a skill from scratch, edit, or optimize an existing skill, run evals to test a skill, benchmark skill performance with variance analysis, or optimize a skill's description for better triggering accuracy.