@notis_ai/cli 0.2.25 → 0.2.26

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.
Files changed (157) hide show
  1. package/README.md +186 -5
  2. package/config/notis_app_design_rules.json +36 -14
  3. package/config/portal-route-roots.json +1 -0
  4. package/dist/agent-hooks/notis-agent-hook.mjs +2784 -541
  5. package/dist/base-skills/notis-cli/.notis-base-skill.json +1 -1
  6. package/dist/base-skills/notis-cli/references/intelligence.md +1 -1
  7. package/dist/base-skills/notis-query/.notis-base-skill.json +1 -1
  8. package/dist/base-skills/notis-query/SKILL.md +0 -1
  9. package/dist/base-skills/notis-query/references/documents.md +7 -0
  10. package/dist/base-skills/notis-query/references/query.md +1 -0
  11. package/dist/base-skills/notis-spaces/.notis-base-skill.json +1 -1
  12. package/dist/base-skills/notis-spaces/SKILL.md +96 -24
  13. package/dist/base-skills/notis-spaces/references/architecture.md +4 -3
  14. package/dist/base-skills/notis-spaces/references/design.md +37 -18
  15. package/dist/base-skills/notis-spaces/references/reading.md +8 -1
  16. package/dist/base-skills/notis-spaces/references/reports.md +6 -6
  17. package/dist/base-skills/notis-spaces/references/sdk.md +71 -7
  18. package/dist/base-skills/notis-spaces/references/store.md +22 -13
  19. package/dist/base-skills/notis-spaces/references/views.md +99 -6
  20. package/dist/sdk/package.json +3 -0
  21. package/dist/sdk/src/cloudComputerWords.ts +53 -0
  22. package/dist/sdk/src/components/Audience.tsx +76 -0
  23. package/dist/sdk/src/components/DocumentPage.tsx +15 -4
  24. package/dist/sdk/src/components/MarkdownEditor.tsx +44 -14
  25. package/dist/sdk/src/components/MultiSelectActionBar.tsx +16 -5
  26. package/dist/sdk/src/components/Skeleton.tsx +162 -6
  27. package/dist/sdk/src/hooks/useAction.ts +12 -2
  28. package/dist/sdk/src/hooks/useAgentQueue.ts +125 -0
  29. package/dist/sdk/src/hooks/useCloudComputerJob.ts +142 -0
  30. package/dist/sdk/src/hooks/useCloudComputerService.ts +388 -0
  31. package/dist/sdk/src/hooks/useCloudComputerShell.ts +95 -7
  32. package/dist/sdk/src/hooks/useCollectionInteractions.ts +40 -2
  33. package/dist/sdk/src/hooks/useItemThread.ts +58 -0
  34. package/dist/sdk/src/hooks/useMarqueeSelection.ts +6 -1
  35. package/dist/sdk/src/hooks/useNativeDocuments.ts +61 -8
  36. package/dist/sdk/src/hooks/useNotisNavigation.ts +31 -8
  37. package/dist/sdk/src/hooks/useQuery.ts +67 -10
  38. package/dist/sdk/src/hooks/useViewParams.ts +47 -11
  39. package/dist/sdk/src/index.ts +31 -4
  40. package/dist/sdk/src/interactions.ts +2 -0
  41. package/dist/sdk/src/nativeData.ts +2 -0
  42. package/dist/sdk/src/optimisticRows.ts +329 -0
  43. package/dist/sdk/src/perf.ts +188 -0
  44. package/dist/sdk/src/provider.tsx +2 -1
  45. package/dist/sdk/src/queryCache.ts +366 -17
  46. package/dist/sdk/src/runtime.ts +55 -4
  47. package/dist/sdk/src/skeleton.ts +103 -0
  48. package/dist/sdk/src/space.ts +662 -28
  49. package/dist/sdk/src/spacePublicUI.ts +36 -0
  50. package/dist/sdk/src/ui/engine/step.ts +54 -0
  51. package/dist/sdk/src/ui/icons.tsx +3 -1
  52. package/dist/sdk/src/words/shell.ts +1 -0
  53. package/dist/skill-sync/index.js +7 -2
  54. package/dist/skill-sync-worker.mjs +40 -26
  55. package/dist/space-harness/host.js +272 -105
  56. package/dist/space-sdk/dist/chunk-BWHAORT4.js +5 -0
  57. package/dist/space-sdk/dist/index.js +9 -4
  58. package/dist/space-sdk/dist/ui.js +12 -12
  59. package/dist/space-sdk/package.json +3 -0
  60. package/dist/space-sdk/src/cloudComputerWords.d.ts +34 -0
  61. package/dist/space-sdk/src/components/Audience.d.ts +46 -0
  62. package/dist/space-sdk/src/components/DocumentPage.d.ts +3 -1
  63. package/dist/space-sdk/src/components/MarkdownEditor.d.ts +21 -0
  64. package/dist/space-sdk/src/components/MultiSelectActionBar.d.ts +5 -1
  65. package/dist/space-sdk/src/components/Skeleton.d.ts +7 -2
  66. package/dist/space-sdk/src/hooks/useAction.d.ts +8 -1
  67. package/dist/space-sdk/src/hooks/useAgentQueue.d.ts +61 -0
  68. package/dist/space-sdk/src/hooks/useCloudComputerJob.d.ts +35 -0
  69. package/dist/space-sdk/src/hooks/useCloudComputerService.d.ts +75 -0
  70. package/dist/space-sdk/src/hooks/useCloudComputerShell.d.ts +36 -3
  71. package/dist/space-sdk/src/hooks/useCollectionInteractions.d.ts +6 -0
  72. package/dist/space-sdk/src/hooks/useItemThread.d.ts +32 -0
  73. package/dist/space-sdk/src/hooks/useMarqueeSelection.d.ts +2 -1
  74. package/dist/space-sdk/src/hooks/useNativeDocumentBody.d.ts +1 -0
  75. package/dist/space-sdk/src/hooks/useNativeDocuments.d.ts +20 -5
  76. package/dist/space-sdk/src/hooks/useNotisNavigation.d.ts +11 -2
  77. package/dist/space-sdk/src/hooks/useQuery.d.ts +24 -2
  78. package/dist/space-sdk/src/hooks/useViewParams.d.ts +2 -0
  79. package/dist/space-sdk/src/index.d.ts +24 -4
  80. package/dist/space-sdk/src/nativeData.d.ts +6 -0
  81. package/dist/space-sdk/src/queryCache.d.ts +97 -2
  82. package/dist/space-sdk/src/runtime.d.ts +53 -4
  83. package/dist/space-sdk/src/skeleton.d.ts +42 -0
  84. package/dist/space-sdk/src/space.ts +662 -28
  85. package/dist/space-sdk/src/tailwind-candidates.d.ts +754 -5
  86. package/dist/space-sdk/src/ui/cloud/CloudComputerFrame.d.ts +29 -0
  87. package/dist/space-sdk/src/ui/cloud/CloudComputerWaking.d.ts +20 -0
  88. package/dist/space-sdk/src/ui/comments/CommentPane.d.ts +15 -2
  89. package/dist/space-sdk/src/ui/comments/PassageComments.d.ts +50 -0
  90. package/dist/space-sdk/src/ui/comments/commentFiles.d.ts +64 -0
  91. package/dist/space-sdk/src/ui/comments/commentModel.d.ts +49 -1
  92. package/dist/space-sdk/src/ui/comments/commentWords.d.ts +26 -0
  93. package/dist/space-sdk/src/ui/comments/index.d.ts +4 -0
  94. package/dist/space-sdk/src/ui/comments/passageModel.d.ts +82 -0
  95. package/dist/space-sdk/src/ui/comments/useComments.d.ts +34 -4
  96. package/dist/space-sdk/src/ui/comments/usePassageComments.d.ts +67 -0
  97. package/dist/space-sdk/src/ui/engine/index.d.ts +2 -2
  98. package/dist/space-sdk/src/ui/engine/step.d.ts +9 -0
  99. package/dist/space-sdk/src/ui/fields/fields.d.ts +2 -1
  100. package/dist/space-sdk/src/ui/index.d.ts +4 -0
  101. package/dist/space-sdk/src/ui/layout/Panels.d.ts +9 -2
  102. package/dist/space-sdk/src/ui/layout/SidePane.d.ts +42 -0
  103. package/dist/space-sdk/src/ui/layout/index.d.ts +2 -1
  104. package/dist/space-sdk/src/ui/layout/panelMath.d.ts +11 -2
  105. package/dist/space-sdk/src/ui/list/ListReader.d.ts +38 -7
  106. package/dist/space-sdk/src/ui/list/Row.d.ts +4 -0
  107. package/dist/space-sdk/src/ui/list/SelectionBar.d.ts +9 -4
  108. package/dist/space-sdk/src/ui/list/useListKeys.d.ts +4 -0
  109. package/dist/space-sdk/src/words/shell.ts +1 -0
  110. package/dist/view-renderer/dist/host.js +355 -188
  111. package/dist/view-renderer/dist/theme.css +1 -1
  112. package/dist/view-renderer/src/host.tsx +4 -1
  113. package/dist/view-renderer/src/index.js +3 -0
  114. package/dist/view-renderer/src/pool.js +8 -4
  115. package/dist/view-renderer/src/renderer.js +92 -23
  116. package/dist/view-renderer/src/skeleton.js +450 -0
  117. package/package.json +4 -4
  118. package/skills/notis-cli/AGENT_INSTRUCTIONS.md +8 -4
  119. package/skills/notis-onboarding/BRIEF.md +15 -9
  120. package/skills/notis-spaces/cli.md +43 -4
  121. package/src/command-specs/auth.js +5 -3
  122. package/src/command-specs/cc.js +410 -0
  123. package/src/command-specs/computer.js +320 -0
  124. package/src/command-specs/diagnostics.js +2 -13
  125. package/src/command-specs/documents.js +22 -4
  126. package/src/command-specs/index.js +7 -0
  127. package/src/command-specs/onboarding.js +127 -7
  128. package/src/command-specs/skills.js +2 -2
  129. package/src/command-specs/spaces.js +162 -30
  130. package/src/command-specs/tools.js +26 -8
  131. package/src/command-specs/views.js +4 -1
  132. package/src/runtime/agent-setup.js +20 -2
  133. package/src/runtime/app-boundary-validator.js +2 -1
  134. package/src/runtime/app-platform.js +13 -0
  135. package/src/runtime/auth-recovery.js +5 -0
  136. package/src/runtime/channel.js +16 -2
  137. package/src/runtime/cloud-transfer.js +587 -0
  138. package/src/runtime/computer-ssh.js +127 -0
  139. package/src/runtime/oauth.js +50 -4
  140. package/src/runtime/skill-sync/index.ts +20 -1
  141. package/src/runtime/skill-sync/local-scanner.ts +1 -0
  142. package/src/runtime/skill-sync/types.ts +2 -0
  143. package/src/runtime/space-audience.js +94 -0
  144. package/src/runtime/space-collection-scaffold.js +2 -1
  145. package/src/runtime/space-fixture-broker.js +2 -1
  146. package/src/runtime/space-lock.js +1 -4
  147. package/src/runtime/space-platform.js +18 -2
  148. package/src/runtime/space-source.js +105 -7
  149. package/src/runtime/space-test-server.js +13 -2
  150. package/src/runtime/space-verification.js +99 -6
  151. package/src/runtime/space-view-manifest.js +22 -4
  152. package/src/runtime/sync-skills.js +24 -20
  153. package/src/runtime/transport.js +19 -0
  154. package/src/runtime/view-render.js +2 -2
  155. package/template/.harness/index.html.tmpl +1 -1
  156. package/dist/skill-sync/index.js.map +0 -7
  157. package/dist/space-sdk/dist/chunk-SVZATGZB.js +0 -5
@@ -1,6 +1,6 @@
1
1
  import { scaffoldSpaceCollection } from '../runtime/space-collection-scaffold.js';
2
- import { appFilesDigest, pullAppSource, resolveProjectDir, saveSpaceVerification, spacePublicationIntent, syncSpaceSdk } from '../runtime/app-platform.js';
3
- import { buildSpaceArtifact, prepareSpaceRelease } from '../runtime/space-platform.js';
2
+ import { appFilesDigest, pullAppSource, resolveProjectDir, saveSpacePendingScreenshots, saveSpaceVerification, spacePublicationIntent, syncSpaceSdk } from '../runtime/app-platform.js';
3
+ import { buildSpaceArtifact, prepareSpaceRelease, requireSpaceIcon } from '../runtime/space-platform.js';
4
4
  import { verifySpaceRelease } from '../runtime/space-verification.js';
5
5
  import { loadSelectedSpace } from '../runtime/space-source.js';
6
6
  import { refreshSpaceAuthoring } from '../runtime/space-database-structures.js';
@@ -47,9 +47,14 @@ function object(value, label) {
47
47
  return parsed;
48
48
  }
49
49
 
50
- async function remote(ctx, operation, { method = 'POST', body, query } = {}) {
50
+ // Checking, publishing, installing or updating a Store copy reads and copies the whole Space: often 20 to 40 s, more on
51
+ // a busy server, so these commands wait at least three minutes instead of the default 30 s.
52
+ const STORE_COPY_TIMEOUT_MS = 180_000;
53
+
54
+ async function remote(ctx, operation, { method = 'POST', body, query, minTimeoutMs = 0 } = {}) {
51
55
  const suffix = query ? `?${new URLSearchParams(Object.entries(query).filter(([, value]) => value != null))}` : '';
52
- const result = await httpRequest({ runtime: ctx.runtime, method, path: `/portal_spaces/${operation}${suffix}`, body, spacesProtocol: true });
56
+ const runtime = minTimeoutMs ? { ...ctx.runtime, timeoutMs: Math.max(ctx.runtime.timeoutMs || 0, minTimeoutMs) } : ctx.runtime;
57
+ const result = await httpRequest({ runtime, method, path: `/portal_spaces/${operation}${suffix}`, body, spacesProtocol: true });
53
58
  return ctx.output.emitSuccess({ command: ctx.spec.command_path.join(' '), data: result.payload,
54
59
  humanSummary: JSON.stringify(result.payload, null, 2), meta: { mutating: method !== 'GET' && !body?.dry_run && ctx.spec.mutates !== false, request_id: result.requestId } });
55
60
  }
@@ -109,8 +114,8 @@ function describeViewerReads(capabilities) {
109
114
  /** Reviewable: a page that uses the cloud computer runs on each viewer's own one, after that viewer allows it. */
110
115
  function describeCloudComputer(capabilities) {
111
116
  const level = capabilities?.cloudComputer;
112
- if (level === 'shell') return " Cloud computer: this page runs commands and writes files on each signed-in viewer's own cloud computer, once that viewer allows it (never on a Site).";
113
- if (level === 'read') return " Cloud computer: this page reads whether each signed-in viewer's own cloud computer is running and signed in to GitHub, once that viewer allows it.";
117
+ if (level === 'shell') return " Cloud Computer: this page runs commands and writes files on each signed-in viewer's own Cloud Computer, once that viewer allows it (never on a Site).";
118
+ if (level === 'read') return " Cloud Computer: this page reads whether each signed-in viewer's own Cloud Computer is running and signed in to GitHub, once that viewer allows it.";
114
119
  return '';
115
120
  }
116
121
 
@@ -124,12 +129,39 @@ function describePendingChanges(summary) {
124
129
  return parts.length ? ` ${parts.join('. ')}.` : '';
125
130
  }
126
131
 
132
+ const SKELETON_FILE = 'bundle/skeleton.json';
133
+
134
+ /** Reviewable: the measured loading skeleton, its warnings and where the loading screenshots are. */
135
+ function describeSkeleton(skeleton) {
136
+ if (!skeleton) return '';
137
+ const parts = [skeleton.status === 'captured' ? `Loading skeleton measured for ${skeleton.regions.join(', ')}.`
138
+ : skeleton.status === 'failed' ? 'The loading skeleton could not be measured; the view keeps its fallback skeleton.' : ''];
139
+ const findings = skeleton.findings || [];
140
+ if (findings.length) {
141
+ const where = value => [value.width, value.locale].filter(Boolean).join(' ');
142
+ const shown = findings.slice(0, 5).map(value => `${where(value) ? `[${where(value)}] ` : ''}${value.message}`);
143
+ parts.push(`Loading state warnings (${findings.length}): ${shown.join(' ')}${findings.length > 5 ? ` And ${findings.length - 5} more in the diagnostic.` : ''}`);
144
+ }
145
+ const paths = (skeleton.pending_screenshots || []).map(value => value.path).filter(Boolean);
146
+ if (paths.length) parts.push(`Loading screenshots: ${paths.join(', ')}.`);
147
+ const text = parts.filter(Boolean).join(' ');
148
+ return text ? ` ${text}` : '';
149
+ }
150
+
151
+ /** Same server verification for this Space, source, grants and authorization mode. */
152
+ function sameVerification(verification, body, sourceDigest) {
153
+ return verification?.valid === true && verification.space_id === body.space_id && verification.source_digest === sourceDigest
154
+ && JSON.stringify(Object.entries(verification.reuse_grants || {}).sort()) === JSON.stringify(Object.entries(body.reuse_grants).sort())
155
+ && (verification.authorization_mode ?? 'authorize_missing') === (body.authorization_mode ?? 'authorize_missing');
156
+ }
157
+
127
158
  async function sourceRelease(ctx, publish, stageOnly = false) {
128
159
  const { directory, key } = selected(ctx);
129
160
  if (!ctx.options.spaceId) throw usageError('Pass --space-id <id> for the existing Space.');
130
161
  const intentKey = publish ? requestId(ctx) : null;
131
162
  const release = await prepareSpaceRelease(directory, key);
132
163
  try {
164
+ if (publish) requireSpaceIcon(release.manifest, key);
133
165
  const identity = [ctx.runtime.apiBase.replace(/\/$/, ''), ctx.runtime.profileName, key, ctx.options.spaceId, intentKey];
134
166
  let verification = publish && !ctx.options.dryRun ? spacePublicationIntent(directory, identity) : null;
135
167
  const local = intentChanges(directory, ctx.options.spaceId, release.manifest,
@@ -138,42 +170,74 @@ async function sourceRelease(ctx, publish, stageOnly = false) {
138
170
  artifact_files: release.files, reuse_grants: object(ctx.options.reuseGrants || '{}', '--reuse-grants'),
139
171
  ...(ctx.options.reuseGrantsOnly ? { authorization_mode: 'reuse_only' } : {}),
140
172
  ...(local.changes ? { changes: local.changes } : {}) };
141
- const sourceDigest = appFilesDigest(release.sourceFiles), artifactDigest = appFilesDigest(release.files);
173
+ const sourceDigest = appFilesDigest(release.sourceFiles), builtDigest = appFilesDigest(release.files);
142
174
  const call = (operation, data) => httpRequest({ runtime: { ...ctx.runtime, timeoutMs: Math.max(ctx.runtime.timeoutMs || 0, 600_000) },
143
175
  method: 'POST', path: `/portal_spaces/${operation}`, body: data, spacesProtocol: true });
144
176
  if (verification && (verification.local_changes_fingerprint ?? null) !== local.fingerprint) {
145
177
  throw usageError('This request ID belongs to different Skill folders or list entries. Restore the state you first deployed to retry, or use a new request ID for a new release.');
146
178
  }
179
+ const retried = Boolean(verification);
180
+ // A retry injects the exact skeleton bytes its first attempt sent, so the stored digest still matches.
181
+ const pinnedSkeleton = retried && Object.hasOwn(verification, 'local_skeleton') ? verification.local_skeleton : undefined;
182
+ // An intent stored before skeletons existed keeps the release exactly as it was built.
183
+ const legacyRetry = retried && pinnedSkeleton === undefined;
184
+ const mismatch = () => usageError('This request ID belongs to different source or grant choices. Keep the original bytes to retry, or use a new request ID for a new release.');
147
185
  if (!verification) {
148
186
  verification = (await call('source-verify', body)).payload;
149
187
  }
150
- if (verification?.valid !== true || verification.space_id !== body.space_id || verification.source_digest !== sourceDigest
151
- || verification.artifact_digest !== artifactDigest || JSON.stringify(Object.entries(verification.reuse_grants || {}).sort())
152
- !== JSON.stringify(Object.entries(body.reuse_grants).sort())
153
- || (verification.authorization_mode ?? 'authorize_missing') !== (body.authorization_mode ?? 'authorize_missing')) {
154
- throw usageError('This request ID belongs to different source or grant choices. Keep the original bytes to retry, or use a new request ID for a new release.');
155
- }
188
+ // The artifact digest is compared once the measured skeleton is in the release (below).
189
+ if (!sameVerification(verification, body, sourceDigest) || (!retried && verification.artifact_digest !== builtDigest)) throw mismatch();
156
190
  const controller = new AbortController();
157
191
  const cancel = () => controller.abort();
158
192
  process.once('SIGINT', cancel); process.once('SIGTERM', cancel);
159
193
  let render;
160
194
  try { render = await verifySpaceRelease(release, { capabilities: verification.capabilities, signal: controller.signal,
161
- authorizationMode: body.authorization_mode, unavailableActions: verification.unavailable_actions }); }
195
+ authorizationMode: body.authorization_mode, unavailableActions: verification.unavailable_actions,
196
+ // Test seam only: the command context never carries it from user options.
197
+ ...(typeof ctx.loadSpaceRenderer === 'function' ? { loadRenderer: ctx.loadSpaceRenderer } : {}) }); }
162
198
  finally { process.removeListener('SIGINT', cancel); process.removeListener('SIGTERM', cancel); }
199
+ if (render.skeleton) {
200
+ const paths = saveSpacePendingScreenshots(directory, render.pendingScreenshots || []);
201
+ render.skeleton.pending_screenshots = render.skeleton.pending_screenshots.map((value, index) => ({ ...value, ...(paths[index] ? { path: paths[index] } : {}) }));
202
+ }
163
203
  const diagnosticPath = saveSpaceVerification(directory, { ...render, space_id: body.space_id });
164
204
  if (!['passed', 'not_applicable_container'].includes(render.status)) {
165
205
  const reason = render.errors?.find(value => value.phase === 'fixture')?.message;
166
206
  throw usageError(`The built Space did not pass offline render verification. Nothing was published.${reason ? ` ${reason}` : ''}`,
167
207
  { render, diagnostic_path: diagnosticPath });
168
208
  }
209
+ // The measured skeleton joins the release in memory, replacing any file at its path; nothing is written to disk.
210
+ const skeletonFile = pinnedSkeleton !== undefined ? pinnedSkeleton
211
+ : render.skeletonJson ? Buffer.from(render.skeletonJson, 'utf8').toString('base64') : null;
212
+ const skeletonWarnings = [];
213
+ const written = release.files[SKELETON_FILE];
214
+ if (!legacyRetry && (skeletonFile || written !== undefined)) {
215
+ const files = { ...release.files };
216
+ if (skeletonFile) {
217
+ files[SKELETON_FILE] = skeletonFile;
218
+ if (written !== undefined && written !== skeletonFile) skeletonWarnings.push(`Replaced ${SKELETON_FILE} with the skeleton verify measured; verify writes this file, do not add it by hand.`);
219
+ } else {
220
+ delete files[SKELETON_FILE];
221
+ skeletonWarnings.push(`Removed ${SKELETON_FILE} from the release: verify measured no loading skeleton for this build, so the file would be stale. Verify writes this file, do not add it by hand.`);
222
+ }
223
+ release.files = files;
224
+ body.artifact_files = files;
225
+ }
226
+ const artifactDigest = appFilesDigest(body.artifact_files);
227
+ if (!retried && artifactDigest !== builtDigest) {
228
+ // The server binds the release that carries the skeleton, and checks the file itself.
229
+ verification = (await call('source-verify', body)).payload;
230
+ if (!sameVerification(verification, body, sourceDigest)) throw mismatch();
231
+ }
232
+ if (verification.artifact_digest !== artifactDigest) throw mismatch();
169
233
  if (publish && !ctx.options.dryRun) {
170
234
  // The retained intent pins the local change set next to the server verification, with the
171
235
  // lock and list it was computed from: the lock and list this publication then rewrites can
172
236
  // never turn the identical command into a different intent.
173
237
  verification = spacePublicationIntent(directory, identity, { ...verification, local_changes_fingerprint: local.fingerprint,
174
- local_state: local.lock ? { lock: local.lock, resources: local.resources ?? null } : null });
238
+ local_state: local.lock ? { lock: local.lock, resources: local.resources ?? null } : null, local_skeleton: skeletonFile });
175
239
  }
176
- const { local_changes_fingerprint: _fingerprint, local_state: _state, ...serverVerification } = verification;
240
+ const { local_changes_fingerprint: _fingerprint, local_state: _state, local_skeleton: _skeleton, ...serverVerification } = verification;
177
241
  // Close/check the pinned local snapshot before the first remote mutation.
178
242
  // The upload uses the captured bytes, not mutable working-tree paths.
179
243
  release.close();
@@ -182,12 +246,13 @@ async function sourceRelease(ctx, publish, stageOnly = false) {
182
246
  : serverVerification;
183
247
  if (publish && !ctx.options.dryRun && !stageOnly) recordPublication(directory, local, result);
184
248
  const data = { ...result, render, diagnostic_path: diagnosticPath, ...(local.summary ? { local_changes: local.summary } : {}) };
249
+ const skeletonSummary = describeSkeleton(render.skeleton);
185
250
  return ctx.output.emitSuccess({ command: ctx.spec.command_path.join(' '), data,
186
251
  humanSummary: publish && !ctx.options.dryRun
187
252
  ? stageOnly ? `Prepared ${key} as revision ${result.candidate_revision}. ${result.preview_url || 'This container has no executable preview.'} Live source was not changed.${describePendingChanges(local.summary).replace(/\.$/, '; they go live with notis spaces promote.')}`
188
- : `Published ${key} as revision ${result.published_revision}${result.replayed ? ' (confirmed retry)' : ''}.${describeAppliedChanges(result)}${describeViewerReads(serverVerification.capabilities)}${describeCloudComputer(serverVerification.capabilities)}`
189
- : `Verified ${key}'s frozen source${render.status === 'passed' ? ', rendered fixtures' : ' (container)'} and current authorizations; nothing was published.${describePendingChanges(local.summary)}${describeViewerReads(serverVerification.capabilities)}${describeCloudComputer(serverVerification.capabilities)}`,
190
- warnings: local.warnings, meta: { mutating: publish && !ctx.options.dryRun } });
253
+ : `Published ${key} as revision ${result.published_revision}${result.replayed ? ' (confirmed retry)' : ''}.${describeAppliedChanges(result)}${describeViewerReads(serverVerification.capabilities)}${describeCloudComputer(serverVerification.capabilities)}${skeletonSummary}`
254
+ : `Verified ${key}'s frozen source${render.status === 'passed' ? ', rendered fixtures' : ' (container)'} and current authorizations; nothing was published.${describePendingChanges(local.summary)}${describeViewerReads(serverVerification.capabilities)}${describeCloudComputer(serverVerification.capabilities)}${skeletonSummary}`,
255
+ warnings: skeletonWarnings.length ? [...(local.warnings || []), ...skeletonWarnings] : local.warnings, meta: { mutating: publish && !ctx.options.dryRun } });
191
256
  } finally { release.close(); }
192
257
  }
193
258
 
@@ -256,6 +321,15 @@ function refreshPulledSdk(projectDir) {
256
321
  const idArgument = { token: '<space-id>', key: 'spaceId', description: 'Exact existing Space ID.' };
257
322
  const recordOption = { flags: '--record <record-key>', description: 'Fixed record context, when this is a record-scoped Space.' };
258
323
  const requestOption = { flags: '--request-id <key>', description: 'Stable intent key. Reuse after timeouts or lost replies.' };
324
+ const receiptOption = { flags: '--receipt <receipt-id>', description: 'The receipt_id store check returned for this exact version.' };
325
+ const confirmedOption = { flags: '--confirmed', description: 'The person said yes to the risks store check reported.' };
326
+
327
+ /** The Store check an agent install or update carries; the server refuses one without it. */
328
+ function checkedBody(ctx) {
329
+ if (ctx.options.confirmed && !ctx.options.receipt) throw usageError('Pass --receipt <receipt-id> from notis spaces store check with --confirmed.');
330
+ return { ...(ctx.options.receipt ? { receipt_id: ctx.options.receipt } : {}),
331
+ ...(ctx.options.confirmed ? { confirmed: true } : {}) };
332
+ }
259
333
 
260
334
  function historyRevision(value, flag) {
261
335
  if (typeof value !== 'string' || !/^\d+$/.test(value) || !Number.isSafeInteger(Number(value))) {
@@ -462,6 +536,44 @@ export const spacesCommandSpecs = [
462
536
  binding_revision: Number(expected), request_id: requestId(ctx) } });
463
537
  },
464
538
  },
539
+ {
540
+ command_path: ['spaces', 'folder'],
541
+ summary: 'Show the folder a Space works in on your Cloud Computer or this computer, or map it to a folder of your own.',
542
+ when_to_use: 'Find where a Space keeps its files and builds, or point it at an existing project folder. Each person maps their own folder; clearing a mapping goes back to the Space\'s own folder, which is never deleted by it.',
543
+ args_schema: { arguments: [idArgument], options: [
544
+ { flags: '--map <path>', description: 'Use this folder instead: inside /vercel/sandbox on the Cloud Computer, absolute or ~/ on this computer.' },
545
+ { flags: '--unmap', description: 'Go back to the Space\'s own folder.' },
546
+ { flags: '--target <where>', description: 'cloud (default) for the Cloud Computer, desktop for this computer through Notis Desktop.' },
547
+ ] },
548
+ examples: ['notis spaces folder <space-id>', 'notis spaces folder <space-id> --map /vercel/sandbox/my-app',
549
+ 'notis spaces folder <space-id> --target desktop --map ~/code/my-app', 'notis spaces folder <space-id> --unmap'],
550
+ output_schema: 'Returns { space_id, target, canonical_path, mapped_path, path }: path is the folder in use, mapped_path is null when unmapped.',
551
+ mutates: true, idempotent: true, require_auth: true,
552
+ backend_call: { type: 'http', path: '/portal_spaces/space-folder' },
553
+ async handler(ctx) {
554
+ const { map, unmap } = ctx.options;
555
+ if (map !== undefined && unmap) throw usageError('Use --map <path> or --unmap, not both.');
556
+ const target = ctx.options.target ?? 'cloud';
557
+ if (!['cloud', 'desktop'].includes(target)) throw usageError('--target is cloud or desktop.');
558
+ if (map !== undefined && (typeof map !== 'string' || !map.trim() || map.includes('\0'))) throw usageError('--map takes a folder path.');
559
+ if (map !== undefined && target === 'cloud' && map !== '/vercel/sandbox' && !map.startsWith('/vercel/sandbox/')) {
560
+ throw usageError('On the Cloud Computer, --map takes a folder inside /vercel/sandbox.');
561
+ }
562
+ if (map !== undefined && target === 'desktop' && !map.startsWith('/') && !map.startsWith('~/')) {
563
+ throw usageError('On this computer, --map takes an absolute folder (/...) or one in your home folder (~/...).');
564
+ }
565
+ const action = map !== undefined ? 'set' : unmap ? 'clear' : 'get';
566
+ const body = { space_id: ctx.args.spaceId, action, target, ...(action === 'set' ? { path: map } : {}) };
567
+ const result = await httpRequest({ runtime: ctx.runtime, method: 'POST', path: '/portal_spaces/space-folder', body, spacesProtocol: true });
568
+ const folder = result.payload || {};
569
+ const where = folder.target === 'desktop' ? 'this computer' : 'the Cloud Computer';
570
+ const summary = folder.mapped_path
571
+ ? `On ${where} this Space works in ${folder.path} (mapped; its own folder is ${folder.canonical_path}).`
572
+ : `On ${where} this Space works in its own folder ${folder.path} (not mapped).`;
573
+ return ctx.output.emitSuccess({ command: ctx.spec.command_path.join(' '), data: folder, humanSummary: summary,
574
+ requestId: result.requestId, meta: { mutating: action !== 'get' } });
575
+ },
576
+ },
465
577
  {
466
578
  command_path: ['spaces', 'aliases', 'list'],
467
579
  summary: 'List the old App page links you manage and the Space each one opens.',
@@ -698,19 +810,35 @@ export const spacesCommandSpecs = [
698
810
  backend_call: { type: 'http', path: '/portal_spaces/store-installs' },
699
811
  handler: ctx => remote(ctx, 'store-installs', { method: 'GET' }),
700
812
  },
813
+ {
814
+ command_path: ['spaces', 'store', 'check'], summary: 'Check a Store listing, or the update of an installed copy, before installing it.',
815
+ when_to_use: 'Always before store install or store update: it returns the risks in plain words, a recommendation, the trust line of a Space shared by link and a receipt valid one hour. Tell the person, wait for their yes, then install with --receipt and --confirmed.',
816
+ args_schema: { arguments: [{ token: '<listing-id>', key: 'listingId', description: 'Exact listing ID.' }],
817
+ options: [{ flags: '--install <install-id>', description: 'Check only what the update of this installed copy changes.' },
818
+ { flags: '--locale <en|fr>', description: "The person's language for the risks and the trust line." }] },
819
+ examples: ['notis spaces store check <listing-id>', 'notis spaces store check <listing-id> --install <install-id> --locale fr'],
820
+ mutates: true, idempotent: false, require_auth: true, backend_call: { type: 'http', path: '/portal_spaces/store-check' },
821
+ handler(ctx) {
822
+ if (ctx.options.locale && !['en', 'fr'].includes(ctx.options.locale)) throw usageError('Pass --locale en or --locale fr.');
823
+ return remote(ctx, 'store-check', { minTimeoutMs: STORE_COPY_TIMEOUT_MS, body: { listing_id: ctx.args.listingId,
824
+ ...(ctx.options.install ? { install_id: ctx.options.install } : {}),
825
+ ...(ctx.options.locale ? { locale: ctx.options.locale } : {}) } });
826
+ },
827
+ },
701
828
  {
702
829
  command_path: ['spaces', 'store', 'publish'], summary: 'Publish a Space and its sub-Spaces as the next Store version.',
703
- when_to_use: 'Share a Space you own as an installable template: team listings publish at once, public ones wait for review. Notis runs the same safety scan and Owner check as the submission page and explains any refusal.',
704
- args_schema: { arguments: [idArgument], options: [{ flags: '--channel <team|public>', description: 'Where to publish.' },
830
+ when_to_use: 'Share a Space you own as an installable template: link and team listings publish at once, public ones wait for review. A link listing never shows in the Store; only people with its link see it. Notis runs the same safety scan and Owner check as the submission page and explains any refusal.',
831
+ args_schema: { arguments: [idArgument], options: [{ flags: '--channel <link|team|public>', description: 'Where to publish: anyone with the link, your team or everyone.' },
705
832
  { flags: '--metadata <json>', description: 'Listing name, tagline, description, category, icon, accent.' },
706
833
  { flags: '--starter <json>', description: 'Starter row IDs per database ({"<database-id>":["<record-key>"]}).' },
707
834
  { flags: '--notes <text>', description: 'Release notes for this version.' },
708
835
  requestOption, { flags: '--dry-run', description: 'Show the package counts and review diff without publishing.' }] },
709
- examples: ['notis spaces store publish <space-id> --channel team --request-id publish-1 --dry-run'],
836
+ examples: ['notis spaces store publish <space-id> --channel team --request-id publish-1 --dry-run',
837
+ 'notis spaces store publish <space-id> --channel link --request-id share-link-1'],
710
838
  mutates: true, idempotent: true, require_auth: true, backend_call: { type: 'http', path: '/portal_spaces/store-publish' },
711
839
  handler(ctx) {
712
- if (!['team', 'public'].includes(ctx.options.channel)) throw usageError('Pass --channel team or --channel public.');
713
- return remote(ctx, 'store-publish', { body: { space_id: ctx.args.spaceId, channel: ctx.options.channel, request_id: requestId(ctx),
840
+ if (!['link', 'team', 'public'].includes(ctx.options.channel)) throw usageError('Pass --channel link, --channel team or --channel public.');
841
+ return remote(ctx, 'store-publish', { minTimeoutMs: STORE_COPY_TIMEOUT_MS, body: { space_id: ctx.args.spaceId, channel: ctx.options.channel, request_id: requestId(ctx),
714
842
  ...(ctx.options.metadata ? { metadata: object(ctx.options.metadata, '--metadata') } : {}),
715
843
  ...(ctx.options.starter ? { starter: object(ctx.options.starter, '--starter') } : {}),
716
844
  ...(ctx.options.notes ? { notes: ctx.options.notes } : {}), dry_run: Boolean(ctx.options.dryRun) } });
@@ -718,28 +846,32 @@ export const spacesCommandSpecs = [
718
846
  },
719
847
  {
720
848
  command_path: ['spaces', 'store', 'install'], summary: 'Install a Store listing as your own independent copy.',
721
- when_to_use: 'Add a published Space template to your account; your copy keeps your changes on later updates.',
849
+ when_to_use: 'Add a published Space template to your account after store check and the person\'s yes; your copy keeps your changes on later updates and its automations arrive paused.',
722
850
  args_schema: { arguments: [{ token: '<listing-id>', key: 'listingId', description: 'Exact listing ID.' }],
723
851
  options: [{ flags: '--name <name>', description: 'Name of the installed top Space.' },
724
852
  { flags: '--parent <space-id>', description: 'Install under one of your Spaces.' },
853
+ receiptOption, confirmedOption,
725
854
  requestOption, { flags: '--dry-run', description: 'Show what the copy contains without installing.' }] },
726
- examples: ['notis spaces store install <listing-id> --request-id install-1'],
855
+ examples: ['notis spaces store install <listing-id> --request-id install-1 --receipt <receipt-id> --confirmed'],
727
856
  mutates: true, idempotent: true, require_auth: true, backend_call: { type: 'http', path: '/portal_spaces/store-install' },
728
- handler: ctx => remote(ctx, 'store-install', { body: { listing_id: ctx.args.listingId, request_id: requestId(ctx),
857
+ handler: ctx => remote(ctx, 'store-install', { minTimeoutMs: STORE_COPY_TIMEOUT_MS, body: { listing_id: ctx.args.listingId, request_id: requestId(ctx),
729
858
  ...(ctx.options.name ? { name: ctx.options.name } : {}), ...(ctx.options.parent ? { parent_space_id: ctx.options.parent } : {}),
730
- dry_run: Boolean(ctx.options.dryRun) } }),
859
+ ...checkedBody(ctx), dry_run: Boolean(ctx.options.dryRun) } }),
731
860
  },
732
861
  {
733
862
  command_path: ['spaces', 'store', 'update'], summary: 'Update an installed copy, keeping your changes, or resolve its conflicts.',
734
863
  when_to_use: 'Take a newer Store version: unchanged parts update, your edits stay, and parts both sides changed become conflicts you resolve.',
735
864
  args_schema: { arguments: [{ token: '<install-id>', key: 'installId', description: 'Exact install ID from store installs.' }],
736
865
  options: [{ flags: '--resolve <json>', description: 'Per conflict key: "keep_mine" or "take_theirs".' },
866
+ receiptOption, confirmedOption,
737
867
  requestOption, { flags: '--dry-run', description: 'Show the three-way plan without changing anything.' }] },
738
868
  examples: ['notis spaces store update <install-id> --request-id update-1 --dry-run',
869
+ 'notis spaces store update <install-id> --request-id update-1 --receipt <receipt-id> --confirmed',
739
870
  'notis spaces store update <install-id> --resolve \'{"skill:<key>":"keep_mine"}\' --request-id resolve-1'],
740
871
  mutates: true, idempotent: true, require_auth: true, backend_call: { type: 'http', path: '/portal_spaces/store-update' },
741
- handler: ctx => remote(ctx, 'store-update', { body: { install_id: ctx.args.installId, request_id: requestId(ctx),
742
- ...(ctx.options.resolve ? { resolution: object(ctx.options.resolve, '--resolve') } : {}), dry_run: Boolean(ctx.options.dryRun) } }),
872
+ handler: ctx => remote(ctx, 'store-update', { minTimeoutMs: STORE_COPY_TIMEOUT_MS, body: { install_id: ctx.args.installId, request_id: requestId(ctx),
873
+ ...(ctx.options.resolve ? { resolution: object(ctx.options.resolve, '--resolve') } : {}), ...checkedBody(ctx),
874
+ dry_run: Boolean(ctx.options.dryRun) } }),
743
875
  },
744
876
  {
745
877
  command_path: ['spaces', 'store', 'unpublish'], summary: 'Stop new installs of a Store listing.',
@@ -223,13 +223,32 @@ export function classifyToolMutation(toolName, args = {}) {
223
223
  return null;
224
224
  }
225
225
 
226
- const LONG_RUNNING_TOOL_TIMEOUT_MS = 600000;
226
+ export const LONG_RUNNING_TOOL_TIMEOUT_MS = 600000;
227
227
  const LONG_RUNNING_TOOL_NAMES = new Set([
228
228
  'LOCAL_NOTIS_GENERATE_IMAGE_OPENAI',
229
229
  'LOCAL_NOTIS_EDIT_IMAGE_OPENAI',
230
230
  'LOCAL_NOTIS_GENERATE_IMAGE_GEMINI',
231
231
  'LOCAL_NOTIS_EDIT_IMAGE_GEMINI',
232
+ // Waking the Cloud Computer and installing dependencies takes minutes.
233
+ 'LOCAL_NOTIS_RUN_SANDBOX_SHELL',
232
234
  ]);
235
+ // A shell call answers once its command ends, so the call itself needs the
236
+ // command's own timeout plus room for the round trip.
237
+ const SHELL_TOOL_NAMES = new Set(['LOCAL_NOTIS_RUN_SANDBOX_SHELL', 'LOCAL_NOTIS_RUN_DESKTOP_SHELL']);
238
+ export const SHELL_CALL_MARGIN_MS = 30000;
239
+
240
+ /** The CLI time limit a call needs: raised for long tools and long shell commands, never lowered. */
241
+ export function toolCallTimeoutMs(toolName, args, currentMs) {
242
+ const name = localNotisToolSlug(toolName);
243
+ let timeout = currentMs || 0;
244
+ if (LONG_RUNNING_TOOL_NAMES.has(name)) timeout = Math.max(timeout, LONG_RUNNING_TOOL_TIMEOUT_MS);
245
+ // A detached job or a job action answers at once: its timeout_ms bounds the job, not this call.
246
+ const waits = args && typeof args === 'object' && !args.detach && !args.job_id;
247
+ if (SHELL_TOOL_NAMES.has(name) && waits && Number.isFinite(args.timeout_ms) && args.timeout_ms > 0) {
248
+ timeout = Math.max(timeout, args.timeout_ms + SHELL_CALL_MARGIN_MS);
249
+ }
250
+ return timeout;
251
+ }
233
252
 
234
253
  const EXTENSION_CONTENT_TYPES = new Map([
235
254
  ['.pdf', 'application/pdf'],
@@ -314,12 +333,10 @@ export async function parseFileBindings(rawFileOptions) {
314
333
  return Promise.all(values.map((value, index) => parseFileBindingSpec(value, index)));
315
334
  }
316
335
 
317
- function ensureLongRunningToolTimeout(ctx, toolNames) {
318
- const names = Array.isArray(toolNames) ? toolNames : [toolNames];
319
- if (!names.some((name) => LONG_RUNNING_TOOL_NAMES.has(localNotisToolSlug(name)))) {
320
- return;
336
+ function ensureLongRunningToolTimeout(ctx, calls) {
337
+ for (const { name, args } of calls) {
338
+ ctx.runtime.timeoutMs = Math.max(ctx.runtime.timeoutMs || 0, toolCallTimeoutMs(name, args, ctx.runtime.timeoutMs));
321
339
  }
322
- ctx.runtime.timeoutMs = Math.max(ctx.runtime.timeoutMs || 0, LONG_RUNNING_TOOL_TIMEOUT_MS);
323
340
  }
324
341
 
325
342
  async function toolsToolkitsHandler(ctx) {
@@ -413,7 +430,7 @@ async function toolsDescribeHandler(ctx) {
413
430
  async function toolsExecHandler(ctx) {
414
431
  const requestedToolName = localNotisToolSlug(ctx.args.toolName);
415
432
  let targetMutating = classifyToolMutation(requestedToolName);
416
- ensureLongRunningToolTimeout(ctx, requestedToolName);
433
+ ensureLongRunningToolTimeout(ctx, [{ name: requestedToolName }]);
417
434
  ctx.output.emitProgress({
418
435
  phase: 'prepare',
419
436
  message: `Resolving ${requestedToolName}`,
@@ -443,6 +460,7 @@ async function toolsExecHandler(ctx) {
443
460
  ? await resolveJsonInput(rawArguments, 'arguments') || {}
444
461
  : parseMaybeJson(rawArguments, 'arguments') || {};
445
462
  targetMutating = classifyToolMutation(requestedToolName, args);
463
+ ensureLongRunningToolTimeout(ctx, [{ name: requestedToolName, args }]);
446
464
 
447
465
  if (ctx.options.dryRun) {
448
466
  if (fileBindings.length) {
@@ -601,7 +619,7 @@ async function toolsExecParallelHandler(ctx) {
601
619
  throw usageError(`calls[${i}] missing required "tool_name" string`);
602
620
  }
603
621
  }
604
- ensureLongRunningToolTimeout(ctx, calls.map((call) => localNotisToolSlug(call.tool_name)));
622
+ ensureLongRunningToolTimeout(ctx, calls.map((call) => ({ name: call.tool_name, args: call.arguments })));
605
623
 
606
624
  const data = await Promise.all(
607
625
  calls.map((call) =>
@@ -12,6 +12,7 @@ export function viewRenderCommandSpec({ screenshotOnly = false } = {}) {
12
12
  args_schema: { arguments: [{ token: '<url>', key: 'url', description: 'Current view-qualified or record link.' }], options: [
13
13
  ...(!screenshotOnly ? [{ flags: '--outputs <kinds>', description: 'Comma-separated markdown,screenshot (default both).' }] : []),
14
14
  { flags: '--width <pixels>', description: '1440 (default) or 390.' },
15
+ { flags: '--view-as <audience>', description: 'public: render the view as the public sees it (no editor-only parts).' },
15
16
  { flags: '--output-dir <path>', description: 'New output directory; defaults to a unique .notis/renders directory. Existing files are never overwritten.' },
16
17
  ] }, examples: [screenshotOnly ? 'notis spaces screenshot <view-link> --width 390' : 'notis views render <view-link> --outputs markdown,screenshot'],
17
18
  mutates: false, idempotent: true, require_auth: true,
@@ -22,12 +23,14 @@ export function viewRenderCommandSpec({ screenshotOnly = false } = {}) {
22
23
  throw usageError('Choose markdown, screenshot, or markdown,screenshot.');
23
24
  }
24
25
  const width = ctx.options.width === undefined ? 1440 : Number(ctx.options.width);
26
+ const viewAs = ctx.options.viewAs;
27
+ if (viewAs !== undefined && viewAs !== 'public') throw usageError('--view-as accepts only public.');
25
28
  const directory = resolve(ctx.options.outputDir || `.notis/renders/${randomUUID()}`);
26
29
  const controller = new AbortController(), cancel = () => controller.abort();
27
30
  process.once('SIGINT', cancel); process.once('SIGTERM', cancel);
28
31
  try {
29
32
  const { result, artifacts } = await renderViewWithCliRuntime({ runtime: ctx.runtime,
30
- url: ctx.args.url, outputs, width, directory, signal: controller.signal });
33
+ url: ctx.args.url, outputs, width, viewAs, directory, signal: controller.signal });
31
34
  const data = { ...result, artifacts };
32
35
  if (data.screenshot) {
33
36
  const { data_base64: _bytes, ...metadata } = data.screenshot;
@@ -395,10 +395,28 @@ function agentPaths(agentId, home) {
395
395
  throw new Error(`Unsupported agent: ${agentId}`);
396
396
  }
397
397
 
398
- export function shouldInstallLocalAgentSetup(env = process.env, home = homedir()) {
398
+ // The cloud computer's root. Present only inside the user's Vercel sandbox.
399
+ const CLOUD_COMPUTER_ROOT = '/vercel/sandbox';
400
+
401
+ /**
402
+ * Whether this process runs on the Notis cloud computer. A test run pins the
403
+ * answer with NOTIS_TEST_CLOUD_COMPUTER=0 or 1, so a suite run on the cloud
404
+ * computer reads the same as one run anywhere else.
405
+ */
406
+ export function onCloudComputer(env = process.env) {
407
+ const pinned = env.NODE_ENV === 'test' ? env.NOTIS_TEST_CLOUD_COMPUTER : undefined;
408
+ if (pinned === '0' || pinned === '1') return pinned === '1';
409
+ return existsSync(CLOUD_COMPUTER_ROOT);
410
+ }
411
+
412
+ export function shouldInstallLocalAgentSetup(
413
+ env = process.env,
414
+ home = homedir(),
415
+ { cloudComputer = () => onCloudComputer(env) } = {},
416
+ ) {
399
417
  if (env.NOTIS_JWT || env.NOTIS_AGENT === '1' || env.NOTIS_DELEGATED_CONTEXT === '1') return false;
400
418
  if (env.CONDUCTOR_IS_LOCAL === '0') return false;
401
- if (existsSync('/vercel/sandbox')) return false;
419
+ if (cloudComputer()) return false;
402
420
  return Boolean(home);
403
421
  }
404
422
 
@@ -361,7 +361,8 @@ export function loadDesignRules({ rulesPath = resolveDesignRulesPath(), profile
361
361
  id: rule.id,
362
362
  severity: typeof rule.toolkit_piece === 'string'
363
363
  ? (livePieces.has(rule.toolkit_piece) ? 'error' : 'warn')
364
- : rule.severity === 'warn' ? 'warn' : 'error',
364
+ // profile_severity.<profile> overrides severity for that profile only.
365
+ : (rule.profile_severity?.[profile] ?? rule.severity) === 'warn' ? 'warn' : 'error',
365
366
  toolkitPiece: typeof rule.toolkit_piece === 'string' ? rule.toolkit_piece : null,
366
367
  scope: rule.scope === 'file' ? 'file' : 'line',
367
368
  regex: new RegExp(rule.pattern, rule.scope === 'file' ? '' : 'gm'),
@@ -2022,6 +2022,19 @@ export function saveSpaceVerification(projectDir, diagnostic) {
2022
2022
  });
2023
2023
  }
2024
2024
 
2025
+ /** The loading-state screenshots of the last verify, `pending-<width>-<locale>.png` beside the diagnostic. */
2026
+ export function saveSpacePendingScreenshots(projectDir, screenshots) {
2027
+ if (!screenshots?.length) return [];
2028
+ return withAppReleaseWorkspace(projectDir, (workspace) => screenshots.map(({ width, locale, png }) => {
2029
+ if (![390, 1440].includes(width) || !['en', 'fr'].includes(locale)) throw usageError('Unsafe pending screenshot name.');
2030
+ const name = `pending-${width}-${locale}.png`;
2031
+ // Replace the previous verify's image without following a planted link.
2032
+ rmSync(name, { force: true });
2033
+ writeFileSync(name, png, { flag: 'wx', mode: 0o600 });
2034
+ return join(workspace.projectDir, '.notis', name);
2035
+ }));
2036
+ }
2037
+
2025
2038
  /** Retain the original CAS after an uncertain publish response, across CLI exits. */
2026
2039
  export function spacePublicationIntent(projectDir, identity, create = null) {
2027
2040
  const name = `space-publish-${createHash('sha256').update(JSON.stringify(identity)).digest('hex')}.json`;
@@ -14,6 +14,11 @@ export function quoteShellArgument(value) {
14
14
  return `'${String(value).replace(/'/g, `'"'"'`)}'`;
15
15
  }
16
16
 
17
+ /** The CLI as this profile runs it, ready to take a subcommand: `npx --package @notis_ai/cli@<tag> -- notis [--profile x]`. */
18
+ export function cliCommandWithProfile(runtime = {}) {
19
+ return `${cliNpx(runtime)}${profileSuffix(runtime.profileName)}`;
20
+ }
21
+
17
22
  function profileSuffix(profileName) {
18
23
  return profileName && profileName !== 'default'
19
24
  ? ` --profile ${quoteShellArgument(profileName)}`
@@ -10,6 +10,9 @@
10
10
  * one command worth documenting, including for nightly accounts.
11
11
  */
12
12
 
13
+ import { existsSync } from 'node:fs';
14
+ import { isAbsolute } from 'node:path';
15
+
13
16
  export const RELEASE_CHANNELS = ['stable', 'nightly'];
14
17
  // Keep equal to the dist-tags in scripts/release-channels.cjs (a test checks).
15
18
  const CHANNEL_TAGS = { stable: 'latest', nightly: 'nightly' };
@@ -57,8 +60,19 @@ export function packageTagForChannel(channel) {
57
60
  return CHANNEL_TAGS[channel] || CHANNEL_TAGS.stable;
58
61
  }
59
62
 
60
- export function cliCommandForChannel(channel) {
61
- return `npx --package ${CLI_PACKAGE_NAME}@${packageTagForChannel(channel)} -- notis`;
63
+ // Set by the `notis` command the installer writes (server/config/cli/install.sh) on a computer without Node.js:
64
+ // npx is not on that shell's PATH, so every command this CLI prints has to name the installed command instead.
65
+ export const CLI_LAUNCHER_ENV = 'NOTIS_CLI_LAUNCHER';
66
+
67
+ /** The installed `notis` command this process runs through, or null. Only an absolute path that exists counts. */
68
+ export function installedLauncher(env = process.env) {
69
+ const value = env[CLI_LAUNCHER_ENV];
70
+ if (typeof value !== 'string' || !isAbsolute(value) || !existsSync(value)) return null;
71
+ return /^[A-Za-z0-9_./-]+$/.test(value) ? value : `'${value.replace(/'/g, `'"'"'`)}'`;
72
+ }
73
+
74
+ export function cliCommandForChannel(channel, env = process.env) {
75
+ return installedLauncher(env) || `npx --package ${CLI_PACKAGE_NAME}@${packageTagForChannel(channel)} -- notis`;
62
76
  }
63
77
 
64
78
  /**