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(issue): 提升官方反馈的信息质量与隐私保护 (#2147)

Dashf9e88ca22d2d
diff --git a/apps/desktop/help-knowledge/commands.md b/apps/desktop/help-knowledge/commands.md
index 8743b2c7fc..490ac30954 100644
--- a/apps/desktop/help-knowledge/commands.md
+++ b/apps/desktop/help-knowledge/commands.md
@@ -11,6 +11,10 @@ Type `/` at the start of the composer to open the command palette.
2. **Built-in app commands** — `/help` (show available commands), `/clear` (clear the current session context — resets the conversation in place without creating a new session), `/cmd` (run a shell command in the working directory), `/issue` (file an issue), `/goal` (start a goal-driven run), `/learn`, `/workflows`, and `/jump-session`.
3. **The agent's own commands** — e.g. `/compact`, `/agents`, `/memory` (the exact list depends on the agent; Claude Code and Codex each contribute their own).
+`/issue` does not require a GitHub plugin or GitHub account. The confirmation card uses Cindy's official bot by default; if a working account is already configured under **Plugins > Cindy GitHub**, that account appears as an optional submission identity.
+
+Before submitting, Cindy helps clarify missing details so the issue is actionable. For bugs, it can collect reproduction steps and user-approved, redacted diagnostic summaries; the confirmation card always shows the final public content. After creation, Cindy returns the issue link and can help interested users reproduce or fix the problem from source because Cindy is open source.
+
**Using the palette:**
- Start typing to filter. Matching is **contains-based** (case-insensitive substring matching on the command name) — not fuzzy.
diff --git a/apps/desktop/help-knowledge/connections.md b/apps/desktop/help-knowledge/connections.md
index 91b9080ef8..074017d121 100644
--- a/apps/desktop/help-knowledge/connections.md
+++ b/apps/desktop/help-knowledge/connections.md
@@ -10,7 +10,7 @@ External account connections have moved out of the old "Third-Party Platforms" s
- **Slack** — bound with a single toggle under **Settings > IM bots** (the "Cindy" tab). One browser sign-in covers both directions: the Slack channel bot that receives tasks, and the agent Slack tools (search / read / post). If Slack tools don't work on an older binding, toggle it off and on once to re-authorize.
- **Telegram** — under **Settings > IM bots** (the "Cindy" tab), turn on Telegram and choose **Link Telegram**. Open the one-time link, start the official Cindy bot, and complete confirmation if prompted. The same card lets you cancel, retry, open the bot, add it to a group, or unlink; no personal bot token is required.
- **Google** (Gmail / Calendar / Drive / Sheets) — handled by the Filo Google plugin (Plugins > Filo Google).
-- **GitHub** — handled by the Cindy GitHub plugin (Plugins > Cindy GitHub; existing PAT connections are migrated automatically).
+- **GitHub** — handled by the Cindy GitHub plugin (Plugins > Cindy GitHub; existing PAT connections are migrated automatically). This connection is optional for `/issue`: feedback uses Cindy's official bot by default, and a working GitHub connection only adds the option to submit as yourself.
- **GitLab** — handled by the Cindy GitLab plugin (Plugins > Cindy GitLab; existing PAT connections are migrated automatically).
- **Codex** — sign in under Settings > Model Providers (separate from the Codex CLI binary the app ships with).
- **FeiShu** — bot only (App ID / Secret under Settings > IM bots; see the FeiShu bot topic). FeiShu is no longer a sign-in method for Cindy itself.
diff --git a/apps/desktop/src/main/github-issue/__tests__/githubIssueSubmitService.test.ts b/apps/desktop/src/main/github-issue/__tests__/githubIssueSubmitService.test.ts
index e86da81b5a..f0065c03b6 100644
--- a/apps/desktop/src/main/github-issue/__tests__/githubIssueSubmitService.test.ts
+++ b/apps/desktop/src/main/github-issue/__tests__/githubIssueSubmitService.test.ts
@@ -9,7 +9,7 @@ import {
submitGithubIssueWithConfirm,
type GithubIssueSubmitServiceDeps,
} from '../githubIssueSubmitService';
-import type { IssueConfirmDecision, IssueSubmissionIdentity } from '../issueConfirmBridge';
+import type { IssueConfirmDecision } from '../issueConfirmBridge';
const REQ = {
sessionId: 'sess-1',
@@ -36,7 +36,7 @@ function makeDeps(over: Partial<GithubIssueSubmitServiceDeps> = {}) {
}));
const deps: GithubIssueSubmitServiceDeps = {
confirm,
- resolveSubmissionIdentity: async () => PLATFORM_IDENTITY,
+ resolveSubmissionChoices: async () => ({ platform: PLATFORM_IDENTITY }),
postIssue,
getAppVersion: () => '0.0.112',
getOsInfo: () => ({ platform: 'darwin', arch: 'arm64', osVersion: '25.5.0' }),
@@ -86,7 +86,7 @@ describe('submitGithubIssueWithConfirm', () => {
osVersion: '25.5.0',
region: 'cn',
},
- PLATFORM_IDENTITY,
+ { platform: PLATFORM_IDENTITY },
'Carol',
);
expect(postIssue).toHaveBeenCalledTimes(1);
@@ -106,9 +106,41 @@ describe('submitGithubIssueWithConfirm', () => {
issueUrl: 'https://github.com/makecindy/cindy/issues/80',
finalTitle: '用户改过的标题',
editedByUser: true,
+ privacyRedacted: false,
});
});
+ it('agent 初稿中的常见敏感信息在确认前自动脱敏,并标记隐私处理', async () => {
+ const confirm = vi.fn<GithubIssueSubmitServiceDeps['confirm']>(
+ async (_sessionId, draft) => ({
+ confirmed: true,
+ title: draft.title,
+ body: draft.body,
+ type: draft.type,
+ publicName: 'Carol',
+ uiLanguage: 'zh-CN',
+ }),
+ );
+ const postIssue = vi.fn<GithubIssueSubmitServiceDeps['postIssue']>(async () => ({
+ githubIssue: { number: 81, url: 'https://github.com/makecindy/cindy/issues/81' },
+ }));
+ const { deps } = makeDeps({ confirm, postIssue });
+ const fakeApiKey = ['sk', 'abcdefghijklmnopqrstuvwx'].join('-');
+ const req = {
+ ...REQ,
+ title: `崩溃日志含 ${fakeApiKey}`,
+ body: '邮箱 [email protected],日志位于 /Users/carol/project/app.log',
+ };
+
+ const result = await submitGithubIssueWithConfirm(deps, req);
+ expect(confirm.mock.calls[0]![1]).toMatchObject({
+ title: '崩溃日志含 [REDACTED:api-key]',
+ body: '邮箱 [REDACTED:email],日志位于 ~/project/app.log',
+ });
+ expect(postIssue).toHaveBeenCalledTimes(1);
+ expect(result).toMatchObject({ ok: true, privacyRedacted: true });
+ });
+
it('env 块只标注非默认区域: cn → CN / dev → Dev,global 省略该行', async () => {
for (const [region, label] of [
['cn', '**版本区域**: CN'],
@@ -135,11 +167,11 @@ describe('submitGithubIssueWithConfirm', () => {
expect(description).toContain('**界面语言**: zh-CN');
});
- it('身份解析收到当前 session workingDir', async () => {
- const resolveSubmissionIdentity = vi.fn(async () => PLATFORM_IDENTITY);
- const { deps } = makeDeps({ resolveSubmissionIdentity });
+ it('身份选项解析收到当前 session workingDir', async () => {
+ const resolveSubmissionChoices = vi.fn(async () => ({ platform: PLATFORM_IDENTITY }));
+ const { deps } = makeDeps({ resolveSubmissionChoices });
await expect(submitGithubIssueWithConfirm(deps, REQ)).resolves.toMatchObject({ ok: true });
- expect(resolveSubmissionIdentity).toHaveBeenCalledWith('/repo');
+ expect(resolveSubmissionChoices).toHaveBeenCalledWith('/repo');
});
it('未编辑时 editedByUser=false;未回传 uiLanguage 时用 fallback locale', async () => {
@@ -255,25 +287,35 @@ describe('submitGithubIssueWithConfirm', () => {
}
});
- it('已绑定身份会展示并严格按该身份提交', async () => {
+ it('已绑定身份作为额外选项展示,并严格按用户选择提交', async () => {
const identity = { kind: 'github-user', login: 'octocat' } as const;
- const { deps, confirm, postIssue } = makeDeps({
- resolveSubmissionIdentity: async (): Promise<IssueSubmissionIdentity> => identity,
+ const submissionChoices = { platform: PLATFORM_IDENTITY, githubUser: identity } as const;
+ const confirm = vi.fn<GithubIssueSubmitServiceDeps['confirm']>(async () => ({
+ confirmed: true as const,
+ title: REQ.title,
+ body: REQ.body,
+ type: REQ.type,
+ submissionIdentity: identity,
+ uiLanguage: 'zh-CN',
+ }));
+ const { deps, postIssue } = makeDeps({
+ resolveSubmissionChoices: async () => submissionChoices,
+ confirm,
});
const res = await submitGithubIssueWithConfirm(deps, REQ);
expect(res).toMatchObject({ ok: true });
- expect(confirm.mock.calls[0]![3]).toEqual(identity);
- expect(confirm.mock.calls[0]![4]).toBeUndefined();
+ expect(confirm.mock.calls[0]![3]).toEqual(submissionChoices);
+ expect(confirm.mock.calls[0]![4]).toBe('Carol');
expect(postIssue.mock.calls[0]![0]).toEqual(identity);
expect(postIssue.mock.calls[0]![1]()).not.toHaveProperty('userName');
});
- it('身份解析失败时不弹确认卡、不提交', async () => {
+ it('身份选项解析意外失败时不弹确认卡、不提交', async () => {
const error = Object.assign(new Error('GitHub token 已失效,请重新绑定'), {
issueErrorCode: 'AUTH_NOT_READY' as const,
});
const { deps, confirm, postIssue } = makeDeps({
- resolveSubmissionIdentity: async () => Promise.reject(error),
+ resolveSubmissionChoices: async () => Promise.reject(error),
});
const res = await submitGithubIssueWithConfirm(deps, REQ);
expect(res).toMatchObject({ ok: false, errorCode: 'AUTH_NOT_READY' });
@@ -300,9 +342,20 @@ describe('submitGithubIssueWithConfirm', () => {
});
it('GitHub 用户直发成功后记账,带 login、不带公开署名', async () => {
+ const identity = { kind: 'github-user', login: 'octocat' } as const;
const onSubmitted = vi.fn();
const { deps } = makeDeps({
- resolveSubmissionIdentity: async () => ({ kind: 'github-user', login: 'octocat' }) as const,
+ resolveSubmissionChoices: async () => ({
+ platform: PLATFORM_IDENTITY,
+ githubUser: identity,
+ }),
+ confirm: vi.fn(async () => ({
+ confirmed: true as const,
+ title: REQ.title,
+ body: REQ.body,
+ type: REQ.type,
+ submissionIdentity: identity,
+ })),
onSubmitted,
});
await expect(submitGithubIssueWithConfirm(deps, REQ)).resolves.toMatchObject({ ok: true });
@@ -359,7 +412,9 @@ describe('submitGithubIssueWithConfirm', () => {
const failed = vi.fn();
await submitGithubIssueWithConfirm(
makeDeps({
- postIssue: vi.fn(async () => Promise.reject(Object.assign(new Error('x'), { statusCode: 500 }))),
+ postIssue: vi.fn(async () =>
+ Promise.reject(Object.assign(new Error('x'), { statusCode: 500 })),
+ ),
onSubmitted: failed,
}).deps,
REQ,
@@ -387,7 +442,17 @@ describe('submitGithubIssueWithConfirm', () => {
});
});
const { deps } = makeDeps({
- resolveSubmissionIdentity: async () => identity,
+ resolveSubmissionChoices: async () => ({
+ platform: PLATFORM_IDENTITY,
+ githubUser: identity,
+ }),
+ confirm: vi.fn(async () => ({
+ confirmed: true as const,
+ title: REQ.title,
+ body: REQ.body,
+ type: REQ.type,
+ submissionIdentity: identity,
+ })),
postIssue,
});
const res = await submitGithubIssueWithConfirm(deps, REQ);
diff --git a/apps/desktop/src/main/github-issue/__tests__/githubUserIssueSubmitter.test.ts b/apps/desktop/src/main/github-issue/__tests__/githubUserIssueSubmitter.test.ts
index d8cfa8652c..9d9ba7add7 100644
--- a/apps/desktop/src/main/github-issue/__tests__/githubUserIssueSubmitter.test.ts
+++ b/apps/desktop/src/main/github-issue/__tests__/githubUserIssueSubmitter.test.ts
@@ -3,7 +3,7 @@ import { describe, expect, it, vi } from 'vitest';
import {
PLATFORM_ISSUE_SUBMISSION_IDENTITY,
postGithubIssueAsUser,
- resolveGithubIssueSubmissionIdentity,
+ resolveGithubIssueSubmissionChoices,
type GithubUserIssueSubmitterDeps,
} from '../githubUserIssueSubmitter';
@@ -28,12 +28,12 @@ function makeDeps(over: Partial<GithubUserIssueSubmitterDeps> = {}): GithubUserI
};
}
-describe('resolveGithubIssueSubmissionIdentity', () => {
- it('已启用且凭证有效时解析为 GitHub 用户本人', async () => {
+describe('resolveGithubIssueSubmissionChoices', () => {
+ it('已启用且凭证有效时保留平台默认并追加 GitHub 用户选项', async () => {
const deps = makeDeps();
- await expect(resolveGithubIssueSubmissionIdentity(deps)).resolves.toEqual({
- kind: 'github-user',
- login: 'octocat',
+ await expect(resolveGithubIssueSubmissionChoices(deps)).resolves.toEqual({
+ platform: PLATFORM_ISSUE_SUBMISSION_IDENTITY,
+ githubUser: { kind: 'github-user', login: 'octocat' },
});
expect(deps.callGhostTool).toHaveBeenCalledWith({
ghostId: 'cindy-github',
@@ -48,19 +48,50 @@ describe('resolveGithubIssueSubmissionIdentity', () => {
{ isGithubCredentialSaved: () => false },
]) {
const deps = makeDeps(over);
- await expect(resolveGithubIssueSubmissionIdentity(deps)).resolves.toEqual(
- PLATFORM_ISSUE_SUBMISSION_IDENTITY,
- );
+ await expect(resolveGithubIssueSubmissionChoices(deps)).resolves.toEqual({
+ platform: PLATFORM_ISSUE_SUBMISSION_IDENTITY,
+ });
expect(deps.callGhostTool).not.toHaveBeenCalled();
}
});
it('当前 workdir 禁用 cindy-github 时走平台身份且不调用插件', async () => {
const deps = makeDeps({ isGithubGhostDisabledForWorkdir: (workdir) => workdir === '/repo' });
- await expect(resolveGithubIssueSubmissionIdentity(deps, '/repo')).resolves.toEqual(
- PLATFORM_ISSUE_SUBMISSION_IDENTITY,
- );
+ await expect(resolveGithubIssueSubmissionChoices(deps, '/repo')).resolves.toEqual({
+ platform: PLATFORM_ISSUE_SUBMISSION_IDENTITY,
+ });
+ expect(deps.callGhostTool).not.toHaveBeenCalled();
+ });
+
+ it('插件 readiness 读取异常时仍返回平台身份', async () => {
+ const warn = vi.fn();
+ const deps = makeDeps({
+ logger: { warn },
+ isGithubGhostEnabled: () => {
+ throw new Error('plugin registry unavailable');
+ },
+ });
+ await expect(resolveGithubIssueSubmissionChoices(deps)).resolves.toEqual({
+ platform: PLATFORM_ISSUE_SUBMISSION_IDENTITY,
+ });
expect(deps.callGhostTool).not.toHaveBeenCalled();
+ expect(warn).toHaveBeenCalledTimes(1);
+ });
+
+ it('可选身份日志失败时仍返回平台身份', async () => {
+ const deps = makeDeps({
+ logger: {
+ warn: () => {
+ throw new Error('logger unavailable');
+ },
+ },
+ isGithubGhostEnabled: () => {
+ throw new Error('plugin registry unavailable');
+ },
+ });
+ await expect(resolveGithubIssueSubmissionChoices(deps)).resolves.toEqual({
+ platform: PLATFORM_ISSUE_SUBMISSION_IDENTITY,
+ });
});
it('插件运行时不可用时在确认前回退平台身份', async () => {
@@ -71,27 +102,31 @@ describe('resolveGithubIssueSubmissionIdentity', () => {
message: '插件启动失败',
})),
});
- await expect(resolveGithubIssueSubmissionIdentity(deps)).resolves.toEqual(
- PLATFORM_ISSUE_SUBMISSION_IDENTITY,
- );
+ await expect(resolveGithubIssueSubmissionChoices(deps)).resolves.toEqual({
+ platform: PLATFORM_ISSUE_SUBMISSION_IDENTITY,
+ });
});
- it('已保存但失效的 token 返回 AUTH_NOT_READY,不冒充未绑定', async () => {
+ it('已保存但失效的 token 只隐藏用户选项,不阻断平台 Bot', async () => {
for (const message of [
'GitHub token 未配置或已失效',
'GitHub API HTTP 403 Forbidden',
'凭证「github_pat」尚未配置',
]) {
+ const warn = vi.fn();
const deps = makeDeps({
+ logger: { warn },
callGhostTool: vi.fn(async () => ({
ok: false as const,
errorCode: 'INTERNAL',
message,
})),
});
- await expect(resolveGithubIssueSubmissionIdentity(deps)).rejects.toMatchObject({
- issueErrorCode: 'AUTH_NOT_READY',
+ await expect(resolveGithubIssueSubmissionChoices(deps)).resolves.toEqual({
+ platform: PLATFORM_ISSUE_SUBMISSION_IDENTITY,
});
+ expect(warn).toHaveBeenCalledTimes(1);
+ expect(JSON.stringify(warn.mock.calls)).not.toContain(message);
}
});
@@ -103,18 +138,21 @@ describe('resolveGithubIssueSubmissionIdentity', () => {
return { ok: true as const, result: { data: { login: 'octocat' } } };
}),
});
- await expect(resolveGithubIssueSubmissionIdentity(deps)).resolves.toEqual(
- PLATFORM_ISSUE_SUBMISSION_IDENTITY,
- );
+ await expect(resolveGithubIssueSubmissionChoices(deps)).resolves.toEqual({
+ platform: PLATFORM_ISSUE_SUBMISSION_IDENTITY,
+ });
});
- it('get_current_user 成功但缺少 login 时拒绝半残身份', async () => {
+ it('get_current_user 成功但缺少 login 时只隐藏半残身份', async () => {
+ const warn = vi.fn();
const deps = makeDeps({
+ logger: { warn },
callGhostTool: vi.fn(async () => ({ ok: true as const, result: { data: {} } })),
});
- await expect(resolveGithubIssueSubmissionIdentity(deps)).rejects.toMatchObject({
- issueErrorCode: 'SERVER_ERROR',
+ await expect(resolveGithubIssueSubmissionChoices(deps)).resolves.toEqual({
+ platform: PLATFORM_ISSUE_SUBMISSION_IDENTITY,
});
+ expect(warn).toHaveBeenCalledTimes(1);
});
});
diff --git a/apps/desktop/src/main/github-issue/__tests__/issueConfirmBridge.test.ts b/apps/desktop/src/main/github-issue/__tests__/issueConfirmBridge.test.ts
index 68af64e851..36a7e343df 100644
--- a/apps/desktop/src/main/github-issue/__tests__/issueConfirmBridge.test.ts
+++ b/apps/desktop/src/main/github-issue/__tests__/issueConfirmBridge.test.ts
@@ -16,7 +16,13 @@ const ENV = {
osVersion: '25.5.0',
region: 'cn' as const,
};
-const IDENTITY = { kind: 'github-user', login: 'octocat' } as const;
+const PLATFORM_IDENTITY = { kind: 'platform', login: 'cindy-issue' } as const;
+const GITHUB_IDENTITY = { kind: 'github-user', login: 'octocat' } as const;
+const PLATFORM_CHOICES = { platform: PLATFORM_IDENTITY } as const;
+const SUBMISSION_CHOICES = {
+ platform: PLATFORM_IDENTITY,
+ githubUser: GITHUB_IDENTITY,
+} as const;
function lastRequestId(broadcast: ReturnType<typeof vi.fn>): string {
const call = broadcast.mock.calls.findLast(
@@ -37,7 +43,7 @@ describe('IssueConfirmBridge', () => {
it('request → broadcast kind=issue_confirm 的 INTERACTION_REQUEST payload', () => {
const broadcast = vi.fn();
const bridge = new IssueConfirmBridge({ broadcast });
- void bridge.request('sess-1', DRAFT, ENV, IDENTITY);
+ void bridge.request('sess-1', DRAFT, ENV, SUBMISSION_CHOICES);
expect(broadcast).toHaveBeenCalledTimes(1);
const [channel, payload] = broadcast.mock.calls[0];
expect(channel).toBe(MAKER_PUSH.INTERACTION_REQUEST);
@@ -47,7 +53,8 @@ describe('IssueConfirmBridge', () => {
kind: 'issue_confirm',
draft: DRAFT,
env: ENV,
- submissionIdentity: IDENTITY,
+ submissionIdentity: PLATFORM_IDENTITY,
+ githubUserIdentity: GITHUB_IDENTITY,
},
});
expect((payload as { request: { requestId: string } }).request.requestId).toBeTruthy();
@@ -60,13 +67,14 @@ describe('IssueConfirmBridge', () => {
it('resolve 确认 decision → promise settle 为 confirmed,值取卡片当前版', async () => {
const broadcast = vi.fn();
const bridge = new IssueConfirmBridge({ broadcast });
- const promise = bridge.request('sess-1', DRAFT, ENV, IDENTITY);
+ const promise = bridge.request('sess-1', DRAFT, ENV, SUBMISSION_CHOICES);
const requestId = lastRequestId(broadcast);
const hit = bridge.resolve(requestId, {
confirmed: true,
title: ' 用户改过的标题 ',
body: '用户改过的正文',
type: 'feature',
+ submissionIdentity: GITHUB_IDENTITY,
uiLanguage: 'ja',
});
expect(hit).toBe(true);
@@ -75,6 +83,7 @@ describe('IssueConfirmBridge', () => {
title: '用户改过的标题',
body: '用户改过的正文',
type: 'feature',
+ submissionIdentity: GITHUB_IDENTITY,
uiLanguage: 'ja',
});
// 多窗口同会话:resolve 后必须广播 DISMISSED 让其它窗口收掉僵尸卡片。
@@ -90,14 +99,13 @@ describe('IssueConfirmBridge', () => {
const broadcast = vi.fn();
const warn = vi.fn();
const bridge = new IssueConfirmBridge({ broadcast, logger: { warn } });
- const platformIdentity = { kind: 'platform', login: 'cindy-issue' } as const;
- const promise = bridge.request('sess-1', DRAFT, ENV, platformIdentity, '当前昵称');
+ const promise = bridge.request('sess-1', DRAFT, ENV, PLATFORM_CHOICES, '当前昵称');
const requestId = lastRequestId(broadcast);
expect(broadcast).toHaveBeenCalledWith(
MAKER_PUSH.INTERACTION_REQUEST,
expect.objectContaining({
request: expect.objectContaining({
- submissionIdentity: platformIdentity,
+ submissionIdentity: PLATFORM_IDENTITY,
suggestedPublicName: '当前昵称',
}),
}),
@@ -109,11 +117,13 @@ describe('IssueConfirmBridge', () => {
title: DRAFT.title,
body: DRAFT.body,
type: DRAFT.type,
+ submissionIdentity: PLATFORM_IDENTITY,
publicName: ' 匿名 ',
}),
).toBe(true);
await expect(promise).resolves.toMatchObject({
confirmed: true,
+ submissionIdentity: PLATFORM_IDENTITY,
publicName: '匿名',
});
expect(warn).not.toHaveBeenCalled();
@@ -124,13 +134,7 @@ describe('IssueConfirmBridge', () => {
const broadcast = vi.fn();
const warn = vi.fn();
const bridge = new IssueConfirmBridge({ broadcast, logger: { warn } });
- const promise = bridge.request(
- 'sess-1',
- DRAFT,
- ENV,
- { kind: 'platform', login: 'cindy-issue' },
- '当前昵称',
- );
+ const promise = bridge.request('sess-1', DRAFT, ENV, PLATFORM_CHOICES, '当前昵称');
const requestId = lastRequestId(broadcast);
expect(
bridge.resolve(requestId, {
@@ -138,6 +142,7 @@ describe('IssueConfirmBridge', () => {
title: DRAFT.title,
body: DRAFT.body,
type: DRAFT.type,
+ submissionIdentity: PLATFORM_IDENTITY,
publicName,
}),
).toBe(true);
@@ -146,10 +151,50 @@ describe('IssueConfirmBridge', () => {
}
});
+ it('旧 renderer 未回传身份时安全回退到平台默认身份', async () => {
+ const broadcast = vi.fn();
+ const bridge = new IssueConfirmBridge({ broadcast });
+ const promise = bridge.request('sess-1', DRAFT, ENV, SUBMISSION_CHOICES, 'Carol');
+ const requestId = lastRequestId(broadcast);
+ expect(
+ bridge.resolve(requestId, {
+ confirmed: true,
+ title: DRAFT.title,
+ body: DRAFT.body,
+ type: DRAFT.type,
+ publicName: 'Carol',
+ }),
+ ).toBe(true);
+ await expect(promise).resolves.toMatchObject({
+ confirmed: true,
+ submissionIdentity: PLATFORM_IDENTITY,
+ publicName: 'Carol',
+ });
+ });
+
+ it('拒绝 renderer 选择本次未提供的 GitHub 身份', async () => {
+ const broadcast = vi.fn();
+ const warn = vi.fn();
+ const bridge = new IssueConfirmBridge({ broadcast, logger: { warn } });
+ const promise = bridge.request('sess-1', DRAFT, ENV, PLATFORM_CHOICES, 'Carol');
+ const requestId = lastRequestId(broadcast);
+ expect(
+ bridge.resolve(requestId, {
+ confirmed: true,
+ title: DRAFT.title,
+ body: DRAFT.body,
+ type: DRAFT.type,
+ submissionIdentity: GITHUB_IDENTITY,
+ }),
+ ).toBe(true);
+ await expect(promise).resolves.toEqual({ confirmed: false, reason: 'cancelled' });
+ expect(warn).toHaveBeenCalledTimes(1);
+ });
+
it('resolve 取消 decision → cancelled;未知 requestId → 返 false', async () => {
const broadcast = vi.fn();
const bridge = new IssueConfirmBridge({ broadcast });
- const promise = bridge.request('sess-1', DRAFT, ENV, IDENTITY);
+ const promise = bridge.request('sess-1', DRAFT, ENV, PLATFORM_CHOICES);
const requestId = lastRequestId(broadcast);
expect(bridge.resolve('nope', { confirmed: false })).toBe(false);
expect(bridge.resolve(requestId, { confirmed: false })).toBe(true);
@@ -174,7 +219,7 @@ describe('IssueConfirmBridge', () => {
const broadcast = vi.fn();
const warn = vi.fn();
const bridge = new IssueConfirmBridge({ broadcast, logger: { warn } });
- const promise = bridge.request('sess-1', DRAFT, ENV, IDENTITY);
+ const promise = bridge.request('sess-1', DRAFT, ENV, PLATFORM_CHOICES);
const requestId = lastRequestId(broadcast);
expect(bridge.resolve(requestId, { confirmed: true, title: '' })).toBe(true);
await expect(promise).resolves.toEqual({ confirmed: false, reason: 'cancelled' });
@@ -184,7 +229,7 @@ describe('IssueConfirmBridge', () => {
it('超时 → timeout decision + 广播 INTERACTION_DISMISSED', async () => {
const broadcast = vi.fn();
const bridge = new IssueConfirmBridge({ broadcast, timeoutMs: 1000 });
- const promise = bridge.request('sess-1', DRAFT, ENV, IDENTITY);
+ const promise = bridge.request('sess-1', DRAFT, ENV, PLATFORM_CHOICES);
const requestId = lastRequestId(broadcast);
vi.advanceTimersByTime(1001);
await expect(promise).resolves.toEqual({ confirmed: false, reason: 'timeout' });
@@ -199,7 +244,7 @@ describe('IssueConfirmBridge', () => {
it('默认确认超时早于 600 秒 MCP deadline', async () => {
const bridge = new IssueConfirmBridge({ broadcast: vi.fn() });
- const promise = bridge.request('sess-1', DRAFT, ENV, IDENTITY);
+ const promise = bridge.request('sess-1', DRAFT, ENV, PLATFORM_CHOICES);
vi.advanceTimersByTime(9 * 60 * 1000 - 1);
expect(bridge.pendingSnapshots('sess-1')).toHaveLength(1);
@@ -212,8 +257,8 @@ describe('IssueConfirmBridge', () => {
it('cleanupForSession 只清目标会话的 pending,并广播收卡', async () => {
const broadcast = vi.fn();
const bridge = new IssueConfirmBridge({ broadcast });
- const p1 = bridge.request('sess-1', DRAFT, ENV, IDENTITY);
- const p2 = bridge.request('sess-2', DRAFT, ENV, IDENTITY);
+ const p1 = bridge.request('sess-1', DRAFT, ENV, PLATFORM_CHOICES);
+ const p2 = bridge.request('sess-2', DRAFT, ENV, PLATFORM_CHOICES);
bridge.cleanupForSession('sess-1', 'session_aborted');
await expect(p1).resolves.toEqual({ confirmed: false, reason: 'session_aborted' });
expect(bridge.pendingSnapshots('sess-1')).toEqual([]);
@@ -243,7 +288,7 @@ describe('onDesktopOnlyConfirmPending(#926)', () => {
'feishu_bot_ou_1',
{ title: 't', body: 'b', type: 'bug' },
{ appVersion: '0.0.0', platform: 'darwin', arch: 'arm64', osVersion: '1', region: 'cn' },
- { kind: 'platform', login: 'cindy' },
+ { platform: { kind: 'platform', login: 'cindy' } },
);
expect(onPending).toHaveBeenCalledWith('feishu_bot_ou_1');
await p; // 超时收口,不留挂起 promise
@@ -255,7 +300,10 @@ describe('onDesktopOnlyConfirmPending(#926)', () => {
's1',
{ title: 't', body: 'b', type: 'bug' },
{ appVersion: '0.0.0', platform: 'darwin', arch: 'arm64', osVersion: '1', region: 'cn' },
- { kind: 'github-user', login: 'u' },
+ {
+ platform: PLATFORM_IDENTITY,
+ githubUser: { kind: 'github-user', login: 'u' },
+ },
);
expect(decision.confirmed).toBe(false);
});
@@ -276,7 +324,10 @@ describe('onDesktopOnlyConfirmPending 抛错防护(#1059 review)', () => {
's-throw',
{ title: 't', body: 'b', type: 'bug' },
{ appVersion: '0.0.0', platform: 'darwin', arch: 'arm64', osVersion: '1', region: 'cn' },
- { kind: 'github-user', login: 'u' },
+ {
+ platform: PLATFORM_IDENTITY,
+ githubUser: { kind: 'github-user', login: 'u' },
+ },
);
expect(decision.confirmed).toBe(false);
expect(warn).toHaveBeenCalledWith(
diff --git a/apps/desktop/src/main/github-issue/cindyGithubGhostDeps.ts b/apps/desktop/src/main/github-issue/cindyGithubGhostDeps.ts
index e3a5c47451..f16aad8a80 100644
--- a/apps/desktop/src/main/github-issue/cindyGithubGhostDeps.ts
+++ b/apps/desktop/src/main/github-issue/cindyGithubGhostDeps.ts
@@ -11,6 +11,7 @@
import { getGhostManager, getGhostPipeDispatcher } from '../cindy-brain';
import { isGhostDisabledForWorkdir } from '../cindy-brain/ghostWorkdirPrefs.js';
+import { createLogger } from '../logger.js';
import { ghostSecretSaved } from '../secrets/providerSecretStore';
import {
CINDY_GITHUB_GHOST_ID,
@@ -19,6 +20,7 @@ import {
} from './githubUserIssueSubmitter';
let sharedDeps: GithubUserIssueSubmitterDeps | null = null;
+const log = createLogger('github-issue/github-user');
/**
* 共享实例 —— 同一次「我的 Issue」查询里,身份解析与随后的搜索用同一个对象,
@@ -44,5 +46,6 @@ export function buildGithubUserSubmitterDeps(): GithubUserIssueSubmitterDeps {
isGithubGhostDisabledForWorkdir: (workdir) =>
isGhostDisabledForWorkdir(CINDY_GITHUB_GHOST_ID, workdir),
callGhostTool: (request) => getGhostPipeDispatcher().callGhostTool(request),
+ logger: log,
};
}
diff --git a/apps/desktop/src/main/github-issue/githubIssueSubmitService.ts b/apps/desktop/src/main/github-issue/githubIssueSubmitService.ts
index c86b0bc659..12913fb567 100644
--- a/apps/desktop/src/main/github-issue/githubIssueSubmitService.ts
+++ b/apps/desktop/src/main/github-issue/githubIssueSubmitService.ts
@@ -16,10 +16,12 @@ import { CINDY_REGION_CODE } from '../../shared/regionCode.js';
import { normalizeIssuePublicName } from '../../shared/issuePublicName.js';
import type { SubmittedIssueRecord } from '../../shared/myIssues.js';
import { myIssueUrl } from '../../shared/myIssues.js';
+import { redactSensitive } from '../learn-host/redaction';
import type {
IssueConfirmDecision,
IssueDraft,
IssueEnvInfo,
+ IssueSubmissionChoices,
IssueSubmissionIdentity,
} from './issueConfirmBridge';
@@ -31,6 +33,8 @@ export type GithubIssueSubmitResult =
issueUrl: string;
finalTitle: string;
editedByUser: boolean;
+ /** agent 初稿进入确认卡前是否命中过常见敏感信息并被自动替换。 */
+ privacyRedacted: boolean;
}
| {
ok: false;
@@ -70,11 +74,11 @@ export interface GithubIssueSubmitServiceDeps {
sessionId: string,
draft: IssueDraft,
env: IssueEnvInfo,
- submissionIdentity: IssueSubmissionIdentity,
+ submissionChoices: IssueSubmissionChoices,
suggestedPublicName?: string,
) => Promise<IssueConfirmDecision>;
- /** 每次发起确认前现查;已绑定但凭证失效时应抛 AUTH_NOT_READY,不能冒充未绑定。 */
- resolveSubmissionIdentity: (workingDir: string) => Promise<IssueSubmissionIdentity>;
+ /** 平台身份必有;仅当实时验证到可用账号时附加 GitHub 用户身份。 */
+ resolveSubmissionChoices: (workingDir: string) => Promise<IssueSubmissionChoices>;
/** body factory must be evaluated for each network attempt after auth refresh. */
postIssue: (
submissionIdentity: IssueSubmissionIdentity,
@@ -110,22 +114,20 @@ export async function submitGithubIssueWithConfirm(
region: deps.getRegion(),
};
- let submissionIdentity: IssueSubmissionIdentity;
+ let submissionChoices: IssueSubmissionChoices;
try {
- submissionIdentity = await deps.resolveSubmissionIdentity(req.workingDir);
+ submissionChoices = await deps.resolveSubmissionChoices(req.workingDir);
} catch (err) {
return mapSubmitError(err);
}
- const suggestedPublicName =
- submissionIdentity.kind === 'platform'
- ? (normalizeIssuePublicName(deps.getSubmitterName()) ?? undefined)
- : undefined;
+ const suggestedPublicName = normalizeIssuePublicName(deps.getSubmitterName()) ?? undefined;
+ const preparedDraft = redactIssueDraft(req);
const decision = await deps.confirm(
req.sessionId,
- { title: req.title, body: req.body, type: req.type },
+ preparedDraft.draft,
env,
- submissionIdentity,
+ submissionChoices,
suggestedPublicName,
);
@@ -144,6 +146,7 @@ export async function submitGithubIssueWithConfirm(
};
}
+ const submissionIdentity = decision.submissionIdentity ?? submissionChoices.platform;
const confirmedPublicName =
submissionIdentity.kind === 'platform' ? normalizeIssuePublicName(decision.publicName) : null;
if (submissionIdentity.kind === 'platform' && !confirmedPublicName) {
@@ -157,9 +160,9 @@ export async function submitGithubIssueWithConfirm(
// 用户确认版优先 —— agent 传入值在这里被丢弃,代码层保证。
const finalTitle = decision.title.slice(0, SERVER_TITLE_MAX);
const editedByUser =
- decision.title !== req.title ||
- decision.body !== req.body ||
- decision.type !== req.type;
+ decision.title !== preparedDraft.draft.title ||
+ decision.body !== preparedDraft.draft.body ||
+ decision.type !== preparedDraft.draft.type;
const uiLanguage = decision.uiLanguage ?? deps.getFallbackLocale();
const regionCode = CINDY_REGION_CODE[env.region];
@@ -195,12 +198,33 @@ export async function submitGithubIssueWithConfirm(
issueUrl: result.githubIssue.url,
finalTitle,
editedByUser,
+ privacyRedacted: preparedDraft.privacyRedacted,
};
} catch (err) {
return mapSubmitError(err);
}
}
+/**
+ * Agent 可能把用户粘贴的日志、错误和路径直接带进初稿。先过高置信度脱敏,再交给
+ * 用户确认;用户在确认卡里主动编辑的内容视为明确确认,不在这里静默改写。
+ */
+function redactIssueDraft(req: SubmitIssueRequest): {
+ draft: Pick<SubmitIssueRequest, 'title' | 'body' | 'type'>;
+ privacyRedacted: boolean;
+} {
+ const title = redactSensitive(req.title);
+ const body = redactSensitive(req.body);
+ return {
+ draft: {
+ title: title.text.trim(),
+ body: body.text.trim(),
+ type: req.type,
+ },
+ privacyRedacted: title.hitCount > 0 || body.hitCount > 0,
+ };
+}
+
/** 记账是 best-effort:任何异常只吞掉,不影响已经成功的提交结果。 */
function recordSubmission(
deps: GithubIssueSubmitServiceDeps,
diff --git a/apps/desktop/src/main/github-issue/githubUserIssueSubmitter.ts b/apps/desktop/src/main/github-issue/githubUserIssueSubmitter.ts
index 931b43f812..a4d20aff8a 100644
--- a/apps/desktop/src/main/github-issue/githubUserIssueSubmitter.ts
+++ b/apps/desktop/src/main/github-issue/githubUserIssueSubmitter.ts
@@ -6,7 +6,7 @@
*/
import type { GithubIssuePostBody, GithubIssuePostResponse } from './githubIssueSubmitService';
-import type { IssueSubmissionIdentity } from './issueConfirmBridge';
+import type { IssueSubmissionChoices, IssueSubmissionIdentity } from './issueConfirmBridge';
export const CINDY_GITHUB_GHOST_ID = 'cindy-github';
export const CINDY_GITHUB_SECRET_KEY = 'github_pat';
@@ -30,6 +30,7 @@ export interface GithubUserIssueSubmitterDeps {
args: Record<string, unknown>;
}) => Promise<GhostToolCallResult>;
identityProbeTimeoutMs?: number;
+ logger?: { warn: (message: string, meta?: Record<string, unknown>) => void };
}
interface IssueSubmissionError extends Error {
@@ -83,35 +84,55 @@ export function callCindyGithubOperation(
return callGithubOperation(deps, name, args, options);
}
-/** 已装、启用且保存了凭证时验证 token;其余场景明确选择平台代提交。 */
-export async function resolveGithubIssueSubmissionIdentity(
+/**
+ * 平台 Bot 始终作为默认身份返回。GitHub 插件只负责提供一个可选增强:当前配置
+ * 完整且身份验证成功时追加本人账号;任何插件、凭证、网络或响应异常都只隐藏
+ * 这个可选项,绝不能阻断官方反馈入口。
+ */
+export async function resolveGithubIssueSubmissionChoices(
deps: GithubUserIssueSubmitterDeps,
workdir?: string | null,
-): Promise<IssueSubmissionIdentity> {
- if (!isCindyGithubGhostUsable(deps, workdir)) {
- return PLATFORM_ISSUE_SUBMISSION_IDENTITY;
+): Promise<IssueSubmissionChoices> {
+ const platformOnly: IssueSubmissionChoices = {
+ platform: PLATFORM_ISSUE_SUBMISSION_IDENTITY,
+ };
+ try {
+ if (!isCindyGithubGhostUsable(deps, workdir)) {
+ return platformOnly;
+ }
+ } catch (err) {
+ logOptionalIdentityUnavailable(deps, 'readiness check failed', err);
+ return platformOnly;
}
let operation: { ok: true; data: unknown } | GithubOperationFailure;
try {
- operation = await callGithubOperation(deps, 'get_current_user', {}, {
- timeoutMs: deps.identityProbeTimeoutMs ?? 5000,
- });
+ operation = await callGithubOperation(
+ deps,
+ 'get_current_user',
+ {},
+ {
+ timeoutMs: deps.identityProbeTimeoutMs ?? 5000,
+ },
+ );
} catch (err) {
- throw malformedResponseError('读取 GitHub 用户身份失败', err);
+ logOptionalIdentityUnavailable(deps, 'identity probe failed', err);
+ return platformOnly;
}
if (!operation.ok) {
- if (isGithubAuthFailure(operation.message)) {
- throw submissionError(
- 'AUTH_NOT_READY',
- `已绑定的 GitHub 身份不可用,issue 未提交。请到「插件」→「Cindy GitHub」重新配置并测试连接:${operation.message}`,
- );
- }
- // 身份尚未选定,插件运行时不可用时可继续走既有平台路径;确认卡会如实展示。
- return PLATFORM_ISSUE_SUBMISSION_IDENTITY;
+ logOptionalIdentityUnavailable(deps, 'identity probe unavailable', operation);
+ return platformOnly;
}
- return { kind: 'github-user', login: parseGithubLogin(operation.data) };
+ try {
+ return {
+ ...platformOnly,
+ githubUser: { kind: 'github-user', login: parseGithubLogin(operation.data) },
+ };
+ } catch (err) {
+ logOptionalIdentityUnavailable(deps, 'identity response invalid', err);
+ return platformOnly;
+ }
}
/** 按确认过的用户身份创建 issue;任何失败都原样报错,绝不降级到平台身份。 */
@@ -222,7 +243,9 @@ function buildDirectIssueBody(body: GithubIssuePostBody): string {
}
function isGithubAuthFailure(message: string): boolean {
- return /token 未配置|token.*失效|凭证.*尚未配置|HTTP 401|HTTP 403|没有权限.*token scope|token scope 不够/i.test(message);
+ return /token 未配置|token.*失效|凭证.*尚未配置|HTTP 401|HTTP 403|没有权限.*token scope|token scope 不够/i.test(
+ message,
+ );
}
function isNetworkFailure(message: string): boolean {
@@ -236,6 +259,28 @@ function malformedResponseError(context: string, err: unknown): IssueSubmissionE
);
}
+function logOptionalIdentityUnavailable(
+ deps: GithubUserIssueSubmitterDeps,
+ reason: string,
+ detail: unknown,
+): void {
+ if (!deps.logger) return;
+ const meta: Record<string, unknown> = { reason };
+ if (detail instanceof Error) {
+ meta.errorName = detail.name;
+ } else if (isRecord(detail) && typeof detail.errorCode === 'string') {
+ meta.errorCode = detail.errorCode;
+ }
+ try {
+ deps.logger.warn(
+ 'GitHub user identity unavailable; platform issue submission remains available',
+ meta,
+ );
+ } catch {
+ // 可选身份的诊断日志也不能反过来阻断平台 Bot 提交。
+ }
+}
+
function submissionError(
issueErrorCode: IssueSubmissionError['issueErrorCode'],
message: string,
diff --git a/apps/desktop/src/main/github-issue/index.ts b/apps/desktop/src/main/github-issue/index.ts
index b65bd63729..c9843d404f 100644
--- a/apps/desktop/src/main/github-issue/index.ts
+++ b/apps/desktop/src/main/github-issue/index.ts
@@ -28,7 +28,7 @@ import { invalidateMyIssuesCache } from './myIssuesRuntime.js';
import { recordSubmittedIssue } from './submittedIssueLedger.js';
import {
postGithubIssueAsUser,
- resolveGithubIssueSubmissionIdentity,
+ resolveGithubIssueSubmissionChoices,
type GithubUserIssueSubmitterDeps,
} from './githubUserIssueSubmitter';
@@ -67,10 +67,10 @@ export async function submitGithubIssueForSession(
const submitScope = activeOwnerScopeKey();
return submitGithubIssueWithConfirm(
{
- confirm: (sessionId, draft, env, submissionIdentity, suggestedPublicName) =>
- bridge.request(sessionId, draft, env, submissionIdentity, suggestedPublicName),
- resolveSubmissionIdentity: (workdir) =>
- resolveGithubIssueSubmissionIdentity(githubUserSubmitterDeps, workdir),
+ confirm: (sessionId, draft, env, submissionChoices, suggestedPublicName) =>
+ bridge.request(sessionId, draft, env, submissionChoices, suggestedPublicName),
+ resolveSubmissionChoices: (workdir) =>
+ resolveGithubIssueSubmissionChoices(githubUserSubmitterDeps, workdir),
postIssue: (submissionIdentity, bodyFactory) => {
if (submissionIdentity.kind === 'github-user') {
return postGithubIssueAsUser(githubUserSubmitterDeps, submissionIdentity, bodyFactory());
diff --git a/apps/desktop/src/main/github-issue/issueConfirmBridge.ts b/apps/desktop/src/main/github-issue/issueConfirmBridge.ts
index 6aab41a255..231d12fcd3 100644
--- a/apps/desktop/src/main/github-issue/issueConfirmBridge.ts
+++ b/apps/desktop/src/main/github-issue/issueConfirmBridge.ts
@@ -48,6 +48,12 @@ export interface IssueEnvInfo {
export type IssueSubmissionIdentity =
{ kind: 'github-user'; login: string } | { kind: 'platform'; login: string };
+/** 平台 Bot 永远存在;验证到可用 GitHub 账号时才追加本人身份选项。 */
+export interface IssueSubmissionChoices {
+ platform: Extract<IssueSubmissionIdentity, { kind: 'platform' }>;
+ githubUser?: Extract<IssueSubmissionIdentity, { kind: 'github-user' }>;
+}
+
export type IssueConfirmDecision =
| {
confirmed: true;
@@ -55,6 +61,8 @@ export type IssueConfirmDecision =
title: string;
body: string;
type: 'bug' | 'feature';
+ /** 用户在确认卡片中明确选择的提交身份;旧 renderer 缺失时按平台默认处理。 */
+ submissionIdentity?: IssueSubmissionIdentity;
/** 平台代发时由用户确认的公开署名;GitHub 用户直发时不存在。 */
publicName?: string;
/** renderer 当前界面语言(i18n.language);main 侧 OS locale 仅作 fallback。 */
@@ -71,7 +79,10 @@ export interface IssueConfirmInteractionSnapshot {
requestId: string;
draft: IssueDraft;
env: IssueEnvInfo;
- submissionIdentity: IssueSubmissionIdentity;
+ /** 默认提交身份;保留字段名以兼容只认识单身份的旧 renderer。 */
+ submissionIdentity: Extract<IssueSubmissionIdentity, { kind: 'platform' }>;
+ /** 仅当当前已验证到可用 GitHub 账号时存在。 */
+ githubUserIdentity?: Extract<IssueSubmissionIdentity, { kind: 'github-user' }>;
suggestedPublicName?: string;
}
@@ -91,7 +102,7 @@ export interface IssueConfirmBridgeDeps {
interface PendingConfirmEntry {
sessionId: string;
request: IssueConfirmInteractionSnapshot;
- requiresPublicName: boolean;
+ submissionChoices: IssueSubmissionChoices;
resolve: (decision: IssueConfirmDecision) => void;
timeoutId: ReturnType<typeof setTimeout>;
}
@@ -106,7 +117,7 @@ export class IssueConfirmBridge {
sessionId: string,
draft: IssueDraft,
env: IssueEnvInfo,
- submissionIdentity: IssueSubmissionIdentity,
+ submissionChoices: IssueSubmissionChoices,
suggestedPublicName?: string,
): Promise<IssueConfirmDecision> {
const requestId = randomUUID();
@@ -115,7 +126,8 @@ export class IssueConfirmBridge {
requestId,
draft,
env,
- submissionIdentity,
+ submissionIdentity: submissionChoices.platform,
+ ...(submissionChoices.githubUser ? { githubUserIdentity: submissionChoices.githubUser } : {}),
suggestedPublicName,
};
return new Promise<IssueConfirmDecision>((resolve) => {
@@ -126,7 +138,7 @@ export class IssueConfirmBridge {
this.pending.set(requestId, {
sessionId,
request,
- requiresPublicName: submissionIdentity.kind === 'platform',
+ submissionChoices,
resolve,
timeoutId,
});
@@ -164,7 +176,7 @@ export class IssueConfirmBridge {
resolve(requestId: string, rawDecision: unknown): boolean {
const entry = this.pending.get(requestId);
if (!entry) return false;
- let decision = parseDecision(rawDecision, entry.requiresPublicName);
+ let decision = parseDecision(rawDecision, entry.submissionChoices);
if (!decision) {
// shape 非法按取消兜底,避免 tool handler 永久挂起。
this.deps.logger?.warn('issue-confirm: invalid decision shape, fallback to cancelled', {
@@ -221,7 +233,10 @@ export class IssueConfirmBridge {
}
}
-function parseDecision(raw: unknown, requiresPublicName: boolean): IssueConfirmDecision | null {
+function parseDecision(
+ raw: unknown,
+ submissionChoices: IssueSubmissionChoices,
+): IssueConfirmDecision | null {
if (!raw || typeof raw !== 'object') return null;
const obj = raw as Record<string, unknown>;
if (obj.confirmed === false) {
@@ -235,16 +250,44 @@ function parseDecision(raw: unknown, requiresPublicName: boolean): IssueConfirmD
obj.body.trim().length > 0 &&
(obj.type === 'bug' || obj.type === 'feature')
) {
- const publicName = requiresPublicName ? normalizeIssuePublicName(obj.publicName) : undefined;
- if (requiresPublicName && !publicName) return null;
+ const submissionIdentity = parseSelectedIdentity(obj.submissionIdentity, submissionChoices);
+ if (!submissionIdentity) return null;
+ const publicName =
+ submissionIdentity.kind === 'platform' ? normalizeIssuePublicName(obj.publicName) : undefined;
+ if (submissionIdentity.kind === 'platform' && !publicName) return null;
return {
confirmed: true,
title: obj.title.trim(),
body: obj.body.trim(),
type: obj.type,
+ submissionIdentity,
...(publicName ? { publicName } : {}),
uiLanguage: typeof obj.uiLanguage === 'string' ? obj.uiLanguage : undefined,
};
}
return null;
}
+
+/**
+ * Renderer 只能选择 Main 在本次确认请求里提供的身份。旧 renderer 不回传该字段时
+ * 继续落到平台默认值,保证升级中途的 pending 卡片仍可安全提交。
+ */
+function parseSelectedIdentity(
+ raw: unknown,
+ choices: IssueSubmissionChoices,
+): IssueSubmissionIdentity | null {
+ if (raw === undefined) return choices.platform;
+ if (!raw || typeof raw !== 'object') return null;
+ const identity = raw as Record<string, unknown>;
+ if (identity.kind === 'platform' && identity.login === choices.platform.login) {
+ return choices.platform;
+ }
+ if (
+ identity.kind === 'github-user' &&
+ choices.githubUser &&
+ identity.login === choices.githubUser.login
+ ) {
+ return choices.githubUser;
+ }
+ return null;
+}
diff --git a/apps/desktop/src/main/maker-ipc/helpKnowledge.generated.ts b/apps/desktop/src/main/maker-ipc/helpKnowledge.generated.ts
index 746aba03cf..cd8839bcd2 100644
--- a/apps/desktop/src/main/maker-ipc/helpKnowledge.generated.ts
+++ b/apps/desktop/src/main/maker-ipc/helpKnowledge.generated.ts
@@ -34,13 +34,13 @@ export const HELP_KNOWLEDGE: HelpKnowledgeDoc[] = [
id: "commands",
title: "Slash commands",
summary: "Type \"/\" in the composer to open a palette merging your skills, built-in app commands, and the agent's own commands.",
- content: "Type `/` at the start of the composer to open the command palette.\n\n**What's in the palette (priority order on collisions):**\n\n1. **Your installed skills** (highest priority) — anything in your global or project skills directory (see the Skills topic).\n2. **Built-in app commands** — `/help` (show available commands), `/clear` (clear the current session context — resets the conversation in place without creating a new session), `/cmd` (run a shell command in the working directory), `/issue` (file an issue), `/goal` (start a goal-driven run), `/learn`, `/workflows`, and `/jump-session`.\n3. **The agent's own commands** — e.g. `/compact`, `/agents`, `/memory` (the exact list depends on the agent; Claude Code and Codex each contribute their own).\n\n**Using the palette:**\n\n- Start typing to filter. Matching is **contains-based** (case-insensitive substring matching on the command name) — not fuzzy.\n- Up to 25 matches shown at a time.\n- **↑ / ↓** move focus, **Enter** runs the focused command, **Esc** closes the palette.\n\n**Notes:**\n\n- If a name collides across sources (same command in a skill and in a built-in), the higher-priority source wins; the lower-priority one is silently skipped (logged as a warning).\n- Most built-in app commands run inside the desktop app (a few, like `/workflows` and `/jump-session`, are handled directly in the UI); agent commands are sent as prompt prefixes to the agent.",
+ content: "Type `/` at the start of the composer to open the command palette.\n\n**What's in the palette (priority order on collisions):**\n\n1. **Your installed skills** (highest priority) — anything in your global or project skills directory (see the Skills topic).\n2. **Built-in app commands** — `/help` (show available commands), `/clear` (clear the current session context — resets the conversation in place without creating a new session), `/cmd` (run a shell command in the working directory), `/issue` (file an issue), `/goal` (start a goal-driven run), `/learn`, `/workflows`, and `/jump-session`.\n3. **The agent's own commands** — e.g. `/compact`, `/agents`, `/memory` (the exact list depends on the agent; Claude Code and Codex each contribute their own).\n\n`/issue` does not require a GitHub plugin or GitHub account. The confirmation card uses Cindy's official bot by default; if a working account is already configured under **Plugins > Cindy GitHub**, that account appears as an optional submission identity.\n\nBefore submitting, Cindy helps clarify missing details so the issue is actionable. For bugs, it can collect reproduction steps and user-approved, redacted diagnostic summaries; the confirmation card always shows the final public content. After creation, Cindy returns the issue link and can help interested users reproduce or fix the problem from source because Cindy is open source.\n\n**Using the palette:**\n\n- Start typing to filter. Matching is **contains-based** (case-insensitive substring matching on the command name) — not fuzzy.\n- Up to 25 matches shown at a time.\n- **↑ / ↓** move focus, **Enter** runs the focused command, **Esc** closes the palette.\n\n**Notes:**\n\n- If a name collides across sources (same command in a skill and in a built-in), the higher-priority source wins; the lower-priority one is silently skipped (logged as a warning).\n- Most built-in app commands run inside the desktop app (a few, like `/workflows` and `/jump-session`, are handled directly in the UI); agent commands are sent as prompt prefixes to the agent.",
},
{
id: "connections",
title: "Connecting external accounts",
summary: "External accounts (Google, Jira / Confluence, GitHub, GitLab) are connected on their plugin detail pages under Plugins; Slack and Telegram are bound under Settings > IM bots; Codex sign-in lives in Settings > Model Providers.",
- content: "External account connections have moved out of the old \"Third-Party Platforms\" section — each integration now lives on its own plugin detail page under **Plugins**, and the plugin's tools use the account you connect there.\n\n**Where to connect what:**\n\n- **Slack** — bound with a single toggle under **Settings > IM bots** (the \"Cindy\" tab). One browser sign-in covers both directions: the Slack channel bot that receives tasks, and the agent Slack tools (search / read / post). If Slack tools don't work on an older binding, toggle it off and on once to re-authorize.\n- **Telegram** — under **Settings > IM bots** (the \"Cindy\" tab), turn on Telegram and choose **Link Telegram**. Open the one-time link, start the official Cindy bot, and complete confirmation if prompted. The same card lets you cancel, retry, open the bot, add it to a group, or unlink; no personal bot token is required.\n- **Google** (Gmail / Calendar / Drive / Sheets) — handled by the Filo Google plugin (Plugins > Filo Google).\n- **GitHub** — handled by the Cindy GitHub plugin (Plugins > Cindy GitHub; existing PAT connections are migrated automatically).\n- **GitLab** — handled by the Cindy GitLab plugin (Plugins > Cindy GitLab; existing PAT connections are migrated automatically).\n- **Codex** — sign in under Settings > Model Providers (separate from the Codex CLI binary the app ships with).\n- **FeiShu** — bot only (App ID / Secret under Settings > IM bots; see the FeiShu bot topic). FeiShu is no longer a sign-in method for Cindy itself.\n- **Cindy AI** — Settings > Model Providers. Web-search keys are configured on the matching plugin detail page (Cindy Web Search).\n\n**Managing connections:**\n\n- Each plugin detail page shows the connected accounts (with status) and lets you reconnect, disconnect, or switch the default account.\n- Disconnect removes the local token only; you may also want to revoke access on the provider's side.\n- A connection error usually means the token expired or was revoked on the provider's side; reconnect to refresh.",
+ content: "External account connections have moved out of the old \"Third-Party Platforms\" section — each integration now lives on its own plugin detail page under **Plugins**, and the plugin's tools use the account you connect there.\n\n**Where to connect what:**\n\n- **Slack** — bound with a single toggle under **Settings > IM bots** (the \"Cindy\" tab). One browser sign-in covers both directions: the Slack channel bot that receives tasks, and the agent Slack tools (search / read / post). If Slack tools don't work on an older binding, toggle it off and on once to re-authorize.\n- **Telegram** — under **Settings > IM bots** (the \"Cindy\" tab), turn on Telegram and choose **Link Telegram**. Open the one-time link, start the official Cindy bot, and complete confirmation if prompted. The same card lets you cancel, retry, open the bot, add it to a group, or unlink; no personal bot token is required.\n- **Google** (Gmail / Calendar / Drive / Sheets) — handled by the Filo Google plugin (Plugins > Filo Google).\n- **GitHub** — handled by the Cindy GitHub plugin (Plugins > Cindy GitHub; existing PAT connections are migrated automatically). This connection is optional for `/issue`: feedback uses Cindy's official bot by default, and a working GitHub connection only adds the option to submit as yourself.\n- **GitLab** — handled by the Cindy GitLab plugin (Plugins > Cindy GitLab; existing PAT connections are migrated automatically).\n- **Codex** — sign in under Settings > Model Providers (separate from the Codex CLI binary the app ships with).\n- **FeiShu** — bot only (App ID / Secret under Settings > IM bots; see the FeiShu bot topic). FeiShu is no longer a sign-in method for Cindy itself.\n- **Cindy AI** — Settings > Model Providers. Web-search keys are configured on the matching plugin detail page (Cindy Web Search).\n\n**Managing connections:**\n\n- Each plugin detail page shows the connected accounts (with status) and lets you reconnect, disconnect, or switch the default account.\n- Disconnect removes the local token only; you may also want to revoke access on the provider's side.\n- A connection error usually means the token expired or was revoked on the provider's side; reconnect to refresh.",
},
{
id: "feishu-bot",
diff --git a/apps/desktop/src/main/mcp-integrations/__tests__/codexHttpBridge.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/codexHttpBridge.test.ts
index 7dbba5fb5a..130c218949 100644
--- a/apps/desktop/src/main/mcp-integrations/__tests__/codexHttpBridge.test.ts
+++ b/apps/desktop/src/main/mcp-integrations/__tests__/codexHttpBridge.test.ts
@@ -340,6 +340,21 @@ describe('codexHttpBridge', () => {
result: { content: [{ type: 'text', text: 'instance-current' }] },
});
+ const activeWithoutThreadId = await fetch(activeUrl, {
+ method: 'POST',
+ headers: { ...headers, 'mcp-session-id': mcpSessionId ?? '' },
+ body: JSON.stringify({
+ jsonrpc: '2.0',
+ id: 6,
+ method: 'tools/call',
+ params: { name: 'current_session', arguments: {} },
+ }),
+ });
+ expect(activeWithoutThreadId.status).toBe(200);
+ expect(await readRpcResponse(activeWithoutThreadId)).toMatchObject({
+ result: { content: [{ type: 'text', text: 'session-instance' }] },
+ });
+
const stale = await call(
withMcpRouteIdentity(bridge.url('cindy_test'), {
sessionInstanceId: 'instance-stale',
@@ -350,6 +365,24 @@ describe('codexHttpBridge', () => {
expect(stale.status).toBe(401);
await stale.text();
+ const staleWithoutThreadId = await fetch(
+ withMcpRouteIdentity(bridge.url('cindy_test'), {
+ sessionInstanceId: 'instance-stale',
+ }),
+ {
+ method: 'POST',
+ headers: { ...headers, 'mcp-session-id': mcpSessionId ?? '' },
+ body: JSON.stringify({
+ jsonrpc: '2.0',
+ id: 7,
+ method: 'tools/call',
+ params: { name: 'current_session', arguments: {} },
+ }),
+ },
+ );
+ expect(staleWithoutThreadId.status).toBe(401);
+ await staleWithoutThreadId.text();
+
// An old unbound URL keeps ordinary session-aware tools compatible, but
// deliberately removes the capability needed for Full Access auto-grants.
const legacySession = await call(bridge.url('cindy_test'), 4, 'current_session');
@@ -661,6 +694,152 @@ describe('codexHttpBridge', () => {
});
});
+ it('accepts batched thread aliases only when their full execution contexts match', async () => {
+ bridge = await startCodexHttpBridge({
+ serverFactories: { lizi_test: createTestServer },
+ pluginIdByServerName: { lizi_test: 'ssh' },
+ logger: noopLogger(),
+ });
+ const first = {
+ agentKind: 'codex',
+ sessionId: 'session-alias',
+ sessionInstanceId: 'instance-alias',
+ workingDir: '/repo',
+ vendorOptions: {
+ [CODEX_DISABLED_BUILTIN_PLUGIN_IDS_KEY]: ['browser'],
+ orcaRole: 'lead',
+ },
+ };
+ bridge.registerThreadContext('thread-alias-one', first);
+ bridge.registerThreadContext('thread-alias-two', {
+ ...first,
+ vendorOptions: {
+ [CODEX_DISABLED_BUILTIN_PLUGIN_IDS_KEY]: ['browser'],
+ orcaRole: 'lead',
+ },
+ });
+
+ const baseHeaders = {
+ authorization: `Bearer ${bridge.token}`,
+ accept: 'application/json, text/event-stream',
+ 'content-type': 'application/json',
+ };
+ const initResp = await fetch(bridge.url('lizi_test'), {
+ method: 'POST',
+ headers: baseHeaders,
+ body: JSON.stringify({
+ jsonrpc: '2.0',
+ id: 1,
+ method: 'initialize',
+ params: {
+ protocolVersion: '2024-11-05',
+ capabilities: {},
+ clientInfo: { name: 'test-client', version: '1.0.0' },
+ },
+ }),
+ });
+ const mcpSessionId = initResp.headers.get('mcp-session-id');
+ await initResp.text();
+
+ const callResp = await fetch(bridge.url('lizi_test'), {
+ method: 'POST',
+ headers: { ...baseHeaders, 'mcp-session-id': mcpSessionId ?? '' },
+ body: JSON.stringify(
+ ['thread-alias-one', 'thread-alias-two'].map((threadId, index) => ({
+ jsonrpc: '2.0',
+ id: index + 2,
+ method: 'tools/call',
+ params: {
+ name: 'current_session',
+ arguments: {},
+ _meta: { threadId },
+ },
+ })),
+ ),
+ });
+
+ expect(callResp.status).toBe(200);
+ const results = (await readAllRpcResponses(callResp)) as Array<{
+ id?: number;
+ result?: { content?: Array<{ text?: string }> };
+ }>;
+ expect(results).toHaveLength(2);
+ for (const entry of results) {
+ expect(entry.result?.content?.[0]?.text).toBe('session-alias');
+ }
+ });
+
+ it('fail-closes batched aliases when their tool policies differ', async () => {
+ bridge = await startCodexHttpBridge({
+ serverFactories: { lizi_test: createTestServer },
+ pluginIdByServerName: { lizi_test: 'ssh' },
+ logger: noopLogger(),
+ });
+ const baseContext = {
+ agentKind: 'codex',
+ sessionId: 'session-alias',
+ sessionInstanceId: 'instance-alias',
+ workingDir: '/repo',
+ };
+ bridge.registerThreadContext('thread-policy-one', {
+ ...baseContext,
+ vendorOptions: { [CODEX_DISABLED_BUILTIN_PLUGIN_IDS_KEY]: ['browser'] },
+ });
+ bridge.registerThreadContext('thread-policy-two', {
+ ...baseContext,
+ vendorOptions: { [CODEX_DISABLED_BUILTIN_PLUGIN_IDS_KEY]: ['android'] },
+ });
+
+ const baseHeaders = {
+ authorization: `Bearer ${bridge.token}`,
+ accept: 'application/json, text/event-stream',
+ 'content-type': 'application/json',
+ };
+ const initResp = await fetch(bridge.url('lizi_test'), {
+ method: 'POST',
+ headers: baseHeaders,
+ body: JSON.stringify({
+ jsonrpc: '2.0',
+ id: 1,
+ method: 'initialize',
+ params: {
+ protocolVersion: '2024-11-05',
+ capabilities: {},
+ clientInfo: { name: 'test-client', version: '1.0.0' },
+ },
+ }),
+ });
+ const mcpSessionId = initResp.headers.get('mcp-session-id');
+ await initResp.text();
+
+ const callResp = await fetch(bridge.url('lizi_test'), {
+ method: 'POST',
+ headers: { ...baseHeaders, 'mcp-session-id': mcpSessionId ?? '' },
+ body: JSON.stringify(
+ ['thread-policy-one', 'thread-policy-two'].map((threadId, index) => ({
+ jsonrpc: '2.0',
+ id: index + 2,
+ method: 'tools/call',
+ params: {
+ name: 'current_session',
+ arguments: {},
+ _meta: { threadId },
+ },
+ })),
+ ),
+ });
+
+ expect(callResp.status).toBe(200);
+ const results = (await readAllRpcResponses(callResp)) as Array<{
+ result?: { isError?: boolean; content?: Array<{ text?: string }> };
+ }>;
+ expect(results).toHaveLength(2);
+ for (const entry of results) {
+ expect(entry.result?.isError).toBe(true);
+ expect(entry.result?.content?.[0]?.text).toMatch(/more than one session/);
+ }
+ });
+
it('fail-closes a batch whose tool calls name two different threads', async () => {
// Two registered+enabled threads coalesced into one batch: the per-call
// policy checks pass, and extractCodexThreadId rightly refuses to pick a
@@ -1068,6 +1247,7 @@ describe('codexHttpBridge', () => {
bridge.registerThreadContext('thread-disabled', {
agentKind: 'codex',
sessionId: 'session-disabled',
+ sessionInstanceId: 'instance-disabled',
workingDir: '/repo',
vendorOptions: {
[CODEX_DISABLED_BUILTIN_PLUGIN_IDS_KEY]: ['ssh'],
@@ -1079,7 +1259,10 @@ describe('codexHttpBridge', () => {
accept: 'application/json, text/event-stream',
'content-type': 'application/json',
};
- const initResp = await fetch(bridge.url('lizi_test'), {
+ const sessionUrl = withMcpRouteIdentity(bridge.url('lizi_test'), {
+ sessionInstanceId: 'instance-disabled',
+ });
+ const initResp = await fetch(sessionUrl, {
method: 'POST',
headers: baseHeaders,
body: JSON.stringify({
@@ -1097,7 +1280,7 @@ describe('codexHttpBridge', () => {
expect(mcpSessionId).toBeTruthy();
await initResp.text();
- const callResp = await fetch(bridge.url('lizi_test'), {
+ const callResp = await fetch(sessionUrl, {
method: 'POST',
headers: { ...baseHeaders, 'mcp-session-id': mcpSessionId ?? '' },
body: JSON.stringify({
@@ -1119,6 +1302,24 @@ describe('codexHttpBridge', () => {
content: [{ type: 'text', text: expect.stringContaining('ssh') }],
},
});
+
+ const withoutThreadId = await fetch(sessionUrl, {
+ method: 'POST',
+ headers: { ...baseHeaders, 'mcp-session-id': mcpSessionId ?? '' },
+ body: JSON.stringify({
+ jsonrpc: '2.0',
+ id: 3,
+ method: 'tools/call',
+ params: { name: 'current_session', arguments: {} },
+ }),
+ });
+ expect(withoutThreadId.status).toBe(200);
+ expect(await readRpcResponse(withoutThreadId)).toMatchObject({
+ result: {
+ isError: true,
+ content: [{ type: 'text', text: expect.stringContaining('ssh') }],
+ },
+ });
});
it.each([
@@ -1173,7 +1374,7 @@ describe('codexHttpBridge', () => {
expect(await readRpcResponse(callResp)).toMatchObject({
result: {
isError: true,
- content: [{ type: 'text', text: expect.stringContaining('could not verify') }],
+ content: [{ type: 'text', text: expect.stringContaining('verified Cindy session') }],
},
});
});
diff --git a/apps/desktop/src/main/mcp-integrations/__tests__/codexMcpThreadContextStore.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/codexMcpThreadContextStore.test.ts
index 63e0081d61..89655c415e 100644
--- a/apps/desktop/src/main/mcp-integrations/__tests__/codexMcpThreadContextStore.test.ts
+++ b/apps/desktop/src/main/mcp-integrations/__tests__/codexMcpThreadContextStore.test.ts
@@ -36,6 +36,54 @@ describe('createCodexMcpThreadContextStore', () => {
expect(store.getContextForThreadId('thread-1')).toBeUndefined();
});
+ it('resolves cloned contexts for one host-owned session instance', () => {
+ const store = createCodexMcpThreadContextStore();
+ const first = {
+ ...ctx('session-1', { orcaRole: 'lead', pluginPolicy: { disabled: ['browser'] } }),
+ sessionInstanceId: 'instance-1',
+ };
+ const alias = {
+ ...first,
+ vendorOptions: { orcaRole: 'lead', pluginPolicy: { disabled: ['browser'] } },
+ };
+
+ store.registerThreadContext('thread-1', first);
+ expect(store.getContextForSessionInstanceId('instance-1')).toBe(first);
+ expect(store.getContextForSessionInstanceId('unknown')).toBeUndefined();
+
+ store.registerThreadContext('thread-2', alias);
+ expect(store.getContextForSessionInstanceId('instance-1')).toBe(first);
+ });
+
+ it('fail-closes aliases whose vendor options differ', () => {
+ const store = createCodexMcpThreadContextStore();
+ const first = {
+ ...ctx('session-1', { pluginPolicy: { disabled: ['browser'] } }),
+ sessionInstanceId: 'instance-1',
+ };
+ const differentPolicy = {
+ ...first,
+ vendorOptions: { pluginPolicy: { disabled: ['ssh'] } },
+ };
+
+ store.registerThreadContext('thread-1', first);
+ store.registerThreadContext('thread-2', differentPolicy);
+
+ expect(store.getContextForSessionInstanceId('instance-1')).toBeUndefined();
+ });
+
+ it('fail-closes duplicate claims with different stable identity', () => {
+ const store = createCodexMcpThreadContextStore();
+ const first = { ...ctx('session-1'), sessionInstanceId: 'instance-1' };
+ const duplicate = { ...ctx('session-2'), sessionInstanceId: 'instance-1' };
+
+ store.registerThreadContext('thread-1', first);
+ store.registerThreadContext('thread-2', duplicate);
+ expect(store.getContextForSessionInstanceId('instance-1')).toBeUndefined();
+ store.unregisterThreadContext('thread-2');
+ expect(store.getContextForSessionInstanceId('instance-1')).toBe(first);
+ });
+
it('ignores a stale unregister after the same thread id is rebound to a new session instance', () => {
const store = createCodexMcpThreadContextStore();
const oldContext = { ...ctx('session-1'), sessionInstanceId: 'instance-old' };
diff --git a/apps/desktop/src/main/mcp-integrations/__tests__/piEnvironment.test.ts b/apps/desktop/src/main/mcp-integrations/__tests__/piEnvironment.test.ts
index 137bb6cf87..23efe69c3c 100644
--- a/apps/desktop/src/main/mcp-integrations/__tests__/piEnvironment.test.ts
+++ b/apps/desktop/src/main/mcp-integrations/__tests__/piEnvironment.test.ts
@@ -575,7 +575,7 @@ describe('piEnvironment per-session identity', () => {
expect(callResp.status).toBe(200);
const result = await readRpcText(callResp) as { result?: { isError?: boolean; content?: { text?: string }[] } };
expect(result.result?.isError).toBe(true);
- expect(result.result?.content?.[0]?.text).toContain('could not verify this session');
+ expect(result.result?.content?.[0]?.text).toContain('verified Cindy session');
});
it('registers the worker bridge before the Pi session role is available', async () => {
diff --git a/apps/desktop/src/main/mcp-integrations/codexHttpBridge.ts b/apps/desktop/src/main/mcp-integrations/codexHttpBridge.ts
index 82fe6cbdbd..020ca823b8 100644
--- a/apps/desktop/src/main/mcp-integrations/codexHttpBridge.ts
+++ b/apps/desktop/src/main/mcp-integrations/codexHttpBridge.ts
@@ -24,7 +24,10 @@ import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js';
import { runWithLiziMcpSessionContext, type LiziMcpSessionContext } from '@cindy/mcps';
import type { Logger } from '@cindy/maker-core';
-import { createCodexMcpThreadContextStore } from './codexMcpThreadContextStore.js';
+import {
+ createCodexMcpThreadContextStore,
+ isSameCodexMcpSessionContext,
+} from './codexMcpThreadContextStore.js';
import { CODEX_DISABLED_BUILTIN_PLUGIN_IDS_KEY } from './codexBuiltinToolPolicy.js';
const SERVER_HEADER = 'Lizi_MCPS/1.0';
@@ -537,15 +540,20 @@ async function dispatchToTransport(opts: DispatchOpts): Promise<void> {
}
if (!activeContext) {
const threadId = extractCodexThreadId(parsedBody);
- activeContext = contextForThreadRoute(
- threadContextStore.getContextForThreadId(threadId),
+ activeContext = contextForRequestRoute(
+ parsedBody,
+ threadContextStore,
threadInstanceQuery,
);
- let decision: 'no_thread_id' | 'thread_unregistered' | 'ctx_resolved';
+ let decision:
+ | 'no_thread_id'
+ | 'thread_unregistered'
+ | 'thread_resolved'
+ | 'instance_resolved';
if (!threadId) {
- decision = 'no_thread_id';
+ decision = activeContext ? 'instance_resolved' : 'no_thread_id';
} else if (activeContext) {
- decision = 'ctx_resolved';
+ decision = 'thread_resolved';
} else {
decision = 'thread_unregistered';
}
@@ -561,7 +569,8 @@ async function dispatchToTransport(opts: DispatchOpts): Promise<void> {
if (
!sessionTokenCtx &&
threadInstanceQuery !== null &&
- hasUnverifiedInstanceBoundToolCall(parsedBody, threadContextStore, threadInstanceQuery)
+ hasToolCall(parsedBody) &&
+ !activeContext
) {
res.statusCode = 401;
res.end('Session instance mismatch');
@@ -667,31 +676,6 @@ interface BlockedToolCall {
context?: LiziMcpSessionContext;
}
-/**
- * `tools/call`s from two different Codex threads coalesced into one JSON-RPC
- * batch. There is no single session context the request could run under, and
- * `extractCodexThreadId` correctly refuses to pick one — but "no context" means
- * the transport would run both calls with an EMPTY AsyncLocalStorage context,
- * and every provider that reads it (cindy_browser's `__mcpSessionId`, …) would
- * fall back to host-side UI-focus inference. That is the exact cross-session
- * mis-routing this boundary exists to prevent, so refusing to pick has to mean
- * refusing to run — fail closed, not fail open to whatever the user is looking
- * at. (Both threads being registered and enabled means the per-call checks
- * below cannot catch this shape.)
- */
-function hasAmbiguousThreadContext(messages: unknown[]): boolean {
- let seen: string | undefined;
- for (const message of messages) {
- if (!isToolCallMessage(message)) continue;
- const threadId = extractCodexThreadIdFromMessage(message);
- // Undefined is `missing_thread_context`'s job, not ambiguity's.
- if (!threadId) continue;
- if (seen && seen !== threadId) return true;
- seen = threadId;
- }
- return false;
-}
-
function findBlockedToolCall(
body: unknown,
threadContextStore: ReturnType<typeof createCodexMcpThreadContextStore>,
@@ -700,11 +684,8 @@ function findBlockedToolCall(
threadInstanceQuery: string | null = null,
): BlockedToolCall | undefined {
const messages = Array.isArray(body) ? body : [body];
- // ?session= 路由时 threadId 不参与任何判定 (强优先, 见下), ambiguity
- // 检查同样豁免 — 否则伪造/串台的 batch threadId 反而有语义效力。
- if (!sessionTokenCtx && hasAmbiguousThreadContext(messages)) {
- return { reason: 'ambiguous_thread_context' };
- }
+ const toolCallContexts: LiziMcpSessionContext[] = [];
+ let resolvedContext: LiziMcpSessionContext | undefined;
for (const message of messages) {
if (!isToolCallMessage(message)) continue;
// Resolve each tools/call independently. Batch siblings such as MCP
@@ -714,11 +695,9 @@ function findBlockedToolCall(
// fail-closed, 请求体的 _meta.threadId 不得覆盖 policy ctx —— 否则伪造
// 一个已注册 threadId 就能绕过本 session 冻结的 built-in plugin
// disabled policy (执行态身份同样是 sessionTokenCtx 强优先)。
- const threadId = extractCodexThreadIdFromMessage(message);
- const context = sessionTokenCtx ?? contextForThreadRoute(
- threadContextStore.getContextForThreadId(threadId),
- threadInstanceQuery,
- );
+ const context =
+ sessionTokenCtx ??
+ contextForToolCallRoute(message, threadContextStore, threadInstanceQuery);
// Ordinary built-in providers are initialized globally, so the bridge is
// their only deterministic per-thread policy boundary. A malformed or
// stale client must not bypass that boundary by omitting an id or naming
@@ -726,6 +705,13 @@ function findBlockedToolCall(
if (!context) {
return { reason: 'missing_thread_context' };
}
+ if (resolvedContext && !isSameCodexMcpSessionContext(resolvedContext, context)) {
+ return { reason: 'ambiguous_thread_context' };
+ }
+ resolvedContext ??= context;
+ toolCallContexts.push(context);
+ }
+ for (const context of toolCallContexts) {
const raw = context?.vendorOptions?.[CODEX_DISABLED_BUILTIN_PLUGIN_IDS_KEY];
if (Array.isArray(raw) && raw.some((id) => id === pluginId)) {
return { reason: 'disabled', context };
@@ -748,19 +734,56 @@ function contextForThreadRoute(
return context.sessionInstanceId === instanceQuery ? context : undefined;
}
-function hasUnverifiedInstanceBoundToolCall(
+function contextForRequestRoute(
body: unknown,
threadContextStore: ReturnType<typeof createCodexMcpThreadContextStore>,
- instanceQuery: string,
-): boolean {
+ instanceQuery: string | null,
+): LiziMcpSessionContext | undefined {
const messages = Array.isArray(body) ? body : [body];
+ let resolved: LiziMcpSessionContext | undefined;
+ let sawToolCall = false;
for (const message of messages) {
if (!isToolCallMessage(message)) continue;
- const threadId = extractCodexThreadIdFromMessage(message);
- const context = threadContextStore.getContextForThreadId(threadId);
- if (!threadId || context?.sessionInstanceId !== instanceQuery) return true;
+ sawToolCall = true;
+ const context = contextForToolCallRoute(message, threadContextStore, instanceQuery);
+ if (!context || (resolved && !isSameCodexMcpSessionContext(resolved, context))) {
+ return undefined;
+ }
+ resolved = context;
}
- return false;
+ if (sawToolCall) return resolved;
+ const threadId = extractCodexThreadId(body);
+ if (threadId) {
+ return contextForThreadRoute(
+ threadContextStore.getContextForThreadId(threadId),
+ instanceQuery,
+ );
+ }
+ return instanceQuery === null
+ ? undefined
+ : threadContextStore.getContextForSessionInstanceId(instanceQuery);
+}
+
+function contextForToolCallRoute(
+ message: unknown,
+ threadContextStore: ReturnType<typeof createCodexMcpThreadContextStore>,
+ instanceQuery: string | null,
+): LiziMcpSessionContext | undefined {
+ const threadId = extractCodexThreadIdFromMessage(message);
+ if (threadId) {
+ // 声明过 threadId 却未注册/已过期时不得回退 instance,避免掩盖串台。
+ return contextForThreadRoute(
+ threadContextStore.getContextForThreadId(threadId),
+ instanceQuery,
+ );
+ }
+ return instanceQuery === null
+ ? undefined
+ : threadContextStore.getContextForSessionInstanceId(instanceQuery);
+}
+
+function hasToolCall(body: unknown): boolean {
+ return (Array.isArray(body) ? body : [body]).some(isToolCallMessage);
}
function withoutSessionInstanceId(
@@ -782,7 +805,7 @@ function writeBlockedToolCallResponse(
? `Built-in tool "${pluginId}" is disabled for this session. Enable it in Settings and start a new session to apply the change.`
: reason === 'ambiguous_thread_context'
? `Built-in tool "${pluginId}" received calls from more than one session in a single batch and cannot tell them apart. Retry the calls one session at a time.`
- : `Built-in tool "${pluginId}" could not verify this session's tool policy. Start a new session and try again.`;
+ : `Built-in tool "${pluginId}" could not bind this call to a verified Cindy session. This is a session-routing problem, not a plugin setup problem. Start a new task and try again.`;
const disabledResult = (id: unknown) => ({
jsonrpc: '2.0',
id: id ?? null,
diff --git a/apps/desktop/src/main/mcp-integrations/codexMcpThreadContextStore.ts b/apps/desktop/src/main/mcp-integrations/codexMcpThreadContextStore.ts
index 351e245932..ac797e6888 100644
--- a/apps/desktop/src/main/mcp-integrations/codexMcpThreadContextStore.ts
+++ b/apps/desktop/src/main/mcp-integrations/codexMcpThreadContextStore.ts
@@ -1,12 +1,36 @@
+import { isDeepStrictEqual } from 'node:util';
+
import type { LiziMcpSessionContext } from '@cindy/mcps';
export interface CodexMcpThreadContextStore {
registerThreadContext(threadId: string, ctx: LiziMcpSessionContext): void;
unregisterThreadContext(threadId: string, expectedSessionInstanceId?: string): void;
getContextForThreadId(threadId: string | undefined): LiziMcpSessionContext | undefined;
+ getContextForSessionInstanceId(
+ sessionInstanceId: string | undefined,
+ ): LiziMcpSessionContext | undefined;
registeredThreadCount(): number;
}
+/**
+ * Two aliases may share one request context only when every field that can
+ * affect routing or tool policy is equivalent. Object identity is deliberately
+ * ignored because registration clones contexts for descendant thread aliases.
+ */
+export function isSameCodexMcpSessionContext(
+ left: LiziMcpSessionContext,
+ right: LiziMcpSessionContext,
+): boolean {
+ return (
+ left.sessionInstanceId === right.sessionInstanceId &&
+ left.sessionId === right.sessionId &&
+ left.agentKind === right.agentKind &&
+ left.workingDir === right.workingDir &&
+ left.remoteHostId === right.remoteHostId &&
+ isDeepStrictEqual(left.vendorOptions, right.vendorOptions)
+ );
+}
+
export function createCodexMcpThreadContextStore(): CodexMcpThreadContextStore {
const contextsByThread = new Map<string, LiziMcpSessionContext>();
@@ -30,6 +54,21 @@ export function createCodexMcpThreadContextStore(): CodexMcpThreadContextStore {
return contextsByThread.get(threadId);
},
+ getContextForSessionInstanceId(sessionInstanceId) {
+ if (!sessionInstanceId) return undefined;
+ let match: LiziMcpSessionContext | undefined;
+ for (const context of contextsByThread.values()) {
+ if (context.sessionInstanceId !== sessionInstanceId) continue;
+ // 同一个 session instance 可能暂时挂在多个 thread alias 上;注册流程
+ // 会为每个 alias 展开出新的对象,因此不能用引用相等判断是否同一实例。
+ // 完整执行上下文一致时复用第一个 context;其余冲突继续 fail closed,
+ // 避免把不同会话实例或 tool policy 串到同一个 opaque route 上。
+ if (match && !isSameCodexMcpSessionContext(match, context)) return undefined;
+ match ??= context;
+ }
+ return match;
+ },
+
registeredThreadCount() {
return contextsByThread.size;
},
diff --git a/apps/desktop/src/renderer/__tests__/deviceLinkInteractionScenarios.test.ts b/apps/desktop/src/renderer/__tests__/deviceLinkInteractionScenarios.test.ts
index 77e1b1e868..20ac74f846 100644
--- a/apps/desktop/src/renderer/__tests__/deviceLinkInteractionScenarios.test.ts
+++ b/apps/desktop/src/renderer/__tests__/deviceLinkInteractionScenarios.test.ts
@@ -679,6 +679,38 @@ describe('device-link 交互快照重建 — 窗口在交互挂起之后才打
makerChatStore.purgeSession(s);
});
+ it('兼容旧 Main 已固定的 GitHub 身份,不静默丢弃确认卡', async () => {
+ const s = sid();
+ local.localGetPendingInteractions.mockResolvedValue([
+ {
+ request: {
+ kind: 'issue_confirm',
+ requestId: 'issue-legacy-github',
+ draft: { title: '旧版标题', body: '旧版正文', type: 'bug' },
+ env: {
+ appVersion: '0.1.33',
+ platform: 'win32',
+ arch: 'x64',
+ osVersion: '10.0',
+ },
+ submissionIdentity: { kind: 'github-user', login: 'legacy-user' },
+ },
+ },
+ ]);
+
+ makerChatStore.ensureInitialMessages(s);
+ await flush();
+ await flush();
+
+ expect(makerChatStore.getSnapshot(s).pendingIssueConfirm).toMatchObject({
+ requestId: 'issue-legacy-github',
+ submissionIdentity: { kind: 'github-user', login: 'legacy-user' },
+ });
+ expect(makerChatStore.getSnapshot(s).pendingIssueConfirm?.githubUserIdentity).toBeUndefined();
+ expect(makerChatStore.getSnapshot(s).pendingIssueConfirm?.suggestedPublicName).toBeUndefined();
+ makerChatStore.purgeSession(s);
+ });
+
it('permission:被控端已挂起 + 不发 push → ensureInitialMessages 后重建 pendingPermission', async () => {
const s = openRemoteSession();
host.seedPending(s, {
diff --git a/apps/desktop/src/renderer/__tests__/issueConfirmPayload.test.ts b/apps/desktop/src/renderer/__tests__/issueConfirmPayload.test.ts
index 3690aa910f..32a71bf8c5 100644
--- a/apps/desktop/src/renderer/__tests__/issueConfirmPayload.test.ts
+++ b/apps/desktop/src/renderer/__tests__/issueConfirmPayload.test.ts
@@ -2,6 +2,7 @@ import { describe, expect, it } from 'vitest';
import {
parseIssueEnvRegion,
+ parseOptionalGithubUserIdentity,
parseIssueSuggestedPublicName,
parseIssueSubmissionIdentity,
} from '@/lib/issueConfirmPayload';
@@ -25,6 +26,19 @@ describe('parseIssueSubmissionIdentity', () => {
});
});
+describe('parseOptionalGithubUserIdentity', () => {
+ it('只保留完整的 GitHub 用户身份,非法可选值按缺失处理', () => {
+ expect(parseOptionalGithubUserIdentity({ kind: 'github-user', login: ' octocat ' })).toEqual({
+ kind: 'github-user',
+ login: 'octocat',
+ });
+ expect(
+ parseOptionalGithubUserIdentity({ kind: 'platform', login: 'cindy-issue' }),
+ ).toBeUndefined();
+ expect(parseOptionalGithubUserIdentity({ kind: 'github-user', login: '' })).toBeUndefined();
+ });
+});
+
describe('parseIssueEnvRegion', () => {
it('保留三种合法构建区域', () => {
expect(parseIssueEnvRegion('cn')).toBe('cn');
diff --git a/apps/desktop/src/renderer/features/cc-agent/IssueConfirmCard.tsx b/apps/desktop/src/renderer/features/cc-agent/IssueConfirmCard.tsx
index cacc836b94..a305946263 100644
--- a/apps/desktop/src/renderer/features/cc-agent/IssueConfirmCard.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/IssueConfirmCard.tsx
@@ -36,6 +36,7 @@ interface IssueConfirmCardProps {
title: string;
body: string;
type: 'bug' | 'feature';
+ submissionIdentity: PendingIssueConfirm['submissionIdentity'];
publicName?: string;
uiLanguage: string;
}
@@ -54,25 +55,38 @@ export function IssueConfirmCard({ sessionId, pending, onRespond }: IssueConfirm
const titleInputId = useId();
const bodyInputId = useId();
const publicNameInputId = useId();
- const [draft, setDraft] = useState<IssueConfirmDraft>(
- () =>
- getIssueConfirmDraft(sessionId, pending.requestId) ?? {
+ const legacyFixedGithubIdentity =
+ pending.submissionIdentity.kind === 'github-user' ? pending.submissionIdentity : null;
+ const [draft, setDraft] = useState<IssueConfirmDraft>(() => {
+ const saved = getIssueConfirmDraft(sessionId, pending.requestId);
+ if (legacyFixedGithubIdentity) {
+ return {
+ ...(saved ?? pending.draft),
+ submissionIdentityKind: 'github-user',
+ publicName: undefined,
+ };
+ }
+ return (
+ saved ?? {
...pending.draft,
- ...(pending.submissionIdentity.kind === 'platform'
- ? {
- publicName: pending.suggestedPublicName ?? t('issueAgent.confirm.anonymous'),
- }
- : {}),
- },
- );
+ submissionIdentityKind: 'platform',
+ publicName: pending.suggestedPublicName ?? t('issueAgent.confirm.anonymous'),
+ }
+ );
+ });
const { title, body, type, publicName = '' } = draft;
+ const selectedIdentity =
+ legacyFixedGithubIdentity ??
+ (draft.submissionIdentityKind === 'github-user' && pending.githubUserIdentity
+ ? pending.githubUserIdentity
+ : pending.submissionIdentity);
const confirmedPublicName =
- pending.submissionIdentity.kind === 'platform' ? normalizeIssuePublicName(publicName) : null;
+ selectedIdentity.kind === 'platform' ? normalizeIssuePublicName(publicName) : null;
const canSubmit =
title.trim().length > 0 &&
body.trim().length > 0 &&
- (pending.submissionIdentity.kind !== 'platform' || confirmedPublicName !== null);
+ (selectedIdentity.kind !== 'platform' || confirmedPublicName !== null);
const updateDraft = useCallback(
(patch: Partial<IssueConfirmDraft>) => {
@@ -81,6 +95,7 @@ export function IssueConfirmCard({ sessionId, pending, onRespond }: IssueConfirm
next.title === draft.title &&
next.body === draft.body &&
next.type === draft.type &&
+ next.submissionIdentityKind === draft.submissionIdentityKind &&
next.publicName === draft.publicName
) {
return;
@@ -114,10 +129,20 @@ export function IssueConfirmCard({ sessionId, pending, onRespond }: IssueConfirm
title: title.trim(),
body: body.trim(),
type,
+ submissionIdentity: selectedIdentity,
...(confirmedPublicName ? { publicName: confirmedPublicName } : {}),
uiLanguage: i18n.language,
});
- }, [canSubmit, confirmedPublicName, onRespond, title, body, type, i18n.language]);
+ }, [
+ canSubmit,
+ confirmedPublicName,
+ onRespond,
+ title,
+ body,
+ type,
+ selectedIdentity,
+ i18n.language,
+ ]);
const handleCancel = useCallback(() => {
onRespond({ confirmed: false });
@@ -154,6 +179,26 @@ export function IssueConfirmCard({ sessionId, pending, onRespond }: IssueConfirm
</button>
);
+ const identityButton = (identity: PendingIssueConfirm['submissionIdentity'], label: string) => {
+ const selected =
+ selectedIdentity.kind === identity.kind && selectedIdentity.login === identity.login;
+ return (
+ <button
+ type="button"
+ aria-pressed={selected}
+ onClick={() => updateDraft({ submissionIdentityKind: identity.kind })}
+ className={cn(
+ 'rounded-full border px-3 py-2 text-13 font-medium transition-colors',
+ selected
+ ? 'border-[var(--chat-input-border)] bg-[var(--perm-allow-btn-bg)] text-[var(--perm-allow-btn-text)]'
+ : 'border-[var(--chat-input-border)] bg-transparent text-[var(--chat-input-text)] hover:bg-[var(--chat-input-bg)]',
+ )}
+ >
+ {label}
+ </button>
+ );
+ };
+
return (
<div
className={cn(
@@ -213,8 +258,14 @@ export function IssueConfirmCard({ sessionId, pending, onRespond }: IssueConfirm
'focus:outline-none focus:ring-1 focus:ring-[var(--focus-ring)]',
)}
/>
+ <p className="mt-1 text-12 leading-snug text-[var(--status-bar-meta)]">
+ {t('issueAgent.confirm.privacyHint')}
+ </p>
- {/* 发布方式由 Main 预先选定;确认阶段只展示实际通道,不提供不可用切换。 */}
+ {/*
+ 新版 Main:平台 Bot 默认 + 可选 GitHub 用户。旧版 Main 可能已固定为 GitHub
+ 用户,此时只能如实展示该单一身份,不能提供旧 Main 不会执行的平台切换。
+ */}
<div
className={cn(
'mt-3 rounded-[8px] border p-3',
@@ -224,22 +275,35 @@ export function IssueConfirmCard({ sessionId, pending, onRespond }: IssueConfirm
<p className="select-none text-12 font-medium text-[var(--status-bar-meta)]">
{t('issueAgent.confirm.submissionMethodLabel')}
</p>
- <p className="mt-1 text-13 leading-snug text-[var(--chat-input-text)]">
- {pending.submissionIdentity.kind === 'github-user'
- ? t('issueAgent.confirm.identityGithubUser', {
- login: pending.submissionIdentity.login,
- })
- : t('issueAgent.confirm.identityPlatform', {
- login: pending.submissionIdentity.login,
- })}
- </p>
+ <div className="mt-2 flex flex-wrap items-center gap-2">
+ {pending.submissionIdentity.kind === 'platform'
+ ? identityButton(
+ pending.submissionIdentity,
+ t('issueAgent.confirm.identityPlatform', {
+ login: pending.submissionIdentity.login,
+ }),
+ )
+ : identityButton(
+ pending.submissionIdentity,
+ t('issueAgent.confirm.identityGithubUser', {
+ login: pending.submissionIdentity.login,
+ }),
+ )}
+ {pending.githubUserIdentity &&
+ identityButton(
+ pending.githubUserIdentity,
+ t('issueAgent.confirm.identityGithubUser', {
+ login: pending.githubUserIdentity.login,
+ }),
+ )}
+ </div>
<p className="mt-1 text-12 leading-snug text-[var(--status-bar-meta)]">
- {pending.submissionIdentity.kind === 'github-user'
+ {selectedIdentity.kind === 'github-user'
? t('issueAgent.confirm.identityGithubUserHint')
: t('issueAgent.confirm.identityPlatformHint')}
</p>
- {pending.submissionIdentity.kind === 'platform' && (
+ {selectedIdentity.kind === 'platform' && (
<>
<label
htmlFor={publicNameInputId}
diff --git a/apps/desktop/src/renderer/features/cc-agent/__tests__/IssueConfirmCard.test.tsx b/apps/desktop/src/renderer/features/cc-agent/__tests__/IssueConfirmCard.test.tsx
index ba75c96cd2..57215ce259 100644
--- a/apps/desktop/src/renderer/features/cc-agent/__tests__/IssueConfirmCard.test.tsx
+++ b/apps/desktop/src/renderer/features/cc-agent/__tests__/IssueConfirmCard.test.tsx
@@ -29,18 +29,24 @@ const initialPending: PendingIssueConfirm = {
osVersion: '10.0',
},
submissionIdentity: {
- kind: 'github-user',
- login: 'tester',
+ kind: 'platform',
+ login: 'cindy-issue',
},
+ githubUserIdentity: { kind: 'github-user', login: 'tester' },
+ suggestedPublicName: '当前昵称',
};
const platformPending: PendingIssueConfirm = {
...initialPending,
- submissionIdentity: {
- kind: 'platform',
- login: 'cindy-issue',
- },
- suggestedPublicName: '当前昵称',
+ githubUserIdentity: undefined,
+};
+
+const legacyGithubPending: PendingIssueConfirm = {
+ ...initialPending,
+ requestId: 'issue-request-legacy-github',
+ submissionIdentity: { kind: 'github-user', login: 'legacy-user' },
+ githubUserIdentity: undefined,
+ suggestedPublicName: undefined,
};
function Harness() {
@@ -173,11 +179,75 @@ describe('IssueConfirmCard draft persistence', () => {
});
describe('IssueConfirmCard submission identity', () => {
- it('GitHub direct publishing only shows the selected account', () => {
- render(<IssueConfirmCard sessionId="session-a" pending={initialPending} onRespond={vi.fn()} />);
- expect(screen.getByText('issueAgent.confirm.identityGithubUser')).not.toBeNull();
+ it('defaults to the platform bot and offers a verified GitHub account as an extra option', () => {
+ const onRespond = vi.fn();
+ render(
+ <IssueConfirmCard sessionId="session-a" pending={initialPending} onRespond={onRespond} />,
+ );
+
+ expect(
+ screen
+ .getByRole('button', { name: 'issueAgent.confirm.identityPlatform' })
+ .getAttribute('aria-pressed'),
+ ).toBe('true');
+ expect(screen.getByText('issueAgent.confirm.privacyHint')).not.toBeNull();
+ expect(screen.getByText('issueAgent.confirm.identityPlatformHint')).not.toBeNull();
+ expect(screen.getByLabelText('issueAgent.confirm.publicNameLabel')).not.toBeNull();
+
+ fireEvent.click(screen.getByRole('button', { name: 'issueAgent.confirm.identityGithubUser' }));
+ expect(screen.getByText('issueAgent.confirm.identityGithubUserHint')).not.toBeNull();
+ expect(screen.queryByLabelText('issueAgent.confirm.publicNameLabel')).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: /issueAgent\.confirm\.submit/ }));
+ expect(onRespond).toHaveBeenCalledWith(
+ expect.objectContaining({
+ confirmed: true,
+ submissionIdentity: { kind: 'github-user', login: 'tester' },
+ }),
+ );
+ });
+
+ it('does not show a GitHub account option when none is currently available', () => {
+ render(
+ <IssueConfirmCard sessionId="session-a" pending={platformPending} onRespond={vi.fn()} />,
+ );
+ expect(
+ screen.getByRole('button', { name: 'issueAgent.confirm.identityPlatform' }),
+ ).not.toBeNull();
+ expect(
+ screen.queryByRole('button', { name: 'issueAgent.confirm.identityGithubUser' }),
+ ).toBeNull();
+ });
+
+ it('keeps an old-Main GitHub identity fixed instead of dropping or mislabeling the card', () => {
+ const onRespond = vi.fn();
+ render(
+ <IssueConfirmCard
+ sessionId="session-a"
+ pending={legacyGithubPending}
+ onRespond={onRespond}
+ />,
+ );
+
+ expect(
+ screen
+ .getByRole('button', { name: 'issueAgent.confirm.identityGithubUser' })
+ .getAttribute('aria-pressed'),
+ ).toBe('true');
+ expect(
+ screen.queryByRole('button', { name: 'issueAgent.confirm.identityPlatform' }),
+ ).toBeNull();
expect(screen.getByText('issueAgent.confirm.identityGithubUserHint')).not.toBeNull();
expect(screen.queryByLabelText('issueAgent.confirm.publicNameLabel')).toBeNull();
+
+ fireEvent.click(screen.getByRole('button', { name: /issueAgent\.confirm\.submit/ }));
+ expect(onRespond).toHaveBeenCalledWith({
+ confirmed: true,
+ title: '原始标题',
+ body: '原始正文',
+ type: 'bug',
+ submissionIdentity: { kind: 'github-user', login: 'legacy-user' },
+ uiLanguage: 'zh-CN',
+ });
});
it('platform publishing submits the edited public name', () => {
@@ -192,6 +262,7 @@ describe('IssueConfirmCard submission identity', () => {
expect(onRespond).toHaveBeenCalledWith(
expect.objectContaining({
confirmed: true,
+ submissionIdentity: { kind: 'platform', login: 'cindy-issue' },
publicName: '公开昵称',
}),
);
@@ -214,6 +285,7 @@ describe('IssueConfirmCard submission identity', () => {
expect(onRespond).toHaveBeenCalledWith(
expect.objectContaining({
confirmed: true,
+ submissionIdentity: { kind: 'platform', login: 'cindy-issue' },
publicName: 'issueAgent.confirm.anonymous',
}),
);
diff --git a/apps/desktop/src/renderer/hooks/useCCAgentChat.ts b/apps/desktop/src/renderer/hooks/useCCAgentChat.ts
index a73d8f5381..7907097f24 100644
--- a/apps/desktop/src/renderer/hooks/useCCAgentChat.ts
+++ b/apps/desktop/src/renderer/hooks/useCCAgentChat.ts
@@ -242,6 +242,7 @@ interface UseCCAgentChatReturn {
title: string;
body: string;
type: 'bug' | 'feature';
+ submissionIdentity: PendingIssueConfirm['submissionIdentity'];
publicName?: string;
uiLanguage: string;
}
@@ -569,6 +570,7 @@ export function useCCAgentChat(
title: string;
body: string;
type: 'bug' | 'feature';
+ submissionIdentity: PendingIssueConfirm['submissionIdentity'];
publicName?: string;
uiLanguage: string;
}
diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.json
index 6df1376ae9..cd57e64817 100644
--- a/apps/desktop/src/renderer/i18n/locales/en/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json
@@ -7856,7 +7856,7 @@
},
"issueAgent": {
"command": {
- "instruction": "I'd like to file feedback for {{appName}}. Please help me turn it into a high-quality GitHub issue: first confirm the feedback type (bug or feature request) and ask follow-up questions for the necessary details (symptoms, reproduction steps or use case, expected behavior). Once there is enough information, submit it with the submit_github_issue tool via cindy_helper call_tool (category=feedback; you can run list_tools first to check the parameters; a confirmation card will be shown to me before submitting). If the submission fails, tell me the reason honestly.{{details}}",
+ "instruction": "I'd like to file feedback for {{appName}}. Help me turn it into a complete, clear GitHub issue: confirm whether it is a bug or feature request, and ask only for missing or ambiguous details. For bugs, collect the symptoms, reproduction steps, expected and actual behavior, frequency, attempted fixes, and—only with my consent—redacted diagnostic summaries; never include passwords, tokens, email addresses, personal paths, or unrelated files. For feature requests, clarify the use case, current pain point, and desired outcome. Once the information is sufficient, submit it with the submit_github_issue tool via cindy_helper call_tool (category=feedback; you can run list_tools first to check the parameters; a confirmation card will be shown to me before submitting). No GitHub plugin or account setup is required: Cindy's official bot is the default, and a working GitHub account appears only as an optional identity in the confirmation card. After creation, tell me the issue number and link, explain that Cindy is open source, and offer to help me reproduce, fix, test, or extend it from source. If the submission fails, tell me the reason honestly.{{details}}",
"detailsPrefix": "\nMy initial description: {{details}}"
},
"confirm": {
@@ -7865,11 +7865,12 @@
"typeFeature": "Feature",
"titleLabel": "Title",
"bodyLabel": "Body (Markdown)",
- "submissionMethodLabel": "Publishing Method",
- "identityGithubUser": "Publish directly through GitHub account @{{login}}",
+ "privacyHint": "Common secrets, personal paths, and email addresses are redacted when detected. Review the public content before submitting.",
+ "submissionMethodLabel": "Submission Identity",
+ "identityGithubUser": "My GitHub account @{{login}}",
"identityGithubUserHint": "You will be the GitHub author and can edit or close this Issue on GitHub",
- "identityPlatform": "Publish through Cindy (GitHub App {{login}})",
- "identityPlatformHint": "You will not be the GitHub author and cannot edit or close this Issue yourself",
+ "identityPlatform": "Cindy official bot @{{login}} (default)",
+ "identityPlatformHint": "No GitHub account setup is required. The official bot creates the Issue, and you can add a public attribution in the body",
"publicNameLabel": "Public Attribution",
"publicNameHint": "This attribution will appear publicly in the Issue body",
"anonymous": "Anonymous",
diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.json
index dbbe23634a..a0a8f0dccf 100644
--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json
@@ -7843,7 +7843,7 @@
},
"issueAgent": {
"command": {
- "instruction": "{{appName}} にフィードバックを送りたいです。質の高い GitHub issue にまとめるのを手伝ってください:まずフィードバックの種類(バグか機能要望か)を確認し、必要な詳細(現象、再現手順または利用シーン、期待する動作)を質問してください。情報が揃ったら cindy_helper の call_tool で submit_github_issue ツールを呼び出して提出してください(category=feedback。先に list_tools でパラメータを確認できます。提出前に確認カードが表示されます)。提出に失敗した場合は、理由をそのまま教えてください。{{details}}",
+ "instruction": "{{appName}} にフィードバックを送りたいです。情報が揃った明確な GitHub issue にまとめるのを手伝ってください:バグか機能要望かを確認し、不足または曖昧な点だけを質問してください。バグでは現象、再現手順、期待する動作と実際の動作、再現頻度、試した対処をできるだけ確認し、ユーザーの同意がある場合だけ個人情報を除いた診断の要約を含めてください。パスワード、トークン、メールアドレス、個人パス、無関係なファイル内容は含めないでください。機能要望では利用シーン、現在の困りごと、期待する結果を確認してください。情報が揃ったら cindy_helper の call_tool で submit_github_issue ツールを呼び出して提出してください(category=feedback。先に list_tools でパラメータを確認できます。提出前に確認カードが表示されます)。GitHub プラグインやアカウントの設定は不要です。既定では Cindy 公式 Bot が送信し、利用可能な GitHub アカウントがある場合のみ確認カードに追加の送信元として表示されます。作成後は issue 番号とリンクを伝え、Cindy がオープンソースであること、ソースから再現・修正・テスト・機能開発を一緒に進められることを案内してください。提出に失敗した場合は、理由をそのまま教えてください。{{details}}",
"detailsPrefix": "\n最初の説明:{{details}}"
},
"confirm": {
@@ -7852,11 +7852,12 @@
"typeFeature": "機能要望",
"titleLabel": "タイトル",
"bodyLabel": "本文(Markdown)",
- "submissionMethodLabel": "公開方法",
- "identityGithubUser": "GitHub アカウント @{{login}} から直接公開",
+ "privacyHint": "検出された一般的な秘密情報、個人パス、メールアドレスはできるだけ自動で隠します。送信前に公開内容を確認してください。",
+ "submissionMethodLabel": "送信元",
+ "identityGithubUser": "自分の GitHub アカウント @{{login}}",
"identityGithubUserHint": "GitHub 上の Issue 作成者となり、自分で編集またはクローズできます",
- "identityPlatform": "Cindy が代理で公開(GitHub App {{login}})",
- "identityPlatformHint": "GitHub 上の Issue 作成者にはならず、自分で編集またはクローズできません",
+ "identityPlatform": "Cindy 公式 Bot @{{login}}(既定)",
+ "identityPlatformHint": "GitHub アカウントの設定は不要です。Issue は公式 Bot が作成し、本文に公開署名を付けられます",
"publicNameLabel": "公開署名",
"publicNameHint": "この署名は Issue 本文に公開表示されます",
"anonymous": "匿名",
diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.json
index 48c4fad3dc..eb7c7accc5 100644
--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json
@@ -7843,7 +7843,7 @@
},
"issueAgent": {
"command": {
- "instruction": "{{appName}}에 피드백을 제출하고 싶습니다. 높은 품질의 GitHub issue로 정리하도록 도와주세요: 먼저 피드백 유형(버그 또는 기능 제안)을 확인하고 필요한 세부 정보(증상, 재현 단계 또는 사용 시나리오, 기대 동작)를 질문해 주세요. 정보가 충분해지면 cindy_helper의 call_tool로 submit_github_issue 도구를 호출해 제출해 주세요(category=feedback, 먼저 list_tools로 매개변수를 확인할 수 있습니다. 제출 전에 확인 카드가 표시됩니다). 제출에 실패하면 이유를 그대로 알려주세요.{{details}}",
+ "instruction": "{{appName}}에 피드백을 제출하고 싶습니다. 정보가 충분하고 명확한 GitHub issue로 정리하도록 도와주세요: 버그인지 기능 제안인지 확인하고, 빠진 정보나 모호한 부분만 질문해 주세요. 버그라면 증상, 재현 단계, 기대 동작과 실제 동작, 재현 빈도, 시도한 해결 방법을 최대한 확인하고, 사용자가 동의한 경우에만 민감 정보를 제거한 진단 요약을 포함해 주세요. 비밀번호, 토큰, 이메일 주소, 개인 경로, 관련 없는 파일 내용은 포함하지 마세요. 기능 제안이라면 사용 시나리오, 현재 문제와 원하는 결과를 확인해 주세요. 정보가 충분해지면 cindy_helper의 call_tool로 submit_github_issue 도구를 호출해 제출해 주세요(category=feedback, 먼저 list_tools로 매개변수를 확인할 수 있습니다. 제출 전에 확인 카드가 표시됩니다). GitHub 플러그인이나 계정 설정은 필요하지 않습니다. 기본적으로 Cindy 공식 봇이 제출하며, 사용 가능한 GitHub 계정이 있을 때만 확인 카드에 추가 제출 계정으로 표시됩니다. 생성 후 issue 번호와 링크를 알려 주고, Cindy가 오픈 소스이며 소스에서 재현·수정·테스트·기능 개발을 함께 진행할 수 있다고 안내해 주세요. 제출에 실패하면 이유를 그대로 알려주세요.{{details}}",
"detailsPrefix": "\n초기 설명: {{details}}"
},
"confirm": {
@@ -7852,11 +7852,12 @@
"typeFeature": "기능 제안",
"titleLabel": "제목",
"bodyLabel": "본문(Markdown)",
- "submissionMethodLabel": "게시 방식",
- "identityGithubUser": "GitHub 계정 @{{login}}에서 직접 게시",
+ "privacyHint": "감지된 일반적인 비밀 정보, 개인 경로, 이메일 주소는 가능한 범위에서 자동으로 가립니다. 제출 전에 공개 내용을 확인하세요.",
+ "submissionMethodLabel": "제출 계정",
+ "identityGithubUser": "내 GitHub 계정 @{{login}}",
"identityGithubUserHint": "GitHub의 Issue 작성자가 되며 직접 수정하거나 닫을 수 있습니다",
- "identityPlatform": "Cindy에서 대신 게시(GitHub App {{login}})",
- "identityPlatformHint": "GitHub의 Issue 작성자가 아니므로 직접 수정하거나 닫을 수 없습니다",
+ "identityPlatform": "Cindy 공식 봇 @{{login}} (기본값)",
+ "identityPlatformHint": "GitHub 계정 설정 없이 사용할 수 있습니다. Issue는 공식 봇이 만들며 본문에 공개 서명을 표시할 수 있습니다",
"publicNameLabel": "공개 서명",
"publicNameHint": "이 서명은 Issue 본문에 공개적으로 표시됩니다",
"anonymous": "익명",
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 9151613f33..6fa93c502f 100644
--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json
@@ -7843,7 +7843,7 @@
},
"issueAgent": {
"command": {
- "instruction": "我想给 {{appName}} 提交一条反馈。请协助我整理成一个高质量的 GitHub issue:先和我确认反馈类型(bug 还是功能建议),并追问必要细节(现象、复现步骤或使用场景、期望行为);信息足够后用 cindy_helper 的 call_tool 调用 submit_github_issue 工具提交(category=feedback,可先 list_tools 查看参数要求;提交前系统会弹确认卡片给我看)。如果提交失败,如实告诉我原因。{{details}}",
+ "instruction": "我想给 {{appName}} 提交一条反馈。请协助我整理成一个高质量、信息完整的 GitHub issue:先确认反馈类型(bug 还是功能建议),只针对缺失或含糊的信息追问;Bug 尽量补齐现象、复现步骤、期望与实际行为、复现频率、已尝试的方法,并在用户同意后纳入经过脱敏的诊断摘要,禁止提交密码、令牌、邮箱、个人路径或无关文件内容;功能建议补齐使用场景、当前痛点和期望结果。信息足够后用 cindy_helper 的 call_tool 调用 submit_github_issue 工具提交(category=feedback,可先 list_tools 查看参数要求;提交前系统会弹确认卡片给我看)。这不需要安装或配置 GitHub 插件:默认由 Cindy 官方 Bot 提交;若当前有可用的 GitHub 账号,确认卡会额外提供本人账号选项。创建成功后告诉我 issue 编号和链接,并说明 Cindy 是开源软件,询问我是否希望通过源码一起复现、修复 Bug、开发功能或准备 PR。如果提交失败,如实告诉我原因。{{details}}",
"detailsPrefix": "\n我的初始描述:{{details}}"
},
"confirm": {
@@ -7852,11 +7852,12 @@
"typeFeature": "功能建议",
"titleLabel": "标题",
"bodyLabel": "正文(Markdown)",
- "submissionMethodLabel": "发布方式",
- "identityGithubUser": "通过 GitHub 账号 @{{login}} 直接发布",
+ "privacyHint": "系统会尽量隐藏常见密钥、个人路径和邮箱;提交前请确认公开内容不包含其他隐私。",
+ "submissionMethodLabel": "提交身份",
+ "identityGithubUser": "我的 GitHub 账号 @{{login}}",
"identityGithubUserHint": "你将成为该 Issue 的 GitHub 作者,可以在 GitHub 编辑或关闭",
- "identityPlatform": "由 Cindy 平台代发(GitHub App {{login}})",
- "identityPlatformHint": "你不是该 Issue 的 GitHub 作者,提交后无法自行编辑或关闭",
+ "identityPlatform": "Cindy 官方 Bot @{{login}}(默认)",
+ "identityPlatformHint": "无需配置 GitHub 账号;Issue 由官方 Bot 创建,你可在正文中选择公开署名",
"publicNameLabel": "公开署名",
"publicNameHint": "该署名会公开显示在 Issue 正文中",
"anonymous": "匿名",
diff --git a/apps/desktop/src/renderer/lib/issueConfirmDraftStore.ts b/apps/desktop/src/renderer/lib/issueConfirmDraftStore.ts
index 2b989d5b4d..a84bc146b1 100644
--- a/apps/desktop/src/renderer/lib/issueConfirmDraftStore.ts
+++ b/apps/desktop/src/renderer/lib/issueConfirmDraftStore.ts
@@ -12,6 +12,8 @@ export interface IssueConfirmDraft {
title: string;
body: string;
type: 'bug' | 'feature';
+ /** 平台为默认;只有 Main 提供了可用账号时才允许保存 github-user。 */
+ submissionIdentityKind?: 'platform' | 'github-user';
/** 平台代发时用户在确认卡片里编辑的公开署名。 */
publicName?: string;
}
diff --git a/apps/desktop/src/renderer/lib/issueConfirmPayload.ts b/apps/desktop/src/renderer/lib/issueConfirmPayload.ts
index 4cb0500003..0e4d4dfc08 100644
--- a/apps/desktop/src/renderer/lib/issueConfirmPayload.ts
+++ b/apps/desktop/src/renderer/lib/issueConfirmPayload.ts
@@ -14,7 +14,7 @@ export function parseIssueEnvRegion(raw: unknown): CindyRegion | undefined {
return raw === 'cn' || raw === 'global' || raw === 'dev' ? raw : undefined;
}
-/** issue_confirm IPC 中的真实 GitHub 提交身份;renderer 只展示,不参与选择。 */
+/** issue_confirm IPC 中可由用户在确认卡选择的实际提交身份。 */
export type IssueSubmissionIdentity =
{ kind: 'github-user'; login: string } | { kind: 'platform'; login: string };
@@ -32,6 +32,14 @@ export function parseIssueSubmissionIdentity(raw: unknown): IssueSubmissionIdent
return { kind: obj.kind, login: obj.login.trim() };
}
+/** 可选 GitHub 用户身份无效时只隐藏该选项,不影响平台确认卡。 */
+export function parseOptionalGithubUserIdentity(
+ raw: unknown,
+): Extract<IssueSubmissionIdentity, { kind: 'github-user' }> | undefined {
+ const identity = parseIssueSubmissionIdentity(raw);
+ return identity?.kind === 'github-user' ? identity : undefined;
+}
+
/** Main 提供的平台代发建议署名;非法值按缺失处理,由卡片回退为“匿名”。 */
export function parseIssueSuggestedPublicName(raw: unknown): string | undefined {
return normalizeIssuePublicName(raw) ?? undefined;
diff --git a/apps/desktop/src/renderer/lib/makerChatStore.ts b/apps/desktop/src/renderer/lib/makerChatStore.ts
index 6e34415fe4..a006fb5838 100644
--- a/apps/desktop/src/renderer/lib/makerChatStore.ts
+++ b/apps/desktop/src/renderer/lib/makerChatStore.ts
@@ -127,6 +127,7 @@ import {
import { buildUserMessageAttachmentPayload } from '@/lib/messageAttachmentPayload';
import {
parseIssueEnvRegion,
+ parseOptionalGithubUserIdentity,
parseIssueSuggestedPublicName,
parseIssueSubmissionIdentity,
type IssueSubmissionIdentity,
@@ -745,8 +746,13 @@ export interface PendingIssueConfirm {
osVersion: string;
region?: CindyRegion;
};
- /** main 已经选定、确认后不会自动切换的实际 GitHub 作者身份。 */
+ /**
+ * Main 提供的默认身份。新版 Main 始终传平台 Bot;旧版 Main 可能已经固定为
+ * GitHub 用户,Renderer 必须保留该形状,不能让升级中的确认卡静默消失。
+ */
submissionIdentity: IssueSubmissionIdentity;
+ /** 当前验证可用时才提供的 GitHub 用户本人身份。 */
+ githubUserIdentity?: Extract<IssueSubmissionIdentity, { kind: 'github-user' }>;
/** 平台代发的建议公开署名;缺失时卡片使用本地化“匿名”。 */
suggestedPublicName?: string;
}
@@ -6550,6 +6556,12 @@ function initGlobalListeners(): void {
(Omit<PendingIssueConfirm['env'], 'region'> & { region?: unknown }) | undefined;
const submissionIdentity = parseIssueSubmissionIdentity(request.submissionIdentity);
if (!draft || !rawEnv || !submissionIdentity) return;
+ // 新版 Main:平台默认 + 可选 GitHub 身份。旧版 Main:只传已经固定的单一
+ // 身份;若它固定为 GitHub,不能凭新版字段再虚构平台切换入口。
+ const githubUserIdentity =
+ submissionIdentity.kind === 'platform'
+ ? parseOptionalGithubUserIdentity(request.githubUserIdentity)
+ : undefined;
const suggestedPublicName =
submissionIdentity.kind === 'platform'
? parseIssueSuggestedPublicName(request.suggestedPublicName)
@@ -6563,6 +6575,7 @@ function initGlobalListeners(): void {
draft,
env,
submissionIdentity,
+ githubUserIdentity,
suggestedPublicName,
},
}));
@@ -12696,7 +12709,7 @@ function respondToPermission(sessionId: string, result: CCAgentPermissionResult)
/**
* issue_confirm: 把确认卡片结果回给 main(IssueConfirmBridge)并清 pendingIssueConfirm。
* confirmed=true 时携带卡片当前的 title/body/type(用户编辑版,main 以此为准)、
- * 平台代发公开署名(publicName)和 renderer 界面语言(uiLanguage)。
+ * 用户选择的提交身份、平台代发公开署名(publicName)和 renderer 界面语言(uiLanguage)。
*/
function respondToIssueConfirm(
sessionId: string,
@@ -12706,6 +12719,7 @@ function respondToIssueConfirm(
title: string;
body: string;
type: 'bug' | 'feature';
+ submissionIdentity: IssueSubmissionIdentity;
publicName?: string;
uiLanguage: string;
}
diff --git a/packages/lizi-mcps/src/__tests__/submitGithubIssueTool.test.ts b/packages/lizi-mcps/src/__tests__/submitGithubIssueTool.test.ts
index 4fc26918a8..5465cc4518 100644
--- a/packages/lizi-mcps/src/__tests__/submitGithubIssueTool.test.ts
+++ b/packages/lizi-mcps/src/__tests__/submitGithubIssueTool.test.ts
@@ -31,6 +31,7 @@ function setup(opts?: {
issueUrl: 'https://github.com/makecindy/cindy/issues/76',
finalTitle: VALID_ARGS.title,
editedByUser: false,
+ privacyRedacted: false,
},
);
const registry = new XdtHelperToolRegistry();
@@ -104,6 +105,13 @@ describe('submit_github_issue tool', () => {
issue_url: 'https://github.com/makecindy/cindy/issues/76',
final_title: VALID_ARGS.title,
edited_by_user: false,
+ privacy_redacted: false,
+ open_source: {
+ repository_url: 'https://github.com/makecindy/cindy',
+ license: 'Apache-2.0',
+ invitation:
+ 'Cindy is open source. If the user is interested, offer help with reproducing the issue, editing the source, adding tests, and preparing a pull request.',
+ },
});
});
diff --git a/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts b/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts
index 460c1a867d..b2325a2cb4 100644
--- a/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts
+++ b/packages/lizi-mcps/src/lizi_xdtHelperMcpServer.ts
@@ -73,7 +73,7 @@ const D_LIST_TOOLS =
'(list_workdirs / list_sessions / get_chat_history 按元数据捞, search_chat_history 按内容语义找),' +
'用于让用户基于自己的对话历史组织 memory / 知识库;' +
`传 category=feedback → 用户要给 ${BRAND_NAME} 官方提 bug / 反馈 / 功能建议时用` +
- '(submit_github_issue,先与用户对话澄清细节,提交前会弹系统确认卡片);' +
+ '(submit_github_issue,先与用户对话澄清缺失细节;Bug 可在用户同意后附脱敏诊断摘要;提交前会弹系统确认卡片,创建后可继续协助源码修复);' +
'传 category=handoff → 把消息投递到一个【已知 session】, 或为外部业务对象(issue / jira / pr)新建专属 session' +
'(send_to_session, 供 skill 绑定业务对象路由用)。' +
'⚠️ 开协同 / 多 agent / 派 worker 干活 / 拉 agent review, 请用 cindy_orca 的 start_team / create_worker, 不要用 handoff(它不组队、不进协同分组)。' +
diff --git a/packages/lizi-mcps/src/xdt-helper/capabilities.ts b/packages/lizi-mcps/src/xdt-helper/capabilities.ts
index 272adfb3b9..fef1a6cbb4 100644
--- a/packages/lizi-mcps/src/xdt-helper/capabilities.ts
+++ b/packages/lizi-mcps/src/xdt-helper/capabilities.ts
@@ -113,10 +113,12 @@ export const CAPABILITIES: readonly CapabilityEntry[] = [
title: '官方反馈提交',
oneLiner: '/issue 命令或自然语言发起,agent 对话式整理后经确认卡片提交 GitHub issue。',
detail: [
- '用户输入 /issue(可带初始描述)或直接说"帮我提个 issue",agent 先追问澄清细节,',
- '整理出结构化标题与正文后调用 submit_github_issue(cindy_helper 的 feedback 类目)。',
+ '用户输入 /issue(可带初始描述)或直接说"帮我提个 issue",agent 先追问缺失或含糊的细节,不够清楚时不会急着提交。',
+ 'Bug 会尽量补齐复现步骤、期望/实际行为、复现频率、已尝试方法和用户同意公开的脱敏诊断摘要;功能建议会澄清使用场景、当前痛点和期望结果。',
+ '整理出结构化标题与正文后调用 submit_github_issue(cindy_helper 的 feedback 类目),系统会尽量隐藏常见密钥、个人路径和邮箱。',
'提交前 App 内弹系统确认卡片,用户可编辑标题/正文、确认或取消;',
- `客户端版本 / OS / 界面语言由系统自动附加,最终创建到 ${BRAND_NAME} 官方 GitHub 仓库。`,
+ '不需要安装或配置 GitHub 插件:默认由 Cindy 官方 Bot 提交;当前已配置且可用的 GitHub 账号只作为确认卡里的额外身份选项。',
+ `客户端版本 / OS / 界面语言由系统自动附加,最终创建到 ${BRAND_NAME} 官方 GitHub 仓库。创建后会返回 issue 链接,并可继续协助用户从源码复现、修复 Bug、开发功能和准备 PR。`,
].join(' '),
},
{
diff --git a/packages/lizi-mcps/src/xdt-helper/submit_github_issue.ts b/packages/lizi-mcps/src/xdt-helper/submit_github_issue.ts
index 9ffd068524..6c78375388 100644
--- a/packages/lizi-mcps/src/xdt-helper/submit_github_issue.ts
+++ b/packages/lizi-mcps/src/xdt-helper/submit_github_issue.ts
@@ -4,9 +4,12 @@
* 流程上的确定性约束全部由 host 侧代码保证(规则 9):
* - 工具被调用后 host 会在 App 内弹出系统确认卡片,用户可编辑/确认/取消,
* 确认是通往提交的唯一路径(handler 在 main 进程挂起等待)。
+ * - agent 初稿进入确认卡前会做高置信度隐私脱敏;确认卡仍展示最终公开内容,
+ * 用户编辑后的内容视为用户明确确认。
* - host 在确认前确定并展示真实提交身份;确认后失败也不会静默切换身份。
* - 环境信息(客户端版本 / 版本区域 / OS / 界面语言)由 host 自动附加,agent 无法也
* 无需填写。版本区域(CN / Dev;默认 global 不标注)是构建期身份,agent 更猜不到。
+ * - 成功返回 issue 链接及开源协作提示,让 agent 可以继续帮助用户从源码参与修复。
* 本文件只承载工具 schema + 描述(对 LLM 的流程指引)和 host 回调的 payload 整形。
*/
@@ -25,6 +28,8 @@ export interface SubmitGithubIssueHostOk {
finalTitle: string;
/** 用户在确认卡片里改过 title/body/type 时为 true。 */
editedByUser: boolean;
+ /** agent 初稿进入确认卡前是否命中过常见敏感信息并被自动替换。 */
+ privacyRedacted?: boolean;
}
export type SubmitGithubIssueHostErrorCode =
@@ -64,11 +69,13 @@ export interface SubmitGithubIssueDeps {
const DESCRIPTION = [
`把整理好的用户反馈提交为 ${BRAND_NAME} 官方仓库的 GitHub issue。`,
'【流程硬约束】',
- '1) 调用前必须先与用户对话澄清:反馈类型(bug / 功能建议)、现象、复现步骤或使用场景、期望行为——信息不完整时先追问,不要急着调用。',
- '2) 本工具被调用后会在 App 内弹出系统确认卡片,用户可以编辑标题/正文并确认或取消;最终提交内容以用户确认的版本为准(返回的 final_title 可能与你传入的不同)。',
- '3) 提交身份由系统确定并显示在确认卡片:已启用 Cindy GitHub 且绑定有效账号时,用该 GitHub 用户本人身份提交(受其 token 仓库权限约束);未绑定或插件不可用时,显示并使用 Cindy 平台代提交。用户身份一旦确认,提交失败不会静默降级成平台身份。',
- '4) errorCode 语义: USER_CANCELLED = 用户主动取消了本次提交,如实告知即可,不要换参数自动重试; CONFIRM_TIMEOUT = 确认卡片超时无人响应(用户可能不在电脑前),告知用户可以再说一声重新发起; AUTH_NOT_READY / NETWORK_ERROR / SERVER_ERROR / HOST_NOT_READY = 提交失败,如实转告原因,不存在任何绕过确认、权限或失败的提交途径。',
- '5) 环境信息(客户端版本 / 版本区域 / OS / 界面语言)由系统自动附加;GitHub 作者就是确认卡片显示的身份——都无需也无法由你填写。版本区域是用户装的哪个区域构建(CN / Dev,默认的 global 构建不标注),构建期烘焙,你猜不到也不要写。',
+ '1) 调用前必须先与用户对话澄清,只针对缺失或含糊的信息提问,不要重复已回答的问题,也不要急着调用。bug 至少确认:现象、复现步骤、期望行为、实际行为、复现频率、已尝试的解决办法;feature 至少确认:使用场景、当前痛点或替代方案、期望结果和建议范围。用户不知道的内容标记为未知,不要猜。',
+ '2) Bug 可以主动收集用户提供的错误摘要、经过脱敏的日志片段和必要截图说明,但先解释会公开到 GitHub,取得用户同意后再纳入正文。优先摘要而不是整段原始日志;不要提交令牌、密码、邮箱、个人路径、内部域名、私有代码或与问题无关的文件内容。系统会在确认卡前自动隐藏常见密钥、个人路径和邮箱,但仍要让用户检查最终正文。',
+ '3) 本工具被调用后会在 App 内弹出系统确认卡片,用户可以编辑标题/正文并确认或取消;最终提交内容以用户确认的版本为准(返回的 final_title 可能与你传入的不同)。确认前不得创建 issue。',
+ '4) Cindy 官方 Bot 是默认且始终可用的提交身份,不要求用户安装插件或配置 GitHub。仅当系统实时验证到可用的 Cindy GitHub 账号时,确认卡才额外提供“用本人账号提交”的选项(受其 token 仓库权限约束)。用户确认身份后,提交失败不会静默切换身份。',
+ '5) errorCode 语义: USER_CANCELLED = 用户主动取消了本次提交,如实告知即可,不要换参数自动重试; CONFIRM_TIMEOUT = 确认卡片超时无人响应(用户可能不在电脑前),告知用户可以再说一声重新发起; AUTH_NOT_READY / NETWORK_ERROR / SERVER_ERROR / HOST_NOT_READY = 提交失败,如实转告原因,不存在任何绕过确认、权限或失败的提交途径。',
+ '6) 环境信息(客户端版本 / 版本区域 / OS / 界面语言)由系统自动附加;GitHub 作者就是确认卡片显示的身份——都无需也无法由你填写。版本区域是用户装的哪个区域构建(CN / Dev,默认的 global 构建不标注),构建期烘焙,你猜不到也不要写。',
+ `7) 提交成功后告诉用户 issue 编号和链接,说明 ${BRAND_NAME} 是开源软件,并询问用户是否愿意继续参与:可以协助其通过源码复现、修复 Bug、开发功能、补测试并准备 PR。`,
].join('\n');
const D_TITLE =
@@ -76,12 +83,20 @@ const D_TITLE =
'禁止截断正文凑标题,禁止「用户反馈」「一个 bug」这类空泛词。';
const D_BODY =
- 'Markdown 正文。bug 用「## 现象 / ## 复现步骤 / ## 期望行为 / ## 实际行为」结构;' +
- 'feature 用「## 使用场景 / ## 诉求 / ## 建议方案」结构,信息来自与用户的对话。' +
+ 'Markdown 正文。bug 优先用「## 现象 / ## 复现步骤 / ## 期望行为 / ## 实际行为 / ## 复现频率 / ## 已尝试」结构;' +
+ 'feature 优先用「## 使用场景 / ## 当前痛点 / ## 诉求 / ## 建议方案」结构,信息来自与用户的对话。' +
+ '诊断信息只放用户同意公开的、经过脱敏的摘要;缺失信息写“用户未知”或省略,不要编造。' +
'不要写环境信息(客户端版本 / 版本区域 / OS / 界面语言)和提交人——系统会自动附加。';
const D_TYPE = 'bug=缺陷, feature=功能建议。决定 GitHub label。';
+const OPEN_SOURCE_FOLLOW_UP = {
+ repository_url: 'https://github.com/makecindy/cindy',
+ license: 'Apache-2.0',
+ invitation:
+ 'Cindy is open source. If the user is interested, offer help with reproducing the issue, editing the source, adding tests, and preparing a pull request.',
+} as const;
+
export function registerSubmitGithubIssueTool(
registry: XdtHelperToolRegistry,
deps: SubmitGithubIssueDeps,
@@ -121,6 +136,8 @@ export function registerSubmitGithubIssueTool(
issue_url: result.issueUrl,
final_title: result.finalTitle,
edited_by_user: result.editedByUser,
+ privacy_redacted: result.privacyRedacted === true,
+ open_source: OPEN_SOURCE_FOLLOW_UP,
});
},
});