feat(repo): add raw file content shortcuts #320

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

合并请求描述

本次合并请求增强仓库文件读取能力,新增 repo +rawrepo +file-existsrepo +manifest,将常见的 raw 文件读取、文件存在性检查、依赖清单读取从 Raw API 沉淀为
标准仓库 Shortcut。

相关Issue

关联Issue编号:暂无

变更内容

1. 增强了仓库原始文件读取能力

  • 新增 repo +raw
  • 支持 --path 指定仓库文件路径。
  • 支持 --ref 指定分支、标签或提交,默认 master
  • 对 raw 路径按段转义,支持包含空格等特殊字符的文件路径。

2. 增强了仓库文件存在性检查能力

  • 新增 repo +file-exists
  • 基于 sub_entries 检查指定文件是否存在。
  • 输出 repository、ref、path、exists 和匹配到的 entry。
  • 适合合规检查、代码审查、文档质量检查等场景。

3. 增强了依赖清单读取能力

  • 新增 repo +manifest
  • 支持 gonodepythonrustjava
  • 内置常见 manifest 映射:
    • go: go.mod
    • node: package.json
    • python: requirements.txtpyproject.tomlPipfilesetup.py
    • rust: Cargo.toml
    • java: pom.xmlbuild.gradlebuild.gradle.kts
  • 多候选文件会按顺序检查,找到后读取 raw 内容;未找到时输出 checked 列表。
  • 拒绝 .. 父路径段。
  • 避免构造跨目录或异常 raw 路径。

5. 完善了测试、文档和 Skill

  • 补充 repo 单元测试,覆盖 raw 路径、默认 ref、文件存在性、manifest fallback、未
    找到、非法输入和 HTTP 错误。
  • 更新 README 和 README.zh-CN 示例。
  • 更新 skills/gitlink-repo
  • 更新 skills/gitlink-complianceskills/gitlink-code-review,优先使用
    repo Shortcut 读取文件和文件树。
  • 新增 doc/changes/repo-raw-file-shortcuts.md

问题描述

多个仓库分析流程需要读取 LICENSE、README、依赖清单、源文件等内容,但之前需要直接
使用 Raw API,例如 /raw/<ref>/<path>sub_entries。这导致 Agent 和用户需要
手动拼接路径与 query,且不同 Skill 中重复保留 Raw API 示例。

问题复现步骤

  1. 查看 skills/gitlink-compliance/SKILL.mdskills/gitlink-code-review/ SKILL.md
  2. 可以看到读取 LICENSE、package.json、go.mod、源文件和目录树时需要手写 Raw
    API。
  3. 用户需要手动拼接 /raw/master/<path>sub_entries? filepath=<path>&ref=<branch>
  4. 文件路径包含空格、分支包含 / 或需要多语言 manifest fallback 时,使用体验不
    统一且容易出错。

根本原因

仓库 Shortcut 已支持 repo +treerepo +readme 等只读能力,但缺少通用 raw 文
件读取、文件存在性检查和常见依赖清单读取封装,导致合规检查和代码审查仍依赖 Raw
API。

修复方案

shortcuts/repo 中新增:

  • repo +raw --path <path> --ref <ref>
  • repo +file-exists --path <path> --ref <ref>
  • repo +manifest --kind <go|node|python|rust|java> --ref <ref>

实现路径清理、raw 路径分段转义、manifest 候选文件映射和 sub_entries 结果匹配逻
辑。同步补齐单元测试、i18n、README、中文 README、Repo/Compliance/Code Review
Skill 和 change note。

## 合并请求描述 本次合并请求增强仓库文件读取能力,新增 `repo +raw`、`repo +file-exists`、`repo +manifest`,将常见的 raw 文件读取、文件存在性检查、依赖清单读取从 Raw API 沉淀为 标准仓库 Shortcut。 ## 相关Issue 关联Issue编号:暂无 ## 变更内容 ### 1. 增强了仓库原始文件读取能力 - 新增 `repo +raw`。 - 支持 `--path` 指定仓库文件路径。 - 支持 `--ref` 指定分支、标签或提交,默认 `master`。 - 对 raw 路径按段转义,支持包含空格等特殊字符的文件路径。 ### 2. 增强了仓库文件存在性检查能力 - 新增 `repo +file-exists`。 - 基于 `sub_entries` 检查指定文件是否存在。 - 输出 repository、ref、path、exists 和匹配到的 entry。 - 适合合规检查、代码审查、文档质量检查等场景。 ### 3. 增强了依赖清单读取能力 - 新增 `repo +manifest`。 - 支持 `go`、`node`、`python`、`rust`、`java`。 - 内置常见 manifest 映射: - go: `go.mod` - node: `package.json` - python: `requirements.txt`、`pyproject.toml`、`Pipfile`、`setup.py` - rust: `Cargo.toml` - java: `pom.xml`、`build.gradle`、`build.gradle.kts` - 多候选文件会按顺序检查,找到后读取 raw 内容;未找到时输出 checked 列表。 - 拒绝 `..` 父路径段。 - 避免构造跨目录或异常 raw 路径。 ### 5. 完善了测试、文档和 Skill - 补充 repo 单元测试,覆盖 raw 路径、默认 ref、文件存在性、manifest fallback、未 找到、非法输入和 HTTP 错误。 - 更新 README 和 README.zh-CN 示例。 - 更新 `skills/gitlink-repo`。 - 更新 `skills/gitlink-compliance` 和 `skills/gitlink-code-review`,优先使用 repo Shortcut 读取文件和文件树。 - 新增 `doc/changes/repo-raw-file-shortcuts.md`。 ## 问题描述 多个仓库分析流程需要读取 LICENSE、README、依赖清单、源文件等内容,但之前需要直接 使用 Raw API,例如 `/raw/<ref>/<path>` 和 `sub_entries`。这导致 Agent 和用户需要 手动拼接路径与 query,且不同 Skill 中重复保留 Raw API 示例。 ## 问题复现步骤 1. 查看 `skills/gitlink-compliance/SKILL.md` 或 `skills/gitlink-code-review/ SKILL.md`。 2. 可以看到读取 LICENSE、package.json、go.mod、源文件和目录树时需要手写 Raw API。 3. 用户需要手动拼接 `/raw/master/<path>` 或 `sub_entries? filepath=<path>&ref=<branch>`。 4. 文件路径包含空格、分支包含 `/` 或需要多语言 manifest fallback 时,使用体验不 统一且容易出错。 ## 根本原因 仓库 Shortcut 已支持 `repo +tree`、`repo +readme` 等只读能力,但缺少通用 raw 文 件读取、文件存在性检查和常见依赖清单读取封装,导致合规检查和代码审查仍依赖 Raw API。 ## 修复方案 在 `shortcuts/repo` 中新增: - `repo +raw --path <path> --ref <ref>` - `repo +file-exists --path <path> --ref <ref>` - `repo +manifest --kind <go|node|python|rust|java> --ref <ref>` 实现路径清理、raw 路径分段转义、manifest 候选文件映射和 `sub_entries` 结果匹配逻 辑。同步补齐单元测试、i18n、README、中文 README、Repo/Compliance/Code Review Skill 和 change note。
ohanabi added 1 commit 2026-07-02 14:31:11 +08:00
wbtiger closed this pull request 2026-07-14 22:56:58 +08:00
wbtiger reopened this pull request 2026-07-14 23:02:14 +08:00
wbtiger closed this pull request 2026-07-14 23:05:37 +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#320
No description provided.