@voxgig/sdkgen 1.2.1 → 1.3.2

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 (345) hide show
  1. package/bin/voxgig-sdkgen +2 -2
  2. package/dist/action/action.d.ts +3 -1
  3. package/dist/action/action.js +26 -10
  4. package/dist/action/action.js.map +1 -1
  5. package/dist/action/feature.js +9 -8
  6. package/dist/action/feature.js.map +1 -1
  7. package/dist/action/target.d.ts +7 -1
  8. package/dist/action/target.js +22 -13
  9. package/dist/action/target.js.map +1 -1
  10. package/dist/cmp/Changelog.d.ts +2 -0
  11. package/dist/cmp/Changelog.js +30 -0
  12. package/dist/cmp/Changelog.js.map +1 -0
  13. package/dist/cmp/Deploy.d.ts +2 -0
  14. package/dist/cmp/Deploy.js +227 -0
  15. package/dist/cmp/Deploy.js.map +1 -0
  16. package/dist/cmp/FeatureHook.js +5 -6
  17. package/dist/cmp/FeatureHook.js.map +1 -1
  18. package/dist/cmp/License.d.ts +2 -0
  19. package/dist/cmp/License.js +44 -0
  20. package/dist/cmp/License.js.map +1 -0
  21. package/dist/cmp/Readme.js +2 -0
  22. package/dist/cmp/Readme.js.map +1 -1
  23. package/dist/cmp/ReadmeErrors.d.ts +2 -0
  24. package/dist/cmp/ReadmeErrors.js +210 -0
  25. package/dist/cmp/ReadmeErrors.js.map +1 -0
  26. package/dist/cmp/ReadmeExplanation.js +213 -223
  27. package/dist/cmp/ReadmeExplanation.js.map +1 -1
  28. package/dist/cmp/ReadmeModel.js +6 -1
  29. package/dist/cmp/ReadmeModel.js.map +1 -1
  30. package/dist/cmp/ReadmeTop.js +389 -82
  31. package/dist/cmp/ReadmeTop.js.map +1 -1
  32. package/dist/cmp/Security.d.ts +2 -0
  33. package/dist/cmp/Security.js +36 -0
  34. package/dist/cmp/Security.js.map +1 -0
  35. package/dist/helpers/canonType.d.ts +7 -0
  36. package/dist/helpers/canonType.js +74 -0
  37. package/dist/helpers/canonType.js.map +1 -0
  38. package/dist/helpers/collectDeps.d.ts +3 -2
  39. package/dist/helpers/collectDeps.js.map +1 -1
  40. package/dist/helpers/naming.d.ts +3 -0
  41. package/dist/helpers/naming.js +51 -0
  42. package/dist/helpers/naming.js.map +1 -0
  43. package/dist/helpers/opExample.d.ts +13 -0
  44. package/dist/helpers/opExample.js +149 -0
  45. package/dist/helpers/opExample.js.map +1 -0
  46. package/dist/helpers/opShape.d.ts +18 -0
  47. package/dist/helpers/opShape.js +225 -0
  48. package/dist/helpers/opShape.js.map +1 -0
  49. package/dist/helpers/packageMeta.d.ts +27 -0
  50. package/dist/helpers/packageMeta.js +224 -0
  51. package/dist/helpers/packageMeta.js.map +1 -0
  52. package/dist/sdkgen.d.ts +12 -2
  53. package/dist/sdkgen.js +60 -20
  54. package/dist/sdkgen.js.map +1 -1
  55. package/dist/tsconfig.tsbuildinfo +1 -1
  56. package/dist/types.d.ts +65 -2
  57. package/dist/types.js.map +1 -1
  58. package/dist/utility.d.ts +2 -1
  59. package/dist/utility.js +39 -11
  60. package/dist/utility.js.map +1 -1
  61. package/model/sdkgen.aontu +137 -0
  62. package/package.json +11 -5
  63. package/project/.sdk/model/feature/feature-index.aontu +5 -0
  64. package/project/.sdk/model/target/go-cli.aontu +47 -0
  65. package/project/.sdk/model/target/go-mcp.aontu +41 -0
  66. package/project/.sdk/model/target/go.aontu +28 -0
  67. package/project/.sdk/model/target/{js.jsonic → js.aontu} +13 -0
  68. package/project/.sdk/model/target/{lua.jsonic → lua.aontu} +13 -0
  69. package/project/.sdk/model/target/{php.jsonic → php.aontu} +13 -0
  70. package/project/.sdk/model/target/{py.jsonic → py.aontu} +13 -0
  71. package/project/.sdk/model/target/{rb.jsonic → rb.aontu} +13 -0
  72. package/project/.sdk/model/target/{ts.jsonic → ts.aontu} +13 -0
  73. package/project/.sdk/src/cmp/go/Config_go.ts +3 -2
  74. package/project/.sdk/src/cmp/go/EntityOperation_go.ts +1 -0
  75. package/project/.sdk/src/cmp/go/EntityTypes_go.ts +197 -0
  76. package/project/.sdk/src/cmp/go/Entity_go.ts +2 -1
  77. package/project/.sdk/src/cmp/go/MainEntity_go.ts +6 -0
  78. package/project/.sdk/src/cmp/go/Main_go.ts +23 -3
  79. package/project/.sdk/src/cmp/go/Package_go.ts +1 -1
  80. package/project/.sdk/src/cmp/go/ReadmeEntity_go.ts +48 -10
  81. package/project/.sdk/src/cmp/go/ReadmeExamplesTest_go.ts +688 -0
  82. package/project/.sdk/src/cmp/go/ReadmeExplanation_go.ts +1 -1
  83. package/project/.sdk/src/cmp/go/ReadmeHowto_go.ts +52 -8
  84. package/project/.sdk/src/cmp/go/ReadmeInstall_go.ts +11 -6
  85. package/project/.sdk/src/cmp/go/ReadmeIntro_go.ts +40 -1
  86. package/project/.sdk/src/cmp/go/ReadmeModel_go.ts +67 -17
  87. package/project/.sdk/src/cmp/go/ReadmeOptions_go.ts +4 -3
  88. package/project/.sdk/src/cmp/go/ReadmeQuick_go.ts +146 -116
  89. package/project/.sdk/src/cmp/go/ReadmeRef_go.ts +87 -21
  90. package/project/.sdk/src/cmp/go/ReadmeTopHowto_go.ts +4 -0
  91. package/project/.sdk/src/cmp/go/ReadmeTopQuick_go.ts +75 -16
  92. package/project/.sdk/src/cmp/go/ReadmeTopTest_go.ts +35 -5
  93. package/project/.sdk/src/cmp/go/TestEntity_go.ts +1 -1
  94. package/project/.sdk/src/cmp/go/Test_go.ts +5 -1
  95. package/project/.sdk/src/cmp/go/fragment/Entity.fragment.go +21 -0
  96. package/project/.sdk/src/cmp/go/fragment/EntityCreateOp.fragment.go +11 -0
  97. package/project/.sdk/src/cmp/go/fragment/EntityListOp.fragment.go +11 -0
  98. package/project/.sdk/src/cmp/go/fragment/EntityLoadOp.fragment.go +11 -0
  99. package/project/.sdk/src/cmp/go/fragment/EntityRemoveOp.fragment.go +11 -0
  100. package/project/.sdk/src/cmp/go/fragment/EntityUpdateOp.fragment.go +11 -0
  101. package/project/.sdk/src/cmp/go/utility_go.ts +70 -0
  102. package/project/.sdk/src/cmp/go-cli/Main_go-cli.ts +195 -0
  103. package/project/.sdk/src/cmp/go-cli/fragment/main.fragment.go +106 -0
  104. package/project/.sdk/src/cmp/go-cli/fragment/words.fragment.go +132 -0
  105. package/project/.sdk/src/cmp/go-mcp/Main_go-mcp.ts +184 -0
  106. package/project/.sdk/src/cmp/go-mcp/fragment/main.fragment.go +68 -0
  107. package/project/.sdk/src/cmp/go-mcp/fragment/tools.fragment.go +114 -0
  108. package/project/.sdk/src/cmp/js/Config_js.ts +3 -6
  109. package/project/.sdk/src/cmp/js/EntityTypes_js.ts +111 -0
  110. package/project/.sdk/src/cmp/js/MainEntity_js.ts +1 -0
  111. package/project/.sdk/src/cmp/js/Main_js.ts +3 -0
  112. package/project/.sdk/src/cmp/js/Package_js.ts +16 -7
  113. package/project/.sdk/src/cmp/js/ReadmeEntity_js.ts +33 -10
  114. package/project/.sdk/src/cmp/js/ReadmeExplanation_js.ts +2 -2
  115. package/project/.sdk/src/cmp/js/ReadmeHowto_js.ts +52 -11
  116. package/project/.sdk/src/cmp/js/ReadmeIntro_js.ts +39 -1
  117. package/project/.sdk/src/cmp/js/ReadmeModel_js.ts +50 -18
  118. package/project/.sdk/src/cmp/js/ReadmeOptions_js.ts +4 -3
  119. package/project/.sdk/src/cmp/js/ReadmeQuick_js.ts +70 -20
  120. package/project/.sdk/src/cmp/js/ReadmeRef_js.ts +50 -16
  121. package/project/.sdk/src/cmp/js/ReadmeTopHowto_js.ts +3 -0
  122. package/project/.sdk/src/cmp/js/ReadmeTopQuick_js.ts +45 -19
  123. package/project/.sdk/src/cmp/js/ReadmeTopTest_js.ts +35 -3
  124. package/project/.sdk/src/cmp/js/fragment/EntityCreateOp.fragment.js +5 -0
  125. package/project/.sdk/src/cmp/js/fragment/EntityListOp.fragment.js +5 -0
  126. package/project/.sdk/src/cmp/js/fragment/EntityLoadOp.fragment.js +5 -0
  127. package/project/.sdk/src/cmp/js/fragment/EntityRemoveOp.fragment.js +5 -0
  128. package/project/.sdk/src/cmp/js/fragment/EntityUpdateOp.fragment.js +5 -0
  129. package/project/.sdk/src/cmp/js/utility_js.ts +57 -0
  130. package/project/.sdk/src/cmp/lua/Config_lua.ts +3 -2
  131. package/project/.sdk/src/cmp/lua/EntityTypes_lua.ts +113 -0
  132. package/project/.sdk/src/cmp/lua/MainEntity_lua.ts +8 -0
  133. package/project/.sdk/src/cmp/lua/Main_lua.ts +4 -0
  134. package/project/.sdk/src/cmp/lua/Package_lua.ts +23 -4
  135. package/project/.sdk/src/cmp/lua/ReadmeEntity_lua.ts +50 -13
  136. package/project/.sdk/src/cmp/lua/ReadmeExamplesTest_lua.ts +293 -0
  137. package/project/.sdk/src/cmp/lua/ReadmeHowto_lua.ts +46 -8
  138. package/project/.sdk/src/cmp/lua/ReadmeInstall_lua.ts +19 -3
  139. package/project/.sdk/src/cmp/lua/ReadmeIntro_lua.ts +38 -1
  140. package/project/.sdk/src/cmp/lua/ReadmeModel_lua.ts +51 -16
  141. package/project/.sdk/src/cmp/lua/ReadmeOptions_lua.ts +4 -3
  142. package/project/.sdk/src/cmp/lua/ReadmeQuick_lua.ts +156 -21
  143. package/project/.sdk/src/cmp/lua/ReadmeRef_lua.ts +71 -23
  144. package/project/.sdk/src/cmp/lua/ReadmeTopQuick_lua.ts +46 -9
  145. package/project/.sdk/src/cmp/lua/ReadmeTopTest_lua.ts +43 -5
  146. package/project/.sdk/src/cmp/lua/Test_lua.ts +4 -0
  147. package/project/.sdk/src/cmp/lua/fragment/EntityCreateOp.fragment.lua +4 -0
  148. package/project/.sdk/src/cmp/lua/fragment/EntityListOp.fragment.lua +4 -0
  149. package/project/.sdk/src/cmp/lua/fragment/EntityLoadOp.fragment.lua +4 -0
  150. package/project/.sdk/src/cmp/lua/fragment/EntityRemoveOp.fragment.lua +4 -0
  151. package/project/.sdk/src/cmp/lua/fragment/EntityUpdateOp.fragment.lua +4 -0
  152. package/project/.sdk/src/cmp/php/Config_php.ts +3 -2
  153. package/project/.sdk/src/cmp/php/EntityTypes_php.ts +142 -0
  154. package/project/.sdk/src/cmp/php/MainEntity_php.ts +18 -1
  155. package/project/.sdk/src/cmp/php/Main_php.ts +4 -0
  156. package/project/.sdk/src/cmp/php/Package_php.ts +18 -7
  157. package/project/.sdk/src/cmp/php/ReadmeEntity_php.ts +46 -14
  158. package/project/.sdk/src/cmp/php/ReadmeExamplesTest_php.ts +401 -0
  159. package/project/.sdk/src/cmp/php/ReadmeHowto_php.ts +56 -13
  160. package/project/.sdk/src/cmp/php/ReadmeInstall_php.ts +15 -3
  161. package/project/.sdk/src/cmp/php/ReadmeIntro_php.ts +40 -1
  162. package/project/.sdk/src/cmp/php/ReadmeModel_php.ts +26 -8
  163. package/project/.sdk/src/cmp/php/ReadmeOptions_php.ts +4 -3
  164. package/project/.sdk/src/cmp/php/ReadmeQuick_php.ts +159 -25
  165. package/project/.sdk/src/cmp/php/ReadmeRef_php.ts +90 -45
  166. package/project/.sdk/src/cmp/php/ReadmeTopHowto_php.ts +1 -1
  167. package/project/.sdk/src/cmp/php/ReadmeTopQuick_php.ts +43 -11
  168. package/project/.sdk/src/cmp/php/ReadmeTopTest_php.ts +52 -11
  169. package/project/.sdk/src/cmp/php/TestDirect_php.ts +9 -9
  170. package/project/.sdk/src/cmp/php/TestEntity_php.ts +6 -12
  171. package/project/.sdk/src/cmp/php/Test_php.ts +4 -0
  172. package/project/.sdk/src/cmp/php/fragment/Entity.fragment.php +13 -1
  173. package/project/.sdk/src/cmp/php/fragment/EntityCreateOp.fragment.php +10 -1
  174. package/project/.sdk/src/cmp/php/fragment/EntityListOp.fragment.php +10 -1
  175. package/project/.sdk/src/cmp/php/fragment/EntityLoadOp.fragment.php +10 -1
  176. package/project/.sdk/src/cmp/php/fragment/EntityRemoveOp.fragment.php +10 -1
  177. package/project/.sdk/src/cmp/php/fragment/EntityUpdateOp.fragment.php +10 -1
  178. package/project/.sdk/src/cmp/php/fragment/Main.fragment.php +22 -14
  179. package/project/.sdk/src/cmp/py/Config_py.ts +3 -2
  180. package/project/.sdk/src/cmp/py/EntityTypes_py.ts +184 -0
  181. package/project/.sdk/src/cmp/py/Entity_py.ts +27 -0
  182. package/project/.sdk/src/cmp/py/MainEntity_py.ts +2 -1
  183. package/project/.sdk/src/cmp/py/Main_py.ts +35 -0
  184. package/project/.sdk/src/cmp/py/Package_py.ts +24 -3
  185. package/project/.sdk/src/cmp/py/ReadmeEntity_py.ts +48 -14
  186. package/project/.sdk/src/cmp/py/ReadmeExamplesTest_py.ts +626 -0
  187. package/project/.sdk/src/cmp/py/ReadmeHowto_py.ts +53 -14
  188. package/project/.sdk/src/cmp/py/ReadmeInstall_py.ts +19 -3
  189. package/project/.sdk/src/cmp/py/ReadmeIntro_py.ts +48 -1
  190. package/project/.sdk/src/cmp/py/ReadmeModel_py.ts +28 -10
  191. package/project/.sdk/src/cmp/py/ReadmeOptions_py.ts +4 -3
  192. package/project/.sdk/src/cmp/py/ReadmeQuick_py.ts +150 -27
  193. package/project/.sdk/src/cmp/py/ReadmeRef_py.ts +86 -40
  194. package/project/.sdk/src/cmp/py/ReadmeTopHowto_py.ts +1 -1
  195. package/project/.sdk/src/cmp/py/ReadmeTopQuick_py.ts +45 -11
  196. package/project/.sdk/src/cmp/py/ReadmeTopTest_py.ts +43 -5
  197. package/project/.sdk/src/cmp/py/TestDirect_py.ts +7 -9
  198. package/project/.sdk/src/cmp/py/TestEntity_py.ts +6 -14
  199. package/project/.sdk/src/cmp/py/Test_py.ts +4 -0
  200. package/project/.sdk/src/cmp/py/fragment/Entity.fragment.py +5 -2
  201. package/project/.sdk/src/cmp/py/fragment/EntityCreateOp.fragment.py +1 -1
  202. package/project/.sdk/src/cmp/py/fragment/EntityListOp.fragment.py +5 -1
  203. package/project/.sdk/src/cmp/py/fragment/EntityLoadOp.fragment.py +6 -1
  204. package/project/.sdk/src/cmp/py/fragment/EntityRemoveOp.fragment.py +6 -1
  205. package/project/.sdk/src/cmp/py/fragment/EntityUpdateOp.fragment.py +1 -1
  206. package/project/.sdk/src/cmp/py/fragment/Main.fragment.py +17 -10
  207. package/project/.sdk/src/cmp/rb/Config_rb.ts +3 -2
  208. package/project/.sdk/src/cmp/rb/EntityTypes_rb.ts +136 -0
  209. package/project/.sdk/src/cmp/rb/MainEntity_rb.ts +1 -0
  210. package/project/.sdk/src/cmp/rb/Main_rb.ts +4 -0
  211. package/project/.sdk/src/cmp/rb/Package_rb.ts +34 -7
  212. package/project/.sdk/src/cmp/rb/ReadmeEntity_rb.ts +47 -13
  213. package/project/.sdk/src/cmp/rb/ReadmeExamplesTest_rb.ts +289 -0
  214. package/project/.sdk/src/cmp/rb/ReadmeHowto_rb.ts +72 -21
  215. package/project/.sdk/src/cmp/rb/ReadmeInstall_rb.ts +16 -4
  216. package/project/.sdk/src/cmp/rb/ReadmeIntro_rb.ts +40 -1
  217. package/project/.sdk/src/cmp/rb/ReadmeModel_rb.ts +29 -12
  218. package/project/.sdk/src/cmp/rb/ReadmeOptions_rb.ts +4 -3
  219. package/project/.sdk/src/cmp/rb/ReadmeQuick_rb.ts +163 -25
  220. package/project/.sdk/src/cmp/rb/ReadmeRef_rb.ts +85 -40
  221. package/project/.sdk/src/cmp/rb/ReadmeTopHowto_rb.ts +1 -1
  222. package/project/.sdk/src/cmp/rb/ReadmeTopQuick_rb.ts +45 -11
  223. package/project/.sdk/src/cmp/rb/ReadmeTopTest_rb.ts +54 -11
  224. package/project/.sdk/src/cmp/rb/TestDirect_rb.ts +9 -9
  225. package/project/.sdk/src/cmp/rb/TestEntity_rb.ts +6 -12
  226. package/project/.sdk/src/cmp/rb/Test_rb.ts +4 -0
  227. package/project/.sdk/src/cmp/rb/fragment/Entity.fragment.rb +2 -0
  228. package/project/.sdk/src/cmp/rb/fragment/EntityCreateOp.fragment.rb +5 -0
  229. package/project/.sdk/src/cmp/rb/fragment/EntityListOp.fragment.rb +20 -2
  230. package/project/.sdk/src/cmp/rb/fragment/EntityLoadOp.fragment.rb +8 -1
  231. package/project/.sdk/src/cmp/rb/fragment/EntityRemoveOp.fragment.rb +6 -1
  232. package/project/.sdk/src/cmp/rb/fragment/EntityUpdateOp.fragment.rb +5 -0
  233. package/project/.sdk/src/cmp/rb/fragment/Main.fragment.rb +24 -8
  234. package/project/.sdk/src/cmp/ts/Config_ts.ts +3 -6
  235. package/project/.sdk/src/cmp/ts/EntityTypes_ts.ts +105 -0
  236. package/project/.sdk/src/cmp/ts/Entity_ts.ts +17 -1
  237. package/project/.sdk/src/cmp/ts/MainEntity_ts.ts +1 -0
  238. package/project/.sdk/src/cmp/ts/Main_ts.ts +6 -0
  239. package/project/.sdk/src/cmp/ts/Package_ts.ts +14 -7
  240. package/project/.sdk/src/cmp/ts/ReadmeEntity_ts.ts +32 -10
  241. package/project/.sdk/src/cmp/ts/ReadmeExampleTest_ts.ts +81 -0
  242. package/project/.sdk/src/cmp/ts/ReadmeExamplesTest_ts.ts +446 -0
  243. package/project/.sdk/src/cmp/ts/ReadmeExplanation_ts.ts +2 -2
  244. package/project/.sdk/src/cmp/ts/ReadmeHowto_ts.ts +57 -11
  245. package/project/.sdk/src/cmp/ts/ReadmeInstall_ts.ts +19 -6
  246. package/project/.sdk/src/cmp/ts/ReadmeIntro_ts.ts +39 -1
  247. package/project/.sdk/src/cmp/ts/ReadmeModel_ts.ts +50 -18
  248. package/project/.sdk/src/cmp/ts/ReadmeOptions_ts.ts +4 -3
  249. package/project/.sdk/src/cmp/ts/ReadmeQuick_ts.ts +141 -48
  250. package/project/.sdk/src/cmp/ts/ReadmeRef_ts.ts +50 -16
  251. package/project/.sdk/src/cmp/ts/ReadmeTopHowto_ts.ts +3 -0
  252. package/project/.sdk/src/cmp/ts/ReadmeTopQuick_ts.ts +58 -19
  253. package/project/.sdk/src/cmp/ts/ReadmeTopTest_ts.ts +35 -3
  254. package/project/.sdk/src/cmp/ts/TestEntity_ts.ts +2 -2
  255. package/project/.sdk/src/cmp/ts/Test_ts.ts +5 -0
  256. package/project/.sdk/src/cmp/ts/fragment/Entity.fragment.ts +3 -1
  257. package/project/.sdk/src/cmp/ts/fragment/EntityBase.fragment.ts +10 -5
  258. package/project/.sdk/src/cmp/ts/fragment/EntityCreateOp.fragment.ts +4 -2
  259. package/project/.sdk/src/cmp/ts/fragment/EntityListOp.fragment.ts +4 -2
  260. package/project/.sdk/src/cmp/ts/fragment/EntityLoadOp.fragment.ts +4 -2
  261. package/project/.sdk/src/cmp/ts/fragment/EntityRemoveOp.fragment.ts +4 -2
  262. package/project/.sdk/src/cmp/ts/fragment/EntityUpdateOp.fragment.ts +4 -2
  263. package/project/.sdk/src/cmp/ts/utility_ts.ts +59 -0
  264. package/project/.sdk/tm/go/LICENSE +1 -1
  265. package/project/.sdk/tm/go/Makefile +36 -1
  266. package/project/.sdk/tm/go/VERSION +1 -0
  267. package/project/.sdk/tm/go/core/context.go +12 -7
  268. package/project/.sdk/tm/go-cli/src/feature/README.md +6 -0
  269. package/project/.sdk/tm/go-cli/src/feature/base/.gitkeep +0 -0
  270. package/project/.sdk/tm/go-cli/src/feature/log/.gitkeep +0 -0
  271. package/project/.sdk/tm/go-cli/src/feature/test/.gitkeep +0 -0
  272. package/project/.sdk/tm/go-mcp/src/feature/README.md +6 -0
  273. package/project/.sdk/tm/go-mcp/src/feature/base/.gitkeep +0 -0
  274. package/project/.sdk/tm/go-mcp/src/feature/log/.gitkeep +0 -0
  275. package/project/.sdk/tm/go-mcp/src/feature/test/.gitkeep +0 -0
  276. package/project/.sdk/tm/js/LICENSE +1 -1
  277. package/project/.sdk/tm/js/Makefile +41 -0
  278. package/project/.sdk/tm/lua/LICENSE +1 -1
  279. package/project/.sdk/tm/lua/Makefile +40 -1
  280. package/project/.sdk/tm/lua/core/context.lua +13 -8
  281. package/project/.sdk/tm/php/LICENSE +1 -1
  282. package/project/.sdk/tm/php/Makefile +31 -1
  283. package/project/.sdk/tm/php/VERSION +1 -0
  284. package/project/.sdk/tm/php/core/Context.php +12 -6
  285. package/project/.sdk/tm/php/test/PrimaryUtilityTest.php +13 -4
  286. package/project/.sdk/tm/php/utility/Done.php +2 -2
  287. package/project/.sdk/tm/php/utility/MakeError.php +3 -3
  288. package/project/.sdk/tm/py/LICENSE +1 -1
  289. package/project/.sdk/tm/py/Makefile +34 -1
  290. package/project/.sdk/tm/py/core/context.py +12 -7
  291. package/project/.sdk/tm/py/test/test_primary_utility.py +15 -4
  292. package/project/.sdk/tm/py/test/test_struct_utility.py +1 -1
  293. package/project/.sdk/tm/py/utility/done.py +3 -1
  294. package/project/.sdk/tm/py/utility/make_error.py +2 -2
  295. package/project/.sdk/tm/rb/LICENSE +1 -1
  296. package/project/.sdk/tm/rb/Makefile +36 -2
  297. package/project/.sdk/tm/rb/core/context.rb +8 -3
  298. package/project/.sdk/tm/rb/test/primary_utility_test.rb +2 -2
  299. package/project/.sdk/tm/rb/utility/done.rb +3 -1
  300. package/project/.sdk/tm/rb/utility/make_error.rb +5 -2
  301. package/project/.sdk/tm/ts/LICENSE +1 -1
  302. package/project/.sdk/tm/ts/Makefile +42 -0
  303. package/project/.sdk/tm/ts/src/Context.ts +8 -3
  304. package/src/action/action.ts +30 -11
  305. package/src/action/feature.ts +12 -14
  306. package/src/action/target.ts +28 -17
  307. package/src/cmp/Changelog.ts +34 -0
  308. package/src/cmp/Deploy.ts +258 -0
  309. package/src/cmp/FeatureHook.ts +6 -8
  310. package/src/cmp/License.ts +49 -0
  311. package/src/cmp/Readme.ts +2 -0
  312. package/src/cmp/ReadmeErrors.ts +257 -0
  313. package/src/cmp/ReadmeExplanation.ts +250 -230
  314. package/src/cmp/ReadmeModel.ts +7 -2
  315. package/src/cmp/ReadmeTop.ts +411 -95
  316. package/src/cmp/Security.ts +41 -0
  317. package/src/helpers/canonType.ts +89 -0
  318. package/src/helpers/collectDeps.ts +5 -3
  319. package/src/helpers/naming.ts +59 -0
  320. package/src/helpers/opExample.ts +170 -0
  321. package/src/helpers/opShape.ts +274 -0
  322. package/src/helpers/packageMeta.ts +236 -0
  323. package/src/sdkgen.ts +91 -23
  324. package/src/tsconfig.json +1 -0
  325. package/src/types.ts +85 -2
  326. package/src/utility.ts +45 -11
  327. package/README.md +0 -2
  328. package/dist/action/lang.d.ts +0 -2
  329. package/dist/action/lang.js +0 -68
  330. package/dist/action/lang.js.map +0 -1
  331. package/dist/cmp/Hook.d.ts +0 -2
  332. package/dist/cmp/Hook.js +0 -10
  333. package/dist/cmp/Hook.js.map +0 -1
  334. package/dist/cmp/Top.d.ts +0 -2
  335. package/dist/cmp/Top.js +0 -23
  336. package/dist/cmp/Top.js.map +0 -1
  337. package/dist/prepare-openapi.d.ts +0 -2
  338. package/dist/prepare-openapi.js +0 -37
  339. package/dist/prepare-openapi.js.map +0 -1
  340. package/model/sdkgen.jsonic +0 -74
  341. package/project/.sdk/model/feature/feature-index.jsonic +0 -5
  342. package/project/.sdk/model/target/go.jsonic +0 -22
  343. package/project/.sdk/tm/go/utility/struct/go.mod +0 -3
  344. /package/project/.sdk/model/feature/{log.jsonic → log.aontu} +0 -0
  345. /package/project/.sdk/model/feature/{test.jsonic → test.aontu} +0 -0
