@h-ai/cli 0.1.0-alpha.65 → 0.1.0-alpha.67
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 +66 -251
- package/README.ja.md +67 -252
- package/README.md +66 -251
- package/dist/{chunk-47V5OT22.js → chunk-7DSURTJ4.js} +32 -115
- package/dist/chunk-7DSURTJ4.js.map +1 -0
- package/dist/{chunk-IPG3QNYK.js → chunk-AOQ4N657.js} +212 -8
- package/dist/chunk-AOQ4N657.js.map +1 -0
- package/dist/cli-config-templates-6AHNUGBN.js +5 -0
- package/dist/{cli-config-templates-SJ2MBIR7.js.map → cli-config-templates-6AHNUGBN.js.map} +1 -1
- package/dist/{cli-skill-templates-A5VIR5J6.js → cli-skill-templates-FC3QRKDO.js} +3 -3
- package/dist/{cli-skill-templates-A5VIR5J6.js.map → cli-skill-templates-FC3QRKDO.js.map} +1 -1
- package/dist/index.js +644 -391
- package/dist/index.js.map +1 -1
- package/dist/{src-6PPBKQ6Q.js → src-2V6VP4I5.js} +972 -520
- package/dist/src-2V6VP4I5.js.map +1 -0
- package/package.json +8 -8
- package/templates/README.md +48 -145
- package/templates/apps/admin/src/routes/admin/+layout.svelte.hbs +1 -1
- package/templates/apps/api/.dockerignore.hbs +18 -12
- package/templates/apps/api/.gitignore.hbs +9 -1
- package/templates/apps/api/apps/{{projectName}}-contract/README.md.hbs +23 -2
- package/templates/apps/api/apps/{{projectName}}-service/README.md.hbs +28 -7
- package/templates/apps/api/apps/{{projectName}}-service/package.json.hbs +1 -3
- package/templates/apps/api/hai.build.json.hbs +1 -0
- package/templates/apps/api/images/app.Dockerfile.hbs +35 -0
- package/templates/apps/api/package.json.hbs +10 -8
- package/templates/apps/fullstack/.dockerignore.hbs +18 -14
- package/templates/apps/fullstack/.gitignore.hbs +9 -1
- package/templates/apps/fullstack/apps/{{projectName}}-app/README.md.hbs +23 -8
- package/templates/apps/fullstack/apps/{{projectName}}-app/index.html.hbs +1 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/package.json.hbs +0 -2
- package/templates/apps/fullstack/apps/{{projectName}}-app/public/runtime-config.js.hbs +4 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/vite.config.ts.hbs +3 -3
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/README.md.hbs +25 -10
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/package.json.hbs +2 -3
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/src/lib.rs.hbs +73 -2
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/tauri.conf.json.hbs +2 -2
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/vite.config.ts.hbs +2 -2
- package/templates/apps/fullstack/apps/{{projectName}}-miniapp/README.md.hbs +16 -6
- package/templates/apps/fullstack/apps/{{projectName}}-web/README.md.hbs +24 -10
- package/templates/apps/fullstack/apps/{{projectName}}-web/package.json.hbs +0 -2
- package/templates/apps/fullstack/apps/{{projectName}}-web/vite.config.ts.hbs +3 -3
- package/templates/apps/fullstack/e2e/fullstack.spec.ts.hbs +12 -1
- package/templates/apps/fullstack/hai.build.json.hbs +7 -0
- package/templates/apps/fullstack/images/app.Dockerfile.hbs +36 -0
- package/templates/apps/fullstack/images/web.Dockerfile.hbs +34 -0
- package/templates/apps/fullstack/package.json.hbs +7 -12
- package/templates/apps/fullstack/packages/{{projectName}}-contract/README.md.hbs +23 -2
- package/templates/apps/fullstack/packages/{{projectName}}-serv/README.md.hbs +28 -7
- package/templates/apps/fullstack/packages/{{projectName}}-serv/package.json.hbs +0 -1
- package/templates/apps/fullstack/packages/{{projectName}}-shared/.gitignore.hbs +7 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/README.md.hbs +33 -12
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/components/AppShell.svelte.hbs +2 -2
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/pages/settings.svelte.hbs +3 -3
- package/templates/apps/fullstack/packages/{{projectName}}-shared/tests/api-client.test.ts.hbs +2 -2
- package/templates/apps/h5/src/routes/+layout.svelte.hbs +2 -2
- package/templates/apps/mobile-app/index.html.hbs +1 -0
- package/templates/apps/mobile-app/public/runtime-config.js +1 -0
- package/templates/apps/mobile-app/src/App.svelte.hbs +2 -2
- package/templates/apps/mobile-app/src/lib/api.ts.hbs +2 -1
- package/templates/apps/mobile-app/src/lib/app-config.ts.hbs +3 -2
- package/templates/apps/mobile-app/src/lib/pages/home.svelte.hbs +2 -2
- package/templates/apps/website/src/routes/+layout.svelte.hbs +3 -3
- package/templates/apps/website/src/routes/services/+page.svelte.hbs +1 -1
- package/templates/base/.dockerignore.hbs +18 -13
- package/templates/base/.gitignore.hbs +9 -1
- package/templates/base/e2e/app.spec.ts.hbs +10 -0
- package/templates/base/hai.build.json.hbs +1 -0
- package/templates/base/images/app.Dockerfile.hbs +64 -0
- package/templates/base/{docker → images/web}/nginx.conf.hbs +6 -0
- package/templates/base/package.json.hbs +20 -19
- package/templates/base/svelte.config.js.hbs +2 -0
- package/templates/base/vite.config.ts.hbs +9 -3
- package/templates/shared/.gitattributes +11 -0
- package/templates/shared/container-runtime-config.sh +30 -0
- package/templates/shared/run-e2e.mjs +65 -0
- package/templates/shared/vite-runtime-config.ts +54 -0
- package/templates/skills/AGENTS.md +3 -3
- package/templates/skills/bridges/admin/AGENTS.md +1 -1
- package/templates/skills/bridges/api/AGENTS.md +1 -1
- package/templates/skills/bridges/fullstack/AGENTS.md.hbs +1 -1
- package/templates/skills/bridges/h5/AGENTS.md +1 -1
- package/templates/skills/bridges/mobile-app/AGENTS.md +1 -1
- package/templates/skills/bridges/website/AGENTS.md +1 -1
- package/templates/skills/hai-api-client/SKILL.md +14 -161
- package/templates/skills/hai-api-client/reference.md +166 -0
- package/templates/skills/hai-api-contract/SKILL.md +15 -273
- package/templates/skills/hai-api-contract/reference.md +278 -0
- package/templates/skills/hai-app-create/SKILL.md +2 -2
- package/templates/skills/hai-app-create/development.md +6 -4
- package/templates/skills/hai-app-create/reference.md +5 -4
- package/templates/skills/hai-app-review/SKILL.md +1 -1
- package/templates/skills/hai-app-tests/SKILL.md +4 -3
- package/templates/skills/hai-app-tests/reference.md +2 -2
- package/templates/skills/hai-app-tests/validation.md +31 -0
- package/templates/skills/hai-audit/SKILL.md +17 -142
- package/templates/skills/hai-audit/reference.md +145 -0
- package/templates/skills/hai-build/SKILL.md +24 -3
- package/templates/skills/hai-build/reference.md +10 -9
- package/templates/skills/hai-cache/SKILL.md +15 -182
- package/templates/skills/hai-cache/reference.md +187 -0
- package/templates/skills/hai-capacitor/SKILL.md +4 -3
- package/templates/skills/hai-capacitor/reference.md +6 -4
- package/templates/skills/hai-ci/SKILL.md +2 -0
- package/templates/skills/hai-core/SKILL.md +3 -3
- package/templates/skills/hai-crypto/SKILL.md +16 -252
- package/templates/skills/hai-crypto/reference.md +256 -0
- package/templates/skills/hai-datapipe/SKILL.md +15 -196
- package/templates/skills/hai-datapipe/reference.md +202 -0
- package/templates/skills/hai-deploy/SKILL.md +28 -271
- package/templates/skills/hai-deploy/middleware.md +6 -18
- package/templates/skills/hai-framework-sync/SKILL.md +2 -2
- package/templates/skills/hai-framework-sync/sync.md +1 -1
- package/templates/skills/hai-iam/SKILL.md +1 -3
- package/templates/skills/hai-kit/SKILL.md +12 -167
- package/templates/skills/hai-kit/reference.md +172 -0
- package/templates/skills/hai-payment/SKILL.md +19 -251
- package/templates/skills/hai-payment/reference.md +256 -0
- package/templates/skills/hai-pr-review/SKILL.md +4 -4
- package/templates/skills/hai-reach/SKILL.md +2 -2
- package/templates/skills/hai-reldb/SKILL.md +1 -1
- package/templates/skills/hai-scheduler/SKILL.md +15 -195
- package/templates/skills/hai-scheduler/reference.md +202 -0
- package/templates/skills/hai-serv/SKILL.md +2 -2
- package/templates/skills/hai-spec-implement/SKILL.md +1 -1
- package/templates/skills/hai-spec-implement/workflow.md +3 -3
- package/templates/skills/hai-storage/SKILL.md +17 -238
- package/templates/skills/hai-storage/reference.md +243 -0
- package/templates/skills/hai-ui/SKILL.md +1 -1
- package/templates/skills/hai-ui/reference.md +11 -5
- package/templates/skills/hai-vecdb/SKILL.md +2 -2
- package/dist/chunk-47V5OT22.js.map +0 -1
- package/dist/chunk-IPG3QNYK.js.map +0 -1
- package/dist/cli-config-templates-SJ2MBIR7.js +0 -5
- package/dist/src-6PPBKQ6Q.js.map +0 -1
- package/templates/apps/api/Dockerfile.hbs +0 -48
- package/templates/apps/fullstack/Dockerfile.hbs +0 -69
- package/templates/base/Dockerfile.hbs +0 -79
- /package/templates/apps/fullstack/{docker → images/web}/19-runtime-config.envsh.hbs +0 -0
- /package/templates/apps/fullstack/{docker → images/web}/nginx.conf.hbs +0 -0
- /package/templates/apps/fullstack/{docker → images/web}/runtime-config.js.template.hbs +0 -0
package/README.en.md
CHANGED
|
@@ -1,305 +1,120 @@
|
|
|
1
1
|
# @h-ai/cli
|
|
2
2
|
|
|
3
|
-
[简体中文](
|
|
3
|
+
[简体中文](README.md) | [English](README.en.md) | [日本語](README.ja.md)
|
|
4
4
|
|
|
5
|
-
[Framework home](../../README.en.md)
|
|
5
|
+
[Framework home](../../README.en.md)
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Introduction
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Use `hai` to create applications, add modules, generate starter code, build and deliver releases. It supports SvelteKit, independent APIs and separate frontend/backend workspaces. Follow the [usage guide](../../docs/usage/README.en.md) for the complete workflow.
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## Core features
|
|
12
12
|
|
|
13
|
-
-
|
|
14
|
-
-
|
|
15
|
-
-
|
|
16
|
-
-
|
|
17
|
-
- **Templates**: minimal / default / full / custom project templates.
|
|
18
|
-
- **Feature composition**: enable IAM, DB, AI, Storage, Crypto, and more as needed.
|
|
19
|
-
- **API service scaffolding**: compose contracts/procedures with `@h-ai/api-contract` + `@h-ai/serv`, consumed through the `@h-ai/api-client` typed client.
|
|
20
|
-
- **Dependency resolution**: selecting features automatically includes their dependencies (for example, IAM adds Crypto).
|
|
13
|
+
- Create admin, website, H5, API, mobile or fullstack applications.
|
|
14
|
+
- Add modules, configuration and AI guidance to existing projects.
|
|
15
|
+
- Generate starter pages, components, endpoints, models and migrations.
|
|
16
|
+
- Build selected images, deliver complete offline bundles or update selected services.
|
|
21
17
|
|
|
22
|
-
##
|
|
23
|
-
|
|
24
|
-
Claude Code v2.1.277 and later can also read root `AGENTS.md` directly when no higher-priority project CLAUDE file overrides it and the built-in support is enabled. The single-line `@AGENTS.md` bridge supports older or disabled sessions without duplicating instructions or requiring a `.claude/` directory. See [AGENTS.md support](https://code.claude.com/docs/en/memory#agentsmd).
|
|
25
|
-
|
|
26
|
-
The CLI copies complete selected skill directories from `templates/skills/` into the generated project's `.agents/skills/`. `SKILL.md` defines boundaries and task navigation; `reference.md`/`guide.md` hold on-demand examples. Do not copy only the entry file. AGENTS.md holds application constraints and Claude/Copilot bridge files reference it. Template changes must sync relevant repository skills. Generation tests verify delivery of reference files.
|
|
27
|
-
|
|
28
|
-
Every application type includes `hai-spec-review` to review requirements and designs before generation: completeness, ambiguity, technical/framework correctness, and consistent naming. It reports located issues with concrete corrections and declares generation readiness only when issues are resolved and evidence is sufficient. `hai init` / `hai add` also backfill this workflow skill while preserving custom files.
|
|
29
|
-
|
|
30
|
-
Business behavior follows the user's current explicit requirements and designated requirements/design documents. Template AGENTS, README, skills, generated code and tests provide adjustable defaults for roles, permissions, workflows, limits and architecture. Review lists differences as template adaptations rather than requirements defects; authorized implementation updates conflicting code, tests and outdated guidance. Installed public API contracts, server authorization, resource isolation, input validation and credential protection still apply. Existing projects must merge this guidance explicitly; `hai init` preserves existing files.
|
|
31
|
-
|
|
32
|
-
After review, the separate `hai-spec-implement` skill handles implementation from documents. Every application includes it, and `hai init` / `hai add` backfill its complete resources. AI splits work by independently verifiable features and actual dependencies, using `docs/task-list.md` and `docs/tasks/<id>-<slug>.md` by default. Each task uses its own Git branch, TDD, quality gates and a local merge; records are marked complete after the actual merge commit and integration checks. Rework keeps the same task ID, file and branch, adding a new cycle linked to prior evidence. This uses Markdown, Git and existing development/test skills, with no new runtime dependency or workflow engine. Requests can plan only, implement a document, execute T003, or repair and merge T002. Planning does not start implementation; selected tasks require completed dependencies, and remote actions follow the user's authorization.
|
|
33
|
-
|
|
34
|
-
After committing requirements/design changes, ask: “I updated docs/requirements.md and docs/design.md; please update the implementation.” The skill records the accepted document SHA, fixed target document SHA and accepted implementation SHA separately in the existing task list. It compares the complete document set, including additions, deletions, renames and related effects, then updates existing tasks or creates new ones for branch-based testing and merging. It advances the baseline only after all differences are handled and overall acceptance passes; interrupted or partial work retains the old baseline. Missing baselines require historical evidence or a coverage review. See [document changes and baselines](templates/skills/hai-spec-implement/changes.md). `hai init` / `hai add` backfill the new reference; existing entrypoints, workflows and task templates still need to be merged against the updated templates.
|
|
35
|
-
|
|
36
|
-
For everyday feature additions, changes and fixes, `AGENTS.md` routes to `hai-app-create/SKILL.md` and `development.md`. Map requirements to existing framework features, configuration and extension points before implementing against the installed package's exports and types. Reuse applicable capabilities and explain concrete gaps; do not install unrelated dependencies to increase module coverage. Codex uses `.agents/skills/` and the project root's persistent `AGENTS.md` rules.
|
|
37
|
-
|
|
38
|
-
Tool entry points share one set of rules and skills: Codex/Cursor use AGENTS and `.agents/skills/`; Copilot's `.github/copilot-instructions.md` only references the shared `AGENTS.md`, with application-specific rules maintained there; OpenCode's opencode.json references the shared rules directly through `instructions: ["AGENTS.md"]`. Claude Code's root CLAUDE.md contains only `@AGENTS.md`; task navigation in the shared rules leads to skill bodies and references in `.agents/skills/` as needed. The CLI does not create `.claude/`, duplicate skills or require symlinks. This setup does not register native Claude skills or `/skill` commands; existing Claude settings and skills are preserved. Sources: [Claude project instructions](https://code.claude.com/docs/en/memory), [Claude native skills](https://code.claude.com/docs/en/skills), [Copilot](https://docs.github.com/en/copilot/concepts/agents/about-agent-skills), [OpenCode](https://docs.opencode.ai/docs/skills/), [Cursor](https://cursor.com/docs/skills).
|
|
39
|
-
|
|
40
|
-
Codex discovers `.agents/skills/` natively and selects skills as needed. Invoke `$hai-app-create`, `$hai-app-review`, or another skill explicitly when useful; entry points and references remain on demand. No additional `.codex/skills` tree or Copilot settings are required. Sources: [Codex skills](https://learn.chatgpt.com/docs/build-skills), [AGENTS.md](https://learn.chatgpt.com/docs/agent-configuration/agents-md).
|
|
41
|
-
|
|
42
|
-
Generated projects share `eslint-rules.js`. Lint rejects explicit `any`, console calls, unexplained suppressions, double unknown assertions, internal framework source imports and writes to known sensitive localStorage keys. A necessary third-party workaround requires a documented local exception. Static rules do not prove authorization, input safety, transaction behavior or log redaction; verify those through tests and review.
|
|
43
|
-
|
|
44
|
-
For existing projects, update the CLI and run `hai init` to fill missing workflow skills, resources and entry files. Existing files are preserved, including AI rules when using `--force`. Merge existing entry files, skills, ESLint configuration and scripts against a newly generated project, and restore missing .npmrc/.gitignore files; filling missing files does not upgrade old rules. Before release, use the CLI built from this repository to create the comparison project and keep unpublished capabilities separate from installed package capabilities.
|
|
45
|
-
|
|
46
|
-
Before writing AI files, the CLI resolves existing file and directory links. Shared skills and project bridges must stay inside the project; external targets stop the write. Existing `.claude/` directories and links are outside generation; `hai init` / `hai add` do not modify or delete their contents.
|
|
47
|
-
|
|
48
|
-
Delivery checks cover both the package archive and generated projects. Source `.npmrc` / `.gitignore` templates use a `.hbs` suffix to avoid packaging exclusions; generation restores their normal names and preserves dependency layout and sensitive-artifact ignore rules. An archive regression verifies every template is in the `.tgz`, beyond creation from the source checkout.
|
|
49
|
-
|
|
50
|
-
## Quick start
|
|
51
|
-
|
|
52
|
-
Requires Node.js 22.22.2+ / 24.15.0+ / 26+; generated root projects and workspace packages declare the same minimum.
|
|
18
|
+
## Getting started
|
|
53
19
|
|
|
54
20
|
### Install the CLI
|
|
55
21
|
|
|
56
|
-
|
|
22
|
+
Use Node.js matching `engines` (`^22.22.2 || ^24.15.0 || >=26.0.0`) and pnpm 12.11.2. In PowerShell use `pnpm.cmd`.
|
|
57
23
|
|
|
58
|
-
```
|
|
24
|
+
```sh
|
|
59
25
|
pnpm add -g @h-ai/cli
|
|
60
26
|
hai --version
|
|
27
|
+
hai --help
|
|
61
28
|
```
|
|
62
29
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
### Create a project
|
|
30
|
+
Generated framework dependencies use the exact CLI version. Installation failures show the command, exit code and output, leaving files available for retry. To test unpublished source, use the local development commands below.
|
|
66
31
|
|
|
67
|
-
|
|
32
|
+
### Create an application
|
|
68
33
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
```bash
|
|
74
|
-
# 交互式创建(推荐)
|
|
75
|
-
hai create my-admin-app
|
|
76
|
-
|
|
77
|
-
# 指定模板与功能
|
|
78
|
-
hai create my-app -t full
|
|
79
|
-
hai create my-app -t custom -f iam,db,ai
|
|
34
|
+
```sh
|
|
35
|
+
hai create my-app --type fullstack --frontends web --yes
|
|
36
|
+
cd my-app
|
|
37
|
+
pnpm dev
|
|
80
38
|
```
|
|
81
39
|
|
|
82
|
-
|
|
40
|
+
Omit options for interactive choices, or use `--yes` for defaults. Installation and Git initialization are enabled; disable them with `--no-install` / `--no-git`. Deployment tools are development dependencies by default; use `--no-deploy` to omit them.
|
|
83
41
|
|
|
84
|
-
|
|
85
|
-
2. Choose a template (minimal / default / full / custom).
|
|
86
|
-
3. Select feature modules (custom template).
|
|
87
|
-
4. Choose whether to include example code.
|
|
88
|
-
5. Choose a package manager (pnpm / npm / yarn).
|
|
89
|
-
6. Choose whether to install dependencies.
|
|
90
|
-
7. Choose whether to initialize Git.
|
|
42
|
+
### Project templates
|
|
91
43
|
|
|
92
|
-
|
|
44
|
+
| Type | Generated project |
|
|
45
|
+
| -------------------------- | ------------------------------------------------------------------------------- |
|
|
46
|
+
| `admin` / `website` / `h5` | SvelteKit admin, website or mobile web application |
|
|
47
|
+
| `api` | Shared contract and API service in a pnpm workspace |
|
|
48
|
+
| `mobile-app` | Svelte + Vite + Capacitor |
|
|
49
|
+
| `fullstack` | Contract, API, shared UI and selected Web/App/Desktop; miniapp is a placeholder |
|
|
93
50
|
|
|
94
|
-
|
|
95
|
-
# 交互式选择
|
|
96
|
-
hai add
|
|
51
|
+
Use `--template minimal|default|full|custom` for module presets and `--features iam,db,...` for application modules. Fullstack keeps IAM, database, cache, crypto, storage and audit for its default management UI. It does not install AI/ONNX/CUDA by default.
|
|
97
52
|
|
|
98
|
-
|
|
99
|
-
hai add iam
|
|
100
|
-
hai add storage
|
|
101
|
-
```
|
|
53
|
+
### Fullstack mini administration
|
|
102
54
|
|
|
103
|
-
|
|
55
|
+
Includes user management, roles, audit logs, avatars, personal settings, themes, languages, onboarding and help. Sign in as `admin` using the random `HAI_ADMIN_DEFAULT_PASSWORD` in root `.env.local`. Existing users are not reset. Adapt the sample business rules as needed; authorization remains on the server.
|
|
104
56
|
|
|
105
|
-
###
|
|
57
|
+
### Application configuration and display
|
|
106
58
|
|
|
107
|
-
|
|
108
|
-
# 校验配置完整性,补全缺失配置
|
|
109
|
-
hai init
|
|
110
|
-
|
|
111
|
-
# 强制重新生成所有配置
|
|
112
|
-
hai init --force
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
### Code generation
|
|
116
|
-
|
|
117
|
-
Names must start with a letter and contain only letters, digits, hyphens, or underscores; paths are rejected. All outputs are preflighted and overwrites rejected by default; only explicit `--force` replaces files. Outputs and symlink targets must stay in the working directory.
|
|
59
|
+
See `.env.example` for settings. Commit shared `.env` and `.env.dev/.env.test/.env.prod`; keep private overrides in `.env.local`. Precedence is process environment > local private file > selected environment > shared base. API projects keep these files in the service directory; fullstack uses the root. See the [usage guide](../../docs/usage/README.en.md) for YAML, environment overrides and application metadata.
|
|
118
60
|
|
|
119
|
-
|
|
61
|
+
### Existing projects and code generation
|
|
120
62
|
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
hai
|
|
124
|
-
|
|
125
|
-
# 指定类型
|
|
126
|
-
hai generate page users
|
|
63
|
+
```sh
|
|
64
|
+
hai add storage
|
|
65
|
+
hai init
|
|
66
|
+
hai generate page dashboard
|
|
127
67
|
hai generate component UserCard
|
|
128
|
-
hai generate api
|
|
129
|
-
hai generate model
|
|
130
|
-
hai generate migration add-
|
|
131
|
-
|
|
132
|
-
# 快捷命令
|
|
133
|
-
hai g:page dashboard
|
|
134
|
-
hai g:component StatusBadge
|
|
135
|
-
hai g:api orders
|
|
136
|
-
hai g:model order
|
|
68
|
+
hai generate api orders
|
|
69
|
+
hai generate model order
|
|
70
|
+
hai generate migration add-orders
|
|
137
71
|
```
|
|
138
72
|
|
|
139
|
-
|
|
73
|
+
`hai add` resolves module dependencies and fills configuration. `hai init` fills missing configuration and AI files while preserving custom content. `--force` regenerates module configuration; review the diff before using it.
|
|
140
74
|
|
|
141
|
-
|
|
142
|
-
| --------- | ----------- | --------------------------------------------------------- |
|
|
143
|
-
| `minimal` | Minimal | Basic SvelteKit/hai skeleton (Svelte 5 + Vite on mobile) |
|
|
144
|
-
| `default` | Default | IAM + DB + Cache + Crypto |
|
|
145
|
-
| `full` | Full | All business modules + API Service / contract integration |
|
|
146
|
-
| `custom` | Custom | Choose as needed |
|
|
75
|
+
The page/api generators target SvelteKit. Extend fullstack/API projects through their contract/procedure structure. Names cannot contain paths; existing files are protected unless `--force` is explicit. Migrations generate up/down functions only; inspect data effects before running them.
|
|
147
76
|
|
|
148
|
-
|
|
77
|
+
### Build and deploy
|
|
149
78
|
|
|
150
|
-
|
|
79
|
+
`pnpm build` compiles sources. Each image has its own Dockerfile in `images/`, selected through `hai.build.json`. `--images` selects build outputs; `--services` selects deployed services. Automatic engine detection prefers reachable Podman, then Docker. Downloads, installation and production dependency packaging share package and SQLite driver caches to avoid downloading them again.
|
|
151
80
|
|
|
152
|
-
|
|
81
|
+
The default container supports CPU workloads or remote AI services without downloading extra GPU runtimes. To use the deployment host's GPU, customize the image and container runtime settings.
|
|
153
82
|
|
|
154
|
-
```
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
pnpm
|
|
158
|
-
pnpm.
|
|
83
|
+
```sh
|
|
84
|
+
pnpm build --target docker
|
|
85
|
+
pnpm run deploy --env prod
|
|
86
|
+
pnpm run deploy --env prod --build --services web
|
|
87
|
+
pnpm run deploy --env prod --build --bundle-only --output release-prod.tar
|
|
159
88
|
```
|
|
160
89
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
The CLI generates a root `.env.local` with a unique random strong `HAI_ADMIN_DEFAULT_PASSWORD`, so `dev` / `start` work directly. Sign in as `admin` using that password; an environment variable with the same name overrides it. Passwords follow `_iam.yml` policy, with a default minimum of 8 characters. Startup logs include the specific validation reason and error code when a password violates the policy. Once users exist, the variable does not reset accounts or passwords. Git and container builds ignore `.env.local`, while `.env.example` contains only a placeholder. Set a separate password in each deployment environment.
|
|
164
|
-
|
|
165
|
-
- Administrators can search, paginate, create, edit, enable, disable and delete users and upload avatars. The server protects the current administrator and rechecks authorization inside a mutation lock so concurrent actions cannot remove every administrator's access.
|
|
166
|
-
- Initial roles are `admin` / `user`. The role page shows member counts and edits descriptions; the user page assigns roles. By default, ordinary users only access personal settings, and the server rejects direct management API calls from them. Adapt these business rules to actual requirements.
|
|
167
|
-
- The audit page filters by action, resource and date. Successful login, logout, password changes and management writes produce audit records without passwords, tokens or avatar contents.
|
|
168
|
-
- Personal settings cover profile, avatar, language, theme and password changes. Preferences are stored in IAM user metadata. Avatars accept PNG/JPEG/WebP up to 512 KiB; the server validates image contents and generates the storage key.
|
|
169
|
-
|
|
170
|
-
The typed api-client and serv crypto transport encrypt JSON business requests, login and refresh in both directions. Web uses an in-memory access token and an HttpOnly refresh Cookie. Native App uses Capacitor secure TokenStorage; native Desktop stores tokens only in memory and requires login after restart. The native refresh body channel verifies the client identifier, explicit transport header and trusted Origin; browser previews use Cookie mode. Public avatars are binary image resources restricted by a whitelist.
|
|
171
|
-
|
|
172
|
-
Web/App/Desktop share one `AdminWorkspace`, management store and typed client. Current-user and refresh routes use the framework's default IAM procedures; theme caching and DOM updates use `@h-ai/ui/theme`. Application code composes initial roles, self-protection, avatars and auditing as example business rules that can change with actual requirements.
|
|
173
|
-
|
|
174
|
-
Default SQLite, local storage and memory cache suit a single-instance mini administration service. Management writes support one writer instance. Multiple read instances require shared database, storage, Redis cache and sticky transport sessions; all management writes must still reach the same writer. Redis alone does not provide atomic last-administrator protection across arbitrary writers. Generated root scripts provide typecheck, lint, build, test and test:e2e; Capacitor/Tauri delivery additionally requires the appropriate native build and packaging.
|
|
175
|
-
|
|
176
|
-
## Application configuration and display
|
|
177
|
-
|
|
178
|
-
Each project documents its variables, enums and bounds in `.env.example`. The [root catalog](../../.env.example) covers all modules; the [environment configuration](templates/skills/hai-app-create/development.md#环境配置) explains mode loading and common scripts.
|
|
179
|
-
|
|
180
|
-
Every generated `.gitignore` includes `**/data/`, covering runtime data and `.gitkeep` at every workspace depth. Runtime code creates the required directories.
|
|
181
|
-
|
|
182
|
-
Fullstack always includes 13 `.yml` files in `packages/<project>-serv/config/`: `_core`, `_serv`, `_db`, `_cache`, `_iam`, `_storage`, `_audit`, `_reach`, `_ai`, `_vecdb`, `_payment`, `_scheduler`, and `_deploy`. Used modules retain working defaults; unused modules, optional fields, and alternative providers remain as comments. `.env.example` also includes commented credentials for unused modules. Module choices entered during creation are preserved.
|
|
183
|
-
|
|
184
|
-
To extend the service, install the required package in its workspace, validate with the public schema, initialize it and close it in reverse order in `src/server/runtime.ts`, then uncomment the relevant configuration. For a fully commented file, remove one outer comment layer first and enable optional blocks as needed. A configuration file alone does not connect business features. Replace connection blocks when switching SQLite/Redis/S3 or Reach providers, keeping each provider name unique. `crypto.init()` takes no configuration and datapipe provides pure functions; neither gets an invented YAML file.
|
|
185
|
-
|
|
186
|
-
Every template reads `name`, `version`, `env`, `defaultLocale` and `logging` from `_core.yml`, obtains metadata through `core.config` and uses `core.logger`. Single-app configuration lives in `config/`, API workspace configuration in `apps/<project>-service/config/`, and fullstack configuration in `packages/<project>-serv/config/`. YAML controls log level and format; initialization does not replace them with a fixed `logging` option.
|
|
187
|
-
|
|
188
|
-
Core environment overrides include `HAI_CORE_NAME`, `HAI_CORE_VERSION`, `HAI_CORE_ENV` and `HAI_CORE_LOGGING_LEVEL`; a whole `HAI_CORE` override follows parent-node precedence. Restart services after server configuration changes. Containers explicitly set `HAI_CORE_ENV=production`, which enables production security policy.
|
|
90
|
+
Complete bundles include application and self-hosted middleware images. Bundle-only mode creates a tar plus Windows `deploy.ps1` and Linux/macOS `deploy.sh`. On an isolated Linux server, extract and run `sh apply.sh`. First installations require a complete bundle; partial updates preserve other services and volumes. Each step reports its result; failure exits nonzero and attempts recovery. See [deployment](../deploy/README.en.md) for prerequisites, caching, versions and recovery.
|
|
189
91
|
|
|
190
|
-
|
|
92
|
+
Build desktop installers with `pnpm build --target desktop --platform windows|linux|macos --arch x64|arm64`, using the target system and toolchain. Test native installers separately from container-hosted web pages.
|
|
191
93
|
|
|
192
|
-
|
|
94
|
+
### AI-assisted development
|
|
193
95
|
|
|
194
|
-
|
|
96
|
+
Root `AGENTS.md` points to `.agents/skills/`; Claude, Copilot and OpenCode entry files reference the same rules. Use [application development](templates/skills/hai-app-create/SKILL.md) for features, [review](templates/skills/hai-spec-review/SKILL.md) and [implementation](templates/skills/hai-spec-implement/SKILL.md) for larger specifications, and [framework sync](templates/skills/hai-framework-sync/SKILL.md) for upgrades.
|
|
195
97
|
|
|
196
|
-
|
|
98
|
+
Skill entries define task boundaries and load adjacent references as needed. `hai init` / `hai add` fill missing content; merge existing custom rules deliberately and copy complete skill directories when syncing.
|
|
197
99
|
|
|
198
|
-
|
|
100
|
+
## Development and testing
|
|
199
101
|
|
|
200
|
-
|
|
102
|
+
### Local development usage
|
|
201
103
|
|
|
202
|
-
|
|
104
|
+
Run from the framework repository root to create projects from current source. Deployment gates additionally require reachable Podman/Docker.
|
|
203
105
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
| Option | Description |
|
|
207
|
-
| ------------------ | ------------------------- |
|
|
208
|
-
| `-v, --verbose` | Verbose output |
|
|
209
|
-
| `-C, --cwd <path>` | Set the working directory |
|
|
210
|
-
|
|
211
|
-
## Local development usage
|
|
212
|
-
|
|
213
|
-
> For local CLI development in the monorepo before publishing to npm.
|
|
214
|
-
|
|
215
|
-
### 1. Build
|
|
216
|
-
|
|
217
|
-
```bash
|
|
218
|
-
# 构建 CLI(生成 dist/)
|
|
106
|
+
```sh
|
|
219
107
|
pnpm --filter @h-ai/cli build
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
pnpm --filter @h-ai/cli
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
### 2. Run directly (no installation)
|
|
226
|
-
|
|
227
|
-
After building, invoke `dist/index.js` directly with `node`:
|
|
228
|
-
|
|
229
|
-
```bash
|
|
230
|
-
# 从仓库根目录运行
|
|
231
|
-
node packages/cli/dist/index.js create my-app
|
|
232
|
-
node packages/cli/dist/index.js create my-app --type admin --features iam,db
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
Or invoke it by absolute path from any directory:
|
|
236
|
-
|
|
237
|
-
```bash
|
|
238
|
-
node /path/to/hai-framework/packages/cli/dist/index.js create my-app
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
### 3. Global linking (`pnpm link`)
|
|
242
|
-
|
|
243
|
-
To use `hai` directly in a terminal, create a global link:
|
|
244
|
-
|
|
245
|
-
```bash
|
|
246
|
-
# 在 packages/cli 目录下执行
|
|
247
|
-
cd packages/cli
|
|
248
|
-
pnpm link --global
|
|
249
|
-
|
|
250
|
-
# 验证
|
|
251
|
-
hai --version
|
|
252
|
-
hai create my-app
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
> Remove the link afterward with `pnpm unlink --global @h-ai/cli`.
|
|
256
|
-
|
|
257
|
-
### 4. Use in other monorepo apps
|
|
258
|
-
|
|
259
|
-
Projects in `apps/*` reference local packages through `workspace:*` and can use them directly:
|
|
260
|
-
|
|
261
|
-
```bash
|
|
262
|
-
# 在仓库根目录执行,对任意 app 类型生成项目
|
|
263
|
-
node packages/cli/dist/index.js create ../my-new-project
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
## 5. Configuration driven authentication
|
|
267
|
-
|
|
268
|
-
Agreements support configuration-loaded userAgreementMarkdown/privacyPolicyMarkdown and URLs. Markdown takes priority for the same agreement and is safely rendered in a modal.
|
|
269
|
-
|
|
270
|
-
Admin/H5/website templates with IAM include AuthPanel and standard routes; mobile and fullstack clients share API actions. Server config/_iam.yml controls methods, registration, recovery, agreement modals and branding. LDAP/Reach are optional: install ldapts only for the default LDAP client, then enable login.ldap and set connection settings. Email/SMS use Reach templates or custom callbacks. Forms expose header/extraFields/footer snippets and AuthPanel forwards login*/register* snippets. Multiple nodes share a database and Redis.
|
|
271
|
-
|
|
272
|
-
[完整 IAM 配置 / IAM configuration](../iam/README.en.md)
|
|
273
|
-
|
|
274
|
-
### 6. Run tests
|
|
275
|
-
|
|
276
|
-
```bash
|
|
277
|
-
# 单元测试 + E2E 模板生成测试
|
|
108
|
+
node packages/cli/dist/index.js create ../my-app
|
|
109
|
+
pnpm --filter @h-ai/cli typecheck
|
|
110
|
+
pnpm --filter @h-ai/cli lint
|
|
278
111
|
pnpm --filter @h-ai/cli test
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
pnpm --filter @h-ai/cli test:
|
|
282
|
-
|
|
283
|
-
# watch 模式
|
|
284
|
-
pnpm --filter @h-ai/cli test:watch
|
|
285
|
-
|
|
286
|
-
# 覆盖率
|
|
287
|
-
pnpm --filter @h-ai/cli test:coverage
|
|
112
|
+
pnpm check:skills
|
|
113
|
+
pnpm --filter @h-ai/cli test:scaffold-gates
|
|
114
|
+
pnpm --filter @h-ai/cli test:deploy-gates
|
|
288
115
|
```
|
|
289
116
|
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
Successful screenshots default to the CLI's `test-results/scaffold-evidence/`. Set `HAI_AUTH_EVIDENCE_DIR` to retain them in a chosen directory after generated projects are cleaned up. Fullstack E2E starts every selected Web/App/Desktop browser preview and checks login, tours, help and profile navigation. Miniapp and native shells require separate platform acceptance.
|
|
293
|
-
|
|
294
|
-
Failures and degraded-state messages must also be localized: website APIs use the request locale for AI fallback and email delivery status; undelivered messages must not be described as received. CLI deployment status uses cliM, and Gallery encryption limitations use bilingual messages. Verify unconfigured, failed, and successful paths in Chinese and English without paid service calls.
|
|
295
|
-
|
|
296
|
-
Provisioned configuration: Neon emits HAI_DB (PostgreSQL JSON), Upstash HAI_CACHE (Redis rediss URL JSON), and R2 HAI_STORAGE (flat S3 JSON). Email/SMS emit HAI_REACH_PROVIDERS; deployApp merges both channels while preserving YAML message templates, replacing the original providers array. Core supports whole-object/array overrides, with parents preceding leaves and schema validation retained. Build subprocesses and target runtimes share provisioned values. R2 needs existing S3 accessKeyId/secretAccessKey, Resend a verified-domain from address, and Alibaba Cloud approved signName/templates. Applications need matching `_db.yml` / `_cache.yml` / `_storage.yml` / `_reach.yml` loaded at startup; network clients require Node.
|
|
297
|
-
|
|
298
|
-
Deployment recovery: `ProvisionResult.resourceStatus` marks created/reused. `getDeployRecovery(result.error)` reads projectName, stage, platformProjectId, and resource lists; unknown means an uncertain request result that must first be checked in the provider console. Preserve returned IDs for failed resources. Recovery excludes envVars, raw exceptions, and credentials; the CLI shows resources and advice. Same-name retries reuse resources. Reused resources are never deleted automatically; clean up newly created resources only after manually confirming they are unused.
|
|
299
|
-
|
|
300
|
-
## Generated form layouts
|
|
301
|
-
|
|
302
|
-
Website contact forms and fullstack management screens reuse UI FormLayout/FormField: one or two columns, stacked or inline labels, automatic spans and narrow-container fallback. User, profile and password forms share the same options and built-in Chinese/English validation. The generated hai-ui skill documents the complete contract.
|
|
117
|
+
Scaffold gates generate real projects and run install, typecheck, lint, build, tests and browser workflows. Deployment gates cover offline bundles, SSH/manual deployment and partial updates. Tests clean up their resources; save requested evidence in a designated directory. Native shells and real cloud providers need separate acceptance.
|
|
303
118
|
|
|
304
119
|
## License
|
|
305
120
|
|