Skip to content

refactor: unify config to ~/.codeblog/config.json#54

Merged
Kadxy merged 3 commits into
mainfrom
refactor/consolidate-config
Feb 24, 2026
Merged

refactor: unify config to ~/.codeblog/config.json#54
Kadxy merged 3 commits into
mainfrom
refactor/consolidate-config

Conversation

@Kadxy

@Kadxy Kadxy commented Feb 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Consolidate three config files into one (~/.codeblog/config.json) with nested schema: { serverUrl, dailyReportHour, auth: { apiKey, activeAgent, userId }, cli: { model, providers, ... } }
  • Fix stale auth after re-login (After switching accounts, CodeBlog still posts with the old account #28): Auth module now writes directly to the same file MCP reads — no more broken callTool("codeblog_setup") sync attempts
  • Migrate config path from ~/.config/codeblog/ to ~/.codeblog/ (Claude Code convention)
  • Standardize field names to camelCase across the board (was snake_case)
  • Add deepMerge with undefined-deletes semantics so Auth.remove() properly clears fields without nuking unrelated sections
  • Logout now disconnects MCP + clears tool cache to force fresh credentials on next connect

Breaking change

Requires codeblog-mcp to be updated to read the new nested config format before this can be released. See MCP_MIGRATION_PLAN.md in this PR for the exact changes needed in that repo.

Files changed (26)

Area Files What changed
Core global/index.ts, config/index.ts, auth/index.ts New config path + schema + Auth as thin proxy
Auth oauth.ts, login.ts, logout.ts, commands.ts Remove broken callTool, add MCP disconnect on logout
CLI setup.ts, config.ts, daily.ts Field name migration to camelCase + nested paths
AI provider.ts, provider-registry.ts, configure.ts, types.ts, models.ts, codeblog-provider.ts Read/write new nested cli.providers.* fields
TUI app.tsx, commands.ts, home.tsx, model.tsx Config field access updated
Tests config.test.ts (new), provider-registry.test.ts, compat.test.ts, provider.test.ts 23 new config tests + existing tests migrated to new schema
Docs README.md, architecture.md, install.sh, install.ps1 Updated paths and schema examples

Test plan

  • bun test — 118 tests pass (95 existing + 23 new config tests)
  • MCP repo updated and published first
  • bun install with new codeblog-mcp version
  • codeblog setup → verify ~/.codeblog/config.json has correct nested structure
  • Logout → Login → /config → confirm MCP reads new key
  • Agent switch → confirm auth.apiKey updated

Refs #28, #48

🤖 Generated with Claude Code

Kadxy and others added 3 commits February 24, 2026 13:15
Auth/config was split across three files causing stale credentials
after re-login (MCP tools kept using old API key from a different
file than what OAuth login updated):

- ~/.codeblog/config.json (MCP server: apiKey, activeAgent, userId)
- ~/.config/codeblog/config.json (CLI: providers, model, flags)
- ~/.local/share/codeblog/auth.json (Auth: type, value, username)

Now everything lives in ~/.codeblog/config.json with nested schema:

  { serverUrl, dailyReportHour, auth: { apiKey, ... }, cli: { model, providers, ... } }

Key changes:
- Global.Path.config → ~/.codeblog/ (was ~/.config/codeblog/)
- Auth module → thin proxy over Config (no more auth.json)
- Config module → deep merge with undefined-deletes-field semantics
- All field names → camelCase (was snake_case)
- Remove broken McpBridge.callTool("codeblog_setup", {api_key}) calls
- Logout now disconnects MCP + clears tool cache
- Tests and docs updated to match new schema

Requires codeblog-mcp to be updated to read nested config format
before this can be released. See MCP_MIGRATION_PLAN.md.

Refs #28, #48

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Config is dynamically imported at runtime, so the namespace isn't
available for type assertions at compile time. The casts were
unnecessary since Config.save accepts Partial<CodeblogConfig>.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Provides autocomplete and validation in VS Code / Cursor when
editing the config file. Reference via "$schema" field:

  { "$schema": "https://codeblog.ai/schemas/config.json", ... }

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@Kadxy

Kadxy commented Feb 24, 2026

Copy link
Copy Markdown
Collaborator Author

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

@Kadxy
Kadxy merged commit 905c5f0 into main Feb 24, 2026
4 checks passed
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