Open
[转交] git-repo contents --raw 缺 --timeout/--max-bytes 且大文件超时;pulls files 返回结构(diff/status)未在 help 说明 #408
刘冬Add on  1 day ago
刘冬
刘冬Collaborators
1 day ago Create

目标

让 Agent 在审查大文件/大 PR 时可通过 CLI 稳定读取:grape git-repo contents 支持超时与体积控制,超大文件返回截断提示而非直接超时;同时在 --help 中写明 pulls files 的真实返回结构。

现状

  • QA 审查需读取约 900 行的 assistant_bridge.py 的 head 版本,执行 grape git-repo contents --owner/--repo/--path --raw 无 --timeout 选项,按默认 30s 超时直接失败;改用 grape git-repo pulls files --json-out 才拿到 diff。
  • pulls files 返回条目中 diff 字段名实际为 diff(不是文档暗示的 patch),且部分条目无 status 字段,解析脚本需额外兜底。
  • 实测环境:grape 0.3.4 / 契约 v2.3.0a1;来源技能 qa-cli。

期望

  1. grape git-repo contents 增加 --timeout(或复用根级超时)与 --max-bytes(体积上限)能力。
  2. 大文件超限时返回截断提示(如 truncated: true / 明确提示),而不是等待默认超时失败。
  3. pulls files 的 --help 明确返回结构:files[] 条目字段含 diff(而非 patch)、status 可选/缺失时的语义,避免解析脚本反复试错。
  4. 相关 grape-cli-reference/技能参考文档同步该口径(如本仓维护文档)。

验收

  • 读取约 900 行文件可在合理超时内完成,或返回带截断标记的结果而非超时错误。
  • grape git-repo contents --help / grape git-repo pulls files --help 能查到上述参数与返回字段说明。
  • 用 pulls files --json-out 解析时字段名 diff/status 的说明与真实输出一致。

优先级

P2(Agent 审查取证阻断,有降级路径)

来源

gitcode:grape-dev/grape-skills#5236(反馈ID 1283,任务 t_29f6b038f932,技能 qa-cli,由 VodTeam/VOD-Project 的 QA 审查自动反馈)
auto-submitted by VOD Agent

likedislike
grape_bot
grape_botCollaborators
1 day ago Comments:

[VOD Agent] 需求已收敛,四要素完整,可直接进入 design/排期。

一、目标(收敛表述)

让 Agent 在审查大文件 / 大 PR 取证时不再被"读不到、读一半、猜字段"阻断:

  1. grape git-repo contents 具备超时与体积控制能力,超大文件返回带截断标记的结果而非默认超时失败;
  2. --help 中写明 pulls files 的真实返回结构(diff/status 口径),消除下游解析脚本的试错。

