feat(file): 新增 file 快捷命令组,无需克隆即可读写仓库文件 #330

Closed
Taoyouce wants to merge 0 commits from Taoyouce/gitlink-cli:feat/file-shortcuts into master
Contributor

背景

响应社区 issue「API是否支持自动读取仓库内文件(README等)?」:目前读取/修改仓库文件只能克隆仓库或手写 Raw API 调用。本 PR 新增 file 快捷命令组,让用户和 AI Agent 无需克隆即可读写仓库文件。目录列表和 README 查看已由 repo +tree / repo +readme 覆盖,本命令组不重复。

命令

命令 用途
file +view 查看文件内容;--raw 仅输出解码后的正文(可直接管道/重定向)
file +search 按文件名搜索仓库文件
file +create 创建文件并提交到指定分支
file +update 更新文件并提交到指定分支
file +delete 删除文件并提交
  • 写命令内容支持 --content 内联或 --content-file 本地文件,二选一强校验;--message 缺省为 <action> <path>--new-branch 支持提交到从 --branch 新建的分支。
  • 实测生产环境 contents/batch 接口拒绝文档中的 base64 编码,故统一使用 text 编码(delete 也需携带空 content/encoding 字段,否则报「请输入正确的文件参数Files」,均已实测确认)。

测试与验证

  • 单测覆盖端点路径、query 映射、payload 构造、内容来源校验、默认提交信息、--new-branch 透传、raw 内容提取(entries/README 两种响应形态)
  • go test ./...go vetgofmt 全部通过
  • 已在生产 gitlink.org.cn 真实仓库对 +view --raw+search+create(含 --new-branch)、+update+delete 全链路逐一验证成功
  • 同步更新 README / README.zh-CN 功能表与示例,新增 doc/changes/file-shortcuts.md
## 背景 响应社区 issue「API是否支持自动读取仓库内文件(README等)?」:目前读取/修改仓库文件只能克隆仓库或手写 Raw API 调用。本 PR 新增 `file` 快捷命令组,让用户和 AI Agent 无需克隆即可读写仓库文件。目录列表和 README 查看已由 `repo +tree` / `repo +readme` 覆盖,本命令组不重复。 ## 命令 | 命令 | 用途 | |------|------| | `file +view` | 查看文件内容;`--raw` 仅输出解码后的正文(可直接管道/重定向) | | `file +search` | 按文件名搜索仓库文件 | | `file +create` | 创建文件并提交到指定分支 | | `file +update` | 更新文件并提交到指定分支 | | `file +delete` | 删除文件并提交 | - 写命令内容支持 `--content` 内联或 `--content-file` 本地文件,二选一强校验;`--message` 缺省为 `<action> <path>`;`--new-branch` 支持提交到从 `--branch` 新建的分支。 - 实测生产环境 contents/batch 接口拒绝文档中的 `base64` 编码,故统一使用 `text` 编码(delete 也需携带空 `content`/`encoding` 字段,否则报「请输入正确的文件参数Files」,均已实测确认)。 ## 测试与验证 - 单测覆盖端点路径、query 映射、payload 构造、内容来源校验、默认提交信息、`--new-branch` 透传、raw 内容提取(entries/README 两种响应形态) - `go test ./...`、`go vet`、`gofmt` 全部通过 - 已在生产 gitlink.org.cn 真实仓库对 `+view --raw`、`+search`、`+create`(含 `--new-branch`)、`+update`、`+delete` 全链路逐一验证成功 - 同步更新 README / README.zh-CN 功能表与示例,新增 doc/changes/file-shortcuts.md
Taoyouce added 1 commit 2026-07-05 17:41:07 +08:00
29e9e927f3 feat(file): 新增 file 快捷命令组(+view/+search/+create/+update/+delete)
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taoyouce added 1 commit 2026-07-05 17:43:14 +08:00
27053f66d4 docs(skills): 新增 gitlink-file Skill 并更新索引
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taoyouce added 1 commit 2026-07-05 18:49:29 +08:00
40bfc64b8b feat(file): wire file shortcuts into i18n with en-US/zh-CN locales
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taoyouce added 1 commit 2026-07-05 18:51:53 +08:00
2d1e75da16 docs: note file shortcuts i18n coverage in change log
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Taoyouce added 1 commit 2026-07-08 22:51:26 +08:00
9588c113cf feat(file): add +batch for multi-file single-commit operations
The contents/batch endpoint accepts multiple file operations per
commit, but each existing shortcut sent exactly one. file +batch
takes a JSON spec (array of {action_type, file_path, content,
encoding}) and applies them atomically in one commit:

  gitlink-cli file +batch -s spec.json -b master -m 'batch ops'

Client-side validation: action_type must be create|update|delete,
file_path required. content/encoding are normalized for delete
entries — the server rejects entries missing content with
'请输入正确的文件参数Files' (production-reproduced).

Production-verified on gitlink.org.cn: 2-file create in one commit,
then 2-file delete in one commit. Unit test covers payload shape,
delete normalization, and action_type validation.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
wbtiger closed this pull request 2026-07-14 22:56:50 +08:00
wbtiger reopened this pull request 2026-07-14 23:02:09 +08:00
wbtiger closed this pull request 2026-07-14 23:05:25 +08:00

Pull request closed

Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Gitlink/gitlink-cli#330
No description provided.