Skip to content

Add AI context description to commands#3503

Merged
ehl-jf merged 4 commits into
masterfrom
JGC-473-ai-context-help
Jun 8, 2026
Merged

Add AI context description to commands#3503
ehl-jf merged 4 commits into
masterfrom
JGC-473-ai-context-help

Conversation

@ehl-jf

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

Copy link
Copy Markdown
Contributor

Summary

JFrog CLI commands now provide AI-agent-oriented help text. When the CLI is invoked by an AI coding agent — or when explicitly requested — each command's --help output expands from its short one-line description into a structured, example-rich guide designed for automated agents: when to use the command, prerequisites, runnable examples, common gotchas, and related commands.

Human output is unchanged by default. The richer text is shown only when AI mode is active, which is determined in this order of precedence:

  1. --ai-help flagjf --ai-help <command> --help forces AI-oriented help for that invocation.
  2. JFROG_CLI_AI_HELP environment variable — set to true to force it on, or false to force it off (a hard opt-out).
  3. Automatic agent detection — when neither of the above is set, the CLI renders AI help if it detects it is running inside a known AI agent (e.g. Claude Code, Cursor, Gemini CLI, GitHub Copilot CLI).

If JFROG_CLI_AI_HELP is set to an unrecognized value, the CLI safely falls back to automatic detection rather than erroring. Commands that have not yet been given AI-oriented text simply continue to show their standard description.

This first release adds AI-oriented help across the JFrog CLI command set, including Artifactory, security/Xray, evidence, AppTrust, and worker (platform-services) commands.

Implementation notes

  • jfrog-cli-core gains an AIDescription field on components.Command/Namespace and a docs/common.ResolveDescription resolver wired into the components -> urfave/cli conversion layer, so any plugin that populates AIDescription renders AI help automatically.
  • The umbrella adds the --ai-help global flag plus an argv pre-pass (it sets JFROG_CLI_AI_HELP before command setup, since the conversion layer reads it then). Local cli.Command literals in main.go and the */cli.go files route Usage/HelpName through corecommon.ResolveDescription; namespace shells use <name>AIUsage constants.
  • main_test.go forces JFROG_CLI_AI_HELP=false during integration-test setup so help-text assertions stay deterministic when the test runner itself runs inside an AI agent.

Dependency status — all merged

Every cross-repo JGC-473 PR has merged; each JFrog dependency is pinned to its merged base-branch version. No temporary replace directives remain.

Dependency PR
jfrog-cli-core/v2 #1563 (merged)
jfrog-cli-artifactory #455 (merged)
jfrog-cli-security #760 (merged)
jfrog-cli-evidence #65 (merged)
jfrog-cli-platform-services #58 (merged)
jfrog-cli-application #81 (merged)

Test plan

  • go build ./... clean
  • go test ./... — 0 failures on a clean (non-agent) env. (The RTECO-1368 TestVisibility_*_E2E tests are agent-env sensitive; they pass on CI and on a shell without CLAUDECODE/CURSOR_*.)
  • Manual matrix: env force-on/off, --ai-help flag, agent auto-detect, unparseable env value (graceful fallback), namespace listings, runtime unaffected.
  • End-to-end plugin AI text verified against the merged module versions: jf rt upload, jf audit, jf evd create, jf apptrust ping, jf worker deploy.

Out of scope (follow-ups)

  • AI-mode help template polish (render the AI text as a standalone block rather than inside the Name: line).

