@nimiplatform/app-tools 0.7.5 → 0.12.0
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 +59 -5
- package/bin/nimi-app.mjs +11 -3
- package/lib/app-access-declaration.mjs +1 -0
- package/lib/app-dependency-combinations.mjs +16 -28
- package/lib/app-doctor-update.mjs +66 -7
- package/lib/app-info.mjs +8 -1
- package/lib/app-project-lifecycle.mjs +82 -9
- package/lib/app-scaffold-capabilities.mjs +3 -3
- package/lib/app-scaffold-profiles.mjs +96 -26
- package/lib/app-scaffold.mjs +54 -7
- package/lib/canonical-capability-ids.generated.mjs +4 -0
- package/package.json +26 -25
- package/scripts/dev-shell.mjs +61 -17
- package/skills/nimi-app-lifecycle/references/acceptance.md +1 -1
- package/skills/nimi-app-lifecycle/references/adapt.md +2 -2
- package/skills/nimi-app-lifecycle/references/release.md +1 -1
- package/skills/nimi-app-lifecycle/references/upgrade-platform.md +14 -0
- package/templates/app-source/src/ai-studio-core/ai-config.ts +17 -3
- package/templates/app-source/src/ai-studio-core/ai-studio-core.css +40 -3
- package/templates/app-source/src/ai-studio-core/audio-separation-request.ts +24 -0
- package/templates/app-source/src/ai-studio-core/contexts.tsx +4 -0
- package/templates/app-source/src/ai-studio-core/history-policy.ts +395 -41
- package/templates/app-source/src/ai-studio-core/history.ts +262 -10
- package/templates/app-source/src/ai-studio-core/host-context.tsx +15 -2
- package/templates/app-source/src/ai-studio-core/index.ts +15 -4
- package/templates/app-source/src/ai-studio-core/job-recovery-panel.tsx +105 -0
- package/templates/app-source/src/ai-studio-core/job-recovery.ts +224 -0
- package/templates/app-source/src/ai-studio-core/managed-result-references.ts +79 -0
- package/templates/app-source/src/ai-studio-core/messages/en.json +185 -10
- package/templates/app-source/src/ai-studio-core/messages/zh.json +185 -10
- package/templates/app-source/src/ai-studio-core/module-registration.ts +9 -1
- package/templates/app-source/src/ai-studio-core/non-success-presentation.ts +81 -2
- package/templates/app-source/src/ai-studio-core/parameters.ts +34 -1
- package/templates/app-source/src/ai-studio-core/runtime-types.ts +124 -8
- package/templates/app-source/src/ai-studio-core/runtime.ts +218 -20
- package/templates/app-source/src/ai-studio-core/section-ai-testing-annotation-result.tsx +123 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-artifact-preview.ts +3 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-audio-separation-result.tsx +26 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-composer.tsx +14 -7
- package/templates/app-source/src/ai-studio-core/section-ai-testing-decision-result.tsx +76 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-exchange-result.tsx +71 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-history.tsx +20 -4
- package/templates/app-source/src/ai-studio-core/section-ai-testing-input.ts +29 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-music-result.tsx +45 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-output.tsx +132 -10
- package/templates/app-source/src/ai-studio-core/section-ai-testing-result.tsx +122 -38
- package/templates/app-source/src/ai-studio-core/section-ai-testing-run.ts +4 -3
- package/templates/app-source/src/ai-studio-core/section-ai-testing-session-result.tsx +66 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-studio-result.tsx +100 -22
- package/templates/app-source/src/ai-studio-core/section-ai-testing-surface.tsx +6 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-transcript-result.tsx +45 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-transcription-result.tsx +106 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-vision-result.tsx +23 -4
- package/templates/app-source/src/ai-studio-core/section-ai-testing-voice-asset-actions.tsx +40 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-voice-conversion-result.tsx +20 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing.tsx +219 -35
- package/templates/app-source/src/ai-studio-core/text-annotation-document.ts +50 -0
- package/templates/app-source/src/ai-studio-core/text-media-replay.ts +51 -0
- package/templates/app-source/src/ai-studio-core/voice-assets.ts +17 -0
- package/templates/app-source/src/ai-studio-core/workspace.tsx +48 -6
- package/templates/app-source/src/studio-modules/studio-create/descriptors.ts +1 -1
- package/templates/app-source/src/studio-modules/studio-create/messages/en.json +13 -1
- package/templates/app-source/src/studio-modules/studio-create/messages/zh.json +13 -1
- 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 -2
- package/templates/app-source/src/studio-modules/studio-create/registration.ts +2 -2
- package/templates/app-source/src/studio-modules/studio-create/runtime.ts +121 -3
- package/templates/app-source/src/studio-modules/studio-media/audio-separate-parameters.tsx +72 -0
- package/templates/app-source/src/studio-modules/studio-media/audio-separate-runtime.ts +90 -0
- package/templates/app-source/src/studio-modules/studio-media/descriptors.ts +16 -1
- package/templates/app-source/src/studio-modules/studio-media/index.ts +2 -0
- package/templates/app-source/src/studio-modules/studio-media/messages/en.json +225 -7
- package/templates/app-source/src/studio-modules/studio-media/messages/zh.json +225 -7
- package/templates/app-source/src/studio-modules/studio-media/music-parameters.tsx +85 -0
- package/templates/app-source/src/studio-modules/studio-media/music-transcription-parameters.tsx +85 -0
- package/templates/app-source/src/studio-modules/studio-media/music-transcription-runtime.ts +64 -0
- package/templates/app-source/src/studio-modules/studio-media/parameter-panel.tsx +9 -26
- package/templates/app-source/src/studio-modules/studio-media/parameters.ts +170 -6
- package/templates/app-source/src/studio-modules/studio-media/registration.ts +29 -1
- package/templates/app-source/src/studio-modules/studio-media/runtime.ts +90 -6
- package/templates/app-source/src/studio-modules/studio-media/vision-parameters.tsx +1 -0
- package/templates/app-source/src/studio-modules/studio-media/vision-runtime.ts +23 -5
- package/templates/app-source/src/studio-modules/studio-media/voice-convert-parameters.tsx +132 -0
- package/templates/app-source/src/studio-modules/studio-media/voice-convert-runtime.ts +120 -0
- package/templates/app-source/src/studio-modules/studio-voice/audio-url.ts +25 -0
- package/templates/app-source/src/studio-modules/studio-voice/messages/en.json +4 -4
- package/templates/app-source/src/studio-modules/studio-voice/messages/zh.json +4 -4
- package/templates/app-source/src/studio-modules/studio-voice/parameters.ts +28 -0
- package/templates/app-source/src/studio-modules/studio-voice/runtime.ts +66 -30
- package/templates/app-source/src/workbench-core/index.ts +2 -0
- package/templates/app-source/src/workbench-core/runtime-gate.tsx +102 -6
- package/templates/app-source/src/workbench-core/workbench-core.css +42 -0
- package/templates/app-source/src/workbench-core/workbench-core.tsx +69 -18
- package/templates/app-source.manifest.json +100 -0
- package/templates/default-starter/README.md +2 -1
- package/templates/default-starter/src/shell/workbench-target-adapter.ts +102 -12
- package/templates/default-starter.manifest.json +0 -4
|
@@ -104,7 +104,11 @@ const DEFAULT_VITE_CONFIG = [
|
|
|
104
104
|
'export default defineConfig({',
|
|
105
105
|
" base: './',",
|
|
106
106
|
" cacheDir: '.vite',",
|
|
107
|
-
'
|
|
107
|
+
' // The bootstrap creates the root once; only components participate in Fast Refresh.',
|
|
108
|
+
" plugins: [react({ exclude: [/\\/node_modules\\//, /\\/src\\/main\\.tsx$/] }), tailwindcss()],",
|
|
109
|
+
' server: {',
|
|
110
|
+
" watch: { ignored: ['**/.nimi/local/**', '**/dist/**', '**/dist-electron/**', '**/dist-electron-package/**'] },",
|
|
111
|
+
' },',
|
|
108
112
|
' resolve: {',
|
|
109
113
|
" dedupe: ['react', 'react-dom', 'react/jsx-runtime', 'react/jsx-dev-runtime'],",
|
|
110
114
|
' },',
|
|
@@ -155,7 +159,6 @@ function renderDefaultElectronProductionPackager(identity) {
|
|
|
155
159
|
"import { spawn } from 'node:child_process';",
|
|
156
160
|
"import { copyFile, cp, mkdir, mkdtemp, readFile, realpath, rm, writeFile } from 'node:fs/promises';",
|
|
157
161
|
"import { createRequire } from 'node:module';",
|
|
158
|
-
"import { tmpdir } from 'node:os';",
|
|
159
162
|
"import path from 'node:path';",
|
|
160
163
|
"import { fileURLToPath } from 'node:url';",
|
|
161
164
|
"import { packager } from '@electron/packager';",
|
|
@@ -199,7 +202,10 @@ function renderDefaultElectronProductionPackager(identity) {
|
|
|
199
202
|
'',
|
|
200
203
|
'await rm(outputRoot, { recursive: true, force: true });',
|
|
201
204
|
'// Use the physical staging root: pnpm canonicalizes cwd before resolving relative tarballs.',
|
|
202
|
-
|
|
205
|
+
'// Staging is this project\'s ignored work area, not OS temp; finally removes it.',
|
|
206
|
+
"const stagingParent = path.join(appRoot, '.nimi', 'local', 'build');",
|
|
207
|
+
'await mkdir(stagingParent, { recursive: true });',
|
|
208
|
+
"const stagingRoot = await realpath(await mkdtemp(path.join(stagingParent, 'electron-')));",
|
|
203
209
|
"const productionSourceRoot = path.join(stagingRoot, 'app');",
|
|
204
210
|
"const packagerTempRoot = path.join(stagingRoot, 'packager');",
|
|
205
211
|
'let packageCompleted = false;',
|
|
@@ -228,7 +234,11 @@ function renderDefaultElectronProductionPackager(identity) {
|
|
|
228
234
|
' try {',
|
|
229
235
|
" const workspace = parseYaml(await readFile(path.join(appRoot, 'pnpm-workspace.yaml'), 'utf8'));",
|
|
230
236
|
" await writeFile(path.join(productionSourceRoot, 'pnpm-workspace.yaml'), stringifyYaml({ ...rebaseLocalPackagePaths(workspace, appRoot, productionSourceRoot), packages: ['.'] }));",
|
|
231
|
-
" } catch (cause) {
|
|
237
|
+
" } catch (cause) {",
|
|
238
|
+
" if (cause.code !== 'ENOENT') throw cause;",
|
|
239
|
+
' // Staging sits inside the project: keep pnpm from adopting an enclosing workspace.',
|
|
240
|
+
" await writeFile(path.join(productionSourceRoot, 'pnpm-workspace.yaml'), stringifyYaml({ packages: ['.'] }));",
|
|
241
|
+
' }',
|
|
232
242
|
" await cp(path.join(appRoot, 'dist'), path.join(productionSourceRoot, 'dist'), { recursive: true, force: false });",
|
|
233
243
|
" await copyFile(path.join(appRoot, 'dist-electron', 'main.js'), path.join(productionSourceRoot, 'dist-electron', 'main.js'));",
|
|
234
244
|
" await copyFile(path.join(appRoot, 'dist-electron', 'preload.cjs'), path.join(productionSourceRoot, 'dist-electron', 'preload.cjs'));",
|
|
@@ -264,7 +274,9 @@ function renderDefaultElectronProductionPackager(identity) {
|
|
|
264
274
|
' tmpdir: packagerTempRoot,',
|
|
265
275
|
' overwrite: false,',
|
|
266
276
|
' // Native add-ons and their shared libraries must remain accessible to the OS loader.',
|
|
267
|
-
|
|
277
|
+
' // asar matches absolute paths with matchBase; a slash-free pattern matches file names,',
|
|
278
|
+
" // because '**' does not cross the dot directories of this staging or the App's path.",
|
|
279
|
+
" asar: { unpack: '*.{node,dylib,dll}' },",
|
|
268
280
|
" ...(MACOS_BUILD ? { extraResource: [path.join(stagingRoot, 'nimi-native')] } : {}),",
|
|
269
281
|
' prune: false,',
|
|
270
282
|
' quiet: true,',
|
|
@@ -273,7 +285,7 @@ function renderDefaultElectronProductionPackager(identity) {
|
|
|
273
285
|
' // Runtime preserves these bytes; Nimi never signs installed third-party code.',
|
|
274
286
|
' ...(MACOS_BUILD ? { osxSign: {',
|
|
275
287
|
" identity: '-', identityValidation: false, preAutoEntitlements: false,",
|
|
276
|
-
' preEmbedProvisioningProfile: false, strictVerify: true,',
|
|
288
|
+
' preEmbedProvisioningProfile: false, strictVerify: true, continueOnError: false,',
|
|
277
289
|
" optionsForFile: () => ({ entitlements: [], hardenedRuntime: false, timestamp: 'none' }),",
|
|
278
290
|
' } } : {}),',
|
|
279
291
|
' beforeAsar: [async ({ buildPath }) => {',
|
|
@@ -759,7 +771,7 @@ function renderGeneratedAIStudioI18n() {
|
|
|
759
771
|
'void generatedI18n.init({',
|
|
760
772
|
' lng: generatedLocale,',
|
|
761
773
|
" fallbackLng: 'en',",
|
|
762
|
-
'
|
|
774
|
+
' initAsync: false,',
|
|
763
775
|
' interpolation: { escapeValue: false },',
|
|
764
776
|
' resources: {',
|
|
765
777
|
' en: { translation: generatedAIStudioMessageBundles.en },',
|
|
@@ -792,7 +804,7 @@ function renderGeneratedAIStudioHostAdapter(resolution) {
|
|
|
792
804
|
' AIStudioHostProvider,',
|
|
793
805
|
` ${workspaceExport},`,
|
|
794
806
|
' DEFAULT_AI_STUDIO_HISTORY_PANEL_PREFERENCES,',
|
|
795
|
-
'
|
|
807
|
+
' appendStudioRunHistoryRecord,',
|
|
796
808
|
' cleanupStudioHistoryArtifacts,',
|
|
797
809
|
' clearStudioHistoryWithPolicy,',
|
|
798
810
|
' createStudioNonSuccess,',
|
|
@@ -907,7 +919,7 @@ function renderGeneratedAIStudioHostAdapter(resolution) {
|
|
|
907
919
|
'async function appendRecord(record: StudioRunHistoryRecord): Promise<AIStudioHistoryProjection> {',
|
|
908
920
|
' return mutateHistory(async () => {',
|
|
909
921
|
' const current = await loadRunHistory();',
|
|
910
|
-
' const next =
|
|
922
|
+
' const next = appendStudioRunHistoryRecord(current, record);',
|
|
911
923
|
' return verifyHistoryProjection(await writeRunHistory(next));',
|
|
912
924
|
' });',
|
|
913
925
|
'}',
|
|
@@ -917,6 +929,10 @@ function renderGeneratedAIStudioHostAdapter(resolution) {
|
|
|
917
929
|
' return { ok: true as const, projection: await appendRecord(record) };',
|
|
918
930
|
' } catch (error) {',
|
|
919
931
|
' const paths = studioHistoryArtifactPaths(record);',
|
|
932
|
+
' if (result.ok && result.output.kind === \'artifacts\' && (result.output.musicGeneration || result.output.musicTranscription || result.output.voiceConversion)) {',
|
|
933
|
+
' // Music recovery already owns these assets; history is an additional index.',
|
|
934
|
+
' return { ok: false as const, message: error instanceof Error ? error.message : String(error), retryRecord: true, remainingCleanupPaths: [] };',
|
|
935
|
+
' }',
|
|
920
936
|
' const cleanup = await cleanupArtifacts(paths);',
|
|
921
937
|
" const message = error instanceof Error ? error.message : String(error || 'History persistence failed.');",
|
|
922
938
|
' return {',
|
|
@@ -1005,14 +1021,16 @@ function renderGeneratedAIStudioHostAdapter(resolution) {
|
|
|
1005
1021
|
' return promptDraftStore;',
|
|
1006
1022
|
'}',
|
|
1007
1023
|
'',
|
|
1008
|
-
'
|
|
1009
|
-
'
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
'
|
|
1013
|
-
'
|
|
1014
|
-
'
|
|
1015
|
-
'}',
|
|
1024
|
+
"const exportText: AIStudioHostPort['app']['commands']['exportText'] = async ({ filename, body }) => {",
|
|
1025
|
+
' try {',
|
|
1026
|
+
' const assets = getNimiLocalAppClient().storage.assets;',
|
|
1027
|
+
" const saved = await assets.write({ relativePath: `exports/${crypto.randomUUID()}/${filename}`,",
|
|
1028
|
+
" body: new Blob([body], { type: 'text/plain' }), mediaType: 'text/plain', overwrite: false });",
|
|
1029
|
+
' let revealed = false;',
|
|
1030
|
+
' try { await assets.reveal(saved.relativePath); revealed = true; } catch { /* The file remains saved. */ }',
|
|
1031
|
+
' return { ok: true, value: { filename, artifactPath: saved.relativePath, byteSize: saved.sizeBytes, revealed } };',
|
|
1032
|
+
' } catch (error) { return { ok: false, error }; }',
|
|
1033
|
+
'};',
|
|
1016
1034
|
'',
|
|
1017
1035
|
'const RUN_STATUS_LABEL_KEYS: Readonly<Record<string, string>> = Object.freeze({',
|
|
1018
1036
|
" ready: 'StudioShell.runStatusReady',",
|
|
@@ -1050,7 +1068,7 @@ function renderGeneratedAIStudioHostAdapter(resolution) {
|
|
|
1050
1068
|
' return { ok: false, error };',
|
|
1051
1069
|
' }',
|
|
1052
1070
|
' },',
|
|
1053
|
-
|
|
1071
|
+
' exportText,',
|
|
1054
1072
|
' },',
|
|
1055
1073
|
' },',
|
|
1056
1074
|
' sdk: {',
|
|
@@ -1068,6 +1086,7 @@ function renderGeneratedAIStudioHostAdapter(resolution) {
|
|
|
1068
1086
|
' createStudioNonSuccess(capability, reason, message, translate, diagnostics)',
|
|
1069
1087
|
' ),',
|
|
1070
1088
|
' }),',
|
|
1089
|
+
' deleteLocalAppVoiceAsset: (voiceAssetId) => getNimiLocalAppClient().ai.voiceAssets.delete(voiceAssetId),',
|
|
1071
1090
|
' async listLocalAppVoiceAssets() {',
|
|
1072
1091
|
" const result = await getNimiLocalAppClient().ai.voiceAssets.list({ pageSize: 100, pageToken: '' });",
|
|
1073
1092
|
' return result.assets.map((asset) => ({',
|
|
@@ -1077,7 +1096,10 @@ function renderGeneratedAIStudioHostAdapter(resolution) {
|
|
|
1077
1096
|
' }));',
|
|
1078
1097
|
' },',
|
|
1079
1098
|
' uploadLocalAppArtifact: (input) => getNimiLocalAppClient().ai.artifacts.upload(input),',
|
|
1099
|
+
' assets: getNimiLocalAppClient().storage.assets,',
|
|
1100
|
+
' storage: getNimiLocalAppClient().storage,',
|
|
1080
1101
|
' aiConfig: {',
|
|
1102
|
+
' getSnapshot: () => getNimiLocalAppClient().aiConfig.get(),',
|
|
1081
1103
|
' get: () => loadStudioAIConfig({',
|
|
1082
1104
|
' get: async () => (await getNimiLocalAppClient().aiConfig.get()).config,',
|
|
1083
1105
|
' }, appId),',
|
|
@@ -1095,9 +1117,12 @@ function renderGeneratedAIStudioHostAdapter(resolution) {
|
|
|
1095
1117
|
'function GeneratedAIConfigPanel({',
|
|
1096
1118
|
' runtime,',
|
|
1097
1119
|
' capabilityId,',
|
|
1120
|
+
' onCommitted,',
|
|
1098
1121
|
'}: {',
|
|
1099
1122
|
' readonly runtime: StudioRuntimeInspection | null;',
|
|
1100
1123
|
' readonly capabilityId: string;',
|
|
1124
|
+
' // Absent when the App-owned ai-studio-core predates commit reporting.',
|
|
1125
|
+
' readonly onCommitted?: () => void;',
|
|
1101
1126
|
'}) {',
|
|
1102
1127
|
' const [snapshot, setSnapshot] = useState<NimiAIConfigSnapshot | null>(null);',
|
|
1103
1128
|
' const [loading, setLoading] = useState(true);',
|
|
@@ -1139,7 +1164,12 @@ function renderGeneratedAIStudioHostAdapter(resolution) {
|
|
|
1139
1164
|
' onOverwrite={async (input) => {',
|
|
1140
1165
|
' const result = await getNimiLocalAppClient().aiConfig.overwrite(input);',
|
|
1141
1166
|
' setSnapshot({ config: result.config, revision: result.revision, effectiveSelections: [] });',
|
|
1142
|
-
|
|
1167
|
+
' // A commit re-reads every mounted consumer, this panel included,',
|
|
1168
|
+
' // even when the drawer closed before the write finished.',
|
|
1169
|
+
" if (result.outcome === 'committed') {",
|
|
1170
|
+
' if (onCommitted) onCommitted();',
|
|
1171
|
+
' else void refresh();',
|
|
1172
|
+
' }',
|
|
1143
1173
|
' return result;',
|
|
1144
1174
|
' }}',
|
|
1145
1175
|
' onOpenOwnerConfiguration={() => {',
|
|
@@ -1255,13 +1285,28 @@ function renderDefaultElectronMain(identity) {
|
|
|
1255
1285
|
"import path from 'node:path';",
|
|
1256
1286
|
"import { fileURLToPath, pathToFileURL } from 'node:url';",
|
|
1257
1287
|
"import { app, BrowserWindow, ipcMain, Menu, protocol, session, webContents } from 'electron';",
|
|
1258
|
-
|
|
1288
|
+
"import { configureNimiElectronAppHostProfile } from '@nimiplatform/kit/shell/electron/host-profile';",
|
|
1289
|
+
'',
|
|
1290
|
+
'declare const __NIMI_ELECTRON_PRODUCTION__: boolean;',
|
|
1291
|
+
'',
|
|
1292
|
+
'// Bind user data, session data and temp to the Host profile Nimi Desktop',
|
|
1293
|
+
'// prepared under the selected data root, before any session or window and',
|
|
1294
|
+
'// before the rest of Kit loads: a module that failed to load first would',
|
|
1295
|
+
"// leave Electron on its default paths in the OS user's profile.",
|
|
1296
|
+
'try {',
|
|
1297
|
+
' configureNimiElectronAppHostProfile(app);',
|
|
1298
|
+
'} catch (error) {',
|
|
1299
|
+
' process.stderr.write(`[nimi-app-host-profile] ${error instanceof Error ? error.message : String(error)}\\n`);',
|
|
1300
|
+
' app.exit(78);',
|
|
1301
|
+
' throw error;',
|
|
1302
|
+
'}',
|
|
1303
|
+
'',
|
|
1304
|
+
'const {',
|
|
1305
|
+
' createNimiElectronStandardApplicationMenuTemplate,',
|
|
1259
1306
|
' isAllowedElectronRendererUrl,',
|
|
1260
1307
|
' registerNimiElectronAppAssetProtocolScheme,',
|
|
1261
1308
|
' registerNimiElectronAppBridge,',
|
|
1262
|
-
"}
|
|
1263
|
-
'',
|
|
1264
|
-
'declare const __NIMI_ELECTRON_PRODUCTION__: boolean;',
|
|
1309
|
+
"} = await import('@nimiplatform/kit/shell/electron/main');",
|
|
1265
1310
|
'',
|
|
1266
1311
|
`const APP_ID = '${identity.appId}';`,
|
|
1267
1312
|
`const NATIVE_BUNDLE_IDENTIFIER = ${JSON.stringify(identity.nativeBundleIdentifier)};`,
|
|
@@ -1274,10 +1319,15 @@ function renderDefaultElectronMain(identity) {
|
|
|
1274
1319
|
'const developmentRendererUrl = readDevelopmentRendererUrl();',
|
|
1275
1320
|
'const rendererUrl = developmentRendererUrl || productionRendererUrl;',
|
|
1276
1321
|
'const allowedRendererUrls = [rendererUrl];',
|
|
1322
|
+
'let resettingRenderer = false;',
|
|
1323
|
+
'let quitting = false;',
|
|
1277
1324
|
'',
|
|
1278
1325
|
`app.setName(${JSON.stringify(identity.appTitle)});`,
|
|
1279
1326
|
'app.setAppUserModelId(NATIVE_BUNDLE_IDENTIFIER);',
|
|
1280
|
-
'
|
|
1327
|
+
'// macOS routes Cmd+C/V/X/A/Z and Cmd+Q through application menu roles.',
|
|
1328
|
+
'Menu.setApplicationMenu(Menu.buildFromTemplate(',
|
|
1329
|
+
` createNimiElectronStandardApplicationMenuTemplate({ appName: ${JSON.stringify(identity.appTitle)} }),`,
|
|
1330
|
+
'));',
|
|
1281
1331
|
'registerNimiElectronAppAssetProtocolScheme(protocol);',
|
|
1282
1332
|
'',
|
|
1283
1333
|
'void app.whenReady().then(async () => {',
|
|
@@ -1286,6 +1336,7 @@ function renderDefaultElectronMain(identity) {
|
|
|
1286
1336
|
' allowedRendererUrls,',
|
|
1287
1337
|
' assetMediaPlatform: { protocol, webRequest: session.defaultSession.webRequest, webContents },',
|
|
1288
1338
|
' ipcMain,',
|
|
1339
|
+
' onSessionInvalidated: resetAccountScopedRenderer,',
|
|
1289
1340
|
' });',
|
|
1290
1341
|
' await createMainWindow();',
|
|
1291
1342
|
' app.on(\'activate\', () => {',
|
|
@@ -1294,8 +1345,23 @@ function renderDefaultElectronMain(identity) {
|
|
|
1294
1345
|
'});',
|
|
1295
1346
|
'',
|
|
1296
1347
|
"app.on('window-all-closed', () => {",
|
|
1297
|
-
" if (process.platform !== 'darwin') app.quit();",
|
|
1348
|
+
" if (process.platform !== 'darwin' && !resettingRenderer && BrowserWindow.getAllWindows().length === 0) app.quit();",
|
|
1298
1349
|
'});',
|
|
1350
|
+
"app.on('before-quit', () => { quitting = true; });",
|
|
1351
|
+
'',
|
|
1352
|
+
'// A revoked/account-changed scope must not leave renderer timers or queued',
|
|
1353
|
+
'// promises alive to use the rebound Host. This does not run on normal renewal.',
|
|
1354
|
+
'function resetAccountScopedRenderer(): void {',
|
|
1355
|
+
' const windows = BrowserWindow.getAllWindows();',
|
|
1356
|
+
' if (quitting || windows.length === 0) return;',
|
|
1357
|
+
' resettingRenderer = true;',
|
|
1358
|
+
' try {',
|
|
1359
|
+
' for (const window of windows) window.destroy();',
|
|
1360
|
+
' void createMainWindow().catch((error: unknown) => {',
|
|
1361
|
+
' process.stderr.write(`[nimi-app-session-reset] ${error instanceof Error ? error.message : String(error)}\\n`);',
|
|
1362
|
+
' });',
|
|
1363
|
+
' } finally { resettingRenderer = false; }',
|
|
1364
|
+
'}',
|
|
1299
1365
|
'',
|
|
1300
1366
|
'async function createMainWindow(): Promise<void> {',
|
|
1301
1367
|
' const window = new BrowserWindow({',
|
|
@@ -1316,7 +1382,11 @@ function renderDefaultElectronMain(identity) {
|
|
|
1316
1382
|
" window.webContents.on('will-navigate', (event, url) => {",
|
|
1317
1383
|
' if (!isAllowedElectronRendererUrl(url, allowedRendererUrls)) event.preventDefault();',
|
|
1318
1384
|
' });',
|
|
1319
|
-
'
|
|
1385
|
+
' try {',
|
|
1386
|
+
' await window.loadURL(rendererUrl);',
|
|
1387
|
+
' } catch (error) {',
|
|
1388
|
+
' if (!window.isDestroyed()) throw error;',
|
|
1389
|
+
' }',
|
|
1320
1390
|
'}',
|
|
1321
1391
|
'',
|
|
1322
1392
|
'function readDevelopmentRendererUrl(): string {',
|
package/lib/app-scaffold.mjs
CHANGED
|
@@ -33,6 +33,22 @@ export const SCAFFOLD_VERSION = '2026-08-31.app-lifecycle-v1';
|
|
|
33
33
|
export const SCAFFOLD_STATE_DIR = '.nimi/app-scaffold';
|
|
34
34
|
export const SCAFFOLD_INTENT_PATH = `${SCAFFOLD_STATE_DIR}/intent.json`;
|
|
35
35
|
export const SCAFFOLD_LOCK_PATH = `${SCAFFOLD_STATE_DIR}/lock.json`;
|
|
36
|
+
// The template's own license notice, kept for the template-derived portions of
|
|
37
|
+
// a generated project. The project root LICENSE is the App's own file.
|
|
38
|
+
export const SCAFFOLD_TEMPLATE_LICENSE_NOTICE_PATH = 'licenses/nimi-app-template.txt';
|
|
39
|
+
// Files that earlier scaffold versions managed and that now belong to the App.
|
|
40
|
+
// Sync records the new owner and leaves the existing file exactly as it is.
|
|
41
|
+
export const SCAFFOLD_APP_OWNED_HANDOVER_PATHS = Object.freeze(['LICENSE']);
|
|
42
|
+
const TEMPLATE_LICENSE_COPYRIGHT_LINE = /^Copyright \(c\) (\d{4}) \S.*$/gmu;
|
|
43
|
+
const TEMPLATE_LICENSE_NOTICE_HEADER = [
|
|
44
|
+
'Nimi App template notice',
|
|
45
|
+
'',
|
|
46
|
+
'This project was created from the Nimi App template in @nimiplatform/app-tools.',
|
|
47
|
+
'Portions that come from the template are provided under the license below.',
|
|
48
|
+
"The App's own license is the LICENSE file at the project root.",
|
|
49
|
+
'',
|
|
50
|
+
'',
|
|
51
|
+
].join('\n');
|
|
36
52
|
const LOCKFILE_POLICY = 'author-install-generates-lockfile';
|
|
37
53
|
const GENERATED_GITIGNORE = [
|
|
38
54
|
'node_modules/',
|
|
@@ -67,11 +83,11 @@ const APP_RELEASE_WORKFLOW = [
|
|
|
67
83
|
' outputs:',
|
|
68
84
|
' matrix: ${{ steps.matrix.outputs.matrix }}',
|
|
69
85
|
' steps:',
|
|
70
|
-
' - uses: actions/checkout@
|
|
86
|
+
' - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1',
|
|
71
87
|
' with:',
|
|
72
88
|
' fetch-depth: 0',
|
|
73
89
|
' persist-credentials: false',
|
|
74
|
-
' - uses: actions/setup-node@
|
|
90
|
+
' - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0',
|
|
75
91
|
' with:',
|
|
76
92
|
' node-version: 24',
|
|
77
93
|
' package-manager-cache: false',
|
|
@@ -158,10 +174,10 @@ const APP_RELEASE_WORKFLOW = [
|
|
|
158
174
|
' fail-fast: false',
|
|
159
175
|
' matrix: ${{ fromJSON(needs.prepare.outputs.matrix) }}',
|
|
160
176
|
' steps:',
|
|
161
|
-
' - uses: actions/checkout@
|
|
177
|
+
' - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1',
|
|
162
178
|
' with:',
|
|
163
179
|
' persist-credentials: false',
|
|
164
|
-
' - uses: actions/setup-node@
|
|
180
|
+
' - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0',
|
|
165
181
|
' with:',
|
|
166
182
|
' node-version: 24',
|
|
167
183
|
' package-manager-cache: false',
|
|
@@ -229,10 +245,10 @@ const APP_RELEASE_WORKFLOW = [
|
|
|
229
245
|
' needs: build-target',
|
|
230
246
|
' runs-on: ubuntu-latest',
|
|
231
247
|
' steps:',
|
|
232
|
-
' - uses: actions/checkout@
|
|
248
|
+
' - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1',
|
|
233
249
|
' with:',
|
|
234
250
|
' persist-credentials: false',
|
|
235
|
-
' - uses: actions/setup-node@
|
|
251
|
+
' - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0',
|
|
236
252
|
' with:',
|
|
237
253
|
' node-version: 24',
|
|
238
254
|
' package-manager-cache: false',
|
|
@@ -1098,6 +1114,25 @@ export function renderAppSubmissionInput(identity, options = {}) {
|
|
|
1098
1114
|
}, { lineWidth: 0 });
|
|
1099
1115
|
}
|
|
1100
1116
|
|
|
1117
|
+
// The App's initial license keeps the template's license text and names the
|
|
1118
|
+
// package author, or the App title when no author was given, as the holder.
|
|
1119
|
+
export function renderInitialAppLicense(templateLicense, holder) {
|
|
1120
|
+
const copyrightLines = [...templateLicense.matchAll(TEMPLATE_LICENSE_COPYRIGHT_LINE)];
|
|
1121
|
+
if (copyrightLines.length !== 1) {
|
|
1122
|
+
throw new Error('Template LICENSE must contain exactly one copyright line');
|
|
1123
|
+
}
|
|
1124
|
+
return templateLicense.replace(TEMPLATE_LICENSE_COPYRIGHT_LINE, (_line, year) => `Copyright (c) ${year} ${holder}`);
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
export function renderTemplateLicenseNotice(templateLicense) {
|
|
1128
|
+
return `${TEMPLATE_LICENSE_NOTICE_HEADER}${templateLicense}`;
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
function readTemplateLicense() {
|
|
1132
|
+
const { baseDir } = loadDefaultStarterSource();
|
|
1133
|
+
return readDefaultStarterSourceFile(baseDir, 'LICENSE');
|
|
1134
|
+
}
|
|
1135
|
+
|
|
1101
1136
|
export function renderScaffoldBoundary() {
|
|
1102
1137
|
return YAML.stringify({
|
|
1103
1138
|
scaffold_contract: 'P-SCAF',
|
|
@@ -1108,12 +1143,24 @@ export function renderScaffoldBoundary() {
|
|
|
1108
1143
|
}
|
|
1109
1144
|
|
|
1110
1145
|
function buildStructuredFiles(identity, profile, versions) {
|
|
1146
|
+
const templateLicense = readTemplateLicense();
|
|
1111
1147
|
const files = [
|
|
1112
1148
|
{
|
|
1113
1149
|
path: '.gitignore',
|
|
1114
1150
|
content: GENERATED_GITIGNORE,
|
|
1115
1151
|
mutationClass: 'scaffold-managed glue',
|
|
1116
1152
|
},
|
|
1153
|
+
{
|
|
1154
|
+
// Created once for the App to own; sync never rewrites it.
|
|
1155
|
+
path: 'LICENSE',
|
|
1156
|
+
content: renderInitialAppLicense(templateLicense, identity.author || identity.appTitle),
|
|
1157
|
+
mutationClass: 'app-owned product code',
|
|
1158
|
+
},
|
|
1159
|
+
{
|
|
1160
|
+
path: SCAFFOLD_TEMPLATE_LICENSE_NOTICE_PATH,
|
|
1161
|
+
content: renderTemplateLicenseNotice(templateLicense),
|
|
1162
|
+
mutationClass: 'scaffold-managed glue',
|
|
1163
|
+
},
|
|
1117
1164
|
{
|
|
1118
1165
|
path: 'package.json',
|
|
1119
1166
|
content: jsonFile(buildPackageJson(profile, versions, identity)),
|
|
@@ -1595,7 +1642,7 @@ export function createAppScaffoldCandidate(input) {
|
|
|
1595
1642
|
return createAppScaffold({ ...input, plan });
|
|
1596
1643
|
}
|
|
1597
1644
|
|
|
1598
|
-
export const APP_AUTHOR_DECLARATION_FIELDS = Object.freeze(['metadata', 'capability_contract_refs', 'required_standardized_feature_refs', 'storage_policy', 'safety_profile']);
|
|
1645
|
+
export const APP_AUTHOR_DECLARATION_FIELDS = Object.freeze(['metadata', 'app_access', 'capability_contract_refs', 'required_standardized_feature_refs', 'storage_policy', 'safety_profile']);
|
|
1599
1646
|
|
|
1600
1647
|
// Source configuration is editable; existing scaffold checks still cover identity and carrier fields.
|
|
1601
1648
|
export function hashScaffoldManagedContent(relativePath, content) {
|
|
@@ -4,13 +4,17 @@
|
|
|
4
4
|
// These identities validate references; they do not admit scaffold features.
|
|
5
5
|
export const CANONICAL_CAPABILITY_IDS = Object.freeze([
|
|
6
6
|
"audio.separate",
|
|
7
|
+
"audio.speaker.embed",
|
|
7
8
|
"audio.synthesize",
|
|
8
9
|
"audio.transcribe",
|
|
10
|
+
"audio.voice.convert",
|
|
9
11
|
"image.face_swap",
|
|
10
12
|
"image.generate",
|
|
11
13
|
"music.generate",
|
|
14
|
+
"music.transcribe",
|
|
12
15
|
"realtime.interact",
|
|
13
16
|
"text.annotate",
|
|
17
|
+
"text.decide",
|
|
14
18
|
"text.embed",
|
|
15
19
|
"text.generate",
|
|
16
20
|
"video.face_swap",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nimiplatform/app-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Public app-authoring CLI for Nimi App projects.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -18,29 +18,29 @@
|
|
|
18
18
|
"provenance": true
|
|
19
19
|
},
|
|
20
20
|
"nimiScaffoldVersions": {
|
|
21
|
-
"sdkVersion": "^0.
|
|
22
|
-
"appToolsVersion": "^0.
|
|
23
|
-
"nimicodingVersion": "0.6.
|
|
21
|
+
"sdkVersion": "^0.21.0",
|
|
22
|
+
"appToolsVersion": "^0.12.0",
|
|
23
|
+
"nimicodingVersion": "0.6.5",
|
|
24
24
|
"aiSdkVersion": "^6.0.85",
|
|
25
|
-
"kitVersion": "^0.
|
|
26
|
-
"reactVersion": "^19.
|
|
27
|
-
"reactDomVersion": "^19.
|
|
28
|
-
"i18nextVersion": "^
|
|
29
|
-
"lucideReactVersion": "^
|
|
30
|
-
"tsxVersion": "^4.23.
|
|
31
|
-
"typescriptVersion": "^
|
|
32
|
-
"nodeTypesVersion": "^24.
|
|
33
|
-
"reactTypesVersion": "^19.
|
|
34
|
-
"reactDomTypesVersion": "^19.
|
|
35
|
-
"viteVersion": "^
|
|
36
|
-
"viteReactPluginVersion": "^
|
|
25
|
+
"kitVersion": "^0.19.0",
|
|
26
|
+
"reactVersion": "^19.3.0",
|
|
27
|
+
"reactDomVersion": "^19.3.0",
|
|
28
|
+
"i18nextVersion": "^26.4.2",
|
|
29
|
+
"lucideReactVersion": "^1.51.0",
|
|
30
|
+
"tsxVersion": "^4.23.15",
|
|
31
|
+
"typescriptVersion": "^6.0.3",
|
|
32
|
+
"nodeTypesVersion": "^24.19.1",
|
|
33
|
+
"reactTypesVersion": "^19.3.0",
|
|
34
|
+
"reactDomTypesVersion": "^19.3.0",
|
|
35
|
+
"viteVersion": "^8.3.3",
|
|
36
|
+
"viteReactPluginVersion": "^6.1.2",
|
|
37
37
|
"tailwindcssVersion": "^4.3.3",
|
|
38
38
|
"tailwindcssViteVersion": "^4.3.3",
|
|
39
39
|
"tauriCliVersion": "^2.11.4",
|
|
40
|
-
"yamlVersion": "^2.9.
|
|
41
|
-
"nimiShellTauriVersion": "0.
|
|
40
|
+
"yamlVersion": "^2.9.1",
|
|
41
|
+
"nimiShellTauriVersion": "0.10.0",
|
|
42
42
|
"electronPackagerVersion": "^20.3.0",
|
|
43
|
-
"electronVersion": "^
|
|
43
|
+
"electronVersion": "^44.5.1",
|
|
44
44
|
"esbuildVersion": "^0.28.2",
|
|
45
45
|
"packageManager": "pnpm@10.34.5"
|
|
46
46
|
},
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"prepack": "pnpm run build",
|
|
56
56
|
"prepublishOnly": "pnpm run build",
|
|
57
57
|
"test": "node ../scripts/with-workspace-surfaces.mjs -- pnpm run test:prepared",
|
|
58
|
-
"test:prepared": "node scripts/sync-scaffold-versions.mjs --check && node --test test/dev-shell.test.mjs && node --test test/app-safety-profile.test.mjs test/app-project-lifecycle.test.mjs test/app-pack.test.mjs test/app-scaffold.test.mjs"
|
|
58
|
+
"test:prepared": "node scripts/sync-scaffold-versions.mjs --check && node --test test/dev-shell.test.mjs && node --test test/app-dependency-combinations.test.mjs test/app-safety-profile.test.mjs test/app-project-lifecycle.test.mjs test/app-pack.test.mjs test/app-scaffold.test.mjs"
|
|
59
59
|
},
|
|
60
60
|
"files": [
|
|
61
61
|
"bin",
|
|
@@ -68,11 +68,11 @@
|
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"pngjs": "7.0.0",
|
|
70
70
|
"semver": "^7.8.5",
|
|
71
|
-
"typescript": "
|
|
72
|
-
"yaml": "
|
|
71
|
+
"typescript": "6.0.3",
|
|
72
|
+
"yaml": "2.9.1"
|
|
73
73
|
},
|
|
74
74
|
"peerDependencies": {
|
|
75
|
-
"vite": "^
|
|
75
|
+
"vite": "^8.0.0"
|
|
76
76
|
},
|
|
77
77
|
"peerDependenciesMeta": {
|
|
78
78
|
"vite": {
|
|
@@ -80,7 +80,8 @@
|
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
|
-
"@types/node": "
|
|
84
|
-
"vite": "
|
|
83
|
+
"@types/node": "24.19.1",
|
|
84
|
+
"vite": "8.3.3",
|
|
85
|
+
"i18next": "26.4.2"
|
|
85
86
|
}
|
|
86
87
|
}
|