@tscircuit/cli 0.1.100 → 0.1.102

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 (2) hide show
  1. package/dist/main.js +397 -96
  2. package/package.json +2 -2
package/dist/main.js CHANGED
@@ -336132,14 +336132,14 @@ Expected ` + (val42.length + 1) + " quasis but got " + node2.quasis.length);
336132
336132
  return path22.slice(0, index2 + 1);
336133
336133
  }
336134
336134
  function mergePaths(url, base) {
336135
- normalizePath2(base, base.type);
336135
+ normalizePath3(base, base.type);
336136
336136
  if (url.path === "/") {
336137
336137
  url.path = base.path;
336138
336138
  } else {
336139
336139
  url.path = stripPathFilename(base.path) + url.path;
336140
336140
  }
336141
336141
  }
336142
- function normalizePath2(url, type2) {
336142
+ function normalizePath3(url, type2) {
336143
336143
  var rel = type2 <= 4;
336144
336144
  var pieces = url.path.split("/");
336145
336145
  var pointer = 1;
@@ -336202,7 +336202,7 @@ Expected ` + (val42.length + 1) + " quasis but got " + node2.quasis.length);
336202
336202
  if (baseType > inputType)
336203
336203
  inputType = baseType;
336204
336204
  }
336205
- normalizePath2(url, inputType);
336205
+ normalizePath3(url, inputType);
336206
336206
  var queryHash = url.query + url.hash;
