@h-ai/cli 0.1.0-alpha9 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +229 -0
- package/README.ja.md +229 -0
- package/README.md +175 -113
- package/dist/chunk-AKV2CQZV.js +1497 -0
- package/dist/chunk-AKV2CQZV.js.map +1 -0
- package/dist/chunk-EF7WOFWZ.js +7557 -0
- package/dist/chunk-EF7WOFWZ.js.map +1 -0
- package/dist/chunk-MUHRBJSW.js +29272 -0
- package/dist/chunk-MUHRBJSW.js.map +1 -0
- package/dist/chunk-ZSDEVXZ7.js +38 -0
- package/dist/{chunk-2H7UOFLK.js.map → chunk-ZSDEVXZ7.js.map} +1 -1
- package/dist/cli-config-templates-HHFHNXBN.js +5 -0
- package/dist/cli-config-templates-HHFHNXBN.js.map +1 -0
- package/dist/cli-skill-templates-PN4FLGBC.js +5 -0
- package/dist/cli-skill-templates-PN4FLGBC.js.map +1 -0
- package/dist/index.js +4444 -554
- package/dist/index.js.map +1 -1
- package/dist/metafile-esm.json +1 -0
- package/dist/src-TEBHR5I5.js +5 -0
- package/dist/src-TEBHR5I5.js.map +1 -0
- package/package.json +35 -15
- package/templates/README.md +56 -114
- package/templates/apps/admin/messages/en-US.json +7 -0
- package/templates/apps/admin/messages/ja-JP.json +40 -0
- package/templates/apps/admin/messages/zh-CN.json +7 -0
- package/templates/apps/admin/src/routes/+layout.svelte.hbs +65 -8
- package/templates/apps/admin/src/routes/+page.svelte.hbs +35 -14
- package/templates/apps/admin/src/routes/admin/+layout.svelte.hbs +54 -22
- package/templates/apps/admin/src/routes/admin/+page.svelte.hbs +33 -24
- package/templates/apps/admin/src/routes/admin/settings/+page.svelte.hbs +16 -13
- package/templates/apps/api/.dockerignore.hbs +25 -0
- package/templates/apps/api/.gitignore.hbs +22 -0
- package/templates/apps/api/.npmrc.hbs +1 -0
- package/templates/apps/api/apps/{{projectName}}-contract/README.md.hbs +39 -0
- package/templates/apps/api/apps/{{projectName}}-contract/package.json.hbs +41 -0
- package/templates/apps/api/apps/{{projectName}}-contract/src/app-contract.ts.hbs +27 -0
- package/templates/apps/api/apps/{{projectName}}-contract/src/app-schemas.ts.hbs +28 -0
- package/templates/apps/api/apps/{{projectName}}-contract/src/index.ts.hbs +5 -0
- package/templates/apps/api/apps/{{projectName}}-contract/src/{{projectName}}-contract.ts.hbs +16 -0
- package/templates/apps/api/apps/{{projectName}}-contract/tests/contract.test.ts.hbs +18 -0
- package/templates/apps/api/apps/{{projectName}}-contract/tsconfig.json.hbs +12 -0
- package/templates/apps/api/apps/{{projectName}}-contract/tsup.config.ts.hbs +11 -0
- package/templates/apps/api/apps/{{projectName}}-contract/vitest.config.ts.hbs +9 -0
- package/templates/apps/api/apps/{{projectName}}-serv/README.md.hbs +60 -0
- package/templates/apps/api/apps/{{projectName}}-serv/config/_core.yml.hbs +17 -0
- package/templates/apps/api/apps/{{projectName}}-serv/config/_serv.yml.hbs +54 -0
- package/templates/apps/api/apps/{{projectName}}-serv/data/.gitkeep.hbs +1 -0
- package/templates/apps/api/apps/{{projectName}}-serv/package.json.hbs +66 -0
- package/templates/apps/api/apps/{{projectName}}-serv/src/app.ts.hbs +119 -0
- package/templates/apps/api/apps/{{projectName}}-serv/src/build-metadata.ts.hbs +7 -0
- package/templates/apps/api/apps/{{projectName}}-serv/src/index.ts.hbs +41 -0
- package/templates/apps/api/apps/{{projectName}}-serv/src/lib/server/init.ts.hbs +165 -0
- package/templates/apps/api/apps/{{projectName}}-serv/src/server/procedures/app-procedures.ts.hbs +57 -0
- package/templates/apps/api/apps/{{projectName}}-serv/src/server/procedures/index.ts.hbs +41 -0
- package/templates/apps/api/apps/{{projectName}}-serv/tests/service.test.ts.hbs +176 -0
- package/templates/apps/api/apps/{{projectName}}-serv/tsconfig.json.hbs +16 -0
- package/templates/apps/api/apps/{{projectName}}-serv/tsup.config.ts.hbs +20 -0
- package/templates/apps/api/apps/{{projectName}}-serv/vitest.config.ts.hbs +12 -0
- package/templates/apps/api/e2e/api-serv.spec.ts.hbs +113 -0
- package/templates/apps/api/e2e/capture-evidence.ts.hbs +23 -0
- package/templates/apps/api/eslint.config.js.hbs +30 -0
- package/templates/apps/api/hai.json.hbs +4 -0
- package/templates/apps/api/images/serv.Dockerfile.hbs +37 -0
- package/templates/apps/api/package.json.hbs +53 -0
- package/templates/apps/api/playwright.config.ts.hbs +67 -0
- package/templates/apps/api/pnpm-workspace.yaml.hbs +40 -0
- package/templates/apps/api/tsconfig.base.json +14 -0
- package/templates/apps/fullstack/.dockerignore.hbs +25 -0
- package/templates/apps/fullstack/.gitignore.hbs +38 -0
- package/templates/apps/fullstack/.npmrc.hbs +1 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/.env.example.hbs +10 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/README.md.hbs +67 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/capacitor.config.ts.hbs +20 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/eslint.config.js.hbs +20 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/index.html.hbs +22 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/messages/en-US.json.hbs +7 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/messages/ja-JP.json.hbs +7 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/messages/zh-CN.json.hbs +7 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/package.json.hbs +86 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/project.inlang/settings.json.hbs +17 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/public/runtime-config.js.hbs +4 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/src/App.svelte.hbs +59 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/src/app.css.hbs +20 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/src/app.d.ts.hbs +8 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/src/build-metadata.ts.hbs +9 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/src/lib/capacitor.ts.hbs +19 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/src/main.ts.hbs +21 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/svelte.config.js.hbs +16 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/tsconfig.json.hbs +23 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/vite.config.ts.hbs +74 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/.env.example.hbs +6 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/README.md.hbs +64 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/eslint.config.js.hbs +20 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/index.html.hbs +20 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/messages/en-US.json.hbs +7 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/messages/ja-JP.json.hbs +7 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/messages/zh-CN.json.hbs +7 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/package.json.hbs +66 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/project.inlang/settings.json.hbs +17 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src/App.svelte.hbs +25 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src/app.css.hbs +18 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src/app.d.ts.hbs +8 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src/build-metadata.ts.hbs +9 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src/main.ts.hbs +20 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/Cargo.toml.hbs +33 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/build.rs.hbs +6 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/capabilities/default.json.hbs +16 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/icons/128x128.png +0 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/icons/128x128@2x.png +0 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/icons/32x32.png +0 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/icons/icon.icns +0 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/icons/icon.ico +0 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/src/lib.rs.hbs +91 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/src/main.rs.hbs +8 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/tauri.conf.json.hbs +46 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/svelte.config.js.hbs +14 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/tsconfig.json.hbs +22 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/vite.config.ts.hbs +89 -0
- package/templates/apps/fullstack/apps/{{projectName}}-miniapp/README.md.hbs +25 -0
- package/templates/apps/fullstack/apps/{{projectName}}-miniapp/messages/en-US.json.hbs +12 -0
- package/templates/apps/fullstack/apps/{{projectName}}-miniapp/messages/ja-JP.json.hbs +12 -0
- package/templates/apps/fullstack/apps/{{projectName}}-miniapp/messages/zh-CN.json.hbs +12 -0
- package/templates/apps/fullstack/apps/{{projectName}}-miniapp/project.inlang/settings.json.hbs +17 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/README.md.hbs +54 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/eslint.config.js.hbs +20 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/index.html.hbs +21 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/messages/en-US.json.hbs +7 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/messages/ja-JP.json.hbs +7 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/messages/zh-CN.json.hbs +7 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/package.json.hbs +53 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/project.inlang/settings.json.hbs +17 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/public/runtime-config.js.hbs +1 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/src/App.svelte.hbs +18 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/src/app.css.hbs +18 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/src/app.d.ts.hbs +8 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/src/build-metadata.ts.hbs +9 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/src/main.ts.hbs +14 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/svelte.config.js.hbs +16 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/tsconfig.json.hbs +23 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/vite.config.ts.hbs +76 -0
- package/templates/apps/fullstack/docs/security-configuration.md.hbs +349 -0
- package/templates/apps/fullstack/e2e/fullstack.spec.ts.hbs +988 -0
- package/templates/apps/fullstack/e2e/session-close.spec.ts.hbs +119 -0
- package/templates/apps/fullstack/eslint.config.js.hbs +41 -0
- package/templates/apps/fullstack/hai.json.hbs +11 -0
- package/templates/apps/fullstack/images/serv.Dockerfile.hbs +38 -0
- package/templates/apps/fullstack/images/web/19-runtime-config.envsh.hbs +5 -0
- package/templates/apps/fullstack/images/web/nginx.conf.hbs +24 -0
- package/templates/apps/fullstack/images/web/runtime-config.js.template.hbs +3 -0
- package/templates/apps/fullstack/images/web.Dockerfile.hbs +37 -0
- package/templates/apps/fullstack/package.json.hbs +61 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/README.md.hbs +40 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/package.json.hbs +30 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/src/admin-contract.ts.hbs +78 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/src/admin-schemas.ts.hbs +134 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/src/app-contract.ts.hbs +20 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/src/app-schemas.ts.hbs +35 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/src/index.ts.hbs +7 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/src/{{projectName}}-contract.ts.hbs +23 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/tests/contract.test.ts.hbs +31 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/tsconfig.json.hbs +9 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/tsup.config.ts.hbs +9 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/README.md.hbs +84 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_ai.yml.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_audit.yml.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_cache.yml.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_core.yml.hbs +22 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_db.yml.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_feedback.yml.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_iam.yml.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_payment.yml.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_reach.yml.hbs +60 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_scheduler.yml.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_serv.yml.hbs +64 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_storage.yml.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_vecdb.yml.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/data/.gitkeep.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/package.json.hbs +62 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/app-server.ts.hbs +115 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/build-metadata.ts.hbs +7 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/index.ts.hbs +40 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/admin-service.ts.hbs +294 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/audit-jobs.ts.hbs +28 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/business-settings.ts.hbs +50 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/messages.ts.hbs +50 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/procedures/admin-procedures.ts.hbs +106 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/procedures/app-procedures.ts.hbs +49 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/procedures/index.ts.hbs +34 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/runtime.ts.hbs +159 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/security-roles.ts.hbs +73 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/tests/app-server.test.ts.hbs +505 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/tests/runtime.test.ts.hbs +72 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/tests/security.test.ts.hbs +183 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/tsconfig.json.hbs +10 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/tsup.config.ts.hbs +18 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/vitest.config.ts.hbs +12 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/.gitignore.hbs +10 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/README.md.hbs +97 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/messages/en-US.json.hbs +164 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/messages/ja-JP.json.hbs +164 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/messages/zh-CN.json.hbs +164 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/package.json.hbs +55 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/project.inlang/settings.json.hbs +11 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/index.ts.hbs +7 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/api/api-client.ts.hbs +94 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/api/feedback-client.ts.hbs +36 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/api/sensitive-actions.svelte.ts.hbs +16 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/api/session-recovery.svelte.ts.hbs +4 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/components/AdminWorkspace.svelte.hbs +122 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/components/AppShell.svelte.hbs +90 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/components/FeedbackEntry.svelte.hbs +86 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/pages/audit.svelte.hbs +94 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/pages/configuration.svelte.hbs +25 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/pages/feedback.svelte.hbs +157 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/pages/roles.svelte.hbs +77 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/pages/settings.svelte.hbs +44 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/pages/users.svelte.hbs +216 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/security/role-label.ts.hbs +12 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/stores/guide-store.ts.hbs +55 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/stores/management-store.svelte.ts.hbs +614 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/stores/theme-store.svelte.ts.hbs +23 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/svelte.config.js.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/tests/api-client.test.ts.hbs +150 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/tests/management-store.test.ts.hbs +253 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/tsconfig.json.hbs +17 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/vitest.config.ts.hbs +7 -0
- package/templates/apps/fullstack/playwright.config.ts.hbs +114 -0
- package/templates/apps/fullstack/playwright.session-close.config.ts.hbs +18 -0
- package/templates/apps/fullstack/pnpm-workspace.yaml.hbs +38 -0
- package/templates/apps/fullstack/tsconfig.base.json +14 -0
- package/templates/apps/h5/messages/en-US.json +3 -0
- package/templates/apps/h5/messages/ja-JP.json +40 -0
- package/templates/apps/h5/messages/zh-CN.json +3 -0
- package/templates/apps/h5/src/routes/+layout.svelte.hbs +85 -30
- package/templates/apps/h5/src/routes/+page.svelte.hbs +20 -8
- package/templates/apps/h5/src/routes/discover/+page.svelte.hbs +17 -6
- package/templates/apps/h5/src/routes/profile/+page.svelte.hbs +17 -6
- package/templates/apps/mobile-app/.env.hbs +3 -0
- package/templates/apps/{android-app → mobile-app}/capacitor.config.ts.hbs +2 -2
- package/templates/apps/mobile-app/index.html.hbs +14 -0
- package/templates/apps/mobile-app/messages/en-US.json +36 -0
- package/templates/apps/mobile-app/messages/ja-JP.json +36 -0
- package/templates/apps/mobile-app/messages/zh-CN.json +36 -0
- package/templates/apps/mobile-app/public/runtime-config.js +1 -0
- package/templates/apps/mobile-app/src/App.svelte.hbs +153 -0
- package/templates/apps/mobile-app/src/lib/api.ts.hbs +213 -0
- package/templates/apps/mobile-app/src/lib/app-config.ts.hbs +14 -0
- package/templates/apps/{android-app → mobile-app}/src/lib/capacitor.ts +6 -7
- package/templates/apps/mobile-app/src/lib/pages/home.svelte.hbs +58 -0
- package/templates/apps/mobile-app/src/lib/pages/profile.svelte.hbs +13 -0
- package/templates/apps/mobile-app/src/lib/pages/tasks.svelte.hbs +16 -0
- package/templates/apps/mobile-app/src/main.ts.hbs +11 -0
- package/templates/apps/website/messages/en-US.json +4 -2
- package/templates/apps/website/messages/ja-JP.json +34 -0
- package/templates/apps/website/messages/zh-CN.json +4 -2
- package/templates/apps/website/scripts/static-website.mjs.hbs +67 -0
- package/templates/apps/website/src/routes/+layout.svelte.hbs +77 -26
- package/templates/apps/website/src/routes/+layout.ts +3 -0
- package/templates/apps/website/src/routes/+page.svelte.hbs +31 -12
- package/templates/apps/website/src/routes/about/+page.svelte.hbs +11 -6
- package/templates/apps/website/src/routes/api/health/+server.ts +3 -0
- package/templates/apps/website/src/routes/contact/+page.svelte.hbs +44 -34
- package/templates/apps/website/src/routes/services/+page.svelte.hbs +27 -40
- package/templates/base/.dockerignore.hbs +27 -0
- package/templates/base/.gitignore.hbs +41 -0
- package/templates/base/.npmrc.hbs +1 -0
- package/templates/base/e2e/app.spec.ts.hbs +213 -0
- package/templates/base/e2e/helpers.ts +1 -1
- package/templates/base/eslint-rules.js +45 -0
- package/templates/base/eslint.config.js.hbs +34 -0
- package/templates/base/hai.json.hbs +4 -0
- package/templates/base/images/web/nginx.conf.hbs +24 -0
- package/templates/base/images/web.Dockerfile.hbs +72 -0
- package/templates/base/package.json.hbs +125 -49
- package/templates/base/playwright.config.ts +44 -6
- package/templates/base/pnpm-workspace.yaml.hbs +40 -0
- package/templates/base/src/app.css.hbs +40 -0
- package/templates/base/src/app.d.ts.hbs +14 -1
- package/templates/base/src/app.html.hbs +13 -0
- package/templates/base/src/hooks.server.ts.hbs +115 -43
- package/templates/base/src/lib/build-metadata.ts.hbs +7 -0
- package/templates/base/src/lib/server/init.ts.hbs +125 -152
- package/templates/base/src/lib/server/kit-config.ts.hbs +40 -0
- package/templates/base/src/routes/+layout.server.ts.hbs +35 -0
- package/templates/base/static/favicon.png +0 -0
- package/templates/base/svelte.config.js.hbs +84 -5
- package/templates/base/tests/scaffold.test.ts.hbs +102 -0
- package/templates/base/tsconfig.json.hbs +50 -0
- package/templates/base/vite.config.ts.hbs +117 -12
- package/templates/base/vitest.config.ts.hbs +19 -0
- package/templates/features/ai/routes/api/chat/+server.ts +6 -7
- package/templates/features/iam/routes-admin/(auth)/+layout.svelte.hbs +3 -17
- package/templates/features/iam/routes-admin/(auth)/auth/forgot-password/+page.svelte.hbs +10 -0
- package/templates/features/iam/routes-admin/(auth)/auth/login/+page.svelte.hbs +9 -96
- package/templates/features/iam/routes-admin/(auth)/auth/register/+page.svelte.hbs +9 -122
- package/templates/features/iam/routes-admin/(auth)/auth/reset-password/+page.svelte.hbs +10 -0
- package/templates/features/iam/routes-h5/auth/forgot-password/+page.svelte.hbs +10 -0
- package/templates/features/iam/routes-h5/auth/login/+page.svelte.hbs +9 -96
- package/templates/features/iam/routes-h5/auth/register/+page.svelte.hbs +9 -112
- package/templates/features/iam/routes-h5/auth/reset-password/+page.svelte.hbs +10 -0
- package/templates/features/iam/routes-shared/api/auth/captcha/+server.ts.hbs +4 -0
- package/templates/features/iam/routes-shared/api/auth/config/+server.ts +4 -0
- package/templates/features/iam/routes-shared/api/auth/login/+server.ts +1 -29
- package/templates/features/iam/routes-shared/api/auth/login/ldap/+server.ts +4 -0
- package/templates/features/iam/routes-shared/api/auth/login/otp/+server.ts +4 -0
- package/templates/features/iam/routes-shared/api/auth/logout/+server.ts +13 -6
- package/templates/features/iam/routes-shared/api/auth/otp/send/+server.ts +4 -0
- package/templates/features/iam/routes-shared/api/auth/password/renew/+server.ts +5 -0
- package/templates/features/iam/routes-shared/api/auth/password-reset/confirm/+server.ts +4 -0
- package/templates/features/iam/routes-shared/api/auth/password-reset/request/+server.ts +4 -0
- package/templates/features/iam/routes-shared/api/auth/reauthenticate/+server.ts +5 -0
- package/templates/features/iam/routes-shared/api/auth/register/+server.ts +1 -23
- package/templates/features/iam/routes-shared/api/auth/session/close/+server.ts.hbs +4 -0
- package/templates/features/iam/routes-website/auth/forgot-password/+page.svelte.hbs +10 -0
- package/templates/features/iam/routes-website/auth/login/+page.svelte.hbs +11 -0
- package/templates/features/iam/routes-website/auth/register/+page.svelte.hbs +11 -0
- package/templates/features/iam/routes-website/auth/reset-password/+page.svelte.hbs +10 -0
- package/templates/features/payment/routes/api/v1/payment/create/+server.ts +25 -23
- package/templates/features/payment/routes/api/v1/payment/notify/[provider]/+server.ts +5 -2
- package/templates/features/storage/routes/api/upload/+server.ts +10 -8
- package/templates/i18n/project.inlang/settings.json +2 -2
- package/templates/shared/.gitattributes +11 -0
- package/templates/shared/build-metadata.ts +42 -0
- package/templates/shared/container-runtime-config.sh +30 -0
- package/templates/shared/e2e-env.ts +98 -0
- package/templates/shared/hash-router.svelte.ts +83 -0
- package/templates/shared/public-base-path.mjs +19 -0
- package/templates/shared/run-e2e.mjs +104 -0
- package/templates/shared/vite-runtime-config.ts +56 -0
- package/templates/skills/AGENTS.md +75 -16
- package/templates/skills/CLAUDE.md +0 -11
- package/templates/skills/bridges/admin/AGENTS.md +89 -0
- package/templates/skills/bridges/api/AGENTS.md +83 -0
- package/templates/skills/bridges/fullstack/AGENTS.md.hbs +102 -0
- package/templates/skills/bridges/h5/AGENTS.md +88 -0
- package/templates/skills/bridges/mobile-app/AGENTS.md +100 -0
- package/templates/skills/bridges/website/AGENTS.md +88 -0
- package/templates/skills/copilot-instructions.md +3 -59
- package/templates/skills/hai-ai/SKILL.md +44 -715
- package/templates/skills/hai-ai/guide.md +457 -0
- package/templates/skills/hai-ai/reference.md +292 -0
- package/templates/skills/hai-api-client/SKILL.md +26 -339
- package/templates/skills/hai-api-client/reference.md +180 -0
- package/templates/skills/hai-api-contract/SKILL.md +36 -0
- package/templates/skills/hai-api-contract/reference.md +280 -0
- package/templates/skills/hai-app-create/SKILL.md +38 -351
- package/templates/skills/hai-app-create/collaboration.md +52 -0
- package/templates/skills/hai-app-create/development.md +243 -0
- package/templates/skills/hai-app-create/reference.md +376 -0
- package/templates/skills/hai-app-review/SKILL.md +57 -126
- package/templates/skills/hai-app-review/differential.md +34 -0
- package/templates/skills/hai-app-tests/SKILL.md +34 -454
- package/templates/skills/hai-app-tests/reference.md +462 -0
- package/templates/skills/hai-app-tests/validation.md +42 -0
- package/templates/skills/hai-audit/SKILL.md +37 -122
- package/templates/skills/hai-audit/reference.md +184 -0
- package/templates/skills/hai-build/SKILL.md +62 -315
- package/templates/skills/hai-build/paths.md +30 -0
- package/templates/skills/hai-build/reference.md +353 -0
- package/templates/skills/hai-cache/SKILL.md +26 -175
- package/templates/skills/hai-cache/reference.md +229 -0
- package/templates/skills/hai-capacitor/SKILL.md +24 -364
- package/templates/skills/hai-capacitor/reference.md +358 -0
- package/templates/skills/hai-change-plan/SKILL.md +46 -0
- package/templates/skills/hai-ci/SKILL.md +114 -0
- package/templates/skills/hai-core/SKILL.md +31 -469
- package/templates/skills/hai-core/reference.md +557 -0
- package/templates/skills/hai-core/request-access.md +65 -0
- package/templates/skills/hai-crypto/SKILL.md +29 -180
- package/templates/skills/hai-crypto/reference.md +317 -0
- package/templates/skills/hai-datapipe/SKILL.md +24 -207
- package/templates/skills/hai-datapipe/reference.md +204 -0
- package/templates/skills/hai-deploy/SKILL.md +53 -178
- package/templates/skills/hai-deploy/credentials.md +19 -0
- package/templates/skills/hai-deploy/middleware.md +129 -0
- package/templates/skills/hai-feedback/SKILL.md +85 -0
- package/templates/skills/hai-framework-sync/SKILL.md +105 -0
- package/templates/skills/hai-framework-sync/sync.md +49 -0
- package/templates/skills/hai-iam/SKILL.md +53 -325
- package/templates/skills/hai-iam/reference.md +535 -0
- package/templates/skills/hai-kit/SKILL.md +33 -329
- package/templates/skills/hai-kit/reference.md +202 -0
- package/templates/skills/hai-payment/SKILL.md +28 -262
- package/templates/skills/hai-payment/reference.md +295 -0
- package/templates/skills/hai-pr-review/SKILL.md +41 -0
- package/templates/skills/hai-reach/SKILL.md +28 -300
- package/templates/skills/hai-reach/reference.md +363 -0
- package/templates/skills/hai-reldb/SKILL.md +28 -449
- package/templates/skills/hai-reldb/reference.md +500 -0
- package/templates/skills/hai-scheduler/SKILL.md +26 -174
- package/templates/skills/hai-scheduler/reference.md +216 -0
- package/templates/skills/hai-serv/SKILL.md +60 -0
- package/templates/skills/hai-serv/reference.md +792 -0
- package/templates/skills/hai-spec-implement/SKILL.md +50 -0
- package/templates/skills/hai-spec-implement/changes.md +67 -0
- package/templates/skills/hai-spec-implement/evaluation.md +18 -0
- package/templates/skills/hai-spec-implement/handoff.md +47 -0
- package/templates/skills/hai-spec-implement/templates.md +117 -0
- package/templates/skills/hai-spec-implement/workflow.md +56 -0
- package/templates/skills/hai-spec-review/SKILL.md +57 -0
- package/templates/skills/hai-spec-review/checklist.md +71 -0
- package/templates/skills/hai-storage/SKILL.md +31 -262
- package/templates/skills/hai-storage/reference.md +284 -0
- package/templates/skills/hai-ui/SKILL.md +62 -238
- package/templates/skills/hai-ui/guide.md +81 -0
- package/templates/skills/hai-ui/reference.md +705 -0
- package/templates/skills/hai-ui-design/SKILL.md +31 -0
- package/templates/skills/hai-ui-design/patterns.md +31 -0
- package/templates/skills/hai-ui-review/SKILL.md +32 -0
- package/templates/skills/hai-ui-review/checklist.md +29 -0
- package/templates/skills/hai-vecdb/SKILL.md +25 -267
- package/templates/skills/hai-vecdb/reference.md +325 -0
- package/templates/skills/opencode.json +0 -5
- package/dist/chunk-2H7UOFLK.js +0 -10
- package/dist/chunk-LANIDJC7.js +0 -659
- package/dist/chunk-LANIDJC7.js.map +0 -1
- package/dist/chunk-YV7WPUI6.js +0 -206
- package/dist/chunk-YV7WPUI6.js.map +0 -1
- package/dist/config-templates-S5RI2MC6.js +0 -5
- package/dist/config-templates-S5RI2MC6.js.map +0 -1
- package/dist/skill-templates-N5DU5FNX.js +0 -5
- package/dist/skill-templates-N5DU5FNX.js.map +0 -1
- package/dist/src-XJ6YXNAF.js +0 -15030
- package/dist/src-XJ6YXNAF.js.map +0 -1
- package/templates/apps/android-app/.env.hbs +0 -3
- package/templates/apps/android-app/messages/en-US.json +0 -24
- package/templates/apps/android-app/messages/zh-CN.json +0 -24
- package/templates/apps/android-app/src/lib/api.ts.hbs +0 -30
- package/templates/apps/android-app/src/routes/+layout.svelte.hbs +0 -42
- package/templates/apps/android-app/src/routes/+layout.ts +0 -7
- package/templates/apps/android-app/src/routes/+page.svelte.hbs +0 -27
- package/templates/apps/api/src/routes/+layout.svelte +0 -14
- package/templates/apps/api/src/routes/+page.svelte +0 -11
- package/templates/apps/api/src/routes/api/v1/health/+server.ts +0 -14
- package/templates/apps/api/src/routes/api/v1/items/+server.ts +0 -37
- package/templates/apps/api/src/routes/api/v1/items/[id]/+server.ts +0 -30
- package/templates/base/src/app.css +0 -2
- package/templates/base/tsconfig.json +0 -8
|
@@ -4,25 +4,50 @@
|
|
|
4
4
|
* =============================================================================
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
{{#if features.crypto}}
|
|
8
|
+
import type { TransportEncryptionOptions } from '@h-ai/kit'
|
|
9
|
+
{{/if}}
|
|
7
10
|
import type { Handle } from '@sveltejs/kit'
|
|
11
|
+
{{#if features.cache}}
|
|
12
|
+
import process from 'node:process'
|
|
13
|
+
{{else}}
|
|
14
|
+
{{#if features.crypto}}
|
|
15
|
+
import process from 'node:process'
|
|
16
|
+
{{/if}}
|
|
17
|
+
{{/if}}
|
|
18
|
+
{{#if hasI18n}}
|
|
19
|
+
import { base } from '$app/paths'
|
|
20
|
+
{{else}}
|
|
21
|
+
{{#if features.iam}}
|
|
22
|
+
import { base } from '$app/paths'
|
|
23
|
+
{{else}}
|
|
24
|
+
{{#if features.crypto}}
|
|
25
|
+
import { base } from '$app/paths'
|
|
26
|
+
{{/if}}
|
|
27
|
+
{{/if}}
|
|
28
|
+
{{/if}}
|
|
29
|
+
{{#if hasI18n}}
|
|
30
|
+
import { paraglideMiddleware } from '$lib/paraglide/server.js'
|
|
31
|
+
{{/if}}
|
|
8
32
|
import { initApp } from '$lib/server/init.js'
|
|
33
|
+
import { getKitConfig } from '$lib/server/kit-config.js'
|
|
34
|
+
{{#if features.cache}}
|
|
35
|
+
import { cache } from '@h-ai/cache'
|
|
36
|
+
{{/if}}
|
|
9
37
|
import { core } from '@h-ai/core'
|
|
10
|
-
|
|
38
|
+
{{#if features.crypto}}
|
|
39
|
+
import { {{#if features.db}}createReldbTransportKeyStore{{else}}createInMemoryKeyStore{{/if}}, crypto, parseTransportServerKeyRing } from '@h-ai/crypto'
|
|
40
|
+
{{/if}}
|
|
11
41
|
{{#if features.iam}}
|
|
12
42
|
import { iam } from '@h-ai/iam'
|
|
13
43
|
{{/if}}
|
|
44
|
+
import { kit } from '@h-ai/kit'
|
|
14
45
|
{{#if features.crypto}}
|
|
15
|
-
|
|
46
|
+
{{#if features.db}}
|
|
47
|
+
import { reldb } from '@h-ai/reldb'
|
|
16
48
|
{{/if}}
|
|
17
|
-
{{#if hasI18n}}
|
|
18
|
-
import { paraglideMiddleware } from '$lib/paraglide/server.js'
|
|
19
49
|
{{/if}}
|
|
20
50
|
|
|
21
|
-
{{#if features.crypto}}
|
|
22
|
-
// 初始化加密模块(同步)
|
|
23
|
-
crypto.init()
|
|
24
|
-
|
|
25
|
-
{{/if}}
|
|
26
51
|
// =============================================================================
|
|
27
52
|
// 应用初始化
|
|
28
53
|
// =============================================================================
|
|
@@ -59,19 +84,17 @@ const initHandle: Handle = async ({ event, resolve }) => {
|
|
|
59
84
|
* API 请求跳过 paraglideMiddleware(不需要页面级 locale + 避免消耗 body)
|
|
60
85
|
*/
|
|
61
86
|
const i18nHandle: Handle = async ({ event, resolve }) => {
|
|
62
|
-
if (event.url.pathname.startsWith(
|
|
87
|
+
if (event.url.pathname.startsWith(`${base}/api/`)) {
|
|
63
88
|
const locale = event.cookies.get('PARAGLIDE_LOCALE') ?? '{{defaultLocale}}'
|
|
64
89
|
event.locals.locale = locale
|
|
65
|
-
kit.i18n.
|
|
66
|
-
return resolve(event)
|
|
90
|
+
return kit.i18n.runWithLocale(locale, () => resolve(event))
|
|
67
91
|
}
|
|
68
92
|
|
|
69
93
|
return paraglideMiddleware(event.request, async ({ locale }) => {
|
|
70
94
|
event.locals.locale = locale
|
|
71
|
-
kit.i18n.
|
|
72
|
-
return resolve(event, {
|
|
95
|
+
return kit.i18n.runWithLocale(locale, () => resolve(event, {
|
|
73
96
|
transformPageChunk: ({ html }) => html.replace('%lang%', locale),
|
|
74
|
-
})
|
|
97
|
+
}))
|
|
75
98
|
})
|
|
76
99
|
}
|
|
77
100
|
|
|
@@ -80,35 +103,84 @@ const i18nHandle: Handle = async ({ event, resolve }) => {
|
|
|
80
103
|
// hai Handle(会话验证 + 限流 + 日志)
|
|
81
104
|
// =============================================================================
|
|
82
105
|
|
|
83
|
-
|
|
84
|
-
{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
+
let configuredHandle: Handle | undefined
|
|
107
|
+
const haiHandle: Handle = async (input) => {
|
|
108
|
+
if (!configuredHandle) {
|
|
109
|
+
const settings = getKitConfig()
|
|
110
|
+
{{#if features.crypto}}
|
|
111
|
+
let transport: TransportEncryptionOptions | undefined
|
|
112
|
+
if (settings.transport !== false) {
|
|
113
|
+
{{#unless features.db}}
|
|
114
|
+
if (core.module.requiresSharedState(process.env))
|
|
115
|
+
throw new Error('Production transport requires the db feature and a shared database registry')
|
|
116
|
+
{{/unless}}
|
|
117
|
+
const ring = parseTransportServerKeyRing(process.env.HAI_CRYPTO_TRANSPORT_SERVERKEYRING)
|
|
118
|
+
if (!ring.success)
|
|
119
|
+
throw new Error(`HAI_CRYPTO_TRANSPORT_SERVERKEYRING: ${ring.error.message} (${ring.error.code})`)
|
|
120
|
+
transport = {
|
|
121
|
+
...settings.transport,
|
|
122
|
+
basePath: base,
|
|
123
|
+
serverKeyRing: ring.data,
|
|
124
|
+
{{#if features.db}}
|
|
125
|
+
keyStore: createReldbTransportKeyStore({ reldb, ttlSeconds: 3600 }),
|
|
126
|
+
{{else}}
|
|
127
|
+
keyStore: createInMemoryKeyStore(),
|
|
128
|
+
{{/if}}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
{{else}}
|
|
132
|
+
if (settings.transport !== false)
|
|
133
|
+
throw new Error('Transport encryption requires the crypto feature; add it before enabling kit.transport')
|
|
134
|
+
{{/if}}
|
|
135
|
+
configuredHandle = kit.createHandle({
|
|
136
|
+
trustedProxies: settings.trustedProxies,
|
|
137
|
+
access: settings.access,
|
|
138
|
+
{{#if features.crypto}}
|
|
139
|
+
crypto: { crypto, transport },
|
|
140
|
+
{{/if}}
|
|
141
|
+
{{#if features.iam}}
|
|
142
|
+
auth: {
|
|
143
|
+
verifyToken: async (token) => {
|
|
144
|
+
const result = await iam.auth.verifyToken(token)
|
|
145
|
+
if (!result.success)
|
|
146
|
+
return null
|
|
147
|
+
const session = result.data
|
|
148
|
+
// 映射为 kit 的 SessionData 形态(携带守卫所需的核心字段)
|
|
149
|
+
return {
|
|
150
|
+
userId: session.userId,
|
|
151
|
+
username: session.username,
|
|
152
|
+
roles: session.roles,
|
|
153
|
+
permissions: session.permissions,
|
|
154
|
+
data: session.data,
|
|
155
|
+
}
|
|
106
156
|
},
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
157
|
+
loginUrl: `${base}/auth/login`,
|
|
158
|
+
protectedPaths: ['/admin/*', '/api/*'].map(path => `${base}${path}`),
|
|
159
|
+
publicPaths: [...kit.auth.publicPaths, '/api/auth/logout', '/api/public/*', '/api/health'].map(path => `${base}${path}`),
|
|
160
|
+
operations: () => iam.auth,
|
|
161
|
+
},
|
|
162
|
+
{{/if}}
|
|
163
|
+
{{#if features.cache}}
|
|
164
|
+
rateLimit: { windowMs: 60000, maxRequests: 200, store: kit.middleware.createCacheRateLimitStore(cache, { namespace: '{{projectName}}', allowMemory: process.env.NODE_ENV !== 'production' || process.env.HAI_E2E === '1' }) },
|
|
165
|
+
{{else}}
|
|
166
|
+
// 未选择cache能力时不启用限流;启用前须接入共享原子store。
|
|
167
|
+
rateLimit: false,
|
|
168
|
+
{{/if}}
|
|
169
|
+
logging: { logBody: false },
|
|
170
|
+
onError: (error: unknown, _event) => {
|
|
171
|
+
core.logger.error('Request error:', { error })
|
|
172
|
+
return new Response(
|
|
173
|
+
JSON.stringify({
|
|
174
|
+
success: false,
|
|
175
|
+
error: core.error.toPublic({ code: 'INTERNAL_ERROR', message: '', httpStatus: 500 }),
|
|
176
|
+
}),
|
|
177
|
+
{ status: 500, headers: { 'Content-Type': 'application/json' } },
|
|
178
|
+
)
|
|
179
|
+
},
|
|
180
|
+
})
|
|
181
|
+
}
|
|
182
|
+
return configuredHandle(input)
|
|
183
|
+
}
|
|
112
184
|
|
|
113
185
|
// =============================================================================
|
|
114
186
|
// 组合 Handle
|
|
@@ -1,190 +1,163 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
* 初始化顺序:
|
|
9
|
-
* 1. core.init — 加载配置文件(约定优于配置)
|
|
10
|
-
{{#if features.db}}
|
|
11
|
-
* 2. reldb.init — 数据库连接
|
|
1
|
+
/** 应用声明真实模块顺序;并发、失败回滚与关闭重试由 core 处理。 */
|
|
2
|
+
{{#if features.ai}}
|
|
3
|
+
import { ai, AIConfigSchema } from '@h-ai/ai'
|
|
4
|
+
{{/if}}
|
|
5
|
+
{{#if features.audit}}
|
|
6
|
+
import { audit, AuditInitConfigSchema } from '@h-ai/audit'
|
|
12
7
|
{{/if}}
|
|
13
8
|
{{#if features.cache}}
|
|
14
|
-
|
|
9
|
+
import { cache, CacheConfigSchema } from '@h-ai/cache'
|
|
15
10
|
{{/if}}
|
|
16
|
-
{
|
|
17
|
-
|
|
11
|
+
import { core } from '@h-ai/core'
|
|
12
|
+
{{#if features.crypto}}
|
|
13
|
+
import { crypto } from '@h-ai/crypto'
|
|
18
14
|
{{/if}}
|
|
19
|
-
{{#if features.
|
|
20
|
-
|
|
15
|
+
{{#if features.feedback}}
|
|
16
|
+
import { feedback } from '@h-ai/feedback'
|
|
21
17
|
{{/if}}
|
|
22
18
|
{{#if features.iam}}
|
|
23
|
-
|
|
19
|
+
import { iam, IamConfigSchema } from '@h-ai/iam'
|
|
24
20
|
{{/if}}
|
|
25
|
-
{{#if features.
|
|
26
|
-
|
|
21
|
+
{{#if features.reach}}
|
|
22
|
+
import { reach, ReachConfigSchema } from '@h-ai/reach'
|
|
27
23
|
{{/if}}
|
|
28
|
-
*/
|
|
29
|
-
|
|
30
|
-
import { core } from '@h-ai/core'
|
|
31
24
|
{{#if features.db}}
|
|
32
25
|
import { reldb, ReldbConfigSchema } from '@h-ai/reldb'
|
|
33
26
|
{{/if}}
|
|
34
|
-
{{#if features.
|
|
35
|
-
|
|
27
|
+
{{#if features.audit}}
|
|
28
|
+
{{#if features.scheduler}}
|
|
29
|
+
import { scheduler, SchedulerConfigSchema } from '@h-ai/scheduler'
|
|
36
30
|
{{/if}}
|
|
37
|
-
{{#if features.iam}}
|
|
38
|
-
import type { IamConfigSettingsInput } from '@h-ai/iam'
|
|
39
|
-
import { iam } from '@h-ai/iam'
|
|
40
31
|
{{/if}}
|
|
41
32
|
{{#if features.storage}}
|
|
42
|
-
import type { StorageConfigInput } from '@h-ai/storage'
|
|
43
33
|
import { storage, StorageConfigSchema } from '@h-ai/storage'
|
|
44
34
|
{{/if}}
|
|
45
|
-
{{#if features.
|
|
46
|
-
import
|
|
47
|
-
|
|
48
|
-
{{
|
|
49
|
-
{
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
{{
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
35
|
+
{{#if features.vecdb}}
|
|
36
|
+
import { vecdb, VecdbConfigSchema } from '@h-ai/vecdb'
|
|
37
|
+
{{/if}}
|
|
38
|
+
{{#if features.feedback}}
|
|
39
|
+
import { buildMetadata } from '../build-metadata.js'
|
|
40
|
+
{{/if}}
|
|
41
|
+
|
|
42
|
+
{{#if features.feedback}}
|
|
43
|
+
let feedbackRetry: ReturnType<typeof setTimeout> | undefined
|
|
44
|
+
let feedbackStarting: Promise<void> | undefined
|
|
45
|
+
let feedbackClosing = false
|
|
46
|
+
let feedbackFailure: string | number | undefined
|
|
47
|
+
|
|
48
|
+
/** 可选辅助能力独立重试;不能回滚已经就绪的 IAM 与业务模块。 */
|
|
49
|
+
function startFeedback(): Promise<void> {
|
|
50
|
+
if (feedbackStarting)
|
|
51
|
+
return feedbackStarting
|
|
52
|
+
feedbackClosing = false
|
|
53
|
+
feedbackStarting = (async () => {
|
|
54
|
+
try {
|
|
55
|
+
const result = await feedback.init({ ...core.config.getOrThrow<import('@h-ai/feedback').FeedbackConfigInput>('feedback'), ...buildMetadata })
|
|
56
|
+
if (!result.success) {
|
|
57
|
+
if (feedbackFailure !== result.error.code)
|
|
58
|
+
core.logger.warn('Optional feedback unavailable; business runtime remains ready', { module: 'feedback', code: result.error.code })
|
|
59
|
+
feedbackFailure = result.error.code
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
feedbackFailure = undefined
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
if (feedbackFailure !== 'configuration')
|
|
67
|
+
core.logger.warn('Optional feedback configuration unavailable; business runtime remains ready', { module: 'feedback' })
|
|
68
|
+
feedbackFailure = 'configuration'
|
|
69
|
+
}
|
|
70
|
+
if (feedbackFailure && !feedbackClosing) {
|
|
71
|
+
feedbackRetry = setTimeout(() => {
|
|
72
|
+
feedbackRetry = undefined
|
|
73
|
+
void startFeedback()
|
|
74
|
+
}, 30000)
|
|
75
|
+
feedbackRetry.unref()
|
|
76
|
+
}
|
|
77
|
+
})().finally(() => { feedbackStarting = undefined })
|
|
78
|
+
return feedbackStarting
|
|
79
|
+
}
|
|
72
80
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
81
|
+
async function closeFeedback() {
|
|
82
|
+
feedbackClosing = true
|
|
83
|
+
if (feedbackRetry)
|
|
84
|
+
clearTimeout(feedbackRetry)
|
|
85
|
+
feedbackRetry = undefined
|
|
86
|
+
await feedbackStarting
|
|
87
|
+
return feedback.close()
|
|
88
|
+
}
|
|
78
89
|
|
|
79
|
-
{{#if features.db}}
|
|
80
|
-
// ─── 配置校验 ───
|
|
81
|
-
const dbValidation = core.config.validate('db', ReldbConfigSchema)
|
|
82
|
-
if (!dbValidation.success) {
|
|
83
|
-
throw new Error(`DB config invalid: ${dbValidation.error.message}`)
|
|
84
|
-
}
|
|
85
|
-
{{/if}}
|
|
86
|
-
{{#if features.cache}}
|
|
87
|
-
const cacheValidation = core.config.validate('cache', CacheConfigSchema)
|
|
88
|
-
if (!cacheValidation.success) {
|
|
89
|
-
throw new Error(`Cache config invalid: ${cacheValidation.error.message}`)
|
|
90
|
-
}
|
|
91
90
|
{{/if}}
|
|
92
91
|
|
|
92
|
+
const runtime = core.module.createRuntime([
|
|
93
|
+
{ name: 'configuration', start: () => { core.init({ configDir: './config' }) }, close: () => {} },
|
|
93
94
|
{{#if features.db}}
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
{ name: 'reldb', start: async () => {
|
|
96
|
+
const config = ReldbConfigSchema.parse(core.config.getOrThrow('db'))
|
|
97
|
+
if (config.type === 'sqlite' && config.database !== ':memory:') {
|
|
98
|
+
const { mkdir } = await import('node:fs/promises')
|
|
99
|
+
const { dirname } = await import('node:path')
|
|
100
|
+
await mkdir(dirname(config.database), { recursive: true })
|
|
101
|
+
}
|
|
102
|
+
return reldb.init(config)
|
|
103
|
+
}, close: () => reldb.close() },
|
|
96
104
|
{{/if}}
|
|
97
105
|
{{#if features.cache}}
|
|
98
|
-
|
|
99
|
-
{{/if}}
|
|
100
|
-
{{#if features.iam}}
|
|
101
|
-
const iamConfig = core.config.getOrThrow<IamConfigSettingsInput>('iam')
|
|
106
|
+
{ name: 'cache', start: () => cache.init(CacheConfigSchema.parse(core.config.getOrThrow('cache'))), close: () => cache.close() },
|
|
102
107
|
{{/if}}
|
|
103
|
-
{{#if features.
|
|
104
|
-
|
|
105
|
-
{{/if}}
|
|
106
|
-
{{#if features.ai}}
|
|
107
|
-
const aiConfig = core.config.get<AIConfigInput>('ai')
|
|
108
|
-
{{/if}}
|
|
109
|
-
{{#if features.reach}}
|
|
110
|
-
const reachConfig = core.config.get<ReachConfigInput>('reach')
|
|
111
|
-
{{/if}}
|
|
112
|
-
|
|
113
|
-
{{#if features.db}}
|
|
114
|
-
// ─── 确保数据目录存在(SQLite) ───
|
|
115
|
-
if (dbConfig.type === 'sqlite') {
|
|
116
|
-
const path = await import('node:path')
|
|
117
|
-
const fs = await import('node:fs')
|
|
118
|
-
const dbDir = path.dirname(dbConfig.database)
|
|
119
|
-
if (!fs.existsSync(dbDir)) {
|
|
120
|
-
fs.mkdirSync(dbDir, { recursive: true })
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
// ─── 初始化数据库 ───
|
|
125
|
-
const dbResult = await reldb.init(dbConfig)
|
|
126
|
-
if (!dbResult.success) {
|
|
127
|
-
throw new Error(`Database initialization failed: ${dbResult.error.message}`)
|
|
128
|
-
}
|
|
108
|
+
{{#if features.vecdb}}
|
|
109
|
+
{ name: 'vecdb', start: () => vecdb.init(VecdbConfigSchema.parse(core.config.getOrThrow('vecdb'))), close: () => vecdb.close() },
|
|
129
110
|
{{/if}}
|
|
130
|
-
|
|
131
|
-
{
|
|
132
|
-
// ─── 初始化缓存 ───
|
|
133
|
-
const cacheResult = await cache.init(cacheConfig)
|
|
134
|
-
if (!cacheResult.success) {
|
|
135
|
-
throw new Error(`Cache initialization failed: ${cacheResult.error.message}`)
|
|
136
|
-
}
|
|
111
|
+
{{#if features.crypto}}
|
|
112
|
+
{ name: 'crypto', start: () => crypto.init(), close: () => crypto.close() },
|
|
137
113
|
{{/if}}
|
|
138
|
-
|
|
139
114
|
{{#if features.storage}}
|
|
140
|
-
|
|
141
|
-
if (storageConfig) {
|
|
142
|
-
const storageValidation = core.config.validate('storage', StorageConfigSchema)
|
|
143
|
-
if (storageValidation.success) {
|
|
144
|
-
const storageResult = await storage.init(storageConfig)
|
|
145
|
-
if (!storageResult.success) {
|
|
146
|
-
core.logger.warn('Storage initialization failed', { error: storageResult.error.message })
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
}
|
|
115
|
+
{ name: 'storage', start: () => storage.init(StorageConfigSchema.parse(core.config.getOrThrow('storage'))), close: () => storage.close() },
|
|
150
116
|
{{/if}}
|
|
151
|
-
|
|
152
117
|
{{#if features.reach}}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
core.logger.warn('Reach initialization failed', { error: reachResult.error.message })
|
|
158
|
-
}
|
|
159
|
-
}
|
|
118
|
+
{ name: 'reach', enabled: () => Boolean(core.config.get('reach')), start: () => reach.init(ReachConfigSchema.parse(core.config.getOrThrow('reach'))), close: () => reach.close() },
|
|
119
|
+
{{/if}}
|
|
120
|
+
{{#if features.audit}}
|
|
121
|
+
{ name: 'audit', start: () => audit.init({ ...AuditInitConfigSchema.parse(core.config.get('audit') ?? {}){{#if features.storage}}, storage{{/if}}{{#if features.reach}}, reach{{/if}} }), close: () => audit.close() },
|
|
160
122
|
{{/if}}
|
|
161
|
-
|
|
162
123
|
{{#if features.iam}}
|
|
163
|
-
|
|
164
|
-
const iamResult = await iam.init(iamConfig)
|
|
165
|
-
if (!iamResult.success) {
|
|
166
|
-
throw new Error(`IAM initialization failed: ${iamResult.error.message}`)
|
|
167
|
-
}
|
|
124
|
+
{ name: 'iam', start: () => iam.init({ ...IamConfigSchema.parse(core.config.getOrThrow('iam')){{#if features.reach}}, reach{{/if}} }), close: () => iam.close() },
|
|
168
125
|
{{/if}}
|
|
169
|
-
|
|
170
126
|
{{#if features.audit}}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
127
|
+
{{#if features.scheduler}}
|
|
128
|
+
{ name: 'audit-jobs', enabled: () => Boolean(audit.schedulerPlan), start: async () => {
|
|
129
|
+
const schedule = audit.schedulerPlan
|
|
130
|
+
if (!schedule)
|
|
131
|
+
return
|
|
132
|
+
const initialized = await scheduler.init({ ...SchedulerConfigSchema.parse(core.config.get('scheduler') ?? {}), ...schedule })
|
|
133
|
+
if (!initialized.success)
|
|
134
|
+
return initialized
|
|
135
|
+
const started = scheduler.start()
|
|
136
|
+
if (!started.success)
|
|
137
|
+
await scheduler.close()
|
|
138
|
+
return started
|
|
139
|
+
}, close: () => scheduler.close() },
|
|
140
|
+
{{/if}}
|
|
141
|
+
{{/if}}
|
|
142
|
+
{{#if features.feedback}}
|
|
143
|
+
{ name: 'feedback', enabled: () => Boolean(core.config.get('feedback')), start: startFeedback, close: closeFeedback },
|
|
176
144
|
{{/if}}
|
|
177
|
-
|
|
178
145
|
{{#if features.ai}}
|
|
179
|
-
|
|
180
|
-
if (aiConfig?.llm?.apiKey) {
|
|
181
|
-
const aiResult = await ai.init(aiConfig)
|
|
182
|
-
if (!aiResult.success) {
|
|
183
|
-
core.logger.warn('AI initialization failed', { error: aiResult.error.message })
|
|
184
|
-
}
|
|
185
|
-
}
|
|
146
|
+
{ name: 'ai', start: () => ai.init(AIConfigSchema.parse(core.config.getOrThrow('ai'))), close: () => ai.close() },
|
|
186
147
|
{{/if}}
|
|
148
|
+
{ name: 'bootstrap', start: () => { core.logger.info('Application initialized') }, close: () => {} },
|
|
149
|
+
])
|
|
150
|
+
|
|
151
|
+
/** 启动失败只报告模块、错误码和配置路径,私密值不进入错误上下文。 */
|
|
152
|
+
export async function initApp(): Promise<void> {
|
|
153
|
+
const result = await runtime.start()
|
|
154
|
+
if (!result.success)
|
|
155
|
+
throw new Error(result.error.message, { cause: result.error })
|
|
156
|
+
}
|
|
187
157
|
|
|
188
|
-
|
|
189
|
-
|
|
158
|
+
/** 清理失败时保留依赖和清理义务,可再次调用。 */
|
|
159
|
+
export async function closeApp(): Promise<void> {
|
|
160
|
+
const result = await runtime.close()
|
|
161
|
+
if (!result.success)
|
|
162
|
+
throw new Error(result.error.message, { cause: result.error })
|
|
190
163
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{{! @skipIfEmpty }}
|
|
2
|
+
{{#unless isSvelteOnlyApp}}
|
|
3
|
+
import type { KitConfig } from '@h-ai/kit'
|
|
4
|
+
import { base } from '$app/paths'
|
|
5
|
+
import { core } from '@h-ai/core'
|
|
6
|
+
import { KitConfigSchema } from '@h-ai/kit'
|
|
7
|
+
|
|
8
|
+
let configured: KitConfig | undefined
|
|
9
|
+
|
|
10
|
+
/** 输入已由 Schema 校验为绝对路径;宿主补构建目录并保留绝对路径类型。 */
|
|
11
|
+
function mounted(path: string): `/${string}` {
|
|
12
|
+
if (!base || path === base || path.startsWith(`${base}/`))
|
|
13
|
+
return `/${path.slice(1)}`
|
|
14
|
+
return `/${base.slice(1)}${path}`
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** 启动时固定服务端配置;浏览器只能接收根 load 明确投影的 transport。 */
|
|
18
|
+
export function getKitConfig(): KitConfig {
|
|
19
|
+
if (configured)
|
|
20
|
+
return configured
|
|
21
|
+
const loaded = core.config.load('kit', './config/_kit.yml', KitConfigSchema)
|
|
22
|
+
if (!loaded.success)
|
|
23
|
+
throw new Error(loaded.error.message)
|
|
24
|
+
const transport = loaded.data.transport
|
|
25
|
+
configured = {
|
|
26
|
+
...loaded.data,
|
|
27
|
+
transport: transport === false
|
|
28
|
+
? false
|
|
29
|
+
: {
|
|
30
|
+
...transport,
|
|
31
|
+
keyExchangePath: mounted(transport.keyExchangePath),
|
|
32
|
+
excludePaths: transport.excludePaths.map(mounted),
|
|
33
|
+
routePlaintextBytes: transport.routePlaintextBytes
|
|
34
|
+
? Object.fromEntries(Object.entries(transport.routePlaintextBytes).map(([path, bytes]) => [mounted(path), bytes]))
|
|
35
|
+
: undefined,
|
|
36
|
+
},
|
|
37
|
+
}
|
|
38
|
+
return configured
|
|
39
|
+
}
|
|
40
|
+
{{/unless}}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{{! @skipIfEmpty }}
|
|
2
|
+
{{#unless isSvelteOnlyApp}}
|
|
3
|
+
import type { CoreConfig } from '@h-ai/core'
|
|
4
|
+
import type { KitPublicConfig } from '@h-ai/kit'
|
|
5
|
+
import { getKitConfig } from '$lib/server/kit-config.js'
|
|
6
|
+
import { core } from '@h-ai/core'
|
|
7
|
+
{{#if features.iam}}
|
|
8
|
+
import { iam } from '@h-ai/iam'
|
|
9
|
+
import { error } from '@sveltejs/kit'
|
|
10
|
+
{{/if}}
|
|
11
|
+
|
|
12
|
+
/** 只向浏览器提供公开配置,避免暴露日志上下文、凭证或其它模块配置。 */
|
|
13
|
+
export async function load() {
|
|
14
|
+
const config = core.config.getOrThrow<CoreConfig>('core')
|
|
15
|
+
{{#if features.iam}}
|
|
16
|
+
const publicConfig = await iam.getPublicConfig()
|
|
17
|
+
if (!publicConfig.success) {
|
|
18
|
+
core.logger.error('Failed to load public authentication configuration', { error: publicConfig.error })
|
|
19
|
+
error(503, { message: core.error.toPublic(publicConfig.error).message })
|
|
20
|
+
}
|
|
21
|
+
{{/if}}
|
|
22
|
+
return {
|
|
23
|
+
kitConfig: { transport: getKitConfig().transport } satisfies KitPublicConfig,
|
|
24
|
+
{{#if features.iam}}
|
|
25
|
+
iamPublicConfig: publicConfig.data,
|
|
26
|
+
{{/if}}
|
|
27
|
+
appConfig: {
|
|
28
|
+
name: config.name,
|
|
29
|
+
version: config.version,
|
|
30
|
+
env: config.env,
|
|
31
|
+
defaultLocale: config.defaultLocale,
|
|
32
|
+
},
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
{{/unless}}
|
|
Binary file
|