mirror of
https://git.openapi.site/https://github.com/desirecore/market.git
synced 2026-12-05 10:59:19 +08:00
fix(skill): 改名发布后确认未嵌进已有目录 / Detect a nested rename after publishing
检查与 mv 之间若目标被别的程序建出,mv 会把临时目录移进去且返回成功。 改名后确认 <目标>/SKILL.md 存在、<目标>/<临时目录名> 不存在,嵌进去时移回 再按重名规则处理;Linux 可用 mv -T。Windows 只用 Rename-Item(目标已存在时 报错),不用 Move-Item 发布。重算 source_hash。 If the target appears between the check and mv, mv nests the temporary directory and still succeeds. After renaming, confirm <target>/SKILL.md exists and <target>/<temporary name> does not; move it back and apply the conflict rules if nested. Windows publishes with Rename-Item only. source_hash recomputed.
This commit is contained in:
1 parent
12d3b76489
commit
273f832499
2 files changed
+10
-4
No files matched your search
@@ -29,7 +29,7 @@ metadata:
|
|||||||
description: >-
|
description: >-
|
||||||
把本机 OpenClaw 数据目录(~/.openclaw/)中的智能体与技能迁移到 DesireCore:按固定映射(SOUL.md→persona.md、AGENTS.md→principles.md、USER.md/MEMORY.md→memory/、workspace skills→智能体私有技能)经 ManageAgent 创建智能体并复制技能,迁移后逐项核对。Use when 用户要求从 OpenClaw 导入、迁移或搬家智能体与技能(migrate / import from OpenClaw)。需要本机已有 OpenClaw 数据目录;不安装、不运行 OpenClaw。
|
把本机 OpenClaw 数据目录(~/.openclaw/)中的智能体与技能迁移到 DesireCore:按固定映射(SOUL.md→persona.md、AGENTS.md→principles.md、USER.md/MEMORY.md→memory/、workspace skills→智能体私有技能)经 ManageAgent 创建智能体并复制技能,迁移后逐项核对。Use when 用户要求从 OpenClaw 导入、迁移或搬家智能体与技能(migrate / import from OpenClaw)。需要本机已有 OpenClaw 数据目录;不安装、不运行 OpenClaw。
|
||||||
body: ./SKILL.zh-CN.md
|
body: ./SKILL.zh-CN.md
|
||||||
source_hash: sha256:57df4b3436266ee3
|
source_hash: sha256:e52a0cec963cbe45
|
||||||
translated_by: human
|
translated_by: human
|
||||||
en-US:
|
en-US:
|
||||||
name: Migrate from OpenClaw
|
name: Migrate from OpenClaw
|
||||||
@@ -37,7 +37,7 @@ metadata:
|
|||||||
description: >-
|
description: >-
|
||||||
Migrate agents and skills from the local OpenClaw data directory (~/.openclaw/) into DesireCore using a fixed mapping (SOUL.md→persona.md, AGENTS.md→principles.md, USER.md/MEMORY.md→memory/, workspace skills→agent-private skills): create agents with ManageAgent, copy skills, then verify every item. Use when the user asks to import or migrate agents or skills from OpenClaw. Requires an existing local OpenClaw data directory; does not install or run OpenClaw.
|
Migrate agents and skills from the local OpenClaw data directory (~/.openclaw/) into DesireCore using a fixed mapping (SOUL.md→persona.md, AGENTS.md→principles.md, USER.md/MEMORY.md→memory/, workspace skills→agent-private skills): create agents with ManageAgent, copy skills, then verify every item. Use when the user asks to import or migrate agents or skills from OpenClaw. Requires an existing local OpenClaw data directory; does not install or run OpenClaw.
|
||||||
body: ./SKILL.md
|
body: ./SKILL.md
|
||||||
source_hash: sha256:57df4b3436266ee3
|
source_hash: sha256:e52a0cec963cbe45
|
||||||
translated_by: human
|
translated_by: human
|
||||||
market:
|
market:
|
||||||
icon: >-
|
icon: >-
|
||||||
@@ -164,7 +164,10 @@ Handle each skill directory (each global skill; for private skills, each subdire
|
|||||||
1. **Look for leftovers**: before copying, use the shell to list the directories in the target's parent directory whose names start with `.<target directory name>.openclaw-import-` (macOS/Linux: `ls -a <parent directory>`; Windows PowerShell: `Get-ChildItem -Force -LiteralPath <parent directory>`). File search tools may omit directories whose names start with a dot, so their results cannot show that there are no leftovers. They are temporary directories left by an interrupted run. Tell the user, delete them once the user agrees, and record them as "cleaned up" in the receipt. Do not delete dot-directories with any other prefix (for example the platform's own `.<name>.import-…` and `.<name>.install-…` temporary directories).
|
1. **Look for leftovers**: before copying, use the shell to list the directories in the target's parent directory whose names start with `.<target directory name>.openclaw-import-` (macOS/Linux: `ls -a <parent directory>`; Windows PowerShell: `Get-ChildItem -Force -LiteralPath <parent directory>`). File search tools may omit directories whose names start with a dot, so their results cannot show that there are no leftovers. They are temporary directories left by an interrupted run. Tell the user, delete them once the user agrees, and record them as "cleaned up" in the receipt. Do not delete dot-directories with any other prefix (for example the platform's own `.<name>.import-…` and `.<name>.install-…` temporary directories).
|
||||||
2. **Copy into a temporary directory**: the temporary directory sits in the **same parent directory** as the target and is named `.<target directory name>.openclaw-import-<random>` (at least 8 random letters and digits). Skill discovery skips directories whose names start with a dot, so a half-finished copy never shows up as a skill. macOS/Linux: `cp -R <source directory> <temporary directory>`; Windows PowerShell: `Copy-Item -Recurse -LiteralPath <source directory> -Destination <temporary directory>`; without a shell, write each file into the temporary directory with Read + Write.
|
2. **Copy into a temporary directory**: the temporary directory sits in the **same parent directory** as the target and is named `.<target directory name>.openclaw-import-<random>` (at least 8 random letters and digits). Skill discovery skips directories whose names start with a dot, so a half-finished copy never shows up as a skill. macOS/Linux: `cp -R <source directory> <temporary directory>`; Windows PowerShell: `Copy-Item -Recurse -LiteralPath <source directory> -Destination <temporary directory>`; without a shell, write each file into the temporary directory with Read + Write.
|
||||||
3. **Check**: the temporary directory must contain a regular file `SKILL.md` that starts with YAML frontmatter opened and closed by `---` lines, parses, and has a non-empty `description`. Otherwise **reject** it: delete this temporary directory, do not publish, and give the reason in the receipt. Once the check passes, add the version to global skills per section 3 inside the temporary directory; leave private skills unchanged.
|
3. **Check**: the temporary directory must contain a regular file `SKILL.md` that starts with YAML frontmatter opened and closed by `---` lines, parses, and has a non-empty `description`. Otherwise **reject** it: delete this temporary directory, do not publish, and give the reason in the receipt. Once the check passes, add the version to global skills per section 3 inside the temporary directory; leave private skills unchanged.
|
||||||
4. **Publish**: first confirm that the target directory does not exist. If it does, never overwrite: for a global skill take the next name per section 4; for a private skill stop and ask. Then publish by renaming within the same parent directory: macOS/Linux `test ! -e <target directory> && mv <temporary directory> <target directory>` (when the target is an existing directory, `mv` moves the temporary directory inside it, so the check cannot be skipped); Windows PowerShell `Rename-Item -LiteralPath <temporary directory> -NewName <target directory name>`, or `Move-Item -LiteralPath <temporary directory> -Destination <target directory>`, in both cases after `Test-Path -LiteralPath <target directory>` confirms the target does not exist. If Windows reports the files are in use or access is denied, wait a few seconds and retry, at most 3 times; if it still fails, clean up per step 5 and ask the user in the receipt to close whatever holds the directory (an editor, a file manager, an antivirus scan) and migrate this item again. Never fall back to copying over the target.
|
4. **Publish**: first confirm that the target directory does not exist. If it does, never overwrite: for a global skill take the next name per section 4; for a private skill stop and ask. Then publish by renaming within the same parent directory, and confirm afterwards that it really landed on the target:
|
||||||
|
- macOS/Linux: `test ! -e <target directory> && mv <temporary directory> <target directory>` (on Linux add `-T`, which fails outright when the target exists and is not empty). If another program creates the target between the check and the rename, `mv` moves the temporary directory inside it without an error, so after renaming confirm that `<target directory>/SKILL.md` exists and `<target directory>/<temporary directory name>` does not. If the temporary directory ended up inside the target, move it back with `mv <target directory>/<temporary directory name> <temporary directory>` and apply the conflict rules above.
|
||||||
|
- Windows PowerShell: after `Test-Path -LiteralPath <target directory>` confirms the target does not exist, run `Rename-Item -LiteralPath <temporary directory> -NewName <target directory name>`. When the target already exists, `Rename-Item` fails instead of moving the temporary directory inside it; apply the conflict rules then. Do not publish with `Move-Item`: when the target is an existing directory it moves the temporary directory inside it. If Windows reports the files are in use or access is denied, wait a few seconds and retry, at most 3 times; if it still fails, clean up per step 5 and ask the user in the receipt to close whatever holds the directory (an editor, a file manager, an antivirus scan) and migrate this item again.
|
||||||
|
- Never fall back to copying over the target.
|
||||||
5. **Clean up on failure**: when copying, checking or publishing fails, delete only the temporary directory this run created (macOS/Linux: `rm -rf -- <temporary directory>`; Windows PowerShell: `Remove-Item -Recurse -Force -LiteralPath <temporary directory>`), after confirming that its path starts with `.<target directory name>.openclaw-import-` and that it is the one created in this run. Never touch the target directory or any other directory. If deleting fails too, give the temporary directory's location in the receipt.
|
5. **Clean up on failure**: when copying, checking or publishing fails, delete only the temporary directory this run created (macOS/Linux: `rm -rf -- <temporary directory>`; Windows PowerShell: `Remove-Item -Recurse -Force -LiteralPath <temporary directory>`), after confirming that its path starts with `.<target directory name>.openclaw-import-` and that it is the one created in this run. Never touch the target directory or any other directory. If deleting fails too, give the temporary directory's location in the receipt.
|
||||||
|
|
||||||
### 6. Boundaries
|
### 6. Boundaries
|
||||||
|
|||||||
@@ -113,7 +113,10 @@ ManageAgent({
|
|||||||
1. **查残留**:在复制之前,用 Shell 列出目标父目录里以 `.<目标目录名>.openclaw-import-` 开头的目录(macOS/Linux:`ls -a <父目录>`;Windows PowerShell:`Get-ChildItem -Force -LiteralPath <父目录>`)。文件搜索工具可能不返回以点开头的目录,不能用它的结果判断没有残留。它们是之前中断留下的临时目录,告诉用户,用户同意后删除并在回执记为「已清理」。不删除其他前缀的点目录(例如平台自己的 `.<名>.import-…`、`.<名>.install-…` 临时目录)。
|
1. **查残留**:在复制之前,用 Shell 列出目标父目录里以 `.<目标目录名>.openclaw-import-` 开头的目录(macOS/Linux:`ls -a <父目录>`;Windows PowerShell:`Get-ChildItem -Force -LiteralPath <父目录>`)。文件搜索工具可能不返回以点开头的目录,不能用它的结果判断没有残留。它们是之前中断留下的临时目录,告诉用户,用户同意后删除并在回执记为「已清理」。不删除其他前缀的点目录(例如平台自己的 `.<名>.import-…`、`.<名>.install-…` 临时目录)。
|
||||||
2. **复制到临时目录**:临时目录与目标在**同一父目录**,名称为 `.<目标目录名>.openclaw-import-<随机串>`(随机串用 8 位以上字母数字)。以点开头的目录不会被技能发现读到,复制到一半时不会出现半成品技能。macOS/Linux:`cp -R <源目录> <临时目录>`;Windows PowerShell:`Copy-Item -Recurse -LiteralPath <源目录> -Destination <临时目录>`;没有 Shell 时用 Read + Write 逐个文件写进临时目录。
|
2. **复制到临时目录**:临时目录与目标在**同一父目录**,名称为 `.<目标目录名>.openclaw-import-<随机串>`(随机串用 8 位以上字母数字)。以点开头的目录不会被技能发现读到,复制到一半时不会出现半成品技能。macOS/Linux:`cp -R <源目录> <临时目录>`;Windows PowerShell:`Copy-Item -Recurse -LiteralPath <源目录> -Destination <临时目录>`;没有 Shell 时用 Read + Write 逐个文件写进临时目录。
|
||||||
3. **检查**:临时目录里必须有普通文件 `SKILL.md`,开头是以 `---` 行开始和结束的 YAML frontmatter,能解析,且 `description` 非空。不满足就**拒绝**:删除这个临时目录,不发布,回执写明原因。检查通过后,全局技能按第 3 节在临时目录里补版本号;私有技能不改。
|
3. **检查**:临时目录里必须有普通文件 `SKILL.md`,开头是以 `---` 行开始和结束的 YAML frontmatter,能解析,且 `description` 非空。不满足就**拒绝**:删除这个临时目录,不发布,回执写明原因。检查通过后,全局技能按第 3 节在临时目录里补版本号;私有技能不改。
|
||||||
4. **发布**:先确认目标目录不存在。已存在时不覆盖:全局技能按第 4 节换下一个名称,私有技能停下询问。然后在同一父目录内改名发布:macOS/Linux `test ! -e <目标目录> && mv <临时目录> <目标目录>`(目标是已有目录时 `mv` 会把临时目录移进去,所以不能省掉前面的检查);Windows PowerShell `Rename-Item -LiteralPath <临时目录> -NewName <目标目录名>`,也可以用 `Move-Item -LiteralPath <临时目录> -Destination <目标目录>`,两者都要先用 `Test-Path -LiteralPath <目标目录>` 确认目标不存在。Windows 报文件被占用或拒绝访问时,等几秒重试,最多 3 次;仍失败就按第 5 步清理,并在回执里请用户关闭占用该目录的程序(如编辑器、文件管理器、杀毒扫描)后重新迁移这一项。不要改用复制覆盖。
|
4. **发布**:先确认目标目录不存在。已存在时不覆盖:全局技能按第 4 节换下一个名称,私有技能停下询问。然后在同一父目录内改名发布,改名后确认确实发布到了目标:
|
||||||
|
- macOS/Linux:`test ! -e <目标目录> && mv <临时目录> <目标目录>`(Linux 可加 `-T`,目标已存在且非空时直接失败)。检查和改名之间如果有别的程序先建了目标目录,`mv` 会把临时目录移进去而不报错,所以改名后必须确认 `<目标目录>/SKILL.md` 存在、`<目标目录>/<临时目录名>` 不存在。临时目录被移进了目标时,用 `mv <目标目录>/<临时目录名> <临时目录>` 移回原处,再按上面的重名规则处理。
|
||||||
|
- Windows PowerShell:用 `Test-Path -LiteralPath <目标目录>` 确认目标不存在后,执行 `Rename-Item -LiteralPath <临时目录> -NewName <目标目录名>`。目标已存在时 `Rename-Item` 报错而不会把临时目录移进去,此时按重名规则处理。不要用 `Move-Item` 发布:目标是已有目录时它会把临时目录移进去。报文件被占用或拒绝访问时,等几秒重试,最多 3 次;仍失败就按第 5 步清理,并在回执里请用户关闭占用该目录的程序(如编辑器、文件管理器、杀毒扫描)后重新迁移这一项。
|
||||||
|
- 不要改用复制覆盖。
|
||||||
5. **失败清理**:复制、检查或发布任何一步失败时,只删除本次创建的这个临时目录(macOS/Linux:`rm -rf -- <临时目录>`;Windows PowerShell:`Remove-Item -Recurse -Force -LiteralPath <临时目录>`),删除前核对路径以 `.<目标目录名>.openclaw-import-` 开头、且就是本次创建的那个。不碰目标目录和其他任何目录。删除也失败时在回执中写明临时目录的位置。
|
5. **失败清理**:复制、检查或发布任何一步失败时,只删除本次创建的这个临时目录(macOS/Linux:`rm -rf -- <临时目录>`;Windows PowerShell:`Remove-Item -Recurse -Force -LiteralPath <临时目录>`),删除前核对路径以 `.<目标目录名>.openclaw-import-` 开头、且就是本次创建的那个。不碰目标目录和其他任何目录。删除也失败时在回执中写明临时目录的位置。
|
||||||
|
|
||||||
### 6. 边界
|
### 6. 边界
|
||||||
|
|||||||
Reference in new issue
Block a user