Skip to content

feat(onboarding): add env-fingerprint command for agent-driven setup - #19

Merged
ArkNill merged 2 commits into
mainfrom
feat/env-fingerprint
May 20, 2026
Merged

feat(onboarding): add env-fingerprint command for agent-driven setup#19
ArkNill merged 2 commits into
mainfrom
feat/env-fingerprint

Conversation

@ArkNill

@ArkNill ArkNill commented May 20, 2026

Copy link
Copy Markdown
Owner

Summary

First deliverable of the LLM-driven onboarding path (Path B): a single,
idempotent command that emits a structured snapshot of the user's local LLM
CLI environment, designed to be consumed by an agent automating an
llm-relay install on the user's behalf.

Background

Onboarding has two paths:

  • Path A (human-driven, secondary): llm-relay init walks the user
    through setup interactively. Already exists.
  • Path B (LLM-driven, primary focus): an agent (Claude Code / Codex /
    Gemini) reads a playbook + structured probes, and configures the user's
    environment itself. The agent needs structured, parseable input to make
    decisions -- not human-friendly text.

env-fingerprint is the first piece of Path B. Subsequent pieces
(ONBOARDING playbook, llm-relay verify {install,config,integration})
will land in follow-up PRs.

Output

llm-relay env-fingerprint [--format json|yaml] [--no-doctor] [--ports 8080,8083]

Sections (schema_version "1"):

Section Contents
llm_relay Package version + on-disk paths (db_dir, db_path, config_path, knowledge_dir)
clis Per-CLI install/version/auth/config_dir. Registry-keyed so unknown ids never appear and missing CLIs are explicit
ports free/in_use per probed TCP port
filesystem home, claude_home, projects_dir, session count, knowledge dir presence
env Relevant env vars; API keys redacted to set/empty/None so output is safe to paste into bug reports
doctor (optional) Summary + per-check status from run_doctor

Design notes

  • Pure collector: composes existing probes (setup_init._detect_clis,
    orch.discovery.discover_all, recover.doctor.run_doctor,
    detect.scanner). No duplicate detection logic.
  • Safe-call wrapping: each sub-probe is wrapped so a single failure
    produces an _error marker on its section without crashing the whole
    snapshot. Partial data is more useful to an agent than no data.
  • Idempotent: makes no changes to the user's environment. Safe to run
    repeatedly.
  • Schema versioning: SCHEMA_VERSION = "1". Adding new fields does not
    require a bump; agents should ignore unknown fields. Breaking changes bump
    the version.

Test coverage

tests/test_env_fingerprint.py (17 tests):

  • Schema shape, doctor toggle, port selection
  • CLI registry coverage (all three known ids appear even when binaries
    missing)
  • API-key redaction (set/empty/unset)
  • Sub-probe failure isolation
  • ISO timestamp with timezone
  • Schema contract guards

Full suite: 546 pass (529 baseline + 17 new). Ruff clean.

Smoke test

$ llm-relay env-fingerprint --no-doctor | jq '.clis | map({id, installed, auth: .auth.preferred})'
[
  { "id": "claude-code",   "installed": true, "auth": "cli_oauth" },
  { "id": "openai-codex",  "installed": true, "auth": "cli_oauth" },
  { "id": "gemini-cli",    "installed": true, "auth": "cli_oauth" }
]

What's next (separate PRs)

  • ONBOARDING playbook (docs/AGENT_SETUP.md or similar) — structured
    guideline that agents follow, with branch conditions and step/verify
    pairs.
  • llm-relay verify {install,config,integration} — idempotent verification
    primitives that both Path A and Path B share.

ArkNill added 2 commits May 20, 2026 16:22
Introduces the first deliverable of the LLM-driven onboarding path
(Path B): a single, idempotent command that emits a structured
snapshot of the user's local LLM CLI environment.

Designed to be consumed by an agent (Claude Code / Codex / Gemini)
that is automating an llm-relay install on the user's behalf. The
agent reads the JSON output and decides which install/configure
steps to take, rather than scraping the human-friendly `init`
output.

  llm-relay env-fingerprint [--format json|yaml] [--no-doctor]
                            [--ports 8080,8083]

