@mcpc-tech/unplugin-dev-inspector-mcp 0.1.6 → 0.1.8

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/dist/cli.cjs CHANGED
@@ -412,6 +412,49 @@ function transformConfig(options) {
412
412
  };
413
413
  }
414
414
  }
415
+ /**
416
+ * Transform entry file to add DevInspector import
417
+ */
418
+ function transformEntryFile(options) {
419
+ const { entryPath } = options;
420
+ try {
421
+ const code = (0, fs.readFileSync)(entryPath, "utf-8");
422
+ if (code.includes("virtual:dev-inspector-mcp")) return {
423
+ success: true,
424
+ modified: false,
425
+ message: "DevInspector is already imported in this file"
426
+ };
427
+ const s = new magic_string.default(code);
428
+ const ast = (0, _babel_parser.parse)(code, {
429
+ sourceType: "module",
430
+ plugins: ["typescript", "jsx"]
431
+ });
432
+ let lastImportEnd = 0;
433
+ traverse(ast, { ImportDeclaration(path$1) {
434
+ if (path$1.node.loc) lastImportEnd = Math.max(lastImportEnd, path$1.node.loc.end.line);
435
+ } });
436
+ const lines = code.split("\n");
437
+ const importLine = "import 'virtual:dev-inspector-mcp';\n";
438
+ if (lastImportEnd > 0) {
439
+ let insertPos = 0;
440
+ for (let i = 0; i < lastImportEnd; i++) insertPos += lines[i].length + 1;
441
+ s.appendLeft(insertPos, importLine);
442
+ } else s.prepend(importLine);
443
+ return {
444
+ success: true,
445
+ modified: true,
446
+ code: s.toString(),
447
+ message: "Successfully added DevInspector import to entry file"
448
+ };
449
+ } catch (error) {
450
+ return {
451
+ success: false,
452
+ modified: false,
453
+ error: error instanceof Error ? error.message : String(error),
454
+ message: "Failed to transform entry file"
455
+ };
456
+ }
457
+ }
415
458
 
416
459
  //#endregion
417
460
  //#region src/utils/package-manager.ts
