@a9n-shoji/rvw 0.2.3 → 0.2.5
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/CHANGELOG.md +29 -0
- package/dist/cli.mjs +89 -35
- package/dist/cli.mjs.map +2 -2
- package/dist/web/assets/{DocumentViewer-B4LdSL1l.js → DocumentViewer-C2e6Mgta.js} +49 -40
- package/dist/web/assets/MarkdownTable-bGEPkcFA.js +7 -0
- package/dist/web/assets/WalkthroughViewer-TxeLcTE2.js +1 -0
- package/dist/web/assets/{abnfDiagram-N423BO3Z-CE1nZSC9.js → abnfDiagram-N423BO3Z-gOmziSzZ.js} +1 -1
- package/dist/web/assets/architecture-TIHT7OUA-B9tjggXM.js +1 -0
- package/dist/web/assets/{architectureDiagram-T3A2C74G-B88qYFUo.js → architectureDiagram-T3A2C74G-C9sPb-OU.js} +1 -1
- package/dist/web/assets/{blockDiagram-VBNYF7ZC-BaX0rhbb.js → blockDiagram-VBNYF7ZC-CxqI40sc.js} +1 -1
- package/dist/web/assets/{c4Diagram-5PPSVZJV-C1ppBaEC.js → c4Diagram-5PPSVZJV-BAK8Z0Vr.js} +1 -1
- package/dist/web/assets/channel-BD2FosIt.js +1 -0
- package/dist/web/assets/{chunk-2GRJ4B5K-D2TTocfh.js → chunk-2GRJ4B5K-oKAARewZ.js} +1 -1
- package/dist/web/assets/{chunk-4I5QYGJK-ikT25rPN.js → chunk-4I5QYGJK-BAAbxidn.js} +1 -1
- package/dist/web/assets/{chunk-5RXB4S5H-CGlPaulj.js → chunk-5RXB4S5H-DQ-Dk-To.js} +1 -1
- package/dist/web/assets/{chunk-6Q2QTUOP-BuuMeCo2.js → chunk-6Q2QTUOP-B64WcpmV.js} +1 -1
- package/dist/web/assets/{chunk-7Z6QIM7H-DT3BAZ4L.js → chunk-7Z6QIM7H-DiUNIjSC.js} +1 -1
- package/dist/web/assets/{chunk-GF5L2VYU-mIdlxzfr.js → chunk-GF5L2VYU-rbtkA8ZE.js} +1 -1
- package/dist/web/assets/{chunk-I66GZJ75-CGl1hx4J.js → chunk-I66GZJ75-BywUmQY9.js} +1 -1
- package/dist/web/assets/{chunk-JQJVKLGR-BLG6gAfx.js → chunk-JQJVKLGR-BW097h_E.js} +1 -1
- package/dist/web/assets/{chunk-KBJHAD2P-D_MPzBJx.js → chunk-KBJHAD2P-C1kXPXRi.js} +1 -1
- package/dist/web/assets/{chunk-NSK5VX7P-CiYiU8wP.js → chunk-NSK5VX7P-kej84W5N.js} +1 -1
- package/dist/web/assets/{chunk-QR6OTTB3-BK8Tnvcc.js → chunk-QR6OTTB3-BOzVZt4h.js} +1 -1
- package/dist/web/assets/{chunk-UBXNYLIW-BuzttTFk.js → chunk-UBXNYLIW-CJsGqSLH.js} +1 -1
- package/dist/web/assets/{chunk-W5SLKNZC-UidmFHe2.js → chunk-W5SLKNZC-BcRL2jRx.js} +1 -1
- package/dist/web/assets/{chunk-WRU74C26-nox7WFnh.js → chunk-WRU74C26-BDqViURG.js} +1 -1
- package/dist/web/assets/classDiagram-JCYQIIEL-yDkoGFrq.js +1 -0
- package/dist/web/assets/classDiagram-v2-OCEON4UE-yDkoGFrq.js +1 -0
- package/dist/web/assets/{cynefin-VYW2F7L2-wDMibS5s.js → cynefin-VYW2F7L2-Dugz8jnV.js} +1 -1
- package/dist/web/assets/{cynefinDiagram-MW4NZA55-CBTrdvOE.js → cynefinDiagram-MW4NZA55-D-C0yr-E.js} +1 -1
- package/dist/web/assets/{dagre-VZM6K2ZE-Bbgn4Rr7.js → dagre-VZM6K2ZE-Cw5E1SBZ.js} +1 -1
- package/dist/web/assets/{diagram-7IWD3JNH-Bm9AuXb9.js → diagram-7IWD3JNH-Sf7kJZ8B.js} +1 -1
- package/dist/web/assets/{diagram-B4RE2ZJO-D3lZ-r-H.js → diagram-B4RE2ZJO-yCiqe-d4.js} +1 -1
- package/dist/web/assets/{diagram-LBJQPF4R-D-GaynX7.js → diagram-LBJQPF4R-GOlna-Ju.js} +1 -1
- package/dist/web/assets/{diagram-Q27KOJAE-BeZRiu1d.js → diagram-Q27KOJAE-D6EGrNVJ.js} +1 -1
- package/dist/web/assets/{diagram-UB23O5K3-C3GP7iMe.js → diagram-UB23O5K3-DdPGDYZ-.js} +1 -1
- package/dist/web/assets/{ebnfDiagram-BXEA7PRR-BJWg0NVU.js → ebnfDiagram-BXEA7PRR-Cm7S99yh.js} +1 -1
- package/dist/web/assets/{erDiagram-JOGREHBK-XPmhUeB_.js → erDiagram-JOGREHBK-BaGSsO0U.js} +1 -1
- package/dist/web/assets/eventmodeling-45OFAUF4-CbAFmLja.js +1 -0
- package/dist/web/assets/flowDiagram-UKHOOZJN-Dz1a-iuK.js +1 -0
- package/dist/web/assets/{ganttDiagram-PKOTCBZU-CL-xEo-M.js → ganttDiagram-PKOTCBZU-Dcim-2qK.js} +1 -1
- package/dist/web/assets/{gitGraph-TEB2WS4Q-BVRyuIx3.js → gitGraph-TEB2WS4Q-BhPbNzbD.js} +1 -1
- package/dist/web/assets/{gitGraphDiagram-DS77QQ5N-BVNIEupW.js → gitGraphDiagram-DS77QQ5N-5n4OZuxI.js} +1 -1
- package/dist/web/assets/index-BOdYI3os.css +1 -0
- package/dist/web/assets/index-D2MzuS4L.js +384 -0
- package/dist/web/assets/{info-DKCQHKI2-BKBUVpfc.js → info-DKCQHKI2-B18FoJmv.js} +1 -1
- package/dist/web/assets/{infoDiagram-6WML65LV-_dTFnzSE.js → infoDiagram-6WML65LV-Cjd9H30j.js} +1 -1
- package/dist/web/assets/{ishikawaDiagram-WSZJBQD7-DIRgD4hO.js → ishikawaDiagram-WSZJBQD7-B2HYwzk0.js} +1 -1
- package/dist/web/assets/{journeyDiagram-NVQOT4AX-bp7nZrfR.js → journeyDiagram-NVQOT4AX-CIIOlEIS.js} +1 -1
- package/dist/web/assets/{kanban-definition-27J2QSJJ-C6mZIo8S.js → kanban-definition-27J2QSJJ-DpD98gCE.js} +1 -1
- package/dist/web/assets/{line-DWTym7eJ.js → line-1uMtgP84.js} +1 -1
- package/dist/web/assets/{mermaid-parser.core-CbecsNA1.js → mermaid-parser.core-CsoLrwW_.js} +3 -3
- package/dist/web/assets/{mermaid.core-CdRuLyYI.js → mermaid.core-DLvBOZ4b.js} +4 -4
- package/dist/web/assets/{mindmap-definition-FAOFIHXS-CU2P1z-9.js → mindmap-definition-FAOFIHXS-aX8l0lZ8.js} +1 -1
- package/dist/web/assets/{packet-7NZHBO7P-CZsup6Od.js → packet-7NZHBO7P-C2mk4cRM.js} +1 -1
- package/dist/web/assets/{pegDiagram-VL7TDLO6-DTTyttpe.js → pegDiagram-VL7TDLO6-DJxCPsMd.js} +1 -1
- package/dist/web/assets/{pie-RZYD4A2V-DgrIiWZA.js → pie-RZYD4A2V-ZvoBUm4W.js} +1 -1
- package/dist/web/assets/{pieDiagram-7S7Q4E2Y-BBNFyPT1.js → pieDiagram-7S7Q4E2Y-B_Zxlt9c.js} +1 -1
- package/dist/web/assets/{quadrantDiagram-CIZ2JOQS-ejp-Aa2l.js → quadrantDiagram-CIZ2JOQS-BdQdNvfJ.js} +1 -1
- package/dist/web/assets/{radar-I7S5WNFK-Cp_hfjrI.js → radar-I7S5WNFK-C50TztIy.js} +1 -1
- package/dist/web/assets/{railroad-3IZDKUUU-Dw-oMal2.js → railroad-3IZDKUUU-C_CK0C2Y.js} +1 -1
- package/dist/web/assets/railroad-abnf-AHOZXSZD-DEjonoj9.js +1 -0
- package/dist/web/assets/railroad-ebnf-EBAXGLYW-BGY58zLm.js +1 -0
- package/dist/web/assets/railroad-peg-LSFZ7HO6-9byrH0Ii.js +1 -0
- package/dist/web/assets/{railroadDiagram-AXF67PYL-DkBUaj6Z.js → railroadDiagram-AXF67PYL-CZ1vA-S_.js} +1 -1
- package/dist/web/assets/{requirementDiagram-LRYGKXZP-Dff1ex_h.js → requirementDiagram-LRYGKXZP-BDp4_zQI.js} +1 -1
- package/dist/web/assets/{sankeyDiagram-W5VNT64P-DptSL9Bc.js → sankeyDiagram-W5VNT64P-CQQl9FYv.js} +1 -1
- package/dist/web/assets/{sequenceDiagram-SI44F4Z6-DEnPcs3U.js → sequenceDiagram-SI44F4Z6-BGANFekR.js} +1 -1
- package/dist/web/assets/{stateDiagram-OKZ733FA-BwJO1MKA.js → stateDiagram-OKZ733FA-DbYseVuv.js} +1 -1
- package/dist/web/assets/stateDiagram-v2-UEYNNEHI-CaYT-_kk.js +1 -0
- package/dist/web/assets/{swimlanes-SLNWSIFB-BosKiwZA.js → swimlanes-SLNWSIFB-Db9iJuW8.js} +1 -1
- package/dist/web/assets/swimlanesDiagram-ULZ7WXOC-CgMcCXPx.js +8 -0
- package/dist/web/assets/{timeline-definition-Z64GVDOM-C5isAn4X.js → timeline-definition-Z64GVDOM-Ioz0wd0X.js} +1 -1
- package/dist/web/assets/{treeView-QDETBFTQ-zEyUXRc4.js → treeView-QDETBFTQ-clJ74kxF.js} +1 -1
- package/dist/web/assets/{treemap-6X3UGDF4-B-X0EQSE.js → treemap-6X3UGDF4-Dr2iSopM.js} +1 -1
- package/dist/web/assets/{vennDiagram-T6HMQDX7-QMdGieCa.js → vennDiagram-T6HMQDX7-Dm_4JT58.js} +1 -1
- package/dist/web/assets/{wardley-OPB4EBWU-BaeAF8d8.js → wardley-OPB4EBWU-BijQqUc8.js} +1 -1
- package/dist/web/assets/{wardleyDiagram-T6FBY63Y-DTQ_uLUq.js → wardleyDiagram-T6FBY63Y-C4x0wEqS.js} +1 -1
- package/dist/web/assets/{xychartDiagram-ELKLHX3M-BMdBWzib.js → xychartDiagram-ELKLHX3M-BGoEonWo.js} +1 -1
- package/dist/web/index.html +2 -2
- package/migrations/011_comment_post_modifier.sql +3 -0
- package/package.json +15 -17
- package/skills/rvw/SKILL.md +1 -1
- package/skills/rvw-walkthrough/SKILL.md +1 -1
- package/skills/rvw-watch-comments/SKILL.md +48 -22
- package/skills/rvw-watch-comments/scripts/auto-ack.mjs +18 -2
- package/skills/rvw-watch-comments/scripts/preflight.mjs +1 -1
- package/skills/rvw-watch-comments/scripts/watch-driver.mjs +47 -17
- package/skills/rvw-watch-comments/scripts/watch-state.mjs +68 -10
- package/dist/web/assets/MarkdownTable-CdbKPft2.js +0 -7
- package/dist/web/assets/WalkthroughViewer-D1LlSQw2.js +0 -1
- package/dist/web/assets/architecture-TIHT7OUA-edLV2Zq-.js +0 -1
- package/dist/web/assets/channel-J8FHSJDG.js +0 -1
- package/dist/web/assets/classDiagram-JCYQIIEL-CmTWSnH0.js +0 -1
- package/dist/web/assets/classDiagram-v2-OCEON4UE-CmTWSnH0.js +0 -1
- package/dist/web/assets/eventmodeling-45OFAUF4-C3c4qddw.js +0 -1
- package/dist/web/assets/flowDiagram-UKHOOZJN-DMA-a1zf.js +0 -1
- package/dist/web/assets/index-D8GJBw23.js +0 -384
- package/dist/web/assets/index-DMD2vvQW.css +0 -1
- package/dist/web/assets/railroad-abnf-AHOZXSZD-BN-ZBhE0.js +0 -1
- package/dist/web/assets/railroad-ebnf-EBAXGLYW-CG97zyI2.js +0 -1
- package/dist/web/assets/railroad-peg-LSFZ7HO6-DHLQ1evQ.js +0 -1
- package/dist/web/assets/stateDiagram-v2-UEYNNEHI-LaSNqvWy.js +0 -1
- package/dist/web/assets/swimlanesDiagram-ULZ7WXOC-C5OBtBlv.js +0 -8
|
@@ -23,6 +23,7 @@ const EXIT_AUTO_ACK = 23;
|
|
|
23
23
|
const EXIT_ALREADY_RUNNING = 24;
|
|
24
24
|
const DEFAULT_MAX_IN_FLIGHT = 1;
|
|
25
25
|
const DEFAULT_AUTO_ACK_POLL_MS = 250;
|
|
26
|
+
const MAX_AUTHOR_LABEL_CHARACTERS = 100;
|
|
26
27
|
const scriptDirectory = path.dirname(fileURLToPath(import.meta.url));
|
|
27
28
|
const stateScript = path.join(scriptDirectory, "watch-state.mjs");
|
|
28
29
|
const autoAckScript = path.join(scriptDirectory, "auto-ack.mjs");
|
|
@@ -41,6 +42,7 @@ function parseArguments(values) {
|
|
|
41
42
|
let autoAck = false;
|
|
42
43
|
let maxInFlight = DEFAULT_MAX_IN_FLIGHT;
|
|
43
44
|
let maxInFlightProvided = false;
|
|
45
|
+
let authorLabel = null;
|
|
44
46
|
for (let index = 0; index < values.length; index += 1) {
|
|
45
47
|
const value = values[index];
|
|
46
48
|
if (value === "--auto-ack") {
|
|
@@ -60,6 +62,18 @@ function parseArguments(values) {
|
|
|
60
62
|
index += 1;
|
|
61
63
|
continue;
|
|
62
64
|
}
|
|
65
|
+
if (value === "--author-label") {
|
|
66
|
+
const next = values[index + 1];
|
|
67
|
+
if (!next || next.startsWith("--") || next.length > MAX_AUTHOR_LABEL_CHARACTERS) {
|
|
68
|
+
throw new DriverError(
|
|
69
|
+
`--author-label must contain 1 through ${MAX_AUTHOR_LABEL_CHARACTERS} characters`,
|
|
70
|
+
EXIT_WATCH,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
authorLabel = next;
|
|
74
|
+
index += 1;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
63
77
|
if (value === "--state") {
|
|
64
78
|
const next = values[index + 1];
|
|
65
79
|
if (!next || next.startsWith("--")) {
|
|
@@ -79,7 +93,10 @@ function parseArguments(values) {
|
|
|
79
93
|
if (!autoAck && maxInFlightProvided) {
|
|
80
94
|
throw new DriverError("--max-in-flight requires --auto-ack", EXIT_WATCH);
|
|
81
95
|
}
|
|
82
|
-
|
|
96
|
+
if (!autoAck && authorLabel !== null) {
|
|
97
|
+
throw new DriverError("--author-label requires --auto-ack", EXIT_WATCH);
|
|
98
|
+
}
|
|
99
|
+
return { state: path.resolve(state), autoAck, maxInFlight, authorLabel };
|
|
83
100
|
}
|
|
84
101
|
|
|
85
102
|
async function runNodeScript(script, args, input) {
|
|
@@ -219,20 +236,17 @@ function releaseDriverLock(lock) {
|
|
|
219
236
|
unlinkIfOwned(lock.path, lock.identity);
|
|
220
237
|
}
|
|
221
238
|
|
|
222
|
-
async function dispatchAutoAck(state, pullRequest) {
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
"--pull-request",
|
|
227
|
-
pullRequest,
|
|
228
|
-
]);
|
|
239
|
+
async function dispatchAutoAck(state, pullRequest, authorLabel) {
|
|
240
|
+
const args = ["--state", state, "--pull-request", pullRequest];
|
|
241
|
+
if (authorLabel !== null) args.push("--author-label", authorLabel);
|
|
242
|
+
const result = await runNodeScript(autoAckScript, args);
|
|
229
243
|
if (result.code !== 0 || !result.json?.ok) {
|
|
230
244
|
throw new DriverError(`auto-ack failed for ${pullRequest}`, EXIT_AUTO_ACK, result);
|
|
231
245
|
}
|
|
232
246
|
write({ ...result.json, type: "batch-acknowledged" });
|
|
233
247
|
}
|
|
234
248
|
|
|
235
|
-
async function dispatchPendingAutoAcks(state, maxInFlight) {
|
|
249
|
+
async function dispatchPendingAutoAcks(state, maxInFlight, authorLabel) {
|
|
236
250
|
const work = await stateCommand(state, "list");
|
|
237
251
|
const inFlight = Number(work.inFlight);
|
|
238
252
|
if (!Number.isSafeInteger(inFlight) || inFlight < 0 || !Array.isArray(work.pending)) {
|
|
@@ -241,12 +255,26 @@ async function dispatchPendingAutoAcks(state, maxInFlight) {
|
|
|
241
255
|
let available = Math.max(0, maxInFlight - inFlight);
|
|
242
256
|
for (const batch of work.pending) {
|
|
243
257
|
if (available === 0) break;
|
|
244
|
-
await dispatchAutoAck(state, batch.pullRequest);
|
|
258
|
+
await dispatchAutoAck(state, batch.pullRequest, authorLabel);
|
|
245
259
|
available -= 1;
|
|
246
260
|
}
|
|
247
261
|
}
|
|
248
262
|
|
|
249
|
-
async function
|
|
263
|
+
async function assertTaskAuthorLabel(state, authorLabel) {
|
|
264
|
+
const current = await stateCommand(state, "status");
|
|
265
|
+
if (!current.authorLabelBound || current.authorLabel === authorLabel) return;
|
|
266
|
+
throw new DriverError(
|
|
267
|
+
`Existing task author label ${current.authorLabel ?? "(unlabeled)"} does not match ${authorLabel ?? "(unlabeled)"}`,
|
|
268
|
+
EXIT_AUTO_ACK,
|
|
269
|
+
{
|
|
270
|
+
state,
|
|
271
|
+
expectedAuthorLabel: current.authorLabel,
|
|
272
|
+
receivedAuthorLabel: authorLabel,
|
|
273
|
+
},
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
async function processFrame(state, frame, autoAck, maxInFlight, authorLabel) {
|
|
250
278
|
if (!frame || typeof frame !== "object" || typeof frame.type !== "string") {
|
|
251
279
|
throw new DriverError("Invalid RFC 7464 frame", EXIT_SEQUENCE, frame);
|
|
252
280
|
}
|
|
@@ -263,6 +291,7 @@ async function processFrame(state, frame, autoAck, maxInFlight) {
|
|
|
263
291
|
anchoredAtCurrent: frame.anchoredAtCurrent,
|
|
264
292
|
autoAck,
|
|
265
293
|
maxInFlight: autoAck ? maxInFlight : null,
|
|
294
|
+
authorLabel: autoAck ? authorLabel : null,
|
|
266
295
|
});
|
|
267
296
|
} else if (frame.type === "comment-posted" && ingested.status === "queued") {
|
|
268
297
|
if (!autoAck) {
|
|
@@ -286,7 +315,7 @@ function autoAckPollMilliseconds() {
|
|
|
286
315
|
: DEFAULT_AUTO_ACK_POLL_MS;
|
|
287
316
|
}
|
|
288
317
|
|
|
289
|
-
async function runWatchOnce(state, autoAck, maxInFlight, stopping) {
|
|
318
|
+
async function runWatchOnce(state, autoAck, maxInFlight, authorLabel, stopping) {
|
|
290
319
|
const current = await stateCommand(state, "status");
|
|
291
320
|
const args = ["comment", "watch"];
|
|
292
321
|
if (current.cursor) args.push("--after", current.cursor);
|
|
@@ -309,7 +338,7 @@ async function runWatchOnce(state, autoAck, maxInFlight, stopping) {
|
|
|
309
338
|
const pumpAutoAcks = async () => {
|
|
310
339
|
if (!autoAck || stopping.requested) return;
|
|
311
340
|
if (autoAckPump) return autoAckPump;
|
|
312
|
-
autoAckPump = dispatchPendingAutoAcks(state, maxInFlight);
|
|
341
|
+
autoAckPump = dispatchPendingAutoAcks(state, maxInFlight, authorLabel);
|
|
313
342
|
try {
|
|
314
343
|
await autoAckPump;
|
|
315
344
|
} catch (error) {
|
|
@@ -345,7 +374,7 @@ async function runWatchOnce(state, autoAck, maxInFlight, stopping) {
|
|
|
345
374
|
}
|
|
346
375
|
readySeen ||= frame.type === "ready";
|
|
347
376
|
stoppedSeen ||= frame.type === "stopped";
|
|
348
|
-
await processFrame(state, frame, autoAck, maxInFlight);
|
|
377
|
+
await processFrame(state, frame, autoAck, maxInFlight, authorLabel);
|
|
349
378
|
}
|
|
350
379
|
await pumpAutoAcks();
|
|
351
380
|
}
|
|
@@ -383,9 +412,10 @@ function delay(milliseconds) {
|
|
|
383
412
|
}
|
|
384
413
|
|
|
385
414
|
async function main() {
|
|
386
|
-
const { state, autoAck, maxInFlight } = parseArguments(process.argv.slice(2));
|
|
415
|
+
const { state, autoAck, maxInFlight, authorLabel } = parseArguments(process.argv.slice(2));
|
|
387
416
|
const driverLock = acquireDriverLock(state);
|
|
388
417
|
try {
|
|
418
|
+
if (autoAck) await assertTaskAuthorLabel(state, authorLabel);
|
|
389
419
|
const stopping = { requested: false, child: null };
|
|
390
420
|
const stop = () => {
|
|
391
421
|
stopping.requested = true;
|
|
@@ -398,8 +428,8 @@ async function main() {
|
|
|
398
428
|
try {
|
|
399
429
|
while (!stopping.requested) {
|
|
400
430
|
const startedAt = Date.now();
|
|
401
|
-
if (autoAck) await dispatchPendingAutoAcks(state, maxInFlight);
|
|
402
|
-
const result = await runWatchOnce(state, autoAck, maxInFlight, stopping);
|
|
431
|
+
if (autoAck) await dispatchPendingAutoAcks(state, maxInFlight, authorLabel);
|
|
432
|
+
const result = await runWatchOnce(state, autoAck, maxInFlight, authorLabel, stopping);
|
|
403
433
|
if (stopping.requested) return;
|
|
404
434
|
if (Date.now() - startedAt >= 30_000) restarts = 0;
|
|
405
435
|
restarts += 1;
|
|
@@ -11,7 +11,7 @@ function fail(message) {
|
|
|
11
11
|
|
|
12
12
|
function parseOptions(values) {
|
|
13
13
|
const result = {};
|
|
14
|
-
const flags = new Set(["follow"]);
|
|
14
|
+
const flags = new Set(["follow", "no-author-label"]);
|
|
15
15
|
for (let index = 0; index < values.length; index += 1) {
|
|
16
16
|
const key = values[index];
|
|
17
17
|
if (!key?.startsWith("--")) fail(`Unexpected argument: ${key ?? ""}`);
|
|
@@ -152,6 +152,32 @@ function setMeta(database, key, value) {
|
|
|
152
152
|
.run(key, value);
|
|
153
153
|
}
|
|
154
154
|
|
|
155
|
+
function taskAuthorLabel(database) {
|
|
156
|
+
const stored = getMeta(database, "author_label");
|
|
157
|
+
return stored === null || stored === "" ? null : stored;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function bindTaskAuthorLabel(database, authorLabel) {
|
|
161
|
+
if (
|
|
162
|
+
authorLabel !== null &&
|
|
163
|
+
(typeof authorLabel !== "string" || authorLabel.length === 0 || authorLabel.length > 100)
|
|
164
|
+
) {
|
|
165
|
+
fail("authorLabel must contain 1 through 100 characters or be null");
|
|
166
|
+
}
|
|
167
|
+
const encoded = authorLabel ?? "";
|
|
168
|
+
const stored = getMeta(database, "author_label");
|
|
169
|
+
if (stored === null) {
|
|
170
|
+
setMeta(database, "author_label", encoded);
|
|
171
|
+
return authorLabel;
|
|
172
|
+
}
|
|
173
|
+
if (stored !== encoded) {
|
|
174
|
+
fail(
|
|
175
|
+
`Existing task author label ${stored || "(unlabeled)"} does not match ${encoded || "(unlabeled)"}`,
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
return taskAuthorLabel(database);
|
|
179
|
+
}
|
|
180
|
+
|
|
155
181
|
function tableExists(database, tableName) {
|
|
156
182
|
return Boolean(
|
|
157
183
|
database
|
|
@@ -409,11 +435,13 @@ function listPending(database) {
|
|
|
409
435
|
ORDER BY first_sequence`,
|
|
410
436
|
)
|
|
411
437
|
.all(now);
|
|
438
|
+
const blockedStatuses =
|
|
439
|
+
getMeta(database, "own_mode") === "investigate-and-reply"
|
|
440
|
+
? "status = 'pending'"
|
|
441
|
+
: "status IN ('pending', 'in_flight')";
|
|
412
442
|
const blockedPullRequests = new Set(
|
|
413
443
|
database
|
|
414
|
-
.prepare(
|
|
415
|
-
"SELECT DISTINCT pull_request_url FROM batches WHERE status IN ('pending', 'in_flight')",
|
|
416
|
-
)
|
|
444
|
+
.prepare(`SELECT DISTINCT pull_request_url FROM batches WHERE ${blockedStatuses}`)
|
|
417
445
|
.all()
|
|
418
446
|
.map((row) => row.pull_request_url),
|
|
419
447
|
);
|
|
@@ -521,14 +549,24 @@ function createBatch(database, pullRequestUrl, now) {
|
|
|
521
549
|
return batchId;
|
|
522
550
|
}
|
|
523
551
|
|
|
524
|
-
function claim(database, pullRequestUrl, writeKey) {
|
|
552
|
+
function claim(database, pullRequestUrl, writeKey, requestedAuthorLabel) {
|
|
525
553
|
const canonicalWriteKey = writeKey === undefined ? undefined : normalizeWriteKey(writeKey);
|
|
526
554
|
return transaction(database, () => {
|
|
555
|
+
const authorLabel =
|
|
556
|
+
requestedAuthorLabel === undefined
|
|
557
|
+
? taskAuthorLabel(database)
|
|
558
|
+
: bindTaskAuthorLabel(database, requestedAuthorLabel);
|
|
527
559
|
const now = new Date().toISOString();
|
|
528
|
-
const
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
560
|
+
const ownMode = getMeta(database, "own_mode");
|
|
561
|
+
if (canonicalWriteKey !== undefined && ownMode !== "fix-and-push") {
|
|
562
|
+
fail("Task policy does not allow repository write reservations");
|
|
563
|
+
}
|
|
564
|
+
if (ownMode !== "investigate-and-reply") {
|
|
565
|
+
const active = database
|
|
566
|
+
.prepare("SELECT id FROM batches WHERE pull_request_url = ? AND status = 'in_flight'")
|
|
567
|
+
.get(pullRequestUrl);
|
|
568
|
+
if (active) fail("Pull Request already has an in-flight batch");
|
|
569
|
+
}
|
|
532
570
|
let batch = database
|
|
533
571
|
.prepare(
|
|
534
572
|
`SELECT * FROM batches
|
|
@@ -583,6 +621,7 @@ function claim(database, pullRequestUrl, writeKey) {
|
|
|
583
621
|
pullRequest: pullRequestUrl,
|
|
584
622
|
attempts: Number(batch.attempts) + 1,
|
|
585
623
|
writeKey: canonicalWriteKey ?? null,
|
|
624
|
+
authorLabel,
|
|
586
625
|
events,
|
|
587
626
|
operations,
|
|
588
627
|
};
|
|
@@ -592,6 +631,9 @@ function claim(database, pullRequestUrl, writeKey) {
|
|
|
592
631
|
function reserveWrite(database, leaseId, writeKey) {
|
|
593
632
|
const canonicalWriteKey = normalizeWriteKey(writeKey);
|
|
594
633
|
return transaction(database, () => {
|
|
634
|
+
if (getMeta(database, "own_mode") !== "fix-and-push") {
|
|
635
|
+
fail("Task policy does not allow repository write reservations");
|
|
636
|
+
}
|
|
595
637
|
const batch = database
|
|
596
638
|
.prepare("SELECT * FROM batches WHERE lease_id = ? AND status = 'in_flight'")
|
|
597
639
|
.get(leaseId);
|
|
@@ -791,6 +833,8 @@ function status(database) {
|
|
|
791
833
|
taskId: getMeta(database, "task_id"),
|
|
792
834
|
databaseId: getMeta(database, "database_id"),
|
|
793
835
|
cursor: getMeta(database, "cursor"),
|
|
836
|
+
authorLabel: taskAuthorLabel(database),
|
|
837
|
+
authorLabelBound: getMeta(database, "author_label") !== null,
|
|
794
838
|
expectedGitHubLogin: getMeta(database, "expected_login") || null,
|
|
795
839
|
ownPullRequests: getMeta(database, "own_mode"),
|
|
796
840
|
otherPullRequests: "investigate-and-reply",
|
|
@@ -841,9 +885,23 @@ async function main() {
|
|
|
841
885
|
return;
|
|
842
886
|
}
|
|
843
887
|
if (command === "claim") {
|
|
888
|
+
if (options["author-label"] !== undefined && options["no-author-label"] === true) {
|
|
889
|
+
fail("Pass either --author-label or --no-author-label, not both");
|
|
890
|
+
}
|
|
891
|
+
const requestedAuthorLabel =
|
|
892
|
+
options["author-label"] !== undefined
|
|
893
|
+
? options["author-label"]
|
|
894
|
+
: options["no-author-label"] === true
|
|
895
|
+
? null
|
|
896
|
+
: undefined;
|
|
844
897
|
write({
|
|
845
898
|
ok: true,
|
|
846
|
-
...claim(
|
|
899
|
+
...claim(
|
|
900
|
+
database,
|
|
901
|
+
required(options, "pull-request"),
|
|
902
|
+
options["write-key"],
|
|
903
|
+
requestedAuthorLabel,
|
|
904
|
+
),
|
|
847
905
|
});
|
|
848
906
|
return;
|
|
849
907
|
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{J as t,U as n,q as r}from"./index-D8GJBw23.js";var i=e(t(),1),a=n(),o=r(),s=new Set([`blockquote`,`details`,`h1`,`h2`,`h3`,`h4`,`h5`,`h6`,`li`,`ol`,`p`,`pre`,`table`,`ul`]);function c(e,t){e.properties??={};let n=e.properties.className,r=Array.isArray(n)?n.map(String):typeof n==`string`?n.split(/\s+/u).filter(Boolean):[];r.includes(t)||r.push(t),e.properties.className=r}function l(e){return{dataRvwSourceStartLine:e.start.line,dataRvwSourceEndLine:e.end.line}}function u(e,t){let n=e.value??``,r=e.position??t;if(!r)return[e];let i=n.split(`
|
|
2
|
-
`);if(i.length===1)return[{type:`element`,tagName:`span`,properties:{...l(r),dataRvwSourceLeaf:`true`},children:[{type:`text`,value:n}],position:r}];let a=[];for(let[e,t]of i.entries()){if(e===i.length-1&&t===``&&n.endsWith(`
|
|
3
|
-
`))continue;let o=Math.min(r.start.line+e,r.end.line);t&&a.push({type:`element`,tagName:`span`,properties:{dataRvwSourceStartLine:o,dataRvwSourceEndLine:o,dataRvwSourceLeaf:`true`},children:[{type:`text`,value:t}],position:{start:{line:o},end:{line:o}}}),e<i.length-1&&a.push({type:`text`,value:`
|
|
4
|
-
`})}return a}function d(e,t,n){if(!e||t===void 0)return;let r=Math.max(1,n.split(`
|
|
5
|
-
`).length);return{start:{line:t},end:{line:Math.min(t+r-1,e.end.line)}}}function f(e,t){let n=e.position;if(!n)return;let r=t.split(`
|
|
6
|
-
`),i=Math.max(1,t.endsWith(`
|
|
7
|
-
`)?r.length-1:r.length),a=n.end.line-n.start.line+1>=i+2,o=n.start.line+ +!!a;return{start:{line:o},end:{line:o+i-1}}}function p(e){if(e.type===`element`&&e.position&&(e.properties={...e.properties,...l(e.position)}),!e.children)return;let t=e.type===`element`&&e.tagName===`code`,n=[],r=e.position?.start.line;for(let i of e.children){if(i.type===`text`){let a=t?f(e,i.value??``):d(e.position,r,i.value??``);if(i.position||a){let e=i.position??a;n.push(...u(i,e)),r=e?.end.line??r;continue}}p(i),r=i.position?.end.line??r,n.push(i)}e.children=n}function m(e,t){return!!(e&&e.start.line<=t.endLine&&e.end.line>=t.startLine)}function h(e,t,n,r){e.type===`element`&&e.properties?.dataRvwSourceLeaf===`true`&&(n&&t.some(t=>t.id===n&&t.range&&m(e.position,t.range))&&c(e,`rvw-markdown-commented`),r&&m(e.position,r)&&c(e,`rvw-markdown-selected`)),e.children?.forEach(e=>h(e,t,n,r))}function g(e,t){let n=null,r=null,i=[{node:e,depth:0}];for(;i.length>0;){let e=i.pop();if(!e)continue;let{node:a,depth:o}=e;if(a.type===`element`&&a.tagName&&s.has(a.tagName)&&a.position&&a.position.start.line<=t&&a.position.end.line>=t){let e=a.position.end.line-a.position.start.line;(!n||o>n.depth||o===n.depth&&e<n.span)&&(n={node:a,depth:o,span:e}),(a.tagName===`ul`||a.tagName===`ol`)&&(!r||o>r.depth)&&(r={node:a,depth:o})}a.children?.forEach(e=>i.push({node:e,depth:o+1}))}return r?.node??n?.node??null}function _(e,t){let n=new Map,r=[];for(let i of t){if(!i.range){r.push(i.id);continue}let t=g(e,i.range.endLine);if(!t){r.push(i.id);continue}let a=n.get(t)??[];a.push(i.id),n.set(t,a)}let i=e=>{if(!e.children)return;let t=[];for(let r of e.children){i(r),t.push(r);let e=n.get(r);e&&t.push({type:`element`,tagName:`div`,properties:{dataRvwCommentAnchor:e.join(`,`)},children:[]})}e.children=t};i(e),r.length>0&&(e.children??=[],e.children.unshift({type:`element`,tagName:`div`,properties:{dataRvwCommentAnchor:r.join(`,`)},children:[]}))}function v(e,t){if(!t)return;let n=t.endLine,r=e=>{if(!e.children)return!1;for(let t=0;t<e.children.length;t+=1){let i=e.children[t];if(!(i.position&&i.position.start.line<=n&&i.position.end.line>=n)){if(r(i))return!0;continue}if(i.tagName!==`ul`&&i.tagName!==`ol`&&i.tagName!==`table`&&r(i))return!0;if(i.type===`element`&&i.tagName&&s.has(i.tagName))return e.children.splice(t+1,0,{type:`element`,tagName:`div`,properties:{className:[`markdown-selection-composer-slot`],dataRvwComposerAnchor:`true`},children:[]}),!0}return!1};r(e)||(e.children??=[],e.children.push({type:`element`,tagName:`div`,properties:{className:[`markdown-selection-composer-slot`],dataRvwComposerAnchor:`true`},children:[]}))}function y(e={}){return t=>{let n=e.annotations??[];p(t),h(t,n,e.activeCommentId??null,e.composerOpen?e.selectedRange??null:null),_(t,n),v(t,e.composerOpen?e.selectedRange??null:null)}}function b(e,t,n,r){let i=t;if(t instanceof Element&&t.childNodes.length>0){let e=r===`start`?Math.min(n,t.childNodes.length-1):Math.max(0,n-1);i=t.childNodes[e]??t}let a=i instanceof Element?i:i?.parentElement;if(!a)return null;let o=a.closest(`[data-rvw-source-leaf='true']`);if(o&&e.contains(o))return o;let s=a.querySelectorAll(`[data-rvw-source-leaf='true']`);if(s.length>0)return r===`start`?s[0]??null:s[s.length-1]??null;let c=a.closest(`[data-rvw-source-start-line]`);if(c&&e.contains(c))return c;let l=a.querySelectorAll(`[data-rvw-source-start-line]`);return r===`start`?l[0]??null:l[l.length-1]??null}function x(e,t){let n=(t instanceof Element?t:t.parentElement)?.closest(`.comment-thread`);return!!(n&&e.contains(n))}function S(e,t){if(!t||t.rangeCount===0||t.isCollapsed||!t.toString().trim())return null;let n=t.getRangeAt(0);if(!e.contains(n.startContainer)||!e.contains(n.endContainer)||x(e,n.startContainer)||x(e,n.endContainer))return null;let r=b(e,n.startContainer,n.startOffset,`start`),i=b(e,n.endContainer,n.endOffset,`end`),a=Number(r?.dataset.rvwSourceStartLine),o=Number(i?.dataset.rvwSourceEndLine);return!Number.isInteger(a)||!Number.isInteger(o)||a<1||o<1?null:{startLine:Math.min(a,o),endLine:Math.max(a,o)}}function C(e,t,n,r){let i=document.caretPositionFromPoint?.(n,r),a=document.caretRangeFromPoint?.(n,r),o=[i?.offsetNode??a?.startContainer??null,t],s=null;for(let t of o){let n=t instanceof Element?t:t instanceof Node?t.parentElement:null;if(!(!n||!e.contains(n))&&(s=n.closest(`[data-rvw-source-leaf='true']`)??n.closest(`[data-rvw-source-start-line]`),s&&e.contains(s)))break}if(!s)return null;let c=Number(s.dataset.rvwSourceStartLine),l=Number(s.dataset.rvwSourceEndLine);return!Number.isInteger(c)||!Number.isInteger(l)||c<1||l<1?null:{startLine:Math.min(c,l),endLine:Math.max(c,l)}}function w(e,t,n){return t&&n?{startLine:Math.min(t.startLine,n.startLine),endLine:Math.max(t.endLine,n.endLine)}:e}function T(e){let t=e?.properties?.dataRvwCommentAnchor;return typeof t==`string`?t.split(`,`).filter(Boolean):[]}function E(e){let t=e?.position;return!t||t.start.line<1||t.end.line<t.start.line?null:{startLine:t.start.line,endLine:t.end.line}}function D(e){let t=E(e);return t?{"data-rvw-source-start-line":t.startLine,"data-rvw-source-end-line":t.endLine}:{}}function O(e){return e.startLine===e.endLine?`L${e.startLine}`:`L${e.startLine}–${e.endLine}`}function k({children:e,className:t,selectedRange:n,composerOpen:r,onSelection:s,onOpenComposer:c,composer:l}){let u=(0,i.useRef)(null),d=(0,i.useRef)(null),f=(0,i.useRef)(null),p=(0,i.useRef)(!1),m=(0,i.useRef)(null),h=(0,i.useRef)(s);h.current=s;let[g,_]=(0,i.useState)(null),[v,y]=(0,i.useState)(null),[b,x]=(0,i.useState)(null),[T,E]=(0,i.useState)(null);(0,i.useEffect)(()=>{if(r)return;let e=()=>{if(p.current)return;let e=u.current;e&&S(e,window.getSelection())||(_(null),y(null),x(null))};return document.addEventListener(`selectionchange`,e),()=>document.removeEventListener(`selectionchange`,e)},[r]),(0,i.useEffect)(()=>{if(r||n)return;let e=u.current;e&&S(e,window.getSelection())||(_(null),y(null),x(null))},[r,n]),(0,i.useEffect)(()=>()=>{m.current!==null&&window.clearTimeout(m.current)},[]),(0,i.useLayoutEffect)(()=>{let e=u.current,t=d.current;if(!v||!e||!t)return;let n=()=>{let n=Math.max(0,e.clientWidth-24),r=Math.min(t.offsetWidth,n),i=12+r/2,a=e.clientWidth-12-r/2,o=Math.max(i,Math.min(v.left,a));x(e=>e!==null&&Math.abs(e-o)<.5?e:o)};n();let i=null;r&&(i=window.requestAnimationFrame(()=>{t.scrollIntoView({block:`nearest`,inline:`nearest`})}));let a=new ResizeObserver(n);return a.observe(e),a.observe(t),()=>{a.disconnect(),i!==null&&window.cancelAnimationFrame(i)}},[v,r]),(0,i.useLayoutEffect)(()=>{if(!r){E(null);return}let e=u.current?.querySelector(`[data-rvw-composer-anchor='true']`);if(!e)return;E(e);let t=window.requestAnimationFrame(()=>{e.scrollIntoView({block:`nearest`,inline:`nearest`})});return()=>{window.cancelAnimationFrame(t)}},[r,n?.endLine,n?.startLine]);let D=(e=null,t=null)=>{let n=u.current;if(!n)return;let r=window.getSelection(),i=S(n,r);if(!i||!r){_(null),y(null),x(null);return}let a=w(i,e,t),o=r.getRangeAt(0).getBoundingClientRect(),s=n.getBoundingClientRect();x(null),y({left:o.left+o.width/2-s.left,top:Math.max(8,o.bottom-s.top+8)}),_(a)},k=r?n:g;return(0,o.jsxs)(`div`,{className:[`markdown-comment-surface`,t].filter(Boolean).join(` `),ref:u,onPointerDown:e=>{if(m.current!==null&&(window.clearTimeout(m.current),m.current=null),e.button!==0){p.current=!1,f.current=null;return}p.current=!0,f.current=C(e.currentTarget,e.target,e.clientX,e.clientY)},onPointerUp:e=>{if(e.target.closest(`.markdown-selection-popover, button, input, textarea, select`)){p.current=!1,f.current=null;return}let t=f.current,n=C(e.currentTarget,e.target,e.clientX,e.clientY);f.current=null,p.current=!1;let r=u.current;if(r&&S(r,window.getSelection())){D(t,n);return}m.current=window.setTimeout(()=>{m.current=null,D()},250)},onPointerCancel:()=>{p.current=!1,f.current=null},onKeyUp:e=>{e.target.closest(`.markdown-selection-popover, button, input, textarea, select`)||window.requestAnimationFrame(()=>D())},children:[e,k&&v&&!T&&(0,o.jsx)(`div`,{ref:d,className:`markdown-selection-popover${r?` is-composing`:``}`,style:{left:b??v.left,top:v.top},onPointerDown:e=>e.stopPropagation(),children:r?l:(0,o.jsxs)(`button`,{className:`markdown-selection-comment-action`,onPointerDown:e=>e.preventDefault(),onClick:()=>{h.current(k),c()},children:[O(k),`へコメント`]})}),T&&(0,a.createPortal)(l,T)]})}var A=({children:e,node:t,...n})=>(0,o.jsx)(`div`,{className:`markdown-table-scroll`,children:(0,o.jsx)(`table`,{...D(t),...n,children:e})});export{D as a,E as i,k as n,y as o,T as r,A as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{B as t,G as n,H as r,J as i,K as a,L as o,R as s,T as c,W as l,_ as u,b as d,c as f,l as p,n as m,o as h,q as g,r as _,s as v,t as y,w as b,x,z as S}from"./index-D8GJBw23.js";import{a as C,i as w,n as T,o as E,r as D,t as O}from"./MarkdownTable-CdbKPft2.js";var k=e(i(),1),A=g(),j=2400;function M(e){return k.Children.toArray(e).map(e=>typeof e==`string`||typeof e==`number`?String(e):(0,k.isValidElement)(e)?M(e.props.children):``).join(``)}function N(e,t){return!!(e&&t&&e.startLine===t.startLine&&e.endLine===t.endLine)}function P(){return(0,A.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 16 16`,width:`16`,height:`16`,children:(0,A.jsx)(`path`,{fill:`currentColor`,d:`M5.5 1.75A1.75 1.75 0 0 1 7.25 0h1.5a1.75 1.75 0 0 1 1.75 1.75V2h3a.75.75 0 0 1 0 1.5h-.64l-.68 10.03A2.5 2.5 0 0 1 9.69 16H6.31a2.5 2.5 0 0 1-2.49-2.47L3.14 3.5H2.5a.75.75 0 0 1 0-1.5h3v-.25Zm1.5 0V2h2v-.25a.25.25 0 0 0-.25-.25h-1.5a.25.25 0 0 0-.25.25ZM4.65 3.5l.67 9.96c.02.58.46 1.04.99 1.04h3.38c.53 0 .97-.46.99-1.04l.67-9.96h-6.7Z`})})}function F({source:e,sourceRange:t,commented:n,bindings:r,references:i,themePreference:a,onOpenReference:s,onCommentRange:c,commentComposer:l}){let u=(0,k.useRef)(null),d=!!l;(0,k.useLayoutEffect)(()=>{if(!d)return;let e=window.requestAnimationFrame(()=>{u.current?.scrollIntoView({block:`nearest`,inline:`nearest`})});return()=>window.cancelAnimationFrame(e)},[d]);let f=(0,k.useCallback)(e=>{if(!(e instanceof Element))return;let t=e.closest(`[data-walkthrough-reference-id]`)?.dataset.walkthroughReferenceId;return t?i.get(t):void 0},[i]),p=(0,k.useCallback)(e=>{for(let t of e.querySelectorAll(`g.node, g.classGroup, g[data-id], g[id^='classId-']`)){let e=t.dataset.id??Object.keys(r).find(e=>t.id===e||t.id.includes(`-${e}`)||t.id.includes(`-${e}-`)||t.id.endsWith(`-${e}`));if(!e)continue;let n=r[e],a=n?i.get(n):void 0;a&&(t.classList.add(`walkthrough-diagram-node--linked`),t.setAttribute(`role`,`button`),t.setAttribute(`tabindex`,`0`),t.setAttribute(`aria-label`,`${a.label}をコードで開く`),t.dataset.walkthroughReferenceId=a.id)}},[r,i]);return(0,A.jsxs)(`div`,{className:`walkthrough-diagram-shell${n?` has-comment`:``}`,...t?{"data-rvw-navigation-start-line":t.startLine,"data-rvw-navigation-end-line":t.endLine}:{},children:[(0,A.jsxs)(`div`,{className:`walkthrough-diagram-toolbar`,children:[(0,A.jsx)(`span`,{children:`Mermaid diagram`}),(0,A.jsx)(`span`,{children:`nodeを選択して開く · Cmd/Ctrlで反対のペイン`}),t&&(0,A.jsxs)(`button`,{className:`button--quiet walkthrough-diagram-comment`,onPointerDown:e=>{e.button===0&&(e.preventDefault(),c(t))},onClick:e=>{e.detail===0&&c(t)},children:[(0,A.jsx)(o,{}),`図全体へコメント`]})]}),(0,A.jsx)(_,{className:`walkthrough-diagram`,source:e,themePreference:a,renderIdPrefix:`rvwWalkthrough`,errorClassName:`walkthrough-diagram-error`,onRendered:p,onPointerDown:e=>{let t=f(e.target);t&&(e.preventDefault(),e.stopPropagation(),s(t,e.metaKey||e.ctrlKey))},onKeyDown:e=>{if(e.key!==`Enter`&&e.key!==` `)return;let t=f(e.target);t&&(e.preventDefault(),s(t,!1))}}),l&&(0,A.jsx)(`div`,{className:`walkthrough-diagram-comment-composer`,ref:u,children:l})]})}var I=(0,k.createContext)(null);function L({range:e,pending:t,error:n,onCancel:r,onSubmit:i}){let[a,o]=(0,k.useState)(``),c=e.startLine===e.endLine?`L${e.startLine}へコメント`:`L${e.startLine}–${e.endLine}へコメント`;return(0,A.jsx)(s,{body:a,label:c,pending:t,error:n,validationError:void 0,placement:`line`,onBodyChange:o,onCancel:r,onSubmit:()=>i(a)})}var R=({children:e,node:t,...n})=>{let r=(0,k.useContext)(I),i=k.Children.count(e)===1?k.Children.only(e):null;if(!r||!(0,k.isValidElement)(i)||i.props.className!==`language-mermaid`)return(0,A.jsx)(`pre`,{...n,children:e});let a=w(t);return(0,A.jsx)(F,{source:M(i.props.children).trim(),sourceRange:a,commented:!!(a&&r.activeCommentId&&r.placedComments.some(({comment:e,placement:t})=>e.id===r.activeCommentId&&t.range&&t.range.startLine<=a.endLine&&t.range.endLine>=a.startLine)),bindings:r.diagramBindings,references:r.references,themePreference:r.themePreference,onOpenReference:r.onOpenReference,onCommentRange:r.onCommentRange,commentComposer:a&&N(a,r.diagramCommentRange)?(0,A.jsx)(L,{range:a,pending:r.diagramCommentPending,error:r.diagramCommentError,onCancel:r.onCancelDiagramComment,onSubmit:e=>r.onSubmitDiagramComment(a,e)},`${a.startLine}:${a.endLine}`):null})},z=(0,k.memo)(function({body:e,diagramBindings:t,references:n,placedComments:r,activeCommentId:i,selectedRange:a,selectionComposerOpen:o,diagramCommentRange:s,markdownSourceOid:l,themePreference:g,onOpenReference:_,onOpenCommentCodeReference:y,onOpenRepositoryLink:S,onCommentActiveChange:w,onCommentRange:T,diagramCommentPending:j,diagramCommentError:M,onCancelDiagramComment:N,onSubmitDiagramComment:P}){let F=(0,k.useMemo)(()=>r.map(({comment:e,placement:t})=>({id:e.id,range:t.range})),[r]),L=(0,k.useMemo)(()=>new Map(r.map(({comment:e,placement:t})=>[e.id,{comment:e,placement:t}])),[r]),z=(0,k.useCallback)(({node:e,children:t,...n})=>{let r=D(e);return r.length===0?(0,A.jsx)(`div`,{...n,children:t}):(0,A.jsx)(`div`,{className:`markdown-inline-comments`,children:r.map(e=>{let t=L.get(e);return t?(0,A.jsx)(m,{comment:t.comment,variant:`inline`,placement:t.placement,markdownSourceOid:l,themePreference:g,onActiveChange:w,onOpenCodeReference:y,onOpenRepositoryLink:S},e):null})})},[L,l,w,y,S,g]);return(0,A.jsx)(I.Provider,{value:{diagramBindings:t,references:n,placedComments:r,activeCommentId:i,diagramCommentRange:s,themePreference:g,onOpenReference:_,onCommentRange:T,diagramCommentPending:j,diagramCommentError:M,onCancelDiagramComment:N,onSubmitDiagramComment:P},children:(0,A.jsx)(`article`,{className:`walkthrough-markdown`,children:(0,A.jsx)(b,{rehypePlugins:[x,[d,p],[E,{annotations:F,activeCommentId:i,selectedRange:a,composerOpen:o}]],remarkPlugins:[u],urlTransform:e=>e.startsWith(`rvw-ref:`)?e:c(e),components:{div:z,table:O,a:({href:e,children:t,node:r,...i})=>{let a=f(e),o=a?n.get(a):void 0;return o?(0,A.jsx)(v,{reference:o,className:`walkthrough-inline-reference`,onOpen:_,children:t}):(0,A.jsx)(`a`,{...C(r),...i,href:e,children:t})},img:({alt:e,title:t,node:n})=>(0,A.jsx)(h,{alt:e,title:t,sourceAttributes:C(n)}),pre:R},children:e})})})});function B({walkthrough:e,comments:i,activeCommentId:c,navigationTarget:u,onNavigationApplied:d,themePreference:f,onCommentActiveChange:p,onOpenReference:h,onOpenCommentCodeReference:g,onOpenRepositoryLink:_,onDeleted:v}){let b=a(),x=(0,k.useRef)(null),C=(0,k.useRef)(null),w=(0,k.useRef)(d);w.current=d;let[E,D]=(0,k.useState)(!1),[O,M]=(0,k.useState)(null),[N,F]=(0,k.useState)(null),[I,L]=(0,k.useState)(null),[R,B]=(0,k.useState)(``),[V,H]=(0,k.useState)(null),U=(0,k.useRef)(0),W=(0,k.useRef)(null),G=(0,k.useMemo)(()=>new Map(e.references.map(e=>[e.id,e])),[e.references]);(0,k.useLayoutEffect)(()=>{if(!u||C.current===u.requestId)return;let e=u.requestId,t=window.requestAnimationFrame(()=>{let t=x.current;if(!t)return;if(u.line===null){t.scrollIntoView({behavior:`auto`,block:`start`,inline:`nearest`}),C.current=e,w.current(e);return}let n=String(u.line),r=t.querySelector(`[data-rvw-navigation-start-line="${n}"]`)??t.querySelector(`[data-rvw-source-start-line="${n}"]`),i=r?.closest(`details:not([open])`);i&&(i.open=!0),r&&(r.scrollIntoView({behavior:`auto`,block:`center`,inline:`nearest`}),C.current=e,w.current(e))});return()=>window.cancelAnimationFrame(t)},[u]);let ee=(0,k.useCallback)((t,n)=>{U.current+=1;let r=U.current;W.current!==null&&(window.clearTimeout(W.current),W.current=null),H(null),h(e,t,n).then(e=>{r!==U.current||!e||(H(e),W.current=window.setTimeout(()=>{H(null),W.current=null},j))})},[h,e]);(0,k.useEffect)(()=>()=>{U.current+=1,W.current!==null&&window.clearTimeout(W.current)},[]);let K=i.filter(t=>t.target.kind===`walkthrough`&&t.target.walkthroughId===e.id),te=K.reduce((e,t)=>e+t.posts.length,0),q=n({queryKey:[`walkthrough-comment-placements`,e.id,e.body,K.map(e=>`${e.id}:${e.updatedAt}`)],queryFn:async()=>{let n=new URLSearchParams({kind:`walkthrough`,pullRequestId:e.pullRequestId,walkthroughId:e.id});return await Promise.all(K.map(async e=>({comment:e,placement:(await t(`/api/comments/${e.id}/placement?${n.toString()}`)).placement})))},enabled:K.length>0}),J=(0,k.useMemo)(()=>q.data??[],[q.data]),ne=(0,k.useMemo)(()=>J.filter(({placement:e})=>!e.outdated&&e.range!==null),[J]),Y=(0,k.useMemo)(()=>J.filter(({comment:e,placement:t})=>e.target.kind===`walkthrough`&&e.target.startLine===null||t.outdated),[J]),X=l({mutationFn:async({range:n,body:i})=>await t(`/api/comments`,r({pullRequestId:e.pullRequestId,target:{kind:`walkthrough`,walkthroughId:e.id,startLine:n?.startLine??null,endLine:n?.endLine??null},body:i,authorLabel:`You`})),onSuccess:async()=>{window.getSelection()?.removeAllRanges(),B(``),D(!1),M(null),F(null),L(null),await b.invalidateQueries({queryKey:[`comments`]}),await b.invalidateQueries({queryKey:[`change-sequence`]})}}),Z=l({mutationFn:async()=>await t(`/api/pull-requests/${e.pullRequestId}/walkthroughs/${e.id}`,{...r({}),method:`DELETE`}),onSuccess:async()=>{v(e),await Promise.all([b.invalidateQueries({queryKey:[`walkthroughs`]}),b.invalidateQueries({queryKey:[`walkthrough`]}),b.invalidateQueries({queryKey:[`comments`]}),b.invalidateQueries({queryKey:[`change-sequence`]})])}}),Q=K.filter(e=>e.resolvedAt===null).length,re=()=>{let e=K.length===0?`紐づくコメントはありません。`:`紐づくコメント ${K.length}件と投稿 ${te}件も削除されます。`;window.confirm(`このウォークスルーを削除します。\n${e}\nコピー済みの参照は無効になります。\n\nこの操作は元に戻せません。`)&&Z.mutate()},ie=O?O.startLine===O.endLine?`L${O.startLine}`:`L${O.startLine}–${O.endLine}`:null,$=()=>{window.getSelection()?.removeAllRanges(),X.reset(),B(``),M(null),F(null),L(null)},ae=e=>{X.reset(),B(``),D(!1),M(null),F(e),L(`diagram`)},oe=O?(0,A.jsx)(s,{body:R,label:`${ie??`選択範囲`}へコメント`,pending:X.isPending,error:X.error,validationError:void 0,placement:`line`,onBodyChange:B,onCancel:$,onSubmit:()=>X.mutate({range:O,body:R})}):null,se=(0,A.jsx)(z,{body:e.body,diagramBindings:e.diagramBindings,references:G,placedComments:ne,activeCommentId:c,selectedRange:I===`selection`?O:null,selectionComposerOpen:I===`selection`,diagramCommentRange:N,markdownSourceOid:e.sourceOid,themePreference:f,onOpenReference:ee,onOpenCommentCodeReference:g,onOpenRepositoryLink:_,onCommentActiveChange:p,onCommentRange:ae,diagramCommentPending:X.isPending,diagramCommentError:X.error,onCancelDiagramComment:$,onSubmitDiagramComment:(e,t)=>X.mutate({range:e,body:t})});return(0,A.jsxs)(`div`,{className:`walkthrough-viewer`,ref:x,children:[(0,A.jsxs)(`header`,{className:`walkthrough-viewer-header`,children:[(0,A.jsxs)(`div`,{className:`walkthrough-viewer-title`,children:[(0,A.jsx)(`span`,{className:`walkthrough-viewer-icon`,children:(0,A.jsx)(y,{})}),(0,A.jsxs)(`div`,{className:`walkthrough-viewer-heading-copy`,children:[(0,A.jsx)(`span`,{className:`walkthrough-kicker`,children:`Agent-provided walkthrough`}),(0,A.jsx)(`h2`,{title:e.title,children:e.title})]})]}),(0,A.jsxs)(`div`,{className:`walkthrough-viewer-actions`,children:[(0,A.jsxs)(`button`,{className:`comment-icon-button walkthrough-comment-button`,"aria-label":`ウォークスルー全体へコメント`,title:`ウォークスルー全体へコメント`,"aria-pressed":E,onClick:()=>{X.reset(),B(``),M(null),F(null),L(null),D(e=>!e)},children:[(0,A.jsx)(o,{}),Q>0&&(0,A.jsx)(`span`,{children:Q})]}),(0,A.jsx)(`button`,{className:`comment-icon-button walkthrough-delete-button`,"aria-label":`ウォークスルーを削除`,title:`ウォークスルーを削除`,disabled:Z.isPending,onClick:re,children:(0,A.jsx)(P,{})})]}),V&&(0,A.jsx)(`div`,{className:`code-reference-notice walkthrough-reference-notice`,role:`status`,"aria-live":`polite`,children:V})]}),(0,A.jsx)(S,{error:Z.error}),(0,A.jsx)(S,{error:q.error}),(E||Y.length>0)&&(0,A.jsxs)(`div`,{className:`walkthrough-comment-area`,children:[E&&(0,A.jsx)(s,{body:R,label:`ウォークスルー全体へコメント`,pending:X.isPending,error:X.error,validationError:void 0,placement:`file`,onBodyChange:B,onCancel:()=>{X.reset(),B(``),D(!1)},onSubmit:()=>X.mutate({range:null,body:R})}),Y.map(({comment:t,placement:n})=>(0,A.jsx)(m,{comment:t,variant:`inline`,placement:n,markdownSourceOid:e.sourceOid,themePreference:f,onActiveChange:p,onOpenCodeReference:g,onOpenRepositoryLink:_},t.id))]}),(0,A.jsx)(T,{className:`walkthrough-markdown-surface`,selectedRange:O,composerOpen:I===`selection`,onSelection:e=>{if(!e){M(null),L(e=>e===`selection`?null:e);return}X.reset(),B(``),D(!1),M(e),F(null),L(null)},onOpenComposer:()=>L(`selection`),composer:oe,children:se})]})}export{B as WalkthroughViewer};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./chunk-KEIR6QF5-BICK3FdT.js";import{M as e}from"./mermaid-parser.core-CbecsNA1.js";export{e as createArchitectureServices};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{at as e,ot as t}from"./chunk-I66GZJ75-CGl1hx4J.js";var n=(n,r)=>t.lang.round(e.parse(n)[r]);export{n as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import"./src-B6xuSHsQ.js";import"./chunk-I66GZJ75-CGl1hx4J.js";import"./chunk-NSK5VX7P-CiYiU8wP.js";import"./chunk-4I5QYGJK-ikT25rPN.js";import"./chunk-WRU74C26-nox7WFnh.js";import"./chunk-7BUUIJ7U-Bb538aSH.js";import"./chunk-UBXNYLIW-BuzttTFk.js";import"./chunk-2GRJ4B5K-D2TTocfh.js";import"./chunk-XXDRQBXY-DqAYeljN.js";import"./chunk-KBJHAD2P-D_MPzBJx.js";import"./chunk-W5SLKNZC-UidmFHe2.js";import"./chunk-QR6OTTB3-BK8Tnvcc.js";import"./chunk-7Z6QIM7H-DT3BAZ4L.js";import{i as t,n,r,t as i}from"./chunk-GF5L2VYU-mIdlxzfr.js";import"./mermaid.core-CdRuLyYI.js";var a={parser:n,get db(){return new i},renderer:r,styles:t,init:e(e=>{e.class||={},e.class.arrowMarkerAbsolute=e.arrowMarkerAbsolute},`init`)};export{a as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./chunk-Y2CYZVJY-DsF7k-Jl.js";import"./src-B6xuSHsQ.js";import"./chunk-I66GZJ75-CGl1hx4J.js";import"./chunk-NSK5VX7P-CiYiU8wP.js";import"./chunk-4I5QYGJK-ikT25rPN.js";import"./chunk-WRU74C26-nox7WFnh.js";import"./chunk-7BUUIJ7U-Bb538aSH.js";import"./chunk-UBXNYLIW-BuzttTFk.js";import"./chunk-2GRJ4B5K-D2TTocfh.js";import"./chunk-XXDRQBXY-DqAYeljN.js";import"./chunk-KBJHAD2P-D_MPzBJx.js";import"./chunk-W5SLKNZC-UidmFHe2.js";import"./chunk-QR6OTTB3-BK8Tnvcc.js";import"./chunk-7Z6QIM7H-DT3BAZ4L.js";import{i as t,n,r,t as i}from"./chunk-GF5L2VYU-mIdlxzfr.js";import"./mermaid.core-CdRuLyYI.js";var a={parser:n,get db(){return new i},renderer:r,styles:t,init:e(e=>{e.class||={},e.class.arrowMarkerAbsolute=e.arrowMarkerAbsolute},`init`)};export{a as diagram};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./chunk-KEIR6QF5-BICK3FdT.js";import{O as e}from"./mermaid-parser.core-CbecsNA1.js";export{e as createEventModelingServices};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import"./src-B6xuSHsQ.js";import"./chunk-I66GZJ75-CGl1hx4J.js";import"./chunk-NSK5VX7P-CiYiU8wP.js";import"./chunk-4I5QYGJK-ikT25rPN.js";import"./chunk-WRU74C26-nox7WFnh.js";import"./chunk-7BUUIJ7U-Bb538aSH.js";import"./chunk-UBXNYLIW-BuzttTFk.js";import"./chunk-2GRJ4B5K-D2TTocfh.js";import"./chunk-XXDRQBXY-DqAYeljN.js";import"./chunk-KBJHAD2P-D_MPzBJx.js";import"./chunk-W5SLKNZC-UidmFHe2.js";import"./chunk-QR6OTTB3-BK8Tnvcc.js";import"./chunk-7Z6QIM7H-DT3BAZ4L.js";import{n as e}from"./chunk-JQJVKLGR-BLG6gAfx.js";import"./mermaid.core-CdRuLyYI.js";export{e as diagram};
|