@nimiplatform/app-tools 0.2.7 → 0.2.8

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
@@ -68,6 +68,15 @@ pnpm dev
68
68
 
69
69
  `dev` uses the Desktop supervisor. Direct Electron, Tauri or renderer launch cannot claim protected Nimi access. Process running and Nimi Access ready remain separate states.
70
70
 
71
+ To continue an existing development App and its data, select a registration explicitly:
72
+
73
+ ```bash
74
+ pnpm dev -- --list-registrations
75
+ pnpm dev -- --resume <selector>
76
+ ```
77
+
78
+ The list shows the current project's registrations and creation times. Copy the desired selector from that list; Desktop resolves it to the exact existing Runtime-owned registration. Selectors last for the current Desktop session, so list again after restarting Desktop. No selector is stored in the App repository, and no App ID or path automatically reopens a subject. Plain `pnpm dev` keeps its fresh-registration behavior when no matching run is active. These options require a Desktop build that supports explicit launcher selection.
79
+
71
80
  The default `windows-x86_64` build profile runs `build:electron:production`. It rebuilds the renderer and Electron main/preload, then creates a fresh, non-installer `dist-electron-package/<app>-shell-win32-x64/` directory with `asar` disabled and an App-specific `<app>-shell.exe`. The production main bundle has a compile-time production marker and rejects every `--nimi-dev-renderer-url` argument; packaged renderer assets stay relative under `dist/`. The protected native binding is resolved from Kit's optional dependency and is never declared directly by the App.
72
81
 
73
82
  Tauri remains an explicit alternative through `pnpm run build:tauri:production`; selecting it requires an explicit Tauri build profile rather than changing the default Electron carrier.
