Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(ios-simulator): restore helper packaging
JiangJiahao70c80b37b5db
diff --git a/apps/desktop/forge.config.ts b/apps/desktop/forge.config.tsindex cedb601081..2c294109df 100644--- a/apps/desktop/forge.config.ts+++ b/apps/desktop/forge.config.ts@@ -22,6 +22,7 @@ import {import { stagePackagedThirdPartyNotices } from './forge-third-party-notices';const _require = createRequire(__filename);+const DESKTOP_PACKAGE_VERSION = (_require('./package.json') as { version: string }).version;// ── 构建期身份(2026-07-17 Cindy 渠道分叉) ─────────────────────────────────────// 区域默认 global;中国大陆包由发布脚本显式注入 CINDY_AUTH_REGION=cn。appId 随区域@@ -680,6 +681,54 @@ function applyMacPackagedDisplayName(buildPath: string, platform: string): void}}+const IOS_SIMULATOR_HELPER_BUNDLE = 'Cindy iOS Simulator Helper.app';+const IOS_SIMULATOR_HELPER_EXECUTABLE = 'ios-simulator-sidecar';++/**+ * Forge first copies the Host-owned helper through extraResource, then this+ * postPackage step moves it into the canonical nested-code location. Raw dev+ * binaries and the temporary helper staging directory must not remain in the+ * final application bundle.+ */+function stageMacIOSSimulatorHelper(buildPath: string, platform: string): void {+ if (platform !== 'darwin' && platform !== 'mas') return;+ const apps = fs.readdirSync(buildPath).filter((name) => name.endsWith('.app'));+ if (apps.length !== 1) {+ throw new Error(+ `[forge:postPackage] expected one macOS app while staging iOS Simulator helper, found ${apps.length}`,+ );+ }++ const appContents = path.join(buildPath, apps[0], 'Contents');+ const resourceRoot = path.join(appContents, 'Resources', 'ios-simulator');+ const sourceBundle = path.join(resourceRoot, 'helper', IOS_SIMULATOR_HELPER_BUNDLE);+ const destinationBundle = path.join(appContents, 'Helpers', IOS_SIMULATOR_HELPER_BUNDLE);+ const sourceExecutable = path.join(+ sourceBundle,+ 'Contents',+ 'MacOS',+ IOS_SIMULATOR_HELPER_EXECUTABLE,+ );+ if (!fs.existsSync(sourceExecutable)) {+ throw new Error(+ `[forge:postPackage] staged iOS Simulator helper executable missing at ${sourceExecutable}`,+ );+ }++ fs.mkdirSync(path.dirname(destinationBundle), { recursive: true });+ fs.rmSync(destinationBundle, { recursive: true, force: true });+ fs.renameSync(sourceBundle, destinationBundle);+ fs.rmSync(path.join(resourceRoot, 'helper'), { recursive: true, force: true });+ fs.rmSync(path.join(resourceRoot, 'native'), { recursive: true, force: true });+ fs.chmodSync(+ path.join(destinationBundle, 'Contents', 'MacOS', IOS_SIMULATOR_HELPER_EXECUTABLE),+ 0o755,+ );+ console.log(+ `[forge:postPackage] staged ${IOS_SIMULATOR_HELPER_BUNDLE} in ${apps[0]}/Contents/Helpers`,+ );+}+function targetPlatformKey(targetPlatform: string, targetArch: string): string {return `${targetPlatform}-${targetArch}`;}@@ -760,6 +809,13 @@ function extraResourcesForTarget(targetPlatform: string): string[] {base.unshift(`resources/${UPDATER_EXE}`);}+ if (targetPlatform === 'darwin' || targetPlatform === 'mas') {+ // WDA archive/manifest are runtime resources. The Host-owned Helper is+ // temporarily copied here and moved to Contents/Helpers by postPackage so+ // the signing pipeline can treat it as nested code.+ base.push('resources/ios-simulator');+ }+// macOS 「帮助 → 安装到命令行」symlink 的目标脚本(<App>/Contents/Resources/cli/cindy)。// 仅 darwin 有此功能,其它平台不打进包。exec 位由 git 跟踪,extraResource 拷贝时保留。if (targetPlatform === 'darwin') {@@ -881,6 +937,52 @@ function swiftArchLabel(arch: ForgeArch, deploymentTarget: string): string {.join('+');}+function iosSimulatorSidecarArch(arch: ForgeArch): 'arm64' | 'x86_64' | 'universal' {+ switch (arch) {+ case 'arm64':+ return 'arm64';+ case 'x64':+ return 'x86_64';+ case 'universal':+ return 'universal';+ default:+ throw new Error(`[forge] unsupported iOS Simulator helper arch: ${arch}`);+ }+}++function buildMacIOSSimulatorHelper(platform: ForgePlatform, arch: ForgeArch): void {+ if (process.platform !== 'darwin' || !isMacForgePlatform(platform)) return;+ const script = path.join(+ __dirname,+ '..',+ '..',+ 'packages',+ 'ios-simulator-runtime',+ 'scripts',+ 'build-native-sidecar.mjs',+ );+ const helperArch = iosSimulatorSidecarArch(arch);+ const result = spawnSync(process.execPath, [script], {+ cwd: path.join(__dirname, '..', '..'),+ env: {+ ...process.env,+ CINDY_IOS_SIDECAR_ARCH: helperArch,+ CINDY_IOS_SIDECAR_OUTPUT_MODE: 'helper',+ CINDY_IOS_SIDECAR_BUNDLE_ID: `${CINDY_APP_ID}.ios-simulator-helper`,+ CINDY_IOS_SIDECAR_VERSION: process.env.APP_VERSION ?? DESKTOP_PACKAGE_VERSION,+ },+ stdio: 'inherit',+ });+ if (result.error) {+ throw new Error(`[forge] iOS Simulator helper build failed: ${result.error.message}`);+ }+ if (result.status !== 0) {+ throw new Error(+ `[forge] iOS Simulator helper build failed for ${helperArch} with exit code ${result.status}`,+ );+ }+}+function runSwiftcForTarget(src: string, dest: string, target: string, extraArgs: string[], label: string): void {const r = spawnSync('swiftc', ['-target', target, src, ...extraArgs, '-o', dest], { stdio: 'inherit' });if (r.error) throw new Error(`[forge] swiftc spawn failed for ${label}: ${r.error.message}`);@@ -1300,6 +1402,7 @@ const config: ForgeConfig = {}stageRipgrep(targetPlatform, targetArch);stageAndroidPlatformTools(targetPlatform, targetArch);+ buildMacIOSSimulatorHelper(platform, arch);buildMacVoiceInputTextInsertionHelper(platform, arch);buildMacVoiceInputModifierShortcutListener(platform, arch);buildMacAgentIslandHelper(platform, arch);@@ -1313,6 +1416,7 @@ const config: ForgeConfig = {const noticeName = stagePackagedThirdPartyNotices(buildPath, opts.platform);console.log(`[forge:postPackage] staged ${noticeName} + restricted component disclosure`);signPackagedExes(buildPath);+ stageMacIOSSimulatorHelper(buildPath, opts.platform);applyMacPackagedDisplayName(buildPath, opts.platform);}},diff --git a/apps/desktop/src/main/mcp-integrations/__tests__/ios-simulator-artifact.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/ios-simulator-artifact.test.tsindex 0bc0e98298..ca4ea22c46 100644--- a/apps/desktop/src/main/mcp-integrations/__tests__/ios-simulator-artifact.test.ts+++ b/apps/desktop/src/main/mcp-integrations/__tests__/ios-simulator-artifact.test.ts@@ -154,6 +154,53 @@ function createCommandRunner(}describe('packaged iOS Simulator sidecar artifact verification', () => {+ it('builds and stages the Host-owned Helper in a clean Forge package', async () => {+ const testDirectory = path.dirname(fileURLToPath(import.meta.url));+ const sourcePath = path.resolve(testDirectory, '../../../../forge.config.ts');+ const source = await readFile(sourcePath, 'utf8');+ const resourcesStart = source.indexOf('function extraResourcesForTarget');+ const resourcesEnd = source.indexOf('function assertRealAndroidPlatformTool');+ const buildStart = source.indexOf('function buildMacIOSSimulatorHelper');+ const buildEnd = source.indexOf('function runSwiftcForTarget');+ const stageStart = source.indexOf('function stageMacIOSSimulatorHelper');+ const stageEnd = source.indexOf('function targetPlatformKey');+ const prePackageStart = source.indexOf('prePackage: async');+ const postPackageStart = source.indexOf('postPackage: async');+ const postPackageEnd = source.indexOf(' makers,', postPackageStart);++ for (const marker of [+ resourcesStart,+ resourcesEnd,+ buildStart,+ buildEnd,+ stageStart,+ stageEnd,+ prePackageStart,+ postPackageStart,+ postPackageEnd,+ ]) {+ expect(marker).toBeGreaterThan(-1);+ }++ const resourcesBody = source.slice(resourcesStart, resourcesEnd);+ const buildBody = source.slice(buildStart, buildEnd);+ const stageBody = source.slice(stageStart, stageEnd);+ const prePackageBody = source.slice(prePackageStart, postPackageStart);+ const postPackageBody = source.slice(postPackageStart, postPackageEnd);++ expect(resourcesBody).toContain("base.push('resources/ios-simulator')");+ expect(resourcesBody).toContain("base.push('resources/cli')");+ expect(buildBody).toContain("CINDY_IOS_SIDECAR_OUTPUT_MODE: 'helper'");+ expect(buildBody).toContain('CINDY_IOS_SIDECAR_ARCH: helperArch');+ expect(buildBody).toContain('`${CINDY_APP_ID}.ios-simulator-helper`');+ expect(buildBody).toContain('process.env.APP_VERSION ?? DESKTOP_PACKAGE_VERSION');+ expect(stageBody).toContain("path.join(appContents, 'Helpers', IOS_SIMULATOR_HELPER_BUNDLE)");+ expect(stageBody).toContain("fs.rmSync(path.join(resourceRoot, 'helper')");+ expect(stageBody).toContain("fs.rmSync(path.join(resourceRoot, 'native')");+ expect(prePackageBody).toContain('buildMacIOSSimulatorHelper(platform, arch);');+ expect(postPackageBody).toContain('stageMacIOSSimulatorHelper(buildPath, opts.platform);');+ });+it('promotes only the fixed signed Helper layout to a verified descriptor', async () => {const fixture = await createFixture();const commandRunner = createCommandRunner(fixture);