Commit graph

269 commits

Author SHA1 Message Date
patriceckhart
872a312a06 fix(install): resolve latest version via GitHub API on Windows
The PowerShell installer scraped the tag from the /releases/latest
redirect via $resp.BaseResponse.ResponseUri, which only exists on
Windows PowerShell 5.1. On PowerShell 7 (the default iwr|iex runtime)
BaseResponse is an HttpResponseMessage with no ResponseUri, so the value
was null, the regex never matched, and the script died with 'could not
resolve latest version' even though zot is public.

Resolve via api.github.com/.../releases/latest instead (tag_name is
returned directly, identical across PS 5.1 and 7+), add status-aware
error messages (404 / 401-403 / other), and drop the stale private-repo
note. Verified on PowerShell 7.7.
2026-05-29 11:26:18 +02:00
patriceckhart
edbbcc1086 fix(provider): include full catalog in model picker, gate by credentials
Active() captured Catalog into a package var initializer, which runs
before the init() functions in catalog_builtin.go/extra_models.go append
the extended catalog. The picker therefore only ever saw the curated
seed list, dropping openrouter and every other extra provider. Defer the
Catalog read to call time so Active() reflects the fully-assembled list.

Also make the model dialog filter strictly by logged-in providers: an
empty credential set now yields an empty picker (with a /login hint)
instead of dumping the entire ~900-model catalog.
2026-05-29 11:26:10 +02:00
patriceckhart
5470345d15 feat(provider): add Claude Opus 4.8 to anthropic + bedrock + gateway catalogs
Anthropic shipped claude-opus-4-8 today (2026-05-28). Pricing and
limits are identical to the 4.7 line per models.dev:

  - 1,000,000 token context window
  - 128,000 token max output
  - reasoning supported
  - $5.00 / $25.00 per 1M input/output tokens
  - $0.50 / $6.25 per 1M cache read/write tokens

Mirror the same provider topology zot already uses for 4.5, 4.6, and
4.7, so the new model shows up everywhere users have an existing
Opus route configured:

  - packages/provider/models.go: anthropic (speculative block,
    matching how 4.5/4.6/4.7 are listed)
  - packages/provider/catalog_builtin.go:
      * amazon-bedrock: anthropic.claude-opus-4-8 plus the five
        regional cross-region inference profiles
        (us./eu./global./jp./au.). AU keeps its 3.3x surcharge
        ($16.50 / $82.50) consistent with 4.6/4.7 AU rows.
      * cloudflare-ai-gateway
      * github-copilot (Copilot pricing is $0/$0, ctx 144k,
        output 64k, matching the 4.7 Copilot row)
      * opencode
      * openrouter: standard route plus the 6x 'Fast' SKU
        ($30/$150/$3/$37.50) consistent with 4.6/4.7
      * vercel-ai-gateway

Vertex (google-vertex / google-vertex-anthropic) is deliberately
skipped: zot's google-vertex provider is Gemini-only today and there
is no google-vertex-anthropic provider wired up. Earlier Opus
versions skip Vertex for the same reason, so 4.8 stays consistent.

Tests:
  - go build ./... clean
  - go vet ./packages/provider/... clean
  - go test ./packages/provider/... pass
2026-05-28 21:34:12 +02:00
patriceckhart
3ce114c8de feat(update): fast-forward installed extensions during zot update
After the binary swap succeeds, zot update now walks
$ZOT_HOME/extensions/ and runs git pull --ff-only on every
extension that is a git checkout.

Per-extension behaviour:
- disabled extensions: skipped
- no .git/ directory: skipped (no remote to pull from)
- dirty worktree: stashed (--include-untracked) before the pull,
  popped after; conflict on pop leaves markers in place with a
  warning rather than discarding the runtime state
- diverged / offline / any git failure: reported as failed and the
  next extension is processed
- timeout per extension: 60s
- no build step is ever executed; authors commit the runnable
  artifact, or the user rebuilds manually and /reload-ext

zot update itself never aborts because of an extension. The
binary swap is the source of truth for success.

Implementation in packages/agent/extupdate.go (~150 LoC), 13 unit
tests covering each branch including stash+pop with untracked
runtime files, diverged history, unreachable remote, and the
mixed-state scenario. README's Extensions section documents the
new behaviour.
2026-05-27 09:37:59 +02:00
patriceckhart
fa7d8d8be5 refactor: split source into packages/{provider,core,tui,agent}
Single Go module, four top-level packages under packages/. Import
paths become github.com/patriceckhart/zot/packages/<name>; downstream
consumers can depend on individual packages without pulling the rest.

Layout:
  packages/provider/     LLM clients + catalog
  packages/provider/auth/ credential store + OAuth + login server
  packages/core/         agent loop, sessions, cost
  packages/tui/          terminal toolkit + chat view
  packages/agent/        CLI wiring, system prompt
    extensions/ extproto/ modes/ tools/ skills/ swarm/
    sdk/  (was pkg/zotcore, package renamed zotcore -> sdk)
    ext/  (was pkg/zotext, package renamed zotext -> ext)

internal/ and pkg/ removed. The internal/assets logo moved into
packages/provider/auth/assets.

Public Go SDK identifiers renamed:
  pkg/zotcore (package zotcore) -> packages/agent/sdk (package sdk)
  pkg/zotext  (package zotext)  -> packages/agent/ext (package ext)

This breaks Go-based extensions and embedders; the JSON wire protocol
for extensions and RPC is unchanged, so non-Go extensions, already-
built extension binaries, and zot rpc consumers are unaffected.

Docs, examples, and the built-in write-zot-extension skill updated
for the new paths and identifiers. Shadow-bug fixes in code samples
(ext := ext.New -> e := ext.New).
2026-05-27 09:07:15 +02:00
patriceckhart
fb3e1afa80 fix btw cursor row and column alignment 2026-05-26 18:55:40 +02:00
patriceckhart
d55af26936 document default thinking level 2026-05-26 18:11:30 +02:00
patriceckhart
583b2a7db2 sanitize gemini tool schemas 2026-05-26 18:10:25 +02:00
patriceckhart
37ef90bbb3 add configurable thinking level 2026-05-26 18:07:33 +02:00
patriceckhart
d6a30a5967 fix swarm editor cursor placement 2026-05-26 17:30:44 +02:00
patriceckhart
80c0ac97a5 feat: auto-swarm summary, system-prompt nudge, README/docs
- Sub-agents are long-lived daemons that keep running on the inbox
  after the initial task, so agent.Wait() never unblocks for them.
  Replaced the Wait-based watcher with a per-turn OnTurnEnd callback:
  Agent.SetOnTurnEnd installs it under the agent mutex, the runner's
  stdout decoder fires it on every turn_end event from the child.
- trackSwarmAgent now subscribes via SetOnTurnEnd. First turn_end per
  tracked sub-agent marks it done; when every entry is done, zot
  flushes one [auto-swarm update] turn via SubmitOrQueue summarising
  each agent's status / task / transcript tail (and the turn error if
  any) so the main agent can recap the collective outcome in chat.
- System addendum extended to tell the model to expect that update
  message and treat it as observed state, not a new user request.
- README: /settings row in the slash-commands table, new /settings
  subsection covering both toggles, auto-swarm paragraph appended to
  the /swarm subsection, /settings listed as a read-only mid-turn
  command.
2026-05-25 18:47:29 +02:00
patriceckhart
6320769094 feat: /settings dialog with auto-swarm toggle
Re-enable the /settings slash command and add an auto-swarm setting
that lets the agent spawn parallel background sub-agents on its own.

- Config: persist auto_swarm_enabled in config.json.
- SettingsStore: SetAutoSwarm; AutoSwarmEnabled() reads live flag.
- /settings: two items (inline images, auto-swarm); any toggle now
  triggers a full repaint (Ctrl+L equivalent) so changes land
  immediately.
- New built-in tool swarm_spawn: forks a background sub-agent against
  the host cwd via Swarm.SpawnReq and returns the agent id immediately
  so the main turn keeps running in parallel. Schema accepts task,
  optional model, optional provider.
- Tool is only registered when auto-swarm is on (startup checks the
  flag; live toggle adds/removes it on the running agent). Model never
  sees a tool it can't use.
- System prompt gains an AutoSwarmSystemAddendum when auto-swarm is on,
  telling the model to use swarm_spawn proactively for parallelizable
  sub-tasks. Applied at Resolve time and live-swapped on toggle so the
  model adapts mid-session without a restart.
- cli.go: construct swarmMgr earlier so the auto-swarm tool can capture
  it before agent build; injectSwarmSpawn helper threads through every
  registry build path (initial, buildAgent, buildAgentFor,
  buildAgentForRescue, /reload-ext).
2026-05-25 18:29:08 +02:00
patriceckhart
66847247b3 fix: full-width extensions divider in slash command popup
len(label) counted bytes, but the leading "── " glyphs are multi-byte
runes, so the rule was padded ~4 columns short of the right edge.
Switched to runewidth.StringWidth(label) to match dialog_frame.go.
2026-05-25 17:08:54 +02:00
patriceckhart
5293277d36 Load user skills by default 2026-05-24 20:12:06 +02:00
patriceckhart
90d877fc3e Align built-in model catalog
Refresh built-in model metadata and add missing provider/model entries. Also fix config validation for duplicate model IDs so a model valid for the configured provider is not repaired based on another provider's matching ID.
2026-05-24 19:32:19 +02:00
patriceckhart
757e158e8e Remove pagination from slash command popup
Slash command list now renders every match at once; the (x/y) counter and page-window slicing only made sense when the popup was capped at a page. Subview pickers (login provider, jump turns, etc.) keep their pagination.
2026-05-24 14:39:05 +02:00
patriceckhart
cd4484d07f Run gofmt on provider files 2026-05-24 12:00:21 +02:00
patriceckhart
388e6720ae Fix Gemini image test for Go 1.23 CI
testing.T.Chdir is Go 1.24 only; CI runs 1.23. Replace with os.Chdir + cleanup so the test compiles on the supported Go version.
2026-05-24 11:58:16 +02:00
patriceckhart
cbd9442039 Document expanded provider and model catalog in README 2026-05-24 11:53:42 +02:00
patriceckhart
92e8475330 Improve multiline input navigation
Let Up/Down move through visual rows in multiline or wrapped editor input before falling back to chat scrolling.

Fix styled-prompt wrap geometry so vertical movement preserves the target visual column, and update help text to describe the new behavior.
2026-05-24 11:38:46 +02:00
patriceckhart
3364159201 Add expanded login provider support
Add GitHub Copilot subscription login and broaden API-key login to all catalog providers.

Persist credentials for additional API-key providers, include them in model filtering and logout, and fix clearing those stored credentials.

Improve provider/model/slash pickers with pagination and clearer credential-state labels.
2026-05-24 11:08:09 +02:00
patriceckhart
689069f11a Expand model catalog and improve session resume
Add built-in provider catalog and support for additional provider backends, including Bedrock, Vertex, Azure OpenAI, GitHub Copilot, OpenAI Responses, and extra user-configured providers/models.

Improve TUI session resume by restoring last-turn context usage and tail-rendering long transcripts for faster first paint.

Handle Gemini image models without tools, persist generated images to the working directory, and make Anthropic transcript replay tolerate assistant-side image artifacts.
2026-05-24 10:15:07 +02:00
patriceckhart
91c696dbfc Fix update banner formatting 2026-05-22 19:21:27 +02:00
patriceckhart
9b7e0ace7f Style update banner command 2026-05-22 19:11:56 +02:00
patriceckhart
3d7f80eebb Add spacing around dialog frames 2026-05-22 18:53:23 +02:00
patriceckhart
8cd8410ace Use ASCII ellipses throughout 2026-05-22 17:19:29 +02:00
patriceckhart
47257c8a54 Add separator before truncated tool footers 2026-05-22 17:12:06 +02:00
patriceckhart
14ffdb65b0 Expose OpenAI Codex as separate provider 2026-05-20 21:24:19 +02:00
patriceckhart
f9d14252dc Fix swarm inbox listener close race 2026-05-20 20:31:13 +02:00
patriceckhart
b13a9a6a4d Embed zot docs in binary 2026-05-20 20:25:29 +02:00
patriceckhart
d46f1d5824 feat(ext-panel): allow invisible selection marker via U+200B
ext_panel_dialog.Render sniffs the leading glyph of each panel line
to decide which row is selected and apply the theme's selection
band: today that's '> ' (U+25B8) or '* ' (U+25CF), both visible.
Extensions that want the highlight without a visible glyph had no
way to opt in - they had to ship the arrow.

