@oyolincc/create 0.2.0 → 0.3.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 (448) 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 +29 -13
  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/.editorconfig +31 -0
  76. package/templates/hono-fullstack/.gitattributes +39 -0
  77. package/templates/hono-fullstack/.vscode/extensions.json +5 -0
  78. package/templates/hono-fullstack/.vscode/launch.json +36 -0
  79. package/templates/hono-fullstack/.vscode/settings.json +26 -0
  80. package/templates/hono-fullstack/AGENTS.md +50 -0
  81. package/templates/hono-fullstack/README.md +51 -0
  82. package/templates/hono-fullstack/_gitignore +35 -0
  83. package/templates/hono-fullstack/apps/server/.dev.vars.example +9 -0
  84. package/templates/hono-fullstack/apps/server/package.json +63 -0
  85. package/templates/hono-fullstack/apps/server/src/adapters/cloudflare/entry.ts +36 -0
  86. package/templates/hono-fullstack/apps/server/src/adapters/nodejs/bootstrap.ts +61 -0
  87. package/templates/hono-fullstack/apps/server/src/adapters/nodejs/entry.ts +62 -0
  88. package/templates/hono-fullstack/apps/server/src/app.ts +43 -0
  89. package/templates/hono-fullstack/apps/server/src/config.ts +47 -0
  90. package/templates/hono-fullstack/apps/server/src/infra/logger/getter.ts +74 -0
  91. package/templates/hono-fullstack/apps/server/src/infra/logger/pino.ts +126 -0
  92. package/templates/hono-fullstack/apps/server/src/infra/work-runner/constants.ts +23 -0
  93. package/templates/hono-fullstack/apps/server/src/infra/work-runner/errors.ts +40 -0
  94. package/templates/hono-fullstack/apps/server/src/infra/work-runner/example/worker-entry.ts +13 -0
  95. package/templates/hono-fullstack/apps/server/src/infra/work-runner/pass-through/runner.ts +42 -0
  96. package/templates/hono-fullstack/apps/server/src/infra/work-runner/piscina/runner.ts +185 -0
  97. package/templates/hono-fullstack/apps/server/src/infra/work-runner/types.ts +118 -0
  98. package/templates/hono-fullstack/apps/server/src/infra/work-runner/utils/business-error.ts +19 -0
  99. package/templates/hono-fullstack/apps/server/src/infra/work-runner/utils/message.ts +49 -0
  100. package/templates/hono-fullstack/apps/server/src/infra/work-runner/utils/transfer.ts +144 -0
  101. package/templates/hono-fullstack/apps/server/src/middlewares/cors.ts +26 -0
  102. package/templates/hono-fullstack/apps/server/src/modules/example/contracts.ts +9 -0
  103. package/templates/hono-fullstack/apps/server/src/modules/example/routes.ts +73 -0
  104. package/templates/hono-fullstack/apps/server/src/modules/example/work-task/tasks.test.ts +49 -0
  105. package/templates/hono-fullstack/apps/server/src/modules/example/work-task/tasks.ts +58 -0
  106. package/templates/hono-fullstack/apps/server/src/shared/app/types.ts +44 -0
  107. package/templates/hono-fullstack/apps/server/src/shared/errors/constants.ts +152 -0
  108. package/templates/hono-fullstack/apps/server/src/shared/errors/defs/index.ts +15 -0
  109. package/templates/hono-fullstack/apps/server/src/shared/errors/handler.ts +16 -0
  110. package/templates/hono-fullstack/apps/server/src/shared/errors/log.ts +67 -0
  111. package/templates/hono-fullstack/apps/server/src/shared/errors/proto.ts +42 -0
  112. package/templates/hono-fullstack/apps/server/src/shared/errors/types.ts +29 -0
  113. package/templates/hono-fullstack/apps/server/src/shared/network/fetcher.ts +35 -0
  114. package/templates/hono-fullstack/apps/server/src/shared/network/openapi/index.ts +50 -0
  115. package/templates/hono-fullstack/apps/server/src/shared/network/openapi/res-defs.ts +39 -0
  116. package/templates/hono-fullstack/apps/server/src/shared/network/types.ts +3 -0
  117. package/templates/hono-fullstack/apps/server/src/shared/network/utils.ts +36 -0
  118. package/templates/hono-fullstack/apps/server/src/shared/network/validator.ts +28 -0
  119. package/templates/hono-fullstack/apps/server/src/shared/utils/index.ts +30 -0
  120. package/templates/hono-fullstack/apps/server/src/virtual-modules.d.ts +5 -0
  121. package/templates/hono-fullstack/apps/server/tsconfig.json +17 -0
  122. package/templates/hono-fullstack/apps/server/vite.config.ts +87 -0
  123. package/templates/hono-fullstack/apps/server/wrangler.jsonc +29 -0
  124. package/templates/hono-fullstack/apps/stack/backend/cloudflare.ts +5 -0
  125. package/templates/hono-fullstack/apps/stack/backend/node.ts +3 -0
  126. package/templates/hono-fullstack/apps/stack/frontend/components/general/ErrorMessage.tsx +4 -0
  127. package/templates/hono-fullstack/apps/stack/frontend/components/layouts/AppLayout.tsx +11 -0
  128. package/templates/hono-fullstack/apps/stack/frontend/components/layouts/Header.tsx +7 -0
  129. package/templates/hono-fullstack/apps/stack/frontend/components/layouts/Page.tsx +5 -0
  130. package/templates/hono-fullstack/apps/stack/frontend/components/layouts/PageContainer.tsx +5 -0
  131. package/templates/hono-fullstack/apps/stack/frontend/modules/example/api.ts +13 -0
  132. package/templates/hono-fullstack/apps/stack/frontend/modules/example/components/ExampleForm.tsx +45 -0
  133. package/templates/hono-fullstack/apps/stack/frontend/modules/example/components/ExampleList.tsx +13 -0
  134. package/templates/hono-fullstack/apps/stack/frontend/modules/example/hooks/api-hooks.ts +14 -0
  135. package/templates/hono-fullstack/apps/stack/frontend/modules/example/stores/index.ts +3 -0
  136. package/templates/hono-fullstack/apps/stack/frontend/routeTree.gen.ts +73 -0
  137. package/templates/hono-fullstack/apps/stack/frontend/router.tsx +22 -0
  138. package/templates/hono-fullstack/apps/stack/frontend/routes/__root.tsx +61 -0
  139. package/templates/hono-fullstack/apps/stack/frontend/routes/api/$.ts +18 -0
  140. package/templates/hono-fullstack/apps/stack/frontend/routes/index.tsx +50 -0
  141. package/templates/hono-fullstack/apps/stack/frontend/shared/network/client.ts +19 -0
  142. package/templates/hono-fullstack/apps/stack/frontend/shared/network/constants.ts +1 -0
  143. package/templates/hono-fullstack/apps/stack/frontend/shared/network/errors.ts +33 -0
  144. package/templates/hono-fullstack/apps/stack/frontend/styles.css +23 -0
  145. package/templates/hono-fullstack/apps/stack/frontend/vite-env.d.ts +6 -0
  146. package/templates/hono-fullstack/apps/stack/package.json +59 -0
  147. package/templates/hono-fullstack/apps/stack/tsconfig.json +13 -0
  148. package/templates/hono-fullstack/apps/stack/tsr.config.json +5 -0
  149. package/templates/hono-fullstack/apps/stack/vite.config.ts +82 -0
  150. package/templates/hono-fullstack/apps/stack/wrangler.jsonc +20 -0
  151. package/templates/hono-fullstack/docs/agents/domain.md +41 -0
  152. package/templates/hono-fullstack/docs/agents/issue-tracker.md +30 -0
  153. package/templates/hono-fullstack/docs/agents/triage-labels.md +15 -0
  154. package/templates/hono-fullstack/envs/.env.example.server +12 -0
  155. package/templates/hono-fullstack/envs/.env.example.sqlite +1 -0
  156. package/templates/hono-fullstack/envs/.env.example.sqlite-d1 +3 -0
  157. package/templates/hono-fullstack/libs/db/drizzle-kit/sqlite-d1.config.ts +22 -0
  158. package/templates/hono-fullstack/libs/db/drizzle-kit/sqlite.config.ts +22 -0
  159. package/templates/hono-fullstack/libs/db/package.json +42 -0
  160. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/client.ts +35 -0
  161. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/d1-client.ts +12 -0
  162. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/columns.ts +37 -0
  163. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/index.ts +7 -0
  164. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/modules/examples/examples.ts +22 -0
  165. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/relations.ts +5 -0
  166. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/tables.ts +5 -0
  167. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/types.ts +7 -0
  168. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/vo.ts +1 -0
  169. package/templates/hono-fullstack/libs/db/src/dialects/sqlite/utils.ts +8 -0
  170. package/templates/hono-fullstack/libs/db/src/shared/types.ts +26 -0
  171. package/templates/hono-fullstack/libs/db/tsconfig.json +10 -0
  172. package/templates/hono-fullstack/libs/db/vite.config.ts +25 -0
  173. package/templates/hono-fullstack/libs/definition/package.json +30 -0
  174. package/templates/hono-fullstack/libs/definition/src/backend.ts +2 -0
  175. package/templates/hono-fullstack/libs/definition/src/configs/defs/log.ts +53 -0
  176. package/templates/hono-fullstack/libs/definition/src/configs/defs/middleware.ts +16 -0
  177. package/templates/hono-fullstack/libs/definition/src/configs/defs/runtime.ts +12 -0
  178. package/templates/hono-fullstack/libs/definition/src/configs/defs/sqlite.ts +26 -0
  179. package/templates/hono-fullstack/libs/definition/src/configs/defs/worker.ts +29 -0
  180. package/templates/hono-fullstack/libs/definition/src/configs/index.ts +5 -0
  181. package/templates/hono-fullstack/libs/definition/src/configs/proto.ts +81 -0
  182. package/templates/hono-fullstack/libs/definition/src/configs/schema.ts +23 -0
  183. package/templates/hono-fullstack/libs/definition/src/frontend.ts +1 -0
  184. package/templates/hono-fullstack/libs/definition/src/modules/example/index.ts +16 -0
  185. package/templates/hono-fullstack/libs/definition/src/modules/index.ts +1 -0
  186. package/templates/hono-fullstack/libs/definition/tsconfig.json +5 -0
  187. package/templates/hono-fullstack/libs/definition/vite.config.ts +16 -0
  188. package/templates/hono-fullstack/oyo.config.json +13 -0
  189. package/templates/hono-fullstack/package.json +25 -0
  190. package/templates/hono-fullstack/pnpm-workspace.yaml +84 -0
  191. package/templates/hono-fullstack/tsconfig.json +4 -0
  192. package/templates/hono-fullstack/turbo.json +36 -0
  193. package/templates/hono-fullstack/vite.config.ts +14 -0
  194. package/templates/hono-server/.agents/skills/ask-matt/PHASE-BOUNDARIES.md +55 -0
  195. package/templates/hono-server/.agents/skills/ask-matt/SKILL.md +90 -0
  196. package/templates/hono-server/.agents/skills/ask-matt/agents/openai.yaml +5 -0
  197. package/templates/hono-server/.agents/skills/code-review/SKILL.md +87 -0
  198. package/templates/hono-server/.agents/skills/code-review/agents/openai.yaml +3 -0
  199. package/templates/hono-server/.agents/skills/codebase-design/DEEPENING.md +37 -0
  200. package/templates/hono-server/.agents/skills/codebase-design/DESIGN-IT-TWICE.md +44 -0
  201. package/templates/hono-server/.agents/skills/codebase-design/SKILL.md +114 -0
  202. package/templates/hono-server/.agents/skills/codebase-design/agents/openai.yaml +3 -0
  203. package/templates/hono-server/.agents/skills/confirm-requirements/SKILL.md +25 -0
  204. package/templates/hono-server/.agents/skills/diagnosing-bugs/SKILL.md +140 -0
  205. package/templates/hono-server/.agents/skills/diagnosing-bugs/agents/openai.yaml +3 -0
  206. package/templates/hono-server/.agents/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +44 -0
  207. package/templates/hono-server/.agents/skills/domain-modeling/ADR-FORMAT.md +47 -0
  208. package/templates/hono-server/.agents/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  209. package/templates/hono-server/.agents/skills/domain-modeling/SKILL.md +74 -0
  210. package/templates/hono-server/.agents/skills/domain-modeling/agents/openai.yaml +3 -0
  211. package/templates/hono-server/.agents/skills/grill-me/SKILL.md +7 -0
  212. package/templates/hono-server/.agents/skills/grill-me/agents/openai.yaml +5 -0
  213. package/templates/hono-server/.agents/skills/grilling/SKILL.md +22 -0
  214. package/templates/hono-server/.agents/skills/grilling/agents/openai.yaml +3 -0
  215. package/templates/hono-server/.agents/skills/implement/SKILL.md +15 -0
  216. package/templates/hono-server/.agents/skills/implement/agents/openai.yaml +5 -0
  217. package/templates/hono-server/.agents/skills/improve-codebase-architecture/HTML-REPORT.md +123 -0
  218. package/templates/hono-server/.agents/skills/improve-codebase-architecture/SKILL.md +71 -0
  219. package/templates/hono-server/.agents/skills/improve-codebase-architecture/agents/openai.yaml +5 -0
  220. package/templates/hono-server/.agents/skills/prototype/LOGIC.md +67 -0
  221. package/templates/hono-server/.agents/skills/prototype/SKILL.md +26 -0
  222. package/templates/hono-server/.agents/skills/prototype/UI.md +112 -0
  223. package/templates/hono-server/.agents/skills/prototype/agents/openai.yaml +3 -0
  224. package/templates/hono-server/.agents/skills/research/SKILL.md +12 -0
  225. package/templates/hono-server/.agents/skills/research/agents/openai.yaml +3 -0
  226. package/templates/hono-server/.agents/skills/resolving-merge-conflicts/SKILL.md +14 -0
  227. package/templates/hono-server/.agents/skills/resolving-merge-conflicts/agents/openai.yaml +3 -0
  228. package/templates/hono-server/.agents/skills/scoped-code-review/SKILL.md +113 -0
  229. package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/SKILL.md +116 -0
  230. package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/agents/openai.yaml +5 -0
  231. package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/domain.md +51 -0
  232. package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/issue-tracker-github.md +45 -0
  233. package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md +46 -0
  234. package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/issue-tracker-local.md +30 -0
  235. package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/triage-labels.md +15 -0
  236. package/templates/hono-server/.agents/skills/tdd/SKILL.md +38 -0
  237. package/templates/hono-server/.agents/skills/tdd/agents/openai.yaml +3 -0
  238. package/templates/hono-server/.agents/skills/tdd/mocking.md +59 -0
  239. package/templates/hono-server/.agents/skills/tdd/tests.md +77 -0
  240. package/templates/hono-server/.agents/skills/teach/GLOSSARY-FORMAT.md +35 -0
  241. package/templates/hono-server/.agents/skills/teach/LEARNING-RECORD-FORMAT.md +46 -0
  242. package/templates/hono-server/.agents/skills/teach/MISSION-FORMAT.md +31 -0
  243. package/templates/hono-server/.agents/skills/teach/RESOURCES-FORMAT.md +32 -0
  244. package/templates/hono-server/.agents/skills/teach/SKILL.md +140 -0
  245. package/templates/hono-server/.agents/skills/teach/agents/openai.yaml +5 -0
  246. package/templates/hono-server/.agents/skills/to-questionnaire/SKILL.md +53 -0
  247. package/templates/hono-server/.agents/skills/to-questionnaire/agents/openai.yaml +5 -0
  248. package/templates/hono-server/.agents/skills/triage/AGENT-BRIEF.md +207 -0
  249. package/templates/hono-server/.agents/skills/triage/OUT-OF-SCOPE.md +105 -0
  250. package/templates/hono-server/.agents/skills/triage/SKILL.md +112 -0
  251. package/templates/hono-server/.agents/skills/triage/agents/openai.yaml +5 -0
  252. package/templates/hono-server/.agents/skills/wait-what/SKILL.md +7 -0
  253. package/templates/hono-server/.agents/skills/wait-what/agents/openai.yaml +5 -0
  254. package/templates/hono-server/.agents/skills/wayfinder/SKILL.md +128 -0
  255. package/templates/hono-server/.agents/skills/wayfinder/agents/openai.yaml +5 -0
  256. package/templates/hono-server/.agents/skills/wizard/SKILL.md +44 -0
  257. package/templates/hono-server/.agents/skills/wizard/agents/openai.yaml +3 -0
  258. package/templates/hono-server/.agents/skills/wizard/template.sh +204 -0
  259. package/templates/hono-server/.agents/skills/writing-for-agents/SKILL-MECHANICS.md +22 -0
  260. package/templates/hono-server/.agents/skills/writing-for-agents/SKILL.md +81 -0
  261. package/templates/hono-server/.agents/skills/writing-for-agents/agents/openai.yaml +3 -0
  262. package/templates/hono-server/.changeset/README.md +8 -0
  263. package/templates/hono-server/.changeset/config.json +11 -0
  264. package/templates/hono-server/.editorconfig +31 -0
  265. package/templates/hono-server/.gitattributes +39 -0
  266. package/templates/hono-server/.vscode/extensions.json +5 -0
  267. package/templates/hono-server/.vscode/launch.json +29 -0
  268. package/templates/hono-server/.vscode/settings.json +26 -0
  269. package/templates/hono-server/AGENTS.md +50 -0
  270. package/templates/hono-server/README.md +44 -0
  271. package/templates/hono-server/_gitignore +35 -0
  272. package/templates/hono-server/apps/server/.dev.vars.example +9 -0
  273. package/templates/hono-server/apps/server/package.json +64 -0
  274. package/templates/hono-server/apps/server/src/adapters/cloudflare/entry.ts +36 -0
  275. package/templates/hono-server/apps/server/src/adapters/nodejs/bootstrap.ts +61 -0
  276. package/templates/hono-server/apps/server/src/adapters/nodejs/entry.ts +62 -0
  277. package/templates/hono-server/apps/server/src/app.ts +43 -0
  278. package/templates/hono-server/apps/server/src/config.ts +47 -0
  279. package/templates/hono-server/apps/server/src/infra/logger/getter.ts +74 -0
  280. package/templates/hono-server/apps/server/src/infra/logger/pino.ts +126 -0
  281. package/templates/hono-server/apps/server/src/infra/work-runner/constants.ts +23 -0
  282. package/templates/hono-server/apps/server/src/infra/work-runner/errors.ts +40 -0
  283. package/templates/hono-server/apps/server/src/infra/work-runner/example/worker-entry.ts +13 -0
  284. package/templates/hono-server/apps/server/src/infra/work-runner/pass-through/runner.ts +42 -0
  285. package/templates/hono-server/apps/server/src/infra/work-runner/piscina/runner.ts +185 -0
  286. package/templates/hono-server/apps/server/src/infra/work-runner/types.ts +118 -0
  287. package/templates/hono-server/apps/server/src/infra/work-runner/utils/business-error.ts +19 -0
  288. package/templates/hono-server/apps/server/src/infra/work-runner/utils/message.ts +49 -0
  289. package/templates/hono-server/apps/server/src/infra/work-runner/utils/transfer.ts +144 -0
  290. package/templates/hono-server/apps/server/src/middlewares/cors.ts +26 -0
  291. package/templates/hono-server/apps/server/src/modules/example/contracts.ts +9 -0
  292. package/templates/hono-server/apps/server/src/modules/example/routes.ts +73 -0
  293. package/templates/hono-server/apps/server/src/modules/example/work-task/tasks.test.ts +49 -0
  294. package/templates/hono-server/apps/server/src/modules/example/work-task/tasks.ts +58 -0
  295. package/templates/hono-server/apps/server/src/shared/app/types.ts +44 -0
  296. package/templates/hono-server/apps/server/src/shared/errors/constants.ts +152 -0
  297. package/templates/hono-server/apps/server/src/shared/errors/defs/index.ts +15 -0
  298. package/templates/hono-server/apps/server/src/shared/errors/handler.ts +16 -0
  299. package/templates/hono-server/apps/server/src/shared/errors/log.ts +67 -0
  300. package/templates/hono-server/apps/server/src/shared/errors/proto.ts +42 -0
  301. package/templates/hono-server/apps/server/src/shared/errors/types.ts +29 -0
  302. package/templates/hono-server/apps/server/src/shared/network/fetcher.ts +35 -0
  303. package/templates/hono-server/apps/server/src/shared/network/openapi/index.ts +50 -0
  304. package/templates/hono-server/apps/server/src/shared/network/openapi/res-defs.ts +39 -0
  305. package/templates/hono-server/apps/server/src/shared/network/types.ts +3 -0
  306. package/templates/hono-server/apps/server/src/shared/network/utils.ts +36 -0
  307. package/templates/hono-server/apps/server/src/shared/network/validator.ts +28 -0
  308. package/templates/hono-server/apps/server/src/shared/utils/index.ts +30 -0
  309. package/templates/hono-server/apps/server/src/virtual-modules.d.ts +5 -0
  310. package/templates/hono-server/apps/server/tsconfig.json +17 -0
  311. package/templates/hono-server/apps/server/vite.config.ts +87 -0
  312. package/templates/hono-server/apps/server/wrangler.jsonc +29 -0
  313. package/templates/hono-server/docker/.env.example +4 -0
  314. package/templates/hono-server/docker/README.md +5 -0
  315. package/templates/hono-server/docker/local/compose.local.app.yml +21 -0
  316. package/templates/hono-server/docker/local/local-app-deploy.sh +8 -0
  317. package/templates/hono-server/docker/local/local-app-down.sh +8 -0
  318. package/templates/hono-server/docker/prod/.env.example.server +11 -0
  319. package/templates/hono-server/docker/prod/compose.prod.stack.yml +21 -0
  320. package/templates/hono-server/docker/prod/update.sh +7 -0
  321. package/templates/hono-server/docker/server.Dockerfile +38 -0
  322. package/templates/hono-server/docker/server.Dockerfile.dockerignore +23 -0
  323. package/templates/hono-server/docs/agents/domain.md +41 -0
  324. package/templates/hono-server/docs/agents/issue-tracker.md +30 -0
  325. package/templates/hono-server/docs/agents/triage-labels.md +15 -0
  326. package/templates/hono-server/envs/.env.example.server +12 -0
  327. package/templates/hono-server/envs/.env.example.sqlite +1 -0
  328. package/templates/hono-server/envs/.env.example.sqlite-d1 +3 -0
  329. package/templates/hono-server/libs/db/drizzle-kit/sqlite-d1.config.ts +22 -0
  330. package/templates/hono-server/libs/db/drizzle-kit/sqlite.config.ts +22 -0
  331. package/templates/hono-server/libs/db/package.json +42 -0
  332. package/templates/hono-server/libs/db/src/dialects/sqlite/client.ts +35 -0
  333. package/templates/hono-server/libs/db/src/dialects/sqlite/d1-client.ts +12 -0
  334. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/columns.ts +37 -0
  335. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/index.ts +7 -0
  336. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/modules/examples/examples.ts +22 -0
  337. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/relations.ts +5 -0
  338. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/tables.ts +5 -0
  339. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/types.ts +7 -0
  340. package/templates/hono-server/libs/db/src/dialects/sqlite/schema/vo.ts +1 -0
  341. package/templates/hono-server/libs/db/src/dialects/sqlite/utils.ts +8 -0
  342. package/templates/hono-server/libs/db/src/shared/types.ts +26 -0
  343. package/templates/hono-server/libs/db/tsconfig.json +10 -0
  344. package/templates/hono-server/libs/db/vite.config.ts +25 -0
  345. package/templates/hono-server/libs/definition/package.json +29 -0
  346. package/templates/hono-server/libs/definition/src/backend.ts +2 -0
  347. package/templates/hono-server/libs/definition/src/configs/defs/log.ts +53 -0
  348. package/templates/hono-server/libs/definition/src/configs/defs/middleware.ts +16 -0
  349. package/templates/hono-server/libs/definition/src/configs/defs/runtime.ts +12 -0
  350. package/templates/hono-server/libs/definition/src/configs/defs/sqlite.ts +26 -0
  351. package/templates/hono-server/libs/definition/src/configs/defs/worker.ts +29 -0
  352. package/templates/hono-server/libs/definition/src/configs/index.ts +5 -0
  353. package/templates/hono-server/libs/definition/src/configs/proto.ts +81 -0
  354. package/templates/hono-server/libs/definition/src/configs/schema.ts +23 -0
  355. package/templates/hono-server/libs/definition/src/modules/example/index.ts +16 -0
  356. package/templates/hono-server/libs/definition/src/modules/index.ts +1 -0
  357. package/templates/hono-server/libs/definition/tsconfig.json +5 -0
  358. package/templates/hono-server/libs/definition/vite.config.ts +15 -0
  359. package/templates/hono-server/oyo.config.json +13 -0
  360. package/templates/hono-server/package.json +25 -0
  361. package/templates/hono-server/pnpm-workspace.yaml +66 -0
  362. package/templates/hono-server/scripts/.env.example.docker +4 -0
  363. package/templates/hono-server/scripts/build-docker-server.sh +13 -0
  364. package/templates/hono-server/scripts/common.sh +20 -0
  365. package/templates/hono-server/tsconfig.json +4 -0
  366. package/templates/hono-server/turbo.json +36 -0
  367. package/templates/hono-server/vite.config.ts +14 -0
  368. package/templates/monorepo/.agents/skills/ask-matt/PHASE-BOUNDARIES.md +55 -0
  369. package/templates/monorepo/.agents/skills/ask-matt/SKILL.md +90 -0
  370. package/templates/monorepo/.agents/skills/ask-matt/agents/openai.yaml +5 -0
  371. package/templates/monorepo/.agents/skills/code-review/SKILL.md +87 -0
  372. package/templates/monorepo/.agents/skills/code-review/agents/openai.yaml +3 -0
  373. package/templates/monorepo/.agents/skills/codebase-design/DEEPENING.md +37 -0
  374. package/templates/monorepo/.agents/skills/codebase-design/DESIGN-IT-TWICE.md +44 -0
  375. package/templates/monorepo/.agents/skills/codebase-design/SKILL.md +114 -0
  376. package/templates/monorepo/.agents/skills/codebase-design/agents/openai.yaml +3 -0
  377. package/templates/monorepo/.agents/skills/confirm-requirements/SKILL.md +25 -0
  378. package/templates/monorepo/.agents/skills/diagnosing-bugs/SKILL.md +140 -0
  379. package/templates/monorepo/.agents/skills/diagnosing-bugs/agents/openai.yaml +3 -0
  380. package/templates/monorepo/.agents/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +44 -0
  381. package/templates/monorepo/.agents/skills/domain-modeling/ADR-FORMAT.md +47 -0
  382. package/templates/monorepo/.agents/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
  383. package/templates/monorepo/.agents/skills/domain-modeling/SKILL.md +74 -0
  384. package/templates/monorepo/.agents/skills/domain-modeling/agents/openai.yaml +3 -0
  385. package/templates/monorepo/.agents/skills/grill-me/SKILL.md +7 -0
  386. package/templates/monorepo/.agents/skills/grill-me/agents/openai.yaml +5 -0
  387. package/templates/monorepo/.agents/skills/grilling/SKILL.md +22 -0
  388. package/templates/monorepo/.agents/skills/grilling/agents/openai.yaml +3 -0
  389. package/templates/monorepo/.agents/skills/implement/SKILL.md +15 -0
  390. package/templates/monorepo/.agents/skills/implement/agents/openai.yaml +5 -0
  391. package/templates/monorepo/.agents/skills/improve-codebase-architecture/HTML-REPORT.md +123 -0
  392. package/templates/monorepo/.agents/skills/improve-codebase-architecture/SKILL.md +71 -0
  393. package/templates/monorepo/.agents/skills/improve-codebase-architecture/agents/openai.yaml +5 -0
  394. package/templates/monorepo/.agents/skills/prototype/LOGIC.md +67 -0
  395. package/templates/monorepo/.agents/skills/prototype/SKILL.md +26 -0
  396. package/templates/monorepo/.agents/skills/prototype/UI.md +112 -0
  397. package/templates/monorepo/.agents/skills/prototype/agents/openai.yaml +3 -0
  398. package/templates/monorepo/.agents/skills/research/SKILL.md +12 -0
  399. package/templates/monorepo/.agents/skills/research/agents/openai.yaml +3 -0
  400. package/templates/monorepo/.agents/skills/resolving-merge-conflicts/SKILL.md +14 -0
  401. package/templates/monorepo/.agents/skills/resolving-merge-conflicts/agents/openai.yaml +3 -0
  402. package/templates/monorepo/.agents/skills/scoped-code-review/SKILL.md +113 -0
  403. package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/SKILL.md +116 -0
  404. package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/agents/openai.yaml +5 -0
  405. package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/domain.md +51 -0
  406. package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/issue-tracker-github.md +45 -0
  407. package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md +46 -0
  408. package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/issue-tracker-local.md +30 -0
  409. package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/triage-labels.md +15 -0
  410. package/templates/monorepo/.agents/skills/tdd/SKILL.md +38 -0
  411. package/templates/monorepo/.agents/skills/tdd/agents/openai.yaml +3 -0
  412. package/templates/monorepo/.agents/skills/tdd/mocking.md +59 -0
  413. package/templates/monorepo/.agents/skills/tdd/tests.md +77 -0
  414. package/templates/monorepo/.agents/skills/teach/GLOSSARY-FORMAT.md +35 -0
  415. package/templates/monorepo/.agents/skills/teach/LEARNING-RECORD-FORMAT.md +46 -0
  416. package/templates/monorepo/.agents/skills/teach/MISSION-FORMAT.md +31 -0
  417. package/templates/monorepo/.agents/skills/teach/RESOURCES-FORMAT.md +32 -0
  418. package/templates/monorepo/.agents/skills/teach/SKILL.md +140 -0
  419. package/templates/monorepo/.agents/skills/teach/agents/openai.yaml +5 -0
  420. package/templates/monorepo/.agents/skills/to-questionnaire/SKILL.md +53 -0
  421. package/templates/monorepo/.agents/skills/to-questionnaire/agents/openai.yaml +5 -0
  422. package/templates/monorepo/.agents/skills/triage/AGENT-BRIEF.md +207 -0
  423. package/templates/monorepo/.agents/skills/triage/OUT-OF-SCOPE.md +105 -0
  424. package/templates/monorepo/.agents/skills/triage/SKILL.md +112 -0
  425. package/templates/monorepo/.agents/skills/triage/agents/openai.yaml +5 -0
  426. package/templates/monorepo/.agents/skills/wait-what/SKILL.md +7 -0
  427. package/templates/monorepo/.agents/skills/wait-what/agents/openai.yaml +5 -0
  428. package/templates/monorepo/.agents/skills/wayfinder/SKILL.md +128 -0
  429. package/templates/monorepo/.agents/skills/wayfinder/agents/openai.yaml +5 -0
  430. package/templates/monorepo/.agents/skills/wizard/SKILL.md +44 -0
  431. package/templates/monorepo/.agents/skills/wizard/agents/openai.yaml +3 -0
  432. package/templates/monorepo/.agents/skills/wizard/template.sh +204 -0
  433. package/templates/monorepo/.agents/skills/writing-for-agents/SKILL-MECHANICS.md +22 -0
  434. package/templates/monorepo/.agents/skills/writing-for-agents/SKILL.md +81 -0
  435. package/templates/monorepo/.agents/skills/writing-for-agents/agents/openai.yaml +3 -0
  436. package/templates/monorepo/.vscode/extensions.json +5 -0
  437. package/templates/monorepo/.vscode/launch.json +0 -3
  438. package/templates/monorepo/.vscode/settings.json +3 -1
  439. package/templates/monorepo/AGENTS.md +50 -0
  440. package/templates/monorepo/README.md +27 -0
  441. package/templates/monorepo/_gitignore +5 -0
  442. package/templates/monorepo/docs/agents/domain.md +41 -0
  443. package/templates/monorepo/docs/agents/issue-tracker.md +30 -0
  444. package/templates/monorepo/docs/agents/triage-labels.md +15 -0
  445. package/templates/monorepo/package.json +4 -3
  446. package/templates/monorepo/pnpm-workspace.yaml +23 -26
  447. package/templates/monorepo/turbo.json +27 -3
  448. package/templates/monorepo/vite.config.ts +1 -0
