-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
背景
shnote 会先在 stdout 输出 WHAT/WHY(包含颜色 ANSI 控制码)。当用户在外层 shell 使用重定向/Here-doc,例如:
shnote --what "写文件" --why "生成配置" run cat <<'EOF2' > output.txt
hello
EOF2由于 > output.txt 是外层 shell 的重定向,shnote 的 stdout 也会被写入文件,导致文件头部混入 WHAT/WHY 和 ANSI 码,进而污染产物。
最新更新的“软性缓解”
从 v0.2.8 的更新说明看,已加入 “codex 提示词 Read/apply_patch 规则”,这能降低 AI 生成这类重定向命令的概率,但对普通用户或手动操作仍会中招,因此仍需显式提醒。
建议
- README/CLI 提示:当需要重定向/Here-doc 写文件时,避免把 shnote 输出重定向进去。
- 给出安全示例:
shnote ... run bash -lc 'cat <<"EOF" > file\n...\nEOF'- 或使用
tee,或让 WHAT/WHY 输出走 stderr。
- 可考虑提供
--quiet/--no-header/--stderr选项,避免破坏管道/重定向场景。
该问题在 AI Agent / 自动化脚本场景很容易出现,建议在文档或运行时提示中做明确警示。
Metadata
Metadata
Assignees
Labels
No labels