Jig, the knitting pattern workbench
A knitting pattern workbench where a designer and an AI agent edit the same
document. Every write, from either of them, goes through one gate and comes back
accepted or refused with the rule it broke and the nearest values that work.
The workbench itself needs JavaScript, because the numbers are computed rather
than stored. Everything below is a true account of what the page does.
Why pattern grading
Grading means resizing one sample garment across nine to thirteen sizes while
every number stays mutually constrained. Cast on is bust width times stitch
gauge, rounded to a multiple of the stitch repeat. A raglan yoke can only reach a
target stitch count in whole increase rounds of eight. Shaping has to land on
whole rows. Armhole depth, cross back and neck drop have to grow as the sizes
grow. Break any one of those and you get a pattern that reads fine and cannot be
knitted.
The worked example
Ask for a cast on of 87 stitches on a cable panel of 12 stitches per repeat plus
2 edge stitches. It is unreachable: 12k plus 2 gives 86 and then 98. The document
refuses the write and names both counts. Take 86 and it commits. That exchange is
the whole product, and it happens identically whether a person types the number
or an agent calls a tool.
The tools an agent can call in this page
Registered on document.modelContext while this tab is open. Four
read and four write, plus two that exist only while a chart panel is selected,
plus one offered to a separate yarn origin.
read_pattern, read the gauge, measurements, counts, rows and shaping.
read_chart, read a charted panel as a grid or row by row in words.
audit_pattern, check the whole pattern for contradictions.
export_pattern, export the finished pattern, withheld while the audit finds anything.
set_gauge, set stitch and row gauge from a measured swatch.
grade_sizes, grade the run from a sample size across a bust range.
edit_number, change one number on one size.
substitute_yarn, swap the yarn and recount whole skeins.
check_panel_fit and set_chart_cell, offered only while a chart panel is selected and withdrawn when it is deselected.
fit_published_pattern, offered to a separate yarn origin rather than to an agent on this page.
Two origins
The yarn data comes from a separate service at
jig-yarn-service.pages.dev,
embedded in an iframe carrying allow="tools" and reached by
getTools({ fromOrigins }). Community notes crossing that boundary are
held as untrusted text: one of them is a prompt injection sample committed on
purpose, and the workbench displays it, refuses to act on it, and records the
refusal.
Elsewhere