OpenClaw agent: pack and apply user data
Who reads this: you are the OpenClaw agent (runtime). This file is not end-user documentation—it tells you what to run, what to say, and what you must never do.
Language: reply to the user in their language; keep technical identifiers (paths, flags) as in the scripts.
Your job in one sentence
Use scripts/pack_openclaw.py and scripts/apply_openclaw.py from this skill to export or restore workspace data (and optional layers only if the user clearly opts in after you warn them). You own preview, collision handling, and consent—the scripts only write files by path.
When the user asks to export (pack)
- 1. Run
pip install -r requirements.txt if dependencies may be missing. - Run
python scripts/pack_openclaw.py --dry-run with the same flags you plan for the real pack; show the user what paths would be included. - Explain: default pack is
workspace/ only. List optional layers (--managed-skills, session flags, config snapshot flags) and do not add any until the user separately approves each, after you give the short risk line (size, transcripts, secrets)—see Before any real disk write. - Run the real pack:
python scripts/pack_openclaw.py with only approved flags. - Give the user the zip path. Before they copy or upload it: you open/list the zip and read
EXPORT_MANIFEST.txt; confirm it matches what you promised (paths + layers).
When the user asks to import (apply)
- 1. If the zip is not clearly from a trusted source or from this skill’s pack layout (
workspace/, EXPORT_MANIFEST.txt, …), stop and say why you will not apply it without their confirmation. - Run
pip install -r requirements.txt if needed. - Tell the user to back up
$OPENCLAW_HOME (or %USERPROFILE%\.openclaw) and the target workspace—or apply to a throwaway copy—unless they explicitly accept overwrite risk after you state it once. - You read
EXPORT_MANIFEST.txt inside the zip, then run
python scripts/apply_openclaw.py --zip <path> --dry-run
with
--openclaw-home,
--workspace, and
--config as the environment needs. Treat the combined manifest + dry-run output as the write contract.
- 5. Walk the user through which paths would be created/overwritten. For overlaps on memory / persona / skills, follow Merge and conflicts (your work; not in scripts)—do not run non–dry-run apply on a live workspace until conflicts are resolved or the user explicitly chooses full replace for that subtree.
- Add
--apply-managed-skills, session flags, or --apply-config only after separate approval and the warnings in Before any real disk write. - Run apply without
--dry-run only when the above is satisfied. If config was restored, remind: they still need valid auth on this machine; old paths inside openclaw.json may be wrong here. - Optionally suggest they run
openclaw doctor in their environment (they execute it, not you).
Before any real disk write (you follow this order)
Skip a step only if the user opts out after you repeat the concrete risk.
- 1. Dry-run first — pack and apply both support
--dry-run. The printed paths are what a real run would touch. - Read
EXPORT_MANIFEST.txt in the zip — authoritative list of packed paths; pair with apply dry-run to see destination collisions. - Backups — dry-run does not change disk; it is not a backup. For apply, insist on backup or throwaway target unless they waive.
- Optional layers = informed consent, not checkbox theater
-
Sessions: full transcripts, large JSONL, overwrite session dirs. Do not pass pack/apply session flags unless the user understands that.
-
Config snapshot / --apply-config: keys, tokens, channels, machine-specific paths. Do not enable without that acknowledgment.
- 5. Config parse / JSON5 — if resolving workspace from config fails, run
pip install -r requirements.txt (includes json5) or pass --workspace explicitly.
What the scripts actually do (so you do not mislead)
- - Pack and apply are filesystem steps: extract or copy bytes to paths. No semantic merge, no three-way merge, no conflict UI in Python.
- You must inspect manifests, diff mentally or with tools, merge text or rename paths, and get explicit user decisions. Never tell the user the “tool merged” or “resolved” overlapping memory/skills unless you did that with their approval.
If you follow previews + consent + collision handling, you can honestly say the flow is transparent; if you skip that, you risk silent data loss.
Safety: what you must assume and say
- - Assume the archive may hold sensitive material: persona,
MEMORY.md, logs, workspace skills; with optional layers, session JSONL and openclaw.json (secrets, channels). - Do not pack or encourage packing
~/.openclaw/credentials/. Apply never writes credentials; tell the user they must re-login / re-pair on a new machine unless they consciously accept copying secrets (you still do not pack credentials via these scripts). - Warn against putting the zip on untrusted or public storage.
- Overwrite rule: same path ⇒ destination file replaced. Same path ≠ same meaning. Only
openclaw.json gets a .bak.<timestamp> when using --apply-config; other paths are not auto-backed up.
Merge and conflicts (your work; not in scripts)
- - A path is an address, not proof two files are equivalent. Do not treat “same path in zip and disk” as safe to overwrite without reading both when the file is memory, persona, or a skill.
- Memory-style files: if both sides exist and differ materially, read both, merge or present a tight conflict summary, and get explicit user direction before non–dry-run apply (or they merge manually / use a temp extract).
- Skills (
SKILL.md etc.): divergent purpose or triggers ⇒ do not pick a winner alone; offer keep local / take zip / merge / rename path so both can exist. - Heuristic: dry-run + manifest + “would this path clobber something important?” ⇒ if yes, merge-or-confirm unless the user explicitly asked to replace that whole subtree.
Pack: default vs optional
| Content | Path inside zip | In default pack? |
|---|
| Workspace (persona, memory, workspace skills, canvas, etc.) | INLINECODE36 | yes |
| Managed skills |
managed-skills/ | no —
--managed-skills |
| Sessions |
sessions/<agentId>/sessions/ | no — session flags + acknowledgement;
large, sensitive, full transcripts |
| Config snapshot |
config/openclaw.json | no — config flags + acknowledgement;
secrets, machine paths |
| Credentials | n/a |
never |
Apply: default vs optional
Match flags to what is in the zip. If a layer is in the zip but flags are missing, the script warns and skips that layer.
| Content | Action | Default apply? |
|---|
| Workspace | Extract workspace/* → target workspace | yes, unless INLINECODE42 |
| Managed skills |
→
<openclaw-home>/skills/ | no —
--apply-managed-skills |
| Sessions | →
<openclaw-home>/agents/<id>/sessions/ | no —
--apply-sessions +
--i-know-restoring-sessions-overwrites |
| Config | →
<openclaw-home>/openclaw.json (existing →
.bak.<timestamp>) | no —
--apply-config +
--i-know-config-overwrites-secrets |
Paths (how you resolve them)
- - OpenClaw home:
$OPENCLAW_HOME or ~/.openclaw; Windows: %USERPROFILE%\.openclaw. - Pack: if
--workspace omitted, script reads config. Apply: --workspace may create the dir; if omitted, config must parse. On a fresh machine, prefer openclaw onboard or pass --workspace explicitly. - Run pack and apply in the same environment family (e.g. both WSL) so paths mean the same thing.
Examples (you adapt paths for the user’s OS)
Workspace-only apply, dry-run then real:
CODEBLOCK0
All optional apply layers — only after the user approved each flag’s risk:
CODEBLOCK1
CLI reference (copy-paste skeletons)
Pack:
CODEBLOCK2
Apply:
CODEBLOCK3
When to activate this skill (trigger hints)
| Intent | Example user phrases |
|---|
| Export | backup workspace, export memory, pack openclaw |
| Import |
new PC restore, import zip, apply backup, restore openclaw |
| Chinese | 一键打包, 一键应用, 导入 zip, 迁移 |
Quick commands (you run from skill root)
| Goal | Command |
|---|
| Pack preview | INLINECODE59 |
| Pack |
python scripts/pack_openclaw.py |
| Apply preview |
python scripts/apply_openclaw.py --zip x.zip --dry-run |
| Apply |
python scripts/apply_openclaw.py --zip x.zip |
| Dependencies |
pip install -r requirements.txt |
OpenClaw agent:打包与应用用户数据
谁阅读此文档: 你是 OpenClaw agent(运行时)。此文件不是最终用户文档——它告诉你该运行什么、该说什么,以及绝对不能做什么。
语言: 用用户的语言回复;技术标识符(路径、标志)保持脚本中的原样。
一句话概括你的工作
使用此技能的 scripts/packopenclaw.py 和 scripts/applyopenclaw.py 来导出或恢复工作区数据(以及可选层,仅当用户在你警告后明确同意时才使用)。你负责预览、冲突处理和用户确认——脚本仅按路径写入文件。
当用户要求导出(打包)时
- 1. 如果依赖可能缺失,运行 pip install -r requirements.txt。
- 使用与你计划用于实际打包相同的标志运行 python scripts/packopenclaw.py --dry-run;向用户展示将包含哪些路径。
- 解释:默认打包仅包含 workspace/。列出可选层(--managed-skills、会话标志、配置快照标志),不要添加任何内容,直到用户在你给出简短风险说明(大小、记录、密钥)后分别批准每一项——参见任何实际磁盘写入之前。
- 运行实际打包:使用仅已批准的标志运行 python scripts/packopenclaw.py。
- 给用户提供 zip 路径。在他们复制或上传之前: 你打开/列出 zip 并读取 EXPORT_MANIFEST.txt;确认其与你承诺的内容(路径 + 层)一致。
当用户要求导入(应用)时
- 1. 如果 zip 并非明确来自可信来源或此技能的打包布局(workspace/、EXPORTMANIFEST.txt、……),停止并说明为什么在没有用户确认的情况下你不会应用它。
- 如果需要,运行 pip install -r requirements.txt。
- 告诉用户备份 $OPENCLAWHOME(或 %USERPROFILE%\.openclaw)和目标工作区——或者应用到一次性副本——除非他们在你陈述一次覆盖风险后明确接受。
- 你读取 zip 内的 EXPORT_MANIFEST.txt,然后运行
python scripts/apply_openclaw.py --zip
--dry-run
并根据环境需要添加 --openclaw-home、--workspace 和 --config。将合并的清单 + dry-run 输出视为写入契约。
- 5. 引导用户了解哪些路径将被创建/覆盖。对于记忆 / 人设 / 技能上的重叠,遵循合并与冲突(你的工作;不在脚本中)——不要在冲突解决或用户明确选择完全替换该子树之前,对实时工作区运行非 dry-run 的应用。
- 仅在分别批准并遵循任何实际磁盘写入之前的警告后,才添加 --apply-managed-skills、会话标志或 --apply-config。
- 仅当上述条件满足时,才运行不带 --dry-run 的应用。如果恢复了配置,提醒:他们仍需要在此机器上拥有有效认证;openclaw.json 中的旧路径可能在此处不正确。
- 可选地建议他们在其环境中运行 openclaw doctor(由他们执行,不是你)。
任何实际磁盘写入之前(你按此顺序执行)
仅当用户在你重复具体风险后选择退出时,才跳过某一步骤。
- 1. 先进行 Dry-run — 打包和应用都支持 --dry-run。打印的路径是实际运行会触及的内容。
- 读取 zip 中的 EXPORT_MANIFEST.txt — 打包路径的权威列表;与应用 dry-run 配对以查看目标冲突。
- 备份 — dry-run 不会更改磁盘;它不是备份。对于应用,坚持要求备份或一次性目标,除非用户放弃此要求。
- 可选层 = 知情同意,而非勾选框表演
- 会话: 完整记录、大型 JSONL、覆盖会话目录。除非用户理解这一点,否则不要传递打包/应用会话标志。
- 配置快照 / --apply-config: 密钥、令牌、频道、机器特定路径。未经确认不要启用。
- 5. 配置解析 / JSON5 — 如果从配置解析工作区失败,运行 pip install -r requirements.txt(包含 json5)或显式传递 --workspace。
脚本实际做什么(这样你就不会误导)
- - 打包和应用是文件系统步骤:将字节提取或复制到路径。没有语义合并,没有三方合并,没有 Python 中的冲突 UI。
- 你必须检查清单、在脑海中或用工具进行差异比较、合并文本或重命名路径,并获取明确的用户决策。永远不要告诉用户“工具已合并”或“已解决”重叠的记忆/技能,除非你在用户批准下这样做了。
如果你遵循预览 + 同意 + 冲突处理,你可以诚实地说明流程是透明的;如果你跳过这些,你可能会面临静默数据丢失的风险。
安全:你必须假设和说明的内容
- - 假设存档可能包含敏感材料:人设、MEMORY.md、日志、工作区技能;使用可选层时,还有会话 JSONL 和 openclaw.json(密钥、频道)。
- 不要打包或鼓励打包 ~/.openclaw/credentials/。应用从不写入凭据;告诉用户他们必须在新机器上重新登录/重新配对,除非他们有意识地接受复制密钥(你仍然不会通过这些脚本打包凭据)。
- 警告不要将 zip 放在不可信或公共存储上。
- 覆盖规则: 相同路径 ⇒ 目标文件被替换。相同路径 ≠ 相同含义。仅 openclaw.json 在使用 --apply-config 时会获得 .bak.;其他路径不会自动备份。
合并与冲突(你的工作;不在脚本中)
- - 路径是一个地址,而不是两个文件等效的证明。不要将“zip 和磁盘中的相同路径”视为安全覆盖,而不在文件是记忆、人设或技能时读取两者。
- 记忆类文件: 如果双方都存在且内容有实质性差异,读取两者,合并或呈现紧凑的冲突摘要,并在非 dry-run 应用之前获取明确的用户指示(或者他们手动合并/使用临时提取)。
- 技能(SKILL.md 等): 目的或触发器不同 ⇒ 不要独自选择胜者;提供保留本地 / 使用 zip 中的 / 合并 / 重命名路径以便两者共存。
- 启发式: dry-run + 清单 + “此路径是否会覆盖重要内容?” ⇒ 如果是,则合并或确认,除非用户明确要求替换整个子树。
打包:默认与可选
| 内容 | zip 内的路径 | 默认打包中? |
|---|
| 工作区(人设、记忆、工作区技能、画布等) | workspace/ | 是 |
| 托管技能 |
managed-skills/ | 否 — --managed-skills |
| 会话 | sessions//sessions/ | 否 — 会话标志 + 确认;大、敏感、完整记录 |
| 配置快照 | config/openclaw.json | 否 — 配置标志 + 确认;密钥、机器路径 |
| 凭据 | n/a | 从不 |
应用:默认与可选
将标志与 zip 中的内容匹配。如果 zip 中有某层但缺少标志,脚本会警告并跳过该层。
| 内容 | 操作 | 默认应用? |
|---|
| 工作区 | 提取 workspace/* → 目标工作区 | 是,除非 --no-apply-workspace |
| 托管技能 |
→ /skills/ | 否 — --apply-managed-skills |
| 会话 | → /agents//sessions/ | 否 — --apply-sessions + --i-know-restoring-sessions-overwrites |
| 配置 | → /openclaw.json(现有 → .bak.) | 否 — --apply-config + --i-know-config-overwrites-secrets |
路径(你如何解析它们)
- - OpenClaw 主目录:$OPENCLAW_HOME 或 ~/.openclaw;Windows:%USERPROFILE%\.openclaw。
- 打包:如果省略 --workspace,脚本读取配置。应用:--workspace 可能创建目录;如果省略,配置必须可解析。在新机器