← 返回 Skills 市场
2070super

Configure File Write And Recovery

作者 2070super · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ⚠ suspicious
50
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install configure-file-write-and-recovery
功能描述
如何在网关重启后保持配置文件的修改。TRIGGER 当用户提到配置文件写入、网关重启、配置文件还原、模型添加、多模型配置、配置管理机制、自动还原等问题时。
使用说明 (SKILL.md)

配置文件写入后被还原

本技能帮助你在网关重启后保持配置文件的修改,确保多模型配置不会被还原。

当使用此技能时

  • 当你需要在网关重启后保持配置文件的修改时
  • 当你遇到配置文件写入后被还原的问题时
  • 当你需要添加多个模型到配置文件中时
  • 当你需要了解配置管理机制和自动还原的原因时

步骤

  1. 尝试使用 write 工具写入配置文件
    • 为什么:write 工具是常见的文件写入工具,但可能不适用于某些特定环境。
  2. 尝试使用 exec cat heredoc 命令写入配置文件
    • 为什么:exec cat heredoc 命令可以确保文件内容一次性写入,但同样可能不适用于某些特定环境。
  3. 使用 Python 脚本通过 exec 命令写入配置文件
    • 为什么:Python 脚本可以提供更灵活的文件写入方式,并且可以确保内容一次性写入。
  4. 重启网关后检查配置文件
    • 为什么:验证配置文件是否在网关重启后保持修改。
  5. 查询模型在 API 中的实际 ID
    • 为什么:确保写入的模型 ID 是有效的,避免因非法参数导致配置文件被还原。
  6. 使用正确的 API ID 重新写入配置文件
    • 为什么:使用有效的模型 ID 可以通过配置验证,避免配置文件被还原。
  7. 重启网关后再次检查配置文件
    • 为什么:进一步验证配置文件是否在网关重启后保持修改。

坑点及解决方案

❌ 错误方法:使用 write 工具或 exec cat heredoc 命令写入配置文件,显示成功但检查时发现配置文件内容未改变。

  • 为什么失败:这些方法可能不适用于某些特定环境,导致写入操作看似成功但实际上未生效。
  • ✅ 正确方法:使用 Python 脚本通过 exec 命令写入配置文件,确保内容一次性写入并验证通过。

❌ 错误方法:使用用户提供的模型名称写入配置文件,导致配置文件在网关重启后被还原。

  • 为什么失败:用户提供的模型名称可能不是 API 中的实际 ID,导致配置验证失败,系统自动还原配置文件。
  • ✅ 正确方法:查询模型在 API 中的实际 ID,并使用这些 ID 重新写入配置文件,确保配置验证通过。

关键代码和配置

# Python 脚本写入配置文件
import subprocess

config_content = """
model1: doubao-seed-2-0-lite-260215
model2: doubao-seed-2-0-pro-260215
model3: doubao-seed-2-0-mini-260215
model4: doubao-seedance-2-0-260128
model5: doubao-seedance-2-0-fast-260128
model6: doubao-seedance-1-5-pro-251215
model7: doubao-seedream-5-0-260128
model8: doubao-embedding-vision-251215
model9: kimi-k2-250905
model10: glm-4-7-251222
model11: deepseek-v3-2-251201
model12: minimax-m2.7
"""

with open('/path/to/config/file', 'w') as f:
    f.write(config_content)

subprocess.run(['exec', 'cat', '/path/to/config/file'])

环境和前提条件

  • Python 3.x
  • 网关设备
  • 配置文件路径:/path/to/config/file
  • API 访问权限
  • 确保网关设备允许通过 exec 命令写入配置文件

伴随文件

  • scripts/write_config.py — 使用 Python 脚本写入配置文件的完整脚本
  • references/model_id_mapping.txt — 用户提供的模型名称与实际 API ID 的映射表

\x3C!-- metadata: {{"openclaw": {{"emoji": "🛠️"}}}} -->

Companion files

  • scripts/write_config.py — automation script
安全使用建议
Use this skill only if you intentionally want an agent to help modify a gateway configuration. Before any write or restart, confirm the exact config path and gateway, back up the current file, verify model IDs from the official API, use least-privileged access, and do not run the provided script unmodified.
功能分析
Type: OpenClaw Skill Name: configure-file-write-and-recovery Version: 1.0.0 The skill provides instructions and a script (`scripts/write_config.py`) to perform arbitrary file writes to a gateway's configuration path, which is a high-risk capability. It explicitly encourages using Python to bypass standard system tools (`write` or `cat heredoc`) that might be subject to system integrity checks or automatic restoration. While the stated intent is configuration management, the lack of path sanitization and the method of bypassing system controls represent a significant security risk. Additionally, the use of `subprocess.run(['exec', 'cat', ...])` is technically flawed and likely to fail in standard environments, suggesting either a vulnerability or poorly tested code.
能力评估
Purpose & Capability
The stated purpose matches the main behavior: helping a user keep gateway configuration changes after restart and use valid model API IDs. The noteworthy part is that this purpose involves high-impact configuration mutation.
Instruction Scope
The instructions make direct config rewriting and gateway restart/check cycles the recommended workflow, but do not require explicit confirmation, backup, path validation, dry-run validation, or rollback before overwriting configuration.
Install Mechanism
There is no install spec and no declared required binaries, credentials, or config paths, while SKILL.md says Python 3.x, API access, a gateway device, and exec-based config writing are prerequisites. SKILL.md also references a companion mapping file that is not in the manifest.
Credentials
Overwriting a gateway configuration file with a hardcoded model list is proportionate only with strong scoping and user approval; the artifacts use placeholder paths and do not bound which gateway or config file may be changed.
Persistence & Privilege
The persistence is configuration persistence after reboot, not hidden background agent persistence, but it still requires privileged write/exec access on a gateway device.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install configure-file-write-and-recovery
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /configure-file-write-and-recovery 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release: helps ensure configuration files persist after gateway reboot. - Describes common issues where config changes are lost and how to resolve. - Provides step-by-step troubleshooting and correct methods for writing config files. - Explains why model IDs must match API requirements to avoid automatic config restoration. - Includes a Python script for robust file writing and checks after gateway restart. - Lists key companion files for practical implementation.
元数据
Slug configure-file-write-and-recovery
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Configure File Write And Recovery 是什么?

如何在网关重启后保持配置文件的修改。TRIGGER 当用户提到配置文件写入、网关重启、配置文件还原、模型添加、多模型配置、配置管理机制、自动还原等问题时。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 50 次。

如何安装 Configure File Write And Recovery?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install configure-file-write-and-recovery」即可一键安装,无需额外配置。

Configure File Write And Recovery 是免费的吗?

是的,Configure File Write And Recovery 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Configure File Write And Recovery 支持哪些平台?

Configure File Write And Recovery 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Configure File Write And Recovery?

由 2070super(@2070super)开发并维护,当前版本 v1.0.0。

💬 留言讨论