Skip to content

Move CLI site data to dedicated config file#2731

Draft
bcotrim wants to merge 1 commit intostu-1350-decoupled-configfrom
stu-1350-decoupled-config-v1
Draft

Move CLI site data to dedicated config file#2731
bcotrim wants to merge 1 commit intostu-1350-decoupled-configfrom
stu-1350-decoupled-config-v1

Conversation

@bcotrim
Copy link
Contributor

@bcotrim bcotrim commented Mar 9, 2026

Related issues

How AI was used in this PR

TBD

Proposed Changes

Splits CLI site configuration from appdata-v1.json into a dedicated ~/.studio/cli.json file. Site data is now CLI-owned; Studio reads sites exclusively via studio site list and _events command, making the CLI the single source of truth.

Key changes:

  • New apps/cli/lib/cli-config.ts module handles CLI-specific site config (version 1, sites array)
  • Moved site helper functions: getSiteByFolder, getSiteUrl, updateSiteLatestCliPid, clearSiteLatestCliPid, updateSiteAutoStart, removeSite
  • Appdata now stores only: auth tokens, snapshots, locale, stats, beta features
  • Updated all site commands, utilities, and tests to use cli-config module
  • Separate lockfile at ~/.studio/cli.json.lock prevents blocking between site and auth operations

Architecture benefits:

  • Single source of truth: CLI owns site configuration
  • Reduced data corruption risk: less file I/O on appdata during site operations
  • Decoupled lifetime: site config persists independently of Studio internal state
  • Type-safe: Zod validation ensures schema compliance across versions

Testing Instructions

  1. Run all CLI tests: npm test -- apps/cli/
    • All 277 tests should pass
  2. Verify site commands work correctly:
    npm run cli:build
    node dist/cli/main.js site create --name "test-site"
    node dist/cli/main.js site list --format json
    node dist/cli/main.js site delete
  3. Check that sites are now stored in ~/.studio/cli.json instead of appdata
  4. Verify appdata still contains auth token and other non-site data

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

Split site data from appdata-v1.json into a new CLI-owned config at ~/.studio/cli.json.
Studio now reads sites exclusively via `studio site list` and _events. The CLI is the
source of truth for site configuration. Auth tokens, snapshots, locale remain in appdata.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
@bcotrim bcotrim self-assigned this Mar 9, 2026
@bcotrim bcotrim changed the base branch from trunk to stu-1350-decoupled-config March 9, 2026 22:07
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