Plexus icon indicating copy to clipboard operation
Plexus copied to clipboard

[Bug]: skill 同步只读 SKILL.md,带 scripts/ 等附属资产的 skill bundle 同步后会丢失子目录

Open linmomo opened this issue 6 months ago • 1 comments

What happened?

import / share-all 流程把 skill 当成单文件 SKILL.md 处理。当 skill 目录下还有 scripts/、lib/、AGENTS.md 等附属资产(这是 Anthropic Skills 标准 + 社区惯例的常见结构),同步过程中:

  1. Plexus personal store 只接收 SKILL.md,附属目录被丢弃
  2. Plexus 把 source agent 的真目录替换成 symlink 指向 personal store(store 里仅有 SKILL.md),用户原始目录里的 scripts/ 等被当场覆盖删除
  3. 取消勾选目标 agent 时,Plexus 删除该 agent 下的 symlink,但 personal store 已经只有 SKILL.md,回不去原始 bundle

实际遭遇:一个带 4 个 wrapper(prepare_run.sh/mark.sh/stop.sh/status.sh)+ lib/ 子目录(含 prepare.sh/loop.sh/analyze.py/discover.sh)的 skill,在一次同步操作后整个 scripts/ 目录消失,无法从 Plexus snapshot 恢复(snapshot 只覆盖 MCP 文件,不含 skills)。

Expected behavior

  1. import 时整个 skill 目录递归拷贝到 personal store(含 SKILL.md 同级文件、子目录如 scripts/、AGENTS.md 等)
  2. 写入 agent native dir 前的 snapshot 应覆盖 skills 目录改动,不只限于 MCP 文件(可考虑 tar.gz 整目录归档)
  3. 真目录被替换为 symlink 之前,先 mv 到 backup 目录保留原始 bundle

Steps to reproduce

# 1. 准备一个 skill bundle,含 SKILL.md 和子目录
mkdir -p ~/.cursor/skills/demo/scripts/lib
echo '---\nname: demo\ndescription: demo skill\n---\nbody' > ~/.cursor/skills/demo/SKILL.md
echo '#!/bin/bash' > ~/.cursor/skills/demo/scripts/run.sh
echo '#!/bin/bash' > ~/.cursor/skills/demo/scripts/lib/helper.sh

# 2. 启动 Plexus dashboard,在 Skills 表 cursor 列勾选 demo 同步到其他 agent
# 3. 检查
ls ~/.config/plexus/personal/skills/demo/        # 只有 SKILL.md
ls ~/.cursor/skills/demo/                        # 真目录被替换成 symlink,scripts/ 不可达

Environment

  • OS: macOS 25.3.0 (Darwin)
  • Node: v24.13.0
  • Plexus: v0.0.7(v0.0.8 路径修复后 bundle 处理逻辑相同)
  • Agent: cursor / claude / gemini

建议补丁方向

  • packages/core/src/import/from-agents.ts 的 readNativeSkillsFromAgent 不只读 SKILL.md,应整目录递归
  • packages/core/src/store/skills.ts 的写入逻辑应保留全部子文件
  • snapshot 系统扩展到 skills 目录变更(关键,避免再次发生不可逆数据丢失)

Additional context

文档里其实提到了 "skills bundle"(README 「Skills」一栏写"Markdown skill bundle 链接或复制到各 agent 的 skill 目录"),但实现里把 bundle 当单文件处理。这个表达和实现的不一致是踩坑根源。

linmomo avatar May 08 '26 15:05 linmomo

Thanks for the detailed report! This is fixed on the current main.

  • Import/share-all/promote now copy the whole skill directory recursively into the personal store (scripts/, lib/, AGENTS.md, etc.), not just SKILL.md — via writeSkillBundle + copySkillResources.
  • snapshots now cover skill directories (not only MCP files), so a full bundle can be restored.
  • a real native skill dir is quarantined to backups/_collisions before being replaced by a symlink, so the original bundle is never silently deleted.

I also added a regression test (packages/core/test/skill-bundle-resources.test.ts) that reproduces your scripts/ + lib/ scenario and asserts the store keeps the bundle and the native dir is quarantined.

miniLV avatar Aug 27 '26 12:08 miniLV