@openora/create 0.4.1-canary.405 → 0.4.1-canary.407
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/dist/.tsbuildinfo +1 -1
- package/dist/generated/versions.js +1 -1
- package/package.json +2 -2
- package/template/__dot__claude/settings.json.tpl +9 -0
- package/template/__dot__rulesync/hooks/guard-comments.mjs +82 -0
- package/template/__dot__rulesync/hooks.json +5 -0
- package/template/__dot__rulesync/skills/babysit/SKILL.md.tpl +48 -0
- package/template/__dot__rulesync/skills/babysit/babysit.mjs +290 -0
- package/template/__dot__rulesync/skills/create-pr/SKILL.md.tpl +1 -1
- package/template/__dot__rulesync/skills/review/SKILL.md.tpl +15 -19
- package/template/__dot__rulesync/skills/ship/SKILL.md.tpl +25 -12
- package/template/__dot__rulesync/subagents/planner.md.tpl +23 -1
- package/template/docs/agents/forge.md.tpl +9 -9
- package/template/docs/agents/issue-tracker.md.tpl +1 -1
- package/template/tools/sync-agents.mjs +7 -1
- package/template/__dot__rulesync/skills/ship/watch-pr.mjs +0 -189
|
@@ -238,7 +238,7 @@ if (owned.length > 0) {
|
|
|
238
238
|
);
|
|
239
239
|
}
|
|
240
240
|
|
|
241
|
-
// Both files are tracked by every consumer, so a template bump cannot wire these
|
|
241
|
+
// Both files are tracked by every consumer, so a template bump cannot wire these hooks in.
|
|
242
242
|
const missingWiring = [
|
|
243
243
|
[
|
|
244
244
|
'.claude/settings.json',
|
|
@@ -258,6 +258,12 @@ const missingWiring = [
|
|
|
258
258
|
'the stacked-PR gate',
|
|
259
259
|
'a PreToolUse "Bash" hook running guard-stack.mjs',
|
|
260
260
|
],
|
|
261
|
+
[
|
|
262
|
+
'.claude/settings.json',
|
|
263
|
+
'guard-comments.mjs',
|
|
264
|
+
'the comment gate',
|
|
265
|
+
'a PreToolUse "Bash" hook running guard-comments.mjs',
|
|
266
|
+
],
|
|
261
267
|
[
|
|
262
268
|
'package.json',
|
|
263
269
|
'guard-mr.mjs --stamp',
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
// Watches the MR or PR of a branch and prints one line, then exits, when ship has work on it:
|
|
3
|
-
// failed | conflicts | threads <ids> | green (only with --until-green) | merged | closed | error <message>
|
|
4
|
-
// A thread waits for an answer until the account this runs as left a final reaction on its last comment (thumbsup
|
|
5
|
-
// or question; eyes only means picked up and stays pending: the agent never writes on the MR) or that comment is its legacy "Agent:" reply; it is reported once it stayed the same for two checks, so a review with
|
|
6
|
-
// ten comments is one line. Run it in the background:
|
|
7
|
-
// node watch-pr.mjs <branch> [--until-green] WATCH_DEBUG=1 prints every check to stderr
|
|
8
|
-
// --once checks one time, for a caller that polls on its own (a scheduler): threads are reported at
|
|
9
|
-
// once, and `none` means nothing to do.
|
|
10
|
-
import { execFileSync } from 'node:child_process';
|
|
11
|
-
|
|
12
|
-
const EVERY_MS = 120_000;
|
|
13
|
-
// ponytail: a repo with no CI on the last commit reads green after this; a head-SHA match on checks if it matters
|
|
14
|
-
const NO_CI_MS = 10 * 60_000;
|
|
15
|
-
const MAX_ERRORS = 5;
|
|
16
|
-
const AGENT_REPLY = 'Agent:';
|
|
17
|
-
const FAILED = [
|
|
18
|
-
'FAILURE',
|
|
19
|
-
'ERROR',
|
|
20
|
-
'CANCELLED',
|
|
21
|
-
'TIMED_OUT',
|
|
22
|
-
'ACTION_REQUIRED',
|
|
23
|
-
'STARTUP_FAILURE',
|
|
24
|
-
'failed',
|
|
25
|
-
'canceled',
|
|
26
|
-
];
|
|
27
|
-
|
|
28
|
-
const [branch, ...flags] = process.argv.slice(2);
|
|
29
|
-
if (!branch) {
|
|
30
|
-
console.error('usage: watch-pr.mjs <branch> [--until-green | --once]');
|
|
31
|
-
process.exit(2);
|
|
32
|
-
}
|
|
33
|
-
const untilGreen = flags.includes('--until-green');
|
|
34
|
-
const once = flags.includes('--once');
|
|
35
|
-
|
|
36
|
-
const run = (cmd, args) =>
|
|
37
|
-
execFileSync(cmd, args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] });
|
|
38
|
-
const json = (cmd, args) => JSON.parse(run(cmd, args));
|
|
39
|
-
const unansweredIds = (lastComments, me) =>
|
|
40
|
-
lastComments
|
|
41
|
-
.filter(
|
|
42
|
-
(comment) =>
|
|
43
|
-
!(comment.author === me && comment.body.trimStart().startsWith(AGENT_REPLY)) &&
|
|
44
|
-
!comment.reactors.includes(me),
|
|
45
|
-
)
|
|
46
|
-
.map((comment) => String(comment.id))
|
|
47
|
-
.sort();
|
|
48
|
-
|
|
49
|
-
const THREADS = `query($owner: String!, $name: String!, $number: Int!, $endCursor: String) {
|
|
50
|
-
viewer { login }
|
|
51
|
-
repository(owner: $owner, name: $name) { pullRequest(number: $number) {
|
|
52
|
-
reviewThreads(first: 100, after: $endCursor) {
|
|
53
|
-
nodes { isResolved comments(last: 1) { nodes { id body author { login } reactions(first: 50) { nodes { content user { login } } } } } }
|
|
54
|
-
pageInfo { hasNextPage endCursor }
|
|
55
|
-
}
|
|
56
|
-
comments(last: 1) { nodes { id body author { login } reactions(first: 50) { nodes { content user { login } } } } }
|
|
57
|
-
} }
|
|
58
|
-
}`;
|
|
59
|
-
|
|
60
|
-
function github() {
|
|
61
|
-
const pr = json('gh', [
|
|
62
|
-
'pr',
|
|
63
|
-
'view',
|
|
64
|
-
branch,
|
|
65
|
-
'--json',
|
|
66
|
-
'number,url,state,mergeable,statusCheckRollup',
|
|
67
|
-
]);
|
|
68
|
-
const [, owner, name] = new URL(pr.url).pathname.split('/');
|
|
69
|
-
const args = [
|
|
70
|
-
'api',
|
|
71
|
-
'graphql',
|
|
72
|
-
'--paginate',
|
|
73
|
-
'--slurp',
|
|
74
|
-
'-f',
|
|
75
|
-
`query=${THREADS}`,
|
|
76
|
-
'-f',
|
|
77
|
-
`owner=${owner}`,
|
|
78
|
-
'-f',
|
|
79
|
-
`name=${name}`,
|
|
80
|
-
'-F',
|
|
81
|
-
`number=${pr.number}`,
|
|
82
|
-
];
|
|
83
|
-
const pages = json('gh', args).map((page) => page.data);
|
|
84
|
-
const open = pages
|
|
85
|
-
.flatMap(({ repository }) => repository.pullRequest.reviewThreads.nodes)
|
|
86
|
-
.filter((thread) => !thread.isResolved)
|
|
87
|
-
.flatMap((thread) => thread.comments.nodes)
|
|
88
|
-
.concat(pages[0].repository.pullRequest.comments.nodes)
|
|
89
|
-
.map((comment) => ({
|
|
90
|
-
...comment,
|
|
91
|
-
author: comment.author?.login,
|
|
92
|
-
reactors: comment.reactions.nodes
|
|
93
|
-
.filter((reaction) => reaction.content !== 'EYES')
|
|
94
|
-
.map((reaction) => reaction.user?.login),
|
|
95
|
-
}));
|
|
96
|
-
const checks = pr.statusCheckRollup ?? [];
|
|
97
|
-
const ci = !checks.length
|
|
98
|
-
? null
|
|
99
|
-
: checks.some((check) => FAILED.includes(check.conclusion || check.state))
|
|
100
|
-
? 'failed'
|
|
101
|
-
: checks.some((check) =>
|
|
102
|
-
check.status
|
|
103
|
-
? check.status !== 'COMPLETED'
|
|
104
|
-
: check.state === 'PENDING' || check.state === 'EXPECTED',
|
|
105
|
-
)
|
|
106
|
-
? 'running'
|
|
107
|
-
: 'passed';
|
|
108
|
-
return {
|
|
109
|
-
state: pr.state.toLowerCase(),
|
|
110
|
-
conflicts: pr.mergeable === 'CONFLICTING',
|
|
111
|
-
ci,
|
|
112
|
-
unanswered: unansweredIds(open, pages[0].viewer.login),
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function gitlab() {
|
|
117
|
-
const mr = json('glab', ['mr', 'view', branch, '-F', 'json']);
|
|
118
|
-
const discussions = run('glab', [
|
|
119
|
-
'api',
|
|
120
|
-
'--paginate',
|
|
121
|
-
'--output',
|
|
122
|
-
'ndjson',
|
|
123
|
-
`projects/${mr.project_id}/merge_requests/${mr.iid}/discussions?per_page=100`,
|
|
124
|
-
])
|
|
125
|
-
.split('\n')
|
|
126
|
-
.filter(Boolean)
|
|
127
|
-
.map((line) => JSON.parse(line));
|
|
128
|
-
const open = discussions
|
|
129
|
-
.map((discussion) => discussion.notes.filter((note) => !note.system))
|
|
130
|
-
.filter(
|
|
131
|
-
(notes) =>
|
|
132
|
-
notes.length &&
|
|
133
|
-
!(
|
|
134
|
-
notes.some((note) => note.resolvable) &&
|
|
135
|
-
notes.every((note) => !note.resolvable || note.resolved)
|
|
136
|
-
),
|
|
137
|
-
)
|
|
138
|
-
.map((notes) => notes.at(-1))
|
|
139
|
-
.map((note) => ({
|
|
140
|
-
...note,
|
|
141
|
-
author: note.author?.username,
|
|
142
|
-
reactors: json('glab', [
|
|
143
|
-
'api',
|
|
144
|
-
`projects/${mr.project_id}/merge_requests/${mr.iid}/notes/${note.id}/award_emoji`,
|
|
145
|
-
])
|
|
146
|
-
.filter((award) => award.name !== 'eyes')
|
|
147
|
-
.map((award) => award.user?.username),
|
|
148
|
-
}));
|
|
149
|
-
const pipeline = mr.head_pipeline?.sha === mr.sha ? mr.head_pipeline.status : null;
|
|
150
|
-
const ci = !pipeline
|
|
151
|
-
? null
|
|
152
|
-
: FAILED.includes(pipeline)
|
|
153
|
-
? 'failed'
|
|
154
|
-
: ['success', 'skipped', 'manual'].includes(pipeline)
|
|
155
|
-
? 'passed'
|
|
156
|
-
: 'running';
|
|
157
|
-
const state = mr.state === 'opened' ? 'open' : mr.state === 'merged' ? 'merged' : 'closed';
|
|
158
|
-
const me = json('glab', ['api', 'user']).username;
|
|
159
|
-
return { state, conflicts: mr.has_conflicts === true, ci, unanswered: unansweredIds(open, me) };
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
const say = (line) => {
|
|
163
|
-
console.log(line);
|
|
164
|
-
process.exit(0);
|
|
165
|
-
};
|
|
166
|
-
const status = /github\.com/.test(run('git', ['remote', 'get-url', 'origin'])) ? github : gitlab;
|
|
167
|
-
const started = Date.now();
|
|
168
|
-
let seen = null;
|
|
169
|
-
let errors = 0;
|
|
170
|
-
for (;;) {
|
|
171
|
-
try {
|
|
172
|
-
const now = status();
|
|
173
|
-
errors = 0;
|
|
174
|
-
if (process.env.WATCH_DEBUG) console.error(JSON.stringify(now));
|
|
175
|
-
if (now.state !== 'open') say(now.state);
|
|
176
|
-
if (now.conflicts) say('conflicts');
|
|
177
|
-
if (now.ci === 'failed') say('failed');
|
|
178
|
-
const ids = now.unanswered.join(' ');
|
|
179
|
-
if (ids && (once || ids === seen)) say(`threads ${ids}`);
|
|
180
|
-
seen = ids;
|
|
181
|
-
const green = now.ci === 'passed' || (now.ci === null && Date.now() - started >= NO_CI_MS);
|
|
182
|
-
if (untilGreen && green && !ids) say('green');
|
|
183
|
-
if (once) say('none');
|
|
184
|
-
} catch (reason) {
|
|
185
|
-
if (once || ++errors >= MAX_ERRORS)
|
|
186
|
-
say(`error ${reason instanceof Error ? reason.message.split('\n')[0] : reason}`);
|
|
187
|
-
}
|
|
188
|
-
await new Promise((resolve) => setTimeout(resolve, EVERY_MS));
|
|
189
|
-
}
|