cli

package
v0.20.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Overview

Package cli implements clawtool's user-facing subcommands.

Subcommand layout (ADR-004 §4):

clawtool init              interactive wizard: pick recipes, apply to repo
clawtool serve             run as MCP server (delegates to internal/server)
clawtool version           print version
clawtool help              print top-level usage
clawtool tools list        list known tools and resolved enabled state
clawtool tools enable <s>  set tools.<selector>.enabled = true
clawtool tools disable <s> set tools.<selector>.enabled = false
clawtool tools status <s>  print resolved state and the rule that won

Source / profile / group subcommands are scaffolded in main.go usage but not wired in v0.2 — they land alongside the source-instance feature.

Package cli — `clawtool doctor` is the one-command diagnostic. It surveys binary / agents / sources / recipes and prints a colour-coded checklist with suggested fix commands. Pure composition of existing internal helpers — no new deps.

Package cli — wizard-side install-prompt UX. Implements setup.Prompter (the abstraction the runner uses for missing prereqs) on top of huh + os/exec, plus the CommandRunner that actually shells out the per-platform install commands.

Kept in a separate file from init_wizard.go so the prompter + runner pair can be swapped or wrapped (e.g. by a dry-run wrapper) without touching the rest of the wizard. Test files inject a recordingRunner and a scriptedPrompter against the same interfaces — the wizard surface stays huh-bound, but every install decision is exercised in unit tests.

Package cli — `clawtool init` wizard. Two-scope welcome screen: repo (recipes) and user-global (agents + sources + secrets), with "both" and a read-only "show me what's available" preview path.

Honors --yes for non-interactive runs and falls back to the same path when stdin/stdout aren't TTYs (CI / containers).

Package cli — `clawtool mcp` subcommand surface (ADR-019).

v0.17 fills in `new`, `list`, `run`, `build`, `install`. The `new` verb runs the huh.Form wizard implemented in mcp_wizard.go; `install` lives in mcp_install.go; this file keeps the dispatcher + the read-only `list` walker.

Package cli — `clawtool mcp install` (ADR-019).

Reads `.clawtool/mcp.toml` from the project at <path>, derives the launch command from the project's language + transport, writes a [sources.<name>] block into ~/.config/clawtool/config.toml. Same surface as `clawtool source add` for catalog entries — just auto-discovers the command instead of asking.

Package cli — `clawtool mcp new` interactive wizard (ADR-019).

huh.Form sequence collects the operator's spec, hands it to internal/mcpgen which renders + writes the project. Tests substitute mcpgenDeps to drive the wizard without hitting disk.

Package cli — `clawtool` (no args) launches a friendly TUI landing menu that points at the most-used flows. Designed for users who'd rather not memorise subcommands; pure huh.Select.

Package cli — `clawtool portal` subcommand surface (ADR-018).

Read-only + persistence operations land in v0.16.1. The interactive `ask` flow that drives Obscura over CDP arrives in v0.16.2; today it returns a clear "deferred" error so the surface is discoverable before the engine ships.

Package cli — `clawtool portal add` interactive wizard (ADR-018, v0.16.3).

Rebuilt on top of the chromedp-backed BrowserSession (ADR-007). Spawns the user's installed Chrome with --headless=false + a temp profile, waits for them to log in (optionally with a copy/paste prompt for the Claude in Chrome side-panel), pulls cookies via Network.getAllCookies, collects the three CSS selectors + a "response done" predicate template, and writes config.toml + secrets.toml.

Per ADR-017 we never wrap claude-in-chrome — the wizard generates a plain-text prompt the operator can paste. clawtool stays MCP-server-free for the wizard transport.

Package cli — `clawtool sandbox` subcommand surface (ADR-020).

v0.18 ships read-only verbs (list / show / doctor) plus the surface stub for `run`. The dispatch-time integration (`clawtool send --sandbox <profile>`) lands v0.18.1+ alongside the per-OS engine implementations.

Package cli — `clawtool skill` subcommand. Scaffolds and lists Agent Skills per the agentskills.io spec: a folder containing SKILL.md (required, with frontmatter name + description) plus optional scripts/, references/, assets/ subdirectories.

The standard was authored by Anthropic and is now open. clawtool's skill subcommand is the bootstrap layer — `clawtool skill new` is the analogue of `npm init` for Agent Skills.

Package cli — `clawtool unattended` subcommand. Operator-facing trust management for ADR-023's --unattended dispatch mode.

Two surfaces:

