Repository navigation
feat: Let coding agents sign in and install every plugin - #358
Conversation
Coding agents run datumctl without a terminal. Two things stopped them from setting it up on their own. datumctl login showed an org/project picker after the browser sign-in. Without a terminal the picker failed for anyone with more than one project, and login returned before saving the session, so the sign-in was lost. Login now honours --project, --organization, DATUM_PROJECT and DATUM_ORGANIZATION to choose the context without the picker. With none of them and no terminal, it saves the session, leaves the context unset and says how to pick one. A current context from another session is cleared so the new session becomes active. Installing every plugin meant parsing the search table and calling install once per name. plugin install --all-available installs every plugin in the official datum catalog (or --index), upgrades ones that are behind, and skips same-name plugins from another source. plugin search gains -o json and -o name for scripts.
ecv
left a comment
There was a problem hiding this comment.
Approve.
Login only changes how a context is chosen; the OAuth/device flow, token storage and output are untouched, so credential handling is not weakened. --all-available loops the existing installPlugin, so every plugin still gets the index SHA256 archive check and the compatibility check, with no new trust path.
- Login: no token is printed or written differently.
saveWithoutContextsaves the same config viaSaveV1Beta1and returns nil on the no-terminal path, so an agent run exits 0 with a signed-in session but no context. Scripts that assume exit 0 means "ready to run commands" will fail on the next call, not at login; the printed hint covers it. - Login:
clearOtherSessionContextunsets the current context when it belongs to a different session. That is deliberate and tested (TestClearOtherSessionContext), but it is a visible behaviour change for anyone signing a second account in, so it deserves a line in the docs. - Install-all:
--index acmeinstalls every plugin from a third-party catalog in one go with no trust warning or confirmation. Singleinstall <catalog>/<plugin>has the same shape, so this is parity, but the blast radius is larger. Archives are still SHA256-pinned by the index, so a compromised catalog is trusted wholesale. - Install-all: partial failure is handled (continue, list failures, exit non-zero, manifest saved only if something installed). However
installPluginwrites each binary before the manifest is saved at the end, so a crash or a failedSavemid-run leaves binaries on disk with no manifest entry. Saving after each successful plugin would close that. - Plugins already installed from another catalog or GitHub are skipped rather than replaced, which avoids a name-shadowing takeover via
--all-available. Good, and covered byTestPlanCatalogInstall. - Tests cover the planner, flag errors, empty catalog, up-to-date no-download,
chooseContext,requestedContextand search output formats. No test drives a real mixed success/failure install loop or the manifest save.
Follow-ups:
- Warn, or require
--yes, before--all-availableagainst a non-official catalog. - Save the manifest per plugin rather than once at the end.
plugin install --all-available --index <catalog> installs every plugin in that catalog, so with a third-party catalog it now lists the plugins it would install and asks to confirm first, as plugin index add does. --yes skips the prompt. With no terminal and no --yes it exits with an error instead of installing anything. The official datum catalog, and a catalog with nothing to install, never prompt.
Rely on datum-cloud/datumctl#358: - Install plugins with `datumctl plugin install --all-available` instead of parsing `plugin search` output and installing one at a time. - Run `datumctl login --project <org>/<project>` from the agent, so the user only approves the sign-in in their browser. Without a project, login signs in and the agent picks the context with `ctx use`. - Always upgrade an existing datumctl, and fall back to the old flow when a flag is missing.
ecv
left a comment
There was a problem hiding this comment.
Approve.
The new commit closes my earlier follow-up: --all-available against a third-party catalog now lists the plan and asks y/N, fails with a hint when no one can answer (script, CI, agent shell), and installs nothing on "no". The official catalog path and single installs are unchanged, and --yes without --all-available is rejected.
Follow-ups:
- Saving the manifest once at the end, rather than per plugin, is still open from the earlier review.
Summary
Coding agents run
datumctlwithout a terminal. These changes let an agent set updatumctlfor a user without asking them to type commands. They come from the agent setup prompt in datum-cloud/agents.datum.net#122, which currently has to work around both problems.datumctl loginBefore: after the browser sign-in, login showed an org/project picker. Without a terminal the picker failed for anyone with more than one project, and login returned before saving the session, so the sign-in was lost.
Now:
--project,--organization,DATUM_PROJECTorDATUM_ORGANIZATIONpicks the context without the picker.--projectalso accepts<org>/<project>. These are the existing global flags; login just never read them.datumctl ctx use <org>/<project>, and exits 0.datumctl plugin install --all-available [--index <catalog>]datumcatalog, or the catalog named by--index.datum, it lists the plugins it would install and asks[y/N], asplugin index adddoes.--yesskips the prompt. With no terminal and no--yesit exits with an error and installs nothing. The official catalog, and a catalog with nothing to install, never prompt.--indexwithout--all-availableis an error that points to<catalog>/<plugin>. A plugin name with--all-availableis also an error.datumctl plugin search -o json|name-o jsonprints an array of{name, index, version, trust, description}. It prints[]when nothing matches.-o nameprints one plugin name per line.Docs
README,
docs/authentication.md(new "Choosing a context" section) anddocs/developer/plugins.md.Test plan
go test ./...,go vet ./...andgofmtpass.org/project, org only, unknown, an ambiguous display name, no terminal, a single context), reading flags vs env vars, and clearing another account's context;--all-availablewith everything up to date and with an empty catalog, the flag errors, andsearch -o json|name|xml.--yes),n(aborts),yand--yes(go ahead), the official catalog and an up-to-date third-party catalog (no prompt), and--yeswithout--all-available(error).plugin search --index datum -o name|jsonlisted all 9 plugins,plugin install --all-availableinstalled all 9, and a second run reported them up to date.datumctl login --project <org>/<project> < /dev/null, and with no scope and no terminal.