feat(plugin): add /kbagent:setup one-command first-run setup - #625
feat(plugin): add /kbagent:setup one-command first-run setup#625claude[bot] wants to merge 2 commits into
Conversation
Collapse the documented five-step onboarding (install CLI -> project add with a hand-pasted Storage API token -> doctor -> two /plugin commands) into one slash command that runs after the plugin is installed. plugins/kbagent/commands/setup.md orchestrates existing verbs only -- `--json version` (respecting `install_channel` on standalone builds), `--json project list` (skip if already connected, never overwrite an alias), `--json auth login --register-projects` (browser PKCE, so no token to paste; relays `session_unsupported_features` from the result rather than hand-listing it) with a `project add` hidden-prompt / KBC_TOKEN fallback for headless hosts, then `--json doctor` interpreted for the user including the claude_plugin check. Every step is conditional on a check, so the command is idempotent. No new CLI surface, no change to `doctor` (its --fix removal in 0.85.0 stands), no token ever printed or passed on a command line. Doc sync for the new surface (none of these are CI-checked): plugin .claude-plugin/CLAUDE.md surfaces list and "For Claude Code users"; skills/kbagent/SKILL.md prose "First-time setup" (auto-generated table untouched); README.md and docs/TUTORIAL.md so the documented flow is install plugin -> /kbagent:setup; install.sh "Next steps"; AGENT_CONTEXT in commands/context.py. Also corrects the already-stale plugin surface inventory in CLAUDE.md and widens the CONTRIBUTING.md sync-map row from commands/keboola.md to commands/*.md with the follow-through list for adding a new slash-command file.
The next-steps hint hardcoded the Claude Code marketplace and plugin names (`keboola/cli` / `kbagent@keboola-agent-cli`). #627 moves the marketplace listing to keboola/ai-kit and does not touch install.sh, so the hardcoded pair would merge silently and then advertise deprecated names. Point at `kbagent doctor` instead, which already prints the current `/plugin` commands and is updated by #627 -- correct under either merge order.
|
Merge-order note vs #627 (which moves the plugin's marketplace listing to This PR overlaps #627 in As of this push, Generated by Claude Code |
Requested by David Esner · Slack thread
Before / After
Today, a new user follows five separate steps across two different places, in the right order, from the docs at keboola.com/cli: generate a Storage API token in the UI → open Claude Code → run the
curl … install.sh | shone-liner in a terminal →kbagent project add --project X --url Y --token …→kbagent doctor→ back in Claude Code,/plugin marketplace add keboola/cliand/plugin install kbagent@keboola-agent-cli. Nothing in the repo chains those;kbagent doctordetects the missing plugin but deliberately does not fix it.After this PR, the documented flow is: install the plugin, then run one command.
/kbagent:setupdoes the rest — and there is no token to generate or paste on the default path.What it does
Adds one new plugin slash command,
/kbagent:setup, that runs first-time setup end to end — install the CLI if missing, connect a project, verify — with every step conditional on a check, so it is idempotent and safe to re-run on a half-finished setup.How
plugins/kbagent/commands/setup.mdis markdown instructions for the agent, in the same shape as the existingkeboola.md/review.md(same frontmatter keys,## Behaviornumbered steps,## Examples, a closing rationale section). It orchestrates existing, already-tested verbs — no new CLI surface, no new code path:kbagent --json version→ if the CLI is absent, run this repo's owninstall.sh, handling the installer's documented PATH caveat (kbagentis onPATHfor the installer's own process only;source $HOME/.local/bin/envor a new shell). Ifkbagent.install_channelis present, that is a standalone/packaged build — the command respects it and points atupgrade_command/upgrade_hintinstead of installing a second kbagent over the top.kbagent --json project list→ if a project is already connected, name the aliases and skip to verification. Never re-registers or overwrites an existing project or alias.kbagent --json auth login --register-projects— browser PKCE with the automatic device-code fallback, so nothing to paste. It readssession_unsupported_featuresoff the result (canonical list:SESSION_UNSUPPORTED_FEATURESinservices/_auth_registration.py) and relays it rather than hand-listing it, and falls back tokbagent --json project add --project '<ALIAS>' --url <STACK_URL>when the user needs one of those surfaces or there is no browser (headless, container, CI). The fallback never passes--tokenon a command line: eitherKBC_TOKENis already in the environment, or the command is handed to the user to run in their own terminal, becauseproject add's hidden token prompt needs a real TTY that a tool-run shell does not have.kbagent --json doctor, interpreted for the user — including theclaude_plugincheck (pass/ version drift →/plugin update kbagent;warn→ print the two/pluginlines;skip→ Claude Code not detected).The body encodes the rules explicitly: never print or persist a token,
--jsonfor anything parsed, don't re-run a step that already passes, and when a step genuinely needs a human (browser login), say so plainly instead of guessing.Flag placement was verified against the live CLI —
--jsonis a root-callback option, so it goes before the subcommand (kbagent --json project list, notproject list --json). All four invocations in the file were run locally.Doc sync (CLAUDE.md convention #17 / CONTRIBUTING.md "Plugin synchronization map")
None of these have a CI freshness check, so they are the silent-failure surfaces for this change:
plugins/kbagent/.claude-plugin/CLAUDE.md— surfaces list (two slash commands → three) and the "For Claude Code users" block now leads with/kbagent:setup.plugins/kbagent/skills/kbagent/SKILL.md— the prose "First-time setup" section points at/kbagent:setupas the one-command path, keeps the manual sequence below it for a plain shell or another agent, and swaps its staleuv tool install git+…line for theinstall.shone-liner plus the PATH caveat. The CI-checked auto-generated decision table was not touched (make skill-checkregenerates it clean).README.md— the Claude Code plugin block is now the two/pluginlines plus/kbagent:setup.docs/TUTORIAL.md— §5 install flow and the "What the plugin ships" component table.install.sh— the printed "Next steps" now leads with/kbagent:setupfor Claude Code users and keeps every existing explicit command under "Or do it by hand", so nothing regresses for people not in Claude Code.src/keboola_agent_cli/commands/context.py(AGENT_CONTEXT) — the "Claude Code Plugin" section, since this is the primary reference agents load at session start.CLAUDE.md— the plugin structure tree and surfaces sentence were already stale (still claimed one slash command and one subagent); corrected while addingsetup.md.CONTRIBUTING.md— the sync-map row forplugins/kbagent/commands/keboola.mdwas stale for the same reason. Widened tocommands/*.mdand given the explicit follow-through list for adding a new slash-command file, which the map has never had (/kbagent:reviewwas added without it).No changelog entry:
pyproject.toml's version is unchanged, and CONTRIBUTING defines a release as a version bump. No new tests: per CONTRIBUTING, the mandatory test checklist is scoped to new CLI commands (service / CLI / E2E layers), and no CI gate or test readsplugins/kbagent/commands/*.mdat all —tests/test_skill_frontmatter.pytargetsskills/kbagent/SKILL.mdexclusively. Nothing enumerates plugin command files, so there was no such test to extend. Flagging that gap rather than papering over it.Checks run
make lint(ruff check src/ tests/ scripts/)make format-check(ruff format . --check)make skill-checkSKILL.mdbyte-identical)make version-checkmake command-sync-checkmake check-error-codesmake check-sentinel-guardsmake loc-checkmake typecheck(ty)make testtests/test_config_store.py::TestPermissionDenied::{test_save_to_readonly_directory,test_load_unreadable_config_file}. Both are environmental and pre-existing: the sandbox runs as uid 0, sochmod 0o000does not deny root and the expectedConfigErrornever raises. Verified identical onmainatd8f7a7bwith this branch's changes absent. This diff touches no config-store code.bash -n install.shkbagent --json version/project list/doctormake test-e2eE2E_API_TOKEN+E2E_URLagainst a real project; no CLI behavior changedmake changelog-checkghbinary, which is absent from this environment. It is local/release-time only and is deliberately not part of CI's per-PRcheckjob.Not in this PR
kbagent setupPython CLI subcommand for agents that are not Claude Code. That is a larger change with real CI follow-through (permissions.pyOPERATION_REGISTRY,commands/context.py,commands-reference.md,CLAUDE.md## All CLI Commands,generate_skill.pySKIP_COMMANDS, plus service/CLI/E2E tests, all gated byscripts/check_command_sync.py) and deserves its own review. A slash command also has a chicken-and-egg limit worth naming: it only helps someone who already installed the plugin, so it cannot cover the/pluginstep for the person who most needs it — it can only detect and explain it.doctorwas not changed to auto-fix anything.doctor --fixwas deliberately removed in 0.85.0; reopening that is out of scope here.Open question for reviewers
The repo's own auth guidance forks, and this command had to pick a side.
plugins/kbagent/.claude-plugin/CLAUDE.md:93-100says a static Storage token is not automatically the answer for an unattended context, and preferskbagent auth login-password(0.84.0+) when account credentials exist.plugins/kbagent/agents/keboola-expert.md:74says the opposite: refuse session auth and point atproject add --token./kbagent:setupcurrently prefers browserauth login --register-projectswith aproject add(hidden-prompt /KBC_TOKEN) fallback — chosen because the product goal is explicitly "no token to paste", and becauselogin-passwordneeds email + password + TOTP that a first-time user is unlikely to have staged. But that is a third position, not a reconciliation. Two things reviewers should decide:auth login-passwordoverproject addwhenKBC_LOGIN_EMAIL/KBC_LOGIN_PASSWORD/KBC_LOGIN_TOTP_SECRETare present in the environment?keboola-expert.md:74and.claude-plugin/CLAUDE.md:93-100should be brought into agreement — they currently give an agent contradictory instructions, independent of this PR. I did not touch either, since picking a winner is a product call andkeboola-expert.mdis the highest silent-drift-risk file in the repo.Generated by Claude Code