diff --git a/.planning/REQUIREMENTS.md b/.planning/REQUIREMENTS.md index c829cf1..888bdfb 100644 --- a/.planning/REQUIREMENTS.md +++ b/.planning/REQUIREMENTS.md @@ -18,7 +18,7 @@ Requirements for initial release. Each maps to roadmap phases. - [ ] **STATE-01**: vmux détecte l'état de chaque session : travaille / attend input / idle - [ ] **STATE-02**: vmux affiche un aperçu des dernières lignes de sortie de chaque session -- [ ] **STATE-03**: vmux distingue le type d'attente (permission prompt, question utilisateur, idle prompt) +- [x] **STATE-03**: vmux distingue le type d'attente (permission prompt, question utilisateur, idle prompt) - [x] **STATE-04**: vmux affiche le temps écoulé depuis que la session attend ("depuis 3 min") ### i3 Integration @@ -72,7 +72,7 @@ Which phases cover which requirements. Updated during roadmap creation. | DISC-04 | Phase 2 | Complete | | STATE-01 | Phase 1 | Pending | | STATE-02 | Phase 1 | Pending | -| STATE-03 | Phase 3 | Pending | +| STATE-03 | Phase 3 | Complete | | STATE-04 | Phase 2 | Complete | | I3-01 | Phase 2 | Complete | | I3-02 | Phase 2 | Complete | diff --git a/.planning/ROADMAP.md b/.planning/ROADMAP.md index 87750ce..3bb032c 100644 --- a/.planning/ROADMAP.md +++ b/.planning/ROADMAP.md @@ -61,7 +61,7 @@ Plans: **Plans**: 2 plans Plans: -- [ ] 03-01-PLAN.md — HookEvent types, processHookEvent mapping, HTTP handler, WaitType dans SessionInfo +- [x] 03-01-PLAN.md — HookEvent types, processHookEvent mapping, HTTP handler, WaitType dans SessionInfo - [ ] 03-02-PLAN.md — Hook server integre au daemon, poll dynamique, affichage WaitType ### Phase 4: Notifications et i3bar diff --git a/.planning/STATE.md b/.planning/STATE.md index 7018eec..8c444aa 100644 --- a/.planning/STATE.md +++ b/.planning/STATE.md @@ -2,14 +2,14 @@ gsd_state_version: 1.0 milestone: v1.0 milestone_name: milestone -status: Ready to plan -stopped_at: Phase 3 context gathered -last_updated: "2026-03-23T18:24:41.510Z" +status: Ready to execute +stopped_at: Completed 03-01-PLAN.md +last_updated: "2026-03-23T18:42:29.103Z" progress: total_phases: 4 completed_phases: 2 - total_plans: 5 - completed_plans: 5 + total_plans: 7 + completed_plans: 6 --- # Project State @@ -19,12 +19,12 @@ progress: See: .planning/PROJECT.md (updated 2026-03-23) **Core value:** Savoir instantanement quelle session Claude Code a besoin de moi, sans scanner manuellement mes workspaces. -**Current focus:** Phase 02 — daemon-et-i3-bridge +**Current focus:** Phase 03 — hook-server ## Current Position -Phase: 3 -Plan: Not started +Phase: 03 (hook-server) — EXECUTING +Plan: 2 of 2 ## Performance Metrics @@ -50,6 +50,7 @@ Plan: Not started | Phase 01 P02 | 4min | 2 tasks | 8 files | | Phase 02 P01 | 5min | 2 tasks | 5 files | | Phase 02 P02 | 4min | 2 tasks | 7 files | +| Phase 03 P01 | 3min | 2 tasks | 4 files | ## Accumulated Context @@ -67,6 +68,8 @@ Recent decisions affecting current work: - [Phase 02]: X11PIDResolver interface pour abstraire ewmh et tester sans X11 - [Phase 02]: maxPPIDDepth=20 pour securiser la remontee de chaine PPID - [Phase 02]: Priorite fuzzy match : label > branche > cwd +- [Phase 03]: UpdateFromHook separe de Update: hooks ne connaissent pas PID/GitBranch/Preview +- [Phase 03]: WaitType omitempty pour compatibilite clients existants ### Pending Todos @@ -78,6 +81,6 @@ None yet. ## Session Continuity -Last session: 2026-03-23T18:24:41.507Z -Stopped at: Phase 3 context gathered -Resume file: .planning/phases/03-hook-server/03-CONTEXT.md +Last session: 2026-03-23T18:42:29.101Z +Stopped at: Completed 03-01-PLAN.md +Resume file: None diff --git a/.planning/phases/03-hook-server/03-01-SUMMARY.md b/.planning/phases/03-hook-server/03-01-SUMMARY.md new file mode 100644 index 0000000..4cbbbde --- /dev/null +++ b/.planning/phases/03-hook-server/03-01-SUMMARY.md @@ -0,0 +1,92 @@ +--- +phase: 03-hook-server +plan: 01 +subsystem: api +tags: [http-hooks, claude-code, json, net-http, event-mapping] + +requires: + - phase: 02-daemon-et-i3-bridge + provides: SessionRegistry, TrackedSession, Daemon, SessionInfo +provides: + - HookEvent struct parsing Claude Code hook JSON + - processHookEvent mapping 4 event types to State+WaitType + - UpdateFromHook with auto-create and WaitingSince transitions + - handleHook HTTP handler with POST validation and body size limit + - SessionInfo.WaitType field for wait type discrimination +affects: [03-hook-server] + +tech-stack: + added: [net/http, net/http/httptest] + patterns: [HTTP handler with MaxBytesReader, event-to-state mapping via switch] + +key-files: + created: [hook.go, hook_test.go] + modified: [protocol.go, protocol_test.go] + +key-decisions: + - "WaitType omitempty: champ vide omis du JSON pour compatibilite avec les clients existants" + - "UpdateFromHook separe de Update: les hooks ne connaissent pas PID/GitBranch/Preview, donc methode dediee qui ne touche que les champs connus" + +patterns-established: + - "Hook event mapping: switch sur HookEventName puis NotificationType pour determiner State+WaitType" + - "HTTP handler pattern: method check, MaxBytesReader, JSON decode, process, 200 OK" + +requirements-completed: [STATE-03] + +duration: 3min +completed: 2026-03-23 +--- + +# Phase 03 Plan 01: Hook Event Processing Summary + +**HookEvent parsing, event-to-state mapping (Notification/Stop/PostToolUse/PreToolUse), UpdateFromHook avec auto-create, et HTTP handler POST /hook avec validation** + +## Performance + +- **Duration:** 3 min +- **Started:** 2026-03-23T18:38:37Z +- **Completed:** 2026-03-23T18:41:45Z +- **Tasks:** 2 +- **Files modified:** 4 + +## Accomplishments +- HookEvent struct couvre tous les champs du payload Claude Code hooks +- processHookEvent mappe les 4 types d'events (Notification, Stop, PostToolUse, PreToolUse) vers State+WaitType +- UpdateFromHook gere les sessions inconnues et les transitions WaitingSince +- handleHook HTTP handler valide method, body size (64KB), et JSON +- 16 tests couvrent tous les cas + +## Task Commits + +1. **Task 1: HookEvent struct, processHookEvent mapping, UpdateFromHook, WaitType** - `e1b176c` (feat) +2. **Task 2: HTTP handler POST /hook avec validation et protection** - `5bec943` (feat) + +## Files Created/Modified +- `hook.go` - HookEvent struct, handleHook HTTP handler, processHookEvent, UpdateFromHook +- `hook_test.go` - 16 tests (12 mapping + 4 HTTP handler) +- `protocol.go` - SessionInfo enrichi avec WaitType +- `protocol_test.go` - Test serialisation JSON de WaitType + +## Decisions Made +- WaitType omitempty : le champ vide est omis du JSON pour ne pas casser les clients existants qui ignorent ce champ +- UpdateFromHook est une methode separee de Update car les hooks ne connaissent pas PID, GitBranch, Preview, Workspace, Label + +## Deviations from Plan + +None - plan executed exactly as written. + +## Issues Encountered +None + +## User Setup Required +None - no external service configuration required. + +## Next Phase Readiness +- hook.go fournit toute la logique de traitement. Le plan 03-02 peut integrer le HTTP server dans le Daemon (startHookServer, hookPort, poll slowdown). +- handleHook est pret a etre monte sur un http.ServeMux. + +--- +*Phase: 03-hook-server* +*Completed: 2026-03-23* + +## Self-Check: PASSED