@nimiplatform/app-tools 0.12.2 → 0.13.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 +137 -492
- package/lib/app-dependency-combinations.mjs +2 -0
- package/lib/app-doctor-update.mjs +8 -2
- package/lib/app-project-lifecycle.mjs +1 -1
- package/lib/app-scaffold-profiles.mjs +85 -28
- package/lib/app-scaffold.mjs +10 -1
- package/package.json +3 -3
- package/skills/nimi-app-lifecycle/references/safety-declaration.md +1 -1
- package/skills/nimi-app-lifecycle/references/upgrade-platform.md +20 -11
- package/templates/app-source/src/ai-studio-core/messages/en.json +2 -0
- package/templates/app-source/src/ai-studio-core/messages/zh.json +2 -0
- package/templates/app-source/src/ai-studio-core/section-ai-testing.tsx +8 -1
- package/templates/app-source/src/ai-studio-core/workspace.tsx +31 -7
- package/templates/app-source/src/workbench-core/workbench-core.css +4 -0
- package/templates/app-source/src/workbench-core/workbench-core.tsx +5 -3
- package/templates/default-starter/AGENTS.md +1 -1
- package/templates/default-starter/README.md +46 -41
- package/templates/default-starter/src/shell/App.tsx +14 -2
- package/templates/default-starter/src/shell/authenticated-shell.tsx +5 -6
- package/templates/default-starter/tsconfig.json +1 -0
|
@@ -9,6 +9,8 @@ const SDK = '@nimiplatform/sdk';
|
|
|
9
9
|
const KIT = '@nimiplatform/kit';
|
|
10
10
|
|
|
11
11
|
export const ADDITIONAL_DEPENDENCY_COMBINATIONS = Object.freeze([
|
|
12
|
+
Object.freeze({ sdkVersion: '^0.21.0', kitVersion: '^0.20.0', nimiShellTauriVersion: '0.10.0', source: 'existing' }),
|
|
13
|
+
Object.freeze({ sdkVersion: '^0.21.0', kitVersion: '^0.19.0', nimiShellTauriVersion: '0.10.0', source: 'existing' }),
|
|
12
14
|
Object.freeze({ sdkVersion: '^0.21.0', kitVersion: '^0.18.1', nimiShellTauriVersion: '0.10.0', source: 'existing' }),
|
|
13
15
|
Object.freeze({ sdkVersion: '^0.21.0', kitVersion: '^0.18.0', nimiShellTauriVersion: '0.10.0', source: 'existing' }),
|
|
14
16
|
Object.freeze({ sdkVersion: '^0.20.0', kitVersion: '^0.17.0', nimiShellTauriVersion: '0.9.0', source: 'existing' }),
|
|
@@ -4,6 +4,7 @@ import path from 'node:path';
|
|
|
4
4
|
import { parse as parseYaml, stringify as stringifyYaml } from 'yaml';
|
|
5
5
|
import {
|
|
6
6
|
buildAppScaffoldSnapshotFromIntent,
|
|
7
|
+
assertStandardNavigationKit,
|
|
7
8
|
managedAppReleaseWorkflowSource,
|
|
8
9
|
SCAFFOLD_APP_OWNED_HANDOVER_PATHS,
|
|
9
10
|
SCAFFOLD_INTENT_PATH,
|
|
@@ -139,7 +140,7 @@ function assertSupportedLock(lock) {
|
|
|
139
140
|
throw new Error(`Unsupported scaffold lock version: ${String(lock?.lockVersion || 'missing')}`);
|
|
140
141
|
}
|
|
141
142
|
if (lock?.scaffoldVersion !== SCAFFOLD_VERSION) {
|
|
142
|
-
throw new Error(`Unsupported scaffold version: ${String(lock?.scaffoldVersion || 'missing')}
|
|
143
|
+
throw new Error(`Unsupported scaffold version: ${String(lock?.scaffoldVersion || 'missing')}. Complete the manual App-owned navigation, managed Host, Kit and scaffold contract migration together before sync; no files were written.`);
|
|
143
144
|
}
|
|
144
145
|
if (!SUPPORTED_APP_SCAFFOLD_PROFILES.includes(lock?.profile)) {
|
|
145
146
|
throw new Error(`Unsupported scaffold profile: ${String(lock?.profile || 'missing')}`);
|
|
@@ -281,6 +282,10 @@ function collectTextFiles(rootDir) {
|
|
|
281
282
|
}
|
|
282
283
|
const fullPath = path.join(currentDir, entry.name);
|
|
283
284
|
if (entry.isDirectory()) {
|
|
285
|
+
// A nested Git checkout is an independently owned repository, including
|
|
286
|
+
// an agent's retained worktree. Its history is not this App's source.
|
|
287
|
+
// Keep checking the current repository's product, Host and declarations.
|
|
288
|
+
if (existsSync(path.join(fullPath, '.git'))) continue;
|
|
284
289
|
if (isNextBuildOutputDirectory(fullPath)) continue;
|
|
285
290
|
// Python environments can contain bundled JS applications. Like
|
|
286
291
|
// node_modules, these installed dependencies are not App source.
|
|
@@ -626,10 +631,10 @@ function validateAppProjectState(targetDir, versions, runners = {}) {
|
|
|
626
631
|
assertLifecycleGuidanceCurrent(targetDir);
|
|
627
632
|
return validateExistingSubmittedApp(targetDir);
|
|
628
633
|
}
|
|
629
|
-
assertLifecycleGuidanceCurrent(targetDir);
|
|
630
634
|
const lock = readLock(targetDir);
|
|
631
635
|
const intent = readIntent(targetDir);
|
|
632
636
|
const snapshot = expectedSnapshotFromLock(lock, versions, intent, targetDir);
|
|
637
|
+
assertLifecycleGuidanceCurrent(targetDir);
|
|
633
638
|
assertNoPendingAppOwnedHandover(lock, snapshot);
|
|
634
639
|
ensureLockMatchesCurrentGenerator(lock, snapshot);
|
|
635
640
|
assertRequiredSupportFiles(targetDir, snapshot);
|
|
@@ -857,6 +862,7 @@ export function planManagedAppSync(cwd, options = {}, versions) {
|
|
|
857
862
|
const intent = readIntent(targetDir);
|
|
858
863
|
const currentManifest = readCurrentAppManifest(targetDir);
|
|
859
864
|
const packageJson = readJsonFile(path.join(targetDir, 'package.json'), 'package.json');
|
|
865
|
+
assertStandardNavigationKit(packageJson.dependencies?.['@nimiplatform/kit']);
|
|
860
866
|
const versionedIntent = {
|
|
861
867
|
...intent,
|
|
862
868
|
version: packageJson.version,
|
|
@@ -1470,7 +1470,7 @@ export function checkAppProject(cwd, options = {}, versions, runners = {}) {
|
|
|
1470
1470
|
}
|
|
1471
1471
|
const safetyProfile = descriptor.safetyProfile ? 'declared' : 'undeclared';
|
|
1472
1472
|
if (options.production === true && !options.json && safetyProfile === 'undeclared') {
|
|
1473
|
-
process.stdout.write('[nimi-app] safety_profile is not declared in nimi.app.yaml; local builds
|
|
1473
|
+
process.stdout.write('[nimi-app] safety_profile is not declared in nimi.app.yaml; local builds, private packages and local import remain usable. Whether a public submission requires the declaration is determined by the current Registry admission policy.\n');
|
|
1474
1474
|
}
|
|
1475
1475
|
return emitResult({
|
|
1476
1476
|
ok: true,
|
|
@@ -52,6 +52,11 @@ export function buildDefaultStarterFiles(identity) {
|
|
|
52
52
|
content: renderDefaultProductArea(identity),
|
|
53
53
|
mutationClass: 'app-owned product code',
|
|
54
54
|
},
|
|
55
|
+
{
|
|
56
|
+
path: 'src/shell/routes/app-navigation.tsx',
|
|
57
|
+
content: renderDefaultAppNavigation(),
|
|
58
|
+
mutationClass: 'app-owned product code',
|
|
59
|
+
},
|
|
55
60
|
...buildGeneratedModuleCompositionFiles(identity),
|
|
56
61
|
{
|
|
57
62
|
path: 'src-tauri/src/main.rs',
|
|
@@ -422,35 +427,24 @@ function renderDefaultProductArea(_identity) {
|
|
|
422
427
|
"import { appTitle } from '../auth/app-identity.js';",
|
|
423
428
|
"import { GeneratedModuleHost, GeneratedRouteRegistry } from '../../scaffold/generated/route-registry.js';",
|
|
424
429
|
'import {',
|
|
425
|
-
' generatedInitialViewId,',
|
|
426
430
|
' generatedNavigationGroups,',
|
|
427
431
|
' hasGeneratedViews,',
|
|
428
|
-
' isGeneratedViewId,',
|
|
429
432
|
"} from '../../scaffold/generated/navigation.js';",
|
|
430
|
-
"import { useCallback
|
|
431
|
-
'',
|
|
432
|
-
"
|
|
433
|
-
'',
|
|
434
|
-
'function readInitialViewId(): string | null {',
|
|
435
|
-
' try {',
|
|
436
|
-
' const stored = globalThis.localStorage?.getItem(VIEW_STORAGE_KEY);',
|
|
437
|
-
' return stored && isGeneratedViewId(stored) ? stored : generatedInitialViewId;',
|
|
438
|
-
' } catch {',
|
|
439
|
-
' return generatedInitialViewId;',
|
|
440
|
-
' }',
|
|
441
|
-
'}',
|
|
433
|
+
"import { useCallback } from 'react';",
|
|
434
|
+
"import { useNimiNavigationSnapshot } from '@nimiplatform/kit/ui/app-chrome';",
|
|
435
|
+
"import { useAppNavigation } from './app-navigation.js';",
|
|
442
436
|
'',
|
|
443
437
|
'export function ProductArea() {',
|
|
444
|
-
' const
|
|
445
|
-
' const
|
|
446
|
-
'
|
|
447
|
-
'
|
|
448
|
-
'
|
|
449
|
-
' }, []);',
|
|
438
|
+
' const { navigation, sidebarVisible } = useAppNavigation();',
|
|
439
|
+
' const activeViewId = useNimiNavigationSnapshot().current.destination.id;',
|
|
440
|
+
' const selectView = useCallback((viewId: string, runId?: string) => {',
|
|
441
|
+
' void navigation.push({ id: viewId, ...(runId ? { runId } : {}) });',
|
|
442
|
+
' }, [navigation]);',
|
|
450
443
|
' return (',
|
|
451
444
|
' <GeneratedModuleHost onSelectView={selectView}>',
|
|
452
445
|
' <WorkbenchCore<string>',
|
|
453
446
|
' activeViewId={activeViewId}',
|
|
447
|
+
' sidebarVisible={hasGeneratedViews && sidebarVisible}',
|
|
454
448
|
' navigationLabel="App modules"',
|
|
455
449
|
' navigationGroups={generatedNavigationGroups}',
|
|
456
450
|
' onSelectView={selectView}',
|
|
@@ -475,6 +469,58 @@ function renderDefaultProductArea(_identity) {
|
|
|
475
469
|
].join('\n');
|
|
476
470
|
}
|
|
477
471
|
|
|
472
|
+
function renderDefaultAppNavigation() {
|
|
473
|
+
return `import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, type ReactNode } from 'react';
|
|
474
|
+
import { createNimiNavigation } from '@nimiplatform/kit/core/navigation';
|
|
475
|
+
import { NimiNavigationProvider } from '@nimiplatform/kit/ui/app-chrome';
|
|
476
|
+
import { generatedInitialViewId, hasGeneratedViews, isGeneratedViewId, generatedHistoryViewIds } from '../../scaffold/generated/navigation.js';
|
|
477
|
+
|
|
478
|
+
// App-owned destinations: extend this catalog when adding product screens.
|
|
479
|
+
export function createAppNavigation() {
|
|
480
|
+
return createNimiNavigation<{ id: string; runId?: string }>({
|
|
481
|
+
initial: { id: generatedInitialViewId ?? 'welcome' },
|
|
482
|
+
validate(value: unknown) {
|
|
483
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error('Invalid App destination.');
|
|
484
|
+
const input = value as Record<string, unknown>;
|
|
485
|
+
if (Object.keys(input).some(key => key !== 'id' && key !== 'runId') || typeof input.id !== 'string'
|
|
486
|
+
|| !(isGeneratedViewId(input.id) || !hasGeneratedViews && input.id === 'welcome')) throw new Error('Unknown App destination.');
|
|
487
|
+
if (input.runId !== undefined && (!generatedHistoryViewIds.includes(input.id) || typeof input.runId !== 'string' || !input.runId.trim() || input.runId.length > 512)) throw new Error('Invalid run reference.');
|
|
488
|
+
return { id: input.id, ...(input.runId === undefined ? {} : { runId: input.runId as string }) };
|
|
489
|
+
},
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
type NavigationOwner = {
|
|
493
|
+
navigation: ReturnType<typeof createAppNavigation>;
|
|
494
|
+
ready: boolean; setReady: (value: boolean) => void;
|
|
495
|
+
sidebarVisible: boolean; setSidebarVisible: (value: boolean) => void;
|
|
496
|
+
};
|
|
497
|
+
const Context = createContext<NavigationOwner | null>(null);
|
|
498
|
+
export function useAppNavigation(): NavigationOwner {
|
|
499
|
+
const owner = useContext(Context);
|
|
500
|
+
if (!owner) throw new Error('App navigation owner is missing.');
|
|
501
|
+
return owner;
|
|
502
|
+
}
|
|
503
|
+
export function AppNavigationProvider({ children }: { children: ReactNode }) {
|
|
504
|
+
const [navigation] = useState(createAppNavigation);
|
|
505
|
+
const [ready, updateReady] = useState(false);
|
|
506
|
+
const [sidebarVisible, setSidebarVisible] = useState(true);
|
|
507
|
+
const lifetime = useRef(0);
|
|
508
|
+
useEffect(() => {
|
|
509
|
+
const generation = ++lifetime.current;
|
|
510
|
+
return () => {
|
|
511
|
+
navigation.reset({ id: generatedInitialViewId ?? 'welcome' });
|
|
512
|
+
queueMicrotask(() => { if (lifetime.current === generation) navigation.dispose(); });
|
|
513
|
+
};
|
|
514
|
+
}, [navigation]);
|
|
515
|
+
const setReady = useCallback((value: boolean) => {
|
|
516
|
+
if (!value) navigation.reset({ id: generatedInitialViewId ?? 'welcome' });
|
|
517
|
+
updateReady(value);
|
|
518
|
+
}, [navigation]);
|
|
519
|
+
return <Context.Provider value={{ navigation, ready, sidebarVisible, setSidebarVisible, setReady }}><NimiNavigationProvider controller={navigation}>{children}</NimiNavigationProvider></Context.Provider>;
|
|
520
|
+
}
|
|
521
|
+
`;
|
|
522
|
+
}
|
|
523
|
+
|
|
478
524
|
function buildGeneratedModuleCompositionFiles(identity) {
|
|
479
525
|
const resolution = identity.capabilityResolution;
|
|
480
526
|
const files = [
|
|
@@ -637,6 +683,9 @@ function renderGeneratedNavigation(resolution) {
|
|
|
637
683
|
'export const generatedNavigationGroups: readonly WorkbenchNavigationGroup<string>[] = Object.freeze([',
|
|
638
684
|
...groups,
|
|
639
685
|
']);',
|
|
686
|
+
aiStudioFeatureModules(resolution).length > 0
|
|
687
|
+
? 'export const generatedHistoryViewIds: readonly string[] = Object.freeze(generatedAIStudioModules.flatMap(module => module.capabilities.map(registration => registration.descriptor.id)));'
|
|
688
|
+
: 'export const generatedHistoryViewIds: readonly string[] = Object.freeze([]);',
|
|
640
689
|
'export const generatedInitialViewId = generatedNavigationGroups[0]?.items[0]?.id ?? null;',
|
|
641
690
|
'export const hasGeneratedViews = generatedInitialViewId !== null;',
|
|
642
691
|
'export function isGeneratedViewId(viewId: string): boolean {',
|
|
@@ -703,7 +752,7 @@ function renderGeneratedRouteRegistry(resolution) {
|
|
|
703
752
|
' onSelectView,',
|
|
704
753
|
' children,',
|
|
705
754
|
'}: {',
|
|
706
|
-
' readonly onSelectView: (viewId: string) => void;',
|
|
755
|
+
' readonly onSelectView: (viewId: string, runId?: string) => void;',
|
|
707
756
|
' readonly children: ReactNode;',
|
|
708
757
|
'}) {',
|
|
709
758
|
...(aiModules.length > 0
|
|
@@ -716,7 +765,7 @@ function renderGeneratedRouteRegistry(resolution) {
|
|
|
716
765
|
' onSelectView,',
|
|
717
766
|
'}: {',
|
|
718
767
|
' readonly activeViewId: string;',
|
|
719
|
-
' readonly onSelectView: (viewId: string) => void;',
|
|
768
|
+
' readonly onSelectView: (viewId: string, runId?: string) => void;',
|
|
720
769
|
'}) {',
|
|
721
770
|
' const rootRef = useRef<HTMLDivElement>(null);',
|
|
722
771
|
' useEffect(() => { rootRef.current?.focus(); }, [activeViewId]);',
|
|
@@ -795,6 +844,7 @@ function renderGeneratedAIStudioHostAdapter(resolution) {
|
|
|
795
844
|
const workspaceExport = core.productEntry.componentExport;
|
|
796
845
|
return [
|
|
797
846
|
"import { createContext, useContext, useEffect, useMemo, useState, type ReactNode } from 'react';",
|
|
847
|
+
"import { useNimiNavigationSnapshot } from '@nimiplatform/kit/ui/app-chrome';",
|
|
798
848
|
"import type { NimiAIConfigSnapshot } from '@nimiplatform/sdk/ai';",
|
|
799
849
|
"import { createNimiClientId } from '@nimiplatform/sdk/types';",
|
|
800
850
|
"import { ModelConfigAIConfigSurface } from '@nimiplatform/kit/features/model-config';",
|
|
@@ -1204,9 +1254,10 @@ function renderGeneratedAIStudioHostAdapter(resolution) {
|
|
|
1204
1254
|
' onSelectCapability,',
|
|
1205
1255
|
' children,',
|
|
1206
1256
|
'}: {',
|
|
1207
|
-
' readonly onSelectCapability: (capabilityId: string) => void;',
|
|
1257
|
+
' readonly onSelectCapability: (capabilityId: string, runId?: string) => void;',
|
|
1208
1258
|
' readonly children: ReactNode;',
|
|
1209
1259
|
'}) {',
|
|
1260
|
+
' const snapshot = useNimiNavigationSnapshot<{ id: string; runId?: string }>();',
|
|
1210
1261
|
' const [runtime, setRuntime] = useState<StudioRuntimeInspection | null>(null);',
|
|
1211
1262
|
' useEffect(() => {',
|
|
1212
1263
|
' let active = true;',
|
|
@@ -1217,6 +1268,7 @@ function renderGeneratedAIStudioHostAdapter(resolution) {
|
|
|
1217
1268
|
' historyRepository,',
|
|
1218
1269
|
' registrations: generatedAIStudioRegistrations,',
|
|
1219
1270
|
' onSelectCapability,',
|
|
1271
|
+
' historyPosition: snapshot.current.destination.runId ? { runId: snapshot.current.destination.runId, entryKey: snapshot.current.key, capabilityId: snapshot.current.destination.id } : undefined,',
|
|
1220
1272
|
' translate,',
|
|
1221
1273
|
' });',
|
|
1222
1274
|
' const state = useMemo(() => ({ runtime, controller }), [controller, runtime]);',
|
|
@@ -1302,7 +1354,8 @@ function renderDefaultElectronMain(identity) {
|
|
|
1302
1354
|
'}',
|
|
1303
1355
|
'',
|
|
1304
1356
|
'const {',
|
|
1305
|
-
'
|
|
1357
|
+
' createNimiElectronAppChromeHost,',
|
|
1358
|
+
' createNimiElectronAppChromeWindowOptions,',
|
|
1306
1359
|
' isAllowedElectronRendererUrl,',
|
|
1307
1360
|
' registerNimiElectronAppAssetProtocolScheme,',
|
|
1308
1361
|
' registerNimiElectronAppBridge,',
|
|
@@ -1324,14 +1377,16 @@ function renderDefaultElectronMain(identity) {
|
|
|
1324
1377
|
'',
|
|
1325
1378
|
`app.setName(${JSON.stringify(identity.appTitle)});`,
|
|
1326
1379
|
'app.setAppUserModelId(NATIVE_BUNDLE_IDENTIFIER);',
|
|
1327
|
-
'
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
'))
|
|
1380
|
+
'const chromeHost = createNimiElectronAppChromeHost({',
|
|
1381
|
+
` metadata: { name: ${JSON.stringify(identity.appTitle)}, version: ${JSON.stringify(identity.version)} },`,
|
|
1382
|
+
' allowedRendererUrls, app,',
|
|
1383
|
+
' menu: { buildFromTemplate: template => Menu.buildFromTemplate(template as Electron.MenuItemConstructorOptions[]), setApplicationMenu: menu => Menu.setApplicationMenu(menu as Electron.Menu | null) },',
|
|
1384
|
+
'});',
|
|
1331
1385
|
'registerNimiElectronAppAssetProtocolScheme(protocol);',
|
|
1332
1386
|
'',
|
|
1333
1387
|
'void app.whenReady().then(async () => {',
|
|
1334
1388
|
' registerNimiElectronAppBridge({',
|
|
1389
|
+
' chromeHost,',
|
|
1335
1390
|
' appId: APP_ID,',
|
|
1336
1391
|
' allowedRendererUrls,',
|
|
1337
1392
|
' assetMediaPlatform: { protocol, webRequest: session.defaultSession.webRequest, webContents },',
|
|
@@ -1365,6 +1420,7 @@ function renderDefaultElectronMain(identity) {
|
|
|
1365
1420
|
'',
|
|
1366
1421
|
'async function createMainWindow(): Promise<void> {',
|
|
1367
1422
|
' const window = new BrowserWindow({',
|
|
1423
|
+
' ...createNimiElectronAppChromeWindowOptions(),',
|
|
1368
1424
|
' width: 1180,',
|
|
1369
1425
|
' height: 780,',
|
|
1370
1426
|
' minWidth: 360,',
|
|
@@ -1378,6 +1434,7 @@ function renderDefaultElectronMain(identity) {
|
|
|
1378
1434
|
' sandbox: true,',
|
|
1379
1435
|
' },',
|
|
1380
1436
|
' });',
|
|
1437
|
+
' chromeHost.bindWindow(window);',
|
|
1381
1438
|
' window.webContents.setWindowOpenHandler(() => ({ action: \'deny\' }));',
|
|
1382
1439
|
" window.webContents.on('will-navigate', (event, url) => {",
|
|
1383
1440
|
' if (!isAllowedElectronRendererUrl(url, allowedRendererUrls)) event.preventDefault();',
|
package/lib/app-scaffold.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
3
|
import YAML from 'yaml';
|
|
4
|
+
import { gte, minVersion } from 'semver';
|
|
4
5
|
import { lifecycleSkillFiles } from './app-lifecycle-guidance.mjs';
|
|
5
6
|
import {
|
|
6
7
|
WORKBENCH_CORE_SOURCE_ROOT,
|
|
@@ -29,7 +30,14 @@ const DEFAULT_APP_VERSION = '0.1.0';
|
|
|
29
30
|
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;
|
|
30
31
|
export const SCAFFOLD_INTENT_VERSION = 4;
|
|
31
32
|
export const SCAFFOLD_LOCK_VERSION = 4;
|
|
32
|
-
export const SCAFFOLD_VERSION = '2026-
|
|
33
|
+
export const SCAFFOLD_VERSION = '2026-10-13.standard-app-navigation-v1';
|
|
34
|
+
// @nimi-authority: rule.nimi.platform.app-ecosystem.p-scaf-021
|
|
35
|
+
export function assertStandardNavigationKit(spec) {
|
|
36
|
+
const minimum = typeof spec === 'string' ? minVersion(spec) : null;
|
|
37
|
+
if (!minimum || !gte(minimum, '0.21.0')) {
|
|
38
|
+
throw new Error('Standard App navigation requires Kit >=0.21.0. Complete the manual navigation, managed Host, Kit and scaffold contract migration together before sync; no files were written.');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
33
41
|
export const SCAFFOLD_STATE_DIR = '.nimi/app-scaffold';
|
|
34
42
|
export const SCAFFOLD_INTENT_PATH = `${SCAFFOLD_STATE_DIR}/intent.json`;
|
|
35
43
|
export const SCAFFOLD_LOCK_PATH = `${SCAFFOLD_STATE_DIR}/lock.json`;
|
|
@@ -661,6 +669,7 @@ function buildPackageJson(profile, versions, identity) {
|
|
|
661
669
|
}
|
|
662
670
|
|
|
663
671
|
function buildRuntimeDependencies(profile, versions, capabilityResolution) {
|
|
672
|
+
assertStandardNavigationKit(versions.kitVersion);
|
|
664
673
|
const dependencies = {
|
|
665
674
|
'@nimiplatform/sdk': versions.sdkVersion,
|
|
666
675
|
'@nimiplatform/kit': versions.kitVersion,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nimiplatform/app-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Public app-authoring CLI for Nimi App projects.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -19,10 +19,10 @@
|
|
|
19
19
|
},
|
|
20
20
|
"nimiScaffoldVersions": {
|
|
21
21
|
"sdkVersion": "^0.21.0",
|
|
22
|
-
"appToolsVersion": "^0.
|
|
22
|
+
"appToolsVersion": "^0.13.0",
|
|
23
23
|
"nimicodingVersion": "0.6.5",
|
|
24
24
|
"aiSdkVersion": "^6.0.85",
|
|
25
|
-
"kitVersion": "^0.
|
|
25
|
+
"kitVersion": "^0.21.0",
|
|
26
26
|
"reactVersion": "^19.3.0",
|
|
27
27
|
"reactDomVersion": "^19.3.0",
|
|
28
28
|
"i18nextVersion": "^26.4.2",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
`nimi.app.yaml` `safety_profile` is the only author input for the App's safety declaration. It states, for the exact version being released, what the App actually provides: intended audience, content descriptors, AI interaction and output facts with the current presence of notices and markings, bounded data/sharing/account/commercial practices, and high-impact decision uses. App Tools projects it one way into `app-info.json`, the archive declaration, the exact sidecar and the candidate; do not maintain a second copy in `.nimi/admission/submission.yaml` — sync regenerates that copy and check rejects a hand-edited one.
|
|
4
4
|
|
|
5
|
-
Omit the field entirely while it is not yet declared. Absence means undeclared; it is never an empty risk list or a platform safety default. Local dev, test, build and pack, private packages and local import stay usable without it.
|
|
5
|
+
Omit the field entirely while it is not yet declared. Absence means undeclared; it is never an empty risk list or a platform safety default. Local dev, test, build and pack, private packages and local import stay usable without it. Whether a public submission requires the declaration is determined by the Registry's current admission policy. App Tools does not determine or fetch that policy during local checks; consult it when preparing a public submission. If the policy requires the declaration, provide the complete block.
|
|
6
6
|
|
|
7
7
|
Declare facts, not proofs. `absent` is a legitimate value for a notice or marking, and `present` means the supported paths uniformly provide it (declare `absent` when only some do). Audience is publisher positioning, not legal age verification. Descriptors cover provided functionality, default content and reasonably foreseeable ordinary use, not every possible model output. Capability names never imply declaration values: a `voice.create` reference does not require an `audio` output entry or a voice-replication risk feature. Do not add marking code, scanners, age checks or business SDK calls to satisfy the declaration.
|
|
8
8
|
|
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
# Platform upgrade
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
3
|
+
Fresh App Tools 0.13 scaffolds require Kit `^0.21.0` or a later admitted pair
|
|
4
|
+
with the standard navigation contract. The combination list also contains
|
|
5
|
+
existing-adoption pairs; those do not permit older Kit in a new scaffold.
|
|
6
|
+
Init verifies generated sources and immutable identity/direct features before
|
|
7
|
+
owner calls. Ordinary current-contract sync preserves a supported selection.
|
|
8
|
+
|
|
9
|
+
The `2026-10-13.standard-app-navigation-v1` contract is a hard cut. An older
|
|
10
|
+
managed scaffold fails init/sync/check before any file write or owner mutation,
|
|
11
|
+
even after only the tool or only Kit is upgraded. It has no automatic migration.
|
|
12
|
+
Prepare a fresh reference with the same App identity, version and direct features
|
|
13
|
+
using the complete target packages. Migrate the App-owned product to its own
|
|
14
|
+
catalog and one `createNimiNavigation` controller, remove Router/active-view/history
|
|
15
|
+
writers and persisted position, and preserve business data, drafts and leave rules.
|
|
16
|
+
Review and replace the managed Host/glue and complete reference intent/lock as
|
|
17
|
+
the same explicit migration; add the App-owned navigation seed and retain the
|
|
18
|
+
App-owned product and license. Do not graft new glue onto an old lock or mark an
|
|
19
|
+
old router as the new contract. Then run the target tool's check, sync dry-run,
|
|
20
|
+
normal sync, installed dependency checks, build/tests and real supervised journey.
|
|
21
|
+
This contract replacement is the bounded exception to ordinary immutable intent
|
|
22
|
+
editing; it is an author-performed migration, never a sync fallback.
|
|
14
23
|
|
|
15
24
|
Read the current and selected target app-tools version matrix plus SDK/Kit migration notes. App-side package consumption uses complete npm tarballs through explicit pnpm-workspace overrides, without depending on the Nimi source checkout or requiring publication. For an authorized platform repair or extension, follow [Platform gaps](platform-gaps.md). Sync preserves package selections; check validates installed identities/versions and lock resolutions. Use normal dev/test/build/pack during iteration. Public release preflight is a later step using registry resolutions, after development acceptance.
|
|
16
25
|
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
"assetRevealFailed": "The folder could not be shown for {{path}}. The file has not been changed; try again when the host is available."
|
|
13
13
|
},
|
|
14
14
|
"History": {
|
|
15
|
+
"positionLoading": "Reading this saved result…",
|
|
16
|
+
"positionUnavailable": "This saved result is unavailable. Retry reading it or go back to another page.",
|
|
15
17
|
"title": "History",
|
|
16
18
|
"panelAriaLabel": "Runtime test History",
|
|
17
19
|
"filterAriaLabel": "Filter history",
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
"assetRevealFailed": "无法显示 {{path}} 所在的文件夹。文件未被修改,请在宿主可用后重试。"
|
|
13
13
|
},
|
|
14
14
|
"History": {
|
|
15
|
+
"positionLoading": "正在读取这条已保存的结果…",
|
|
16
|
+
"positionUnavailable": "这条已保存的结果不可用。可以重试读取,或后退到其他页面。",
|
|
15
17
|
"title": "历史",
|
|
16
18
|
"panelAriaLabel": "Runtime 测试历史",
|
|
17
19
|
"filterAriaLabel": "筛选历史",
|
|
@@ -466,9 +466,16 @@ function TextStudioShell({
|
|
|
466
466
|
setActiveRun(null);
|
|
467
467
|
}
|
|
468
468
|
|
|
469
|
+
const historyPreviewId = useRef<string | null>(null);
|
|
469
470
|
useEffect(() => {
|
|
470
471
|
const record = historySelectionRequest?.record;
|
|
471
|
-
if (!record || record.capabilityId !== capability.id)
|
|
472
|
+
if (!record || record.capabilityId !== capability.id) {
|
|
473
|
+
const previous = historyPreviewId.current;
|
|
474
|
+
if (previous) setActiveRun(current => current?.id === previous ? null : current);
|
|
475
|
+
historyPreviewId.current = null;
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
historyPreviewId.current = record.id;
|
|
472
479
|
selectHistoryRun(record);
|
|
473
480
|
}, [historySelectionRequest?.requestId, capability.id]);
|
|
474
481
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react';
|
|
2
|
-
import { nimiToast } from '@nimiplatform/kit/ui';
|
|
2
|
+
import { Button, InlineAlert, LoadingSkeleton, nimiToast } from '@nimiplatform/kit/ui';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
5
|
StudioCapabilityParameterContext,
|
|
@@ -28,6 +28,7 @@ import type { StudioCapabilityRunResult, StudioRuntimeInspection } from './runti
|
|
|
28
28
|
import { SectionAITesting } from './section-ai-testing.js';
|
|
29
29
|
import type { StudioAIConfigPanelRenderInput } from './section-ai-testing-surface.js';
|
|
30
30
|
import type { StudioTranslate } from './non-success-presentation.js';
|
|
31
|
+
import { useAIStudioHost } from './host-context.js';
|
|
31
32
|
|
|
32
33
|
export type AIStudioHistoryProjection = {
|
|
33
34
|
readonly runHistory: StudioRunHistory;
|
|
@@ -100,7 +101,8 @@ export type AIStudioWorkspaceProps = {
|
|
|
100
101
|
export type AIStudioWorkspaceControllerOptions = {
|
|
101
102
|
readonly historyRepository: AIStudioHistoryRepository;
|
|
102
103
|
readonly registrations: readonly StudioCapabilityRegistration[];
|
|
103
|
-
readonly onSelectCapability: (capabilityId: string) => void;
|
|
104
|
+
readonly onSelectCapability: (capabilityId: string, historyRunId?: string) => void;
|
|
105
|
+
readonly historyPosition?: { readonly runId: string; readonly entryKey: string; readonly capabilityId: string };
|
|
104
106
|
readonly translate: StudioTranslate;
|
|
105
107
|
};
|
|
106
108
|
|
|
@@ -118,6 +120,8 @@ export type AIStudioWorkspaceController = {
|
|
|
118
120
|
readonly history: StudioRunHistory | null;
|
|
119
121
|
readonly lastResult: StudioCapabilityRunResult | null;
|
|
120
122
|
readonly historySelectionRequest: { readonly requestId: number; readonly record: StudioRunHistoryRecord } | null;
|
|
123
|
+
readonly historySelectionPending: boolean;
|
|
124
|
+
readonly historySelectionUnavailable: boolean;
|
|
121
125
|
readonly selectHistoryRun: (record: StudioRunHistoryRecord) => void;
|
|
122
126
|
};
|
|
123
127
|
|
|
@@ -134,6 +138,7 @@ export function useAIStudioWorkspaceController({
|
|
|
134
138
|
historyRepository,
|
|
135
139
|
registrations,
|
|
136
140
|
onSelectCapability,
|
|
141
|
+
historyPosition,
|
|
137
142
|
translate,
|
|
138
143
|
}: AIStudioWorkspaceControllerOptions): AIStudioWorkspaceController {
|
|
139
144
|
const [projection, setProjection] = useState<AIStudioHistoryProjection | null>(null);
|
|
@@ -348,16 +353,23 @@ export function useAIStudioWorkspaceController({
|
|
|
348
353
|
}
|
|
349
354
|
}, [historyIssue, historyRepository, refreshHistory]);
|
|
350
355
|
|
|
356
|
+
const selectionEntry = useRef<string | null>(null);
|
|
357
|
+
const selectedRecord = historyPosition ? Object.values(projection?.runHistory ?? {}).flat().find(item => item.id === historyPosition.runId && item.capabilityId === historyPosition.capabilityId) : undefined;
|
|
358
|
+
useEffect(() => {
|
|
359
|
+
if (!historyPosition) { selectionEntry.current = null; setHistorySelectionRequest(null); return; }
|
|
360
|
+
const record = selectedRecord;
|
|
361
|
+
if (!record) { setHistorySelectionRequest(null); return; }
|
|
362
|
+
if (selectionEntry.current === historyPosition.entryKey) return;
|
|
363
|
+
selectionEntry.current = historyPosition.entryKey;
|
|
364
|
+
setHistorySelectionRequest(current => ({ requestId: (current?.requestId ?? 0) + 1, record }));
|
|
365
|
+
}, [historyPosition?.runId, historyPosition?.entryKey, selectedRecord]);
|
|
366
|
+
|
|
351
367
|
const selectHistoryRun = useCallback((record: StudioRunHistoryRecord) => {
|
|
352
368
|
if (!registrations.some((entry) => entry.descriptor.id === record.capabilityId)) {
|
|
353
369
|
nimiToast.warning(translate('History.unsupportedCapability'));
|
|
354
370
|
return;
|
|
355
371
|
}
|
|
356
|
-
onSelectCapability(record.capabilityId);
|
|
357
|
-
setHistorySelectionRequest((current) => ({
|
|
358
|
-
requestId: (current?.requestId ?? 0) + 1,
|
|
359
|
-
record,
|
|
360
|
-
}));
|
|
372
|
+
onSelectCapability(record.capabilityId, record.id);
|
|
361
373
|
}, [onSelectCapability, registrations, translate]);
|
|
362
374
|
|
|
363
375
|
return {
|
|
@@ -374,6 +386,8 @@ export function useAIStudioWorkspaceController({
|
|
|
374
386
|
history: projection?.runHistory ?? null,
|
|
375
387
|
lastResult,
|
|
376
388
|
historySelectionRequest,
|
|
389
|
+
historySelectionPending: Boolean(historyPosition && !projection && !historyIssue),
|
|
390
|
+
historySelectionUnavailable: Boolean(historyPosition && ((projection && !selectedRecord) || (!projection && historyIssue))),
|
|
377
391
|
selectHistoryRun,
|
|
378
392
|
};
|
|
379
393
|
}
|
|
@@ -389,6 +403,16 @@ export function AIStudioWorkspace({
|
|
|
389
403
|
headerActions,
|
|
390
404
|
rootTestId,
|
|
391
405
|
}: AIStudioWorkspaceProps) {
|
|
406
|
+
const { translate } = useAIStudioHost();
|
|
407
|
+
if (controller.historySelectionPending) {
|
|
408
|
+
return <div className="p-5"><LoadingSkeleton lines={4} label={translate('History.positionLoading')} /></div>;
|
|
409
|
+
}
|
|
410
|
+
if (controller.historySelectionUnavailable) {
|
|
411
|
+
return <div className="p-5"><InlineAlert tone="warning">
|
|
412
|
+
<p>{controller.historyLoadState.error ?? translate('History.positionUnavailable')}</p>
|
|
413
|
+
<Button onClick={controller.historyLoadState.retry}>{translate('Common.retry')}</Button>
|
|
414
|
+
</InlineAlert></div>;
|
|
415
|
+
}
|
|
392
416
|
return (
|
|
393
417
|
<StudioCapabilityParameterContext.Provider value={controller.parameterStore}>
|
|
394
418
|
<StudioHistoryLoadContext.Provider value={controller.historyLoadState}>
|
|
@@ -24,6 +24,7 @@ export type WorkbenchNavigationGroup<TViewId extends string> = {
|
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
export type WorkbenchCoreProps<TViewId extends string> = {
|
|
27
|
+
readonly sidebarVisible?: boolean;
|
|
27
28
|
readonly activeViewId: TViewId | null;
|
|
28
29
|
readonly navigationLabel: string;
|
|
29
30
|
readonly navigationPresentation?: 'rail' | 'catalog';
|
|
@@ -39,6 +40,7 @@ export type WorkbenchCoreProps<TViewId extends string> = {
|
|
|
39
40
|
};
|
|
40
41
|
|
|
41
42
|
export function WorkbenchCore<TViewId extends string>({
|
|
43
|
+
sidebarVisible = true,
|
|
42
44
|
activeViewId,
|
|
43
45
|
navigationLabel,
|
|
44
46
|
navigationPresentation = 'rail',
|
|
@@ -53,9 +55,9 @@ export function WorkbenchCore<TViewId extends string>({
|
|
|
53
55
|
children,
|
|
54
56
|
}: WorkbenchCoreProps<TViewId>) {
|
|
55
57
|
return (
|
|
56
|
-
<main className="workbench" data-testid={rootTestId} data-navigation-presentation={navigationPresentation}>
|
|
58
|
+
<main className="workbench" data-testid={rootTestId} data-navigation-presentation={navigationPresentation} data-sidebar-visible={sidebarVisible}>
|
|
57
59
|
<div className="workbench__body">
|
|
58
|
-
<aside className="workbench-side-nav" aria-label={navigationLabel}>
|
|
60
|
+
{sidebarVisible ? <aside className="workbench-side-nav" aria-label={navigationLabel}>
|
|
59
61
|
{navigationPresentation === 'catalog' && navigationTitle ? (
|
|
60
62
|
<div className="workbench-side-nav__heading">
|
|
61
63
|
<h1>{navigationTitle}</h1>
|
|
@@ -106,7 +108,7 @@ export function WorkbenchCore<TViewId extends string>({
|
|
|
106
108
|
{accountSlot ? <div className="workbench-side-nav__account">{accountSlot}</div> : null}
|
|
107
109
|
</div>
|
|
108
110
|
) : null}
|
|
109
|
-
</aside>
|
|
111
|
+
</aside> : null}
|
|
110
112
|
<div className="workbench__main">
|
|
111
113
|
<div className="workbench__content">{children}</div>
|
|
112
114
|
</div>
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
- Treat `.nimi/app-scaffold/{intent,lock}.json` as app-scaffold intent and lock state.
|
|
5
5
|
- App Tools maintains its identity/contract projections and the declared engineering fields in `.nimi/config` and `.nimi/admission`; the build profile and product declarations retain their App-owned inputs. Nimi-coding maintains its own methodology and AGENTS block through its declared sync command.
|
|
6
6
|
- Keep auth, Runtime, App Access declaration, manifest, and Tauri shell glue in scaffold-managed files.
|
|
7
|
-
- App-owned product code is `src/workbench-core/**`, selected `src/capabilities/**`, `src/shell/routes/product-area.tsx`, and App-authored product screens, state, tests, styles, and bounded native helpers.
|
|
7
|
+
- App-owned product code is `src/workbench-core/**`, selected `src/capabilities/**`, `src/shell/routes/product-area.tsx`, `src/shell/routes/app-navigation.tsx`, and App-authored product screens, state, tests, styles, and bounded native helpers.
|
|
8
8
|
- Scaffold-managed code is the carrier/auth wiring, identity, manifests, project tooling, bounded native integration, and `src/scaffold/generated/**` composition glue.
|
|
9
9
|
- Treat this template as the identity-neutral, Lab-derived base. The generator composes it positively with only the dependency closure of explicitly selected admitted features under `src/capabilities/**`.
|
|
10
10
|
- The scaffold contains developer build/release inputs and one managed GitHub workflow, but it must not generate public admission, listing, registry-main, installed, running, or Runtime-access truth.
|