Commit Graph

333 Commits

Author SHA1 Message Date
YeonGyu-Kim
24a7f333a2 refactor(background-agent): remove file persistence, use memory-only
- Remove background_tasks.json persistence (race condition with multiple instances)
- Pure memory-based task management
- Add logging for promptAsync errors
- Remove unused persist/restore methods

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
80cfe87390 fix(background-agent): use promptAsync to wake parent session
- Change prompt() to promptAsync() for parent session notification
- Only mark 404 errors as permanent task failure
- Add defensive progress initialization

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
5733291a0f fix(background-agent): notify parent session when task completes
- Add notifyParentSession() to send message to parent session via prompt()
- Agent receives completion notification immediately, not waiting for next chat.message
- Includes task ID, description, duration, tool calls in notification

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
b5d56246f6 fix(background-agent): add polling mechanism for child session tracking
- Replace unreliable event-based tracking with 2-second polling
- Use SDK session.get() to detect completion (status === idle)
- Use SDK session.messages() to count tool_use parts for progress
- Auto-start polling on launch, auto-stop when no running tasks
- Resume polling on restore if running tasks exist

Fixes: Child session events not reaching plugin event handler

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
245acdabad fix(background-agent): address Oracle review feedback
- Remove unused storage.ts (dead code, runtime inconsistency)
- Change persist() to sync void (debounce semantics clarity)
- Add type guards in handleEvent() for event safety
- Remove unused 'pending' from BackgroundTaskStatus

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
49fb046363 feat(background-agent): integrate into main plugin
🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
ce6a09b891 feat(background-notification): add completion notification hook
🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
2fad28d552 feat(background-task): add 4 background task tools
🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
698cdb6744 feat(background-agent): add BackgroundManager with persistence layer
🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
9ba0015530 feat(plugin): integrate omo_task tool and prevent recursion in subagents
Register omo_task tool in main plugin and disable it for explore/librarian agents to prevent infinite recursion.

- Export createOmoTask from src/tools/index.ts
- Initialize omo_task in main plugin with ctx
- Spread omo_task into builtinTools export
- Add recursion prevention: disable omo_task tool for explore agent config
- Add recursion prevention: disable omo_task tool for librarian agent config

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
f6dd6e3c7f feat(omo-task): add agent orchestration tool for subagent spawning
Implement omo_task tool that allows main agents (oracle, frontend-ui-ux-engineer, etc.) to spawn explore or librarian as subagents.

- Add constants: ALLOWED_AGENTS, TASK_TOOL_DESCRIPTION_TEMPLATE
- Add types: AllowedAgentType, OmoTaskArgs, OmoTaskResult
- Implement createOmoTask function with session management
- Support both new session creation and existing session continuation
- Include proper error handling and logging

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
4891a0e6f2 Revert "feat(hooks): disable redundant inject hooks by default in Claude Code compatibility layer"
This reverts commit 8e0a4fedbffebdd67d02a52612b5315fd406b036.
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
dd645994b2 feat(hooks): disable redundant inject hooks by default in Claude Code compatibility layer
Automatically disables these Claude Code hooks that duplicate oh-my-opencode functionality:
- inject_rules.py (replaced by rules-injector hook)
- inject_readme.py (replaced by directory-readme-injector hook)
- inject_knowledge.py (replaced by directory-agents-injector hook)
- remind*rules*.py (replaced by rules-injector hook)

