feat: extend GitHub trans route reads

This commit is contained in:
Codex
2026-06-15 03:33:14 +00:00
parent 008f7fbb62
commit b2c2819fe2
5 changed files with 109 additions and 21 deletions
+12 -7
View File
@@ -58,6 +58,7 @@ bun scripts/cli.ts gh issue view <number|url|owner/repo#number> \
```
`read` 是兼容别名。支持 `owner/repo#number` shorthand(如 `pikasTech/HWLAB#1024`)。
人工读取 issue/PR 正文优先走 `trans gh:/owner/repo/issue/<number> cat|rg``trans gh:/owner/repo/pr/<number> cat|rg``gh issue view/read` 主要保留为结构化 JSON 底座、metadata 读取和兼容入口。
### 创建
@@ -107,7 +108,7 @@ trans gh:/owner/name/issue/<number> apply-patch <<'PATCH'
PATCH
# PR 正文同样使用 body.md
trans gh:/owner/name/pr/<number> apply-patch --dry-run <<'PATCH'
trans gh:/owner/name/pr/<number> apply-patch <<'PATCH'
*** Begin Patch
*** Update File: body.md
@@
@@ -117,7 +118,7 @@ trans gh:/owner/name/pr/<number> apply-patch --dry-run <<'PATCH'
PATCH
```
GitHub issue/PR 正文局部修补必须优先走 `trans gh:/owner/repo/issue/<number> apply-patch``trans gh:/owner/repo/pr/<number> apply-patch`;虚拟文件固定是 `body.md``apply_patch``patch-apply` 仅作为兼容别名。底层 `bun scripts/cli.ts gh issue patch ... --body-patch-stdin` 是受控写回底座或兼容入口,不作为人工首选。`trans gh:` 会先读取当前正文,把 Codex `apply_patch` envelope 应用到 `body.md`,再通过现有 `gh issue/pr update` guard 写回;`--dry-run` 只输出计划不写 GitHub
GitHub issue/PR 正文局部修补必须优先走 `trans gh:/owner/repo/issue/<number> apply-patch``trans gh:/owner/repo/pr/<number> apply-patch`;虚拟文件固定是 `body.md``apply_patch``patch-apply` 仅作为兼容别名。底层 `bun scripts/cli.ts gh issue patch ... --body-patch-stdin` 是受控写回底座或兼容入口,不作为人工首选。`trans gh:` 会先读取当前正文,把 Codex `apply_patch` envelope 应用到 `body.md`,再通过现有 `gh issue/pr update` guard 写回;普通小补丁不需要固定先跑 `--dry-run`,高风险正文预览时才加 `--dry-run`
### 评论
@@ -266,8 +267,12 @@ bun scripts/cli.ts gh pr reopen <number> [--comment ...]
trans gh:/pikasTech/HWLAB ls
# 列出 PR / Issue
trans gh:/pikasTech/HWLAB/pr ls [--limit N] [--full]
trans gh:/pikasTech/HWLAB/issue ls [--limit N] [--full]
trans gh:/pikasTech/HWLAB/pr ls [--state open|closed|all] [--limit N] [--full]
trans gh:/pikasTech/HWLAB/issue ls [--state open|closed|all] [--limit N] [--search TEXT] [--label L] [--full]
# 读取 / 检索正文
trans gh:/pikasTech/HWLAB/issue/1236 cat
trans gh:/pikasTech/HWLAB/issue/1236 rg 'API_KEY|YAML-first'
# 查看单个条目
trans gh:/pikasTech/HWLAB/pr/507 ls
@@ -286,7 +291,7 @@ trans gh:/pikasTech/HWLAB/pr/507 apply-patch <<'PATCH'
PATCH
```
正文一楼映射为 `body.md`route 未写 `/1` 时默认一楼正文。写回走 `gh issue/pr update` 的 guard 规则。`apply-patch` 是首选 operation`apply_patch``patch-apply` 只作为兼容别名。`rm` 对正文结构化拒绝。
正文一楼映射为 `body.md`route 未写 `/1` 时默认一楼正文。`issue ls --search/--state` 用于替代常见 `bun scripts/cli.ts gh issue list ... --search/--state` 读取;单条正文优先用 `cat``rg`,不要为了看 body 再走 `gh issue view --json body --full`写回走 `gh issue/pr update` 的 guard 规则。`apply-patch` 是首选 operation`apply_patch``patch-apply` 只作为兼容别名;普通小补丁在已读取上下文后可以直接 apply,`--dry-run` 只作为高风险正文的可选预览`rm` 对正文结构化拒绝。
---
@@ -356,9 +361,9 @@ EOF
shorthand 与显式 `--repo` 冲突时结构化失败。
### 干跑优先
### 高风险写入预览
写操作前先 `--dry-run`
整篇 replace、批量 lifecycle、PR merge 或并发敏感正文写入可先 `--dry-run``trans gh:/... apply-patch` 的普通小补丁在已读取上下文后不需要固定 dry-run
```bash
bun scripts/cli.ts gh issue update 20 --mode append --body-stdin --dry-run <<'EOF'
+18
View File
@@ -58,6 +58,24 @@ trans D601:win/c/test cmd cd
Windows operation 必须显式区分:`ps` 走 PowerShell`cmd` 走 cmd.exe。
### GitHub issue/PR route
```bash
trans gh:/pikasTech/HWLAB/issue ls --state all --limit 20 --search 'YAML-first 测试账号 API_KEY 准备 PJ2026-0105' --full
trans gh:/pikasTech/HWLAB/issue/1236 cat
trans gh:/pikasTech/HWLAB/issue/1236 rg 'API_KEY|YAML-first'
trans gh:/pikasTech/HWLAB/issue/1236 apply-patch <<'PATCH'
*** Begin Patch
*** Update File: body.md
@@
-old text
+new text
*** End Patch
PATCH
```
GitHub issue/PR 正文读写也走 `trans gh:/owner/repo/...`。常见读取优先用 `issue ls --search/--state``cat``rg`,不要为了看正文先回到 `bun scripts/cli.ts gh issue view --json body --full`;普通小补丁可直接 `apply-patch``--dry-run` 只作为高风险正文预览。
---
## Operation