zot/internal/agent/extensions
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
..
base64.go feat(extensions): phase 2 — extension-defined tools 2026-04-19 14:46:32 +02:00
events.go feat(ext): phase 4 - full-event interception, arg rewrites, /reload-ext 2026-04-19 17:02:04 +02:00
intercept_test.go feat(ext): phase 4 - full-event interception, arg rewrites, /reload-ext 2026-04-19 17:02:04 +02:00
manager.go feat: runtime cwd switching via hidden /cd and extension submit_slash 2026-05-19 19:38:47 +02:00
manager_test.go feat: runtime cwd switching via hidden /cd and extension submit_slash 2026-05-19 19:38:47 +02:00
tool.go feat(extensions): phase 2 — extension-defined tools 2026-04-19 14:46:32 +02:00
tool_test.go feat(extensions): phase 2 — extension-defined tools 2026-04-19 14:46:32 +02:00