Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
refactor(host-runtime): share workspace file and diff helpers
vastsa1c90b3ec5f83
diff --git a/apps/desktop/electron/main/chat-ref-resolve.ts b/apps/desktop/electron/main/chat-ref-resolve.tsindex 81bf787bc..1f9d9965d 100644--- a/apps/desktop/electron/main/chat-ref-resolve.ts+++ b/apps/desktop/electron/main/chat-ref-resolve.ts@@ -6,7 +6,7 @@ import type {FsChatRefProjectRoot,FsChatRefRoot,} from "@pi-desktop/shared";-import { isAttachmentBlobRef, isIgnoredName } from "./fs-panel.js";+import { isAttachmentBlobRef, isIgnoredName } from "@pi-desktop/host-runtime";import { getWorkspaceFileIndex } from "./fs-index.js";/**diff --git a/apps/desktop/electron/main/fs-index.ts b/apps/desktop/electron/main/fs-index.tsindex 4e771c3b8..2bd0a79b3 100644--- a/apps/desktop/electron/main/fs-index.ts+++ b/apps/desktop/electron/main/fs-index.ts@@ -2,7 +2,7 @@ import { spawn } from "node:child_process";import { readdir } from "node:fs/promises";import { join } from "node:path";import type { FsIndexEntry, FsIndexResult } from "@pi-desktop/shared";-import { isIgnoredName } from "./fs-panel.js";+import { isIgnoredName } from "@pi-desktop/host-runtime";/*** Workspace file index for the composer "@" menu (D124, ADR 0024).diff --git a/apps/desktop/electron/main/ipc/workspace-ipc.ts b/apps/desktop/electron/main/ipc/workspace-ipc.tsindex 3c053ca3a..c6ced60c9 100644--- a/apps/desktop/electron/main/ipc/workspace-ipc.ts+++ b/apps/desktop/electron/main/ipc/workspace-ipc.ts@@ -25,7 +25,7 @@ import {consumeComposerPickerSelection,rememberComposerPickerSelection,} from "../composer-picker";-import { collectWorkspaceDiff } from "../git-diff";+import { collectWorkspaceDiff } from "@pi-desktop/host-runtime";import { parseAllowedExternalUrl } from "../safe-open-external";import {isAttachmentBlobRef,@@ -34,7 +34,7 @@ import {readOpenableImage,resolveOpenablePath,resolveRealOpenablePath,-} from "../fs-panel";+} from "@pi-desktop/host-runtime";import { resolveChatFileRef } from "../chat-ref-resolve";import { getWorkspaceFileIndex } from "../fs-index";import {diff --git a/apps/desktop/electron/main/plugin-dev-tools.ts b/apps/desktop/electron/main/plugin-dev-tools.tsindex 8f9fa05cd..84ca2a2a4 100644--- a/apps/desktop/electron/main/plugin-dev-tools.ts+++ b/apps/desktop/electron/main/plugin-dev-tools.ts@@ -6,7 +6,7 @@ import {scaffold,type CheckResult,} from "@pi-desktop/plugin-devkit";-import { resolveWithinRoot } from "./fs-panel";+import { resolveWithinRoot } from "@pi-desktop/host-runtime";import type { AgentSidecar, LocalToolResult } from "./agent-sidecar";/**diff --git a/apps/desktop/electron/main/plugin-runtime.ts b/apps/desktop/electron/main/plugin-runtime.tsindex cbfbb636c..570b3b703 100644--- a/apps/desktop/electron/main/plugin-runtime.ts+++ b/apps/desktop/electron/main/plugin-runtime.ts@@ -77,7 +77,7 @@ import {resolveRealPathForCreateWithinRoot,resolveRealPathWithinRoot,resolveWithinRoot,-} from "./fs-panel";+} from "@pi-desktop/host-runtime";import { McpServerClient, type McpServerClientOptions } from "./plugin-mcp";import { PluginToolInvocations, type PluginToolInvocation } from "./plugin-tool-invocations";import { DevPluginWatcher, type DevPluginWatcherDeps } from "./plugin-watcher";@@ -986,7 +986,7 @@ export function readDevPluginDeclaration(pluginPath: string): {/*** `realpath` with the input as its own fallback, for a path that may not exist- * yet. Containment is decided by `fs-panel`'s checks; this only exists so the+ * yet. Containment is decided by the host-runtime workspace-files checks; this only exists so the* relative path we compare scopes against is expressed in the same terms.*/function realpathOrSelf(path: string): string {diff --git a/apps/desktop/test/fs-panel-guard.test.mjs b/apps/desktop/test/fs-panel-guard.test.mjsindex 0e4d69f64..cbac450d4 100644--- a/apps/desktop/test/fs-panel-guard.test.mjs+++ b/apps/desktop/test/fs-panel-guard.test.mjs@@ -16,7 +16,7 @@ import {resolveRealOpenablePath,resolveWithinRoot,MAX_TEXT_BYTES,-} from "../electron/main/fs-panel.ts";+} from "../../../packages/host-runtime/src/workspace-files.ts";const ROOT = resolve("virtual-workspace");diff --git a/apps/desktop/test/git-diff-parse.test.mjs b/apps/desktop/test/git-diff-parse.test.mjsindex 0383d3e4f..d72fc6345 100644--- a/apps/desktop/test/git-diff-parse.test.mjs+++ b/apps/desktop/test/git-diff-parse.test.mjs@@ -5,7 +5,7 @@ import {parseFilePatch,parseStatusZ,splitUnifiedDiff,-} from "../electron/main/git-diff.ts";+} from "../../../packages/host-runtime/src/workspace-diff.ts";test("parses porcelain -z status including renames and untracked", () => {const raw = [diff --git a/apps/desktop/test/message-image-display.test.mjs b/apps/desktop/test/message-image-display.test.mjsindex 684384d3e..d1ea0de95 100644--- a/apps/desktop/test/message-image-display.test.mjs+++ b/apps/desktop/test/message-image-display.test.mjs@@ -10,7 +10,7 @@ const [transcript, markdown, api, main, panel, protocol, hook] = await Promise.aread("../src/components/Markdown.tsx"),read("../src/lib/api.ts"),readMainSource(),- read("../electron/main/fs-panel.ts"),+ read("../../../packages/host-runtime/src/workspace-files.ts"),read("../../../packages/shared/src/protocol.ts"),read("../src/lib/use-referenced-image-data-url.ts"),]);diff --git a/packages/host-runtime/src/index.ts b/packages/host-runtime/src/index.tsindex 55720460b..e7034e40b 100644--- a/packages/host-runtime/src/index.ts+++ b/packages/host-runtime/src/index.ts@@ -10,3 +10,5 @@ export * from "./turn-persistence.js";export * from "./turn-events.js";export * from "./runtime-service.js";export * from "./plan-dispatch.js";+export * from "./workspace-files.js";+export * from "./workspace-diff.js";diff --git a/apps/desktop/electron/main/git-diff.ts b/packages/host-runtime/src/workspace-diff.tssimilarity index 100%rename from apps/desktop/electron/main/git-diff.tsrename to packages/host-runtime/src/workspace-diff.tsdiff --git a/apps/desktop/electron/main/fs-panel.ts b/packages/host-runtime/src/workspace-files.tssimilarity index 100%rename from apps/desktop/electron/main/fs-panel.tsrename to packages/host-runtime/src/workspace-files.ts