@llipe.com/dev-tasks 0.8.0 → 0.9.1

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.
Files changed (99) hide show
  1. package/.claude/agents/developer.md +16 -11
  2. package/.claude/agents/qa-engineer.md +104 -0
  3. package/.claude/agents/verifier.md +1 -1
  4. package/.claude/commands/developer.md +14 -10
  5. package/.claude/commands/planner.md +10 -8
  6. package/.claude/commands/qa-engineer.md +23 -0
  7. package/.claude/skills/activity-coverage-gap-analysis/SKILL.md +107 -0
  8. package/.claude/skills/activity-test-implementation/SKILL.md +109 -0
  9. package/.claude/skills/activity-test-standards/SKILL.md +122 -0
  10. package/.claude/skills/implement/SKILL.md +14 -12
  11. package/.github/agents/developer.agent.md +16 -11
  12. package/.github/agents/planner.agent.md +10 -8
  13. package/.github/agents/qa-engineer.agent.md +104 -0
  14. package/.github/agents/verifier.agent.md +1 -1
  15. package/.github/instructions/implement.instructions.md +14 -12
  16. package/.github/prompts/qa-engineer.prompt.md +23 -0
  17. package/.github/skills/activity-coverage-gap-analysis/SKILL.md +107 -0
  18. package/.github/skills/activity-test-implementation/SKILL.md +109 -0
  19. package/.github/skills/activity-test-standards/SKILL.md +122 -0
  20. package/.kiro/agents/developer.md +16 -11
  21. package/.kiro/agents/planner.md +10 -8
  22. package/.kiro/agents/qa-engineer.md +108 -0
  23. package/.kiro/agents/verifier.md +1 -1
  24. package/.kiro/skills/activity-coverage-gap-analysis/SKILL.md +107 -0
  25. package/.kiro/skills/activity-test-implementation/SKILL.md +109 -0
  26. package/.kiro/skills/activity-test-standards/SKILL.md +122 -0
  27. package/.kiro/steering/implement.md +14 -12
  28. package/AGENTS.md +50 -23
  29. package/CHANGELOG.md +56 -0
  30. package/CLAUDE.md +6 -3
  31. package/README.md +108 -112
  32. package/TESTING.md +183 -0
  33. package/bundle-manifest.json +1 -0
  34. package/dist/core/distribution/install.d.ts.map +1 -1
  35. package/dist/core/distribution/install.js +25 -2
  36. package/dist/core/distribution/install.js.map +1 -1
  37. package/dist/core/distribution/profiles.d.ts +21 -0
  38. package/dist/core/distribution/profiles.d.ts.map +1 -1
  39. package/dist/core/distribution/profiles.js +21 -0
  40. package/dist/core/distribution/profiles.js.map +1 -1
  41. package/dist/core/distribution/update.d.ts +3 -0
  42. package/dist/core/distribution/update.d.ts.map +1 -1
  43. package/dist/core/distribution/update.js +141 -15
  44. package/dist/core/distribution/update.js.map +1 -1
  45. package/dist/core/extract/asyncapi/declared.d.ts +19 -0
  46. package/dist/core/extract/asyncapi/declared.d.ts.map +1 -0
  47. package/dist/core/extract/asyncapi/declared.js +168 -0
  48. package/dist/core/extract/asyncapi/declared.js.map +1 -0
  49. package/dist/core/extract/asyncapi/index.d.ts +1 -0
  50. package/dist/core/extract/asyncapi/index.d.ts.map +1 -1
  51. package/dist/core/extract/asyncapi/index.js +1 -0
  52. package/dist/core/extract/asyncapi/index.js.map +1 -1
  53. package/dist/core/extract/asyncapi/types.d.ts +1 -1
  54. package/dist/core/extract/asyncapi/types.d.ts.map +1 -1
  55. package/dist/core/extract/ladder.d.ts +79 -0
  56. package/dist/core/extract/ladder.d.ts.map +1 -0
  57. package/dist/core/extract/ladder.js +70 -0
  58. package/dist/core/extract/ladder.js.map +1 -0
  59. package/dist/core/extract/openapi/index.d.ts +35 -5
  60. package/dist/core/extract/openapi/index.d.ts.map +1 -1
  61. package/dist/core/extract/openapi/index.js +136 -3
  62. package/dist/core/extract/openapi/index.js.map +1 -1
  63. package/dist/core/extract/openapi/route2-introspect.d.ts +18 -0
  64. package/dist/core/extract/openapi/route2-introspect.d.ts.map +1 -0
  65. package/dist/core/extract/openapi/route2-introspect.js +249 -0
  66. package/dist/core/extract/openapi/route2-introspect.js.map +1 -0
  67. package/dist/core/extract/openapi/route2.d.ts +40 -17
  68. package/dist/core/extract/openapi/route2.d.ts.map +1 -1
  69. package/dist/core/extract/openapi/route2.js +202 -10
  70. package/dist/core/extract/openapi/route2.js.map +1 -1
  71. package/dist/core/extract/openapi/types.d.ts +3 -3
  72. package/dist/core/extract/openapi/types.d.ts.map +1 -1
  73. package/dist/core/extract/provider.d.ts +4 -0
  74. package/dist/core/extract/provider.d.ts.map +1 -1
  75. package/dist/core/extract/report.d.ts +29 -1
  76. package/dist/core/extract/report.d.ts.map +1 -1
  77. package/dist/core/extract/report.js +7 -2
  78. package/dist/core/extract/report.js.map +1 -1
  79. package/dist/core/extract/schema.d.ts +16 -18
  80. package/dist/core/extract/schema.d.ts.map +1 -1
  81. package/dist/core/extract/schema.js +48 -43
  82. package/dist/core/extract/schema.js.map +1 -1
  83. package/dist/core/extract/workspaces.d.ts +33 -0
  84. package/dist/core/extract/workspaces.d.ts.map +1 -0
  85. package/dist/core/extract/workspaces.js +193 -0
  86. package/dist/core/extract/workspaces.js.map +1 -0
  87. package/package.json +11 -2
  88. package/dist/core/extract/openapi/llm-descriptions.d.ts +0 -41
  89. package/dist/core/extract/openapi/llm-descriptions.d.ts.map +0 -1
  90. package/dist/core/extract/openapi/llm-descriptions.js +0 -36
  91. package/dist/core/extract/openapi/llm-descriptions.js.map +0 -1
  92. package/dist/core/extract/orm/llm-descriptions.d.ts +0 -28
  93. package/dist/core/extract/orm/llm-descriptions.d.ts.map +0 -1
  94. package/dist/core/extract/orm/llm-descriptions.js +0 -64
  95. package/dist/core/extract/orm/llm-descriptions.js.map +0 -1
  96. package/dist/core/extract/orm/migration-inference.d.ts +0 -25
  97. package/dist/core/extract/orm/migration-inference.d.ts.map +0 -1
  98. package/dist/core/extract/orm/migration-inference.js +0 -76
  99. package/dist/core/extract/orm/migration-inference.js.map +0 -1
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Extraction ladder runner.
3
+ *
4
+ * Runs extraction rungs in order (declared → observed → inferred) and returns
5
+ * the first usable result with provenance metadata and confidence policy.
6
+ *
7
+ * Confidence policy (enforced, not convention):
8
+ * - declared → high
9
+ * - observed → high
10
+ * - inferred → low (capped — an inferred rung MUST NOT emit medium or high)
11
+ */
12
+ /**
13
+ * Confidence policy: maps rung kind to confidence level.
14
+ * Inferred is always capped at "low" regardless of what the rung claims.
15
+ */
16
+ export function getConfidenceForRung(kind) {
17
+ switch (kind) {
18
+ case "declared":
19
+ return "high";
20
+ case "observed":
21
+ return "high";
22
+ case "inferred":
23
+ return "low";
24
+ }
25
+ }
26
+ /**
27
+ * Run the extraction ladder.
28
+ *
29
+ * Executes rungs in array order (caller should provide them as
30
+ * declared → observed → inferred). Stops at the first rung that
31
+ * produces a non-null result. Collects diagnostics from all attempted rungs.
32
+ *
33
+ * Confidence is determined by the ladder policy, not the rung output.
34
+ */
35
+ export function runLadder(rungs) {
36
+ const allDiagnostics = [];
37
+ for (const rung of rungs) {
38
+ let output;
39
+ try {
40
+ output = rung.execute();
41
+ }
42
+ catch (err) {
43
+ // Rung threw — treat as unavailable with a diagnostic
44
+ const message = err instanceof Error ? err.message : String(err);
45
+ allDiagnostics.push(`${rung.name} failed: ${message}`);
46
+ continue;
47
+ }
48
+ // Collect diagnostics from this rung regardless of result
49
+ allDiagnostics.push(...output.diagnostics);
50
+ if (output.result !== null) {
51
+ // Winner found — apply confidence policy and return
52
+ return {
53
+ result: output.result,
54
+ winningRung: rung.kind,
55
+ confidence: getConfidenceForRung(rung.kind),
56
+ provenance: { rung: rung.kind, name: rung.name },
57
+ diagnostics: allDiagnostics,
58
+ };
59
+ }
60
+ }
61
+ // All rungs failed
62
+ return {
63
+ result: null,
64
+ winningRung: null,
65
+ confidence: "low",
66
+ provenance: null,
67
+ diagnostics: allDiagnostics,
68
+ };
69
+ }
70
+ //# sourceMappingURL=ladder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ladder.js","sourceRoot":"","sources":["../../../core/extract/ladder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AA4DH;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,IAAc;IACjD,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,UAAU;YACb,OAAO,MAAM,CAAC;QACh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AAC;AACJ,CAAC"}
@@ -1,13 +1,43 @@
1
1
  /**
2
- * OpenAPI extraction module barrel export.
2
+ * OpenAPI extraction module barrel export and ladder orchestrator.
3
3
  */
4
4
  export type { ExtractedEndpoint, OpenApiConfidence, OpenApiDocument, OpenApiExtractionResult, OpenApiSource, RequestBodySchema, ResponseSchema, RouteParam, UnresolvedRoute, } from "./types.js";
5
5
  export { extractRoute1, detectOnDiskSpec, normalizeSpec, Route1Error } from "./route1.js";
6
6
  export { extractRoute3, composePath, extractPathParams } from "./route3.js";
7
- export { extractRoute2 } from "./route2.js";
8
- export type { Route2Config, Route2Extractor } from "./route2.js";
7
+ export { extractRoute2, extractRoute2Express } from "./route2.js";
8
+ export type { Route2Config, Route2Extractor, Route2Options } from "./route2.js";
9
9
  export { validateOpenApi, extractionResultToDocument } from "./validate.js";
10
10
  export type { ValidationResult, ValidationError } from "./validate.js";
11
- export { applyLlmDescriptions } from "./llm-descriptions.js";
12
- export type { OpenApiLlmProvider } from "./llm-descriptions.js";
11
+ import { type LadderResult } from "../ladder.js";
12
+ import type { OpenApiExtractionResult } from "./types.js";
13
+ /**
14
+ * Options for the OpenAPI ladder extraction.
15
+ */
16
+ export interface OpenApiLadderOptions {
17
+ /** Root directory of the project */
18
+ rootDir: string;
19
+ /** Override entry point for route2 boot */
20
+ entry?: string;
21
+ /** Skip the observed (boot) rung */
22
+ noBoot?: boolean;
23
+ /** Timeout for boot in ms (default: 10000) */
24
+ bootTimeout?: number;
25
+ }
26
+ /**
27
+ * Result from the OpenAPI ladder extraction.
28
+ */
29
+ export interface OpenApiLadderResult {
30
+ /** The extraction result (null if all rungs failed) */
31
+ extraction: OpenApiExtractionResult | null;
32
+ /** Ladder metadata */
33
+ ladder: LadderResult<OpenApiExtractionResult>;
34
+ }
35
+ /**
36
+ * Run the OpenAPI extraction ladder: declared → observed → inferred.
37
+ *
38
+ * 1. Declared (route1): Look for on-disk OpenAPI spec
39
+ * 2. Observed (route2): Boot the app and introspect the router
40
+ * 3. Inferred (route3): AST analysis (always low confidence)
41
+ */
42
+ export declare function extractOpenApiLadder(options: OpenApiLadderOptions): Promise<OpenApiLadderResult>;
13
43
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../core/extract/openapi/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC5E,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,YAAY,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../core/extract/openapi/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,YAAY,EACV,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,uBAAuB,EACvB,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAClE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAC5E,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAIvE,OAAO,EAAa,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAK1D;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;IAChB,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,oCAAoC;IACpC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8CAA8C;IAC9C,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,uDAAuD;IACvD,UAAU,EAAE,uBAAuB,GAAG,IAAI,CAAC;IAC3C,sBAAsB;IACtB,MAAM,EAAE,YAAY,CAAC,uBAAuB,CAAC,CAAC;CAC/C;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,CAgI9B"}
@@ -1,9 +1,142 @@
1
1
  /**
2
- * OpenAPI extraction module barrel export.
2
+ * OpenAPI extraction module barrel export and ladder orchestrator.
3
3
  */
