ov write --content 值以 "-" 开头(如 frontmatter "---")时被误判为选项名,静默失败 exit 2
Description(现象)
ov write <uri> --content "<内容>" 当内容首行以 - 开头时(最典型:一切带 YAML frontmatter 的 markdown 文件,首行就是 ---),CLI 将参数值误判为选项名,打印 usage 后 exit 2,没有任何错误信息指向真实原因。
这个形态在日常使用里极其常见——往 viking 写规则/笔记/文档大多是 frontmatter 开头的 markdown——而且配合管道(如 | head)使用时退出码会被吞,造成「看似成功、实际未写入」的假象(我们在自动化同步里踩了一下午才发现)。
Steps to Reproduce
# ① 失败:exit 2,只打印 usage
ov write viking://user/default/memories/test.md --content "---
name: test
---"
# ② 等号形式可绕过:exit 0,正常写入
ov write viking://user/default/memories/test.md --content="---
name: test
---"
# ③ --from-file 也正常:exit 0
ov write viking://user/default/memories/test.md --from-file ./test.md --wait
受控排除过的变量(均无辜):多行内容、反引号、$()、内容中间出现的 --flag 字样、内容体积(10KB 级同过)。唯一变量是首行以 - 开头。
Expected Behavior
--content 的值无论首字符是什么,都应完整归属该选项(Click 侧显式消费选项值 / allow_interspersed_args 相关处理);若确实无法解析,报错应指明「值以 - 开头请改用 --content= 或 --from-file」。
Actual Behavior
- 空格分隔形式 + 值首行
---→ usage 错误 exit 2,无指向性报错 - 等号形式与
--from-file均正常
Environment
- OpenViking v0.4.22(uv tool 安装,macOS arm64)
Suggested Fixes
- CLI 参数解析修复:
--content的值显式归属,不进入选项猜测 - 或(至少)报错信息明确指引等号形式 /
--from-file - 文档标注:同步 frontmatter 文件推荐
--from-file
另附一个伴生小坑(与本 issue 独立):ov write --wait 在服务端语义处理(VLM 摘要)慢于客户端超时阈值时报「请求超时」,但服务端实际已落盘——客户端超时与写入结果不一致时,建议提示用户读回核验。
感谢这个项目,本地多 agent 共享记忆场景非常好用 🙏
I reproduced this on current main (914ee57d) with the actual Rust CLI parser. The frontmatter regression fails before any HTTP request; the equals form and existing source-selection rules still pass.
I'd like to work on a narrow fix. Allowing hyphen-prefixed --content values fixes the ordinary cases, but I also confirmed that the compatibility argument preprocessor rewrites literal --compact content into --compact=true. I'll protect that value boundary as part of the same fix, preserve following flags and --from-file conflicts, and run the complete Rust CLI suite plus a compiled-binary write smoke test.
This targets the content parsing defect. The independently noted --wait timeout/write-result ambiguity needs its own recovery discussion.