fix(help): hide plural aliases from help output#440
Conversation
Plural shortcut commands (issues, orgs, logs, etc.) and whoami were cluttering the help output alongside the canonical grouped commands. Uses Stricli's hideRoute to suppress them from help and completions while keeping them functional. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨Init
Issue List
Other
Bug Fixes 🐛Dsn
Init
Other
Documentation 📚
Internal Changes 🔧Init
Tests
Other
Other
🤖 This preview updates automatically when you update the PR. |
Codecov Results 📊✅ 111 passed | Total: 111 | Pass Rate: 100% | Execution Time: 0ms 📊 Comparison with Base Branch
✨ No test changes detected All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 1101 uncovered lines. Files with missing lines (2)
Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 95.08% 95.09% +0.01%
==========================================
Files 165 165 —
Lines 22390 22402 +12
Branches 0 0 —
==========================================
+ Hits 21289 21301 +12
- Misses 1101 1101 —
- Partials 0 0 —Generated by Codecov Action |
## Summary
- Fix misaligned hint lines in the `sentry init` feature multiselect
prompt by prefixing them with clack's `│` bar character
## Problem
The multiselect hint lines ("Error Monitoring is always included" and
"space=toggle, a=all, enter=confirm") were rendered without clack's `│`
bar prefix, causing visual misalignment with the option lines below
them.
**Before:**
```
◆ Select features to enable
Error Monitoring is always included
space=toggle, a=all, enter=confirm
│ ◻ Session Replay
│ ◼ Performance Monitoring
└
```
**After:**
```
◆ Select features to enable
│ Error Monitoring is always included
│ space=toggle, a=all, enter=confirm
│ ◻ Session Replay
│ ◼ Performance Monitoring
└
```
## Root Cause
Clack's `multiselect` renderer does not split multi-line `message`
strings and prefix continuation lines with the `│` bar (unlike
`log.message()` which does). The hint lines were embedded in the message
with only manual ` ` padding, missing the `│ ` prefix that clack applies
to option lines.
## Fix
Prefix hint lines with `chalk.gray("│")` (U+2502) to match clack's
visual frame, keeping the bar gray (matching clack's coloring) and the
hint text dim.
Phase 1 of #346: Add structured JSON output to the `help` command so AI agents can discover CLI commands at runtime. ## What Three modes of `sentry help --json`: - **Full tree**: `sentry help --json` → all routes, commands, flags, positional params as JSON - **Route group**: `sentry help --json issue` → group metadata with subcommands - **Specific command**: `sentry help --json issue list` → single command's full metadata Framework-injected flags (`help`, `helpAll`, `log-level`, `verbose`) are stripped from JSON output so agents see only user-facing flags. ## Architecture - **`src/lib/introspect.ts`** (new) — shared route-tree introspection module with types, type guards, extraction functions, and JSON cleaning utilities. Used at runtime by `help --json` and at build time by `generate-skill.ts`. - **`src/commands/help.ts`** — adds `output: "json"` and `--json` flag. Dynamic imports for the route tree and introspect module to avoid circular deps. - **`src/lib/help.ts`** — consolidated to import shared types from `introspect.ts` instead of duplicating them. - **`script/generate-skill.ts`** — imports shared types and functions from `introspect.ts`, removing ~100 lines of duplication. No functional change to output. ## Tests - 33 unit tests for introspection functions - 12 property-based tests (fast-check) for invariants - 10 integration tests for `help --json` end-to-end
…#436) ## Summary Moves the slug normalization warning from 5 individual command files into `parseOrgProjectArg()` itself. Every caller now gets the warning automatically — no per-command boilerplate, and no risk of future commands forgetting it. ### Changes **`src/lib/arg-parsing.ts`** — core change: - Added private `warnNormalized()` helper that builds a display slug from the `ParsedOrgProject` variant - Restructured `parseOrgProjectArg()` to emit the warning internally before returning - Improved message now includes the actual normalized value: `Normalized slug to 'my-org/my-project' (Sentry slugs use dashes, never underscores)` **5 command files** — removed duplicate 3-line if-blocks: - `src/commands/event/view.ts` - `src/commands/log/view.ts` - `src/commands/trace/view.ts` - `src/commands/span/list.ts` (also removed now-unused `logger.withTag()`) - `src/commands/span/view.ts` (also removed now-unused `cmdLog` variable) **`test/lib/arg-parsing.test.ts`** — 6 new tests: - Warning emitted for each variant: `project-search`, `explicit` (org/project), `org-all` - No warning for `auto-detect` or non-underscored slugs ### Before / After **Before** — copy-pasted in every command: ```typescript const parsed = parseOrgProjectArg(targetArg); if (parsed.type !== "auto-detect" && parsed.normalized) { log.warn("Normalized slug (Sentry slugs use dashes, not underscores)"); } ``` **After** — callers just call the parser: ```typescript const parsed = parseOrgProjectArg(targetArg); // Warning emitted automatically inside parseOrgProjectArg ``` ### Test Plan - [x] `bun run typecheck` — passes - [x] `bun run lint` — passes (0 errors) - [x] `bun test test/lib/arg-parsing.test.ts` — 106 tests pass - [x] `git grep 'Sentry slugs use dashes' -- 'src/'` — only matches `arg-parsing.ts` Closes #431
Enforce PR #433 `buildCommand` conventions via lint rules that run as part of `bun run lint`: ## GritQL Plugins (new) Two Biome GritQL plugins in `lint-rules/` ban anti-patterns in `src/commands/`: - **`no-stdout-write-in-commands`** — commands should yield `CommandOutput`, not call `stdout.write()` directly - **`no-process-stdout-in-commands`** — commands should not access `process.stdout` Both use `file($name, $body)` scoping so they only fire on command files and produce inline editor diagnostics. > **Note on Biome GritQL:** bare `$filename` / `$program` metavariables don't work in Biome 2.3.8 plugins (they cause "didn't specify a valid span" errors). The `file($name, $body)` pattern is the correct approach — `$name` contains the full absolute path so regex needs `.*` anchors. ## noRestrictedImports (new) Biome override bans `chalk` imports in `src/commands/**/*.ts`, directing developers to `colorTag()` from the markdown rendering pipeline which respects `NO_COLOR` / `SENTRY_PLAIN_OUTPUT`. ## Bug fix Fix `muted()` usage in `src/commands/issue/view.ts` to use the `isPlainOutput()` pattern, so span-tree fallback messages don't leak ANSI codes in plain-output mode.
Extract shared trace-target parsing and resolution into `src/lib/trace-target.ts`, replacing duplicated positional argument parsing and target resolution logic across 4 commands. ## New shared module: `src/lib/trace-target.ts` **`parseTraceTarget(args, usageHint)`** — Parses positional args into a discriminated union: - `<trace-id>` → `auto-detect` - `<org>/<trace-id>` → `org-scoped` - `<org>/<project>/<trace-id>` → `explicit` - `<target> <trace-id>` → delegates to `parseOrgProjectArg` **`resolveTraceOrgProject(parsed, cwd, hint)`** — For commands needing org+project (span list, span view, trace view) **`resolveTraceOrg(parsed, cwd, hint)`** — For org-scoped commands (trace logs) ## Commands migrated | Command | Lines removed | What changed | |---------|--------------|--------------| | `span list` | ~55 | Replaced `parsePositionalArgs` + 4-way switch | | `span view` | ~40 | Replaced `parsePositionalArgs` + `resolveTarget` helper | | `trace view` | ~83 | Replaced `parsePositionalArgs` + switch; kept swap detection as `preProcessArgs` | | `trace logs` | ~44 | Replaced custom slash parsing + `resolveOrg` call | Net: **-29 lines** (777 added to shared module + tests, 806 removed from commands) Closes #434
#428) ## Summary Redesign `sentry init` to support smart positional arguments for org/project targeting and directory specification. ### Supported forms ``` sentry init # auto-detect everything, dir = cwd sentry init . # dir = cwd, auto-detect org sentry init ./subdir # dir = subdir, auto-detect org sentry init acme/ # explicit org, dir = cwd sentry init acme/my-app # explicit org + project, dir = cwd sentry init my-app # search for project across orgs → sets org + project sentry init acme/ ./subdir # explicit org, dir = subdir sentry init acme/my-app ./subdir # explicit org + project, dir = subdir sentry init ./subdir acme/ # swapped → auto-correct with warning sentry init ./subdir acme/my-app # swapped → auto-correct with warning ``` ### Design Two optional positionals with smart disambiguation: - **Path-like args** (starting with `.` `/` `~` `~/`) are treated as the **directory** - **Everything else** is treated as the **org/project target** - When args are in wrong order (path first, target second), they are **auto-swapped with a warning** — following the established swap pattern from view commands - **Bare slugs** (e.g., `my-app`) are resolved via `resolveProjectBySlug` to search across all accessible orgs, setting both org and project from the match - **Two paths** or **two targets** → error with helpful message - User-provided org/project slugs are validated via `validateResourceId` at parse time; API-resolved values from `resolveProjectBySlug` skip redundant validation ### Files changed | File | Change | |---|---| | `src/lib/arg-parsing.ts` | Add `looksLikePath()` for syntactic path detection (no filesystem I/O) | | `src/commands/init.ts` | Two positionals, `classifyArgs()` disambiguation, `resolveTarget()` with `resolveProjectBySlug` for bare slugs, `validateResourceId` on user-provided slugs only | | `src/lib/init/types.ts` | Add `org?` and `project?` to `WizardOptions` | | `src/lib/init/local-ops.ts` | Use `options.org`/`options.project` in `createSentryProject()` to skip interactive org resolution and override wizard-detected project name | | `test/commands/init.test.ts` | 26 tests covering all arg combinations, swap detection, error cases | ### Breaking change `sentry init <directory>` no longer works for bare directory names (e.g., `sentry init mydir`). Use path syntax: `sentry init ./mydir`. --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Instead of just hiding plural aliases, show them as muted hints next to their parent command (e.g. "alias: sentry issues" next to issue). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Reverts the inline alias hints — aliases should only be excluded from SKILL.md generation, not decorated in the help output. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| } | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Override replaces global restricted imports for command files
Medium Severity
The new noRestrictedImports override for src/commands/**/*.ts only declares @stricli/core and chalk restrictions. Biome overrides replace (not merge) rule configurations for matching files, so the global node:fs and node:process import restrictions are silently dropped for all command files. The intent was to add the chalk restriction on top of the existing ones, but the override loses the other two.
|
closing this. see #441 |


Summary
Plural shortcut commands (
sentry issues,sentry logs,sentry orgs, etc.) andsentry whoamiwere showing in the help output alongside the canonical grouped commands (sentry issue list,sentry log list, etc.), making it noisy. Hides them using Stricli'shideRoute— the commands still work, they just don't appear insentry --helpor shell completions.Test plan
sentry— plural aliases no longer listedsentry --help— samesentry issues— still works