@oyolincc/create 0.0.0-dev-20260513130832 → 0.0.0-dev-20260922064135

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 (418) hide show
  1. package/dist/index.d.mts +2 -2
  2. package/dist/index.mjs +2 -2
  3. package/dist/index.mjs.map +1 -1
  4. package/package.json +31 -16
  5. package/templates/hono-fullstack/.agents/skills/ask-matt/PHASE-BOUNDARIES.md +55 -0
  6. package/templates/hono-fullstack/.agents/skills/ask-matt/SKILL.md +90 -0
  7. package/templates/hono-fullstack/.agents/skills/ask-matt/agents/openai.yaml +5 -0
  8. package/templates/hono-fullstack/.agents/skills/code-review/SKILL.md +87 -0
  9. package/templates/hono-fullstack/.agents/skills/code-review/agents/openai.yaml +3 -0
  10. package/templates/hono-fullstack/.agents/skills/codebase-design/DEEPENING.md +37 -0
  11. package/templates/hono-fullstack/.agents/skills/codebase-design/DESIGN-IT-TWICE.md +44 -0
  12. package/templates/hono-fullstack/.agents/skills/codebase-design/SKILL.md +114 -0
  13. package/templates/hono-fullstack/.agents/skills/codebase-design/agents/openai.yaml +3 -0
  14. package/templates/hono-fullstack/.agents/skills/confirm-requirements/SKILL.md +25 -0
  15. package/templates/hono-fullstack/.agents/skills/diagnosing-bugs/SKILL.md +140 -0
  16. package/templates/hono-fullstack/.agents/skills/diagnosing-bugs/agents/openai.yaml +3 -0
  17. package/templates/hono-fullstack/.agents/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +44 -0
  18. package/templates/hono-fullstack/.agents/skills/domain-modeling/ADR-FORMAT.md +47 -0
  19. package/templates/hono-fullstack/.agents/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  20. package/templates/hono-fullstack/.agents/skills/domain-modeling/SKILL.md +74 -0
  21. package/templates/hono-fullstack/.agents/skills/domain-modeling/agents/openai.yaml +3 -0
  22. package/templates/hono-fullstack/.agents/skills/grill-me/SKILL.md +7 -0
  23. package/templates/hono-fullstack/.agents/skills/grill-me/agents/openai.yaml +5 -0
  24. package/templates/hono-fullstack/.agents/skills/grilling/SKILL.md +22 -0
  25. package/templates/hono-fullstack/.agents/skills/grilling/agents/openai.yaml +3 -0
  26. package/templates/hono-fullstack/.agents/skills/implement/SKILL.md +15 -0
  27. package/templates/hono-fullstack/.agents/skills/implement/agents/openai.yaml +5 -0
  28. package/templates/hono-fullstack/.agents/skills/improve-codebase-architecture/HTML-REPORT.md +123 -0
  29. package/templates/hono-fullstack/.agents/skills/improve-codebase-architecture/SKILL.md +71 -0
  30. package/templates/hono-fullstack/.agents/skills/improve-codebase-architecture/agents/openai.yaml +5 -0
  31. package/templates/hono-fullstack/.agents/skills/prototype/LOGIC.md +67 -0
  32. package/templates/hono-fullstack/.agents/skills/prototype/SKILL.md +26 -0
  33. package/templates/hono-fullstack/.agents/skills/prototype/UI.md +112 -0
  34. package/templates/hono-fullstack/.agents/skills/prototype/agents/openai.yaml +3 -0
  35. package/templates/hono-fullstack/.agents/skills/research/SKILL.md +12 -0
  36. package/templates/hono-fullstack/.agents/skills/research/agents/openai.yaml +3 -0
  37. package/templates/hono-fullstack/.agents/skills/resolving-merge-conflicts/SKILL.md +14 -0
  38. package/templates/hono-fullstack/.agents/skills/resolving-merge-conflicts/agents/openai.yaml +3 -0
  39. package/templates/hono-fullstack/.agents/skills/scoped-code-review/SKILL.md +113 -0
  40. package/templates/hono-fullstack/.agents/skills/setup-matt-pocock-skills/SKILL.md +116 -0
  41. package/templates/hono-fullstack/.agents/skills/setup-matt-pocock-skills/agents/openai.yaml +5 -0
  42. package/templates/hono-fullstack/.agents/skills/setup-matt-pocock-skills/domain.md +51 -0
  43. package/templates/hono-fullstack/.agents/skills/setup-matt-pocock-skills/issue-tracker-github.md +45 -0
  44. package/templates/hono-fullstack/.agents/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md +46 -0
  45. package/templates/hono-fullstack/.agents/skills/setup-matt-pocock-skills/issue-tracker-local.md +30 -0
  46. package/templates/hono-fullstack/.agents/skills/setup-matt-pocock-skills/triage-labels.md +15 -0
  47. package/templates/hono-fullstack/.agents/skills/tdd/SKILL.md +38 -0
  48. package/templates/hono-fullstack/.agents/skills/tdd/agents/openai.yaml +3 -0
  49. package/templates/hono-fullstack/.agents/skills/tdd/mocking.md +59 -0
  50. package/templates/hono-fullstack/.agents/skills/tdd/tests.md +77 -0
  51. package/templates/hono-fullstack/.agents/skills/teach/GLOSSARY-FORMAT.md +35 -0
  52. package/templates/hono-fullstack/.agents/skills/teach/LEARNING-RECORD-FORMAT.md +46 -0
  53. package/templates/hono-fullstack/.agents/skills/teach/MISSION-FORMAT.md +31 -0
  54. package/templates/hono-fullstack/.agents/skills/teach/RESOURCES-FORMAT.md +32 -0
  55. package/templates/hono-fullstack/.agents/skills/teach/SKILL.md +140 -0
  56. package/templates/hono-fullstack/.agents/skills/teach/agents/openai.yaml +5 -0
  57. package/templates/hono-fullstack/.agents/skills/to-questionnaire/SKILL.md +53 -0
  58. package/templates/hono-fullstack/.agents/skills/to-questionnaire/agents/openai.yaml +5 -0
  59. package/templates/hono-fullstack/.agents/skills/triage/AGENT-BRIEF.md +207 -0
  60. package/templates/hono-fullstack/.agents/skills/triage/OUT-OF-SCOPE.md +105 -0
  61. package/templates/hono-fullstack/.agents/skills/triage/SKILL.md +112 -0
  62. package/templates/hono-fullstack/.agents/skills/triage/agents/openai.yaml +5 -0
  63. package/templates/hono-fullstack/.agents/skills/wait-what/SKILL.md +7 -0
  64. package/templates/hono-fullstack/.agents/skills/wait-what/agents/openai.yaml +5 -0
  65. package/templates/hono-fullstack/.agents/skills/wayfinder/SKILL.md +128 -0
  66. package/templates/hono-fullstack/.agents/skills/wayfinder/agents/openai.yaml +5 -0
  67. package/templates/hono-fullstack/.agents/skills/wizard/SKILL.md +44 -0
  68. package/templates/hono-fullstack/.agents/skills/wizard/agents/openai.yaml +3 -0
  69. package/templates/hono-fullstack/.agents/skills/wizard/template.sh +204 -0
  70. package/templates/hono-fullstack/.agents/skills/writing-for-agents/SKILL-MECHANICS.md +22 -0
  71. package/templates/hono-fullstack/.agents/skills/writing-for-agents/SKILL.md +81 -0
  72. package/templates/hono-fullstack/.agents/skills/writing-for-agents/agents/openai.yaml +3 -0
  73. package/templates/hono-fullstack/.changeset/README.md +8 -0
  74. package/templates/hono-fullstack/.changeset/config.json +11 -0
  75. package/templates/hono-fullstack/.vscode/extensions.json +5 -0
  76. package/templates/hono-fullstack/.vscode/launch.json +25 -0
  77. package/templates/hono-fullstack/.vscode/settings.json +24 -0
  78. package/templates/hono-fullstack/AGENTS.md +43 -0
  79. package/templates/hono-fullstack/README.md +37 -0
  80. package/templates/hono-fullstack/_gitignore +30 -0
  81. package/templates/hono-fullstack/apps/server/package.json +55 -0
  82. package/templates/hono-fullstack/apps/server/src/adapters/nodejs/bootstrap.ts +64 -0
  83. package/templates/hono-fullstack/apps/server/src/adapters/nodejs/config.ts +53 -0
  84. package/templates/hono-fullstack/apps/server/src/adapters/nodejs/entry.ts +50 -0
  85. package/templates/hono-fullstack/apps/server/src/app.ts +43 -0
  86. package/templates/hono-fullstack/apps/server/src/infra/logger/getter.ts +74 -0
  87. package/templates/hono-fullstack/apps/server/src/infra/logger/pino.ts +122 -0
  88. package/templates/hono-fullstack/apps/server/src/infra/work-runner/constants.ts +23 -0
  89. package/templates/hono-fullstack/apps/server/src/infra/work-runner/errors.ts +40 -0
  90. package/templates/hono-fullstack/apps/server/src/infra/work-runner/example/runner.test.ts +56 -0
  91. package/templates/hono-fullstack/apps/server/src/infra/work-runner/example/runner.ts +185 -0
  92. package/templates/hono-fullstack/apps/server/src/infra/work-runner/example/worker-entry.ts +34 -0
  93. package/templates/hono-fullstack/apps/server/src/infra/work-runner/types.ts +113 -0
  94. package/templates/hono-fullstack/apps/server/src/infra/work-runner/utils/business-error.ts +19 -0
  95. package/templates/hono-fullstack/apps/server/src/infra/work-runner/utils/message.ts +46 -0
  96. package/templates/hono-fullstack/apps/server/src/infra/work-runner/utils/transfer.ts +144 -0
  97. package/templates/hono-fullstack/apps/server/src/middlewares/cors.ts +26 -0
  98. package/templates/hono-fullstack/apps/server/src/modules/example/contracts.ts +9 -0
  99. package/templates/hono-fullstack/apps/server/src/modules/example/routes.ts +75 -0
  100. package/templates/hono-fullstack/apps/server/src/modules/example/work-task/tasks.test.ts +37 -0
  101. package/templates/hono-fullstack/apps/server/src/modules/example/work-task/tasks.ts +35 -0
  102. package/templates/hono-fullstack/apps/server/src/shared/app/types.ts +45 -0
  103. package/templates/hono-fullstack/apps/server/src/shared/errors/constants.ts +152 -0
  104. package/templates/hono-fullstack/apps/server/src/shared/errors/defs/index.ts +15 -0
  105. package/templates/hono-fullstack/apps/server/src/shared/errors/handler.ts +16 -0
  106. package/templates/hono-fullstack/apps/server/src/shared/errors/log.ts +67 -0
  107. package/templates/hono-fullstack/apps/server/src/shared/errors/proto.ts +42 -0
  108. package/templates/hono-fullstack/apps/server/src/shared/errors/types.ts +29 -0
  109. package/templates/hono-fullstack/apps/server/src/shared/network/fetcher.ts +35 -0
  110. package/templates/hono-fullstack/apps/server/src/shared/network/openapi/index.ts +50 -0
  111. package/templates/hono-fullstack/apps/server/src/shared/network/openapi/res-defs.ts +39 -0
  112. package/templates/hono-fullstack/apps/server/src/shared/network/types.ts +3 -0
  113. package/templates/hono-fullstack/apps/server/src/shared/network/utils.ts +36 -0
  114. package/templates/hono-fullstack/apps/server/src/shared/network/validator.ts +28 -0
  115. package/templates/hono-fullstack/apps/server/src/shared/utils/index.ts +30 -0
  116. package/templates/hono-fullstack/apps/server/src/virtual-modules.d.ts +5 -0
  117. package/templates/hono-fullstack/apps/server/tsconfig.json +16 -0
  118. package/templates/hono-fullstack/apps/server/vite.config.ts +79 -0
  119. package/templates/hono-fullstack/apps/stack/frontend/modules/example/api.ts +13 -0
  120. package/templates/hono-fullstack/apps/stack/frontend/modules/example/components/ExamplePage.tsx +59 -0
  121. package/templates/hono-fullstack/apps/stack/frontend/modules/example/hooks/api-hooks.ts +14 -0
  122. package/templates/hono-fullstack/apps/stack/frontend/modules/example/stores/index.ts +3 -0
  123. package/templates/hono-fullstack/apps/stack/frontend/routeTree.gen.ts +56 -0
  124. package/templates/hono-fullstack/apps/stack/frontend/router.tsx +22 -0
  125. package/templates/hono-fullstack/apps/stack/frontend/routes/__root.tsx +61 -0
  126. package/templates/hono-fullstack/apps/stack/frontend/routes/index.tsx +4 -0
  127. package/templates/hono-fullstack/apps/stack/frontend/shared/network/client.ts +19 -0
  128. package/templates/hono-fullstack/apps/stack/frontend/shared/network/constants.ts +1 -0
  129. package/templates/hono-fullstack/apps/stack/frontend/shared/network/errors.ts +33 -0
  130. package/templates/hono-fullstack/apps/stack/frontend/styles.css +23 -0
  131. package/templates/hono-fullstack/apps/stack/frontend/vite-env.d.ts +1 -0
  132. package/templates/hono-fullstack/apps/stack/nitro/handlers/hono.ts +1 -0
  133. package/templates/hono-fullstack/apps/stack/nitro/plugins/hono.ts +9 -0
  134. package/templates/hono-fullstack/apps/stack/package.json +44 -0
  135. package/templates/hono-fullstack/apps/stack/tsconfig.json +12 -0
  136. package/templates/hono-fullstack/apps/stack/tsr.config.json +5 -0
  137. package/templates/hono-fullstack/apps/stack/vite.config.ts +33 -0
  138. package/templates/hono-fullstack/docs/agents/domain.md +41 -0
  139. package/templates/hono-fullstack/docs/agents/issue-tracker.md +30 -0
  140. package/templates/hono-fullstack/docs/agents/triage-labels.md +15 -0
  141. package/templates/hono-fullstack/envs/.env.example.server +12 -0
  142. package/templates/hono-fullstack/envs/.env.example.sqlite +1 -0
  143. package/templates/hono-fullstack/libs/db/drizzle-kit/sqlite.config.ts +22 -0
  144. package/templates/hono-fullstack/libs/db/package.json +40 -0
  145. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/client.ts +35 -0
  146. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/columns.ts +32 -0
  147. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/index.ts +7 -0
  148. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/modules/examples/examples.ts +22 -0
  149. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/relations.ts +5 -0
  150. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/tables.ts +5 -0
  151. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/types.ts +7 -0
  152. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/vo.ts +1 -0
  153. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/utils.ts +8 -0
  154. package/templates/hono-fullstack/libs/db/src/shared/types.ts +26 -0
  155. package/templates/hono-fullstack/libs/db/tsconfig.json +10 -0
  156. package/templates/hono-fullstack/libs/db/vite.config.ts +21 -0
  157. package/templates/hono-fullstack/libs/definition/package.json +30 -0
  158. package/templates/hono-fullstack/libs/definition/src/backend.ts +2 -0
  159. package/templates/hono-fullstack/libs/definition/src/configs/defs/log.ts +53 -0
  160. package/templates/hono-fullstack/libs/definition/src/configs/defs/middleware.ts +16 -0
  161. package/templates/hono-fullstack/libs/definition/src/configs/defs/runtime.ts +11 -0
  162. package/templates/hono-fullstack/libs/definition/src/configs/defs/sqlite.ts +13 -0
  163. package/templates/hono-fullstack/libs/definition/src/configs/defs/worker.ts +29 -0
  164. package/templates/hono-fullstack/libs/definition/src/configs/index.ts +5 -0
  165. package/templates/hono-fullstack/libs/definition/src/configs/proto.ts +81 -0
  166. package/templates/hono-fullstack/libs/definition/src/configs/schema.ts +23 -0
  167. package/templates/hono-fullstack/libs/definition/src/frontend.ts +1 -0
  168. package/templates/hono-fullstack/libs/definition/src/modules/example/index.ts +16 -0
  169. package/templates/hono-fullstack/libs/definition/src/modules/index.ts +1 -0
  170. package/templates/hono-fullstack/libs/definition/tsconfig.json +5 -0
  171. package/templates/hono-fullstack/libs/definition/vite.config.ts +13 -0
  172. package/templates/hono-fullstack/oyo.config.json +12 -0
  173. package/templates/hono-fullstack/package.json +25 -0
  174. package/templates/hono-fullstack/pnpm-workspace.yaml +82 -0
  175. package/templates/hono-fullstack/tsconfig.json +4 -0
  176. package/templates/hono-fullstack/turbo.json +14 -0
  177. package/templates/hono-fullstack/vite.config.ts +13 -0
  178. package/templates/hono-server/.agents/skills/ask-matt/PHASE-BOUNDARIES.md +55 -0
  179. package/templates/hono-server/.agents/skills/ask-matt/SKILL.md +90 -0
  180. package/templates/hono-server/.agents/skills/ask-matt/agents/openai.yaml +5 -0
  181. package/templates/hono-server/.agents/skills/code-review/SKILL.md +87 -0
  182. package/templates/hono-server/.agents/skills/code-review/agents/openai.yaml +3 -0
  183. package/templates/hono-server/.agents/skills/codebase-design/DEEPENING.md +37 -0
  184. package/templates/hono-server/.agents/skills/codebase-design/DESIGN-IT-TWICE.md +44 -0
  185. package/templates/hono-server/.agents/skills/codebase-design/SKILL.md +114 -0
  186. package/templates/hono-server/.agents/skills/codebase-design/agents/openai.yaml +3 -0
  187. package/templates/hono-server/.agents/skills/confirm-requirements/SKILL.md +25 -0
  188. package/templates/hono-server/.agents/skills/diagnosing-bugs/SKILL.md +140 -0
  189. package/templates/hono-server/.agents/skills/diagnosing-bugs/agents/openai.yaml +3 -0
  190. package/templates/hono-server/.agents/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +44 -0
  191. package/templates/hono-server/.agents/skills/domain-modeling/ADR-FORMAT.md +47 -0
  192. package/templates/hono-server/.agents/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  193. package/templates/hono-server/.agents/skills/domain-modeling/SKILL.md +74 -0
  194. package/templates/hono-server/.agents/skills/domain-modeling/agents/openai.yaml +3 -0
  195. package/templates/hono-server/.agents/skills/grill-me/SKILL.md +7 -0
  196. package/templates/hono-server/.agents/skills/grill-me/agents/openai.yaml +5 -0
  197. package/templates/hono-server/.agents/skills/grilling/SKILL.md +22 -0
  198. package/templates/hono-server/.agents/skills/grilling/agents/openai.yaml +3 -0
  199. package/templates/hono-server/.agents/skills/implement/SKILL.md +15 -0
  200. package/templates/hono-server/.agents/skills/implement/agents/openai.yaml +5 -0
  201. package/templates/hono-server/.agents/skills/improve-codebase-architecture/HTML-REPORT.md +123 -0
  202. package/templates/hono-server/.agents/skills/improve-codebase-architecture/SKILL.md +71 -0
  203. package/templates/hono-server/.agents/skills/improve-codebase-architecture/agents/openai.yaml +5 -0
  204. package/templates/hono-server/.agents/skills/prototype/LOGIC.md +67 -0
  205. package/templates/hono-server/.agents/skills/prototype/SKILL.md +26 -0
  206. package/templates/hono-server/.agents/skills/prototype/UI.md +112 -0
  207. package/templates/hono-server/.agents/skills/prototype/agents/openai.yaml +3 -0
  208. package/templates/hono-server/.agents/skills/research/SKILL.md +12 -0
  209. package/templates/hono-server/.agents/skills/research/agents/openai.yaml +3 -0
  210. package/templates/hono-server/.agents/skills/resolving-merge-conflicts/SKILL.md +14 -0
  211. package/templates/hono-server/.agents/skills/resolving-merge-conflicts/agents/openai.yaml +3 -0
  212. package/templates/hono-server/.agents/skills/scoped-code-review/SKILL.md +113 -0
  213. package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/SKILL.md +116 -0
  214. package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/agents/openai.yaml +5 -0
  215. package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/domain.md +51 -0
  216. package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/issue-tracker-github.md +45 -0
  217. package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md +46 -0
  218. package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/issue-tracker-local.md +30 -0
  219. package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/triage-labels.md +15 -0
  220. package/templates/hono-server/.agents/skills/tdd/SKILL.md +38 -0
  221. package/templates/hono-server/.agents/skills/tdd/agents/openai.yaml +3 -0
  222. package/templates/hono-server/.agents/skills/tdd/mocking.md +59 -0
  223. package/templates/hono-server/.agents/skills/tdd/tests.md +77 -0
  224. package/templates/hono-server/.agents/skills/teach/GLOSSARY-FORMAT.md +35 -0
  225. package/templates/hono-server/.agents/skills/teach/LEARNING-RECORD-FORMAT.md +46 -0
  226. package/templates/hono-server/.agents/skills/teach/MISSION-FORMAT.md +31 -0
  227. package/templates/hono-server/.agents/skills/teach/RESOURCES-FORMAT.md +32 -0
  228. package/templates/hono-server/.agents/skills/teach/SKILL.md +140 -0
  229. package/templates/hono-server/.agents/skills/teach/agents/openai.yaml +5 -0
  230. package/templates/hono-server/.agents/skills/to-questionnaire/SKILL.md +53 -0
  231. package/templates/hono-server/.agents/skills/to-questionnaire/agents/openai.yaml +5 -0
  232. package/templates/hono-server/.agents/skills/triage/AGENT-BRIEF.md +207 -0
  233. package/templates/hono-server/.agents/skills/triage/OUT-OF-SCOPE.md +105 -0
  234. package/templates/hono-server/.agents/skills/triage/SKILL.md +112 -0
  235. package/templates/hono-server/.agents/skills/triage/agents/openai.yaml +5 -0
  236. package/templates/hono-server/.agents/skills/wait-what/SKILL.md +7 -0
  237. package/templates/hono-server/.agents/skills/wait-what/agents/openai.yaml +5 -0
  238. package/templates/hono-server/.agents/skills/wayfinder/SKILL.md +128 -0
  239. package/templates/hono-server/.agents/skills/wayfinder/agents/openai.yaml +5 -0
  240. package/templates/hono-server/.agents/skills/wizard/SKILL.md +44 -0
  241. package/templates/hono-server/.agents/skills/wizard/agents/openai.yaml +3 -0
  242. package/templates/hono-server/.agents/skills/wizard/template.sh +204 -0
  243. package/templates/hono-server/.agents/skills/writing-for-agents/SKILL-MECHANICS.md +22 -0
  244. package/templates/hono-server/.agents/skills/writing-for-agents/SKILL.md +81 -0
  245. package/templates/hono-server/.agents/skills/writing-for-agents/agents/openai.yaml +3 -0
  246. package/templates/hono-server/.changeset/README.md +8 -0
  247. package/templates/hono-server/.changeset/config.json +11 -0
  248. package/templates/hono-server/.editorconfig +31 -0
  249. package/templates/hono-server/.gitattributes +39 -0
  250. package/templates/hono-server/.vscode/extensions.json +5 -0
  251. package/templates/hono-server/.vscode/launch.json +25 -0
  252. package/templates/hono-server/.vscode/settings.json +24 -0
  253. package/templates/hono-server/AGENTS.md +43 -0
  254. package/templates/hono-server/README.md +31 -0
  255. package/templates/hono-server/_gitignore +30 -0
  256. package/templates/hono-server/apps/server/package.json +54 -0
  257. package/templates/hono-server/apps/server/src/adapters/nodejs/bootstrap.ts +61 -0
  258. package/templates/hono-server/apps/server/src/adapters/nodejs/config.ts +53 -0
  259. package/templates/hono-server/apps/server/src/adapters/nodejs/entry.ts +42 -0
  260. package/templates/hono-server/apps/server/src/app.ts +43 -0
  261. package/templates/hono-server/apps/server/src/infra/logger/getter.ts +74 -0
  262. package/templates/hono-server/apps/server/src/infra/logger/pino.ts +122 -0
  263. package/templates/hono-server/apps/server/src/infra/work-runner/constants.ts +23 -0
  264. package/templates/hono-server/apps/server/src/infra/work-runner/errors.ts +40 -0
  265. package/templates/hono-server/apps/server/src/infra/work-runner/example/runner.test.ts +56 -0
  266. package/templates/hono-server/apps/server/src/infra/work-runner/example/runner.ts +185 -0
  267. package/templates/hono-server/apps/server/src/infra/work-runner/example/worker-entry.ts +34 -0
  268. package/templates/hono-server/apps/server/src/infra/work-runner/types.ts +113 -0
  269. package/templates/hono-server/apps/server/src/infra/work-runner/utils/business-error.ts +19 -0
  270. package/templates/hono-server/apps/server/src/infra/work-runner/utils/message.ts +46 -0
  271. package/templates/hono-server/apps/server/src/infra/work-runner/utils/transfer.ts +144 -0
  272. package/templates/hono-server/apps/server/src/middlewares/cors.ts +26 -0
  273. package/templates/hono-server/apps/server/src/modules/example/contracts.ts +5 -0
  274. package/templates/hono-server/apps/server/src/modules/example/routes.ts +46 -0
  275. package/templates/hono-server/apps/server/src/modules/example/work-task/tasks.test.ts +37 -0
  276. package/templates/hono-server/apps/server/src/modules/example/work-task/tasks.ts +35 -0
  277. package/templates/hono-server/apps/server/src/shared/app/types.ts +45 -0
  278. package/templates/hono-server/apps/server/src/shared/errors/constants.ts +152 -0
  279. package/templates/hono-server/apps/server/src/shared/errors/defs/index.ts +15 -0
  280. package/templates/hono-server/apps/server/src/shared/errors/handler.ts +16 -0
  281. package/templates/hono-server/apps/server/src/shared/errors/log.ts +67 -0
  282. package/templates/hono-server/apps/server/src/shared/errors/proto.ts +42 -0
  283. package/templates/hono-server/apps/server/src/shared/errors/types.ts +29 -0
  284. package/templates/hono-server/apps/server/src/shared/network/fetcher.ts +35 -0
  285. package/templates/hono-server/apps/server/src/shared/network/openapi/index.ts +50 -0
  286. package/templates/hono-server/apps/server/src/shared/network/openapi/res-defs.ts +39 -0
  287. package/templates/hono-server/apps/server/src/shared/network/types.ts +3 -0
  288. package/templates/hono-server/apps/server/src/shared/network/utils.ts +36 -0
  289. package/templates/hono-server/apps/server/src/shared/network/validator.ts +28 -0
  290. package/templates/hono-server/apps/server/src/shared/utils/index.ts +30 -0
  291. package/templates/hono-server/apps/server/src/virtual-modules.d.ts +5 -0
  292. package/templates/hono-server/apps/server/tsconfig.json +16 -0
  293. package/templates/hono-server/apps/server/vite.config.ts +79 -0
  294. package/templates/hono-server/docker/.env.example +4 -0
  295. package/templates/hono-server/docker/README.md +5 -0
  296. package/templates/hono-server/docker/local/compose.local.app.yml +21 -0
  297. package/templates/hono-server/docker/local/local-app-deploy.sh +8 -0
  298. package/templates/hono-server/docker/local/local-app-down.sh +8 -0
  299. package/templates/hono-server/docker/prod/.env.example.server +11 -0
  300. package/templates/hono-server/docker/prod/compose.prod.stack.yml +21 -0
  301. package/templates/hono-server/docker/prod/update.sh +7 -0
  302. package/templates/hono-server/docker/server.Dockerfile +40 -0
  303. package/templates/hono-server/docker/server.Dockerfile.dockerignore +23 -0
  304. package/templates/hono-server/docs/agents/domain.md +41 -0
  305. package/templates/hono-server/docs/agents/issue-tracker.md +30 -0
  306. package/templates/hono-server/docs/agents/triage-labels.md +15 -0
  307. package/templates/hono-server/envs/.env.example.server +12 -0
  308. package/templates/hono-server/libs/definition/package.json +29 -0
  309. package/templates/hono-server/libs/definition/src/backend.ts +2 -0
  310. package/templates/hono-server/libs/definition/src/configs/defs/log.ts +53 -0
  311. package/templates/hono-server/libs/definition/src/configs/defs/middleware.ts +16 -0
  312. package/templates/hono-server/libs/definition/src/configs/defs/runtime.ts +11 -0
  313. package/templates/hono-server/libs/definition/src/configs/defs/worker.ts +29 -0
  314. package/templates/hono-server/libs/definition/src/configs/index.ts +4 -0
  315. package/templates/hono-server/libs/definition/src/configs/proto.ts +81 -0
  316. package/templates/hono-server/libs/definition/src/configs/schema.ts +23 -0
  317. package/templates/hono-server/libs/definition/src/modules/example/index.ts +16 -0
  318. package/templates/hono-server/libs/definition/src/modules/index.ts +1 -0
  319. package/templates/hono-server/libs/definition/tsconfig.json +5 -0
  320. package/templates/hono-server/libs/definition/vite.config.ts +12 -0
  321. package/templates/hono-server/oyo.config.json +11 -0
  322. package/templates/hono-server/package.json +26 -0
  323. package/templates/hono-server/pnpm-workspace.yaml +57 -0
  324. package/templates/hono-server/scripts/.env.example.docker +4 -0
  325. package/templates/hono-server/scripts/build-docker-server.sh +13 -0
  326. package/templates/hono-server/scripts/common.sh +20 -0
  327. package/templates/hono-server/tsconfig.json +4 -0
  328. package/templates/hono-server/turbo.json +14 -0
  329. package/templates/hono-server/vite.config.ts +13 -0
  330. package/templates/monorepo/.agents/skills/ask-matt/PHASE-BOUNDARIES.md +55 -0
  331. package/templates/monorepo/.agents/skills/ask-matt/SKILL.md +90 -0
  332. package/templates/monorepo/.agents/skills/ask-matt/agents/openai.yaml +5 -0
  333. package/templates/monorepo/.agents/skills/code-review/SKILL.md +87 -0
  334. package/templates/monorepo/.agents/skills/code-review/agents/openai.yaml +3 -0
  335. package/templates/monorepo/.agents/skills/codebase-design/DEEPENING.md +37 -0
  336. package/templates/monorepo/.agents/skills/codebase-design/DESIGN-IT-TWICE.md +44 -0
  337. package/templates/monorepo/.agents/skills/codebase-design/SKILL.md +114 -0
  338. package/templates/monorepo/.agents/skills/codebase-design/agents/openai.yaml +3 -0
  339. package/templates/monorepo/.agents/skills/confirm-requirements/SKILL.md +25 -0
  340. package/templates/monorepo/.agents/skills/diagnosing-bugs/SKILL.md +140 -0
  341. package/templates/monorepo/.agents/skills/diagnosing-bugs/agents/openai.yaml +3 -0
  342. package/templates/monorepo/.agents/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +44 -0
  343. package/templates/monorepo/.agents/skills/domain-modeling/ADR-FORMAT.md +47 -0
  344. package/templates/monorepo/.agents/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  345. package/templates/monorepo/.agents/skills/domain-modeling/SKILL.md +74 -0
  346. package/templates/monorepo/.agents/skills/domain-modeling/agents/openai.yaml +3 -0
  347. package/templates/monorepo/.agents/skills/grill-me/SKILL.md +7 -0
  348. package/templates/monorepo/.agents/skills/grill-me/agents/openai.yaml +5 -0
  349. package/templates/monorepo/.agents/skills/grilling/SKILL.md +22 -0
  350. package/templates/monorepo/.agents/skills/grilling/agents/openai.yaml +3 -0
  351. package/templates/monorepo/.agents/skills/implement/SKILL.md +15 -0
  352. package/templates/monorepo/.agents/skills/implement/agents/openai.yaml +5 -0
  353. package/templates/monorepo/.agents/skills/improve-codebase-architecture/HTML-REPORT.md +123 -0
  354. package/templates/monorepo/.agents/skills/improve-codebase-architecture/SKILL.md +71 -0
  355. package/templates/monorepo/.agents/skills/improve-codebase-architecture/agents/openai.yaml +5 -0
  356. package/templates/monorepo/.agents/skills/prototype/LOGIC.md +67 -0
  357. package/templates/monorepo/.agents/skills/prototype/SKILL.md +26 -0
  358. package/templates/monorepo/.agents/skills/prototype/UI.md +112 -0
  359. package/templates/monorepo/.agents/skills/prototype/agents/openai.yaml +3 -0
  360. package/templates/monorepo/.agents/skills/research/SKILL.md +12 -0
  361. package/templates/monorepo/.agents/skills/research/agents/openai.yaml +3 -0
  362. package/templates/monorepo/.agents/skills/resolving-merge-conflicts/SKILL.md +14 -0
  363. package/templates/monorepo/.agents/skills/resolving-merge-conflicts/agents/openai.yaml +3 -0
  364. package/templates/monorepo/.agents/skills/scoped-code-review/SKILL.md +113 -0
  365. package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/SKILL.md +116 -0
  366. package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/agents/openai.yaml +5 -0
  367. package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/domain.md +51 -0
  368. package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/issue-tracker-github.md +45 -0
  369. package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md +46 -0
  370. package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/issue-tracker-local.md +30 -0
  371. package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/triage-labels.md +15 -0
  372. package/templates/monorepo/.agents/skills/tdd/SKILL.md +38 -0
  373. package/templates/monorepo/.agents/skills/tdd/agents/openai.yaml +3 -0
  374. package/templates/monorepo/.agents/skills/tdd/mocking.md +59 -0
  375. package/templates/monorepo/.agents/skills/tdd/tests.md +77 -0
  376. package/templates/monorepo/.agents/skills/teach/GLOSSARY-FORMAT.md +35 -0
  377. package/templates/monorepo/.agents/skills/teach/LEARNING-RECORD-FORMAT.md +46 -0
  378. package/templates/monorepo/.agents/skills/teach/MISSION-FORMAT.md +31 -0
  379. package/templates/monorepo/.agents/skills/teach/RESOURCES-FORMAT.md +32 -0
  380. package/templates/monorepo/.agents/skills/teach/SKILL.md +140 -0
  381. package/templates/monorepo/.agents/skills/teach/agents/openai.yaml +5 -0
  382. package/templates/monorepo/.agents/skills/to-questionnaire/SKILL.md +53 -0
  383. package/templates/monorepo/.agents/skills/to-questionnaire/agents/openai.yaml +5 -0
  384. package/templates/monorepo/.agents/skills/triage/AGENT-BRIEF.md +207 -0
  385. package/templates/monorepo/.agents/skills/triage/OUT-OF-SCOPE.md +105 -0
  386. package/templates/monorepo/.agents/skills/triage/SKILL.md +112 -0
  387. package/templates/monorepo/.agents/skills/triage/agents/openai.yaml +5 -0
  388. package/templates/monorepo/.agents/skills/wait-what/SKILL.md +7 -0
  389. package/templates/monorepo/.agents/skills/wait-what/agents/openai.yaml +5 -0
  390. package/templates/monorepo/.agents/skills/wayfinder/SKILL.md +128 -0
  391. package/templates/monorepo/.agents/skills/wayfinder/agents/openai.yaml +5 -0
  392. package/templates/monorepo/.agents/skills/wizard/SKILL.md +44 -0
  393. package/templates/monorepo/.agents/skills/wizard/agents/openai.yaml +3 -0
  394. package/templates/monorepo/.agents/skills/wizard/template.sh +204 -0
  395. package/templates/monorepo/.agents/skills/writing-for-agents/SKILL-MECHANICS.md +22 -0
  396. package/templates/monorepo/.agents/skills/writing-for-agents/SKILL.md +81 -0
  397. package/templates/monorepo/.agents/skills/writing-for-agents/agents/openai.yaml +3 -0
  398. package/templates/monorepo/.editorconfig +31 -0
  399. package/templates/monorepo/.gitattributes +39 -0
  400. package/templates/monorepo/.vscode/extensions.json +5 -0
  401. package/templates/monorepo/.vscode/launch.json +25 -0
  402. package/templates/monorepo/.vscode/settings.json +3 -1
  403. package/templates/monorepo/AGENTS.md +43 -0
  404. package/templates/monorepo/README.md +27 -0
  405. package/templates/monorepo/_gitignore +8 -0
  406. package/templates/monorepo/docs/agents/domain.md +41 -0
  407. package/templates/monorepo/docs/agents/issue-tracker.md +30 -0
  408. package/templates/monorepo/docs/agents/triage-labels.md +15 -0
  409. package/templates/monorepo/envs/.env.example +1 -0
  410. package/templates/monorepo/oyo.config.json +11 -0
  411. package/templates/monorepo/package.json +24 -0
  412. package/templates/monorepo/pnpm-workspace.yaml +32 -0
  413. package/templates/monorepo/tsconfig.json +4 -0
  414. package/templates/monorepo/turbo.json +14 -0
  415. package/templates/monorepo/vite.config.ts +13 -0
  416. package/templates/monorepo/.vite-hooks/pre-commit +0 -1
  417. /package/templates/{monorepo/_editorconfig → hono-fullstack/.editorconfig} +0 -0
  418. /package/templates/{monorepo/_gitattributes → hono-fullstack/.gitattributes} +0 -0
