@fiodos/cli 0.1.2 → 0.1.3

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.2",
3
+ "version": "0.1.3",
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/index.js CHANGED
@@ -396,6 +396,7 @@ async function main() {
396
396
  colors: fyodosTermColors(),
397
397
  assumeYes,
398
398
  noWire,
399
+ runTest: !process.argv.includes('--no-wire-test'),
399
400
  });
400
401
  reportWireResult(result, fyodosTermColors());
401
402
  }
package/src/wireWeb.js CHANGED
@@ -206,7 +206,7 @@ function printMountPreview(plan, colors) {
206
206
  }
207
207
 
208
208
  async function wireWebOrb(appRoot, opts = {}) {
209
- const { colors = {}, assumeYes = false, noWire = false } = opts;
209
+ const { colors = {}, assumeYes = false, noWire = false, runTest = true } = opts;
210
210
  if (noWire) return { status: 'skipped' };
211
211
 
212
212
  const framework = detectFramework(appRoot);
@@ -232,20 +232,53 @@ async function wireWebOrb(appRoot, opts = {}) {
232
232
  return { status: 'declined', file: plan.rel };
233
233
  }
234
234
 
235
+ const build = async () => {
236
+ try {
237
+ return await runPostWireTest(appRoot, { timeoutMs: 180000 });
238
+ } catch (e) {
239
+ return { ok: false, stage: 'runner', command: '(runner)', output: String((e && e.message) || e) };
240
+ }
241
+ };
242
+
235
243
  const backups = backupFiles(plan.files);
236
244
  try {
237
245
  applyMount(plan);
238
246
  if (!verifyMounted(plan)) {
239
- throw new Error('post-edit verification failed — FiodosAgent not found in edited files');
247
+ revertFiles(backups);
248
+ printSnippet(target, framework, colors, appRoot, 'post-edit verification failed — FiodosAgent not found in edited files');
249
+ return { status: 'failed', file: plan.rel };
240
250
  }
241
- const test = await runPostWireTest(appRoot, { timeoutMs: 180000 });
242
- if (!test.ok && test.stage !== 'skipped-no-deps') {
251
+
252
+ // The orb is a single, trivial component mount — it must APPEAR. We therefore
253
+ // only revert when WE are demonstrably the cause: the app built fine on its
254
+ // own but breaks once the orb is mounted (e.g. the SDK package isn't installed
255
+ // yet). A pre-existing build failure, a timeout, or a missing toolchain must
256
+ // NOT make the orb vanish — that was the silent "orb never shows up" bug.
257
+ // Fast path: one build. Only when it fails do we spend a second build (on the
258
+ // reverted original) to tell "we broke it" from "it was already broken".
259
+ if (runTest) {
260
+ const test = await build();
261
+ if (test.ok || test.stage === 'skipped-no-deps') {
262
+ writeConsentDoc(appRoot, plan);
263
+ return { status: 'added', file: plan.rel, test };
264
+ }
265
+ // Build failed with the orb mounted — was the app building WITHOUT it?
243
266
  revertFiles(backups);
244
- printSnippet(target, framework, colors, appRoot, `build/typecheck failed after mount — reverted (${test.command})`);
245
- return { status: 'reverted', file: plan.rel, test, reason: test.output };
267
+ const baseline = await build();
268
+ if (baseline.ok) {
269
+ // Built before, fails now → the mount is the regression. Keep it reverted.
270
+ printSnippet(target, framework, colors, appRoot, `mount caused a build regression — reverted (${test.command})`);
271
+ return { status: 'reverted', file: plan.rel, test, reason: test.output };
272
+ }
273
+ // It was already not building (or not verifiable) before us → keep the orb.
274
+ applyMount(plan);
275
+ verifyMounted(plan);
276
+ writeConsentDoc(appRoot, plan);
277
+ return { status: 'added', file: plan.rel, test, preexistingFailure: true };
246
278
  }
279
+
247
280
  writeConsentDoc(appRoot, plan);
248
- return { status: 'added', file: plan.rel, test };
281
+ return { status: 'added', file: plan.rel };
249
282
  } catch (err) {
250
283
  revertFiles(backups);
251
284
  printSnippet(target, framework, colors, appRoot, err.message || String(err));
@@ -259,7 +292,9 @@ function reportWireResult(result, colors = {}) {
259
292
  switch (result.status) {
260
293
  case 'added':
261
294
  console.error(`${tag} · ✓ orb added to ${result.file}. Start your web app (e.g. \`npm run dev\`) to see it.`);
262
- if (result.test && result.test.stage === 'skipped-no-deps') {
295
+ if (result.preexistingFailure) {
296
+ console.error(`${tag} · ${dim || ''}Note: your app was ALREADY not building before the orb was added (${result.test && result.test.stage}); not caused by Fiodos — the orb is kept so it appears once your build is fixed.${reset || ''}`);
297
+ } else if (result.test && result.test.stage === 'skipped-no-deps') {
263
298
  console.error(`${tag} · ${dim || ''}build not verified (no node_modules) — run npm install && npm run build locally.${reset || ''}`);
264
299
  } else if (result.test && result.test.ok) {
265
300
  console.error(`${tag} · ✓ ${result.test.command} passed after mount.`);