From f43969b31ab3b83ec55ab0eb90b034556db457a7 Mon Sep 17 00:00:00 2001 From: Mario Zechner Date: Sun, 28 Dec 2025 14:50:45 +0100 Subject: [PATCH] Update plan: mark before_agent_start as complete --- .pi/hooks/test-command.ts | 2 +- packages/coding-agent/docs/session-tree-plan.md | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.pi/hooks/test-command.ts b/.pi/hooks/test-command.ts index 9e909de2..086770bd 100644 --- a/.pi/hooks/test-command.ts +++ b/.pi/hooks/test-command.ts @@ -10,7 +10,7 @@ export default function (pi: HookAPI) { // Register a custom message renderer for our "test-info" type pi.registerMessageRenderer("test-info", (message, options, theme) => { - const box = new Box(0, 0, (t) => theme.bg("success", t)); + const box = new Box(0, 0, (t) => theme.bg("customMessageBg", t)); const label = theme.fg("successText", "[TEST INFO]"); box.addChild(new Text(label, 0, 0)); diff --git a/packages/coding-agent/docs/session-tree-plan.md b/packages/coding-agent/docs/session-tree-plan.md index ad4f6c60..49c1ae0e 100644 --- a/packages/coding-agent/docs/session-tree-plan.md +++ b/packages/coding-agent/docs/session-tree-plan.md @@ -285,7 +285,7 @@ Benefits: - Works with branching (pruning entries are part of the tree) - Trade-off: cache busting on first submission after pruning -### Investigate: `context` event vs `before_agent_start` +### Investigate: `context` event vs `before_agent_start` ✅ References: - [#324](https://github.com/badlogic/pi-mono/issues/324) - `before_agent_start` proposal @@ -329,9 +329,11 @@ Questions: | Cache impact | Can bust cache | Append-only, cache-safe | | Use case | Transient manipulation | Persistent context injection | -**Design questions:** -- [ ] Should `before_agent_start` create a new message type (`SystemMessage` with `role: "system"`)? -- [ ] How should it render in TUI? (label when collapsed, full content when expanded) +**Implementation (completed):** +- Reuses `HookMessage` type (no new message type needed) +- Handler returns `{ message: Pick }` +- Message is appended to agent state AND persisted to session before `agent.prompt()` is called +- Renders using existing `HookMessageComponent` (or custom renderer if registered) - [ ] How does it interact with compaction? (treated like user messages?) - [ ] Can hook return multiple messages or just one?