@nimiplatform/app-tools 0.4.0 → 0.5.1

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
@@ -224,8 +224,10 @@ pnpm dlx --package @nimiplatform/app-tools nimi-app --help
224
224
  ## Portable App information (package v2)
225
225
 
226
226
  A distribution package includes `app-info.json`, containing its actual icon,
227
- summary, usage guide, version notes, license and portable requirements. Fill in
228
- `nimi.app.yaml` before running a production check or build:
227
+ summary, available usage guide and version notes, license and portable requirements.
228
+ Every `pack`, including development-mode packaging and non-release CI, requires
229
+ valid App information. Complete `nimi.app.yaml` and its resources before packing;
230
+ production check/build validates them before the build starts:
229
231
 
230
232
  ```yaml
231
233
  metadata:
@@ -261,8 +263,10 @@ explicit license identifier; it does not turn a private license into an
261
263
  open-source Registry license. Name and summary allow 120 and 280 characters.
262
264
  Scaffold `sync` preserves these author-edited metadata, requirement and storage
263
265
  fields while continuing to check the managed identity and carrier fields.
264
- Incomplete development projects remain usable; production preflight reports
265
- missing resources before invoking the build.
266
+ The scaffold does not supply finished artwork. Add the declared icon, a summary
267
+ and license information; provide any declared documents or omit optional document
268
+ paths for local/private packages. Until then, package-producing CI will fail.
269
+ Incomplete projects remain editable with `dev` and ordinary non-production builds.
266
270
 
267
271
  Pack writes `nimi.app-package/v2` and emits the exact embedded information bytes
268
272
  as `<app_id>-<version>-<target_id>.app-info.json` next to the `.nimiapp` and
@@ -276,6 +280,20 @@ declares the tested public SDK, Kit and Tauri shell versions used by new Apps an
276
280
  explicit `sync`; workspace development version bumps do not change those ranges.
277
281
  The release workflow requires those public versions before publishing App Tools.
278
282
 
283
+ App Tools 0.5.1 uses SDK `^0.11.0` and Kit `^0.7.0`. Existing Apps upgrade explicitly:
284
+
285
+ ```bash
286
+ pnpm add -D @nimiplatform/app-tools@^0.5.1
287
+ pnpm run sync
288
+ pnpm install
289
+ pnpm run check
290
+ pnpm run test
291
+ pnpm run app:build -- --target windows-x86_64
292
+ ```
293
+
294
+ Use the App's declared target for the final build. `sync` preserves App-owned
295
+ product code; update any affected SDK/Kit API usage in that code before release.
296
+
279
297
  The v2 Runtime rejects v1 packages. Existing immutable publisher Releases and
280
298
  approved descriptors must not be edited to invent the missing asset. Prepare a
281
299
  new App version and real target builds, publish new immutable assets, and follow
@@ -345,6 +345,7 @@ function buildForbiddenPatterns() {
345
345
  ];
346
346
  }
347
347
 
348
+ // @nimi-authority: rule.nimi.platform.app-ecosystem.p-scaf-016b
348
349
  function scanForbiddenPatterns(targetDir, profile, selectedLabels = null) {
349
350
  const findings = [];
350
351
  const patterns = buildForbiddenPatterns();
@@ -366,12 +367,15 @@ function scanForbiddenPatterns(targetDir, profile, selectedLabels = null) {
366
367
  const text = readFileSync(filePath, 'utf8');
367
368
  const isManagedReleaseWorkflow = relativePath === '.github/workflows/nimi-app-release.yml'
368
369
  && text.replaceAll('\r\n', '\n') === managedAppReleaseWorkflowSource();
369
- const isTestFile = relativePath.startsWith('test/') || /(?:^|\/)\w[^/]*\.(?:test|spec)\.[cm]?[jt]sx?$/i.test(relativePath);
370
+ const isTestFile = /^(?:test|tests)\//.test(relativePath) || /(?:^|\/)\w[^/]*\.(?:test|spec)\.[cm]?[jt]sx?$/i.test(relativePath);
371
+ const isAgentSkillReference = /^(?:\.agents|\.claude)\/skills\//.test(relativePath);
370
372
  for (const [label, pattern] of patterns) {
371
373
  if (selectedLabels && !selectedLabels.has(label)) {
372
374
  continue;
373
375
  }
374
- if (selectedLabels && isTestFile) {
376
+ // Existing repositories may vendor agent skills and their example code.
377
+ // Those examples and test fixtures are not the App's protected callers.
378
+ if (selectedLabels && (isTestFile || isAgentSkillReference)) {
375
379
  continue;
376
380
  }
377
381
  // Test files reference provider/model names to assert behavior (including
@@ -609,13 +613,14 @@ function validateExistingSubmittedApp(targetDir) {
609
613
  export function initApp(cwd, options = {}, versions, runners = {}) {
610
614
  const targetDir = resolveTargetDir(cwd, options);
611
615
  const intent = readIntent(targetDir);
616
+ const currentManifest = readCurrentAppManifest(targetDir);
612
617
  const snapshot = buildAppScaffoldSnapshotFromIntent({ intent, versions, targetDir });
613
618
  if (!runners?.runNimicodingSync) {
614
619
  throw new Error('Missing nimicoding sync runner');
615
620
  }
616
621
  const nimicoding = runners.runNimicodingSync(targetDir, 'apply');
617
622
  for (const file of snapshot.initFiles) {
618
- writeScaffoldFile(targetDir, file);
623
+ writeScaffoldFile(targetDir, file, currentManifest);
619
624
  }
620
625
  validateAppProjectState(targetDir, versions, runners);
621
626
  const payload = {
@@ -703,14 +708,25 @@ function assertNoClassificationConflict(lock, snapshot) {
703
708
  }
704
709
  }
705
710
 
706
- function writeScaffoldFile(targetDir, file) {
711
+ function readCurrentAppManifest(targetDir) {
712
+ const manifestPath = path.join(targetDir, 'nimi.app.yaml');
713
+ if (!existsSync(manifestPath)) return undefined;
714
+ let manifest;
715
+ try { manifest = parseYaml(readFileSync(manifestPath, 'utf8')); }
716
+ catch (error) { throw new Error(`nimi.app.yaml is invalid: ${error.message}`, { cause: error }); }
717
+ if (!manifest || typeof manifest !== 'object' || Array.isArray(manifest)) {
718
+ throw new Error('nimi.app.yaml must contain an App declaration mapping before init or sync');
719
+ }
720
+ return manifest;
721
+ }
722
+
723
+ function writeScaffoldFile(targetDir, file, currentManifest) {
707
724
  const targetPath = path.join(targetDir, file.path);
708
725
  mkdirSync(path.dirname(targetPath), { recursive: true });
709
- if (file.path === 'nimi.app.yaml' && existsSync(targetPath)) {
710
- const current = parseYaml(readFileSync(targetPath, 'utf8'));
726
+ if (file.path === 'nimi.app.yaml' && currentManifest) {
711
727
  const next = parseYaml(file.content);
712
728
  for (const field of APP_AUTHOR_DECLARATION_FIELDS) {
713
- if (Object.hasOwn(current, field)) next[field] = current[field];
729
+ if (Object.hasOwn(currentManifest, field)) next[field] = currentManifest[field];
714
730
  }
715
731
  writeFileSync(targetPath, stringifyYaml(next, { lineWidth: 0 }));
716
732
  return;
@@ -722,6 +738,7 @@ export function syncManagedApp(cwd, options = {}, versions, runners = {}) {
722
738
  const targetDir = resolveTargetDir(cwd, options);
723
739
  const lock = readLock(targetDir);
724
740
  const intent = readIntent(targetDir);
741
+ const currentManifest = readCurrentAppManifest(targetDir);
725
742
  const packageJson = readJsonFile(path.join(targetDir, 'package.json'), 'package.json');
726
743
  const versionedIntent = {
727
744
  ...intent,
@@ -743,7 +760,7 @@ export function syncManagedApp(cwd, options = {}, versions, runners = {}) {
743
760
  if (!managedEntry) {
744
761
  continue;
745
762
  }
746
- writeScaffoldFile(targetDir, file);
763
+ writeScaffoldFile(targetDir, file, currentManifest);
747
764
  }
748
765
  writeScaffoldFile(targetDir, {
749
766
  path: SCAFFOLD_LOCK_PATH,
package/lib/app-info.mjs CHANGED
@@ -71,7 +71,8 @@ function storage(value) {
71
71
  function https(value, field) {
72
72
  if (value === undefined || value === '') return '';
73
73
  text(value, field, 2048);
74
- const url = new URL(value);
74
+ let url;
75
+ try { url = new URL(value); } catch { throw new Error(`App info ${field} must be a valid HTTPS URL without credentials`); }
75
76
  if (url.protocol !== 'https:' || !url.hostname || url.username || url.password) throw new Error(`App info ${field} must be HTTPS without credentials`);
76
77
  return value;
77
78
  }
@@ -105,9 +106,15 @@ function resource(root, relative, label, maxBytes) {
105
106
  if (typeof relative !== 'string' || path.isAbsolute(relative) || relative.includes('\\')
106
107
  || relative.split('/').some((part) => !part || part === '.' || part === '..')) throw new Error(`metadata.${label} must name an App-relative resource`);
107
108
  const file = path.join(root, relative);
108
- const stat = lstatSync(file);
109
- if (!stat.isFile() || stat.isSymbolicLink() || stat.size === 0 || stat.size > maxBytes) throw new Error(`metadata.${label} is missing, not a regular file, or exceeds its size limit`);
110
- return readFileSync(file);
109
+ const field = label === 'license' ? 'App license' : `metadata.${label}`;
110
+ try {
111
+ const stat = lstatSync(file);
112
+ if (!stat.isFile() || stat.isSymbolicLink() || stat.size === 0 || stat.size > maxBytes) throw new Error(`must be a nonempty regular file of at most ${maxBytes} bytes`);
113
+ return readFileSync(file);
114
+ } catch (error) {
115
+ if (error?.code === 'ENOENT' || error?.code === 'ENOTDIR') throw new Error(`${field} resource is missing: ${relative}`);
116
+ throw new Error(`${field} resource ${relative}: ${error.message}`, { cause: error });
117
+ }
111
118
  }
112
119
 
113
120
  export function readAppInfo(root, targetId) {
package/lib/app-pack.mjs CHANGED
@@ -536,7 +536,9 @@ export function aggregateAppTargetCandidates(cwd, options = {}) {
536
536
  const entries = readNimiAppArchive(bytes);
537
537
  const infoAsset = target.app_info;
538
538
  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}`);
