@nimiplatform/app-tools 0.14.0 → 0.16.0-rc.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -24
- package/bin/nimi-app.mjs +35 -15
- package/lib/app-access-declaration.mjs +3 -0
- package/lib/app-dependency-combinations.mjs +70 -24
- package/lib/app-doctor-update.mjs +97 -39
- package/lib/app-host-support.mjs +6 -0
- package/lib/app-identifiers.mjs +27 -0
- package/lib/app-info.mjs +292 -1
- package/lib/app-lifecycle-guidance.mjs +1 -1
- package/lib/app-pack.mjs +65 -39
- package/lib/app-project-lifecycle.mjs +149 -244
- package/lib/app-scaffold-capabilities.mjs +13 -109
- package/lib/app-scaffold-profiles.mjs +81 -115
- package/lib/app-scaffold.mjs +74 -166
- package/lib/app-toolchain-updates.mjs +45 -0
- package/lib/canonical-capability-ids.generated.mjs +2 -0
- package/lib/development-environment.d.mts +10 -0
- package/lib/development-environment.mjs +39 -0
- package/lib/hosted-web-release.mjs +98 -0
- package/lib/index.mjs +43 -3
- package/lib/mobile-development.mjs +19 -0
- package/lib/realm-environments.generated.mjs +5 -0
- package/lib/storefront-media.mjs +154 -0
- package/lib/web-coordination.mjs +59 -0
- package/lib/web-development.d.mts +23 -0
- package/lib/web-development.mjs +118 -0
- package/lib/web-scaffold.mjs +125 -0
- package/package.json +33 -21
- package/scripts/dev-shell.mjs +4 -1
- package/scripts/sync-scaffold-versions.mjs +0 -2
- package/skills/nimi-app-lifecycle/SKILL.md +3 -1
- package/skills/nimi-app-lifecycle/references/acceptance.md +6 -2
- package/skills/nimi-app-lifecycle/references/adapt.md +5 -3
- package/skills/nimi-app-lifecycle/references/audit.md +3 -2
- package/skills/nimi-app-lifecycle/references/create.md +6 -2
- package/skills/nimi-app-lifecycle/references/release.md +10 -0
- package/skills/nimi-app-lifecycle/references/upgrade-platform.md +12 -7
- package/templates/app-source/src/ai-studio-core/ai-studio-core.css +87 -52
- package/templates/app-source/src/ai-studio-core/history-policy.ts +45 -11
- package/templates/app-source/src/ai-studio-core/history.ts +22 -11
- package/templates/app-source/src/ai-studio-core/host-context.tsx +9 -4
- package/templates/app-source/src/ai-studio-core/index.ts +2 -0
- package/templates/app-source/src/ai-studio-core/job-recovery-panel.tsx +15 -5
- package/templates/app-source/src/ai-studio-core/job-recovery.ts +2 -2
- package/templates/app-source/src/ai-studio-core/messages/en.json +73 -19
- package/templates/app-source/src/ai-studio-core/messages/zh.json +73 -19
- package/templates/app-source/src/ai-studio-core/module-registration.ts +1 -0
- package/templates/app-source/src/ai-studio-core/non-success-presentation.ts +30 -5
- package/templates/app-source/src/ai-studio-core/parameter-fields.tsx +12 -6
- package/templates/app-source/src/ai-studio-core/parameters.ts +4 -0
- package/templates/app-source/src/ai-studio-core/prompt-drafts.ts +42 -0
- package/templates/app-source/src/ai-studio-core/runtime-types.ts +9 -2
- package/templates/app-source/src/ai-studio-core/runtime.ts +8 -4
- package/templates/app-source/src/ai-studio-core/section-ai-testing-composer.tsx +98 -90
- package/templates/app-source/src/ai-studio-core/section-ai-testing-exchange-result.tsx +1 -1
- package/templates/app-source/src/ai-studio-core/section-ai-testing-history.tsx +205 -48
- package/templates/app-source/src/ai-studio-core/section-ai-testing-input.ts +1 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-output.tsx +36 -14
- package/templates/app-source/src/ai-studio-core/section-ai-testing-result.tsx +96 -75
- package/templates/app-source/src/ai-studio-core/section-ai-testing-run.ts +59 -16
- package/templates/app-source/src/ai-studio-core/section-ai-testing-session-result.tsx +2 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing-studio-result.tsx +12 -21
- package/templates/app-source/src/ai-studio-core/section-ai-testing-transcription-result.tsx +2 -2
- package/templates/app-source/src/ai-studio-core/section-ai-testing-vision-result.tsx +3 -3
- package/templates/app-source/src/ai-studio-core/section-ai-testing.tsx +158 -76
- package/templates/app-source/src/ai-studio-core/workspace.tsx +49 -22
- package/templates/app-source/src/product-modules/agent-center/index.tsx +2 -3
- package/templates/app-source/src/product-modules/agent-conversation/index.tsx +2 -3
- package/templates/app-source/src/studio-modules/studio-create/messages/en.json +12 -3
- package/templates/app-source/src/studio-modules/studio-create/messages/zh.json +12 -3
- package/templates/app-source/src/studio-modules/studio-create/parameter-panel.tsx +11 -2
- package/templates/app-source/src/studio-modules/studio-create/parameters.ts +2 -1
- package/templates/app-source/src/studio-modules/studio-create/runtime.ts +47 -5
- package/templates/app-source/src/studio-modules/studio-media/messages/en.json +59 -8
- package/templates/app-source/src/studio-modules/studio-media/messages/zh.json +68 -8
- package/templates/app-source/src/studio-modules/studio-media/music-parameters.tsx +2 -1
- package/templates/app-source/src/studio-modules/studio-media/parameter-panel.tsx +271 -83
- package/templates/app-source/src/studio-modules/studio-media/parameters.ts +120 -2
- package/templates/app-source/src/studio-modules/studio-media/registration.ts +1 -0
- package/templates/app-source/src/studio-modules/studio-media/runtime.ts +24 -14
- package/templates/app-source/src/studio-modules/studio-voice/descriptors.ts +1 -1
- package/templates/app-source/src/studio-modules/studio-voice/messages/en.json +3 -2
- package/templates/app-source/src/studio-modules/studio-voice/messages/zh.json +3 -2
- package/templates/app-source/src/studio-modules/studio-voice/parameter-panel.tsx +46 -23
- package/templates/app-source/src/studio-modules/studio-voice/registration.ts +2 -1
- package/templates/app-source/src/studio-modules/studio-voice/runtime.ts +2 -2
- package/templates/app-source/src/workbench-core/workbench-core.tsx +27 -3
- package/templates/default-starter/AGENTS.md +3 -3
- package/templates/default-starter/README.md +1 -1
- package/templates/default-starter/src/shell/App.tsx +6 -18
- package/templates/default-starter/src/shell/auth/local-app-client.ts +6 -15
- package/templates/default-starter/src/shell/auth/runtime-platform.ts +7 -107
- package/templates/default-starter/src/shell/workbench-target-adapter.ts +9 -126
- package/templates/default-starter.manifest.json +0 -16
- package/templates/hosted-web-release.yml +98 -0
- package/templates/default-starter/src-tauri/Cargo.toml +0 -17
- package/templates/default-starter/src-tauri/build.rs +0 -32
- package/templates/default-starter/src-tauri/capabilities/default.json +0 -7
- package/templates/default-starter/src-tauri/tauri.conf.json +0 -26
package/lib/app-pack.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { assertDesktopHostSupport } from './app-host-support.mjs';
|
|
2
|
+
import { isAppId } from './app-identifiers.mjs';
|
|
1
3
|
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-scaf-009b
|
|
2
4
|
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-napp-014a
|
|
3
5
|
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-napp-018a
|
|
@@ -23,7 +25,8 @@ import {
|
|
|
23
25
|
} from 'node:fs';
|
|
24
26
|
import path from 'node:path';
|
|
25
27
|
import { parse as parseYaml, stringify as stringifyYaml } from 'yaml';
|
|
26
|
-
import { APP_INFO_DECLARATION_FIELDS, APP_INFO_MAX_BYTES, readAppInfo, validateAppInfo } from './app-info.mjs';
|
|
28
|
+
import { APP_INFO_DECLARATION_FIELDS, APP_INFO_MAX_BYTES, readAppInfo, readAppStorefront, validateAppInfo } from './app-info.mjs';
|
|
29
|
+
import { STOREFRONT_ARCHIVE_MAX_BYTES } from './storefront-media.mjs';
|
|
27
30
|
import { observeWindowsExecutableFacts } from './windows-powershell.mjs';
|
|
28
31
|
import { SYMBOLIC_LINK_MODE, validatePayloadLinks } from './payload-links.mjs';
|
|
29
32
|
import { observeMacOSExecutableFacts } from './macos-native.mjs';
|
|
@@ -34,7 +37,6 @@ const AGGREGATE_FORMAT = 'nimi.app-release-candidate/v1';
|
|
|
34
37
|
const BUILD_PROFILE_PATH = '.nimi/config/build-profile.yaml';
|
|
35
38
|
const ELECTRON_BUILD_PROFILE_REF = 'electron-packager-pnpm-vite';
|
|
36
39
|
const APP_OWNED_ELECTRON_BUILD_PROFILE_REF = 'electron-pnpm';
|
|
37
|
-
const TAURI_BUILD_PROFILE_REF = 'tauri-pnpm-vite';
|
|
38
40
|
const OUTPUT_DIR = 'dist/nimi-app';
|
|
39
41
|
const SEMVER_PATTERN = /^(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)(?:-[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?(?:\+[0-9A-Za-z]+(?:[.-][0-9A-Za-z]+)*)?$/u;
|
|
40
42
|
const TARGETS = Object.freeze({
|
|
@@ -137,21 +139,6 @@ function readYaml(filePath, label) {
|
|
|
137
139
|
}
|
|
138
140
|
}
|
|
139
141
|
|
|
140
|
-
function readCargoPackageVersion(source) {
|
|
141
|
-
let inPackage = false;
|
|
142
|
-
for (const line of source.split(/\r?\n/u)) {
|
|
143
|
-
const header = line.match(/^\s*\[([^\]]+)\]\s*(?:#.*)?$/u);
|
|
144
|
-
if (header) {
|
|
145
|
-
inPackage = header[1] === 'package';
|
|
146
|
-
continue;
|
|
147
|
-
}
|
|
148
|
-
if (!inPackage) continue;
|
|
149
|
-
const match = line.match(/^\s*version\s*=\s*"([^"]+)"\s*(?:#.*)?$/u);
|
|
150
|
-
if (match) return match[1];
|
|
151
|
-
}
|
|
152
|
-
throw new Error('src-tauri/Cargo.toml [package] version is missing');
|
|
153
|
-
}
|
|
154
|
-
|
|
155
142
|
function collectPayload(payloadPath, os) {
|
|
156
143
|
const stat = lstatSync(payloadPath);
|
|
157
144
|
if (stat.isSymbolicLink()) throw new Error('Pack payload must not contain symbolic links');
|
|
@@ -311,7 +298,17 @@ export function readNimiAppArchive(bytes) {
|
|
|
311
298
|
return entries;
|
|
312
299
|
}
|
|
313
300
|
|
|
301
|
+
function readNativePackProfile(targetDir) {
|
|
302
|
+
const profile = readYaml(path.join(targetDir, BUILD_PROFILE_PATH), BUILD_PROFILE_PATH);
|
|
303
|
+
assertDesktopHostSupport(profile.build_profile_ref);
|
|
304
|
+
if (![ELECTRON_BUILD_PROFILE_REF, APP_OWNED_ELECTRON_BUILD_PROFILE_REF].includes(profile.build_profile_ref)) {
|
|
305
|
+
throw new Error(`${BUILD_PROFILE_PATH} build_profile_ref is unsupported: ${String(profile.build_profile_ref)}`);
|
|
306
|
+
}
|
|
307
|
+
return profile;
|
|
308
|
+
}
|
|
309
|
+
|
|
314
310
|
function readPackInputs(targetDir, targetId) {
|
|
311
|
+
const buildProfile = readNativePackProfile(targetDir);
|
|
315
312
|
const target = TARGETS[targetId];
|
|
316
313
|
if (!target) throw new Error(`Unsupported App package target: ${targetId}`);
|
|
317
314
|
const packageJson = readJson(path.join(targetDir, 'package.json'), 'package.json');
|
|
@@ -324,31 +321,12 @@ function readPackInputs(targetDir, targetId) {
|
|
|
324
321
|
const manifestPath = path.join(targetDir, 'nimi.app.yaml');
|
|
325
322
|
const manifest = readYaml(manifestPath, 'nimi.app.yaml');
|
|
326
323
|
const appInfo = readAppInfo(targetDir, targetId);
|
|
327
|
-
const buildProfile = readYaml(path.join(targetDir, BUILD_PROFILE_PATH), BUILD_PROFILE_PATH);
|
|
328
|
-
const buildProfileRef = buildProfile.build_profile_ref;
|
|
329
|
-
if (![ELECTRON_BUILD_PROFILE_REF, APP_OWNED_ELECTRON_BUILD_PROFILE_REF, TAURI_BUILD_PROFILE_REF].includes(buildProfileRef)) {
|
|
330
|
-
throw new Error(`${BUILD_PROFILE_PATH} build_profile_ref is unsupported: ${String(buildProfileRef)}`);
|
|
331
|
-
}
|
|
332
|
-
const requiresTauri = buildProfileRef === TAURI_BUILD_PROFILE_REF;
|
|
333
324
|
const appId = String(manifest.app_id || '');
|
|
334
325
|
const version = String(packageJson.version || '');
|
|
335
|
-
if (
|
|
326
|
+
if (!isAppId(appId)) throw new Error('nimi.app.yaml app_id must be canonical and dotted');
|
|
336
327
|
if (!SEMVER_PATTERN.test(version) || manifest.version !== version) {
|
|
337
328
|
throw new Error('package.json and nimi.app.yaml versions must be exact and lockstep before pack');
|
|
338
329
|
}
|
|
339
|
-
if (requiresTauri) {
|
|
340
|
-
const cargoPath = path.join(targetDir, 'src-tauri', 'Cargo.toml');
|
|
341
|
-
const tauriPath = path.join(targetDir, 'src-tauri', 'tauri.conf.json');
|
|
342
|
-
if (!existsSync(cargoPath)) throw new Error('src-tauri/Cargo.toml is missing');
|
|
343
|
-
if (!existsSync(tauriPath)) throw new Error('src-tauri/tauri.conf.json is missing');
|
|
344
|
-
const tauriConfig = readJson(tauriPath, 'src-tauri/tauri.conf.json');
|
|
345
|
-
if (
|
|
346
|
-
readCargoPackageVersion(readFileSync(cargoPath, 'utf8')) !== version
|
|
347
|
-
|| tauriConfig.version !== version
|
|
348
|
-
) {
|
|
349
|
-
throw new Error('package.json, nimi.app.yaml, Cargo.toml, and tauri.conf.json versions must be exact and lockstep before pack');
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
330
|
const configured = buildProfile.targets?.[targetId];
|
|
353
331
|
if (!configured || typeof configured !== 'object' || Array.isArray(configured)) throw new Error(`Build profile does not declare target: ${targetId}`);
|
|
354
332
|
if (configured.os !== target.os || configured.arch !== target.arch) throw new Error(`Build profile target identity mismatch: ${targetId}`);
|
|
@@ -550,6 +528,7 @@ export function packAppTarget(cwd, options = {}) {
|
|
|
550
528
|
|
|
551
529
|
export function aggregateAppTargetCandidates(cwd, options = {}) {
|
|
552
530
|
const targetDir = path.resolve(cwd, String(options.dir || '').trim() || '.');
|
|
531
|
+
readNativePackProfile(targetDir);
|
|
553
532
|
const outputDir = path.join(targetDir, OUTPUT_DIR);
|
|
554
533
|
if (!existsSync(outputDir)) throw new Error('No target metadata exists to aggregate');
|
|
555
534
|
const files = readdirSync(outputDir).filter((name) => name.endsWith('.target.json')).sort();
|
|
@@ -558,6 +537,7 @@ export function aggregateAppTargetCandidates(cwd, options = {}) {
|
|
|
558
537
|
const appId = targets[0].app_id;
|
|
559
538
|
const version = targets[0].version;
|
|
560
539
|
const seen = new Set();
|
|
540
|
+
const parsedInfos = [];
|
|
561
541
|
for (const target of targets) {
|
|
562
542
|
const metadataLabel = `${target.target_id || 'unknown'} target metadata`;
|
|
563
543
|
if (target.format !== TARGET_METADATA_FORMAT || target.app_id !== appId || target.version !== version) throw new Error('Target metadata cannot be aggregated across App releases');
|
|
@@ -588,6 +568,7 @@ export function aggregateAppTargetCandidates(cwd, options = {}) {
|
|
|
588
568
|
if (infoBytes.length !== infoAsset.size || createHash('sha256').update(infoBytes).digest('hex') !== infoAsset.sha256 || !entries.get('app-info.json')?.bytes.equals(infoBytes)) throw new Error(`Target App info changed or differs from archive: ${target.target_id}`);
|
|
589
569
|
const info = validateAppInfo(JSON.parse(infoBytes));
|
|
590
570
|
if (info.app_id !== appId || info.version !== version || info.target_id !== target.target_id) throw new Error(`Target App info identity differs: ${target.target_id}`);
|
|
571
|
+
parsedInfos.push({ targetId: target.target_id, info });
|
|
591
572
|
validatePayloadLinks(entries, target.os);
|
|
592
573
|
const manifest = readPackageManifestFromArchive(entries, metadataLabel);
|
|
593
574
|
if (manifest.format !== PACKAGE_FORMAT) throw new Error(`Target archive manifest format is invalid: ${target.asset_name}`);
|
|
@@ -602,8 +583,53 @@ export function aggregateAppTargetCandidates(cwd, options = {}) {
|
|
|
602
583
|
throw new Error(`Target archive runtime_entry is missing or non-executable: ${runtimeEntry}`);
|
|
603
584
|
}
|
|
604
585
|
}
|
|
605
|
-
const
|
|
586
|
+
const firstInfo = parsedInfos[0].info;
|
|
587
|
+
for (const entry of parsedInfos.slice(1)) {
|
|
588
|
+
for (const field of ['display_name', 'summary', 'icon', 'readme_markdown', 'release_notes_markdown', 'safety_profile', 'storefront']) {
|
|
589
|
+
if (!sameCanonicalValue(entry.info[field], firstInfo[field])) {
|
|
590
|
+
throw new Error(`Target App info ${field} differs between ${parsedInfos[0].targetId} and ${entry.targetId}; one release shares one presentation`);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
let storefrontMedia;
|
|
595
|
+
if (firstInfo.storefront?.media !== undefined) {
|
|
596
|
+
const repoManifest = readYaml(path.join(targetDir, 'nimi.app.yaml'), 'nimi.app.yaml');
|
|
597
|
+
const { storefront: repoStorefront, mediaEntries } = readAppStorefront(targetDir, repoManifest);
|
|
598
|
+
if (!sameCanonicalValue(repoStorefront?.media, firstInfo.storefront.media)) {
|
|
599
|
+
throw new Error('Repository storefront media changed after target packing; rebuild targets and aggregate from the same commit');
|
|
600
|
+
}
|
|
601
|
+
const archiveEntries = [...mediaEntries.entries()]
|
|
602
|
+
.sort(([left], [right]) => compareText(left, right))
|
|
603
|
+
.map(([name, bytes]) => ({ name, bytes, mode: 0o644 }));
|
|
604
|
+
const mediaArchive = writeNimiAppArchive(archiveEntries);
|
|
605
|
+
if (mediaArchive.length > STOREFRONT_ARCHIVE_MAX_BYTES) {
|
|
606
|
+
throw new Error(`Storefront media archive exceeds ${STOREFRONT_ARCHIVE_MAX_BYTES} bytes`);
|
|
607
|
+
}
|
|
608
|
+
const mediaAssetName = `${appId}-${version}-storefront-media.zip`;
|
|
609
|
+
const mediaArchivePath = path.join(outputDir, mediaAssetName);
|
|
610
|
+
writeAppArchiveFile(mediaArchivePath, mediaArchive);
|
|
611
|
+
storefrontMedia = {
|
|
612
|
+
asset_name: mediaAssetName,
|
|
613
|
+
size: mediaArchive.length,
|
|
614
|
+
sha256: hashAppArchive(mediaArchive),
|
|
615
|
+
};
|
|
616
|
+
}
|
|
617
|
+
const candidate = {
|
|
618
|
+
format: AGGREGATE_FORMAT,
|
|
619
|
+
app_id: appId,
|
|
620
|
+
version,
|
|
621
|
+
...(storefrontMedia ? { storefront_media: storefrontMedia } : {}),
|
|
622
|
+
targets: targets.sort((left, right) => compareText(left.target_id, right.target_id)),
|
|
623
|
+
};
|
|
606
624
|
const candidatePath = path.join(outputDir, `${appId}-${version}.candidate.json`);
|
|
607
625
|
writeFileSync(candidatePath, canonicalJson(candidate));
|
|
608
|
-
return {
|
|
626
|
+
return {
|
|
627
|
+
ok: true,
|
|
628
|
+
command: 'pack',
|
|
629
|
+
aggregate: true,
|
|
630
|
+
dir: targetDir,
|
|
631
|
+
candidatePath,
|
|
632
|
+
...(storefrontMedia ? { storefrontMediaPath: path.join(outputDir, storefrontMedia.asset_name) } : {}),
|
|
633
|
+
...candidate,
|
|
634
|
+
};
|
|
609
635
|
}
|