@@ -28,12 +28,14 @@ local record cmdargs
2828 forward : string
2929 synthetic : {string }
3030 -- Explicit value type ("number" / "boolean" / "string" / "list" /
31- -- "table"). When omitted it is inferred from `default`. Set it for an
32- -- optional typed arg that has no default, e.g. a number that defaults
33- -- to nil (leave unchanged). A "list" is a comma-separated string on
34- -- the command line and a JSON string array over MCP; a "table" is a
35- -- brace-balanced Lua expression on the command line and a JSON object
36- -- over MCP (actions receive a string or a table and handle both).
31+ -- "table" / "rows"). When omitted it is inferred from `default`. Set
32+ -- it for an optional typed arg that has no default, e.g. a number
33+ -- that defaults to nil (leave unchanged). A "list" is a
34+ -- comma-separated string on the command line and a JSON string array
35+ -- over MCP; a "table" is a brace-balanced Lua expression on the
36+ -- command line and a JSON object over MCP; "rows" is the same on the
37+ -- console but a JSON ARRAY of objects over MCP (actions receive a
38+ -- string or a table and handle both).
3739 kind : string
3840 -- Allowed values for a string arg; projected as a JSON Schema enum.
3941 enum : {string }
@@ -146,7 +148,8 @@ function cmdargs.validate(schema: cmdargs.Schema)
146148 local args = schema.args
147149 for name, spec in pairs (args) do
148150 if spec.rest then
149- if argType (spec) ~= " string" and argType (spec) ~= " table" then
151+ local at = argType (spec)
152+ if at ~= " string" and at ~= " table" and at ~= " rows" then
150153 error (" cmdargs: rest arg '" .. name .. " ' must be string-typed" )
151154 end
152155 if isSynthetic (spec) or spec.forward then
@@ -396,12 +399,14 @@ function cmdargs.parseValues(schema: cmdargs.Schema, given: {string: any}): {str
396399 end
397400 local want = argType (spec)
398401 local got = type (v)
399- if want == " list" or want == " table" then
402+ if want == " list" or want == " table" or want == " rows " then
400403 -- JSON arrays/objects arrive as tables; strings stay accepted
401- -- (the comma form for lists, a Lua expression for tables).
404+ -- (the comma form for lists, a Lua expression for tables/rows ).
402405 if got ~= " table" and got ~= " string" then
403406 return nil , name .. " must be a JSON " ..
404- ((want == " list" ) and " array" or " object" ) .. " , got " .. got
407+ ((want == " list" ) and " array"
408+ or (want == " rows" ) and " array of objects"
409+ or " object" ) .. " , got " .. got
405410 end
406411 if want == " list" then
407412 if got == " string" then
@@ -477,6 +482,8 @@ function cmdargs.toolSchema(schema: cmdargs.Schema): {string: any}
477482 prop = {type = " array" , items = {type = " string" }, description = desc}
478483 elseif t == " table" then
479484 prop = {type = " object" , description = desc}
485+ elseif t == " rows" then
486+ prop = {type = " array" , items = {type = " object" }, description = desc}
480487 else
481488 prop = {type = t, description = desc}
482489 end
@@ -546,6 +553,8 @@ function cmdargs.signature(schema: cmdargs.Schema): string
546553 hint = " a,b"
547554 elseif kind == " table" then
548555 hint = " {}"
556+ elseif kind == " rows" then
557+ hint = " [{..}]"
549558 else
550559 hint = " ..."
551560 end
0 commit comments