oh-my-opencode 2.13.0 → 2.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.ja.md CHANGED
@@ -189,13 +189,15 @@ Windows から Linux に初めて乗り換えた時のこと、自分の思い
189
189
 
190
190
  インストールするだけで、エージェントは以下のようなワークフローで働けるようになります:
191
191
 
192
- 1. バックグラウンドタスクとして Gemini 3 Pro にフロントエンドを書かせている間に、Claude Opus 4.5 がバックエンドを作成し、デバッグで詰まったら GPT 5.2 に助けを求めます。フロントエンドの実装完了報告が来たら、それを検証して出荷します。
193
- 2. 何か調べる必要があれば、公式ドキュメント、コードベースの全履歴、GitHub に公開されている実装例まで徹底的に調査します。単なる grep だけでなく、内蔵された LSP ツールや AST-Grep まで駆使します。
194
- 3. LLM に仕事を任せる際、コンテキスト管理の心配はもう不要です。私がやります。
195
- - OhMyOpenCode は複数のエージェントを積極的に活用し、コンテキストの負荷を軽減します。
196
- - **あなたのエージェントは今や開発チームのリードです。あなたは AI マネージャーです。**
197
- 4. 頼んだ仕事が完了するまで止まりません。
198
- 5. このプロジェクトについて深く知りたくない?大丈夫です。ただ 'ultrathink' と入力してください。
192
+ 1. Sisyphusは自分自身でファイルを探し回るような時間の無駄はしません。メインエージェントのコンテキストを軽量に保つため、より高速で安価なモデルへ並列でバックグラウンドタスクを飛ばし、自身の代わりに領域の調査を完了させます。
193
+ 1. SisyphusはリファクタリングにLSPを活用します。その方が確実で、安全、かつ的確だからです。
194
+ 1. UIに関わる重い作業が必要な場合、SisyphusはフロントエンドのタスクをGemini 3 Proに直接デリゲートします。
195
+ 1. もしSisyphusがループに陥ったり壁にぶつかったりしても、無駄に悩み続けることはありません。高IQな戦略的バックアップとしてGPT 5.2を呼び出します。
196
+ 1. 複雑なオープンソースフレームワークを扱っていますか?Sisyphusはサブエージェントを生成し、生のソースコードやドキュメントをリアルタイムで消化します。彼は完全なコンテキスト認識を持って動作します。
197
+ 1. Sisyphusがコメントに触れるとき、その存在意義を証明するか、さもなくば削除します。あなたのコードベースを常にクリーンに保ちます。
198
+ 1. Sisyphusは自身のTODOリストに縛られています。もし始めたことを終わらせられなければ、システムは彼を強制的に「bouldering」モードに戻します。あなたのタスクは、何があろうと完了します。
199
+ 1. 正直、ドキュメントなんて読む必要はありません。ただプロンプトを書いてください。「ultrawork」というキーワードを含めるだけで十分です。Sisyphusが構造を分析し、コンテキストを集め、外部のソースコードまで掘り下げ、仕事が100%完了するまでboulderingを続けます。
200
+ 1. ぶっちゃけ、「ultrawork」と打つのすら面倒ですよね。それなら「ulw」だけでOKです。ただulwと打ち、コーヒーでも飲んでいてください。仕事は終わっています。
199
201
 
200
202
  このような機能が不要であれば、前述の通り、特定の機能だけを選んで使うことができます。
201
203
 
package/README.ko.md CHANGED
@@ -186,13 +186,15 @@ OpenCode 가 낭만이 사라진것같은 오늘날의 시대에, 당신에게
186
186
 
187
187
  #### 그저 설치하면 되는 것.
188
188
 
189
- 1. 백그라운드 태스크로 Gemini 3 Pro 프론트엔드를 작성하게 시켜두는 동안, Claude Opus 4.5 백엔드를 작성하고, 디버깅하다 막히면 GPT 5.2 에게 도움을 받습니다. 프론트엔드 구현이 완료되었다고 보고받으면, 이를 다시 확인하고 일하게 만들 수 있습니다.
190
- 2. 뭔가 찾아볼 일이 생기면 공식문서, 코드베이스의 모든 히스토리, GitHub 에 공개된 현재 구현 현황까지 다 뒤져보고, 단순 Grep 을 넘어 내장된 LSP 도구, AstGrep 까지 사용하여 답변을 제공합니다.
191
- 3. LLM 에게 일을 맡길때에 컨텍스트에 대한 걱정은 이상 하지마세요. 제가 하겠습니다.
192
- - OhMyOpenCode 여러 에이전트를 적극 활용하도록 하여 컨텍스트 관리에 관한 부담을 줄입니다.
193
- - **당신의 에이전트는 이제 개발팀 리드입니다. 당신은 이제 AI Manager 입니다.**
194
- 4. 하기로 약속 일을 완수 까지 멈추지 않습니다.
195
- 5. 프로젝트에 자세히 알기 싫다고요? 괜찮습니다. 그냥 'ultrawork' 라고 치세요.
189
+ 1. 시지푸스는 직접 파일을 찾아다니며 시간을 낭비하지 않습니다. 메인 에이전트의 컨텍스트를 가볍게 유지하기 위해, 빠르고 저렴한 모델들에게 병렬로 백그라운드 태스크를 실행시켜 지형지물을 파악하게 합니다.
190
+ 1. 시지푸스는 LSP를 활용해 리팩토링을 수행합니다. 이는 훨씬 결정론적이고 안전하며 정교합니다.
191
+ 1. UI 작업이 필요한 고난도 태스크를 마주하면, 시지푸스는 프론트엔드 작업을 Gemini 3 Pro에게 직접 위임합니다.
192
+ 1. 루프에 갇히거나 한계에 부딪히면 시지푸스는 무의미하게 반복하지 않습니다. High-IQ 전략적 백업을 위해 GPT 5.2를 호출합니다.
193
+ 1. 복잡한 오픈소스 프레임워크를 다루시나요? 시지푸스는 서브에이전트들을 생성해 소스 코드와 문서를 실시간으로 파악합니다. 완벽한 컨텍스트 인지를 바탕으로 작동합니다.
194
+ 1. 시지푸스는 주석을 건드릴 존재 이유를 증명하거나, 아니면 그냥 날려버립니다. 당신의 코드베이스를 깨끗하게 유지합니다.
195
+ 1. 시지푸스는 본인의 TODO 리스트에 귀속됩니다. 시작한 일을 끝내지 못하면 시스템이 그를 다시 "bouldering" 모드로 강제 소환합니다. 작업은 무조건 완료됩니다.
196
+ 1. 솔직히 문서 읽을 필요도 없습니다. 그냥 프롬프트를 작성하세요. 'ultrawork' 키워드를 포함하기만 하면 됩니다. 시지푸스가 구조를 분석하고, 컨텍스트를 수집하고, 외부 소스 코드를 파헤치며 작업이 100% 완료될 때까지 계속 bouldering을 이어갈 것입니다.
197
+ 1. 사실 'ultrawork'라고 타이핑하는 것도 일입니다. 그냥 'ulw'라고 치세요. 딱 ulw 세 글자면 됩니다. 그리고 커피나 한잔하세요. 작업은 이미 끝났습니다.
196
198
 
197
199
  그러나 이러한 작업이 싫다면, 말했듯 특정한 기능만 가져가 사용 할 수 있습니다.
198
200
 
package/README.md CHANGED
@@ -128,8 +128,7 @@ No stupid token consumption massive subagents here. No bloat tools here.
128
128
 
129
129
  # Oh My OpenCode
130
130
 
131
- oMoMoMoMoMo···
132
-
131
+ Meet Sisyphus: The Batteries-Included Agent that codes like you.
133
132
 
