Skip to content

feat(dm-agent-sync): recompose composable files at session start#58

Merged
chubes4 merged 1 commit intomainfrom
feat/dynamic-directives-external-runtimes
Apr 22, 2026
Merged

feat(dm-agent-sync): recompose composable files at session start#58
chubes4 merged 1 commit intomainfrom
feat/dynamic-directives-external-runtimes

Conversation

@chubes4
Copy link
Copy Markdown
Member

@chubes4 chubes4 commented Apr 22, 2026

Summary

  • hooks/dm-agent-sync.sh: runs wp datamachine agent compose immediately after WP-CLI detection, before building the CLAUDE.md @ include block. Covers Claude Code and Studio Code SessionStart.
  • kimaki/plugins/dm-agent-sync.ts: OpenCode config hook 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

This PR stands alone: agent compose has existed in DM for a long time, so the compose call is safe against any DM version.

Test plan

  • Claude Code: claude session start runs the hook, agent compose runs, AGENTS.md is updated, CLAUDE.md @ include block is rewritten. Confirm via claude --debug logs or file mtime.
  • Studio Code: same flow.
  • OpenCode: opencode invocation runs the plugin's config hook, compose fires, agent switcher reflects current agent roster + file paths.
  • Site without Data Machine: both runtimes no-op silently (already covered by existing DM-detection guards; verify no error output).
  • Rapid session starts: DM's 60-second debounce prevents redundant disk writes; the compose call itself is idempotent.

🤖 Generated with Claude Code

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.
@chubes4 chubes4 merged commit 8ec7f1c into main Apr 22, 2026
2 checks passed
@chubes4 chubes4 deleted the feat/dynamic-directives-external-runtimes branch April 22, 2026 13:28
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.

1 participant