@step-forge/step-forge 0.0.22 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","names":[],"sources":["../../src/runtime/config.ts","../../src/runtime/filter.ts","../../src/runtime/reporters.ts","../../src/runtime/runner.ts","../../src/runtime/cli.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { access } from \"node:fs/promises\";\n\n/**\n * User-facing runner configuration. The same shape is accepted from a\n * `step-forge.config.ts` file (default export) and from CLI flags, with flags\n * taking precedence. Everything is optional; {@link resolveConfig} fills in\n * defaults.\n */\nexport interface RunnerOptions {\n /** Feature-file glob(s), relative to `cwd`. Defaults to every `.feature` file. */\n features?: string | string[];\n /** Step-module glob(s), relative to `cwd`. Defaults to every `.steps.ts` file. */\n steps?: string | string[];\n /**\n * Module that default-exports a world factory `() => world`, relative to\n * `cwd`. When omitted each scenario gets a fresh `BasicWorld`.\n */\n world?: string;\n /**\n * Max scenarios in flight at once. Defaults to `1` (serial), matching\n * Cucumber's default execution model — scenarios often share module-level\n * state via hooks, which only holds under serial execution. Raise it to opt\n * into parallelism for isolated, I/O-bound suites.\n */\n concurrency?: number;\n /** Reporter name. Default `pretty`. */\n reporter?: \"pretty\" | \"progress\";\n /**\n * Verbose output: report every scenario (pass, fail, skip) instead of only\n * failures. Passed to whichever reporter is active. Default `false`.\n */\n verbose?: boolean;\n /** Only run scenarios whose name matches this (string → substring/regex). */\n name?: string;\n /** Cucumber tag expression, e.g. `@smoke and not @wip`. */\n tags?: string;\n}\n\n/** Fully-resolved config: no optionals, globs kept as arrays, paths absolute. */\nexport interface ResolvedConfig {\n cwd: string;\n features: string[];\n steps: string[];\n world?: string;\n concurrency: number;\n reporter: \"pretty\" | \"progress\";\n verbose: boolean;\n name?: string;\n tags?: string;\n}\n\nconst DEFAULT_FEATURES = \"**/*.feature\";\nconst DEFAULT_STEPS = \"**/*.steps.ts\";\nconst CONFIG_BASENAMES = [\n \"step-forge.config.ts\",\n \"step-forge.config.mts\",\n \"step-forge.config.js\",\n \"step-forge.config.mjs\",\n];\n\nfunction toArray<T>(value: T | T[] | undefined): T[] {\n if (value === undefined) return [];\n return Array.isArray(value) ? value : [value];\n}\n\nasync function exists(p: string): Promise<boolean> {\n try {\n await access(p);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Locate and import a `step-forge.config.*` file from `cwd`, returning its\n * default export (or `{}` if none is present). Imported by absolute file URL so\n * Bun transpiles the TypeScript config natively.\n */\nexport async function loadConfigFile(cwd: string): Promise<RunnerOptions> {\n for (const basename of CONFIG_BASENAMES) {\n const candidate = path.join(cwd, basename);\n if (!(await exists(candidate))) continue;\n const mod = await import(pathToFileURL(candidate).href);\n return (mod.default ?? mod) as RunnerOptions;\n }\n return {};\n}\n\n/**\n * Merge file config with CLI overrides and apply defaults. CLI overrides win\n * field-by-field; array globs are normalised to arrays and default when neither\n * source provides them.\n */\nexport function resolveConfig(\n cwd: string,\n file: RunnerOptions,\n cli: RunnerOptions\n): ResolvedConfig {\n const pick = <K extends keyof RunnerOptions>(key: K): RunnerOptions[K] =>\n cli[key] ?? file[key];\n\n const features = toArray(pick(\"features\"));\n const steps = toArray(pick(\"steps\"));\n\n return {\n cwd,\n features: features.length ? features : [DEFAULT_FEATURES],\n steps: steps.length ? steps : [DEFAULT_STEPS],\n world: pick(\"world\"),\n concurrency: pick(\"concurrency\") ?? 1,\n reporter: pick(\"reporter\") ?? \"pretty\",\n verbose: pick(\"verbose\") ?? false,\n name: pick(\"name\"),\n tags: pick(\"tags\"),\n };\n}\n","import { ParsedScenario } from \"../analyzer/types\";\n\n/**\n * A predicate over a scenario's tags, compiled from a Cucumber tag expression.\n * Supports `and`, `or`, `not`, parentheses, and bare `@tag` atoms — the common\n * subset of Cucumber's tag-expression language. Kept dependency-free; swap for\n * `@cucumber/tag-expressions` if fuller parity is needed.\n */\nexport type TagPredicate = (tags: readonly string[]) => boolean;\n\n/** Tokenise a tag expression into atoms, operators, and parentheses. */\nfunction tokenize(expr: string): string[] {\n const tokens: string[] = [];\n const re = /\\s*(\\(|\\)|@[^\\s()]+|\\band\\b|\\bor\\b|\\bnot\\b)\\s*/gy;\n let index = 0;\n while (index < expr.length) {\n re.lastIndex = index;\n const m = re.exec(expr);\n if (!m || m.index !== index) {\n throw new Error(`Invalid tag expression near: ${expr.slice(index)}`);\n }\n tokens.push(m[1]);\n index = re.lastIndex;\n }\n return tokens;\n}\n\n/**\n * Compile a tag expression into a predicate via recursive descent\n * (or → and → not → primary). Throws on malformed input so a bad `--tags` flag\n * fails loudly rather than silently matching nothing.\n */\nexport function compileTagExpression(expr: string): TagPredicate {\n const tokens = tokenize(expr);\n let pos = 0;\n\n const peek = () => tokens[pos];\n const next = () => tokens[pos++];\n\n const parseOr = (): TagPredicate => {\n let left = parseAnd();\n while (peek() === \"or\") {\n next();\n const right = parseAnd();\n const l = left;\n left = tags => l(tags) || right(tags);\n }\n return left;\n };\n\n const parseAnd = (): TagPredicate => {\n let left = parseNot();\n while (peek() === \"and\") {\n next();\n const right = parseNot();\n const l = left;\n left = tags => l(tags) && right(tags);\n }\n return left;\n };\n\n const parseNot = (): TagPredicate => {\n if (peek() === \"not\") {\n next();\n const operand = parseNot();\n return tags => !operand(tags);\n }\n return parsePrimary();\n };\n\n const parsePrimary = (): TagPredicate => {\n const token = next();\n if (token === \"(\") {\n const inner = parseOr();\n if (next() !== \")\") throw new Error(\"Unbalanced parentheses in tags\");\n return inner;\n }\n if (token === undefined || !token.startsWith(\"@\")) {\n throw new Error(`Expected a tag, got: ${token ?? \"end of input\"}`);\n }\n return tags => tags.includes(token);\n };\n\n const predicate = parseOr();\n if (pos !== tokens.length) {\n throw new Error(`Unexpected token in tag expression: ${peek()}`);\n }\n return predicate;\n}\n\nexport interface SelectOptions {\n /** Substring or `/regex/flags` match against the scenario (or outline) name. */\n name?: string;\n /** Cucumber tag expression. */\n tags?: string;\n}\n\n/** Parse a `/pattern/flags` string into a RegExp, else treat it as a substring. */\nfunction toNameMatcher(name: string): (candidate: string) => boolean {\n const delim = /^\\/(.*)\\/([a-z]*)$/.exec(name);\n if (delim) {\n const re = new RegExp(delim[1], delim[2]);\n return candidate => re.test(candidate);\n }\n return candidate => candidate.includes(name);\n}\n\n/**\n * Narrow scenarios by name and tags, then apply `@only` focus. `@skip` is *not*\n * applied here — skipped scenarios stay in the set so the runner can report them\n * as skipped rather than silently dropping them. Returns scenarios in input\n * order.\n *\n * `@only` semantics mirror the Vitest plugin: if any surviving scenario is\n * tagged `@only` (and not `@skip`), the run is focused to just those.\n */\nexport function selectScenarios(\n scenarios: ParsedScenario[],\n options: SelectOptions\n): ParsedScenario[] {\n let selected = scenarios;\n\n if (options.name) {\n const matches = toNameMatcher(options.name);\n selected = selected.filter(\n s => matches(s.name) || (s.outline ? matches(s.outline.name) : false)\n );\n }\n\n if (options.tags) {\n const predicate = compileTagExpression(options.tags);\n selected = selected.filter(s => predicate(s.tags));\n }\n\n const focused = selected.filter(\n s => s.tags.includes(\"@only\") && !s.tags.includes(\"@skip\")\n );\n return focused.length ? focused : selected;\n}\n","import { relative } from \"node:path\";\nimport { relativeFrame, relativeLocation, userFrames } from \"../sourceLocation\";\nimport { ScenarioResult, StepResult } from \"./engine\";\n\n/**\n * A reporter observes the run. `onScenarioEnd` fires as each scenario finishes\n * (completion order, non-deterministic under concurrency); `onComplete` fires\n * once with every result for the end-of-run output.\n *\n * Every reporter accepts a `verbose` flag: without it a reporter reports only\n * failures (plus a summary); with it, it reports every scenario. A reporter may\n * render the same either way — `verbose` is a request, not a requirement.\n */\nexport interface Reporter {\n onScenarioEnd?(result: ScenarioResult): void;\n onComplete(results: ScenarioResult[], durationMs: number): void;\n}\n\nexport interface ReporterOptions {\n cwd?: string;\n verbose?: boolean;\n}\n\n// --- ANSI colouring -------------------------------------------------------\nconst useColor =\n !process.env.NO_COLOR && (process.stdout.isTTY ?? false) === true;\n\nconst wrap = (open: number, close: number) => (s: string) =>\n useColor ? `\\x1b[${open}m${s}\\x1b[${close}m` : s;\n\nconst c = {\n green: wrap(32, 39),\n red: wrap(31, 39),\n yellow: wrap(33, 39),\n dim: wrap(2, 22),\n bold: wrap(1, 22),\n};\n\nconst STATUS_MARK: Record<StepResult[\"status\"], string> = {\n passed: c.green(\"✓\"),\n failed: c.red(\"✗\"),\n skipped: c.yellow(\"-\"),\n};\n\n/** ✓ / ✗ / - for a whole scenario (skipped = every step skipped). */\nfunction scenarioMark(result: ScenarioResult): string {\n if (result.status === \"failed\") return c.red(\"✗\");\n if (result.steps.every(s => s.status === \"skipped\")) return c.yellow(\"-\");\n return c.green(\"✓\");\n}\n\n/** Dot per scenario for the live heartbeat: `.` pass / `F` fail / `-` skip. */\nfunction scenarioDot(result: ScenarioResult): string {\n if (result.status === \"failed\") return c.red(\"F\");\n if (result.steps.every(s => s.status === \"skipped\")) return c.yellow(\"-\");\n return c.green(\".\");\n}\n\n/** Indent every non-empty line of a block by `pad` spaces. */\nfunction indent(text: string, pad: number): string {\n const prefix = \" \".repeat(pad);\n return text\n .split(\"\\n\")\n .map(line => (line ? prefix + line : line))\n .join(\"\\n\");\n}\n\n/**\n * The error, trimmed to user frames: `Name: message` followed by only the\n * caller's own stack frames (library/engine and `node_modules` frames removed),\n * source-mapped by Bun to the original `.ts`. Falls back to just the message\n * when nothing user-owned is left (e.g. an undefined-step error).\n */\nfunction renderError(error: Error, cwd: string): string {\n const header = `${error.name}: ${error.message}`;\n const frames = userFrames(error.stack).map(\n f => ` at ${relativeFrame(f, cwd)}`\n );\n return frames.length ? `${header}\\n${frames.join(\"\\n\")}` : header;\n}\n\n/**\n * The detail block shown beneath a failing step: the `.feature` line, the step\n * definition location, and the trimmed error — the two coordinates that make a\n * failure easy to chase (where in the feature, which step definition).\n */\nfunction failureDetail(\n stepResult: StepResult,\n result: ScenarioResult,\n cwd: string\n): string {\n const lines = [\n `feature: ${relative(cwd, result.scenario.file)}:${stepResult.step.line}`,\n ];\n if (stepResult.source) {\n lines.push(`defined: ${relativeLocation(stepResult.source, cwd)}`);\n }\n if (stepResult.error) lines.push(renderError(stepResult.error, cwd));\n return indent(c.red(lines.join(\"\\n\")), 6);\n}\n\n/**\n * One scenario as a Cucumber-style block: a marked header with its `.feature`\n * location, then each step with its mark (and, in `verbose`, the step\n * definition location as a trailing comment). A failing step is followed by its\n * failure detail; a scenario-level error (a failing hook, no step to blame) is\n * appended at the end.\n */\nfunction renderScenario(\n result: ScenarioResult,\n cwd: string,\n opts: { stepSource: boolean }\n): string {\n const label = result.scenario.outline\n ? `${result.scenario.outline.name} › ${result.scenario.name}`\n : result.scenario.name;\n const lines: string[] = [`${scenarioMark(result)} ${c.bold(label)}`];\n\n const loc = result.scenario.line\n ? `${relative(cwd, result.scenario.file)}:${result.scenario.line}`\n : relative(cwd, result.scenario.file);\n lines.push(indent(c.dim(loc), 4));\n lines.push(\"\");\n\n for (const step of result.scenario.steps) {\n const sr = result.steps.find(s => s.step === step);\n const status = sr?.status ?? \"skipped\";\n const comment =\n opts.stepSource && sr?.source\n ? c.dim(` # ${relativeLocation(sr.source, cwd)}`)\n : \"\";\n lines.push(\n ` ${STATUS_MARK[status]} ${c.dim(step.effectiveKeyword)} ${step.text}${comment}`\n );\n if (sr?.status === \"failed\") lines.push(failureDetail(sr, result, cwd));\n }\n\n // A hook failure has no failing step; surface its error at scenario level.\n const stepFailed = result.steps.some(s => s.status === \"failed\");\n if (result.error && !stepFailed) {\n lines.push(indent(c.red(renderError(result.error, cwd)), 4));\n }\n\n return lines.join(\"\\n\");\n}\n\n// --- Summary --------------------------------------------------------------\ninterface Totals {\n scenarios: { passed: number; failed: number; skipped: number };\n steps: { passed: number; failed: number; skipped: number };\n}\n\nfunction tally(results: ScenarioResult[]): Totals {\n const totals: Totals = {\n scenarios: { passed: 0, failed: 0, skipped: 0 },\n steps: { passed: 0, failed: 0, skipped: 0 },\n };\n for (const result of results) {\n if (result.status === \"failed\") totals.scenarios.failed++;\n else if (result.steps.every(s => s.status === \"skipped\"))\n totals.scenarios.skipped++;\n else totals.scenarios.passed++;\n for (const step of result.steps) totals.steps[step.status]++;\n }\n return totals;\n}\n\nfunction renderSummary(results: ScenarioResult[], durationMs: number): string {\n const t = tally(results);\n const scenarioTotal =\n t.scenarios.passed + t.scenarios.failed + t.scenarios.skipped;\n const stepTotal = t.steps.passed + t.steps.failed + t.steps.skipped;\n\n const part = (n: number, label: string, color: (s: string) => string) =>\n n > 0 ? color(`${n} ${label}`) : null;\n\n const line = (\n total: number,\n noun: string,\n counts: { passed: number; failed: number; skipped: number }\n ) => {\n const parts = [\n part(counts.passed, \"passed\", c.green),\n part(counts.failed, \"failed\", c.red),\n part(counts.skipped, \"skipped\", c.yellow),\n ].filter((x): x is string => x !== null);\n return `${total} ${noun}${total === 1 ? \"\" : \"s\"} (${parts.join(\", \")})`;\n };\n\n return [\n line(scenarioTotal, \"scenario\", t.scenarios),\n line(stepTotal, \"step\", t.steps),\n c.dim(`${(durationMs / 1000).toFixed(2)}s`),\n ].join(\"\\n\");\n}\n\nfunction write(text: string): void {\n process.stdout.write(text);\n}\n\n/** Feature-grouped tree of every scenario (used by `--verbose`). */\nfunction renderFullTree(results: ScenarioResult[], cwd: string): string {\n const groups = new Map<string, ScenarioResult[]>();\n for (const r of results) {\n const bucket = groups.get(r.scenario.file) ?? [];\n bucket.push(r);\n groups.set(r.scenario.file, bucket);\n }\n const out: string[] = [];\n for (const [file, group] of groups) {\n out.push(c.bold(`Feature: ${relative(cwd, file)}`), \"\");\n for (const r of group)\n out.push(indent(renderScenario(r, cwd, { stepSource: true }), 2), \"\");\n }\n return out.join(\"\\n\");\n}\n\n/** The failing scenarios only (used by the default, non-verbose output). */\nfunction renderFailures(results: ScenarioResult[], cwd: string): string {\n const failed = results.filter(r => r.status === \"failed\");\n if (!failed.length) return \"\";\n return (\n failed\n .map(r => renderScenario(r, cwd, { stepSource: false }))\n .join(\"\\n\\n\") + \"\\n\\n\"\n );\n}\n\n/**\n * Default reporter. Non-verbose: a dot per scenario as a heartbeat, then the\n * failing scenarios in Cucumber-style detail, then the summary. Verbose: the\n * full feature → scenario → step tree instead of just failures.\n */\nexport function prettyReporter(opts: ReporterOptions = {}): Reporter {\n const cwd = opts.cwd ?? process.cwd();\n const verbose = opts.verbose ?? false;\n return {\n onScenarioEnd(result) {\n if (!verbose) write(scenarioDot(result));\n },\n onComplete(results, durationMs) {\n const body = verbose\n ? `\\n${renderFullTree(results, cwd)}\\n`\n : `\\n\\n${renderFailures(results, cwd)}`;\n write(`${body}${renderSummary(results, durationMs)}\\n`);\n },\n };\n}\n\n/**\n * Compact reporter: a dot per scenario, then failures in detail and the\n * summary. Always minimal — `verbose` is accepted for interface parity but does\n * not expand the output (use `pretty --verbose` for the full tree).\n */\nexport function progressReporter(opts: ReporterOptions = {}): Reporter {\n const cwd = opts.cwd ?? process.cwd();\n return {\n onScenarioEnd(result) {\n write(scenarioDot(result));\n },\n onComplete(results, durationMs) {\n write(\n `\\n\\n${renderFailures(results, cwd)}${renderSummary(results, durationMs)}\\n`\n );\n },\n };\n}\n\nexport function makeReporter(\n name: \"pretty\" | \"progress\",\n opts: ReporterOptions = {}\n): Reporter {\n return name === \"progress\" ? progressReporter(opts) : prettyReporter(opts);\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { ParsedScenario } from \"../analyzer/types\";\nimport { parseFeatureFiles } from \"../analyzer/gherkinParser\";\nimport { globFiles } from \"../globFiles\";\nimport { BasicWorld, MergeableWorld } from \"../world\";\nimport {\n compileRegistry,\n CompiledStep,\n runScenario,\n ScenarioResult,\n} from \"./engine\";\nimport { globalHookRegistry, runHooks, runHooksParallel } from \"./hooks\";\nimport { globalRegistry } from \"./registry\";\nimport { selectScenarios } from \"./filter\";\nimport { makeReporter, Reporter } from \"./reporters\";\nimport { ResolvedConfig } from \"./config\";\n\ntype WorldFactory = () => MergeableWorld<any, any, any>;\n\n/**\n * Import every step-definition module so its `.step(...)` calls self-register\n * into the shared `globalRegistry`. Imported by file URL so Bun transpiles the\n * TypeScript natively.\n */\nasync function importSteps(files: string[]): Promise<void> {\n for (const file of files) {\n await import(pathToFileURL(file).href);\n }\n}\n\n/** Load the configured world factory, or default to a fresh `BasicWorld`. */\nasync function loadWorldFactory(\n world: string | undefined,\n cwd: string\n): Promise<WorldFactory> {\n if (!world) return () => new BasicWorld();\n const resolved = path.resolve(cwd, world);\n const mod = await import(pathToFileURL(resolved).href);\n const factory = mod.default ?? mod;\n if (typeof factory !== \"function\") {\n throw new Error(\n `World module ${world} must default-export a factory function () => world`\n );\n }\n return factory as WorldFactory;\n}\n\n/** A scenario carrying `@skip` never runs: report it with all steps skipped. */\nfunction skippedResult(scenario: ParsedScenario): ScenarioResult {\n return {\n scenario,\n status: \"passed\",\n steps: scenario.steps.map(step => ({ step, status: \"skipped\" as const })),\n };\n}\n\n/**\n * Run `items` through `worker`, at most `limit` in flight. Results come back in\n * input order even though completion order is not deterministic. A minimal\n * dependency-free pool — the whole point of the single-process model.\n */\nasync function runPool<T, R>(\n items: T[],\n limit: number,\n worker: (item: T, index: number) => Promise<R>\n): Promise<R[]> {\n const results = new Array<R>(items.length);\n let cursor = 0;\n const runNext = async (): Promise<void> => {\n while (cursor < items.length) {\n const index = cursor++;\n results[index] = await worker(items[index], index);\n }\n };\n const workers = Array.from(\n { length: Math.min(Math.max(1, limit), items.length) },\n runNext\n );\n await Promise.all(workers);\n return results;\n}\n\nexport interface RunResult {\n results: ScenarioResult[];\n passed: boolean;\n durationMs: number;\n}\n\n/**\n * Execute a whole run end to end: discover and import steps, load the world,\n * parse and select scenarios, then run them concurrently against a\n * compiled-once step table with global/feature hooks around the batch. Never\n * throws for test failures — inspect `RunResult.passed`.\n */\nexport async function run(\n config: ResolvedConfig,\n reporter: Reporter = makeReporter(config.reporter, {\n cwd: config.cwd,\n verbose: config.verbose,\n })\n): Promise<RunResult> {\n const start =\n typeof performance !== \"undefined\" ? performance.now() : Date.now();\n\n const [featureFiles, stepFiles] = await Promise.all([\n globFiles(config.features, config.cwd),\n globFiles(config.steps, config.cwd),\n ]);\n\n await importSteps(stepFiles);\n const makeWorld = await loadWorldFactory(config.world, config.cwd);\n\n const compiled: CompiledStep[] = compileRegistry(globalRegistry);\n const allScenarios = parseFeatureFiles(featureFiles);\n const selected = selectScenarios(allScenarios, {\n name: config.name,\n tags: config.tags,\n });\n\n // Global `beforeAll` hooks run once, in parallel, before any scenario starts;\n // feature before/after bracket the whole batch inside them. (Hooks aren't\n // file-scoped in the registry, so per-file bracketing would be meaningless\n // under concurrent execution.)\n await runHooksParallel(\"global\", \"before\", globalHookRegistry);\n await runHooks(\"feature\", \"before\", globalHookRegistry);\n\n const results = await runPool(\n selected,\n config.concurrency,\n async scenario => {\n const result = scenario.tags.includes(\"@skip\")\n ? skippedResult(scenario)\n : await runScenario(scenario, compiled, makeWorld, globalHookRegistry);\n reporter.onScenarioEnd?.(result);\n return result;\n }\n );\n\n await runHooks(\"feature\", \"after\", globalHookRegistry);\n // Global `afterAll` hooks run once, in parallel, after every scenario is done.\n await runHooksParallel(\"global\", \"after\", globalHookRegistry);\n\n const durationMs =\n (typeof performance !== \"undefined\" ? performance.now() : Date.now()) -\n start;\n reporter.onComplete(results, durationMs);\n\n return {\n results,\n passed: results.every(r => r.status !== \"failed\"),\n durationMs,\n };\n}\n","#!/usr/bin/env bun\nimport { parseArgs } from \"node:util\";\nimport * as path from \"node:path\";\nimport { loadConfigFile, resolveConfig, RunnerOptions } from \"./config\";\nimport { run } from \"./runner\";\n\nconst HELP = `step-forge — native TypeScript runner for Gherkin step definitions\n\nUsage:\n step-forge [options] [feature globs...]\n\nOptions:\n -t, --tags <expr> Tag expression, e.g. \"@smoke and not @wip\"\n -n, --name <pattern> Only scenarios whose name matches (substring or /regex/)\n -s, --steps <glob> Step-definition module glob (repeatable)\n -w, --world <module> World factory module (default export () => world)\n -c, --concurrency <n> Max scenarios in flight (default: 1, i.e. serial)\n -r, --reporter <name> \"pretty\" (default) or \"progress\"\n -v, --verbose Report every scenario, not just failures\n --config <path> Config file directory (default: cwd)\n -h, --help Show this help\n\nPositional arguments are feature globs and override the configured features.\n`;\n\n/** Parse argv into config overrides. Positional args become feature globs. */\nfunction parseCli(argv: string[]): { cwd: string; overrides: RunnerOptions } {\n const { values, positionals } = parseArgs({\n args: argv,\n allowPositionals: true,\n options: {\n tags: { type: \"string\", short: \"t\" },\n name: { type: \"string\", short: \"n\" },\n steps: { type: \"string\", short: \"s\", multiple: true },\n world: { type: \"string\", short: \"w\" },\n concurrency: { type: \"string\", short: \"c\" },\n reporter: { type: \"string\", short: \"r\" },\n verbose: { type: \"boolean\", short: \"v\" },\n config: { type: \"string\" },\n help: { type: \"boolean\", short: \"h\" },\n },\n });\n\n if (values.help) {\n process.stdout.write(HELP);\n process.exit(0);\n }\n\n const overrides: RunnerOptions = {};\n if (positionals.length) overrides.features = positionals;\n if (values.tags) overrides.tags = values.tags;\n if (values.name) overrides.name = values.name;\n if (values.steps) overrides.steps = values.steps;\n if (values.world) overrides.world = values.world;\n if (values.verbose) overrides.verbose = true;\n if (values.reporter) {\n if (values.reporter !== \"pretty\" && values.reporter !== \"progress\") {\n throw new Error(`Unknown reporter: ${values.reporter}`);\n }\n overrides.reporter = values.reporter;\n }\n if (values.concurrency !== undefined) {\n const n = Number(values.concurrency);\n if (!Number.isInteger(n) || n < 1) {\n throw new Error(`--concurrency must be a positive integer`);\n }\n overrides.concurrency = n;\n }\n\n const cwd = values.config\n ? path.resolve(process.cwd(), values.config)\n : process.cwd();\n return { cwd, overrides };\n}\n\nasync function main(): Promise<void> {\n const { cwd, overrides } = parseCli(process.argv.slice(2));\n const fileConfig = await loadConfigFile(cwd);\n const config = resolveConfig(cwd, fileConfig, overrides);\n const { passed } = await run(config);\n process.exitCode = passed ? 0 : 1;\n}\n\nmain().catch(err => {\n process.stderr.write(`${err instanceof Error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Q,OAAO,MAAM,GAAG,eAAe,QAAQ,IAAI,QAAQ,OAAO,GAAG,EAAE,GAAG;CAC1E,QAAQ,WAAW;AACrB,CAAC"}
1
+ {"version":3,"file":"cli.js","names":["useColor","wrap","write","useColor"],"sources":["../../src/runtime/config.ts","../../src/runtime/filter.ts","../../src/runtime/reporters.ts","../../src/runtime/runner.ts","../../src/runtime/prompt.ts","../../src/runtime/watcher.ts","../../src/runtime/interactive.ts","../../src/runtime/cli.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { access } from \"node:fs/promises\";\n\n/**\n * User-facing runner configuration. The same shape is accepted from a\n * `step-forge.config.ts` file (default export) and from CLI flags, with flags\n * taking precedence. Everything is optional; {@link resolveConfig} fills in\n * defaults.\n */\nexport interface RunnerOptions {\n /** Feature-file glob(s), relative to `cwd`. Defaults to every `.feature` file. */\n features?: string | string[];\n /** Step-module glob(s), relative to `cwd`. Defaults to every `.steps.ts` file. */\n steps?: string | string[];\n /**\n * Module that default-exports a world factory `() => world`, relative to\n * `cwd`. When omitted each scenario gets a fresh `BasicWorld`.\n */\n world?: string;\n /**\n * Max scenarios in flight at once. Defaults to `1` (serial), matching\n * Cucumber's default execution model — scenarios often share module-level\n * state via hooks, which only holds under serial execution. Raise it to opt\n * into parallelism for isolated, I/O-bound suites.\n */\n concurrency?: number;\n /** Reporter name. Default `pretty`. */\n reporter?: \"pretty\" | \"progress\";\n /**\n * Verbose output: report every scenario (pass, fail, skip) instead of only\n * failures. Passed to whichever reporter is active. Default `false`.\n */\n verbose?: boolean;\n /** Only run scenarios whose name matches this (string → substring/regex). */\n name?: string;\n /** Cucumber tag expression, e.g. `@smoke and not @wip`. */\n tags?: string;\n}\n\n/** Fully-resolved config: no optionals, globs kept as arrays, paths absolute. */\nexport interface ResolvedConfig {\n cwd: string;\n features: string[];\n steps: string[];\n world?: string;\n concurrency: number;\n reporter: \"pretty\" | \"progress\";\n verbose: boolean;\n name?: string;\n tags?: string;\n}\n\nconst DEFAULT_FEATURES = \"**/*.feature\";\nconst DEFAULT_STEPS = \"**/*.steps.ts\";\nconst CONFIG_BASENAMES = [\n \"step-forge.config.ts\",\n \"step-forge.config.mts\",\n \"step-forge.config.js\",\n \"step-forge.config.mjs\",\n];\n\nfunction toArray<T>(value: T | T[] | undefined): T[] {\n if (value === undefined) return [];\n return Array.isArray(value) ? value : [value];\n}\n\nasync function exists(p: string): Promise<boolean> {\n try {\n await access(p);\n return true;\n } catch {\n return false;\n }\n}\n\n/**\n * Locate and import a `step-forge.config.*` file from `cwd`, returning its\n * default export (or `{}` if none is present). Imported by absolute file URL so\n * Bun transpiles the TypeScript config natively.\n */\nexport async function loadConfigFile(cwd: string): Promise<RunnerOptions> {\n for (const basename of CONFIG_BASENAMES) {\n const candidate = path.join(cwd, basename);\n if (!(await exists(candidate))) continue;\n const mod = await import(pathToFileURL(candidate).href);\n return (mod.default ?? mod) as RunnerOptions;\n }\n return {};\n}\n\n/**\n * Merge file config with CLI overrides and apply defaults. CLI overrides win\n * field-by-field; array globs are normalised to arrays and default when neither\n * source provides them.\n */\nexport function resolveConfig(\n cwd: string,\n file: RunnerOptions,\n cli: RunnerOptions\n): ResolvedConfig {\n const pick = <K extends keyof RunnerOptions>(key: K): RunnerOptions[K] =>\n cli[key] ?? file[key];\n\n const features = toArray(pick(\"features\"));\n const steps = toArray(pick(\"steps\"));\n\n return {\n cwd,\n features: features.length ? features : [DEFAULT_FEATURES],\n steps: steps.length ? steps : [DEFAULT_STEPS],\n world: pick(\"world\"),\n concurrency: pick(\"concurrency\") ?? 1,\n reporter: pick(\"reporter\") ?? \"pretty\",\n verbose: pick(\"verbose\") ?? false,\n name: pick(\"name\"),\n tags: pick(\"tags\"),\n };\n}\n","import { ParsedScenario } from \"../analyzer/types\";\n\n/**\n * A predicate over a scenario's tags, compiled from a Cucumber tag expression.\n * Supports `and`, `or`, `not`, parentheses, and bare `@tag` atoms — the common\n * subset of Cucumber's tag-expression language. Kept dependency-free; swap for\n * `@cucumber/tag-expressions` if fuller parity is needed.\n */\nexport type TagPredicate = (tags: readonly string[]) => boolean;\n\n/** Tokenise a tag expression into atoms, operators, and parentheses. */\nfunction tokenize(expr: string): string[] {\n const tokens: string[] = [];\n const re = /\\s*(\\(|\\)|@[^\\s()]+|\\band\\b|\\bor\\b|\\bnot\\b)\\s*/gy;\n let index = 0;\n while (index < expr.length) {\n re.lastIndex = index;\n const m = re.exec(expr);\n if (!m || m.index !== index) {\n throw new Error(`Invalid tag expression near: ${expr.slice(index)}`);\n }\n tokens.push(m[1]);\n index = re.lastIndex;\n }\n return tokens;\n}\n\n/**\n * Compile a tag expression into a predicate via recursive descent\n * (or → and → not → primary). Throws on malformed input so a bad `--tags` flag\n * fails loudly rather than silently matching nothing.\n */\nexport function compileTagExpression(expr: string): TagPredicate {\n const tokens = tokenize(expr);\n let pos = 0;\n\n const peek = () => tokens[pos];\n const next = () => tokens[pos++];\n\n const parseOr = (): TagPredicate => {\n let left = parseAnd();\n while (peek() === \"or\") {\n next();\n const right = parseAnd();\n const l = left;\n left = tags => l(tags) || right(tags);\n }\n return left;\n };\n\n const parseAnd = (): TagPredicate => {\n let left = parseNot();\n while (peek() === \"and\") {\n next();\n const right = parseNot();\n const l = left;\n left = tags => l(tags) && right(tags);\n }\n return left;\n };\n\n const parseNot = (): TagPredicate => {\n if (peek() === \"not\") {\n next();\n const operand = parseNot();\n return tags => !operand(tags);\n }\n return parsePrimary();\n };\n\n const parsePrimary = (): TagPredicate => {\n const token = next();\n if (token === \"(\") {\n const inner = parseOr();\n if (next() !== \")\") throw new Error(\"Unbalanced parentheses in tags\");\n return inner;\n }\n if (token === undefined || !token.startsWith(\"@\")) {\n throw new Error(`Expected a tag, got: ${token ?? \"end of input\"}`);\n }\n return tags => tags.includes(token);\n };\n\n const predicate = parseOr();\n if (pos !== tokens.length) {\n throw new Error(`Unexpected token in tag expression: ${peek()}`);\n }\n return predicate;\n}\n\nexport interface SelectOptions {\n /** Substring or `/regex/flags` match against the scenario (or outline) name. */\n name?: string;\n /** Cucumber tag expression. */\n tags?: string;\n}\n\n/** Parse a `/pattern/flags` string into a RegExp, else treat it as a substring. */\nfunction toNameMatcher(name: string): (candidate: string) => boolean {\n const delim = /^\\/(.*)\\/([a-z]*)$/.exec(name);\n if (delim) {\n const re = new RegExp(delim[1], delim[2]);\n return candidate => re.test(candidate);\n }\n return candidate => candidate.includes(name);\n}\n\n/**\n * Narrow scenarios by name and tags, then apply `@only` focus. `@skip` is *not*\n * applied here — skipped scenarios stay in the set so the runner can report them\n * as skipped rather than silently dropping them. Returns scenarios in input\n * order.\n *\n * `@only` semantics mirror the Vitest plugin: if any surviving scenario is\n * tagged `@only` (and not `@skip`), the run is focused to just those.\n */\nexport function selectScenarios(\n scenarios: ParsedScenario[],\n options: SelectOptions\n): ParsedScenario[] {\n let selected = scenarios;\n\n if (options.name) {\n const matches = toNameMatcher(options.name);\n selected = selected.filter(\n s => matches(s.name) || (s.outline ? matches(s.outline.name) : false)\n );\n }\n\n if (options.tags) {\n const predicate = compileTagExpression(options.tags);\n selected = selected.filter(s => predicate(s.tags));\n }\n\n const focused = selected.filter(\n s => s.tags.includes(\"@only\") && !s.tags.includes(\"@skip\")\n );\n return focused.length ? focused : selected;\n}\n","import { relative } from \"node:path\";\nimport { relativeFrame, relativeLocation, userFrames } from \"../sourceLocation\";\nimport { ScenarioResult, StepResult } from \"./engine\";\n\n/**\n * A reporter observes the run. `onScenarioEnd` fires as each scenario finishes\n * (completion order, non-deterministic under concurrency); `onComplete` fires\n * once with every result for the end-of-run output.\n *\n * Every reporter accepts a `verbose` flag: without it a reporter reports only\n * failures (plus a summary); with it, it reports every scenario. A reporter may\n * render the same either way — `verbose` is a request, not a requirement.\n */\nexport interface Reporter {\n onScenarioEnd?(result: ScenarioResult): void;\n onComplete(results: ScenarioResult[], durationMs: number): void;\n}\n\nexport interface ReporterOptions {\n cwd?: string;\n verbose?: boolean;\n}\n\n// --- ANSI colouring -------------------------------------------------------\nconst useColor =\n !process.env.NO_COLOR && (process.stdout.isTTY ?? false) === true;\n\nconst wrap = (open: number, close: number) => (s: string) =>\n useColor ? `\\x1b[${open}m${s}\\x1b[${close}m` : s;\n\nconst c = {\n green: wrap(32, 39),\n red: wrap(31, 39),\n yellow: wrap(33, 39),\n dim: wrap(2, 22),\n bold: wrap(1, 22),\n};\n\nconst STATUS_MARK: Record<StepResult[\"status\"], string> = {\n passed: c.green(\"✓\"),\n failed: c.red(\"✗\"),\n skipped: c.yellow(\"-\"),\n};\n\n/** ✓ / ✗ / - for a whole scenario (skipped = every step skipped). */\nfunction scenarioMark(result: ScenarioResult): string {\n if (result.status === \"failed\") return c.red(\"✗\");\n if (result.steps.every(s => s.status === \"skipped\")) return c.yellow(\"-\");\n return c.green(\"✓\");\n}\n\n/** Dot per scenario for the live heartbeat: `.` pass / `F` fail / `-` skip. */\nfunction scenarioDot(result: ScenarioResult): string {\n if (result.status === \"failed\") return c.red(\"F\");\n if (result.steps.every(s => s.status === \"skipped\")) return c.yellow(\"-\");\n return c.green(\".\");\n}\n\n/** Indent every non-empty line of a block by `pad` spaces. */\nfunction indent(text: string, pad: number): string {\n const prefix = \" \".repeat(pad);\n return text\n .split(\"\\n\")\n .map(line => (line ? prefix + line : line))\n .join(\"\\n\");\n}\n\n/**\n * The error, trimmed to user frames: `Name: message` followed by only the\n * caller's own stack frames (library/engine and `node_modules` frames removed),\n * source-mapped by Bun to the original `.ts`. Falls back to just the message\n * when nothing user-owned is left (e.g. an undefined-step error).\n */\nfunction renderError(error: Error, cwd: string): string {\n const header = `${error.name}: ${error.message}`;\n const frames = userFrames(error.stack).map(\n f => ` at ${relativeFrame(f, cwd)}`\n );\n return frames.length ? `${header}\\n${frames.join(\"\\n\")}` : header;\n}\n\n/**\n * The detail block shown beneath a failing step: the `.feature` line, the step\n * definition location, and the trimmed error — the two coordinates that make a\n * failure easy to chase (where in the feature, which step definition).\n */\nfunction failureDetail(\n stepResult: StepResult,\n result: ScenarioResult,\n cwd: string\n): string {\n const lines = [\n `feature: ${relative(cwd, result.scenario.file)}:${stepResult.step.line}`,\n ];\n if (stepResult.source) {\n lines.push(`defined: ${relativeLocation(stepResult.source, cwd)}`);\n }\n if (stepResult.error) lines.push(renderError(stepResult.error, cwd));\n return indent(c.red(lines.join(\"\\n\")), 6);\n}\n\n/**\n * One scenario as a Cucumber-style block: a marked header with its `.feature`\n * location, then each step with its mark (and, in `verbose`, the step\n * definition location as a trailing comment). A failing step is followed by its\n * failure detail; a scenario-level error (a failing hook, no step to blame) is\n * appended at the end.\n */\nfunction renderScenario(\n result: ScenarioResult,\n cwd: string,\n opts: { stepSource: boolean }\n): string {\n const label = result.scenario.outline\n ? `${result.scenario.outline.name} › ${result.scenario.name}`\n : result.scenario.name;\n const lines: string[] = [`${scenarioMark(result)} ${c.bold(label)}`];\n\n const loc = result.scenario.line\n ? `${relative(cwd, result.scenario.file)}:${result.scenario.line}`\n : relative(cwd, result.scenario.file);\n lines.push(indent(c.dim(loc), 4));\n lines.push(\"\");\n\n for (const step of result.scenario.steps) {\n const sr = result.steps.find(s => s.step === step);\n const status = sr?.status ?? \"skipped\";\n const comment =\n opts.stepSource && sr?.source\n ? c.dim(` # ${relativeLocation(sr.source, cwd)}`)\n : \"\";\n lines.push(\n ` ${STATUS_MARK[status]} ${c.dim(step.effectiveKeyword)} ${step.text}${comment}`\n );\n if (sr?.status === \"failed\") lines.push(failureDetail(sr, result, cwd));\n }\n\n // A hook failure has no failing step; surface its error at scenario level.\n const stepFailed = result.steps.some(s => s.status === \"failed\");\n if (result.error && !stepFailed) {\n lines.push(indent(c.red(renderError(result.error, cwd)), 4));\n }\n\n return lines.join(\"\\n\");\n}\n\n// --- Summary --------------------------------------------------------------\ninterface Totals {\n scenarios: { passed: number; failed: number; skipped: number };\n steps: { passed: number; failed: number; skipped: number };\n}\n\nfunction tally(results: ScenarioResult[]): Totals {\n const totals: Totals = {\n scenarios: { passed: 0, failed: 0, skipped: 0 },\n steps: { passed: 0, failed: 0, skipped: 0 },\n };\n for (const result of results) {\n if (result.status === \"failed\") totals.scenarios.failed++;\n else if (result.steps.every(s => s.status === \"skipped\"))\n totals.scenarios.skipped++;\n else totals.scenarios.passed++;\n for (const step of result.steps) totals.steps[step.status]++;\n }\n return totals;\n}\n\nfunction renderSummary(results: ScenarioResult[], durationMs: number): string {\n const t = tally(results);\n const scenarioTotal =\n t.scenarios.passed + t.scenarios.failed + t.scenarios.skipped;\n const stepTotal = t.steps.passed + t.steps.failed + t.steps.skipped;\n\n const part = (n: number, label: string, color: (s: string) => string) =>\n n > 0 ? color(`${n} ${label}`) : null;\n\n const line = (\n total: number,\n noun: string,\n counts: { passed: number; failed: number; skipped: number }\n ) => {\n const parts = [\n part(counts.passed, \"passed\", c.green),\n part(counts.failed, \"failed\", c.red),\n part(counts.skipped, \"skipped\", c.yellow),\n ].filter((x): x is string => x !== null);\n return `${total} ${noun}${total === 1 ? \"\" : \"s\"} (${parts.join(\", \")})`;\n };\n\n return [\n line(scenarioTotal, \"scenario\", t.scenarios),\n line(stepTotal, \"step\", t.steps),\n c.dim(`${(durationMs / 1000).toFixed(2)}s`),\n ].join(\"\\n\");\n}\n\nfunction write(text: string): void {\n process.stdout.write(text);\n}\n\n/** Feature-grouped tree of every scenario (used by `--verbose`). */\nfunction renderFullTree(results: ScenarioResult[], cwd: string): string {\n const groups = new Map<string, ScenarioResult[]>();\n for (const r of results) {\n const bucket = groups.get(r.scenario.file) ?? [];\n bucket.push(r);\n groups.set(r.scenario.file, bucket);\n }\n const out: string[] = [];\n for (const [file, group] of groups) {\n out.push(c.bold(`Feature: ${relative(cwd, file)}`), \"\");\n for (const r of group)\n out.push(indent(renderScenario(r, cwd, { stepSource: true }), 2), \"\");\n }\n return out.join(\"\\n\");\n}\n\n/** The failing scenarios only (used by the default, non-verbose output). */\nfunction renderFailures(results: ScenarioResult[], cwd: string): string {\n const failed = results.filter(r => r.status === \"failed\");\n if (!failed.length) return \"\";\n return (\n failed\n .map(r => renderScenario(r, cwd, { stepSource: false }))\n .join(\"\\n\\n\") + \"\\n\\n\"\n );\n}\n\n/**\n * Default reporter. Non-verbose: a dot per scenario as a heartbeat, then the\n * failing scenarios in Cucumber-style detail, then the summary. Verbose: the\n * full feature → scenario → step tree instead of just failures.\n */\nexport function prettyReporter(opts: ReporterOptions = {}): Reporter {\n const cwd = opts.cwd ?? process.cwd();\n const verbose = opts.verbose ?? false;\n return {\n onScenarioEnd(result) {\n if (!verbose) write(scenarioDot(result));\n },\n onComplete(results, durationMs) {\n const body = verbose\n ? `\\n${renderFullTree(results, cwd)}\\n`\n : `\\n\\n${renderFailures(results, cwd)}`;\n write(`${body}${renderSummary(results, durationMs)}\\n`);\n },\n };\n}\n\n/**\n * Compact reporter: a dot per scenario, then failures in detail and the\n * summary. Always minimal — `verbose` is accepted for interface parity but does\n * not expand the output (use `pretty --verbose` for the full tree).\n */\nexport function progressReporter(opts: ReporterOptions = {}): Reporter {\n const cwd = opts.cwd ?? process.cwd();\n return {\n onScenarioEnd(result) {\n write(scenarioDot(result));\n },\n onComplete(results, durationMs) {\n write(\n `\\n\\n${renderFailures(results, cwd)}${renderSummary(results, durationMs)}\\n`\n );\n },\n };\n}\n\nexport function makeReporter(\n name: \"pretty\" | \"progress\",\n opts: ReporterOptions = {}\n): Reporter {\n return name === \"progress\" ? progressReporter(opts) : prettyReporter(opts);\n}\n","/* eslint-disable @typescript-eslint/no-explicit-any */\nimport * as path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { ParsedScenario } from \"../analyzer/types\";\nimport { parseFeatureFiles } from \"../analyzer/gherkinParser\";\nimport { globFiles } from \"../globFiles\";\nimport { BasicWorld, MergeableWorld } from \"../world\";\nimport {\n compileRegistry,\n CompiledStep,\n runScenario,\n ScenarioResult,\n} from \"./engine\";\nimport { globalHookRegistry, runHooks, runHooksParallel } from \"./hooks\";\nimport { globalRegistry } from \"./registry\";\nimport { selectScenarios } from \"./filter\";\nimport { makeReporter, Reporter } from \"./reporters\";\nimport { ResolvedConfig } from \"./config\";\n\ntype WorldFactory = () => MergeableWorld<any, any, any>;\n\n/**\n * Import every step-definition module so its `.step(...)` calls self-register\n * into the shared `globalRegistry`. Imported by file URL so Bun transpiles the\n * TypeScript natively.\n */\nasync function importSteps(files: string[]): Promise<void> {\n for (const file of files) {\n await import(pathToFileURL(file).href);\n }\n}\n\n/** Load the configured world factory, or default to a fresh `BasicWorld`. */\nasync function loadWorldFactory(\n world: string | undefined,\n cwd: string\n): Promise<WorldFactory> {\n if (!world) return () => new BasicWorld();\n const resolved = path.resolve(cwd, world);\n const mod = await import(pathToFileURL(resolved).href);\n const factory = mod.default ?? mod;\n if (typeof factory !== \"function\") {\n throw new Error(\n `World module ${world} must default-export a factory function () => world`\n );\n }\n return factory as WorldFactory;\n}\n\n/** A scenario carrying `@skip` never runs: report it with all steps skipped. */\nfunction skippedResult(scenario: ParsedScenario): ScenarioResult {\n return {\n scenario,\n status: \"passed\",\n steps: scenario.steps.map(step => ({ step, status: \"skipped\" as const })),\n };\n}\n\n/**\n * Run `items` through `worker`, at most `limit` in flight. Results come back in\n * input order even though completion order is not deterministic. A minimal\n * dependency-free pool — the whole point of the single-process model.\n */\nasync function runPool<T, R>(\n items: T[],\n limit: number,\n worker: (item: T, index: number) => Promise<R>\n): Promise<R[]> {\n const results = new Array<R>(items.length);\n let cursor = 0;\n const runNext = async (): Promise<void> => {\n while (cursor < items.length) {\n const index = cursor++;\n results[index] = await worker(items[index], index);\n }\n };\n const workers = Array.from(\n { length: Math.min(Math.max(1, limit), items.length) },\n runNext\n );\n await Promise.all(workers);\n return results;\n}\n\nexport interface RunResult {\n results: ScenarioResult[];\n passed: boolean;\n durationMs: number;\n}\n\n/**\n * Execute a whole run end to end: discover and import steps, load the world,\n * parse and select scenarios, then run them concurrently against a\n * compiled-once step table with global/feature hooks around the batch. Never\n * throws for test failures — inspect `RunResult.passed`.\n */\nexport async function run(\n config: ResolvedConfig,\n reporter: Reporter = makeReporter(config.reporter, {\n cwd: config.cwd,\n verbose: config.verbose,\n })\n): Promise<RunResult> {\n const start =\n typeof performance !== \"undefined\" ? performance.now() : Date.now();\n\n const [featureFiles, stepFiles] = await Promise.all([\n globFiles(config.features, config.cwd),\n globFiles(config.steps, config.cwd),\n ]);\n\n await importSteps(stepFiles);\n const makeWorld = await loadWorldFactory(config.world, config.cwd);\n\n const compiled: CompiledStep[] = compileRegistry(globalRegistry);\n const allScenarios = parseFeatureFiles(featureFiles);\n const selected = selectScenarios(allScenarios, {\n name: config.name,\n tags: config.tags,\n });\n\n // Global `beforeAll` hooks run once, in parallel, before any scenario starts;\n // feature before/after bracket the whole batch inside them. (Hooks aren't\n // file-scoped in the registry, so per-file bracketing would be meaningless\n // under concurrent execution.)\n await runHooksParallel(\"global\", \"before\", globalHookRegistry);\n await runHooks(\"feature\", \"before\", globalHookRegistry);\n\n const results = await runPool(\n selected,\n config.concurrency,\n async scenario => {\n const result = scenario.tags.includes(\"@skip\")\n ? skippedResult(scenario)\n : await runScenario(scenario, compiled, makeWorld, globalHookRegistry);\n reporter.onScenarioEnd?.(result);\n return result;\n }\n );\n\n await runHooks(\"feature\", \"after\", globalHookRegistry);\n // Global `afterAll` hooks run once, in parallel, after every scenario is done.\n await runHooksParallel(\"global\", \"after\", globalHookRegistry);\n\n const durationMs =\n (typeof performance !== \"undefined\" ? performance.now() : Date.now()) -\n start;\n reporter.onComplete(results, durationMs);\n\n return {\n results,\n passed: results.every(r => r.status !== \"failed\"),\n durationMs,\n };\n}\n","import * as readline from \"node:readline\";\n\n/**\n * A hand-rolled, dependency-free typeahead prompt for interactive mode. It owns\n * the terminal's raw-mode input and renders a block pinned to the bottom of the\n * screen: a scrollable list of suggestions above a `> query` input line. Run\n * output is meant to scroll *above* this block — {@link Prompt.printAbove} erases\n * the block, lets a caller write, then redraws it lower down.\n *\n * The prompt is pure view + input: it filters/ranks {@link Suggestion}s by the\n * typed query and reports intent through callbacks ({@link PromptHandlers}), but\n * holds no run/watch logic. The orchestrator wires those callbacks.\n */\nexport interface Suggestion {\n /** Human label shown after the badge, e.g. a scenario name. */\n label: string;\n /** Short kind marker shown before the label, e.g. `#tag` / `feature`. */\n badge: string;\n /** Text the query is matched against (case-insensitively). */\n search: string;\n /** Opaque payload handed back to {@link PromptHandlers.onSubmit}. */\n value: unknown;\n}\n\nexport interface PromptHandlers {\n /** Enter: `value` is the highlighted suggestion, or `null` when none matches. */\n onSubmit(value: unknown | null, query: string): void;\n /** The query text changed (insert/delete) — used to suspend auto-runs. */\n onEdit(query: string): void;\n /** Escape pressed. */\n onEscape(): void;\n /** Ctrl-C / Ctrl-D — the caller should tear down and exit. */\n onQuit(): void;\n}\n\nexport interface PromptOptions {\n handlers: PromptHandlers;\n /** Input prefix. Default `\"› \"`. */\n prefix?: string;\n /** Max suggestion rows shown at once. Default `10`. */\n maxVisible?: number;\n /** Initial query text. */\n initialQuery?: string;\n}\n\n// --- ANSI ------------------------------------------------------------------\nconst useColor =\n !process.env.NO_COLOR && (process.stdout.isTTY ?? false) === true;\nconst wrap = (open: number, close: number) => (s: string) =>\n useColor ? `\\x1b[${open}m${s}\\x1b[${close}m` : s;\nconst color = {\n green: wrap(32, 39),\n cyan: wrap(36, 39),\n dim: wrap(2, 22),\n bold: wrap(1, 22),\n inverse: wrap(7, 27),\n};\n\n/** Ranked match: lower rank sorts first; `-1` means \"no match\" (excluded). */\nfunction rank(search: string, query: string): number {\n if (!query) return 0;\n const idx = search.indexOf(query);\n if (idx === -1) return -1;\n if (idx === 0) return 0; // prefix\n // word-boundary (space, `:`, `›`, `@`) scores above a bare substring.\n return /[\\s:›@/]/.test(search[idx - 1]) ? 1 : 2;\n}\n\nexport class Prompt {\n private readonly handlers: PromptHandlers;\n private readonly prefix: string;\n private readonly maxVisible: number;\n\n private all: Suggestion[] = [];\n private matches: Suggestion[] = [];\n private query: string;\n private cursor: number; // caret index within `query`\n private selected = 0; // index into `matches`\n private window = 0; // first visible match index\n\n /** Optional dim status line shown just above the input (set by the caller). */\n status = \"\";\n\n /** Lines the pinned block currently occupies, so a redraw can erase them. */\n private rendered = 0;\n private started = false;\n /** While true the block is hidden so a run's output can own the screen. */\n private suspended = false;\n private keyListener?: (str: string, key: readline.Key) => void;\n\n constructor(options: PromptOptions) {\n this.handlers = options.handlers;\n this.prefix = options.prefix ?? \"› \";\n this.maxVisible = options.maxVisible ?? 10;\n this.query = options.initialQuery ?? \"\";\n this.cursor = this.query.length;\n }\n\n /** Replace the suggestion pool (e.g. after the feature cache rebuilds). */\n setSuggestions(suggestions: Suggestion[]): void {\n this.all = suggestions;\n this.refilter();\n if (this.started) this.render();\n }\n\n get value(): string {\n return this.query;\n }\n\n /** Enter raw mode, attach the keypress listener, and draw the block. */\n start(): void {\n if (this.started) return;\n this.started = true;\n readline.emitKeypressEvents(process.stdin);\n if (process.stdin.isTTY) process.stdin.setRawMode(true);\n this.keyListener = (str, key) => this.onKey(str, key ?? {});\n process.stdin.on(\"keypress\", this.keyListener);\n process.stdin.resume();\n this.render();\n }\n\n /** Erase the block, restore cooked mode, and detach the listener. */\n stop(): void {\n if (!this.started) return;\n this.started = false;\n this.erase();\n write(\"\\x1b[?25h\"); // ensure the cursor is visible again\n if (this.keyListener) process.stdin.off(\"keypress\", this.keyListener);\n if (process.stdin.isTTY) process.stdin.setRawMode(false);\n process.stdin.pause();\n }\n\n /**\n * Erase the pinned block and hide it for the duration of an (async) run, so\n * everything written to stdout in the meantime scrolls where the prompt was.\n * Keypresses still update state but don't repaint until {@link endOutput}.\n */\n beginOutput(): void {\n if (!this.started) return;\n this.erase();\n this.suspended = true;\n }\n\n /** Redraw the pinned block below whatever output {@link beginOutput} let through. */\n endOutput(): void {\n if (!this.started) return;\n this.suspended = false;\n this.render();\n }\n\n /** Force a redraw (after mutating `status`, say). No-op while suspended. */\n redraw(): void {\n if (this.started && !this.suspended) this.render();\n }\n\n // --- input ---------------------------------------------------------------\n private onKey(str: string, key: readline.Key): void {\n if (key.ctrl && (key.name === \"c\" || key.name === \"d\")) {\n this.handlers.onQuit();\n return;\n }\n switch (key.name) {\n case \"return\":\n case \"enter\": {\n const value = this.matches[this.selected]?.value ?? null;\n this.handlers.onSubmit(value, this.query);\n return;\n }\n case \"escape\":\n this.handlers.onEscape();\n return;\n case \"up\":\n this.move(-1);\n return;\n case \"down\":\n this.move(1);\n return;\n case \"left\":\n this.cursor = Math.max(0, this.cursor - 1);\n this.render();\n return;\n case \"right\":\n this.cursor = Math.min(this.query.length, this.cursor + 1);\n this.render();\n return;\n case \"home\":\n this.cursor = 0;\n this.render();\n return;\n case \"end\":\n this.cursor = this.query.length;\n this.render();\n return;\n case \"backspace\":\n this.deleteBefore();\n return;\n case \"delete\":\n this.deleteAfter();\n return;\n }\n // Any single printable character (space included) is inserted.\n if (str && str.length === 1 && str >= \" \" && !key.ctrl && !key.meta) {\n this.insert(str);\n }\n }\n\n private insert(ch: string): void {\n this.query =\n this.query.slice(0, this.cursor) + ch + this.query.slice(this.cursor);\n this.cursor += ch.length;\n this.afterEdit();\n }\n\n private deleteBefore(): void {\n if (this.cursor === 0) return;\n this.query =\n this.query.slice(0, this.cursor - 1) + this.query.slice(this.cursor);\n this.cursor--;\n this.afterEdit();\n }\n\n private deleteAfter(): void {\n if (this.cursor >= this.query.length) return;\n this.query =\n this.query.slice(0, this.cursor) + this.query.slice(this.cursor + 1);\n this.afterEdit();\n }\n\n private afterEdit(): void {\n this.refilter();\n this.render();\n this.handlers.onEdit(this.query);\n }\n\n private move(delta: number): void {\n if (this.matches.length === 0) return;\n this.selected = Math.min(\n this.matches.length - 1,\n Math.max(0, this.selected + delta)\n );\n this.reWindow();\n this.render();\n }\n\n private refilter(): void {\n const q = this.query.trim().toLowerCase();\n this.matches = this.all\n .map((s, index) => ({ s, index, r: rank(s.search, q) }))\n .filter(m => m.r !== -1)\n .sort((a, b) => a.r - b.r || a.index - b.index)\n .map(m => m.s);\n this.selected = 0;\n this.window = 0;\n }\n\n private reWindow(): void {\n if (this.selected < this.window) this.window = this.selected;\n else if (this.selected >= this.window + this.maxVisible)\n this.window = this.selected - this.maxVisible + 1;\n }\n\n // --- rendering -----------------------------------------------------------\n /** Build the block's lines, top (suggestions) to bottom (input). */\n private buildLines(): string[] {\n const lines: string[] = [];\n const total = this.matches.length;\n\n if (this.query.trim() && total === 0) {\n lines.push(color.dim(\" no matching tag, feature, or scenario\"));\n }\n\n const end = Math.min(this.window + this.maxVisible, total);\n for (let i = this.window; i < end; i++) {\n const s = this.matches[i];\n const active = i === this.selected;\n const badge = color.cyan(s.badge.padEnd(9));\n const row = `${badge} ${s.label}`;\n lines.push(active ? color.inverse(`❯ ${row}`) : ` ${row}`);\n }\n if (total > end) {\n lines.push(color.dim(` …and ${total - end} more`));\n }\n\n if (this.status) lines.push(color.dim(this.status));\n lines.push(`${color.bold(this.prefix)}${this.query}`);\n return lines;\n }\n\n private render(): void {\n if (this.suspended) return; // a run owns the screen; don't repaint over it\n write(\"\\x1b[?25l\"); // hide caret while we repaint\n this.moveToBlockStart();\n write(\"\\x1b[0J\"); // clear from here to end of screen\n const lines = this.buildLines();\n write(lines.join(\"\\r\\n\"));\n this.rendered = lines.length;\n // Park the caret on the input line at the right column.\n write(`\\r\\x1b[${stringWidth(this.prefix) + this.cursor}C`);\n write(\"\\x1b[?25h\");\n }\n\n /** Erase the block and leave the caret at the block's top-left. */\n private erase(): void {\n this.moveToBlockStart();\n write(\"\\x1b[0J\");\n this.rendered = 0;\n }\n\n /** Move the caret to column 0 of the block's first line. */\n private moveToBlockStart(): void {\n if (this.rendered > 1) write(`\\x1b[${this.rendered - 1}A`);\n write(\"\\r\");\n }\n}\n\n/** Visible width, ignoring the ANSI escapes our color helpers may inject. */\nfunction stringWidth(s: string): number {\n // eslint-disable-next-line no-control-regex\n return s.replace(/\\x1b\\[[0-9;]*m/g, \"\").length;\n}\n\nfunction write(s: string): void {\n process.stdout.write(s);\n}\n","import * as fs from \"node:fs\";\nimport * as path from \"node:path\";\n\n/** Glob metacharacters — the same set {@link globFiles} treats as \"magic\". */\nconst MAGIC = /[*?[\\]{}!()]/;\n\n/** File extensions worth reacting to: features and step/world modules. */\nconst WATCHED_EXT = /\\.(feature|ts|mts|js|mjs|cts|cjs)$/;\n\nexport interface Watcher {\n /** Stop watching and release every underlying `fs.watch` handle. */\n close(): void;\n}\n\n/**\n * Watch the directories implied by feature/step globs and invoke `onChange`\n * (debounced, coalesced) whenever a relevant file changes. Roots are the literal\n * directory prefixes of each glob — e.g. `features/**\\/*.feature` watches\n * `features/` recursively — deduped so nested roots aren't watched twice.\n *\n * Recursive watching is supported on macOS and Windows and on modern Linux\n * (Node ≥ 20 / Bun); on older Linux only the top level of each root is seen.\n */\nexport function watchFeatures(\n globs: string[],\n cwd: string,\n onChange: () => void,\n debounceMs = 120\n): Watcher {\n const roots = watchRoots(globs, cwd);\n const watchers: fs.FSWatcher[] = [];\n let timer: ReturnType<typeof setTimeout> | undefined;\n\n const schedule = (filename: string | null) => {\n // `fs.watch` may report a null filename; when we do get one, ignore churn\n // from unrelated files (editor swap files, `.git`, build output).\n if (filename && !WATCHED_EXT.test(filename)) return;\n if (timer) clearTimeout(timer);\n timer = setTimeout(onChange, debounceMs);\n };\n\n for (const root of roots) {\n try {\n const w = fs.watch(root, { recursive: true }, (_event, filename) =>\n schedule(filename)\n );\n w.on(\"error\", () => {}); // a removed/renamed root shouldn't crash the loop\n watchers.push(w);\n } catch {\n // Root doesn't exist yet (or can't be watched) — skip it silently.\n }\n }\n\n return {\n close() {\n if (timer) clearTimeout(timer);\n for (const w of watchers) w.close();\n },\n };\n}\n\n/**\n * The set of directories to watch: each glob's literal prefix (the path up to\n * its first magic character), resolved against `cwd`, deduped, with any root\n * that nests inside another dropped. Falls back to `cwd` when nothing resolves.\n */\nexport function watchRoots(globs: string[], cwd: string): string[] {\n const dirs = new Set<string>();\n for (const glob of globs) {\n dirs.add(path.resolve(cwd, literalPrefix(glob)));\n }\n const roots = [...dirs].sort();\n // Drop any root contained in an earlier (shorter) one, so recursive watches\n // don't overlap.\n const pruned = roots.filter(\n (r, i) => !roots.some((other, j) => j < i && isInside(r, other))\n );\n return pruned.length ? pruned : [cwd];\n}\n\n/** The directory portion of a glob before its first magic segment. */\nfunction literalPrefix(glob: string): string {\n const segments = glob.split(\"/\");\n const literal: string[] = [];\n for (const seg of segments) {\n if (MAGIC.test(seg)) break;\n literal.push(seg);\n }\n const joined = literal.join(\"/\");\n // A bare `*.feature` has no literal prefix → watch cwd (\".\").\n if (!joined) return \".\";\n // If the whole pattern was literal it points at a file; watch its directory.\n return MAGIC.test(glob) ? joined : path.dirname(joined);\n}\n\n/** True when `child` is `parent` itself or nested beneath it. */\nfunction isInside(child: string, parent: string): boolean {\n if (child === parent) return true;\n const rel = path.relative(parent, child);\n return !!rel && !rel.startsWith(\"..\") && !path.isAbsolute(rel);\n}\n","import { spawn } from \"node:child_process\";\nimport * as path from \"node:path\";\nimport { ParsedScenario } from \"../analyzer/types\";\nimport { ParsedFeature, parseFeatureCatalog } from \"../analyzer/gherkinParser\";\nimport { globFiles } from \"../globFiles\";\nimport { ResolvedConfig } from \"./config\";\nimport { Prompt, Suggestion } from \"./prompt\";\nimport { watchFeatures, Watcher } from \"./watcher\";\n\n/**\n * A population the user can pick and run: a whole tag, a whole feature file, or\n * a single scenario. Resolved against the freshly-parsed features on every run,\n * so it survives edits that shift line numbers.\n */\ntype Choice =\n | { kind: \"tag\"; tag: string }\n | { kind: \"feature\"; file: string; name: string }\n | { kind: \"scenario\"; file: string; name: string; line?: number };\n\nconst useColor =\n !process.env.NO_COLOR && (process.stdout.isTTY ?? false) === true;\nconst bold = (s: string) => (useColor ? `\\x1b[1m${s}\\x1b[22m` : s);\nconst dim = (s: string) => (useColor ? `\\x1b[2m${s}\\x1b[22m` : s);\nconst red = (s: string) => (useColor ? `\\x1b[31m${s}\\x1b[39m` : s);\nconst yellow = (s: string) => (useColor ? `\\x1b[33m${s}\\x1b[39m` : s);\n\n/**\n * Entry point for `step-forge -i`. Brings up the always-live typeahead prompt,\n * watches the configured feature/step directories, and re-runs the armed\n * population on every relevant file change. Requires a TTY.\n */\nexport async function runInteractive(config: ResolvedConfig): Promise<void> {\n if (!process.stdin.isTTY) {\n process.stderr.write(\n \"Interactive mode (-i) requires a TTY; stdin is not a terminal.\\n\"\n );\n process.exitCode = 1;\n return;\n }\n await new InteractiveSession(config).start();\n}\n\nclass InteractiveSession {\n private readonly config: ResolvedConfig;\n private readonly prompt: Prompt;\n private watcher?: Watcher;\n private catalog: ParsedFeature[] = [];\n\n // State machine: `armed` is the committed population; `dirty` means the query\n // was edited since the last commit, which suspends file-change re-runs.\n private armed: Choice | null = null;\n private dirty = false;\n private running = false;\n private rerunQueued = false;\n /** Increments per run so back-to-back identical output is still distinguishable. */\n private runCount = 0;\n\n private done!: () => void;\n\n constructor(config: ResolvedConfig) {\n this.config = config;\n this.prompt = new Prompt({\n initialQuery: config.tags ?? config.name ?? \"\",\n handlers: {\n onSubmit: value => this.onSubmit(value),\n onEdit: () => this.onEdit(),\n onEscape: () => this.onEscape(),\n onQuit: () => this.onQuit(),\n },\n });\n }\n\n async start(): Promise<void> {\n await this.rebuildCatalog();\n this.prompt.status = this.status();\n this.prompt.start();\n this.watcher = watchFeatures(\n [...this.config.features, ...this.config.steps],\n this.config.cwd,\n () => void this.onFsChange()\n );\n await new Promise<void>(resolve => {\n this.done = resolve;\n });\n }\n\n // --- prompt events -------------------------------------------------------\n private onSubmit(value: unknown | null): void {\n if (!value) return; // nothing highlighted (empty query / no matches)\n this.armed = value as Choice;\n this.dirty = false;\n this.prompt.status = this.status();\n this.triggerRun();\n }\n\n private onEdit(): void {\n // Editing the query suspends auto-runs until the next Enter re-commits.\n if (this.armed) this.dirty = true;\n this.prompt.status = this.status();\n this.prompt.redraw();\n }\n\n private onEscape(): void {\n if (!this.armed) return;\n this.armed = null;\n this.dirty = false;\n this.prompt.status = this.status();\n this.prompt.redraw();\n }\n\n private onQuit(): void {\n this.watcher?.close();\n this.prompt.stop();\n process.stdout.write(\"\\n\");\n process.exitCode = 0;\n this.done?.();\n }\n\n // --- filesystem watch ----------------------------------------------------\n private async onFsChange(): Promise<void> {\n await this.rebuildCatalog();\n if (this.armed && !this.dirty) this.triggerRun();\n }\n\n private async rebuildCatalog(): Promise<void> {\n try {\n const featureFiles = await globFiles(\n this.config.features,\n this.config.cwd\n );\n this.catalog = parseFeatureCatalog(featureFiles);\n } catch {\n // A half-written feature mid-save may fail to parse; keep the old cache.\n }\n this.prompt.setSuggestions(buildSuggestions(this.catalog));\n }\n\n // --- run cycle -----------------------------------------------------------\n private triggerRun(): void {\n if (!this.armed) return;\n if (this.running) {\n this.rerunQueued = true; // coalesce: run once more when the current ends\n return;\n }\n this.running = true;\n this.prompt.beginOutput();\n void this.runLoop();\n }\n\n private async runLoop(): Promise<void> {\n try {\n do {\n this.rerunQueued = false;\n if (this.armed) await this.executeOnce(this.armed);\n } while (this.rerunQueued && this.armed && !this.dirty);\n } catch (err) {\n process.stdout.write(\n red(`\\n run failed: ${err instanceof Error ? err.message : err}\\n`)\n );\n } finally {\n this.running = false;\n this.prompt.status = this.status();\n this.prompt.endOutput(); // redraws the prompt below the run's output\n }\n }\n\n /**\n * One run of `choice`: resolve its scenarios against the current parse, then\n * shell out to a **fresh** `step-forge` process scoped to just that\n * population. A child process is used deliberately — Bun caches ES modules for\n * the life of a process and ignores query-string cache-busting, so re-running\n * in-process would never pick up edited step code. A new process re-reads\n * every step/feature file, which is exactly what a watch loop needs.\n */\n private async executeOnce(choice: Choice): Promise<void> {\n const selected = resolveScenarios(choice, this.scenarios());\n\n const count = `${selected.length} scenario${selected.length === 1 ? \"\" : \"s\"}`;\n process.stdout.write(\n `\\n${bold(`▶ ${choiceLabel(choice)}`)} ${dim(\n `(${count} · run #${++this.runCount} · ${clock()})`\n )}\\n\\n`\n );\n\n if (selected.length === 0) {\n process.stdout.write(yellow(\" no scenarios match this selection\\n\"));\n return;\n }\n\n // A single scenario is analyzed (dependency/undefined/ambiguous checks) and\n // run verbose; a broader population uses the configured reporter.\n const single = selected.length === 1;\n if (single) await this.analyzeScenario(selected[0]);\n\n await this.spawnRun(runArgs(choice, selected[0], single, this.config));\n }\n\n /** Every scenario across the current catalog, flattened. */\n private scenarios(): ParsedScenario[] {\n return this.catalog.flatMap(f => f.scenarios);\n }\n\n /**\n * Run `step-forge` as a child process with `args`, streaming its output to the\n * terminal (where the erased prompt was). Re-invokes the very CLI that's\n * running us (`process.execPath` + `argv[1]`), so it works identically from\n * the source tree and the built bin. Never rejects — a spawn error is reported\n * and swallowed so the watch loop survives.\n */\n private spawnRun(args: string[]): Promise<void> {\n return new Promise(resolve => {\n const child = spawn(process.execPath, [process.argv[1], ...args], {\n cwd: this.config.cwd,\n // Own stdin ourselves (raw-mode prompt); let the child inherit our\n // stdout/stderr so its reporter output lands above the prompt live.\n stdio: [\"ignore\", \"inherit\", \"inherit\"],\n });\n child.on(\"error\", err => {\n process.stdout.write(red(` could not start runner: ${err.message}\\n`));\n resolve();\n });\n child.on(\"close\", () => resolve());\n });\n }\n\n /**\n * Run the static analyzer over a single scenario and print any dependency /\n * undefined / ambiguous diagnostics. The analyzer needs the optional\n * `typescript` peer for AST extraction; if it's absent we note that and skip,\n * never failing the run.\n */\n private async analyzeScenario(scenario: ParsedScenario): Promise<void> {\n let analyzer: typeof import(\"../analyzer/index\");\n try {\n analyzer = await import(\"../analyzer/index\");\n } catch {\n process.stdout.write(\n dim(\" analysis skipped: install `typescript` to enable it\\n\\n\")\n );\n return;\n }\n try {\n const stepFiles = await globFiles(this.config.steps, this.config.cwd);\n const defs = analyzer.extractStepDefinitions(stepFiles);\n const matched = analyzer.matchScenarioSteps(scenario, defs);\n const diagnostics = analyzer.defaultRules.flatMap(rule =>\n rule.check(scenario, matched)\n );\n printDiagnostics(diagnostics, this.config.cwd);\n } catch (err) {\n process.stdout.write(\n dim(\n ` analysis unavailable: ${err instanceof Error ? err.message : err}\\n\\n`\n )\n );\n }\n }\n\n // --- status line ---------------------------------------------------------\n private status(): string {\n if (!this.armed) {\n return \" type to filter · ↑↓ move · enter run · ctrl-c quit\";\n }\n if (this.dirty) {\n return \" ⏸ suspended (query edited) · enter runs the selection · esc cancel\";\n }\n return ` ▶ watching ${choiceLabel(this.armed)} · save a file to re-run · enter forces · esc change · ctrl-c quit`;\n }\n}\n\n// --- choices ---------------------------------------------------------------\n/** Build the typeahead pool: every tag, feature, and scenario in the catalog. */\nfunction buildSuggestions(catalog: ParsedFeature[]): Suggestion[] {\n const suggestions: Suggestion[] = [];\n\n const tags = new Set<string>();\n for (const feature of catalog) {\n for (const scenario of feature.scenarios) {\n for (const tag of scenario.tags) tags.add(tag);\n }\n }\n for (const tag of [...tags].sort()) {\n suggestions.push({\n badge: \"#tag\",\n label: tag,\n search: tag.toLowerCase(),\n value: { kind: \"tag\", tag } satisfies Choice,\n });\n }\n\n for (const feature of catalog) {\n const featureLabel = feature.name || path.basename(feature.file);\n suggestions.push({\n badge: \"feature\",\n label: featureLabel,\n search: `${feature.name} ${feature.file}`.toLowerCase(),\n value: {\n kind: \"feature\",\n file: feature.file,\n name: feature.name,\n } satisfies Choice,\n });\n\n for (const scenario of feature.scenarios) {\n const scenarioName = scenario.outline\n ? `${scenario.outline.name} › ${scenario.name}`\n : scenario.name;\n suggestions.push({\n badge: \"scenario\",\n label: scenarioName,\n search: `${featureLabel} ${scenarioName}`.toLowerCase(),\n value: {\n kind: \"scenario\",\n file: scenario.file,\n name: scenario.name,\n line: scenario.line,\n } satisfies Choice,\n });\n }\n }\n\n return suggestions;\n}\n\n/** Resolve a choice to its scenarios against the current parse. */\nfunction resolveScenarios(\n choice: Choice,\n scenarios: ParsedScenario[]\n): ParsedScenario[] {\n switch (choice.kind) {\n case \"tag\":\n return scenarios.filter(s => s.tags.includes(choice.tag));\n case \"feature\":\n return scenarios.filter(s => s.file === choice.file);\n case \"scenario\":\n return scenarios.filter(\n s =>\n s.file === choice.file &&\n s.name === choice.name &&\n (choice.line === undefined || s.line === choice.line)\n );\n }\n}\n\nfunction choiceLabel(choice: Choice): string {\n switch (choice.kind) {\n case \"tag\":\n return choice.tag;\n case \"feature\":\n return choice.name || path.basename(choice.file);\n case \"scenario\":\n return choice.name;\n }\n}\n\n/**\n * The `step-forge` argv that reproduces this selection in a child process. The\n * base flags forward the resolved config (steps/world/concurrency) so the child\n * matches the parent's setup regardless of its own config file; the scope flags\n * narrow to the chosen population:\n * - tag → all configured features, filtered by `-t <tag>`\n * - feature → that single feature file\n * - scenario → that feature file, name-anchored with `-n \"/^…$/\"`\n * A single scenario runs verbose; a population uses the configured reporter.\n */\nfunction runArgs(\n choice: Choice,\n first: ParsedScenario,\n single: boolean,\n config: ResolvedConfig\n): string[] {\n const args: string[] = [];\n for (const glob of config.steps) args.push(\"-s\", glob);\n if (config.world) args.push(\"-w\", config.world);\n args.push(\"-c\", String(config.concurrency));\n\n switch (choice.kind) {\n case \"tag\":\n args.push(...config.features, \"-t\", choice.tag);\n break;\n case \"feature\":\n args.push(choice.file);\n break;\n case \"scenario\":\n args.push(choice.file, \"-n\", `/^${escapeRegExp(first.name)}$/`);\n break;\n }\n\n if (single) {\n args.push(\"-v\");\n } else {\n args.push(\"-r\", config.reporter);\n if (config.verbose) args.push(\"-v\");\n }\n return args;\n}\n\n/** Escape a scenario name for use inside an anchored `-n` regex. */\nfunction escapeRegExp(text: string): string {\n return text.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n\n/** Local wall-clock time as `HH:MM:SS`, so each run's header is dated. */\nfunction clock(): string {\n const d = new Date();\n return [d.getHours(), d.getMinutes(), d.getSeconds()]\n .map(n => String(n).padStart(2, \"0\"))\n .join(\":\");\n}\n\n// --- diagnostics -----------------------------------------------------------\nfunction printDiagnostics(\n diagnostics: import(\"../analyzer/types\").Diagnostic[],\n cwd: string\n): void {\n if (diagnostics.length === 0) return; // clean scenario: say nothing, let the run speak\n process.stdout.write(bold(\" analyzer:\\n\"));\n for (const d of diagnostics) {\n const mark =\n d.severity === \"error\"\n ? red(\"✗\")\n : d.severity === \"warning\"\n ? yellow(\"!\")\n : dim(\"i\");\n const loc = `${path.relative(cwd, d.file)}:${d.range.startLine}`;\n process.stdout.write(` ${mark} ${d.message} ${dim(`(${loc})`)}\\n`);\n }\n process.stdout.write(\"\\n\");\n}\n","#!/usr/bin/env bun\nimport { parseArgs } from \"node:util\";\nimport * as path from \"node:path\";\nimport { loadConfigFile, resolveConfig, RunnerOptions } from \"./config\";\nimport { run } from \"./runner\";\nimport { runInteractive } from \"./interactive\";\n\nconst HELP = `step-forge — native TypeScript runner for Gherkin step definitions\n\nUsage:\n step-forge [options] [feature globs...]\n\nOptions:\n -t, --tags <expr> Tag expression, e.g. \"@smoke and not @wip\"\n -n, --name <pattern> Only scenarios whose name matches (substring or /regex/)\n -s, --steps <glob> Step-definition module glob (repeatable)\n -w, --world <module> World factory module (default export () => world)\n -c, --concurrency <n> Max scenarios in flight (default: 1, i.e. serial)\n -r, --reporter <name> \"pretty\" (default) or \"progress\"\n -v, --verbose Report every scenario, not just failures\n -i, --interactive Interactive watch mode: pick a tag/feature/scenario\n and re-run it on every file change\n --config <path> Config file directory (default: cwd)\n -h, --help Show this help\n\nPositional arguments are feature globs and override the configured features.\n`;\n\n/** Parse argv into config overrides. Positional args become feature globs. */\nfunction parseCli(argv: string[]): {\n cwd: string;\n overrides: RunnerOptions;\n interactive: boolean;\n} {\n const { values, positionals } = parseArgs({\n args: argv,\n allowPositionals: true,\n options: {\n tags: { type: \"string\", short: \"t\" },\n name: { type: \"string\", short: \"n\" },\n steps: { type: \"string\", short: \"s\", multiple: true },\n world: { type: \"string\", short: \"w\" },\n concurrency: { type: \"string\", short: \"c\" },\n reporter: { type: \"string\", short: \"r\" },\n verbose: { type: \"boolean\", short: \"v\" },\n interactive: { type: \"boolean\", short: \"i\" },\n config: { type: \"string\" },\n help: { type: \"boolean\", short: \"h\" },\n },\n });\n\n if (values.help) {\n process.stdout.write(HELP);\n process.exit(0);\n }\n\n const overrides: RunnerOptions = {};\n if (positionals.length) overrides.features = positionals;\n if (values.tags) overrides.tags = values.tags;\n if (values.name) overrides.name = values.name;\n if (values.steps) overrides.steps = values.steps;\n if (values.world) overrides.world = values.world;\n if (values.verbose) overrides.verbose = true;\n if (values.reporter) {\n if (values.reporter !== \"pretty\" && values.reporter !== \"progress\") {\n throw new Error(`Unknown reporter: ${values.reporter}`);\n }\n overrides.reporter = values.reporter;\n }\n if (values.concurrency !== undefined) {\n const n = Number(values.concurrency);\n if (!Number.isInteger(n) || n < 1) {\n throw new Error(`--concurrency must be a positive integer`);\n }\n overrides.concurrency = n;\n }\n\n const cwd = values.config\n ? path.resolve(process.cwd(), values.config)\n : process.cwd();\n return { cwd, overrides, interactive: values.interactive ?? false };\n}\n\nasync function main(): Promise<void> {\n const { cwd, overrides, interactive } = parseCli(process.argv.slice(2));\n const fileConfig = await loadConfigFile(cwd);\n const config = resolveConfig(cwd, fileConfig, overrides);\n if (interactive) {\n await runInteractive(config);\n return; // interactive mode manages its own lifecycle and exit code\n }\n const { passed } = await run(config);\n process.exitCode = passed ? 0 : 1;\n}\n\nmain().catch(err => {\n process.stderr.write(`${err instanceof Error ? err.stack : String(err)}\\n`);\n process.exitCode = 1;\n});\n"],"mappings":";;;;;;;;;;;;;AAqDA,MAAM,mBAAmB;AACzB,MAAM,gBAAgB;AACtB,MAAM,mBAAmB;CACvB;CACA;CACA;CACA;AACF;AAEA,SAAS,QAAW,OAAiC;CACnD,IAAI,UAAU,KAAA,GAAW,OAAO,CAAC;CACjC,OAAO,MAAM,QAAQ,KAAK,IAAI,QAAQ,CAAC,KAAK;AAC9C;AAEA,eAAe,OAAO,GAA6B;CACjD,IAAI;EACF,MAAM,OAAO,CAAC;EACd,OAAO;CACT,QAAQ;EACN,OAAO;CACT;AACF;;;;;;AAOA,eAAsB,eAAe,KAAqC;CACxE,KAAK,MAAM,YAAY,kBAAkB;EACvC,MAAM,YAAY,KAAK,KAAK,KAAK,QAAQ;EACzC,IAAI,CAAE,MAAM,OAAO,SAAS,GAAI;EAChC,MAAM,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SAAS,IAAI;AAClC;AAEA,KAAK,CAAC,CAAC,OAAM,QAAO;CAClB,QAAQ,OAAO,MAAM,GAAG,eAAe,QAAQ,IAAI,QAAQ,OAAO,GAAG,EAAE,GAAG;CAC1E,QAAQ,WAAW;AACrB,CAAC"}
@@ -5,6 +5,15 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
6
  var __getProtoOf = Object.getPrototypeOf;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __exportAll = (all, no_symbols) => {
9
+ let target = {};
10
+ for (var name in all) __defProp(target, name, {
11
+ get: all[name],
12
+ enumerable: true
13
+ });
14
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
15
+ return target;
16
+ };
8
17
  var __copyProps = (to, from, except, desc) => {
9
18
  if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
19
  key = keys[i];
@@ -177,8 +186,31 @@ function parseFeatureFiles(filePaths) {
177
186
  }
178
187
  return scenarios;
179
188
  }
