Skip to content

fix(agent): prioritize Cindy Skills before downstream Skills - #1650

Merged
MagicLizi merged 5 commits into
makecindy:mainfrom
zqchris:skill-precedence
Aug 4, 2026
Merged

fix(agent): prioritize Cindy Skills before downstream Skills#1650
MagicLizi merged 5 commits into
makecindy:mainfrom
zqchris:skill-precedence

Conversation

@zqchris

@zqchris zqchris commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

这次改了什么

摘要

修复 #1645:Claude / Codex 会话现在在高于具体 Skill 内容的 Cindy system 段中,统一遵守通用来源优先级。

当 Cindy 管理、用户或项目来源的 Skill 与下游 harness / plugin Skill 对同一工作同时适用时:

  • 先加载并遵守适用的 Cindy 侧 Skill;
  • 下游 Skill 只能补充,不能替代、弱化或绕过前置工作流与安全门禁;
  • 显式点名下游 Skill 也不豁免 Cindy 侧规则;
  • 不冲突的 Skill 继续正常共存。

上一版按具体 Skill、插件来源、selector 和本机路径绑定 Codex overlay 的实现已整体撤回。最终产品代码不认识任何具体 Skill、插件、marketplace、selector 或用户目录,也不修改下游插件包。

Skill 是否与当前工作重叠属于模型侧的语义判断;现有 Claude / Codex harness 没有通用的 source-aware invocation hook,也没有下发结构化 provenance 字段。因此本 PR 把来源契约放在高于后续 Skill 内容的静态 system 指令层,让模型读各 harness 列 Skill 时本来就带的来源标注(插件 / marketplace / 内置命名空间为下游,其余归 Cindy 自有来源),并在清单没给出可用标注时 fail-closed 按下游处理、仍先跑 Cindy 侧 Skill。不扩写 capability routing 的具体能力表。

变更类型

  • feat 新功能
  • fix 缺陷修复
  • refactor / perf 重构或性能优化
  • docs / test / chore 文档、测试或工程维护
  • 其他:

范围

UI 变化

不涉及。

  • 引用的设计规范:不涉及。

怎么验证的

自动验证

pnpm --filter desktop exec vitest run \
  src/main/maker-host/__tests__/runtimeConfigs.test.ts \
  src/main/maker-host/__tests__/piSystemPrompt.test.ts \
  --pool=threads --maxWorkers=1
结果:2 个文件、5 tests,通过(最终 head 0434598e)

pnpm --filter desktop run --if-present typecheck
结果:通过(最终 head)

pnpm --filter desktop exec eslint src/main/maker-host/runtime-configs.ts \
  src/main/maker-host/__tests__/runtimeConfigs.test.ts
结果:通过(最终 head)

pnpm check:dco
结果:通过(3 个签名 commit,2 个 merge commit 豁免)

git diff --check
结果:通过

最终 diff 单例标识 / 本机路径扫描
结果:无命中

手工验证

不涉及 UI。已检查最终 compose 结果:Claude 与 Codex 均包含来源优先级段;Pi 仍只组合原有 host + Pi 专属段。

未执行的验证

最后一版(0434598e)只改了一个 system prompt 的 Markdown 文本和对应断言,未再本地重跑全仓 pnpm test:unit;完整门禁以本 PR 的 client-ci 结果为准。上一版 117b307 时曾本地跑过 pnpm test:unit -- --workspace-concurrency=1,通过。

未对真实 Claude / Codex 模型做线上 A/B。系统段的装配、顺序与作用范围由确定性单测覆盖;真实模型行为继续由 PR 自动 review 与正式版验收观察。

风险

风险分类

  • 无已知风险
  • SQLite / migration
  • system prompt
  • 协议兼容
  • 权限 / 安全 / 用户数据
  • 存量插件兼容(批准状态 / 指纹 / manifest 校验 / 安装布局 / 包格式)
  • 原生层 / fingerprint / OTA
  • 跨平台差异
  • 其他:

影响与回滚

  • system prompt 改动已由仓库维护者于 2026-08-04 明确确认。
  • 行为影响:只改变 Claude / Codex 对重叠 Skill 来源的优先关系;不改变工具、MCP、事件翻译、权限或插件内容。
  • 缓存影响:新增段为 808 字节静态文本,版本升级后会产生一次新的 prompt 前缀;同一版本内内容、位置和顺序恒定,不引入逐回合 cache fragmentation。
  • 性能影响:不增加 IO、网络请求或热路径判断。
  • 回滚 / 降级方式:回滚本 PR 即移除该静态来源规则;无数据迁移或用户配置恢复步骤。

