@voxgig/sdkgen 4.45.0 → 4.47.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 (276) hide show
  1. package/bin/voxgig-sdkgen +1 -1
  2. package/dist/action/check.js +73 -4
  3. package/dist/action/check.js.map +1 -1
  4. package/dist/action/copies.js +1 -0
  5. package/dist/action/copies.js.map +1 -1
  6. package/dist/action/doctor.d.ts +26 -2
  7. package/dist/action/doctor.js +208 -11
  8. package/dist/action/doctor.js.map +1 -1
  9. package/dist/action/package.d.ts +1 -1
  10. package/dist/action/package.js +15 -16
  11. package/dist/action/package.js.map +1 -1
  12. package/dist/action/remove.js +16 -4
  13. package/dist/action/remove.js.map +1 -1
  14. package/dist/action/resolve.d.ts +1 -0
  15. package/dist/action/resolve.js +10 -4
  16. package/dist/action/resolve.js.map +1 -1
  17. package/dist/action/target.d.ts +2 -1
  18. package/dist/action/target.js +50 -11
  19. package/dist/action/target.js.map +1 -1
  20. package/dist/admin/status.d.ts +7 -1
  21. package/dist/admin/status.js +34 -5
  22. package/dist/admin/status.js.map +1 -1
  23. package/dist/cmp/AgentGuide.js +46 -23
  24. package/dist/cmp/AgentGuide.js.map +1 -1
  25. package/dist/cmp/AgentGuideContent.d.ts +9 -7
  26. package/dist/cmp/AgentGuideContent.js +73 -43
  27. package/dist/cmp/AgentGuideContent.js.map +1 -1
  28. package/dist/cmp/AgentGuideFeature.js +19 -9
  29. package/dist/cmp/AgentGuideFeature.js.map +1 -1
  30. package/dist/cmp/AgentGuideTop.js +95 -49
  31. package/dist/cmp/AgentGuideTop.js.map +1 -1
  32. package/dist/cmp/Changelog.js +45 -4
  33. package/dist/cmp/Changelog.js.map +1 -1
  34. package/dist/cmp/Deploy.js +73 -35
  35. package/dist/cmp/Deploy.js.map +1 -1
  36. package/dist/cmp/Entity.js +1 -1
  37. package/dist/cmp/Entity.js.map +1 -1
  38. package/dist/cmp/ExternalTarget.js +10 -5
  39. package/dist/cmp/ExternalTarget.js.map +1 -1
  40. package/dist/cmp/Feature.js +12 -5
  41. package/dist/cmp/Feature.js.map +1 -1
  42. package/dist/cmp/FeatureDocs.d.ts +6 -4
  43. package/dist/cmp/FeatureDocs.js +14 -39
  44. package/dist/cmp/FeatureDocs.js.map +1 -1
  45. package/dist/cmp/FeatureHook.d.ts +7 -1
  46. package/dist/cmp/FeatureHook.js +34 -1
  47. package/dist/cmp/FeatureHook.js.map +1 -1
  48. package/dist/cmp/Main.js +1 -1
  49. package/dist/cmp/Main.js.map +1 -1
  50. package/dist/cmp/PublishWorkflow.js +89 -55
  51. package/dist/cmp/PublishWorkflow.js.map +1 -1
  52. package/dist/cmp/ReadmeErrors.js +521 -18
  53. package/dist/cmp/ReadmeErrors.js.map +1 -1
  54. package/dist/cmp/ReadmeExplanation.js +280 -44
  55. package/dist/cmp/ReadmeExplanation.js.map +1 -1
  56. package/dist/cmp/ReadmeFeatures.js +16 -7
  57. package/dist/cmp/ReadmeFeatures.js.map +1 -1
  58. package/dist/cmp/ReadmeIntro.js +4 -3
  59. package/dist/cmp/ReadmeIntro.js.map +1 -1
  60. package/dist/cmp/ReadmeModel.js +2 -2
  61. package/dist/cmp/ReadmeModel.js.map +1 -1
  62. package/dist/cmp/ReadmeRefFeatures.js +34 -24
  63. package/dist/cmp/ReadmeRefFeatures.js.map +1 -1
  64. package/dist/cmp/ReadmeStation.js +12 -9
  65. package/dist/cmp/ReadmeStation.js.map +1 -1
  66. package/dist/cmp/ReadmeTop.js +479 -382
  67. package/dist/cmp/ReadmeTop.js.map +1 -1
  68. package/dist/cmp/ReadmeUnions.js +8 -2
  69. package/dist/cmp/ReadmeUnions.js.map +1 -1
  70. package/dist/cmp/Registered.js +1 -1
  71. package/dist/cmp/Registered.js.map +1 -1
  72. package/dist/cmp/Security.js +26 -5
  73. package/dist/cmp/Security.js.map +1 -1
  74. package/dist/cmp/Test.js +1 -1
  75. package/dist/cmp/Test.js.map +1 -1
  76. package/dist/helpers/alongside.d.ts +2 -3
  77. package/dist/helpers/alongside.js +16 -15
  78. package/dist/helpers/alongside.js.map +1 -1
  79. package/dist/helpers/applicability.d.ts +3 -1
  80. package/dist/helpers/applicability.js +40 -1
  81. package/dist/helpers/applicability.js.map +1 -1
  82. package/dist/helpers/component.js +9 -1
  83. package/dist/helpers/component.js.map +1 -1
  84. package/dist/helpers/copymerge.d.ts +3 -0
  85. package/dist/helpers/copymerge.js +43 -10
  86. package/dist/helpers/copymerge.js.map +1 -1
  87. package/dist/helpers/definitionPlan.js +0 -1
  88. package/dist/helpers/definitionPlan.js.map +1 -1
  89. package/dist/helpers/doccheck.d.ts +11 -0
  90. package/dist/helpers/doccheck.js +146 -0
  91. package/dist/helpers/doccheck.js.map +1 -0
  92. package/dist/helpers/doctext.d.ts +11 -0
  93. package/dist/helpers/doctext.js +85 -0
  94. package/dist/helpers/doctext.js.map +1 -0
  95. package/dist/helpers/exampleCall.d.ts +16 -0
  96. package/dist/helpers/exampleCall.js +334 -0
  97. package/dist/helpers/exampleCall.js.map +1 -0
  98. package/dist/helpers/exportnames.d.ts +4 -0
  99. package/dist/helpers/exportnames.js +35 -0
  100. package/dist/helpers/exportnames.js.map +1 -0
  101. package/dist/helpers/facts.d.ts +2 -1
  102. package/dist/helpers/facts.js +210 -5
  103. package/dist/helpers/facts.js.map +1 -1
  104. package/dist/helpers/flowGuard.d.ts +1 -1
  105. package/dist/helpers/flowGuard.js +20 -7
  106. package/dist/helpers/flowGuard.js.map +1 -1
  107. package/dist/helpers/generated.d.ts +1 -0
  108. package/dist/helpers/generated.js +1 -1
  109. package/dist/helpers/generated.js.map +1 -1
  110. package/dist/helpers/graphqlPoint.d.ts +2 -1
  111. package/dist/helpers/graphqlPoint.js +17 -0
  112. package/dist/helpers/graphqlPoint.js.map +1 -1
  113. package/dist/helpers/guardModel.d.ts +2 -0
  114. package/dist/helpers/guardModel.js +41 -0
  115. package/dist/helpers/guardModel.js.map +1 -0
  116. package/dist/helpers/manifest.d.ts +2 -1
  117. package/dist/helpers/manifest.js +16 -0
  118. package/dist/helpers/manifest.js.map +1 -1
  119. package/dist/helpers/mcpTools.d.ts +2 -1
  120. package/dist/helpers/mcpTools.js +8 -1
  121. package/dist/helpers/mcpTools.js.map +1 -1
  122. package/dist/helpers/modelcheck.d.ts +2 -1
  123. package/dist/helpers/modelcheck.js +13 -0
  124. package/dist/helpers/modelcheck.js.map +1 -1
  125. package/dist/helpers/opExample.d.ts +9 -2
  126. package/dist/helpers/opExample.js +22 -2
  127. package/dist/helpers/opExample.js.map +1 -1
  128. package/dist/helpers/opShape.d.ts +2 -1
  129. package/dist/helpers/opShape.js +29 -17
  130. package/dist/helpers/opShape.js.map +1 -1
  131. package/dist/helpers/packageMeta.d.ts +6 -4
  132. package/dist/helpers/packageMeta.js +88 -53
  133. package/dist/helpers/packageMeta.js.map +1 -1
  134. package/dist/helpers/placement.d.ts +15 -0
  135. package/dist/helpers/placement.js +76 -0
  136. package/dist/helpers/placement.js.map +1 -0
  137. package/dist/helpers/semver.d.ts +3 -1
  138. package/dist/helpers/semver.js +28 -0
  139. package/dist/helpers/semver.js.map +1 -1
  140. package/dist/helpers/serverVars.js +3 -2
  141. package/dist/helpers/serverVars.js.map +1 -1
  142. package/dist/helpers/shipped.d.ts +2 -1
  143. package/dist/helpers/shipped.js +12 -0
  144. package/dist/helpers/shipped.js.map +1 -1
  145. package/dist/helpers/sourcestring.d.ts +3 -0
  146. package/dist/helpers/sourcestring.js +43 -0
  147. package/dist/helpers/sourcestring.js.map +1 -0
  148. package/dist/helpers/stdrep.d.ts +1 -1
  149. package/dist/helpers/stdrep.js +5 -1
  150. package/dist/helpers/stdrep.js.map +1 -1
  151. package/dist/helpers/surface.d.ts +7 -0
  152. package/dist/helpers/surface.js +69 -0
  153. package/dist/helpers/surface.js.map +1 -0
  154. package/dist/helpers/targetguard.d.ts +13 -0
  155. package/dist/helpers/targetguard.js +65 -0
  156. package/dist/helpers/targetguard.js.map +1 -0
  157. package/dist/helpers/text.d.ts +3 -1
  158. package/dist/helpers/text.js +16 -0
  159. package/dist/helpers/text.js.map +1 -1
  160. package/dist/helpers/textguard.d.ts +31 -0
  161. package/dist/helpers/textguard.js +157 -0
  162. package/dist/helpers/textguard.js.map +1 -0
  163. package/dist/helpers/title.d.ts +4 -0
  164. package/dist/helpers/title.js +52 -0
  165. package/dist/helpers/title.js.map +1 -0
  166. package/dist/sdkgen.d.ts +4 -6
  167. package/dist/sdkgen.js +72 -63
  168. package/dist/sdkgen.js.map +1 -1
  169. package/dist/testkit.d.ts +7 -2
  170. package/dist/testkit.js +27 -20
  171. package/dist/testkit.js.map +1 -1
  172. package/dist/tsconfig.tsbuildinfo +1 -1
  173. package/dist/utility.js +2 -1
  174. package/dist/utility.js.map +1 -1
  175. package/model/fact.aontu +150 -0
  176. package/model/sdkgen.aontu +15 -3
  177. package/package.json +3 -1
  178. package/project/.sdk/src/cmp/c/ReadmeQuick_c.ts +2 -2
  179. package/project/.sdk/src/cmp/c/ReadmeTopQuick_c.ts +1 -1
  180. package/project/.sdk/src/cmp/clojure/ReadmeEntity_clojure.ts +12 -3
  181. package/project/.sdk/src/cmp/clojure/ReadmeQuick_clojure.ts +1 -1
  182. package/project/.sdk/src/cmp/cpp/ReadmeQuick_cpp.ts +1 -1
  183. package/project/.sdk/src/cmp/csharp/ReadmeQuick_csharp.ts +1 -1
  184. package/project/.sdk/src/cmp/elixir/ReadmeQuick_elixir.ts +1 -1
  185. package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +1 -1
  186. package/project/.sdk/src/cmp/java/ReadmeQuick_java.ts +1 -1
  187. package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +1 -1
  188. package/project/.sdk/src/cmp/kotlin/ReadmeQuick_kotlin.ts +1 -1
  189. package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +1 -1
  190. package/project/.sdk/src/cmp/ocaml/ReadmeQuick_ocaml.ts +1 -1
  191. package/project/.sdk/src/cmp/perl/ReadmeQuick_perl.ts +1 -1
  192. package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +1 -1
  193. package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +1 -1
  194. package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +1 -1
  195. package/project/.sdk/src/cmp/rust/ReadmeQuick_rust.ts +1 -1
  196. package/project/.sdk/src/cmp/scala/ReadmeQuick_scala.ts +1 -1
  197. package/project/.sdk/src/cmp/scala/ReadmeRef_scala.ts +4 -1
  198. package/project/.sdk/src/cmp/swift/ReadmeQuick_swift.ts +2 -1
  199. package/project/.sdk/src/cmp/swift/ReadmeRef_swift.ts +3 -0
  200. package/project/.sdk/src/cmp/swift/ReadmeTopQuick_swift.ts +2 -1
  201. package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +1 -1
  202. package/project/.sdk/src/cmp/ts/TestDefinition_ts.ts +3 -1
  203. package/project/.sdk/src/cmp/zig/ReadmeOptions_zig.ts +1 -1
  204. package/project/.sdk/src/cmp/zig/ReadmeQuick_zig.ts +3 -3
  205. package/project/.sdk/src/cmp/zig/ReadmeTopQuick_zig.ts +2 -2
  206. package/project/.sdk/tm/ocaml/test/feature/secrets/t_secrets.ml +3 -1
  207. package/project/.sdk/tm/php/test/feature/secrets/SecretsTest.php +2 -1
  208. package/project/.sdk/tm/zig/test/feature/secrets/secrets_test.zig +11 -2
  209. package/project/sdkgen-package.json +1 -1
  210. package/src/action/check.ts +99 -4
  211. package/src/action/copies.ts +2 -0
  212. package/src/action/doctor.ts +304 -15
  213. package/src/action/package.ts +11 -13
  214. package/src/action/remove.ts +20 -5
  215. package/src/action/resolve.ts +11 -4
  216. package/src/action/target.ts +66 -15
  217. package/src/admin/status.ts +25 -5
  218. package/src/cmp/AgentGuide.ts +52 -25
  219. package/src/cmp/AgentGuideContent.ts +75 -43
  220. package/src/cmp/AgentGuideFeature.ts +21 -10
  221. package/src/cmp/AgentGuideTop.ts +119 -49
  222. package/src/cmp/Changelog.ts +56 -5
  223. package/src/cmp/Deploy.ts +81 -40
  224. package/src/cmp/Entity.ts +1 -1
  225. package/src/cmp/ExternalTarget.ts +12 -6
  226. package/src/cmp/Feature.ts +13 -6
  227. package/src/cmp/FeatureDocs.ts +21 -40
  228. package/src/cmp/FeatureHook.ts +38 -1
  229. package/src/cmp/Main.ts +1 -1
  230. package/src/cmp/PublishWorkflow.ts +94 -60
  231. package/src/cmp/ReadmeErrors.ts +555 -25
  232. package/src/cmp/ReadmeExplanation.ts +316 -52
  233. package/src/cmp/ReadmeFeatures.ts +18 -8
  234. package/src/cmp/ReadmeIntro.ts +4 -3
  235. package/src/cmp/ReadmeModel.ts +2 -2
  236. package/src/cmp/ReadmeRefFeatures.ts +39 -27
  237. package/src/cmp/ReadmeStation.ts +13 -16
  238. package/src/cmp/ReadmeTop.ts +538 -397
  239. package/src/cmp/ReadmeUnions.ts +10 -2
  240. package/src/cmp/Registered.ts +1 -1
  241. package/src/cmp/Security.ts +35 -7
  242. package/src/cmp/Test.ts +1 -1
  243. package/src/helpers/alongside.ts +16 -19
  244. package/src/helpers/applicability.ts +44 -1
  245. package/src/helpers/component.ts +11 -1
  246. package/src/helpers/copymerge.ts +58 -10
  247. package/src/helpers/definitionPlan.ts +0 -1
  248. package/src/helpers/doccheck.ts +174 -0
  249. package/src/helpers/doctext.ts +115 -0
  250. package/src/helpers/exampleCall.ts +415 -0
  251. package/src/helpers/exportnames.ts +47 -0
  252. package/src/helpers/facts.ts +259 -5
  253. package/src/helpers/flowGuard.ts +22 -7
  254. package/src/helpers/generated.ts +3 -1
  255. package/src/helpers/graphqlPoint.ts +20 -1
  256. package/src/helpers/guardModel.ts +50 -0
  257. package/src/helpers/manifest.ts +19 -0
  258. package/src/helpers/mcpTools.ts +11 -1
  259. package/src/helpers/modelcheck.ts +16 -0
  260. package/src/helpers/opExample.ts +34 -2
  261. package/src/helpers/opShape.ts +29 -16
  262. package/src/helpers/packageMeta.ts +89 -52
  263. package/src/helpers/placement.ts +114 -0
  264. package/src/helpers/semver.ts +35 -0
  265. package/src/helpers/serverVars.ts +4 -2
  266. package/src/helpers/shipped.ts +13 -0
  267. package/src/helpers/sourcestring.ts +47 -0
  268. package/src/helpers/stdrep.ts +6 -1
  269. package/src/helpers/surface.ts +82 -0
  270. package/src/helpers/targetguard.ts +91 -0
  271. package/src/helpers/text.ts +22 -0
  272. package/src/helpers/textguard.ts +208 -0
  273. package/src/helpers/title.ts +59 -0
  274. package/src/sdkgen.ts +82 -78
  275. package/src/testkit.ts +42 -20
  276. package/src/utility.ts +2 -1
