@sumrco/cli 0.2.1 → 0.3.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 (37) hide show
  1. package/ai/modules/kontract/resources/api-generation-standards.rf.md +83 -0
  2. package/ai/modules/kontract/resources/authoring/configuration.rf.md +220 -0
  3. package/ai/modules/kontract/resources/authoring/design-profile/api-styles.rf.md +241 -0
  4. package/ai/modules/kontract/resources/authoring/design-profile/async-styles.rf.md +134 -0
  5. package/ai/modules/kontract/resources/authoring/design-profile/overview.md +64 -0
  6. package/ai/modules/kontract/resources/authoring/design-profile/schema-layout-styles.rf.md +356 -0
  7. package/ai/modules/kontract/resources/authoring/overview.md +56 -0
  8. package/ai/modules/kontract/resources/authoring/schema-reuse.rf.md +492 -0
  9. package/ai/modules/kontract/resources/authoring/scope-and-splitting.rf.md +244 -0
  10. package/ai/modules/kontract/resources/authoring/spec-layout.rf.md +492 -0
  11. package/ai/modules/kontract/resources/authoring/team-members/spec-author.tm.md +77 -0
  12. package/ai/modules/kontract/resources/{workflows/contract-change.wf.md → authoring/workflows/spec-change.wf.md} +24 -16
  13. package/ai/modules/kontract/resources/generated-output.rf.md +185 -17
  14. package/ai/modules/kontract/resources/openapi-sdk-generator-research.rf.md +57 -0
  15. package/ai/modules/kontract/resources/overview.md +130 -44
  16. package/ai/modules/kontract/resources/performance.rf.md +7 -7
  17. package/ai/modules/kontract/sumr.module.yaml +5 -2
  18. package/ai/modules/mission/sumr.module.yaml +6 -0
  19. package/ai/modules/playbook/resources/authoring/content-structure.rf.md +1 -1
  20. package/ai/modules/playbook/resources/authoring/cross-referencing.rf.md +1 -1
  21. package/ai/modules/playbook/resources/authoring/descriptions.rf.md +1 -1
  22. package/ai/modules/playbook/resources/authoring/extraction.rf.md +1 -1
  23. package/ai/modules/playbook/resources/authoring/flows.rf.md +1 -1
  24. package/ai/modules/playbook/resources/authoring/folder-structure.rf.md +1 -1
  25. package/ai/modules/playbook/resources/authoring/frontmatter.rf.md +4 -1
  26. package/ai/modules/playbook/resources/authoring/markdown.rf.md +1 -1
  27. package/ai/modules/playbook/resources/authoring/overview.md +1 -1
  28. package/ai/modules/playbook/resources/team-members/{playbook-technical-writer.tm.md → technical-writer.tm.md} +3 -2
  29. package/ai/modules/playbook/sumr.module.yaml +7 -2
  30. package/index.js +486 -284
  31. package/package.json +1 -1
  32. package/ai/modules/kontract/resources/configuration.rf.md +0 -123
  33. package/ai/modules/kontract/resources/openapi-generator-lessons.rf.md +0 -61
  34. package/ai/modules/kontract/resources/schema-reuse.rf.md +0 -233
  35. package/ai/modules/kontract/resources/scope-and-splitting.rf.md +0 -147
  36. package/ai/modules/kontract/resources/spec-layout.rf.md +0 -69
  37. package/ai/modules/kontract/resources/team-members/contract-author.tm.md +0 -52
