@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.
Files changed (97) hide show
  1. package/README.md +59 -5
  2. package/bin/nimi-app.mjs +11 -3
  3. package/lib/app-access-declaration.mjs +1 -0
  4. package/lib/app-dependency-combinations.mjs +16 -28
  5. package/lib/app-doctor-update.mjs +66 -7
  6. package/lib/app-info.mjs +8 -1
  7. package/lib/app-project-lifecycle.mjs +82 -9
  8. package/lib/app-scaffold-capabilities.mjs +3 -3
  9. package/lib/app-scaffold-profiles.mjs +96 -26
  10. package/lib/app-scaffold.mjs +54 -7
  11. package/lib/canonical-capability-ids.generated.mjs +4 -0
  12. package/package.json +26 -25
  13. package/scripts/dev-shell.mjs +61 -17
  14. package/skills/nimi-app-lifecycle/references/acceptance.md +1 -1
  15. package/skills/nimi-app-lifecycle/references/adapt.md +2 -2
  16. package/skills/nimi-app-lifecycle/references/release.md +1 -1
  17. package/skills/nimi-app-lifecycle/references/upgrade-platform.md +14 -0
  18. package/templates/app-source/src/ai-studio-core/ai-config.ts +17 -3
  19. package/templates/app-source/src/ai-studio-core/ai-studio-core.css +40 -3
  20. package/templates/app-source/src/ai-studio-core/audio-separation-request.ts +24 -0
  21. package/templates/app-source/src/ai-studio-core/contexts.tsx +4 -0
  22. package/templates/app-source/src/ai-studio-core/history-policy.ts +395 -41
  23. package/templates/app-source/src/ai-studio-core/history.ts +262 -10
  24. package/templates/app-source/src/ai-studio-core/host-context.tsx +15 -2
  25. package/templates/app-source/src/ai-studio-core/index.ts +15 -4
  26. package/templates/app-source/src/ai-studio-core/job-recovery-panel.tsx +105 -0
  27. package/templates/app-source/src/ai-studio-core/job-recovery.ts +224 -0
  28. package/templates/app-source/src/ai-studio-core/managed-result-references.ts +79 -0
  29. package/templates/app-source/src/ai-studio-core/messages/en.json +185 -10
  30. package/templates/app-source/src/ai-studio-core/messages/zh.json +185 -10
  31. package/templates/app-source/src/ai-studio-core/module-registration.ts +9 -1
  32. package/templates/app-source/src/ai-studio-core/non-success-presentation.ts +81 -2
  33. package/templates/app-source/src/ai-studio-core/parameters.ts +34 -1
  34. package/templates/app-source/src/ai-studio-core/runtime-types.ts +124 -8
  35. package/templates/app-source/src/ai-studio-core/runtime.ts +218 -20
  36. package/templates/app-source/src/ai-studio-core/section-ai-testing-annotation-result.tsx +123 -0
  37. package/templates/app-source/src/ai-studio-core/section-ai-testing-artifact-preview.ts +3 -0
  38. package/templates/app-source/src/ai-studio-core/section-ai-testing-audio-separation-result.tsx +26 -0
  39. package/templates/app-source/src/ai-studio-core/section-ai-testing-composer.tsx +14 -7
  40. package/templates/app-source/src/ai-studio-core/section-ai-testing-decision-result.tsx +76 -0
  41. package/templates/app-source/src/ai-studio-core/section-ai-testing-exchange-result.tsx +71 -0
  42. package/templates/app-source/src/ai-studio-core/section-ai-testing-history.tsx +20 -4
  43. package/templates/app-source/src/ai-studio-core/section-ai-testing-input.ts +29 -0
  44. package/templates/app-source/src/ai-studio-core/section-ai-testing-music-result.tsx +45 -0
  45. package/templates/app-source/src/ai-studio-core/section-ai-testing-output.tsx +132 -10
  46. package/templates/app-source/src/ai-studio-core/section-ai-testing-result.tsx +122 -38
  47. package/templates/app-source/src/ai-studio-core/section-ai-testing-run.ts +4 -3
  48. package/templates/app-source/src/ai-studio-core/section-ai-testing-session-result.tsx +66 -0
  49. package/templates/app-source/src/ai-studio-core/section-ai-testing-studio-result.tsx +100 -22
  50. package/templates/app-source/src/ai-studio-core/section-ai-testing-surface.tsx +6 -0
  51. package/templates/app-source/src/ai-studio-core/section-ai-testing-transcript-result.tsx +45 -0
  52. package/templates/app-source/src/ai-studio-core/section-ai-testing-transcription-result.tsx +106 -0
  53. package/templates/app-source/src/ai-studio-core/section-ai-testing-vision-result.tsx +23 -4
  54. package/templates/app-source/src/ai-studio-core/section-ai-testing-voice-asset-actions.tsx +40 -0
  55. package/templates/app-source/src/ai-studio-core/section-ai-testing-voice-conversion-result.tsx +20 -0
  56. package/templates/app-source/src/ai-studio-core/section-ai-testing.tsx +219 -35
  57. package/templates/app-source/src/ai-studio-core/text-annotation-document.ts +50 -0
  58. package/templates/app-source/src/ai-studio-core/text-media-replay.ts +51 -0
  59. package/templates/app-source/src/ai-studio-core/voice-assets.ts +17 -0
  60. package/templates/app-source/src/ai-studio-core/workspace.tsx +48 -6
  61. package/templates/app-source/src/studio-modules/studio-create/descriptors.ts +1 -1
  62. package/templates/app-source/src/studio-modules/studio-create/messages/en.json +13 -1
  63. package/templates/app-source/src/studio-modules/studio-create/messages/zh.json +13 -1
  64. package/templates/app-source/src/studio-modules/studio-create/parameter-panel.tsx +11 -2
  65. package/templates/app-source/src/studio-modules/studio-create/parameters.ts +2 -2
  66. package/templates/app-source/src/studio-modules/studio-create/registration.ts +2 -2
  67. package/templates/app-source/src/studio-modules/studio-create/runtime.ts +121 -3
  68. package/templates/app-source/src/studio-modules/studio-media/audio-separate-parameters.tsx +72 -0
  69. package/templates/app-source/src/studio-modules/studio-media/audio-separate-runtime.ts +90 -0
  70. package/templates/app-source/src/studio-modules/studio-media/descriptors.ts +16 -1
  71. package/templates/app-source/src/studio-modules/studio-media/index.ts +2 -0
  72. package/templates/app-source/src/studio-modules/studio-media/messages/en.json +225 -7
  73. package/templates/app-source/src/studio-modules/studio-media/messages/zh.json +225 -7
  74. package/templates/app-source/src/studio-modules/studio-media/music-parameters.tsx +85 -0
  75. package/templates/app-source/src/studio-modules/studio-media/music-transcription-parameters.tsx +85 -0
  76. package/templates/app-source/src/studio-modules/studio-media/music-transcription-runtime.ts +64 -0
  77. package/templates/app-source/src/studio-modules/studio-media/parameter-panel.tsx +9 -26
  78. package/templates/app-source/src/studio-modules/studio-media/parameters.ts +170 -6
  79. package/templates/app-source/src/studio-modules/studio-media/registration.ts +29 -1
  80. package/templates/app-source/src/studio-modules/studio-media/runtime.ts +90 -6
  81. package/templates/app-source/src/studio-modules/studio-media/vision-parameters.tsx +1 -0
  82. package/templates/app-source/src/studio-modules/studio-media/vision-runtime.ts +23 -5
  83. package/templates/app-source/src/studio-modules/studio-media/voice-convert-parameters.tsx +132 -0
  84. package/templates/app-source/src/studio-modules/studio-media/voice-convert-runtime.ts +120 -0
  85. package/templates/app-source/src/studio-modules/studio-voice/audio-url.ts +25 -0
  86. package/templates/app-source/src/studio-modules/studio-voice/messages/en.json +4 -4
  87. package/templates/app-source/src/studio-modules/studio-voice/messages/zh.json +4 -4
  88. package/templates/app-source/src/studio-modules/studio-voice/parameters.ts +28 -0
  89. package/templates/app-source/src/studio-modules/studio-voice/runtime.ts +66 -30
  90. package/templates/app-source/src/workbench-core/index.ts +2 -0
  91. package/templates/app-source/src/workbench-core/runtime-gate.tsx +102 -6
  92. package/templates/app-source/src/workbench-core/workbench-core.css +42 -0
  93. package/templates/app-source/src/workbench-core/workbench-core.tsx +69 -18
  94. package/templates/app-source.manifest.json +100 -0
  95. package/templates/default-starter/README.md +2 -1
  96. package/templates/default-starter/src/shell/workbench-target-adapter.ts +102 -12
  97. package/templates/default-starter.manifest.json +0 -4
