@nimiplatform/app-tools 0.6.3 → 0.11.4

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 (115) hide show
  1. package/README.md +153 -12
  2. package/bin/nimi-app.mjs +16 -14
  3. package/lib/app-access-declaration.mjs +1 -0
  4. package/lib/app-dependency-combinations.mjs +49 -0
  5. package/lib/app-doctor-update.mjs +84 -23
  6. package/lib/app-info.mjs +33 -3
  7. package/lib/app-lifecycle-guidance.mjs +4 -2
  8. package/lib/app-pack.mjs +5 -2
  9. package/lib/app-project-lifecycle.mjs +284 -53
  10. package/lib/app-safety-profile.mjs +204 -0
  11. package/lib/app-scaffold-capabilities.mjs +11 -3
  12. package/lib/app-scaffold-profiles.mjs +136 -27
  13. package/lib/app-scaffold.mjs +55 -7
  14. package/lib/canonical-capability-ids.generated.mjs +25 -0
  15. package/lib/index.mjs +0 -4
  16. package/package.json +27 -31
  17. package/scripts/dev-shell.mjs +80 -18
  18. package/skills/nimi-app-lifecycle/SKILL.md +7 -3
  19. package/skills/nimi-app-lifecycle/references/acceptance.md +7 -1
  20. package/skills/nimi-app-lifecycle/references/adapt.md +46 -1
  21. package/skills/nimi-app-lifecycle/references/audit.md +55 -0
  22. package/skills/nimi-app-lifecycle/references/platform-gaps.md +15 -0
  23. package/skills/nimi-app-lifecycle/references/release.md +2 -2
  24. package/skills/nimi-app-lifecycle/references/safety-declaration.md +37 -0
  25. package/skills/nimi-app-lifecycle/references/upgrade-platform.md +16 -2
  26. package/templates/app-source/src/ai-studio-core/ai-config.ts +17 -3
  27. package/templates/app-source/src/ai-studio-core/ai-studio-core.css +40 -3
  28. package/templates/app-source/src/ai-studio-core/audio-separation-request.ts +24 -0
  29. package/templates/app-source/src/ai-studio-core/contexts.tsx +4 -0
  30. package/templates/app-source/src/ai-studio-core/history-policy.ts +395 -41
  31. package/templates/app-source/src/ai-studio-core/history.ts +262 -10
  32. package/templates/app-source/src/ai-studio-core/host-context.tsx +15 -2
  33. package/templates/app-source/src/ai-studio-core/index.ts +15 -4
  34. package/templates/app-source/src/ai-studio-core/job-recovery-panel.tsx +105 -0
  35. package/templates/app-source/src/ai-studio-core/job-recovery.ts +224 -0
  36. package/templates/app-source/src/ai-studio-core/managed-result-references.ts +79 -0
  37. package/templates/app-source/src/ai-studio-core/messages/en.json +185 -10
  38. package/templates/app-source/src/ai-studio-core/messages/zh.json +185 -10
  39. package/templates/app-source/src/ai-studio-core/module-registration.ts +9 -1
  40. package/templates/app-source/src/ai-studio-core/non-success-presentation.ts +81 -2
  41. package/templates/app-source/src/ai-studio-core/parameters.ts +34 -1
  42. package/templates/app-source/src/ai-studio-core/runtime-types.ts +124 -8
  43. package/templates/app-source/src/ai-studio-core/runtime.ts +218 -20
  44. package/templates/app-source/src/ai-studio-core/section-ai-testing-annotation-result.tsx +123 -0
  45. package/templates/app-source/src/ai-studio-core/section-ai-testing-artifact-preview.ts +3 -0
  46. package/templates/app-source/src/ai-studio-core/section-ai-testing-audio-separation-result.tsx +26 -0
  47. package/templates/app-source/src/ai-studio-core/section-ai-testing-composer.tsx +14 -7
  48. package/templates/app-source/src/ai-studio-core/section-ai-testing-decision-result.tsx +76 -0
  49. package/templates/app-source/src/ai-studio-core/section-ai-testing-exchange-result.tsx +71 -0
  50. package/templates/app-source/src/ai-studio-core/section-ai-testing-history.tsx +20 -4
  51. package/templates/app-source/src/ai-studio-core/section-ai-testing-input.ts +29 -0
  52. package/templates/app-source/src/ai-studio-core/section-ai-testing-music-result.tsx +45 -0
  53. package/templates/app-source/src/ai-studio-core/section-ai-testing-output.tsx +132 -10
  54. package/templates/app-source/src/ai-studio-core/section-ai-testing-result.tsx +122 -38
  55. package/templates/app-source/src/ai-studio-core/section-ai-testing-run.ts +4 -3
  56. package/templates/app-source/src/ai-studio-core/section-ai-testing-session-result.tsx +66 -0
  57. package/templates/app-source/src/ai-studio-core/section-ai-testing-studio-result.tsx +100 -22
  58. package/templates/app-source/src/ai-studio-core/section-ai-testing-surface.tsx +6 -0
  59. package/templates/app-source/src/ai-studio-core/section-ai-testing-transcript-result.tsx +45 -0
  60. package/templates/app-source/src/ai-studio-core/section-ai-testing-transcription-result.tsx +106 -0
  61. package/templates/app-source/src/ai-studio-core/section-ai-testing-vision-result.tsx +23 -4
  62. package/templates/app-source/src/ai-studio-core/section-ai-testing-voice-asset-actions.tsx +40 -0
  63. package/templates/app-source/src/ai-studio-core/section-ai-testing-voice-conversion-result.tsx +20 -0
  64. package/templates/app-source/src/ai-studio-core/section-ai-testing.tsx +219 -35
  65. package/templates/app-source/src/ai-studio-core/text-annotation-document.ts +50 -0
  66. package/templates/app-source/src/ai-studio-core/text-media-replay.ts +51 -0
  67. package/templates/app-source/src/ai-studio-core/voice-assets.ts +17 -0
  68. package/templates/app-source/src/ai-studio-core/workspace.tsx +48 -6
  69. package/templates/app-source/src/studio-modules/studio-create/descriptors.ts +1 -1
  70. package/templates/app-source/src/studio-modules/studio-create/messages/en.json +13 -1
  71. package/templates/app-source/src/studio-modules/studio-create/messages/zh.json +13 -1
  72. package/templates/app-source/src/studio-modules/studio-create/parameter-panel.tsx +11 -2
  73. package/templates/app-source/src/studio-modules/studio-create/parameters.ts +2 -2
  74. package/templates/app-source/src/studio-modules/studio-create/registration.ts +2 -2
  75. package/templates/app-source/src/studio-modules/studio-create/runtime.ts +121 -3
  76. package/templates/app-source/src/studio-modules/studio-media/audio-separate-parameters.tsx +72 -0
  77. package/templates/app-source/src/studio-modules/studio-media/audio-separate-runtime.ts +90 -0
  78. package/templates/app-source/src/studio-modules/studio-media/descriptors.ts +16 -1
  79. package/templates/app-source/src/studio-modules/studio-media/index.ts +2 -0
  80. package/templates/app-source/src/studio-modules/studio-media/messages/en.json +225 -7
  81. package/templates/app-source/src/studio-modules/studio-media/messages/zh.json +225 -7
  82. package/templates/app-source/src/studio-modules/studio-media/music-parameters.tsx +85 -0
  83. package/templates/app-source/src/studio-modules/studio-media/music-transcription-parameters.tsx +85 -0
  84. package/templates/app-source/src/studio-modules/studio-media/music-transcription-runtime.ts +64 -0
  85. package/templates/app-source/src/studio-modules/studio-media/parameter-panel.tsx +9 -26
  86. package/templates/app-source/src/studio-modules/studio-media/parameters.ts +170 -6
  87. package/templates/app-source/src/studio-modules/studio-media/registration.ts +29 -1
  88. package/templates/app-source/src/studio-modules/studio-media/runtime.ts +90 -6
  89. package/templates/app-source/src/studio-modules/studio-media/vision-parameters.tsx +1 -0
  90. package/templates/app-source/src/studio-modules/studio-media/vision-runtime.ts +23 -5
  91. package/templates/app-source/src/studio-modules/studio-media/voice-convert-parameters.tsx +132 -0
  92. package/templates/app-source/src/studio-modules/studio-media/voice-convert-runtime.ts +120 -0
  93. package/templates/app-source/src/studio-modules/studio-voice/audio-url.ts +25 -0
  94. package/templates/app-source/src/studio-modules/studio-voice/messages/en.json +4 -4
  95. package/templates/app-source/src/studio-modules/studio-voice/messages/zh.json +4 -4
  96. package/templates/app-source/src/studio-modules/studio-voice/parameters.ts +36 -10
  97. package/templates/app-source/src/studio-modules/studio-voice/runtime.ts +66 -30
  98. package/templates/app-source/src/workbench-core/index.ts +2 -0
  99. package/templates/app-source/src/workbench-core/runtime-gate.tsx +102 -6
  100. package/templates/app-source/src/workbench-core/workbench-core.css +42 -0
  101. package/templates/app-source/src/workbench-core/workbench-core.tsx +69 -18
  102. package/templates/app-source.manifest.json +100 -0
  103. package/templates/default-starter/AGENTS.md +4 -2
  104. package/templates/default-starter/README.md +2 -1
  105. package/templates/default-starter/src/shell/workbench-target-adapter.ts +102 -12
  106. package/templates/default-starter.manifest.json +0 -4
  107. package/lib/simulator-conformance-ast.mjs +0 -498
  108. package/lib/simulator-conformance-css.mjs +0 -116
  109. package/lib/simulator-conformance-graph.mjs +0 -757
  110. package/lib/simulator-conformance.d.mts +0 -14
  111. package/lib/simulator-conformance.mjs +0 -203
  112. package/lib/simulator-css-profile.d.mts +0 -27
  113. package/lib/simulator-css-profile.mjs +0 -531
  114. package/lib/simulator-kit-export-resolution.mjs +0 -70
  115. package/lib/simulator-manifest.mjs +0 -334
