feat: introduce macher-context-resolved-functions hook#61
Conversation
|
Thanks @elij ! I'm definitely open to adding something like this, though I've also been messing with the idea of storing the context buffer-locally (rather than scoped to a closure for the request) - the idea would be that the context can then be reset at the beginning of a request (this would probably be the default behavior as it functionally matches the current behavior), or preserved and passed forward to the next request, or modified by other packages, etc. This might solve the issue in a way that doesn't lock macher into this tool-override magic that's currently being performed. Alongside this, I'd probably also add tools to view the current diff between the workspace and the filesystem, and/or merge the current filesystem state into the workspace. The best API for this isn't quite obvious to me yet. Could you share a bit more about your use case? |
|
It's basically as you describe so it's good to know you're thinking about it! The use case is a feed forward in a 3 way merge (or macher revise by default) -- original file system, in flight diff, and context invalidation (file system changed). Context invalidation is either manual (rejected patch, but this needs strong prompts) or file system modified without applying patch. Basically using macher in agentic workflows -- this is in flight diffs but I'm also doing cross buffer workflows and using tools on the context state. This is strictly in the macher workflow which is my preferred framework for this. I am curious about your vision for tools applied to context as I'm using rsync but there might be a better way that you're thinking about! |
Introduces `macher-context-resolved-functions`, a context interception hook that fires immediately after it is lazily resolved for a request. This enables dependent packages to safely modify the context object, trigger file system side-effects, or inject a persistent context by updating the FSM state prior to tool execution. If a hook function replaces the context in the FSM, the new context is correctly adopted and returned.
This PR introduces a new hook to better support downstream packages that need to hook into the macher request lifecycle.
Previously, packages requiring a persistent context or file system syncs before a revision request had to aggressively advise macher--setup-tools. By natively triggering macher-context-resolved-functions inside the lazy initializer, extensions can safely tap into the flow.
Key changes: