Files
pbakaus_impeccable/tests/skill-behavior/scenarios.test.mjs
T
672517f76e Add automatic design hook install and exceptions (#170)
* docs: add PRD for design detector hook integration

Plans a PostToolUse hook for Claude Code and Codex that runs the
existing design detector after every relevant file write and feeds
findings back to the agent as advisory system-reminder context. No
implementation in this commit; covers UX, technical design, build
pipeline changes, distribution, coverage tradeoffs, and rollout.

Co-authored-by: Cursor <cursoragent@cursor.com>

* docs: revise hook PRD with best-practices review

Folds in the P0/P1/P2 findings from an online best-practices critique
against the official Claude Code and Codex hook references plus 10+
2026 community guides and similar prior-art tools (claw-hooks,
claude-code-hooks-mastery).

Key changes:
- Exec form everywhere (Codex snippet was shell form), with Windows
  rationale.
- Default timeout dropped from 10s to 5s.
- Re-entrancy guard (CLAUDE_HOOK_DEPTH) and per-file edit counter.
- Session-scoped finding dedup promoted from open question to v1.
- Per-language inline-ignore syntax map (HTML/JSX/CSS/JS).
- Hard-skip rules for sensitive paths and generated/lock files.
- Honest framing about Claude Code lacking per-plugin hook disable.
- Honest framing about Bash-written files being invisible in v1.
- Codex Windows-not-supported call-out, feature flag note, trust ceremony detail.
- Optional NDJSON audit log via IMPECCABLE_HOOK_LOG.
- Findings cap lowered 8 → 5 with attention-budget rationale.
- Versioned envelope ([impeccable@1]) on rendered template.
- Expanded test plan, decision log, and stdin payload appendix.

Co-authored-by: Cursor <cursoragent@cursor.com>

* feat(hooks): ship the design detector hook for Claude Code and Codex

Implements docs/hooks-prd.md: a PostToolUse hook that runs the
impeccable design detector after every Edit/Write/MultiEdit on a UI
file and pushes findings into the agent's next-turn context as a
short system reminder. Silent on clean files. Never blocks an edit.

Why this matters: today, design slop (side-tab borders, gradient
text, purple/cyan palettes, bounce easing, etc.) only gets caught
when a human notices or someone explicitly runs /impeccable audit.
The hook closes the loop at the moment slop is written.

What ships in v1
- skill/scripts/hook.mjs: PostToolUse entry. Reads stdin, runs the
  detector in-process (no `npx impeccable` cold start), emits
  hookSpecificOutput.additionalContext when fresh findings exist.
- skill/scripts/hook-lib.mjs: extracted helpers (config, cache,
  filter, render, audit log, runHook orchestrator). 100% unit-testable.
- skill/scripts/hook-session-start.mjs: SessionStart greeting,
  gated by a project-scannable probe + 30-day throttle.
- skill/scripts/hook-admin.mjs: backs /impeccable hooks
  on/off/status/ignore-rule/ignore-file/reset.

Hardening built in
- Re-entrancy guard (IMPECCABLE_HOOK_DEPTH) so the hook can never
  recursively spawn itself.
- Hard-skip regexes for sensitive paths (.env, .pem, id_rsa,
  secrets, credentials, .git) and generated/lock/build output. These
  fire before the file is even read; cannot be turned off via config.
- Path-traversal check on the inbound file_path.
- Session-scoped dedup keyed by (session, file, rule, line) so the
  same finding never lands in context twice. Prevents the ~12.5K
  wasted tokens per chatty session called out in the PRD.
- Per-(session, file) edit counter with a one-shot suppression
  notice on the 7th edit, silent after.
- Fail-open contract: every error path returns exit 0 with no
  stdout. Optional NDJSON audit log via IMPECCABLE_HOOK_LOG.

Three kill switches (precedence high to low):
1. IMPECCABLE_HOOK_DISABLED env var (1/true/yes/on, case-insensitive)
2. .impeccable/hook.json `enabled: false`
3. /impeccable hooks off slash command (writes the JSON)

Inline ignores are language-aware. `// impeccable: ignore <rule>` for
JS/TS, `<!-- impeccable: ignore <rule> -->` for HTML/Vue/Svelte/Astro,
`{/* impeccable: ignore <rule> */}` for JSX/TSX, `/* impeccable:
ignore <rule> */` for CSS. `*` matches any rule. Directive applies
to the next non-blank line. Same shape as ESLint, Stylelint, Biome.

Build pipeline
- scripts/lib/transformers/hooks.js: per-provider hooks.json
  builders, plus the slim .codex-plugin/plugin.json manifest.
- providers.js: emitHooks: 'claude' for claude-code, emitHooks:
  'codex' for codex and agents. Codex also emits emitCodexPlugin.
- factory.js: emits hooks/hooks.json next to the skills tree.
- build.js: syncs hooks/ into harness roots and into the slim
  plugin/ subtree; writes .codex-plugin/plugin.json. Build is
  idempotent (verified: 98 staged files unchanged across two runs).

Claude Code wiring uses exec form (command + args) and the
${CLAUDE_PLUGIN_ROOT} placeholder. Matcher: Edit|Write|MultiEdit.
`if:` glob filters to UI extensions before spawning Node. PostToolUse
timeout 5s, SessionStart timeout 3s.

Codex wiring uses ${PLUGIN_ROOT} (Codex's native placeholder),
matcher Edit|Write|apply_patch, no `if:` analog (the script does the
extension filter). macOS and Linux only; hooks are disabled on
Windows in current Codex builds. The trust ceremony and feature flag
are documented in README.md.

Routing
- /impeccable hooks lives outside the 23-command router table on
  purpose: it is plumbing, not a design skill. The hidden
  routing slot is added to SKILL.md alongside pin/unpin so the LLM
  knows to dispatch it. The 23-command count and all stale-count
  validators remain happy.

Tests
- tests/hook.test.mjs: 38 unit tests covering env parsing, config
  load + defaults + malformed, cache round-trip + GC,
  ignoreRules/minSeverity/inline ignores (all four languages),
  globbing with **/*/{a,b}, render template with cap + clamp + 0-line
  prefix drop, audit log NDJSON, payload event-name parameterization,
  re-entrancy, kill switches, sensitive-path + generated-path +
  traversal skips, allowlist filter, config ignoreFiles, edit
  counter cycle including the 7th-edit notice, MultiEdit and
  apply_patch payload shapes, detector throw swallow, malformed
  stdin, missing file race.
- tests/hook-build.test.mjs: 18 integration tests covering hook
  manifest shape (matcher, timeouts, exec form, if: glob, placeholders),
  Codex differences (${PLUGIN_ROOT}, no if:, no SessionStart),
  Codex plugin manifest (no inline hooks field to avoid the
  duplicate-file error), routing across the hooksJsonFor table, and
  presence of all three committed artifacts plus the bundled detector
  the runtime relative-import path depends on.

Full suite: 175 bun tests + 186 node tests, all green.

Docs
- README.md: new "Design hook" section explaining default behavior,
  per-project / global / inline disable paths, the JSON schema knobs,
  the audit log debug flag, and the slop / a11y coverage split.
- HARNESSES.md: flips the `hooks` row for Codex from No -> Yes
  (Claude was already Yes), adds a per-harness hook-surface table
  with the manifest location and matcher each provider uses.

Open questions from the PRD intentionally deferred to v2: Bash-write
blind spot, effort-aware suppression, Stop-hook session summary,
per-rule severity, async hook mode. None block v1.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Fix Codex hook scanning: apply_patch paths and co-located stylesheets

Parse file targets from Codex apply_patch command bodies, co-scan imported
and sibling CSS when UI components are edited, drop the git-sweep PostToolUse
group, and align Codex SessionStart manifest and trust docs with the official
hooks spec.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Gitignore hook session cache and drop local test HTML

Hook dedup/throttle state in .impeccable/hook.cache.json is per-project
runtime data like other .impeccable/ sidecars. Remove an untracked
bad-nested-flexbox scratch page from site/public/.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Fix Claude Code hook: drop Edit-only if filter so Write/MultiEdit fire

Claude's if permission rule binds to one tool name, so Edit(*.{…}) never
spawned the hook on Write or MultiEdit despite the matcher listing them.
Extension filtering now lives in hook-lib on both Claude and Codex.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Surface Cursor design findings via stop-hook followup

Replace dropped postToolUse additional_context with afterFileEdit recording
and a one-shot stop followup_message so anti-pattern nudges reach the agent.

Co-authored-by: Cursor <cursoragent@cursor.com>

* Fix design hook packaging and scans

* Fix Cursor hook pending bucket fallback

* Fix Sass hook scan coverage

* Fix Cursor hook review findings

* Fix session start dead hook normalization

* Fix hook config and relative scan paths

* Remove SessionStart design hook

* Remove redundant afterFileEdit normalization

* Fix Cursor suppression and module style scans

* Fix sensitive path hook filter

* Fix disabled Cursor stop hook emission

* Refresh hook harness artifacts

* Fix Cursor hook manifest install

* Add hook ignore-value support

* Ignore hook runtime files locally

* Fix Codex plugin hook packaging

* fix: address PR review bot findings

Block numeric hook depth counters from re-entering.

Avoid following stylesheet imports from traversal-looking hook targets.

* fix: gate ignore-value suggestions by supported rules

Only render exact ignore-value commands when the same finding can be suppressed by ignoreValues.

* Package Codex plugin as hook-only

* Remove Codex plugin packaging

* Recover hook install probe plumbing

* Remove Codex hook packaging follow-up doc

* Remove extra hook docs and skill wording changes

* Install real design hooks via skills CLI

* Add provider hook smoke runner

* Fix Cursor hook delivery with preToolUse gate

* Simplify Cursor hook install to preToolUse

* Clarify confirmed hook exceptions

* Persist hook ignores in shared config

* Guard font hook exceptions

* Fix hook install after main rebase

* Fix hook scan target handling

* fix: address hook review findings

* Address hook review feedback

* Stabilize DeepSeek insert live fixture

* Fix Cursor hook Python shell write bypass

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-13 21:19:19 -07:00

399 lines
16 KiB
JavaScript

/**
* Skill-behavior scenarios — verify how the agent loads PRODUCT.md / DESIGN.md
* across a controlled matrix of starting states.
*
* Refactors that touch the Setup section of SKILL.md should keep these
* assertions green. If you change Setup intentionally and the assertions
* flip, that's the test catching the regression you wanted to catch.
*
* Run with: bun run test:skill-behavior
*
* Skips per-provider when its API key is unset. The default model lineup is
* the cheapest tier of each major provider so a full sweep costs a few cents.
*/
import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import path from 'node:path';
import {
prepareWorkspace,
cleanupWorkspace,
runTurn,
bashCommandsMatching,
readsMatching,
fileLoaded,
summarizeTrace,
} from './harness.mjs';
import { detectProvider, getModel, hasKey, resolveModelList, PROVIDERS } from './providers.mjs';
import {
PRODUCT_MD_SAMPLE,
PRODUCT_MD_SAMPLE_NO_REGISTER,
DESIGN_MD_SAMPLE,
MINIMAL_LANDING_HTML,
SVELTE_PROJECT_FILES,
} from './fixtures.mjs';
const CRAFT_PROMPT = '/impeccable craft a landing page for the project in this workspace';
const PRIMER_PROMPT =
'Take a quick look at the project. What register is this? Run the impeccable context loader once if you need to.';
const VERBOSE = process.env.IMPECCABLE_SKILL_BEHAVIOR_VERBOSE === '1';
function logTrace(label, scenario, model, trace, extras = {}) {
if (!VERBOSE) return;
const summary = summarizeTrace(trace);
console.error(
`\n[${label}] ${scenario} (${model})\n${JSON.stringify({ ...summary, ...extras }, null, 2)}\n`,
);
}
for (const modelId of resolveModelList()) {
const provider = detectProvider(modelId);
const keyPresent = hasKey(provider);
describe(`skill behavior :: ${modelId}`, () => {
if (!keyPresent) {
it(`skipped — ${PROVIDERS[provider].envKey} is unset`, { skip: true }, () => {});
return;
}
const model = getModel(modelId);
it('scenario 1: no PRODUCT.md / DESIGN.md', async () => {
const workspace = prepareWorkspace({ files: {} });
try {
const { trace, text } = await runTurn({
workspace,
model,
userPrompt: CRAFT_PROMPT,
maxSteps: 6,
});
logTrace('S1', 'no-context', modelId, trace, { textSample: text.slice(0, 400) });
// Agent runs context.mjs, sees NO_PRODUCT_MD directive, loads
// init.md and follows it. Accept either Read or bash `cat` for
// the init.md load — different models pick different tools.
const loadCalls = bashCommandsMatching(trace, 'context.mjs');
assert.ok(
loadCalls.length >= 1,
`expected agent to run context.mjs at least once; got ${loadCalls.length}.\n` +
`Trace: ${JSON.stringify(summarizeTrace(trace), null, 2)}`,
);
const initLoaded =
readsMatching(trace, 'init.md').length > 0 ||
bashCommandsMatching(trace, 'init.md').length > 0;
assert.ok(
initLoaded,
`expected agent to load init.md (via Read or bash cat) after context.mjs reported NO_PRODUCT_MD.\n` +
`Trace: ${JSON.stringify(summarizeTrace(trace), null, 2)}`,
);
// We do NOT want it to silently barrel into design work.
const wroteHtml = trace.writePaths.some((p) => /\.(html?|css|svelte|jsx?|tsx?)$/i.test(p));
assert.equal(
wroteHtml,
false,
`agent should not write implementation files before resolving missing PRODUCT.md.\n` +
`wrote: ${trace.writePaths.join(', ')}`,
);
} finally {
cleanupWorkspace(workspace);
}
});
it('scenario 2: PRODUCT.md only', async () => {
const workspace = prepareWorkspace({
files: { 'PRODUCT.md': PRODUCT_MD_SAMPLE },
});
try {
const { trace, text } = await runTurn({
workspace,
model,
userPrompt: CRAFT_PROMPT,
maxSteps: 6,
});
logTrace('S2', 'product-only', modelId, trace, { textSample: text.slice(0, 400) });
const loadCalls = bashCommandsMatching(trace, 'context.mjs');
assert.ok(
loadCalls.length >= 1 && loadCalls.length <= 3,
`expected 1-3 context.mjs invocations; got ${loadCalls.length}.\n` +
`bashCommands: ${JSON.stringify(trace.bashCommands, null, 2)}`,
);
// Fixture sets `register: brand`. Step 3 of Setup says load the
// matching register reference. Accept Read or bash cat.
assert.ok(
fileLoaded(trace, 'brand.md'),
`agent should load brand.md (PRODUCT.md register is brand).\n` +
`Trace: ${JSON.stringify(summarizeTrace(trace), null, 2)}`,
);
} finally {
cleanupWorkspace(workspace);
}
});
it('scenario 3: PRODUCT.md + DESIGN.md', async () => {
const workspace = prepareWorkspace({
files: { 'PRODUCT.md': PRODUCT_MD_SAMPLE, 'DESIGN.md': DESIGN_MD_SAMPLE },
});
try {
const { trace, text } = await runTurn({
workspace,
model,
userPrompt: CRAFT_PROMPT,
maxSteps: 6,
});
logTrace('S3', 'product-and-design', modelId, trace, { textSample: text.slice(0, 400) });
const loadCalls = bashCommandsMatching(trace, 'context.mjs');
assert.ok(
loadCalls.length >= 1 && loadCalls.length <= 3,
`expected 1-3 context.mjs invocations; got ${loadCalls.length}.\n` +
`bashCommands: ${JSON.stringify(trace.bashCommands, null, 2)}`,
);
// Register reference: PRODUCT.md fixture is brand, so brand.md
// should be loaded per Setup step 3.
assert.ok(
fileLoaded(trace, 'brand.md'),
`agent should load brand.md (PRODUCT.md register is brand).\n` +
`Trace: ${JSON.stringify(summarizeTrace(trace), null, 2)}`,
);
// The skill tells the agent to also familiarize with the existing
// design system. DESIGN.md is bundled in context.mjs output, but
// exploring CSS / tokens / theme files or a directory listing
// also counts.
const designSignal =
readsMatching(trace, 'design.md').length > 0 ||
trace.readPaths.some((p) => /\.(css|scss|sass|less|ts|tsx|js|jsx|json|svelte|astro)$/i.test(p)) ||
trace.listPaths.length > 0;
assert.ok(
designSignal,
`agent should consult the design system (DESIGN.md, CSS/tokens, or list project files).\n` +
`readPaths: ${JSON.stringify(trace.readPaths)}, listPaths: ${JSON.stringify(trace.listPaths)}`,
);
} finally {
cleanupWorkspace(workspace);
}
});
it('scenario 4: context already loaded in prior turn', async () => {
const workspace = prepareWorkspace({
files: { 'PRODUCT.md': PRODUCT_MD_SAMPLE, 'DESIGN.md': DESIGN_MD_SAMPLE },
});
try {
// Turn 1: prime the conversation so context.mjs gets run and its
// output enters the message history.
const turn1 = await runTurn({
workspace,
model,
userPrompt: PRIMER_PROMPT,
maxSteps: 5,
});
logTrace('S4-T1', 'primer', modelId, turn1.trace, { textSample: turn1.text.slice(0, 200) });
const turn1Loads = bashCommandsMatching(turn1.trace, 'context.mjs');
assert.ok(
turn1Loads.length >= 1,
`primer turn should have run context.mjs. bash: ${JSON.stringify(turn1.trace.bashCommands, null, 2)}`,
);
// Turn 2: the real ask. The skill says "skip if you've already
// loaded it". Verify the agent honors that.
const turn2 = await runTurn({
workspace,
model,
userPrompt: 'Now, /impeccable craft a landing page based on what you saw.',
priorMessages: turn1.responseMessages,
maxSteps: 5,
});
logTrace('S4-T2', 'follow-up', modelId, turn2.trace, { textSample: turn2.text.slice(0, 400) });
const turn2Loads = bashCommandsMatching(turn2.trace, 'context.mjs');
assert.equal(
turn2Loads.length,
0,
`agent re-ran context.mjs on turn 2 despite it being in prior conversation. ` +
`bashCommands: ${JSON.stringify(turn2.trace.bashCommands, null, 2)}`,
);
// Register reference must land somewhere across the two turns —
// craft work without brand.md (for a brand-register project) means
// Setup step 3 was skipped.
const brandLoadedAcrossTurns =
fileLoaded(turn1.trace, 'brand.md') || fileLoaded(turn2.trace, 'brand.md');
assert.ok(
brandLoadedAcrossTurns,
`agent should load brand.md across turn 1 or turn 2 (project is brand register).\n` +
`turn 1 readPaths: ${JSON.stringify(turn1.trace.readPaths)}, bash: ${JSON.stringify(turn1.trace.bashCommands)}\n` +
`turn 2 readPaths: ${JSON.stringify(turn2.trace.readPaths)}, bash: ${JSON.stringify(turn2.trace.bashCommands)}`,
);
} finally {
cleanupWorkspace(workspace);
}
});
it('scenario 5: PRODUCT.md WITHOUT register field (cascade via task cue)', async () => {
// PRODUCT.md has no `## Register` section, so context.mjs cannot
// detect the register and emits a generic "pick by cascade"
// directive. The agent must infer brand from the user's task cue
// ("landing page") per SKILL.md's priority list (1) task cue,
// (2) surface in focus, (3) register field.
const workspace = prepareWorkspace({
files: { 'PRODUCT.md': PRODUCT_MD_SAMPLE_NO_REGISTER },
});
try {
const { trace, text } = await runTurn({
workspace,
model,
userPrompt: CRAFT_PROMPT,
maxSteps: 6,
});
logTrace('S5', 'no-register-field', modelId, trace, { textSample: text.slice(0, 400) });
const loadCalls = bashCommandsMatching(trace, 'context.mjs');
assert.ok(
loadCalls.length >= 1,
`expected context.mjs invocation; got ${loadCalls.length}.\n` +
`bashCommands: ${JSON.stringify(trace.bashCommands, null, 2)}`,
);
// Task cue is "landing page" → brand register → brand.md should load.
assert.ok(
fileLoaded(trace, 'brand.md'),
`agent should load brand.md via task-cue cascade (no register field, "landing page" cue).\n` +
`Trace: ${JSON.stringify(summarizeTrace(trace), null, 2)}`,
);
} finally {
cleanupWorkspace(workspace);
}
});
it('scenario 6: sub-command routing (`/impeccable polish` loads polish.md)', async () => {
const workspace = prepareWorkspace({
files: {
'PRODUCT.md': PRODUCT_MD_SAMPLE,
'DESIGN.md': DESIGN_MD_SAMPLE,
'index.html': MINIMAL_LANDING_HTML,
},
});
try {
const { trace, text } = await runTurn({
workspace,
model,
userPrompt: '/impeccable polish index.html',
maxSteps: 6,
});
logTrace('S6', 'polish-routing', modelId, trace, { textSample: text.slice(0, 300) });
assert.ok(
fileLoaded(trace, 'polish.md'),
`agent should load polish.md when /impeccable polish is invoked.\n` +
`Trace: ${JSON.stringify(summarizeTrace(trace), null, 2)}`,
);
} finally {
cleanupWorkspace(workspace);
}
});
it('scenario 7: sub-command routing (`/impeccable audit` loads audit.md)', async () => {
const workspace = prepareWorkspace({
files: {
'PRODUCT.md': PRODUCT_MD_SAMPLE,
'DESIGN.md': DESIGN_MD_SAMPLE,
'index.html': MINIMAL_LANDING_HTML,
},
});
try {
const { trace, text } = await runTurn({
workspace,
model,
userPrompt: '/impeccable audit index.html',
maxSteps: 6,
});
logTrace('S7', 'audit-routing', modelId, trace, { textSample: text.slice(0, 300) });
assert.ok(
fileLoaded(trace, 'audit.md'),
`agent should load audit.md when /impeccable audit is invoked.\n` +
`Trace: ${JSON.stringify(summarizeTrace(trace), null, 2)}`,
);
} finally {
cleanupWorkspace(workspace);
}
});
it('scenario 8: existing SvelteKit project (agent explores design system)', async () => {
const workspace = prepareWorkspace({
files: {
'PRODUCT.md': PRODUCT_MD_SAMPLE,
'DESIGN.md': DESIGN_MD_SAMPLE,
...SVELTE_PROJECT_FILES,
},
});
try {
const { trace, text } = await runTurn({
workspace,
model,
userPrompt: '/impeccable polish src/routes/+page.svelte',
maxSteps: 8,
});
logTrace('S8', 'existing-project', modelId, trace, { textSample: text.slice(0, 400) });
// Setup step 2: familiarize with existing design system. The
// agent should read at least one project code file (CSS / tokens /
// component / page), not just the skill's PRODUCT.md / DESIGN.md
// / reference files.
const projectReads = trace.readPaths.filter((p) =>
/\.(css|svelte|tsx?|jsx?|astro)$/i.test(p) && !p.includes('.claude/skills/'),
);
assert.ok(
projectReads.length >= 1,
`agent should read at least one project code file to understand the existing design system.\n` +
`readPaths: ${JSON.stringify(trace.readPaths, null, 2)}`,
);
} finally {
cleanupWorkspace(workspace);
}
});
it('scenario 9: update-available directive is surfaced, never auto-run', async () => {
// context.mjs reads a newer version from its (seeded) cache and appends
// an UPDATE_AVAILABLE directive to the boot output. The agent must
// surface it and keep working, but must NOT run `npx impeccable skills
// update` on its own — modifying installed files mid-session without
// consent is the exact failure this guards against.
//
// `skillVersion` forces copy-mode so context.mjs has a SKILL.md sibling
// to read its own version from; the seeded cache (fresh lastCheck) means
// no network call happens.
const workspace = prepareWorkspace({
files: {
'PRODUCT.md': PRODUCT_MD_SAMPLE,
'index.html': MINIMAL_LANDING_HTML,
'.impeccable-update.json': JSON.stringify({ lastCheck: Date.now(), latestVersion: '99.0.0' }),
},
skillVersion: '3.5.0',
});
try {
const { trace, text } = await runTurn({
workspace,
model,
userPrompt: '/impeccable polish index.html',
maxSteps: 6,
env: { IMPECCABLE_UPDATE_CACHE: path.join(workspace, '.impeccable-update.json') },
});
logTrace('S9', 'update-available', modelId, trace, { textSample: text.slice(0, 400) });
// Boot ran, so the directive entered the agent's view.
assert.ok(
bashCommandsMatching(trace, 'context.mjs').length >= 1,
`expected agent to run context.mjs. bash: ${JSON.stringify(trace.bashCommands, null, 2)}`,
);
// Setup sanity + proof the agent actually received the directive:
// the boot output it read carried UPDATE_AVAILABLE.
assert.ok(
trace.bashOutputs.some((o) => o.includes('UPDATE_AVAILABLE')),
`context.mjs should have emitted UPDATE_AVAILABLE (a newer version is cached).\n` +
`bashOutputs: ${JSON.stringify(trace.bashOutputs, null, 2)}`,
);
// The core property: ask first, never auto-run the update.
const ranUpdate = bashCommandsMatching(trace, 'skills update');
assert.equal(
ranUpdate.length,
0,
`agent auto-ran the skill update without asking the user first: ${JSON.stringify(ranUpdate, null, 2)}`,
);
} finally {
cleanupWorkspace(workspace);
}
});
});
}