关于 agent-import
agent-import 是用于在 Starchild 中载入其他 Agent 导出的迁移包的技能。它要求先与用户核对包内内容,再应用设置、身份信息、记忆、任务、密钥和文件。
主要功能
- 01下载并解压迁移包
- 02应用前检查包内内容
- 03迁移设置、身份信息和记忆
- 04注册并实现定时任务
- 05请求环境密钥并复制文件
适用场景
- 01将 Agent 设置和身份迁入 Starchild
- 02检查并恢复导出的记忆
- 03根据迁移包重建定时任务
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ starchild-ai-agent/ official-skills --skill agent-import安装后在 Claude Code 中输入/agent-import确认已加载。
附带文件scripts/download.py
详细介绍
Agent 导入 — 迁移包加载器
下载迁移包并将其加载到此 Starchild Agent 中。该迁移包由另一个 Agent 使用 agent-export 技能创建。
快速开始
当用户提供迁移代码和下载令牌时:
1. Run the import script to download & extract
2. Review the extracted data with the user
3. Apply each component using native tools
步骤 1 — 下载并解压
用户会提供源 Agent 中的两个值:CODE(8 个字符)和 DOWNLOAD_TOKEN。
python3 skills/agent-import/scripts/download.py <CODE> <DOWNLOAD_TOKEN>
脚本仅通过 Fly 内部网络(sc-agent-migration.internal)下载。中继策略禁止公开下载。如果无法连接内部网络,导入将失败,必须从 Fly 机器重试。下载令牌授权下载;令牌只能使用一次,并会与代码同时过期(有效期为 1 小时)。
成功后,脚本会将迁移包解压到 migration/,并打印内容摘要。
步骤 2 — 检查内容
在应用任何内容之前,先阅读并总结迁移包的内容:
cat migration/manifest.json
cat migration/memory/agent.json 2>/dev/null
cat migration/memory/user.json 2>/dev/null
cat migration/identity/profile.json 2>/dev/null
cat migration/identity/soul.md 2>/dev/null
cat migration/user/settings.json 2>/dev/null
cat migration/tasks/tasks.json 2>/dev/null
cat migration/env/keys.json 2>/dev/null
find migration/files/ -type f 2>/dev/null
应用之前,务必向用户展示摘要并征求确认。
步骤 3 — 应用组件
使用 Starchild 原生工具应用每个组件。顺序很重要:
3a. 用户设置(首先应用 — 为其他所有内容设置时区/语言)
读取 migration/user/settings.json,然后调用:
user_settings(action="update", settings={
"name": "...",
"what_to_call": "...",
"timezone": "...",
"language": "..."
})
只包含 JSON 中存在的字段。
3b. Agent 身份
读取 migration/identity/profile.json,然后调用:
agent_profile(action="update", profile={
"name": "...",
"vibe": "...",
"emoji": "...",
"creature": "..."
})
3c. SOUL.md
如果 migration/identity/soul.md 存在,则读取该文件并写入 prompt/SOUL.md。
如果现有 SOUL.md 有内容,则与其合并。不要盲目覆盖平台默认设置——应整合其中的个性特征。
3d. 记忆 — Agent
读取 migration/memory/agent.json,对每个条目调用:
memory(action="add", target="memory", content="<entry>")
⚠️ 记忆有 5000 个字符的限制。如果迁移包中有很多条目,优先保留最有用的条目。先使用 memory(action="read") 检查当前用量。
3e. 记忆 — 用户
读取 migration/memory/user.json,对每个条目调用:
memory(action="add", target="user", content="<entry>")
⚠️ 用户记忆有 3000 个字符的限制。优先保留偏好和更正信息。
3f. 任务
读取 migration/tasks/tasks.json,对每个任务:
scheduled_task(action="register", title=..., schedule=..., description=..., channels=...)- 根据描述编写
run.py脚本 - 测试脚本:
bash("python3 tasks/{job_id}/run.py") scheduled_task(action="activate", job_id=...)
任务需要实际实现——描述是规格说明,不是可运行代码。请酌情编写每个任务的脚本。
3g. 环境密钥
读取 migration/env/keys.json,然后调用:
request_env_input(env_vars=[...], reason="Migration from <source>")
此操作会提示用户安全地输入值。
3h. 文件
将文件从 migration/files/ 复制到工作区:
cp -r migration/files/* . 2>/dev/null
检查要复制的内容,并跳过可能会覆盖重要现有文件的文件。
步骤 4 — 清理
rm -rf migration/ migration-bundle.tar.gz
错误处理
| 错误 | 原因 | 修复方法 |
|---|---|---|
401 unauthorized | 下载令牌错误或缺失 | 重新检查源 Agent 输出中的令牌 |
404 not found | 代码已使用或从未存在 | 请源 Agent 重新导出 |
410 expired | 代码已超过 1 小时 | 请源 Agent 重新导出 |
403 internal_only | 从非 Fly 内部网络尝试下载 | 从 Fly 机器/内部网络运行导入 |
429 rate limited | 失败尝试次数过多 | 等待 1 小时 |
| Invalid tar.gz | 上传文件已损坏 | 从源 Agent 重新导出 |
| No manifest.json | 迁移包结构无效 | 迁移包根目录必须包含 manifest.json |