Skip to content

Commit 5356630

Browse files
committed
docs(config): document codeiq.yml, resolution order, and migration from .osscodeiq.yml
1 parent b88bb9b commit 5356630

3 files changed

Lines changed: 223 additions & 28 deletions

File tree

CLAUDE.md

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -367,18 +367,46 @@ mvn dependency-check:check
367367

368368
## Configuration
369369

370-
### Application properties (`application.yml`)
371-
- `codeiq.root-path` -- codebase root (default: `.`)
372-
- `codeiq.cache-dir` -- cache directory name (default: `.code-intelligence`)
373-
- `codeiq.graph.path` -- Neo4j graph path (default: `.osscodeiq/graph.db`)
374-
- `codeiq.max-radius` -- max ego graph radius (default: 10)
375-
- `codeiq.max-depth` -- max impact trace depth (default: 10)
376-
- `codeiq.batch-size` -- files per H2 flush batch (default: 500)
377-
- `codeiq.neo4j.enabled` -- Neo4j conditional toggle (default: `true`, overridden to `false` in `indexing` profile)
378-
- `spring.ai.mcp.server.protocol` -- MCP protocol (STREAMABLE)
379-
380-
### Project-level overrides (`.osscodeiq.yml`)
381-
Placed in the codebase root, loaded by `ProjectConfigLoader` before analysis.
370+
Single source of truth: **`codeiq.yml`** at the repo root. See
371+
`docs/codeiq.yml.example` for the full schema (snake_case throughout;
372+
camelCase accepted as a deprecated alias for one release). Resolution order
373+
(last wins):
374+
375+
1. Built-in defaults (`ConfigDefaults.builtIn()`)
376+
2. `~/.codeiq/config.yml` (user-global)
377+
3. `./codeiq.yml` (project)
378+
4. `CODEIQ_<SECTION>_<KEY>` env vars (e.g. `CODEIQ_SERVING_PORT=9090`)
379+
5. CLI flags on `code-iq <command>`
380+
381+
Validate and introspect with:
382+
383+
```bash
384+
code-iq config validate
385+
code-iq config explain
386+
```
387+
388+
### Spring-owned keys (stay in `application.yml`)
389+
390+
A small set of keys still lives in `src/main/resources/application.yml`
391+
because they drive Spring's `@ConditionalOnProperty` / `@Value` wiring and
392+
have not been migrated into `codeiq.yml`:
393+
394+
- `codeiq.neo4j.enabled` -- profile-conditional toggle (`false` in the
395+
`indexing` profile, `true` in `serving`).
396+
- `codeiq.neo4j.bolt.port` -- embedded Neo4j Bolt listener port.
397+
- `codeiq.cors.allowed-origin-patterns` -- CORS allow-list for the REST API.
398+
- `codeiq.ui.enabled` -- toggles the React SPA static resource handler.
399+
400+
`UnifiedConfigBeans` bridges the unified config to the legacy `CodeIqConfig`
401+
bean for code paths that haven't been ported yet.
402+
403+
### `.osscodeiq.yml` deprecation
404+
405+
`.osscodeiq.yml` is deprecated. `ProjectConfigLoader` still loads it for one
406+
release, translates its legacy flat keys into the unified nested shape, and
407+
logs a one-time WARN per canonical path. Rename to `codeiq.yml` and migrate
408+
flat keys into the `project:` / `indexing:` / `serving:` / `mcp:` /
409+
`observability:` / `detectors:` sections.
382410

383411
## Gotchas & Lessons Learned
384412

README.md

Lines changed: 85 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -157,31 +157,100 @@ java -jar code-iq-*-cli.jar serve /shared
157157

158158
## Configuration
159159