提交前检查

  • 已 review 完整 diff
  • 每个任务 commit 都带 DCO 签名;merge commit 按规则豁免
  • UI 改动已在「UI 变化」注明引用的设计规范章节(不涉及 UI)
  • 未提交凭证、令牌或授权文件
  • 已补充必要文档(本次行为契约即独立 prompt 文件)
  • 已确认测试结果或说明未执行原因

Copilot AI lite review requested due to automatic review settings August 4, 2026 07:19
@zqchris
zqchris requested a review from a team as a code owner August 4, 2026 07:19
@greptile-apps

greptile-apps Bot commented Aug 4, 2026

Copy link
Copy Markdown

Greptile Summary

本 PR 为 Claude 与 Codex 的 system prompt 增加统一的 Skill 来源优先级契约,同时明确保持 Pi 的 prompt 组成不变。

  • 新增通用的 Cindy 侧与下游 Skill 优先级提示词
  • 按“产品身份 → 来源优先级 → agent 专属段”的顺序组装 Claude/Codex prompt
  • 增加 Claude、Codex 注入规则及 Pi 隔离行为的回归测试

Confidence Score: 5/5

当前变更看起来可以安全合并。

未发现仍需阻止合并的失败。

Important Files Changed

Filename Overview
apps/desktop/src/main/maker-host/runtime-configs.ts 将静态 Skill 来源优先级段加入 Claude 与 Codex 的 system prompt 组装流程,并保持产品身份段位于最前。
apps/desktop/src/main/maker-host/skill-source-precedence-prompt.md 定义 Cindy 侧 Skill 优先于重叠下游 Skill 的通用来源级契约及无来源标注时的处理方式。
apps/desktop/src/main/maker-host/tests/runtimeConfigs.test.ts 覆盖 Claude/Codex 的规则注入、关键契约文本及具体 Skill、selector 和本机路径不泄漏的约束。
apps/desktop/src/main/maker-host/tests/piSystemPrompt.test.ts 验证 Claude/Codex 专属的来源优先级段不会扩展到 Pi prompt。

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Identity[产品身份段] --> Precedence[Skill 来源优先级段]
  Precedence --> Claude[Claude 专属段]
  Precedence --> Codex[Codex 专属段]
  Identity --> Pi[Pi 专属段]
  Pi -. 不注入 .-> Precedence
Loading

Reviews (3): Last reviewed commit: "fix: make Skill source precedence resolv..." | Re-trigger Greptile

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea4e0a5c35

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/main/maker-host/capability-routing.ts Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Not ready to approve

新增的下游 SKILL.md 注入内容会暴露本机绝对路径且 explicitSelectors 存在易碰撞的短选择器,属于需要先收敛的安全边界问题。

Once you've addressed the issues Copilot identified, you can request another Copilot review.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

该 PR 修复在 Cindy workdir 内下游 Codex 官方 GitHub 插件 Skill(github:yeet)可能抢先生效、从而绕过 Cindy git-workflow 工作流门禁的问题;通过在 Cindy 隔离的 Codex plugin overlay 中引入“前置 Skill 绑定”策略,确保下游 Skill 只能补充、不能替代 Cindy 的前置规则。

Changes:

  • 在 capability routing policy 中新增 prerequisiteSkills 类型与路由字段,表达“下游 Skill 需先绑定 Cindy-owned 前置 Skill”的依赖关系。
  • Desktop 侧为 github@openai-curated / github@openai-curated-remotegithub:yeet 设为 explicit-only,并在隔离 overlay 的下游 SKILL.md 前注入 git-workflow(去 frontmatter)正文,同时把前置 Skill 内容 hash 纳入快照以支持自愈重建。
  • 新增回归测试覆盖:provenance 精确匹配、BOM/CRLF 保真、内容变化/删除后的 fail-closed 与自愈重建。
