@nimiplatform/app-tools 0.14.0 → 0.16.0-rc.12
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 +112 -24
- package/bin/nimi-app.mjs +35 -15
- package/lib/app-access-declaration.mjs +3 -0
- package/lib/app-dependency-combinations.mjs +70 -24
- package/lib/app-doctor-update.mjs +97 -39
- package/lib/app-host-support.mjs +6 -0
- package/lib/app-identifiers.mjs +27 -0
- package/lib/app-info.mjs +292 -1
- package/lib/app-lifecycle-guidance.mjs +1 -1
- package/lib/app-pack.mjs +65 -39
- package/lib/app-project-lifecycle.mjs +149 -244
- package/lib/app-scaffold-capabilities.mjs +13 -109
- package/lib/app-scaffold-profiles.mjs +81 -115
- package/lib/app-scaffold.mjs +74 -166
- 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 +43 -3
- package/lib/mobile-development.mjs +19 -0
- package/lib/realm-environments.generated.mjs +5 -0
- package/lib/storefront-media.mjs +154 -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 +33 -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/release.md +10 -0
- 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 +68 -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 +98 -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
|
@@ -1,17 +1,21 @@
|
|
|
1
|
+
import { assertDesktopHostSupport } from './app-host-support.mjs';
|
|
2
|
+
import { hostedWebIdentity, isAppId } from './app-identifiers.mjs';
|
|
3
|
+
import { readWebDevelopment } from './web-development.mjs';
|
|
1
4
|
import { readAppInfo } from './app-info.mjs';
|
|
2
5
|
import { CANONICAL_CAPABILITY_IDS } from './canonical-capability-ids.generated.mjs';
|
|
3
6
|
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-scaf-018c
|
|
4
7
|
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-napp-009b
|
|
5
8
|
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-napp-043a
|
|
6
9
|
|
|
7
|
-
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, writeFileSync } from 'node:fs';
|
|
10
|
+
import { existsSync, globSync, lstatSync, mkdirSync, readFileSync, readdirSync, realpathSync, writeFileSync } from 'node:fs';
|
|
8
11
|
import { createRequire } from 'node:module';
|
|
9
12
|
import path from 'node:path';
|
|
10
|
-
import { satisfies } from 'semver';
|
|
13
|
+
import { satisfies, validRange } from 'semver';
|
|
14
|
+
import { lockedRegistryVersion, planToolchainUpdates } from './app-toolchain-updates.mjs';
|
|
11
15
|
import { parse as parseYaml, parseDocument as parseYamlDocument, stringify as stringifyYaml } from 'yaml';
|
|
12
16
|
|
|
13
17
|
import { assertManifestAppAccessDeclaration } from './app-access-declaration.mjs';
|
|
14
|
-
import { defaultDependencyCombination, resolveDependencyCombination } from './app-dependency-combinations.mjs';
|
|
18
|
+
import { appToolsDeclaration, defaultDependencyCombination, isLocalDependencySpec, resolveDependencyCombination } from './app-dependency-combinations.mjs';
|
|
15
19
|
import { SAFETY_PROFILE_FIELD, normalizeSafetyProfile } from './app-safety-profile.mjs';
|
|
16
20
|
import { planManagedAppSync, validateAppProject, validateAppProjectInputs, validateManagedAppFiles } from './app-doctor-update.mjs';
|
|
17
21
|
import { LIFECYCLE_SKILL_PATH, hasLifecycleGuidanceOwner, lifecycleOwnerSteps, planLifecycleGuidance } from './app-lifecycle-guidance.mjs';
|
|
@@ -20,6 +24,7 @@ import {
|
|
|
20
24
|
SCAFFOLD_INTENT_PATH,
|
|
21
25
|
SCAFFOLD_LOCK_PATH,
|
|
22
26
|
SUPPORTED_APP_SCAFFOLD_PROFILES,
|
|
27
|
+
hashScaffoldContent,
|
|
23
28
|
managedAppReleaseWorkflowSource,
|
|
24
29
|
renderAppBuildProfile,
|
|
25
30
|
renderAppIdentityInput,
|
|
@@ -50,9 +55,22 @@ const SYNCHRONIZED_NIMI_PACKAGES = new Set([
|
|
|
50
55
|
const BUILD_PROFILE_PATH = '.nimi/config/build-profile.yaml';
|
|
51
56
|
const ELECTRON_BUILD_PROFILE_REF = 'electron-packager-pnpm-vite';
|
|
52
57
|
const APP_OWNED_ELECTRON_BUILD_PROFILE_REF = 'electron-pnpm';
|
|
53
|
-
const
|
|
54
|
-
const SUPPORTED_BUILD_PROFILE_REFS = new Set([ELECTRON_BUILD_PROFILE_REF, APP_OWNED_ELECTRON_BUILD_PROFILE_REF, TAURI_BUILD_PROFILE_REF]);
|
|
58
|
+
const SUPPORTED_BUILD_PROFILE_REFS = new Set([ELECTRON_BUILD_PROFILE_REF, APP_OWNED_ELECTRON_BUILD_PROFILE_REF, 'web-pnpm']);
|
|
55
59
|
const MANAGED_WORKFLOW_PATH = '.github/workflows/nimi-app-release.yml';
|
|
60
|
+
const HOSTED_WEB_WORKFLOW_PATH = '.github/workflows/nimi-web-release.yml';
|
|
61
|
+
function hostedWorkflowSource() {
|
|
62
|
+
return readFileSync(new URL('../templates/hosted-web-release.yml', import.meta.url), 'utf8').replaceAll('\r\n', '\n');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function planHostedWorkflow(targetDir) {
|
|
66
|
+
const file = plannedFile(targetDir, HOSTED_WEB_WORKFLOW_PATH, hostedWorkflowSource());
|
|
67
|
+
const previous = file.previous?.toString('utf8').replaceAll('\r\n', '\n');
|
|
68
|
+
// Apps initialized with the published rc.9 template can upgrade through normal sync.
|
|
69
|
+
if (previous !== undefined && previous !== file.content &&
|
|
70
|
+
hashScaffoldContent(previous) !== 'c80010a26c4ed010807ec67e79083d04f8ed4345753e7d0bb12e3fe333c3f241') // pragma: allowlist secret -- SHA-256 of the public rc.9 hosted workflow
|
|
71
|
+
throw new Error('Unknown hosted Web workflow collision: ' + HOSTED_WEB_WORKFLOW_PATH);
|
|
72
|
+
return file;
|
|
73
|
+
}
|
|
56
74
|
const APP_IDENTITY_PATH = '.nimi/config/app-identity.yaml';
|
|
57
75
|
const SUBMISSION_PATH = '.nimi/admission/submission.yaml';
|
|
58
76
|
const SEMVER_PATTERN = /^(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?(?:\+[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?$/u;
|
|
@@ -105,7 +123,7 @@ function readSubmittedManifest(targetDir, sources) {
|
|
|
105
123
|
|| appId !== document?.app_id
|
|
106
124
|
|| !displayName.trim()
|
|
107
125
|
|| displayName !== displayName.trim()
|
|
108
|
-
||
|
|
126
|
+
|| !isAppId(appId)
|
|
109
127
|
|| !SUPPORTED_APP_SCAFFOLD_PROFILES.includes(profile)
|
|
110
128
|
) {
|
|
111
129
|
throw new Error('Existing submitted app requires canonical app_id and supported profile');
|
|
@@ -113,7 +131,10 @@ function readSubmittedManifest(targetDir, sources) {
|
|
|
113
131
|
if (document?.manifest_role !== 'submitted-input') {
|
|
114
132
|
throw new Error('Submitted manifest marker missing');
|
|
115
133
|
}
|
|
116
|
-
const
|
|
134
|
+
const platform = document.platform || 'desktop';
|
|
135
|
+
if (!['desktop', 'web'].includes(platform)) throw new Error('Unsupported App platform.');
|
|
136
|
+
const hosted = Object.hasOwn(document, 'public_slug') ? hostedWebIdentity(appId, document.public_slug) : null;
|
|
137
|
+
const rendererOrigin = platform === 'web' ? (hosted?.origin ?? readWebDevelopment(document).site.origin) : document?.local_development?.electron?.renderer_origin;
|
|
117
138
|
let parsedOrigin;
|
|
118
139
|
try {
|
|
119
140
|
parsedOrigin = new URL(rendererOrigin);
|
|
@@ -123,9 +144,7 @@ function readSubmittedManifest(targetDir, sources) {
|
|
|
123
144
|
if (
|
|
124
145
|
typeof rendererOrigin !== 'string'
|
|
125
146
|
|| rendererOrigin.trim() !== rendererOrigin
|
|
126
|
-
|| parsedOrigin.protocol !== 'http:'
|
|
127
|
-
|| parsedOrigin.hostname !== '127.0.0.1'
|
|
128
|
-
|| !parsedOrigin.port
|
|
147
|
+
|| (platform === 'desktop' && (parsedOrigin.protocol !== 'http:' || parsedOrigin.hostname !== '127.0.0.1' || !parsedOrigin.port))
|
|
129
148
|
|| parsedOrigin.username
|
|
130
149
|
|| parsedOrigin.password
|
|
131
150
|
|| parsedOrigin.pathname !== '/'
|
|
@@ -150,7 +169,7 @@ function readSubmittedManifest(targetDir, sources) {
|
|
|
150
169
|
throw new Error(`nimi.app.yaml ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
151
170
|
}
|
|
152
171
|
}
|
|
153
|
-
return Object.freeze({ appId, displayName, profile, version, rendererOrigin: parsedOrigin.origin, capabilityContractRefs: document.capability_contract_refs, requiredStandardizedFeatureRefs: document.required_standardized_feature_refs, storagePolicy: document.storage_policy, safetyProfile });
|
|
172
|
+
return Object.freeze({ appId, displayName, profile, platform, version, publicSlug: hosted?.slug, rendererOrigin: parsedOrigin.origin, capabilityContractRefs: document.capability_contract_refs, requiredStandardizedFeatureRefs: document.required_standardized_feature_refs, storagePolicy: document.storage_policy, safetyProfile });
|
|
154
173
|
}
|
|
155
174
|
|
|
156
175
|
function assertNoRetiredScaffoldState(targetDir) {
|
|
@@ -167,12 +186,12 @@ function assertNoRetiredScaffoldState(targetDir) {
|
|
|
167
186
|
|
|
168
187
|
// The SDK/Kit pair comes from the App's resolved combination; the tool
|
|
169
188
|
// dependencies come from the selected tool version. Both are one judgment
|
|
170
|
-
// shared by manifest, lock
|
|
171
|
-
function expectedNimiDependencies(versions, combination) {
|
|
189
|
+
// shared by manifest, lock and workflow checks.
|
|
190
|
+
function expectedNimiDependencies(versions, combination, packageJson) {
|
|
172
191
|
return Object.freeze([
|
|
173
192
|
Object.freeze({ name: '@nimiplatform/sdk', section: 'dependencies', version: combination.sdkVersion }),
|
|
174
193
|
Object.freeze({ name: '@nimiplatform/kit', section: 'dependencies', version: combination.kitVersion }),
|
|
175
|
-
Object.freeze({ name: '@nimiplatform/app-tools', section: 'devDependencies', version: versions.appToolsVersion }),
|
|
194
|
+
Object.freeze({ name: '@nimiplatform/app-tools', section: 'devDependencies', version: appToolsDeclaration(packageJson.devDependencies?.['@nimiplatform/app-tools'], versions.appToolsVersion) }),
|
|
176
195
|
Object.freeze({ name: '@nimiplatform/nimi-coding', section: 'devDependencies', version: versions.nimicodingVersion }),
|
|
177
196
|
]);
|
|
178
197
|
}
|
|
@@ -191,13 +210,16 @@ function selectDependencyCombination(packageJson, versions, managed) {
|
|
|
191
210
|
function managedProjectVersions(targetDir, versions) {
|
|
192
211
|
const packagePath = path.join(targetDir, 'package.json');
|
|
193
212
|
if (!existsSync(packagePath)) return versions;
|
|
194
|
-
const
|
|
195
|
-
|
|
213
|
+
const pkg = readJsonFile(packagePath, 'package.json');
|
|
214
|
+
const combination = resolveDependencyCombination(pkg, versions);
|
|
215
|
+
const appToolsVersion = appToolsDeclaration(pkg.devDependencies?.['@nimiplatform/app-tools'], versions.appToolsVersion);
|
|
216
|
+
return Object.freeze({ ...versions, ...combination, appToolsVersion });
|
|
196
217
|
}
|
|
197
218
|
|
|
198
219
|
function describeCombination(combination, toolVersions) {
|
|
199
|
-
const
|
|
200
|
-
|
|
220
|
+
const dependencies = { '@nimiplatform/sdk': combination.sdkVersion, '@nimiplatform/kit': combination.kitVersion };
|
|
221
|
+
const { source } = resolveDependencyCombination({ dependencies }, toolVersions);
|
|
222
|
+
return { sdk: combination.sdkVersion, kit: combination.kitVersion, source };
|
|
201
223
|
}
|
|
202
224
|
|
|
203
225
|
function dependencySection(packageJson, sectionName) {
|
|
@@ -209,13 +231,6 @@ function dependencySection(packageJson, sectionName) {
|
|
|
209
231
|
return section;
|
|
210
232
|
}
|
|
211
233
|
|
|
212
|
-
function isLocalDependencySpec(value) {
|
|
213
|
-
const normalized = typeof value === 'string' ? value.trim() : '';
|
|
214
|
-
return /^(?:file|link|patch|path|portal|workspace):/iu.test(normalized)
|
|
215
|
-
|| /^(?:\.{1,2}[\\/]|~[\\/]|[A-Za-z]:[\\/]|\\\\)/u.test(normalized)
|
|
216
|
-
|| /\.(?:tar\.gz|tgz)(?:[?#].*)?$/iu.test(normalized);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
234
|
function localPackageArchive(value) {
|
|
220
235
|
return typeof value === 'string' ? value.match(/^(file:[^\r\n]+?\.(?:tgz|tar\.gz))(?:\(.*\))?$/u)?.[1] || '' : '';
|
|
221
236
|
}
|
|
@@ -255,7 +270,7 @@ function assertPublicNimiDependencySpecs(packageJson) {
|
|
|
255
270
|
}
|
|
256
271
|
}
|
|
257
272
|
|
|
258
|
-
function assertPackageManifestCurrent(packageJson, versions, combination) {
|
|
273
|
+
function assertPackageManifestCurrent(packageJson, versions, combination, platform = 'desktop') {
|
|
259
274
|
if (packageJson.private !== true || Object.hasOwn(packageJson, 'publishConfig')) {
|
|
260
275
|
throw new Error('Nimi App package.json must be private and must not declare npm publishConfig');
|
|
261
276
|
}
|
|
@@ -263,7 +278,7 @@ function assertPackageManifestCurrent(packageJson, versions, combination) {
|
|
|
263
278
|
throw new Error(`package.json packageManager must be ${versions.packageManager}`);
|
|
264
279
|
}
|
|
265
280
|
assertPublicNimiDependencySpecs(packageJson);
|
|
266
|
-
for (const expected of expectedNimiDependencies(versions, combination)) {
|
|
281
|
+
for (const expected of expectedNimiDependencies(versions, combination, packageJson)) {
|
|
267
282
|
const section = dependencySection(packageJson, expected.section);
|
|
268
283
|
if (section?.[expected.name] !== expected.version) {
|
|
269
284
|
throw new Error(`package.json ${expected.section}.${expected.name} must be ${expected.version}`);
|
|
@@ -296,24 +311,25 @@ function assertPackageManifestCurrent(packageJson, versions, combination) {
|
|
|
296
311
|
throw new Error(`package.json scripts.${name} must not mutate managed App state during dependency installation`);
|
|
297
312
|
}
|
|
298
313
|
}
|
|
299
|
-
if (scripts.pack !== 'nimi-app pack') {
|
|
314
|
+
if (platform === 'desktop' && scripts.pack !== 'nimi-app pack') {
|
|
300
315
|
throw new Error('package.json scripts.pack must use the canonical nimi-app pack owner');
|
|
301
316
|
}
|
|
302
|
-
if (scripts.publish !== undefined) {
|
|
317
|
+
if (platform === 'desktop' && scripts.publish !== undefined) {
|
|
303
318
|
throw new Error('package.json scripts.publish is unavailable until publisher GitHub and registry orchestration is implemented');
|
|
304
319
|
}
|
|
305
320
|
return combination;
|
|
306
321
|
}
|
|
307
322
|
|
|
308
|
-
function normalizePackageManifest(packageJson, descriptor, versions, buildProfileRef, packageSource, combination) {
|
|
323
|
+
function normalizePackageManifest(packageJson, descriptor, versions, buildProfileRef, packageSource, combination, toolchainUpdates) {
|
|
309
324
|
if (!packageJson || typeof packageJson !== 'object' || Array.isArray(packageJson)) {
|
|
310
325
|
throw new Error('package.json must contain an object');
|
|
311
326
|
}
|
|
312
327
|
const normalized = JSON.parse(JSON.stringify(packageJson));
|
|
313
328
|
normalized.private = true;
|
|
314
329
|
delete normalized.publishConfig;
|
|
330
|
+
for (const { section, name, to } of toolchainUpdates) normalized[section][name] = to;
|
|
315
331
|
for (const sectionName of NPM_DEPENDENCY_SECTIONS) dependencySection(normalized, sectionName);
|
|
316
|
-
for (const expected of expectedNimiDependencies(versions, combination)) {
|
|
332
|
+
for (const expected of expectedNimiDependencies(versions, combination, packageJson)) {
|
|
317
333
|
for (const sectionName of NPM_DEPENDENCY_SECTIONS) {
|
|
318
334
|
const section = dependencySection(normalized, sectionName);
|
|
319
335
|
if (section) delete section[expected.name];
|
|
@@ -332,6 +348,11 @@ function normalizePackageManifest(packageJson, descriptor, versions, buildProfil
|
|
|
332
348
|
if (!normalized.scripts || typeof normalized.scripts !== 'object' || Array.isArray(normalized.scripts)) {
|
|
333
349
|
throw new Error('package.json scripts must be an object');
|
|
334
350
|
}
|
|
351
|
+
if (descriptor.platform === 'web') {
|
|
352
|
+
normalized.scripts.dev = 'nimi-app dev --platform web';
|
|
353
|
+
normalized.scripts.sync ||= 'nimi-app sync';
|
|
354
|
+
if (normalized.scripts.pack === 'nimi-app pack') delete normalized.scripts.pack;
|
|
355
|
+
} else {
|
|
335
356
|
if (typeof normalized.scripts['build:electron'] !== 'string' || !normalized.scripts['build:electron'].trim()) {
|
|
336
357
|
throw new Error('package.json build:electron must build the Desktop-supervised Electron host');
|
|
337
358
|
}
|
|
@@ -344,6 +365,7 @@ function normalizePackageManifest(packageJson, descriptor, versions, buildProfil
|
|
|
344
365
|
normalized.scripts.sync ||= 'nimi-app sync';
|
|
345
366
|
normalized.scripts.pack = 'nimi-app pack';
|
|
346
367
|
delete normalized.scripts.publish;
|
|
368
|
+
}
|
|
347
369
|
for (const name of ['doctor', 'update']) {
|
|
348
370
|
if (/^nimi-app\s+(?:doctor|update)$/u.test(String(normalized.scripts[name] || '').trim())) {
|
|
349
371
|
delete normalized.scripts[name];
|
|
@@ -355,7 +377,7 @@ function normalizePackageManifest(packageJson, descriptor, versions, buildProfil
|
|
|
355
377
|
.replace(/\bpnpm\s+run\s+doctor\s*&&\s*/gu, '')
|
|
356
378
|
.replace(/\bnimi-app\s+doctor\s*&&\s*/gu, '');
|
|
357
379
|
}
|
|
358
|
-
assertPackageManifestCurrent(normalized, versions, combination);
|
|
380
|
+
assertPackageManifestCurrent(normalized, versions, combination, descriptor.platform);
|
|
359
381
|
// Project formatters may use different whitespace or key order. Only managed
|
|
360
382
|
// value changes require rewriting this App-owned manifest.
|
|
361
383
|
if (stableInputJson(normalized) === stableInputJson(packageJson)) return packageSource;
|
|
@@ -584,6 +606,10 @@ function assertPnpmLockCurrent(targetDir, packageJson, localPackages, versions,
|
|
|
584
606
|
if (!importer || typeof importer !== 'object' || Array.isArray(importer)) {
|
|
585
607
|
throw installRequiredError('pnpm-lock.yaml root importer is missing');
|
|
586
608
|
}
|
|
609
|
+
for (const update of planToolchainUpdates(packageJson, importer, versions)) {
|
|
610
|
+
if (update.lockedAffected) throw installRequiredError(`pnpm-lock.yaml resolves ${update.name}@${update.locked}. Select a patched release (fixed in ${update.fixedVersion})`);
|
|
611
|
+
}
|
|
612
|
+
const requiredPackages = expectedNimiDependencies(versions, combination, packageJson);
|
|
587
613
|
const installedLock = localPackages.size > 0 ? readInstalledPnpmLock(targetDir) : null;
|
|
588
614
|
for (const [name, selected] of localPackages) {
|
|
589
615
|
if (lock.overrides?.[name] !== selected) throw installRequiredError(`pnpm-lock.yaml local package override does not match pnpm-workspace.yaml: ${name}`);
|
|
@@ -599,7 +625,7 @@ function assertPnpmLockCurrent(targetDir, packageJson, localPackages, versions,
|
|
|
599
625
|
if (!existsSync(manifestPath)) throw installRequiredError(`Local Nimi package is not installed: ${name}`);
|
|
600
626
|
const installed = readJsonFile(manifestPath, name);
|
|
601
627
|
const declared = NPM_DEPENDENCY_SECTIONS.map((section) => dependencySection(packageJson, section)?.[name]).filter((value) => value !== undefined);
|
|
602
|
-
const expected =
|
|
628
|
+
const expected = requiredPackages.find((entry) => entry.name === name)?.version
|
|
603
629
|
|| (KIT_OWNED_NATIVE_CARRIERS.includes(name) ? combination.kitVersion : declared[0]);
|
|
604
630
|
if (!expected || declared.some((specifier) => specifier !== expected)) {
|
|
605
631
|
throw installRequiredError(`Local Nimi package has no consistent declared version: ${name}`);
|
|
@@ -621,10 +647,21 @@ function assertPnpmLockCurrent(targetDir, packageJson, localPackages, versions,
|
|
|
621
647
|
const packageSection = dependencySection(packageJson, sectionName) || {};
|
|
622
648
|
const lockSection = importer[sectionName] || {};
|
|
623
649
|
for (const [name, specifier] of Object.entries(packageSection)) {
|
|
650
|
+
if ((name === 'vite' || name === 'electron') && sectionName !== 'peerDependencies' && validRange(specifier)) {
|
|
651
|
+
const entry = lockSection[name];
|
|
652
|
+
if (typeof entry?.specifier !== 'string' || (entry.specifier !== specifier && entry.specifier !== lock.overrides?.[name])
|
|
653
|
+
|| !satisfies(lockedRegistryVersion(entry), specifier)) {
|
|
654
|
+
throw installRequiredError(`pnpm-lock.yaml ${sectionName}.${name} does not resolve the declared range ${specifier}`);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
624
657
|
if (!name.startsWith('@nimiplatform/')) continue;
|
|
625
658
|
if (lockSection?.[name]?.specifier !== (localPackages.get(name) || specifier)) {
|
|
626
659
|
throw installRequiredError(`pnpm-lock.yaml ${sectionName}.${name} specifier does not match package.json`);
|
|
627
660
|
}
|
|
661
|
+
if (!localPackages.has(name) && requiredPackages.some(dep => dep.name === name)
|
|
662
|
+
&& !satisfies(lockedRegistryVersion(lockSection[name]), specifier)) {
|
|
663
|
+
throw installRequiredError(`pnpm-lock.yaml ${sectionName}.${name} does not resolve the declared range ${specifier}`);
|
|
664
|
+
}
|
|
628
665
|
if (localPackages.has(name)
|
|
629
666
|
&& installedLock?.importers?.['.']?.[sectionName]?.[name]?.version !== lockSection[name]?.version) {
|
|
630
667
|
throw installRequiredError(`Local Nimi package installation is stale: ${name}`);
|
|
@@ -653,95 +690,6 @@ function assertPnpmLockCurrent(targetDir, packageJson, localPackages, versions,
|
|
|
653
690
|
}
|
|
654
691
|
}
|
|
655
692
|
|
|
656
|
-
function assertCargoLockCurrent(targetDir, version) {
|
|
657
|
-
const cargoLockError = (detail) => new Error(`${detail}. Run cargo update -p nimi-shell-tauri --precise ${version}, then rerun nimi-app check.`);
|
|
658
|
-
const lockPath = path.join(targetDir, 'src-tauri', 'Cargo.lock');
|
|
659
|
-
if (!existsSync(lockPath)) {
|
|
660
|
-
throw cargoLockError('src-tauri/Cargo.lock is missing');
|
|
661
|
-
}
|
|
662
|
-
const blocks = readFileSync(lockPath, 'utf8').split(/\r?\n\[\[package\]\]\r?\n/u);
|
|
663
|
-
const block = blocks.find((entry) => /^name\s*=\s*"nimi-shell-tauri"\s*$/mu.test(entry));
|
|
664
|
-
if (!block) throw cargoLockError('src-tauri/Cargo.lock is missing nimi-shell-tauri');
|
|
665
|
-
const lockedVersion = block.match(/^version\s*=\s*"([^"]+)"\s*$/mu)?.[1];
|
|
666
|
-
const source = block.match(/^source\s*=\s*"([^"]+)"\s*$/mu)?.[1];
|
|
667
|
-
const checksum = block.match(/^checksum\s*=\s*"([a-f0-9]{64})"\s*$/mu)?.[1];
|
|
668
|
-
if (lockedVersion !== version || !source?.startsWith('registry+') || !checksum) {
|
|
669
|
-
throw cargoLockError(`src-tauri/Cargo.lock nimi-shell-tauri must resolve registry version ${version} with checksum`);
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
function cargoDependencyLocations(source) {
|
|
674
|
-
const lines = source.split(/\r?\n/u);
|
|
675
|
-
let section = '';
|
|
676
|
-
const entries = [];
|
|
677
|
-
let dependenciesHeader = -1;
|
|
678
|
-
for (let index = 0; index < lines.length; index += 1) {
|
|
679
|
-
const header = lines[index].match(/^\s*\[([^\]]+)\]\s*(?:#.*)?$/u);
|
|
680
|
-
if (header) {
|
|
681
|
-
section = header[1];
|
|
682
|
-
if (section === 'dependencies') dependenciesHeader = index;
|
|
683
|
-
continue;
|
|
684
|
-
}
|
|
685
|
-
if (/^\s*nimi-shell-tauri\s*=/u.test(lines[index])) {
|
|
686
|
-
entries.push({ index, section, line: lines[index].trim() });
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
return { lines, entries, dependenciesHeader };
|
|
690
|
-
}
|
|
691
|
-
|
|
692
|
-
function normalizeCargoManifest(source, version) {
|
|
693
|
-
const newline = source.includes('\r\n') ? '\r\n' : '\n';
|
|
694
|
-
const hadFinalNewline = source.endsWith('\n');
|
|
695
|
-
const { lines, entries, dependenciesHeader } = cargoDependencyLocations(source);
|
|
696
|
-
if (entries.length > 1 || entries.some((entry) => entry.section !== 'dependencies')) {
|
|
697
|
-
throw new Error('src-tauri/Cargo.toml must declare nimi-shell-tauri exactly once under [dependencies]');
|
|
698
|
-
}
|
|
699
|
-
const canonicalLine = `nimi-shell-tauri = "${version}"`;
|
|
700
|
-
if (entries.length === 1) {
|
|
701
|
-
lines[entries[0].index] = canonicalLine;
|
|
702
|
-
} else if (dependenciesHeader >= 0) {
|
|
703
|
-
let insertion = lines.length;
|
|
704
|
-
for (let index = dependenciesHeader + 1; index < lines.length; index += 1) {
|
|
705
|
-
if (/^\s*\[[^\]]+\]/u.test(lines[index])) {
|
|
706
|
-
insertion = index;
|
|
707
|
-
break;
|
|
708
|
-
}
|
|
709
|
-
}
|
|
710
|
-
if (insertion === lines.length && lines.at(-1) === '') insertion -= 1;
|
|
711
|
-
lines.splice(insertion, 0, canonicalLine);
|
|
712
|
-
} else {
|
|
713
|
-
if (lines.at(-1) === '') lines.pop();
|
|
714
|
-
if (lines.length > 0 && lines.at(-1) !== '') lines.push('');
|
|
715
|
-
lines.push('[dependencies]', canonicalLine);
|
|
716
|
-
}
|
|
717
|
-
const rendered = lines.join(newline);
|
|
718
|
-
return hadFinalNewline && !rendered.endsWith(newline) ? `${rendered}${newline}` : rendered;
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
function assertCargoManifestCurrent(source, version) {
|
|
722
|
-
const { entries } = cargoDependencyLocations(source);
|
|
723
|
-
const expected = `nimi-shell-tauri = "${version}"`;
|
|
724
|
-
if (entries.length !== 1 || entries[0].section !== 'dependencies' || entries[0].line !== expected) {
|
|
725
|
-
throw new Error(`src-tauri/Cargo.toml nimi-shell-tauri must use exact public version ${version}`);
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
function normalizeTauriConfig(config, appId) {
|
|
730
|
-
if (!config || typeof config !== 'object' || Array.isArray(config)) {
|
|
731
|
-
throw new Error('src-tauri/tauri.conf.json must contain an object');
|
|
732
|
-
}
|
|
733
|
-
const normalized = JSON.parse(JSON.stringify(config));
|
|
734
|
-
normalized.identifier = `ai.nimi.apps.${appId}`;
|
|
735
|
-
return `${JSON.stringify(normalized, null, 2)}\n`;
|
|
736
|
-
}
|
|
737
|
-
|
|
738
|
-
function assertTauriConfigCurrent(config, appId) {
|
|
739
|
-
const expected = `ai.nimi.apps.${appId}`;
|
|
740
|
-
if (config?.identifier !== expected) {
|
|
741
|
-
throw new Error(`src-tauri/tauri.conf.json identifier must be ${expected}`);
|
|
742
|
-
}
|
|
743
|
-
}
|
|
744
|
-
|
|
745
693
|
function normalizeStandaloneSourceFiles(targetDir, sources) {
|
|
746
694
|
const planned = [];
|
|
747
695
|
for (const name of ['vite.config.ts', 'vite.config.js', 'vite.config.mjs']) {
|
|
@@ -803,77 +751,24 @@ function tauriIdentifierFromAppId(appId) {
|
|
|
803
751
|
return `ai.nimi.apps.${appId}`;
|
|
804
752
|
}
|
|
805
753
|
|
|
806
|
-
function readProjectLifecycleFiles(targetDir,
|
|
754
|
+
function readProjectLifecycleFiles(targetDir, sources) {
|
|
807
755
|
const packagePath = path.join(targetDir, 'package.json');
|
|
808
756
|
if (!existsSync(packagePath)) throw new Error('Required App lifecycle file is missing: package.json');
|
|
809
|
-
const
|
|
757
|
+
const packageSource = readProjectText(targetDir, 'package.json', sources);
|
|
758
|
+
return {
|
|
810
759
|
packagePath,
|
|
811
|
-
packageSource
|
|
812
|
-
packageJson: JSON.parse(
|
|
813
|
-
cargoPath: null,
|
|
814
|
-
cargoSource: null,
|
|
815
|
-
tauriPath: null,
|
|
816
|
-
tauriSource: null,
|
|
817
|
-
tauriConfig: null,
|
|
760
|
+
packageSource,
|
|
761
|
+
packageJson: JSON.parse(packageSource),
|
|
818
762
|
};
|
|
819
|
-
if (buildProfileRef !== TAURI_BUILD_PROFILE_REF) return files;
|
|
820
|
-
files.cargoPath = path.join(targetDir, 'src-tauri', 'Cargo.toml');
|
|
821
|
-
files.tauriPath = path.join(targetDir, 'src-tauri', 'tauri.conf.json');
|
|
822
|
-
for (const requiredPath of [files.cargoPath, files.tauriPath]) {
|
|
823
|
-
if (!existsSync(requiredPath)) throw new Error(`Required App lifecycle file is missing: ${path.relative(targetDir, requiredPath)}`);
|
|
824
|
-
}
|
|
825
|
-
files.cargoSource = readProjectText(targetDir, 'src-tauri/Cargo.toml', sources);
|
|
826
|
-
files.tauriSource = readProjectText(targetDir, 'src-tauri/tauri.conf.json', sources);
|
|
827
|
-
files.tauriConfig = JSON.parse(files.tauriSource);
|
|
828
|
-
return files;
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
function readCargoPackageVersion(source) {
|
|
832
|
-
let inPackage = false;
|
|
833
|
-
for (const line of source.split(/\r?\n/u)) {
|
|
834
|
-
const header = line.match(/^\s*\[([^\]]+)\]\s*(?:#.*)?$/u);
|
|
835
|
-
if (header) {
|
|
836
|
-
inPackage = header[1] === 'package';
|
|
837
|
-
continue;
|
|
838
|
-
}
|
|
839
|
-
if (!inPackage) continue;
|
|
840
|
-
const match = line.match(/^\s*version\s*=\s*"([^"]+)"\s*(?:#.*)?$/u);
|
|
841
|
-
if (match) return match[1];
|
|
842
|
-
}
|
|
843
|
-
throw new Error('src-tauri/Cargo.toml [package] version is missing');
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
function readCargoPackageName(source) {
|
|
847
|
-
let inPackage = false;
|
|
848
|
-
for (const line of source.split(/\r?\n/u)) {
|
|
849
|
-
const header = line.match(/^\s*\[([^\]]+)\]\s*(?:#.*)?$/u);
|
|
850
|
-
if (header) {
|
|
851
|
-
inPackage = header[1] === 'package';
|
|
852
|
-
continue;
|
|
853
|
-
}
|
|
854
|
-
if (!inPackage) continue;
|
|
855
|
-
const match = line.match(/^\s*name\s*=\s*"([^"]+)"\s*(?:#.*)?$/u);
|
|
856
|
-
if (match) return match[1];
|
|
857
|
-
}
|
|
858
|
-
throw new Error('src-tauri/Cargo.toml [package] name is missing');
|
|
859
763
|
}
|
|
860
764
|
|
|
861
|
-
function assertVersionLockstep(files, descriptor
|
|
765
|
+
function assertVersionLockstep(files, descriptor) {
|
|
862
766
|
const version = files.packageJson.version;
|
|
863
767
|
if (typeof version !== 'string' || !SEMVER_PATTERN.test(version)) {
|
|
864
768
|
throw new Error('package.json version must be an exact semantic version');
|
|
865
769
|
}
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
observed.push(
|
|
869
|
-
['src-tauri/Cargo.toml', readCargoPackageVersion(files.cargoSource)],
|
|
870
|
-
['src-tauri/tauri.conf.json', files.tauriConfig.version],
|
|
871
|
-
);
|
|
872
|
-
}
|
|
873
|
-
for (const [name, candidate] of observed) {
|
|
874
|
-
if (candidate !== null && candidate !== undefined && candidate !== version) {
|
|
875
|
-
throw new Error(`${name} version must match package.json version ${version}`);
|
|
876
|
-
}
|
|
770
|
+
if (descriptor.version != null && descriptor.version !== version) {
|
|
771
|
+
throw new Error(`nimi.app.yaml version must match package.json version ${version}`);
|
|
877
772
|
}
|
|
878
773
|
return version;
|
|
879
774
|
}
|
|
@@ -918,12 +813,13 @@ function assertCanonicalAuthoringInputs(targetDir, descriptor, files, version, n
|
|
|
918
813
|
'support_manifest',
|
|
919
814
|
'review_inputs',
|
|
920
815
|
'admission_truth',
|
|
921
|
-
], ['ai_profile_recommendation_ref', SAFETY_PROFILE_FIELD]);
|
|
816
|
+
], ['ai_profile_recommendation_ref', SAFETY_PROFILE_FIELD, 'platform']);
|
|
922
817
|
const expectedSubmissionIdentity = {
|
|
923
818
|
app_id: descriptor.appId,
|
|
924
819
|
display_name: descriptor.displayName,
|
|
925
820
|
version,
|
|
926
821
|
profile: descriptor.profile,
|
|
822
|
+
...(descriptor.platform === 'web' ? { platform: 'web' } : {}),
|
|
927
823
|
npm_package_name: expectedIdentity.npm_package_name,
|
|
928
824
|
cargo_package_name: expectedIdentity.cargo_package_name,
|
|
929
825
|
tauri_identifier: expectedIdentity.tauri_identifier,
|
|
@@ -995,7 +891,7 @@ function isScopedComponentReleaseWorkflow(source, targetDir) {
|
|
|
995
891
|
});
|
|
996
892
|
}
|
|
997
893
|
|
|
998
|
-
function assertManagedWorkflowCurrent(targetDir, sources) {
|
|
894
|
+
function assertManagedWorkflowCurrent(targetDir, sources, hosted) {
|
|
999
895
|
const workflowPath = path.join(targetDir, MANAGED_WORKFLOW_PATH);
|
|
1000
896
|
if (!hasProjectFile(targetDir, MANAGED_WORKFLOW_PATH, sources)) throw new Error(`Required App lifecycle file is missing: ${MANAGED_WORKFLOW_PATH}`);
|
|
1001
897
|
if (readProjectText(targetDir, MANAGED_WORKFLOW_PATH, sources) !== managedAppReleaseWorkflowSource()) {
|
|
@@ -1005,6 +901,7 @@ function assertManagedWorkflowCurrent(targetDir, sources) {
|
|
|
1005
901
|
for (const name of existsSync(workflowDir) ? readdirSync(workflowDir).sort() : []) {
|
|
1006
902
|
const candidatePath = path.join(workflowDir, name);
|
|
1007
903
|
if (candidatePath === workflowPath || !/\.ya?ml$/iu.test(name)) continue;
|
|
904
|
+
if (hosted && name === 'nimi-web-release.yml') continue;
|
|
1008
905
|
const source = readFileSync(candidatePath, 'utf8');
|
|
1009
906
|
if (!isScopedComponentReleaseWorkflow(source, targetDir) && (
|
|
1010
907
|
/\bgh\s+release\s+(?:create|upload|edit|delete)\b/iu.test(source)
|
|
@@ -1053,6 +950,7 @@ function readBuildProfile(targetDir, sources) {
|
|
|
1053
950
|
const buildProfileRef = typeof profile.build_profile_ref === 'string'
|
|
1054
951
|
? profile.build_profile_ref
|
|
1055
952
|
: '';
|
|
953
|
+
assertDesktopHostSupport(buildProfileRef);
|
|
1056
954
|
if (!SUPPORTED_BUILD_PROFILE_REFS.has(buildProfileRef)) {
|
|
1057
955
|
throw new Error(`${BUILD_PROFILE_PATH} build_profile_ref is unsupported: ${String(profile.build_profile_ref)}`);
|
|
1058
956
|
}
|
|
@@ -1064,11 +962,11 @@ function readBuildProfile(targetDir, sources) {
|
|
|
1064
962
|
throw new Error(`${BUILD_PROFILE_PATH} must declare at least one target`);
|
|
1065
963
|
}
|
|
1066
964
|
for (const [targetId, target] of Object.entries(targets)) {
|
|
1067
|
-
const expected = CURRENT_APP_TARGETS[targetId];
|
|
965
|
+
const expected = buildProfileRef === 'web-pnpm' ? (targetId === 'web' ? {} : null) : CURRENT_APP_TARGETS[targetId];
|
|
1068
966
|
if (!expected || !target || typeof target !== 'object' || Array.isArray(target)) {
|
|
1069
967
|
throw new Error(`${BUILD_PROFILE_PATH} declares unsupported target: ${targetId}`);
|
|
1070
968
|
}
|
|
1071
|
-
if (target.os !== expected.os || target.arch !== expected.arch) {
|
|
969
|
+
if (buildProfileRef !== 'web-pnpm' && (target.os !== expected.os || target.arch !== expected.arch)) {
|
|
1072
970
|
throw new Error(`${BUILD_PROFILE_PATH} target identity mismatch: ${targetId}`);
|
|
1073
971
|
}
|
|
1074
972
|
}
|
|
@@ -1087,7 +985,7 @@ function currentTargetId() {
|
|
|
1087
985
|
}
|
|
1088
986
|
|
|
1089
987
|
function selectBuildOwner(profile, requestedTarget) {
|
|
1090
|
-
const target = String(requestedTarget || '').trim() || currentTargetId();
|
|
988
|
+
const target = String(requestedTarget || '').trim() || (profile.buildProfileRef === 'web-pnpm' ? 'web' : currentTargetId());
|
|
1091
989
|
const targetProfile = profile.targets[target];
|
|
1092
990
|
if (Object.keys(profile.targets).length > 0 && (!targetProfile || typeof targetProfile !== 'object' || Array.isArray(targetProfile))) {
|
|
1093
991
|
throw new Error(`Unsupported App build target: ${target}`);
|
|
@@ -1147,31 +1045,24 @@ function assertProjectLifecycleCurrent(targetDir, versions, options = {}) {
|
|
|
1147
1045
|
const sources = options.sources;
|
|
1148
1046
|
const descriptor = readSubmittedManifest(targetDir, sources);
|
|
1149
1047
|
const buildProfile = readBuildProfile(targetDir, sources);
|
|
1150
|
-
|
|
1048
|
+
if ((descriptor.platform === 'web') !== (buildProfile.buildProfileRef === 'web-pnpm')) throw new Error('Manifest platform and build owner disagree.');
|
|
1049
|
+
const files = readProjectLifecycleFiles(targetDir, sources);
|
|
1151
1050
|
const combination = selectDependencyCombination(files.packageJson, versions, options.managed === true);
|
|
1152
|
-
assertPackageManifestCurrent(files.packageJson, versions, combination);
|
|
1153
|
-
const version = assertVersionLockstep(files, descriptor
|
|
1154
|
-
|
|
1051
|
+
assertPackageManifestCurrent(files.packageJson, versions, combination, descriptor.platform);
|
|
1052
|
+
const version = assertVersionLockstep(files, descriptor);
|
|
1053
|
+
const nativeIdentity = {
|
|
1155
1054
|
cargoPackageName: cargoPackageNameFromNpmPackageName(files.packageJson.name),
|
|
1156
1055
|
tauriIdentifier: tauriIdentifierFromAppId(descriptor.appId),
|
|
1157
1056
|
};
|
|
1158
|
-
if (buildProfile.buildProfileRef === TAURI_BUILD_PROFILE_REF) {
|
|
1159
|
-
assertCargoManifestCurrent(files.cargoSource, combination.nimiShellTauriVersion);
|
|
1160
|
-
assertTauriConfigCurrent(files.tauriConfig, descriptor.appId);
|
|
1161
|
-
nativeIdentity = {
|
|
1162
|
-
cargoPackageName: readCargoPackageName(files.cargoSource),
|
|
1163
|
-
tauriIdentifier: files.tauriConfig.identifier,
|
|
1164
|
-
};
|
|
1165
|
-
}
|
|
1166
1057
|
assertNoStandaloneParentSources(targetDir, sources);
|
|
1167
1058
|
const authoring = assertCanonicalAuthoringInputs(targetDir, descriptor, files, version, nativeIdentity, sources);
|
|
1168
|
-
|
|
1059
|
+
if (descriptor.publicSlug && (!hasProjectFile(targetDir, HOSTED_WEB_WORKFLOW_PATH, sources) || readProjectText(targetDir, HOSTED_WEB_WORKFLOW_PATH, sources).replaceAll('\r\n', '\n') !== hostedWorkflowSource())) {
|
|
1060
|
+
throw new Error('The hosted Web workflow must match App Tools. Use nimi-app sync to install its reviewed template.');
|
|
1061
|
+
}
|
|
1062
|
+
if (descriptor.platform !== 'web') assertManagedWorkflowCurrent(targetDir, sources, Boolean(descriptor.publicSlug));
|
|
1169
1063
|
const localPackages = assertPnpmWorkspaceCurrent(targetDir, sources, options.production === true);
|
|
1170
1064
|
if (options.requireInstalledLock === true) {
|
|
1171
1065
|
assertPnpmLockCurrent(targetDir, files.packageJson, localPackages, versions, combination);
|
|
1172
|
-
if (buildProfile.buildProfileRef === TAURI_BUILD_PROFILE_REF) {
|
|
1173
|
-
assertCargoLockCurrent(targetDir, combination.nimiShellTauriVersion);
|
|
1174
|
-
}
|
|
1175
1066
|
}
|
|
1176
1067
|
return { descriptor, files, version, buildProfile, authoring, combination };
|
|
1177
1068
|
}
|
|
@@ -1179,37 +1070,30 @@ function assertProjectLifecycleCurrent(targetDir, versions, options = {}) {
|
|
|
1179
1070
|
function buildExistingSubmittedAppSyncPlan(targetDir, versions, sources, managed = false) {
|
|
1180
1071
|
const descriptor = readSubmittedManifest(targetDir, sources);
|
|
1181
1072
|
const buildProfile = readBuildProfile(targetDir, sources);
|
|
1182
|
-
|
|
1073
|
+
if ((descriptor.platform === 'web') !== (buildProfile.buildProfileRef === 'web-pnpm')) throw new Error('Manifest platform and build owner disagree.');
|
|
1074
|
+
const files = readProjectLifecycleFiles(targetDir, sources);
|
|
1183
1075
|
const version = files.packageJson.version;
|
|
1184
1076
|
if (typeof version !== 'string' || !SEMVER_PATTERN.test(version)) {
|
|
1185
1077
|
throw new Error('package.json version must be an exact semantic version before sync');
|
|
1186
1078
|
}
|
|
1187
|
-
const requiresTauri = buildProfile.buildProfileRef === TAURI_BUILD_PROFILE_REF;
|
|
1188
1079
|
const combination = selectDependencyCombination(files.packageJson, versions, managed);
|
|
1080
|
+
const lockPath = path.join(targetDir, 'pnpm-lock.yaml');
|
|
1081
|
+
const importer = existsSync(lockPath) ? parseYamlFile(readFileSync(lockPath, 'utf8'), lockPath)?.importers?.['.'] : null;
|
|
1082
|
+
const toolchainUpdates = planToolchainUpdates(files.packageJson, importer, versions);
|
|
1189
1083
|
const identity = {
|
|
1190
1084
|
appId: descriptor.appId,
|
|
1191
1085
|
appTitle: descriptor.displayName,
|
|
1192
1086
|
version,
|
|
1193
1087
|
profile: descriptor.profile,
|
|
1088
|
+
...(descriptor.platform === 'web' ? { platform: 'web' } : {}),
|
|
1194
1089
|
packageName: files.packageJson.name,
|
|
1195
|
-
cargoPackageName:
|
|
1196
|
-
|
|
1197
|
-
: cargoPackageNameFromNpmPackageName(files.packageJson.name),
|
|
1198
|
-
tauriIdentifier: requiresTauri
|
|
1199
|
-
? files.tauriConfig.identifier
|
|
1200
|
-
: tauriIdentifierFromAppId(descriptor.appId),
|
|
1090
|
+
cargoPackageName: cargoPackageNameFromNpmPackageName(files.packageJson.name),
|
|
1091
|
+
tauriIdentifier: tauriIdentifierFromAppId(descriptor.appId),
|
|
1201
1092
|
author: typeof files.packageJson.author === 'string' ? files.packageJson.author : '',
|
|
1202
1093
|
};
|
|
1203
1094
|
const planned = [
|
|
1204
|
-
{ path: files.packagePath, content: normalizePackageManifest(files.packageJson, descriptor, versions, buildProfile.buildProfileRef, files.packageSource, combination), previous: files.packageSource },
|
|
1095
|
+
{ path: files.packagePath, content: normalizePackageManifest(files.packageJson, descriptor, versions, buildProfile.buildProfileRef, files.packageSource, combination, toolchainUpdates), previous: files.packageSource },
|
|
1205
1096
|
];
|
|
1206
|
-
if (requiresTauri) {
|
|
1207
|
-
planned.push(
|
|
1208
|
-
{ path: files.cargoPath, content: normalizeCargoManifest(files.cargoSource, combination.nimiShellTauriVersion), previous: files.cargoSource },
|
|
1209
|
-
{ path: files.tauriPath, content: normalizeTauriConfig(files.tauriConfig, descriptor.appId), previous: files.tauriSource },
|
|
1210
|
-
);
|
|
1211
|
-
identity.tauriIdentifier = tauriIdentifierFromAppId(descriptor.appId);
|
|
1212
|
-
}
|
|
1213
1097
|
planned.push(...normalizeStandaloneSourceFiles(targetDir, sources));
|
|
1214
1098
|
const identityPath = path.join(targetDir, APP_IDENTITY_PATH);
|
|
1215
1099
|
planned.push({
|
|
@@ -1238,7 +1122,7 @@ function buildExistingSubmittedAppSyncPlan(targetDir, versions, sources, managed
|
|
|
1238
1122
|
'support_manifest',
|
|
1239
1123
|
'review_inputs',
|
|
1240
1124
|
'admission_truth',
|
|
1241
|
-
], ['ai_profile_recommendation_ref', SAFETY_PROFILE_FIELD]);
|
|
1125
|
+
], ['ai_profile_recommendation_ref', SAFETY_PROFILE_FIELD, 'platform']);
|
|
1242
1126
|
canonicalInputList(currentSubmission.capability_contract_refs, `${SUBMISSION_PATH} capability_contract_refs`);
|
|
1243
1127
|
canonicalInputList(currentSubmission.required_standardized_feature_refs, `${SUBMISSION_PATH} required_standardized_feature_refs`);
|
|
1244
1128
|
normalizeStorageInput(currentSubmission.storage_policy, `${SUBMISSION_PATH} storage_policy`);
|
|
@@ -1281,26 +1165,18 @@ function buildExistingSubmittedAppSyncPlan(targetDir, versions, sources, managed
|
|
|
1281
1165
|
content: normalizedBuildProfile,
|
|
1282
1166
|
previous: currentBuildProfile,
|
|
1283
1167
|
});
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1168
|
+
if (descriptor.platform !== 'web') {
|
|
1169
|
+
const workflowPath = path.join(targetDir, MANAGED_WORKFLOW_PATH);
|
|
1170
|
+
planned.push({
|
|
1171
|
+
path: workflowPath,
|
|
1172
|
+
content: managedAppReleaseWorkflowSource(),
|
|
1173
|
+
previous: existsSync(workflowPath) ? readFileSync(workflowPath, 'utf8') : '',
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1176
|
+
if (descriptor.publicSlug) planned.push(planHostedWorkflow(targetDir));
|
|
1290
1177
|
const workspace = normalizePnpmWorkspace(targetDir);
|
|
1291
1178
|
if (workspace) planned.push(workspace);
|
|
1292
|
-
return { descriptor, planned: planned.map((file) => plannedFile(targetDir, path.relative(targetDir, file.path), file.content)), buildProfileRef: buildProfile.buildProfileRef, combination };
|
|
1293
|
-
}
|
|
1294
|
-
|
|
1295
|
-
function lifecycleNextSteps(buildProfileRef, combination) {
|
|
1296
|
-
return [
|
|
1297
|
-
'pnpm install',
|
|
1298
|
-
...(buildProfileRef === TAURI_BUILD_PROFILE_REF
|
|
1299
|
-
? [`cargo update -p nimi-shell-tauri --precise ${combination.nimiShellTauriVersion}`]
|
|
1300
|
-
: []),
|
|
1301
|
-
'nimi-app sync',
|
|
1302
|
-
'nimi-app check',
|
|
1303
|
-
];
|
|
1179
|
+
return { descriptor, planned: planned.map((file) => plannedFile(targetDir, path.relative(targetDir, file.path), file.content)), buildProfileRef: buildProfile.buildProfileRef, combination, toolchainUpdates, packageJson: files.packageJson };
|
|
1304
1180
|
}
|
|
1305
1181
|
|
|
1306
1182
|
function runNimicodingSync(targetDir, mode, runners) {
|
|
@@ -1332,11 +1208,14 @@ function validateProjectPlan(targetDir, versions, planned, managed) {
|
|
|
1332
1208
|
|
|
1333
1209
|
export function validateAppInitialization(targetDir, versions) {
|
|
1334
1210
|
const effective = managedProjectVersions(targetDir, versions);
|
|
1335
|
-
const
|
|
1211
|
+
const planned = readSubmittedManifest(targetDir).publicSlug ? [planHostedWorkflow(targetDir)] : [];
|
|
1212
|
+
const current = assertProjectLifecycleCurrent(targetDir, effective, { managed: true, sources: planSources(targetDir, planned) });
|
|
1336
1213
|
for (const target of Object.keys(current.buildProfile.targets)) selectBuildOwner(current.buildProfile, target);
|
|
1214
|
+
return planned;
|
|
1337
1215
|
}
|
|
1338
1216
|
|
|
1339
1217
|
function ownershipHandoverMessage(handover) {
|
|
1218
|
+
if (handover.path.startsWith('src-tauri/')) return `${handover.path} leaves scaffold management (${handover.file}).`;
|
|
1340
1219
|
if (handover.file === 'missing') {
|
|
1341
1220
|
return `${handover.path} now belongs to the App and is missing; add the App's own ${handover.path} before packaging.`;
|
|
1342
1221
|
}
|
|
@@ -1355,19 +1234,37 @@ function executeProjectPlan(targetDir, options, versions, runners, plan, scaffol
|
|
|
1355
1234
|
if (scaffold) validateManagedAppFiles(targetDir, scaffold.snapshot.lock, planSources(targetDir, plan.planned));
|
|
1356
1235
|
validateProjectPlan(targetDir, versions, plan.planned, Boolean(scaffold));
|
|
1357
1236
|
const handovers = scaffold?.handovers ?? [];
|
|
1237
|
+
const dependencyChanges = expectedNimiDependencies(versions, plan.combination, plan.packageJson).flatMap(({ name, section, version }) => {
|
|
1238
|
+
const declared = plan.packageJson[section]?.[name] ?? null;
|
|
1239
|
+
const from = declared === version ? scaffold?.previousDependencies?.[name] ?? declared : declared;
|
|
1240
|
+
return from === version ? [] : [{ name, from, to: version, kind: section === 'devDependencies' ? 'tool' : 'sdk-kit' }];
|
|
1241
|
+
});
|
|
1242
|
+
const manual = plan.toolchainUpdates.filter(update => update.manual);
|
|
1358
1243
|
const preview = {
|
|
1244
|
+
dependencyChanges, toolchainUpdates: plan.toolchainUpdates, readyToApply: manual.length === 0,
|
|
1359
1245
|
ok: true, command: options.adopt ? 'init' : 'sync', dir: targetDir,
|
|
1360
1246
|
managed: Boolean(scaffold), appId: plan.descriptor.appId,
|
|
1361
1247
|
dryRun: options.dryRun === true, skillPath: LIFECYCLE_SKILL_PATH,
|
|
1362
1248
|
changes: describeChanges(targetDir, plan.planned), ownerSteps: lifecycleOwnerSteps(versions),
|
|
1363
|
-
nextSteps:
|
|
1249
|
+
nextSteps: [...plan.toolchainUpdates.filter(dep => dep.lockedAffected && dep.from === dep.to && !dep.manual)
|
|
1250
|
+
.map(dep => `pnpm update ${dep.name}`), 'pnpm install', 'nimi-app sync', 'nimi-app check'],
|
|
1364
1251
|
dependencyCombination: describeCombination(plan.combination, toolVersions),
|
|
1252
|
+
...(scaffold ? { retainedHostFiles: scaffold.snapshot.retainedHostFiles ?? [] } : {}),
|
|
1365
1253
|
...(scaffold ? { ownershipHandover: handovers } : {}),
|
|
1366
1254
|
};
|
|
1255
|
+
if (!options.json) {
|
|
1256
|
+
if (preview.retainedHostFiles?.length) process.stdout.write(`[nimi-app] Retained ${preview.retainedHostFiles.length} locked Host files for the selected SDK/Kit combination.\n`);
|
|
1257
|
+
for (const dep of dependencyChanges) process.stdout.write(`[nimi-app] ${dep.kind}: ${dep.name} ${dep.from ?? '(unset)'} -> ${dep.to}\n`);
|
|
1258
|
+
for (const dep of plan.toolchainUpdates) {
|
|
1259
|
+
const action = dep.manual ? 'select a patched range manually' : `sync target ${dep.to}`;
|
|
1260
|
+
process.stdout.write(`[nimi-app] ${dep.name}: declared ${dep.from}, locked ${dep.locked ?? '(unresolved)'}, ${action} (fix ${dep.fixedVersion})\n`);
|
|
1261
|
+
}
|
|
1262
|
+
}
|
|
1367
1263
|
if (options.dryRun) {
|
|
1368
1264
|
emitOwnershipHandovers(handovers, options);
|
|
1369
1265
|
return emitResult(preview, options, `${preview.command} preview: ${preview.changes.map((file) => `${file.action} ${file.path}`).join(', ') || 'no app-tools changes'}`);
|
|
1370
1266
|
}
|
|
1267
|
+
if (manual.length) throw new Error('Select a patched dependency in package.json before sync: ' + manual.map(dep => `${dep.name}@${dep.from} (fixed in ${dep.fixedVersion})`).join(', '));
|
|
1371
1268
|
const nimicoding = runNimicodingSync(targetDir, 'apply', runners);
|
|
1372
1269
|
const lockPath = path.join(targetDir, SCAFFOLD_LOCK_PATH);
|
|
1373
1270
|
const lockFile = plan.planned.find((file) => file.path === lockPath);
|
|
@@ -1382,6 +1279,7 @@ function executeProjectPlan(targetDir, options, versions, runners, plan, scaffol
|
|
|
1382
1279
|
}
|
|
1383
1280
|
validateAppProject(targetDir, { silent: true }, versions, runners);
|
|
1384
1281
|
emitOwnershipHandovers(handovers, options);
|
|
1282
|
+
if (!options.json && (dependencyChanges.length || plan.toolchainUpdates.length)) process.stdout.write(`[nimi-app] Next: ${preview.nextSteps.join(' -> ')}\n`);
|
|
1385
1283
|
return emitResult({ ...preview, synchronizedFiles, nimicodingSync: nimicoding?.summary || null }, options, `${preview.command} completed for ${targetDir}`);
|
|
1386
1284
|
}
|
|
1387
1285
|
|
|
@@ -1435,8 +1333,7 @@ export function adoptAppProject(cwd, options = {}, versions, runners = {}) {
|
|
|
1435
1333
|
} catch (cause) {
|
|
1436
1334
|
throw new Error(`${cause.message}. Prepare the real App-owned Host and build/test inputs using ${LIFECYCLE_SKILL_PATH}`, { cause });
|
|
1437
1335
|
}
|
|
1438
|
-
|
|
1439
|
-
const files = readProjectLifecycleFiles(targetDir, plan.buildProfileRef);
|
|
1336
|
+
const files = readProjectLifecycleFiles(targetDir, sources);
|
|
1440
1337
|
const profile = readBuildProfile(targetDir, sources);
|
|
1441
1338
|
for (const command of [profile.testCommand, profile.buildCommand, ...Object.keys(profile.targets).map((target) => selectBuildOwner(profile, target).command)]) {
|
|
1442
1339
|
const script = command.match(/^pnpm\s+run\s+([^\s]+)(?:\s|$)/u)?.[1];
|
|
@@ -1466,7 +1363,8 @@ export function checkAppProject(cwd, options = {}, versions, runners = {}) {
|
|
|
1466
1363
|
if (!managed) nimicoding = runNimicodingSync(targetDir, 'check', runners);
|
|
1467
1364
|
const { descriptor, buildProfile, combination } = existingState || assertProjectLifecycleCurrent(targetDir, effective, { requireInstalledLock: true, production: options.production === true, managed });
|
|
1468
1365
|
if (options.production === true) {
|
|
1469
|
-
|
|
1366
|
+
if (descriptor.platform === 'web' && !descriptor.publicSlug) throw new Error('Web release preflight requires a hosted public_slug; use development check for other Web sources.');
|
|
1367
|
+
if (descriptor.platform !== 'web') for (const target of Object.keys(buildProfile.targets)) readAppInfo(targetDir, target);
|
|
1470
1368
|
}
|
|
1471
1369
|
const safetyProfile = descriptor.safetyProfile ? 'declared' : 'undeclared';
|
|
1472
1370
|
if (options.production === true && !options.json && safetyProfile === 'undeclared') {
|
|
@@ -1480,6 +1378,7 @@ export function checkAppProject(cwd, options = {}, versions, runners = {}) {
|
|
|
1480
1378
|
managed,
|
|
1481
1379
|
appId: descriptor.appId,
|
|
1482
1380
|
profile: descriptor.profile,
|
|
1381
|
+
...(descriptor.platform === 'web' ? { platform: 'web' } : {}),
|
|
1483
1382
|
safetyProfile,
|
|
1484
1383
|
dependencyCombination: describeCombination(combination, versions),
|
|
1485
1384
|
targets: Object.keys(buildProfile.targets).sort(),
|
|
@@ -1492,6 +1391,11 @@ export function checkAppProject(cwd, options = {}, versions, runners = {}) {
|
|
|
1492
1391
|
export function testAppProject(cwd, options = {}, runners = {}) {
|
|
1493
1392
|
const targetDir = resolveTargetDir(cwd, options);
|
|
1494
1393
|
const profile = readBuildProfile(targetDir);
|
|
1394
|
+
if (profile.testCommand === 'pnpm run test:app'
|
|
1395
|
+
&& readJsonFile(path.join(targetDir, 'package.json'), 'package.json').scripts?.['test:app'] === 'node --test test/*.test.mjs'
|
|
1396
|
+
&& globSync('test/*.test.mjs', { cwd: targetDir }).length === 0) {
|
|
1397
|
+
throw new Error('No App tests found. Add a business test under test/*.test.mjs or configure the App-owned test:app script.');
|
|
1398
|
+
}
|
|
1495
1399
|
const result = runOwnerCommand(targetDir, 'test', profile.testCommand, options, runners);
|
|
1496
1400
|
return emitResult({
|
|
1497
1401
|
ok: true,
|
|
@@ -1506,6 +1410,7 @@ export function buildAppProject(cwd, options = {}, runners = {}) {
|
|
|
1506
1410
|
const targetDir = resolveTargetDir(cwd, options);
|
|
1507
1411
|
const profile = readBuildProfile(targetDir);
|
|
1508
1412
|
const selected = selectBuildOwner(profile, options.target);
|
|
1413
|
+
if (options.production === true && profile.buildProfileRef === 'web-pnpm') throw new Error('For a hosted Web release, use nimi-app check --production and your build:release script. Use nimi-app build for ordinary static output.');
|
|
1509
1414
|
if (options.production === true) readAppInfo(targetDir, selected.target);
|
|
1510
1415
|
const result = runOwnerCommand(targetDir, 'build', selected.command, options, runners);
|
|
1511
1416
|
assertBuiltRuntimeEntry(targetDir, selected);
|