160-
Create `.osscodeiq.yml` in your repo root to customize the pipeline:
160+
code-iq is configured by a single YAML file at the repo root: **`codeiq.yml`**.
161+
Every field is optional; omitted fields fall back to the in-code defaults
162+
(`ConfigDefaults.builtIn()`). See
163+
[`docs/codeiq.yml.example`](docs/codeiq.yml.example) for the full reference
164+
with inline documentation. All keys are **snake_case**; camelCase spellings
165+
are accepted as deprecated aliases for one release and log a WARN on load.
166+
167+
### Resolution order (last wins)
168+
169+
1. Built-in defaults
170+
2. `~/.codeiq/config.yml` (user-global)
171+
3. `./codeiq.yml` (project)
172+
4. Environment variables: `CODEIQ_<SECTION>_<KEY>` (e.g. `CODEIQ_SERVING_PORT=9090`,
173+
`CODEIQ_MCP_AUTH_MODE=bearer`, `CODEIQ_INDEXING_BATCH_SIZE=1000`). Nested
174+
keys are flattened with underscores; values parse as YAML scalars.
175+
5. CLI flags on `code-iq <command>`
176+
177+
### Commands
178+
179+
```bash
180+
code-iq config validate # Validate ./codeiq.yml, exit 1 on error
181+
code-iq config validate -p custom.yml
182+
code-iq config explain # Print each effective value + its source layer
183+
```
184+
185+
### Minimal example
161186

162187
```yaml
188+
project:
189+
name: my-service
190+
root: .
191+
192+
indexing:
193+
exclude: ['**/node_modules/**', '**/build/**', '**/dist/**']
194+
cache_dir: .code-iq/cache
195+
batch_size: 500
196+
197+
serving:
198+
port: 8080
199+
bind_address: 0.0.0.0
200+
201+
mcp:
202+
enabled: true
203+
transport: http
204+
```
205+
206+
### Spring-owned keys (stay in `application.yml`)
207+
208+
A handful of keys drive Spring's `@ConditionalOnProperty` / `@Value` wiring
209+
and have not been migrated into `codeiq.yml`. Keep them in
210+
`src/main/resources/application.yml`:
211+
212+
- `codeiq.neo4j.enabled` -- profile-conditional Neo4j toggle (`false` under
213+
the `indexing` profile, `true` under `serving`).
214+
- `codeiq.neo4j.bolt.port` -- embedded Neo4j Bolt listener port.
215+
- `codeiq.cors.allowed-origin-patterns` -- CORS allow-list for the REST API.
216+
- `codeiq.ui.enabled` -- toggles the React SPA static resource handler.
217+
218+
Everything else belongs in `codeiq.yml`. `UnifiedConfigBeans` bridges the
219+
two worlds for values that exist in both.
220+
221+
### Migration from `.osscodeiq.yml`
222+
223+
`.osscodeiq.yml` is deprecated. code-iq still loads it for one release via
224+
`ProjectConfigLoader`, translates its legacy flat keys into the unified
225+
shape, and logs a one-time WARN per path. Rename the file to `codeiq.yml`
226+
and restructure flat keys into the nested sections.
227+
228+
**Before** (`.osscodeiq.yml`, legacy flat schema):
229+
230+
```yaml
231+
languages: [java, typescript, yaml]
232+
exclude:
233+
- '**/node_modules/**'
234+
- '**/build/**'
163235
pipeline:
164236
parallelism: 4
165237
batch-size: 500
238+
batch_size: 500
239+
```
166240

167-
languages:
168-
- java
169-
- typescript
170-
- yaml
171-
172-
detectors:
173-
categories:
174-
- endpoints
175-
- entities
176-
- auth
177-
- config
241+
**After** (`codeiq.yml`, unified snake_case schema):
178242

179-
exclude:
180-
- "**/node_modules/**"
181-
- "**/build/**"
243+
```yaml
244+
indexing:
245+
languages: [java, typescript, yaml]
246+
exclude:
247+
- '**/node_modules/**'
248+
- '**/build/**'
249+
parallelism: 4
250+
batch_size: 500
182251
```
183252

184-
Or auto-generate a config: `code-iq plugins suggest /path/to/repo`
253+
See `docs/codeiq.yml.example` for the full schema.
185254

186255
## Graph Model
187256

