feat: live stack-state injection via agent harness hook (#304) - #306
Draft
aarontrowbridge wants to merge 2 commits into
Draft
feat: live stack-state injection via agent harness hook (#304)#306aarontrowbridge wants to merge 2 commits into
aarontrowbridge wants to merge 2 commits into
Conversation
aarontrowbridge
force-pushed
the
304-feat-live-stack-state-injection-via-agent-harness-hook
branch
from
August 20, 2026 08:48
a91ada6 to
a37166a
Compare
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Adds a second opencode plugin (amicode_context.ts) implementing experimental.chat.system.transform that reads solver mode, routing, active problem, and live runs on every prompt build and injects them as the final system[] entry. - opencode-plugin/stack_state.ts — standalone state readers + builders - opencode-plugin/amicode_context.ts — system.transform hook plugin - src/opencode_config — removed solver/routing from file splice; buildOpencodeConfigContent accepts extraPluginPaths param - src/extension.ts — registers context plugin in boot + solver-switch; fixes mkdtemp asymmetry in solver-switch re-prep - AGENTS.md — one-line recovery pointer appended Closes #304.
Extends the amicode_context plugin's system.transform injection so the sections that went stale as boot-time file splices are read LIVE from disk on every prompt build: - stack_state.ts: lean fleet line (role from fleet.json, devices + freshness from fleet-status.json, on-demand pointers) — absent fleet.json renders nothing; marker-only Armonia mount discovery (smol-toml-free port of mount_store semantics: kind ranks, duplicate skip, kind-rank order) + the user-memory sections (profile, recent problems, reference demos, mount stack, memory index) read from the personal vault, section text byte-identical to the retired substrate/user_splice.ts builders (pinned golden in test/stack_state.test.ts, 14 cases incl. caps + splice-parity order) - opencode_config.ts: the boot-time user-memory/mount/memory splices are REMOVED (they were the staleness bug: hand-maintained server bundles and re-prepped project dirs served yesterday's memory index); the template AGENTS.md carries the single broadened recovery pointer (replaces the programmatic append — was duplicated) - user_splice.ts + vault_store's now-dead index readers deleted; solverModeSection/routingSection stay as the WIP's parity oracles - packaging.test.ts pins amicode_context.ts + stack_state.ts as must-ship vsix assets (the server config's dead reference goes live the moment a vsix carries them) Closes the 'Amicode forgets the fleet' class: a distiller write, a solver switch, or a vault sync reaches the next message without a re-prep or server restart.
aarontrowbridge
force-pushed
the
304-feat-live-stack-state-injection-via-agent-harness-hook
branch
from
August 21, 2026 13:26
a37166a to
8d39f63
Compare
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.
Implements #304.
Adds a second opencode plugin (
amicode_context.ts) implementingexperimental.chat.system.transformthat reads live state on every prompt build and injects it as the finalsystem[]entry.Scope (expanded 2026-08-21): the original WIP moved solver mode + routing off the boot-time file splice. This update finishes the job — the fleet line and the user-memory sections (profile, recent problems, reference demos, mount stack, memory index) also move to the live hook. Motivation: the boot-time splices were the "Amicode forgets the fleet" bug class — a hand-maintained server bundle (the canonical launchd server's staging dir) or a stale re-prep served yesterday's memory index and yesterday's solver mode to every new session (observed: 10-entry index frozen at Aug 16 vs 18 live; cloud-HP solver instructions served after the user switched back to Piccolo).
Key changes:
opencode-plugin/stack_state.ts— standalone state readers + markdown builders (node-builtins only for Bun runtime): solver mode, routing, active problem, live runs (original WIP) + NEW lean fleet line (~/.amico/ops/fleet/fleet.jsonrole,fleet-status.jsondevices/freshness with stale/unreadable degradation, on-demand pointers — absent fleet.json renders nothing) + NEW marker-only Armonia mount discovery (smol-toml-free port of mount_store semantics: kind ranks, duplicate-id skip, kind-rank ordering) and the five user-memory sections read live from the personal vault, section text byte-identical to the retiredsubstrate/user_splice.tsbuilders. No mounts.toml manifest support (smol-toml unavailable in Bun; no manifest exists in practice — documented in-module).opencode-plugin/amicode_context.ts— the plugin, single export, one hook (unchanged)src/opencode_config.ts— solver/routing AND the user-memory/mount/memory-index splices removed fromprepareOpencodeProject(the latter previously the only injector);buildOpencodeConfigContentacceptsextraPluginPaths(original WIP)src/extension.ts— boot + solver-switch register the context plugin; solver-switchprojectDirasymmetry fixed (original WIP)packages/extension/AGENTS.md— single broadened recovery pointer (template tail) covering solver mode, routing, fleet, and the vault files; replaces the WIP's programmatic append (was duplicated)substrate/user_splice.ts+ the now-dead vault_store index readers (KNOWLEDGE/DEMOS/MEMORY) — the plugin owns that text now, pinned golden intest/stack_state.test.ts(14 cases: fleet rendering + degradation, mount discovery incl. duplicate/marker-less skips, section text parity with the retired builders, caps 50/30/50, splice-parity section order, hermetic env-seam composition).solverModeSection/routingSectiondeliberately stay as the original WIP's parity oracles (test-only) — noted asymmetry, reviewer's call whether to fold them into stack_state pins too.test/packaging.test.ts— pinsamicode_context.ts+stack_state.tsas must-ship vsix assets.Hook support verified against the deployed fork binary:
experimental.chat.system.transformis typed (packages/plugin/src/index.ts:291), triggered (agent/agent.ts:381), and the frozen canonical server binary contains the hook string. Silent no-op remains the failure mode if a binary lacks it — which is why the recovery pointer exists.Deployment sequencing (the canonical launchd server serves a hand-staged bundle):
amicode_context.tsreference — dead since it was added — goes live the moment the newest installed vsix ships it).__EXT__to the newest vsix at boot).~/.amico/server/opencode-project-staging/opencode-project/AGENTS.md— until then they render twice (harmless, just noisy).Verification:
tsc --noEmitclean; full extension suite 1186 passed / 5 skipped / 100 files.