Skip to content

Conversation

@JosephAnson
Copy link
Contributor

Description

Add additional tool to display all the available hooks in the nuxt application, detects modules hooks so it works quite well when trying to figure out what's available in the project

image

Additional context

Currently using a private property _hooks, maybes there's a better way to extract the hooks. I can't seem to find anything when exploring https://github.com/unjs/hookable

Testing

Tested against nuxt content in the playground to see if the hooks are being discovered correctly, "mdc:configSources" is available as expected

@antfu
Copy link
Owner

antfu commented Mar 15, 2025

When would this information be useful? There are actually nuxt hooks, app hooks, nitro hooks, each of them applies to different context. I feel just adding it tool might not help LLM to understand the project better but might be more confusing

@JosephAnson
Copy link
Contributor Author

Hey, sure I understand your concerns, I can see how it might get confused. Generally when i've been testing the tool, the llm will call to check to see which hooks are available to validate the decision it's trying to take. I think it already knows roughly what nuxt can do and in which context things are relevant. It doesn't usually know which new hooks exist however, so it's an improvement as it now it factors in hooks from plugins or any additional hooks that have been added.

Figures out context of each hook

image

Example: Current usage

image

Example: Report Incorrect usage

It will also report incorrect usage of hooks if the name doesn't exist, can be useful if users aren't running TS. It's a bit of a concern however, as I've have noticed that the list isn't complete, callHook needs to be called before it's visible as some listed here, you could argue it's good because you know which ones are actually available during the nuxt runtime.

image

If we can get the list to be accurate I think it could be a useful tool to have, however I'm not sure if that could be possible, probably not worth adding if the list isn't accurate.

@JosephAnson JosephAnson closed this Apr 4, 2025
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