Proj/language selection
Summary
Brings the language-selection feature stack to main and resolves the divergence between this branch and main's recently-landed tool-mode response-file surface (ENG-3002) and <img> first-class inline content (ENG-3021).
After this lands:
- Curate kickoff and correction prompts emit a language clause — either
"Match the user's input language…"(auto, the default) or"…in <language>"(fixed). The calling agent's LLM is told which language to write the topic body in. - The preference is stored in global daemon settings (
language.mode/language.code) since ENG-2974. A per-project.brv/config.json languagefield is still honored as a fallback for users who configured before the migration. - The MCP
curatetool description carries the auto clause so the same instruction reaches non-CLI callers.
The recently-merged main features (--response-file /--delete-response-file and <img> inline support) are preserved
unchanged — the language thread composes on top, not in place of.
What's included
Feature work (history-only — these landed on the branch already):
- ENG-2687 —
BrvConfig.languageschema + language-clause builder - ENG-2688 — Threaded
languagethroughkickoffSessionandcontinueSession; auto clause appended to MCPTOOL_DESCRIPTION - ENG-2689 — CJK bigram tokenizer wired into MiniSearch (
INDEX_SCHEMA_VERSIONbumped to 7) - ENG-2690 —
brv queryhelper + cross-language curate→query roundtrip coverage in the auto-test harness - ENG-2691 —
brv config set/get language.*CLI (now intercepted and redirected tobrv settings setper ENG-2974) - ENG-2974 — Language preference moved from per-project config to global daemon settings; legacy
brv config set language.*kept as a deprecation gate that names the new command
Merge-resolution work (new in this PR):
src/agent/infra/tools/implementations/search-knowledge-service.ts— UNION of ENG-3021'sparsed.imageContentindexer wiring (frommain) and ENG-2689'stokenizeWithCjkinMINISEARCH_OPTIONS(from this branch).INDEX_SCHEMA_VERSIONhappened to be at 7 on both sides — coincidence, both changes needed an index invalidation.src/oclif/commands/curate/index.ts— Keptmain's richerhandleContinuationbody (mutex checks +loadResponseFile+ local pre-dispatch validation +dispatchContinuationhelper + post-success--delete-response-filecleanup) and grafted the language thread on top:resolveLanguagePreference(projectRoot)is called once afterprojectRootis resolvedlanguageis passed intodispatchContinuation(...)dispatchContinuation's args widened to acceptlanguage?: BrvConfigLanguageand forwarded intocontinueSession({...})Imports merged as a clean disjoint union —BrvConfigLanguage,ProjectConfigStore,SettingsEvents,SETTINGS_KEYSfrom this branch +CurateSessionEnvelopeand the full curate-session helper set frommain.
- Lib-layer signatures (
curate-session.ts) already acceptlanguage?on bothKickoffOptionsandContinueOptions, so no lib changes were required.
Harness migration (local-auto-test/language-selection-e2e):
- Migrated 11 cases from the deprecated
brv config set language.*tobrv settings set language.*+settings getverification. Settings are GLOBAL since ENG-2974, so each migrated case wraps its mutation intry/finallywithresetLanguageSettings()to keep cases isolated. - Case 6 was repurposed from the obsolete cross-field "fixed-
without-code" validation (no longer applicable —
language.modeandlanguage.codeare independent settings keys) into a deprecation-gate test that confirmsbrv config set language.*rejects withcode: 'deprecated-key'and names the newbrv settings set ...command. - Pre-suite reset added in
restartDaemonso a prior aborted run cannot leak global state into the next run. - README updated to reflect the new surface and renumbered to 22 cases.
Conflict-resolution summary (for future archaeology)
| File | Strategy |
|---|---|
search-knowledge-service.ts |
UNION — both contributions preserved verbatim |
curate/index.ts (imports) |
Disjoint UNION |
curate/index.ts (handleContinuation) |
Kept main's body, grafted language thread via dispatchContinuation widening |
curate-session.ts |
No change required — already a superset |
Test plan
- [x]
npm run lint— 0 errors (280 pre-existing warnings on unrelated test files, none on merged files) - [x]
npm test— 9006 / 9006 passing - [x]
local-auto-test/curate-tool-mode-e2e— 20 / 20 (all--response-file/--delete-response-filecases + all language-clause cases pass) - [x]
local-auto-test/language-selection-e2e— 22 / 22 after thebrv settings setmigration - [x] Manual:
brv settings set/get language.mode|coderound-trips;brv config set language.*deprecation message names the newbrv settings setcommand
Reviewer call-outs
- The
dispatchContinuationwidening (addedlanguage?: BrvConfigLanguageto its args type) is the only behavioural change tomain's response-file surface — all other main-side contracts are byte-equivalent. Worth a focused read onsrc/oclif/commands/curate/index.ts. - The harness migration is intentionally scoped to language settings only. The tool-mode harness's language smoke cases pass without migration because they use the
.brv/config.jsonproject-config fallback tier thatresolveLanguagePreferencestill honors. INDEX_SCHEMA_VERSIONwas bumped to 7 by both branches independently (CJK tokenizer on this branch,<img>indexer onmain). Existing cached indexes were already invalidated by whichever side landed first; no additional bump needed.
Out of scope
- Sunset of the project-config
languagefield (theresolveLanguagePreferencefallback). Tracked separately — needs raw-overrides exposure on the settings transport somode: 'auto'from daemon can short-circuit the fallback cleanly. - Sunset of
brv config set/getentirely — the surface still hosts thelanguage.*deprecation gate and theapplyConfigSetdispatcher for the next project-config key that needs to land.
Claude finished @danhdoan's task in 4m 49s —— View job
Claude Code Review
- [x] Read CLAUDE.md and gather context
- [x] Review merge-resolution changes (
search-knowledge-service.ts,curate/index.ts) - [x] Review language-clause & curate-prompt-builder
- [x] Review settings surface migration (events, validator, format-settings)
- [x] Review CJK tokenizer
- [x] Review WebUI/TUI surface
- [x] Post inline comments for issues found
- [x] Post summary with score
Summary
Score: 4.5 / 5 — solid, well-tested, conservative merge. The merge-resolution is clean and additive; the language-clause threading composes on top of main's response-file / <img> surface without breaking either contract. The deferred concerns (precedence quirk, project-config sunset) are correctly scoped out and documented.
Strengths
- Single source of truth for the language clause (
language-clause.ts) — every emission site (kickoff, correction, MCP tool description) routes through one helper. Wording revisions are a one-file change. - CJK tokenizer is well-engineered — script-boundary splits, BMP-correct
for…ofiteration, single-char unigram fallback, comprehensive test coverage including cross-script isolation regressions. Empirical baseline ("MiniSearch 7.2.0 returned []") in the docstring is exactly the kind of forensic note that ages well. - Schema defends against silent fallback to English —
isBrvConfigJsonrejects{mode: 'fixed'}withoutcodeat load time, structurally closing the "silently writes in English" failure mode. - Strict TDD discipline — unit tests for
language-clause,brv-config,curate-prompt-builder,curate-session,cjk-tokenizerPLUS a full-pipeline integration test (language-roundtrip.test.ts) covering Russian / Vietnamese / Chinese / Japanese end-to-end against a real on-disk config. - Deprecation gate is clean —
brv config set language.*rejects with a structuredcode: 'deprecated-key'that names the new command, instead of silently succeeding or silently no-op'ing. - Daemon read uses a tight retry budget (
maxRetries: 1, retryDelayMs: 0) — prevents a ~9s curate stall when the daemon is unreachable, and is asserted with a unit test that capsconnector.callCount.
Findings (all non-blocking — see inline comments)
readLanguageFromSettingsprecedence: explicit daemonmode: 'auto'can be overridden by stale project-configfixed. Documented but worth surfacing during sunset.- Surface asymmetry:
brv config get language.*still reads the legacy fallback whilebrv config setis gated — could mislead a mid-migration user. - Enum invalid-value error surfaces as
code: 'invalid_value'rather than a more specific'invalid_enum_option'or'invalid_value_type'withexpected: 'enum'. - CJK Extension A (
0x3400-0x4DBF) is excluded — fine, but suggested as a cheap follow-up for zh-TW rare-char coverage. - WebUI
general.tsxpanel ordering doesn't matchCATEGORY_ORDER(LanguagePanel rendered before Updates, but listed after). - Minor
enum-settings-row.tsxif (next === null) returnlooks like dead code unless the Select callback type isstring | null. buildLanguageClausesilently degrades{mode: 'fixed', code: undefined}→ auto, with no logger breadcrumb — fine today, worth instrumenting if future call sites bypassBrvConfig.fromJson.
Risk profile: low. Merge-resolution is byte-equivalent for main-side contracts (per the PR's own claim); the only behavioral widening is dispatchContinuation's language?: BrvConfigLanguage param, which is opt-in and fully covered by curate-prompt-builder.test.ts. Test plan checks out — full suite passes 9006/9006, both relevant local-auto-test harnesses green.
Recommendation: ship after addressing finding #1's UX surfacing (the "I clicked auto but it's still Russian" failure mode is the most likely user-visible footgun during the migration window). Other findings can fold into follow-ups. · Branch: proj/language-selection
Claude finished @danhdoan's task in 5m 21s —— View job
Claude finished @danhdoan's task —— View job
Claude Code Review
- [x] Read CLAUDE.md and PR diff
- [x] Review merge-resolution changes (
search-knowledge-service.ts,curate/index.ts) - [x] Review language-clause & curate-prompt-builder
- [x] Review settings surface (events, validator, format-settings, handlers)
- [x] Review CJK tokenizer
- [x] Review WebUI/TUI settings surfaces
- [x] Post inline comments and final score
Summary
Score: 3.5 / 5 — solid feature work and a clean merge resolution, but one ship-blocking documentation defect and a state-trap created by the brv config removal that need attention before merge. The underlying code is well-designed and well-tested; the issues are in reaching users with correct instructions and giving them a way out of pre-migration state.
Strengths
- Single source of truth for the language clause —
language-clause.tsis the only file that emits clause text; kickoff, correction prompt, and MCP tool description all import from it. Wording revisions are a one-file change. - Defense-in-depth schema validation —
isBrvConfigJsonrejects{mode: 'fixed'}withoutcodeat load time, structurally closing the "silently writes in English" failure mode.buildLanguageClausedefends against the same shape anyway. - CJK tokenizer is well-engineered — script-boundary splits, BMP-correct iteration, single-char unigram fallback, and an empirical baseline in the docstring ("MiniSearch 7.2.0 returned []") that ages well. Tests cover cross-script isolation and corpus invariance.
- Tight retry budget for the daemon settings read (
maxRetries: 1, retryDelayMs: 0) prevents a ~9s curate kickoff stall when the daemon is unreachable; asserted with aconnector.callCountcap so a future loosening can't slip through. - Strict TDD discipline visible across 13 changed/added test files —
language-clause,cjk-tokenizer,read-language-from-settings, full-pipelinelanguage-roundtrip.test.tscovering Russian / Vietnamese / Chinese / Japanese end-to-end. - Merge resolution is clean —
search-knowledge-service.tsis a verbatim UNION of CJK tokenizer +<img>indexer (both invalidate via the sameINDEX_SCHEMA_VERSION = 7bump);curate/index.tswidensdispatchContinuationto threadlanguagewithout disturbingmain's response-file / overwrite contract.
Findings (inline comments on each)
- Ship-blocker —
CHANGELOG.mdreferences commands that no longer exist. The Unreleased entry describesbrv config set/get language.*and the restoration recipe (brv config set language.code en+brv config set language.mode fixed) as the user-facing surface. Commitd7f3bf6removedbrv configentirely in this PR; the canonical surface isbrv settings set/get language.mode|code. Users following the release notes will hitCommand not found. Code suggestion attached. - WebUI panel ordering doesn't match
CATEGORY_ORDER—general.tsxrendersLanguagePanelbeforeUpdatesPanel; TUI andbrv settingstext both sort by the shared constant. The docstring onCATEGORY_ORDERwarns about exactly this split-source drift. Cheapest fix is to swap the two JSX lines. - Project-config language fallback is now a one-way trap. With
brv configremoved, a user with a stale.brv/config.json{language: fixed, code: 'ru'}who toggles daemonlanguage.modetoautocannot makeautotake effect —readLanguageFromSettingsreturnsundefinedfor non-fixeddaemon mode and the fallback wins. Two paths: (a) havereadLanguageFromSettingsreturn{mode: 'auto'}explicitly so a daemonautoshort-circuits the fallback, or (b) drop the project-config fallback entirely as a follow-up. (a) is small, well-tested, and unblocks (b). - MCP tool description is auto-only —
buildLanguageClause()(no arg) builds once at server boot, so a user withmode: 'fixed', code: 'ru'who curates via the MCPbrv-curatetool will see saved memory in English even though oclifbrv curatehonors fixed. Code comment documents the limitation but no UX breadcrumb. Suggest either a docs note inbrv connectors installREADME or threading the clause through per-call responses. - CJK tokenizer excludes Extension A (
0x3400-0x4DBF) — ~6,500 codepoints in active zh-TW / zh-HK use. BMP-safe, single-line fix, butINDEX_SCHEMA_VERSIONwould need a bump. Non-blocking; flag as zh-TW backlog item. - Dead-code
if (next === null) returninenum-settings-row.tsx— RadixSelect.onValueChangeemitsstring, notstring | null. Drop the check or surface the edge case explicitly with a toast.
Out-of-scope items the PR correctly defers
- Sunset of the project-config
languagefield (tracked). - MCP per-call language clause (tracked above).
Risk profile: medium, driven mostly by finding #1 (user-facing docs lie about the surface). Code-level correctness is high; merge resolution is byte-equivalent for main-side contracts as claimed.
Recommendation: address finding #1 before merge — it's a 4-line CHANGELOG edit and prevents every reader from running broken commands. Finding #3 is the next-most-important since it's the "I clicked auto but it's still Russian" footgun for migrating users and the PR's own "Out of scope" doesn't fully cover it. The others fold cleanly into follow-ups. · Branch: proj/language-selection