/** * Reviewed identifier placeholders for generated bash (CEO-12, DX-5, ENG-8). * * A `` 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 = { // Enumerations: the value is one of the listed literals. '': { grammar: oneOf('approval', 'clarification', 'routing', 'cherry-pick', 'feedback-loop'), what: 'question category' }, '': { grammar: oneOf('one-way', 'two-way'), what: 'door type' }, '': { grammar: oneOf('never-ask', 'always-ask', 'ask-only-for-one-way'), what: 'question preference' }, '': { grammar: oneOf('never-ask', 'always-ask', 'ask-only-for-one-way'), what: 'question preference' }, '': { grammar: oneOf('clean', 'flagged'), what: 'semantic review outcome' }, '': { grammar: /^(?:[0-9]+(?:\.[0-9]+)?|null)$/, what: 'health score or null' }, '': { grammar: oneOf('github', 'gitlab', 'unknown'), what: 'detected git platform' }, '': { 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. '': { grammar: ID, what: 'question or record id (kebab-case)' }, '': { grammar: ID, what: 'option key' }, '': { grammar: ID, what: 'question summary as a kebab-case slug' }, '': { grammar: NUM, what: 'GitHub comment id from the fetched JSON' }, '': { grammar: NUM, what: 'EARLY_PR_OPENED_AT epoch seconds printed by gstack-greptile-early open' }, '': { grammar: NUM, what: 'PR/MR number from the open-PR lookup or the early-PR create output' }, '': { grammar: /^[0-9]+(?:\.[0-9]+)*$/, what: 'NEW_VERSION from the version bump (dot-separated digits)' }, '': { grammar: /^[0-9]*$/, what: 'filed issue number, or empty when none was filed' }, '': { grammar: NUM, what: 'canary check number' }, // /eval-plan (plan E1): the pilot's ledger inputs. '': { grammar: NUMBER, what: 'spend cap in USD' }, '': { grammar: NUM, what: 'items in the full eval run' }, '': { grammar: NUM, what: 'concurrent eval workers' }, '': { grammar: ID, what: 'PILOT_ATTEMPT id printed by pilot start' }, '': { grammar: /^(?:[0-9]+(?:\.[0-9]+)?|unknown)$/, what: 'actual cost in USD from the provider usage field, or unknown' }, '': { grammar: NUM, what: 'GitHub Actions run id' }, '': { grammar: NUM, what: 'process id printed by an earlier block' }, '': { grammar: ID, what: 'freeze owner token printed by acquire' }, '': { grammar: ID, what: 'run id printed by Setup' }, '': { grammar: ID, what: 'run id printed by Setup' }, '': { grammar: oneOf('ceo', 'design', 'dx', 'eng'), what: 'autoplan phase' }, '': { grammar: /^[A-Z]$/, what: 'variant letter' }, '': { grammar: ID, what: 'screen name slug' }, '': { grammar: ID, what: 'screen name slug' }, '': { grammar: ID, what: 'page name slug' }, '': { grammar: ID, what: 'slug' }, '': { grammar: ID, what: 'slug' }, '': { grammar: ID, what: 'design dimension slug' }, '': { grammar: ID, what: 'profile dimension name' }, '': { grammar: NUMBER, what: 'profile dimension value' }, '': { grammar: NUMBER, what: 'profile answer value' }, '': { grammar: NUMBER, what: 'profile answer value' }, '': { grammar: NUMBER, what: 'profile answer value' }, '': { grammar: NUMBER, what: 'profile answer value' }, '': { grammar: NUMBER, what: 'profile answer value' }, '': { grammar: oneOf('claude', 'codex'), what: 'harness name' }, '': { grammar: ID, what: 'eval suite name' }, '': { grammar: /^[A-Za-z0-9._:,-]+$/, what: 'comma-separated model ids' }, '': { grammar: /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/, what: 'GitHub login' }, '': { grammar: /^[A-Za-z0-9_][A-Za-z0-9_.-]*$/, what: 'GitLab username' }, // Dates. '': { grammar: DATE, what: 'YYYY-MM-DD' }, '': { grammar: DATE, what: 'YYYY-MM-DD' }, '': { grammar: /^[0-9]+[dhwm]$|^[0-9]{4}-[0-9]{2}-[0-9]{2}$/, what: 'retro window (7d, 24h, 2w) or date' }, '': { grammar: /^[0-9]+[dhwm]$/, what: 'retro window (7d, 24h, 2w)' }, // Git refs. Branch names from remote data travel as data (ENG-8), never through this list. '': { grammar: REF, what: 'base branch detected by the skill' }, '': { grammar: REF, what: 'default branch detected by the skill' }, '': { grammar: REF, what: 'diff base ref detected by the skill' }, '': { grammar: REF, what: 'base branch detected by the skill' }, '': { grammar: REF, what: 'current branch (git branch --show-current)' }, '': { grammar: /^[0-9a-f]{7,40}$/, what: 'commit sha' }, // Paths printed by earlier gstack blocks or chosen by the skill. '': { grammar: ID, what: 'basename of the mktemp body file printed by the previous block' }, '': { grammar: ID, what: 'basename of the mktemp title file printed by the previous block' }, '': { grammar: ID, what: 'basename of the mktemp gate-command file printed by the previous block (/eval-plan price-gate)' }, '': { grammar: ID, what: 'basename of the mktemp reply file printed by the previous block' }, '': { grammar: ID, what: 'basename of the mktemp draft file printed by the free-text block' }, '': { grammar: ID, what: 'basename of the mktemp approach file printed by the free-text block' }, '': { grammar: PATH, what: 'mktemp directory printed by the Greptile fetch block' }, '': { grammar: QUOTED, what: 'snapshot tool path printed by autoplan', quoted: true }, '': { grammar: QUOTED, what: 'plan path', quoted: true }, '': { grammar: QUOTED, what: 'plan path', quoted: true }, '': { grammar: QUOTED, what: 'restore path printed by autoplan', quoted: true }, '': { grammar: QUOTED, what: 'methodology path printed by autoplan', quoted: true }, '': { grammar: QUOTED, what: 'checkpoint path printed by autoplan', quoted: true }, '': { grammar: QUOTED, what: 'checkpoint path printed by autoplan', quoted: true }, '': { grammar: QUOTED, what: 'prompt file path printed by the prepare step', quoted: true }, '': { grammar: QUOTED, what: 'run directory printed by an earlier block', quoted: true }, '': { grammar: QUOTED, what: 'Aside output directory printed by an earlier block', quoted: true }, '': { grammar: QUOTED, what: 'Aside output directory printed by an earlier block', quoted: true }, '': { grammar: QUOTED, what: 'report directory printed by Setup', quoted: true }, '': { grammar: QUOTED, what: 'file path printed by the previous block', quoted: true }, '': { grammar: QUOTED, what: 'install directory printed by Step 2', quoted: true }, '': { grammar: QUOTED, what: 'approved design path', quoted: true }, '': { grammar: QUOTED, what: 'image path printed by the design tool', quoted: true }, '': { grammar: QUOTED, what: 'design doc path', quoted: true }, '': { grammar: QUOTED, what: 'review directory printed by mktemp', quoted: true }, '': { grammar: QUOTED, what: 'round file path', quoted: true }, '': { grammar: QUOTED, what: 'round file path', quoted: true }, '': { grammar: QUOTED, what: 'round file path', quoted: true }, '': { grammar: QUOTED, what: 'round file path', quoted: true }, '': { grammar: QUOTED, what: 'app source directory', quoted: true }, '': { grammar: QUOTED, what: 'directory the user named', quoted: true }, '': { grammar: QUOTED, what: 'directory detected by the skill', quoted: true }, '': { grammar: QUOTED, what: 'staged HTML path', quoted: true }, '': { grammar: QUOTED, what: 'staged directory printed by an earlier block', quoted: true }, '': { grammar: PATH, what: 'output directory' }, '': { grammar: PATH, what: 'repository path from discovery' }, '': { grammar: PATH, what: 'bound plan file path' }, '': { grammar: PATH, what: 'sketch directory printed by an earlier block' }, '': { grammar: PATH, what: 'finalized HTML path' }, '': { grammar: PATH, what: 'finalized HTML path' }, '': { grammar: PATH, what: 'approved variant image path' }, '': { grammar: PATH, what: 'test file path' }, '': { grammar: PATH, what: 'source file path' }, '': { grammar: PATHS, what: 'space-separated file paths', list: true }, '': { grammar: PATHS, what: 'space-separated file paths', list: true }, '': { grammar: PATHS, what: 'space-separated file paths', list: true }, '': { grammar: PATHS, what: 'path or glob', list: true }, '': { 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. '': { grammar: URL, what: 'http(s) URL', quoted: true }, '': { grammar: URL, what: 'http(s) URL', quoted: true }, '': { grammar: URL, what: 'http(s) URL', quoted: true }, '': { grammar: URL, what: 'http(s) URL', quoted: true }, '': { grammar: URL, what: 'http(s) URL', quoted: true }, '': { grammar: URL, what: 'http(s) URL', quoted: true }, '': { grammar: URL, what: 'http(s) URL', quoted: true }, '': { grammar: QUOTED, what: 'CSS selector', quoted: true }, '': { grammar: QUOTED, what: 'CSS selector', quoted: true }, '': { grammar: QUOTED, what: 'CSS selector', quoted: true }, '': { grammar: QUOTED, what: 'search words', quoted: true }, '': { grammar: QUOTED, what: 'search words', quoted: true }, '': { grammar: QUOTED, what: 'search word', quoted: true }, '': { grammar: QUOTED, what: 'search word', quoted: true }, '': { grammar: QUOTED, what: 'search word', quoted: true }, '': { grammar: QUOTED, what: 'test command', quoted: true }, '': { grammar: QUOTED, what: 'test command', quoted: true }, // External-host renders: Claude Code outside voice and the gbrain page save. '': { grammar: QUOTED, what: 'installed runtime path', quoted: true }, '': { grammar: oneOf('fresh', 'resume'), what: 'Claude Code session mode' }, '': { grammar: ID, what: 'feature slug for the gbrain page' }, '': { 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. '': { grammar: ID, what: 'basename of the mktemp prompt file (Aside, Codex, benchmark) printed by the previous block' }, '': { grammar: ID, what: 'basename of the mktemp design brief file printed by the free-text block' }, '': { 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. '': { grammar: ID, what: 'basename of the mktemp Codex review focus file printed by the free-text block' }, '': { grammar: /^OFFICE_HOURS_VERDICT round=[1-3] sha256=[0-9a-f]{64} path=\/[^'"`$\\\n]+$/, what: 'office-hours reviewer verdict receipt (one line)', quoted: true }, '': { grammar: ID, what: 'basename of the mktemp PR body draft (through ## Documentation) printed by the free-text block' }, '': { grammar: ID, what: 'basename of the mktemp PR body draft (after the documentation section) printed by the free-text block' }, '': { grammar: ID, what: 'basename of the mktemp rejected-test list printed by the free-text block' }, '': { grammar: oneOf('new', 'resume'), what: 'Codex consult session mode' }, '': { grammar: QUOTED, what: 'benchmark prompt file path', quoted: true }, '': { 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, }, };