Files
gstack/test/helpers/claude-pty-runner.ts
garrytan a1b21407eb refactor(pty): one runPtySession loop drives observation, counting and floor
test/helpers/pty/session.ts owns launch -> start -> (poll -> tick)* ->
timeout and the failure contract the three runners each hand-rolled: the
run's own error wins over capture and close errors, close always runs, owned
fixture cleanup runs last (also when launch fails). Each runner now supplies a
PtySessionPlan: its boot/command step, poll cadence (2s observation/floor
sleep; counting's output wake + 250ms coalesce), tick policy (permission
handling, native identity, terminal rules stay per runner because they differ)
and capture hooks. The runner bodies are decomposed into top-level steps so no
function exceeds 150 lines; behavior is unchanged and the fake-driver cases
from the first W4 commit pass unmodified.

The counting capture step and the native completion-summary predicate are now
named functions (countingCapture, isNativeCompletionSummary), so
plan-create-prepublication and plan-count-completion call them directly
instead of executing sliced source. The two harnesses that still execute a
sliced runner body with injected boundaries (eng-seeded-completion-ai,
plan-floor-permission) pass the PtyDriver seam instead of overriding
Date/Bun.sleep.
2026-09-30 06:15:24 +00:00

31 lines
2.8 KiB
TypeScript

/**
* Public entry point of the PTY test harness. Tests (117 importers, and the
* mock.module fixture tests) import this path; the code lives in
* test/helpers/pty/* and those modules import each other directly, never
* through this barrel. To add a helper: put it in the owning pty/ module and
* re-export it here by name. Size ratchet (c): pty/ modules stay at or under
* 800 lines and 150 lines per top-level function; this barrel must not grow.
* Moved from the former 5,047-line claude-pty-runner.ts.
*/
export { resolveClaudeBinary } from './pty/binary';
export { stripAnsi, isRejectedSlashCommand, isPlanReadyVisible, isAutoDecidedVisible, extractPlanFilePath, planFileHasDecisionsSection, TAIL_SCAN_BYTES, isPermissionDialogVisible, stripPtyResidue, isNumberedOptionListVisible } from './pty/screen';
export { selectPtyNumberedOption, launchClaudePty } from './pty/launch';
export type { ClaudePtyOptions, ClaudePtySession } from './pty/launch';
export { runPtySession, realPtyDriver } from './pty/session';
export type { PtyDriver, PtyStep, PtySessionPlan } from './pty/session';
export { logPtySnapshot, judgePtyState } from './pty/judge';
export type { PtyStateVerdict } from './pty/judge';
export { isProseAUQVisible, isScopeGateQuestionVisible, isScopeGateAutoSelectVisible, parseNumberedOptions, MODE_RE, optionsSignature, classifyVisible, COMPLETION_SUMMARY_RE, classifyPlanCountFrame, planCountSubmissionInput } from './pty/classify';
export type { ClassifyResult } from './pty/classify';
export { nativePlanCallFingerprint, planCountQuestionPhase, parseQuestionPrompt, auqFingerprint, planCountQuestionInput, matchesNativePlanQuestion, capturePlanCountQuestion, createPlanCountPermissionGuard, planCountPrerequisitePick } from './pty/auq';
export type { AskUserQuestionFingerprint, Step0BoundaryPredicate } from './pty/auq';
export { assertReviewReportAtBottom, hasNativePlanCompletion, isQuestionlessNativePlanExit, evaluateOwnedNativePlanTerminal, hasNativePlanTerminal, assertReportAtBottomIfPlanWritten } from './pty/plan-native';
export type { ReviewReportAtBottomResult, NativePlanTerminalReview, NativePlanTerminalAssessment, NativePlanTerminalEvaluator } from './pty/plan-native';
export { ceoStep0Boundary, engSetupAUQ, engFirstReviewAUQ, engStep0Boundary, designReviewSetupAUQ } from './pty/boundaries';
export { runPlanSkillObservation } from './pty/runners/observation';
export type { PlanSkillObservation, PlanSkillObservationOptions } from './pty/runners/observation';
export { runPlanSkillCounting, countingCapture, isNativeCompletionSummary } from './pty/runners/counting';
export type { PlanSkillCountObservation, PlanSkillCountingOptions, CountingRun } from './pty/runners/counting';
export { planFloorDXPane, planFloorDXReplyInput, runPlanSkillFloorCheck } from './pty/runners/floor';
export type { PlanSkillFloorObservation, PlanFloorDXReply } from './pty/runners/floor';