diff options
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/main.zig b/src/main.zig index 14a14b6..be0ac86 100644 --- a/src/main.zig +++ b/src/main.zig @@ -526,12 +526,30 @@ pub fn main(init: std.process.Init) !void { defer cli_recv.deinit(); var recv = cli_recv.receiver(); - // Build the slash-command registry and register builtins. Future Lua - // extensions will append commands here too. + // Build the slash-command registry and register builtins, then append + // any commands declared by Lua extensions (harvested at load time). var cmd_registry = command.Registry.init(alloc); defer cmd_registry.deinit(); try command_compaction.register(&cmd_registry); + // Append slash commands declared by Lua extensions via + // `panto.register_command`. A name collision with a builtin (or + // between two extensions) surfaces as `error.DuplicateCommand` and + // aborts startup, matching the tool-name collision policy. + for (rt.commandList()) |lua_cmd| { + cmd_registry.registerLua( + lua_cmd.name, + lua_cmd.description, + lua_cmd.handler_ref, + ) catch |err| { + std.log.err( + "lua: failed to register command '/{s}': {t}", + .{ lua_cmd.name, err }, + ); + return err; + }; + } + var cmd_ctx: command.Context = .{ .allocator = alloc, .conv = &conv, @@ -542,6 +560,7 @@ pub fn main(init: std.process.Init) !void { .compaction_prompt = compaction_prompt, .provider_name = banner_provider_initial, .model_name = banner_model_initial, + .lua_rt = rt, }; while (true) { |