Output sections (schema_version "1"):
  - llm_relay: package version + on-disk paths
  - clis: per-CLI install/version/auth/config_dir (registry-keyed,
    so unknown ids never appear and missing CLIs are explicit)
  - ports: free/in_use per probed TCP port
  - filesystem: home, claude_home, projects_dir, session count,
    knowledge dir presence
  - env: relevant env vars; API keys redacted to set/empty/None
    so the output can be safely pasted into a bug report
  - doctor (optional): summary + per-check status from run_doctor

The module is a pure collector that composes existing probes
(setup_init._detect_clis, orch.discovery.discover_all,
recover.doctor.run_doctor, detect.scanner) so it does not duplicate
detection logic and stays in sync with what the relay actually does.

Each sub-probe is wrapped in a safe-call so a single failure
produces an `_error` marker on its section without crashing the
whole snapshot -- partial data is more useful to an agent than no
data.

Tests cover: schema shape, doctor toggle, port selection, CLI
registry coverage, API-key redaction, sub-probe failure isolation,
ISO timestamp with timezone, schema contract.

This is foundational for the upcoming ONBOARDING playbook + verify
primitives that complete Path B.
Adds the env-fingerprint entry to CHANGELOG.md so the structured-
snapshot command is documented alongside the other Unreleased
changes. No code change.
@ArkNill
ArkNill merged commit 0e918be into main May 20, 2026
6 checks passed
@ArkNill
ArkNill deleted the feat/env-fingerprint branch May 20, 2026 08:44
cnighswonger pushed a commit to cnighswonger/llm-relay that referenced this pull request Jun 1, 2026
Third and final slice of Path B (LLM-driven onboarding). With
env-fingerprint (PR ArkNill#19) describing state and verify (PR ArkNill#20)
asserting expectations, this document sequences them into an
end-to-end install flow an agent can follow without scraping
human-friendly output.

Audience: AI coding agents (Claude Code / Codex / Gemini) running
an llm-relay setup on a user's behalf. The document is explicit
that it is NOT a human tutorial -- humans should use README.md and
`llm-relay init` directly.

Structure:

  Phase 0 — Probe (env-fingerprint)
  Phase 1 — Install or upgrade the package (with extras decision table)
  Phase 2 — Initialize local state (llm-relay init)
  Phase 3 — Per-CLI integration (claude-code / openai-codex / gemini-cli)
  Phase 4 — Optional: start the server (Linux/macOS vs Windows service)
  Phase 5 — Final acceptance (verify all)

Each phase ends with a `verify` call, and the playbook spells out how
to respond to pass / warn / fail outcomes.

Permission protocol:

The playbook never assumes consent for system-modifying actions. Five
explicit markers gate any operation that touches outside of read-only
probes:

  [PERMISSION: install-package]      pip install
  [PERMISSION: write-config]          llm-relay init (writes ~/.llm-relay/, edits ~/.claude/settings.json)
  [PERMISSION: edit-claude-settings] direct settings.json edit (last resort)
  [PERMISSION: fix-permissions]       chmod / chown on home dir files
  [PERMISSION: install-service]       Windows background service registration

"When to stop and ask" section enumerates ambiguous states (no CLI
installed, verify fail with no remediation, multiple Python
interpreters, etc.) where the agent must defer to the user instead
of improvising.

"What not to do" section pins down the agent's scope: do not modify
session transcripts, do not install LLM CLIs on the user's behalf,
do not auto-edit shell rc files, do not retry a failing remediation
more than once.

README updated with an "Agent-driven setup" section linking to the
playbook and showing the four entry-point commands.

CHANGELOG documents the playbook under Unreleased ### Added.

Schema contract: both env-fingerprint and verify use
schema_version "1"; the playbook calls out that an agent should
fall back to the in-tree playbook for whatever release it has
installed if the schema version differs.
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.

1 participant