Repository navigation
v0.1.4
Patch Changes
-
#8
889ed5bThanks @SutuSebastian! - Query CLI-
codemap query --json: print a JSON array of result rows to stdout (and{"error":"…"}on SQL errors) for agents and automation. Document that the query subcommand does not cap rows — use SQLLIMITfor bounded results. Update bundled agent rule and skill with--jsonpreference, verbatim structural answers, and generic SQL recipes (fan-out + sample targets). -
codemap query --recipe <id>for bundled read-only SQL so agents can run common structural queries without embedding SQL on the command line.--jsonworks with recipes the same way as ad-hoc SQL. Bundled ids include dependencyfan-out/fan-out-sample/fan-out-sample-json(JSON1json_group_array) /fan-in, indexindex-summary,files-largest, Reactcomponents-by-hooks(comma-based hook count, no JSON1), andmarkers-by-kind. The benchmark suite uses thefan-outrecipe SQL for an indexed-path scenario; docs clarify that recipes add no extra query cost vs pasting the same SQL. -
Recipe discovery (no index / DB):
codemap query --recipes-jsonprints all bundled recipes (id,description,sql) as JSON.codemap query --print-sql <id>prints one recipe’s SQL.listQueryRecipeCatalog()insrc/cli/query-recipes.tsis the single derived view ofQUERY_RECIPESfor the JSON output.
Golden tests
bun run test:golden: indexfixtures/minimal, run scenarios fromfixtures/golden/scenarios.json, and compare query JSON tofixtures/golden/minimal/. Usebun scripts/query-golden.ts --updateafter intentional fixture or schema changes. Documented in benchmark.md and CONTRIBUTING.
Query robustness
- With
--json,{"error":"…"}is printed for invalid SQL, database open failures, andcodemap querybootstrap failures (config / resolver setup), not only bad SQL. The CLI setsprocess.exitCodeinstead ofprocess.exitso piped stdout is not cut off mid-stream.
Benchmark &
CODEMAP_BENCHMARK_CONFIG- Each
indexedSqlin custom scenario JSON is validated as a single read-onlySELECT(orWITH…SELECT) — DDL/DML andRETURNINGare rejected before execution. - Config file paths are resolved from
process.cwd()(see benchmark.md).traditional.regexstrings are developer-controlled (local JSON);filesmode compiles the regex once per scenario. - Overlapping globs in the traditional path are deduplicated so Files read / Bytes read count each path once.
- The default components in
shop/scenario uses aLIKEfilter aligned with the traditional globs undercomponents/shop/(*.tsx and *.jsx, matchingcomponentsrows from the parser) and avoids unrelated paths such asworkshop.
Recipes (determinism)
- Bundled recipe SQL adds stable secondary
ORDER BYcolumns (and orders innerLIMITsamples) so--recipe/--jsonoutput does not vary on aggregate ties.
External QA
bun run qa:external:--max-filesand--max-symbolsmust be positive integers (invalid values throw before indexing).
-