Skip to content

Credentials are project-local only — running any command from another directory silently "logs you out" #53

Description

@dark-sorceror

Summary

traceroot login writes credentials to ./.traceroot/config.json relative to the current working directory, and discovery reads exactly $CWD/.traceroot/config.json — no upward walk toward the git root, no home-directory fallback. Run any command from a different directory (even a subdirectory of the same repo) and the CLI reports No API key found. Run 'traceroot login' with no hint that the user is logged in — one directory over. Most developer CLIs log in globally, so this reads as "my login didn't stick."

Related documentation bug: src/config/schema.ts:2 claims the config lives at ~/.traceroot/config.json — a location the CLI never reads or writes.

Current behavior

  1. In a project directory: traceroot login → writes ./.traceroot/config.json (0600, auto-gitignored).
  2. cd subdir && traceroot traces listerror: No API key found. Run 'traceroot login', or set TRACEROOT_API_KEY, or pass --api-key.
  3. Nothing in the error says credentials are per-directory or where the CLI looked.

Where this lives:

  • configPath() resolves: explicit argument → TRACEROOT_CONFIG_PATHjoin(process.cwd(), ".traceroot", "config.json") (src/config/manager.ts:20-29). No other candidate location, no ancestor search. The auto-discovered .env fallback is equally CWD-only.
  • The "No API key found" error (src/commands/shared.ts:25-29) never states which path was checked.
  • src/config/schema.ts:2 docstring contradicts src/config/manager.ts:13-19.

Proposal

  1. Keep project-local as the primary (it's genuinely useful for multi-project users), but add a global fallback — ~/.config/traceroot/config.json — read when no project-local config resolves. Alternatively or additionally: walk upward from $CWD to the nearest .traceroot/config.json, bounded by the git root, so subdirectories of a logged-in project just work.
  2. When resolution fails, say where the CLI looked and that config is per-directory, e.g. No API key found. Looked for ./.traceroot/config.json (config is stored per-directory). Run 'traceroot login' here, set TRACEROOT_API_KEY, or pass --api-key.
  3. Fix the schema.ts docstring.

Impact

  • Day-one onboarding trap: the first cd after login appears to destroy the session; status fails the same way with no breadcrumb.
  • Trains users to re-enter their API key repeatedly, scattering key copies across directories.

Acceptance criteria

  • With a config written in directory A and no other credential source, commands run elsewhere resolve credentials from the global fallback (or, with the upward-walk approach, from any subdirectory of A).
  • Precedence is documented and tested: flags > --env-file > env vars > project-local config > global config (> auto .env), with status/doctor reporting which source and path won.
  • The "No API key found" error names the path(s) checked.
  • src/config/schema.ts no longer claims ~/.traceroot/config.json.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions