fix(cli): scaffold embeddings section in config --init#1719
Conversation
buildInitTemplate() never included an embeddings block, so a fresh global config had no model/llmProvider/provider keys — including the provider field added in #1716 for the remote embedding backend. docs check acknowledged: this is a scaffold-only addition to an existing CLI command; docs/guides/configuration.md already documents the embeddings section in full, and no README/CLAUDE.md/ROADMAP.md content is affected. Impact: 1 functions changed, 2 affected
Greptile SummaryThis PR fixes a gap in
Confidence Score: 5/5Safe to merge — the change is a one-block addition to a template builder, with a well-isolated integration test that guards against CI path-resolution quirks. The fix directly references DEFAULTS.embeddings so it can never diverge from the actual schema defaults. The test pins the scaffolded file path via CODEGRAPH_USER_CONFIG and explicitly clears competing env vars, making the assertion deterministic on all platforms. No existing behaviour is altered. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["codegraph config --init"] --> B["handleInit()"]
B --> C{"File exists?"}
C -- Yes --> D["Exit with error"]
C -- No --> E["buildInitTemplate()"]
E --> F["llm block\n(provider, model, baseUrl,\napiKey, apiKeyCommand)"]
E --> G["embeddings block NEW\n(model, llmProvider, provider)"]
E --> H["query / build / ci / search blocks"]
F & G & H --> I["JSON.stringify(template)"]
I --> J["Write to CODEGRAPH_USER_CONFIG\nor XDG default path"]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A["codegraph config --init"] --> B["handleInit()"]
B --> C{"File exists?"}
C -- Yes --> D["Exit with error"]
C -- No --> E["buildInitTemplate()"]
E --> F["llm block\n(provider, model, baseUrl,\napiKey, apiKeyCommand)"]
E --> G["embeddings block NEW\n(model, llmProvider, provider)"]
E --> H["query / build / ci / search blocks"]
F & G & H --> I["JSON.stringify(template)"]
I --> J["Write to CODEGRAPH_USER_CONFIG\nor XDG default path"]
Reviews (2): Last reviewed commit: "fix: isolate CODEGRAPH_USER_CONFIG in co..." | Re-trigger Greptile |
Codegraph Impact Analysis1 functions changed → 2 callers affected across 1 files
|
The new "config --init scaffolds an embeddings section" test only overrode HOME/USERPROFILE for the spawned CLI process, but getDefaultUserConfigPath() checks XDG_CONFIG_HOME and (on Windows) APPDATA ahead of the HOME-derived fallback. Both are set ambiently on GitHub Actions hosted runners (XDG_CONFIG_HOME=/home/runner/.config on ubuntu-latest, APPDATA=...\runneradmin\AppData\Roaming on windows-2022), so --init wrote the scaffolded file outside the test's tmpHome and the follow-up read failed with ENOENT. Pin the target path explicitly via CODEGRAPH_USER_CONFIG (highest priority in the resolution order) and unset XDG_CONFIG_HOME/APPDATA for the spawned process, matching the isolation pattern already used in tests/unit/config-user.test.ts.
Summary
buildInitTemplate()insrc/cli/commands/config.tsnever included anembeddingsblock, socodegraph config --initscaffoldedllm,query,build,ci, andsearchbut omittedembeddingsentirely — including theproviderfield added in feat(search): configurable remote embedding provider for codegraph embed #1716 for the remote embedding backend.embeddingsblock (model,llmProvider,provider) mirroringDEFAULTS.embeddings, placed next tollmsince the remote provider option relies onllm.baseUrl/apiKeyCommand.Closes #1718
Test plan
Config CLI commands > config --init scaffolds an embeddings section alongside llmintests/integration/cli.test.ts, verifying the scaffolded file containsembeddings: { model: null, llmProvider: null, provider: null }npx vitest run tests/integration/cli.test.ts— 30/30 passednpx vitest run tests/unit/config.test.ts tests/unit/config-user.test.ts— 88/88 passednpm run lint— cleancodegraph diff-impact --staged -T— change contained tobuildInitTemplateand its 2 transitive callers