File summaries
File Description
packages/maker-core/src/types/capability-routing.ts 为 capability routing 增加 prerequisiteSkills 类型与字段,支持“前置 Skill”策略表达。
apps/desktop/src/main/maker-host/codex-global-plugins.ts 在 Codex 插件隔离 overlay 写入前置 Skill block,并把前置 Skill 内容 hash 纳入快照用于自愈重建。
apps/desktop/src/main/maker-host/capability-routing.ts 构建 Desktop routing policy:当 git-workflow 存在时,为 github:yeet 注入 prerequisite + explicit-only。
apps/desktop/src/main/maker-host/auth-adapters.ts 在 shared skills fan-out 成功后刷新 routing policy,确保 git-workflow 安装状态能影响路由。
apps/desktop/src/main/tests/codexGlobalPlugins.test.ts 覆盖前置 block 注入、自愈重建、BOM/CRLF/frontmatter 处理等行为。
apps/desktop/src/main/tests/capabilityRouting.test.ts 新增 routing policy 构建/刷新测试,验证仅在 git-workflow 存在时绑定 GitHub publish 路由。
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 2
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment thread apps/desktop/src/main/maker-host/codex-global-plugins.ts Outdated
Comment thread apps/desktop/src/main/maker-host/capability-routing.ts Outdated
@MagicLizi MagicLizi added status:threads-open 还有未 resolve 的评审讨论(review-pr 自动维护,仅展示) touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) labels Aug 4, 2026
@MagicLizi

Copy link
Copy Markdown
Contributor

@zqchris 👋 这个 PR 还有 3 条 review conversation 没 resolve(apps/desktop/src/main/maker-host/capability-routing.ts / apps/desktop/src/main/maker-host/codex-global-plugins.ts),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

zqchris added 2 commits August 4, 2026 16:52
Signed-off-by: zqchris <chrisz83@gmail.com>
Signed-off-by: zqchris <chrisz83@gmail.com>
Copilot AI review requested due to automatic review settings August 4, 2026 08:57
@zqchris zqchris changed the title fix(agent): enforce Cindy Skill prerequisites fix(agent): prioritize Cindy Skills before downstream Skills Aug 4, 2026
Copilot AI previously approved these changes Aug 4, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Ready to approve

变更范围小且有针对性单测覆盖,当前仅有注释表述与实际文件内容不一致的轻微问题需要可选修正。

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details

Suppressed comments (1)

apps/desktop/src/main/maker-host/runtime-configs.ts:29

  • 这里的注释把 hostSystemPrompt 描述为“产品身份”,但当前仓库内的 host-system-prompt.md 是空文件(composeHostPrompt 运行时会被过滤掉)。建议把注释改成更贴近实际的“host 共用段”,避免误导后续读代码的人以为身份段一定来自该文件。
// Claude / Codex 的 host system prompt:产品身份 → Skill 来源优先级 → agent 专属段。
// Skill 优先级不放 host-system-prompt.md,避免把 #1645 的 Claude/Codex 行为扩到 Pi。
  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 117b3075a2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/main/maker-host/skill-source-precedence-prompt.md Outdated
@MagicLizi

Copy link
Copy Markdown
Contributor

@zqchris 👋 这个 PR 还有 1 条 review conversation 没 resolve(apps/desktop/src/main/maker-host/skill-source-precedence-prompt.md),auto-review 因此暂时跳过、没法继续审查 / 合并。

如果你已经按评论改完或回应了,请到对应 thread 上点 Resolve conversation;全部 resolve 后,下一轮 auto-review 会自动重新审查这个 PR。

@MagicLizi MagicLizi removed touches:core 改动碰到架构核心路径(review-pr 自动维护,仅展示) status:threads-open 还有未 resolve 的评审讨论(review-pr 自动维护,仅展示) labels Aug 4, 2026
Codex review 指出上一版 prompt 引用了 available-Skills 里并不存在的
provenance 字段,同时又禁止一切按名称/命名空间推断,导致这条来源优先级
规则对模型不可执行。

改为让模型读清单里已有的来源标注(插件 / marketplace / 内置命名空间为
下游,其余归 Cindy 自有来源),并在无可用标注时 fail-closed 视作下游、
仍先跑 Cindy 侧 Skill。产品代码依旧只表达来源级规则,不含任何具体
Skill、插件、marketplace、selector 或本机路径。

