Skip to content

Commit a43da8d

Browse files
authored
Allow users to create issue via CLI with prefilled system and os info (RooCodeInc#3250)
* Change bug report template * it should be text area * [TRIVIAL] Add npm script for issue creation * Adjust script & add changeset * Use cline repo * remove comment * open should work on any platform
1 parent 062bb5b commit a43da8d

File tree

4 files changed

+152
-1
lines changed

4 files changed

+152
-1
lines changed

.changeset/little-needles-play.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"claude-dev": minor
3+
---
4+
5+
Add npm script for issue creation

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ body:
4747
placeholder: "e.g., Windows 11, macOS Sonoma, Ubuntu 22.04"
4848
validations:
4949
required: true
50+
- type: textarea
51+
id: system-info
52+
attributes:
53+
label: System Info
54+
description: What system information is relevant to the issue?
55+
placeholder: "e.g., CPU: Intel Core i7-11700K, GPU: NVIDIA GeForce RTX 3070, RAM: 32GB DDR4"
56+
validations:
57+
required: true
5058
- type: input
5159
id: cline-version
5260
attributes:

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@
313313
"prepare": "husky",
314314
"changeset": "changeset",
315315
"version-packages": "changeset version",
316-
"docs:preview": "cd docs && mintlify dev"
316+
"docs:preview": "cd docs && mintlify dev",
317+
"report-issue": "node scripts/report-issue.js"
317318
},
318319
"devDependencies": {
319320
"@changesets/cli": "^2.27.12",

scripts/report-issue.js

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
const { execSync } = require("child_process")
2+
const readline = require("readline")
3+
const os = require("os")
4+
5+
const rl = readline.createInterface({
6+
input: process.stdin,
7+
output: process.stdout,
8+
})
9+
10+
const ask = (question) => new Promise((resolve) => rl.question(`\n${question}`, resolve))
11+
12+
const getClineVersion = () => {
13+
try {
14+
const extensions = execSync("code --list-extensions --show-versions").toString()
15+
const clineMatch = extensions.match(/claude-dev@(\d+\.\d+\.\d+)/)
16+
return clineMatch ? clineMatch[1] : "Not installed"
17+
} catch (err) {
18+
return "Error getting version"
19+
}
20+
}
21+
22+
const collectSystemInfo = () => {
23+
let cpuInfo = "N/A"
24+
let memoryInfo = "N/A"
25+
try {
26+
if (process.platform === "darwin") {
27+
cpuInfo = execSync("sysctl -n machdep.cpu.brand_string").toString().trim()
28+
memoryInfo = execSync("sysctl -n hw.memsize").toString().trim()
29+
memoryInfo = `${Math.round(parseInt(memoryInfo) / 1e9)} GB RAM`
30+
} else {
31+
// Linux specific commands
32+
cpuInfo = execSync("lscpu").toString().split("\n").slice(0, 5).join("\n")
33+
memoryInfo = execSync("free -h").toString()
34+
}
35+
} catch (err) {
36+
// Fallback for unsupported systems
37+
cpuInfo = Array.from(new Set(os.cpus().map((c) => c.model))).join("\n")
38+
memoryInfo = `${Math.round(os.totalmem() / 1e9)} GB RAM`
39+
}
40+
41+
return {
42+
cpuInfo,
43+
memoryInfo,
44+
os: `${os.arch()}; ${os.version()}`,
45+
nodeVersion: execSync("node -v").toString().trim(),
46+
npmVersion: execSync("npm -v").toString().trim(),
47+
clineVersion: getClineVersion(),
48+
}
49+
}
50+
51+
const checkGitHubAuth = async () => {
52+
try {
53+
execSync("gh auth status", { stdio: "ignore" })
54+
return true
55+
} catch (err) {
56+
console.log("\nGitHub authentication required.")
57+
console.log("\nPlease run the following command in your terminal to authenticate:")
58+
console.log("\n gh auth login\n")
59+
console.log("After authenticating, run this script again.")
60+
return false
61+
}
62+
}
63+
64+
const createIssueUrl = (systemInfo, issueTitle) => {
65+
return (
66+
`https://github.com/cline/cline/issues/new?template=bug_report.yml` +
67+
`&title=${issueTitle}` +
68+
`&operating-system=${systemInfo.os}` +
69+
`&cline-version=${systemInfo.clineVersion}` +
70+
`&system-info=${
71+
`Node: ${systemInfo.nodeVersion}\n` +
72+
`npm: ${systemInfo.npmVersion}\n` +
73+
`CPU Info: ${systemInfo.cpuInfo}\n` +
74+
`Free RAM: ${systemInfo.memoryInfo}`
75+
}`
76+
)
77+
}
78+
79+
const openUrl = (url) => {
80+
try {
81+
switch (process.platform) {
82+
case "darwin":
83+
execSync(`open "${url}"`)
84+
break
85+
case "win32":
86+
execSync(`start "" "${url}"`)
87+
break
88+
case "linux":
89+
execSync(`xdg-open "${url}"`)
90+
break
91+
default:
92+
console.log("\nPlease open this URL in your browser:")
93+
console.log(url)
94+
}
95+
} catch (err) {
96+
console.log("\nFailed to open URL automatically. Please open this URL in your browser:")
97+
console.log(url)
98+
}
99+
}
100+
101+
const submitIssue = async (issueTitle, systemInfo) => {
102+
try {
103+
const issueUrl = createIssueUrl(systemInfo, issueTitle)
104+
console.log("\nOpening GitHub issue creation page in your browser...")
105+
openUrl(issueUrl)
106+
} catch (err) {
107+
console.error("\nFailed to create issue URL:", err.message)
108+
}
109+
}
110+
111+
async function main() {
112+
const consent = await ask("Do you consent to collect system data and submit a GitHub issue? (y/n): ")
113+
if (consent.trim().toLowerCase() !== "y") {
114+
console.log("\nAborted.")
115+
rl.close()
116+
return
117+
}
118+
119+
console.log("Collecting system data...")
120+
const systemInfo = collectSystemInfo()
121+
122+
const isAuthenticated = await checkGitHubAuth()
123+
if (!isAuthenticated) {
124+
rl.close()
125+
return
126+
}
127+
128+
const issueTitle = await ask("Enter the title for your issue: ")
129+
130+
await submitIssue(issueTitle, systemInfo)
131+
rl.close()
132+
}
133+
134+
main().catch((err) => {
135+
console.error("\nAn error occurred:", err)
136+
rl.close()
137+
})

0 commit comments

Comments
 (0)