Files
sql-server-query-ai/kb/Analyst model.md
T
ahmed mohammedandClaude Opus 4.7 8b42a0931c docs: karpathy-pattern wiki built from the spec, plan, design contract and decisions ledger
kb/ is its own wiki root: 34 pages across 7 categories, index.md catalog, log.md, AGENTS.md schema layer, and raw/ holding copies of README, the spec, the 13-task plan, the design master and the SDD ledger.

Every page cross-references 3 to 6 others and all 107 wikilinks resolve except two [["list"]] artefacts inside JSON snippets in the copied plan.

Kept separate from the repository root on purpose: its generated graph lands in kb/.ua/ instead of overwriting the code graph.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-09-22 12:14:05 +03:00

1.3 KiB

Analyst model

lib/analyst.ts talks to any OpenAI-compatible endpoint the user pastes in settings. Two calls, two jobs.

proposeCandidates asks for 2 to 4 genuinely different remediation options and validates them against a zod schema: key, title, diagnosis, 1-4 actions, option_type, sql_to_run, expected. Fewer than two options is an error, because Jev scoring cannot rank a single option.

streamReport writes the final answer as OpenUI Lang, streamed token by token into OpenUI report language. Its system prompt carries hard requirements: every option with sql_to_run gets a SqlBlock containing exactly that T-SQL, and every option gets a ScoreBar.

Both calls spread the user's extra JSON parameters after max_tokens, which is how the output ceiling is raised from the settings screen without a rebuild. extractJson recovers an object from prose or fenced output and, when the response was cut off, names the character count instead of blaming the model.

The local QA endpoint is http://192.168.88.131:8888/v1 running qwen3.8-flash-next; it streams reasoning instead of content unless extra params include {"chat_template_kwargs":{"enable_thinking":false}}.

Related: Jev scoring, Option type and sql to run, Placeholder SQL is dropped, Output token ceiling.