@@ -0,0 +1,64 @@
1
+ ---
2
+ name: design-profile
3
+ title: Contract Design Profile
4
+ description: "How Kontract profile values guide HTTP, async schema, and schema directory examples without changing generation."
5
+ tags: [kontract, design-profile, http, asyncapi, schema-layout]
6
+ ---
7
+
8
+ # Contract Design Profile
9
+
10
+ `sumr kontract init` writes a guidance-only profile to `sumr.yaml`.
11
+ `sumr kontract config` shows or updates it later without hand-editing YAML:
12
+
13
+ ```yaml
14
+ kontract:
15
+ guidance:
16
+ profile:
17
+ apiStyle: pragmatic-rest
18
+ asyncStyle: command-event
19
+ schemaLayoutStyle: by-product-capability
20
+ ```
21
+
22
+ The profile guides docs and AI examples. It does not change generator output,
23
+ API schema validation, async schema validation, or application architecture.
24
+
25
+ ```bash
26
+ sumr kontract config
27
+ sumr kontract config --api-style rpc-action --async-style cloud-events
28
+ ```
29
+
30
+ ## Profile axes
31
+
32
+ | Config key | Reader-facing meaning | Axis reference |
33
+ |---|---|---|
34
+ | `apiStyle` | API path and component example style. | `api-styles.rf.md` |
35
+ | `asyncStyle` | async schema channel/address and message example style. | `async-styles.rf.md` |
36
+ | `schemaLayoutStyle` | Schema layout style for schema file and folder examples. | `schema-layout-styles.rf.md` |
37
+
38
+ Read the axis-specific references before writing examples. Do not infer file
39
+ moves from the profile alone: the profile is guidance-only.
40
+
41
+ ## CLI and YAML names
42
+
43
+ Use `schemaLayoutStyle` in `sumr.yaml` and `--schema-layout-style` in the CLI.
44
+ Do not use organization wording for this axis.
45
+
46
+ ## Safe interpretation
47
+
48
+ - HTTP examples must follow `apiStyle`.
49
+ - async schema examples must follow `asyncStyle`, but only when the repo has
50
+ async schema sources/targets or the user asks for messaging contracts.
51
+ - Schema file/folder examples must follow `schemaLayoutStyle`, described as the
52
+ schema layout style.
53
+ - If the repo is API-only, keep examples API-only; do not add
54
+ `*.async.yml`, channels, messages, or `messages/` folders only because the
55
+ profile has an `asyncStyle` default.
56
+ - If the repo is async-only, keep examples async-only; do not add
57
+ `*.api.yml`, paths, parameters, or HTTP responses only because the profile
58
+ has an `apiStyle` default.
59
+ - If the repo has both protocols, keep API schema and async schema roots and
60
+ protocol-specific folders separate. Share only components with
61
+ identical meaning, especially enums and scalar value objects.
62
+ - If an agent recommends moving root specs, it must call out that generated
63
+ output namespaces/import paths can change because Kontract mirrors root spec
64
+ paths under the configured source input directory.
@@ -0,0 +1,356 @@
1
+ ---
2
+ category: reference
3
+ name: schema-layout-styles
4
+ title: Schema Layout Style Examples
5
+ description: "Schema layout styles for Kontract profile examples, including canonical folder trees and generated-output migration warnings."
6
+ label: Schema Layout Styles
7
+ when: Choosing or explaining `kontract.guidance.profile.schemaLayoutStyle`, schema folder layout, root spec locations, or generated namespace impact
8
+ order: 18
9
+ ---
10
+
11
+ # Schema Layout Style Examples
12
+
13
+ Use `kontract.guidance.profile.schemaLayoutStyle` to choose the schema layout
14
+ examples an agent should produce. Use the same wording in user-facing guidance.
15
+
16
+ This is guidance only; it does not move files or change generation by itself.
17
+
18
+ ## Style summary
19
+
20
+ | Style | Choose this when | Sample layout |
21
+ |---|---|---|
22
+ | `by-product-capability` | A product capability owns one or more focused contract surfaces; it may be API-only. | `schema/recipes/recipes.api.yml`, `schema/recipes/catalog.api.yml` |
23
+ | `by-api-surface` | Public, partner, admin, or internal surfaces are released separately. | `schema/public.api.yml`, `schema/admin.api.yml` |
24
+ | `by-service-owner` | Teams generate contracts by deployable service ownership. | `schema/catalog-service/catalog.api.yml` |
25
+ | `by-resource-area` | Specs are easiest to review by stable resource area. | `schema/recipes/recipes.api.yml`, `schema/ingredients/ingredients.api.yml` |
26
+ | `by-workflow` | A workflow spans several resources and needs one contract owner. | `schema/checkout/checkout.api.yml` |
27
+ | `by-message-family` | Messaging files are owned by command, event, or query family. | `schema/events/recipe-events.async.yml` |
28
+ | `mixed` | A repo has intentional legacy or multi-team layout differences. | Document the style per folder before adding examples. |
29
+
30
+ ## Canonical folder trees
31
+
32
+ Use these trees as the source of truth when an agent proposes schema files,
33
+ folder moves, or examples. Do not combine two schema layout styles unless
34
+ `schemaLayoutStyle: mixed`.
35
+
36
+ ## Protocol-aware rule
37
+
38
+ First inspect the configured source directory and targets. If the repo currently
39
+ contains only API schema roots, show API-only folder trees and examples. Do not
40
+ add async schema roots, channels, message folders, or NATS naming samples unless the
41
+ user asks for messaging contracts or the repo already has async schema files.
42
+
43
+ Use one of these three protocol scenarios before choosing a layout tree:
44
+
45
+ 1. **API-only** — HTTP roots, path fragments, parameters, responses, and
46
+ `components.schemas` only.
47
+ 2. **async-only** — messaging roots, channels, operations, messages, and
48
+ message payload schemas only.
49
+ 3. **API + async** — keep API schema and async schema roots and protocol
50
+ layers separate. Share only components with identical meaning across
51
+ both protocols, especially enums, scalar value objects, IDs, slugs, and other
52
+ reusable payload shapes.
53
+
54
+ Do not share API schema paths, parameters, responses, async schema channels,
55
+ operations, or messages across protocols. Those are protocol-specific layers.
56
+
57
+ ### `by-product-capability`
58
+
59
+ The first folder is a product capability. Start with focused API schema roots when
60
+ the capability only exposes HTTP contracts. Add messaging roots only when the
61
+ capability actually owns async schema contracts.
62
+
63
+ API-only example:
64
+
65
+ ```text
66
+ schema/
67
+ recipes/
68
+ recipes.api.yml # API schema root; generates under recipes/http
69
+ shared/ # only if promoted reusable recipe components exist
70
+ enums.yml
71
+ kitchen/
72
+ stations.api.yml # API schema root; generates under kitchen/http
73
+ ```
74
+
75
+ API-only with multiple sub-areas in one generated capability package:
76
+
77
+ ```text
78
+ schema/
79
+ recipes/
80
+ main.api.yml # api: 3.0.3; groups under recipes/http
81
+ catalog.api.yml # api: 3.0.3; groups under recipes/http
82
+ ingredients.api.yml # api: 3.0.3; groups under recipes/http
83
+ shared/ # capability-local promoted components only
84
+ enums.yml
85
+ components.yml
86
+ ```
87
+
88
+ Use this grouped API schema pattern when the capability folder owns the generated
89
+ package and the filenames describe focused surfaces. Keep one-off schemas in the
90
+ surface file's `components.schemas`; move only repeated capability concepts into
91
+ the capability's `shared/` folder. Promote again to `schema/shared/` only when
92
+ another capability shares the same semantics.
93
+
94
+ async-only example:
95
+
96
+ ```text
97
+ schema/
98
+ recipes/
99
+ recipes.async.yml # async schema root; generates under recipes/nats
100
+ messages/
101
+ recipe-commands.yml # channels, operations, messages
102
+ recipe-events.yml
103
+ models/
104
+ recipe.yml # message payload schemas
105
+ enums.yml # message enums
106
+ ```
107
+
108
+ API schema plus async schema example only when both protocols exist:
109
+
110
+ ```text
111
+ schema/
112
+ recipes/
113
+ recipes.api.yml # HTTP root
114
+ recipes.async.yml # messaging root
115
+ paths/
116
+ recipes.yml # API schema path fragments
117
+ messages/
118
+ recipes.yml # async schema channels/messages
119
+ models/
120
+ recipe.yml # protocol-payload shapes
121
+ enums.yml # shared enums when meanings match
122
+ ```
123
+
124
+ Combined preview when teaching all product-capability scenarios together:
125
+
126
+ ```text
127
+ schema/
128
+ recipes/
129
+ # API-only
130
+ recipes.api.yml
131
+
132
+ recipes-messaging/
133
+ # async-only capability
134
+ recipes.async.yml
135
+ messages/
136
+ recipe-events.yml
137
+
138
+ bookstore/
139
+ # Both protocols, separate layers
140
+ bookstore.api.yml
141
+ bookstore.async.yml
142
+ paths/
143
+ books.yml
144
+ messages/
145
+ books.yml
146
+ models/
147
+ enums.yml
148
+ ```
149
+
150
+ Do **not** describe this as `by-resource-area` only because fragments or routes
151
+ inside `recipes/` are named `recipes.yml`, `ingredients.yml`, or `orders.yml`.
152
+ Those are resource-area fragments inside a product-capability root.
153
+
154
+ Do **not** add `paths/` fragments to a simple API-only capability unless the
155
+ root file is too large, mixes independently owned surfaces, or needs reusable
156
+ path-item fragments.
157
+
158
+ ### `by-api-surface`
159
+
160
+ The root entrypoints are released API surfaces. Use this when public, partner,
161
+ admin, and internal contracts need independent review and generation boundaries.
162
+
163
+ ```text
164
+ schema/
165
+ public.api.yml # public HTTP surface
166
+ partner.api.yml # partner HTTP surface
167
+ admin.api.yml # admin HTTP surface
168
+ internal.api.yml # internal HTTP surface, when HTTP
169
+ internal-events.async.yml # internal messaging surface, when messaging
170
+ shared/
171
+ enums.yml # shared only when semantics match
172
+ ```
173
+
174
+ If the internal surface is messaging, use a separate async schema root such as
175
+ `internal-events.async.yml`; do not imply it exists for API-only repos.
176
+ When both protocols exist, share components through `schema/shared/` or
177
+ surface-local `models/enums.yml`; keep `public.api.yml` and
178
+ `internal-events.async.yml` independent entrypoints.
179
+
180
+ ### `by-service-owner`
181
+
182
+ The first folder is the deployable service or owning team boundary.
183
+
184
+ ```text
185
+ schema/
186
+ catalog-service/
187
+ catalog.api.yml # API-only service surface
188
+ fulfillment-service/
189
+ fulfillment.api.yml
190
+ notification-service/
191
+ notifications.async.yml # async-only service surface
192
+ order-service/
193
+ orders.api.yml # both protocols for one service owner
194
+ orders.async.yml
195
+ models/
196
+ enums.yml
197
+ ```
198
+
199
+ Add service-owned async schema roots only when the service owns messaging contracts:
200
+
201
+ ```text
202
+ schema/
203
+ catalog-service/
204
+ catalog.async.yml
205
+ fulfillment-service/
206
+ fulfillment.async.yml
207
+ ```
208
+
209
+ When a service owns both protocols, put both roots under the same service owner
210
+ folder and share only `models/enums.yml` or scalar/value-object
211
+ fragments.
212
+
213
+ ### `by-resource-area`
214
+
215
+ Top-level roots are stable resource areas. There is no product-capability parent
216
+ folder above them. Each resource area can become an independent generated
217
+ namespace.
218
+
219
+ ```text
220
+ schema/
221
+ books/
222
+ books.api.yml
223
+ authors/
224
+ authors.api.yml
225
+ book-events/
226
+ books.async.yml
227
+ ```
228
+
229
+ A true `by-resource-area` recommendation should not say "keep resource-area
230
+ files inside product-capability roots." That is a `by-product-capability` layout
231
+ with resource-area fragments.
232
+
233
+ ### `by-workflow`
234
+
235
+ The first folder is an end-to-end workflow that spans multiple resources.
236
+
237
+ ```text
238
+ schema/
239
+ checkout/
240
+ checkout.api.yml # API-only workflow
241
+ fulfillment/
242
+ fulfillment.async.yml # async-only workflow
243
+ returns/
244
+ returns.api.yml # both protocols, shared enums only
245
+ returns.async.yml
246
+ models/
247
+ enums.yml
248
+ ```
249
+
250
+ If a workflow includes both HTTP and messaging contracts, keep both roots under
251
+ the workflow folder and name each root by the contract surface.
252
+ If the workflow is API-only, do not add an async schema file. If it is
253
+ async-only, do not add HTTP path folders.
254
+
255
+ ### `by-message-family`
256
+
257
+ async schema roots are grouped by message family. Use this only when messaging
258
+ families are the real ownership/review boundary. This style is normally
259
+ async-only; if the repo also has API schema, keep HTTP specs in a separate
260
+ layout island or use `mixed`.
261
+
262
+ ```text
263
+ schema/
264
+ commands/
265
+ recipe-commands.async.yml
266
+ order-commands.async.yml
267
+ events/
268
+ recipe-events.async.yml
269
+ order-events.async.yml
270
+ queries/
271
+ recipe-queries.async.yml
272
+ shared/
273
+ message-enums.yml
274
+ ```
275
+
276
+ ### `mixed`
277
+
278
+ Use `mixed` only when a repo intentionally has more than one directory structure
279
+ style. Document the style at each top-level folder before adding examples.
280
+
281
+ ```text
282
+ schema/
283
+ public.api.yml # by-api-surface, API-only
284
+ recipes/ # by-product-capability, both protocols
285
+ recipes.api.yml
286
+ recipes.async.yml
287
+ models/
288
+ enums.yml # shared enums
289
+ events/ # by-message-family, async-only
290
+ recipe-events.async.yml
291
+ README.md # explains why styles differ
292
+ ```
293
+
294
+ ## Do / don't examples
295
+
296
+ ### When `schemaLayoutStyle: by-product-capability`
297
+
298
+ Do:
299
+
300
+ ```text
301
+ schema/
302
+ recipes/
303
+ recipes.api.yml
304
+ shared/
305
+ enums.yml # only if promoted reusable recipe components exist
306
+ ```
307
+
308
+ Or, when one product capability intentionally groups several API schema sub-areas
309
+ into one generated package:
310
+
311
+ ```text
312
+ schema/
313
+ recipes/
314
+ main.api.yml
315
+ catalog.api.yml
316
+ ingredients.api.yml
317
+ shared/
318
+ enums.yml # only if more than one surface uses it
319
+ components.yml
320
+ ```
321
+
322
+ Do not call this repo-wide `by-resource-area` only because the files or optional
323
+ fragments inside `recipes/` are named by resources.
324
+
325
+ Do not move every schema into `shared/` just to keep root files short. Split by
326
+ surface first, then promote only repeated concepts with the same product
327
+ meaning.
328
+
329
+ When both protocols exist in the same capability, keep `recipes.api.yml`,
330
+ `recipes.async.yml`, `paths/`, and `messages/` separate. Share only
331
+ `models/enums.yml` or other schemas when the meaning is identical.
332
+
333
+ ### When `schemaLayoutStyle: by-resource-area`
334
+
335
+ Do:
336
+
337
+ ```text
338
+ schema/
339
+ recipes/
340
+ recipes.api.yml
341
+ ingredients/
342
+ ingredients.api.yml
343
+ ```
344
+
345
+ Don't nest resource areas under a product-capability parent unless
346
+ `schemaLayoutStyle: mixed` and the folder documents that exception.
347
+
348
+ ## Generated output warning
349
+
350
+ Schema paths affect generated output namespaces and import paths. Moving schema
351
+ roots is a generated contract layout migration, not docs cleanup.
352
+
353
+ Before recommending a folder move, state whether the user wants:
354
+
355
+ 1. a guidance-only profile change, or
356
+ 2. an actual schema and generated-output namespace migration.
@@ -0,0 +1,56 @@
1
+ ---
2
+ name: authoring
3
+ title: Spec Authoring
4
+ description: "How Kontract spec authors should configure guidance, organize specs, reuse schemas, and change API or async schema files safely."
5
+ tags: [kontract, authoring, api, async, schema-layout, contracts]
6
+ ---
7
+
8
+ # Spec Authoring
9
+
10
+ Use this folder when an agent is asked to create, move, review, or refactor
11
+ Kontract source specs. Authoring guidance is about the source of truth under the
12
+ configured `kontract.sources[].input` directory, not generated TypeScript output.
13
+ Source roots use `*.api.yml` / `*.api.yaml` for API schemas and
14
+ `*.async.yml` / `*.async.yaml` for async schemas.
15
+
16
+ Start here before proposing schema files or folder moves:
17
+
18
+ 1. Read the repo's `sumr.yaml` and identify `kontract.sources[]`, targets, and
19
+ `kontract.guidance.profile`.
20
+ 2. Inspect the actual source specs under each configured input directory. If the
21
+ repo only has API schema roots, produce API-only examples; do not introduce
22
+ async schema files, channels, messages, or `messages/` folders unless the user
23
+ asks for messaging contracts.
24
+ 3. Use the contract design profile to align API paths, async schema channels, and
25
+ schema folder examples with the selected styles.
26
+ 4. Use the spec layout rules before creating or moving API/async roots.
27
+ 5. Use schema reuse guidance before adding new payloads, envelopes, errors,
28
+ pagination, scalar constraints, schedules, or config objects.
29
+ 6. Use scope and splitting guidance before expanding a large spec or proposing a
30
+ folder migration.
31
+ 7. Run the spec-change workflow when a spec change must be validated,
32
+ generated, and reviewed.
33
+
34
+ ## Non-negotiables
35
+
36
+ - The selected profile is guidance-only; it does not move files or change
37
+ generation by itself.
38
+ - Moving root spec files changes generated output namespaces/import paths because
39
+ output mirrors paths under the configured source input directory.
40
+ - Do not mix schema layout styles unless `schemaLayoutStyle: mixed` and
41
+ each top-level folder documents the exception.
42
+ - Do not call resource-area fragments inside a product-capability folder a
43
+ repo-wide `by-resource-area` layout.
44
+ - Do not split a simple API schema root into `paths/` fragments by default. Use a
45
+ single focused root with local `components.schemas` first; split into fragments
46
+ only when size, ownership, or reuse pressure justifies it.
47
+ - Keep schemas local to the owning API surface first. Promote to a
48
+ capability-local `shared/` folder only when multiple surfaces in that
49
+ capability reuse the same product concept; promote to `schema/shared/` only
50
+ when multiple capabilities share the same meaning.
51
+ - Separate the three protocol scenarios: API-only, async-only, and
52
+ API + async. When both protocols exist, keep protocol-specific layers
53
+ separate and share only components with identical meaning, especially
54
+ enums and scalar value objects.
55
+ - Generated files are outputs. Change specs first, validate, generate, then
56
+ review the generated diff.