Skip to content

feat(help): add common flags section and cache-age hints (#785)#859

Merged
BYK merged 4 commits intomainfrom
byk/feat-fresh-flag-discoverability
Apr 28, 2026
Merged

feat(help): add common flags section and cache-age hints (#785)#859
BYK merged 4 commits intomainfrom
byk/feat-fresh-flag-discoverability

Conversation

@BYK
Copy link
Copy Markdown
Member

@BYK BYK commented Apr 28, 2026

Summary

Closes the last remaining item from #785 — making --fresh/-f discoverable.

1. "Flags:" section in sentry / sentry help

Adds a new section between commands and environment variables showing the most important cross-command flags:

Flags:
        --json       Output as JSON (with --fields to select)
    -f, --fresh      Bypass cache and fetch fresh data
    -v, --verbose    Enable debug logging
        --help       Show help for a command
        --version    Show version

Also exposed via sentry help --json in a new flags array.

Shown in the branded help (sentry, sentry help) but intentionally not in sentry --help — the Stricli-generated --help stays terse and token-efficient for AI agents.

Note: --fresh is available on most read commands (list, view, whoami) but not on mutation commands (create, delete, resolve, login). This mirrors gh --help which lists flags that apply to "most commands" without enumerating exceptions.

2. Cache-age hint in command footers

When data is served from the HTTP response cache, commands now show a hint like:

cached · 3m ago · use -f to refresh

This is applied automatically in buildCommand (src/lib/command.ts) — individual commands don't need any changes. The mechanism:

  1. response-cache.ts sets a module-level lastCacheHitAgeMs on cache hits
  2. sentry-client.ts clears it at the start of each authenticatedFetch() call
  3. buildCommand calls appendCacheHint(returned?.hint) after the generator completes
  4. Bare return; paths (e.g. --web) are skipped since no data was rendered

The hint is suppressed in JSON mode, when --fresh is passed, and when SENTRY_NO_CACHE=1 is set.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

PR Preview Action v1.8.1

QR code for preview link

🚀 View preview at
https://cli.sentry.dev/_preview/pr-859/

Built to branch gh-pages at 2026-04-28 06:34 UTC.
Preview will be ready when the GitHub Pages deployment is complete.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 28, 2026

Codecov Results 📊

6178 passed | Total: 6178 | Pass Rate: 100% | Execution Time: 0ms

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +20
Passed Tests 📈 +20
Failed Tests
Skipped Tests

All tests are passing successfully.

❌ Patch coverage is 79.17%. Project has 12843 uncovered lines.
✅ Project coverage is 75.94%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
src/lib/help.ts 66.67% ⚠️ 25 Missing
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    75.82%    75.94%    +0.12%
==========================================
  Files          289       290        +1
  Lines        53347     53384       +37
  Branches         0         0         —
==========================================
+ Hits         40451     40541       +90
- Misses       12896     12843       -53
- Partials         0         0         —

Generated by Codecov Action

Surface --fresh/-f discoverability in two ways:

1. Add a "Flags:" section to `sentry --help` (between commands and env
   vars) showing --json, --fresh/-f, --verbose/-v, --help, --version.
   Also exposed via `sentry help --json` in the new `flags` array.

2. Show "cached · 3m ago · use -f to refresh" hint in command footers
   when data was served from the HTTP response cache. Applied
   automatically in buildCommand's wrapper — individual commands don't
   need any changes. Uses a module-level signal in response-cache.ts
   (set on cache hit, cleared per-request in authenticatedFetch).

Closes the last remaining item from #785.
@BYK BYK force-pushed the byk/feat-fresh-flag-discoverability branch from e99a401 to 5fe6860 Compare April 28, 2026 05:52
@BYK BYK marked this pull request as ready for review April 28, 2026 05:58
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5fe6860. Configure here.

Comment thread src/lib/response-cache.ts
BYK added 3 commits April 28, 2026 06:04
Cursor Bugbot caught a dangling 'Cache bypass control' banner left
above the new 'Last cache-hit age' section in response-cache.ts.
…ession, tests

- Intercept top-level `sentry --help` / `-h` in cli.ts and rewrite to
  `sentry help` so the branded output (with Flags + Env Vars sections)
  is shown instead of Stricli's terse default. Subcommand help is unchanged.
- Suppress cache-age hint on bare `return;` paths (e.g. --web) where no
  data is rendered — the hint references refreshing data the user never saw.
- Add positive-path tests for formatCacheHint and appendCacheHint using
  a test-only setter (setLastCacheHitAgeForTesting).
- Add JSDoc note about parallel API call hint determinism.
- Delete stale plan file.
Stricli's built-in `--help` is intentionally left as the terse,
token-efficient format for AI agents. The branded help (with Flags +
Environment Variables sections) is shown via `sentry` (no-args) and
`sentry help`, which are the human discovery paths.
@BYK BYK merged commit dfa902d into main Apr 28, 2026
26 checks passed
@BYK BYK deleted the byk/feat-fresh-flag-discoverability branch April 28, 2026 06:38
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.

1 participant