opencode-magi 0.10.0 → 0.11.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.ja.md +254 -0
- package/README.md +31 -26
- package/dist/commands.js +11 -9
- package/dist/config/index.js +2 -0
- package/dist/config/resolve.js +120 -246
- package/dist/config/validate.js +103 -1110
- package/dist/constant.js +135 -0
- package/dist/graphql/index.generated.js +125 -0
- package/dist/graphql/index.js +49 -0
- package/dist/index.js +12 -800
- package/dist/magi.js +357 -0
- package/dist/permissions/common.json +22 -22
- package/dist/permissions/editor.json +12 -12
- package/dist/prompts/index.js +98 -0
- package/dist/prompts/merge/ci-classification/output-contract.md +22 -0
- package/dist/prompts/merge/ci-classification/task.md +10 -0
- package/dist/prompts/merge/ci-classification/validate.json +20 -0
- package/dist/prompts/merge/conflict/output-contract.md +12 -0
- package/dist/prompts/merge/conflict/task.md +9 -0
- package/dist/prompts/merge/conflict/validate.json +4 -0
- package/dist/prompts/merge/edit/output-contract.md +26 -0
- package/dist/prompts/merge/edit/task.md +10 -0
- package/dist/prompts/merge/edit/validate.json +60 -0
- package/dist/prompts/review/ci-classification/output-contract.md +21 -0
- package/dist/prompts/review/ci-classification/task.md +7 -0
- package/dist/prompts/review/ci-classification/validate.json +20 -0
- package/dist/prompts/review/close-reconsideration/output-contract.md +21 -0
- package/dist/prompts/review/close-reconsideration/task.md +6 -0
- package/dist/prompts/review/close-reconsideration/validate.json +44 -0
- package/dist/prompts/review/comment/output-contract.md +11 -0
- package/dist/prompts/review/comment/task.md +3 -0
- package/dist/prompts/review/comment/validate.json +8 -0
- package/dist/prompts/review/finding-validation/output-contract.md +25 -0
- package/dist/prompts/{templates/review/finding-validation.md → review/finding-validation/task.md} +2 -3
- package/dist/prompts/review/finding-validation/validate.json +21 -0
- package/dist/prompts/review/rereview/output-contract.md +30 -0
- package/dist/prompts/{templates/review/rereview.md → review/rereview/task.md} +8 -11
- package/dist/prompts/review/rereview/validate.json +87 -0
- package/dist/prompts/review/review/output-contract.md +25 -0
- package/dist/prompts/{templates/review/review.md → review/review/task.md} +2 -5
- package/dist/prompts/review/review/validate.json +54 -0
- package/dist/prompts/triage/acceptance/output-contract.md +16 -0
- package/dist/prompts/triage/acceptance/validate.json +23 -0
- package/dist/prompts/triage/category/output-contract.md +16 -0
- package/dist/prompts/triage/category/validate.json +23 -0
- package/dist/prompts/triage/comment-classification/output-contract.md +15 -0
- package/dist/prompts/triage/comment-classification/validate.json +28 -0
- package/dist/prompts/triage/create/output-contract.md +28 -0
- package/dist/prompts/triage/create/validate.json +73 -0
- package/dist/prompts/triage/deplicate/output-contract.md +16 -0
- package/dist/prompts/triage/deplicate/validate.json +20 -0
- package/dist/prompts/triage/existing/output-contract.md +16 -0
- package/dist/prompts/triage/existing/validate.json +13 -0
- package/dist/prompts/triage/reconsider/output-contract.md +16 -0
- package/dist/prompts/triage/reconsider/validate.json +23 -0
- package/dist/prompts/triage/signal/output-contract.md +19 -0
- package/dist/prompts/triage/signal/validate.json +18 -0
- package/dist/tools/clear/index.js +21 -0
- package/dist/tools/index.js +12 -0
- package/dist/tools/merge/action.js +47 -0
- package/dist/tools/merge/context.js +118 -0
- package/dist/tools/merge/editor.js +264 -0
- package/dist/tools/merge/index.js +151 -0
- package/dist/tools/merge/index.type.js +1 -0
- package/dist/tools/merge/merge.js +42 -0
- package/dist/tools/merge/report.js +73 -0
- package/dist/tools/review/action.js +429 -0
- package/dist/tools/review/check.js +295 -0
- package/dist/tools/review/context.js +258 -0
- package/dist/tools/review/index.js +104 -0
- package/dist/tools/review/index.type.js +1 -0
- package/dist/tools/review/report.js +143 -0
- package/dist/tools/review/review.js +145 -0
- package/dist/tools/review/reviewer.js +409 -0
- package/dist/tools/triage/index.js +16 -0
- package/dist/tools/validate/index.js +28 -0
- package/dist/utils/array.js +6 -0
- package/dist/utils/assertion.js +38 -0
- package/dist/utils/exec.js +14 -0
- package/dist/utils/fs.js +24 -0
- package/dist/utils/function.js +37 -0
- package/dist/utils/github.js +63 -0
- package/dist/utils/index.js +10 -0
- package/dist/utils/index.type.js +1 -0
- package/dist/utils/object.js +21 -0
- package/dist/utils/opencode.js +25 -0
- package/dist/utils/string.js +38 -0
- package/dist/utils/worker.js +30 -0
- package/package.json +20 -8
- package/schema.json +6 -4
- package/dist/config/load.js +0 -62
- package/dist/config/output.js +0 -25
- package/dist/config/worktree.js +0 -25
- package/dist/github/commands.js +0 -905
- package/dist/github/retry.js +0 -44
- package/dist/orchestrator/abort.js +0 -9
- package/dist/orchestrator/ci.js +0 -579
- package/dist/orchestrator/findings.js +0 -88
- package/dist/orchestrator/inline-comments.js +0 -73
- package/dist/orchestrator/majority.js +0 -62
- package/dist/orchestrator/merge.js +0 -1260
- package/dist/orchestrator/model.js +0 -216
- package/dist/orchestrator/pool.js +0 -15
- package/dist/orchestrator/report.js +0 -175
- package/dist/orchestrator/review-context.js +0 -342
- package/dist/orchestrator/review.js +0 -1480
- package/dist/orchestrator/run-manager.js +0 -2132
- package/dist/orchestrator/safety.js +0 -44
- package/dist/orchestrator/triage.js +0 -1370
- package/dist/prompts/compose.js +0 -473
- package/dist/prompts/contracts.js +0 -300
- package/dist/prompts/output.js +0 -401
- package/dist/prompts/templates/merge/ci-classification.md +0 -16
- package/dist/prompts/templates/merge/conflict.md +0 -10
- package/dist/prompts/templates/merge/edit.md +0 -15
- package/dist/prompts/templates/review/ci-classification.md +0 -9
- package/dist/prompts/templates/review/close-reconsideration.md +0 -6
- /package/dist/{types.js → config/index.type.js} +0 -0
- /package/dist/prompts/{templates/triage/acceptance.md → triage/acceptance/task.md} +0 -0
- /package/dist/prompts/{templates/triage/category.md → triage/category/task.md} +0 -0
- /package/dist/prompts/{templates/triage/comment-classification.md → triage/comment-classification/task.md} +0 -0
- /package/dist/prompts/{templates/triage/create.md → triage/create/task.md} +0 -0
- /package/dist/prompts/{templates/triage/duplicate.md → triage/deplicate/task.md} +0 -0
- /package/dist/prompts/{templates/triage/existing-pr.md → triage/existing/task.md} +0 -0
- /package/dist/prompts/{templates/triage/reconsider.md → triage/reconsider/task.md} +0 -0
- /package/dist/prompts/{templates/triage/signal.md → triage/signal/task.md} +0 -0
package/dist/constant.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import commonPermissions from "./permissions/common.json" with { type: "json" };
|
|
4
|
+
export const CONFIG_PATH = {
|
|
5
|
+
GLOBAL: join(homedir(), ".config", "opencode", "magi.json"),
|
|
6
|
+
PROJECT: join(".opencode", "magi.json"),
|
|
7
|
+
};
|
|
8
|
+
export const DEFAULT_CONFIG = {
|
|
9
|
+
agents: {
|
|
10
|
+
permissions: commonPermissions,
|
|
11
|
+
},
|
|
12
|
+
clear: {
|
|
13
|
+
branch: true,
|
|
14
|
+
output: true,
|
|
15
|
+
session: true,
|
|
16
|
+
worktree: true,
|
|
17
|
+
},
|
|
18
|
+
github: {
|
|
19
|
+
host: "github.com",
|
|
20
|
+
owner: "",
|
|
21
|
+
repo: "",
|
|
22
|
+
retryApiAttempts: 3,
|
|
23
|
+
url: "",
|
|
24
|
+
},
|
|
25
|
+
language: "en",
|
|
26
|
+
merge: {
|
|
27
|
+
automation: {
|
|
28
|
+
close: false,
|
|
29
|
+
conflict: false,
|
|
30
|
+
merge: true,
|
|
31
|
+
},
|
|
32
|
+
checks: {
|
|
33
|
+
wait: true,
|
|
34
|
+
},
|
|
35
|
+
maxThreadResolutionCycles: 5,
|
|
36
|
+
},
|
|
37
|
+
mode: "single",
|
|
38
|
+
output: {
|
|
39
|
+
repairAttempts: 3,
|
|
40
|
+
},
|
|
41
|
+
review: {
|
|
42
|
+
automation: {
|
|
43
|
+
close: false,
|
|
44
|
+
merge: true,
|
|
45
|
+
},
|
|
46
|
+
checks: {
|
|
47
|
+
exclude: [],
|
|
48
|
+
retryFailedJobs: 3,
|
|
49
|
+
wait: true,
|
|
50
|
+
},
|
|
51
|
+
concurrency: {
|
|
52
|
+
reviewers: 3,
|
|
53
|
+
runs: 3,
|
|
54
|
+
},
|
|
55
|
+
merge: {
|
|
56
|
+
approvalPolicy: "majority",
|
|
57
|
+
auto: true,
|
|
58
|
+
deleteBranch: true,
|
|
59
|
+
method: "squash",
|
|
60
|
+
queue: false,
|
|
61
|
+
},
|
|
62
|
+
output: ".magi/runs/pr",
|
|
63
|
+
safety: {
|
|
64
|
+
allowAuthors: [],
|
|
65
|
+
blockedPaths: [],
|
|
66
|
+
requiredLabels: [],
|
|
67
|
+
},
|
|
68
|
+
worktree: ".magi/worktrees/pr",
|
|
69
|
+
},
|
|
70
|
+
triage: {
|
|
71
|
+
automation: {
|
|
72
|
+
close: false,
|
|
73
|
+
create: false,
|
|
74
|
+
label: [
|
|
75
|
+
{ remove: ["triage"], when: { disposition: "accepted" } },
|
|
76
|
+
{
|
|
77
|
+
add: ["duplicate"],
|
|
78
|
+
remove: ["triage"],
|
|
79
|
+
when: { disposition: "duplicate" },
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
add: ["duplicate"],
|
|
83
|
+
remove: ["triage"],
|
|
84
|
+
when: { disposition: "already_handled" },
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
add: ["wontfix"],
|
|
88
|
+
remove: ["triage"],
|
|
89
|
+
when: { disposition: "rejected" },
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
add: ["invalid"],
|
|
93
|
+
remove: ["triage"],
|
|
94
|
+
when: { disposition: "invalid" },
|
|
95
|
+
},
|
|
96
|
+
{ add: ["question"], when: { disposition: "needs_category" } },
|
|
97
|
+
{ add: ["question"], when: { disposition: "needs_acceptance" } },
|
|
98
|
+
],
|
|
99
|
+
merge: false,
|
|
100
|
+
review: false,
|
|
101
|
+
},
|
|
102
|
+
categories: [
|
|
103
|
+
{
|
|
104
|
+
description: "Something is broken or behaves incorrectly.",
|
|
105
|
+
id: "bug",
|
|
106
|
+
labels: ["bug"],
|
|
107
|
+
types: ["Bug"],
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
description: "Maintenance, refactoring, chores, or planned work.",
|
|
111
|
+
id: "task",
|
|
112
|
+
labels: ["task"],
|
|
113
|
+
types: ["Task"],
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
description: "New or improved user-facing capability.",
|
|
117
|
+
id: "feature",
|
|
118
|
+
labels: ["enhancement"],
|
|
119
|
+
types: ["Feature"],
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
concurrency: {
|
|
123
|
+
runs: 3,
|
|
124
|
+
},
|
|
125
|
+
output: ".magi/runs/issue",
|
|
126
|
+
safety: {
|
|
127
|
+
allowAuthors: [],
|
|
128
|
+
allowMentionActors: [],
|
|
129
|
+
allowMentionRoles: ["AUTHOR", "OWNER", "MEMBER", "COLLABORATOR"],
|
|
130
|
+
blockedLabels: [],
|
|
131
|
+
requiredLabels: ["triage"],
|
|
132
|
+
},
|
|
133
|
+
worktree: ".magi/worktrees/issue",
|
|
134
|
+
},
|
|
135
|
+
};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import gql from 'graphql-tag';
|
|
2
|
+
export const ClosingIssuesDocument = gql `
|
|
3
|
+
query closingIssues($cursor: String, $owner: String!, $repo: String!, $pr: Int!) {
|
|
4
|
+
repository(owner: $owner, name: $repo) {
|
|
5
|
+
pullRequest(number: $pr) {
|
|
6
|
+
closingIssuesReferences(first: 50, after: $cursor) {
|
|
7
|
+
nodes {
|
|
8
|
+
author {
|
|
9
|
+
login
|
|
10
|
+
}
|
|
11
|
+
body
|
|
12
|
+
comments(last: 50) {
|
|
13
|
+
nodes {
|
|
14
|
+
author {
|
|
15
|
+
login
|
|
16
|
+
}
|
|
17
|
+
body
|
|
18
|
+
createdAt
|
|
19
|
+
databaseId
|
|
20
|
+
url
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
number
|
|
24
|
+
state
|
|
25
|
+
title
|
|
26
|
+
url
|
|
27
|
+
}
|
|
28
|
+
pageInfo {
|
|
29
|
+
endCursor
|
|
30
|
+
hasNextPage
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
export const EnqueuePullRequestDocument = gql `
|
|
38
|
+
mutation enqueuePullRequest($id: ID!) {
|
|
39
|
+
enqueuePullRequest(input: {pullRequestId: $id}) {
|
|
40
|
+
mergeQueueEntry {
|
|
41
|
+
id
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
`;
|
|
46
|
+
export const MergeQueueStatusDocument = gql `
|
|
47
|
+
query mergeQueueStatus($owner: String!, $repo: String!, $pr: Int!) {
|
|
48
|
+
repository(owner: $owner, name: $repo) {
|
|
49
|
+
pullRequest(number: $pr) {
|
|
50
|
+
state
|
|
51
|
+
isInMergeQueue
|
|
52
|
+
mergeQueueEntry {
|
|
53
|
+
id
|
|
54
|
+
}
|
|
55
|
+
timelineItems(last: 1, itemTypes: REMOVED_FROM_MERGE_QUEUE_EVENT) {
|
|
56
|
+
nodes {
|
|
57
|
+
... on RemovedFromMergeQueueEvent {
|
|
58
|
+
createdAt
|
|
59
|
+
reason
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
`;
|
|
67
|
+
export const ResolveReviewThreadDocument = gql `
|
|
68
|
+
mutation resolveReviewThread($threadId: ID!) {
|
|
69
|
+
resolveReviewThread(input: {threadId: $threadId}) {
|
|
70
|
+
thread {
|
|
71
|
+
id
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
export const ReviewThreadsDocument = gql `
|
|
77
|
+
query reviewThreads($cursor: String, $owner: String!, $repo: String!, $pr: Int!) {
|
|
78
|
+
repository(owner: $owner, name: $repo) {
|
|
79
|
+
pullRequest(number: $pr) {
|
|
80
|
+
reviewThreads(first: 50, after: $cursor) {
|
|
81
|
+
nodes {
|
|
82
|
+
comments(last: 50) {
|
|
83
|
+
nodes {
|
|
84
|
+
author {
|
|
85
|
+
login
|
|
86
|
+
}
|
|
87
|
+
body
|
|
88
|
+
createdAt
|
|
89
|
+
databaseId
|
|
90
|
+
url
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
id
|
|
94
|
+
isResolved
|
|
95
|
+
line
|
|
96
|
+
path
|
|
97
|
+
}
|
|
98
|
+
pageInfo {
|
|
99
|
+
endCursor
|
|
100
|
+
hasNextPage
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
`;
|
|
107
|
+
export function getSdk(requester) {
|
|
108
|
+
return {
|
|
109
|
+
closingIssues(variables, options) {
|
|
110
|
+
return requester(ClosingIssuesDocument, variables, options);
|
|
111
|
+
},
|
|
112
|
+
enqueuePullRequest(variables, options) {
|
|
113
|
+
return requester(EnqueuePullRequestDocument, variables, options);
|
|
114
|
+
},
|
|
115
|
+
mergeQueueStatus(variables, options) {
|
|
116
|
+
return requester(MergeQueueStatusDocument, variables, options);
|
|
117
|
+
},
|
|
118
|
+
resolveReviewThread(variables, options) {
|
|
119
|
+
return requester(ResolveReviewThreadDocument, variables, options);
|
|
120
|
+
},
|
|
121
|
+
reviewThreads(variables, options) {
|
|
122
|
+
return requester(ReviewThreadsDocument, variables, options);
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { isObject } from "@/utils";
|
|
2
|
+
import { getSdk } from "./index.generated";
|
|
3
|
+
function isConnection(value) {
|
|
4
|
+
if (!value || !isObject(value))
|
|
5
|
+
return false;
|
|
6
|
+
return "nodes" in value && "pageInfo" in value;
|
|
7
|
+
}
|
|
8
|
+
function findConnection(value) {
|
|
9
|
+
if (isConnection(value))
|
|
10
|
+
return value;
|
|
11
|
+
if (!value || !isObject(value))
|
|
12
|
+
return undefined;
|
|
13
|
+
for (const child of Object.values(value)) {
|
|
14
|
+
const connection = findConnection(child);
|
|
15
|
+
if (connection)
|
|
16
|
+
return connection;
|
|
17
|
+
}
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
export function graphql(requester) {
|
|
21
|
+
const sdk = getSdk(requester);
|
|
22
|
+
const bound = Object.fromEntries(Object.entries(sdk).map(([key, req]) => [key, req.bind(sdk)]));
|
|
23
|
+
async function paginate(req, params) {
|
|
24
|
+
let cursor = params.cursor ?? null;
|
|
25
|
+
let result;
|
|
26
|
+
for (;;) {
|
|
27
|
+
const page = (await req({
|
|
28
|
+
...params,
|
|
29
|
+
cursor,
|
|
30
|
+
}));
|
|
31
|
+
const connection = findConnection(page);
|
|
32
|
+
if (!connection)
|
|
33
|
+
return page;
|
|
34
|
+
if (!result) {
|
|
35
|
+
result = page;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
const target = findConnection(result);
|
|
39
|
+
target?.nodes?.push(...(connection.nodes ?? []));
|
|
40
|
+
}
|
|
41
|
+
if (!connection.pageInfo?.hasNextPage)
|
|
42
|
+
return result;
|
|
43
|
+
cursor = connection.pageInfo.endCursor ?? null;
|
|
44
|
+
if (!cursor)
|
|
45
|
+
throw new Error("GraphQL page was truncated");
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return { ...bound, paginate };
|
|
49
|
+
}
|