Skip to content

feat(RHIDP-14129): add intent-based CLI commands and backstage-cli pass-through - #156

Open
yangcao77 wants to merge 6 commits into
redhat-developer:mainfrom
yangcao77:intent-based-cli
Open

feat(RHIDP-14129): add intent-based CLI commands and backstage-cli pass-through#156
yangcao77 wants to merge 6 commits into
redhat-developer:mainfrom
yangcao77:intent-based-cli

Conversation

@yangcao77

@yangcao77 yangcao77 commented Aug 5, 2026

Copy link
Copy Markdown

https://redhat.atlassian.net/browse/RHIDP-14129

Adds intent-based subcommands and backstage-cli pass-through commands to rhdh-cli

Today, interacting with a running RHDH/Backstage instance from the CLI requires backstage-cli actions execute <pluginId>:<actionName> with internal action IDs and raw JSON input. This is very bad experience for human operations.

This change makes rhdh-cli the single entry point:

# Before: two CLIs, raw action IDs                                                                         
backstage-cli auth login --backend-url https://rhdh.example.com                                            
backstage-cli actions execute catalog:query-catalog-entities --query '{"kind":"Component"}' 
backstage-cli actions execute catalog:query-catalog-entities --query '{"kind":"Template"}'   

# After: one CLI, intent-based commands                                                                    
rhdh-cli auth login --backend-url https://rhdh.example.com                                                 
rhdh-cli catalog list --kind Component   
rhdh-cli template list
           

All intent-based commands support --output json for agent consumption and --instance <name> for multi-instance targeting.

The local metadata file is still going to use the config file for backstage-cli , so that existing backstage-cli user can migrate to use rhdh-cli with no extra effort

  • Commands shell out to backstage-cli, no new backend dependencies
  • Large responses use file redirect to work around Node.js pipe buffer limits
  • Human-readable output (entity tables, search results) by default; --output json for agents
  • Existing plugin export and plugin package commands are unchanged

see recording:

rhdh-cli.mov

…tions related will use backstage-cli

Signed-off-by: Stephanie <yangcao@redhat.com>
Signed-off-by: Stephanie <yangcao@redhat.com>
@yangcao77 yangcao77 changed the title [RHIDP-14129] Add intent-based CLI commands and backstage-cli pass-through feat(RHIDP-14129) Add intent-based CLI commands and backstage-cli pass-through Aug 5, 2026
@yangcao77

Copy link
Copy Markdown
Author

@kadel @benwilcock @elsony @durandom FYI

@yangcao77 yangcao77 changed the title feat(RHIDP-14129) Add intent-based CLI commands and backstage-cli pass-through feat(RHIDP-14129): add intent-based CLI commands and backstage-cli pass-through Aug 5, 2026
- Statically import command modules in commands/index.ts instead of
  using require(), since the backstage-cli bundler only follows static
  ESM imports/dynamic import() and silently dropped the require()'d
  files from the packed dist, breaking every command once installed
  from npm (Cannot find module './backstage-passthrough').
- Fix TS2352 in intent-errors.ts by adding a safe getStderr() helper
  instead of casting Error directly to Record<string, unknown>.
- Restrict the PATH used to resolve backstage-cli via `which` to
  directories that aren't group/other-writable, addressing the
  SonarCloud S4036 PATH-search security hotspot in lib/client.ts.
- Extract shared runEntityListAction/runRawAction/runSearchAction
  helpers and a registerPassthroughCommand helper to remove the heavy
  code duplication SonarCloud flagged across catalog/api/template/
  search/docs/backstage-passthrough command files.
- Fix pre-existing lint (no-empty, func-names) and prettier issues so
  the Checks job can get past the linter/prettier steps.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread src/commands/intent-based-actions/client.ts Fixed
…ctory

Move catalog/api/search/docs/template/backstage-passthrough and their
supporting client/format/intent-errors/helpers modules into
src/commands/intent-based-actions/, mirroring the existing
export-dynamic-plugin/ and package-dynamic-plugins/ layout, with a
single registerIntentCommands() entry point.

Co-authored-by: Cursor <cursoragent@cursor.com>
Comment thread src/commands/intent-based-actions/client.ts Fixed
SonarCloud S4036 still flagged spawnSync('which', ...) even with a restricted PATH env, since it pattern-matches on shelling out to a path-search utility rather than analyzing the PATH value. Replace it with a direct filesystem walk over PATH entries (skipping group/other-writable directories) and an accessSync executability check, avoiding the flagged pattern entirely.

Co-authored-by: Cursor <cursoragent@cursor.com>
@sonarqubecloud

sonarqubecloud Bot commented Aug 5, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants