diff --git a/src/cli/help.ts b/src/cli/help.ts index 2a8f919bb..049c060ab 100644 --- a/src/cli/help.ts +++ b/src/cli/help.ts @@ -1,285 +1,10 @@ import { readFileSync } from "node:fs"; import { dirname, join } from "node:path"; import { fileURLToPath } from "node:url"; +import { findCommand } from "./registry"; const repoRoot = dirname(fileURLToPath(new URL("../../package.json", import.meta.url))); -type HelpEntry = { - usage: string; - summary: string; - details?: string[]; -}; - -const helpEntries: Record = { - init: { usage: "ocx init", summary: "Interactive setup for providers and Codex config injection." }, - setup: { usage: "ocx setup", summary: "Interactive setup for providers and Codex config injection (alias of init)." }, - start: { usage: "ocx start [--port ]", summary: "Start the proxy server and sync models to Codex." }, - stop: { usage: "ocx stop", summary: "Stop the proxy and restore native Codex config." }, - restore: { - usage: "ocx restore [back]", - summary: "Restore native Codex config without stopping the proxy; `restore back` re-points codex at the running proxy.", - }, - eject: { - usage: "ocx eject [back]", - summary: "Restore native Codex config without stopping the proxy; `eject back` re-points codex at the running proxy.", - }, - "recover-history": { - usage: "ocx recover-history --legacy-openai", - summary: "Explicitly recover pre-backup syncResumeHistory rows.", - }, - uninstall: { - usage: "ocx uninstall", - summary: "Remove service/shim/config and restore native Codex.", - details: [ - "Alias: ocx remove", - "Config cleanup requires ownership metadata created by a fresh install; legacy or shared directories are left in place.", - ], - }, - remove: { - usage: "ocx remove", - summary: "Remove service/shim/config and restore native Codex.", - details: [ - "Alias of: ocx uninstall", - "Config cleanup requires ownership metadata created by a fresh install; legacy or shared directories are left in place.", - ], - }, - service: { - usage: "ocx service [install|start|stop|status|uninstall|remove]", - summary: "Run as a background service.", - details: [ - "With no subcommand, installs/updates and starts the background service.", - "Use `ocx service status` to see diagnostics and log paths.", - ], - }, - "codex-shim": { - usage: "ocx codex-shim ", - summary: "Auto-start the proxy when `codex` launches.", - details: ["Use `remove` as an alias for `uninstall`."], - }, - tray: { - usage: "ocx tray [--json] [--no-start]", - summary: "Install and control the Windows status tray icon.", - details: [ - "The tray starts at Windows login and provides one-click proxy controls.", - "Tray start/stop controls the icon only; use its menu to start or stop the proxy.", - "--no-start (install only) installs the tray without launching it immediately.", - ], - }, - ensure: { usage: "ocx ensure", summary: "Ensure the proxy is running and Codex config/cache are current." }, - sync: { - usage: "ocx sync [--restart-codex]", - summary: "Fetch provider models and inject them into Codex config.", - details: [ - "After writing the catalog, warns if long-lived Codex app-server processes are still running.", - "--restart-codex sends SIGTERM only to matching app-server / code-mode-host processes (may interrupt active turns).", - ], - }, - "sync-cache": { - usage: "ocx sync-cache [--restart-codex]", - summary: "Refresh Codex's model cache from the active catalog.", - details: [ - "Warns when Codex app-server processes still hold an in-memory model list.", - "--restart-codex sends SIGTERM only to matching app-server / code-mode-host processes (may interrupt active turns).", - ], - }, - status: { usage: "ocx status", summary: "Check proxy server status." }, - doctor: { usage: "ocx doctor", summary: "Diagnose environment/network issues (paths, WSL /mnt, proxy env, ChatGPT reachability)." }, - debug: { - usage: "ocx debug ", - summary: "Show or toggle runtime provider, usage, injection, and Claude debug capture.", - details: [ - "Provider: ocx debug provider on | off | status | reset | logs [-f]", - "Usage JSONL: ocx debug usage on | off | status | reset | logs [-f]", - "Env default: OCX_DEBUG=1 (legacy OCX_DEBUG_FRAMES still works)", - ], - }, - login: { usage: "ocx login ", summary: "OAuth or API-key login for a provider." }, - logout: { usage: "ocx logout ", summary: "Remove a stored provider login." }, - gui: { usage: "ocx gui", summary: "Open the opencodex dashboard." }, - update: { - usage: "ocx update [--tag latest|preview]", - summary: "Update opencodex. Preview installs stay on the preview tag unless overridden.", - }, - provider: { - usage: "ocx provider ", - summary: "Non-interactive provider management.", - details: [ - "Subcommands: list, add/edit/test/remove/show, set-default, selected, quota, presets, account-mode", - "Registry providers are auto-configured by name. Custom providers need --adapter and --base-url.", - "Run `ocx provider --help` for full usage and examples.", - ], - }, - account: { - usage: "ocx account ...", - summary: "List and switch provider accounts and API-key pools (GUI parity).", - details: [ - "list [provider] Codex account pool, OAuth accounts and API keys (identifiers shown masked as the API returns them).", - "current Show the active account or key.", - "use Switch the active credential; 'main' selects the Codex App login.", - "refresh Force-refresh Codex or provider quota reports.", - "auto-switch Control the Codex pool threshold.", - "priority [first|earlier|normal|later|last|-100..100|reset] Selection order; omit the value to read it.", - "remove --yes Remove a stored account or key after an existence check.", - "add-key [--label