From 6894c43e65b83536da0324a083f8a0b033a96c19 Mon Sep 17 00:00:00 2001 From: Fixture Date: Sat, 5 Sep 2026 15:47:19 +0900 Subject: [PATCH] docs: generate env and CLI reference tables from source README carried a hand-written environment-variable table (12 rows, including AGENTDESK_SERVER_PORT which the binary never reads) and a CLI Reference block that had drifted from src/cli/args.rs (19 subcommands missing, a `--flavor dev` value that does not exist). Both are now generated from the source tree: - scripts/generate_env_reference.py -> docs/generated/env-reference.md Collects env::var / env::var_os / std::env::var literal reads, const-defined AGENTDESK_*/ADK_* names (including indirect env::var(CONST) reads), *env* helper calls, and tracing EnvFilter::from_default_env (RUST_LOG). Excludes tests.rs, src/**/tests/, and #[cfg(test)] modules. Sorted by name; one-sentence description from the nearest comment naming the variable. - scripts/generate_cli_reference.py -> docs/generated/cli-reference.md Parses the clap derive items (Parser/Subcommand/Args/ValueEnum) without a cargo build and renders every command, nested subcommand, flag, positional, value-enum choices, defaults, after_help and cfg/hide notes. The unit test asserts the derived top-level list equals the clap snapshot test in args.rs. - README links to both documents and keeps only a short "commonly used" list. - scripts/ci-script-checks.sh regenerates both docs, runs their unit tests, and reuses the existing `git diff --exit-code` tracked-doc gate so drift fails the PR. docs/generated/README.md records the exception to the warning-only drift policy. Co-Authored-By: Claude Fable 5.1 --- README.md | 102 +-- docs/generated/README.md | 9 + docs/generated/cli-reference.md | 1209 ++++++++++++++++++++++++++ docs/generated/env-reference.md | 138 +++ scripts/ci-script-checks.sh | 16 +- scripts/generate_cli_reference.py | 865 ++++++++++++++++++ scripts/generate_env_reference.py | 442 ++++++++++ tests/test_generate_cli_reference.py | 92 ++ tests/test_generate_env_reference.py | 117 +++ 9 files changed, 2914 insertions(+), 76 deletions(-) create mode 100644 docs/generated/cli-reference.md create mode 100644 docs/generated/env-reference.md create mode 100644 scripts/generate_cli_reference.py create mode 100644 scripts/generate_env_reference.py create mode 100644 tests/test_generate_cli_reference.py create mode 100644 tests/test_generate_env_reference.py diff --git a/README.md b/README.md index 072ed60313..50eb6424f4 100644 --- a/README.md +++ b/README.md @@ -446,21 +446,16 @@ AgentDesk keeps settings in multiple surfaces on purpose. The contract is per-su ### Environment Variables -| Variable | Purpose | -|----------|---------| -| `AGENTDESK_ROOT_DIR` | Override runtime directory (default: `~/.adk/release`) | -| `AGENTDESK_CONFIG` | Override config file path | -| `AGENTDESK_REPO_DIR` | Override resolved AgentDesk repo path used by `git`/`gh` exec helpers | -| `AGENTDESK_SERVER_PORT` | Override HTTP server port (default: 8791) | -| `AGENTDESK_INSTALL_PORT` | Override the macOS installer-created config port; sandbox install roots derive a non-8791 loopback port by default | -| `AGENTDESK_API_URL` | Override base URL the CLI client uses to reach the local API | -| `AGENTDESK_TOKEN` | Optional Discord bot token forwarded to `dcserver` at startup. **Not** used by `discord-send*` CLI commands (those load configured bot tokens via the wizard, or require `--key`) and **not** used for `/api/*` auth — that comes from `server.auth_token` in `agentdesk.yaml` | -| `AGENTDESK_DCSERVER_LABEL` | Override launchd service label | -| `AGENTDESK_STATUS_INTERVAL_SECS` | Status polling interval (default: 5) | -| `AGENTDESK_TURN_TIMEOUT_SECS` | Turn watchdog timeout in seconds (default: 3600) | -| `AGENTDESK_HEADLESS_DISCORD_NONCE` | Opt in (`1` or `true`) to an enforced Discord nonce for trusted durable `headless_turn` outbox rows on the <=2,000-character manual/v3 inline path. Default is off. Retries of one parsed positive row ID reuse the same nonce, but Discord applies duplicate suppression only within its bounded recent-nonce retention window; this is not indefinite deduplication, and oversize attachment/chunk paths are outside this rollout. | -| `AGENTDESK_GH_PATH` / `AGENTDESK_CODEX_PATH` / `AGENTDESK_GEMINI_PATH` | Override resolved provider/CLI binary paths | -| `RUST_LOG` | Standard tracing filter (default: `agentdesk=info`) | +The full list of environment variables the binary reads is generated from the +source tree: see [docs/generated/env-reference.md](docs/generated/env-reference.md) +(regenerate with `python3 scripts/generate_env_reference.py`; CI fails when it +drifts). The most commonly used ones: + +- `AGENTDESK_ROOT_DIR` — runtime directory (default: `~/.adk/release`) +- `AGENTDESK_CONFIG` — config file path +- `AGENTDESK_API_URL` — base URL the CLI client uses to reach the local API +- `AGENTDESK_TOKEN` — optional Discord bot token forwarded to `dcserver` at startup. **Not** used by `discord-send*` CLI commands and **not** used for `/api/*` auth (that comes from `server.auth_token` in `agentdesk.yaml`) +- `RUST_LOG` — standard tracing filter (default: `agentdesk=info`) ## Customization @@ -631,73 +626,30 @@ Each agent maps to a Discord channel where it receives and responds to tasks. ## CLI Reference +Every subcommand, nested subcommand, flag, and positional argument is generated +from the clap definitions in `src/cli/args.rs`: see +[docs/generated/cli-reference.md](docs/generated/cli-reference.md) (regenerate +with `python3 scripts/generate_cli_reference.py`; CI fails when it drifts). +`agentdesk --help` and `agentdesk --help` print the same information +at runtime. + +Frequently used entry points: + ``` -# Server agentdesk dcserver # Start Discord control plane agentdesk init # Interactive setup wizard -agentdesk reconfigure # Re-run setup (preserves data) -agentdesk restart-dcserver # Graceful restart with crash context -agentdesk doctor [--json] [--profile quick|deep|security] -agentdesk doctor --fix --allow-restart # Explicit service restart repair -agentdesk doctor --fix --repair-sqlite-cache # Explicit legacy SQLite cache repair -agentdesk emit-launchd-plist --flavor release|dev [--label