package/bin/nimi-app.mjs CHANGED
@@ -21,7 +21,7 @@ function parseArgs(argv) {
21
21
  const [command = '', ...rest] = argv;
22
22
  const values = {
23
23
  dir: '', profile: '', appId: '', version: '', title: '', packageName: '', author: '',
24
- features: undefined, shell: '', cdpPort: undefined, noCdp: false, conformance: '', target: '', aggregate: false, production: false, json: false,
24
+ features: undefined, shell: '', cdpPort: undefined, noCdp: false, listRegistrations: false, resume: '', conformance: '', target: '', aggregate: false, production: false, json: false,
25
25
  };
26
26
  const seen = new Set();
27
27
  const readValue = (index, flag, key, preserve = false) => {
@@ -80,6 +80,16 @@ function parseArgs(argv) {
80
80
  index = readValue(index, '--cdp-port', 'cdpPort');
81
81
  continue;
82
82
  }
83
+ if (rest[index] === '--resume') {
84
+ index = readValue(index, '--resume', 'resume', true);
85
+ continue;
86
+ }
87
+ if (rest[index] === '--list-registrations') {
88
+ if (seen.has('listRegistrations')) throw new Error('Duplicate option: --list-registrations');
89
+ seen.add('listRegistrations');
90
+ values.listRegistrations = true;
91
+ continue;
92
+ }
83
93
  if (rest[index] === '--no-cdp') {
84
94
  if (seen.has('noCdp')) throw new Error('Duplicate option: --no-cdp');
85
95
  seen.add('noCdp');
@@ -127,7 +137,7 @@ function assertCommandOptions(command, providedOptions) {
127
137
  init: new Set(['dir', 'json']),
128
138
  sync: new Set(['dir', 'json']),
129
139
  check: new Set(['dir', 'json', 'conformance', 'production']),
130
- dev: new Set(['dir', 'shell', 'cdpPort', 'noCdp']),
140
+ dev: new Set(['dir', 'shell', 'cdpPort', 'noCdp', 'listRegistrations', 'resume']),
131
141
  test: new Set(['dir', 'json']),
132
142
  build: new Set(['dir', 'target', 'production', 'json']),
133
143
  pack: new Set(['dir', 'target', 'aggregate', 'production', 'json']),
@@ -158,7 +168,7 @@ function printUsage() {
158
168
  ' nimi-app init [--dir path] [--json]',
159
169
  ' nimi-app sync [--dir path] [--json]',
160
170
  ' nimi-app check [--dir path] [--conformance simulator | --production] [--json]',
161
- ' nimi-app dev [--dir path] [--shell electron] [--cdp-port 1024..65535 | --no-cdp]',
171
+ ' nimi-app dev [--dir path] [--shell electron] [--list-registrations | --resume <selector>] [--cdp-port 1024..65535 | --no-cdp]',
162
172
  ' nimi-app test [--dir path] [--json]',
163
173
  ' nimi-app build [--dir path] [--target target-id] [--production] [--json]',
164
174
  ' nimi-app pack [--dir path] (--target target-id [--production] | --aggregate) [--json]',
@@ -285,6 +295,8 @@ try {
285
295
  shell,
286
296
  cdpPort,
287
297
  noCdp,
298
+ listRegistrations,
299
+ resume,
288
300
  conformance,
289
301
  target,
290
302
  aggregate,
@@ -375,6 +387,8 @@ try {
375
387
  shell: shell || 'electron',
376
388
  cdpPort,
377
389
  noCdp,
390
+ listRegistrations,
391
+ resume,
378
392
  });
379
393
  break;
380
394
  default:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nimiplatform/app-tools",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
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.9.0",
22
- "appToolsVersion": "^0.2.7",
21
+ "sdkVersion": "^0.9.1",
22
+ "appToolsVersion": "^0.2.8",
23
23
  "nimicodingVersion": "0.6.1",
24
24
  "aiSdkVersion": "^6.0.85",
25
- "kitVersion": "^0.5.0",
25
+ "kitVersion": "^0.5.1",
26
26
  "reactVersion": "^19.2.8",
27
27
  "reactDomVersion": "^19.2.8",
28
28
  "i18nextVersion": "^25.10.10",
@@ -10,6 +10,7 @@ import { parse as parseYaml } from 'yaml';
10
10
  const DESCRIPTOR_RELATIVE_PATH = ['.nimi', 'run', 'desktop', 'local-development', 'presence.v1.json'];
11
11
  const MAX_HEARTBEAT_AGE_MS = 10_000;
12
12
  const REQUEST_TIMEOUT_MS = 5_000;
13
+ const INTENT_REQUEST_TIMEOUT_MS = 30_000;
13
14
  const STATUS_POLL_MS = 350;
14
15
  const AUTO_CDP_PORT = 0;
15
16
  const CDP_PORT_ENV_KEY = 'NIMI_APP_DEV_CDP_PORT';
@@ -22,11 +23,16 @@ const TERMINAL_STATES = new Set([
22
23
  'stopped',
23
24
  ]);
24
25
 
26
+ // @nimi-authority: rule.nimi.platform.app-ecosystem.p-scaf-018a
25
27
  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.resume && !/^dev-project-[A-Za-z0-9_-]{1,148}$/u.test(options.resume)) {
30
+ throw new DevShellError('local-development-selector-invalid', '--resume requires a current-host selector from --list-registrations.');
31
+ }
26
32
  const shell = normalizeShell(options.shell || 'electron');
27
33
  assertLocalDevelopmentPlatform(process.platform, shell);
28
34
  const projectRoot = await canonicalProjectRoot(cwd, options.dir);
29
- const cdpPort = await resolveRequestedCdpPort(projectRoot, options);
35
+ const cdpPort = options.listRegistrations ? undefined : await resolveRequestedCdpPort(projectRoot, options);
30
36
  const appId = await readAppId(projectRoot);
31
37
  const descriptorPath = options.descriptorPath
32
38
  ? path.resolve(options.descriptorPath)
@@ -36,6 +42,26 @@ export async function runDevShell(cwd, options = {}) {
36
42
  if (typeof fetchImpl !== 'function') {
37
43
  throw new DevShellError('local-development-launcher-unavailable', 'This Node.js runtime does not provide fetch.');
38
44
  }
45
+ if (options.listRegistrations) {
46
+ const listed = await postJson(fetchImpl, descriptor.endpoint, '/v1/registrations', {
47
+ schemaVersion: 1, appId, projectRoot, shell,
48
+ });
49
+ if (listed?.status !== 'ok' || !Array.isArray(listed.registrations)) {
50
+ throw new DevShellError(listed?.reasonCode || 'local-development-intent-invalid', 'Desktop could not list current-host registrations.');
51
+ }
52
+ const output = options.output ?? process.stdout;
53
+ for (const row of listed.registrations) {
54
+ if (typeof row.selector !== 'string' || !/^dev-project-[A-Za-z0-9_-]{1,148}$/u.test(row.selector)
55
+ || typeof row.displayName !== 'string' || !Number.isSafeInteger(row.registeredAtUnixMs)) {
56
+ throw new DevShellError('local-development-intent-invalid', 'Desktop returned an invalid registration projection.');
57
+ }
58
+ output.write(`${row.selector}\t${new Date(row.registeredAtUnixMs).toISOString()}\t${row.displayName}\n`);
59
+ }
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
+ }
39
65
 
40
66
  const startIntent = {
41
67
  schemaVersion: 1,
@@ -43,6 +69,7 @@ export async function runDevShell(cwd, options = {}) {
43
69
  projectRoot,
44
70
  shell,
45
71
  ...(cdpPort === undefined ? {} : { cdpPort }),
72
+ ...(options.resume ? { registrationSelector: options.resume } : {}),
46
73
  };
47
74
  const start = await postJson(fetchImpl, descriptor.endpoint, '/v1/start', startIntent);
48
75
  const initial = parseBridgeRun(start);
@@ -213,7 +240,8 @@ async function postJson(fetchImpl, endpoint, route, body) {
213
240
  headers: { 'Content-Type': 'application/json' },
214
241
  body: JSON.stringify(body),
215
242
  redirect: 'error',
216
- signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
243
+ signal: AbortSignal.timeout(route === '/v1/start' || route === '/v1/registrations'
244
+ ? INTENT_REQUEST_TIMEOUT_MS : REQUEST_TIMEOUT_MS),
217
245
  });
218
246
  } catch {
219
247
  throw new DevShellError(