agent: add /usage slash command to REPL

Adds a new `/usage` meta command to print cumulative token usage and
cache hit rate for the current session. Also updates zenai.
This commit is contained in:
Adrià Arrufat committed 2026-06-05 13:35:34 +02:00
1 parent 88c8828224
commit 2d2914e878
4 files changed
+34 -6

No files matched your search

+3 -2
View File
@@ -17,7 +17,7 @@
// along with this program. If not, see <https://www.gnu.org/licenses/>.
//! REPL-only meta slash commands (`/help`, `/quit`, `/verbosity`, `/effort`,
//! `/model`, `/provider`). Meta commands aren't tool slash commands — they're handled
//! `/usage`, `/model`, `/provider`). Meta commands aren't tool slash commands — they're handled
//! by `Agent.handleMeta` and never reach the recorder. Tool slash-command
//! schema primitives live in `lp.Schema`; consumers should import that
//! directly.
@@ -47,7 +47,7 @@ pub const MetaCommand = struct {
/// Dispatched by `Agent.handleMeta` via an exhaustive switch so adding
/// a new meta command is a compile error until it's wired up there too.
const Tag = enum { help, quit, verbosity, effort, save, load, model, provider };
const Tag = enum { help, quit, verbosity, effort, usage, save, load, model, provider };
};
pub const meta_commands = [_]MetaCommand{
@@ -55,6 +55,7 @@ pub const meta_commands = [_]MetaCommand{
.{ .tag = .quit, .name = "quit", .hint = "", .values = &.{}, .description = "Exit the REPL" },
.{ .tag = .verbosity, .name = "verbosity", .hint = "<low|medium|high>", .values = &.{ "low", "medium", "high" }, .description = "Set agent verbosity" },
.{ .tag = .effort, .name = "effort", .hint = "<none|minimal|low|medium|high|xhigh>", .values = &.{ "none", "minimal", "low", "medium", "high", "xhigh" }, .description = "Set per-turn reasoning effort" },
.{ .tag = .usage, .name = "usage", .hint = "", .values = &.{}, .description = "Show token usage and cache stats for this session" },
.{ .tag = .save, .name = "save", .hint = "[filename.js] [prompt]", .values = &.{}, .description = "Save this session to a file" },
.{ .tag = .load, .name = "load", .hint = "<path>", .values = &.{}, .description = "Load and run a script from disk" },
.{ .tag = .model, .name = "model", .hint = "[name]", .values = &.{}, .description = "Change the model" },