ts-procedures 8.6.0 → 9.1.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 (630) hide show
  1. package/CHANGELOG.md +540 -0
  2. package/README.md +166 -101
  3. package/agent_config/claude-code/.claude-plugin/plugin.json +1 -1
  4. package/agent_config/claude-code/agents/ts-procedures-architect.md +11 -10
  5. package/agent_config/claude-code/skills/ts-procedures/SKILL.md +25 -12
  6. package/agent_config/claude-code/skills/ts-procedures/anti-patterns.md +10 -12
  7. package/agent_config/claude-code/skills/ts-procedures/api-reference.md +141 -45
  8. package/agent_config/claude-code/skills/ts-procedures/checklist.md +7 -6
  9. package/agent_config/claude-code/skills/ts-procedures/patterns.md +45 -6
  10. package/agent_config/claude-code/skills/ts-procedures/templates/client.md +1 -1
  11. package/agent_config/claude-code/skills/ts-procedures/templates/hono.md +1 -1
  12. package/agent_config/copilot/copilot-instructions.md +50 -33
  13. package/agent_config/cursor/cursorrules +50 -33
  14. package/build/adapters/astro/astro-context.js.map +1 -0
  15. package/build/adapters/astro/create-handler.js.map +1 -0
  16. package/build/adapters/astro/index.js.map +1 -0
  17. package/build/{implementations/http → adapters}/astro/index.test.js +1 -1
  18. package/build/adapters/astro/index.test.js.map +1 -0
  19. package/build/adapters/astro/rewrite-request.js.map +1 -0
  20. package/build/adapters/hono/envelope-parity.test.js +98 -0
  21. package/build/adapters/hono/envelope-parity.test.js.map +1 -0
  22. package/build/{implementations/http → adapters}/hono/handlers/http-stream.d.ts +1 -1
  23. package/build/adapters/hono/handlers/http-stream.js +55 -0
  24. package/build/adapters/hono/handlers/http-stream.js.map +1 -0
  25. package/build/{implementations/http → adapters}/hono/handlers/http-stream.test.js +1 -1
  26. package/build/adapters/hono/handlers/http-stream.test.js.map +1 -0
  27. package/build/{implementations/http → adapters}/hono/handlers/http.d.ts +1 -1
  28. package/build/adapters/hono/handlers/http.js +50 -0
  29. package/build/adapters/hono/handlers/http.js.map +1 -0
  30. package/build/{implementations/http → adapters}/hono/handlers/http.test.js +1 -1
  31. package/build/adapters/hono/handlers/http.test.js.map +1 -0
  32. package/build/{implementations/http → adapters}/hono/handlers/rpc.d.ts +2 -2
  33. package/build/adapters/hono/handlers/rpc.js +23 -0
  34. package/build/adapters/hono/handlers/rpc.js.map +1 -0
  35. package/build/{implementations/http → adapters}/hono/handlers/rpc.test.js +1 -1
  36. package/build/adapters/hono/handlers/rpc.test.js.map +1 -0
  37. package/build/adapters/hono/handlers/stream.d.ts +12 -0
  38. package/build/adapters/hono/handlers/stream.js +89 -0
  39. package/build/adapters/hono/handlers/stream.js.map +1 -0
  40. package/build/{implementations/http → adapters}/hono/handlers/stream.test.js +3 -2
  41. package/build/adapters/hono/handlers/stream.test.js.map +1 -0
  42. package/build/{implementations/http → adapters}/hono/index.d.ts +24 -12
  43. package/build/{implementations/http → adapters}/hono/index.js +19 -8
  44. package/build/adapters/hono/index.js.map +1 -0
  45. package/build/{implementations/http → adapters}/hono/index.test.js +2 -4
  46. package/build/adapters/hono/index.test.js.map +1 -0
  47. package/build/{implementations/http → adapters/hono}/on-request-error.test.js +2 -2
  48. package/build/adapters/hono/on-request-error.test.js.map +1 -0
  49. package/build/adapters/hono/request.d.ts +7 -0
  50. package/build/adapters/hono/request.js +22 -0
  51. package/build/adapters/hono/request.js.map +1 -0
  52. package/build/{implementations/http → adapters/hono}/route-errors.test.js +4 -4
  53. package/build/adapters/hono/route-errors.test.js.map +1 -0
  54. package/build/adapters/hono/types.d.ts +55 -0
  55. package/build/adapters/hono/types.js +19 -0
  56. package/build/adapters/hono/types.js.map +1 -0
  57. package/build/client/freeze.test.js +39 -0
  58. package/build/client/freeze.test.js.map +1 -0
  59. package/build/client/typed-error-dispatch.test.js +2 -2
  60. package/build/client/typed-error-dispatch.test.js.map +1 -1
  61. package/build/codegen/__fixtures__/make-envelope.d.ts +1 -1
  62. package/build/codegen/bin/cli.d.ts +5 -0
  63. package/build/codegen/bin/cli.js +139 -182
  64. package/build/codegen/bin/cli.js.map +1 -1
  65. package/build/codegen/bin/cli.test.js +12 -2
  66. package/build/codegen/bin/cli.test.js.map +1 -1
  67. package/build/codegen/bin/flag-specs.d.ts +9 -0
  68. package/build/codegen/bin/flag-specs.js +33 -31
  69. package/build/codegen/bin/flag-specs.js.map +1 -1
  70. package/build/codegen/bin/flag-specs.test.js +14 -1
  71. package/build/codegen/bin/flag-specs.test.js.map +1 -1
  72. package/build/codegen/collect-models.d.ts +1 -1
  73. package/build/codegen/emit/api-route.d.ts +8 -0
  74. package/build/codegen/emit/api-route.js +156 -0
  75. package/build/codegen/emit/api-route.js.map +1 -0
  76. package/build/codegen/emit/context.d.ts +30 -0
  77. package/build/codegen/emit/context.js +2 -0
  78. package/build/codegen/emit/context.js.map +1 -0
  79. package/build/codegen/emit/declarations.d.ts +24 -0
  80. package/build/codegen/emit/declarations.js +48 -0
  81. package/build/codegen/emit/declarations.js.map +1 -0
  82. package/build/codegen/emit/format-types.d.ts +61 -0
  83. package/build/codegen/emit/format-types.js +188 -0
  84. package/build/codegen/emit/format-types.js.map +1 -0
  85. package/build/codegen/emit/http-stream-route.d.ts +7 -0
  86. package/build/codegen/emit/http-stream-route.js +138 -0
  87. package/build/codegen/emit/http-stream-route.js.map +1 -0
  88. package/build/codegen/emit/route-shared.d.ts +37 -0
  89. package/build/codegen/emit/route-shared.js +88 -0
  90. package/build/codegen/emit/route-shared.js.map +1 -0
  91. package/build/codegen/emit/rpc-route.d.ts +7 -0
  92. package/build/codegen/emit/rpc-route.js +37 -0
  93. package/build/codegen/emit/rpc-route.js.map +1 -0
  94. package/build/codegen/emit/scope-file.d.ts +39 -0
  95. package/build/codegen/emit/scope-file.js +166 -0
  96. package/build/codegen/emit/scope-file.js.map +1 -0
  97. package/build/codegen/emit/stream-route.d.ts +7 -0
  98. package/build/codegen/emit/stream-route.js +62 -0
  99. package/build/codegen/emit/stream-route.js.map +1 -0
  100. package/build/codegen/emit-errors.d.ts +1 -1
  101. package/build/codegen/emit-errors.integration.test.js +1 -1
  102. package/build/codegen/emit-errors.integration.test.js.map +1 -1
  103. package/build/codegen/emit-scope.d.ts +13 -30
  104. package/build/codegen/emit-scope.js +15 -844
  105. package/build/codegen/emit-scope.js.map +1 -1
  106. package/build/codegen/emit-scope.test.js +67 -0
  107. package/build/codegen/emit-scope.test.js.map +1 -1
  108. package/build/codegen/goldens.test.js +69 -0
  109. package/build/codegen/goldens.test.js.map +1 -0
  110. package/build/codegen/group-routes.d.ts +1 -1
  111. package/build/codegen/pipeline.d.ts +1 -1
  112. package/build/codegen/resolve-envelope.d.ts +1 -1
  113. package/build/codegen/targets/_shared/error-schemas.d.ts +1 -1
  114. package/build/codegen/targets/_shared/route-slots.d.ts +1 -1
  115. package/build/codegen/targets/_shared/target-run.d.ts +1 -1
  116. package/build/codegen/targets/kotlin/emit-route-kotlin.d.ts +1 -1
  117. package/build/codegen/targets/swift/emit-route-swift.d.ts +1 -1
  118. package/build/core/create-http-stream.d.ts +50 -0
  119. package/build/core/create-http-stream.js +108 -0
  120. package/build/core/create-http-stream.js.map +1 -0
  121. package/build/{create-http-stream.test.js → core/create-http-stream.test.js} +1 -1
  122. package/build/core/create-http-stream.test.js.map +1 -0
  123. package/build/core/create-http.d.ts +51 -0
  124. package/build/core/create-http.js +65 -0
  125. package/build/core/create-http.js.map +1 -0
  126. package/build/{create-http.test.js → core/create-http.test.js} +27 -4
  127. package/build/core/create-http.test.js.map +1 -0
  128. package/build/core/create-stream.d.ts +26 -0
  129. package/build/core/create-stream.js +80 -0
  130. package/build/core/create-stream.js.map +1 -0
  131. package/build/{create-stream.test.js → core/create-stream.test.js} +23 -28
  132. package/build/core/create-stream.test.js.map +1 -0
  133. package/build/core/create.d.ts +22 -0
  134. package/build/core/create.js +71 -0
  135. package/build/core/create.js.map +1 -0
  136. package/build/{create.test.js → core/create.test.js} +25 -46
  137. package/build/core/create.test.js.map +1 -0
  138. package/build/core/definition-site.d.ts +24 -0
  139. package/build/{stack-utils.js → core/definition-site.js} +20 -20
  140. package/build/core/definition-site.js.map +1 -0
  141. package/build/{stack-utils.test.js → core/definition-site.test.js} +12 -3
  142. package/build/core/definition-site.test.js.map +1 -0
  143. package/build/{errors.d.ts → core/errors.d.ts} +19 -8
  144. package/build/{errors.js → core/errors.js} +21 -26
  145. package/build/core/errors.js.map +1 -0
  146. package/build/core/errors.test.js.map +1 -0
  147. package/build/core/factory-options.test.js +82 -0
  148. package/build/core/factory-options.test.js.map +1 -0
  149. package/build/core/http-route.d.ts +13 -0
  150. package/build/core/http-route.js +54 -0
  151. package/build/core/http-route.js.map +1 -0
  152. package/build/core/internal.d.ts +72 -0
  153. package/build/core/internal.js +128 -0
  154. package/build/core/internal.js.map +1 -0
  155. package/build/{migration.test.js → core/migration.test.js} +17 -1
  156. package/build/core/migration.test.js.map +1 -0
  157. package/build/core/procedures.d.ts +143 -0
  158. package/build/core/procedures.js +64 -0
  159. package/build/core/procedures.js.map +1 -0
  160. package/build/{index.test.js → core/procedures.test.js} +14 -11
  161. package/build/core/procedures.test.js.map +1 -0
  162. package/build/core/types.d.ts +183 -0
  163. package/build/{schema → core}/types.js.map +1 -1
  164. package/build/exports.d.ts +31 -11
  165. package/build/exports.js +23 -8
  166. package/build/exports.js.map +1 -1
  167. package/build/schema/adapter.d.ts +35 -0
  168. package/build/schema/adapter.js +13 -0
  169. package/build/schema/adapter.js.map +1 -0
  170. package/build/schema/adapter.test.js +53 -0
  171. package/build/schema/adapter.test.js.map +1 -0
  172. package/build/schema/compile.d.ts +37 -0
  173. package/build/schema/compile.js +38 -0
  174. package/build/schema/compile.js.map +1 -0
  175. package/build/schema/compile.test.js +78 -0
  176. package/build/schema/compile.test.js.map +1 -0
  177. package/build/schema/compute-schema.d.ts +47 -37
  178. package/build/schema/compute-schema.js +86 -29
  179. package/build/schema/compute-schema.js.map +1 -1
  180. package/build/schema/compute-schema.test.js +158 -40
  181. package/build/schema/compute-schema.test.js.map +1 -1
  182. package/build/schema/json-schema.d.ts +17 -0
  183. package/build/schema/json-schema.js +2 -0
  184. package/build/schema/json-schema.js.map +1 -0
  185. package/build/schema/typebox.d.ts +11 -0
  186. package/build/schema/typebox.js +24 -0
  187. package/build/schema/typebox.js.map +1 -0
  188. package/build/schema/typebox.test.js +34 -0
  189. package/build/schema/typebox.test.js.map +1 -0
  190. package/build/server/context.d.ts +8 -0
  191. package/build/server/context.js +7 -0
  192. package/build/server/context.js.map +1 -0
  193. package/build/server/context.test.js +16 -0
  194. package/build/server/context.test.js.map +1 -0
  195. package/build/{doc-envelope.d.ts → server/doc-envelope.d.ts} +1 -1
  196. package/build/server/doc-envelope.js.map +1 -0
  197. package/build/server/doc-envelope.test.d.ts +1 -0
  198. package/build/server/doc-envelope.test.js.map +1 -0
  199. package/build/{implementations/http → server}/doc-registry.d.ts +7 -2
  200. package/build/{implementations/http → server}/doc-registry.js +9 -5
  201. package/build/server/doc-registry.js.map +1 -0
  202. package/build/server/doc-registry.test.d.ts +1 -0
  203. package/build/{implementations/http → server}/doc-registry.test.js +27 -24
  204. package/build/server/doc-registry.test.js.map +1 -0
  205. package/build/server/docs/docs.test.d.ts +1 -0
  206. package/build/server/docs/docs.test.js +237 -0
  207. package/build/server/docs/docs.test.js.map +1 -0
  208. package/build/{implementations/http/hono → server}/docs/http-doc.d.ts +2 -2
  209. package/build/{implementations/http/hono → server}/docs/http-doc.js +1 -1
  210. package/build/server/docs/http-doc.js.map +1 -0
  211. package/build/{implementations/http/hono → server}/docs/http-stream-doc.d.ts +2 -2
  212. package/build/{implementations/http/hono → server}/docs/http-stream-doc.js +1 -1
  213. package/build/server/docs/http-stream-doc.js.map +1 -0
  214. package/build/{implementations/http/hono → server}/docs/rpc-doc.d.ts +2 -2
  215. package/build/{implementations/http/hono → server}/docs/rpc-doc.js +1 -1
  216. package/build/server/docs/rpc-doc.js.map +1 -0
  217. package/build/{implementations/http/hono → server}/docs/stream-doc.d.ts +2 -2
  218. package/build/{implementations/http/hono → server}/docs/stream-doc.js +1 -1
  219. package/build/server/docs/stream-doc.js.map +1 -0
  220. package/build/server/errors/dispatch.d.ts +96 -0
  221. package/build/{implementations/http/error-dispatch.js → server/errors/dispatch.js} +20 -10
  222. package/build/server/errors/dispatch.js.map +1 -0
  223. package/build/server/errors/dispatch.test.d.ts +1 -0
  224. package/build/server/errors/dispatch.test.js +418 -0
  225. package/build/server/errors/dispatch.test.js.map +1 -0
  226. package/build/{implementations/http/error-taxonomy.d.ts → server/errors/taxonomy.d.ts} +8 -17
  227. package/build/{implementations/http/error-taxonomy.js → server/errors/taxonomy.js} +6 -15
  228. package/build/server/errors/taxonomy.js.map +1 -0
  229. package/build/server/errors/taxonomy.test.d.ts +1 -0
  230. package/build/{implementations/http/error-taxonomy.test.js → server/errors/taxonomy.test.js} +45 -39
  231. package/build/server/errors/taxonomy.test.js.map +1 -0
  232. package/build/server/index.d.ts +29 -0
  233. package/build/server/index.js +27 -0
  234. package/build/server/index.js.map +1 -0
  235. package/build/server/no-framework-imports.test.d.ts +1 -0
  236. package/build/server/no-framework-imports.test.js +40 -0
  237. package/build/server/no-framework-imports.test.js.map +1 -0
  238. package/build/{implementations/http/hono/path.d.ts → server/paths.d.ts} +2 -3
  239. package/build/{implementations/http/hono/path.js → server/paths.js} +1 -1
  240. package/build/server/paths.js.map +1 -0
  241. package/build/server/paths.test.d.ts +1 -0
  242. package/build/server/paths.test.js +111 -0
  243. package/build/server/paths.test.js.map +1 -0
  244. package/build/server/request/params.d.ts +29 -0
  245. package/build/server/request/params.js +43 -0
  246. package/build/server/request/params.js.map +1 -0
  247. package/build/server/request/params.test.d.ts +1 -0
  248. package/build/server/request/params.test.js +91 -0
  249. package/build/server/request/params.test.js.map +1 -0
  250. package/build/server/request/query.d.ts +9 -0
  251. package/build/server/request/query.js +22 -0
  252. package/build/server/request/query.js.map +1 -0
  253. package/build/server/request/query.test.d.ts +1 -0
  254. package/build/server/request/query.test.js +60 -0
  255. package/build/server/request/query.test.js.map +1 -0
  256. package/build/server/sse.d.ts +70 -0
  257. package/build/server/sse.js +94 -0
  258. package/build/server/sse.js.map +1 -0
  259. package/build/server/sse.test.d.ts +1 -0
  260. package/build/server/sse.test.js +98 -0
  261. package/build/server/sse.test.js.map +1 -0
  262. package/build/{implementations → server}/types.d.ts +17 -15
  263. package/build/{implementations → server}/types.js.map +1 -1
  264. package/docs/astro-adapter.md +8 -9
  265. package/docs/client-and-codegen.md +10 -4
  266. package/docs/client-error-handling.md +5 -5
  267. package/docs/codegen-kotlin.md +2 -3
  268. package/docs/codegen-swift.md +1 -2
  269. package/docs/core.md +135 -54
  270. package/docs/http-integrations.md +58 -6
  271. package/docs/migration-v8-to-v9.md +200 -0
  272. package/docs/plans/2026-06-09-v9-rewrite.md +130 -0
  273. package/docs/specs/2026-06-09-v9-rewrite-design.md +221 -0
  274. package/docs/streaming.md +12 -0
  275. package/package.json +25 -48
  276. package/src/{implementations/http → adapters}/astro/index.test.ts +2 -2
  277. package/src/adapters/hono/__fixtures__/parity-envelope.json +389 -0
  278. package/src/adapters/hono/envelope-parity.test.ts +126 -0
  279. package/src/{implementations/http → adapters}/hono/handlers/http-stream.test.ts +1 -1
  280. package/src/adapters/hono/handlers/http-stream.ts +73 -0
  281. package/src/{implementations/http → adapters}/hono/handlers/http.test.ts +1 -1
  282. package/src/adapters/hono/handlers/http.ts +70 -0
  283. package/src/{implementations/http → adapters}/hono/handlers/rpc.test.ts +2 -2
  284. package/src/adapters/hono/handlers/rpc.ts +39 -0
  285. package/src/{implementations/http → adapters}/hono/handlers/stream.test.ts +4 -3
  286. package/src/{implementations/http → adapters}/hono/handlers/stream.ts +19 -92
  287. package/src/{implementations/http → adapters}/hono/index.test.ts +14 -16
  288. package/src/{implementations/http → adapters}/hono/index.ts +35 -30
  289. package/src/{implementations/http → adapters/hono}/on-request-error.test.ts +3 -3
  290. package/src/adapters/hono/request.ts +28 -0
  291. package/src/{implementations/http → adapters/hono}/route-errors.test.ts +5 -5
  292. package/src/{implementations/http → adapters}/hono/types.ts +43 -20
  293. package/src/client/freeze.test.ts +41 -0
  294. package/src/client/typed-error-dispatch.test.ts +3 -3
  295. package/src/codegen/__fixtures__/make-envelope.ts +1 -1
  296. package/src/codegen/__fixtures__/models-envelope.json +310 -0
  297. package/src/codegen/__goldens__/MANIFEST.json +85 -0
  298. package/src/codegen/__goldens__/kotlin-default--models/Billing.kt +112 -0
  299. package/src/codegen/__goldens__/kotlin-default--models/BillingReports.kt +26 -0
  300. package/src/codegen/__goldens__/kotlin-default--models/Orders.kt +88 -0
  301. package/src/codegen/__goldens__/kotlin-default--users/Users.kt +189 -0
  302. package/src/codegen/__goldens__/swift-default--models/Billing.swift +97 -0
  303. package/src/codegen/__goldens__/swift-default--models/BillingReports.swift +20 -0
  304. package/src/codegen/__goldens__/swift-default--models/Orders.swift +81 -0
  305. package/src/codegen/__goldens__/swift-default--users/Users.swift +204 -0
  306. package/src/codegen/__goldens__/ts-default--models/_client.ts +1319 -0
  307. package/src/codegen/__goldens__/ts-default--models/_errors.ts +90 -0
  308. package/src/codegen/__goldens__/ts-default--models/_models.ts +10 -0
  309. package/src/codegen/__goldens__/ts-default--models/_types.ts +502 -0
  310. package/src/codegen/__goldens__/ts-default--models/billing-reports.ts +29 -0
  311. package/src/codegen/__goldens__/ts-default--models/billing.ts +67 -0
  312. package/src/codegen/__goldens__/ts-default--models/index.ts +48 -0
  313. package/src/codegen/__goldens__/ts-default--models/orders.ts +80 -0
  314. package/src/codegen/__goldens__/ts-default--users/_client.ts +1319 -0
  315. package/src/codegen/__goldens__/ts-default--users/_errors.ts +90 -0
  316. package/src/codegen/__goldens__/ts-default--users/_types.ts +502 -0
  317. package/src/codegen/__goldens__/ts-default--users/index.ts +38 -0
  318. package/src/codegen/__goldens__/ts-default--users/users.ts +169 -0
  319. package/src/codegen/__goldens__/ts-external-runtime--models/_errors.ts +90 -0
  320. package/src/codegen/__goldens__/ts-external-runtime--models/_models.ts +10 -0
  321. package/src/codegen/__goldens__/ts-external-runtime--models/billing-reports.ts +29 -0
  322. package/src/codegen/__goldens__/ts-external-runtime--models/billing.ts +67 -0
  323. package/src/codegen/__goldens__/ts-external-runtime--models/index.ts +48 -0
  324. package/src/codegen/__goldens__/ts-external-runtime--models/orders.ts +80 -0
  325. package/src/codegen/__goldens__/ts-external-runtime--users/_errors.ts +90 -0
  326. package/src/codegen/__goldens__/ts-external-runtime--users/index.ts +38 -0
  327. package/src/codegen/__goldens__/ts-external-runtime--users/users.ts +169 -0
  328. package/src/codegen/__goldens__/ts-flat--models/_client.ts +1319 -0
  329. package/src/codegen/__goldens__/ts-flat--models/_errors.ts +87 -0
  330. package/src/codegen/__goldens__/ts-flat--models/_models.ts +10 -0
  331. package/src/codegen/__goldens__/ts-flat--models/_types.ts +502 -0
  332. package/src/codegen/__goldens__/ts-flat--models/billing-reports.ts +28 -0
  333. package/src/codegen/__goldens__/ts-flat--models/billing.ts +51 -0
  334. package/src/codegen/__goldens__/ts-flat--models/index.ts +42 -0
  335. package/src/codegen/__goldens__/ts-flat--models/orders.ts +73 -0
  336. package/src/codegen/__goldens__/ts-flat--users/_client.ts +1319 -0
  337. package/src/codegen/__goldens__/ts-flat--users/_errors.ts +87 -0
  338. package/src/codegen/__goldens__/ts-flat--users/_types.ts +502 -0
  339. package/src/codegen/__goldens__/ts-flat--users/index.ts +34 -0
  340. package/src/codegen/__goldens__/ts-flat--users/users.ts +126 -0
  341. package/src/codegen/__goldens__/ts-no-share-models--models/_client.ts +1319 -0
  342. package/src/codegen/__goldens__/ts-no-share-models--models/_errors.ts +90 -0
  343. package/src/codegen/__goldens__/ts-no-share-models--models/_types.ts +502 -0
  344. package/src/codegen/__goldens__/ts-no-share-models--models/billing-reports.ts +29 -0
  345. package/src/codegen/__goldens__/ts-no-share-models--models/billing.ts +111 -0
  346. package/src/codegen/__goldens__/ts-no-share-models--models/index.ts +48 -0
  347. package/src/codegen/__goldens__/ts-no-share-models--models/orders.ts +112 -0
  348. package/src/codegen/__goldens__/ts-no-share-models--users/_client.ts +1319 -0
  349. package/src/codegen/__goldens__/ts-no-share-models--users/_errors.ts +90 -0
  350. package/src/codegen/__goldens__/ts-no-share-models--users/_types.ts +502 -0
  351. package/src/codegen/__goldens__/ts-no-share-models--users/index.ts +38 -0
  352. package/src/codegen/__goldens__/ts-no-share-models--users/users.ts +169 -0
  353. package/src/codegen/__goldens__/ts-shared-models-module--models/_client.ts +1319 -0
  354. package/src/codegen/__goldens__/ts-shared-models-module--models/_errors.ts +90 -0
  355. package/src/codegen/__goldens__/ts-shared-models-module--models/_models.ts +7 -0
  356. package/src/codegen/__goldens__/ts-shared-models-module--models/_types.ts +502 -0
  357. package/src/codegen/__goldens__/ts-shared-models-module--models/billing-reports.ts +29 -0
  358. package/src/codegen/__goldens__/ts-shared-models-module--models/billing.ts +67 -0
  359. package/src/codegen/__goldens__/ts-shared-models-module--models/index.ts +48 -0
  360. package/src/codegen/__goldens__/ts-shared-models-module--models/orders.ts +80 -0
  361. package/src/codegen/bin/cli.test.ts +13 -2
  362. package/src/codegen/bin/cli.ts +181 -144
  363. package/src/codegen/bin/flag-specs.test.ts +16 -1
  364. package/src/codegen/bin/flag-specs.ts +43 -31
  365. package/src/codegen/bundle-size.test.ts +1 -1
  366. package/src/codegen/collect-models.ts +1 -1
  367. package/src/codegen/e2e.test.ts +1 -1
  368. package/src/codegen/emit/api-route.ts +184 -0
  369. package/src/codegen/emit/context.ts +32 -0
  370. package/src/codegen/emit/declarations.ts +49 -0
  371. package/src/codegen/emit/format-types.ts +232 -0
  372. package/src/codegen/emit/http-stream-route.ts +162 -0
  373. package/src/codegen/emit/route-shared.ts +104 -0
  374. package/src/codegen/emit/rpc-route.ts +49 -0
  375. package/src/codegen/emit/scope-file.ts +226 -0
  376. package/src/codegen/emit/stream-route.ts +81 -0
  377. package/src/codegen/emit-errors.integration.test.ts +2 -2
  378. package/src/codegen/emit-errors.test.ts +1 -1
  379. package/src/codegen/emit-errors.ts +1 -1
  380. package/src/codegen/emit-scope.test.ts +75 -2
  381. package/src/codegen/emit-scope.ts +15 -1048
  382. package/src/codegen/goldens.test.ts +89 -0
  383. package/src/codegen/group-routes.test.ts +1 -1
  384. package/src/codegen/group-routes.ts +1 -1
  385. package/src/codegen/pipeline.test.ts +1 -1
  386. package/src/codegen/pipeline.ts +1 -1
  387. package/src/codegen/resolve-envelope.test.ts +1 -1
  388. package/src/codegen/resolve-envelope.ts +1 -1
  389. package/src/codegen/targets/_shared/error-schemas.test.ts +1 -1
  390. package/src/codegen/targets/_shared/error-schemas.ts +1 -1
  391. package/src/codegen/targets/_shared/route-slots.test.ts +1 -1
  392. package/src/codegen/targets/_shared/route-slots.ts +1 -1
  393. package/src/codegen/targets/_shared/target-run.ts +1 -1
  394. package/src/codegen/targets/kotlin/emit-route-kotlin.test.ts +1 -1
  395. package/src/codegen/targets/kotlin/emit-route-kotlin.ts +1 -1
  396. package/src/codegen/targets/kotlin/emit-scope-kotlin.test.ts +1 -1
  397. package/src/codegen/targets/swift/access-level.test.ts +1 -1
  398. package/src/codegen/targets/swift/emit-route-swift.test.ts +1 -1
  399. package/src/codegen/targets/swift/emit-route-swift.ts +1 -1
  400. package/src/codegen/targets/swift/emit-scope-swift.test.ts +1 -1
  401. package/src/codegen/targets/ts/shared-models.test.ts +1 -1
  402. package/src/{create-http-stream.test.ts → core/create-http-stream.test.ts} +1 -1
  403. package/src/core/create-http-stream.ts +207 -0
  404. package/src/{create-http.test.ts → core/create-http.test.ts} +31 -4
  405. package/src/core/create-http.ts +126 -0
  406. package/src/{create-stream.test.ts → core/create-stream.test.ts} +28 -31
  407. package/src/core/create-stream.ts +142 -0
  408. package/src/{create.test.ts → core/create.test.ts} +25 -57
  409. package/src/core/create.ts +121 -0
  410. package/src/{stack-utils.test.ts → core/definition-site.test.ts} +14 -3
  411. package/src/{stack-utils.ts → core/definition-site.ts} +20 -23
  412. package/src/{errors.test.ts → core/errors.test.ts} +1 -1
  413. package/src/{errors.ts → core/errors.ts} +30 -28
  414. package/src/core/factory-options.test.ts +112 -0
  415. package/src/core/http-route.ts +73 -0
  416. package/src/core/internal.ts +203 -0
  417. package/src/{migration.test.ts → core/migration.test.ts} +23 -1
  418. package/src/{index.test.ts → core/procedures.test.ts} +13 -11
  419. package/src/core/procedures.ts +75 -0
  420. package/src/core/types.ts +196 -0
  421. package/src/exports.ts +60 -11
  422. package/src/schema/adapter.test.ts +58 -0
  423. package/src/schema/adapter.ts +45 -0
  424. package/src/schema/compile.test.ts +95 -0
  425. package/src/schema/compile.ts +64 -0
  426. package/src/schema/compute-schema.test.ts +222 -41
  427. package/src/schema/compute-schema.ts +145 -71
  428. package/src/schema/json-schema.ts +21 -0
  429. package/src/schema/typebox.test.ts +40 -0
  430. package/src/schema/typebox.ts +27 -0
  431. package/src/server/context.test.ts +22 -0
  432. package/src/server/context.ts +18 -0
  433. package/src/{doc-envelope.test.ts → server/doc-envelope.test.ts} +2 -2
  434. package/src/{doc-envelope.ts → server/doc-envelope.ts} +1 -1
  435. package/src/{implementations/http → server}/doc-registry.test.ts +32 -26
  436. package/src/{implementations/http → server}/doc-registry.ts +11 -7
  437. package/src/server/docs/docs.test.ts +287 -0
  438. package/src/{implementations/http/hono → server}/docs/http-doc.ts +3 -3
  439. package/src/{implementations/http/hono → server}/docs/http-stream-doc.ts +3 -3
  440. package/src/{implementations/http/hono → server}/docs/rpc-doc.ts +3 -3
  441. package/src/{implementations/http/hono → server}/docs/stream-doc.ts +3 -3
  442. package/src/server/errors/dispatch.test.ts +450 -0
  443. package/src/server/errors/dispatch.ts +189 -0
  444. package/src/{implementations/http/error-taxonomy.test.ts → server/errors/taxonomy.test.ts} +45 -39
  445. package/src/{implementations/http/error-taxonomy.ts → server/errors/taxonomy.ts} +8 -17
  446. package/src/server/index.ts +29 -0
  447. package/src/server/no-framework-imports.test.ts +43 -0
  448. package/src/server/paths.test.ts +141 -0
  449. package/src/{implementations/http/hono/path.ts → server/paths.ts} +2 -13
  450. package/src/server/request/params.test.ts +143 -0
  451. package/src/server/request/params.ts +68 -0
  452. package/src/server/request/query.test.ts +70 -0
  453. package/src/server/request/query.ts +24 -0
  454. package/src/server/sse.test.ts +113 -0
  455. package/src/server/sse.ts +117 -0
  456. package/src/{implementations → server}/types.ts +17 -16
  457. package/build/create-http-stream.d.ts +0 -58
  458. package/build/create-http-stream.js +0 -122
  459. package/build/create-http-stream.js.map +0 -1
  460. package/build/create-http-stream.test.js.map +0 -1
  461. package/build/create-http.d.ts +0 -49
  462. package/build/create-http.js +0 -108
  463. package/build/create-http.js.map +0 -1
  464. package/build/create-http.test.js.map +0 -1
  465. package/build/create-stream.d.ts +0 -35
  466. package/build/create-stream.js +0 -123
  467. package/build/create-stream.js.map +0 -1
  468. package/build/create-stream.test.js.map +0 -1
  469. package/build/create.d.ts +0 -28
  470. package/build/create.js +0 -82
  471. package/build/create.js.map +0 -1
  472. package/build/create.test.js.map +0 -1
  473. package/build/doc-envelope.js.map +0 -1
  474. package/build/doc-envelope.test.js.map +0 -1
  475. package/build/errors.js.map +0 -1
  476. package/build/errors.test.js.map +0 -1
  477. package/build/implementations/http/astro/astro-context.js.map +0 -1
  478. package/build/implementations/http/astro/create-handler.js.map +0 -1
  479. package/build/implementations/http/astro/index.js.map +0 -1
  480. package/build/implementations/http/astro/index.test.js.map +0 -1
  481. package/build/implementations/http/astro/rewrite-request.js.map +0 -1
  482. package/build/implementations/http/doc-registry.js.map +0 -1
  483. package/build/implementations/http/doc-registry.test.js.map +0 -1
  484. package/build/implementations/http/error-dispatch.d.ts +0 -76
  485. package/build/implementations/http/error-dispatch.js.map +0 -1
  486. package/build/implementations/http/error-dispatch.test.js +0 -254
  487. package/build/implementations/http/error-dispatch.test.js.map +0 -1
  488. package/build/implementations/http/error-taxonomy.js.map +0 -1
  489. package/build/implementations/http/error-taxonomy.test.js.map +0 -1
  490. package/build/implementations/http/hono/docs/http-doc.js.map +0 -1
  491. package/build/implementations/http/hono/docs/http-stream-doc.js.map +0 -1
  492. package/build/implementations/http/hono/docs/rpc-doc.js.map +0 -1
  493. package/build/implementations/http/hono/docs/stream-doc.js.map +0 -1
  494. package/build/implementations/http/hono/handlers/http-stream.js +0 -123
  495. package/build/implementations/http/hono/handlers/http-stream.js.map +0 -1
  496. package/build/implementations/http/hono/handlers/http-stream.test.js.map +0 -1
  497. package/build/implementations/http/hono/handlers/http.js +0 -110
  498. package/build/implementations/http/hono/handlers/http.js.map +0 -1
  499. package/build/implementations/http/hono/handlers/http.test.js.map +0 -1
  500. package/build/implementations/http/hono/handlers/rpc.js +0 -32
  501. package/build/implementations/http/hono/handlers/rpc.js.map +0 -1
  502. package/build/implementations/http/hono/handlers/rpc.test.js.map +0 -1
  503. package/build/implementations/http/hono/handlers/stream.d.ts +0 -23
  504. package/build/implementations/http/hono/handlers/stream.js +0 -147
  505. package/build/implementations/http/hono/handlers/stream.js.map +0 -1
  506. package/build/implementations/http/hono/handlers/stream.test.js.map +0 -1
  507. package/build/implementations/http/hono/index.js.map +0 -1
  508. package/build/implementations/http/hono/index.test.js.map +0 -1
  509. package/build/implementations/http/hono/path.js.map +0 -1
  510. package/build/implementations/http/hono/path.test.js +0 -83
  511. package/build/implementations/http/hono/path.test.js.map +0 -1
  512. package/build/implementations/http/hono/types.d.ts +0 -51
  513. package/build/implementations/http/hono/types.js.map +0 -1
  514. package/build/implementations/http/on-request-error.test.js.map +0 -1
  515. package/build/implementations/http/route-errors.test.js.map +0 -1
  516. package/build/index.d.ts +0 -175
  517. package/build/index.js +0 -47
  518. package/build/index.js.map +0 -1
  519. package/build/index.test.js.map +0 -1
  520. package/build/migration.test.js.map +0 -1
  521. package/build/schema/extract-json-schema.d.ts +0 -2
  522. package/build/schema/extract-json-schema.js +0 -12
  523. package/build/schema/extract-json-schema.js.map +0 -1
  524. package/build/schema/extract-json-schema.test.js +0 -23
  525. package/build/schema/extract-json-schema.test.js.map +0 -1
  526. package/build/schema/parser.d.ts +0 -36
  527. package/build/schema/parser.js +0 -210
  528. package/build/schema/parser.js.map +0 -1
  529. package/build/schema/parser.test.js +0 -120
  530. package/build/schema/parser.test.js.map +0 -1
  531. package/build/schema/resolve-schema-lib.d.ts +0 -12
  532. package/build/schema/resolve-schema-lib.js +0 -11
  533. package/build/schema/resolve-schema-lib.js.map +0 -1
  534. package/build/schema/resolve-schema-lib.test.js +0 -17
  535. package/build/schema/resolve-schema-lib.test.js.map +0 -1
  536. package/build/schema/types.d.ts +0 -8
  537. package/build/schema/types.js +0 -2
  538. package/build/stack-utils.d.ts +0 -25
  539. package/build/stack-utils.js.map +0 -1
  540. package/build/stack-utils.test.js.map +0 -1
  541. package/build/types.d.ts +0 -142
  542. package/build/types.js +0 -2
  543. package/build/types.js.map +0 -1
  544. package/docs/decisions/2026-06-02-monorepo-split-evaluation.md +0 -80
  545. package/docs/handoffs/2026-06-08-dx-round2-declines.md +0 -45
  546. package/docs/handoffs/ajsc-named-type-collision.md +0 -134
  547. package/docs/handoffs/ajsc-named-type-support.md +0 -181
  548. package/docs/handoffs/shared-models-auto-resolve-response.md +0 -181
  549. package/docs/npm-workspaces-migration-plan.md +0 -611
  550. package/docs/superpowers/plans/2026-04-24-doc-registry-simplification.md +0 -886
  551. package/docs/superpowers/plans/2026-04-24-kotlin-codegen-target.md +0 -1265
  552. package/docs/superpowers/plans/2026-04-25-ajsc-v7-kotlin-polish.md +0 -1993
  553. package/docs/superpowers/plans/2026-04-29-safe-result-api.md +0 -2293
  554. package/docs/superpowers/plans/2026-05-07-astro-adapter.md +0 -1391
  555. package/docs/superpowers/plans/2026-05-08-create-http.md +0 -3355
  556. package/docs/superpowers/plans/2026-05-08-hono-app-builder-convergence.md +0 -3365
  557. package/docs/superpowers/plans/2026-06-05-dx-feedback-round.md +0 -1292
  558. package/docs/superpowers/plans/2026-06-06-shared-models-convention-and-diagnostics.md +0 -659
  559. package/docs/superpowers/plans/2026-06-08-codegen-dx-surfacing.md +0 -428
  560. package/docs/superpowers/specs/2026-04-24-kotlin-swift-codegen-design.md +0 -401
  561. package/docs/superpowers/specs/2026-04-25-ajsc-v7-kotlin-polish-design.md +0 -314
  562. package/docs/superpowers/specs/2026-04-25-swift-codegen-design.md +0 -264
  563. package/docs/superpowers/specs/2026-04-29-safe-result-api-design.md +0 -324
  564. package/docs/superpowers/specs/2026-05-07-astro-adapter-design.md +0 -252
  565. package/docs/superpowers/specs/2026-05-08-create-http-design.md +0 -409
  566. package/docs/superpowers/specs/2026-05-08-hono-app-builder-convergence-design.md +0 -411
  567. package/docs/superpowers/specs/2026-06-05-dx-feedback-round-design.md +0 -285
  568. package/docs/superpowers/specs/2026-06-08-dx-feedback-round-2-design.md +0 -376
  569. package/src/create-http-stream.ts +0 -191
  570. package/src/create-http.ts +0 -210
  571. package/src/create-stream.ts +0 -228
  572. package/src/create.ts +0 -172
  573. package/src/implementations/http/README.md +0 -390
  574. package/src/implementations/http/error-dispatch.test.ts +0 -283
  575. package/src/implementations/http/error-dispatch.ts +0 -176
  576. package/src/implementations/http/hono/handlers/http-stream.ts +0 -152
  577. package/src/implementations/http/hono/handlers/http.ts +0 -145
  578. package/src/implementations/http/hono/handlers/rpc.ts +0 -54
  579. package/src/implementations/http/hono/path.test.ts +0 -96
  580. package/src/index.ts +0 -101
  581. package/src/schema/extract-json-schema.test.ts +0 -25
  582. package/src/schema/extract-json-schema.ts +0 -15
  583. package/src/schema/parser.test.ts +0 -182
  584. package/src/schema/parser.ts +0 -265
  585. package/src/schema/resolve-schema-lib.test.ts +0 -19
  586. package/src/schema/resolve-schema-lib.ts +0 -29
  587. package/src/schema/types.ts +0 -20
  588. package/src/types.ts +0 -133
  589. /package/build/{implementations/http → adapters}/astro/astro-context.d.ts +0 -0
  590. /package/build/{implementations/http → adapters}/astro/astro-context.js +0 -0
  591. /package/build/{implementations/http → adapters}/astro/create-handler.d.ts +0 -0
  592. /package/build/{implementations/http → adapters}/astro/create-handler.js +0 -0
  593. /package/build/{implementations/http → adapters}/astro/index.d.ts +0 -0
  594. /package/build/{implementations/http → adapters}/astro/index.js +0 -0
  595. /package/build/{implementations/http → adapters}/astro/index.test.d.ts +0 -0
  596. /package/build/{implementations/http → adapters}/astro/rewrite-request.d.ts +0 -0
  597. /package/build/{implementations/http → adapters}/astro/rewrite-request.js +0 -0
  598. /package/build/{create-http-stream.test.d.ts → adapters/hono/envelope-parity.test.d.ts} +0 -0
  599. /package/build/{implementations/http → adapters}/hono/handlers/http-stream.test.d.ts +0 -0
  600. /package/build/{implementations/http → adapters}/hono/handlers/http.test.d.ts +0 -0
  601. /package/build/{implementations/http → adapters}/hono/handlers/rpc.test.d.ts +0 -0
  602. /package/build/{implementations/http → adapters}/hono/handlers/stream.test.d.ts +0 -0
  603. /package/build/{implementations/http → adapters}/hono/index.test.d.ts +0 -0
  604. /package/build/{implementations/http → adapters/hono}/on-request-error.test.d.ts +0 -0
  605. /package/build/{implementations/http → adapters/hono}/route-errors.test.d.ts +0 -0
  606. /package/build/{create-http.test.d.ts → client/freeze.test.d.ts} +0 -0
  607. /package/build/{create-stream.test.d.ts → codegen/goldens.test.d.ts} +0 -0
  608. /package/build/{create.test.d.ts → core/create-http-stream.test.d.ts} +0 -0
  609. /package/build/{doc-envelope.test.d.ts → core/create-http.test.d.ts} +0 -0
  610. /package/build/{errors.test.d.ts → core/create-stream.test.d.ts} +0 -0
  611. /package/build/{implementations/http/doc-registry.test.d.ts → core/create.test.d.ts} +0 -0
  612. /package/build/{implementations/http/error-dispatch.test.d.ts → core/definition-site.test.d.ts} +0 -0
  613. /package/build/{implementations/http/error-taxonomy.test.d.ts → core/errors.test.d.ts} +0 -0
  614. /package/build/{errors.test.js → core/errors.test.js} +0 -0
  615. /package/build/{implementations/http/hono/path.test.d.ts → core/factory-options.test.d.ts} +0 -0
  616. /package/build/{migration.test.d.ts → core/migration.test.d.ts} +0 -0
  617. /package/build/{index.test.d.ts → core/procedures.test.d.ts} +0 -0
  618. /package/build/{implementations/http/hono → core}/types.js +0 -0
  619. /package/build/schema/{extract-json-schema.test.d.ts → adapter.test.d.ts} +0 -0
  620. /package/build/schema/{parser.test.d.ts → compile.test.d.ts} +0 -0
  621. /package/build/schema/{resolve-schema-lib.test.d.ts → typebox.test.d.ts} +0 -0
  622. /package/build/{stack-utils.test.d.ts → server/context.test.d.ts} +0 -0
  623. /package/build/{doc-envelope.js → server/doc-envelope.js} +0 -0
  624. /package/build/{doc-envelope.test.js → server/doc-envelope.test.js} +0 -0
  625. /package/build/{implementations → server}/types.js +0 -0
  626. /package/src/{implementations/http → adapters}/astro/README.md +0 -0
  627. /package/src/{implementations/http → adapters}/astro/astro-context.ts +0 -0
  628. /package/src/{implementations/http → adapters}/astro/create-handler.ts +0 -0
  629. /package/src/{implementations/http → adapters}/astro/index.ts +0 -0
  630. /package/src/{implementations/http → adapters}/astro/rewrite-request.ts +0 -0
@@ -1,428 +0,0 @@
1
- # Codegen DX Surfacing (Workstream A) Implementation Plan
2
-
3
- > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
4
-
5
- **Goal:** Make three already-present client capabilities discoverable in the generated TS output — input-less calls (`api.auth.Me()` instead of `Me({})`), the per-call options bag (`signal`/`timeout`), declared route errors — and emit per-scope client interfaces so DI seams don't force `as unknown as typeof api` casts.
6
-
7
- **Architecture:** All changes live in the TS codegen emitters (`src/codegen/emit-scope.ts`, `src/codegen/emit-index.ts`). No runtime/client changes. #9 flips four `paramsTypeName` fallbacks from `'unknown'` to `'void'` (verified: a required `void` param is omittable at the call site, so `Me()` compiles while `Me({})` is a type error). #8/#10 replace the single-line callable JSDoc with a shared `buildCallableJsDoc` helper that names the options bag and (for error routes) the declared `Errors`. #15 derives per-scope client types from the factory's `ReturnType`, reusing the pattern already in `emit-index.ts`.
8
-
9
- **Tech Stack:** TypeScript, Vitest, ajsc (JSON Schema → TS). Tests are string assertions over `emitScopeFile` / `emitIndexFile` output.
10
-
11
- **Source spec:** `docs/superpowers/specs/2026-06-08-dx-feedback-round-2-design.md` (Workstream A: #9, #8, #10-breadcrumb, #15).
12
-
13
- **Pre-verified facts (do not re-litigate):**
14
- - `tsc --strict`: `declare const a: (params: void, options?: Opts) => Promise<number>` ⇒ `a()` compiles, `a({})` / `a({ nonsense: 1 })` are type errors. So `void` for `TParams` is sufficient — no signature restructuring.
15
- - Current input-less output is `client.bindCallable<unknown, void>` (`emit-scope.test.ts:1255,1281`).
16
- - `paramsTypeName` fallback sites (params position only): `emit-scope.ts:398` (RPC), `:536` (API), `:679` (http-stream), `:816` (stream). The response/yield `unknown` fallbacks at `:399`, `:680`, `:817` MUST stay `unknown`.
17
- - Callable JSDoc single-line sites: `:412` (RPC), `:641` (API), `:777` (http-stream), `:822` (stream).
18
- - Per-route `Errors` type is already emitted + reachable (`Users.GetUser.Errors` / `GetUserErrors`, `emit-scope.test.ts:740,750`); generated error classes are real, so `instanceof` already works on the throwing path. #10 here is a JSDoc breadcrumb only — the consumer-facing prose is Workstream D.
19
- - `emit-index.ts` already emits `create${Service}Bindings` returning `{ <scope>: … }` and already uses `ReturnType<typeof factoryName>` (`:128,145`).
20
-
21
- ---
22
-
23
- ## File Structure
24
-
25
- - **Modify** `src/codegen/emit-scope.ts` — (a) four `paramsTypeName` fallbacks `'unknown'`→`'void'`; (b) add `buildCallableJsDoc` helper; (c) call it at the four callable sites.
26
- - **Modify** `src/codegen/emit-scope.test.ts` — update the two `apiGroupNoBody` assertions; add input-less RPC + stream cases; add JSDoc assertions.
27
- - **Modify** `src/codegen/emit-index.ts` — emit `export type ${Service}Client = ReturnType<typeof create${Service}Bindings>` + one `export type ${Pascal}Client = …['<scope>']` per scope.
28
- - **Modify** `src/codegen/emit-index.test.ts` — assert the new per-scope client type exports.
29
-
30
- Each task is independently testable and committable.
31
-
32
- ---
33
-
34
- ### Task 1: #9 — input-less routes emit `void` params
35
-
36
- **Files:**
37
- - Modify: `src/codegen/emit-scope.ts:398,536,679,816`
38
- - Test: `src/codegen/emit-scope.test.ts` (update `apiGroupNoBody`; add input-less RPC + stream fixtures)
39
-
40
- - [ ] **Step 1: Update the existing input-less assertions to the target output (failing test)**
41
-
42
- In `src/codegen/emit-scope.test.ts`, the `apiGroupNoBody` describe block currently asserts the old output. Change both occurrences:
43
-
44
- ```ts
45
- // flat mode — was: client.bindCallable<unknown, void>
46
- it('neither body nor headers: param type is void, return type is void', async () => {
47
- const out = await emitScopeFile(apiGroupNoBody)
48
- expect(out).toContain('client.bindCallable<void, void>')
49
- expect(out).not.toContain('client.bindCallable<unknown,')
50
- })
51
- ```
52
-
53
- ```ts
54
- // namespace mode — was: client.bindCallable<unknown, void>
55
- it('neither body nor headers: param type is void, return type is void', async () => {
56
- const out = await emitScopeFile(apiGroupNoBody, { namespaceTypes: true })
57
- expect(out).toContain('client.bindCallable<void, void>')
58
- })
59
- ```
60
-
61
- - [ ] **Step 2: Add input-less RPC and stream fixtures + assertions (failing test)**
62
-
63
- Append to `src/codegen/emit-scope.test.ts`:
64
-
65
- ```ts
66
- // Input-less RPC (no body) and stream (no params) — exercise the void-param fallback
67
- // across the RPC and stream emission paths, not just API.
68
- const rpcGroupNoInput: ScopeGroup = {
69
- scopeKey: 'session',
70
- camelCase: 'session',
71
- routes: [
72
- {
73
- kind: 'rpc',
74
- name: 'Logout',
75
- path: '/session/logout',
76
- method: 'post',
77
- scope: 'session',
78
- version: 1,
79
- jsonSchema: {
80
- response: { type: 'object', properties: { ok: { type: 'boolean' } }, required: ['ok'] },
81
- },
82
- } satisfies RPCHttpRouteDoc,
83
- ],
84
- }
85
-
86
- const streamGroupNoParams: ScopeGroup = {
87
- scopeKey: 'ticks',
88
- camelCase: 'ticks',
89
- routes: [
90
- {
91
- kind: 'stream',
92
- name: 'WatchTicks',
93
- path: '/ticks/stream',
94
- methods: ['get'],
95
- streamMode: 'sse',
96
- scope: 'ticks',
97
- version: 1,
98
- jsonSchema: {
99
- params: undefined,
100
- yieldType: { type: 'object', properties: { n: { type: 'number' } }, required: ['n'] },
101
- returnType: undefined,
102
- },
103
- } satisfies StreamHttpRouteDoc,
104
- ],
105
- }
106
-
107
- describe('emitScopeFile input-less routes (void params)', () => {
108
- it('RPC route with no body emits void as the params type arg', async () => {
109
- const out = await emitScopeFile(rpcGroupNoInput)
110
- expect(out).toContain('client.bindCallable<void,')
111
- expect(out).not.toContain('client.bindCallable<unknown,')
112
- })
113
-
114
- it('stream route with no params emits void as the params type', async () => {
115
- const out = await emitScopeFile(streamGroupNoParams)
116
- // Stream callables are direct methods: WatchTicks(params: void, options?)
117
- expect(out).toContain('WatchTicks(params: void')
118
- expect(out).not.toContain('WatchTicks(params: unknown')
119
- })
120
- })
121
- ```
122
-
123
- - [ ] **Step 3: Run the tests to verify they fail**
124
-
125
- Run: `npx vitest run src/codegen/emit-scope.test.ts -t "void"`
126
- Expected: FAIL — the four assertions report `unknown` where `void` is expected.
127
-
128
- - [ ] **Step 4: Flip the four params fallbacks to `void`**
129
-
130
- In `src/codegen/emit-scope.ts`, change only the params-position fallbacks (leave response/yield fallbacks as `unknown`):
131
-
132
- ```ts
133
- // line 398 (emitRpcRoute)
134
- const paramsTypeName = refs['Params'] ?? 'void'
135
- ```
136
- ```ts
137
- // line 536 (emitApiRoute)
138
- let paramsTypeName = 'void'
139
- ```
140
- ```ts
141
- // line 679 (emitHttpStreamRoute)
142
- let paramsTypeName = 'void'
143
- ```
144
- ```ts
145
- // line 816 (emitStreamRoute)
146
- const paramsTypeName = refs['Params'] ?? 'void'
147
- ```
148
-
149
- Do NOT touch `:399` (`responseTypeName`), `:680` (`yieldTypeName`), or `:817` (`yieldTypeName`) — those are return/yield positions and stay `unknown`.
150
-
151
- - [ ] **Step 5: Run the new + existing scope tests to verify they pass**
152
-
153
- Run: `npx vitest run src/codegen/emit-scope.test.ts`
154
- Expected: PASS — all assertions green, including the unchanged input-ful routes (regression guard: routes with channels still emit `${Pascal}Req` / `Params`, never `void`).
155
-
156
- - [ ] **Step 6: Extend the canonical envelope fixture with an input-less route (pipeline-level guard)**
157
-
158
- Add an input-less route to `src/codegen/__fixtures__/users-envelope.json` so the full pipeline + any compile-level e2e exercises it (the existing five routes all have ≥1 req channel). Append to `routes`:
159
-
160
- ```json
161
- {
162
- "kind": "api",
163
- "name": "Heartbeat",
164
- "scope": "users",
165
- "method": "GET",
166
- "fullPath": "/users/heartbeat",
167
- "jsonSchema": { "req": {}, "res": {} },
168
- "errors": []
169
- }
170
- ```
171
-
172
- - [ ] **Step 7: Run the full codegen suite to confirm nothing else snapshots the fixture route count**
173
-
174
- Run: `npx vitest run src/codegen/`
175
- Expected: PASS. If a fixture-count assertion in `pipeline.test.ts` / `e2e.test.ts` fails, update that count from 5 to 6 (the added route is intentional). Verify the failure is only the count, not a behavior change.
176
-
177
- - [ ] **Step 8: Commit**
178
-
179
- ```bash
180
- git add src/codegen/emit-scope.ts src/codegen/emit-scope.test.ts src/codegen/__fixtures__/users-envelope.json
181
- git commit -m "feat(codegen): emit void params for input-less routes so api.X() needs no ({})"
182
- ```
183
-
184
- ---
185
-
186
- ### Task 2: #8 + #10 — callable JSDoc surfaces the options bag and declared errors
187
-
188
- **Files:**
189
- - Modify: `src/codegen/emit-scope.ts` (add `buildCallableJsDoc`; replace single-line JSDoc at `:412,641,777,822`)
190
- - Test: `src/codegen/emit-scope.test.ts`
191
-
192
- - [ ] **Step 1: Write failing tests for the JSDoc breadcrumbs**
193
-
194
- Append to `src/codegen/emit-scope.test.ts`:
195
-
196
- ```ts
197
- describe('emitScopeFile callable JSDoc surfaces options + errors', () => {
198
- it('mentions the per-call options bag on an RPC callable', async () => {
199
- const out = await emitScopeFile(rpcGroup)
200
- expect(out).toContain('POST') // existing method label preserved
201
- expect(out).toContain('@param options')
202
- expect(out).toContain('ProcedureCallOptions')
203
- expect(out).toContain('signal')
204
- })
205
-
206
- it('mentions declared errors + Scope.Route.Errors on a route with errors (namespace)', async () => {
207
- const out = await emitScopeFile(rpcGroupWithErrors, {
208
- namespaceTypes: true,
209
- errorKeys: new Set(['NotFound']),
210
- serviceName: 'Api',
211
- })
212
- expect(out).toContain('@throws')
213
- expect(out).toContain('Users.GetUser.Errors')
214
- expect(out).toContain('instanceof')
215
- })
216
-
217
- it('omits the @throws line when a route declares no errors', async () => {
218
- const out = await emitScopeFile(rpcGroupNoErrors, { serviceName: 'Api' })
219
- expect(out).not.toContain('@throws')
220
- expect(out).toContain('@param options') // options line still present
221
- })
222
-
223
- it('mentions options on a stream callable but no @throws', async () => {
224
- const out = await emitScopeFile(streamGroup)
225
- expect(out).toContain('@param options')
226
- expect(out).not.toContain('@throws')
227
- })
228
- })
229
- ```
230
-
231
- - [ ] **Step 2: Run to verify failure**
232
-
233
- Run: `npx vitest run src/codegen/emit-scope.test.ts -t "JSDoc surfaces"`
234
- Expected: FAIL — current JSDoc is a single line (`/** POST /users/1 */`) with no `@param options` / `@throws`.
235
-
236
- - [ ] **Step 3: Add the `buildCallableJsDoc` helper**
237
-
238
- Add to `src/codegen/emit-scope.ts` (near the other route-emission helpers, above `emitRpcRoute`):
239
-
240
- ```ts
241
- /**
242
- * Builds the multi-line JSDoc comment for a route callable. Surfaces the
243
- * second `options` argument (the per-call AbortSignal/timeout seam — DX #8) and,
244
- * for routes that declare typed errors, points at the route's `Errors` type and
245
- * how to narrow it on the throwing path (DX #10). Indented for placement inside
246
- * the bind-object (4 spaces).
247
- */
248
- function buildCallableJsDoc(opts: {
249
- methodLabel: string
250
- path: string
251
- errorsRef: string | null
252
- }): string {
253
- const lines = [
254
- ` /**`,
255
- ` * ${opts.methodLabel} ${opts.path}`,
256
- ` *`,
257
- ` * @param options Optional per-call {@link ProcedureCallOptions} —`,
258
- ` * \`signal\` (cancel on dispose), \`timeout\`, \`headers\`, \`basePath\`.`,
259
- ]
260
- if (opts.errorsRef) {
261
- lines.push(
262
- ` * @throws Declared typed errors: {@link ${opts.errorsRef}}. Narrow with`,
263
- ` * \`instanceof\` on the throwing path, or call \`.safe()\` for a \`Result\`.`,
264
- )
265
- }
266
- lines.push(` */`)
267
- return lines.join('\n')
268
- }
269
- ```
270
-
271
- - [ ] **Step 4: Replace the four single-line JSDoc comments with the helper**
272
-
273
- `emit-scope.ts:412` (RPC) — replace `` ` /** ${route.method.toUpperCase()} ${route.path} */`, `` with:
274
- ```ts
275
- buildCallableJsDoc({
276
- methodLabel: route.method.toUpperCase(),
277
- path: route.path,
278
- errorsRef: hasErrors ? errorsRef : null,
279
- }),
280
- ```
281
-
282
- `emit-scope.ts:641` (API) — replace the single-line comment with:
283
- ```ts
284
- buildCallableJsDoc({
285
- methodLabel: route.method.toUpperCase(),
286
- path: route.fullPath,
287
- errorsRef: hasErrors ? errorsRef : null,
288
- }),
289
- ```
290
-
291
- `emit-scope.ts:777` (http-stream) — streams carry no `.safe()` typed-error arm, so `errorsRef: null`:
292
- ```ts
293
- buildCallableJsDoc({
294
- methodLabel: route.method.toUpperCase(),
295
- path: route.fullPath,
296
- errorsRef: null,
297
- }),
298
- ```
299
-
300
- `emit-scope.ts:822` (stream) — `errorsRef: null`:
301
- ```ts
302
- buildCallableJsDoc({
303
- methodLabel: route.methods.map((m) => m.toUpperCase()).join('|'),
304
- path: route.path,
305
- errorsRef: null,
306
- }),
307
- ```
308
-
309
- > Note: `hasErrors` and `errorsRef` are already in scope at the RPC (`:403,:404`) and API (`:627`-region) call sites. Confirm before editing; if a site computes them later, hoist the computation above the callable array.
310
-
311
- - [ ] **Step 5: Run to verify the new tests pass and the existing method/path JSDoc assertions still hold**
312
-
313
- Run: `npx vitest run src/codegen/emit-scope.test.ts`
314
- Expected: PASS — including the existing `callable includes JSDoc with method and path` tests (`POST` / `/users/1` still present on the first comment line).
315
-
316
- - [ ] **Step 6: Commit**
317
-
318
- ```bash
319
- git add src/codegen/emit-scope.ts src/codegen/emit-scope.test.ts
320
- git commit -m "feat(codegen): surface per-call options + declared errors in callable JSDoc"
321
- ```
322
-
323
- ---
324
-
325
- ### Task 3: #15 — per-scope client interfaces derived from the bindings factory
326
-
327
- **Files:**
328
- - Modify: `src/codegen/emit-index.ts` (after the factory function, before/after `create${Service}Client`)
329
- - Test: `src/codegen/emit-index.test.ts`
330
-
331
- - [ ] **Step 1: Write failing tests for the derived client types**
332
-
333
- Add to `src/codegen/emit-index.test.ts` (use the existing multi-scope fixture in that file; if it has scopes `users` and `posts`, assert both):
334
-
335
- ```ts
336
- describe('emitIndexFile per-scope client types (DX #15)', () => {
337
- it('emits the aggregate client type from the factory return type', async () => {
338
- const out = emitIndexFile(groups, { serviceName: 'Api' })
339
- expect(out).toContain('export type ApiClient = ReturnType<typeof createApiBindings>')
340
- })
341
-
342
- it('emits one per-scope client type as an indexed access into the aggregate', async () => {
343
- const out = emitIndexFile(groups, { serviceName: 'Api' })
344
- // groups here are camelCase 'users' / 'posts' (adjust to the fixture's scopes)
345
- expect(out).toContain("export type UsersClient = ApiClient['users']")
346
- expect(out).toContain("export type PostsClient = ApiClient['posts']")
347
- })
348
-
349
- it('honors a custom serviceName in the client type names', async () => {
350
- const out = emitIndexFile(groups, { serviceName: 'Catalog' })
351
- expect(out).toContain('export type CatalogClient = ReturnType<typeof createCatalogBindings>')
352
- expect(out).toContain("export type UsersClient = CatalogClient['users']")
353
- })
354
- })
355
- ```
356
-
357
- > Before writing, open `src/codegen/emit-index.test.ts` and reuse its existing `groups` fixture + `import { emitIndexFile }` line. Match the scope camelCase names it already defines rather than introducing new ones.
358
-
359
- - [ ] **Step 2: Run to verify failure**
360
-
361
- Run: `npx vitest run src/codegen/emit-index.test.ts -t "per-scope client types"`
362
- Expected: FAIL — no `export type ApiClient` / `UsersClient` in current output.
363
-
364
- - [ ] **Step 3: Emit the derived client types in `emit-index.ts`**
365
-
366
- In `src/codegen/emit-index.ts`, after the `${factoryName}` function is pushed onto `pieces` (after the block ending at line 107, before the `create${Service}Client` block at line 109), insert:
367
-
368
- ```ts
369
- // Per-scope client interfaces, derived from the bindings factory's return type
370
- // (DX #15). Reuses the `ReturnType<typeof factory>` pattern already used by the
371
- // convenience client below. Lets a consumer type a dependency as the narrow scope
372
- // port — `constructor(client: UsersClient = api.users)` — and a fake satisfies just
373
- // that scope with no `as unknown as typeof api` cast. `${Service}Client` is the
374
- // callable bundle; it does NOT collide with the `${Service}.<Scope>` type namespace.
375
- const aggregateClientType = `${servicePascal}Client`
376
- pieces.push(
377
- `export type ${aggregateClientType} = ReturnType<typeof ${factoryName}>`,
378
- ...groups.map(
379
- (g) => `export type ${toPascalCase(g.camelCase)}Client = ${aggregateClientType}['${g.camelCase}']`,
380
- ),
381
- '',
382
- )
383
- ```
384
-
385
- - [ ] **Step 4: Run to verify the new tests pass**
386
-
387
- Run: `npx vitest run src/codegen/emit-index.test.ts`
388
- Expected: PASS.
389
-
390
- - [ ] **Step 5: Confirm the generated index still type-checks end-to-end**
391
-
392
- Run: `npx vitest run src/codegen/`
393
- Expected: PASS. The added type aliases are pure derivations of an existing emitted value, so any compile-level e2e test that builds the generated index continues to compile. If `e2e.test.ts` snapshots the full index text, update the snapshot and eyeball the diff (only the new `export type …Client` lines added).
394
-
395
- - [ ] **Step 6: Commit**
396
-
397
- ```bash
398
- git add src/codegen/emit-index.ts src/codegen/emit-index.test.ts
399
- git commit -m "feat(codegen): emit per-scope client types so DI seams need no aggregate-client cast"
400
- ```
401
-
402
- ---
403
-
404
- ## Self-Review
405
-
406
- **Spec coverage (Workstream A items #9, #8, #10-breadcrumb, #15):**
407
- - #9 → Task 1 (four `void` fallbacks + RPC/API/stream coverage + fixture). ✓
408
- - #8 → Task 2 (`@param options` on all four callable kinds). ✓
409
- - #10 (breadcrumb half) → Task 2 (`@throws` + `Scope.Route.Errors` + `instanceof`). The consumer prose half is Workstream D, out of this plan by design. ✓
410
- - #15 → Task 3 (`${Service}Client` + per-scope indexed types). ✓
411
-
412
- **Type consistency:** `buildCallableJsDoc({ methodLabel, path, errorsRef })` — same three-field shape at all four call sites. `errorsRef` is `string | null` everywhere (the RPC/API sites pass `hasErrors ? errorsRef : null`; stream sites pass `null`). `aggregateClientType` / `${Pascal}Client` naming consistent between emit code and tests.
413
-
414
- **Placeholder scan:** no TBD/TODO; every code step shows the literal edit; every run step shows the command + expected result.
415
-
416
- **Known follow-ups (NOT this plan):** the `isProcedureError` guard (deferred sugar — `instanceof` already works); the consumer-facing docs for #10/#8 (Workstream D); #6 no-content (Workstream B, server-side); correlation-id (Workstream E).
417
-
418
- ---
419
-
420
- ## Execution Handoff
421
-
422
- **Plan complete and saved to `docs/superpowers/plans/2026-06-08-codegen-dx-surfacing.md`. Two execution options:**
423
-
424
- **1. Subagent-Driven (recommended)** — fresh subagent per task, review between tasks, fast iteration.
425
-
426
- **2. Inline Execution** — execute tasks in this session via executing-plans, batch execution with checkpoints.
427
-
428
- **Which approach?**