stack/docs
Konsti Wohlwend bf93740c7e
feat: add CLI Auth dashboard app (#1739)
## Summary

New "CLI Auth" app registered in `apps-config.ts` (alpha, parent:
authentication) and `apps-frontend.tsx` (TerminalWindowIcon, `/cli-auth`
route).

**Backend** — `GET /internal/cli-auth`:
- Queries `CliAuthAttempt` (last 50) with computed status from
`usedAt`/`refreshToken`/`expiresAt`
- Joins claimed `refreshToken` values against `ProjectUserRefreshToken`
to find active CLI sessions + user info via `ProjectUser`
- Returns `{ summary, recent_attempts, active_cli_users }`

**Dashboard** — `/cli-auth/page-client.tsx`:
- Fetches via `hexclaveAppInternalsSymbol` →
`sendRequest("/internal/cli-auth", {}, "admin")`
- Renders KPI cards (total/completed/expired/active), active sessions
list with last-active time, and recent attempts with status badges
- Expired sessions collapsed by default under `<details>`

Link to Devin session:
https://app.devin.ai/sessions/0868d1452a024b9da36b9d6a45044ff3
Requested by: @N2D4

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Adds an alpha CLI Auth dashboard to track CLI login attempts and active
refresh tokens, powered by a hidden admin-only endpoint.

- **New Features**
- Registers `cli-auth` under Authentication; adds `/cli-auth` route with
TerminalWindowIcon and docs link.
- Backend `GET /internal/cli-auth`: summary stats (incl. used_attempts),
last 50 attempts with computed status, and active CLI users by joining
CLI-issued refresh tokens (bounded).
- Dashboard fetches via admin request and shows KPIs, active sessions
(last-active/expiry), and recent attempts; expired sessions are
collapsed.

- **Bug Fixes**
- Use per-project admin app (`useAdminApp`) to avoid
ADMIN_AUTHENTICATION_REQUIRED and ensure correct tenancy scoping.
- Resolve primary emails for active sessions via `ContactChannel` join
to prevent 500s.
- Fix badges by using `DesignBadge` label prop and set expired to red;
add default cases in status switches.
- Bound token lookup to last 200 CLI-issued tokens and use a separate
COUNT(*) for accurate `active_tokens`.
  - Align loading skeleton grid with the KPI layout.
  - Docs: add `cli-auth` icon.

<sup>Written for commit 292859e921.
Summary will update on new commits.</sup>

<a
href="https://cubic.dev/pr/hexclave/hexclave/pull/1739?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>

<!-- End of auto-generated description by cubic. -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **New Features**
* Added a **CLI Auth** dashboard page with metrics for active sessions,
an expandable expired session list, and recent login attempts.
* Added a hidden internal analytics endpoint powering the dashboard
(summary, recent attempts, and active users).
* Registered **CLI Auth** in the app catalog/navigation (alpha) and
added its icon to the docs UI.
* **Bug Fixes**
* Improved request/response validation, loading/error states, and
avoided state updates after unmount.
* **Documentation**
* Updated docs indexing settings and added a redirect for a related
guide.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
2026-07-08 12:34:34 -07:00
..
code-examples Document init script less 2026-06-26 13:50:48 -07:00
content/docs Move queryAnalytics to server app (#1687) 2026-07-02 09:42:10 -07:00
lib [Docs] - Full cleanup (#1105) 2026-01-27 00:38:51 -06:00
public chore(cli-auth): publishable key no longer required for cli auth (#1590) 2026-06-12 10:12:27 -07:00
scripts Fix Docker build 2025-12-28 19:38:17 +01:00
src feat: add CLI Auth dashboard app (#1739) 2026-07-08 12:34:34 -07:00
templates-api Update missing docs redirects 2026-06-03 17:14:22 -07:00
.env Rename STACK_* env vars to HEXCLAVE_* in env templates, with legacy dual-read (#1588) 2026-06-19 18:58:53 -07:00
.env.development Rename STACK_* env vars to HEXCLAVE_* in env templates, with legacy dual-read (#1588) 2026-06-19 18:58:53 -07:00
.eslintrc.json Upgrade ESLint 2026-02-27 10:58:28 -08:00
.gitignore [Docs][Site] + [Dashboard][UI] - Adds docs to Stack Companion (#869) 2025-10-30 20:01:30 -05:00
cli.json New docs (#698) 2025-06-20 13:30:01 -07:00
instrumentation-client.ts Upgrade PostHog 2026-01-30 23:38:06 -08:00
next.config.mjs feat(hexclave): PR 3 — native @hexclave/* source rename + delete dual-publish wiring (#1482) 2026-05-29 15:21:59 -07:00
package.json chore: update package versions 2026-07-06 23:34:27 +00:00
postcss.config.mjs New docs (#698) 2025-06-20 13:30:01 -07:00
README.md Rename port prefix envvar 2026-05-27 18:09:52 -07:00
source.config.ts [Docs] - Full cleanup (#1105) 2026-01-27 00:38:51 -06:00
tsconfig.json Upgrade TypeScript from 5.9.3 to 6.0.3 (#1644) 2026-06-22 17:18:15 -07:00

Stack Auth Documentation

This is the documentation site for Stack Auth, built with Next.js and Fumadocs.

Development

pnpm dev

The docs server runs on port 8104 by default (or ${NEXT_PUBLIC_HEXCLAVE_PORT_PREFIX}04).

Project Structure

Content (/content)

Directory Description
content/docs/ Main documentation (guides, SDK reference, components)
content/api/ REST API reference documentation

App Routes (/src/app)

Route Description
/docs Main documentation pages
/api API reference pages (rendered from OpenAPI specs)
/docs-embed Embedded docs for dashboard companion widget
/api-embed Embedded API docs for dashboard companion widget
/mcp-browser MCP documentation browser
/handler/[...stack] Stack Auth handler route
/api/search Search API endpoint
/api/chat AI documentation chat endpoint
/llms.txt LLM-friendly documentation (plain text)
/llms.mdx LLM-friendly documentation (MDX format)

SDK Route Handlers

These routes serve SDK-specific documentation:

  • /js/[...path] - JavaScript SDK
  • /next/[...path] - Next.js SDK
  • /react/[...path] - React SDK
  • /python/[...path] - Python SDK
  • /rest-api/[...path] - REST API

Key Files

File Description
lib/source.ts Content source adapter using Fumadocs loader()
source.config.ts Fumadocs MDX configuration (frontmatter schema, etc.)
app/layout.config.tsx Shared layout options
lib/platform-config.ts Platform/framework configuration for code examples

Components (/src/components)

Directory Description
api/ API playground components
chat/ AI chat interface
layout/ Layout UI components (search, navigation)
layouts/ Page layouts (docs, API)
mdx/ Custom MDX components
stack-auth/ Stack Auth demo components
ui/ Base UI components (button, etc.)

OpenAPI Specs (/openapi)

Contains OpenAPI JSON specifications organized by access level:

  • client-*.json - Client-side API endpoints
  • server-*.json - Server-side API endpoints
  • admin-*.json - Admin API endpoints
  • webhooks-*.json - Webhook event schemas

Scripts

# Generate API docs from OpenAPI specs
pnpm generate-openapi-docs

# Clear generated docs
pnpm clear-docs

Learn More