@@ -0,0 +1,688 @@
1
+ import { cmp, Content, File } from '@voxgig/sdkgen'
2
+
3
+ import {
4
+ KIT,
5
+ getModelPath,
6
+ } from '@voxgig/apidef'
7
+
8
+
9
+ // Emits go/test/readme_examples_test.go — a COMPLETENESS GATE over every
10
+ // ```go block in ALL THREE docs that ship go examples:
11
+ // - the root README.md (top-level, multi-language quick start)
12
+ // - the per-language go/README.md
13
+ // - the per-language go/REFERENCE.md
14
+ //
15
+ // For every ```go block, tagged by (source doc, index), it exercises the
16
+ // block against the real generated SDK:
17
+ //
18
+ // - Fragments (statement snippets) are wrapped in a function with a SEEDED
19
+ // test-mode `client` in scope and `go build`-checked. Any stray `import`
20
+ // line inside the fragment is stripped and constructor calls are rewritten
21
+ // to the seeded test client (so undefined-variable placeholders like
22
+ // sdk.TestSDK(testopts, sdkopts) still type-check). A call to a method
23
+ // that does not exist, a wrong argument count/type, or `.data`/`.ok` field
24
+ // access on a bare entity-op result fails to compile — and so fails.
25
+ // - Complete programs (a block with `func main`) are built as-is (the
26
+ // documented, possibly live, form must compile) AND a test-mode variant —
27
+ // its constructor rewritten to a seeded `sdk.TestSDK(...)` — is RUN with
28
+ // `go run`. A genuine runtime panic (nil pointer, nil map, index,
29
+ // interface conversion) FAILS the test; a tolerated not-found domain
30
+ // error does not.
31
+ // - Illustrative blocks are the ONLY blocks skipped, and the class is
32
+ // NARROW: a bare signature (a `func` line with no body) or a comment-only
33
+ // / `/* ... */` placeholder. Everything else must compile or run.
34
+ //
35
+ // Completeness: per doc, total == compiled + illustration is asserted. A block
36
+ // that is neither compiled nor a recognized illustration — e.g. real code
37
+ // hidden behind a `/* ... */` comment that the old logic silently skipped —
38
+ // FAILS the gate, so no compilable example can escape the check.
39
+ const ReadmeExamplesTest = cmp(function ReadmeExamplesTest(props: any) {
40
+ const { ctx$: { model } } = props
41
+
42
+ // Seed a test-mode fixture for every active entity. Complete-program
43
+ // examples load by "example_id", so seed that record for each entity; the
44
+ // offline mock then returns it instead of 404-ing.
45
+ const entity = getModelPath(model, `main.${KIT}.entity`) || {}
46
+ const entnames = Object.values(entity)
47
+ .filter((e: any) => e && e.active !== false)
48
+ .map((e: any) => e.name)
49
+
50
+ const goSeedEntries = entnames
51
+ .map((n: string) =>
52
+ `"${n}": map[string]any{"example_id": map[string]any{"id": "example_id"}}`)
53
+ .join(', ')
54
+ const goSeed = `map[string]any{"entity": map[string]any{${goSeedEntries}}}`
55
+
56
+ File({ name: 'readme_examples_test.go' }, () => {
57
+ Content(`package sdktest
58
+
59
+ import (
60
+ "fmt"
61
+ "os"
62
+ "os/exec"
63
+ "path/filepath"
64
+ "runtime"
65
+ "strconv"
66
+ "strings"
67
+ "testing"
68
+ )
69
+
70
+ // testSeed is a test-mode fixture seeded for every entity. It is spliced as
71
+ // literal Go source into fragment wrappers and into the test-mode variant of
72
+ // complete programs, so the offline mock transport has data to return.
73
+ const testSeed = \`${goSeed}\`
74
+
75
+ // doc names one of the three docs that carry go examples, with its path
76
+ // relative to this test file's directory (which is <repo>/go/test): the root
77
+ // README is two levels up, the go docs are one.
78
+ type doc struct {
79
+ label string
80
+ relpath string
81
+ }
82
+
83
+ // docStat accumulates the completeness bookkeeping for one doc.
84
+ type docStat struct {
85
+ total int
86
+ compiled int
87
+ illustration int
88
+ leaked []int
89
+ }
90
+
91
+ // TestReadmeGoSnippets is a completeness gate over every \`\`\`go fenced block
92
+ // in the root README.md, go/README.md, and go/REFERENCE.md. Fragments are
93
+ // \`go build\`-checked with a seeded test client injected; complete programs
94
+ // are built as-is and their test-mode variant is run with \`go run\`; and per
95
+ // doc, total == compiled + illustration is asserted.
96
+ func TestReadmeGoSnippets(t *testing.T) {
97
+ _, thisFile, _, _ := runtime.Caller(0)
98
+ testDir := filepath.Dir(thisFile)
99
+ moduleRoot := filepath.Dir(testDir)
100
+
101
+ modulePath := readModulePath(moduleRoot)
102
+ if modulePath == "" {
103
+ t.Fatal("could not read module path from go.mod")
104
+ }
105
+
106
+ docs := []doc{
107
+ {"root README", filepath.Join(testDir, "..", "..", "README.md")},
108
+ {"go/README", filepath.Join(testDir, "..", "README.md")},
109
+ {"go/REFERENCE", filepath.Join(testDir, "..", "REFERENCE.md")},
110
+ }
111
+
112
+ work, err := os.MkdirTemp(moduleRoot, "readmecheck-")
113
+ if err != nil {
114
+ t.Fatalf("mkdir temp: %v", err)
115
+ }
116
+ defer os.RemoveAll(work)
117
+ rel := filepath.Base(work)
118
+
119
+ binDir := filepath.Join(work, "bin")
120
+ if err := os.MkdirAll(binDir, 0o755); err != nil {
121
+ t.Fatal(err)
122
+ }
123
+
124
+ fragDir := filepath.Join(work, "frag")
125
+ fragFiles := map[string]string{}
126
+ var progDirs []string
127
+ var runDirs []string
128
+ progCount := 0
129
+
130
+ stats := make([]*docStat, len(docs))
131
+
132
+ for di, d := range docs {
133
+ src, err := os.ReadFile(d.relpath)
134
+ if err != nil {
135
+ t.Fatalf("%s not found at %s: %v", d.label, d.relpath, err)
136
+ }
137
+ blocks := extractFencedBlocks(string(src), "go")
138
+ if len(blocks) == 0 {
139
+ t.Fatalf("no go code blocks in %s", d.label)
140
+ }
141
+ st := &docStat{total: len(blocks)}
142
+ stats[di] = st
143
+
144
+ for bi, block := range blocks {
145
+ if isIllustration(block) {
146
+ st.illustration++
147
+ continue
148
+ }
149
+ if strings.Contains(block, "/*") {
150
+ // Real code hidden behind a block comment: neither a
151
+ // recognized illustration nor safely compilable as-is. Flag
152
+ // it so the completeness assertion catches a would-be
153
+ // silently-skipped example rather than dropping it.
154
+ st.leaked = append(st.leaked, bi+1)
155
+ continue
156
+ }
157
+ if strings.Contains(block, "func main") {
158
+ // The documented program (possibly using the live sdk.New)
159
+ // must compile as-is.
160
+ dir := filepath.Join(work, "prog"+strconv.Itoa(progCount))
161
+ if err := os.MkdirAll(dir, 0o755); err != nil {
162
+ t.Fatal(err)
163
+ }
164
+ if err := os.WriteFile(filepath.Join(dir, "main.go"), []byte(block), 0o644); err != nil {
165
+ t.Fatal(err)
166
+ }
167
+ progDirs = append(progDirs, "./"+rel+"/prog"+strconv.Itoa(progCount))
168
+
169
+ // A test-mode variant — constructor rewritten to a seeded
170
+ // sdk.TestSDK(...) — is run offline to prove the program runs.
171
+ if variant, ok := rewriteCtorsToTest(block); ok {
172
+ if !strings.Contains(variant, "os.") {
173
+ variant = removeImportLine(variant, "os")
174
+ }
175
+ runDir := filepath.Join(work, "run"+strconv.Itoa(progCount))
176
+ if err := os.MkdirAll(runDir, 0o755); err != nil {
177
+ t.Fatal(err)
178
+ }
179
+ if err := os.WriteFile(filepath.Join(runDir, "main.go"), []byte(variant), 0o644); err != nil {
180
+ t.Fatal(err)
181
+ }
182
+ runDirs = append(runDirs, "./"+rel+"/run"+strconv.Itoa(progCount))
183
+ }
184
+
185
+ progCount++
186
+ st.compiled++
187
+ continue
188
+ }
189
+ name := "snip" + strconv.Itoa(len(fragFiles))
190
+ fragFiles[name] = wrapFragment(name, block, modulePath)
191
+ st.compiled++
192
+ }
193
+ }
194
+
195
+ fragPkg := ""
196
+ if len(fragFiles) > 0 {
197
+ if err := os.MkdirAll(fragDir, 0o755); err != nil {
198
+ t.Fatal(err)
199
+ }
200
+ fragPkg = "./" + rel + "/frag"
201
+ }
202
+
203
+ if len(progDirs) == 0 && fragPkg == "" {
204
+ t.Fatal("no buildable go snippets across docs")
205
+ }
206
+
207
+ // Build. The Go compiler is the oracle for unused imports/vars in the
208
+ // wrapped fragments: blank them out and rebuild. Any OTHER error is a
209
+ // genuine snippet bug and fails the test. The loop is progress-based,
210
+ // not attempt-capped: \`-gcflags=-e\` lifts the compiler's 10-error cap so
211
+ // every error surfaces in one round, applyFixes repairs them all, and
212
+ // the loop continues while a round makes progress. It fails hard when no
213
+ // fix applies, and fails as non-converged when a round changes nothing
214
+ // in the build output (the fixes stopped helping).
215
+ var lastOut string
216
+ for {
217
+ for name, content := range fragFiles {
218
+ if err := os.WriteFile(filepath.Join(fragDir, name+".go"), []byte(content), 0o644); err != nil {
219
+ t.Fatal(err)
220
+ }
221
+ }
222
+ out, buildErr := runGoBuild(moduleRoot, binDir, progDirs, fragPkg)
223
+ if buildErr == nil {
224
+ break
225
+ }
226
+ if out == lastOut {
227
+ t.Fatalf("README go snippets did not converge to a clean build:\\n%s", out)
228
+ }
229
+ lastOut = out
230
+ if !applyFixes(out, fragFiles) {
231
+ t.Fatalf("README go snippet failed to compile:\\n%s", out)
232
+ }
233
+ }
234
+
235
+ // Everything compiled. Now RUN the test-mode variants of the complete
236
+ // programs and fail on a genuine runtime panic.
237
+ if fail := runProgs(moduleRoot, runDirs); fail != "" {
238
+ t.Fatal(fail)
239
+ }
240
+
241
+ // Completeness: every block in every doc is either compiled/run or a
242
+ // recognized (narrow) illustration. A leaked block or a count mismatch is
243
+ // a silently-untested example and fails the gate.
244
+ for di, d := range docs {
245
+ st := stats[di]
246
+ if len(st.leaked) > 0 {
247
+ t.Errorf("%s: go block(s) %v are neither compiled nor a "+
248
+ "recognized illustration (silently untested) — use // "+
249
+ "comments with real code, or a bare signature / /* ... */ "+
250
+ "placeholder", d.label, st.leaked)
251
+ }
252
+ if st.total != st.compiled+st.illustration {
253
+ t.Errorf("%s completeness: total %d != compiled %d + "+
254
+ "illustration %d", d.label, st.total, st.compiled,
255
+ st.illustration)
256
+ }
257
+ fmt.Printf("[readme-go] %s: total=%d compiled=%d illustration=%d\\n",
258
+ d.label, st.total, st.compiled, st.illustration)
259
+ }
260
+ }
261
+
262
+ // runProgs executes each test-mode program variant with \`go run\` and reports
263
+ // a genuine runtime panic (nil pointer / nil map / index / interface
264
+ // conversion). A tolerated not-found domain error (panic(err) on an offline
265
+ // fixture miss) is not a failure. A run-variant that fails to even compile is
266
+ // skipped — the documented program already passed the strict build check, so
267
+ // a rewrite artefact must not manufacture a false failure.
268
+ func runProgs(moduleRoot string, dirs []string) string {
269
+ runtimeSigs := []string{
270
+ "runtime error",
271
+ "invalid memory address",
272
+ "nil pointer dereference",
273
+ "index out of range",
274
+ "slice bounds out of range",
275
+ "interface conversion",
276
+ "assignment to entry in nil map",
277
+ }
278
+ for _, d := range dirs {
279
+ cmd := exec.Command("go", "run", d)
280
+ cmd.Dir = moduleRoot
281
+ out, err := cmd.CombinedOutput()
282
+ if err == nil {
283
+ continue
284
+ }
285
+ s := string(out)
286
+ if !strings.Contains(s, "panic:") {
287
+ // Did not run (compile artefact of the rewrite) — tolerate.
288
+ continue
289
+ }
290
+ for _, sig := range runtimeSigs {
291
+ if strings.Contains(s, sig) {
292
+ return "README go complete program panicked at runtime " +
293
+ "(nil / type bug in a documented call):\\n" + s
294
+ }
295
+ }
296
+ // Domain-error panic (e.g. offline fixture miss) — tolerated.
297
+ }
298
+ return ""
299
+ }
300
+
301
+ // rewriteCtorsToTest replaces every sdk.New.../sdk.Test... constructor call
302
+ // in src with a seeded test-mode client, so a documented (possibly live)
303
+ // program runs offline against the mock, and a fragment whose constructor
304
+ // takes undefined placeholder variables still type-checks. Single
305
+ // left-to-right pass with balanced-paren matching; returns the rewritten
306
+ // source and whether any replacement was made.
307
+ func rewriteCtorsToTest(src string) (string, bool) {
308
+ repl := "sdk.TestSDK(" + testSeed + ", nil)"
309
+ var b strings.Builder
310
+ changed := false
311
+ i := 0
312
+ for i < len(src) {
313
+ matched := ""
314
+ if strings.HasPrefix(src[i:], "sdk.New") {
315
+ matched = "sdk.New"
316
+ } else if strings.HasPrefix(src[i:], "sdk.Test") {
317
+ matched = "sdk.Test"
318
+ }
319
+ if matched == "" {
320
+ b.WriteByte(src[i])
321
+ i++
322
+ continue
323
+ }
324
+ // Consume the rest of the identifier (e.g. NewAdviceSlipSDK, TestSDK).
325
+ j := i + len(matched)
326
+ for j < len(src) && isIdentByte(src[j]) {
327
+ j++
328
+ }
329
+ if j >= len(src) || src[j] != '(' {
330
+ b.WriteString(src[i:j])
331
+ i = j
332
+ continue
333
+ }
334
+ // Scan the balanced ( ... ) argument list.
335
+ depth := 0
336
+ k := j
337
+ for k < len(src) {
338
+ switch src[k] {
339
+ case '(':
340
+ depth++
341
+ case ')':
342
+ depth--
343
+ }
344
+ k++
345
+ if depth == 0 {
346
+ break
347
+ }
348
+ }
349
+ b.WriteString(repl)
350
+ changed = true
351
+ i = k
352
+ }
353
+ return b.String(), changed
354
+ }
355
+
356
+ func isIdentByte(c byte) bool {
357
+ return c == '_' ||
358
+ (c >= 'a' && c <= 'z') ||
359
+ (c >= 'A' && c <= 'Z') ||
360
+ (c >= '0' && c <= '9')
361
+ }
362
+
363
+ // runGoBuild type-checks the fragment package with \`go build -gcflags=-e\`
364
+ // (a non-main package produces no output but is still fully type-checked —
365
+ // unlike \`go build -o dir/\`, which skips non-main packages — and \`-e\` lifts
366
+ // the compiler's 10-errors-per-package cap so EVERY unused-var/import error
367
+ // surfaces in a single round), and builds each complete program with
368
+ // \`-o binDir/\`. Any compile error from either is returned.
369
+ func runGoBuild(dir, binDir string, progDirs []string, fragPkg string) (string, error) {
370
+ var out strings.Builder
371
+ if fragPkg != "" {
372
+ cmd := exec.Command("go", "build", "-gcflags=-e", fragPkg)
373
+ cmd.Dir = dir
374
+ o, err := cmd.CombinedOutput()
375
+ out.Write(o)
376
+ if err != nil {
377
+ return out.String(), err
378
+ }
379
+ }
380
+ if len(progDirs) > 0 {
381
+ args := append([]string{"build", "-gcflags=-e", "-o", binDir + string(os.PathSeparator)}, progDirs...)
382
+ cmd := exec.Command("go", args...)
383
+ cmd.Dir = dir
384
+ o, err := cmd.CombinedOutput()
385
+ out.Write(o)
386
+ if err != nil {
387
+ return out.String(), err
388
+ }
389
+ }
390
+ return out.String(), nil
391
+ }
392
+
393
+ func extractFencedBlocks(md, lang string) []string {
394
+ var blocks []string
395
+ lines := strings.Split(md, "\\n")
396
+ open := "\`\`\`" + lang
397
+ inBlock := false
398
+ var cur []string
399
+ for _, line := range lines {
400
+ trimmed := strings.TrimSpace(line)
401
+ if !inBlock {
402
+ if trimmed == open {
403
+ inBlock = true
404
+ cur = nil
405
+ }
406
+ continue
407
+ }
408
+ if trimmed == "\`\`\`" {
409
+ blocks = append(blocks, strings.Join(cur, "\\n"))
410
+ inBlock = false
411
+ continue
412
+ }
413
+ cur = append(cur, line)
414
+ }
415
+ return blocks
416
+ }
417
+
418
+ // isIllustration is the NARROW class of blocks that are intentionally not
419
+ // compiled:
420
+ // - a bare signature: a top-level func line with no body;
421
+ // - a comment-only block: nothing remains after stripping // and /* */;
422
+ // - a /* ... */ value-slot placeholder: a fill-in-the-blank template such as
423
+ // "field": /* type */, that is deliberately not compilable.
424
+ // Every other block is compiled or run.
425
+ func isIllustration(block string) bool {
426
+ trimmed := strings.TrimSpace(block)
427
+ if strings.HasPrefix(trimmed, "func ") && !strings.Contains(block, "{") {
428
+ return true
429
+ }
430
+ if strings.TrimSpace(stripGoComments(block)) == "" {
431
+ return true
432
+ }
433
+ if hasPlaceholderComment(block) {
434
+ return true
435
+ }
436
+ return false
437
+ }
438
+
439
+ // hasPlaceholderComment reports whether the block uses a /* ... */ comment in a
440
+ // value slot — immediately after ':', '=', '(', '{' or ',' (ignoring spaces) —
441
+ // i.e. the comment stands in for a value (\`"field": /* type */,\`), making the
442
+ // block a non-compilable illustration. A /* ... */ elsewhere (an incidental
443
+ // block comment) is NOT a placeholder, so a block that merely contains one is
444
+ // left for the completeness gate to flag rather than silently skip.
445
+ func hasPlaceholderComment(block string) bool {
446
+ i := 0
447
+ for {
448
+ j := strings.Index(block[i:], "/*")
449
+ if j < 0 {
450
+ return false
451
+ }
452
+ start := i + j
453
+ p := start - 1
454
+ for p >= 0 && (block[p] == ' ' || block[p] == '\\t') {
455
+ p--
456
+ }
457
+ if p >= 0 {
458
+ switch block[p] {
459
+ case ':', '=', '(', '{', ',':
460
+ return true
461
+ }
462
+ }
463
+ end := strings.Index(block[start+2:], "*/")
464
+ if end < 0 {
465
+ return false
466
+ }
467
+ i = start + 2 + end + 2
468
+ }
469
+ }
470
+
471
+ // stripGoComments removes /* ... */ block comments and // line comments so a
472
+ // placeholder-only block can be recognized.
473
+ func stripGoComments(s string) string {
474
+ var b strings.Builder
475
+ i := 0
476
+ for i < len(s) {
477
+ if i+1 < len(s) && s[i] == '/' && s[i+1] == '*' {
478
+ j := strings.Index(s[i+2:], "*/")
479
+ if j < 0 {
480
+ break
481
+ }
482
+ i = i + 2 + j + 2
483
+ continue
484
+ }
485
+ if i+1 < len(s) && s[i] == '/' && s[i+1] == '/' {
486
+ k := strings.IndexByte(s[i:], '\\n')
487
+ if k < 0 {
488
+ break
489
+ }
490
+ i += k
491
+ continue
492
+ }
493
+ b.WriteByte(s[i])
494
+ i++
495
+ }
496
+ return b.String()
497
+ }
498
+
499
+ // stripImportLines drops any single-line \`import ...\` statement from a
500
+ // fragment. Quick-start fragments carry their own import line (e.g.
501
+ // \`import sdk "..."\`), which is illegal inside the function wrapper; the
502
+ // wrapper re-adds the correct imports itself.
503
+ func stripImportLines(block string) string {
504
+ var kept []string
505
+ for _, line := range strings.Split(block, "\\n") {
506
+ if strings.HasPrefix(strings.TrimSpace(line), "import ") {
507
+ continue
508
+ }
509
+ kept = append(kept, line)
510
+ }
511
+ return strings.Join(kept, "\\n")
512
+ }
513
+
514
+ func wrapFragment(name, block, modulePath string) string {
515
+ // Drop stray import lines and rewrite constructors to the seeded test
516
+ // client so placeholder args (options, testopts, ...) type-check.
517
+ block = stripImportLines(block)
518
+ if rewritten, ok := rewriteCtorsToTest(block); ok {
519
+ block = rewritten
520
+ }
521
+
522
+ declaresClient := strings.Contains(block, "client :=")
523
+ injectClient := !declaresClient && strings.Contains(block, "client")
524
+
525
+ needSdk := injectClient || strings.Contains(block, "sdk.")
526
+ usesFmt := strings.Contains(block, "fmt.")
527
+ usesOs := strings.Contains(block, "os.")
528
+ usesCore := strings.Contains(block, "core.")
529
+ usesEntity := strings.Contains(block, "entity.")
530
+
531
+ var imports []string
532
+ if usesFmt {
533
+ imports = append(imports, "\\t\\"fmt\\"")
534
+ }
535
+ if usesOs {
536
+ imports = append(imports, "\\t\\"os\\"")
537
+ }
538
+ if needSdk {
539
+ imports = append(imports, "\\tsdk \\""+modulePath+"\\"")
540
+ }
541
+ if usesCore {
542
+ imports = append(imports, "\\t\\""+modulePath+"/core\\"")
543
+ }
544
+ if usesEntity {
545
+ imports = append(imports, "\\t\\""+modulePath+"/entity\\"")
546
+ }
547
+
548
+ var b strings.Builder
549
+ b.WriteString("package readmefrag\\n\\n")
550
+ if len(imports) > 0 {
551
+ b.WriteString("import (\\n")
552
+ b.WriteString(strings.Join(imports, "\\n"))
553
+ b.WriteString("\\n)\\n\\n")
554
+ }
555
+ b.WriteString("func " + name + "() {\\n")
556
+ if injectClient {
557
+ // Seeded test client so the fragment's documented calls have data.
558
+ b.WriteString("\\tclient := sdk.TestSDK(" + testSeed + ", nil)\\n")
559
+ }
560
+ b.WriteString(block)
561
+ b.WriteString("\\n}\\n")
562
+ return b.String()
563
+ }
564
+
565
+ func applyFixes(out string, fragFiles map[string]string) bool {
566
+ changed := false
567
+ for _, line := range strings.Split(out, "\\n") {
568
+ if !strings.Contains(line, ".go:") {
569
+ continue
570
+ }
571
+ key := snipKeyFromLine(line)
572
+ if key == "" {
573
+ continue
574
+ }
575
+ content, ok := fragFiles[key]
576
+ if !ok {
577
+ continue
578
+ }
579
+ if strings.Contains(line, "imported and not used") {
580
+ pkg := quoted(line)
581
+ if pkg != "" {
582
+ nc := removeImportLine(content, pkg)
583
+ if nc != content {
584
+ fragFiles[key] = nc
585
+ changed = true
586
+ }
587
+ }
588
+ } else if strings.Contains(line, "not used") {
589
+ nm := unusedName(line)
590
+ if nm != "" {
591
+ fragFiles[key] = addBlankAssign(content, nm)
592
+ changed = true
593
+ }
594
+ }
595
+ }
596
+ return changed
597
+ }
598
+
599
+ func snipKeyFromLine(line string) string {
600
+ i := strings.Index(line, "snip")
601
+ if i < 0 {
602
+ return ""
603
+ }
604
+ rest := line[i:]
605
+ j := strings.Index(rest, ".go")
606
+ if j < 0 {
607
+ return ""
608
+ }
609
+ return rest[:j]
610
+ }
611
+
612
+ func quoted(line string) string {
613
+ a := strings.Index(line, "\\"")
614
+ if a < 0 {
615
+ return ""
616
+ }
617
+ b := strings.Index(line[a+1:], "\\"")
618
+ if b < 0 {
619
+ return ""
620
+ }
621
+ return line[a+1 : a+1+b]
622
+ }
623
+
624
+ func unusedName(line string) string {
625
+ marker := "not used:"
626
+ i := strings.Index(line, marker)
627
+ if i >= 0 {
628
+ return strings.TrimSpace(line[i+len(marker):])
629
+ }
630
+ // Fallback: "<name> declared but not used"
631
+ d := strings.Index(line, " declared")
632
+ if d < 0 {
633
+ return ""
634
+ }
635
+ head := strings.TrimSpace(line[:d])
636
+ parts := strings.Fields(head)
637
+ if len(parts) == 0 {
638
+ return ""
639
+ }
640
+ return parts[len(parts)-1]
641
+ }
642
+
643
+ func removeImportLine(content, pkg string) string {
644
+ needle := "\\"" + pkg + "\\""
645
+ var kept []string
646
+ for _, line := range strings.Split(content, "\\n") {
647
+ t := strings.TrimSpace(line)
648
+ // An import spec line ends with the quoted path (with optional
649
+ // alias prefix); the \`import (\` opener does not.
650
+ if strings.HasSuffix(t, needle) && !strings.HasPrefix(t, "import") {
651
+ continue
652
+ }
653
+ kept = append(kept, line)
654
+ }
655
+ return strings.Join(kept, "\\n")
656
+ }
657
+
658
+ func addBlankAssign(content, name string) string {
659
+ // Insert \`_ = name\` before the final closing brace of the func.
660
+ last := strings.LastIndex(content, "}")
661
+ if last < 0 {
662
+ return content
663
+ }
664
+ return content[:last] + "\\t_ = " + name + "\\n" + content[last:]
665
+ }
666
+
667
+ func readModulePath(moduleRoot string) string {
668
+ data, err := os.ReadFile(filepath.Join(moduleRoot, "go.mod"))
669
+ if err != nil {
670
+ return ""
671
+ }
672
+ for _, line := range strings.Split(string(data), "\\n") {
673
+ t := strings.TrimSpace(line)
674
+ if strings.HasPrefix(t, "module ") {
675
+ return strings.TrimSpace(strings.TrimPrefix(t, "module"))
676
+ }
677
+ }
678
+ return ""
679
+ }
680
+ `)
681
+ })
682
+
683
+ })
684
+
685
+
686
+ export {
687
+ ReadmeExamplesTest
688
+ }
@@ -6,7 +6,7 @@ const ReadmeExplanation = cmp(function ReadmeExplanation(props: any) {
6
6
  const { target, ctx$: { model } } = props
7
7
 
8
8
  // Go module path == repo path on GitHub (org from model.origin).
9
- const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk`
9
+ const gomodule = `github.com/${model.origin || 'voxgig-sdk'}/${model.name}-sdk/go`
10
10
 
11
11
  Content(`### Data as maps
12
12