@intelligentelectron/universal-netlist 0.0.12

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 (105) hide show
  1. package/CHANGELOG.md +121 -0
  2. package/LICENSE +190 -0
  3. package/NOTICE +4 -0
  4. package/README.md +246 -0
  5. package/dist/circuit-traversal.d.ts +73 -0
  6. package/dist/circuit-traversal.d.ts.map +1 -0
  7. package/dist/circuit-traversal.js +299 -0
  8. package/dist/circuit-traversal.js.map +1 -0
  9. package/dist/cli/commands.d.ts +23 -0
  10. package/dist/cli/commands.d.ts.map +1 -0
  11. package/dist/cli/commands.js +140 -0
  12. package/dist/cli/commands.js.map +1 -0
  13. package/dist/cli/prompts.d.ts +10 -0
  14. package/dist/cli/prompts.d.ts.map +1 -0
  15. package/dist/cli/prompts.js +22 -0
  16. package/dist/cli/prompts.js.map +1 -0
  17. package/dist/cli/shell.d.ts +15 -0
  18. package/dist/cli/shell.d.ts.map +1 -0
  19. package/dist/cli/shell.js +66 -0
  20. package/dist/cli/shell.js.map +1 -0
  21. package/dist/cli/updater.d.ts +46 -0
  22. package/dist/cli/updater.d.ts.map +1 -0
  23. package/dist/cli/updater.js +319 -0
  24. package/dist/cli/updater.js.map +1 -0
  25. package/dist/index.d.ts +16 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +63 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/parsers/altium/connectivity.d.ts +32 -0
  30. package/dist/parsers/altium/connectivity.d.ts.map +1 -0
  31. package/dist/parsers/altium/connectivity.js +308 -0
  32. package/dist/parsers/altium/connectivity.js.map +1 -0
  33. package/dist/parsers/altium/discovery.d.ts +30 -0
  34. package/dist/parsers/altium/discovery.d.ts.map +1 -0
  35. package/dist/parsers/altium/discovery.js +174 -0
  36. package/dist/parsers/altium/discovery.js.map +1 -0
  37. package/dist/parsers/altium/hierarchy.d.ts +29 -0
  38. package/dist/parsers/altium/hierarchy.d.ts.map +1 -0
  39. package/dist/parsers/altium/hierarchy.js +94 -0
  40. package/dist/parsers/altium/hierarchy.js.map +1 -0
  41. package/dist/parsers/altium/index.d.ts +53 -0
  42. package/dist/parsers/altium/index.d.ts.map +1 -0
  43. package/dist/parsers/altium/index.js +404 -0
  44. package/dist/parsers/altium/index.js.map +1 -0
  45. package/dist/parsers/altium/net-extractor.d.ts +24 -0
  46. package/dist/parsers/altium/net-extractor.d.ts.map +1 -0
  47. package/dist/parsers/altium/net-extractor.js +295 -0
  48. package/dist/parsers/altium/net-extractor.js.map +1 -0
  49. package/dist/parsers/altium/ole-reader.d.ts +91 -0
  50. package/dist/parsers/altium/ole-reader.d.ts.map +1 -0
  51. package/dist/parsers/altium/ole-reader.js +304 -0
  52. package/dist/parsers/altium/ole-reader.js.map +1 -0
  53. package/dist/parsers/altium/record-parser.d.ts +21 -0
  54. package/dist/parsers/altium/record-parser.d.ts.map +1 -0
  55. package/dist/parsers/altium/record-parser.js +117 -0
  56. package/dist/parsers/altium/record-parser.js.map +1 -0
  57. package/dist/parsers/altium/schemas.d.ts +277 -0
  58. package/dist/parsers/altium/schemas.d.ts.map +1 -0
  59. package/dist/parsers/altium/schemas.js +246 -0
  60. package/dist/parsers/altium/schemas.js.map +1 -0
  61. package/dist/parsers/altium/types.d.ts +213 -0
  62. package/dist/parsers/altium/types.d.ts.map +1 -0
  63. package/dist/parsers/altium/types.js +180 -0
  64. package/dist/parsers/altium/types.js.map +1 -0
  65. package/dist/parsers/cadence/discovery.d.ts +45 -0
  66. package/dist/parsers/cadence/discovery.d.ts.map +1 -0
  67. package/dist/parsers/cadence/discovery.js +277 -0
  68. package/dist/parsers/cadence/discovery.js.map +1 -0
  69. package/dist/parsers/cadence/index.d.ts +41 -0
  70. package/dist/parsers/cadence/index.d.ts.map +1 -0
  71. package/dist/parsers/cadence/index.js +139 -0
  72. package/dist/parsers/cadence/index.js.map +1 -0
  73. package/dist/parsers/cadence/pstchip-parser.d.ts +23 -0
  74. package/dist/parsers/cadence/pstchip-parser.d.ts.map +1 -0
  75. package/dist/parsers/cadence/pstchip-parser.js +82 -0
  76. package/dist/parsers/cadence/pstchip-parser.js.map +1 -0
  77. package/dist/parsers/cadence/pstxnet-parser.d.ts +15 -0
  78. package/dist/parsers/cadence/pstxnet-parser.d.ts.map +1 -0
  79. package/dist/parsers/cadence/pstxnet-parser.js +55 -0
  80. package/dist/parsers/cadence/pstxnet-parser.js.map +1 -0
  81. package/dist/parsers/cadence/pstxprt-parser.d.ts +24 -0
  82. package/dist/parsers/cadence/pstxprt-parser.d.ts.map +1 -0
  83. package/dist/parsers/cadence/pstxprt-parser.js +75 -0
  84. package/dist/parsers/cadence/pstxprt-parser.js.map +1 -0
  85. package/dist/parsers/index.d.ts +33 -0
  86. package/dist/parsers/index.d.ts.map +1 -0
  87. package/dist/parsers/index.js +49 -0
  88. package/dist/parsers/index.js.map +1 -0
  89. package/dist/server.d.ts +16 -0
  90. package/dist/server.d.ts.map +1 -0
  91. package/dist/server.js +277 -0
  92. package/dist/server.js.map +1 -0
  93. package/dist/service.d.ts +129 -0
  94. package/dist/service.d.ts.map +1 -0
  95. package/dist/service.js +759 -0
  96. package/dist/service.js.map +1 -0
  97. package/dist/types.d.ts +242 -0
  98. package/dist/types.d.ts.map +1 -0
  99. package/dist/types.js +27 -0
  100. package/dist/types.js.map +1 -0
  101. package/dist/version.d.ts +10 -0
  102. package/dist/version.d.ts.map +1 -0
  103. package/dist/version.js +25 -0
  104. package/dist/version.js.map +1 -0
  105. package/package.json +74 -0
@@ -0,0 +1,299 @@
1
+ /**
2
+ * Circuit traversal utilities for netlist analysis
3
+ * Pure functions for identifying power/ground nets and passive components
4
+ */
5
+ import { createHash } from "crypto";
6
+ import { getPinNet } from "./types.js";
7
+ // Regex patterns for net classification
8
+ const GROUND_NET_PATTERN = /^(GND|VSS|AGND|DGND|PGND|SGND|CGND)$/i;
9
+ const POWER_NET_PATTERN = /^(VCC\w*|VDD\w*|VIN\w*|VOUT\w*|VBAT\w*|VBUS\w*|VSYS\w*|PWR_\w+|RAIL_\w+|PP\w*|PN\w*|LD_PP\w*|LD_PN\w*|[+-]?\d+V\d*\w*|[+-].+)$/i;
10
+ const STOP_NET_PATTERN = /^(GND|VSS|AGND|DGND|PGND|SGND|CGND|VCC\w*|VDD\w*|VIN\w*|VOUT\w*|VBAT\w*|VBUS\w*|VSYS\w*|PWR_\w+|RAIL_\w+|PP\w*|PN\w*|LD_PP\w*|LD_PN\w*|[+-]?\d+V\d*\w*|[+-].+)$/i;
11
+ const DNS_PATTERN = /\b(DNS|DNP|DNF|DNI)\b|DO\s*NOT\s*(STUFF|POPULATE|INSTALL)|NOT\s*POPULATED|NO\s*POP/i;
12
+ /**
13
+ * Check if a net name matches the ground pattern.
14
+ */
15
+ export const isGroundNet = (netName) => GROUND_NET_PATTERN.test(netName);
16
+ /**
17
+ * Check if a net name matches the power pattern.
18
+ */
19
+ export const isPowerNet = (netName) => POWER_NET_PATTERN.test(netName);
20
+ /**
21
+ * Check if a net name matches the stop pattern (power or ground).
22
+ */
23
+ export const isStopNet = (netName) => STOP_NET_PATTERN.test(netName);
24
+ /**
25
+ * Determine if a component is a traversable passive (R/RS, L, C, FB).
26
+ */
27
+ export const isPassive = (refdes) => {
28
+ const refdesUpper = refdes.toUpperCase();
29
+ return (refdesUpper.startsWith("RS") ||
30
+ refdesUpper.startsWith("R") ||
31
+ refdesUpper.startsWith("FR") ||
32
+ refdesUpper.startsWith("L") ||
33
+ refdesUpper.startsWith("C") ||
34
+ refdesUpper.startsWith("FB"));
35
+ };
36
+ /**
37
+ * Check if a string is a valid refdes (letters followed by alphanumerics).
38
+ * Filters out Cadence instance paths like "@DESIGN.SHEET:INS123@PART".
39
+ */
40
+ export const isValidRefdes = (refdes) => /^[A-Z][A-Z0-9_]*$/i.test(refdes);
41
+ /**
42
+ * Extract a refdes prefix (letters only).
43
+ */
44
+ export const getRefdesPrefix = (refdes) => {
45
+ const match = refdes.toUpperCase().match(/^[A-Z]+/);
46
+ return match ? match[0] : refdes.toUpperCase();
47
+ };
48
+ /**
49
+ * Check if a refdes matches a prefix filter.
50
+ */
51
+ export const matchesRefdesType = (refdes, type) => {
52
+ const refdesUpper = refdes.toUpperCase();
53
+ const typeUpper = type.toUpperCase();
54
+ return refdesUpper.startsWith(typeUpper);
55
+ };
56
+ /**
57
+ * Detect Do Not Stuff components using common markers.
58
+ */
59
+ export const isDnsComponent = (component) => {
60
+ if (!component)
61
+ return false;
62
+ const haystack = `${component.mpn ?? ""} ${component.description ?? ""} ${component.comment ?? ""}`;
63
+ return DNS_PATTERN.test(haystack);
64
+ };
65
+ /**
66
+ * Generate a natural sort key for strings with numbers.
67
+ * Allows proper sorting like: U1, U2, U10 (instead of U1, U10, U2)
68
+ */
69
+ export const naturalSortKey = (s) => {
70
+ const str = String(s);
71
+ const parts = str.split(/(\d+)/);
72
+ return parts.map((part) => {
73
+ const num = parseInt(part, 10);
74
+ return isNaN(num) ? part.toLowerCase() : num;
75
+ });
76
+ };
77
+ /**
78
+ * Natural sort comparator function.
79
+ * Usage: array.sort(naturalSort)
80
+ */
81
+ export const naturalSort = (a, b) => {
82
+ const aKey = naturalSortKey(a);
83
+ const bKey = naturalSortKey(b);
84
+ for (let i = 0; i < Math.min(aKey.length, bKey.length); i++) {
85
+ const aVal = aKey[i];
86
+ const bVal = bKey[i];
87
+ if (aVal < bVal)
88
+ return -1;
89
+ if (aVal > bVal)
90
+ return 1;
91
+ }
92
+ return aKey.length - bKey.length;
93
+ };
94
+ /**
95
+ * Compute a stable hash for a circuit.
96
+ * Components with the same XNET produce identical hashes regardless of query starting point.
97
+ */
98
+ export const computeCircuitHash = (components) => {
99
+ if (!components || components.length === 0) {
100
+ return "0".repeat(16);
101
+ }
102
+ const sortedComponents = [...components].sort((a, b) => naturalSort(a.refdes, b.refdes));
103
+ const canonicalForm = sortedComponents.map((comp) => ({
104
+ refdes: comp.refdes,
105
+ mpn: comp.mpn,
106
+ connections: comp.connections
107
+ .map((conn) => ({
108
+ pins: [...conn.pins].sort(naturalSort),
109
+ net: conn.net,
110
+ }))
111
+ .sort((a, b) => a.net.localeCompare(b.net)),
112
+ }));
113
+ const canonicalJson = JSON.stringify(canonicalForm);
114
+ const hash = createHash("sha256").update(canonicalJson).digest("hex");
115
+ return hash.substring(0, 16);
116
+ };
117
+ /**
118
+ * Group flat pin connections by component (refdes).
119
+ * Consolidates multiple pin entries for the same component.
120
+ * Aggregates pins by net - multiple pins on the same net are grouped together.
121
+ */
122
+ const groupCircuitPins = (flat, visitedNets, skipped) => {
123
+ const byRefdes = new Map();
124
+ for (const entry of flat) {
125
+ let comp = byRefdes.get(entry.refdes);
126
+ if (!comp) {
127
+ comp = {
128
+ refdes: entry.refdes,
129
+ mpn: entry.mpn,
130
+ description: entry.description,
131
+ comment: entry.comment,
132
+ value: entry.value,
133
+ dns: entry.dns,
134
+ netToPins: new Map(),
135
+ };
136
+ byRefdes.set(entry.refdes, comp);
137
+ }
138
+ if (!comp.netToPins.has(entry.net)) {
139
+ comp.netToPins.set(entry.net, []);
140
+ }
141
+ const pinsForNet = comp.netToPins.get(entry.net);
142
+ if (!pinsForNet.includes(entry.pin)) {
143
+ pinsForNet.push(entry.pin);
144
+ }
145
+ }
146
+ const components = [];
147
+ for (const comp of byRefdes.values()) {
148
+ const connections = [];
149
+ for (const [net, pinList] of comp.netToPins.entries()) {
150
+ connections.push({
151
+ net,
152
+ pins: pinList.sort(naturalSort),
153
+ });
154
+ }
155
+ connections.sort((a, b) => naturalSort(a.pins[0] || "", b.pins[0] || ""));
156
+ components.push({
157
+ refdes: comp.refdes,
158
+ mpn: comp.mpn,
159
+ description: comp.description,
160
+ comment: comp.comment,
161
+ value: comp.value,
162
+ dns: comp.dns,
163
+ connections,
164
+ });
165
+ }
166
+ return {
167
+ components,
168
+ visited_nets: visitedNets,
169
+ skipped,
170
+ };
171
+ };
172
+ /**
173
+ * Traverse circuit from a starting net, following passive components.
174
+ * Uses BFS to explore connections through R, L, C, FB components.
175
+ * Stops at active components and power/ground nets.
176
+ */
177
+ export const traverseCircuitFromNet = (startNet, nets, components, options = {}) => {
178
+ if (!startNet || !nets[startNet]) {
179
+ return { components: [], visited_nets: [], skipped: {} };
180
+ }
181
+ const skipTypes = (options.skipTypes ?? []).map((type) => type.trim().toUpperCase());
182
+ const includeDns = options.includeDns ?? false;
183
+ const skipped = {};
184
+ const skippedComponents = new Set();
185
+ const shouldSkipComponent = (refdes, _component, isDns) => {
186
+ if (!includeDns && isDns) {
187
+ return true;
188
+ }
189
+ const refdesUpper = refdes.toUpperCase();
190
+ const matchedType = skipTypes.find((type) => refdesUpper.startsWith(type));
191
+ if (matchedType) {
192
+ if (!skippedComponents.has(refdes)) {
193
+ skippedComponents.add(refdes);
194
+ skipped[matchedType] = (skipped[matchedType] || 0) + 1;
195
+ }
196
+ return true;
197
+ }
198
+ return false;
199
+ };
200
+ const visitedNets = new Set([startNet]);
201
+ const visitedPins = new Set();
202
+ const queue = [startNet];
203
+ const flatCircuit = [];
204
+ while (queue.length > 0) {
205
+ const currentNet = queue.shift();
206
+ const netConnections = nets[currentNet] || {};
207
+ for (const [refdes, pins] of Object.entries(netConnections)) {
208
+ const comp = components[refdes];
209
+ const dns = isDnsComponent(comp);
210
+ if (shouldSkipComponent(refdes, comp, dns)) {
211
+ continue;
212
+ }
213
+ const dnsFlag = includeDns && dns ? true : undefined;
214
+ const pinArray = Array.isArray(pins) ? pins : [pins];
215
+ for (const pin of pinArray) {
216
+ const pinId = `${refdes}:${pin}`;
217
+ if (visitedPins.has(pinId))
218
+ continue;
219
+ visitedPins.add(pinId);
220
+ flatCircuit.push({
221
+ refdes,
222
+ pin,
223
+ net: currentNet,
224
+ mpn: comp?.mpn,
225
+ description: comp?.description,
226
+ comment: comp?.comment,
227
+ value: comp?.value,
228
+ dns: dnsFlag,
229
+ });
230
+ if (comp?.pins && isPassive(refdes)) {
231
+ for (const [otherPin, otherNet] of Object.entries(comp.pins)) {
232
+ if (otherPin === pin)
233
+ continue;
234
+ const otherPinId = `${refdes}:${otherPin}`;
235
+ if (visitedPins.has(otherPinId))
236
+ continue;
237
+ visitedPins.add(otherPinId);
238
+ const otherNetName = getPinNet(otherNet);
239
+ flatCircuit.push({
240
+ refdes,
241
+ pin: otherPin,
242
+ net: otherNetName,
243
+ mpn: comp?.mpn,
244
+ description: comp?.description,
245
+ comment: comp?.comment,
246
+ value: comp?.value,
247
+ dns: dnsFlag,
248
+ });
249
+ if (visitedNets.has(otherNetName))
250
+ continue;
251
+ visitedNets.add(otherNetName);
252
+ if (isStopNet(otherNetName))
253
+ continue;
254
+ const otherNetConns = nets[otherNetName] || {};
255
+ let hasPassiveToFollow = false;
256
+ for (const [otherRefdes] of Object.entries(otherNetConns)) {
257
+ const otherComp = components[otherRefdes];
258
+ const otherDns = isDnsComponent(otherComp);
259
+ if (shouldSkipComponent(otherRefdes, otherComp, otherDns)) {
260
+ continue;
261
+ }
262
+ const otherDnsFlag = includeDns && otherDns ? true : undefined;
263
+ if (isPassive(otherRefdes)) {
264
+ hasPassiveToFollow = true;
265
+ }
266
+ else {
267
+ const pinsOnNet = otherNetConns[otherRefdes];
268
+ const pinsArray = Array.isArray(pinsOnNet)
269
+ ? pinsOnNet
270
+ : [pinsOnNet];
271
+ for (const activePin of pinsArray) {
272
+ const activePinId = `${otherRefdes}:${activePin}`;
273
+ if (!visitedPins.has(activePinId)) {
274
+ visitedPins.add(activePinId);
275
+ flatCircuit.push({
276
+ refdes: otherRefdes,
277
+ pin: activePin,
278
+ net: otherNetName,
279
+ mpn: otherComp?.mpn,
280
+ description: otherComp?.description,
281
+ comment: otherComp?.comment,
282
+ value: otherComp?.value,
283
+ dns: otherDnsFlag,
284
+ });
285
+ }
286
+ }
287
+ }
288
+ }
289
+ if (hasPassiveToFollow) {
290
+ queue.push(otherNetName);
291
+ }
292
+ }
293
+ }
294
+ }
295
+ }
296
+ }
297
+ return groupCircuitPins(flatCircuit, Array.from(visitedNets), skipped);
298
+ };
299
+ //# sourceMappingURL=circuit-traversal.js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AM,SAAS,IAAI,SAAS,EAAE,CAAC;oCAClC,MAAM,WAAW,GAAG,GAAG,WAAW,IAAI,SAAS,EAAE,CAAC;oCAClD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;wCAClC,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;wCAC7B,WAAW,CAAC,IAAI,CAAC;4CACf,MAAM,EAAE,WAAW;4CACnB,GAAG,EAAE,SAAS;4CACd,GAAG,EAAE,YAAY;4CACjB,GAAG,EAAE,SAAS,EAAE,GAAG;4CACnB,WAAW,EAAE,SAAS,EAAE,WAAW;4CACnC,OAAO,EAAE,SAAS,EAAE,OAAO;4CAC3B,KAAK,EAAE,SAAS,EAAE,KAAK;4CACvB,GAAG,EAAE,YAAY;yCAClB,CAAC,CAAC;oCACL,CAAC;gCACH,CAAC;4BACH,CAAC;wBACH,CAAC;wBAED,IAAI,kBAAkB,EAAE,CAAC;4BACvB,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;wBAC3B,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,gBAAgB,CAAC,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,CAAC;AACzE,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * CLI command handlers for --version, --help, --update, and --uninstall.
3
+ */
4
+ /**
5
+ * Print version information.
6
+ */
7
+ export declare const printVersion: () => void;
8
+ /**
9
+ * Print help message.
10
+ */
11
+ export declare const printHelp: () => void;
12
+ /**
13
+ * Handle --update command.
14
+ * Checks for updates and installs if available.
15
+ * For npm installs, directs users to use npm update instead.
16
+ */
17
+ export declare const handleUpdateCommand: () => Promise<void>;
18
+ /**
19
+ * Handle --uninstall command.
20
+ * Removes the binary and PATH entries from shell rc files.
21
+ */
22
+ export declare const handleUninstallCommand: () => Promise<void>;
23
+ //# sourceMappingURL=commands.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH;;GAEG;AACH,eAAO,MAAM,YAAY,QAAO,IAE/B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,SAAS,QAAO,IA2B5B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,QAAa,OAAO,CAAC,IAAI,CA6DxD,CAAC;AAYF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,QAAa,OAAO,CAAC,IAAI,CAmC3D,CAAC"}
@@ -0,0 +1,140 @@
1
+ /**
2
+ * CLI command handlers for --version, --help, --update, and --uninstall.
3
+ */
4
+ import { existsSync, rmSync } from "node:fs";
5
+ import { dirname } from "node:path";
6
+ import { VERSION, GITHUB_REPO, BINARY_NAME } from "../version.js";
7
+ import { checkForUpdate, performUpdate, isNpmInstall } from "./updater.js";
8
+ import { confirm } from "./prompts.js";
9
+ import { removeFromPath } from "./shell.js";
10
+ /**
11
+ * Print version information.
12
+ */
13
+ export const printVersion = () => {
14
+ console.log(`${BINARY_NAME} v${VERSION}`);
15
+ };
16
+ /**
17
+ * Print help message.
18
+ */
19
+ export const printHelp = () => {
20
+ console.log(`
21
+ ${BINARY_NAME} v${VERSION}
22
+
23
+ MCP server for querying EDA netlists. Supports Cadence and Altium Designer formats.
24
+
25
+ USAGE:
26
+ ${BINARY_NAME} [OPTIONS]
27
+
28
+ OPTIONS:
29
+ --version, -v Print version and exit
30
+ --help, -h Show this help message
31
+ --update Check for and install updates
32
+ --uninstall Remove binary and PATH entries
33
+ --no-update Disable auto-update check on startup
34
+
35
+ INSTALLATION:
36
+ curl -fsSL https://raw.githubusercontent.com/${GITHUB_REPO}/main/install.sh | bash
37
+
38
+ ENVIRONMENT:
39
+ UNIVERSAL_NETLIST_MCP_NO_UPDATE=1 Disable auto-updates
40
+
41
+ MORE INFO:
42
+ https://github.com/${GITHUB_REPO}
43
+ `.trim());
44
+ };
45
+ /**
46
+ * Handle --update command.
47
+ * Checks for updates and installs if available.
48
+ * For npm installs, directs users to use npm update instead.
49
+ */
50
+ export const handleUpdateCommand = async () => {
51
+ // For npm installs, provide npm-specific update instructions
52
+ if (isNpmInstall()) {
53
+ console.log(`Checking for updates...`);
54
+ const check = await checkForUpdate();
55
+ if (check.error) {
56
+ console.error(`Error checking for updates: ${check.error}`);
57
+ process.exit(1);
58
+ }
59
+ if (!check.updateAvailable) {
60
+ console.log(`Already at latest version (${VERSION})`);
61
+ return;
62
+ }
63
+ console.log(`Update available: ${VERSION} -> ${check.latestVersion}`);
64
+ console.log("");
65
+ console.log("To update, run:");
66
+ console.log(" npm update -g universal-netlist");
67
+ return;
68
+ }
69
+ console.log(`Checking for updates...`);
70
+ const check = await checkForUpdate();
71
+ if (check.error) {
72
+ console.error(`Error checking for updates: ${check.error}`);
73
+ process.exit(1);
74
+ }
75
+ if (!check.updateAvailable) {
76
+ console.log(`Already at latest version (${VERSION})`);
77
+ return;
78
+ }
79
+ console.log(`Update available: ${VERSION} -> ${check.latestVersion}`);
80
+ if (!check.downloadUrl) {
81
+ console.error("No download URL available for your platform");
82
+ process.exit(1);
83
+ }
84
+ const confirmed = await confirm("Install update?");
85
+ if (!confirmed) {
86
+ console.log("Update cancelled");
87
+ return;
88
+ }
89
+ console.log("Downloading update...");
90
+ const result = await performUpdate(check.downloadUrl, check.latestVersion);
91
+ if (!result.success) {
92
+ console.error(`Update failed: ${result.error}`);
93
+ process.exit(1);
94
+ }
95
+ console.log(`Updated from ${result.previousVersion} to ${result.newVersion}`);
96
+ console.log("Please restart to use the new version.");
97
+ };
98
+ /**
99
+ * Get the path to the current executable.
100
+ */
101
+ const getCurrentExecutablePath = () => {
102
+ if (process.execPath.includes("node") || process.execPath.includes("bun")) {
103
+ return process.argv[1];
104
+ }
105
+ return process.execPath;
106
+ };
107
+ /**
108
+ * Handle --uninstall command.
109
+ * Removes the binary and PATH entries from shell rc files.
110
+ */
111
+ export const handleUninstallCommand = async () => {
112
+ const confirmed = await confirm(`This will remove ${BINARY_NAME} from your system. Continue?`);
113
+ if (!confirmed) {
114
+ console.log("Uninstall cancelled");
115
+ return;
116
+ }
117
+ const binaryPath = getCurrentExecutablePath();
118
+ const binDir = dirname(binaryPath);
119
+ const installDir = dirname(binDir);
120
+ // Remove PATH entries from shell rc files
121
+ console.log("Removing PATH entries...");
122
+ const modifiedFiles = removeFromPath();
123
+ if (modifiedFiles.length > 0) {
124
+ console.log(`Modified: ${modifiedFiles.join(", ")}`);
125
+ }
126
+ // Remove install directory
127
+ console.log(`Removing install directory: ${installDir}`);
128
+ if (existsSync(installDir)) {
129
+ try {
130
+ rmSync(installDir, { recursive: true });
131
+ }
132
+ catch (error) {
133
+ console.error(`Failed to remove directory: ${error instanceof Error ? error.message : error}`);
134
+ console.log("You may need to remove it manually.");
135
+ }
136
+ }
137
+ console.log("");
138
+ console.log(`${BINARY_NAME} has been uninstalled.`);
139
+ };
140
+ //# sourceMappingURL=commands.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commands.js","sourceRoot":"","sources":["../../src/cli/commands.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,GAAS,EAAE;IACrC,OAAO,CAAC,GAAG,CAAC,GAAG,WAAW,KAAK,OAAO,EAAE,CAAC,CAAC;AAC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CAAC,CAAC,CAAC,KAAK,EAAE,CAChF,CAAC;YACF,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;QACrD,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,GAAG,WAAW,wBAAwB,CAAC,CAAC;AACtD,CAAC,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * User interaction utilities for CLI prompts.
3
+ */
4
+ /**
5
+ * Prompt user for confirmation with a y/N prompt.
6
+ * @param question - The question to ask the user
7
+ * @returns Promise resolving to true if user confirms, false otherwise
8
+ */
9
+ export declare const confirm: (question: string) => Promise<boolean>;
10
+ //# sourceMappingURL=prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/cli/prompts.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAU,UAAU,MAAM,KAAG,OAAO,CAAC,OAAO,CAY/D,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * User interaction utilities for CLI prompts.
3
+ */
4
+ import * as readline from "node:readline";
5
+ /**
6
+ * Prompt user for confirmation with a y/N prompt.
7
+ * @param question - The question to ask the user
8
+ * @returns Promise resolving to true if user confirms, false otherwise
9
+ */
10
+ export const confirm = async (question) => {
11
+ const rl = readline.createInterface({
12
+ input: process.stdin,
13
+ output: process.stdout,
14
+ });
15
+ return new Promise((resolve) => {
16
+ rl.question(`${question} [y/N] `, (answer) => {
17
+ rl.close();
18
+ resolve(answer.toLowerCase() === "y" || answer.toLowerCase() === "yes");
19
+ });
20
+ });
21
+ };
22
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/cli/prompts.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAE1C;;;;GAIG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAAE,QAAgB,EAAoB,EAAE;IAClE,MAAM,EAAE,GAAG,QAAQ,CAAC,eAAe,CAAC;QAClC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,MAAM,EAAE,OAAO,CAAC,MAAM;KACvB,CAAC,CAAC;IAEH,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,EAAE,CAAC,QAAQ,CAAC,GAAG,QAAQ,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE;YAC3C,EAAE,CAAC,KAAK,EAAE,CAAC;YACX,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,KAAK,GAAG,IAAI,MAAM,CAAC,WAAW,EAAE,KAAK,KAAK,CAAC,CAAC;QAC1E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Shell rc file manipulation for PATH integration.
3
+ */
4
+ /**
5
+ * Get shell configuration file paths to check for PATH entries.
6
+ * @returns Array of paths to shell rc files
7
+ */
8
+ export declare const getShellRcFiles: () => string[];
9
+ /**
10
+ * Remove universal-netlist PATH entries from shell rc files.
11
+ * Looks for "# Universal Netlist MCP Server" comment blocks and removes them.
12
+ * @returns Array of file paths that were modified
13
+ */
14
+ export declare const removeFromPath: () => string[];
15
+ //# sourceMappingURL=shell.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../src/cli/shell.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAO,MAAM,EASxC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,QAAO,MAAM,EA2CvC,CAAC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Shell rc file manipulation for PATH integration.
3
+ */
4
+ import * as fs from "node:fs";
5
+ import * as path from "node:path";
6
+ import * as os from "node:os";
7
+ /**
8
+ * Get shell configuration file paths to check for PATH entries.
9
+ * @returns Array of paths to shell rc files
10
+ */
11
+ export const getShellRcFiles = () => {
12
+ const home = os.homedir();
13
+ return [
14
+ path.join(home, ".zshrc"),
15
+ path.join(home, ".bashrc"),
16
+ path.join(home, ".bash_profile"),
17
+ path.join(home, ".profile"),
18
+ path.join(home, ".config", "fish", "config.fish"),
19
+ ];
20
+ };
21
+ /**
22
+ * Remove universal-netlist PATH entries from shell rc files.
23
+ * Looks for "# Universal Netlist MCP Server" comment blocks and removes them.
24
+ * @returns Array of file paths that were modified
25
+ */
26
+ export const removeFromPath = () => {
27
+ const modified = [];
28
+ for (const rcFile of getShellRcFiles()) {
29
+ if (!fs.existsSync(rcFile))
30
+ continue;
31
+ const content = fs.readFileSync(rcFile, "utf-8");
32
+ const lines = content.split("\n");
33
+ const filtered = [];
34
+ let i = 0;
35
+ let changed = false;
36
+ while (i < lines.length) {
37
+ const line = lines[i];
38
+ // Skip "# Universal Netlist MCP Server" comment and the following export/fish_add_path line
39
+ if (line.trim() === "# Universal Netlist MCP Server") {
40
+ changed = true;
41
+ i++; // Skip comment
42
+ // Skip the next line if it's the PATH export
43
+ if (i < lines.length && lines[i].includes("universal-netlist")) {
44
+ i++;
45
+ }
46
+ // Skip trailing empty line if present
47
+ if (i < lines.length && lines[i].trim() === "") {
48
+ i++;
49
+ }
50
+ continue;
51
+ }
52
+ filtered.push(line);
53
+ i++;
54
+ }
55
+ if (changed) {
56
+ // Remove trailing newlines
57
+ while (filtered.length > 0 && filtered[filtered.length - 1] === "") {
58
+ filtered.pop();
59
+ }
60
+ fs.writeFileSync(rcFile, filtered.join("\n") + "\n");
61
+ modified.push(rcFile);
62
+ }
63
+ }
64
+ return modified;
65
+ };
66
+ //# sourceMappingURL=shell.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell.js","sourceRoot":"","sources":["../../src/cli/shell.ts"],"names":[],"mappings":"AAAA;;GAEG;A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