@ravshansbox/pi-github 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/github.js +4 -0
- package/dist/poller.js +2 -0
- package/dist/watch.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@ Watches open issues in a GitHub repo and answers new issues and comments with [p
|
|
|
7
7
|
- Polls the repo of the current directory for new issues and comments every 30 seconds. Pull requests are ignored.
|
|
8
8
|
- Only handles issues and comments created after the first start. After a restart it picks up where it stopped, including runs a crash cut off. A crash right after posting a reply can lead to that reply being posted twice.
|
|
9
9
|
- Each issue gets its own git worktree in `.worktrees/issue-<number>` on branch `issue-<number>`, and its own pi session that continues across comments.
|
|
10
|
+
- New issues and comments get an 👀 reaction as soon as they are picked up.
|
|
10
11
|
- Issues are handled in parallel, up to 3 at once. Comments on the same issue are handled one after another.
|
|
11
12
|
- The agent's final message is posted as a comment that starts with `agent:`. Comments that start with `agent:` are ignored, so it does not answer itself.
|
|
12
13
|
- If the agent made commits, the branch is pushed and a pull request is opened once. Later commits update the same pull request.
|
|
@@ -22,7 +23,7 @@ Watches open issues in a GitHub repo and answers new issues and comments with [p
|
|
|
22
23
|
|
|
23
24
|
```sh
|
|
24
25
|
cd path/to/your/repo
|
|
25
|
-
npx -y @ravshansbox/pi-github [--interval <seconds>] [--concurrency <number>]
|
|
26
|
+
npx -y @ravshansbox/pi-github@latest [--interval <seconds>] [--concurrency <number>]
|
|
26
27
|
```
|
|
27
28
|
|
|
28
29
|
Press Ctrl+C to stop after running agents finish, or press it twice to quit at once.
|
package/dist/github.js
CHANGED
|
@@ -44,6 +44,10 @@ export function createGitHub({ baseUrl, token, repo }) {
|
|
|
44
44
|
postComment: async (issueNumber, body) => {
|
|
45
45
|
await request("POST", `/repos/${repo}/issues/${issueNumber}/comments`, { body });
|
|
46
46
|
},
|
|
47
|
+
addReaction: async (target, content) => {
|
|
48
|
+
const path = target.kind === "issue" ? `issues/${target.id}` : `issues/comments/${target.id}`;
|
|
49
|
+
await request("POST", `/repos/${repo}/${path}/reactions`, { content });
|
|
50
|
+
},
|
|
47
51
|
getDefaultBranch: async () => {
|
|
48
52
|
const data = (await (await request("GET", `/repos/${repo}`)).json());
|
|
49
53
|
return data.default_branch;
|
package/dist/poller.js
CHANGED
|
@@ -15,6 +15,7 @@ export async function poll(github, state) {
|
|
|
15
15
|
.map((issue) => ({
|
|
16
16
|
key: `issue:${issue.number}`,
|
|
17
17
|
kind: "issue",
|
|
18
|
+
id: issue.number,
|
|
18
19
|
issueNumber: issue.number,
|
|
19
20
|
author: issue.user.login,
|
|
20
21
|
body: issue.body ?? "",
|
|
@@ -25,6 +26,7 @@ export async function poll(github, state) {
|
|
|
25
26
|
.map((comment) => ({
|
|
26
27
|
key: `comment:${comment.id}`,
|
|
27
28
|
kind: "comment",
|
|
29
|
+
id: comment.id,
|
|
28
30
|
issueNumber: Number(comment.issue_url.split("/").pop()),
|
|
29
31
|
author: comment.user.login,
|
|
30
32
|
body: comment.body,
|
package/dist/watch.js
CHANGED
|
@@ -57,6 +57,7 @@ export async function watch({ github, agent, repoRoot, stateFile, intervalMs, co
|
|
|
57
57
|
for (const trigger of result.triggers) {
|
|
58
58
|
log(`#${trigger.issueNumber}: new ${trigger.kind} from @${trigger.author}`);
|
|
59
59
|
dispatcher.dispatch(trigger);
|
|
60
|
+
await github.addReaction(trigger, "eyes").catch((error) => log(`#${trigger.issueNumber}: reaction failed: ${error instanceof Error ? error.message : error}`));
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
catch (error) {
|