YeonGyu-Kim
5e4102566c
refactor(model-fallback): fully encapsulate session state in factory closure
...
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent )
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai >
2026-04-18 02:35:46 +09:00
YeonGyu-Kim
2440ed9a6f
fix(hook): add tool_use/tool_result pair validator to prevent API errors
...
Adds a defensive tool-pair-validator hook that runs as the final step in
the messages transform pipeline. When compaction or context-window recovery
removes user messages containing tool_result blocks without removing the
preceding assistant message with tool_use blocks, this validator detects
the mismatch and either:
1. Injects missing tool_result parts into the next user message, or
2. Creates a synthetic user message with placeholder tool_results
This prevents Anthropic API errors like 'tool_use ids found without
tool_result blocks immediately after'.
Fixes #3014
2026-04-02 13:31:48 +09:00
YeonGyu-Kim
7b2b8be181
Merge pull request #2771 from MoerAI/fix/bash-file-read-guard
...
fix(hooks): add bash-file-read-guard to warn agents against cat/head/tail (fixes #2096 )
2026-03-28 01:44:44 +09:00
YeonGyu-Kim
e22e13cd29
fix( #2732 ): detect crashed subagent sessions with shorter timeout
...
When a subagent session disappears from the status registry (process
crashed), the main agent was waiting the full stale timeout before
acting. Fix:
- Add sessionGoneTimeoutMs config option (default 60s, vs 30min normal)
- task-poller: use shorter timeout when session is gone from status
- manager: verify session existence when gone, fail crashed tasks
immediately with descriptive error
- Add legacy-plugin-toast hook for #2823 migration warnings
- Update schema with new config option
2026-03-27 15:43:01 +09:00
YeonGyu-Kim
af301ab29a
fix(webfetch): guard redirect loops in built-in flow
2026-03-24 23:58:53 +09:00
MoerAI
2f801f6c28
fix(hooks): add bash-file-read-guard to warn agents against cat/head/tail ( fixes #2096 )
2026-03-23 20:15:20 +09:00
YeonGyu-Kim
ccaf759b6b
fix(hooks): remove gpt permission continuation hook
...
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent )
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai >
2026-03-19 12:02:52 +09:00
YeonGyu-Kim
55ac653eaa
feat(hooks): add todo-description-override hook to enforce atomic todo format
...
Override TodoWrite description via tool.definition hook to require
WHERE/WHY/HOW/RESULT in each todo title and enforce 1-3 tool call
granularity.
2026-03-18 11:49:13 +09:00
YeonGyu-Kim
674df1b1b8
fix(hooks): remove dead delegate-task-english-directive hook
2026-03-16 10:38:54 +09:00
YeonGyu-Kim
f3de122147
feat(hooks): add delegate-task-english-directive hook to enforce English for subagents
...
Appends bold uppercase English-only directive to explore, librarian,
oracle, and plan subagent prompts via tool.execute.before on the task tool.
2026-03-13 14:22:13 +09:00
YeonGyu-Kim
a1b060841f
fix(continuation): auto-continue GPT permission-seeking replies
...
Resume GPT sessions when the last assistant reply ends in a permission-seeking tail, while honoring stop-continuation and avoiding duplicate continuation across todo and atlas flows.
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent )
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai >
2026-03-11 21:20:59 +09:00
YeonGyu-Kim
cc6ab1addc
feat(hooks): add read-image-resizer hook
...
Intercepts Read tool output with image attachments and resizes to comply with Anthropic API limits (≤1568px long edge, ≤5MB). Only activates for Anthropic provider sessions and appends resize metadata (original/new resolution, token count) to tool output.
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode )
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai >
2026-02-28 13:21:40 +09:00
YeonGyu-Kim
27d5379215
refactor(hooks): remove beast-mode system integration
...
Remove the beast-mode-system hook and all transform wiring so Copilot-specific prompt injection is fully eliminated from the runtime pipeline.
2026-02-22 01:57:22 +09:00
YeonGyu-Kim
fe415319e5
fix: resolve publish blockers for v3.7.4→v3.8.0 release
...
- Fix #1991 crash: optional chaining for task-history sessionID access
- Fix #1992 think-mode: add antigravity entries to HIGH_VARIANT_MAP
- Fix #1949 Copilot premium misattribution: use createInternalAgentTextPart
- Fix #1982 load_skills: pass directory to discoverSkills for project-level skills
- Fix command priority: sort scopePriority before .find(), project-first return
- Fix Google provider transform: apply in userFallbackModels path
- Fix ralph-loop TUI: optional chaining for event handler
- Fix runtime-fallback: unify dual fallback engines, remove HTTP 400 from retry,
fix pendingFallbackModel stuck state, add priority gate to skip model-fallback
when runtime-fallback is active
- Fix Prometheus task system: exempt from todowrite/todoread deny
- Fix background_output: default full_session to true
- Remove orphan hooks: hashline-edit-diff-enhancer (redundant with hashline_edit
built-in diff), task-reminder (dead code)
- Remove orphan config entries: 3 stale hook names from Zod schema
- Fix disabled_hooks schema: accept arbitrary strings for forward compatibility
- Register json-error-recovery hook in tool-guard pipeline
- Add disabled_hooks gating for question-label-truncator, task-resume-info,
claude-code-hooks
- Update test expectations to match new behavior
2026-02-21 16:24:18 +09:00
YeonGyu-Kim
daa0d48026
fix(rebase): remove duplicated hooks exports and event dispatch artifact
2026-02-21 05:36:11 +09:00
YeonGyu-Kim
6ad615958f
fix(ci): restore missing hook exports and align config-handler test fixtures
2026-02-21 05:33:53 +09:00
YeonGyu-Kim
9f09f77588
feat(hooks): export json-error-recovery hook
...
🤖 Generated with assistance of [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode )
2026-02-21 03:33:30 +09:00
YeonGyu-Kim
481106a12e
Merge branch 'pr-1959' into dev
...
# Conflicts:
# src/hooks/index.ts
# src/plugin/event.ts
# src/tools/delegate-task/sync-task.ts
2026-02-21 02:49:39 +09:00
Rebase Bot
632570f7ec
feat(config): add runtime_fallback and fallback_models schema
...
Add configuration schemas for runtime model fallback feature:
- RuntimeFallbackConfigSchema with enabled, retry_on_errors,
max_fallback_attempts, cooldown_seconds, notify_on_fallback
- FallbackModelsSchema for init-time fallback model selection
- Add fallback_models to AgentOverrideConfigSchema and CategoryConfigSchema
- Export types and schemas from config/index.ts
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode )
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai >
2026-02-21 02:28:27 +09:00
VespianRex
f5f1d1d4c2
Fix model fallback across main/background/sync agents
2026-02-20 17:45:53 +02:00
YeonGyu-Kim
3dba1c49d4
feat(hooks): add no-hephaestus-non-gpt hook to enforce GPT-only for Hephaestus
2026-02-20 10:49:04 +09:00
YeonGyu-Kim
50de1a18f2
feat(hooks): add hashline-edit-diff-enhancer for TUI inline diff display
...
Capture file content before hashline edit execution and compute filediff
metadata after, enabling opencode TUI to render inline diffs for the
plugin's edit tool (which replaces the built-in EditTool).
2026-02-19 18:40:42 +09:00
YeonGyu-Kim
6df7f73f81
refactor: remove dead ultrawork model override code
...
Remove ultrawork-model-override hook and per-agent ultrawork model swap
config that relied on zen opencode.ai free tier (no longer functional).
Removed:
- src/hooks/ultrawork-model-override/ (hook, test, index)
- ultrawork field from AgentOverrideConfigSchema
- ultrawork-model-override from HookNameSchema
- UltraworkConfig type from model-fallback-types
- Non-max20 sonnet+ultrawork-opus codepath from model-fallback
- Claude subscription model table from installation docs
- All references in plugin-interface, create-session-hooks, schema.json
- Related test cases and updated snapshots
2026-02-19 03:17:40 +09:00
YeonGyu-Kim
e863fe2013
feat(hooks): add ultrawork-model-override hook for per-agent model swap
2026-02-18 17:47:08 +09:00
YeonGyu-Kim
a60a153d19
refactor(hooks): rename sisyphus-gpt-hephaestus-reminder to no-sisyphus-gpt
...
Shorter hook name, disableable via disabled_hooks config, migration added
for backward compatibility. Also forces agent switch to Hephaestus on
Sisyphus + GPT detection. Docs updated with new hook name.
2026-02-18 16:33:16 +09:00
YeonGyu-Kim
0bffdc441e
feat(hooks): add sisyphus-gpt-hephaestus-reminder hook
...
Shows error toast when Sisyphus runs with a GPT model, nudging user to
use Hephaestus instead.
🤖 Generated with [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-opencode )
2026-02-18 01:08:40 +09:00
bowtiedswan
86f2a93fc9
feat(hooks): add json-error-recovery hook to prevent infinite retry loops
2026-02-16 21:35:58 +02:00
YeonGyu-Kim
af7b1ee620
refactor(hashline): override native edit tool instead of separate tool + disabler hook
...
Replace 3-component hashline system (separate hashline_edit tool + edit
disabler hook + OpenAI-exempted read enhancer) with 2-component system
that directly overrides the native edit tool key, matching the
delegate_task pattern.
- Register hashline tool as 'edit' key to override native edit
- Delete hashline-edit-disabler hook (no longer needed)
- Delete hashline-provider-state module (no remaining consumers)
- Remove OpenAI exemption from read enhancer (explicit opt-in means all providers)
- Remove setProvider wiring from chat-params
2026-02-17 00:03:10 +09:00
YeonGyu-Kim
51dde4d43f
feat(hashline): port hashline edit tool from oh-my-pi
...
This PR ports the hashline edit tool from oh-my-pi to oh-my-opencode as an experimental feature.
## Features
- New experimental.hashline_edit config flag
- hashline_edit tool with 4 operations: set_line, replace_lines, insert_after, replace
- Hash-based line anchors for safe concurrent editing
- Edit tool disabler for non-OpenAI providers
- Read output enhancer with LINE:HASH prefixes
- Provider state tracking module
## Technical Details
- xxHash32-based 2-char hex hashes
- Bottom-up edit application to prevent index shifting
- OpenAI provider exemption (uses native apply_patch)
- 90 tests covering all operations and edge cases
- All files under 200 LOC limit
## Files Added/Modified
- src/tools/hashline-edit/ (7 files, ~400 LOC)
- src/hooks/hashline-edit-disabler/ (4 files, ~200 LOC)
- src/hooks/hashline-read-enhancer/ (3 files, ~400 LOC)
- src/features/hashline-provider-state.ts (13 LOC)
- src/config/schema/experimental.ts (hashline_edit flag)
- src/config/schema/hooks.ts (2 new hook names)
- src/plugin/tool-registry.ts (conditional registration)
- src/plugin/chat-params.ts (provider state tracking)
- src/tools/index.ts (export)
- src/hooks/index.ts (exports)
2026-02-17 00:03:10 +09:00
YeonGyu-Kim
b58f3edf6d
refactor: remove redundant subagent-question-blocker hook
...
Replace PreToolUse hook-based question tool blocking with the existing
tools parameter approach (tools: { question: false }) which physically
removes the tool from the LLM's toolset before inference.
The hook was redundant because every session.prompt() call already passes
question: false via the tools parameter. OpenCode converts this to a
PermissionNext deny rule and deletes the tool from the toolset, preventing
the LLM from even seeing it. The hook only fired after the LLM already
called the tool, wasting tokens.
Changes:
- Remove subagent-question-blocker hook invocation from PreToolUse chain
- Remove hook registration from create-session-hooks.ts
- Delete src/hooks/subagent-question-blocker/ directory (dead code)
- Remove hook from HookNameSchema and barrel export
- Fix sync-executor.ts missing question: false in tools parameter
- Add regression tests for both the removal and the tools parameter
2026-02-13 14:55:46 +09:00
YeonGyu-Kim
46a30cd7ec
Merge remote-tracking branch 'origin/dev' into refactor/modular-code-enforcement
...
# Conflicts:
# src/agents/utils.ts
# src/config/schema.ts
# src/features/background-agent/spawner/background-session-creator.ts
# src/features/background-agent/spawner/parent-directory-resolver.ts
# src/features/background-agent/spawner/tmux-callback-invoker.ts
# src/features/tmux-subagent/manager.ts
# src/hooks/interactive-bash-session/index.ts
# src/hooks/task-continuation-enforcer.test.ts
# src/index.ts
# src/plugin-handlers/config-handler.test.ts
# src/tools/background-task/tools.ts
# src/tools/call-omo-agent/tools.ts
# src/tools/delegate-task/executor.ts
2026-02-08 19:05:41 +09:00
YeonGyu-Kim
c6fafd6624
fix: remove task-continuation-enforcer and restore task tool titles
2026-02-08 17:49:22 +09:00
YeonGyu-Kim
f3f6ba47fe
merge: integrate origin/dev into modular-enforcement branch
...
Resolves all merge conflicts, preserving our split module structure
while integrating all dev changes:
- Custom agent summaries support (parseRegisteredAgentSummaries)
- Background notification queue (enqueueNotificationForParent)
- Atlas shared git-worktree module (collectGitDiffStats, formatFileChanges)
- Ralph-loop withTimeout + DEFAULT_API_TIMEOUT=5000
- Session recovery assistant_prefill_unsupported error type
- Atlas agentOverrides forwarding
- Config handler plan model demotion (buildPlanDemoteConfig)
- Delegate-task agentOverrides, promptSyncWithModelSuggestionRetry, variant
- LSP init timeout + stale init detection
- isPlanFamily function + task-continuation-enforcer hook
- Handoff command
2026-02-08 17:34:47 +09:00
YeonGyu-Kim
a5af7e95c0
Merge pull request #1536 from code-yeongyu/feat/task-continuation-enforcer
...
feat(hooks): implement task-continuation-enforcer
2026-02-08 16:43:42 +09:00
YeonGyu-Kim
e4583668c0
refactor(hooks): split session-notification and unstable-agent-babysitter
...
Extract notification and babysitter logic:
- session-notification-formatting.ts, session-notification-scheduler.ts
- session-notification-sender.ts, session-todo-status.ts
- task-message-analyzer.ts: message analysis for babysitter hook
2026-02-08 16:23:56 +09:00
YeonGyu-Kim
3947084cc5
fix: add compaction todo preserver hook
...
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode )
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai >
2026-02-07 19:15:46 +09:00
YeonGyu-Kim
60bbeb7304
fix(compaction): remove hardcoded Claude model from compaction hooks
2026-02-06 18:58:48 +09:00
YeonGyu-Kim
551dbc95f2
feat(hooks): register task-continuation-enforcer in plugin lifecycle
...
Integrates at 4 points: creation (gated by task_system), session
recovery callbacks, event handler, and stop-continuation command.
2026-02-06 11:21:53 +09:00
YeonGyu-Kim
ddf878e53c
feat(write-existing-file-guard): add hook to prevent write tool from overwriting existing files
...
Adds a PreToolUse hook that intercepts write operations and throws an error
if the target file already exists, guiding users to use the edit tool instead.
- Throws error: 'File already exists. Use edit tool instead.'
- Hook is enabled by default, can be disabled via disabled_hooks
- Includes comprehensive test suite with BDD-style comments
2026-02-05 01:58:14 +09:00
YeonGyu-Kim
dea13a37a6
feat(task-system): add experimental task system with Claude Code spec alignment ( #1415 )
...
* feat(hooks): add tasks-todowrite-disabler hook to block TodoRead/TodoWrite
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode )
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai >
* feat(task-tools): add parallel execution guidance to descriptions
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode )
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai >
* refactor(index): migrate task system to experimental.task_system flag
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode )
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai >
* docs: update AGENTS.md for experimental task system
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode )
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai >
* fix(task-tests): align test field names with Claude Code spec (subject, blockedBy, addBlockedBy)
* fix: address Cubic review feedback
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode )
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai >
* fix: add optional chaining for tasksTodowriteDisabler null check
---------
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai >
2026-02-03 12:11:23 +09:00
YeonGyu-Kim
62e1687474
feat: add agent fallback and preemptive-compaction restoration
...
- Add agent visibility fallback for first-run scenarios
- Restore preemptive-compaction hook
- Update migration and schema for preemptive-compaction restoration
2026-02-02 22:40:59 +09:00
justsisyphus
64356c520b
feat(hooks): add unstable-agent-babysitter hook for monitoring unstable background agents
2026-02-01 17:07:18 +09:00
YeonGyu-Kim
f146aeff0f
refactor: major codebase cleanup - BDD comments, file splitting, bug fixes ( #1350 )
...
* style(tests): normalize BDD comments from '// #given' to '// given'
- Replace 4,668 Python-style BDD comments across 107 test files
- Patterns changed: // #given -> // given, // #when -> // when, // #then -> // then
- Also handles no-space variants: //#given -> // given
* fix(rules-injector): prefer output.metadata.filePath over output.title
- Extract file path resolution to dedicated output-path.ts module
- Prefer metadata.filePath which contains actual file path
- Fall back to output.title only when metadata unavailable
- Fixes issue where rules weren't injected when tool output title was a label
* feat(slashcommand): add optional user_message parameter
- Add user_message optional parameter for command arguments
- Model can now call: command='publish' user_message='patch'
- Improves error messages with clearer format guidance
- Helps LLMs understand correct parameter usage
* feat(hooks): restore compaction-context-injector hook
- Restore hook deleted in cbbc7bd0 for session compaction context
- Injects 7 mandatory sections: User Requests, Final Goal, Work Completed,
Remaining Tasks, Active Working Context, MUST NOT Do, Agent Verification State
- Re-register in hooks/index.ts and main plugin entry
* refactor(background-agent): split manager.ts into focused modules
- Extract constants.ts for TTL values and internal types (52 lines)
- Extract state.ts for TaskStateManager class (204 lines)
- Extract spawner.ts for task creation logic (244 lines)
- Extract result-handler.ts for completion handling (265 lines)
- Reduce manager.ts from 1377 to 755 lines (45% reduction)
- Maintain backward compatible exports
* refactor(agents): split prometheus-prompt.ts into subdirectory
- Move 1196-line prometheus-prompt.ts to prometheus/ subdirectory
- Organize prompt sections into separate files for maintainability
- Update agents/index.ts exports
* refactor(delegate-task): split tools.ts into focused modules
- Extract categories.ts for category definitions and routing
- Extract executor.ts for task execution logic
- Extract helpers.ts for utility functions
- Extract prompt-builder.ts for prompt construction
- Reduce tools.ts complexity with cleaner separation of concerns
* refactor(builtin-skills): split skills.ts into individual skill files
- Move each skill to dedicated file in skills/ subdirectory
- Create barrel export for backward compatibility
- Improve maintainability with focused skill modules
* chore: update import paths and lockfile
- Update prometheus import path after refactor
- Update bun.lock
* fix(tests): complete BDD comment normalization
- Fix remaining #when/#then patterns missed by initial sed
- Affected: state.test.ts, events.test.ts
---------
Co-authored-by: justsisyphus <justsisyphus@users.noreply.github.com >
2026-02-01 16:47:50 +09:00
justsisyphus
cbbc7bd075
refactor: remove orphaned compaction-context-injector hook
...
Hook was disconnected from plugin flow since commit 4a82ff40 .
Never called at runtime, superseded by preemptive-compaction hook.
2026-02-01 14:16:21 +09:00
YeonGyu-Kim
e63c568c4f
feat(hooks): add /stop-continuation command to halt all continuation mechanisms ( #1316 )
...
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode )
Co-authored-by: justsisyphus <justsisyphus@users.noreply.github.com >
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai >
2026-01-31 15:09:05 +09:00
justsisyphus
de439edc22
feat(subagent): block question tool at both SDK and hook level
...
- Add permission: [{ permission: 'question', action: 'deny' }] to session.create()
in background-agent and delegate-task for SDK-level blocking
- Add subagent-question-blocker hook as backup layer to intercept question tool
calls in tool.execute.before event
- Ensures subagents cannot ask questions to users and must work autonomously
2026-01-27 13:07:09 +09:00
justsisyphus
da416b362b
feat(hooks): add category-skill-reminder hook ( #1123 )
...
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode )
Co-authored-by: justsisyphus <justsisyphus@users.noreply.github.com >
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai >
2026-01-26 11:48:32 +09:00
YeonGyu-Kim
0aa8f486af
feat(hooks): add sisyphus-junior-notepad hook for conditional notepad rules injection ( #1092 )
...
* refactor(shared): extract isCallerOrchestrator to session-utils
* refactor(atlas): use shared isCallerOrchestrator, change to prepend
* refactor(prometheus-md-only): change to prepend pattern
* refactor(sisyphus-junior): remove Work_Context (moved to hook)
* feat(hooks): add sisyphus-junior-notepad hook
* fix(shared): replace dynamic require with static import in session-utils
- Change from dynamic require to static import for better bundler compatibility
- Fix import path: ../../features -> ../features
- Add barrel export to src/shared/index.ts
* feat(hooks): register sisyphus-junior-notepad hook
- Add to HookNameSchema in schema.ts
- Export from hooks/index.ts
- Register with isHookEnabled in index.ts
- Auto-generated schema.json update
---------
Co-authored-by: justsisyphus <justsisyphus@users.noreply.github.com >
2026-01-25 14:52:11 +09:00
yimingll
3a22c24cf4
fix: auto-truncate question option labels exceeding 30 characters
...
When AI generates AskUserQuestion tool calls with option labels longer
than 30 characters, opencode validation rejects them with "too_big" error.
This fix adds a pre-tool-use hook that automatically truncates labels
to 30 characters (with "..." suffix) before the validation occurs.
Fixes the error:
"The question tool was called with invalid arguments: expected string
to have <=30 characters"
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2026-01-24 15:59:45 +09:00
justsisyphus
c46d57f3aa
refactor(hooks): rename sisyphus-orchestrator to atlas
...
- Rename SisyphusOrchestratorHookOptions → AtlasHookOptions
- Rename createSisyphusOrchestratorHook → createAtlasHook
- Update hook name in schema: sisyphus-orchestrator → atlas
- Update all documentation references
- Rename image: orchestrator-sisyphus.png → orchestrator-atlas.png
2026-01-20 16:52:20 +09:00