feat(content-write): 支持 mode=create 创建新文件#1608
Merged
qin-ctx merged 7 commits intovolcengine:mainfrom Apr 21, 2026
Merged
Conversation
添加 _is_not_found() 辅助方法,统一检测 NotFoundError 和 AGFSNotFoundError 两种 not-found 异常。在 _safe_stat() 中使用该 方法替代原来的 isinstance(exc, NotFoundError) 检查,确保 AGFS 路径的 not-found 错误被正确包装为 NotFoundError。
验证 mode=create 写入文件后通过 GET /read 读回,确认内容一致。
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
1 similar comment
PR Code Suggestions ✨No code suggestions found for the PR. |
Contributor
Author
|
Closes #1585 |
zhoujh01
approved these changes
Apr 21, 2026
r266-tech
added a commit
to r266-tech/OpenViking
that referenced
this pull request
Apr 21, 2026
r266-tech
added a commit
to r266-tech/OpenViking
that referenced
this pull request
Apr 21, 2026
qin-ctx
pushed a commit
that referenced
this pull request
Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
为
POST /api/v1/content/write新增mode="create"支持创建新文件,补齐 HTTP API 层的文件创建能力缺口。背景:当前
content/write端点要求目标文件已存在,不存在则返回 404。底层VikingFS.write_file()已支持创建(自动_ensure_parent_dirs),但 HTTP 层未暴露。这阻塞了 MCP 插件memwrite等需要通过 API 创建新文件的消费方。Changes
Python 服务层(
openviking/storage/content_write.py)_validate_mode()接受"create"值_CREATE_ALLOWED_EXTENSIONS白名单(.md/.txt/.json/.yaml/.yml/.toml/.py/.js/.ts),防止创建二进制文件_validate_create_extension()扩展名校验_create_and_write()方法:自动创建父目录 → 写入文件 → 语义刷新write()中 create 路径在_safe_stat之前分流,文件已存在时返回 HTTP 409Rust CLI(
crates/ov_cli/)ov write新增--mode参数(replace | append | create),与--append互斥测试
test_create_mode_*测试(使用FakeVikingFS隔离)Behavior Matrix
modereplace(默认)replaceappendappendcreatecreateBackward Compatibility
mode默认值仍为"replace",不传参行为完全不变Commits
83bb014添加 mode=create 服务层和 HTTP API 测试(TDD Red)133b5dd实现 mode=create 文件创建功能7f82b13ov write 支持 --mode 参数6142bdb清理测试文件中的过时 TDD 注释eab0616修复 _safe_stat 未正确处理 AGFSNotFoundError 的问题5b41dff添加 create mode 写后读集成测试Related
memwrite工具(创建能力的消费方)Closes #1585