feat(opencode-bridge): P4 close remaining data gaps — exitCode, reason, cwd, stdout#976
Merged
Conversation
…n, cwd, stdout - Add exitCode/exit_code to postToolUse toolResult (from metadata or derived from isError). Unlocks SkillUsageRule, TokenTrackerRule, VerificationGateRule numeric exit code checks. - Add stdout alias for toolResult.output — rules that check toolResult.stdout now work (VerificationGateRule). - Add reason field to sessionEnd payload. session.idle events pass reason= "idle" instead of "unknown". SessionEndRule goal pause breadcrumb now shows accurate reason. - Add cwd to userPromptSubmitted — UserPromptContextRule can locate project-local CONTEXT.md without falling back to os.getcwd(). All 38 bridge tests + 13 security tests pass.
Owner
Author
|
/copilot-review |
…ION_ID shell.env hook injects COPILOT_AGENT_SESSION_ID into all subprocess environments (bash tool, shell mode, PTY terminals) when opencode's own session ID is available and the env var isn't already set. This enables get_session_id() and rules that read env vars directly (RecurrenceDetectorRule, SessionCompilerRule, EpisodeBatcherRule) to correctly identify the session without falling back to ppid-<PPID>.
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
Closes all remaining data gaps between the opencode bridge and hook_runner rules.
Changes
exitCode/exit_codein toolResult — reads fromoutput.metadata.exitCodeormetadata.exit_code, falls back to deriving fromisError(1 error / 0 success). Unlocks SkillUsageRule, TokenTrackerRule, VerificationGateRule numeric exit code checks.stdoutalias —toolResult.stdout = output.outputfor rules that checktoolResult.stdout(VerificationGateRule).reasonin sessionEnd —session.idleevents now passreason: "idle"instead ofreason: "unknown". SessionEndRule goal pause breadcrumb now shows accurate reason.cwdin userPromptSubmitted — UserPromptContextRule can locate project-localCONTEXT.mdwithout falling back toos.getcwd().Remaining Gaps
After P4, the data flow between bridge and hook_runner is complete for all 10 events. The remaining architectural gaps (agentStop, voting, shell.env, tool.definition) cannot be closed via data mapping — they would require feature additions to opencode's plugin API or fall under "deeply CLI-tied" rules.
Testing
Part of Phase 2 opencode bridge (continuing from PR #973, #974, #975)