336207
336207
  switch (inputType) {
336208
336208
  case 2:
@@ -432739,9 +432739,14 @@ var {
432739
432739
  import * as fs4 from "node:fs";
432740
432740
  import * as path5 from "node:path";
432741
432741
 
432742
- // lib/shared/detect-pkg-manager.ts
432742
+ // lib/shared/setup-tsci-packages.ts
432743
+ import fs2 from "node:fs";
432744
+ import path from "node:path";
432745
+
432746
+ // lib/shared/get-package-manager.ts
432743
432747
  import fs from "fs";
432744
- var detectPackageManager = () => {
432748
+ import { execSync } from "node:child_process";
432749
+ function detectPackageManager() {
432745
432750
  const userAgent = process.env.npm_config_user_agent || "";
432746
432751
  if (userAgent.startsWith("yarn"))
432747
432752
  return "yarn";
@@ -432768,27 +432773,89 @@ var detectPackageManager = () => {
432768
432773
  return "bun";
432769
432774
  } catch (error) {}
432770
432775
  return "npm";
432771
- };
432776
+ }
432777
+ function getPackageManager() {
432778
+ const pm = detectPackageManager();
432779
+ return {
432780
+ name: pm,
432781
+ uninstall: ({ name, cwd }) => {
432782
+ let uninstallCommand;
432783
+ if (pm === "yarn") {
432784
+ uninstallCommand = `yarn remove ${name}`;
432785
+ } else if (pm === "pnpm") {
432786
+ uninstallCommand = `pnpm remove ${name}`;
432787
+ } else if (pm === "bun") {
432788
+ uninstallCommand = `bun remove ${name}`;
432789
+ } else {
432790
+ uninstallCommand = `npm uninstall ${name}`;
432791
+ }
432792
+ execSync(uninstallCommand, { stdio: "pipe", cwd });
432793
+ },
432794
+ install: ({ name, cwd }) => {
432795
+ let installCommand;
432796
+ if (pm === "yarn") {
432797
+ installCommand = `yarn add ${name}`;
432798
+ } else if (pm === "pnpm") {
432799
+ installCommand = `pnpm add ${name}`;
432800
+ } else if (pm === "bun") {
432801
+ if (name.startsWith("@tsci/")) {
432802
+ installCommand = `bun add ${name} --registry https://npm.tscircuit.com`;
432803
+ } else {
432804
+ installCommand = `bun add ${name}`;
432805
+ }
432806
+ } else {
432807
+ installCommand = `npm install ${name}`;
432808
+ }
432809
+ execSync(installCommand, { stdio: "pipe", cwd });
432810
+ },
432811
+ init: ({ cwd }) => {
432812
+ const initCommand = getInitCommand();
432813
+ execSync(initCommand, { stdio: "inherit", cwd });
432814
+ },
432815
+ installDeps: ({ deps, cwd, dev }) => {
432816
+ const installCommand = getInstallDepsCommand(deps, dev);
432817
+ execSync(installCommand, { stdio: "inherit", cwd });
432818
+ },
432819
+ getInitCommand,
432820
+ getInstallDepsCommand
432821
+ };
432822
+ function getInitCommand() {
432823
+ if (pm === "yarn")
432824
+ return "yarn init -y";
432825
+ if (pm === "pnpm")
432826
+ return "pnpm init";
432827
+ if (pm === "bun")
432828
+ return "bun init -y";
432829
+ return "npm init -y";
432830
+ }
432831
+ function getInstallDepsCommand(deps, dev) {
432832
+ const depList = deps.join(" ");
432833
+ if (pm === "bun")
432834
+ return dev ? `bun add -d ${depList}` : `bun add ${depList}`;
432835
+ if (pm === "yarn")
432836
+ return dev ? `yarn add -D ${depList}` : `yarn add ${depList}`;
432837
+ if (pm === "pnpm")
432838
+ return dev ? `pnpm add -D ${depList}` : `pnpm add ${depList}`;
432839
+ return dev ? `npm install -D ${depList}` : `npm install ${depList}`;
432840
+ }
432841
+ }
432772
432842
 
432773
432843
  // lib/shared/setup-tsci-packages.ts
432774
- import fs2 from "node:fs";
432775
- import path from "node:path";
432776
- import { execSync } from "node:child_process";
432777
- function setupTsciProject(directory = process.cwd(), dependencies = ["@types/react", "@tscircuit/core"]) {
432844
+ async function setupTsciProject(directory = process.cwd(), dependencies = ["@types/react", "@tscircuit/core"]) {
432778
432845
  const projectPath = path.resolve(directory);
432779
432846
  if (!fs2.existsSync(projectPath)) {
432780
432847
  fs2.mkdirSync(projectPath, { recursive: true });
432781
432848
  }
432782
- const packageManager = detectPackageManager();
432849
+ const packageManager = getPackageManager();
432783
432850
  console.log(`Initializing project in ${projectPath}...`);
432784
432851
  process.chdir(projectPath);
432785
432852
  if (!fs2.existsSync("package.json")) {
432786
- const initCommand = packageManager === "yarn" ? "yarn init -y" : packageManager === "pnpm" ? "pnpm init" : packageManager === "bun" ? "bun init -y" : "npm init -y";
432787
432853
  try {
432788
- execSync(initCommand, { stdio: "inherit" });
432854
+ packageManager.init({ cwd: projectPath });
432789
432855
  console.log("Project initialized successfully.");
432790
432856
  } catch (error) {
432791
- console.warn("Failed to automatically inititialize project.");
432857
+ console.warn("Failed to automatically initialize project.");
432858
+ const initCommand = packageManager.getInitCommand();
432792
432859
  console.warn("Please inititialize using the command:");
432793
432860
  console.warn(` ${initCommand}`);
432794
432861
  }
@@ -432799,12 +432866,16 @@ function setupTsciProject(directory = process.cwd(), dependencies = ["@types/rea
432799
432866
  console.log("Updated package.json to remove unnecessary fields.");
432800
432867
  if (dependencies.length > 0) {
432801
432868
  console.log("Installing dependencies...");
432802
- const installCommand = packageManager === "bun" ? `bun add -D ${dependencies.join(" ")}` : packageManager === "yarn" ? `yarn add -D ${dependencies.join(" ")}` : packageManager === "pnpm" ? `pnpm add -D ${dependencies.join(" ")}` : `npm install -D ${dependencies.join(" ")}`;
432803
432869
  try {
432804
- execSync(installCommand, { stdio: "inherit" });
432870
+ packageManager.installDeps({
432871
+ deps: dependencies,
432872
+ cwd: projectPath,
432873
+ dev: true
432874
+ });
432805
432875
  console.log("Dependencies installed successfully.");
432806
432876
  } catch (error) {
432807
432877
  console.warn("Failed to automatically install the required dependencies.");
432878
+ const installCommand = packageManager.getInstallDepsCommand(dependencies, true);
432808
432879
  console.warn("Please install them manually using the command:");
432809
432880
  console.warn(` ${installCommand}`);
432810
432881
  }
@@ -433425,7 +433496,7 @@ import readline from "node:readline";
433425
433496
  import { execSync as execSync2 } from "node:child_process";
433426
433497
  var import_semver = __toESM2(require_semver2(), 1);
433427
433498
  // package.json
433428
- var version = "0.1.99";
433499
+ var version = "0.1.101";
433429
433500
  var package_default = {
433430
433501
  name: "@tscircuit/cli",
433431
433502
  version,
@@ -433436,7 +433507,7 @@ var package_default = {
433436
433507
  "@tscircuit/core": "^0.0.353",
433437
433508
  "@tscircuit/eval": "^0.0.152",
433438
433509
  "@tscircuit/fake-snippets": "^0.0.23",
433439
- "@tscircuit/file-server": "^0.0.19",
433510
+ "@tscircuit/file-server": "^0.0.23",
433440
433511
  "@tscircuit/runframe": "^0.0.341",
433441
433512
  "@types/bun": "^1.2.2",
433442
433513
  "@types/configstore": "^6.0.2",
@@ -433600,8 +433671,8 @@ var checkForTsciUpdates = async () => {
433600
433671
  const userWantsToUpdate = await askConfirmation(`A new version of tsci is available (${currentCliVersion()} → ${latestCliVersion}).
433601
433672
  Would you like to update now?`);
433602
433673
  if (userWantsToUpdate) {
433603
- const packageManager = detectPackageManager();
433604
- const installCommand = getGlobalDepsInstallCommand(packageManager, "@tscircuit/cli@latest");
433674
+ const packageManager = getPackageManager();
433675
+ const installCommand = getGlobalDepsInstallCommand(packageManager.name, "@tscircuit/cli@latest");
433605
433676
  try {
433606
433677
  console.log(`Updating tsci using: ${installCommand}`);
433607
433678
  execSync2(installCommand, { stdio: "inherit" });
@@ -434398,6 +434469,8 @@ init_lib();
434398
434469
  init_lib();
434399
434470
  init_lib();
434400
434471
  init_lib();
434472
+ init_lib();
434473
+ init_lib();
434401
434474
  var fileSchema = z.object({
434402
434475
  file_id: z.string(),
434403
434476
  file_path: z.string(),
@@ -434406,28 +434479,56 @@ var fileSchema = z.object({
434406
434479
  });
434407
434480
  var eventSchema = z.object({
434408
434481
  event_id: z.string(),
434409
- event_type: z.literal("FILE_UPDATED"),
434482
+ event_type: z.union([
434483
+ z.literal("FILE_UPDATED"),
434484
+ z.literal("FILE_DELETED"),
434485
+ z.literal("FILE_CREATED")
434486
+ ]),
434410
434487
  file_path: z.string(),
434411
- created_at: z.string()
434488
+ created_at: z.string(),
434489
+ initiator: z.string().optional()
434412
434490
  });
434413
434491
  var databaseSchema = z.object({
434414
434492
  idCounter: z.number().default(0),
434415
434493
  files: z.array(fileSchema).default([]),
434416
434494
  events: z.array(eventSchema).default([])
434417
434495
  });
434496
+ function normalizePath(path7) {
434497
+ if (!path7 || path7 === "/")
434498
+ return "";
434499
+ let normalized = path7.replace(/\\+/g, "/").replace(/\/\/+/, "/");
434500
+ if (normalized.startsWith("/")) {
434501
+ normalized = normalized.slice(1);
434502
+ }
434503
+ if (normalized.length > 1 && normalized.endsWith("/")) {
434504
+ normalized = normalized.slice(0, -1);
434505
+ }
434506
+ return normalized;
434507
+ }
434418
434508
  var createDatabase = () => {
434419
434509
  return hoist(createStore(initializer));
434420
434510
  };
434421
434511
  var initializer = combine(databaseSchema.parse({}), (set, get) => ({
434422
434512
  upsertFile: (file, opts) => {
434513
+ const file_path = normalizePath(file.file_path);
434423
434514
  set((state) => {
434424
- const existingFileIndex = state.files.findIndex((f) => f.file_path === file.file_path);
434515
+ const existingFileIndex = state.files.findIndex((f) => normalizePath(f.file_path) === file_path);
434425
434516
  const newFile = {
434426
434517
  ...file,
434518
+ file_path,
434427
434519
  file_id: existingFileIndex >= 0 ? state.files[existingFileIndex].file_id : state.idCounter.toString(),
434428
434520
  created_at: existingFileIndex >= 0 ? state.files[existingFileIndex].created_at : (/* @__PURE__ */ new Date()).toISOString()
434429
434521
  };
434430
- const files = existingFileIndex >= 0 ? state.files.map((f, i) => i === existingFileIndex ? newFile : f) : [...state.files, newFile];
434522
+ let files;
434523
+ if (existingFileIndex >= 0) {
434524
+ files = [
434525
+ ...state.files.slice(0, existingFileIndex),
434526
+ newFile,
434527
+ ...state.files.slice(existingFileIndex + 1)
434528
+ ];
434529
+ } else {
434530
+ files = [...state.files, newFile];
434531
+ }
434431
434532
  return {
434432
434533
  files,
434433
434534
  idCounter: existingFileIndex >= 0 ? state.idCounter : state.idCounter + 1
@@ -434435,15 +434536,88 @@ var initializer = combine(databaseSchema.parse({}), (set, get) => ({
434435
434536
  });
434436
434537
  get().createEvent({
434437
434538
  event_type: "FILE_UPDATED",
434438
- file_path: file.file_path,
434539
+ file_path,
434439
434540
  created_at: (/* @__PURE__ */ new Date()).toISOString(),
434440
434541
  initiator: opts.initiator
434441
434542
  });
434442
- return get().files.find((f) => f.file_path === file.file_path);
434543
+ return get().files.find((f) => normalizePath(f.file_path) === file_path);
434443
434544
  },
434444
434545
  getFile: (query) => {
434445
434546
  const state = get();
434446
- return state.files.find((f) => query.file_id && f.file_id === query.file_id || query.file_path && f.file_path === query.file_path);
434547
+ return state.files.find((f) => query.file_id && f.file_id === query.file_id || query.file_path && normalizePath(f.file_path) === normalizePath(query.file_path));
434548
+ },
434549
+ getFileByPath: (file_path) => {
434550
+ const state = get();
434551
+ const norm = normalizePath(file_path);
434552
+ return state.files.find((f) => normalizePath(f.file_path) === norm);
434553
+ },
434554
+ renameFile: (old_file_path, new_file_path, opts) => {
434555
+ let renamedFile;
434556
+ const normOld = normalizePath(old_file_path);
434557
+ const normNew = normalizePath(new_file_path);
434558
+ set((state) => {
434559
+ const fileIndex = state.files.findIndex((f) => normalizePath(f.file_path) === normOld);
434560
+ if (fileIndex === -1)
434561
+ return state;
434562
+ const file = state.files[fileIndex];
434563
+ renamedFile = {
434564
+ ...file,
434565
+ file_path: normNew
434566
+ };
434567
+ const files = [
434568
+ ...state.files.slice(0, fileIndex),
434569
+ renamedFile,
434570
+ ...state.files.slice(fileIndex + 1)
434571
+ ];
434572
+ state.events.push({
434573
+ event_id: (state.idCounter + 0).toString(),
434574
+ event_type: "FILE_CREATED",
434575
+ file_path: normNew,
434576
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
434577
+ initiator: opts.initiator
434578
+ });
434579
+ state.events.push({
434580
+ event_id: (state.idCounter + 1).toString(),
434581
+ event_type: "FILE_DELETED",
434582
+ file_path: normOld,
434583
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
434584
+ initiator: opts.initiator
434585
+ });
434586
+ return {
434587
+ files,
434588
+ events: state.events,
434589
+ idCounter: state.idCounter + 2
434590
+ };
434591
+ });
434592
+ return renamedFile;
434593
+ },
434594
+ deleteFile: (query, opts) => {
434595
+ let deletedFile;
434596
+ set((state) => {
434597
+ const initialLength = state.files.length;
434598
+ const files = state.files.filter((f) => {
434599
+ const match = query.file_id && f.file_id === query.file_id || query.file_path && normalizePath(f.file_path) === normalizePath(query.file_path);
434600
+ if (match) {
434601
+ deletedFile = f;
434602
+ }
434603
+ return !match;
434604
+ });
434605
+ if (files.length === initialLength) {
434606
+ return state;
434607
+ }
434608
+ return {
434609
+ files
434610
+ };
434611
+ });
434612
+ if (deletedFile) {
434613
+ get().createEvent({
434614
+ event_type: "FILE_DELETED",
434615
+ file_path: normalizePath(deletedFile.file_path),
434616
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
434617
+ initiator: opts.initiator
434618
+ });
434619
+ }
434620
+ return deletedFile;
434447
434621
  },
434448
434622
  createEvent: (event) => {
434449
434623
  set((state) => ({
@@ -434760,6 +434934,25 @@ var reset_default = withRouteSpec({
434760
434934
  ctx.db.resetEvents();
434761
434935
  return ctx.json({ ok: true });
434762
434936
  });
434937
+ var delete_default = withRouteSpec({
434938
+ methods: ["POST", "DELETE"],
434939
+ commonParams: z.object({
434940
+ file_id: z.string().optional(),
434941
+ file_path: z.string().optional(),
434942
+ initiator: z.string().optional()
434943
+ }),
434944
+ jsonResponse: z.union([z.null(), z.object({ error: z.string() })])
434945
+ })(async (req, ctx) => {
434946
+ const { file_id, file_path, initiator } = req.commonParams;
434947
+ if (!file_id && !file_path) {
434948
+ return ctx.json({ error: "Either file_id or file_path must be provided" }, { status: 400 });
434949
+ }
434950
+ const deletedFile = ctx.db.deleteFile({ file_id, file_path }, { initiator });
434951
+ if (!deletedFile) {
434952
+ return ctx.json({ error: "File not found" }, { status: 404 });
434953
+ }
434954
+ return ctx.json(null, { status: 204 });
434955
+ });
434763
434956
  var download_default = withRouteSpec({
434764
434957
  methods: ["GET"],
434765
434958
  queryParams: z.object({
@@ -434832,6 +435025,39 @@ var list_default4 = withRouteSpec({
434832
435025
  }))
434833
435026
  });
434834
435027
  });
435028
+ var rename_default = withRouteSpec({
435029
+ methods: ["POST"],
435030
+ jsonBody: z.object({
435031
+ old_file_path: z.string(),
435032
+ new_file_path: z.string(),
435033
+ initiator: z.string().optional()
435034
+ }),
435035
+ jsonResponse: z.object({
435036
+ file: z.object({
435037
+ file_id: z.string(),
435038
+ file_path: z.string(),
435039
+ text_content: z.string(),
435040
+ created_at: z.string()
435041
+ }).nullable()
435042
+ })
435043
+ })(async (req, ctx) => {
435044
+ const body = await req.json();
435045
+ const oldFile = ctx.db.getFileByPath(body.old_file_path);
435046
+ if (!oldFile) {
435047
+ return ctx.json({ file: null }, { status: 404 });
435048
+ }
435049
+ const existingFile = ctx.db.getFileByPath(body.new_file_path);
435050
+ if (existingFile) {
435051
+ return ctx.json({ file: null }, { status: 409 });
435052
+ }
435053
+ const file = ctx.db.renameFile(body.old_file_path, body.new_file_path, {
435054
+ initiator: body.initiator
435055
+ });
435056
+ if (!file) {
435057
+ return ctx.json({ file: null }, { status: 500 });
435058
+ }
435059
+ return ctx.json({ file });
435060
+ });
434835
435061
  var upsert_default = withRouteSpec({
434836
435062
  methods: ["POST"],
434837
435063
  jsonBody: z.object({
@@ -434964,10 +435190,12 @@ var routeMapWithHandlers = {
434964
435190
  "/events/create": create_default2,
434965
435191
  "/events/list": list_default3,
434966
435192
  "/events/reset": reset_default,
435193
+ "/files/delete": delete_default,
434967
435194
  "/files/download": download_default,
434968
435195
  "/files/download/[[file_path]]": file_path_default,
434969
435196
  "/files/get": get_default2,
434970
435197
  "/files/list": list_default4,
435198
+ "/files/rename": rename_default,
434971
435199
  "/files/upsert": upsert_default,
434972
435200
  "/health": health_default,
434973
435201
  "/proxy": proxy_default,
@@ -436075,7 +436303,7 @@ function createPattern(matcher) {
436075
436303
  }
436076
436304
  return () => false;
436077
436305
  }
436078
- function normalizePath(path7) {
436306
+ function normalizePath2(path7) {
436079
436307
  if (typeof path7 !== "string")
436080
436308
  throw new Error("string expected");
436081
436309
  path7 = sysPath2.normalize(path7);
@@ -436091,7 +436319,7 @@ function normalizePath(path7) {
436091
436319
  return path7;
436092
436320
  }
436093
436321
  function matchPatterns(patterns, testString, stats) {
436094
- const path7 = normalizePath(testString);
436322
+ const path7 = normalizePath2(testString);
436095
436323
  for (let index = 0;index < patterns.length; index++) {
436096
436324
  const pattern = patterns[index];
436097
436325
  if (pattern(path7, stats)) {
@@ -438977,21 +439205,22 @@ var pushSnippet = async ({
438977
439205
  // lib/shared/add-package.ts
438978
439206
  import * as fs17 from "node:fs";
438979
439207
  import * as path17 from "node:path";
438980
- import { execSync as execSync3 } from "node:child_process";
438981
- async function addPackage(componentPath, projectDir = process.cwd()) {
438982
- let packageName;
439208
+ function normalizePackageNameToNpm(componentPath) {
438983
439209
  if (componentPath.startsWith("@tscircuit/")) {
438984
- packageName = componentPath;
439210
+ return componentPath;
438985
439211
  } else if (componentPath.startsWith("@tsci/")) {
438986
- packageName = componentPath;
439212
+ return componentPath;
438987
439213
  } else {
438988
439214
  const match = componentPath.match(/^([^/.]+)[/.](.+)$/);
438989
439215
  if (!match) {
438990
439216
  throw new Error("Invalid component path. Use format: author/component-name, author.component-name, @tscircuit/package-name, or @tsci/author.component-name");
438991
439217
  }
438992
439218
  const [, author, componentName] = match;
438993
- packageName = `@tsci/${author}.${componentName}`;
439219
+ return `@tsci/${author}.${componentName}`;
438994
439220
  }
439221
+ }
439222
+ async function addPackage(componentPath, projectDir = process.cwd()) {
439223
+ const packageName = normalizePackageNameToNpm(componentPath);
438995
439224
  console.log(`Adding ${packageName}...`);
438996
439225
  const npmrcPath = path17.join(projectDir, ".npmrc");
438997
439226
  const npmrcContent = fs17.existsSync(npmrcPath) ? fs17.readFileSync(npmrcPath, "utf-8") : "";
@@ -439011,23 +439240,9 @@ async function addPackage(componentPath, projectDir = process.cwd()) {
439011
439240
  console.log(`Added ${packageName} successfully.`);
439012
439241
  return;
439013
439242
  }
439014
- const packageManager = detectPackageManager();
439015
- let installCommand;
439016
- if (packageManager === "yarn") {
439017
- installCommand = `yarn add ${packageName}`;
439018
- } else if (packageManager === "pnpm") {
439019
- installCommand = `pnpm add ${packageName}`;
439020
- } else if (packageManager === "bun") {
439021
- if (packageName.startsWith("@tsci/")) {
439022
- installCommand = `bun add ${packageName} --registry https://npm.tscircuit.com`;
439023
- } else {
439024
- installCommand = `bun add ${packageName}`;
439025
- }
439026
- } else {
439027
- installCommand = `npm install ${packageName}`;
439028
- }
439243
+ const packageManager = getPackageManager();
439029
439244
  try {
439030
- execSync3(installCommand, { stdio: "pipe", cwd: projectDir });
439245
+ packageManager.install({ name: packageName, cwd: projectDir });
439031
439246
  console.log(`Added ${packageName} successfully.`);
439032
439247
  } catch (error) {
439033
439248
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -439037,6 +439252,9 @@ async function addPackage(componentPath, projectDir = process.cwd()) {
439037
439252
  }
439038
439253
 
439039
439254
  // cli/dev/DevServer.ts
439255
+ var import_debug2 = __toESM2(require_src(), 1);
439256
+ var debug2 = import_debug2.default("tscircuit:devserver");
439257
+
439040
439258
  class DevServer {
439041
439259
  port;
439042
439260
  componentFilePath;
@@ -439073,6 +439291,9 @@ class DevServer {
439073
439291
  });
439074
439292
  this.filesystemWatcher.on("change", (filePath) => this.handleFileChangedOnFilesystem(filePath));
439075
439293
  this.filesystemWatcher.on("add", (filePath) => this.handleFileChangedOnFilesystem(filePath));
439294
+ this.filesystemWatcher.on("unlink", (filePath) => this.handleFileRemovedFromFilesystem(filePath));
439295
+ this.filesystemWatcher.on("unlinkDir", (filePath) => this.handleFileRemovedFromFilesystem(filePath));
439296
+ this.filesystemWatcher.on("rename", (oldPath, newPath) => this.handleFileRename(oldPath, newPath));
439076
439297
  await this.upsertInitialFiles();
439077
439298
  this.typesHandler?.handleInitialTypeDependencies(this.componentFilePath);
439078
439299
  }
@@ -439101,6 +439322,56 @@ class DevServer {
439101
439322
  }
439102
439323
  }).json();
439103
439324
  }
439325
+ async handleFileRemovedFromFilesystem(absoluteFilePath) {
439326
+ const relativeFilePath = path18.relative(this.projectDir, absoluteFilePath);
439327
+ if (!relativeFilePath || relativeFilePath.trim() === "") {
439328
+ debug2("Skipping delete for empty file path");
439329
+ return;
439330
+ }
439331
+ debug2(`Deleting file ${relativeFilePath} from server`);
439332
+ const deleteFile = async () => {
439333
+ return await this.fsKy.post("api/files/delete", {
439334
+ json: {
439335
+ file_path: relativeFilePath,
439336
+ initiator: "filesystem_change"
439337
+ },
439338
+ throwHttpErrors: false,
439339
+ timeout: 5000,
439340
+ retry: {
439341
+ limit: 3,
439342
+ methods: ["POST"],
439343
+ statusCodes: [408, 413, 429, 500, 502, 503, 504]
439344
+ }
439345
+ }).json();
439346
+ };
439347
+ const response = await Promise.resolve(deleteFile()).catch((error) => {
439348
+ console.error(`Network error deleting ${relativeFilePath}: ${error instanceof Error ? error.message : String(error)}`);
439349
+ return { error: "Connection error" };
439350
+ });
439351
+ if (response && response.error) {
439352
+ if (response.error.includes("File not found")) {
439353
+ debug2(`File not found: ${relativeFilePath}`);
439354
+ } else {
439355
+ console.error(`Failed to delete file ${relativeFilePath}: ${response.error}`);
439356
+ }
439357
+ return;
439358
+ }
439359
+ debug2(`Successfully deleted file ${relativeFilePath} from server`);
439360
+ }
439361
+ async handleFileRename(oldPath, newPath) {
439362
+ const oldRelativePath = path18.relative(this.projectDir, oldPath);
439363
+ const newRelativePath = path18.relative(this.projectDir, newPath);
439364
+ await this.handleFileRemovedFromFilesystem(oldPath);
439365
+ const fileContent = fs18.readFileSync(newPath, "utf-8");
439366
+ await this.fsKy.post("api/files/upsert", {
439367
+ json: {
439368
+ file_path: newRelativePath,
439369
+ text_content: fileContent,
439370
+ initiator: "filesystem_change"
439371
+ }
439372
+ });
439373
+ debug2(`File renamed from ${oldRelativePath} to ${newRelativePath}`);
439374
+ }
439104
439375
  async upsertInitialFiles() {
439105
439376
  const filePaths = getPackageFilePaths(this.projectDir);
439106
439377
  for (const filePath of filePaths) {
@@ -439134,6 +439405,7 @@ class DevServer {
439134
439405
  async stop() {
439135
439406
  this.httpServer?.close();
439136
439407
  this.eventsWatcher?.stop();
439408
+ await this.filesystemWatcher?.close();
439137
439409
  }
439138
439410
  async handleInstallPackage(full_package_name) {
439139
439411
  const postEvent = async (event, message) => {
@@ -439942,33 +440214,33 @@ init_dist4();
439942
440214
  var import_transformation_matrix38 = __toESM2(require_build_commonjs(), 1);
439943
440215
  init_dist2();
439944
440216
  init_dist2();
439945
- var import_debug2 = __toESM2(require_src(), 1);
440217
+ var import_debug3 = __toESM2(require_src(), 1);
439946
440218
  init_dist2();
439947
440219
  var import_transformation_matrix39 = __toESM2(require_build_commonjs(), 1);
439948
440220
  init_dist2();
439949
- var import_debug3 = __toESM2(require_src(), 1);
440221
+ var import_debug4 = __toESM2(require_src(), 1);
439950
440222
  init_dist2();
439951
440223
  var import_transformation_matrix40 = __toESM2(require_build_commonjs(), 1);
439952
440224
  var import_transformation_matrix41 = __toESM2(require_build_commonjs(), 1);
439953
440225
  var import_transformation_matrix42 = __toESM2(require_build_commonjs(), 1);
439954
- var import_debug4 = __toESM2(require_src(), 1);
440226
+ var import_debug5 = __toESM2(require_src(), 1);
439955
440227
  var import_transformation_matrix43 = __toESM2(require_build_commonjs(), 1);
439956
440228
  var import_transformation_matrix44 = __toESM2(require_build_commonjs(), 1);
439957
440229
  var import_transformation_matrix45 = __toESM2(require_build_commonjs(), 1);
439958
- var import_debug5 = __toESM2(require_src(), 1);
439959
440230
  var import_debug6 = __toESM2(require_src(), 1);
439960
- var import_transformation_matrix46 = __toESM2(require_build_commonjs(), 1);
439961
440231
  var import_debug7 = __toESM2(require_src(), 1);
440232
+ var import_transformation_matrix46 = __toESM2(require_build_commonjs(), 1);
440233
+ var import_debug8 = __toESM2(require_src(), 1);
439962
440234
  var import_transformation_matrix47 = __toESM2(require_build_commonjs(), 1);
439963
440235
  init_dist2();
439964
440236
  var import_transformation_matrix48 = __toESM2(require_build_commonjs(), 1);
439965
- var import_debug8 = __toESM2(require_src(), 1);
440237
+ var import_debug9 = __toESM2(require_src(), 1);
439966
440238
  var import_transformation_matrix49 = __toESM2(require_build_commonjs(), 1);
439967
440239
  var import_transformation_matrix50 = __toESM2(require_build_commonjs(), 1);
439968
440240
  init_dist2();
439969
- var import_debug9 = __toESM2(require_src(), 1);
439970
440241
  var import_debug10 = __toESM2(require_src(), 1);
439971
440242
  var import_debug11 = __toESM2(require_src(), 1);
440243
+ var import_debug12 = __toESM2(require_src(), 1);
439972
440244
  function getComponentValue(sourceComponent) {
439973
440245
  if (!sourceComponent)
439974
440246
  return "";
@@ -440369,7 +440641,7 @@ function getCombinedSourcePortName(circuitElements, connectedSourcePortIds) {
440369
440641
  }
440370
440642
  return portInfos.map((p) => p.displayName).join("--");
440371
440643
  }
440372
- var debug2 = import_debug2.default("dsn-converter:processPcbTraces");
440644
+ var debug3 = import_debug3.default("dsn-converter:processPcbTraces");
440373
440645
  var DEFAULT_VIA_DIAMETER = 600;
440374
440646
  var DEFAULT_VIA_HOLE = 300;
440375
440647
  function createWire(opts) {
@@ -440393,7 +440665,7 @@ function processPcbTraces(circuitElements, pcb) {
440393
440665
  source_trace_id: pcbTrace.source_trace_id
440394
440666
  });
440395
440667
  const source_net2 = source_trace2 && su_default(circuitElements).source_net.list().find((n2) => source_trace2.connected_source_net_ids.includes(n2.source_net_id));
440396
- debug2(`PCB TRACE
440668
+ debug3(`PCB TRACE
440397
440669
  ----------
440398
440670
  `, pcbTrace);
440399
440671
  const sourceTraceConnectedPortIds = getCombinedSourcePortName(circuitElements, source_trace2?.connected_source_port_ids || []);
@@ -440402,7 +440674,7 @@ function processPcbTraces(circuitElements, pcb) {
440402
440674
  let currentWire = null;
440403
440675
  for (let i = 0;i < pcbTrace.route.length; i++) {
440404
440676
  const point2 = pcbTrace.route[i];
440405
- debug2(`POINT
440677
+ debug3(`POINT
440406
440678
  ------
440407
440679
  `, point2);
440408
440680
  if (point2.route_type === "wire") {
@@ -440444,7 +440716,7 @@ function processPcbTraces(circuitElements, pcb) {
440444
440716
  continue;
440445
440717
  }
440446
440718
  if (point2.route_type === "via") {
440447
- debug2(`VIA
440719
+ debug3(`VIA
440448
440720
  ----
440449
440721
  `, point2);
440450
440722
  if (currentWire) {
@@ -440453,7 +440725,7 @@ function processPcbTraces(circuitElements, pcb) {
440453
440725
  currentWire = null;
440454
440726
  }
440455
440727
  const viaPadstackName = findOrCreateViaPadstack(dsnWrapper, DEFAULT_VIA_DIAMETER, DEFAULT_VIA_HOLE);
440456
- debug2("VIA PADSTACK NAME:", viaPadstackName);
440728
+ debug3("VIA PADSTACK NAME:", viaPadstackName);
440457
440729
  if (dsnWrapper.getStructure() && !dsnWrapper.getStructure()?.via) {
440458
440730
  dsnWrapper.getStructure().via = viaPadstackName;
440459
440731
  }
@@ -440475,7 +440747,7 @@ function processPcbTraces(circuitElements, pcb) {
440475
440747
  }
440476
440748
  }
440477
440749
  }
440478
- debug2("PCB WIRING/NETWORK_OUT AT END", JSON.stringify(pcb.is_dsn_pcb ? pcb.wiring : pcb.routes.network_out.nets, null, 2));
440750
+ debug3("PCB WIRING/NETWORK_OUT AT END", JSON.stringify(pcb.is_dsn_pcb ? pcb.wiring : pcb.routes.network_out.nets, null, 2));
440479
440751
  }
440480
440752
  var transformMmToUm2 = import_transformation_matrix39.scale(1000);
440481
440753
  function processPlatedHoles(componentGroups, circuitElements, pcb) {
@@ -440753,7 +441025,7 @@ function groupComponents(circuitElements) {
440753
441025
  }
440754
441026
  return Array.from(componentMap.values());
440755
441027
  }
440756
- var debug22 = import_debug3.default("dsn-converter:mergeDsnSessionIntoDsnPcb");
441028
+ var debug22 = import_debug4.default("dsn-converter:mergeDsnSessionIntoDsnPcb");
440757
441029
  var stringifyDsnJson = (dsnJson) => {
440758
441030
  const indent = " ";
440759
441031
  let result = "";
@@ -440942,14 +441214,14 @@ var convertCircuitJsonToDsnString = (circuitJson) => {
440942
441214
  const dsnJson = convertCircuitJsonToDsnJson(circuitJson);
440943
441215
  return stringifyDsnJson(dsnJson);
440944
441216
  };
440945
- var debug3 = import_debug4.default("dsn-converter:convertPadstacksToSmtpads");
440946
- var debug4 = import_debug5.default("dsn-converter:convertWiringPathToPcbTraces");
440947
- var debug5 = import_debug7.default("dsn-converter:convertWiringViaToPcbVias");
440948
- var debug6 = import_debug6.default("dsn-converter:convertWiresToPcbTraces");
440949
- var debug7 = import_debug8.default("dsn-converter");
440950
- var debug8 = import_debug10.default("dsn-converter:getPinNum");
440951
- var debug9 = import_debug11.default("dsn-converter:getViaCoords");
440952
- var debug10 = import_debug9.default("dsn-converter:parse-dsn-to-dsn-json");
441217
+ var debug32 = import_debug5.default("dsn-converter:convertPadstacksToSmtpads");
441218
+ var debug4 = import_debug6.default("dsn-converter:convertWiringPathToPcbTraces");
441219
+ var debug5 = import_debug8.default("dsn-converter:convertWiringViaToPcbVias");
441220
+ var debug6 = import_debug7.default("dsn-converter:convertWiresToPcbTraces");
441221
+ var debug7 = import_debug9.default("dsn-converter");
441222
+ var debug8 = import_debug11.default("dsn-converter:getPinNum");
441223
+ var debug9 = import_debug12.default("dsn-converter:getViaCoords");
441224
+ var debug10 = import_debug10.default("dsn-converter:parse-dsn-to-dsn-json");
440953
441225
 
440954
441226
  // node_modules/@tscircuit/eval/dist/eval/chunk-7SIVWFC6.js
440955
441227
  function normalizeFilePath(filePath) {
@@ -444707,25 +444979,25 @@ var fp = footprinter;
444707
444979
 
444708
444980
  // node_modules/@tscircuit/core/dist/index.js
444709
444981
  init_dist();
444710
- var import_debug15 = __toESM2(require_src(), 1);
444982
+ var import_debug16 = __toESM2(require_src(), 1);
444711
444983
  var import_react = __toESM2(require_react(), 1);
444712
444984
  var import_react_reconciler = __toESM2(require_react_reconciler(), 1);
444713
444985
  var import_react_reconciler_18 = __toESM2(require_react_reconciler_18(), 1);
444714
444986
  var import_constants12 = __toESM2(require_constants5(), 1);
444715
- var import_debug16 = __toESM2(require_src(), 1);
444987
+ var import_debug17 = __toESM2(require_src(), 1);
444716
444988
  var import_transformation_matrix54 = __toESM2(require_build_commonjs(), 1);
444717
444989
  init_dist();
444718
- var import_debug17 = __toESM2(require_src(), 1);
444990
+ var import_debug18 = __toESM2(require_src(), 1);
444719
444991
  init_dist3();
444720
444992
  var import_transformation_matrix55 = __toESM2(require_build_commonjs(), 1);
444721
444993
  init_lib();
444722
444994
  init_lib();
444723
444995
 
444724
444996
  // node_modules/@tscircuit/infgrid-ijump-astar/dist/index.js
444725
- var import_debug12 = __toESM2(require_src(), 1);
444726
- init_dist();
444727
444997
  var import_debug13 = __toESM2(require_src(), 1);
444998
+ init_dist();
444728
444999
  var import_debug14 = __toESM2(require_src(), 1);
445000
+ var import_debug15 = __toESM2(require_src(), 1);
444729
445001
  init_dist2();
444730
445002
  var import_performance_now = __toESM2(require_performance_now(), 1);
444731
445003
 
@@ -445033,7 +445305,7 @@ function addViasWhenLayerChanges(route) {
445033
445305
  newRoute.push(route[route.length - 1]);
445034
445306
  return newRoute;
445035
445307
  }
445036
- var debug11 = import_debug13.default("autorouter:shortenPathWithShortcuts");
445308
+ var debug11 = import_debug14.default("autorouter:shortenPathWithShortcuts");
445037
445309
  function shortenPathWithShortcuts(route, checkIfObstacleBetweenPoints) {
445038
445310
  if (route.length <= 2) {
445039
445311
  return route;
@@ -445138,7 +445410,7 @@ function shortenPathWithShortcuts(route, checkIfObstacleBetweenPoints) {
445138
445410
  }
445139
445411
  return shortened;
445140
445412
  }
445141
- var debug23 = import_debug12.default("autorouting-dataset:astar");
445413
+ var debug23 = import_debug13.default("autorouting-dataset:astar");
445142
445414
  var GeneralizedAstarAutorouter = class {
445143
445415
  openSet = [];
445144
445416
  closedSet = /* @__PURE__ */ new Set;
@@ -445492,7 +445764,7 @@ var GeneralizedAstarAutorouter = class {
445492
445764
  }
445493
445765
  }
445494
445766
  };
445495
- var debug32 = import_debug14.default("autorouting-dataset:infinite-grid-ijump-astar:get-distance-to-overcome-obstacle");
445767
+ var debug33 = import_debug15.default("autorouting-dataset:infinite-grid-ijump-astar:get-distance-to-overcome-obstacle");
445496
445768
  function getDistanceToOvercomeObstacle({
445497
445769
  node,
445498
445770
  travelDir,
@@ -445530,7 +445802,7 @@ function getDistanceToOvercomeObstacle({
445530
445802
  const o1OrthoDim = extendingAlongXAxis ? obstacle.height : obstacle.width;
445531
445803
  const o2OrthoDim = extendingAlongXAxis ? obstacleAtEnd.height : obstacleAtEnd.width;
445532
445804
  if (o2OrthoDim > o1OrthoDim) {
445533
- debug32("next obstacle on path is bigger, not trying to overcome it");
445805
+ debug33("next obstacle on path is bigger, not trying to overcome it");
445534
445806
  return distToOvercomeObstacle;
445535
445807
  }
445536
445808
  const endObstacleDistToOvercome = getDistanceToOvercomeObstacle({
@@ -448157,7 +448429,7 @@ class Row {
448157
448429
  _constant;
448158
448430
  }
448159
448431
  // node_modules/@tscircuit/core/dist/index.js
448160
- var import_debug18 = __toESM2(require_src(), 1);
448432
+ var import_debug19 = __toESM2(require_src(), 1);
448161
448433
  init_dist();
448162
448434
 
448163
448435
  // node_modules/@tscircuit/math-utils/dist/index.js
@@ -456412,7 +456684,7 @@ var CapacityMeshSolver = class extends BaseSolver {
456412
456684
 
456413
456685
  // node_modules/@tscircuit/core/dist/index.js
456414
456686
  init_dist();
456415
- var import_debug19 = __toESM2(require_src(), 1);
456687
+ var import_debug20 = __toESM2(require_src(), 1);
456416
456688
  var import_transformation_matrix61 = __toESM2(require_build_commonjs(), 1);
456417
456689
  init_dist2();
456418
456690
  init_dist2();
@@ -456512,7 +456784,7 @@ __export4(components_exports, {
456512
456784
  Transistor: () => Transistor,
456513
456785
  Via: () => Via
456514
456786
  });
456515
- var debug13 = import_debug16.default("tscircuit:renderable");
456787
+ var debug13 = import_debug17.default("tscircuit:renderable");
456516
456788
  var orderedRenderPhases = [
456517
456789
  "ReactSubtreesRender",
456518
456790
  "InitializePortsFromChildren",
@@ -456965,7 +457237,7 @@ function isMatchingSelector(component, selector) {
456965
457237
  return component.props[prop].toString() === value2;
456966
457238
  });
456967
457239
  }
456968
- var debugSelectAll = import_debug17.default("tscircuit:primitive-component:selectAll");
457240
+ var debugSelectAll = import_debug18.default("tscircuit:primitive-component:selectAll");
456969
457241
  var PrimitiveComponent = class extends Renderable {
456970
457242
  parent = null;
456971
457243
  children;
@@ -458800,7 +459072,7 @@ var getAllDimensionsForSchematicBox = (params2) => {
458800
459072
  pinCount
458801
459073
  };
458802
459074
  };
458803
- var debug24 = import_debug18.default("tscircuit:core:footprint");
459075
+ var debug24 = import_debug19.default("tscircuit:core:footprint");
458804
459076
  var Footprint = class extends PrimitiveComponent {
458805
459077
  get config() {
458806
459078
  return {
@@ -460288,7 +460560,7 @@ searched component ${targetComponent.getString()}, which has ports: ${targetComp
460288
460560
  this.schematic_trace_id = trace.schematic_trace_id;
460289
460561
  }
460290
460562
  };
460291
- var debug33 = import_debug15.default("tscircuit:core");
460563
+ var debug34 = import_debug16.default("tscircuit:core");
460292
460564
  var rotation3 = z.object({
460293
460565
  x: rotation,
460294
460566
  y: rotation,
@@ -460677,7 +460949,7 @@ var NormalComponent = class extends PrimitiveComponent {
460677
460949
  const existingPorts = this.children.filter((c) => c.componentName === "Port");
460678
460950
  const conflictingPort = existingPorts.find((p) => p.isMatchingAnyOf(component.getNameAndAliases()));
460679
460951
  if (conflictingPort) {
460680
- debug33(`Similar ports added. Port 1: ${conflictingPort}, Port 2: ${component}`);
460952
+ debug34(`Similar ports added. Port 1: ${conflictingPort}, Port 2: ${component}`);
460681
460953
  }
460682
460954
  }
460683
460955
  super.add(component);
@@ -461414,14 +461686,14 @@ var Group = class extends NormalComponent {
461414
461686
  return false;
461415
461687
  }
461416
461688
  _hasTracesToRoute() {
461417
- const debug42 = import_debug19.default("tscircuit:core:_hasTracesToRoute");
461689
+ const debug42 = import_debug20.default("tscircuit:core:_hasTracesToRoute");
461418
461690
  const traces = this.selectAll("trace");
461419
461691
  debug42(`[${this.getString()}] has ${traces.length} traces to route`);
461420
461692
  return traces.length > 0;
461421
461693
  }
461422
461694
  async _runEffectMakeHttpAutoroutingRequest() {
461423
461695
  const { db } = this.root;
461424
- const debug42 = import_debug19.default("tscircuit:core:_runEffectMakeHttpAutoroutingRequest");
461696
+ const debug42 = import_debug20.default("tscircuit:core:_runEffectMakeHttpAutoroutingRequest");
461425
461697
  const props = this._parsedProps;
461426
461698
  const autorouterConfig2 = this._getAutorouterConfig();
461427
461699
  const serverUrl = autorouterConfig2.serverUrl;
@@ -461519,7 +461791,7 @@ var Group = class extends NormalComponent {
461519
461791
  async _runLocalAutorouting() {
461520
461792
  const { db } = this.root;
461521
461793
  const props = this._parsedProps;
461522
- const debug42 = import_debug19.default("tscircuit:core:_runLocalAutorouting");
461794
+ const debug42 = import_debug20.default("tscircuit:core:_runLocalAutorouting");
461523
461795
  debug42(`[${this.getString()}] starting local autorouting`);
461524
461796
  const autorouterConfig2 = this._getAutorouterConfig();
461525
461797
  const { simpleRouteJson, connMap } = getSimpleRouteJsonFromCircuitJson({
@@ -461595,7 +461867,7 @@ var Group = class extends NormalComponent {
461595
461867
  }
461596
461868
  }
461597
461869
  doInitialPcbTraceRender() {
461598
- const debug42 = import_debug19.default("tscircuit:core:doInitialPcbTraceRender");
461870
+ const debug42 = import_debug20.default("tscircuit:core:doInitialPcbTraceRender");
461599
461871
  if (!this.isSubcircuit)
461600
461872
  return;
461601
461873
  if (this.root?.pcbDisabled)
@@ -461614,7 +461886,7 @@ var Group = class extends NormalComponent {
461614
461886
  this._startAsyncAutorouting();
461615
461887
  }
461616
461888
  updatePcbTraceRender() {
461617
- const debug42 = import_debug19.default("tscircuit:core:updatePcbTraceRender");
461889
+ const debug42 = import_debug20.default("tscircuit:core:updatePcbTraceRender");
461618
461890
  debug42(`[${this.getString()}] updating...`);
461619
461891
  if (!this.isSubcircuit)
461620
461892
  return;
@@ -464204,10 +464476,10 @@ var CircuitRunner = class {
464204
464476
 
464205
464477
  // lib/shared/generate-circuit-json.ts
464206
464478
  var import_make_vfs2 = __toESM2(require_dist8(), 1);
464207
- var import_debug20 = __toESM2(require_src(), 1);
464479
+ var import_debug21 = __toESM2(require_src(), 1);
464208
464480
  import path21 from "node:path";
464209
464481
  import fs21 from "node:fs";
464210
- var debug14 = import_debug20.default("tsci:generate-circuit-json");
464482
+ var debug14 = import_debug21.default("tsci:generate-circuit-json");
464211
464483
  var ALLOWED_FILE_EXTENSIONS = [
464212
464484
  ".tsx",
464213
464485
  ".ts",
@@ -464495,6 +464767,34 @@ var registerSearch = (program3) => {
464495
464767
  });
464496
464768
  };
464497
464769
 
464770
+ // lib/shared/remove-package.ts
464771
+ async function removePackage(componentPath, projectDir = process.cwd()) {
464772
+ const packageName = normalizePackageNameToNpm(componentPath);
464773
+ console.log(`Removing ${packageName}...`);
464774
+ const packageManager = getPackageManager();
464775
+ try {
464776
+ packageManager.uninstall({ name: packageName, cwd: projectDir });
464777
+ console.log(`Removed ${packageName} successfully.`);
464778
+ } catch (error) {
464779
+ const errorMessage = error instanceof Error ? error.message : String(error);
464780
+ if (errorMessage.includes("is not in dependencies") || errorMessage.includes("not present in package.json") || errorMessage.includes("No such package") || errorMessage.includes("not found in dependencies")) {
464781
+ console.log(`${packageName} is not a dependency.`);
464782
+ return;
464783
+ }
464784
+ console.error(`Failed to remove ${packageName}:`, errorMessage);
464785
+ throw new Error(`Failed to remove ${packageName}: ${errorMessage}`);
464786
+ }
464787
+ }
464788
+
464789
+ // cli/remove/register.ts
464790
+ var registerRemove = (program3) => {
464791
+ program3.command("remove").description("Remove a tscircuit component package from your project").argument("<component>", "Component to remove (e.g. author/component-name)").action((componentPath) => {
464792
+ return removePackage(componentPath).catch(() => {
464793
+ process.exit(1);
464794
+ });
464795
+ });
464796
+ };
464797
+
464498
464798
  // cli/main.ts
464499
464799
  var program2 = new Command;
464500
464800
  program2.name("tsci").description("CLI for developing tscircuit snippets").version(getVersion());
@@ -464512,6 +464812,7 @@ registerConfigPrint(program2);
464512
464812
  registerConfigSet(program2);
464513
464813
  registerExport(program2);
464514
464814
  registerAdd(program2);
464815
+ registerRemove(program2);
464515
464816
  registerUpgradeCommand(program2);
464516
464817
  registerSearch(program2);
464517
464818
  if (process.argv.length === 2) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.100",
3
+ "version": "0.1.102",
4
4
  "main": "dist/main.js",
5
5
  "devDependencies": {
6
6
  "@babel/standalone": "^7.26.9",
@@ -8,7 +8,7 @@
8
8
  "@tscircuit/core": "^0.0.353",
9
9
  "@tscircuit/eval": "^0.0.152",
10
10
  "@tscircuit/fake-snippets": "^0.0.23",
11
- "@tscircuit/file-server": "^0.0.19",
11
+ "@tscircuit/file-server": "^0.0.23",
12
12
  "@tscircuit/runframe": "^0.0.341",
13
13
  "@types/bun": "^1.2.2",
14
14
  "@types/configstore": "^6.0.2",