Add the plugin's SessionStart hook so a session learns its own id (issue 1744)

A session is never told its session id by any tool, only by a hook's
stdin, so it cannot name itself to claude_code_wait. The plugin's
SessionStart hook (claude-code session-start <waits-dir>) prints the id
and how to give it, plus the session's still-open waits after a /clear,
reading the waits file claude_code_wait mirrors directly rather than
calling back into this module. Carries the Stop hook's command and the
GuardFiles.WaitsDir plumbing MarketplaceWith needs for both (issue 1743
wires the Stop hook's dispatch next).
This commit is contained in:
jochen
2026-10-21 18:07:36 +02:00
parent 56c68be7fa
commit 37628f4bce
6 changed files with 198 additions and 6 deletions
+12 -2
View File
@@ -130,9 +130,15 @@ var waiting *Waiting
// nodes never collide over the same session id.
func waitsKey(p Paths, session string) string { return p.Node + "/" + session }
// waitsFilePath is where one session's waits are mirrored, under the agent's home.
// WaitsDirPath is where this node's sessions' waits are mirrored, under the agent's home: the directory the
// plugin's SessionStart and Stop hooks (1744, 1743) are given on their command line.
func WaitsDirPath(p Paths) string {
return filepath.Join(p.Home, ".claude", filepath.FromSlash(WaitsDir))
}
// waitsFilePath is where one session's waits are mirrored.
func waitsFilePath(p Paths, session string) string {
return filepath.Join(p.Home, ".claude", filepath.FromSlash(WaitsDir), session+".json")
return filepath.Join(WaitsDirPath(p), session+".json")
}
func newWaitID() string {
@@ -396,6 +402,10 @@ func ListWaits(p Paths, session string, store WaitStore, now time.Time) (map[str
return map[string]any{"session": session, "open": out}, nil
}
// waitsFileIn is where one session's mirrored waits are, given a hook's own waits-dir argument: the hooks
// have no launch environment, only their command line, so they never recompute this from Paths.
func waitsFileIn(waitsDir, session string) string { return filepath.Join(waitsDir, session+".json") }
// readWaitsFile reads one session's mirrored file, as the hooks do: a plain local read, as the session's own
// account (never through fsys or the module's state), and never calling back into this module.
func readWaitsFile(path string) (WaitsFile, error) {