Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
feat(pi): 跟随用户主语言生成内容
Chris0cde5998ca15
diff --git a/apps/desktop/src/main/maker-host/__tests__/piSystemPrompt.test.ts b/apps/desktop/src/main/maker-host/__tests__/piSystemPrompt.test.tsnew file mode 100644index 0000000000..09191056fb--- /dev/null+++ b/apps/desktop/src/main/maker-host/__tests__/piSystemPrompt.test.ts@@ -0,0 +1,20 @@+import { describe, expect, it } from 'vitest';++import { composePiSystemPrompt } from '../pi-host.js';++describe('composePiSystemPrompt', () => {+ it('keeps the shared identity first and appends the Pi language behavior', () => {+ const prompt = composePiSystemPrompt(+ 'You are Cindy.',+ "Infer the user's primary language and use it for reasoning and user-facing content.",+ );++ expect(prompt).toBe(+ "You are Cindy.\n\nInfer the user's primary language and use it for reasoning and user-facing content.",+ );+ });++ it('trims sections and omits empty ones', () => {+ expect(composePiSystemPrompt(' You are Cindy. ', ' ')).toBe('You are Cindy.');+ });+});diff --git a/apps/desktop/src/main/maker-host/pi-host.ts b/apps/desktop/src/main/maker-host/pi-host.tsindex c7d82edd07..fc200c5a55 100644--- a/apps/desktop/src/main/maker-host/pi-host.ts+++ b/apps/desktop/src/main/maker-host/pi-host.ts@@ -36,6 +36,7 @@ import { getClaudeEndpoint } from './anthropic-compat-proxy-host.js';import { hasClaudeAiOAuth } from './claude-credentials-store.js';import { hasGrokOAuthLogin } from './grok-oauth-login.js';import hostSystemPrompt from './host-system-prompt.md?raw';+import piSystemPrompt from './pi-system-prompt.md?raw';import { createLogger } from '../logger.js';const log = createLogger('pi-host');@@ -135,10 +136,17 @@ export const desktopPiAuthAdapter: AuthAdapter = new DesktopPiAuthAdapter();// ── RuntimeConfig ────────────────────────────────────────────────────────────+export function composePiSystemPrompt(hostPrompt: string, agentPrompt: string): string {+ return [hostPrompt, agentPrompt]+ .map((section) => section.trim())+ .filter(Boolean)+ .join('\n\n');+}+function buildDesktopPiRuntimeConfig(): AgentRuntimeConfig {const config: AgentRuntimeConfig = {- // P0 只挂 host 共用产品段;pi 专属段(pi-system-prompt.md)等行为面稳定后再立。- systemPrompt: hostSystemPrompt.trim(),+ // 保留 host 共用身份段,再追加 Pi 专属行为段;maker-core 会整体追加到 Pi 原生 prompt。+ systemPrompt: composePiSystemPrompt(hostSystemPrompt, piSystemPrompt),userDataPath: app.getPath('userData'),};// 网关 endpoint 随 model-access 凭据同步就绪,用 getter 惰性读(与 claude remoteEndpoint 同理)。diff --git a/apps/desktop/src/main/maker-host/pi-system-prompt.md b/apps/desktop/src/main/maker-host/pi-system-prompt.mdnew file mode 100644index 0000000000..36b11e024a--- /dev/null+++ b/apps/desktop/src/main/maker-host/pi-system-prompt.md@@ -0,0 +1 @@+Infer the user's primary language from the conversation and any explicit language preference. Whenever practical, use that language by default for reasoning, planning, explanations, and user-facing content. Preserve the language required by code, commands, identifiers, quoted material, external interfaces, or an explicit user request.