feat(dm-agent-sync): recompose composable files at session start#58
Merged
feat(dm-agent-sync): recompose composable files at session start#58
Conversation
Coding-agent sessions read AGENTS.md once at the top. DM's new ComposableFileInvalidation keeps the file fresh while WordPress is handling requests — but state changed by cron, direct DB edits, WP-CLI, or external processes between requests leaves AGENTS.md stale until the next triggering hook fires. Add a single `wp datamachine agent compose` call at the start of each runtime's sync path: - hooks/dm-agent-sync.sh (Claude Code + Studio Code SessionStart): runs compose immediately after WP-CLI detection, before computing @ includes. - kimaki/plugins/dm-agent-sync.ts (OpenCode config hook): runs compose before listing agents and building agent-switcher entries. Both calls are silenced and tolerate missing DM — no behavior change on sites without Data Machine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
hooks/dm-agent-sync.sh: runswp datamachine agent composeimmediately after WP-CLI detection, before building the CLAUDE.md@include block. Covers Claude Code and Studio Code SessionStart.kimaki/plugins/dm-agent-sync.ts: OpenCodeconfighook runs the same compose call before listing agents and assembling agent-switcher entries.Both calls are silenced and tolerate missing DM — no behavior change on sites without Data Machine.
Why
Coding-agent sessions read AGENTS.md once at the top and cache it for the duration of the session. DM's
ComposableFileInvalidation(see Extra-Chill/data-machine#1160) keeps AGENTS.md fresh while WordPress is handling requests, but state changed by cron, direct DB edits, WP-CLI invocations, or other external processes between requests leaves the on-disk file stale until the next in-request invalidation hook fires.A single compose call at session-start makes this a non-issue: the file on disk matches live state at the exact moment the external runtime reads it. Belt-and-suspenders with DM's in-request invalidation.
Pairs with
Configured Sourcesstate to the AGENTS.md section and registers on the new DM filter.This PR stands alone:
agent composehas existed in DM for a long time, so the compose call is safe against any DM version.Test plan
claudesession start runs the hook,agent composeruns, AGENTS.md is updated, CLAUDE.md@include block is rewritten. Confirm viaclaude --debuglogs or file mtime.opencodeinvocation runs the plugin'sconfighook, compose fires, agent switcher reflects current agent roster + file paths.🤖 Generated with Claude Code