@nimiplatform/app-tools 0.2.8 → 0.2.9

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
@@ -34,7 +34,7 @@ node app-tools/bin/nimi-app.mjs --help
34
34
 
35
35
  ## Create
36
36
 
37
- Interactive use validates every field, shows the resolved plan and asks for confirmation. The optional `author` names one person or team. Non-interactive use supplies the same inputs directly:
37
+ Interactive use validates every field, shows the resolved plan and asks for confirmation. The optional `author` names one person or team; include `--author` when creating a Windows release project because the standard packager uses it for executable metadata. Non-interactive use supplies the same inputs directly:
38
38
 
39
39
  ```bash
40
40
  node app-tools/bin/nimi-app.mjs create \
@@ -83,9 +83,9 @@ Tauri remains an explicit alternative through `pnpm run build:tauri:production`;
83
83
 
84
84
  ## Canonical release boundary
85
85
 
86
- The production chain is singular. Its publisher GitHub Release stage is
87
- available for explicitly configured pilot repositories; later registry and
88
- installed lifecycle stages remain unavailable:
86
+ The publisher GitHub Release stage is available for configured repositories.
87
+ Registry review, Runtime installation, and Desktop launch are separate owner
88
+ stages:
89
89
 
90
90
  ```text
91
91
  public App repository
@@ -101,7 +101,95 @@ public App repository
101
101
 
102
102
  The registry references publisher Release assets and never mirrors bytes. GitHub Release is not catalog admission; catalog admission is not installed; installed is not running; running is not Nimi Access ready.
103
103
 
104
- Repository administration must enable a protected `v*` tag ruleset and GitHub immutable releases before production. The managed tag workflow fetches the repository's canonical default branch and rejects a tag commit outside that history before production preflight, build, attestation, or Release. A fine-grained `NIMI_REPOSITORY_ADMIN_TOKEN` secret with repository Administration read permission lets the workflow verify protected-tag and immutable-release settings; it cannot enable or change them. Manual workflow dispatch runs only the non-production build/package path. On Windows, the tag-only production build invokes the App-declared production build with no certificate-secret mapping or app-tools-owned signing step. Optional native signing remains publisher-owned and must already be reflected in the final exact Runtime entry before production pack observes and records its native-trust posture; a present invalid or unresolved signature still fails closed. A successful tag workflow creates the immutable publisher GitHub Release and no registry, installed, running, or Nimi Access truth. Registry submission, the shared installed carrier, and installed launch remain unavailable.
104
+ Repository administration must enable a protected `v*` tag ruleset and GitHub immutable releases before production. The managed tag workflow fetches the repository's canonical default branch and rejects a tag commit outside that history before production preflight, build, attestation, or Release. A fine-grained `NIMI_REPOSITORY_ADMIN_TOKEN` secret with repository Administration read permission lets the workflow verify protected-tag and immutable-release settings; it cannot enable or change them. Manual workflow dispatch runs only the non-production build/package path. On Windows, the tag-only production build invokes the App-declared production build with no certificate-secret mapping or app-tools-owned signing step. Optional native signing remains publisher-owned and must already be reflected in the final exact Runtime entry before production pack observes and records its native-trust posture; a present invalid or unresolved signature still fails closed. A successful tag workflow creates the immutable publisher GitHub Release and no registry, installed, running, or Nimi Access truth. Submit the immutable Release to the Registry review flow, then use a current Nimi Desktop build with verified Windows package support for installation and acceptance.
105
+
106
+ ## Publishing on GitHub
107
+
108
+ Local development does not need a GitHub token. Publishing an App Release does.
109
+ `nimi-app check --production` checks local inputs; the tag workflow checks the
110
+ GitHub repository settings. Complete the one-time setup below before pushing a
111
+ release tag.
112
+
113
+ ### 1. Configure the publisher repository
114
+
115
+ Use a public repository owned by the publisher. You need administrator access
116
+ for this setup.
117
+
118
+ - In **Settings → General → Releases**, enable **Release immutability**.
119
+ - In **Settings → Rules → Rulesets**, create a **tag** ruleset, set enforcement
120
+ to **Active**, and include tags matching `v*`. Enable **Restrict updates**
121
+ and **Restrict deletions**. Tag creation must remain available to the publisher.
122
+
123
+ These settings protect published versions. The workflow only checks them; it
124
+ does not change repository settings.
125
+
126
+ ### 2. Create the read-only settings token
127
+
128
+ Open [GitHub's fine-grained token page](https://github.com/settings/personal-access-tokens/new).
129
+
130
+ 1. Name the token so you can recognize its purpose, and choose an expiration date.
131
+ 2. Set **Resource owner** to the user or organization that owns the App repository.
132
+ 3. Under **Repository access**, choose **Only select repositories** and select
133
+ this App repository.
134
+ 4. Under **Repository permissions**, set **Administration** to **Read-only**.
135
+ GitHub includes read-only Metadata automatically. No Contents write,
136
+ Actions write, Secrets write, or organization-wide access is needed.
137
+ 5. Generate the token. If the organization requires approval, complete that
138
+ approval before publishing.
139
+
140
+ This token reads tag-protection and release-immutability settings. The workflow
141
+ uses GitHub's separate built-in token to publish artifacts and its OIDC
142
+ permission to create build attestations.
143
+
144
+ ### 3. Save it as an Actions secret
145
+
146
+ In the App repository, open **Settings → Secrets and variables → Actions →
147
+ New repository secret**.
148
+
149
+ - **Name:** `NIMI_REPOSITORY_ADMIN_TOKEN`
150
+ - **Secret:** the fine-grained token value from step 2
151
+
152
+ Save it and confirm the exact name appears in the repository's Actions secrets.
153
+ Use a **secret**, not an Actions variable. An organization secret is also
154
+ supported when its repository-access list includes this App. Keep the value
155
+ out of source files, `.env`, and release notes.
156
+
157
+ ### 4. Check, build, and publish a version
158
+
159
+ Run the existing local path from the App repository:
160
+
161
+ ```bash
162
+ pnpm run sync
163
+ pnpm exec nimi-app check --production
164
+ pnpm exec nimi-app test
165
+ pnpm exec nimi-app build --target windows-x86_64 --production
166
+ pnpm exec nimi-app pack --target windows-x86_64 --production
167
+ ```
168
+
169
+ Commit the release changes and get that exact commit onto the repository's
170
+ canonical default branch. Keep `package.json` and `nimi.app.yaml` versions
171
+ equal. Use that version for the annotated tag; `0.1.0` below is an example:
172
+
173
+ ```bash
174
+ git tag -a v0.1.0 -m "Release 0.1.0"
175
+ git push origin v0.1.0
176
+ ```
177
+
178
+ Open **Actions → nimi-app-release**. A successful run produces the immutable
179
+ GitHub Release containing the `.nimiapp` package and aggregate candidate JSON.
180
+ Manual workflow dispatch checks the development path and does not publish.
181
+
182
+ If setup fails, the failed step points to the required setting. Add or replace
183
+ the secret, fix its repository selection/permissions, or enable the named
184
+ setting, then use **Re-run failed jobs** on the same run. A tag outside the
185
+ default branch requires merging its exact commit first. A code change requires
186
+ a new version and tag. Newly published release proofs can take a short time to
187
+ appear; the workflow waits for this specific delay and still requires successful
188
+ verification.
189
+
190
+ GitHub Release publication is followed by the separate
191
+ [Registry submission and human admission flow](https://github.com/nimiplatform/nimi-app-registry#ownership-boundary).
192
+ App Tools does not create an approval or install the App as a side effect.
105
193
 
106
194
  ## Acceptance status
107
195
 
package/bin/nimi-app.mjs CHANGED
@@ -366,6 +366,10 @@ try {
366
366
  production,
367
367
  json,
368
368
  });
369
+ if (production && !json) {
370
+ process.stdout.write('[nimi-app] Local checks do not verify GitHub repository settings or secrets. Before tagging, configure NIMI_REPOSITORY_ADMIN_TOKEN and release protection:\n');
371
+ process.stdout.write('https://github.com/nimiplatform/nimi/blob/main/app-tools/README.md#publishing-on-github\n');
372
+ }
369
373
  break;
370
374
  case 'test':
371
375
  testApp(process.cwd(), { dir, json });
@@ -388,7 +388,13 @@ function scanForbiddenPatterns(targetDir, profile, selectedLabels = null) {
388
388
  if (label === 'environment custody of protected material' && isManagedReleaseWorkflow) {
389
389
  continue;
390
390
  }
391
- if (pattern.test(text)) {
391
+ // Publishing documentation names the GitHub-only repository secret.
392
+ // App/runtime source still cannot read it, and other protected Nimi
393
+ // environment material remains forbidden in documentation as well.
394
+ const scanText = label === 'environment custody of protected material' && relativePath.endsWith('.md')
395
+ ? text.replace(/\bNIMI_REPOSITORY_ADMIN_TOKEN\b/gu, '')
396
+ : text;
397
+ if (pattern.test(scanText)) {
392
398
  findings.push(`${relativePath}: ${label}`);
393
399
  }
394
400
  }
@@ -135,9 +135,7 @@ function renderDefaultElectronProductionPackager(identity) {
135
135
  '',
136
136
  `const APP_EXECUTABLE_NAME = ${JSON.stringify(identity.cargoPackageName)};`,
137
137
  `const APP_PRODUCT_NAME = ${JSON.stringify(identity.appTitle)};`,
138
- `const APP_VERSION = ${JSON.stringify(identity.version)};`,
139
138
  resolveWindowsResourceVersion.toString(),
140
- 'const WINDOWS_RESOURCE_VERSION = resolveWindowsResourceVersion(APP_VERSION);',
141
139
  "const NATIVE_BINDING_PACKAGE = '@nimiplatform/kit-protected-local-win32-x64';",
142
140
  "const appRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');",
143
141
  "const outputRoot = path.join(appRoot, 'dist-electron-package');",
@@ -148,6 +146,8 @@ function renderDefaultElectronProductionPackager(identity) {
148
146
  '}',
149
147
  '',
150
148
  "const appPackage = JSON.parse(await readFile(path.join(appRoot, 'package.json'), 'utf8'));",
149
+ 'const APP_VERSION = appPackage.version;',
150
+ 'const WINDOWS_RESOURCE_VERSION = resolveWindowsResourceVersion(APP_VERSION);',
151
151
  "for (const sectionName of ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies']) {",
152
152
  ' if (Object.hasOwn(appPackage[sectionName] || {}, NATIVE_BINDING_PACKAGE)) {',
153
153
  " throw new Error('The protected native binding must arrive through the Kit optional dependency.');",
@@ -79,7 +79,6 @@ const APP_RELEASE_WORKFLOW = [
79
79
  ' - run: pnpm exec nimi-app sync',
80
80
  ' - run: test -z "$(git status --porcelain)"',
81
81
  ' - run: pnpm exec nimi-app check --json > .nimi-targets.json',
82
- ' - run: pnpm exec nimi-app test',
83
82
  ' - name: Require tag/version lockstep',
84
83
  " if: github.event_name == 'push' && github.ref_type == 'tag'",
85
84
  ' run: node -e "const p=require(\'./package.json\'); if (process.env.GITHUB_REF_NAME !== (\'v\' + p.version)) throw new Error(\'tag_version_mismatch\')"',
@@ -107,8 +106,23 @@ const APP_RELEASE_WORKFLOW = [
107
106
  ' GH_TOKEN: ${{ secrets.NIMI_REPOSITORY_ADMIN_TOKEN }}',
108
107
  ' shell: bash',
109
108
  ' run: |',
110
- ' test -n "$GH_TOKEN"',
111
- ' test "$(gh api "repos/$GITHUB_REPOSITORY/immutable-releases" --jq .enabled)" = true',
109
+ " if test -z \"$GH_TOKEN\"; then",
110
+ " echo \"::error title=Missing release setup::Add the repository Actions secret NIMI_REPOSITORY_ADMIN_TOKEN before publishing.\"",
111
+ " echo \"Create a fine-grained personal access token at https://github.com/settings/personal-access-tokens/new\"",
112
+ " echo \"Select the repository owner and only $GITHUB_REPOSITORY. Grant repository Administration: Read-only.\"",
113
+ " echo \"Save its value as NIMI_REPOSITORY_ADMIN_TOKEN at https://github.com/$GITHUB_REPOSITORY/settings/secrets/actions\"",
114
+ " echo \"Guide: https://github.com/nimiplatform/nimi/blob/main/app-tools/README.md#publishing-on-github\"",
115
+ " echo \"Then open this Actions run and choose Re-run failed jobs. Keep the existing tag.\"",
116
+ " exit 1",
117
+ " fi",
118
+ " if ! immutable=$(gh api \"repos/$GITHUB_REPOSITORY/immutable-releases\" --jq .enabled); then",
119
+ " echo \"::error title=Release settings inaccessible::Check token expiration, repository selection, Administration: Read-only, and any required organization approval.\"",
120
+ " exit 1",
121
+ " fi",
122
+ " if test \"$immutable\" != true; then",
123
+ " echo \"::error title=Immutable releases required::Enable release immutability in repository Settings > General > Releases, then re-run failed jobs.\"",
124
+ " exit 1",
125
+ " fi",
112
126
  ' protected=false',
113
127
  ' while read -r ruleset_id; do',
114
128
  ' ruleset=$(gh api "repos/$GITHUB_REPOSITORY/rulesets/$ruleset_id")',
@@ -122,7 +136,11 @@ const APP_RELEASE_WORKFLOW = [
122
136
  ' break',
123
137
  ' fi',
124
138
  ' done < <(gh api "repos/$GITHUB_REPOSITORY/rulesets" --jq \'.[] | select(.target == "tag" and .enforcement == "active") | .id\')',
125
- ' test "$protected" = true',
139
+ " if test \"$protected\" != true; then",
140
+ " echo \"::error title=Version tag protection required::Create an active tag ruleset for v* with Restrict updates and Restrict deletions in repository Settings > Rules > Rulesets.\"",
141
+ " echo \"After saving the ruleset, re-run failed jobs. Do not move or replace the existing tag.\"",
142
+ " exit 1",
143
+ " fi",
126
144
  ' - name: Resolve declared target matrix',
127
145
  ' id: matrix',
128
146
  ' shell: bash',
@@ -148,6 +166,8 @@ const APP_RELEASE_WORKFLOW = [
148
166
  ' package-manager-cache: false',
149
167
  ' - run: corepack enable',
150
168
  ' - run: pnpm install --frozen-lockfile',
169
+ ' - name: Test declared target',
170
+ ' run: pnpm exec nimi-app test',
151
171
  ' - name: Build development target',
152
172
  " if: github.event_name != 'push' || github.ref_type != 'tag'",
153
173
  ' env:',
@@ -248,6 +268,25 @@ const APP_RELEASE_WORKFLOW = [
248
268
  ' run: |',
249
269
  ' set -euo pipefail',
250
270
  ' shopt -s nullglob',
271
+ " verify_release() {",
272
+ " local verification_log",
273
+ " verification_log=$(mktemp)",
274
+ " for attempt in 1 2 3 4 5 6; do",
275
+ " if gh release verify \"$GITHUB_REF_NAME\" --repo \"$GITHUB_REPOSITORY\" >\"$verification_log\" 2>&1; then",
276
+ " cat \"$verification_log\"",
277
+ " rm \"$verification_log\"",
278
+ " return 0",
279
+ " fi",
280
+ " cat \"$verification_log\"",
281
+ " if ! grep -q \"no attestations for tag\" \"$verification_log\" || test \"$attempt\" = 6; then",
282
+ " rm \"$verification_log\"",
283
+ " echo \"::error title=Release verification failed::Inspect the error above. A published immutable Release must not be replaced; re-run failed jobs after its proof is available.\"",
284
+ " return 1",
285
+ " fi",
286
+ " echo \"Waiting for GitHub to make the new immutable Release attestation available (attempt $attempt/6).\"",
287
+ " sleep 10",
288
+ " done",
289
+ " }",
251
290
  ' assets=(release-assets/*.nimiapp release-assets/*.candidate.json)',
252
291
  ' test "${#assets[@]}" -gt 0',
253
292
  " expected=$(printf '%s\\n' \"${assets[@]##*/}\" | jq -R -s -c 'split(\"\\n\")[:-1] | sort')",
@@ -258,7 +297,7 @@ const APP_RELEASE_WORKFLOW = [
258
297
  ' test "$unexpected" -eq 0',
259
298
  ' if test "$(jq -r .draft <<<"$release_json")" = false; then',
260
299
  ' test "$existing" = "$expected"',
261
- ' gh release verify "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY"',
300
+ ' verify_release',
262
301
  ' for asset in "${assets[@]}"; do gh release verify-asset "$GITHUB_REF_NAME" "$asset" --repo "$GITHUB_REPOSITORY"; done',
263
302
  ' exit 0',
264
303
  ' fi',
@@ -280,7 +319,7 @@ const APP_RELEASE_WORKFLOW = [
280
319
  ' fi',
281
320
  ' done',
282
321
  ' gh release edit "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY" --draft=false',
283
- ' gh release verify "$GITHUB_REF_NAME" --repo "$GITHUB_REPOSITORY"',
322
+ ' verify_release',
284
323
  ' for asset in "${assets[@]}"; do gh release verify-asset "$GITHUB_REF_NAME" "$asset" --repo "$GITHUB_REPOSITORY"; done',
285
324
  '',
286
325
  ].join('\n');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nimiplatform/app-tools",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
4
4
  "description": "Public app-authoring CLI for Nimi App projects.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -19,7 +19,7 @@
19
19
  },
20
20
  "nimiScaffoldVersions": {
21
21
  "sdkVersion": "^0.9.1",
22
- "appToolsVersion": "^0.2.8",
22
+ "appToolsVersion": "^0.2.9",
23
23
  "nimicodingVersion": "0.6.1",
24
24
  "aiSdkVersion": "^6.0.85",
25
25
  "kitVersion": "^0.5.1",
@@ -24,7 +24,7 @@ pnpm run app:build -- --target windows-x86_64
24
24
  pnpm dev
25
25
  ```
26
26
 
27
- After a real target build, `pnpm run pack -- --target <target-id>` uses app-tools as the only package owner. Local publish is unavailable; a protected version tag runs the managed GitHub Release workflow, while registry pull-request orchestration remains unavailable until its owner path exists.
27
+ After a real target build, `pnpm run pack -- --target <target-id>` uses app-tools as the only package owner. App Tools has no local `publish` command. A protected version tag runs the managed GitHub Release workflow; submit the resulting immutable Release through the separate Registry pull-request and human-review flow.
28
28
 
29
29
  Before production, the public GitHub repository must enable a protected `v*` tag ruleset and immutable releases and provide a read-only repository-admin token for checking those settings. On Windows, the tag-only production build runs the App-declared build owner without a Nimi signing step. A publisher may sign the exact declared Host through its own build or signing custody; production pack records either verified Authenticode or explicit unsigned posture and rejects invalid or unresolved signatures. Manual workflow dispatch runs only the non-production path. The resulting GitHub Release remains independent from registry admission, Runtime installation, Desktop launch, and Nimi Access.
30
30
 
@@ -36,6 +36,30 @@ The default `windows-x86_64` build creates a fresh non-installer Electron direct
36
36
 
37
37
  Runtime, Realm, registry admission, installed state and process truth remain with their canonical owners. This repository stores no Runtime credentials or protected session material.
38
38
 
39
+ ## Publish with GitHub
40
+
41
+ Before pushing a release tag, complete these one-time repository steps:
42
+
43
+ 1. **Settings → General → Releases:** enable Release immutability.
44
+ 2. **Settings → Rules → Rulesets:** create an active tag ruleset for `v*`
45
+ that restricts updates and deletions.
46
+ 3. [Create a fine-grained token](https://github.com/settings/personal-access-tokens/new)
47
+ for this repository's owner and only this repository, with **Administration:
48
+ Read-only**. Complete organization approval if required.
49
+ 4. **Settings → Secrets and variables → Actions → New repository secret:**
50
+ save the token value under the exact name `NIMI_REPOSITORY_ADMIN_TOKEN`.
51
+
52
+ See the [step-by-step publishing guide](https://github.com/nimiplatform/nimi/blob/main/app-tools/README.md#publishing-on-github)
53
+ for repository setup, permission details, version tagging, and
54
+ recovery from setup errors. Local checks do not verify GitHub secrets.
55
+
56
+ Run `pnpm exec nimi-app check --production`, then the real production build
57
+ and pack. Commit the release on the repository's default branch and push an
58
+ annotated `v<package.json version>` tag. Watch **Actions → nimi-app-release**.
59
+ If a repository setting or secret is missing, fix it and **Re-run failed jobs**;
60
+ keep the existing tag. Registry admission is a separate human review after
61
+ the immutable Release exists.
62
+
39
63
  ## Support
40
64
 
41
65
  Report startup or Runtime issues through this repository's issue tracker. Diagnostics must exclude credentials and other private data.