orbit-code-ai 0.1.38 → 0.1.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orbit-code-ai",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "description": "Orbit AI – Your AI-powered IBM ACE coding companion",
5
5
  "type": "module",
6
6
  "author": "moenawaf",
@@ -0,0 +1,287 @@
1
+ ---
2
+ name: api-contract
3
+ description: Generate a CONTRACT-ONLY OpenAPI (Swagger) 2.0 or 3.0 API definition from an LLD/spec — paths, operations, fully-modeled request/response/error schemas, and a security scheme. This is the API DESIGN/interface (what consumers code against and what you import into API Connect), with NO gateway assembly (no x-ibm-configuration). Pairs with /apic-api, which adds the gateway implementation.
4
+ trigger: /api-contract
5
+ ---
6
+
7
+ # /api-contract
8
+
9
+ Generate the **contract half** of an API: a clean OpenAPI 2.0 (or 3.0) document that models the
10
+ interface — every operation, the full request/response/error schemas, and the security scheme —
11
+ with **no** DataPower/APIC assembly. This is the artifact you hand to consumers, publish as the
12
+ Swagger, or import into API Connect before attaching a gateway assembly.
13
+
14
+ > This skill produces `swagger`/`openapi` + `paths` + `definitions` (or `components.schemas`) ONLY.
15
+ > It NEVER emits `x-ibm-configuration`, `assembly`, `invoke`, `gatewayscript`, or any policy. If the
16
+ > user needs the deployable gateway implementation, that is the separate **/apic-api** skill.
17
+
18
+ ## Usage
19
+
20
+ ```
21
+ /api-contract <ApiName> [host] [description + operations + request/response/error models]
22
+
23
+ Flags:
24
+ --openapi 2.0|3.0 target spec version — USER'S CHOICE. Ask if unspecified; do not assume.
25
+ --security S consumer auth scheme: basic | apikey | clientid-secret | oauth2 | none.
26
+ Ask if unspecified. (apikey/clientid-secret = API-key headers; oauth2 needs
27
+ a provider/scopes, so ask for them.)
28
+ --host H API host (e.g. api.example.com). Ask/placeholder if not given.
29
+ --basePath P base path (default "/").
30
+
31
+ Input model: paste the LLD's operation list and the request/response/error field models (tables or
32
+ JSON samples). The skill's job is to transcribe those faithfully into OpenAPI schemas.
33
+ ```
34
+
35
+ ## Variables to Derive
36
+
37
+ - `{ApiTitle}` = human title, e.g. `Commercial Credit Report API`.
38
+ - `{x-ibm-name}` = kebab-case of the API name, e.g. `commercial-credit-report-api` (also the file stem).
39
+ - `{version}` = `1.0.0` unless supplied.
40
+ - `{host}` = `--host` or a clearly-marked placeholder (`CHANGEME.example.com`).
41
+ - `{basePath}` = `--basePath` or `/`.
42
+
43
+ Output filename: `{x-ibm-name}_{version}.yaml`
44
+
45
+ ---
46
+
47
+ ## Clarify before generating (do this FIRST)
48
+
49
+ Ask for anything the prompt didn't supply, in ONE batched follow-up:
50
+ - **OpenAPI version** — 2.0 or 3.0 (always ask if unspecified).
51
+ - **Security scheme** — basic / API-key / OAuth2 / none. For **OAuth2**, ask for the provider name and
52
+ scopes; if none is available, emit a clearly-marked placeholder scheme and list it in the summary.
53
+ - **Host / basePath** — if not given, use `CHANGEME.example.com` / `/` and flag it.
54
+ - **The data models** — if the request/response/error field structures weren't provided, ask for them
55
+ (a table or a JSON sample per operation). Do NOT invent business fields you were not given.
56
+
57
+ Never fabricate real-looking hosts, scopes, or business fields. Placeholders must look like
58
+ placeholders and be listed in the summary.
59
+
60
+ ---
61
+
62
+ ## Generation rules
63
+
64
+ 1. **Contract-only. NEVER emit `x-ibm-configuration` or any assembly/policy.** The output is
65
+ `swagger`/`openapi`, `info`, `host`/`servers`, `basePath`, `schemes`, `paths`, `securityDefinitions`
66
+ /`components.securitySchemes`, and `definitions`/`components.schemas`. Nothing else.
67
+ 2. **The spec version is the user's choice.** Emit 2.0 from the skeleton, or apply the 3.0 transform.
68
+ 3. **One file, ALL operations.** Put every operation under `paths`. Each operation gets: `summary`,
69
+ `operationId` (camelCase of the operation), `tags`, `security`, request `parameters`/`requestBody`,
70
+ and a `responses` map.
71
+ 4. **Model every response code the LLD lists** — success (200/201) AND the error codes (400/401/422/500,
72
+ etc.), each with a schema `$ref`. If the LLD gives an error-response shape, model it once
73
+ (e.g. `ErrorResponse`) and reuse it; distinct error bodies (e.g. a different 500 shape) get their own.
74
+ 5. **Transcribe schemas FAITHFULLY (this is the whole job).** Reproduce the LLD's data model exactly:
75
+ nesting, arrays, required fields, enums, lengths, formats, nullability, and field descriptions. See
76
+ the "Schema modeling reference" below. Do not flatten nested structures or drop fields.
77
+ 6. **Reuse via `$ref`.** Give every reusable object type a named definition and `$ref` it. Don't inline
78
+ the same structure twice. Deeply-nested one-off objects may be inlined, but shared types must be named.
79
+ 7. **Preserve constraints from the LLD**: `required`, `enum`, `maxLength`/`minLength`, `minItems`,
80
+ `minimum`/`maximum`, `format` (`byte` for base64, `date`/`date-time`, `int32`/`int64`), and
81
+ `x-nullable: true` (2.0) / `nullable: true` (3.0) for fields the LLD marks nullable. Carry the LLD's
82
+ field descriptions into `description:` — including conditional rules ("mandatory if X is present").
83
+ 8. **Security scheme** per `--security` (see "Security schemes"). Reference it from each operation's
84
+ `security` (and/or a top-level `security`).
85
+ 9. **No invented business data.** Every field/enum/value comes from the LLD. `example:` values may be
86
+ added only when the LLD provides samples; otherwise omit examples or use obvious placeholders.
87
+
88
+ ---
89
+
90
+ ## OpenAPI 2.0 skeleton (contract-only)
91
+
92
+ Fill `{slots}`. Example shows one POST operation with success + error responses and a few schema
93
+ patterns; repeat the `paths` entry per operation and grow `definitions` to cover the full model.
94
+
95
+ ```yaml
96
+ swagger: "2.0"
97
+ info:
98
+ title: {ApiTitle}
99
+ version: {version}
100
+ x-ibm-name: {x-ibm-name}
101
+ description: |
102
+ {one-or-more lines describing the API, from the LLD purpose/scope}
103
+ host: {host}
104
+ basePath: {basePath}
105
+ schemes:
106
+ - https
107
+ paths:
108
+ {basePath-relative-path}: # e.g. /v1.0/GetReport (one block per operation)
109
+ post: # or get/put/delete
110
+ summary: {short summary}
111
+ operationId: {operationId}
112
+ tags:
113
+ - {Tag}
114
+ security:
115
+ - {securitySchemeName}: []
116
+ parameters:
117
+ - in: body
118
+ name: body
119
+ required: true
120
+ schema:
121
+ $ref: '#/definitions/{RequestType}'
122
+ responses:
123
+ '200':
124
+ description: Successful operation
125
+ schema:
126
+ $ref: '#/definitions/{ResponseType}'
127
+ '400':
128
+ description: Bad Request
129
+ schema:
130
+ $ref: '#/definitions/ErrorResponse'
131
+ '401':
132
+ description: Authentication failed or token expired
133
+ schema:
134
+ $ref: '#/definitions/ErrorResponse'
135
+ '422':
136
+ description: Validation Error
137
+ schema:
138
+ $ref: '#/definitions/ErrorResponse'
139
+ '500':
140
+ description: Backend / Generic Error
141
+ schema:
142
+ $ref: '#/definitions/ErrorResponse500'
143
+ securityDefinitions:
144
+ # one of the blocks from "Security schemes" below
145
+ basicAuth:
146
+ type: basic
147
+ description: Basic authentication for API Gateway consumers.
148
+ definitions:
149
+ {RequestType}:
150
+ type: object
151
+ required:
152
+ - {mandatoryField}
153
+ properties:
154
+ {field}:
155
+ type: string
156
+ {arrayField}:
157
+ type: array
158
+ minItems: 1
159
+ items:
160
+ $ref: '#/definitions/{ItemType}'
161
+ {ResponseType}:
162
+ type: object
163
+ properties:
164
+ status:
165
+ $ref: '#/definitions/Status200'
166
+ payload:
167
+ $ref: '#/definitions/{PayloadType}'
168
+ # Reusable status / error models (name them once, reuse):
169
+ Status200:
170
+ type: object
171
+ properties:
172
+ statusCode: { type: string, example: "200" }
173
+ description: { type: string, example: "Success" }
174
+ ErrorResponse:
175
+ type: object
176
+ properties:
177
+ status:
178
+ type: object
179
+ properties:
180
+ statusCode: { type: string, example: "E10001" }
181
+ description: { type: string, example: "Validation failed" }
182
+ ErrorResponse500:
183
+ type: object
184
+ properties:
185
+ status:
186
+ type: object
187
+ properties:
188
+ statusCode: { type: string, example: "E10999" }
189
+ description: { type: string, example: "Generic Error" }
190
+ # ... every other type the LLD models (nested objects, arrays, enums, byte, etc.) ...
191
+ ```
192
+
193
+ ---
194
+
195
+ ## Schema modeling reference (LLD → OpenAPI)
196
+
197
+ Translate each LLD attribute exactly:
198
+
199
+ | LLD says | OpenAPI (2.0) |
200
+ |---|---|
201
+ | text / string | `type: string` |
202
+ | number / decimal | `type: number` |
203
+ | integer | `type: integer` (add `format: int32`/`int64` if the LLD distinguishes) |
204
+ | boolean / flag | `type: boolean` |
205
+ | base64 / binary (e.g. PDF) | `type: string`, `format: byte` |
206
+ | date / datetime | `type: string`, `format: date` / `date-time` |
207
+ | max length N | `maxLength: N` (also `minLength` if given) |
208
+ | allowed values {A,B} | `enum: [A, B]` |
209
+ | list / repeating / (1..*) | `type: array`, `items: {...}`, add `minItems: 1` when ≥1 required |
210
+ | object / nested group | `type: object` with `properties:` (or `$ref` a named type) |
211
+ | mandatory (M) | add the field to the parent's `required:` list |
212
+ | optional (O) | leave out of `required` |
213
+ | conditional (C) | leave out of `required`; put the rule in `description:` ("mandatory if X present") |
214
+ | nullable / may be null | `x-nullable: true` (2.0) / `nullable: true` (3.0) |
215
+ | shared/reused structure | a named `definitions` entry, `$ref`'d everywhere it appears |
216
+
217
+ Rules of thumb:
218
+ - **Model the FULL depth.** If the LLD nests 6 levels deep, so does the schema. Don't collapse.
219
+ - **Name shared types** (`Status200`, `ErrorResponse`, `AddressType`, …); inline only true one-offs.
220
+ - **Descriptions carry the LLD's semantics** — especially conditional/mutually-exclusive field notes.
221
+
222
+ ---
223
+
224
+ ## Security schemes
225
+
226
+ Pick per `--security` (all go under `securityDefinitions` in 2.0):
227
+
228
+ ```yaml
229
+ # basic
230
+ basicAuth: { type: basic, description: Basic authentication for API Gateway consumers. }
231
+
232
+ # API key (single header)
233
+ apiKey: { type: apiKey, in: header, name: X-API-Key }
234
+
235
+ # client-id / client-secret (APIC-style pair)
236
+ clientID: { type: apiKey, in: header, name: X-IBM-Client-Id }
237
+ clientSecret: { type: apiKey, in: header, name: X-IBM-Client-Secret }
238
+
239
+ # oauth2 (ASK for provider + scopes; use placeholders if unknown and list them in the summary)
240
+ oauth2:
241
+ type: oauth2
242
+ flow: application # or accessCode/implicit/password per the provider
243
+ tokenUrl: https://{CHANGEME-oauth-host}/oauth2/token
244
+ scopes:
245
+ {scope}: {description}
246
+ ```
247
+
248
+ Reference the scheme from each operation's `security:` (and optionally a top-level `security:`). For
249
+ `--security none`, omit `securityDefinitions`/`security` entirely.
250
+
251
+ ---
252
+
253
+ ## OpenAPI 3.0 transform (`--openapi 3.0`)
254
+
255
+ Same contract, only these structural changes:
256
+
257
+ | 2.0 | 3.0 |
258
+ |---|---|
259
+ | `swagger: "2.0"` | `openapi: 3.0.0` |
260
+ | `host` + `basePath` + `schemes` | `servers: [ { url: https://{host}{basePath} } ]` |
261
+ | `definitions:` | `components.schemas:` |
262
+ | `securityDefinitions:` | `components.securitySchemes:` (`basic`→`{type: http, scheme: basic}`) |
263
+ | body param (`in: body`, `schema`) | `requestBody.content.application/json.schema` |
264
+ | response `schema:` | `responses.<code>.content.application/json.schema` |
265
+ | `$ref: '#/definitions/X'` | `$ref: '#/components/schemas/X'` |
266
+ | `x-nullable: true` | `nullable: true` |
267
+
268
+ ---
269
+
270
+ ## After generating
271
+
272
+ **Use the Write tool to create `{x-ibm-name}_{version}.yaml` in the current working directory.** Write
273
+ the full document, then print this summary:
274
+
275
+ ```
276
+ ✓ {ApiTitle} — OpenAPI {2.0|3.0} contract generated → {x-ibm-name}_{version}.yaml [api-contract rev-1]
277
+
278
+ operations {N} ({verb path}, …)
279
+ security {basic|apikey|clientid-secret|oauth2|none}
280
+ responses {per op: 200 + error codes modeled}
281
+ schemas {count} definitions
282
+ host/basePath {host}{basePath}
283
+ placeholders {list any CHANGEME values, or "none"}
284
+
285
+ Contract only — no gateway assembly. Add the DataPower implementation with /apic-api (or import this
286
+ into API Connect and build the assembly there).
287
+ ```