@muggleai/works 5.22.0-staging.157 → 5.22.0-staging.159
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/.claude-plugin/marketplace.json +1 -1
- package/README.md +3 -1
- package/dist/{chunk-E3T2RN6R.js → chunk-M2PJRVCC.js} +16 -0
- package/dist/{chunk-DLBPRPUN.js → chunk-SF75W2SV.js} +217 -47
- package/dist/cli.js +2 -2
- package/dist/index.js +2 -2
- package/dist/plugin/.claude-plugin/plugin.json +1 -1
- package/dist/plugin/.codex-plugin/plugin.json +1 -1
- package/dist/plugin/.cursor-plugin/plugin.json +1 -1
- package/dist/plugin/config/preference-defaults.json +1 -0
- package/dist/plugin/hooks/README.md +15 -7
- package/dist/plugin/hooks/codex-hooks.json +3 -10
- package/dist/plugin/hooks/hooks.json +14 -20
- package/dist/plugin/scripts/ensure-electron-app.sh +133 -186
- package/dist/plugin/scripts/guardrail-lib.sh +15 -9
- package/dist/plugin/scripts/guardrails.mjs +137 -21
- package/dist/plugin/scripts/session-maintenance.sh +98 -0
- package/dist/plugin/skills/_shared/ci-check-to-command.md +2 -1
- package/dist/plugin/skills/_shared/vcs/github/pr-checks.md +9 -0
- package/dist/plugin/skills/do/fix-ci.md +14 -4
- package/dist/plugin/skills/do/open-prs/forward.md +2 -0
- package/dist/plugin/skills/do/pre-flight.md +2 -0
- package/dist/plugin/skills/muggle-do/SKILL.md +1 -0
- package/dist/plugin/skills/muggle-preferences/ops/configure.md +1 -0
- package/dist/plugin/skills/muggle-preferences/preference-gates/autoInstallCiWorkflow.md +13 -0
- package/dist/release-manifest.json +3 -3
- package/dist/{src-V245RV7L.js → src-5QO7XTIG.js} +1 -1
- package/package.json +2 -1
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/.codex-plugin/plugin.json +1 -1
- package/plugin/.cursor-plugin/plugin.json +1 -1
- package/plugin/config/preference-defaults.json +1 -0
- package/plugin/hooks/README.md +15 -7
- package/plugin/hooks/codex-hooks.json +3 -10
- package/plugin/hooks/hooks.json +14 -20
- package/plugin/scripts/ensure-electron-app.sh +133 -186
- package/plugin/scripts/guardrail-lib.sh +15 -9
- package/plugin/scripts/guardrails.mjs +137 -21
- package/plugin/scripts/session-maintenance.sh +98 -0
- package/plugin/skills/_shared/ci-check-to-command.md +2 -1
- package/plugin/skills/_shared/vcs/github/pr-checks.md +9 -0
- package/plugin/skills/do/fix-ci.md +14 -4
- package/plugin/skills/do/open-prs/forward.md +2 -0
- package/plugin/skills/do/pre-flight.md +2 -0
- package/plugin/skills/muggle-do/SKILL.md +1 -0
- package/plugin/skills/muggle-preferences/ops/configure.md +1 -0
- package/plugin/skills/muggle-preferences/preference-gates/autoInstallCiWorkflow.md +13 -0
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"name": "muggleai",
|
|
10
10
|
"source": "./plugin",
|
|
11
11
|
"description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
|
|
12
|
-
"version": "5.22.0-staging.
|
|
12
|
+
"version": "5.22.0-staging.159"
|
|
13
13
|
}
|
|
14
14
|
]
|
|
15
15
|
}
|
package/README.md
CHANGED
|
@@ -167,7 +167,9 @@ Nested GitLab namespaces of any depth are handled — the project path is everyt
|
|
|
167
167
|
|
|
168
168
|
When a PR is opened from a session running this plugin, Muggle reserves a comment for the acceptance walkthrough and holds the turn open until it's settled — by the walkthrough, or by a stated reason acceptance testing doesn't apply.
|
|
169
169
|
|
|
170
|
-
A PR opened any other way — the web UI, a teammate without the plugin — never passes through that session, so the same check also runs in GitHub Actions.
|
|
170
|
+
A PR opened any other way — the web UI, a teammate without the plugin — never passes through that session, so the same check also runs in GitHub Actions. It fails while the comment is still empty, and whenever the walkthrough reports a failed or inconclusive test case; the check's summary names each one with its failing step and a link to the run. When the Muggle PR watcher sees it red, it repairs the cases, re-runs the whole suite, and re-settles the comment.
|
|
171
|
+
|
|
172
|
+
The `autoInstallCiWorkflow` preference, chosen during `muggle init`, decides whether Muggle adds the workflow itself: `always` installs it in the repository `muggle init` runs in and in any repository `/muggle-do` opens a PR from, `ask` (the default) asks first, `never` leaves CI alone. To add it to a repository by hand:
|
|
171
173
|
|
|
172
174
|
```bash
|
|
173
175
|
muggle ci-install
|
|
@@ -2446,6 +2446,7 @@ var PreferenceKey = /* @__PURE__ */ ((PreferenceKey2) => {
|
|
|
2446
2446
|
PreferenceKey2["AutoReuseValidationContext"] = "autoReuseValidationContext";
|
|
2447
2447
|
PreferenceKey2["AutoRouteBuildToMuggleDo"] = "autoRouteBuildToMuggleDo";
|
|
2448
2448
|
PreferenceKey2["AutoWatchPR"] = "autoWatchPR";
|
|
2449
|
+
PreferenceKey2["AutoInstallCiWorkflow"] = "autoInstallCiWorkflow";
|
|
2449
2450
|
PreferenceKey2["WatcherLifetime"] = "watcherLifetime";
|
|
2450
2451
|
PreferenceKey2["MaxCatchUpRebases"] = "maxCatchUpRebases";
|
|
2451
2452
|
PreferenceKey2["ReusePreparePlan"] = "reusePreparePlan";
|
|
@@ -2491,6 +2492,7 @@ var DEFAULT_PREFERENCES = {
|
|
|
2491
2492
|
["autoReuseValidationContext" /* AutoReuseValidationContext */]: "always" /* Always */,
|
|
2492
2493
|
["autoRouteBuildToMuggleDo" /* AutoRouteBuildToMuggleDo */]: "always" /* Always */,
|
|
2493
2494
|
["autoWatchPR" /* AutoWatchPR */]: "always" /* Always */,
|
|
2495
|
+
["autoInstallCiWorkflow" /* AutoInstallCiWorkflow */]: "ask" /* Ask */,
|
|
2494
2496
|
["reusePreparePlan" /* ReusePreparePlan */]: "always" /* Always */,
|
|
2495
2497
|
["watcherLifetime" /* WatcherLifetime */]: "7d" /* SevenDays */,
|
|
2496
2498
|
["maxCatchUpRebases" /* MaxCatchUpRebases */]: "20" /* TwentyRebases */
|
|
@@ -2542,6 +2544,7 @@ var PREFERENCE_ALLOWED_VALUES = {
|
|
|
2542
2544
|
["autoReuseValidationContext" /* AutoReuseValidationContext */]: ALWAYS_ASK_NEVER,
|
|
2543
2545
|
["autoRouteBuildToMuggleDo" /* AutoRouteBuildToMuggleDo */]: ALWAYS_ASK_NEVER,
|
|
2544
2546
|
["autoWatchPR" /* AutoWatchPR */]: ALWAYS_ASK_NEVER,
|
|
2547
|
+
["autoInstallCiWorkflow" /* AutoInstallCiWorkflow */]: ALWAYS_ASK_NEVER,
|
|
2545
2548
|
["reusePreparePlan" /* ReusePreparePlan */]: ALWAYS_ASK_NEVER,
|
|
2546
2549
|
["watcherLifetime" /* WatcherLifetime */]: WATCHER_LIFETIMES,
|
|
2547
2550
|
["maxCatchUpRebases" /* MaxCatchUpRebases */]: CATCH_UP_REBASE_BUDGETS
|
|
@@ -2610,6 +2613,9 @@ var PREFERENCES_SCHEMA = {
|
|
|
2610
2613
|
["autoWatchPR" /* AutoWatchPR */]: {
|
|
2611
2614
|
description: "After a test run opens a PR, start a muggle-pr-followup watcher that polls for new reviews and hands them to /muggle-do"
|
|
2612
2615
|
},
|
|
2616
|
+
["autoInstallCiWorkflow" /* AutoInstallCiWorkflow */]: {
|
|
2617
|
+
description: "When muggle init runs in a repository, or /muggle-do opens a PR in one, that lacks .github/workflows/muggle-walkthrough.yml, add it \u2014 the CI check that fails a PR whose E2E walkthrough is missing or reports a failed or inconclusive test case"
|
|
2618
|
+
},
|
|
2613
2619
|
["reusePreparePlan" /* ReusePreparePlan */]: {
|
|
2614
2620
|
description: "Reuse the saved prepare plan for this stack (skip discovery, jump to check-running + smoke-test) instead of rediscovering from scratch"
|
|
2615
2621
|
},
|
|
@@ -8530,6 +8536,16 @@ var ONBOARDING_CHOICE_GROUPS = [
|
|
|
8530
8536
|
{ value: "ask" /* Ask */, label: "Ask each time" }
|
|
8531
8537
|
]
|
|
8532
8538
|
},
|
|
8539
|
+
{
|
|
8540
|
+
header: "CI check",
|
|
8541
|
+
key: "autoInstallCiWorkflow" /* AutoInstallCiWorkflow */,
|
|
8542
|
+
prompt: "Add the Muggle E2E check to a repository's CI? It fails a pull request whose walkthrough is missing or reports a failed test.",
|
|
8543
|
+
optionLabels: [
|
|
8544
|
+
{ value: "always" /* Always */, label: "Always \u2014 add it to every repo Muggle works in" },
|
|
8545
|
+
{ value: "ask" /* Ask */, label: "Ask in each repo" },
|
|
8546
|
+
{ value: "never" /* Never */, label: "Never \u2014 I'll run muggle ci-install myself" }
|
|
8547
|
+
]
|
|
8548
|
+
},
|
|
8533
8549
|
{
|
|
8534
8550
|
header: "PR watcher",
|
|
8535
8551
|
key: "watcherLifetime" /* WatcherLifetime */,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __export, getLogger, getConfig, createChildLogger, buildElectronAppReleaseAssetUrl, getActiveRuntimeTarget, getAuthService, hasApiKey, getElectronAppVersion, getElectronAppDir, getPlatformKey, reconcileProjectPreferences, getDataDir, PREFERENCES_FILE_NAME, isFirstRun, writePreferences, DEFAULT_PREFERENCES, isElectronAppInstalled, getElectronAppChecksums, getChecksumForPlatform, getElectronAppSignedFromVersion, getReleaseSignerIdentityUri, verifyFileChecksum, calculateFileChecksum, initTelemetry, Surface, ServiceName, track, EventName, getQaTools, getLocalQaTools, performLogout, assertDeviceCodeClientProvisioned, performLogin, toolRequiresAuth, getCallerCredentials, getElectronAppReleaseTagPrefix, hasShownDisclosure, markDisclosureShown, getBundledElectronAppVersion, getElectronAppVersionSource, getCredentialsFilePath, buildElectronAppChecksumsUrl, __require, getDisclosureCopy, buildOnboardingPlan, applyOnboardingAnswers, needsOnboarding, readRunView, RunViewError, renderRunViewText, writeRunViewHtml, openBrowserUrl, OnboardingBlanketChoice, PreferenceKey } from './chunk-
|
|
1
|
+
import { __export, getLogger, getConfig, createChildLogger, buildElectronAppReleaseAssetUrl, getActiveRuntimeTarget, getAuthService, hasApiKey, getElectronAppVersion, getElectronAppDir, getPlatformKey, reconcileProjectPreferences, getDataDir, PREFERENCES_FILE_NAME, isFirstRun, writePreferences, DEFAULT_PREFERENCES, isElectronAppInstalled, getElectronAppChecksums, getChecksumForPlatform, getElectronAppSignedFromVersion, getReleaseSignerIdentityUri, verifyFileChecksum, calculateFileChecksum, initTelemetry, Surface, ServiceName, track, EventName, getQaTools, getLocalQaTools, performLogout, assertDeviceCodeClientProvisioned, performLogin, toolRequiresAuth, getCallerCredentials, getElectronAppReleaseTagPrefix, hasShownDisclosure, markDisclosureShown, getBundledElectronAppVersion, getElectronAppVersionSource, getCredentialsFilePath, buildElectronAppChecksumsUrl, __require, getDisclosureCopy, buildOnboardingPlan, applyOnboardingAnswers, needsOnboarding, readRunView, RunViewError, renderRunViewText, writeRunViewHtml, openBrowserUrl, OnboardingBlanketChoice, PreferenceKey, resolvePreferences } from './chunk-M2PJRVCC.js';
|
|
2
2
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
3
3
|
import { ListToolsRequestSchema, CallToolRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
4
4
|
import { v4 } from 'uuid';
|
|
@@ -370,6 +370,111 @@ var STEP_THUMBNAIL_QUALITY = 70;
|
|
|
370
370
|
var STEP_PAIR_IMAGE_WIDTH = 420;
|
|
371
371
|
var MAX_COMMENT_BYTES = 64e3;
|
|
372
372
|
|
|
373
|
+
// src/e2e-result/types.ts
|
|
374
|
+
var UnpassedCaseStatus = /* @__PURE__ */ ((UnpassedCaseStatus2) => {
|
|
375
|
+
UnpassedCaseStatus2["Failed"] = "failed";
|
|
376
|
+
UnpassedCaseStatus2["Inconclusive"] = "inconclusive";
|
|
377
|
+
return UnpassedCaseStatus2;
|
|
378
|
+
})(UnpassedCaseStatus || {});
|
|
379
|
+
|
|
380
|
+
// src/e2e-result/constants.ts
|
|
381
|
+
var E2E_RESULT_MARKER_PREFIX = "<!-- muggle-e2e-result:v1 ";
|
|
382
|
+
var E2E_RESULT_MARKER_SUFFIX = " -->";
|
|
383
|
+
var UNPASSED_DETAIL_MAX_CHARS = 300;
|
|
384
|
+
var UNPASSED_STATUS_EMOJI = {
|
|
385
|
+
["failed" /* Failed */]: "\u274C",
|
|
386
|
+
["inconclusive" /* Inconclusive */]: "\u26A0\uFE0F"
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
// src/e2e-result/format.ts
|
|
390
|
+
function escapeHtml(s) {
|
|
391
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
392
|
+
}
|
|
393
|
+
function describeUnpassedCase(unpassed) {
|
|
394
|
+
const outcome = unpassed.status === "failed" /* Failed */ && unpassed.failedStep !== void 0 ? `failed at step ${unpassed.failedStep}` : unpassed.status;
|
|
395
|
+
return `${outcome}: ${escapeHtml(unpassed.detail)}`;
|
|
396
|
+
}
|
|
397
|
+
function renderUnpassedCaseBullet(unpassed, linkText, linkTarget) {
|
|
398
|
+
return `- ${UNPASSED_STATUS_EMOJI[unpassed.status]} **${escapeHtml(unpassed.name)}** \u2014 ${describeUnpassedCase(unpassed)} \xB7 [${linkText}](${linkTarget})`;
|
|
399
|
+
}
|
|
400
|
+
var UnpassedCaseSchema = z.object({
|
|
401
|
+
name: z.string(),
|
|
402
|
+
testCaseId: z.string(),
|
|
403
|
+
status: z.enum(UnpassedCaseStatus),
|
|
404
|
+
failedStep: z.number().int().positive().optional(),
|
|
405
|
+
detail: z.string(),
|
|
406
|
+
viewUrl: z.string()
|
|
407
|
+
});
|
|
408
|
+
var E2eResultRecordSchema = z.object({
|
|
409
|
+
total: z.number().int().nonnegative(),
|
|
410
|
+
passed: z.number().int().nonnegative(),
|
|
411
|
+
unpassed: z.array(UnpassedCaseSchema)
|
|
412
|
+
});
|
|
413
|
+
function renderE2eResultMarker(record) {
|
|
414
|
+
const json = JSON.stringify(record).replace(/</g, "\\u003c").replace(/>/g, "\\u003e");
|
|
415
|
+
return `${E2E_RESULT_MARKER_PREFIX}${json}${E2E_RESULT_MARKER_SUFFIX}`;
|
|
416
|
+
}
|
|
417
|
+
function parseE2eResultMarker(body) {
|
|
418
|
+
const start = body.indexOf(E2E_RESULT_MARKER_PREFIX);
|
|
419
|
+
if (start === -1) return null;
|
|
420
|
+
const jsonStart = start + E2E_RESULT_MARKER_PREFIX.length;
|
|
421
|
+
const end = body.indexOf(E2E_RESULT_MARKER_SUFFIX, jsonStart);
|
|
422
|
+
if (end === -1) return null;
|
|
423
|
+
try {
|
|
424
|
+
const parsed = E2eResultRecordSchema.safeParse(JSON.parse(body.slice(jsonStart, end)));
|
|
425
|
+
return parsed.success ? parsed.data : null;
|
|
426
|
+
} catch {
|
|
427
|
+
return null;
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
function latestE2eResult(bodies) {
|
|
431
|
+
for (let i = bodies.length - 1; i >= 0; i--) {
|
|
432
|
+
const record = parseE2eResultMarker(bodies[i]);
|
|
433
|
+
if (record) return record;
|
|
434
|
+
}
|
|
435
|
+
return null;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
// src/cli/pr-section/result-record.ts
|
|
439
|
+
function failureOrdinal(test, failureStepIndex) {
|
|
440
|
+
const position = test.steps.findIndex((s) => s.stepIndex === failureStepIndex);
|
|
441
|
+
return position === -1 ? failureStepIndex : position + 1;
|
|
442
|
+
}
|
|
443
|
+
function oneLineDetail(text) {
|
|
444
|
+
const flat = text.replace(/\s+/g, " ").trim();
|
|
445
|
+
return flat.length > UNPASSED_DETAIL_MAX_CHARS ? `${flat.slice(0, UNPASSED_DETAIL_MAX_CHARS - 1)}\u2026` : flat;
|
|
446
|
+
}
|
|
447
|
+
function toUnpassedCase(test) {
|
|
448
|
+
if (test.status === "failed") {
|
|
449
|
+
return {
|
|
450
|
+
name: test.name,
|
|
451
|
+
testCaseId: test.testCaseId,
|
|
452
|
+
status: "failed" /* Failed */,
|
|
453
|
+
failedStep: failureOrdinal(test, test.failureStepIndex),
|
|
454
|
+
detail: oneLineDetail(test.error),
|
|
455
|
+
viewUrl: test.viewUrl
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
if (test.status === "inconclusive") {
|
|
459
|
+
return {
|
|
460
|
+
name: test.name,
|
|
461
|
+
testCaseId: test.testCaseId,
|
|
462
|
+
status: "inconclusive" /* Inconclusive */,
|
|
463
|
+
detail: oneLineDetail(test.reason),
|
|
464
|
+
viewUrl: test.viewUrl
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
return null;
|
|
468
|
+
}
|
|
469
|
+
function buildE2eResultRecord(latestTests) {
|
|
470
|
+
const unpassed = latestTests.map(toUnpassedCase).filter((entry) => entry !== null);
|
|
471
|
+
return {
|
|
472
|
+
total: latestTests.length,
|
|
473
|
+
passed: latestTests.filter((test) => test.status === "passed").length,
|
|
474
|
+
unpassed
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
|
|
373
478
|
// src/cli/pr-section/resolve-urls-types.ts
|
|
374
479
|
var GS_SCHEME = "gs://";
|
|
375
480
|
var PUBLIC_URL_PATH = "/v1/protected/storage/publicUrl";
|
|
@@ -505,10 +610,6 @@ function endingScreenshot(test) {
|
|
|
505
610
|
}
|
|
506
611
|
return test.steps[test.steps.length - 1];
|
|
507
612
|
}
|
|
508
|
-
function failureOrdinal(test, failureStepIndex) {
|
|
509
|
-
const position = test.steps.findIndex((s) => s.stepIndex === failureStepIndex);
|
|
510
|
-
return position === -1 ? failureStepIndex : position + 1;
|
|
511
|
-
}
|
|
512
613
|
function defaultEndingCaption(test) {
|
|
513
614
|
if (test.status === "failed") {
|
|
514
615
|
return `Failure at step ${failureOrdinal(test, test.failureStepIndex)}`;
|
|
@@ -537,9 +638,6 @@ function endingFrame(test) {
|
|
|
537
638
|
function fullSizeImage(url, alt) {
|
|
538
639
|
return `<a href="${url}"><img src="${url}" width="${DETAIL_IMAGE_WIDTH}" alt="${escapeHtml(alt).replace(/"/g, """)}"></a>`;
|
|
539
640
|
}
|
|
540
|
-
function escapeHtml(s) {
|
|
541
|
-
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
542
|
-
}
|
|
543
641
|
function tableCell(s) {
|
|
544
642
|
return s.replace(/\s*\n\s*/g, " ").replace(/\|/g, "\\|");
|
|
545
643
|
}
|
|
@@ -564,8 +662,9 @@ function renderOverview(report) {
|
|
|
564
662
|
lines.push("", "_No tests were executed._");
|
|
565
663
|
return lines.join("\n");
|
|
566
664
|
}
|
|
567
|
-
lines.push("");
|
|
568
665
|
const numbering = buildTestNumbering(latestRuns);
|
|
666
|
+
lines.push(...renderNeedsAttention(buildE2eResultRecord(latestRuns.map((entry) => entry.test))));
|
|
667
|
+
lines.push("");
|
|
569
668
|
const anyGrouped = latestRuns.some((entry) => Boolean(entry.test.useCaseName));
|
|
570
669
|
if (!anyGrouped) {
|
|
571
670
|
for (const entry of latestRuns) {
|
|
@@ -582,6 +681,15 @@ function renderOverview(report) {
|
|
|
582
681
|
}
|
|
583
682
|
return lines.join("\n");
|
|
584
683
|
}
|
|
684
|
+
function renderNeedsAttention(record) {
|
|
685
|
+
if (record.unpassed.length === 0) return [];
|
|
686
|
+
return [
|
|
687
|
+
"",
|
|
688
|
+
"**Needs attention**",
|
|
689
|
+
"",
|
|
690
|
+
...record.unpassed.map((unpassed) => renderUnpassedCaseBullet(unpassed, "see details", `#${testAnchor(unpassed.testCaseId)}`))
|
|
691
|
+
];
|
|
692
|
+
}
|
|
585
693
|
function renderUseCaseGroup(useCaseName, members, numbering) {
|
|
586
694
|
const groupCounts = countTests(members);
|
|
587
695
|
const isAllPassed = groupCounts.passed === groupCounts.total;
|
|
@@ -606,7 +714,7 @@ function buildTestNumbering(latestRuns) {
|
|
|
606
714
|
}
|
|
607
715
|
function renderOverviewBullet(entry, numbering, indent) {
|
|
608
716
|
const rerunNote = entry.attempts > 1 ? ` _(${entry.attempts} runs)_` : "";
|
|
609
|
-
const detailsLink = ` \xB7 [see details](#${testAnchor(entry.test)})`;
|
|
717
|
+
const detailsLink = ` \xB7 [see details](#${testAnchor(entry.test.testCaseId)})`;
|
|
610
718
|
return `${indent}- ${statusEmoji(entry.test)} **${numbering.get(entry.test.testCaseId)}.** ${entry.test.name}${rerunNote}${detailsLink}`;
|
|
611
719
|
}
|
|
612
720
|
function buildGroupedLayout(latestRuns) {
|
|
@@ -631,7 +739,7 @@ function buildGroupedLayout(latestRuns) {
|
|
|
631
739
|
}
|
|
632
740
|
function renderTestDetails(entry, projectId, testNumber, dashboardBaseUrl = DASHBOARD_URL_BASE, screenshotDetail = "before-and-after" /* BeforeAndAfter */) {
|
|
633
741
|
const { test } = entry;
|
|
634
|
-
const lines = [`<a name="${testAnchor(test)}"></a>`, "", `#### ${statusEmoji(test)} ${testNumber}. ${test.name}`, ""];
|
|
742
|
+
const lines = [`<a name="${testAnchor(test.testCaseId)}"></a>`, "", `#### ${statusEmoji(test)} ${testNumber}. ${test.name}`, ""];
|
|
635
743
|
if (test.description && !isSameText(test.description, test.name)) {
|
|
636
744
|
lines.push(`_${test.description.replace(/\s*\n\s*/g, " ")}_`, "");
|
|
637
745
|
}
|
|
@@ -647,8 +755,8 @@ function renderTestDetails(entry, projectId, testNumber, dashboardBaseUrl = DASH
|
|
|
647
755
|
function indented(content) {
|
|
648
756
|
return ["<dl><dd>", "", ...content, "", "</dd></dl>"];
|
|
649
757
|
}
|
|
650
|
-
function testAnchor(
|
|
651
|
-
return `${TEST_DETAILS_ANCHOR_PREFIX}${
|
|
758
|
+
function testAnchor(testCaseId) {
|
|
759
|
+
return `${TEST_DETAILS_ANCHOR_PREFIX}${testCaseId}`;
|
|
652
760
|
}
|
|
653
761
|
function evidenceToggleLabel(test, screenshotDetail) {
|
|
654
762
|
const count = test.steps.length;
|
|
@@ -743,7 +851,11 @@ ${TEST_DETAILS_DIVIDER}
|
|
|
743
851
|
`);
|
|
744
852
|
}
|
|
745
853
|
function renderBody(report, opts) {
|
|
746
|
-
const
|
|
854
|
+
const resultMarker = renderE2eResultMarker(
|
|
855
|
+
buildE2eResultRecord(resolveLatestRuns(report.tests).map((entry) => entry.test))
|
|
856
|
+
);
|
|
857
|
+
const overview = `${resultMarker}
|
|
858
|
+
${renderOverview(report)}`;
|
|
747
859
|
if (report.tests.length === 0) {
|
|
748
860
|
return overview;
|
|
749
861
|
}
|
|
@@ -915,7 +1027,7 @@ async function resolveGsScreenshotUrls(report, opts) {
|
|
|
915
1027
|
if (gsUrls.length === 0) {
|
|
916
1028
|
return report;
|
|
917
1029
|
}
|
|
918
|
-
const mcps = await import('./src-
|
|
1030
|
+
const mcps = await import('./src-5QO7XTIG.js');
|
|
919
1031
|
const credentials = await mcps.getCallerCredentialsAsync();
|
|
920
1032
|
if (!credentials.bearerToken && !credentials.apiKey) {
|
|
921
1033
|
stderrWrite(
|
|
@@ -968,7 +1080,7 @@ var withSentinel = (s) => s ? `${REPORT_SECTION_SENTINEL}
|
|
|
968
1080
|
${s}` : s;
|
|
969
1081
|
async function resolveDashboardBaseUrl(stderrWrite) {
|
|
970
1082
|
try {
|
|
971
|
-
const mcps = await import('./src-
|
|
1083
|
+
const mcps = await import('./src-5QO7XTIG.js');
|
|
972
1084
|
return mcps.resolveActiveProfile().dashboardBaseUrl;
|
|
973
1085
|
} catch (err) {
|
|
974
1086
|
stderrWrite(
|
|
@@ -1064,7 +1176,9 @@ function renderUserWorkflow() {
|
|
|
1064
1176
|
return `name: muggle-walkthrough
|
|
1065
1177
|
|
|
1066
1178
|
# Every PR owes a settled Muggle AI walkthrough comment: the E2E acceptance
|
|
1067
|
-
# result, or a stated reason E2E does not apply. The
|
|
1179
|
+
# result, or a stated reason E2E does not apply. The check fails while that
|
|
1180
|
+
# comment is empty, and whenever the walkthrough reports a failed or
|
|
1181
|
+
# inconclusive test case \u2014 its summary names each one. The verdict rides a check run
|
|
1068
1182
|
# against the PR head SHA rather than this job's own status, because the
|
|
1069
1183
|
# issue_comment trigger runs against the default branch \u2014 only a head-SHA check
|
|
1070
1184
|
# reaches the PR from there, which is what lets settling the comment turn the
|
|
@@ -1958,12 +2072,16 @@ function getHelpGuidance() {
|
|
|
1958
2072
|
function helpCommand() {
|
|
1959
2073
|
console.log(getHelpGuidance());
|
|
1960
2074
|
}
|
|
1961
|
-
var QUESTION = "Make E2E acceptance a CI check in this repo? It adds a GitHub Actions workflow
|
|
1962
|
-
async function
|
|
2075
|
+
var QUESTION = "Make E2E acceptance a CI check in this repo? It adds a GitHub Actions workflow that fails a pull request\nwhose Muggle walkthrough is missing or reports a failed test. [y/N]: ";
|
|
2076
|
+
async function applyCiWorkflowPreference(preference, cwd, ask) {
|
|
1963
2077
|
if (!existsSync(join(cwd, ".git"))) return "not-applicable" /* NotApplicable */;
|
|
1964
2078
|
if (existsSync(join(cwd, USER_WORKFLOW_PATH))) return "already-installed" /* AlreadyInstalled */;
|
|
1965
|
-
|
|
1966
|
-
if (
|
|
2079
|
+
if (preference === "never" /* Never */) return "turned-off" /* TurnedOff */;
|
|
2080
|
+
if (preference !== "always" /* Always */) {
|
|
2081
|
+
if (!ask) return "deferred" /* Deferred */;
|
|
2082
|
+
const answer = (await ask(QUESTION)).trim().toLowerCase();
|
|
2083
|
+
if (answer !== "y" && answer !== "yes") return "declined" /* Declined */;
|
|
2084
|
+
}
|
|
1967
2085
|
installCiWorkflow({ cwd, force: false });
|
|
1968
2086
|
return "installed" /* Installed */;
|
|
1969
2087
|
}
|
|
@@ -2109,19 +2227,25 @@ function reportOutcome(result) {
|
|
|
2109
2227
|
console.log(summary);
|
|
2110
2228
|
}
|
|
2111
2229
|
var CI_OFFER_REPORT = {
|
|
2112
|
-
["installed" /* Installed */]: `Added ${USER_WORKFLOW_PATH} \u2014 commit it, and every pull request here will owe a
|
|
2230
|
+
["installed" /* Installed */]: `Added ${USER_WORKFLOW_PATH} \u2014 commit it, and every pull request here will owe a passing walkthrough comment.`,
|
|
2113
2231
|
["declined" /* Declined */]: "Left CI alone. Run `muggle ci-install` whenever you want it.",
|
|
2232
|
+
["deferred" /* Deferred */]: "This repo has no Muggle E2E check in CI yet \u2014 run `muggle ci-install` to add it.",
|
|
2233
|
+
["turned-off" /* TurnedOff */]: null,
|
|
2114
2234
|
["already-installed" /* AlreadyInstalled */]: null,
|
|
2115
2235
|
["not-applicable" /* NotApplicable */]: null
|
|
2116
2236
|
};
|
|
2117
|
-
async function runCiOffer() {
|
|
2237
|
+
async function runCiOffer(ask) {
|
|
2238
|
+
const preference = resolvePreferences()["autoInstallCiWorkflow" /* AutoInstallCiWorkflow */];
|
|
2239
|
+
const line = CI_OFFER_REPORT[await applyCiWorkflowPreference(preference, process.cwd(), ask)];
|
|
2240
|
+
if (line) {
|
|
2241
|
+
console.log("");
|
|
2242
|
+
console.log(line);
|
|
2243
|
+
}
|
|
2244
|
+
}
|
|
2245
|
+
async function runInteractiveCiOffer() {
|
|
2118
2246
|
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
2119
2247
|
try {
|
|
2120
|
-
|
|
2121
|
-
if (line) {
|
|
2122
|
-
console.log("");
|
|
2123
|
-
console.log(line);
|
|
2124
|
-
}
|
|
2248
|
+
await runCiOffer((q) => rl.question(q));
|
|
2125
2249
|
} finally {
|
|
2126
2250
|
rl.close();
|
|
2127
2251
|
}
|
|
@@ -2137,7 +2261,9 @@ async function initCommand(options) {
|
|
|
2137
2261
|
} catch (error) {
|
|
2138
2262
|
console.error(error instanceof Error ? error.message : String(error));
|
|
2139
2263
|
process.exitCode = 1;
|
|
2264
|
+
return;
|
|
2140
2265
|
}
|
|
2266
|
+
await runCiOffer(null);
|
|
2141
2267
|
return;
|
|
2142
2268
|
}
|
|
2143
2269
|
if (!process.stdin.isTTY) {
|
|
@@ -2151,7 +2277,7 @@ async function initCommand(options) {
|
|
|
2151
2277
|
console.log("Muggle is already set up. Re-running the walkthrough \u2014 your current values are pre-selected.");
|
|
2152
2278
|
}
|
|
2153
2279
|
reportOutcome(applyOnboardingAnswers(await runTerminalWalkthrough()));
|
|
2154
|
-
await
|
|
2280
|
+
await runInteractiveCiOffer();
|
|
2155
2281
|
}
|
|
2156
2282
|
|
|
2157
2283
|
// src/cli/login.ts
|
|
@@ -2265,14 +2391,21 @@ function walkthroughVerdict(bodies) {
|
|
|
2265
2391
|
if (statuses.includes("pending" /* Pending */)) return "pending" /* Pending */;
|
|
2266
2392
|
return "missing" /* Missing */;
|
|
2267
2393
|
}
|
|
2394
|
+
function boundedChildTimeoutMs(ceilingMs) {
|
|
2395
|
+
return ceilingMs;
|
|
2396
|
+
}
|
|
2397
|
+
|
|
2398
|
+
// src/pr-walkthrough/gh.ts
|
|
2268
2399
|
var GH_CALLS_ENV = "MUGGLE_GUARDRAIL_GH_CALLS";
|
|
2269
2400
|
var defaultGhRunner = (args, input) => {
|
|
2270
2401
|
if (process.env[GH_CALLS_ENV] === "off") return null;
|
|
2402
|
+
const timeoutMs = boundedChildTimeoutMs(GH_COMMENT_TIMEOUT_MS);
|
|
2403
|
+
if (timeoutMs === null) return null;
|
|
2271
2404
|
try {
|
|
2272
2405
|
return execFileSync("gh", args, {
|
|
2273
2406
|
encoding: "utf-8",
|
|
2274
2407
|
input,
|
|
2275
|
-
timeout:
|
|
2408
|
+
timeout: timeoutMs,
|
|
2276
2409
|
stdio: ["pipe", "pipe", "ignore"],
|
|
2277
2410
|
windowsHide: true
|
|
2278
2411
|
});
|
|
@@ -2328,25 +2461,61 @@ function reserveComment(pr, comments, run) {
|
|
|
2328
2461
|
return postPrComment(pr, renderReservedComment(), run);
|
|
2329
2462
|
}
|
|
2330
2463
|
|
|
2331
|
-
// src/cli/pr-walkthrough/
|
|
2464
|
+
// src/cli/pr-walkthrough/constants.ts
|
|
2332
2465
|
var CHECK_RUN_NAME = "muggle-walkthrough";
|
|
2333
|
-
var
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
["
|
|
2466
|
+
var CHECK_RUN_TITLE = "Muggle AI PR visual walkthrough";
|
|
2467
|
+
var CHECK_SUMMARY_MAX_CASES = 50;
|
|
2468
|
+
var OUTCOME_CONCLUSIONS = {
|
|
2469
|
+
["settled" /* Settled */]: "success" /* Success */,
|
|
2470
|
+
["e2e-not-passing" /* E2eNotPassing */]: "failure" /* Failure */,
|
|
2471
|
+
["unsettled" /* Unsettled */]: "failure" /* Failure */,
|
|
2472
|
+
["unreadable" /* Unreadable */]: "neutral" /* Neutral */
|
|
2337
2473
|
};
|
|
2338
|
-
|
|
2339
|
-
|
|
2474
|
+
var FIXED_SUMMARIES = {
|
|
2475
|
+
["settled" /* Settled */]: "This PR's Muggle AI walkthrough comment is settled \u2014 every E2E acceptance case passed, or it states why E2E does not apply.",
|
|
2476
|
+
["unsettled" /* Unsettled */]: "This PR's Muggle AI walkthrough comment is still empty. Run the E2E acceptance suite and post the walkthrough into it (/muggle:muggle-test), or record why E2E does not apply to this change.",
|
|
2477
|
+
["unreadable" /* Unreadable */]: "The PR's comments could not be read, so the walkthrough duty could not be judged."
|
|
2478
|
+
};
|
|
2479
|
+
|
|
2480
|
+
// src/cli/pr-walkthrough/summary.ts
|
|
2481
|
+
function countLabel(count, status) {
|
|
2482
|
+
return count > 0 ? `${count} ${status}` : null;
|
|
2483
|
+
}
|
|
2484
|
+
function renderNotPassingSummary(record) {
|
|
2485
|
+
const failed = record.unpassed.filter((c) => c.status === "failed" /* Failed */).length;
|
|
2486
|
+
const tally = [
|
|
2487
|
+
countLabel(failed, "failed" /* Failed */),
|
|
2488
|
+
countLabel(record.unpassed.length - failed, "inconclusive" /* Inconclusive */)
|
|
2489
|
+
].filter((part) => part !== null).join(", ");
|
|
2490
|
+
const listed = record.unpassed.slice(0, CHECK_SUMMARY_MAX_CASES).map((unpassed) => renderUnpassedCaseBullet(unpassed, "open run", unpassed.viewUrl));
|
|
2491
|
+
const hidden = record.unpassed.length - listed.length;
|
|
2492
|
+
return [
|
|
2493
|
+
`E2E acceptance did not pass \u2014 ${tally} of ${record.total} test ${record.total === 1 ? "case" : "cases"}. Fix them, re-run the whole suite, and update the walkthrough comment; editing it re-runs this check.`,
|
|
2494
|
+
"",
|
|
2495
|
+
...listed,
|
|
2496
|
+
...hidden > 0 ? [`- \u2026and ${hidden} more \u2014 see the walkthrough comment.`] : []
|
|
2497
|
+
].join("\n");
|
|
2498
|
+
}
|
|
2499
|
+
|
|
2500
|
+
// src/cli/pr-walkthrough/check.ts
|
|
2501
|
+
function judgeComments(pr, comments, run) {
|
|
2502
|
+
if (comments === null) {
|
|
2503
|
+
return { outcome: "unreadable" /* Unreadable */, summary: FIXED_SUMMARIES["unreadable" /* Unreadable */] };
|
|
2504
|
+
}
|
|
2505
|
+
const bodies = comments.map((comment) => comment.body);
|
|
2506
|
+
const verdict = walkthroughVerdict(bodies);
|
|
2507
|
+
if (verdict === "missing" /* Missing */) reserveComment(pr, comments, run);
|
|
2508
|
+
const record = latestE2eResult(bodies);
|
|
2509
|
+
if (record && record.unpassed.length > 0) {
|
|
2510
|
+
return { outcome: "e2e-not-passing" /* E2eNotPassing */, summary: renderNotPassingSummary(record) };
|
|
2511
|
+
}
|
|
2512
|
+
const outcome = verdict === "satisfied" /* Satisfied */ ? "settled" /* Settled */ : "unsettled" /* Unsettled */;
|
|
2513
|
+
return { outcome, summary: FIXED_SUMMARIES[outcome] };
|
|
2340
2514
|
}
|
|
2341
2515
|
async function runPrWalkthroughCheck(options, run = defaultGhRunner) {
|
|
2342
2516
|
const pr = { repo: options.repo, prNumber: options.prNumber };
|
|
2343
|
-
const
|
|
2344
|
-
|
|
2345
|
-
if (comments !== null) {
|
|
2346
|
-
const verdict = walkthroughVerdict(comments.map((comment) => comment.body));
|
|
2347
|
-
if (verdict === "missing" /* Missing */) reserveComment(pr, comments, run);
|
|
2348
|
-
conclusion = conclusionFor(verdict);
|
|
2349
|
-
}
|
|
2517
|
+
const { outcome, summary } = judgeComments(pr, listPrComments(pr, run), run);
|
|
2518
|
+
const conclusion = OUTCOME_CONCLUSIONS[outcome];
|
|
2350
2519
|
if (options.publishCheckRun) {
|
|
2351
2520
|
createCheckRun(
|
|
2352
2521
|
options.repo,
|
|
@@ -2354,17 +2523,18 @@ async function runPrWalkthroughCheck(options, run = defaultGhRunner) {
|
|
|
2354
2523
|
name: CHECK_RUN_NAME,
|
|
2355
2524
|
headSha: options.headSha,
|
|
2356
2525
|
conclusion,
|
|
2357
|
-
title:
|
|
2358
|
-
summary
|
|
2526
|
+
title: CHECK_RUN_TITLE,
|
|
2527
|
+
summary
|
|
2359
2528
|
},
|
|
2360
2529
|
run
|
|
2361
2530
|
);
|
|
2362
2531
|
}
|
|
2363
2532
|
const failsLocally = conclusion === "failure" /* Failure */ && !options.publishCheckRun;
|
|
2364
2533
|
return {
|
|
2534
|
+
outcome,
|
|
2365
2535
|
conclusion,
|
|
2366
2536
|
exitCode: failsLocally ? 1 : 0,
|
|
2367
|
-
summary
|
|
2537
|
+
summary
|
|
2368
2538
|
};
|
|
2369
2539
|
}
|
|
2370
2540
|
function readEvent(eventPath) {
|
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { src_exports as commands, createUnifiedMcpServer, server_exports as server } from './chunk-
|
|
2
|
-
export { createChildLogger, e2e_exports as e2e, getConfig, getLocalQaTools, getLogger, getQaTools, local_exports as localQa, mcp_exports as mcp, e2e_exports as qa, src_exports as shared } from './chunk-
|
|
1
|
+
export { src_exports as commands, createUnifiedMcpServer, server_exports as server } from './chunk-SF75W2SV.js';
|
|
2
|
+
export { createChildLogger, e2e_exports as e2e, getConfig, getLocalQaTools, getLogger, getQaTools, local_exports as localQa, mcp_exports as mcp, e2e_exports as qa, src_exports as shared } from './chunk-M2PJRVCC.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "muggle",
|
|
3
3
|
"description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
|
|
4
|
-
"version": "5.22.0-staging.
|
|
4
|
+
"version": "5.22.0-staging.159",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Muggle AI",
|
|
7
7
|
"email": "support@muggle-ai.com"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "muggle",
|
|
3
|
-
"version": "5.22.0-staging.
|
|
3
|
+
"version": "5.22.0-staging.159",
|
|
4
4
|
"description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Muggle AI",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "muggle",
|
|
3
3
|
"displayName": "Muggle AI",
|
|
4
4
|
"description": "Real-browser E2E acceptance for your coding agent: test the flows you changed and open the PR with screenshots. Built for flows other tools can't reach: managed test identities with live inboxes (magic links, email OTP and 2FA, verification mail, password resets), an encrypted secret store for login and test credentials, and a test graph that runs prerequisite flows first. Plain-English tests become replayable scripts on localhost or preview URLs.",
|
|
5
|
-
"version": "5.22.0-staging.
|
|
5
|
+
"version": "5.22.0-staging.159",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Muggle AI",
|
|
8
8
|
"email": "support@muggle-ai.com"
|
|
@@ -28,7 +28,7 @@ A recorder that *clears* an obligation — a walkthrough posted, a failure diagn
|
|
|
28
28
|
|
|
29
29
|
Each guardrail is a bash gate script in `../scripts/` holding a `guardrail_wants` pre-filter and the `guardrails.mjs` subcommand it feeds; the bundled `../scripts/guardrails.mjs` holds the decision logic (built from `src/guardrails/`, vitest-covered). The busy events — a shell command before and after it runs, and every turn end — register one `guardrail-dispatch.sh` command listing their gates, which reads the payload once, asks every gate's pre-filter in that one process, and starts Node once (`guardrails.mjs run <gates...>`) for just the gates that could fire, merging their responses. Rarer events call a gate script directly. Per-session state in `~/.muggle-ai/guardrails/<session_id>.json` tracks what fired. Any *failure* degrades to `{}` (allow) — a gate blocks only by an explicit, tested decision, never by accident; `guardrail-lib.sh` is the one place that falls back, and `run` isolates gates from each other.
|
|
30
30
|
|
|
31
|
-
Pre-filters are bash builtins only (`guardrail-lib.sh`), so an irrelevant event starts no process at all. A gate that has spent its block budget stamps a `<gate>Released` flag, which its wrapper then pre-filters on — without it a released gate keeps cold-starting Node on every remaining turn end to answer `{}`, and the walkthrough gate keeps
|
|
31
|
+
Pre-filters are bash builtins only (`guardrail-lib.sh`), so an irrelevant event starts no process at all. A gate that has spent its block budget stamps a `<gate>Released` flag, which its wrapper then pre-filters on — without it a released gate keeps cold-starting Node on every remaining turn end to answer `{}`, and the walkthrough gate keeps queuing provider scans to do it. That pre-filter is a second, looser copy of what `guardrails.mjs` matches, and it is the one place a guardrail can fail *silently*: a payload it drops — a skip marker, a reopen line, a comment edit — reaches no recorder, and the gate keeps demanding an action the user already took. Over-matching is free; under-matching is a dead escape hatch. `src/test/guardrails/hook-prefilter.test.ts` pins every payload each subcommand acts on against the wrapper guarding it, and derives the skip-marker tokens from source so a new marker is covered the moment it exists.
|
|
32
32
|
|
|
33
33
|
## Guardrails
|
|
34
34
|
|
|
@@ -47,7 +47,7 @@ Pre-filters are bash builtins only (`guardrail-lib.sh`), so an irrelevant event
|
|
|
47
47
|
| `Stop` | `guardrail-e2e-gate.sh` | **enforce** | unit tests passed this session, no E2E ran yet, and no skip was recorded | `autoE2ETest` | **block** the turn until E2E runs via `muggle-test` or a `MUGGLE_E2E_SKIP` marker records a legitimate skip (full message once, one-line reminders after; releases after 3 blocks) |
|
|
48
48
|
| `Stop` | `guardrail-terminal-gate.sh` | **enforce** | a PR went terminal this session and the AskUserQuestion next-options offer hasn't run since | — | **block** the turn until the post-merge handoff runs (full message once, one-line reminders after; releases after 3 blocks; nothing but the offer resets the counter) |
|
|
49
49
|
| `Stop` | `guardrail-watch-gate.sh` | **enforce** | a PR opened this session that no `muggle-do` session slot tracks | `autoWatchPR` | **block** the turn until a slot is seeded via `muggle-pr-followup` or a `MUGGLE_WATCH_SKIP` marker records a legitimate skip (releases after 3 blocks) |
|
|
50
|
-
| `Stop` | `guardrail-walkthrough-gate.sh` | **enforce** | an E2E acceptance run happened this session and a PR in play — opened this session or on the working branch — carries no walkthrough in its body or comments | `postPRVisualWalkthrough` | **block** the turn until the walkthrough is posted via `muggle-pr-visual-walkthrough` or a `MUGGLE_WALKTHROUGH_SKIP` marker records a legitimate skip (releases after 3 blocks; an unreachable PR fails open to not-owed) |
|
|
50
|
+
| `Stop` | `guardrail-walkthrough-gate.sh` | **enforce** | an E2E acceptance run happened this session and a PR in play — opened this session or on the working branch — carries no walkthrough in its body or comments | `postPRVisualWalkthrough` | **block** the turn until the walkthrough is posted via `muggle-pr-visual-walkthrough` or a `MUGGLE_WALKTHROUGH_SKIP` marker records a legitimate skip (releases after 3 blocks; an unreachable PR fails open to not-owed). The provider lookups run in a detached scan, queued when the gate arms, when a PR opens, and at each turn end; the gate decides on the last scan for the session's current PRs and stays open until one lands |
|
|
51
51
|
| `Stop` | `guardrail-stage-gate.sh` | **enforce** | a skill invoked this session declared `mandatoryStages` and one of those files was never opened | — | **block** the turn until the stages are read or a `MUGGLE_STAGE_SKIP` marker records a legitimate skip (releases after 3 blocks) |
|
|
52
52
|
| `Stop` | `guardrail-debug-path-gate.sh` | **enforce** | a local execution returned a non-passing run this session and nothing routed it through `_shared/debug-failed-run.md` | — | **block** the turn until the run is diagnosed (its `*-failure-classified` emit or feedback naming it) or a `MUGGLE_DEBUG_SKIP: <runId> <reason>` marker clears that run (releases after 3 blocks) |
|
|
53
53
|
| `Stop` | `guardrail-comment-reply-gate.sh` | **enforce** | this session claimed a review thread and left one of its comments uncovered | — | **block** the turn until each comment gets its threaded reply per `do/per-comment-replies.md` or a `MUGGLE_REPLY_SKIP: <comment-id> <reason>` marker defers it (releases after 3 blocks). The claim is the signal, not a push, so a round that answers a question with no code change is caught too; a thread another session claimed never blocks this one |
|
|
@@ -74,14 +74,18 @@ Codex runs a plugin's hooks only once the user trusts them: it asks at startup (
|
|
|
74
74
|
|
|
75
75
|
The nudge counts only slots **this session owns**, and reports the rest as orphans it will not act on — ownership and the recovery rules it gates are defined in [`reconcile`](../skills/muggle-pr-followup/reconcile.md). Nothing owned and nothing orphaned → it emits nothing. A pure directory scan (no `gh`, no writes), so it's cheap enough for every session start.
|
|
76
76
|
|
|
77
|
+
## Session-start upkeep
|
|
78
|
+
|
|
79
|
+
`SessionStart` (`scripts/ensure-electron-app.sh`) injects the session context and nothing slower: it reads the caches the upkeep leaves and resolves preferences in one Node process. The upkeep itself — the Electron runner install (`muggle setup`, capped at 60 s), the npm version lookup behind the upgrade notice, and the state GC below — runs in `scripts/session-maintenance.sh`, which the hook launches detached at most once a day. Its `~/.cache/muggle/session-maintenance-due` stamp holds the epoch second it next comes due, so every other start launches nothing; the stamp is written before the work starts, so sessions opening together run it once.
|
|
80
|
+
|
|
77
81
|
## Session-start state GC
|
|
78
82
|
|
|
79
|
-
`
|
|
83
|
+
`scripts/gc-state.sh`, run by the upkeep — prunes ephemeral state that nothing else garbage-collects, so it doesn't grow without bound (the per-session guardrails files and finalized watcher slots otherwise accumulate one-per-session forever). Collection is keyed on **inactivity, never creation age**, so state a long-lived session still relies on is never deleted out from under it:
|
|
80
84
|
|
|
81
|
-
- `~/.muggle-ai/guardrails/*.json` (one per session) is pruned only after 14 days of **no activity**. An in-use session keeps rewriting its file (`guardrails.mjs` on every guarded tool call) and
|
|
85
|
+
- `~/.muggle-ai/guardrails/*.json` (one per session, plus its walkthrough-scan sidecar) is pruned only after 14 days of **no activity**. An in-use session keeps rewriting its file (`guardrails.mjs` on every guarded tool call) and `ensure-electron-app.sh` refreshes it on every resume, so its mtime tracks last activity — a session that runs for months stays live indefinitely, and only one that has genuinely gone quiet for the whole window (i.e. ended) is collected.
|
|
82
86
|
- Finalized watcher slots (`result.md` present) are pruned 30 days after finalize; their `followup.log` is forensic-only. An **open** slot — a PR watched for any length of time — has no `result.md` and is never touched.
|
|
83
87
|
|
|
84
|
-
Both windows are overridable (`MUGGLE_GUARDRAILS_TTL_DAYS`, `MUGGLE_SLOT_TTL_DAYS`). TTL-gated to once per day via a `~/.cache/muggle/state-gc-checked` marker
|
|
88
|
+
Both windows are overridable (`MUGGLE_GUARDRAILS_TTL_DAYS`, `MUGGLE_SLOT_TTL_DAYS`). TTL-gated to once per day via a `~/.cache/muggle/state-gc-checked` marker; silent and best-effort. It refreshes the current session's own state before sweeping, so never collects it, and never touches an open slot.
|
|
85
89
|
|
|
86
90
|
## Footprint caps
|
|
87
91
|
|
|
@@ -93,7 +97,11 @@ Every hook here fires on every tool call, prompt or turn end in every open sessi
|
|
|
93
97
|
| Programs started beyond each hook's own launch on an irrelevant event | 0 (Stop: 1, a transcript `tail` until the capability-claim gate has nudged; bash cannot seek) |
|
|
94
98
|
| `node`, `gh`, `python` on that path | 0 |
|
|
95
99
|
| Median wall time of one irrelevant firing, Linux/macOS | 100 ms |
|
|
96
|
-
| Hook commands in the whole manifest |
|
|
97
|
-
| Hook timeout | declared on every hook;
|
|
100
|
+
| Hook commands in the whole manifest | 14 |
|
|
101
|
+
| Hook timeout | declared on every hook; 1 s each, 2 s summed over the hooks one firing launches |
|
|
102
|
+
| Median wall time of each hook, on every scenario in `HOOK_RUNTIME_SCENARIOS`, every platform | 1 s |
|
|
103
|
+
| Summed median wall time of the hooks one firing launches | 2 s |
|
|
98
104
|
|
|
99
105
|
Counts are exec counts, so they are identical on every runner. Every count is exact: CI fails when a change exceeds a limit, and also when it beats one until `footprint/constants.ts` is lowered to match, so a gain cannot be given back later.
|
|
106
|
+
|
|
107
|
+
The harness kills a hook at its timeout, so the 1 s timeout is the hard cap; the runtime scenarios hold each hook inside it. They fire every `hooks.json` group — a group no scenario fires fails CI — on its irrelevant path and on the payloads that make its gates do real work, with `gh`, `muggle`, `npm`, `npx`, `curl` and `wget` replaced by stand-ins that stall for 5 s, so a hook that waits on the network or an install fails there rather than on a user's machine. Work that has to wait on the network leaves the hook path: the walkthrough comment's reserve and settle writes and the walkthrough gate's provider scan run as detached `guardrails.mjs` background jobs, and every other child a gate starts (`git`, the dev-server probe) is cut to what is left of a 600 ms allowance (`src/hook-budget/`).
|