Skip to content

fix(cli): scaffold embeddings section in config --init#1719

Merged
carlos-alm merged 2 commits into
mainfrom
fix/config-init-embeddings-1718
Jul 2, 2026
Merged

fix(cli): scaffold embeddings section in config --init#1719
carlos-alm merged 2 commits into
mainfrom
fix/config-init-embeddings-1718

Conversation

@carlos-alm

Copy link
Copy Markdown
Contributor

Summary

  • buildInitTemplate() in src/cli/commands/config.ts never included an embeddings block, so codegraph config --init scaffolded llm, query, build, ci, and search but omitted embeddings entirely — including the provider field added in feat(search): configurable remote embedding provider for codegraph embed #1716 for the remote embedding backend.
  • Adds an embeddings block (model, llmProvider, provider) mirroring DEFAULTS.embeddings, placed next to llm since the remote provider option relies on llm.baseUrl/apiKeyCommand.

Closes #1718

Test plan

  • Added Config CLI commands > config --init scaffolds an embeddings section alongside llm in tests/integration/cli.test.ts, verifying the scaffolded file contains embeddings: { model: null, llmProvider: null, provider: null }
  • npx vitest run tests/integration/cli.test.ts — 30/30 passed
  • npx vitest run tests/unit/config.test.ts tests/unit/config-user.test.ts — 88/88 passed
  • npm run lint — clean
  • codegraph diff-impact --staged -T — change contained to buildInitTemplate and its 2 transitive callers

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-apps

greptile-apps Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a gap in codegraph config --init where buildInitTemplate() produced a scaffolded config that omitted the embeddings section entirely, leaving users unaware of the remote-provider option introduced in #1716.

  • Adds an embeddings: { model, llmProvider, provider } block to buildInitTemplate(), directly mirroring DEFAULTS.embeddings and placed adjacent to llm since the remote provider relies on llm.baseUrl/apiKeyCommand.
  • Adds an integration test that pins CODEGRAPH_USER_CONFIG and clears XDG_CONFIG_HOME/APPDATA to avoid CI path-resolution divergence, then verifies the scaffolded file contains the expected null-initialised embeddings block.

Confidence Score: 5/5

Safe 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

Filename Overview
src/cli/commands/config.ts Adds the missing embeddings block to buildInitTemplate(), correctly reading all three fields from DEFAULTS.embeddings and placing the block between llm and query as intended.
tests/integration/cli.test.ts New integration test carefully isolates the file-system side-effects of --init using CODEGRAPH_USER_CONFIG, unsetting XDG_CONFIG_HOME and APPDATA to stay correct on CI runners, and asserts the exact shape of the scaffolded embeddings block.

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"]
Loading
%%{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"]
Loading

Reviews (2): Last reviewed commit: "fix: isolate CODEGRAPH_USER_CONFIG in co..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Codegraph Impact Analysis

1 functions changed2 callers affected across 1 files

  • buildInitTemplate in src/cli/commands/config.ts:110 (2 transitive callers)

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.
@carlos-alm carlos-alm merged commit 597ed1c into main Jul 2, 2026
22 checks passed
@carlos-alm carlos-alm deleted the fix/config-init-embeddings-1718 branch July 2, 2026 05:40
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: codegraph config --init scaffold omits the embeddings section entirely

1 participant