Add CLI and deeplinks for running arbitrary user-defined scripts (#253)
* Add runScript/stopScript deeplinks for named scripts
Introduces sub-path deeplinks that target a specific user-defined
script by UUID, so CLI tooling and share URLs can run or stop
scripts other than the primary .run-kind one.
- Add .runScript(scriptID:) and .stopScript(scriptID:) cases to
Deeplink.WorktreeAction and a parseWorktreeScript helper that
matches worktree/<id>/script/<uuid>/run|stop.
- Route the new actions in worktreeActionEffect through existing
runNamedScript / stopScript reducer paths. Unknown script UUIDs
surface an alert rather than silently dropping.
- Reuse requiresInputConfirmation for URL-scheme run requests so
script commands display in the confirmation sheet under the
existing automatedActionPolicy gate. Stop requests are not
gated, matching the bare .stop behaviour.
- Extend parser and reducer test suites covering happy paths,
unknown UUIDs, missing verb, and policy bypass.
* Add CLI and socket query for named script run/stop
Wires the earlier runScript/stopScript deeplinks to actual CLI
tooling and adds the socket query needed to discover script UUIDs.
- Add "scripts" socket query resource keyed on worktreeID that
returns each ScriptDefinition as id / kind / name / displayName
plus a running marker derived from runningScriptsByWorktreeID.
- Extend `supacode worktree run` and `stop` with `--script/-s`
so callers can target a specific script by UUID while the
zero-argument form keeps firing the bare run / stop deeplinks
for backward compatibility.
- Introduce `supacode worktree script list` (via a sibling
WorktreeScriptCommand to satisfy SwiftLint nesting) that prints
tab-separated id / kind / displayName rows and underlines any
currently running script.
- Validate `--script` arguments as UUIDs at the CLI layer so a
typo surfaces a helpful error instead of a generic deeplink
parse failure.
* Harden named-script deeplinks and document new CLI surface
Review follow-ups covering cross-worktree correctness, silent
success paths, the `-s` flag collision, and in-app docs.
- Resolve the target script directly from the worktree's
@SharedReader RepositorySettings in runScript/stopScript
deeplink handlers so cross-worktree CLI calls no longer miss
a freshly loaded selection's scripts.
- Validate empty command, already-running, and not-running
cases inline in the deeplink effects and surface them as
alerts. Previously these hit silent `.none` guards in
runNamedScript / stopScript and misled the CLI into ok:true.
- Normalize trailing slashes in the `scripts` socket query so
`supacode worktree script list -w <path>` matches worktree
IDs with or without a trailing slash, matching resolveWorktreeID.
- Rename the CLI short flag from `-s` to `-c` under `worktree
run`/`stop` so it stops colliding with `-s` = `--surface`
across the rest of the CLI. Long form `--script` is unchanged.
- Update CLIReferenceView, DeeplinkReferenceView, and the
supacode-cli skill content with the new subcommand, option,
and deeplink URLs.
- Extend the test suite with confirm-accepted round trip,
socket-source responseFD storage, empty command, already
running, and not-running-stop cases, and rewrite the existing
script deeplink tests to seed scripts via @Shared repository
settings now that the reducer reads them from there.
* Surface an alert when the target worktree vanishes mid-flight
Phase 3 verification caught a narrow but real silent-success
path in the script deeplink effects: if the target worktree is
removed between the initial `handleWorktreeDeeplink` check and
the confirmation-accept re-dispatch, both runScript and
stopScript handlers would return `.none` without setting an
alert, so the outer response flow would report `ok:true` to the
CLI even though nothing ran.
- Set a "Worktree not found" alert in the worktree-missing guard
of both runScriptDeeplinkEffect and stopScriptDeeplinkEffect
so the alert-diff check drives the socket response to ok:false.
- Extract a shared worktreeNotFoundAlert helper.
- Add stopScriptSocketDeeplinkSendsErrorWhenNotRunning as a
regression guard exercising the socket responseFD path for
stop failures, which had no coverage.
* Polish named-script CLI: DRY alert, sanitize list output, skill doc
Final polish pass after Phase 3 self-review.
- Collapse the inline "Worktree not found" AlertState block in
handleWorktreeDeeplink into the worktreeNotFoundAlert helper
introduced for the script deeplink effects.
- Sanitize tab, newline, and carriage return characters in the
`worktree script list` output so a script name containing
those characters cannot corrupt the tab-separated columns
when the output is piped into xargs/cut/awk.
- Expand CLISkillContent's shared/codex sections to document
the new `worktree script list` subcommand, the `-c`
`--script` flag, and the tab-separated list output format
so agents reading the skill pick up the new surface.
authored by