Skip to content

Commit f46f882

Browse files
committed
Use one model config setting and document config-first setup
1 parent 764c65d commit f46f882

12 files changed

Lines changed: 48 additions & 21 deletions

‎README.md‎

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ ctxt status
2626

2727
The first run creates `.ctxt/ctx_config.toml` and starts indexing right away. You can edit the config later; CLI flags override config values. Start `ctxt watch .` when you want a live index that follows file changes.
2828

29+
**Want to choose a model before indexing?** Run `ctxt config init` first,
30+
edit `model` under `[llm]` in `.ctxt/ctx_config.toml`, then run `ctxt init .`.
31+
See [config setup](#ctxt-config-init) for details.
32+
2933
LLM synonyms are optional. To enable them, set `OPENROUTER_API_KEY` in your shell or secret manager before running `ctxt init .`. Without a key, indexing still works with lexical matching.
3034

3135
## LLM flexibility
@@ -254,10 +258,27 @@ ctxt doctor --json
254258

255259
### `ctxt config init`
256260

257-
Create or overwrite `.ctxt/ctx_config.toml`:
261+
Create `.ctxt/ctx_config.toml` before indexing if you want to choose your model
262+
or customize ignore rules first:
263+
264+
```bash
265+
ctxt config init
266+
```
267+
268+
Edit `model` under `[llm]` in the generated file, then build the index:
269+
270+
```bash
271+
ctxt init .
272+
```
273+
274+
`--output` selects a different config path. Existing files are preserved;
275+
`--force` explicitly overwrites them with the starter defaults.
276+
277+
After indexing, changing the model does not invalidate cached synonyms. To
278+
regenerate synonyms with your saved model, run:
258279

259280
```bash
260-
ctxt config init --output .ctxt/ctx_config.toml
281+
ctxt sync . --force
261282
```
262283

263284
## Configuration
@@ -268,7 +289,6 @@ ctxt config init --output .ctxt/ctx_config.toml
268289
[common]
269290
output = ".ctxt/ctx_index.json"
270291
synonym_cache = ".ctxt/ctx_cache.json"
271-
llm_model = "deepseek/deepseek-v4-flash"
272292
batch_size = 8 # names per LLM request; 0 enables smart batching
273293
synonyms_min = 5 # min synonyms per name
274294
synonyms_max = 12 # max synonyms per name
@@ -287,6 +307,9 @@ parallel_requests = 10 # concurrent LLM batches
287307

288308
**LLM config resolution:** flag → config `api_key` → config `api_key_env` → `LLM_API_KEY` → `OPENROUTER_API_KEY`.
289309

310+
**Model selection:** `--llm-model` → `[llm].model` → built-in default. Set the
311+
saved model only under `[llm]`; `[common].llm_model` is not supported.
312+
290313
**Supported providers:** OpenRouter (default) and APIs that implement the
291314
OpenAI chat-completions request/response shape. The `provider` value labels
292315
the configuration; `endpoint` and `model` control the request.

‎command_config.go‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ func newConfigInitCommand() *cobra.Command {
1818
cmd := &cobra.Command{
1919
Use: "init",
2020
Short: "Create starter .ctxt/ctx_config.toml",
21+
Long: `Create the project config before indexing so you can choose your model and settings.
22+
23+
From the project root, run "ctxt config init", edit [llm].model in
24+
.ctxt/ctx_config.toml, then run "ctxt init ." to build the index.
25+
26+
Existing config files are preserved unless you pass --force.`,
2127
RunE: func(cmd *cobra.Command, args []string) error {
2228
target := outPath
2329
if target == "" {
@@ -27,6 +33,7 @@ func newConfigInitCommand() *cobra.Command {
2733
return err
2834
}
2935
LogInfof("Created starter config at %s", target)
36+
LogInfof("Edit [llm].model and other settings before indexing your project.")
3037
return nil
3138
},
3239
}

‎command_examples.go‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ func newExamplesCommand() *cobra.Command {
1313
Long: ``,
1414
Run: func(cmd *cobra.Command, args []string) {
1515
fmt.Print(`Setup:
16+
ctxt config init Create config to customize before indexing
1617
ctxt init . Build index for current project
17-
ctxt init . --model openai/gpt-4o Use specific model for synonyms
18+
ctxt init . --llm-model openai/gpt-4o Use specific model for synonyms
1819
1920
Search:
2021
ctxt search-hints "auth" Find auth-related files
@@ -37,7 +38,7 @@ Benchmarks:
3738
Inspection:
3839
ctxt status Show index stats
3940
ctxt doctor Health check
40-
ctxt config show View current config
41+
ctxt config --help See config setup options
4142
ctxt clean Remove all ctxt files
4243
`)
4344
},

‎command_init.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ Creates two files:
2121
2222
With an LLM API key, ctxt sends filenames + extracted imports to the LLM to generate domain-accurate synonyms. Without one, falls back to lexical splitting (pascalCase → "pascal case", snake_case → "snake case").
2323
24+
To choose your model before indexing, run "ctxt config init", edit [llm].model
25+
in .ctxt/ctx_config.toml, then run "ctxt init .".
26+
2427
Examples:
2528
ctxt init . Basic setup
26-
ctxt init . --model openai/gpt-4o Use specific LLM model
29+
ctxt init . --llm-model openai/gpt-4o Use specific LLM model
2730
ctxt init . --symbol-extractor treesitter Force tree-sitter (no regex fallback)
2831
ctxt init . --symbol-extractor regex Regex-only extraction
2932
ctxt init . --synonyms 8 Generate up to 8 synonyms per name

‎config.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ type ContextingConfig struct {
2121
type CommonConfig struct {
2222
OutputPath string `toml:"output"`
2323
SynonymCache string `toml:"synonym_cache"`
24-
Model string `toml:"llm_model"`
2524
APIKey string `toml:"api_key"`
2625
BatchSize int `toml:"batch_size"`
2726
SynonymsPerName int `toml:"synonyms"`

‎config_apply.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import "github.com/spf13/cobra"
55
func applyCommonConfig(cmd *cobra.Command, flags *CommonFlags, cfg CommonConfig) {
66
applyStringFlag(cmd, "output", &flags.OutputPath, cfg.OutputPath)
77
applyStringFlag(cmd, "synonym-cache", &flags.SynonymCache, cfg.SynonymCache)
8-
applyStringFlag(cmd, "llm-model", &flags.Model, cfg.Model)
98
applyStringFlag(cmd, "api-key", &flags.APIKey, cfg.APIKey)
109
applyIntFlag(cmd, "batch-size", &flags.BatchSize, cfg.BatchSize)
1110
applyIntFlag(cmd, "synonyms", &flags.SynonymsPerName, cfg.SynonymsPerName)

‎config_template.go‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package contexting
33
const starterConfigTemplate = `[common]
44
output = ".ctxt/ctx_index.json"
55
synonym_cache = ".ctxt/ctx_cache.json"
6-
llm_model = "deepseek/deepseek-v4-flash"
76
batch_size = 8 # names per batch; smaller = faster individual requests
87
synonyms_min = 5 # min synonyms per name
98
synonyms_max = 12 # max synonyms per name
@@ -22,10 +21,6 @@ model = "deepseek/deepseek-v4-flash"
2221
# api_key = "sk-..." # or use api_key_env for security
2322
api_key_env = "OPENROUTER_API_KEY" # read key from env var
2423
# max_tokens = 512
25-
# provider = "openrouter"
26-
# endpoint = "https://openrouter.ai/api/v1/chat/completions"
27-
# model = "deepseek/deepseek-v4-flash"
28-
# api_key_env = "OPENROUTER_API_KEY"
2924
3025
[init]
3126
root = "."

‎config_test.go‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ func TestLoadContextingConfig(t *testing.T) {
1414
content := `
1515
[common]
1616
output = "out/context.json"
17-
llm_model = "openai/gpt-oss-safeguard-20b"
1817
batch_size = 12
1918
ignore = ["dist", "build"]
2019
verbose = true
2120
21+
[llm]
22+
model = "openai/gpt-oss-safeguard-20b"
23+
2224
[watch]
2325
debounce = "2s"
2426
search_log = false
@@ -47,6 +49,9 @@ show_tokens = true
4749
if cfg.Common.BatchSize != 12 {
4850
t.Fatalf("unexpected batch size: %d", cfg.Common.BatchSize)
4951
}
52+
if cfg.LLM.Model != "openai/gpt-oss-safeguard-20b" {
53+
t.Fatalf("unexpected LLM model: %s", cfg.LLM.Model)
54+
}
5055
if cfg.Watch.Debounce != "2s" {
5156
t.Fatalf("unexpected debounce: %s", cfg.Watch.Debounce)
5257
}

‎context.toml.example‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[common]
22
output = ".ctxt/ctx_index.json"
33
synonym_cache = ".ctxt/ctx_cache.json"
4-
llm_model = "deepseek/deepseek-v4-flash"
54
batch_size = 8 # names per batch; 0 enables smart batching
65
synonyms_min = 5 # min synonyms per name
76
synonyms_max = 12 # max synonyms per name

‎docs/DEVELOPER_MANUAL.html‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,6 @@ <h3 id="config-file">ctx_config.toml</h3>
675675
[common]
676676
output = ".ctxt/ctx_index.json" <span class="cmt"># Index output path</span>
677677
synonym_cache = ".ctx/ctx_cache.json"
678-
llm_model = "deepseek/deepseek-v4-flash" <span class="cmt"># Default LLM model (overridden by [llm])</span>
679678
batch_size = 8 <span class="cmt"># 0 = smart batching</span>
680679
synonyms = 10 <span class="cmt"># Desired synonyms per name</span>
681680
ignore = [".git", "node_modules", ...] <span class="cmt"># Extra ignore patterns</span>

0 commit comments

Comments
 (0)