Signed-off-by: zqchris <chrisz83@gmail.com>
Copilot AI review requested due to automatic review settings August 4, 2026 13:21
Copilot AI dismissed their stale review, a newer Copilot review was requested August 4, 2026 13:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Ready to approve

变更范围聚焦且有针对性单测覆盖注入与隔离边界,未发现会影响运行时行为正确性的阻塞问题。

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Review details

Suppressed comments (1)

apps/desktop/src/main/maker-host/tests/runtimeConfigs.test.ts:107

  • 这里用整段 promptnot.toMatch(/\$[\w:-]+|\/(?:Users|home)\/[A-Z]:\\/) 会把断言范围扩到 host identity / agent-specific prompt;后续如果 Claude/Codex 专属段需要提到 $HOME$PATH 等环境变量示例或其它合法 $... 文本,会导致与本测试目标(仅保证“Skill source precedence”段不包含具体 selector/本机路径)无关的脆弱失败。建议把负向断言收窄到 ## Skill source precedence 这一段落本身。
        /no usable source\s+label, treat the Skill as downstream and still run the applicable Cindy-side Skill first/u,
      );
      // 产品侧只表达来源级规则:不得出现具体 selector、Skill 名或本机路径。
      expect(prompt).not.toMatch(/\$[\w:-]+|\/(?:Users|home)\/|[A-Z]:\\/u);
    }
  • Files reviewed: 4/4 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0434598e5d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/desktop/src/main/maker-host/runtime-configs.ts
@zqchris

zqchris commented Aug 4, 2026

Copy link
Copy Markdown
Contributor Author

补一条 CI 说明,避免误判:本 PR 的 Windows unit tests (1/2) 失败不是本 PR 引入的,是从 main 继承的。

失败项只有一个文件:

FAIL src/renderer/__tests__/sentPastedTextPreview.test.ts
  > UserMessage pasted-text chip wiring > S3 测量镜像与收起态渲染共用同一份投影正文