clawtool unattended status [<repo>]    show whether <repo> (or cwd) is trusted
clawtool unattended grant  [<repo>]    explicitly trust <repo> for unattended dispatch
clawtool unattended revoke [<repo>]    remove the trust grant
clawtool unattended list               list every granted repo
clawtool unattended path                print the trust file location

`clawtool yolo` is a deliberately-jokey alias so operators searching docs / muscle-memory the Cline term find it.

Package cli — `clawtool uninstall` removes every artifact clawtool drops on the host. Designed for the tester / dogfooder who installs the binary fresh ten times a day and ends up with duplicate sources / portals / sticky defaults.

The cleanup is intentionally exhaustive — config + secrets + caches + data dirs + sticky pointers + worktrees + BIAM SQLite + telemetry id. The binary itself is opt-in (--purge-binary) because the user may have installed via Homebrew / curl / Go and the right removal command differs by source.

Per ADR-007 doesn't apply here: this is "rm -rf clawtool's own files", which is by definition not delegable to an upstream. We still rely on stdlib os.RemoveAll for the actual removal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App struct {
	Stdout io.Writer
	Stderr io.Writer
	Stdin  io.Reader
	// ConfigPath overrides the default config location. Empty = config.DefaultPath().
	ConfigPath string
	// contains filtered or unexported fields
}

App holds CLI dependencies. Stdout/stderr are injected so tests can capture.

func New

func New() *App

New returns an App writing to the process's stdout/stderr and using the default config path.

func (*App) AgentUnset added in v0.20.0

func (a *App) AgentUnset() error

AgentUnset clears the sticky default file. Idempotent.

func (*App) AgentUse added in v0.20.0

func (a *App) AgentUse(instance string) error

AgentUse persists the sticky default. We validate the instance exists in the supervisor's registry up front so the user gets a clean error here rather than at the next `clawtool send`.

func (*App) AgentWhich added in v0.20.0

func (a *App) AgentWhich() error

AgentWhich resolves the empty selector and prints the result. Same precedence chain Send uses, exposed read-only for the user to inspect what would happen.

func (*App) BridgeAdd added in v0.20.0

func (a *App) BridgeAdd(family string) error

BridgeAdd resolves the family to its recipe and applies it. Idempotent; if the bridge is already installed Detect returns Applied and Apply short-circuits.

func (*App) BridgeList added in v0.20.0

func (a *App) BridgeList() error

BridgeList prints all known bridge recipes with their Detect state.

func (*App) BridgeRemove added in v0.20.0

func (a *App) BridgeRemove(family string) error

BridgeRemove is a placeholder. Claude Code's `claude plugin remove` surface isn't standardized yet across plugin types; v0.10.x will add proper uninstall semantics. For now we print a manual hint.

func (*App) HooksList added in v0.20.0

func (a *App) HooksList() error

HooksList prints every configured event with its entry count. Empty config → friendly hint.

func (*App) HooksShow added in v0.20.0

func (a *App) HooksShow(event string) error

HooksShow dumps the per-entry config for a single event.

func (*App) HooksTest added in v0.20.0

func (a *App) HooksTest(event string, payload map[string]any) error

HooksTest synthesises the event with the given payload and runs every configured entry. Prints per-entry success/failure so the operator can iterate on hook scripts without firing the real lifecycle event (which might be hard to reproduce).

func (*App) Init

func (a *App) Init() error

Init writes a default config to disk if the file does not already exist. Returns an "already exists" error if it does — callers can ignore that.

func (*App) McpList added in v0.20.0

func (a *App) McpList(argv []string) error

McpList walks `root` (default cwd) for `.clawtool/mcp.toml` markers and prints one line per project. Skips node_modules / vendor / .git so a recursive walk doesn't melt on a typical repo.

func (*App) Path

func (a *App) Path() string

Path returns the resolved config path (override > default).

func (*App) PortalAdd added in v0.20.0

func (a *App) PortalAdd(name string) error

PortalAdd opens $EDITOR with a TOML template for the named portal. On save we validate the parsed stanza and append it to config.toml. The validation refuses anything that wouldn't drive an Ask flow successfully, so a fat-finger landing in config never reaches the dispatch path.

func (*App) PortalAsk added in v0.20.0

func (a *App) PortalAsk(argv []string) error

PortalAsk is the deferred-feature placeholder. Validates the resolved portal so the operator gets the same diagnostics they will get in v0.16.2, then surfaces the deferred error.

func (*App) PortalList added in v0.20.0

func (a *App) PortalList() error

PortalList prints the configured portals one per line — same shape as `clawtool send --list` so the operator sees both surfaces consistently.

func (*App) PortalRemove added in v0.20.0

func (a *App) PortalRemove(name string) error

