@tscircuit/schematic-trace-solver 0.0.87 → 0.0.89

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 (118) hide show
  1. package/.agents/skills/schematic-trace-visualization/SKILL.md +115 -0
  2. package/.github/scripts/import-json-bug-report.ts +15 -1
  3. package/.github/workflows/json-bug-report.yml +3 -2
  4. package/AGENTS.md +22 -0
  5. package/dist/index.js +30 -22
  6. package/lib/solvers/Example28Solver/reroute.ts +10 -0
  7. package/lib/testing/PipelineStageDebugRunner.ts +344 -0
  8. package/package.json +3 -2
  9. package/scripts/debug-pipeline-stages.ts +146 -0
  10. package/site/bug-reports/bug-report-20260706T220324Z.page.tsx +4 -0
  11. package/site/bug-reports/bug-report-20260707T020342Z.page.tsx +4 -0
  12. package/site/bug-reports/bug-report-20260707T092615Z.page.tsx +4 -0
  13. package/site/bug-reports/bug-report-20260707T134549Z.page.tsx +4 -0
  14. package/site/bug-reports/bug-report-20260707T134722Z.page.tsx +4 -0
  15. package/site/bug-reports/bug-report-20260707T140410Z.page.tsx +4 -0
  16. package/site/bug-reports/bug-report-20260707T141025Z.page.tsx +4 -0
  17. package/site/bug-reports/bug-report-20260707T141421Z.page.tsx +4 -0
  18. package/tests/bug-reports/bug-report-20260706T213649Z/__snapshots__/bug-report-20260706T213649Z.snap.svg +386 -0
  19. package/tests/bug-reports/bug-report-20260706T213649Z/bug-report-20260706T213649Z.json +1471 -0
  20. package/tests/bug-reports/bug-report-20260706T213649Z/bug-report-20260706T213649Z.test.ts +12 -0
  21. package/tests/bug-reports/bug-report-20260706T220324Z/__snapshots__/bug-report-20260706T220324Z.snap.svg +357 -3448
  22. package/tests/bug-reports/bug-report-20260707T020342Z/__snapshots__/bug-report-20260707T020342Z.snap.svg +64 -0
  23. package/tests/bug-reports/bug-report-20260707T020342Z/bug-report-20260707T020342Z.json +233 -0
  24. package/tests/bug-reports/bug-report-20260707T020342Z/bug-report-20260707T020342Z.test.ts +12 -0
  25. package/tests/bug-reports/bug-report-20260707T092615Z/__snapshots__/bug-report-20260707T092615Z.snap.svg +252 -0
  26. package/tests/bug-reports/bug-report-20260707T092615Z/bug-report-20260707T092615Z.json +1392 -0
  27. package/tests/bug-reports/bug-report-20260707T092615Z/bug-report-20260707T092615Z.test.ts +12 -0
  28. package/tests/bug-reports/bug-report-20260707T134549Z/__snapshots__/bug-report-20260707T134549Z.snap.svg +124 -0
  29. package/tests/bug-reports/bug-report-20260707T134549Z/bug-report-20260707T134549Z.json +652 -0
  30. package/tests/bug-reports/bug-report-20260707T134549Z/bug-report-20260707T134549Z.test.ts +12 -0
  31. package/tests/bug-reports/bug-report-20260707T134722Z/__snapshots__/bug-report-20260707T134722Z.snap.svg +73 -0
  32. package/tests/bug-reports/bug-report-20260707T134722Z/bug-report-20260707T134722Z.json +265 -0
  33. package/tests/bug-reports/bug-report-20260707T134722Z/bug-report-20260707T134722Z.test.ts +12 -0
  34. package/tests/bug-reports/bug-report-20260707T140410Z/__snapshots__/bug-report-20260707T140410Z.snap.svg +154 -0
  35. package/tests/bug-reports/bug-report-20260707T140410Z/bug-report-20260707T140410Z.json +610 -0
  36. package/tests/bug-reports/bug-report-20260707T140410Z/bug-report-20260707T140410Z.test.ts +12 -0
  37. package/tests/bug-reports/bug-report-20260707T141025Z/__snapshots__/bug-report-20260707T141025Z.snap.svg +67 -0
  38. package/tests/bug-reports/bug-report-20260707T141025Z/bug-report-20260707T141025Z.json +185 -0
  39. package/tests/bug-reports/bug-report-20260707T141025Z/bug-report-20260707T141025Z.test.ts +12 -0
  40. package/tests/bug-reports/bug-report-20260707T141421Z/__snapshots__/bug-report-20260707T141421Z.snap.svg +114 -0
  41. package/tests/bug-reports/bug-report-20260707T141421Z/bug-report-20260707T141421Z.json +499 -0
  42. package/tests/bug-reports/bug-report-20260707T141421Z/bug-report-20260707T141421Z.test.ts +23 -0
  43. package/tests/examples/__snapshots__/example01.snap.svg +59 -162
  44. package/tests/examples/__snapshots__/example02.snap.svg +64 -273
  45. package/tests/examples/__snapshots__/example03.snap.svg +85 -290
  46. package/tests/examples/__snapshots__/example04.snap.svg +50 -94
  47. package/tests/examples/__snapshots__/example05.snap.svg +73 -191
  48. package/tests/examples/__snapshots__/example06.snap.svg +49 -95
  49. package/tests/examples/__snapshots__/example07.snap.svg +65 -218
  50. package/tests/examples/__snapshots__/example08.snap.svg +61 -143
  51. package/tests/examples/__snapshots__/example09.snap.svg +123 -493
  52. package/tests/examples/__snapshots__/example10.snap.svg +57 -136
  53. package/tests/examples/__snapshots__/example11.snap.svg +64 -173
  54. package/tests/examples/__snapshots__/example12.snap.svg +58 -159
  55. package/tests/examples/__snapshots__/example13.snap.svg +78 -348
  56. package/tests/examples/__snapshots__/example14.snap.svg +77 -293
  57. package/tests/examples/__snapshots__/example15.snap.svg +140 -984
  58. package/tests/examples/__snapshots__/example16.snap.svg +62 -162
  59. package/tests/examples/__snapshots__/example17.snap.svg +67 -198
  60. package/tests/examples/__snapshots__/example18.snap.svg +69 -249
  61. package/tests/examples/__snapshots__/example19.snap.svg +63 -202
  62. package/tests/examples/__snapshots__/example20.snap.svg +60 -148
  63. package/tests/examples/__snapshots__/example21.snap.svg +73 -298
  64. package/tests/examples/__snapshots__/example22.snap.svg +62 -156
  65. package/tests/examples/__snapshots__/example23.snap.svg +66 -172
  66. package/tests/examples/__snapshots__/example24.snap.svg +64 -164
  67. package/tests/examples/__snapshots__/example25.snap.svg +76 -299
  68. package/tests/examples/__snapshots__/example26.snap.svg +64 -164
  69. package/tests/examples/__snapshots__/example27.snap.svg +83 -300
  70. package/tests/examples/__snapshots__/example28.snap.svg +54 -115
  71. package/tests/examples/__snapshots__/example29.snap.svg +257 -1299
  72. package/tests/examples/__snapshots__/example30.snap.svg +91 -293
  73. package/tests/examples/__snapshots__/example31.snap.svg +47 -88
  74. package/tests/examples/__snapshots__/example32.snap.svg +107 -405
  75. package/tests/examples/__snapshots__/example33.snap.svg +71 -180
  76. package/tests/examples/__snapshots__/example34.snap.svg +55 -116
  77. package/tests/examples/__snapshots__/example35.snap.svg +69 -176
  78. package/tests/examples/__snapshots__/example36.snap.svg +65 -159
  79. package/tests/examples/__snapshots__/example37.snap.svg +75 -223
  80. package/tests/examples/__snapshots__/example38.snap.svg +46 -76
  81. package/tests/examples/__snapshots__/example39.snap.svg +51 -106
  82. package/tests/examples/__snapshots__/example40.snap.svg +83 -270
  83. package/tests/examples/__snapshots__/example41.snap.svg +54 -118
  84. package/tests/examples/__snapshots__/example42.snap.svg +67 -194
  85. package/tests/examples/__snapshots__/example43.snap.svg +62 -168
  86. package/tests/examples/__snapshots__/example44.snap.svg +86 -369
  87. package/tests/examples/__snapshots__/example45.snap.svg +60 -169
  88. package/tests/examples/__snapshots__/example46.snap.svg +80 -342
  89. package/tests/examples/__snapshots__/example47.snap.svg +82 -323
  90. package/tests/examples/__snapshots__/example48.snap.svg +64 -167
  91. package/tests/examples/__snapshots__/example49.snap.svg +120 -565
  92. package/tests/examples/__snapshots__/example50.snap.svg +71 -189
  93. package/tests/fixtures/getLastStepGraphicsObject.ts +38 -0
  94. package/tests/fixtures/getLastStepSvg.ts +9 -0
  95. package/tests/repros/__snapshots__/bugreport-001-gnd-overlap.snap.svg +67 -218
  96. package/tests/repros/__snapshots__/manufacturePartNumber-text-box.snap.svg +47 -87
  97. package/tests/repros/__snapshots__/netlabel-connector-through-rail-label.snap.svg +73 -272
  98. package/tests/repros/__snapshots__/repro-atmega328p-fault-pullup.snap.svg +88 -0
  99. package/tests/repros/__snapshots__/repro-atmega328p-missing-gnd-netlabel.snap.svg +118 -0
  100. package/tests/repros/__snapshots__/repro-bq24074-battery-charger.snap.svg +94 -395
  101. package/tests/repros/__snapshots__/repro-cc2340r5.snap.svg +88 -467
  102. package/tests/repros/__snapshots__/repro-ina237-current-monitor.snap.svg +109 -569
  103. package/tests/repros/__snapshots__/repro130-bq27441-fuel-gauge-trace-through-c1.snap.svg +95 -459
  104. package/tests/repros/__snapshots__/repro51-overlap-junction-crossing.snap.svg +64 -176
  105. package/tests/repros/__snapshots__/trace-overlap-box-resistor.snap.svg +51 -112
  106. package/tests/repros/assets/repro-atmega328p-fault-pullup.input.json +239 -0
  107. package/tests/repros/assets/repro-atmega328p-missing-gnd-netlabel.input.json +432 -0
  108. package/tests/repros/repro-atmega328p-fault-pullup.test.ts +11 -0
  109. package/tests/repros/repro-atmega328p-missing-gnd-netlabel.test.ts +16 -0
  110. package/tests/solvers/SchematicTraceSingleLineSolver2/__snapshots__/SchematicTraceSingleLineSolver2_01-example17-d1_1-u1_1.snap.svg +59 -159
  111. package/tests/solvers/TraceCleanupSolver/__snapshots__/TraceCleanupSolver.snap.svg +54 -118
  112. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/__snapshots__/TraceLabelOverlapAvoidanceSolver.snap.svg +58 -245
  113. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/renderComparisonView/__snapshots__/renderComparisonView01.snap.svg +73 -222
  114. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/renderComparisonView/__snapshots__/renderComparisonView02.snap.svg +65 -204
  115. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/renderComparisonView/__snapshots__/renderComparisonView03.snap.svg +65 -183
  116. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/sub-solver/__snapshots__/MergedNetLabelObstacles.snap.svg +54 -139
  117. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/sub-solver/__snapshots__/OverlapAvoidanceStepSolver.snap.svg +61 -215
  118. package/tests/solvers/TraceLabelOverlapAvoidanceSolver/sub-solver/__snapshots__/SingleOverlapSolver.snap.svg +54 -124
