@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.
- package/.agents/skills/schematic-trace-visualization/SKILL.md +115 -0
- package/.github/scripts/import-json-bug-report.ts +15 -1
- package/.github/workflows/json-bug-report.yml +3 -2
- package/AGENTS.md +22 -0
- package/dist/index.js +30 -22
- package/lib/solvers/Example28Solver/reroute.ts +10 -0
- package/lib/testing/PipelineStageDebugRunner.ts +344 -0
- package/package.json +3 -2
- package/scripts/debug-pipeline-stages.ts +146 -0
- package/site/bug-reports/bug-report-20260706T220324Z.page.tsx +4 -0
- package/site/bug-reports/bug-report-20260707T020342Z.page.tsx +4 -0
- package/site/bug-reports/bug-report-20260707T092615Z.page.tsx +4 -0
- package/site/bug-reports/bug-report-20260707T134549Z.page.tsx +4 -0
- package/site/bug-reports/bug-report-20260707T134722Z.page.tsx +4 -0
- package/site/bug-reports/bug-report-20260707T140410Z.page.tsx +4 -0
- package/site/bug-reports/bug-report-20260707T141025Z.page.tsx +4 -0
- package/site/bug-reports/bug-report-20260707T141421Z.page.tsx +4 -0
- package/tests/bug-reports/bug-report-20260706T213649Z/__snapshots__/bug-report-20260706T213649Z.snap.svg +386 -0
- package/tests/bug-reports/bug-report-20260706T213649Z/bug-report-20260706T213649Z.json +1471 -0
- package/tests/bug-reports/bug-report-20260706T213649Z/bug-report-20260706T213649Z.test.ts +12 -0
- package/tests/bug-reports/bug-report-20260706T220324Z/__snapshots__/bug-report-20260706T220324Z.snap.svg +357 -3448
- package/tests/bug-reports/bug-report-20260707T020342Z/__snapshots__/bug-report-20260707T020342Z.snap.svg +64 -0
- package/tests/bug-reports/bug-report-20260707T020342Z/bug-report-20260707T020342Z.json +233 -0
- package/tests/bug-reports/bug-report-20260707T020342Z/bug-report-20260707T020342Z.test.ts +12 -0
- package/tests/bug-reports/bug-report-20260707T092615Z/__snapshots__/bug-report-20260707T092615Z.snap.svg +252 -0
- package/tests/bug-reports/bug-report-20260707T092615Z/bug-report-20260707T092615Z.json +1392 -0
- package/tests/bug-reports/bug-report-20260707T092615Z/bug-report-20260707T092615Z.test.ts +12 -0
- package/tests/bug-reports/bug-report-20260707T134549Z/__snapshots__/bug-report-20260707T134549Z.snap.svg +124 -0
- package/tests/bug-reports/bug-report-20260707T134549Z/bug-report-20260707T134549Z.json +652 -0
- package/tests/bug-reports/bug-report-20260707T134549Z/bug-report-20260707T134549Z.test.ts +12 -0
- package/tests/bug-reports/bug-report-20260707T134722Z/__snapshots__/bug-report-20260707T134722Z.snap.svg +73 -0
- package/tests/bug-reports/bug-report-20260707T134722Z/bug-report-20260707T134722Z.json +265 -0
- package/tests/bug-reports/bug-report-20260707T134722Z/bug-report-20260707T134722Z.test.ts +12 -0
- package/tests/bug-reports/bug-report-20260707T140410Z/__snapshots__/bug-report-20260707T140410Z.snap.svg +154 -0
- package/tests/bug-reports/bug-report-20260707T140410Z/bug-report-20260707T140410Z.json +610 -0
- package/tests/bug-reports/bug-report-20260707T140410Z/bug-report-20260707T140410Z.test.ts +12 -0
- package/tests/bug-reports/bug-report-20260707T141025Z/__snapshots__/bug-report-20260707T141025Z.snap.svg +67 -0
- package/tests/bug-reports/bug-report-20260707T141025Z/bug-report-20260707T141025Z.json +185 -0
- package/tests/bug-reports/bug-report-20260707T141025Z/bug-report-20260707T141025Z.test.ts +12 -0
- package/tests/bug-reports/bug-report-20260707T141421Z/__snapshots__/bug-report-20260707T141421Z.snap.svg +114 -0
- package/tests/bug-reports/bug-report-20260707T141421Z/bug-report-20260707T141421Z.json +499 -0
- package/tests/bug-reports/bug-report-20260707T141421Z/bug-report-20260707T141421Z.test.ts +23 -0
- package/tests/examples/__snapshots__/example01.snap.svg +59 -162
- package/tests/examples/__snapshots__/example02.snap.svg +64 -273
- package/tests/examples/__snapshots__/example03.snap.svg +85 -290
- package/tests/examples/__snapshots__/example04.snap.svg +50 -94
- package/tests/examples/__snapshots__/example05.snap.svg +73 -191
- package/tests/examples/__snapshots__/example06.snap.svg +49 -95
- package/tests/examples/__snapshots__/example07.snap.svg +65 -218
- package/tests/examples/__snapshots__/example08.snap.svg +61 -143
- package/tests/examples/__snapshots__/example09.snap.svg +123 -493
- package/tests/examples/__snapshots__/example10.snap.svg +57 -136
- package/tests/examples/__snapshots__/example11.snap.svg +64 -173
- package/tests/examples/__snapshots__/example12.snap.svg +58 -159
- package/tests/examples/__snapshots__/example13.snap.svg +78 -348
- package/tests/examples/__snapshots__/example14.snap.svg +77 -293
- package/tests/examples/__snapshots__/example15.snap.svg +140 -984
- package/tests/examples/__snapshots__/example16.snap.svg +62 -162
- package/tests/examples/__snapshots__/example17.snap.svg +67 -198
- package/tests/examples/__snapshots__/example18.snap.svg +69 -249
- package/tests/examples/__snapshots__/example19.snap.svg +63 -202
- package/tests/examples/__snapshots__/example20.snap.svg +60 -148
- package/tests/examples/__snapshots__/example21.snap.svg +73 -298
- package/tests/examples/__snapshots__/example22.snap.svg +62 -156
- package/tests/examples/__snapshots__/example23.snap.svg +66 -172
- package/tests/examples/__snapshots__/example24.snap.svg +64 -164
- package/tests/examples/__snapshots__/example25.snap.svg +76 -299
- package/tests/examples/__snapshots__/example26.snap.svg +64 -164
- package/tests/examples/__snapshots__/example27.snap.svg +83 -300
- package/tests/examples/__snapshots__/example28.snap.svg +54 -115
- package/tests/examples/__snapshots__/example29.snap.svg +257 -1299
- package/tests/examples/__snapshots__/example30.snap.svg +91 -293
- package/tests/examples/__snapshots__/example31.snap.svg +47 -88
- package/tests/examples/__snapshots__/example32.snap.svg +107 -405
- package/tests/examples/__snapshots__/example33.snap.svg +71 -180
- package/tests/examples/__snapshots__/example34.snap.svg +55 -116
- package/tests/examples/__snapshots__/example35.snap.svg +69 -176
- package/tests/examples/__snapshots__/example36.snap.svg +65 -159
- package/tests/examples/__snapshots__/example37.snap.svg +75 -223
- package/tests/examples/__snapshots__/example38.snap.svg +46 -76
- package/tests/examples/__snapshots__/example39.snap.svg +51 -106
- package/tests/examples/__snapshots__/example40.snap.svg +83 -270
- package/tests/examples/__snapshots__/example41.snap.svg +54 -118
- package/tests/examples/__snapshots__/example42.snap.svg +67 -194
- package/tests/examples/__snapshots__/example43.snap.svg +62 -168
- package/tests/examples/__snapshots__/example44.snap.svg +86 -369
- package/tests/examples/__snapshots__/example45.snap.svg +60 -169
- package/tests/examples/__snapshots__/example46.snap.svg +80 -342
- package/tests/examples/__snapshots__/example47.snap.svg +82 -323
- package/tests/examples/__snapshots__/example48.snap.svg +64 -167
- package/tests/examples/__snapshots__/example49.snap.svg +120 -565
- package/tests/examples/__snapshots__/example50.snap.svg +71 -189
- package/tests/fixtures/getLastStepGraphicsObject.ts +38 -0
- package/tests/fixtures/getLastStepSvg.ts +9 -0
- package/tests/repros/__snapshots__/bugreport-001-gnd-overlap.snap.svg +67 -218
- package/tests/repros/__snapshots__/manufacturePartNumber-text-box.snap.svg +47 -87
- package/tests/repros/__snapshots__/netlabel-connector-through-rail-label.snap.svg +73 -272
- package/tests/repros/__snapshots__/repro-atmega328p-fault-pullup.snap.svg +88 -0
- package/tests/repros/__snapshots__/repro-atmega328p-missing-gnd-netlabel.snap.svg +118 -0
- package/tests/repros/__snapshots__/repro-bq24074-battery-charger.snap.svg +94 -395
- package/tests/repros/__snapshots__/repro-cc2340r5.snap.svg +88 -467
- package/tests/repros/__snapshots__/repro-ina237-current-monitor.snap.svg +109 -569
- package/tests/repros/__snapshots__/repro130-bq27441-fuel-gauge-trace-through-c1.snap.svg +95 -459
- package/tests/repros/__snapshots__/repro51-overlap-junction-crossing.snap.svg +64 -176
- package/tests/repros/__snapshots__/trace-overlap-box-resistor.snap.svg +51 -112
- package/tests/repros/assets/repro-atmega328p-fault-pullup.input.json +239 -0
- package/tests/repros/assets/repro-atmega328p-missing-gnd-netlabel.input.json +432 -0
- package/tests/repros/repro-atmega328p-fault-pullup.test.ts +11 -0
- package/tests/repros/repro-atmega328p-missing-gnd-netlabel.test.ts +16 -0
- package/tests/solvers/SchematicTraceSingleLineSolver2/__snapshots__/SchematicTraceSingleLineSolver2_01-example17-d1_1-u1_1.snap.svg +59 -159
- package/tests/solvers/TraceCleanupSolver/__snapshots__/TraceCleanupSolver.snap.svg +54 -118
- package/tests/solvers/TraceLabelOverlapAvoidanceSolver/__snapshots__/TraceLabelOverlapAvoidanceSolver.snap.svg +58 -245
- package/tests/solvers/TraceLabelOverlapAvoidanceSolver/renderComparisonView/__snapshots__/renderComparisonView01.snap.svg +73 -222
- package/tests/solvers/TraceLabelOverlapAvoidanceSolver/renderComparisonView/__snapshots__/renderComparisonView02.snap.svg +65 -204
- package/tests/solvers/TraceLabelOverlapAvoidanceSolver/renderComparisonView/__snapshots__/renderComparisonView03.snap.svg +65 -183
- package/tests/solvers/TraceLabelOverlapAvoidanceSolver/sub-solver/__snapshots__/MergedNetLabelObstacles.snap.svg +54 -139
- package/tests/solvers/TraceLabelOverlapAvoidanceSolver/sub-solver/__snapshots__/OverlapAvoidanceStepSolver.snap.svg +61 -215
- 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
|
+
}
|