Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins
TypeScript ai-agentcoding-agentdesktop-appelectronglobali18nlocal-firstmcppipi-agentpi-desktoppluginsreactrusttypescript
const en = {
title: "Memory",
description: "Keep useful preferences and facts at user or project level.",
enabled: "Use memory",
disabledHint: "Memory is off for AI. You can still manage saved entries below.",
scopeHeading: "Available levels",
user: "User",
project: "Project",
userHint: "Shared across projects and sessions in this local PI profile.",
projectHint: "Shared only by sessions in the current project.",
aiReadEnabled: "AI recall",
aiReadHint: "Let the assistant look up relevant memories when needed.",
aiWriteEnabled: "AI write",
aiWriteHint: "Let the assistant save, update, or forget facts when requested. No automatic transcript extraction.",
privacy: "Stored locally. Recalled entries are returned to the conversation model. Do not store passwords or tokens.",
proposals: "Awaiting your confirmation",
proposalHint: "The assistant can only suggest user-level memories. Confirm one to save it, or dismiss it.",
proposalAccept: "Save",
proposalReject: "Dismiss",
proposalAccepted: "Proposal saved.",
proposalRejected: "Proposal dismissed.",
proposalNone: "No pending proposals.",
manage: "Manage memories",
scope: "Level",
noProject: "No project selected",
currentProject: "Current project",
titleLabel: "Label",
titleHint: "Saving again with the same label retires the earlier entry instead of deleting it.",
content: "Memory text",
add: "Add memory",
update: "Save changes",
saving: "Saving…",
cancel: "Cancel",
search: "Search this level",
empty: "No memories at this level yet.",
noResults: "No matching memories.",
edit: "Edit",
remove: "Delete",
confirmDelete: "Delete this memory? It is retired and keeps its history.",
confirm: "Confirm delete",
manual: "Manual",
ai: "AI",
refresh: "Refresh",
loading: "Loading memories…",
saved: "Memory saved.",
deleted: "Memory deleted.",
settingsSaved: "Memory settings saved.",
contextChanged: "The project or session changed. The list was refreshed and the previous draft was cleared.",
invalidContent: "Enter a non-empty memory within the character limit.",
unavailable: "Reload the plugin folder to use memory in this version.",
toolsUnavailable: "AI memory tools are unavailable. Load the plugin folder again and grant the agent tool permission. Manual memory management still works.",
error: "The memory request failed.",
count: (count) => `${count} ${count === 1 ? "memory" : "memories"}`,
revision: (value) => `Revision ${value}`,
};
const zh = {
title: "记忆",
description: "按用户和项目两个级别保存常用偏好和事实。",
enabled: "启用记忆",
disabledHint: "AI 记忆功能已关闭。仍可在下方管理已保存的记忆。",
scopeHeading: "可用级别",
user: "用户级别",
project: "项目级别",
userHint: "在此本地 PI 配置中的所有项目、会话间共享。",
projectHint: "仅在当前项目的会话间共享。",
aiReadEnabled: "AI 召回",
aiReadHint: "允许助手按需检索相关记忆。",
aiWriteEnabled: "AI 写入",
aiWriteHint: "允许助手根据请求保存、更新或遗忘事实,不自动提取每轮对话。",
privacy: "记忆保存在本地。召回的条目会交给当前对话模型。请勿保存密码或令牌。",
proposals: "等待你确认",
proposalHint: "助手只能建议用户级记忆。确认后才会保存,也可以直接忽略。",
proposalAccept: "保存",
proposalReject: "忽略",
proposalAccepted: "提案已保存。",
proposalRejected: "提案已忽略。",
proposalNone: "没有待确认的提案。",
manage: "管理记忆",
scope: "级别",
noProject: "未选择项目",
currentProject: "当前项目",
titleLabel: "标签",
titleHint: "用相同标签再次保存会让旧条目失效,而不是删除它。",
content: "记忆内容",
add: "添加记忆",
update: "保存修改",
saving: "保存中…",
cancel: "取消",
search: "搜索当前级别",
empty: "此级别暂无记忆。",
noResults: "没有匹配的记忆。",
edit: "编辑",
remove: "删除",
confirmDelete: "确认删除这条记忆?条目将失效,但会保留历史记录。",
confirm: "确认删除",
manual: "手动",
ai: "AI",
refresh: "刷新",
loading: "正在加载记忆…",
saved: "记忆已保存。",
deleted: "记忆已删除。",
settingsSaved: "记忆设置已保存。",
contextChanged: "项目或会话已切换。已刷新列表,并清空之前的编辑草稿。",
invalidContent: "请输入非空记忆,且不要超过字数限制。",
unavailable: "请重新加载插件文件夹,以使用此版本的记忆功能。",
toolsUnavailable: "AI 记忆工具不可用。请重新加载插件文件夹并授予 Agent 工具权限,手动记忆管理仍可使用。",
error: "记忆操作失败。",
count: (count) => `${count} 条记忆`,
revision: (value) => `版本 ${value}`,
};
export function memoryCopy(locale) {
return typeof locale === "string" && locale.toLowerCase().startsWith("zh") ? zh : en;
}
const zhErrors = {
MEMORY_CANCELLED: "记忆操作已取消。",
MEMORY_CAPACITY: "记忆或待确认提案已达上限。请清理条目或处理待确认提案后重试。",
MEMORY_CONFLICT: "记忆已变化或与现有条目重复。请刷新后重试。",
MEMORY_CONTEXT_CHANGED: "当前项目或会话已切换。请刷新后再操作。",
MEMORY_INVALID_INPUT: "记忆操作的输入无效。请检查内容和长度。",
MEMORY_NO_PROJECT: "当前会话未关联项目。",
MEMORY_NOT_FOUND: "该记忆或提案已不存在。请刷新列表。",
MEMORY_STORAGE_INVALID: "记忆存储无效或版本不受支持,原文件未被覆盖。",
MEMORY_STORAGE_IO: "无法读写记忆。请检查插件数据目录的权限后重试。",
MEMORY_UNAVAILABLE: "记忆功能不可用。请重新加载插件后重试。",
};
export function memoryError(locale, error) {
const copy = memoryCopy(locale);
if (copy === en && error?.message) return error.message;
return (copy === zh && Object.hasOwn(zhErrors, error?.code) ? zhErrors[error.code] : null)
?? (error?.code ? `${copy.error} (${error.code})` : copy.error);
}