Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

Merge remote-tracking branch 'origin/main' into redo/plugin-approval-receipt-migration

Yuewei-LLd9431ae477d2
diff --cc apps/desktop/src/main/__tests__/ownerNamespaceMigration.test.ts
index 856c70d6cd,77822c90b5..403e5ed90f
--- a/apps/desktop/src/main/__tests__/ownerNamespaceMigration.test.ts
+++ b/apps/desktop/src/main/__tests__/ownerNamespaceMigration.test.ts
@@@ -24,6 -21,6 +24,21 @@@ async function tempRoot(): Promise<stri
return root;
}
++async function canCreateFileSymlink(): Promise<boolean> {
++ const probeRoot = await fs.mkdtemp(path.join(os.tmpdir(), 'owner-namespace-symlink-probe-'));
++ try {
++ const target = path.join(probeRoot, 'target.txt');
++ const link = path.join(probeRoot, 'link.txt');
++ await fs.writeFile(target, 'probe');
++ await fs.symlink(target, link, process.platform === 'win32' ? 'file' : undefined);
++ return true;
++ } catch {
++ return false;
++ } finally {
++ await fs.rm(probeRoot, { recursive: true, force: true });
++ }
++}
++
/**
* Chromium uses a relative file symlink for SingletonLock on macOS/Linux.
* Windows local test hosts may not have file-symlink privileges, so use a
@@@ -459,93 -446,6 +474,94 @@@ describe('claimLegacyOwnerNamespace', (
expect(hasLegacyOwnerNamespaceClaim('cloud-a', root)).toBe(true);
expect(hasLegacyOwnerNamespaceClaim('cloud-b', root)).toBe(false);
});
+ it('keeps the claim marker valid if the completion rename fails', async () => {
+ const root = await tempRoot();
+ const ownerId = 'cloud-a';
+ const markerPath = path.join(root, __testing.CLAIM_MARKER);
+ await fs.writeFile(path.join(root, 'ghost-workdir-prefs.json'), 'legacy-prefs');
+ let failCompletionRename = true;
+
+ await expect(
+ claimLegacyOwnerNamespace(
+ { mode: 'cloud', dataOwnerId: ownerId, user: { id: ownerId } },
+ realFsDeps(root, {}, {
+ rename: async (source: string, target: string) => {
+ if (target === markerPath && failCompletionRename) {
+ failCompletionRename = false;
+ throw Object.assign(new Error('simulated completion failure'), { code: 'EIO' });
+ }
+ return fs.rename(source, target);
+ },
+ }),
+ ),
+ ).rejects.toThrow('simulated completion failure');
+ await expect(fs.readFile(markerPath, 'utf8').then(JSON.parse)).resolves.toMatchObject({
+ version: 1,
+ ownerKey: dataOwnerStorageKey(ownerId),
+ complete: false,
+ });
+ });
+
+ it('does not move a symlinked legacy credential into the owner namespace', async () => {
++ if (!(await canCreateFileSymlink())) return;
+ const root = await tempRoot();
+ const external = await tempRoot();
+ const source = path.join(root, 'model-access-credentials.json');
+ await fs.writeFile(path.join(external, 'credentials.json'), '{"secret":"external"}');
+ await fs.symlink(
+ path.join(external, 'credentials.json'),
+ source,
+ process.platform === 'win32' ? 'file' : undefined,
+ );
+
+ const result = await claimLegacyOwnerNamespace(
+ { mode: 'cloud', dataOwnerId: 'cloud-a', user: { id: 'cloud-a' } },
+ realFsDeps(root),
+ );
+ const target = path.join(
+ root,
+ 'owners',
+ dataOwnerStorageKey('cloud-a'),
+ 'model-access-credentials.json',
+ );
+
+ expect(result).toMatchObject({ status: 'migrated', moved: 0, conflicts: 1 });
+ expect((await fs.lstat(source)).isSymbolicLink()).toBe(true);
+ await expect(fs.access(target)).rejects.toThrow();
+ });
+
+ it('does not write legacy data through a linked owner target root', async () => {
+ const root = await tempRoot();
+ const external = await tempRoot();
+ const ownerKey = dataOwnerStorageKey('cloud-a');
+ await fs.writeFile(path.join(root, 'slack-hook.json'), 'legacy-hook');
+ await fs.mkdir(path.join(root, 'owners'), { recursive: true });
+ await fs.symlink(
+ external,
+ path.join(root, 'owners', ownerKey),
+ process.platform === 'win32' ? 'junction' : 'dir',
+ );
+
+ const result = await claimLegacyOwnerNamespace(
+ { mode: 'cloud', dataOwnerId: 'cloud-a', user: { id: 'cloud-a' } },
+ realFsDeps(root),
+ );
+
+ expect(result).toMatchObject({ status: 'partial', moved: 0, conflicts: 1 });
+ await expect(fs.readFile(path.join(root, 'slack-hook.json'), 'utf8')).resolves.toBe('legacy-hook');
+ await expect(fs.access(path.join(external, 'slack-hook.json'))).rejects.toThrow();
+ });
+});
+
+it('fails closed when owner projection roots cannot be enumerated', () => {
+ const readdir = vi.spyOn(fsSync, 'readdirSync').mockImplementationOnce(() => {
+ throw Object.assign(new Error('denied'), { code: 'EACCES' });
+ });
+ try {
+ expect(() => listLegacyOwnerProjectionRoots('C:\\cindy-user-data')).toThrow('denied');
+ } finally {
+ readdir.mockRestore();
+ }
});
describe('legacy Ghost plugin recovery', () => {
diff --cc apps/desktop/src/main/cindy-brain/__tests__/forge.test.ts
index 4fd7d958c2,3900a03c5a..77d24d9761
--- a/apps/desktop/src/main/cindy-brain/__tests__/forge.test.ts
+++ b/apps/desktop/src/main/cindy-brain/__tests__/forge.test.ts
@@@ -1121,15 -696,17 +1121,26 @@@ describe('scaffoldGhostDir', () =>
});
describe('FORGE_GUIDE', () => {
+ it('documents installed-directory isolation and the structured refusal', () => {
+ expect(FORGE_GUIDE).toContain('已安装插件目录');
+ expect(FORGE_GUIDE).toContain('SOURCE_IS_INSTALLED_PLUGIN');
+ // 脚手架侧的同一禁区也要写进手册,否则 agent 会先把骨架建进安装目录再撞墙。
+ expect(FORGE_GUIDE).toContain('也不能落在已安装插件目录或 Host 状态目录内');
+ expect(FORGE_GUIDE).toContain('复制/迁出');
+ expect(FORGE_GUIDE).toContain('junction');
+ });
+
+ it('向量检索示例按请求维度回放,不把回执 dim 当作请求判据', () => {
+ expect(FORGE_GUIDE).toContain('const requestedDim = undefined');
+ expect(FORGE_GUIDE).toContain('requestedDim 来自这次请求而不是回执');
+ expect(FORGE_GUIDE).toContain(
+ '...(storedRequestedDim !== undefined ? { dimensions: storedRequestedDim } : {}),',
+ );
+ expect(FORGE_GUIDE).not.toContain(
+ '...(storedDim !== undefined ? { dimensions: storedDim } : {}),',
+ );
+ });
+
it('分章体量守卫:每个 ## 章节须留在单次工具结果安全体量内(#890 分章投递的不变量)', () => {
// 手册"随主机版本演进"持续增长;任一章越过单次 MCP 结果上限会静默复现 #890 于该章。
// 上限取 32KB:当前最大章 ~22KB,余量 ~45%,越线即该拆小节。
diff --cc packages/maker-core/src/agents/pi/__tests__/pi-agent.integration.test.ts
index 663b38e9c5,663b38e9c5..53d3cbf0bb
--- a/packages/maker-core/src/agents/pi/__tests__/pi-agent.integration.test.ts
+++ b/packages/maker-core/src/agents/pi/__tests__/pi-agent.integration.test.ts
@@@ -355,6 -355,6 +355,7 @@@ describe.skipIf(!piAvailable)('PiAgent
contextWindow: 200_000,
efforts: [],
defaultEffort: null,
++ supportsImageInput: true,
},
],
},