Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
Merge origin/main into fix/page-copy-concision
vastsa9952a46baefe
diff --cc docs/adr/0269-capability-level-transfer.mdindex 23c61d7d8,000000000..623f5f341mode 100644,000000..100644--- a/docs/adr/0269-capability-level-transfer.md+++ b/docs/adr/0269-capability-level-transfer.md@@@ -1,155 -1,0 +1,155 @@@- # ADR 0267: Move capability documents between the global and project levels++# ADR 0269: Move capability documents between the global and project levels++- Status: Accepted for implementation+- Date: 2026-09-16+- Amends: ADR 0112 (agent capability management roots and Settings IA — adds a+ cross-level move to the capability surfaces)+- Related: ADR 0056 (user-owned MCP servers and skills), D193, D194++## Context++ADR 0112 made `.agents` the only capability root and separated file ownership+from app-local activation state: an MCP server or skill lives globally+(`~/.agents/servers`, `~/.agents/skills`) or inside a project+(`<project>/.agents/...`), while `<data>/agent-capabilities/*.json` records+whether it is enabled, with a per-project override for global documents. The two+levels were reachable only as two independent lists. Changing a capability's+level therefore meant deleting the file at one level and recreating it at the+other: the user had to retype the document, the enablement decision was lost,+and a mistake destroyed the only copy. Nothing in the Settings IA expressed the+switch as one action.++Users do legitimately change their mind about ownership — a scratch server+graduates from one project to every project, or a global experiment turns out to+belong to one repository. This ADR records the move that the MCP and Skill pages+now expose (`mcp.transfer` / `skills.transfer`).++## Decision++### 1. A level switch moves the document; it does not copy it++The file's level *is* its ownership. A copy would leave the source level holding+a definition the user just said belongs elsewhere, so the same capability would+appear twice with two names until the user cleaned up the old one — and the two+would drift. The source level stops listing the entry, and the destination holds+the only file.++The move is one unit per capability: `McpServerRegistry::transfer` relocates the+server's JSON file, and `UserSkillRegistry::transfer` relocates either the single+Markdown document or, for the conventional `<skill>/SKILL.md` shape, the whole+skill directory with the sibling resources a `Skill` invocation resolves+(`directory_skill_root`, `copy_directory_contents`). `move_capability_file`+tries `fs::rename` first so a same-filesystem move is atomic and cheap, and+falls back to copy-then-remove for a project on another mount. When the document+must be rewritten (the rename case below), the destination is written before the+source is removed, so an interrupted move leaves a shadowed duplicate rather+than no capability at all.++### 2. A destination collision renames the arriving document; it never blocks the move++The destination level may already own the same id, or the same display name /+label compared case-insensitively, the way project-over-global shadowing+compares it. Overwriting an existing document would be data loss, and refusing+the move would make the level switch useless whenever both sides happen to share+a name. The arriving document is therefore disambiguated the way a file manager+disambiguates a copy: a colliding id takes a `-2`/`-3`… suffix (within the+64-character id budget, `suffixed_capability_id`), and a colliding display name+takes a ` (2)`/` (3)`… suffix (`suffixed_display_name`). The existing entry and+its file stay untouched, and the RPC response returns the record under the id+it landed on so the UI can follow the rename.++Renaming a skill rewrites only the frontmatter `name` line+(`rewrite_document_name`); every other frontmatter field, the whitespace, the+line endings, and the body are copied byte for byte, because the user asked to+relocate a document, not to reformat it. A document with no parsable frontmatter+block gets a fresh one so the renamed file is still scannable.++A skill's identity is not its file name, and the move has to plan against the+scanner rather than the filesystem. The catalog derives a skill's id with+`capability_id`: the slug of the frontmatter `name` when that slug is usable,+otherwise the slug of the path stem, and a hash as a last resort. A Chinese+name, or a name whose slug already belongs to another document, therefore lands+on an id the file name does not predict. Choosing a file name first and reading+the id back from it produced exactly the failure this decision avoids: the+source file was gone while the arrival was reported missing, and a same-id+document silently lost the scan's de-duplication and vanished from Settings.+`plan_skill_placement` now replays the real `capability_id` for the exact path+each candidate would occupy, accepts only a placement the scan lists as its own+record, and `transfer` resolves the arrived record by path — never by the stem+it chose — so the state entry is written under the id the catalog will read+back. A landing the scan still refuses (an empty body, an oversized document)+is rolled back to the source with its original bytes, because no state has been+written yet and a loud error beats a stranded file.++The same reasoning makes id collisions case-insensitive: macOS and Windows both+hand back one file for `MyServer.json` and `myserver.json`, so a move that+compared ids literally would write over a definition it never listed.+++One artifact of that pre-existing `capability_id` rule is accepted rather than+changed here: a non-ASCII name that has to be suffixed gains ASCII characters,+and those characters alone become its slug. A Chinese-named skill arriving+beside a same-named one therefore lands on the id `2`, not on a readable stem.+Making the slug ignore a purely numeric remainder would change how every+imported document is identified, which is a wider decision than a level move.+### 3. Activation state follows the document++State is app-local and ownership-free, so a move that left the old enablement+behind would silently change whether the capability runs, and a move that left+entries at the source level would leave pointers to an id that no longer exists+there. `set_moved_capability_state` therefore drops the source level's state for+the old id — via `CapabilityState::forget`, including every project override a+moved global document had — and writes the value the source row was showing at+the destination:++- moving into a project stores that project's own state;+- moving into global stores that value as the new global default, never another+ project's override, because the move says nothing about the projects the+ document left behind.++A global source read may carry a `projectPath`, which is exactly the context the+visible value is resolved in; `CapabilityTarget` keeps that field so the two+meanings — "owner" and "state context" — are never confused.++### 4. The two ends are explicit and a same-directory move is a no-op++`mcp.transfer` / `skills.transfer` take `{ id, from, to }`, each end a+`{ level, projectPath? }` target, instead of a single level and an implicit+"other side": the two ends can never be derived from one another wrongly, and a+project-level end without `projectPath` fails with `CAPABILITY_INVALID`.+`CapabilityTarget::same_directory` makes a move whose ends name the same+directory a no-op that returns the current record, so a UI that offers the+action redundantly can never rewrite the file.++### 5. The global `.agents` root has a redirect seam++`PI_DESKTOP_AGENTS_DIR` repoints the global capability root, the way+`PI_DESKTOP_DATA_DIR` repoints the app-local data directory; an empty value+falls back to the home directory (`AGENTS_DIR_ENV`, `global_agents_dir`). A+cross-level move spans the real home directory and a project, so without the+seam the global half of the feature can only be tested against the developer's+own `~/.agents`, and an isolated or portable install cannot place its global+capabilities anywhere but the user's home. It is a test and installation seam,+not a user setting, and it is not exposed in Settings.++## Consequences++- A capability has exactly one home. The Settings row disappears from the source+ group and appears in the destination group, which is the confirmation the move+ happened; a same-level duplicate is impossible by construction.+- A directory skill keeps working after the move because its resources travel+ with the document; a renamed directory skill is written under its new id.+- Collisions stay productive: both definitions survive under names the user can+ tell apart, at the cost of the user having to recognize the `-2` name as the+ one they just moved.+- A moved global document drops its other projects' overrides. Those entries no+ longer name any global document, so keeping them would be state for a+ capability that does not exist; the projects simply fall back to no entry.+- The move is host-owned and does not touch the renderer's level queries:+ `mcp.list` / `mcp.active` / `skills.list` / `skills.active` report the result+ after the scan, and the document itself never carries `enabled`.+- Validation: transfer, rename, state, and directory-resource paths are covered+ by host-core registry tests, and the move-menu destination rule has a+ source-contract test in `apps/desktop/test/agent-capability-settings.test.mjs`.+ The rendered journey is specified as E2E-CAPABILITY-move-across-levels and+ remains Draft until a rendered E2E run is performed.diff --cc docs/adr/README.mdindex 5b14e4e01,8e19f33c9..6585acac6--- a/docs/adr/README.md+++ b/docs/adr/README.md@@@ -293,4 -293,5 +293,6 @@@ Each ADR includes| session-content-search | [Discover sessions by indexed message text](session-content-search.md) | Accepted || transcript-reading-ownership | [Share renderer history and search views](transcript-reading-ownership.md) | Accepted || 0266 | [Plugin fs roots follow the calling session](0266-plugin-fs-root-follows-the-calling-session.md) | Accepted (D093) |- | 0267 | [Move capability documents between the global and project levels](0267-capability-level-transfer.md) | Accepted for implementation (amends ADR 0112) |+ | 0267 | [Plugin labels follow the app language](0267-plugin-labels-follow-the-app-language.md) | Accepted (amends 0160; ADR 0182) |+ | 0268 | Remove quotes, annotations, and side chats | Accepted (supersedes message-quotes-and-side-chats / response-annotations / floating-annotation-index) |++| 0269 | [Move capability documents between the global and project levels](0269-capability-level-transfer.md) | Accepted for implementation (amends ADR 0112) |diff --cc packages/i18n/src/locales/de/index.tsindex 63deba39a,2b4476929..ad429f678--- a/packages/i18n/src/locales/de/index.ts+++ b/packages/i18n/src/locales/de/index.ts@@@ -463,18 -495,10 +445,8 @@@ export const de ="thinking": "Denken","thinkingShow": "Denken anzeigen","thinkingHide": "Denken ausblenden",- "thinkingUnavailable": "Denken ist für dieses Modell nicht verfügbar.",- "thinkingEnable": "Denken aktivieren","untitledTask": "Neue Aufgabe"},- "sideChat": {- parentBusy: "Das Hauptgespräch antwortet noch. Warte auf das Ende, bevor du diesen Seitenchat startest.",- readOnly: "Diese native Pi-Sitzung ist derzeit schreibgeschützt.",- "title": "Seitenchat",- "sessionTitle": "Seitenchat: {{title}}",- "placeholder": "Stellen Sie eine Rückfrage zu dieser Antwort",- "empty": "Fragen Sie hier, ohne die Hauptkonversation zu ändern.",- "addToMain": "Zum Hauptchat hinzufügen",- "openAsSession": "Als Konversation öffnen"- },"session": {"renameTitle": "Aufgabe umbenennen","renameAction": "Aufgabe umbenennen {{title}}",diff --cc packages/i18n/src/locales/en/index.tsindex 56bdb617a,9bfecae6f..a422d23c7--- a/packages/i18n/src/locales/en/index.ts+++ b/packages/i18n/src/locales/en/index.ts@@@ -470,18 -502,10 +452,8 @@@ export const en =thinking: "Thinking",thinkingShow: "Show thinking",thinkingHide: "Hide thinking",- thinkingUnavailable: "Thinking isn't available for this model.",- thinkingEnable: "Enable thinking",untitledTask: "New task",},- sideChat: {- parentBusy: "The main conversation is still replying. Wait for it to finish before starting this side chat.",- readOnly: "This native Pi session is read-only right now.",- title: "Side chat",- sessionTitle: "Side chat: {{title}}",- placeholder: "Ask a follow-up about this answer",- empty: "Ask here to keep the main conversation unchanged.",- addToMain: "Add to main chat",- openAsSession: "Open as a conversation",- },session: {renameTitle: "Rename task",renameAction: "Rename task {{title}}",diff --cc packages/i18n/src/locales/es/index.tsindex 8a1f08f90,459804de7..cbcc05190--- a/packages/i18n/src/locales/es/index.ts+++ b/packages/i18n/src/locales/es/index.ts@@@ -463,18 -495,10 +445,8 @@@ export const es ="thinking": "Pensamiento","thinkingShow": "Mostrar pensamiento","thinkingHide": "Ocultar pensamiento",- "thinkingUnavailable": "Pensamiento no está disponible para este modelo.",- "thinkingEnable": "Habilitar el pensamiento","untitledTask": "Nueva tarea"},- "sideChat": {- parentBusy: "La conversación principal sigue respondiendo. Espera a que termine antes de iniciar este chat lateral.",- readOnly: "Esta sesión nativa de Pi es de solo lectura en este momento.",- "title": "Chat lateral",- "sessionTitle": "Chat lateral: {{title}}",- "placeholder": "Haga una pregunta de seguimiento sobre esta respuesta",- "empty": "Pregunte aquí para no cambiar la conversación principal.",- "addToMain": "Añadir al chat principal",- "openAsSession": "Abrir como conversación"- },"session": {"renameTitle": "Cambiar nombre de tarea","renameAction": "Cambiar nombre de tarea {{title}}",diff --cc packages/i18n/src/locales/fr/index.tsindex 5a99863d4,9d938a226..fa7a4b7fb--- a/packages/i18n/src/locales/fr/index.ts+++ b/packages/i18n/src/locales/fr/index.ts@@@ -463,18 -495,10 +445,8 @@@ export const fr ="thinking": "Réflexion","thinkingShow": "Afficher la réflexion","thinkingHide": "Masquer la réflexion",- "thinkingUnavailable": "La réflexion n'est pas disponible pour ce modèle.",- "thinkingEnable": "Activer la réflexion","untitledTask": "Nouvelle tâche"},- "sideChat": {- parentBusy: "La conversation principale répond encore. Attendez la fin avant de démarrer cette discussion latérale.",- readOnly: "Cette session Pi native est en lecture seule pour le moment.",- "title": "Chat latéral",- "sessionTitle": "Chat latéral : {{title}}",- "placeholder": "Posez une question complémentaire sur cette réponse",- "empty": "Posez votre question ici, sans modifier la conversation principale.",- "addToMain": "Ajouter au chat principal",- "openAsSession": "Ouvrir comme conversation"- },"session": {"renameTitle": "Renommer la tâche","renameAction": "Renommer la tâche {{title}}",diff --cc packages/i18n/src/locales/ko/index.tsindex dfba65309,b9275a9e5..1591ccfbf--- a/packages/i18n/src/locales/ko/index.ts+++ b/packages/i18n/src/locales/ko/index.ts@@@ -472,18 -504,10 +454,8 @@@ export const ko =thinking: "생각 중",thinkingShow: "생각 표시",thinkingHide: "생각 숨기기",- thinkingUnavailable: "이 모델에서는 생각 기능을 사용할 수 없습니다.",- thinkingEnable: "생각 기능 켜기",untitledTask: "새 작업",},- sideChat: {- parentBusy: "기본 대화가 응답 중입니다. 응답이 끝난 후 사이드 채팅을 시작하세요.",- readOnly: "이 네이티브 Pi 세션은 현재 읽기 전용입니다.",- title: "사이드 채팅",- sessionTitle: "사이드 채팅: {{title}}",- placeholder: "이 답변에 대해 이어서 질문하세요",- empty: "여기에서 질문하면 기본 대화가 그대로 유지됩니다.",- addToMain: "기본 대화에 추가",- openAsSession: "대화로 열기",- },session: {renameTitle: "작업 이름 바꾸기",renameAction: "작업 이름 바꾸기 {{title}}",diff --cc packages/i18n/src/locales/tr/index.tsindex 97fdfb1d2,75e6149a7..1e4bfd443--- a/packages/i18n/src/locales/tr/index.ts+++ b/packages/i18n/src/locales/tr/index.ts@@@ -472,18 -504,10 +454,8 @@@ export const tr =thinking: "Düşünme",thinkingShow: "Düşünmeyi göster",thinkingHide: "Düşünmeyi gizle",- thinkingUnavailable: "Bu model için düşünme yok.",- thinkingEnable: "Düşünmeyi aç",untitledTask: "Yeni görev",},- sideChat: {- parentBusy: "Ana sohbet hâlâ yanıt veriyor. Yan sohbeti başlatmadan önce bitmesini bekleyin.",- readOnly: "Bu yerel Pi oturumu şu anda salt okunur.",- title: "Yan sohbet",- sessionTitle: "Yan sohbet: {{title}}",- placeholder: "Bu yanıtla ilgili ek soru sorun",- empty: "Buradan sorun, ana sohbet değişmeden kalır.",- addToMain: "Ana sohbete ekle",- openAsSession: "Sohbet olarak aç",- },session: {renameTitle: "Görevi yeniden adlandır",renameAction: "{{title}} görevini yeniden adlandır",diff --cc packages/i18n/src/locales/zh-CN/index.tsindex 348253afd,994fdb9f5..9f9e2fa7a--- a/packages/i18n/src/locales/zh-CN/index.ts+++ b/packages/i18n/src/locales/zh-CN/index.ts@@@ -468,18 -500,10 +450,8 @@@ export const zhCN =thinking: "思考",thinkingShow: "显示思考过程",thinkingHide: "隐藏思考过程",- thinkingUnavailable: "当前模型不支持思考过程。",- thinkingEnable: "开启思考",untitledTask: "新建任务",},- sideChat: {- parentBusy: "主会话仍在回复中,请等待回复结束后再发送侧边问题。",- readOnly: "该原生 Pi 会话当前为只读状态。",- title: "侧边聊天",- sessionTitle: "侧边聊天:{{title}}",- placeholder: "就这条回复继续追问",- empty: "在这里追问,主对话不受影响。",- addToMain: "加入主对话",- openAsSession: "作为对话打开",- },session: {renameTitle: "重命名任务",renameAction: "重命名任务“{{title}}”",diff --cc packages/i18n/src/locales/zh-TW/index.tsindex da4d9302c,638bf5a06..dbc65743a--- a/packages/i18n/src/locales/zh-TW/index.ts+++ b/packages/i18n/src/locales/zh-TW/index.ts@@@ -468,18 -500,10 +450,8 @@@ export const zhTW =thinking: "思考",thinkingShow: "顯示思考過程",thinkingHide: "隱藏思考過程",- thinkingUnavailable: "當前模型不支援思考過程。",- thinkingEnable: "開啟思考",untitledTask: "新建任務",},- sideChat: {- parentBusy: "主對話仍在回覆中,請等待回覆結束後再傳送側邊問題。",- readOnly: "此原生 Pi 工作階段目前為唯讀狀態。",- title: "側邊聊天",- sessionTitle: "側邊聊天:{{title}}",- placeholder: "就這則回覆繼續追問",- empty: "在這裡追問,主對話不受影響。",- addToMain: "加入主對話",- openAsSession: "作為對話開啟",- },session: {renameTitle: "重新命名任務",renameAction: "重新命名任務“{{title}}”",