Users can override via opencode-cc-plugin.json if needed.

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
fcdfcd3186 feat(hooks): add rules-injector hook for .cursor/rules and .claude/rules support
Implements adaptive rule injection similar to Claude Code's rule system:
- Searches .cursor/rules and .claude/rules directories recursively
- Supports YAML frontmatter with globs, paths, alwaysApply, description
- Adaptive project root detection (finds markers even outside ctx.directory)
- Symlink duplicate detection via realpath comparison
- Content hash deduplication (SHA-256) to avoid re-injecting same rules
- picomatch-based glob pattern matching for file-specific rules

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
YeonGyu-Kim
c12f73f774 fix(hooks): improve thinking block order recovery with error-based index targeting
- Add findMessageByIndexNeedingThinking for precise message targeting
- Detect "expected X found Y" error pattern for thinking block order
- Remove isLastMessage skip - recovery now handles final assistant messages
- Simplify orphan detection: any non-thinking first part is orphan

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-13 00:35:34 +09:00
Srinivasa Babu B
64138ee88f Refactor AgentOverridesSchema to use object structure (#24) 2025-12-12 15:38:39 +09:00
Nguyen Quang Huy
359340de65 feat: add claude_code config object to toggle Claude Code compatibility features (#23) 2025-12-12 15:23:50 +09:00
YeonGyu-Kim
652f343c95 feat(agents): enhance librarian and explore prompts with parallel execution and evidence-based citations (#21)
* feat(agents): enhance librarian and explore prompts with parallel execution and evidence-based citations

Librarian agent enhancements:
- Add mandatory 5+ parallel tool execution requirement
- Add WebSearch integration for latest information
- Add repository cloning to /tmp for deep source analysis
- Require GitHub permalinks for all code citations
- Add evidence-based reasoning with specific code references
- Enhanced gh CLI usage with permalink construction

Explore agent enhancements:
- Add mandatory 3+ parallel tool execution requirement
- Extensive Git CLI integration for repository analysis
- Add git log, git blame, git diff commands for exploration
- Add parallel execution examples and best practices

* feat(agents): add LSP and AST-grep tools to librarian and explore prompts

Librarian agent:
- Added LSP tools section (lsp_hover, lsp_goto_definition, lsp_find_references, etc.)
- Added AST-grep section with pattern examples for structural code search
- Updated parallel execution examples to include LSP and AST-grep tools
- Added guidance on when to use AST-grep vs Grep vs LSP

Explore agent:
- Added LSP tools section for semantic code analysis
- Added AST-grep section with examples for TypeScript/React patterns
- Updated parallel execution examples to include 6 tools
- Added tool selection guidance for LSP and AST-grep

* fix(agents): remove explore agent references from librarian prompt

Subagents cannot call other agents, so replaced all Explore agent
references with direct tool usage (Glob, Grep, ast_grep_search).

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-12 09:16:57 +09:00
YeonGyu-Kim
9ba41558de feat(config): add cross-platform user-level config support (#20) 2025-12-12 08:53:27 +09:00
YeonGyu-Kim
50727171a6 feat(agents): upgrade oracle model from GPT-5.1 to GPT-5.2 (#19) 2025-12-12 08:52:18 +09:00
Nguyen Quang Huy
e4036185f0 fix: load config from user-level ~/.config/opencode/oh-my-opencode.json (#17) 2025-12-12 08:29:32 +09:00
YeonGyu-Kim
d34154bc68 feat(skill): align with opencode-skills approach
- Add Zod schema validation following Anthropic Agent Skills Spec v1.0
- Include basePath in skill output for path resolution
- Simplify tool description and output format
- Add validation error logging for invalid skills

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-11 10:14:20 +09:00
YeonGyu-Kim
9e00be91af feat(hooks): add directory README.md injector (#15)
Implements README.md injection similar to existing AGENTS.md injector.
Automatically injects README.md contents when reading files, searching
upward from file directory to project root.

Closes #14

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-11 10:13:04 +09:00
YeonGyu-Kim
61bbbcb577 feat(hooks): integrate anthropic-auto-compact hook for automatic context summarization
Enables automatic session summarization when Anthropic token limits are exceeded.
The hook detects token limit errors and triggers compact operation on session idle.

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-10 23:43:35 +09:00
YeonGyu-Kim
adabace02d improve(hooks): refine context window reminder message for better clarity and guidance 2025-12-10 15:45:45 +09:00
YeonGyu-Kim
8102d178cb fix(hooks): fix TODO continuation abort handling with timer-based approach
Replace blocking await with non-blocking timer scheduling to handle race
condition between session.idle and session.error events. When ESC abort
occurs, session.error immediately cancels the pending timer, preventing
unwanted continuation prompts.

Changes:
- Add pendingTimers Map to track scheduled continuation checks
- Cancel timer on session.error (especially abort cases)
- Cancel timer on message.updated and session.deleted for cleanup
- Reduce delay to 200ms for faster response
- Maintain existing Set-based flag logic for compatibility

This fixes the issue where ESC abort would not prevent continuation
prompts due to event ordering (idle before error)
2025-12-10 15:45:45 +09:00
YeonGyu-Kim
4f019f8fe5 fix(hooks): improve session recovery for empty content messages
- Extract message index from Anthropic error messages (messages.N format)
- Sort messages by time.created instead of id for accurate ordering
- Remove last message skip logic that prevented recovery
- Prioritize recovery targets: index-matched > failedMsg > all empty
- Add error logging for debugging recovery failures

Fixes issue where 'messages.83: all messages must have non-empty content' errors were not being recovered properly due to incorrect message ordering and overly restrictive filtering.

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-10 15:45:45 +09:00
YeonGyu-Kim
7b19177c8a Revert "fix(hooks): improve TODO continuation race condition handling with state machine pattern"
This reverts commit e59b0be6cc380a3750e2d56c4c7ba553feef2c40.
2025-12-10 15:45:45 +09:00
YeonGyu-Kim
e8f59cbbf8 fix(hooks): improve TODO continuation race condition handling with state machine pattern
- Replace multiple Set-based tracking with explicit SessionStatus state machine
- Implement setTimeout+clearTimeout pattern for robust race condition handling
- SessionStatus tracks: idle → continuation-sent or aborted states
- Increase grace period to 500ms to accommodate event ordering delays
- Add cleanupSession utility for proper resource cleanup

This addresses ESC abort not canceling continuation prompts when session.idle
arrives before session.error event, which can occur due to async event processing
in OpenCode plugin system
2025-12-10 15:45:45 +09:00
YeonGyu-Kim
5a793bb526 fix(hooks): align Claude Code hooks with opencode-cc-plugin reference
100% port verification via Oracle agent parallel checks:
- PreToolUse: recordToolUse(), isHookDisabled(), Object.assign(), error message
- PostToolUse: recordToolResult(), isHookDisabled(), permissionMode, title field
- Stop: isHookDisabled(), parentSessionId, error/interrupt state tracking
- UserPromptSubmit: interrupt checks, recordUserMessage(), log messages

All four hooks now match opencode-cc-plugin/src/plugin/*.ts exactly.

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-09 19:00:01 +09:00
YeonGyu-Kim
2ec351d0d8 feat(hooks): implement UserPromptSubmit with chat.message hook and injectHookMessage
- Add chat.message handler to createClaudeCodeHooksHook factory
- Integrate executeUserPromptSubmitHooks() for user prompt processing
- Use injectHookMessage() for file system based message injection
- Add sessionFirstMessageProcessed tracking for title generation skip
- Register chat.message hook in plugin entry point

This completes 100% port of Claude Code hooks from opencode-cc-plugin.

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-09 18:20:13 +09:00
YeonGyu-Kim
441fc1a219 feat(hooks): integrate Claude Code hooks with plugin system
- Create factory function createClaudeCodeHooksHook()
- Wire tool.execute.before → executePreToolUseHooks
- Wire tool.execute.after → executePostToolUseHooks
- Wire event (session.idle) → executeStopHooks
- Register hooks in src/index.ts
- Claude hooks execute first in handler chain

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-09 18:10:30 +09:00
YeonGyu-Kim
bd67419d1d feat(features): add hook message injector
- Port hook-message-injector from opencode-cc-plugin (4 files)
- constants.ts: XDG-based path definitions (MESSAGE_STORAGE, PART_STORAGE)
- types.ts: MessageMeta, OriginalMessageContext, TextPart interfaces
- injector.ts: injectHookMessage() implementation with message/part storage
- index.ts: Barrel export
- Self-contained module with no import path changes needed
- Preserves XDG_DATA_HOME environment variable support
- Preserves message fallback logic for incomplete originalMessage

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-09 18:02:45 +09:00
YeonGyu-Kim
dca98121ac feat(hooks): add UserPromptSubmit and Stop executors
- Port user-prompt-submit.ts from opencode-cc-plugin (118 lines)
- Port stop.ts from opencode-cc-plugin (119 lines)
- Preserve recursion prevention logic (<user-prompt-submit-hook> tags)
- Preserve inject_prompt support (message injection, stop prompt injection)
- Preserve stopHookActiveState management (per-session state)
- Import path adjustments: ../types → ./types, ../../config → ./plugin-config
- All exit code handling preserved (exitCode 2 → block, etc.)

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-09 18:00:16 +09:00
YeonGyu-Kim
3fcfedcec0 feat(hooks): add PostToolUse hook executor
- Port post-tool-use.ts from opencode-cc-plugin (200 lines)
- Implement executePostToolUseHooks() with full transcript support
- Include temp file cleanup in finally block
- Preserve all exit code handling and output fields
- Update notepad.md with Task 5 completion log

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-09 17:55:06 +09:00
YeonGyu-Kim
530c4d63d5 feat(hooks): add PreToolUse hook executor
🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-09 17:48:28 +09:00
YeonGyu-Kim
e0b43380cc feat(hooks): add Claude hooks config, transcript, and todo
🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-09 17:41:39 +09:00
YeonGyu-Kim
a27cac96d5 feat(hooks): add Claude Code hooks type definitions
🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-09 17:36:12 +09:00
YeonGyu-Kim
fef7f4ca03 feat(shared): add Claude hooks command executor and utilities
- Add snake-case.ts: objectToSnakeCase, objectToCamelCase utilities
- Add tool-name.ts: transformToolName with PascalCase conversion
- Add pattern-matcher.ts: findMatchingHooks for hook config matching
- Add hook-disabled.ts: isHookDisabled for hook config validation
- Add temporary stub types at src/hooks/claude-code-hooks/types.ts
- Export all new utilities from src/shared/index.ts

Stub types will be replaced with full implementation in Task 1.
Import paths adjusted from opencode-cc-plugin structure to oh-my-opencode.

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-09 17:31:15 +09:00
YeonGyu-Kim
207435450c refactor(index): integrate session-state module and remove local variables
- Add imports: agent-loader, mcp-loader, session-state, logger
- Remove local session variables (mainSessionID, currentSessionID, currentSessionTitle)
- Use setter/getter functions from session-state module
- Add agent loading in config hook (loadUserAgents, loadProjectAgents)
- Add MCP loading in config hook (loadMcpConfigs)
- Replace console.error with logger

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-09 16:59:22 +09:00
YeonGyu-Kim
376bf363af feat(features): add claude-code-agent-loader, mcp-loader, session-state 2025-12-09 16:59:22 +09:00
YeonGyu-Kim
c7a65af475 refactor(features): rename command-loader and skill-loader with claude-code prefix 2025-12-09 16:59:22 +09:00
YeonGyu-Kim
8e7447deee feat(shared): add file-based logger utility 2025-12-09 16:59:22 +09:00
YeonGyu-Kim
c0e0dc1f95 feat: integrate command/skill loaders and think-mode hook in main entry
- Add loadCommands() and loadSkills() to config
- Register think-mode hook for UserPromptSubmit event

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-09 16:59:22 +09:00
YeonGyu-Kim
7059407cbc feat(hooks): export createThinkModeHook from index
🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-09 16:59:22 +09:00
YeonGyu-Kim
589cf60252 feat(hooks): add think-mode hook for automatic model switching
Detects thinking keywords (ultrathink, deepthink, etc.) and switches
to thinking-capable models automatically.

Supports model patterns:
- claude-sonnet-4-0 -> claude-sonnet-4-0-max-thinking
- claude-sonnet-4-20250514 -> claude-sonnet-4-20250514-max-thinking

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-09 16:59:22 +09:00
YeonGyu-Kim
e5cdaa5192 feat(tools): export slashcommand and skill tools from index
🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-09 16:59:22 +09:00
YeonGyu-Kim
340eb30147 feat(tools): add skill tool for invoking skills in conversation
Provides 'skill' tool that invokes skills loaded by skill-loader.
Skills expand into detailed instructions when invoked.

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-09 16:59:22 +09:00
YeonGyu-Kim
e72b927ccb feat(tools): add slashcommand tool for executing slash commands
Provides 'slashcommand' tool that executes commands loaded by command-loader.
Handles shell injection and file reference resolution.

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-09 16:59:22 +09:00
YeonGyu-Kim
3c6ffe5d9c feat(skill-loader): add skill loader that converts skills to commands
Skills are loaded from:
- ~/.claude/skills/ (user scope)
- .claude/skills/ (project scope)

Each skill directory contains SKILL.md with frontmatter metadata.

🤖 GENERATED WITH ASSISTANCE OF [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode)
2025-12-09 16:59:22 +09:00