agent: rename userPromptSubmit→preTurn, stop→postTurn

Names now reflect the turn lifecycle rather than implementation details.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Levi Neely 2026-04-19 15:47:42 +02:00
parent d8c0f8a8a3
commit 524dccdc81
4 changed files with 10 additions and 10 deletions

View File

@ -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": []
}
}
```

View File

@ -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(),
})

View File

@ -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"
)

View File

@ -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"])
}
}