From 524dccdc81a6460fbff8d49f01cbc5d0b095e16a Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Sun, 19 Apr 2026 15:47:42 +0200 Subject: [PATCH] =?UTF-8?q?agent:=20rename=20userPromptSubmit=E2=86=92preT?= =?UTF-8?q?urn,=20stop=E2=86=92postTurn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Names now reflect the turn lifecycle rather than implementation details. Co-Authored-By: Claude Sonnet 4.6 --- README.md | 6 +++--- pkg/agent/core.go | 4 ++-- pkg/agent/hooks.go | 4 ++-- pkg/config/config_test.go | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 3373112..dabf029 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ The reference frontend is [ollie-tui](https://github.com/lneely/ollie-tui), a te **`agent.AgentEnv`** — wires together a backend, tool dispatcher, config, and hooks into the environment passed to `NewAgentCore`. Built via `BuildAgentEnv`. -**`agent.Hooks`** — lifecycle callbacks (`agentSpawn`, `userPromptSubmit`, `stop`) executed as shell commands with a JSON payload. Run via `Hooks.Run`. +**`agent.Hooks`** — lifecycle callbacks (`agentSpawn`, `preTurn`, `postTurn`, `preCompact`, `postCompact`) executed as shell commands with a JSON payload. Run via `Hooks.Run`. **`backend.Backend`** — the LLM interface: `ChatStream`, `Models`, `ContextLength`, `Name`, `Model`/`SetModel`, `DefaultModel`. Implementations: Ollama, OpenAI-compatible, Anthropic, Copilot, Kiro. @@ -62,8 +62,8 @@ No build step — ollie-core is a library. "$OLLIE/x/prime 01_ollie", "notify-send ollie started" ], - "userPromptSubmit": [], - "stop": [] + "preTurn": [], + "postTurn": [] } } ``` diff --git a/pkg/agent/core.go b/pkg/agent/core.go index 55699cc..d74ae31 100644 --- a/pkg/agent/core.go +++ b/pkg/agent/core.go @@ -636,7 +636,7 @@ func (s *agentCore) Submit(ctx context.Context, input string, handler EventHandl handler(Event{Role: "user", Content: input}) - hookResult := s.hooks.Run(ctx, HookUserPromptSubmit, map[string]string{ + hookResult := s.hooks.Run(ctx, HookPreTurn, map[string]string{ "session_id": s.sessionID, "cwd": s.CWD(), "prompt": input, @@ -732,7 +732,7 @@ func (s *agentCore) Submit(ctx context.Context, input string, handler EventHandl handler(Event{Role: "newline"}) - stopResult := s.hooks.Run(ctx, HookStop, map[string]string{ + stopResult := s.hooks.Run(ctx, HookPostTurn, map[string]string{ "session_id": s.sessionID, "cwd": s.CWD(), }) diff --git a/pkg/agent/hooks.go b/pkg/agent/hooks.go index 2eebd0a..137c9da 100644 --- a/pkg/agent/hooks.go +++ b/pkg/agent/hooks.go @@ -14,8 +14,8 @@ import ( // Hook name constants for well-known agent lifecycle events. const ( HookAgentSpawn = "agentSpawn" - HookUserPromptSubmit = "userPromptSubmit" - HookStop = "stop" + HookPreTurn = "preTurn" + HookPostTurn = "postTurn" HookPreCompact = "preCompact" HookPostCompact = "postCompact" ) diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 24884c7..d3a3bb9 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -6,7 +6,7 @@ import ( ) func TestLoad(t *testing.T) { - content := `{"hooks": {"stop": "notify-send done"}}` + content := `{"hooks": {"postTurn": "notify-send done"}}` tmpfile, err := os.CreateTemp("", "config*.json") if err != nil { @@ -24,8 +24,8 @@ func TestLoad(t *testing.T) { t.Fatalf("Load failed: %v", err) } - if len(cfg.Hooks["stop"]) != 1 || cfg.Hooks["stop"][0] != "notify-send done" { - t.Errorf("Expected hook 'notify-send done', got %q", cfg.Hooks["stop"]) + if len(cfg.Hooks["postTurn"]) != 1 || cfg.Hooks["postTurn"][0] != "notify-send done" { + t.Errorf("Expected hook 'notify-send done', got %q", cfg.Hooks["postTurn"]) } }