docs: prefer trans gh route for body patches

This commit is contained in:
Codex
2026-06-15 03:10:50 +00:00
parent 779721ea73
commit 008f7fbb62
4 changed files with 36 additions and 14 deletions
+15 -4
View File
@@ -172,6 +172,17 @@ function readDocument(route: GhContentRoute): GhRouteDocument {
};
}
function documentRoute(route: GhContentRoute): GhContentRoute {
if ((route.area === "pr-item" || route.area === "issue-item" || route.area === "legacy-item") && route.floor === null) {
return { ...route, floor: 1 };
}
return route;
}
function isPatchOperation(operation: string): boolean {
return operation === "patch-apply" || operation === "apply-patch" || operation === "apply_patch";
}
function numberFromUnknown(value: unknown): number | null {
return typeof value === "number" && Number.isFinite(value) ? value : null;
}
@@ -536,7 +547,7 @@ export async function runGhContentRoute(target: string, args: string[]): Promise
if (operation === "ls" || operation === "dir") {
return listRoute(route, opArgs);
}
const document = readDocument(route);
const document = readDocument(documentRoute(route));
if (operation === "cat") {
process.stdout.write(document.body);
return 0;
@@ -544,7 +555,7 @@ export async function runGhContentRoute(target: string, args: string[]): Promise
if (operation === "rg") {
return runRg(document.body, opArgs);
}
if (operation === "patch-apply" || operation === "apply-patch") {
if (isPatchOperation(operation)) {
const dryRun = opArgs.includes("--dry-run");
const unsupported = opArgs.filter((arg) => arg !== "--dry-run");
if (unsupported.length > 0) throw new Error(`unsupported gh ${operation} args: ${unsupported.join(" ")}`);
@@ -580,7 +591,7 @@ export async function runGhContentRoute(target: string, args: string[]): Promise
ok: false,
degradedReason: "unsupported-operation",
route,
message: "gh route floor 1 is the issue/PR body and cannot be removed safely; use patch-apply to delete reviewed sections.",
message: "gh route floor 1 is the issue/PR body and cannot be removed safely; use apply-patch to delete reviewed sections.",
});
return 2;
}
@@ -588,7 +599,7 @@ export async function runGhContentRoute(target: string, args: string[]): Promise
ok: false,
degradedReason: "unsupported-command",
route,
supported: ["cat", "rg", "patch-apply", "apply-patch", "rm"],
supported: ["cat", "rg", "patch-apply", "apply-patch", "apply_patch", "rm"],
});
return 2;
}