Adds U+200B (zero-width space) as a third recognised prefix.
Extensions can now emit '\u200B' at the start of the selected row
to get the blue selection band without any visible marker; the
character renders as zero columns so other rows that omit it line
up perfectly. The visible arrow markers keep working unchanged.

Used by zot-workspaces to highlight the cursor row without
inserting a triangle into the otherwise clean list.
2026-05-19 19:48:17 +02:00
patriceckhart
e48f4dda76 feat: runtime cwd switching via hidden /cd and extension submit_slash
Adds the plumbing needed to let an extension jump the running zot
session into a different working directory without restarting the
process. Two pieces:

1) Hidden /cd <path> slash command

   * accepts ~/abs/relative paths, validates the target is a real
     directory
   * cancels the active turn, flushes + closes the current session
   * re-roots the shared sandbox (the /jail state is preserved
     verbatim - if jailed it stays jailed, just pointed at the new
     cwd)
   * rebuilds the agent via the existing buildAgent() so tools,
     AGENTS.md addendum, system prompt, and sessions dir all bind
     to the new cwd
   * opens a fresh session in the new cwd's bucket (matches the
     semantics of relaunching with zot --cwd <path>)
   * pushes the new state into the running Interactive via a new
     ApplyChangedCWD method and re-scopes the swarm dashboard

   /cd is not in slash_suggest's catalog, not in /help, not in the
   README. It's in a new hiddenSlashCommands list so the dispatcher
   accepts it without surfacing the verb to autocomplete. The
   slashCancelsTurn switch returns true for /cd so it never races
   with a streaming turn.

   InteractiveConfig.ChangeCWD is the optional host hook; embedders
   that don't wire it surface 'host did not wire ChangeCWD' instead
   of no-oping.

2) submit_slash extension protocol frame

   Extensions can now send a spontaneous {type:'submit_slash',
   text:'/...'} frame from any handler (notably panel_key) to run
   a slash command in the host TUI as if the user had typed it.
   The host refuses anything that doesn't start with '/' and logs
   the refusal to the extension's stderr log file, so a misbehaving
   extension can't sneak a plain-text model prompt through this
   path.

   HostHooks gains a SubmitSlash(text string) method; the three
   existing implementers (interactive, non-interactive, rpc) and
   the test stub now satisfy it. Only the interactive hook does
   anything; the rest no-op since slash commands aren't meaningful
   outside the TUI.

   Interactive.SubmitSlash routes the text through runSlash with
   the same cancel-active-turn-if-destructive treatment the editor
   uses for typed commands.

The workspaces extension drives this end-to-end: pressing Enter on
a row sends panel_close + submit_slash '/cd <abs>', which jumps
zot into that directory in place.
2026-05-19 19:38:47 +02:00
patriceckhart
ad93054ac4 feat(editor): extend path tab-completion to /btw and /swarm editors
The shell-style path tab-completion added in the previous commit only
ran against the main interactive editor; /btw and /swarm have their
own *tui.Editor instances inside their dialogs and routed Tab through
editor.HandleKey untouched, so '~/Dev'+Tab inserted nothing in those
modes.

Refactored the completion into a free helper:

  tryPathTabCompleteEditor(ed *tui.Editor, cwd string) bool

The Interactive method is now a thin wrapper that adds frame
invalidation. btwDialog gained a cwd field (set by Open) and calls
the helper before forwarding to editor.HandleKey. swarmDialog
already tracked d.cwd; both its prompt-editor and spawn-editor
paths now run the helper before HandleKey, gated to skip when the
@-picker popup is active so Tab there still selects the highlighted
chip.

Net effect: ~/Dev+Tab, ./int+Tab, cmd/+Tab, etc. now work the same
way in the main composer, in /btw side chats, and in /swarm spawn
and follow-up prompts.
2026-05-19 18:50:05 +02:00
patriceckhart
8096aebd0c feat(editor): shell-style tab-completion for path tokens
Typing a path-like token and pressing Tab in the editor now completes
it against the filesystem, the way bash / zsh do. No popup, no UI -
the token is rewritten in place.

Recognised shapes:
  ~ or ~/foo       - expanded via os.UserHomeDir(); the displayed
                     token keeps its ~ form after completion
  /abs/path        - absolute
  ./foo, ../foo    - relative to cwd
  foo/bar          - any token containing a slash, relative to cwd

Bare words ('hello', 'fix') without a slash or tilde are still no-ops
on Tab so plain text isn't disturbed.

Behaviour matches a typical shell:
  - one match: full replace, trailing / appended for directories so
    the next Tab can dive in
  - multiple matches: completes to the longest common prefix; if the
    prefix is already what was typed, Tab is a no-op (no second-tab
    'show options' list yet)
  - dotfiles hidden unless the user typed a leading dot

Tab inside the slash-command and @-file popups still does what it did
before; the new path completion only kicks in when neither popup is
active.
2026-05-19 18:44:01 +02:00
patriceckhart
4f008e8871 fix(@-picker): pick up files and folders created mid-session
fileSuggester.scan() cached the directory listing keyed only on the
absolute path, and the only invalidation paths (Reset / Invalidate /
SetCWD) never fired for in-place filesystem changes. Once the picker
had scanned the cwd, any later mkdir or touch was invisible until
zot restarted.

Key the cache on (path, mtime) instead. Stat the browse directory on
every scan and re-read when its ModTime has moved; OSes bump dir
mtime on every entry add / remove / rename, so the picker now reflects
the filesystem within a keystroke. Stat is one cheap syscall and only
runs while the popup is open, so the input loop stays responsive on
large repos.

Added TestFileSuggesterPicksUpNewEntries to pin the behaviour: scan,
sleep past the fs mtime tick, mkdir, scan again, expect the new dir.
2026-05-19 18:37:36 +02:00
patriceckhart
81c913aef9 feat(/study): accept an optional file or directory argument
/study previously hard-coded the prompt to 'the current directory'.
It now takes an optional path - typed, drag-dropped, or selected via
the @ file picker - and tailors the prompt to whatever was passed,
distinguishing files from directories via os.Stat and rendering paths
under cwd as relative for readability. With no argument, behaviour is
unchanged.

Examples:
  /study                          -> current directory (old behaviour)
  /study internal                 -> directory internal
  /study [dir:internal/]          -> directory internal (via @-picker)
  /study cmd/zot/main.go          -> file cmd/zot/main.go
  /study [file:cmd/zot/main.go]   -> file cmd/zot/main.go (via @-picker)
2026-05-19 18:37:27 +02:00
patriceckhart
e0c933ad7e Allow styled extension panel lines 2026-05-19 17:47:27 +02:00
patriceckhart
25e7da2c01 tui: highlight selected rows and accent frame in extension panel
Style ext panel rows that start with the selection markers (▸ / ●) using
the theme's selection colors, pad them to full width, and keep ✓ glyphs
in the tool color. Render the panel header and bottom rule in the accent
color so panels stand out from regular dialogs.
2026-05-17 13:48:45 +02:00
patriceckhart
1aea23e419 swarm: drop git-worktree / isolation; agents share the host cwd
Each swarm subagent now runs with cwd == the parent zot's RepoRoot, just
like the main agent. No per-agent git worktree, no swarm/<id> branch, no
SetIsolation toggle, no '\''i'\'' dashboard shortcut, no --isolated flag. The
previous worktree flow was confusing (toggling '\''i'\'' on a running agent
couldn'\''t reseat its cwd, so edits kept landing in the host repo anyway)
and shipped without a real use case.

Concretely:

- delete internal/swarm/worktree.go and the WorktreeManager interface.
- Config loses Worktree; SpawnReq loses Isolated; Agent loses Branch and
  Isolated; AgentSnapshot loses Branch and Isolated; agentMeta loses
  branch and isolated (older meta.json files still decode \u2014 unknown JSON
  keys are ignored \u2014 and buildDetachedAgent coerces any stale per-
  worktree Dir back to the live RepoRoot so detached agents resume in
  the right place).
- Swarm.Remove no longer calls into any worktree manager, so it can'\''t
  accidentally git-worktree-remove the user'\''s actual source tree; it
  only clears <swarm-root>/agents/<id>/.
- runner.go drops the <Dir>/.zot/session.json fallback (every plausible
  Dir is now the user'\''s repo, where a stray .zot/ would litter the
  source tree); SessionPath is required and Spawn always populates it
  under <swarm-root>/agents/<id>/session.json.
- swarm dialog: remove isolate/SetIsolateFunc, the '\''i'\'' key handler, the
  MODE column, the mode/branch lines in the transcript header. Fix the
  transcript-view cursor row math (row += 4 was counting a now-removed
  branch row, leaving the caret one row above the editor accent bar).
- swarm slash command: drop /swarm isolate, /swarm unisolate, and the
  --isolated flag on /swarm new; trim the spawn-flag parser and tests.
- README and slash-suggest description updated; site copy updated in a
  separate commit.

Tests adjusted accordingly; full suite green.
2026-05-17 00:01:29 +02:00
patriceckhart
63e28ad156 Close swarm event log in follower test 2026-05-16 14:18:12 +02:00
patriceckhart
d7fe461910 Fix swarm tests on Windows CI 2026-05-16 14:12:03 +02:00
patriceckhart
37526a6286 Format swarm code 2026-05-16 14:01:23 +02:00
patriceckhart
36f190af31 Deliver sliding-in messages during agent loop 2026-05-16 12:47:38 +02:00
patriceckhart
467ad0a990 modes: adapt slide-back chord hint to terminal
The "Press Option+up to slide back into input" hint shown under the
sliding-in queue was correct on Ghostty, iTerm2 (Meta=Option),
Terminal.app (Use Option as Meta), Alacritty, and Kitty -- all of
which send CSI 1;3A for Option+Up, which the input parser reads as
KeyUp + Alt.

VS Code's integrated terminal (xterm.js on macOS) swallows plain
Option as a compose modifier by default, so Option+Up never reaches
zot as an Alt-modified arrow. Option+Shift+Up does work there:
xterm.js emits CSI 1;4A (Shift+Alt), which the parser already
accepts as alt=true. The binding has always worked in VS Code;
only the displayed hint was misleading.

Fix: a small slideBackChordHint() helper that returns
"Option+Shift+up" when TERM_PROGRAM=vscode and "Option+up"
otherwise. interactive.go's queue-hint row calls it instead of
hardcoding the chord. The binding itself is unchanged -- both
chords work on every terminal -- the hint just adapts to what the
host actually delivers.

README.md gains a one-sentence note under Queued messages
documenting both chords and that the hint adapts via
$TERM_PROGRAM.

Tests cover the VS Code branch, case-insensitive detection
(VSCode / VSCODE / VsCode), and the default for "", "ghostty",
"iTerm.app", "Apple_Terminal", "alacritty", "kitty".
2026-05-16 12:01:05 +02:00
patriceckhart
b11e6ed4e4 swarm: introduce /swarm dashboard, /btw-style transcript view, and per-session scope
A /swarm subsystem for long-running parallel subagents. Each agent runs
in its own subprocess against a fresh git worktree (branch swarm/<id>)
with its own persistent session file and unix-socket inbox; the parent
zot stays in the main session and pokes / observes them via the
dashboard.

Highlights:

- New internal/swarm package: Agent, Spawn/Resume/Kill/Remove, event log
  (events.jsonl), inbox protocol (listen/dial), worktree manager, exec
  runner that spawns "zot --swarm-agent ...".
