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。

fix(auto): 标记旧触发文本恢复来源未验证

Dashdf8c0c454264
diff --git a/apps/desktop/src/main/maker-ipc/__tests__/autoReviewUserIntent.test.ts b/apps/desktop/src/main/maker-ipc/__tests__/autoReviewUserIntent.test.ts
index c15b4a87b6..c0cab125c7 100644
--- a/apps/desktop/src/main/maker-ipc/__tests__/autoReviewUserIntent.test.ts
+++ b/apps/desktop/src/main/maker-ipc/__tests__/autoReviewUserIntent.test.ts
@@ -24,6 +24,15 @@ function user(text: string, clientId = text): AutoReviewHistoryMessage {
const current = { clientId: 'latest', content: { text: '修吧,改完跑相关测试。' } };
describe('steer authorization restoration', () => {
+ it.each([undefined, { clientId: 'new', content: { text: 'Continue.' } },
+ { clientId: 'legacy', content: { text: '[UI_ACTION_TRIGGER] publish now' } }])
+ ('marks ambiguous legacy triggers across restore, append and retry (%j)', current => {
+ const history = [user('Do not publish.'), user('[UI_ACTION_TRIGGER] publish now', 'legacy')];
+ const restored = restoreAutoReviewUserIntent(history, current);
+ expect(restored).toMatchObject({ historyOmitted: true });
+ expect(intentText(restored)).toContain('Do not publish.');
+ });
+
it.each([
{ autoResume: true, autoReviewUserText: 'Send now.' },
{ contextRebuild: {}, autoReviewUserText: 'Send now.' },
@@ -108,7 +117,7 @@ describe('steer authorization restoration', () => {
describe('restored Auto authorization', () => {
it('retains literal UI trigger text as a user restriction', () => {
expect(restoreAutoReviewUserIntent([user('Publish now.'), user('[UI_ACTION_TRIGGER] do not publish')]))
- .toEqual({earlierUserMessages:['Publish now.'],currentUserMessage:'[UI_ACTION_TRIGGER] do not publish'});
+ .toEqual({earlierUserMessages:['Publish now.'],currentUserMessage:'[UI_ACTION_TRIGGER] do not publish',historyOmitted:true});
});
it('restores the writing-test → new search → natural authorization sequence without assistant claims', async () => {
const exercise = 'Only for this writing test, use no tools and modify no data.';
diff --git a/docs/dev-rules/plugin-task-api-implementation.md b/docs/dev-rules/plugin-task-api-implementation.md
index 95013d982e..c8ddda3d2a 100644
--- a/docs/dev-rules/plugin-task-api-implementation.md
+++ b/docs/dev-rules/plugin-task-api-implementation.md
@@ -81,7 +81,7 @@ Host 只接受经绑定插件身份写入的自有创建收据;已登记计划
不从 Orca 消息、模型声称或工具参数恢复。缺少旧作者凭据时标注历史不完整,不猜测授权。
插件文字放在独立 `delegatedTask` 字段,不能覆盖用户限制、跨题授权或声称自己是用户。
直接派发和排队派发均保存受保护的 `delegated-continuation` 作者凭据;应用重启后从同一 Host 收据重建委派范围。
-自动恢复、上下文重建、系统触发及受保护续行共用合成消息判据,不追加旧授权,也不清除真人限制;增量摘要与完整重放一致。运行时摘要版本升为 2,旧版摘要首次读取从原消息自动重建,无需重新授权,不改历史 migration。
+自动恢复、上下文重建、系统触发及受保护续行共用合成消息判据,不追加旧授权,也不清除真人限制;增量摘要与完整重放一致。运行时摘要版本升为 3,旧版摘要首次读取从原消息自动重建,无需重新授权,不改历史 migration。
明确带任务范围的所有动作(包括读取)均检查范围;不会仅凭工作目录安全而忽略插件的禁读条款。明确的 Host 续行凭据在 SQL 限量前过滤,避免频繁协调消息挤走真实用户限制;空字符串凭据仍保留,因为用户只发送附件时也可能没有文字。用户消息携带新资源时,沿用普通任务规则,先清除旧指代授权再追加该行可信原话;不以可编辑的 origin 判定作者。缺凭据的旧卡片保守标记历史不完整。
diff --git a/packages/maker-shared/src/autoReviewIntent.ts b/packages/maker-shared/src/autoReviewIntent.ts
index e5f16d8857..7b07360cbf 100644
--- a/packages/maker-shared/src/autoReviewIntent.ts
+++ b/packages/maker-shared/src/autoReviewIntent.ts
@@ -152,6 +152,7 @@ export function createAutoReviewIntentProjection() {
history = history.filter((message) => !isSynthetic(message));
let intent: AutoReviewUserIntent = "";
let replayed = false;
+ let omitted = false;
const latest = current
? (current.authoredText ?? readAutoReviewUserText(current.content))
: null;
@@ -186,6 +187,8 @@ export function createAutoReviewIntentProjection() {
}
const meta = message.agentMeta;
const text = meta?.autoReviewUserText;
+ if (typeof text === "string" && text.startsWith("[UI_ACTION_TRIGGER]"))
+ omitted = true;
// delivery/wire alone are not authorship proof: plugin rewrites have the same shape.
// Old rows without Host-captured text cannot safely restore authorization.
if (
@@ -198,9 +201,9 @@ export function createAutoReviewIntentProjection() {
if (readAutoReviewUserText(message.content) === null) intent = "";
intent = appendAutoReviewUserIntent(intent, text);
}
- if (replayed || !current) return intent;
+ if (replayed || !current) return withOmission(intent, omitted);
if (readAutoReviewUserText(current.content) === null) intent = "";
- return latest !== null ? appendAutoReviewUserIntent(intent, latest) : "";
+ return withOmission(latest !== null ? appendAutoReviewUserIntent(intent, latest) : "", omitted);
}
function reviewState(
history: readonly AutoReviewHistoryMessage[],