@nimiplatform/app-tools 0.13.1 → 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 +65 -8
- package/bin/nimi-app.mjs +26 -10
- package/lib/app-access-declaration.mjs +3 -0
- package/lib/app-dependency-combinations.mjs +70 -20
- package/lib/app-doctor-update.mjs +95 -36
- package/lib/app-host-support.mjs +6 -0
- package/lib/app-icons.mjs +181 -0
- package/lib/app-identifiers.mjs +27 -0
- package/lib/app-info.mjs +21 -33
- package/lib/app-lifecycle-guidance.mjs +2 -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 +108 -117
- package/lib/app-scaffold.mjs +70 -165
- 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 +39 -27
- package/scripts/dev-shell.mjs +4 -1
- package/scripts/sync-scaffold-versions.mjs +0 -2
- package/skills/nimi-app-lifecycle/SKILL.md +13 -5
- package/skills/nimi-app-lifecycle/references/acceptance.md +6 -2
- package/skills/nimi-app-lifecycle/references/adapt.md +7 -3
- package/skills/nimi-app-lifecycle/references/audit.md +3 -2
- package/skills/nimi-app-lifecycle/references/create.md +8 -2
- package/skills/nimi-app-lifecycle/references/release.md +2 -0
- package/skills/nimi-app-lifecycle/references/upgrade-platform.md +15 -1
- 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 +79 -19
- package/templates/app-source/src/ai-studio-core/messages/zh.json +79 -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 +40 -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 +102 -77
- package/templates/app-source/src/ai-studio-core/section-ai-testing-run.ts +62 -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 +26 -9
- 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 +182 -81
- 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 +17 -3
- package/templates/app-source/src/studio-modules/studio-create/messages/zh.json +17 -3
- package/templates/app-source/src/studio-modules/studio-create/parameter-panel.tsx +33 -1
- package/templates/app-source/src/studio-modules/studio-create/parameters.ts +3 -1
- package/templates/app-source/src/studio-modules/studio-create/runtime.ts +47 -4
- 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 +8 -5
- package/templates/default-starter/NIMI_APP.md +7 -0
- package/templates/default-starter/README.md +3 -1
- package/templates/default-starter/src/shell/App.tsx +12 -20
- 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 +4 -16
- package/templates/hosted-web-release.yml +88 -0
- package/templates/default-starter/src-tauri/Cargo.toml +0 -17
- package/templates/default-starter/src-tauri/build.rs +0 -32
- package/templates/default-starter/src-tauri/capabilities/default.json +0 -7
- package/templates/default-starter/src-tauri/tauri.conf.json +0 -26
package/lib/app-scaffold.mjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { isAppId } from './app-identifiers.mjs';
|
|
2
|
+
import { WEB_BASE_TEMPLATE_PATHS, webDevelopmentInput, webBuildProfile, webPackage, webDependencyMatrix } from './web-scaffold.mjs';
|
|
3
|
+
import { resolveWebAppScaffoldFeatures } from './app-scaffold-capabilities.mjs';
|
|
1
4
|
import path from 'node:path';
|
|
2
5
|
import { createHash } from 'node:crypto';
|
|
3
6
|
import YAML from 'yaml';
|
|
@@ -14,7 +17,6 @@ import {
|
|
|
14
17
|
resolveAppScaffoldCandidateFeatures,
|
|
15
18
|
resolveAppScaffoldFeatures,
|
|
16
19
|
resolveAppScaffoldIntentFeatures,
|
|
17
|
-
validateAppScaffoldCargoDependencyValue,
|
|
18
20
|
validateAppScaffoldNpmRegistryVersion,
|
|
19
21
|
} from './app-scaffold-capabilities.mjs';
|
|
20
22
|
import {
|
|
@@ -61,6 +63,8 @@ const LOCKFILE_POLICY = 'author-install-generates-lockfile';
|
|
|
61
63
|
const GENERATED_GITIGNORE = [
|
|
62
64
|
'node_modules/',
|
|
63
65
|
'dist/',
|
|
66
|
+
'dist-web/',
|
|
67
|
+
'dist-mobile/',
|
|
64
68
|
'dist-electron/',
|
|
65
69
|
'dist-electron-package/',
|
|
66
70
|
'src-tauri/target/',
|
|
@@ -72,8 +76,6 @@ const GENERATED_GITIGNORE = [
|
|
|
72
76
|
'.DS_Store',
|
|
73
77
|
'',
|
|
74
78
|
].join('\n');
|
|
75
|
-
const MINIMAL_TAURI_ICON_PNG = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVR4nGNgAAIAAAUAAXpeqz8AAAAASUVORK5CYII=', 'base64');
|
|
76
|
-
const MINIMAL_TAURI_ICON_ICO = Buffer.from('AAABAAEAAQEAAAEAIABEAAAAFgAAAIlQTkcNChoKAAAADUlIRFIAAAABAAAAAQgGAAAAHxXEiQAAAAtJREFUeJxjYAACAAAFAAF6Xqs/AAAAAElFTkSuQmCC', 'base64');
|
|
77
79
|
|
|
78
80
|
const APP_RELEASE_WORKFLOW = [
|
|
79
81
|
'name: nimi-app-release',
|
|
@@ -391,7 +393,7 @@ function normalizeExplicitAppId(input) {
|
|
|
391
393
|
if (raw !== raw.trim() || raw !== raw.toLowerCase()) {
|
|
392
394
|
throw new Error(`Invalid app id: ${input}`);
|
|
393
395
|
}
|
|
394
|
-
if (
|
|
396
|
+
if (!isAppId(raw)) {
|
|
395
397
|
throw new Error(`Invalid app id: ${input}`);
|
|
396
398
|
}
|
|
397
399
|
return raw;
|
|
@@ -528,12 +530,15 @@ function buildAppIdentity(
|
|
|
528
530
|
accentPack = 'nimi-accent',
|
|
529
531
|
features = undefined,
|
|
530
532
|
featureResolver = resolveAppScaffoldFeatures,
|
|
533
|
+
platform = 'desktop',
|
|
531
534
|
) {
|
|
532
535
|
const resolvedPackageName = packageName || packageSafeName(appId);
|
|
533
|
-
|
|
536
|
+
if (!['desktop', 'web'].includes(platform)) throw new Error(`Unsupported App platform: ${platform}`);
|
|
537
|
+
const capabilityResolution = platform === 'web' ? resolveWebAppScaffoldFeatures(features, featureResolver) : featureResolver(features);
|
|
534
538
|
const identity = {
|
|
535
539
|
appId,
|
|
536
540
|
appTitle,
|
|
541
|
+
platform,
|
|
537
542
|
version: normalizeAppVersion(version),
|
|
538
543
|
profile,
|
|
539
544
|
packageName: resolvedPackageName,
|
|
@@ -583,8 +588,10 @@ function resolveAppScaffoldCreateInputWithResolver(
|
|
|
583
588
|
options.accentPack,
|
|
584
589
|
options.features,
|
|
585
590
|
featureResolver,
|
|
591
|
+
options.platform || 'desktop',
|
|
586
592
|
);
|
|
587
593
|
return Object.freeze({
|
|
594
|
+
...(identity.platform === 'web' ? { platform: 'web' } : {}),
|
|
588
595
|
profile,
|
|
589
596
|
appId,
|
|
590
597
|
appTitle,
|
|
@@ -614,13 +621,13 @@ function buildPackageJson(profile, versions, identity) {
|
|
|
614
621
|
'@nimiplatform/app-tools': versions.appToolsVersion,
|
|
615
622
|
'@nimiplatform/nimi-coding': versions.nimicodingVersion,
|
|
616
623
|
'@tailwindcss/vite': versions.tailwindcssViteVersion,
|
|
617
|
-
'@tauri-apps/cli': versions.tauriCliVersion,
|
|
618
624
|
'@types/node': versions.nodeTypesVersion,
|
|
619
625
|
'@types/react': versions.reactTypesVersion,
|
|
620
626
|
'@types/react-dom': versions.reactDomTypesVersion,
|
|
621
627
|
'@vitejs/plugin-react': versions.viteReactPluginVersion,
|
|
622
628
|
electron: versions.electronVersion,
|
|
623
629
|
esbuild: versions.esbuildVersion,
|
|
630
|
+
pngjs: versions.pngjsVersion,
|
|
624
631
|
tailwindcss: versions.tailwindcssVersion,
|
|
625
632
|
typescript: versions.typescriptVersion,
|
|
626
633
|
vite: versions.viteVersion,
|
|
@@ -655,7 +662,6 @@ function buildPackageJson(profile, versions, identity) {
|
|
|
655
662
|
build: 'tsc --noEmit && vite build',
|
|
656
663
|
'build:electron': 'tsc -p tsconfig.electron.json && node scripts/bundle-electron-preload.mjs',
|
|
657
664
|
'build:electron:production': 'node scripts/clean-electron-production.mjs && pnpm run build && pnpm run build:electron && node scripts/package-electron-production.mjs',
|
|
658
|
-
'build:tauri:production': 'tauri build',
|
|
659
665
|
postinstall: 'install-electron --no',
|
|
660
666
|
validate: 'node scripts/validate.mjs',
|
|
661
667
|
},
|
|
@@ -665,7 +671,7 @@ function buildPackageJson(profile, versions, identity) {
|
|
|
665
671
|
if (identity.author) {
|
|
666
672
|
packageJson.author = identity.author;
|
|
667
673
|
}
|
|
668
|
-
return packageJson;
|
|
674
|
+
return identity.platform === 'web' ? webPackage(packageJson) : packageJson;
|
|
669
675
|
}
|
|
670
676
|
|
|
671
677
|
function buildRuntimeDependencies(profile, versions, capabilityResolution) {
|
|
@@ -700,96 +706,6 @@ function resolveScaffoldVersionReference(value, versions, dependencyName) {
|
|
|
700
706
|
return resolved;
|
|
701
707
|
}
|
|
702
708
|
|
|
703
|
-
function buildCargoDependencies(profile, versions, capabilityResolution) {
|
|
704
|
-
const dependencies = {
|
|
705
|
-
'nimi-shell-tauri': versions.nimiShellTauriVersion,
|
|
706
|
-
tauri: { version: '2', features: [] },
|
|
707
|
-
serde: { version: '1', features: ['derive'] },
|
|
708
|
-
serde_json: '1',
|
|
709
|
-
url: '2',
|
|
710
|
-
base64: '0.22',
|
|
711
|
-
dirs: '6',
|
|
712
|
-
time: '=0.3.47',
|
|
713
|
-
'tauri-build': { version: '2', features: [] },
|
|
714
|
-
};
|
|
715
|
-
for (const [name, value] of Object.entries(capabilityResolution.cargoDependencies || {})) {
|
|
716
|
-
if (Object.hasOwn(dependencies, name) && canonicalJson(dependencies[name]) !== canonicalJson(value)) {
|
|
717
|
-
throw new Error(`App scaffold base/module Cargo dependency collision for ${name}`);
|
|
718
|
-
}
|
|
719
|
-
dependencies[name] = value;
|
|
720
|
-
}
|
|
721
|
-
for (const [name, value] of Object.entries(dependencies)) {
|
|
722
|
-
validateAppScaffoldCargoDependencyValue(value, name);
|
|
723
|
-
}
|
|
724
|
-
return dependencies;
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
function cargoShellDependencyLine(profile, versions) {
|
|
728
|
-
return `nimi-shell-tauri = ${renderCargoDependencyValue(versions.nimiShellTauriVersion, 'nimi-shell-tauri')}`;
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
export function renderCargoDependencyValue(value, label) {
|
|
732
|
-
validateAppScaffoldCargoDependencyValue(value, label);
|
|
733
|
-
if (typeof value === 'string' && value.trim() === value && value) {
|
|
734
|
-
return JSON.stringify(value);
|
|
735
|
-
}
|
|
736
|
-
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
737
|
-
throw new Error(`Invalid Cargo dependency descriptor: ${label}`);
|
|
738
|
-
}
|
|
739
|
-
const fields = [];
|
|
740
|
-
for (const key of Object.keys(value).sort()) {
|
|
741
|
-
const field = value[key];
|
|
742
|
-
if (typeof field === 'string' && field.trim() === field && field) {
|
|
743
|
-
fields.push(`${key} = ${JSON.stringify(field)}`);
|
|
744
|
-
continue;
|
|
745
|
-
}
|
|
746
|
-
if (typeof field === 'boolean') {
|
|
747
|
-
fields.push(`${key} = ${field ? 'true' : 'false'}`);
|
|
748
|
-
continue;
|
|
749
|
-
}
|
|
750
|
-
if (Array.isArray(field) && field.every((item) => typeof item === 'string' && item.trim() === item && item)) {
|
|
751
|
-
fields.push(`${key} = [${field.map((item) => JSON.stringify(item)).join(', ')}]`);
|
|
752
|
-
continue;
|
|
753
|
-
}
|
|
754
|
-
throw new Error(`Invalid Cargo dependency value: ${label}.${key}`);
|
|
755
|
-
}
|
|
756
|
-
if (fields.length === 0) throw new Error(`Invalid empty Cargo dependency descriptor: ${label}`);
|
|
757
|
-
return `{ ${fields.join(', ')} }`;
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
function renderCargoManifest(content, profile, versions, identity) {
|
|
761
|
-
let rendered = content.replace(
|
|
762
|
-
/^nimi-shell-tauri\s*=.*$/m,
|
|
763
|
-
cargoShellDependencyLine(profile, versions),
|
|
764
|
-
);
|
|
765
|
-
rendered = rendered.replace(
|
|
766
|
-
/^(\[package\][\s\S]*?^version\s*=\s*)"[^"]+"/m,
|
|
767
|
-
`$1${JSON.stringify(identity.version)}`,
|
|
768
|
-
);
|
|
769
|
-
const baseNames = new Set([
|
|
770
|
-
'tauri',
|
|
771
|
-
'nimi-shell-tauri',
|
|
772
|
-
'serde',
|
|
773
|
-
'serde_json',
|
|
774
|
-
'url',
|
|
775
|
-
'base64',
|
|
776
|
-
'dirs',
|
|
777
|
-
'time',
|
|
778
|
-
'tauri-build',
|
|
779
|
-
]);
|
|
780
|
-
const additions = [];
|
|
781
|
-
for (const [name, value] of Object.entries(identity.capabilityResolution.cargoDependencies || {})) {
|
|
782
|
-
if (!/^[A-Za-z0-9_-]+$/u.test(name)) throw new Error(`Invalid Cargo dependency name: ${name}`);
|
|
783
|
-
if (baseNames.has(name)) continue;
|
|
784
|
-
additions.push(`${name} = ${renderCargoDependencyValue(value, name)}`);
|
|
785
|
-
}
|
|
786
|
-
if (additions.length === 0) return rendered;
|
|
787
|
-
const marker = '\n[build-dependencies]';
|
|
788
|
-
if (!rendered.includes(marker)) throw new Error('Generated Cargo manifest is missing [build-dependencies]');
|
|
789
|
-
rendered = rendered.replace(marker, `\n${additions.join('\n')}\n${marker}`);
|
|
790
|
-
return rendered;
|
|
791
|
-
}
|
|
792
|
-
|
|
793
709
|
function targetIdentityMap(identity) {
|
|
794
710
|
return {
|
|
795
711
|
tauriIdentifier: identity.tauriIdentifier,
|
|
@@ -890,6 +806,7 @@ function buildNimiAppManifest(identity) {
|
|
|
890
806
|
display_name: identity.appTitle,
|
|
891
807
|
version: identity.version,
|
|
892
808
|
profile: identity.profile,
|
|
809
|
+
...(identity.platform === 'web' ? { platform: 'web' } : {}),
|
|
893
810
|
manifest_role: 'submitted-input',
|
|
894
811
|
app_access: identity.appAccessItems,
|
|
895
812
|
capability_contract_refs: identity.capabilityResolution.capabilityContractRefs,
|
|
@@ -898,32 +815,14 @@ function buildNimiAppManifest(identity) {
|
|
|
898
815
|
metadata: {
|
|
899
816
|
summary: '',
|
|
900
817
|
icon: 'assets/app-icon.png',
|
|
901
|
-
readme: 'README.md',
|
|
902
818
|
release_notes: 'RELEASE_NOTES.md',
|
|
903
819
|
},
|
|
904
|
-
local_development: {
|
|
905
|
-
electron: {
|
|
906
|
-
renderer_origin: `http://127.0.0.1:${identity.devPort}`,
|
|
907
|
-
},
|
|
820
|
+
local_development: identity.platform === 'web' ? { web: webDevelopmentInput(identity) } : {
|
|
821
|
+
electron: { renderer_origin: `http://127.0.0.1:${identity.devPort}` },
|
|
908
822
|
},
|
|
909
823
|
}, { lineWidth: 0 });
|
|
910
824
|
}
|
|
911
825
|
|
|
912
|
-
function renderTauriConfig(raw, identity) {
|
|
913
|
-
const config = JSON.parse(raw);
|
|
914
|
-
config.productName = identity.appTitle;
|
|
915
|
-
config.version = identity.version;
|
|
916
|
-
config.identifier = identity.nativeBundleIdentifier;
|
|
917
|
-
config.build = { ...config.build, devUrl: `http://127.0.0.1:${identity.devPort}` };
|
|
918
|
-
config.app = {
|
|
919
|
-
...config.app,
|
|
920
|
-
windows: Array.isArray(config.app?.windows)
|
|
921
|
-
? config.app.windows.map((window) => ({ ...window, title: identity.appTitle }))
|
|
922
|
-
: [],
|
|
923
|
-
};
|
|
924
|
-
return jsonFile(config);
|
|
925
|
-
}
|
|
926
|
-
|
|
927
826
|
function renderAppIdentityModule(identity) {
|
|
928
827
|
return [
|
|
929
828
|
`export const appId = ${JSON.stringify(identity.appId)};`,
|
|
@@ -944,9 +843,6 @@ function escapeHtmlText(input) {
|
|
|
944
843
|
}
|
|
945
844
|
|
|
946
845
|
function renderIdentitySensitiveStarterFile(relativePath, raw, manifest, identity) {
|
|
947
|
-
if (relativePath === 'src-tauri/tauri.conf.json') {
|
|
948
|
-
return renderTauriConfig(raw, identity);
|
|
949
|
-
}
|
|
950
846
|
if (relativePath === 'src/shell/auth/app-identity.ts') {
|
|
951
847
|
return renderAppIdentityModule(identity);
|
|
952
848
|
}
|
|
@@ -956,34 +852,31 @@ function renderIdentitySensitiveStarterFile(relativePath, raw, manifest, identit
|
|
|
956
852
|
return applyIdentityReplacement(raw, manifest, targetIdentityMap(identity));
|
|
957
853
|
}
|
|
958
854
|
|
|
959
|
-
function applyProfileSeam(relativePath, content, profile,
|
|
855
|
+
function applyProfileSeam(relativePath, content, profile, identity) {
|
|
960
856
|
if (relativePath === 'nimi.app.yaml') {
|
|
961
857
|
return buildNimiAppManifest(identity);
|
|
962
858
|
}
|
|
963
|
-
if (relativePath === 'src-tauri/Cargo.toml') {
|
|
964
|
-
return renderCargoManifest(content, profile, versions, identity);
|
|
965
|
-
}
|
|
966
859
|
if (relativePath === 'README.md') {
|
|
967
860
|
return content.replace(/Profile: `standalone`/, `Profile: \`${profile}\``);
|
|
968
861
|
}
|
|
969
862
|
return content;
|
|
970
863
|
}
|
|
971
864
|
|
|
972
|
-
function buildDefaultStarterTemplateFiles(identity, profile
|
|
865
|
+
function buildDefaultStarterTemplateFiles(identity, profile) {
|
|
973
866
|
const { baseDir, manifest } = loadDefaultStarterSource();
|
|
974
|
-
const
|
|
975
|
-
return
|
|
867
|
+
const entries = identity.platform === 'web' ? manifest.files.filter(entry => WEB_BASE_TEMPLATE_PATHS.has(entry.path)) : manifest.files;
|
|
868
|
+
return entries.map((entry) => {
|
|
976
869
|
const raw = readDefaultStarterSourceFile(baseDir, entry.path);
|
|
977
870
|
const identityApplied = renderIdentitySensitiveStarterFile(entry.path, raw, manifest, identity);
|
|
978
871
|
return {
|
|
979
872
|
path: entry.path,
|
|
980
|
-
content: applyProfileSeam(entry.path, identityApplied, profile,
|
|
873
|
+
content: applyProfileSeam(entry.path, identityApplied, profile, identity),
|
|
981
874
|
mutationClass: entry.class,
|
|
982
875
|
};
|
|
983
876
|
});
|
|
984
877
|
}
|
|
985
878
|
|
|
986
|
-
function buildCapabilitySliceFiles(identity, profile
|
|
879
|
+
function buildCapabilitySliceFiles(identity, profile) {
|
|
987
880
|
if (identity.capabilityResolution.modules.length === 0) return [];
|
|
988
881
|
const { baseDir, manifest } = loadAppSource(identity.capabilityResolution.resolvedModuleIds);
|
|
989
882
|
const mappings = identity.capabilityResolution.modules.flatMap((module) => (
|
|
@@ -1010,7 +903,7 @@ function buildCapabilitySliceFiles(identity, profile, versions) {
|
|
|
1010
903
|
const rendered = rewriteMappedModuleSpecifiers(raw, entry.path, outputPath, mappings);
|
|
1011
904
|
files.push({
|
|
1012
905
|
path: outputPath,
|
|
1013
|
-
content: applyProfileSeam(outputPath, rendered, profile,
|
|
906
|
+
content: applyProfileSeam(outputPath, rendered, profile, identity),
|
|
1014
907
|
mutationClass: 'app-owned product code',
|
|
1015
908
|
ownerKind: 'module',
|
|
1016
909
|
ownerId: module.id,
|
|
@@ -1021,7 +914,7 @@ function buildCapabilitySliceFiles(identity, profile, versions) {
|
|
|
1021
914
|
return files.sort((left, right) => left.path.localeCompare(right.path));
|
|
1022
915
|
}
|
|
1023
916
|
|
|
1024
|
-
function buildWorkbenchCoreFiles(identity, profile
|
|
917
|
+
function buildWorkbenchCoreFiles(identity, profile) {
|
|
1025
918
|
const { baseDir, manifest } = loadAppSource(identity.capabilityResolution.resolvedModuleIds);
|
|
1026
919
|
const sourcePrefix = `${WORKBENCH_CORE_SOURCE_ROOT}/`;
|
|
1027
920
|
const selected = manifest.files.filter((entry) => entry.path.startsWith(sourcePrefix));
|
|
@@ -1033,7 +926,7 @@ function buildWorkbenchCoreFiles(identity, profile, versions) {
|
|
|
1033
926
|
assertIdentityNeutralProductSource(entry.path, raw, manifest);
|
|
1034
927
|
return {
|
|
1035
928
|
path: entry.path,
|
|
1036
|
-
content: applyProfileSeam(entry.path, raw, profile,
|
|
929
|
+
content: applyProfileSeam(entry.path, raw, profile, identity),
|
|
1037
930
|
mutationClass: 'app-owned product code',
|
|
1038
931
|
ownerKind: 'skeleton',
|
|
1039
932
|
ownerId: 'workbench-core',
|
|
@@ -1056,6 +949,7 @@ export function renderAppIdentityInput(identity) {
|
|
|
1056
949
|
|
|
1057
950
|
export function renderAppBuildProfile(options = {}) {
|
|
1058
951
|
const identity = options.identity || null;
|
|
952
|
+
if (identity?.platform === 'web') return YAML.stringify(webBuildProfile(), { lineWidth: 0 });
|
|
1059
953
|
const targets = options.targets || (identity ? {
|
|
1060
954
|
'windows-x86_64': {
|
|
1061
955
|
os: 'windows',
|
|
@@ -1103,6 +997,7 @@ export function renderAppSubmissionInput(identity, options = {}) {
|
|
|
1103
997
|
display_name: identity.appTitle,
|
|
1104
998
|
version: identity.version,
|
|
1105
999
|
profile: identity.profile,
|
|
1000
|
+
...(identity.platform === 'web' ? { platform: 'web' } : {}),
|
|
1106
1001
|
npm_package_name: identity.packageName,
|
|
1107
1002
|
cargo_package_name: identity.cargoPackageName,
|
|
1108
1003
|
tauri_identifier: identity.tauriIdentifier,
|
|
@@ -1208,17 +1103,11 @@ function buildStructuredFiles(identity, profile, versions) {
|
|
|
1208
1103
|
content: renderScaffoldBoundary(),
|
|
1209
1104
|
mutationClass: 'scaffold-managed glue',
|
|
1210
1105
|
},
|
|
1211
|
-
{
|
|
1212
|
-
path: 'src-tauri/icons/icon.png',
|
|
1213
|
-
content: MINIMAL_TAURI_ICON_PNG,
|
|
1214
|
-
mutationClass: 'scaffold-managed glue',
|
|
1215
|
-
},
|
|
1216
|
-
{
|
|
1217
|
-
path: 'src-tauri/icons/icon.ico',
|
|
1218
|
-
content: MINIMAL_TAURI_ICON_ICO,
|
|
1219
|
-
mutationClass: 'scaffold-managed glue',
|
|
1220
|
-
},
|
|
1221
1106
|
];
|
|
1107
|
+
if (identity.platform === 'web') {
|
|
1108
|
+
const webPaths = new Set(['.gitignore', 'LICENSE', SCAFFOLD_TEMPLATE_LICENSE_NOTICE_PATH, 'package.json', 'nimi.app.yaml', '.nimi/config/app-identity.yaml', '.nimi/config/build-profile.yaml', '.nimi/admission/submission.yaml', '.nimi/contracts/scaffold-boundary.yaml']);
|
|
1109
|
+
return files.filter(file => webPaths.has(file.path));
|
|
1110
|
+
}
|
|
1222
1111
|
return files;
|
|
1223
1112
|
}
|
|
1224
1113
|
|
|
@@ -1235,7 +1124,7 @@ function buildIdentityMapping(identity, targetDir = '') {
|
|
|
1235
1124
|
appSlug: identity.appSlug,
|
|
1236
1125
|
rendererEntryId: identity.rendererEntryId,
|
|
1237
1126
|
devPort: identity.devPort,
|
|
1238
|
-
devRendererOrigin:
|
|
1127
|
+
devRendererOrigin: `${identity.platform === 'web' ? 'https' : 'http'}://127.0.0.1:${identity.devPort}`,
|
|
1239
1128
|
appOwnedNamespace: identity.appOwnedNamespace,
|
|
1240
1129
|
// Checkout location belongs to CLI diagnostics, not persisted identity.
|
|
1241
1130
|
targetDir: null,
|
|
@@ -1250,6 +1139,7 @@ function buildScaffoldIntent(identity, versions, targetDir = '') {
|
|
|
1250
1139
|
initCommand: 'pnpm exec nimi-app init',
|
|
1251
1140
|
initOrder: ['nimi-app create', 'pnpm install', 'pnpm exec nimi-app init'],
|
|
1252
1141
|
profile: identity.profile,
|
|
1142
|
+
...(identity.platform === 'web' ? { platform: 'web' } : {}),
|
|
1253
1143
|
appId: identity.appId,
|
|
1254
1144
|
appTitle: identity.appTitle,
|
|
1255
1145
|
version: identity.version,
|
|
@@ -1271,7 +1161,7 @@ function buildScaffoldIntent(identity, versions, targetDir = '') {
|
|
|
1271
1161
|
requiredStandardizedFeatureRefs: identity.capabilityResolution.requiredStandardizedFeatureRefs,
|
|
1272
1162
|
devPort: identity.devPort,
|
|
1273
1163
|
appIdentity: buildIdentityMapping(identity, targetDir),
|
|
1274
|
-
dependencyMatrix: buildDependencyMatrix(identity.profile, versions, identity.capabilityResolution),
|
|
1164
|
+
dependencyMatrix: buildDependencyMatrix(identity.profile, versions, identity.capabilityResolution, identity.platform),
|
|
1275
1165
|
semantics: {
|
|
1276
1166
|
role: 'app-scaffold-init-input',
|
|
1277
1167
|
authority: 'app-tools-orchestration-input-not-platform-admission',
|
|
@@ -1306,13 +1196,13 @@ function buildScaffoldFiles(identity, versions) {
|
|
|
1306
1196
|
'structured',
|
|
1307
1197
|
),
|
|
1308
1198
|
...withFileOwner(
|
|
1309
|
-
buildDefaultStarterTemplateFiles(identity, identity.profile
|
|
1199
|
+
buildDefaultStarterTemplateFiles(identity, identity.profile),
|
|
1310
1200
|
'carrier',
|
|
1311
1201
|
'default-starter',
|
|
1312
1202
|
),
|
|
1313
1203
|
...withFileOwner(buildDefaultStarterFiles(identity), 'generated-glue', 'composition'),
|
|
1314
|
-
...buildWorkbenchCoreFiles(identity, identity.profile
|
|
1315
|
-
...buildCapabilitySliceFiles(identity, identity.profile
|
|
1204
|
+
...buildWorkbenchCoreFiles(identity, identity.profile),
|
|
1205
|
+
...buildCapabilitySliceFiles(identity, identity.profile),
|
|
1316
1206
|
];
|
|
1317
1207
|
}
|
|
1318
1208
|
|
|
@@ -1367,8 +1257,8 @@ export function hashScaffoldContent(content) {
|
|
|
1367
1257
|
return createHash('sha256').update(content).digest('hex');
|
|
1368
1258
|
}
|
|
1369
1259
|
|
|
1370
|
-
function buildDependencyMatrix(profile, versions, capabilityResolution) {
|
|
1371
|
-
|
|
1260
|
+
function buildDependencyMatrix(profile, versions, capabilityResolution, platform = 'desktop') {
|
|
1261
|
+
const matrix = {
|
|
1372
1262
|
npm: {
|
|
1373
1263
|
'@nimiplatform/app-tools': versions.appToolsVersion,
|
|
1374
1264
|
'@nimiplatform/nimi-coding': versions.nimicodingVersion,
|
|
@@ -1376,22 +1266,20 @@ function buildDependencyMatrix(profile, versions, capabilityResolution) {
|
|
|
1376
1266
|
typescript: versions.typescriptVersion,
|
|
1377
1267
|
vite: versions.viteVersion,
|
|
1378
1268
|
tailwindcss: versions.tailwindcssVersion,
|
|
1379
|
-
'@tauri-apps/cli': versions.tauriCliVersion,
|
|
1380
1269
|
'@tailwindcss/vite': versions.tailwindcssViteVersion,
|
|
1381
1270
|
'@vitejs/plugin-react': versions.viteReactPluginVersion,
|
|
1382
1271
|
'@electron/packager': versions.electronPackagerVersion,
|
|
1383
1272
|
electron: versions.electronVersion,
|
|
1384
1273
|
esbuild: versions.esbuildVersion,
|
|
1274
|
+
pngjs: versions.pngjsVersion,
|
|
1385
1275
|
yaml: versions.yamlVersion,
|
|
1386
1276
|
},
|
|
1387
|
-
cargo: buildCargoDependencies(profile, versions, capabilityResolution),
|
|
1388
1277
|
toolchain: {
|
|
1389
1278
|
node: '>=24',
|
|
1390
1279
|
pnpm: versions.packageManager.replace(/^pnpm@/u, ''),
|
|
1391
|
-
rust: '>=1.80',
|
|
1392
|
-
tauri: '2',
|
|
1393
1280
|
},
|
|
1394
1281
|
};
|
|
1282
|
+
return platform === 'web' ? webDependencyMatrix(matrix) : matrix;
|
|
1395
1283
|
}
|
|
1396
1284
|
|
|
1397
1285
|
function buildScaffoldLock(identity, versions, files, targetDir = '') {
|
|
@@ -1424,6 +1312,7 @@ function buildScaffoldLock(identity, versions, files, targetDir = '') {
|
|
|
1424
1312
|
lockVersion: SCAFFOLD_LOCK_VERSION,
|
|
1425
1313
|
scaffoldVersion: SCAFFOLD_VERSION,
|
|
1426
1314
|
profile: identity.profile,
|
|
1315
|
+
...(identity.platform === 'web' ? { platform: 'web' } : {}),
|
|
1427
1316
|
appId: identity.appId,
|
|
1428
1317
|
appTitle: identity.appTitle,
|
|
1429
1318
|
version: identity.version,
|
|
@@ -1451,7 +1340,7 @@ function buildScaffoldLock(identity, versions, files, targetDir = '') {
|
|
|
1451
1340
|
},
|
|
1452
1341
|
managedFileHashes,
|
|
1453
1342
|
appOwnedInitialHashes,
|
|
1454
|
-
dependencyMatrix: buildDependencyMatrix(identity.profile, versions, identity.capabilityResolution),
|
|
1343
|
+
dependencyMatrix: buildDependencyMatrix(identity.profile, versions, identity.capabilityResolution, identity.platform),
|
|
1455
1344
|
semantics: {
|
|
1456
1345
|
initRole: 'developer-scaffold-initialization-after-install',
|
|
1457
1346
|
nimicodingProjectionOwner: '@nimiplatform/nimi-coding',
|
|
@@ -1466,7 +1355,7 @@ function buildScaffoldLock(identity, versions, files, targetDir = '') {
|
|
|
1466
1355
|
}
|
|
1467
1356
|
|
|
1468
1357
|
function buildAppScaffoldSnapshotWithResolver(
|
|
1469
|
-
{ profile, versions, appId, appTitle, version = DEFAULT_APP_VERSION, packageName, author, accentPack, features, targetDir = '' },
|
|
1358
|
+
{ profile, platform = 'desktop', versions, appId, appTitle, version = DEFAULT_APP_VERSION, packageName, author, accentPack, features, targetDir = '' },
|
|
1470
1359
|
featureResolver,
|
|
1471
1360
|
) {
|
|
1472
1361
|
const identity = buildAppIdentity(
|
|
@@ -1479,6 +1368,7 @@ function buildAppScaffoldSnapshotWithResolver(
|
|
|
1479
1368
|
accentPack,
|
|
1480
1369
|
features,
|
|
1481
1370
|
featureResolver,
|
|
1371
|
+
platform,
|
|
1482
1372
|
);
|
|
1483
1373
|
const createFiles = [
|
|
1484
1374
|
...buildScaffoldFiles(identity, versions),
|
|
@@ -1508,6 +1398,7 @@ function buildAppScaffoldSnapshotWithResolver(
|
|
|
1508
1398
|
appTitle: identity.appTitle,
|
|
1509
1399
|
version: identity.version,
|
|
1510
1400
|
profile: identity.profile,
|
|
1401
|
+
...(identity.platform === 'web' ? { platform: 'web' } : {}),
|
|
1511
1402
|
packageName: identity.packageName,
|
|
1512
1403
|
packageAuthor: identity.author || null,
|
|
1513
1404
|
cargoPackageName: identity.cargoPackageName,
|
|
@@ -1530,7 +1421,7 @@ export function buildAppScaffoldCandidateSnapshot(input) {
|
|
|
1530
1421
|
return buildAppScaffoldSnapshotWithResolver(input, resolveAppScaffoldCandidateFeatures);
|
|
1531
1422
|
}
|
|
1532
1423
|
|
|
1533
|
-
export function buildAppScaffoldSnapshotFromIntent({ intent, versions, targetDir = '', allowDerivedAppAccessDrift = false, refreshDerived = false }) {
|
|
1424
|
+
export function buildAppScaffoldSnapshotFromIntent({ intent, versions, targetDir = '', allowDerivedAppAccessDrift = false, refreshDerived = false, refreshInitialDependencies = false }) {
|
|
1534
1425
|
if (intent?.intentVersion !== SCAFFOLD_INTENT_VERSION) {
|
|
1535
1426
|
throw new Error(`Unsupported scaffold intent version: ${String(intent?.intentVersion || 'missing')}`);
|
|
1536
1427
|
}
|
|
@@ -1543,6 +1434,7 @@ export function buildAppScaffoldSnapshotFromIntent({ intent, versions, targetDir
|
|
|
1543
1434
|
const canonicalTargetDir = targetDir || intent?.appIdentity?.targetDir || '';
|
|
1544
1435
|
const snapshot = buildAppScaffoldSnapshotWithResolver({
|
|
1545
1436
|
profile: intent.profile,
|
|
1437
|
+
platform: intent.platform || 'desktop',
|
|
1546
1438
|
versions,
|
|
1547
1439
|
appId: intent.appId,
|
|
1548
1440
|
appTitle: intent.appTitle,
|
|
@@ -1555,15 +1447,26 @@ export function buildAppScaffoldSnapshotFromIntent({ intent, versions, targetDir
|
|
|
1555
1447
|
}, resolveAppScaffoldIntentFeatures);
|
|
1556
1448
|
const expectedIntent = JSON.parse(snapshot.filesByPath.get(SCAFFOLD_INTENT_PATH).content);
|
|
1557
1449
|
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-scaf-018c
|
|
1558
|
-
const immutableInputs = new Set(['intentVersion', 'scaffoldVersion', 'initRequired', 'initCommand', 'initOrder', 'profile', 'appId', 'appTitle', 'version', 'packageName', 'packageAuthor', 'cargoPackageName', 'tauriIdentifier', 'accentPack', 'directFeatures', 'devPort', 'semantics']);
|
|
1450
|
+
const immutableInputs = new Set(['intentVersion', 'scaffoldVersion', 'initRequired', 'initCommand', 'initOrder', 'profile', 'platform', 'appId', 'appTitle', 'version', 'packageName', 'packageAuthor', 'cargoPackageName', 'tauriIdentifier', 'accentPack', 'directFeatures', 'devPort', 'semantics']);
|
|
1559
1451
|
if (canonicalJson(Object.keys(intent).sort()) !== canonicalJson(Object.keys(expectedIntent).sort())) {
|
|
1560
1452
|
throw new Error('Scaffold intent fields do not match the current canonical resolved intent');
|
|
1561
1453
|
}
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
:
|
|
1454
|
+
// A compatible creator patch may have different dependency defaults. Its
|
|
1455
|
+
// historical matrix never supplies executable glue or new dependency values.
|
|
1456
|
+
let comparableIntent = intent;
|
|
1457
|
+
if (refreshDerived) {
|
|
1458
|
+
comparableIntent = Object.fromEntries(Object.entries(expectedIntent).map(([key, value]) => [key, immutableInputs.has(key) ? intent[key] : value]));
|
|
1459
|
+
} else if (refreshInitialDependencies) {
|
|
1460
|
+
const historical = intent.dependencyMatrix?.npm;
|
|
1461
|
+
const current = expectedIntent.dependencyMatrix.npm;
|
|
1462
|
+
if (canonicalJson(Object.keys(historical ?? {}).sort()) !== canonicalJson(Object.keys(current).sort())) {
|
|
1463
|
+
throw new Error('Scaffold creator dependencies differ from the current contract. Initialize with the original creator, then sync.');
|
|
1464
|
+
}
|
|
1465
|
+
for (const [name, spec] of Object.entries(historical)) validateAppScaffoldNpmRegistryVersion(spec, name);
|
|
1466
|
+
comparableIntent = { ...intent, dependencyMatrix: { ...intent.dependencyMatrix, npm: current } };
|
|
1467
|
+
} else if (allowDerivedAppAccessDrift) {
|
|
1468
|
+
comparableIntent = { ...intent, appAccessItems: expectedIntent.appAccessItems };
|
|
1469
|
+
}
|
|
1567
1470
|
if (canonicalJson(comparableIntent) !== canonicalJson(expectedIntent)) {
|
|
1568
1471
|
throw new Error('Scaffold intent does not match the current canonical resolved intent');
|
|
1569
1472
|
}
|
|
@@ -1577,6 +1480,7 @@ function buildAppScaffoldCreatePlanWithResolver(
|
|
|
1577
1480
|
const resolvedInput = resolveAppScaffoldCreateInputWithResolver({ cwd, options }, featureResolver);
|
|
1578
1481
|
const snapshot = buildAppScaffoldSnapshotWithResolver({
|
|
1579
1482
|
profile: resolvedInput.profile,
|
|
1483
|
+
platform: resolvedInput.platform || 'desktop',
|
|
1580
1484
|
versions,
|
|
1581
1485
|
appId: resolvedInput.appId,
|
|
1582
1486
|
appTitle: resolvedInput.appTitle,
|
|
@@ -1602,7 +1506,6 @@ function buildAppScaffoldCreatePlanWithResolver(
|
|
|
1602
1506
|
resolvedAssets: snapshot.lock.resolvedAssets,
|
|
1603
1507
|
hostAdapterContracts: snapshot.lock.hostAdapterContracts,
|
|
1604
1508
|
npmDependencies: snapshot.lock.dependencyMatrix.npm,
|
|
1605
|
-
cargoDependencies: snapshot.lock.dependencyMatrix.cargo,
|
|
1606
1509
|
appAccessItems: snapshot.lock.appAccessItems,
|
|
1607
1510
|
topology,
|
|
1608
1511
|
}),
|
|
@@ -1651,12 +1554,14 @@ export function createAppScaffoldCandidate(input) {
|
|
|
1651
1554
|
return createAppScaffold({ ...input, plan });
|
|
1652
1555
|
}
|
|
1653
1556
|
|
|
1654
|
-
export const APP_AUTHOR_DECLARATION_FIELDS = Object.freeze(['metadata', 'app_access', 'capability_contract_refs', 'required_standardized_feature_refs', 'storage_policy', 'safety_profile']);
|
|
1557
|
+
export const APP_AUTHOR_DECLARATION_FIELDS = Object.freeze(['metadata', 'app_access', 'capability_contract_refs', 'required_standardized_feature_refs', 'storage_policy', 'safety_profile', 'public_slug']);
|
|
1655
1558
|
|
|
1656
1559
|
// Source configuration is editable; existing scaffold checks still cover identity and carrier fields.
|
|
1657
1560
|
export function hashScaffoldManagedContent(relativePath, content) {
|
|
1658
1561
|
if (relativePath !== 'nimi.app.yaml') return hashScaffoldContent(content);
|
|
1659
1562
|
const manifest = YAML.parse(content.toString());
|
|
1660
1563
|
for (const field of APP_AUTHOR_DECLARATION_FIELDS) delete manifest[field];
|
|
1564
|
+
if (manifest.local_development) delete manifest.local_development.web;
|
|
1565
|
+
if (manifest.local_development) delete manifest.local_development.mobile;
|
|
1661
1566
|
return hashScaffoldContent(YAML.stringify(manifest, { lineWidth: 0 }));
|
|
1662
1567
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { minVersion, satisfies, valid, validRange } from 'semver';
|
|
2
|
+
|
|
3
|
+
// Patched release lines used by Nimi Apps. Vite GHSA-p4f5-76q4-ffq7
|
|
4
|
+
// and Electron's Chromium backports have separate fixes on maintained lines.
|
|
5
|
+
const fixes = {
|
|
6
|
+
vite: [
|
|
7
|
+
['>=8.3.0 <8.3.7', '8.3.7'], ['>=8.2.0 <8.2.5', '8.2.5'],
|
|
8
|
+
['>=8 <8.1.7', '8.1.7'], ['>=7 <7.3.8', '7.3.8'], ['>=4 <6.4.6', '6.4.6'],
|
|
9
|
+
],
|
|
10
|
+
electron: [
|
|
11
|
+
['>=45 <45.4.1', '45.4.1'], ['>=44 <44.11.5', '44.11.5'], ['>=43 <43.8.12', '43.8.12'],
|
|
12
|
+
],
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function lockedRegistryVersion(entry) {
|
|
16
|
+
return typeof entry?.version === 'string' ? valid(entry.version.split('(')[0]) : null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// Sync can raise a conventional range within its existing bounds. An exact
|
|
20
|
+
// vulnerable pin or a custom range remains an explicit publisher decision.
|
|
21
|
+
export function planToolchainUpdates(pkg, importer, versions) {
|
|
22
|
+
const updates = [];
|
|
23
|
+
for (const section of ['dependencies', 'devDependencies', 'optionalDependencies']) {
|
|
24
|
+
for (const [name, releases] of Object.entries(fixes)) {
|
|
25
|
+
const from = pkg[section]?.[name];
|
|
26
|
+
if (typeof from !== 'string') continue;
|
|
27
|
+
const entry = importer?.[section]?.[name];
|
|
28
|
+
const locked = lockedRegistryVersion(entry);
|
|
29
|
+
const minimum = validRange(from) && minVersion(from);
|
|
30
|
+
const affected = releases.find(([range]) => minimum && satisfies(minimum, range));
|
|
31
|
+
const lockedFix = releases.find(([range]) => locked && satisfies(locked, range));
|
|
32
|
+
if (!affected && !lockedFix) continue;
|
|
33
|
+
const fixedVersion = (lockedFix || affected)[1];
|
|
34
|
+
const preferred = minVersion(versions[name + 'Version'])?.version;
|
|
35
|
+
const recommended = [preferred, fixedVersion].find(version => version && satisfies(version, from)
|
|
36
|
+
&& !releases.some(([range]) => satisfies(version, range)));
|
|
37
|
+
const operator = from.match(/^([~^])\d+\.\d+\.\d+$/u)?.[1];
|
|
38
|
+
const to = affected && operator && recommended ? operator + recommended : from;
|
|
39
|
+
const alreadyPatched = locked && !lockedFix && satisfies(locked, from);
|
|
40
|
+
updates.push({ section, name, from, to, locked, lockedAffected: Boolean(lockedFix),
|
|
41
|
+
fixedVersion, manual: !recommended && !alreadyPatched });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return updates;
|
|
45
|
+
}
|
|
@@ -10,6 +10,7 @@ export const CANONICAL_CAPABILITY_IDS = Object.freeze([
|
|
|
10
10
|
"audio.voice.convert",
|
|
11
11
|
"image.face_swap",
|
|
12
12
|
"image.generate",
|
|
13
|
+
"image.upscale",
|
|
13
14
|
"music.generate",
|
|
14
15
|
"music.transcribe",
|
|
15
16
|
"realtime.interact",
|
|
@@ -19,6 +20,7 @@ export const CANONICAL_CAPABILITY_IDS = Object.freeze([
|
|
|
19
20
|
"text.generate",
|
|
20
21
|
"video.face_swap",
|
|
21
22
|
"video.generate",
|
|
23
|
+
"video.upscale",
|
|
22
24
|
"vision.locate",
|
|
23
25
|
"voice.create",
|
|
24
26
|
"world.generate"
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface DevelopmentRealm {
|
|
2
|
+
readonly name: 'official' | 'local';
|
|
3
|
+
readonly apiOrigin: string;
|
|
4
|
+
readonly realtimeOrigin: string;
|
|
5
|
+
readonly webOrigin: string;
|
|
6
|
+
readonly environmentId: string;
|
|
7
|
+
}
|
|
8
|
+
export function resolveDevelopmentRealm(selection?: 'official' | 'local', env?: Record<string, string | undefined>): DevelopmentRealm;
|
|
9
|
+
export function developmentRealmEnvironment(realm: DevelopmentRealm): Record<string, string>;
|
|
10
|
+
export function exactDevelopmentOrigin(value: string, label: string): string;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { REALM_PROFILES } from './realm-environments.generated.mjs';
|
|
2
|
+
|
|
3
|
+
// @nimi-authority: rule.nimi.platform.core-protocol.development-topology
|
|
4
|
+
export function resolveDevelopmentRealm(selection, env = process.env) {
|
|
5
|
+
const name = selection ?? env.NIMI_DEV_REALM ?? 'official';
|
|
6
|
+
if (!Object.hasOwn(REALM_PROFILES, name)) throw new Error('Choose --realm official or --realm local.');
|
|
7
|
+
const profile = { ...REALM_PROFILES[name] };
|
|
8
|
+
if (name === 'local') {
|
|
9
|
+
for (const [field, key] of [['apiOrigin', 'NIMI_DEV_REALM_URL'], ['realtimeOrigin', 'NIMI_DEV_REALTIME_URL'], ['webOrigin', 'NIMI_DEV_WEB_URL']]) {
|
|
10
|
+
if (env[key] !== undefined) profile[field] = exactDevelopmentOrigin(env[key], key);
|
|
11
|
+
}
|
|
12
|
+
if (profile.apiOrigin === REALM_PROFILES.official.apiOrigin) throw new Error('Official Realm requires the official environment.');
|
|
13
|
+
if (env.NIMI_DEV_REALM_ENVIRONMENT_ID !== undefined) profile.environmentId = env.NIMI_DEV_REALM_ENVIRONMENT_ID;
|
|
14
|
+
}
|
|
15
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9_.-]{0,127}$/.test(profile.environmentId)) throw new Error('Invalid development Realm environment id.');
|
|
16
|
+
return Object.freeze({ name, ...profile });
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function exactDevelopmentOrigin(value, label) {
|
|
20
|
+
const url = new URL(value);
|
|
21
|
+
if (value !== url.origin || url.username || url.password || (url.protocol !== 'https:'
|
|
22
|
+
&& !(url.protocol === 'http:' && ['localhost', '127.0.0.1'].includes(url.hostname)))) {
|
|
23
|
+
throw new Error(`${label} requires an exact HTTPS origin (HTTP only for loopback).`);
|
|
24
|
+
}
|
|
25
|
+
return url.origin;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function developmentRealmEnvironment(realm) {
|
|
29
|
+
return {
|
|
30
|
+
NIMI_DEV_REALM: realm.name,
|
|
31
|
+
NIMI_REALM_URL: realm.apiOrigin,
|
|
32
|
+
NIMI_REALTIME_URL: realm.realtimeOrigin,
|
|
33
|
+
NIMI_WEB_URL: realm.webOrigin,
|
|
34
|
+
NIMI_DEV_REALM_URL: realm.apiOrigin,
|
|
35
|
+
NIMI_DEV_REALTIME_URL: realm.realtimeOrigin,
|
|
36
|
+
NIMI_DEV_WEB_URL: realm.webOrigin,
|
|
37
|
+
NIMI_DEV_REALM_ENVIRONMENT_ID: realm.environmentId,
|
|
38
|
+
};
|
|
39
|
+
}
|