@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.
Files changed (96) hide show
  1. package/README.md +48 -5
  2. package/bin/nimi-app.mjs +26 -10
  3. package/lib/app-access-declaration.mjs +3 -0
  4. package/lib/app-dependency-combinations.mjs +70 -24
  5. package/lib/app-doctor-update.mjs +92 -36
  6. package/lib/app-host-support.mjs +6 -0
  7. package/lib/app-identifiers.mjs +27 -0
  8. package/lib/app-lifecycle-guidance.mjs +1 -1
  9. package/lib/app-pack.mjs +14 -36
  10. package/lib/app-project-lifecycle.mjs +141 -243
  11. package/lib/app-scaffold-capabilities.mjs +13 -109
  12. package/lib/app-scaffold-profiles.mjs +81 -115
  13. package/lib/app-scaffold.mjs +68 -164
  14. package/lib/app-toolchain-updates.mjs +45 -0
  15. package/lib/canonical-capability-ids.generated.mjs +2 -0
  16. package/lib/development-environment.d.mts +10 -0
  17. package/lib/development-environment.mjs +39 -0
  18. package/lib/hosted-web-release.mjs +98 -0
  19. package/lib/index.mjs +40 -1
  20. package/lib/mobile-development.mjs +19 -0
  21. package/lib/realm-environments.generated.mjs +5 -0
  22. package/lib/web-coordination.mjs +59 -0
  23. package/lib/web-development.d.mts +23 -0
  24. package/lib/web-development.mjs +118 -0
  25. package/lib/web-scaffold.mjs +125 -0
  26. package/package.json +32 -21
  27. package/scripts/dev-shell.mjs +4 -1
  28. package/scripts/sync-scaffold-versions.mjs +0 -2
  29. package/skills/nimi-app-lifecycle/SKILL.md +3 -1
  30. package/skills/nimi-app-lifecycle/references/acceptance.md +6 -2
  31. package/skills/nimi-app-lifecycle/references/adapt.md +5 -3
  32. package/skills/nimi-app-lifecycle/references/audit.md +3 -2
  33. package/skills/nimi-app-lifecycle/references/create.md +6 -2
  34. package/skills/nimi-app-lifecycle/references/upgrade-platform.md +12 -7
  35. package/templates/app-source/src/ai-studio-core/ai-studio-core.css +87 -52
  36. package/templates/app-source/src/ai-studio-core/history-policy.ts +45 -11
  37. package/templates/app-source/src/ai-studio-core/history.ts +22 -11
  38. package/templates/app-source/src/ai-studio-core/host-context.tsx +9 -4
  39. package/templates/app-source/src/ai-studio-core/index.ts +2 -0
  40. package/templates/app-source/src/ai-studio-core/job-recovery-panel.tsx +15 -5
  41. package/templates/app-source/src/ai-studio-core/job-recovery.ts +2 -2
  42. package/templates/app-source/src/ai-studio-core/messages/en.json +73 -19
  43. package/templates/app-source/src/ai-studio-core/messages/zh.json +73 -19
  44. package/templates/app-source/src/ai-studio-core/module-registration.ts +1 -0
  45. package/templates/app-source/src/ai-studio-core/non-success-presentation.ts +30 -5
  46. package/templates/app-source/src/ai-studio-core/parameter-fields.tsx +12 -6
  47. package/templates/app-source/src/ai-studio-core/parameters.ts +4 -0
  48. package/templates/app-source/src/ai-studio-core/prompt-drafts.ts +42 -0
  49. package/templates/app-source/src/ai-studio-core/runtime-types.ts +9 -2
  50. package/templates/app-source/src/ai-studio-core/runtime.ts +8 -4
  51. package/templates/app-source/src/ai-studio-core/section-ai-testing-composer.tsx +98 -90
  52. package/templates/app-source/src/ai-studio-core/section-ai-testing-exchange-result.tsx +1 -1
  53. package/templates/app-source/src/ai-studio-core/section-ai-testing-history.tsx +205 -48
  54. package/templates/app-source/src/ai-studio-core/section-ai-testing-input.ts +1 -0
  55. package/templates/app-source/src/ai-studio-core/section-ai-testing-output.tsx +36 -14
  56. package/templates/app-source/src/ai-studio-core/section-ai-testing-result.tsx +96 -75
  57. package/templates/app-source/src/ai-studio-core/section-ai-testing-run.ts +59 -16
  58. package/templates/app-source/src/ai-studio-core/section-ai-testing-session-result.tsx +2 -0
  59. package/templates/app-source/src/ai-studio-core/section-ai-testing-studio-result.tsx +12 -21
  60. package/templates/app-source/src/ai-studio-core/section-ai-testing-transcription-result.tsx +2 -2
  61. package/templates/app-source/src/ai-studio-core/section-ai-testing-vision-result.tsx +3 -3
  62. package/templates/app-source/src/ai-studio-core/section-ai-testing.tsx +158 -76
  63. package/templates/app-source/src/ai-studio-core/workspace.tsx +49 -22
  64. package/templates/app-source/src/product-modules/agent-center/index.tsx +2 -3
  65. package/templates/app-source/src/product-modules/agent-conversation/index.tsx +2 -3
  66. package/templates/app-source/src/studio-modules/studio-create/messages/en.json +12 -3
  67. package/templates/app-source/src/studio-modules/studio-create/messages/zh.json +12 -3
  68. package/templates/app-source/src/studio-modules/studio-create/parameter-panel.tsx +11 -2
  69. package/templates/app-source/src/studio-modules/studio-create/parameters.ts +2 -1
  70. package/templates/app-source/src/studio-modules/studio-create/runtime.ts +47 -5
  71. package/templates/app-source/src/studio-modules/studio-media/messages/en.json +59 -8
  72. package/templates/app-source/src/studio-modules/studio-media/messages/zh.json +59 -8
  73. package/templates/app-source/src/studio-modules/studio-media/music-parameters.tsx +2 -1
  74. package/templates/app-source/src/studio-modules/studio-media/parameter-panel.tsx +271 -83
  75. package/templates/app-source/src/studio-modules/studio-media/parameters.ts +120 -2
  76. package/templates/app-source/src/studio-modules/studio-media/registration.ts +1 -0
  77. package/templates/app-source/src/studio-modules/studio-media/runtime.ts +24 -14
  78. package/templates/app-source/src/studio-modules/studio-voice/descriptors.ts +1 -1
  79. package/templates/app-source/src/studio-modules/studio-voice/messages/en.json +3 -2
  80. package/templates/app-source/src/studio-modules/studio-voice/messages/zh.json +3 -2
  81. package/templates/app-source/src/studio-modules/studio-voice/parameter-panel.tsx +46 -23
  82. package/templates/app-source/src/studio-modules/studio-voice/registration.ts +2 -1
  83. package/templates/app-source/src/studio-modules/studio-voice/runtime.ts +2 -2
  84. package/templates/app-source/src/workbench-core/workbench-core.tsx +27 -3
  85. package/templates/default-starter/AGENTS.md +3 -3
  86. package/templates/default-starter/README.md +1 -1
  87. package/templates/default-starter/src/shell/App.tsx +6 -18
  88. package/templates/default-starter/src/shell/auth/local-app-client.ts +6 -15
  89. package/templates/default-starter/src/shell/auth/runtime-platform.ts +7 -107
  90. package/templates/default-starter/src/shell/workbench-target-adapter.ts +9 -126
  91. package/templates/default-starter.manifest.json +0 -16
  92. package/templates/hosted-web-release.yml +88 -0
  93. package/templates/default-starter/src-tauri/Cargo.toml +0 -17
  94. package/templates/default-starter/src-tauri/build.rs +0 -32
  95. package/templates/default-starter/src-tauri/capabilities/default.json +0 -7
  96. package/templates/default-starter/src-tauri/tauri.conf.json +0 -26
