Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions .claude/hooks-config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ blocked_patterns = [
"git",
"jj-immutable",
"jj-main-guard",
"jj-push-guard",
"gh-pr-create-guard",
# "jj-push-guard", # E2E テスト中に一時的に無効化
# "gh-pr-create-guard", # E2E テスト中に一時的に無効化
"electron",
]

Expand Down Expand Up @@ -113,12 +113,14 @@ name = "commit_refactor"
type = "ai"
prompt = "optimize_commit_structure"

# ─── PostToolUse: PR モニター ───
# ─── Post-PR Monitor: daemon + state file ───
#
# gh pr create / git push / jj git push / pnpm push 検出後に
# CI + CodeRabbit の自動モニタリングを CronCreate で開始する。
# check-ci-coderabbit.exe によるポーリングで監視し、
# 結果の action フィールドに従って Claude が行動する。
# pnpm pr-create / pnpm push 実行時に daemon がバックグラウンドで起動し、
# check-ci-coderabbit.exe を定期ポーリングして結果を
# .claude/pr-monitor-state.json に書き出す。
# Claude は CronCreate で state file を cat し、action に従って行動する。
# CronCreate は UX 最適化レイヤーであり、コア機能ではない。
# フォールバック: cat .claude/pr-monitor-state.json で手動確認可能。
Comment on lines +116 to +123

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

同ファイル冒頭の SessionStart 説明がまだ旧 --resume フローです。

Line 11-12 には .session-id と claude -p --resume が残っているので、このセクションだけ新設計に更新すると設定ファイル内の説明が矛盾します。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.claude/hooks-config.toml around lines 116 - 123, Update the SessionStart
explanatory block to reflect the new design by removing references to the old
resume flow (specifically ".session-id" and the "claude -p --resume" invocation)
and replacing them with the new session startup semantics used elsewhere in this
config (keep CronCreate and pr-monitor-state.json details consistent). Locate
the SessionStart heading and its first lines that mention ".session-id" and
"claude -p --resume", delete or reword those lines to describe the current
startup mechanism and how the daemon reads/writes .claude/pr-monitor-state.json
so the file’s explanations no longer conflict.


[post_pr_monitor]
enabled = true
Expand Down
10 changes: 9 additions & 1 deletion docs/adr/adr-009-post-pr-monitor.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Claude が action フィールドに従い行動

| コンポーネント | 種別 | 役割 |
|---|---|---|
| `hooks-post-pr-monitor.exe` | スタンドアロン CLI (Rust) | PR 作成 + CronCreate 監視開始 |
| `hooks-post-pr-monitor.exe` | スタンドアロン CLI (Rust) | PR 作成 + daemon 起動 + state file 管理 |
| `hooks-pre-tool-validate.exe` | PreToolUse hook (Rust) | `gh-pr-create-guard` で直接の `gh pr create` をブロック |
| `check-ci-coderabbit.exe` | スタンドアロン CLI (Rust) | CI・CodeRabbit 状態チェック → JSON 出力 |
| `post-pr-create-review-check` SKILL.md | Claude Skill | 監視結果の解釈・報告手順 |
Expand Down Expand Up @@ -144,6 +144,14 @@ check_coderabbit = true
信頼性が低かった。push-pipeline と同じ「ガード + 専用コマンド + claude -p」パターンに
統一することで、CronCreate の実行を確実にした。

- **2026-04-05**: `claude -p --resume` → daemon + state file アーキテクチャに変更。
VSCode 拡張では `~/.claude/sessions/` に CLI セッションのみ登録されるため、
`claude -p --resume <session_id>` で VSCode セッションにアクセスできないことが判明。
外部プロセスから Claude セッションに状態を注入する設計自体がアンチパターンであると認識。
新設計: daemon が外部で監視を完結させ、結果を `.claude/pr-monitor-state.json` に書き出す。
Claude は state file を読むだけ。CronCreate は UX 最適化レイヤーとして維持(state file の
cat のみ実行)し、コア機能ではない。フォールバック: 手動 `cat` で確認可能。
Comment on lines +147 to +153

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

ADR 本文のフロー図も新設計に揃えた方がよいです。

変更履歴は daemon + state file 化を説明していますが、Line 55-83 のアーキテクチャ図はまだ claude -p 起点の旧フローです。今のままだと同じ ADR の中で新旧設計が混在します。

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/adr/adr-009-post-pr-monitor.md` around lines 147 - 153, The ADR
currently documents the daemon + state-file design in the prose but still
displays the old "claude -p" flow in the architecture/flow diagram section;
update that flow diagram so it depicts the new daemon →
.claude/pr-monitor-state.json → Claude (state-file read) flow, mark CronCreate
as an optional UX layer that only cats the state file, and remove or replace any
arrows/labels that show external processes injecting state into Claude or
starting from `claude -p` so the diagram matches the new design.


## 参考

- ADR-001 — hooks の実装言語として Rust を採用
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
"push": ".\\.claude\\hooks-push-pipeline.exe && .\\.claude\\hooks-post-pr-monitor.exe --monitor-only",
"pr-create": ".\\.claude\\hooks-post-pr-monitor.exe",
"check-ci": ".\\.claude\\check-ci-coderabbit.exe",
"mark-notified": ".\\.claude\\hooks-post-pr-monitor.exe --mark-notified",
"check-monitor": "type .\\.claude\\pr-monitor-state.json 2>NUL || echo No active monitor",
"deploy:hooks": "npx tsx scripts/deploy-hooks.ts",
"py-lint": "ruff check src/",
"py-test": "python -m pytest tests/",
Expand Down
26 changes: 26 additions & 0 deletions src/hooks-post-pr-monitor/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src/hooks-post-pr-monitor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ edition = "2021"

[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
toml = "0.8"

[profile.release]
Expand Down
Loading