Commit Graph
2 Commits
Author SHA1 Message Date
yige fc021e34b5 fix(skill): 迁移技能目录先放临时目录、检查后改名发布 / Stage skill copies and publish by rename (#433)
## 概要 / Summary

desirecore/desirecore#7068 评审意见 1 的修正:`migrate-from-openclaw`
复制技能目录时不再直接写到最终位置。

1. 在**目标同一父目录**下复制到临时目录
`.<目标目录名>.openclaw-import-<随机串>`。客户端的全局与智能体私有技能发现都会跳过以点开头的目录(`skills/discovery.ts`
的 `scanSkillsFromDir`),复制到一半不会出现半成品技能;前缀与平台自己的
`.<名>.import-…`(本地技能导入)、`.<名>.install-…`(智能体安装)区分开。
2. 检查:`SKILL.md` 是普通文件,frontmatter 以 `---` 行开始和结束、能解析,`description`
非空(与客户端 Schema 唯一必填项一致)。不通过即拒绝,删除临时目录,不发布。
3. 全局技能在临时目录里补版本号;私有技能不改。
4. 发布:确认目标不存在后同目录改名(macOS/Linux `test ! -e … && mv`,避免 `mv`
把目录移进已有目录;Windows `Rename-Item` / `Move-Item`,先
`Test-Path`)。目标已存在时按原重名规则(全局技能换 `-openclaw[-N]`,私有技能停下询问),绝不覆盖。Windows
被占用时重试最多 3 次,仍失败则清理并在回执中给出指引。
5. 失败只删本次创建的临时目录;中断留下的同前缀临时目录经用户同意后清理,不碰其他点目录。
6. 回执逐个技能目录写明 **成功 / 拒绝 / 已清理**;核对步骤增加「目标目录下直接就是 `SKILL.md`」。

工作区 `skills/` 下不是目录的条目不复制,在回执中列出。中英文正文同步修改,`source_hash` 重算为
`sha256:63deff0e68c3f3ea`(按 `scripts/i18n/translate.py` 的算法,先用旧哈希
`1afa5bf5e6016987` 验证算法一致)。

Follow-up to review comment 1 on desirecore/desirecore#7068. Skill
directories are now copied into a dot-prefixed temporary directory next
to the target (skill discovery skips dot-directories), checked
(`SKILL.md` with parseable frontmatter and a non-empty `description`),
and published with a same-directory rename. Existing targets are never
overwritten; on failure only the run's own temporary directory is
deleted; leftovers from interrupted runs are cleaned up with the user's
consent. Windows uses `Rename-Item` / `Move-Item` with up to 3 retries
when files are in use. The receipt states succeeded / rejected / cleaned
up per skill directory. Both locales updated; `source_hash` recomputed.

## 验证 / Verification

隔离实例:desirecore#7068 分支,`npm run dev -- --home /tmp/dc-oc`,算力只用官方
`desirecore-cloud`(运行记录中 72 处 provider 字段全部是它),审批模式为「每次确认」。技能使用本 PR 的
f067801,从菜单入口预填草稿后发送。合成夹具包括:智能体「赛博牛马」及其私有技能 daily-report,全局技能
web-notes、pdf-tools(与已有技能重名)、broken-notes(SKILL.md 没有
frontmatter)、not-a-skill。另外预置了中断残留
`.web-notes.openclaw-import-k3j9x2m7`,以及平台前缀的干扰目录
`.web-notes.import-…-decoy`。

| 情况 | 结果 |
| --- | --- |
| 成功 | 私有技能 daily-report,以及全局技能 pdf-tools(改名为
pdf-tools-openclaw)、web-notes,都走了同父目录的 `.<目标>.openclaw-import-<12
位十六进制>` → 补版本号(仅全局技能)→ `test ! -e && mv` 发布。产物 SHA-256
与旧导入器基线逐个一致:`356893c9`、`55ed792d`、`78b63fba`、`2376c01e`;记忆和人格文件同样一致 |
| 被拒 | broken-notes 的检查未通过,本次临时目录已删除,没有发布 |
| 中断后清理 | 残留 `.web-notes.openclaw-import-k3j9x2m7`
经用户同意后删除,回执记为「已清理」;不同前缀的干扰目录保留 |
| 技能发现 | 迁移前列表里没有两个点开头的目录 |
| 来源 | `/tmp/ocs/home/.openclaw` 没有被改动 |

回执逐项写明了成功、拒绝和已清理。验证中发现一个问题:模型用文件搜索工具查残留,没有返回点开头的目录,预览时误报「无残留」,直到最终核对才用
`ls` 发现。12d3b76 改为复制前用 `ls -a` / `Get-ChildItem -Force` 列目录。273f832 按
Copilot 评审修正了 `mv` 嵌套问题。这两个提交改的是列目录和发布后的复核,没有重跑整轮界面验证;`mv` 的嵌套与移回已在本机用
shell 实测。

Verified in an isolated instance (official compute only) with f067801.
Success, rejection and leftover cleanup all behaved as specified, the
output hashes match the old importer baseline, and the decoy with the
platform prefix was kept. 12d3b76 (list leftovers with the shell) and
273f832 (detect a nested rename, Windows uses Rename-Item only) were not
re-run end to end; the `mv` nesting and move-back were tested locally in
a shell.
2026-12-03 22:55:12 +08:00
yigeandmashagua 4245947c4c feat(skill): 新增从 OpenClaw 迁移技能 / Add migrate-from-openclaw skill (#431)
## 概要 / Summary

新增官方技能 `migrate-from-openclaw`:把本机 OpenClaw
数据目录(`~/.openclaw/`)里的智能体与技能迁移到 DesireCore。DesireCore 客户端将移除内置的 OpenClaw
专用导入器(desirecore/desirecore#6563),迁移能力改由本技能以操作知识的形式提供,Agent 用既有的
`ManageAgent`、文件工具与 `FileDigest` 完成。

Adds the official `migrate-from-openclaw` Skill, which migrates agents
and skills from the local OpenClaw data directory (`~/.openclaw/`) into
DesireCore. The DesireCore client is removing its built-in OpenClaw
importer (desirecore/desirecore#6563); this Skill carries the migration
as operating knowledge, and the Agent performs it with the existing
`ManageAgent`, file tools and `FileDigest`.

## 内容 / What it covers

- 来源结构:`openclaw.json` 的 `agents.list[]` 与
`agents.defaults.workspace`,`~` 展开规则,`IDENTITY.md` 名称与表情解析,全局技能目录只认含
`SKILL.md` 的子目录。
-
固定映射:`SOUL.md→persona.md`、`AGENTS.md→principles.md`、`USER.md`/`MEMORY.md→memory/`、workspace
`skills/`→智能体私有技能;描述取 `SOUL.md` 首个非空行(≤200 字符)。与客户端原导入器一致。
- 重名:智能体交给 `ManageAgent` 的既有原子分配(`-2`、`-3`);全局技能沿用
`<名>-openclaw[-N]`;缺版本号补 `1.0.0`。
- 流程:扫描 → 预览并由用户选择 → 创建 → 复制 → 逐文件 `FileDigest` 核对 → 回执。只读来源,不覆盖已有内容,不碰
MCP、权限、模型与凭据。
- Source layout, the fixed file mapping (same as the client's former
importer), conflict naming, and a scan → preview/choose → create → copy
→ per-file `FileDigest` verification → receipt procedure. The source is
read-only; existing content is never overwritten.

## 外部依赖披露 / External dependency disclosure

需要本机已有 OpenClaw 数据目录;本技能只读取它,不安装、不授权、不运行
OpenClaw,也不访问其网络服务(`description`、`compatibility`、本地化文案与正文均已写明)。

Requires an existing local OpenClaw data directory; the Skill only reads
it and does not install, license or operate OpenClaw (stated in
`description`, `compatibility`, localized text and the body).

## 目录 / Catalog

- 不加入 `builtin-skills.json`:只对 OpenClaw 用户有意义,按需从市场安装(客户端加号菜单入口会按需安装并预填
`/skill:migrate-from-openclaw`)。
- `requiredClientVersion` 10.0.180(`ManageAgent` 的 `avatarGeneration`
参数从该版起存在);`manifest.json` 技能计数 164 → 165。
- Not added to `builtin-skills.json`; installed on demand.
`requiredClientVersion` 10.0.180; skill count 164 → 165.

## 校验 / Checks

- `validate-i18n.py`:0 error(新条目只有与其他内置技能相同的 license/review evidence 警告)
- `validate_catalog_metadata.py --require-complete`:0 error
- `translate.py --check`:通过(中英正文均为人工撰写,`source_hash` 一致)
- 公共信息边界自检:无客户或私有信息;示例为通用名称。

运行时验收(隔离 DesireCore 实例用合成 OpenClaw 夹具按本技能迁移,与原导入器产出逐项对比)完成后补充在下方评论。

Runtime acceptance (migrating a synthetic OpenClaw fixture in an
isolated DesireCore instance and comparing with the former importer's
output) will be added as a comment.

---------

Co-authored-by: mashagua <993498039@qq.com>
2026-12-03 21:32:17 +08:00