@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
|
@@ -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';
|
|
@@ -50,9 +54,12 @@ const SYNCHRONIZED_NIMI_PACKAGES = new Set([
|
|
|
50
54
|
const BUILD_PROFILE_PATH = '.nimi/config/build-profile.yaml';
|
|
51
55
|
const ELECTRON_BUILD_PROFILE_REF = 'electron-packager-pnpm-vite';
|
|
52
56
|
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]);
|
|
57
|
+
const SUPPORTED_BUILD_PROFILE_REFS = new Set([ELECTRON_BUILD_PROFILE_REF, APP_OWNED_ELECTRON_BUILD_PROFILE_REF, 'web-pnpm']);
|
|
55
58
|
const MANAGED_WORKFLOW_PATH = '.github/workflows/nimi-app-release.yml';
|
|
59
|
+
const HOSTED_WEB_WORKFLOW_PATH = '.github/workflows/nimi-web-release.yml';
|
|
60
|
+
function hostedWorkflowSource() {
|
|
61
|
+
return readFileSync(new URL('../templates/hosted-web-release.yml', import.meta.url), 'utf8').replaceAll('\r\n', '\n');
|
|
62
|
+
}
|
|
56
63
|
const APP_IDENTITY_PATH = '.nimi/config/app-identity.yaml';
|
|
57
64
|
const SUBMISSION_PATH = '.nimi/admission/submission.yaml';
|
|
58
65
|
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 +112,7 @@ function readSubmittedManifest(targetDir, sources) {
|
|
|
105
112
|
|| appId !== document?.app_id
|
|
106
113
|
|| !displayName.trim()
|
|
107
114
|
|| displayName !== displayName.trim()
|
|
108
|
-
||
|
|
115
|
+
|| !isAppId(appId)
|
|
109
116
|
|| !SUPPORTED_APP_SCAFFOLD_PROFILES.includes(profile)
|
|
110
117
|
) {
|
|
111
118
|
throw new Error('Existing submitted app requires canonical app_id and supported profile');
|
|
@@ -113,7 +120,10 @@ function readSubmittedManifest(targetDir, sources) {
|
|
|
113
120
|
if (document?.manifest_role !== 'submitted-input') {
|
|
114
121
|
throw new Error('Submitted manifest marker missing');
|
|
115
122
|
}
|
|
116
|
-
const
|
|
123
|
+
const platform = document.platform || 'desktop';
|
|
124
|
+
if (!['desktop', 'web'].includes(platform)) throw new Error('Unsupported App platform.');
|
|
125
|
+
const hosted = Object.hasOwn(document, 'public_slug') ? hostedWebIdentity(appId, document.public_slug) : null;
|
|
126
|
+
const rendererOrigin = platform === 'web' ? (hosted?.origin ?? readWebDevelopment(document).site.origin) : document?.local_development?.electron?.renderer_origin;
|
|
117
127
|
let parsedOrigin;
|
|
118
128
|
try {
|
|
119
129
|
parsedOrigin = new URL(rendererOrigin);
|
|
@@ -123,9 +133,7 @@ function readSubmittedManifest(targetDir, sources) {
|
|
|
123
133
|
if (
|
|
124
134
|
typeof rendererOrigin !== 'string'
|
|
125
135
|
|| rendererOrigin.trim() !== rendererOrigin
|
|
126
|
-
|| parsedOrigin.protocol !== 'http:'
|
|
127
|
-
|| parsedOrigin.hostname !== '127.0.0.1'
|
|
128
|
-
|| !parsedOrigin.port
|
|
136
|
+
|| (platform === 'desktop' && (parsedOrigin.protocol !== 'http:' || parsedOrigin.hostname !== '127.0.0.1' || !parsedOrigin.port))
|
|
129
137
|
|| parsedOrigin.username
|
|
130
138
|
|| parsedOrigin.password
|
|
131
139
|
|| parsedOrigin.pathname !== '/'
|
|
@@ -150,7 +158,7 @@ function readSubmittedManifest(targetDir, sources) {
|
|
|
150
158
|
throw new Error(`nimi.app.yaml ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
151
159
|
}
|
|
152
160
|
}
|
|
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 });
|
|
161
|
+
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
162
|
}
|
|
155
163
|
|
|
156
164
|
function assertNoRetiredScaffoldState(targetDir) {
|
|
@@ -167,12 +175,12 @@ function assertNoRetiredScaffoldState(targetDir) {
|
|
|
167
175
|
|
|
168
176
|
// The SDK/Kit pair comes from the App's resolved combination; the tool
|
|
169
177
|
// dependencies come from the selected tool version. Both are one judgment
|
|
170
|
-
// shared by manifest, lock
|
|
171
|
-
function expectedNimiDependencies(versions, combination) {
|
|
178
|
+
// shared by manifest, lock and workflow checks.
|
|
179
|
+
function expectedNimiDependencies(versions, combination, packageJson) {
|
|
172
180
|
return Object.freeze([
|
|
173
181
|
Object.freeze({ name: '@nimiplatform/sdk', section: 'dependencies', version: combination.sdkVersion }),
|
|
174
182
|
Object.freeze({ name: '@nimiplatform/kit', section: 'dependencies', version: combination.kitVersion }),
|
|
175
|
-
Object.freeze({ name: '@nimiplatform/app-tools', section: 'devDependencies', version: versions.appToolsVersion }),
|
|
183
|
+
Object.freeze({ name: '@nimiplatform/app-tools', section: 'devDependencies', version: appToolsDeclaration(packageJson.devDependencies?.['@nimiplatform/app-tools'], versions.appToolsVersion) }),
|
|
176
184
|
Object.freeze({ name: '@nimiplatform/nimi-coding', section: 'devDependencies', version: versions.nimicodingVersion }),
|
|
177
185
|
]);
|
|
178
186
|
}
|
|
@@ -191,13 +199,16 @@ function selectDependencyCombination(packageJson, versions, managed) {
|
|
|
191
199
|
function managedProjectVersions(targetDir, versions) {
|
|
192
200
|
const packagePath = path.join(targetDir, 'package.json');
|
|
193
201
|
if (!existsSync(packagePath)) return versions;
|
|
194
|
-
const
|
|
195
|
-
|
|
202
|
+
const pkg = readJsonFile(packagePath, 'package.json');
|
|
203
|
+
const combination = resolveDependencyCombination(pkg, versions);
|
|
204
|
+
const appToolsVersion = appToolsDeclaration(pkg.devDependencies?.['@nimiplatform/app-tools'], versions.appToolsVersion);
|
|
205
|
+
return Object.freeze({ ...versions, ...combination, appToolsVersion });
|
|
196
206
|
}
|
|
197
207
|
|
|
198
208
|
function describeCombination(combination, toolVersions) {
|
|
199
|
-
const
|
|
200
|
-
|
|
209
|
+
const dependencies = { '@nimiplatform/sdk': combination.sdkVersion, '@nimiplatform/kit': combination.kitVersion };
|
|
210
|
+
const { source } = resolveDependencyCombination({ dependencies }, toolVersions);
|
|
211
|
+
return { sdk: combination.sdkVersion, kit: combination.kitVersion, source };
|
|
201
212
|
}
|
|
202
213
|
|
|
203
214
|
function dependencySection(packageJson, sectionName) {
|
|
@@ -209,13 +220,6 @@ function dependencySection(packageJson, sectionName) {
|
|
|
209
220
|
return section;
|
|
210
221
|
}
|
|
211
222
|
|
|
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
223
|
function localPackageArchive(value) {
|
|
220
224
|
return typeof value === 'string' ? value.match(/^(file:[^\r\n]+?\.(?:tgz|tar\.gz))(?:\(.*\))?$/u)?.[1] || '' : '';
|
|
221
225
|
}
|
|
@@ -255,7 +259,7 @@ function assertPublicNimiDependencySpecs(packageJson) {
|
|
|
255
259
|
}
|
|
256
260
|
}
|
|
257
261
|
|
|
258
|
-
function assertPackageManifestCurrent(packageJson, versions, combination) {
|
|
262
|
+
function assertPackageManifestCurrent(packageJson, versions, combination, platform = 'desktop') {
|
|
259
263
|
if (packageJson.private !== true || Object.hasOwn(packageJson, 'publishConfig')) {
|
|
260
264
|
throw new Error('Nimi App package.json must be private and must not declare npm publishConfig');
|
|
261
265
|
}
|
|
@@ -263,7 +267,7 @@ function assertPackageManifestCurrent(packageJson, versions, combination) {
|
|
|
263
267
|
throw new Error(`package.json packageManager must be ${versions.packageManager}`);
|
|
264
268
|
}
|
|
265
269
|
assertPublicNimiDependencySpecs(packageJson);
|
|
266
|
-
for (const expected of expectedNimiDependencies(versions, combination)) {
|
|
270
|
+
for (const expected of expectedNimiDependencies(versions, combination, packageJson)) {
|
|
267
271
|
const section = dependencySection(packageJson, expected.section);
|
|
268
272
|
if (section?.[expected.name] !== expected.version) {
|
|
269
273
|
throw new Error(`package.json ${expected.section}.${expected.name} must be ${expected.version}`);
|
|
@@ -296,24 +300,25 @@ function assertPackageManifestCurrent(packageJson, versions, combination) {
|
|
|
296
300
|
throw new Error(`package.json scripts.${name} must not mutate managed App state during dependency installation`);
|
|
297
301
|
}
|
|
298
302
|
}
|
|
299
|
-
if (scripts.pack !== 'nimi-app pack') {
|
|
303
|
+
if (platform === 'desktop' && scripts.pack !== 'nimi-app pack') {
|
|
300
304
|
throw new Error('package.json scripts.pack must use the canonical nimi-app pack owner');
|
|
301
305
|
}
|
|
302
|
-
if (scripts.publish !== undefined) {
|
|
306
|
+
if (platform === 'desktop' && scripts.publish !== undefined) {
|
|
303
307
|
throw new Error('package.json scripts.publish is unavailable until publisher GitHub and registry orchestration is implemented');
|
|
304
308
|
}
|
|
305
309
|
return combination;
|
|
306
310
|
}
|
|
307
311
|
|
|
308
|
-
function normalizePackageManifest(packageJson, descriptor, versions, buildProfileRef, packageSource, combination) {
|
|
312
|
+
function normalizePackageManifest(packageJson, descriptor, versions, buildProfileRef, packageSource, combination, toolchainUpdates) {
|
|
309
313
|
if (!packageJson || typeof packageJson !== 'object' || Array.isArray(packageJson)) {
|
|
310
314
|
throw new Error('package.json must contain an object');
|
|
311
315
|
}
|
|
312
316
|
const normalized = JSON.parse(JSON.stringify(packageJson));
|
|
313
317
|
normalized.private = true;
|
|
314
318
|
delete normalized.publishConfig;
|
|
319
|
+
for (const { section, name, to } of toolchainUpdates) normalized[section][name] = to;
|
|
315
320
|
for (const sectionName of NPM_DEPENDENCY_SECTIONS) dependencySection(normalized, sectionName);
|
|
316
|
-
for (const expected of expectedNimiDependencies(versions, combination)) {
|
|
321
|
+
for (const expected of expectedNimiDependencies(versions, combination, packageJson)) {
|
|
317
322
|
for (const sectionName of NPM_DEPENDENCY_SECTIONS) {
|
|
318
323
|
const section = dependencySection(normalized, sectionName);
|
|
319
324
|
if (section) delete section[expected.name];
|
|
@@ -332,6 +337,11 @@ function normalizePackageManifest(packageJson, descriptor, versions, buildProfil
|
|
|
332
337
|
if (!normalized.scripts || typeof normalized.scripts !== 'object' || Array.isArray(normalized.scripts)) {
|
|
333
338
|
throw new Error('package.json scripts must be an object');
|
|
334
339
|
}
|
|
340
|
+
if (descriptor.platform === 'web') {
|
|
341
|
+
normalized.scripts.dev = 'nimi-app dev --platform web';
|
|
342
|
+
normalized.scripts.sync ||= 'nimi-app sync';
|
|
343
|
+
if (normalized.scripts.pack === 'nimi-app pack') delete normalized.scripts.pack;
|
|
344
|
+
} else {
|
|
335
345
|
if (typeof normalized.scripts['build:electron'] !== 'string' || !normalized.scripts['build:electron'].trim()) {
|
|
336
346
|
throw new Error('package.json build:electron must build the Desktop-supervised Electron host');
|
|
337
347
|
}
|
|
@@ -344,6 +354,7 @@ function normalizePackageManifest(packageJson, descriptor, versions, buildProfil
|
|
|
344
354
|
normalized.scripts.sync ||= 'nimi-app sync';
|
|
345
355
|
normalized.scripts.pack = 'nimi-app pack';
|
|
346
356
|
delete normalized.scripts.publish;
|
|
357
|
+
}
|
|
347
358
|
for (const name of ['doctor', 'update']) {
|
|
348
359
|
if (/^nimi-app\s+(?:doctor|update)$/u.test(String(normalized.scripts[name] || '').trim())) {
|
|
349
360
|
delete normalized.scripts[name];
|
|
@@ -355,7 +366,7 @@ function normalizePackageManifest(packageJson, descriptor, versions, buildProfil
|
|
|
355
366
|
.replace(/\bpnpm\s+run\s+doctor\s*&&\s*/gu, '')
|
|
356
367
|
.replace(/\bnimi-app\s+doctor\s*&&\s*/gu, '');
|
|
357
368
|
}
|
|
358
|
-
assertPackageManifestCurrent(normalized, versions, combination);
|
|
369
|
+
assertPackageManifestCurrent(normalized, versions, combination, descriptor.platform);
|
|
359
370
|
// Project formatters may use different whitespace or key order. Only managed
|
|
360
371
|
// value changes require rewriting this App-owned manifest.
|
|
361
372
|
if (stableInputJson(normalized) === stableInputJson(packageJson)) return packageSource;
|
|
@@ -584,6 +595,10 @@ function assertPnpmLockCurrent(targetDir, packageJson, localPackages, versions,
|
|
|
584
595
|
if (!importer || typeof importer !== 'object' || Array.isArray(importer)) {
|
|
585
596
|
throw installRequiredError('pnpm-lock.yaml root importer is missing');
|
|
586
597
|
}
|
|
598
|
+
for (const update of planToolchainUpdates(packageJson, importer, versions)) {
|
|
599
|
+
if (update.lockedAffected) throw installRequiredError(`pnpm-lock.yaml resolves ${update.name}@${update.locked}. Select a patched release (fixed in ${update.fixedVersion})`);
|
|
600
|
+
}
|
|
601
|
+
const requiredPackages = expectedNimiDependencies(versions, combination, packageJson);
|
|
587
602
|
const installedLock = localPackages.size > 0 ? readInstalledPnpmLock(targetDir) : null;
|
|
588
603
|
for (const [name, selected] of localPackages) {
|
|
589
604
|
if (lock.overrides?.[name] !== selected) throw installRequiredError(`pnpm-lock.yaml local package override does not match pnpm-workspace.yaml: ${name}`);
|
|
@@ -599,7 +614,7 @@ function assertPnpmLockCurrent(targetDir, packageJson, localPackages, versions,
|
|
|
599
614
|
if (!existsSync(manifestPath)) throw installRequiredError(`Local Nimi package is not installed: ${name}`);
|
|
600
615
|
const installed = readJsonFile(manifestPath, name);
|
|
601
616
|
const declared = NPM_DEPENDENCY_SECTIONS.map((section) => dependencySection(packageJson, section)?.[name]).filter((value) => value !== undefined);
|
|
602
|
-
const expected =
|
|
617
|
+
const expected = requiredPackages.find((entry) => entry.name === name)?.version
|
|
603
618
|
|| (KIT_OWNED_NATIVE_CARRIERS.includes(name) ? combination.kitVersion : declared[0]);
|
|
604
619
|
if (!expected || declared.some((specifier) => specifier !== expected)) {
|
|
605
620
|
throw installRequiredError(`Local Nimi package has no consistent declared version: ${name}`);
|
|
@@ -621,10 +636,21 @@ function assertPnpmLockCurrent(targetDir, packageJson, localPackages, versions,
|
|
|
621
636
|
const packageSection = dependencySection(packageJson, sectionName) || {};
|
|
622
637
|
const lockSection = importer[sectionName] || {};
|
|
623
638
|
for (const [name, specifier] of Object.entries(packageSection)) {
|
|
639
|
+
if ((name === 'vite' || name === 'electron') && sectionName !== 'peerDependencies' && validRange(specifier)) {
|
|
640
|
+
const entry = lockSection[name];
|
|
641
|
+
if (typeof entry?.specifier !== 'string' || (entry.specifier !== specifier && entry.specifier !== lock.overrides?.[name])
|
|
642
|
+
|| !satisfies(lockedRegistryVersion(entry), specifier)) {
|
|
643
|
+
throw installRequiredError(`pnpm-lock.yaml ${sectionName}.${name} does not resolve the declared range ${specifier}`);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
624
646
|
if (!name.startsWith('@nimiplatform/')) continue;
|
|
625
647
|
if (lockSection?.[name]?.specifier !== (localPackages.get(name) || specifier)) {
|
|
626
648
|
throw installRequiredError(`pnpm-lock.yaml ${sectionName}.${name} specifier does not match package.json`);
|
|
627
649
|
}
|
|
650
|
+
if (!localPackages.has(name) && requiredPackages.some(dep => dep.name === name)
|
|
651
|
+
&& !satisfies(lockedRegistryVersion(lockSection[name]), specifier)) {
|
|
652
|
+
throw installRequiredError(`pnpm-lock.yaml ${sectionName}.${name} does not resolve the declared range ${specifier}`);
|
|
653
|
+
}
|
|
628
654
|
if (localPackages.has(name)
|
|
629
655
|
&& installedLock?.importers?.['.']?.[sectionName]?.[name]?.version !== lockSection[name]?.version) {
|
|
630
656
|
throw installRequiredError(`Local Nimi package installation is stale: ${name}`);
|
|
@@ -653,95 +679,6 @@ function assertPnpmLockCurrent(targetDir, packageJson, localPackages, versions,
|
|
|
653
679
|
}
|
|
654
680
|
}
|
|
655
681
|
|
|
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
682
|
function normalizeStandaloneSourceFiles(targetDir, sources) {
|
|
746
683
|
const planned = [];
|
|
747
684
|
for (const name of ['vite.config.ts', 'vite.config.js', 'vite.config.mjs']) {
|
|
@@ -803,77 +740,24 @@ function tauriIdentifierFromAppId(appId) {
|
|
|
803
740
|
return `ai.nimi.apps.${appId}`;
|
|
804
741
|
}
|
|
805
742
|
|
|
806
|
-
function readProjectLifecycleFiles(targetDir,
|
|
743
|
+
function readProjectLifecycleFiles(targetDir, sources) {
|
|
807
744
|
const packagePath = path.join(targetDir, 'package.json');
|
|
808
745
|
if (!existsSync(packagePath)) throw new Error('Required App lifecycle file is missing: package.json');
|
|
809
|
-
const
|
|
746
|
+
const packageSource = readProjectText(targetDir, 'package.json', sources);
|
|
747
|
+
return {
|
|
810
748
|
packagePath,
|
|
811
|
-
packageSource
|
|
812
|
-
packageJson: JSON.parse(
|
|
813
|
-
cargoPath: null,
|
|
814
|
-
cargoSource: null,
|
|
815
|
-
tauriPath: null,
|
|
816
|
-
tauriSource: null,
|
|
817
|
-
tauriConfig: null,
|
|
749
|
+
packageSource,
|
|
750
|
+
packageJson: JSON.parse(packageSource),
|
|
818
751
|
};
|
|
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
752
|
}
|
|
860
753
|
|
|
861
|
-
function assertVersionLockstep(files, descriptor
|
|
754
|
+
function assertVersionLockstep(files, descriptor) {
|
|
862
755
|
const version = files.packageJson.version;
|
|
863
756
|
if (typeof version !== 'string' || !SEMVER_PATTERN.test(version)) {
|
|
864
757
|
throw new Error('package.json version must be an exact semantic version');
|
|
865
758
|
}
|
|
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
|
-
}
|
|
759
|
+
if (descriptor.version != null && descriptor.version !== version) {
|
|
760
|
+
throw new Error(`nimi.app.yaml version must match package.json version ${version}`);
|
|
877
761
|
}
|
|
878
762
|
return version;
|
|
879
763
|
}
|
|
@@ -918,12 +802,13 @@ function assertCanonicalAuthoringInputs(targetDir, descriptor, files, version, n
|
|
|
918
802
|
'support_manifest',
|
|
919
803
|
'review_inputs',
|
|
920
804
|
'admission_truth',
|
|
921
|
-
], ['ai_profile_recommendation_ref', SAFETY_PROFILE_FIELD]);
|
|
805
|
+
], ['ai_profile_recommendation_ref', SAFETY_PROFILE_FIELD, 'platform']);
|
|
922
806
|
const expectedSubmissionIdentity = {
|
|
923
807
|
app_id: descriptor.appId,
|
|
924
808
|
display_name: descriptor.displayName,
|
|
925
809
|
version,
|
|
926
810
|
profile: descriptor.profile,
|
|
811
|
+
...(descriptor.platform === 'web' ? { platform: 'web' } : {}),
|
|
927
812
|
npm_package_name: expectedIdentity.npm_package_name,
|
|
928
813
|
cargo_package_name: expectedIdentity.cargo_package_name,
|
|
929
814
|
tauri_identifier: expectedIdentity.tauri_identifier,
|
|
@@ -995,7 +880,7 @@ function isScopedComponentReleaseWorkflow(source, targetDir) {
|
|
|
995
880
|
});
|
|
996
881
|
}
|
|
997
882
|
|
|
998
|
-
function assertManagedWorkflowCurrent(targetDir, sources) {
|
|
883
|
+
function assertManagedWorkflowCurrent(targetDir, sources, hosted) {
|
|
999
884
|
const workflowPath = path.join(targetDir, MANAGED_WORKFLOW_PATH);
|
|
1000
885
|
if (!hasProjectFile(targetDir, MANAGED_WORKFLOW_PATH, sources)) throw new Error(`Required App lifecycle file is missing: ${MANAGED_WORKFLOW_PATH}`);
|
|
1001
886
|
if (readProjectText(targetDir, MANAGED_WORKFLOW_PATH, sources) !== managedAppReleaseWorkflowSource()) {
|
|
@@ -1005,6 +890,7 @@ function assertManagedWorkflowCurrent(targetDir, sources) {
|
|
|
1005
890
|
for (const name of existsSync(workflowDir) ? readdirSync(workflowDir).sort() : []) {
|
|
1006
891
|
const candidatePath = path.join(workflowDir, name);
|
|
1007
892
|
if (candidatePath === workflowPath || !/\.ya?ml$/iu.test(name)) continue;
|
|
893
|
+
if (hosted && name === 'nimi-web-release.yml') continue;
|
|
1008
894
|
const source = readFileSync(candidatePath, 'utf8');
|
|
1009
895
|
if (!isScopedComponentReleaseWorkflow(source, targetDir) && (
|
|
1010
896
|
/\bgh\s+release\s+(?:create|upload|edit|delete)\b/iu.test(source)
|
|
@@ -1053,6 +939,7 @@ function readBuildProfile(targetDir, sources) {
|
|
|
1053
939
|
const buildProfileRef = typeof profile.build_profile_ref === 'string'
|
|
1054
940
|
? profile.build_profile_ref
|
|
1055
941
|
: '';
|
|
942
|
+
assertDesktopHostSupport(buildProfileRef);
|
|
1056
943
|
if (!SUPPORTED_BUILD_PROFILE_REFS.has(buildProfileRef)) {
|
|
1057
944
|
throw new Error(`${BUILD_PROFILE_PATH} build_profile_ref is unsupported: ${String(profile.build_profile_ref)}`);
|
|
1058
945
|
}
|
|
@@ -1064,11 +951,11 @@ function readBuildProfile(targetDir, sources) {
|
|
|
1064
951
|
throw new Error(`${BUILD_PROFILE_PATH} must declare at least one target`);
|
|
1065
952
|
}
|
|
1066
953
|
for (const [targetId, target] of Object.entries(targets)) {
|
|
1067
|
-
const expected = CURRENT_APP_TARGETS[targetId];
|
|
954
|
+
const expected = buildProfileRef === 'web-pnpm' ? (targetId === 'web' ? {} : null) : CURRENT_APP_TARGETS[targetId];
|
|
1068
955
|
if (!expected || !target || typeof target !== 'object' || Array.isArray(target)) {
|
|
1069
956
|
throw new Error(`${BUILD_PROFILE_PATH} declares unsupported target: ${targetId}`);
|
|
1070
957
|
}
|
|
1071
|
-
if (target.os !== expected.os || target.arch !== expected.arch) {
|
|
958
|
+
if (buildProfileRef !== 'web-pnpm' && (target.os !== expected.os || target.arch !== expected.arch)) {
|
|
1072
959
|
throw new Error(`${BUILD_PROFILE_PATH} target identity mismatch: ${targetId}`);
|
|
1073
960
|
}
|
|
1074
961
|
}
|
|
@@ -1087,7 +974,7 @@ function currentTargetId() {
|
|
|
1087
974
|
}
|
|
1088
975
|
|
|
1089
976
|
function selectBuildOwner(profile, requestedTarget) {
|
|
1090
|
-
const target = String(requestedTarget || '').trim() || currentTargetId();
|
|
977
|
+
const target = String(requestedTarget || '').trim() || (profile.buildProfileRef === 'web-pnpm' ? 'web' : currentTargetId());
|
|
1091
978
|
const targetProfile = profile.targets[target];
|
|
1092
979
|
if (Object.keys(profile.targets).length > 0 && (!targetProfile || typeof targetProfile !== 'object' || Array.isArray(targetProfile))) {
|
|
1093
980
|
throw new Error(`Unsupported App build target: ${target}`);
|
|
@@ -1147,31 +1034,24 @@ function assertProjectLifecycleCurrent(targetDir, versions, options = {}) {
|
|
|
1147
1034
|
const sources = options.sources;
|
|
1148
1035
|
const descriptor = readSubmittedManifest(targetDir, sources);
|
|
1149
1036
|
const buildProfile = readBuildProfile(targetDir, sources);
|
|
1150
|
-
|
|
1037
|
+
if ((descriptor.platform === 'web') !== (buildProfile.buildProfileRef === 'web-pnpm')) throw new Error('Manifest platform and build owner disagree.');
|
|
1038
|
+
const files = readProjectLifecycleFiles(targetDir, sources);
|
|
1151
1039
|
const combination = selectDependencyCombination(files.packageJson, versions, options.managed === true);
|
|
1152
|
-
assertPackageManifestCurrent(files.packageJson, versions, combination);
|
|
1153
|
-
const version = assertVersionLockstep(files, descriptor
|
|
1154
|
-
|
|
1040
|
+
assertPackageManifestCurrent(files.packageJson, versions, combination, descriptor.platform);
|
|
1041
|
+
const version = assertVersionLockstep(files, descriptor);
|
|
1042
|
+
const nativeIdentity = {
|
|
1155
1043
|
cargoPackageName: cargoPackageNameFromNpmPackageName(files.packageJson.name),
|
|
1156
1044
|
tauriIdentifier: tauriIdentifierFromAppId(descriptor.appId),
|
|
1157
1045
|
};
|
|
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
1046
|
assertNoStandaloneParentSources(targetDir, sources);
|
|
1167
1047
|
const authoring = assertCanonicalAuthoringInputs(targetDir, descriptor, files, version, nativeIdentity, sources);
|
|
1168
|
-
|
|
1048
|
+
if (descriptor.publicSlug && (!hasProjectFile(targetDir, HOSTED_WEB_WORKFLOW_PATH, sources) || readProjectText(targetDir, HOSTED_WEB_WORKFLOW_PATH, sources).replaceAll('\r\n', '\n') !== hostedWorkflowSource())) {
|
|
1049
|
+
throw new Error('The hosted Web workflow must match App Tools. Use nimi-app sync to install its reviewed template.');
|
|
1050
|
+
}
|
|
1051
|
+
if (descriptor.platform !== 'web') assertManagedWorkflowCurrent(targetDir, sources, Boolean(descriptor.publicSlug));
|
|
1169
1052
|
const localPackages = assertPnpmWorkspaceCurrent(targetDir, sources, options.production === true);
|
|
1170
1053
|
if (options.requireInstalledLock === true) {
|
|
1171
1054
|
assertPnpmLockCurrent(targetDir, files.packageJson, localPackages, versions, combination);
|
|
1172
|
-
if (buildProfile.buildProfileRef === TAURI_BUILD_PROFILE_REF) {
|
|
1173
|
-
assertCargoLockCurrent(targetDir, combination.nimiShellTauriVersion);
|
|
1174
|
-
}
|
|
1175
1055
|
}
|
|
1176
1056
|
return { descriptor, files, version, buildProfile, authoring, combination };
|
|
1177
1057
|
}
|
|
@@ -1179,37 +1059,30 @@ function assertProjectLifecycleCurrent(targetDir, versions, options = {}) {
|
|
|
1179
1059
|
function buildExistingSubmittedAppSyncPlan(targetDir, versions, sources, managed = false) {
|
|
1180
1060
|
const descriptor = readSubmittedManifest(targetDir, sources);
|
|
1181
1061
|
const buildProfile = readBuildProfile(targetDir, sources);
|
|
1182
|
-
|
|
1062
|
+
if ((descriptor.platform === 'web') !== (buildProfile.buildProfileRef === 'web-pnpm')) throw new Error('Manifest platform and build owner disagree.');
|
|
1063
|
+
const files = readProjectLifecycleFiles(targetDir, sources);
|
|
1183
1064
|
const version = files.packageJson.version;
|
|
1184
1065
|
if (typeof version !== 'string' || !SEMVER_PATTERN.test(version)) {
|
|
1185
1066
|
throw new Error('package.json version must be an exact semantic version before sync');
|
|
1186
1067
|
}
|
|
1187
|
-
const requiresTauri = buildProfile.buildProfileRef === TAURI_BUILD_PROFILE_REF;
|
|
1188
1068
|
const combination = selectDependencyCombination(files.packageJson, versions, managed);
|
|
1069
|
+
const lockPath = path.join(targetDir, 'pnpm-lock.yaml');
|
|
1070
|
+
const importer = existsSync(lockPath) ? parseYamlFile(readFileSync(lockPath, 'utf8'), lockPath)?.importers?.['.'] : null;
|
|
1071
|
+
const toolchainUpdates = planToolchainUpdates(files.packageJson, importer, versions);
|
|
1189
1072
|
const identity = {
|
|
1190
1073
|
appId: descriptor.appId,
|
|
1191
1074
|
appTitle: descriptor.displayName,
|
|
1192
1075
|
version,
|
|
1193
1076
|
profile: descriptor.profile,
|
|
1077
|
+
...(descriptor.platform === 'web' ? { platform: 'web' } : {}),
|
|
1194
1078
|
packageName: files.packageJson.name,
|
|
1195
|
-
cargoPackageName:
|
|
1196
|
-
|
|
1197
|
-
: cargoPackageNameFromNpmPackageName(files.packageJson.name),
|
|
1198
|
-
tauriIdentifier: requiresTauri
|
|
1199
|
-
? files.tauriConfig.identifier
|
|
1200
|
-
: tauriIdentifierFromAppId(descriptor.appId),
|
|
1079
|
+
cargoPackageName: cargoPackageNameFromNpmPackageName(files.packageJson.name),
|
|
1080
|
+
tauriIdentifier: tauriIdentifierFromAppId(descriptor.appId),
|
|
1201
1081
|
author: typeof files.packageJson.author === 'string' ? files.packageJson.author : '',
|
|
1202
1082
|
};
|
|
1203
1083
|
const planned = [
|
|
1204
|
-
{ path: files.packagePath, content: normalizePackageManifest(files.packageJson, descriptor, versions, buildProfile.buildProfileRef, files.packageSource, combination), previous: files.packageSource },
|
|
1084
|
+
{ path: files.packagePath, content: normalizePackageManifest(files.packageJson, descriptor, versions, buildProfile.buildProfileRef, files.packageSource, combination, toolchainUpdates), previous: files.packageSource },
|
|
1205
1085
|
];
|
|
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
1086
|
planned.push(...normalizeStandaloneSourceFiles(targetDir, sources));
|
|
1214
1087
|
const identityPath = path.join(targetDir, APP_IDENTITY_PATH);
|
|
1215
1088
|
planned.push({
|
|
@@ -1238,7 +1111,7 @@ function buildExistingSubmittedAppSyncPlan(targetDir, versions, sources, managed
|
|
|
1238
1111
|
'support_manifest',
|
|
1239
1112
|
'review_inputs',
|
|
1240
1113
|
'admission_truth',
|
|
1241
|
-
], ['ai_profile_recommendation_ref', SAFETY_PROFILE_FIELD]);
|
|
1114
|
+
], ['ai_profile_recommendation_ref', SAFETY_PROFILE_FIELD, 'platform']);
|
|
1242
1115
|
canonicalInputList(currentSubmission.capability_contract_refs, `${SUBMISSION_PATH} capability_contract_refs`);
|
|
1243
1116
|
canonicalInputList(currentSubmission.required_standardized_feature_refs, `${SUBMISSION_PATH} required_standardized_feature_refs`);
|
|
1244
1117
|
normalizeStorageInput(currentSubmission.storage_policy, `${SUBMISSION_PATH} storage_policy`);
|
|
@@ -1281,26 +1154,24 @@ function buildExistingSubmittedAppSyncPlan(targetDir, versions, sources, managed
|
|
|
1281
1154
|
content: normalizedBuildProfile,
|
|
1282
1155
|
previous: currentBuildProfile,
|
|
1283
1156
|
});
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1157
|
+
if (descriptor.platform !== 'web') {
|
|
1158
|
+
const workflowPath = path.join(targetDir, MANAGED_WORKFLOW_PATH);
|
|
1159
|
+
planned.push({
|
|
1160
|
+
path: workflowPath,
|
|
1161
|
+
content: managedAppReleaseWorkflowSource(),
|
|
1162
|
+
previous: existsSync(workflowPath) ? readFileSync(workflowPath, 'utf8') : '',
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1165
|
+
if (descriptor.publicSlug) {
|
|
1166
|
+
const hostedPath = path.join(targetDir, HOSTED_WEB_WORKFLOW_PATH);
|
|
1167
|
+
const previous = existsSync(hostedPath) ? readFileSync(hostedPath, 'utf8') : null;
|
|
1168
|
+
const template = hostedWorkflowSource();
|
|
1169
|
+
if (previous !== null && previous.replaceAll('\r\n', '\n') !== template) throw new Error('Unknown hosted Web workflow collision: ' + HOSTED_WEB_WORKFLOW_PATH);
|
|
1170
|
+
planned.push({ path: hostedPath, content: template, previous });
|
|
1171
|
+
}
|
|
1290
1172
|
const workspace = normalizePnpmWorkspace(targetDir);
|
|
1291
1173
|
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
|
-
];
|
|
1174
|
+
return { descriptor, planned: planned.map((file) => plannedFile(targetDir, path.relative(targetDir, file.path), file.content)), buildProfileRef: buildProfile.buildProfileRef, combination, toolchainUpdates, packageJson: files.packageJson };
|
|
1304
1175
|
}
|
|
1305
1176
|
|
|
1306
1177
|
function runNimicodingSync(targetDir, mode, runners) {
|
|
@@ -1337,6 +1208,7 @@ export function validateAppInitialization(targetDir, versions) {
|
|
|
1337
1208
|
}
|
|
1338
1209
|
|
|
1339
1210
|
function ownershipHandoverMessage(handover) {
|
|
1211
|
+
if (handover.path.startsWith('src-tauri/')) return `${handover.path} leaves scaffold management (${handover.file}).`;
|
|
1340
1212
|
if (handover.file === 'missing') {
|
|
1341
1213
|
return `${handover.path} now belongs to the App and is missing; add the App's own ${handover.path} before packaging.`;
|
|
1342
1214
|
}
|
|
@@ -1355,19 +1227,37 @@ function executeProjectPlan(targetDir, options, versions, runners, plan, scaffol
|
|
|
1355
1227
|
if (scaffold) validateManagedAppFiles(targetDir, scaffold.snapshot.lock, planSources(targetDir, plan.planned));
|
|
1356
1228
|
validateProjectPlan(targetDir, versions, plan.planned, Boolean(scaffold));
|
|
1357
1229
|
const handovers = scaffold?.handovers ?? [];
|
|
1230
|
+
const dependencyChanges = expectedNimiDependencies(versions, plan.combination, plan.packageJson).flatMap(({ name, section, version }) => {
|
|
1231
|
+
const declared = plan.packageJson[section]?.[name] ?? null;
|
|
1232
|
+
const from = declared === version ? scaffold?.previousDependencies?.[name] ?? declared : declared;
|
|
1233
|
+
return from === version ? [] : [{ name, from, to: version, kind: section === 'devDependencies' ? 'tool' : 'sdk-kit' }];
|
|
1234
|
+
});
|
|
1235
|
+
const manual = plan.toolchainUpdates.filter(update => update.manual);
|
|
1358
1236
|
const preview = {
|
|
1237
|
+
dependencyChanges, toolchainUpdates: plan.toolchainUpdates, readyToApply: manual.length === 0,
|
|
1359
1238
|
ok: true, command: options.adopt ? 'init' : 'sync', dir: targetDir,
|
|
1360
1239
|
managed: Boolean(scaffold), appId: plan.descriptor.appId,
|
|
1361
1240
|
dryRun: options.dryRun === true, skillPath: LIFECYCLE_SKILL_PATH,
|
|
1362
1241
|
changes: describeChanges(targetDir, plan.planned), ownerSteps: lifecycleOwnerSteps(versions),
|
|
1363
|
-
nextSteps:
|
|
1242
|
+
nextSteps: [...plan.toolchainUpdates.filter(dep => dep.lockedAffected && dep.from === dep.to && !dep.manual)
|
|
1243
|
+
.map(dep => `pnpm update ${dep.name}`), 'pnpm install', 'nimi-app sync', 'nimi-app check'],
|
|
1364
1244
|
dependencyCombination: describeCombination(plan.combination, toolVersions),
|
|
1245
|
+
...(scaffold ? { retainedHostFiles: scaffold.snapshot.retainedHostFiles ?? [] } : {}),
|
|
1365
1246
|
...(scaffold ? { ownershipHandover: handovers } : {}),
|
|
1366
1247
|
};
|
|
1248
|
+
if (!options.json) {
|
|
1249
|
+
if (preview.retainedHostFiles?.length) process.stdout.write(`[nimi-app] Retained ${preview.retainedHostFiles.length} locked Host files for the selected SDK/Kit combination.\n`);
|
|
1250
|
+
for (const dep of dependencyChanges) process.stdout.write(`[nimi-app] ${dep.kind}: ${dep.name} ${dep.from ?? '(unset)'} -> ${dep.to}\n`);
|
|
1251
|
+
for (const dep of plan.toolchainUpdates) {
|
|
1252
|
+
const action = dep.manual ? 'select a patched range manually' : `sync target ${dep.to}`;
|
|
1253
|
+
process.stdout.write(`[nimi-app] ${dep.name}: declared ${dep.from}, locked ${dep.locked ?? '(unresolved)'}, ${action} (fix ${dep.fixedVersion})\n`);
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1367
1256
|
if (options.dryRun) {
|
|
1368
1257
|
emitOwnershipHandovers(handovers, options);
|
|
1369
1258
|
return emitResult(preview, options, `${preview.command} preview: ${preview.changes.map((file) => `${file.action} ${file.path}`).join(', ') || 'no app-tools changes'}`);
|
|
1370
1259
|
}
|
|
1260
|
+
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
1261
|
const nimicoding = runNimicodingSync(targetDir, 'apply', runners);
|
|
1372
1262
|
const lockPath = path.join(targetDir, SCAFFOLD_LOCK_PATH);
|
|
1373
1263
|
const lockFile = plan.planned.find((file) => file.path === lockPath);
|
|
@@ -1382,6 +1272,7 @@ function executeProjectPlan(targetDir, options, versions, runners, plan, scaffol
|
|
|
1382
1272
|
}
|
|
1383
1273
|
validateAppProject(targetDir, { silent: true }, versions, runners);
|
|
1384
1274
|
emitOwnershipHandovers(handovers, options);
|
|
1275
|
+
if (!options.json && (dependencyChanges.length || plan.toolchainUpdates.length)) process.stdout.write(`[nimi-app] Next: ${preview.nextSteps.join(' -> ')}\n`);
|
|
1385
1276
|
return emitResult({ ...preview, synchronizedFiles, nimicodingSync: nimicoding?.summary || null }, options, `${preview.command} completed for ${targetDir}`);
|
|
1386
1277
|
}
|
|
1387
1278
|
|
|
@@ -1435,8 +1326,7 @@ export function adoptAppProject(cwd, options = {}, versions, runners = {}) {
|
|
|
1435
1326
|
} catch (cause) {
|
|
1436
1327
|
throw new Error(`${cause.message}. Prepare the real App-owned Host and build/test inputs using ${LIFECYCLE_SKILL_PATH}`, { cause });
|
|
1437
1328
|
}
|
|
1438
|
-
|
|
1439
|
-
const files = readProjectLifecycleFiles(targetDir, plan.buildProfileRef);
|
|
1329
|
+
const files = readProjectLifecycleFiles(targetDir, sources);
|
|
1440
1330
|
const profile = readBuildProfile(targetDir, sources);
|
|
1441
1331
|
for (const command of [profile.testCommand, profile.buildCommand, ...Object.keys(profile.targets).map((target) => selectBuildOwner(profile, target).command)]) {
|
|
1442
1332
|
const script = command.match(/^pnpm\s+run\s+([^\s]+)(?:\s|$)/u)?.[1];
|
|
@@ -1466,7 +1356,8 @@ export function checkAppProject(cwd, options = {}, versions, runners = {}) {
|
|
|
1466
1356
|
if (!managed) nimicoding = runNimicodingSync(targetDir, 'check', runners);
|
|
1467
1357
|
const { descriptor, buildProfile, combination } = existingState || assertProjectLifecycleCurrent(targetDir, effective, { requireInstalledLock: true, production: options.production === true, managed });
|
|
1468
1358
|
if (options.production === true) {
|
|
1469
|
-
|
|
1359
|
+
if (descriptor.platform === 'web' && !descriptor.publicSlug) throw new Error('Web release preflight requires a hosted public_slug; use development check for other Web sources.');
|
|
1360
|
+
if (descriptor.platform !== 'web') for (const target of Object.keys(buildProfile.targets)) readAppInfo(targetDir, target);
|
|
1470
1361
|
}
|
|
1471
1362
|
const safetyProfile = descriptor.safetyProfile ? 'declared' : 'undeclared';
|
|
1472
1363
|
if (options.production === true && !options.json && safetyProfile === 'undeclared') {
|
|
@@ -1480,6 +1371,7 @@ export function checkAppProject(cwd, options = {}, versions, runners = {}) {
|
|
|
1480
1371
|
managed,
|
|
1481
1372
|
appId: descriptor.appId,
|
|
1482
1373
|
profile: descriptor.profile,
|
|
1374
|
+
...(descriptor.platform === 'web' ? { platform: 'web' } : {}),
|
|
1483
1375
|
safetyProfile,
|
|
1484
1376
|
dependencyCombination: describeCombination(combination, versions),
|
|
1485
1377
|
targets: Object.keys(buildProfile.targets).sort(),
|
|
@@ -1492,6 +1384,11 @@ export function checkAppProject(cwd, options = {}, versions, runners = {}) {
|
|
|
1492
1384
|
export function testAppProject(cwd, options = {}, runners = {}) {
|
|
1493
1385
|
const targetDir = resolveTargetDir(cwd, options);
|
|
1494
1386
|
const profile = readBuildProfile(targetDir);
|
|
1387
|
+
if (profile.testCommand === 'pnpm run test:app'
|
|
1388
|
+
&& readJsonFile(path.join(targetDir, 'package.json'), 'package.json').scripts?.['test:app'] === 'node --test test/*.test.mjs'
|
|
1389
|
+
&& globSync('test/*.test.mjs', { cwd: targetDir }).length === 0) {
|
|
1390
|
+
throw new Error('No App tests found. Add a business test under test/*.test.mjs or configure the App-owned test:app script.');
|
|
1391
|
+
}
|
|
1495
1392
|
const result = runOwnerCommand(targetDir, 'test', profile.testCommand, options, runners);
|
|
1496
1393
|
return emitResult({
|
|
1497
1394
|
ok: true,
|
|
@@ -1506,6 +1403,7 @@ export function buildAppProject(cwd, options = {}, runners = {}) {
|
|
|
1506
1403
|
const targetDir = resolveTargetDir(cwd, options);
|
|
1507
1404
|
const profile = readBuildProfile(targetDir);
|
|
1508
1405
|
const selected = selectBuildOwner(profile, options.target);
|
|
1406
|
+
if (options.production === true && profile.buildProfileRef === 'web-pnpm') throw new Error('Web release preflight is not implemented; build produces website files only.');
|
|
1509
1407
|
if (options.production === true) readAppInfo(targetDir, selected.target);
|
|
1510
1408
|
const result = runOwnerCommand(targetDir, 'build', selected.command, options, runners);
|
|
1511
1409
|
assertBuiltRuntimeEntry(targetDir, selected);
|