@nimiplatform/app-tools 0.12.1 → 0.12.3

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 CHANGED
@@ -117,9 +117,11 @@ rejected rather than normalized. A matrix range in the manifest does not
117
117
  require an automatic upgrade; install with the frozen lockfile until
118
118
  deliberately selecting and synchronizing a new component combination.
119
119
 
120
- The production Beta candidate guide uses App Tools 0.12.0 with SDK `^0.21.0`,
121
- Kit/native `^0.19.0`, the matching production Runtime, and Tauri `0.10.0` when
122
- selected. Existing D2 projects retain their declared `^0.18.1` Kit combination. Fresh scaffold
120
+ The production Beta candidate guide uses App Tools 0.12.3 with SDK `^0.21.0`,
121
+ Kit/native `^0.20.0`, the matching production Runtime, and Tauri `0.10.0` when
122
+ selected. Existing production `^0.19.0` and D2 `^0.18.1` projects retain their
123
+ declared Kit combination. Before explicitly upgrading to Kit 0.20, follow the
124
+ [Realtime and conversation setup migration notes](../kit/CHANGELOG.md). Fresh scaffold
123
125
  defaults still come from `nimiScaffoldVersions` in `package.json`; explicitly
124
126
  select the current SDK/Kit pair to use this guide. On an initialized App, run
125
127
  `nimi-app sync`, install the resulting dependencies, then run `nimi-app check`
@@ -170,7 +172,7 @@ Local archives may also use paths relative to the App. Install, run sync and
170
172
  check, then use the normal dev/test/build/pack loop. Sync retains these choices;
171
173
  check verifies matrix compatibility and compares the selected tarball version,
172
174
  source and integrity with pnpm's installed dependency lock and package manifest.
173
- The default SDK `^0.21.0` / Kit `^0.18.1` / Rust carrier `0.10.0`
175
+ The default SDK `^0.21.0` / Kit `^0.20.0` / Rust carrier `0.10.0`
174
176
  combination also admits complete local archives for development. Select the
175
177
  matching Runtime and native packages. A local archive does not establish public
176
178
  registry availability; production preflight checks the registry resolutions.
@@ -499,8 +501,10 @@ A distribution package includes `app-info.json`, containing its actual icon,
499
501
  summary, available usage guide and version notes, license, portable requirements
500
502
  and, when declared, the publisher safety declaration from `nimi.app.yaml`
