feat(settings): scaffold default settings.json on first run#203
Open
kuishou68 wants to merge 1 commit into
Open
feat(settings): scaffold default settings.json on first run#203kuishou68 wants to merge 1 commit into
kuishou68 wants to merge 1 commit into
Conversation
A fresh install has no ~/.deepcode/settings.json, so the first task fails with "API key not found" and the user must create the file by hand while guessing the schema. Add ensureUserSettingsFile(), which writes a template settings file with an empty API_KEY and default BASE_URL/MODEL when none exists, and never overwrites an existing file. The CLI calls it on startup (after the TTY check) and tells the user where to set their key. Covered by unit tests for both the create and the never-overwrite paths.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Closes #202.
A fresh install has no
~/.deepcode/settings.json, so the first task fails with:The message says "configure" the file, but it does not exist — the user has to create it from scratch and guess the schema. Settings are only ever read on startup; nothing scaffolds the file on first run.
Change
packages/core/src/settings.tsbuildDefaultSettings()— returns the template (env.API_KEY = "",BASE_URL = DEFAULT_BASE_URL,MODEL = DEFAULT_MODEL).ensureUserSettingsFile()— writes that template to the user settings path when missing; returns{ path, created }. Never overwrites an existing file.packages/core/src/index.ts— export both helpers from the public API.packages/cli/src/cli.tsx— callensureUserSettingsFile()on startup (after the TTY check, before the TUI renders). When a file is newly created, print where it is and remind the user to setAPI_KEY. Failures are caught and reported without blocking startup.After this change the first run leaves the user with a ready-to-edit config file; they only paste their key instead of authoring the file by hand.
Tests
Added to
packages/core/src/tests/settings-and-notify.test.ts(run against a tempHOME):buildDefaultSettings()),Verification
npm run typecheck— passesnpm run lint/prettier --check— clean on changed filesnpm run test --workspace @vegamo/deepcode-core— 248 passing, 0 failing (incl. the 2 new tests)Notes
settings.jsonare untouched (the file is only written when absent).API_KEYis empty, so the existing "API key not found" guard still applies until the user fills it in — now they have an obvious file to edit.