539
- const infoBytes = readFileSync(path.join(outputDir, infoAsset.asset_name));
539
+ const infoPath = path.join(outputDir, infoAsset.asset_name);
540
+ if (!existsSync(infoPath)) throw new Error(`Target App info asset is missing: ${infoAsset.asset_name}`);
541
+ const infoBytes = readFileSync(infoPath);
540
542
  if (infoBytes.length !== infoAsset.size || createHash('sha256').update(infoBytes).digest('hex') !== infoAsset.sha256 || !entries.get('app-info.json')?.bytes.equals(infoBytes)) throw new Error(`Target App info changed or differs from archive: ${target.target_id}`);
541
543
  const info = validateAppInfo(JSON.parse(infoBytes));
542
544
  if (info.app_id !== appId || info.version !== version || info.target_id !== target.target_id) throw new Error(`Target App info identity differs: ${target.target_id}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nimiplatform/app-tools",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
4
4
  "description": "Public app-authoring CLI for Nimi App projects.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -18,11 +18,11 @@
18
18
  "provenance": true
19
19
  },
20
20
  "nimiScaffoldVersions": {
21
- "sdkVersion": "^0.10.0",
22
- "appToolsVersion": "^0.4.0",
21
+ "sdkVersion": "^0.11.0",
22
+ "appToolsVersion": "^0.5.1",
23
23
  "nimicodingVersion": "0.6.2",
24
24
  "aiSdkVersion": "^6.0.85",
25
- "kitVersion": "^0.6.0",
25
+ "kitVersion": "^0.7.0",
26
26
  "reactVersion": "^19.2.8",
27
27
  "reactDomVersion": "^19.2.8",
28
28
  "i18nextVersion": "^25.10.10",