surshar / claude-code
Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.
Built by Anthropic · github.com/anthropics
| 1 | #!/usr/bin/env bun |
| 2 | |
| 3 | // Posts a comment when a lifecycle label is applied to an issue, |
| 4 | // giving the author a heads-up and a chance to respond before auto-close. |
| 5 | |
| 6 | import { lifecycle } from "./issue-lifecycle.ts"; |
| 7 | |
| 8 | const DRY_RUN = process.argv.includes("--dry-run"); |
| 9 | const token = process.env.GITHUB_TOKEN; |
| 10 | const repo = process.env.GITHUB_REPOSITORY; // owner/repo |
| 11 | const label = process.env.LABEL; |
| 12 | const issueNumber = process.env.ISSUE_NUMBER; |
| 13 | |
| 14 | if (!DRY_RUN && !token) throw new Error("GITHUB_TOKEN required"); |
| 15 | if (!repo) throw new Error("GITHUB_REPOSITORY required"); |
| 16 | if (!label) throw new Error("LABEL required"); |
| 17 | if (!issueNumber) throw new Error("ISSUE_NUMBER required"); |
| 18 | |
| 19 | const entry = lifecycle.find((l) => l.label === label); |
| 20 | if (!entry) { |
| 21 | console.log(`No lifecycle entry for label "${label}", skipping`); |
| 22 | process.exit(0); |
| 23 | } |
| 24 | |
| 25 | const body = `${entry.nudge} This issue will be closed automatically if there's no activity within ${entry.days} days.`; |
| 26 | |
| 27 | // -- |
| 28 | |
| 29 | if (DRY_RUN) { |
| 30 | console.log(`Would comment on #${issueNumber} for label "${label}":\n\n${body}`); |
| 31 | process.exit(0); |
| 32 | } |
| 33 | |
| 34 | const response = await fetch( |
| 35 | `https://api.github.com/repos/${repo}/issues/${issueNumber}/comments`, |
| 36 | { |
| 37 | method: "POST", |
| 38 | headers: { |
| 39 | Authorization: `Bearer ${token}`, |
| 40 | Accept: "application/vnd.github.v3+json", |
| 41 | "Content-Type": "application/json", |
| 42 | "User-Agent": "lifecycle-comment", |
| 43 | }, |
| 44 | body: JSON.stringify({ body }), |
| 45 | } |
| 46 | ); |
| 47 | |
| 48 | if (!response.ok) { |
| 49 | const text = await response.text(); |
| 50 | throw new Error(`GitHub API ${response.status}: ${text}`); |
| 51 | } |
| 52 | |
| 53 | console.log(`Commented on #${issueNumber} for label "${label}"`); |