Skip to content

Polish: root help, project sorting, list alignment#219

Merged
jeremy merged 9 commits intomainfrom
polish
Mar 9, 2026
Merged

Polish: root help, project sorting, list alignment#219
jeremy merged 9 commits intomainfrom
polish

Conversation

@jeremy
Copy link
Copy Markdown
Member

@jeremy jeremy commented Mar 9, 2026

Summary

  • Custom root help: Bare basecamp now shows a curated gh-style help screen with categories (Core Commands, Shortcuts, Search & Browse, Auth & Config), flags, examples, and a learn-more footer. Descriptions are sourced from live registered commands to prevent drift from catalog copy.
  • Machine-output preserved: --json, --agent, --quiet, and non-TTY bare root still return the quickstart JSON envelope. First-run wizard detection is preserved.
  • Bad config resilience: Bare root tolerates config/profile validation errors so broken config doesn't block help.
  • Project sorting: basecamp projects sorts alphabetically by name (client-side, gated on full result set to avoid misleading partial-page sorts).
  • ID column alignment: Right-aligns meta-role columns (IDs) in presenter list output. Scoped to meta columns only — todo content is not padded.
  • Catalog fix: url command description corrected from "Open Basecamp URL in browser" to "Parse Basecamp URLs".

Test plan

  • make check passes (vet, lint, unit tests, e2e, surface snapshot, provenance)
  • basecamp shows curated help
  • basecamp --help shows same curated help
  • basecamp --json returns quickstart JSON envelope
  • basecamp --agent returns quickstart JSON envelope
  • BASECAMP_PROFILE=bogus basecamp shows help (no error)
  • basecamp todos --help shows default cobra help (not curated)
  • basecamp --help --agent returns structured JSON
  • basecamp projects sorted alphabetically, IDs right-aligned

Summary by cubic

Polishes root help and list output: curated help for bare basecamp in interactive TTY, alphabetical projects list, and right‑aligned IDs. Keeps quickstart JSON for non‑TTY and machine modes, and improves resilience when config is broken.

  • New Features

    • Curated root help with categories, flags, examples; subcommands keep default cobra help. Supports --help --agent JSON help.
    • projects list sorts by name when the full set is returned.
    • List presenters right-align meta ID columns; content stays unpadded.
    • Compact root usage message on errors.
    • Catalog url description updated to “Parse Basecamp URLs”.
  • Bug Fixes

    • Bare-root help gated on interactive TTY; non‑TTY, --json, --agent, or config format=json|quiet keep quickstart JSON.
    • Preferences (hints/stats) applied even when profile or HTTPS validation fails.
    • Unreadable config now initializes a minimal app so wizard detection and machine-output checks still work; help vs quickstart routing stays correct.
    • Fixed a nil app panic in the bare-root quickstart path.

Written for commit 061651b. Summary will update on new commits.

jeremy added 3 commits March 9, 2026 11:23
RenderList now pre-computes max width for meta-role columns (IDs, dates)
and right-aligns them. Non-meta columns like todo content are left
unpadded to avoid wasting space on variable-length text.

Only the project schema currently has meta columns in its list view
([id, name]), so this fixes the ragged ID alignment there without
affecting todo output.
The BC3 API returns projects in reverse chronological order, which
makes scanning by name difficult. Add client-side alphabetical sort
after fetch, gated on full result set (page == 0 && limit == 0) to
avoid misleadingly sorting partial pages.
Replace the animated quickstart screen with curated help when running
bare `basecamp` interactively. Machine-output modes (--json, --agent,
--quiet, non-TTY) preserve the quickstart JSON envelope. First-run
wizard detection is preserved.

The root help renders curated command categories (Core, Shortcuts,
Search & Browse, Auth & Config), flags, examples, and a learn-more
footer. Descriptions are sourced from the live registered commands
(not catalog copy) to prevent drift. Remaining commands are
discoverable via `basecamp commands`.

Bare-root PersistentPreRunE now tolerates config/profile validation
errors — bad config no longer blocks help. The app context is still
created when config loads successfully so wizard detection and
IsMachineOutput work correctly.

Also exports CommandCategories() for use by the help renderer and
fixes the url catalog description ("Parse Basecamp URLs" to match
the command's actual Short field).
Copilot AI review requested due to automatic review settings March 9, 2026 18:26
@jeremy jeremy requested a review from a team as a code owner March 9, 2026 18:26
@github-actions github-actions bot added commands CLI command implementations tests Tests (unit and e2e) output Output formatting and presentation enhancement New feature or request labels Mar 9, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 9 files

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 87878b10d0

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR polishes the CLI’s default UX by replacing the bare-root quick-start display with a curated, categorized help screen (while preserving structured/agent output paths), plus small output and listing refinements.

Changes:

  • Add a custom “gh-style” root help renderer (curated categories, flags, examples, learn-more) and update root usage behavior.
  • Sort basecamp projects output alphabetically by project name when listing the full result set.
  • Right-align meta-role columns (e.g., IDs) in styled list rendering, and add/adjust unit + e2e coverage for the new behaviors.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/presenter/render.go Pre-computes widths for meta-role columns and right-aligns them during list rendering.
internal/presenter/presenter_test.go Adds tests for ID right-alignment and ensures todo content isn’t padded to max width.
internal/commands/quickstart.go Changes bare-root default to show help unless in machine-output mode / first-run wizard.
internal/commands/projects.go Adds client-side alphabetical sort by name when listing the full project set.
internal/commands/commands.go Exports CommandCategories() and fixes catalog description for url.
internal/cli/root.go Wires custom root help/usage, and tolerates certain config/profile errors for bare-root help.
internal/cli/help.go Implements the curated root help renderer and agent JSON help handling.
internal/cli/help_test.go Adds unit tests for curated root help, agent help JSON, and bare-root resilience.
e2e/core.bats Updates e2e expectations: bare basecamp and basecamp --help now show curated help.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Piped/non-TTY invocations (e.g. `basecamp | jq`) should produce
quickstart JSON, not help text. Use app.IsInteractive() so the TTY
check drives the decision rather than requiring explicit --json/--agent
flags.

Fixes review feedback on PR #219.
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 3 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="internal/commands/quickstart.go">

<violation number="1" location="internal/commands/quickstart.go:65">
P1: Nil `app` causes a panic inside `runQuickStart`. When `app == nil`, this condition is true and calls `runQuickStart`, which dereferences `app` without a nil guard at `app.Auth.IsAuthenticated()`. Change to `app != nil && !app.IsInteractive()` so a nil app falls through to `cmd.Help()` (which works without app context).</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

When app context is nil, fall through to cmd.Help() instead of calling
runQuickStart which dereferences app. Issue identified by cubic.
Copilot AI review requested due to automatic review settings March 9, 2026 18:50
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

jeremy added 2 commits March 9, 2026 12:07
- Check IsMachineOutput() in RunQuickStartDefault so config-driven
  format=json/quiet on an interactive TTY routes to quickstart, not help
- Call resolvePreferences in both bareRoot early-return branches so
  config-driven hints and stats are applied even when profile resolution
  or HTTPS validation fails
- Add tests for config-driven format routing, breadcrumbs with hints,
  and bad-profile preference resolution
- Add isolateHelpTest helper to all help tests for keyring/config/cache
  isolation via BASECAMP_NO_KEYRING and XDG temp dirs
- Tighten todo content padding assertion to check for exactly two-space
  separator (not just absence of 24+ spaces)
- Precompute lowercase sort keys in project listing to avoid repeated
  ToLower allocations in the comparator
Copilot AI review requested due to automatic review settings March 9, 2026 19:11
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 3 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="internal/commands/projects.go">

<violation number="1" location="internal/commands/projects.go:131">
P1: Pre-computed `keys` slice falls out of sync with `projects` during sorting. `sort.Slice` swaps elements in `projects` but `keys` is never reordered to match, so after the first swap the comparator uses stale keys for the wrong projects. This produces an incorrect (non-deterministic) sort order. Revert to the original inline `ToLower` which always reads the current element.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

sort.Slice only swaps elements in the target slice, not the parallel
keys slice, so precomputed keys go stale after the first swap. Revert
to inline ToLower which always reads from the current element.
Issue identified by cubic.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Consolidates the three bareRoot error-tolerance paths into a single
initBareRootApp closure that handles nil config (uses config.Default),
resolves preferences, and creates the app. The config-load-failure path
now initializes a minimal app instead of returning nil, so wizard
detection and machine-output flags still work with an unreadable config.
@jeremy jeremy merged commit b4a7fa7 into main Mar 9, 2026
25 checks passed
@jeremy jeremy deleted the polish branch March 9, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands CLI command implementations enhancement New feature or request output Output formatting and presentation tests Tests (unit and e2e)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants