@nimiplatform/app-tools 0.14.0 → 0.16.0-rc.9
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.md +48 -5
- package/bin/nimi-app.mjs +26 -10
- package/lib/app-access-declaration.mjs +3 -0
- package/lib/app-dependency-combinations.mjs +70 -24
- package/lib/app-doctor-update.mjs +92 -36
- package/lib/app-host-support.mjs +6 -0
- package/lib/app-identifiers.mjs +27 -0
- package/lib/app-lifecycle-guidance.mjs +1 -1
- package/lib/app-pack.mjs +14 -36
- package/lib/app-project-lifecycle.mjs +141 -243
- package/lib/app-scaffold-capabilities.mjs +13 -109
- package/lib/app-scaffold-profiles.mjs +81 -115
- package/lib/app-scaffold.mjs +68 -164
- package/lib/app-toolchain-updates.mjs +45 -0
- package/lib/canonical-capability-ids.generated.mjs +2 -0
- package/lib/development-environment.d.mts +10 -0
- package/lib/development-environment.mjs +39 -0
- package/lib/hosted-web-release.mjs +98 -0
- package/lib/index.mjs +40 -1
- package/lib/mobile-development.mjs +19 -0
- package/lib/realm-environments.generated.mjs +5 -0
- package/lib/web-coordination.mjs +59 -0
- package/lib/web-development.d.mts +23 -0
- package/lib/web-development.mjs +118 -0
- package/lib/web-scaffold.mjs +125 -0
- package/package.json +32 -21
- package/scripts/dev-shell.mjs +4 -1
- package/scripts/sync-scaffold-versions.mjs +0 -2
- package/skills/nimi-app-lifecycle/SKILL.md +3 -1
- package/skills/nimi-app-lifecycle/references/acceptance.md +6 -2
- package/skills/nimi-app-lifecycle/references/adapt.md +5 -3
- package/skills/nimi-app-lifecycle/references/audit.md +3 -2
- package/skills/nimi-app-lifecycle/references/create.md +6 -2
- package/skills/nimi-app-lifecycle/references/upgrade-platform.md +12 -7
- package/templates/app-source/src/ai-studio-core/ai-studio-core.css +87 -52
- package/templates/app-source/src/ai-studio-core/history-policy.ts +45 -11
- package/templates/app-source/src/ai-studio-core/history.ts +22 -11
- package/templates/app-source/src/ai-studio-core/host-context.tsx +9 -4
- package/templates/app-source/src/ai-studio-core/index.ts +2 -0
- package/templates/app-source/src/ai-studio-core/job-recovery-panel.tsx +15 -5
- package/templates/app-source/src/ai-studio-core/job-recovery.ts +2 -2
- package/templates/app-source/src/ai-studio-core/messages/en.json +73 -19
- package/templates/app-source/src/ai-studio-core/messages/zh.json +73 -19
- package/templates/app-source/src/ai-studio-core/module-registration.ts +1 -0
- package/templates/app-source/src/ai-studio-core/non-success-presentation.ts +30 -5
- package/templates/app-source/src/ai-studio-core/parameter-fields.tsx +12 -6
- package/templates/app-source/src/ai-studio-core/parameters.ts +4 -0
- package/templates/app-source/src/ai-studio-core/prompt-drafts.ts +42 -0
- package/templates/app-source/src/ai-studio-core/runtime-types.ts +9 -2
- package/templates/app-source/src/ai-studio-core/runtime.ts +8 -4
- package/templates/app-source/src/ai-studio-core/section-ai-testing-composer.tsx +98 -90
- package/templates/app-source/src/ai-studio-core/section-ai-testing-exchange-result.tsx +1 -1
- package/templates/app-source/src/ai-studio-core/section-ai-testing-history.tsx +205 -48
- package/templates/app-source/src/ai-studio-core/section-ai-testing-input.ts +1 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-output.tsx +36 -14
- package/templates/app-source/src/ai-studio-core/section-ai-testing-result.tsx +96 -75
- package/templates/app-source/src/ai-studio-core/section-ai-testing-run.ts +59 -16
- package/templates/app-source/src/ai-studio-core/section-ai-testing-session-result.tsx +2 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-studio-result.tsx +12 -21
- package/templates/app-source/src/ai-studio-core/section-ai-testing-transcription-result.tsx +2 -2
- package/templates/app-source/src/ai-studio-core/section-ai-testing-vision-result.tsx +3 -3
- package/templates/app-source/src/ai-studio-core/section-ai-testing.tsx +158 -76
- package/templates/app-source/src/ai-studio-core/workspace.tsx +49 -22
- package/templates/app-source/src/product-modules/agent-center/index.tsx +2 -3
- package/templates/app-source/src/product-modules/agent-conversation/index.tsx +2 -3
- package/templates/app-source/src/studio-modules/studio-create/messages/en.json +12 -3
- package/templates/app-source/src/studio-modules/studio-create/messages/zh.json +12 -3
- package/templates/app-source/src/studio-modules/studio-create/parameter-panel.tsx +11 -2
- package/templates/app-source/src/studio-modules/studio-create/parameters.ts +2 -1
- package/templates/app-source/src/studio-modules/studio-create/runtime.ts +47 -5
- package/templates/app-source/src/studio-modules/studio-media/messages/en.json +59 -8
- package/templates/app-source/src/studio-modules/studio-media/messages/zh.json +59 -8
- package/templates/app-source/src/studio-modules/studio-media/music-parameters.tsx +2 -1
- package/templates/app-source/src/studio-modules/studio-media/parameter-panel.tsx +271 -83
- package/templates/app-source/src/studio-modules/studio-media/parameters.ts +120 -2
- package/templates/app-source/src/studio-modules/studio-media/registration.ts +1 -0
- package/templates/app-source/src/studio-modules/studio-media/runtime.ts +24 -14
- package/templates/app-source/src/studio-modules/studio-voice/descriptors.ts +1 -1
- package/templates/app-source/src/studio-modules/studio-voice/messages/en.json +3 -2
- package/templates/app-source/src/studio-modules/studio-voice/messages/zh.json +3 -2
- package/templates/app-source/src/studio-modules/studio-voice/parameter-panel.tsx +46 -23
- package/templates/app-source/src/studio-modules/studio-voice/registration.ts +2 -1
- package/templates/app-source/src/studio-modules/studio-voice/runtime.ts +2 -2
- package/templates/app-source/src/workbench-core/workbench-core.tsx +27 -3
- package/templates/default-starter/AGENTS.md +3 -3
- package/templates/default-starter/README.md +1 -1
- package/templates/default-starter/src/shell/App.tsx +6 -18
- package/templates/default-starter/src/shell/auth/local-app-client.ts +6 -15
- package/templates/default-starter/src/shell/auth/runtime-platform.ts +7 -107
- package/templates/default-starter/src/shell/workbench-target-adapter.ts +9 -126
- package/templates/default-starter.manifest.json +0 -16
- package/templates/hosted-web-release.yml +88 -0
- package/templates/default-starter/src-tauri/Cargo.toml +0 -17
- package/templates/default-starter/src-tauri/build.rs +0 -32
- package/templates/default-starter/src-tauri/capabilities/default.json +0 -7
- package/templates/default-starter/src-tauri/tauri.conf.json +0 -26
package/README.md
CHANGED
|
@@ -48,6 +48,7 @@ pnpm install
|
|
|
48
48
|
pnpm run init
|
|
49
49
|
pnpm run sync
|
|
50
50
|
pnpm run check
|
|
51
|
+
# Open a matching Nimi Home, sign in and enable Developer Mode.
|
|
51
52
|
pnpm dev
|
|
52
53
|
```
|
|
53
54
|
|
|
@@ -61,20 +62,30 @@ Set `--author` to the person or team responsible for the App and its license.
|
|
|
61
62
|
|
|
62
63
|
### Dependencies & Existing Projects
|
|
63
64
|
|
|
64
|
-
|
|
65
|
+
The supported native App host is Electron on Windows x64 and macOS arm64. Standard projects need Node, pnpm, prebuilt Kit bindings and a ready Nimi Home and Runtime. Apps own any additional Rust toolchain. Existing Tauri projects can use their original tools or explicitly migrate to Electron. Use published packages, or override them for local development with the complete archives described below—never point dependencies at a Nimi source checkout.
|
|
65
66
|
|
|
66
|
-
- **SDK and Kit Version Alignment**: Keep the SDK/Kit
|
|
67
|
-
- **
|
|
67
|
+
- **SDK and Kit Version Alignment**: Keep the SDK/Kit combination in the selected package's `nimiScaffoldVersions` and lockfile (`sync` preserves supported ranges and exact pins, and rejects an unlisted pairing). Source manifests may select numbered RC packages; a candidate version does not claim public availability. Use Kit's matching optional native package and the Runtime contract named by that combination's migration notes.
|
|
68
|
+
- **Tool and security updates**: The CLI accepts compatible patches within a bounded project range. Preview dependency changes with `pnpm exec nimi-app sync --dry-run --json`. Sync raises compatible direct Vite and Electron security floors. Select a patched version explicitly when your pin excludes the fix. After sync run `pnpm install`, `pnpm exec nimi-app check` and `pnpm audit`, then commit the updated App lockfile. An installed App follows its package and Runtime contracts independently of the authoring CLI.
|
|
69
|
+
- **Testing Local Tarballs**: During local development, select complete `.tgz` archives via `pnpm-workspace.yaml` overrides, including Kit's matching optional native package. A package version identifies fixed content: increment the candidate version for a content change, then update declarations, overrides and the lockfile with `pnpm install`. Do not overwrite an archive with different content under the same version. Record the selected native trust profile in the existing delivery notes. For local acceptance, run ordinary `check` and `build`, followed by `pack --production` when inspecting a native payload (`check --production` requires dependencies resolved from the public registry). Builds do not replace real login, source confirmation, direct connection, AI/data and recovery acceptance.
|
|
68
70
|
- **Adopting or Upgrading Projects**: Follow the [adoption guide](skills/nimi-app-lifecycle/SKILL.md) and [platform upgrade reference](skills/nimi-app-lifecycle/references/upgrade-platform.md). Preview managed changes before applying them with `init --adopt --dry-run --json` or `sync --dry-run --json`. Adoption preserves your App-owned product and Host code rather than converting an application framework; migrating from an older scaffold contract requires following the documented migration steps, not just bumping dependency versions.
|
|
69
71
|
|
|
70
72
|
---
|
|
71
73
|
|
|
72
74
|
## 3. Desktop-Supervised Development
|
|
73
75
|
|
|
76
|
+
For ordinary native App work, use a matching **installed Nimi and official Realm**. Sign in, enable Developer Mode, and run `pnpm dev` in your App repository. This works with public packages and an official account. If a compatible source Home is already running against a Realm suitable for your task, use that Home and the same App command.
|
|
77
|
+
|
|
78
|
+
When changing Runtime, SDK or Kit, source Nimi defaults to official Realm. Choose `--realm local` on the source Home launcher for Realm integration or controlled data. Native `nimi-app dev` discovers the active Home and inherits its target. From a Nimi checkout, `pnpm doctor:dev -- --host source --realm official` compares the requested and observed Runtime. Coordinate with other developers before switching a shared host. The switch ends live App sessions. Compatible versions can use the same model and engine files in sequence. See the [local development guide](https://github.com/nimiplatform/nimi/blob/main/LOCAL_DEVELOPMENT.md).
|
|
79
|
+
|
|
74
80
|
Nimi Apps run inside a Desktop-supervised Electron shell. The host provides a protected session for SDK calls without exposing Nimi credentials to the App renderer (note that this session bridge does not create an OS-level sandbox for the entire application).
|
|
75
81
|
|
|
76
|
-
|
|
77
|
-
|
|
82
|
+
<a id="continuing-an-existing-session"></a>
|
|
83
|
+
|
|
84
|
+
### Reopening a Development Registration
|
|
85
|
+
|
|
86
|
+
After a restart, list registrations on the current host and resume the one that owns your App data. Use the selector from the current list. The new launch establishes a fresh protected session.
|
|
87
|
+
|
|
88
|
+
If you need the App terminal to confirm a planned stop, press `Ctrl+C` there and wait for `stopped` before quitting Home. Closing Home first can disconnect the terminal before it receives the final status.
|
|
78
89
|
|
|
79
90
|
```bash
|
|
80
91
|
# List active registrations
|
|
@@ -242,3 +253,35 @@ During release, the managed GitHub Actions workflow uploads this sidecar to the
|
|
|
242
253
|
## License
|
|
243
254
|
|
|
244
255
|
Licensed under [Apache-2.0](../licenses/Apache-2.0.txt).
|
|
256
|
+
|
|
257
|
+
## Web development (current source build)
|
|
258
|
+
|
|
259
|
+
The same CLI supports `create --platform web`, Web `init/sync/check/test/build`, existing-site `init --adopt`, and `dev --platform web`. `standalone` is still the repository topology. Web `--features all` currently resolves to `studio-create` (text, streaming chat and embeddings); other feature selections fail explicitly until their Web carrier is admitted. Mobile generation remains outside this command. For managed Web hosting, build a static release with the App's public slug and prepare it for separate human Registry admission.
|
|
260
|
+
|
|
261
|
+
Use matching complete SDK, Kit and App Tools source archives until the new entries are published; a published package with the same numeric version may not contain this source iteration. No source-directory dependency links are required.
|
|
262
|
+
|
|
263
|
+
The current workbench uses account-owned prompt drafts with an asynchronous `promptDraft` projection and independent history record documents. For existing unreleased generated prototypes, update the App-owned AI Studio capability source together with the generated host adapters. `sync` intentionally preserves `src/capabilities` and does not migrate or overwrite that business source; running `check` alone is not a substitute for the project's typecheck/build after this source update.
|
|
264
|
+
|
|
265
|
+
The generated `nimi.app.yaml` has `platform: web`. Its `local_development.web` uses official Realm and leaves `origin`, `redirect_uri` and `client_id` empty until you configure the exact source registered through the public Registry. Configure them before init/check/dev. Choose an HTTPS origin dedicated to this App; a generated port hash or different client id cannot isolate scripts on the same browser origin. Put browser-trusted `NIMI_WEB_TLS_KEY` and `NIMI_WEB_TLS_CERT` file paths in `.env.local`. Source review and first PC Home confirmation remain required and do not require a native package release. The CLI does not approve the source.
|
|
266
|
+
|
|
267
|
+
For local Realm integration, add `local_development.web.local` with that environment's exact source fields and use `nimi-app dev --platform web --realm local`. The App-owned `command` stays on `web`; source fields survive sync. Default official values come from the package's public Realm profile. A local profile is explicit and never a fallback from an unavailable official service.
|
|
268
|
+
|
|
269
|
+
`@nimiplatform/app-tools/web` exports the Node-only `nimiWebViteConfig` helper. Its development proxy only forwards scoped identity and SDP coordination routes and strips official cookies. AI, files, audio and results use the browser-to-PC connection. Built static files need a separately configured production origin and bounded coordination route; the Vite dev server is not production hosting.
|
|
270
|
+
|
|
271
|
+
For a Nimi-hosted release declare `public_slug` in `nimi.app.yaml`, use the existing Web production build, and set `NIMI_WEB_VERSION` to the protected Web release version. App Tools generates the exact `https://<slug>.nimi.xyz` origin, root callback, public client identity, official account URL and Realm environment together with `nimi-web-bundle.json`. It places compiled assets under `/_releases/<version>/assets/`. Run `nimi-app sync` to install the managed `.github/workflows/nimi-web-release.yml`. The protected `web-v*` workflow uses `build:web:release` or `build:release` and sets `NIMI_WEB_ARCHIVE` so the same build writes the immutable candidate ZIP. Publish the static directory as a stored ZIP using `packHostedWeb(directory, outputFile)` from `@nimiplatform/app-tools/web/release`. App-authored Pages control files are excluded. Executable public assets should be imported into the build or explicitly referenced under their release path.
|
|
272
|
+
|
|
273
|
+
For an independently registered release build, use `pnpm build:release` in a generated Web App or pass `release: true` to `nimiWebViteConfig` from the App's build config. Set `NIMI_WEB_ORIGIN`, `NIMI_WEB_REDIRECT_URI`, `NIMI_WEB_CLIENT_ID`, `NIMI_WEB_REALM_ENVIRONMENT_ID`, and `NIMI_WEB_OFFICIAL_WEB_URL` to the deployment values. The build uses the App ID from `nimi.app.yaml` and the release inputs for its source and login. Serve the coordination allowlist defined by `isWebCoordinationPath` on that App origin, forwarding it to the matching Realm without cookies. Source admission and cookie isolation are deployment requirements.
|
|
274
|
+
|
|
275
|
+
A Desktop project can also declare an App-owned `local_development.web` entry and use `dev --platform web`. Init/sync preserve it and check validates both entries. This does not change the project's managed platform, native feature selection or build profile: its Web renderer, tests and build remain App-owned. Update retained capability modules alongside the selected tool package when their generated Host interface changes; sync deliberately preserves those App-owned files.
|
|
276
|
+
|
|
277
|
+
For an existing website, keep its product entry and actual commands. Use a `web-pnpm` build profile with the real `test_command` / `build_command`, and a `web` target describing the browser output directory and `payload/index.html` entry. The identity-free configuration does not replace a site's own account system. SDK current-user context must follow its verified account session; never use an operator account or a front-end asserted Nimi account ID as another user's identity.
|
|
278
|
+
|
|
279
|
+
Native-only guidance such as Electron installation, native signatures and `pack --production` above does not apply to the Web carrier. The initial generated test command typechecks the project; App business tests and real task acceptance belong to the application iteration.
|
|
280
|
+
|
|
281
|
+
The current Web bootstrap uses Kit `auth/app/web` plus its shared Provider, account control and access gate. The old `core/remote-app-session` entry was removed in this unreleased hard cut. Existing App-owned Web entries must be updated explicitly with their selected SDK/Kit source package combination; sync does not take ownership of the application entry. Generated business callbacks retain their captured client; identity-only views use their own identity lifetime rather than a Runtime connection key.
|
|
282
|
+
|
|
283
|
+
### Existing mobile development entry
|
|
284
|
+
|
|
285
|
+
An existing App can add `local_development.mobile.command: pnpm run dev:android` to `nimi.app.yaml`, define that real App-owned script in `package.json`, and select it with `nimi-app dev --platform mobile`. Desktop shell, registration selectors and Desktop CDP flags do not apply. App Tools delegates the native command; it does not create a local Home session or native source qualification. The additional command survives supported init/sync updates as App-owned configuration.
|
|
286
|
+
|
|
287
|
+
The initial reference is Zhiyu's Android Capacitor container using Kit `auth/app/mobile`. Ordinary debug development uses official Realm with a registered Android App Link, the actual debug package/signature and verified HTTPS association; it does not require a release APK. Its project and Android build/device tools remain prerequisites. `--realm local` explicitly enables the existing non-production `android-dev-scheme` path where the local source is admitted. Source admission and Home consent stay with their owners. This entry does not add mobile scaffolding, APK publication or store release. A child process exiting successfully is not Runtime acceptance. Node build configuration may consume `@nimiplatform/app-tools/development` to resolve the same selected Realm.
|
package/bin/nimi-app.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
packApp,
|
|
11
11
|
resolveAppCreateInput,
|
|
12
12
|
resolveAppCreatePlan,
|
|
13
|
-
|
|
13
|
+
runAppDevelopment,
|
|
14
14
|
syncApp,
|
|
15
15
|
testApp,
|
|
16
16
|
} from '../lib/index.mjs';
|
|
@@ -21,9 +21,9 @@ import { createInterface } from 'node:readline/promises';
|
|
|
21
21
|
function parseArgs(argv) {
|
|
22
22
|
const [command = '', ...rest] = argv;
|
|
23
23
|
const values = {
|
|
24
|
-
dir: '', profile: '', appId: '', version: '', title: '', packageName: '', author: '',
|
|
24
|
+
dir: '', profile: '', platform: '', appId: '', version: '', title: '', packageName: '', author: '',
|
|
25
25
|
features: undefined, shell: '', cdpPort: undefined, noCdp: false, listRegistrations: false, resume: '', newRegistration: false, target: '', aggregate: false, production: false, json: false,
|
|
26
|
-
adopt: false, dryRun: false, input: '',
|
|
26
|
+
adopt: false, dryRun: false, input: '', realm: '',
|
|
27
27
|
};
|
|
28
28
|
const seen = new Set();
|
|
29
29
|
const readValue = (index, flag, key, preserve = false) => {
|
|
@@ -39,6 +39,11 @@ function parseArgs(argv) {
|
|
|
39
39
|
return index + 1;
|
|
40
40
|
};
|
|
41
41
|
for (let index = 0; index < rest.length; index += 1) {
|
|
42
|
+
if (rest[index] === '--realm') {
|
|
43
|
+
if (command !== 'dev') throw new Error(`${rest[index]} is available only for dev.`);
|
|
44
|
+
index = readValue(index, rest[index], rest[index].slice(2));
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
42
47
|
if (rest[index] === '--input') {
|
|
43
48
|
index = readValue(index, '--input', 'input');
|
|
44
49
|
continue;
|
|
@@ -81,6 +86,10 @@ function parseArgs(argv) {
|
|
|
81
86
|
index = readValue(index, '--author', 'author', true);
|
|
82
87
|
continue;
|
|
83
88
|
}
|
|
89
|
+
if (rest[index] === '--platform') {
|
|
90
|
+
index = readValue(index, '--platform', 'platform');
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
84
93
|
if (rest[index] === '--features') {
|
|
85
94
|
index = readValue(index, '--features', 'features');
|
|
86
95
|
continue;
|
|
@@ -148,11 +157,11 @@ function parseArgs(argv) {
|
|
|
148
157
|
|
|
149
158
|
function assertCommandOptions(command, providedOptions) {
|
|
150
159
|
const allowed = {
|
|
151
|
-
create: new Set(['dir', 'profile', 'appId', 'version', 'title', 'packageName', 'author', 'features', 'json']),
|
|
160
|
+
create: new Set(['dir', 'profile', 'platform', 'appId', 'version', 'title', 'packageName', 'author', 'features', 'json']),
|
|
152
161
|
init: new Set(['dir', 'json', 'adopt', 'input', 'dryRun']),
|
|
153
162
|
sync: new Set(['dir', 'json', 'dryRun']),
|
|
154
163
|
check: new Set(['dir', 'json', 'production']),
|
|
155
|
-
dev: new Set(['dir', 'shell', 'cdpPort', 'noCdp', 'listRegistrations', 'resume', 'newRegistration']),
|
|
164
|
+
dev: new Set(['dir', 'platform', 'shell', 'realm', 'cdpPort', 'noCdp', 'listRegistrations', 'resume', 'newRegistration']),
|
|
156
165
|
test: new Set(['dir', 'json']),
|
|
157
166
|
build: new Set(['dir', 'target', 'production', 'json']),
|
|
158
167
|
pack: new Set(['dir', 'target', 'aggregate', 'production', 'json']),
|
|
@@ -179,11 +188,11 @@ function printUsage() {
|
|
|
179
188
|
'Nimi App developer tools',
|
|
180
189
|
'',
|
|
181
190
|
'Usage:',
|
|
182
|
-
' nimi-app create [--dir path] [--profile standalone] [--features admitted-ids|all] [--app-id dotted.id] [--version semver] [--title title] [--package-name name] [--author person-or-team] [--json]',
|
|
191
|
+
' nimi-app create [--dir path] [--profile standalone] [--platform desktop|web] [--features admitted-ids|all] [--app-id dotted.id] [--version semver] [--title title] [--package-name name] [--author person-or-team] [--json]',
|
|
183
192
|
' nimi-app init [--adopt [--input json-path]] [--dry-run] [--dir path] [--json]',
|
|
184
193
|
' nimi-app sync [--dry-run] [--dir path] [--json]',
|
|
185
194
|
' nimi-app check [--dir path] [--production] [--json]',
|
|
186
|
-
' nimi-app dev [--dir path] [--shell electron] [--list-registrations | --resume <selector> | --new-registration] [--cdp-port 1024..65535 | --no-cdp]',
|
|
195
|
+
' nimi-app dev [--dir path] [--platform desktop|web|mobile] [--realm official|local (web/mobile)] [--shell electron] [--list-registrations | --resume <selector> | --new-registration] [--cdp-port 1024..65535 | --no-cdp]',
|
|
187
196
|
' nimi-app test [--dir path] [--json]',
|
|
188
197
|
' nimi-app build [--dir path] [--target target-id] [--production] [--json]',
|
|
189
198
|
' nimi-app pack [--dir path] (--target target-id [--production] | --aggregate) [--json]',
|
|
@@ -197,6 +206,7 @@ function printUsage() {
|
|
|
197
206
|
'',
|
|
198
207
|
'Current module registry:',
|
|
199
208
|
` Admitted features: ${featureList(admitted)}`,
|
|
209
|
+
` Web features: ${featureList(admitted.filter(entry => entry.carriers.includes('web')))}`,
|
|
200
210
|
` Candidate features (not public-selectable): ${featureList(candidates)}`,
|
|
201
211
|
` Internal modules (dependency-only): ${internalList}`,
|
|
202
212
|
admitted.length > 0
|
|
@@ -210,6 +220,7 @@ function printUsage() {
|
|
|
210
220
|
' AI features resolve the internal ai-studio-core once; it cannot be selected directly.',
|
|
211
221
|
' Generated Apps exclude Lab-only Settings/account, App Access diagnostics, Realm/Agent probes, World Tour, and native/diagnostic surfaces.',
|
|
212
222
|
'',
|
|
223
|
+
'Native desktop support: Electron on Windows x64 and macOS arm64. Standard builds use Node and pnpm with prebuilt Kit bindings.',
|
|
213
224
|
'Third-party topology:',
|
|
214
225
|
' standalone: any empty target directory using public dependency version declarations.',
|
|
215
226
|
' Development may resolve complete local npm tarballs through documented overrides; no additional create mode is needed.',
|
|
@@ -224,7 +235,7 @@ function printUsage() {
|
|
|
224
235
|
' create -> dependency install -> init -> sync -> check -> dev/test/build -> pack',
|
|
225
236
|
' Run init and later commands only after dependency installation.',
|
|
226
237
|
` Before init, read the packaged lifecycle skill: ${LIFECYCLE_SKILL_PATH}`,
|
|
227
|
-
' Existing adoption requires pnpm
|
|
238
|
+
' Existing adoption requires pnpm and real App-owned dev/build/test inputs: use a supervised Electron Host for Desktop, or the Web carrier and an admitted HTTPS source.',
|
|
228
239
|
' Use electron-pnpm for an existing renderer framework; no fresh scaffold lock is created.',
|
|
229
240
|
'',
|
|
230
241
|
'Development CDP:',
|
|
@@ -311,12 +322,14 @@ try {
|
|
|
311
322
|
command,
|
|
312
323
|
dir,
|
|
313
324
|
profile,
|
|
325
|
+
platform,
|
|
314
326
|
appId,
|
|
315
327
|
version,
|
|
316
328
|
title,
|
|
317
329
|
packageName,
|
|
318
330
|
author,
|
|
319
331
|
features: parsedFeatures,
|
|
332
|
+
realm,
|
|
320
333
|
shell,
|
|
321
334
|
cdpPort,
|
|
322
335
|
noCdp,
|
|
@@ -351,6 +364,7 @@ try {
|
|
|
351
364
|
const rawInput = {
|
|
352
365
|
dir,
|
|
353
366
|
profile,
|
|
367
|
+
platform,
|
|
354
368
|
appId,
|
|
355
369
|
version,
|
|
356
370
|
title,
|
|
@@ -419,9 +433,11 @@ try {
|
|
|
419
433
|
}
|
|
420
434
|
break;
|
|
421
435
|
case 'dev':
|
|
422
|
-
await
|
|
436
|
+
await runAppDevelopment(process.cwd(), {
|
|
437
|
+
realm,
|
|
423
438
|
dir,
|
|
424
|
-
shell
|
|
439
|
+
shell,
|
|
440
|
+
platform,
|
|
425
441
|
cdpPort,
|
|
426
442
|
noCdp,
|
|
427
443
|
listRegistrations,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-scaf-018c
|
|
2
|
+
import { gt, intersects, minVersion, satisfies, subset, valid, validRange } from 'semver';
|
|
2
3
|
|
|
3
4
|
// The manifest names the tested candidate/default combination. Explicitly selected
|
|
4
5
|
// development pairs use the same current Host, never an older template.
|
|
@@ -9,28 +10,45 @@ const SDK = '@nimiplatform/sdk';
|
|
|
9
10
|
const KIT = '@nimiplatform/kit';
|
|
10
11
|
|
|
11
12
|
export const ADDITIONAL_DEPENDENCY_COMBINATIONS = Object.freeze([
|
|
12
|
-
Object.freeze({ sdkVersion: '^0.
|
|
13
|
-
Object.freeze({ sdkVersion: '^0.
|
|
14
|
-
Object.freeze({ sdkVersion: '^0.22.
|
|
15
|
-
Object.freeze({ sdkVersion: '^0.
|
|
16
|
-
Object.freeze({ sdkVersion: '^0.
|
|
17
|
-
Object.freeze({ sdkVersion: '^0.
|
|
18
|
-
Object.freeze({ sdkVersion: '^0.21.0', kitVersion: '^0.
|
|
19
|
-
Object.freeze({ sdkVersion: '^0.21.0', kitVersion: '^0.
|
|
20
|
-
Object.freeze({ sdkVersion: '^0.
|
|
21
|
-
Object.freeze({ sdkVersion: '^0.
|
|
22
|
-
Object.freeze({ sdkVersion: '^0.
|
|
13
|
+
Object.freeze({ sdkVersion: '^0.24.0-rc.7', kitVersion: '^0.24.0-rc.11', source: 'existing' }),
|
|
14
|
+
Object.freeze({ sdkVersion: '^0.24.0-rc.2', kitVersion: '^0.24.0-rc.1', source: 'existing' }),
|
|
15
|
+
Object.freeze({ sdkVersion: '^0.22.2', kitVersion: '^0.22.1', source: 'existing' }),
|
|
16
|
+
Object.freeze({ sdkVersion: '^0.22.1', kitVersion: '^0.22.1', source: 'existing' }),
|
|
17
|
+
Object.freeze({ sdkVersion: '^0.22.1', kitVersion: '^0.22.0', source: 'existing' }),
|
|
18
|
+
Object.freeze({ sdkVersion: '^0.22.0', kitVersion: '^0.22.0', source: 'existing' }),
|
|
19
|
+
Object.freeze({ sdkVersion: '^0.21.0', kitVersion: '^0.21.0', source: 'existing' }),
|
|
20
|
+
Object.freeze({ sdkVersion: '^0.21.0', kitVersion: '^0.20.0', source: 'existing' }),
|
|
21
|
+
Object.freeze({ sdkVersion: '^0.21.0', kitVersion: '^0.19.0', source: 'existing' }),
|
|
22
|
+
Object.freeze({ sdkVersion: '^0.21.0', kitVersion: '^0.18.1', source: 'existing' }),
|
|
23
|
+
Object.freeze({ sdkVersion: '^0.21.0', kitVersion: '^0.18.0', source: 'existing' }),
|
|
24
|
+
Object.freeze({ sdkVersion: '^0.20.0', kitVersion: '^0.17.0', source: 'existing' }),
|
|
25
|
+
Object.freeze({ sdkVersion: '^0.18.1', kitVersion: '^0.15.3', source: 'existing' }),
|
|
26
|
+
Object.freeze({ sdkVersion: '^0.19.0', kitVersion: '^0.16.0', source: 'existing' }),
|
|
23
27
|
]);
|
|
24
28
|
|
|
25
|
-
function
|
|
26
|
-
|
|
29
|
+
export function isLocalDependencySpec(value) {
|
|
30
|
+
const normalized = typeof value === 'string' ? value.trim() : '';
|
|
31
|
+
return /^(?:file|link|patch|path|portal|workspace):/iu.test(normalized)
|
|
32
|
+
|| /^(?:\.{1,2}[\\/]|~[\\/]|[A-Za-z]:[\\/]|\\\\)/u.test(normalized)
|
|
33
|
+
|| /\.(?:tar\.gz|tgz)(?:[?#].*)?$/iu.test(normalized);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// The released CLI may be a later patch selected by the project's bounded range.
|
|
37
|
+
export function appToolsDeclaration(declared, toolRange) {
|
|
38
|
+
if (declared === toolRange) return declared;
|
|
39
|
+
const minimum = typeof declared === 'string' && validRange(declared) && minVersion(declared);
|
|
40
|
+
const running = minVersion(toolRange);
|
|
41
|
+
if (minimum && running && gt(minimum, running)) {
|
|
42
|
+
throw new Error(`This App requires app-tools ${declared}. Install the selected tool before running init, sync or check.`);
|
|
43
|
+
}
|
|
44
|
+
return minimum && running && (valid(declared) || subset(declared, '^' + minimum.version)) && satisfies(running, declared)
|
|
45
|
+
? declared : toolRange;
|
|
27
46
|
}
|
|
28
47
|
|
|
29
48
|
export function defaultDependencyCombination(versions) {
|
|
30
49
|
return Object.freeze({
|
|
31
50
|
sdkVersion: versions.sdkVersion,
|
|
32
51
|
kitVersion: versions.kitVersion,
|
|
33
|
-
nimiShellTauriVersion: versions.nimiShellTauriVersion,
|
|
34
52
|
source: 'default',
|
|
35
53
|
});
|
|
36
54
|
}
|
|
@@ -39,18 +57,46 @@ function describe(combination) {
|
|
|
39
57
|
return `${SDK}@${combination.sdkVersion} with ${KIT}@${combination.kitVersion}`;
|
|
40
58
|
}
|
|
41
59
|
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
60
|
+
// semver's range intersection can reject a prerelease pin that satisfies the range.
|
|
61
|
+
function selectionsOverlap(recorded, selected) {
|
|
62
|
+
const selectedPin = valid(validRange(selected));
|
|
63
|
+
if (selectedPin) return satisfies(selectedPin, recorded);
|
|
64
|
+
const recordedPin = valid(validRange(recorded));
|
|
65
|
+
if (recordedPin) return satisfies(recordedPin, selected);
|
|
66
|
+
return intersects(recorded, selected);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export function matchesRecordedHostDependencies(npm, combination) {
|
|
70
|
+
return selectionsOverlap(npm[SDK], combination.sdkVersion)
|
|
71
|
+
&& selectionsOverlap(npm[KIT], combination.kitVersion);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Some verified pairs share a minor line. Match each
|
|
75
|
+
// declaration to its most specific admitted floor, then validate the pair.
|
|
76
|
+
function matchingLine(spec, lines) {
|
|
77
|
+
const range = typeof spec === 'string' && validRange(spec);
|
|
78
|
+
if (!range || !minVersion(range)) return undefined;
|
|
79
|
+
const pin = valid(range);
|
|
80
|
+
let best;
|
|
81
|
+
for (const line of new Set(lines)) {
|
|
82
|
+
const admitted = pin ? satisfies(pin, line) : subset(range, line);
|
|
83
|
+
if (admitted && (!best || gt(minVersion(line), minVersion(best)))) best = line;
|
|
84
|
+
}
|
|
85
|
+
return best;
|
|
86
|
+
}
|
|
87
|
+
|
|
46
88
|
export function resolveDependencyCombination(packageJson, versions) {
|
|
47
89
|
const fallback = defaultDependencyCombination(versions);
|
|
48
90
|
const section = packageJson?.dependencies;
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
|
|
91
|
+
const declaredSdk = section?.[SDK];
|
|
92
|
+
const declaredKit = section?.[KIT];
|
|
93
|
+
const sdk = declaredSdk === undefined || isLocalDependencySpec(declaredSdk) ? fallback.sdkVersion : declaredSdk;
|
|
94
|
+
const kit = declaredKit === undefined || isLocalDependencySpec(declaredKit) ? fallback.kitVersion : declaredKit;
|
|
52
95
|
if (sdk === fallback.sdkVersion && kit === fallback.kitVersion) return fallback;
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
96
|
+
const pairs = [fallback, ...ADDITIONAL_DEPENDENCY_COMBINATIONS];
|
|
97
|
+
const sdkLine = matchingLine(sdk, pairs.map(pair => pair.sdkVersion));
|
|
98
|
+
const kitLine = matchingLine(kit, pairs.map(pair => pair.kitVersion));
|
|
99
|
+
const selected = pairs.find(pair => pair.sdkVersion === sdkLine && pair.kitVersion === kitLine);
|
|
100
|
+
if (selected) return { ...selected, sdkVersion: sdk, kitVersion: kit };
|
|
101
|
+
throw new Error(`Unsupported SDK/Kit combination: ${describe({ sdkVersion: sdk, kitVersion: kit })}. Select a verified pair explicitly before sync. Tool default: ${describe(fallback)}.`);
|
|
56
102
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
import { isAppId } from './app-identifiers.mjs';
|
|
2
|
+
import { readWebDevelopment } from './web-development.mjs';
|
|
3
|
+
import { readMobileDevelopment } from './mobile-development.mjs';
|
|
1
4
|
import { APP_AUTHOR_DECLARATION_FIELDS, hashScaffoldManagedContent } from './app-scaffold.mjs';
|
|
2
5
|
import { readAppIntroduction } from './app-info.mjs';
|
|
3
6
|
import { existsSync, readdirSync, readFileSync, realpathSync, statSync } from 'node:fs';
|
|
4
7
|
import path from 'node:path';
|
|
8
|
+
import { minVersion } from 'semver';
|
|
5
9
|
import { parse as parseYaml, stringify as stringifyYaml } from 'yaml';
|
|
6
10
|
import {
|
|
7
11
|
buildAppScaffoldSnapshotFromIntent,
|
|
@@ -16,8 +20,8 @@ import {
|
|
|
16
20
|
} from './app-scaffold.mjs';
|
|
17
21
|
import { assertManifestAppAccessDeclaration } from './app-access-declaration.mjs';
|
|
18
22
|
import { assertLifecycleGuidanceCurrent, LIFECYCLE_SKILL_PATH, lifecycleOwnerSteps, planLifecycleGuidance } from './app-lifecycle-guidance.mjs';
|
|
19
|
-
import { applyProjectFiles, describeChanges, plannedFile } from './app-project-files.mjs';
|
|
20
|
-
import { resolveDependencyCombination } from './app-dependency-combinations.mjs';
|
|
23
|
+
import { applyProjectFiles, assertProjectOutputPath, describeChanges, plannedFile } from './app-project-files.mjs';
|
|
24
|
+
import { appToolsDeclaration, matchesRecordedHostDependencies, resolveDependencyCombination } from './app-dependency-combinations.mjs';
|
|
21
25
|
|
|
22
26
|
const SCAN_EXCLUDED_DIRS = new Set([
|
|
23
27
|
'.git',
|
|
@@ -207,9 +211,39 @@ function expectedSnapshotFromLock(lock, versions, intent, targetDir, options = {
|
|
|
207
211
|
if (stableStringify(intent.directFeatures) !== stableStringify(lock.directFeatures)) {
|
|
208
212
|
throw new Error('Scaffold feature selection is immutable; create a fresh scaffold for a different feature closure');
|
|
209
213
|
}
|
|
214
|
+
if (versions.source === 'existing') retainMatchingHostFiles(targetDir, lock, snapshot, versions);
|
|
210
215
|
return snapshot;
|
|
211
216
|
}
|
|
212
217
|
|
|
218
|
+
// A maintained SDK/Kit pair can predate APIs imported by today's generated
|
|
219
|
+
// renderer and Host. Its checked-in wiring also binds the App-owned feature
|
|
220
|
+
// modules. Carry it forward only with the original paths, class and digest.
|
|
221
|
+
function retainMatchingHostFiles(targetDir, lock, snapshot, versions) {
|
|
222
|
+
const matrix = lock.dependencyMatrix;
|
|
223
|
+
const migration = 'Migrate the App-owned feature modules and matching Host with the selected SDK/Kit before sync.';
|
|
224
|
+
if (!matchesRecordedHostDependencies(matrix.npm, versions)) {
|
|
225
|
+
throw new Error(migration);
|
|
226
|
+
}
|
|
227
|
+
assertSameJson(lock.hostAdapterContracts, snapshot.lock.hostAdapterContracts, 'Scaffold host adapter contracts');
|
|
228
|
+
snapshot.retainedHostFiles = [];
|
|
229
|
+
snapshot.filesWithoutLock = snapshot.filesWithoutLock.map(file => {
|
|
230
|
+
const expected = snapshot.lock.managedFileHashes[file.path];
|
|
231
|
+
if (!expected || !/^(?:src\/|src-electron\/|vite\.config\.ts$)/u.test(file.path)) return file;
|
|
232
|
+
const recorded = lock.managedFileHashes?.[file.path];
|
|
233
|
+
if (!recorded || recorded.class !== expected.class) throw new Error(`${file.path}: ${migration}`);
|
|
234
|
+
const absolute = path.join(targetDir, file.path);
|
|
235
|
+
assertProjectOutputPath(targetDir, absolute);
|
|
236
|
+
const content = existsSync(absolute) ? readFileSync(absolute) : null;
|
|
237
|
+
if (!content || hashScaffoldManagedContent(file.path, content) !== recorded.sha256) {
|
|
238
|
+
throw new Error(`Managed scaffold drift detected: ${file.path}. Restore its locked source before sync.`);
|
|
239
|
+
}
|
|
240
|
+
if (recorded.sha256 === expected.sha256) return file;
|
|
241
|
+
snapshot.lock.managedFileHashes[file.path] = { ...expected, sha256: recorded.sha256 };
|
|
242
|
+
snapshot.retainedHostFiles.push(file.path);
|
|
243
|
+
return { ...file, content };
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
|
|
213
247
|
function readContentForHash(filePath) {
|
|
214
248
|
return readFileSync(filePath);
|
|
215
249
|
}
|
|
@@ -443,26 +477,6 @@ function assertRequiredSupportFiles(targetDir, snapshot) {
|
|
|
443
477
|
if (missing.length > 0) {
|
|
444
478
|
throw new Error(`Missing required scaffold support files: ${missing.join(', ')}`);
|
|
445
479
|
}
|
|
446
|
-
|
|
447
|
-
const tauriConfig = JSON.parse(readFileSync(path.join(targetDir, 'src-tauri/tauri.conf.json'), 'utf8'));
|
|
448
|
-
const icons = tauriConfig?.bundle?.icon;
|
|
449
|
-
if (!Array.isArray(icons) || icons.join(',') !== 'icons/icon.png,icons/icon.ico') {
|
|
450
|
-
throw new Error('Tauri icon support drift: bundle.icon must be ["icons/icon.png","icons/icon.ico"]');
|
|
451
|
-
}
|
|
452
|
-
const icon = readFileSync(path.join(targetDir, 'src-tauri/icons/icon.png'));
|
|
453
|
-
const pngSignature = [0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a];
|
|
454
|
-
if (icon.length !== 68 || pngSignature.some((value, index) => icon[index] !== value)) {
|
|
455
|
-
throw new Error('Tauri icon support drift: src-tauri/icons/icon.png is not the scaffold PNG');
|
|
456
|
-
}
|
|
457
|
-
const ico = readFileSync(path.join(targetDir, 'src-tauri/icons/icon.ico'));
|
|
458
|
-
const icoHeader = [0x00, 0x00, 0x01, 0x00, 0x01, 0x00];
|
|
459
|
-
if (
|
|
460
|
-
ico.length !== 90
|
|
461
|
-
|| icoHeader.some((value, index) => ico[index] !== value)
|
|
462
|
-
|| pngSignature.some((value, index) => ico[index + 22] !== value)
|
|
463
|
-
) {
|
|
464
|
-
throw new Error('Tauri icon support drift: src-tauri/icons/icon.ico is not the scaffold ICO');
|
|
465
|
-
}
|
|
466
480
|
}
|
|
467
481
|
|
|
468
482
|
function usesAppOwnedRenderer(targetDir, plannedSources) {
|
|
@@ -485,10 +499,8 @@ function assertProjectConfiguration(targetDir, parsedManifest = null, managed =
|
|
|
485
499
|
throw new Error(`Submitted manifest YAML cannot be parsed: ${error instanceof Error ? error.message : String(error)}`);
|
|
486
500
|
}
|
|
487
501
|
}
|
|
488
|
-
const rendererOrigin = assertElectronLocalDevelopmentManifest(document);
|
|
489
502
|
readAppIntroduction(targetDir, document);
|
|
490
|
-
|
|
491
|
-
assertOfficialDevelopmentEntrypoints(targetDir, rendererOrigin, undefined, managed || !usesAppOwnedRenderer(targetDir));
|
|
503
|
+
assertCarrierDevelopmentInputs(targetDir, document, readJsonFile(path.join(targetDir, 'package.json')), managed);
|
|
492
504
|
}
|
|
493
505
|
|
|
494
506
|
function assertElectronLocalDevelopmentManifest(document) {
|
|
@@ -591,12 +603,27 @@ function assertNimicodingProjectionCurrent(targetDir, runners) {
|
|
|
591
603
|
}
|
|
592
604
|
}
|
|
593
605
|
|
|
606
|
+
function assertCarrierDevelopmentInputs(targetDir, manifest, packageJson, managed, plannedSources) {
|
|
607
|
+
if (manifest.local_development && Object.hasOwn(manifest.local_development, 'mobile')) readMobileDevelopment(manifest, packageJson);
|
|
608
|
+
if (manifest.platform === 'web' || (manifest.local_development && Object.hasOwn(manifest.local_development, 'web'))) {
|
|
609
|
+
const declaration = manifest.local_development.web;
|
|
610
|
+
const script = /^pnpm run ([A-Za-z0-9][A-Za-z0-9:_.-]*)$/u.exec(declaration?.command || '')?.[1];
|
|
611
|
+
if (!script || !packageJson.scripts?.[script] || /\bnimi-app\s+dev\b/u.test(packageJson.scripts[script])) throw new Error('Web dev requires a non-recursive App-owned renderer script.');
|
|
612
|
+
if (manifest.platform === 'web' || declaration.origin || declaration.redirect_uri || declaration.client_id) readWebDevelopment(manifest);
|
|
613
|
+
if (declaration.local) readWebDevelopment(manifest, { realm: 'local' });
|
|
614
|
+
}
|
|
615
|
+
if (manifest.platform !== 'web') {
|
|
616
|
+
if (manifest.platform !== undefined && manifest.platform !== 'desktop') throw new Error('Unsupported App platform.');
|
|
617
|
+
const rendererOrigin = assertElectronLocalDevelopmentManifest(manifest);
|
|
618
|
+
assertDeclaredHostSourceDirectory(targetDir, manifest);
|
|
619
|
+
assertOfficialDevelopmentEntrypoints(targetDir, rendererOrigin, packageJson, managed || !usesAppOwnedRenderer(targetDir, plannedSources));
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
|
|
594
623
|
export function validateAppProjectInputs(targetDir, manifest, packageJson, managed = false, plannedSources) {
|
|
595
624
|
assertManifestAppAccessDeclaration(stringifyYaml(manifest), 'nimi.app.yaml');
|
|
596
625
|
readAppIntroduction(targetDir, manifest);
|
|
597
|
-
|
|
598
|
-
assertDeclaredHostSourceDirectory(targetDir, manifest);
|
|
599
|
-
assertOfficialDevelopmentEntrypoints(targetDir, rendererOrigin, packageJson, managed || !usesAppOwnedRenderer(targetDir, plannedSources));
|
|
626
|
+
assertCarrierDevelopmentInputs(targetDir, manifest, packageJson, managed, plannedSources);
|
|
600
627
|
const findings = scanForbiddenPatterns(targetDir, manifest.profile, managed ? null : LOCAL_DEVELOPMENT_BYPASS_LABELS, plannedSources);
|
|
601
628
|
if (findings.length) throw new Error(`Forbidden App source patterns: ${findings.join('; ')}`);
|
|
602
629
|
}
|
|
@@ -669,7 +696,7 @@ function validateExistingSubmittedApp(targetDir) {
|
|
|
669
696
|
}
|
|
670
697
|
const appId = typeof parsed?.app_id === 'string' ? parsed.app_id.trim() : '';
|
|
671
698
|
const profile = typeof parsed?.profile === 'string' ? parsed.profile.trim() : '';
|
|
672
|
-
if (!appId || appId !== parsed?.app_id || !SUPPORTED_APP_SCAFFOLD_PROFILES.includes(profile)) {
|
|
699
|
+
if (!isAppId(appId) || appId !== parsed?.app_id || !SUPPORTED_APP_SCAFFOLD_PROFILES.includes(profile)) {
|
|
673
700
|
throw new Error('Existing submitted app requires canonical app_id and supported profile');
|
|
674
701
|
}
|
|
675
702
|
if (parsed?.manifest_role !== 'submitted-input') {
|
|
@@ -697,19 +724,40 @@ export function initApp(cwd, options = {}, versions, runners = {}) {
|
|
|
697
724
|
// Create still uses the tool default. An explicit listed selection before
|
|
698
725
|
// first init refreshes derived glue through this owner, just as sync does.
|
|
699
726
|
// Check the original generated files before projecting the selected pair.
|
|
700
|
-
const
|
|
701
|
-
const
|
|
702
|
-
const
|
|
727
|
+
const pkg = readJsonFile(path.join(targetDir, 'package.json'));
|
|
728
|
+
const creatorSpec = intent?.dependencyMatrix?.npm?.['@nimiplatform/app-tools'];
|
|
729
|
+
const compatiblePatch = typeof creatorSpec === 'string' && creatorSpec !== versions.appToolsVersion
|
|
730
|
+
&& appToolsDeclaration(creatorSpec, versions.appToolsVersion) === creatorSpec;
|
|
731
|
+
const creatorVersions = compatiblePatch
|
|
732
|
+
? { ...versions, ...resolveDependencyCombination({ dependencies: intent.dependencyMatrix.npm }, versions) }
|
|
733
|
+
: versions;
|
|
734
|
+
const original = buildAppScaffoldSnapshotFromIntent({ intent, versions: creatorVersions, targetDir, refreshInitialDependencies: compatiblePatch });
|
|
735
|
+
const combination = resolveDependencyCombination(pkg, versions);
|
|
736
|
+
const appToolsVersion = appToolsDeclaration(pkg.devDependencies?.['@nimiplatform/app-tools'], versions.appToolsVersion);
|
|
737
|
+
const effective = { ...versions, ...combination, appToolsVersion };
|
|
703
738
|
const snapshot = buildAppScaffoldSnapshotFromIntent({ intent, versions: effective, targetDir, refreshDerived: true });
|
|
739
|
+
if (combination.source === 'existing'
|
|
740
|
+
&& !matchesRecordedHostDependencies(intent.dependencyMatrix.npm, combination)) {
|
|
741
|
+
throw new Error('The selected SDK/Kit requires a different Host. Initialize with the creator combination or migrate the Host and App-owned feature modules together.');
|
|
742
|
+
}
|
|
704
743
|
validateAppProjectInputs(targetDir, currentManifest, readJsonFile(path.join(targetDir, 'package.json')), true);
|
|
705
744
|
const initializedPaths = new Set(snapshot.initFiles.map((file) => file.path));
|
|
706
|
-
|
|
745
|
+
const initialFiles = Object.entries(original.lock.managedFileHashes).filter(([relativePath]) =>
|
|
746
|
+
!initializedPaths.has(relativePath) && !(compatiblePatch && relativePath === SCAFFOLD_INTENT_PATH));
|
|
747
|
+
try {
|
|
748
|
+
assertManagedFilesCurrent(targetDir, { managedFileHashes: Object.fromEntries(initialFiles) });
|
|
749
|
+
} catch (cause) {
|
|
750
|
+
if (!compatiblePatch) throw cause;
|
|
751
|
+
throw new Error(`${cause.message}. Review the listed files. For an untouched scaffold from a different generator, run nimi-app init with its exact creator ${minVersion(creatorSpec).version} (published package or original tarball), then sync with the selected tool.`, { cause });
|
|
752
|
+
}
|
|
707
753
|
const managedFiles = snapshot.filesWithoutLock.filter((file) => snapshot.lock.managedFileHashes[file.path]);
|
|
708
754
|
const planned = [...managedFiles.map((file) => {
|
|
709
755
|
let content = file.content;
|
|
710
756
|
if (file.path === 'nimi.app.yaml' && currentManifest) {
|
|
711
757
|
const next = parseYaml(content);
|
|
712
758
|
for (const field of APP_AUTHOR_DECLARATION_FIELDS) if (Object.hasOwn(currentManifest, field)) next[field] = currentManifest[field];
|
|
759
|
+
if (currentManifest.local_development?.web) next.local_development = { ...next.local_development, web: currentManifest.local_development.web };
|
|
760
|
+
if (currentManifest.local_development?.mobile) next.local_development = { ...next.local_development, mobile: currentManifest.local_development.mobile };
|
|
713
761
|
content = stringifyYaml(next, { lineWidth: 0 });
|
|
714
762
|
}
|
|
715
763
|
return plannedFile(targetDir, file.path, content);
|
|
@@ -794,7 +842,13 @@ function collectExpectedClasses(snapshot) {
|
|
|
794
842
|
// A lock written by an earlier scaffold version can still list a file that the
|
|
795
843
|
// current generator creates once for the App to own. Only the declared paths
|
|
796
844
|
// may change owner, and only from managed glue to App-owned product code.
|
|
845
|
+
const RETIRED_TAURI_GLUE = new Set([
|
|
846
|
+
'src-tauri/Cargo.toml', 'src-tauri/build.rs', 'src-tauri/capabilities/default.json',
|
|
847
|
+
'src-tauri/tauri.conf.json', 'src-tauri/src/main.rs', 'src-tauri/icons/icon.png', 'src-tauri/icons/icon.ico',
|
|
848
|
+
]);
|
|
849
|
+
|
|
797
850
|
function isAppOwnedHandover(relativePath, lockedEntry, current) {
|
|
851
|
+
if (!current && RETIRED_TAURI_GLUE.has(relativePath)) return lockedEntry?.class === 'scaffold-managed glue';
|
|
798
852
|
return SCAFFOLD_APP_OWNED_HANDOVER_PATHS.includes(relativePath)
|
|
799
853
|
&& lockedEntry?.class === 'scaffold-managed glue'
|
|
800
854
|
&& current?.owner === 'app-owned'
|
|
@@ -835,14 +889,14 @@ function assertNoClassificationConflict(lock, snapshot, targetDir) {
|
|
|
835
889
|
handovers.push(describeAppOwnedHandover(targetDir, relativePath, entry));
|
|
836
890
|
continue;
|
|
837
891
|
}
|
|
838
|
-
throw new Error(`Scaffold classification conflict: ${relativePath}
|
|
892
|
+
throw new Error(`Scaffold classification conflict: ${relativePath}. Review its ownership and restore the matching scaffold lock before sync.`);
|
|
839
893
|
}
|
|
840
894
|
for (const [relativePath, entry] of Object.entries(lock.appOwnedInitialHashes || {})) {
|
|
841
895
|
const current = currentClasses.get(relativePath);
|
|
842
896
|
if (current?.owner === 'app-owned' && current.class === entry.class) {
|
|
843
897
|
continue;
|
|
844
898
|
}
|
|
845
|
-
throw new Error(`Scaffold classification conflict: ${relativePath}
|
|
899
|
+
throw new Error(`Scaffold classification conflict: ${relativePath}. Review its ownership and restore the matching scaffold lock before sync.`);
|
|
846
900
|
}
|
|
847
901
|
return handovers;
|
|
848
902
|
}
|
|
@@ -882,10 +936,12 @@ export function planManagedAppSync(cwd, options = {}, versions) {
|
|
|
882
936
|
if (file.path === 'nimi.app.yaml' && currentManifest) {
|
|
883
937
|
const next = parseYaml(content);
|
|
884
938
|
for (const field of APP_AUTHOR_DECLARATION_FIELDS) if (Object.hasOwn(currentManifest, field)) next[field] = currentManifest[field];
|
|
939
|
+
if (currentManifest.local_development?.web) next.local_development = { ...next.local_development, web: currentManifest.local_development.web };
|
|
940
|
+
if (currentManifest.local_development?.mobile) next.local_development = { ...next.local_development, mobile: currentManifest.local_development.mobile };
|
|
885
941
|
content = stringifyYaml(next, { lineWidth: 0 });
|
|
886
942
|
}
|
|
887
943
|
return plannedFile(targetDir, file.path, content);
|
|
888
944
|
});
|
|
889
945
|
planned.push(...planLifecycleGuidance(targetDir), plannedFile(targetDir, SCAFFOLD_LOCK_PATH, `${JSON.stringify(snapshot.lock, null, 2)}\n`));
|
|
890
|
-
return { targetDir, snapshot, planned, handovers };
|
|
946
|
+
return { targetDir, snapshot, planned, handovers, previousDependencies: lock.dependencyMatrix.npm };
|
|
891
947
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-scaf-002a
|
|
2
|
+
export function assertDesktopHostSupport(profileRef) {
|
|
3
|
+
if (profileRef === 'tauri-pnpm-vite') {
|
|
4
|
+
throw new Error('tauri-pnpm-vite is unsupported in this release. Use the original Tauri toolchain or explicitly migrate the App to Electron.');
|
|
5
|
+
}
|
|
6
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
|
|
3
|
+
const segment = '[a-z0-9](?:[a-z0-9-]*[a-z0-9])?';
|
|
4
|
+
const productId = new RegExp('^' + segment + '(?:\\.' + segment + ')+$');
|
|
5
|
+
const clientId = /^[a-z][a-z0-9]*(?:[._-][a-z0-9]+)+$/u;
|
|
6
|
+
const publicSlug = new RegExp('^' + segment + '$');
|
|
7
|
+
|
|
8
|
+
export function isAppId(value) {
|
|
9
|
+
return typeof value === 'string' && value.length >= 3 && value.length <= 120 && productId.test(value);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function isClientId(value) {
|
|
13
|
+
return typeof value === 'string' && value.length >= 3 && value.length <= 120 && clientId.test(value);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function hostedWebIdentity(appId, slug, registeredClient) {
|
|
17
|
+
if (!isAppId(appId)) throw new Error('Invalid hosted Web product ID.');
|
|
18
|
+
if (typeof slug !== 'string' || slug.length > 63 || !publicSlug.test(slug))
|
|
19
|
+
throw new Error('Invalid hosted Web slug.');
|
|
20
|
+
const preferred = appId + '.web';
|
|
21
|
+
const id =
|
|
22
|
+
registeredClient ??
|
|
23
|
+
(isClientId(preferred) ? preferred : 'web.' + createHash('sha256').update(appId).digest('hex'));
|
|
24
|
+
if (!isClientId(id)) throw new Error('Invalid hosted Web client ID.');
|
|
25
|
+
const origin = 'https://' + slug + '.nimi.xyz';
|
|
26
|
+
return { appId, slug, clientId: id, origin, redirectUri: origin + '/' };
|
|
27
|
+
}
|