@@ -9,7 +9,8 @@ import {
9
9
 
10
10
  import { credentialPlacement } from '../utility'
11
11
  import { optionalComponent } from '../helpers/optional'
12
- import { featureDocs } from './FeatureDocs'
12
+ import { featureDocs, codeList } from './FeatureDocs'
13
+ import { PIPELINE_STAGES, pipelineLength } from './FeatureHook'
13
14
  import type { FeatureDoc } from './FeatureDocs'
14
15
 
15
16
  import {
@@ -20,8 +21,10 @@ import { mcpTools, MCP_WRITE_OPS } from '../helpers/mcpTools'
20
21
  import type { ExampleLang, PrimaryCall } from '../helpers/opExample'
21
22
  import { canonScalarKey } from '../helpers/canonType'
22
23
  import { safeVarName, exampleVarName, jsKey } from '../helpers/naming'
23
- import { modelText } from '../helpers/text'
24
- import { isConsumer } from '../helpers/alongside'
24
+ import { definitionName, modelText } from '../helpers/text'
25
+ import { fact } from '../helpers/facts'
26
+ import { documentOrder, surfaceOf } from '../helpers/surface'
27
+ import { copyMode, MERGE } from '../helpers/copymerge'
25
28
 
26
29
  import {
27
30
  installCommand as pkgInstall,
@@ -31,6 +34,7 @@ import {
31
34
  vendorCommand,
32
35
  apiName,
33
36
  nonAffiliation,
37
+ publisherInfo,
34
38
  docsSiteUrl,
35
39
  originName,
36
40
  isDefaultPublisher,
@@ -97,243 +101,186 @@ function entityExample(lang: ExampleLang, Name: string, call: PrimaryCall | null
97
101
  }
98
102
 
99
103
 
100
- const ReadmeTop = cmp(function ReadmeTop(props: any) {
101
- const { ctx$ } = props
102
- const { model } = ctx$
103
-
104
- if (model.name && !model.Name) names(model, model.name)
105
-
106
- const info = modelText(model)
107
- const def = (model.main && model.main.def) || {}
108
-
109
- const productName = info.title || `${model.Name} API`
110
-
111
- const tagline = info.tagline
112
- || def.tagline
113
- || `${productName} client, generated from the OpenAPI spec.`
114
-
115
- const aboutMd = info.about_md || ''
116
- const homepage = info.homepage || ''
117
- const docsUrl = info.docs_url || ''
118
- const entityDesc = info.entity_desc || {}
119
-
120
- const apiSummary = (info.summary || '').trim()
121
- const apiWebsite = (info.website || '').trim()
122
- const websiteLine = apiWebsite
123
- ? `Learn more about ${productName} at ` +
124
- `[${apiWebsite.replace(/^https?:\/\//, '').replace(/\/$/, '')}](${apiWebsite}).`
125
- : ''
126
-
127
- // Attribution for API metadata sourced from a third-party catalogue (e.g.
128
- // freepublicapis.com). Rendered only when the model carries an
129
- // `info.meta_source` URL, so first-party SDKs never show it. The link points
130
- // back to the catalogue that kindly supplied the metadata.
131
- const metaSource = (info.meta_source || '').trim()
132
- const metaSourceLine = metaSource
133
- ? `Metadata kindly supplied by ` +
134
- `[${metaSource.replace(/^https?:\/\//, '').replace(/\/$/, '')}](${metaSource}).`
135
- : ''
136
-
137
- const entity = getModelPath(model, `main.${KIT}.entity`)
138
- const target = getModelPath(model, `main.${KIT}.target`)
139
- const feature = getModelPath(model, `main.${KIT}.feature`)
140
-
141
- each(entity, (ent: any) => { if (!ent.Name) names(ent, ent.name) })
142
- each(feature, (feat: any) => { if (!feat.Name) names(feat, feat.name) })
143
-
144
- const activeEntities = each(entity).filter((e: any) => e.active !== false)
145
- const activeTargets = each(target).filter((t: any) => t.active !== false)
146
-
147
- const hasCli = activeTargets.some((t: any) => t.name === 'go-cli')
148
- const hasMcp = activeTargets.some((t: any) => t.name === 'go-mcp')
104
+ const ReadmeTopTitle = cmp(function ReadmeTopTitle(props: any) {
105
+ const { model, tagline, apiSummary, websiteLine, metaSourceLine } = props.s
149
106
 
150
-
151
- const docsOrder: string[] = (getModelPath(model, `main.${KIT}.config.docs_order`,
152
- { only_active: false, required: false }) as any) || []
153
-
154
- const orderOf = (name: string): number => {
155
- const i = docsOrder.indexOf(name)
156
- if (i !== -1) return i
157
- if (name === 'go-cli') return docsOrder.length + 1
158
- if (name === 'go-mcp') return docsOrder.length + 2
159
- return docsOrder.length
160
- }
161
-
162
- const ordered = activeTargets
163
- .slice()
164
- .sort((a: any, b: any) => orderOf(a.name) - orderOf(b.name))
165
-
166
- const isCliOrMcp = (t: any) => t.name === 'go-cli' || t.name === 'go-mcp'
167
-
168
- const sdkTargets = ordered.filter((t: any) => !isConsumer(t))
169
-
170
- // The CLI and the MCP server have surfaces of their own below.
171
- const consumerTargets = ordered.filter((t: any) => isConsumer(t) && !isCliOrMcp(t))
172
-
173
- const docTargets = ordered.filter((t: any) => !isCliOrMcp(t))
174
-
175
- const pkgTargets = activeTargets
176
- .filter((t: any) => hasPackageName(model, t.name))
177
- .sort((a: any, b: any) => orderOf(a.name) - orderOf(b.name))
178
-
179
- const langList = sdkTargets.map((t: any) => t.title).join(', ')
180
- const leadTarget = pickLeadTarget(sdkTargets)
181
-
182
- File({ name: 'README.md' }, () => {
183
-
184
- Content(`# ${model.Name} SDK
107
+ Content(`# ${model.Name} SDK
185
108
 
186
109
  ${tagline}
187
110
 
188
111
  `)
189
- if (apiSummary) {
190
- Content(`${apiSummary}
112
+ if (apiSummary) {
113
+ Content(`${apiSummary}
191
114
 
192
115
  `)
193
- }
194
- if (websiteLine) {
195
- Content(`${websiteLine}
116
+ }
117
+ if (websiteLine) {
118
+ Content(`${websiteLine}
196
119
 
197
120
  `)
198
- }
199
- Content(`${nonAffiliation(model)}
121
+ }
122
+ Content(`${nonAffiliation(model)}
200
123
 
201
124
  `)
202
- if (isDefaultPublisher(model)) {
203
- Content(`Learn more about Voxgig SDKs at [voxgig.com/sdk](${VOXGIG_SDK}).
125
+ if (isDefaultPublisher(model)) {
126
+ Content(`Learn more about Voxgig SDKs at [voxgig.com/sdk](${VOXGIG_SDK}).
204
127
 
205
128
  `)
206
- }
129
+ }
207
130
 
208
- // THE GENERATED SITE, LINKED FROM THE TOP, because the repository was the
209
- // one place it could not be found from. `docs_url` further down is the
210
- // UPSTREAM API's documentation, not this, and a reader who lands on the
211
- // repo rather than arriving from a link had no route to the site at all.
212
- // Empty unless the project actually publishes one -- see docsSiteUrl.
213
- const siteUrl = docsSiteUrl(model)
214
- if (siteUrl) {
215
- Content(`Full documentation for this SDK: [${siteUrl}](${siteUrl})
131
+ // THE GENERATED SITE, LINKED FROM THE TOP, because the repository was the
132
+ // one place it could not be found from. `docs_url` further down is the
133
+ // UPSTREAM API's documentation, not this, and a reader who lands on the
134
+ // repo rather than arriving from a link had no route to the site at all.
135
+ // Empty unless the project actually publishes one -- see docsSiteUrl.
136
+ const siteUrl = docsSiteUrl(model)
137
+ if (siteUrl) {
138
+ Content(`Full documentation for this SDK: [${siteUrl}](${siteUrl})
216
139
 
217
140
  `)
218
- }
219
- if (metaSourceLine) {
220
- Content(`${metaSourceLine}
141
+ }
142
+ if (metaSourceLine) {
143
+ Content(`${metaSourceLine}
221
144
 
222
145
  `)
223
- }
146
+ }
147
+ })
148
+
149
+
150
+ const ReadmeTopSurfaceLine = cmp(function ReadmeTopSurfaceLine(props: any) {
151
+ const { hasCli, hasMcp, sdkTargets, consumerTargets, langList, definition } = props.s
224
152
 
225
- if (sdkTargets.length > 1) {
226
- const surfaces = []
227
- surfaces.push(`${langList} SDKs`)
228
- if (hasCli) surfaces.push('a CLI with an interactive REPL')
229
- if (hasMcp) surfaces.push('an MCP server for AI agents')
230
- consumerTargets.forEach((t: any) => surfaces.push(`the ${t.title} package`))
231
- const surfaceList = surfaces.length > 1
232
- ? surfaces.slice(0, -1).join(', ') + ', and ' + surfaces[surfaces.length - 1]
233
- : surfaces[0]
234
- Content(`> ${surfaceList} — all generated from one OpenAPI spec by [@voxgig/sdkgen](${SDKGEN_REPO}).
153
+ if (sdkTargets.length > 1) {
154
+ const surfaces = []
155
+ surfaces.push(`${langList} SDKs`)
156
+ if (hasCli) surfaces.push('a CLI with an interactive REPL')
157
+ if (hasMcp) surfaces.push('an MCP server for AI agents')
158
+ consumerTargets.forEach((t: any) => surfaces.push(`the ${fact(t, 'title')} package`))
159
+ const surfaceList = surfaces.length > 1
160
+ ? surfaces.slice(0, -1).join(', ') + ', and ' + surfaces[surfaces.length - 1]
161
+ : surfaces[0]
162
+ Content(`> ${surfaceList} — all generated from one ${definition} by [@voxgig/sdkgen](${SDKGEN_REPO}).
235
163
 
236
164
  `)
237
- }
165
+ }
166
+ })
167
+
238
168
 
239
- // FEATURES BELONG BESIDE THE TARGETS. What an SDK can do is as much a
240
- // reason to choose it as which language it is in, and a reader who has to
241
- // scroll past every language section to discover that retries, caching and
242
- // tracing are built in has already decided it is a thin HTTP wrapper.
243
- // Named here, in one line, with the detail left to each target's README.
244
- const features = featureDocs(model)
245
- if (0 < features.length) {
246
- Content(`> **Features:** ${features.map((f: FeatureDoc) => '`' + f.name + '`').join(', ')} — opt-in,
247
- > inactive until switched on, and configured per client. See the Features
169
+ const ReadmeTopFeatureLine = cmp(function ReadmeTopFeatureLine(props: any) {
170
+ const { model } = props.s
171
+
172
+ // FEATURES BELONG BESIDE THE TARGETS. What an SDK can do is as much a
173
+ // reason to choose it as which language it is in, and a reader who has to
174
+ // scroll past every language section to discover that retries, caching and
175
+ // tracing are built in has already decided it is a thin HTTP wrapper.
176
+ // Named here, in one line, with the detail left to each target's README.
177
+ const features = featureDocs(model)
178
+ if (0 < features.length) {
179
+ const on = features.filter((f: FeatureDoc) => f.on).map((f: FeatureDoc) => f.name)
180
+ const state = 0 === on.length ? `opt-in,
181
+ > inactive until switched on, and configured per client.` : `configured per client.
182
+ > ${codeList(on)} ${1 === on.length ? 'runs' : 'run'} by default${on.length < features.length ?
183
+ '; the rest are opt-in, inactive until switched on' : ''}.`
184
+ Content(`> **Features:** ${features.map((f: FeatureDoc) => '`' + f.name + '`').join(', ')} — ${state} See the Features
248
185
  > section of any SDK README below for what each one does.
249
186
 
250
187
  `)
251
- }
188
+ }
189
+ })
190
+
252
191
 
253
- if (aboutMd) {
254
- Content(`## About ${productName}
192
+ const ReadmeTopAbout = cmp(function ReadmeTopAbout(props: any) {
193
+ const { text, productName, aboutMd } = props.s
255
194
 
256
- ${aboutMd.trim()}
195
+ if (aboutMd) {
196
+ Content(`## About ${productName}
197
+
198
+ ${aboutMd}
257
199
 
258
200
  `)
259
- } else if (def.desc) {
260
- Content(`${def.desc}
201
+ } else if (text.desc.text) {
202
+ Content(`${text.desc.text}
261
203
 
262
204
  `)
263
- }
205
+ }
206
+ })
264
207
 
265
- if (activeEntities.length > 0) {
266
- const entNames = activeEntities.map((e: any) => e.Name)
267
- const entCount = entNames.length
268
- const entList = entCount > 1
269
- ? entNames.slice(0, -1).join(', ') + ' and ' + entNames[entNames.length - 1]
270
- : entNames[0]
271
- const NAME_INLINE_MAX = 6
272
- const inlineNames = entCount <= NAME_INLINE_MAX
273
- const surface = inlineNames
274
- ? `a small set of **semantic entities** — ${entList} —`
275
- : `**${entCount} semantic entities**`
276
- const seeEntities = inlineNames
277
- ? ''
278
- : ' See the [Entities](#entities) table below for the full list.'
279
- const exEnt = activeEntities[0]
280
- const ex = exEnt.Name
281
- const exLower = exampleVarName(ex.toLowerCase(), 'ts')
282
- // The example call uses the entity's PRIMARY op — an op it actually
283
- // exposes (prefer list -> the array, then load -> the record, else a
284
- // create with its required fields). A create-only entity therefore never
285
- // shows a phantom .list()/.load() that would not compile. If it exposes
286
- // only remove (or nothing), the op line is omitted entirely.
287
- const primaryOp = entityPrimaryOp(exEnt)
288
- let exCall = ''
289
- const exIdField = entityIdField(exEnt)
290
- const exListArg = listMatchArg('ts', exEnt)
291
- const exLoadArg = matchArg('ts', exEnt, 'load', exIdField,
292
- idLiteral(exEnt, 'load', exIdField))
293
-
294
- if ('list' === primaryOp) {
295
- exCall = `const items = await client.${ex}().list(${exListArg})`
296
- } else if ('load' === primaryOp) {
297
- exCall = `const ${exLower} = await client.${ex}().load(${exLoadArg})`
298
- } else if ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp) {
299
- const exIdF = entityIdField(exEnt)
300
- // Drop the id only when the request shape says it is OPTIONAL. It is
301
- // server-assigned on a normal create, but an op whose id comes from a
302
- // PATH PARAMETER requires it, and the typed CreateData then rejects a
303
- // body without it. Same rule as dataArg in helpers/opExample.
304
- const shapeItems = requestExampleItems(exEnt, primaryOp)
305
- .filter((it: any) =>
306
- (it.name !== exIdF && it.name !== 'id') || !it.optional)
307
- const required = shapeItems.filter((it: any) => !it.optional)
308
- const chosen = required.length ? required : shapeItems.slice(0, 3)
309
- const bodyLines = chosen.map((it: any) => ` ${jsKey(it.name)}: ${tsExampleLiteral(it.type)},`)
310
- const body = bodyLines.length ? `\n${bodyLines.join('\n')}\n` : ''
311
- exCall = `const ${exLower} = await client.${ex}().${primaryOp}({${body}})`
312
- }
313
- const CANON_OPS = ['list', 'load', 'create', 'update', 'patch', 'remove']
314
- const opSet = new Set<string>()
315
- activeEntities.forEach((e: any) => Object.keys(e.op || {})
316
- .forEach((o: string) => { if ((e.op as any)[o] && (e.op as any)[o].active !== false) opSet.add(o) }))
317
- const opNames = CANON_OPS.filter((o) => opSet.has(o)).concat([...opSet].filter((o) => !CANON_OPS.includes(o)))
318
- const opList = (opNames.length ? opNames : ['list', 'load']).map((o) => '`' + o + '`').join(', ')
319
-
320
- // In the SDK's own language: ts when it has one, else the first the
321
- // example helpers can write, else no example at all.
322
- const lang = exampleLang(model, sdkTargets)
323
- let snippet = ''
324
- if ('ts' === lang) {
325
- snippet = `const client = new ${model.Name}SDK()${exCall ? '\n' + exCall : ''}`
326
- }
327
- else if (null != lang) {
328
- const call = ['list', 'load', 'create', 'update', 'patch'].includes(String(primaryOp))
329
- ? primaryOpCall(lang, ex, exampleVarName(ex.toLowerCase(), lang), primaryOp!, exIdField, exEnt)
330
- : null
331
- snippet = entityExample(lang, model.Name, call)
332
- }
333
- const exBlock = '' === snippet ? '.' :
334
- `:\n\n\`\`\`${EXAMPLE_FENCE[lang!]}\n${snippet}\n\`\`\``
335
208
 
336
- Content(`## Entities, not endpoints
209
+ const ReadmeTopEntityModel = cmp(function ReadmeTopEntityModel(props: any) {
210
+ const { model, activeEntities, sdkTargets } = props.s
211
+
212
+ if (activeEntities.length > 0) {
213
+ const entNames = activeEntities.map((e: any) => e.Name)
214
+ const entCount = entNames.length
215
+ const entList = entCount > 1
216
+ ? entNames.slice(0, -1).join(', ') + ' and ' + entNames[entNames.length - 1]
217
+ : entNames[0]
218
+ const NAME_INLINE_MAX = 6
219
+ const inlineNames = entCount <= NAME_INLINE_MAX
220
+ const surface = inlineNames
221
+ ? `a small set of **semantic entities** — ${entList} —`
222
+ : `**${entCount} semantic entities**`
223
+ const seeEntities = inlineNames
224
+ ? ''
225
+ : ' See the [Entities](#entities) table below for the full list.'
226
+ const exEnt = activeEntities[0]
227
+ const ex = exEnt.Name
228
+ const exLower = exampleVarName(ex.toLowerCase(), 'ts')
229
+ // The example call uses the entity's PRIMARY op — an op it actually
230
+ // exposes (prefer list -> the array, then load -> the record, else a
231
+ // create with its required fields). A create-only entity therefore never
232
+ // shows a phantom .list()/.load() that would not compile. If it exposes
233
+ // only remove (or nothing), the op line is omitted entirely.
234
+ const primaryOp = entityPrimaryOp(exEnt)
235
+ let exCall = ''
236
+ const exIdField = entityIdField(exEnt)
237
+ const exListArg = listMatchArg('ts', exEnt)
238
+ const exLoadArg = matchArg('ts', exEnt, 'load', exIdField,
239
+ idLiteral(exEnt, 'load', exIdField))
240
+
241
+ if ('list' === primaryOp) {
242
+ exCall = `const items = await client.${ex}().list(${exListArg})`
243
+ } else if ('load' === primaryOp) {
244
+ exCall = `const ${exLower} = await client.${ex}().load(${exLoadArg})`
245
+ } else if ('create' === primaryOp || 'update' === primaryOp || 'patch' === primaryOp) {
246
+ const exIdF = entityIdField(exEnt)
247
+ // Drop the id only when the request shape says it is OPTIONAL. It is
248
+ // server-assigned on a normal create, but an op whose id comes from a
249
+ // PATH PARAMETER requires it, and the typed CreateData then rejects a
250
+ // body without it. Same rule as dataArg in helpers/opExample.
251
+ const shapeItems = requestExampleItems(exEnt, primaryOp)
252
+ .filter((it: any) =>
253
+ (it.name !== exIdF && it.name !== 'id') || !it.optional)
254
+ const required = shapeItems.filter((it: any) => !it.optional)
255
+ const chosen = required.length ? required : shapeItems.slice(0, 3)
256
+ const bodyLines = chosen.map((it: any) => ` ${jsKey(it.name)}: ${tsExampleLiteral(it.type)},`)
257
+ const body = bodyLines.length ? `\n${bodyLines.join('\n')}\n` : ''
258
+ exCall = `const ${exLower} = await client.${ex}().${primaryOp}({${body}})`
259
+ }
260
+ const CANON_OPS = ['list', 'load', 'create', 'update', 'patch', 'remove']
261
+ const opSet = new Set<string>()
262
+ activeEntities.forEach((e: any) => Object.keys(e.op || {})
263
+ .forEach((o: string) => { if ((e.op as any)[o] && (e.op as any)[o].active !== false) opSet.add(o) }))
264
+ const opNames = CANON_OPS.filter((o) => opSet.has(o)).concat([...opSet].filter((o) => !CANON_OPS.includes(o)))
265
+ const opList = (opNames.length ? opNames : ['list', 'load']).map((o) => '`' + o + '`').join(', ')
266
+
267
+ // In the SDK's own language: ts when it has one, else the first the
268
+ // example helpers can write, else no example at all.
269
+ const lang = exampleLang(model, sdkTargets)
270
+ let snippet = ''
271
+ if ('ts' === lang) {
272
+ snippet = `const client = new ${model.Name}SDK()${exCall ? '\n' + exCall : ''}`
273
+ }
274
+ else if (null != lang) {
275
+ const call = ['list', 'load', 'create', 'update', 'patch'].includes(String(primaryOp))
276
+ ? primaryOpCall(lang, ex, exampleVarName(ex.toLowerCase(), lang), primaryOp!, exIdField, exEnt)
277
+ : null
278
+ snippet = entityExample(lang, model.Name, call)
279
+ }
280
+ const exBlock = '' === snippet ? '.' :
281
+ `:\n\n\`\`\`${EXAMPLE_FENCE[lang!]}\n${snippet}\n\`\`\``
282
+
283
+ Content(`## Entities, not endpoints
337
284
 
338
285
  This SDK exposes the API as ${surface} that you
339
286
  call directly, instead of assembling URL paths and query strings.${seeEntities} Entities are
@@ -344,126 +291,156 @@ Thinking in entities keeps the mental model small — for people and AI agents a
344
291
  rather than reasoning about raw HTTP routes and query parameters.
345
292
 
346
293
  `)
347
- }
294
+ }
295
+ })
348
296
 
349
- if (sdkTargets.length > 0) {
350
- Content(`## Offline unit testing
297
+
298
+ const ReadmeTopTesting = cmp(function ReadmeTopTesting(props: any) {
299
+ const { ctx$, sdkTargets } = props.s
300
+
301
+ if (sdkTargets.length > 0) {
302
+ Content(`## Offline unit testing
351
303
 
352
304
  Every SDK ships a built-in **test mode** that swaps the HTTP transport for
353
305
  an in-memory mock, so your unit tests run fully offline — no server, no
354
306
  network, and no credentials:
355
307
 
356
308
  `)
357
- sdkTargets.forEach((tgt: any) => {
358
- const Test =
359
- optionalComponent(ctx$, tgt, 'ReadmeTopTest')
360
- if (Test) {
361
- Content(`### ${tgt.title}
309
+ sdkTargets.forEach((tgt: any) => {
310
+ const Test =
311
+ optionalComponent(ctx$, tgt, 'ReadmeTopTest')
312
+ if (Test) {
313
+ Content(`### ${fact(tgt, 'title')}
362
314
 
363
315
  `)
364
- Test['ReadmeTopTest']({ target: tgt })
365
- Content(`
316
+ Test['ReadmeTopTest']({ target: tgt })
317
+ Content(`
366
318
  `)
367
- }
368
- })
369
- }
319
+ }
320
+ })
321
+ }
322
+ })
323
+
324
+
325
+ const ReadmeTopPackages = cmp(function ReadmeTopPackages(props: any) {
326
+ const { model, pkgTargets } = props.s
370
327
 
371
- // 3. Packages — real published package name + install command per
372
- // ecosystem. A package that is NOT yet live on its registry (the fleet
373
- // default: 'pending') must NOT advertise a `npm install ...` that 404s —
374
- // its Install cell links to the target README's install section instead,
375
- // as do go-cli and go-mcp, which the Go proxy cannot install.
376
- if (pkgTargets.length > 0) {
377
- Content(`## Packages
328
+ // 3. Packages — real published package name + install command per
329
+ // ecosystem. A package that is NOT yet live on its registry (the fleet
330
+ // default: 'pending') must NOT advertise a `npm install ...` that 404s —
331
+ // its Install cell links to the target README's install section instead,
332
+ // as do go-cli and go-mcp, which the Go proxy cannot install.
333
+ if (pkgTargets.length > 0) {
334
+ Content(`## Packages
378
335
 
379
336
  | Language | Package | Install |
380
337
  | --- | --- | --- |
381
338
  `)
382
- pkgTargets.forEach((tgt: any) => {
383
- const state = registryState(model, tgt.name)
384
- let cell: string
385
- if ('active' === state) {
386
- const cmd = installCommand(tgt, model)
387
- if (!cmd) return
388
- cell = '`' + cmd + '`'
389
- } else if ('tag' === state) {
390
- const cmd = vendorCommand(model, tgt.name)
391
- cell = cmd
392
- ? '`' + cmd + '`'
393
- : `build from source — [${tgt.name}/README.md](${tgt.name}/README.md)`
394
- } else {
395
- // The target README always gives a route that works without a
396
- // tag, which a repository may not have.
397
- cell = `publish pending — [install from source](${tgt.name}/README.md#install)`
398
- }
399
- Content(`| ${tgt.title} | \`${packageName(model, tgt.name)}\` | ${cell} |
400
- `)
401
- })
402
- Content(`
339
+ pkgTargets.forEach((tgt: any) => {
340
+ const state = registryState(model, tgt.name)
341
+ const readme = fact(tgt, 'docs').readme
342
+ let cell: string
343
+ if ('active' === state) {
344
+ const cmd = installCommand(tgt, model)
345
+ cell = cmd
346
+ ? '`' + cmd + '`'
347
+ : readme ? `see [${tgt.name}/README.md](${tgt.name}/README.md#install)` : `see \`${tgt.name}/\``
348
+ } else if ('tag' === state) {
349
+ const cmd = vendorCommand(model, tgt.name)
350
+ cell = cmd
351
+ ? '`' + cmd + '`'
352
+ : 'build from source — ' + (readme ? `[${tgt.name}/README.md](${tgt.name}/README.md)` : `\`${tgt.name}/\``)
353
+ } else {
354
+ // The target README always gives a route that works without a
355
+ // tag, which a repository may not have.
356
+ cell = readme ? `publish pending — [install from source](${tgt.name}/README.md#install)` :
357
+ `publish pending — install from source in \`${tgt.name}/\``
358
+ }
359
+ Content(`| ${fact(tgt, 'title')} | \`${packageName(model, tgt.name)}\` | ${cell} |
403
360
  `)
404
- }
361
+ })
362
+ Content(`
363
+ `)
364
+ }
365
+ })
405
366
 
406
- if (leadTarget) {
407
- Content(`## Quickstart
408
367
 
409
- ### ${leadTarget.title}
368
+ const ReadmeTopQuickstart = cmp(function ReadmeTopQuickstart(props: any) {
369
+ const { model, ctx$, leadTarget } = props.s
410
370
 
411
- `)
412
- const LeadQuick =
413
- optionalComponent(ctx$, leadTarget, 'ReadmeTopQuick')
414
- if (LeadQuick) {
415
- LeadQuick['ReadmeTopQuick']({ target: leadTarget })
416
- }
417
- const placement = credentialPlacement(model)
418
- Content(`
419
- ${'' === placement ? '' : placement + '\n\n'}See the [${leadTarget.title} README](${leadTarget.name}/README.md) for the full guide.
371
+ if (leadTarget) {
372
+ Content(`## Quickstart
373
+
374
+ ### ${fact(leadTarget, 'title')}
420
375
 
421
376
  `)
377
+ const LeadQuick =
378
+ optionalComponent(ctx$, leadTarget, 'ReadmeTopQuick')
379
+ if (LeadQuick) {
380
+ LeadQuick['ReadmeTopQuick']({ target: leadTarget })
422
381
  }
382
+ const placement = credentialPlacement(model)
383
+ Content(`
384
+ ${'' === placement ? '' : placement + '\n\n'}${fact(leadTarget, 'docs').readme ?
385
+ `See the [${fact(leadTarget, 'title')} README](${leadTarget.name}/README.md) for the full guide.` : ''}
386
+
387
+ `)
388
+ }
389
+ })
423
390
 
424
- if (sdkTargets.length > 0 || hasCli || hasMcp || consumerTargets.length > 0) {
425
- Content(`## Surfaces
391
+
392
+ const ReadmeTopSurfaces = cmp(function ReadmeTopSurfaces(props: any) {
393
+ const { hasCli, hasMcp, cliTargets, mcpTargets, sdkTargets, consumerTargets, langList } = props.s
394
+ const paths = (targets: any[]) => targets.map((t: any) => `\`${t.name}/\``).join(' ')
395
+
396
+ if (sdkTargets.length > 0 || hasCli || hasMcp || consumerTargets.length > 0) {
397
+ Content(`## Surfaces
426
398
 
427
399
  | Surface | Path |
428
400
  | --- | --- |
429
401
  `)
430
- if (sdkTargets.length > 0) {
431
- const paths = sdkTargets.map((t: any) => `\`${t.name}/\``).join(' ')
432
- Content(`| **SDK** (${langList}) | ${paths} |
402
+ if (sdkTargets.length > 0) {
403
+ Content(`| **SDK** (${langList}) | ${paths(sdkTargets)} |
433
404
  `)
434
- }
435
- if (hasCli) {
436
- Content(`| **CLI** | \`go-cli/\` |
405
+ }
406
+ if (hasCli) {
407
+ Content(`| **CLI** | ${paths(cliTargets)} |
437
408
  `)
438
- }
439
- if (hasMcp) {
440
- Content(`| **MCP server** | \`go-mcp/\` |
409
+ }
410
+ if (hasMcp) {
411
+ Content(`| **MCP server** | ${paths(mcpTargets)} |
441
412
  `)
442
- }
443
- consumerTargets.forEach((t: any) => {
444
- Content(`| **${t.title}** | \`${t.name}/\` |
413
+ }
414
+ consumerTargets.forEach((t: any) => {
415
+ Content(`| **${fact(t, 'title')}** | \`${t.name}/\` |
445
416
  `)
446
- })
447
- Content(`
417
+ })
418
+ Content(`
448
419
  `)
449
- }
420
+ }
421
+ })
450
422
 
451
- if (hasMcp) {
452
- const mcpOps = mcpTools(model).map((tool) => tool.op)
453
- const mcpWrite = true === model.main?.[KIT]?.target?.['go-mcp']?.tool?.write
454
- const toggle = "`main: kit: target: 'go-mcp': tool: write: true`"
455
- const opText = mcpOps.length < 2 ? mcpOps.join('') :
456
- mcpOps.slice(0, -1).join(', ') + ' and ' + mcpOps[mcpOps.length - 1]
457
- // What the server reads and writes is what it registers, not the flag.
458
- const reads = mcpOps.some((op) => MCP_WRITE_OPS.includes(op)) ? '' : mcpWrite ?
459
- ' It only reads, as no entity has a create, update, patch or remove a plain call runs.' :
460
- ` It only reads: create, update, patch and remove become tools when the SDK's model sets
423
+
424
+ const ReadmeTopMcp = cmp(function ReadmeTopMcp(props: any) {
425
+ const { model, hasMcp, mcpTargets } = props.s
426
+
427
+ if (hasMcp) {
428
+ const mcp = mcpTargets[0].name
429
+ const mcpOps = mcpTools(model, mcp).map((tool) => tool.op)
430
+ const mcpWrite = true === mcpTargets[0].tool?.write
431
+ const toggle = `\`main: kit: target: '${mcp}': tool: write: true\``
432
+ const opText = mcpOps.length < 2 ? mcpOps.join('') :
433
+ mcpOps.slice(0, -1).join(', ') + ' and ' + mcpOps[mcpOps.length - 1]
434
+ // What the server reads and writes is what it registers, not the flag.
435
+ const reads = mcpOps.some((op) => MCP_WRITE_OPS.includes(op)) ? '' : mcpWrite ?
436
+ ' It only reads, as no entity has a create, update, patch or remove a plain call runs.' :
437
+ ` It only reads: create, update, patch and remove become tools when the SDK's model sets
461
438
  ${toggle}.`
462
- Content(0 === mcpOps.length ? `## Use it from an AI agent (MCP)
439
+ Content(0 === mcpOps.length ? `## Use it from an AI agent (MCP)
463
440
 
464
441
  The generated MCP server has no tools for this SDK: no entity has a list or
465
442
  load a plain call runs${mcpWrite ? ', or a create, update, patch or remove' :
466
- `, and create, update, patch and remove are off until the SDK's model sets
443
+ `, and create, update, patch and remove are off until the SDK's model sets
467
444
  ${toggle}`}.
468
445
 
469
446
  ` : `## Use it from an AI agent (MCP)
@@ -473,7 +450,7 @@ The generated MCP server exposes this SDK's ${opText} operations as
473
450
  can call directly.${reads} Build and register it:
474
451
 
475
452
  \`\`\`bash
476
- cd go-mcp && go build -o ${model.name}-mcp .
453
+ cd ${mcp} && go build -o ${model.name}-mcp .
477
454
  \`\`\`
478
455
 
479
456
  Then add it to your agent's MCP config (Claude Desktop, Cursor, etc.):
@@ -489,10 +466,15 @@ Then add it to your agent's MCP config (Claude Desktop, Cursor, etc.):
489
466
  \`\`\`
490
467
 
491
468
  `)
492
- }
469
+ }
470
+ })
471
+
472
+
473
+ const ReadmeTopEntities = cmp(function ReadmeTopEntities(props: any) {
474
+ const { activeEntities } = props.s
493
475
 
494
- if (activeEntities.length > 0) {
495
- Content(`## Entities
476
+ if (activeEntities.length > 0) {
477
+ Content(`## Entities
496
478
 
497
479
  The API exposes ${activeEntities.length === 1 ? 'one entity' : activeEntities.length + ' entities'}:
498
480
 
@@ -500,48 +482,56 @@ The API exposes ${activeEntities.length === 1 ? 'one entity' : activeEntities.le
500
482
  | --- | --- | --- |
501
483
  `)
502
484
 
503
- activeEntities.map((ent: any) => {
504
- const ops = ent.op || {}
505
- const opNames = Object.keys(ops).filter((o: string) => (ops as any)[o]?.active !== false)
506
- const entdesc = entityDesc[ent.name] || ent.short || ent.desc ||
507
- `The ${ent.Name} entity${opNames.length ? ' (' + opNames.join(', ') + ')' : ''}.`
508
- const path = entityPath(ent)
509
- Content(`| **${ent.Name}** | ${entdesc} | \`${path}\` |
485
+ activeEntities.map((ent: any) => {
486
+ const ops = ent.op || {}
487
+ const opNames = Object.keys(ops).filter((o: string) => (ops as any)[o]?.active !== false)
488
+ const entdesc = fact(ent, 'desc').cell ||
489
+ `The ${ent.Name} entity${opNames.length ? ' (' + opNames.join(', ') + ')' : ''}.`
490
+ const path = entityPath(ent)
491
+ Content(`| **${ent.Name}** | ${entdesc} | \`${path}\` |
510
492
  `)
511
- })
493
+ })
512
494
 
513
- const opUnion = new Set<string>()
514
- activeEntities.forEach((e: any) => Object.keys(e.op || {})
515
- .forEach((o: string) => { if ((e.op as any)[o]?.active !== false) opUnion.add(o) }))
516
- const opAvail = ['load', 'list', 'create', 'update', 'patch', 'remove'].filter((o) => opUnion.has(o))
517
- const opBold = (opAvail.length ? opAvail : ['load', 'list']).map((o) => '**' + o + '**').join(', ')
518
- Content(`
495
+ const opUnion = new Set<string>()
496
+ activeEntities.forEach((e: any) => Object.keys(e.op || {})
497
+ .forEach((o: string) => { if ((e.op as any)[o]?.active !== false) opUnion.add(o) }))
498
+ const opAvail = ['load', 'list', 'create', 'update', 'patch', 'remove'].filter((o) => opUnion.has(o))
499
+ const opBold = (opAvail.length ? opAvail : ['load', 'list']).map((o) => '**' + o + '**').join(', ')
500
+ Content(`
519
501
  The operations available across these entities are ${opBold} — see each entity's
520
502
  own list above for exactly which it supports.
521
503
 
522
504
  `)
523
- }
505
+ }
506
+ })
507
+
508
+
509
+ const ReadmeTopOtherLanguages = cmp(function ReadmeTopOtherLanguages(props: any) {
510
+ const { ctx$, sdkTargets, leadTarget } = props.s
524
511
 
525
- const otherTargets = sdkTargets.filter((t: any) => leadTarget && t.name !== leadTarget.name)
526
- if (otherTargets.length > 0) {
527
- Content(`## Quickstart in other languages
512
+ const otherTargets = sdkTargets.filter((t: any) => leadTarget && t.name !== leadTarget.name)
513
+ if (otherTargets.length > 0) {
514
+ Content(`## Quickstart in other languages
528
515
 
529
516
  `)
530
- otherTargets.forEach((tgt: any) => {
531
- const Quick =
532
- optionalComponent(ctx$, tgt, 'ReadmeTopQuick')
533
- if (Quick) {
534
- Content(`### ${tgt.title}
517
+ otherTargets.forEach((tgt: any) => {
518
+ const Quick =
519
+ optionalComponent(ctx$, tgt, 'ReadmeTopQuick')
520
+ if (Quick) {
521
+ Content(`### ${fact(tgt, 'title')}
535
522
 
536
523
  `)
537
- Quick['ReadmeTopQuick']({ target: tgt })
538
- Content(`
524
+ Quick['ReadmeTopQuick']({ target: tgt })
525
+ Content(`
539
526
  `)
540
- }
541
- })
542
- }
527
+ }
528
+ })
529
+ }
530
+ })
543
531
 
544
- Content(`## Direct and prepare
532
+
533
+ const ReadmeTopDirect = cmp(function ReadmeTopDirect() {
534
+ Content(`## Direct and prepare
545
535
 
546
536
  For endpoints the entity model doesn't cover, use the low-level methods:
547
537
 
@@ -552,8 +542,13 @@ Both accept a map with \`path\`, \`method\`, \`params\`, \`query\`,
552
542
  \`headers\`, and \`body\`. See the [How-to guides](#how-to-guides) below.
553
543
 
554
544
  `)
545
+ })
555
546
 
556
- Content(`## How-to guides
547
+
548
+ const ReadmeTopHowtoGuides = cmp(function ReadmeTopHowtoGuides(props: any) {
549
+ const { ctx$, sdkTargets } = props.s
550
+
551
+ Content(`## How-to guides
557
552
 
558
553
  ### Make a direct API call
559
554
 
@@ -561,70 +556,79 @@ When the entity interface does not cover an endpoint, use \`direct\`:
561
556
 
562
557
  `)
563
558
 
564
- sdkTargets.forEach((tgt: any) => {
565
- const Howto =
566
- optionalComponent(ctx$, tgt, 'ReadmeTopHowto')
567
- if (Howto) {
568
- Howto['ReadmeTopHowto']({ target: tgt })
569
- }
570
- })
559
+ sdkTargets.forEach((tgt: any) => {
560
+ const Howto =
561
+ optionalComponent(ctx$, tgt, 'ReadmeTopHowto')
562
+ if (Howto) {
563
+ Howto['ReadmeTopHowto']({ target: tgt })
564
+ }
565
+ })
566
+ })
567
+
571
568
 
572
- Content(`## Advanced
569
+ const ReadmeTopAdvanced = cmp(function ReadmeTopAdvanced(props: any) {
570
+ const { feature } = props.s
571
+
572
+ Content(`## Advanced
573
573
 
574
574
  > Everyday use only needs the sections above. This explains the internals
575
575
  > behind every call — relevant when writing custom features.
576
576
 
577
- Every SDK call runs the same five-stage pipeline:
577
+ Every entity operation runs the same ${pipelineLength()}-stage pipeline:
578
578
 
579
- 1. **Point** — resolve the API endpoint from the operation definition.
580
- 2. **Spec** — build the HTTP specification (URL, method, headers, body).
581
- 3. **Request** — send the HTTP request.
582
- 4. **Response** — receive and parse the response.
583
- 5. **Result** — extract the result data for the caller.
579
+ ${PIPELINE_STAGES.map((s, i) => (i + 1) + '. **' + s.name + '** — ' + s.purpose).join('\n')}
584
580
 
585
- A feature hook fires at each stage (e.g. \`PrePoint\`, \`PreSpec\`,
586
- \`PreRequest\`), so features can inspect or modify the pipeline without
581
+ A feature hook fires before each stage (e.g. \`${PIPELINE_STAGES[0].hook}\`, \`${PIPELINE_STAGES[1].hook}\`,
582
+ \`${PIPELINE_STAGES[2].hook}\`), so features can inspect or modify the pipeline without
587
583
  forking the SDK.
588
584
 
589
- ### Features
590
-
591
585
  `)
592
586
 
593
- Content(`| Feature | Purpose |
587
+ const active = each(feature).filter((feat: any) => feat.active)
588
+ if (0 < active.length) {
589
+ Content(`### Features
590
+
591
+ | Feature | Purpose |
594
592
  | --- | --- |
595
593
  `)
596
- each(feature, (feat: any) => {
597
- if (!feat.active) return
598
- const purpose = feat.title || feat.Name || feat.name
594
+ for (const feat of active) {
595
+ const purpose = fact(feat, 'title').cell || feat.Name || feat.name
599
596
  Content(`| **${feat.Name || feat.name}Feature** | ${purpose} |
600
597
  `)
601
- })
602
-
598
+ }
603
599
  Content(`
604
- Pass custom features via the \`extend\` option at construction time.
600
+ `)
601
+ }
602
+
603
+ Content(`Pass custom features via the \`extend\` option at construction time.
605
604
 
606
605
  `)
606
+ })
607
+
607
608
 
608
- // 11c. Customization: model-driven declarations, in-repo templates and
609
- // components, regeneration that overwrites, customising in `.sdk`, and a
610
- // map of which paths are the project's to edit. Every SDK repo carries
611
- // its own generator, so this belongs in every README. A repository that
612
- // regenerates `.sdk` in full says so, since its copies do not merge.
613
- const mapTarget = sdkTargets[0] || docTargets[0]
614
- const targetDir = mapTarget ? `\`<target>/\`, such as \`${mapTarget.name}/\`` : `\`<target>/\``
615
- const merging = 'overwrite' !== model.main?.kit?.copies
616
- const mergeNote = merging ?
617
- `An add merges toolchain updates into the
609
+ const ReadmeTopCustomizing = cmp(function ReadmeTopCustomizing(props: any) {
610
+ const { model, sdkTargets, docTargets, definition } = props.s
611
+
612
+ // 11c. Customization: model-driven declarations, in-repo templates and
613
+ // components, regeneration that overwrites, customising in `.sdk`, and a
614
+ // map of which paths are the project's to edit. Every SDK repo carries
615
+ // its own generator, so this belongs in every README. A repository that
616
+ // regenerates `.sdk` in full says so, since its copies do not merge.
617
+ const mapTarget = sdkTargets[0] || docTargets[0]
618
+ const targetDir = mapTarget ? `\`<target>/\`, such as \`${mapTarget.name}/\`` : `\`<target>/\``
619
+ const merging = MERGE === copyMode(model.main?.[KIT]?.copies)
620
+ const mergeNote = merging ?
621
+ `An add merges toolchain updates into the
618
622
  edited copies, and \`voxgig-sdkgen doctor\` reports any drift from what a
619
623
  resync would write.` :
620
- `This repository regenerates \`.sdk\` in full
624
+ `This repository regenerates \`.sdk\` in full
621
625
  (\`main: kit: copies: 'overwrite'\`): set it to \`'merge'\` before
622
626
  customising, so that an add merges toolchain updates into the edited
623
627
  copies.`
624
- const copiesRow = merging ?
625
- `Yes. They are this project's copies, and \`target add\` merges toolchain updates into your edits.` :
626
- `Only after setting \`copies\` to \`'merge'\`. This repository regenerates them in full.`
627
- Content(`## Customizing this SDK
628
+ const copiesRow = merging ?
629
+ `Yes. They are this project's copies, and \`target add\` merges toolchain updates into your edits.` :
630
+ `Only after setting \`copies\` to \`'merge'\`. This repository regenerates them in full.`
631
+ Content(`## Customizing this SDK
628
632
 
629
633
  This repository contains its own generator (\`.sdk/\`), so the SDK is
630
634
  customizable without forking any upstream tool:
@@ -658,7 +662,7 @@ customizable without forking any upstream tool:
658
662
  | \`.sdk/model/text.aontu\` | The README wording, in \`main.kit.text\`: the tagline, the summary and the entity descriptions | Yes. The scaffold writes it once and never again. |
659
663
  | \`.sdk/model/guide/guide.aontu\` | How the spec's paths map onto entities and operations | Yes. The scaffold writes it once and never again. |
660
664
  | \`.sdk/model/\`, the rest | The API model built from the spec, and the target and feature definitions | Not by hand. Generation, \`target add\` and a new scaffold run rewrite it, apart from a feature or target this project defines itself. |
661
- | \`.sdk/def/\` | The OpenAPI spec | Replace it when the API changes. Generation rebuilds the model from it. |
665
+ | \`.sdk/def/\` | The ${definition} | Replace it when the API changes. Generation rebuilds the model from it. |
662
666
  | \`.sdk/src/cmp/<target>/\`, \`.sdk/tm/<target>/\` | The components and templates that generate each target | ${copiesRow} |
663
667
  | \`.sdk/test/\` | The shared test cases the generated tests run | No. |
664
668
  | ${targetDir} | One generated SDK per target, with its own tests | No. Generation overwrites it. |
@@ -681,62 +685,199 @@ How-to: [customize and propagate templates](https://github.com/voxgig/sdkgen/blo
681
685
  The full story: [voxgig.com/sdk/custom](https://voxgig.com/sdk/custom).
682
686
 
683
687
  `)
688
+ })
684
689
 
685
- if (docTargets.length > 0) {
686
- Content(`## Per-language documentation
690
+
691
+ const ReadmeTopPerLanguage = cmp(function ReadmeTopPerLanguage(props: any) {
692
+ const { docTargets } = props.s
693
+
694
+ if (docTargets.length > 0) {
695
+ Content(`## Per-language documentation
687
696
 
688
697
  `)
689
- docTargets.forEach((tgt: any) => {
690
- Content(`- [${tgt.title}](${tgt.name}/README.md)
698
+ docTargets.filter((tgt: any) => fact(tgt, 'docs').readme).forEach((tgt: any) => {
699
+ Content(`- [${fact(tgt, 'title')}](${tgt.name}/README.md)
691
700
  `)
692
- })
693
- Content(`
701
+ })
702
+ Content(`
694
703
  `)
695
- }
704
+ }
705
+ })
696
706
 
697
- const upstreamUrl = (info.contact && info.contact.url)
698
- || (info.servers && info.servers[0] && info.servers[0].url)
699
- || homepage
700
- Content(`## Upstream API
701
707
 
702
- This SDK is generated from the upstream OpenAPI specification. It is an
703
- unofficial client and is not affiliated with the API provider.
708
+ const ReadmeTopUpstream = cmp(function ReadmeTopUpstream(props: any) {
709
+ const { text, definition, definitionFull, model } = props.s
710
+ const upstream = text.upstream
711
+ const docs = text.docs_url
712
+ Content(`## Upstream API
704
713
 
705
- The OpenAPI spec(s) this SDK was generated from are kept in the
714
+ This SDK is generated from the upstream ${definitionFull}.${publisherInfo(model).official ? '' : ` It is an
715
+ unofficial client and is not affiliated with the API provider.`}
716
+
717
+ The ${definition}(s) this SDK was generated from are kept in the
706
718
  [\`.sdk/def/\`](.sdk/def/) folder.
707
719
 
708
720
  `)
709
- if (upstreamUrl) {
710
- // A per-tenant server URL carries an OpenAPI server variable —
711
- // `https://{instance}.dreamapply.com/api` — and is the right thing to
712
- // SHOW, because it tells the reader the host is theirs to fill in. It is
713
- // not a thing to LINK: the braces are not a resolvable address, so a
714
- // markdown link renders as clickable and dead. Show it as code instead.
715
- const templated = /[{}]/.test(upstreamUrl)
716
- Content(templated
717
- ? `- Upstream API: \`${upstreamUrl}\`
721
+ if (upstream.raw) {
722
+ // A per-tenant server URL carries an OpenAPI server variable —
723
+ // `https://{instance}.dreamapply.com/api` — and is the right thing to
724
+ // SHOW, because it tells the reader the host is theirs to fill in. It is
725
+ // not a thing to LINK: the braces are not a resolvable address, so a
726
+ // markdown link renders as clickable and dead. Show it as code instead.
727
+ const templated = /[{}]/.test(upstream.raw)
728
+ Content(templated
729
+ ? `- Upstream API: ${upstream.code}
718
730
  `
719
- : `- Upstream API: [${upstreamUrl}](${upstreamUrl})
731
+ : `- Upstream API: [${upstream.inline}](${upstream.link})
720
732
  `)
721
- }
722
- if (docsUrl && docsUrl !== upstreamUrl) {
723
- Content(`- Documentation: [${docsUrl}](${docsUrl})
733
+ }
734
+ if (docs.raw && docs.raw !== upstream.raw) {
735
+ Content(`- Documentation: [${docs.inline}](${docs.link})
724
736
  `)
725
- }
726
- Content(`
737
+ }
738
+ Content(`
727
739
  `)
740
+ })
728
741
 
729
- Content(`## Security
742
+
743
+ const ReadmeTopSecurity = cmp(function ReadmeTopSecurity(props: any) {
744
+ const { model } = props.s
745
+
746
+ Content(`## Security
730
747
 
731
748
  Please report security issues ${securityContact(model)}. See [SECURITY.md](SECURITY.md).
732
749
  Do not open public issues for suspected vulnerabilities.
733
750
 
734
751
  `)
752
+ })
753
+
735
754
 
736
- Content(`---
755
+ const ReadmeTopFooter = cmp(function ReadmeTopFooter(props: any) {
756
+ const { productName, definition } = props.s
737
757
 
738
- Generated from the ${productName} OpenAPI spec by [@voxgig/sdkgen](${SDKGEN_REPO}).
758
+ Content(`---
759
+
760
+ Generated from the ${productName} ${definition} by [@voxgig/sdkgen](${SDKGEN_REPO}).
739
761
  `)
762
+ })
763
+
764
+
765
+ const ReadmeTop = cmp(function ReadmeTop(props: any) {
766
+ const { ctx$ } = props
767
+ const { model } = ctx$
768
+
769
+ if (model.name && !model.Name) names(model, model.name)
770
+
771
+ const info = modelText(model)
772
+ const def = (model.main && model.main.def) || {}
773
+
774
+ const text = fact(model.main[KIT], 'text')
775
+
776
+ const productName = fact(model.main[KIT], 'apiName').inline
777
+
778
+ const kind = fact(model.main[KIT], 'definitionKind')
779
+ const definition = definitionName(kind)
780
+ const definitionFull = definitionName(kind, true)
781
+
782
+ const tagline = text.tagline.inline
783
+ || `${productName} client, generated from the ${definition}.`
784
+
785
+ const aboutMd = text.about_md.text
786
+
787
+ const apiSummary = text.summary.inline
788
+ const websiteLine = text.website.raw
789
+ ? `Learn more about ${productName} at [${text.website.label}](${text.website.link}).`
790
+ : ''
791
+
792
+ // Attribution for API metadata sourced from a third-party catalogue (e.g.
793
+ // freepublicapis.com). Rendered only when the model carries an
794
+ // `info.meta_source` URL, so first-party SDKs never show it. The link points
795
+ // back to the catalogue that kindly supplied the metadata.
796
+ const metaSourceLine = text.meta_source.raw
797
+ ? `Metadata kindly supplied by [${text.meta_source.label}](${text.meta_source.link}).`
798
+ : ''
799
+
800
+ const entity = getModelPath(model, `main.${KIT}.entity`)
801
+ const target = getModelPath(model, `main.${KIT}.target`)
802
+ const feature = getModelPath(model, `main.${KIT}.feature`)
803
+
804
+ each(entity, (ent: any) => { if (!ent.Name) names(ent, ent.name) })
805
+ each(feature, (feat: any) => { if (!feat.Name) names(feat, feat.name) })
806
+
807
+ const activeEntities = each(entity).filter((e: any) => e.active !== false)
808
+ const activeTargets = fact(model.main[KIT], 'active').map((name: string) => target[name])
809
+
810
+ const cliTargets = activeTargets.filter((t: any) => 'cli' === surfaceOf(t))
811
+ const mcpTargets = activeTargets.filter((t: any) => 'mcp' === surfaceOf(t))
812
+ const hasCli = 0 < cliTargets.length
813
+ const hasMcp = 0 < mcpTargets.length
814
+
815
+
816
+ const ordered = documentOrder(model, activeTargets)
817
+
818
+ const isCliOrMcp = (t: any) => ['cli', 'mcp'].includes(surfaceOf(t))
819
+
820
+ const sdkTargets = ordered.filter((t: any) => 'sdk' === surfaceOf(t))
821
+
822
+ // The CLI and the MCP server have surfaces of their own below.
823
+ const consumerTargets = ordered.filter((t: any) => 'sdk' !== surfaceOf(t) && !isCliOrMcp(t))
824
+
825
+ const docTargets = ordered.filter((t: any) => !isCliOrMcp(t))
826
+
827
+ const pkgTargets = ordered.filter((t: any) => hasPackageName(model, t.name))
828
+
829
+ const langList = sdkTargets.map((t: any) => fact(t, 'title')).join(', ')
830
+ const leadTarget = pickLeadTarget(sdkTargets)
831
+
832
+ const s = {
833
+ model,
834
+ ctx$,
835
+ info,
836
+ def,
837
+ text,
838
+ productName,
839
+ definition,
840
+ definitionFull,
841
+ tagline,
842
+ aboutMd,
843
+ apiSummary,
844
+ websiteLine,
845
+ metaSourceLine,
846
+ feature,
847
+ activeEntities,
848
+ hasCli,
849
+ hasMcp,
850
+ cliTargets,
851
+ mcpTargets,
852
+ sdkTargets,
853
+ consumerTargets,
854
+ docTargets,
855
+ pkgTargets,
856
+ langList,
857
+ leadTarget,
858
+ }
859
+
860
+ File({ name: 'README.md' }, () => {
861
+ ReadmeTopTitle({ s })
862
+ ReadmeTopSurfaceLine({ s })
863
+ ReadmeTopFeatureLine({ s })
864
+ ReadmeTopAbout({ s })
865
+ ReadmeTopEntityModel({ s })
866
+ ReadmeTopTesting({ s })
867
+ ReadmeTopPackages({ s })
868
+ ReadmeTopQuickstart({ s })
869
+ ReadmeTopSurfaces({ s })
870
+ ReadmeTopMcp({ s })
871
+ ReadmeTopEntities({ s })
872
+ ReadmeTopOtherLanguages({ s })
873
+ ReadmeTopDirect({ s })
874
+ ReadmeTopHowtoGuides({ s })
875
+ ReadmeTopAdvanced({ s })
876
+ ReadmeTopCustomizing({ s })
877
+ ReadmeTopPerLanguage({ s })
878
+ ReadmeTopUpstream({ s })
879
+ ReadmeTopSecurity({ s })
880
+ ReadmeTopFooter({ s })
740
881
  })
741
882
  })
742
883