indierf-schematic-mcp 0.1.0 → 0.1.1

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.
@@ -135,6 +135,17 @@ export function listModels(input: { query?: unknown; family?: unknown; limit?: u
135
135
  return { ok: true, answer, count: all.length, families: MODEL_FAMILIES, models: shown.map(modelLine) };
136
136
  }
137
137
 
138
+ /** How connect names this model's pins, for the first part placed: only the pins it has (SM-01b). */
139
+ function pinRefWords(m: ModelInfo): string {
140
+ const first = `${m.refPrefix}1`;
141
+ if (m.pinsFromData) return `pins are referenced as ${first}.1, ${first}.2 and on, one per data port, in connect.`;
142
+ const refs = m.pins.map((_, i) => `${first}.${i + 1}`);
143
+ if (refs.length === 0) return "it has no pins to connect.";
144
+ if (refs.length === 1) return `its pin is referenced as ${refs[0]} in connect.`;
145
+ const listed = refs.length <= 6 ? `${refs.slice(0, -1).join(", ")} and ${refs[refs.length - 1]}` : `${refs[0]} to ${refs[refs.length - 1]}`;
146
+ return `its pins are referenced as ${listed} in connect.`;
147
+ }
148
+
138
149
  export function describeModel(input: { model?: unknown }): Answer | Refusal {
139
150
  if (typeof input.model !== "string") return refuse("model is a model id, for example lumped.C; list_models finds one.", "model");
140
151
  const m = getModelInfo(input.model);
@@ -166,7 +177,7 @@ export function describeModel(input: { model?: unknown }): Answer | Refusal {
166
177
  if (m.pinsFromData) rules.push("Pins come from a data item (a Touchstone file), which a link cannot carry.");
167
178
  return {
168
179
  ok: true,
169
- answer: `${m.label} (${m.id}) has ${m.pinsFromData ? "one pin per data port" : plural(m.pins.length, "pin")} and ${plural(params.length, "parameter")}; pins are referenced as ${m.refPrefix}1.1, ${m.refPrefix}1.2 in connect.`,
180
+ answer: `${m.label} (${m.id}) has ${m.pinsFromData ? "one pin per data port" : plural(m.pins.length, "pin")} and ${plural(params.length, "parameter")}; ${pinRefWords(m)}`,
170
181
  id: m.id,
171
182
  name: m.label,
172
183
  description: m.description,
@@ -199,19 +210,41 @@ export function opLine(name: OpName): string {
199
210
 
200
211
  export const OP_LINES: readonly string[] = OP_NAMES.map((name) => `${name}: ${opLine(name)}`);
201
212
 
202
- /** One op's arguments as JSON Schema (`z.toJSONSchema`), with `op` itself left out. */
213
+ /** The ops whose pos `edit` fills when it is left out. */
214
+ const PLACING_OPS: readonly string[] = ["placeInstance", "placeSubcircuit", "placeFilter", "placeEqualizer"];
215
+
216
+ /** The arguments `edit` fills when an op leaves them out, with the default in words. */
217
+ function editDefaults(name: OpName): Record<string, string> {
218
+ const out: Record<string, string> = {};
219
+ if (requires(name, "designId")) out.designId = "Optional: edit fills in the top design when left out.";
220
+ if (PLACING_OPS.includes(name) && requires(name, "pos")) out.pos = "Optional: edit places it below the parts already there when left out.";
221
+ return out;
222
+ }
223
+
224
+ /**
225
+ * One op's arguments as JSON Schema (`z.toJSONSchema`), with `op` itself left
226
+ * out, and the arguments `edit` fills (designId, pos) shown as optional with
227
+ * their default (SM-01b: six of ten eval runners read them as required).
228
+ */
203
229
  export function describeOp(input: { op?: unknown }): Answer | Refusal {
204
230
  if (typeof input.op !== "string" || !OP_NAMES.includes(input.op as OpName)) {
205
231
  return refuse(`op is one of the operation names: ${OP_NAMES.join(", ")}.`, "op");
206
232
  }
207
233
  const name = input.op as OpName;
208
234
  const schema = z.toJSONSchema(OP_DEFINITIONS[name].schema) as { properties?: Record<string, unknown>; required?: string[] };
209
- const { op: _op, ...properties } = schema.properties ?? {};
235
+ const { op: _op, ...rest } = schema.properties ?? {};
210
236
  void _op;
211
- const args = { ...schema, properties, required: (schema.required ?? []).filter((k) => k !== "op") };
212
- const defaults: string[] = [];
213
- if (requires(name, "designId")) defaults.push("designId: the top design when left out.");
214
- if (["placeInstance", "placeSubcircuit", "placeFilter"].includes(name)) defaults.push("pos: a free spot below the parts already there when left out.");
237
+ const filled = editDefaults(name);
238
+ const properties = Object.fromEntries(
239
+ Object.entries(rest).map(([key, value]) => {
240
+ const words = filled[key];
241
+ if (!words || !isObject(value)) return [key, value];
242
+ const own = typeof value.description === "string" ? `${sentence(value.description)} ` : "";
243
+ return [key, { ...value, description: `${own}${words}` }];
244
+ }),
245
+ );
246
+ const args = { ...schema, properties, required: (schema.required ?? []).filter((k) => k !== "op" && filled[k] === undefined) };
247
+ const defaults = Object.entries(filled).map(([key, words]) => `${key}: ${words.replace(/^Optional: /, "")}`);
215
248
  return {
216
249
  ok: true,
217
250
  answer: `Pass { "op": "${name}", "args": { … } } in edit's ops; args follows this schema.`,
@@ -256,7 +289,7 @@ function normalizeOps(raw: unknown, doc: SchematicDocument): { ok: true; ops: Re
256
289
  void _op;
257
290
  const op: Record<string, unknown> = { ...flat, ...(isObject(args) ? args : {}), op: name };
258
291
  if (op.designId === undefined && requires(name as OpName, "designId")) op.designId = doc.topDesignId;
259
- if (op.pos === undefined && ["placeInstance", "placeSubcircuit", "placeFilter", "placeEqualizer"].includes(name) && requires(name as OpName, "pos")) {
292
+ if (op.pos === undefined && PLACING_OPS.includes(name) && requires(name as OpName, "pos")) {
260
293
  const big = name === "placeFilter" || name === "placeEqualizer";
261
294
  op.pos = cursor(String(op.designId), big ? 40 : 10);
262
295
  filled.push(`ops[${index}] ${name} placed at (${(op.pos as { x: number }).x}, ${(op.pos as { y: number }).y})`);
@@ -305,6 +338,22 @@ const ercWords = (erc: { errors: number; diagnostics: Diagnostic[] }) =>
305
338
  ? "ERC finds no errors."
306
339
  : `ERC finds ${plural(erc.errors, "error")}, first: ${sentence(erc.diagnostics.find((d) => d.severity === "error")!.message)} get_netlist lists each with its fix.`;
307
340
 
341
+ /**
342
+ * Every instance on the top design in words, grounds and the rest named
343
+ * apart so the count adds up to what was placed (SM-01b): "3 parts, 2 grounds,
344
+ * 2 ports". A part is anything that is not a port, ground, no-connect or
345
+ * probe; no-connects and probes are named only when there are some.
346
+ */
347
+ function instanceWords(doc: SchematicDocument): string {
348
+ const top = Object.values(doc.designs[doc.topDesignId]!.sheet.instances);
349
+ const count = (model: string) => top.filter((i) => i.model === model).length;
350
+ const parts = top.filter((i) => ![SYS_PORT, SYS_GND, SYS_NC, SYS_VPROBE].includes(i.model)).length;
351
+ const words = [plural(parts, "part"), plural(count(SYS_GND), "ground"), plural(count(SYS_PORT), "port")];
352
+ if (count(SYS_NC) > 0) words.push(plural(count(SYS_NC), "no-connect"));
353
+ if (count(SYS_VPROBE) > 0) words.push(plural(count(SYS_VPROBE), "probe"));
354
+ return words.join(", ");
355
+ }
356
+
308
357
  /** Applies ops as one transaction and answers with what changed, the ERC count and the link. */
309
358
  async function applyOps(
310
359
  loaded: SchematicDocument,
@@ -332,10 +381,7 @@ async function applyOps(
332
381
  .map((p) => p.refdes);
333
382
  const erc = ercOf(doc);
334
383
  const { link, linkNote } = await linkOf(doc);
335
- const top = Object.values(doc.designs[doc.topDesignId]!.sheet.instances);
336
- const ports = top.filter((i) => i.model === SYS_PORT).length;
337
- const parts = top.filter((i) => ![SYS_PORT, SYS_GND, SYS_NC, SYS_VPROBE].includes(i.model)).length;
338
- const counts = `${plural(parts, "part")}, ${plural(ports, "port")}, ${plural(Object.keys(doc.simulations).length, "simulation")} and ${plural(Object.keys(doc.goals).length, "goal")}`;
384
+ const counts = `${instanceWords(doc)}, ${plural(Object.keys(doc.simulations).length, "simulation")} and ${plural(Object.keys(doc.goals).length, "goal")}`;
339
385
  const notes = result.results.map((r) => r.note).filter((n): n is string => typeof n === "string");
340
386
  const head = lead
341
387
  ? lead(doc, added)
@@ -463,7 +509,7 @@ export async function getNetlist(input: SourceInput): Promise<Answer | Refusal>
463
509
  const runnable = summary.simulations.filter((s) => s.enabled).length;
464
510
  return {
465
511
  ok: true,
466
- answer: `${summary.name}: ${plural(summary.parts.length, "part")} and ${plural(summary.ports.length, "port")}${summary.nets !== null ? ` on ${plural(summary.nets, "node")}` : ""}, ${plural(summary.simulations.length, "simulation")} (${runnable} enabled) and ${plural(summary.goals.length, "goal")}. ${ercWords(erc)}${loaded.migratedFrom !== null ? ` The file was schema version ${loaded.migratedFrom} and was read as the current one.` : ""}`,
512
+ answer: `${summary.name}: ${instanceWords(doc)}${summary.nets !== null ? ` on ${plural(summary.nets, "node")}` : ""}, ${plural(summary.simulations.length, "simulation")} (${runnable} enabled) and ${plural(summary.goals.length, "goal")}. ${ercWords(erc)}${loaded.migratedFrom !== null ? ` The file was schema version ${loaded.migratedFrom} and was read as the current one.` : ""}`,
467
513
  summary,
468
514
  erc: { errors: erc.errors, warnings: erc.warnings, diagnostics },
469
515
  netlist,
@@ -532,6 +578,38 @@ async function inTime<T>(ms: number, work: Promise<T>, stop: () => void): Promis
532
578
 
533
579
  const messages = (d: readonly { message: string }[]) => d.map((x) => sentence(x.message)).join(" ");
534
580
 
581
+ /** At most this many frequencies, the sentence gives each value at its frequency. */
582
+ export const EACH_POINT_WORDS = 4;
583
+
584
+ /**
585
+ * An S run's sentence (SM-01b). With a few frequencies, each value at its
586
+ * frequency: "S21 -0.50 dB at 1 GHz and -19.22 dB at 2 GHz". With a sweep,
587
+ * the extremes and where each falls: "S21 between -60.12 dB at 3 GHz and
588
+ * 0.00 dB at 412.5 MHz". The old "from 1 GHz to 2 GHz: S21 -19.22 to
589
+ * -0.50 dB" read as frequency order.
590
+ */
591
+ export function spSentence(name: string, freqHz: readonly number[], series: [string, number[] | undefined][], ports: number): string {
592
+ const db = (v: number) => `${(Math.abs(v) < 0.005 ? 0 : v).toFixed(2)} dB`;
593
+ const each = freqHz.length <= EACH_POINT_WORDS;
594
+ const words = series
595
+ .filter((entry): entry is [string, number[]] => entry[1] !== undefined && entry[1].length > 0)
596
+ .map(([label, values]) => {
597
+ if (each) {
598
+ const at = values.map((v, i) => `${db(v)} at ${hzWords(freqHz[i]!)}`);
599
+ return `${label} ${at.length === 1 ? at[0] : `${at.slice(0, -1).join(", ")} and ${at[at.length - 1]}`}`;
600
+ }
601
+ let lo = 0;
602
+ let hi = 0;
603
+ values.forEach((v, i) => {
604
+ if (v < values[lo]!) lo = i;
605
+ if (v > values[hi]!) hi = i;
606
+ });
607
+ return `${label} between ${db(values[lo]!)} at ${hzWords(freqHz[lo]!)} and ${db(values[hi]!)} at ${hzWords(freqHz[hi]!)}`;
608
+ });
609
+ const where = each ? "" : ` from ${hzWords(freqHz[0]!)} to ${hzWords(freqHz[freqHz.length - 1]!)}`;
610
+ return `${name}${where}: ${words.join("; ") || `${plural(ports, "port")} solved`}.`;
611
+ }
612
+
535
613
  export interface SimulateInput extends SourceInput {
536
614
  simulations?: unknown;
537
615
  frequencies_Hz?: unknown;
@@ -568,7 +646,11 @@ export async function simulate(input: SimulateInput, options: EngineOptions = {}
568
646
  }
569
647
  const refused = sims.filter((s) => notHere(s)).map((s) => ({ id: s.id, name: s.name, kind: s.kind, reason: notHere(s)! }));
570
648
  const runs = sims.filter((s) => !notHere(s));
571
- if (runs.length === 0) return refuse(refused.map((r) => r.reason).join(" "), "simulations", { refused });
649
+ if (runs.length === 0) {
650
+ // This refusal sends the user to the page, so it carries the link that opens the schematic there (SM-01b).
651
+ const { link, linkNote } = await linkOf(doc);
652
+ return refuse(refused.map((r) => r.reason).join(" "), "simulations", { refused, link, ...(linkNote && { linkNote }) });
653
+ }
572
654
 
573
655
  // The scratch document: only the runs asked for, the asked frequencies in place of each S sweep.
574
656
  const scratch: SchematicDocument = structuredClone(doc);
@@ -645,11 +727,7 @@ export async function simulate(input: SimulateInput, options: EngineOptions = {}
645
727
  ...(touchstone && { touchstone }),
646
728
  engineVersion: view.engineVersion,
647
729
  });
648
- const at = keep.length === 1 ? ` at ${hzWords(view.freqHz[0]!)}` : ` from ${hzWords(view.freqHz[keep[0]!]!)} to ${hzWords(view.freqHz[keep[keep.length - 1]!]!)}`;
649
- const s21 = s.S21?.dB;
650
- const s11 = s.S11?.dB;
651
- const span = (v: number[]) => (v.length === 1 ? `${v[0]!.toFixed(2)} dB` : `${Math.min(...v).toFixed(2)} to ${Math.max(...v).toFixed(2)} dB`);
652
- lines.push(`${sim.name}${at}: ${[s21 && `S21 ${span(s21)}`, s11 && `S11 ${span(s11)}`, nfValues && `NF ${span(nfValues)}`].filter(Boolean).join(", ") || `${plural(view.ports, "port")} solved`}.`);
730
+ lines.push(spSentence(sim.name, keep.map((k) => view.freqHz[k]!), [["S21", s.S21?.dB], ["S11", s.S11?.dB], ["NF", nfValues ?? undefined]], view.ports));
653
731
  }
654
732
  const { link, linkNote } = await linkOf(doc);
655
733
  const ran = results.filter((r) => r.ok).length;
@@ -1116,6 +1116,17 @@ export function filterGoals(spec: FilterSpec): FilterGoal[] {
1116
1116
  }));
1117
1117
  }
1118
1118
 
1119
+ /**
1120
+ * Every goal edge of `filterGoals`, rising, once each (card SM-01b). Goals
1121
+ * are scored only on solved points, and a 401-point sweep steps over the
1122
+ * edges (10 MHz + k · 7.475 MHz never lands on 1 or 2 GHz), so the placed
1123
+ * sweep solves these too, as a list segment beside the `lin` one.
1124
+ */
1125
+ export function filterGoalEdgesHz(spec: FilterSpec): number[] {
1126
+ const edges = filterGoals(spec).flatMap((g) => [g.fStartHz, g.fStopHz]).filter((f): f is number => f !== undefined);
1127
+ return [...new Set(edges)].sort((a, b) => a - b);
1128
+ }
1129
+
1119
1130
  /**
1120
1131
  * How a variant moves the goals: the pass-band goal drops by a coupled form's
1121
1132
  * pass-band error or an unequal ladder's flat loss, and the stop-band goal
@@ -73,6 +73,7 @@ import type { Op, OpOf } from "./schema";
73
73
  import {
74
74
  DEFAULT_FILTER_SPEC,
75
75
  DEFAULT_STOPBAND_DB,
76
+ filterGoalEdgesHz,
76
77
  filterGoals,
77
78
  filterNote,
78
79
  filterReadout,
@@ -1865,6 +1866,9 @@ function placeFilter(doc: SchematicDocument, op: OpOf<"placeFilter">, ctx: OpCon
1865
1866
  if (op.sweep ?? true) {
1866
1867
  const sweep = filterSweep(spec);
1867
1868
  const hz = (f: number) => `${exactEngineering(f)}Hz`;
1869
+ // The goal edges as their own points, written as the goals write them, so each is a solved
1870
+ // frequency the goal is scored at (SM-01b); the engine sorts the segments and drops repeats.
1871
+ const edges = filterGoalEdgesHz(spec);
1868
1872
  const simId = ctx.genId("sim");
1869
1873
  const plotId = ctx.genId("plot");
1870
1874
  const readout = filterReadout(filter, ports);
@@ -1876,7 +1880,7 @@ function placeFilter(doc: SchematicDocument, op: OpOf<"placeFilter">, ctx: OpCon
1876
1880
  op: "addSimulation",
1877
1881
  id: simId,
1878
1882
  name: "Filter sweep",
1879
- freq: [{ lin: [hz(sweep.startHz), hz(sweep.stopHz), sweep.points] }],
1883
+ freq: [{ lin: [hz(sweep.startHz), hz(sweep.stopHz), sweep.points] }, ...(edges.length > 0 ? [{ list: edges.map(hz) }] : [])],
1880
1884
  ...(readout.mixedMode && { mixedMode: readout.mixedMode }),
1881
1885
  },
1882
1886
  { op: "addPlot", id: plotId, name: readout.label === "S21" ? "Filter S21 and S11" : `Filter ${readout.label} and its reflection`, kind: "rect" },
@@ -289,7 +289,11 @@ export const OP_DEFINITIONS = {
289
289
  bandwidthHz: z.number().positive().optional().describe("Band-pass and band-stop bandwidth f2 - f1 in Hz."),
290
290
  z0: z.number().min(1).max(1000).optional().describe("System impedance in ohms. Default 50."),
291
291
  first: z.enum(["shunt", "series"]).optional().describe("Whether the ladder starts with a shunt or a series arm. Default shunt."),
292
- eSeries: z.enum(["E12", "E24", "E96"]).nullable().optional(),
292
+ eSeries: z
293
+ .enum(["E12", "E24", "E96"])
294
+ .nullable()
295
+ .optional()
296
+ .describe("E12, E24 or E96 snaps each L and C to the nearest standard value of that series (log distance). Omitted or null keeps the exact synthesized values, with no snapping."),
293
297
  form: z
294
298
  .enum(["ladder", "top-c", "shunt-l", "tubular", "norton"])
295
299
  .optional()
@@ -457,7 +461,9 @@ export const OP_DEFINITIONS = {
457
461
  name: IdentSchema,
458
462
  expr: ExprSchema,
459
463
  tune: VariableSchema.shape.tune,
460
- optimize: VariableSchema.shape.optimize,
464
+ optimize: VariableSchema.shape.optimize.describe(
465
+ "Marks the variable for the optimizer: enabled, and min and max as plain SI numbers in the variable's unit, no suffix (5e-9 for 5 nH, 1e-12 for 1 pF).",
466
+ ),
461
467
  stats: VariableSchema.shape.stats,
462
468
  }),
463
469
  },
@@ -776,7 +782,7 @@ export const OP_DEFINITIONS = {
776
782
 
777
783
  addMeasurement: {
778
784
  description:
779
- "Add a measurement: a quantity of one simulation, such as db(S11), gmax, or nf. A goal compares it with a target. The quantity grammar is the one plots use.",
785
+ "Add a measurement: a quantity of one simulation, such as db(S11), mag(S21) on an S run, gmax, or nf. A goal compares it with a target. The quantity grammar is the one plots use.",
780
786
  schema: z.strictObject({
781
787
  op: z.literal("addMeasurement"),
782
788
  id: OptId,
@@ -54,6 +54,26 @@ export type TransactResult =
54
54
  }
55
55
  | { ok: false; error: TransactError };
56
56
 
57
+ type Issue = { code?: string; path: PropertyKey[]; message: string; errors?: Issue[][] };
58
+
59
+ /**
60
+ * The issue to name for a failed op. A union (a frequency segment is lin, log
61
+ * or list) fails as a bare "Invalid input"; the branch that got deepest into
62
+ * the value is the one the caller meant, so its own issue is named, with the
63
+ * full path (SM-01b: `freq.0.lin.2` and what it needs, not `freq.0: Invalid
64
+ * input`). A tie keeps the union's own issue.
65
+ */
66
+ function innermostIssue(issue: Issue | undefined): Issue | undefined {
67
+ if (!issue || issue.code !== "invalid_union" || !issue.errors?.length) return issue;
68
+ const firsts = issue.errors.map((branch) => branch[0]).filter((x): x is Issue => x !== undefined);
69
+ const depth = (x: Issue) => x.path.length;
70
+ const deepest = Math.max(...firsts.map(depth));
71
+ const winners = firsts.filter((x) => depth(x) === deepest);
72
+ if (winners.length !== 1 || deepest === 0) return issue;
73
+ const inner = innermostIssue(winners[0]!)!;
74
+ return { ...inner, path: [...issue.path, ...inner.path] };
75
+ }
76
+
57
77
  /**
58
78
  * Applies a batch of ops as one all-or-nothing, undoable change. Every op is
59
79
  * schema-checked first; then ops run in order against an immer draft. Any
@@ -83,7 +103,7 @@ export function transact(
83
103
  for (const [i, raw] of ops.entries()) {
84
104
  const result = OpSchema.safeParse(raw);
85
105
  if (!result.success) {
86
- const issue = result.error.issues[0];
106
+ const issue = innermostIssue(result.error.issues[0]);
87
107
  return {
88
108
  ok: false,
89
109
  error: {
@@ -186,10 +186,16 @@ export const DesignSchema = z.strictObject({
186
186
  sheet: SheetSchema,
187
187
  });
188
188
 
189
+ /** A segment's count: a whole number from 1, named in the refusal (SM-01b; it said only "Invalid input"). */
190
+ const segmentCount = (what: string) => {
191
+ const error = `${what} is a whole number from 1, for example 401.`;
192
+ return z.number({ error }).int({ error }).min(1, { error });
193
+ };
194
+
189
195
  /** Frequency segments, as in the engine's `SpSim`. Values are expressions. */
190
196
  export const SegmentSchema = z.union([
191
- z.strictObject({ lin: z.tuple([ExprSchema, ExprSchema, z.number().int().min(1)]) }),
192
- z.strictObject({ log: z.tuple([ExprSchema, ExprSchema, z.number().int().min(1)]) }),
197
+ z.strictObject({ lin: z.tuple([ExprSchema, ExprSchema, segmentCount("lin's third value, the point count,")]) }),
198
+ z.strictObject({ log: z.tuple([ExprSchema, ExprSchema, segmentCount("log's third value, the points per decade,")]) }),
193
199
  z.strictObject({ list: z.array(ExprSchema).min(1).max(100_000) }),
194
200
  ]);
195
201
 
@@ -658,7 +658,7 @@ export const QuantitySchema = z
658
658
  "Not a valid quantity. Examples: db(S21), phase_deg(S21), vswr(S11), z(S11), re(z(S11)), gd(S21), S11, db(S21/S31), im(Z11)/(2*pi*freq), on a DC sweep v(VP1), i(R1), p(R1), and on an AC run db(v(out)), db(vratio(out,in)), phase_deg(v(out)).",
659
659
  })
660
660
  .describe(
661
- "Quantity, for example db(S21), vswr(S11), z(S11), re(z(S11)), gd(S21), or S11 for Smith and polar plots. Z21 and Y21 (or Z(i,j), Y(i,j)) are the open-circuit Z and short-circuit Y matrices. Arithmetic with + - * / ^, numbers, pi and freq (Hz) works point by point, no spaces: db(S21/S31) is amplitude balance, phase_deg(S21/S31) phase balance, im(Z11)/(2*pi*freq) an inductance, 290*(10^(nf/10)-1) noise temperature. With a differential port map on the S simulation (mixedMode), Sdd21, Scc11, Sdc21 and Scd12 read the differential and common modes of logical ports, numbered by their place in the map, and Sds21, Scs21, Ssd12, Ssc12 and Sss11 a single-ended logical port; Sdd(10,1) past 9; db(Sdd21), z(Sdd11) on 2·Z0. target() is the document's default target curve (S21 in dB) and target(name) a named one: db(S21)-target() is an equalizer's residual. On a DC sweep: v(VP1) at a voltage probe or net label, i(R1) entering a part's first pin, p(R1) absorbed. On an AC run: db(v(out)) in dBV, v(a,b), db(vratio(out,in)) in dB, i(R1), wrapped in mag, phase_deg, uphase_deg, re, im or gd.",
661
+ "Quantity, for example db(S21), mag(S21) (the plain ratio |S21|), phase_deg(S21), vswr(S11), z(S11), re(z(S11)), gd(S21), or S11 for Smith and polar plots. Z21 and Y21 (or Z(i,j), Y(i,j)) are the open-circuit Z and short-circuit Y matrices. Arithmetic with + - * / ^, numbers, pi and freq (Hz) works point by point, no spaces: db(S21/S31) is amplitude balance, phase_deg(S21/S31) phase balance, im(Z11)/(2*pi*freq) an inductance, 290*(10^(nf/10)-1) noise temperature. With a differential port map on the S simulation (mixedMode), Sdd21, Scc11, Sdc21 and Scd12 read the differential and common modes of logical ports, numbered by their place in the map, and Sds21, Scs21, Ssd12, Ssc12 and Sss11 a single-ended logical port; Sdd(10,1) past 9; db(Sdd21), z(Sdd11) on 2·Z0. target() is the document's default target curve (S21 in dB) and target(name) a named one: db(S21)-target() is an equalizer's residual. On a DC sweep: v(VP1) at a voltage probe or net label, i(R1) entering a part's first pin, p(R1) absorbed. On an AC run: db(v(out)) in dBV, v(a,b), db(vratio(out,in)) in dB, i(R1), wrapped in mag, phase_deg, uphase_deg, re, im or gd.",
662
662
  );
663
663
 
664
664
  /** The S-parameter part of an `SpResult`, as the binding reads it. */
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "indierf-schematic-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module"
5
5
  }
@@ -39,11 +39,11 @@ const EDITING =
39
39
  const CIRCUIT = [
40
40
  "A port (sys.port) is a termination to ground with one pin: connect P1.1 to the circuit's input, nothing to its other side; its Z is the reference impedance (default 50 Ω) and its num orders the S-parameters (S21 is from port 1 to port 2). In a DC run a port is Re Z to ground.",
41
41
  "Ground is sys.gnd, one pin (GND1.1).",
42
- 'connect takes pin references "C1.2": refdes, a dot, then the 1-based pin number or the pin name; it joins them with a net label unless via is "wire".',
42
+ 'connect takes two pin references, a and b, each "C1.2": refdes, a dot, then the 1-based pin number or the pin name, as in { "op": "connect", "args": { "a": "C1.2", "b": "L1.1" } }; it joins them with a net label unless via is "wire".',
43
43
  "A microstrip, CPW or stripline part needs a substrate: addSubstrate (kind msub for microstrip) before placing it; with exactly one substrate of the kind it is used automatically.",
44
44
  ].join(" ");
45
45
  const LINK =
46
- "Every answer opens with answer, one sentence to act on, then the numbers, then link, the page that opens the same schematic: give it to the user. A refusal (isError, { error }) changes nothing and carries no link: fix the input it names and call again.";
46
+ "Every answer opens with answer, one sentence to act on, then the numbers, then link, the page that opens the same schematic: give it to the user. A refusal (isError, { error }) changes nothing: fix the input it names and call again. A refusal carries no link, except one that sends the user to the page (a simulation the local server does not run), which carries the schematic's link.";
47
47
 
48
48
  const SOURCE = {
49
49
  link: { type: "string", description: "A https://www.indierf.com/schematic#s=schematic1.… link, or the bare schematic1.… payload." },
@@ -105,7 +105,7 @@ export const TOOLS = [
105
105
  title: "Edit a schematic",
106
106
  description: [
107
107
  "Apply a list of operations to a schematic as one transaction, one undo step on the page: all apply or none does, and a refusal is the failing op's own error text with its index.",
108
- 'Each op is { "op": name, "args": { … } }. describe_op gives one op\'s arguments as JSON Schema. designId defaults to the top design. A placeInstance, placeSubcircuit or placeFilter without pos lands below the parts already there; give parts distinct pos (10 grid units apart) yourself, because pins that touch are connected.',
108
+ 'Each op is { "op": name, "args": { … } }, for example { "op": "connect", "args": { "a": "C1.2", "b": "L1.1" } }. describe_op gives one op\'s arguments as JSON Schema. designId defaults to the top design. A placeInstance, placeSubcircuit or placeFilter without pos lands below the parts already there; give parts distinct pos (10 grid units apart) yourself, because pins that touch are connected.',
109
109
  "Returns the parts added, removed and changed, the ERC count and the new link.",
110
110
  DOCUMENT,
111
111
  EDITING,
@@ -150,7 +150,7 @@ export const TOOLS = [
150
150
  name: "place_filter",
151
151
  title: "Place an LC filter",
152
152
  description: [
153
- "Synthesize a lumped LC ladder filter and place it in one undo step, the page's Insert, Filter: the ladder, two ports numbered after any already there, a ground per shunt arm, a note, and unless sweep is false an S sweep, an S21 and S11 plot and pass-band and stop-band goals at the spec, so simulate, optimize and run_yield work on it at once.",
153
+ "Synthesize a lumped LC ladder filter and place it in one undo step, the page's Insert, Filter: the ladder, two ports numbered after any already there, a ground per shunt arm, a note, and unless sweep is false an S sweep, an S21 and S11 plot and pass-band and stop-band goals at the spec, so simulate, optimize and run_yield work on it at once. The sweep is 401 points across the response plus every goal edge (the cutoff and the stop-band edge), so each goal is scored exactly at its edges.",
154
154
  "response lowpass, highpass, bandpass or bandstop; approximation butterworth, chebyshev, elliptic, chebyshev2, bessel, gaussian or linear-phase; n 1 to 9; cutoffHz for low-pass and high-pass (the ripple edge for chebyshev and elliptic, the 3 dB point for the others), centerHz and bandwidthHz for band-pass and band-stop, in Hz.",
155
155
  "Returns each part with its value and the link.",
156
156
  DOCUMENT,
@@ -177,7 +177,7 @@ export const TOOLS = [
177
177
  "Run the schematic's enabled S-parameter and DC operating-point simulations in the engine on this machine.",
178
178
  `An S run returns each S-parameter (every pair up to 4 ports; S11 and Si1 above) in dB and degrees, and NF in dB for a two-port, at frequencies_Hz when given (at most ${MAX_FREQUENCIES}, run in place of the sweep) or on the simulation's own sweep thinned evenly to at most ${MAX_POINTS} points. touchstone: true adds the Touchstone text of each S run.`,
179
179
  "A DC operating point returns every node voltage (with its net labels), each part's current entering its first pin and power, each port, and each probe.",
180
- "AC, harmonic balance, load-pull, loop-gain (stability) runs and DC sweeps are refused with the reason: they are not in the local server yet; the link runs them on the page.",
180
+ "AC, harmonic balance, load-pull, loop-gain (stability) runs and DC sweeps are refused with the reason: they are not in the local server yet. The refusal carries the schematic's link, which runs them on the page.",
181
181
  `One call stops at ${SECONDS} s of engine time and says so. A clamp is named in clamps.`,
182
182
  DOCUMENT,
183
183
  UNITS,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "indierf-schematic-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Build, solve, optimize and yield-check RF circuits locally with the IndieRF Schematic Simulator.",
5
5
  "mcpName": "com.indierf/schematic",
6
6
  "type": "module",