package/lib/app-info.mjs CHANGED
@@ -1,11 +1,22 @@
1
1
  // @nimi-authority: rule.nimi.platform.app-ecosystem.p-napp-042a
2
+ // @nimi-authority: rule.nimi.platform.app-ecosystem.p-napp-043a
2
3
  import { existsSync, lstatSync, readFileSync } from 'node:fs';
3
4
  import path from 'node:path';
4
5
  import { PNG } from 'pngjs';
5
6
  import { parse as parseYaml } from 'yaml';
6
7
  import { normalizeAppAccessItems } from './app-access-declaration.mjs';
8
+ import { CANONICAL_CAPABILITY_IDS } from './canonical-capability-ids.generated.mjs';
9
+ import { SAFETY_PROFILE_FIELD, normalizeSafetyProfile } from './app-safety-profile.mjs';
7
10
 
8
11
  export const APP_INFO_MAX_BYTES = 1024 * 1024;
12
+ export const APP_INFO_FIELDS = Object.freeze([
13
+ 'format', 'app_id', 'version', 'target_id', 'display_name', 'summary', 'icon', 'readme_markdown', 'release_notes_markdown',
14
+ 'license', 'app_access', 'capability_contract_refs', 'required_standardized_feature_refs', 'storage_policy', 'author',
15
+ 'homepage_url', 'support_url', SAFETY_PROFILE_FIELD,
16
+ ]);
17
+ // Declaration fields that App Tools projects from nimi.app.yaml into the
18
+ // archive declaration and that Registry compares against the candidate.
19
+ export const APP_INFO_DECLARATION_FIELDS = Object.freeze(['app_id', 'display_name', 'version', 'app_access', 'capability_contract_refs', 'required_standardized_feature_refs', 'storage_policy', SAFETY_PROFILE_FIELD]);
9
20
  const PNG_SIGNATURE = Buffer.from('89504e470d0a1a0a', 'hex');
