@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
@@ -6,14 +6,21 @@ import {
6
6
  getModelPath
7
7
  } from '../types'
8
8
 
9
+ import { CANON_UNION_JOIN } from '../helpers/canonType'
10
+ import { originName } from '../helpers/packageMeta'
11
+
9
12
 
10
13
  const MIN_REPORTED_BRANCHES = 3
11
14
 
12
15
 
13
16
  const ReadmeUnions = cmp(function ReadmeUnions(props: any) {
14
- const { ctx$ } = props
17
+ const { ctx$, target } = props
15
18
  const { model } = ctx$
16
19
 
20
+ // Where a language cannot join a union's branches, a two-variant field is
21
+ // an open value too, though it is below the table's threshold.
22
+ const joins = null != (CANON_UNION_JOIN as any)[originName(model, target?.name)]
23
+
17
24
  const entity = getModelPath(model, `main.${KIT}.entity`)
18
25
 
19
26
  const rows: { entity: string, field: string, branches: number, depth: number }[] = []
@@ -65,7 +72,8 @@ ${rows.map((r) =>
65
72
 
66
73
  These values round-trip unchanged — read them, modify them, send them back. If
67
74
  the API adds a \`discriminator\` to the definition, regenerating will type them.
68
- Every other field is typed normally.
75
+ ${joins ? 'Every other field is typed normally.' :
76
+ 'A field with two variants is an open value here too; every other field is\ntyped normally.'}
69
77
  `)
70
78
  })
71
79
 
@@ -25,7 +25,7 @@ function registerComponent(name: string, options: RegisterOptions = {}) {
25
25
  const { target, ctx$ } = props
26
26
  const { model, log } = ctx$
27
27
 
28
- const stdrep = ensureStdrep(ctx$)
28
+ const stdrep = ensureStdrep(ctx$, target)
29
29
 
30
30
  const path = `./cmp/${target.name}/${name}_${target.name}`
31
31
  const mod: any = optional ? loadOptional(ctx$, path) : requirePath(ctx$, path)
@@ -1,22 +1,48 @@
1
- import { Content, File } from 'jostraca'
1
+ import { Content, File, each } from 'jostraca'
2
2
  import { cmp } from '../helpers/component'
3
+ import { fact } from '../helpers/facts'
4
+ import { documentOrder, surfaceOf } from '../helpers/surface'
5
+ import { seriesList } from '../helpers/text'
6
+ import { KIT, getModelPath } from '../types'
3
7
 
4
8
  import {
5
- apiName, isDefaultPublisher, publisherInfo, repoInfo, securityContact,
9
+ apiName, isDefaultPublisher, publisherInfo, registryLabel, registryName, repoInfo,
10
+ securityContact,
6
11
  } from '../helpers/packageMeta'
7
12
 
8
13
 
14
+ // Where the SDK packages are published: each registry, then the Go module,
15
+ // then the git tags a port with no registry releases by.
16
+ function publishedTo(model: any): string[] {
17
+ const sdks = documentOrder(model,
18
+ each(getModelPath(model, `main.${KIT}.target`, { required: false }) || {})
19
+ .filter((t: any) => false !== t.active && 'sdk' === surfaceOf(t)))
20
+
21
+ const registries = sdks.filter((t: any) => 'go' !== fact(t, 'origin'))
22
+ .map((t: any) => registryName(model, t.name))
23
+
24
+ return [
25
+ ...new Set(registries.filter((name: string) => '' !== name).map(registryLabel)),
26
+ ...(sdks.some((t: any) => 'go' === fact(t, 'origin')) ? ['the Go module'] : []),
27
+ ...(registries.includes('') ? ['git tags'] : []),
28
+ ]
29
+ }
30
+
31
+
9
32
  const Security = cmp(function Security(props: any) {
10
33
  const { ctx$ } = props
11
34
  const { model } = ctx$
12
35
 
13
- const { issuesUrl } = repoInfo(model)
36
+ const { issuesUrl, host, hostName } = repoInfo(model)
37
+ const publicIssues = hostName === host ? `public issues on ${host}` : `public ${hostName} issues`
14
38
  const publisher = publisherInfo(model)
15
39
 
16
40
  // Voxgig's own response commitment, which another publisher has not made.
17
41
  const promise = isDefaultPublisher(model) ?
18
42
  ' We aim to\nacknowledge reports within 3 business days.' : ''
19
43
 
44
+ const places = publishedTo(model)
45
+
20
46
  File({ name: 'SECURITY.md' }, () => {
21
47
  Content(`# Security Policy
22
48
 
@@ -24,18 +50,20 @@ const Security = cmp(function Security(props: any) {
24
50
 
25
51
  Please report security issues ${securityContact(model)}.
26
52
 
27
- Do not open public GitHub issues for suspected vulnerabilities.${promise}
53
+ Do not open ${publicIssues} for suspected vulnerabilities.${promise}
28
54
 
29
55
  For non-security bugs, use the issue tracker: ${issuesUrl}
30
56
 
31
57
  ## Scope
32
58
 
33
59
  This policy applies to the generated ${publisher.name} SDK packages published from this
34
- repository (npm, PyPI, Packagist, RubyGems, LuaRocks, and the Go module).
60
+ repository${0 === places.length ? '' : ' (' + seriesList(places) + ')'}.
35
61
 
36
- This is an unofficial SDK for the ${apiName(model)} public API, generated by
62
+ ${publisher.official ?
63
+ `This SDK for the ${apiName(model)} API is generated by ${publisher.name}.` :
64
+ `This is an unofficial SDK for the ${apiName(model)} public API, generated by
37
65
  ${publisher.name}. It is not affiliated with, endorsed by, or sponsored by the upstream
38
- API provider.
66
+ API provider.`}
39
67
  `)
40
68
  })
41
69
  })
package/src/cmp/Test.ts CHANGED
@@ -20,7 +20,7 @@ import {
20
20
  const Test = cmp(function Test(props: any) {
21
21
  const { target, ctx$ } = props
22
22
  const { model, log } = ctx$
23
- const stdrep = ensureStdrep(ctx$)
23
+ const stdrep = ensureStdrep(ctx$, target)
24
24
 
25
25
  const points = Object.values(model.main.kit.entity || {}).flatMap((entity: any) =>
26
26
  Object.values(entity.op || {}).flatMap((op: any) => op.points || [])) as any[]
@@ -1,26 +1,24 @@
1
1
  import { KIT } from '@voxgig/apidef'
2
2
 
3
+ import { fact } from './facts'
4
+ import { surfaceOf } from './surface'
3
5
 
4
- const PHASES = ['entity', 'feature', 'readme', 'agentguide', 'test']
5
6
 
6
-
7
- // A consumer (py-data) switches every phase off and has no ReadmeTop components.
8
- function isConsumer(target: any): boolean {
9
- return PHASES.every((name: string) => false === target?.phase?.[name]?.active)
10
- }
11
-
12
-
13
- // Names only the active surfaces, so a project with go-mcp off is not promised one.
14
- function alongsideNote(model: any, self: string): string {
7
+ // Names only the active surfaces, so a project with go-mcp off is not promised
8
+ // one. `link` is the root README from this target's folder, and without one
9
+ // there is no note.
10
+ function alongsideNote(model: any, self: string, link?: string): string {
15
11
  const target = model?.main?.[KIT]?.target || {}
16
- const others = Object.entries(target)
17
- .filter(([name, t]: [string, any]) => name !== self && null != t && false !== t.active)
12
+ const readme = link ?? (null == target[self] ? '' : fact(target[self], 'link').readme)
13
+ if ('' === readme) return ''
14
+
15
+ const others = fact(model.main[KIT], 'active')
16
+ .filter((name: string) => name !== self)
17
+ .map((name: string) => surfaceOf(target[name]))
18
18
 
19
- const has = (name: string) => others.some(([other]) => other === name)
20
- const cli = has('go-cli')
21
- const mcp = has('go-mcp')
22
- const langs = others.some(([name, t]: [string, any]) =>
23
- 'go-cli' !== name && 'go-mcp' !== name && !isConsumer(t))
19
+ const cli = others.includes('cli')
20
+ const mcp = others.includes('mcp')
21
+ const langs = others.includes('sdk')
24
22
 
25
23
  const parts: string[] = []
26
24
  if (langs) parts.push('Other languages')
@@ -34,13 +32,12 @@ function alongsideNote(model: any, self: string): string {
34
32
  const verb = 1 === parts.length && !langs ? 'lives' : 'live'
35
33
 
36
34
  return `> ${list[0].toUpperCase() + list.slice(1)} ${verb} alongside this one — see
37
- > the [top-level README](../README.md).
35
+ > the [top-level README](${readme}).
38
36
 
39
37
  `
40
38
  }
41
39
 
42
40
 
43
41
  export {
44
- isConsumer,
45
42
  alongsideNote,
46
43
  }
@@ -1,6 +1,13 @@
1
1
 
2
+ import Fs from 'node:fs'
3
+
4
+ import { Aontu } from 'aontu'
2
5
  import { KIT, getModelPath } from '@voxgig/apidef'
3
6
 
7
+ import { definitionPathAny, migrateIncludes } from './definition'
8
+ import { scaffoldFolder } from './shipped'
9
+ import { resolvesBundled } from '../action/resolve'
10
+
4
11
 
5
12
  function tags(val: any): string[] {
6
13
  if (Array.isArray(val)) {
@@ -23,12 +30,25 @@ function featureApplies(feature: any, target: any): boolean {
23
30
  return true
24
31
  }
25
32
 
26
- const provides = tags(target && target.provides)
33
+ const provides = providedBy(target)
27
34
 
28
35
  return needs.every((need: string) => provides.includes(need))
29
36
  }
30
37
 
31
38
 
39
+ // An add keeps an alias's own model file, so one that declares no `provides`
40
+ // takes its origin's.
41
+ function providedBy(target: any): string[] {
42
+ const own = target?.provides
43
+ const origin = target?.origname
44
+ if ((null != own && 0 < Object.keys(own).length) || 'string' !== typeof origin ||
45
+ '' === origin || origin === target.name || !resolvesBundled(target, target.name)) {
46
+ return tags(own)
47
+ }
48
+ return shippedProvides(origin)
49
+ }
50
+
51
+
32
52
  function targetFeatures(model: any, target: any): Record<string, any> {
33
53
  const feature = getModelPath(model, `main.${KIT}.feature`, { required: false }) || {}
34
54
 
@@ -53,6 +73,27 @@ function targetFeatures(model: any, target: any): Record<string, any> {
53
73
  }
54
74
 
55
75
 
76
+ const shipped = new Map<string, string[]>()
77
+
78
+ // The tags this package's own copy of a target provides; a project's older
79
+ // copy of the same target may lack them.
80
+ function shippedProvides(origin: string): string[] {
81
+ if (!shipped.has(origin)) {
82
+ const path = definitionPathAny(Fs, scaffoldFolder(), 'target', origin)
83
+ let provides: string[] = []
84
+ if (Fs.existsSync(path)) {
85
+ const errs: any[] = []
86
+ const model = new Aontu().generate(migrateIncludes(Fs.readFileSync(path, 'utf8')), { path, errs })
87
+ if (0 === errs.length) {
88
+ provides = tags(model?.main?.[KIT]?.target?.[origin]?.provides)
89
+ }
90
+ }
91
+ shipped.set(origin, provides)
92
+ }
93
+ return shipped.get(origin) as string[]
94
+ }
95
+
96
+
56
97
  const TAGS = [
57
98
  // A vendored sekreto port lives in this target's feature container.
58
99
  'sekreto',
@@ -69,6 +110,8 @@ function unknownTags(val: any): string[] {
69
110
 
70
111
  export {
71
112
  featureApplies,
113
+ providedBy,
114
+ shippedProvides,
72
115
  targetFeatures,
73
116
  tags as featureTags,
74
117
  unknownTags,
@@ -6,12 +6,22 @@ import * as Jostraca from 'jostraca'
6
6
  const COMPONENT = 'cmp'
7
7
 
8
8
 
9
- // jostraca's cmp, labelling each node it makes with the component's name.
9
+ // The components that write one target's own files, a project's registered
10
+ // ones included.
11
+ const PER_TARGET = ['Main', 'Entity', 'Feature', 'Readme', 'Test', 'AgentGuide', 'Registered']
12
+
13
+
14
+ // jostraca's cmp, labelling each node it makes with the component's name. A
15
+ // target a run override relocates writes nothing in the in-tree pass.
10
16
  const cmp: typeof Jostraca.cmp = ((component: any) => {
11
17
  const labelled = (props: any, children?: any) => {
12
18
  if (null != props?.ctx$?.node?.meta) {
13
19
  props.ctx$.node.meta[COMPONENT] = component.name
14
20
  }
21
+ if (PER_TARGET.includes(component.name) &&
22
+ true === props?.ctx$?.meta?.relocated?.includes(props?.target?.name)) {
23
+ return
24
+ }
15
25
  return component(props, children)
16
26
  }
17
27
  Object.defineProperty(labelled, 'name', { value: component.name })
@@ -4,6 +4,8 @@ import { execFileSync } from 'node:child_process'
4
4
 
5
5
  import { DiffUtil } from 'jostraca'
6
6
 
7
+ import { isTypeScript, missingExports } from './exportnames'
8
+
7
9
 
8
10
  // How a toolchain write treats a project file the project changed after the
9
11
  // toolchain last wrote it.
@@ -39,6 +41,10 @@ type GuardSpec = {
39
41
  // Earlier versions of a file, newest first, for a base the store lacks.
40
42
  versions?: (abs: string) => Iterable<Buffer>
41
43
 
44
+ // Drops the record of files kept with no base, which the run recorded as
45
+ // written.
46
+ forget?: (rels: string[]) => void
47
+
42
48
  error?: (msg: string) => Error
43
49
  }
44
50
 
@@ -53,6 +59,13 @@ type Conflict = {
53
59
  type MergeOutcome = {
54
60
  merged: string[]
55
61
  kept: string[]
62
+
63
+ // Kept with no base, so nothing records them: an add stops on them again.
64
+ unrecorded: string[]
65
+
66
+ // Kept TypeScript files, by the names the incoming copy exports and they lack.
67
+ lacking: Record<string, string[]>
68
+
56
69
  retained: string[]
57
70
  spared: string[]
58
71
  }
@@ -385,7 +398,9 @@ class CopyGuard {
385
398
 
386
399
 
387
400
  finish(): MergeOutcome {
388
- const outcome: MergeOutcome = { merged: [], kept: [], retained: [], spared: this.spared }
401
+ const outcome: MergeOutcome = {
402
+ merged: [], kept: [], unrecorded: [], lacking: {}, retained: [], spared: this.spared,
403
+ }
389
404
  const conflicts: Conflict[] = []
390
405
  const writes: [string, Buffer][] = []
391
406
  const bases = new Map<string, Buffer>()
@@ -422,7 +437,21 @@ class CopyGuard {
422
437
 
423
438
  if (null != conflict && true === this.spec.keep) {
424
439
  outcome.kept.push(rel)
425
- bases.set(rel, incoming)
440
+
441
+ // Recording the incoming copy as a base would pass a stale copy off as
442
+ // a customization.
443
+ if ('nobase' === conflict.why) {
444
+ outcome.unrecorded.push(rel)
445
+ }
446
+ else {
447
+ bases.set(rel, incoming)
448
+ }
449
+
450
+ const names = isTypeScript(rel) ?
451
+ missingExports(incoming.toString('utf8'), local.toString('utf8')) : []
452
+ if (0 < names.length) {
453
+ outcome.lacking[rel] = names
454
+ }
426
455
  }
427
456
  else if (null != conflict) {
428
457
  conflicts.push(conflict)
@@ -447,6 +476,9 @@ class CopyGuard {
447
476
  }
448
477
 
449
478
  this.keepBases(bases)
479
+ if (0 < outcome.unrecorded.length) {
480
+ this.spec.forget?.(outcome.unrecorded)
481
+ }
450
482
  clearConflicts(this.spec)
451
483
  this.report(outcome)
452
484
 
@@ -534,17 +566,26 @@ class CopyGuard {
534
566
  }
535
567
 
536
568
  const shown = this.spec.conflictdir
569
+ const nobase = conflicts.filter((c: Conflict) => 'nobase' === c.why).length
537
570
 
538
571
  const msg = this.spec.what + ': ' + conflicts.length +
539
572
  ' locally changed file(s) cannot take the incoming copy, so nothing was changed:\n ' +
540
573
  conflicts.map((c: Conflict) => c.rel + ' (' + why[c.why] + ')').join('\n ') +
541
574
  '\n\n The incoming copies are in ' + shown + '/, with conflict markers where ' +
542
- 'both sides changed the same lines. Then either:' +
543
- '\n - fold the incoming change into the local file by hand and re-run with ' +
544
- '--keep, which keeps the local files and records the incoming copies as ' +
545
- 'their base;' +
546
- '\n - or re-run with --force, which takes the incoming copies and discards ' +
547
- 'the local changes.'
575
+ 'both sides changed the same lines. ' +
576
+ (0 < nobase ?
577
+ 'Nothing records what an add wrote to ' +
578
+ (nobase === conflicts.length ? 'them' : nobase + ' of them') +
579
+ ', so nothing shows whether they hold a local change or an older ' +
580
+ 'copy this update would replace, and --keep would leave them as they ' +
581
+ 'are, unrecorded. Commit, then re-run with --force, which takes the ' +
582
+ 'incoming copies; `git diff` then shows any local change to restore.' :
583
+ 'Then either:' +
584
+ '\n - fold the incoming change into the local file by hand and re-run with ' +
585
+ '--keep, which keeps the local files and records the incoming copies as ' +
586
+ 'their base;' +
587
+ '\n - or re-run with --force, which takes the incoming copies and discards ' +
588
+ 'the local changes.')
548
589
 
549
590
  return null == this.spec.error ? new Error(msg) : this.spec.error(msg)
550
591
  }
@@ -563,9 +604,16 @@ class CopyGuard {
563
604
 
564
605
  if (0 < outcome.kept.length) {
565
606
  log.warn({
566
- point: 'copy-merge-kept', files: outcome.kept,
607
+ point: 'copy-merge-kept', files: outcome.kept, unrecorded: outcome.unrecorded,
608
+ lacking: outcome.lacking,
567
609
  note: this.spec.what + ': --keep, kept ' + outcome.kept.length +
568
- ' local file(s) as they are: ' + outcome.kept.join(', ')
610
+ ' local file(s) as they are: ' + outcome.kept.join(', ') +
611
+ (0 === outcome.unrecorded.length ? '' :
612
+ '; nothing records what an add wrote to ' + outcome.unrecorded.join(', ') +
613
+ ', so they stay unrecorded until an add with --force replaces them') +
614
+ Object.entries(outcome.lacking).map(([rel, names]: [string, string[]]) =>
615
+ '; ' + rel + ' lacks ' + names.join(', ') + ', which the incoming copy ' +
616
+ 'exports').join('')
569
617
  })
570
618
  }
571
619
 
@@ -73,7 +73,6 @@ function definitionPlan(ctx$: any): DefinitionPoint[] {
73
73
  if (false === entity.active) continue
74
74
 
75
75
  for (const [op, operation] of Object.entries(entity.op || {}) as any[]) {
76
- // An inactive operation stays in the model but gets no method.
77
76
  if (false === operation?.active || !GENERATED_OPS.includes(op)) continue
78
77
 
79
78
  const points = (operation?.points || []).filter((p: any) => false !== p.a)
@@ -0,0 +1,174 @@
1
+ import Path from 'node:path'
2
+
3
+ import { claimedFiles } from './generated'
4
+
5
+
6
+ type DocFinding = {
7
+ point: 'doc-link-dangling' | 'doc-table-broken'
8
+ file: string
9
+ line: number
10
+ note: string
11
+ }
12
+
13
+
14
+ // GitHub's heading anchors, which is what a reader's browser follows.
15
+ function slug(heading: string): string {
16
+ return heading.trim().toLowerCase()
17
+ .replace(/`/g, '')
18
+ .replace(/[^\p{L}\p{N}\s_-]/gu, '')
19
+ .replace(/\s/g, '-')
20
+ }
21
+
22
+
23
+ function anchors(text: string): Set<string> {
24
+ const out = new Set<string>()
25
+ const seen = new Map<string, number>()
26
+ let fence = false
27
+ for (const line of text.split('\n')) {
28
+ if (/^\s*(```|~~~)/.test(line)) fence = !fence
29
+ if (fence) continue
30
+ const m = /^#{1,6}\s+(.*)$/.exec(line)
31
+ if (!m) continue
32
+ const s = slug(m[1])
33
+ const n = seen.get(s) ?? 0
34
+ out.add(0 === n ? s : s + '-' + n)
35
+ seen.set(s, n + 1)
36
+ }
37
+ return out
38
+ }
39
+
40
+
41
+ // The lines of a document outside its fenced blocks, numbered from one.
42
+ function prose(text: string): [number, string][] {
43
+ const out: [number, string][] = []
44
+ let fence = ''
45
+ text.split('\n').forEach((line, i) => {
46
+ const open = /^ {0,3}(`{3,}|~{3,})/.exec(line)
47
+ if (open && ('' === fence || open[1].startsWith(fence))) {
48
+ fence = '' === fence ? open[1] : ''
49
+ }
50
+ else if ('' === fence) {
51
+ out.push([i + 1, line])
52
+ }
53
+ })
54
+ return out
55
+ }
56
+
57
+
58
+ function cells(row: string): number {
59
+ return (row.trim().match(/(?<!\\)\|/g) || []).length
60
+ }
61
+
62
+
63
+ const DELIMITER = /^\s*\|?\s*:?-{3,}:?\s*(\|\s*:?-{3,}:?\s*)*\|?\s*$/
64
+
65
+ // Each row of a table ends as its header ends and holds as many cells; a
66
+ // row with no header before it is the second half of a row a line break cut.
67
+ function tables(file: string, text: string): DocFinding[] {
68
+ const out: DocFinding[] = []
69
+ const lines = prose(text)
70
+ let header: string | null = null
71
+ for (let i = 0; i < lines.length; i++) {
72
+ const [num, line] = lines[i]
73
+ if (!/^ {0,3}\|/.test(line)) {
74
+ header = null
75
+ }
76
+ else if (null == header) {
77
+ if (DELIMITER.test(lines[i + 1]?.[1] ?? '')) {
78
+ header = line
79
+ i++
80
+ }
81
+ else {
82
+ out.push({ point: 'doc-table-broken', file, line: num, note: 'a row outside a table: ' + line })
83
+ }
84
+ }
85
+ else if (cells(line) !== cells(header) ||
86
+ line.trim().endsWith('|') !== header.trim().endsWith('|')) {
87
+ out.push({ point: 'doc-table-broken', file, line: num, note: line })
88
+ }
89
+ }
90
+ return out
91
+ }
92
+
93
+
94
+ // A malformed escape such as `100%.md` is a path as written, as a browser reads it.
95
+ function decoded(rel: string): string {
96
+ try {
97
+ return decodeURI(rel)
98
+ }
99
+ catch (_err) {
100
+ return rel
101
+ }
102
+ }
103
+
104
+
105
+ function links(file: string, text: string, docs: Map<string, string>,
106
+ exists: (rel: string) => boolean): DocFinding[] {
107
+ const out: DocFinding[] = []
108
+ const dir = Path.posix.dirname(file)
109
+ for (const [num, line] of prose(text)) {
110
+ const bare = line.replace(/(`+)[^`][\s\S]*?\1/g, '')
111
+ for (const m of bare.matchAll(/\]\(<?([^)\s>]+)>?(?:\s+"[^"]*")?\)/g)) {
112
+ const href = m[1]
113
+ if (/^[a-z][a-z0-9+.-]*:/i.test(href) || href.startsWith('/')) continue
114
+ const [rel, frag] = href.split('#')
115
+ const target = '' === rel ? file : Path.posix.normalize(Path.posix.join(dir, decoded(rel)))
116
+ if ('' !== rel && !exists(target)) {
117
+ out.push({ point: 'doc-link-dangling', file, line: num, note: target })
118
+ }
119
+ else if (null != frag && '' !== frag && docs.has(target) && !anchors(docs.get(target)!).has(frag)) {
120
+ out.push({ point: 'doc-link-dangling', file, line: num, note: target + '#' + frag })
121
+ }
122
+ }
123
+ }
124
+ return out
125
+ }
126
+
127
+
128
+ function walk(node: any, visit: (node: any) => void): void {
129
+ if (null == node) return
130
+ visit(node)
131
+ for (const child of node.children ?? []) walk(child, visit)
132
+ }
133
+
134
+
135
+ // Every Markdown file a pass kept, checked against what the pass wrote and
136
+ // what is already in `folder`: a relative link that resolves nowhere, and a
137
+ // table row that a line break or a pipe has broken. A dry run copies nothing,
138
+ // so there a path under a copy's destination counts as written.
139
+ function docFindings(root: any, folder: string, onDisk: (path: string) => boolean,
140
+ dryrun = false): DocFinding[] {
141
+ const rel = (full: string) =>
142
+ Path.relative(Path.resolve(folder), Path.resolve(full)).split(Path.sep).join('/')
143
+ const claims = claimedFiles(root, folder)
144
+ const written = new Set<string>(Object.keys(claims.files).map(rel))
145
+ const copied = claims.copies.map((c: any) => rel(c.to))
146
+
147
+ const docs = new Map<string, string>()
148
+ walk(root, (node: any) => {
149
+ if ('file' === node.kind && 'string' === typeof node.fullpath && node.fullpath.endsWith('.md') &&
150
+ Array.isArray(node.content)) {
151
+ docs.set(rel(node.fullpath), node.content.join(''))
152
+ }
153
+ })
154
+
155
+ const exists = (path: string): boolean => written.has(path) ||
156
+ [...written].some((p) => p.startsWith(path + '/')) ||
157
+ (dryrun && copied.some((c) => path === c || path.startsWith(c + '/'))) ||
158
+ onDisk(Path.join(folder, path))
159
+
160
+ const out: DocFinding[] = []
161
+ for (const [file, text] of docs) {
162
+ out.push(...tables(file, text), ...links(file, text, docs, exists))
163
+ }
164
+ return out
165
+ }
166
+
167
+
168
+ export {
169
+ anchors,
170
+ docFindings,
171
+ slug,
172
+ }
173
+
174
+ export type { DocFinding }