summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorT <t@tjp.lol>2026-04-26 11:09:37 -0600
committerT <t@tjp.lol>2026-05-25 11:48:47 -0700
commit52b2ca78aed7950af27d4865aee65da781514a99 (patch)
tree24f512e67afd677b6c0d8a8064819e8f5332d28d /src
parentd3d5a6295a67bdc99e35e5bfd77359d98a850c3f (diff)
Initial work, and name change to pantograph
Diffstat (limited to 'src')
-rw-r--r--src/main.zig59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig
new file mode 100644
index 0000000..1356bdc
--- /dev/null
+++ b/src/main.zig
@@ -0,0 +1,59 @@
+const std = @import("std");
+const libpanto = @import("libpanto");
+
+pub fn main() !void {
+ const config = libpanto.config.Config.fromEnv() catch |err| switch (err) {
+ error.MissingApiKey => {
+ std.debug.print("panto: PANTO_API_KEY environment variable is required\n", .{});
+ return;
+ },
+ };
+
+ var debug_allocator = std.heap.DebugAllocator(.{}).init;
+ defer _ = debug_allocator.deinit();
+ const alloc = debug_allocator.allocator();
+
+ var conv = libpanto.conversation.Conversation.init(alloc);
+ defer conv.deinit();
+
+ try conv.addSystemMessage("You are a helpful assistant.");
+
+ const io = std.Io.Threaded.global_single_threaded.io();
+
+ var stdout_buffer: [4096]u8 = undefined;
+ var stdout_file = std.Io.File.stdout().writer(io, &stdout_buffer);
+ const stdout = &stdout_file.interface;
+
+ var stdin_buffer: [4096]u8 = undefined;
+ var stdin_file = std.Io.File.stdin().reader(io, &stdin_buffer);
+ const stdin = &stdin_file.interface;
+
+ try stdout.print("panto — model: {s}\n> ", .{config.model});
+ try stdout_file.flush();
+
+ while (true) {
+ const line = stdin.takeDelimiter('\n') catch |err| {
+ std.debug.print("Read error: {}\n", .{err});
+ return;
+ };
+ if (line) |text| {
+ if (text.len == 0) {
+ try stdout.print("> ", .{});
+ try stdout_file.flush();
+ continue;
+ }
+ // Copy the line since the reader buffer may be reused
+ const owned = try alloc.dupe(u8, text);
+ defer alloc.free(owned);
+ try conv.addUserMessage(owned);
+ // TODO: call agent.runStep() once provider is implemented
+ try stdout.print("(streaming not yet implemented)\n> ", .{});
+ try stdout_file.flush();
+ } else {
+ // EOF (Ctrl+D)
+ try stdout.print("\n", .{});
+ try stdout_file.flush();
+ break;
+ }
+ }
+}