@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
|
@@ -1,30 +1,109 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Svelte 配置
|
|
3
3
|
*/
|
|
4
|
-
{{#
|
|
5
|
-
import
|
|
6
|
-
{{
|
|
7
|
-
|
|
4
|
+
{{#unless isSvelteOnlyApp}}
|
|
5
|
+
import process from 'node:process'
|
|
6
|
+
{{/unless}}
|
|
7
|
+
{{#if hasUi}}
|
|
8
|
+
import { autoImportHaiUi } from '@h-ai/ui/auto-import'
|
|
8
9
|
{{/if}}
|
|
10
|
+
{{#unless isSvelteOnlyApp}}
|
|
11
|
+
import adapter from '@sveltejs/adapter-node'
|
|
12
|
+
{{#if_eq appType 'website'}}
|
|
13
|
+
import staticAdapter from '@sveltejs/adapter-static'
|
|
14
|
+
{{/if_eq}}
|
|
15
|
+
{{/unless}}
|
|
9
16
|
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte'
|
|
17
|
+
{{#unless isSvelteOnlyApp}}
|
|
18
|
+
import { resolvePublicBasePath } from './scripts/public-base-path.mjs'
|
|
19
|
+
{{/unless}}
|
|
20
|
+
{{#if_eq appType 'website'}}
|
|
21
|
+
import { resolveStaticWebsite, validateStaticRoutes } from './scripts/static-website.mjs'
|
|
22
|
+
|
|
23
|
+
const website = resolveStaticWebsite()
|
|
24
|
+
const staticOutput = staticAdapter({ strict: false })
|
|
25
|
+
{{/if_eq}}
|
|
26
|
+
|
|
27
|
+
{{#if isSvelteOnlyApp}}
|
|
28
|
+
/** @type {import('@sveltejs/vite-plugin-svelte').SvelteConfig} */
|
|
29
|
+
const config = {
|
|
30
|
+
preprocess: [{{#if hasUi}}autoImportHaiUi(), {{/if}}vitePreprocess()],
|
|
31
|
+
compilerOptions: {
|
|
32
|
+
runes: true,
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
{{else}}
|
|
36
|
+
const DEFAULT_E2E_ORIGINS = ['http://localhost:4173', 'http://127.0.0.1:4173']
|
|
37
|
+
|
|
38
|
+
function resolveTrustedOrigins() {
|
|
39
|
+
if (process.env.HAI_E2E !== '1')
|
|
40
|
+
return []
|
|
41
|
+
|
|
42
|
+
const rawBaseUrl = process.env.BASE_URL ?? DEFAULT_E2E_ORIGINS[0]
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
const url = new URL(rawBaseUrl)
|
|
46
|
+
const origins = new Set([url.origin])
|
|
47
|
+
|
|
48
|
+
if (url.hostname === 'localhost') {
|
|
49
|
+
url.hostname = '127.0.0.1'
|
|
50
|
+
origins.add(url.origin)
|
|
51
|
+
}
|
|
52
|
+
else if (url.hostname === '127.0.0.1') {
|
|
53
|
+
url.hostname = 'localhost'
|
|
54
|
+
origins.add(url.origin)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return [...origins]
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return DEFAULT_E2E_ORIGINS
|
|
61
|
+
}
|
|
62
|
+
}
|
|
10
63
|
|
|
11
64
|
/** @type {import('@sveltejs/kit').Config} */
|
|
12
65
|
const config = {
|
|
13
|
-
preprocess: vitePreprocess(),
|
|
66
|
+
preprocess: [{{#if hasUi}}autoImportHaiUi(), {{/if}}vitePreprocess()],
|
|
14
67
|
compilerOptions: {
|
|
15
68
|
runes: true,
|
|
16
69
|
},
|
|
17
70
|
kit: {
|
|
71
|
+
// 环境文件由 Vite 的 core loader 统一加载;Kit 不再二次读取根目录私有配置。
|
|
72
|
+
env: { dir: './.svelte-kit' },
|
|
73
|
+
paths: { base: resolvePublicBasePath() },
|
|
18
74
|
{{#if isCapacitorApp}}
|
|
19
75
|
adapter: adapter({
|
|
20
76
|
pages: 'build',
|
|
21
77
|
assets: 'build',
|
|
22
78
|
fallback: 'index.html',
|
|
23
79
|
}),
|
|
80
|
+
{{else}}
|
|
81
|
+
{{#if_eq appType 'website'}}
|
|
82
|
+
adapter: website.enabled
|
|
83
|
+
? {
|
|
84
|
+
...staticOutput,
|
|
85
|
+
name: 'hai-static-website',
|
|
86
|
+
async adapt(builder) {
|
|
87
|
+
// 仅省略模板健康端点;自定义API或未预渲染页面明确失败,不用SPA回退掩盖。
|
|
88
|
+
validateStaticRoutes(builder.routes)
|
|
89
|
+
await staticOutput.adapt(builder)
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
: adapter(),
|
|
24
93
|
{{else}}
|
|
25
94
|
adapter: adapter(),
|
|
95
|
+
{{/if_eq}}
|
|
26
96
|
{{/if}}
|
|
97
|
+
csrf: {
|
|
98
|
+
trustedOrigins: resolveTrustedOrigins(),
|
|
99
|
+
},
|
|
100
|
+
alias: {
|
|
101
|
+
$components: './src/lib/components',
|
|
102
|
+
$stores: './src/lib/stores',
|
|
103
|
+
$utils: './src/lib/utils',
|
|
104
|
+
},
|
|
27
105
|
},
|
|
28
106
|
}
|
|
107
|
+
{{/if}}
|
|
29
108
|
|
|
30
109
|
export default config
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
{{#unless isSvelteOnlyApp}}
|
|
2
|
+
import type { CoreConfig } from '@h-ai/core'
|
|
3
|
+
{{/unless}}
|
|
4
|
+
import { readFile } from 'node:fs/promises'
|
|
5
|
+
import { join } from 'node:path'
|
|
6
|
+
{{#unless isSvelteOnlyApp}}
|
|
7
|
+
import process from 'node:process'
|
|
8
|
+
{{/unless}}
|
|
9
|
+
import { fileURLToPath } from 'node:url'
|
|
10
|
+
{{#unless isSvelteOnlyApp}}
|
|
11
|
+
{{#if features.iam}}
|
|
12
|
+
import { cache } from '@h-ai/cache'
|
|
13
|
+
{{/if}}
|
|
14
|
+
import { core } from '@h-ai/core'
|
|
15
|
+
{{#if features.iam}}
|
|
16
|
+
import { iam } from '@h-ai/iam'
|
|
17
|
+
import { reldb } from '@h-ai/reldb'
|
|
18
|
+
{{/if}}
|
|
19
|
+
{{/unless}}
|
|
20
|
+
import { describe, expect, it } from 'vitest'
|
|
21
|
+
{{#unless isSvelteOnlyApp}}
|
|
22
|
+
import { getKitConfig } from '../src/lib/server/kit-config'
|
|
23
|
+
import { load } from '../src/routes/+layout.server'
|
|
24
|
+
{{/unless}}
|
|
25
|
+
|
|
26
|
+
const rootDir = fileURLToPath(new URL('..', import.meta.url))
|
|
27
|
+
|
|
28
|
+
describe('generated scaffold', () => {
|
|
29
|
+
it('declares project metadata and quality gate scripts', async () => {
|
|
30
|
+
const packageJsonPath = join(rootDir, 'package.json')
|
|
31
|
+
const pkg = JSON.parse(await readFile(packageJsonPath, 'utf-8')) as {
|
|
32
|
+
name: string
|
|
33
|
+
scripts: Record<string, string>
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
expect(pkg.name).toBe('{{projectName}}')
|
|
37
|
+
expect(pkg.scripts.typecheck).toBeDefined()
|
|
38
|
+
expect(pkg.scripts.lint).toBeDefined()
|
|
39
|
+
expect(pkg.scripts.test).toBeDefined()
|
|
40
|
+
expect(pkg.scripts['test:e2e']).toBeDefined()
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
{{#if isSvelteOnlyApp}}
|
|
44
|
+
it('renders the Vite app shell entry', async () => {
|
|
45
|
+
const indexHtml = await readFile(join(rootDir, 'index.html'), 'utf-8')
|
|
46
|
+
expect(indexHtml).toContain('<div id="app"></div>')
|
|
47
|
+
})
|
|
48
|
+
{{else}}
|
|
49
|
+
it('renders the app shell locale marker', async () => {
|
|
50
|
+
const appHtml = await readFile(join(rootDir, 'src/app.html'), 'utf-8')
|
|
51
|
+
expect(appHtml).toContain('lang="{{#if hasI18n}}{{#if isCapacitorApp}}{{defaultLocale}}{{else}}%lang%{{/if}}{{else}}{{defaultLocale}}{{/if}}"')
|
|
52
|
+
})
|
|
53
|
+
{{/if}}
|
|
54
|
+
{{#unless isCapacitorApp}}
|
|
55
|
+
|
|
56
|
+
it('ships an application config loaded at startup', async () => {
|
|
57
|
+
const result = core.config.load<CoreConfig>('core', join(rootDir, 'config/_core.yml'))
|
|
58
|
+
expect(result.success).toBe(true)
|
|
59
|
+
if (!result.success)
|
|
60
|
+
return
|
|
61
|
+
expect(result.data.name).toBe(process.env.HAI_CORE_NAME ?? '{{projectName}}')
|
|
62
|
+
expect(result.data.defaultLocale).toBe(process.env.HAI_CORE_DEFAULTLOCALE ?? '{{defaultLocale}}')
|
|
63
|
+
})
|
|
64
|
+
{{/unless}}
|
|
65
|
+
{{#unless isSvelteOnlyApp}}
|
|
66
|
+
|
|
67
|
+
it('publishes only public metadata from parsed core configuration', async () => {
|
|
68
|
+
core.init({ configDir: './config' })
|
|
69
|
+
const config = core.config.getOrThrow<CoreConfig>('core')
|
|
70
|
+
expect(core.logger.getLevel()).toBe(config.logging?.level ?? 'info')
|
|
71
|
+
{{#if features.iam}}
|
|
72
|
+
// 动态公开策略依赖已初始化的 IAM,使用隔离内存后端,不能用未等待的 Promise 冒充数据。
|
|
73
|
+
try {
|
|
74
|
+
const db = await reldb.init({ type: 'sqlite', database: ':memory:' })
|
|
75
|
+
expect(db.success).toBe(true)
|
|
76
|
+
const cached = await cache.init({ type: 'memory' })
|
|
77
|
+
expect(cached.success).toBe(true)
|
|
78
|
+
const initialized = await iam.init({ seedDefaultData: false })
|
|
79
|
+
expect(initialized.success).toBe(true)
|
|
80
|
+
const publicConfig = await iam.getPublicConfig()
|
|
81
|
+
if (!publicConfig.success)
|
|
82
|
+
throw new Error(publicConfig.error.message)
|
|
83
|
+
expect(await load()).toEqual({
|
|
84
|
+
kitConfig: { transport: getKitConfig().transport },
|
|
85
|
+
iamPublicConfig: publicConfig.data,
|
|
86
|
+
appConfig: { name: config.name, version: config.version, env: config.env, defaultLocale: config.defaultLocale },
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
finally {
|
|
90
|
+
await iam.close()
|
|
91
|
+
await cache.close()
|
|
92
|
+
await reldb.close()
|
|
93
|
+
}
|
|
94
|
+
{{else}}
|
|
95
|
+
expect(await load()).toEqual({
|
|
96
|
+
kitConfig: { transport: getKitConfig().transport },
|
|
97
|
+
appConfig: { name: config.name, version: config.version, env: config.env, defaultLocale: config.defaultLocale },
|
|
98
|
+
})
|
|
99
|
+
{{/if}}
|
|
100
|
+
})
|
|
101
|
+
{{/unless}}
|
|
102
|
+
})
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{{#if isSvelteOnlyApp}}
|
|
2
|
+
{
|
|
3
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
"target": "ES2022",
|
|
6
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
|
+
"moduleDetection": "force",
|
|
8
|
+
"module": "ESNext",
|
|
9
|
+
"moduleResolution": "bundler",
|
|
10
|
+
"resolveJsonModule": true,
|
|
11
|
+
"types": ["svelte", "vite/client", "node", "vitest/globals"],
|
|
12
|
+
"allowJs": true,
|
|
13
|
+
"checkJs": false,
|
|
14
|
+
"strict": true,
|
|
15
|
+
"noEmit": true,
|
|
16
|
+
"isolatedModules": true,
|
|
17
|
+
"verbatimModuleSyntax": true,
|
|
18
|
+
"skipLibCheck": true
|
|
19
|
+
},
|
|
20
|
+
"include": [
|
|
21
|
+
"src/**/*.ts",
|
|
22
|
+
"src/**/*.svelte",
|
|
23
|
+
"tests/**/*.ts",
|
|
24
|
+
"vite.config.ts",
|
|
25
|
+
"svelte.config.js"
|
|
26
|
+
],
|
|
27
|
+
"exclude": ["node_modules", "dist", "build", "android", "ios"]
|
|
28
|
+
}
|
|
29
|
+
{{else}}
|
|
30
|
+
{
|
|
31
|
+
"extends": "./.svelte-kit/tsconfig.json",
|
|
32
|
+
"compilerOptions": {
|
|
33
|
+
"moduleResolution": "bundler",
|
|
34
|
+
"allowImportingTsExtensions": true,
|
|
35
|
+
"allowJs": true,
|
|
36
|
+
"checkJs": false,
|
|
37
|
+
"strict": true,
|
|
38
|
+
"verbatimModuleSyntax": true,
|
|
39
|
+
"skipLibCheck": true
|
|
40
|
+
},
|
|
41
|
+
"include": [
|
|
42
|
+
"src/**/*",
|
|
43
|
+
"src/**/*.svelte"
|
|
44
|
+
],
|
|
45
|
+
"exclude": [
|
|
46
|
+
"node_modules",
|
|
47
|
+
".svelte-kit"
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
{{/if}}
|
|
@@ -1,27 +1,132 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* {{projectName}} - Vite 配置
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
{{#if isSvelteOnlyApp}}
|
|
5
|
+
import type { CoreConfig } from '@h-ai/core'
|
|
6
|
+
{{/if}}
|
|
7
|
+
import type { Plugin } from 'vite'
|
|
8
|
+
import path from 'node:path'
|
|
9
|
+
import process from 'node:process'
|
|
10
|
+
import { fileURLToPath } from 'node:url'
|
|
11
|
+
import { core } from '@h-ai/core'
|
|
5
12
|
{{#if hasUi}}
|
|
6
|
-
import
|
|
13
|
+
import { haiOptimizeExclude, haiPrebundledDeps } from '@h-ai/ui/vite'
|
|
7
14
|
{{/if}}
|
|
8
15
|
{{#if hasI18n}}
|
|
9
16
|
import { paraglideVitePlugin } from '@inlang/paraglide-js'
|
|
10
17
|
{{/if}}
|
|
18
|
+
{{#if isSvelteOnlyApp}}
|
|
19
|
+
import { svelte } from '@sveltejs/vite-plugin-svelte'
|
|
20
|
+
{{else}}
|
|
21
|
+
import { sveltekit } from '@sveltejs/kit/vite'
|
|
22
|
+
{{/if}}
|
|
23
|
+
{{#if hasUi}}
|
|
24
|
+
import tailwindcss from '@tailwindcss/vite'
|
|
25
|
+
{{/if}}
|
|
11
26
|
import { defineConfig } from 'vite'
|
|
27
|
+
import { resolveBuildMetadata } from './scripts/build-metadata.js'
|
|
28
|
+
{{#if_eq appType 'website'}}
|
|
29
|
+
import { resolveStaticWebsite } from './scripts/static-website.mjs'
|
|
30
|
+
{{/if_eq}}
|
|
31
|
+
{{#if isSvelteOnlyApp}}
|
|
32
|
+
import { resolvePublicBasePath } from './scripts/public-base-path.mjs'
|
|
33
|
+
import { publicRuntimeConfig } from './scripts/vite-runtime-config.js'
|
|
34
|
+
{{/if}}
|
|
35
|
+
|
|
36
|
+
export default defineConfig(({ mode, command }) => {
|
|
37
|
+
{{#if_eq appType 'website'}}
|
|
38
|
+
const website = resolveStaticWebsite()
|
|
39
|
+
{{/if_eq}}
|
|
40
|
+
const envResult = command === 'build' || process.env.HAI_E2E === '1'{{#if_eq appType 'website'}} || website.enabled{{/if_eq}} ? { success: true as const, data: {} as Record<string, string> } : core.config.loadEnvFiles({ mode, envDir: process.cwd() })
|
|
41
|
+
if (!envResult.success)
|
|
42
|
+
throw new Error(envResult.error.message)
|
|
43
|
+
const env = envResult.data
|
|
44
|
+
Object.assign(process.env, env)
|
|
45
|
+
const buildMetadata = resolveBuildMetadata(fileURLToPath(new URL('.', import.meta.url)))
|
|
46
|
+
const metadataAsset: Plugin = {
|
|
47
|
+
name: 'hai-build-metadata',
|
|
48
|
+
generateBundle() {
|
|
49
|
+
this.emitFile({ type: 'asset', fileName: 'build-metadata.json', source: JSON.stringify(buildMetadata) })
|
|
50
|
+
},
|
|
51
|
+
}
|
|
52
|
+
{{#if isSvelteOnlyApp}}
|
|
53
|
+
// 浏览器无法读取 YAML;构建时通过 core 解析,仅注入明确可公开的字段。
|
|
54
|
+
core.init({ configDir: './config' })
|
|
55
|
+
const config = core.config.getOrThrow<CoreConfig>('core')
|
|
56
|
+
const appConfig = {
|
|
57
|
+
name: config.name,
|
|
58
|
+
version: config.version,
|
|
59
|
+
env: config.env,
|
|
60
|
+
defaultLocale: config.defaultLocale,
|
|
61
|
+
logging: config.logging ? { level: config.logging.level, format: config.logging.format } : undefined,
|
|
62
|
+
}
|
|
63
|
+
const publicBase = resolvePublicBasePath()
|
|
64
|
+
{{/if}}
|
|
12
65
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
66
|
+
return {
|
|
67
|
+
{{#if isSvelteOnlyApp}}
|
|
68
|
+
base: publicBase ? `${publicBase}/` : './',
|
|
69
|
+
{{/if}}
|
|
70
|
+
envDir: false,
|
|
71
|
+
envPrefix: ['VITE_', 'PUBLIC_'],
|
|
72
|
+
define: {
|
|
73
|
+
__HAI_BUILD_METADATA__: JSON.stringify(buildMetadata),
|
|
74
|
+
{{#if_eq appType 'website'}}
|
|
75
|
+
__HAI_BUILD_STATIC__: JSON.stringify(website.enabled),
|
|
76
|
+
{{/if_eq}}
|
|
77
|
+
{{#if isSvelteOnlyApp}}
|
|
78
|
+
__APP_CORE_CONFIG__: JSON.stringify(appConfig),
|
|
79
|
+
{{/if}}
|
|
80
|
+
},
|
|
81
|
+
plugins: [
|
|
82
|
+
metadataAsset,
|
|
83
|
+
{{#if_eq appType 'website'}}
|
|
84
|
+
{
|
|
85
|
+
name: 'hai-static-website-assets',
|
|
86
|
+
generateBundle() {
|
|
87
|
+
if (!website.enabled)
|
|
88
|
+
return
|
|
89
|
+
this.emitFile({ type: 'asset', fileName: '.nojekyll', source: '' })
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{{/if_eq}}
|
|
93
|
+
{{#if isSvelteOnlyApp}}
|
|
94
|
+
publicRuntimeConfig({ apiBase: process.env.PUBLIC_API_BASE, {{#if features.crypto}}apiTransport: process.env.PUBLIC_API_TRANSPORT, apiKeyExchangePath: process.env.PUBLIC_API_KEY_EXCHANGE_PATH, {{/if}}core: appConfig }),
|
|
95
|
+
svelte(),
|
|
96
|
+
{{else}}
|
|
97
|
+
sveltekit(),
|
|
98
|
+
{{/if}}
|
|
16
99
|
{{#if hasUi}}
|
|
17
|
-
|
|
100
|
+
tailwindcss(),
|
|
18
101
|
{{/if}}
|
|
19
102
|
{{#if hasI18n}}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
103
|
+
paraglideVitePlugin({
|
|
104
|
+
project: './project.inlang',
|
|
105
|
+
outdir: './src/lib/paraglide',
|
|
106
|
+
strategy: ['cookie', 'baseLocale'],
|
|
107
|
+
}),
|
|
108
|
+
{{/if}}
|
|
109
|
+
],
|
|
110
|
+
{{#if hasUi}}
|
|
111
|
+
optimizeDeps: {
|
|
112
|
+
// bits-ui 含 .svelte 源码须 exclude;@internationalized/date 须与 bits-ui 同为原始副本,
|
|
113
|
+
// 避免日期类型 instanceof 失败("Unknown date type")。
|
|
114
|
+
exclude: [...haiOptimizeExclude],
|
|
115
|
+
// 预打包 @h-ai/ui 的重型纯 JS 依赖,避免首次进入业务路由触发依赖再优化与整页刷新
|
|
116
|
+
include: [...haiPrebundledDeps],
|
|
117
|
+
},
|
|
25
118
|
{{/if}}
|
|
26
|
-
|
|
119
|
+
{{#unless isSvelteOnlyApp}}
|
|
120
|
+
ssr: {
|
|
121
|
+
noExternal: ['@h-ai/ui', '@h-ai/kit'],
|
|
122
|
+
// sm-crypto 同时列入生产依赖,避免 adapter-node 再次打包其动态 require。
|
|
123
|
+
external: ['@h-ai/core', 'sm-crypto'],
|
|
124
|
+
},
|
|
125
|
+
{{/unless}}
|
|
126
|
+
server: {
|
|
127
|
+
fs: {
|
|
128
|
+
allow: [path.resolve(process.cwd())],
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
}
|
|
27
132
|
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { fileURLToPath } from 'node:url'
|
|
2
|
+
{{#unless isSvelteOnlyApp}}
|
|
3
|
+
import { sveltekit } from '@sveltejs/kit/vite'
|
|
4
|
+
{{/unless}}
|
|
5
|
+
import { defineConfig } from 'vitest/config'
|
|
6
|
+
import { resolveBuildMetadata } from './scripts/build-metadata.js'
|
|
7
|
+
|
|
8
|
+
export default defineConfig({
|
|
9
|
+
{{#unless isSvelteOnlyApp}}
|
|
10
|
+
plugins: [sveltekit()],
|
|
11
|
+
{{/unless}}
|
|
12
|
+
define: { __HAI_BUILD_METADATA__: JSON.stringify(resolveBuildMetadata(fileURLToPath(new URL('.', import.meta.url)))) },
|
|
13
|
+
test: {
|
|
14
|
+
globals: true,
|
|
15
|
+
environment: 'node',
|
|
16
|
+
include: ['tests/**/*.test.ts'],
|
|
17
|
+
exclude: ['e2e/**'],
|
|
18
|
+
},
|
|
19
|
+
})
|
|
@@ -4,23 +4,22 @@
|
|
|
4
4
|
import type { RequestHandler } from './$types'
|
|
5
5
|
import { ai } from '@h-ai/ai'
|
|
6
6
|
import { kit } from '@h-ai/kit'
|
|
7
|
+
import { z } from 'zod'
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
const { message } = await request.json()
|
|
9
|
+
const ChatInputSchema = z.object({ message: z.string().trim().min(1).max(4000) }).strict()
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
11
|
+
export const POST: RequestHandler = kit.handler(async ({ request, locals }) => {
|
|
12
|
+
const { message } = await kit.validate.body(request, ChatInputSchema)
|
|
14
13
|
|
|
15
14
|
const result = await ai.llm.ask(message, {
|
|
16
15
|
systemPrompt: 'You are a helpful assistant.',
|
|
17
16
|
})
|
|
18
17
|
|
|
19
18
|
if (!result.success) {
|
|
20
|
-
return kit.response.
|
|
19
|
+
return kit.response.fromError(result.error, locals.requestId)
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
return kit.response.ok({
|
|
24
23
|
reply: result.data,
|
|
25
24
|
}, locals.requestId)
|
|
26
|
-
}
|
|
25
|
+
})
|
|
@@ -1,21 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
<script lang="ts">
|
|
3
|
-
/**
|
|
4
|
-
* 认证布局(登录/注册共用)
|
|
5
|
-
*/
|
|
1
|
+
<script lang='ts'>
|
|
6
2
|
import type { Snippet } from 'svelte'
|
|
7
3
|
|
|
8
|
-
|
|
9
|
-
children: Snippet
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
let { children }: Props = $props()
|
|
4
|
+
const { children }: { children: Snippet } = $props()
|
|
13
5
|
</script>
|
|
14
6
|
|
|
15
|
-
|
|
16
|
-
<div class="card w-full max-w-md bg-base-100 shadow-xl">
|
|
17
|
-
<div class="card-body">
|
|
18
|
-
{@render children()}
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
</div>
|
|
7
|
+
{@render children()}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script lang='ts'>
|
|
2
|
+
import { base, resolve } from '$app/paths'
|
|
3
|
+
import { page } from '$app/state'
|
|
4
|
+
import { kit } from '@h-ai/kit'
|
|
5
|
+
import { AuthPanel } from '@h-ai/ui/components/scenes/iam/index'
|
|
6
|
+
|
|
7
|
+
const actions = kit.client.createAuthActions({ basePath: `${base}/api/auth` })
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<AuthPanel config={page.data.iamPublicConfig} {actions} initialMode='forgot' resetToken={page.url.searchParams.get('token') ?? ''} loginUrl={resolve('/auth/login', {})} />
|
|
@@ -1,98 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
{
|
|
7
|
-
|
|
8
|
-
{{/
|
|
9
|
-
|
|
10
|
-
let username = $state('')
|
|
11
|
-
let password = $state('')
|
|
12
|
-
let error = $state('')
|
|
13
|
-
let loading = $state(false)
|
|
14
|
-
|
|
15
|
-
async function handleLogin() {
|
|
16
|
-
error = ''
|
|
17
|
-
loading = true
|
|
18
|
-
try {
|
|
19
|
-
const res = await fetch('/api/auth/login', {
|
|
20
|
-
method: 'POST',
|
|
21
|
-
headers: { 'Content-Type': 'application/json' },
|
|
22
|
-
body: JSON.stringify({ username, password }),
|
|
23
|
-
})
|
|
24
|
-
const data = await res.json()
|
|
25
|
-
if (data.success) {
|
|
26
|
-
window.location.href = '/admin'
|
|
27
|
-
} else {
|
|
28
|
-
{{#if hasI18n}}
|
|
29
|
-
error = data.error?.message || m.auth_login_failed()
|
|
30
|
-
{{else}}
|
|
31
|
-
error = data.error?.message || '登录失败'
|
|
32
|
-
{{/if}}
|
|
33
|
-
}
|
|
34
|
-
} catch {
|
|
35
|
-
{{#if hasI18n}}
|
|
36
|
-
error = m.auth_error_network()
|
|
37
|
-
{{else}}
|
|
38
|
-
error = '网络错误'
|
|
39
|
-
{{/if}}
|
|
40
|
-
} finally {
|
|
41
|
-
loading = false
|
|
42
|
-
}
|
|
43
|
-
}
|
|
1
|
+
<script lang='ts'>
|
|
2
|
+
import { goto } from '$app/navigation'
|
|
3
|
+
import { base, resolve } from '$app/paths'
|
|
4
|
+
import { page } from '$app/state'
|
|
5
|
+
import { kit } from '@h-ai/kit'
|
|
6
|
+
import { AuthPanel } from '@h-ai/ui/components/scenes/iam/index'
|
|
7
|
+
|
|
8
|
+
const actions = kit.client.createAuthActions({ basePath: `${base}/api/auth` })
|
|
44
9
|
</script>
|
|
45
10
|
|
|
46
|
-
<
|
|
47
|
-
{{#if hasI18n}}
|
|
48
|
-
<title>{m.auth_login_title()}</title>
|
|
49
|
-
{{else}}
|
|
50
|
-
<title>登录</title>
|
|
51
|
-
{{/if}}
|
|
52
|
-
</svelte:head>
|
|
53
|
-
|
|
54
|
-
{{#if hasI18n}}
|
|
55
|
-
<h2 class="card-title justify-center mb-4">{m.auth_login_title()}</h2>
|
|
56
|
-
{{else}}
|
|
57
|
-
<h2 class="card-title justify-center mb-4">登录</h2>
|
|
58
|
-
{{/if}}
|
|
59
|
-
|
|
60
|
-
{#if error}
|
|
61
|
-
<div class="alert alert-error mb-4">
|
|
62
|
-
<span>{error}</span>
|
|
63
|
-
</div>
|
|
64
|
-
{/if}
|
|
65
|
-
|
|
66
|
-
<form onsubmit={(e) => { e.preventDefault(); handleLogin() }} class="space-y-4">
|
|
67
|
-
<div class="form-control">
|
|
68
|
-
{{#if hasI18n}}
|
|
69
|
-
<label class="label" for="username"><span class="label-text">{m.auth_label_username()}</span></label>
|
|
70
|
-
{{else}}
|
|
71
|
-
<label class="label" for="username"><span class="label-text">用户名</span></label>
|
|
72
|
-
{{/if}}
|
|
73
|
-
<input id="username" type="text" class="input input-bordered w-full" bind:value={username} required />
|
|
74
|
-
</div>
|
|
75
|
-
<div class="form-control">
|
|
76
|
-
{{#if hasI18n}}
|
|
77
|
-
<label class="label" for="password"><span class="label-text">{m.auth_label_password()}</span></label>
|
|
78
|
-
{{else}}
|
|
79
|
-
<label class="label" for="password"><span class="label-text">密码</span></label>
|
|
80
|
-
{{/if}}
|
|
81
|
-
<input id="password" type="password" class="input input-bordered w-full" bind:value={password} required />
|
|
82
|
-
</div>
|
|
83
|
-
<button type="submit" class="btn btn-primary w-full" disabled={loading}>
|
|
84
|
-
{{#if hasI18n}}
|
|
85
|
-
{loading ? m.auth_login_loading() : m.auth_login_submit()}
|
|
86
|
-
{{else}}
|
|
87
|
-
{loading ? '登录中...' : '登录'}
|
|
88
|
-
{{/if}}
|
|
89
|
-
</button>
|
|
90
|
-
</form>
|
|
91
|
-
|
|
92
|
-
<div class="text-center mt-4">
|
|
93
|
-
{{#if hasI18n}}
|
|
94
|
-
<a href="/auth/register" class="link link-primary text-sm">{m.auth_login_to_register()}</a>
|
|
95
|
-
{{else}}
|
|
96
|
-
<a href="/auth/register" class="link link-primary text-sm">没有账号?立即注册</a>
|
|
97
|
-
{{/if}}
|
|
98
|
-
</div>
|
|
11
|
+
<AuthPanel config={page.data.iamPublicConfig} {actions} initialMode='login' loginUrl={resolve('/auth/login', {})} registerUrl={resolve('/auth/register', {})} onauthenticated={() => goto(resolve('/admin', {}))} />
|