10
21
 
11
22
  function text(value, label, max, multiline = false) {
@@ -21,7 +32,13 @@ function refs(value, label) {
21
32
  if (!Array.isArray(value) || new Set(value).size !== value.length) {
22
33
  throw new Error(`App info ${label} must be an explicit unique list (empty is allowed)`);
23
34
  }
24
- return value.map((item) => text(item, label, 200));
35
+ const entries = value.map((item) => text(item, label, 200));
36
+ if (label === 'capability_contract_refs') {
37
+ for (const entry of entries) {
38
+ if (!CANONICAL_CAPABILITY_IDS.includes(entry)) throw new Error(`App info ${label} contains unknown CapabilityContract: ${entry}`);
39
+ }
40
+ }
41
+ return entries;
25
42
  }
26
43
 
27
44
  export function validateAppIcon(bytes) {
@@ -77,8 +94,19 @@ function https(value, field) {
77
94
  return value;
78
95
  }
79
96
 
97
+ // A declared safety_profile must already be canonical (tool-serialized); an
98
+ // absent field means undeclared and is never filled in.
99
+ function safetyProfile(value, label) {
100
+ if (value === undefined) return undefined;
101
+ const normalized = normalizeSafetyProfile(value);
102
+ if (JSON.stringify(normalized) !== JSON.stringify(value)) throw new Error(`${label} safety_profile is not canonical; run nimi-app sync to project the declaration`);
103
+ return normalized;
104
+ }
105
+
80
106
  export function validateAppInfo(info) {
81
- if (!info || info.format !== 'nimi.app-info/v1') throw new Error('Unsupported App info format');
107
+ if (!info || typeof info !== 'object' || Array.isArray(info)) throw new Error('Unsupported App info format');
108
+ for (const key of Object.keys(info)) if (!APP_INFO_FIELDS.includes(key)) throw new Error(`App info contains unsupported field: ${key}`);
109
+ if (info.format !== 'nimi.app-info/v1') throw new Error('Unsupported App info format');
82
110
  for (const key of ['app_id', 'version', 'target_id']) text(info[key], key, 200);
83
111
  text(info.display_name, 'display_name', 120);
84
112
  text(info.summary, 'summary', 280);
@@ -98,6 +126,7 @@ export function validateAppInfo(info) {
98
126
  if (info.author) text(info.author, 'author', 200);
99
127
  https(info.homepage_url, 'homepage_url');
100
128
  https(info.support_url, 'support_url');
129
+ safetyProfile(info[SAFETY_PROFILE_FIELD], 'App info');
101
130
  if (Buffer.byteLength(JSON.stringify(info)) > APP_INFO_MAX_BYTES) throw new Error('App info exceeds 1 MiB');
102
131
  return info;
103
132
  }
@@ -136,11 +165,12 @@ export function readAppInfo(root, targetId) {
136
165
  required_standardized_feature_refs: refs(manifest.required_standardized_feature_refs, 'required_standardized_feature_refs'),
137
166
  storage_policy: storage(manifest.storage_policy),
138
167
  author: metadata.author || '', homepage_url: https(metadata.homepage_url, 'homepage_url'), support_url: https(metadata.support_url, 'support_url'),
168
+ ...(manifest[SAFETY_PROFILE_FIELD] === undefined ? {} : { [SAFETY_PROFILE_FIELD]: normalizeSafetyProfile(manifest[SAFETY_PROFILE_FIELD]) }),
139
169
  });
140
170
  const submissionPath = path.join(root, '.nimi/admission/submission.yaml');
141
171
  if (existsSync(submissionPath)) {
142
172
  const submission = parseYaml(readFileSync(submissionPath, 'utf8'));
143
- for (const field of ['app_id', 'version', 'display_name', 'capability_contract_refs', 'required_standardized_feature_refs']) {
173
+ for (const field of ['app_id', 'version', 'display_name', 'capability_contract_refs', 'required_standardized_feature_refs', SAFETY_PROFILE_FIELD]) {
144
174
  if (JSON.stringify(info[field]) !== JSON.stringify(submission[field])) throw new Error(`App info differs from submission ${field}; run nimi-app sync to project the declaration`);
145
175
  }
146
176
  if (JSON.stringify(storage(submission.storage_policy)) !== JSON.stringify(info.storage_policy)) throw new Error('App info differs from submission storage_policy; run nimi-app sync to project the declaration');
@@ -5,14 +5,16 @@ import { assertProjectOutputPath, changedFiles, plannedFile } from './app-projec
5
5
 
6
6
  export const LIFECYCLE_SKILL_PATH = fileURLToPath(new URL('../skills/nimi-app-lifecycle/SKILL.md', import.meta.url));
7
7
  export const PROJECT_SKILL_DIR = '.agents/skills/nimi-app-lifecycle';
8
- const SKILL_FILES = ['SKILL.md', ...['create', 'adapt', 'upgrade-platform', 'sync-upstream', 'release', 'acceptance'].map((name) => `references/${name}.md`)];
8
+ const SKILL_FILES = ['SKILL.md', ...['audit', 'create', 'adapt', 'platform-gaps', 'upgrade-platform', 'sync-upstream', 'safety-declaration', 'release', 'acceptance'].map((name) => `references/${name}.md`)];
9
9
  const START = '<!-- nimi-app:managed:start -->';
10
10
  const END = '<!-- nimi-app:managed:end -->';
11
11
  const AGENTS_BLOCK = `${START}
12
12
  ## Nimi App development
13
13
 
14
- - For creating, adapting, upgrading or releasing this App, read [the lifecycle skill](.agents/skills/nimi-app-lifecycle/SKILL.md) and only the relevant scenario.
14
+ - For auditing adaptation feasibility or cost, creating, adapting, upgrading or releasing this App, read [the lifecycle skill](.agents/skills/nimi-app-lifecycle/SKILL.md) and only the relevant scenario. Audit-only requests do not begin implementation; prior reports remain evidence-dependent.
15
+ - For first integration or foundation wiring changes, use the selected app-tools package's generated reference and reuse its Host, preload, renderer, session, App Access, AIConfig and AI call wiring. Follow the adaptation guide's baseline checks and reuse passing results for ordinary business edits.
15
16
  - Keep App-owned product behavior, Host code, business accounts and non-AI services with this repository. Use the SDK/Kit Local App carrier for Nimi AI, configuration, storage and session access.
17
+ - Development may consume complete local npm tarballs through the supported explicit overrides and version matrix; public-release preflight uses registry resolutions. Do not substitute source-workspace or directory links.
16
18
  - App Tools owns its lifecycle skill, this block, managed workflow and declared engineering fields; preserve other instructions, product source and licenses. Existing adoption does not create fresh scaffold intent or lock.
17
19
  - Product-operation guides apply to their specific business tasks; they do not replace the Nimi development boundary.
18
20
  - Reuse the user's confirmed scope and authorization. Report command checks separately from actual App journeys; unrun relevant paths remain NOT-VERIFIED.
package/lib/app-pack.mjs CHANGED
@@ -4,6 +4,7 @@
4
4
  // @nimi-authority: rule.nimi.platform.app-ecosystem.p-napp-024a
5
5
  // @nimi-authority: rule.nimi.platform.app-ecosystem.p-napp-024b
6
6
  // @nimi-authority: rule.nimi.platform.app-ecosystem.p-napp-034a
7
+ // @nimi-authority: rule.nimi.platform.app-ecosystem.p-napp-043a
7
8
 
8
9
  import { createHash } from 'node:crypto';
9
10
  import {
@@ -17,7 +18,7 @@ import {
17
18
  } from 'node:fs';
18
19
  import path from 'node:path';
19
20
  import { parse as parseYaml, stringify as stringifyYaml } from 'yaml';
20
- import { APP_INFO_MAX_BYTES, readAppInfo, validateAppInfo } from './app-info.mjs';
21
+ import { APP_INFO_DECLARATION_FIELDS, APP_INFO_MAX_BYTES, readAppInfo, validateAppInfo } from './app-info.mjs';
21
22
  import { observeWindowsExecutableFacts } from './windows-powershell.mjs';
22
23
  import { SYMBOLIC_LINK_MODE, validatePayloadLinks } from './payload-links.mjs';
23
24
  import { observeMacOSExecutableFacts } from './macos-native.mjs';
@@ -467,7 +468,9 @@ export function packAppTarget(cwd, options = {}) {
467
468
  };
468
469
  const infoBytes = Buffer.from(canonicalJson(input.appInfo));
469
470
  if (infoBytes.length > APP_INFO_MAX_BYTES) throw new Error('App info exceeds 1 MiB');
470
- const declaration = Object.fromEntries(['app_id', 'display_name', 'version', 'app_access', 'capability_contract_refs', 'required_standardized_feature_refs', 'storage_policy'].map((key) => [key, input.appInfo[key]]));
471
+ // An undeclared safety_profile stays absent from the declaration copy; it is
472
+ // never serialized as an empty or default declaration.
473
+ const declaration = Object.fromEntries(APP_INFO_DECLARATION_FIELDS.filter((key) => input.appInfo[key] !== undefined).map((key) => [key, input.appInfo[key]]));
471
474
  const archive = writeNimiAppArchive([
472
475
  { name: 'LICENSE', bytes: readFileSync(input.licensePath), mode: 0o644 },
473
476
  { name: 'manifest.json', bytes: canonicalJson(packageManifest), mode: 0o644 },