@@ -0,0 +1,146 @@
1
+ import path from "node:path"
2
+ import { readFile } from "node:fs/promises"
3
+ import { SchematicTracePipelineSolver } from "lib/solvers/SchematicTracePipelineSolver/SchematicTracePipelineSolver"
4
+ import { PipelineStageDebugRunner } from "lib/testing/PipelineStageDebugRunner"
5
+ import type { InputProblem } from "lib/types/InputProblem"
6
+
7
+ type Options = {
8
+ inputPath: string
9
+ outDir?: string
10
+ stopAfterStage?: string
11
+ pngSize: number
12
+ writePng: boolean
13
+ writeSvg: boolean
14
+ writeGraphicsJson: boolean
15
+ writeStepPngs: boolean
16
+ }
17
+
18
+ function printUsage() {
19
+ console.log(`Usage: bun run debug:pipeline <input.json> [options]
20
+
21
+ Options:
22
+ --out <dir> Output directory
23
+ --stop-after <stage|n> Stop after a stage name or 1-based stage number
24
+ --png-size <px> PNG width and height, default 1536
25
+ --no-png Do not write .png files
26
+ --svg Also write .svg files
27
+ --no-json Do not write .graphics.json files
28
+ --step-pngs Also write one PNG per graphics step when step values exist
29
+
30
+ Example:
31
+ bun run debug:pipeline tests/assets/example01.json
32
+ `)
33
+ }
34
+
35
+ function parseArgs(argv: string[]): Options {
36
+ const args = [...argv]
37
+ const inputPath = args.shift()
38
+ if (!inputPath || inputPath === "--help" || inputPath === "-h") {
39
+ printUsage()
40
+ process.exit(inputPath ? 0 : 1)
41
+ }
42
+
43
+ const options: Options = {
44
+ inputPath,
45
+ pngSize: 1536,
46
+ writePng: true,
47
+ writeSvg: false,
48
+ writeGraphicsJson: true,
49
+ writeStepPngs: false,
50
+ }
51
+
52
+ while (args.length > 0) {
53
+ const arg = args.shift()
54
+ if (arg === "--out") {
55
+ options.outDir = args.shift()
56
+ if (!options.outDir) throw new Error("--out requires a directory")
57
+ continue
58
+ }
59
+ if (arg === "--stop-after") {
60
+ options.stopAfterStage = args.shift()
61
+ if (!options.stopAfterStage) {
62
+ throw new Error("--stop-after requires a stage name or number")
63
+ }
64
+ continue
65
+ }
66
+ if (arg === "--png-size") {
67
+ const pngSize = Number(args.shift())
68
+ if (!Number.isFinite(pngSize) || pngSize <= 0) {
69
+ throw new Error("--png-size requires a positive number")
70
+ }
71
+ options.pngSize = pngSize
72
+ continue
73
+ }
74
+ if (arg === "--no-png") {
75
+ options.writePng = false
76
+ continue
77
+ }
78
+ if (arg === "--svg") {
79
+ options.writeSvg = true
80
+ continue
81
+ }
82
+ if (arg === "--no-json") {
83
+ options.writeGraphicsJson = false
84
+ continue
85
+ }
86
+ if (arg === "--step-pngs") {
87
+ options.writeStepPngs = true
88
+ continue
89
+ }
90
+ throw new Error(`Unknown argument: ${arg}`)
91
+ }
92
+
93
+ return options
94
+ }
95
+
96
+ function getDefaultOutputDir(inputPath: string) {
97
+ const basename = path.basename(inputPath).replace(/\.json$/i, "")
98
+ const timestamp = new Date().toISOString().replace(/[:.]/g, "-")
99
+ return path.resolve(
100
+ process.cwd(),
101
+ "tmp",
102
+ "schematic-trace-debug",
103
+ `${basename}-${timestamp}`,
104
+ )
105
+ }
106
+
107
+ const options = parseArgs(process.argv.slice(2))
108
+ const inputPath = path.resolve(process.cwd(), options.inputPath)
109
+ const inputProblem = JSON.parse(
110
+ await readFile(inputPath, "utf8"),
111
+ ) as InputProblem
112
+ const outputDir = options.outDir
113
+ ? path.resolve(process.cwd(), options.outDir)
114
+ : getDefaultOutputDir(inputPath)
115
+ const solver = new SchematicTracePipelineSolver(inputProblem)
116
+
117
+ const runner = new PipelineStageDebugRunner({
118
+ pipelineSolver: solver,
119
+ outputDir,
120
+ writeGraphicsJson: options.writeGraphicsJson,
121
+ writePng: options.writePng,
122
+ writeSvg: options.writeSvg,
123
+ pngWidth: options.pngSize,
124
+ pngHeight: options.pngSize,
125
+ writeStepPngs: options.writeStepPngs,
126
+ stopAfterStage: options.stopAfterStage,
127
+ context: {
128
+ inputPath: path.relative(process.cwd(), inputPath),
129
+ stopAfterStage: options.stopAfterStage ?? "",
130
+ writePng: options.writePng,
131
+ writeSvg: options.writeSvg,
132
+ writeGraphicsJson: options.writeGraphicsJson,
133
+ writeStepPngs: options.writeStepPngs,
134
+ pngSize: options.pngSize,
135
+ },
136
+ onLog: (line) => console.log(line),
137
+ })
138
+
139
+ const result = await runner.run()
140
+
141
+ console.log(`\nWrote ${result.stageArtifacts.length} stage artifact(s).`)
142
+ console.log(`Output: ${path.relative(process.cwd(), result.outputDir)}`)
143
+
144
+ if (result.error) {
145
+ process.exitCode = 1
146
+ }
@@ -0,0 +1,4 @@
1
+ import { PipelineDebugger } from "site/components/PipelineDebugger"
2
+ import inputProblem from "../../tests/bug-reports/bug-report-20260706T220324Z/bug-report-20260706T220324Z.json"
3
+
4
+ export default () => <PipelineDebugger inputProblem={inputProblem as any} />
@@ -0,0 +1,4 @@
1
+ import { PipelineDebugger } from "site/components/PipelineDebugger"
2
+ import inputProblem from "../../tests/bug-reports/bug-report-20260707T020342Z/bug-report-20260707T020342Z.json"
3
+
4
+ export default () => <PipelineDebugger inputProblem={inputProblem as any} />
@@ -0,0 +1,4 @@
1
+ import { PipelineDebugger } from "site/components/PipelineDebugger"
2
+ import inputProblem from "../../tests/bug-reports/bug-report-20260707T092615Z/bug-report-20260707T092615Z.json"
3
+
4
+ export default () => <PipelineDebugger inputProblem={inputProblem as any} />
@@ -0,0 +1,4 @@
1
+ import { PipelineDebugger } from "site/components/PipelineDebugger"
2
+ import inputProblem from "../../tests/bug-reports/bug-report-20260707T134549Z/bug-report-20260707T134549Z.json"
3
+
4
+ export default () => <PipelineDebugger inputProblem={inputProblem as any} />
@@ -0,0 +1,4 @@
1
+ import { PipelineDebugger } from "site/components/PipelineDebugger"
2
+ import inputProblem from "../../tests/bug-reports/bug-report-20260707T134722Z/bug-report-20260707T134722Z.json"
3
+
4
+ export default () => <PipelineDebugger inputProblem={inputProblem as any} />
@@ -0,0 +1,4 @@
1
+ import { PipelineDebugger } from "site/components/PipelineDebugger"
2
+ import inputProblem from "../../tests/bug-reports/bug-report-20260707T140410Z/bug-report-20260707T140410Z.json"
3
+
4
+ export default () => <PipelineDebugger inputProblem={inputProblem as any} />
@@ -0,0 +1,4 @@
1
+ import { PipelineDebugger } from "site/components/PipelineDebugger"
2
+ import inputProblem from "../../tests/bug-reports/bug-report-20260707T141025Z/bug-report-20260707T141025Z.json"
3
+
4
+ export default () => <PipelineDebugger inputProblem={inputProblem as any} />
@@ -0,0 +1,4 @@
1
+ import { PipelineDebugger } from "site/components/PipelineDebugger"
2
+ import inputProblem from "../../tests/bug-reports/bug-report-20260707T141421Z/bug-report-20260707T141421Z.json"
3
+
4
+ export default () => <PipelineDebugger inputProblem={inputProblem as any} />