Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(pi): 会话引擎显示/落库/身份全链修正 —— 实机测通 pi 会话
zqchrisf166e005b976
diff --git a/apps/desktop/src/main/maker-host/session-storage.ts b/apps/desktop/src/main/maker-host/session-storage.tsindex 540de0b55e..407613378f 100644--- a/apps/desktop/src/main/maker-host/session-storage.ts+++ b/apps/desktop/src/main/maker-host/session-storage.ts@@ -12,6 +12,8 @@import { and, eq, inArray } from 'drizzle-orm';+import { dbToMakerAgentKind, makerToDbAgentKind } from '../../shared/agentKindConversion.js';+import type {AgentKind,SessionMeta,@@ -25,14 +27,15 @@ import { normalizeRemoteHostId } from '../localDb/mapper.js';import { DESKTOP_VISIBLE_SESSION_SOURCES } from '../../shared/sessionSource.js';import { normalizeWorkingDirForStorage } from '../../shared/workingDir.js';-type DbAgentKind = 'cc' | 'codex';+type DbAgentKind = 'cc' | 'codex' | 'pi';+// 形态映射走 shared/agentKindConversion 正本(支持 pi;此前 pi 被误落成 codex)。function toDbKind(k: AgentKind): DbAgentKind {- return k === 'claude-code' ? 'cc' : 'codex';+ return makerToDbAgentKind(k);}function fromDbKind(k: string): AgentKind {- return k === 'codex' ? 'codex' : 'claude-code';+ return dbToMakerAgentKind(k);}function normalizeWorkspaceKind(value: unknown): WorkspaceKind {diff --git a/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx b/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsxindex a5f7f0b056..689adc4e81 100644--- a/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx+++ b/apps/desktop/src/renderer/components/new-chat/ModelSelector.tsx@@ -290,15 +290,17 @@ export function resolveModelSelectorAgentIdentity(runtimeAgentKind: AgentKind | null | undefined,pendingTarget: AgentKind | null | undefined,): ModelSelectorAgentIdentity | undefined {+ const toVendorKey = (kind: AgentKind): 'cc' | 'codex' | 'pi' =>+ kind === 'codex' ? 'codex' : kind === 'pi' ? 'pi' : 'cc';if (pendingTarget) {return {- vendorKey: pendingTarget === 'codex' ? 'codex' : 'cc',+ vendorKey: toVendorKey(pendingTarget),state: 'pending',};}if (!runtimeAgentKind) return undefined;return {- vendorKey: runtimeAgentKind === 'codex' ? 'codex' : 'cc',+ vendorKey: toVendorKey(runtimeAgentKind),state: 'current',};}@@ -1806,7 +1808,9 @@ export function ModelSelector({agentIdentity && !fallbackOption?.active? agentIdentity.vendorKey === 'cc'? t('newChat.modelSelector.trigger.agent.claudeCode')- : t('newChat.modelSelector.trigger.agent.codex')+ : agentIdentity.vendorKey === 'pi'+ ? t('newChat.modelSelector.trigger.agent.pi')+ : t('newChat.modelSelector.trigger.agent.codex'): null;const agentIdentityLabel =agentName && agentIdentity?.state === 'pending'diff --git a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsxindex 937701021b..2fb4be90e0 100644--- a/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/CCAgentSessionView.tsx@@ -24,7 +24,7 @@ import {} from 'react';import type { CSSProperties, ReactNode } from 'react';import { useLocation, useNavigate, useOutletContext, useParams } from 'react-router-dom';-import { normalizeDbAgentKind } from '../../../shared/agentKindConversion';+import { dbToMakerAgentKind, normalizeDbAgentKind } from '../../../shared/agentKindConversion';import { useTranslation } from 'react-i18next';import type { AgentInputReference } from '@cindy/maker-shared/agent-input-projection';import {@@ -714,7 +714,7 @@ export function CCAgentSessionView({if (!remoteDeviceId || !remoteModelMemoryScopeKey) return;const deviceId = remoteDeviceId;const scopeKey = remoteModelMemoryScopeKey;- const agent = session?.agentKind === 'codex' ? 'codex' : 'claude-code';+ const agent = dbToMakerAgentKind(session?.agentKind);const vendorSlot = agent === 'codex' ? 'codex' : 'claudeCode';let cancelled = false;@@ -1108,7 +1108,7 @@ export function CCAgentSessionView({const isRemoteSession = !!session?.remoteHostId;useEffect(() => {let cancelled = false;- const agentKind = session?.agentKind === 'codex' ? 'codex' : 'claude-code';+ const agentKind = dbToMakerAgentKind(session?.agentKind);// SSH remote 显式禁用控制端本机 skill 扫描;本地无 workingDir 时 Claude 仍扫全局 skills。const wd = session?.workingDir;// 先同步清空:切换会话(尤其 local→remote)时 loadAllCommands 是异步的,清空可避免@@ -1246,7 +1246,7 @@ export function CCAgentSessionView({} = useCCAgentChat(sessionId, handleTitleUpdate, { chatRealtime });// 展示引擎可乐观跟随 intent;真实 event reducer 仍只读 store.agentKind。const displayAgentKind =- agentSwitchIntent?.target ?? (session?.agentKind === 'codex' ? 'codex' : 'claude-code');+ agentSwitchIntent?.target ?? dbToMakerAgentKind(session?.agentKind);const isCodex = displayAgentKind === 'codex';// live 供应商目录(含内置 + 自定义,按 agent 挂模型)—— vendor↔model 一致性校验的真源,// 与模型选择器同源(见下方 M35 vendor fallback effect)。本地 IPC 极快返回,有模块级缓存。@@ -1626,7 +1626,7 @@ export function CCAgentSessionView({const getHelpCommandsSnapshot = useCallback(async (): Promise<UnifiedCommand[]> => {const cached = allCommandsRef.current;if (cached.length > 0) return cached;- const agentKind = session?.agentKind === 'codex' ? 'codex' : 'claude-code';+ const agentKind = dbToMakerAgentKind(session?.agentKind);try {// device-link 远程会话同源:传 remoteDeviceId,fallback 快照也从被控端读(见上方 cache effect 说明)。return await loadAllCommands(@@ -2153,7 +2153,7 @@ export function CCAgentSessionView({capabilities: sessionCaps,providerId: session?.providerId ?? null,modelId: newModelId,- agentKind: session?.agentKind === 'codex' ? 'codex' : 'claude-code',+ agentKind: dbToMakerAgentKind(session?.agentKind),});if (!supportsFast) {const currentFastMode = sessionId ? makerChatStore.getSnapshot(sessionId).fastMode : false;@@ -2696,7 +2696,7 @@ export function CCAgentSessionView({// 远程模型可能只存在于被控端(本地目录查不到 → 误判跨 vendor),且本地 DB 没有该会话行,// sessionService.update 会写错 / refreshServerSession 对远程是 no-op。直接跳过(规则:host 为准)。if (getSessionDeviceId(sessionId)) return;- const agent = isCodex ? 'codex' : 'claude-code';+ const agent = displayAgentKind;if (!shouldFallbackVendorModel(providers, sessionModel, agent)) return;const defaultModel = getDefaultModelForVendor(isCodex ? 'codex' : 'cc');sessionService@@ -3541,13 +3541,7 @@ export function CCAgentSessionView({sessionId={sessionId}// session=null 是冷启动 / 直链 GET 尚未回流的合法首帧;显式传 null,// 让 ChatInput 暂不显示 Agent 身份,不能跟随 displayAgentKind 的 cc 回退。- runtimeAgentKind={- session- ? session.agentKind === 'codex'- ? 'codex'- : 'claude-code'- : null- }+ runtimeAgentKind={session ? dbToMakerAgentKind(session.agentKind) : null}initialWorkingDir={session?.workingDir}remoteHostId={session?.remoteHostId ?? null}deviceLinkDeviceId={remoteDeviceId}@@ -3588,7 +3582,7 @@ export function CCAgentSessionView({attachmentState={attachmentState}externalDragOver={isDragOver}onComposerDropHandled={resetFullAreaDragState}- vendorKey={isCodex ? 'codex' : 'cc'}+ vendorKey={normalizeDbAgentKind(displayAgentKind)}extraDirs={session?.extraDirs ?? []}onExtraDirsChange={handleExtraDirsChange}compactToolbar={compactToolbar}diff --git a/apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsx b/apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsxindex c04f519301..962282d14c 100644--- a/apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsx+++ b/apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsx@@ -2709,7 +2709,7 @@ export function NewMakerDraftRoute() {// seed store,否则勾了计划模式的首条消息可能以 planMode:false 发出// (worktree 路径同款 seed;bot review P2)。makerChatStore.setSessionRuntime(newSession.id, {- agentKind: persistedAgentKind === 'codex' ? 'codex' : 'claude-code',+ agentKind: capabilityAgentKind,fastMode: effectiveFastMode,planModeEnabled: effectivePlanMode,});diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 100ef8c269..57afff7623 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -4625,6 +4625,7 @@"agent": {"claudeCode": "Claude Code","codex": "Codex",+ "pi": "Pi","pending": "Next: {{agent}}"}},diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex 7896b247b7..503c1e1f3a 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -4623,6 +4623,7 @@"agent": {"claudeCode": "Claude Code","codex": "Codex",+ "pi": "Pi","pending": "次回:{{agent}}"}},diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 7ae1b63f49..7b6b445045 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -4623,6 +4623,7 @@"agent": {"claudeCode": "Claude Code","codex": "Codex",+ "pi": "Pi","pending": "다음: {{agent}}"}},diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex 64f23587b3..d3aa21fc54 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -4623,6 +4623,7 @@"agent": {"claudeCode": "Claude Code","codex": "Codex",+ "pi": "Pi","pending": "下条:{{agent}}"}},diff --git a/apps/desktop/src/renderer/lib/makerChatStore.ts b/apps/desktop/src/renderer/lib/makerChatStore.tsindex 097fa5fa67..63d3df4168 100644--- a/apps/desktop/src/renderer/lib/makerChatStore.ts+++ b/apps/desktop/src/renderer/lib/makerChatStore.ts@@ -22,6 +22,7 @@*/import type { CindyRegion } from '@cindy/maker-shared/brand-identity';+import { dbToMakerAgentKind } from '../../shared/agentKindConversion';import { redactSensitiveText } from '@cindy/maker-shared/error-redaction';import { applyCodexPlanSnapshotOnDone } from '@cindy/maker-shared/message-render';import {@@ -9063,7 +9064,7 @@ function mirrorSessionFields(// 同步清 sdkSessionId(旧引擎的原生会话 id 对新引擎无意义,与 noteAgentSwitched// 口径一致)。幂等:发起窗口已 noteAgentSwitched → 同值 no-op。if (patch.agentKind === 'cc' || patch.agentKind === 'codex' || patch.agentKind === 'pi') {- const nextKind = patch.agentKind === 'codex' ? 'codex' : 'claude-code';+ const nextKind = dbToMakerAgentKind(patch.agentKind);setState(sessionId, (s) => {const intentApplied = s.agentSwitchIntent?.target === nextKind;if (s.agentKind === nextKind && !intentApplied) return s;diff --git a/packages/maker-core/src/agents/pi/index.ts b/packages/maker-core/src/agents/pi/index.tsindex eb07c8261e..f2928ba6d7 100644--- a/packages/maker-core/src/agents/pi/index.ts+++ b/packages/maker-core/src/agents/pi/index.ts@@ -58,7 +58,9 @@ const PI_PROVIDER_ID = 'cindy';const PI_API_KEY_ENV = 'CINDY_PI_API_KEY';/** pi 内置 prompt 被 --system-prompt 整体替换后的最小基底段。 */-const PI_SYSTEM_PROMPT_BASE = `You are a coding agent running inside Cindy. You help users by reading files, executing commands, editing code, and writing new files.+const PI_SYSTEM_PROMPT_BASE = `You are a coding agent running inside the pi coding agent harness (github.com/earendil-works/pi), embedded into Cindy. You help users by reading files, executing commands, editing code, and writing new files.++Your agent harness is pi. When asked which harness, agent, or CLI framework you run in, answer "pi" — not Claude Code or Codex. Your underlying language model may come from any provider routed through Cindy's gateway; that is separate from the harness, which is pi.Guidelines:- Be concise in your responses