134
133
  [Claude Code](https://www.claude.com/product/claude-code) is great.
135
134
  But if you're a hacker, you'll fall head over heels for [OpenCode](https://github.com/sst/opencode).
@@ -197,8 +196,17 @@ Meet our main agent: Sisyphus (Opus 4.5 High). Below are the tools Sisyphus uses
197
196
 
198
197
  Just by installing this, you make your agents to work like:
199
198
 
200
- 1. While Gemini 3 Pro writes the frontend as a background task, Claude Opus 4.5 handles the backend. Stuck debugging? Call GPT 5.2 for help. When the frontend reports done, verify and ship.
201
- 2. Need to look something up? It scours official docs, your entire codebase history, and public GitHub implementations—using not just grep but built-in LSP tools and AST-Grep.
199
+ 1. Sisyphus doesn't waste time hunting for files himself; he keeps the main agent's context lean. Instead, he fires off background tasks to faster, cheaper models in parallel to map the territory for him.
200
+ 1. Sisyphus leverages LSP for refactoring; it's more deterministic, safer, and surgical.
201
+ 1. When the heavy lifting requires a UI touch, Sisyphus delegates frontend tasks directly to Gemini 3 Pro.
202
+ 1. If Sisyphus gets stuck in a loop or hits a wall, he doesn't keep banging his head—he calls GPT 5.2 for high-IQ strategic backup.
203
+ 1. Working with a complex open-source framework? Sisyphus spawns subagents to digest the raw source code and documentation in real-time. He operates with total contextual awareness.
204
+ 1. When Sisyphus touches comments, he either justifies their existence or nukes them. He keeps your codebase clean.
205
+ 1. Sisyphus is bound by his TODO list. If he doesn't finish what he started, the system forces him back into "bouldering" mode. Your task gets done, period.
206
+ 1. Honestly, don't even bother reading the docs. Just write your prompt. Include the 'ultrawork' keyword. Sisyphus will analyze the structure, gather the context, dig through external source code, and just keep bouldering until the job is 100% complete.
207
+ 1. Actually, typing 'ultrawork' is too much effort. Just type 'ulw'. Just ulw. Sip your coffee. Your work is done.
208
+
209
+ Need to look something up? It scours official docs, your entire codebase history, and public GitHub implementations—using not just grep but built-in LSP tools and AST-Grep.
202
210
  3. Stop worrying about context management when delegating to LLMs. I've got it covered.
203
211
  - OhMyOpenCode aggressively leverages multiple agents to lighten the context load.
204
212
  - **Your agent is now the dev team lead. You're the AI Manager.**
package/README.zh-cn.md CHANGED
@@ -191,13 +191,15 @@ oMoMoMoMoMo···
191
191
 
192
192
  装完之后,你的 Agent 画风是这样的:
193
193
 
194
- 1. 后台让 Gemini 3 Pro 写前端,Claude Opus 4.5 同时在写后端。调试卡住了?喊 GPT 5.2 过来救场。前端说搞定了,你验货,上线。
195
- 2. 要查资料?它会把官方文档、整个代码历史、GitHub 上的公开实现翻个底朝天——靠的不只是 grep,还有内置 LSP 和 AST-Grep。
196
- 3. 别再操心什么上下文管理了。我包了。
197
- - OhMyOpenCode 疯狂压榨多个 Agent,把上下文负担降到最低。
198
- - **现在的 Agent 才是开发组长,你?你是 AI 经理。**
199
- 4. 活儿没干完,绝对不收工。
200
- 5. 不想研究这么深?没事。输入 "ultrathink" 就完事了。
194
+ 1. Sisyphus 从不把时间浪费在苦哈哈地找文件上,他时刻保持主 Agent Context 精简干练。相反,他会并行启动一堆又快又便宜的背景任务模型,帮他先探路,摸清代码全貌。
195
+ 1. Sisyphus 善用 LSP 进行重构;这种方式更具确定性,更安全,且手术刀般精准。
196
+ 1. 遇到需要 UI 润色的重活儿时,Sisyphus 会直接把前端任务甩给 Gemini 3 Pro 处理。
197
+ 1. 如果 Sisyphus 陷入死循环或碰了壁,他绝不会在那儿死磕——他会呼叫 GPT 5.2 提供高智商的战略支援。
198
+ 1. 在处理复杂的开源框架?Sisyphus 会派生出 Subagents 实时消化源码和文档。他是在拥有全局 Context 意识的情况下进行操作的。
199
+ 1. 当 Sisyphus 动到注释时,他要么证明其存在的价值,要么直接干掉。他只负责保持你的代码库干净整洁。
200
+ 1. Sisyphus 受 TODO 列表的绝对约束。如果活儿没干完,系统会强行把他踢回"推石头(bouldering)"模式。一句话,任务必须搞定。
201
+ 1. 说实话,连文档都别费劲读了。直接写你的 Prompt,带上 'ultrawork' 关键字。Sisyphus 会自动分析结构、抓取 Context、深度挖掘外部源码,然后就这么一直"推石头",直到任务 100% 彻底完成。
202
+ 1. 其实,输入 'ultrawork' 都挺费劲的。直接打 'ulw' 就行。就打 ulw。喝你的咖啡去吧,活儿已经帮你干完了。
201
203
 
202
204
  如果你不需要这全套服务,前面说了,挑你喜欢的用。
203
205
 
package/dist/cli/index.js CHANGED
@@ -2657,7 +2657,7 @@ var require_napi = __commonJS((exports, module) => {
2657
2657
  var require_package = __commonJS((exports, module) => {
2658
2658
  module.exports = {
2659
2659
  name: "oh-my-opencode",
2660
- version: "2.12.4",
2660
+ version: "2.13.0",
2661
2661
  description: "OpenCode plugin - custom agents (oracle, librarian) and enhanced features",
2662
2662
  main: "dist/index.js",
2663
2663
  types: "dist/index.d.ts",
@@ -0,0 +1 @@
1
+ export declare const REFACTOR_TEMPLATE = "# Intelligent Refactor Command\n\n## Usage\n```\n/refactor <refactoring-target> [--scope=<file|module|project>] [--strategy=<safe|aggressive>]\n\nArguments:\n refactoring-target: What to refactor. Can be:\n - File path: src/auth/handler.ts\n - Symbol name: \"AuthService class\"\n - Pattern: \"all functions using deprecated API\"\n - Description: \"extract validation logic into separate module\"\n\nOptions:\n --scope: Refactoring scope (default: module)\n - file: Single file only\n - module: Module/directory scope\n - project: Entire codebase\n\n --strategy: Risk tolerance (default: safe)\n - safe: Conservative, maximum test coverage required\n - aggressive: Allow broader changes with adequate coverage\n```\n\n## What This Command Does\n\nPerforms intelligent, deterministic refactoring with full codebase awareness. Unlike blind search-and-replace, this command:\n\n1. **Understands your intent** - Analyzes what you actually want to achieve\n2. **Maps the codebase** - Builds a definitive codemap before touching anything\n3. **Assesses risk** - Evaluates test coverage and determines verification strategy\n4. **Plans meticulously** - Creates a detailed plan with Plan agent\n5. **Executes precisely** - Step-by-step refactoring with LSP and AST-grep\n6. **Verifies constantly** - Runs tests after each change to ensure zero regression\n\n---\n\n# PHASE 0: INTENT GATE (MANDATORY FIRST STEP)\n\n**BEFORE ANY ACTION, classify and validate the request.**\n\n## Step 0.1: Parse Request Type\n\n| Signal | Classification | Action |\n|--------|----------------|--------|\n| Specific file/symbol | Explicit | Proceed to codebase analysis |\n| \"Refactor X to Y\" | Clear transformation | Proceed to codebase analysis |\n| \"Improve\", \"Clean up\" | Open-ended | **MUST ask**: \"What specific improvement?\" |\n| Ambiguous scope | Uncertain | **MUST ask**: \"Which modules/files?\" |\n| Missing context | Incomplete | **MUST ask**: \"What's the desired outcome?\" |\n\n## Step 0.2: Validate Understanding\n\nBefore proceeding, confirm:\n- [ ] Target is clearly identified\n- [ ] Desired outcome is understood\n- [ ] Scope is defined (file/module/project)\n- [ ] Success criteria can be articulated\n\n**If ANY of above is unclear, ASK CLARIFYING QUESTION:**\n\n```\nI want to make sure I understand the refactoring goal correctly.\n\n**What I understood**: [interpretation]\n**What I'm unsure about**: [specific ambiguity]\n\nOptions I see:\n1. [Option A] - [implications]\n2. [Option B] - [implications]\n\n**My recommendation**: [suggestion with reasoning]\n\nShould I proceed with [recommendation], or would you prefer differently?\n```\n\n## Step 0.3: Create Initial Todos\n\n**IMMEDIATELY after understanding the request, create todos:**\n\n```\nTodoWrite([\n {\"id\": \"phase-1\", \"content\": \"PHASE 1: Codebase Analysis - launch parallel explore agents\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"phase-2\", \"content\": \"PHASE 2: Build Codemap - map dependencies and impact zones\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"phase-3\", \"content\": \"PHASE 3: Test Assessment - analyze test coverage and verification strategy\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"phase-4\", \"content\": \"PHASE 4: Plan Generation - invoke Plan agent for detailed refactoring plan\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"phase-5\", \"content\": \"PHASE 5: Execute Refactoring - step-by-step with continuous verification\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"phase-6\", \"content\": \"PHASE 6: Final Verification - full test suite and regression check\", \"status\": \"pending\", \"priority\": \"high\"}\n])\n```\n\n---\n\n# PHASE 1: CODEBASE ANALYSIS (PARALLEL EXPLORATION)\n\n**Mark phase-1 as in_progress.**\n\n## 1.1: Launch Parallel Explore Agents (BACKGROUND)\n\nFire ALL of these simultaneously using `call_omo_agent`:\n\n```\n// Agent 1: Find the refactoring target\ncall_omo_agent(\n subagent_type=\"explore\",\n run_in_background=true,\n prompt=\"Find all occurrences and definitions of [TARGET]. \n Report: file paths, line numbers, usage patterns.\"\n)\n\n// Agent 2: Find related code\ncall_omo_agent(\n subagent_type=\"explore\", \n run_in_background=true,\n prompt=\"Find all code that imports, uses, or depends on [TARGET].\n Report: dependency chains, import graphs.\"\n)\n\n// Agent 3: Find similar patterns\ncall_omo_agent(\n subagent_type=\"explore\",\n run_in_background=true,\n prompt=\"Find similar code patterns to [TARGET] in the codebase.\n Report: analogous implementations, established conventions.\"\n)\n\n// Agent 4: Find tests\ncall_omo_agent(\n subagent_type=\"explore\",\n run_in_background=true,\n prompt=\"Find all test files related to [TARGET].\n Report: test file paths, test case names, coverage indicators.\"\n)\n\n// Agent 5: Architecture context\ncall_omo_agent(\n subagent_type=\"explore\",\n run_in_background=true,\n prompt=\"Find architectural patterns and module organization around [TARGET].\n Report: module boundaries, layer structure, design patterns in use.\"\n)\n```\n\n## 1.2: Direct Tool Exploration (WHILE AGENTS RUN)\n\nWhile background agents are running, use direct tools:\n\n### LSP Tools for Precise Analysis:\n\n```typescript\n// Get symbol information at target location\nlsp_hover(filePath, line, character) // Type info, docs, signatures\n\n// Find definition(s)\nlsp_goto_definition(filePath, line, character) // Where is it defined?\n\n// Find ALL usages across workspace\nlsp_find_references(filePath, line, character, includeDeclaration=true)\n\n// Get file structure\nlsp_document_symbols(filePath) // Hierarchical outline\n\n// Search symbols by name\nlsp_workspace_symbols(filePath, query=\"[target_symbol]\")\n\n// Get current diagnostics\nlsp_diagnostics(filePath) // Errors, warnings before we start\n```\n\n### AST-Grep for Pattern Analysis:\n\n```typescript\n// Find structural patterns\nast_grep_search(\n pattern=\"function $NAME($$$) { $$$ }\", // or relevant pattern\n lang=\"typescript\", // or relevant language\n paths=[\"src/\"]\n)\n\n// Preview refactoring (DRY RUN)\nast_grep_replace(\n pattern=\"[old_pattern]\",\n rewrite=\"[new_pattern]\",\n lang=\"[language]\",\n dryRun=true // ALWAYS preview first\n)\n```\n\n### Grep for Text Patterns:\n\n```\ngrep(pattern=\"[search_term]\", path=\"src/\", include=\"*.ts\")\n```\n\n## 1.3: Collect Background Results\n\n```\nbackground_output(task_id=\"[agent_1_id]\")\nbackground_output(task_id=\"[agent_2_id]\")\n...\n```\n\n**Mark phase-1 as completed after all results collected.**\n\n---\n\n# PHASE 2: BUILD CODEMAP (DEPENDENCY MAPPING)\n\n**Mark phase-2 as in_progress.**\n\n## 2.1: Construct Definitive Codemap\n\nBased on Phase 1 results, build:\n\n```\n## CODEMAP: [TARGET]\n\n### Core Files (Direct Impact)\n- `path/to/file.ts:L10-L50` - Primary definition\n- `path/to/file2.ts:L25` - Key usage\n\n### Dependency Graph\n```\n[TARGET] \n\u251C\u2500\u2500 imports from: \n\u2502 \u251C\u2500\u2500 module-a (types)\n\u2502 \u2514\u2500\u2500 module-b (utils)\n\u251C\u2500\u2500 imported by:\n\u2502 \u251C\u2500\u2500 consumer-1.ts\n\u2502 \u251C\u2500\u2500 consumer-2.ts\n\u2502 \u2514\u2500\u2500 consumer-3.ts\n\u2514\u2500\u2500 used by:\n \u251C\u2500\u2500 handler.ts (direct call)\n \u2514\u2500\u2500 service.ts (dependency injection)\n```\n\n### Impact Zones\n| Zone | Risk Level | Files Affected | Test Coverage |\n|------|------------|----------------|---------------|\n| Core | HIGH | 3 files | 85% covered |\n| Consumers | MEDIUM | 8 files | 70% covered |\n| Edge | LOW | 2 files | 50% covered |\n\n### Established Patterns\n- Pattern A: [description] - used in N places\n- Pattern B: [description] - established convention\n```\n\n## 2.2: Identify Refactoring Constraints\n\nBased on codemap:\n- **MUST follow**: [existing patterns identified]\n- **MUST NOT break**: [critical dependencies]\n- **Safe to change**: [isolated code zones]\n- **Requires migration**: [breaking changes impact]\n\n**Mark phase-2 as completed.**\n\n---\n\n# PHASE 3: TEST ASSESSMENT (VERIFICATION STRATEGY)\n\n**Mark phase-3 as in_progress.**\n\n## 3.1: Detect Test Infrastructure\n\n```bash\n# Check for test commands\ncat package.json | jq '.scripts | keys[] | select(test(\"test\"))'\n\n# Or for Python\nls -la pytest.ini pyproject.toml setup.cfg\n\n# Or for Go\nls -la *_test.go\n```\n\n## 3.2: Analyze Test Coverage\n\n```\n// Find all tests related to target\ncall_omo_agent(\n subagent_type=\"explore\",\n run_in_background=false, // Need this synchronously\n prompt=\"Analyze test coverage for [TARGET]:\n 1. Which test files cover this code?\n 2. What test cases exist?\n 3. Are there integration tests?\n 4. What edge cases are tested?\n 5. Estimated coverage percentage?\"\n)\n```\n\n## 3.3: Determine Verification Strategy\n\nBased on test analysis:\n\n| Coverage Level | Strategy |\n|----------------|----------|\n| HIGH (>80%) | Run existing tests after each step |\n| MEDIUM (50-80%) | Run tests + add safety assertions |\n| LOW (<50%) | **PAUSE**: Propose adding tests first |\n| NONE | **BLOCK**: Refuse aggressive refactoring |\n\n**If coverage is LOW or NONE, ask user:**\n\n```\nTest coverage for [TARGET] is [LEVEL].\n\n**Risk Assessment**: Refactoring without adequate tests is dangerous.\n\nOptions:\n1. Add tests first, then refactor (RECOMMENDED)\n2. Proceed with extra caution, manual verification required\n3. Abort refactoring\n\nWhich approach do you prefer?\n```\n\n## 3.4: Document Verification Plan\n\n```\n## VERIFICATION PLAN\n\n### Test Commands\n- Unit: `bun test` / `npm test` / `pytest` / etc.\n- Integration: [command if exists]\n- Type check: `tsc --noEmit` / `pyright` / etc.\n\n### Verification Checkpoints\nAfter each refactoring step:\n1. lsp_diagnostics \u2192 zero new errors\n2. Run test command \u2192 all pass\n3. Type check \u2192 clean\n\n### Regression Indicators\n- [Specific test that must pass]\n- [Behavior that must be preserved]\n- [API contract that must not change]\n```\n\n**Mark phase-3 as completed.**\n\n---\n\n# PHASE 4: PLAN GENERATION (PLAN AGENT)\n\n**Mark phase-4 as in_progress.**\n\n## 4.1: Invoke Plan Agent\n\n```\nTask(\n subagent_type=\"plan\",\n prompt=\"Create a detailed refactoring plan:\n\n ## Refactoring Goal\n [User's original request]\n\n ## Codemap (from Phase 2)\n [Insert codemap here]\n\n ## Test Coverage (from Phase 3)\n [Insert verification plan here]\n\n ## Constraints\n - MUST follow existing patterns: [list]\n - MUST NOT break: [critical paths]\n - MUST run tests after each step\n\n ## Requirements\n 1. Break down into atomic refactoring steps\n 2. Each step must be independently verifiable\n 3. Order steps by dependency (what must happen first)\n 4. Specify exact files and line ranges for each step\n 5. Include rollback strategy for each step\n 6. Define commit checkpoints\"\n)\n```\n\n## 4.2: Review and Validate Plan\n\nAfter receiving plan from Plan agent:\n\n1. **Verify completeness**: All identified files addressed?\n2. **Verify safety**: Each step reversible?\n3. **Verify order**: Dependencies respected?\n4. **Verify verification**: Test commands specified?\n\n## 4.3: Register Detailed Todos\n\nConvert Plan agent output into granular todos:\n\n```\nTodoWrite([\n // Each step from the plan becomes a todo\n {\"id\": \"refactor-1\", \"content\": \"Step 1: [description]\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"verify-1\", \"content\": \"Verify Step 1: run tests\", \"status\": \"pending\", \"priority\": \"high\"},\n {\"id\": \"refactor-2\", \"content\": \"Step 2: [description]\", \"status\": \"pending\", \"priority\": \"medium\"},\n {\"id\": \"verify-2\", \"content\": \"Verify Step 2: run tests\", \"status\": \"pending\", \"priority\": \"medium\"},\n // ... continue for all steps\n])\n```\n\n**Mark phase-4 as completed.**\n\n---\n\n# PHASE 5: EXECUTE REFACTORING (DETERMINISTIC EXECUTION)\n\n**Mark phase-5 as in_progress.**\n\n## 5.1: Execution Protocol\n\nFor EACH refactoring step:\n\n### Pre-Step\n1. Mark step todo as `in_progress`\n2. Read current file state\n3. Verify lsp_diagnostics is baseline\n\n### Execute Step\nUse appropriate tool:\n\n**For Symbol Renames:**\n```typescript\nlsp_prepare_rename(filePath, line, character) // Validate rename is possible\nlsp_rename(filePath, line, character, newName) // Execute rename\n```\n\n**For Pattern Transformations:**\n```typescript\n// Preview first\nast_grep_replace(pattern, rewrite, lang, dryRun=true)\n\n// If preview looks good, execute\nast_grep_replace(pattern, rewrite, lang, dryRun=false)\n```\n\n**For Structural Changes:**\n```typescript\n// Use Edit tool for precise changes\nedit(filePath, oldString, newString)\n```\n\n### Post-Step Verification (MANDATORY)\n\n```typescript\n// 1. Check diagnostics\nlsp_diagnostics(filePath) // Must be clean or same as baseline\n\n// 2. Run tests\nbash(\"bun test\") // Or appropriate test command\n\n// 3. Type check\nbash(\"tsc --noEmit\") // Or appropriate type check\n```\n\n### Step Completion\n1. If verification passes \u2192 Mark step todo as `completed`\n2. If verification fails \u2192 **STOP AND FIX**\n\n## 5.2: Failure Recovery Protocol\n\nIf ANY verification fails:\n\n1. **STOP** immediately\n2. **REVERT** the failed change\n3. **DIAGNOSE** what went wrong\n4. **OPTIONS**:\n - Fix the issue and retry\n - Skip this step (if optional)\n - Consult oracle agent for help\n - Ask user for guidance\n\n**NEVER proceed to next step with broken tests.**\n\n## 5.3: Commit Checkpoints\n\nAfter each logical group of changes:\n\n```bash\ngit add [changed-files]\ngit commit -m \"refactor(scope): description\n\n[details of what was changed and why]\"\n```\n\n**Mark phase-5 as completed when all refactoring steps done.**\n\n---\n\n# PHASE 6: FINAL VERIFICATION (REGRESSION CHECK)\n\n**Mark phase-6 as in_progress.**\n\n## 6.1: Full Test Suite\n\n```bash\n# Run complete test suite\nbun test # or npm test, pytest, go test, etc.\n```\n\n## 6.2: Type Check\n\n```bash\n# Full type check\ntsc --noEmit # or equivalent\n```\n\n## 6.3: Lint Check\n\n```bash\n# Run linter\neslint . # or equivalent\n```\n\n## 6.4: Build Verification (if applicable)\n\n```bash\n# Ensure build still works\nbun run build # or npm run build, etc.\n```\n\n## 6.5: Final Diagnostics\n\n```typescript\n// Check all changed files\nfor (file of changedFiles) {\n lsp_diagnostics(file) // Must all be clean\n}\n```\n\n## 6.6: Generate Summary\n\n```markdown\n## Refactoring Complete\n\n### What Changed\n- [List of changes made]\n\n### Files Modified\n- `path/to/file.ts` - [what changed]\n- `path/to/file2.ts` - [what changed]\n\n### Verification Results\n- Tests: PASSED (X/Y passing)\n- Type Check: CLEAN\n- Lint: CLEAN\n- Build: SUCCESS\n\n### No Regressions Detected\nAll existing tests pass. No new errors introduced.\n```\n\n**Mark phase-6 as completed.**\n\n---\n\n# CRITICAL RULES\n\n## NEVER DO\n- Skip lsp_diagnostics check after changes\n- Proceed with failing tests\n- Make changes without understanding impact\n- Use `as any`, `@ts-ignore`, `@ts-expect-error`\n- Delete tests to make them pass\n- Commit broken code\n- Refactor without understanding existing patterns\n\n## ALWAYS DO\n- Understand before changing\n- Preview before applying (ast_grep dryRun=true)\n- Verify after every change\n- Follow existing codebase patterns\n- Keep todos updated in real-time\n- Commit at logical checkpoints\n- Report issues immediately\n\n## ABORT CONDITIONS\nIf any of these occur, **STOP and consult user**:\n- Test coverage is zero for target code\n- Changes would break public API\n- Refactoring scope is unclear\n- 3 consecutive verification failures\n- User-defined constraints violated\n\n---\n\n# Tool Usage Philosophy\n\nYou already know these tools. Use them intelligently:\n\n## LSP Tools\nLeverage the full LSP toolset (`lsp_*`) for precision analysis. Key patterns:\n- **Understand before changing**: `lsp_hover`, `lsp_goto_definition` to grasp context\n- **Impact analysis**: `lsp_find_references` to map all usages before modification\n- **Safe refactoring**: `lsp_prepare_rename` \u2192 `lsp_rename` for symbol renames\n- **Continuous verification**: `lsp_diagnostics` after every change\n\n## AST-Grep\nUse `ast_grep_search` and `ast_grep_replace` for structural transformations.\n**Critical**: Always `dryRun=true` first, review, then execute.\n\n## Agents\n- `explore`: Parallel codebase pattern discovery\n- `plan`: Detailed refactoring plan generation\n- `oracle`: Consult for complex architectural decisions\n- `librarian`: **Use proactively** when encountering deprecated methods or library migration tasks. Query official docs and OSS examples for modern replacements.\n\n## Deprecated Code & Library Migration\nWhen you encounter deprecated methods/APIs during refactoring:\n1. Fire `librarian` to find the recommended modern alternative\n2. **DO NOT auto-upgrade to latest version** unless user explicitly requests migration\n3. If user requests library migration, use `librarian` to fetch latest API docs before making changes\n\n---\n\n**Remember: Refactoring without tests is reckless. Refactoring without understanding is destructive. This command ensures you do neither.**\n\n<user-request>\n$ARGUMENTS\n</user-request>\n";
@@ -1,5 +1,5 @@
1
1
  import type { CommandDefinition } from "../claude-code-command-loader";
2
- export type BuiltinCommandName = "init-deep" | "ralph-loop" | "cancel-ralph";
2
+ export type BuiltinCommandName = "init-deep" | "ralph-loop" | "cancel-ralph" | "refactor";
3
3
  export interface BuiltinCommandConfig {
4
4
  disabled_commands?: BuiltinCommandName[];
5
5
  }
package/dist/index.js CHANGED
@@ -45667,6 +45667,632 @@ This will:
45667
45667
 
45668
45668
  Check if a loop is active and cancel it. Inform the user of the result.`;
45669
45669
 
45670
+ // src/features/builtin-commands/templates/refactor.ts
45671
+ var REFACTOR_TEMPLATE = `# Intelligent Refactor Command
45672
+
45673
+ ## Usage
45674
+ \`\`\`
45675
+ /refactor <refactoring-target> [--scope=<file|module|project>] [--strategy=<safe|aggressive>]
45676
+
45677
+ Arguments:
45678
+ refactoring-target: What to refactor. Can be:
45679
+ - File path: src/auth/handler.ts
45680
+ - Symbol name: "AuthService class"
45681
+ - Pattern: "all functions using deprecated API"
45682
+ - Description: "extract validation logic into separate module"
45683
+
45684
+ Options:
45685
+ --scope: Refactoring scope (default: module)
45686
+ - file: Single file only
45687
+ - module: Module/directory scope
45688
+ - project: Entire codebase
45689
+
45690
+ --strategy: Risk tolerance (default: safe)
45691
+ - safe: Conservative, maximum test coverage required
45692
+ - aggressive: Allow broader changes with adequate coverage
45693
+ \`\`\`
45694
+
45695
+ ## What This Command Does
45696
+
45697
+ Performs intelligent, deterministic refactoring with full codebase awareness. Unlike blind search-and-replace, this command:
45698
+
45699
+ 1. **Understands your intent** - Analyzes what you actually want to achieve
45700
+ 2. **Maps the codebase** - Builds a definitive codemap before touching anything
45701
+ 3. **Assesses risk** - Evaluates test coverage and determines verification strategy
45702
+ 4. **Plans meticulously** - Creates a detailed plan with Plan agent
45703
+ 5. **Executes precisely** - Step-by-step refactoring with LSP and AST-grep
45704
+ 6. **Verifies constantly** - Runs tests after each change to ensure zero regression
45705
+
45706
+ ---
45707
+
45708
+ # PHASE 0: INTENT GATE (MANDATORY FIRST STEP)
45709
+
45710
+ **BEFORE ANY ACTION, classify and validate the request.**
45711
+
45712
+ ## Step 0.1: Parse Request Type
45713
+
45714
+ | Signal | Classification | Action |
45715
+ |--------|----------------|--------|
45716
+ | Specific file/symbol | Explicit | Proceed to codebase analysis |
45717
+ | "Refactor X to Y" | Clear transformation | Proceed to codebase analysis |
45718
+ | "Improve", "Clean up" | Open-ended | **MUST ask**: "What specific improvement?" |
45719
+ | Ambiguous scope | Uncertain | **MUST ask**: "Which modules/files?" |
45720
+ | Missing context | Incomplete | **MUST ask**: "What's the desired outcome?" |
45721
+
45722
+ ## Step 0.2: Validate Understanding
45723
+
45724
+ Before proceeding, confirm:
45725
+ - [ ] Target is clearly identified
45726
+ - [ ] Desired outcome is understood
45727
+ - [ ] Scope is defined (file/module/project)
45728
+ - [ ] Success criteria can be articulated
45729
+
45730
+ **If ANY of above is unclear, ASK CLARIFYING QUESTION:**
45731
+
45732
+ \`\`\`
45733
+ I want to make sure I understand the refactoring goal correctly.
45734
+
45735
+ **What I understood**: [interpretation]
45736
+ **What I'm unsure about**: [specific ambiguity]
45737
+
45738
+ Options I see:
45739
+ 1. [Option A] - [implications]
45740
+ 2. [Option B] - [implications]
45741
+
45742
+ **My recommendation**: [suggestion with reasoning]
45743
+
45744
+ Should I proceed with [recommendation], or would you prefer differently?
45745
+ \`\`\`
45746
+
45747
+ ## Step 0.3: Create Initial Todos
45748
+
45749
+ **IMMEDIATELY after understanding the request, create todos:**
45750
+
45751
+ \`\`\`
45752
+ TodoWrite([
45753
+ {"id": "phase-1", "content": "PHASE 1: Codebase Analysis - launch parallel explore agents", "status": "pending", "priority": "high"},
45754
+ {"id": "phase-2", "content": "PHASE 2: Build Codemap - map dependencies and impact zones", "status": "pending", "priority": "high"},
45755
+ {"id": "phase-3", "content": "PHASE 3: Test Assessment - analyze test coverage and verification strategy", "status": "pending", "priority": "high"},
45756
+ {"id": "phase-4", "content": "PHASE 4: Plan Generation - invoke Plan agent for detailed refactoring plan", "status": "pending", "priority": "high"},
45757
+ {"id": "phase-5", "content": "PHASE 5: Execute Refactoring - step-by-step with continuous verification", "status": "pending", "priority": "high"},
45758
+ {"id": "phase-6", "content": "PHASE 6: Final Verification - full test suite and regression check", "status": "pending", "priority": "high"}
45759
+ ])
45760
+ \`\`\`
45761
+
45762
+ ---
45763
+
45764
+ # PHASE 1: CODEBASE ANALYSIS (PARALLEL EXPLORATION)
45765
+
45766
+ **Mark phase-1 as in_progress.**
45767
+
45768
+ ## 1.1: Launch Parallel Explore Agents (BACKGROUND)
45769
+
45770
+ Fire ALL of these simultaneously using \`call_omo_agent\`:
45771
+
45772
+ \`\`\`
45773
+ // Agent 1: Find the refactoring target
45774
+ call_omo_agent(
45775
+ subagent_type="explore",
45776
+ run_in_background=true,
45777
+ prompt="Find all occurrences and definitions of [TARGET].
45778
+ Report: file paths, line numbers, usage patterns."
45779
+ )
45780
+
45781
+ // Agent 2: Find related code
45782
+ call_omo_agent(
45783
+ subagent_type="explore",
45784
+ run_in_background=true,
45785
+ prompt="Find all code that imports, uses, or depends on [TARGET].
45786
+ Report: dependency chains, import graphs."
45787
+ )
45788
+
45789
+ // Agent 3: Find similar patterns
45790
+ call_omo_agent(
45791
+ subagent_type="explore",
45792
+ run_in_background=true,
45793
+ prompt="Find similar code patterns to [TARGET] in the codebase.
45794
+ Report: analogous implementations, established conventions."
45795
+ )
45796
+
45797
+ // Agent 4: Find tests
45798
+ call_omo_agent(
45799
+ subagent_type="explore",
45800
+ run_in_background=true,
45801
+ prompt="Find all test files related to [TARGET].
45802
+ Report: test file paths, test case names, coverage indicators."
45803
+ )
45804
+
45805
+ // Agent 5: Architecture context
45806
+ call_omo_agent(
45807
+ subagent_type="explore",
45808
+ run_in_background=true,
45809
+ prompt="Find architectural patterns and module organization around [TARGET].
45810
+ Report: module boundaries, layer structure, design patterns in use."
45811
+ )
45812
+ \`\`\`
45813
+
45814
+ ## 1.2: Direct Tool Exploration (WHILE AGENTS RUN)
45815
+
45816
+ While background agents are running, use direct tools:
45817
+
45818
+ ### LSP Tools for Precise Analysis:
45819
+
45820
+ \`\`\`typescript
45821
+ // Get symbol information at target location
45822
+ lsp_hover(filePath, line, character) // Type info, docs, signatures
45823
+
45824
+ // Find definition(s)
45825
+ lsp_goto_definition(filePath, line, character) // Where is it defined?
45826
+
45827
+ // Find ALL usages across workspace
45828
+ lsp_find_references(filePath, line, character, includeDeclaration=true)
45829
+
45830
+ // Get file structure
45831
+ lsp_document_symbols(filePath) // Hierarchical outline
45832
+
45833
+ // Search symbols by name
45834
+ lsp_workspace_symbols(filePath, query="[target_symbol]")
45835
+
45836
+ // Get current diagnostics
45837
+ lsp_diagnostics(filePath) // Errors, warnings before we start
45838
+ \`\`\`
45839
+
45840
+ ### AST-Grep for Pattern Analysis:
45841
+
45842
+ \`\`\`typescript
45843
+ // Find structural patterns
45844
+ ast_grep_search(
45845
+ pattern="function $NAME($$$) { $$$ }", // or relevant pattern
45846
+ lang="typescript", // or relevant language
45847
+ paths=["src/"]
45848
+ )
45849
+
45850
+ // Preview refactoring (DRY RUN)
45851
+ ast_grep_replace(
45852
+ pattern="[old_pattern]",
45853
+ rewrite="[new_pattern]",
45854
+ lang="[language]",
45855
+ dryRun=true // ALWAYS preview first
45856
+ )
45857
+ \`\`\`
45858
+
45859
+ ### Grep for Text Patterns:
45860
+
45861
+ \`\`\`
45862
+ grep(pattern="[search_term]", path="src/", include="*.ts")
45863
+ \`\`\`
45864
+
45865
+ ## 1.3: Collect Background Results
45866
+
45867
+ \`\`\`
45868
+ background_output(task_id="[agent_1_id]")
45869
+ background_output(task_id="[agent_2_id]")
45870
+ ...
45871
+ \`\`\`
45872
+
45873
+ **Mark phase-1 as completed after all results collected.**
45874
+
45875
+ ---
45876
+
45877
+ # PHASE 2: BUILD CODEMAP (DEPENDENCY MAPPING)
45878
+
45879
+ **Mark phase-2 as in_progress.**
45880
+
45881
+ ## 2.1: Construct Definitive Codemap
45882
+
45883
+ Based on Phase 1 results, build:
45884
+
45885
+ \`\`\`
45886
+ ## CODEMAP: [TARGET]
45887
+
45888
+ ### Core Files (Direct Impact)
45889
+ - \`path/to/file.ts:L10-L50\` - Primary definition
45890
+ - \`path/to/file2.ts:L25\` - Key usage
45891
+
45892
+ ### Dependency Graph
45893
+ \`\`\`
45894
+ [TARGET]
45895
+ \u251C\u2500\u2500 imports from:
45896
+ \u2502 \u251C\u2500\u2500 module-a (types)
45897
+ \u2502 \u2514\u2500\u2500 module-b (utils)
45898
+ \u251C\u2500\u2500 imported by:
45899
+ \u2502 \u251C\u2500\u2500 consumer-1.ts
45900
+ \u2502 \u251C\u2500\u2500 consumer-2.ts
45901
+ \u2502 \u2514\u2500\u2500 consumer-3.ts
45902
+ \u2514\u2500\u2500 used by:
45903
+ \u251C\u2500\u2500 handler.ts (direct call)
45904
+ \u2514\u2500\u2500 service.ts (dependency injection)
45905
+ \`\`\`
45906
+
45907
+ ### Impact Zones
45908
+ | Zone | Risk Level | Files Affected | Test Coverage |
45909
+ |------|------------|----------------|---------------|
45910
+ | Core | HIGH | 3 files | 85% covered |
45911
+ | Consumers | MEDIUM | 8 files | 70% covered |
45912
+ | Edge | LOW | 2 files | 50% covered |
45913
+
45914
+ ### Established Patterns
45915
+ - Pattern A: [description] - used in N places
45916
+ - Pattern B: [description] - established convention
45917
+ \`\`\`
45918
+
45919
+ ## 2.2: Identify Refactoring Constraints
45920
+
45921
+ Based on codemap:
45922
+ - **MUST follow**: [existing patterns identified]
45923
+ - **MUST NOT break**: [critical dependencies]
45924
+ - **Safe to change**: [isolated code zones]
45925
+ - **Requires migration**: [breaking changes impact]
45926
+
45927
+ **Mark phase-2 as completed.**
45928
+
45929
+ ---
45930
+
45931
+ # PHASE 3: TEST ASSESSMENT (VERIFICATION STRATEGY)
45932
+
45933
+ **Mark phase-3 as in_progress.**
45934
+
45935
+ ## 3.1: Detect Test Infrastructure
45936
+
45937
+ \`\`\`bash
45938
+ # Check for test commands
45939
+ cat package.json | jq '.scripts | keys[] | select(test("test"))'
45940
+
45941
+ # Or for Python
45942
+ ls -la pytest.ini pyproject.toml setup.cfg
45943
+
45944
+ # Or for Go
45945
+ ls -la *_test.go
45946
+ \`\`\`
45947
+
45948
+ ## 3.2: Analyze Test Coverage
45949
+
45950
+ \`\`\`
45951
+ // Find all tests related to target
45952
+ call_omo_agent(
45953
+ subagent_type="explore",
45954
+ run_in_background=false, // Need this synchronously
45955
+ prompt="Analyze test coverage for [TARGET]:
45956
+ 1. Which test files cover this code?
45957
+ 2. What test cases exist?
45958
+ 3. Are there integration tests?
45959
+ 4. What edge cases are tested?
45960
+ 5. Estimated coverage percentage?"
45961
+ )
45962
+ \`\`\`
45963
+
45964
+ ## 3.3: Determine Verification Strategy
45965
+
45966
+ Based on test analysis:
45967
+
45968
+ | Coverage Level | Strategy |
45969
+ |----------------|----------|
45970
+ | HIGH (>80%) | Run existing tests after each step |
45971
+ | MEDIUM (50-80%) | Run tests + add safety assertions |
45972
+ | LOW (<50%) | **PAUSE**: Propose adding tests first |
45973
+ | NONE | **BLOCK**: Refuse aggressive refactoring |
45974
+
45975
+ **If coverage is LOW or NONE, ask user:**
45976
+
45977
+ \`\`\`
45978
+ Test coverage for [TARGET] is [LEVEL].
45979
+
45980
+ **Risk Assessment**: Refactoring without adequate tests is dangerous.
45981
+
45982
+ Options:
45983
+ 1. Add tests first, then refactor (RECOMMENDED)
45984
+ 2. Proceed with extra caution, manual verification required
45985
+ 3. Abort refactoring
45986
+
45987
+ Which approach do you prefer?
45988
+ \`\`\`
45989
+
45990
+ ## 3.4: Document Verification Plan
45991
+
45992
+ \`\`\`
45993
+ ## VERIFICATION PLAN
45994
+
45995
+ ### Test Commands
45996
+ - Unit: \`bun test\` / \`npm test\` / \`pytest\` / etc.
45997
+ - Integration: [command if exists]
45998
+ - Type check: \`tsc --noEmit\` / \`pyright\` / etc.
45999
+
46000
+ ### Verification Checkpoints
46001
+ After each refactoring step:
46002
+ 1. lsp_diagnostics \u2192 zero new errors
46003
+ 2. Run test command \u2192 all pass
46004
+ 3. Type check \u2192 clean
46005
+
46006
+ ### Regression Indicators
46007
+ - [Specific test that must pass]
46008
+ - [Behavior that must be preserved]
46009
+ - [API contract that must not change]
46010
+ \`\`\`
46011
+
46012
+ **Mark phase-3 as completed.**
46013
+
46014
+ ---
46015
+
46016
+ # PHASE 4: PLAN GENERATION (PLAN AGENT)
46017
+
46018
+ **Mark phase-4 as in_progress.**
46019
+
46020
+ ## 4.1: Invoke Plan Agent
46021
+
46022
+ \`\`\`
46023
+ Task(
46024
+ subagent_type="plan",
46025
+ prompt="Create a detailed refactoring plan:
46026
+
46027
+ ## Refactoring Goal
46028
+ [User's original request]
46029
+
46030
+ ## Codemap (from Phase 2)
46031
+ [Insert codemap here]
46032
+
46033
+ ## Test Coverage (from Phase 3)
46034
+ [Insert verification plan here]
46035
+
46036
+ ## Constraints
46037
+ - MUST follow existing patterns: [list]
46038
+ - MUST NOT break: [critical paths]
46039
+ - MUST run tests after each step
46040
+
46041
+ ## Requirements
46042
+ 1. Break down into atomic refactoring steps
46043
+ 2. Each step must be independently verifiable
46044
+ 3. Order steps by dependency (what must happen first)
46045
+ 4. Specify exact files and line ranges for each step
46046
+ 5. Include rollback strategy for each step
46047
+ 6. Define commit checkpoints"
46048
+ )
46049
+ \`\`\`
46050
+
46051
+ ## 4.2: Review and Validate Plan
46052
+
46053
+ After receiving plan from Plan agent:
46054
+
46055
+ 1. **Verify completeness**: All identified files addressed?
46056
+ 2. **Verify safety**: Each step reversible?
46057
+ 3. **Verify order**: Dependencies respected?
46058
+ 4. **Verify verification**: Test commands specified?
46059
+
46060
+ ## 4.3: Register Detailed Todos
46061
+
46062
+ Convert Plan agent output into granular todos:
46063
+
46064
+ \`\`\`
46065
+ TodoWrite([
46066
+ // Each step from the plan becomes a todo
46067
+ {"id": "refactor-1", "content": "Step 1: [description]", "status": "pending", "priority": "high"},
46068
+ {"id": "verify-1", "content": "Verify Step 1: run tests", "status": "pending", "priority": "high"},
46069
+ {"id": "refactor-2", "content": "Step 2: [description]", "status": "pending", "priority": "medium"},
46070
+ {"id": "verify-2", "content": "Verify Step 2: run tests", "status": "pending", "priority": "medium"},
46071
+ // ... continue for all steps
46072
+ ])
46073
+ \`\`\`
46074
+
46075
+ **Mark phase-4 as completed.**
46076
+
46077
+ ---
46078
+
46079
+ # PHASE 5: EXECUTE REFACTORING (DETERMINISTIC EXECUTION)
46080
+
46081
+ **Mark phase-5 as in_progress.**
46082
+
46083
+ ## 5.1: Execution Protocol
46084
+
46085
+ For EACH refactoring step:
46086
+
46087
+ ### Pre-Step
46088
+ 1. Mark step todo as \`in_progress\`
46089
+ 2. Read current file state
46090
+ 3. Verify lsp_diagnostics is baseline
46091
+
46092
+ ### Execute Step
46093
+ Use appropriate tool:
46094
+
46095
+ **For Symbol Renames:**
46096
+ \`\`\`typescript
46097
+ lsp_prepare_rename(filePath, line, character) // Validate rename is possible
46098
+ lsp_rename(filePath, line, character, newName) // Execute rename
46099
+ \`\`\`
46100
+
46101
+ **For Pattern Transformations:**
46102
+ \`\`\`typescript
46103
+ // Preview first
46104
+ ast_grep_replace(pattern, rewrite, lang, dryRun=true)
46105
+
46106
+ // If preview looks good, execute
46107
+ ast_grep_replace(pattern, rewrite, lang, dryRun=false)
46108
+ \`\`\`
46109
+
46110
+ **For Structural Changes:**
46111
+ \`\`\`typescript
46112
+ // Use Edit tool for precise changes
46113
+ edit(filePath, oldString, newString)
46114
+ \`\`\`
46115
+
46116
+ ### Post-Step Verification (MANDATORY)
46117
+
46118
+ \`\`\`typescript
46119
+ // 1. Check diagnostics
46120
+ lsp_diagnostics(filePath) // Must be clean or same as baseline
46121
+
46122
+ // 2. Run tests
46123
+ bash("bun test") // Or appropriate test command
46124
+
46125
+ // 3. Type check
46126
+ bash("tsc --noEmit") // Or appropriate type check
46127
+ \`\`\`
46128
+
46129
+ ### Step Completion
46130
+ 1. If verification passes \u2192 Mark step todo as \`completed\`
46131
+ 2. If verification fails \u2192 **STOP AND FIX**
46132
+
46133
+ ## 5.2: Failure Recovery Protocol
46134
+
46135
+ If ANY verification fails:
46136
+
46137
+ 1. **STOP** immediately
46138
+ 2. **REVERT** the failed change
46139
+ 3. **DIAGNOSE** what went wrong
46140
+ 4. **OPTIONS**:
46141
+ - Fix the issue and retry
46142
+ - Skip this step (if optional)
46143
+ - Consult oracle agent for help
46144
+ - Ask user for guidance
46145
+
46146
+ **NEVER proceed to next step with broken tests.**
46147
+
46148
+ ## 5.3: Commit Checkpoints
46149
+
46150
+ After each logical group of changes:
46151
+
46152
+ \`\`\`bash
46153
+ git add [changed-files]
46154
+ git commit -m "refactor(scope): description
46155
+
46156
+ [details of what was changed and why]"
46157
+ \`\`\`
46158
+
46159
+ **Mark phase-5 as completed when all refactoring steps done.**
46160
+
46161
+ ---
46162
+
46163
+ # PHASE 6: FINAL VERIFICATION (REGRESSION CHECK)
46164
+
46165
+ **Mark phase-6 as in_progress.**
46166
+
46167
+ ## 6.1: Full Test Suite
46168
+
46169
+ \`\`\`bash
46170
+ # Run complete test suite
46171
+ bun test # or npm test, pytest, go test, etc.
46172
+ \`\`\`
46173
+
46174
+ ## 6.2: Type Check
46175
+
46176
+ \`\`\`bash
46177
+ # Full type check
46178
+ tsc --noEmit # or equivalent
46179
+ \`\`\`
46180
+
46181
+ ## 6.3: Lint Check
46182
+
46183
+ \`\`\`bash
46184
+ # Run linter
46185
+ eslint . # or equivalent
46186
+ \`\`\`
46187
+
46188
+ ## 6.4: Build Verification (if applicable)
46189
+
46190
+ \`\`\`bash
46191
+ # Ensure build still works
46192
+ bun run build # or npm run build, etc.
46193
+ \`\`\`
46194
+
46195
+ ## 6.5: Final Diagnostics
46196
+
46197
+ \`\`\`typescript
46198
+ // Check all changed files
46199
+ for (file of changedFiles) {
46200
+ lsp_diagnostics(file) // Must all be clean
46201
+ }
46202
+ \`\`\`
46203
+
46204
+ ## 6.6: Generate Summary
46205
+
46206
+ \`\`\`markdown
46207
+ ## Refactoring Complete
46208
+
46209
+ ### What Changed
46210
+ - [List of changes made]
46211
+
46212
+ ### Files Modified
46213
+ - \`path/to/file.ts\` - [what changed]
46214
+ - \`path/to/file2.ts\` - [what changed]
46215
+
46216
+ ### Verification Results
46217
+ - Tests: PASSED (X/Y passing)
46218
+ - Type Check: CLEAN
46219
+ - Lint: CLEAN
46220
+ - Build: SUCCESS
46221
+
46222
+ ### No Regressions Detected
46223
+ All existing tests pass. No new errors introduced.
46224
+ \`\`\`
46225
+
46226
+ **Mark phase-6 as completed.**
46227
+
46228
+ ---
46229
+
46230
+ # CRITICAL RULES
46231
+
46232
+ ## NEVER DO
46233
+ - Skip lsp_diagnostics check after changes
46234
+ - Proceed with failing tests
46235
+ - Make changes without understanding impact
46236
+ - Use \`as any\`, \`@ts-ignore\`, \`@ts-expect-error\`
46237
+ - Delete tests to make them pass
46238
+ - Commit broken code
46239
+ - Refactor without understanding existing patterns
46240
+
46241
+ ## ALWAYS DO
46242
+ - Understand before changing
46243
+ - Preview before applying (ast_grep dryRun=true)
46244
+ - Verify after every change
46245
+ - Follow existing codebase patterns
46246
+ - Keep todos updated in real-time
46247
+ - Commit at logical checkpoints
46248
+ - Report issues immediately
46249
+
46250
+ ## ABORT CONDITIONS
46251
+ If any of these occur, **STOP and consult user**:
46252
+ - Test coverage is zero for target code
46253
+ - Changes would break public API
46254
+ - Refactoring scope is unclear
46255
+ - 3 consecutive verification failures
46256
+ - User-defined constraints violated
46257
+
46258
+ ---
46259
+
46260
+ # Tool Usage Philosophy
46261
+
46262
+ You already know these tools. Use them intelligently:
46263
+
46264
+ ## LSP Tools
46265
+ Leverage the full LSP toolset (\`lsp_*\`) for precision analysis. Key patterns:
46266
+ - **Understand before changing**: \`lsp_hover\`, \`lsp_goto_definition\` to grasp context
46267
+ - **Impact analysis**: \`lsp_find_references\` to map all usages before modification
46268
+ - **Safe refactoring**: \`lsp_prepare_rename\` \u2192 \`lsp_rename\` for symbol renames
46269
+ - **Continuous verification**: \`lsp_diagnostics\` after every change
46270
+
46271
+ ## AST-Grep
46272
+ Use \`ast_grep_search\` and \`ast_grep_replace\` for structural transformations.
46273
+ **Critical**: Always \`dryRun=true\` first, review, then execute.
46274
+
46275
+ ## Agents
46276
+ - \`explore\`: Parallel codebase pattern discovery
46277
+ - \`plan\`: Detailed refactoring plan generation
46278
+ - \`oracle\`: Consult for complex architectural decisions
46279
+ - \`librarian\`: **Use proactively** when encountering deprecated methods or library migration tasks. Query official docs and OSS examples for modern replacements.
46280
+
46281
+ ## Deprecated Code & Library Migration
46282
+ When you encounter deprecated methods/APIs during refactoring:
46283
+ 1. Fire \`librarian\` to find the recommended modern alternative
46284
+ 2. **DO NOT auto-upgrade to latest version** unless user explicitly requests migration
46285
+ 3. If user requests library migration, use \`librarian\` to fetch latest API docs before making changes
46286
+
46287
+ ---
46288
+
46289
+ **Remember: Refactoring without tests is reckless. Refactoring without understanding is destructive. This command ensures you do neither.**
46290
+
46291
+ <user-request>
46292
+ $ARGUMENTS
46293
+ </user-request>
46294
+ `;
46295
+
45670
46296
  // src/features/builtin-commands/commands.ts
45671
46297
  var BUILTIN_COMMAND_DEFINITIONS = {
45672
46298
  "init-deep": {
@@ -45696,6 +46322,13 @@ $ARGUMENTS
45696
46322
  template: `<command-instruction>
45697
46323
  ${CANCEL_RALPH_TEMPLATE}
45698
46324
  </command-instruction>`
46325
+ },
46326
+ refactor: {
46327
+ description: "(builtin) Intelligent refactoring command with LSP, AST-grep, architecture analysis, codemap, and TDD verification.",
46328
+ template: `<command-instruction>
46329
+ ${REFACTOR_TEMPLATE}
46330
+ </command-instruction>`,
46331
+ argumentHint: "<refactoring-target> [--scope=<file|module|project>] [--strategy=<safe|aggressive>]"
45699
46332
  }
45700
46333
  };
45701
46334
  function loadBuiltinCommands(disabledCommands) {
@@ -46288,17 +46921,9 @@ function createConfigHandler(deps) {
46288
46921
  log(`Plugin load errors`, { errors: pluginComponents.errors });
46289
46922
  }
46290
46923
  const builtinAgents = createBuiltinAgents(pluginConfig.disabled_agents, pluginConfig.agents, ctx.directory, config3.model);
46291
- const rawUserAgents = pluginConfig.claude_code?.agents ?? true ? loadUserAgents() : {};
46292
- const rawProjectAgents = pluginConfig.claude_code?.agents ?? true ? loadProjectAgents() : {};
46924
+ const userAgents = pluginConfig.claude_code?.agents ?? true ? loadUserAgents() : {};
46925
+ const projectAgents = pluginConfig.claude_code?.agents ?? true ? loadProjectAgents() : {};
46293
46926
  const rawPluginAgents = pluginComponents.agents;
46294
- const userAgents = Object.fromEntries(Object.entries(rawUserAgents).map(([k, v]) => [
46295
- k,
46296
- v ? migrateAgentConfig(v) : v
46297
- ]));
46298
- const projectAgents = Object.fromEntries(Object.entries(rawProjectAgents).map(([k, v]) => [
46299
- k,
46300
- v ? migrateAgentConfig(v) : v
46301
- ]));
46302
46927
  const pluginAgents = Object.fromEntries(Object.entries(rawPluginAgents).map(([k, v]) => [
46303
46928
  k,
46304
46929
  v ? migrateAgentConfig(v) : v
@@ -46564,9 +47189,6 @@ var OhMyOpenCodePlugin = async (ctx) => {
46564
47189
  interactive_bash
46565
47190
  },
46566
47191
  "chat.message": async (input, output) => {
46567
- if (input.agent === "Sisyphus") {
46568
- output.message.variant = "max";
46569
- }
46570
47192
  await claudeCodeHooks["chat.message"]?.(input, output);
46571
47193
  await keywordDetector?.["chat.message"]?.(input, output);
46572
47194
  await contextInjector["chat.message"]?.(input, output);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oh-my-opencode",
3
- "version": "2.13.0",
3
+ "version": "2.13.1",
4
4
  "description": "OpenCode plugin - custom agents (oracle, librarian) and enhanced features",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",