mirror of
https://github.com/garrytan/gstack.git
synced 2026-09-16 18:05:31 +02:00
* feat: add a restricted and supervised Claude Code runner Preserve configured authentication and models while enforcing tool access, strict completion JSON, bounded output and process cleanup. Cover argv, failure handling, session metadata and Windows process containment. * feat: route outside reviews by harness and migrate wrapper installs Use Claude Code from Codex and Codex from other supported hosts, with shared invocation rendering, positive gate validation and per-phase provenance. Rename /claude to /claude-code, repair managed shared and copied installations safely, and generate native Kiro skills. Add installed-workflow, failure-injection and live cross-harness regression coverage. * test: recognize CEO mode labels without terminal spacing The paid workflow rendered SCOPEEXPANSION at option 4, but its driver required a literal space. Match the leading mode title without cursor-spacing artifacts and ignore adjacent preview text. Preserve missing-target failures and downstream posture assertions. * test: isolate plan-count fixtures before starting review workflows Seed the complete test plan in a private git repository before launching Claude, so a bare slash command cannot review the live workspace while a delayed fixture message remains queued. Preserve count thresholds, parsers and budgets. Add initial-context and installed-discovery tests, and retain startup/terminal diagnostics on failed evaluations. * test: stabilize review fixtures and Claude eval startup Preserve source boundaries in workflow judge inputs, isolate CEO mode plans, and wait for interactive trust input readiness. Keep startup failure evidence and retain existing models, budgets, and assertions. Co-Authored-By: OpenAI Codex <noreply@openai.com> * test: classify collapsed review modes and isolate seeded findings Keep review questions out of the setup count when terminal cursor positioning removes spaces. State existing webhook safeguards so the five-finding control measures its seeded defects without accidental extra security and concurrency gaps. Preserve question bands and the paired control. Co-Authored-By: OpenAI Codex <noreply@openai.com> * test: isolate browser daemon state across free shards Co-Authored-By: OpenAI Codex <noreply@openai.com> * test: stabilize native review counting and interactive navigation Co-Authored-By: OpenAI Codex <noreply@openai.com> * chore: prepare v1.82.0.0 release Co-Authored-By: OpenAI Codex <noreply@openai.com> * fix: eliminate browser and process-cleanup test flakes Pin every CI surface to Bun 1.4.0 to avoid extra-stdio finalizers closing reused live sockets. Add an isolated GC/listener regression that fails on Bun 1.3.13, and prevent coordinated rollback to an affected CI runtime. Check renderer cleanup against the render's own staging directory so concurrent renders cannot invalidate the assertion. Make the no-pgrep process-tree walk tolerate disappearing /proc entries, and synchronize its test fixture through child readiness and pipe EOF instead of sleeps. Validation: 9,157 passed, 31 skipped, zero failures across 556 files with retries disabled. Build, all-host generation freshness, and skill checks passed. All three races have failing-before/passing-after regressions. * fix: count completed native review questions in evals * fix: drive review navigation from confirmed native choices * fix: require complete section-loading eval reports * test: isolate telemetry HTTP transport from local assertions * fix: keep review input on the active native question * test: let tunnel revocation daemon choose an available port * test: allocate available ports for pairing and watchdog fixtures * fix: stabilize planning eval navigation and phase reporting * test: isolate installed runtime paths in planning evals * test: stabilize review evidence and concurrent refresh fixtures * fix: resolve design findings before editing the plan * fix: honor and persist disabled outside plan reviews * fix: preserve planning decisions and terminal evidence Load installed host reviews at autoplan phase entry and wait for completed reviewers and saved artifacts. Reuse approved remedies while preserving individual finding decisions. Drive interactive evals from the current terminal viewport, bind native questions across scrolling, and require complete native report evidence. Cover captured stale menus, permission lifecycles, setup classification, and disabled-review tool availability with deterministic regressions. Advance release metadata and the upgrade migration to the unclaimed 1.83.0.0 slot. * fix: drive native review questions and preserve current plans Use the native single-choice keyboard protocol and current terminal viewport, with per-question navigation inside packets and completed-call coverage. Keep permissions, multi-select menus, and Submit controls distinct. Send Autoplan reviewers the amended implementation plan, keep its review record separate, and supply retained application contracts in the chain fixture. Clarify individual DevEx decisions and complete CEO fix options; use one active plan destination for the section-loading report. * fix: preserve complete plan-review decisions * fix: recognize native plan dialogs and reviewer controls * fix: preserve review decisions and phase completion * fix: recognize completed reviews without losing findings * fix: preserve review continuity and native eval completion * test: fix native review completion and eval retry isolation * test: handle native review menus and complete eval fixtures * test: fix native review setup, completion, and isolation failures * test: limit native skill discovery to runtime assets * fix: bind Autoplan reviews to full ordered phase inputs * test: fix planning eval routing, counting, and timeout handling * chore: advance queued release to v1.84.0.0 * fix: preserve complete review inputs and planning decisions * fix: reconcile review approvals and preserve phase obligations * fix: preserve review obligations and unblock eval permissions Carry recorded Autoplan requirements into blind phase inputs, require Eng review approvals before exit, and exercise combined asynchronous flows in CEO reviews. Correct native finding and handoff classification and unblock repeated report edits using scoped request identities. * fix: retain plan requirements and complete native review dialogs * fix: complete native review prompts and retain plan references * fix: preserve review inputs and classify native eval evidence * fix: check competing completion orders in CEO reviews * fix: recognize review decisions and require phase methodology Require the current phase methodology before Autoplan snapshots. Correct substantive decision, closed handoff, and cache-finding classification, and honor the recommended implementation approach in native review dialogs. Add captured-transcript regressions without changing review thresholds, provider models, retries, or deadlines. * test: bind native review decisions and close completed handoffs * fix: complete review dialogs and verify methodology delivery * fix: preserve review evidence and unblock native eval prompts * fix: handle native review question completions * fix: recognize native review narration and controls * fix: count native review decisions and isolate eval fixtures * test: verify seeded review coverage and current artifact permissions * test: isolate model and brain-aware skill renders * fix: repair native workflow evaluation and clarify review steps * fix: stabilize workflow eval evidence and review guidance * test: repair native workflow observation and fixture isolation * fix: recognize completed workflow evidence and owned skill reads * test: repair seeded workflow delivery and completion evidence * test: recognize current review evidence across native forms * test: handle native review variants and permission redraws * fix: honor review preferences and recognize native eval evidence * test: recognize completed review decisions and queued permissions * test: match current review contracts and partial-line edits * test: recognize completed workflow evidence and bounded human waits * fix: preserve review entry gates and native eval interactions * fix: recognize native workflow evidence and preserve review gates * test: recognize current review evidence and preconfigure workflow fixtures * test: recognize completed review findings and scoped artifact permissions * fix: stabilize native workflow review and permission evidence * fix: recognize current review evidence and scoped edit confirmations Clarify Design and engineering review entry instructions and Design scoring. Recognize required legacy coverage and public Autoplan completion recaps. Bind the pending Edit confirmation to its exact file, ordered digest, and one-request approval when a preceding command display remains visible. Keep reviews within their existing size limits and preserve scope gates when extracting workflow fixtures from either supported preamble header. Keep failure outcomes, review thresholds, provider choices, and eval budgets. * fix: recover review workflow progress and eval evidence * fix: recognize valid review evidence and scope selection * test: fix review evidence parsing and repeated artifact prompts * test: recognize valid review decisions and pending native cards * fix(plan-eng-review): keep final navigation consistent with approved tasks * test: recognize valid review evidence and bind legacy diff requests * fix: stabilize review eval evidence and harness repair guidance * docs: update project documentation for v1.85.0.0 Co-Authored-By: OpenAI Codex <noreply@openai.com> * test: fix Windows CI fixtures and credential scan Rebase captured JSON values and filesystem evidence using the appropriate path convention. Compile native fake CLIs on Windows and synchronize pipe holder readiness, with cleanup retained when assertions fail. Assemble synthetic credential fixtures at runtime so the added-line scan keeps enforcing the same gate without flagging its own rejection controls. Discover generated skills directly for the empty-find regression check, avoiding a recursive scan through saved evaluation artifacts and dependencies. * fix: preserve source renders on Windows Compare canonical generator paths using native separators so an output sidecar pointing at the source cannot overwrite its skill or metadata. Keep the regression fixture isolated from the real checkout and expose freshness diagnostics before asserting subprocess status. Detach Windows drain-test pipe holders from the fake provider's automatic child cleanup while preserving the enclosing runner job and its assertions. * fix: clarify outside review fallback and CEO decisions Render one applicable own-harness fallback path and retain native review, disabled policy, and missing-coverage semantics. Align report field names and mode labels, and make the existing per-cut scope approval explicit. Regenerate skill outputs and keep the workflow judge's model, thresholds, and retry policy unchanged. * chore: move release to free version slot (v1.86.0.0) PR #2852 now claims v1.85.0.0. Align the release metadata and rename migration so upgrades from that version still receive it. Co-Authored-By: OpenAI Codex <noreply@openai.com> * fix: include engineering review prerequisites and restore branch context * fix: recognize coverage diagrams and clarify design review instructions * fix: preserve file identities and join Windows test processes --------- Co-authored-by: OpenAI Codex <noreply@openai.com>
175 lines
11 KiB
TypeScript
175 lines
11 KiB
TypeScript
// ─── Shared Design Constants ────────────────────────────────
|
|
|
|
import { DESIGN_SLOP_CATALOG } from '../../lib/design-catalog';
|
|
|
|
/**
|
|
* gstack's AI slop anti-patterns — shared between DESIGN_METHODOLOGY and DESIGN_HARD_RULES.
|
|
*
|
|
* Derived from the typed catalog in lib/design-catalog.ts: the 11 entries flagged
|
|
* `legacyBlacklist`, prose verbatim, in catalog order. Overused fonts live there
|
|
* too (OVERUSED_FONTS_DISPLAY), role-scoped: banned as the display voice, several
|
|
* still fine as body/UI on an Operate or Read surface.
|
|
*/
|
|
export const AI_SLOP_BLACKLIST: string[] = DESIGN_SLOP_CATALOG
|
|
.filter(e => e.legacyBlacklist)
|
|
.map(e => e.prose);
|
|
|
|
/** OpenAI hard rejection criteria (from "Designing Delightful Frontends with GPT-5.4", Mar 2026) */
|
|
export const OPENAI_HARD_REJECTIONS = [
|
|
'Generic SaaS card grid as first impression',
|
|
'Beautiful image with weak brand',
|
|
'Strong headline with no clear action',
|
|
'Busy imagery behind text',
|
|
'Sections repeating same mood statement',
|
|
'Carousel with no narrative purpose',
|
|
'App UI made of stacked cards instead of layout',
|
|
];
|
|
|
|
/** OpenAI litmus checks — 7 yes/no tests for cross-model consensus scoring */
|
|
export const OPENAI_LITMUS_CHECKS = [
|
|
'Brand/product unmistakable in first screen?',
|
|
'One strong visual anchor present?',
|
|
'Page understandable by scanning headlines only?',
|
|
'Each section has one job?',
|
|
'Are cards actually necessary?',
|
|
'Does motion improve hierarchy or atmosphere?',
|
|
'Would design feel premium with all decorative shadows removed?',
|
|
];
|
|
|
|
/**
|
|
* Web-search flag for every codex invocation (#2525).
|
|
*
|
|
* codex >=0.144 deprecated the legacy `--enable`-based web_search_cached
|
|
* spelling (web search is on by default; the deprecation notice says to set
|
|
* `web_search` to "live", "indexed", "cached", or "disabled" at the top
|
|
* level), and `--enable <FEATURE>` now means `-c features.<name>=true`
|
|
* (verified on 0.147.0), so the legacy spelling is headed for hard
|
|
* rejection. This is the ONE source
|
|
* of truth: resolvers interpolate it directly and templates reference it via
|
|
* the {{CODEX_WEB_SEARCH_FLAG}} token — never write the flag inline.
|
|
*
|
|
* Semantics note: unlike the legacy flag (which yielded to an existing
|
|
* top-level `web_search` in config.toml), the -c form explicitly overrides
|
|
* it. Deliberate: gstack wants deterministic cached search for review
|
|
* invocations. Native `codex review` disables web search regardless of
|
|
* configuration, so on that path the flag is a harmless no-op.
|
|
*/
|
|
export const CODEX_WEB_SEARCH_FLAG = `-c 'web_search="cached"'`;
|
|
|
|
/**
|
|
* Default model for gstack-owned Codex invocations.
|
|
*
|
|
* Conductor's current Codex CLI default may lag the frontier model exposed to
|
|
* agents, so gstack pins its own default and lets users override it per shell
|
|
* with GSTACK_CODEX_MODEL or per invocation with an explicit `-c model=...`.
|
|
* The -c form is accepted by both `codex exec` and `codex review`.
|
|
*/
|
|
export const CODEX_FRONTIER_MODEL = 'gpt-6-astra';
|
|
export const CODEX_MODEL_CONFIG_FLAG = `-c "model=\\"\${GSTACK_CODEX_MODEL:-${CODEX_FRONTIER_MODEL}}\\""`;
|
|
// Native review prefers review_model over model when the user has pinned it.
|
|
export const CODEX_REVIEW_MODEL_CONFIG_FLAG = `${CODEX_MODEL_CONFIG_FLAG} -c "review_model=\\"\${GSTACK_CODEX_MODEL:-${CODEX_FRONTIER_MODEL}}\\""`;
|
|
|
|
/**
|
|
* Shared Codex error handling block for resolver output.
|
|
* Used by ADVERSARIAL_STEP, CODEX_PLAN_REVIEW, CODEX_SECOND_OPINION,
|
|
* DESIGN_OUTSIDE_VOICES, DESIGN_REVIEW_LITE, DESIGN_SKETCH.
|
|
*/
|
|
export function codexErrorHandling(feature: string): string {
|
|
return `**Error handling:** All errors are non-blocking — the ${feature} is informational.
|
|
- Auth failure (stderr contains "auth", "login", "unauthorized"): note and skip
|
|
- Timeout: note timeout duration and skip
|
|
- Empty response: note and skip
|
|
On any error: continue — ${feature} is informational, not a gate.`;
|
|
}
|
|
|
|
/**
|
|
* Shared Codex preflight bash block — the single source of truth for deciding
|
|
* whether a Codex review pass should run. Used by ADVERSARIAL_STEP,
|
|
* CODEX_PLAN_REVIEW, and CODEX_DOC_REVIEW so install/auth/config detection
|
|
* lives in exactly one place.
|
|
*
|
|
* Emits ONE self-contained bash block (the caller must place it in a single
|
|
* fenced block — CLAUDE.md: each block is a fresh shell, so functions sourced
|
|
* here do NOT persist to later blocks). It:
|
|
* 1. reads the `codex_reviews` master switch,
|
|
* 2. sources `gstack-codex-probe`,
|
|
* 3. runs `command -v codex` (literal — keeps the e2e substring assertion),
|
|
* then `_gstack_codex_auth_probe`, then `_gstack_codex_version_check`,
|
|
* 4. logs the relevant `_gstack_codex_log_event` for each non-ready outcome,
|
|
* 5. sets ONE canonical mode var and echoes `CODEX_MODE: <mode>` so the agent
|
|
* gates later blocks on the echoed value.
|
|
*
|
|
* Mode values: `disabled` (config off) | `not_installed` | `not_authed` | `ready`.
|
|
* The path is host-rewritten at gen-skill-docs time (pathRewrites), so the
|
|
* literal `~/.claude/skills/gstack` is correct here and becomes `$GSTACK_ROOT`
|
|
* etc. for non-Claude hosts.
|
|
*
|
|
* `disabledBehavior` controls the `disabled`-mode interpretation, which is the
|
|
* one branch that legitimately differs per caller (D1):
|
|
* - `skip-all` (plan / doc reviews): disabled means no extra review step at
|
|
* all — skip the section, no Claude fallback.
|
|
* - `codex-only` (diff adversarial): disabled gates only the Codex passes; the
|
|
* free Claude adversarial subagent still runs.
|
|
*/
|
|
export function codexPreflight(opts: { modeVar?: string; disabledBehavior: 'skip-all' | 'codex-only' }): string {
|
|
const m = opts.modeVar ?? '_CODEX_MODE';
|
|
const disabledLine = opts.disabledBehavior === 'codex-only'
|
|
? 'Skip the Codex passes only; the Claude adversarial subagent below STILL runs (it is free and fast). Print: "Codex passes skipped (codex_reviews disabled) — running Claude adversarial only."'
|
|
: 'Skip this section entirely; do NOT fall back to a Claude subagent — disabled means no extra review step. Print: "Codex review skipped (codex_reviews disabled). Re-enable: `gstack-config set codex_reviews enabled`."';
|
|
return `\`\`\`bash
|
|
# Codex preflight: one block (functions sourced here don't persist to later blocks).
|
|
_TEL=$(~/.claude/skills/gstack/bin/gstack-config get telemetry 2>/dev/null || echo off)
|
|
_CODEX_CFG=$(~/.claude/skills/gstack/bin/gstack-config get codex_reviews 2>/dev/null || echo enabled)
|
|
source ~/.claude/skills/gstack/bin/gstack-codex-probe 2>/dev/null || true
|
|
if [ "$_CODEX_CFG" = "disabled" ]; then
|
|
${m}="disabled"
|
|
# Running-under-Codex presence probe (#2519): a live Codex session exports
|
|
# CODEX_THREAD_ID / CODEX_SANDBOX into every shell it spawns (verified
|
|
# against a live \`codex exec 'env | grep -i codex'\` capture, codex 0.147.0).
|
|
# Nested codex spawns from inside a Codex host multiply token burn
|
|
# (observed: one /review = 15M tokens). A stale own-harness artifact must stop.
|
|
elif { [ -n "\${CODEX_THREAD_ID:-}" ] || [ -n "\${CODEX_SANDBOX:-}" ] || [ "\${GSTACK_ACTIVE_HOST:-}" = codex ]; }; then
|
|
${m}="under_codex"
|
|
elif ! command -v codex >/dev/null 2>&1; then
|
|
${m}="not_installed"; _gstack_codex_log_event "codex_cli_missing" 2>/dev/null || true
|
|
elif ! _gstack_codex_auth_probe >/dev/null 2>&1; then
|
|
${m}="not_authed"; _gstack_codex_log_event "codex_auth_failed" 2>/dev/null || true
|
|
else
|
|
# Capture the probe's code: 2 means the CLI cannot execute at all, which is a
|
|
# different problem (and a different fix) from a model the account can't use.
|
|
_gstack_codex_model_probe; _CODEX_MP=$?
|
|
if [ "$_CODEX_MP" -eq 2 ]; then
|
|
${m}="broken_install"
|
|
elif [ "$_CODEX_MP" -ne 0 ]; then
|
|
${m}="model_unusable"
|
|
else
|
|
${m}="ready"; _gstack_codex_version_check 2>/dev/null || true
|
|
fi
|
|
fi
|
|
echo "CODEX_MODE: $${m}"
|
|
\`\`\`
|
|
|
|
Branch on the echoed \`CODEX_MODE\`:
|
|
- **\`disabled\`** — the user turned Codex reviews off (\`codex_reviews=disabled\`). ${disabledLine}
|
|
- **\`not_installed\`** — Codex CLI absent. Print: "Codex not installed — falling back to a Claude subagent (fresh context, but the same harness; model identity is unknown). Install Codex for an actual outside-model read: \`npm install -g @openai/codex\`." Fall back to the Claude subagent path.
|
|
- **\`under_codex\`** — stale artifact selected its own harness. Print: "Codex outside review unavailable: harness mismatch; no outside process started. Missing coverage. Repair: setup --host codex." Skip the outside invocation and follow the workflow's native-review instructions below. Conflicting inherited harness markers are not grounds to guess another provider.
|
|
- **\`not_authed\`** — installed but no credentials. Print: "Codex installed but not authenticated — falling back to a Claude subagent (same harness; model identity is unknown). Run \`codex login\` or set \`$CODEX_API_KEY\`." Fall back to the Claude subagent path.
|
|
- **\`broken_install\`** — the CLI is on PATH but cannot execute (spawn ENOENT, non-executable binary, missing vendor payload). Print: "Codex is installed but its binary cannot run — Codex passes skipped. Reinstall: \`npm install -g @openai/codex\`." Relay the probe's HINT lines and fall back to the Claude subagent path. This state exists because a missing binary used to land in the model probe's fail-open bucket and report \`ready\`, so every Codex pass was skipped silently (#2742).
|
|
- **\`model_unusable\`** — authed but the account cannot use gstack's selected Codex model (#2477: HTTP 400 on every call). Relay the probe's HINT lines, tell the user the one-line fix (set \`GSTACK_CODEX_MODEL=<supported-model>\` or pass an explicit \`-c model=...\` override), and fall back to the Claude subagent path. The ~10s round trip is cached for 1h; timeouts fail open to \`ready\`.
|
|
- **\`ready\`** — run the Codex pass below.`;
|
|
}
|
|
|
|
/**
|
|
* Canonical foreground-dispatch guidance (#497 → #2440 → third recurrence at
|
|
* /ship Step 18). Claude Code v2.1.198 made Agent-tool subagents run in the
|
|
* BACKGROUND by default; a synchronous dispatch site must pass the flag
|
|
* explicitly or the parent waits on output that never arrives. Rendered via
|
|
* {{FOREGROUND_DISPATCH_NOTE}} in section templates; resolver sites may
|
|
* interpolate it directly. Same name as the placeholder for grep-ability.
|
|
*/
|
|
/** The Claude Code release that flipped Agent-tool subagents to background-by-default (#497/#2440 class). Interpolated at every RESOLVER site; three templates carry the literal inline (autoplan/sections/ceo-phase, cso, design-shotgun) — grep 'Claude Code v2.1' when bumping. */
|
|
export const CC_BACKGROUND_DEFAULT_SINCE = 'Claude Code v2.1.198';
|
|
|
|
export const FOREGROUND_DISPATCH_NOTE =
|
|
`**Foreground required:** pass \`run_in_background: false\` on the Agent call — subagents run in the BACKGROUND by default since ${CC_BACKGROUND_DEFAULT_SINCE}. (Merely omitting the flag no longer produces a foreground run; it must be explicitly false.) The dispatch happens ONLY via the Agent tool: invoking the target as a Skill, or executing its workflow inline in your own context, is WRONG even though the skill may appear in your available-skills list — inline execution forfeits the fresh-context isolation this dispatch exists for, and the explicit flag already makes the Agent call block. (Where a step defines an inline FALLBACK, it applies only after a dispatched subagent has failed.)`;
|