GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Hooks support? · Issue #1473 · anomalyco/opencode

Hooks support? #1473

New issue
Copy link
New issue
Copy link
Closed
Closed
Hooks support?#1473
Copy link
Assignees
thdxr

Description

@codeagencybe
codeagencybe
opened on Jul 31, 2025
Issue body actions

Is there an option to use hooks with opencode?

I want the agent to call a script after a task ends to automatically commit and push everything and open a PR.

Currently, it works by giving the instructions to the agent, but it consumes more and a lot of tokens. Also the output is not always consistent. Sometimes it doesn't set the assignee or labels, sometimes it randomly does nothing at all and I have to follow prompt to run the GitHub stuff.

And it's not efficient to let AI handle a simple task that can be run programmatically.

What is the best way to solve this with opencode?

Reacted by arash-qc, Giovanni, Alp Sahin, Raymel, dev-abhirup-sc, enprop, Henrique Souza, Emin Meydanoglu, Max Sysoev, Benedict Summers and 7 more
Reacted by Christopher Carroll Smith, arash-qc, Alp Sahin, Henrique Souza, Emin Meydanoglu and Somshubra Majumdar
Reacted by Thomas Roche, Hayashi Tomoharu and Henrique Souza

Activity

  1. fahmi-grande commented on Aug 1, 2025

    @fahmi-grande
    fahmi-grande
    on Aug 1, 2025
    More actions

    Up for this. Claude Code hooks can do so much things right now. especially for this PreToolUse

  2. thdxr
    self-assigned this
    on Aug 1, 2025
  3. thdxr commented on Aug 1, 2025

    @thdxr
    thdxr
    on Aug 1, 2025 – with Linear
    Member
    More actions

    we'll have something better than hooks - likely tomorrow

    Reacted by Fabio Tielen, Florian Vidal, mbastakis, Henry Moran, tomdevelops, Dan Kubb, Anh Dung Nguyen, Adam Hosker, enprop, Sheldon Zheng and 5 more
    Reacted by Tobias Walle, Muhammad Fahmi Ayil Ilahi, Dan Kubb, Arsham Shirvani and Bohdan Mart
  4. SquallLeonhart13 commented on Aug 1, 2025

    @SquallLeonhart13
    SquallLeonhart13
    on Aug 1, 2025
    More actions

    better than hooks? Bold statement
    I added claude likes hooks to the best of my (claude) ability no promises. Testing now with our new platform that helps capture hook event data to make a principle engineer, we are in early beta if you guys want to check us out https://github.com/principle-md/opencode-with-hooks/releases/tag/v0.4.0
    https://principle-md.com

  5. ofonseca-pyming commented on Aug 4, 2025

    @ofonseca-pyming
    ofonseca-pyming
    on Aug 4, 2025
    More actions

    With plugins you can extend beyond the execution of user-defined shell commands:
    https://opencode.ai/docs/plugins/

    Reacted by Arsen Nuramatov, tomdevelops, Adam Hosker, enprop, Luqmaan and John1995ac
  6. rmoriz commented on Aug 8, 2025

    @rmoriz
    rmoriz
    on Aug 8, 2025
    Contributor
    More actions

    Did someone get the plugin approach to work? even the examples (notification) won't work for me. Neither in a project, nor globally (v0.4.1)

  7. asafyish commented on Aug 9, 2025

    @asafyish
    asafyish
    on Aug 9, 2025
    More actions

    I also tried using simple plugins, nothing works.
    I have a plugin in ~/.config/opencode/plugin - but it doesn't load, no errors in the logs.

  8. darrenhinde commented on Aug 9, 2025

    @darrenhinde
    darrenhinde
    on Aug 9, 2025
    More actions

    Also having the same issue, tried both in project and the global level.

  9. rmoriz commented on Aug 9, 2025

    @rmoriz
    rmoriz
    on Aug 9, 2025
    Contributor
    More actions

    let's use opencode to debug 😎
    https://opencode.ai/s/U09ntSBv

    Based on my analysis of the opencode plugin system, I've identified several issues that could prevent plugins from loading or working properly:
    Issues Found:

    1. Plugin Hook Structure Mismatch in Documentation vs. Implementation

      Documentation shows tool.execute.before as nested hooks in /packages/web/src/content/docs/docs/plugins.mdx:96-106
      But implementation expects flat hook names like "tool.execute.before" in /packages/opencode/src/plugin/index.ts:25-36

    2. Missing Error Handling in Plugin Loading

      Plugin loading in /packages/opencode/src/plugin/index.ts:20-35 lacks error handling
      If a plugin fails to load or export properly, it could silently fail or crash the loading process

    3. Inconsistent Plugin Discovery Paths

      Global plugins search in ~/.config/opencode/plugin/.ts via /packages/opencode/src/config/config.ts:108
      Project plugins search in .opencode/plugin/
      .ts via /packages/opencode/src/config/config.ts:109
      But documentation mentions .opencode/plugin directory, not specific file patterns

    4. Plugin Configuration Loading Issues

      Config loading at /packages/opencode/src/config/config.ts:475-482 tries to resolve plugin paths but catches errors silently
      This could mask actual plugin loading failures

    5. Event System Integration

      Plugin initialization in /packages/opencode/src/plugin/index.ts:59-68 subscribes to all bus events
      But there's no verification that plugins actually get called properly

    6. No Plugin Validation or Loading Logs

      Missing debug logging to help troubleshoot plugin loading issues
      No validation that exported functions match the Plugin interface

    Main Problem Areas:

    config.ts:105-111 - Plugin discovery and path resolution
    plugin/index.ts:20-35 - Plugin loading loop with no error handling
    plugin/index.ts:42-57 - Hook triggering mechanism
    plugin/index.ts:59-68 - Event subscription for plugins
    

    The most likely cause of user reports is that plugins are failing to load due to path resolution issues or silent failures in the loading process, with no debugging information to help users understand what went wrong.

    Reacted by Darren Hinde
  10. rmoriz commented on Aug 9, 2025

    @rmoriz
    rmoriz
    on Aug 9, 2025
    Contributor
    More actions

    this works for me:

    Write .opencode/plugin/say-notification.ts

    import type { Plugin } from "@opencode-ai/plugin"
    
    export const SayNotificationPlugin: Plugin = async ({ app, client, $ }) => {
      console.log("Say Notification Plugin initialized!")
    
      return {
        event: async ({ event }) => {
          // Trigger when session becomes idle (user stops interacting)
          if (event.type === "session.idle") {
            try {
              // Use macOS say command to announce session completion
              await $`say "Your opencode session is now idle and ready for new input"`
            } catch (error) {
              console.error("Failed to use say command:", error)
            }
          }
        },
      }
    }

    prompt:

    can you create an example plugin in typescript that calls macos' "say" command with a message when the session is idle?
    rmoriz (11:46 PM)
    
    I'll create an example TypeScript plugin that uses macOS's say command when a session becomes idle.
    claude-sonnet-4 (11:46 PM)
    
    Reacted by Christopher Carroll Smith and ikkun1222
  11. rmoriz commented on Aug 9, 2025

    @rmoriz
    rmoriz
    on Aug 9, 2025
    Contributor
    More actions

    TODO:

    JavaScript plugins are supported, but there's a discrepancy in the current implementation. The config only searches for .ts files, but the
    documentation shows JavaScript examples. This might be one of the issues causing plugin loading problems.

    Here's the JavaScript version I created. The main differences from TypeScript:

    • No type imports needed
    • Same functionality and structure
    • Works with Bun's native JavaScript support

    However, I noticed the config currently only searches for .ts files in /packages/opencode/src/config/config.ts:108-109. This should
    probably
    be updated to also include .js files to match the documentation.

    The JavaScript plugin should work if you manually add it to your config or if the search pattern gets updated to include .js files.
    claude-sonnet-4 (11:55 PM)

    Reacted by Christopher Carroll Smith
  12. asafyish commented on Aug 10, 2025

    @asafyish
    asafyish
    on Aug 10, 2025
    More actions

    The problem I had was indeed js file instead of ts.

  13. rekram1-node commented on Aug 29, 2025

    @rekram1-node
    rekram1-node
    on Aug 29, 2025
    Member
    More actions

    Closing since js files are supported and docs have been updated: https://opencode.ai/docs/plugins/

  14. rekram1-node
    closed this as completedon Aug 29, 2025
  15. bussard76
    added a commit that references this issue on May 12, 2026

    docs: flatten changelog and roadmap URLs (anomalyco#1473)

    88e71aa
  16. mylesndavid
    added a commit that references this issue on Sep 22, 2026

    feat(desktop): GPT Live calls, Voice tab and narrower resizable panel…

    123d146
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @thdxr
    thdxr

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.