fix(upgrade): migrate agent.build.prompt to instructions array#66
Merged
fix(upgrade): migrate agent.build.prompt to instructions array#66
Conversation
agent.build.prompt/agent.plan.prompt in opencode.json pushes custom
prompts to the top of system[1], displacing the canonical OpenCode
opening. Anthropic's third-party-app detector fingerprints the first
bytes of system[1] on Claude Max OAuth requests; when the canonical
opening is missing, it routes to extra-usage billing and returns 400.
The upgrade script previously skipped Phase 2b (opencode.json drift
check) entirely when the primary runtime was claude-code, even though
opencode.json exists and kimaki spawns opencode sessions. This left
existing installs stuck on the old format with no automated fix path.
Changes:
- repair-opencode-json.py: add prompt migration alongside plugin check
- parse_file_includes() extracts {file:./path} from legacy prompts
- check_prompt_migration() detects agent.build.prompt/plan.prompt
- apply_prompt_migration() removes prompt keys, sets instructions array
- prompt check runs for ALL runtimes; plugin check stays opencode-only
- upgrade.sh: remove runtime gate on check_opencode_json_drift()
- Phase 2b now runs whenever opencode.json exists on disk
- Updated docs/help text for --repair-opencode-json to cover migration
- Summary warns about both plugin and prompt drift
Fixes: wp-coding-agents#60 (automated migration for existing installs)
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.
Problem
Existing installs set up before #60 have
agent.build.prompt/agent.plan.promptin theiropencode.json. This format pushes custom prompts to the top ofsystem[1], displacing OpenCode's canonical opening. Anthropic's third-party-app detector fingerprints the first bytes ofsystem[1]on Claude Max OAuth requests — when the canonical opening is missing, it routes to extra-usage billing and returns 400.The upgrade script's Phase 2b skipped the drift check entirely when the primary runtime was
claude-code, so installs where kimaki spawns opencode sessions (like chubes.net) were stuck with no automated fix path.Changes
lib/repair-opencode-json.py— added prompt migration alongside existing plugin check:parse_file_includes()— extracts{file:./path}references from legacy prompt stringscheck_prompt_migration()— detectsagent.build.prompt/agent.plan.promptpresenceapply_prompt_migration()— removespromptkeys, sets top-levelinstructionsarrayupgrade.sh— Phase 2b now runs wheneveropencode.jsonexists:RUNTIME != "opencode"gate oncheck_opencode_json_drift()--repair-opencode-jsonnow fixes both plugin array and prompt formatTesting
Verified on chubes.net VPS (runtime: claude-code, bridge: kimaki):
opencode.json→ diagnostic detectsprompt_migration: "needed"--apply→ migrates correctly, preserves mode/model/plugin/permissionsok(idempotent)upgrade.sh --dry-runwith old config → warns about driftupgrade.sh --dry-runwith new config → reports "matches current setup"