Skip to content

feat: add auth0 docs search command for documentation discovery - #1686

Merged
developerkunal merged 6 commits into
mainfrom
DXCDT-2441/add-docs-search-command
Sep 25, 2026
Merged

developerkunal merged 6 commits into
mainfrom
DXCDT-2441/add-docs-search-command

Conversation

@developerkunal

@developerkunal developerkunal commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🔧 Changes

Adds a new auth0 docs parent command with a search subcommand (alias find) so users and agents can discover Auth0 documentation directly from the terminal. It queries the public Auth0 documentation search index and prints matching pages with their titles, types, and URLs. No authentication is required.

  • The query can be passed as an argument or entered interactively when omitted.
  • Results are sorted by descending relevance score (the API returns them unsorted).
  • Search targets the English documentation, which is the only language the index is reliably localized in for now.
  • Output formats: default human table plus --json, --json-compact, and --csv (mutually exclusive). A single human-mode result renders as a key/value detail view showing a content snippet.
  • Agent mode emits machine-readable JSON whose URLs use the raw-markdown .md form, with a stable field order (title, type, url, snippet, score).
  • --open opens a result in the browser: an interactive picker in a TTY when there are multiple results, otherwise the top result. When a machine output format (--json/--json-compact/--csv) is set, the picker is suppressed and the top result opens so the emitted output is not clobbered. It is not supported in agent mode and fails fast with a clear error; agents fetch a page directly using the raw-markdown .md URL already present in the JSON output.
  • Registered in the no-auth allowlist and the generated command docs, with the README top-level command list updated.

🔬 Testing

  • Table-driven unit tests cover request shape, score sorting, non-200 and invalid-JSON handling, URL building (including leading-slash paths), rune-safe snippet truncation, result-type parsing, the interactive-open picker gate and its suppression under machine output formats, and the agent-mode --open rejection.
  • make docs, make test-unit, and make build all pass; lint is clean for the new files.

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

Add a new 'auth0 docs' parent command with a 'search' subcommand (alias
'find') that queries the public Auth0 documentation search index and prints
matching pages with their titles, sections, types, and URLs. No
authentication is required.

- Query can be passed as an argument or entered interactively when omitted.
- Results are sorted by descending relevance score.
- --language (en/fr/ja, default en) selects the docs language and rejects
  unsupported values up front.
- Output formats: default human table plus --json, --json-compact, and --csv.
  A single human-mode result renders as a key/value detail view with a snippet.
- Agent mode emits machine-readable JSON with raw-markdown .md URLs and a
  stable field order.
- --open opens a result in the browser (interactive picker in a TTY, top
  result otherwise); in agent mode it fetches the top result's markdown and
  prints it as JSON instead.
- Long section breadcrumbs are collapsed in the table view for readability.
@developerkunal
developerkunal requested a review from a team as a code owner September 23, 2026 04:39
Copilot stopped work on behalf of developerkunal due to an error September 23, 2026 04:54
Provider 1.58.0 added token_lifetime_for_anonymous_access_tokens with a
validation range of 86400-2592000, but the Management API returns 0 for
the built-in Management API resource server, so terraform plan rejected
its own generated config. Cap the generated required_providers version
at < 1.58.0 so tf generate stays plannable.
- Suppress the interactive open picker when a machine output format
  (--json/--json-compact/--csv) is set, so --json --open no longer prints
  JSON and then launches a prompt over it. The picker gate is extracted
  into docsShouldPromptForResult and unit tested.
- Skip the spinner in agent mode at both fetch sites so stderr stays clean
  and machine-readable, matching the rest of the CLI.
- Cap search and markdown response reads with io.LimitReader.
- Build page URLs with url.JoinPath to avoid a double slash on leading-slash
  paths, and handle a single-token openapi value instead of mislabeling it.
- Hoist the duplicated docsResultURL call in the picker loop.
--open opens a result in a browser and, in a terminal, lets a human pick
which one. An agent can do neither, and previously it just fetched the top
result's markdown, which is an arbitrary guess. Agents already get every
result's raw-markdown .md URL in the normal JSON output and can fetch pages
directly, so fail fast with unsupported_in_agent_mode instead, matching the
acul dev pattern. Removes the now-dead markdown-fetch code and its test.
@developerkunal
developerkunal enabled auto-merge (squash) September 24, 2026 13:07
Comment thread internal/cli/docs.go Outdated
@developerkunal
developerkunal merged commit 85689e8 into main Sep 25, 2026
6 checks passed
@developerkunal
developerkunal deleted the DXCDT-2441/add-docs-search-command branch September 25, 2026 06:42
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.

3 participants