perf(cli): keep root help off runtime graph
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* CLI argument parsing and help display
|
||||
*/
|
||||
import { APP_NAME, CONFIG_DIR_NAME, logger } from "@oh-my-pi/pi-utils";
|
||||
import { APP_NAME, logger } from "@oh-my-pi/pi-utils";
|
||||
import chalk from "chalk";
|
||||
import { CLI_THINKING_LEVELS, type ConfiguredThinkingLevel, parseCliThinkingLevel } from "../thinking";
|
||||
import { BUILTIN_TOOL_NAMES, HIDDEN_TOOL_NAMES, normalizeToolNames } from "../tools/builtin-names";
|
||||
@@ -13,8 +13,11 @@ import {
|
||||
STRING_SETTERS,
|
||||
STRING_VALUE_FLAGS,
|
||||
} from "./flag-tables";
|
||||
import { getExtraHelpText } from "./help-extra";
|
||||
import { CliUsageError } from "./usage-error";
|
||||
|
||||
export { getExtraHelpText };
|
||||
|
||||
export type Mode = "text" | "json" | "rpc" | "acp" | "rpc-ui";
|
||||
|
||||
export interface Args {
|
||||
@@ -330,92 +333,6 @@ export function reportCliUsageError(
|
||||
return true;
|
||||
}
|
||||
|
||||
export function getExtraHelpText(): string {
|
||||
return `${chalk.bold("Environment Variables:")}
|
||||
${chalk.dim("# Core Providers")}
|
||||
ANTHROPIC_API_KEY - Anthropic Claude models
|
||||
ANTHROPIC_OAUTH_TOKEN - Anthropic OAuth (takes precedence over API key)
|
||||
CLAUDE_CODE_USE_FOUNDRY - Enable Anthropic Foundry mode (uses Foundry endpoint + mTLS)
|
||||
FOUNDRY_BASE_URL - Anthropic Foundry base URL (e.g., https://<foundry-host>)
|
||||
ANTHROPIC_FOUNDRY_API_KEY - Anthropic token used as Authorization: Bearer <token> in Foundry mode
|
||||
ANTHROPIC_CUSTOM_HEADERS - Extra headers for Foundry or any custom ANTHROPIC_BASE_URL gateway (e.g., "user-id: USERNAME")
|
||||
CLAUDE_CODE_CLIENT_CERT - Client certificate (PEM path or inline PEM) for mTLS
|
||||
CLAUDE_CODE_CLIENT_KEY - Client private key (PEM path or inline PEM) for mTLS
|
||||
NODE_EXTRA_CA_CERTS - CA bundle path (or inline PEM) for server certificate validation
|
||||
OPENAI_API_KEY - OpenAI GPT models
|
||||
GEMINI_API_KEY - Google Gemini models
|
||||
COPILOT_GITHUB_TOKEN - GitHub Copilot
|
||||
|
||||
${chalk.dim("# Additional LLM Providers")}
|
||||
AZURE_OPENAI_API_KEY - Azure OpenAI models
|
||||
GROQ_API_KEY - Groq models
|
||||
CEREBRAS_API_KEY - Cerebras models
|
||||
XAI_API_KEY - xAI Grok models
|
||||
OPENROUTER_API_KEY - OpenRouter aggregated models
|
||||
KILO_API_KEY - Kilo Gateway models
|
||||
MISTRAL_API_KEY - Mistral models
|
||||
ZAI_API_KEY - z.ai models (ZhipuAI/GLM)
|
||||
UMANS_AI_CODING_PLAN_API_KEY - Umans AI Coding Plan models
|
||||
UMANS_WEBSEARCH_PROVIDER - Umans gateway web search backend (native or exa)
|
||||
MINIMAX_API_KEY - MiniMax models
|
||||
OPENCODE_API_KEY - OpenCode Zen/OpenCode Go models
|
||||
CURSOR_ACCESS_TOKEN - Cursor AI models
|
||||
AI_GATEWAY_API_KEY - Vercel AI Gateway
|
||||
WAFER_SERVERLESS_API_KEY - Wafer Serverless (pay-as-you-go)
|
||||
|
||||
${chalk.dim("# Cloud Providers")}
|
||||
AWS_PROFILE - AWS Bedrock (or AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY)
|
||||
GOOGLE_CLOUD_PROJECT - Google Vertex AI (requires GOOGLE_CLOUD_LOCATION)
|
||||
GOOGLE_APPLICATION_CREDENTIALS - Service account for Vertex AI
|
||||
|
||||
${chalk.dim("# Search & Tools")}
|
||||
EXA_API_KEY - Exa web search
|
||||
BRAVE_API_KEY - Brave web search
|
||||
PERPLEXITY_API_KEY - Perplexity web search API key (optional; anonymous fallback)
|
||||
PERPLEXITY_COOKIES - Perplexity web search (session cookie)
|
||||
TAVILY_API_KEY - Tavily web search
|
||||
TINYFISH_API_KEY - TinyFish web search
|
||||
FIRECRAWL_API_KEY - Firecrawl web search
|
||||
ANTHROPIC_SEARCH_API_KEY - Anthropic web search (override; isolates search from main ANTHROPIC_API_KEY)
|
||||
ANTHROPIC_SEARCH_BASE_URL - Anthropic web search base URL (override; pairs with ANTHROPIC_SEARCH_API_KEY)
|
||||
|
||||
${chalk.dim("# Configuration")}
|
||||
OMP_PROFILE - Named profile for isolated agent state (same as --profile)
|
||||
Use \`omp --profile <name> --alias <command>\` to create a shell shortcut for a profile
|
||||
PI_CODING_AGENT_DIR - Session storage directory (default: ~/${CONFIG_DIR_NAME}/agent)
|
||||
PI_PACKAGE_DIR - Override package directory (for Nix/Guix store paths)
|
||||
PI_SMOL_MODEL - Override smol/fast model (see --smol)
|
||||
PI_SLOW_MODEL - Override slow/reasoning model (see --slow)
|
||||
PI_PLAN_MODEL - Override planning model (see --plan)
|
||||
PI_NO_PTY - Disable PTY-based interactive bash execution
|
||||
For complete environment variable reference, see:
|
||||
${chalk.dim("docs/environment-variables.md")}
|
||||
${chalk.bold("Available Tools (default-enabled unless noted):")}
|
||||
read - Read file contents
|
||||
bash - Execute bash commands
|
||||
edit - Edit files with find/replace
|
||||
write - Write files (creates/overwrites)
|
||||
grep - Search file contents
|
||||
glob - Find files by glob pattern
|
||||
lsp - Language server protocol (code intelligence)
|
||||
python - Execute Python code (requires: ${APP_NAME} setup python)
|
||||
notebook - Edit Jupyter notebooks
|
||||
inspect_image - Analyze images with a vision model
|
||||
browser - Browser automation (Puppeteer)
|
||||
computer - Native host desktop capture and input (disabled by default)
|
||||
task - Launch sub-agents for parallel tasks
|
||||
todo - Manage todo/task lists
|
||||
web_search - Search the web
|
||||
ask - Ask user questions (interactive mode only)
|
||||
|
||||
${chalk.bold("Plugin Options:")}
|
||||
--plugin-dir <path> Load plugin from directory (repeatable)
|
||||
|
||||
${chalk.bold("Useful Commands:")}
|
||||
omp agents unpack - Export bundled subagents to ~/.omp/agent/agents (default)
|
||||
omp agents unpack --project - Export bundled subagents to ./.omp/agents`;
|
||||
}
|
||||
|
||||
export function printHelp(): void {
|
||||
process.stdout.write(
|
||||
`${chalk.bold(APP_NAME)} - AI coding assistant\n\n` +
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* — see `commands/complete.ts`. The flag→source mapping below is the only manual
|
||||
* knob and is keyed by flag name so it stays stable as flags are added.
|
||||
*/
|
||||
import type { ArgDescriptor, CliConfig, CommandCtor, FlagDescriptor } from "@oh-my-pi/pi-utils/cli";
|
||||
import type { ArgDescriptor, CliConfig, CommandMetadata, FlagDescriptor } from "@oh-my-pi/pi-utils/cli";
|
||||
import { BUILTIN_TOOL_NAMES } from "../tools/builtin-names";
|
||||
|
||||
export type Shell = "bash" | "zsh" | "fish";
|
||||
@@ -88,9 +88,9 @@ function argValue(desc: ArgDescriptor): ValueSource {
|
||||
return { kind: "file" };
|
||||
}
|
||||
|
||||
function buildFlags(Cmd: CommandCtor): CompletionFlag[] {
|
||||
function buildFlags(command: CommandMetadata): CompletionFlag[] {
|
||||
const out: CompletionFlag[] = [];
|
||||
const flags = Cmd.flags ?? {};
|
||||
const flags = command.flags ?? {};
|
||||
for (const name in flags) {
|
||||
const desc = flags[name];
|
||||
out.push({
|
||||
@@ -104,9 +104,9 @@ function buildFlags(Cmd: CommandCtor): CompletionFlag[] {
|
||||
return out;
|
||||
}
|
||||
|
||||
function buildArgs(Cmd: CommandCtor): CompletionArg[] {
|
||||
function buildArgs(command: CommandMetadata): CompletionArg[] {
|
||||
const out: CompletionArg[] = [];
|
||||
const args = Cmd.args ?? {};
|
||||
const args = command.args ?? {};
|
||||
for (const name in args) {
|
||||
const desc = args[name];
|
||||
out.push({ name, description: desc.description ?? "", value: argValue(desc) });
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
import { APP_NAME, CONFIG_DIR_NAME } from "@oh-my-pi/pi-utils/dirs";
|
||||
import chalk from "chalk";
|
||||
|
||||
export function getExtraHelpText(): string {
|
||||
return `${chalk.bold("Environment Variables:")}
|
||||
${chalk.dim("# Core Providers")}
|
||||
ANTHROPIC_API_KEY - Anthropic Claude models
|
||||
ANTHROPIC_OAUTH_TOKEN - Anthropic OAuth (takes precedence over API key)
|
||||
CLAUDE_CODE_USE_FOUNDRY - Enable Anthropic Foundry mode (uses Foundry endpoint + mTLS)
|
||||
FOUNDRY_BASE_URL - Anthropic Foundry base URL (e.g., https://<foundry-host>)
|
||||
ANTHROPIC_FOUNDRY_API_KEY - Anthropic token used as Authorization: Bearer <token> in Foundry mode
|
||||
ANTHROPIC_CUSTOM_HEADERS - Extra headers for Foundry or any custom ANTHROPIC_BASE_URL gateway (e.g., "user-id: USERNAME")
|
||||
CLAUDE_CODE_CLIENT_CERT - Client certificate (PEM path or inline PEM) for mTLS
|
||||
CLAUDE_CODE_CLIENT_KEY - Client private key (PEM path or inline PEM) for mTLS
|
||||
NODE_EXTRA_CA_CERTS - CA bundle path (or inline PEM) for server certificate validation
|
||||
OPENAI_API_KEY - OpenAI GPT models
|
||||
GEMINI_API_KEY - Google Gemini models
|
||||
COPILOT_GITHUB_TOKEN - GitHub Copilot
|
||||
|
||||
${chalk.dim("# Additional LLM Providers")}
|
||||
AZURE_OPENAI_API_KEY - Azure OpenAI models
|
||||
GROQ_API_KEY - Groq models
|
||||
CEREBRAS_API_KEY - Cerebras models
|
||||
XAI_API_KEY - xAI Grok models
|
||||
OPENROUTER_API_KEY - OpenRouter aggregated models
|
||||
KILO_API_KEY - Kilo Gateway models
|
||||
MISTRAL_API_KEY - Mistral models
|
||||
ZAI_API_KEY - z.ai models (ZhipuAI/GLM)
|
||||
UMANS_AI_CODING_PLAN_API_KEY - Umans AI Coding Plan models
|
||||
UMANS_WEBSEARCH_PROVIDER - Umans gateway web search backend (native or exa)
|
||||
MINIMAX_API_KEY - MiniMax models
|
||||
OPENCODE_API_KEY - OpenCode Zen/OpenCode Go models
|
||||
CURSOR_ACCESS_TOKEN - Cursor AI models
|
||||
AI_GATEWAY_API_KEY - Vercel AI Gateway
|
||||
WAFER_SERVERLESS_API_KEY - Wafer Serverless (pay-as-you-go)
|
||||
|
||||
${chalk.dim("# Cloud Providers")}
|
||||
AWS_PROFILE - AWS Bedrock (or AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY)
|
||||
GOOGLE_CLOUD_PROJECT - Google Vertex AI (requires GOOGLE_CLOUD_LOCATION)
|
||||
GOOGLE_APPLICATION_CREDENTIALS - Service account for Vertex AI
|
||||
|
||||
${chalk.dim("# Search & Tools")}
|
||||
EXA_API_KEY - Exa web search
|
||||
BRAVE_API_KEY - Brave web search
|
||||
PERPLEXITY_API_KEY - Perplexity web search API key (optional; anonymous fallback)
|
||||
PERPLEXITY_COOKIES - Perplexity web search (session cookie)
|
||||
TAVILY_API_KEY - Tavily web search
|
||||
TINYFISH_API_KEY - TinyFish web search
|
||||
FIRECRAWL_API_KEY - Firecrawl web search
|
||||
ANTHROPIC_SEARCH_API_KEY - Anthropic web search (override; isolates search from main ANTHROPIC_API_KEY)
|
||||
ANTHROPIC_SEARCH_BASE_URL - Anthropic web search base URL (override; pairs with ANTHROPIC_SEARCH_API_KEY)
|
||||
|
||||
${chalk.dim("# Configuration")}
|
||||
OMP_PROFILE - Named profile for isolated agent state (same as --profile)
|
||||
Use \`omp --profile <name> --alias <command>\` to create a shell shortcut for a profile
|
||||
PI_CODING_AGENT_DIR - Session storage directory (default: ~/${CONFIG_DIR_NAME}/agent)
|
||||
PI_PACKAGE_DIR - Override package directory (for Nix/Guix store paths)
|
||||
PI_SMOL_MODEL - Override smol/fast model (see --smol)
|
||||
PI_SLOW_MODEL - Override slow/reasoning model (see --slow)
|
||||
PI_PLAN_MODEL - Override planning model (see --plan)
|
||||
PI_NO_PTY - Disable PTY-based interactive bash execution
|
||||
For complete environment variable reference, see:
|
||||
${chalk.dim("docs/environment-variables.md")}
|
||||
${chalk.bold("Available Tools (default-enabled unless noted):")}
|
||||
read - Read file contents
|
||||
bash - Execute bash commands
|
||||
edit - Edit files with find/replace
|
||||
write - Write files (creates/overwrites)
|
||||
grep - Search file contents
|
||||
glob - Find files by glob pattern
|
||||
lsp - Language server protocol (code intelligence)
|
||||
python - Execute Python code (requires: ${APP_NAME} setup python)
|
||||
notebook - Edit Jupyter notebooks
|
||||
inspect_image - Analyze images with a vision model
|
||||
browser - Browser automation (Puppeteer)
|
||||
computer - Native host desktop capture and input (disabled by default)
|
||||
task - Launch sub-agents for parallel tasks
|
||||
todo - Manage todo/task lists
|
||||
web_search - Search the web
|
||||
ask - Ask user questions (interactive mode only)
|
||||
|
||||
${chalk.bold("Plugin Options:")}
|
||||
--plugin-dir <path> Load plugin from directory (repeatable)
|
||||
|
||||
${chalk.bold("Useful Commands:")}
|
||||
omp agents unpack - Export bundled subagents to ~/.omp/agent/agents (default)
|
||||
omp agents unpack --project - Export bundled subagents to ./.omp/agents`;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Thinking selectors accepted by the `--thinking` CLI flag, in display order.
|
||||
* Shared by help metadata, shell completions, and validation warnings.
|
||||
*/
|
||||
export const CLI_THINKING_LEVELS: readonly string[] = [
|
||||
"off",
|
||||
"minimal",
|
||||
"low",
|
||||
"medium",
|
||||
"high",
|
||||
"xhigh",
|
||||
"max",
|
||||
"auto",
|
||||
];
|
||||
Reference in New Issue
Block a user