@oyolincc/create 0.0.0-dev-20260513110237 → 0.0.0-dev-20260918103756
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.
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +35 -17
- package/templates/hono-fullstack/.agents/skills/ask-matt/PHASE-BOUNDARIES.md +55 -0
- package/templates/hono-fullstack/.agents/skills/ask-matt/SKILL.md +90 -0
- package/templates/hono-fullstack/.agents/skills/ask-matt/agents/openai.yaml +5 -0
- package/templates/hono-fullstack/.agents/skills/code-review/SKILL.md +87 -0
- package/templates/hono-fullstack/.agents/skills/code-review/agents/openai.yaml +3 -0
- package/templates/hono-fullstack/.agents/skills/codebase-design/DEEPENING.md +37 -0
- package/templates/hono-fullstack/.agents/skills/codebase-design/DESIGN-IT-TWICE.md +44 -0
- package/templates/hono-fullstack/.agents/skills/codebase-design/SKILL.md +114 -0
- package/templates/hono-fullstack/.agents/skills/codebase-design/agents/openai.yaml +3 -0
- package/templates/hono-fullstack/.agents/skills/confirm-requirements/SKILL.md +25 -0
- package/templates/hono-fullstack/.agents/skills/diagnosing-bugs/SKILL.md +140 -0
- package/templates/hono-fullstack/.agents/skills/diagnosing-bugs/agents/openai.yaml +3 -0
- package/templates/hono-fullstack/.agents/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +44 -0
- package/templates/hono-fullstack/.agents/skills/domain-modeling/ADR-FORMAT.md +47 -0
- package/templates/hono-fullstack/.agents/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
- package/templates/hono-fullstack/.agents/skills/domain-modeling/SKILL.md +74 -0
- package/templates/hono-fullstack/.agents/skills/domain-modeling/agents/openai.yaml +3 -0
- package/templates/hono-fullstack/.agents/skills/grill-me/SKILL.md +7 -0
- package/templates/hono-fullstack/.agents/skills/grill-me/agents/openai.yaml +5 -0
- package/templates/hono-fullstack/.agents/skills/grilling/SKILL.md +22 -0
- package/templates/hono-fullstack/.agents/skills/grilling/agents/openai.yaml +3 -0
- package/templates/hono-fullstack/.agents/skills/implement/SKILL.md +15 -0
- package/templates/hono-fullstack/.agents/skills/implement/agents/openai.yaml +5 -0
- package/templates/hono-fullstack/.agents/skills/improve-codebase-architecture/HTML-REPORT.md +123 -0
- package/templates/hono-fullstack/.agents/skills/improve-codebase-architecture/SKILL.md +71 -0
- package/templates/hono-fullstack/.agents/skills/improve-codebase-architecture/agents/openai.yaml +5 -0
- package/templates/hono-fullstack/.agents/skills/prototype/LOGIC.md +67 -0
- package/templates/hono-fullstack/.agents/skills/prototype/SKILL.md +26 -0
- package/templates/hono-fullstack/.agents/skills/prototype/UI.md +112 -0
- package/templates/hono-fullstack/.agents/skills/prototype/agents/openai.yaml +3 -0
- package/templates/hono-fullstack/.agents/skills/research/SKILL.md +12 -0
- package/templates/hono-fullstack/.agents/skills/research/agents/openai.yaml +3 -0
- package/templates/hono-fullstack/.agents/skills/resolving-merge-conflicts/SKILL.md +14 -0
- package/templates/hono-fullstack/.agents/skills/resolving-merge-conflicts/agents/openai.yaml +3 -0
- package/templates/hono-fullstack/.agents/skills/scoped-code-review/SKILL.md +113 -0
- package/templates/hono-fullstack/.agents/skills/setup-matt-pocock-skills/SKILL.md +116 -0
- package/templates/hono-fullstack/.agents/skills/setup-matt-pocock-skills/agents/openai.yaml +5 -0
- package/templates/hono-fullstack/.agents/skills/setup-matt-pocock-skills/domain.md +51 -0
- package/templates/hono-fullstack/.agents/skills/setup-matt-pocock-skills/issue-tracker-github.md +45 -0
- package/templates/hono-fullstack/.agents/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md +46 -0
- package/templates/hono-fullstack/.agents/skills/setup-matt-pocock-skills/issue-tracker-local.md +30 -0
- package/templates/hono-fullstack/.agents/skills/setup-matt-pocock-skills/triage-labels.md +15 -0
- package/templates/hono-fullstack/.agents/skills/tdd/SKILL.md +38 -0
- package/templates/hono-fullstack/.agents/skills/tdd/agents/openai.yaml +3 -0
- package/templates/hono-fullstack/.agents/skills/tdd/mocking.md +59 -0
- package/templates/hono-fullstack/.agents/skills/tdd/tests.md +77 -0
- package/templates/hono-fullstack/.agents/skills/teach/GLOSSARY-FORMAT.md +35 -0
- package/templates/hono-fullstack/.agents/skills/teach/LEARNING-RECORD-FORMAT.md +46 -0
- package/templates/hono-fullstack/.agents/skills/teach/MISSION-FORMAT.md +31 -0
- package/templates/hono-fullstack/.agents/skills/teach/RESOURCES-FORMAT.md +32 -0
- package/templates/hono-fullstack/.agents/skills/teach/SKILL.md +140 -0
- package/templates/hono-fullstack/.agents/skills/teach/agents/openai.yaml +5 -0
- package/templates/hono-fullstack/.agents/skills/to-questionnaire/SKILL.md +53 -0
- package/templates/hono-fullstack/.agents/skills/to-questionnaire/agents/openai.yaml +5 -0
- package/templates/hono-fullstack/.agents/skills/triage/AGENT-BRIEF.md +207 -0
- package/templates/hono-fullstack/.agents/skills/triage/OUT-OF-SCOPE.md +105 -0
- package/templates/hono-fullstack/.agents/skills/triage/SKILL.md +112 -0
- package/templates/hono-fullstack/.agents/skills/triage/agents/openai.yaml +5 -0
- package/templates/hono-fullstack/.agents/skills/wait-what/SKILL.md +7 -0
- package/templates/hono-fullstack/.agents/skills/wait-what/agents/openai.yaml +5 -0
- package/templates/hono-fullstack/.agents/skills/wayfinder/SKILL.md +128 -0
- package/templates/hono-fullstack/.agents/skills/wayfinder/agents/openai.yaml +5 -0
- package/templates/hono-fullstack/.agents/skills/wizard/SKILL.md +44 -0
- package/templates/hono-fullstack/.agents/skills/wizard/agents/openai.yaml +3 -0
- package/templates/hono-fullstack/.agents/skills/wizard/template.sh +204 -0
- package/templates/hono-fullstack/.agents/skills/writing-for-agents/SKILL-MECHANICS.md +22 -0
- package/templates/hono-fullstack/.agents/skills/writing-for-agents/SKILL.md +81 -0
- package/templates/hono-fullstack/.agents/skills/writing-for-agents/agents/openai.yaml +3 -0
- package/templates/hono-fullstack/.changeset/README.md +8 -0
- package/templates/hono-fullstack/.changeset/config.json +11 -0
- package/templates/hono-fullstack/.vscode/extensions.json +5 -0
- package/templates/hono-fullstack/.vscode/launch.json +25 -0
- package/templates/hono-fullstack/.vscode/settings.json +24 -0
- package/templates/hono-fullstack/AGENTS.md +43 -0
- package/templates/hono-fullstack/README.md +37 -0
- package/templates/hono-fullstack/_gitignore +30 -0
- package/templates/hono-fullstack/apps/server/package.json +56 -0
- package/templates/hono-fullstack/apps/server/src/adapters/nodejs/bootstrap.ts +64 -0
- package/templates/hono-fullstack/apps/server/src/adapters/nodejs/config.ts +53 -0
- package/templates/hono-fullstack/apps/server/src/adapters/nodejs/entry.ts +47 -0
- package/templates/hono-fullstack/apps/server/src/app.test.ts +52 -0
- package/templates/hono-fullstack/apps/server/src/app.ts +45 -0
- package/templates/hono-fullstack/apps/server/src/infra/logger/getter.ts +74 -0
- package/templates/hono-fullstack/apps/server/src/infra/logger/pino.ts +122 -0
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/constants.ts +23 -0
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/errors.ts +40 -0
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/example/runner.test.ts +56 -0
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/example/runner.ts +185 -0
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/example/worker-entry.ts +34 -0
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/types.ts +113 -0
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/utils/business-error.ts +19 -0
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/utils/message.ts +46 -0
- package/templates/hono-fullstack/apps/server/src/infra/work-runner/utils/transfer.ts +144 -0
- package/templates/hono-fullstack/apps/server/src/middlewares/cors.ts +26 -0
- package/templates/hono-fullstack/apps/server/src/modules/example/contracts.ts +9 -0
- package/templates/hono-fullstack/apps/server/src/modules/example/routes.ts +75 -0
- package/templates/hono-fullstack/apps/server/src/modules/example/work-task/tasks.test.ts +37 -0
- package/templates/hono-fullstack/apps/server/src/modules/example/work-task/tasks.ts +35 -0
- package/templates/hono-fullstack/apps/server/src/shared/app/types.ts +40 -0
- package/templates/hono-fullstack/apps/server/src/shared/errors/constants.ts +152 -0
- package/templates/hono-fullstack/apps/server/src/shared/errors/defs/index.ts +15 -0
- package/templates/hono-fullstack/apps/server/src/shared/errors/handler.ts +16 -0
- package/templates/hono-fullstack/apps/server/src/shared/errors/log.ts +67 -0
- package/templates/hono-fullstack/apps/server/src/shared/errors/proto.ts +42 -0
- package/templates/hono-fullstack/apps/server/src/shared/errors/types.ts +29 -0
- package/templates/hono-fullstack/apps/server/src/shared/network/fetcher.ts +35 -0
- package/templates/hono-fullstack/apps/server/src/shared/network/openapi/index.ts +50 -0
- package/templates/hono-fullstack/apps/server/src/shared/network/openapi/res-defs.ts +39 -0
- package/templates/hono-fullstack/apps/server/src/shared/network/types.ts +3 -0
- package/templates/hono-fullstack/apps/server/src/shared/network/utils.ts +36 -0
- package/templates/hono-fullstack/apps/server/src/shared/network/validator.ts +21 -0
- package/templates/hono-fullstack/apps/server/src/shared/utils/index.ts +30 -0
- package/templates/hono-fullstack/apps/server/src/virtual-modules.d.ts +5 -0
- package/templates/hono-fullstack/apps/server/tsconfig.json +16 -0
- package/templates/hono-fullstack/apps/server/vite.config.ts +79 -0
- package/templates/hono-fullstack/apps/stack/frontend/modules/example/ExamplePage.tsx +57 -0
- package/templates/hono-fullstack/apps/stack/frontend/modules/example/api.ts +13 -0
- package/templates/hono-fullstack/apps/stack/frontend/modules/example/hooks.ts +13 -0
- package/templates/hono-fullstack/apps/stack/frontend/routeTree.gen.ts +56 -0
- package/templates/hono-fullstack/apps/stack/frontend/router.tsx +22 -0
- package/templates/hono-fullstack/apps/stack/frontend/routes/__root.tsx +61 -0
- package/templates/hono-fullstack/apps/stack/frontend/routes/index.tsx +4 -0
- package/templates/hono-fullstack/apps/stack/frontend/shared/network/client.ts +19 -0
- package/templates/hono-fullstack/apps/stack/frontend/shared/network/constants.ts +1 -0
- package/templates/hono-fullstack/apps/stack/frontend/shared/network/errors.ts +33 -0
- package/templates/hono-fullstack/apps/stack/frontend/styles.css +23 -0
- package/templates/hono-fullstack/apps/stack/frontend/vite-env.d.ts +1 -0
- package/templates/hono-fullstack/apps/stack/nitro/handlers/hono.ts +1 -0
- package/templates/hono-fullstack/apps/stack/nitro/plugins/hono.ts +9 -0
- package/templates/hono-fullstack/apps/stack/package.json +43 -0
- package/templates/hono-fullstack/apps/stack/tsconfig.json +10 -0
- package/templates/hono-fullstack/apps/stack/tsr.config.json +5 -0
- package/templates/hono-fullstack/apps/stack/vite.config.ts +33 -0
- package/templates/hono-fullstack/docs/agents/domain.md +41 -0
- package/templates/hono-fullstack/docs/agents/issue-tracker.md +30 -0
- package/templates/hono-fullstack/docs/agents/triage-labels.md +15 -0
- package/templates/hono-fullstack/envs/.env.example.server +12 -0
- package/templates/hono-fullstack/envs/.env.example.sqlite +2 -0
- package/templates/hono-fullstack/libs/db/drizzle-kit/sqlite.config.ts +22 -0
- package/templates/hono-fullstack/libs/db/package.json +39 -0
- package/templates/hono-fullstack/libs/db/src/dialects/sqlite/client.ts +35 -0
- package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/columns.ts +32 -0
- package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/index.ts +7 -0
- package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/modules/examples/examples.ts +22 -0
- package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/relations.ts +5 -0
- package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/tables.ts +5 -0
- package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/types.ts +7 -0
- package/templates/hono-fullstack/libs/db/src/dialects/sqlite/schema/vo.ts +1 -0
- package/templates/hono-fullstack/libs/db/src/dialects/sqlite/utils.ts +8 -0
- package/templates/hono-fullstack/libs/db/src/shared/types.ts +26 -0
- package/templates/hono-fullstack/libs/db/tsconfig.json +10 -0
- package/templates/hono-fullstack/libs/db/vite.config.ts +21 -0
- package/templates/hono-fullstack/libs/definition/package.json +30 -0
- package/templates/hono-fullstack/libs/definition/src/backend.ts +2 -0
- package/templates/hono-fullstack/libs/definition/src/configs/defs/log.ts +53 -0
- package/templates/hono-fullstack/libs/definition/src/configs/defs/middleware.ts +16 -0
- package/templates/hono-fullstack/libs/definition/src/configs/defs/runtime.ts +11 -0
- package/templates/hono-fullstack/libs/definition/src/configs/defs/sqlite.ts +13 -0
- package/templates/hono-fullstack/libs/definition/src/configs/defs/worker.ts +29 -0
- package/templates/hono-fullstack/libs/definition/src/configs/index.ts +5 -0
- package/templates/hono-fullstack/libs/definition/src/configs/proto.ts +81 -0
- package/templates/hono-fullstack/libs/definition/src/configs/schema.ts +23 -0
- package/templates/hono-fullstack/libs/definition/src/frontend.ts +1 -0
- package/templates/hono-fullstack/libs/definition/src/modules/example/index.ts +16 -0
- package/templates/hono-fullstack/libs/definition/src/modules/index.ts +1 -0
- package/templates/hono-fullstack/libs/definition/tsconfig.json +5 -0
- package/templates/hono-fullstack/libs/definition/vite.config.ts +13 -0
- package/templates/hono-fullstack/oyo.config.json +12 -0
- package/templates/hono-fullstack/package.json +29 -0
- package/templates/hono-fullstack/pnpm-workspace.yaml +82 -0
- package/templates/hono-fullstack/tsconfig.json +4 -0
- package/templates/hono-fullstack/turbo.json +13 -0
- package/templates/hono-fullstack/vite.config.ts +13 -0
- package/templates/hono-server/.agents/skills/ask-matt/PHASE-BOUNDARIES.md +55 -0
- package/templates/hono-server/.agents/skills/ask-matt/SKILL.md +90 -0
- package/templates/hono-server/.agents/skills/ask-matt/agents/openai.yaml +5 -0
- package/templates/hono-server/.agents/skills/code-review/SKILL.md +87 -0
- package/templates/hono-server/.agents/skills/code-review/agents/openai.yaml +3 -0
- package/templates/hono-server/.agents/skills/codebase-design/DEEPENING.md +37 -0
- package/templates/hono-server/.agents/skills/codebase-design/DESIGN-IT-TWICE.md +44 -0
- package/templates/hono-server/.agents/skills/codebase-design/SKILL.md +114 -0
- package/templates/hono-server/.agents/skills/codebase-design/agents/openai.yaml +3 -0
- package/templates/hono-server/.agents/skills/confirm-requirements/SKILL.md +25 -0
- package/templates/hono-server/.agents/skills/diagnosing-bugs/SKILL.md +140 -0
- package/templates/hono-server/.agents/skills/diagnosing-bugs/agents/openai.yaml +3 -0
- package/templates/hono-server/.agents/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +44 -0
- package/templates/hono-server/.agents/skills/domain-modeling/ADR-FORMAT.md +47 -0
- package/templates/hono-server/.agents/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
- package/templates/hono-server/.agents/skills/domain-modeling/SKILL.md +74 -0
- package/templates/hono-server/.agents/skills/domain-modeling/agents/openai.yaml +3 -0
- package/templates/hono-server/.agents/skills/grill-me/SKILL.md +7 -0
- package/templates/hono-server/.agents/skills/grill-me/agents/openai.yaml +5 -0
- package/templates/hono-server/.agents/skills/grilling/SKILL.md +22 -0
- package/templates/hono-server/.agents/skills/grilling/agents/openai.yaml +3 -0
- package/templates/hono-server/.agents/skills/implement/SKILL.md +15 -0
- package/templates/hono-server/.agents/skills/implement/agents/openai.yaml +5 -0
- package/templates/hono-server/.agents/skills/improve-codebase-architecture/HTML-REPORT.md +123 -0
- package/templates/hono-server/.agents/skills/improve-codebase-architecture/SKILL.md +71 -0
- package/templates/hono-server/.agents/skills/improve-codebase-architecture/agents/openai.yaml +5 -0
- package/templates/hono-server/.agents/skills/prototype/LOGIC.md +67 -0
- package/templates/hono-server/.agents/skills/prototype/SKILL.md +26 -0
- package/templates/hono-server/.agents/skills/prototype/UI.md +112 -0
- package/templates/hono-server/.agents/skills/prototype/agents/openai.yaml +3 -0
- package/templates/hono-server/.agents/skills/research/SKILL.md +12 -0
- package/templates/hono-server/.agents/skills/research/agents/openai.yaml +3 -0
- package/templates/hono-server/.agents/skills/resolving-merge-conflicts/SKILL.md +14 -0
- package/templates/hono-server/.agents/skills/resolving-merge-conflicts/agents/openai.yaml +3 -0
- package/templates/hono-server/.agents/skills/scoped-code-review/SKILL.md +113 -0
- package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/SKILL.md +116 -0
- package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/agents/openai.yaml +5 -0
- package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/domain.md +51 -0
- package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/issue-tracker-github.md +45 -0
- package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md +46 -0
- package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/issue-tracker-local.md +30 -0
- package/templates/hono-server/.agents/skills/setup-matt-pocock-skills/triage-labels.md +15 -0
- package/templates/hono-server/.agents/skills/tdd/SKILL.md +38 -0
- package/templates/hono-server/.agents/skills/tdd/agents/openai.yaml +3 -0
- package/templates/hono-server/.agents/skills/tdd/mocking.md +59 -0
- package/templates/hono-server/.agents/skills/tdd/tests.md +77 -0
- package/templates/hono-server/.agents/skills/teach/GLOSSARY-FORMAT.md +35 -0
- package/templates/hono-server/.agents/skills/teach/LEARNING-RECORD-FORMAT.md +46 -0
- package/templates/hono-server/.agents/skills/teach/MISSION-FORMAT.md +31 -0
- package/templates/hono-server/.agents/skills/teach/RESOURCES-FORMAT.md +32 -0
- package/templates/hono-server/.agents/skills/teach/SKILL.md +140 -0
- package/templates/hono-server/.agents/skills/teach/agents/openai.yaml +5 -0
- package/templates/hono-server/.agents/skills/to-questionnaire/SKILL.md +53 -0
- package/templates/hono-server/.agents/skills/to-questionnaire/agents/openai.yaml +5 -0
- package/templates/hono-server/.agents/skills/triage/AGENT-BRIEF.md +207 -0
- package/templates/hono-server/.agents/skills/triage/OUT-OF-SCOPE.md +105 -0
- package/templates/hono-server/.agents/skills/triage/SKILL.md +112 -0
- package/templates/hono-server/.agents/skills/triage/agents/openai.yaml +5 -0
- package/templates/hono-server/.agents/skills/wait-what/SKILL.md +7 -0
- package/templates/hono-server/.agents/skills/wait-what/agents/openai.yaml +5 -0
- package/templates/hono-server/.agents/skills/wayfinder/SKILL.md +128 -0
- package/templates/hono-server/.agents/skills/wayfinder/agents/openai.yaml +5 -0
- package/templates/hono-server/.agents/skills/wizard/SKILL.md +44 -0
- package/templates/hono-server/.agents/skills/wizard/agents/openai.yaml +3 -0
- package/templates/hono-server/.agents/skills/wizard/template.sh +204 -0
- package/templates/hono-server/.agents/skills/writing-for-agents/SKILL-MECHANICS.md +22 -0
- package/templates/hono-server/.agents/skills/writing-for-agents/SKILL.md +81 -0
- package/templates/hono-server/.agents/skills/writing-for-agents/agents/openai.yaml +3 -0
- package/templates/hono-server/.changeset/README.md +8 -0
- package/templates/hono-server/.changeset/config.json +11 -0
- package/templates/hono-server/.editorconfig +31 -0
- package/templates/hono-server/.gitattributes +39 -0
- package/templates/hono-server/.vscode/extensions.json +5 -0
- package/templates/hono-server/.vscode/launch.json +25 -0
- package/templates/hono-server/.vscode/settings.json +24 -0
- package/templates/hono-server/AGENTS.md +43 -0
- package/templates/hono-server/README.md +31 -0
- package/templates/hono-server/_gitignore +30 -0
- package/templates/hono-server/apps/server/package.json +55 -0
- package/templates/hono-server/apps/server/src/adapters/nodejs/bootstrap.ts +61 -0
- package/templates/hono-server/apps/server/src/adapters/nodejs/config.ts +53 -0
- package/templates/hono-server/apps/server/src/adapters/nodejs/entry.ts +40 -0
- package/templates/hono-server/apps/server/src/app.test.ts +52 -0
- package/templates/hono-server/apps/server/src/app.ts +45 -0
- package/templates/hono-server/apps/server/src/infra/logger/getter.ts +74 -0
- package/templates/hono-server/apps/server/src/infra/logger/pino.ts +122 -0
- package/templates/hono-server/apps/server/src/infra/work-runner/constants.ts +23 -0
- package/templates/hono-server/apps/server/src/infra/work-runner/errors.ts +40 -0
- package/templates/hono-server/apps/server/src/infra/work-runner/example/runner.test.ts +56 -0
- package/templates/hono-server/apps/server/src/infra/work-runner/example/runner.ts +185 -0
- package/templates/hono-server/apps/server/src/infra/work-runner/example/worker-entry.ts +34 -0
- package/templates/hono-server/apps/server/src/infra/work-runner/types.ts +113 -0
- package/templates/hono-server/apps/server/src/infra/work-runner/utils/business-error.ts +19 -0
- package/templates/hono-server/apps/server/src/infra/work-runner/utils/message.ts +46 -0
- package/templates/hono-server/apps/server/src/infra/work-runner/utils/transfer.ts +144 -0
- package/templates/hono-server/apps/server/src/middlewares/cors.ts +26 -0
- package/templates/hono-server/apps/server/src/modules/example/contracts.ts +5 -0
- package/templates/hono-server/apps/server/src/modules/example/routes.ts +46 -0
- package/templates/hono-server/apps/server/src/modules/example/work-task/tasks.test.ts +37 -0
- package/templates/hono-server/apps/server/src/modules/example/work-task/tasks.ts +35 -0
- package/templates/hono-server/apps/server/src/shared/app/types.ts +40 -0
- package/templates/hono-server/apps/server/src/shared/errors/constants.ts +152 -0
- package/templates/hono-server/apps/server/src/shared/errors/defs/index.ts +15 -0
- package/templates/hono-server/apps/server/src/shared/errors/handler.ts +16 -0
- package/templates/hono-server/apps/server/src/shared/errors/log.ts +67 -0
- package/templates/hono-server/apps/server/src/shared/errors/proto.ts +42 -0
- package/templates/hono-server/apps/server/src/shared/errors/types.ts +29 -0
- package/templates/hono-server/apps/server/src/shared/network/fetcher.ts +35 -0
- package/templates/hono-server/apps/server/src/shared/network/openapi/index.ts +50 -0
- package/templates/hono-server/apps/server/src/shared/network/openapi/res-defs.ts +39 -0
- package/templates/hono-server/apps/server/src/shared/network/types.ts +3 -0
- package/templates/hono-server/apps/server/src/shared/network/utils.ts +36 -0
- package/templates/hono-server/apps/server/src/shared/network/validator.ts +21 -0
- package/templates/hono-server/apps/server/src/shared/utils/index.ts +30 -0
- package/templates/hono-server/apps/server/src/virtual-modules.d.ts +5 -0
- package/templates/hono-server/apps/server/tsconfig.json +16 -0
- package/templates/hono-server/apps/server/vite.config.ts +79 -0
- package/templates/hono-server/docker/.env.example +4 -0
- package/templates/hono-server/docker/README.md +5 -0
- package/templates/hono-server/docker/local/compose.local.app.yml +21 -0
- package/templates/hono-server/docker/local/local-app-deploy.sh +8 -0
- package/templates/hono-server/docker/local/local-app-down.sh +8 -0
- package/templates/hono-server/docker/prod/.env.example.server +11 -0
- package/templates/hono-server/docker/prod/compose.prod.stack.yml +21 -0
- package/templates/hono-server/docker/prod/update.sh +7 -0
- package/templates/hono-server/docker/server.Dockerfile +40 -0
- package/templates/hono-server/docker/server.Dockerfile.dockerignore +23 -0
- package/templates/hono-server/docs/agents/domain.md +41 -0
- package/templates/hono-server/docs/agents/issue-tracker.md +30 -0
- package/templates/hono-server/docs/agents/triage-labels.md +15 -0
- package/templates/hono-server/envs/.env.example.server +12 -0
- package/templates/hono-server/libs/definition/package.json +29 -0
- package/templates/hono-server/libs/definition/src/backend.ts +2 -0
- package/templates/hono-server/libs/definition/src/configs/defs/log.ts +53 -0
- package/templates/hono-server/libs/definition/src/configs/defs/middleware.ts +16 -0
- package/templates/hono-server/libs/definition/src/configs/defs/runtime.ts +11 -0
- package/templates/hono-server/libs/definition/src/configs/defs/worker.ts +29 -0
- package/templates/hono-server/libs/definition/src/configs/index.ts +4 -0
- package/templates/hono-server/libs/definition/src/configs/proto.ts +81 -0
- package/templates/hono-server/libs/definition/src/configs/schema.ts +23 -0
- package/templates/hono-server/libs/definition/src/modules/example/index.ts +16 -0
- package/templates/hono-server/libs/definition/src/modules/index.ts +1 -0
- package/templates/hono-server/libs/definition/tsconfig.json +5 -0
- package/templates/hono-server/libs/definition/vite.config.ts +12 -0
- package/templates/hono-server/oyo.config.json +11 -0
- package/templates/hono-server/package.json +26 -0
- package/templates/hono-server/pnpm-workspace.yaml +57 -0
- package/templates/hono-server/scripts/.env.example.docker +4 -0
- package/templates/hono-server/scripts/build-docker-server.sh +13 -0
- package/templates/hono-server/scripts/common.sh +20 -0
- package/templates/hono-server/tsconfig.json +4 -0
- package/templates/hono-server/turbo.json +13 -0
- package/templates/hono-server/vite.config.ts +13 -0
- package/templates/monorepo/.agents/skills/ask-matt/PHASE-BOUNDARIES.md +55 -0
- package/templates/monorepo/.agents/skills/ask-matt/SKILL.md +90 -0
- package/templates/monorepo/.agents/skills/ask-matt/agents/openai.yaml +5 -0
- package/templates/monorepo/.agents/skills/code-review/SKILL.md +87 -0
- package/templates/monorepo/.agents/skills/code-review/agents/openai.yaml +3 -0
- package/templates/monorepo/.agents/skills/codebase-design/DEEPENING.md +37 -0
- package/templates/monorepo/.agents/skills/codebase-design/DESIGN-IT-TWICE.md +44 -0
- package/templates/monorepo/.agents/skills/codebase-design/SKILL.md +114 -0
- package/templates/monorepo/.agents/skills/codebase-design/agents/openai.yaml +3 -0
- package/templates/monorepo/.agents/skills/confirm-requirements/SKILL.md +25 -0
- package/templates/monorepo/.agents/skills/diagnosing-bugs/SKILL.md +140 -0
- package/templates/monorepo/.agents/skills/diagnosing-bugs/agents/openai.yaml +3 -0
- package/templates/monorepo/.agents/skills/diagnosing-bugs/scripts/hitl-loop.template.sh +44 -0
- package/templates/monorepo/.agents/skills/domain-modeling/ADR-FORMAT.md +47 -0
- package/templates/monorepo/.agents/skills/domain-modeling/CONTEXT-FORMAT.md +60 -0
- package/templates/monorepo/.agents/skills/domain-modeling/SKILL.md +74 -0
- package/templates/monorepo/.agents/skills/domain-modeling/agents/openai.yaml +3 -0
- package/templates/monorepo/.agents/skills/grill-me/SKILL.md +7 -0
- package/templates/monorepo/.agents/skills/grill-me/agents/openai.yaml +5 -0
- package/templates/monorepo/.agents/skills/grilling/SKILL.md +22 -0
- package/templates/monorepo/.agents/skills/grilling/agents/openai.yaml +3 -0
- package/templates/monorepo/.agents/skills/implement/SKILL.md +15 -0
- package/templates/monorepo/.agents/skills/implement/agents/openai.yaml +5 -0
- package/templates/monorepo/.agents/skills/improve-codebase-architecture/HTML-REPORT.md +123 -0
- package/templates/monorepo/.agents/skills/improve-codebase-architecture/SKILL.md +71 -0
- package/templates/monorepo/.agents/skills/improve-codebase-architecture/agents/openai.yaml +5 -0
- package/templates/monorepo/.agents/skills/prototype/LOGIC.md +67 -0
- package/templates/monorepo/.agents/skills/prototype/SKILL.md +26 -0
- package/templates/monorepo/.agents/skills/prototype/UI.md +112 -0
- package/templates/monorepo/.agents/skills/prototype/agents/openai.yaml +3 -0
- package/templates/monorepo/.agents/skills/research/SKILL.md +12 -0
- package/templates/monorepo/.agents/skills/research/agents/openai.yaml +3 -0
- package/templates/monorepo/.agents/skills/resolving-merge-conflicts/SKILL.md +14 -0
- package/templates/monorepo/.agents/skills/resolving-merge-conflicts/agents/openai.yaml +3 -0
- package/templates/monorepo/.agents/skills/scoped-code-review/SKILL.md +113 -0
- package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/SKILL.md +116 -0
- package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/agents/openai.yaml +5 -0
- package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/domain.md +51 -0
- package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/issue-tracker-github.md +45 -0
- package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/issue-tracker-gitlab.md +46 -0
- package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/issue-tracker-local.md +30 -0
- package/templates/monorepo/.agents/skills/setup-matt-pocock-skills/triage-labels.md +15 -0
- package/templates/monorepo/.agents/skills/tdd/SKILL.md +38 -0
- package/templates/monorepo/.agents/skills/tdd/agents/openai.yaml +3 -0
- package/templates/monorepo/.agents/skills/tdd/mocking.md +59 -0
- package/templates/monorepo/.agents/skills/tdd/tests.md +77 -0
- package/templates/monorepo/.agents/skills/teach/GLOSSARY-FORMAT.md +35 -0
- package/templates/monorepo/.agents/skills/teach/LEARNING-RECORD-FORMAT.md +46 -0
- package/templates/monorepo/.agents/skills/teach/MISSION-FORMAT.md +31 -0
- package/templates/monorepo/.agents/skills/teach/RESOURCES-FORMAT.md +32 -0
- package/templates/monorepo/.agents/skills/teach/SKILL.md +140 -0
- package/templates/monorepo/.agents/skills/teach/agents/openai.yaml +5 -0
- package/templates/monorepo/.agents/skills/to-questionnaire/SKILL.md +53 -0
- package/templates/monorepo/.agents/skills/to-questionnaire/agents/openai.yaml +5 -0
- package/templates/monorepo/.agents/skills/triage/AGENT-BRIEF.md +207 -0
- package/templates/monorepo/.agents/skills/triage/OUT-OF-SCOPE.md +105 -0
- package/templates/monorepo/.agents/skills/triage/SKILL.md +112 -0
- package/templates/monorepo/.agents/skills/triage/agents/openai.yaml +5 -0
- package/templates/monorepo/.agents/skills/wait-what/SKILL.md +7 -0
- package/templates/monorepo/.agents/skills/wait-what/agents/openai.yaml +5 -0
- package/templates/monorepo/.agents/skills/wayfinder/SKILL.md +128 -0
- package/templates/monorepo/.agents/skills/wayfinder/agents/openai.yaml +5 -0
- package/templates/monorepo/.agents/skills/wizard/SKILL.md +44 -0
- package/templates/monorepo/.agents/skills/wizard/agents/openai.yaml +3 -0
- package/templates/monorepo/.agents/skills/wizard/template.sh +204 -0
- package/templates/monorepo/.agents/skills/writing-for-agents/SKILL-MECHANICS.md +22 -0
- package/templates/monorepo/.agents/skills/writing-for-agents/SKILL.md +81 -0
- package/templates/monorepo/.agents/skills/writing-for-agents/agents/openai.yaml +3 -0
- package/templates/monorepo/.editorconfig +31 -0
- package/templates/monorepo/.gitattributes +39 -0
- package/templates/monorepo/.vscode/extensions.json +5 -0
- package/templates/monorepo/.vscode/launch.json +25 -0
- package/templates/monorepo/.vscode/settings.json +3 -1
- package/templates/monorepo/AGENTS.md +43 -0
- package/templates/monorepo/README.md +27 -0
- package/templates/monorepo/_gitignore +8 -0
- package/templates/monorepo/docs/agents/domain.md +41 -0
- package/templates/monorepo/docs/agents/issue-tracker.md +30 -0
- package/templates/monorepo/docs/agents/triage-labels.md +15 -0
- package/templates/monorepo/envs/.env.example +1 -0
- package/templates/monorepo/oyo.config.json +11 -0
- package/templates/monorepo/package.json +24 -0
- package/templates/monorepo/pnpm-workspace.yaml +32 -0
- package/templates/monorepo/tsconfig.json +4 -0
- package/templates/monorepo/turbo.json +13 -0
- package/templates/monorepo/vite.config.ts +13 -0
- package/templates/monorepo/.vite-hooks/pre-commit +0 -1
- /package/templates/{monorepo/_editorconfig → hono-fullstack/.editorconfig} +0 -0
- /package/templates/{monorepo/_gitattributes → hono-fullstack/.gitattributes} +0 -0
|
@@ -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,40 @@
|
|
|
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 } 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
|
+
}
|
|
@@ -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,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,21 @@
|
|
|
1
|
+
import type { ValidationTargets } from 'hono'
|
|
2
|
+
import { validator } from 'hono-openapi'
|
|
3
|
+
import { flatten, type GenericSchema } 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
|
+
) =>
|
|
13
|
+
validator(target, schema, (result, _c) => {
|
|
14
|
+
if (!result.success) {
|
|
15
|
+
throw E.NORMAL.VALIDATION.create({
|
|
16
|
+
extensions: {
|
|
17
|
+
validationError: flatten(result.error as any),
|
|
18
|
+
},
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
})
|
|
@@ -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,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "@oyolincc/dev-config/tsconfig.bundler.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"verbatimModuleSyntax": true,
|
|
5
|
+
"jsx": "react-jsx",
|
|
6
|
+
"jsxImportSource": "hono/jsx",
|
|
7
|
+
"outDir": "./dist",
|
|
8
|
+
"paths": {
|
|
9
|
+
"@/*": ["./src/*"],
|
|
10
|
+
"@error-categories": ["./src/shared/errors/defs/index.ts"]
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"files": [],
|
|
14
|
+
"include": ["src", "./*.ts", "./*.mts"],
|
|
15
|
+
"exclude": ["node_modules"]
|
|
16
|
+
}
|