@step-forge/step-forge 0.0.25-alpha.4 → 0.0.25-alpha.5

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.
@@ -1,531 +0,0 @@
1
- const require_gherkinParser = require("./gherkinParser-_ZgvELdy.cjs");
2
- let typescript = require("typescript");
3
- typescript = require_gherkinParser.__toESM(typescript, 1);
4
- let _cucumber_cucumber_expressions = require("@cucumber/cucumber-expressions");
5
- //#region src/analyzer/stepExtractor.ts
6
- const BUILDER_NAMES = {
7
- givenBuilder: "given",
8
- whenBuilder: "when",
9
- thenBuilder: "then"
10
- };
11
- /**
12
- * Built-in parsers exported by the library, mapped to the cucumber-expression
13
- * placeholder they register. A step's `.parsers([...])` drives which `{name}`
14
- * each variable becomes; without this the extractor defaulted every variable to
15
- * `{string}`, so `the deposit amount is {int}` was recorded as `{string}` and a
16
- * plain number like `100` looked unmatched. Custom parsers are resolved from
17
- * their `name` property (see {@link resolveCustomParserName}); anything we can't
18
- * resolve falls back to `string`.
19
- */
20
- const BUILTIN_PARSER_PLACEHOLDERS = {
21
- intParser: "int",
22
- numberParser: "float",
23
- stringParser: "string",
24
- booleanParser: "boolean"
25
- };
26
- function extractStepDefinitions(filePaths, tsConfigPath) {
27
- const fast = extractWithSources(filePaths.map(parseSourceFile).filter((s) => s !== null), null);
28
- if (!fast.needsChecker) return fast.results;
29
- const program = typescript.default.createProgram(filePaths, resolveCompilerOptions(tsConfigPath));
30
- const checker = program.getTypeChecker();
31
- return extractWithSources(filePaths.map((fp) => program.getSourceFile(fp)).filter((s) => s !== void 0), checker).results;
32
- }
33
- /** Parse a single file into an AST with no type resolution. */
34
- function parseSourceFile(filePath) {
35
- const text = typescript.default.sys.readFile(filePath);
36
- if (text === void 0) return null;
37
- const scriptKind = filePath.endsWith(".tsx") ? typescript.default.ScriptKind.TSX : typescript.default.ScriptKind.TS;
38
- return typescript.default.createSourceFile(filePath, text, typescript.default.ScriptTarget.ESNext, true, scriptKind);
39
- }
40
- /** Resolve compiler options from tsconfig (fallback to sane defaults). */
41
- function resolveCompilerOptions(tsConfigPath) {
42
- const configPath = tsConfigPath ?? typescript.default.findConfigFile(process.cwd(), typescript.default.sys.fileExists);
43
- let compilerOptions = {
44
- target: typescript.default.ScriptTarget.ESNext,
45
- module: typescript.default.ModuleKind.ESNext,
46
- moduleResolution: typescript.default.ModuleResolutionKind.Node10,
47
- strict: true,
48
- esModuleInterop: true
49
- };
50
- if (configPath) {
51
- const configFile = typescript.default.readConfigFile(configPath, typescript.default.sys.readFile);
52
- if (!configFile.error) compilerOptions = typescript.default.parseJsonConfigFileContent(configFile.config, typescript.default.sys, configPath.replace(/[/\\][^/\\]+$/, "")).options;
53
- }
54
- compilerOptions.noEmit = true;
55
- return compilerOptions;
56
- }
57
- function extractWithSources(sources, checker) {
58
- const ctx = {
59
- checker,
60
- needsChecker: false
61
- };
62
- const results = [];
63
- for (const sourceFile of sources) results.push(...extractFromSourceFile(sourceFile, ctx));
64
- return {
65
- results,
66
- needsChecker: ctx.needsChecker
67
- };
68
- }
69
- function extractFromSourceFile(sourceFile, ctx) {
70
- const results = [];
71
- function visit(node) {
72
- if (typescript.default.isCallExpression(node) && typescript.default.isPropertyAccessExpression(node.expression) && node.expression.name.text === "step") {
73
- const meta = extractFromRegisterCall(node, sourceFile, ctx);
74
- if (meta) results.push(meta);
75
- }
76
- typescript.default.forEachChild(node, visit);
77
- }
78
- visit(sourceFile);
79
- return results;
80
- }
81
- function extractFromRegisterCall(registerCall, sourceFile, ctx) {
82
- const chain = collectCallChain(registerCall);
83
- let stepType = null;
84
- let statementCall = null;
85
- let expression = null;
86
- let dependencies = {
87
- given: {},
88
- when: {},
89
- then: {}
90
- };
91
- let produces = [];
92
- let placeholders = null;
93
- for (const link of chain) {
94
- const name = getCallName(link);
95
- if (!name) continue;
96
- if (name === "register") continue;
97
- if (name === "step") {
98
- produces = extractProducedKeys(link, ctx);
99
- continue;
100
- }
101
- if (name === "dependencies") {
102
- dependencies = extractDependencies(link);
103
- continue;
104
- }
105
- if (name === "parsers") {
106
- placeholders = resolveParserPlaceholders(link, sourceFile);
107
- continue;
108
- }
109
- if (name === "statement") {
110
- statementCall = link;
111
- continue;
112
- }
113
- if (BUILDER_NAMES[name]) {
114
- stepType = BUILDER_NAMES[name];
115
- continue;
116
- }
117
- }
118
- if (statementCall) expression = extractExpression(statementCall, placeholders);
119
- if (!stepType || !expression) {
120
- const reExport = resolveReExportedCall(chain, ctx);
121
- if (reExport) {
122
- if (!stepType) stepType = reExport.stepType;
123
- if (!expression) expression = reExport.expression;
124
- }
125
- }
126
- if (!stepType || !expression) return null;
127
- const line = sourceFile.getLineAndCharacterOfPosition(registerCall.getStart()).line + 1;
128
- return {
129
- stepType,
130
- expression,
131
- dependencies,
132
- produces,
133
- sourceFile: sourceFile.fileName,
134
- line
135
- };
136
- }
137
- /**
138
- * Collect all call expressions in the method chain, from register() back to the origin.
139
- */
140
- function collectCallChain(call) {
141
- const chain = [call];
142
- let current = call.expression;
143
- while (true) {
144
- if (typescript.default.isPropertyAccessExpression(current)) current = current.expression;
145
- if (typescript.default.isCallExpression(current)) {
146
- chain.push(current);
147
- current = current.expression;
148
- } else break;
149
- }
150
- return chain;
151
- }
152
- function getCallName(call) {
153
- const expr = call.expression;
154
- if (typescript.default.isPropertyAccessExpression(expr)) return expr.name.text;
155
- if (typescript.default.isIdentifier(expr)) return expr.text;
156
- return null;
157
- }
158
- function extractExpression(statementCall, placeholders) {
159
- const arg = statementCall.arguments[0];
160
- if (!arg) return null;
161
- if (typescript.default.isStringLiteral(arg)) return arg.text;
162
- if (typescript.default.isArrowFunction(arg)) return extractExpressionFromArrowFunction(arg, placeholders);
163
- return null;
164
- }
165
- function extractExpressionFromArrowFunction(fn, placeholders) {
166
- const params = fn.parameters.map((p) => p.name.getText());
167
- let body = fn.body;
168
- if (typescript.default.isBlock(body)) {
169
- const returnStmt = body.statements.find(typescript.default.isReturnStatement);
170
- if (returnStmt?.expression) body = returnStmt.expression;
171
- else return null;
172
- }
173
- if (typescript.default.isTemplateExpression(body)) return reconstructExpressionFromTemplate(body, params, placeholders);
174
- if (typescript.default.isNoSubstitutionTemplateLiteral(body)) return body.text;
175
- return null;
176
- }
177
- function reconstructExpressionFromTemplate(template, paramNames, placeholders) {
178
- let result = template.head.text;
179
- for (const span of template.templateSpans) {
180
- let placeholder = "string";
181
- if (typescript.default.isIdentifier(span.expression) && paramNames.includes(span.expression.text)) {
182
- const index = paramNames.indexOf(span.expression.text);
183
- placeholder = placeholders?.[index] ?? "string";
184
- }
185
- result += `{${placeholder}}`;
186
- result += span.literal.text;
187
- }
188
- return result;
189
- }
190
- /**
191
- * Resolve `.parsers([intParser, colorParser])` to the placeholder name for each
192
- * variable, positionally. Built-ins map via {@link BUILTIN_PARSER_PLACEHOLDERS};
193
- * a custom parser is resolved from its `name` property in the same source file;
194
- * anything unresolved defaults to `string`, matching the runtime default parser.
195
- */
196
- function resolveParserPlaceholders(parsersCall, sourceFile) {
197
- const arg = parsersCall.arguments[0];
198
- if (!arg || !typescript.default.isArrayLiteralExpression(arg)) return null;
199
- return arg.elements.map((element) => {
200
- if (typescript.default.isIdentifier(element)) {
201
- const builtin = BUILTIN_PARSER_PLACEHOLDERS[element.text];
202
- if (builtin) return builtin;
203
- const custom = resolveCustomParserName(element.text, sourceFile);
204
- if (custom) return custom;
205
- }
206
- return "string";
207
- });
208
- }
209
- /**
210
- * Find `const <identifier> = { name: "...", ... }` in `sourceFile` and return
211
- * its `name` — the cucumber placeholder a custom `Parser` registers. Scoped to
212
- * the file, so a parser imported from elsewhere won't resolve (it falls back to
213
- * `string`); the common in-file `const colorParser: Parser<Color> = {...}` does.
214
- */
215
- function resolveCustomParserName(identifier, sourceFile) {
216
- let found = null;
217
- const visit = (node) => {
218
- if (found) return;
219
- if (typescript.default.isVariableDeclaration(node) && typescript.default.isIdentifier(node.name) && node.name.text === identifier && node.initializer && typescript.default.isObjectLiteralExpression(node.initializer)) {
220
- for (const prop of node.initializer.properties) if (typescript.default.isPropertyAssignment(prop) && typescript.default.isIdentifier(prop.name) && prop.name.text === "name" && typescript.default.isStringLiteralLike(prop.initializer)) {
221
- found = prop.initializer.text;
222
- return;
223
- }
224
- }
225
- typescript.default.forEachChild(node, visit);
226
- };
227
- visit(sourceFile);
228
- return found;
229
- }
230
- function extractDependencies(depsCall) {
231
- const deps = {
232
- given: {},
233
- when: {},
234
- then: {}
235
- };
236
- const arg = depsCall.arguments[0];
237
- if (!arg || !typescript.default.isObjectLiteralExpression(arg)) return deps;
238
- for (const prop of arg.properties) {
239
- if (!typescript.default.isPropertyAssignment(prop) || !typescript.default.isIdentifier(prop.name)) continue;
240
- const phase = prop.name.text;
241
- if (!deps[phase]) continue;
242
- if (typescript.default.isObjectLiteralExpression(prop.initializer)) {
243
- for (const innerProp of prop.initializer.properties) if (typescript.default.isPropertyAssignment(innerProp) && typescript.default.isIdentifier(innerProp.name) && typescript.default.isStringLiteral(innerProp.initializer)) {
244
- const val = innerProp.initializer.text;
245
- if (val === "required" || val === "optional") deps[phase][innerProp.name.text] = val;
246
- }
247
- }
248
- }
249
- return deps;
250
- }
251
- function extractProducedKeys(stepCall, ctx) {
252
- const callback = stepCall.arguments[0];
253
- if (!callback) return [];
254
- if (typescript.default.isArrowFunction(callback) || typescript.default.isFunctionExpression(callback)) return extractProducedKeysFromCallback(callback, ctx);
255
- return [];
256
- }
257
- function extractProducedKeysFromCallback(callback, ctx) {
258
- const body = callback.body;
259
- if (!typescript.default.isBlock(body)) return extractKeysFromExpression(body, ctx);
260
- const keys = /* @__PURE__ */ new Set();
261
- function visitReturn(node) {
262
- if (typescript.default.isReturnStatement(node) && node.expression) for (const key of extractKeysFromExpression(node.expression, ctx)) keys.add(key);
263
- typescript.default.forEachChild(node, visitReturn);
264
- }
265
- visitReturn(body);
266
- return [...keys];
267
- }
268
- function extractKeysFromExpression(expr, ctx) {
269
- while (typescript.default.isParenthesizedExpression(expr)) expr = expr.expression;
270
- if (typescript.default.isObjectLiteralExpression(expr)) return expr.properties.filter((p) => typescript.default.isPropertyAssignment(p) || typescript.default.isShorthandPropertyAssignment(p)).map((p) => p.name.getText()).filter(Boolean);
271
- if (!ctx.checker) {
272
- ctx.needsChecker = true;
273
- return [];
274
- }
275
- try {
276
- return ctx.checker.getTypeAtLocation(expr).getProperties().map((p) => p.name).filter((n) => n !== "merge");
277
- } catch {
278
- return [];
279
- }
280
- }
281
- function resolveReExportedCall(chain, ctx) {
282
- const lastCall = chain[chain.length - 1];
283
- if (!lastCall) return null;
284
- const expr = lastCall.expression;
285
- let identifier = null;
286
- if (typescript.default.isIdentifier(expr)) identifier = expr;
287
- else if (typescript.default.isPropertyAccessExpression(expr) && typescript.default.isIdentifier(expr.expression)) identifier = expr.expression;
288
- if (!identifier) return null;
289
- if (!ctx.checker) {
290
- ctx.needsChecker = true;
291
- return null;
292
- }
293
- const symbol = ctx.checker.getSymbolAtLocation(identifier);
294
- if (!symbol) return null;
295
- const decl = symbol.valueDeclaration;
296
- if (!decl || !typescript.default.isVariableDeclaration(decl) || !decl.initializer) return null;
297
- const init = decl.initializer;
298
- if (typescript.default.isPropertyAccessExpression(init) && init.name.text === "statement") {
299
- const callExpr = init.expression;
300
- if (typescript.default.isCallExpression(callExpr)) {
301
- const callee = callExpr.expression;
302
- if (typescript.default.isIdentifier(callee) && BUILDER_NAMES[callee.text]) {
303
- const expression = extractExpression(lastCall, null);
304
- return {
305
- stepType: BUILDER_NAMES[callee.text],
306
- expression
307
- };
308
- }
309
- }
310
- }
311
- return null;
312
- }
313
- //#endregion
314
- //#region src/analyzer/stepMatcher.ts
315
- /** `{name}` tokens in a cucumber expression (empty name is the anonymous `{}`). */
316
- const PARAM_TOKEN = /\{([^}]*)\}/g;
317
- /**
318
- * Compile each definition's cucumber expression with the **same** engine the
319
- * runtime uses (`@cucumber/cucumber-expressions`), so the analyzer and the
320
- * runtime agree on what a step matches.
321
- *
322
- * A hand-rolled `{param}` → `(.+)` regex used to stand in here, but it treated
323
- * cucumber-expression alternative (`a/b`) and optional (`text(s)`) syntax as
324
- * literal characters — so any step definition using them (e.g.
325
- * `there should be {int} error/errors`) never matched, and every such step was
326
- * wrongly reported as an undefined step regardless of the real state.
327
- *
328
- * Built-in placeholders (`{int}`, `{float}`, `{string}`, `{word}`) keep their
329
- * real, strict regexes so the analyzer disambiguates the way the runtime does
330
- * (e.g. `no` isn't an `{int}`). The analyzer has only the expression string, not
331
- * a custom parser's regexp, so each custom `{name}` is registered as a permissive
332
- * parameter type (any value) — lenient about the value's exact shape, but still
333
- * anchored by the surrounding literal text.
334
- */
335
- function compileDefinitions(definitions) {
336
- const compiled = [];
337
- for (const def of definitions) try {
338
- const registry = new _cucumber_cucumber_expressions.ParameterTypeRegistry();
339
- for (const [, name] of def.expression.matchAll(PARAM_TOKEN)) {
340
- if (!name || registry.lookupByTypeName(name)) continue;
341
- registry.defineParameterType(new _cucumber_cucumber_expressions.ParameterType(name, /.+/, null, (value) => value));
342
- }
343
- compiled.push({
344
- expression: new _cucumber_cucumber_expressions.CucumberExpression(def.expression, registry),
345
- definition: def
346
- });
347
- } catch {}
348
- return compiled;
349
- }
350
- function matchScenarioSteps(scenario, definitions) {
351
- const compiled = compileDefinitions(definitions);
352
- return scenario.steps.map((step) => {
353
- const matches = findMatches(step.text, step.effectiveKeyword, compiled);
354
- return {
355
- ...step,
356
- definitions: matches
357
- };
358
- });
359
- }
360
- function findMatchingDefinitions(text, effectiveKeyword, definitions) {
361
- return findMatches(text, effectiveKeyword, compileDefinitions(definitions));
362
- }
363
- function findMatches(text, effectiveKeyword, compiled) {
364
- const expectedStepType = {
365
- Given: "given",
366
- When: "when",
367
- Then: "then"
368
- }[effectiveKeyword];
369
- const typedMatches = [];
370
- for (const { expression, definition } of compiled) {
371
- if (definition.stepType !== expectedStepType) continue;
372
- if (expression.match(text) != null) typedMatches.push(definition);
373
- }
374
- if (typedMatches.length > 0) return typedMatches;
375
- const fallbackMatches = [];
376
- for (const { expression, definition } of compiled) if (expression.match(text) != null) fallbackMatches.push(definition);
377
- return fallbackMatches;
378
- }
379
- //#endregion
380
- //#region src/analyzer/rules/index.ts
381
- const defaultRules = [
382
- {
383
- name: "undefined-step",
384
- check(scenario, matchedSteps) {
385
- return matchedSteps.filter((step) => step.definitions.length === 0).map((step) => ({
386
- file: scenario.file,
387
- range: {
388
- startLine: step.line,
389
- startColumn: step.column,
390
- endLine: step.line,
391
- endColumn: step.column + step.text.length
392
- },
393
- severity: "error",
394
- message: `Step "${step.text}" does not match any step definition`,
395
- rule: "undefined-step",
396
- source: "step-forge"
397
- }));
398
- }
399
- },
400
- {
401
- name: "ambiguous-step",
402
- check(scenario, matchedSteps) {
403
- return matchedSteps.filter((step) => step.definitions.length > 1).map((step) => {
404
- const locations = step.definitions.map((d) => `${d.sourceFile}:${d.line}`).join(", ");
405
- return {
406
- file: scenario.file,
407
- range: {
408
- startLine: step.line,
409
- startColumn: step.column,
410
- endLine: step.line,
411
- endColumn: step.column + step.text.length
412
- },
413
- severity: "error",
414
- message: `Step "${step.text}" matches multiple step definitions: ${locations}`,
415
- rule: "ambiguous-step",
416
- source: "step-forge"
417
- };
418
- });
419
- }
420
- },
421
- {
422
- name: "dependency-check",
423
- check(scenario, matchedSteps) {
424
- const diagnostics = [];
425
- const produced = {
426
- given: /* @__PURE__ */ new Set(),
427
- when: /* @__PURE__ */ new Set(),
428
- then: /* @__PURE__ */ new Set()
429
- };
430
- for (const step of matchedSteps) {
431
- if (step.definitions.length !== 1) continue;
432
- const { dependencies, produces, stepType } = step.definitions[0];
433
- const missing = {};
434
- for (const phase of [
435
- "given",
436
- "when",
437
- "then"
438
- ]) for (const [key, requirement] of Object.entries(dependencies[phase])) if (requirement === "required" && !produced[phase].has(key)) {
439
- if (!missing[phase]) missing[phase] = [];
440
- missing[phase].push(key);
441
- }
442
- if (Object.keys(missing).length > 0) {
443
- const message = "Missing required dependencies:\n" + Object.entries(missing).map(([phase, keys]) => `${phase.charAt(0).toUpperCase() + phase.slice(1)}: ${keys.map((k) => `${phase}.${k}`).join(", ")}`).join("\n");
444
- diagnostics.push({
445
- file: scenario.file,
446
- range: {
447
- startLine: step.line,
448
- startColumn: step.column,
449
- endLine: step.line,
450
- endColumn: step.column + step.text.length
451
- },
452
- severity: "error",
453
- message,
454
- rule: "dependency-check",
455
- source: "step-forge"
456
- });
457
- }
458
- for (const key of produces) produced[stepType].add(key);
459
- }
460
- return diagnostics;
461
- }
462
- }
463
- ];
464
- function runRules(rules, scenario, matchedSteps) {
465
- return rules.flatMap((rule) => rule.check(scenario, matchedSteps));
466
- }
467
- //#endregion
468
- //#region src/analyzer/index.ts
469
- var analyzer_exports = /* @__PURE__ */ require_gherkinParser.__exportAll({
470
- analyze: () => analyze,
471
- defaultRules: () => defaultRules,
472
- extractStepDefinitions: () => extractStepDefinitions,
473
- findMatchingDefinitions: () => findMatchingDefinitions,
474
- matchScenarioSteps: () => matchScenarioSteps,
475
- parseFeatureContent: () => require_gherkinParser.parseFeatureContent,
476
- parseFeatureFiles: () => require_gherkinParser.parseFeatureFiles
477
- });
478
- async function analyze(config, options) {
479
- const rules = options?.rules ?? defaultRules;
480
- const stepFilePaths = await require_gherkinParser.globFiles(config.stepFiles);
481
- const featureFilePaths = await require_gherkinParser.globFiles(config.featureFiles);
482
- if (stepFilePaths.length === 0) return [];
483
- if (featureFilePaths.length === 0) return [];
484
- const stepDefinitions = extractStepDefinitions(stepFilePaths, config.tsConfigPath);
485
- const scenarios = require_gherkinParser.parseFeatureFiles(featureFilePaths);
486
- const diagnostics = [];
487
- for (const scenario of scenarios) {
488
- const scenarioDiags = runRules(rules, scenario, matchScenarioSteps(scenario, stepDefinitions));
489
- diagnostics.push(...scenarioDiags);
490
- }
491
- return diagnostics;
492
- }
493
- //#endregion
494
- Object.defineProperty(exports, "analyze", {
495
- enumerable: true,
496
- get: function() {
497
- return analyze;
498
- }
499
- });
500
- Object.defineProperty(exports, "analyzer_exports", {
501
- enumerable: true,
502
- get: function() {
503
- return analyzer_exports;
504
- }
505
- });
506
- Object.defineProperty(exports, "defaultRules", {
507
- enumerable: true,
508
- get: function() {
509
- return defaultRules;
510
- }
511
- });
512
- Object.defineProperty(exports, "extractStepDefinitions", {
513
- enumerable: true,
514
- get: function() {
515
- return extractStepDefinitions;
516
- }
517
- });
518
- Object.defineProperty(exports, "findMatchingDefinitions", {
519
- enumerable: true,
520
- get: function() {
521
- return findMatchingDefinitions;
522
- }
523
- });
524
- Object.defineProperty(exports, "matchScenarioSteps", {
525
- enumerable: true,
526
- get: function() {
527
- return matchScenarioSteps;
528
- }
529
- });
530
-
531
- //# sourceMappingURL=analyzer-DRudicCk.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"analyzer-DRudicCk.cjs","names":["ts","ParameterTypeRegistry","ParameterType","CucumberExpression","globFiles","parseFeatureFiles"],"sources":["../../src/analyzer/stepExtractor.ts","../../src/analyzer/stepMatcher.ts","../../src/analyzer/rules/ambiguousStepRule.ts","../../src/analyzer/rules/dependencyRule.ts","../../src/analyzer/rules/undefinedStepRule.ts","../../src/analyzer/rules/index.ts","../../src/analyzer/index.ts"],"sourcesContent":["import ts from \"typescript\";\nimport { StepDefinitionMeta } from \"./types.js\";\n\ntype StepType = \"given\" | \"when\" | \"then\";\n\nconst BUILDER_NAMES: Record<string, StepType> = {\n givenBuilder: \"given\",\n whenBuilder: \"when\",\n thenBuilder: \"then\",\n};\n\n/**\n * Built-in parsers exported by the library, mapped to the cucumber-expression\n * placeholder they register. A step's `.parsers([...])` drives which `{name}`\n * each variable becomes; without this the extractor defaulted every variable to\n * `{string}`, so `the deposit amount is {int}` was recorded as `{string}` and a\n * plain number like `100` looked unmatched. Custom parsers are resolved from\n * their `name` property (see {@link resolveCustomParserName}); anything we can't\n * resolve falls back to `string`.\n */\nconst BUILTIN_PARSER_PLACEHOLDERS: Record<string, string> = {\n intParser: \"int\",\n numberParser: \"float\",\n stringParser: \"string\",\n booleanParser: \"boolean\",\n};\n\n/**\n * Threaded through the AST walk. `checker` is `null` on the parse-only fast\n * path; a step that genuinely needs type information sets `needsChecker`, which\n * triggers a one-time retry with a real type-checked `Program`.\n */\ninterface ExtractCtx {\n checker: ts.TypeChecker | null;\n needsChecker: boolean;\n}\n\nexport function extractStepDefinitions(\n filePaths: string[],\n tsConfigPath?: string\n): StepDefinitionMeta[] {\n // Fast path: parse each file with `createSourceFile` (tokenize + parse only,\n // no type resolution — ~1ms/file) and walk the AST. Building a full\n // type-checked `Program` loads `lib.*.d.ts` and resolves every import (~150ms)\n // and is only needed for two uncommon shapes: a `.step()` whose return isn't a\n // plain object literal, or the re-exported-builder pattern. Those set\n // `needsChecker`, and we retry once with a real Program below.\n const sources = filePaths\n .map(parseSourceFile)\n .filter((s): s is ts.SourceFile => s !== null);\n const fast = extractWithSources(sources, null);\n if (!fast.needsChecker) return fast.results;\n\n // Slow path: some step needs type information. Build the program once and\n // re-extract from *its* source files — the checker only understands nodes it\n // bound itself, so the parse-only ASTs above can't be reused here.\n const program = ts.createProgram(\n filePaths,\n resolveCompilerOptions(tsConfigPath)\n );\n const checker = program.getTypeChecker();\n const checkedSources = filePaths\n .map(fp => program.getSourceFile(fp))\n .filter((s): s is ts.SourceFile => s !== undefined);\n return extractWithSources(checkedSources, checker).results;\n}\n\n/** Parse a single file into an AST with no type resolution. */\nfunction parseSourceFile(filePath: string): ts.SourceFile | null {\n const text = ts.sys.readFile(filePath);\n if (text === undefined) return null;\n const scriptKind = filePath.endsWith(\".tsx\")\n ? ts.ScriptKind.TSX\n : ts.ScriptKind.TS;\n // setParentNodes: true — the extractor relies on `.getText()`/`.getStart()`,\n // which walk parent pointers up to the SourceFile.\n return ts.createSourceFile(\n filePath,\n text,\n ts.ScriptTarget.ESNext,\n true,\n scriptKind\n );\n}\n\n/** Resolve compiler options from tsconfig (fallback to sane defaults). */\nfunction resolveCompilerOptions(tsConfigPath?: string): ts.CompilerOptions {\n const configPath =\n tsConfigPath ?? ts.findConfigFile(process.cwd(), ts.sys.fileExists);\n let compilerOptions: ts.CompilerOptions = {\n target: ts.ScriptTarget.ESNext,\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Node10,\n strict: true,\n esModuleInterop: true,\n };\n\n if (configPath) {\n const configFile = ts.readConfigFile(configPath, ts.sys.readFile);\n if (!configFile.error) {\n const parsed = ts.parseJsonConfigFileContent(\n configFile.config,\n ts.sys,\n configPath.replace(/[/\\\\][^/\\\\]+$/, \"\")\n );\n compilerOptions = parsed.options;\n }\n }\n\n // Ensure noEmit so we don't write files\n compilerOptions.noEmit = true;\n return compilerOptions;\n}\n\nfunction extractWithSources(\n sources: ts.SourceFile[],\n checker: ts.TypeChecker | null\n): { results: StepDefinitionMeta[]; needsChecker: boolean } {\n const ctx: ExtractCtx = { checker, needsChecker: false };\n const results: StepDefinitionMeta[] = [];\n for (const sourceFile of sources) {\n results.push(...extractFromSourceFile(sourceFile, ctx));\n }\n return { results, needsChecker: ctx.needsChecker };\n}\n\nfunction extractFromSourceFile(\n sourceFile: ts.SourceFile,\n ctx: ExtractCtx\n): StepDefinitionMeta[] {\n const results: StepDefinitionMeta[] = [];\n\n function visit(node: ts.Node) {\n // The chain now terminates at `.step(...)`, which is the registration\n // point (there is no `.register()` anymore).\n if (\n ts.isCallExpression(node) &&\n ts.isPropertyAccessExpression(node.expression) &&\n node.expression.name.text === \"step\"\n ) {\n const meta = extractFromRegisterCall(node, sourceFile, ctx);\n if (meta) {\n results.push(meta);\n }\n }\n ts.forEachChild(node, visit);\n }\n\n visit(sourceFile);\n return results;\n}\n\nfunction extractFromRegisterCall(\n registerCall: ts.CallExpression,\n sourceFile: ts.SourceFile,\n ctx: ExtractCtx\n): StepDefinitionMeta | null {\n // Walk backwards through the method chain to find all parts\n // Pattern: builder().statement(...).dependencies?(...).step(...).register()\n // Or: Variable(\"...\").dependencies?(...).step(...).register()\n\n const chain = collectCallChain(registerCall);\n\n let stepType: StepType | null = null;\n let statementCall: ts.CallExpression | null = null;\n let expression: string | null = null;\n let dependencies: StepDefinitionMeta[\"dependencies\"] = {\n given: {},\n when: {},\n then: {},\n };\n let produces: string[] = [];\n // Placeholder names per variable, from `.parsers([...])` (positional).\n let placeholders: string[] | null = null;\n\n for (const link of chain) {\n const name = getCallName(link);\n if (!name) continue;\n\n if (name === \"register\") {\n // Already at register, continue\n continue;\n }\n\n if (name === \"step\") {\n produces = extractProducedKeys(link, ctx);\n continue;\n }\n\n if (name === \"dependencies\") {\n dependencies = extractDependencies(link);\n continue;\n }\n\n if (name === \"parsers\") {\n placeholders = resolveParserPlaceholders(link, sourceFile);\n continue;\n }\n\n if (name === \"statement\") {\n statementCall = link;\n // Try to find the builder type by continuing up the chain\n continue;\n }\n\n // Check if this is a builder call like givenBuilder()\n if (BUILDER_NAMES[name]) {\n stepType = BUILDER_NAMES[name];\n continue;\n }\n }\n\n // Build the expression after the whole chain is seen, so `.parsers([...])` —\n // which the chain visits before `.statement(...)` here, but conceptually\n // annotates it — determines each variable's placeholder.\n if (statementCall)\n expression = extractExpression(statementCall, placeholders);\n\n // If we didn't find the builder or expression in the chain, try the \"re-exported\" pattern:\n // const Given = givenBuilder<T>().statement;\n // Given(\"foo\").step(...).register()\n if (!stepType || !expression) {\n const reExport = resolveReExportedCall(chain, ctx);\n if (reExport) {\n if (!stepType) stepType = reExport.stepType;\n if (!expression) expression = reExport.expression;\n }\n }\n\n if (!stepType || !expression) {\n return null;\n }\n\n const line =\n sourceFile.getLineAndCharacterOfPosition(registerCall.getStart()).line + 1;\n\n return {\n stepType,\n expression,\n dependencies,\n produces,\n sourceFile: sourceFile.fileName,\n line,\n };\n}\n\n/**\n * Collect all call expressions in the method chain, from register() back to the origin.\n */\nfunction collectCallChain(call: ts.CallExpression): ts.CallExpression[] {\n const chain: ts.CallExpression[] = [call];\n let current: ts.Expression = call.expression;\n\n while (true) {\n // Walk through PropertyAccessExpression to find the next call\n if (ts.isPropertyAccessExpression(current)) {\n current = current.expression;\n }\n\n if (ts.isCallExpression(current)) {\n chain.push(current);\n current = current.expression;\n } else {\n break;\n }\n }\n\n return chain;\n}\n\nfunction getCallName(call: ts.CallExpression): string | null {\n const expr = call.expression;\n\n // .method() pattern\n if (ts.isPropertyAccessExpression(expr)) {\n return expr.name.text;\n }\n\n // direct call: functionName()\n if (ts.isIdentifier(expr)) {\n return expr.text;\n }\n\n return null;\n}\n\nfunction extractExpression(\n statementCall: ts.CallExpression,\n placeholders: string[] | null\n): string | null {\n const arg = statementCall.arguments[0];\n if (!arg) return null;\n\n // String literal: .statement(\"a user\")\n if (ts.isStringLiteral(arg)) {\n return arg.text;\n }\n\n // Arrow function with template literal: .statement((name: string) => `a user named ${name}`)\n if (ts.isArrowFunction(arg)) {\n return extractExpressionFromArrowFunction(arg, placeholders);\n }\n\n return null;\n}\n\nfunction extractExpressionFromArrowFunction(\n fn: ts.ArrowFunction,\n placeholders: string[] | null\n): string | null {\n const params = fn.parameters.map(p => p.name.getText());\n\n // The body should be a template expression or string literal\n let body = fn.body;\n\n // If wrapped in a block with a return, unwrap\n if (ts.isBlock(body)) {\n const returnStmt = body.statements.find(ts.isReturnStatement);\n if (returnStmt?.expression) {\n body = returnStmt.expression;\n } else {\n return null;\n }\n }\n\n if (ts.isTemplateExpression(body)) {\n return reconstructExpressionFromTemplate(body, params, placeholders);\n }\n\n if (ts.isNoSubstitutionTemplateLiteral(body)) {\n return body.text;\n }\n\n return null;\n}\n\nfunction reconstructExpressionFromTemplate(\n template: ts.TemplateExpression,\n paramNames: string[],\n placeholders: string[] | null\n): string {\n let result = template.head.text;\n\n for (const span of template.templateSpans) {\n // A variable interpolation becomes its declared parser placeholder (default\n // `{string}`); a non-variable interpolation falls back to `{string}`.\n let placeholder = \"string\";\n if (\n ts.isIdentifier(span.expression) &&\n paramNames.includes(span.expression.text)\n ) {\n const index = paramNames.indexOf(span.expression.text);\n placeholder = placeholders?.[index] ?? \"string\";\n }\n result += `{${placeholder}}`;\n result += span.literal.text;\n }\n\n return result;\n}\n\n/**\n * Resolve `.parsers([intParser, colorParser])` to the placeholder name for each\n * variable, positionally. Built-ins map via {@link BUILTIN_PARSER_PLACEHOLDERS};\n * a custom parser is resolved from its `name` property in the same source file;\n * anything unresolved defaults to `string`, matching the runtime default parser.\n */\nfunction resolveParserPlaceholders(\n parsersCall: ts.CallExpression,\n sourceFile: ts.SourceFile\n): string[] | null {\n const arg = parsersCall.arguments[0];\n if (!arg || !ts.isArrayLiteralExpression(arg)) return null;\n return arg.elements.map(element => {\n if (ts.isIdentifier(element)) {\n const builtin = BUILTIN_PARSER_PLACEHOLDERS[element.text];\n if (builtin) return builtin;\n const custom = resolveCustomParserName(element.text, sourceFile);\n if (custom) return custom;\n }\n return \"string\";\n });\n}\n\n/**\n * Find `const <identifier> = { name: \"...\", ... }` in `sourceFile` and return\n * its `name` — the cucumber placeholder a custom `Parser` registers. Scoped to\n * the file, so a parser imported from elsewhere won't resolve (it falls back to\n * `string`); the common in-file `const colorParser: Parser<Color> = {...}` does.\n */\nfunction resolveCustomParserName(\n identifier: string,\n sourceFile: ts.SourceFile\n): string | null {\n let found: string | null = null;\n const visit = (node: ts.Node): void => {\n if (found) return;\n if (\n ts.isVariableDeclaration(node) &&\n ts.isIdentifier(node.name) &&\n node.name.text === identifier &&\n node.initializer &&\n ts.isObjectLiteralExpression(node.initializer)\n ) {\n for (const prop of node.initializer.properties) {\n if (\n ts.isPropertyAssignment(prop) &&\n ts.isIdentifier(prop.name) &&\n prop.name.text === \"name\" &&\n ts.isStringLiteralLike(prop.initializer)\n ) {\n found = prop.initializer.text;\n return;\n }\n }\n }\n ts.forEachChild(node, visit);\n };\n visit(sourceFile);\n return found;\n}\n\nfunction extractDependencies(\n depsCall: ts.CallExpression\n): StepDefinitionMeta[\"dependencies\"] {\n const deps: StepDefinitionMeta[\"dependencies\"] = {\n given: {},\n when: {},\n then: {},\n };\n\n const arg = depsCall.arguments[0];\n if (!arg || !ts.isObjectLiteralExpression(arg)) return deps;\n\n for (const prop of arg.properties) {\n if (!ts.isPropertyAssignment(prop) || !ts.isIdentifier(prop.name)) continue;\n\n const phase = prop.name.text as \"given\" | \"when\" | \"then\";\n if (!deps[phase]) continue;\n\n if (ts.isObjectLiteralExpression(prop.initializer)) {\n for (const innerProp of prop.initializer.properties) {\n if (\n ts.isPropertyAssignment(innerProp) &&\n ts.isIdentifier(innerProp.name) &&\n ts.isStringLiteral(innerProp.initializer)\n ) {\n const val = innerProp.initializer.text;\n if (val === \"required\" || val === \"optional\") {\n deps[phase][innerProp.name.text] = val;\n }\n }\n }\n }\n }\n\n return deps;\n}\n\nfunction extractProducedKeys(\n stepCall: ts.CallExpression,\n ctx: ExtractCtx\n): string[] {\n const callback = stepCall.arguments[0];\n if (!callback) return [];\n\n // Try to get the return type of the callback by analyzing its body\n if (ts.isArrowFunction(callback) || ts.isFunctionExpression(callback)) {\n return extractProducedKeysFromCallback(callback, ctx);\n }\n\n return [];\n}\n\nfunction extractProducedKeysFromCallback(\n callback: ts.ArrowFunction | ts.FunctionExpression,\n ctx: ExtractCtx\n): string[] {\n const body = callback.body;\n\n // Concise arrow: () => ({ key: value })\n if (!ts.isBlock(body)) {\n return extractKeysFromExpression(body, ctx);\n }\n\n // Block body: look at return statements\n const keys = new Set<string>();\n function visitReturn(node: ts.Node) {\n if (ts.isReturnStatement(node) && node.expression) {\n for (const key of extractKeysFromExpression(node.expression, ctx)) {\n keys.add(key);\n }\n }\n ts.forEachChild(node, visitReturn);\n }\n visitReturn(body);\n return [...keys];\n}\n\nfunction extractKeysFromExpression(\n expr: ts.Expression,\n ctx: ExtractCtx\n): string[] {\n // Unwrap parenthesized expressions\n while (ts.isParenthesizedExpression(expr)) {\n expr = expr.expression;\n }\n\n // Object literal: { user: ..., token: ... }\n if (ts.isObjectLiteralExpression(expr)) {\n return expr.properties\n .filter(\n (p): p is ts.PropertyAssignment | ts.ShorthandPropertyAssignment =>\n ts.isPropertyAssignment(p) || ts.isShorthandPropertyAssignment(p)\n )\n .map(p => p.name.getText())\n .filter(Boolean);\n }\n\n // Non-literal return (a variable, a spread-only object, a function call): the\n // keys can only come from the type checker. On the parse-only pass we have\n // none — flag it so the caller retries with a real Program.\n if (!ctx.checker) {\n ctx.needsChecker = true;\n return [];\n }\n try {\n const type = ctx.checker.getTypeAtLocation(expr);\n return type\n .getProperties()\n .map(p => p.name)\n .filter(n => n !== \"merge\");\n } catch {\n return [];\n }\n}\n\ninterface ReExportResult {\n stepType: StepType;\n expression: string | null;\n}\n\nfunction resolveReExportedCall(\n chain: ts.CallExpression[],\n ctx: ExtractCtx\n): ReExportResult | null {\n // Look for the pattern: Variable(\"...\")... where Variable was assigned from builderType().statement\n // The last call in the chain (furthest from register) should be the variable call\n\n const lastCall = chain[chain.length - 1];\n if (!lastCall) return null;\n\n const expr = lastCall.expression;\n\n // If it's an identifier (like \"Given\", \"When\", \"Then\"), trace its declaration\n let identifier: ts.Identifier | null = null;\n if (ts.isIdentifier(expr)) {\n identifier = expr;\n } else if (\n ts.isPropertyAccessExpression(expr) &&\n ts.isIdentifier(expr.expression)\n ) {\n identifier = expr.expression;\n }\n\n if (!identifier) return null;\n\n // Tracing the re-exported builder's declaration needs symbol resolution,\n // which only a real Program provides. Flag for the checked retry.\n if (!ctx.checker) {\n ctx.needsChecker = true;\n return null;\n }\n\n const symbol = ctx.checker.getSymbolAtLocation(identifier);\n if (!symbol) return null;\n\n const decl = symbol.valueDeclaration;\n if (!decl || !ts.isVariableDeclaration(decl) || !decl.initializer)\n return null;\n\n // Check if initializer is builderType<T>().statement\n const init = decl.initializer;\n\n // Pattern: givenBuilder<T>().statement (PropertyAccessExpression)\n if (ts.isPropertyAccessExpression(init) && init.name.text === \"statement\") {\n const callExpr = init.expression;\n if (ts.isCallExpression(callExpr)) {\n const callee = callExpr.expression;\n if (ts.isIdentifier(callee) && BUILDER_NAMES[callee.text]) {\n // The lastCall IS the statement call — extract expression from it.\n // The re-exported-builder pattern carries no `.parsers(...)`, so\n // variables fall back to the default `{string}` placeholder.\n const expression = extractExpression(lastCall, null);\n return {\n stepType: BUILDER_NAMES[callee.text],\n expression,\n };\n }\n }\n }\n\n return null;\n}\n","import {\n CucumberExpression,\n ParameterType,\n ParameterTypeRegistry,\n} from \"@cucumber/cucumber-expressions\";\nimport { MatchedStep, ParsedScenario, StepDefinitionMeta } from \"./types.js\";\n\ninterface CompiledPattern {\n expression: CucumberExpression;\n definition: StepDefinitionMeta;\n}\n\n/** `{name}` tokens in a cucumber expression (empty name is the anonymous `{}`). */\nconst PARAM_TOKEN = /\\{([^}]*)\\}/g;\n\n/**\n * Compile each definition's cucumber expression with the **same** engine the\n * runtime uses (`@cucumber/cucumber-expressions`), so the analyzer and the\n * runtime agree on what a step matches.\n *\n * A hand-rolled `{param}` → `(.+)` regex used to stand in here, but it treated\n * cucumber-expression alternative (`a/b`) and optional (`text(s)`) syntax as\n * literal characters — so any step definition using them (e.g.\n * `there should be {int} error/errors`) never matched, and every such step was\n * wrongly reported as an undefined step regardless of the real state.\n *\n * Built-in placeholders (`{int}`, `{float}`, `{string}`, `{word}`) keep their\n * real, strict regexes so the analyzer disambiguates the way the runtime does\n * (e.g. `no` isn't an `{int}`). The analyzer has only the expression string, not\n * a custom parser's regexp, so each custom `{name}` is registered as a permissive\n * parameter type (any value) — lenient about the value's exact shape, but still\n * anchored by the surrounding literal text.\n */\nfunction compileDefinitions(\n definitions: StepDefinitionMeta[]\n): CompiledPattern[] {\n const compiled: CompiledPattern[] = [];\n for (const def of definitions) {\n try {\n const registry = new ParameterTypeRegistry();\n for (const [, name] of def.expression.matchAll(PARAM_TOKEN)) {\n if (!name || registry.lookupByTypeName(name)) continue;\n registry.defineParameterType(\n new ParameterType(name, /.+/, null, (value: string) => value)\n );\n }\n compiled.push({\n expression: new CucumberExpression(def.expression, registry),\n definition: def,\n });\n } catch {\n // Skip definitions whose expression can't be compiled.\n }\n }\n return compiled;\n}\n\nexport function matchScenarioSteps(\n scenario: ParsedScenario,\n definitions: StepDefinitionMeta[]\n): MatchedStep[] {\n const compiled = compileDefinitions(definitions);\n\n return scenario.steps.map(step => {\n const matches = findMatches(step.text, step.effectiveKeyword, compiled);\n return {\n ...step,\n definitions: matches,\n };\n });\n}\n\nexport function findMatchingDefinitions(\n text: string,\n effectiveKeyword: \"Given\" | \"When\" | \"Then\",\n definitions: StepDefinitionMeta[]\n): StepDefinitionMeta[] {\n const compiled = compileDefinitions(definitions);\n return findMatches(text, effectiveKeyword, compiled);\n}\n\nfunction findMatches(\n text: string,\n effectiveKeyword: \"Given\" | \"When\" | \"Then\",\n compiled: CompiledPattern[]\n): StepDefinitionMeta[] {\n const keywordToStepType: Record<string, string> = {\n Given: \"given\",\n When: \"when\",\n Then: \"then\",\n };\n const expectedStepType = keywordToStepType[effectiveKeyword];\n\n // First try to match with the correct step type\n const typedMatches: StepDefinitionMeta[] = [];\n for (const { expression, definition } of compiled) {\n if (definition.stepType !== expectedStepType) continue;\n if (expression.match(text) != null) typedMatches.push(definition);\n }\n\n if (typedMatches.length > 0) return typedMatches;\n\n // Fallback: match any step type\n const fallbackMatches: StepDefinitionMeta[] = [];\n for (const { expression, definition } of compiled) {\n if (expression.match(text) != null) fallbackMatches.push(definition);\n }\n\n return fallbackMatches;\n}\n","import {\n AnalysisRule,\n Diagnostic,\n MatchedStep,\n ParsedScenario,\n} from \"../types.js\";\n\nexport const ambiguousStepRule: AnalysisRule = {\n name: \"ambiguous-step\",\n\n check(\n scenario: ParsedScenario,\n matchedSteps: MatchedStep[]\n ): Diagnostic[] {\n return matchedSteps\n .filter((step) => step.definitions.length > 1)\n .map((step) => {\n const locations = step.definitions\n .map((d) => `${d.sourceFile}:${d.line}`)\n .join(\", \");\n return {\n file: scenario.file,\n range: {\n startLine: step.line,\n startColumn: step.column,\n endLine: step.line,\n endColumn: step.column + step.text.length,\n },\n severity: \"error\" as const,\n message: `Step \"${step.text}\" matches multiple step definitions: ${locations}`,\n rule: \"ambiguous-step\",\n source: \"step-forge\" as const,\n };\n });\n },\n};\n","import {\n AnalysisRule,\n Diagnostic,\n MatchedStep,\n ParsedScenario,\n} from \"../types.js\";\n\nexport const dependencyRule: AnalysisRule = {\n name: \"dependency-check\",\n\n check(\n scenario: ParsedScenario,\n matchedSteps: MatchedStep[]\n ): Diagnostic[] {\n const diagnostics: Diagnostic[] = [];\n const produced = {\n given: new Set<string>(),\n when: new Set<string>(),\n then: new Set<string>(),\n };\n\n for (const step of matchedSteps) {\n if (step.definitions.length !== 1) continue;\n\n const { dependencies, produces, stepType } = step.definitions[0];\n\n // Collect all missing required dependencies for this step\n const missing: Record<string, string[]> = {};\n for (const phase of [\"given\", \"when\", \"then\"] as const) {\n for (const [key, requirement] of Object.entries(dependencies[phase])) {\n if (requirement === \"required\" && !produced[phase].has(key)) {\n if (!missing[phase]) {\n missing[phase] = [];\n }\n missing[phase].push(key);\n }\n }\n }\n\n if (Object.keys(missing).length > 0) {\n const lines = Object.entries(missing).map(\n ([phase, keys]) =>\n `${phase.charAt(0).toUpperCase() + phase.slice(1)}: ${keys.map((k) => `${phase}.${k}`).join(\", \")}`\n );\n const message =\n \"Missing required dependencies:\\n\" + lines.join(\"\\n\");\n\n diagnostics.push({\n file: scenario.file,\n range: {\n startLine: step.line,\n startColumn: step.column,\n endLine: step.line,\n endColumn: step.column + step.text.length,\n },\n severity: \"error\",\n message,\n rule: \"dependency-check\",\n source: \"step-forge\",\n });\n }\n\n // Add produced keys for this step\n for (const key of produces) {\n produced[stepType].add(key);\n }\n }\n\n return diagnostics;\n },\n};\n","import {\n AnalysisRule,\n Diagnostic,\n MatchedStep,\n ParsedScenario,\n} from \"../types.js\";\n\nexport const undefinedStepRule: AnalysisRule = {\n name: \"undefined-step\",\n\n check(\n scenario: ParsedScenario,\n matchedSteps: MatchedStep[]\n ): Diagnostic[] {\n return matchedSteps\n .filter((step) => step.definitions.length === 0)\n .map((step) => ({\n file: scenario.file,\n range: {\n startLine: step.line,\n startColumn: step.column,\n endLine: step.line,\n endColumn: step.column + step.text.length,\n },\n severity: \"error\" as const,\n message: `Step \"${step.text}\" does not match any step definition`,\n rule: \"undefined-step\",\n source: \"step-forge\" as const,\n }));\n },\n};\n","import {\n AnalysisRule,\n Diagnostic,\n MatchedStep,\n ParsedScenario,\n} from \"../types.js\";\nimport { ambiguousStepRule } from \"./ambiguousStepRule.js\";\nimport { dependencyRule } from \"./dependencyRule.js\";\nimport { undefinedStepRule } from \"./undefinedStepRule.js\";\n\nexport const defaultRules: AnalysisRule[] = [\n undefinedStepRule,\n ambiguousStepRule,\n dependencyRule,\n];\n\nexport function runRules(\n rules: AnalysisRule[],\n scenario: ParsedScenario,\n matchedSteps: MatchedStep[]\n): Diagnostic[] {\n return rules.flatMap((rule) => rule.check(scenario, matchedSteps));\n}\n","import { globFiles } from \"../globFiles.js\";\nimport { extractStepDefinitions } from \"./stepExtractor.js\";\nimport { parseFeatureFiles, parseFeatureContent } from \"./gherkinParser.js\";\nimport { matchScenarioSteps, findMatchingDefinitions } from \"./stepMatcher.js\";\nimport { defaultRules, runRules } from \"./rules/index.js\";\nimport type {\n AnalyzerConfig,\n AnalysisRule,\n Diagnostic,\n StepDefinitionMeta,\n ParsedScenario,\n MatchedStep,\n ParsedStep,\n} from \"./types.js\";\n\nexport type {\n AnalyzerConfig,\n AnalysisRule,\n Diagnostic,\n StepDefinitionMeta,\n ParsedScenario,\n MatchedStep,\n ParsedStep,\n};\n\nexport {\n extractStepDefinitions,\n parseFeatureFiles,\n parseFeatureContent,\n matchScenarioSteps,\n findMatchingDefinitions,\n defaultRules,\n};\n\nexport interface AnalyzeOptions {\n rules?: AnalysisRule[];\n}\n\nexport async function analyze(\n config: AnalyzerConfig,\n options?: AnalyzeOptions\n): Promise<Diagnostic[]> {\n const rules = options?.rules ?? defaultRules;\n\n // 1. Resolve file globs to paths\n const stepFilePaths = await globFiles(config.stepFiles);\n const featureFilePaths = await globFiles(config.featureFiles);\n\n if (stepFilePaths.length === 0) {\n return [];\n }\n if (featureFilePaths.length === 0) {\n return [];\n }\n\n // 2. Extract step metadata from step files\n const stepDefinitions = extractStepDefinitions(\n stepFilePaths,\n config.tsConfigPath\n );\n\n // 3. Parse feature files\n const scenarios = parseFeatureFiles(featureFilePaths);\n\n // 4. For each scenario, match steps and run rules\n const diagnostics: Diagnostic[] = [];\n for (const scenario of scenarios) {\n const matchedSteps = matchScenarioSteps(scenario, stepDefinitions);\n const scenarioDiags = runRules(rules, scenario, matchedSteps);\n diagnostics.push(...scenarioDiags);\n }\n\n return diagnostics;\n}\n"],"mappings":";;;;;AAKA,MAAM,gBAA0C;CAC9C,cAAc;CACd,aAAa;CACb,aAAa;AACf;;;;;;;;;;AAWA,MAAM,8BAAsD;CAC1D,WAAW;CACX,cAAc;CACd,cAAc;CACd,eAAe;AACjB;AAYA,SAAgB,uBACd,WACA,cACsB;CAUtB,MAAM,OAAO,mBAHG,UACb,IAAI,eAAe,CAAC,CACpB,QAAQ,MAA0B,MAAM,IACL,GAAG,IAAI;CAC7C,IAAI,CAAC,KAAK,cAAc,OAAO,KAAK;CAKpC,MAAM,UAAUA,WAAAA,QAAG,cACjB,WACA,uBAAuB,YAAY,CACrC;CACA,MAAM,UAAU,QAAQ,eAAe;CAIvC,OAAO,mBAHgB,UACpB,KAAI,OAAM,QAAQ,cAAc,EAAE,CAAC,CAAC,CACpC,QAAQ,MAA0B,MAAM,KAAA,CACJ,GAAG,OAAO,CAAC,CAAC;AACrD;;AAGA,SAAS,gBAAgB,UAAwC;CAC/D,MAAM,OAAOA,WAAAA,QAAG,IAAI,SAAS,QAAQ;CACrC,IAAI,SAAS,KAAA,GAAW,OAAO;CAC/B,MAAM,aAAa,SAAS,SAAS,MAAM,IACvCA,WAAAA,QAAG,WAAW,MACdA,WAAAA,QAAG,WAAW;CAGlB,OAAOA,WAAAA,QAAG,iBACR,UACA,MACAA,WAAAA,QAAG,aAAa,QAChB,MACA,UACF;AACF;;AAGA,SAAS,uBAAuB,cAA2C;CACzE,MAAM,aACJ,gBAAgBA,WAAAA,QAAG,eAAe,QAAQ,IAAI,GAAGA,WAAAA,QAAG,IAAI,UAAU;CACpE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