docs/codeiq.yml.example

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# docs/codeiq.yml.example
2+
#
3+
# Authoritative reference for `codeiq.yml` (Phase B unified config).
4+
#
5+
# - Place this file as `codeiq.yml` at the repo root.
6+
# - Every field is optional; omitted fields fall back to the built-in defaults
7+
# (see `ConfigDefaults.builtIn()`).
8+
# - All keys are snake_case. camelCase spellings (e.g. `cacheDir`, `batchSize`,
9+
# `bindAddress`, `pageCacheMb`, `perToolTimeoutMs`, `logFormat`) are accepted
10+
# as deprecated aliases for one release and emit a WARN on load. Do not use
11+
# camelCase in new config.
12+
# - Run `code-iq config validate` to type-check your file, and
13+
# `code-iq config explain` to print every effective value and the layer it
14+
# was resolved from.
15+
16+
# ---------------------------------------------------------------------------
17+
# project
18+
# ---------------------------------------------------------------------------
19+
project:
20+
name: my-service # human-readable identifier; defaults to null
21+
root: . # codebase root, relative to this file (default: ".")
22+
service_name: my-service # override for the emitted SERVICE node name
23+
modules: [] # optional list of sub-modules (Phase C). Example:
24+
# - path: services/api
25+
# type: maven # maven | gradle | npm | pnpm | pip | go | cargo | ...
26+
# name: api
27+
# kind: service # service | library | tool | infra
28+
29+
# ---------------------------------------------------------------------------
30+
# indexing
31+
# ---------------------------------------------------------------------------
32+
indexing:
33+
languages: [] # allow-list; empty = detect all supported languages
34+
include: [] # glob allow-list; empty = include everything discovered
35+
exclude: # glob deny-list; applied after `include`
36+
- '**/node_modules/**'
37+
- '**/build/**'
38+
- '**/dist/**'
39+
- '**/generated/**'
40+
incremental: true # reuse H2 cache when file hashes match
41+
cache_dir: .code-iq/cache # H2 analysis cache directory
42+
parallelism: auto # "auto" or a positive integer
43+
batch_size: 500 # files per H2 flush batch (default: 500)
44+
max_depth: 10 # max impact-trace depth
45+
max_radius: 10 # max ego-graph radius
46+
max_files: null # null = no cap; positive int to bound discovery
47+
max_snippet_lines: null # null = use CodeIqConfig default
48+
49+
# ---------------------------------------------------------------------------
50+
# serving
51+
# ---------------------------------------------------------------------------
52+
serving:
53+
port: 8080 # HTTP port for REST + MCP + UI
54+
bind_address: 0.0.0.0 # interface to bind; 127.0.0.1 for localhost-only
55+
read_only: false # must be false in non-prod; CI gate enforces this
56+
neo4j:
57+
dir: .code-iq/graph/graph.db # embedded Neo4j data directory
58+
page_cache_mb: 256 # Neo4j page cache (MB)
59+
heap_initial_mb: 256 # JVM -Xms for Neo4j (MB)
60+
heap_max_mb: 1024 # JVM -Xmx for Neo4j (MB)
61+
62+
# ---------------------------------------------------------------------------
63+
# mcp (Model Context Protocol server)
64+
# ---------------------------------------------------------------------------
65+
mcp:
66+
enabled: true # expose MCP tools via the serving layer
67+
transport: http # http | stdio
68+
base_path: /mcp # HTTP path prefix when transport=http
69+
auth:
70+
mode: none # none (default) | bearer | mtls
71+
token_env: CODEIQ_MCP_TOKEN # env var read when mode=bearer
72+
limits:
73+
per_tool_timeout_ms: 15000 # hard cap per tool invocation
74+
max_results: 500 # cap on result rows returned per tool
75+
max_payload_bytes: 2000000 # cap on single response body (bytes)
76+
rate_per_minute: 300 # per-client rate limit
77+
tools:
78+
enabled: ['*'] # allow-list of tool names; '*' = all
79+
disabled: [] # deny-list wins over `enabled`
80+
81+
# ---------------------------------------------------------------------------
82+
# observability
83+
# ---------------------------------------------------------------------------
84+
observability:
85+
metrics: true # expose Micrometer/Prometheus metrics
86+
tracing: false # emit OTLP spans (off by default)
87+
log_format: json # json | text
88+
log_level: info # trace | debug | info | warn | error
89+
90+
# ---------------------------------------------------------------------------
91+
# detectors
92+
# ---------------------------------------------------------------------------
93+
detectors:
94+
profiles: [default] # named detector bundles to activate
95+
overrides: # per-detector feature flags, keyed by SimpleClassName
96+
SpringRestDetector: { enabled: true }
97+
QuarkusRestDetector: { enabled: true }
98+
# MicronautRestDetector: { enabled: false }

0 commit comments

Comments
 (0)