Skip to content

feat: derive opencode instructions from Data Machine injectable memory files#193

Merged
chubes4 merged 1 commit into
mainfrom
sync-instructions
Jun 7, 2026
Merged

feat: derive opencode instructions from Data Machine injectable memory files#193
chubes4 merged 1 commit into
mainfrom
sync-instructions

Conversation

@chubes4
Copy link
Copy Markdown
Member

@chubes4 chubes4 commented Jun 7, 2026

Summary

Extends the dm-agent-sync opencode plugin so the top-level instructions list is derived from Data Machine's registered injectable memory files instead of a static, hand-maintained array in opencode.json that silently drifts whenever a new memory file is registered in DM.

Closes #192. Depends on Extra-Chill/data-machine#2568 (the injectable-files command this consumes).

Problem

Two disconnected injection systems existed:

  1. DM runtime AI calls — inject all registered memory files (incl. new ones like WAKE.md). ✓
  2. opencode sessions — read a static instructions array in opencode.json that nothing keeps in sync with DM's registry.

dm-agent-sync previously only ran datamachine memory compose (refreshing composable files like AGENTS.md); it never touched the instructions list. So any memory file DM registers for injection was invisible to opencode sessions until someone hand-edited opencode.json — a latent drift bug for the whole class of "new memory file."

Fix

In the plugin's config hook, after the existing compose, call:

wp datamachine memory injectable-files --format=json

parse the resolved absolute paths, and write them into config.instructions. The opencode config(input) hook receives a mutable Config whose instructions?: string[] field we replace. Now any file DM registers for injection flows to opencode automatically — zero hand-edits, drift bug gone.

Graceful degradation

Leaves the existing instructions list untouched if:

  • DM predates the command (call exits non-zero),
  • output can't be parsed as JSON,
  • or no paths come back.

DM already filters to on-disk files, so a registered-but-not-yet-written file (e.g. a briefing before its task first runs) can't break session load.

Layer boundary (correct split)

  • data-machine (#2568) answers "which of MY files should inject?" — generic resolved paths, no opencode knowledge.
  • this plugin owns "how opencode consumes that" — the injectable-files call + writing config.instructions. Runtime-specific code lives here, the only place it belongs.

Verification

  • TypeScript transpiles clean (bun build bridges/kimaki/plugins/dm-agent-sync.ts).
  • The consumed command was verified live in the DM PR (#2570 / data-machine#2568): for the primary agent it returns NETWORK/SITE/RULES/SOUL/USER/MEMORY — exactly the set currently hardcoded in opencode.json — so this swap is behavior-preserving today, and additive (WAKE.md etc.) once those land.

Note: homeboy lint on the local VPS dev box currently fails ESLint with a js-yaml parse error trying to load eslint.config.mjs via the legacy eslintrc loader — that's an environment/toolchain mismatch on this box (ESLint 8.57 + flat config), not a finding against this file (0 findings reported). CI uses its own pinned toolchain.

Constraints honored

  • Conventional commit (feat:).
  • No version bumps / changelog edits (homeboy-managed).

…y files

The dm-agent-sync plugin already recomposes Data Machine's composable memory
files on session start. This extends it to also derive opencode's top-level
`instructions` list from DM's registered injectable memory files, replacing the
static, hand-maintained list in opencode.json that silently drifts whenever a
new memory file is registered in DM.

On session start, after the existing compose, it calls
`wp datamachine memory injectable-files --format=json`, parses the resolved
absolute paths, and writes them into config.instructions via the opencode
`config` hook. Any file DM registers for injection (e.g. a new briefing file)
now flows to opencode automatically with no hand-edits.

Graceful no-op: if DM predates the command, the call fails, the output can't be
parsed, or no paths come back, the existing instructions list is left
untouched. DM already filters to on-disk files, so a registered-but-not-yet-
written file can't break session load.

Layer boundary: DM stays agnostic (injectable-files returns generic paths,
knows nothing about opencode). The opencode-specific knowledge — writing those
paths into config.instructions — lives here in the integration layer, the only
place runtime-specific code belongs.

Verified: TypeScript transpiles clean (bun build). The opencode config hook
receives a mutable Config whose `instructions?: string[]` field is replaced.

Refs #192
Depends on Extra-Chill/data-machine#2568 (the injectable-files command)
@chubes4 chubes4 merged commit 09aaf70 into main Jun 7, 2026
5 checks passed
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.

feat: sync opencode instructions list from Data Machine's injectable memory files

1 participant