mirror of
https://github.com/db9979/sshtermy.git
synced 2026-12-06 20:54:09 +01:00
* Ziel-Modus im Einsatz + Befehle als Blöcke (UX 1–10) - ? gibt der KI im Ziel-Modus eine Anweisung, ⇧S überspringt mit Grund - Befehl wartet auf Eingabe ([Y/n], Pager, --More--, Press any key): Knöpfe im Panel, der Agent hält an (agent/inputwait.go) - Ziel wartet auf dich in verdecktem Tab: Einblendung, im Hintergrund Desktop-Meldung; Tab zeigt Zustand und Schrittzahl - f startet ein Folgeziel mit den Schritten davor (agent/notes.go) - Dateien, die ein Schritt ändert, werden vorher per SFTP gesichert, u holt sie zurück (agent/changes.go, ui/goalux.go) - Zielverlauf je Verbindung, nur lokal (store/goalruns.go) - Verbindungsabbruch: Ziel hält an, ⏎ setzt nach dem Neuverbinden fort - Selbst getippte Befehle gehen als Schritt mit Ausgabe an die KI - Alt+Bild↑/↓ springt von Befehl zu Befehl, Alt+O listet die Befehle des Tabs (Ausgabe kopieren, an KI, lesen) (ui/cmdblocks.go) - README, README.de, Webseite, Kurzreferenz (PDF) nachgezogen Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018i4GUhGZZ2TUnwsDFTQe1N * Test Sicherung/Zurückholen nur mit Unix-Shell Unter Windows ist die lokale Shell PowerShell mit C:\-Pfaden; die Sicherung erkennt bewusst nur Unix-Befehle mit Unix-Pfaden. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018i4GUhGZZ2TUnwsDFTQe1N --------- Co-authored-by: Claude <noreply@anthropic.com>
73 lines
2.7 KiB
Go
73 lines
2.7 KiB
Go
package agent
|
|
|
|
import (
|
|
"regexp"
|
|
"strings"
|
|
)
|
|
|
|
// Befehl wartet auf eine Eingabe: Rückfrage (Y/n), Pager (less, --More--)
|
|
// oder „beliebige Taste“. Der Ziel-Modus würde sonst ewig auf den Prompt
|
|
// warten. Passwortabfragen erkennt LooksLikeSecretPrompt.
|
|
|
|
// InputKind: welche Art Eingabe erwartet wird.
|
|
type InputKind string
|
|
|
|
const (
|
|
InputNone InputKind = ""
|
|
InputYesNo InputKind = "yesno" // [Y/n], (yes/no), Continue?
|
|
InputPager InputKind = "pager" // less, more, --More-- am Switch
|
|
InputAnyKey InputKind = "key" // Press any key / ENTER
|
|
InputConfirm InputKind = "confirm" // [confirm] (Cisco): ⏎ = ja
|
|
)
|
|
|
|
var (
|
|
ynRx = regexp.MustCompile(`(?i)(\[\s*y(es)?\s*/\s*n(o)?\s*\]|\(\s*y(es)?\s*/\s*n(o)?\s*\)|\[\s*j\s*/\s*n\s*\]|\(\s*j(a)?\s*/\s*n(ein)?\s*\)|\byes/no\b|\by/n\b)\s*[?:]?\s*$`)
|
|
ynQRx = regexp.MustCompile(`(?i)\b(do you want to continue|continue|proceed|are you sure|overwrite|möchten sie fortfahren|fortfahren|wirklich)\b[^\n]{0,40}\?\s*$`)
|
|
confirmRx = regexp.MustCompile(`(?i)\[confirm\]\s*$`)
|
|
pagerRx = regexp.MustCompile(`(?i)(^\s*:\s*$|\(END\)\s*$|^\s*lines \d+-\d+(/\d+)?( \d+%)?( \(END\))?\s*$|--\s*more\s*--|-- ?more ?--|--mehr--|press space|<--- more --->|^\s*more\s*$|\bmanual page\b.*\(press h for help or q to quit\))`)
|
|
keyRx = regexp.MustCompile(`(?i)(press any key|press (enter|return)|hit (enter|return)|beliebige taste|drücken sie (die )?(eingabe|enter)|press <?enter>? to continue)[^\n]{0,30}$`)
|
|
)
|
|
|
|
// InputWait prüft die Zeile mit dem Cursor (und bei Pagern die letzte
|
|
// Bildschirmzeile). alt = Alternativer Bildschirm (less, man).
|
|
func InputWait(cursorLine string, alt bool) InputKind {
|
|
l := strings.TrimRight(cursorLine, " \t")
|
|
if strings.TrimSpace(l) == "" {
|
|
return InputNone
|
|
}
|
|
switch {
|
|
case confirmRx.MatchString(l):
|
|
return InputConfirm
|
|
case ynRx.MatchString(l), ynQRx.MatchString(l):
|
|
return InputYesNo
|
|
case keyRx.MatchString(l):
|
|
return InputAnyKey
|
|
case pagerRx.MatchString(l):
|
|
if strings.TrimSpace(l) == ":" && !alt {
|
|
return InputNone // ein Doppelpunkt allein ist ohne Pager eher eine Eingabe
|
|
}
|
|
return InputPager
|
|
}
|
|
return InputNone
|
|
}
|
|
|
|
// InputKeys: was die Knöpfe senden. Reihenfolge = Anzeige.
|
|
type InputButton struct {
|
|
Key, Label, Send string // Label ist deutsch, die Oberfläche übersetzt
|
|
}
|
|
|
|
func InputKeys(k InputKind) []InputButton {
|
|
ctrlC := InputButton{"ctrl+c", "abbrechen", "\x03"}
|
|
switch k {
|
|
case InputYesNo:
|
|
return []InputButton{{"j", "ja", "y\r"}, {"n", "nein", "n\r"}, ctrlC}
|
|
case InputConfirm:
|
|
return []InputButton{{"j", "ja", "\r"}, {"n", "nein", "n"}, ctrlC}
|
|
case InputPager:
|
|
return []InputButton{{"space", "weiter", " "}, {"q", "beenden", "q"}, ctrlC}
|
|
case InputAnyKey:
|
|
return []InputButton{{"enter", "weiter", "\r"}, ctrlC}
|
|
}
|
|
return nil
|
|
}
|