@@ -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 (!/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?(?:\.[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)+$/.test(raw)) {
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
- const capabilityResolution = featureResolver(features);
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,7 +621,6 @@ 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,
@@ -656,7 +662,6 @@ function buildPackageJson(profile, versions, identity) {
656
662
  build: 'tsc --noEmit && vite build',
657
663
  'build:electron': 'tsc -p tsconfig.electron.json && node scripts/bundle-electron-preload.mjs',
658
664
  'build:electron:production': 'node scripts/clean-electron-production.mjs && pnpm run build && pnpm run build:electron && node scripts/package-electron-production.mjs',
659
- 'build:tauri:production': 'tauri build',
660
665
  postinstall: 'install-electron --no',
661
666
  validate: 'node scripts/validate.mjs',
662
667
  },
@@ -666,7 +671,7 @@ function buildPackageJson(profile, versions, identity) {
666
671
  if (identity.author) {
667
672
  packageJson.author = identity.author;
668
673
  }
669
- return packageJson;
674
+ return identity.platform === 'web' ? webPackage(packageJson) : packageJson;
670
675
  }
671
676
 
672
677
  function buildRuntimeDependencies(profile, versions, capabilityResolution) {
@@ -701,96 +706,6 @@ function resolveScaffoldVersionReference(value, versions, dependencyName) {
701
706
  return resolved;
702
707
  }
703
708
 
704
- function buildCargoDependencies(profile, versions, capabilityResolution) {
705
- const dependencies = {
706
- 'nimi-shell-tauri': versions.nimiShellTauriVersion,
707
- tauri: { version: '2', features: [] },
708
- serde: { version: '1', features: ['derive'] },
709
- serde_json: '1',
710
- url: '2',
711
- base64: '0.23',
712
- dirs: '7',
713
- time: '=0.3.55',
714
- 'tauri-build': { version: '2', features: [] },
715
- };
716
- for (const [name, value] of Object.entries(capabilityResolution.cargoDependencies || {})) {
717
- if (Object.hasOwn(dependencies, name) && canonicalJson(dependencies[name]) !== canonicalJson(value)) {
718
- throw new Error(`App scaffold base/module Cargo dependency collision for ${name}`);
719
- }
720
- dependencies[name] = value;
721
- }
722
- for (const [name, value] of Object.entries(dependencies)) {
723
- validateAppScaffoldCargoDependencyValue(value, name);
724
- }
725
- return dependencies;
726
- }
727
-
728
- function cargoShellDependencyLine(profile, versions) {
729
- return `nimi-shell-tauri = ${renderCargoDependencyValue(versions.nimiShellTauriVersion, 'nimi-shell-tauri')}`;
730
- }
731
-
732
- export function renderCargoDependencyValue(value, label) {
733
- validateAppScaffoldCargoDependencyValue(value, label);
734
- if (typeof value === 'string' && value.trim() === value && value) {
735
- return JSON.stringify(value);
736
- }
737
- if (!value || typeof value !== 'object' || Array.isArray(value)) {
738
- throw new Error(`Invalid Cargo dependency descriptor: ${label}`);
739
- }
740
- const fields = [];
741
- for (const key of Object.keys(value).sort()) {
742
- const field = value[key];
743
- if (typeof field === 'string' && field.trim() === field && field) {
744
- fields.push(`${key} = ${JSON.stringify(field)}`);
745
- continue;
746
- }
747
- if (typeof field === 'boolean') {
748
- fields.push(`${key} = ${field ? 'true' : 'false'}`);
749
- continue;
750
- }
751
- if (Array.isArray(field) && field.every((item) => typeof item === 'string' && item.trim() === item && item)) {
752
- fields.push(`${key} = [${field.map((item) => JSON.stringify(item)).join(', ')}]`);
753
- continue;
754
- }
755
- throw new Error(`Invalid Cargo dependency value: ${label}.${key}`);
756
- }
757
- if (fields.length === 0) throw new Error(`Invalid empty Cargo dependency descriptor: ${label}`);
758
- return `{ ${fields.join(', ')} }`;
759
- }
760
-
761
- function renderCargoManifest(content, profile, versions, identity) {
762
- let rendered = content.replace(
763
- /^nimi-shell-tauri\s*=.*$/m,
764
- cargoShellDependencyLine(profile, versions),
765
- );
766
- rendered = rendered.replace(
767
- /^(\[package\][\s\S]*?^version\s*=\s*)"[^"]+"/m,
768
- `$1${JSON.stringify(identity.version)}`,
769
- );
770
- const baseNames = new Set([
771
- 'tauri',
772
- 'nimi-shell-tauri',
773
- 'serde',
774
- 'serde_json',
775
- 'url',
776
- 'base64',
777
- 'dirs',
778
- 'time',
779
- 'tauri-build',
780
- ]);
781
- const additions = [];
782
- for (const [name, value] of Object.entries(identity.capabilityResolution.cargoDependencies || {})) {
783
- if (!/^[A-Za-z0-9_-]+$/u.test(name)) throw new Error(`Invalid Cargo dependency name: ${name}`);
784
- if (baseNames.has(name)) continue;
785
- additions.push(`${name} = ${renderCargoDependencyValue(value, name)}`);
786
- }
787
- if (additions.length === 0) return rendered;
788
- const marker = '\n[build-dependencies]';
789
- if (!rendered.includes(marker)) throw new Error('Generated Cargo manifest is missing [build-dependencies]');
790
- rendered = rendered.replace(marker, `\n${additions.join('\n')}\n${marker}`);
791
- return rendered;
792
- }
793
-
794
709
  function targetIdentityMap(identity) {
795
710
  return {
796
711
  tauriIdentifier: identity.tauriIdentifier,
@@ -891,6 +806,7 @@ function buildNimiAppManifest(identity) {
891
806
  display_name: identity.appTitle,
892
807
  version: identity.version,
893
808
  profile: identity.profile,
809
+ ...(identity.platform === 'web' ? { platform: 'web' } : {}),
894
810
  manifest_role: 'submitted-input',
895
811
  app_access: identity.appAccessItems,
896
812
  capability_contract_refs: identity.capabilityResolution.capabilityContractRefs,
@@ -901,29 +817,12 @@ function buildNimiAppManifest(identity) {
901
817
  icon: 'assets/app-icon.png',
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, versions, manifest, identity) {
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, versions) {
865
+ function buildDefaultStarterTemplateFiles(identity, profile) {
973
866
  const { baseDir, manifest } = loadDefaultStarterSource();
974
- const target = targetIdentityMap(identity);
975
- return manifest.files.map((entry) => {
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, versions, manifest, identity),
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, versions) {
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, versions, manifest, identity),
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, versions) {
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, versions, manifest, identity),
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: `http://127.0.0.1:${identity.devPort}`,
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, versions),
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, versions),
1315
- ...buildCapabilitySliceFiles(identity, identity.profile, versions),
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
- return {
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,7 +1266,6 @@ 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,
@@ -1385,14 +1274,12 @@ function buildDependencyMatrix(profile, versions, capabilityResolution) {
1385
1274
  pngjs: versions.pngjsVersion,
1386
1275
  yaml: versions.yamlVersion,
1387
1276
  },
1388
- cargo: buildCargoDependencies(profile, versions, capabilityResolution),
1389
1277
  toolchain: {
1390
1278
  node: '>=24',
1391
1279
  pnpm: versions.packageManager.replace(/^pnpm@/u, ''),
1392
- rust: '>=1.80',
1393
- tauri: '2',
1394
1280
  },
1395
1281
  };
1282
+ return platform === 'web' ? webDependencyMatrix(matrix) : matrix;
1396
1283
  }
1397
1284
 
1398
1285
  function buildScaffoldLock(identity, versions, files, targetDir = '') {
@@ -1425,6 +1312,7 @@ function buildScaffoldLock(identity, versions, files, targetDir = '') {
1425
1312
  lockVersion: SCAFFOLD_LOCK_VERSION,
1426
1313
  scaffoldVersion: SCAFFOLD_VERSION,
1427
1314
  profile: identity.profile,
1315
+ ...(identity.platform === 'web' ? { platform: 'web' } : {}),
1428
1316
  appId: identity.appId,
1429
1317
  appTitle: identity.appTitle,
1430
1318
  version: identity.version,
@@ -1452,7 +1340,7 @@ function buildScaffoldLock(identity, versions, files, targetDir = '') {
1452
1340
  },
1453
1341
  managedFileHashes,
1454
1342
  appOwnedInitialHashes,
1455
- dependencyMatrix: buildDependencyMatrix(identity.profile, versions, identity.capabilityResolution),
1343
+ dependencyMatrix: buildDependencyMatrix(identity.profile, versions, identity.capabilityResolution, identity.platform),
1456
1344
  semantics: {
1457
1345
  initRole: 'developer-scaffold-initialization-after-install',
1458
1346
  nimicodingProjectionOwner: '@nimiplatform/nimi-coding',
@@ -1467,7 +1355,7 @@ function buildScaffoldLock(identity, versions, files, targetDir = '') {
1467
1355
  }
1468
1356
 
1469
1357
  function buildAppScaffoldSnapshotWithResolver(
1470
- { 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 = '' },
1471
1359
  featureResolver,
1472
1360
  ) {
1473
1361
  const identity = buildAppIdentity(
@@ -1480,6 +1368,7 @@ function buildAppScaffoldSnapshotWithResolver(
1480
1368
  accentPack,
1481
1369
  features,
1482
1370
  featureResolver,
1371
+ platform,
1483
1372
  );
1484
1373
  const createFiles = [
1485
1374
  ...buildScaffoldFiles(identity, versions),
@@ -1509,6 +1398,7 @@ function buildAppScaffoldSnapshotWithResolver(
1509
1398
  appTitle: identity.appTitle,
1510
1399
  version: identity.version,
1511
1400
  profile: identity.profile,
1401
+ ...(identity.platform === 'web' ? { platform: 'web' } : {}),
1512
1402
  packageName: identity.packageName,
1513
1403
  packageAuthor: identity.author || null,
1514
1404
  cargoPackageName: identity.cargoPackageName,
@@ -1531,7 +1421,7 @@ export function buildAppScaffoldCandidateSnapshot(input) {
1531
1421
  return buildAppScaffoldSnapshotWithResolver(input, resolveAppScaffoldCandidateFeatures);
1532
1422
  }
1533
1423
 
1534
- export function buildAppScaffoldSnapshotFromIntent({ intent, versions, targetDir = '', allowDerivedAppAccessDrift = false, refreshDerived = false }) {
1424
+ export function buildAppScaffoldSnapshotFromIntent({ intent, versions, targetDir = '', allowDerivedAppAccessDrift = false, refreshDerived = false, refreshInitialDependencies = false }) {
1535
1425
  if (intent?.intentVersion !== SCAFFOLD_INTENT_VERSION) {
1536
1426
  throw new Error(`Unsupported scaffold intent version: ${String(intent?.intentVersion || 'missing')}`);
1537
1427
  }
@@ -1544,6 +1434,7 @@ export function buildAppScaffoldSnapshotFromIntent({ intent, versions, targetDir
1544
1434
  const canonicalTargetDir = targetDir || intent?.appIdentity?.targetDir || '';
1545
1435
  const snapshot = buildAppScaffoldSnapshotWithResolver({
1546
1436
  profile: intent.profile,
1437
+ platform: intent.platform || 'desktop',
1547
1438
  versions,
1548
1439
  appId: intent.appId,
1549
1440
  appTitle: intent.appTitle,
@@ -1556,15 +1447,26 @@ export function buildAppScaffoldSnapshotFromIntent({ intent, versions, targetDir
1556
1447
  }, resolveAppScaffoldIntentFeatures);
1557
1448
  const expectedIntent = JSON.parse(snapshot.filesByPath.get(SCAFFOLD_INTENT_PATH).content);
1558
1449
  // @nimi-authority: rule.nimi.platform.app-ecosystem.p-scaf-018c
1559
- 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']);
1560
1451
  if (canonicalJson(Object.keys(intent).sort()) !== canonicalJson(Object.keys(expectedIntent).sort())) {
1561
1452
  throw new Error('Scaffold intent fields do not match the current canonical resolved intent');
1562
1453
  }
1563
- const comparableIntent = refreshDerived
1564
- ? Object.fromEntries(Object.entries(expectedIntent).map(([key, value]) => [key, immutableInputs.has(key) ? intent[key] : value]))
1565
- : allowDerivedAppAccessDrift
1566
- ? { ...intent, appAccessItems: expectedIntent.appAccessItems }
1567
- : intent;
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
+ }
1568
1470
  if (canonicalJson(comparableIntent) !== canonicalJson(expectedIntent)) {
1569
1471
  throw new Error('Scaffold intent does not match the current canonical resolved intent');
1570
1472
  }
@@ -1578,6 +1480,7 @@ function buildAppScaffoldCreatePlanWithResolver(
1578
1480
  const resolvedInput = resolveAppScaffoldCreateInputWithResolver({ cwd, options }, featureResolver);
1579
1481
  const snapshot = buildAppScaffoldSnapshotWithResolver({
1580
1482
  profile: resolvedInput.profile,
1483
+ platform: resolvedInput.platform || 'desktop',
1581
1484
  versions,
1582
1485
  appId: resolvedInput.appId,
1583
1486
  appTitle: resolvedInput.appTitle,
@@ -1603,7 +1506,6 @@ function buildAppScaffoldCreatePlanWithResolver(
1603
1506
  resolvedAssets: snapshot.lock.resolvedAssets,
1604
1507
  hostAdapterContracts: snapshot.lock.hostAdapterContracts,
1605
1508
  npmDependencies: snapshot.lock.dependencyMatrix.npm,
1606
- cargoDependencies: snapshot.lock.dependencyMatrix.cargo,
1607
1509
  appAccessItems: snapshot.lock.appAccessItems,
1608
1510
  topology,
1609
1511
  }),
@@ -1652,12 +1554,14 @@ export function createAppScaffoldCandidate(input) {
1652
1554
  return createAppScaffold({ ...input, plan });
1653
1555
  }
1654
1556
 
1655
- 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']);
1656
1558
 
1657
1559
  // Source configuration is editable; existing scaffold checks still cover identity and carrier fields.
1658
1560
  export function hashScaffoldManagedContent(relativePath, content) {
1659
1561
  if (relativePath !== 'nimi.app.yaml') return hashScaffoldContent(content);
1660
1562
  const manifest = YAML.parse(content.toString());
1661
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;
1662
1566
  return hashScaffoldContent(YAML.stringify(manifest, { lineWidth: 0 }));
1663
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
+ }