LLM Wiki is a cross-platform desktop application that turns your documents into an organized, interlinked knowledge base — automatically. Instead of traditional RAG (retrieve-and-answer from scratch every time), the LLM incrementally builds and maintains a persistent wiki from your sources。
TypeScript
feat: add local cli isolation controls
nash_su3cad88ff2c0f
diff --git a/src-tauri/src/api_server.rs b/src-tauri/src/api_server.rsindex aaafec9c..e9c1d281 100644--- a/src-tauri/src/api_server.rs+++ b/src-tauri/src/api_server.rs@@ -8,7 +8,7 @@ use std::thread;use std::time::{Duration, Instant};use serde::{Deserialize, Serialize};-use serde_json::{json, Value};+use serde_json::{json, Map, Value};use tauri::{AppHandle, Manager};use tiny_http::{Header, Method, Response, Server, StatusCode};use walkdir::WalkDir;@@ -1039,7 +1039,7 @@ fn load_review_items(project_path: &str, query: &ReviewQuery) -> Result<Vec<Valucontinue;}}- reviews.push(item.clone());+ reviews.push(sanitize_review_item(item));if reviews.len() >= query.limit {break;}@@ -1048,6 +1048,79 @@ fn load_review_items(project_path: &str, query: &ReviewQuery) -> Result<Vec<ValuOk(reviews)}+fn sanitize_review_item(item: &Value) -> Value {+ let mut out = Map::new();+ copy_string_field(item, &mut out, "id");+ copy_string_field(item, &mut out, "type");+ copy_string_field(item, &mut out, "title");+ copy_string_field(item, &mut out, "description");+ copy_string_field(item, &mut out, "sourcePath");+ copy_string_array_field(item, &mut out, "affectedPages");+ copy_string_array_field(item, &mut out, "searchQueries");+ copy_review_options(item, &mut out);+ copy_bool_field(item, &mut out, "resolved");+ copy_string_field(item, &mut out, "resolvedAction");+ copy_number_field(item, &mut out, "createdAt");+ Value::Object(out)+}++fn copy_string_field(item: &Value, out: &mut Map<String, Value>, key: &str) {+ if let Some(value) = item.get(key).and_then(Value::as_str) {+ out.insert(key.to_string(), Value::String(value.to_string()));+ }+}++fn copy_bool_field(item: &Value, out: &mut Map<String, Value>, key: &str) {+ if let Some(value) = item.get(key).and_then(Value::as_bool) {+ out.insert(key.to_string(), Value::Bool(value));+ }+}++fn copy_number_field(item: &Value, out: &mut Map<String, Value>, key: &str) {+ if let Some(value) = item.get(key).and_then(Value::as_f64) {+ if value.is_finite() {+ out.insert(key.to_string(), json!(value));+ }+ }+}++fn copy_string_array_field(item: &Value, out: &mut Map<String, Value>, key: &str) {+ let Some(values) = item.get(key).and_then(Value::as_array) else {+ return;+ };+ let strings = values+ .iter()+ .filter_map(Value::as_str)+ .map(|value| Value::String(value.to_string()))+ .collect::<Vec<_>>();+ out.insert(key.to_string(), Value::Array(strings));+}++fn copy_review_options(item: &Value, out: &mut Map<String, Value>) {+ let Some(values) = item.get("options").and_then(Value::as_array) else {+ return;+ };+ let options = values+ .iter()+ .filter_map(|option| {+ let option = option.as_object()?;+ let mut sanitized = Map::new();+ if let Some(label) = option.get("label").and_then(Value::as_str) {+ sanitized.insert("label".to_string(), Value::String(label.to_string()));+ }+ if let Some(action) = option.get("action").and_then(Value::as_str) {+ sanitized.insert("action".to_string(), Value::String(action.to_string()));+ }+ if sanitized.is_empty() {+ None+ } else {+ Some(Value::Object(sanitized))+ }+ })+ .collect::<Vec<_>>();+ out.insert("options".to_string(), Value::Array(options));+}+fn handle_reviews(app: &AppHandle, project_id: &str, query: &str) -> ApiResponse {let project = match resolve_project(app, project_id) {Ok(project) => project,@@ -1414,7 +1487,8 @@ mod tests {"description": "Add Attention","options": [],"resolved": false,- "createdAt": 1+ "createdAt": 1,+ "internalSecret": "do-not-expose"},{"id": "r2",@@ -1436,6 +1510,7 @@ mod tests {assert_eq!(query.status.as_str(), "unresolved");assert_eq!(reviews.len(), 1);assert_eq!(reviews[0].get("id").and_then(Value::as_str), Some("r1"));+ assert!(reviews[0].get("internalSecret").is_none());let _ = fs::remove_dir_all(root);}diff --git a/src-tauri/src/commands/claude_cli.rs b/src-tauri/src/commands/claude_cli.rsindex 8c102dc3..3629430b 100644--- a/src-tauri/src/commands/claude_cli.rs+++ b/src-tauri/src/commands/claude_cli.rs@@ -211,6 +211,7 @@ pub async fn claude_cli_spawn(stream_id: String,model: String,messages: Vec<ClaudeMessage>,+ isolate_local_config: bool,) -> Result<(), String> {// Build the turn list: fold any system messages into a preamble on// the first user turn rather than using a CLI flag, because@@ -253,14 +254,7 @@ pub async fn claude_cli_spawn(let claude = find_claude_command().await?;let mut cmd = Command::new(&claude);suppress_windows_console(&mut cmd);- cmd.arg("-p")- .arg("--output-format")- .arg("stream-json")- .arg("--input-format")- .arg("stream-json")- .arg("--verbose")- .arg("--model")- .arg(&model);+ cmd.args(build_claude_cli_args(&model, isolate_local_config));cmd.stdin(Stdio::piped()).stdout(Stdio::piped())@@ -387,6 +381,40 @@ pub async fn claude_cli_spawn(Ok(())}+fn build_claude_cli_args(model: &str, isolate_local_config: bool) -> Vec<String> {+ let mut args = vec![+ "-p".to_string(),+ "--output-format".to_string(),+ "stream-json".to_string(),+ "--input-format".to_string(),+ "stream-json".to_string(),+ "--verbose".to_string(),+ ];++ if isolate_local_config {+ // Claude has no documented "empty setting sources" mode. Keep the+ // narrow project source so explicit project-level Claude settings can+ // still apply, while user/global config, MCP, tools, sessions, and+ // slash commands are constrained below.+ args.extend([+ "--setting-sources".to_string(),+ "project".to_string(),+ "--strict-mcp-config".to_string(),+ "--mcp-config".to_string(),+ "{}".to_string(),+ "--disable-slash-commands".to_string(),+ "--tools".to_string(),+ "".to_string(),+ "--no-session-persistence".to_string(),+ "--prompt-suggestions".to_string(),+ "false".to_string(),+ ]);+ }++ args.extend(["--model".to_string(), model.to_string()]);+ args+}+/// Kill a running child registered under `stream_id`. Called on/// AbortSignal in the frontend. No-op if the id is unknown (e.g. the/// process already exited).@@ -444,4 +472,36 @@ mod tests {assert_eq!(claude_content_text_only(&content), "system rule");}++ #[test]+ fn claude_args_do_not_isolate_local_config_by_default() {+ let args = build_claude_cli_args("sonnet", false);++ assert!(args.contains(&"--model".to_string()));+ assert!(args.contains(&"sonnet".to_string()));+ assert!(!args.contains(&"--setting-sources".to_string()));+ assert!(!args.contains(&"--strict-mcp-config".to_string()));+ assert!(!args.contains(&"--disable-slash-commands".to_string()));+ }++ #[test]+ fn claude_args_can_isolate_user_config_tools_and_mcp() {+ let args = build_claude_cli_args("sonnet", true);++ assert!(args+ .windows(2)+ .any(|pair| pair[0] == "--setting-sources" && pair[1] == "project"));+ assert!(args.contains(&"--strict-mcp-config".to_string()));+ assert!(args+ .windows(2)+ .any(|pair| pair[0] == "--mcp-config" && pair[1] == "{}"));+ assert!(args.contains(&"--disable-slash-commands".to_string()));+ assert!(args+ .windows(2)+ .any(|pair| pair[0] == "--tools" && pair[1].is_empty()));+ assert!(args.contains(&"--no-session-persistence".to_string()));+ assert!(args+ .windows(2)+ .any(|pair| pair[0] == "--prompt-suggestions" && pair[1] == "false"));+ }}diff --git a/src-tauri/src/commands/codex_cli.rs b/src-tauri/src/commands/codex_cli.rsindex d8bb41d1..9bf79523 100644--- a/src-tauri/src/commands/codex_cli.rs+++ b/src-tauri/src/commands/codex_cli.rs@@ -131,6 +131,7 @@ pub async fn codex_cli_spawn(stream_id: String,model: String,prompt: String,+ isolate_local_config: bool,) -> Result<(), String> {if prompt.trim().is_empty() {return Err("No prompt to send to codex CLI".to_string());@@ -139,17 +140,7 @@ pub async fn codex_cli_spawn(let codex = find_codex_command().await?;let mut cmd = Command::new(&codex);suppress_windows_console(&mut cmd);- cmd.arg("-a")- .arg("never")- .arg("exec")- .arg("--json")- .arg("--skip-git-repo-check")- .arg("--sandbox")- .arg("read-only")- .arg("--ephemeral")- .arg("--model")- .arg(&model)- .arg("-");+ cmd.args(build_codex_cli_args(&model, isolate_local_config));cmd.stdin(Stdio::piped()).stdout(Stdio::piped())@@ -276,6 +267,29 @@ pub async fn codex_cli_spawn(Ok(())}+fn build_codex_cli_args(model: &str, isolate_local_config: bool) -> Vec<String> {+ let mut args = vec!["-a".to_string(), "never".to_string(), "exec".to_string()];++ if isolate_local_config {+ args.extend([+ "--ignore-user-config".to_string(),+ "--ignore-rules".to_string(),+ ]);+ }++ args.extend([+ "--json".to_string(),+ "--skip-git-repo-check".to_string(),+ "--sandbox".to_string(),+ "read-only".to_string(),+ "--ephemeral".to_string(),+ "--model".to_string(),+ model.to_string(),+ "-".to_string(),+ ]);+ args+}+#[tauri::command]pub async fn codex_cli_kill(state: State<'_, CodexCliState>,@@ -316,4 +330,34 @@ mod tests {assert_eq!(out.len(), 5);assert!(std::str::from_utf8(out.as_bytes()).is_ok());}++ #[test]+ fn codex_args_do_not_isolate_local_config_by_default() {+ let args = build_codex_cli_args("gpt-5", false);++ assert!(args+ .windows(3)+ .any(|pair| pair[0] == "-a" && pair[1] == "never" && pair[2] == "exec"));+ assert!(args.contains(&"--model".to_string()));+ assert!(args.contains(&"gpt-5".to_string()));+ assert!(!args.contains(&"--ignore-user-config".to_string()));+ assert!(!args.contains(&"--ignore-rules".to_string()));+ }++ #[test]+ fn codex_args_can_isolate_user_config_and_rules() {+ let args = build_codex_cli_args("gpt-5", true);+ let exec_pos = args.iter().position(|arg| arg == "exec").expect("exec arg");+ let ignore_config_pos = args+ .iter()+ .position(|arg| arg == "--ignore-user-config")+ .expect("ignore-user-config arg");+ let ignore_rules_pos = args+ .iter()+ .position(|arg| arg == "--ignore-rules")+ .expect("ignore-rules arg");++ assert!(ignore_config_pos > exec_pos);+ assert!(ignore_rules_pos > exec_pos);+ }}diff --git a/src-tauri/src/commands/fs.rs b/src-tauri/src/commands/fs.rsindex 75afcb15..ac20bc2d 100644--- a/src-tauri/src/commands/fs.rs+++ b/src-tauri/src/commands/fs.rs@@ -23,7 +23,7 @@ const MEDIA_EXTS: &[&str] = &[const LEGACY_DOC_EXTS: &[&str] = &["ppt", "pages", "numbers", "key", "epub"];fn require_absolute_path(operation: &str, path: &str) -> Result<(), String> {- if Path::new(path).is_absolute() {+ if is_absolute_path_cross_platform(path) {Ok(())} else {Err(format!(@@ -33,6 +33,26 @@ fn require_absolute_path(operation: &str, path: &str) -> Result<(), String> {}}+fn is_absolute_path_cross_platform(path: &str) -> bool {+ if path.is_empty() {+ return false;+ }+ if Path::new(path).is_absolute() {+ return true;+ }++ let bytes = path.as_bytes();+ if bytes.len() >= 3+ && bytes[1] == b':'+ && bytes[0].is_ascii_alphabetic()+ && matches!(bytes[2], b'/' | b'\\')+ {+ return true;+ }++ path.starts_with(r"\\") || path.starts_with("//")+}+#[tauri::command]pub async fn read_file(path: String, extract_images: Option<bool>) -> Result<String, String> {// `spawn_blocking` is REQUIRED, not a perf nicety. The body does@@ -1944,16 +1964,13 @@ mod tests {#[test]fn allow_absolute_write_paths() {assert!(require_absolute_path("write_file", "/tmp/project/wiki/sources/page.md").is_ok());- #[cfg(windows)]- {- assert!(require_absolute_path("write_file", "C:/project/wiki/sources/page.md").is_ok());- assert!(- require_absolute_path("write_file", r"C:\project\wiki\sources\page.md").is_ok()- );- assert!(- require_absolute_path("write_file", r"\\server\share\wiki\sources\page.md").is_ok()- );- }+ assert!(require_absolute_path("write_file", "C:/project/wiki/sources/page.md").is_ok());+ assert!(require_absolute_path("write_file", r"C:\project\wiki\sources\page.md").is_ok());+ assert!(+ require_absolute_path("write_file", r"\\server\share\wiki\sources\page.md").is_ok()+ );+ assert!(require_absolute_path("write_file", "//server/share/wiki/sources/page.md").is_ok());+ assert!(require_absolute_path("write_file", "C:wiki/sources/page.md").is_err());}/// Pull the inner sync `copy_recursive` body out fromdiff --git a/src/components/settings/preset-resolver.test.ts b/src/components/settings/preset-resolver.test.tsindex 93ae399f..71a70eb2 100644--- a/src/components/settings/preset-resolver.test.ts+++ b/src/components/settings/preset-resolver.test.ts@@ -102,4 +102,38 @@ describe("resolveConfig", () => {expect(resolved.azureApiVersion).toBe("2025-01-01-preview")expect(resolved.azureModelFamily).toBe("gpt5")})++ it("carries local CLI isolation for Claude Code and Codex CLI presets", () => {+ const preset: LlmPreset = {+ id: "codex-cli",+ label: "Codex CLI",+ provider: "codex-cli",+ defaultModel: "gpt-5",+ }++ const resolved = resolveConfig(+ preset,+ { localCliIsolation: true },+ fallbackConfig(),+ )++ expect(resolved.localCliIsolation).toBe(true)+ })++ it("does not apply local CLI isolation to hosted providers", () => {+ const preset: LlmPreset = {+ id: "openai",+ label: "OpenAI",+ provider: "openai",+ defaultModel: "gpt-5",+ }++ const resolved = resolveConfig(+ preset,+ { localCliIsolation: true },+ fallbackConfig({ localCliIsolation: true }),+ )++ expect(resolved.localCliIsolation).toBe(false)+ })})diff --git a/src/components/settings/preset-resolver.ts b/src/components/settings/preset-resolver.tsindex dc26ba82..644c335d 100644--- a/src/components/settings/preset-resolver.ts+++ b/src/components/settings/preset-resolver.ts@@ -19,6 +19,7 @@ export function resolveConfig(const maxContextSize =ov.maxContextSize ?? preset.suggestedContextSize ?? fallback.maxContextSizeconst reasoning = ov.reasoning ?? { mode: "auto" as const }+ const localCliIsolation = ov.localCliIsolation === trueif (preset.provider === "custom") {return {@@ -30,6 +31,7 @@ export function resolveConfig(maxContextSize,apiMode: ov.apiMode ?? preset.apiMode ?? "chat_completions",reasoning,+ localCliIsolation: false,}}@@ -42,6 +44,7 @@ export function resolveConfig(customEndpoint: fallback.customEndpoint,maxContextSize,reasoning,+ localCliIsolation: false,}}@@ -56,6 +59,7 @@ export function resolveConfig(azureModelFamily: ov.azureModelFamily ?? preset.azureModelFamily ?? "auto",maxContextSize,reasoning,+ localCliIsolation: false,}}@@ -70,6 +74,7 @@ export function resolveConfig(customEndpoint: fallback.customEndpoint,maxContextSize,reasoning,+ localCliIsolation,}}@@ -84,5 +89,6 @@ export function resolveConfig(customEndpoint: fallback.customEndpoint,maxContextSize,reasoning,+ localCliIsolation: false,}}diff --git a/src/components/settings/sections/llm-provider-section.tsx b/src/components/settings/sections/llm-provider-section.tsxindex bd8c86a8..87527345 100644--- a/src/components/settings/sections/llm-provider-section.tsx+++ b/src/components/settings/sections/llm-provider-section.tsx@@ -128,6 +128,8 @@ function PresetRow({const azureModelFamily = ov.azureModelFamily ?? preset.azureModelFamily ?? "auto"const context = ov.maxContextSize ?? preset.suggestedContextSize ?? 131072const reasoning = ov.reasoning ?? { mode: "auto" as const }+ const localCliIsolation = ov.localCliIsolation === true+ const isLocalCliProvider = preset.provider === "claude-code" || preset.provider === "codex-cli"const [testState, setTestState] = useState<ProviderTestState>({ kind: "idle" })const hasConfig = !!apiKey || !!ov.baseUrl || !!ov.model || !!ov.azureApiVersion || !!ov.azureModelFamily// Local CLI providers authenticate via their own existing login state@@ -310,6 +312,47 @@ function PresetRow({{preset.provider === "claude-code" && <ClaudeCliStatusPill />}{preset.provider === "codex-cli" && <CodexCliStatusPill />}+ {isLocalCliProvider && (+ <div className="space-y-2 rounded-md border p-3">+ <div className="flex items-start justify-between gap-3">+ <div>+ <div className="text-sm font-medium">+ {t("settings.sections.llm.localCliIsolation")}+ </div>+ <p className="mt-1 text-xs text-muted-foreground">+ {t("settings.sections.llm.localCliIsolationHint")}+ </p>+ </div>+ <button+ type="button"+ onClick={() => onChange({ localCliIsolation: !localCliIsolation })}+ className={`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full border transition-colors ${+ localCliIsolation+ ? "border-primary bg-primary"+ : "border-muted-foreground/30 bg-muted-foreground/20 hover:bg-muted-foreground/30"+ }`}+ title={+ localCliIsolation+ ? t("settings.sections.llm.localCliIsolationOn")+ : t("settings.sections.llm.localCliIsolationOff")+ }+ aria-label={t("settings.sections.llm.localCliIsolation")}+ >+ <span+ className={`inline-block h-3.5 w-3.5 rounded-full bg-white shadow-sm ring-1 ring-black/10 transition-transform ${+ localCliIsolation ? "translate-x-4" : "translate-x-0.5"+ }`}+ />+ </button>+ </div>+ <div className="rounded-md bg-muted/50 px-2 py-1.5 text-xs text-muted-foreground">+ {localCliIsolation+ ? t("settings.sections.llm.localCliIsolationOn")+ : t("settings.sections.llm.localCliIsolationOff")}+ </div>+ </div>+ )}+{needsApiKey && (<div className="space-y-2"><Label>{t("settings.apiKey")}</Label>diff --git a/src/components/settings/settings-types.ts b/src/components/settings/settings-types.tsindex 29a1d5b0..080483e9 100644--- a/src/components/settings/settings-types.ts+++ b/src/components/settings/settings-types.ts@@ -19,6 +19,7 @@ export interface SettingsDraft {maxContextSize: numberapiMode: CustomApiMode | undefinedreasoning: ReasoningConfig | undefined+ localCliIsolation: boolean// EmbeddingembeddingEnabled: booleandiff --git a/src/components/settings/settings-view.tsx b/src/components/settings/settings-view.tsxindex 3c49335f..4b42cbe6 100644--- a/src/components/settings/settings-view.tsx+++ b/src/components/settings/settings-view.tsx@@ -126,6 +126,7 @@ function initialDraft(maxContextSize: llm.maxContextSize ?? 204800,apiMode: llm.apiMode,reasoning: llm.reasoning,+ localCliIsolation: llm.localCliIsolation === true,embeddingEnabled: embed.enabled,embeddingEndpoint: embed.endpoint,embeddingApiKey: embed.apiKey,@@ -321,6 +322,7 @@ export function SettingsView() {maxContextSize: draft.maxContextSize,apiMode: draft.provider === "custom" ? draft.apiMode : undefined,reasoning: draft.reasoning,+ localCliIsolation: draft.localCliIsolation,}const newEmbed = {enabled: draft.embeddingEnabled,diff --git a/src/i18n/en.json b/src/i18n/en.jsonindex ebb33465..3cef23e5 100644--- a/src/i18n/en.json+++ b/src/i18n/en.json@@ -263,6 +263,10 @@"endpointPreviewAutoApply": "(applied automatically when you leave the input)","providerTests": "Provider tests","providerTestsHint": "Connection test verifies the endpoint can respond. Functional test asks the model to follow a tiny instruction.",+ "localCliIsolation": "Isolate local CLI configuration",+ "localCliIsolationHint": "Optional for Claude Code and Codex CLI. When enabled, LLM Wiki asks the CLI to ignore user-level rules/config/MCP/tools where supported. This is configuration isolation, not a process sandbox: the CLI still uses your local login credentials and network access. Leave off if you intentionally rely on your local CLI setup.",+ "localCliIsolationOn": "Isolation on: user CLI rules, MCP/tools, and persisted sessions are disabled where the CLI supports it. Local credentials and network access are still controlled by the CLI itself.",+ "localCliIsolationOff": "Isolation off: this provider can use your normal local CLI configuration.","testConnection": "Test connection","testFunction": "Test function","testingConnection": "Testing connection…",diff --git a/src/i18n/zh.json b/src/i18n/zh.jsonindex 4b43d1e1..7a0eb001 100644--- a/src/i18n/zh.json+++ b/src/i18n/zh.json@@ -263,6 +263,10 @@"endpointPreviewAutoApply": "(离开输入框时自动套用)","providerTests": "Provider 测试","providerTestsHint": "连接测试用于确认 endpoint 能正常响应;功能测试会让模型执行一个极小指令。",+ "localCliIsolation": "隔离本地 CLI 配置",+ "localCliIsolationHint": "仅用于 Claude Code 和 Codex CLI。开启后,LLM Wiki 会让 CLI 尽量忽略用户级 rules / config / MCP / tools。这是配置隔离,不是进程沙箱:CLI 仍会使用你的本机登录凭据和网络能力。若你有意依赖本机 CLI 配置,请保持关闭。",+ "localCliIsolationOn": "隔离已开启:在 CLI 支持的范围内禁用用户规则、MCP/tools 和持久会话。本机凭据和网络访问仍由 CLI 自身控制。",+ "localCliIsolationOff": "隔离已关闭:该 Provider 可以使用你平时的本地 CLI 配置。","testConnection": "测试连接","testFunction": "测试功能","testingConnection": "正在测试连接…",diff --git a/src/lib/__tests__/claude-cli-transport.test.ts b/src/lib/__tests__/claude-cli-transport.test.tsindex d832ebda..0619162f 100644--- a/src/lib/__tests__/claude-cli-transport.test.ts+++ b/src/lib/__tests__/claude-cli-transport.test.ts@@ -228,6 +228,47 @@ describe("streamClaudeCodeCli", () => {expect(callbacks.onError).not.toHaveBeenCalled()})+ it("passes local CLI isolation preference to the Rust transport", async () => {+ const callbacks = {+ onToken: vi.fn(),+ onDone: vi.fn(),+ onError: vi.fn(),+ }++ const stream = streamClaudeCodeCli(+ {+ provider: "claude-code",+ apiKey: "",+ model: "claude-sonnet-4-6",+ ollamaUrl: "",+ customEndpoint: "",+ maxContextSize: 200000,+ localCliIsolation: true,+ },+ [{ role: "user", content: "Analyze this source." }],+ callbacks,+ )++ await vi.waitFor(() => {+ expect(tauriMocks.invoke).toHaveBeenCalledWith(+ "claude_cli_spawn",+ expect.objectContaining({ isolateLocalConfig: true }),+ )+ })++ const payload = tauriMocks.invoke.mock.calls[0]?.[1] as { streamId: string }+ tauriMocks.emit(+ `claude-cli:${payload.streamId}`,+ JSON.stringify({+ type: "assistant",+ message: { content: [{ type: "text", text: "ok" }] },+ }),+ )+ tauriMocks.emit(`claude-cli:${payload.streamId}:done`, { code: 0, stderr: "" })++ await stream+ })+it("surfaces a clear error when completion has no assistant text", async () => {const callbacks = {onToken: vi.fn(),diff --git a/src/lib/claude-cli-transport.ts b/src/lib/claude-cli-transport.tsindex c1c80188..9a4536fc 100644--- a/src/lib/claude-cli-transport.ts+++ b/src/lib/claude-cli-transport.ts@@ -107,6 +107,7 @@ type SpawnPayload = Record<string, unknown> & {streamId: stringmodel: stringmessages: ChatMessage[]+ isolateLocalConfig: boolean}/**@@ -257,6 +258,7 @@ export async function streamClaudeCodeCli(streamId,model: config.model,messages,+ isolateLocalConfig: config.localCliIsolation === true,}await invoke("claude_cli_spawn", payload)if (aborted || signal?.aborted) {diff --git a/src/lib/codex-cli-transport.test.ts b/src/lib/codex-cli-transport.test.tsindex 39ec0e5f..e04fffc5 100644--- a/src/lib/codex-cli-transport.test.ts+++ b/src/lib/codex-cli-transport.test.ts@@ -195,6 +195,55 @@ describe("streamCodexCli", () => {expect(callbacks.onError).not.toHaveBeenCalled()})+ it("passes local CLI isolation preference to the Rust transport", async () => {+ const callbacks = {+ onToken: vi.fn(),+ onDone: vi.fn(),+ onError: vi.fn(),+ }++ const stream = streamCodexCli(+ {+ provider: "codex-cli",+ apiKey: "",+ model: "gpt-5.1-codex-mini",+ ollamaUrl: "",+ customEndpoint: "",+ maxContextSize: 128000,+ localCliIsolation: true,+ },+ [{ role: "user", content: "Analyze this source." }],+ callbacks,+ )++ await vi.waitFor(() => {+ expect(tauriMocks.invoke).toHaveBeenCalledWith(+ "codex_cli_spawn",+ expect.objectContaining({ isolateLocalConfig: true }),+ )+ })++ const payload = tauriMocks.invoke.mock.calls[0]?.[1] as { streamId: string }+ tauriMocks.emit(+ `codex-cli:${payload.streamId}`,+ JSON.stringify({+ type: "item.completed",+ item: { type: "agent_message", text: "isolated analysis" },+ }),+ )+ tauriMocks.emit(`codex-cli:${payload.streamId}:done`, {+ code: 0,+ stderr: "",+ stdout: "",+ })++ await stream++ expect(callbacks.onToken).toHaveBeenCalledWith("isolated analysis")+ expect(callbacks.onDone).toHaveBeenCalledTimes(1)+ expect(callbacks.onError).not.toHaveBeenCalled()+ })+it("does not replay done stdout when a live agent message was already emitted", async () => {const callbacks = {onToken: vi.fn(),diff --git a/src/lib/codex-cli-transport.ts b/src/lib/codex-cli-transport.tsindex da9b1edf..cab88be5 100644--- a/src/lib/codex-cli-transport.ts+++ b/src/lib/codex-cli-transport.ts@@ -61,6 +61,7 @@ type SpawnPayload = Record<string, unknown> & {streamId: stringmodel: stringprompt: string+ isolateLocalConfig: boolean}export async function streamCodexCli(@@ -196,6 +197,7 @@ export async function streamCodexCli(streamId,model: config.model,prompt: buildPrompt(messages),+ isolateLocalConfig: config.localCliIsolation === true,}await invoke("codex_cli_spawn", payload)if (aborted || signal?.aborted) {diff --git a/src/lib/wiki-schema.test.ts b/src/lib/wiki-schema.test.tsindex b5fe412c..1f291b52 100644--- a/src/lib/wiki-schema.test.ts+++ b/src/lib/wiki-schema.test.ts@@ -27,6 +27,32 @@ describe("parseWikiSchemaRouting", () => {overview: "wiki",})})++ it("ignores unrelated markdown tables outside the Page Types section", () => {+ const routing = parseWikiSchemaRouting([+ "# Wiki Schema",+ "",+ "| Name | Directory |",+ "| ---- | --------- |",+ "| draft | wiki/drafts/ |",+ "",+ "## Page Types",+ "",+ "| Type | Directory | Purpose |",+ "| ---- | --------- | ------- |",+ "| concept | wiki/concepts/ | Ideas |",+ "",+ "## Examples",+ "",+ "| Type | Directory |",+ "| ---- | --------- |",+ "| person | wiki/people/ |",+ ].join("\n"))++ expect(routing.typeDirs).toEqual({+ concept: "wiki/concepts",+ })+ })})describe("validateWikiPageRouting", () => {diff --git a/src/lib/wiki-schema.ts b/src/lib/wiki-schema.tsindex 73053540..efe30c6b 100644--- a/src/lib/wiki-schema.ts+++ b/src/lib/wiki-schema.ts@@ -26,7 +26,7 @@ export async function loadProjectWikiSchemaRouting(export function parseWikiSchemaRouting(markdown: string): WikiSchemaRouting {const typeDirs: Record<string, string> = {}- for (const line of markdown.split("\n")) {+ for (const line of pageTypesSectionLines(markdown)) {if (!line.trim().startsWith("|")) continueconst cells = line.split("|")@@ -44,6 +44,25 @@ export function parseWikiSchemaRouting(markdown: string): WikiSchemaRouting {return { typeDirs }}+function pageTypesSectionLines(markdown: string): string[] {+ const lines = markdown.split("\n")+ const start = lines.findIndex((line) => {+ const match = line.trim().match(/^(#{1,6})\s+(.+?)\s*#*$/)+ return !!match && /^page\s+types$/i.test(match[2].trim())+ })++ if (start < 0) return []++ const headingLevel = lines[start].trim().match(/^(#{1,6})/)?.[1].length ?? 6+ const out: string[] = []+ for (const line of lines.slice(start + 1)) {+ const heading = line.trim().match(/^(#{1,6})\s+/)+ if (heading && heading[1].length <= headingLevel) break+ out.push(line)+ }+ return out+}+export function validateWikiPageRouting(relativePath: string,content: string,diff --git a/src/stores/wiki-store.ts b/src/stores/wiki-store.tsindex 18e45920..5fecbc6f 100644--- a/src/stores/wiki-store.ts+++ b/src/stores/wiki-store.ts@@ -28,6 +28,12 @@ interface LlmConfig {maxContextSize: number // max context window in charactersapiMode?: CustomApiModereasoning?: ReasoningConfig+ /**+ * Local CLI providers only. When true, LLM Wiki asks Claude/Codex CLI+ * to ignore user-level rules/config/MCP/tool state where the CLI exposes+ * such controls. Default false preserves existing advanced-user setups.+ */+ localCliIsolation?: boolean}export type SearchProvider = "tavily" | "serpapi" | "searxng" | "ollama" | "none"@@ -276,6 +282,7 @@ export interface ProviderOverride {apiMode?: CustomApiModemaxContextSize?: numberreasoning?: ReasoningConfig+ localCliIsolation?: boolean}export type ProviderConfigs = Record<string, ProviderOverride>@@ -370,6 +377,7 @@ export const useWikiStore = create<WikiState>((set) => ({customEndpoint: "",azureApiVersion: "2024-10-21",reasoning: { mode: "auto" },+ localCliIsolation: false,},providerConfigs: {},activePresetId: null,