189
+ /** Build a fresh gherkin parser and parse `content` into a document. */
190
+ function parseDocument(content) {
191
+ return new _cucumber_gherkin.Parser(new _cucumber_gherkin.AstBuilder(_cucumber_messages.IdGenerator.uuid()), new _cucumber_gherkin.GherkinClassicTokenMatcher()).parse(content);
192
+ }
193
+ /**
194
+ * Parse feature files into a catalog of `{ file, name, scenarios }`, one entry
195
+ * per file (one gherkin parse each). Used by interactive mode to offer
196
+ * feature/scenario names as typeahead choices labelled by their `Feature:` title.
197
+ */
198
+ function parseFeatureCatalog(filePaths) {
199
+ return filePaths.map((file) => {
200
+ const document = parseDocument(node_fs.readFileSync(file, "utf-8"));
201
+ return {
202
+ file,
203
+ name: document.feature?.name ?? "",
204
+ scenarios: documentToScenarios(document, file)
205
+ };
206
+ });
207
+ }
180
208
  function parseFeatureContent(content, filePath) {
181
- const feature = new _cucumber_gherkin.Parser(new _cucumber_gherkin.AstBuilder(_cucumber_messages.IdGenerator.uuid()), new _cucumber_gherkin.GherkinClassicTokenMatcher()).parse(content).feature;
209
+ return documentToScenarios(parseDocument(content), filePath);
210
+ }
211
+ /** Expand a parsed gherkin document into scenarios (outline rows included). */
212
+ function documentToScenarios(gherkinDocument, filePath) {
213
+ const feature = gherkinDocument.feature;
182
214
  if (!feature) return [];
183
215
  const featureBackground = [];
184
216
  const scenarios = [];
@@ -286,6 +318,12 @@ Object.defineProperty(exports, "BasicWorld", {
286
318
  return BasicWorld;
287
319
  }
288
320
  });