501
503
  `safety_profile` (see the lifecycle skill's safety-declaration reference). An
502
- undeclared `safety_profile` stays absent and blocks nothing locally; new public
503
- Registry admission requires the complete declaration.
504
+ undeclared `safety_profile` stays absent and blocks nothing locally. The
505
+ Registry's current admission policy determines whether a public submission
506
+ requires the complete declaration; App Tools does not fetch that policy during
507
+ local checks.
504
508
  Every `pack`, including development-mode packaging and non-release CI, requires
505
509
  valid App information. Complete `nimi.app.yaml` and its resources before packing;
506
510
  production check/build validates them before the build starts:
@@ -9,6 +9,7 @@ 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.19.0', nimiShellTauriVersion: '0.10.0', source: 'existing' }),
12
13
  Object.freeze({ sdkVersion: '^0.21.0', kitVersion: '^0.18.1', nimiShellTauriVersion: '0.10.0', source: 'existing' }),
13
14
  Object.freeze({ sdkVersion: '^0.21.0', kitVersion: '^0.18.0', nimiShellTauriVersion: '0.10.0', source: 'existing' }),
14
15
  Object.freeze({ sdkVersion: '^0.20.0', kitVersion: '^0.17.0', nimiShellTauriVersion: '0.9.0', source: 'existing' }),
package/lib/app-pack.mjs CHANGED
@@ -9,6 +9,11 @@
9
9
  import { createHash } from 'node:crypto';
10
10
  import {
11
11
  existsSync,
12
+ openSync,
13
+ closeSync,
14
+ fstatSync,
15
+ readSync,
16
+ writeSync,
12
17
  lstatSync,
13
18
  mkdirSync,
14
19
  readFileSync,
@@ -51,6 +56,43 @@ function canonicalJson(value) {
51
56
  return `${JSON.stringify(sortedValue(value), null, 2)}\n`;
52
57
  }
53
58
 
59
+ export function hashAppArchive(bytes) {
60
+ const hash = createHash('sha256');
61
+ // Node's native crypto update accepts at most an int32-sized input even
62
+ // though a valid ZIP32 App archive can exceed 2 GiB.
63
+ const chunkBytes = 64 * 1024 * 1024;
64
+ for (let offset = 0; offset < bytes.length; offset += chunkBytes) {
65
+ hash.update(bytes.subarray(offset, offset + chunkBytes));
66
+ }
67
+ return hash.digest('hex');
68
+ }
69
+
70
+ export function writeAppArchiveFile(filePath, bytes) {
71
+ const fd = openSync(filePath, 'w');
72
+ try {
73
+ let offset = 0;
74
+ while (offset < bytes.length) {
75
+ const written = writeSync(fd, bytes, offset, Math.min(64 * 1024 * 1024, bytes.length - offset));
76
+ if (written <= 0) throw new Error('App archive write did not make progress');
77
+ offset += written;
78
+ }
79
+ } finally { closeSync(fd); }
80
+ }
81
+
82
+ export function readAppArchiveFile(filePath) {
83
+ const fd = openSync(filePath, 'r');
84
+ try {
85
+ const bytes = Buffer.allocUnsafe(fstatSync(fd).size);
86
+ let offset = 0;
87
+ while (offset < bytes.length) {
88
+ const read = readSync(fd, bytes, offset, Math.min(64 * 1024 * 1024, bytes.length - offset), null);
89
+ if (read <= 0) throw new Error('App archive ended before its recorded size');
90
+ offset += read;
91
+ }
92
+ return bytes;
93
+ } finally { closeSync(fd); }
94
+ }
95
+
54
96
  function sameCanonicalValue(left, right) {
55
97
  return JSON.stringify(sortedValue(left)) === JSON.stringify(sortedValue(right));
56
98
  }
@@ -114,7 +156,7 @@ function collectPayload(payloadPath, os) {
114
156
  const stat = lstatSync(payloadPath);
115
157
  if (stat.isSymbolicLink()) throw new Error('Pack payload must not contain symbolic links');
116
158
  if (stat.isFile()) {
117
- return [{ relative: path.basename(payloadPath), bytes: readFileSync(payloadPath), mode: stat.mode & 0o111 ? 0o755 : 0o644 }];
159
+ return [{ relative: path.basename(payloadPath), bytes: readAppArchiveFile(payloadPath), mode: stat.mode & 0o111 ? 0o755 : 0o644 }];
118
160
  }
119
161
  if (!stat.isDirectory()) throw new Error('Pack payload must be a regular file or directory');
120
162
  const entries = [];
@@ -129,7 +171,7 @@ function collectPayload(payloadPath, os) {
129
171
  } else if (entryStat.isDirectory()) {
130
172
  walk(absolute, relative);
131
173
  } else if (entryStat.isFile()) {
132
- entries.push({ relative, bytes: readFileSync(absolute), mode: entryStat.mode & 0o111 ? 0o755 : 0o644 });
174
+ entries.push({ relative, bytes: readAppArchiveFile(absolute), mode: entryStat.mode & 0o111 ? 0o755 : 0o644 });
133
175
  } else {
134
176
  throw new Error(`Unsupported pack payload entry: ${relative}`);
135
177
  }
@@ -478,14 +520,14 @@ export function packAppTarget(cwd, options = {}) {
478
520
  { name: 'app-info.json', bytes: infoBytes, mode: 0o644 },
479
521
  ...payloadEntries,
480
522
  ]);
481
- const sha256 = createHash('sha256').update(archive).digest('hex');
523
+ const sha256 = hashAppArchive(archive);
482
524
  const outputDir = path.join(targetDir, OUTPUT_DIR);
483
525
  mkdirSync(outputDir, { recursive: true });
484
526
  const stem = `${input.appId}-${input.version}-${input.targetId}`;
485
527
  const artifactPath = path.join(outputDir, `${stem}.nimiapp`);
486
528
  const metadataPath = path.join(outputDir, `${stem}.target.json`);
487
529
  const appInfoPath = path.join(outputDir, `${stem}.app-info.json`);
488
- writeFileSync(artifactPath, archive);
530
+ writeAppArchiveFile(artifactPath, archive);
489
531
  writeFileSync(appInfoPath, infoBytes);
490
532
  const metadata = {
491
533
  format: TARGET_METADATA_FORMAT,
@@ -535,8 +577,8 @@ export function aggregateAppTargetCandidates(cwd, options = {}) {
535
577
  validateNativeExecutionFacts(target.native_trust, target.execution_profile, metadataLabel, target.os);
536
578
  const artifactPath = path.join(outputDir, assetName);
537
579
  if (!existsSync(artifactPath)) throw new Error(`Target artifact is missing: ${target.asset_name}`);
538
- const bytes = readFileSync(artifactPath);
539
- if (bytes.length !== target.size || createHash('sha256').update(bytes).digest('hex') !== target.sha256) throw new Error(`Target artifact changed after pack: ${target.asset_name}`);
580
+ const bytes = readAppArchiveFile(artifactPath);
581
+ if (bytes.length !== target.size || hashAppArchive(bytes) !== target.sha256) throw new Error(`Target artifact changed after pack: ${target.asset_name}`);
540
582
  const entries = readNimiAppArchive(bytes);
541
583
  const infoAsset = target.app_info;
542
584
  if (infoAsset?.asset_name !== `${appId}-${version}-${target.target_id}.app-info.json` || !Number.isSafeInteger(infoAsset.size) || infoAsset.size <= 0 || infoAsset.size > APP_INFO_MAX_BYTES) throw new Error(`Target App info reference is invalid: ${target.target_id}`);
@@ -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 and private packages remain usable, while new public Registry admission requires the declaration.\n');
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nimiplatform/app-tools",
3
- "version": "0.12.1",
3
+ "version": "0.12.3",
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.12.1",
22
+ "appToolsVersion": "^0.12.3",
23
23
  "nimicodingVersion": "0.6.5",
24
24
  "aiSdkVersion": "^6.0.85",
25
- "kitVersion": "^0.19.0",
25
+ "kitVersion": "^0.20.0",
26
26
  "reactVersion": "^19.3.0",
27
27
  "reactDomVersion": "^19.3.0",
28
28
  "i18nextVersion": "^26.4.2",
@@ -55,7 +55,8 @@
55
55
  "prepack": "pnpm run build",
56
56
  "prepublishOnly": "pnpm run build",
57
57
  "test": "node ../scripts/with-workspace-surfaces.mjs -- pnpm run test:prepared",
58
- "test:prepared": "node scripts/sync-scaffold-versions.mjs --check && node --test test/dev-shell.test.mjs && node --test test/app-dependency-combinations.test.mjs test/app-safety-profile.test.mjs test/app-project-lifecycle.test.mjs test/app-pack.test.mjs test/app-scaffold.test.mjs"
58
+ "test:large-archive": "node --test test/app-pack-large.test.mjs",
59
+ "test:prepared": "node scripts/sync-scaffold-versions.mjs --check && node --test test/dev-shell.test.mjs && node --test test/app-dependency-combinations.test.mjs test/app-safety-profile.test.mjs test/app-project-lifecycle.test.mjs test/app-pack.test.mjs test/app-pack-large.test.mjs test/app-scaffold.test.mjs"
59
60
  },
60
61
  "files": [
61
62
  "bin",
@@ -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. New public Registry admission requires the complete declaration, so declare it before preparing a public submission.
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