cli: support short flags and hide tool results in REPL

This commit is contained in:
Adrià Arrufat committed 2026-05-07 14:22:26 +02:00
1 parent 0de602695f
commit 8e9e82b478
3 files changed
+9 -3

No files matched your search

+1 -1
View File
@@ -200,7 +200,7 @@ const Commands = cli.Builder(.{
.{ .name = "base_url", .type = ?[:0]const u8 },
.{ .name = "system_prompt", .type = ?[:0]const u8 },
.{ .name = "self_heal", .type = bool },
.{ .name = "interactive", .type = bool },
.{ .name = "interactive", .short = 'i', .type = bool },
.{ .name = "task", .type = ?[]const u8 },
.{ .name = "task_attachments", .type = []const u8, .multiple = true },
.{ .name = "mcp", .type = bool },
+5 -1
View File
@@ -1059,7 +1059,11 @@ fn handleToolCall(ctx: *anyopaque, allocator: std.mem.Allocator, tool_name: []co
self.terminal.printToolCall(tool_name, arguments);
if (self.tool_executor.call(allocator, tool_name, arguments)) |output| {
const capped = capToolOutput(allocator, output);
self.terminal.printToolResult(tool_name, capped);
// Only the user-explicit path (slash commands) should surface tool
// result bodies in the REPL. Agent-driven calls show only the call
// line; bodies are hidden unless `--verbosity verbose` (also needed
// by the benchmark harness which parses both lines).
if (self.terminal.verbosity == .verbose) self.terminal.printToolResult(tool_name, capped);
return .{ .content = capped };
} else |err| {
const msg = std.fmt.allocPrint(allocator, "Error: {s}", .{@errorName(err)}) catch "Error: tool execution failed";
+3 -1
View File
@@ -552,8 +552,10 @@ pub fn Builder(comptime commands: anytype) type {
// We allow both `--my-option` and `--my_option` variants;
// assuming given `option` struct prefer snake_case for `name`.
// Match an option.
const matches_short = comptime @hasField(@TypeOf(option), "short");
if (std.mem.eql(u8, option_name, "--" ++ option.name) or
std.mem.eql(u8, option_name, "--" ++ comptime toKebabCase(option.name)))
std.mem.eql(u8, option_name, "--" ++ comptime toKebabCase(option.name)) or
(matches_short and std.mem.eql(u8, option_name, "-" ++ [_]u8{option.short})))
{
try parseValue(allocator, args, &@field(c, option.name), option);
continue :iter_args;