@@ -0,0 +1,113 @@
1
+ import type { ExampleRunnerTaskModel } from '@/modules/example/work-task/tasks'
2
+ import type { MessagePort, Transferable } from 'node:worker_threads'
3
+ import type { WorkerErrorCode, WorkSubject } from './constants'
4
+
5
+ // export const WorkerInvocationType = Object.freeze({
6
+ // READY: 'READY',
7
+ // TASK: 'TASK',
8
+ // } as const)
9
+ // export type WorkerInvocationType = (typeof WorkerInvocationType)[keyof typeof WorkerInvocationType]
10
+
11
+ // export const WorkerSignalType = Object.freeze({
12
+ // STARTED: 'started',
13
+ // } as const)
14
+ // export type WorkerSignalType = (typeof WorkerSignalType)[keyof typeof WorkerSignalType]
15
+
16
+ export type DefineRunnerTaskModel<
17
+ TSubject extends WorkSubject,
18
+ TInput,
19
+ TOutput,
20
+ TTaskErrorCode extends string = string,
21
+ > = {
22
+ subject: TSubject
23
+ input: TInput
24
+ output: TOutput
25
+ errorCode: TTaskErrorCode | WorkerErrorCode
26
+ }
27
+
28
+ export type AnyRunnerTaskModel = ExampleRunnerTaskModel
29
+
30
+ export type GetRunnerTaskModel<TSubject extends WorkSubject> = Extract<
31
+ AnyRunnerTaskModel,
32
+ { subject: TSubject }
33
+ >
34
+
35
+ export type RunnerTaskParams<TSubject extends WorkSubject> = Pick<
36
+ GetRunnerTaskModel<TSubject>,
37
+ 'input' | 'subject'
38
+ >
39
+ export type RunnerTaskInput<TSubject extends WorkSubject> = GetRunnerTaskModel<TSubject>['input']
40
+ export type RunnerTaskOutput<TSubject extends WorkSubject> = GetRunnerTaskModel<TSubject>['output']
41
+ export type RunnerTaskErrorCode<TSubject extends WorkSubject> =
42
+ GetRunnerTaskModel<TSubject>['errorCode']
43
+
44
+ export type RunnerTaskInvocation<TInput> = {
45
+ input: TInput
46
+ messagePort: MessagePort
47
+ }
48
+
49
+ export type RunnerTaskJsonValue =
50
+ | string
51
+ | number
52
+ | boolean
53
+ | null
54
+ | readonly RunnerTaskJsonValue[]
55
+ | { readonly [key: string]: RunnerTaskJsonValue }
56
+
57
+ /** Worker 通信中的错误详情必须保持为可结构化克隆、可 JSON 序列化的普通数据。 */
58
+ export type RunnerTaskErrorDetails = Readonly<Record<string, RunnerTaskJsonValue>>
59
+
60
+ export type WorkerMessage =
61
+ | {
62
+ type: 'log'
63
+ level: 'debug' | 'info' | 'warn' | 'error'
64
+ message: string
65
+ data?: RunnerTaskErrorDetails
66
+ }
67
+ | {
68
+ type: 'progress'
69
+ value: number
70
+ message?: string
71
+ }
72
+ | {
73
+ type: 'result'
74
+ data: RunnerTaskJsonValue
75
+ }
76
+ | {
77
+ type: 'error'
78
+ error: RunnerTaskError
79
+ }
80
+
81
+ export type RunnerTaskError<TCode extends string = string> = {
82
+ code: TCode
83
+ /** 仅供服务端诊断,不应直接作为 HTTP 响应文案。 */
84
+ message: string
85
+ details?: RunnerTaskErrorDetails
86
+ cause?: unknown
87
+ }
88
+
89
+ export type RunnerTaskResult<TData, TCode extends string = string> =
90
+ | { ok: true; data: TData }
91
+ | { ok: false; error: RunnerTaskError<TCode> }
92
+
93
+ export type RunnerTaskRunResult<TSubject extends WorkSubject> = RunnerTaskResult<
94
+ RunnerTaskOutput<TSubject>,
95
+ RunnerTaskErrorCode<TSubject>
96
+ >
97
+
98
+ export type RunnerTaskRunOptions = {
99
+ signal?: AbortSignal
100
+ transferList?: Transferable[]
101
+ }
102
+
103
+ export interface AppWorkRunner {
104
+ run<TSubject extends WorkSubject>(
105
+ task: RunnerTaskParams<TSubject>,
106
+ options?: RunnerTaskRunOptions,
107
+ ): Promise<RunnerTaskRunResult<TSubject>>
108
+ shutdown(): Promise<void>
109
+ }
110
+
111
+ // 已识别的公共 Worker 错误 Code 由具体任务与业务错误 Code 组合:
112
+ // 队列满、任务超时、Worker 暂不可用等返回失败 DTO;
113
+ // 未识别的 Piscina 异常和程序缺陷仍保持 Promise rejection,不能在此兜底吞掉。
@@ -0,0 +1,19 @@
1
+ import { hasProp } from '@/shared/utils'
2
+ import type { RunnerTaskErrorDetails } from '../types'
3
+
4
+ export class WorkerTaskBusinessError extends Error {
5
+ readonly details?: RunnerTaskErrorDetails
6
+
7
+ constructor(message: string, details?: RunnerTaskErrorDetails, cause?: unknown) {
8
+ super(message, { cause })
9
+ this.name = 'WorkerTaskBusinessError'
10
+ this.details = details
11
+ }
12
+ }
13
+
14
+ export function isWorkerTaskBusinessError(error: unknown): error is WorkerTaskBusinessError {
15
+ return (
16
+ error instanceof WorkerTaskBusinessError ||
17
+ (error instanceof Error && hasProp(error, 'name') && error.name === 'WorkerTaskBusinessError')
18
+ )
19
+ }
@@ -0,0 +1,46 @@
1
+ import type { AppLogger } from '@/shared/app/types'
2
+ import type { RunnerTaskErrorDetails, WorkerMessage } from '../types'
3
+ import type { MessagePort } from 'node:worker_threads'
4
+ import type { WorkSubject } from '../constants'
5
+
6
+ export function workerLog(
7
+ messagePort: MessagePort,
8
+ level: Extract<WorkerMessage, { type: 'log' }>['level'],
9
+ message: string,
10
+ data?: RunnerTaskErrorDetails,
11
+ ): void {
12
+ messagePort.postMessage({ type: 'log', level, message, data } satisfies WorkerMessage)
13
+ }
14
+
15
+ export function workerProgress(messagePort: MessagePort, value: number, message?: string): void {
16
+ messagePort.postMessage({ type: 'progress', value, message } satisfies WorkerMessage)
17
+ }
18
+
19
+ export function handleWorkerMessage(
20
+ message: WorkerMessage,
21
+ logger: AppLogger,
22
+ context: {
23
+ subject: WorkSubject
24
+ },
25
+ ): void {
26
+ switch (message.type) {
27
+ case 'log':
28
+ logger[message.level]({ subject: context.subject, worker: message.data }, message.message)
29
+ break
30
+ case 'progress':
31
+ logger.debug(
32
+ { subject: context.subject, progress: message.value },
33
+ message.message || 'Worker progress',
34
+ )
35
+ break
36
+ case 'result':
37
+ logger.debug({ subject: context.subject }, 'Worker result delivered')
38
+ break
39
+ case 'error':
40
+ logger.warn(
41
+ { subject: context.subject, workerError: message.error },
42
+ 'Worker error delivered',
43
+ )
44
+ break
45
+ }
46
+ }
@@ -0,0 +1,144 @@
1
+ import { isMarkedAsUntransferable } from 'node:worker_threads'
2
+
3
+ export interface TransferableResult<T> {
4
+ value: T
5
+ transferable?: ArrayBuffer
6
+ }
7
+
8
+ /**
9
+ * 排除不需要遍历其属性的原生系统对象(交由 V8 结构化克隆内部处理)
10
+ */
11
+ function isCloneableLeaf(value: unknown): boolean {
12
+ return (
13
+ value instanceof Date ||
14
+ value instanceof RegExp ||
15
+ value instanceof Error ||
16
+ (typeof URL !== 'undefined' && value instanceof URL)
17
+ )
18
+ }
19
+
20
+ /**
21
+ * 转换 ArrayBufferView
22
+ */
23
+ export function toTransferable<T extends ArrayBufferView>(view: T): TransferableResult<T> {
24
+ const buffer = view.buffer
25
+
26
+ // 1. SharedArrayBuffer 或已显式标记为不可转移的 Buffer,原样返回(由系统克隆)
27
+ if (!(buffer instanceof ArrayBuffer) || isMarkedAsUntransferable(buffer)) {
28
+ return { value: view }
29
+ }
30
+
31
+ // 2. 独占且干净的 Buffer:直接转移,零拷贝
32
+ if (view.byteOffset === 0 && view.byteLength === buffer.byteLength) {
33
+ return { value: view, transferable: buffer }
34
+ }
35
+
36
+ // 3. 处于切片/池化状态:切片降级,提取独立 ArrayBuffer
37
+ const newBuffer = buffer.slice(view.byteOffset, view.byteOffset + view.byteLength)
38
+
39
+ // 4. 重新包装 View,修复 Node.js Buffer 的构造函数废弃警告
40
+ let newView: T
41
+ if (typeof Buffer !== 'undefined' && Buffer.isBuffer(view)) {
42
+ newView = Buffer.from(newBuffer) as unknown as T
43
+ } else {
44
+ const Ctor = view.constructor as new (buf: ArrayBuffer) => T
45
+ newView = new Ctor(newBuffer)
46
+ }
47
+
48
+ return {
49
+ value: newView,
50
+ transferable: newBuffer,
51
+ }
52
+ }
53
+
54
+ /**
55
+ * 【主入口】:深层提取 Transferables
56
+ */
57
+ export function extractTransferables(input: any): {
58
+ input: any
59
+ transferList: ArrayBuffer[]
60
+ } {
61
+ const transferables = new Set<ArrayBuffer>()
62
+ const extracted = new WeakMap<object, unknown>()
63
+
64
+ function extract(value: any): any {
65
+ if (!value || typeof value !== 'object') return value
66
+
67
+ // 命中缓存(环状引用 / 重复对象)
68
+ const cached = extracted.get(value)
69
+ if (cached !== undefined) return cached
70
+
71
+ // 裸 ArrayBuffer
72
+ if (value instanceof ArrayBuffer) {
73
+ if (!isMarkedAsUntransferable(value)) {
74
+ transferables.add(value)
75
+ }
76
+ extracted.set(value, value)
77
+ return value
78
+ }
79
+
80
+ // ArrayBufferView (Buffer, TypedArray, DataView)
81
+ if (ArrayBuffer.isView(value)) {
82
+ const { value: transferableView, transferable } = toTransferable(value)
83
+ if (transferable) {
84
+ transferables.add(transferable)
85
+ }
86
+ extracted.set(value, transferableView)
87
+ return transferableView
88
+ }
89
+
90
+ // 遇到原生特殊对象,直接跳过深入遍历
91
+ if (isCloneableLeaf(value)) {
92
+ extracted.set(value, value)
93
+ return value
94
+ }
95
+
96
+ // 场景 4:普通数组
97
+ if (Array.isArray(value)) {
98
+ const array: unknown[] = []
99
+ extracted.set(value, array)
100
+ for (let i = 0; i < value.length; i++) {
101
+ array.push(extract(value[i]))
102
+ }
103
+ return array
104
+ }
105
+
106
+ // 场景 5:Map 和 Set
107
+ if (value instanceof Map) {
108
+ const map = new Map()
109
+ extracted.set(value, map)
110
+ for (const [k, v] of value) {
111
+ map.set(extract(k), extract(v))
112
+ }
113
+ return map
114
+ }
115
+ if (value instanceof Set) {
116
+ const set = new Set()
117
+ extracted.set(value, set)
118
+ for (const v of value) {
119
+ set.add(extract(v))
120
+ }
121
+ return set
122
+ }
123
+
124
+ // 场景 6:普通对象 & 自定义类实例(支持 Symbol 键)
125
+ const proto = Object.getPrototypeOf(value)
126
+ if (proto === null || proto === Object.prototype || (proto && proto.constructor !== Object)) {
127
+ const object: Record<string | symbol, unknown> = {}
128
+ extracted.set(value, object)
129
+
130
+ const keys = Reflect.ownKeys(value)
131
+ for (const key of keys) {
132
+ object[key] = extract(value[key as keyof typeof value])
133
+ }
134
+ return object
135
+ }
136
+
137
+ return value
138
+ }
139
+
140
+ return {
141
+ input: extract(input),
142
+ transferList: [...transferables],
143
+ }
144
+ }
@@ -0,0 +1,26 @@
1
+ import type { AppEnv } from '@/shared/app/types'
2
+ import { cors } from 'hono/cors'
3
+ import { createMiddleware } from 'hono/factory'
4
+
5
+ export const corsMiddleware = () => {
6
+ return createMiddleware<AppEnv>(async (c, next) => {
7
+ const corsConfig = c.get('appConfig')
8
+ const domains = corsConfig.middleware.cors.domains
9
+ const middleware = cors({
10
+ origin: (origin) => {
11
+ const isAllowedDomain = domains.some((domain) => {
12
+ try {
13
+ return domain === '*' || new URL(origin).host === domain
14
+ } catch {
15
+ return false
16
+ }
17
+ })
18
+ return isAllowedDomain ? origin : null
19
+ },
20
+ allowHeaders: ['Content-Type'],
21
+ allowMethods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
22
+ credentials: true,
23
+ })
24
+ return middleware(c, next)
25
+ })
26
+ }
@@ -0,0 +1,9 @@
1
+ import * as v from 'valibot'
2
+
3
+ export const processExampleInputSchema = v.object({
4
+ message: v.pipe(v.string(), v.minLength(1)),
5
+ })
6
+
7
+ export const createExampleInputSchema = v.object({
8
+ message: v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(500)),
9
+ })
@@ -0,0 +1,75 @@
1
+ import { type Context, Hono } from 'hono'
2
+ import { describeRoute } from 'hono-openapi'
3
+ import * as v from 'valibot'
4
+ import { examples, vcExamples, type SqliteDBType } from '@repo/db/sqlite/schema'
5
+ import type { AppEnv } from '@/shared/app/types'
6
+ import { WorkSubject } from '@/infra/work-runner/constants'
7
+ import { E } from '@/shared/errors/defs'
8
+ import { jsonResponse, OpenApiTags } from '@/shared/network/openapi'
9
+ import { successJson } from '@/shared/network/utils'
10
+ import { generalValidator } from '@/shared/network/validator'
11
+ import { createExampleInputSchema, processExampleInputSchema } from './contracts'
12
+
13
+ const getDb = (context: Context<AppEnv>) => context.get('db') as SqliteDBType
14
+
15
+ export const exampleRoutes = new Hono<AppEnv>()
16
+ .get(
17
+ '/health',
18
+ describeRoute({
19
+ operationId: 'getHealth',
20
+ tags: [OpenApiTags.System],
21
+ summary: 'Health check',
22
+ responses: { 200: jsonResponse(v.object({ data: v.object({ status: v.string() }) })) },
23
+ }),
24
+ (c) => successJson(c, { status: 'ok' }),
25
+ )
26
+ .get(
27
+ '/examples',
28
+ describeRoute({
29
+ operationId: 'listExamples',
30
+ tags: [OpenApiTags.Example],
31
+ summary: 'List example rows',
32
+ responses: { 200: { description: 'Example rows' } },
33
+ }),
34
+ async (c) => successJson(c, await getDb(c).select(vcExamples.default).from(examples)),
35
+ )
36
+ .post(
37
+ '/examples',
38
+ describeRoute({
39
+ operationId: 'createExample',
40
+ tags: [OpenApiTags.Example],
41
+ summary: 'Create an example row',
42
+ responses: { 200: { description: 'Created example row' } },
43
+ }),
44
+ generalValidator('json', createExampleInputSchema),
45
+ async (c) => {
46
+ const [row] = await getDb(c)
47
+ .insert(examples)
48
+ .values(c.req.valid('json'))
49
+ .returning(vcExamples.default)
50
+ return successJson(c, row)
51
+ },
52
+ )
53
+ .post(
54
+ '/examples/process',
55
+ describeRoute({
56
+ operationId: 'processExample',
57
+ tags: [OpenApiTags.Example],
58
+ summary: 'Process an example message in the worker pool',
59
+ responses: { 200: jsonResponse(v.object({ data: v.object({ normalized: v.string() }) })) },
60
+ }),
61
+ generalValidator('json', processExampleInputSchema),
62
+ async (c) => {
63
+ const result = await c.get('exampleWorkRunner').run({
64
+ subject: WorkSubject.PROCESS_EXAMPLE,
65
+ input: c.req.valid('json'),
66
+ })
67
+ if (!result.ok) {
68
+ throw E.NORMAL.INTERNAL.create({
69
+ cause: result.error,
70
+ extensions: { workerCode: result.error.code },
71
+ })
72
+ }
73
+ return successJson(c, result.data)
74
+ },
75
+ )
@@ -0,0 +1,37 @@
1
+ import { MessageChannel } from 'node:worker_threads'
2
+ import { describe, expect, it } from 'vite-plus/test'
3
+ import { executeExampleTask } from './tasks'
4
+
5
+ describe('Example worker task', () => {
6
+ it('normalizes a message and reports progress', async () => {
7
+ const { port1, port2 } = new MessageChannel()
8
+ const messages: unknown[] = []
9
+ port1.on('message', (message) => messages.push(message))
10
+ const result = await executeExampleTask({ message: ' hello worker ' }, port2)
11
+ await new Promise<void>((resolve) => setImmediate(resolve))
12
+
13
+ expect(result).toEqual({
14
+ ok: true,
15
+ data: { original: ' hello worker ', normalized: 'hello worker', length: 12 },
16
+ })
17
+ expect(messages).toEqual(
18
+ expect.arrayContaining([
19
+ expect.objectContaining({ type: 'log' }),
20
+ expect.objectContaining({ type: 'progress', value: 100 }),
21
+ ]),
22
+ )
23
+ port1.close()
24
+ port2.close()
25
+ })
26
+
27
+ it('preserves a business exception model', async () => {
28
+ const { port1, port2 } = new MessageChannel()
29
+ await expect(executeExampleTask({ message: ' ' }, port2)).rejects.toMatchObject({
30
+ name: 'WorkerTaskBusinessError',
31
+ message: 'Message must not be empty',
32
+ details: { field: 'message' },
33
+ })
34
+ port1.close()
35
+ port2.close()
36
+ })
37
+ })
@@ -0,0 +1,35 @@
1
+ import type { ProcessExampleInput, ProcessExampleOutput } from '@repo/definition/backend'
2
+ import { type WorkSubject } from '@/infra/work-runner/constants'
3
+ import type { DefineRunnerTaskModel, RunnerTaskResult } from '@/infra/work-runner/types'
4
+ import { WorkerTaskBusinessError } from '@/infra/work-runner/utils/business-error'
5
+ import { workerLog, workerProgress } from '@/infra/work-runner/utils/message'
6
+ import type { MessagePort } from 'node:worker_threads'
7
+
8
+ export type ExampleTaskErrorCode = 'EXAMPLE_PROCESS_FAILED'
9
+
10
+ export type ExampleRunnerTaskModel = DefineRunnerTaskModel<
11
+ typeof WorkSubject.PROCESS_EXAMPLE,
12
+ ProcessExampleInput,
13
+ ProcessExampleOutput,
14
+ ExampleTaskErrorCode
15
+ >
16
+
17
+ export async function executeExampleTask(
18
+ input: ExampleRunnerTaskModel['input'],
19
+ messagePort: MessagePort,
20
+ ): Promise<RunnerTaskResult<ProcessExampleOutput, ExampleTaskErrorCode>> {
21
+ workerLog(messagePort, 'debug', 'Example task started')
22
+ workerProgress(messagePort, 0, 'Validating input')
23
+
24
+ const original = input.message
25
+ const normalized = original.trim().replace(/\s+/g, ' ')
26
+ if (!normalized) {
27
+ throw new WorkerTaskBusinessError('Message must not be empty', { field: 'message' })
28
+ }
29
+
30
+ workerProgress(messagePort, 100, 'Example task completed')
31
+ return {
32
+ ok: true,
33
+ data: { original, normalized, length: normalized.length },
34
+ }
35
+ }
@@ -0,0 +1,45 @@
1
+ import type {
2
+ CORSConfig,
3
+ LogBaseConfig,
4
+ LogPrettyRawConfig,
5
+ LogRollRawConfig,
6
+ LogRollSchemaConfig,
7
+ RuntimeConfig,
8
+ WorkerConfig,
9
+ } from '@repo/definition/backend'
10
+ import type { AppWorkRunner } from '@/infra/work-runner/types'
11
+ import type { MiddlewareHandler, Context } from 'hono'
12
+ import type { PinoLogger as HonoPinoLogger } from 'hono-pino'
13
+ import type { RequestIdVariables } from 'hono/request-id'
14
+
15
+ export type AppLogger = HonoPinoLogger
16
+
17
+ export type LogConfig = {
18
+ base: LogBaseConfig
19
+ roll?: LogRollSchemaConfig & LogRollRawConfig
20
+ pretty?: LogPrettyRawConfig
21
+ }
22
+
23
+ export type AppConfig = {
24
+ runtime: RuntimeConfig & { isLocal: boolean }
25
+ log: LogConfig
26
+ worker: WorkerConfig
27
+ middleware: { cors: CORSConfig }
28
+ }
29
+
30
+ export type AppDependencies = {
31
+ appConfig: AppConfig
32
+ loggerHandler: MiddlewareHandler<{ Variables: { logger: AppLogger } }>
33
+ exampleWorkRunner: AppWorkRunner
34
+ /** Fullstack injects its SQLite database; standalone intentionally leaves this absent. */
35
+ db?: unknown
36
+ }
37
+
38
+ export type AppEnv = {
39
+ Variables: RequestIdVariables & AppDependencies & { logger?: AppLogger }
40
+ }
41
+
42
+ export type CreateAppOptions = {
43
+ basePath?: string
44
+ makeDependencies: (c: Context<AppEnv>) => Promise<AppDependencies> | AppDependencies
45
+ }