@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,244 @@
1
+ ---
2
+ category: reference
3
+ name: scope-and-splitting
4
+ title: Scope, Size, and Splitting
5
+ description: "How to keep Kontract specs and generator code small, product-aligned, and reviewable with explicit line-count budgets and split triggers."
6
+ label: Scope and Splitting
7
+ when: Reviewing large specs or code files, deciding whether to split a product capability/API surface spec, or optimizing oversized Kontract modules
8
+ order: 18
9
+ ---
10
+
11
+ # Scope, Size, and Splitting
12
+
13
+ Kontract is the next iteration of the AutoSync/async schema idea: keep the
14
+ documentation-first and DRY discipline, but make the boundaries more explicit.
15
+ Large files are not automatically bad, but they hide duplicated concepts,
16
+ mixed product areas, and unstable generated output. Treat size limits as review
17
+ triggers first and hard caps second.
18
+
19
+ ## Source-of-truth rule
20
+
21
+ Put durable guidance in Playbook resources and module docs; generated editor
22
+ rules should point back to those resources. Do not copy long rules into Cursor,
23
+ Claude, Codex, or generated contracts. The source contract spec and the source
24
+ Playbook resource are the maintained truth.
25
+
26
+ ## Public example hygiene
27
+
28
+ Files under `resources/` become public AI guidance. Never use internal SUMR,
29
+ customer, product, infrastructure, event-subject, route, table, or data-model
30
+ examples there. Public examples must be sanitized and generic.
31
+
32
+ Use example areas such as:
33
+
34
+ - kitchen recipes and ingredients;
35
+ - bookstore inventory;
36
+ - parcel shipping;
37
+ - job hierarchies and departments;
38
+ - todos or calendar events.
39
+
40
+ Prefer `example.*`, `recipes`, `orders`, `ingredients`, `jobs`, or similarly
41
+ generic names. Do not use real service names, internal nouns, customer nouns,
42
+ NATS subject prefixes, API paths, or entity relationships as examples. Internal
43
+ examples are acceptable in private `docs/` only when they are necessary to
44
+ explain the module's current behavior.
45
+
46
+ ## File size budgets
47
+
48
+ | File kind | Healthy target | Review trigger | Split/optimize trigger | Hard stop |
49
+ |---|---:|---:|---:|---:|
50
+ | Kontract TypeScript source | <= 200 lines | > 250 lines | > 400 lines | > 500 lines |
51
+ | API/async service spec | 150-350 lines | > 400 lines | > 700 lines | > 1000 lines |
52
+ | Shared component YAML | 100-300 lines | > 400 lines | > 600 lines | > 900 lines |
53
+ | Generated TypeScript output | no manual target | review if surprising | fix generator/spec, never hand-split | no hand edits |
54
+
55
+ Exceptions require a documented reason in the PR or handoff. Generated files,
56
+ large fixtures, and intentionally dense compatibility snapshots are exempt from
57
+ manual splitting, but they can still reveal generator or spec-design problems.
58
+
59
+ ## Split triggers
60
+
61
+ Split or optimize before adding more content when a file shows any of these:
62
+
63
+ - multiple product capabilities or API surfaces in one spec;
64
+ - more than roughly 7-10 operations with different lifecycle owners;
65
+ - request/response schemas for unrelated use cases in one component block;
66
+ - repeated envelope, pagination, error, scalar, schedule, or config shapes;
67
+ - repeated operation patterns that should become shared parameters/responses;
68
+ - a TypeScript file with orchestration, parsing, emitting, IO, and formatting
69
+ responsibilities mixed together;
70
+ - a generated diff where a small spec change creates many near-identical files.
71
+
72
+ Do not split only by line count. First identify the product or technical
73
+ boundary that gives the new file a stable name and owner.
74
+
75
+ Visual section comments can help readers navigate a healthy file, but they are
76
+ not a substitute for splitting an oversized or mixed-surface spec. If comments
77
+ start acting like a table of contents, split by capability/surface instead.
78
+
79
+ ## Product capability and API surface spec structure
80
+
81
+ Use directory nesting to communicate product ownership. The path should answer
82
+ "who owns this contract?" and the filename should answer "which surface is this?"
83
+ Read `kontract.guidance.profile.schemaLayoutStyle` before proposing a layout and
84
+ use the canonical trees in the schema layout style reference. Do not describe
85
+ resource-area fragments inside a product-capability folder as a repo-wide
86
+ `by-resource-area` layout.
87
+
88
+ For an API-only repo, keep the example API-only:
89
+
90
+ ```text
91
+ schema/
92
+ recipes/
93
+ main.api.yml # api: 3.0.3; grouped under recipes/http
94
+ catalog.api.yml
95
+ ingredients.api.yml
96
+ shared/ # only promoted reusable recipe concepts
97
+ enums.yml
98
+ components.yml
99
+ kitchen/
100
+ stations.api.yml
101
+ shared/
102
+ pagination.yml # only promoted cross-capability components
103
+ errors.yml
104
+ ```
105
+
106
+ For an async-only repo, keep the example async-only:
107
+
108
+ ```text
109
+ schema/
110
+ shared/
111
+ message-enums.yml
112
+ recipes/
113
+ recipes.async.yml
114
+ messages/
115
+ recipe-commands.yml
116
+ recipe-events.yml
117
+ models/
118
+ recipe.yml
119
+ enums.yml
120
+ ```
121
+
122
+ When a folder already carries the product-capability name, prefer
123
+ `*.api.yml` for focused surfaces that should generate as one package:
124
+
125
+ ```text
126
+ schema/
127
+ recipes/
128
+ catalog.api.yml # api: 3.0.3
129
+ ingredients.api.yml # api: 3.0.3
130
+ shared/
131
+ enums.yml # promoted after both surfaces need it
132
+ components.yml
133
+ ```
134
+
135
+ Kontract content-detects the protocol marker and groups those files under the
136
+ first folder (`recipes` in this example). Use explicit `*.api.yml` or
137
+ `*.async.yml` when each nested file should remain an independently generated
138
+ service path.
139
+
140
+ Add async schema examples only when messaging contracts exist:
141
+
142
+ ```text
143
+ schema/
144
+ recipes/
145
+ catalog.api.yml # api: 3.0.3
146
+ publishing.async.yml # async: 3.0.0
147
+ inventory.async.yml # async: 3.0.0
148
+ ```
149
+
150
+ When API schema and async schema both exist, keep `paths/` and `messages/` separate.
151
+ Share only schemas, especially enums, scalar value objects, IDs, and
152
+ slugs, through `models/` or `schema/shared/`.
153
+
154
+ If the selected schema layout style is `by-resource-area`, the resource
155
+ areas should be top-level roots under the configured schema input, not nested
156
+ under a product-capability folder. Moving from capability roots to resource-area
157
+ roots changes generated output namespaces/import paths, so call it out as a
158
+ schema and generated-output migration before recommending it.
159
+
160
+ When one product capability should keep a single generated package but the
161
+ contract is too large for one file, keep the explicit root files and split the
162
+ internals into plain `.yml` fragments. This mirrors Redocly-style authoring:
163
+ roots are the public entrypoints, fragments are implementation detail, and
164
+ schemas can be shared by API schema and async schema only when the business shape is
165
+ protocol-neutral.
166
+
167
+ ```text
168
+ schema/
169
+ bookstore/
170
+ bookstore.api.yml # API schema root entrypoint
171
+ paths/
172
+ books.yml # API schema Path Item fragment
173
+ authors.yml # API schema Path Item fragment
174
+ models/
175
+ shared.yml
176
+ books.yml
177
+ authors.yml
178
+ ```
179
+
180
+ Only add `bookstore.async.yml` and `messages/` fragments if the repo has
181
+ async schema contracts or the user asks for messaging. Do not use split fragments as
182
+ the default answer for a small API schema file.
183
+
184
+ Guidelines:
185
+
186
+ - Keep one entry-point spec per independently released API surface, not one
187
+ giant file per repo.
188
+ - Split by product meaning: `recipes`, `ingredients`, `orders`, `jobs`, or
189
+ `inventory`, not by generic words like `common`, `misc`, or `helpers`.
190
+ - Keep API schema route hierarchies aligned with the selected HTTP style. When a
191
+ child route depends on a parent for authorization, tenancy, lifecycle, or
192
+ meaning, nest it under that parent unless the selected style documents a
193
+ different public pattern.
194
+ - Use short section markers only as editor landmarks inside a file that is still
195
+ small enough to review.
196
+ - Use `schema/shared/` only for cross-capability concepts with stable semantics
197
+ and an obvious owner.
198
+ - Prefer capability-local shared components when a concept is reused only inside
199
+ one product capability.
200
+ - Keep one-off schemas inside the surface that owns them. Do not move every
201
+ component into `shared/` to anticipate future reuse.
202
+ - Keep `info.title` deliberate because async schema NATS namespaces derive from it;
203
+ filenames and titles should not drift semantically.
204
+ - Keep `$ref` paths repo-relative and validate after moving files.
205
+
206
+ ## Refactor order for oversized specs
207
+
208
+ 1. Keep one-off schemas local to the root or surface that owns them.
209
+ 2. Extract repeated capability-only shapes into a capability-local `shared/`
210
+ folder.
211
+ 3. Promote repeated cross-capability scalars, pagination, errors, envelopes,
212
+ schedules, and config objects into `schema/shared/` only when the same meaning
213
+ is reused across capabilities.
214
+ 4. Split operations by API surface when the file still mixes independently owned
215
+ workflows.
216
+ 5. Validate the moved refs with `sumr kontract validate`.
217
+ 6. Generate with the smallest useful scope and review both the spec diff and
218
+ generated output diff.
219
+
220
+ ## Refactor order for oversized code
221
+
222
+ 1. Name the current responsibilities in the file.
223
+ 2. Extract pure helpers first, then emitters/readers, then orchestration.
224
+ 3. Move interfaces and types into `src/types/` or `*.types.ts`; logic files
225
+ should import types instead of declaring them inline.
226
+ 4. Move reusable constants to `src/lib/constants.ts` or the existing constants
227
+ module.
228
+ 5. Add or adjust focused tests around the extracted seam before broad rewrites.
229
+
230
+ Prefer small safe extractions over a big rewrite. The goal is a clearer module
231
+ boundary, not a larger abstraction layer.
232
+
233
+ ## Review checklist
234
+
235
+ Before accepting a large spec or source file:
236
+
237
+ - [ ] The file is under the healthy target, or the reason for exceeding it is
238
+ documented.
239
+ - [ ] The file has one clear product/technical owner.
240
+ - [ ] Shared concepts are referenced with `$ref` rather than copied.
241
+ - [ ] No generic bucket names (`common`, `misc`, `utils`) hide unrelated
242
+ responsibilities.
243
+ - [ ] Generated output changes match the intended API surface only.
244
+ - [ ] Any split keeps spec and regenerated output committed together.