A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.
Rust agentagent-orchestrationaiai-agentsclaude-codecodexcoding-agentlinuxmacosmultiplayermultiplexerrustterminalterminal-emulatorterminal-multiplexertmuxtuiweztermwindows
Add `thinkterm update` and the thinkterm-update crate behind it
RoversX618d7ad7a9b7
diff --git a/Cargo.lock b/Cargo.lockindex da31dfdf..b201b0f4 100644--- a/Cargo.lock+++ b/Cargo.lock@@ -6513,6 +6513,23 @@ dependencies = ["wezterm-term",]+[[package]]+name = "thinkterm-update"+version = "0.1.0"+dependencies = [+ "anyhow",+ "config",+ "hex",+ "http_req",+ "log",+ "plist",+ "semver",+ "serde",+ "serde_json",+ "sha2",+ "tempfile",+]+[[package]]name = "thiserror"version = "1.0.69"@@ -7708,6 +7725,7 @@ dependencies = ["textwrap","thinkterm-proto","thinkterm-tui",+ "thinkterm-update","umask","url","wezterm-client",@@ -7818,6 +7836,7 @@ dependencies = ["termwiz 0.24.0","textwrap","thinkterm-proto",+ "thinkterm-update","thiserror 1.0.69","umask","url",@@ -8005,7 +8024,6 @@ dependencies = ["frecency","futures","hdrhistogram",- "http_req","ignore","image","k9",@@ -8025,7 +8043,6 @@ dependencies = ["percent-encoding","phf","phf_codegen 0.10.0",- "plist","portable-pty","promise","pulldown-cmark",@@ -8051,6 +8068,7 @@ dependencies = ["thinkterm-core","thinkterm-proto","thinkterm-syntax",+ "thinkterm-update","thiserror 1.0.69","tiny-skia","trash",diff --git a/Cargo.toml b/Cargo.tomlindex cc2cbfb2..5bb03e32 100644--- a/Cargo.toml+++ b/Cargo.toml@@ -9,6 +9,7 @@ members = ["thinkterm-core","thinkterm-proto","thinkterm-tui",+ "thinkterm-update","deps/cairo","wezterm","wezterm-blob-leases",@@ -76,6 +77,7 @@ colorgrad = "0.6"config = { path = "config" }thinkterm-core = { path = "thinkterm-core" }thinkterm-proto = { path = "thinkterm-proto" }+thinkterm-update = { path = "thinkterm-update" }core-foundation = "=0.10.0"core-graphics = "=0.24.0"core-text = "=21.0.0"diff --git a/README.md b/README.mdindex b74bd666..217ec9e7 100644--- a/README.md+++ b/README.md@@ -71,6 +71,8 @@ curl -fsSL https://raw.githubusercontent.com/RoversX/thinkterm/main/install.sh |It asks whether you want the desktop build or the server build (CLI + TUI + mux server, no GUI and, on Linux, no graphics libraries); `sh -s -- --server` or `--desktop` skips the question. Linux gets a tarball unpacked under `~/.local` and needs glibc 2.35 or newer (Ubuntu 22.04, Debian 12, RHEL 10); macOS gets the signed `ThinkTerm.app` plus command-line links in `~/.local/bin`. Downloads are verified against the digest GitHub recorded for them. The mux server runs as your user; on Linux, `loginctl enable-linger $USER` keeps it alive after you log out.+`thinkterm update` upgrades an install the script made; for a deb, rpm, AppImage, Homebrew or source build it names the right way to update instead. When the desktop connects to a remote host whose mux server runs an incompatible version, it offers to install its own version there over the same SSH connection, and then to restart the server (which ends the sessions it holds).+---## Agents can talk to each other@@ -114,6 +116,7 @@ thinkterm connect <name> Connect to a ThinkTerm multiplexerthinkterm ssh / serial SSH session / serial portthinkterm cli <subcommand> Interact with the mux serverthinkterm imgcat <file> Print an image to the terminal+thinkterm update Check for a newer release and install it```Run `thinkterm --help` for the full list.diff --git a/assets/shell-completion/bash b/assets/shell-completion/bashindex 5c95494d..0c2d5d8f 100644--- a/assets/shell-completion/bash+++ b/assets/shell-completion/bash@@ -58,6 +58,12 @@ _thinkterm() {thinkterm,start)cmd="thinkterm__start";;+ thinkterm,tui)+ cmd="thinkterm__tui"+ ;;+ thinkterm,update)+ cmd="thinkterm__update"+ ;;thinkterm__cli,activate-pane)cmd="thinkterm__cli__activate__pane";;@@ -70,6 +76,9 @@ _thinkterm() {thinkterm__cli,adjust-pane-size)cmd="thinkterm__cli__adjust__pane__size";;+ thinkterm__cli,agent)+ cmd="thinkterm__cli__agent"+ ;;thinkterm__cli,get-pane-direction)cmd="thinkterm__cli__get__pane__direction";;@@ -118,6 +127,18 @@ _thinkterm() {thinkterm__cli,zoom-pane)cmd="thinkterm__cli__zoom__pane";;+ thinkterm__cli__agent,help)+ cmd="thinkterm__cli__agent__help"+ ;;+ thinkterm__cli__agent,list)+ cmd="thinkterm__cli__agent__list"+ ;;+ thinkterm__cli__agent__help,help)+ cmd="thinkterm__cli__agent__help__help"+ ;;+ thinkterm__cli__agent__help,list)+ cmd="thinkterm__cli__agent__help__list"+ ;;thinkterm__cli__help,activate-pane)cmd="thinkterm__cli__help__activate__pane";;@@ -130,6 +151,9 @@ _thinkterm() {thinkterm__cli__help,adjust-pane-size)cmd="thinkterm__cli__help__adjust__pane__size";;+ thinkterm__cli__help,agent)+ cmd="thinkterm__cli__help__agent"+ ;;thinkterm__cli__help,get-pane-direction)cmd="thinkterm__cli__help__get__pane__direction";;@@ -178,6 +202,9 @@ _thinkterm() {thinkterm__cli__help,zoom-pane)cmd="thinkterm__cli__help__zoom__pane";;+ thinkterm__cli__help__agent,list)+ cmd="thinkterm__cli__help__agent__list"+ ;;thinkterm__help,blocking-start)cmd="thinkterm__help__blocking__start";;@@ -220,6 +247,12 @@ _thinkterm() {thinkterm__help,start)cmd="thinkterm__help__start";;+ thinkterm__help,tui)+ cmd="thinkterm__help__tui"+ ;;+ thinkterm__help,update)+ cmd="thinkterm__help__update"+ ;;thinkterm__help__cli,activate-pane)cmd="thinkterm__help__cli__activate__pane";;@@ -232,6 +265,9 @@ _thinkterm() {thinkterm__help__cli,adjust-pane-size)cmd="thinkterm__help__cli__adjust__pane__size";;+ thinkterm__help__cli,agent)+ cmd="thinkterm__help__cli__agent"+ ;;thinkterm__help__cli,get-pane-direction)cmd="thinkterm__help__cli__get__pane__direction";;@@ -277,6 +313,9 @@ _thinkterm() {thinkterm__help__cli,zoom-pane)cmd="thinkterm__help__cli__zoom__pane";;+ thinkterm__help__cli__agent,list)+ cmd="thinkterm__help__cli__agent__list"+ ;;*);;esac@@ -284,7 +323,7 @@ _thinkterm() {case "${cmd}" inthinkterm)- opts="-n -h -V --skip-config --config-file --config --help --version start blocking-start ssh serial connect ls-fonts show-keys cli imgcat set-working-directory record replay shell-completion help"+ opts="-n -h -V --skip-config --config-file --config --help --version start blocking-start ssh serial connect tui ls-fonts show-keys cli imgcat set-working-directory record replay update shell-completion help"if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; thenCOMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )return 0@@ -354,7 +393,7 @@ _thinkterm() {return 0;;thinkterm__cli)- opts="-h --no-auto-start --prefer-mux --class --help list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help"+ opts="-h --no-auto-start --prefer-mux --class --help list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help"if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; thenCOMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )return 0@@ -459,6 +498,80 @@ _thinkterm() {COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )return 0;;+ thinkterm__cli__agent)+ opts="-h --help list help"+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ fi+ case "${prev}" in+ *)+ COMPREPLY=()+ ;;+ esac+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ ;;+ thinkterm__cli__agent__help)+ opts="list help"+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ fi+ case "${prev}" in+ *)+ COMPREPLY=()+ ;;+ esac+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ ;;+ thinkterm__cli__agent__help__help)+ opts=""+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 5 ]] ; then+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ fi+ case "${prev}" in+ *)+ COMPREPLY=()+ ;;+ esac+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ ;;+ thinkterm__cli__agent__help__list)+ opts=""+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 5 ]] ; then+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ fi+ case "${prev}" in+ *)+ COMPREPLY=()+ ;;+ esac+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ ;;+ thinkterm__cli__agent__list)+ opts="-h --format --help"+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ fi+ case "${prev}" in+ --format)+ COMPREPLY=($(compgen -f "${cur}"))+ return 0+ ;;+ *)+ COMPREPLY=()+ ;;+ esac+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ ;;thinkterm__cli__get__pane__direction)opts="-h --pane-id --help Up Down Left Right Next Prev"if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then@@ -504,7 +617,7 @@ _thinkterm() {return 0;;thinkterm__cli__help)- opts="list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help"+ opts="list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help"if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; thenCOMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )return 0@@ -573,6 +686,34 @@ _thinkterm() {COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )return 0;;+ thinkterm__cli__help__agent)+ opts="list"+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ fi+ case "${prev}" in+ *)+ COMPREPLY=()+ ;;+ esac+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ ;;+ thinkterm__cli__help__agent__list)+ opts=""+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 5 ]] ; then+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ fi+ case "${prev}" in+ *)+ COMPREPLY=()+ ;;+ esac+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ ;;thinkterm__cli__help__get__pane__direction)opts=""if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then@@ -1108,7 +1249,7 @@ _thinkterm() {return 0;;thinkterm__help)- opts="start blocking-start ssh serial connect ls-fonts show-keys cli imgcat set-working-directory record replay shell-completion help"+ opts="start blocking-start ssh serial connect tui ls-fonts show-keys cli imgcat set-working-directory record replay update shell-completion help"if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; thenCOMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )return 0@@ -1136,7 +1277,7 @@ _thinkterm() {return 0;;thinkterm__help__cli)- opts="list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane"+ opts="list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent"if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; thenCOMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )return 0@@ -1205,6 +1346,34 @@ _thinkterm() {COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )return 0;;+ thinkterm__help__cli__agent)+ opts="list"+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ fi+ case "${prev}" in+ *)+ COMPREPLY=()+ ;;+ esac+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ ;;+ thinkterm__help__cli__agent__list)+ opts=""+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 5 ]] ; then+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ fi+ case "${prev}" in+ *)+ COMPREPLY=()+ ;;+ esac+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ ;;thinkterm__help__cli__get__pane__direction)opts=""if [[ ${cur} == -* || ${COMP_CWORD} -eq 4 ]] ; then@@ -1583,6 +1752,34 @@ _thinkterm() {COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )return 0;;+ thinkterm__help__tui)+ opts=""+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ fi+ case "${prev}" in+ *)+ COMPREPLY=()+ ;;+ esac+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ ;;+ thinkterm__help__update)+ opts=""+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 3 ]] ; then+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ fi+ case "${prev}" in+ *)+ COMPREPLY=()+ ;;+ esac+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ ;;thinkterm__imgcat)opts="-h --width --height --no-preserve-aspect-ratio --position --no-move-cursor --hold --tmux-passthru --max-pixels --no-resample --resample-format --resample-filter --resize --show-resample-timing --help [FILE_NAME]"if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then@@ -1834,6 +2031,46 @@ _thinkterm() {COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )return 0;;+ thinkterm__tui)+ opts="-h --class --prefer-mux --tui-config --help [DOMAIN]..."+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ fi+ case "${prev}" in+ --class)+ COMPREPLY=($(compgen -f "${cur}"))+ return 0+ ;;+ --tui-config)+ COMPREPLY=($(compgen -f "${cur}"))+ return 0+ ;;+ *)+ COMPREPLY=()+ ;;+ esac+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ ;;+ thinkterm__update)+ opts="-y -h --check --yes --version --help"+ if [[ ${cur} == -* || ${COMP_CWORD} -eq 2 ]] ; then+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ fi+ case "${prev}" in+ --version)+ COMPREPLY=($(compgen -f "${cur}"))+ return 0+ ;;+ *)+ COMPREPLY=()+ ;;+ esac+ COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )+ return 0+ ;;esac}diff --git a/assets/shell-completion/fish b/assets/shell-completion/fishindex a581dd31..eb5a5601 100644--- a/assets/shell-completion/fish+++ b/assets/shell-completion/fish@@ -34,6 +34,7 @@ complete -c thinkterm -n "__fish_thinkterm_needs_command" -f -a "blocking-start"complete -c thinkterm -n "__fish_thinkterm_needs_command" -f -a "ssh" -d 'Establish an ssh session'complete -c thinkterm -n "__fish_thinkterm_needs_command" -f -a "serial" -d 'Open a serial port'complete -c thinkterm -n "__fish_thinkterm_needs_command" -f -a "connect" -d 'Connect to ThinkTerm multiplexer'+complete -c thinkterm -n "__fish_thinkterm_needs_command" -f -a "tui" -d 'Open the ThinkTerm terminal interface'complete -c thinkterm -n "__fish_thinkterm_needs_command" -f -a "ls-fonts" -d 'Display information about fonts'complete -c thinkterm -n "__fish_thinkterm_needs_command" -f -a "show-keys" -d 'Show key assignments'complete -c thinkterm -n "__fish_thinkterm_needs_command" -f -a "cli" -d 'Interact with experimental mux server'@@ -41,6 +42,7 @@ complete -c thinkterm -n "__fish_thinkterm_needs_command" -f -a "imgcat" -d 'Outcomplete -c thinkterm -n "__fish_thinkterm_needs_command" -f -a "set-working-directory" -d 'Advise the terminal of the current working directory by emitting an OSC 7 escape sequence'complete -c thinkterm -n "__fish_thinkterm_needs_command" -f -a "record" -d 'Record a terminal session as an asciicast'complete -c thinkterm -n "__fish_thinkterm_needs_command" -f -a "replay" -d 'Replay an asciicast terminal session'+complete -c thinkterm -n "__fish_thinkterm_needs_command" -f -a "update" -d 'Check for a newer release and install it'complete -c thinkterm -n "__fish_thinkterm_needs_command" -f -a "shell-completion" -d 'Generate shell completion information'complete -c thinkterm -n "__fish_thinkterm_needs_command" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'complete -c thinkterm -n "__fish_thinkterm_using_subcommand start" -l cwd -d 'Specify the current working directory for the initially spawned program' -r -f -a "(__fish_complete_directories)"@@ -79,6 +81,10 @@ complete -c thinkterm -n "__fish_thinkterm_using_subcommand connect" -l workspaccomplete -c thinkterm -n "__fish_thinkterm_using_subcommand connect" -l position -d 'Override the position for the initial window launched by this process.' -rcomplete -c thinkterm -n "__fish_thinkterm_using_subcommand connect" -l new-tab -d 'When spawning into an existing GUI instance, spawn a new tab into the active window rather than spawn a new window'complete -c thinkterm -n "__fish_thinkterm_using_subcommand connect" -s h -l help -d 'Print help (see more with \'--help\')'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand tui" -l class -d 'Window class used to discover a running ThinkTerm GUI socket' -r+complete -c thinkterm -n "__fish_thinkterm_using_subcommand tui" -l tui-config -d 'Override the independent ThinkTerm TUI settings file' -r -F+complete -c thinkterm -n "__fish_thinkterm_using_subcommand tui" -l prefer-mux -d 'Prefer connecting to a background mux server. The default is to prefer connecting to a running ThinkTerm GUI instance'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand tui" -s h -l help -d 'Print help'complete -c thinkterm -n "__fish_thinkterm_using_subcommand ls-fonts" -l text -d 'Explain which fonts are used to render the supplied text string' -rcomplete -c thinkterm -n "__fish_thinkterm_using_subcommand ls-fonts" -l codepoints -d 'Explain which fonts are used to render the specified unicode code point sequence. Code points are comma separated hex values' -rcomplete -c thinkterm -n "__fish_thinkterm_using_subcommand ls-fonts" -l list-system -d 'Whether to list all fonts available to the system'@@ -87,30 +93,31 @@ complete -c thinkterm -n "__fish_thinkterm_using_subcommand ls-fonts" -s h -l hecomplete -c thinkterm -n "__fish_thinkterm_using_subcommand show-keys" -l key-table -d 'In lua mode, show only the named key table' -rcomplete -c thinkterm -n "__fish_thinkterm_using_subcommand show-keys" -l lua -d 'Show the keys as lua config statements'complete -c thinkterm -n "__fish_thinkterm_using_subcommand show-keys" -s h -l help -d 'Print help'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -l class -d 'When connecting to a gui instance, if you started the gui with `--class SOMETHING`, you should also pass that same value here in order for the client to find the correct gui instance' -r-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -l no-auto-start -d 'Don\'t automatically start the server'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -l prefer-mux -d 'Prefer connecting to a background mux server. The default is to prefer connecting to a running ThinkTerm GUI instance'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -s h -l help -d 'Print help'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -f -a "list" -d 'list windows, tabs and panes'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -f -a "list-clients" -d 'list clients'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -f -a "proxy" -d 'start rpc proxy pipe'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -f -a "tlscreds" -d 'obtain tls credentials'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -f -a "move-pane-to-new-tab" -d 'Move a pane into a new tab'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -f -a "split-pane" -d 'split the current pane. Outputs the pane-id for the newly created pane on success'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -f -a "spawn" -d 'Spawn a command into a new window or tab Outputs the pane-id for the newly created pane on success'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -f -a "send-text" -d 'Send text to a pane as though it were pasted. If bracketed paste mode is enabled in the pane, then the text will be sent as a bracketed paste'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -f -a "get-text" -d 'Retrieves the textual content of a pane and output it to stdout'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -f -a "activate-pane-direction" -d 'Activate an adjacent pane in the specified direction'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -f -a "get-pane-direction" -d 'Determine the adjacent pane in the specified direction'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -f -a "kill-pane" -d 'Kill a pane'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -f -a "activate-pane" -d 'Activate (focus) a pane'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -f -a "adjust-pane-size" -d 'Adjust the size of a pane directionally'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -f -a "activate-tab" -d 'Activate a tab'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -f -a "set-tab-title" -d 'Change the title of a tab'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -f -a "set-window-title" -d 'Change the title of a window'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -f -a "rename-workspace" -d 'Rename a workspace'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -f -a "zoom-pane" -d 'Zoom, unzoom, or toggle zoom state'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -l class -d 'When connecting to a gui instance, if you started the gui with `--class SOMETHING`, you should also pass that same value here in order for the client to find the correct gui instance' -r+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -l no-auto-start -d 'Don\'t automatically start the server'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -l prefer-mux -d 'Prefer connecting to a background mux server. The default is to prefer connecting to a running ThinkTerm GUI instance'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -s h -l help -d 'Print help'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "list" -d 'list windows, tabs and panes'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "list-clients" -d 'list clients'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "proxy" -d 'start rpc proxy pipe'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "tlscreds" -d 'obtain tls credentials'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "move-pane-to-new-tab" -d 'Move a pane into a new tab'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "split-pane" -d 'split the current pane. Outputs the pane-id for the newly created pane on success'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "spawn" -d 'Spawn a command into a new window or tab Outputs the pane-id for the newly created pane on success'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "send-text" -d 'Send text to a pane as though it were pasted. If bracketed paste mode is enabled in the pane, then the text will be sent as a bracketed paste'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "get-text" -d 'Retrieves the textual content of a pane and output it to stdout'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "activate-pane-direction" -d 'Activate an adjacent pane in the specified direction'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "get-pane-direction" -d 'Determine the adjacent pane in the specified direction'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "kill-pane" -d 'Kill a pane'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "activate-pane" -d 'Activate (focus) a pane'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "adjust-pane-size" -d 'Adjust the size of a pane directionally'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "activate-tab" -d 'Activate a tab'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "set-tab-title" -d 'Change the title of a tab'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "set-window-title" -d 'Change the title of a window'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "rename-workspace" -d 'Rename a workspace'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "zoom-pane" -d 'Zoom, unzoom, or toggle zoom state'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "agent" -d 'Query agent statuses'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and not __fish_seen_subcommand_from list list-clients proxy tlscreds move-pane-to-new-tab split-pane spawn send-text get-text activate-pane-direction get-pane-direction kill-pane activate-pane adjust-pane-size activate-tab set-tab-title set-window-title rename-workspace zoom-pane agent help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and __fish_seen_subcommand_from list" -l format -d 'Controls the output format. "table" and "json" are possible formats' -rcomplete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and __fish_seen_subcommand_from list" -s h -l help -d 'Print help'complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and __fish_seen_subcommand_from list-clients" -l format -d 'Controls the output format. "table" and "json" are possible formats' -r@@ -181,6 +188,9 @@ complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and __fish_seencomplete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and __fish_seen_subcommand_from zoom-pane" -l unzoom -d 'Unzooms the pane if it was zoomed'complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and __fish_seen_subcommand_from zoom-pane" -l toggle -d 'Toggles the zoom state of the pane'complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and __fish_seen_subcommand_from zoom-pane" -s h -l help -d 'Print help'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and __fish_seen_subcommand_from agent" -s h -l help -d 'Print help'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and __fish_seen_subcommand_from agent" -f -a "list" -d 'List panes running detected coding agents'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and __fish_seen_subcommand_from agent" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and __fish_seen_subcommand_from help" -f -a "list" -d 'list windows, tabs and panes'complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and __fish_seen_subcommand_from help" -f -a "list-clients" -d 'list clients'complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and __fish_seen_subcommand_from help" -f -a "proxy" -d 'start rpc proxy pipe'@@ -200,6 +210,7 @@ complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and __fish_seencomplete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and __fish_seen_subcommand_from help" -f -a "set-window-title" -d 'Change the title of a window'complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and __fish_seen_subcommand_from help" -f -a "rename-workspace" -d 'Rename a workspace'complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and __fish_seen_subcommand_from help" -f -a "zoom-pane" -d 'Zoom, unzoom, or toggle zoom state'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and __fish_seen_subcommand_from help" -f -a "agent" -d 'Query agent statuses'complete -c thinkterm -n "__fish_thinkterm_using_subcommand cli; and __fish_seen_subcommand_from help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'complete -c thinkterm -n "__fish_thinkterm_using_subcommand imgcat" -l width -d 'Specify the display width; defaults to "auto" which automatically selects an appropriate size. You may also use an integer value `N` to specify the number of cells, or `Npx` to specify the number of pixels, or `N%` to size relative to the terminal width' -rcomplete -c thinkterm -n "__fish_thinkterm_using_subcommand imgcat" -l height -d 'Specify the display height; defaults to "auto" which automatically selects an appropriate size. You may also use an integer value `N` to specify the number of cells, or `Npx` to specify the number of pixels, or `N%` to size relative to the terminal height' -r@@ -234,6 +245,10 @@ complete -c thinkterm -n "__fish_thinkterm_using_subcommand replay" -l explain -complete -c thinkterm -n "__fish_thinkterm_using_subcommand replay" -l explain-only -d 'Don\'t replay, just show the explanation'complete -c thinkterm -n "__fish_thinkterm_using_subcommand replay" -l cat -d 'Just emit raw escape sequences all at once, with no timing information'complete -c thinkterm -n "__fish_thinkterm_using_subcommand replay" -s h -l help -d 'Print help'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand update" -l version -d 'Install this release instead of the latest one (a downgrade is allowed)' -r+complete -c thinkterm -n "__fish_thinkterm_using_subcommand update" -l check -d 'Only report whether a newer release exists; install nothing'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand update" -s y -l yes -d 'Install without asking for confirmation'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand update" -s h -l help -d 'Print help'complete -c thinkterm -n "__fish_thinkterm_using_subcommand shell-completion" -l shell -d 'Which shell to generate for' -r -f -a "bash\t''elvish\t''fish\t''@@ -241,20 +256,22 @@ power-shell\t''zsh\t''fig\t''"complete -c thinkterm -n "__fish_thinkterm_using_subcommand shell-completion" -s h -l help -d 'Print help'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect ls-fonts show-keys cli imgcat set-working-directory record replay shell-completion help" -f -a "start" -d 'Start the GUI, optionally running an alternative program [aliases: -e]'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect ls-fonts show-keys cli imgcat set-working-directory record replay shell-completion help" -f -a "blocking-start" -d 'Start the GUI in blocking mode. You shouldn\'t see this, but you may see it in shell completions because of this open clap issue: <https://github.com/clap-rs/clap/issues/1335>'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect ls-fonts show-keys cli imgcat set-working-directory record replay shell-completion help" -f -a "ssh" -d 'Establish an ssh session'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect ls-fonts show-keys cli imgcat set-working-directory record replay shell-completion help" -f -a "serial" -d 'Open a serial port'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect ls-fonts show-keys cli imgcat set-working-directory record replay shell-completion help" -f -a "connect" -d 'Connect to ThinkTerm multiplexer'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect ls-fonts show-keys cli imgcat set-working-directory record replay shell-completion help" -f -a "ls-fonts" -d 'Display information about fonts'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect ls-fonts show-keys cli imgcat set-working-directory record replay shell-completion help" -f -a "show-keys" -d 'Show key assignments'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect ls-fonts show-keys cli imgcat set-working-directory record replay shell-completion help" -f -a "cli" -d 'Interact with experimental mux server'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect ls-fonts show-keys cli imgcat set-working-directory record replay shell-completion help" -f -a "imgcat" -d 'Output an image to the terminal'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect ls-fonts show-keys cli imgcat set-working-directory record replay shell-completion help" -f -a "set-working-directory" -d 'Advise the terminal of the current working directory by emitting an OSC 7 escape sequence'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect ls-fonts show-keys cli imgcat set-working-directory record replay shell-completion help" -f -a "record" -d 'Record a terminal session as an asciicast'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect ls-fonts show-keys cli imgcat set-working-directory record replay shell-completion help" -f -a "replay" -d 'Replay an asciicast terminal session'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect ls-fonts show-keys cli imgcat set-working-directory record replay shell-completion help" -f -a "shell-completion" -d 'Generate shell completion information'-complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect ls-fonts show-keys cli imgcat set-working-directory record replay shell-completion help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect tui ls-fonts show-keys cli imgcat set-working-directory record replay update shell-completion help" -f -a "start" -d 'Start the GUI, optionally running an alternative program [aliases: -e]'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect tui ls-fonts show-keys cli imgcat set-working-directory record replay update shell-completion help" -f -a "blocking-start" -d 'Start the GUI in blocking mode. You shouldn\'t see this, but you may see it in shell completions because of this open clap issue: <https://github.com/clap-rs/clap/issues/1335>'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect tui ls-fonts show-keys cli imgcat set-working-directory record replay update shell-completion help" -f -a "ssh" -d 'Establish an ssh session'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect tui ls-fonts show-keys cli imgcat set-working-directory record replay update shell-completion help" -f -a "serial" -d 'Open a serial port'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect tui ls-fonts show-keys cli imgcat set-working-directory record replay update shell-completion help" -f -a "connect" -d 'Connect to ThinkTerm multiplexer'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect tui ls-fonts show-keys cli imgcat set-working-directory record replay update shell-completion help" -f -a "tui" -d 'Open the ThinkTerm terminal interface'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect tui ls-fonts show-keys cli imgcat set-working-directory record replay update shell-completion help" -f -a "ls-fonts" -d 'Display information about fonts'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect tui ls-fonts show-keys cli imgcat set-working-directory record replay update shell-completion help" -f -a "show-keys" -d 'Show key assignments'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect tui ls-fonts show-keys cli imgcat set-working-directory record replay update shell-completion help" -f -a "cli" -d 'Interact with experimental mux server'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect tui ls-fonts show-keys cli imgcat set-working-directory record replay update shell-completion help" -f -a "imgcat" -d 'Output an image to the terminal'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect tui ls-fonts show-keys cli imgcat set-working-directory record replay update shell-completion help" -f -a "set-working-directory" -d 'Advise the terminal of the current working directory by emitting an OSC 7 escape sequence'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect tui ls-fonts show-keys cli imgcat set-working-directory record replay update shell-completion help" -f -a "record" -d 'Record a terminal session as an asciicast'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect tui ls-fonts show-keys cli imgcat set-working-directory record replay update shell-completion help" -f -a "replay" -d 'Replay an asciicast terminal session'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect tui ls-fonts show-keys cli imgcat set-working-directory record replay update shell-completion help" -f -a "update" -d 'Check for a newer release and install it'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect tui ls-fonts show-keys cli imgcat set-working-directory record replay update shell-completion help" -f -a "shell-completion" -d 'Generate shell completion information'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and not __fish_seen_subcommand_from start blocking-start ssh serial connect tui ls-fonts show-keys cli imgcat set-working-directory record replay update shell-completion help" -f -a "help" -d 'Print this message or the help of the given subcommand(s)'complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and __fish_seen_subcommand_from cli" -f -a "list" -d 'list windows, tabs and panes'complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and __fish_seen_subcommand_from cli" -f -a "list-clients" -d 'list clients'complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and __fish_seen_subcommand_from cli" -f -a "proxy" -d 'start rpc proxy pipe'@@ -274,5 +291,6 @@ complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and __fish_seecomplete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and __fish_seen_subcommand_from cli" -f -a "set-window-title" -d 'Change the title of a window'complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and __fish_seen_subcommand_from cli" -f -a "rename-workspace" -d 'Rename a workspace'complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and __fish_seen_subcommand_from cli" -f -a "zoom-pane" -d 'Zoom, unzoom, or toggle zoom state'+complete -c thinkterm -n "__fish_thinkterm_using_subcommand help; and __fish_seen_subcommand_from cli" -f -a "agent" -d 'Query agent statuses'complete -c wezterm -w thinktermdiff --git a/assets/shell-completion/zsh b/assets/shell-completion/zshindex eba715be..c7b32e5f 100644--- a/assets/shell-completion/zsh+++ b/assets/shell-completion/zsh@@ -101,6 +101,16 @@ _arguments "${_arguments_options[@]}" : \'*::prog -- Instead of executing your shell, run PROG. For example\: `thinkterm start -- bash -l` will spawn bash as if it were a login shell:_cmdambivalent' \&& ret=0;;+(tui)+_arguments "${_arguments_options[@]}" : \+'--class=[Window class used to discover a running ThinkTerm GUI socket]:CLASS:_default' \+'--tui-config=[Override the independent ThinkTerm TUI settings file]:PATH:_files' \+'--prefer-mux[Prefer connecting to a background mux server. The default is to prefer connecting to a running ThinkTerm GUI instance]' \+'-h[Print help]' \+'--help[Print help]' \+'*::domains -- Mux client domains to show. Defaults to Local when omitted; remote domains can also be attached later from the Connections panel:_default' \+&& ret=0+;;(ls-fonts)_arguments "${_arguments_options[@]}" : \'(--list-system --codepoints)--text=[Explain which fonts are used to render the supplied text string]:TEXT:_default' \@@ -310,6 +320,55 @@ _arguments "${_arguments_options[@]}" : \'--help[Print help]' \&& ret=0;;+(agent)+_arguments "${_arguments_options[@]}" : \+'-h[Print help]' \+'--help[Print help]' \+":: :_thinkterm__cli__agent_commands" \+"*::: :->agent" \+&& ret=0++ case $state in+ (agent)+ words=($line[1] "${words[@]}")+ (( CURRENT += 1 ))+ curcontext="${curcontext%:*:*}:thinkterm-cli-agent-command-$line[1]:"+ case $line[1] in+ (list)+_arguments "${_arguments_options[@]}" : \+'--format=[Controls the output format. "table" and "json" are possible formats]:FORMAT:_default' \+'-h[Print help]' \+'--help[Print help]' \+&& ret=0+;;+(help)+_arguments "${_arguments_options[@]}" : \+":: :_thinkterm__cli__agent__help_commands" \+"*::: :->help" \+&& ret=0++ case $state in+ (help)+ words=($line[1] "${words[@]}")+ (( CURRENT += 1 ))+ curcontext="${curcontext%:*:*}:thinkterm-cli-agent-help-command-$line[1]:"+ case $line[1] in+ (list)+_arguments "${_arguments_options[@]}" : \+&& ret=0+;;+(help)+_arguments "${_arguments_options[@]}" : \+&& ret=0+;;+ esac+ ;;+esac+;;+ esac+ ;;+esac+;;(help)_arguments "${_arguments_options[@]}" : \":: :_thinkterm__cli__help_commands" \@@ -398,6 +457,26 @@ _arguments "${_arguments_options[@]}" : \_arguments "${_arguments_options[@]}" : \&& ret=0;;+(agent)+_arguments "${_arguments_options[@]}" : \+":: :_thinkterm__cli__help__agent_commands" \+"*::: :->agent" \+&& ret=0++ case $state in+ (agent)+ words=($line[1] "${words[@]}")+ (( CURRENT += 1 ))+ curcontext="${curcontext%:*:*}:thinkterm-cli-help-agent-command-$line[1]:"+ case $line[1] in+ (list)+_arguments "${_arguments_options[@]}" : \+&& ret=0+;;+ esac+ ;;+esac+;;(help)_arguments "${_arguments_options[@]}" : \&& ret=0@@ -458,6 +537,16 @@ _arguments "${_arguments_options[@]}" : \':cast_file:_files' \&& ret=0;;+(update)+_arguments "${_arguments_options[@]}" : \+'--version=[Install this release instead of the latest one (a downgrade is allowed)]:VERSION:_default' \+'--check[Only report whether a newer release exists; install nothing]' \+'-y[Install without asking for confirmation]' \+'--yes[Install without asking for confirmation]' \+'-h[Print help]' \+'--help[Print help]' \+&& ret=0+;;(shell-completion)_arguments "${_arguments_options[@]}" : \'--shell=[Which shell to generate for]:SHELL:(bash elvish fish power-shell zsh fig)' \@@ -497,6 +586,10 @@ _arguments "${_arguments_options[@]}" : \_arguments "${_arguments_options[@]}" : \&& ret=0;;+(tui)+_arguments "${_arguments_options[@]}" : \+&& ret=0+;;(ls-fonts)_arguments "${_arguments_options[@]}" : \&& ret=0@@ -592,6 +685,26 @@ _arguments "${_arguments_options[@]}" : \(zoom-pane)_arguments "${_arguments_options[@]}" : \&& ret=0+;;+(agent)+_arguments "${_arguments_options[@]}" : \+":: :_thinkterm__help__cli__agent_commands" \+"*::: :->agent" \+&& ret=0++ case $state in+ (agent)+ words=($line[1] "${words[@]}")+ (( CURRENT += 1 ))+ curcontext="${curcontext%:*:*}:thinkterm-help-cli-agent-command-$line[1]:"+ case $line[1] in+ (list)+_arguments "${_arguments_options[@]}" : \+&& ret=0+;;+ esac+ ;;+esac;;esac;;@@ -613,6 +726,10 @@ _arguments "${_arguments_options[@]}" : \_arguments "${_arguments_options[@]}" : \&& ret=0;;+(update)+_arguments "${_arguments_options[@]}" : \+&& ret=0+;;(shell-completion)_arguments "${_arguments_options[@]}" : \&& ret=0@@ -638,6 +755,7 @@ _thinkterm_commands() {'ssh:Establish an ssh session' \'serial:Open a serial port' \'connect:Connect to ThinkTerm multiplexer' \+'tui:Open the ThinkTerm terminal interface' \'ls-fonts:Display information about fonts' \'show-keys:Show key assignments' \'cli:Interact with experimental mux server' \@@ -645,6 +763,7 @@ _thinkterm_commands() {'set-working-directory:Advise the terminal of the current working directory by emitting an OSC 7 escape sequence' \'record:Record a terminal session as an asciicast' \'replay:Replay an asciicast terminal session' \+'update:Check for a newer release and install it' \'shell-completion:Generate shell completion information' \'help:Print this message or the help of the given subcommand(s)' \)@@ -677,6 +796,7 @@ _thinkterm__cli_commands() {'set-window-title:Change the title of a window' \'rename-workspace:Rename a workspace' \'zoom-pane:Zoom, unzoom, or toggle zoom state' \+'agent:Query agent statuses' \'help:Print this message or the help of the given subcommand(s)' \)_describe -t commands 'thinkterm cli commands' commands "$@"@@ -701,6 +821,37 @@ _thinkterm__cli__adjust-pane-size_commands() {local commands; commands=()_describe -t commands 'thinkterm cli adjust-pane-size commands' commands "$@"}+(( $+functions[_thinkterm__cli__agent_commands] )) ||+_thinkterm__cli__agent_commands() {+ local commands; commands=(+'list:List panes running detected coding agents' \+'help:Print this message or the help of the given subcommand(s)' \+ )+ _describe -t commands 'thinkterm cli agent commands' commands "$@"+}+(( $+functions[_thinkterm__cli__agent__help_commands] )) ||+_thinkterm__cli__agent__help_commands() {+ local commands; commands=(+'list:List panes running detected coding agents' \+'help:Print this message or the help of the given subcommand(s)' \+ )+ _describe -t commands 'thinkterm cli agent help commands' commands "$@"+}+(( $+functions[_thinkterm__cli__agent__help__help_commands] )) ||+_thinkterm__cli__agent__help__help_commands() {+ local commands; commands=()+ _describe -t commands 'thinkterm cli agent help help commands' commands "$@"+}+(( $+functions[_thinkterm__cli__agent__help__list_commands] )) ||+_thinkterm__cli__agent__help__list_commands() {+ local commands; commands=()+ _describe -t commands 'thinkterm cli agent help list commands' commands "$@"+}+(( $+functions[_thinkterm__cli__agent__list_commands] )) ||+_thinkterm__cli__agent__list_commands() {+ local commands; commands=()+ _describe -t commands 'thinkterm cli agent list commands' commands "$@"+}(( $+functions[_thinkterm__cli__get-pane-direction_commands] )) ||_thinkterm__cli__get-pane-direction_commands() {local commands; commands=()@@ -733,6 +884,7 @@ _thinkterm__cli__help_commands() {'set-window-title:Change the title of a window' \'rename-workspace:Rename a workspace' \'zoom-pane:Zoom, unzoom, or toggle zoom state' \+'agent:Query agent statuses' \'help:Print this message or the help of the given subcommand(s)' \)_describe -t commands 'thinkterm cli help commands' commands "$@"@@ -757,6 +909,18 @@ _thinkterm__cli__help__adjust-pane-size_commands() {local commands; commands=()_describe -t commands 'thinkterm cli help adjust-pane-size commands' commands "$@"}+(( $+functions[_thinkterm__cli__help__agent_commands] )) ||+_thinkterm__cli__help__agent_commands() {+ local commands; commands=(+'list:List panes running detected coding agents' \+ )+ _describe -t commands 'thinkterm cli help agent commands' commands "$@"+}+(( $+functions[_thinkterm__cli__help__agent__list_commands] )) ||+_thinkterm__cli__help__agent__list_commands() {+ local commands; commands=()+ _describe -t commands 'thinkterm cli help agent list commands' commands "$@"+}(( $+functions[_thinkterm__cli__help__get-pane-direction_commands] )) ||_thinkterm__cli__help__get-pane-direction_commands() {local commands; commands=()@@ -915,6 +1079,7 @@ _thinkterm__help_commands() {'ssh:Establish an ssh session' \'serial:Open a serial port' \'connect:Connect to ThinkTerm multiplexer' \+'tui:Open the ThinkTerm terminal interface' \'ls-fonts:Display information about fonts' \'show-keys:Show key assignments' \'cli:Interact with experimental mux server' \@@ -922,6 +1087,7 @@ _thinkterm__help_commands() {'set-working-directory:Advise the terminal of the current working directory by emitting an OSC 7 escape sequence' \'record:Record a terminal session as an asciicast' \'replay:Replay an asciicast terminal session' \+'update:Check for a newer release and install it' \'shell-completion:Generate shell completion information' \'help:Print this message or the help of the given subcommand(s)' \)@@ -954,6 +1120,7 @@ _thinkterm__help__cli_commands() {'set-window-title:Change the title of a window' \'rename-workspace:Rename a workspace' \'zoom-pane:Zoom, unzoom, or toggle zoom state' \+'agent:Query agent statuses' \)_describe -t commands 'thinkterm help cli commands' commands "$@"}@@ -977,6 +1144,18 @@ _thinkterm__help__cli__adjust-pane-size_commands() {local commands; commands=()_describe -t commands 'thinkterm help cli adjust-pane-size commands' commands "$@"}+(( $+functions[_thinkterm__help__cli__agent_commands] )) ||+_thinkterm__help__cli__agent_commands() {+ local commands; commands=(+'list:List panes running detected coding agents' \+ )+ _describe -t commands 'thinkterm help cli agent commands' commands "$@"+}+(( $+functions[_thinkterm__help__cli__agent__list_commands] )) ||+_thinkterm__help__cli__agent__list_commands() {+ local commands; commands=()+ _describe -t commands 'thinkterm help cli agent list commands' commands "$@"+}(( $+functions[_thinkterm__help__cli__get-pane-direction_commands] )) ||_thinkterm__help__cli__get-pane-direction_commands() {local commands; commands=()@@ -1112,6 +1291,16 @@ _thinkterm__help__start_commands() {local commands; commands=()_describe -t commands 'thinkterm help start commands' commands "$@"}+(( $+functions[_thinkterm__help__tui_commands] )) ||+_thinkterm__help__tui_commands() {+ local commands; commands=()+ _describe -t commands 'thinkterm help tui commands' commands "$@"+}+(( $+functions[_thinkterm__help__update_commands] )) ||+_thinkterm__help__update_commands() {+ local commands; commands=()+ _describe -t commands 'thinkterm help update commands' commands "$@"+}(( $+functions[_thinkterm__imgcat_commands] )) ||_thinkterm__imgcat_commands() {local commands; commands=()@@ -1162,6 +1351,16 @@ _thinkterm__start_commands() {local commands; commands=()_describe -t commands 'thinkterm start commands' commands "$@"}+(( $+functions[_thinkterm__tui_commands] )) ||+_thinkterm__tui_commands() {+ local commands; commands=()+ _describe -t commands 'thinkterm tui commands' commands "$@"+}+(( $+functions[_thinkterm__update_commands] )) ||+_thinkterm__update_commands() {+ local commands; commands=()+ _describe -t commands 'thinkterm update commands' commands "$@"+}if [ "$funcstack[1]" = "_thinkterm" ]; then_thinkterm "$@"diff --git a/thinkterm-update/Cargo.toml b/thinkterm-update/Cargo.tomlnew file mode 100644index 00000000..4c4e19f4--- /dev/null+++ b/thinkterm-update/Cargo.toml@@ -0,0 +1,22 @@+[package]+name = "thinkterm-update"+version = "0.1.0"+edition = "2021"+publish = false++[dependencies]+anyhow.workspace = true+config.workspace = true+http_req.workspace = true+log.workspace = true+semver.workspace = true+sha2.workspace = true+hex.workspace = true+serde = { workspace = true, features = ["derive"] }+serde_json.workspace = true++[target.'cfg(target_os = "macos")'.dependencies]+plist.workspace = true++[dev-dependencies]+tempfile.workspace = truediff --git a/thinkterm-update/src/lib.rs b/thinkterm-update/src/lib.rsnew file mode 100644index 00000000..f242790e--- /dev/null+++ b/thinkterm-update/src/lib.rs@@ -0,0 +1,468 @@+//! What the CLI, the GUI and the mux client share about updating ThinkTerm:+//! which release is out, which version this build is, how this copy was+//! installed, and how to hand the job to `install.sh`.+//!+//! The installer itself is deliberately not reimplemented here. `install.sh`+//! is the one place that knows the archive layouts and the swap between the+//! desktop and server variants, so `thinkterm update` and the remote update+//! both run it; this crate only decides whether that is the right thing to+//! do and with which arguments.++use anyhow::{anyhow, Context};+use serde::{Deserialize, Serialize};+use std::path::{Path, PathBuf};++pub mod manifest;+pub mod method;++pub use manifest::InstallManifest;+pub use method::InstallMethod;++/// The repository every update link points at. The update check, the toast,+/// the Settings pages and the installer all build their URLs from this, so a+/// fork or a rename is one edit rather than a grep.+pub const REPO_URL: &str = "https://github.com/RoversX/thinkterm";++/// Raw address of the installer on the default branch. `thinkterm update`+/// and the remote update fetch it from here rather than from the release+/// they install: the script has to understand the *current* archive layout,+/// and a fix to it should reach every existing install at once.+pub const INSTALL_SCRIPT_URL: &str =+ "https://raw.githubusercontent.com/RoversX/thinkterm/main/install.sh";++const API_RELEASES: &str = "https://api.github.com/repos/RoversX/thinkterm/releases";++/// The oldest glibc the Linux release binaries run on: the Ubuntu 22.04 base+/// they are built in. `install.sh` carries the same number and refuses+/// older hosts; this copy lets a client refuse before it even offers.+pub const MIN_GLIBC: (u32, u32) = (2, 35);++/// Parse `getconf GNU_LIBC_VERSION` output ("glibc 2.31") or a bare+/// "2.31" into (major, minor).+pub fn parse_glibc_version(text: &str) -> Option<(u32, u32)> {+ let token = text.split_whitespace().last()?;+ let mut parts = token.split('.');+ let major = parts.next()?.parse().ok()?;+ let minor = parts.next()?.parse().ok()?;+ Some((major, minor))+}++/// What to tell someone whose host cannot take a release binary (too old a+/// glibc, musl, an unsupported architecture): the build they have to do+/// themselves, pinned to `version` so it matches the client that asked.+pub fn build_from_source_instructions(version: &str) -> String {+ let checkout = if is_release_version(version) {+ format!("git clone --branch {version} {REPO_URL}.git")+ } else {+ format!("git clone {REPO_URL}.git # then check out the commit this client was built from")+ };+ format!(+ "Build ThinkTerm {version} from source on that host instead:\n \+ {checkout}\n \+ cd thinkterm && ./get-deps && cargo build --release -p wezterm -p wezterm-mux-server\n \+ install -Dm755 target/release/thinkterm target/release/wezterm target/release/thinkterm-mux-server -t ~/.local/bin\n\+ then stop the old thinkterm-mux-server there and reconnect."+ )+}++pub fn releases_url() -> String {+ format!("{REPO_URL}/releases")+}++pub fn release_tag_url(tag: &str) -> String {+ format!("{REPO_URL}/releases/tag/{tag}")+}++#[derive(Debug, Serialize, Deserialize, Clone)]+pub struct Release {+ pub url: String,+ pub body: String,+ pub html_url: String,+ pub tag_name: String,+ pub assets: Vec<Asset>,+}++#[derive(Debug, Serialize, Deserialize, Clone)]+pub struct Asset {+ pub name: String,+ pub size: usize,+ pub url: String,+ pub browser_download_url: String,+ /// `sha256:<hex>`, recorded by GitHub at upload. Absent on assets+ /// uploaded before GitHub started computing it, and on cached release+ /// JSON written by older builds.+ #[serde(default)]+ pub digest: Option<String>,+}++impl Asset {+ /// The hex sha256 GitHub recorded, if any.+ pub fn sha256(&self) -> Option<&str> {+ self.digest.as_deref()?.strip_prefix("sha256:")+ }+}++/// Download one release asset and verify it against GitHub's digest when+/// there is one. A missing digest is reported, not treated as a failure.+pub fn download_asset(asset: &Asset) -> anyhow::Result<(Vec<u8>, bool)> {+ use sha2::Digest;+ let body = http_get(&asset.browser_download_url)+ .with_context(|| format!("downloading {}", asset.name))?;+ match asset.sha256() {+ Some(expected) => {+ let got = hex::encode(sha2::Sha256::digest(&body));+ if got != expected {+ anyhow::bail!(+ "checksum mismatch for {}: expected {expected}, got {got}; \+ the download is corrupt or has been tampered with",+ asset.name+ );+ }+ Ok((body, true))+ }+ None => Ok((body, false)),+ }+}++/// Windows: fetch the release's installer and hand over to it. Inno Setup+/// closes the running ThinkTerm, replaces the files and restarts it, so+/// this process must not wait for it -- it is one of the files.+///+/// `/SILENT` keeps the progress window and drops every question; `/SP-`+/// skips the "this will install" prompt; the two APPLICATIONS switches let+/// the installer stop and restart a running ThinkTerm rather than fail on a+/// locked file. Elevation is the installer's own UAC prompt.+pub fn run_windows_installer(release: &Release) -> anyhow::Result<()> {+ let version = release.tag_name.trim_start_matches('v');+ let wanted = format!("ThinkTerm-{version}-setup.exe");+ let asset = release+ .assets+ .iter()+ .find(|a| a.name.eq_ignore_ascii_case(&wanted))+ .ok_or_else(|| anyhow!("release {version} has no {wanted}; see {}", release.html_url))?;++ println!("downloading {} ({} bytes)...", asset.name, asset.size);+ let (body, verified) = download_asset(asset)?;+ if !verified {+ println!("note: GitHub recorded no checksum for this asset; the download was not verified");+ }++ let dir = std::env::temp_dir().join("thinkterm-update");+ std::fs::create_dir_all(&dir)?;+ let path = dir.join(&asset.name);+ std::fs::write(&path, &body).with_context(|| format!("writing {}", path.display()))?;++ println!("starting the installer: {}", path.display());+ std::process::Command::new(&path)+ .args(["/SILENT", "/SP-", "/CLOSEAPPLICATIONS", "/RESTARTAPPLICATIONS", "/NORESTART"])+ .spawn()+ .with_context(|| format!("starting {}", path.display()))?;+ Ok(())+}++fn get_github_release_info(uri: &str) -> anyhow::Result<Release> {+ let body = http_get(uri)?;+ let release: Release = serde_json::from_slice(&body)+ .with_context(|| format!("parsing the GitHub release JSON from {uri}"))?;+ Ok(release)+}++/// One HTTP GET, whole body in memory. The releases API answers are small+/// and the installer script is a few dozen kilobytes; nothing here streams.+pub fn http_get(uri: &str) -> anyhow::Result<Vec<u8>> {+ use http_req::request::{HttpVersion, Request};+ use http_req::uri::Uri;+ use std::convert::TryFrom;++ let parsed = Uri::try_from(uri)?;+ let mut body = Vec::new();+ let mut request = Request::new(&parsed);+ request+ .version(HttpVersion::Http10)+ .header("User-Agent", &format!("thinkterm/{}", config::wezterm_version()));+ // The same convention as install.sh: a token lifts the anonymous API+ // rate limit and is what makes a private repository reachable at all.+ let auth = std::env::var("GITHUB_TOKEN")+ .ok()+ .filter(|t| !t.trim().is_empty())+ .map(|t| format!("Bearer {}", t.trim()));+ if let Some(auth) = &auth {+ request.header("Authorization", auth);+ }+ let res = request+ .send(&mut body)+ .map_err(|e| anyhow!("fetching {uri}: {e}"))?;+ if !res.status_code().is_success() {+ anyhow::bail!(+ "fetching {uri}: HTTP {} {}",+ res.status_code(),+ res.reason()+ );+ }+ Ok(body)+}++pub fn get_latest_release_info() -> anyhow::Result<Release> {+ get_github_release_info(&format!("{API_RELEASES}/latest"))+}++pub fn get_release_by_tag(tag: &str) -> anyhow::Result<Release> {+ get_github_release_info(&format!("{API_RELEASES}/tags/{tag}"))+}++#[allow(unused)]+pub fn get_nightly_release_info() -> anyhow::Result<Release> {+ get_release_by_tag("nightly")+}++/// The release version of the running build, for comparison against the tag+/// of the latest GitHub release.+///+/// `wezterm_version()` is baked in at compile time from `.tag`, which only the+/// release workflow writes -- and macOS is the one platform whose packages are+/// built by hand rather than in CI, so its binaries carry a commit stamp that+/// `is_newer_release` deliberately refuses to compare against a `v*` tag. The+/// bundle's Info.plist does carry the release version, is read at runtime+/// rather than compile time, and is already what Finder and the About panel+/// show, so prefer it when we are running from inside an app bundle.+pub fn running_release_version() -> String {+ #[cfg(target_os = "macos")]+ {+ if let Some(version) = macos_bundle_version() {+ return version;+ }+ }+ config::wezterm_version().to_string()+}++/// `<bundle>.app/Contents/MacOS/<exe>` puts Info.plist one level up from the+/// executable's directory. Returns None for a bare `cargo build` binary, which+/// has no bundle and should keep reporting its commit stamp.+#[cfg(target_os = "macos")]+fn macos_bundle_version() -> Option<String> {+ let exe = std::env::current_exe().ok()?;+ version_from_info_plist(exe.parent()?.parent()?.join("Info.plist"))+}++#[cfg(target_os = "macos")]+fn version_from_info_plist(path: PathBuf) -> Option<String> {+ let value = plist::Value::from_file(path).ok()?;+ let version = value+ .as_dictionary()?+ .get("CFBundleShortVersionString")?+ .as_string()?+ .trim()+ .to_string();+ if version.is_empty() {+ None+ } else {+ Some(version)+ }+}++/// Whether a version string names a release, as opposed to the+/// `<date>-<hash>` commit stamp a plain checkout builds with. Only a release+/// has a tag on GitHub, so only a release can be fetched by name.+pub fn is_release_version(version: &str) -> bool {+ semver::Version::parse(version.trim_start_matches('v')).is_ok()+}++/// Is `latest` a release the running build should be told about?+///+/// The two strings only compare meaningfully when they use the same scheme.+/// A CI build carries the release tag (the workflow writes `.tag`, which+/// wezterm-version's build.rs prefers); anything built from a plain checkout+/// carries a `<date>-<hash>` commit stamp instead. Comparing across the two+/// with `>` is what made every `v*` release look permanently newer than every+/// local build: 'v' sorts above every digit, so the banner never went away.+pub fn is_newer_release(latest: &str, current: &str) -> bool {+ let parse = |s: &str| semver::Version::parse(s.trim_start_matches('v')).ok();+ match (parse(latest), parse(current)) {+ (Some(latest), Some(current)) => latest > current,+ // Both on the commit-stamp scheme, which upstream still uses for its+ // own tags. It starts with a zero-padded date, so lexicographic order+ // is chronological order.+ (None, None) => latest > current,+ // One of each: there is no ordering between the schemes, and a build+ // that never came from a release is not something to nag about.+ _ => false,+ }+}++/// The shell one-liner that installs release `version` of `variant` for the+/// invoking user, as `install.sh` documents it. Used verbatim over ssh for+/// the remote update and quoted in messages that tell a person what to run.+///+/// `~/.local/bin` goes on PATH first because a non-interactive ssh shell does+/// not source the files that would add it, and the script's PATH reminder is+/// aimed at a person reading a terminal.+pub fn install_command(variant: &str, version: &str) -> String {+ format!(+ "export PATH=\"$HOME/.local/bin:$PATH\"; \+ curl -fsSL {INSTALL_SCRIPT_URL} | sh -s -- --{variant} --version {version}"+ )+}++/// Run `install.sh` on this machine for the install the manifest describes,+/// asking it for release `tag`. The script is fetched fresh and fed to `sh`+/// on stdin, exactly as the documented `curl | sh` does, so there is one+/// installer to keep correct rather than two.+///+/// Returns once the script has finished; its own output goes straight to the+/// terminal, which is where a person running `thinkterm update` is looking.+pub fn run_local_installer(manifest: &InstallManifest, tag: &str) -> anyhow::Result<()> {+ run_installer(manifest, tag, false).map(|_| ())+}++/// The same, with the installer's output collected and returned instead of+/// written to the terminal: what a GUI that has no terminal shows in its+/// own window. On failure the output is in the error's message.+pub fn run_local_installer_captured(manifest: &InstallManifest, tag: &str) -> anyhow::Result<String> {+ run_installer(manifest, tag, true)+}++fn run_installer(manifest: &InstallManifest, tag: &str, capture: bool) -> anyhow::Result<String> {+ use std::io::{Read, Write};+ use std::process::{Command, Stdio};++ let script = http_get(INSTALL_SCRIPT_URL)+ .with_context(|| format!("downloading the installer from {INSTALL_SCRIPT_URL}"))?;++ let mut cmd = Command::new("sh");+ cmd.arg("-s")+ .arg("--")+ .arg(format!("--{}", manifest.variant))+ .arg("--version")+ .arg(tag)+ .arg("--prefix")+ .arg(&manifest.prefix);+ if let Some(app) = &manifest.app {+ if let Some(dir) = Path::new(app).parent() {+ cmd.arg("--app-dir").arg(dir);+ }+ }+ let (out, err) = if capture {+ (Stdio::piped(), Stdio::piped())+ } else {+ (Stdio::inherit(), Stdio::inherit())+ };+ let mut child = cmd+ .stdin(Stdio::piped())+ .stdout(out)+ .stderr(err)+ .spawn()+ .context("running sh for the installer")?;+ {+ let mut stdin = child+ .stdin+ .take()+ .ok_or_else(|| anyhow!("no stdin on the installer process"))?;+ stdin.write_all(&script)?;+ }+ // stderr on its own thread, so a chatty installer cannot fill one pipe+ // while this end waits on the other.+ let stderr_thread = child.stderr.take().map(|mut stderr| {+ std::thread::spawn(move || {+ let mut buf = Vec::new();+ let _ = stderr.read_to_end(&mut buf);+ buf+ })+ });+ let mut output = Vec::new();+ if let Some(mut stdout) = child.stdout.take() {+ stdout.read_to_end(&mut output)?;+ }+ if let Some(thread) = stderr_thread {+ if let Ok(mut err) = thread.join() {+ output.append(&mut err);+ }+ }+ let status = child.wait()?;+ let output = String::from_utf8_lossy(&output).into_owned();+ if !status.success() {+ if capture && !output.trim().is_empty() {+ anyhow::bail!("the installer exited with {status}:\n{}", output.trim());+ }+ anyhow::bail!("the installer exited with {status}");+ }+ Ok(output)+}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn release_tags_order_by_semver() {+ assert!(is_newer_release("0.2.0", "0.1.9"));+ assert!(is_newer_release("v0.2.0", "0.1.9"));+ assert!(!is_newer_release("0.1.9", "0.2.0"));+ assert!(!is_newer_release("0.2.0", "0.2.0"));+ }++ #[test]+ fn commit_stamps_order_by_date_and_never_against_tags() {+ assert!(is_newer_release("20260904-120000-abcdef12", "20260903-120000-abcdef12"));+ assert!(!is_newer_release("0.2.0", "20260903-120000-abcdef12"));+ assert!(!is_newer_release("20260903-120000-abcdef12", "0.2.0"));+ }++ #[test]+ fn only_semver_is_a_release_version() {+ assert!(is_release_version("0.1.0"));+ assert!(is_release_version("v0.1.0"));+ assert!(!is_release_version("20260904-120000-abcdef12"));+ }++ /// The bundle template is the version a hand-built macOS package reports,+ /// so a release that forgets to bump it silently stops notifying users.+ #[cfg(target_os = "macos")]+ #[test]+ fn bundle_template_carries_a_comparable_version() {+ let plist = Path::new(env!("CARGO_MANIFEST_DIR"))+ .join("../assets/macos/ThinkTerm.app/Contents/Info.plist");+ let version = version_from_info_plist(plist)+ .expect("the shipped Info.plist must declare CFBundleShortVersionString");+ assert!(+ is_release_version(&version),+ "Info.plist version {version:?} must parse as semver, or macOS \+ builds cannot be compared against a release tag"+ );+ }++ #[test]+ fn glibc_versions_parse_from_getconf_output() {+ assert_eq!(parse_glibc_version("glibc 2.31\n"), Some((2, 31)));+ assert_eq!(parse_glibc_version("2.35"), Some((2, 35)));+ assert_eq!(parse_glibc_version(""), None);+ assert!(parse_glibc_version("glibc 2.31").unwrap() < MIN_GLIBC);+ assert!(parse_glibc_version("glibc 2.39").unwrap() >= MIN_GLIBC);+ }++ #[test]+ fn source_instructions_pin_a_release_tag() {+ let text = build_from_source_instructions("0.2.0");+ assert!(text.contains("--branch 0.2.0"), "{text}");+ assert!(text.contains("thinkterm-mux-server"), "{text}");+ }++ #[test]+ fn asset_digest_is_read_with_and_without_the_field() {+ let with: Asset = serde_json::from_str(+ r#"{"name":"a","size":1,"url":"u","browser_download_url":"b","digest":"sha256:abcd"}"#,+ )+ .unwrap();+ assert_eq!(with.sha256(), Some("abcd"));+ let without: Asset =+ serde_json::from_str(r#"{"name":"a","size":1,"url":"u","browser_download_url":"b"}"#)+ .unwrap();+ assert_eq!(without.sha256(), None);+ }++ #[test]+ fn install_command_names_variant_and_version() {+ let cmd = install_command("server", "0.2.0");+ assert!(cmd.contains("--server --version 0.2.0"), "{cmd}");+ assert!(cmd.contains(INSTALL_SCRIPT_URL), "{cmd}");+ }+}diff --git a/thinkterm-update/src/manifest.rs b/thinkterm-update/src/manifest.rsnew file mode 100644index 00000000..2833d003--- /dev/null+++ b/thinkterm-update/src/manifest.rs@@ -0,0 +1,232 @@+//! The file `install.sh` leaves behind: `<prefix>/share/thinkterm/install-manifest`,+//! one `key=value` per line. It is the only evidence that this copy of+//! ThinkTerm was put here by the script -- and therefore that the script may+//! overwrite it. A deb, rpm, AppImage or Homebrew install writes no such+//! file and belongs to its own updater.++use anyhow::{anyhow, Context};+use std::path::{Path, PathBuf};++#[derive(Debug, Clone, PartialEq, Eq)]+pub struct InstallManifest {+ /// `desktop` or `server`.+ pub variant: String,+ pub version: String,+ pub os: String,+ pub arch: String,+ /// The `--prefix` the script installed under; binaries are in `bin/`.+ pub prefix: String,+ /// macOS only: where the app bundle went.+ pub app: Option<String>,+ pub installed_at: Option<String>,+ /// Where this manifest was read from.+ pub path: PathBuf,+}++impl InstallManifest {+ pub fn parse(text: &str, path: &Path) -> anyhow::Result<Self> {+ let mut variant = None;+ let mut version = None;+ let mut os = None;+ let mut arch = None;+ let mut prefix = None;+ let mut app = None;+ let mut installed_at = None;+ for line in text.lines() {+ let line = line.trim();+ if line.is_empty() || line.starts_with('#') {+ continue;+ }+ let Some((key, value)) = line.split_once('=') else {+ continue;+ };+ let value = value.trim().to_string();+ match key.trim() {+ "variant" => variant = Some(value),+ "version" => version = Some(value),+ "os" => os = Some(value),+ "arch" => arch = Some(value),+ "prefix" => prefix = Some(value),+ "app" => app = Some(value),+ "installed_at" => installed_at = Some(value),+ _ => {}+ }+ }+ let field = |name: &str, value: Option<String>| {+ value+ .filter(|v| !v.is_empty())+ .ok_or_else(|| anyhow!("{}: missing {name}=", path.display()))+ };+ let variant = field("variant", variant)?;+ if variant != "desktop" && variant != "server" {+ anyhow::bail!("{}: unknown variant '{variant}'", path.display());+ }+ Ok(Self {+ variant,+ version: field("version", version)?,+ os: os.unwrap_or_default(),+ arch: arch.unwrap_or_default(),+ prefix: field("prefix", prefix)?,+ app: app.filter(|a| !a.is_empty()),+ installed_at,+ path: path.to_path_buf(),+ })+ }++ pub fn load(path: &Path) -> anyhow::Result<Self> {+ let text = std::fs::read_to_string(path)+ .with_context(|| format!("reading {}", path.display()))?;+ Self::parse(&text, path)+ }++ /// The manifest describing the running executable, if the script+ /// installed it.+ ///+ /// Two places are tried. `<exe>/../../share/thinkterm/install-manifest`+ /// covers a Linux install, where the binary sits in `<prefix>/bin`. On+ /// macOS the binary runs from inside the app bundle -- `~/.local/bin`+ /// holds only symlinks to it -- so the default prefix is tried as well,+ /// and accepted only when its manifest names the bundle we are running+ /// from. A manifest that describes some other copy of ThinkTerm must not+ /// license overwriting this one.+ pub fn for_running_executable() -> Option<Self> {+ let exe = std::env::current_exe().ok()?;+ Self::for_executable(&exe, dirs_home().as_deref())+ }++ fn for_executable(exe: &Path, home: Option<&Path>) -> Option<Self> {+ let exe = std::fs::canonicalize(exe).unwrap_or_else(|_| exe.to_path_buf());+ let mut candidates = Vec::new();+ if let Some(prefix) = exe.parent().and_then(Path::parent) {+ candidates.push(prefix.join("share/thinkterm/install-manifest"));+ }+ if let Some(home) = home {+ candidates.push(home.join(".local/share/thinkterm/install-manifest"));+ }+ for path in candidates {+ let Ok(manifest) = Self::load(&path) else {+ continue;+ };+ if manifest.describes(&exe) {+ return Some(manifest);+ }+ }+ None+ }++ /// Does this manifest cover the executable at `exe` (already canonical)?+ /// Either the binary lives in the manifest's `<prefix>/bin`, or on macOS+ /// inside the bundle the manifest recorded.+ fn describes(&self, exe: &Path) -> bool {+ let same = |a: &Path, b: &Path| {+ let a = std::fs::canonicalize(a).unwrap_or_else(|_| a.to_path_buf());+ let b = std::fs::canonicalize(b).unwrap_or_else(|_| b.to_path_buf());+ a == b+ };+ if let Some(dir) = exe.parent() {+ if same(dir, &Path::new(&self.prefix).join("bin")) {+ return true;+ }+ }+ if let Some(app) = &self.app {+ let app = std::fs::canonicalize(app).unwrap_or_else(|_| PathBuf::from(app));+ if exe.starts_with(&app) {+ return true;+ }+ }+ false+ }+}++fn dirs_home() -> Option<PathBuf> {+ std::env::var_os("HOME").map(PathBuf::from)+}++#[cfg(test)]+mod tests {+ use super::*;++ const SAMPLE: &str = "variant=server\nversion=0.1.0\nos=linux\narch=x86_64\nprefix=/home/u/.local\ninstalled_at=2026-09-04T05:11:43Z\ninstaller=install.sh\n";++ #[test]+ fn parses_the_script_output() {+ let m = InstallManifest::parse(SAMPLE, Path::new("/x")).unwrap();+ assert_eq!(m.variant, "server");+ assert_eq!(m.version, "0.1.0");+ assert_eq!(m.prefix, "/home/u/.local");+ assert_eq!(m.app, None);+ assert_eq!(m.installed_at.as_deref(), Some("2026-09-04T05:11:43Z"));+ }++ #[test]+ fn rejects_an_unknown_variant() {+ let err = InstallManifest::parse("variant=gui\nversion=1\nprefix=/p\n", Path::new("/x"))+ .unwrap_err();+ assert!(err.to_string().contains("unknown variant"), "{err}");+ }++ #[test]+ fn finds_the_manifest_next_to_a_prefix_install() {+ let dir = tempfile::tempdir().unwrap();+ let prefix = dir.path().join("pfx");+ std::fs::create_dir_all(prefix.join("bin")).unwrap();+ std::fs::create_dir_all(prefix.join("share/thinkterm")).unwrap();+ let exe = prefix.join("bin/thinkterm");+ std::fs::write(&exe, b"").unwrap();+ std::fs::write(+ prefix.join("share/thinkterm/install-manifest"),+ format!("variant=desktop\nversion=0.1.0\nprefix={}\n", prefix.display()),+ )+ .unwrap();+ let m = InstallManifest::for_executable(&exe, None).unwrap();+ assert_eq!(m.variant, "desktop");+ }++ #[test]+ fn a_manifest_for_another_install_is_ignored() {+ let dir = tempfile::tempdir().unwrap();+ let home = dir.path().join("home");+ std::fs::create_dir_all(home.join(".local/share/thinkterm")).unwrap();+ std::fs::create_dir_all(home.join(".local/bin")).unwrap();+ std::fs::write(+ home.join(".local/share/thinkterm/install-manifest"),+ format!(+ "variant=server\nversion=0.1.0\nprefix={}\n",+ home.join(".local").display()+ ),+ )+ .unwrap();+ // A system-wide binary elsewhere: the user's manifest does not cover it.+ let elsewhere = dir.path().join("usr/bin");+ std::fs::create_dir_all(&elsewhere).unwrap();+ let exe = elsewhere.join("thinkterm");+ std::fs::write(&exe, b"").unwrap();+ assert!(InstallManifest::for_executable(&exe, Some(&home)).is_none());+ // The same binary inside that prefix is covered.+ let exe = home.join(".local/bin/thinkterm");+ std::fs::write(&exe, b"").unwrap();+ assert!(InstallManifest::for_executable(&exe, Some(&home)).is_some());+ }++ #[test]+ fn a_macos_bundle_named_by_the_manifest_is_covered() {+ let dir = tempfile::tempdir().unwrap();+ let home = dir.path().join("home");+ let app = dir.path().join("Applications/ThinkTerm.app");+ std::fs::create_dir_all(app.join("Contents/MacOS")).unwrap();+ std::fs::create_dir_all(home.join(".local/share/thinkterm")).unwrap();+ let exe = app.join("Contents/MacOS/thinkterm");+ std::fs::write(&exe, b"").unwrap();+ std::fs::write(+ home.join(".local/share/thinkterm/install-manifest"),+ format!(+ "variant=desktop\nversion=0.1.0\nprefix={}\napp={}\n",+ home.join(".local").display(),+ app.display()+ ),+ )+ .unwrap();+ let m = InstallManifest::for_executable(&exe, Some(&home)).unwrap();+ assert_eq!(m.app.as_deref(), Some(app.to_str().unwrap()));+ }+}diff --git a/thinkterm-update/src/method.rs b/thinkterm-update/src/method.rsnew file mode 100644index 00000000..3aec9329--- /dev/null+++ b/thinkterm-update/src/method.rs@@ -0,0 +1,217 @@+//! How the running copy of ThinkTerm got onto this machine, and therefore+//! who is allowed to replace it.+//!+//! Only a script install is ours to update: it is the one case where+//! nothing else tracks the files. Everything else has an owner -- a package+//! manager, Homebrew, the AppImage's own updater, the person who ran+//! `cargo build` -- and the right move is to name that owner, not to write+//! over its files.++use crate::InstallManifest;+use std::path::Path;++#[derive(Debug, Clone, PartialEq, Eq)]+pub enum InstallMethod {+ /// Put here by `install.sh`; the manifest says where and which variant.+ Script(InstallManifest),+ /// Running from an AppImage, which updates through AppImageUpdate.+ AppImage,+ /// A Homebrew formula or cask (macOS or Linuxbrew).+ Homebrew,+ /// From the Nix store.+ Nix,+ /// Under `/usr/bin` or another system directory without a manifest:+ /// a deb, rpm, apk or distribution package.+ SystemPackage,+ /// The Windows installer.+ WindowsInstaller,+ /// A ThinkTerm.app that no manifest accounts for: unzipped from the+ /// release by hand and dragged into place. Carries the bundle path, so+ /// the installer can be pointed at the same place.+ MacAppBundle(std::path::PathBuf),+ /// Built from a checkout: a commit-stamp version, or a binary sitting in+ /// a cargo `target/` directory.+ SourceBuild,+ /// Nothing recognisable; the person who put it here knows.+ Unknown,+}++impl InstallMethod {+ /// Classify the running executable.+ pub fn detect() -> Self {+ let exe = std::env::current_exe().ok();+ let version = crate::running_release_version();+ Self::classify(+ exe.as_deref(),+ InstallManifest::for_running_executable(),+ std::env::var_os("APPIMAGE").is_some(),+ &version,+ )+ }++ fn classify(+ exe: Option<&Path>,+ manifest: Option<InstallManifest>,+ appimage: bool,+ version: &str,+ ) -> Self {+ if let Some(manifest) = manifest {+ return Self::Script(manifest);+ }+ if appimage {+ return Self::AppImage;+ }+ let path = exe+ .map(|p| p.to_string_lossy().replace('\\', "/"))+ .unwrap_or_default();+ let has = |needle: &str| path.contains(needle);+ if has("/Cellar/") || has("/Caskroom/") || has("/homebrew/") || has("/linuxbrew/") {+ return Self::Homebrew;+ }+ if path.starts_with("/nix/store/") {+ return Self::Nix;+ }+ if cfg!(windows) && (has("/Program Files") || has("/AppData/Local/Programs/")) {+ return Self::WindowsInstaller;+ }+ if has("/ThinkTerm.app/Contents/MacOS/") {+ if let Some(app) = exe.and_then(|e| e.ancestors().find(|a| a.ends_with("ThinkTerm.app"))) {+ return Self::MacAppBundle(app.to_path_buf());+ }+ }+ if has("/target/") || !crate::is_release_version(version) {+ return Self::SourceBuild;+ }+ if path.starts_with("/usr/bin/")+ || path.starts_with("/usr/lib/")+ || path.starts_with("/usr/libexec/")+ || path.starts_with("/opt/")+ {+ return Self::SystemPackage;+ }+ Self::Unknown+ }++ /// True when `thinkterm update` may replace the files itself: a script+ /// install, or a bundle it can take over by running the script at it.+ pub fn self_updatable(&self) -> bool {+ matches!(self, Self::Script(_) | Self::MacAppBundle(_))+ }++ /// The manifest to run the installer with. A hand-installed bundle has+ /// none, so one is made up for it: desktop variant, the default prefix+ /// for the command-line links, and the bundle where it already is. The+ /// installer then writes the real manifest, and the next update finds+ /// it the ordinary way.+ pub fn manifest_for_install(&self) -> Option<InstallManifest> {+ match self {+ Self::Script(m) => Some(m.clone()),+ Self::MacAppBundle(app) => {+ let home = std::env::var_os("HOME").map(std::path::PathBuf::from)?;+ Some(InstallManifest {+ variant: "desktop".into(),+ version: crate::running_release_version(),+ os: "macos".into(),+ arch: std::env::consts::ARCH.into(),+ prefix: home.join(".local").to_string_lossy().into_owned(),+ app: Some(app.to_string_lossy().into_owned()),+ installed_at: None,+ path: home.join(".local/share/thinkterm/install-manifest"),+ })+ }+ _ => None,+ }+ }++ /// One or two sentences telling a person how this install is updated,+ /// for the methods that are not ours to touch.+ pub fn how_to_update(&self) -> String {+ match self {+ Self::Script(m) => format!(+ "installed by install.sh ({} variant, {}); `thinkterm update` can replace it",+ m.variant, m.version+ ),+ Self::AppImage => "this is an AppImage: update it with AppImageUpdate, or download the \+ new AppImage from the releases page"+ .into(),+ Self::Homebrew => "installed with Homebrew: run `brew upgrade thinkterm`".into(),+ Self::Nix => "installed from the Nix store: update it through your Nix configuration".into(),+ Self::SystemPackage => "installed by the system package manager: update it with apt, dnf, \+ pacman or whatever installed it, using the new package from the \+ releases page"+ .into(),+ Self::WindowsInstaller => "installed by the Windows installer; `thinkterm update` downloads \+ the new installer and runs it"+ .into(),+ Self::MacAppBundle(app) => format!(+ "a ThinkTerm.app installed by hand at {}; `thinkterm update` can replace it in \+ place and put the command-line links under ~/.local/bin",+ app.display()+ ),+ Self::SourceBuild => "this is a build from source: pull the repository and build again".into(),+ Self::Unknown => "this copy was not installed by install.sh, so `thinkterm update` will \+ not touch it; replace it the way it was installed"+ .into(),+ }+ }+}++#[cfg(test)]+mod tests {+ use super::*;+ use std::path::PathBuf;++ fn manifest() -> InstallManifest {+ InstallManifest {+ variant: "server".into(),+ version: "0.1.0".into(),+ os: "linux".into(),+ arch: "x86_64".into(),+ prefix: "/home/u/.local".into(),+ app: None,+ installed_at: None,+ path: PathBuf::from("/home/u/.local/share/thinkterm/install-manifest"),+ }+ }++ #[test]+ fn a_manifest_wins_over_everything_else() {+ let m = InstallMethod::classify(+ Some(Path::new("/opt/homebrew/Cellar/thinkterm/0.1.0/bin/thinkterm")),+ Some(manifest()),+ true,+ "0.1.0",+ );+ assert!(m.self_updatable());+ }++ #[test]+ fn classifies_the_common_layouts() {+ let c = |p: &str, v: &str| InstallMethod::classify(Some(Path::new(p)), None, false, v);+ assert_eq!(+ c("/opt/homebrew/Cellar/thinkterm/0.1.0/bin/thinkterm", "0.1.0"),+ InstallMethod::Homebrew+ );+ assert_eq!(+ c("/Applications/ThinkTerm.app/Contents/MacOS/thinkterm", "0.1.0"),+ InstallMethod::MacAppBundle(PathBuf::from("/Applications/ThinkTerm.app"))+ );+ assert_eq!(c("/usr/bin/thinkterm", "0.1.0"), InstallMethod::SystemPackage);+ assert_eq!(+ c("/nix/store/abc-thinkterm-0.1.0/bin/thinkterm", "0.1.0"),+ InstallMethod::Nix+ );+ assert_eq!(+ c("/home/u/src/thinkterm/target/release/thinkterm", "0.1.0"),+ InstallMethod::SourceBuild+ );+ assert_eq!(+ c("/usr/bin/thinkterm", "20260904-120000-abcdef12"),+ InstallMethod::SourceBuild+ );+ assert_eq!(+ InstallMethod::classify(Some(Path::new("/usr/bin/thinkterm")), None, true, "0.1.0"),+ InstallMethod::AppImage+ );+ }+}diff --git a/wezterm/Cargo.toml b/wezterm/Cargo.tomlindex 03d927be..b0fd83fd 100644--- a/wezterm/Cargo.toml+++ b/wezterm/Cargo.toml@@ -45,6 +45,7 @@ termwiz.workspace = truetextwrap.workspace =truethinkterm-proto.workspace = truethinkterm-tui = { path = "../thinkterm-tui" }+thinkterm-update.workspace = trueumask.workspace = trueurl.workspace = truewezterm-client.workspace = truediff --git a/wezterm/src/main.rs b/wezterm/src/main.rsindex 9c7992fe..c2c8eaf5 100644--- a/wezterm/src/main.rs+++ b/wezterm/src/main.rs@@ -253,6 +253,9 @@ enum SubCommand {#[command(name = "replay", about = "Replay an asciicast terminal session")]Replay(asciicast::PlayCommand),+ #[command(name = "update", about = "Check for a newer release and install it")]+ Update(UpdateCommand),+/// Generate shell completion information#[command(name = "shell-completion")]ShellCompletion {@@ -750,6 +753,136 @@ impl ImgCatCommand {}}+/// `thinkterm update`: the one-command upgrade for a copy that install.sh+/// put here. Anything else (a deb, Homebrew, an AppImage, a build from+/// source) has its own updater, and the command names it instead of+/// touching files it does not own.+#[derive(Debug, Parser, Clone)]+struct UpdateCommand {+ /// Only report whether a newer release exists; install nothing.+ #[arg(long)]+ check: bool,++ /// Install without asking for confirmation.+ #[arg(long, short = 'y')]+ yes: bool,++ /// Install this release instead of the latest one (a downgrade is+ /// allowed).+ #[arg(long, value_name = "VERSION")]+ version: Option<String>,+}++impl UpdateCommand {+ fn run(&self) -> anyhow::Result<()> {+ use thinkterm_update::{InstallMethod, INSTALL_SCRIPT_URL};++ let current = thinkterm_update::running_release_version();+ let method = InstallMethod::detect();++ let target = match &self.version {+ Some(tag) => thinkterm_update::get_release_by_tag(tag.trim_start_matches('v'))+ .or_else(|_| thinkterm_update::get_release_by_tag(tag))+ .with_context(|| format!("release {tag} not found"))?,+ None => thinkterm_update::get_latest_release_info()+ .context("looking up the latest release on GitHub")?,+ };+ let target_version = target.tag_name.trim_start_matches('v').to_string();++ println!("running: {current}");+ if self.version.is_some() {+ println!("target: {target_version}");+ } else {+ println!("latest: {target_version}");+ }+ println!("install: {}", method.how_to_update());++ let newer = thinkterm_update::is_newer_release(&target.tag_name, ¤t);+ if self.version.is_none() && !newer {+ if thinkterm_update::is_release_version(¤t) {+ println!("You are on the latest release.");+ } else {+ println!(+ "This is not a release build, so there is nothing to compare it against; \+ {} is the latest release.",+ target_version+ );+ }+ return Ok(());+ }+ if self.check {+ if newer {+ println!("A newer release is available: {}", target.html_url);+ } else {+ println!("Release page: {}", target.html_url);+ }+ return Ok(());+ }++ if matches!(method, InstallMethod::WindowsInstaller) || (cfg!(windows) && matches!(method, InstallMethod::Unknown)) {+ if !self.yes {+ print!("Download the {target_version} installer and run it? It will close ThinkTerm and reopen it. [y/N] ");+ std::io::stdout().flush()?;+ let mut answer = String::new();+ std::io::stdin().read_line(&mut answer)?;+ if !matches!(answer.trim(), "y" | "Y" | "yes") {+ println!("Not installing.");+ return Ok(());+ }+ }+ thinkterm_update::run_windows_installer(&target)?;+ println!("The installer is running; it finishes on its own.");+ return Ok(());+ }++ let Some(manifest) = method.manifest_for_install() else {+ println!();+ println!("Not installing: {}.", method.how_to_update());+ println!("Release page: {}", target.html_url);+ if cfg!(unix) {+ println!(+ "To switch this machine to script-managed installs instead, run:\n \+ curl -fsSL {INSTALL_SCRIPT_URL} | sh"+ );+ }+ return Ok(());+ };++ if !self.yes {+ match &method {+ InstallMethod::MacAppBundle(app) => print!(+ "Replace {} with {} and link its command-line tools under {}/bin? [y/N] ",+ app.display(),+ target_version,+ manifest.prefix+ ),+ _ => print!(+ "Install {} ({} variant, under {})? [y/N] ",+ target_version, manifest.variant, manifest.prefix+ ),+ }+ std::io::stdout().flush()?;+ let mut answer = String::new();+ std::io::stdin().read_line(&mut answer)?;+ if !matches!(answer.trim(), "y" | "Y" | "yes") {+ println!("Not installing.");+ return Ok(());+ }+ }++ if let Err(err) = thinkterm_update::run_local_installer(&manifest, &target.tag_name) {+ println!();+ println!("The installer failed ({err:#}); nothing was changed.");+ println!("If it refused this machine (glibc, musl, architecture), a release binary cannot run here.");+ println!("{}", thinkterm_update::build_from_source_instructions(&target_version));+ anyhow::bail!("update failed");+ }+ println!();+ println!("Installed {target_version}. A running thinkterm-mux-server or GUI keeps the old build until it is restarted.");+ Ok(())+ }+}+#[derive(Debug, Parser, Clone)]struct SetCwdCommand {/// The directory to specify.@@ -894,6 +1027,7 @@ fn run() -> anyhow::Result<()> {SubCommand::Cli(cli) => cli::run_cli(&opts, cli),SubCommand::Record(cmd) => cmd.run(init_config(&opts)?),SubCommand::Replay(cmd) => cmd.run(),+ SubCommand::Update(cmd) => cmd.run(),SubCommand::Tui(cmd) => thinkterm_tui::run(init_config(&opts)?,thinkterm_tui::TuiOptions {