Skip to content

agentctx profile with no subcommand writes usage to stdout but exits 1, diverging from the CLI's error convention #86

Description

@Deepam02

Problem

Running agentctx profile with no subcommand prints the usage block to stdout and then returns exit code 1:

  • File / line: packages/agentctx/src/cli/profile-cmd.ts:29-33
    case undefined:
    case "--help":
    case "help":
      env.io.out(PROFILE_USAGE);          // → stdout
      return command === undefined ? 1 : 0; // no subcommand → exit 1

This is inconsistent with the rest of the CLI in two ways:

  1. Every other "missing required argument" path writes usage to stderr (env.io.err), not stdout, while returning 1 — e.g. search with no query (cli/search.ts:42-44), show with no id (cli/show.ts:36-38), and even profile's own edit/clear subcommands (cli/profile-cmd.ts:95, :140). A non-zero exit that prints to stdout is the odd one out; scripts checking $? get an error code while the diagnostic went to stdout instead of stderr.

  2. The top-level no-command case returns 0 (cli/main.ts:46-51 prints HELP to stdout and returns 0), so the two "no command given" entry points disagree on exit code.

The result is real but minor: agentctx profile looks like a help invocation (usage on stdout) yet signals failure (exit 1), and the stream/exit-code pairing doesn't match the conventions used everywhere else.

What done looks like

  • agentctx profile with no subcommand routes its usage output through the same channel/exit-code convention as the rest of the CLI: either treat it as an error (usage → env.io.err, exit 1, matching search/show) or as help (usage → stdout, exit 0, matching the top-level --help). Pick one and apply it consistently.
  • agentctx profile --help / agentctx profile help continue to print usage to stdout and exit 0.
  • A test in test/cli/ asserts the chosen stream and exit code for the no-subcommand invocation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions