Conversation
SubagentStopフックのJSON出力対応のため、SubagentStopOutput型をtypes.goに追加。 StopOutputと同じスキーマを使用(公式仕様に準拠)。
ExecuteSubagentStopAction_TypeOutputテストケースを追加。 9つのシナリオ(decision未指定/block+reason/fail-safe等)をカバー。 テストをコンパイル可能にするため、ExecuteSubagentStopActionのシグネチャを (*ActionOutput, error)に変更し、スタブ実装を追加。hooks.goの呼び出し元も修正。
ExecuteSubagentStopAction_TypeCommandテストケースを追加。 9つのシナリオ(有効JSON/コマンド失敗/無効JSON/fail-safe等)をカバー。 Stopと同じスキーマのため、同様のテストパターンを使用。
ExecuteStopActionと同じロジックでSubagentStop JSON出力を実装。 - command/outputアクション両対応 - fail-safe: エラー時はdecision="block" - checkUnsupportedFieldsSubagentStopを追加 - テストケースのwantSystemMessage期待値を修正 全18テストケースがパス(TypeOutput 9件、TypeCommand 9件)
executeStopHooksと同じマージロジックでSubagentStop hooks実装。 - 複数アクションのdecision/reason/systemMessageマージ - decision="block"時のearly return - fail-safe: アクションエラー時にdecision="block" - runHooksのSubagentStopブランチ更新(戻り値を破棄) - 既存テスト2件 + 新規テスト8件を修正/追加 全テストパス(SubagentStop関連27件)
main.goから呼び出す公開ラッパー関数を実装。 - stdin入力のパース - executeSubagentStopHooksへの委譲 - (*SubagentStopOutput, error)を返してJSON化対応 RunStopHooksと同じパターン。Step 5完了。
Step 3 (validate)とStep 6 (main.go)を実装完了。 - utils.go: validateSubagentStopOutputを追加(StopとStopOutput同じスキーマ) - utils_test.go: TestValidateSubagentStopOutputを追加(5テストケース) - main.go: SubagentStop JSON出力ハンドリング追加(Stopと同じパターン) - RunSubagentStopHooks呼び出し - fail-safe: エラー時decision="block" - JSON Marshal + validate + stdout出力 - 常にexit 0 全テストパス。ビルド成功。
CLAUDE.mdとREADME.mdにSubagentStop JSON出力の説明を追加。 - CLAUDE.md: SubagentStop JSON Outputセクション追加(Stopと同じパターン) - Output/Command action形式 - Field merging、Exit code behavior、Exampleを記載 - README.md: Exit Status Controlセクション更新 - JSON Output EventsにSubagentStopを追加 - Legacy Exit Code EventsからSubagentStopを除外 - exit_statusデフォルト一覧を更新 Step 1-6完了。ドキュメント整備完了。
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.
概要
SubagentStopフックをレガシーなexit codeベースの実装からJSON出力形式に移行し、Claude Code公式仕様に準拠させました。
背景
cchookは各フックイベントのJSON出力対応を段階的に進めています。SessionStart、UserPromptSubmit、PreToolUse、Stop、PostToolUseのJSON出力対応は完了済みでしたが、SubagentStopはレガシーなexit codeベースの実装が残っていました。Claude Code公式仕様ではSubagentStopもStopと同じJSON出力形式が必要とされています。
変更内容
SubagentStopOutput型を追加(StopOutputと同一スキーマ、公式仕様準拠)ExecuteSubagentStopActionをJSON出力対応に変更((*ActionOutput, error)を返すシグネチャに変更)decision="block"checkUnsupportedFieldsSubagentStopを追加executeSubagentStopHooksをJSON出力対応に変更decision="block"時のearly returndecision="block"RunSubagentStopHooks公開ラッパー関数を追加runHooksのSubagentStopブランチを更新validateSubagentStopOutputを追加(スキーマ検証 + セマンティック検証)TestExecuteSubagentStopAction_TypeOutput(9件)TestExecuteSubagentStopAction_TypeCommand(9件)TestExecuteSubagentStopHooksJSON(8件)TestValidateSubagentStopOutput(5件)関連情報