Skip to content

Commit 2d0ff9b

Browse files
smpark-lunaclaude
andcommitted
docs(harness-view): add on-device LLM Chat workflow
The Workflow view's Core tab listed seven workflows but had no entry for the chat flow that landed in v0.9.0 (Gemma 4 + Nemotron 3 Nano), so the viewer's "how does this app actually do X" picture stopped at search / graph / TUI / GUI. Adds an `on-device-llm-chat` entry with both diagrams: * mermaid — high-level request loop: model present? → optional ModelDownloader → GgufReader probe → GpuEnumerator/CtxRecommender → LlmHost load → ChatTemplateRegistry pick → AgentChatLoop's JSON-tool-call cycle against CodeScanToolbelt (SqliteStore + FS), terminating on `tool=done`. Forensic log path called out. * sourceMermaid — file/class layout grouped by directory (Tui/, Services/Llm/, Services/Llm/Tools/, Services/) showing the wiring between ChatView and the toolchain. Annotates the two chat templates by their distinguishing turn markers so the family boundary is visible. Also patches the existing `tui-flow` entry: its Home-menu diagram was missing the Chat node entirely and its sourceMermaid only listed TuiApp.cs, so adds the Chat node with a `see on-device-llm-chat` back-edge to the LLamaSharp host, plus ChatView.cs and the new StartupTracer in the source panel. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 15892da commit 2d0ff9b

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