321
+ Object.defineProperty(exports, "__exportAll", {
322
+ enumerable: true,
323
+ get: function() {
324
+ return __exportAll;
325
+ }
326
+ });
289
327
  Object.defineProperty(exports, "__toESM", {
290
328
  enumerable: true,
291
329
  get: function() {
@@ -304,6 +342,12 @@ Object.defineProperty(exports, "globFiles", {
304
342
  return globFiles;
305
343
  }
306
344
  });
345
+ Object.defineProperty(exports, "parseFeatureCatalog", {
346
+ enumerable: true,
347
+ get: function() {
348
+ return parseFeatureCatalog;
349
+ }
350
+ });
307
351
  Object.defineProperty(exports, "parseFeatureContent", {
308
352
  enumerable: true,
309
353
  get: function() {
@@ -335,4 +379,4 @@ Object.defineProperty(exports, "userFrames", {
335
379
  }
336
380
  });
337
381
 
338
- //# sourceMappingURL=gherkinParser-BT40q_i3.cjs.map
382
+ //# sourceMappingURL=gherkinParser-_ZgvELdy.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gherkinParser-_ZgvELdy.cjs","names":["path","_","path","fs","Parser","AstBuilder","messages","GherkinClassicTokenMatcher"],"sources":["../../src/sourceLocation.ts","../../src/world.ts","../../src/globFiles.ts","../../src/analyzer/gherkinParser.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/**\n * Directory holding the library's own compiled code. In development this is the\n * `src/` tree; in the published package it's `dist/` (this module is bundled\n * into the shipped chunks). Stack frames under it are internal plumbing —\n * builders, the engine, the runner — and are hidden from users so that a\n * failure points at *their* step, not ours.\n */\nconst LIB_ROOT = path.dirname(fileURLToPath(import.meta.url));\n\nexport interface SourceFrame {\n file: string;\n line: number;\n column: number;\n}\n\n/**\n * A frame belongs to user code if it's an absolute path that is neither inside\n * the library nor inside any `node_modules` (assertion libs, etc.). That leaves\n * exactly the frames a user cares about: their own step definitions.\n */\nfunction isUserFile(file: string): boolean {\n return (\n path.isAbsolute(file) &&\n !file.startsWith(LIB_ROOT + path.sep) &&\n !file.includes(`${path.sep}node_modules${path.sep}`)\n );\n}\n\n/** Parse one `Error.stack` line into a frame, tolerating V8/Bun variations. */\nfunction parseFrame(frameLine: string): SourceFrame | undefined {\n const m = /:(\\d+):(\\d+)\\)?\\s*$/.exec(frameLine);\n if (!m) return undefined;\n let file = frameLine.slice(0, m.index);\n const paren = file.lastIndexOf(\"(\");\n if (paren !== -1) file = file.slice(paren + 1);\n file = file.trim().replace(/^at\\s+/, \"\");\n if (file.startsWith(\"file://\")) {\n try {\n file = fileURLToPath(file);\n } catch {\n return undefined;\n }\n }\n return { file, line: Number(m[1]), column: Number(m[2]) };\n}\n\n/** Every user-code frame in a stack, nearest-first, internals removed. */\nexport function userFrames(stack: string | undefined): SourceFrame[] {\n if (!stack) return [];\n const frames: SourceFrame[] = [];\n for (const line of stack.split(\"\\n\")) {\n const frame = parseFrame(line);\n if (frame && isUserFile(frame.file)) frames.push(frame);\n }\n return frames;\n}\n\n/**\n * Capture the user source location of the current call site — the first\n * user-code frame above this function. Called from `.step()` registration so\n * each step remembers where it was defined (Cucumber-style), independent of\n * where an error is later thrown. Returns an absolute `file:line:column`, or\n * `undefined` if no user frame is visible.\n */\nexport function captureDefinitionSite(): string | undefined {\n const frame = userFrames(new Error().stack)[0];\n return frame ? `${frame.file}:${frame.line}:${frame.column}` : undefined;\n}\n\n/** Render an absolute `file:line:column` relative to `cwd` for display. */\nexport function relativeLocation(location: string, cwd: string): string {\n const m = /^(.*):(\\d+):(\\d+)$/.exec(location);\n if (!m) return location;\n return `${path.relative(cwd, m[1])}:${m[2]}:${m[3]}`;\n}\n\n/** Render a frame relative to `cwd`. */\nexport function relativeFrame(frame: SourceFrame, cwd: string): string {\n return `${path.relative(cwd, frame.file)}:${frame.line}:${frame.column}`;\n}\n","import _ from \"lodash\";\n\nexport type WorldState<State> = {\n readonly [K in keyof State]?: State[K];\n};\n\nexport type MergeableWorldState<T> = WorldState<T> & {\n merge: (newState: Partial<T>) => void;\n};\n\nfunction mergeCustomizer(objValue: unknown, srcValue: unknown) {\n if (_.isArray(objValue)) {\n return objValue.concat(srcValue);\n } else if (objValue && !_.isPlainObject(objValue) && objValue !== srcValue) {\n throw new Error(\n `Merge would have destroyed previous value ${objValue} with ${srcValue}`\n );\n }\n return objValue;\n}\n\nexport const createMergeableState = <T>(\n state: WorldState<T>\n): MergeableWorldState<T> => {\n return {\n ...state,\n merge: (newState: Partial<T>) => {\n state = _.merge({ ...state }, newState, mergeCustomizer);\n },\n };\n};\n\nexport type MergeableWorld<Given, When, Then> = {\n given: MergeableWorldState<Given>;\n when: MergeableWorldState<When>;\n then: MergeableWorldState<Then>;\n};\n\nexport class BasicWorld<Given, When, Then> {\n private givenState: WorldState<Given> = {};\n private whenState: WorldState<When> = {};\n private thenState: WorldState<Then> = {};\n\n public get given(): MergeableWorldState<Given> {\n return {\n ...this.givenState,\n merge: (newState: Partial<Given>) => {\n this.givenState = _.merge(\n { ...this.givenState },\n newState,\n mergeCustomizer\n );\n },\n };\n }\n\n public get when(): MergeableWorldState<When> {\n return {\n ...this.whenState,\n merge: (newState: Partial<When>) => {\n this.whenState = _.merge(\n { ...this.whenState },\n newState,\n mergeCustomizer\n );\n },\n };\n }\n\n public get then(): MergeableWorldState<Then> {\n return {\n ...this.thenState,\n merge: (newState: Partial<Then>) => {\n this.thenState = _.merge(\n { ...this.thenState },\n newState,\n mergeCustomizer\n );\n },\n };\n }\n}\n\nexport const createBasicWorld = <Given, When, Then>(): MergeableWorld<\n Given,\n When,\n Then\n> => {\n return new BasicWorld<Given, When, Then>();\n};\n","import { glob } from \"node:fs/promises\";\nimport { stat } from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\n/** Glob metacharacters. A pattern with none of these is a literal path. */\nconst MAGIC = /[*?[\\]{}!()]/;\n\nasync function isFile(p: string): Promise<boolean> {\n try {\n return (await stat(p)).isFile();\n } catch {\n return false;\n }\n}\n\n/**\n * Resolve glob patterns to a de-duplicated list of absolute file paths, with one\n * important portability guarantee: a **literal absolute path** (no glob magic)\n * is returned directly if it exists, without being handed to `glob()`.\n *\n * This exists because `node:fs`'s `glob` diverges between runtimes — Node\n * matches an absolute-path pattern, Bun returns nothing for one. Rather than\n * depend on that behaviour, we only ever glob relative patterns (against `cwd`)\n * and short-circuit concrete absolute paths ourselves, so callers get identical\n * results under Node and Bun.\n */\nexport async function globFiles(\n patterns: string[],\n cwd: string = process.cwd()\n): Promise<string[]> {\n const files = new Set<string>();\n for (const pattern of patterns) {\n if (path.isAbsolute(pattern) && !MAGIC.test(pattern)) {\n if (await isFile(pattern)) files.add(pattern);\n continue;\n }\n for await (const match of glob(pattern, { cwd })) {\n files.add(path.resolve(cwd, match));\n }\n }\n return [...files];\n}\n","import * as fs from \"node:fs\";\nimport {\n GherkinClassicTokenMatcher,\n Parser,\n AstBuilder,\n} from \"@cucumber/gherkin\";\nimport * as messages from \"@cucumber/messages\";\nimport { ParsedScenario, ParsedStep } from \"./types.js\";\n\ntype GherkinKeyword = \"Given\" | \"When\" | \"Then\" | \"And\" | \"But\";\n\nexport function parseFeatureFiles(filePaths: string[]): ParsedScenario[] {\n const scenarios: ParsedScenario[] = [];\n\n for (const filePath of filePaths) {\n const content = fs.readFileSync(filePath, \"utf-8\");\n const parsed = parseFeatureContent(content, filePath);\n scenarios.push(...parsed);\n }\n\n return scenarios;\n}\n\n/**\n * One parsed feature file: its `Feature:` title (empty if unnamed) plus every\n * scenario (outline rows expanded). {@link parseFeatureContent} exposes just the\n * scenarios; {@link parseFeatureCatalog} keeps the title too, for UIs that label\n * scenarios by their feature.\n */\nexport interface ParsedFeature {\n file: string;\n name: string;\n scenarios: ParsedScenario[];\n}\n\n/** Build a fresh gherkin parser and parse `content` into a document. */\nfunction parseDocument(content: string): messages.GherkinDocument {\n const builder = new AstBuilder(messages.IdGenerator.uuid());\n const matcher = new GherkinClassicTokenMatcher();\n return new Parser(builder, matcher).parse(content);\n}\n\n/**\n * Parse feature files into a catalog of `{ file, name, scenarios }`, one entry\n * per file (one gherkin parse each). Used by interactive mode to offer\n * feature/scenario names as typeahead choices labelled by their `Feature:` title.\n */\nexport function parseFeatureCatalog(filePaths: string[]): ParsedFeature[] {\n return filePaths.map(file => {\n const document = parseDocument(fs.readFileSync(file, \"utf-8\"));\n return {\n file,\n name: document.feature?.name ?? \"\",\n scenarios: documentToScenarios(document, file),\n };\n });\n}\n\nexport function parseFeatureContent(\n content: string,\n filePath: string\n): ParsedScenario[] {\n return documentToScenarios(parseDocument(content), filePath);\n}\n\n/** Expand a parsed gherkin document into scenarios (outline rows included). */\nfunction documentToScenarios(\n gherkinDocument: messages.GherkinDocument,\n filePath: string\n): ParsedScenario[] {\n const feature = gherkinDocument.feature;\n if (!feature) return [];\n\n // Collect background steps at the feature level\n const featureBackground: messages.Step[] = [];\n const scenarios: ParsedScenario[] = [];\n const featureTags = tagNames(feature.tags);\n\n for (const child of feature.children) {\n if (child.background) {\n featureBackground.push(...child.background.steps);\n }\n\n if (child.scenario) {\n scenarios.push(\n ...expandScenario(\n child.scenario,\n featureBackground,\n filePath,\n featureTags\n )\n );\n }\n\n if (child.rule) {\n // Rules can have their own backgrounds and tags, both inherited by the\n // rule's scenarios.\n const ruleBackground: messages.Step[] = [...featureBackground];\n const ruleTags = [...featureTags, ...tagNames(child.rule.tags)];\n for (const ruleChild of child.rule.children) {\n if (ruleChild.background) {\n ruleBackground.push(...ruleChild.background.steps);\n }\n if (ruleChild.scenario) {\n scenarios.push(\n ...expandScenario(\n ruleChild.scenario,\n ruleBackground,\n filePath,\n ruleTags\n )\n );\n }\n }\n }\n }\n\n return scenarios;\n}\n\n/** Extract tag names (each keeping its leading `@`), deduped in order. */\nfunction tagNames(tags: readonly messages.Tag[] | undefined): string[] {\n return [...new Set((tags ?? []).map(t => t.name))];\n}\n\nfunction expandScenario(\n scenario: messages.Scenario,\n backgroundSteps: messages.Step[],\n filePath: string,\n inheritedTags: string[]\n): ParsedScenario[] {\n const scenarioTags = [...inheritedTags, ...tagNames(scenario.tags)];\n const hasExamples =\n scenario.examples.length > 0 &&\n scenario.examples.some(e => e.tableBody.length > 0);\n\n if (!hasExamples) {\n // Regular scenario\n const bgParsed = convertSteps(backgroundSteps);\n const scenarioParsed = convertSteps(scenario.steps);\n const allSteps = resolveEffectiveKeywords([...bgParsed, ...scenarioParsed]);\n\n return [\n {\n name: scenario.name,\n file: filePath,\n line: scenario.location.line,\n steps: allSteps,\n tags: scenarioTags,\n },\n ];\n }\n\n // Scenario Outline — expand with each example row. Rows carry the outline's\n // base name so the runner can group them, plus the Examples-block tags.\n const results: ParsedScenario[] = [];\n for (const example of scenario.examples) {\n if (!example.tableHeader || example.tableBody.length === 0) continue;\n const headers = example.tableHeader.cells.map(c => c.value);\n const exampleTags = [...scenarioTags, ...tagNames(example.tags)];\n\n for (const row of example.tableBody) {\n const values = row.cells.map(c => c.value);\n const substitution: Record<string, string> = {};\n headers.forEach((h, i) => {\n substitution[h] = values[i];\n });\n\n const bgParsed = convertSteps(backgroundSteps);\n const scenarioSteps = convertSteps(scenario.steps).map(step => ({\n ...step,\n text: substituteExampleValues(step.text, substitution),\n }));\n const allSteps = resolveEffectiveKeywords([\n ...bgParsed,\n ...scenarioSteps,\n ]);\n\n results.push({\n name: headers.map((h, i) => `${h}=${values[i]}`).join(\", \"),\n file: filePath,\n line: row.location.line,\n steps: allSteps,\n tags: exampleTags,\n outline: { name: scenario.name },\n });\n }\n }\n\n return results;\n}\n\nfunction convertSteps(\n steps: readonly messages.Step[]\n): Omit<ParsedStep, \"effectiveKeyword\">[] {\n return steps.map(step => ({\n keyword: normalizeKeyword(step.keyword),\n text: step.text,\n line: step.location.line,\n // step.location.column points to the keyword start; shift past the\n // keyword (which includes a trailing space) so column points to the\n // start of the step text. This makes `column + text.length` produce\n // the correct end position for diagnostic ranges.\n column: (step.location.column ?? 1) + step.keyword.length,\n }));\n}\n\nfunction normalizeKeyword(keyword: string): GherkinKeyword {\n const trimmed = keyword.trim();\n // Gherkin keywords may include trailing space, e.g. \"Given \"\n if (trimmed === \"Given\") return \"Given\";\n if (trimmed === \"When\") return \"When\";\n if (trimmed === \"Then\") return \"Then\";\n if (trimmed === \"And\") return \"And\";\n if (trimmed === \"But\") return \"But\";\n // Fallback: treat as Given (shouldn't happen with valid Gherkin)\n return \"Given\";\n}\n\nfunction resolveEffectiveKeywords(\n steps: Omit<ParsedStep, \"effectiveKeyword\">[]\n): ParsedStep[] {\n let lastEffective: \"Given\" | \"When\" | \"Then\" = \"Given\";\n\n return steps.map(step => {\n let effectiveKeyword: \"Given\" | \"When\" | \"Then\";\n if (step.keyword === \"And\" || step.keyword === \"But\") {\n effectiveKeyword = lastEffective;\n } else {\n effectiveKeyword = step.keyword as \"Given\" | \"When\" | \"Then\";\n }\n lastEffective = effectiveKeyword;\n\n return {\n ...step,\n effectiveKeyword,\n };\n });\n}\n\nfunction substituteExampleValues(\n text: string,\n substitution: Record<string, string>\n): string {\n let result = text;\n for (const [key, value] of Object.entries(substitution)) {\n result = result.replace(new RegExp(`<${key}>`, \"g\"), value);\n }\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAM,WAAWA,UAAK,SAAA,GAAA,SAAA,cAAA,CAAA,QAAA,KAAA,CAAA,CAAA,cAAA,UAAA,CAAA,CAAA,IAAqC,CAAC;;;;;;AAa5D,SAAS,WAAW,MAAuB;CACzC,OACEA,UAAK,WAAW,IAAI,KACpB,CAAC,KAAK,WAAW,WAAWA,U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,SAAS,KAAK,YAAY,OAC7C,mBAAmB;OAEnB,mBAAmB,KAAK;EAE1B,gBAAgB;EAEhB,OAAO;GACL,GAAG;GACH;EACF;CACF,CAAC;AACH;AAEA,SAAS,wBACP,MACA,cACQ;CACR,IAAI,SAAS;CACb,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,YAAY,GACpD,SAAS,OAAO,QAAQ,IAAI,OAAO,IAAI,IAAI,IAAI,GAAG,GAAG,KAAK;CAE5D,OAAO;AACT"}
@@ -151,8 +151,31 @@ function parseFeatureFiles(filePaths) {
151
151
  }
152
152
  return scenarios;
153
153
  }
154
+ /** Build a fresh gherkin parser and parse `content` into a document. */
155
+ function parseDocument(content) {
156
+ return new Parser(new AstBuilder(messages.IdGenerator.uuid()), new GherkinClassicTokenMatcher()).parse(content);
157
+ }
158
+ /**
159
+ * Parse feature files into a catalog of `{ file, name, scenarios }`, one entry
160
+ * per file (one gherkin parse each). Used by interactive mode to offer
161
+ * feature/scenario names as typeahead choices labelled by their `Feature:` title.
162
+ */
163
+ function parseFeatureCatalog(filePaths) {
164
+ return filePaths.map((file) => {
165
+ const document = parseDocument(fs.readFileSync(file, "utf-8"));
166
+ return {
167
+ file,
168
+ name: document.feature?.name ?? "",
169
+ scenarios: documentToScenarios(document, file)
170
+ };
171
+ });
172
+ }
154
173
  function parseFeatureContent(content, filePath) {
155
- const feature = new Parser(new AstBuilder(messages.IdGenerator.uuid()), new GherkinClassicTokenMatcher()).parse(content).feature;
174
+ return documentToScenarios(parseDocument(content), filePath);
175
+ }
176
+ /** Expand a parsed gherkin document into scenarios (outline rows included). */
177
+ function documentToScenarios(gherkinDocument, filePath) {
178
+ const feature = gherkinDocument.feature;
156
179
  if (!feature) return [];
157
180
  const featureBackground = [];
158
181
  const scenarios = [];
@@ -254,6 +277,6 @@ function substituteExampleValues(text, substitution) {
254
277
  return result;
255
278
  }
256
279
  //#endregion
257
- export { captureDefinitionSite as a, userFrames as c, BasicWorld as i, parseFeatureFiles as n, relativeFrame as o, globFiles as r, relativeLocation as s, parseFeatureContent as t };
280
+ export { BasicWorld as a, relativeLocation as c, globFiles as i, userFrames as l, parseFeatureContent as n, captureDefinitionSite as o, parseFeatureFiles as r, relativeFrame as s, parseFeatureCatalog as t };
258
281
 
259
- //# sourceMappingURL=gherkinParser-NcttZgN4.js.map
282
+ //# sourceMappingURL=gherkinParser-i-Q7M6mi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gherkinParser-i-Q7M6mi.js","names":[],"sources":["../../src/sourceLocation.ts","../../src/world.ts","../../src/globFiles.ts","../../src/analyzer/gherkinParser.ts"],"sourcesContent":["import * as path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\n/**\n * Directory holding the library's own compiled code. In development this is the\n * `src/` tree; in the published package it's `dist/` (this module is bundled\n * into the shipped chunks). Stack frames under it are internal plumbing —\n * builders, the engine, the runner — and are hidden from users so that a\n * failure points at *their* step, not ours.\n */\nconst LIB_ROOT = path.dirname(fileURLToPath(import.meta.url));\n\nexport interface SourceFrame {\n file: string;\n line: number;\n column: number;\n}\n\n/**\n * A frame belongs to user code if it's an absolute path that is neither inside\n * the library nor inside any `node_modules` (assertion libs, etc.). That leaves\n * exactly the frames a user cares about: their own step definitions.\n */\nfunction isUserFile(file: string): boolean {\n return (\n path.isAbsolute(file) &&\n !file.startsWith(LIB_ROOT + path.sep) &&\n !file.includes(`${path.sep}node_modules${path.sep}`)\n );\n}\n\n/** Parse one `Error.stack` line into a frame, tolerating V8/Bun variations. */\nfunction parseFrame(frameLine: string): SourceFrame | undefined {\n const m = /:(\\d+):(\\d+)\\)?\\s*$/.exec(frameLine);\n if (!m) return undefined;\n let file = frameLine.slice(0, m.index);\n const paren = file.lastIndexOf(\"(\");\n if (paren !== -1) file = file.slice(paren + 1);\n file = file.trim().replace(/^at\\s+/, \"\");\n if (file.startsWith(\"file://\")) {\n try {\n file = fileURLToPath(file);\n } catch {\n return undefined;\n }\n }\n return { file, line: Number(m[1]), column: Number(m[2]) };\n}\n\n/** Every user-code frame in a stack, nearest-first, internals removed. */\nexport function userFrames(stack: string | undefined): SourceFrame[] {\n if (!stack) return [];\n const frames: SourceFrame[] = [];\n for (const line of stack.split(\"\\n\")) {\n const frame = parseFrame(line);\n if (frame && isUserFile(frame.file)) frames.push(frame);\n }\n return frames;\n}\n\n/**\n * Capture the user source location of the current call site — the first\n * user-code frame above this function. Called from `.step()` registration so\n * each step remembers where it was defined (Cucumber-style), independent of\n * where an error is later thrown. Returns an absolute `file:line:column`, or\n * `undefined` if no user frame is visible.\n */\nexport function captureDefinitionSite(): string | undefined {\n const frame = userFrames(new Error().stack)[0];\n return frame ? `${frame.file}:${frame.line}:${frame.column}` : undefined;\n}\n\n/** Render an absolute `file:line:column` relative to `cwd` for display. */\nexport function relativeLocation(location: string, cwd: string): string {\n const m = /^(.*):(\\d+):(\\d+)$/.exec(location);\n if (!m) return location;\n return `${path.relative(cwd, m[1])}:${m[2]}:${m[3]}`;\n}\n\n/** Render a frame relative to `cwd`. */\nexport function relativeFrame(frame: SourceFrame, cwd: string): string {\n return `${path.relative(cwd, frame.file)}:${frame.line}:${frame.column}`;\n}\n","import _ from \"lodash\";\n\nexport type WorldState<State> = {\n readonly [K in keyof State]?: State[K];\n};\n\nexport type MergeableWorldState<T> = WorldState<T> & {\n merge: (newState: Partial<T>) => void;\n};\n\nfunction mergeCustomizer(objValue: unknown, srcValue: unknown) {\n if (_.isArray(objValue)) {\n return objValue.concat(srcValue);\n } else if (objValue && !_.isPlainObject(objValue) && objValue !== srcValue) {\n throw new Error(\n `Merge would have destroyed previous value ${objValue} with ${srcValue}`\n );\n }\n return objValue;\n}\n\nexport const createMergeableState = <T>(\n state: WorldState<T>\n): MergeableWorldState<T> => {\n return {\n ...state,\n merge: (newState: Partial<T>) => {\n state = _.merge({ ...state }, newState, mergeCustomizer);\n },\n };\n};\n\nexport type MergeableWorld<Given, When, Then> = {\n given: MergeableWorldState<Given>;\n when: MergeableWorldState<When>;\n then: MergeableWorldState<Then>;\n};\n\nexport class BasicWorld<Given, When, Then> {\n private givenState: WorldState<Given> = {};\n private whenState: WorldState<When> = {};\n private thenState: WorldState<Then> = {};\n\n public get given(): MergeableWorldState<Given> {\n return {\n ...this.givenState,\n merge: (newState: Partial<Given>) => {\n this.givenState = _.merge(\n { ...this.givenState },\n newState,\n mergeCustomizer\n );\n },\n };\n }\n\n public get when(): MergeableWorldState<When> {\n return {\n ...this.whenState,\n merge: (newState: Partial<When>) => {\n this.whenState = _.merge(\n { ...this.whenState },\n newState,\n mergeCustomizer\n );\n },\n };\n }\n\n public get then(): MergeableWorldState<Then> {\n return {\n ...this.thenState,\n merge: (newState: Partial<Then>) => {\n this.thenState = _.merge(\n { ...this.thenState },\n newState,\n mergeCustomizer\n );\n },\n };\n }\n}\n\nexport const createBasicWorld = <Given, When, Then>(): MergeableWorld<\n Given,\n When,\n Then\n> => {\n return new BasicWorld<Given, When, Then>();\n};\n","import { glob } from \"node:fs/promises\";\nimport { stat } from \"node:fs/promises\";\nimport * as path from \"node:path\";\n\n/** Glob metacharacters. A pattern with none of these is a literal path. */\nconst MAGIC = /[*?[\\]{}!()]/;\n\nasync function isFile(p: string): Promise<boolean> {\n try {\n return (await stat(p)).isFile();\n } catch {\n return false;\n }\n}\n\n/**\n * Resolve glob patterns to a de-duplicated list of absolute file paths, with one\n * important portability guarantee: a **literal absolute path** (no glob magic)\n * is returned directly if it exists, without being handed to `glob()`.\n *\n * This exists because `node:fs`'s `glob` diverges between runtimes — Node\n * matches an absolute-path pattern, Bun returns nothing for one. Rather than\n * depend on that behaviour, we only ever glob relative patterns (against `cwd`)\n * and short-circuit concrete absolute paths ourselves, so callers get identical\n * results under Node and Bun.\n */\nexport async function globFiles(\n patterns: string[],\n cwd: string = process.cwd()\n): Promise<string[]> {\n const files = new Set<string>();\n for (const pattern of patterns) {\n if (path.isAbsolute(pattern) && !MAGIC.test(pattern)) {\n if (await isFile(pattern)) files.add(pattern);\n continue;\n }\n for await (const match of glob(pattern, { cwd })) {\n files.add(path.resolve(cwd, match));\n }\n }\n return [...files];\n}\n","import * as fs from \"node:fs\";\nimport {\n GherkinClassicTokenMatcher,\n Parser,\n AstBuilder,\n} from \"@cucumber/gherkin\";\nimport * as messages from \"@cucumber/messages\";\nimport { ParsedScenario, ParsedStep } from \"./types.js\";\n\ntype GherkinKeyword = \"Given\" | \"When\" | \"Then\" | \"And\" | \"But\";\n\nexport function parseFeatureFiles(filePaths: string[]): ParsedScenario[] {\n const scenarios: ParsedScenario[] = [];\n\n for (const filePath of filePaths) {\n const content = fs.readFileSync(filePath, \"utf-8\");\n const parsed = parseFeatureContent(content, filePath);\n scenarios.push(...parsed);\n }\n\n return scenarios;\n}\n\n/**\n * One parsed feature file: its `Feature:` title (empty if unnamed) plus every\n * scenario (outline rows expanded). {@link parseFeatureContent} exposes just the\n * scenarios; {@link parseFeatureCatalog} keeps the title too, for UIs that label\n * scenarios by their feature.\n */\nexport interface ParsedFeature {\n file: string;\n name: string;\n scenarios: ParsedScenario[];\n}\n\n/** Build a fresh gherkin parser and parse `content` into a document. */\nfunction parseDocument(content: string): messages.GherkinDocument {\n const builder = new AstBuilder(messages.IdGenerator.uuid());\n const matcher = new GherkinClassicTokenMatcher();\n return new Parser(builder, matcher).parse(content);\n}\n\n/**\n * Parse feature files into a catalog of `{ file, name, scenarios }`, one entry\n * per file (one gherkin parse each). Used by interactive mode to offer\n * feature/scenario names as typeahead choices labelled by their `Feature:` title.\n */\nexport function parseFeatureCatalog(filePaths: string[]): ParsedFeature[] {\n return filePaths.map(file => {\n const document = parseDocument(fs.readFileSync(file, \"utf-8\"));\n return {\n file,\n name: document.feature?.name ?? \"\",\n scenarios: documentToScenarios(document, file),\n };\n });\n}\n\nexport function parseFeatureContent(\n content: string,\n filePath: string\n): ParsedScenario[] {\n return documentToScenarios(parseDocument(content), filePath);\n}\n\n/** Expand a parsed gherkin document into scenarios (outline rows included). */\nfunction documentToScenarios(\n gherkinDocument: messages.GherkinDocument,\n filePath: string\n): ParsedScenario[] {\n const feature = gherkinDocument.feature;\n if (!feature) return [];\n\n // Collect background steps at the feature level\n const featureBackground: messages.Step[] = [];\n const scenarios: ParsedScenario[] = [];\n const featureTags = tagNames(feature.tags);\n\n for (const child of feature.children) {\n if (child.background) {\n featureBackground.push(...child.background.steps);\n }\n\n if (child.scenario) {\n scenarios.push(\n ...expandScenario(\n child.scenario,\n featureBackground,\n filePath,\n featureTags\n )\n );\n }\n\n if (child.rule) {\n // Rules can have their own backgrounds and tags, both inherited by the\n // rule's scenarios.\n const ruleBackground: messages.Step[] = [...featureBackground];\n const ruleTags = [...featureTags, ...tagNames(child.rule.tags)];\n for (const ruleChild of child.rule.children) {\n if (ruleChild.background) {\n ruleBackground.push(...ruleChild.background.steps);\n }\n if (ruleChild.scenario) {\n scenarios.push(\n ...expandScenario(\n ruleChild.scenario,\n ruleBackground,\n filePath,\n ruleTags\n )\n );\n }\n }\n }\n }\n\n return scenarios;\n}\n\n/** Extract tag names (each keeping its leading `@`), deduped in order. */\nfunction tagNames(tags: readonly messages.Tag[] | undefined): string[] {\n return [...new Set((tags ?? []).map(t => t.name))];\n}\n\nfunction expandScenario(\n scenario: messages.Scenario,\n backgroundSteps: messages.Step[],\n filePath: string,\n inheritedTags: string[]\n): ParsedScenario[] {\n const scenarioTags = [...inheritedTags, ...tagNames(scenario.tags)];\n const hasExamples =\n scenario.examples.length > 0 &&\n scenario.examples.some(e => e.tableBody.length > 0);\n\n if (!hasExamples) {\n // Regular scenario\n const bgParsed = convertSteps(backgroundSteps);\n const scenarioParsed = convertSteps(scenario.steps);\n const allSteps = resolveEffectiveKeywords([...bgParsed, ...scenarioParsed]);\n\n return [\n {\n name: scenario.name,\n file: filePath,\n line: scenario.location.line,\n steps: allSteps,\n tags: scenarioTags,\n },\n ];\n }\n\n // Scenario Outline — expand with each example row. Rows carry the outline's\n // base name so the runner can group them, plus the Examples-block tags.\n const results: ParsedScenario[] = [];\n for (const example of scenario.examples) {\n if (!example.tableHeader || example.tableBody.length === 0) continue;\n const headers = example.tableHeader.cells.map(c => c.value);\n const exampleTags = [...scenarioTags, ...tagNames(example.tags)];\n\n for (const row of example.tableBody) {\n const values = row.cells.map(c => c.value);\n const substitution: Record<string, string> = {};\n headers.forEach((h, i) => {\n substitution[h] = values[i];\n });\n\n const bgParsed = convertSteps(backgroundSteps);\n const scenarioSteps = convertSteps(scenario.steps).map(step => ({\n ...step,\n text: substituteExampleValues(step.text, substitution),\n }));\n const allSteps = resolveEffectiveKeywords([\n ...bgParsed,\n ...scenarioSteps,\n ]);\n\n results.push({\n name: headers.map((h, i) => `${h}=${values[i]}`).join(\", \"),\n file: filePath,\n line: row.location.line,\n steps: allSteps,\n tags: exampleTags,\n outline: { name: scenario.name },\n });\n }\n }\n\n return results;\n}\n\nfunction convertSteps(\n steps: readonly messages.Step[]\n): Omit<ParsedStep, \"effectiveKeyword\">[] {\n return steps.map(step => ({\n keyword: normalizeKeyword(step.keyword),\n text: step.text,\n line: step.location.line,\n // step.location.column points to the keyword start; shift past the\n // keyword (which includes a trailing space) so column points to the\n // start of the step text. This makes `column + text.length` produce\n // the correct end position for diagnostic ranges.\n column: (step.location.column ?? 1) + step.keyword.length,\n }));\n}\n\nfunction normalizeKeyword(keyword: string): GherkinKeyword {\n const trimmed = keyword.trim();\n // Gherkin keywords may include trailing space, e.g. \"Given \"\n if (trimmed === \"Given\") return \"Given\";\n if (trimmed === \"When\") return \"When\";\n if (trimmed === \"Then\") return \"Then\";\n if (trimmed === \"And\") return \"And\";\n if (trimmed === \"But\") return \"But\";\n // Fallback: treat as Given (shouldn't happen with valid Gherkin)\n return \"Given\";\n}\n\nfunction resolveEffectiveKeywords(\n steps: Omit<ParsedStep, \"effectiveKeyword\">[]\n): ParsedStep[] {\n let lastEffective: \"Given\" | \"When\" | \"Then\" = \"Given\";\n\n return steps.map(step => {\n let effectiveKeyword: \"Given\" | \"When\" | \"Then\";\n if (step.keyword === \"And\" || step.keyword === \"But\") {\n effectiveKeyword = lastEffective;\n } else {\n effectiveKeyword = step.keyword as \"Given\" | \"When\" | \"Then\";\n }\n lastEffective = effectiveKeyword;\n\n return {\n ...step,\n effectiveKeyword,\n };\n });\n}\n\nfunction substituteExampleValues(\n text: string,\n substitution: Record<string, string>\n): string {\n let result = text;\n for (const [key, value] of Object.entries(substitution)) {\n result = result.replace(new RegExp(`<${key}>`, \"g\"), value);\n }\n return result;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAUA,MAAM,WAAW,KAAK,QAAQ,cAAc,OAAO,KAAK,GAAG,CAAC;;;;;;AAa5D,SAAS,WAAW,MAAuB;CACzC,OACE,KAAK,WAAW,IAAI,KACpB,CAAC,KAAK,WAAW,WAAW,KAAK,GAAG,KACpC,CAAC,KAAK,SAAS,GAAG,KAAK,IAAI,cAAc,KAAK,KAAK;AAEvD;;AAGA,SAAS,WAAW,WAA4C;CAC9D,MAAM,IAAI,sBAAsB,KAAK,SAAS;CAC9C,IAAI,CAAC,GAAG,OAAO,KAAA;CACf,IAAI,OAAO,UAAU,MAAM,GAAG,EAAE,KAAK;CACrC,MAAM,QAAQ,KAAK,YAAY,GAAG;CAClC,IAAI,UAAU,IAAI,OAAO,KAAK,MAAM,QAAQ,CAAC;CAC7C,OAAO,KAAK,KAAK,CAAC,CAAC,QAAQ,UAAU,EAAE;CACvC,IAAI,KAAK,WAAW,SAAS,GAC3B,IAAI;EACF,OAAO,cAAc,IAAI;CAC3B,QAAQ;EACN;CACF;CAEF,OAAO;EAAE;EAAM,MAAM,OAAO,EAAE,EAAE;EAAG,QAAQ,OAAO,EAAE,EAAE;CAAE;AAC1D;;AAGA,SAAgB,WAAW,OAA0C;CACnE,IAAI,CAAC,OAAO,OAAO,CAAC;CACpB,MAAM,SAAwB,CAAC;CAC/B,KAAK,MAAM,QAAQ,MAAM,MAAM,IAAI,GAAG;EACpC,MAAM,QAAQ,WAAW,IAAI;EAC7B,IAAI,SAAS,WAAW,MAAM,IAAI,GAAG,OAAO,KAAK,KA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