Skip to content

Conversation

@berenar
Copy link
Contributor

@berenar berenar commented Oct 24, 2025

Motivation

I want to create a plugin that:

  1. Runs when I start a new session
  2. Checks if the AGENTS.md file is present
  3. Warns the user if it's missing

I didn't find an event suited for that.

Proposed solution

I added an event session.started that triggers when a session starts.
I believe this will be useful for other plugins too.

FYI

  • I added a test but I could not test a plugin that uses this event.
  • I believe some types need to be updated.
  • I think we should update the documentation to clearly list all events that can be used in plugins. I could update the file /packages/web/src/content/docs/plugins.mdx but maybe there's a way to keep that list updated in the docs.

@rekram1-node
Copy link
Collaborator

I think we should update the documentation to clearly list all events that can be used in plugins. I could update the file /packages/web/src/content/docs/plugins.mdx but maybe there's a way to keep that list updated in the docs.

We need to do some type of doc gen prolly

@rekram1-node
Copy link
Collaborator

for your usecase you could technically run the plugin whenever they start up opencode (rather than every new session). just make defining the warning within the plugin function rather than a hook it returns

@rekram1-node
Copy link
Collaborator

There is this Updated event right below, do you think having 2 events fire at same time could cause confusion here?

Screenshot 2025-10-25 at 1 49 24 AM

@berenar
Copy link
Contributor Author

berenar commented Oct 27, 2025

There is this Updated event right below, do you think having 2 events fire at same time could cause confusion here?

@rekram1-node Well, right now, the session is immediately updated right after it's created, so yes, it makes sense that both Created and Updated events are triggered.

However, to me, it makes more sense if createNext only triggered one Created event by replacing the Updated event with Created. But that could break any internal listeners (and users' plugins) of the Updated event that assume that's the event triggered when a session starts.

@rekram1-node
Copy link
Collaborator

shipping it, thanks!!

@rekram1-node rekram1-node merged commit b562863 into sst:dev Oct 27, 2025
3 checks passed
@rekram1-node
Copy link
Collaborator

renaming it to session.created it will be released later today probs

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants