@h-ai/cli 1.0.0-beta.19 → 1.0.0-beta.20
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 +69 -197
- package/README.ja.md +69 -197
- package/README.md +69 -197
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +14 -14
- package/templates/README.md +40 -35
- package/templates/apps/api/apps/{{projectName}}-contract/README.md.hbs +8 -0
- package/templates/apps/api/apps/{{projectName}}-serv/README.md.hbs +3 -1
- package/templates/apps/fullstack/apps/{{projectName}}-app/README.md.hbs +5 -7
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/README.md.hbs +6 -8
- package/templates/apps/fullstack/apps/{{projectName}}-miniapp/README.md.hbs +2 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/README.md.hbs +6 -8
- package/templates/apps/fullstack/packages/{{projectName}}-contract/README.md.hbs +7 -5
- package/templates/apps/fullstack/packages/{{projectName}}-serv/README.md.hbs +9 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/README.md.hbs +48 -68
- package/templates/base/package.json.hbs +1 -1
- package/templates/skills/hai-ai/guide.md +3 -1
- package/templates/skills/hai-ai/reference.md +2 -2
- package/templates/skills/hai-deploy/SKILL.md +2 -0
- package/templates/skills/hai-ui/SKILL.md +1 -1
- package/templates/skills/hai-ui/reference.md +1 -0
package/README.en.md
CHANGED
|
@@ -1,276 +1,148 @@
|
|
|
1
1
|
# @h-ai/cli
|
|
2
2
|
|
|
3
|
-
[简体中文](README.md) | [English](README.en.md) | [日本語](README.ja.md)
|
|
3
|
+
[简体中文](README.md) | [English](README.en.md) | [日本語](README.ja.md) · [Framework home](../../README.en.md)
|
|
4
4
|
|
|
5
|
-
[
|
|
5
|
+
Use `hai` to create applications, add modules, generate starter code, and build Web, API and native artifacts. Follow the [usage guide](../../docs/usage/README.en.md) for the full workflow.
|
|
6
6
|
|
|
7
|
-
##
|
|
8
|
-
|
|
9
|
-
Generated projects enable `zh-CN`, `en-US` and `ja-JP` by default. Interactive setup can select Japanese as the default; fullstack can restrict locales through `fullstack.i18n.locales`. CLI messages select Chinese, English or Japanese using `HAI_CORE_DEFAULTLOCALE` → `LC_ALL` → `LC_MESSAGES` → `LANG`.
|
|
10
|
-
|
|
11
|
-
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.
|
|
12
|
-
|
|
13
|
-
## Core features
|
|
14
|
-
|
|
15
|
-
- Create admin, website, H5, API, mobile or fullstack applications.
|
|
16
|
-
- Add modules, configuration and AI guidance to existing projects.
|
|
17
|
-
- Generate starter pages, components, endpoints, models and migrations.
|
|
18
|
-
- Build selected images, deliver complete offline bundles or update selected services.
|
|
19
|
-
|
|
20
|
-
## Getting started
|
|
7
|
+
## Quick Start
|
|
21
8
|
|
|
22
9
|
### Install the CLI
|
|
23
10
|
|
|
24
11
|
Use Node.js matching `engines` (`^22.23.4 || ^24.22.1 || ^26.12.1`) and pnpm 12.11.2. In PowerShell use `pnpm.cmd`.
|
|
25
12
|
|
|
26
|
-
Inspect the published channels and install latest. Check supported options with `hai create --help`; validate unreleased source features using the local development steps below.
|
|
27
|
-
|
|
28
13
|
```sh
|
|
29
|
-
pnpm view @h-ai/cli dist-tags
|
|
30
14
|
pnpm view @h-ai/cli@latest version
|
|
31
15
|
pnpm add -g @h-ai/cli@latest
|
|
32
16
|
hai --version
|
|
33
|
-
hai --help
|
|
34
|
-
```
|
|
35
|
-
|
|
36
|
-
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.
|
|
37
|
-
|
|
38
|
-
### Create an application
|
|
39
|
-
|
|
40
|
-
```sh
|
|
41
17
|
hai create my-app --type fullstack --frontends web
|
|
42
18
|
cd my-app
|
|
43
19
|
pnpm dev
|
|
44
20
|
```
|
|
45
21
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
### Project templates
|
|
49
|
-
|
|
50
|
-
| Type | Generated project |
|
|
51
|
-
| -------------------------- | ------------------------------------------------------------------------------- |
|
|
52
|
-
| `admin` / `website` / `h5` | SvelteKit admin, website or mobile web application |
|
|
53
|
-
| `api` | Shared contract and API service in a pnpm workspace |
|
|
54
|
-
| `mobile-app` | Svelte + Vite + Capacitor |
|
|
55
|
-
| `fullstack` | Contract, API, shared UI and selected Web/App/Desktop; miniapp is a placeholder |
|
|
56
|
-
|
|
57
|
-
Each template installs only the modules it uses: admin/h5 include authentication, OTP/password-reset notifications, database, cache and crypto; website uses Core/Kit/UI; API includes authentication, notifications, uploads and feedback; fullstack retains administration, audit, storage, notifications, scheduling and feedback; mobile-app uses client capabilities only. AI, payment, vecdb and datapipe are not installed by default. Every project retains complete module YAML and `.env.example` references, with unused settings commented out and excluded from public environment defaults. To add a feature, install its dependencies, enable the required configuration and wire initialization, cleanup and business routes. Adding a dependency does not enable features automatically. `--template`, `--features` and `--examples/--no-examples` remain removed; `create --yes/-y` is now `--defaults`. Old options fail explicitly. `deploy --yes` keeps its meaning; existing projects are not automatically trimmed.
|
|
58
|
-
|
|
59
|
-
Standalone `mobile-app` includes frontend crypto and encrypted typed-client transport. For an existing plaintext API, explicitly set `PUBLIC_API_TRANSPORT=off`. `PUBLIC_API_KEY_EXCHANGE_PATH` overrides the public exchange subpath. Handshake failures never fall back, server private keys never enter clients, and cleanup closes transport before client-owned crypto.
|
|
60
|
-
|
|
61
|
-
Admin, website, h5 and Fullstack Web check browser versions before loading the application. The standalone upgrade page shows the current version, the minimum and official update instructions. The minimum is Chrome/Edge 111, Firefox 114, Safari 16.4 or iOS/iPadOS 16.4. See the [browser startup check](../../docs/usage/getting-started/build.md#浏览器启动检测) for existing projects.
|
|
62
|
-
|
|
63
|
-
### Static websites and GitHub Pages
|
|
64
|
-
|
|
65
|
-
New websites default to Node SSR and install only Core/Kit/UI, so they can use the static build below directly. Remove any server business dependencies, initialization or custom APIs/actions added later before publishing statically. Commented configuration and environment references do not affect static builds.
|
|
66
|
-
|
|
67
|
-
Website defaults to Node SSR. Set `HAI_BUILD_STATIC=1` and `PUBLIC_BASE_PATH=/docs-site` (replace docs-site with the repository name; segments allow only ASCII letters, digits, _, . and -; no trailing slash, empty for a root site) for `pnpm build` to generate the static build directory. The static flag accepts 0/1 and applies only to compile. PUBLIC_BASE_PATH also supports Docker website builds; native app/desktop targets reject website paths. Static builds reject server-side business modules, custom APIs/actions and pages that were not prerendered, preserve production guards and use no SPA fallback. The default health API is excluded.
|
|
22
|
+
Input a project name and template type; output is a project with dependency installation and Git initialization enabled. `--defaults` accepts defaults. `--no-install`, `--no-git` and `--no-deploy` omit installation, Git and deployment development dependencies respectively. Missing choices are interactive. Check each installed command with `hai <command> --help`.
|
|
68
23
|
|
|
69
|
-
|
|
24
|
+
## Features
|
|
70
25
|
|
|
71
|
-
|
|
26
|
+
### Commands, inputs and outputs
|
|
72
27
|
|
|
73
|
-
|
|
28
|
+
These are terminal commands; no framework service initialization is required. Observe actual output and exit status. Replace TARGET_VERSION with the published exact version returned by pnpm view; do not pass the placeholder literally.
|
|
74
29
|
|
|
75
|
-
|
|
30
|
+
| Command | Purpose and input | Output and example |
|
|
31
|
+
| -------------- | -------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
32
|
+
| create | Project name, type and fullstack frontend choices | `hai create orders --type admin --defaults` creates an admin application |
|
|
33
|
+
| add | Add a named module to the current project | `hai add ai` adds dependencies, configuration and skills while preserving business files; wire initialization, shutdown and routes in the application |
|
|
34
|
+
| init | Complete project configuration and AI entry points | `hai init` fills missing files; review changes before `--force` rebuilds module configuration |
|
|
35
|
+
| generate / g | Type, name and target workspace | `hai generate api orders --workspace orders-serv` creates routes or contract/procedure files; shortcuts are g:page/g:component/g:api/g:model |
|
|
36
|
+
| build | Target, images/platform and source inputs | `hai build --target image --json` emits the current artifact JSON; build has no deployment environment option |
|
|
37
|
+
| deploy | Environment, artifacts and selected services | `hai deploy --env prod --plan` emits a read-only plan; omit plan to enter delivery |
|
|
38
|
+
| upgrade | Exact release version and project | `hai upgrade TARGET_VERSION` reports dependencies, integrity, configuration and skill drift without installation or overwrites |
|
|
39
|
+
| deploy-secrets | Server directory and private JSON | `hai deploy-secrets /srv/orders --import /private/orders.json --runtime docker` validates by default; only explicit `--apply` writes state |
|
|
40
|
+
| feedback | Action, diagnostic ZIP and filters | `hai feedback summary feedback.zip` prints a summary; inspect/evidence/view provide manifest, evidence or a local viewer |
|
|
76
41
|
|
|
77
|
-
|
|
42
|
+
Global `--cwd/-C` selects the project and `--verbose/-v` enables detailed diagnostics. CLI language follows `HAI_CORE_DEFAULTLOCALE` → `LC_ALL` → `LC_MESSAGES` → `LANG`, independently of the generated application's language.
|
|
78
43
|
|
|
79
|
-
###
|
|
44
|
+
### Templates
|
|
80
45
|
|
|
81
|
-
|
|
46
|
+
| type | Generated application and use case |
|
|
47
|
+
| -------------------- | ------------------------------------------------------------------------------------ |
|
|
48
|
+
| admin / website / h5 | SvelteKit admin, presentation website or mobile Web; website starts with Core/Kit/UI |
|
|
49
|
+
| api | Shared contract and independent Serv in a pnpm workspace |
|
|
50
|
+
| mobile-app | Svelte/Vite/Capacitor client connected to an independent API |
|
|
51
|
+
| fullstack | Contract, Serv, shared UI and selected Web/App/Desktop; miniapp is a placeholder |
|
|
82
52
|
|
|
83
|
-
|
|
53
|
+
Templates install modules they actually use and retain commented optional configuration plus `.env.example`. Uncommenting a block does not wire a feature. Add AI/payment/vecdb/datapipe when needed; production uses shared database, Redis and file backends. Chinese, English and Japanese are enabled by default; fullstack can restrict `fullstack.i18n.locales`.
|
|
84
54
|
|
|
85
|
-
|
|
55
|
+
Browser templates check known unsupported versions before loading: Chrome/Edge111, Firefox114, Safari and iOS/iPadOS16.4 are the minimums. See [browser startup](../../docs/usage/getting-started/build.md#浏览器启动检测).
|
|
86
56
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
Templates default to `pretty` logging and install `pino-pretty` as a runtime dependency; set `HAI_CORE_LOGGING_FORMAT=json` for JSON. Startup failures retain the module, error code and configuration fields; occupied ports report `EADDRINUSE`, address and port.
|
|
90
|
-
|
|
91
|
-
Public settings live in `.env` and `.env.<mode>`; SSH settings and credentials go to Git-ignored `.env.<mode>.local`. `.env.local` contains shared machine-private settings. Builds do not read deployment secrets. All `HAI_*` settings use process > `.env.<mode>.local` > `.env.local` > `.env.<mode>` > `.env` > YAML. Within one source, fields override base JSON. Replacing a whole node from a higher source clears lower-source fields. Node/Vite and deployment share Core resolution.
|
|
92
|
-
|
|
93
|
-
### Existing projects and code generation
|
|
94
|
-
|
|
95
|
-
`hai add ai` also installs reldb and vecdb. Integrate startup in database → vector store → AI order, with reverse cleanup and explicit cleanup failure handling. Production profiles select PostgreSQL (or the chosen MySQL), Redis, S3 and Qdrant for enabled modules, using Compose DNS names `db/cache/storage/vecdb`. Inject database/cache passwords, S3 credentials, model keys and protected Qdrant keys privately. Override internal addresses when running outside Compose. Production Reach intentionally rejects an empty provider array until a real `HAI_REACH_PROVIDERS` JSON secret is supplied. `hai add` preserves configured production values, adds missing fields, and requires integration into the existing application entry point.
|
|
57
|
+
### Generate pages, components, APIs, models and migrations
|
|
96
58
|
|
|
97
59
|
```sh
|
|
98
|
-
hai add storage
|
|
99
|
-
hai init
|
|
100
|
-
hai generate
|
|
101
60
|
hai generate page dashboard
|
|
102
61
|
hai generate component UserCard
|
|
103
|
-
hai generate api orders
|
|
62
|
+
hai generate api orders --workspace orders-serv
|
|
104
63
|
hai generate model order
|
|
105
64
|
hai generate migration add-orders
|
|
106
65
|
```
|
|
107
66
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
Pages use SvelteKit file routes. APIs use either SvelteKit routes or the target serv application's shared contract/procedure structure. API/fullstack roots select a unique backend automatically; use `--workspace <package-name-or-relative-path>` when multiple applications apply, or enter the target workspace. Plain Vite page/API combinations are rejected. Serv does not accept `--output`; SvelteKit route output must stay inside `src/routes`; custom `kit.files` layouts are rejected rather than guessed. SvelteKit API targets must already install `@h-ai/kit` and `zod`. Serv updates only existing aggregation points with `@hai-generator` markers; unknown structures require manual integration. Names cannot contain paths. Existing files require `--force`, which never replaces registered business domains. Files are checked as one batch and rolled back on write failure. Migrations only generate up/down functions; inspect data effects before running them.
|
|
111
|
-
|
|
112
|
-
CLI messages support Chinese, English and Japanese. The first nonempty value from `HAI_CORE_DEFAULTLOCALE`, `LC_ALL`, `LC_MESSAGES` and `LANG` selects the initial language. Regional `en`/`zh`/`ja` variants use the existing dictionaries; `C`/`POSIX` use English. Unknown languages preserve the current core locale, which defaults to Chinese. In PowerShell, run `$env:HAI_CORE_DEFAULTLOCALE='en-US'` before `hai generate`. Internal commands also honor in-process locale changes via `core.i18n.setGlobalLocale('en-US')`. Omitting a type or name opens a prompt; cancellation writes no files. Generated Chinese code comments and user-supplied names remain unchanged.
|
|
113
|
-
|
|
114
|
-
Prompts, validation, module/template names, descriptions and completion messages in `create`, `add`, `init` and `generate` use the current CLI locale. Catalog labels are translated when read, including after an in-process locale change. The CLI locale is separate from the generated application’s `core.defaultLocale`; generated Chinese README text, configuration/code comments, user input and original external-tool diagnostics remain unchanged.
|
|
115
|
-
|
|
116
|
-
### SvelteKit endpoint security
|
|
117
|
-
|
|
118
|
-
Select crypto when creating admin, website or h5 projects to enable transport in `_kit.yml`; its default remains false. The server uses separately generated environment key rings, and the root layout exposes only public transport settings. Private IP/time policies remain server-side. Select db for a database registry; an in-memory registry without db is limited to development/test. Static websites have no dynamic endpoints.
|
|
67
|
+
Names cannot contain paths. Existing business files are preserved by default. `--workspace` accepts a package name or relative directory; SvelteKit `--output` must remain inside src/routes and Serv does not accept it. Pages require file routing; unsupported plain-Vite page/API combinations fail clearly. Serv updates only aggregation entries marked `@hai-generator`. The batch is validated before writing and rolled back on write failure. `--force` replaces generated files only. Migration output contains up/down functions, not executed database changes.
|
|
119
68
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
### Optional HTTPS certificates
|
|
123
|
-
|
|
124
|
-
`pnpm run deploy` offers no HTTPS, existing PEM certificate/key paths, or Let’s Encrypt for every container template. Relative paths resolve from the project root. Certificates are checked for domain, validity and key matching, then copied into private releases. A pinned official Certbot image handles issuance and renewal checks every 12 hours, with automatic Nginx reload. It requires terms acceptance, a real email, public DNS, port 80 and CA connectivity. Isolated servers use existing certificates. Certificate state stays on the server; keys stay out of application images. `--yes` reuses saved settings.
|
|
125
|
-
|
|
126
|
-
Configure `hai.json.deploy.provider.expose.https` or private environment overrides. Defaults are HTTPS 443 and HTTP redirection; omission retains HTTP. Enabling/disabling HTTPS or changing mode, domain, ports or supplied certificates requires a full deployment. See the [HTTPS guide](../../docs/usage/configuration/delivery.md#可选https证书). Plans use `root` for the project and `serviceDir` for the service source/configuration directory, exposing only public certificate metadata.
|
|
127
|
-
|
|
128
|
-
### Build and deploy
|
|
129
|
-
|
|
130
|
-
On Windows, builds forward stdout/stderr with normalized terminal line endings. pnpm downloads use append-only logs while retaining warnings and failures.
|
|
131
|
-
|
|
132
|
-
Select image and npm downloads independently with `--image-source official|cn|custom` and `--npm-source official|cn|custom`. The mainland-China preset uses 1ms mirrors for Docker Hub/GHCR and npmmirror for npm. First-time interactive choices become `hai.json.build.sources` defaults. Flags override only this invocation; `--yes` reuses settings, and an unconfigured noninteractive run uses official sources. Configure `build.proxy` through `--proxy-mode inherit|system|custom|none`, `--proxy-url`, and `--proxy-bypass`. Both Docker and Podman receive build proxy arguments; loopback URLs are handled according to the build network and checked inside the build container. Image pulls use the engine's own proxy settings. See [download sources and proxies](../../docs/usage/configuration/delivery.md#下载源和代理) for custom mappings, system-proxy support and existing Dockerfile updates.
|
|
69
|
+
### Build, static sites and native packages
|
|
133
70
|
|
|
134
71
|
```sh
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
72
|
+
hai build --target image --images "serv,web" --concurrency 1
|
|
73
|
+
hai build --target app --platform android --runtime auto --debug
|
|
74
|
+
hai build --target desktop --platform windows --arch x64
|
|
138
75
|
```
|
|
139
76
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
Custom PostgreSQL, MySQL, Redis and pgvector connections offer a choice between a URL and individual fields. The URL is hidden during entry, and the saved address shows the scheme, host and port. The S3 wizard asks for the API `endpoint` and `bucket` separately. Validation errors identify the variable and its expected value format. See [connecting existing middleware](../../docs/usage/configuration/delivery.md#连接已有数据库缓存和对象存储) for examples.
|
|
143
|
-
|
|
144
|
-
Node backends (Serv / SvelteKit SSR) read `<deployment-root>/config/.env.runtime` on every start. This single application file includes managed connections. Edit a field such as `HAI_STORAGE_PUBLICENDPOINT`, then restart the backend; fields override parent JSON within the same source. The configuration directory is mounted read-only at `/run/hai/config`, so atomic file replacement is visible on restart. Private proxy identity and Node startup options remain deployment settings. Static Web, native middleware environment, ports/mounts, and Nginx routes or limits require deployment. Web/middleware-only updates retain the file; partial backend updates preserve managed connections, while full updates use the new package with existing managed credentials. Back up edits and copy permanent settings into the source environment.
|
|
145
|
-
|
|
146
|
-
The outer `README.txt` and the archive’s `APPLY.txt` include the file index, environment precedence, names of variables in this bundle, and troubleshooting steps. The unpacked `config/.env.runtime` is release input, the deployment root holds the active file, and `releases/<ID>/` holds the release record. After rotating an external PostgreSQL password, update the project environment and deploy the backend. Packaging rejects conflicting URL and separate passwords. Use a full deployment to switch between external and bundled middleware.
|
|
77
|
+
Target defaults to compile; alternatives are image/app/desktop. Image roles are serv/web; native targets are not Compose services. Images run at most two builds concurrently. Auto selects ready Podman then Docker; an explicit engine does not fall back. Android without runtime uses the host toolchain. iOS requires macOS/Xcode and signing.
|
|
147
78
|
|
|
148
|
-
|
|
79
|
+
Artifacts use separate `.hai/build/` batches and update relative `latest` only after archival succeeds. Image `--json` stdout contains only the current result; pass its `artifactDir` to deployment. Progress and failures go to stderr. Unknown Git provenance or dirty state is not a clean-input guarantee. See [names, signing and automation](../../docs/usage/getting-started/build.md).
|
|
149
80
|
|
|
150
|
-
|
|
81
|
+
For a static website, set build-process `HAI_BUILD_STATIC=1` and the actual `PUBLIC_BASE_PATH`, then run `pnpm build`. Publish build only, including .nojekyll. Static builds reject dynamic APIs/actions, server business initialization, private assets and links. An unconnected contact form explains the missing service and retains input. Changing the website path requires rebuilding; API addresses are separate. See [static/subpath configuration](../../docs/usage/configuration/delivery.md).
|
|
151
82
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
Database connections are validated against the selected backend’s public schema before saving. MySQL `ssl` accepts only `false` or a strict TLS object; `{}` verifies the certificate chain and DNS identity by default. PostgreSQL keeps its modes. CLI bundles the pure schemas and Zod, so validation needs no database package or driver in the target application; running that application still requires its dependencies. Deployment still requires an installed, resolvable `@h-ai/deploy` (a development dependency in generated projects).
|
|
155
|
-
|
|
156
|
-
`pnpm build` compiles sources. Each image has its own Dockerfile in `images/`, selected through `hai.json.build.images`, alongside the project deployment settings in `deploy`. `--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.
|
|
157
|
-
|
|
158
|
-
Build images only from a trusted context that other parties cannot replace during the build. The CLI maintains dependency inputs and a `.managed.json` manifest under each context’s `images/dependencies/`. Cache ancestor directories must not be symbolic links or Windows junctions, and cache files must not be links or have multiple hard links. Updates publish exclusive temporary files atomically; unchanged content keeps its timestamp, and stale tracked files are removed only within the cache tree. If a cache path error occurs, use its reason and diagnostic code to check links or permissions before rebuilding. Tracking manifests are limited to 16MiB; oversized or invalid JSON receives a diagnostic without echoing file contents.
|
|
159
|
-
|
|
160
|
-
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.
|
|
161
|
-
|
|
162
|
-
After filtering caller `HAI_/PUBLIC_/VITE_` values, CLI injects only internally generated `HAI_BUILD_ID/HAI_BUILD_COMMIT`; Docker passes the image batch identity to compilation. Feedback reads each browser/server artifact's own `appVersion/buildId/commit`, with its own manifest version and a shared ID within one SSR build. Missing owning Git commits are explicitly `unknown`. The three-field `build-metadata.json` matches inlined code and supports comparison with actual API/ZIP evidence.
|
|
163
|
-
|
|
164
|
-
Delivery roles are `serv` for a separate API backend, `web` for a static or SSR browser site, `app` for Android/iOS installers, and `desktop` for desktop installers. Fullstack containers use serv plus optional web; API uses serv; browser images for admin/website/h5/mobile-app use web. Native app/desktop outputs are not server Compose services. Use serv/web with `--images` and `--services`, and `--target app` or `--target desktop` for native packages. API service directories are `apps/<project>-serv`. Images and containers share the normalized root `package.json.name`: remove scope, lowercase, and replace invalid character runs with a hyphen. Missing or invalid names fail without falling back to directory names. Images use `localhost/hai-<project>-<role>:<buildId>`; containers use `hai-<project>-<environment>-<role>`. Images remain reusable across environments.
|
|
83
|
+
### Deployment, offline delivery and recovery
|
|
165
84
|
|
|
166
85
|
```sh
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
pnpm run deploy --env prod --build --services "serv,web"
|
|
172
|
-
pnpm run deploy --env prod --build --bundle-only
|
|
86
|
+
hai deploy --env prod --plan
|
|
87
|
+
hai deploy --env prod --plan --inspect-remote
|
|
88
|
+
hai deploy --env prod --build --bundle-only
|
|
89
|
+
hai deploy --env prod --build --services "serv,web"
|
|
173
90
|
```
|
|
174
91
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
`manifest.source.dirty` covers nonignored Git changes in the project, selected image contexts and Dockerfiles, including sibling packages when the context is the repository root. Inputs outside the owning repository or an incomplete check produce `null`, which does not mean clean. This field does not attest the content of build inputs.
|
|
178
|
-
|
|
179
|
-
The default deployment name comes from `package.json.name` at the project root (the nearest `hai.json` or lockfile directory), rejecting missing or invalid names, with an explicit environment appended. A fullstack `hai-delivery` project scanned at `packages/hai-delivery-serv` with `--env test` generates `/opt/hai/apps/hai-delivery-test` and `bundle-hai-delivery-test-<deploymentId>-<version>.tar.gz`. Remote directories, bundles, the Compose project, API/Web/middleware containers, data volumes, server credential state and incremental baselines share this name. Actual project names ending in `-serv` are preserved.
|
|
180
|
-
|
|
181
|
-
Artifact formats 4 and 5 record primaryService (serv/web); hasWeb describes the complete browser topology. Format 5 also records a non-root webBasePath. Only serv + web generates a same-origin API proxy. Rebuild artifacts using formats 1–3. Back up the existing deployment and verify project identity, volumes and managed credentials before establishing a new full deployment baseline. Tools do not migrate data across projects. Full deployments still remove obsolete service containers under the same Compose project; editing deploy-target.json.directory alone does not migrate resources.
|
|
182
|
-
|
|
183
|
-
For existing projects, update build.images names in hai.json, Dockerfile filenames and references first. Rename API service directories/packages and dependent references to -serv, then reinstall dependencies and build a complete artifact. Renaming archives or editing manifest files does not replace a new build.
|
|
184
|
-
|
|
185
|
-
The CLI --project-name option and SDK DeployAppOptions.projectName override have been removed. Obsolete overrides fail explicitly; maintain resource identity in the root package.json.name.
|
|
186
|
-
|
|
187
|
-
The server persists managed middleware passwords in `<remoteDir>/managed-secrets.env` (mode 0600); back it up with data volumes. Each package supplies random first-use candidates without a build-machine cache. The online SDK, deploy.sh, deploy.ps1 and deploy-local.sh resolve server values under the deployment lock and update both application connections and native middleware variables. The delivery tar stays immutable; only private server runtime files receive resolved values. Missing state with an existing corresponding volume stops deployment before services change: restore the server credential backup. Deployment never silently rotates passwords or deletes data. Legacy credentials can be explicitly verified and imported using the procedure below.
|
|
188
|
-
|
|
189
|
-
For Docker or Podman deployments, set per-image hostname mappings in `deploy.container.compose.services.<serv or web>.extra_hosts`, then rebuild the bundle and deploy the affected service. [Configuration example](../../docs/usage/configuration/delivery.md#为容器设置主机名映射)
|
|
190
|
-
|
|
191
|
-
Complete bundles include application and self-hosted middleware images. Deployment caches, archives and operation directories default to `.hai/deploy/<environment>/` at the project root; `--output` can override the archive path relative to the command directory. Interactive bundle-only mode offers to add or update SSH settings after builds and middleware configuration, before packaging. It saves them in `.env.<environment>.local` for the current and subsequent targets; `--yes` or declining reuses existing settings. The delivery directory contains only a tar, deploy-local.sh, read-target.awk, README.txt, `deploy-target.json` with field descriptions, Windows PowerShell 5+ `deploy.ps1` and Linux/macOS `deploy.sh`. Check the target and fill missing fields before upload. Both scripts read it, support key/agent and password authentication, and need no Node/pnpm. The target references only `passwordEnv` (default `HAI_DEPLOY_PROVIDER_SSH_PASSWORD`); the operator environment supplies the password to this SSH/SCP process tree only, never to the application environment or bundle. Target edits affect that bundle only and never write back to the project. On isolated Linux servers, copy the whole directory and run `sh deploy-local.sh` to extract and deploy automatically. If you copy only the archive, extract it, read `APPLY.txt`, and run `sh ./apply.sh` from that directory. 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.
|
|
192
|
-
|
|
193
|
-
Missing SSH connection and authentication fields are collected once; hidden password input preserves spaces and leading zeros. Complete settings are reused with `--yes`. Public settings live in `.env` and `.env.<mode>`; SSH settings and credentials go to Git-ignored `.env.<mode>.local`. `.env.local` contains shared machine-private settings. Builds do not read deployment secrets. All `HAI_*` settings use process > `.env.<mode>.local` > `.env.local` > `.env.<mode>` > `.env` > YAML. Within one source, fields override base JSON. Replacing a whole node from a higher source clears lower-source fields. Node/Vite and deployment share Core resolution.
|
|
194
|
-
|
|
195
|
-
Failures display local managed-process termination separately from remote unknown/finished-script state and the server result path. Local SSH exit does not prove remote termination. Inspect unknown server state first; CLI never reruns deployment or rollback automatically. Windows command execution uses an embedded system PowerShell/.NET Job and requires Add-Type; failure never starts an unmanaged command.
|
|
196
|
-
|
|
197
|
-
Normal foreground deployment and synchronous failure recovery explicitly unlock `.deploy.lock` after finalization and terminal-result publication, so background services do not block later deployments. On HUP/INT/TERM or a killed parent shell, active child commands retain the inherited lock until every holder exits or the server restarts. Keep the lock file permanently; never delete or replace it.
|
|
198
|
-
|
|
199
|
-
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.
|
|
92
|
+
Plan validates and reports; inspect-remote additionally reads baseline facts over SSH. Not-inspected is not verified. Bundle-only avoids target connections and produces the archive, target description, upload/local scripts and instructions; APPLY.txt inside describes manual deployment. Initial installation and topology changes require a complete bundle; partial updates require a matching successful server baseline.
|
|
200
93
|
|
|
201
|
-
|
|
94
|
+
Root `package.json.name` defines project identity with an environment suffix. Protect server credentials, backend bindings and volumes together. Failed updates can restore previous services, but do not undo database changes, migrations, notifications or payments. For unknown SSH results, inspect remote facts before retrying. See [deployment/recovery](../deploy/README.en.md).
|
|
202
95
|
|
|
203
|
-
|
|
96
|
+
HTTPS supports existing regular PEM files or Let's Encrypt. Each certificate/key is limited to1MiB and links are rejected; ACME needs DNS, email, terms acceptance and public port80. Certificate state stays on the server. Enabling, disabling or changing the layout requires full deployment. See [HTTPS](../../docs/usage/configuration/delivery.md#可选https证书).
|
|
204
97
|
|
|
205
|
-
|
|
98
|
+
### Diagnostics, release inspection and credential import
|
|
206
99
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
The fullstack example separates `admin`, `audit_admin`, `config_admin`, `business_operator` and basic `user` duties in application configuration. System administrators cannot take over other duty accounts. CLI creates independent random bootstrap passwords for all four duties in each `.env.dev.local/.env.test.local/.env.prod.local`, keeping these files out of Git and distributing environment secrets through protected configuration, and existing accounts are never reset or reassigned. Select security enhancements in `_iam.yml`/`_audit.yml`; see the generated README.
|
|
214
|
-
|
|
215
|
-
The [fullstack security configuration guide template](templates/apps/fullstack/docs/security-configuration.md.hbs) explains every switch, default, prerequisite and effect on users. New projects include it as `docs/security-configuration.md`, linked from their README.
|
|
216
|
-
|
|
217
|
-
### Feedback and offline analysis
|
|
100
|
+
```sh
|
|
101
|
+
hai feedback evidence feedback.zip --request-id request-42 --page 1 --page-size 20
|
|
102
|
+
hai feedback view feedback.zip
|
|
103
|
+
hai upgrade TARGET_VERSION
|
|
104
|
+
```
|
|
218
105
|
|
|
219
|
-
|
|
106
|
+
Bundles must be regular single-link files up to64MiB. View listens on loopback with a random path and uses the framework viewer instead of executing bundled replacement scripts. Filtered results are not proof of complete evidence.
|
|
220
107
|
|
|
221
|
-
|
|
108
|
+
Upgrade checks actual consumer artifacts, CLI/deploy, catalog/lock/installation and skill customization; it does not execute migrations. Deploy-secrets requires Node on the Linux server and a private regular single-link JSON file up to64KiB. Import neither restores database data nor establishes a successful release baseline. See [credential requirements](../deploy/docs/credential-import.en.md).
|
|
222
109
|
|
|
223
|
-
|
|
110
|
+
### AI guidance and application experience
|
|
224
111
|
|
|
225
|
-
|
|
112
|
+
Generated applications use AGENTS.md and `.agents/skills/`; Claude/Copilot/OpenCode reference shared rules. Module installation completes applicable skill references while preserving custom files. Use installed public types to confirm contracts. See [template composition](templates/README.md).
|
|
226
113
|
|
|
227
|
-
|
|
114
|
+
Fullstack includes user/role management, audit, feedback, profile, theme and locale UI. Initial passwords are distributed through private environment files or Secrets and are never printed. They create missing accounts without resetting existing users. Native display names come from Core; artifact filenames use project identity.
|
|
228
115
|
|
|
229
|
-
|
|
116
|
+
## Configuration
|
|
230
117
|
|
|
231
|
-
|
|
118
|
+
`hai.json.build.images` selects roles, contexts, Dockerfiles and ports. Build.sources/build.proxy select image/npm sources and proxies; deploy selects delivery targets. Sources are official/cn/custom and proxy modes are inherit/system/custom/none. Command options apply to the current operation. See the [configuration manual](../../docs/usage/configuration/delivery.md).
|
|
232
119
|
|
|
233
|
-
|
|
120
|
+
HAI priority is process > mode-private > global-private > mode-public > base env > YAML. Within a source, child fields override parent JSON; a higher-source parent removes lower-source children. Runtime credentials and SSH settings stay private; builds do not read deployment secrets. Ordinary backend configuration needs restart; topology, proxy, HTTPS or website build paths require deployment/rebuilding. See [runtime configuration](../../docs/usage/configuration/runtime.md).
|
|
234
121
|
|
|
235
|
-
|
|
122
|
+
Contexts must remain trusted and stable. Dependency sources/cache files must be regular single-link files; cache ancestors reject symlinks/junctions. Tracking is limited to16MiB and archives are compared/copied in64KiB chunks. Unchanged files retain mtime; updates replace atomically. Diagnostics identify path, reason and code without echoing manifest contents.
|
|
236
123
|
|
|
237
|
-
|
|
124
|
+
Keep applicable deepmerge/DaisyUI patch files and patchedDependencies registrations in pnpm projects. Installing an npm package does not inherit this workspace's patch configuration. See [patches](../../patches/).
|
|
238
125
|
|
|
239
|
-
|
|
126
|
+
## Error Handling
|
|
240
127
|
|
|
241
|
-
|
|
128
|
+
Failures report a safe cause, path or step and exit nonzero. Failed installation preserves generated files for retry; failed builds do not advance successful latest. Keep secrets out of arguments and logs. Plans, preflight and import receipts have separate scopes. Correct the failing prerequisite and retry that step; inspect facts first for unknown outcomes.
|
|
242
129
|
|
|
243
|
-
|
|
130
|
+
## Development
|
|
244
131
|
|
|
245
|
-
|
|
132
|
+
Use current source from the repository root:
|
|
246
133
|
|
|
247
134
|
```sh
|
|
248
|
-
pnpm --filter @h-ai/cli build
|
|
249
|
-
node packages/cli/dist/index.js create ../my-app
|
|
250
135
|
pnpm --filter @h-ai/cli typecheck
|
|
251
136
|
pnpm --filter @h-ai/cli lint
|
|
137
|
+
pnpm --filter @h-ai/cli build
|
|
138
|
+
node packages/cli/dist/index.js create ../my-app
|
|
252
139
|
pnpm --filter @h-ai/cli test
|
|
253
140
|
pnpm check:skills
|
|
254
141
|
pnpm --filter @h-ai/cli test:scaffold-gates
|
|
255
|
-
pnpm --filter @h-ai/cli test:scaffold-gates --list --json
|
|
256
142
|
pnpm --filter @h-ai/cli test:deploy-gates
|
|
257
143
|
```
|
|
258
144
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
Scaffold gates generate real projects and run install, typecheck, lint, build, tests and browser workflows, including generated HTTP routes, CLI process locale selection and environment file consumption. Use `--generate` or `--i18n` for focused reruns. Deployment gates cover actual resource ownership and dynamic host port isolation, as well as offline bundles, SSH/manual deployment, incremental updates and rollback. Cleanup uses only container IDs and private image tags recorded by the current run. Safe metadata remains in ignored `tmp/validation/module-review/VERIFY-05/`. Produced browser screenshots, traces and reports remain under ignored `tmp/validation/module-review/scaffold-browser/` or `deploy-browser/` by default. Explicit evidence, HTML report and output paths are respected; temporary projects, keys, data and processes are still cleaned up. Native shells and real cloud providers need separate acceptance.
|
|
262
|
-
|
|
263
|
-
Optional Windows installer acceptance requires the Rust `x86_64-pc-windows-msvc` target and MSVC build tools. Set `HAI_CLI_NATIVE_BUILD=1` and run `pnpm --filter @h-ai/cli test:scaffold-gates`; the existing fullstack scenario builds an NSIS installer and checks the application-root version against its filename. `CARGO_BUILD_JOBS=2` limits Rust compilation concurrency. Native UI interactions and device capabilities require separate acceptance.
|
|
264
|
-
|
|
265
|
-
Deployment fixtures inspect pinned public base images and pull only confirmed missing images; HAI_DEPLOY_E2E_MIRROR remains available. Public image caches are never cleanup targets. A successful create records its container ID before asynchronous APT/pip/sshd preparation inside a private PID namespace. Preparation errors, deadlines and cooperative cancellation wait for the local client to close, then remove and verify that exact owned ID; only the nested Podman fixture is privileged. HAI_DEPLOY_E2E_APT_MIRROR accepts a mirror hostname and keeps HTTPS. Ownership tests use run-specific private tags of pinned public images while preserving foreign same-content tags, retag protection, dynamic ports and external sentinels. A lost create acknowledgment without a trusted ID, or a forcibly terminated test process, remains unknown and never authorizes adoption by name or label.
|
|
266
|
-
|
|
267
|
-
`--generate` runs focused route gates: it reuses installed workspace dependencies, generates and builds real SvelteKit, serv API and fullstack backend projects, then accesses their new routes, including transport. It does not replace the full installation and browser matrix.
|
|
268
|
-
|
|
269
|
-
`test:e2e` gives each server explicit isolated backends and an absolute data directory. Server children do not inherit external `HAI_*` / `PUBLIC_*` / `VITE_*` settings or read the user's `.env.local`. Test-only `HAI_E2E=1` preserves ordinary development/production dotenv behavior and shared-backend requirements; transport cases use a fresh trusted SM2 ring and the actual registry. Scaffold browser runs also use an independent TCP counter to verify that external database settings are never contacted. Complete deployment acceptance retains real Redis/S3, incremental updates and rollback for fullstack.
|
|
270
|
-
|
|
271
|
-
Fullstack projects with a browser frontend share one `playwright.config.ts`. `pnpm test:e2e` runs the default suite first, then starts fresh services with a separate data directory for the page-exit and idle-timeout tests.
|
|
272
|
-
|
|
273
|
-
`--i18n` builds the CLI and checks language precedence, help, successful generation and errors in separate processes, alongside Chinese/English/Japanese prompt, validation, cancellation and create/add/init cases.
|
|
145
|
+
Scaffold gates install, compile and run generated project tests/browser flows; deployment gates need Podman/Docker. Focused `--generate` and `--i18n` cover routes and terminal locale. Isolated fixtures do not prove production data or external-provider acceptance. Windows native gates require Rust/MSVC and explicit HAI_CLI_NATIVE_BUILD=1. Real-device interaction needs separate verification.
|
|
274
146
|
|
|
275
147
|
## License
|
|
276
148
|
|