feat(run): persistent agent identity via the agent config key and ONECLI_AGENT - #106
Merged
Conversation
…CLI_AGENT `onecli run` gains a machine-local agent pin: the agent identity now resolves as --agent flag > ONECLI_AGENT env > `onecli config set agent <identifier>`, falling back to the project's server-side default agent when none is set. Config keys grow `agent` (validated with the same input hardening as the --agent flag); `config get agent` respects the full precedence chain like `project` does. Also fixes help drift: `onecli help` now lists run's --enforce flag and names the valid config keys on config get/set. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
onecli rungains a persistent, machine-local agent identity. The agent resolves as:--agent <identifier>flag (unchanged)ONECLI_AGENTenvironment variable (new)onecli config set agent <identifier>(new config key)agentjoinsapi-hostandprojectas a config key, with the same input hardening the--agentflag already applies (pkg/validate.ResourceID) — on the flag, the env value, and atconfig settime.config get agentrespects the full precedence chain, exactly likeproject.onecli helpnow listsrun's--enforceflag (it was missing), andconfig get/config setname the valid keys.ONECLI_PROJECT/ newONECLI_AGENTenv vars.Why
The dashboard's Install page can pin a machine to a specific agent (onecli-cloud#747). Until now that persistence had nowhere to live:
--agenthad to be retyped on every run, and the old install script'sconfig set default-agentline targeted a key that never existed — it failed silently. This PR gives the pin a real home; the new install script callsonecli config set agent "$AGENT"and prints a loud fallback (onecli run --agent … -- <command>) on older CLI versions.Release order: this should release before the onecli-cloud#747 deploy; onecli/onecli-docs#12 merges last so the script's pin line works from day one (the fallback covers any skew).
Verification
go build ./...,go test ./...,go test -race ./...all green;golangci-lint run— 0 issues;gofmt -lclean; the hand-maintained help lockstep test passes.config set, and the fullresolveAgentmatrix (flag > env > config file > empty; hardened-input rejection on flag and env).$HOME: the install script's exact pin line fails on 2.9.0 with{"error":"unknown config key: agent"}(the script's loud-fallback branch) and succeeds on this build; round-trip, env precedence, and invalid rejection all verified through the real binary; all output JSON.Review
Self-review (hunk-by-hunk) + this repo's own skills walked in full:
agent-first-cli(JSON-only stdout, boundary hardening on all three input paths, self-documenting help — clean),golang-patterns(mirrors the existingresolveProjectidiom exactly;%wwrapping; documented exports — clean),golang-pro(MUST-list incl.-race, table-driven rejection tests — clean), plus a cross-repo contract check against the cloud PR (key name, env var, precedence, wire param — identical). Findings: none beyond implementation.🤖 Generated with Claude Code