AssertionError: expected '/**\r\n * UserMessage\r\n * ---------…'
  to match /longMessageCollapsed\s*\n\s*\? renderContent\(\n\s*displayBubbleBody,/
Test Files  1 failed | 811 passed (812)

main 上同样红:

run head 结论
2026-08-04T13:15Z 44eff0d13 failure
2026-08-04T12:46Z 789f417c7 failure
2026-08-04T12:30Z 4c4baf2c0 success

回归点是 #1680789f417c7)改写的这两条源码文本断言:

expect(source).toMatch(
  /longMessageCollapsed\s*\n\s*\? renderContent\(\n\s*displayBubbleBody,/,
);
expect(source).toContain('bubbleAgentReferences,\n                              false,');

两条都把 \n 当字面换行匹配源码文本。Windows checkout 是 CRLF,实际读到的是 \r\n,所以 \s*\ntoContain('...,\n ...') 在 Windows 上必然不匹配 —— macOS / Linux 全绿、只有 Windows 红,特征吻合。

本 PR 只改了一段 system prompt 的 Markdown 文本和 runtimeConfigs.test.ts 的对应断言,与 renderer 无关。已跑:runtimeConfigs.test.ts + piSystemPrompt.test.ts 定向通过(5 tests)、desktop typecheck 通过、eslint 通过、check:dco 通过。

这条 Windows 红需要在 main 上单独修(把两条断言改成 CRLF 无关的形式),不在本 PR 范围内。

@MagicLizi MagicLizi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

审查通过,零阻断项。两条 P2 建议(prompt 措辞、测试 DRY)均非阻断。架构正确:precedence prompt 正确插入 host 与 agent-specific 之间,Pi 路径正确排除,无运行时文件 I/O 风险。

@MagicLizi
MagicLizi merged commit 0a5fecb into makecindy:main Aug 4, 2026
8 of 10 checks passed
@MagicLizi

Copy link
Copy Markdown
Contributor

Skill 来源优先级终于有了确定性的落地——从此 Cindy 侧规则不再被下游 harness 插件悄悄绕过,而且整个实现干净到只有一个 .md 静态注入,零运行时 I/O。合并了 🎉

wykris added a commit to wykris/cindy that referenced this pull request Aug 5, 2026
* main: (36 commits)
  fix(mobile): 修复 iOS 推送点击任务跳转 (makecindy#1721)
  fix(desktop): stop retrying unavailable cursor styling (makecindy#1722)
  fix(codex): 强制退役时只对真实在飞的会话广播终态错误 (makecindy#1720)
  fix: 修复 Cindy Browser 与 Codex 浏览器能力冲突 (makecindy#1706)
  fix(agent): 统一 continuation 的执行结束与正文投影语义 (makecindy#1703)
  fix: 为 PI 接通离线 grep/find/ls 工具 (makecindy#1718)
  fix(codex): 熔断切模型后的上下文压缩风暴 (makecindy#1717)
  fix(desktop): 远程发送改为乐观收口 (makecindy#1615)
  feat(worktree): 新建 Worktree 使用 Cindy 分支命名空间 (makecindy#1682)
  fix(desktop): 修复新建对话语音输入无法停止 (makecindy#1663)
  fix: KIMI(kimi-k3) Claude Code 下空消息腐蚀——转录归一化+响应流撞车改名自愈 (makecindy#1327)
  fix(desktop): 修复远程任务侧边栏加载闪烁 (makecindy#1713)
  refactor(mobile): Android bundle 不再引用 expo-notifications 原生模块 (makecindy#1667)
  fix(codex): 屏蔽重复的 Sky Computer Use 能力 (makecindy#1693)
  feat(ghost): 插件新增权限后引导用户重新授权 (makecindy#1695)
  perf(desktop): 加速任务切换渲染 (makecindy#1684)
  fix(agent): prioritize Cindy Skills before downstream Skills (makecindy#1650)
  test(desktop): 修复 sentPastedTextPreview 源码扫描在 Windows 上的 CRLF 误红
  fix(browser): 保留 OAuth 弹窗浏览上下文 (makecindy#1690)
  fix: 统一消息 chip 的乐观态与收起态渲染 (makecindy#1680)
  ...

Signed-off-by: Kris <406048119@qq.com>

# Conflicts:
#	apps/desktop/src/renderer/__tests__/chatInputSessionFocus.test.ts
#	apps/desktop/src/renderer/features/cc-agent/sidebar/SessionItem.tsx
wykris added a commit to wykris/cindy that referenced this pull request Aug 6, 2026
* main: (36 commits)
  fix(mobile): 修复 iOS 推送点击任务跳转 (makecindy#1721)
  fix(desktop): stop retrying unavailable cursor styling (makecindy#1722)
  fix(codex): 强制退役时只对真实在飞的会话广播终态错误 (makecindy#1720)
  fix: 修复 Cindy Browser 与 Codex 浏览器能力冲突 (makecindy#1706)
  fix(agent): 统一 continuation 的执行结束与正文投影语义 (makecindy#1703)
  fix: 为 PI 接通离线 grep/find/ls 工具 (makecindy#1718)
  fix(codex): 熔断切模型后的上下文压缩风暴 (makecindy#1717)
  fix(desktop): 远程发送改为乐观收口 (makecindy#1615)
  feat(worktree): 新建 Worktree 使用 Cindy 分支命名空间 (makecindy#1682)
  fix(desktop): 修复新建对话语音输入无法停止 (makecindy#1663)
  fix: KIMI(kimi-k3) Claude Code 下空消息腐蚀——转录归一化+响应流撞车改名自愈 (makecindy#1327)
  fix(desktop): 修复远程任务侧边栏加载闪烁 (makecindy#1713)
  refactor(mobile): Android bundle 不再引用 expo-notifications 原生模块 (makecindy#1667)
  fix(codex): 屏蔽重复的 Sky Computer Use 能力 (makecindy#1693)
  feat(ghost): 插件新增权限后引导用户重新授权 (makecindy#1695)
  perf(desktop): 加速任务切换渲染 (makecindy#1684)
  fix(agent): prioritize Cindy Skills before downstream Skills (makecindy#1650)
  test(desktop): 修复 sentPastedTextPreview 源码扫描在 Windows 上的 CRLF 误红
  fix(browser): 保留 OAuth 弹窗浏览上下文 (makecindy#1690)
  fix: 统一消息 chip 的乐观态与收起态渲染 (makecindy#1680)
  ...

Signed-off-by: Kris <406048119@qq.com>

# Conflicts:
#	apps/desktop/src/renderer/__tests__/chatInputSessionFocus.test.ts
#	apps/desktop/src/renderer/features/cc-agent/sidebar/SessionItem.tsx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants