@workos/oagen 0.3.0 → 0.5.0

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 (42) hide show
  1. package/README.md +72 -1
  2. package/dist/cli/index.mjs +955 -90
  3. package/dist/cli/index.mjs.map +1 -1
  4. package/dist/compat/index.d.mts +1 -1
  5. package/dist/compat/index.mjs +9 -4
  6. package/dist/compat/index.mjs.map +1 -1
  7. package/dist/{diff-Cn6S74vV.mjs → diff-CSy3g-Bq.mjs} +541 -43
  8. package/dist/diff-CSy3g-Bq.mjs.map +1 -0
  9. package/dist/{differ-B6472Yef.mjs → differ-CG5ZErKl.mjs} +2 -2
  10. package/dist/{differ-B6472Yef.mjs.map → differ-CG5ZErKl.mjs.map} +1 -1
  11. package/dist/index.d.mts +111 -3
  12. package/dist/index.d.mts.map +1 -1
  13. package/dist/index.mjs +340 -30
  14. package/dist/index.mjs.map +1 -1
  15. package/dist/scripts/smoke/baseline.mjs +317 -33
  16. package/dist/scripts/smoke/baseline.mjs.map +1 -1
  17. package/dist/smoke.d.mts +140 -0
  18. package/dist/smoke.d.mts.map +1 -1
  19. package/dist/smoke.mjs +317 -33
  20. package/dist/smoke.mjs.map +1 -1
  21. package/dist/{tree-sitter-DFRXfWg9.mjs → tree-sitter-C53w_0WE.mjs} +5 -7
  22. package/dist/tree-sitter-C53w_0WE.mjs.map +1 -0
  23. package/dist/{types-O25qZxMl.d.mts → types-D84LjrVG.d.mts} +167 -2
  24. package/dist/types-D84LjrVG.d.mts.map +1 -0
  25. package/dist/verify/index.d.mts +1 -1
  26. package/dist/verify/index.mjs +4 -4
  27. package/dist/verify/index.mjs.map +1 -1
  28. package/docs/agents/architecture.md +1 -1
  29. package/docs/architecture/emitter-contract.md +1 -2
  30. package/docs/architecture/ir-types.md +73 -1
  31. package/docs/architecture/pipeline.md +0 -1
  32. package/docs/cli.md +29 -8
  33. package/docs/core/minimal-emitter.md +0 -4
  34. package/docs/core/quickstart.md +0 -1
  35. package/examples/reference-emitter/README.md +0 -1
  36. package/examples/reference-emitter/src/emitter.ts +0 -5
  37. package/package.json +4 -4
  38. package/skills/review-operations/SKILL.md +83 -0
  39. package/dist/diff-Cn6S74vV.mjs.map +0 -1
  40. package/dist/tree-sitter-DFRXfWg9.mjs.map +0 -1
  41. package/dist/types-O25qZxMl.d.mts.map +0 -1
  42. package/examples/reference-emitter/src/generators/config.ts +0 -19
package/docs/cli.md CHANGED
@@ -122,6 +122,25 @@ oagen parse --spec openapi.yml
122
122
  | --------------- | -------- | ----------------------- | ------------------------------------------------ |
123
123
  | `--spec <path>` | No | `OPENAPI_SPEC_PATH` env | Path to an OpenAPI 3.x spec file (YAML or JSON). |
124
124
 
125
+ ## `oagen resolve`
126
+
127
+ Resolve operation names from the spec using the algorithm and optional hints. Outputs a review table (markdown) or JSON for programmatic use.
128
+
129
+ ```bash
130
+ # Markdown review table (default)
131
+ oagen resolve --spec openapi.yml
132
+
133
+ # JSON output for CI/scripting
134
+ oagen resolve --spec openapi.yml --format json
135
+ ```
136
+
137
+ | Argument | Required | Default | Description |
138
+ | ------------------- | -------- | ----------------------- | ------------------------------------------------ |
139
+ | `--spec <path>` | No | `OPENAPI_SPEC_PATH` env | Path to an OpenAPI 3.x spec file (YAML or JSON). |
140
+ | `--format <format>` | No | `table` | Output format: `table` (markdown) or `json`. |
141
+
142
+ When `oagen.config.ts` defines `operationHints` and/or `mountRules`, they are applied automatically. The table format flags operations that have no hint and are resolved purely by algorithm.
143
+
125
144
  ## Configuration (`oagen.config.ts`)
126
145
 
127
146
  Place an `oagen.config.ts` (or `.js`/`.mjs`) in your project root to register emitters, extractors, and customize pipeline behavior. The CLI loads this file at startup before any command runs.
@@ -142,11 +161,13 @@ export default config;
142
161
 
143
162
  ### Options
144
163
 
145
- | Key | Type | Description |
146
- | ---------------------- | ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
147
- | `emitters` | `Emitter[]` | Language emitters to register. Each emitter implements the `Emitter` interface and generates SDK files for one target language. |
148
- | `extractors` | `Extractor[]` | API surface extractors to register. Each extractor parses a live SDK and produces an `ApiSurface` JSON used for compat verification. |
149
- | `emitterProject` | `string` | Path to the emitter project directory. Used by skills to scaffold new emitters, tests, and smoke runners in the correct location. |
150
- | `smokeRunners` | `Record<string, string>` | Map from language key to custom smoke runner script path. Overrides the built-in `sdk-test.ts` for `oagen verify`. Can also be set per-invocation with `--smoke-runner`. |
151
- | `operationIdTransform` | `(id: string) => string` | Custom transform for operation IDs. Receives the raw `operationId` from the spec; return the desired operation name. No additional casing conversion is applied. When omitted, `operationId` values are converted to `camelCase`. |
152
- | `docUrl` | `string` | Base URL for documentation links. When set, relative markdown paths in descriptions (e.g. `[User](/reference/authkit/user)`) are expanded to full URLs (e.g. `[User](https://workos.com/docs/reference/authkit/user)`). |
164
+ | Key | Type | Description |
165
+ | ---------------------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
166
+ | `emitters` | `Emitter[]` | Language emitters to register. Each emitter implements the `Emitter` interface and generates SDK files for one target language. |
167
+ | `extractors` | `Extractor[]` | API surface extractors to register. Each extractor parses a live SDK and produces an `ApiSurface` JSON used for compat verification. |
168
+ | `emitterProject` | `string` | Path to the emitter project directory. Used by skills to scaffold new emitters, tests, and smoke runners in the correct location. |
169
+ | `smokeRunners` | `Record<string, string>` | Map from language key to custom smoke runner script path. Overrides the built-in `sdk-test.ts` for `oagen verify`. Can also be set per-invocation with `--smoke-runner`. |
170
+ | `operationIdTransform` | `(id: string) => string` | Custom transform for operation IDs. Receives the raw `operationId` from the spec; return the desired operation name. No additional casing conversion is applied. When omitted, `operationId` values are converted to `camelCase`. |
171
+ | `docUrl` | `string` | Base URL for documentation links. When set, relative markdown paths in descriptions (e.g. `[User](/reference/authkit/user)`) are expanded to full URLs (e.g. `[User](https://workos.com/docs/reference/authkit/user)`). |
172
+ | `operationHints` | `Record<string, OperationHint>` | Per-operation overrides keyed by `"METHOD /path"`. Override derived method names, remount to a different service, or split union-body operations into typed wrappers. See [Operation Resolution](architecture/ir-types.md#operation-resolution). |
173
+ | `mountRules` | `Record<string, string>` | Service-level remounting. Maps IR service name to target service/namespace (PascalCase). All operations in the source service are mounted on the target unless overridden per-operation in `operationHints`. |
@@ -71,10 +71,6 @@ export const demoEmitter: Emitter = {
71
71
  return [];
72
72
  },
73
73
 
74
- generateConfig(): GeneratedFile[] {
75
- return [];
76
- },
77
-
78
74
  generateTypeSignatures(): GeneratedFile[] {
79
75
  return [];
80
76
  },
@@ -105,7 +105,6 @@ export const demoEmitter: Emitter = {
105
105
  },
106
106
  ],
107
107
  generateErrors: () => [],
108
- generateConfig: () => [],
109
108
  generateTypeSignatures: () => [],
110
109
  generateTests: () => [],
111
110
  fileHeader: () => "# Generated by oagen",
@@ -9,7 +9,6 @@ A minimal but working TypeScript emitter for oagen, demonstrating the Emitter in
9
9
  - `generateResources` — resource classes using `planOperation`
10
10
  - `generateClient` — top-level client with resource accessors
11
11
  - `generateErrors` — error class hierarchy
12
- - `generateConfig` — config types and base resource class
13
12
  - Type mapping via `mapTypeRef`
14
13
 
15
14
  ## What it does NOT cover
@@ -4,7 +4,6 @@ import { generateEnums } from './generators/enums.js';
4
4
  import { generateResources } from './generators/resources.js';
5
5
  import { generateClient } from './generators/client.js';
6
6
  import { generateErrors } from './generators/errors.js';
7
- import { generateConfig } from './generators/config.js';
8
7
  import { generateTests } from './generators/tests.js';
9
8
 
10
9
  /**
@@ -38,10 +37,6 @@ export const typescriptEmitter: Emitter = {
38
37
  return generateErrors(ctx);
39
38
  },
40
39
 
41
- generateConfig(ctx: EmitterContext): GeneratedFile[] {
42
- return generateConfig(ctx);
43
- },
44
-
45
40
  generateTests(spec: ApiSpec, ctx: EmitterContext): GeneratedFile[] {
46
41
  return generateTests(spec, ctx);
47
42
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workos/oagen",
3
- "version": "0.3.0",
3
+ "version": "0.5.0",
4
4
  "description": "Framework for building OpenAPI SDK emitters",
5
5
  "author": "WorkOS",
6
6
  "license": "MIT",
@@ -74,7 +74,7 @@
74
74
  "prepare": "husky"
75
75
  },
76
76
  "dependencies": {
77
- "@redocly/openapi-core": "^1.34.3",
77
+ "@redocly/openapi-core": "^2.25.1",
78
78
  "commander": "^13.1.0",
79
79
  "dotenv": "^17.3.1",
80
80
  "tree-sitter": "^0.21.1",
@@ -94,12 +94,12 @@
94
94
  "@commitlint/cli": "^20.5.0",
95
95
  "@commitlint/config-conventional": "^20.5.0",
96
96
  "@types/node": "^25.3.3",
97
- "@vitest/coverage-v8": "^3.2.4",
97
+ "@vitest/coverage-v8": "^4.1.2",
98
98
  "husky": "^9.1.7",
99
99
  "oxfmt": "^0.36.0",
100
100
  "oxlint": "^1.51.0",
101
101
  "prettier": "^3.8.1",
102
102
  "tsdown": "^0.21.5",
103
- "vitest": "^3.0.0"
103
+ "vitest": "^4.1.2"
104
104
  }
105
105
  }
@@ -0,0 +1,83 @@
1
+ ---
2
+ name: review-operations
3
+ description: >-
4
+ Review resolved operation names from the OpenAPI spec. Runs the resolution
5
+ algorithm with hints applied and outputs a review table for human approval.
6
+ Use when reviewing operation names, checking for unhinted operations, auditing
7
+ method naming, or after spec changes. Also triggers for "operation names",
8
+ "method names", "hint map", "operation review", "unhinted operations".
9
+ ---
10
+
11
+ # /review-operations
12
+
13
+ Parse the OpenAPI spec, run operation resolution with the configured hint map, and produce a review table highlighting operations that need attention.
14
+
15
+ ## Accept Arguments
16
+
17
+ Accept `--spec <path>` as an optional argument. If not provided, fall back to the `OPENAPI_SPEC_PATH` environment variable, then try `../openapi-spec/spec/open-api-spec.yaml`.
18
+
19
+ ## Step 1: Resolve Paths
20
+
21
+ 1. **Spec path**: from argument, `OPENAPI_SPEC_PATH` env, or `../openapi-spec/spec/open-api-spec.yaml`
22
+ 2. **oagen-emitters project**: check if `oagen.config.ts` exists in the current directory. If not, use `AskUserQuestion`: "Where is your oagen-emitters project?"
23
+ 3. Validate the spec file exists before proceeding.
24
+
25
+ ## Step 2: Run Resolution
26
+
27
+ Run `oagen resolve` to get the full resolution output:
28
+
29
+ ```bash
30
+ npx oagen resolve --spec <path> --format json
31
+ ```
32
+
33
+ Parse the JSON output. Each entry has: `service`, `method`, `path`, `derivedName`, `hintApplied`, `mountOn`, `wrappers`.
34
+
35
+ ## Step 3: Categorize Operations
36
+
37
+ Sort operations into three categories:
38
+
39
+ 1. **Hinted** — operations with an explicit name or mount override in `operationHints` or `mountRules`
40
+ 2. **Algorithm-derived (look good)** — unhinted operations where the derived name follows standard CRUD patterns and reads naturally
41
+ 3. **Needs review** — unhinted operations where the derived name may be suboptimal:
42
+ - Plural names for single-resource POST/PUT/PATCH/DELETE (e.g., `create_organizations` instead of `create_organization`)
43
+ - Names using `list_` for non-collection GETs (e.g., `list_profile`)
44
+ - Generic names like `create_token` that don't capture the operation's purpose
45
+ - Names with deeply nested paths that lose context
46
+
47
+ ## Step 4: Output Review Table
48
+
49
+ Print a markdown table with all operations, grouped by category:
50
+
51
+ ```markdown
52
+ ## Operations needing review (N)
53
+
54
+ | Service | Method | Path | Current Name | Suggested Action |
55
+ | ------- | ------ | ---- | ------------ | ---------------- |
56
+
57
+ ## Algorithm-derived operations (N)
58
+
59
+ | Service | Method | Path | Derived Name | Mount On |
60
+ | ------- | ------ | ---- | ------------ | -------- |
61
+
62
+ ## Hinted operations (N)
63
+
64
+ | Service | Method | Path | Hint Name | Mount On |
65
+ | ------- | ------ | ---- | --------- | -------- |
66
+ ```
67
+
68
+ For "needs review" operations, suggest a concrete action:
69
+
70
+ - `add name hint: <suggested_name>` for semantic renames
71
+ - `add mountOn hint: <target>` for service remounting
72
+ - `singularize: <name>` for plural-to-singular fixes
73
+
74
+ ## Step 5: Summary
75
+
76
+ Print a summary:
77
+
78
+ - Total operations
79
+ - Hinted (with name or mount overrides)
80
+ - Algorithm-derived (no action needed)
81
+ - Needs review (may need hints)
82
+
83
+ If there are operations needing review, ask the user: "Would you like me to add hints for any of these operations to `oagen.config.ts`?"