mintchip 0.2.0__py3-none-any.whl
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.
- mintchip/__init__.py +101 -0
- mintchip/__main__.py +7 -0
- mintchip/chips/__init__.py +7 -0
- mintchip/chips/bar.py +233 -0
- mintchip/chips/ci.py +194 -0
- mintchip/chips/delta.py +164 -0
- mintchip/chips/dist.py +384 -0
- mintchip/chips/funnel.py +129 -0
- mintchip/chips/gauge.py +197 -0
- mintchip/chips/num.py +55 -0
- mintchip/chips/rank.py +182 -0
- mintchip/chips/ratio.py +141 -0
- mintchip/chips/share.py +164 -0
- mintchip/chips/spark.py +278 -0
- mintchip/chips/strip.py +173 -0
- mintchip/chips/timeline.py +257 -0
- mintchip/chips/waterfall.py +212 -0
- mintchip/cli.py +691 -0
- mintchip/diff.py +645 -0
- mintchip/directives.py +782 -0
- mintchip/doctor.py +145 -0
- mintchip/fmt.py +135 -0
- mintchip/guide.py +189 -0
- mintchip/ingest.py +725 -0
- mintchip/prose.py +225 -0
- mintchip/render/__init__.py +1 -0
- mintchip/render/html.py +295 -0
- mintchip/render/svg_base.py +337 -0
- mintchip/render/text_base.py +215 -0
- mintchip/scales.py +117 -0
- mintchip/skill.py +332 -0
- mintchip/spec.py +659 -0
- mintchip/tables.py +1043 -0
- mintchip/themes.py +102 -0
- mintchip-0.2.0.dist-info/METADATA +274 -0
- mintchip-0.2.0.dist-info/RECORD +39 -0
- mintchip-0.2.0.dist-info/WHEEL +4 -0
- mintchip-0.2.0.dist-info/entry_points.txt +2 -0
- mintchip-0.2.0.dist-info/licenses/LICENSE +21 -0
mintchip/themes.py
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"""Ink roles and the four themes (auto, light, dark, mono).
|
|
2
|
+
|
|
3
|
+
A theme says how each ink role is painted. It never names a background: chips paint no
|
|
4
|
+
background, so the reader's surface shows through. In the ``auto`` theme, ``ink`` is
|
|
5
|
+
``currentColor`` and the other roles are CSS custom properties with fallbacks that reach 3:1
|
|
6
|
+
contrast on both a white (#FFFFFF) and a dark (#14181F) surface.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import re
|
|
12
|
+
from dataclasses import dataclass, replace
|
|
13
|
+
|
|
14
|
+
__all__ = ["ROLES", "THEMES", "Theme", "contrast_ratio", "relative_luminance", "resolve_theme"]
|
|
15
|
+
|
|
16
|
+
# Paint roles a renderer may ask for. "context" is ink at reduced opacity (see svg_base).
|
|
17
|
+
ROLES = ("ink", "context", "accent", "good", "bad", "warn")
|
|
18
|
+
|
|
19
|
+
# Text colours a standalone SVG sets for itself in light and dark mode.
|
|
20
|
+
LIGHT_INK = "#1A1D21"
|
|
21
|
+
DARK_INK = "#E6E9EE"
|
|
22
|
+
|
|
23
|
+
_ACCENT = "#3B7DDD" # blue: "look here", never red
|
|
24
|
+
_GOOD = "#2A9152"
|
|
25
|
+
_BAD = "#DC4535"
|
|
26
|
+
_WARN = "#B87A00"
|
|
27
|
+
|
|
28
|
+
_HEX = re.compile(r"#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})")
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@dataclass(frozen=True)
|
|
32
|
+
class Theme:
|
|
33
|
+
"""How each ink role is painted. ``auto`` themes emit CSS (currentColor, var())."""
|
|
34
|
+
|
|
35
|
+
name: str
|
|
36
|
+
ink: str
|
|
37
|
+
accent: str
|
|
38
|
+
good: str
|
|
39
|
+
bad: str
|
|
40
|
+
warn: str
|
|
41
|
+
auto: bool = False
|
|
42
|
+
|
|
43
|
+
def paint(self, role: str) -> str:
|
|
44
|
+
"""CSS colour for a role. ``context`` uses ink; svg_base lowers its opacity."""
|
|
45
|
+
if role in ("ink", "context"):
|
|
46
|
+
return "currentColor" if self.auto else self.ink
|
|
47
|
+
if role not in ROLES:
|
|
48
|
+
raise ValueError(f"unknown ink role {role!r}; use one of {', '.join(ROLES)}")
|
|
49
|
+
colour = getattr(self, role)
|
|
50
|
+
if self.auto and colour == AUTO_FALLBACKS[role]:
|
|
51
|
+
return f"var(--mc-{role}, {colour})"
|
|
52
|
+
return colour
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
AUTO_FALLBACKS = {"accent": _ACCENT, "good": _GOOD, "bad": _BAD, "warn": _WARN}
|
|
56
|
+
|
|
57
|
+
THEMES: dict[str, Theme] = {
|
|
58
|
+
"auto": Theme("auto", "currentColor", _ACCENT, _GOOD, _BAD, _WARN, auto=True),
|
|
59
|
+
"light": Theme("light", LIGHT_INK, _ACCENT, _GOOD, _BAD, _WARN),
|
|
60
|
+
"dark": Theme("dark", DARK_INK, _ACCENT, _GOOD, _BAD, _WARN),
|
|
61
|
+
"mono": Theme("mono", "#111111", "#111111", "#111111", "#111111", "#111111"),
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def resolve_theme(theme: str | Theme = "auto", accent: str | None = None) -> Theme:
|
|
66
|
+
"""Look up a theme by name (or pass one through) and apply an ``accent`` override."""
|
|
67
|
+
if isinstance(theme, str):
|
|
68
|
+
if theme not in THEMES:
|
|
69
|
+
raise ValueError(f"unknown theme {theme!r}; use one of {', '.join(THEMES)}")
|
|
70
|
+
theme = THEMES[theme]
|
|
71
|
+
elif not isinstance(theme, Theme):
|
|
72
|
+
raise TypeError(f"theme must be a name or a Theme, not {type(theme).__name__}")
|
|
73
|
+
if accent is not None:
|
|
74
|
+
if not isinstance(accent, str) or not _HEX.fullmatch(accent):
|
|
75
|
+
raise ValueError(f"accent must be a hex colour like '#2563EB', not {accent!r}")
|
|
76
|
+
theme = replace(theme, accent=accent)
|
|
77
|
+
return theme
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
def _rgb(colour: str) -> tuple[float, float, float]:
|
|
81
|
+
if not _HEX.fullmatch(colour):
|
|
82
|
+
raise ValueError(f"expected a hex colour like '#1F5A9D', got {colour!r}")
|
|
83
|
+
h = colour[1:]
|
|
84
|
+
if len(h) == 3:
|
|
85
|
+
h = "".join(ch * 2 for ch in h)
|
|
86
|
+
return int(h[0:2], 16) / 255, int(h[2:4], 16) / 255, int(h[4:6], 16) / 255
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def relative_luminance(colour: str) -> float:
|
|
90
|
+
"""WCAG 2.1 relative luminance of a hex colour."""
|
|
91
|
+
|
|
92
|
+
def lin(c: float) -> float:
|
|
93
|
+
return c / 12.92 if c <= 0.03928 else ((c + 0.055) / 1.055) ** 2.4
|
|
94
|
+
|
|
95
|
+
r, g, b = _rgb(colour)
|
|
96
|
+
return 0.2126 * lin(r) + 0.7152 * lin(g) + 0.0722 * lin(b)
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def contrast_ratio(a: str, b: str) -> float:
|
|
100
|
+
"""WCAG 2.1 contrast ratio between two hex colours (1 to 21)."""
|
|
101
|
+
hi, lo = sorted((relative_luminance(a), relative_luminance(b)), reverse=True)
|
|
102
|
+
return (hi + 0.05) / (lo + 0.05)
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: mintchip
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Word-sized graphics for the numbers in an agent's report: sparklines, intervals, before/after and pass/fail chips in text, Markdown or HTML, from one shell command.
|
|
5
|
+
Project-URL: Repository, https://github.com/blaiszik/mintchip
|
|
6
|
+
Author: Ben Blaiszik
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Keywords: agents,cli,data-visualization,llm,reporting,small multiples,sparklines,svg,tufte,unicode,word-sized graphics
|
|
10
|
+
Classifier: Development Status :: 3 - Alpha
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
15
|
+
Requires-Python: >=3.10
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
18
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# mintchip
|
|
22
|
+
|
|
23
|
+
Word-sized graphics for the numbers in an agent's report. A trend, an interval, a before and
|
|
24
|
+
after or a pass/fail run sits inside the sentence or table cell that mentions it, as plain text,
|
|
25
|
+
Markdown or HTML, from one shell command. Python standard library only.
|
|
26
|
+
|
|
27
|
+

|
|
28
|
+
|
|
29
|
+
<!-- BEGIN mintchip:hero -->
|
|
30
|
+
**Before**: the report as an agent usually writes it.
|
|
31
|
+
|
|
32
|
+
```text
|
|
33
|
+
The ablation finished (5 seeds, 8k steps each). Retrieval did best: validation
|
|
34
|
+
loss went from 1.84 to 1.32, 0.96, 0.74, 0.61, 0.52, 0.46, 0.43 and finally
|
|
35
|
+
0.42, which is inside the 0.38–0.48 target band, and accuracy reached 0.82, a
|
|
36
|
+
lift of +0.08 over the baseline (95% CI +0.05 to +0.11). The reranker reached
|
|
37
|
+
0.79 accuracy (+0.05, 95% CI +0.02 to +0.08) with a final validation loss of
|
|
38
|
+
0.51. Warmup reached 0.75 (+0.01, 95% CI −0.02 to +0.04), so its effect is not
|
|
39
|
+
distinguishable from zero; its validation loss ended at 0.70. The baseline
|
|
40
|
+
reached 0.74 accuracy and a final validation loss of 0.78.
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**After**: the same report with two chips and one table, rendered as HTML (`--format html`) in your
|
|
44
|
+
light or dark theme,
|
|
45
|
+
|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
and as it prints in a terminal:
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
The ablation finished (5 seeds, 8k steps). Retrieval wins: val loss settled at
|
|
52
|
+
0.42 (range 0.42 to 1.84) █▆▄▃▂▂▁▁▁, inside the target band, and accuracy rose
|
|
53
|
+
by +0.08 (95% CI +0.05 to +0.11) [·│···├─●─┤·]. Warmup's interval crosses zero,
|
|
54
|
+
so drop it.
|
|
55
|
+
|
|
56
|
+
variant accuracy lift, 95% CI val loss
|
|
57
|
+
−0.03 +0.13
|
|
58
|
+
────────────────────────────────────────────────────────
|
|
59
|
+
retrieval 0.82 +0.08 [··│··├─●─┤·] 0.42 █▅▄▃▂▁▁▁▁
|
|
60
|
+
reranker 0.79 +0.05 [··│├─●─┤···] 0.51 █▆▄▃▂▂▂▁▁
|
|
61
|
+
warmup 0.75 +0.01 [·├┼○┤······] 0.70 █▆▅▄▃▃▃▂▂
|
|
62
|
+
baseline 0.74 — 0.78 █▇▆▅▄▃▃▃▃
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
<details><summary>The two commands that wrote it</summary>
|
|
66
|
+
|
|
67
|
+
```text
|
|
68
|
+
$ cat message.txt
|
|
69
|
+
The ablation finished (5 seeds, 8k steps). Retrieval wins: val loss settled at {{spark 1.84 1.32 0.96 0.74 0.61 0.52 0.46 0.43 0.42 band=0.38:0.48}}, inside the target band, and accuracy rose by {{ci 0.08 0.05:0.11 level=0.95}}. Warmup's interval crosses zero, so drop it.
|
|
70
|
+
$ mintchip render message.txt
|
|
71
|
+
The ablation finished (5 seeds, 8k steps). Retrieval wins: val loss settled at 0.42 (range 0.42 to 1.84) █▆▄▃▂▂▁▁▁, inside the target band, and accuracy rose by +0.08 (95% CI +0.05 to +0.11) [·│···├─●─┤·]. Warmup's interval crosses zero, so drop it.
|
|
72
|
+
|
|
73
|
+
$ cat runs.json
|
|
74
|
+
[
|
|
75
|
+
{"variant": "retrieval", "acc": 0.82, "lift": [0.08, 0.05, 0.11], "loss": [1.84, 1.32, 0.96, 0.74, 0.61, 0.52, 0.46, 0.43, 0.42]},
|
|
76
|
+
{"variant": "reranker", "acc": 0.79, "lift": [0.05, 0.02, 0.08], "loss": [1.86, 1.41, 1.05, 0.83, 0.69, 0.6, 0.55, 0.52, 0.51]},
|
|
77
|
+
{"variant": "warmup", "acc": 0.75, "lift": [0.01, -0.02, 0.04], "loss": [1.8, 1.52, 1.25, 1.04, 0.9, 0.81, 0.75, 0.72, 0.7]},
|
|
78
|
+
{"variant": "baseline", "acc": 0.74, "lift": null, "loss": [1.85, 1.6, 1.36, 1.15, 0.99, 0.89, 0.83, 0.8, 0.78]}
|
|
79
|
+
]
|
|
80
|
+
$ mintchip table runs.json --col variant --col acc:num:accuracy --col 'lift:ci:lift, 95% CI' \
|
|
81
|
+
--col 'loss:spark:val loss' --set lift.level=0.95
|
|
82
|
+
variant accuracy lift, 95% CI val loss
|
|
83
|
+
−0.03 +0.13
|
|
84
|
+
────────────────────────────────────────────────────────
|
|
85
|
+
retrieval 0.82 +0.08 [··│··├─●─┤·] 0.42 █▅▄▃▂▁▁▁▁
|
|
86
|
+
reranker 0.79 +0.05 [··│├─●─┤···] 0.51 █▆▄▃▂▂▂▁▁
|
|
87
|
+
warmup 0.75 +0.01 [·├┼○┤······] 0.70 █▆▅▄▃▃▃▂▂
|
|
88
|
+
baseline 0.74 — 0.78 █▇▆▅▄▃▃▃▃
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
</details>
|
|
92
|
+
<!-- END mintchip:hero -->
|
|
93
|
+
|
|
94
|
+
## Install
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
pip install mintchip # or: uvx mintchip guide
|
|
98
|
+
mintchip skill --install --global # auto-detects Claude Code, Codex, Cursor, Antigravity
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Python 3.10 or later, no dependencies. It installs one command, `mintchip`.
|
|
102
|
+
|
|
103
|
+
## Three commands (plus pipes & diffs)
|
|
104
|
+
|
|
105
|
+
<!-- BEGIN mintchip:commands -->
|
|
106
|
+
**One chip.** Values fill the chip's slots in order; options are `--name value`.
|
|
107
|
+
|
|
108
|
+
```text
|
|
109
|
+
$ mintchip spark 1.84 1.32 0.96 0.74 0.61 0.52 0.46 0.43 0.42 --band 0.38:0.48
|
|
110
|
+
0.42 (range 0.42 to 1.84) █▆▄▃▂▂▁▁▁
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**A message.** `render` replaces each `{{kind …}}` directive in the prose with its chip. The tokens
|
|
114
|
+
are the ones the command line takes, with options as `name=value`.
|
|
115
|
+
|
|
116
|
+
```text
|
|
117
|
+
$ mintchip render - <<'EOF'
|
|
118
|
+
Val loss settled at {{spark 1.84 1.32 0.96 0.74 0.61 0.52 0.46 0.43 0.42 band=0.38:0.48}}, and retrieval lifted accuracy by {{ci 0.08 0.05:0.11 level=0.95}}.
|
|
119
|
+
EOF
|
|
120
|
+
Val loss settled at 0.42 (range 0.42 to 1.84) █▆▄▃▂▂▁▁▁, and retrieval lifted accuracy by +0.08 (95% CI +0.05 to +0.11) [·│···├─●─┤·].
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**A table.** Three or more comparable things go in a table, and each chip column shares one scale:
|
|
124
|
+
the `ci` column below is a forest plot with one zero line.
|
|
125
|
+
|
|
126
|
+
```text
|
|
127
|
+
$ mintchip table - --col variant --col acc:num:accuracy --col 'lift:ci:lift, 95% CI' \
|
|
128
|
+
--set lift.level=0.95 <<'EOF'
|
|
129
|
+
[
|
|
130
|
+
{"variant": "retrieval", "acc": 0.82, "lift": [0.08, 0.05, 0.11]},
|
|
131
|
+
{"variant": "reranker", "acc": 0.79, "lift": [0.05, 0.02, 0.08]},
|
|
132
|
+
{"variant": "warmup", "acc": 0.75, "lift": [0.01, -0.02, 0.04]},
|
|
133
|
+
{"variant": "baseline", "acc": 0.74, "lift": null}
|
|
134
|
+
]
|
|
135
|
+
EOF
|
|
136
|
+
variant accuracy lift, 95% CI
|
|
137
|
+
−0.03 +0.13
|
|
138
|
+
────────────────────────────────────────
|
|
139
|
+
retrieval 0.82 +0.08 [··│··├─●─┤·]
|
|
140
|
+
reranker 0.79 +0.05 [··│├─●─┤···]
|
|
141
|
+
warmup 0.75 +0.01 [·├┼○┤······]
|
|
142
|
+
baseline 0.74 —
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Every command takes `--format text|md|ansi|html|svg|json`, `--ascii` and `--compact`. stdout carries
|
|
146
|
+
only the result. A distortion, such as a clipped outlier or a cut axis, is marked in the chip and
|
|
147
|
+
named in a warning on stderr; `--strict` makes that exit 1.
|
|
148
|
+
<!-- END mintchip:commands -->
|
|
149
|
+
|
|
150
|
+
**Pipes, benchmark diffs, and diagnostics.** Parse real developer tool outputs with zero extra
|
|
151
|
+
dependencies, compare two runs, or verify glyph legibility in your terminal:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
git diff --numstat | mintchip from git-diff # share chip of changed lines by area
|
|
155
|
+
mintchip from hyperfine bench.json --format md # shared-scale dist + mean table
|
|
156
|
+
mintchip from junit results.xml # pass/fail strip per suite
|
|
157
|
+
mintchip diff main.json pr.json --fail-on-regression 5 # delta + CI forest plot (exit 1 on regression)
|
|
158
|
+
mintchip render report.txt --format html --fragment # embeddable HTML fragment (no <html> shell)
|
|
159
|
+
mintchip doctor # check UTF-8, ANSI, and Unicode/ASCII glyphs
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Pick a chip by what you have
|
|
163
|
+
|
|
164
|
+
Each image below is the chip at its real size; it takes the colour of the text around it, so it
|
|
165
|
+
reads in light and dark themes. The [gallery](gallery/README.md) shows every chip in a sentence,
|
|
166
|
+
in a table beside its siblings, and at its edge cases, with the warning each one prints.
|
|
167
|
+
|
|
168
|
+
<!-- BEGIN mintchip:catalog -->
|
|
169
|
+
| You have | Chip | At 1× | As text |
|
|
170
|
+
|---|---|---|---|
|
|
171
|
+
| One number, no context | [`num`](gallery/README.md#num) | — | `0.82 ± 0.03` |
|
|
172
|
+
| A series over time or steps | [`spark`](gallery/README.md#spark) |  | `0.42 █▆▄▃▂▂▁▁▁` |
|
|
173
|
+
| An estimate with an interval | [`ci`](gallery/README.md#ci) |  | `+0.08 [·│···├─●─┤·]` |
|
|
174
|
+
| Raw samples of one measurement | [`dist`](gallery/README.md#dist) |  | `med 20.3 ms [▃▃▃█·▃▃··▃]→47.8` |
|
|
175
|
+
| A value against a total | [`bar`](gallery/README.md#bar) |  | `82% ██████▌│` |
|
|
176
|
+
| A reading with a normal range | [`gauge`](gallery/README.md#gauge) |  | `7.38 [···├●───┤··]` |
|
|
177
|
+
| A before and an after value | [`delta`](gallery/README.md#delta) |  | `0.74→0.82 [··○────●··]` |
|
|
178
|
+
| A pass/warn/fail/skip result per item | [`strip`](gallery/README.md#strip) |  | `5/8 pass ███▄█×█·` |
|
|
179
|
+
| Parts of a whole | [`share`](gallery/README.md#share) |  | `62·28·10% ██████▏███▏█` |
|
|
180
|
+
| A count out of a total, or a probability | [`ratio`](gallery/README.md#ratio) |  | `3/10 ●●●○○○○○○○` |
|
|
181
|
+
| Durations of phases | [`timeline`](gallery/README.md#timeline) |  | `7.5 s ██▏██████▏██` |
|
|
182
|
+
| A position in a ranked field | [`rank`](gallery/README.md#rank) |  | `#2/18 [········●·]` |
|
|
183
|
+
| Signed contributions from a start to a total | [`waterfall`](gallery/README.md#waterfall) |  | `0.63→0.82 (+0.19)` |
|
|
184
|
+
| Counts through ordered stages | [`funnel`](gallery/README.md#funnel) |  | `1,200 → 290 (24%)` |
|
|
185
|
+
| Three or more of the same thing | `mintchip table` | | |
|
|
186
|
+
<!-- END mintchip:catalog -->
|
|
187
|
+
|
|
188
|
+
## For agents
|
|
189
|
+
|
|
190
|
+
- `mintchip skill --install --global` installs the skill for Claude Code, Codex, Cursor, and
|
|
191
|
+
Antigravity (auto-detected), or `--target agents-md` / `--target claude-md` to upsert a marked
|
|
192
|
+
block into `AGENTS.md` / `CLAUDE.md`.
|
|
193
|
+
- `mintchip guide` prints a cheat-sheet of under 6,000 characters: when a chip helps (and when to
|
|
194
|
+
leave plain numbers alone), the table above, the token grammar, and the three commands with real
|
|
195
|
+
output. It is written for a system prompt.
|
|
196
|
+
- [`skills/mintchip/SKILL.md`](skills/mintchip/SKILL.md) and [`llms.txt`](llms.txt) are generated
|
|
197
|
+
directly from `mintchip guide --write .` so they never drift.
|
|
198
|
+
- `mintchip guide --agents` prints a paragraph for your own `AGENTS.md` or `CLAUDE.md`:
|
|
199
|
+
|
|
200
|
+
<!-- BEGIN mintchip:agents -->
|
|
201
|
+
```markdown
|
|
202
|
+
## Reporting numbers with mintchip
|
|
203
|
+
When you report numbers (results, benchmarks, test runs, timings, comparisons), give the ones
|
|
204
|
+
with a shape a word-sized chip. Run `mintchip guide` once for the syntax. Then write the
|
|
205
|
+
message with `{{kind …}}` directives, e.g. `{{spark 1.84 0.96 0.42}}` or
|
|
206
|
+
`{{ci 0.08 0.05:0.11 level=0.95}}`, and pipe it through `mintchip render` (`--format md` for
|
|
207
|
+
Markdown); put three or more comparable rows in `mintchip table`. Keep one chip per sentence,
|
|
208
|
+
two at most, and leave numbers with no shape as plain numbers.
|
|
209
|
+
```
|
|
210
|
+
<!-- END mintchip:agents -->
|
|
211
|
+
|
|
212
|
+
- `mintchip schema [KIND]` prints JSON Schema (draft 2020-12) for chip specs, ready to register
|
|
213
|
+
as a tool definition. A directive takes the same JSON: `{{ {"chip": "ci", "estimate": 0.08,
|
|
214
|
+
"interval": [0.05, 0.11]} }}`.
|
|
215
|
+
- [Recipes](gallery/README.md#recipes-for-coding-agents) for test results, diff size, coverage,
|
|
216
|
+
benchmarks, time per phase and context budget.
|
|
217
|
+
|
|
218
|
+
## Design rules
|
|
219
|
+
|
|
220
|
+
1. **Bare.** The number in the text's own type, then a graphic with no frame, fill or border.
|
|
221
|
+
2. **Designed at 1×.** At most three kinds of mark; strokes at least 1.25 and dots at least
|
|
222
|
+
1.75 units on a 16-unit line. A chip is never taller than the text.
|
|
223
|
+
3. **Four ink roles.** Data in the text colour, context at reduced opacity, blue for "look
|
|
224
|
+
here", and green, amber and red only when you declare a direction or the data is
|
|
225
|
+
pass/warn/fail. Red means bad and nothing else.
|
|
226
|
+
4. **Comparable things share a scale**, automatically, in a table column or a sentence.
|
|
227
|
+
5. **Number first.** A reader who sees only the number loses the shape, never the fact.
|
|
228
|
+
6. **If the glyph cannot beat the numbers, print the numbers** (`waterfall`, `funnel`).
|
|
229
|
+
7. **Three or more comparable values make a table.** One chip per sentence is normal; two is
|
|
230
|
+
the ceiling.
|
|
231
|
+
8. **Distortions are announced**: a clipped outlier, a cut axis, a downsampled series or a
|
|
232
|
+
stretched flat one gets a mark in the chip and a warning on stderr.
|
|
233
|
+
|
|
234
|
+
## Python
|
|
235
|
+
|
|
236
|
+
<!-- BEGIN mintchip:python -->
|
|
237
|
+
```python
|
|
238
|
+
>>> import mintchip as mc
|
|
239
|
+
>>> loss = mc.spark([1.84, 1.32, 0.96, 0.74, 0.61, 0.52, 0.46, 0.43, 0.42], band=(0.38, 0.48))
|
|
240
|
+
>>> print(loss)
|
|
241
|
+
0.42 (range 0.42 to 1.84) █▆▄▃▂▂▁▁▁
|
|
242
|
+
>>> lift = mc.ci(0.08, (0.05, 0.11), level=0.95)
|
|
243
|
+
>>> print(mc.format_prose("Loss settled at {loss}; accuracy rose by {lift}.", loss=loss, lift=lift))
|
|
244
|
+
Loss settled at 0.42 █▆▄▃▂▂▁▁▁; accuracy rose by +0.08 [·│···├─●─┤·].
|
|
245
|
+
>>> lift.to_dict()
|
|
246
|
+
{'chip': 'ci', 'estimate': 0.08, 'interval': [0.05, 0.11], 'level': 0.95}
|
|
247
|
+
>>> rows = [{"run": "retrieval", "lift": (0.08, 0.05, 0.11)}, {"run": "warmup", "lift": (0.01, -0.02, 0.04)}]
|
|
248
|
+
>>> print(mc.table(rows, {"run": "text", "lift": {"chip": "ci", "level": 0.95}}))
|
|
249
|
+
run lift
|
|
250
|
+
−0.03 +0.13
|
|
251
|
+
──────────────────────────────
|
|
252
|
+
retrieval +0.08 [··│··├─●─┤·]
|
|
253
|
+
warmup +0.01 [·├┼○┤······]
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
A chip is a small record; drawing happens when you render it: `chip.text(ascii=, compact=, color=)`,
|
|
257
|
+
`chip.markdown()`, `chip.svg(theme=, standalone=)`, `chip.html()` (inline, with a popover that needs
|
|
258
|
+
no JavaScript) and `chip.save('x.svg')`. Prose and tables render the same ways, and
|
|
259
|
+
`mc.document(title, blocks)` makes a whole page styled by `mc.css()`.
|
|
260
|
+
<!-- END mintchip:python -->
|
|
261
|
+
|
|
262
|
+
## Development
|
|
263
|
+
|
|
264
|
+
```bash
|
|
265
|
+
uv sync --extra dev
|
|
266
|
+
uv run pytest -q
|
|
267
|
+
uv run ruff check .
|
|
268
|
+
uv run python gallery/build_gallery.py # regenerate the examples in both READMEs and gallery/output
|
|
269
|
+
uv run mintchip guide --write . # regenerate skills/mintchip/SKILL.md and llms.txt
|
|
270
|
+
uv run python scripts/preview.py --out /tmp/preview.html # judge chips at 1x, light and dark
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
Every output shown in this README is generated: `tests/test_readme.py` fails when it differs
|
|
274
|
+
from what the code prints now. MIT licensed.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
mintchip/__init__.py,sha256=4yi0hRvYQWcHWCVFYikJsKJKx7XjvpPpQ9H-oJs9zeg,2521
|
|
2
|
+
mintchip/__main__.py,sha256=VbopMzMGYXDQfUzXRFiajwIzAuOs-SWSnSOJ-T08EU0,139
|
|
3
|
+
mintchip/cli.py,sha256=vzKHX47X3k58wJwu3WKrCstf5nW6mONzKoJ9GuWHkOg,28240
|
|
4
|
+
mintchip/diff.py,sha256=CM3Q-iaBtM6FTiUEOXNKBnMxrBeGfLy8C7E7Y7807gU,22476
|
|
5
|
+
mintchip/directives.py,sha256=TezqiC-4472iGog5CVz__d11NnqibAWeQtMleBSxDKg,30541
|
|
6
|
+
mintchip/doctor.py,sha256=D7PjL1TAHmLkJPiPf6h98rxNgQMa4Z4i-N35_fTcBuc,5488
|
|
7
|
+
mintchip/fmt.py,sha256=wFX0RY0K9e9A5gtYryyrhz1iQ7Pgek9wAdLwHcGT2iA,5234
|
|
8
|
+
mintchip/guide.py,sha256=kq98Cja5-b9feWKkxVsegmPmvA146zp0d3zrMZT4EiI,7838
|
|
9
|
+
mintchip/ingest.py,sha256=8NJBe_Phxo2h1RinItNwhxRDfNP27nrG5gEqUfwevc4,26962
|
|
10
|
+
mintchip/prose.py,sha256=S9oT6qYmJ91k6mjleAETfIdeXXuGpcNgJ9K3lJWvMag,9755
|
|
11
|
+
mintchip/scales.py,sha256=9ix-p42JpznIUhy_sT_lLR5tH5XT8X8RnHdpOm_k6ts,4447
|
|
12
|
+
mintchip/skill.py,sha256=ldGNDpnyIHKdNkTt8ZqvfJOJuLN3GQ23I00C4dbjZmQ,10824
|
|
13
|
+
mintchip/spec.py,sha256=7KIAxmQX8gcrH5YD3NgYgyW6YSlGdbU48MQfCYic8bI,25962
|
|
14
|
+
mintchip/tables.py,sha256=uBur19zddo-V-ZyGf1vm23F7s4CtKBWU1m734Fp0tjI,45576
|
|
15
|
+
mintchip/themes.py,sha256=s63YeCS162ZEGJbZyeniqXKxVWd4lw22wVItQOve3hc,3779
|
|
16
|
+
mintchip/chips/__init__.py,sha256=sajLfy5xyiLURwskvV7H2K-dJ5z-EyOwt-piqkVBO9U,215
|
|
17
|
+
mintchip/chips/bar.py,sha256=-CaJAmh66gCOiWwiQQf6KddPGwdt4zr7c3uHyTTes40,9360
|
|
18
|
+
mintchip/chips/ci.py,sha256=yqbBmWq5mlEz15Pp972UEPUJTEZBYhcSxGC4Z4oYq2Y,7329
|
|
19
|
+
mintchip/chips/delta.py,sha256=-p0TWz217-Z3F1TZPHzURvezzhp_7cqBHr4CV8KKq_k,6663
|
|
20
|
+
mintchip/chips/dist.py,sha256=OYI9SDCf6Hsd3hL2Gutg66RfRs290BoHTqEsDaBBVuY,15240
|
|
21
|
+
mintchip/chips/funnel.py,sha256=JXJxsdKzP9kAddAgM6_elTkCpI0P6wJE1XxDmOG21y8,5149
|
|
22
|
+
mintchip/chips/gauge.py,sha256=ZCcckRkNTBYpRBC8SVNXbJFbq78uiZIvzsUlNqX2HIA,7477
|
|
23
|
+
mintchip/chips/num.py,sha256=fE3NK7To85D5TT4YbhwAjuTxrs_1K-pjtJ0fCF0RiyQ,2443
|
|
24
|
+
mintchip/chips/rank.py,sha256=T8dTSrzTdWiglb4IvVxGZCZFdLBpNF48dWAqCVzOgNc,7383
|
|
25
|
+
mintchip/chips/ratio.py,sha256=coRCdjiSxGsn9zVp1RtxE_E_bxGue37t6XCW88WK_qc,5437
|
|
26
|
+
mintchip/chips/share.py,sha256=BiiAEVCAwWkX2yBTsmUXAf3AI7mbadoV8EZIj1mYlpU,6624
|
|
27
|
+
mintchip/chips/spark.py,sha256=dYXjbQqth9WnfZoBDMO-Xw1_IXPt_JZOlBasUeyY9dM,11177
|
|
28
|
+
mintchip/chips/strip.py,sha256=nF1_6m56ATAdQkaH6GRr1-Cw6z_CHUkLwAEng9bmbtA,6996
|
|
29
|
+
mintchip/chips/timeline.py,sha256=2AC1LiT5yImLDArtqiJK7lOyCBAnNHgeLpB5ken1W8w,10786
|
|
30
|
+
mintchip/chips/waterfall.py,sha256=3xTV3hvrnCR6u2ZHTu3GvQN1p2nlt67v6shUxdvFdTw,8603
|
|
31
|
+
mintchip/render/__init__.py,sha256=YtHSSuvKb9WqYlXdE5BWaORMmQjqgUiMyd-U5YbQbro,90
|
|
32
|
+
mintchip/render/html.py,sha256=gXiHh5NYI2tiu-P8diFXd5cwq3UJuBo4RnnTTl2Xcao,13881
|
|
33
|
+
mintchip/render/svg_base.py,sha256=fiFj0AdaqxyBCPHVrkbzG9eHo7kCn80nnmTcDETkmBs,14067
|
|
34
|
+
mintchip/render/text_base.py,sha256=fO31qlmWTS-MfuJVJDDBQSI-adG7Uz_EkIUOVpQY23g,8026
|
|
35
|
+
mintchip-0.2.0.dist-info/METADATA,sha256=ZMzlk6F7jCdTxPxSfRj45T34sBDZxPxNf1pp0mnkqng,15518
|
|
36
|
+
mintchip-0.2.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
37
|
+
mintchip-0.2.0.dist-info/entry_points.txt,sha256=OJo3wQWPXjIpGY_ccnu0dxp4law9kNDK42AJBohpX00,47
|
|
38
|
+
mintchip-0.2.0.dist-info/licenses/LICENSE,sha256=J4aKSh2qG5yovBmKguURS9Kj4rJ1pUSApNbj8N0ZX4k,1069
|
|
39
|
+
mintchip-0.2.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ben Blaiszik
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|