@@ -474,10 +517,14 @@ async function runSetupCommand() {
474
517
  let dryRun = false;
475
518
  let configPath;
476
519
  let bundlerType;
520
+ let entryPath;
477
521
  for (let i = 0; i < args.length; i++) if (args[i] === "--dry-run") dryRun = true;
478
522
  else if (args[i] === "--config" && args[i + 1]) {
479
523
  configPath = args[i + 1];
480
524
  i++;
525
+ } else if (args[i] === "--entry" && args[i + 1]) {
526
+ entryPath = args[i + 1];
527
+ i++;
481
528
  } else if (args[i] === "--bundler" && args[i + 1]) {
482
529
  bundlerType = args[i + 1];
483
530
  i++;
@@ -485,10 +532,6 @@ async function runSetupCommand() {
485
532
  console.log(`
486
533
  ╔══════════════════════════════════════════════════════════╗
487
534
  ║ 🔧 DevInspector Setup Command ║
488
- ╠══════════════════════════════════════════════════════════╣
489
- ║ ║
490
- ║ Automatically add DevInspector to your bundler config ║
491
- ║ ║
492
535
  ╚══════════════════════════════════════════════════════════╝
493
536
 
494
537
  Usage:
@@ -496,6 +539,7 @@ Usage:
496
539
 
497
540
  Options:
498
541
  --config <path> Specify config file path (auto-detect by default)
542
+ --entry <path> Specify entry file path to add import (optional)
499
543
  --bundler <type> Specify bundler type: vite, webpack, nextjs
500
544
  --dry-run Preview changes without applying them
501
545
  --help, -h Show this help message
@@ -504,14 +548,11 @@ Examples:
504
548
  # Auto-detect and setup
505
549
  npx @mcpc-tech/unplugin-dev-inspector-mcp setup
506
550
 
551
+ # Setup defining entry file (for React Router v7 / non-HTML apps)
552
+ npx @mcpc-tech/unplugin-dev-inspector-mcp setup --entry src/main.tsx
553
+
507
554
  # Preview changes without applying
508
555
  npx @mcpc-tech/unplugin-dev-inspector-mcp setup --dry-run
509
-
510
- # Setup specific config
511
- npx @mcpc-tech/unplugin-dev-inspector-mcp setup --config vite.config.ts
512
-
513
- # Setup for specific bundler
514
- npx @mcpc-tech/unplugin-dev-inspector-mcp setup --bundler vite
515
556
  `);
516
557
  process.exit(0);
517
558
  }
@@ -565,23 +606,48 @@ Examples:
565
606
  if (result.error) console.error(` Error: ${result.error}`);
566
607
  process.exit(1);
567
608
  }
568
- if (!result.modified) {
569
- console.log(`\n✅ ${result.message}`);
570
- process.exit(0);
609
+ let entryResult;
610
+ if (entryPath) {
611
+ console.log(`\n${dryRun ? "🔍 Previewing" : "🔧 Transforming"} entry file: ${entryPath}...`);
612
+ const { transformEntryFile: transformEntryFile$1 } = await Promise.resolve().then(() => require("./codemod-transformer.cjs"));
613
+ entryResult = transformEntryFile$1({
614
+ entryPath,
615
+ dryRun
616
+ });
617
+ if (!entryResult.success) {
618
+ console.error(`\n❌ ${entryResult.message}`);
619
+ if (entryResult.error) console.error(` Error: ${entryResult.error}`);
620
+ }
571
621
  }
572
622
  if (dryRun) {
573
- console.log("\n📄 Preview of changes:");
574
- console.log("".repeat(60));
575
- console.log(result.code);
576
- console.log("─".repeat(60));
623
+ if (result.modified) {
624
+ console.log("\n📄 Preview of config changes:");
625
+ console.log("─".repeat(60));
626
+ console.log(result.code);
627
+ console.log("─".repeat(60));
628
+ } else console.log(`\n✅ Config: ${result.message}`);
629
+ if (entryPath && entryResult) {
630
+ if (entryResult.modified) {
631
+ console.log("\n📄 Preview of entry file changes:");
632
+ console.log("─".repeat(60));
633
+ console.log(entryResult.code);
634
+ console.log("─".repeat(60));
635
+ } else if (entryResult.success) console.log(`\n✅ Entry file: ${entryResult.message}`);
636
+ }
577
637
  console.log("\n💡 Run without --dry-run to apply these changes");
578
638
  process.exit(0);
579
639
  }
580
- (0, fs.writeFileSync)(targetConfig.path, result.code, "utf-8");
581
- console.log(`\n✅ ${result.message}`);
582
640
  const installed = installPackage("@mcpc-tech/unplugin-dev-inspector-mcp", true);
641
+ if (result.modified) {
642
+ (0, fs.writeFileSync)(targetConfig.path, result.code, "utf-8");
643
+ console.log(`\n✅ ${result.message}`);
644
+ } else console.log(`\n✅ ${result.message}`);
645
+ if (entryPath && entryResult && entryResult.success) if (entryResult.modified) {
646
+ (0, fs.writeFileSync)(entryPath, entryResult.code, "utf-8");
647
+ console.log(`✅ ${entryResult.message}`);
648
+ } else console.log(`✅ ${entryResult.message}`);
583
649
  console.log(`\n📝 Next steps:`);
584
- console.log(` 1. Review the changes in ${targetConfig.path} and package.json`);
650
+ console.log(` 1. Review the changes in ${targetConfig.path}${entryPath ? ` and ${entryPath}` : ""} and package.json`);
585
651
  if (!installed) {
586
652
  console.log(` 2. Install the package: npm i -D @mcpc-tech/unplugin-dev-inspector-mcp`);
587
653
  console.log(` 3. Start your dev server`);
@@ -682,4 +748,9 @@ main();
682
748
 
683
749
  //#endregion
684
750
  exports.StandaloneServer = StandaloneServer;
685
- exports.startStandaloneServer = startStandaloneServer;
751
+ exports.startStandaloneServer = startStandaloneServer;
752
+ exports.transformConfig = transformConfig;
753
+ exports.transformEntryFile = transformEntryFile;
754
+ exports.transformNextConfig = transformNextConfig;
755
+ exports.transformViteConfig = transformViteConfig;
756
+ exports.transformWebpackConfig = transformWebpackConfig;
package/dist/cli.js CHANGED
@@ -408,6 +408,49 @@ function transformConfig(options) {
408
408
  };
409
409
  }
410
410
  }
411
+ /**
412
+ * Transform entry file to add DevInspector import
413
+ */
414
+ function transformEntryFile(options) {
415
+ const { entryPath } = options;
416
+ try {
417
+ const code = readFileSync(entryPath, "utf-8");
418
+ if (code.includes("virtual:dev-inspector-mcp")) return {
419
+ success: true,
420
+ modified: false,
421
+ message: "DevInspector is already imported in this file"
422
+ };
423
+ const s = new MagicString(code);
424
+ const ast = parse(code, {
425
+ sourceType: "module",
426
+ plugins: ["typescript", "jsx"]
427
+ });
428
+ let lastImportEnd = 0;
429
+ traverse(ast, { ImportDeclaration(path$1) {
430
+ if (path$1.node.loc) lastImportEnd = Math.max(lastImportEnd, path$1.node.loc.end.line);
431
+ } });
432
+ const lines = code.split("\n");
433
+ const importLine = "import 'virtual:dev-inspector-mcp';\n";
434
+ if (lastImportEnd > 0) {
435
+ let insertPos = 0;
436
+ for (let i = 0; i < lastImportEnd; i++) insertPos += lines[i].length + 1;
437
+ s.appendLeft(insertPos, importLine);
438
+ } else s.prepend(importLine);
439
+ return {
440
+ success: true,
441
+ modified: true,
442
+ code: s.toString(),
443
+ message: "Successfully added DevInspector import to entry file"
444
+ };
445
+ } catch (error) {
446
+ return {
447
+ success: false,
448
+ modified: false,
449
+ error: error instanceof Error ? error.message : String(error),
450
+ message: "Failed to transform entry file"
451
+ };
452
+ }
453
+ }
411
454
 
412
455
  //#endregion
413
456
  //#region src/utils/package-manager.ts
@@ -470,10 +513,14 @@ async function runSetupCommand() {
470
513
  let dryRun = false;
471
514
  let configPath;
472
515
  let bundlerType;
516
+ let entryPath;
473
517
  for (let i = 0; i < args.length; i++) if (args[i] === "--dry-run") dryRun = true;
474
518
  else if (args[i] === "--config" && args[i + 1]) {
475
519
  configPath = args[i + 1];
476
520
  i++;
521
+ } else if (args[i] === "--entry" && args[i + 1]) {
522
+ entryPath = args[i + 1];
523
+ i++;
477
524
  } else if (args[i] === "--bundler" && args[i + 1]) {
478
525
  bundlerType = args[i + 1];
479
526
  i++;
@@ -481,10 +528,6 @@ async function runSetupCommand() {
481
528
  console.log(`
482
529
  ╔══════════════════════════════════════════════════════════╗
483
530
  ║ 🔧 DevInspector Setup Command ║
484
- ╠══════════════════════════════════════════════════════════╣
485
- ║ ║
486
- ║ Automatically add DevInspector to your bundler config ║
487
- ║ ║
488
531
  ╚══════════════════════════════════════════════════════════╝
489
532
 
490
533
  Usage:
@@ -492,6 +535,7 @@ Usage:
492
535
 
493
536
  Options:
494
537
  --config <path> Specify config file path (auto-detect by default)
538
+ --entry <path> Specify entry file path to add import (optional)
495
539
  --bundler <type> Specify bundler type: vite, webpack, nextjs
496
540
  --dry-run Preview changes without applying them
497
541
  --help, -h Show this help message
@@ -500,14 +544,11 @@ Examples:
500
544
  # Auto-detect and setup
501
545
  npx @mcpc-tech/unplugin-dev-inspector-mcp setup
502
546
 
547
+ # Setup defining entry file (for React Router v7 / non-HTML apps)
548
+ npx @mcpc-tech/unplugin-dev-inspector-mcp setup --entry src/main.tsx
549
+
503
550
  # Preview changes without applying
504
551
  npx @mcpc-tech/unplugin-dev-inspector-mcp setup --dry-run
505
-
506
- # Setup specific config
507
- npx @mcpc-tech/unplugin-dev-inspector-mcp setup --config vite.config.ts
508
-
509
- # Setup for specific bundler
510
- npx @mcpc-tech/unplugin-dev-inspector-mcp setup --bundler vite
511
552
  `);
512
553
  process.exit(0);
513
554
  }
@@ -561,23 +602,48 @@ Examples:
561
602
  if (result.error) console.error(` Error: ${result.error}`);
562
603
  process.exit(1);
563
604
  }
564
- if (!result.modified) {
565
- console.log(`\n✅ ${result.message}`);
566
- process.exit(0);
605
+ let entryResult;
606
+ if (entryPath) {
607
+ console.log(`\n${dryRun ? "🔍 Previewing" : "🔧 Transforming"} entry file: ${entryPath}...`);
608
+ const { transformEntryFile: transformEntryFile$1 } = await import("./codemod-transformer.js");
609
+ entryResult = transformEntryFile$1({
610
+ entryPath,
611
+ dryRun
612
+ });
613
+ if (!entryResult.success) {
614
+ console.error(`\n❌ ${entryResult.message}`);
615
+ if (entryResult.error) console.error(` Error: ${entryResult.error}`);
616
+ }
567
617
  }
568
618
  if (dryRun) {
569
- console.log("\n📄 Preview of changes:");
570
- console.log("".repeat(60));
571
- console.log(result.code);
572
- console.log("─".repeat(60));
619
+ if (result.modified) {
620
+ console.log("\n📄 Preview of config changes:");
621
+ console.log("─".repeat(60));
622
+ console.log(result.code);
623
+ console.log("─".repeat(60));
624
+ } else console.log(`\n✅ Config: ${result.message}`);
625
+ if (entryPath && entryResult) {
626
+ if (entryResult.modified) {
627
+ console.log("\n📄 Preview of entry file changes:");
628
+ console.log("─".repeat(60));
629
+ console.log(entryResult.code);
630
+ console.log("─".repeat(60));
631
+ } else if (entryResult.success) console.log(`\n✅ Entry file: ${entryResult.message}`);
632
+ }
573
633
  console.log("\n💡 Run without --dry-run to apply these changes");
574
634
  process.exit(0);
575
635
  }
576
- writeFileSync(targetConfig.path, result.code, "utf-8");
577
- console.log(`\n✅ ${result.message}`);
578
636
  const installed = installPackage("@mcpc-tech/unplugin-dev-inspector-mcp", true);
637
+ if (result.modified) {
638
+ writeFileSync(targetConfig.path, result.code, "utf-8");
639
+ console.log(`\n✅ ${result.message}`);
640
+ } else console.log(`\n✅ ${result.message}`);
641
+ if (entryPath && entryResult && entryResult.success) if (entryResult.modified) {
642
+ writeFileSync(entryPath, entryResult.code, "utf-8");
643
+ console.log(`✅ ${entryResult.message}`);
644
+ } else console.log(`✅ ${entryResult.message}`);
579
645
  console.log(`\n📝 Next steps:`);
580
- console.log(` 1. Review the changes in ${targetConfig.path} and package.json`);
646
+ console.log(` 1. Review the changes in ${targetConfig.path}${entryPath ? ` and ${entryPath}` : ""} and package.json`);
581
647
  if (!installed) {
582
648
  console.log(` 2. Install the package: npm i -D @mcpc-tech/unplugin-dev-inspector-mcp`);
583
649
  console.log(` 3. Start your dev server`);
@@ -677,4 +743,4 @@ Run with --help for more information:
677
743
  main();
678
744
 
679
745
  //#endregion
680
- export { startStandaloneServer as n, StandaloneServer as t };
746
+ export { transformWebpackConfig as a, transformViteConfig as i, transformEntryFile as n, StandaloneServer as o, transformNextConfig as r, startStandaloneServer as s, transformConfig as t };
@@ -0,0 +1,4 @@
1
+ const require_chunk = require('./chunk.cjs');
2
+ const require_cli = require('./cli.cjs');
3
+
4
+ exports.transformEntryFile = require_cli.transformEntryFile;
@@ -0,0 +1,3 @@
1
+ import { a as transformWebpackConfig, i as transformViteConfig, n as transformEntryFile, r as transformNextConfig, t as transformConfig } from "./cli.js";
2
+
3
+ export { transformEntryFile };
package/dist/index.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import * as unplugin0 from "unplugin";
1
+ import * as unplugin1 from "unplugin";
2
2
 
3
3
  //#region src/utils/config-updater.d.ts
4
4
  type EditorId = "cursor" | "vscode" | "windsurf" | "claude-code" | "antigravity";
@@ -183,10 +183,10 @@ interface DevInspectorOptions extends McpConfigOptions, AcpOptions {
183
183
  }
184
184
  //#endregion
185
185
  //#region src/core.d.ts
186
- declare const unplugin: unplugin0.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
186
+ declare const unplugin: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
187
187
  //#endregion
188
188
  //#region src/core-external.d.ts
189
- declare const unpluginExternal: unplugin0.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
189
+ declare const unpluginExternal: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
190
190
  //#endregion
191
191
  //#region src/turbopack.d.ts
192
192
  interface TurbopackDevInspectorOptions extends DevInspectorOptions {
@@ -211,7 +211,7 @@ interface TurbopackDevInspectorOptions extends DevInspectorOptions {
211
211
  declare function turbopackDevInspector(options?: TurbopackDevInspectorOptions): any;
212
212
  //#endregion
213
213
  //#region src/index.d.ts
214
- declare const external: unplugin0.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
214
+ declare const external: unplugin1.UnpluginInstance<DevInspectorOptions | undefined, boolean>;
215
215
  declare module "virtual:dev-inspector-mcp" {}
216
216
  //#endregion
217
217
  export { type CustomEditorConfig, type DevInspectorOptions, type EditorId, type McpConfigOptions, type TurbopackDevInspectorOptions, unplugin as default, unplugin, external, turbopackDevInspector, unpluginExternal };
@@ -1,3 +1,3 @@
1
- import { n as startStandaloneServer, t as StandaloneServer } from "./cli.js";
1
+ import { o as StandaloneServer, s as startStandaloneServer } from "./cli.js";
2
2
 
3
3
  export { startStandaloneServer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mcpc-tech/unplugin-dev-inspector-mcp",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Universal dev inspector plugin for React/Vue - inspect component sources and API calls in any bundler",
5
5
  "type": "module",
6
6
  "license": "MIT",