Home/harness-view/data/workflow-graph.json

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,16 @@
2525
{
2626
"id": "tui-flow",
2727
"label": "Interactive TUI",
28-
"description": "tui command — Terminal.Gui v2 (NetDriver) state machine. Project list → scan/search/graph screens, all reading from the same SqliteStore",
29-
"mermaid": "flowchart LR\n U[codescan tui] --> APP[TuiApp]\n APP --> HOME[Home menu]\n HOME --> PRJ[Projects screen]\n HOME --> SCAN[Scan screen]\n HOME --> KW[Keyword search]\n HOME --> GR[Graph search]\n PRJ --> ST[(SqliteStore)]\n SCAN --> ST\n KW --> ST\n GR --> ST",
30-
"sourceMermaid": "flowchart TB\n subgraph Tui[Tui/]\n TA[TuiApp.cs<br/>state machine root]\n end\n subgraph Svc[Services/]\n ST[SqliteStore.cs]\n DS[DirectoryScanner.cs]\n SA[SourceAnalyzer.cs]\n end\n TA --> ST\n TA --> DS\n TA --> SA"
28+
"description": "tui command — Terminal.Gui v2 (NetDriver) state machine. Home menu fans out to scan/search/graph/projects/chat screens, all sharing the same SqliteStore. Chat descends into the on-device LLM workflow",
29+
"mermaid": "flowchart LR\n U[codescan tui] --> APP[TuiApp]\n APP --> HOME[Home menu]\n HOME --> PRJ[Projects screen]\n HOME --> SCAN[Scan screen]\n HOME --> KW[Keyword search]\n HOME --> GR[Graph search]\n HOME --> CHAT[Chat screen]\n PRJ --> ST[(SqliteStore)]\n SCAN --> ST\n KW --> ST\n GR --> ST\n CHAT -->|see on-device-llm-chat| LLM[(LLamaSharp host)]",
30+
"sourceMermaid": "flowchart TB\n subgraph Tui[Tui/]\n TA[TuiApp.cs<br/>state machine root]\n CV[ChatView.cs<br/>chat sub-state machine]\n end\n subgraph Svc[Services/]\n ST[SqliteStore.cs]\n DS[DirectoryScanner.cs]\n SA[SourceAnalyzer.cs]\n end\n subgraph Diag[Services/Diagnostics/]\n STR[StartupTracer.cs<br/>cold-start phase log]\n end\n TA --> ST\n TA --> DS\n TA --> SA\n TA --> CV\n TA -.marks.-> STR"
31+
},
32+
{
33+
"id": "on-device-llm-chat",
34+
"label": "On-device LLM Chat (Gemma 4 / Nemotron 3 Nano)",
35+
"description": "TUI Chat — picks a GGUF (Gemma 4 E4B/E2B or NVIDIA Nemotron 3 Nano 4B), loads it through LLamaSharp on CPU or Vulkan GPU, and drives a JSON tool-call loop against the indexed codebase. The model is grammar-constrained (GBNF) to emit ONE tool-call JSON per turn; CodeScanToolbelt executes the call against SqliteStore / the local filesystem and feeds the result back as the next turn's input. Turn markers + antiprompts are family-aware — Gemma 4 (`<|turn>…<turn|>`) and Nemotron 3 Nano (ChatML + /no_think) are mutually incompatible, so ChatTemplateRegistry picks the right one from the catalog entry, the filename, or the GGUF `general.architecture` field. Runs fully offline — no network after the one-time model download. Every raw model emission and tool result is appended to `~/.codescan/logs/chat-*.log` for postmortem.",
36+
"mermaid": "flowchart LR\n U[TUI Chat screen] --> CV[ChatView]\n CV --> SEL{GGUF on disk?}\n SEL -->|no| DL[ModelDownloader<br/>HTTP Range resume → .part]\n DL --> SEL\n SEL -->|yes| GG[GgufReader<br/>arch + ctx + KV dims]\n GG --> GE[GpuEnumerator<br/>Vulkan + nvidia-smi]\n GE --> CR[CtxRecommender<br/>ctx fits selected device]\n CR --> LH[LlmHost.LoadAsync<br/>CPU or Vulkan offload]\n LH --> CTR[ChatTemplateRegistry<br/>family pick]\n CTR --> ACL[AgentChatLoop<br/>StatelessExecutor + GBNF]\n Q[User question] --> ACL\n ACL -->|JSON tool call| TB[CodeScanToolbelt]\n TB -->|db_search / project_tree / project_info / list_projects / graph_query| ST[(SqliteStore)]\n TB -->|read_file / grep_file| FS[(Local filesystem)]\n TB -->|tool result JSON| ACL\n ACL -->|tool = done| ANS[Answer rendered as<br/>Gemma / Nemotron label]\n ACL -.every turn.-> LOG[~/.codescan/logs/chat-*.log]",
37+
"sourceMermaid": "flowchart TB\n subgraph Tui[Tui/]\n CV[ChatView.cs<br/>state machine + transcript + picker]\n end\n subgraph Llm[Services/Llm/]\n CAT[ChatModelCatalog.cs<br/>Gemma 4 + Nemotron 3 Nano entries<br/>+ ChatModelFamily]\n LOC[ModelLocator.cs<br/>~/.codescan/models/]\n DL[ModelDownloader.cs<br/>resumable HTTPS]\n GG[GgufReader.cs<br/>header probe pre-load]\n GE[GpuEnumerator.cs]\n CR[CtxRecommender.cs]\n LH[LlmHost.cs<br/>LLamaSharp wrapper]\n end\n subgraph Tools[Services/Llm/Tools/]\n IT[ChatTemplate.cs<br/>IChatTemplate + ChatHistoryEntry]\n GCT[GemmaChatTemplate.cs<br/>&lt;|turn&gt; markers]\n NCT[NemotronChatTemplate.cs<br/>ChatML + /no_think preamble]\n CTR[ChatTemplateRegistry.cs<br/>catalog → filename → arch]\n TG[CodeScanToolGrammar.cs<br/>GBNF + system prompt<br/>+ PATH COPY RULE]\n ACL[AgentChatLoop.cs<br/>JSON tool-call loop]\n TB[CodeScanToolbelt.cs<br/>tool dispatch +<br/>Did-you-mean basename recovery]\n CSL[ChatSessionLogger.cs]\n end\n subgraph Svc[Services/]\n ST[SqliteStore.cs]\n end\n CV --> CAT\n CV --> LOC\n CV --> DL\n CV --> GG\n CV --> GE\n CV --> CR\n CV --> LH\n CV --> CTR\n CV --> ACL\n CTR --> GCT\n CTR --> NCT\n ACL --> IT\n ACL --> TG\n ACL --> TB\n ACL --> CSL\n TB --> ST"
3138
},
3239
{
3340
"id": "gui-flow",

0 commit comments

Comments
 (0)