magpie icon indicating copy to clipboard operation
magpie copied to clipboard

library: 未安装 Codex CLI 仅登录(~/.codex/auth.json)时,资源库指令仍误把 Codex 列为目标

Open TomXPRIME opened this issue 1 week ago • 3 comments

问题描述

本地没有安装 Codex CLI(也没有安装 Codex Desktop 或 Cindy),只是做过 Codex 登录(~/.codex/ 下仅有 auth.json),但在 资源库(Library)→ 指令 等页面中仍然出现了 Codex 目标,并且同步技能时还在 ~/.codex/skills/ 下创建了技能链接。与此同时,Agents 页面和 magpie ls 中均正确未列出 Codex。

环境信息

  • OS: Windows
  • Magpie 版本: v0.1.4947
  • 本地状态:
    • where codex 无结果(未安装 Codex CLI)
    • ~/.codex/ 中仅包含 auth.json(登录产生)以及 Magpie 同步产生的 skills/ 目录
    • magpie ls 中无 Codex

原因定位

  1. internal/agent/codex.go 中 codex() 为 Codex 设置了 a.shared = a.Name 和 a.sharedApp = cindyCodexHere(同时配置了 signIn: "auth.json")。
  2. 在 internal/agent/agent.go 中:
    • configHere() 调用 agentDir(a.Dir, append([]string{a.signIn}, a.readHere...)...),正确忽略了 auth.json,因此 a.Detected() 返回 false;
    • 但 SharedHere() 调用的是 agentDir(a.Dir),未传入 a.signIn("auth.json")和 a.readHere:
      func (a *Agent) SharedHere() bool {
          return a.shared != "" && a.WSL == "" && a.Dir != "" && !Taken(a.Dir) && (agentDir(a.Dir) || a.SharedRead())
      }
      
    • 因此只要 ~/.codex/auth.json 存在,agentDir("~/.codex") 就会返回 true,导致 SharedHere() 误判为 true。
  3. 接着在 internal/library/targets.go 的 targetsAsleep() 中:
    • !a.Detected() && !a.SharedHere() 为 false(被 SharedHere() == true 放行);
    • 又因为 internal/agent/install.go 中 CLIMissing() 在 !a.Detected() 时直接返回 false,所以 !gone && a.CLIMissing() && !a.SharedRead() 也未能拦截。
    • 最终 Codex 泄漏进 library.Targets(),出现在资源库指令/技能目标列表中。

期望行为 / 修复建议

  • 当本地未安装 Codex CLI/应用(也未安装共享 ~/.codex 的 Cindy)、仅因登录存在 ~/.codex/auth.json 时,Codex 不应出现在资源库(指令/技能/MCP)目标中。
  • 建议在 Agent.SharedHere() 中调用 agentDir 时与 configHere() 保持一致,传入 a.signIn 与 a.readHere(忽略仅由登录产生的文件)。

TomXPRIME avatar Nov 27 '26 11:11 TomXPRIME

On it: checking the chain in the source (SharedHere vs configHere, targetsAsleep) and fixing it for every agent with a shared folder, including folders magpie's own Library sync made.

yetone avatar Nov 27 '26 12:11 yetone

Fixed in 22f0f3f1a, released in v0.1.4966.

A folder holding only what magpie itself wrote there no longer counts as the agent's, or as its vendor's other app's: the sign-in file (Codex's auth.json, Claude Code's .credentials.json), and what the Library writes (instructions, MCP, hooks, subagents, skills, and a config.toml / settings.json holding only the Library's keys). So with no Codex CLI, Codex app or Cindy here, Codex is no Library target and no skill is linked into ~/.codex/skills. Codex through Cindy or a real install, and the Cursor editor's ~/.cursor, are still targets.

If you were already affected: nothing is deleted. Codex gets nothing new; what the Library had already given it (skills linked in ~/.codex/skills, AGENTS.md) stays, and the Library lists Codex as not installed on the rows of what it has, so you can untick it there to take it out.

Leaving this open until you confirm it works on your machine.

yetone avatar Nov 27 '26 13:11 yetone

这条看起来已经修了:提交 22f0f3f1a「agent: a folder holding only what magpie wrote is no agent's, and no Library target」(2026-11-28,上游 85cdca969)。

它与这条的缺陷是同一件事:只有 magpie 自己写的东西的目录不算该 agent 的、也不作 Library 目标。

建议可以关;若你原本还想要别的(更宽的输入、别的上游),把剩下的列一句即可。

L0NE-6 avatar Nov 28 '26 12:11 L0NE-6