- New internal/agent/swarm_agent.go: daemon-mode child entry point.
  Reuses the standard agent loop but persists turns to the supervisor-
  chosen session.json and streams events as JSONL on stdout. Mirror to
  events.jsonl is dormant while the supervisor's stdout pipe is alive so
  events do not get double-written.
- Resume reattaches in place: reuses the same worktree, session, branch
  and inbox path; carries forward the prior transcript replayed from
  events.jsonl. Resume no longer re-fires the original Task as a fresh
  user turn -- that was producing "agent busy; send cancel first" races.
- core.NewSessionAtPath plus an openOrCreateSession fallback so the
  child actually persists its session.json at the supervisor-chosen path
  on first spawn instead of running with sess==nil.
- Dashboard in internal/agent/modes/swarm_dialog.go + swarm_slash.go:
  list / new / kill / remove / resume / logs / send subcommands plus an
  interactive picker. Transcript view is /btw-style: an always-on
  inline editor at the bottom, streaming auto-follow, inline busy
  spinner with the agent's current activity such as "thinking" or
  "tool: edit". /model inside the spawn editor pops the global model
  picker.
- Per-session scope: each spawn is stamped with the host session's id
  and only shows in that session's /swarm dashboard. Pre-upgrade agents
  -- empty session_id -- remain visible everywhere as a safety net. The
  active scope is re-applied whenever loadSession swaps sessions.
- Resolve falls back to the provider's default model when the persisted
  cfg.Model is no longer in the catalogue, warns on stderr, and rewrites
  config.json so the next launch is silent.
- ReadEventLog folds back-to-back same-type identical-payload events
  within 250ms so events.jsonl files polluted by the old supervisor +
  mirror double-write read back cleanly.
- DrawLog gains an idle no-op fast path: identical buffer plus identical
  cursor = emit nothing, so the terminal's cursor blink keeps ticking in
  dialogs whose underlying agent is idle.

Slash UX:

- New /swarm command with subcommands; the suggester picks it up.
- README.md documents the full dashboard, CLI, and persistence story,
  and explicitly notes that /session export does NOT bundle subagents
  -- their worktree and unix-socket inbox cannot round-trip through a
  .zotsession.

Tests cover: SpawnReq + Resume lifecycle, session-id scoping + persistence,
default-child-args spawn vs resume contract, NewSessionAtPath at a fixed
path, model fallback when the configured model is gone, swarm dialog
behaviour -- auto-open editor, /model in spawn editor, transcript grows
without internal scroll, busy spinner, multi-message send -- event-log
dedup, swarm emitter dormant-until-orphan, and the DrawLog idle no-op +
change-breaks-fast-path invariants.
2026-05-16 11:53:20 +02:00
patriceckhart
797041288d tui: strip ANSI from prompt before wrapping so cursor lands at end
When the interactive editor's Prompt carried ANSI styling — the
themed "▌ " glyph that interactive mode builds via
cfg.Theme.AccentBar — the raw escape bytes leaked into wrapLine's
per-rune width counter. Each byte of the SGR sequence (ESC, '[',
digits, ';', 'm') reported runewidth 1, so an 11-byte color escape
inflated the perceived prompt width by ~10 cells. wrapLine then
made wrap decisions against that inflated width, locateCursor
walked the inflated bodies, and Render() returned a cursor column
that landed inside the wrapped row instead of at its visible end.

The bug was intermittent because depending on the typed buffer's
length the geometry sometimes aligned by accident. Drag-and-dropping
a long screencaptureui temp path into VS Code's terminal reliably
triggered it, since the path stays inline (the temp file is already
gone by paste time so collapseOrQuoteFilePaths -> pathExists
returns false -> falls through to verbatim insert).

Fix: in Editor.Render, do all wrap and cursor math against a
plain-text prompt (ANSI stripped via stripANSI), then re-attach
the styled original to the very first wrapped row's leading
substring before returning. Continuation rows already use an
indent of spaces only, so they need no styling fixup. wrapLine
itself stays ANSI-unaware on purpose: the rest of the codebase
relies on its simple rune-based behaviour for plain text and
making it ANSI-aware would be a much bigger change with regression
risk elsewhere.

