fix: bound web-probe and gh diagnostic output (#884)
Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
+34
-10
@@ -4711,6 +4711,22 @@ function compactCommentSummary(comment: GitHubComment): Record<string, unknown>
|
||||
};
|
||||
}
|
||||
|
||||
function compactIssueViewCommentSummary(comment: GitHubComment): Record<string, unknown> {
|
||||
const body = comment.body ?? "";
|
||||
return {
|
||||
id: comment.id,
|
||||
url: comment.html_url,
|
||||
author: comment.user?.login ?? null,
|
||||
createdAt: comment.created_at ?? null,
|
||||
updatedAt: comment.updated_at ?? null,
|
||||
bodyChars: body.length,
|
||||
bodySha: bodySha(body),
|
||||
bodyPreview: ghShort(preview(body).replace(/\s+/gu, " "), 200),
|
||||
bodyOmitted: true,
|
||||
fullBodyIncluded: false,
|
||||
};
|
||||
}
|
||||
|
||||
function prStateDetail(pr: GitHubPullRequest): "open" | "closed" | "merged" {
|
||||
if (pr.merged === true || pr.merged_at !== null && pr.merged_at !== undefined) return "merged";
|
||||
return pr.state === "closed" ? "closed" : "open";
|
||||
@@ -6019,13 +6035,13 @@ async function getIssueComment(token: string, repo: string, commentId: number):
|
||||
return githubRequest<GitHubComment>(token, "GET", `/repos/${owner}/${name}/issues/comments/${commentId}`);
|
||||
}
|
||||
|
||||
function selectedIssueJson(issue: GitHubIssue, comments: GitHubComment[] | null, fields: IssueViewJsonField[] | undefined): Record<string, unknown> | null {
|
||||
function selectedIssueJson(issue: GitHubIssue, comments: GitHubComment[] | null, fields: IssueViewJsonField[] | undefined, options: { includeFullCommentBodies?: boolean } = {}): Record<string, unknown> | null {
|
||||
if (fields === undefined) return null;
|
||||
const summary = issueSummary(issue);
|
||||
const selected: Record<string, unknown> = {};
|
||||
for (const field of fields) {
|
||||
if (field === "comments") {
|
||||
selected.comments = (comments ?? []).map(commentSummary);
|
||||
selected.comments = (comments ?? []).map(options.includeFullCommentBodies === true ? commentSummary : compactIssueViewCommentSummary);
|
||||
} else {
|
||||
selected[field] = summary[field];
|
||||
}
|
||||
@@ -6033,11 +6049,12 @@ function selectedIssueJson(issue: GitHubIssue, comments: GitHubComment[] | null,
|
||||
return selected;
|
||||
}
|
||||
|
||||
async function issueRead(repo: string, token: string, issueNumber: number, jsonFields: IssueViewJsonField[] | undefined, commandName = "issue read", disclosure: Record<string, unknown> | null = null): Promise<GitHubCommandResult> {
|
||||
async function issueRead(repo: string, token: string, issueNumber: number, jsonFields: IssueViewJsonField[] | undefined, commandName = "issue read", disclosure: Record<string, unknown> | null = null, options: { includeFullCommentBodies?: boolean } = {}): Promise<GitHubCommandResult> {
|
||||
const issue = await getIssue(token, repo, issueNumber);
|
||||
if (isGitHubError(issue)) return commandError(commandName, repo, issue, { issueNumber });
|
||||
const needsComments = jsonFields === undefined || jsonFields.includes("comments");
|
||||
const includeBody = jsonFields === undefined || jsonFields.includes("body");
|
||||
const includeFullCommentBodies = options.includeFullCommentBodies === true;
|
||||
const comments = needsComments ? await listIssueComments(token, repo, issueNumber) : null;
|
||||
if (isGitHubError(comments)) return commandError(commandName, repo, comments, { issueNumber, issue: issueSummary(issue, { includeBody, includePreview: false }) });
|
||||
return {
|
||||
@@ -6047,21 +6064,28 @@ async function issueRead(repo: string, token: string, issueNumber: number, jsonF
|
||||
...(disclosure === null ? {} : { disclosure }),
|
||||
issue: issueSummary(issue, { includeBody, includePreview: false }),
|
||||
codeQueueBoardHint: codeQueueBoardCommanderBriefHint(issueNumber, issue.body ?? ""),
|
||||
...(comments === null ? {} : { comments: comments.map(commentSummary) }),
|
||||
...(comments === null || jsonFields !== undefined ? {} : { comments: comments.map(includeFullCommentBodies ? commentSummary : compactCommentSummary) }),
|
||||
...(jsonFields === undefined ? {} : {
|
||||
jsonFields,
|
||||
json: selectedIssueJson(issue, comments, jsonFields),
|
||||
json: selectedIssueJson(issue, comments, jsonFields, { includeFullCommentBodies }),
|
||||
compatibility: {
|
||||
legacyJsonBodyPath: includeBody ? ".data.issue.body" : null,
|
||||
bodyOmitted: !includeBody,
|
||||
readCommands: includeBody ? null : issueBodyReadCommands(repo, issueNumber),
|
||||
commentsCompacted: comments !== null && !includeFullCommentBodies,
|
||||
commentBodiesOmitted: comments !== null && !includeFullCommentBodies,
|
||||
fullCommentBodiesIncluded: comments !== null && includeFullCommentBodies,
|
||||
commentsPath: comments === null ? null : ".data.json.comments",
|
||||
readCommands: {
|
||||
...(includeBody ? {} : issueBodyReadCommands(repo, issueNumber)),
|
||||
...(comments !== null && !includeFullCommentBodies ? issueCommentReadCommands(repo, issueNumber) : {}),
|
||||
},
|
||||
},
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
async function issueView(repo: string, token: string, issueNumber: number, jsonFields: IssueViewJsonField[] | undefined, disclosure: Record<string, unknown> | null = null): Promise<GitHubCommandResult> {
|
||||
return issueRead(repo, token, issueNumber, jsonFields, "issue view", disclosure);
|
||||
async function issueView(repo: string, token: string, issueNumber: number, jsonFields: IssueViewJsonField[] | undefined, disclosure: Record<string, unknown> | null = null, options: { includeFullCommentBodies?: boolean } = {}): Promise<GitHubCommandResult> {
|
||||
return issueRead(repo, token, issueNumber, jsonFields, "issue view", disclosure, options);
|
||||
}
|
||||
|
||||
const GITHUB_USER_ATTACHMENT_URL_PATTERN = /https:\/\/github\.com\/user-attachments\/assets\/[A-Za-z0-9._-]+(?:\?[^\s<>"')]+)?/giu;
|
||||
@@ -8653,8 +8677,8 @@ export async function runGhCommand(args: string[]): Promise<GitHubCommandResult
|
||||
const missing = authRequired(resolved.repo, `issue ${sub}`, probe);
|
||||
if (missing !== null || token === null) return missing ?? authRequired(resolved.repo, `issue ${sub}`, { present: false, source: null, ghFallbackAttempted: true });
|
||||
const disclosure = readDisclosureOptions(options, resolved.shorthand);
|
||||
if (sub === "read") return withNumberOptionHint(issueRead(resolved.repo, token, resolved.number, issueReadJsonFields(options), "issue read", disclosure), resolved);
|
||||
return withNumberOptionHint(issueView(resolved.repo, token, resolved.number, issueReadJsonFields(options), disclosure), resolved);
|
||||
if (sub === "read") return withNumberOptionHint(issueRead(resolved.repo, token, resolved.number, issueReadJsonFields(options), "issue read", disclosure, { includeFullCommentBodies: options.raw || options.full }), resolved);
|
||||
return withNumberOptionHint(issueView(resolved.repo, token, resolved.number, issueReadJsonFields(options), disclosure, { includeFullCommentBodies: options.raw || options.full }), resolved);
|
||||
}
|
||||
const { token, probe } = resolveToken(true);
|
||||
const missing = authRequired(options.repo, `issue ${sub ?? ""}`.trim(), probe);
|
||||
|
||||
Reference in New Issue
Block a user