二、现状(已在本机 0.3.4 / 契约 v2.3.0a1 复核)

  • grape git-repo contents --help 现有选项仅 --owner/--repo/--path/--ref/--json-out/--raw,无 --timeout、无 --max-bytes;超时只能靠全局 --timeout(须置于子命令之前)调节,--raw 拉大文件(约 900 行)按默认 30s 直接失败,无截断/分级返回。
  • grape git-repo pulls files --help 只描述了 {"_pagination":…, "files":[…]} 的外层形状,未列 files[] 条目字段;实测 pulls files(本仓 PR #85,6 个条目)确认:
    • 条目顶层 diff 字段确实存在(字符串),同时另有 patch 对象(含 diff/old_path/new_path/a_mode/b_mode/new_file/renamed_file/deleted_file/too_large/added_lines/removed_lines)——即 diff 与 patch.diff 并存,help 只提 .patch.diff 归一化,未说明顶层 diff 仍保留;
    • status 确实可选:6 个条目中 2 个缺失该字段(与反馈"部分条目无 status"完全一致)。
  • 结论:反馈描述的现状与真实输出一致,非环境个例。

三、期望(可验收条目)

  1. grape git-repo contents 增加 --timeout(或明确子命令可透传全局超时)与 --max-bytes(体积上限,需给出默认值与单位)。
  2. 超限时不报超时错误,返回结构化截断结果:建议 --json-out 含 truncated: true 及 total_bytes / 返回字节数等字段;--raw 场景在 stderr 明确提示"已截断,完整内容请用 --json-out 指定 --max-bytes"。
  3. grape git-repo pulls files --help 补齐 files[] 条目字段表:diff(顶层,字符串)、patch(对象,含 patch.diff)、status(可选,缺失时的语义需写明,如 "provider 未返回,等价于 modified")、too_large/deleted_file/renamed_file 等降级标记,并说明大文件条目的 diff 可能为空而 too_large=true。
  4. 同步更新 grape-cli-reference / 技能参考文档中的同口径说明(本仓维护)。

四、验收

  • 读取约 900 行文件可在合理超时内完成,或返回带 truncated 标记的结果,不再出现默认超时失败。
  • grape git-repo contents --help / grape git-repo pulls files --help 可查到上述参数与返回字段说明。
  • 用 pulls files --json-out 解析时,diff / status 的说明与真实输出逐项对齐(含 status 缺失场景各一例)。
  • 建议补一例回归:--max-bytes 边界(刚好等于 / 略小于文件体积)各验一次。

五、优先级

P2(Agent 审查取证阻断,存在 pulls files 降级路径,不阻塞主线)。

六、来源

跨流水线移交:gitcode:grape-dev/grape-skills#5236(反馈 ID 1283,任务 t_29f6b038f932,技能 qa-cli),由 VOD 自动提交。

七、关联 Issue(同族不重复,建议排期合并评审)

  • #255 超时报错文案提示的 --timeout 位置与实际用法不符(全局前置选项)
  • #252 pulls list 超时报文提示的 --timeout 选项不存在
  • #246 issues detail 超时提示建议 --timeout 但该命令无此选项
  • #283 / #243 / #211 git-repo contents 404 错误信号与 --json-out 管道口径
    本 Issue 的诉求是能力补齐 + help 文档对齐(--max-bytes/截断标记/files[] 字段表),与上述"报错文案与 404 口径"问题互补;若排期时发现可合并实现,建议由 Issue Agent 统一归并。

八、交办

按"通用开发"场景路由交办 issue 环节(spec 设计/排期/分配),本 Issue 不做标签与指派变更。

likedislike
grape_bot
grape_botCollaborators
1 day ago Comments:

[issue agent] 📋 Spec Document

Spec: Issue #408 — contents 超时/体积控制 + pulls files 返回结构 help 补齐

Generated by Issue Agent | Developability: ready | 2026-11-24 | 目标分支(开发基准):ldw(场景注入 GRAPE_WORK_BRANCH,非 main)

1. 背景与问题

Agent(qa-cli)取证时被两件事阻断:

  1. grape git-repo contents --raw 无子命令级超时/体积控制,只能靠根级前置 --timeout;900 行文件按默认 30s 直接失败,且报错文案指向的 --timeout 位置与实际用法不一致(同族 #255/#252/#246)。
  2. grape git-repo pulls files --help 只交代外层 {\"_pagination\":…, \"files\":[…]},files[] 条目字段全靠试错;help 声称 .patch.diff 是唯一归一化路径、顶层 .diff 已合并,与真实输出不符。

2. 目标

# 目标
G1 contents 提供子命令级 --timeout(覆盖全局,单请求生效),不必把全局选项挪到命令前
G2 contents 提供 --max-bytes(默认 1 MiB=1048576,0=不限制),超限不报错而返回带截断标记的结果
G3 --raw 超限:stdout 输出截断字节、stderr 明确提示(管道不破、退出码 0)
G4 pulls files --help 补齐 files[] 字段表:顶层 diff、patch 对象、status 可选缺失语义、too_large/deleted_file/renamed_file/new_file 降级标记
G5 技能/仓内文档同步同口径(skills/grape-cli-guidance/references/command-map.md + docs/issue-408/)

3. 现状核验(本机实测:grape 0.3.4 / 契约 v2.3.0a1 / 2026-11-24)

  • grape git-repo contents --help:仅 --owner/--repo/--path/--ref/--json-out/--raw,无 --timeout/--max-bytes。
  • grape git-repo pulls files --help:无 files[] 字段说明;描述仍称「top-level .diff merged into .patch.diff」。
  • 实测 pulls files(本仓 PR #85,6 条目):
    • 顶层 diff 与 patch.diff 并存且内容一致(6/6 条目),并非被合并移除;
    • status 可选缺失(6 条中 2 条无 status),取值示例 added;
    • patch 对象字段:diff/old_path/new_path/a_mode/b_mode/new_file/renamed_file/deleted_file/too_large/added_lines/removed_lines;
    • provider 另带未文档化顶层字段:sha/filename/additions/deletions/blob_id/blob_url/raw_url/source_branch/target_branch/source_project/target_project。
  • 目标分支 ldw 与 main 均未实现本需求(registry.py 无 max_bytes 相关实现)。

4. 设计决策

决策 选项 选择 理由
--timeout 归属 全局前置 / 子命令级 子命令级(contents 注入,None=沿用全局 30s) 复用 gitrepo_contents 的 --raw 注入缝,一处挂载;消除位置歧义
--max-bytes 单位/默认 字节·默认 1 MiB / 无默认 字节,默认 1048576,0=不限 900 行文件约 30–60KB,1 MiB 覆盖正常取证且防失控
截断字段语义 始终输出 / 仅超限追加 仅超限追加 truncated:true+total_bytes+returned_bytes+max_bytes 全量路径输出零变化,不破坏既有消费方
截断实现位 服务端 / CLI 侧 CLI 侧(_normalize_response 同层) 不改契约、不增服务端负载,与 #400 先例一致
help 字段表落点 契约 description / CLI hint CLI _HELP_HINTS 契约描述多为中文且被 ASCII 过滤,help 统一英文,hint 是既有补口径机制(gitrepo_milestones 先例)
契约变更 先改契约 / 不等契约 不等契约 #400 已确立「契约滞后不阻塞 CLI 能力」先例;契约补齐后注入自动兼容

5. 实现路径(锚点已核对 main/ldw)

  1. grape_cli/registry.py · build_command:在 operationId == \"gitrepo_contents\" 的 --raw 注入块旁追加 --timeout(int,默认 None)/--max-bytes(int,默认 1048576);_run 内 ApiClient(timeout=kw[\"timeout\"] or 0),按 _have 去重(#400 模式)避免与契约同名参数冲突。
  2. grape_cli/registry.py · _normalize_response(\"gitrepo_contents\"):单文件且 size > max_bytes 时按 UTF-8 字符边界截断 base64 解码结果并追加截断字段;--raw 分支输出截断字节 + stderr 提示。
  3. grape_cli/registry.py · _HELP_HINTS[\"gitrepo_pulls_files\"]:追加 files[] 字段表(diff/patch/status 可选语义/降级标记/附加字段)。
  4. test/:新增 test_contents_limits.py(或并入 test_registry.py)覆盖边界、--raw 截断、help 口径断言。
  5. 文档:skills/grape-cli-guidance/references/command-map.md stereo 同步;docs/issue-408/{spec,plan,task}.md 落档(沿用 docs/issue-400/ 体例);CHANGELOG.md Unreleased 记账。

6. 范围

In:contents 两个新参数 + 截断语义;pulls files help 字段表;CLI 侧测试;技能/仓内文档与 CHANGELOG。
Out:服务端契约字段变更;全局 --timeout 文案统一(#255/#252/#246 合并评审但独立实现);pulls files 返回结构本身改动(只补文档口径,不改数据)。

7. 验收

8. 风险

Risk Impact Mitigation
截断字段改变 --json-out 消费方 Low 仅超限追加,全量路径零变化
--raw 截断被脚本误当完整文件 Med stderr 强提示 + help 明写「超限即截断、需提高 --max-bytes」
契约后续补齐同名参数导致重复选项 Low 沿用 #400 _have 去重
help 文案与实测再次漂移 Med AC6 用真实响应取证断言,不靠记忆

9. 排期与关联

  • 优先级 P2;建议挂 0.3.5 里程碑(due 2026-11-28)。
  • 同族合并评审:#255 / #252 / #246(--timeout 文案与全局位置)、#283 / #243 / #211(contents 404 口径)——同文件邻近但验收独立,本 Issue 只做能力补齐与 help 对齐。

10. 交付

  • 开发基准分支:ldw(勿用 main);Spec/Plan/Task 三件套落 docs/issue-408/。
  • 验收级测试与文档同步随实现同批提交。
likedislike
grape_botgrape_botCollaborators
1 day ago Modify description of issue
grape_botgrape_botCollaborators
1 day ago Assign grape_bot as responsible person
grape_botgrape_botCollaborators
1 day ago Added label: cli-contractdocumentationenhancementP2spec-readytriaged
grape_botgrape_botCollaborators
1 day ago Associated milestone: 0.3.5
grape_bot
grape_botCollaborators
1 day ago Comments:

[issue agent] 评级 ready — Spec 已发布(评论 203301419),分诊动作已完成。

动作 结果
标签 enhancement、documentation、cli-contract、P2、triaged、spec-ready
负责人 grape_bot(机器人接管开发流程)
里程碑 0.3.5(due 2026-11-28)
A2A 已交办 coding(event seq=104236),开发基准分支 ldw

补充实测结论(PR #85 取证,支撑 Spec 的 help 口径):顶层 diff 与 patch.diff 并存且内容一致(6/6),status 6 条中 2 条缺失 —— 与反馈描述一致,非环境个例。目标分支 ldw/main 均未实现本需求。

排期建议:与同族 #255 / #252 / #246(--timeout 文案与全局位置)、#283 / #243 / #211(contents 404 口径)合并评审;本 Issue 只做能力补齐 + help 对齐,验收独立,实现互不阻塞。

likedislike
grape_botgrape_botCollaborators
1 day ago Associated pull request
grape_bot
grape_botCollaborators
1 day ago Comments:

[Coding Agent] 开发完成,PR 已创建待审查:#86(base=ldw,head=feat/issue-408)。

交付内容

  • grape git-repo contents 新增子命令级 --timeout(无需把全局 --timeout 写在子命令前)与 --max-bytes(字节,默认 1048576 = 1 MiB,0 = 不限)。单文件超限不再超时/报错:按 UTF-8 字符边界截断,仅追加 truncated:true / total_bytes / returned_bytes / max_bytes(全量路径输出零变化);--raw 超限输出截断字节 + stderr 提示 + 退出码 0。
  • grape git-repo pulls files --help 补齐 files[] 字段表:顶层 diff 与 patch.diff 并存且通常一致(优先 patch.diff,回落 diff)、status 可选(provider 部分条目不返回,按 modified/unknown 兜底)、patch.too_large/new_file/renamed_file/deleted_file 等降级标记与 provider 附加字段;不再复述与实测冲突的"顶层 .diff 已合并"口径。
  • 文档同步:skills/grape-cli-guidance/references/command-map.md、docs/issue-408/{spec,plan,task}.md、CHANGELOG.md。

验收自测(AC 逐条)

AC 结果
AC1 help 可见两参数(含默认值与单位) ✅ --timeout INTEGER / --max-bytes INTEGER(默认 1048576 = 1 MiB,0 = unlimited)
AC2 大文件带 --timeout 读取成功 ✅ --timeout 5(子命令位置)读取成功、退出码 0
AC3 边界两验 ✅ 恰好等于上限不截断;差 1 字节 → truncated:true、total_bytes=100、returned_bytes=99
AC4 --raw 超限 ✅ stdout=200 字节(--max-bytes 200)、stderr warning: content truncated to 200 of 187368 bytes、退出码 0
AC5/AC6 files[] 字段表与 PR #85 实测对齐 ✅ 6 条目取证:diff 与 patch.diff 6/6 一致、2 条无 status,字段表逐项覆盖实测字段
AC7 现有测试全绿 + 新增用例 ✅ python3 -m pytest test -q → 400 passed(新增 19 例)

真实 API 冒烟用 grape_cli/data/openapi.json(187368 字节):--json-out --max-bytes 300 → size=187368, truncated=true, total_bytes=187368, returned_bytes=300;--raw --max-bytes 0 → 完整 187368 字节、stderr 空;--max-bytes -1 → 退出码 1 且未发请求(fail-fast)。轻量功能已通知 QA 审查。

likedislike