@@ -0,0 +1,152 @@
1
+ import { fz } from '@/shared/utils'
2
+
3
+ // /* 参考自 grpc code */
4
+ // export const ErrorCode = fz({
5
+ // // 操作已被取消,通常由调用方取消。
6
+ // //
7
+ // // HTTP 映射:499 Client Closed Request
8
+ // CANCELLED: 'CANCELLED',
9
+
10
+ // // 未知错误。例如,当从另一个地址空间接收到的 `Status` 值
11
+ // // 属于本地址空间未知的错误空间时,可能返回此错误。此外,
12
+ // // 未返回足够错误信息的 API 所抛出的错误也可能被转换为此错误。
13
+ // //
14
+ // // HTTP 映射:500 Internal Server Error
15
+ // UNKNOWN: 'UNKNOWN',
16
+
17
+ // // 客户端指定了无效参数。注意这与 `FAILED_PRECONDITION` 不同。
18
+ // // `INVALID_ARGUMENT` 表示无论系统状态如何都有问题的参数
19
+ // //(例如,格式错误的文件名)。
20
+ // //
21
+ // // HTTP 映射:400 Bad Request
22
+ // INVALID_ARGUMENT: 'INVALID_ARGUMENT',
23
+
24
+ // // 在操作完成之前已超过截止时间。对于会改变系统状态的操作,
25
+ // // 即使操作已成功完成,也可能返回此错误。例如,来自服务器的
26
+ // // 成功响应可能延迟过久,导致截止时间已过期。
27
+ // //
28
+ // // HTTP 映射:504 Gateway Timeout
29
+ // DEADLINE_EXCEEDED: 'DEADLINE_EXCEEDED',
30
+
31
+ // // 未找到某些请求的实体(例如,文件或目录)。
32
+ // //
33
+ // // 给服务端开发者的说明:如果请求对某一类用户整体被拒绝,
34
+ // // 例如渐进式功能发布或未文档化的白名单,可以使用 `NOT_FOUND`。
35
+ // // 如果请求对某一类用户中的部分用户被拒绝,例如基于用户的访问控制,
36
+ // // 则必须使用 `PERMISSION_DENIED`。
37
+ // //
38
+ // // HTTP 映射:404 Not Found
39
+ // NOT_FOUND: 'NOT_FOUND',
40
+
41
+ // // 客户端尝试创建的实体(例如,文件或目录)已存在。
42
+ // //
43
+ // // HTTP 映射:409 Conflict
44
+ // ALREADY_EXISTS: 'ALREADY_EXISTS',
45
+
46
+ // // 调用方没有执行指定操作的权限。`PERMISSION_DENIED` 不得用于
47
+ // // 因资源耗尽而导致的拒绝(此类错误应使用 `RESOURCE_EXHAUSTED`)。
48
+ // // 如果无法识别调用方,则不得使用 `PERMISSION_DENIED`
49
+ // //(此类错误应使用 `UNAUTHENTICATED`)。此错误码并不表示
50
+ // // 请求有效,也不表示请求的实体存在或满足其他前置条件。
51
+ // //
52
+ // // HTTP 映射:403 Forbidden
53
+ // PERMISSION_DENIED: 'PERMISSION_DENIED',
54
+
55
+ // // 请求缺少执行该操作的有效身份验证凭据。
56
+ // //
57
+ // // HTTP 映射:401 Unauthorized
58
+ // UNAUTHENTICATED: 'UNAUTHENTICATED',
59
+
60
+ // // 某些资源已耗尽,可能是每用户配额,
61
+ // // 也可能是整个文件系统空间不足。
62
+ // //
63
+ // // HTTP 映射:429 Too Many Requests
64
+ // RESOURCE_EXHAUSTED: 'RESOURCE_EXHAUSTED',
65
+
66
+ // // 操作被拒绝,因为系统未处于执行该操作所需的状态。
67
+ // // 例如,要删除的目录非空、对非目录执行 rmdir 操作等。
68
+ // //
69
+ // // 服务实现者可以使用以下指南在 `FAILED_PRECONDITION`、
70
+ // // `ABORTED` 和 `UNAVAILABLE` 之间做出选择:
71
+ // // (a) 如果客户端可以仅重试失败的调用,则使用 `UNAVAILABLE`。
72
+ // // (b) 如果客户端应在更高层级重试,则使用 `ABORTED`。
73
+ // // 例如,当客户端指定的 test-and-set 失败时,表示客户端
74
+ // // 应重新开始读-改-写序列。
75
+ // // (c) 如果客户端在系统状态被明确修复之前不应重试,
76
+ // // 则使用 `FAILED_PRECONDITION`。例如,如果 rmdir 因目录
77
+ // // 非空而失败,应返回 `FAILED_PRECONDITION`,因为除非
78
+ // // 目录中的文件被删除,否则客户端不应重试。
79
+ // //
80
+ // // HTTP 映射:400 Bad Request
81
+ // FAILED_PRECONDITION: 'FAILED_PRECONDITION',
82
+
83
+ // // 操作已中止,通常由于并发问题,例如序列号检查失败或事务中止。
84
+ // //
85
+ // // 关于在 `FAILED_PRECONDITION`、`ABORTED` 和 `UNAVAILABLE`
86
+ // // 之间如何选择,请参阅上述指南。
87
+ // //
88
+ // // HTTP 映射:409 Conflict
89
+ // ABORTED: 'ABORTED',
90
+
91
+ // // 操作超出了有效范围。例如,在文件末尾之后进行 seek 或 read。
92
+ // //
93
+ // // 与 `INVALID_ARGUMENT` 不同,此错误表示的问题可能在系统状态
94
+ // // 改变后得到修复。例如,32 位文件系统在被要求读取不在
95
+ // // [0,2^32-1] 范围内的偏移量时会生成 `INVALID_ARGUMENT`,
96
+ // // 但在被要求读取超过当前文件大小的偏移量时会生成 `OUT_OF_RANGE`。
97
+ // //
98
+ // // `FAILED_PRECONDITION` 与 `OUT_OF_RANGE` 之间存在一定重叠。
99
+ // // 我们建议在适用时使用更具体的 `OUT_OF_RANGE`,以便遍历
100
+ // // 某个空间的调用方可以方便地查找 `OUT_OF_RANGE` 错误来判断
101
+ // // 是否已完成。
102
+ // //
103
+ // // HTTP 映射:400 Bad Request
104
+ // OUT_OF_RANGE: 'OUT_OF_RANGE',
105
+
106
+ // // 操作未实现,或在本服务中不受支持/未启用。
107
+ // //
108
+ // // HTTP 映射:501 Not Implemented
109
+ // UNIMPLEMENTED: 'UNIMPLEMENTED',
110
+
111
+ // // 内部错误。这意味着底层系统预期的不变量已被破坏。
112
+ // // 此错误码保留用于严重错误。
113
+ // //
114
+ // // HTTP 映射:500 Internal Server Error
115
+ // INTERNAL: 'INTERNAL',
116
+
117
+ // // 服务当前不可用。这很可能是暂时性状况,可以通过带退避的重试来纠正。
118
+ // // 请注意,重试非幂等操作并不总是安全的。
119
+ // //
120
+ // // 关于在 `FAILED_PRECONDITION`、`ABORTED` 和 `UNAVAILABLE`
121
+ // // 之间如何选择,请参阅上述指南。
122
+ // //
123
+ // // HTTP 映射:503 Service Unavailable
124
+ // UNAVAILABLE: 'UNAVAILABLE',
125
+
126
+ // // 不可恢复的数据丢失或损坏。
127
+ // //
128
+ // // HTTP 映射:500 Internal Server Error
129
+ // DATA_LOSS: 'DATA_LOSS',
130
+ // })
131
+ // export type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode]
132
+
133
+ export const ErrorHttpStatus = fz({
134
+ CANCELLED: 499,
135
+ UNKNOWN: 500,
136
+ INVALID_ARGUMENT: 400,
137
+ UNPROCESSABLE_ENTITY: 422,
138
+ DEADLINE_EXCEEDED: 504,
139
+ NOT_FOUND: 404,
140
+ ALREADY_EXISTS: 409,
141
+ PERMISSION_DENIED: 403,
142
+ UNAUTHENTICATED: 401,
143
+ RESOURCE_EXHAUSTED: 429,
144
+ FAILED_PRECONDITION: 400,
145
+ ABORTED: 409,
146
+ OUT_OF_RANGE: 400,
147
+ UNIMPLEMENTED: 501,
148
+ INTERNAL: 500,
149
+ UNAVAILABLE: 503,
150
+ DATA_LOSS: 500,
151
+ })
152
+ export type ErrorHttpStatus = (typeof ErrorHttpStatus)[keyof typeof ErrorHttpStatus]
@@ -0,0 +1,15 @@
1
+ import { ErrorHttpStatus } from '../constants'
2
+ import { defineErrorCategories } from '../proto'
3
+ import type { ErrorCategoryItem } from '../types'
4
+
5
+ const normalErrorCategories = {
6
+ INTERNAL: { status: ErrorHttpStatus.INTERNAL, message: 'Internal Server Error' },
7
+ CLIENT_ABORTED: { status: ErrorHttpStatus.CANCELLED, message: 'Request aborted' },
8
+ VALIDATION: {
9
+ status: ErrorHttpStatus.UNPROCESSABLE_ENTITY,
10
+ message: 'Request validation failed',
11
+ },
12
+ NOT_FOUND: { status: ErrorHttpStatus.NOT_FOUND, message: 'Resource not found' },
13
+ } satisfies Record<string, ErrorCategoryItem>
14
+
15
+ export const E = defineErrorCategories({ NORMAL: normalErrorCategories })
@@ -0,0 +1,16 @@
1
+ import { problemDetailsHandler } from 'hono-problem-details'
2
+ import { E } from './defs'
3
+ import { logLevelFor } from './log'
4
+ import type { ErrorHandler } from 'hono'
5
+ import type { AppEnv } from '@/shared/app/types'
6
+ import { getLogger } from '@/infra/logger/getter'
7
+
8
+ const problemHandler = problemDetailsHandler({
9
+ defaultType: E.NORMAL.INTERNAL.type,
10
+ })
11
+
12
+ export const globalErrorHandler: ErrorHandler<AppEnv> = (err, c) => {
13
+ const logger = getLogger()
14
+ logger[logLevelFor(err)](err)
15
+ return problemHandler(err, c)
16
+ }
@@ -0,0 +1,67 @@
1
+ import { HTTPException } from 'hono/http-exception'
2
+ import { ProblemDetailsError } from 'hono-problem-details'
3
+ import { isEmpty, objectEntries } from '../utils'
4
+
5
+ const MAX_CAUSE_DEPTH = 5
6
+
7
+ function compact(input: Record<string, unknown>) {
8
+ const out: Record<string, unknown> = {}
9
+ for (const [key, value] of objectEntries(input)) {
10
+ if (isEmpty(value)) continue
11
+ out[key] = value
12
+ }
13
+ return out
14
+ }
15
+
16
+ function serializeUnknown(value: unknown, seen: Set<object>, depth: number): unknown {
17
+ if (!(value instanceof Error)) return isEmpty(value) ? undefined : value
18
+ return compact({
19
+ name: value.name,
20
+ message: value.message,
21
+ stack: value.stack,
22
+ cause: serializeError(value.cause, seen, depth + 1),
23
+ })
24
+ }
25
+
26
+ function serializeError(value: unknown, seen: Set<object>, depth: number): unknown {
27
+ if (!(value instanceof Error)) return isEmpty(value) ? undefined : value
28
+ if (seen.has(value)) return { truncated: 'circular-cause' }
29
+ if (depth > MAX_CAUSE_DEPTH) return { truncated: 'max-cause-depth' }
30
+
31
+ seen.add(value)
32
+
33
+ if (value instanceof ProblemDetailsError) {
34
+ const { type, status, detail, instance, extensions } = value.problemDetails
35
+ return compact({
36
+ ...extensions,
37
+ type,
38
+ status,
39
+ detail,
40
+ instance,
41
+ cause: serializeError(value.cause, seen, depth + 1),
42
+ })
43
+ }
44
+ if (value instanceof HTTPException) {
45
+ return compact({
46
+ status: value.status,
47
+ detail: value.message,
48
+ cause: serializeError(value.cause, seen, depth + 1),
49
+ })
50
+ }
51
+ return serializeUnknown(value, seen, depth)
52
+ }
53
+
54
+ export function serializeErr(value: unknown) {
55
+ // 业务错误不需要堆栈信息,未知未捕获错误才需要
56
+ return serializeError(value, new Set(), 0)
57
+ }
58
+
59
+ export function logLevelFor(err: unknown): 'warn' | 'error' {
60
+ if (err instanceof ProblemDetailsError) {
61
+ return err.problemDetails.status < 500 ? 'warn' : 'error'
62
+ }
63
+ if (err instanceof HTTPException) {
64
+ return err.status < 500 ? 'warn' : 'error'
65
+ }
66
+ return 'error'
67
+ }
@@ -0,0 +1,42 @@
1
+ import format from 'string-template'
2
+ import { problemDetails } from 'hono-problem-details'
3
+ import { fz, hasProp } from '../utils'
4
+ import type { ErrorCategoryItem, ErrorCreateInput, Recursive, WithErrorType } from './types'
5
+
6
+ export function isErrorCategoryItem(obj: unknown): obj is ErrorCategoryItem {
7
+ return !!obj && typeof obj === 'object' && hasProp(obj, 'status') && hasProp(obj, 'message')
8
+ }
9
+
10
+ export function defineErrorCategories<T extends Recursive<ErrorCategoryItem>>(
11
+ value: T,
12
+ ): WithErrorType<T> {
13
+ function traverse(obj: any, currentPath: string): any {
14
+ if (isErrorCategoryItem(obj)) {
15
+ const { status, message } = obj
16
+ return fz({
17
+ ...obj,
18
+ type: currentPath,
19
+ create(input: ErrorCreateInput = {}) {
20
+ const { msgContext, message: messageOverride, cause, ...rest } = input
21
+ const error = problemDetails({
22
+ ...rest,
23
+ status,
24
+ type: currentPath,
25
+ detail: messageOverride || format(message, msgContext || {}),
26
+ })
27
+ if (cause !== undefined) error.cause = cause
28
+ return error
29
+ },
30
+ })
31
+ }
32
+
33
+ const result: any = {}
34
+ for (const key of Object.keys(obj)) {
35
+ const nextPath = currentPath ? `${currentPath}.${key}` : key
36
+ result[key] = traverse(obj[key], nextPath)
37
+ }
38
+ return fz(result)
39
+ }
40
+
41
+ return traverse(value, '')
42
+ }
@@ -0,0 +1,29 @@
1
+ import type { ProblemDetailsError, ProblemDetailsInput } from 'hono-problem-details'
2
+ import type { ErrorHttpStatus } from './constants'
3
+
4
+ export interface Recursive<T> {
5
+ [key: string]: Recursive<T> | T
6
+ }
7
+
8
+ export type ErrorCategoryItem = {
9
+ status: ErrorHttpStatus
10
+ message: string
11
+ }
12
+
13
+ export type ErrorCreateInput = {
14
+ msgContext?: Record<string, unknown>
15
+ message?: string
16
+ cause?: unknown
17
+ } & Omit<ProblemDetailsInput, 'status' | 'type' | 'message'>
18
+
19
+ export type WithErrorType<T, Prefix extends string = ''> = T extends ErrorCategoryItem
20
+ ? T & {
21
+ type: Prefix
22
+ create: (input?: ErrorCreateInput) => ProblemDetailsError
23
+ }
24
+ : {
25
+ [K in keyof T]: WithErrorType<
26
+ T[K],
27
+ Prefix extends '' ? K & string : `${Prefix}.${K & string}`
28
+ >
29
+ }
@@ -0,0 +1,35 @@
1
+ import ky, { type Options, type KyInstance, isKyError, isTimeoutError } from 'ky'
2
+ import { defu } from 'defu'
3
+
4
+ const defaultBaseOptions: Options = {
5
+ // 默认手动处理重定向,避免ky自动重定向导致请求失败
6
+ redirect: 'manual',
7
+ retry: {
8
+ // 默认不重试
9
+ limit: 0,
10
+ // 如果配置了重试,则 如果是http错误或超时,超时则重试,否则走默认行为;
11
+ // 其他情况可能是hooks内代码逻辑报错,不重试
12
+ shouldRetry({ error }) {
13
+ if (isKyError(error)) {
14
+ if (isTimeoutError(error)) {
15
+ return true
16
+ }
17
+ return undefined
18
+ }
19
+ return false
20
+ },
21
+ },
22
+ }
23
+
24
+ export function getOptions(options?: Options): Options {
25
+ return defu({}, defaultBaseOptions, options)
26
+ }
27
+
28
+ /**
29
+ * 创建基础请求器
30
+ * 适用于Node.js和浏览器环境,不包含业务逻辑
31
+ * beforeRequest -> afterResponse -> beforeError -> shouldRetry -> beforeRetry -> beforeRequest -> ...
32
+ */
33
+ export function createFetcher(options?: Options): KyInstance {
34
+ return ky.create(getOptions(options))
35
+ }
@@ -0,0 +1,50 @@
1
+ import type { Hono } from 'hono'
2
+ import { swaggerUI } from '@hono/swagger-ui'
3
+ import { generateSpecs } from 'hono-openapi'
4
+ import type { AppEnv } from '@/shared/app/types'
5
+ import { stringify } from 'yaml'
6
+
7
+ export * from './res-defs'
8
+
9
+ export const OpenApiTags = {
10
+ System: 'System',
11
+ Example: 'Example',
12
+ } as const
13
+
14
+ const DOCS_YAML_PATH = '/docs/openapi.yaml'
15
+
16
+ const openApiSpecOptions = {
17
+ documentation: {
18
+ info: {
19
+ title: '@repo/server',
20
+ version: '0.0.0',
21
+ description: 'Hono API Server',
22
+ },
23
+ tags: [
24
+ { name: OpenApiTags.System, description: 'Server infrastructure' },
25
+ { name: OpenApiTags.Example, description: 'Example vertical slice' },
26
+ ],
27
+ },
28
+ exclude: [DOCS_YAML_PATH, '/swagger'],
29
+ defaultOptions: {
30
+ ALL: {
31
+ responses: {
32
+ 422: {
33
+ description: '请求参数校验失败',
34
+ },
35
+ },
36
+ },
37
+ },
38
+ }
39
+
40
+ export const configureOpenAPI = (app: Hono<AppEnv>) => {
41
+ let yamlSpecs: string | undefined
42
+ app.get(DOCS_YAML_PATH, async (c) => {
43
+ if (!yamlSpecs) {
44
+ yamlSpecs = stringify(await generateSpecs(app, openApiSpecOptions, c))
45
+ }
46
+ return c.text(yamlSpecs, 200, { 'Content-Type': 'application/yaml; charset=utf-8' })
47
+ })
48
+
49
+ app.get('/swagger', swaggerUI({ url: DOCS_YAML_PATH }))
50
+ }
@@ -0,0 +1,39 @@
1
+ import { type DescribeRouteOptions, resolver } from 'hono-openapi'
2
+ import type { GenericSchema } from 'valibot'
3
+
4
+ type OpenApiResponse = NonNullable<DescribeRouteOptions['responses']>[string]
5
+
6
+ export const jsonResponse = (schema: GenericSchema, description = '请求成功'): OpenApiResponse => ({
7
+ description,
8
+ content: {
9
+ 'application/json': {
10
+ schema: resolver(schema),
11
+ },
12
+ },
13
+ })
14
+
15
+ export type BinaryResponseOptions = {
16
+ description?: string
17
+ mediaType?: string
18
+ headers?: Record<
19
+ string,
20
+ {
21
+ description?: string
22
+ schema: { type: 'string'; format?: string }
23
+ }
24
+ >
25
+ }
26
+
27
+ export const binaryResponse = ({
28
+ description = '二进制响应',
29
+ mediaType = 'application/octet-stream',
30
+ headers,
31
+ }: BinaryResponseOptions = {}): OpenApiResponse => ({
32
+ description,
33
+ ...(headers ? { headers } : {}),
34
+ content: {
35
+ [mediaType]: {
36
+ schema: { type: 'string', format: 'binary' },
37
+ },
38
+ },
39
+ })
@@ -0,0 +1,3 @@
1
+ export interface SuccessResObjBody<TData> {
2
+ data: TData
3
+ }
@@ -0,0 +1,36 @@
1
+ import type { Context } from 'hono'
2
+ import type { ContentfulStatusCode } from 'hono/utils/http-status'
3
+ import type { SuccessResObjBody } from './types'
4
+
5
+ export function createContentDisposition(
6
+ filename?: string,
7
+ options?: {
8
+ asciiFallback?: string
9
+ },
10
+ ): string {
11
+ if (!filename) {
12
+ return 'inline'
13
+ }
14
+ const { asciiFallback = 'download' } = options || {}
15
+
16
+ // 1. 去除换行、引号、反斜杠及正斜杠,防止 Header 注入和路径遍历
17
+ const safeFilename = String(filename).replace(/[\r\n"\\/]/g, '_')
18
+
19
+ // 4. RFC 5987 编码:补充 encodeURIComponent 未编码的特殊字符 ( ' ( ) * )
20
+ const rfc5987Filename = encodeURIComponent(safeFilename).replace(
21
+ /['()*]/g,
22
+ (c) => `%${c.charCodeAt(0).toString(16).toUpperCase()}`,
23
+ )
24
+
25
+ return `attachment; filename="${asciiFallback}"; filename*=UTF-8''${rfc5987Filename}`
26
+ }
27
+
28
+ // 成功响应体
29
+ export function createSuccessObjBody<TData = any>(data: TData): SuccessResObjBody<TData> {
30
+ return {
31
+ data,
32
+ }
33
+ }
34
+
35
+ export const successJson = <T>(c: Context, data: T, status: ContentfulStatusCode = 200) =>
36
+ c.json(createSuccessObjBody(data), status)
@@ -0,0 +1,28 @@
1
+ import type { Env, MiddlewareHandler, ValidationTargets } from 'hono'
2
+ import { validator } from 'hono-openapi'
3
+ import { flatten, type GenericSchema, type InferInput, type InferOutput } from 'valibot'
4
+ import { E } from '@/shared/errors/defs'
5
+
6
+ export const generalValidator = <
7
+ TTarget extends keyof ValidationTargets,
8
+ TSchema extends GenericSchema,
9
+ >(
10
+ target: TTarget,
11
+ schema: TSchema,
12
+ ): MiddlewareHandler<
13
+ Env,
14
+ string,
15
+ {
16
+ in: { [K in TTarget]: InferInput<TSchema> }
17
+ out: { [K in TTarget]: InferOutput<TSchema> }
18
+ }
19
+ > =>
20
+ validator(target, schema, (result, _c) => {
21
+ if (!result.success) {
22
+ throw E.NORMAL.VALIDATION.create({
23
+ extensions: {
24
+ validationError: flatten(result.error as any),
25
+ },
26
+ })
27
+ }
28
+ })
@@ -0,0 +1,30 @@
1
+ export const fz = Object.freeze
2
+
3
+ export const hasProp = <P extends string>(
4
+ item: object,
5
+ prop: P,
6
+ ): item is { [key in P]: unknown } => {
7
+ return Object.prototype.hasOwnProperty.call(item, prop)
8
+ }
9
+
10
+ export function isEmpty(value: unknown) {
11
+ return value === undefined || value === null || value === ''
12
+ }
13
+
14
+ export function createSingleton<T, Args extends any[]>(
15
+ factory: (...args: Args) => T,
16
+ ): (...args: Args) => T {
17
+ let instance: T | null = null
18
+
19
+ return (...args: Args): T => {
20
+ if (!instance) {
21
+ instance = factory(...args)
22
+ }
23
+ return instance
24
+ }
25
+ }
26
+
27
+ export const objectEntries = <T extends object>(obj: T) =>
28
+ Object.entries(obj) as {
29
+ [K in keyof T]-?: [K extends string | number ? `${K}` : never, T[K]]
30
+ }[keyof T][]
@@ -0,0 +1,5 @@
1
+ declare module 'virtual:workers' {
2
+ /** Absolute filesystem path to the packed workers directory (`dist/workers`). */
3
+ const workersDir: string
4
+ export default workersDir
5
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "extends": "@oyolincc/dev-config/tsconfig.bundler.json",
3
+ "compilerOptions": {
4
+ "types": ["node", "./worker-configuration.d.ts"],
5
+ "verbatimModuleSyntax": true,
6
+ "jsx": "react-jsx",
7
+ "jsxImportSource": "hono/jsx",
8
+ "outDir": "./dist",
9
+ "paths": {
10
+ "@/*": ["./src/*"],
11
+ "@error-categories": ["./src/shared/errors/defs/index.ts"]
12
+ }
13
+ },
14
+ "files": [],
15
+ "include": ["src", "./*.ts", "./*.mts"],
16
+ "exclude": ["node_modules"]
17
+ }
@@ -0,0 +1,87 @@
1
+ import { defineConfig, type Plugin } from 'vite-plus'
2
+ import { packConfig } from '@oyolincc/dev-config'
3
+ import devServer from '@hono/vite-dev-server'
4
+ import nodeAdapter from '@hono/vite-dev-server/node'
5
+ import { loadEnvSync } from '@oyolincc/env-loader'
6
+ import path from 'node:path'
7
+ // import { builtinModules } from 'node:module'
8
+
9
+ const __dirname = import.meta.dirname
10
+ const isServe = !!process.env.VITE_PUBLIC_DEV_SERVE
11
+ const workersDir = path.resolve(__dirname, 'dist/workers')
12
+
13
+ function virtualWorkers(kind: 'dev' | 'pack'): Plugin {
14
+ const virtualId = 'virtual:workers'
15
+ const resolvedId = `\0${virtualId}`
16
+
17
+ return {
18
+ name: 'virtual-workers',
19
+ resolveId(id) {
20
+ if (id === virtualId) return resolvedId
21
+ return null
22
+ },
23
+ load(id) {
24
+ if (id !== resolvedId) return null
25
+ // vp dev / test: Piscina cannot follow Vite's module graph; pack --watch writes dist/workers.
26
+ if (kind === 'dev') {
27
+ return `export default ${JSON.stringify(workersDir)}`
28
+ }
29
+ // vp pack: inlined into the server entry, so import.meta.dirname is dist/.
30
+ return "import path from 'node:path'\nexport default path.join(import.meta.dirname, 'workers')"
31
+ },
32
+ }
33
+ }
34
+
35
+ export default defineConfig(() => {
36
+ return {
37
+ test: {
38
+ clearMocks: false,
39
+ },
40
+ plugins: [
41
+ virtualWorkers('dev'),
42
+ {
43
+ name: 'node-bootstrap',
44
+ async configureServer() {
45
+ loadEnvSync({
46
+ preset: 'server',
47
+ })
48
+ },
49
+ },
50
+ devServer({
51
+ entry: './src/adapters/nodejs/entry.ts',
52
+ adapter: nodeAdapter(),
53
+ }) as Plugin,
54
+ ],
55
+ pack: {
56
+ ...packConfig,
57
+ plugins: [virtualWorkers('pack')],
58
+ deps: {
59
+ neverBundle: ['cloudflare:workers'],
60
+ },
61
+ entry: {
62
+ ...(isServe
63
+ ? {}
64
+ : {
65
+ nodejsMain: './src/adapters/nodejs/bootstrap.ts',
66
+ }),
67
+ nodejsEntry: './src/adapters/nodejs/entry.ts',
68
+ cloudflareEntry: './src/adapters/cloudflare/entry.ts',
69
+ // Enable this entry together with PiscinaWorkRunner in the Node.js adapter.
70
+ // 'workers/example-worker': './src/infra/work-runner/example/worker-entry.ts',
71
+ },
72
+ // deps: {
73
+ // neverBundle: [...builtinModules],
74
+ // },
75
+ },
76
+ resolve: {
77
+ alias: {
78
+ '@': path.resolve(__dirname, './src'),
79
+ '@error-categories': path.resolve(__dirname, './src/shared/errors/defs/index.ts'),
80
+ },
81
+ },
82
+ server: {
83
+ port: Number(process.env.NODE_PORT) || 6464,
84
+ host: true,
85
+ },
86
+ }
87
+ })