feat: derive opencode instructions from Data Machine injectable memory files#193
Merged
Conversation
…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)
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
Extends the
dm-agent-syncopencode plugin so the top-levelinstructionslist is derived from Data Machine's registered injectable memory files instead of a static, hand-maintained array inopencode.jsonthat silently drifts whenever a new memory file is registered in DM.Closes #192. Depends on Extra-Chill/data-machine#2568 (the
injectable-filescommand this consumes).Problem
Two disconnected injection systems existed:
instructionsarray inopencode.jsonthat nothing keeps in sync with DM's registry.dm-agent-syncpreviously only randatamachine 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-editedopencode.json— a latent drift bug for the whole class of "new memory file."Fix
In the plugin's
confighook, after the existing compose, call:parse the resolved absolute paths, and write them into
config.instructions. The opencodeconfig(input)hook receives a mutableConfigwhoseinstructions?: 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 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)
injectable-filescall + writingconfig.instructions. Runtime-specific code lives here, the only place it belongs.Verification
bun build bridges/kimaki/plugins/dm-agent-sync.ts).opencode.json— so this swap is behavior-preserving today, and additive (WAKE.md etc.) once those land.Constraints honored
feat:).