PortalRemove rewrites config.toml without the [portals.<name>] stanza. Cookies in secrets.toml are left in place so a temporary remove-then-re-add doesn't lose the export. Operators clean secrets manually when they want a true uninstall.

func (*App) PortalUnset added in v0.20.0

func (a *App) PortalUnset() error

PortalUnset removes the sticky-default file. Idempotent.

func (*App) PortalUse added in v0.20.0

func (a *App) PortalUse(name string) error

PortalUse persists the sticky default for `clawtool portal ask`.

func (*App) PortalWhich added in v0.20.0

func (a *App) PortalWhich() error

PortalWhich resolves the sticky-default portal. Same precedence chain as the agent sticky default (env > sticky file > single- configured fallback).

func (*App) RecipeApply added in v0.9.0

func (a *App) RecipeApply(name string, kvs []string) error

RecipeApply runs the recipe against the current working directory. Options are key=value strings; comma-separated values become []string. v0.9 keeps options simple — wizard / MCP path will pass richer types as the surface evolves.

func (*App) RecipeList added in v0.9.0

func (a *App) RecipeList(category string) error

RecipeList prints every registered recipe grouped by category with its Detect state in the cwd.

func (*App) RecipeStatus added in v0.9.0

func (a *App) RecipeStatus(name string) error

RecipeStatus prints the Detect output for one recipe or all recipes.

func (*App) Run

func (a *App) Run(argv []string) int

Run dispatches argv (excluding program name) to the right subcommand. Returns the exit code; 0 = success, 2 = usage error, 1 = runtime failure.

func (*App) SandboxDoctor added in v0.20.0

func (a *App) SandboxDoctor() error

SandboxDoctor reports every registered engine's availability.

func (*App) SandboxList added in v0.20.0

func (a *App) SandboxList() error

SandboxList prints every configured profile + the engine that would run it on this host.

func (*App) SandboxShow added in v0.20.0

func (a *App) SandboxShow(name string) error

SandboxShow parses one profile + prints the resolved view.

func (*App) SecretsPath

func (a *App) SecretsPath() string

SecretsPath returns the secrets-store path. Tests can shadow App.SecretsPath to point at a tmp file; production uses secrets.DefaultPath().

func (*App) Send added in v0.20.0

func (a *App) Send(args sendArgs) error

Send routes through Supervisor.Send and streams stdout.

func (*App) SendList added in v0.20.0

func (a *App) SendList() error

SendList prints the supervisor's agent registry — same shape as the MCP `AgentList` response and the HTTP `GET /v1/agents` body.

func (*App) SetSecretsPath

func (a *App) SetSecretsPath(p string)

SetSecretsPath lets tests redirect the secrets store to a tmp file.

func (*App) TaskGet added in v0.20.0

func (a *App) TaskGet(taskID string) error

TaskGet prints the task row + every message envelope for the task, JSON-formatted so a script can parse it.

func (*App) TaskList added in v0.20.0

func (a *App) TaskList(limit int) error

TaskList prints the recent BIAM task summary.

func (*App) TaskWait added in v0.20.0

func (a *App) TaskWait(taskID string, timeout time.Duration) error

TaskWait blocks until the task is terminal, then dumps the same shape TaskGet does.

func (*App) ToolsDisable

func (a *App) ToolsDisable(selector string) error

ToolsDisable writes tools.<selector>.enabled = false.

func (*App) ToolsEnable

func (a *App) ToolsEnable(selector string) error

ToolsEnable writes tools.<selector>.enabled = true.

func (*App) ToolsList

func (a *App) ToolsList() error

ToolsList prints registered core tools and their resolved enabled state.

func (*App) ToolsStatus

func (a *App) ToolsStatus(selector string) error

ToolsStatus prints the resolved enabled state for a selector and the rule that won, per ADR-004 §4.

func (*App) Uninstall added in v0.20.0

func (a *App) Uninstall(args uninstallArgs) error

Uninstall performs the cleanup. Public so the MCP tool surface + integration tests can call it without going through argv.

func (*App) WorktreeGC added in v0.20.0

func (a *App) WorktreeGC(minAge time.Duration) error

WorktreeGC reaps orphans (dead PID + minAge cutoff).

func (*App) WorktreeList added in v0.20.0

func (a *App) WorktreeList() error

WorktreeList prints every worktree under ~/.cache/clawtool/worktrees with its marker info. Useful before running gc to see what's reapable.

func (*App) WorktreeShow added in v0.20.0

func (a *App) WorktreeShow(taskID string) error

WorktreeShow dumps the marker JSON for one worktree.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL