← 返回
未分类
中文
File Writer
Safely write or append text content to files ONLY in /home/alfred/.openclaw/workspace/scratch. Creates backups before overwriting ({filename}.bak, .bak.1, et...
安全地将文本内容写入或追加到文件,仅限 /home/alfred/.openclaw/workspace/scratch 目录。覆盖前自动创建备份 ({filename}.bak, .bak.1 等)
nagilem
未分类
clawhub
v1.0.0 1 版本 100000 Key: 无需
#latest
概述
版本历史 (1)
安全
概述
File Writer Skill Quick Start Base directory: /home/alfred/.openclaw/workspace/scratch. All paths relative to this (e.g., "notes.txt" or "subdir/log.md"). Sanitize: Reject if path contains '../', starts with '/', or has non-text extensions (allow only .txt, .md, .log, .json). Primary tools: 'write' for saving, 'read' for checks/backups, 'exec' for mkdir -p (fallback to message if unavailable). Mode: Write (default/overwrite with backup), append (if specified). Step-by-Step Workflow Parse query: Extract rel_path (e.g., "subdir/notes.txt"), content, mode (write/append; infer from phrases like "update" = write). If missing (e.g., "write that information"), use message to ask for rel_path/content. Sanitize: Validate rel_path (no escapes, safe extension). Compute full_path = base_dir + rel_path. Create subdirs if needed: Extract parent from rel_path; call 'exec'("mkdir -p [base_dir]/[parent]") or message: "Please run mkdir -p [full_parent] and confirm." Check existence (call 'read' on full_path): If exists and write mode: Create backup (read content, find unique .bak.N path, 'write' to it). Confirm overwrite/append: Use message ("Confirm [action] on [file]? Yes/No"). Execute: Write: 'write' full_path with content. Append: 'read' existing, concatenate content, 'write' back. Handle errors: Reply with details; log via message ("Wrote [bytes] to [full_path] at [timestamp]"). If tools fail, fallback: Message requesting user runs echo "[content]" > [full_path] or >> for append. Safety Guidelines Limits: Max 50k chars; reject binary/large. Backups: Always for overwrites; increment .bak.N until unique (e.g., check with 'read'). Sensitive paths: If contains 'secret' or 'key', double-confirm. No auto-mkdir if exec unavailable: Require user confirmation/action. See references/safety.md for patterns. Edge Cases Empty content: Reject with "Content required." Non-existent for append: Treat as write. Existing .bak: Increment (e.g., .bak.1, .bak.2; use loop with 'read' to find next). Invalid path: "Invalid: Must be relative text file in scratch." Large content: Reject or chunk (multiple writes if over limit). Bundled Resources scripts/backup_file.sh: Fallback Bash for creating backups if tools limited. references/safety.md: Sanitization and confirmation patterns.
版本历史
共 1 个版本
v1.0.0
当前
2026-05-02 01:11 安全 安全
安全检测
腾讯云安全 (Sanbu)
安全,无风险
查看报告
🔗 相关推荐
ai-intelligence
oswalpalash
类型化知识图谱,用于结构化智能体记忆与可组合技能。支持创建/查询实体(人员、项目、任务、事件、文档)及关联...
★ 711
📥 243,740
security-compliance
spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,215
📥 266,446
developer-tools
steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 668
📥 324,060