diff --git a/github/index.ts b/github/index.ts
index 4d0e9e68..09b49667 100644
--- a/github/index.ts
+++ b/github/index.ts
@@ -168,7 +168,9 @@ try {
const summary = await summarize(response)
await pushToLocalBranch(summary)
}
- const hasShared = prData.comments.nodes.some((c) => c.body.includes(`${useShareUrl()}/s/${shareId}`))
+ const hasShared = prData.comments.nodes.some((c) =>
+ c.body.includes(`${useShareUrl()}/s/${shareId}`),
+ )
await updateComment(`${response}${footer({ image: !hasShared })}`)
}
// Fork PR
@@ -180,7 +182,9 @@ try {
const summary = await summarize(response)
await pushToForkBranch(summary, prData)
}
- const hasShared = prData.comments.nodes.some((c) => c.body.includes(`${useShareUrl()}/s/${shareId}`))
+ const hasShared = prData.comments.nodes.some((c) =>
+ c.body.includes(`${useShareUrl()}/s/${shareId}`),
+ )
await updateComment(`${response}${footer({ image: !hasShared })}`)
}
}
@@ -361,7 +365,9 @@ async function getAccessToken() {
if (!response.ok) {
const responseJson = (await response.json()) as { error?: string }
- throw new Error(`App token exchange failed: ${response.status} ${response.statusText} - ${responseJson.error}`)
+ throw new Error(
+ `App token exchange failed: ${response.status} ${response.statusText} - ${responseJson.error}`,
+ )
}
const responseJson = (await response.json()) as { token: string }
@@ -402,8 +408,12 @@ async function getUserPrompt() {
// ie.
// ie. [api.json](https://github.com/user-attachments/files/21433810/api.json)
// ie. 
- const mdMatches = prompt.matchAll(/!?\[.*?\]\((https:\/\/github\.com\/user-attachments\/[^)]+)\)/gi)
- const tagMatches = prompt.matchAll(/
/gi)
+ const mdMatches = prompt.matchAll(
+ /!?\[.*?\]\((https:\/\/github\.com\/user-attachments\/[^)]+)\)/gi,
+ )
+ const tagMatches = prompt.matchAll(
+ /
/gi,
+ )
const matches = [...mdMatches, ...tagMatches].sort((a, b) => a.index - b.index)
console.log("Images", JSON.stringify(matches, null, 2))
@@ -430,7 +440,8 @@ async function getUserPrompt() {
// Replace img tag with file path, ie. @image.png
const replacement = `@${filename}`
- prompt = prompt.slice(0, start + offset) + replacement + prompt.slice(start + offset + tag.length)
+ prompt =
+ prompt.slice(0, start + offset) + replacement + prompt.slice(start + offset + tag.length)
offset += replacement.length - tag.length
const contentType = res.headers.get("content-type")
@@ -498,7 +509,12 @@ async function subscribeSessionEvents() {
? JSON.stringify(part.state.input)
: "Unknown"
console.log()
- console.log(color + `|`, "\x1b[0m\x1b[2m" + ` ${tool.padEnd(7, " ")}`, "", "\x1b[0m" + title)
+ console.log(
+ color + `|`,
+ "\x1b[0m\x1b[2m" + ` ${tool.padEnd(7, " ")}`,
+ "",
+ "\x1b[0m" + title,
+ )
}
if (part.type === "text") {
@@ -710,7 +726,8 @@ async function assertPermissions() {
throw new Error(`Failed to check permissions for user ${actor}: ${error}`)
}
- if (!["admin", "write"].includes(permission)) throw new Error(`User ${actor} does not have write permissions`)
+ if (!["admin", "write"].includes(permission))
+ throw new Error(`User ${actor} does not have write permissions`)
}
async function updateComment(body: string) {
@@ -730,12 +747,13 @@ async function updateComment(body: string) {
async function createPR(base: string, branch: string, title: string, body: string) {
console.log("Creating pull request...")
const { repo } = useContext()
+ const truncatedTitle = title.length > 256 ? title.slice(0, 253) + "..." : title
const pr = await octoRest.rest.pulls.create({
owner: repo.owner,
repo: repo.repo,
head: branch,
base,
- title,
+ title: truncatedTitle,
body,
})
return pr.data.number
@@ -753,7 +771,9 @@ function footer(opts?: { image?: boolean }) {
return `
\n`
})()
- const shareUrl = shareId ? `[opencode session](${useShareUrl()}/s/${shareId}) | ` : ""
+ const shareUrl = shareId
+ ? `[opencode session](${useShareUrl()}/s/${shareId}) | `
+ : ""
return `\n\n${image}${shareUrl}[github run](${useEnvRunUrl()})`
}
@@ -936,9 +956,13 @@ function buildPromptDataForPR(pr: GitHubPullRequest) {
})
.map((c) => `- ${c.author.login} at ${c.createdAt}: ${c.body}`)
- const files = (pr.files.nodes || []).map((f) => `- ${f.path} (${f.changeType}) +${f.additions}/-${f.deletions}`)
+ const files = (pr.files.nodes || []).map(
+ (f) => `- ${f.path} (${f.changeType}) +${f.additions}/-${f.deletions}`,
+ )
const reviewData = (pr.reviews.nodes || []).map((r) => {
- const comments = (r.comments.nodes || []).map((c) => ` - ${c.path}:${c.line ?? "?"}: ${c.body}`)
+ const comments = (r.comments.nodes || []).map(
+ (c) => ` - ${c.path}:${c.line ?? "?"}: ${c.body}`,
+ )
return [
`- ${r.author.login} at ${r.submittedAt}:`,
` - Review body: ${r.body}`,
@@ -960,9 +984,15 @@ function buildPromptDataForPR(pr: GitHubPullRequest) {
`Deletions: ${pr.deletions}`,
`Total Commits: ${pr.commits.totalCount}`,
`Changed Files: ${pr.files.nodes.length} files`,
- ...(comments.length > 0 ? ["", ...comments, ""] : []),
- ...(files.length > 0 ? ["", ...files, ""] : []),
- ...(reviewData.length > 0 ? ["", ...reviewData, ""] : []),
+ ...(comments.length > 0
+ ? ["", ...comments, ""]
+ : []),
+ ...(files.length > 0
+ ? ["", ...files, ""]
+ : []),
+ ...(reviewData.length > 0
+ ? ["", ...reviewData, ""]
+ : []),
"",
].join("\n")
}