fix: Accept --session on plugin commands - #305
Merged
scotwells merged 1 commit intoOct 1, 2026
Merged
Conversation
"datumctl <plugin> <subcmd> --session X" failed with the plugin's own "unknown flag: --session", because only a --session placed before the plugin name was consumed by datumctl; anywhere else it was forwarded as one of the plugin's arguments. That pointed users at the wrong component and pushed them toward switching their active session instead, which is exactly what the flag exists to avoid. datumctl now takes --session out of a plugin command line wherever it appears and turns it into the DATUM_SESSION (and API host) the plugin already understands. Arguments after a bare "--" still belong to the plugin. The flag continues to beat DATUM_SESSION, and --session with no value now fails with datumctl's own message rather than quietly running as the active session. Fixes #304 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
drewr
approved these changes
Sep 29, 2026
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.
Fixes #304
datumctl assistant card --session swells@datum.net@api.datum.netfailed withpatch: unknown flag: --session. Only a--sessionplaced before the plugin name was consumed by datumctl; put anywhere else it was forwarded to the plugin as one of its own arguments. The error named the plugin rather than datumctl, and the workaround was to switch the active session — the thing the flag exists to avoid.You can now put
--sessionwhere you'd naturally put it:datumctl takes the flag out of the command line wherever it appears and turns it into the
DATUM_SESSIONand API host the plugin already understands. Arguments after a bare--are still the plugin's to interpret. The same handling now applies to a plugin's shell completion and--help.Also:
--sessionwith no value fails with datumctl's own "needs a session name" message instead of clearing the override and quietly running as the active session.Precedence
--sessionbeatsDATUM_SESSION, unchanged from the root command and from what the flag's own help says. A bad--sessionvalue fails immediately;DATUM_SESSIONis still resolved lazily, so a stale export only breaks commands that actually need a session.Scope
Narrowed deliberately to
--session. The other global flags a plugin doesn't parse are not in the same class: plugins define their own--project,--organd-o(the assistant plugin does), so consuming those at the datumctl layer would break them.--sessionis the one flag datumctl owns end to end and no plugin defines.Base
Stacked on #303 (
feat/302-session-override), which introduces the global--sessionflag. There is nothing to fix onmain— the flag doesn't exist there yet. Retarget tomainonce #303 lands.Verified
go build ./...,go vet ./...,go test ./...clean.internal/plugindispatch/session_override_test.gocover the flag after the plugin name,--session=, the--boundary, the missing-value error, and a fake managed plugin asserting the argv andDATUM_SESSION/DATUM_API_HOSTit receives. They fail on the parent branch and pass here.assistantplugin: the flag after the subcommand prints the agent card, and pointing it at staging vs production actually changes the endpoint the plugin talks to (patch.staging.env.datum.netvspatch.datum.net), so the session is taking effect and not just being dropped. Also checked flag-beats-env, unknown session, ambiguous email, missing value,--help, and-o jsonstill reaching the plugin.🤖 Generated with Claude Code