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。

feat(bots): restore per-teammate linked projects

Chris3f7078ea3184
diff --git a/apps/desktop/scripts/fixtures/bot-projects/projects-fixture.tsx b/apps/desktop/scripts/fixtures/bot-projects/projects-fixture.tsx
new file mode 100644
index 0000000000..a0a1ed8155
--- /dev/null
+++ b/apps/desktop/scripts/fixtures/bot-projects/projects-fixture.tsx
@@ -0,0 +1,28 @@
+import { mountPage, subscription } from '../../ui-page/harness';
+import { BotProjectsSettings } from '../../../src/renderer/features/bots/BotProjectsSettings';
+import type { BotProjectOption } from '../../../src/shared/botWorkbench';
+
+mountPage({
+ host: ctx => {
+ let projects: BotProjectOption[] = [
+ { id: 'alpha', name: 'Cindy', path: '/Users/chris/Projects/cindy', linked: ctx.case !== 'empty', available: true },
+ { id: 'beta', name: 'Filo · 移动端与协作体验', path: '/Users/chris/Projects/filo', linked: false, available: true },
+ ...(ctx.case === 'legacy' ? [
+ { id: 'remote', name: 'Design archive', path: 'D:\\Projects\\Design archive', deviceId: 'other-device', linked: true, available: false },
+ { id: 'missing', name: '旧项目资料', path: '/Users/chris/Archived/project', linked: true, available: false },
+ ] : []),
+ ];
+ let fail = ctx.case === 'error';
+ return {
+ localDb: { bots: { projects: {
+ list: async () => { if (fail) { fail = false; throw new Error('offline'); } return projects; },
+ set: async (_botId: string, id: string, linked: boolean) => {
+ projects = projects.map(project => project.id === id ? { ...project, linked } : project);
+ return projects;
+ },
+ } } },
+ maker: { onBotWorkbenchChanged: subscription('projects') },
+ };
+ },
+ render: () => <div className="mx-auto max-w-xl p-5"><BotProjectsSettings botId="fixture" /></div>,
+});
diff --git a/apps/desktop/scripts/fixtures/bot-projects/ui-page.mjs b/apps/desktop/scripts/fixtures/bot-projects/ui-page.mjs
new file mode 100644
index 0000000000..ae87f95dda
--- /dev/null
+++ b/apps/desktop/scripts/fixtures/bot-projects/ui-page.mjs
@@ -0,0 +1,28 @@
+import assert from 'node:assert/strict';
+export default {
+ name: 'bot-projects', entry: './projects-fixture.tsx', viewport: { width: 460, height: 540 },
+ real: 'BotProjectsSettings, project list, selection, add/remove, error recovery and standard controls',
+ notCovered: 'Account persistence, actual file reads and remote-device transport; local persistence also tested in the full isolated Desktop.',
+ cases: {
+ default: { about: 'Add a second project and remove it without changing the first' },
+ empty: { about: 'Start with no links; selection and add are separate actions' },
+ legacy: { about: 'Preserve foreign computer and missing project associations' },
+ error: { about: 'Recover from an unavailable list without treating it as empty' },
+ },
+ async ready(page) { await page.getByRole('combobox').or(page.getByRole('alert')).first().waitFor(); },
+ async check(page, ui) {
+ if (ui.case === 'error') {
+ await page.getByRole('button', { name: await ui.t('bots.memory.useLatest'), exact: true }).click();
+ await page.getByRole('alert').waitFor({ state: 'detached' });
+ }
+ await page.getByRole('combobox').click();
+ await page.getByRole('option', { name: 'Filo · 移动端与协作体验', exact: true }).click();
+ await page.getByRole('button', { name: await ui.t('bots.projects.add'), exact: true }).click();
+ const remove = page.getByRole('button', { name: await ui.t('bots.projects.remove', { name: 'Filo · 移动端与协作体验' }), exact: true });
+ await remove.waitFor();
+ await ui.capture('added');
+ await remove.click();
+ await remove.waitFor({ state: 'detached' });
+ assert.equal(await page.getByRole('alert').count(), 0);
+ },
+};
diff --git a/apps/desktop/src/main/localDb/ipc/__tests__/botRemoteEditors.test.ts b/apps/desktop/src/main/localDb/ipc/__tests__/botRemoteEditors.test.ts
index 8cdf20206b..6face1e9b4 100644
--- a/apps/desktop/src/main/localDb/ipc/__tests__/botRemoteEditors.test.ts
+++ b/apps/desktop/src/main/localDb/ipc/__tests__/botRemoteEditors.test.ts
@@ -242,3 +242,31 @@ it('keeps follow-up off until chosen and rejects an invitation made stale by ano
const stale = await read(); f.owner('b');
await expect(f.send(stale, { enabled: true })).rejects.toThrow();
});
+
+// Restored project links use existing opaque settings actions. Minimal input: two projects and a stale save.
+// Covers list/detail/save, device paths withheld and owner-bound rejection; unit, no network.
+it('links multiple projects through settings while keeping paths private and rejecting stale or foreign saves', async () => {
+ const f = fixture();
+ const projects = [
+ { id: 'a'.repeat(64), name: 'First', path: '/PRIVATE/first', linked: true, available: true },
+ { id: 'b'.repeat(64), name: 'Second', path: '/PRIVATE/second', linked: false, available: true },
+ { id: 'c'.repeat(64), name: 'Remote', path: '/PRIVATE/remote', deviceId: 'other', linked: true, available: false },
+ ];
+ f.deps.projects = { list: vi.fn(async () => projects.map(project => ({ ...project }))), set: vi.fn(async (_bot, id, linked) => { projects.find(p => p.id === id)!.linked = linked; }) };
+ const list = await f.resource('settings:bot-a/projects');
+ expect(f.entries(list)).toHaveLength(3);
+ expect(JSON.stringify(list)).not.toContain('/PRIVATE');
+ const id = 'settings:bot-a/projects/' + projects[1].id;
+ const detail = await f.resource(id);
+ expect(JSON.stringify(detail)).not.toContain('/PRIVATE');
+ expect(f.deps.projects.set).not.toHaveBeenCalled();
+ await f.send(detail, { linked: true });
+ expect(projects.map(p => p.linked)).toEqual([true, true, true]);
+ await expect(f.send(detail, { linked: false })).rejects.toThrow();
+ const foreign = await f.resource(id); f.owner('other');
+ await expect(f.send(foreign, { linked: false })).rejects.toThrow();
+ expect(projects[1].linked).toBe(true);
+ f.owner('a');
+ await f.send(await f.resource(id), { linked: false });
+ expect(projects.map(p => p.linked)).toEqual([true, false, true]);
+});
diff --git a/apps/desktop/src/main/localDb/ipc/botRemoteEditors.ts b/apps/desktop/src/main/localDb/ipc/botRemoteEditors.ts
index e162b64230..e9eeb85f8b 100644
--- a/apps/desktop/src/main/localDb/ipc/botRemoteEditors.ts
+++ b/apps/desktop/src/main/localDb/ipc/botRemoteEditors.ts
@@ -8,10 +8,12 @@ import type { RemoteResourceHostContext } from '../../device-link/remoteResource
import type { BotSkillDetail } from '../../../shared/botSkill.js';
import { throwIpcError } from '../../utils/ipcValidate.js';
import { createBotRemoteMemoryEditor, memoryCopy, type BotRemoteMemoryService } from './botRemoteMemory.js';
+import type { BotProjectOption } from '../../../shared/botWorkbench.js';
type Kind = 'skill' | 'mcp' | 'toolset';
type Capability = { id: string; name: string; description: string; available: boolean; joined: boolean };
export interface BotRemoteEditorDeps extends Pick<BotRemoteSettingsDeps, 'owner' | 'assertOwner' | 'read' | 'update' | 'skills'> {
+ projects?: { list(botId: string): Promise<BotProjectOption[]>; set(botId: string, id: string, linked: boolean): Promise<unknown> };
followUp?: { get(): Promise<BotAutonomySettingsView>; set(botId: string | null): Promise<BotAutonomySettingsView> };
modelDefaults(): Promise<BotModelRoute[]>;
create(input: { id: string; name: string; avatarImageBase64: string; locale?: string; capabilities?: { modelChainOverride: BotModelRoute[] } }): Promise<void>;
@@ -29,6 +31,12 @@ export interface BotRemoteEditorOptions {
}
const text = (fallback: string, cn: string, tw: string, ja: string, ko: string): RemoteLocalizedText => ({ fallback, translations: { 'zh-CN': cn, 'zh-TW': tw, ja, ko } });
export const editorCopy = {
+ projects: text('Linked Projects', '关联项目', '關聯專案', '関連プロジェクト', '연결된 프로젝트'),
+ projectLinked: text('Link This Project', '关联此项目', '關聯此專案', 'このプロジェクトを関連付ける', '이 프로젝트 연결'),
+ projectHelp: text('Read materials when needed. Linking does not assign sessions or start background work.', '需要时读取资料。关联不会接手任务,也不会启动后台工作。', '需要時讀取資料。關聯不會接手任務,也不會啟動背景工作。', '必要なときに資料を読みます。関連付けてもセッションの担当やバックグラウンド作業は開始しません。', '필요할 때 자료를 읽습니다. 연결해도 세션을 맡거나 백그라운드 작업을 시작하지 않습니다.'),
+ projectRemote: text('On another computer', '位于另一台电脑', '位於另一台電腦', '別のコンピューターにあります', '다른 컴퓨터에 있음'),
+ projectUnavailable: text('Directory unavailable', '目录暂不可用', '目錄暫不可用', 'ディレクトリを利用できません', '디렉터리를 사용할 수 없습니다'),
+ projectEmpty: text('Add projects to the project list on the teammate’s computer first.', '请先在伙伴所在电脑的项目列表中添加项目。', '請先在夥伴所在電腦的專案列表中新增專案。', '先にチームメイトのコンピューターのプロジェクト一覧に追加してください。', '먼저 팀원이 실행되는 컴퓨터의 프로젝트 목록에 프로젝트를 추가하세요.'),
followUp: text("Follow Up on My Sessions", "跟进我的任务", "跟進我的任務", "自分のセッションをフォロー", "내 세션 후속 확인"),
followUpConsent: text("Once enabled, I’ll read summaries of sessions you create on the teammate’s computer, assess progress, and let you know about important changes. This uses your model allowance. You can turn it off anytime.", "开启后,我会读取伙伴所在电脑上你创建的任务摘要,分析进展并提醒你重要变化。这会使用模型额度,你可以随时关闭。", "開啟後,我會讀取夥伴所在電腦上你建立的任務摘要,分析進度並提醒你重要變化。這會使用模型額度,你可以隨時關閉。", "有効にすると、チームメイトが動作するコンピューターであなたが作成したセッションの要約を読み、進捗を確認して重要な変化をお知らせします。モデルの利用枠を消費します。いつでも無効にできます。", "켜면 팀원이 실행되는 컴퓨터에서 직접 만든 세션의 요약을 읽고 진행 상황을 분석하여 중요한 변화를 알려드립니다. 모델 사용량이 소모되며 언제든 끌 수 있습니다."),
followUpStart: text("Start Following Up", "开始跟进", "開始跟進", "フォローを開始", "후속 확인 시작"),
@@ -70,6 +78,34 @@ export function createBotRemoteEditors(deps: BotRemoteEditorDeps, bind: ReturnTy
const memoryEditor = createBotRemoteMemoryEditor(deps, bind);
return async (context: RemoteResourceHostContext, id: string, locale?: string, options: BotRemoteEditorOptions = {}): Promise<RemoteResource> => {
const owner = deps.owner(); deps.assertOwner(owner);
+ const projectMatch = /^settings:([A-Za-z0-9_-]{1,128})\/projects(?:\/([a-f0-9]{64}))?$/.exec(id);
+ if (projectMatch && deps.projects) {
+ const [, botId, projectId] = projectMatch;
+ const settings = await deps.read(botId); deps.assertOwner(owner);
+ const projects = await deps.projects.list(botId); deps.assertOwner(owner);
+ const resource: RemoteResource = { ref: ref(id), revision: hash(projects), display: { title: editorCopy.projects }, links: [], blocks: [] };
+ if (!projectId) {
+ resource.blocks = [{ id: 'projects', primitive: 'list', fallbackMarkdown: projects.length ? resolveRemoteText(editorCopy.projectHelp, locale) : resolveRemoteText(editorCopy.projectEmpty, locale),
+ data: { entries: projects.map(project => ({ id: project.id, title: `${project.linked ? '✓ ' : ''}${project.name}${project.deviceId ? ` · ${resolveRemoteText(editorCopy.projectRemote, locale)}` : ''}`, resourceId: `${id}/${project.id}` })) } }];
+ return resource;
+ }
+ const project = projects.find(project => project.id === projectId);
+ if (!project) throwIpcError('NOT_FOUND', 'Project unavailable');
+ resource.display.title = project.name;
+ const panel = form('project', editorCopy.projects, [{ id: 'linked', label: editorCopy.projectLinked, kind: 'toggle' }], { linked: project.linked });
+ resource.blocks = [{ ...panel.block, fallbackMarkdown: [resolveRemoteText(editorCopy.projectHelp, locale), project.deviceId ? resolveRemoteText(editorCopy.projectRemote, locale) : !project.available ? resolveRemoteText(editorCopy.projectUnavailable, locale) : ''].filter(Boolean).join('\n\n') }];
+ resource.actions = [{ ...panel.action, disabled: settings.source.status !== 'active' }];
+ return bind(context, resource, async () => {
+ await deps.read(botId); deps.assertOwner(owner);
+ const next = await deps.projects!.list(botId); deps.assertOwner(owner);
+ return hash(next);
+ }, async request => {
+ const input = request.input ?? {}; keys(input, ['linked']);
+ if (typeof input.linked !== 'boolean') fail();
+ await deps.projects!.set(botId, projectId, input.linked as boolean); deps.assertOwner(owner);
+ return receipt(id);
+ });
+ }
if (id === 'create') {
const modelChain = await deps.modelDefaults(); deps.assertOwner(owner);
const panel = form('create', editorCopy.create, [
diff --git a/apps/desktop/src/main/localDb/ipc/botRemoteManagement.ts b/apps/desktop/src/main/localDb/ipc/botRemoteManagement.ts
index 8bbdf058d9..394ddbb207 100644
--- a/apps/desktop/src/main/localDb/ipc/botRemoteManagement.ts
+++ b/apps/desktop/src/main/localDb/ipc/botRemoteManagement.ts
@@ -14,6 +14,7 @@ import { createBotRemoteEditors } from './botRemoteEditors.js';
import { decodeBotAvatarImage } from './botAvatarSelection.js';
import { runRegisteredBotLifecycleAction } from '../../maker-ipc/botLifecycleService.js';
import { listBotSettingsCapabilities, validateBotCapabilityAdditions } from '../../maker-host/index.js';
+import { botLinkedProjectAccess } from '../../maker-ipc/botLinkedProjects.js';
async function validateModelChain(chain: BotModelRoute[]) {
const scope = activeOwnerScopeKey();
@@ -44,6 +45,10 @@ const settings = createBotRemoteSettingsResource({ ...deps,
lifecycle: (botId, action, confirmName, guard) => runRegisteredBotLifecycleAction({ botId, action, confirmName, keepTaskHistory: true, worktreeDisposition: 'retain' }, guard),
});
const getEditor = createBotRemoteEditors({ ...deps,
+ projects: {
+ list: async botId => (await botLinkedProjectAccess(botId)).read(),
+ set: async (botId, id, linked) => (await botLinkedProjectAccess(botId)).set(id, linked),
+ },
followUp: { get: getBotAutonomySettingsView, set: setBotAutonomySchedulerBotId },
async modelDefaults() {
const owner = deps.owner();
diff --git a/apps/desktop/src/main/localDb/ipc/botRemoteResourceProvider.ts b/apps/desktop/src/main/localDb/ipc/botRemoteResourceProvider.ts
index 98c777d710..f1dc0751e7 100644
--- a/apps/desktop/src/main/localDb/ipc/botRemoteResourceProvider.ts
+++ b/apps/desktop/src/main/localDb/ipc/botRemoteResourceProvider.ts
@@ -134,7 +134,7 @@ export function registerBotRemoteResourceProvider(management?: typeof botRemoteM
}
const resource = management && request.client.primitives.includes('form') ? await management.get(context, source.id) : management && source.invitation ? await management.getInvitation(context, source.id) : botRemoteResourceFromSource(source);
if (management && request.client.primitives.includes('form')) {
- for (const page of ['avatar', 'skills', 'connections', 'followUp'] as const) {
+ for (const page of ['avatar', 'skills', 'connections', 'projects', 'followUp'] as const) {
const block = resource.blocks?.find(block => block.id === page);
const data = { entries: [{ id: page, title: editorCopy[page], resourceId: `settings:${source.id}/${page === 'followUp' ? 'follow-up' : page}` }] };
if (block) block.data = data;
diff --git a/apps/desktop/src/main/localDb/ipc/bots.ts b/apps/desktop/src/main/localDb/ipc/bots.ts
index 3874456b94..eca4338336 100644
--- a/apps/desktop/src/main/localDb/ipc/bots.ts
+++ b/apps/desktop/src/main/localDb/ipc/bots.ts
@@ -2563,6 +2563,18 @@ export function registerBotIpc(): void {
const workbench: BotWorkbench = { responsibleSessionIds };
return workbench;
});
+ for (const operation of ['list', 'set'] as const) {
+ ipcMain.handle(`local-db:bots:projects:${operation}`, async (event, rawBotId: unknown, rawId?: unknown, rawLinked?: unknown) => {
+ assertTrustedAppRendererEvent(event);
+ const botId = readText(rawBotId, 'botId', 128, true);
+ const { botLinkedProjectAccess } = await import('../../maker-ipc/botLinkedProjects.js');
+ const access = await botLinkedProjectAccess(botId);
+ if (operation === 'list') return access.read();
+ const id = readText(rawId, 'projectId', 64, true);
+ if (typeof rawLinked !== 'boolean') throwIpcError('INVALID_PARAMS', 'linked must be a boolean');
+ return access.set(id, rawLinked);
+ });
+ }
for (const operation of ['list', 'update', 'act'] as const) {
ipcMain.handle(`local-db:bots:todos:${operation}`, async (event, rawBotId: unknown, input: unknown) => {
assertTrustedAppRendererEvent(event);
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/botWorkbenchService.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/botWorkbenchService.test.ts
index ca3d1be622..fc9b30a50e 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/botWorkbenchService.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/botWorkbenchService.test.ts
@@ -20,6 +20,8 @@ import { botProfileDir } from '../botProfileFolder.js';
import { LEGACY_MAX_DIRECTORIES, boundLegacyJudgments } from '../botWorkbenchLegacy.js';
import {
mergeCompanionWorkbench,
+ readBotLinkedProjects,
+ setBotLinkedProject,
normalizeWorkbench,
readCompanionWorkbench,
readLegacyWorkbenchJudgments,
@@ -163,3 +165,35 @@ describe('legacy workbench moving with the companion', () => {
expect((await readCompanionWorkbench(root, 'bot-1', 'desk')).directories).toHaveLength(1);
});
});
+
+// Linked-project restoration: existing tests only cover legacy judgment/cloud transport.
+// Production storage must keep multiple associations, other computers and judgments; no task ownership is written.
+// Minimal regression: add/remove a second directory beside a legacy directory. Tier: unit, isolated temporary files.
+describe('linked projects', () => {
+ it('retains legacy links and judgments while independently adding and removing multiple projects', async () => {
+ root = await mkdtemp(path.join(os.tmpdir(), 'bot-projects-'));
+ const first = path.join(root, 'first'); const second = path.join(root, 'second');
+ const legacy = { directories: [{ path: first, addedAt: 'old' }, { path: first, addedAt: 'remote', deviceId: 'other' }], tasks: { 'idea:icons': judgment('idea', '2026-10-01T00:00:00.000Z') } };
+ const file = await writeLegacy(root, legacy);
+ await setBotLinkedProject(root, 'bot-1', { path: second }, true, () => {});
+ await setBotLinkedProject(root, 'bot-1', { path: second }, true, () => {});
+ expect(await readBotLinkedProjects(root, 'bot-1')).toHaveLength(3);
+ expect(await readBotLinkedProjects(root, 'bot-2')).toEqual([]);
+ await setBotLinkedProject(root, 'bot-1', { path: first }, false, () => {});
+ expect((await readBotLinkedProjects(root, 'bot-1')).map(p => [p.path, p.deviceId])).toEqual([[first, 'other'], [second, undefined]]);
+ const saved = JSON.parse(await readFile(file, 'utf8'));
+ expect(saved.tasks).toEqual(legacy.tasks);
+ expect(saved.responsibleSessionIds).toBeUndefined();
+ expect((await readCompanionWorkbench(root, 'bot-1', 'self')).directories.map(p => p.deviceId)).toEqual(['other', 'self']);
+ });
+ it('refuses damaged data and revoked writes without losing the existing associations', async () => {
+ root = await mkdtemp(path.join(os.tmpdir(), 'bot-projects-'));
+ const file = await writeLegacy(root, '{broken');
+ await expect(setBotLinkedProject(root, 'bot-1', { path: root }, true, () => {})).rejects.toThrow();
+ expect(await readFile(file, 'utf8')).toBe('{broken');
+ await writeLegacy(root, { directories: [{ path: root, addedAt: 'old' }], tasks: {} });
+ let checks = 0;
+ await expect(setBotLinkedProject(root, 'bot-1', { path: root }, false, () => { if (++checks === 4) throw Error('REVOKED'); })).rejects.toThrow('REVOKED');
+ expect(await readBotLinkedProjects(root, 'bot-1')).toEqual([{ path: root, addedAt: 'old' }]);
+ });
+});
diff --git a/apps/desktop/src/main/maker-ipc/botLinkedProjects.ts b/apps/desktop/src/main/maker-ipc/botLinkedProjects.ts
new file mode 100644
index 0000000000..7d100d8b5f
--- /dev/null
+++ b/apps/desktop/src/main/maker-ipc/botLinkedProjects.ts
@@ -0,0 +1,70 @@
+import { createHash } from 'node:crypto';
+import { stat } from 'node:fs/promises';
+import path from 'node:path';
+import { activeOwnerScopeKey, isAppSessionBoundaryPending, ownerScopedUserDataPath } from '../appSessionState.js';
+import { getBotRemoteSettingsSource } from '../localDb/ipc/bots.js';
+import { listRecentWorkdirs } from '../localDb/ipc/recentWorkdirs.js';
+import { listProjectAliases } from '../localDb/ipc/projectAliases.js';
+import { loadSidebarSettingsSnapshot } from '../sidebarSettingsStore.js';
+import { projectKeyComparisonKey } from '../../shared/projectKeys.js';
+import type { BotLinkedProject, BotProjectOption } from '../../shared/botWorkbench.js';
+import { throwIpcError } from '../utils/ipcValidate.js';
+import { readBotLinkedProjects, setBotLinkedProject } from './botWorkbenchService.js';
+import { broadcastBotRemoteResourceChanged } from './botRemoteResourceInvalidation.js';
+
+const identity = (directory: string) => projectKeyComparisonKey(`local:${directory}`, process.platform);
+const projectId = (project: Pick<BotLinkedProject, 'path' | 'deviceId'>) => createHash('sha256')
+ .update(JSON.stringify([project.deviceId ?? null, project.deviceId ? project.path : identity(project.path)])).digest('hex');
+
+/** One account-bound service for local settings, remote settings and the teammate tools. */
+export async function botLinkedProjectAccess(botId: string) {
+ const owner = activeOwnerScopeKey();
+ const root = ownerScopedUserDataPath();
+ const assertCurrent = () => {
+ if (isAppSessionBoundaryPending() || activeOwnerScopeKey() !== owner)
+ throwIpcError('PRECONDITION_FAILED', 'Account changed');
+ };
+ assertCurrent();
+ const settings = await getBotRemoteSettingsSource(botId);
+ assertCurrent();
+ const read = async (): Promise<BotProjectOption[]> => {
+ assertCurrent();
+ const [linked, registered, aliases] = await Promise.all([
+ readBotLinkedProjects(root, botId), listRecentWorkdirs(), listProjectAliases(),
+ ]);
+ assertCurrent();
+ const hidden = new Set(loadSidebarSettingsSnapshot().hiddenProjectKeys.map(key => projectKeyComparisonKey(key, process.platform)));
+ const names = new Map(aliases.map(row => [projectKeyComparisonKey(row.projectKey, process.platform), row.alias]));
+ const options = new Map<string, BotProjectOption>();
+ for (const project of linked) {
+ const local = !project.deviceId;
+ const known = local ? registered.find(row => identity(row.path) === identity(project.path)) : undefined;
+ const basename = project.deviceId && path.win32.isAbsolute(project.path) ? path.win32.basename(project.path) : path.basename(project.path);
+ const id = projectId(project);
+ const available = local && (known?.exists ?? await stat(project.path).then(value => value.isDirectory(), () => false));
+ assertCurrent();
+ options.set(id, { id, path: project.path, name: local ? names.get(identity(project.path)) || basename : basename,
+ ...(project.deviceId ? { deviceId: project.deviceId } : {}), linked: true, available });
+ }
+ for (const project of registered) {
+ if (!project.exists || hidden.has(identity(project.path))) continue;
+ const id = projectId(project);
+ if (!options.has(id)) options.set(id, { id, path: project.path,
+ name: names.get(identity(project.path)) || path.basename(project.path), linked: false, available: true });
+ }
+ return [...options.values()];
+ };
+ return {
+ read,
+ async set(id: string, linked: boolean, actionGuard: () => void = () => {}) {
+ if (settings.source.status !== 'active') throwIpcError('PRECONDITION_FAILED', 'Teammate is not active');
+ const project = (await read()).find(item => item.id === id);
+ if (!project || linked && !project.linked && !project.available) throwIpcError('NOT_FOUND', 'Project unavailable');
+ const guard = () => { assertCurrent(); actionGuard(); };
+ guard();
+ await setBotLinkedProject(root, botId, { path: project.path, ...(project.deviceId ? { deviceId: project.deviceId } : {}) }, linked, guard);
+ broadcastBotRemoteResourceChanged(botId);
+ return read();
+ },
+ };
+}
diff --git a/apps/desktop/src/main/maker-ipc/botWorkbenchLegacy.ts b/apps/desktop/src/main/maker-ipc/botWorkbenchLegacy.ts
index 44dbcb6fb4..2e3ef5dbf2 100644
--- a/apps/desktop/src/main/maker-ipc/botWorkbenchLegacy.ts
+++ b/apps/desktop/src/main/maker-ipc/botWorkbenchLegacy.ts
@@ -1,8 +1,8 @@
/**
* 旧版工作台(2026-10-17 之前「项目 + 判断」形态)留在伙伴 Home `workbench.json` 里的数据。
*
- * 新版工作台不再读写这些字段(放弃「项目」思路,见 `shared/botWorkbench.ts`),文件原样保留,
- * 不迁移、不改写。只有两处仍然只读地用到它们:
+ * 新版工作台不再按项目认领任务。directories 由伙伴关联项目设置读写,旧判断保留,
+ * 并继续用于以下兼容路径:
* - 伙伴 Todo 把旧 PR / issue / 建议判断按稳定 id 兼容导入(`botTodoStore.ts`);
* - 云端伙伴搬家时把旧文件原样随身带走(`botWorkbenchService.ts` 的 companion 读写),
* 不让新版本把另一台还在旧版本上的电脑的数据清空。
diff --git a/apps/desktop/src/main/maker-ipc/botWorkbenchService.ts b/apps/desktop/src/main/maker-ipc/botWorkbenchService.ts
index 38a7f19696..7dcfec9772 100644
--- a/apps/desktop/src/main/maker-ipc/botWorkbenchService.ts
+++ b/apps/desktop/src/main/maker-ipc/botWorkbenchService.ts
@@ -1,15 +1,12 @@
/**
- * 伙伴工作台在伙伴 Home 里的旧文件 `<ownerRoot>/bots/<botId>/workbench.json`。
- *
- * 2026-10-17 起放弃「项目」思路:工作台不再记项目目录,也不再写候选任务的判断;伙伴负责的任务
- * 来自 `task-responsibility.v1.json` 与它发起的后台任务(`botWorkbenchTools.ts`),「一眼」投影由
- * 宿主观察层给出。旧文件原样保留、不迁移、不改写,只剩两种只读 / 透传用途:
- * - 旧 PR / issue / 建议判断仍是伙伴 Todo 的兼容来源(`readLegacyWorkbenchJudgments`);
- * - 云端伙伴搬家时整份旧数据随身走(`readCompanionWorkbench` / `mergeCompanionWorkbench`),
- * 另一台还在旧版本上的电脑不会因为本机升级而丢掉它的目录与判断。
+ * The original workbench file keeps linked project references and legacy Todo judgments.
+ * Projects are context only; task responsibility lives in task-responsibility.v1.json.
+ * Cloud handoff retains directory device identity and never opens another computer's paths.
*/
import { promises as fs } from 'node:fs';
import path from 'node:path';
+import type { BotLinkedProject } from '../../shared/botWorkbench.js';
+import { projectKeyComparisonKey } from '../../shared/projectKeys.js';
import { BrowserWindow } from 'electron';
@@ -26,12 +23,7 @@ import { createLogger } from '../logger.js';
const log = createLogger('bot-workbench');
const WORKBENCH_FILE = 'workbench.json';
-interface StoredDirectory {
- path: string;
- addedAt: string;
- /** The computer the folder is on when it is not this one (cloud-companions.md §2). */
- deviceId?: string;
-}
+type StoredDirectory = BotLinkedProject;
interface StoredWorkbench {
directories: StoredDirectory[];
@@ -95,16 +87,22 @@ async function readStored(userDataDir: string, botId: string): Promise<StoredWor
}
}
-async function writeStored(userDataDir: string, botId: string, stored: StoredWorkbench): Promise<void> {
+async function writeStored(userDataDir: string, botId: string, stored: StoredWorkbench, guard?: () => void): Promise<void> {
const target = workbenchPath(userDataDir, botId);
await fs.mkdir(path.dirname(target), { recursive: true });
const temp = `${target}.${process.pid}.${Date.now()}.tmp`;
- await fs.writeFile(
- temp,
- `${JSON.stringify({ directories: stored.directories, tasks: stored.tasks }, null, 2)}\n`,
- 'utf8',
- );
- await fs.rename(temp, target);
+ try {
+ guard?.();
+ await fs.writeFile(
+ temp,
+ `${JSON.stringify({ directories: stored.directories, tasks: stored.tasks }, null, 2)}\n`,
+ 'utf8',
+ );
+ guard?.();
+ await fs.rename(temp, target);
+ } finally {
+ await fs.rm(temp, { force: true });
+ }
}
/** 同一伙伴的读改写串行,并发的搬家合并互不覆盖。 */
@@ -113,13 +111,17 @@ function mutate<T>(
userDataDir: string,
botId: string,
change: (stored: StoredWorkbench) => { next: StoredWorkbench; result: T },
+ guard?: () => void,
): Promise<T> {
const key = `${userDataDir}\0${botId}`;
const run = (writeChains.get(key) ?? Promise.resolve())
.catch(() => undefined)
.then(async () => {
- const { next, result } = change(await readStored(userDataDir, botId));
- await writeStored(userDataDir, botId, next);
+ guard?.();
+ const stored = await readStoredStrict(userDataDir, botId);
+ guard?.();
+ const { next, result } = change(stored);
+ await writeStored(userDataDir, botId, next, guard);
return result;
});
writeChains.set(key, run);
@@ -131,8 +133,32 @@ function mutate<T>(
return run;
}
-// 工作台的持久形状只剩逐任务责任(由 `readBotResponsibleSessionIds` 现算,不在本文件里)。
-// 旧 workbench.json 的 `directories` / `tasks` 字段只经 `readLegacyWorkbenchJudgments` 读,其余一律忽略。
+/** Existing associations remain in the original file and travel with the companion. */
+export async function readBotLinkedProjects(userDataDir: string, botId: string): Promise<BotLinkedProject[]> {
+ return (await readStoredStrict(userDataDir, botId)).directories;
+}
+
+export async function setBotLinkedProject(
+ userDataDir: string, botId: string, project: Pick<BotLinkedProject, 'path' | 'deviceId'>,
+ linked: boolean, guard: () => void,
+): Promise<void> {
+ if (!normalizeDirectories([project]).length) throw new Error('INVALID_PROJECT');
+ await mutate(userDataDir, botId, stored => {
+ const same = (entry: BotLinkedProject) => entry.deviceId === project.deviceId && (project.deviceId
+ ? entry.path === project.path
+ : projectKeyComparisonKey(`local:${entry.path}`, process.platform) === projectKeyComparisonKey(`local:${project.path}`, process.platform));
+ const exists = stored.directories.some(same);
+ if (linked && !exists && stored.directories.length >= LEGACY_MAX_DIRECTORIES) throw new Error('PROJECT_LIMIT');
+ const directories = linked
+ ? exists ? stored.directories : [...stored.directories, { ...project, addedAt: new Date().toISOString() }]
+ : stored.directories.filter(entry => !same(entry));
+ return { next: { ...stored, directories }, result: undefined };
+ }, guard);
+ guard();
+ broadcastBotWorkbenchChanged(botId);
+}
+
+// Project links and legacy judgments do not grant responsibility for any task.
/** 旧判断:伙伴 Todo 的兼容导入来源。只读,不做文件系统探测。 */
export async function readLegacyWorkbenchJudgments(
@@ -147,7 +173,7 @@ const PORTABLE_JUDGMENT = /^(pr|issue|idea):/;
/**
* The legacy workbench as it travels with the companion (cloud-companions.md §2): every folder
- * with the computer it is on, and the portable judgments. Carried unchanged for older computers.
+ * with the computer it is on, and the portable judgments. The same references are used by linked-project settings.
*/
export async function readCompanionWorkbench(userDataDir: string, botId: string, selfDeviceId: string): Promise<{
directories: Array<{ path: string; addedAt: string; deviceId: string }>;
@@ -164,7 +190,7 @@ export async function readCompanionWorkbench(userDataDir: string, botId: string,
/**
* The companion moved here: the legacy folders and portable judgments from the cloud join what is
* here; the cloud wins. With `replace` (this computer synced them before) they take the place of
- * what is here; judgments that never travel stay. Nothing here reads the folders any more.
+ * what is here; judgments that never travel stay. Project content is read on demand, never during handoff.
*/
export async function mergeCompanionWorkbench(userDataDir: string, botId: string, selfDeviceId: string, cloud: unknown,
options: { replace?: boolean } = {}): Promise<void> {
diff --git a/apps/desktop/src/main/maker-ipc/botWorkbenchTools.ts b/apps/desktop/src/main/maker-ipc/botWorkbenchTools.ts
index 4d65a59c84..4484a37de2 100644
--- a/apps/desktop/src/main/maker-ipc/botWorkbenchTools.ts
+++ b/apps/desktop/src/main/maker-ipc/botWorkbenchTools.ts
@@ -6,10 +6,10 @@
* - 逐任务责任读伙伴家的 task-responsibility 与它自己开的后台任务(bot_delegations);
* - 继续复用宿主已有的发消息路径(本机 = send_to_session 同一条链路;另一台电脑 =
* 跨电脑 send_to_session 的同一条通路),由调用方注入;停止走通用的 stop_session_turn。
- * 2026-10-17 放弃「项目」:不再按目录发现候选、不再现算项目素材、不再导入本机外部会话。
+ * 项目关联只提供按需阅读的入口,不按目录发现候选任务或导入本机外部会话。
*/
import { and, desc, eq, isNotNull } from 'drizzle-orm';
-import { hasTaskActionAuthorization, assertTaskActionCurrent } from './taskActionAuthorization.js';
+import { hasTaskActionAuthorization, assertTaskActionCurrent, captureTaskActionSyncGuard } from './taskActionAuthorization.js';
import { getDbClient } from '../localDb/client/current.js';
import { botDelegations, botProfiles, botSessionLinks, sessions } from '../localDb/schema.js';
@@ -61,6 +61,36 @@ export async function resolveWorkbenchCaller(callerSessionId: string): Promise<W
return { ok: true, botId: row.botId };
}
+/** Query context only. The workbench authorization and task responsibility remain untouched. */
+export async function runBotProjectsTool(params: {
+ callerSessionId: string; projectId?: string; linked?: boolean; includeAvailable?: boolean;
+}) {
+ const owner = activeOwnerScopeKey();
+ try {
+ if (isAppSessionBoundaryPending()) throw new Error('OWNER_SCOPE_CHANGED');
+ const caller = await resolveWorkbenchCaller(params.callerSessionId);
+ if (!caller.ok) return caller;
+ const { botLinkedProjectAccess } = await import('./botLinkedProjects.js');
+ if (owner !== activeOwnerScopeKey() || isAppSessionBoundaryPending()) throw new Error('OWNER_SCOPE_CHANGED');
+ const access = await botLinkedProjectAccess(caller.botId);
+ let projects;
+ if (params.projectId !== undefined) {
+ if (typeof params.linked !== 'boolean' || !hasTaskActionAuthorization(params.callerSessionId))
+ return { ok: false as const, errorCode: 'TASK_ACTION_AUTHORIZATION_REQUIRED', message: 'Changing project links requires authorization.' };
+ await assertTaskActionCurrent();
+ projects = await access.set(params.projectId, params.linked, captureTaskActionSyncGuard());
+ } else projects = await access.read();
+ return { ok: true as const, projects: projects.filter(project => project.linked || params.includeAvailable).map(project => ({
+ project_id: project.id, name: project.name, working_dir: project.path,
+ device_id: project.deviceId ?? null, linked: project.linked, available_locally: project.available,
+ // These are locations to check on demand, not promises that the files exist.
+ ...(!project.deviceId && project.available ? { context_locations: ['AGENTS.md', 'CLAUDE.md', 'README.md', '.cindy/project-knowledge/TOC.md'] } : {}),
+ })) };
+ } catch {
+ return { ok: false as const, errorCode: 'PROJECTS_UNAVAILABLE', message: 'Could not read or save project links. Re-read the saved state before retrying.' };
+ }
+}
+
async function readWorkbenchTarget(taskId: string): Promise<WorkbenchTargetFacts | null> {
const db = getDbClient().drizzle;
const [row] = await db
diff --git a/apps/desktop/src/main/maker-ipc/taskActionAuthorization.ts b/apps/desktop/src/main/maker-ipc/taskActionAuthorization.ts
index 0dd767a170..bddef6c7dd 100644
--- a/apps/desktop/src/main/maker-ipc/taskActionAuthorization.ts
+++ b/apps/desktop/src/main/maker-ipc/taskActionAuthorization.ts
@@ -11,6 +11,7 @@ export const TASK_ACTION_TOOLS: ReadonlySet<string> = new Set([
'send_to_agent',
'continue_workbench_task',
'set_workbench_task_responsibility',
+ 'set_teammate_project',
'send_to_session',
'steer_session',
'stop_session_turn',
diff --git a/apps/desktop/src/main/mcp-integrations/mcp-providers.ts b/apps/desktop/src/main/mcp-integrations/mcp-providers.ts
index edcfd2cf40..68b9db3148 100644
--- a/apps/desktop/src/main/mcp-integrations/mcp-providers.ts
+++ b/apps/desktop/src/main/mcp-integrations/mcp-providers.ts
@@ -86,6 +86,7 @@ import {
import {
captureBotCreatedTaskResponsibility,
runBotWorkbenchTool,
+ runBotProjectsTool,
type BotWorkbenchHostDeps,
} from '../maker-ipc/botWorkbenchTools.js';
import { createTaskDigestReader } from './taskDigest.js';
@@ -1114,6 +1115,7 @@ export function createDesktopMcpProviders(deps: DesktopMcpProvidersDeps): LiziMc
// 授权在 botWorkbenchAccess 里逐次确定性校验;投递复用 send_to_session 的同一条宿主路径。
// 停止走通用的 stop_session_turn。
botWorkbench: {
+ projects: runBotProjectsTool,
todos: async (caller, operation, input) => {
try {
const access = await todoForCaller(caller, () => getTaskActionInputState(caller).ownerInput);
diff --git a/apps/desktop/src/preload/preload.ts b/apps/desktop/src/preload/preload.ts
index 228ad4784e..33ecd72e7f 100644
--- a/apps/desktop/src/preload/preload.ts
+++ b/apps/desktop/src/preload/preload.ts
@@ -5758,6 +5758,12 @@ contextBridge.exposeInMainWorld('electronAPI', {
update: (botId: string, patch: import('@cindy/maker-shared/teammate-todo').TodoPatch) => ipcRenderer.invoke('local-db:bots:todos:update', botId, patch),
act: (botId: string, input: {id:string;revision:number;requestId:string;locale?:string}) => ipcRenderer.invoke('local-db:bots:todos:act', botId, input),
},
+ projects: {
+ list: (botId: string): Promise<import('../shared/botWorkbench').BotProjectOption[]> =>
+ ipcRenderer.invoke('local-db:bots:projects:list', botId),
+ set: (botId: string, projectId: string, linked: boolean): Promise<import('../shared/botWorkbench').BotProjectOption[]> =>
+ ipcRenderer.invoke('local-db:bots:projects:set', botId, projectId, linked),
+ },
workbench: {
get: (botId: string): Promise<unknown> =>
ipcRenderer.invoke('local-db:bots:workbench:get', botId),
diff --git a/apps/desktop/src/renderer/features/bots/BotProjectsSettings.tsx b/apps/desktop/src/renderer/features/bots/BotProjectsSettings.tsx
new file mode 100644
index 0000000000..d1e5d7f1f6
--- /dev/null
+++ b/apps/desktop/src/renderer/features/bots/BotProjectsSettings.tsx
@@ -0,0 +1,75 @@
+import { useCallback, useEffect, useRef, useState } from 'react';
+import { FolderOpen, Plus, X } from 'lucide-react';
+import { Button } from '@/components/ui/button';
+import { Select } from '@/components/ui/select';
+import { Spinner } from '@/components/ui/spinner';
+import { useBotTranslation } from './botPronounContext';
+import type { BotProjectOption } from '../../../shared/botWorkbench';
+
+export function BotProjectsSettings({ botId }: { botId: string }) {
+ const { t } = useBotTranslation();
+ const [projects, setProjects] = useState<BotProjectOption[] | null>(null);
+ const [selected, setSelected] = useState('');
+ const [busy, setBusy] = useState(false);
+ const [error, setError] = useState(false);
+ const generation = useRef(0);
+ const inFlight = useRef(false);
+ const load = useCallback(async () => {
+ const token = ++generation.current;
+ try {
+ const next = await window.electronAPI.localDb.bots.projects.list(botId);
+ if (token === generation.current) { setProjects(next); setError(false); }
+ } catch { if (token === generation.current) setError(true); }
+ }, [botId]);
+ useEffect(() => {
+ void load();
+ const unsubscribe = window.electronAPI.maker.onBotWorkbenchChanged(({ botId: changed }) => {
+ if (changed === botId && !inFlight.current) void load();
+ });
+ return () => { generation.current++; unsubscribe(); };
+ }, [botId, load]);
+ const set = async (id: string, linked: boolean) => {
+ if (inFlight.current) return;
+ inFlight.current = true;
+ setBusy(true); setError(false);
+ const token = ++generation.current;
+ try {
+ const next = await window.electronAPI.localDb.bots.projects.set(botId, id, linked);
+ if (token === generation.current) { setProjects(next); setSelected(''); }
+ } catch { if (token === generation.current) setError(true); }
+ finally { inFlight.current = false; if (token === generation.current) setBusy(false); }
+ };
+ const linked = projects?.filter(project => project.linked) ?? [];
+ const available = projects?.filter(project => !project.linked && project.available) ?? [];
+ return <div className="space-y-4 py-3">
+ <p className="text-13 leading-6 text-[var(--text-secondary)]">{t('bots.projects.description')}</p>
+ {error && <div role="alert" className="flex items-center justify-between gap-3 text-13 text-[var(--text-danger)]">
+ <span>{t('bots.projects.failed')}</span>
+ <Button variant="secondary" compact disabled={busy} onClick={() => void load()}>{t('bots.memory.useLatest')}</Button>
+ </div>}
+ {!projects && !error ? <Spinner size={18} /> : null}
+ {linked.length > 0 ? <ul className="divide-y divide-[var(--border-default)] rounded-xl border border-[var(--border-default)]">
+ {linked.map(project => <li key={project.id} className="flex items-center gap-3 px-4 py-3">
+ <FolderOpen size={16} className="shrink-0 text-[var(--text-secondary)]" aria-hidden="true" />
+ <div className="min-w-0 flex-1">
+ <p className="break-words text-13 font-medium text-[var(--text-primary)]">{project.name}</p>
+ <p className="mt-1 break-all text-12 leading-5 text-[var(--text-secondary)]">{project.path}</p>
+ {(project.deviceId || !project.available) && <p className="mt-1 text-12 leading-5 text-[var(--text-tertiary)]">
+ {project.deviceId ? t('bots.projects.otherComputer', { device: project.deviceId }) : t('bots.projects.unavailable')}
+ </p>}
+ </div>
+ <Button variant="secondary" tone="quiet" compact disabled={busy} aria-label={t('bots.projects.remove', { name: project.name })}
+ onClick={() => void set(project.id, false)}><X size={16} /></Button>
+ </li>)}
+ </ul> : projects ? <p className="py-3 text-13 text-[var(--text-tertiary)]">{t('bots.projects.empty')}</p> : null}
+ {projects && <div className="flex flex-wrap items-center gap-2">
+ <Select label={t('bots.projects.choose')} value={selected} disabled={busy || !available.length}
+ className="min-w-0 flex-1" onValueChange={setSelected}
+ options={available.map(project => ({ value: project.id, label: project.name, title: project.path }))} />
+ <Button variant="secondary" disabled={busy || !available.some(project => project.id === selected)} onClick={() => void set(selected, true)}>
+ <Plus size={16} />{t('bots.projects.add')}
+ </Button>
+ </div>}
+ {projects && !available.length && <p className="text-12 leading-5 text-[var(--text-tertiary)]">{t('bots.projects.noAvailable')}</p>}
+ </div>;
+}
diff --git a/apps/desktop/src/renderer/features/bots/BotsHomeView.tsx b/apps/desktop/src/renderer/features/bots/BotsHomeView.tsx
index 8d3c841ac8..d73702cdc0 100644
--- a/apps/desktop/src/renderer/features/bots/BotsHomeView.tsx
+++ b/apps/desktop/src/renderer/features/bots/BotsHomeView.tsx
@@ -70,6 +70,7 @@ import {
type BotSettingsPayload,
} from './botSettingsAutosave';
import { useBotSettingsAutosave } from './useBotSettingsAutosave';
+import { BotProjectsSettings } from './BotProjectsSettings';
const DAY_MS = 24 * 60 * 60 * 1_000;
@@ -148,6 +149,7 @@ export function BotSettings({
| 'advanced'
| 'routines'
| 'memory'
+ | 'projects'
>(initialPage);
const voiceLeaveRef = useRef<(() => Promise<boolean>) | null>(null);
const routineLeaveRef = useRef<(() => Promise<boolean>) | null>(null);
@@ -155,7 +157,7 @@ export function BotSettings({
const memoryLeaveRef = useRef<(() => Promise<boolean>) | null>(null);
const memoryBackRef = useRef<(() => Promise<boolean>) | null>(null);
const pageTitle =
- page === 'voice'
+ page === 'projects' ? t('bots.projects.title') : page === 'voice'
? t('bots.voiceMode.settingsTitle')
: page === 'channels'
? t('bots.channels.title')
@@ -417,6 +419,7 @@ export function BotSettings({
['profile', botSettingsIcons.profile, t('bots.profile.title')],
['personality', botSettingsIcons.personality, t('bots.profile.personality')],
['memory', botSettingsIcons.memory, t('bots.memory.title')],
+ ['projects', botSettingsIcons.projects, t('bots.projects.title')],
['model', botSettingsIcons.model, t('bots.settingsTabs.model')],
['voice', botSettingsIcons.voice, t('bots.voiceMode.settingsTitle')],
['capabilities', botSettingsIcons.capabilities, t('bots.capabilities.title')],
@@ -643,6 +646,7 @@ export function BotSettings({
}} />
</div>
</section>
+ {page === 'projects' && <BotProjectsSettings key={bot.id} botId={bot.id} />}
{page === 'capabilities' && (
<div>
<BotCapabilitySettings
diff --git a/apps/desktop/src/renderer/features/bots/RemoteBotSettings.tsx b/apps/desktop/src/renderer/features/bots/RemoteBotSettings.tsx
index 38d77dfdf4..ace719d425 100644
--- a/apps/desktop/src/renderer/features/bots/RemoteBotSettings.tsx
+++ b/apps/desktop/src/renderer/features/bots/RemoteBotSettings.tsx
@@ -465,7 +465,7 @@ function RemoteBotSettingsContent({ bot, beforeCloseRef, onDeleted, initialPage
void save();
}}
>
- {item.id === 'follow-up' ? <p className="text-12 leading-5 text-[var(--text-secondary)]">{item.text}</p> : null}
+ {(item.id === 'follow-up' || item.id === 'project') ? <p className="text-12 leading-5 text-[var(--text-secondary)]">{item.text}</p> : null}
{item.id === 'avatar' ? (
<BotPortraitPicker
disabled={disabled}
@@ -603,6 +603,7 @@ function RemoteBotSettingsContent({ bot, beforeCloseRef, onDeleted, initialPage
resourceId === bot.id
? bot.id
: resourceId.includes('/connections/') ||
+ resourceId.includes('/projects/') ||
resourceId.includes('/skills/') ||
resourceId.includes('/memory/')
? resourceId.slice(0, resourceId.lastIndexOf('/'))
diff --git a/apps/desktop/src/renderer/features/bots/botSettingsIcons.ts b/apps/desktop/src/renderer/features/bots/botSettingsIcons.ts
index 8b4e65a1e7..113ca6e3d4 100644
--- a/apps/desktop/src/renderer/features/bots/botSettingsIcons.ts
+++ b/apps/desktop/src/renderer/features/bots/botSettingsIcons.ts
@@ -5,6 +5,7 @@ export const botSettingsIcons = {
profile: Info,
personality: UserRound,
memory: Brain,
+ projects: FolderOpen,
model: Sparkles,
voice: AudioLines,
capabilities: Settings2,
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index e5e321e289..0e3135dff0 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -10352,6 +10352,18 @@
"rootNotLoaded": "The original message is not in the loaded history",
"rootUnavailable": "The original message is no longer in this chat, so a thread can’t start here",
"openFailed": "The thread didn’t open. Try again."
+ },
+ "projects": {
+ "title": "Linked Projects",
+ "description": "Read project materials when needed. Linking a project does not assign its sessions or start background work.",
+ "empty": "No linked projects yet.",
+ "choose": "Choose a project",
+ "add": "Add",
+ "remove": "Remove {{name}}",
+ "otherComputer": "On another computer",
+ "unavailable": "Directory unavailable",
+ "failed": "Could not update projects. Reload to check the saved state.",
+ "noAvailable": "Add more projects from the project list first."
}
},
"common": {
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index c634b6c660..985ba51ab7 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -10317,6 +10317,18 @@
"rootNotLoaded": "元のメッセージは読み込み済みの履歴にありません",
"rootUnavailable": "元のメッセージがこのチャットにないため、スレッドを開始できません",
"openFailed": "スレッドを開けませんでした。もう一度お試しください。"
+ },
+ "projects": {
+ "title": "関連プロジェクト",
+ "description": "必要なときにプロジェクトの資料を読みます。関連付けてもセッションの担当やバックグラウンド作業は開始しません。",
+ "empty": "関連プロジェクトはありません",
+ "choose": "プロジェクトを選択",
+ "add": "追加",
+ "remove": "{{name}}を解除",
+ "otherComputer": "別のコンピューターにあります",
+ "unavailable": "ディレクトリを利用できません",
+ "failed": "プロジェクトを更新できませんでした。再読み込みして保存状態を確認してください。",
+ "noAvailable": "他のプロジェクトは、先にプロジェクト一覧に追加してください。"
}
},
"common": {
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 66f9c9d783..2079af5d69 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -10317,6 +10317,18 @@
"rootNotLoaded": "원본 메시지가 불러온 기록에 없습니다",
"rootUnavailable": "원본 메시지가 이 채팅에 없어 스레드를 시작할 수 없습니다",
"openFailed": "스레드를 열지 못했습니다. 다시 시도하세요."
+ },
+ "projects": {
+ "title": "연결된 프로젝트",
+ "description": "필요할 때 프로젝트 자료를 읽습니다. 연결해도 세션을 맡거나 백그라운드 작업을 시작하지 않습니다.",
+ "empty": "연결된 프로젝트가 없습니다",
+ "choose": "프로젝트 선택",
+ "add": "추가",
+ "remove": "{{name}} 연결 해제",
+ "otherComputer": "다른 컴퓨터에 있음",
+ "unavailable": "디렉터리를 사용할 수 없습니다",
+ "failed": "프로젝트를 업데이트하지 못했습니다. 다시 불러와 저장 상태를 확인하세요.",
+ "noAvailable": "다른 프로젝트는 먼저 프로젝트 목록에 추가하세요."
}
},
"common": {
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
index 0f0fe7389c..d324398416 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -10317,6 +10317,18 @@
"rootNotLoaded": "原消息不在已加载的记录里",
"rootUnavailable": "原消息已不在私聊里,不能开话题",
"openFailed": "话题没打开,请重试"
+ },
+ "projects": {
+ "title": "关联项目",
+ "description": "需要时读取项目资料。关联不会接手项目内的任务,也不会启动后台工作。",
+ "empty": "尚未关联项目",
+ "choose": "选择项目",
+ "add": "添加",
+ "remove": "移除 {{name}}",
+ "otherComputer": "位于另一台电脑",
+ "unavailable": "目录暂不可用",
+ "failed": "项目未能更新,请重新加载核对保存结果。",
+ "noAvailable": "更多项目可先在项目列表中添加。"
}
},
"common": {
diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
index d6cdcbde1a..09465975cd 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json
@@ -10317,6 +10317,18 @@
"rootNotLoaded": "原訊息不在已載入的紀錄裡",
"rootUnavailable": "原訊息已不在私聊裡,無法開話題",
"openFailed": "話題沒有開啟,請重試"
+ },
+ "projects": {
+ "title": "關聯專案",
+ "description": "需要時讀取專案資料。關聯不會接手專案內的任務,也不會啟動背景工作。",
+ "empty": "尚未關聯專案",
+ "choose": "選擇專案",
+ "add": "新增",
+ "remove": "移除 {{name}}",
+ "otherComputer": "位於另一台電腦",
+ "unavailable": "目錄暫不可用",
+ "failed": "專案未能更新,請重新載入核對儲存結果。",
+ "noAvailable": "更多專案可先在專案列表中新增。"
}
},
"common": {
diff --git a/apps/desktop/src/renderer/vite-env.d.ts b/apps/desktop/src/renderer/vite-env.d.ts
index 732ccc0aa6..eb8af15892 100644
--- a/apps/desktop/src/renderer/vite-env.d.ts
+++ b/apps/desktop/src/renderer/vite-env.d.ts
@@ -4973,6 +4973,10 @@ interface ElectronAPI {
update: (botId:string, patch:import('@cindy/maker-shared/teammate-todo').TodoPatch) => Promise<import('@cindy/maker-shared/teammate-todo').TeammateTodo>;
act: (botId:string, input:{id:string;revision:number;requestId:string;locale?:string}) => Promise<import('@cindy/maker-shared/teammate-todo').TeammateTodo | null>;
};
+ projects: {
+ list: (botId: string) => Promise<import('../shared/botWorkbench').BotProjectOption[]>;
+ set: (botId: string, projectId: string, linked: boolean) => Promise<import('../shared/botWorkbench').BotProjectOption[]>;
+ };
workbench: {
get: (botId: string) => Promise<import('../shared/botWorkbench').BotWorkbench | null>;
readTask: (
diff --git a/apps/desktop/src/shared/botWorkbench.ts b/apps/desktop/src/shared/botWorkbench.ts
index 110afb3b1b..aeadfb24fb 100644
--- a/apps/desktop/src/shared/botWorkbench.ts
+++ b/apps/desktop/src/shared/botWorkbench.ts
@@ -3,7 +3,7 @@
*
* 2026-10-17 起放弃「项目」思路:伙伴不再按目录接手项目,也不再写候选任务的判断。工作台只剩
* 它负责的任务(自己开的 + 明确接手的)与宿主观察层给出的「一眼」投影(见 `botAutonomy.ts`)。
- * 旧版 `workbench.json` 里的 `directories` / `tasks` 读取时一律忽略,不迁移、不报错;旧判断
+ * `workbench.json` 的 directories 用于伙伴设置中的关联项目,不作为任务责任来源;旧判断
* 只作为 Todo 的兼容来源由主进程读取(`botWorkbenchLegacy.ts`)。
*
* 任务状态只从宿主已有的真实信号推导——运行中、等待交互、上一轮出错或被打断、后台任务状态、
@@ -15,6 +15,23 @@ export interface BotWorkbench {
responsibleSessionIds?: string[];
}
+/** Project references provide context, never task responsibility or execution permission. */
+export interface BotLinkedProject {
+ path: string;
+ addedAt: string;
+ /** Missing means this computer; a foreign path must never be opened locally. */
+ deviceId?: string;
+}
+
+export interface BotProjectOption {
+ id: string;
+ name: string;
+ path: string;
+ deviceId?: string;
+ linked: boolean;
+ available: boolean;
+}
+
/** 一件任务最近内容的只读摘录(工具与详情视图共用)。 */
export interface WorkbenchTranscriptItem {
role: 'user' | 'assistant';
diff --git a/apps/mobile/src/session/CompanionProfileNativeView.ios.tsx b/apps/mobile/src/session/CompanionProfileNativeView.ios.tsx
index 858a27e5a0..46d14faa59 100644
--- a/apps/mobile/src/session/CompanionProfileNativeView.ios.tsx
+++ b/apps/mobile/src/session/CompanionProfileNativeView.ios.tsx
@@ -47,7 +47,7 @@ export function CompanionProfileNativeView(p: CompanionProfileNativeViewProps) {
<HStack spacing={ROW_GAP} modifiers={[frame({ maxWidth: Infinity, minHeight: 44 }), contentShape(shapes.rectangle())]}><Image systemName={symbol as never} size={iconSize.action} modifiers={[foregroundStyle(colors.textSecondary), frame({ width: ROW_ICON_WIDTH })]} /><Text>{tr(id)}</Text><Spacer /><Image systemName="chevron.right" size={iconSize.xs} /></HStack>
</Button>;
const panel = (target?: ProfilePanel) => target?.action ? <>
- {(target.id === 'capability' || target.id === 'follow-up') && target.text ? note(target.text) : null}
+ {(target.id === 'capability' || target.id === 'follow-up' || target.id === 'project') && target.text ? note(target.text) : null}
{target.action.fields?.map(field => <Field key={field.id} field={field} values={p.values} onChange={p.onChange} busy={p.busy || !p.online || !!target.action?.disabled} />)}
<Section>{action(tr('save'), () => p.onSubmit(target), !p.online || !p.dirty || p.conflict || !!target.action.disabled)}</Section>
</> : note(target?.text || tr('hostUpgrade'));
@@ -57,7 +57,7 @@ export function CompanionProfileNativeView(p: CompanionProfileNativeViewProps) {
<Text modifiers={[font({ textStyle: 'headline' }), lineLimit(2)]}>{p.name}</Text><Spacer />
</HStack></Section>
<Section>{row('profile', 'person.crop.circle')}{row('memory', 'brain')}{row('models', 'slider.horizontal.3')}{row('skills', 'sparkles')}</Section>
- {p.data?.panels.find(item => item.id === 'followUp')?.entries?.map(entry => <Section key={entry.id}>{action(label(entry.title), () => p.onEditor(entry.resourceId), !p.online)}</Section>)}
+ {p.data?.panels.filter(item => item.id === 'projects' || item.id === 'followUp').flatMap(item => item.entries ?? [])?.map(entry => <Section key={entry.id}>{action(label(entry.title), () => p.onEditor(entry.resourceId), !p.online)}</Section>)}
<Section>{row('artifacts', 'doc.text')}{p.onSearch ? row('search', 'magnifyingglass', p.onSearch) : null}{row('permissions', 'hand.raised')}</Section>
{p.onHome ? <Section>{row('home', 'desktopcomputer', p.onHome)}</Section> : null}
<Section>{p.data?.panels.filter(item => ['restart', 'resume', 'delete'].includes(item.id) && item.action).map(item => <Button key={item.id} onPress={() => p.onConfirm(item)} modifiers={[buttonStyle('plain'), listRowInsets({ top: 4, bottom: 4, leading: 16, trailing: 16 }), disabled(p.busy || !p.online), frame({ minHeight: 44 }), ...(item.id === 'delete' ? [foregroundStyle(colors.destructive)] : [])]}><HStack modifiers={[frame({ maxWidth: Infinity, minHeight: 44 }), contentShape(shapes.rectangle())]}><Text>{label(item.action!.label)}</Text><Spacer /></HStack></Button>)}</Section>
diff --git a/apps/mobile/src/session/CompanionProfileSheet.tsx b/apps/mobile/src/session/CompanionProfileSheet.tsx
index 85de3399ac..e10aae435e 100644
--- a/apps/mobile/src/session/CompanionProfileSheet.tsx
+++ b/apps/mobile/src/session/CompanionProfileSheet.tsx
@@ -369,7 +369,7 @@ function CompanionProfileSheetContent(props: CompanionProfileSheetProps) {
const save = (target: ProfilePanel, blocked: boolean) => <MainWindowActionButton action={{ label: t('devices.companionProfile.save'), busy,
disabled: blocked || !online || !dirty || conflict?.page === page, onPress: () => void submit(target) }} />;
const formPanel = (target: ProfilePanel | undefined) => target?.action ? <>
- {(target.id === 'capability' || target.id === 'follow-up') && target.text ? noteText(target.text) : null}
+ {(target.id === 'capability' || target.id === 'follow-up' || target.id === 'project') && target.text ? noteText(target.text) : null}
<CompanionProfileForm panel={target} values={editing ? values : target.values} onChange={changeValues} disabled={busy || !online || !!target.action.disabled} />
{save(target, !!target.action.disabled)}
</> : target?.text ? <Text selectable style={styles.body}>{target.text}</Text> : !data && online ? spinner : note('hostUpgrade');
@@ -383,7 +383,7 @@ function CompanionProfileSheetContent(props: CompanionProfileSheetProps) {
<Text accessibilityRole="header" numberOfLines={2} style={styles.name}>{name}</Text>
</View>
<View style={styles.group}>{row('profile', Info)}{row('memory', Brain)}{row('models', Sparkles)}{row('skills', Settings2)}</View>
- {data?.panels.find(item => item.id === 'followUp')?.entries?.map(entry => <View style={styles.group} key={entry.id}><ContextSheetRow icon={null} trailing="chevron" label={label(entry.title)} onPress={() => void openEditor(entry.resourceId)} disabled={!online} /></View>)}
+ {data?.panels.filter(item => item.id === 'projects' || item.id === 'followUp').flatMap(item => item.entries ?? [])?.map(entry => <View style={styles.group} key={entry.id}><ContextSheetRow icon={null} trailing="chevron" label={label(entry.title)} onPress={() => void openEditor(entry.resourceId)} disabled={!online} /></View>)}
<View style={styles.group}>{row('artifacts', FileText)}{onOpenSearch ? row('search', History, onOpenSearch) : null}{row('permissions', Hand)}</View>
{onOpenHome ? <View style={styles.group}>{row('home', Monitor, onOpenHome)}</View> : null}
{/* Host order, like iOS: restart / resume / delete are whatever the computer offers now. */}
diff --git a/docs/dev-rules/protocol-compatibility.md b/docs/dev-rules/protocol-compatibility.md
index 43bb327b6d..f6008b963c 100644
--- a/docs/dev-rules/protocol-compatibility.md
+++ b/docs/dev-rules/protocol-compatibility.md
@@ -3071,3 +3071,13 @@ namespace + id 下同一插件的有界 JSON 请求;`deviceSync: true` 是独
配置读取、保存与包内导航照旧,完整跨文档确认隔离须两端都更新。插件本身无需更新,
不改变已装批准、凭证、KV、版本或原生指纹。实现与时序验证见
[原配置页协议](../remote-plugin-oauth.md#手机原配置页授权的增量能力)。
+
+
+## 伙伴关联项目
+
+`teammates` 增加 `settings:<botId>/projects` 与其项目详情资源。使用既有 list/form/toggle 原语,
+保存仍绑定账号、控制端、伙伴和资源 revision。远程不传目录绝对路径,项目 ID 为不透明摘要;
+旧控制端可忽略新入口,新控制端连接旧 Host 时不显示入口。手机两端与远程桌面共用宿主投影。
+本机新增 `local-db:bots:projects:list/set` 仅用于受信 renderer,不进入远程 IPC allowlist。
+旧 `workbench.json` 目录及设备归属沿用原格式;关联不进入任务负责范围或扩大文件权限。
+不改服务端、数据库 schema、Mobile 原生配置或指纹。
diff --git a/docs/product-rules/agent-user-parity.md b/docs/product-rules/agent-user-parity.md
index b65c167be3..077fc80636 100644
--- a/docs/product-rules/agent-user-parity.md
+++ b/docs/product-rules/agent-user-parity.md
@@ -55,6 +55,7 @@
| 定时任务 | 删除单条运行记录、标记已读 | 无 | 无 |
| 项目 | 列出、登记、改名、移除;工作目录列表 | 有 | 无 |
| 伙伴 | 发现伙伴、伙伴间消息 | 有 | 有 |
+| 伙伴 | 自身关联项目:列出、添加与移除(原有文件工具按需读资料) | 有 | 无(远程设置界面可管理) |
| 伙伴 | 资料、能力、待办、后台任务 | 有 | 无 |
| 伙伴 | 「一眼」投影(等你 / 在做;用户界面已改为近况,2026-10-21) | 有 | 无 |
| 伙伴 | 跟进任务:读取与继续(自动跟进所有任务的伙伴) | 有 | 有(2026-10-17) |
diff --git a/docs/product-rules/cindy-bots-runtime.md b/docs/product-rules/cindy-bots-runtime.md
index fc7269e77e..39bc1363d1 100644
--- a/docs/product-rules/cindy-bots-runtime.md
+++ b/docs/product-rules/cindy-bots-runtime.md
@@ -315,6 +315,23 @@ Cindy 应用,也不取消伙伴已委派的独立任务。操作中禁用重
读写和学习,工具入口在存储及刷新之前明确返回不可用,不能承诺下一轮或新任务生效;
这不影响远端已支持的共同基座、记忆、协作及能力发现。手机控制本机运行时仍使用本机自有 Skill。
+### 关联项目(2026-10-22)
+
+每个伙伴(包括 Cindy)在设置中独立关联多个项目。项目列表可添加、查看和移除;关联沿用 Home 中
+`workbench.json` 的 `directories`,旧关联直接可见,保留 `deviceId` 与旧 Todo 判断。移除只改关联,
+不删除项目、文件、记忆或任务责任。损坏文件不能用空列表覆盖。
+
+关联是按需读取资料的入口,不改变伙伴 Home、默认工作目录、文件工具权限或逐任务责任,不自动授权
+改仓库、向任务发消息或后台扫描。伙伴通过 `list_teammate_projects` 查询自己的关联及目录所属电脑,
+按需用原有文件工具读取项目的 AGENTS、README 和项目知识索引等;项目资料与记忆沿用项目自己的规范,
+不复制进伙伴个人记忆。另一台电脑上的路径只作引用,不在本机打开;需在原电脑按已有访问方式读取。
+`set_teammate_project` 只修改调用伙伴自己的关联,走现有权限与行动核验。
+
+桌面本地设置从注册项目中选择;远程桌面与手机复用 `settings:<botId>/projects` 的列表、项目开关与保存,
+只传项目名、可用状态和不透明 ID,不暴露宿主绝对路径。新增项目先在伙伴所在电脑登记到项目列表。
+主力电脑切换沿用已有目录随行协议,文件不搬家,不把另一台电脑上的目录当作本机目录。
+实现:`botLinkedProjects.ts`、`botWorkbenchService.ts`、`BotProjectsSettings.tsx` 与 `botRemoteEditors.ts`。
+
## 5. 模型候选链
伙伴 Profile 可配置 **1–5 个有序候选**,每项是一个完整运行路由:
diff --git a/packages/lizi-mcps/src/__tests__/botWorkbenchTool.test.ts b/packages/lizi-mcps/src/__tests__/botWorkbenchTool.test.ts
index 00891bbd3f..d48065c908 100644
--- a/packages/lizi-mcps/src/__tests__/botWorkbenchTool.test.ts
+++ b/packages/lizi-mcps/src/__tests__/botWorkbenchTool.test.ts
@@ -193,3 +193,19 @@ it('keeps older hosts usable without advertising an unavailable responsibility w
expect(names).toContain('get_workbench');
expect(names).not.toContain('set_workbench_task_responsibility');
});
+
+// Restored links are independently discoverable; no task responsibility callback runs when linking.
+// Minimal input: list + one project toggle with a caller session. Unit tool registry contract.
+it('exposes project discovery and changes using caller identity without claiming any tasks', async () => {
+ const { callbacks } = setup();
+ callbacks.projects = vi.fn(async () => ({ ok: true as const, projects: [{ project_id: 'a'.repeat(64), working_dir: '/project', linked: true }] }));
+ const registry = new XdtHelperToolRegistry();
+ registerBotWorkbenchTools(registry, { callbacks, getSessionContext: () => ({ sessionId: 'main', agentKind: 'codex', workingDir: '/home' }) });
+ expect(parse(await registry.call('list_teammate_projects', {}))).toMatchObject({ ok: true, projects: [{ linked: true }] });
+ await registry.call('set_teammate_project', { project_id: 'a'.repeat(64), linked: false });
+ expect(callbacks.projects).toHaveBeenLastCalledWith({ callerSessionId: 'main', projectId: 'a'.repeat(64), linked: false });
+ expect(callbacks.setResponsibility).not.toHaveBeenCalled();
+ const unbound = new XdtHelperToolRegistry();
+ registerBotWorkbenchTools(unbound, { callbacks, getSessionContext: () => ({ agentKind: 'codex', workingDir: '/home' }) });
+ expect(parse(await unbound.call('list_teammate_projects', {}))).toMatchObject({ ok: false, errorCode: 'NOT_A_BOT_SESSION' });
+});
diff --git a/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts b/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts
index 7324e33485..11853bc8c8 100644
--- a/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts
+++ b/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts
@@ -154,7 +154,7 @@ export const HELPER_CATEGORY_DESCRIPTIONS: Record<(typeof CATEGORY_ENUM)[number]
handoff: '给已有任务发消息,或新建任务。发给已有任务可跨电脑(deviceId::sessionId);新建只在本机。',
skills: 'Skill 的搜索、发布与学习。本机与 SkillHub。',
app_update: `检查与安装本机的 ${BRAND_NAME} 更新。本机。`,
- bots: '伙伴:资料、能力、工作台、待办、后台任务、伙伴间消息与主力电脑。伙伴间消息(list_agents / send_to_agent)、主力电脑(get_teammate_home / move_teammate_home)、总调度伙伴读取与继续另一台电脑上的任务(read_workbench_task / continue_workbench_task 传 deviceId::sessionId)可跨电脑;其余本机。',
+ bots: '伙伴:资料、能力、关联项目(list_teammate_projects / set_teammate_project,仅自身)、工作台、待办、后台任务、伙伴间消息与主力电脑。伙伴间消息(list_agents / send_to_agent)、主力电脑(get_teammate_home / move_teammate_home)、总调度伙伴读取与继续另一台电脑上的任务(read_workbench_task / continue_workbench_task 传 deviceId::sessionId)可跨电脑;其余本机。',
};
interface SessionTaskCallbacks {
diff --git a/packages/lizi-mcps/src/xdt-helper/bot_workbench.ts b/packages/lizi-mcps/src/xdt-helper/bot_workbench.ts
index 929c2dee89..313630366e 100644
--- a/packages/lizi-mcps/src/xdt-helper/bot_workbench.ts
+++ b/packages/lizi-mcps/src/xdt-helper/bot_workbench.ts
@@ -50,6 +50,7 @@ export interface WorkbenchTranscriptWire {
}
export interface BotWorkbenchCallbacks {
+ projects?: (params: { callerSessionId: string; projectId?: string; linked?: boolean; includeAvailable?: boolean }) => Promise<ControlResult<{ projects: Array<Record<string, unknown>> }, string>>;
setResponsibility?: (params: { callerSessionId: string; taskId: string; responsible: boolean }) => Promise<ControlResult<{ taskId: string; responsible: boolean }, string>>;
todos?: (
callerSessionId: string,
@@ -125,6 +126,29 @@ export function registerBotWorkbenchTools(
deps: BotWorkbenchToolDeps,
): void {
const callerSessionId = () => deps.getSessionContext().sessionId ?? null;
+ if (deps.callbacks.projects) {
+ const projects = deps.callbacks.projects;
+ registry.register({
+ name: 'list_teammate_projects', category: 'bots',
+ description: 'List your linked projects with their computer, directory and availability. Read relevant project instructions and materials on demand with your file tools; keep project knowledge in its existing location, not your personal memory. Foreign-computer paths must not be read locally. include_available also lists local registered projects you can link. This does not read project contents, assign tasks, authorize repository changes or start background work.',
+ inputShape: { include_available: z.boolean().optional() },
+ handler: async ({ include_available }) => {
+ const id = callerSessionId(); if (!id) return missingSession();
+ const result = await projects({ callerSessionId: id, includeAvailable: include_available });
+ return result.ok ? okPayload({ projects: result.projects }) : errorPayload(result.errorCode, result.message);
+ },
+ });
+ registry.register({
+ name: 'set_teammate_project', category: 'bots',
+ description: 'Link or unlink one project in your own teammate settings when the owner requests it. Use the project_id from list_teammate_projects(include_available=true). Unlinking preserves files, project registration, memory and task responsibility. Linking is context only, not authorization to edit a repository, contact tasks or scan in the background.',
+ inputShape: { project_id: z.string().regex(/^[a-f0-9]{64}$/), linked: z.boolean() },
+ handler: async ({ project_id, linked }) => {
+ const id = callerSessionId(); if (!id) return missingSession();
+ const result = await projects({ callerSessionId: id, projectId: project_id, linked });
+ return result.ok ? okPayload({ projects: result.projects }) : errorPayload(result.errorCode, result.message);
+ },
+ });
+ }
if (deps.callbacks.todos) registerTodoTools(registry, callerSessionId, deps.callbacks.todos);
if (deps.callbacks.setResponsibility) {
diff --git a/packages/lizi-mcps/src/xdt-helper/capabilities.ts b/packages/lizi-mcps/src/xdt-helper/capabilities.ts
index cede591802..3f37c0869f 100644
--- a/packages/lizi-mcps/src/xdt-helper/capabilities.ts
+++ b/packages/lizi-mcps/src/xdt-helper/capabilities.ts
@@ -65,7 +65,7 @@ export const CAPABILITIES: readonly CapabilityEntry[] = [
'【原则】用户本人能做的操作(含跨电脑),Agent 也应有对应工具;是否执行由权限档与自动审核决定。数据保存在各自的电脑上:下结论「没有 / 没人在跟」之前,先确认查的是不是只有本机。',
'【任务】cindy_helper history 类:list_sessions / search_chat_history(device=local|all|<deviceId>)、get_chat_history(deviceId::sessionId)、get_task_digest(一件任务的 ≤2KB 摘要:状态、已持续分钟、最后的要求与回答、待答问题、错误、模型路线与建议换到的下一条、PR、排队数;deviceId::sessionId 只读)、list_history_devices 可跨电脑;list_workdirs、list_session_queue 仅本机。handoff 类 send_to_session:发给既有任务可跨电脑(deviceId::sessionId),新建任务仅本机。control 类 archive_sessions / unarchive_sessions 可跨电脑(deviceId::sessionId,单次限定一台电脑);改名、移动、标签、排队消息、插话、停止、运行设置、list_projects 与项目增删改仅本机。',
'【定时任务】cindy_scheduler:schedule_list / get / list_runs(device=local|all|<deviceId>,list 可用 query 做文本筛选)与 schedule_update / pause / resume / delete / run_now(device=<deviceId>)可跨电脑;schedule_create、schedule_set_pre_run_hook、当前运行的通知设置仅本机。',
- '【伙伴】cindy_helper bots 类(仅伙伴任务可见):list_agents / send_to_agent 可跨电脑(deviceId::botId);get_teammate_home / move_teammate_home 查看与更换任一伙伴的主力电脑(跨电脑,更换按权限档);资料、能力、待办、后台任务仅本机。',
+ '【伙伴】cindy_helper bots 类(仅伙伴任务可见):list_agents / send_to_agent 可跨电脑(deviceId::botId);get_teammate_home / move_teammate_home 查看与更换任一伙伴的主力电脑(跨电脑,更换按权限档);资料、能力、待办、后台任务仅本机。list_teammate_projects / set_teammate_project 读取与修改自身关联项目,资料按需读取,关联不授予任务责任或执行权限。',
'【自动跟进】宿主在任务卡住、等主人、出错、撞用量上限、做完时叫醒负责跟进的伙伴(内置例行任务)。伙伴先 get_task_digest 读摘要,再用 continue_workbench_task 让任务继续、send_to_session 代答低风险问题、set_session_runtime 换到 suggested_route(仅本机)、update_teammate_todo 记下要主人处理的事。get_workbench 是工作台「一眼」(等你 / 在做,仅本机投影);负责「自动跟进所有任务」的伙伴可读取与继续另一台在线电脑上的任务(read_workbench_task / continue_workbench_task 传 deviceId::sessionId),别的伙伴开的任务默认只读不继续(TASK_FOLLOWED_BY_OTHER_BOT,主人可在那位伙伴的设置里交出来);其它伙伴只碰自己开的或接手的任务。',
'【跨电脑的前提】对方电脑在线、同一账号、已开启远程控制。离线、未开启、版本不支持或超时会按电脑写明原因,结果里的 partial=true 表示有电脑没查到。',
'【尚无工具】在另一台电脑上新建任务或定时任务、管理另一台电脑上的任务(改名 / 停止 / 队列)与项目;这些用户可在远程控制里手动完成。',