@nimiplatform/app-tools 0.5.1 → 0.5.2

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/lib/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
1
+ import { existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, statSync, writeFileSync } from 'node:fs';
2
2
  import { spawnSync } from 'node:child_process';
3
3
  import path from 'node:path';
4
4
  import {
@@ -12,9 +12,11 @@ import {
12
12
  import { initApp } from './app-doctor-update.mjs';
13
13
  import {
14
14
  buildAppProject,
15
+ adoptAppProject,
15
16
  checkAppProject,
16
17
  syncAppProject,
17
18
  testAppProject,
19
+ validateAppInitialization,
18
20
  } from './app-project-lifecycle.mjs';
19
21
  import { aggregateAppTargetCandidates, packAppTarget } from './app-pack.mjs';
20
22
  export { runDevShell } from '../scripts/dev-shell.mjs';
@@ -68,13 +70,25 @@ function runNimicodingSync(targetDir, mode) {
68
70
  if (!['apply', 'check'].includes(mode)) {
69
71
  throw new Error(`Unsupported nimicoding sync mode: ${mode}`);
70
72
  }
73
+ const packagePath = path.join(targetDir, 'node_modules', '@nimiplatform', 'nimi-coding', 'package.json');
74
+ const expectedVersion = SCAFFOLD_VERSIONS.nimicodingVersion;
75
+ let installed;
76
+ try { installed = JSON.parse(readFileSync(packagePath, 'utf8')); }
77
+ catch { throw new Error(`Install project-local @nimiplatform/nimi-coding@${expectedVersion} before nimi-app ${mode === 'apply' ? 'init/sync' : 'check'}.`); }
78
+ if (installed.name !== '@nimiplatform/nimi-coding' || installed.version !== expectedVersion) {
79
+ throw new Error(`Project-local @nimiplatform/nimi-coding must be ${expectedVersion}, found ${installed.version || 'unknown'}. Install the target app-tools/nimi-coding combination before applying projections.`);
80
+ }
81
+ let entry;
82
+ try {
83
+ const packageRoot = realpathSync(path.dirname(packagePath));
84
+ if (typeof installed.bin?.nimicoding !== 'string' || !installed.bin.nimicoding) throw new Error('Missing bin.nimicoding');
85
+ entry = realpathSync(path.resolve(packageRoot, installed.bin.nimicoding));
86
+ if (!entry.startsWith(`${packageRoot}${path.sep}`) || !statSync(entry).isFile()) throw new Error('Invalid bin.nimicoding');
87
+ } catch (cause) {
88
+ throw new Error(`Project-local @nimiplatform/nimi-coding@${expectedVersion} must declare an existing nimicoding entry inside its package. Reinstall the selected package before init/sync/check.`, { cause });
89
+ }
71
90
  const flag = mode === 'apply' ? '--apply' : '--check';
72
- const pnpmArgs = ['--silent', 'exec', 'nimicoding', 'sync', flag, '--json'];
73
- const command =
74
- process.platform === 'win32'
75
- ? { binary: 'cmd.exe', args: ['/d', '/c', 'corepack', 'pnpm', ...pnpmArgs] }
76
- : { binary: 'corepack', args: ['pnpm', ...pnpmArgs] };
77
- const result = spawnSync(command.binary, command.args, {
91
+ const result = spawnSync(process.execPath, [entry, 'sync', flag, '--json'], {
78
92
  cwd: targetDir,
79
93
  encoding: 'utf8',
80
94
  });
@@ -180,6 +194,8 @@ function resolveCreateTopology() {
180
194
  }
181
195
 
182
196
  export function initAppScaffold(cwd, options = {}) {
197
+ if (options.adopt) return adoptAppProject(cwd, options, appScaffoldVersions(), appToolRunners());
198
+ validateAppInitialization(path.resolve(cwd, options.dir || '.'), appScaffoldVersions());
183
199
  return initApp(cwd, options, appScaffoldVersions(), appToolRunners());
184
200
  }
185
201
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nimiplatform/app-tools",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
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.11.0",
22
- "appToolsVersion": "^0.5.1",
23
- "nimicodingVersion": "0.6.2",
21
+ "sdkVersion": "^0.12.0",
22
+ "appToolsVersion": "^0.5.2",
23
+ "nimicodingVersion": "0.6.3",
24
24
  "aiSdkVersion": "^6.0.85",
25
- "kitVersion": "^0.7.0",
25
+ "kitVersion": "^0.8.0",
26
26
  "reactVersion": "^19.2.8",
27
27
  "reactDomVersion": "^19.2.8",
28
28
  "i18nextVersion": "^25.10.10",
@@ -38,7 +38,7 @@
38
38
  "tailwindcssViteVersion": "^4.3.3",
39
39
  "tauriCliVersion": "^2.11.4",
40
40
  "yamlVersion": "^2.9.0",
41
- "nimiShellTauriVersion": "0.2.1",
41
+ "nimiShellTauriVersion": "0.4.0",
42
42
  "electronPackagerVersion": "^20.3.0",
43
43
  "electronVersion": "^42.10.1",
44
44
  "esbuildVersion": "^0.28.2",
@@ -65,6 +65,7 @@
65
65
  "lib",
66
66
  "scripts",
67
67
  "templates",
68
+ "skills",
68
69
  "README.md"
69
70
  ],
70
71
  "dependencies": {
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: nimi-app-lifecycle
3
+ description: Create, adapt, maintain and prepare releases of Nimi App repositories with app-tools and the standard SDK/Kit carrier. Use for App development, not for carrying out the App's own creative or research tasks.
4
+ ---
5
+
6
+ # Nimi App lifecycle
7
+
8
+ Start with the repository's package manifest, actual product entry and nearest instructions. Preserve the user's current product scope and stage. Read only the scenario needed now:
9
+
10
+ | Task | Guide |
11
+ | --- | --- |
12
+ | Create a new App | [Create](references/create.md) |
13
+ | Adapt an existing project | [Adapt](references/adapt.md) |
14
+ | Upgrade app-tools, SDK or Kit | [Platform upgrade](references/upgrade-platform.md) |
15
+ | Bring in upstream changes | [Upstream sync](references/sync-upstream.md) |
16
+ | Prepare a Release or Registry submission | [Release](references/release.md) |
17
+ | Verify real App behavior or installation | [Acceptance](references/acceptance.md) |
18
+
19
+ For an ordinary product edit, follow its existing code and tests. Do not reinitialize or run the entire release journey unless affected inputs or behavior require it.
20
+
21
+ ## Boundaries that matter
22
+
23
+ - App-owned workflows, tool handlers, business accounts, non-AI services and product presentation stay with the App. Nimi AI, configuration, managed storage and protected sessions use public SDK/Kit Local App surfaces. Display identity is not a business login ticket.
24
+ - The current authoring recipe uses pnpm, Vite and Desktop-supervised Electron. A Next/server or Python project needs real App-owned carrier/build work before adoption. Preserve the original user tasks; do not silently reduce the product to a scaffold example.
25
+ - Read the selected app-tools package's `nimiScaffoldVersions` and the SDK/Kit migration notes. Public Apps use published registry dependencies. Private platform experiments are not public installation evidence.
26
+ - App Tools maintains its fixed lifecycle skill, AGENTS block and declared engineering projections. Existing Apps have no fresh scaffold intent/lock. Preserve their Host, product source and license; report unknown file collisions rather than inventing ownership.
27
+ - GitHub owns publisher builds and Releases; Registry owns candidate validation and human admission; Runtime owns packages and App access; Desktop owns exact processes. These are separate facts. The external AI host owns the development task.
28
+ - Continue authorized work through verification. Missing prerequisites pause dependent steps only. Never infer publication or human approval from a passing command. Mark relevant unrun product paths NOT-VERIFIED.
29
+
30
+ The package's README and `nimi-app --help` expose this same guide before init. Explicit init/sync projects it into the App; dependency installation does not activate repository instructions.
@@ -0,0 +1,15 @@
1
+ # App acceptance
2
+
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
+
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.
6
+
7
+ Verify the real output the user needs: a cited research result, a correctly indexed document, or a playable/exported media artifact. Check cancellation, reconnect or account change when that behavior is affected. Tests and mocks can establish a contract; they cannot replace actual AI or App acceptance.
8
+
9
+ For a declared release target, verify Catalog discovery/download/install, exact Host launch, current Access, real business use and uninstall on an ordinary machine without the source workspace or development runtimes. Local-package import proves only that separate source path. Keep missing external services visible.
10
+
11
+ With two separately admitted versions, verify N to N+1 and the promised data retention. Reuse existing Runtime failure tests for preservation of the old package; if a normal real failure is observed, retry the same N/N+1 after confirming N remains available. Do not manufacture N+2, a downgrade path or a new fault-injection service.
12
+
13
+ Runtime uninstall removes its exact managed package after Desktop stops the Host. App-owned OS storage remains untouched, including disclosed paths; explain the App's own cleanup action separately. Ordinary repair and arbitrary rollback remain outside this workflow.
14
+
15
+ Report the tested App/version, target and result, plus relevant NOT-VERIFIED paths. Tool-core checks, a representative App slice, first release/install and a later update are separate completion levels. Keep necessary local output under `.nimi/local/`; do not create another task or proof ledger.
@@ -0,0 +1,19 @@
1
+ # Existing project
2
+
3
+ Before changing code, identify the upstream URL and baseline commit, license, user journeys, actual AI/auth/storage entry points, business services, helper processes and active instruction loaders. Record a short upstream/range note in the existing App README or product document; do not create another integration state file.
4
+
5
+ Install a selected published app-tools package and read this package skill before init. Install its matching SDK/Kit and exact nimi-coding. Prepare actual App-owned pnpm/Vite/Electron Host, renderer and test/production-build commands; do not make init manufacture a test success or convert a server deployment implicitly.
6
+
7
+ Use `pnpm exec nimi-app init --adopt --dry-run --json`, then apply without `--dry-run` once the changes fit the authorized scope. Existing nimi.app.yaml and `.nimi/config/build-profile.yaml` are the inputs. If either is absent, supply `--input <json-path>` with only `manifest` and/or `build_profile`, using their existing schemas from the app-tools README. A file under `.nimi/local/` is sufficient. Input supplied alongside an existing file must agree with it. Target paths are declarations at init; build/pack later verify real artifacts.
8
+
9
+ 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.
10
+
11
+ ## Map only the capabilities the product uses
12
+
13
+ - Renderer code can use `createNimiClient` with Kit's `createNimiLocalAppStandardShellSurface`. Node business work uses `registerNimiElectronAppBridge(...).services` from the same protected Host, fixed app commands and session invalidation callbacks. Consult the installed SDK/Kit public types for exact inputs.
14
+ - Keep the App's tool loop, IDs, ordered tool results and any opaque continuity needed in subsequent turns. An SDK model step does not run business callbacks.
15
+ - Preserve Runtime-issued embedding space across batches; do not combine incompatible results. Carry cancellation and session invalidation into outstanding work and prevent late writes to a new session.
16
+ - Local media helpers receive bounded business inputs and an explicit environment; they do not receive Nimi credentials or a generic protected forwarding endpoint.
17
+ - Non-AI services, such as search engines, stay App-owned with honest setup requirements. Do not turn all external HTTP into an AI bypass finding.
18
+
19
+ Separate development instructions from product-operation guides, including other host entry files actually used by the repository. Upstream supplier examples may remain as knowledge; check the active product/agent route instead of deleting by keyword. Keep unimplemented original workflows explicit rather than counting a visible menu or retained source as completion.
@@ -0,0 +1,7 @@
1
+ # New project
2
+
3
+ Use `nimi-app create` with an App ID, title and the admitted features the user's task needs. `--features all` means the tool's admitted catalog, not all Nimi Lab code. `nimi-app --help` lists the actual options and capability names.
4
+
5
+ After creation: install dependencies, run `pnpm exec nimi-app init`, then sync/check. Init can be previewed with `--dry-run --json`. The lifecycle skill becomes project-local at init; create's package content can already be read for guidance.
6
+
7
+ Build App-owned routes and workflows on the generated carrier. Preserve the selected App identity and direct feature selection. Use existing package test/build commands and exercise the affected real App task through the official launcher. Placeholder artwork or an empty feature list does not make a release-ready product: complete the App's portable information before production packaging.
@@ -0,0 +1,15 @@
1
+ # Release and Registry
2
+
3
+ Before production, 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.
4
+
5
+ Read the app-tools README's publisher setup for protected version tags, Release immutability and the GitHub repository-settings read credential. Check real settings when publication is in scope. Keep App package/manifest versions equal and the annotated `v<version>` tag on a commit in the actual canonical default-branch history. Publish only with the user's existing authorization; fixing a local check does not authorize a new release.
6
+
7
+ The managed tag workflow owns production tests, target artifacts, attestations and immutable Release execution. Manual dispatch is a development build. Reuse its final Release/asset verification; a code change needs a new version, not a moved tag. Do not add local publish or another App production workflow.
8
+
9
+ For catalog admission, use the Registry owner's `scripts/prepare-submission.mjs` with the exact repository/tag and its documented App-owned inputs. Read the Registry README before using this script and confirm it exists in the selected Registry revision. It prepares only `{schema_version:1,candidate}` from actual release facts. Do not copy admission or review fields from an approved descriptor. Candidate validation and base-owned PR transition checks differ from `pnpm check`, which validates the Registry main tree.
10
+
11
+ An external publisher submits from its own fork; an authorized publisher sharing the Registry namespace can use a same-repository branch. Use one publisher-owned branch/PR for the exact version and release, including retries. Human maintainers own admission; the agent must not invent their decision. Registry main stores metadata, while bytes remain with the publisher Release.
12
+
13
+ Real matching unsigned or unnotarized posture is not automatically a blocker. Do not require KYC, non-null SBOM or purchased signing as a generic prerequisite. State proof strength according to what the existing verifier actually checks.
14
+
15
+ First publication and admission can precede installed acceptance. Verify first Catalog installation and business use afterward. Test an update only once a second, higher version is separately admitted; a future N+1 is not a prerequisite for the first release.
@@ -0,0 +1,7 @@
1
+ # Upstream changes
2
+
3
+ Read the fork's recorded upstream baseline, actual remotes and the requested target commit. If no target was selected, choose a justified upstream revision from the current task and show what it changes. Keep the downstream product mainline as its real GitHub canonical default; its name need not be `nimi`.
4
+
5
+ Fetch the needed upstream history without automatically importing release tags. Review code, dependency, license, CI and instruction-entry changes together. Merge into the working flow required by the repository; do not routinely rebase shared published history, force-push, add a permanent mirror branch or resolve every conflict with one side.
6
+
7
+ Check affected AI provider initialization, accounts, storage, tooling and agent routing for old paths reintroduced by the merge. Remap new business capabilities through their actual owner. Preserve the original product task, then update the recorded upstream SHA and rerun only affected checks and journeys. App release versions remain independent of upstream tags and component versions.
@@ -0,0 +1,11 @@
1
+ # Platform upgrade
2
+
3
+ Read the current and selected target app-tools version matrix plus SDK/Kit migration notes. A source checkout or private tarball may support experimentation; a public App release must be reproducible from the published combination.
4
+
5
+ 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.
6
+
7
+ Review App-owned instructions outside managed blocks when the upgrade changes an ownership boundary or command. Correct obsolete routing against the current owner; adding another conflicting paragraph is not a migration of those instructions.
8
+
9
+ 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
+
11
+ 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.
@@ -202,6 +202,8 @@ async function* streamLocalAppTextEvents(
202
202
  let started = false;
203
203
  let textItemOpened = false;
204
204
  for await (const event of subscription) {
205
+ // This one-turn text surface has no follow-up turn to carry opaque state into.
206
+ if (event.type === 'reasoning-continuity') continue;
205
207
  if (!started) {
206
208
  started = true;
207
209
  yield {
@@ -225,6 +227,11 @@ async function* streamLocalAppTextEvents(
225
227
  actionHint: event.actionHint,
226
228
  });
227
229
  }
230
+ if (event.type === 'tool-call' || event.finishReason === 'tool-calls') {
231
+ throw Object.assign(new Error('The text-only Studio request received undeclared tool output.'), {
232
+ reasonCode: 'SDK_AI_RUNTIME_OUTPUT_INVALID',
233
+ });
234
+ }
228
235
  if (textItemOpened) {
229
236
  yield localTextCompletionDeltaEvent(event);
230
237
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  ## Scope
4
4
  - Treat `.nimi/app-scaffold/{intent,lock}.json` as app-scaffold intent and lock state.
5
- - Treat `.nimi/{config,contracts,methodology}/**` as `@nimiplatform/nimi-coding` managed projections created by `pnpm run init`.
5
+ - App Tools maintains its identity/contract projections and the declared engineering fields in `.nimi/config` and `.nimi/admission`; the build profile and product declarations retain their App-owned inputs. Nimi-coding maintains its own methodology and AGENTS block through its declared sync command.
6
6
  - Keep auth, Runtime, App Access declaration, manifest, and Tauri shell glue in scaffold-managed files.
7
7
  - App-owned product code is `src/workbench-core/**`, selected `src/capabilities/**`, `src/shell/routes/product-area.tsx`, and App-authored product screens, state, tests, styles, and bounded native helpers.
8
8
  - Scaffold-managed code is the carrier/auth wiring, identity, manifests, project tooling, bounded native integration, and `src/scaffold/generated/**` composition glue.
@@ -28,6 +28,7 @@
28
28
  - Read platform authority only when ownership or semantics remain ambiguous; skip unrelated platform packages and generated files.
29
29
 
30
30
  ## Verification Commands
31
- - After `pnpm install` and `pnpm run init`, run `pnpm run sync`, `pnpm run check`, the directly affected tests, and the affected build.
31
+ - Initial setup: after `pnpm install` and `pnpm run init`, run `pnpm run sync`, `pnpm run check`, the directly affected tests, and the affected build.
32
+ - In an initialized project, app-owned changes use the directly affected tests and build. Rerun sync/check when scaffold inputs, managed glue, or dependencies change, and before packaging; do not repeat initialization for ordinary product edits.
32
33
  - Run the official Desktop-supervised App journey when product interaction is in scope; shell or native checks alone do not replace it.
33
34
  - Mark every product path not actually run as `NOT-VERIFIED`. Help text, focused tests, and CDP visibility do not establish implementation or release acceptance.