added Perl port, updated readme

This commit is contained in:
Luxferre
2026-08-09 09:26:44 +03:00
parent bc6002235e
commit 6bd56f0d5e
4 changed files with 412 additions and 27 deletions
+9 -8
View File
@@ -1,5 +1,5 @@
// Bantam agent, tiny, powerful, DIY. Public domain. Created by Luxferre in 2026.
// Go port: zero external dependencies, stdlib only.
// Bantam agent: tiny, powerful, DIY
// Created by Luxferre in 2026, released into the public domain
package main
@@ -612,12 +612,12 @@ func readLine(prompt string) (string, bool) {
e.draw()
rn, _, err := stdin.ReadRune()
if err != nil {
fmt.Println()
fmt.Print("\r\n")
return "", false
}
switch rn {
case '\r':
fmt.Println()
fmt.Print("\r\n")
return string(e.buf), true
case '\n':
e.buf = append(e.buf, 0)
@@ -625,11 +625,11 @@ func readLine(prompt string) (string, bool) {
e.buf[e.pos] = '\n'
e.pos++
case 0x03:
fmt.Println()
fmt.Print("\r\n")
return "", false
case 0x04:
if len(e.buf) == 0 {
fmt.Println()
fmt.Print("\r\n")
return "", false
}
case 0x7f, 0x08:
@@ -687,6 +687,7 @@ func main() {
}
loadHistory()
fmt.Println(c("Bantam Agent ready", 1, 32) + c(" (Ctrl+J = new line)", 2))
fmt.Println(c(fmt.Sprintf("endpoint: %s model: %s temp: %v", cfg.Endpoint, cfg.Model, cfg.Temperature), 2))
for {
u, ok := readLine(c("> ", 1, 36))
if !ok {
@@ -753,8 +754,8 @@ func main() {
continue
case u == "/help":
fmt.Println(c("Bantam commands:", 1, 36))
for _, kv := range [][2]string{{"/quit", "quit"}, {"/clear", "reset to system prompt"}, {"/save", "save session"}, {"/list", "list sessions"}, {"/load <id>", "load session"}, {"/compact", "compact context"}, {"/help", "show help"}} {
fmt.Println(c(fmt.Sprintf("%-12s", kv[0]), 1, 32) + kv[1])
for _, kv := range [][2]string{{"/quit", "exit"}, {"/clear", "reset to system prompt"}, {"/save", "save session"}, {"/list", "list sessions"}, {"/load <id>", "load session"}, {"/compact", "compact context"}, {"/help", "show help"}} {
fmt.Println(c(fmt.Sprintf(" %-12s", kv[0]), 1, 32) + kv[1])
}
continue
}