@ehl-jf ehl-jf force-pushed the JGC-473-ai-context-help branch from dfde4c1 to 2cba82a Compare May 27, 2026 08:33
@ehl-jf ehl-jf changed the title JGC-473 - Add --ai-help flag, AI text for umbrella commands, and call-site wiring Add --ai-help flag, AI text for umbrella commands, and call-site wiring Jun 1, 2026
@ehl-jf ehl-jf marked this pull request as ready for review June 1, 2026 12:33
@ehl-jf ehl-jf changed the title Add --ai-help flag, AI text for umbrella commands, and call-site wiring Add AI context description for each command Jun 1, 2026
@ehl-jf ehl-jf force-pushed the JGC-473-ai-context-help branch from 2cba82a to eae5fc3 Compare June 1, 2026 12:45
The list should be comma-separated(,) in the form of user1,user2,...
`
}

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.

Shouldn't all the changes below be in jfrog-cli-artifactory ?
https://github.com/jfrog/jfrog-cli-artifactory/blob/main/artifactory/docs/groupaddusers/help.go
Is there a reason we have this in CLI too ?

This applies to all help.go files.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It is because the commands are not located in RT repo.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe they should someday.

@ehl-jf ehl-jf force-pushed the JGC-473-ai-context-help branch from 01b7665 to a662e89 Compare June 1, 2026 13:39
@ehl-jf ehl-jf changed the title Add AI context description for each command Add AI context description to commands Jun 1, 2026
Comment thread docs/artifactory/permissiontargetupdate/help.go Outdated
ehl-jf added 2 commits June 8, 2026 10:07
Add a global --ai-help flag that, together with the JFROG_CLI_AI_HELP env
var, switches the conversion layer in jfrog-cli-core to render
AIDescription instead of Description.

The argv pre-pass runs before getCommands() so the conversion layer
(invoked during command setup) reads the env var early; urfave/cli's
own flag parsing happens later inside app.Run, by which time
command strings are already frozen.

The flag deliberately omits EnvVar: urfave/cli's BoolFlag EnvVar
binding parses the env value with strconv.ParseBool at startup and
crashes on unparseable values (e.g. JFROG_CLI_AI_HELP=maybe). Our
resolver in docs/common.AIHelpEnabled treats unparseable as a soft
fall-back to detection - bypassing urfave/cli's binding preserves
that gentler behavior.

No AIDescription content is populated yet; that arrives via the
follow-up backfill commit (umbrella subagent for help.go files and
call-site rewrites).
…l sites

Builds on commit 0650eec (which added the --ai-help flag and argv
pre-pass to main.go). This commit completes the umbrella's side of
JGC-473 by:

1. Adding GetAIDescription() to 85 docs/<ns>/<cmd>/help.go files for
   all visible jfrog-cli local commands. 28 help.go files for hidden /
   deprecated / dead-code stubs were intentionally skipped.

2. Rewriting cli.Command literals in main.go and 7 */cli.go files to
   route Usage / HelpName through corecommon.ResolveDescription, so the
   conversion-layer mechanism in jfrog-cli-core applies to the umbrella's
   own urfave/cli-based commands (which don't go through components.Command).
   For namespace shells with hardcoded Usage strings (rt, mc, pl, c, etc.)
   new <name>AIUsage constants were introduced.

3. Adding JFROG_CLI_AI_HELP=false default in main_test.go's
   setupIntegrationTests so help-text assertions remain deterministic
   when the test runner inherits an AI agent's env (CLAUDECODE,
   CURSOR_AGENT, etc.). CI runners without agent env are unaffected.

TEMPORARY go.mod state - REMOVE the 5 replace directives in the replace
block before merge. Each points at the in-flight JGC-473 branch of the
respective repo (jfrog-cli-core on JGC-473-devbase; 4 plugin repos on
developer's fork because direct org push is not in scope for plugin
repos). Once each repo's JGC-473 PR merges to its base branch, the
require pinning is sufficient and these replaces MUST be removed.

This PR MUST NOT merge until: (a) all 5 cross-repo JGC-473 PRs have
merged, AND (b) the yarn-coordination break between core master and
jfrog-cli-artifactory main is resolved upstream (RTECO-1035 follow-up).
@ehl-jf ehl-jf force-pushed the JGC-473-ai-context-help branch from 983a8fb to f077068 Compare June 8, 2026 08:11
@ehl-jf ehl-jf added safe to test Approve running integration tests on a pull request improvement Automatically generated release notes labels Jun 8, 2026
Per @vitaliil-jfrog: drop the "GitOps-style RBAC management" framing (not a
documented JFrog concept) in favor of the concrete use case (re-applying a
known-good definition from version control to correct drift). Also soften the
adjacent gotcha that asserted unverifiable partial-rollback behavior to a plain
"verify the result" suggestion.
Audit of the AIDescription examples surfaced flags and related-command
references that do not exist for their commands; an agent copying them would
hit "unknown flag" errors. Fixes:

- terraform-config: --server-id-resolve/--repo-resolve do not exist (deploy-only);
  use --server-id-deploy/--repo-deploy.
- poetry-config, pnpm-config: resolve-only; drop the non-existent --repo-deploy.
- gp (go-publish): remove the invented --deps flag (and its gotcha).
- eot (exchange-oidc-token): the URL flag is --url, not --platform-url; also fixed
  the same --platformUrl typo in the command's own Usage string.
- rt user-create: the groups flag is --users-groups, not --groups.
- npm-config: removed the bogus "--interactive=false" note (no such flag); prompts
  occur only when required flags are missing.
- docker: Related referenced "jf xr docker-scan" -> "jf docker scan".
- npm: Related referenced "jf xr audit npm" -> "jf audit".
@ehl-jf ehl-jf added safe to test Approve running integration tests on a pull request and removed safe to test Approve running integration tests on a pull request labels Jun 8, 2026
@ehl-jf ehl-jf merged commit eb1d5eb into master Jun 8, 2026
92 of 93 checks passed
@ehl-jf ehl-jf deleted the JGC-473-ai-context-help branch June 8, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Automatically generated release notes safe to test Approve running integration tests on a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants