AgentSkillsCN

typdd

当用户希望在Typst中绘制、渲染、可视化或自定义二元决策图(BDD),或询问有关布尔表达式图、决策树,或逻辑电路可视化时使用此功能。

SKILL.md
--- frontmatter
name: typdd
description: Use when user wants to draw, render, visualize, or customize a Binary Decision Diagram (BDD) in Typst, or asks about boolean expression diagrams, decision trees, or logic circuit visualization.
argument-hint: <boolean expression or customization request>
allowed-tools:
  - Write
  - Edit
  - Bash
  - Read
  - Glob

typdd

Render publication-ready BDD diagrams in Typst. Write #bdd("expr"), typdd handles parsing, building, reducing, layout, and rendering via fletcher.

Workflow

  1. New file: create .typ with #bdd(...)existing file: add/edit #bdd(...) calls
  2. Ensure #import "@preview/typdd:0.1.0": bdd is at the top
  3. Compile: typst compile file.typ file.png (add --root . for local imports)

Example

typst
#import "@preview/typdd:0.1.0": bdd
#set page(width: auto, height: auto, margin: 1em)
#set text(font: "New Computer Modern", size: 10pt)

#grid(
  columns: 3, column-gutter: 2em, align: center + horizon,
  bdd("x1 & x2"),
  bdd("x1 ^ x2", style: "presentation"),
  bdd("a & (b | !c)", labels: (a: $alpha$, b: $beta$, c: $gamma$), compact: true),
)

API — bdd(expr, ..options)

ParameterTypeDefaultDescription
exprstrrequiredBoolean expression
stylestr"classic"classic / paper / presentation / curved
orderarraynoneVariable ordering, e.g. ("x3","x1","x2")
labelsdict(:)Display names: (x1: $alpha$) or (a: "emoji")
show-edge-labelsboolfalseShow 0/1 on edges
directionstr"TB"TB / BT / LR / RL
scalefloat1.0Uniform scale factor
compactboolfalseTighter spacing for large BDDs
reducedbooltrueApply BDD reduction (set false for teaching)
center-rootbooltrueCenter on root node
node-sep / level-seplengthautoSpacing overrides
show-complementboolfalseComplement edge bubbles

bdd-from-json(data, ..options) — same rendering options, imports from JSON interchange format.

Operators

& AND · | OR · ! NOT · ^ XOR · => IMPLIES · ~& NAND · ~| NOR · ~^ XNOR · ite(c,t,f)

Precedence (low→high): =>|^&!. Variables: alphanumeric (x1, input_A). Constants: 0, 1, true, false.

Styles

classic (B&W default) · paper (thin grayscale) · presentation (blue/colored) · curved (curved edges)

Common Mistakes

MistakeFix
Missing #set page(width: auto, height: auto)Add it for standalone images
Using && or ||Single-char: & and |
Hyphenated variable namesAlphanumeric only: input_A not input-A
>20 variables or >1000 char expressionSimplify or use compact: true