diff --git a/cmd/Assist/main.go b/cmd/Assist/main.go index c5ac18d..a102e17 100644 --- a/cmd/Assist/main.go +++ b/cmd/Assist/main.go @@ -92,7 +92,7 @@ func main() { defer w.CloseFiles() w.Name(windowName) - w.Write("tag", []byte("Get Attach Stop Restart Kill Alias Context Log Daemon Sandbox ")) + w.Write("tag", []byte("Get Attach Stop Restart Kill Alias Context Daemon Sandbox ")) refreshList(w) w.Ctl("clean") @@ -221,19 +221,7 @@ func main() { if err := openContextWindow(sess); err != nil { fmt.Fprintf(os.Stderr, "Error opening context window: %v\n", err) } - case "Log": - if arg == "" { - fmt.Fprintf(os.Stderr, "Usage: Log \n") - continue - } - sess, err := getSession(arg) - if err != nil { - fmt.Fprintf(os.Stderr, "Session not found: %s\n", arg) - continue - } - if err := openLogWindow(sess); err != nil { - fmt.Fprintf(os.Stderr, "Error opening log window: %v\n", err) - } + case "Sandbox": if err := openSandboxWindow(); err != nil { fmt.Fprintf(os.Stderr, "Error opening sandbox window: %v\n", err) @@ -605,56 +593,6 @@ func openContextWindow(sess *SessionInfo) error { return nil } -func openLogWindow(sess *SessionInfo) error { - go func() { - displayName := sess.Alias - if displayName == "" { - displayName = sess.ID - } - - w, err := acme.New() - if err != nil { - fmt.Fprintf(os.Stderr, "Error creating log window: %v\n", err) - return - } - defer w.CloseFiles() - - w.Name(fmt.Sprintf("/AnviLLM/Log.%s", displayName)) - w.Ctl("clean") - - // Stream log using external command - logPath := fmt.Sprintf("agent/%s/log", sess.ID) - cmd := exec.Command("9p", "read", logPath) - - stdout, err := cmd.StdoutPipe() - if err != nil { - fmt.Fprintf(os.Stderr, "Error creating pipe: %v\n", err) - return - } - - if err := cmd.Start(); err != nil { - fmt.Fprintf(os.Stderr, "Error starting 9p read: %v\n", err) - return - } - - // Stream output to window - buf := make([]byte, 8192) - for { - n, err := stdout.Read(buf) - if n > 0 { - w.Addr("$") - w.Write("data", buf[:n]) - w.Ctl("clean") - } - if err != nil { - break - } - } - - cmd.Wait() - }() - return nil -} func handleContextWindow(w *acme.Win, sess *SessionInfo) { defer w.CloseFiles() diff --git a/mkfile b/mkfile index bd4ef68..e8404b3 100644 --- a/mkfile +++ b/mkfile @@ -7,6 +7,8 @@ build:V: go build -o $INSTALL_PATH/Assist ./cmd/Assist go build -o $INSTALL_PATH/anvillm ./cmd/anvillm go build -o $INSTALL_PATH/anvilweb ./cmd/anvilweb + cp scripts/Alog $INSTALL_PATH/Alog + chmod 0755 $INSTALL_PATH/Alog mkdir -p $INSTALL_PATH/Workflows cp scripts/DevReview $INSTALL_PATH/Workflows/DevReview chmod 0755 $INSTALL_PATH/Workflows/DevReview diff --git a/scripts/Alog b/scripts/Alog new file mode 100755 index 0000000..538da07 --- /dev/null +++ b/scripts/Alog @@ -0,0 +1,28 @@ +#!/usr/bin/env rc + +# Alog - Stream AnviLLM session log to Acme window + +if(~ $#* 1) { + sess=$1 + + # Get alias for display name + alias=`{9p read agent/$sess/alias >[2]/dev/null} + if(~ $alias '') { + name=$sess + } + if not { + name=$alias + } + + # Create window and get its ID + winid=`{9p read acme/new/ctl | awk '{print $1}'} + echo name /AnviLLM/Log.$name | 9p write acme/$winid/ctl + echo clean | 9p write acme/$winid/ctl + + # Stream log to window + 9p read agent/$sess/log | 9p write acme/$winid/data +} +if not { + echo 'Usage: Alog ' >[1=2] + exit 1 +}