@@ -4,6 +4,7 @@ import { lstat, readFile, realpath, stat } from 'node:fs/promises';
4
4
  import { homedir } from 'node:os';
5
5
  import path from 'node:path';
6
6
  import process from 'node:process';
7
+ import { createInterface } from 'node:readline/promises';
7
8
  import { parseEnv } from 'node:util';
8
9
  import { parse as parseYaml } from 'yaml';
9
10
 
@@ -25,7 +26,9 @@ const TERMINAL_STATES = new Set([
25
26
 
26
27
  // @nimi-authority: rule.nimi.platform.app-ecosystem.p-scaf-018a
27
28
  export async function runDevShell(cwd, options = {}) {
28
- if (options.listRegistrations && options.resume) throw new DevShellError('local-development-intent-invalid', '--list-registrations and --resume cannot be combined.');
29
+ if ([options.listRegistrations, options.resume, options.newRegistration].filter(Boolean).length > 1) {
30
+ throw new DevShellError('local-development-intent-invalid', '--list-registrations, --resume and --new-registration cannot be combined.');
31
+ }
29
32
  if (options.resume && !/^dev-project-[A-Za-z0-9_-]{1,148}$/u.test(options.resume)) {
30
33
  throw new DevShellError('local-development-selector-invalid', '--resume requires a current-host selector from --list-registrations.');
31
34
  }
@@ -42,8 +45,10 @@ export async function runDevShell(cwd, options = {}) {
42
45
  if (typeof fetchImpl !== 'function') {
43
46
  throw new DevShellError('local-development-launcher-unavailable', 'This Node.js runtime does not provide fetch.');
44
47
  }
45
- if (options.listRegistrations) {
46
- const listed = await postJson(fetchImpl, descriptor.endpoint, '/v1/registrations', {
48
+ if (!options.listRegistrations) await assertProjectElectronRuntime(projectRoot);
49
+ let registrationSelector = options.resume;
50
+ if (options.listRegistrations || (!options.resume && !options.newRegistration)) {
51
+ const listed = await postJson(fetchImpl, descriptor, '/v1/registrations', {
47
52
  schemaVersion: 1, appId, projectRoot, shell,
48
53
  });
49
54
  if (listed?.status !== 'ok' || !Array.isArray(listed.registrations)) {
@@ -55,24 +60,29 @@ export async function runDevShell(cwd, options = {}) {
55
60
  || typeof row.displayName !== 'string' || !Number.isSafeInteger(row.registeredAtUnixMs)) {
56
61
  throw new DevShellError('local-development-intent-invalid', 'Desktop returned an invalid registration projection.');
57
62
  }
58
- output.write(`${row.selector}\t${new Date(row.registeredAtUnixMs).toISOString()}\t${row.displayName}\n`);
59
63
  }
60
- output.write(listed.registrations.length
61
- ? '[nimi-app dev] Resume an explicit selection with: pnpm dev -- --resume <selector>\n'
62
- : '[nimi-app dev] No current-host registrations for this project. Run pnpm dev to create one.\n');
63
- return listed.registrations;
64
+ if (options.listRegistrations) {
65
+ printRegistrations(output, listed.registrations);
66
+ output.write(listed.registrations.length
67
+ ? '[nimi-app dev] Resume an explicit selection with: pnpm dev -- --resume <selector>\n'
68
+ : '[nimi-app dev] No current-host registrations for this project. Run pnpm dev to create one.\n');
69
+ return listed.registrations;
70
+ }
71
+ if (listed.registrations.length) {
72
+ registrationSelector = await selectRegistration(listed.registrations, options);
73
+ }
64
74
  }
65
75
 
66
- await assertProjectElectronRuntime(projectRoot);
67
76
  const startIntent = {
68
77
  schemaVersion: 1,
69
78
  appId,
70
79
  projectRoot,
71
80
  shell,
72
81
  ...(cdpPort === undefined ? {} : { cdpPort }),
73
- ...(options.resume ? { registrationSelector: options.resume } : {}),
82
+ ...(registrationSelector ? { registrationSelector } : {}),
83
+ ...(options.newRegistration ? { newRegistration: true } : {}),
74
84
  };
75
- const start = await postJson(fetchImpl, descriptor.endpoint, '/v1/start', startIntent);
85
+ const start = await postJson(fetchImpl, descriptor, '/v1/start', startIntent);
76
86
  const initial = parseBridgeRun(start);
77
87
  if (!initial.runId) {
78
88
  throw bridgeError(start, initial);
@@ -88,7 +98,7 @@ export async function runDevShell(cwd, options = {}) {
88
98
  if (cancelling) return;
89
99
  cancelling = true;
90
100
  try {
91
- await postJson(fetchImpl, descriptor.endpoint, '/v1/cancel', {
101
+ await postJson(fetchImpl, descriptor, '/v1/cancel', {
92
102
  schemaVersion: 1,
93
103
  runId: initial.runId,
94
104
  });
@@ -117,7 +127,7 @@ export async function runDevShell(cwd, options = {}) {
117
127
  return current;
118
128
  }
119
129
  await delay(STATUS_POLL_MS, signal);
120
- const response = await postJson(fetchImpl, descriptor.endpoint, '/v1/status', {
130
+ const response = await postJson(fetchImpl, descriptor, '/v1/status', {
121
131
  schemaVersion: 1,
122
132
  runId: initial.runId,
123
133
  });
@@ -136,6 +146,36 @@ export async function runDevShell(cwd, options = {}) {
136
146
  }
137
147
  }
138
148
 
149
+ function printRegistrations(output, registrations) {
150
+ for (const [index, row] of registrations.entries()) {
151
+ output.write(`${index + 1}. ${row.selector}\t${new Date(row.registeredAtUnixMs).toISOString()}\t${row.displayName}\n`);
152
+ }
153
+ }
154
+
155
+ async function selectRegistration(registrations, options) {
156
+ const input = options.input ?? process.stdin;
157
+ const output = options.output ?? process.stdout;
158
+ printRegistrations(output, registrations);
159
+ const guidance = 'Choose an existing registration with --resume <selector>, or use --new-registration for separate App data.';
160
+ if (!input.isTTY || !output.isTTY) {
161
+ throw new DevShellError('local-development-registration-selection-required', guidance);
162
+ }
163
+ const prompt = createInterface({ input, output });
164
+ try {
165
+ const answer = (await prompt.question(
166
+ '[nimi-app dev] Resume which registration? Enter its number (empty cancels): ',
167
+ options.signal ? { signal: options.signal } : undefined,
168
+ )).trim();
169
+ const index = /^\d+$/u.test(answer) ? Number(answer) - 1 : -1;
170
+ if (!Number.isSafeInteger(index) || !registrations[index]) {
171
+ throw new DevShellError('local-development-registration-selection-required', guidance);
172
+ }
173
+ return registrations[index].selector;
174
+ } finally {
175
+ prompt.close();
176
+ }
177
+ }
178
+
139
179
  export function assertLocalDevelopmentPlatform(platform, shell) {
140
180
  if (shell !== 'electron') {
141
181
  throw new DevShellError(
@@ -212,6 +252,7 @@ async function readPresenceDescriptor(descriptorPath, now) {
212
252
  await assertRegularFileWithoutSymlinkAncestry(descriptorPath);
213
253
  const raw = JSON.parse(await readFile(descriptorPath, 'utf8'));
214
254
  if (!isPlainObject(raw) || Object.keys(raw).sort().join(',') !== [
255
+ 'callerToken',
215
256
  'desktopAppId',
216
257
  'desktopPid',
217
258
  'endpoint',
@@ -227,7 +268,8 @@ async function readPresenceDescriptor(descriptorPath, now) {
227
268
  if (!Number.isFinite(heartbeat) || now - heartbeat > MAX_HEARTBEAT_AGE_MS || heartbeat - now > 5_000) {
228
269
  throw new Error('heartbeat');
229
270
  }
230
- return { endpoint: normalizeLoopbackEndpoint(raw.endpoint) };
271
+ if (typeof raw.callerToken !== 'string' || !/^[0-9a-f]{64}$/u.test(raw.callerToken)) throw new Error('caller-token');
272
+ return { endpoint: normalizeLoopbackEndpoint(raw.endpoint), callerToken: raw.callerToken };
231
273
  } catch {
232
274
  throw new DevShellError(
233
275
  'local-development-desktop-not-running',
@@ -250,12 +292,14 @@ async function assertRegularFileWithoutSymlinkAncestry(filePath) {
250
292
  if (!metadata.isFile()) throw new Error('not-file');
251
293
  }
252
294
 
253
- async function postJson(fetchImpl, endpoint, route, body) {
295
+ async function postJson(fetchImpl, desktop, route, body) {
254
296
  let response;
255
297
  try {
256
- response = await fetchImpl(`${endpoint}${route}`, {
298
+ response = await fetchImpl(`${desktop.endpoint}${route}`, {
257
299
  method: 'POST',
258
- headers: { 'Content-Type': 'application/json' },
300
+ // The token read from the owner-only presence file proves this caller
301
+ // is the official launcher running as the same OS user.
302
+ headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${desktop.callerToken}` },
259
303
  body: JSON.stringify(body),
260
304
  redirect: 'error',
261
305
  signal: AbortSignal.timeout(route === '/v1/start' || route === '/v1/registrations'
@@ -2,7 +2,7 @@
2
2
 
3
3
  Select the actual user journey and affected capability. Reuse the App's package scripts, existing tests and prior sufficient evidence; a small source or wording change does not require the whole release chain.
4
4
 
5
- For development, run the official `nimi-app dev` launcher with Desktop supervising Electron. Attach only to the exact App's reported loopback CDP target. Renderer URLs or independently launched processes cannot prove protected access. Use the existing `--list-registrations` and explicit `--resume <selector>` when continuing the same development data; do not persist selectors or reopen by App ID/path. Native and installed UI use their owner-supported paths, not production CDP additions.
5
+ For development, run the official `nimi-app dev` launcher with Desktop supervising Electron. Attach only to the exact App's reported loopback CDP target. Renderer URLs or independently launched processes cannot prove protected access. Use the existing `--list-registrations` and explicit `--resume <selector>` when continuing the same development data; do not persist selectors or reopen by App ID/path. Plain dev requests an explicit selection when registrations exist; non-interactive runs must pass --resume. Use --new-registration only for deliberately separate App data, never as a fallback from a rejected resume. Native and installed UI use their owner-supported paths, not production CDP additions.
6
6
 
7
7
  On Windows the project must have its Electron binary installed. If the launcher reports a missing `node_modules/electron/dist/electron.exe`, run the matched package's explicit `pnpm exec install-electron --no`, then retry the original launch. An installed npm wrapper or a successful `pnpm rebuild electron` alone does not prove that binary is present. Keep the explicit installer in the App's normal dependency setup; no empty renderer or alternate Host is needed.
8
8
 
@@ -37,9 +37,9 @@ Use `pnpm exec nimi-app init --adopt --dry-run --json`, then apply without `--dr
37
37
 
38
38
  Review the exact dependency, dev/renderer/pack script and workflow changes. Existing Host and business code, README and license remain App-owned; no fresh intent/lock is created. An unknown same-name skill/workflow or broken managed block requires a bounded cleanup, not forced takeover. Install normalized dependencies, sync/check, then run affected tests and the official App journey.
39
39
 
40
- Preserve the Electron `--user-data-dir` supplied by Desktop during supervised development. Do not replace it with an App's fixed `app.setPath('userData', ...)`: Desktop discovers the ephemeral CDP port from that profile's `DevToolsActivePort` file. Keep business databases and media in their declared App-owned storage, separately from the Electron profile. A `local-development-cdp-port-unavailable` error can mean that the Host exited early or moved that profile; a DevTools listening line alone does not establish successful supervision. Inspect the actual Host startup error and retry the normal launcher after fixing it. Also verify icons, preload and business-process resource paths from the built Host entry, since bundling can change their directory base.
40
+ Make Kit's `configureNimiElectronAppHostProfile(app)` from `@nimiplatform/kit/shell/electron/host-profile` the first call of the Electron main, before any session, window or `whenReady` work, and load the rest of Kit afterwards, as the generated Host does with `await import('@nimiplatform/kit/shell/electron/main')`. It binds user data, session data and temp to the Host profile Desktop prepared under the selected Nimi data root for both development and installed launches; without that profile the Host must stop rather than use Electron's default location. Do not override those paths with a fixed `app.setPath(...)` or another `--user-data-dir`: Desktop discovers the ephemeral development CDP port from that profile's `DevToolsActivePort` file. Keep business databases and media in their declared App-owned storage, separately from the Electron profile. A `local-development-cdp-port-unavailable` error can mean that the Host exited early or moved that profile; a DevTools listening line alone does not establish successful supervision. Inspect the actual Host startup error and retry the normal launcher after fixing it. Also verify icons, preload and business-process resource paths from the built Host entry, since bundling can change their directory base.
41
41
 
42
- Browser localStorage and IndexedDB are Host-profile data, not the SDK's Nimi-mediated JSON/asset partition. The installed launch does not supply the development profile, so do not promise automatic transfer of browser drafts from development to installation. For `app-owned-os-storage`, disclose the actual stable OS roots used by the packaged Host. It may explicitly place its packaged Electron profile beneath an already disclosed App-owned root, while preserving Desktop's development override. Alternatively, verify and disclose its actual default profile location; an App display name alone is not evidence of that path. Do not put Nimi's private development-profile layout in an App manifest. Keep important projects in the App's declared durable storage and use its normal project export/open workflow across those separate profiles; verify restart retention before promising it.
42
+ Browser localStorage and IndexedDB are Host-profile data, not the SDK's Nimi-mediated JSON/asset partition. Development and installed launches receive separate Host profiles, and switching the Nimi data root starts from a new one, so do not promise automatic transfer of browser drafts between them. For `app-owned-os-storage`, disclose the actual stable OS roots the packaged Host uses for its own data; its Electron profile stays in the Nimi Host profile. Do not put Nimi's private Host-profile layout in an App manifest. Keep important projects in the App's declared durable storage and use its normal project export/open workflow across those separate profiles; verify restart retention before promising it.
43
43
 
44
44
  ## Map only the capabilities the product uses
45
45
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Before public release, use public dependencies and frozen locks, complete portable App information and existing notices, and build/pack on the declared OS/architecture. Reuse `nimi-app check --production`, `test`, `build --target <target> --production`, and `pack --target <target> --production`. Local check does not establish GitHub settings or a release. Local installed-App acceptance can precede this with complete local npm tarballs and `pack --production`; follow the acceptance guide without requiring publication first.
4
4
 
5
- The packaged root `LICENSE` must match the reviewed source file byte for byte. New scaffolds include `LICENSE -text` in `.gitattributes`; for an existing repository, retain its other attributes and add that rule before tagging. It preserves the Git blob's original bytes when Windows would otherwise convert LF to CRLF. Registry checks the exact published package against the tagged source.
5
+ The root `LICENSE` is App-owned: a new scaffold starts it as MIT naming the author or App title, sync never rewrites it, and the App sets its own terms plus the matching `package.json` `license` identifier. Keep the scaffold-managed `licenses/nimi-app-template.txt` notice for template-derived code. The packaged root `LICENSE` must match the reviewed source file byte for byte. New scaffolds include `LICENSE -text` in `.gitattributes`; for an existing repository, retain its other attributes and add that rule before tagging. It preserves the Git blob's original bytes when Windows would otherwise convert LF to CRLF. Registry checks the exact published package against the tagged source.
6
6
 
7
7
  Electron packages must unpack native add-ons and their companion shared libraries with their relative layout intact. The scaffold uses `asar: { unpack: '**/*.{node,dylib,dll}' }` for the supported Mac/Windows targets. Existing App-owned packagers need the equivalent rule: unpacking only `.node` leaves libraries such as Sharp's libvips inside ASAR, where the OS loader cannot find them. Verify native loading from the packaged layout; a successful source launch or build alone does not prove that layout works.
8
8
 
@@ -1,5 +1,17 @@
1
1
  # Platform upgrade
2
2
 
3
+ Before first fresh init, an App may explicitly select another combination listed
4
+ by the installed tool in package.json. Init verifies the original generated
5
+ sources, preserves immutable identity and direct features, and projects the
6
+ selected pair into derived intent, glue and lock. Fresh create still uses the
7
+ tool default; do not edit intent or lock by hand. Unlisted pairs fail before
8
+ owner mutations.
9
+
10
+ App Tools 0.9 requires the Host-profile contract in Kit 0.13: select SDK
11
+ `^0.16.0` and Kit `^0.13.0` before sync. Older combinations are rejected before
12
+ files or owner projections change. There is no old-template or default-profile
13
+ fallback. Use the selected package's matrix for later versions.
14
+
3
15
  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.
4
16
 
5
17
  Install the target app-tools and its exact nimi-coding first. The App-local nimi-coding executable performs its own projections, so running an old installed executable is not a target-version sync. Use the target tool for `nimi-app sync --dry-run --json`; this previews app-tools files and lists the separate owner step without pretending to preview nimi-coding's internals.
@@ -8,6 +20,8 @@ Review App-owned instructions outside managed blocks when the upgrade changes an
8
20
 
9
21
  Upgrading app-tools does not by itself move an existing App's SDK/Kit combination: sync preserves a supported combination and check rejects an unlisted SDK x Kit pairing rather than normalizing it. Selecting a new SDK/Kit combination is a deliberate App decision. When it is made, migrate the affected App-owned API uses, run sync, then install the full normalized dependency set and regenerate the package-manager lockfile. Run check and the relevant tests/build and real journey. Fresh scaffold identity and direct features remain fixed; the tool updates derived version/matrix projections. Existing Apps continue without a fresh lock.
10
22
 
23
+ A scaffold from an app-tools version that still managed `LICENSE` hands it to the App on the next sync: the file stays byte for byte, the lock records the App as owner, sync reports the handover and adds `licenses/nimi-app-template.txt`, and check asks for that sync first. Replace a license that still names the template holder with the App's own terms.
24
+
11
25
  For existing Apps, sync preserves the exact `package.json` text when its managed values are already current. A project formatter's whitespace or key ordering alone is not drift; actual managed value changes are still synchronized.
12
26
 
13
27
  Do not downgrade away required features, edit installed package code or disable checks to get a green result. A platform capability awaiting publication blocks public release reproducibility, not independent engineering work. Validate a representative actual old-to-new combination; do not build a general migration framework.
@@ -17,6 +17,9 @@ export type StudioAIConfigVisibilityTarget = StudioAIConfigRefreshEventTarget &
17
17
  readonly visibilityState: string;
18
18
  };
19
19
 
20
+ /** Reports a possible AIConfig write inside this App window, e.g. when the in-app drawer closes. */
21
+ export const STUDIO_AI_CONFIG_CHANGED_EVENT = 'nimi://ai-studio-ai-config-changed';
22
+
20
23
  export async function loadStudioAIConfig(
21
24
  client: Pick<StudioAIConfigClient, 'get'>,
22
25
  expectedAppId: string,
@@ -30,23 +33,34 @@ export async function loadStudioAIConfig(
30
33
  }
31
34
  }
32
35
 
36
+ /**
37
+ * Focus and visibility report writes from other surfaces; the in-app change
38
+ * event reports same-window writes, which never move focus.
39
+ */
33
40
  export function subscribeStudioAIConfigRefresh(
34
41
  refresh: () => void,
35
42
  focusTarget: StudioAIConfigRefreshEventTarget,
36
43
  visibilityTarget: StudioAIConfigVisibilityTarget,
37
44
  ): () => void {
38
- const onFocus: EventListener = () => refresh();
45
+ const onRefresh: EventListener = () => refresh();
39
46
  const onVisibilityChange: EventListener = () => {
40
47
  if (visibilityTarget.visibilityState === 'visible') refresh();
41
48
  };
42
- focusTarget.addEventListener('focus', onFocus);
49
+ focusTarget.addEventListener('focus', onRefresh);
50
+ focusTarget.addEventListener(STUDIO_AI_CONFIG_CHANGED_EVENT, onRefresh);
43
51
  visibilityTarget.addEventListener('visibilitychange', onVisibilityChange);
44
52
  return () => {
45
- focusTarget.removeEventListener('focus', onFocus);
53
+ focusTarget.removeEventListener('focus', onRefresh);
54
+ focusTarget.removeEventListener(STUDIO_AI_CONFIG_CHANGED_EVENT, onRefresh);
46
55
  visibilityTarget.removeEventListener('visibilitychange', onVisibilityChange);
47
56
  };
48
57
  }
49
58
 
59
+ /** Dispatches from a node inside the App document so it bubbles to the window focus target. */
60
+ export function notifyStudioAIConfigChanged(source: Pick<EventTarget, 'dispatchEvent'>): void {
61
+ source.dispatchEvent(new Event(STUDIO_AI_CONFIG_CHANGED_EVENT, { bubbles: true }));
62
+ }
63
+
50
64
  export function requireStudioAIConfigOwner(
51
65
  config: NimiPortableAppAIConfig,
52
66
  expectedAppId: string,
@@ -18,12 +18,18 @@
18
18
  .studio__title,
19
19
  .studio__head-actions{ display: flex; align-items: center; gap: 10px; min-width: 0;}
20
20
  .studio__title{ flex-wrap: wrap; overflow: visible; row-gap: 6px;}
21
- .studio__stage{ min-width: 0; min-height: 0; display: grid;}
21
+ .studio__stage{ min-width: 0; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr); grid-auto-rows: auto;}
22
+ .studio-recovery{ min-width: 0; border-top: 1px solid var(--nimi-border-subtle);}
23
+ .studio-recovery > summary{ padding: 10px 18px; cursor: pointer; color: var(--nimi-text-secondary); font-size: 13px; line-height: 20px;}
24
+ .studio-recovery > summary:focus-visible{ outline: 2px solid var(--nimi-focus-ring-color); outline-offset: -2px;}
25
+ .studio-recovery__state{ float: right; max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--nimi-text-muted); font-size: 12px;}
26
+ .studio-recovery__body{ display: grid; gap: 12px; max-height: min(320px, 40vh); overflow: auto; padding: 0 18px 12px;}
27
+ .studio-recovery__body p{ margin: 0; overflow-wrap: anywhere;}
22
28
  .studio-start{ display: grid; place-items: center; min-height: 0; padding: 24px 24px 108px;}
23
29
  .studio-start__center{ display: grid; gap: 31px; width: min(842px, 100%);}
24
30
  .studio-start__center h2{ margin: 0; text-align: center; font-size: 36px; line-height: 1.08; font-weight: var(--nimi-type-page-title-weight); letter-spacing: 0;}
25
31
  .studio-thread{ --nimi-ui-module-lab-studio-scrollbar-gutter: 17px; display: grid; grid-template-rows: minmax(0, 1fr) auto; min-height: 0;}
26
- .studio-thread__scroll{ min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 18px;}
32
+ .studio-thread__scroll{ container-type: size; min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 18px;}
27
33
  .studio-thread__composer{ border-top: 0; padding: 12px calc(18px + var(--nimi-ui-module-lab-studio-scrollbar-gutter)) 16px 18px; background: transparent;}
28
34
  .studio-turn{ display: grid; gap: 14px; max-width: var(--nimi-ui-module-lab-studio-work-width); margin: 0 auto 28px;}
29
35
  .studio-turn__label{ display: flex; align-items: center; gap: 8px; color: color-mix(in srgb, var(--nimi-text-muted) 88%, var(--nimi-text-secondary)); font-size: 12px; font-weight: var(--nimi-type-page-title-weight); letter-spacing: 0.12em; text-transform: uppercase;}
@@ -60,7 +66,7 @@
60
66
  .studio-composer--vision.studio-composer--compact .studio-locate-parameters p{ display: none;}
61
67
  .studio-composer--vision.studio-composer--compact .studio-input{ padding-bottom: 16px;}
62
68
  .studio-locate-result{margin:0;display:grid;gap:12px;min-width:0;}
63
- .studio-locate-result__image{position:relative;width:100%;overflow:hidden;background:var(--nimi-surface-card);border-radius:var(--nimi-radius-md);}
69
+ .studio-locate-result__image{position:relative;width:100%;max-height:min(520px,80cqh);overflow:hidden;background:var(--nimi-surface-card);border-radius:var(--nimi-radius-md);}
64
70
  .studio-locate-result__image img{display:block;width:100%;height:100%;object-fit:contain;image-orientation:from-image;}
65
71
  .studio-locate-result__image svg{position:absolute;inset:0;width:100%;height:100%;pointer-events:none;}
66
72
  .studio-locate-result__image rect{fill:transparent;stroke:var(--nimi-accent);stroke-width:3;filter:drop-shadow(0 1px 1px white);}
@@ -149,6 +155,7 @@
149
155
  .studio-result__blocked-line,
150
156
  .studio-result__pending-line{ display: flex; align-items: center; gap: 8px; font-weight: var(--nimi-type-page-title-weight);}
151
157
  .studio-result__blocked-line{ color: var(--nimi-status-warning);}
158
+ .studio-result__reselect{ justify-self: start;}
152
159
  .studio-result__pending-line{ color: var(--nimi-text-secondary);}
153
160
  .studio-spin{ animation: nimi-ui-module-lab-studio-spin 0.9s linear infinite;}
154
161
  .studio-chips{ display: flex; flex-wrap: wrap; gap: 6px;}
@@ -156,6 +163,35 @@
156
163
  .studio-voice-list{ display: grid; gap: 8px; margin: 0; padding: 0; list-style: none;}
157
164
  .studio-voice-list li{ display: grid; gap: 2px;}
158
165
  .studio-voice-list span{ color: var(--nimi-text-muted); font-size: 12px;}
166
+ .studio-annotation{ display: grid; gap: 8px; min-width: 0;}
167
+ .studio-annotation > summary{ cursor: pointer; font-weight: 600;}
168
+ .studio-annotation__text{ margin: 0; white-space: pre-wrap; overflow-wrap: anywhere;}
169
+ .studio-annotation__sentence{ display: grid; gap: 6px; min-width: 0; overflow-x: auto;}
170
+ .studio-annotation__tokens{ border-collapse: collapse; font-size: 12px;}
171
+ .studio-annotation__tokens th,
172
+ .studio-annotation__tokens td{ padding: 3px 8px; border-bottom: 1px solid var(--nimi-border-subtle); text-align: left; white-space: nowrap;}
173
+ .studio-annotation__tokens th{ color: var(--nimi-text-muted); font-weight: 600;}
174
+ .studio-exchange,
175
+ .studio-exchange__items{ display: grid; gap: 10px; margin: 0; padding-left: 18px;}
176
+ .studio-exchange__step{ display: grid; gap: 6px; min-width: 0;}
177
+ .studio-exchange__kind{ color: var(--nimi-text-muted); font-size: 12px;}
178
+ .studio-exchange__text{ margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere;}
179
+ .studio-decision,
180
+ .studio-decision__bars{ display: grid; gap: 10px; margin: 0; padding: 0; list-style: none;}
181
+ .studio-decision__bars{ gap: 6px;}
182
+ .studio-decision__question{ display: grid; gap: 8px; min-width: 0; border: 1px solid var(--nimi-border-subtle); border-radius: var(--nimi-radius-md); padding: 12px 14px;}
183
+ .studio-decision__head{ display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; min-width: 0;}
184
+ .studio-decision__id{ font-weight: 600; overflow-wrap: anywhere;}
185
+ .studio-decision__kind{ color: var(--nimi-text-muted); font-size: 12px;}
186
+ .studio-decision__answer{ margin: 0; overflow-wrap: anywhere;}
187
+ .studio-decision__bar{ display: grid; grid-template-columns: minmax(0, 36%) minmax(0, 1fr) auto; align-items: center; gap: 10px; color: var(--nimi-text-secondary); font-size: 13px;}
188
+ .studio-decision__label{ min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;}
189
+ .studio-decision__track{ height: 8px; overflow: hidden; border-radius: 999px; background: var(--nimi-surface-active);}
190
+ .studio-decision__fill{ display: block; height: 100%; border-radius: inherit; background: color-mix(in srgb, var(--nimi-text-muted) 55%, transparent);}
191
+ .studio-decision__value{ font-family: var(--nimi-font-mono); font-size: 12px; text-align: right;}
192
+ .studio-decision__bar--selected{ color: var(--nimi-text-primary); font-weight: 600;}
193
+ .studio-decision__bar--selected .studio-decision__fill{ background: var(--nimi-action-primary-bg);}
194
+ .studio-turn__request{ border: 1px solid var(--nimi-border-subtle); border-radius: var(--nimi-radius-lg); background: color-mix(in srgb, var(--nimi-surface-card) 72%, transparent);}
159
195
  .studio-diag{ position: relative; min-width: 0; max-width: 100%; border-top: 1px solid var(--nimi-border-subtle); padding: 12px 16px 14px;}
160
196
  .studio-diag > summary{ display: inline-flex; max-width: calc(100% - 64px); align-items: center; gap: 5px; cursor: pointer; list-style: none; color: var(--nimi-text-secondary); font-size: 12px; font-weight: var(--nimi-type-page-title-weight); vertical-align: middle;}
161
197
  .studio-diag > summary::-webkit-details-marker{ display: none;}
@@ -258,6 +294,7 @@
258
294
  .studio-recent__rows li:hover .studio-recent__row-delete,
259
295
  .studio-recent__rows li:focus-within .studio-recent__row-delete{ opacity: 1;}
260
296
  .studio-recent__row-delete:hover{ background: var(--nimi-surface-active); color: var(--nimi-text-primary);}
297
+ .studio-recent__row-delete--document{ right: 32px;}
261
298
  .studio-recent__icon--media{ overflow: hidden; border-radius: var(--nimi-radius-sm);}
262
299
  .studio-recent__icon--media img{ display: block; width: 22px; height: 22px; object-fit: cover;}
263
300
  /* The history filter popover styles live in the portal-scoped block at the end
@@ -0,0 +1,24 @@
1
+ import type { StudioAudioSeparationRequest } from './runtime-types.js';
2
+
3
+ export function isAudioSeparationRequest(value: unknown): value is StudioAudioSeparationRequest {
4
+ if (!value || typeof value !== 'object' || Array.isArray(value)) return false;
5
+ const request = value as Record<string, unknown>;
6
+ if (request.kind === 'full-source') return Object.keys(request).length === 1;
7
+ return request.kind === 'range'
8
+ && Object.keys(request).every(key => ['kind', 'startSeconds', 'endSeconds'].includes(key))
9
+ && typeof request.startSeconds === 'number' && Number.isFinite(request.startSeconds) && request.startSeconds >= 0
10
+ && (request.endSeconds === undefined || (typeof request.endSeconds === 'number'
11
+ && Number.isFinite(request.endSeconds) && request.endSeconds > request.startSeconds));
12
+ }
13
+
14
+ /** Only a saved submission, never the current composer or output duration. */
15
+ export function audioSeparationRequestFromParameters(
16
+ parameters?: Readonly<Record<string, unknown>>,
17
+ ): StudioAudioSeparationRequest | undefined {
18
+ if (!parameters || typeof parameters.sourceRelativePath !== 'string' || !parameters.sourceRelativePath.trim()
19
+ || parameters.recoverySubmissionId !== undefined) return undefined;
20
+ if (parameters.startSeconds === undefined && parameters.endSeconds === undefined) return { kind: 'full-source' };
21
+ const request = { kind: 'range', startSeconds: parameters.startSeconds === undefined ? 0 : parameters.startSeconds,
22
+ ...(parameters.endSeconds === undefined ? {} : { endSeconds: parameters.endSeconds }) };
23
+ return isAudioSeparationRequest(request) ? request : undefined;
24
+ }
@@ -1,6 +1,8 @@
1
1
  import { createContext } from 'react';
2
2
 
3
3
  import type { StudioParameterState, StudioParameterValue } from './parameters.js';
4
+ import type { StudioCapabilityRunResult } from './runtime-types.js';
5
+ import type { StudioRunConfigSnapshot, StudioRunHistoryRecord } from './history.js';
4
6
 
5
7
  export type StudioHistoryPanelScope = 'capability' | 'all' | 'media';
6
8
 
@@ -40,6 +42,8 @@ export type StudioHistoryActions = {
40
42
  };
41
43
 
42
44
  export const StudioHistoryActionsContext = createContext<StudioHistoryActions | null>(null);
45
+ export const StudioHistoryResultContext = createContext<((result: StudioCapabilityRunResult, prompt: string,
46
+ runConfig?: StudioRunConfigSnapshot) => Promise<StudioRunHistoryRecord>) | null>(null);
43
47
 
44
48
  export type StudioHistoryPanelState = {
45
49
  readonly collapsed: boolean;