@tscircuit/cli 0.1.2085 → 0.1.2087

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/README.md CHANGED
@@ -182,6 +182,39 @@ the solver can be reproduced independently. Values that JSON cannot represent
182
182
  directly, such as `undefined`, `NaN`, maps, sets, or circular references, use
183
183
  explicit `value_type` records instead of being silently discarded.
184
184
 
185
+ ## Searching DigiKey and Mouser parts
186
+
187
+ Use `--digikey` or `--mouser` for distributor stock and supplier part numbers:
188
+
189
+ ```sh
190
+ tsci search --digikey LM358
191
+ tsci search --mouser --json "buck converter"
192
+ tsci search --digikey --mouser LM358
193
+ tsci search --ti --digikey --mouser --json TPS62160
194
+ ```
195
+
196
+ Results come from [DigiKey Search](https://digikeysearch.tscircuit.com) and
197
+ [Mouser Search](https://mousersearch.tscircuit.com), without requiring distributor
198
+ API credentials. Text output includes supplier part numbers; JSON preserves
199
+ returned part metadata with `source: "digikey"` or `source: "mouser"`.
200
+ Stock and pricing reflect the services' cached responses. These flags provide
201
+ part discovery, not direct TSX import from distributors.
202
+
203
+ ## Searching Texas Instruments parts
204
+
205
+ Use `--ti` to search the TI catalog indexed by [tisearch](https://tisearch.tscircuit.com):
206
+
207
+ ```sh
208
+ tsci search --ti TPS62160
209
+ tsci search --ti --json "buck converter"
210
+ tsci search --ti --jlcpcb TPS62160
211
+ ```
212
+
213
+ JSON results identify TI parts with `source: "ti"` and include stored stock,
214
+ pricing, and product links. No TI API credentials are needed. Search reads the
215
+ indexed catalog; stock and metadata reflect the latest completed background
216
+ refresh. This flag provides part discovery, not TSX component import.
217
+
185
218
  ## Development
186
219
 
187
220
  This command will open the `index.tsx` file for editing.
package/dist/cli/main.js CHANGED
@@ -153438,7 +153438,7 @@ var import_perfect_cli = __toESM3(require_dist3(), 1);
153438
153438
  // lib/getVersion.ts
153439
153439
  import { createRequire as createRequire2 } from "node:module";
153440
153440
  // package.json
153441
- var version = "0.1.2084";
153441
+ var version = "0.1.2086";
153442
153442
  var package_default = {
153443
153443
  name: "@tscircuit/cli",
153444
153444
  version,
@@ -366857,14 +366857,20 @@ var entry_default = Fuse2;
366857
366857
 
366858
366858
  // cli/search/register.ts
366859
366859
  var registerSearch = (program) => {
366860
- program.command("search").description("Search for footprints, CAD models or packages in the tscircuit ecosystem").argument("<query...>", "Search query (e.g. keyword, author, or package name)").option("--kicad", "Search KiCad footprints").option("--jlcpcb", "Search JLCPCB components").option("--lcsc", "Alias for --jlcpcb").option("--tscircuit", "Search tscircuit registry packages").option("--json", "Output search results as JSON").action(async (queryParts, opts) => {
366860
+ program.command("search").description("Search for footprints, CAD models or packages in the tscircuit ecosystem").argument("<query...>", "Search query (e.g. keyword, author, or package name)").option("--kicad", "Search KiCad footprints").option("--jlcpcb", "Search JLCPCB components").option("--lcsc", "Alias for --jlcpcb").option("--ti", "Search Texas Instruments components").option("--digikey", "Search DigiKey components").option("--mouser", "Search Mouser components").option("--tscircuit", "Search tscircuit registry packages").option("--json", "Output search results as JSON").action(async (queryParts, opts) => {
366861
366861
  const query = getQueryFromParts(queryParts);
366862
- const hasFilters = opts.kicad || opts.jlcpcb || opts.lcsc || opts.tscircuit;
366862
+ const hasFilters = opts.kicad || opts.jlcpcb || opts.lcsc || opts.ti || opts.digikey || opts.mouser || opts.tscircuit;
366863
366863
  const searchKicad = opts.kicad;
366864
366864
  const searchJlc = opts.jlcpcb || opts.lcsc || !hasFilters;
366865
366865
  const searchTscircuit = opts.tscircuit;
366866
366866
  let results = { packages: [] };
366867
366867
  let jlcResults = [];
366868
+ let tiResults = [];
366869
+ const distributors = [
366870
+ { source: "digikey", label: "DigiKey", enabled: opts.digikey },
366871
+ { source: "mouser", label: "Mouser", enabled: opts.mouser }
366872
+ ];
366873
+ const distributorResults = [];
366868
366874
  let kicadResults = [];
366869
366875
  try {
366870
366876
  if (searchTscircuit) {
@@ -366878,13 +366884,40 @@ var registerSearch = (program) => {
366878
366884
  const jlcResponse = await fetch(jlcSearchUrl).then((r) => r.json());
366879
366885
  jlcResults = jlcResponse?.components ?? [];
366880
366886
  }
366887
+ if (opts.ti) {
366888
+ const tiSearchUrl = "https://tisearch.tscircuit.com/api/search?limit=10&q=" + encodeURIComponent(query);
366889
+ const response = await fetch(tiSearchUrl);
366890
+ if (!response.ok)
366891
+ throw new Error(`TI search failed (HTTP ${response.status})`);
366892
+ const data = await response.json();
366893
+ if (!Array.isArray(data?.components))
366894
+ throw new Error("TI search returned an invalid response");
366895
+ tiResults = data.components;
366896
+ }
366897
+ for (const distributor of distributors) {
366898
+ if (!distributor.enabled)
366899
+ continue;
366900
+ const url = `https://${distributor.source}search.tscircuit.com/api/search?limit=10&q=${encodeURIComponent(query)}`;
366901
+ const response = await fetch(url, {
366902
+ headers: { accept: "application/json" }
366903
+ });
366904
+ if (!response.ok)
366905
+ throw new Error(`${distributor.label} search failed (HTTP ${response.status})`);
366906
+ const data = await response.json();
366907
+ if (!Array.isArray(data?.components))
366908
+ throw new Error(`${distributor.label} search returned an invalid response`);
366909
+ distributorResults.push({
366910
+ ...distributor,
366911
+ components: data.components
366912
+ });
366913
+ }
366881
366914
  if (searchKicad) {
366882
366915
  const kicadFiles = await fetch("https://kicad-mod-cache.tscircuit.com/kicad_files.json").then((r) => r.json());
366883
366916
  const fuse = new entry_default(kicadFiles);
366884
366917
  kicadResults = fuse.search(query).slice(0, 10).map((r) => r.item);
366885
366918
  }
366886
366919
  } catch (error) {
366887
- console.error(kleur_default.red("Failed to search registry:"), error instanceof Error ? error.message : error);
366920
+ console.error(kleur_default.red("Failed to search:"), error instanceof Error ? error.message : error);
366888
366921
  process.exit(1);
366889
366922
  }
366890
366923
  if (opts.json) {
@@ -366897,6 +366930,11 @@ var registerSearch = (program) => {
366897
366930
  source: "tscircuit",
366898
366931
  ...pkg
366899
366932
  })),
366933
+ ...tiResults.map((comp) => ({
366934
+ ...comp,
366935
+ source: "ti"
366936
+ })),
366937
+ ...distributorResults.flatMap(({ source, components }) => components.map((comp) => ({ ...comp, source }))),
366900
366938
  ...jlcResults.map((comp) => ({
366901
366939
  source: "jlcpcb",
366902
366940
  ...comp
@@ -366908,10 +366946,12 @@ var registerSearch = (program) => {
366908
366946
  }, null, 2));
366909
366947
  return;
366910
366948
  }
366911
- if (!kicadResults.length && !results.packages.length && !jlcResults.length) {
366949
+ if (!kicadResults.length && !results.packages.length && !jlcResults.length && !tiResults.length && !distributorResults.some(({ components }) => components.length)) {
366912
366950
  const sources = [
366913
366951
  searchTscircuit && "tscircuit registry",
366914
366952
  searchJlc && "JLCPCB",
366953
+ opts.ti && "Texas Instruments",
366954
+ ...distributors.filter((d) => d.enabled).map((d) => d.label),
366915
366955
  searchKicad && "KiCad"
366916
366956
  ].filter(Boolean);
366917
366957
  console.log(kleur_default.yellow(`No results found for "${query}" in ${sources.join(", ")}.`));
@@ -366938,6 +366978,24 @@ var registerSearch = (program) => {
366938
366978
  console.log(`${idx + 1}. ${comp.mfr} (C${comp.lcsc}) - ${comp.description} (stock: ${comp.stock.toLocaleString("en-US")})`);
366939
366979
  });
366940
366980
  }
366981
+ if (tiResults.length) {
366982
+ console.log();
366983
+ console.log(kleur_default.bold().underline(`Found ${tiResults.length} component(s) in TI search:`));
366984
+ tiResults.forEach((comp, idx) => {
366985
+ console.log(`${idx + 1}. ${comp.mfr} - ${comp.description} (stock: ${comp.stock.toLocaleString("en-US")})`);
366986
+ });
366987
+ }
366988
+ for (const { source, label, components } of distributorResults) {
366989
+ if (!components.length)
366990
+ continue;
366991
+ console.log();
366992
+ console.log(kleur_default.bold().underline(`Found ${components.length} component(s) in ${label} search:`));
366993
+ components.forEach((comp, idx) => {
366994
+ const supplierNumber = comp.supplier_part_number || comp[`${source}_product_number`];
366995
+ const identity = supplierNumber ? `${comp.mfr} (${supplierNumber})` : comp.mfr;
366996
+ console.log(`${idx + 1}. ${identity} - ${comp.description} (stock: ${comp.stock.toLocaleString("en-US")})`);
366997
+ });
366998
+ }
366941
366999
  console.log(`
366942
367000
  `);
366943
367001
  });
package/dist/lib/index.js CHANGED
@@ -69109,7 +69109,7 @@ var getNodeHandler = (winterSpec, { port, middleware = [] }) => {
69109
69109
  }));
69110
69110
  };
69111
69111
  // package.json
69112
- var version = "0.1.2084";
69112
+ var version = "0.1.2086";
69113
69113
  var package_default = {
69114
69114
  name: "@tscircuit/cli",
69115
69115
  version,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/cli",
3
- "version": "0.1.2085",
3
+ "version": "0.1.2087",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/tscircuit/cli"