-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
67 lines (62 loc) · 1.81 KB
/
Copy pathindex.js
File metadata and controls
67 lines (62 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* GitHub Issue Resolver Plugin for OpenClaw
*
* This plugin provides tools to fetch and analyze GitHub issues.
*
* Tools:
* - github_issues: List issues from a repository
* - github_issue_analyze: Analyze a specific issue (coming soon)
*/
const https = require('https');
// Helper function to make HTTPS requests
function fetchJSON(url) {
return new Promise((resolve, reject) => {
https.get(url, { headers: { 'User-Agent': 'OpenClaw-GitHub-Plugin' } }, (res) => {
let data = '';
res.on('data', chunk => data += chunk);
res.on('end', () => {
try {
resolve(JSON.parse(data));
} catch (e) {
reject(new Error('Failed to parse JSON'));
}
});
}).on('error', reject);
});
}
module.exports = {
// Tool: github_issues
github_issues: async ({ owner, repo, state = 'open', per_page = 30 }) => {
try {
const url = `https://api.github.com/repos/${owner}/${repo}/issues?state=${state}&per_page=${per_page}`;
const issues = await fetchJSON(url);
return {
success: true,
count: issues.length,
issues: issues.map(i => ({
number: i.number,
title: i.title,
state: i.state,
labels: i.labels.map(l => l.name),
score: i.score,
comments: i.comments,
updated_at: i.updated_at,
url: i.html_url,
body_preview: i.body ? i.body.substring(0, 200) + '...' : null
}))
};
} catch (error) {
return {
success: false,
error: error.message
};
}
},
// Tool: github_issue_analyze (placeholder)
github_issue_analyze: async ({ owner, repo, issue_number }) => {
return {
success: true,
message: `Analysis for issue #${issue_number} in ${owner}/${repo} (coming soon)`
};
}
};