Skip to content

Add AIDescription field and AI-mode help resolver#1563

Merged
ehl-jf merged 1 commit into
masterfrom
JGC-473-ai-context-help
Jun 1, 2026
Merged

Add AIDescription field and AI-mode help resolver#1563
ehl-jf merged 1 commit into
masterfrom
JGC-473-ai-context-help

Conversation

@ehl-jf
Copy link
Copy Markdown
Contributor

@ehl-jf ehl-jf commented May 21, 2026

Summary

Foundational change for JGC-473 (AI-agent-oriented help text in JFrog CLI).

  • Adds optional AIDescription string to components.Command and components.Namespace. Empty falls back to Description, so callers that don't opt in see no behavior change.
  • Adds docs/common.ResolveDescription(human, ai string), AIHelpEnabled(), and const EnvAIHelp = "JFROG_CLI_AI_HELP".
  • Wires ResolveDescription into the components -> urfave/cli conversion layer so plugins that populate AIDescription get agent-flavored help automatically.
  • Agent detection goes through an overridable AIAgentDetector function variable to keep the resolver unit-testable (the underlying ExecutionContext is sync.Once-memoized and can't be reset).

Cross-repo coordination

This is the foundation PR; the 5 plugin PRs and the jfrog-cli umbrella PR reference this branch via temporary go.mod replaces during review, and re-pin to the merged master commit once this PR lands. Merge this PR first.

Test plan

  • go build ./... clean
  • go vet ./... clean (apart from a pre-existing sync.Once copy warning in common/commands/execution_context_test.go that predates this PR)
  • go test ./... all packages pass, including the new docs/common/aihelp_test.go (resolver matrix) and plugins/components/conversionlayer_test.go (round-trip via convertCommand)
  • Manual verification of all 9 scenarios from the plan's §6 matrix (env force-on/off, agent auto-detect, --ai-help flag, unparseable env value, runtime unaffected)

Linked PRs (downstream consumers)

Add AIDescription to components.Command and components.Namespace, plus a
new docs/common.ResolveDescription helper that prefers the AI text when
JFROG_CLI_AI_HELP is truthy or the process is detected as an AI agent.
Wire it into the components->urfave/cli conversion layer so plugins that
populate AIDescription get the agent-flavored help with no other changes.

Setting AIDescription is purely additive: empty falls back to Description,
so callers that don't opt in see no behavior change.

Detection hooks through an AIAgentDetector function variable rather than
calling commands.DetectExecutionContext() directly. The underlying
ExecutionContext is sync.Once-memoized and cannot be reset, which would
make the resolver untestable; the hook lets unit tests inject a
deterministic answer.
@ehl-jf ehl-jf force-pushed the JGC-473-ai-context-help branch from 2c472e7 to 6f07899 Compare June 1, 2026 12:40
@ehl-jf ehl-jf changed the title JGC-473 - Add AIDescription field and AI-mode help resolver Add AIDescription field and AI-mode help resolver Jun 1, 2026
@ehl-jf ehl-jf added safe-to-test ignore for release Automatically generated release notes and removed safe-to-test labels Jun 1, 2026
Comment thread docs/common/aihelp.go
// The default consults the memoized ExecutionContext in
// common/commands. Exposed as a variable so tests can inject a deterministic
// answer — DetectExecutionContext caches via sync.Once and cannot be reset.
var AIAgentDetector = func() bool {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: IsAIAgentRequest or similar would match better with a boolean return

@ehl-jf ehl-jf merged commit 8d52a53 into master Jun 1, 2026
18 of 19 checks passed
@ehl-jf ehl-jf deleted the JGC-473-ai-context-help branch June 1, 2026 13:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ignore for release Automatically generated release notes safe-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants