@fiodos/cli 0.1.19 → 0.1.20

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fiodos/cli",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "Fiodos CLI — analyzes your app's source code and generates the in-app voice-agent manifest, then wires the orb. Powers `npx @fiodos/cli analyze`.",
5
5
  "type": "commonjs",
6
6
  "bin": {
package/src/aiAnalyze.js CHANGED
@@ -51,7 +51,7 @@ function resolveModel(model) {
51
51
  // focus the analysis — which folder/app, what to emphasize or ignore — but never
52
52
  // override the system rules, invent actions, skip verification or change the
53
53
  // output schema). When empty, the prompt is byte-identical to a spec-less run.
54
- const MAX_USER_SPEC_CHARS = 1000;
54
+ const MAX_USER_SPEC_CHARS = 2500;
55
55
 
56
56
  function sanitizeUserSpec(raw) {
57
57
  if (raw == null) return '';
@@ -88,9 +88,10 @@ AppManifest (all fields required unless noted):
88
88
  "routes": [{
89
89
  "intent": string (snake_case, UNIQUE across routes AND actions),
90
90
  "label": string, "route": string (opaque route string for the app's navigation adapter — an expo-router href, a URL path, or "BACK"),
91
- "description": string (one line: WHAT THIS SCREEN SHOWS and what the user can do there),
91
+ "description": string (one DISTINCTIVE line: what THIS screen shows and what the user does there, phrased so it can NOT be confused with sibling screens — name the concrete content/entities unique to it. e.g. "Lists the registered people/accounts; from here you open and manage each individual user" — NOT a generic "a screen of the app"),
92
+ "bubblePrompt": string (SHORT user-facing call-to-action shown in a small "thought bubble" next to the assistant orb WHEN THE USER IS ON THIS SCREEN. One friendly question/offer in the app's language, max ~6 words, ending naturally (often a "?"). Distinct per screen and tied to what the user does HERE — e.g. a cart screen: "¿Finalizar tu compra?"; a users list: "¿Buscar un usuario?"; a login screen: "¿Quieres iniciar sesión?". NOT a description, NOT the label verbatim. Optional — omit if nothing natural fits),
92
93
  "actionIntents": string[] (OPTIONAL: intents of the actions a user performs FROM this screen — the action handlers actually wired into THIS screen's component/page. Use exact action intent ids from the "actions" array; [] if none. Advisory only, never gates anything),
93
- "examples": string[] (3-4 natural voice phrases, REQUIRED non-empty)
94
+ "examples": string[] (5-8 natural voice phrases a user might say to reach this screen, REQUIRED non-empty. Include SYNONYMS and PARAPHRASES that do NOT contain the literal label word, so the agent recognizes indirect requests — e.g. for a "Users" screen: "ver usuarios", "la pantalla donde vemos a las personas", "muéstrame las cuentas", "lista de gente registrada", "quiénes están dados de alta". Vary the verb and the noun; cover the obvious phrasing AND at least two oblique ones. Avoid near-duplicates that differ only in a word)
94
95
  }],
95
96
  "actions": [{
96
97
  "intent": string (snake_case, UNIQUE across routes AND actions),
@@ -106,7 +107,7 @@ AppManifest (all fields required unless noted):
106
107
  "confirmationMessageTemplate": string (REQUIRED if requireConfirmation true),
107
108
  "parameters": { "<name>": {"type": "string"|"number"|"boolean", "required": boolean, "description": string (non-empty)} },
108
109
  "contextRequirements": {"requiresVisibleContent"?: bool, "requiresAuth"?: bool} (optional; set requiresAuth: true for actions that need a signed-in user — see the REQUIRES-AUTH rule below),
109
- "examples": string[] (3-4 natural voice phrases, REQUIRED non-empty)
110
+ "examples": string[] (5-8 natural voice phrases a user might say to trigger this action, REQUIRED non-empty. Include SYNONYMS and PARAPHRASES that do NOT rely on the literal label word, so indirect requests are recognized — e.g. for "Empty cart": "vacía el carrito", "quita todo lo que tengo", "borra todos los productos de la cesta". Vary verb and phrasing; avoid near-duplicates)
110
111
  }],
111
112
  "policies": {"requireConfirmationForDestructive": true, "allowedWithoutAuth": string[], "contextRetentionTurns": 5}
112
113
  }
@@ -217,8 +218,17 @@ This is the context the agent reads to understand the app, so it can reason inst
217
218
  - relatedIntents: other manifest intents this naturally flows into or from (e.g. add-to-cart → checkout). Use the exact intent ids; [] if none.
218
219
  - route description: what the screen displays and what can be done there.
219
220
  - route actionIntents: for each screen, the intents of the actions whose handlers are actually wired into THAT screen's component/page (what the user can DO there). Use exact action intent ids; omit or [] when the screen is purely informational/navigational. This is "what you can do here" context — it never restricts the agent.
221
+ - route bubblePrompt: a SHORT, friendly CTA (in the app's language, ~6 words max) the assistant shows beside the orb on THAT screen to invite the user to act — e.g. login screen → "¿Quieres iniciar sesión?", cart → "¿Finalizar tu compra?", users list → "¿Buscar un usuario?". Make it distinct per screen and grounded in what the user does there; it is end-user copy, not a description. Omit when nothing natural fits.
220
222
  - appType/appFlow: the app category and its main end-to-end flow.
221
- Be precise and concise — quality over volume. Never pad.
223
+
224
+ DISTINCTIVENESS (this is what prevents the agent picking the wrong screen/action):
225
+ - Two screens are EASILY confused when their descriptions are generic. Write each route's description so it names the concrete entities/content unique to THAT screen and could not be copy-pasted onto a sibling. Bad (confusable): "Dashboard screen of the app." Good: "Aggregate overview with KPI cards (totals of users, projects, revenue); it does NOT list individual records." vs "Lists individual user records with per-user detail."
226
+ - EXAMPLES are how the agent maps indirect speech to the right intent. For every route AND action, after the obvious phrasing add at least TWO oblique phrasings that a real user would say WITHOUT the label word (descriptive references to the content, e.g. "where we see the people" for a Users screen, "the page with the totals/summary" for an Overview screen). This directly reduces cross-screen confusion. Make examples DISTINCT across sibling screens — never give two screens an example that would fit both.
227
+
228
+ SENSITIVE ACTIONS — EXTRA DETAIL (still static, no per-turn change):
229
+ For any action with requireConfirmation true (delete/remove, logout, place/cancel orders, spend money, irreversible changes), make description, preconditions and effect noticeably MORE detailed than for normal actions: spell out exactly what is affected, what is irreversible, and the precise post-state. This richer manual lives in the static prompt so the agent reasons carefully about the stakes; it does NOT change the confirmation flow (the engine still enforces it).
230
+
231
+ Be precise and DISTINCTIVE. Descriptions stay one tight line each (no padding), but examples should be VARIED and cover several real phrasings (synonyms/paraphrases are wanted, near-duplicate filler is not).
222
232
 
223
233
  Also return EVIDENCE for every route and action: the file (exact relative path as given in the FILE headers) and symbol (function/property name) in the provided code that justifies it. Evidence is verified mechanically afterwards: an action whose file or symbol does not exist is dropped, and unverifiable items count against you.
224
234
 
@@ -354,12 +364,75 @@ function buildUserPrompt(appMeta, files, omitted, staticRoutes, surface = null,
354
364
  );
355
365
  }
356
366
 
367
+ /**
368
+ * Extract the FIRST complete, balanced JSON object from `text`, scanning from
369
+ * the first `{` to its matching `}` while respecting string literals and escape
370
+ * sequences (so braces inside string values don't throw the counter off).
371
+ * Returns the substring, or null when no balanced object is found.
372
+ *
373
+ * This is what makes parsing robust to a model that emits trailing prose (or a
374
+ * second brace-bearing sentence) after an otherwise valid JSON object — the
375
+ * cause of "Unexpected non-whitespace character after JSON at position N".
376
+ */
377
+ function extractBalancedJsonObject(text) {
378
+ const start = text.indexOf('{');
379
+ if (start < 0) return null;
380
+ let depth = 0;
381
+ let inString = false;
382
+ let escaped = false;
383
+ for (let i = start; i < text.length; i += 1) {
384
+ const ch = text[i];
385
+ if (escaped) {
386
+ escaped = false;
387
+ continue;
388
+ }
389
+ if (ch === '\\') {
390
+ if (inString) escaped = true;
391
+ continue;
392
+ }
393
+ if (ch === '"') {
394
+ inString = !inString;
395
+ continue;
396
+ }
397
+ if (inString) continue;
398
+ if (ch === '{') {
399
+ depth += 1;
400
+ } else if (ch === '}') {
401
+ depth -= 1;
402
+ if (depth === 0) return text.slice(start, i + 1);
403
+ }
404
+ }
405
+ return null;
406
+ }
407
+
357
408
  function parseJsonContent(raw) {
358
409
  let trimmed = (raw || '').trim();
359
410
  if (!trimmed) return {};
411
+ // Strip a leading/trailing markdown code fence if the model wrapped its JSON.
360
412
  if (trimmed.startsWith('```')) {
361
413
  trimmed = trimmed.replace(/^```(?:json)?\s*/i, '').replace(/\s*```\s*$/i, '').trim();
362
414
  }
415
+ // 1) Happy path: the response is exactly one JSON value.
416
+ try {
417
+ return JSON.parse(trimmed);
418
+ } catch {
419
+ /* fall through to tolerant extraction */
420
+ }
421
+ // 2) Tolerant path: take the FIRST balanced {…} object and ignore anything
422
+ // the model appended after it (trailing prose, a second sentence, a stray
423
+ // fence). A brace-aware scan beats indexOf('{')+lastIndexOf('}'), which
424
+ // OVER-captures when the trailing text itself contains braces — the exact
425
+ // failure mode ("Unexpected non-whitespace character after JSON").
426
+ const balanced = extractBalancedJsonObject(trimmed);
427
+ if (balanced) {
428
+ try {
429
+ return JSON.parse(balanced);
430
+ } catch {
431
+ /* fall through to the legacy widest-slice as a last resort */
432
+ }
433
+ }
434
+ // 3) Last resort: widest {…} slice (previous behavior) so we never regress on
435
+ // inputs the old path could handle.
363
436
  const start = trimmed.indexOf('{');
364
437
  const end = trimmed.lastIndexOf('}');
365
438
  if (start < 0 || end <= start) throw new Error('Model response is not JSON');
@@ -580,4 +653,7 @@ module.exports = {
580
653
  sanitizeUserSpec,
581
654
  MAX_USER_SPEC_CHARS,
582
655
  manifestSchemaDoc,
656
+ // Exported so the response parser is unit-testable without a live AI call.
657
+ parseJsonContent,
658
+ extractBalancedJsonObject,
583
659
  };
package/src/index.js CHANGED
@@ -739,9 +739,32 @@ function detectPlatform(appRoot, appDir) {
739
739
  ) {
740
740
  return 'web';
741
741
  }
742
+ // The Fiodos SDK the developer installed states their target platform — the
743
+ // strongest intent signal in a mixed monorepo whose root has no framework dep
744
+ // of its own (e.g. EVO: root has @fiodos/react-native, the real Expo app lives
745
+ // in mobile/mobile/). Without this we'd wrongly default a mobile repo to 'web'
746
+ // and run the web orb wiring against a sibling Next.js app.
747
+ const sdkPlatform = fiodosSdkPlatform(deps);
748
+ if (sdkPlatform) return sdkPlatform;
742
749
  return appDir ? 'mobile' : 'web';
743
750
  }
744
751
 
752
+ /**
753
+ * Platform implied by the installed Fiodos SDK. Returns 'mobile' | 'web' | null
754
+ * (null when both or neither are present — no unambiguous signal).
755
+ */
756
+ function fiodosSdkPlatform(deps) {
757
+ if (!deps) return null;
758
+ const mobile = Boolean(deps['@fiodos/react-native']);
759
+ const web = Boolean(
760
+ deps['@fiodos/react'] || deps['@fiodos/vue'] || deps['@fiodos/svelte'] ||
761
+ deps['@fiodos/angular'] || deps['@fiodos/web-core'],
762
+ );
763
+ if (mobile && !web) return 'mobile';
764
+ if (web && !mobile) return 'web';
765
+ return null;
766
+ }
767
+
745
768
  function readAppMeta(appRoot) {
746
769
  const meta = { name: path.basename(appRoot), description: '', dependencies: [] };
747
770
  const pkgPath = path.join(appRoot, 'package.json');
@@ -103,6 +103,30 @@ function tail(s, n = 60) {
103
103
  return lines.slice(-n).join('\n').trim();
104
104
  }
105
105
 
106
+ /** Compact build failure for the terminal — not the full next/vite log. */
107
+ function summarizeBuildOutput(raw, maxLines = 4) {
108
+ const lines = String(raw || '').split('\n');
109
+ const picked = [];
110
+ const push = (line) => {
111
+ const t = line.trim();
112
+ if (!t || picked.includes(t)) return;
113
+ if (/telemetry|Learn more:/i.test(t)) return;
114
+ if (/^▲ Next\.js/i.test(t)) return;
115
+ picked.push(t);
116
+ };
117
+ for (const line of lines) {
118
+ if (
119
+ /Module not found|Can't resolve|Failed to compile|error TS\d+|SyntaxError|ENOENT/i.test(line)
120
+ ) {
121
+ push(line);
122
+ }
123
+ }
124
+ if (picked.length === 0) {
125
+ for (const line of lines.slice(-maxLines)) push(line);
126
+ }
127
+ return picked.slice(0, maxLines).join('\n').trim();
128
+ }
129
+
106
130
  async function runPostWireTest(appRoot, opts = {}) {
107
131
  const timeoutMs = opts.timeoutMs || 240000;
108
132
  if (!fs.existsSync(path.join(appRoot, 'node_modules'))) {
@@ -136,4 +160,4 @@ async function runPostWireTest(appRoot, opts = {}) {
136
160
  return { ok: res.status === 0, stage: chosen.stage, command: chosen.label, output };
137
161
  }
138
162
 
139
- module.exports = { runPostWireTest, chooseCommand };
163
+ module.exports = { runPostWireTest, chooseCommand, summarizeBuildOutput, readPkg };
@@ -51,12 +51,49 @@ function platformDepsMatch(deps, platform) {
51
51
  return false;
52
52
  }
53
53
 
54
- function tryCandidate(appRoot, rel, platform, score) {
54
+ /**
55
+ * How "complete" / runnable a candidate app folder looks. A monorepo can nest a
56
+ * thin source wrapper (e.g. mobile/) around the REAL runnable app (mobile/mobile/
57
+ * with app.json, the expo dep, native ios/android dirs). Conventional-name
58
+ * matching alone would pick the wrapper; this score lets the real app win.
59
+ */
60
+ function appCompleteness(dir, platform) {
61
+ let score = 0;
62
+ const has = (rel) => fs.existsSync(path.join(dir, rel));
63
+ if (has('app') || has('src') || has('pages')) score += 2;
64
+ let pkg = {};
65
+ try {
66
+ pkg = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8'));
67
+ } catch {
68
+ /* ignore */
69
+ }
70
+ const deps = { ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}) };
71
+ const scripts = pkg.scripts || {};
72
+ if (pkg.main) score += 2;
73
+ if (platform === 'mobile') {
74
+ if (has('app.json') || has('app.config.js') || has('app.config.ts')) score += 4;
75
+ if (deps.expo) score += 4;
76
+ if (has('ios') || has('android')) score += 2;
77
+ if (scripts.start || scripts.ios || scripts.android) score += 1;
78
+ } else if (platform === 'web') {
79
+ if (
80
+ has('next.config.js') || has('next.config.ts') || has('next.config.mjs') ||
81
+ has('vite.config.js') || has('vite.config.ts') || has('index.html') ||
82
+ has('angular.json') || has('svelte.config.js')
83
+ ) {
84
+ score += 4;
85
+ }
86
+ if (scripts.build || scripts.dev) score += 1;
87
+ }
88
+ return score;
89
+ }
90
+
91
+ function tryCandidate(appRoot, rel, platform, nameScore) {
55
92
  const dir = path.join(appRoot, rel);
56
93
  if (!fs.existsSync(dir) || !fs.statSync(dir).isDirectory()) return null;
57
94
  const deps = readDeps(path.join(dir, 'package.json'));
58
95
  if (!platformDepsMatch(deps, platform)) return null;
59
- return { root: dir, rel, score, reason: rel };
96
+ return { root: dir, rel, nameScore, complete: appCompleteness(dir, platform), reason: rel };
60
97
  }
61
98
 
62
99
  /**
@@ -112,8 +149,15 @@ function resolveAnalysisRoot(appRoot, platform) {
112
149
  return { root: abs, scoped: false, reason: 'no sub-app detected' };
113
150
  }
114
151
 
115
- // Prefer higher score, then shorter path (closer to root).
116
- candidates.sort((a, b) => b.score - a.score || a.rel.length - b.rel.length);
152
+ // Prefer the most complete/runnable app first (so a real nested app beats a
153
+ // thin same-named wrapper), then the conventional-name confidence, then the
154
+ // shorter path (closer to root).
155
+ candidates.sort(
156
+ (a, b) =>
157
+ b.complete - a.complete ||
158
+ b.nameScore - a.nameScore ||
159
+ a.rel.length - b.rel.length,
160
+ );
117
161
  const best = candidates[0];
118
162
  return {
119
163
  root: best.root,
package/src/verify.js CHANGED
@@ -31,6 +31,63 @@ function fileHasIdentifier(content, identifier) {
31
31
  return re.test(content);
32
32
  }
33
33
 
34
+ /**
35
+ * Upper bound on examples kept per route/action. The enriched prompt asks the
36
+ * model for 5-8 varied phrasings; this cap protects the cacheable system prompt
37
+ * from a runaway list while leaving generous room for real synonyms.
38
+ */
39
+ const MAX_EXAMPLES = 10;
40
+
41
+ /**
42
+ * Sanitize a manifest item's `examples` array WITHOUT ever dropping the item:
43
+ * trims, removes empties, deduplicates case-insensitively (first spelling wins),
44
+ * and caps the count. Fail-open: when the model returned nothing usable, falls
45
+ * back to a single phrase derived from the label/intent so the core validator's
46
+ * "non-empty examples" rule still passes (today's contract, never weakened).
47
+ */
48
+ function sanitizeExamples(raw, fallbackLabel) {
49
+ const list = Array.isArray(raw) ? raw : [];
50
+ const seen = new Set();
51
+ const cleaned = [];
52
+ for (const entry of list) {
53
+ if (typeof entry !== 'string') continue;
54
+ const phrase = entry.replace(/\s+/g, ' ').trim();
55
+ if (!phrase) continue;
56
+ const key = phrase.toLowerCase();
57
+ if (seen.has(key)) continue;
58
+ seen.add(key);
59
+ cleaned.push(phrase);
60
+ if (cleaned.length >= MAX_EXAMPLES) break;
61
+ }
62
+ if (cleaned.length === 0) {
63
+ const fallback = String(fallbackLabel || '').replace(/\s+/g, ' ').trim();
64
+ if (fallback) cleaned.push(fallback);
65
+ }
66
+ return cleaned;
67
+ }
68
+
69
+ /**
70
+ * Max length (chars) of a route's `bubblePrompt` (the short orb CTA). The prompt
71
+ * asks for ~6 words; this is a generous hard cap so a runaway sentence can never
72
+ * bloat the bubble UI or the served manifest.
73
+ */
74
+ const MAX_BUBBLE_PROMPT = 80;
75
+
76
+ /**
77
+ * Sanitize a route's `bubblePrompt` (fail-open, item never dropped): trims,
78
+ * collapses whitespace, strips wrapping quotes, and caps the length. Returns
79
+ * undefined when there is nothing usable (the SDK then derives a fallback from
80
+ * the label/examples), so a bad value never sticks.
81
+ */
82
+ function sanitizeBubblePrompt(raw) {
83
+ if (typeof raw !== 'string') return undefined;
84
+ let s = raw.replace(/\s+/g, ' ').trim();
85
+ s = s.replace(/^["'«»“”]+|["'«»“”]+$/g, '').trim();
86
+ if (!s) return undefined;
87
+ if (s.length > MAX_BUBBLE_PROMPT) s = s.slice(0, MAX_BUBBLE_PROMPT).trim();
88
+ return s || undefined;
89
+ }
90
+
34
91
  /** Normalize an expo-router href for comparison: strip (groups), trailing /index. */
35
92
  function normalizeHref(href) {
36
93
  return ('/' + String(href || '')
@@ -197,8 +254,33 @@ function verifyManifest(manifest, evidence, sentFiles, staticRoutes, opts = {})
197
254
  else delete route.actionIntents;
198
255
  }
199
256
 
257
+ // Examples hygiene (fail-open): trim, dedupe and cap the enriched phrasings on
258
+ // every surviving route and action. Never drops the item; falls back to the
259
+ // label so the core validator's non-empty-examples rule still holds.
260
+ for (const route of dedupedRoutes) {
261
+ if (route.route === 'BACK') continue;
262
+ route.examples = sanitizeExamples(route.examples, route.label || route.intent);
263
+ let bubble = sanitizeBubblePrompt(route.bubblePrompt);
264
+ if (!bubble) {
265
+ try {
266
+ const { deriveBubblePromptFromContext, resolveMessages } = require('@fiodos/core');
267
+ bubble = sanitizeBubblePrompt(
268
+ deriveBubblePromptFromContext(route, resolveMessages('en'), {
269
+ locale: 'en',
270
+ actions: dedupedActions,
271
+ }),
272
+ );
273
+ } catch {
274
+ /* core unavailable — leave bubble unset */
275
+ }
276
+ }
277
+ if (bubble) route.bubblePrompt = bubble;
278
+ else delete route.bubblePrompt;
279
+ }
280
+
200
281
  // Schema coercion the model sometimes needs (same as the old engine).
201
282
  for (const action of dedupedActions) {
283
+ action.examples = sanitizeExamples(action.examples, action.label || action.intent);
202
284
  for (const spec of Object.values(action.parameters || {})) {
203
285
  if (spec.type === 'integer' || spec.type === 'float') spec.type = 'number';
204
286
  else if (!['string', 'number', 'boolean'].includes(spec.type)) spec.type = 'string';
@@ -217,4 +299,4 @@ function verifyManifest(manifest, evidence, sentFiles, staticRoutes, opts = {})
217
299
  };
218
300
  }
219
301
 
220
- module.exports = { verifyManifest, normalizeHref };
302
+ module.exports = { verifyManifest, normalizeHref, sanitizeExamples, MAX_EXAMPLES };
package/src/wireWeb.js CHANGED
@@ -13,7 +13,7 @@
13
13
  const fs = require('fs');
14
14
  const path = require('path');
15
15
  const readline = require('readline');
16
- const { runPostWireTest } = require('./postWireTest');
16
+ const { runPostWireTest, summarizeBuildOutput, readPkg } = require('./postWireTest');
17
17
  const {
18
18
  assessMount,
19
19
  describePlan,
@@ -173,8 +173,49 @@ function askYesNo(question) {
173
173
  });
174
174
  }
175
175
 
176
+ const WEB_SDK_BY_FRAMEWORK = {
177
+ vue: '@fiodos/vue',
178
+ svelte: '@fiodos/svelte',
179
+ sveltekit: '@fiodos/svelte',
180
+ angular: '@fiodos/angular',
181
+ };
182
+
183
+ function expectedWebSdk(framework) {
184
+ return WEB_SDK_BY_FRAMEWORK[framework] || '@fiodos/react';
185
+ }
186
+
187
+ /**
188
+ * Detects the one misconfiguration that silently breaks the build: the developer
189
+ * installed the MOBILE SDK (@fiodos/react-native) in a web app. The mount writes
190
+ * `import { FiodosAgent } from '@fiodos/react'` (or the framework SDK), so the
191
+ * bundler then dies on "Can't resolve". We catch it up front and print a short,
192
+ * actionable note instead of dumping the whole build log.
193
+ *
194
+ * If no Fiodos SDK is installed at all we stay silent and let the mount proceed
195
+ * (the dashboard install step / post-wire build covers that path), so this never
196
+ * blocks a clean integration that simply hasn't run npm install yet.
197
+ */
198
+ function webSdkMissing(appRoot, framework) {
199
+ const pkg = readPkg(appRoot);
200
+ const deps = { ...(pkg.dependencies || {}), ...(pkg.devDependencies || {}) };
201
+ const expected = expectedWebSdk(framework);
202
+ if (deps[expected] || deps['@fiodos/web-core']) return null;
203
+ if (deps['@fiodos/react-native']) {
204
+ return (
205
+ `installed @fiodos/react-native, but this web app needs ${expected} — ` +
206
+ `run npm install ${expected} @fiodos/core`
207
+ );
208
+ }
209
+ return null;
210
+ }
211
+
176
212
  function printSnippet(target, framework, colors, appRoot, reason) {
177
213
  const { blue, cyan, dim, reset } = colors;
214
+ if (reason && reason.includes('@fiodos/react-native')) {
215
+ console.error(`\n${cyan}◉${reset} ${blue}Fiodos${reset} · ${dim}${reason}${reset}`);
216
+ console.error(`${dim}Then re-run analyze — the orb mount will be automatic.${reset}\n`);
217
+ return;
218
+ }
178
219
  const ts = !target || target.ext === '.tsx';
179
220
  console.error(`\n${cyan}◉${reset} ${blue}Fiodos${reset} · ${dim}add the orb to your web app (copy this):${reset}`);
180
221
  if (reason) {
@@ -252,6 +293,12 @@ async function wireWebOrb(appRoot, opts = {}) {
252
293
  return { status: 'printed', reason: plan.reason };
253
294
  }
254
295
 
296
+ const sdkGap = webSdkMissing(appRoot, framework);
297
+ if (sdkGap) {
298
+ printSnippet(target, framework, colors, appRoot, sdkGap);
299
+ return { status: 'printed', reason: sdkGap };
300
+ }
301
+
255
302
  if (!assumeYes) {
256
303
  printMountPreview(plan, colors);
257
304
  }
@@ -313,7 +360,12 @@ async function wireWebOrb(appRoot, opts = {}) {
313
360
  if (baseline.ok) {
314
361
  // Built before, fails now → the mount is the regression. Keep it reverted.
315
362
  printSnippet(target, framework, colors, appRoot, `mount caused a build regression — reverted (${test.command})`);
316
- return { status: 'reverted', file: plan.rel, test, reason: test.output };
363
+ return {
364
+ status: 'reverted',
365
+ file: plan.rel,
366
+ test,
367
+ reason: summarizeBuildOutput(test.output),
368
+ };
317
369
  }
318
370
  // It was already not building (or not verifiable) before us → keep the orb.
319
371
  applyMount(plan);
@@ -348,8 +400,11 @@ function reportWireResult(result, colors = {}, opts = {}) {
348
400
  console.error(`${tag} · ${dim || ''}automatic mount not possible${result.reason ? `: ${result.reason}` : ''}. Paste the snippet above.${reset || ''}`);
349
401
  break;
350
402
  case 'reverted':
351
- console.error(`${tag} · ✗ mount reverted — app would not build. Paste the snippet above or fix manually.`);
352
- if (result.reason) console.error(`${dim}${result.reason}${reset}`);
403
+ console.error(`${tag} · ✗ mount reverted — app would not build.`);
404
+ if (result.reason) {
405
+ console.error(`${dim}${result.reason}${reset}`);
406
+ }
407
+ console.error(`${tag} · ${dim || ''}Fix the issue above, then re-run analyze or paste the snippet.${reset || ''}`);
353
408
  break;
354
409
  case 'failed':
355
410
  console.error(`${tag} · ✗ could not safely edit ${result.file}. Paste the snippet above.`);