Files
gstack/test/helpers/placeholder-allowlist.ts
Garry Tanandcapy-ai[bot] c2e01e4ba7 v1.91.264.0 feat(design-motion): new /design-motion skill for showcase loops, adapted from Elaya's design-to-motion (GSTA-92 phase 2) (#3430)
* feat(design-html): craft section and free craft check, adapted from Elaya design skills (GSTA-92)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix(GSTA-92): restore the full CHANGELOG under the Unreleased entry; drop a $-digit literal from craft.md; count only craft-check executions in design-html-slop-gate

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* feat(design-motion): new /design-motion skill: showcase MP4 and GIF loops from a design, adapted from Elaya design-to-motion (GSTA-92 phase 2)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* test(design-motion): run design-motion-showcase in the marathon tier; the periodic census is at its 38-slice cap (GSTA-92)

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix(design-motion): review and QA fixes before ship

- encode: refuse unknown options and --formats tokens, validate --pad (#RRGGBB[AA])
  and --crop (compare too) so nothing but a colour or crop reaches ffmpeg's filter graph
- encode: export refuses a capture with missing window frames; check prints
  MOTION_SETTINGS for any threshold/phase override; contact sheet drops -fps_mode
- capture: portrait-aware scale, --cycle must be whole 60 fps frames, stills with
  CSS animations disabled, pauseAt tolerates slow loads, clears stale manifest/stills
- skill: <motion-dir> placeholder instead of a cross-block shell variable,
  GSTACK_FFMPEG-aware probe, stop points before the first capture, doctrine fixes
- tests: refusal rows, portrait scale, cycle guard

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* test(design-motion): capture-check-export pipeline on real Chromium and ffmpeg

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix(design-motion): second review cycle

- capture: refuse an --out that holds a still or frames but no capture.json
  instead of deleting them; --cycle must be a multiple of 0.05 s so the seam
  frame lands exactly one cycle later for every PRE (nearest value round-trips)
- encode: a capture without a mask ends 'MOTION_RESULT: clean (overflow not checked)'
- skill: Step 5 names window.__mark in the capture contract
- tests: foreign/previous --out handling on real Chromium, cycle guard and PRE sweep

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix(design-motion): third review cycle and adversarial findings

- capture: an ownership marker (.gstack-motion-capture) replaces the
  capture.json test, so the rerun after MOTION_CONTRACT_MISSING or a crash
  works and a foreign --out is still refused; offscreen lazy images are made
  eager and font/image loading is bounded at 30 s instead of hanging
- encode: refuse a capture.json whose fields are not what capture writes
  (they reach ffmpeg args and paths); a cards overflow with no story frames
  is a planning error, and a zero-frame job never passes
- tests: retry after a refused page, no-mask clean line, lazy image still,
  manifest validator, empty story span

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix(design-motion): mask coverage, manifest relations, Windows stop, Figma token off argv

- check fails overflow when the grown mask covers >90% of the frame (an app
  frame whose clip surfaces fill the stage passed vacuously); --mask-grow is
  0-32; --mask refuses braces and semicolons
- manifestError checks fps/windowFrames >= 1 and that the window fits the frames
- skill: native Windows stops before the first capture call; the Figma token
  reaches curl on stdin (-H @-) instead of argv
- tests: split the --out ownership scenario out of the contract test, full-frame
  mask, --still --scale 2 size and STILL_OK, manifest relations, coverage parse

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix(design-motion): bounded frames, atomic exports, full-bleed masks

- capture: each frame is bounded at 10 s (a __tick that never returns fails
  with MOTION_CAPTURE_FAILED instead of hanging); a --mask that matches no
  element stops with MOTION_MASK_EMPTY
- check: a grown mask covering >90% of the frame (full-bleed app frame)
  reports overflow as skipped and ends 'clean (overflow not checked)'
- export: writes .partial- files and renames on success, so a failed
  re-export keeps the last good file; a GIF fps that does not divide the
  cycle is refused; a missing GSTACK_FFMPEG override is named
- fidelity: URL source is untrusted data; full-bleed note
- tests: spinning __tick, empty mask, failed re-export, drifting gif fps

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix(design-motion): app-only coverage skip, gif fps cap, early empty mask

- check: the >90% coverage skip applies only to an app frame's own surfaces
  (ungrown mask); in cards, or when --mask-grow pushes coverage over 90%,
  overflow fails with what to change (a cards capture with real overflow
  passed as 'clean (overflow not checked)' after a large grow)
- export: --gif-fps/--small-fps capped at 50 (GIF delays are 1/100 s)
- compare resolves its paths (a colon in a relative path read as a protocol)
- capture: MOTION_MASK_EMPTY is checked before the first frame
- tests: cards vs app full-frame mask, fps cap, no frames on an empty mask

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* fix(design-motion): seek story transitions from their own frame

- capture: an animation first seen in a frame where window.__mark did not
  move (a story's class toggle) is seeked from that frame instead of the
  last mark, so it eases in the export instead of popping ~100 ms ahead
- encode: an empty numeric option is refused instead of read as 0
- figma: only fill a file key and node id that look like Figma's
- tests: class-toggled transition mid-fade at its midpoint, blank --min-db

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

* docs: PROJECT_STRUCTURE names Elaya's MIT material and licenses/MIT-elaya.txt

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>

---------

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
2026-10-27 03:04:06 +00:00

208 lines
16 KiB
TypeScript

/**
* Reviewed identifier placeholders for generated bash (CEO-12, DX-5, ENG-8).
*
* A `<placeholder>` the model fills in may appear in a command only when it is
* listed here. Free text (bodies, titles, messages, briefs, prompts, error
* output, reviewer or diff text) is never listed: it reaches a command only as
* the contents of a `mktemp` file the agent writes with its file-write tool.
*
* Each entry names the grammar a value must match before the skill uses it; a
* value that fails is not used. `quoted` entries may appear only inside single
* or double quotes (or a quoted heredoc), and their grammar excludes every
* character that can end or expand those quotes: `'`, `"`, backtick, `$`, `\`
* and newline. Every other entry may appear unquoted, so its grammar also
* excludes `;|&()<>?[]{}!#` and, unless it is a `list`, whitespace and `*`. test/generated-bash-placeholders
* .test.ts proves each grammar rejects those characters.
*/
/** `list`: a space-separated list where word splitting is intended (spaces, and `*` globs, allowed). */
export interface IdentifierGrammar { grammar: RegExp; what: string; quoted?: true; list?: true }
const NUM = /^[0-9]+$/;
const ID = /^[A-Za-z0-9][A-Za-z0-9._-]*$/;
/** Shell-safe subset of git ref names; the posting skills also run `git check-ref-format --branch`. */
const REF = /^[\p{L}\p{N}_][\p{L}\p{N}._/@+-]*$/u;
const PATH = /^[\p{L}\p{N}._/@+:,%=~-]+$/u;
/** Space-separated path lists (word splitting intended); `*` may glob. */
const PATHS = /^[\p{L}\p{N}._/@+:,%=~* -]+$/u;
/** Inside quotes only: anything that cannot end or expand the quotes. */
const QUOTED = /^[^'"`$\\\n]+$/;
const DATE = /^[0-9]{4}-[0-9]{2}-[0-9]{2}$/;
const NUMBER = /^-?[0-9]+(?:\.[0-9]+)?$/;
const URL = /^https?:\/\/[^'"`$\\\s<>]+$/;
const oneOf = (...alts: string[]) => new RegExp(`^(?:${alts.map(a => a.replace(/[.*+?^${}()|[\]\\/-]/g, '\\$&')).join('|')})$`);
export const IDENTIFIER_PLACEHOLDERS: Record<string, IdentifierGrammar> = {
// Enumerations: the value is one of the listed literals.
'<approval|clarification|routing|cherry-pick|feedback-loop>': { grammar: oneOf('approval', 'clarification', 'routing', 'cherry-pick', 'feedback-loop'), what: 'question category' },
'<one-way|two-way>': { grammar: oneOf('one-way', 'two-way'), what: 'door type' },
'<never-ask|always-ask|ask-only-for-one-way>': { grammar: oneOf('never-ask', 'always-ask', 'ask-only-for-one-way'), what: 'question preference' },
'<pref>': { grammar: oneOf('never-ask', 'always-ask', 'ask-only-for-one-way'), what: 'question preference' },
'<clean|flagged>': { grammar: oneOf('clean', 'flagged'), what: 'semantic review outcome' },
'<N|null>': { grammar: /^(?:[0-9]+(?:\.[0-9]+)?|null)$/, what: 'health score or null' },
'<platform>': { grammar: oneOf('github', 'gitlab', 'unknown'), what: 'detected git platform' },
'<effort-level>': { grammar: /^[a-z]*$/, what: "the request's /codex --effort level, or empty for none (the probe validates the level)", quoted: true },
// Ids, keys and numbers.
'<id>': { grammar: ID, what: 'question or record id (kebab-case)' },
'<key>': { grammar: ID, what: 'option key' },
'<summary-slug>': { grammar: ID, what: 'question summary as a kebab-case slug' },
'<comment-id>': { grammar: NUM, what: 'GitHub comment id from the fetched JSON' },
'<opened-at>': { grammar: NUM, what: 'EARLY_PR_OPENED_AT epoch seconds printed by gstack-greptile-early open' },
'<pr-number>': { grammar: NUM, what: 'PR/MR number from the open-PR lookup or the early-PR create output' },
'<new-version>': { grammar: /^[0-9]+(?:\.[0-9]+)*$/, what: 'NEW_VERSION from the version bump (dot-separated digits)' },
'<issue-number>': { grammar: /^[0-9]*$/, what: 'filed issue number, or empty when none was filed' },
'<check-number>': { grammar: NUM, what: 'canary check number' },
// /eval-plan (plan E1): the pilot's ledger inputs.
'<cap-usd>': { grammar: NUMBER, what: 'spend cap in USD' },
'<total-items>': { grammar: NUM, what: 'items in the full eval run' },
'<workers>': { grammar: NUM, what: 'concurrent eval workers' },
'<attempt-id>': { grammar: ID, what: 'PILOT_ATTEMPT id printed by pilot start' },
'<usd|unknown>': { grammar: /^(?:[0-9]+(?:\.[0-9]+)?|unknown)$/, what: 'actual cost in USD from the provider usage field, or unknown' },
'<run-id>': { grammar: NUM, what: 'GitHub Actions run id' },
'<PID>': { grammar: NUM, what: 'process id printed by an earlier block' },
'<retained-owner-token>': { grammar: ID, what: 'freeze owner token printed by acquire' },
'<RUN_ID>': { grammar: ID, what: 'run id printed by Setup' },
'<RUN_ID from Setup>': { grammar: ID, what: 'run id printed by Setup' },
'<PHASE>': { grammar: oneOf('ceo', 'design', 'dx', 'eng'), what: 'autoplan phase' },
'<VARIANT>': { grammar: /^[A-Z]$/, what: 'variant letter' },
'<SCREEN>': { grammar: ID, what: 'screen name slug' },
'<screen-name>': { grammar: ID, what: 'screen name slug' },
'<page-name>': { grammar: ID, what: 'page name slug' },
'<name>': { grammar: ID, what: 'slug' },
'<slug>': { grammar: ID, what: 'slug' },
'<dimension>': { grammar: ID, what: 'design dimension slug' },
'<dim>': { grammar: ID, what: 'profile dimension name' },
// /design-motion (GSTA-92 plan item 15): capture and export arguments the skill's plan fixes.
'<frame-size>': { grammar: /^[0-9]+x[0-9]+$/, what: 'design frame size in CSS pixels, WxH' },
'<cycle-seconds>': { grammar: NUMBER, what: 'loop cycle length in seconds' },
'<app|cards>': { grammar: oneOf('app', 'cards'), what: 'motion layout: joined app surfaces or separate cards' },
'<hex-color>': { grammar: /^#(?:[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/, what: 'page background colour as hex', quoted: true },
'<figma-file-key>': { grammar: ID, what: 'Figma file key from the link' },
'<figma-node-id>': { grammar: /^[0-9]+[:-][0-9]+$/, what: 'Figma node id from the link' },
'<new_value>': { grammar: NUMBER, what: 'profile dimension value' },
'<Q1_VALUE>': { grammar: NUMBER, what: 'profile answer value' },
'<Q2_VALUE>': { grammar: NUMBER, what: 'profile answer value' },
'<Q3_VALUE>': { grammar: NUMBER, what: 'profile answer value' },
'<Q4_VALUE>': { grammar: NUMBER, what: 'profile answer value' },
'<Q5_VALUE>': { grammar: NUMBER, what: 'profile answer value' },
'<actual-harness>': { grammar: oneOf('claude', 'codex'), what: 'harness name' },
'<suite>': { grammar: ID, what: 'eval suite name' },
'<picked-models>': { grammar: /^[A-Za-z0-9._:,-]+$/, what: 'comma-separated model ids' },
'<github-username>': { grammar: /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/, what: 'GitHub login' },
'<gitlab-username>': { grammar: /^[A-Za-z0-9_][A-Za-z0-9_.-]*$/, what: 'GitLab username' },
// Dates.
'<today>': { grammar: DATE, what: 'YYYY-MM-DD' },
'<start_date>': { grammar: DATE, what: 'YYYY-MM-DD' },
'<since>': { grammar: /^[0-9]+[dhwm]$|^[0-9]{4}-[0-9]{2}-[0-9]{2}$/, what: 'retro window (7d, 24h, 2w) or date' },
'<window>': { grammar: /^[0-9]+[dhwm]$/, what: 'retro window (7d, 24h, 2w)' },
'<window-days>': { grammar: NUM, what: 'retro window in whole days' },
// Git refs. Branch names from remote data travel as data (ENG-8), never through this list.
'<base>': { grammar: REF, what: 'base branch detected by the skill' },
'<default>': { grammar: REF, what: 'default branch detected by the skill' },
'<diff-base>': { grammar: REF, what: 'diff base ref detected by the skill' },
'<detected-base-branch>': { grammar: REF, what: 'base branch detected by the skill' },
'<branch-name>': { grammar: REF, what: 'current branch (git branch --show-current)' },
'<prior-review-commit>': { grammar: /^[0-9a-f]{7,40}$/, what: 'commit sha' },
// Paths printed by earlier gstack blocks or chosen by the skill.
'<body-file-name>': { grammar: ID, what: 'basename of the mktemp body file printed by the previous block' },
'<title-file-name>': { grammar: ID, what: 'basename of the mktemp title file printed by the previous block' },
'<gate-file-name>': { grammar: ID, what: 'basename of the mktemp gate-command file printed by the previous block (/eval-plan price-gate)' },
'<reply-file-name>': { grammar: ID, what: 'basename of the mktemp reply file printed by the previous block' },
'<redact-file-name>': { grammar: ID, what: 'basename of the mktemp draft file printed by the free-text block' },
'<approach-file-name>': { grammar: ID, what: 'basename of the mktemp approach file printed by the free-text block' },
'<greptile-dir>': { grammar: PATH, what: 'mktemp directory printed by the Greptile fetch block' },
'<SNAPSHOT_TOOL>': { grammar: QUOTED, what: 'snapshot tool path printed by autoplan', quoted: true },
'<SOURCE_PLAN>': { grammar: QUOTED, what: 'plan path', quoted: true },
'<ACTIVE_PLAN>': { grammar: QUOTED, what: 'plan path', quoted: true },
'<RESTORE_PATH>': { grammar: QUOTED, what: 'restore path printed by autoplan', quoted: true },
'<methodologyPath>': { grammar: QUOTED, what: 'methodology path printed by autoplan', quoted: true },
'<CEO_STEP0_CHECKPOINT>': { grammar: QUOTED, what: 'checkpoint path printed by autoplan', quoted: true },
'<AMENDMENT_CHECKPOINT>': { grammar: QUOTED, what: 'checkpoint path printed by autoplan', quoted: true },
'<prepared-prompt-file>': { grammar: QUOTED, what: 'prompt file path printed by the prepare step', quoted: true },
'<run-dir>': { grammar: QUOTED, what: 'run directory printed by an earlier block', quoted: true },
'<ASIDE_DIR>': { grammar: QUOTED, what: 'Aside output directory printed by an earlier block', quoted: true },
'<ASIDE_DIR or $_TMP>': { grammar: QUOTED, what: 'Aside output directory printed by an earlier block', quoted: true },
'<REPORT_DIR from Setup>': { grammar: QUOTED, what: 'report directory printed by Setup', quoted: true },
'<the FILE path printed above>': { grammar: QUOTED, what: 'file path printed by the previous block', quoted: true },
'<install dir from Step 2>': { grammar: QUOTED, what: 'install directory printed by Step 2', quoted: true },
'<APPROVED path>': { grammar: QUOTED, what: 'approved design path', quoted: true },
'<first path from the printed saved list>': { grammar: QUOTED, what: 'image path printed by the design tool', quoted: true },
'<design-path>': { grammar: QUOTED, what: 'design doc path', quoted: true },
'<review-directory>': { grammar: QUOTED, what: 'review directory printed by mktemp', quoted: true },
'<round-1.json>': { grammar: QUOTED, what: 'round file path', quoted: true },
'<round-1.json if present>': { grammar: QUOTED, what: 'round file path', quoted: true },
'<round-2.json if present>': { grammar: QUOTED, what: 'round file path', quoted: true },
'<round-3.json if present>': { grammar: QUOTED, what: 'round file path', quoted: true },
'<source-dir>': { grammar: QUOTED, what: 'app source directory', quoted: true },
'<user-provided-path>': { grammar: QUOTED, what: 'directory the user named', quoted: true },
'<detected-directory>': { grammar: QUOTED, what: 'directory detected by the skill', quoted: true },
'<staged>': { grammar: QUOTED, what: 'staged HTML path', quoted: true },
'<stagedDir>': { grammar: QUOTED, what: 'staged directory printed by an earlier block', quoted: true },
'<outdir>': { grammar: PATH, what: 'output directory' },
'<path>': { grammar: PATH, what: 'repository path from discovery' },
'<plan-path>': { grammar: PATH, what: 'bound plan file path' },
'<sketch-dir>': { grammar: PATH, what: 'sketch directory printed by an earlier block' },
'<path-to-finalized.html>': { grammar: PATH, what: 'finalized HTML path' },
'<path-to-page.html>': { grammar: PATH, what: 'saved page HTML path' },
'<finalized.html>': { grammar: PATH, what: 'finalized HTML path' },
'<motion-dir>': { grammar: PATH, what: 'run directory printed by the /design-motion Step 0 MOTION_DIR line' },
'<approved-variant.png>': { grammar: PATH, what: 'approved variant image path' },
'<failing-test-file>': { grammar: PATH, what: 'test file path' },
'<source-file-under-test>': { grammar: PATH, what: 'source file path' },
'<affected-files>': { grammar: PATHS, what: 'space-separated file paths', list: true },
'<only-changed-files>': { grammar: PATHS, what: 'space-separated file paths', list: true },
'<only-verified-source-and-regression-files>': { grammar: PATHS, what: 'space-separated file paths', list: true },
'<scope>': { grammar: PATHS, what: 'path or glob', list: true },
'<project eval command>': { grammar: /^[A-Za-z0-9._/@+:,%=~ -]+$/, what: 'the eval command the project documents (words and flags only)', list: true },
// Quoted-only values: URLs, selectors, search words and commands.
'<url>': { grammar: URL, what: 'http(s) URL', quoted: true },
'<page-url>': { grammar: URL, what: 'http(s) URL', quoted: true },
'<base-url>': { grammar: URL, what: 'http(s) URL', quoted: true },
'<target-url>': { grammar: URL, what: 'http(s) URL', quoted: true },
'<affected-url>': { grammar: URL, what: 'http(s) URL', quoted: true },
'<TARGET_URL>': { grammar: URL, what: 'http(s) URL', quoted: true },
'<site>': { grammar: URL, what: 'http(s) URL', quoted: true },
'<selector>': { grammar: QUOTED, what: 'CSS selector', quoted: true },
'<row-selector>': { grammar: QUOTED, what: 'CSS selector', quoted: true },
'<title-selector>': { grammar: QUOTED, what: 'CSS selector', quoted: true },
'<your-keyword>': { grammar: QUOTED, what: 'search words', quoted: true },
'<keywords>': { grammar: QUOTED, what: 'search words', quoted: true },
'<keyword1>': { grammar: QUOTED, what: 'search word', quoted: true },
'<keyword2>': { grammar: QUOTED, what: 'search word', quoted: true },
'<keyword3>': { grammar: QUOTED, what: 'search word', quoted: true },
'<tests>': { grammar: QUOTED, what: 'test command', quoted: true },
'<vitest>': { grammar: QUOTED, what: 'test command', quoted: true },
// External-host renders: Claude Code outside voice and the gbrain page save.
'<gstack-runtime-root>': { grammar: QUOTED, what: 'installed runtime path', quoted: true },
'<fresh-or-resume>': { grammar: oneOf('fresh', 'resume'), what: 'Claude Code session mode' },
'<feature-slug>': { grammar: ID, what: 'feature slug for the gbrain page' },
'<page-file>': { grammar: QUOTED, what: 'mktemp page file path printed by the previous command', quoted: true },
// A3 group 1 (Aside prompts, design briefs, design approval feedback): mktemp basenames.
'<prompt-file-name>': { grammar: ID, what: 'basename of the mktemp prompt file (Aside, Codex, benchmark) printed by the previous block' },
'<brief-file-name>': { grammar: ID, what: 'basename of the mktemp design brief file printed by the free-text block' },
'<feedback-file-name>': { grammar: ID, what: 'basename of the mktemp design feedback file printed by the previous block' },
// A3 group 2 (Codex prompts and misc): mktemp basenames, mode switches,
// the benchmark prompt path and the sync-gbrain orchestrator flags.
'<focus-file-name>': { grammar: ID, what: 'basename of the mktemp Codex review focus file printed by the free-text block' },
'<receipt line>': { grammar: /^OFFICE_HOURS_VERDICT round=[1-3] sha256=[0-9a-f]{64} path=\/[^'"`$\\\n]+$/, what: 'office-hours reviewer verdict receipt (one line)', quoted: true },
'<body-top-file-name>': { grammar: ID, what: 'basename of the mktemp PR body draft (through ## Documentation) printed by the free-text block' },
'<body-rest-file-name>': { grammar: ID, what: 'basename of the mktemp PR body draft (after the documentation section) printed by the free-text block' },
'<rejected-file-name>': { grammar: ID, what: 'basename of the mktemp rejected-test list printed by the free-text block' },
'<new|resume>': { grammar: oneOf('new', 'resume'), what: 'Codex consult session mode' },
'<prompt-path>': { grammar: QUOTED, what: 'benchmark prompt file path', quoted: true },
'<user-args>': {
grammar: /^(?:(?:--(?:incremental|full|dry-run|quiet|no-code|no-memory|no-brain-sync|code-only|dream|no-dream|allow-reclone|prune-gone-worktrees)|--sources [a-z][a-z0-9_,-]*)(?: (?=-)|$))*$/,
what: 'gstack-gbrain-sync flags (space-separated; --sources takes one comma-separated type list)',
list: true,
},
};