4
4
  export { extractRoute1, detectOnDiskSpec, normalizeSpec, Route1Error } from "./route1.js";
5
5
  export { extractRoute3, composePath, extractPathParams } from "./route3.js";
6
- export { extractRoute2 } from "./route2.js";
6
+ export { extractRoute2, extractRoute2Express } from "./route2.js";
7
7
  export { validateOpenApi, extractionResultToDocument } from "./validate.js";
8
- export { applyLlmDescriptions } from "./llm-descriptions.js";
8
+ import { extractRoute1 } from "./route1.js";
9
+ import { extractRoute2Express } from "./route2.js";
10
+ import { extractRoute3 } from "./route3.js";
11
+ /**
12
+ * Run the OpenAPI extraction ladder: declared → observed → inferred.
13
+ *
14
+ * 1. Declared (route1): Look for on-disk OpenAPI spec
15
+ * 2. Observed (route2): Boot the app and introspect the router
16
+ * 3. Inferred (route3): AST analysis (always low confidence)
17
+ */
18
+ export async function extractOpenApiLadder(options) {
19
+ const { rootDir, entry, noBoot, bootTimeout } = options;
20
+ const rungs = [
21
+ // Rung 1: Declared — on-disk spec
22
+ {
23
+ kind: "declared",
24
+ name: "route1-on-disk-spec",
25
+ execute: () => {
26
+ try {
27
+ const result = extractRoute1(rootDir);
28
+ return { result, diagnostics: result ? [] : ["No on-disk OpenAPI spec found"] };
29
+ }
30
+ catch (err) {
31
+ return {
32
+ result: null,
33
+ diagnostics: [`route1 failed: ${err instanceof Error ? err.message : String(err)}`],
34
+ };
35
+ }
36
+ },
37
+ },
38
+ ];
39
+ // Rung 2: Observed — boot + introspect (skip if --no-boot)
40
+ if (!noBoot) {
41
+ rungs.push({
42
+ kind: "observed",
43
+ name: "route2-boot-introspect",
44
+ execute: () => {
45
+ // Route2 is async but ladder is sync — we need a sync wrapper.
46
+ // This is handled by running the ladder async below.
47
+ // Placeholder — will be replaced in async execution.
48
+ return { result: null, diagnostics: ["route2 requires async execution"] };
49
+ },
50
+ });
51
+ }
52
+ // Rung 3: Inferred — AST analysis (always low confidence)
53
+ rungs.push({
54
+ kind: "inferred",
55
+ name: "route3-ast-inference",
56
+ execute: () => {
57
+ try {
58
+ const result = extractRoute3(rootDir);
59
+ if (result.endpoints.length === 0) {
60
+ return { result: null, diagnostics: ["route3 found no endpoints"] };
61
+ }
62
+ // Force confidence: low on all endpoints (ladder policy enforces this)
63
+ const lowConfResult = {
64
+ ...result,
65
+ confidence: "low",
66
+ endpoints: result.endpoints.map((e) => ({ ...e, confidence: "low" })),
67
+ };
68
+ return { result: lowConfResult, diagnostics: [] };
69
+ }
70
+ catch (err) {
71
+ return {
72
+ result: null,
73
+ diagnostics: [`route3 failed: ${err instanceof Error ? err.message : String(err)}`],
74
+ };
75
+ }
76
+ },
77
+ });
78
+ // Since route2 is async, we run a custom ladder that handles it.
79
+ // First try route1 (sync)
80
+ const route1Result = rungs[0].execute();
81
+ if (route1Result.result) {
82
+ const ladderResult = {
83
+ result: route1Result.result,
84
+ winningRung: "declared",
85
+ confidence: "high",
86
+ provenance: { rung: "declared", name: "route1-on-disk-spec" },
87
+ diagnostics: route1Result.diagnostics,
88
+ };
89
+ return { extraction: route1Result.result, ladder: ladderResult };
90
+ }
91
+ // Try route2 (async) if not skipped
92
+ const allDiagnostics = [...route1Result.diagnostics];
93
+ if (!noBoot) {
94
+ try {
95
+ const route2Result = await extractRoute2Express(rootDir, {
96
+ entry,
97
+ timeout: bootTimeout,
98
+ });
99
+ if (route2Result && route2Result.endpoints.length > 0) {
100
+ const ladderResult = {
101
+ result: route2Result,
102
+ winningRung: "observed",
103
+ confidence: "high",
104
+ provenance: { rung: "observed", name: "route2-boot-introspect" },
105
+ diagnostics: allDiagnostics,
106
+ };
107
+ return { extraction: route2Result, ladder: ladderResult };
108
+ }
109
+ allDiagnostics.push("route2 returned no endpoints or null");
110
+ }
111
+ catch (err) {
112
+ allDiagnostics.push(`route2 failed: ${err instanceof Error ? err.message : String(err)}`);
113
+ }
114
+ }
115
+ else {
116
+ allDiagnostics.push("route2 skipped (--no-boot)");
117
+ }
118
+ // Try route3 (sync) — inferred, always low confidence
119
+ const route3Rung = rungs[rungs.length - 1];
120
+ const route3Result = route3Rung.execute();
121
+ allDiagnostics.push(...route3Result.diagnostics);
122
+ if (route3Result.result) {
123
+ const ladderResult = {
124
+ result: route3Result.result,
125
+ winningRung: "inferred",
126
+ confidence: "low",
127
+ provenance: { rung: "inferred", name: "route3-ast-inference" },
128
+ diagnostics: allDiagnostics,
129
+ };
130
+ return { extraction: route3Result.result, ladder: ladderResult };
131
+ }
132
+ // All failed
133
+ const ladderResult = {
134
+ result: null,
135
+ winningRung: null,
136
+ confidence: "low",
137
+ provenance: null,
138
+ diagnostics: allDiagnostics,
139
+ };
140
+ return { extraction: null, ladder: ladderResult };
141
+ }
9
142
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../core/extract/openapi/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAcH,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAE5E,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../core/extract/openapi/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAcH,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1F,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAElE,OAAO,EAAE,eAAe,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAO5E,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AA0B5C;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oB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AAE,CAAC;QACxB,MAAM,YAAY,GAA0C;YAC1D,MAAM,EAAE,YAAY,CAAC,MAAM;YAC3B,WAAW,EAAE,UAAU;YACvB,UAAU,EAAE,KAAK;YACjB,UAAU,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,sBAAsB,EAAE;YAC9D,WAAW,EAAE,cAAc;SAC5B,CAAC;QACF,OAAO,EAAE,UAAU,EAAE,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;IACnE,CAAC;IAED,aAAa;IACb,MAAM,YAAY,GAA0C;QAC1D,MAAM,EAAE,IAAI;QACZ,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,KAAK;QACjB,UAAU,EAAE,IAAI;QAChB,WAAW,EAAE,cAAc;KAC5B,CAAC;IACF,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;AACpD,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Route 2 Introspection Script — runs as a child process.
3
+ *
4
+ * This script:
5
+ * 1. Receives the app entry point path via argv[2]
6
+ * 2. Imports the module
7
+ * 3. Locates the Express app export (default, named `app`, or `createApp()` factory)
8
+ * 4. Walks the router stack recursively to enumerate all routes
9
+ * 5. Prints JSON to stdout
10
+ *
11
+ * Supports both Express 4 (app._router.stack) and Express 5 (app.router.stack).
12
+ *
13
+ * The parent process (`extractRoute2Express`) runs this via execa with a hard timeout.
14
+ * Any failure (import error, no app found, etc.) results in a non-zero exit with
15
+ * a JSON error payload on stderr.
16
+ */
17
+ export {};
18
+ //# sourceMappingURL=route2-introspect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route2-introspect.d.ts","sourceRoot":"","sources":["../../../../core/extract/openapi/route2-introspect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG"}
@@ -0,0 +1,249 @@
1
+ /**
2
+ * Route 2 Introspection Script — runs as a child process.
3
+ *
4
+ * This script:
5
+ * 1. Receives the app entry point path via argv[2]
6
+ * 2. Imports the module
7
+ * 3. Locates the Express app export (default, named `app`, or `createApp()` factory)
8
+ * 4. Walks the router stack recursively to enumerate all routes
9
+ * 5. Prints JSON to stdout
10
+ *
11
+ * Supports both Express 4 (app._router.stack) and Express 5 (app.router.stack).
12
+ *
13
+ * The parent process (`extractRoute2Express`) runs this via execa with a hard timeout.
14
+ * Any failure (import error, no app found, etc.) results in a non-zero exit with
15
+ * a JSON error payload on stderr.
16
+ */
17
+ import { resolve } from "node:path";
18
+ import { pathToFileURL } from "node:url";
19
+ // Express 5 uses layer.match() to populate layer.path with the mount prefix
20
+ /**
21
+ * Walk the Express router stack recursively to extract all registered routes.
22
+ * Supports both Express 4 and Express 5 internal structures.
23
+ */
24
+ function walkStack(stack, basePath) {
25
+ const routes = [];
26
+ for (const layer of stack) {
27
+ if (layer.route) {
28
+ // This is a route layer (app.get, app.post, etc.)
29
+ const route = layer.route;
30
+ const fullPath = composePath(basePath, route.path);
31
+ for (const method of Object.keys(route.methods)) {
32
+ if (route.methods[method]) {
33
+ routes.push({ method, path: fullPath });
34
+ }
35
+ }
36
+ }
37
+ else if (layer.handle && layer.handle.stack) {
38
+ // This is a mounted sub-router
39
+ const prefix = extractMountPrefix(layer);
40
+ const nestedPath = composePath(basePath, prefix);
41
+ const nestedStack = layer.handle.stack;
42
+ routes.push(...walkStack(nestedStack, nestedPath));
43
+ }
44
+ }
45
+ return routes;
46
+ }
47
+ /**
48
+ * Extract the mount prefix from a router layer.
49
+ *
50
+ * Express 4: uses layer.regexp or layer.path
51
+ * Express 5: uses layer.match() — calling match populates layer.path
52
+ */
53
+ function extractMountPrefix(layer) {
54
+ // Express 5: use Layer.match() if available
55
+ if (typeof layer.match === "function") {
56
+ // We need a test path that would match. Express 5 uses prefix matching for
57
+ // use() middleware, so try common patterns until one matches.
58
+ const testPaths = generateTestPaths();
59
+ for (const testPath of testPaths) {
60
+ const matched = layer.match(testPath);
61
+ if (matched && typeof layer.path === "string") {
62
+ return layer.path;
63
+ }
64
+ }
65
+ // If layer.path was already set (catch-all "/")
66
+ if (typeof layer.path === "string") {
67
+ return layer.path === "/" ? "" : layer.path;
68
+ }
69
+ return "";
70
+ }
71
+ // Express 4: try layer.path first
72
+ if (typeof layer.path === "string" && layer.path) {
73
+ return layer.path;
74
+ }
75
+ // Express 4: parse from regexp
76
+ const regexp = layer.regexp;
77
+ if (regexp) {
78
+ const source = regexp.source;
79
+ const match = source.match(/^\^((?:\\\/[^?(*]+)+)/);
80
+ if (match) {
81
+ return match[1].replace(/\\\//g, "/");
82
+ }
83
+ }
84
+ return "";
85
+ }
86
+ /**
87
+ * Generate test paths to probe Express 5 matchers.
88
+ * Includes common API prefixes and exhaustive single/double-segment combos.
89
+ */
90
+ function generateTestPaths() {
91
+ const paths = ["/"];
92
+ const segments = [
93
+ "api",
94
+ "v1",
95
+ "v2",
96
+ "v3",
97
+ "admin",
98
+ "auth",
99
+ "public",
100
+ "internal",
101
+ "health",
102
+ "metrics",
103
+ "webhooks",
104
+ "users",
105
+ "static",
106
+ "assets",
107
+ ];
108
+ // Single-segment paths
109
+ for (const seg of segments) {
110
+ paths.push(`/${seg}/test`);
111
+ }
112
+ // Double-segment paths (cover /api/v1, /api/v2, etc.)
113
+ for (const s1 of segments) {
114
+ for (const s2 of segments) {
115
+ paths.push(`/${s1}/${s2}/test`);
116
+ }
117
+ }
118
+ return paths;
119
+ }
120
+ /**
121
+ * Compose two path segments, handling trailing/leading slashes.
122
+ */
123
+ function composePath(base, segment) {
124
+ const normalizedBase = base.replace(/\/+$/, "");
125
+ const normalizedSegment = segment.startsWith("/") ? segment : segment ? `/${segment}` : "";
126
+ const composed = normalizedBase + normalizedSegment;
127
+ return composed || "/";
128
+ }
129
+ /**
130
+ * Try to locate an Express app from a module's exports.
131
+ * Checks: default export, named `app`, `createApp()` factory.
132
+ */
133
+ function findExpressApp(moduleExports) {
134
+ // Check default export
135
+ if (moduleExports.default && isExpressApp(moduleExports.default)) {
136
+ return moduleExports.default;
137
+ }
138
+ // Check named `app` export
139
+ if (moduleExports.app && isExpressApp(moduleExports.app)) {
140
+ return moduleExports.app;
141
+ }
142
+ // Check `createApp` factory
143
+ if (typeof moduleExports.createApp === "function") {
144
+ try {
145
+ const app = moduleExports.createApp();
146
+ if (isExpressApp(app))
147
+ return app;
148
+ }
149
+ catch {
150
+ // Factory failed, continue
151
+ }
152
+ }
153
+ // Check any export that looks like an Express app
154
+ for (const key of Object.keys(moduleExports)) {
155
+ if (key === "default" || key === "app" || key === "createApp")
156
+ continue;
157
+ if (isExpressApp(moduleExports[key])) {
158
+ return moduleExports[key];
159
+ }
160
+ }
161
+ return null;
162
+ }
163
+ /**
164
+ * Check if a value looks like an Express app.
165
+ * Express 4: app._router.stack
166
+ * Express 5: app.router.stack
167
+ */
168
+ function isExpressApp(value) {
169
+ if (!value || typeof value !== "function")
170
+ return false;
171
+ return getRouterStack(value) !== null;
172
+ }
173
+ /**
174
+ * Get the router stack from an Express app (supports Express 4 and 5).
175
+ */
176
+ function getRouterStack(app) {
177
+ // Express 5: app.router.stack
178
+ const router5 = app.router;
179
+ if (router5 &&
180
+ typeof router5 === "function" &&
181
+ Array.isArray(router5.stack)) {
182
+ return router5.stack;
183
+ }
184
+ if (router5 && typeof router5 === "object" && Array.isArray(router5.stack)) {
185
+ return router5.stack;
186
+ }
187
+ // Express 4: app._router.stack
188
+ const router4 = app._router;
189
+ if (router4 && Array.isArray(router4.stack)) {
190
+ return router4.stack;
191
+ }
192
+ return null;
193
+ }
194
+ async function main() {
195
+ const entryPath = process.argv[2];
196
+ if (!entryPath) {
197
+ const error = { error: "No entry point provided", code: "no-entry" };
198
+ process.stderr.write(JSON.stringify(error));
199
+ process.exit(1);
200
+ }
201
+ const absoluteEntry = resolve(entryPath);
202
+ const entryUrl = pathToFileURL(absoluteEntry).href;
203
+ let moduleExports;
204
+ try {
205
+ moduleExports = (await import(entryUrl));
206
+ }
207
+ catch (err) {
208
+ const error = {
209
+ error: `Failed to import: ${err instanceof Error ? err.message : String(err)}`,
210
+ code: "import-failed",
211
+ };
212
+ process.stderr.write(JSON.stringify(error));
213
+ process.exit(1);
214
+ }
215
+ const app = findExpressApp(moduleExports);
216
+ if (!app) {
217
+ const error = {
218
+ error: "No Express app export found (checked: default, app, createApp)",
219
+ code: "no-app-export",
220
+ };
221
+ process.stderr.write(JSON.stringify(error));
222
+ process.exit(1);
223
+ }
224
+ const stack = getRouterStack(app);
225
+ if (!stack) {
226
+ const error = {
227
+ error: "Express app found but router stack is not accessible",
228
+ code: "no-router-stack",
229
+ };
230
+ process.stderr.write(JSON.stringify(error));
231
+ process.exit(1);
232
+ }
233
+ const endpoints = walkStack(stack, "");
234
+ const result = {
235
+ endpoints,
236
+ framework: "express",
237
+ };
238
+ process.stdout.write(JSON.stringify(result));
239
+ process.exit(0);
240
+ }
241
+ main().catch((err) => {
242
+ const error = {
243
+ error: `Unexpected: ${err instanceof Error ? err.message : String(err)}`,
244
+ code: "unexpected",
245
+ };
246
+ process.stderr.write(JSON.stringify(error));
247
+ process.exit(1);
248
+ });
249
+ //# sourceMappingURL=route2-introspect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route2-introspect.js","sourceRoot":"","sources":["../../../../core/extract/openapi/route2-introspect.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAiBzC,4EAA4E;AAE5E;;;GAGG;AACH,SAAS,SAAS,CAAC,KAAqC,EAAE,QAAgB;IACxE,MAAM,MAAM,GAAsB,EAAE,CAAC;IAErC,KAAK,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;QAC1B,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;YAChB,kDAAkD;YAClD,MAAM,KAAK,GAAG,KAAK,CAAC,KAGnB,CAAC;YACF,MAAM,QAAQ,GAAG,WAAW,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CAAC;IAED,MAAM,KAAK,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;IAClC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,KAAK,GAAoB;YAC7B,KAAK,EAAE,sDAAsD;YAC7D,IAAI,EAAE,iBAAiB;SACxB,CAAC;QACF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;QAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,SAAS,GAAG,SAAS,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAEvC,MAAM,MAAM,GAAqB;QAC/B,SAAS;QACT,SAAS,EAAE,SAAS;KACrB,CAAC;IAEF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IAC7C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,MAAM,KAAK,GAAoB;QAC7B,KAAK,EAAE,eAAe,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE;QACxE,IAAI,EAAE,YAAY;KACnB,CAAC;IACF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;IAC5C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -1,16 +1,35 @@
1
1
  /**
2
- * OpenAPI Route 2: Isolated framework boot (NOT IMPLEMENTED).
2
+ * OpenAPI Route 2: Boot + Introspect route discovery.
3
3
  *
4
- * This file defines the interface for a future Route 2 extractor that would:
5
- * 1. Boot the framework in an isolated environment
6
- * 2. Introspect the route table at runtime
7
- * 3. Extract full OpenAPI specs with runtime type information
4
+ * Boots the application in a child process and walks the Express router stack
5
+ * to discover all registered routes — including dynamically-registered routes
6
+ * that AST analysis (route3) cannot resolve.
8
7
  *
9
- * This is a capability hook only — implementation is deferred.
8
+ * Strategy: spawn a child process that imports the app module, locates the
9
+ * Express app export, walks `app._router.stack`, and prints discovered routes
10
+ * as JSON to stdout. The parent process handles timeouts and failures gracefully.
11
+ *
12
+ * Failure taxonomy:
13
+ * - entry-not-found: no resolvable entry point in package.json or common paths
14
+ * - import-failed: module import threw an error
15
+ * - no-app-export: module loaded but no Express app found in exports
16
+ * - timeout: boot exceeded the configured timeout
17
+ * - parse-error: child process output was not valid JSON
18
+ *
19
+ * All failures return null (rung unavailable), never crash dt.
10
20
  */
11
21
  import type { OpenApiExtractionResult } from "./types.js";
12
22
  /**
13
- * Configuration for the route 2 framework boot extractor.
23
+ * Configuration for route2 extraction.
24
+ */
25
+ export interface Route2Options {
26
+ /** Override entry point path (relative to fixtureDir or absolute) */
27
+ entry?: string;
28
+ /** Timeout in milliseconds (default: 10000) */
29
+ timeout?: number;
30
+ }
31
+ /**
32
+ * Route2 extraction configuration (legacy interface kept for compatibility).
14
33
  */
15
34
  export interface Route2Config {
16
35
  /** Path to the application entry point */
@@ -25,22 +44,26 @@ export interface Route2Config {
25
44
  env?: Record<string, string>;
26
45
  }
27
46
  /**
28
- * Route 2 extractor interface.
29
- * A future implementation would:
30
- * 1. Spawn the app in a child process with instrumentation
31
- * 2. Wait for the server to be ready
32
- * 3. Query the framework's internal route table
33
- * 4. Shut down the process cleanly
47
+ * Route2 extractor interface (legacy — kept for compatibility).
34
48
  */
35
49
  export interface Route2Extractor {
36
- /** Boot the framework and extract the route table */
37
50
  extract(config: Route2Config): Promise<OpenApiExtractionResult>;
38
- /** Check if the framework can be booted (deps installed, entry point valid) */
39
51
  canBoot(config: Route2Config): Promise<boolean>;
40
52
  }
41
53
  /**
42
- * Placeholder: Route 2 is not yet implemented.
43
- * Calling this will throw an error indicating the feature is pending.
54
+ * Extract OpenAPI endpoints by booting an Express app and introspecting its router.
55
+ *
56
+ * Returns null if:
57
+ * - No entry point found
58
+ * - Boot fails (import error, no app export, timeout)
59
+ * - Output is unparseable
60
+ *
61
+ * Never throws — failures are "rung unavailable".
62
+ */
63
+ export declare function extractRoute2Express(rootDir: string, options?: Route2Options): Promise<OpenApiExtractionResult | null>;
64
+ /**
65
+ * Legacy placeholder — kept for backward compatibility with existing imports.
66
+ * @deprecated Use extractRoute2Express instead.
44
67
  */
45
68
  export declare function extractRoute2(_config: Route2Config): Promise<OpenApiExtractionResult>;
46
69
  //# sourceMappingURL=route2.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"route2.d.ts","sourceRoot":"","sources":["../../../../core/extract/openapi/route2.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,0CAA0C;IAC1C,UAAU,EAAE,MAAM,CAAC;IACnB,6BAA6B;IAC7B,SAAS,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;IACrD,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0DAA0D;IAC1D,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe;IAC9B,qDAAqD;IACrD,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IAChE,+EAA+E;IAC/E,OAAO,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CACjD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,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