Adds editor_ansi_prompt_test.go which reproduces the exact captured
live scenario (the ANSI-themed prompt + the verbatim screencaptureui
path + ' hello' typed afterwards) and asserts the cursor lands at
the visible end of the last wrapped row.
2026-05-13 11:13:20 +02:00
patriceckhart
8b4b62f240 tui: suppress \x1b[3J scrollback-clear on VS Code's terminal
VS Code's integrated terminal (xterm.js) interprets the
erase-in-display-3 escape (\x1b[3J) as "drop scrollback rows AND
snap the viewport to the top of the remaining buffer." Once the
user has reopened a terminal with VS Code's persistent-sessions
feature on, there is real replayed scrollback above the live
cursor, so the snap is visible: the host scrollbar yanks to the
top on every full repaint — first paint, Ctrl+L (Renderer.Clear),
and any writeFull(true) shrink.

Every other terminal we tested (iTerm, Ghostty, Kitty, Alacritty,
Apple Terminal) treats \x1b[3J as "drop scrollback rows without
moving the viewport," which is what we want.

Detect VS Code (and Cursor, which shares xterm.js) via
$TERM_PROGRAM == "vscode" in NewRenderer and stash the result on
the Renderer as keepScrollback. Gate all three emission sites
(resize handler, Clear(), writeFull(true)) through a single
helper clearScrollbackSeq() that returns "" when keepScrollback
is true and SeqClearScrollback otherwise.

Trade-off on VS Code: stale zot frames remain visible if you
scroll up in the terminal's scrollback. Strictly less disruptive
than the scrollbar yanking on every Ctrl+L, and limited to the
one terminal that actually has the bug.
2026-05-13 10:37:48 +02:00
patriceckhart
f47996bc82 agent: add 'zot update' subcommand for in-place self-update
Adds a CLI subcommand that downloads the latest GitHub release for
the current GOOS/GOARCH, verifies its sha256 against checksums.txt,
extracts the archive, and atomically replaces the running binary.

  zot update           install the latest release
  zot update --check   show whether one is available, install nothing
  zot update --help    usage

Dispatch follows the same router shape as runBotCommand /
runExtCommand in cli.go. Asset naming stays in sync with the
archives.name_template in .goreleaser.yaml (zot_<ver>_<os>_<arch>).
Reuses fetchLatestRelease + versionLess from update.go so the
"what's latest" answer is identical to the in-TUI banner.

Refuses to operate on dev builds (version 0.0.0) since the version
comparison is meaningless and we'd happily downgrade a freshly
compiled local build back to whatever ships on GitHub. $GITHUB_TOKEN
is honoured so private-repo releases work.

Unix: atomic os.Rename in place (the kernel keeps the running
binary's inode alive until exit). Windows: rename current aside
to .old, drop the new exe in, leave the .old for next-update
cleanup since the running process has it locked.
2026-05-12 21:27:11 +02:00
patriceckhart
43da5e5249 tui: reset auto-follow baseline on new turn to stop viewport jump
startTurnWithImages clears the previous turn's tool-call overlay and
pins scrollOffset to 0. Without also resetting prevChatLen/prevChatCols,
the auto-follow guard on the next render sees a synthetic negative
delta equal to the number of overlay rows that were cleared, and
nudges scrollOffset by that amount. On terminals that mirror zot's
chat-pane scroll into their native scrollbar this is visible as a
viewport jump the instant the user presses enter on a follow-up
prompt.

Zero them out in the same locked block so the guard short-circuits
on the very next render, the same way it already does on column
resize. The legitimate "user scrolled up while content streams in"
case is unaffected because prevChatLen is repopulated on that first
post-submit render.
2026-05-12 20:43:43 +02:00
patriceckhart
1030ae584d Hide /jail when sandbox is already jailed
/jail and /unjail are mutually exclusive actions, so only show the
one that actually applies in the current state.
2026-05-11 18:11:18 +02:00