Skip to content

Tell add-ons how they were invoked, so their messages name the right command #17

Done

Description

@itvi-1234

Problem
rc runs a language profiler as an add-on and passes the arguments through unchanged. When the add-on fails with a usage or setup error it names its own binary. Example, from rc profile typescript generate --project . with no --name:

error: usage: --name is required
usage: runtimeconditions-typescript-profiler [profile] verify-bindings --project DIR [--json]
       runtimeconditions-typescript-profiler [profile] generate --project DIR --name NAME ...

The user ran rc profile typescript generate ..., so the command they should copy is not the one printed.

Proposal (to discuss)

  • rc tells the add-on how it was invoked, for example through an environment variable that holds the command prefix (rc profile typescript).
  • Profilers use it in their usage text and in messages that suggest a command, and fall back to their own name when it is not set.
  • rc keeps passing the exit code through and prints no extra message of its own.

Acceptance

  • With and without rc, a usage error shows a command the user can copy.
  • A test in rc-cli runs a fake add-on and checks that it receives the variable.
  • The contract (spec issue) records the variable name.

Activity

  1. abhinavkdeval08-design commented on Nov 22, 2026

    @abhinavkdeval08-design
    Member

    Hi @itvi-1234, I'd like to take the rc-cli side of this.

    From reading newLanguageCommand in internal/cli/plugins.go, the change would be small: when rc runs an add-on it appends one variable to the child's environment (inheriting os.Environ(), since process.Spec.Env == nil currently means "inherit"), holding the exact prefix the user typed, e.g. rc profile typescript. It would apply to all three add-ons from that one place and leave exit-code passthrough untouched.

    Proposed details, happy to change any of them:

    • Variable name: RC_COMMAND_PREFIX (value like rc profile typescript). I don't have a strong view on the name, so I'll use whatever the contract issue settles on.
    • Set only for the real invocation, not for the --version --json probe.
    • Test: extend the fake runner test to assert the variable is present with the right value for typescript, java and python.
    • Docs: record the variable in docs/language-profilers.md.

    The profilers adopting it would be separate follow-ups in their own repos. Does this match what you had in mind, and is the variable name settled yet?

  2. abhinavkdeval08-design commented on Nov 27, 2026

    @abhinavkdeval08-design
    Member

    Hi @itvi-1234 👋

    I have opened PR #26 implementing the rc-cli side of this proposal:

    Summary of Changes:

    • Dynamic prefix passing: In newLanguageCommand (internal/cli/plugins.go), we now inject RC_COMMAND_PREFIX using cmd.CommandPath() (e.g. rc profile typescript) into the add-on execution environment.
    • Probe isolation: The variable is passed strictly during the actual invocation (Run), leaving the --version --json discovery probe untouched.
    • Transparent passthrough: Output streams (Stdout, Stderr) and exit code propagation remain completely unaffected.
    • Tests & Docs: Unit test assertions added across all three supported runtimes (TypeScript, Java, Python) in plugins_test.go, and documentation updated in docs/language-profilers.md.

    Notes / Questions for Discussion:

    1. Variable naming: Is RC_COMMAND_PREFIX good to finalize, or would you prefer another convention based on the spec/contract discussion? Happy to adjust if needed!
    2. Issue scope: Linked the PR with Refs #17 so the issue remains open for the profiler consumption follow-ups.

    Whenever you have a moment, please take a look. Feedback is welcome!

  3. added 2 commits that reference this issue on Nov 27, 2026
  4. colinjlacy commented on Nov 27, 2026

    @colinjlacy
    Contributor

    Closed by #26

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions