mirror of
https://github.com/patriceckhart/zot.git
synced 2026-06-27 13:56:33 +02:00
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.
|
||
|---|---|---|
| .. | ||
| base64.go | ||
| events.go | ||
| intercept_test.go | ||
| manager.go | ||
| manager_test.go | ||
| tool.go | ||
| tool_test.go | ||