Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions hooks/dm-agent-sync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ detect_wp_cmd() {

WP_CMD=$(detect_wp_cmd) || exit 0

# ---------------------------------------------------------------------------
# Refresh composable files before computing @ includes
# ---------------------------------------------------------------------------
# SectionRegistry callbacks can read live state (Intelligence sources, skill
# inventory, etc.). DM regenerates composable files when their feeder state
# fires a registered invalidation hook, but those hooks only run inside a
# WordPress request. State changed via direct DB edits, cron, or external
# processes would leave the on-disk file stale. Running `agent compose` here
# guarantees AGENTS.md (and any sibling composable files) match live state
# at the moment the coding-agent session starts.

$WP_CMD datamachine agent compose >/dev/null 2>&1 || true

# ---------------------------------------------------------------------------
# Query active agents from Data Machine
# ---------------------------------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions kimaki/plugins/dm-agent-sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ const dmAgentSync: Plugin = async ({ $ }) => {
return {
config: async (config) => {
try {
// Refresh composable files before the session reads them.
// DM SectionRegistry callbacks render live state (configured sources,
// skills, config). DM's own invalidation hooks cover state changes
// that happen inside a WordPress request, but cron jobs, direct DB
// edits, or other external processes would leave AGENTS.md stale.
// Running compose here guarantees the file matches live state at the
// moment OpenCode loads the session prompt.
await $`wp datamachine agent compose --allow-root 2>/dev/null`.quiet().nothrow();

// Query all agents from Data Machine.
const agentsRaw = await $`wp datamachine agents list --format=json --allow-root 2>/dev/null`.quiet().nothrow().text();

Expand Down
Loading