From 1abf05aec7ab67b0d4e24711aab5167616a0798f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Arrufat?= Date: Mon, 11 May 2026 14:53:17 +0200 Subject: [PATCH] agent: unify command keywords and simplify env listing Centralizes PandaScript keywords in Command.zig as a single source of truth for the parser and REPL. Simplifies environment variable listing and formatting in tools.zig. --- src/agent/Agent.zig | 2 +- src/agent/Command.zig | 44 ++++++++++++++++------------ src/agent/Terminal.zig | 44 ++++++++-------------------- src/browser/tools.zig | 66 ++++++++++++++---------------------------- 4 files changed, 61 insertions(+), 95 deletions(-) diff --git a/src/agent/Agent.zig b/src/agent/Agent.zig index 52d081b9..ab7b3fdf 100644 --- a/src/agent/Agent.zig +++ b/src/agent/Agent.zig @@ -319,7 +319,7 @@ fn runRepl(self: *Self) void { // PandaScript command. if (std.meta.activeTag(cmd) == .natural_language) { if (Command.keywordSyntax(line)) |kc| { - self.terminal.printErrorFmt("Usage: {s} {s}", .{ kc.name, kc.args }); + self.terminal.printErrorFmt("Usage: {s} {s}", .{ kc.name, kc.args.? }); continue; } } diff --git a/src/agent/Command.zig b/src/agent/Command.zig index 6ca26895..5b7a7ac4 100644 --- a/src/agent/Command.zig +++ b/src/agent/Command.zig @@ -219,34 +219,42 @@ pub fn parse(line: []const u8) Command { pub const KeywordSyntax = struct { name: []const u8, - args: []const u8, + /// Null for argless commands (TREE, MARKDOWN, LOGIN, ACCEPT_COOKIES). + args: ?[]const u8, +}; + +/// Single source of truth for PandaScript keyword names — consumed by the +/// parser, the REPL highlighter, and Tab completion. Order is REPL-facing +/// (action verbs first), so completions feel natural. +pub const keywords = [_]KeywordSyntax{ + .{ .name = "GOTO", .args = "" }, + .{ .name = "CLICK", .args = "''" }, + .{ .name = "TYPE", .args = "'' ''" }, + .{ .name = "WAIT", .args = "''" }, + .{ .name = "SCROLL", .args = "[x] [y]" }, + .{ .name = "HOVER", .args = "''" }, + .{ .name = "SELECT", .args = "'' ''" }, + .{ .name = "CHECK", .args = "'' [true|false]" }, + .{ .name = "TREE", .args = null }, + .{ .name = "MARKDOWN", .args = null }, + .{ .name = "EXTRACT", .args = "''" }, + .{ .name = "EVAL", .args = "'