From 17357ba6fc15c2272ed3f93b153eba9b581da946 Mon Sep 17 00:00:00 2001 From: Kujtim Hoxha Date: Wed, 26 Nov 2025 12:14:26 +0100 Subject: [PATCH] chore: some small changes --- internal/agent/agent.go | 1 - internal/hooks/README.md | 4 ++-- internal/hooks/builtins.go | 18 ++++++++++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/internal/agent/agent.go b/internal/agent/agent.go index 99263093dff00bb1b0a63324c10354bc6da44756..0cb63debefe0e61e4868f40ecdc8367f32473e0b 100644 --- a/internal/agent/agent.go +++ b/internal/agent/agent.go @@ -242,7 +242,6 @@ func (a *sessionAgent) Run(ctx context.Context, call SessionAgentCall) (*fantasy var assistantMsg message.Message assistantMsg, err = a.messages.Create(callContext, call.SessionID, message.CreateMessageParams{ Role: message.Assistant, - Parts: []message.ContentPart{}, Model: a.largeModel.ModelCfg.Model, Provider: a.largeModel.ModelCfg.Provider, }) diff --git a/internal/hooks/README.md b/internal/hooks/README.md index 0fd4b4c0194a413fd009489a1bb001e90e115cbf..12b314f94c67df4a130e7165cb3f0cdc774d0a41 100644 --- a/internal/hooks/README.md +++ b/internal/hooks/README.md @@ -14,10 +14,10 @@ The hooks package provides a flexible, shell-based system for customizing Crush ### Cross-Platform Support -The hooks system works on **Windows, macOS, and Linux**: +The hooks system works on **Windows**, **macOS**, and **Linux**: - **Hook Files**: All hooks must be `.sh` files (shell scripts) -- **Shell Execution**: Uses Crush's internal POSIX shell emulator (`mvdan.cc/sh`) on all platforms +- **Shell Execution**: Uses Crush's internal POSIX shell emulator ([mvdan.cc/sh](https://mvdan.cc/sh)) on all platforms - **Hook Discovery**: - **Unix/macOS**: `.sh` files must have execute permission (`chmod +x hook.sh`) - **Windows**: `.sh` files are automatically recognized (no permission needed) diff --git a/internal/hooks/builtins.go b/internal/hooks/builtins.go index 544b2d0dc30905a757e91686eeb374fb42ec36db..e7301f66c1998904e7b67d5dee2d076d6fde8e65 100644 --- a/internal/hooks/builtins.go +++ b/internal/hooks/builtins.go @@ -15,7 +15,7 @@ func crushGetInput(ctx context.Context, args []string) error { hc := interp.HandlerCtx(ctx) if len(args) != 2 { - fmt.Fprintln(hc.Stderr, "Usage: crush_get_input ") + fmt.Fprintf(hc.Stderr, "Wrong number of arguments to `crush_get_input`. Expected 2, got %d.\n", len(args)) return interp.ExitStatus(1) } @@ -40,7 +40,7 @@ func crushGetInput(ctx context.Context, args []string) error { func crushGetToolInput(ctx context.Context, args []string) error { hc := interp.HandlerCtx(ctx) if len(args) != 2 { - fmt.Fprintln(hc.Stderr, "Usage: crush_get_tool_input ") + fmt.Fprintf(hc.Stderr, "Wrong number of arguments to `crush_get_tool_input`. Expected 2, got %d.\n", len(args)) return interp.ExitStatus(1) } @@ -70,6 +70,11 @@ func crushGetToolInput(ctx context.Context, args []string) error { func crushGetPrompt(ctx context.Context, args []string) error { hc := interp.HandlerCtx(ctx) + if len(args) != 1 { + fmt.Fprintf(hc.Stderr, "Wrong number of arguments to `crush_get_prompt`. Expected 1, got %d.\n", len(args)) + return interp.ExitStatus(1) + } + stdin := hc.Env.Get("_CRUSH_STDIN").Str var data map[string]any @@ -88,12 +93,13 @@ func crushGetPrompt(ctx context.Context, args []string) error { // crushLog writes a log message using slog.Debug. // Usage: crush_log "debug message" func crushLog(ctx context.Context, args []string) error { - if len(args) < 2 { + switch len(args) { + case 0, 1: + return nil + default: + slog.Debug(joinArgs(args[1:])) return nil } - - slog.Debug(joinArgs(args[1:])) - return nil } // formatJSONValue converts a JSON value to a string suitable for shell output.