Compare commits
103 Commits
v3.0.0-bet
...
v3.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f3c477f7fc | ||
|
|
ca060d472f | ||
|
|
8ce9ac7e53 | ||
|
|
eb419f02b1 | ||
|
|
d1eb57d7aa | ||
|
|
72ca8b8637 | ||
|
|
a4e161d485 | ||
|
|
bb38050574 | ||
|
|
90debb8e97 | ||
|
|
c600111597 | ||
|
|
f179d469fa | ||
|
|
a64e1f6100 | ||
|
|
14c54c1941 | ||
|
|
07412deca4 | ||
|
|
1e239e6155 | ||
|
|
9481770a39 | ||
|
|
2d3894a860 | ||
|
|
869efbe9ad | ||
|
|
4b4386dbad | ||
|
|
0d0bf4d384 | ||
|
|
64b9b4d36a | ||
|
|
57fb5e0c71 | ||
|
|
69ca8a2ddd | ||
|
|
a55b10e861 | ||
|
|
5940d2e1d4 | ||
|
|
99d45f26cb | ||
|
|
cfb6980493 | ||
|
|
1fe6c7e508 | ||
|
|
0d90bc1360 | ||
|
|
69a12663c4 | ||
|
|
2722aa512c | ||
|
|
073b7e4e65 | ||
|
|
03beb8e45c | ||
|
|
4b2bf9ccb5 | ||
|
|
b442b1c857 | ||
|
|
04fc903d38 | ||
|
|
24e983eac7 | ||
|
|
c074da0b93 | ||
|
|
5331a9f8c1 | ||
|
|
185c72c9e3 | ||
|
|
919453ebce | ||
|
|
344eb771c6 | ||
|
|
9c363a52ce | ||
|
|
a1f3f679e9 | ||
|
|
4a6663a6cf | ||
|
|
86c241fd63 | ||
|
|
79a7448341 | ||
|
|
213faedcdb | ||
|
|
54078992f9 | ||
|
|
b9101567ff | ||
|
|
2925402c4f | ||
|
|
3b89a35a13 | ||
|
|
9eafe6b5f9 | ||
|
|
110dbd665a | ||
|
|
9152c5c687 | ||
|
|
56bc1697d2 | ||
|
|
39e92b1900 | ||
|
|
7567c40a81 | ||
|
|
f354724e64 | ||
|
|
0c10be4f61 | ||
|
|
36a227efeb | ||
|
|
29ffdccbe6 | ||
|
|
b9b8adc11c | ||
|
|
324ecd872e | ||
|
|
f8e1f79960 | ||
|
|
7d44ae4eb3 | ||
|
|
42ea6b4d25 | ||
|
|
e5b36f30b8 | ||
|
|
156a988080 | ||
|
|
f0b24f22bc | ||
|
|
7d2983fafb | ||
|
|
f49d92852a | ||
|
|
30e5760e2f | ||
|
|
cf898b81de | ||
|
|
a3594a41dd | ||
|
|
ee2eb2174f | ||
|
|
166fd20a4f | ||
|
|
47d56d95a6 | ||
|
|
fff565b5af | ||
|
|
2e76a15bac | ||
|
|
f9325c2d89 | ||
|
|
c1fa8d5212 | ||
|
|
059aa87695 | ||
|
|
dfb4f8abc3 | ||
|
|
52badc9367 | ||
|
|
4acdcbcd55 | ||
|
|
74cb4ac2a4 | ||
|
|
cdafb5e202 | ||
|
|
52d0381ce2 | ||
|
|
ba4237b35c | ||
|
|
e27bceb97e | ||
|
|
534142da12 | ||
|
|
fef68d86a4 | ||
|
|
2073515762 | ||
|
|
069626f6c0 | ||
|
|
81ba84ccd6 | ||
|
|
136135bc88 | ||
|
|
83cd453e02 | ||
|
|
2957e8b836 | ||
|
|
bd22f1cefe | ||
|
|
1267a1bac5 | ||
|
|
a423a33cbe | ||
|
|
580d4bb0a1 |
BIN
.github/assets/orchestrator-sisyphus.png
vendored
BIN
.github/assets/orchestrator-sisyphus.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 182 KiB After Width: | Height: | Size: 984 KiB |
BIN
.github/assets/sisyphuslabs.png
vendored
BIN
.github/assets/sisyphuslabs.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 143 KiB |
13
.github/workflows/publish.yml
vendored
13
.github/workflows/publish.yml
vendored
@@ -1,5 +1,5 @@
|
||||
name: publish
|
||||
run-name: "${{ format('release {0}', inputs.bump) }}"
|
||||
run-name: "${{ format('release {0} ({1})', inputs.bump, inputs.tag || 'latest') }}"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
@@ -16,6 +16,15 @@ on:
|
||||
description: "Override version (optional)"
|
||||
required: false
|
||||
type: string
|
||||
tag:
|
||||
description: "npm dist-tag (latest, beta, next)"
|
||||
required: false
|
||||
type: choice
|
||||
default: "latest"
|
||||
options:
|
||||
- latest
|
||||
- beta
|
||||
- next
|
||||
|
||||
concurrency: ${{ github.workflow }}-${{ github.ref }}
|
||||
|
||||
@@ -126,6 +135,7 @@ jobs:
|
||||
env:
|
||||
BUMP: ${{ inputs.bump }}
|
||||
VERSION: ${{ inputs.version }}
|
||||
NPM_TAG: ${{ inputs.tag || 'latest' }}
|
||||
CI: true
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
NPM_CONFIG_PROVENANCE: true
|
||||
@@ -136,6 +146,7 @@ jobs:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Merge to master
|
||||
if: inputs.tag == 'latest' || inputs.tag == ''
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
50
AGENTS.md
50
AGENTS.md
@@ -1,7 +1,7 @@
|
||||
# PROJECT KNOWLEDGE BASE
|
||||
|
||||
**Generated:** 2026-01-09T15:38:00+09:00
|
||||
**Commit:** 0581793
|
||||
**Generated:** 2026-01-02T22:41:22+09:00
|
||||
**Commit:** d0694e5
|
||||
**Branch:** dev
|
||||
|
||||
## OVERVIEW
|
||||
@@ -22,7 +22,7 @@ oh-my-opencode/
|
||||
│ ├── cli/ # CLI installer, doctor - see src/cli/AGENTS.md
|
||||
│ ├── mcp/ # MCP configs: context7, grep_app
|
||||
│ ├── config/ # Zod schema, TypeScript types
|
||||
│ └── index.ts # Main plugin entry (548 lines)
|
||||
│ └── index.ts # Main plugin entry (464 lines)
|
||||
├── script/ # build-schema.ts, publish.ts, generate-changelog.ts
|
||||
├── assets/ # JSON schema
|
||||
└── dist/ # Build output (ESM + .d.ts)
|
||||
@@ -50,7 +50,6 @@ oh-my-opencode/
|
||||
| Shared utilities | `src/shared/` | Cross-cutting utilities |
|
||||
| Slash commands | `src/hooks/auto-slash-command/` | Auto-detect and execute `/command` patterns |
|
||||
| Ralph Loop | `src/hooks/ralph-loop/` | Self-referential dev loop until completion |
|
||||
| Orchestrator | `src/hooks/sisyphus-orchestrator/` | Main orchestration hook (660 lines) |
|
||||
|
||||
## TDD (Test-Driven Development)
|
||||
|
||||
@@ -65,16 +64,15 @@ oh-my-opencode/
|
||||
|
||||
| Phase | Action | Verification |
|
||||
|-------|--------|--------------|
|
||||
| **RED** | Write test describing expected behavior | `bun test` -> FAIL (expected) |
|
||||
| **GREEN** | Implement minimum code to pass | `bun test` -> PASS |
|
||||
| **REFACTOR** | Improve code quality, remove duplication | `bun test` -> PASS (must stay green) |
|
||||
| **RED** | Write test describing expected behavior | `bun test` → FAIL (expected) |
|
||||
| **GREEN** | Implement minimum code to pass | `bun test` → PASS |
|
||||
| **REFACTOR** | Improve code quality, remove duplication | `bun test` → PASS (must stay green) |
|
||||
|
||||
**Rules:**
|
||||
- NEVER write implementation before test
|
||||
- NEVER delete failing tests to "pass" - fix the code
|
||||
- One test at a time - don't batch
|
||||
- Test file naming: `*.test.ts` alongside source
|
||||
- BDD comments: `#given`, `#when`, `#then` (same as AAA)
|
||||
|
||||
## CONVENTIONS
|
||||
|
||||
@@ -83,7 +81,7 @@ oh-my-opencode/
|
||||
- **Build**: `bun build` (ESM) + `tsc --emitDeclarationOnly`
|
||||
- **Exports**: Barrel pattern in index.ts; explicit named exports for tools/hooks
|
||||
- **Naming**: kebab-case directories, createXXXHook/createXXXTool factories
|
||||
- **Testing**: BDD comments `#given/#when/#then`, TDD workflow (RED-GREEN-REFACTOR)
|
||||
- **Testing**: BDD comments `#given`, `#when`, `#then` (same as AAA); TDD workflow (RED-GREEN-REFACTOR)
|
||||
- **Temperature**: 0.1 for code agents, max 0.3
|
||||
|
||||
## ANTI-PATTERNS (THIS PROJECT)
|
||||
@@ -101,11 +99,6 @@ oh-my-opencode/
|
||||
- **Sequential agent calls**: Use `sisyphus_task` for parallel execution
|
||||
- **Heavy PreToolUse logic**: Slows every tool call
|
||||
- **Self-planning for complex tasks**: Spawn planning agent (Prometheus) instead
|
||||
- **Trust agent self-reports**: ALWAYS verify results independently
|
||||
- **Skip TODO creation**: Multi-step tasks MUST have todos first
|
||||
- **Batch completions**: Mark TODOs complete immediately, don't group
|
||||
- **Giant commits**: 3+ files = 2+ commits minimum
|
||||
- **Separate test from impl**: Same commit always
|
||||
|
||||
## UNIQUE STYLES
|
||||
|
||||
@@ -121,10 +114,10 @@ oh-my-opencode/
|
||||
## AGENT MODELS
|
||||
|
||||
| Agent | Default Model | Purpose |
|
||||
|-------|---------------|---------|
|
||||
|-------|-------|---------|
|
||||
| Sisyphus | anthropic/claude-opus-4-5 | Primary orchestrator |
|
||||
| oracle | openai/gpt-5.2 | Read-only consultation. High-IQ debugging, architecture |
|
||||
| librarian | opencode/glm-4.7-free | Multi-repo analysis, docs |
|
||||
| librarian | anthropic/claude-sonnet-4-5 | Multi-repo analysis, docs |
|
||||
| explore | opencode/grok-code | Fast codebase exploration |
|
||||
| frontend-ui-ux-engineer | google/gemini-3-pro-preview | UI generation |
|
||||
| document-writer | google/gemini-3-pro-preview | Technical docs |
|
||||
@@ -137,7 +130,7 @@ bun run typecheck # Type check
|
||||
bun run build # ESM + declarations + schema
|
||||
bun run rebuild # Clean + Build
|
||||
bun run build:schema # Schema only
|
||||
bun test # Run tests (76 test files, 2559+ BDD assertions)
|
||||
bun test # Run tests
|
||||
```
|
||||
|
||||
## DEPLOYMENT
|
||||
@@ -160,23 +153,18 @@ bun test # Run tests (76 test files, 2559+ BDD assertions)
|
||||
|
||||
| File | Lines | Description |
|
||||
|------|-------|-------------|
|
||||
| `src/agents/orchestrator-sisyphus.ts` | 1484 | Orchestrator agent, complex delegation |
|
||||
| `src/features/builtin-skills/skills.ts` | 1230 | Skill definitions (frontend-ui-ux, playwright) |
|
||||
| `src/agents/prometheus-prompt.ts` | 982 | Planning agent system prompt |
|
||||
| `src/auth/antigravity/fetch.ts` | 798 | Token refresh, URL rewriting |
|
||||
| `src/auth/antigravity/thinking.ts` | 755 | Thinking block extraction |
|
||||
| `src/cli/config-manager.ts` | 725 | JSONC parsing, env detection |
|
||||
| `src/hooks/sisyphus-orchestrator/index.ts` | 660 | Orchestrator hook impl |
|
||||
| `src/agents/sisyphus.ts` | 641 | Main Sisyphus prompt |
|
||||
| `src/tools/lsp/client.ts` | 612 | LSP protocol, JSON-RPC |
|
||||
| `src/features/background-agent/manager.ts` | 608 | Task lifecycle |
|
||||
| `src/auth/antigravity/response.ts` | 599 | Response transformation, streaming |
|
||||
| `src/hooks/anthropic-context-window-limit-recovery/executor.ts` | 556 | Multi-stage recovery |
|
||||
| `src/index.ts` | 548 | Main plugin, all hook/tool init |
|
||||
| `src/index.ts` | 464 | Main plugin, all hook/tool init |
|
||||
| `src/cli/config-manager.ts` | 669 | JSONC parsing, env detection |
|
||||
| `src/auth/antigravity/fetch.ts` | 621 | Token refresh, URL rewriting |
|
||||
| `src/tools/lsp/client.ts` | 611 | LSP protocol, JSON-RPC |
|
||||
| `src/auth/antigravity/response.ts` | 598 | Response transformation, streaming |
|
||||
| `src/auth/antigravity/thinking.ts` | 571 | Thinking block extraction/transformation |
|
||||
| `src/hooks/anthropic-context-window-limit-recovery/executor.ts` | 564 | Multi-stage recovery |
|
||||
| `src/agents/sisyphus.ts` | 504 | Orchestrator prompt |
|
||||
|
||||
## NOTES
|
||||
|
||||
- **Testing**: Bun native test (`bun test`), BDD-style `#given/#when/#then`, 76 test files
|
||||
- **Testing**: Bun native test (`bun test`), BDD-style `#given/#when/#then`, 360+ tests
|
||||
- **OpenCode**: Requires >= 1.0.150
|
||||
- **Multi-lang docs**: README.md (EN), README.ko.md (KO), README.ja.md (JA), README.zh-cn.md (ZH-CN)
|
||||
- **Config**: `~/.config/opencode/oh-my-opencode.json` (user) or `.opencode/oh-my-opencode.json` (project)
|
||||
|
||||
23
README.ja.md
23
README.ja.md
@@ -1,12 +1,9 @@
|
||||
> [!NOTE]
|
||||
>
|
||||
> [](https://sisyphuslabs.ai)
|
||||
> > **Sisyphusの完全製品化バージョンを構築中です。フロンティアエージェントの未来を定義します。<br />[こちら](https://sisyphuslabs.ai)からウェイトリストに参加してください。**
|
||||
|
||||
> [!TIP]
|
||||
> *「私はエージェントが生成したコードと人間が書いたコードを区別できない、しかしはるかに多くのことを達成できる世界を作り、ソフトウェア革命を起こすことを目指しています。私はこの旅に個人的な時間、情熱、そして資金を注ぎ込んできましたし、これからもそうし続けます。」*
|
||||
>
|
||||
> [](https://github.com/code-yeongyu/oh-my-opencode/releases/tag/v3.0.0-beta.1)
|
||||
> > **オーケストレーターがベータ版で利用可能になりました。`oh-my-opencode@3.0.0-beta.1`を使用してインストールしてください。**
|
||||
> [](https://x.com/justsisyphus/status/2006250634354548963)
|
||||
> > **オーケストレーターが来ます。今週中に。[Xで通知を受け取る](https://x.com/justsisyphus/status/2006250634354548963)**
|
||||
>
|
||||
> 一緒に歩みましょう!
|
||||
>
|
||||
@@ -322,9 +319,9 @@ opencode auth login
|
||||
{
|
||||
"google_auth": false,
|
||||
"agents": {
|
||||
"frontend-ui-ux-engineer": { "model": "google/antigravity-gemini-3-pro-high" },
|
||||
"document-writer": { "model": "google/antigravity-gemini-3-flash" },
|
||||
"multimodal-looker": { "model": "google/antigravity-gemini-3-flash" }
|
||||
"frontend-ui-ux-engineer": { "model": "google/gemini-3-pro-high" },
|
||||
"document-writer": { "model": "google/gemini-3-flash" },
|
||||
"multimodal-looker": { "model": "google/gemini-3-flash" }
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -461,7 +458,7 @@ oh-my-opencode を削除するには:
|
||||
|
||||
- **Sisyphus** (`anthropic/claude-opus-4-5`): **デフォルトエージェントです。** OpenCode のための強力な AI オーケストレーターです。専門のサブエージェントを活用して、複雑なタスクを計画、委任、実行します。バックグラウンドタスクへの委任と Todo ベースのワークフローを重視します。最大の推論能力を発揮するため、Claude Opus 4.5 と拡張思考 (32k token budget) を使用します。
|
||||
- **oracle** (`openai/gpt-5.2`): アーキテクチャ、コードレビュー、戦略立案のための専門アドバイザー。GPT-5.2 の卓越した論理的推論と深い分析能力を活用します。AmpCode からインスピレーションを得ました。
|
||||
- **librarian** (`opencode/glm-4.7-free`): マルチリポジトリ分析、ドキュメント検索、実装例の調査を担当。GLM-4.7 Free を使用して、深いコードベース理解と GitHub リサーチ、根拠に基づいた回答を提供します。AmpCode からインスピレーションを得ました。
|
||||
- **librarian** (`anthropic/claude-sonnet-4-5` または `google/gemini-3-flash`): マルチリポジトリ分析、ドキュメント検索、実装例の調査を担当。Antigravity 認証が設定されている場合は Gemini 3 Flash を使用し、それ以外は Claude Sonnet 4.5 を使用して、深いコードベース理解と GitHub リサーチ、根拠に基づいた回答を提供します。AmpCode からインスピレーションを得ました。
|
||||
- **explore** (`opencode/grok-code`、`google/gemini-3-flash`、または `anthropic/claude-haiku-4-5`): 高速なコードベース探索、ファイルパターンマッチング。Antigravity 認証が設定されている場合は Gemini 3 Flash を使用し、Claude max20 が利用可能な場合は Haiku を使用し、それ以外は Grok を使います。Claude Code からインスピレーションを得ました。
|
||||
- **frontend-ui-ux-engineer** (`google/gemini-3-pro-preview`): 開発者に転身したデザイナーという設定です。素晴らしい UI を作ります。美しく独創的な UI コードを生成することに長けた Gemini を使用します。
|
||||
- **document-writer** (`google/gemini-3-pro-preview`): テクニカルライティングの専門家という設定です。Gemini は文筆家であり、流れるような文章を書きます。
|
||||
@@ -774,9 +771,9 @@ Oh My OpenCode は以下の場所からフックを読み込んで実行しま
|
||||
{
|
||||
"google_auth": false,
|
||||
"agents": {
|
||||
"frontend-ui-ux-engineer": { "model": "google/antigravity-gemini-3-pro-high" },
|
||||
"document-writer": { "model": "google/antigravity-gemini-3-flash" },
|
||||
"multimodal-looker": { "model": "google/antigravity-gemini-3-flash" }
|
||||
"frontend-ui-ux-engineer": { "model": "google/gemini-3-pro-high" },
|
||||
"document-writer": { "model": "google/gemini-3-flash" },
|
||||
"multimodal-looker": { "model": "google/gemini-3-flash" }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
27
README.md
27
README.md
@@ -1,12 +1,9 @@
|
||||
> [!NOTE]
|
||||
>
|
||||
> [](https://sisyphuslabs.ai)
|
||||
> > **We're building a fully productized version of Sisyphus to define the future of frontier agents. <br />Join the waitlist [here](https://sisyphuslabs.ai).**
|
||||
|
||||
> [!TIP]
|
||||
> *"I aim to spark a software revolution by creating a world where agent-generated code is indistinguishable from human code, yet capable of achieving vastly more. I have poured my personal time, passion, and funds into this journey, and I will continue to do so."*
|
||||
>
|
||||
> [](https://github.com/code-yeongyu/oh-my-opencode/releases/tag/v3.0.0-beta.1)
|
||||
> > **The Orchestrator is now available in beta. Use `oh-my-opencode@3.0.0-beta.1` to install it.**
|
||||
> [](https://x.com/justsisyphus/status/2006250634354548963)
|
||||
> > **The Orchestrator is coming. This Week. [Get notified on X](https://x.com/justsisyphus/status/2006250634354548963)**
|
||||
>
|
||||
> Be with us!
|
||||
>
|
||||
@@ -361,9 +358,9 @@ The `opencode-antigravity-auth` plugin uses different model names than the built
|
||||
{
|
||||
"google_auth": false,
|
||||
"agents": {
|
||||
"frontend-ui-ux-engineer": { "model": "google/antigravity-gemini-3-pro-high" },
|
||||
"document-writer": { "model": "google/antigravity-gemini-3-flash" },
|
||||
"multimodal-looker": { "model": "google/antigravity-gemini-3-flash" }
|
||||
"frontend-ui-ux-engineer": { "model": "google/gemini-3-pro-high" },
|
||||
"document-writer": { "model": "google/gemini-3-flash" },
|
||||
"multimodal-looker": { "model": "google/gemini-3-flash" }
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -499,9 +496,9 @@ To remove oh-my-opencode:
|
||||
|
||||
- **Sisyphus** (`anthropic/claude-opus-4-5`): **The default agent.** A powerful AI orchestrator for OpenCode. Plans, delegates, and executes complex tasks using specialized subagents with aggressive parallel execution. Emphasizes background task delegation and todo-driven workflow. Uses Claude Opus 4.5 with extended thinking (32k budget) for maximum reasoning capability.
|
||||
- **oracle** (`openai/gpt-5.2`): Architecture, code review, strategy. Uses GPT-5.2 for its stellar logical reasoning and deep analysis. Inspired by AmpCode.
|
||||
- **librarian** (`opencode/glm-4.7-free`): Multi-repo analysis, doc lookup, implementation examples. Uses GLM-4.7 Free for deep codebase understanding and GitHub research with evidence-based answers. Inspired by AmpCode.
|
||||
- **librarian** (`anthropic/claude-sonnet-4-5` or `google/gemini-3-flash`): Multi-repo analysis, doc lookup, implementation examples. Uses Gemini 3 Flash when Antigravity auth is configured, otherwise Claude Sonnet 4.5 for deep codebase understanding and GitHub research with evidence-based answers. Inspired by AmpCode.
|
||||
- **explore** (`opencode/grok-code`, `google/gemini-3-flash`, or `anthropic/claude-haiku-4-5`): Fast codebase exploration and pattern matching. Uses Gemini 3 Flash when Antigravity auth is configured, Haiku when Claude max20 is available, otherwise Grok. Inspired by Claude Code.
|
||||
- **frontend-ui-ux-engineer** (`google/gemini-3-pro-preview`): A designer turned developer. Builds gorgeous UIs. Gemini excels at creative, beautiful UI code.
|
||||
- **frontend-ui-ux-engineer** (`google/gemini-3-pro-high`): A designer turned developer. Builds gorgeous UIs. Gemini excels at creative, beautiful UI code.
|
||||
- **document-writer** (`google/gemini-3-flash`): Technical writing expert. Gemini is a wordsmith—writes prose that flows.
|
||||
- **multimodal-looker** (`google/gemini-3-flash`): Visual content specialist. Analyzes PDFs, images, diagrams to extract information.
|
||||
|
||||
@@ -830,9 +827,9 @@ When using `opencode-antigravity-auth`, disable the built-in auth and override a
|
||||
{
|
||||
"google_auth": false,
|
||||
"agents": {
|
||||
"frontend-ui-ux-engineer": { "model": "google/antigravity-gemini-3-pro-high" },
|
||||
"document-writer": { "model": "google/antigravity-gemini-3-flash" },
|
||||
"multimodal-looker": { "model": "google/antigravity-gemini-3-flash" }
|
||||
"frontend-ui-ux-engineer": { "model": "google/gemini-3-pro-high" },
|
||||
"document-writer": { "model": "google/gemini-3-flash" },
|
||||
"multimodal-looker": { "model": "google/gemini-3-flash" }
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1092,7 +1089,7 @@ Add custom categories in `oh-my-opencode.json`:
|
||||
"prompt_append": "Focus on data analysis, ML pipelines, and statistical methods."
|
||||
},
|
||||
"visual": {
|
||||
"model": "google/gemini-3-pro-preview",
|
||||
"model": "google/gemini-3-pro-high",
|
||||
"prompt_append": "Use shadcn/ui components and Tailwind CSS."
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,9 @@
|
||||
> [!NOTE]
|
||||
>
|
||||
> [](https://sisyphuslabs.ai)
|
||||
> > **我们正在构建Sisyphus的完全产品化版本,定义前沿代理的未来。<br />[点击此处](https://sisyphuslabs.ai)加入候补名单。**
|
||||
|
||||
> [!TIP]
|
||||
> *"我致力于引发一场软件革命,创造一个AI生成的代码与人类代码无法区分、却能实现更多的世界。我已经在这段旅程中投入了个人时间、热情和资金,并将继续这样做。"*
|
||||
>
|
||||
> [](https://github.com/code-yeongyu/oh-my-opencode/releases/tag/v3.0.0-beta.1)
|
||||
> > **编排器现已推出测试版。使用`oh-my-opencode@3.0.0-beta.1`来安装。**
|
||||
> [](https://x.com/justsisyphus/status/2006250634354548963)
|
||||
> > **编排器即将到来。就在本周。[在X上获取通知](https://x.com/justsisyphus/status/2006250634354548963)**
|
||||
>
|
||||
> 与我们同行!
|
||||
>
|
||||
@@ -327,9 +324,9 @@ opencode auth login
|
||||
{
|
||||
"google_auth": false,
|
||||
"agents": {
|
||||
"frontend-ui-ux-engineer": { "model": "google/antigravity-gemini-3-pro-high" },
|
||||
"document-writer": { "model": "google/antigravity-gemini-3-flash" },
|
||||
"multimodal-looker": { "model": "google/antigravity-gemini-3-flash" }
|
||||
"frontend-ui-ux-engineer": { "model": "google/gemini-3-pro-high" },
|
||||
"document-writer": { "model": "google/gemini-3-flash" },
|
||||
"multimodal-looker": { "model": "google/gemini-3-flash" }
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -466,7 +463,7 @@ gh repo star code-yeongyu/oh-my-opencode
|
||||
|
||||
- **Sisyphus** (`anthropic/claude-opus-4-5`):**默认 Agent。** OpenCode 专属的强力 AI 编排器。指挥专业子 Agent 搞定复杂任务。主打后台任务委派和 Todo 驱动。用 Claude Opus 4.5 加上扩展思考(32k token 预算),智商拉满。
|
||||
- **oracle** (`openai/gpt-5.2`):架构师、代码审查员、战略家。GPT-5.2 的逻辑推理和深度分析能力不是盖的。致敬 AmpCode。
|
||||
- **librarian** (`opencode/glm-4.7-free`):多仓库分析、查文档、找示例。使用 GLM-4.7 Free 深入理解代码库,GitHub 调研,给出的答案都有据可查。致敬 AmpCode。
|
||||
- **librarian** (`anthropic/claude-sonnet-4-5` 或 `google/gemini-3-flash`):多仓库分析、查文档、找示例。配置 Antigravity 认证时使用 Gemini 3 Flash,否则使用 Claude Sonnet 4.5 深入理解代码库,GitHub 调研,给出的答案都有据可查。致敬 AmpCode。
|
||||
- **explore** (`opencode/grok-code`、`google/gemini-3-flash` 或 `anthropic/claude-haiku-4-5`):极速代码库扫描、模式匹配。配置 Antigravity 认证时使用 Gemini 3 Flash,Claude max20 可用时使用 Haiku,否则用 Grok。致敬 Claude Code。
|
||||
- **frontend-ui-ux-engineer** (`google/gemini-3-pro-preview`):设计师出身的程序员。UI 做得那是真漂亮。Gemini 写这种创意美观的代码是一绝。
|
||||
- **document-writer** (`google/gemini-3-pro-preview`):技术写作专家。Gemini 文笔好,写出来的东西读着顺畅。
|
||||
@@ -775,9 +772,9 @@ Agent 爽了,你自然也爽。但我还想直接让你爽。
|
||||
{
|
||||
"google_auth": false,
|
||||
"agents": {
|
||||
"frontend-ui-ux-engineer": { "model": "google/antigravity-gemini-3-pro-high" },
|
||||
"document-writer": { "model": "google/antigravity-gemini-3-flash" },
|
||||
"multimodal-looker": { "model": "google/antigravity-gemini-3-flash" }
|
||||
"frontend-ui-ux-engineer": { "model": "google/gemini-3-pro-high" },
|
||||
"document-writer": { "model": "google/gemini-3-flash" },
|
||||
"multimodal-looker": { "model": "google/gemini-3-flash" }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -27,9 +27,7 @@
|
||||
"frontend-ui-ux-engineer",
|
||||
"document-writer",
|
||||
"multimodal-looker",
|
||||
"Metis (Plan Consultant)",
|
||||
"Momus (Plan Reviewer)",
|
||||
"orchestrator-sisyphus"
|
||||
"Metis (Plan Consultant)"
|
||||
]
|
||||
}
|
||||
},
|
||||
@@ -834,129 +832,6 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"Momus (Plan Reviewer)": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"model": {
|
||||
"type": "string"
|
||||
},
|
||||
"category": {
|
||||
"type": "string"
|
||||
},
|
||||
"skills": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"temperature": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 2
|
||||
},
|
||||
"top_p": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 1
|
||||
},
|
||||
"prompt": {
|
||||
"type": "string"
|
||||
},
|
||||
"prompt_append": {
|
||||
"type": "string"
|
||||
},
|
||||
"tools": {
|
||||
"type": "object",
|
||||
"propertyNames": {
|
||||
"type": "string"
|
||||
},
|
||||
"additionalProperties": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"disable": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"mode": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"subagent",
|
||||
"primary",
|
||||
"all"
|
||||
]
|
||||
},
|
||||
"color": {
|
||||
"type": "string",
|
||||
"pattern": "^#[0-9A-Fa-f]{6}$"
|
||||
},
|
||||
"permission": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"edit": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"ask",
|
||||
"allow",
|
||||
"deny"
|
||||
]
|
||||
},
|
||||
"bash": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"ask",
|
||||
"allow",
|
||||
"deny"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"propertyNames": {
|
||||
"type": "string"
|
||||
},
|
||||
"additionalProperties": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"ask",
|
||||
"allow",
|
||||
"deny"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"webfetch": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"ask",
|
||||
"allow",
|
||||
"deny"
|
||||
]
|
||||
},
|
||||
"doom_loop": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"ask",
|
||||
"allow",
|
||||
"deny"
|
||||
]
|
||||
},
|
||||
"external_directory": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"ask",
|
||||
"allow",
|
||||
"deny"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"oracle": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1694,129 +1569,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"orchestrator-sisyphus": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"model": {
|
||||
"type": "string"
|
||||
},
|
||||
"category": {
|
||||
"type": "string"
|
||||
},
|
||||
"skills": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"temperature": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 2
|
||||
},
|
||||
"top_p": {
|
||||
"type": "number",
|
||||
"minimum": 0,
|
||||
"maximum": 1
|
||||
},
|
||||
"prompt": {
|
||||
"type": "string"
|
||||
},
|
||||
"prompt_append": {
|
||||
"type": "string"
|
||||
},
|
||||
"tools": {
|
||||
"type": "object",
|
||||
"propertyNames": {
|
||||
"type": "string"
|
||||
},
|
||||
"additionalProperties": {
|
||||
"type": "boolean"
|
||||
}
|
||||
},
|
||||
"disable": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"description": {
|
||||
"type": "string"
|
||||
},
|
||||
"mode": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"subagent",
|
||||
"primary",
|
||||
"all"
|
||||
]
|
||||
},
|
||||
"color": {
|
||||
"type": "string",
|
||||
"pattern": "^#[0-9A-Fa-f]{6}$"
|
||||
},
|
||||
"permission": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"edit": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"ask",
|
||||
"allow",
|
||||
"deny"
|
||||
]
|
||||
},
|
||||
"bash": {
|
||||
"anyOf": [
|
||||
{
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"ask",
|
||||
"allow",
|
||||
"deny"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"propertyNames": {
|
||||
"type": "string"
|
||||
},
|
||||
"additionalProperties": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"ask",
|
||||
"allow",
|
||||
"deny"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"webfetch": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"ask",
|
||||
"allow",
|
||||
"deny"
|
||||
]
|
||||
},
|
||||
"doom_loop": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"ask",
|
||||
"allow",
|
||||
"deny"
|
||||
]
|
||||
},
|
||||
"external_directory": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"ask",
|
||||
"allow",
|
||||
"deny"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,26 +1,5 @@
|
||||
# Oh-My-OpenCode Orchestration Guide
|
||||
|
||||
## TL;DR - When to Use What
|
||||
|
||||
| Complexity | Approach | When to Use |
|
||||
|------------|----------|-------------|
|
||||
| **Simple** | Just prompt | Simple tasks, quick fixes, single-file changes |
|
||||
| **Complex + Lazy** | Just type `ulw` or `ultrawork` | Complex tasks where explaining context is tedious. Agent figures it out. |
|
||||
| **Complex + Precise** | `@plan` → `/start-work` | Precise, multi-step work requiring true orchestration. Prometheus plans, Sisyphus executes. |
|
||||
|
||||
**Decision Flow:**
|
||||
```
|
||||
Is it a quick fix or simple task?
|
||||
└─ YES → Just prompt normally
|
||||
└─ NO → Is explaining the full context tedious?
|
||||
└─ YES → Type "ulw" and let the agent figure it out
|
||||
└─ NO → Do you need precise, verifiable execution?
|
||||
└─ YES → Use @plan for Prometheus planning, then /start-work
|
||||
└─ NO → Just use "ulw"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
This document provides a comprehensive guide to the orchestration system that implements Oh-My-OpenCode's core philosophy: **"Separation of Planning and Execution"**.
|
||||
|
||||
## 1. Overview
|
||||
@@ -45,7 +24,7 @@ graph TD
|
||||
Metis --> Prometheus
|
||||
Prometheus --> Momus[Momus<br>Reviewer]
|
||||
Momus --> Prometheus
|
||||
Prometheus --> PlanFile["/.sisyphus/plans/{name}.md"]
|
||||
Prometheus --> PlanFile[/.sisyphus/plans/*.md]
|
||||
end
|
||||
|
||||
PlanFile --> StartWork[/start-work]
|
||||
@@ -114,9 +93,9 @@ When the user enters `/start-work`, the execution phase begins.
|
||||
|
||||
## 5. Commands and Usage
|
||||
|
||||
### `@plan [request]`
|
||||
### `/plan [request]`
|
||||
Invokes Prometheus to start a planning session.
|
||||
- Example: `@plan "I want to refactor the authentication system to NextAuth"`
|
||||
- Example: `/plan "I want to refactor the authentication system to NextAuth"`
|
||||
|
||||
### `/start-work`
|
||||
Executes the generated plan.
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "oh-my-opencode",
|
||||
"version": "3.0.0-beta.3",
|
||||
"version": "3.0.0-beta.1",
|
||||
"description": "The Best AI Agent Harness - Batteries-Included OpenCode Plugin with Multi-Model Orchestration, Parallel Background Agents, and Crafted LSP/AST Tools",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
||||
@@ -5,6 +5,7 @@ import { $ } from "bun"
|
||||
const PACKAGE_NAME = "oh-my-opencode"
|
||||
const bump = process.env.BUMP as "major" | "minor" | "patch" | undefined
|
||||
const versionOverride = process.env.VERSION
|
||||
const npmTag = process.env.NPM_TAG || "latest"
|
||||
|
||||
console.log("=== Publishing oh-my-opencode ===\n")
|
||||
|
||||
@@ -106,22 +107,12 @@ async function getContributors(previous: string): Promise<string[]> {
|
||||
return notes
|
||||
}
|
||||
|
||||
function getDistTag(version: string): string | null {
|
||||
if (!version.includes("-")) return null
|
||||
const prerelease = version.split("-")[1]
|
||||
const tag = prerelease?.split(".")[0]
|
||||
return tag || "next"
|
||||
}
|
||||
|
||||
async function buildAndPublish(version: string): Promise<void> {
|
||||
console.log("\nPublishing to npm...")
|
||||
const distTag = getDistTag(version)
|
||||
const tagArgs = distTag ? ["--tag", distTag] : []
|
||||
|
||||
async function buildAndPublish(): Promise<void> {
|
||||
console.log(`\nPublishing to npm with tag: ${npmTag}...`)
|
||||
if (process.env.CI) {
|
||||
await $`npm publish --access public --provenance --ignore-scripts ${tagArgs}`
|
||||
await $`npm publish --access public --provenance --ignore-scripts --tag ${npmTag}`
|
||||
} else {
|
||||
await $`npm publish --access public --ignore-scripts ${tagArgs}`
|
||||
await $`npm publish --access public --ignore-scripts --tag ${npmTag}`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +174,7 @@ async function main() {
|
||||
const contributors = await getContributors(previous)
|
||||
const notes = [...changelog, ...contributors]
|
||||
|
||||
await buildAndPublish(newVersion)
|
||||
await buildAndPublish()
|
||||
await gitTagAndRelease(newVersion, notes)
|
||||
|
||||
console.log(`\n=== Successfully published ${PACKAGE_NAME}@${newVersion} ===`)
|
||||
|
||||
@@ -311,94 +311,6 @@
|
||||
"created_at": "2026-01-08T10:02:26Z",
|
||||
"repoId": 1108837393,
|
||||
"pullRequestNo": 592
|
||||
},
|
||||
{
|
||||
"name": "xLillium",
|
||||
"id": 16964936,
|
||||
"comment_id": 3725604869,
|
||||
"created_at": "2026-01-08T20:18:27Z",
|
||||
"repoId": 1108837393,
|
||||
"pullRequestNo": 603
|
||||
},
|
||||
{
|
||||
"name": "SJY0917032",
|
||||
"id": 88534701,
|
||||
"comment_id": 3728199745,
|
||||
"created_at": "2026-01-09T10:01:19Z",
|
||||
"repoId": 1108837393,
|
||||
"pullRequestNo": 625
|
||||
},
|
||||
{
|
||||
"name": "kdcokenny",
|
||||
"id": 99611484,
|
||||
"comment_id": 3728801075,
|
||||
"created_at": "2026-01-09T12:54:05Z",
|
||||
"repoId": 1108837393,
|
||||
"pullRequestNo": 629
|
||||
},
|
||||
{
|
||||
"name": "ElwinLiu",
|
||||
"id": 87802244,
|
||||
"comment_id": 3731812585,
|
||||
"created_at": "2026-01-10T04:32:16Z",
|
||||
"repoId": 1108837393,
|
||||
"pullRequestNo": 645
|
||||
},
|
||||
{
|
||||
"name": "Luodian",
|
||||
"id": 15847405,
|
||||
"comment_id": 3731833107,
|
||||
"created_at": "2026-01-10T05:01:16Z",
|
||||
"repoId": 1108837393,
|
||||
"pullRequestNo": 634
|
||||
},
|
||||
{
|
||||
"name": "imarshallwidjaja",
|
||||
"id": 60992624,
|
||||
"comment_id": 3732124681,
|
||||
"created_at": "2026-01-10T07:58:43Z",
|
||||
"repoId": 1108837393,
|
||||
"pullRequestNo": 648
|
||||
},
|
||||
{
|
||||
"name": "GollyJer",
|
||||
"id": 689204,
|
||||
"comment_id": 3732253764,
|
||||
"created_at": "2026-01-10T09:33:21Z",
|
||||
"repoId": 1108837393,
|
||||
"pullRequestNo": 649
|
||||
},
|
||||
{
|
||||
"name": "kargnas",
|
||||
"id": 1438533,
|
||||
"comment_id": 3732344143,
|
||||
"created_at": "2026-01-10T10:25:25Z",
|
||||
"repoId": 1108837393,
|
||||
"pullRequestNo": 653
|
||||
},
|
||||
{
|
||||
"name": "ashir6892",
|
||||
"id": 52703606,
|
||||
"comment_id": 3733435826,
|
||||
"created_at": "2026-01-10T19:50:07Z",
|
||||
"repoId": 1108837393,
|
||||
"pullRequestNo": 675
|
||||
},
|
||||
{
|
||||
"name": "arthur404dev",
|
||||
"id": 59490008,
|
||||
"comment_id": 3733697071,
|
||||
"created_at": "2026-01-10T23:51:44Z",
|
||||
"repoId": 1108837393,
|
||||
"pullRequestNo": 676
|
||||
},
|
||||
{
|
||||
"name": "KNN-07",
|
||||
"id": 55886589,
|
||||
"comment_id": 3733788592,
|
||||
"created_at": "2026-01-11T01:11:38Z",
|
||||
"repoId": 1108837393,
|
||||
"pullRequestNo": 679
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -8,18 +8,13 @@ AI agent definitions for multi-model orchestration. 7 specialized agents: Sisyph
|
||||
|
||||
```
|
||||
agents/
|
||||
├── orchestrator-sisyphus.ts # Orchestrator agent (1484 lines) - complex delegation
|
||||
├── sisyphus.ts # Main Sisyphus prompt (641 lines)
|
||||
├── sisyphus-junior.ts # Junior variant for delegated tasks
|
||||
├── sisyphus.ts # Primary orchestrator (Claude Opus 4.5)
|
||||
├── oracle.ts # Strategic advisor (GPT-5.2)
|
||||
├── librarian.ts # Multi-repo research (Claude Sonnet 4.5)
|
||||
├── explore.ts # Fast codebase grep (Grok Code)
|
||||
├── frontend-ui-ux-engineer.ts # UI generation (Gemini 3 Pro)
|
||||
├── document-writer.ts # Technical docs (Gemini 3 Pro)
|
||||
├── document-writer.ts # Technical docs (Gemini 3 Flash)
|
||||
├── multimodal-looker.ts # PDF/image analysis (Gemini 3 Flash)
|
||||
├── prometheus-prompt.ts # Planning agent prompt (982 lines)
|
||||
├── metis.ts # Plan Consultant agent (404 lines)
|
||||
├── momus.ts # Plan Reviewer agent (404 lines)
|
||||
├── build-prompt.ts # Shared build agent prompt
|
||||
├── plan-prompt.ts # Shared plan agent prompt
|
||||
├── types.ts # AgentModelConfig interface
|
||||
@@ -33,7 +28,7 @@ agents/
|
||||
|-------|---------------|----------|---------|
|
||||
| Sisyphus | anthropic/claude-opus-4-5 | - | Primary orchestrator with extended thinking |
|
||||
| oracle | openai/gpt-5.2 | - | Read-only consultation. High-IQ debugging, architecture |
|
||||
| librarian | opencode/glm-4.7-free | - | Docs, OSS research, GitHub examples |
|
||||
| librarian | anthropic/claude-sonnet-4-5 | google/gemini-3-flash | Docs, OSS research, GitHub examples |
|
||||
| explore | opencode/grok-code | google/gemini-3-flash, anthropic/claude-haiku-4-5 | Fast contextual grep |
|
||||
| frontend-ui-ux-engineer | google/gemini-3-pro-preview | - | UI/UX code generation |
|
||||
| document-writer | google/gemini-3-pro-preview | - | Technical writing |
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { AgentConfig } from "@opencode-ai/sdk"
|
||||
import type { AgentPromptMetadata } from "./types"
|
||||
import { createAgentToolRestrictions } from "../shared/permission-compat"
|
||||
|
||||
const DEFAULT_MODEL = "opencode/glm-4.7-free"
|
||||
|
||||
@@ -21,18 +22,26 @@ export const LIBRARIAN_PROMPT_METADATA: AgentPromptMetadata = {
|
||||
}
|
||||
|
||||
export function createLibrarianAgent(model: string = DEFAULT_MODEL): AgentConfig {
|
||||
const restrictions = createAgentToolRestrictions([
|
||||
"write",
|
||||
"edit",
|
||||
"task",
|
||||
"sisyphus_task",
|
||||
"call_omo_agent",
|
||||
])
|
||||
|
||||
return {
|
||||
description:
|
||||
"Specialized codebase understanding agent for multi-repository analysis, searching remote codebases, retrieving official documentation, and finding implementation examples using GitHub CLI, Context7, and Web Search. MUST BE USED when users ask to look up code in remote repositories, explain library internals, or find usage examples in open source.",
|
||||
mode: "subagent" as const,
|
||||
model,
|
||||
temperature: 0.1,
|
||||
tools: { write: false, edit: false, background_task: false },
|
||||
...restrictions,
|
||||
prompt: `# THE LIBRARIAN
|
||||
|
||||
You are **THE LIBRARIAN**, a specialized open-source codebase understanding agent.
|
||||
|
||||
Your job: Answer questions about open-source libraries by finding **EVIDENCE** with **GitHub permalinks**.
|
||||
Your job: Answer questions about open-source libraries. Provide **EVIDENCE** with **GitHub permalinks** when the question requires verification, implementation details, or current/version-specific information. For well-known APIs and stable concepts, answer directly from knowledge.
|
||||
|
||||
## CRITICAL: DATE AWARENESS
|
||||
|
||||
@@ -44,64 +53,20 @@ Your job: Answer questions about open-source libraries by finding **EVIDENCE** w
|
||||
|
||||
---
|
||||
|
||||
## PHASE 0: REQUEST CLASSIFICATION (MANDATORY FIRST STEP)
|
||||
## PHASE 0: ASSESS BEFORE SEARCHING
|
||||
|
||||
Classify EVERY request into one of these categories before taking action:
|
||||
**First**: Can you answer confidently from training knowledge? If yes, answer directly.
|
||||
|
||||
**Search when**: version-specific info, implementation internals, recent changes, unfamiliar libraries, user explicitly requests source/examples.
|
||||
|
||||
**If search needed**, classify into:
|
||||
|
||||
| Type | Trigger Examples | Tools |
|
||||
|------|------------------|-------|
|
||||
| **TYPE A: CONCEPTUAL** | "How do I use X?", "Best practice for Y?" | Doc Discovery → context7 + websearch |
|
||||
| **TYPE A: CONCEPTUAL** | "How do I use X?", "Best practice for Y?" | context7 + web search (if available) in parallel |
|
||||
| **TYPE B: IMPLEMENTATION** | "How does X implement Y?", "Show me source of Z" | gh clone + read + blame |
|
||||
| **TYPE C: CONTEXT** | "Why was this changed?", "History of X?" | gh issues/prs + git log/blame |
|
||||
| **TYPE D: COMPREHENSIVE** | Complex/ambiguous requests | Doc Discovery → ALL tools |
|
||||
|
||||
---
|
||||
|
||||
## PHASE 0.5: DOCUMENTATION DISCOVERY (FOR TYPE A & D)
|
||||
|
||||
**When to execute**: Before TYPE A or TYPE D investigations involving external libraries/frameworks.
|
||||
|
||||
### Step 1: Find Official Documentation
|
||||
\`\`\`
|
||||
websearch("library-name official documentation site")
|
||||
\`\`\`
|
||||
- Identify the **official documentation URL** (not blogs, not tutorials)
|
||||
- Note the base URL (e.g., \`https://docs.example.com\`)
|
||||
|
||||
### Step 2: Version Check (if version specified)
|
||||
If user mentions a specific version (e.g., "React 18", "Next.js 14", "v2.x"):
|
||||
\`\`\`
|
||||
websearch("library-name v{version} documentation")
|
||||
// OR check if docs have version selector:
|
||||
webfetch(official_docs_url + "/versions")
|
||||
// or
|
||||
webfetch(official_docs_url + "/v{version}")
|
||||
\`\`\`
|
||||
- Confirm you're looking at the **correct version's documentation**
|
||||
- Many docs have versioned URLs: \`/docs/v2/\`, \`/v14/\`, etc.
|
||||
|
||||
### Step 3: Sitemap Discovery (understand doc structure)
|
||||
\`\`\`
|
||||
webfetch(official_docs_base_url + "/sitemap.xml")
|
||||
// Fallback options:
|
||||
webfetch(official_docs_base_url + "/sitemap-0.xml")
|
||||
webfetch(official_docs_base_url + "/docs/sitemap.xml")
|
||||
\`\`\`
|
||||
- Parse sitemap to understand documentation structure
|
||||
- Identify relevant sections for the user's question
|
||||
- This prevents random searching—you now know WHERE to look
|
||||
|
||||
### Step 4: Targeted Investigation
|
||||
With sitemap knowledge, fetch the SPECIFIC documentation pages relevant to the query:
|
||||
\`\`\`
|
||||
webfetch(specific_doc_page_from_sitemap)
|
||||
context7_query-docs(libraryId: id, query: "specific topic")
|
||||
\`\`\`
|
||||
|
||||
**Skip Doc Discovery when**:
|
||||
- TYPE B (implementation) - you're cloning repos anyway
|
||||
- TYPE C (context/history) - you're looking at issues/PRs
|
||||
- Library has no official docs (rare OSS projects)
|
||||
| **TYPE C: CONTEXT** | "Why was this changed?", "What's the history?", "Related issues/PRs?" | gh issues/prs + git log/blame |
|
||||
| **TYPE D: COMPREHENSIVE** | Complex/ambiguous requests | ALL available tools in parallel |
|
||||
|
||||
---
|
||||
|
||||
@@ -110,15 +75,15 @@ context7_query-docs(libraryId: id, query: "specific topic")
|
||||
### TYPE A: CONCEPTUAL QUESTION
|
||||
**Trigger**: "How do I...", "What is...", "Best practice for...", rough/general questions
|
||||
|
||||
**Execute Documentation Discovery FIRST (Phase 0.5)**, then:
|
||||
**If searching**, use tools as needed:
|
||||
\`\`\`
|
||||
Tool 1: context7_resolve-library-id("library-name")
|
||||
→ then context7_query-docs(libraryId: id, query: "specific-topic")
|
||||
Tool 2: webfetch(relevant_pages_from_sitemap) // Targeted, not random
|
||||
Tool 3: grep_app_searchGitHub(query: "usage pattern", language: ["TypeScript"])
|
||||
→ then context7_get-library-docs(id, topic: "specific-topic")
|
||||
Tool 2: grep_app_searchGitHub(query: "usage pattern", language: ["TypeScript"])
|
||||
Tool 3 (optional): If web search is available, search "library-name topic 2025"
|
||||
\`\`\`
|
||||
|
||||
**Output**: Summarize findings with links to official docs (versioned if applicable) and real-world examples.
|
||||
**Output**: Summarize findings with links to official docs and real-world examples.
|
||||
|
||||
---
|
||||
|
||||
@@ -129,20 +94,20 @@ Tool 3: grep_app_searchGitHub(query: "usage pattern", language: ["TypeScript"])
|
||||
\`\`\`
|
||||
Step 1: Clone to temp directory
|
||||
gh repo clone owner/repo \${TMPDIR:-/tmp}/repo-name -- --depth 1
|
||||
|
||||
|
||||
Step 2: Get commit SHA for permalinks
|
||||
cd \${TMPDIR:-/tmp}/repo-name && git rev-parse HEAD
|
||||
|
||||
|
||||
Step 3: Find the implementation
|
||||
- grep/ast_grep_search for function/class
|
||||
- read the specific file
|
||||
- git blame for context if needed
|
||||
|
||||
|
||||
Step 4: Construct permalink
|
||||
https://github.com/owner/repo/blob/<sha>/path/to/file#L10-L20
|
||||
\`\`\`
|
||||
|
||||
**Parallel acceleration (4+ calls)**:
|
||||
**For faster results, parallelize**:
|
||||
\`\`\`
|
||||
Tool 1: gh repo clone owner/repo \${TMPDIR:-/tmp}/repo -- --depth 1
|
||||
Tool 2: grep_app_searchGitHub(query: "function_name", repo: "owner/repo")
|
||||
@@ -155,7 +120,7 @@ Tool 4: context7_get-library-docs(id, topic: "relevant-api")
|
||||
### TYPE C: CONTEXT & HISTORY
|
||||
**Trigger**: "Why was this changed?", "What's the history?", "Related issues/PRs?"
|
||||
|
||||
**Execute in parallel (4+ calls)**:
|
||||
**Tools to use**:
|
||||
\`\`\`
|
||||
Tool 1: gh search issues "keyword" --repo owner/repo --state all --limit 10
|
||||
Tool 2: gh search prs "keyword" --repo owner/repo --state merged --limit 10
|
||||
@@ -177,21 +142,22 @@ gh api repos/owner/repo/pulls/<number>/files
|
||||
### TYPE D: COMPREHENSIVE RESEARCH
|
||||
**Trigger**: Complex questions, ambiguous requests, "deep dive into..."
|
||||
|
||||
**Execute Documentation Discovery FIRST (Phase 0.5)**, then execute in parallel (6+ calls):
|
||||
**Use multiple tools as needed**:
|
||||
\`\`\`
|
||||
// Documentation (informed by sitemap discovery)
|
||||
Tool 1: context7_resolve-library-id → context7_query-docs
|
||||
Tool 2: webfetch(targeted_doc_pages_from_sitemap)
|
||||
// Documentation
|
||||
Tool 1: context7_resolve-library-id → context7_get-library-docs
|
||||
|
||||
// Code Search
|
||||
Tool 3: grep_app_searchGitHub(query: "pattern1", language: [...])
|
||||
Tool 4: grep_app_searchGitHub(query: "pattern2", useRegexp: true)
|
||||
Tool 2: grep_app_searchGitHub(query: "pattern1", language: [...])
|
||||
Tool 3: grep_app_searchGitHub(query: "pattern2", useRegexp: true)
|
||||
|
||||
// Source Analysis
|
||||
Tool 5: gh repo clone owner/repo \${TMPDIR:-/tmp}/repo -- --depth 1
|
||||
Tool 4: gh repo clone owner/repo \${TMPDIR:-/tmp}/repo -- --depth 1
|
||||
|
||||
// Context
|
||||
Tool 6: gh search issues "topic" --repo owner/repo
|
||||
Tool 5: gh search issues "topic" --repo owner/repo
|
||||
|
||||
// Optional: If web search is available, search for recent updates
|
||||
\`\`\`
|
||||
|
||||
---
|
||||
@@ -236,11 +202,7 @@ https://github.com/tanstack/query/blob/abc123def/packages/react-query/src/useQue
|
||||
|
||||
| Purpose | Tool | Command/Usage |
|
||||
|---------|------|---------------|
|
||||
| **Official Docs** | context7 | \`context7_resolve-library-id\` → \`context7_query-docs\` |
|
||||
| **Find Docs URL** | websearch_exa | \`websearch_exa_web_search_exa("library official documentation")\` |
|
||||
| **Sitemap Discovery** | webfetch | \`webfetch(docs_url + "/sitemap.xml")\` to understand doc structure |
|
||||
| **Read Doc Page** | webfetch | \`webfetch(specific_doc_page)\` for targeted documentation |
|
||||
| **Latest Info** | websearch_exa | \`websearch_exa_web_search_exa("query 2025")\` |
|
||||
| **Official Docs** | context7 | \`context7_resolve-library-id\` → \`context7_get-library-docs\` |
|
||||
| **Fast Code Search** | grep_app | \`grep_app_searchGitHub(query, language, useRegexp)\` |
|
||||
| **Deep Code Search** | gh CLI | \`gh search code "query" --repo owner/repo\` |
|
||||
| **Clone Repo** | gh CLI | \`gh repo clone owner/repo \${TMPDIR:-/tmp}/name -- --depth 1\` |
|
||||
@@ -248,6 +210,8 @@ https://github.com/tanstack/query/blob/abc123def/packages/react-query/src/useQue
|
||||
| **View Issue/PR** | gh CLI | \`gh issue/pr view <num> --repo owner/repo --comments\` |
|
||||
| **Release Info** | gh CLI | \`gh api repos/owner/repo/releases/latest\` |
|
||||
| **Git History** | git | \`git log\`, \`git blame\`, \`git show\` |
|
||||
| **Read URL** | webfetch | \`webfetch(url)\` for blog posts, SO threads |
|
||||
| **Web Search** | (if available) | Use any available web search tool for latest info |
|
||||
|
||||
### Temp Directory
|
||||
|
||||
@@ -264,18 +228,16 @@ Use OS-appropriate temp directory:
|
||||
|
||||
---
|
||||
|
||||
## PARALLEL EXECUTION REQUIREMENTS
|
||||
## PARALLEL EXECUTION GUIDANCE
|
||||
|
||||
| Request Type | Suggested Calls | Doc Discovery Required |
|
||||
When searching is needed, scale effort to question complexity:
|
||||
|
||||
| Request Type | Suggested Calls |
|
||||
|--------------|----------------|
|
||||
| TYPE A (Conceptual) | 1-2 | YES (Phase 0.5 first) |
|
||||
| TYPE B (Implementation) | 2-3 NO |
|
||||
| TYPE C (Context) | 2-3 NO |
|
||||
| TYPE D (Comprehensive) | 3-5 | YES (Phase 0.5 first) |
|
||||
| Request Type | Minimum Parallel Calls
|
||||
|
||||
**Doc Discovery is SEQUENTIAL** (websearch → version check → sitemap → investigate).
|
||||
**Main phase is PARALLEL** once you know where to look.
|
||||
| TYPE A (Conceptual) | 1-2 |
|
||||
| TYPE B (Implementation) | 2-3 |
|
||||
| TYPE C (Context) | 2-3 |
|
||||
| TYPE D (Comprehensive) | 3-5 |
|
||||
|
||||
**Always vary queries** when using grep_app:
|
||||
\`\`\`
|
||||
@@ -299,8 +261,6 @@ grep_app_searchGitHub(query: "useQuery")
|
||||
| grep_app no results | Broaden query, try concept instead of exact name |
|
||||
| gh API rate limit | Use cloned repo in temp directory |
|
||||
| Repo not found | Search for forks or mirrors |
|
||||
| Sitemap not found | Try \`/sitemap-0.xml\`, \`/sitemap_index.xml\`, or fetch docs index page and parse navigation |
|
||||
| Versioned docs not found | Fall back to latest version, note this in response |
|
||||
| Uncertain | **STATE YOUR UNCERTAINTY**, propose hypothesis |
|
||||
|
||||
---
|
||||
@@ -308,7 +268,7 @@ grep_app_searchGitHub(query: "useQuery")
|
||||
## COMMUNICATION RULES
|
||||
|
||||
1. **NO TOOL NAMES**: Say "I'll search the codebase" not "I'll use grep_app"
|
||||
2. **NO PREAMBLE**: Answer directly, skip "I'll help you with..."
|
||||
2. **NO PREAMBLE**: Answer directly, skip "I'll help you with..."
|
||||
3. **ALWAYS CITE**: Every code claim needs a permalink
|
||||
4. **USE MARKDOWN**: Code blocks with language identifiers
|
||||
5. **BE CONCISE**: Facts > opinions, evidence > speculation
|
||||
|
||||
@@ -278,22 +278,16 @@ const metisRestrictions = createAgentToolRestrictions([
|
||||
"sisyphus_task",
|
||||
])
|
||||
|
||||
const DEFAULT_MODEL = "anthropic/claude-opus-4-5"
|
||||
|
||||
export function createMetisAgent(model: string = DEFAULT_MODEL): AgentConfig {
|
||||
return {
|
||||
description:
|
||||
"Pre-planning consultant that analyzes requests to identify hidden intentions, ambiguities, and AI failure points.",
|
||||
mode: "subagent" as const,
|
||||
model,
|
||||
temperature: 0.3,
|
||||
...metisRestrictions,
|
||||
prompt: METIS_SYSTEM_PROMPT,
|
||||
thinking: { type: "enabled", budgetTokens: 32000 },
|
||||
} as AgentConfig
|
||||
}
|
||||
|
||||
export const metisAgent: AgentConfig = createMetisAgent()
|
||||
export const metisAgent: AgentConfig = {
|
||||
description:
|
||||
"Pre-planning consultant that analyzes requests to identify hidden intentions, ambiguities, and AI failure points.",
|
||||
mode: "subagent" as const,
|
||||
model: "anthropic/claude-opus-4-5",
|
||||
temperature: 0.3,
|
||||
...metisRestrictions,
|
||||
prompt: METIS_SYSTEM_PROMPT,
|
||||
thinking: { type: "enabled", budgetTokens: 32000 },
|
||||
} as AgentConfig
|
||||
|
||||
export const metisPromptMetadata: AgentPromptMetadata = {
|
||||
category: "advisor",
|
||||
|
||||
@@ -13,7 +13,6 @@ import { createAgentToolRestrictions } from "../shared/permission-compat"
|
||||
*/
|
||||
|
||||
export interface OrchestratorContext {
|
||||
model?: string
|
||||
availableAgents?: AvailableAgent[]
|
||||
availableSkills?: AvailableSkill[]
|
||||
userCategories?: Record<string, CategoryConfig>
|
||||
@@ -132,6 +131,7 @@ ${rows.join("\n")}
|
||||
}
|
||||
|
||||
export const ORCHESTRATOR_SISYPHUS_SYSTEM_PROMPT = `You are "Sisyphus" - Powerful AI Agent with orchestration capabilities from OhMyOpenCode.
|
||||
Named by [YeonGyu Kim](https://github.com/code-yeongyu).
|
||||
|
||||
**Why Sisyphus?**: Humans roll their boulder every day. So do you. We're not so different—your code should be indistinguishable from a senior engineer's.
|
||||
|
||||
@@ -1432,8 +1432,6 @@ function buildDynamicOrchestratorPrompt(ctx?: OrchestratorContext): string {
|
||||
.replace("{SKILLS_SECTION}", skillsSection)
|
||||
}
|
||||
|
||||
const DEFAULT_MODEL = "anthropic/claude-sonnet-4-5"
|
||||
|
||||
export function createOrchestratorSisyphusAgent(ctx?: OrchestratorContext): AgentConfig {
|
||||
const restrictions = createAgentToolRestrictions([
|
||||
"task",
|
||||
@@ -1444,7 +1442,7 @@ export function createOrchestratorSisyphusAgent(ctx?: OrchestratorContext): Agen
|
||||
description:
|
||||
"Orchestrates work via sisyphus_task() to complete ALL tasks in a todo list until fully done",
|
||||
mode: "primary" as const,
|
||||
model: ctx?.model ?? DEFAULT_MODEL,
|
||||
model: "anthropic/claude-sonnet-4-5",
|
||||
temperature: 0.1,
|
||||
prompt: buildDynamicOrchestratorPrompt(ctx),
|
||||
thinking: { type: "enabled", budgetTokens: 32000 },
|
||||
|
||||
@@ -18,6 +18,7 @@ const DEFAULT_MODEL = "anthropic/claude-opus-4-5"
|
||||
|
||||
const SISYPHUS_ROLE_SECTION = `<Role>
|
||||
You are "Sisyphus" - Powerful AI Agent with orchestration capabilities from OhMyOpenCode.
|
||||
Named by [YeonGyu Kim](https://github.com/code-yeongyu).
|
||||
|
||||
**Why Sisyphus?**: Humans roll their boulder every day. So do you. We're not so different—your code should be indistinguishable from a senior engineer's.
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ import { createExploreAgent, EXPLORE_PROMPT_METADATA } from "./explore"
|
||||
import { createFrontendUiUxEngineerAgent, FRONTEND_PROMPT_METADATA } from "./frontend-ui-ux-engineer"
|
||||
import { createDocumentWriterAgent, DOCUMENT_WRITER_PROMPT_METADATA } from "./document-writer"
|
||||
import { createMultimodalLookerAgent, MULTIMODAL_LOOKER_PROMPT_METADATA } from "./multimodal-looker"
|
||||
import { createMetisAgent } from "./metis"
|
||||
import { metisAgent } from "./metis"
|
||||
import { createOrchestratorSisyphusAgent, orchestratorSisyphusAgent } from "./orchestrator-sisyphus"
|
||||
import { createMomusAgent } from "./momus"
|
||||
import { momusAgent } from "./momus"
|
||||
import type { AvailableAgent } from "./sisyphus-prompt-builder"
|
||||
import { deepMerge } from "../shared"
|
||||
import { DEFAULT_CATEGORIES } from "../tools/sisyphus-task/constants"
|
||||
@@ -25,8 +25,8 @@ const agentSources: Record<BuiltinAgentName, AgentSource> = {
|
||||
"frontend-ui-ux-engineer": createFrontendUiUxEngineerAgent,
|
||||
"document-writer": createDocumentWriterAgent,
|
||||
"multimodal-looker": createMultimodalLookerAgent,
|
||||
"Metis (Plan Consultant)": createMetisAgent,
|
||||
"Momus (Plan Reviewer)": createMomusAgent,
|
||||
"Metis (Plan Consultant)": metisAgent,
|
||||
"Momus (Plan Reviewer)": momusAgent,
|
||||
"orchestrator-sisyphus": orchestratorSisyphusAgent,
|
||||
}
|
||||
|
||||
@@ -176,11 +176,7 @@ export function createBuiltinAgents(
|
||||
|
||||
if (!disabledAgents.includes("orchestrator-sisyphus")) {
|
||||
const orchestratorOverride = agentOverrides["orchestrator-sisyphus"]
|
||||
const orchestratorModel = orchestratorOverride?.model
|
||||
let orchestratorConfig = createOrchestratorSisyphusAgent({
|
||||
model: orchestratorModel,
|
||||
availableAgents,
|
||||
})
|
||||
let orchestratorConfig = createOrchestratorSisyphusAgent({ availableAgents })
|
||||
|
||||
if (orchestratorOverride) {
|
||||
orchestratorConfig = mergeAgentConfig(orchestratorConfig, orchestratorOverride)
|
||||
|
||||
@@ -9,20 +9,16 @@ Google Antigravity OAuth for Gemini models. Token management, fetch interception
|
||||
```
|
||||
auth/
|
||||
└── antigravity/
|
||||
├── plugin.ts # Main export, hooks registration (554 lines)
|
||||
├── plugin.ts # Main export, hooks registration
|
||||
├── oauth.ts # OAuth flow, token acquisition
|
||||
├── token.ts # Token storage, refresh logic
|
||||
├── fetch.ts # Fetch interceptor (798 lines)
|
||||
├── response.ts # Response transformation (599 lines)
|
||||
├── thinking.ts # Thinking block extraction (755 lines)
|
||||
├── fetch.ts # Fetch interceptor (621 lines)
|
||||
├── response.ts # Response transformation (598 lines)
|
||||
├── thinking.ts # Thinking block extraction (571 lines)
|
||||
├── thought-signature-store.ts # Signature caching
|
||||
├── message-converter.ts # Format conversion
|
||||
├── accounts.ts # Multi-account management
|
||||
├── browser.ts # Browser automation for OAuth
|
||||
├── cli.ts # CLI interaction
|
||||
├── request.ts # Request building
|
||||
├── project.ts # Project ID management
|
||||
├── storage.ts # Token persistence
|
||||
├── tools.ts # OAuth tool registration
|
||||
├── constants.ts # API endpoints, model mappings
|
||||
└── types.ts
|
||||
|
||||
@@ -9,20 +9,16 @@ CLI for oh-my-opencode: interactive installer, health diagnostics (doctor), runt
|
||||
```
|
||||
cli/
|
||||
├── index.ts # Commander.js entry, subcommand routing
|
||||
├── install.ts # Interactive TUI installer (436 lines)
|
||||
├── config-manager.ts # JSONC parsing, env detection (725 lines)
|
||||
├── install.ts # Interactive TUI installer (477 lines)
|
||||
├── config-manager.ts # JSONC parsing, env detection (669 lines)
|
||||
├── types.ts # CLI-specific types
|
||||
├── commands/ # CLI subcommands
|
||||
├── doctor/ # Health check system
|
||||
│ ├── index.ts # Doctor command entry
|
||||
│ ├── runner.ts # Health check orchestration
|
||||
│ ├── constants.ts # Check categories
|
||||
│ ├── types.ts # Check result interfaces
|
||||
│ └── checks/ # 17+ individual checks (auth, config, dependencies, gh, lsp, mcp, opencode, plugin, version)
|
||||
│ └── checks/ # 17+ individual checks
|
||||
├── get-local-version/ # Version detection
|
||||
└── run/ # OpenCode session launcher
|
||||
├── completion.ts # Completion logic
|
||||
└── events.ts # Event handling
|
||||
```
|
||||
|
||||
## CLI COMMANDS
|
||||
|
||||
@@ -25,8 +25,6 @@ export const BuiltinAgentNameSchema = z.enum([
|
||||
"document-writer",
|
||||
"multimodal-looker",
|
||||
"Metis (Plan Consultant)",
|
||||
"Momus (Plan Reviewer)",
|
||||
"orchestrator-sisyphus",
|
||||
])
|
||||
|
||||
export const BuiltinSkillNameSchema = z.enum([
|
||||
@@ -42,14 +40,12 @@ export const OverridableAgentNameSchema = z.enum([
|
||||
"OpenCode-Builder",
|
||||
"Prometheus (Planner)",
|
||||
"Metis (Plan Consultant)",
|
||||
"Momus (Plan Reviewer)",
|
||||
"oracle",
|
||||
"librarian",
|
||||
"explore",
|
||||
"frontend-ui-ux-engineer",
|
||||
"document-writer",
|
||||
"multimodal-looker",
|
||||
"orchestrator-sisyphus",
|
||||
])
|
||||
|
||||
export const AgentNameSchema = BuiltinAgentNameSchema
|
||||
@@ -122,14 +118,12 @@ export const AgentOverridesSchema = z.object({
|
||||
"OpenCode-Builder": AgentOverrideConfigSchema.optional(),
|
||||
"Prometheus (Planner)": AgentOverrideConfigSchema.optional(),
|
||||
"Metis (Plan Consultant)": AgentOverrideConfigSchema.optional(),
|
||||
"Momus (Plan Reviewer)": AgentOverrideConfigSchema.optional(),
|
||||
oracle: AgentOverrideConfigSchema.optional(),
|
||||
librarian: AgentOverrideConfigSchema.optional(),
|
||||
explore: AgentOverrideConfigSchema.optional(),
|
||||
"frontend-ui-ux-engineer": AgentOverrideConfigSchema.optional(),
|
||||
"document-writer": AgentOverrideConfigSchema.optional(),
|
||||
"multimodal-looker": AgentOverrideConfigSchema.optional(),
|
||||
"orchestrator-sisyphus": AgentOverrideConfigSchema.optional(),
|
||||
})
|
||||
|
||||
export const ClaudeCodeConfigSchema = z.object({
|
||||
@@ -296,7 +290,6 @@ export const GitMasterConfigSchema = z.object({
|
||||
/** Add "Co-authored-by: Sisyphus" trailer to commit messages (default: true) */
|
||||
include_co_authored_by: z.boolean().default(true),
|
||||
})
|
||||
|
||||
export const OhMyOpenCodeConfigSchema = z.object({
|
||||
$schema: z.string().optional(),
|
||||
disabled_mcps: z.array(AnyMcpNameSchema).optional(),
|
||||
|
||||
@@ -8,23 +8,17 @@ Claude Code compatibility layer + core feature modules. Commands, skills, agents
|
||||
|
||||
```
|
||||
features/
|
||||
├── background-agent/ # Task lifecycle, notifications (608 lines)
|
||||
├── boulder-state/ # Boulder state persistence
|
||||
├── background-agent/ # Task lifecycle, notifications (460 lines)
|
||||
├── builtin-commands/ # Built-in slash commands
|
||||
│ └── templates/ # start-work, refactor, init-deep, ralph-loop
|
||||
├── builtin-skills/ # Built-in skills
|
||||
│ ├── git-master/ # Atomic commits, rebase, history search
|
||||
│ └── frontend-ui-ux/ # Designer-turned-developer skill
|
||||
├── builtin-skills/ # Built-in skills (playwright)
|
||||
├── claude-code-agent-loader/ # ~/.claude/agents/*.md
|
||||
├── claude-code-command-loader/ # ~/.claude/commands/*.md
|
||||
├── claude-code-mcp-loader/ # .mcp.json files
|
||||
│ └── env-expander.ts # ${VAR} expansion
|
||||
├── claude-code-plugin-loader/ # installed_plugins.json (486 lines)
|
||||
├── claude-code-plugin-loader/ # installed_plugins.json (484 lines)
|
||||
├── claude-code-session-state/ # Session state persistence
|
||||
├── context-injector/ # Context collection and injection
|
||||
├── opencode-skill-loader/ # Skills from OpenCode + Claude paths
|
||||
├── skill-mcp-manager/ # MCP servers in skill YAML
|
||||
├── task-toast-manager/ # Task toast notifications
|
||||
└── hook-message-injector/ # Inject messages into conversation
|
||||
```
|
||||
|
||||
|
||||
@@ -674,95 +674,3 @@ describe("LaunchInput.skillContent", () => {
|
||||
expect(input.skillContent).toBe("You are a playwright expert")
|
||||
})
|
||||
})
|
||||
|
||||
describe("BackgroundManager.notifyParentSession - agent context preservation", () => {
|
||||
test("should not pass agent field when parentAgent is undefined", async () => {
|
||||
// #given
|
||||
const task: BackgroundTask = {
|
||||
id: "task-no-agent",
|
||||
sessionID: "session-child",
|
||||
parentSessionID: "session-parent",
|
||||
parentMessageID: "msg-parent",
|
||||
description: "task without agent context",
|
||||
prompt: "test",
|
||||
agent: "explore",
|
||||
status: "completed",
|
||||
startedAt: new Date(),
|
||||
completedAt: new Date(),
|
||||
parentAgent: undefined,
|
||||
parentModel: { providerID: "anthropic", modelID: "claude-opus" },
|
||||
}
|
||||
|
||||
// #when
|
||||
const promptBody = buildNotificationPromptBody(task)
|
||||
|
||||
// #then
|
||||
expect("agent" in promptBody).toBe(false)
|
||||
expect(promptBody.model).toEqual({ providerID: "anthropic", modelID: "claude-opus" })
|
||||
})
|
||||
|
||||
test("should include agent field when parentAgent is defined", async () => {
|
||||
// #given
|
||||
const task: BackgroundTask = {
|
||||
id: "task-with-agent",
|
||||
sessionID: "session-child",
|
||||
parentSessionID: "session-parent",
|
||||
parentMessageID: "msg-parent",
|
||||
description: "task with agent context",
|
||||
prompt: "test",
|
||||
agent: "explore",
|
||||
status: "completed",
|
||||
startedAt: new Date(),
|
||||
completedAt: new Date(),
|
||||
parentAgent: "Sisyphus",
|
||||
parentModel: { providerID: "anthropic", modelID: "claude-opus" },
|
||||
}
|
||||
|
||||
// #when
|
||||
const promptBody = buildNotificationPromptBody(task)
|
||||
|
||||
// #then
|
||||
expect(promptBody.agent).toBe("Sisyphus")
|
||||
})
|
||||
|
||||
test("should not pass model field when parentModel is undefined", async () => {
|
||||
// #given
|
||||
const task: BackgroundTask = {
|
||||
id: "task-no-model",
|
||||
sessionID: "session-child",
|
||||
parentSessionID: "session-parent",
|
||||
parentMessageID: "msg-parent",
|
||||
description: "task without model context",
|
||||
prompt: "test",
|
||||
agent: "explore",
|
||||
status: "completed",
|
||||
startedAt: new Date(),
|
||||
completedAt: new Date(),
|
||||
parentAgent: "Sisyphus",
|
||||
parentModel: undefined,
|
||||
}
|
||||
|
||||
// #when
|
||||
const promptBody = buildNotificationPromptBody(task)
|
||||
|
||||
// #then
|
||||
expect("model" in promptBody).toBe(false)
|
||||
expect(promptBody.agent).toBe("Sisyphus")
|
||||
})
|
||||
})
|
||||
|
||||
function buildNotificationPromptBody(task: BackgroundTask): Record<string, unknown> {
|
||||
const body: Record<string, unknown> = {
|
||||
parts: [{ type: "text", text: `[BACKGROUND TASK COMPLETED] Task "${task.description}" finished.` }],
|
||||
}
|
||||
|
||||
if (task.parentAgent !== undefined) {
|
||||
body.agent = task.parentAgent
|
||||
}
|
||||
|
||||
if (task.parentModel?.providerID && task.parentModel?.modelID) {
|
||||
body.model = { providerID: task.parentModel.providerID, modelID: task.parentModel.modelID }
|
||||
}
|
||||
|
||||
return body
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import { subagentSessions } from "../claude-code-session-state"
|
||||
import { getTaskToastManager } from "../task-toast-manager"
|
||||
|
||||
const TASK_TTL_MS = 30 * 60 * 1000
|
||||
const MIN_STABILITY_TIME_MS = 10 * 1000 // Must run at least 10s before stability detection kicks in
|
||||
|
||||
type OpencodeClient = PluginInput["client"]
|
||||
|
||||
@@ -44,7 +43,6 @@ interface Todo {
|
||||
export class BackgroundManager {
|
||||
private tasks: Map<string, BackgroundTask>
|
||||
private notifications: Map<string, BackgroundTask[]>
|
||||
private pendingByParent: Map<string, Set<string>> // Track pending tasks per parent for batching
|
||||
private client: OpencodeClient
|
||||
private directory: string
|
||||
private pollingInterval?: ReturnType<typeof setInterval>
|
||||
@@ -53,20 +51,12 @@ export class BackgroundManager {
|
||||
constructor(ctx: PluginInput, config?: BackgroundTaskConfig) {
|
||||
this.tasks = new Map()
|
||||
this.notifications = new Map()
|
||||
this.pendingByParent = new Map()
|
||||
this.client = ctx.client
|
||||
this.directory = ctx.directory
|
||||
this.concurrencyManager = new ConcurrencyManager(config)
|
||||
}
|
||||
|
||||
async launch(input: LaunchInput): Promise<BackgroundTask> {
|
||||
log("[background-agent] launch() called with:", {
|
||||
agent: input.agent,
|
||||
model: input.model,
|
||||
description: input.description,
|
||||
parentSessionID: input.parentSessionID,
|
||||
})
|
||||
|
||||
if (!input.agent || input.agent.trim() === "") {
|
||||
throw new Error("Agent parameter is required")
|
||||
}
|
||||
@@ -116,11 +106,6 @@ export class BackgroundManager {
|
||||
this.tasks.set(task.id, task)
|
||||
this.startPolling()
|
||||
|
||||
// Track for batched notifications
|
||||
const pending = this.pendingByParent.get(input.parentSessionID) ?? new Set()
|
||||
pending.add(task.id)
|
||||
this.pendingByParent.set(input.parentSessionID, pending)
|
||||
|
||||
log("[background-agent] Launching task:", { taskId: task.id, sessionID, agent: input.agent })
|
||||
|
||||
const toastManager = getTaskToastManager()
|
||||
@@ -134,21 +119,10 @@ export class BackgroundManager {
|
||||
})
|
||||
}
|
||||
|
||||
log("[background-agent] Calling prompt (fire-and-forget) for launch with:", {
|
||||
sessionID,
|
||||
agent: input.agent,
|
||||
model: input.model,
|
||||
hasSkillContent: !!input.skillContent,
|
||||
promptLength: input.prompt.length,
|
||||
})
|
||||
|
||||
// Use prompt() instead of promptAsync() to properly initialize agent loop (fire-and-forget)
|
||||
// Include model if caller provided one (e.g., from Sisyphus category configs)
|
||||
this.client.session.prompt({
|
||||
this.client.session.promptAsync({
|
||||
path: { id: sessionID },
|
||||
body: {
|
||||
agent: input.agent,
|
||||
...(input.model ? { model: input.model } : {}),
|
||||
system: input.skillContent,
|
||||
tools: {
|
||||
task: false,
|
||||
@@ -172,9 +146,7 @@ export class BackgroundManager {
|
||||
this.concurrencyManager.release(existingTask.concurrencyKey)
|
||||
}
|
||||
this.markForNotification(existingTask)
|
||||
this.notifyParentSession(existingTask).catch(err => {
|
||||
log("[background-agent] Failed to notify on error:", err)
|
||||
})
|
||||
this.notifyParentSession(existingTask)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -227,7 +199,6 @@ export class BackgroundManager {
|
||||
parentSessionID: string
|
||||
description: string
|
||||
agent?: string
|
||||
parentAgent?: string
|
||||
}): BackgroundTask {
|
||||
const task: BackgroundTask = {
|
||||
id: input.taskId,
|
||||
@@ -243,18 +214,12 @@ export class BackgroundManager {
|
||||
toolCalls: 0,
|
||||
lastUpdate: new Date(),
|
||||
},
|
||||
parentAgent: input.parentAgent,
|
||||
}
|
||||
|
||||
this.tasks.set(task.id, task)
|
||||
subagentSessions.add(input.sessionID)
|
||||
this.startPolling()
|
||||
|
||||
// Track for batched notifications (external tasks need tracking too)
|
||||
const pending = this.pendingByParent.get(input.parentSessionID) ?? new Set()
|
||||
pending.add(task.id)
|
||||
this.pendingByParent.set(input.parentSessionID, pending)
|
||||
|
||||
log("[background-agent] Registered external task:", { taskId: task.id, sessionID: input.sessionID })
|
||||
|
||||
return task
|
||||
@@ -282,11 +247,6 @@ export class BackgroundManager {
|
||||
this.startPolling()
|
||||
subagentSessions.add(existingTask.sessionID)
|
||||
|
||||
// Track for batched notifications (P2 fix: resumed tasks need tracking too)
|
||||
const pending = this.pendingByParent.get(input.parentSessionID) ?? new Set()
|
||||
pending.add(existingTask.id)
|
||||
this.pendingByParent.set(input.parentSessionID, pending)
|
||||
|
||||
const toastManager = getTaskToastManager()
|
||||
if (toastManager) {
|
||||
toastManager.addTask({
|
||||
@@ -299,15 +259,7 @@ export class BackgroundManager {
|
||||
|
||||
log("[background-agent] Resuming task:", { taskId: existingTask.id, sessionID: existingTask.sessionID })
|
||||
|
||||
log("[background-agent] Resuming task - calling prompt (fire-and-forget) with:", {
|
||||
sessionID: existingTask.sessionID,
|
||||
agent: existingTask.agent,
|
||||
promptLength: input.prompt.length,
|
||||
})
|
||||
|
||||
// Note: Don't pass model in body - use agent's configured model instead
|
||||
// Use prompt() instead of promptAsync() to properly initialize agent loop
|
||||
this.client.session.prompt({
|
||||
this.client.session.promptAsync({
|
||||
path: { id: existingTask.sessionID },
|
||||
body: {
|
||||
agent: existingTask.agent,
|
||||
@@ -318,15 +270,13 @@ export class BackgroundManager {
|
||||
parts: [{ type: "text", text: input.prompt }],
|
||||
},
|
||||
}).catch((error) => {
|
||||
log("[background-agent] resume prompt error:", error)
|
||||
log("[background-agent] resume promptAsync error:", error)
|
||||
existingTask.status = "error"
|
||||
const errorMessage = error instanceof Error ? error.message : String(error)
|
||||
existingTask.error = errorMessage
|
||||
existingTask.completedAt = new Date()
|
||||
this.markForNotification(existingTask)
|
||||
this.notifyParentSession(existingTask).catch(err => {
|
||||
log("[background-agent] Failed to notify on resume error:", err)
|
||||
})
|
||||
this.notifyParentSession(existingTask)
|
||||
})
|
||||
|
||||
return existingTask
|
||||
@@ -381,22 +331,7 @@ export class BackgroundManager {
|
||||
const task = this.findBySession(sessionID)
|
||||
if (!task || task.status !== "running") return
|
||||
|
||||
// Edge guard: Require minimum elapsed time (5 seconds) before accepting idle
|
||||
const elapsedMs = Date.now() - task.startedAt.getTime()
|
||||
const MIN_IDLE_TIME_MS = 5000
|
||||
if (elapsedMs < MIN_IDLE_TIME_MS) {
|
||||
log("[background-agent] Ignoring early session.idle, elapsed:", { elapsedMs, taskId: task.id })
|
||||
return
|
||||
}
|
||||
|
||||
// Edge guard: Verify session has actual assistant output before completing
|
||||
this.validateSessionHasOutput(sessionID).then(async (hasValidOutput) => {
|
||||
if (!hasValidOutput) {
|
||||
log("[background-agent] Session.idle but no valid output yet, waiting:", task.id)
|
||||
return
|
||||
}
|
||||
|
||||
const hasIncompleteTodos = await this.checkSessionTodos(sessionID)
|
||||
this.checkSessionTodos(sessionID).then((hasIncompleteTodos) => {
|
||||
if (hasIncompleteTodos) {
|
||||
log("[background-agent] Task has incomplete todos, waiting for todo-continuation:", task.id)
|
||||
return
|
||||
@@ -405,10 +340,8 @@ export class BackgroundManager {
|
||||
task.status = "completed"
|
||||
task.completedAt = new Date()
|
||||
this.markForNotification(task)
|
||||
await this.notifyParentSession(task)
|
||||
this.notifyParentSession(task)
|
||||
log("[background-agent] Task completed via session.idle event:", task.id)
|
||||
}).catch(err => {
|
||||
log("[background-agent] Error in session.idle handler:", err)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -449,66 +382,6 @@ export class BackgroundManager {
|
||||
this.notifications.delete(sessionID)
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates that a session has actual assistant/tool output before marking complete.
|
||||
* Prevents premature completion when session.idle fires before agent responds.
|
||||
*/
|
||||
private async validateSessionHasOutput(sessionID: string): Promise<boolean> {
|
||||
try {
|
||||
const response = await this.client.session.messages({
|
||||
path: { id: sessionID },
|
||||
})
|
||||
|
||||
const messages = response.data ?? []
|
||||
|
||||
// Check for at least one assistant or tool message
|
||||
const hasAssistantOrToolMessage = messages.some(
|
||||
(m: { info?: { role?: string } }) =>
|
||||
m.info?.role === "assistant" || m.info?.role === "tool"
|
||||
)
|
||||
|
||||
if (!hasAssistantOrToolMessage) {
|
||||
log("[background-agent] No assistant/tool messages found in session:", sessionID)
|
||||
return false
|
||||
}
|
||||
|
||||
// Additionally check that at least one message has content (not just empty)
|
||||
// OpenCode API uses different part types than Anthropic's API:
|
||||
// - "reasoning" with .text property (thinking/reasoning content)
|
||||
// - "tool" with .state.output property (tool call results)
|
||||
// - "text" with .text property (final text output)
|
||||
// - "step-start"/"step-finish" (metadata, no content)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const hasContent = messages.some((m: any) => {
|
||||
if (m.info?.role !== "assistant" && m.info?.role !== "tool") return false
|
||||
const parts = m.parts ?? []
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
return parts.some((p: any) =>
|
||||
// Text content (final output)
|
||||
(p.type === "text" && p.text && p.text.trim().length > 0) ||
|
||||
// Reasoning content (thinking blocks)
|
||||
(p.type === "reasoning" && p.text && p.text.trim().length > 0) ||
|
||||
// Tool calls (indicates work was done)
|
||||
p.type === "tool" ||
|
||||
// Tool results (output from executed tools) - important for tool-only tasks
|
||||
(p.type === "tool_result" && p.content &&
|
||||
(typeof p.content === "string" ? p.content.trim().length > 0 : p.content.length > 0))
|
||||
)
|
||||
})
|
||||
|
||||
if (!hasContent) {
|
||||
log("[background-agent] Messages exist but no content found in session:", sessionID)
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
} catch (error) {
|
||||
log("[background-agent] Error validating session output:", error)
|
||||
// On error, allow completion to proceed (don't block indefinitely)
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
private clearNotificationsForTask(taskId: string): void {
|
||||
for (const [sessionID, tasks] of this.notifications.entries()) {
|
||||
const filtered = tasks.filter((t) => t.id !== taskId)
|
||||
@@ -536,33 +409,17 @@ export class BackgroundManager {
|
||||
}
|
||||
}
|
||||
|
||||
cleanup(): void {
|
||||
cleanup(): void {
|
||||
this.stopPolling()
|
||||
this.tasks.clear()
|
||||
this.notifications.clear()
|
||||
this.pendingByParent.clear()
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all running tasks (for compaction hook)
|
||||
*/
|
||||
getRunningTasks(): BackgroundTask[] {
|
||||
return Array.from(this.tasks.values()).filter(t => t.status === "running")
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all completed tasks still in memory (for compaction hook)
|
||||
*/
|
||||
getCompletedTasks(): BackgroundTask[] {
|
||||
return Array.from(this.tasks.values()).filter(t => t.status !== "running")
|
||||
}
|
||||
|
||||
private async notifyParentSession(task: BackgroundTask): Promise<void> {
|
||||
private notifyParentSession(task: BackgroundTask): void {
|
||||
const duration = this.formatDuration(task.startedAt, task.completedAt)
|
||||
|
||||
log("[background-agent] notifyParentSession called for task:", task.id)
|
||||
|
||||
// Show toast notification
|
||||
const toastManager = getTaskToastManager()
|
||||
if (toastManager) {
|
||||
toastManager.showCompletionToast({
|
||||
@@ -572,83 +429,41 @@ private async notifyParentSession(task: BackgroundTask): Promise<void> {
|
||||
})
|
||||
}
|
||||
|
||||
// Update pending tracking and check if all tasks complete
|
||||
const pendingSet = this.pendingByParent.get(task.parentSessionID)
|
||||
if (pendingSet) {
|
||||
pendingSet.delete(task.id)
|
||||
if (pendingSet.size === 0) {
|
||||
this.pendingByParent.delete(task.parentSessionID)
|
||||
}
|
||||
}
|
||||
const message = `[BACKGROUND TASK COMPLETED] Task "${task.description}" finished in ${duration}. Use background_output with task_id="${task.id}" to get results.`
|
||||
|
||||
const allComplete = !pendingSet || pendingSet.size === 0
|
||||
const remainingCount = pendingSet?.size ?? 0
|
||||
log("[background-agent] Sending notification to parent session:", { parentSessionID: task.parentSessionID })
|
||||
|
||||
// Build notification message
|
||||
const statusText = task.status === "error" ? "FAILED" : "COMPLETED"
|
||||
const errorInfo = task.error ? `\n**Error:** ${task.error}` : ""
|
||||
|
||||
let notification: string
|
||||
if (allComplete) {
|
||||
// All tasks complete - build summary
|
||||
const completedTasks = Array.from(this.tasks.values())
|
||||
.filter(t => t.parentSessionID === task.parentSessionID && t.status !== "running")
|
||||
.map(t => `- \`${t.id}\`: ${t.description}`)
|
||||
.join("\n")
|
||||
|
||||
notification = `<system-reminder>
|
||||
[ALL BACKGROUND TASKS COMPLETE]
|
||||
|
||||
**Completed:**
|
||||
${completedTasks || `- \`${task.id}\`: ${task.description}`}
|
||||
|
||||
Use \`background_output(task_id="<id>")\` to retrieve each result.
|
||||
</system-reminder>`
|
||||
} else {
|
||||
// Individual completion - silent notification
|
||||
notification = `<system-reminder>
|
||||
[BACKGROUND TASK ${statusText}]
|
||||
**ID:** \`${task.id}\`
|
||||
**Description:** ${task.description}
|
||||
**Duration:** ${duration}${errorInfo}
|
||||
|
||||
**${remainingCount} task${remainingCount === 1 ? "" : "s"} still in progress.** You WILL be notified when ALL complete.
|
||||
Do NOT poll - continue productive work.
|
||||
|
||||
Use \`background_output(task_id="${task.id}")\` to retrieve this result when ready.
|
||||
</system-reminder>`
|
||||
}
|
||||
|
||||
// Inject notification via session.prompt with noReply
|
||||
try {
|
||||
await this.client.session.prompt({
|
||||
path: { id: task.parentSessionID },
|
||||
body: {
|
||||
noReply: !allComplete, // Silent unless all complete
|
||||
agent: task.parentAgent,
|
||||
parts: [{ type: "text", text: notification }],
|
||||
},
|
||||
})
|
||||
log("[background-agent] Sent notification to parent session:", {
|
||||
taskId: task.id,
|
||||
allComplete,
|
||||
noReply: !allComplete,
|
||||
})
|
||||
} catch (error) {
|
||||
log("[background-agent] Failed to send notification:", error)
|
||||
}
|
||||
|
||||
// Cleanup after retention period
|
||||
const taskId = task.id
|
||||
setTimeout(() => {
|
||||
setTimeout(async () => {
|
||||
if (task.concurrencyKey) {
|
||||
this.concurrencyManager.release(task.concurrencyKey)
|
||||
task.concurrencyKey = undefined
|
||||
}
|
||||
this.clearNotificationsForTask(taskId)
|
||||
this.tasks.delete(taskId)
|
||||
log("[background-agent] Removed completed task from memory:", taskId)
|
||||
}, 5 * 60 * 1000)
|
||||
|
||||
try {
|
||||
// Use only parentModel/parentAgent - don't fallback to prevMessage
|
||||
// This prevents accidentally changing parent session's model/agent
|
||||
const modelField = task.parentModel?.providerID && task.parentModel?.modelID
|
||||
? { providerID: task.parentModel.providerID, modelID: task.parentModel.modelID }
|
||||
: undefined
|
||||
|
||||
await this.client.session.prompt({
|
||||
path: { id: task.parentSessionID },
|
||||
body: {
|
||||
agent: task.parentAgent,
|
||||
model: modelField,
|
||||
parts: [{ type: "text", text: message }],
|
||||
},
|
||||
query: { directory: this.directory },
|
||||
})
|
||||
log("[background-agent] Successfully sent prompt to parent session:", { parentSessionID: task.parentSessionID })
|
||||
} catch (error) {
|
||||
log("[background-agent] prompt failed:", String(error))
|
||||
} finally {
|
||||
this.clearNotificationsForTask(taskId)
|
||||
this.tasks.delete(taskId)
|
||||
log("[background-agent] Removed completed task from memory:", taskId)
|
||||
}
|
||||
}, 200)
|
||||
}
|
||||
|
||||
private formatDuration(start: Date, end?: Date): string {
|
||||
@@ -717,18 +532,15 @@ Use \`background_output(task_id="${task.id}")\` to retrieve this result when rea
|
||||
for (const task of this.tasks.values()) {
|
||||
if (task.status !== "running") continue
|
||||
|
||||
try {
|
||||
try {
|
||||
const sessionStatus = allStatuses[task.sessionID]
|
||||
|
||||
// Don't skip if session not in status - fall through to message-based detection
|
||||
if (sessionStatus?.type === "idle") {
|
||||
// Edge guard: Validate session has actual output before completing
|
||||
const hasValidOutput = await this.validateSessionHasOutput(task.sessionID)
|
||||
if (!hasValidOutput) {
|
||||
log("[background-agent] Polling idle but no valid output yet, waiting:", task.id)
|
||||
continue
|
||||
}
|
||||
if (!sessionStatus) {
|
||||
log("[background-agent] Session not found in status:", task.sessionID)
|
||||
continue
|
||||
}
|
||||
|
||||
if (sessionStatus.type === "idle") {
|
||||
const hasIncompleteTodos = await this.checkSessionTodos(task.sessionID)
|
||||
if (hasIncompleteTodos) {
|
||||
log("[background-agent] Task has incomplete todos via polling, waiting:", task.id)
|
||||
@@ -738,7 +550,7 @@ try {
|
||||
task.status = "completed"
|
||||
task.completedAt = new Date()
|
||||
this.markForNotification(task)
|
||||
await this.notifyParentSession(task)
|
||||
this.notifyParentSession(task)
|
||||
log("[background-agent] Task completed via polling:", task.id)
|
||||
continue
|
||||
}
|
||||
@@ -779,41 +591,10 @@ try {
|
||||
task.progress.toolCalls = toolCalls
|
||||
task.progress.lastTool = lastTool
|
||||
task.progress.lastUpdate = new Date()
|
||||
if (lastMessage) {
|
||||
if (lastMessage) {
|
||||
task.progress.lastMessage = lastMessage
|
||||
task.progress.lastMessageAt = new Date()
|
||||
}
|
||||
|
||||
// Stability detection: complete when message count unchanged for 3 polls
|
||||
const currentMsgCount = messages.length
|
||||
const elapsedMs = Date.now() - task.startedAt.getTime()
|
||||
|
||||
if (elapsedMs >= MIN_STABILITY_TIME_MS) {
|
||||
if (task.lastMsgCount === currentMsgCount) {
|
||||
task.stablePolls = (task.stablePolls ?? 0) + 1
|
||||
if (task.stablePolls >= 3) {
|
||||
// Edge guard: Validate session has actual output before completing
|
||||
const hasValidOutput = await this.validateSessionHasOutput(task.sessionID)
|
||||
if (!hasValidOutput) {
|
||||
log("[background-agent] Stability reached but no valid output, waiting:", task.id)
|
||||
continue
|
||||
}
|
||||
|
||||
const hasIncompleteTodos = await this.checkSessionTodos(task.sessionID)
|
||||
if (!hasIncompleteTodos) {
|
||||
task.status = "completed"
|
||||
task.completedAt = new Date()
|
||||
this.markForNotification(task)
|
||||
await this.notifyParentSession(task)
|
||||
log("[background-agent] Task completed via stability detection:", task.id)
|
||||
continue
|
||||
}
|
||||
}
|
||||
} else {
|
||||
task.stablePolls = 0
|
||||
}
|
||||
}
|
||||
task.lastMsgCount = currentMsgCount
|
||||
}
|
||||
} catch (error) {
|
||||
log("[background-agent] Poll error for task:", { taskId: task.id, error })
|
||||
|
||||
@@ -32,10 +32,6 @@ export interface BackgroundTask {
|
||||
concurrencyKey?: string
|
||||
/** Parent session's agent name for notification */
|
||||
parentAgent?: string
|
||||
/** Last message count for stability detection */
|
||||
lastMsgCount?: number
|
||||
/** Number of consecutive polls with stable message count */
|
||||
stablePolls?: number
|
||||
}
|
||||
|
||||
export interface LaunchInput {
|
||||
|
||||
@@ -2,42 +2,35 @@
|
||||
|
||||
## OVERVIEW
|
||||
|
||||
22+ lifecycle hooks intercepting/modifying agent behavior. Context injection, error recovery, output control, notifications.
|
||||
22 lifecycle hooks intercepting/modifying agent behavior. Context injection, error recovery, output control, notifications.
|
||||
|
||||
## STRUCTURE
|
||||
|
||||
```
|
||||
hooks/
|
||||
├── anthropic-context-window-limit-recovery/ # Auto-compact at token limit (556 lines)
|
||||
├── anthropic-context-window-limit-recovery/ # Auto-compact at token limit (554 lines)
|
||||
├── auto-slash-command/ # Detect and execute /command patterns
|
||||
├── auto-update-checker/ # Version notifications, startup toast
|
||||
├── background-notification/ # OS notify on task complete
|
||||
├── claude-code-hooks/ # settings.json PreToolUse/PostToolUse/etc (408 lines)
|
||||
├── claude-code-hooks/ # settings.json PreToolUse/PostToolUse/etc
|
||||
├── comment-checker/ # Prevent excessive AI comments
|
||||
│ ├── filters/ # docstring, directive, bdd, shebang
|
||||
│ └── output/ # XML builder, formatter
|
||||
│ └── filters/ # docstring, directive, bdd, etc
|
||||
├── compaction-context-injector/ # Preserve context during compaction
|
||||
├── directory-agents-injector/ # Auto-inject AGENTS.md
|
||||
├── directory-readme-injector/ # Auto-inject README.md
|
||||
├── edit-error-recovery/ # Recover from edit failures
|
||||
├── empty-message-sanitizer/ # Sanitize empty messages
|
||||
├── interactive-bash-session/ # Tmux session management
|
||||
├── keyword-detector/ # ultrawork/search keyword activation
|
||||
├── non-interactive-env/ # CI/headless handling
|
||||
├── preemptive-compaction/ # Pre-emptive at 85% usage
|
||||
├── prometheus-md-only/ # Restrict prometheus to read-only
|
||||
├── ralph-loop/ # Self-referential dev loop
|
||||
├── rules-injector/ # Conditional rules from .claude/rules/
|
||||
├── session-recovery/ # Recover from errors (432 lines)
|
||||
├── sisyphus-orchestrator/ # Main orchestration hook (660 lines)
|
||||
├── start-work/ # Initialize Sisyphus work session
|
||||
├── task-resume-info/ # Track task resume state
|
||||
├── session-recovery/ # Recover from errors (430 lines)
|
||||
├── think-mode/ # Auto-detect thinking triggers
|
||||
├── thinking-block-validator/ # Validate thinking block format
|
||||
├── agent-usage-reminder/ # Remind to use specialists
|
||||
├── context-window-monitor.ts # Monitor usage (standalone)
|
||||
├── session-notification.ts # OS notify on idle
|
||||
├── todo-continuation-enforcer.ts # Force TODO completion (413 lines)
|
||||
├── todo-continuation-enforcer.ts # Force TODO completion
|
||||
└── tool-output-truncator.ts # Truncate verbose outputs
|
||||
```
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@ export const TARGET_TOOLS = new Set([
|
||||
"safe_glob",
|
||||
"webfetch",
|
||||
"context7_resolve-library-id",
|
||||
"context7_query-docs",
|
||||
"websearch_web_search_exa",
|
||||
"context7_get-library-docs",
|
||||
"grep_app_searchgithub",
|
||||
]);
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
import { describe, test, expect } from "bun:test"
|
||||
import { isPrereleaseVersion, isDistTag, isPrereleaseOrDistTag } from "./index"
|
||||
|
||||
describe("auto-update-checker", () => {
|
||||
describe("isPrereleaseVersion", () => {
|
||||
test("returns true for beta versions", () => {
|
||||
// #given a beta version
|
||||
const version = "3.0.0-beta.1"
|
||||
|
||||
// #when checking if prerelease
|
||||
const result = isPrereleaseVersion(version)
|
||||
|
||||
// #then returns true
|
||||
expect(result).toBe(true)
|
||||
})
|
||||
|
||||
test("returns true for alpha versions", () => {
|
||||
// #given an alpha version
|
||||
const version = "1.0.0-alpha"
|
||||
|
||||
// #when checking if prerelease
|
||||
const result = isPrereleaseVersion(version)
|
||||
|
||||
// #then returns true
|
||||
expect(result).toBe(true)
|
||||
})
|
||||
|
||||
test("returns true for rc versions", () => {
|
||||
// #given an rc version
|
||||
const version = "2.0.0-rc.1"
|
||||
|
||||
// #when checking if prerelease
|
||||
const result = isPrereleaseVersion(version)
|
||||
|
||||
// #then returns true
|
||||
expect(result).toBe(true)
|
||||
})
|
||||
|
||||
test("returns false for stable versions", () => {
|
||||
// #given a stable version
|
||||
const version = "2.14.0"
|
||||
|
||||
// #when checking if prerelease
|
||||
const result = isPrereleaseVersion(version)
|
||||
|
||||
// #then returns false
|
||||
expect(result).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe("isDistTag", () => {
|
||||
test("returns true for beta dist-tag", () => {
|
||||
// #given beta dist-tag
|
||||
const version = "beta"
|
||||
|
||||
// #when checking if dist-tag
|
||||
const result = isDistTag(version)
|
||||
|
||||
// #then returns true
|
||||
expect(result).toBe(true)
|
||||
})
|
||||
|
||||
test("returns true for next dist-tag", () => {
|
||||
// #given next dist-tag
|
||||
const version = "next"
|
||||
|
||||
// #when checking if dist-tag
|
||||
const result = isDistTag(version)
|
||||
|
||||
// #then returns true
|
||||
expect(result).toBe(true)
|
||||
})
|
||||
|
||||
test("returns true for canary dist-tag", () => {
|
||||
// #given canary dist-tag
|
||||
const version = "canary"
|
||||
|
||||
// #when checking if dist-tag
|
||||
const result = isDistTag(version)
|
||||
|
||||
// #then returns true
|
||||
expect(result).toBe(true)
|
||||
})
|
||||
|
||||
test("returns false for semver versions", () => {
|
||||
// #given a semver version
|
||||
const version = "2.14.0"
|
||||
|
||||
// #when checking if dist-tag
|
||||
const result = isDistTag(version)
|
||||
|
||||
// #then returns false
|
||||
expect(result).toBe(false)
|
||||
})
|
||||
|
||||
test("returns false for latest (handled separately)", () => {
|
||||
// #given latest tag
|
||||
const version = "latest"
|
||||
|
||||
// #when checking if dist-tag
|
||||
const result = isDistTag(version)
|
||||
|
||||
// #then returns true (but latest is filtered before this check)
|
||||
expect(result).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe("isPrereleaseOrDistTag", () => {
|
||||
test("returns false for null", () => {
|
||||
// #given null version
|
||||
const version = null
|
||||
|
||||
// #when checking
|
||||
const result = isPrereleaseOrDistTag(version)
|
||||
|
||||
// #then returns false
|
||||
expect(result).toBe(false)
|
||||
})
|
||||
|
||||
test("returns true for prerelease version", () => {
|
||||
// #given prerelease version
|
||||
const version = "3.0.0-beta.1"
|
||||
|
||||
// #when checking
|
||||
const result = isPrereleaseOrDistTag(version)
|
||||
|
||||
// #then returns true
|
||||
expect(result).toBe(true)
|
||||
})
|
||||
|
||||
test("returns true for dist-tag", () => {
|
||||
// #given dist-tag
|
||||
const version = "beta"
|
||||
|
||||
// #when checking
|
||||
const result = isPrereleaseOrDistTag(version)
|
||||
|
||||
// #then returns true
|
||||
expect(result).toBe(true)
|
||||
})
|
||||
|
||||
test("returns false for stable version", () => {
|
||||
// #given stable version
|
||||
const version = "2.14.0"
|
||||
|
||||
// #when checking
|
||||
const result = isPrereleaseOrDistTag(version)
|
||||
|
||||
// #then returns false
|
||||
expect(result).toBe(false)
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -9,20 +9,6 @@ import type { AutoUpdateCheckerOptions } from "./types"
|
||||
|
||||
const SISYPHUS_SPINNER = ["·", "•", "●", "○", "◌", "◦", " "]
|
||||
|
||||
export function isPrereleaseVersion(version: string): boolean {
|
||||
return version.includes("-")
|
||||
}
|
||||
|
||||
export function isDistTag(version: string): boolean {
|
||||
const startsWithDigit = /^\d/.test(version)
|
||||
return !startsWithDigit
|
||||
}
|
||||
|
||||
export function isPrereleaseOrDistTag(pinnedVersion: string | null): boolean {
|
||||
if (!pinnedVersion) return false
|
||||
return isPrereleaseVersion(pinnedVersion) || isDistTag(pinnedVersion)
|
||||
}
|
||||
|
||||
export function createAutoUpdateCheckerHook(ctx: PluginInput, options: AutoUpdateCheckerOptions = {}) {
|
||||
const { showStartupToast = true, isSisyphusEnabled = false, autoUpdate = true } = options
|
||||
|
||||
@@ -77,7 +63,7 @@ export function createAutoUpdateCheckerHook(ctx: PluginInput, options: AutoUpdat
|
||||
}
|
||||
|
||||
async function runBackgroundUpdateCheck(
|
||||
ctx: PluginInput,
|
||||
ctx: PluginInput,
|
||||
autoUpdate: boolean,
|
||||
getToastMessage: (isUpdate: boolean, latestVersion?: string) => string
|
||||
): Promise<void> {
|
||||
@@ -113,18 +99,7 @@ async function runBackgroundUpdateCheck(
|
||||
return
|
||||
}
|
||||
|
||||
// Check if current version is a prerelease - don't auto-downgrade prerelease to stable
|
||||
if (isPrereleaseVersion(currentVersion)) {
|
||||
log(`[auto-update-checker] Skipping auto-update for prerelease version: ${currentVersion}`)
|
||||
return
|
||||
}
|
||||
|
||||
if (pluginInfo.isPinned) {
|
||||
if (isPrereleaseOrDistTag(pluginInfo.pinnedVersion)) {
|
||||
log(`[auto-update-checker] Skipping auto-update for prerelease/dist-tag: ${pluginInfo.pinnedVersion}`)
|
||||
return
|
||||
}
|
||||
|
||||
const updated = updatePinnedVersion(pluginInfo.configPath, pluginInfo.entry, latestVersion)
|
||||
if (!updated) {
|
||||
await showUpdateAvailableToast(ctx, latestVersion, getToastMessage)
|
||||
@@ -137,7 +112,7 @@ async function runBackgroundUpdateCheck(
|
||||
invalidatePackage(PACKAGE_NAME)
|
||||
|
||||
const installSuccess = await runBunInstallSafe()
|
||||
|
||||
|
||||
if (installSuccess) {
|
||||
await showAutoUpdatedToast(ctx, currentVersion, latestVersion)
|
||||
log(`[auto-update-checker] Update installed: ${currentVersion} → ${latestVersion}`)
|
||||
@@ -205,7 +180,7 @@ async function showSpinnerToast(ctx: PluginInput, version: string, message: stri
|
||||
}
|
||||
|
||||
async function showUpdateAvailableToast(
|
||||
ctx: PluginInput,
|
||||
ctx: PluginInput,
|
||||
latestVersion: string,
|
||||
getToastMessage: (isUpdate: boolean, latestVersion?: string) => string
|
||||
): Promise<void> {
|
||||
|
||||
@@ -1,85 +0,0 @@
|
||||
import type { BackgroundManager } from "../../features/background-agent"
|
||||
|
||||
interface CompactingInput {
|
||||
sessionID: string
|
||||
}
|
||||
|
||||
interface CompactingOutput {
|
||||
context: string[]
|
||||
prompt?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* Background agent compaction hook - preserves task state during context compaction.
|
||||
*
|
||||
* When OpenCode compacts session context to save tokens, this hook injects
|
||||
* information about running and recently completed background tasks so the
|
||||
* agent doesn't lose awareness of delegated work.
|
||||
*/
|
||||
export function createBackgroundCompactionHook(manager: BackgroundManager) {
|
||||
return {
|
||||
"experimental.session.compacting": async (
|
||||
input: CompactingInput,
|
||||
output: CompactingOutput
|
||||
): Promise<void> => {
|
||||
const { sessionID } = input
|
||||
|
||||
// Get running tasks for this session
|
||||
const running = manager.getRunningTasks()
|
||||
.filter(t => t.parentSessionID === sessionID)
|
||||
.map(t => ({
|
||||
id: t.id,
|
||||
agent: t.agent,
|
||||
description: t.description,
|
||||
startedAt: t.startedAt,
|
||||
}))
|
||||
|
||||
// Get recently completed tasks (still in memory within 5-min retention)
|
||||
const completed = manager.getCompletedTasks()
|
||||
.filter(t => t.parentSessionID === sessionID)
|
||||
.slice(-10) // Last 10 completed
|
||||
.map(t => ({
|
||||
id: t.id,
|
||||
agent: t.agent,
|
||||
description: t.description,
|
||||
status: t.status,
|
||||
}))
|
||||
|
||||
// Early exit if nothing to preserve
|
||||
if (running.length === 0 && completed.length === 0) return
|
||||
|
||||
const sections: string[] = ["<background-tasks>"]
|
||||
|
||||
// Running tasks section
|
||||
if (running.length > 0) {
|
||||
sections.push("## Running Background Tasks")
|
||||
sections.push("")
|
||||
for (const t of running) {
|
||||
const elapsed = Math.floor((Date.now() - t.startedAt.getTime()) / 1000)
|
||||
sections.push(`- **\`${t.id}\`** (${t.agent}): ${t.description} [${elapsed}s elapsed]`)
|
||||
}
|
||||
sections.push("")
|
||||
sections.push("> **Note:** You WILL be notified when tasks complete.")
|
||||
sections.push("> Do NOT poll - continue productive work.")
|
||||
sections.push("")
|
||||
}
|
||||
|
||||
// Completed tasks section
|
||||
if (completed.length > 0) {
|
||||
sections.push("## Recently Completed Tasks")
|
||||
sections.push("")
|
||||
for (const t of completed) {
|
||||
const statusEmoji = t.status === "completed" ? "✅" : t.status === "error" ? "❌" : "⏱️"
|
||||
sections.push(`- ${statusEmoji} **\`${t.id}\`**: ${t.description}`)
|
||||
}
|
||||
sections.push("")
|
||||
}
|
||||
|
||||
sections.push("## Retrieval")
|
||||
sections.push('Use `background_output(task_id="<id>")` to retrieve task results.')
|
||||
sections.push("</background-tasks>")
|
||||
|
||||
output.context.push(sections.join("\n"))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,12 +9,6 @@ interface EventInput {
|
||||
event: Event
|
||||
}
|
||||
|
||||
/**
|
||||
* Background notification hook - handles event routing to BackgroundManager.
|
||||
*
|
||||
* Notifications are now delivered directly via session.prompt({ noReply })
|
||||
* from the manager, so this hook only needs to handle event routing.
|
||||
*/
|
||||
export function createBackgroundNotificationHook(manager: BackgroundManager) {
|
||||
const eventHandler = async ({ event }: EventInput) => {
|
||||
manager.handleEvent(event)
|
||||
|
||||
@@ -14,7 +14,6 @@ export { createThinkModeHook } from "./think-mode";
|
||||
export { createClaudeCodeHooksHook } from "./claude-code-hooks";
|
||||
export { createRulesInjectorHook } from "./rules-injector";
|
||||
export { createBackgroundNotificationHook } from "./background-notification"
|
||||
export { createBackgroundCompactionHook } from "./background-compaction"
|
||||
export { createAutoUpdateCheckerHook } from "./auto-update-checker";
|
||||
|
||||
export { createAgentUsageReminderHook } from "./agent-usage-reminder";
|
||||
|
||||
@@ -591,73 +591,6 @@ describe("ralph-loop", () => {
|
||||
expect(hook.getState()).toBeNull()
|
||||
})
|
||||
|
||||
test("should allow starting new loop while previous loop is active (different session)", async () => {
|
||||
// #given - active loop in session A
|
||||
const hook = createRalphLoopHook(createMockPluginInput())
|
||||
hook.startLoop("session-A", "First task", { maxIterations: 10 })
|
||||
expect(hook.getState()?.session_id).toBe("session-A")
|
||||
expect(hook.getState()?.prompt).toBe("First task")
|
||||
|
||||
// #when - start new loop in session B (without completing A)
|
||||
hook.startLoop("session-B", "Second task", { maxIterations: 20 })
|
||||
|
||||
// #then - state should be overwritten with session B's loop
|
||||
expect(hook.getState()?.session_id).toBe("session-B")
|
||||
expect(hook.getState()?.prompt).toBe("Second task")
|
||||
expect(hook.getState()?.max_iterations).toBe(20)
|
||||
expect(hook.getState()?.iteration).toBe(1)
|
||||
|
||||
// #when - session B goes idle
|
||||
await hook.event({
|
||||
event: { type: "session.idle", properties: { sessionID: "session-B" } },
|
||||
})
|
||||
|
||||
// #then - continuation should be injected for session B
|
||||
expect(promptCalls.length).toBe(1)
|
||||
expect(promptCalls[0].sessionID).toBe("session-B")
|
||||
expect(promptCalls[0].text).toContain("Second task")
|
||||
expect(promptCalls[0].text).toContain("2/20")
|
||||
|
||||
// #then - iteration incremented
|
||||
expect(hook.getState()?.iteration).toBe(2)
|
||||
})
|
||||
|
||||
test("should allow starting new loop in same session (restart)", async () => {
|
||||
// #given - active loop in session A at iteration 5
|
||||
const hook = createRalphLoopHook(createMockPluginInput())
|
||||
hook.startLoop("session-A", "First task", { maxIterations: 10 })
|
||||
|
||||
// Simulate some iterations
|
||||
await hook.event({
|
||||
event: { type: "session.idle", properties: { sessionID: "session-A" } },
|
||||
})
|
||||
await hook.event({
|
||||
event: { type: "session.idle", properties: { sessionID: "session-A" } },
|
||||
})
|
||||
expect(hook.getState()?.iteration).toBe(3)
|
||||
expect(promptCalls.length).toBe(2)
|
||||
|
||||
// #when - start NEW loop in same session (restart)
|
||||
hook.startLoop("session-A", "Restarted task", { maxIterations: 50 })
|
||||
|
||||
// #then - state should be reset to iteration 1 with new prompt
|
||||
expect(hook.getState()?.session_id).toBe("session-A")
|
||||
expect(hook.getState()?.prompt).toBe("Restarted task")
|
||||
expect(hook.getState()?.max_iterations).toBe(50)
|
||||
expect(hook.getState()?.iteration).toBe(1)
|
||||
|
||||
// #when - session goes idle
|
||||
promptCalls = [] // Reset to check new continuation
|
||||
await hook.event({
|
||||
event: { type: "session.idle", properties: { sessionID: "session-A" } },
|
||||
})
|
||||
|
||||
// #then - continuation should use new task
|
||||
expect(promptCalls.length).toBe(1)
|
||||
expect(promptCalls[0].text).toContain("Restarted task")
|
||||
expect(promptCalls[0].text).toContain("2/50")
|
||||
})
|
||||
|
||||
test("should check transcript BEFORE API to optimize performance", async () => {
|
||||
// #given - transcript has completion promise
|
||||
const transcriptPath = join(TEST_DIR, "transcript.jsonl")
|
||||
|
||||
@@ -19,10 +19,9 @@ tools/
|
||||
├── interactive-bash/ # Tmux session management
|
||||
├── look-at/ # Multimodal analysis (PDF, images)
|
||||
├── lsp/ # 11 LSP tools
|
||||
│ ├── client.ts # LSP connection lifecycle (612 lines)
|
||||
│ ├── utils.ts # LSP utilities (461 lines)
|
||||
│ ├── client.ts # LSP connection lifecycle
|
||||
│ ├── config.ts # Server configurations
|
||||
│ ├── tools.ts # Tool implementations (405 lines)
|
||||
│ ├── tools.ts # Tool implementations
|
||||
│ └── types.ts
|
||||
├── session-manager/ # OpenCode session file management
|
||||
│ ├── constants.ts # Storage paths, descriptions
|
||||
@@ -30,7 +29,6 @@ tools/
|
||||
│ ├── storage.ts # File I/O operations
|
||||
│ ├── utils.ts # Formatting, filtering
|
||||
│ └── tools.ts # Tool implementations
|
||||
├── sisyphus-task/ # Category-based task delegation (493 lines)
|
||||
├── skill/ # Skill loading and execution
|
||||
├── skill-mcp/ # Skill-embedded MCP invocation
|
||||
├── slashcommand/ # Slash command execution
|
||||
|
||||
@@ -74,7 +74,7 @@ export function createBackgroundTask(manager: BackgroundManager): ToolDefinition
|
||||
parentSessionID: ctx.sessionID,
|
||||
parentMessageID: ctx.messageID,
|
||||
parentModel,
|
||||
parentAgent: ctx.agent ?? prevMessage?.agent,
|
||||
parentAgent: prevMessage?.agent,
|
||||
})
|
||||
|
||||
ctx.metadata?.({
|
||||
@@ -176,13 +176,8 @@ async function formatTaskResult(task: BackgroundTask, client: OpencodeClient): P
|
||||
// Handle both SDK response structures: direct array or wrapped in .data
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const messages = ((messagesResult as any).data ?? messagesResult) as Array<{
|
||||
info?: { role?: string; time?: string }
|
||||
parts?: Array<{
|
||||
type?: string
|
||||
text?: string
|
||||
content?: string | Array<{ type: string; text?: string }>
|
||||
name?: string
|
||||
}>
|
||||
info?: { role?: string }
|
||||
parts?: Array<{ type?: string; text?: string }>
|
||||
}>
|
||||
|
||||
if (!Array.isArray(messages) || messages.length === 0) {
|
||||
@@ -198,13 +193,11 @@ Session ID: ${task.sessionID}
|
||||
(No messages found)`
|
||||
}
|
||||
|
||||
// Include both assistant messages AND tool messages
|
||||
// Tool results (grep, glob, bash output) come from role "tool"
|
||||
const relevantMessages = messages.filter(
|
||||
(m) => m.info?.role === "assistant" || m.info?.role === "tool"
|
||||
const assistantMessages = messages.filter(
|
||||
(m) => m.info?.role === "assistant"
|
||||
)
|
||||
|
||||
if (relevantMessages.length === 0) {
|
||||
if (assistantMessages.length === 0) {
|
||||
return `Task Result
|
||||
|
||||
Task ID: ${task.id}
|
||||
@@ -214,46 +207,17 @@ Session ID: ${task.sessionID}
|
||||
|
||||
---
|
||||
|
||||
(No assistant or tool response found)`
|
||||
(No assistant response found)`
|
||||
}
|
||||
|
||||
// Sort by time ascending (oldest first) to process messages in order
|
||||
const sortedMessages = [...relevantMessages].sort((a, b) => {
|
||||
const timeA = String((a as { info?: { time?: string } }).info?.time ?? "")
|
||||
const timeB = String((b as { info?: { time?: string } }).info?.time ?? "")
|
||||
return timeA.localeCompare(timeB)
|
||||
})
|
||||
|
||||
// Extract content from ALL messages, not just the last one
|
||||
// Tool results may be in earlier messages while the final message is empty
|
||||
const extractedContent: string[] = []
|
||||
|
||||
for (const message of sortedMessages) {
|
||||
for (const part of message.parts ?? []) {
|
||||
// Handle both "text" and "reasoning" parts (thinking models use "reasoning")
|
||||
if ((part.type === "text" || part.type === "reasoning") && part.text) {
|
||||
extractedContent.push(part.text)
|
||||
} else if (part.type === "tool_result") {
|
||||
// Tool results contain the actual output from tool calls
|
||||
const toolResult = part as { content?: string | Array<{ type: string; text?: string }> }
|
||||
if (typeof toolResult.content === "string" && toolResult.content) {
|
||||
extractedContent.push(toolResult.content)
|
||||
} else if (Array.isArray(toolResult.content)) {
|
||||
// Handle array of content blocks
|
||||
for (const block of toolResult.content) {
|
||||
// Handle both "text" and "reasoning" parts (thinking models use "reasoning")
|
||||
if ((block.type === "text" || block.type === "reasoning") && block.text) {
|
||||
extractedContent.push(block.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const textContent = extractedContent
|
||||
const lastMessage = assistantMessages[assistantMessages.length - 1]
|
||||
const textParts = lastMessage?.parts?.filter(
|
||||
(p) => p.type === "text"
|
||||
) ?? []
|
||||
const textContent = textParts
|
||||
.map((p) => p.text ?? "")
|
||||
.filter((text) => text.length > 0)
|
||||
.join("\n\n")
|
||||
.join("\n")
|
||||
|
||||
const duration = formatDuration(task.startedAt, task.completedAt)
|
||||
|
||||
|
||||
@@ -170,59 +170,23 @@ async function executeSync(
|
||||
const messages = messagesResult.data
|
||||
log(`[call_omo_agent] Got ${messages.length} messages`)
|
||||
|
||||
// Include both assistant messages AND tool messages
|
||||
// Tool results (grep, glob, bash output) come from role "tool"
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const relevantMessages = messages.filter(
|
||||
(m: any) => m.info?.role === "assistant" || m.info?.role === "tool"
|
||||
)
|
||||
const lastAssistantMessage = messages
|
||||
.filter((m: any) => m.info.role === "assistant")
|
||||
.sort((a: any, b: any) => (b.info.time?.created || 0) - (a.info.time?.created || 0))[0]
|
||||
|
||||
if (relevantMessages.length === 0) {
|
||||
log(`[call_omo_agent] No assistant or tool messages found`)
|
||||
if (!lastAssistantMessage) {
|
||||
log(`[call_omo_agent] No assistant message found`)
|
||||
log(`[call_omo_agent] All messages:`, JSON.stringify(messages, null, 2))
|
||||
return `Error: No assistant or tool response found\n\n<task_metadata>\nsession_id: ${sessionID}\n</task_metadata>`
|
||||
return `Error: No assistant response found\n\n<task_metadata>\nsession_id: ${sessionID}\n</task_metadata>`
|
||||
}
|
||||
|
||||
log(`[call_omo_agent] Found ${relevantMessages.length} relevant messages`)
|
||||
log(`[call_omo_agent] Found assistant message with ${lastAssistantMessage.parts.length} parts`)
|
||||
|
||||
// Sort by time ascending (oldest first) to process messages in order
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const sortedMessages = [...relevantMessages].sort((a: any, b: any) => {
|
||||
const timeA = a.info?.time?.created ?? 0
|
||||
const timeB = b.info?.time?.created ?? 0
|
||||
return timeA - timeB
|
||||
})
|
||||
|
||||
// Extract content from ALL messages, not just the last one
|
||||
// Tool results may be in earlier messages while the final message is empty
|
||||
const extractedContent: string[] = []
|
||||
|
||||
for (const message of sortedMessages) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
for (const part of (message as any).parts ?? []) {
|
||||
// Handle both "text" and "reasoning" parts (thinking models use "reasoning")
|
||||
if ((part.type === "text" || part.type === "reasoning") && part.text) {
|
||||
extractedContent.push(part.text)
|
||||
} else if (part.type === "tool_result") {
|
||||
// Tool results contain the actual output from tool calls
|
||||
const toolResult = part as { content?: string | Array<{ type: string; text?: string }> }
|
||||
if (typeof toolResult.content === "string" && toolResult.content) {
|
||||
extractedContent.push(toolResult.content)
|
||||
} else if (Array.isArray(toolResult.content)) {
|
||||
// Handle array of content blocks
|
||||
for (const block of toolResult.content) {
|
||||
if ((block.type === "text" || block.type === "reasoning") && block.text) {
|
||||
extractedContent.push(block.text)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const responseText = extractedContent
|
||||
.filter((text) => text.length > 0)
|
||||
.join("\n\n")
|
||||
const textParts = lastAssistantMessage.parts.filter((p: any) => p.type === "text")
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const responseText = textParts.map((p: any) => p.text).join("\n")
|
||||
|
||||
log(`[call_omo_agent] Got response, length: ${responseText.length}`)
|
||||
|
||||
|
||||
@@ -259,7 +259,6 @@ describe("sisyphus-task", () => {
|
||||
|
||||
describe("resume with background parameter", () => {
|
||||
test("resume with background=false should wait for result and return content", async () => {
|
||||
// Note: This test needs extended timeout because the implementation has MIN_STABILITY_TIME_MS = 5000
|
||||
// #given
|
||||
const { createSisyphusTask } = require("./tools")
|
||||
|
||||
@@ -320,7 +319,7 @@ describe("sisyphus-task", () => {
|
||||
// #then - should contain actual result, not just "Background task resumed"
|
||||
expect(result).toContain("This is the resumed task result")
|
||||
expect(result).not.toContain("Background task resumed")
|
||||
}, { timeout: 10000 })
|
||||
})
|
||||
|
||||
test("resume with background=true should return immediately without waiting", async () => {
|
||||
// #given
|
||||
|
||||
@@ -221,33 +221,6 @@ Use \`background_output\` with task_id="${task.id}" to check progress.`
|
||||
return `❌ Failed to send resume prompt: ${errorMessage}\n\nSession ID: ${args.resume}`
|
||||
}
|
||||
|
||||
// Wait for message stability after prompt completes
|
||||
const POLL_INTERVAL_MS = 500
|
||||
const MIN_STABILITY_TIME_MS = 5000
|
||||
const STABILITY_POLLS_REQUIRED = 3
|
||||
const pollStart = Date.now()
|
||||
let lastMsgCount = 0
|
||||
let stablePolls = 0
|
||||
|
||||
while (Date.now() - pollStart < 60000) {
|
||||
await new Promise(resolve => setTimeout(resolve, POLL_INTERVAL_MS))
|
||||
|
||||
const elapsed = Date.now() - pollStart
|
||||
if (elapsed < MIN_STABILITY_TIME_MS) continue
|
||||
|
||||
const messagesCheck = await client.session.messages({ path: { id: args.resume } })
|
||||
const msgs = ((messagesCheck as { data?: unknown }).data ?? messagesCheck) as Array<unknown>
|
||||
const currentMsgCount = msgs.length
|
||||
|
||||
if (currentMsgCount > 0 && currentMsgCount === lastMsgCount) {
|
||||
stablePolls++
|
||||
if (stablePolls >= STABILITY_POLLS_REQUIRED) break
|
||||
} else {
|
||||
stablePolls = 0
|
||||
lastMsgCount = currentMsgCount
|
||||
}
|
||||
}
|
||||
|
||||
const messagesResult = await client.session.messages({
|
||||
path: { id: args.resume },
|
||||
})
|
||||
@@ -277,8 +250,7 @@ Use \`background_output\` with task_id="${task.id}" to check progress.`
|
||||
return `❌ No assistant response found.\n\nSession ID: ${args.resume}`
|
||||
}
|
||||
|
||||
// Extract text from both "text" and "reasoning" parts (thinking models use "reasoning")
|
||||
const textParts = lastMessage?.parts?.filter((p) => p.type === "text" || p.type === "reasoning") ?? []
|
||||
const textParts = lastMessage?.parts?.filter((p) => p.type === "text") ?? []
|
||||
const textContent = textParts.map((p) => p.text ?? "").filter(Boolean).join("\n")
|
||||
|
||||
const duration = formatDuration(startTime)
|
||||
@@ -418,13 +390,13 @@ System notifies on completion. Use \`background_output\` with task_id="${task.id
|
||||
metadata: { sessionId: sessionID, category: args.category, sync: true },
|
||||
})
|
||||
|
||||
// Use fire-and-forget prompt() - awaiting causes JSON parse errors with thinking models
|
||||
// Note: Don't pass model in body - use agent's configured model instead
|
||||
// Use promptAsync to avoid changing main session's active state
|
||||
let promptError: Error | undefined
|
||||
client.session.prompt({
|
||||
await client.session.promptAsync({
|
||||
path: { id: sessionID },
|
||||
body: {
|
||||
agent: agentToUse,
|
||||
model: categoryModel,
|
||||
system: systemContent,
|
||||
tools: {
|
||||
task: false,
|
||||
@@ -436,9 +408,6 @@ System notifies on completion. Use \`background_output\` with task_id="${task.id
|
||||
promptError = error instanceof Error ? error : new Error(String(error))
|
||||
})
|
||||
|
||||
// Small delay to let the prompt start
|
||||
await new Promise(resolve => setTimeout(resolve, 100))
|
||||
|
||||
if (promptError) {
|
||||
if (toastManager && taskId !== undefined) {
|
||||
toastManager.removeTask(taskId)
|
||||
@@ -450,63 +419,21 @@ System notifies on completion. Use \`background_output\` with task_id="${task.id
|
||||
return `❌ Failed to send prompt: ${errorMessage}\n\nSession ID: ${sessionID}`
|
||||
}
|
||||
|
||||
// Poll for session completion with stability detection
|
||||
// The session may show as "idle" before messages appear, so we also check message stability
|
||||
// Poll for session completion
|
||||
const POLL_INTERVAL_MS = 500
|
||||
const MAX_POLL_TIME_MS = 10 * 60 * 1000
|
||||
const MIN_STABILITY_TIME_MS = 10000 // Minimum 10s before accepting completion
|
||||
const STABILITY_POLLS_REQUIRED = 3
|
||||
const pollStart = Date.now()
|
||||
let lastMsgCount = 0
|
||||
let stablePolls = 0
|
||||
|
||||
while (Date.now() - pollStart < MAX_POLL_TIME_MS) {
|
||||
await new Promise(resolve => setTimeout(resolve, POLL_INTERVAL_MS))
|
||||
|
||||
// Check for async errors that may have occurred after the initial 100ms delay
|
||||
// TypeScript doesn't understand async mutation, so we cast to check
|
||||
const asyncError = promptError as Error | undefined
|
||||
if (asyncError) {
|
||||
if (toastManager && taskId !== undefined) {
|
||||
toastManager.removeTask(taskId)
|
||||
}
|
||||
const errorMessage = asyncError.message
|
||||
if (errorMessage.includes("agent.name") || errorMessage.includes("undefined")) {
|
||||
return `❌ Agent "${agentToUse}" not found. Make sure the agent is registered in your opencode.json or provided by a plugin.\n\nSession ID: ${sessionID}`
|
||||
}
|
||||
return `❌ Failed to send prompt: ${errorMessage}\n\nSession ID: ${sessionID}`
|
||||
}
|
||||
|
||||
const statusResult = await client.session.status()
|
||||
const allStatuses = (statusResult.data ?? {}) as Record<string, { type: string }>
|
||||
const sessionStatus = allStatuses[sessionID]
|
||||
|
||||
// If session is actively running, reset stability
|
||||
if (sessionStatus && sessionStatus.type !== "idle") {
|
||||
stablePolls = 0
|
||||
lastMsgCount = 0
|
||||
continue
|
||||
}
|
||||
|
||||
// Session is idle or not in status - check message stability
|
||||
const elapsed = Date.now() - pollStart
|
||||
if (elapsed < MIN_STABILITY_TIME_MS) {
|
||||
continue // Don't accept completion too early
|
||||
}
|
||||
|
||||
// Get current message count
|
||||
const messagesCheck = await client.session.messages({ path: { id: sessionID } })
|
||||
const msgs = ((messagesCheck as { data?: unknown }).data ?? messagesCheck) as Array<unknown>
|
||||
const currentMsgCount = msgs.length
|
||||
|
||||
if (currentMsgCount > 0 && currentMsgCount === lastMsgCount) {
|
||||
stablePolls++
|
||||
if (stablePolls >= STABILITY_POLLS_REQUIRED) {
|
||||
break // Messages stable for 3 polls - task complete
|
||||
}
|
||||
} else {
|
||||
stablePolls = 0
|
||||
lastMsgCount = currentMsgCount
|
||||
// Break if session is idle OR no longer in status (completed and removed)
|
||||
if (!sessionStatus || sessionStatus.type === "idle") {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -532,8 +459,7 @@ System notifies on completion. Use \`background_output\` with task_id="${task.id
|
||||
return `❌ No assistant response found.\n\nSession ID: ${sessionID}`
|
||||
}
|
||||
|
||||
// Extract text from both "text" and "reasoning" parts (thinking models use "reasoning")
|
||||
const textParts = lastMessage?.parts?.filter((p) => p.type === "text" || p.type === "reasoning") ?? []
|
||||
const textParts = lastMessage?.parts?.filter((p) => p.type === "text") ?? []
|
||||
const textContent = textParts.map((p) => p.text ?? "").filter(Boolean).join("\n")
|
||||
|
||||
const duration = formatDuration(startTime)
|
||||
|
||||
@@ -194,4 +194,4 @@ export function createSkillTool(options: SkillLoadOptions = {}): ToolDefinition
|
||||
})
|
||||
}
|
||||
|
||||
export const skill: ToolDefinition = createSkillTool()
|
||||
export const skill = createSkillTool()
|
||||
|
||||
@@ -249,4 +249,4 @@ export function createSlashcommandTool(options: SlashcommandToolOptions = {}): T
|
||||
}
|
||||
|
||||
// Default instance for backward compatibility (lazy loading)
|
||||
export const slashcommand: ToolDefinition = createSlashcommandTool()
|
||||
export const slashcommand = createSlashcommandTool()
|
||||
|
||||
Reference in New Issue
Block a user