jigstore 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.
- jigstore/__init__.py +10 -0
- jigstore/__main__.py +3 -0
- jigstore/chart/USAGE.md +20 -0
- jigstore/chart/__init__.py +6 -0
- jigstore/chart/png.py +45 -0
- jigstore/chart/render.py +1312 -0
- jigstore/cli.py +86 -0
- jigstore/mcp.py +268 -0
- jigstore/py.typed +0 -0
- jigstore/table/USAGE.md +17 -0
- jigstore/table/__init__.py +6 -0
- jigstore/table/render.py +665 -0
- jigstore-0.2.0.dist-info/METADATA +211 -0
- jigstore-0.2.0.dist-info/RECORD +18 -0
- jigstore-0.2.0.dist-info/WHEEL +5 -0
- jigstore-0.2.0.dist-info/entry_points.txt +2 -0
- jigstore-0.2.0.dist-info/licenses/LICENSE +21 -0
- jigstore-0.2.0.dist-info/top_level.txt +1 -0
jigstore/__init__.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""Jigstore: deterministic tools ("jigs") for AI agents, so the model writes a short spec
|
|
2
|
+
instead of generating the whole output token by token."""
|
|
3
|
+
|
|
4
|
+
__version__ = "0.2.0"
|
|
5
|
+
|
|
6
|
+
# name -> one-line summary. `jigstore list` prints this; `jigstore docs <name>` prints usage.
|
|
7
|
+
CATALOG = {
|
|
8
|
+
"chart": "12 chart types (bar, line, pie, waterfall, funnel, heatmap, sparkline...) from a JSON spec -> SVG or PNG",
|
|
9
|
+
"table": "rows or a CSV/JSON file -> Markdown, SVG, PNG, HTML or CSV, with totals, formats and sorting",
|
|
10
|
+
}
|
jigstore/__main__.py
ADDED
jigstore/chart/USAGE.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# chart
|
|
2
|
+
|
|
3
|
+
`jigstore chart '<json>' [-o out.svg|out.png]` prints the output path.
|
|
4
|
+
Spec can be `@file.json` or `-` (stdin). `-o -` prints the SVG.
|
|
5
|
+
|
|
6
|
+
Types: bar hbar line area scatter pie donut histogram waterfall funnel heatmap sparkline
|
|
7
|
+
|
|
8
|
+
Data:
|
|
9
|
+
- `"data":{"A":1,"B":2}` one series
|
|
10
|
+
- `"x":["Q1","Q2"],"series":{"2025":[1,2],"2026":[3,4]}` many series (heatmap: one per row)
|
|
11
|
+
- scatter: `"series":{"name":[[x,y,size?,"label"?]]}`; histogram: `"values":[..]`,`"bins":10`
|
|
12
|
+
- waterfall: changes, `"total":"Net"` adds a total bar
|
|
13
|
+
|
|
14
|
+
Options: title subtitle xlabel ylabel w h theme(light|dark) palette(default|colorblind|mono|warm|cool)
|
|
15
|
+
colors([..]|{series:color}) prefix suffix decimals legend(top|bottom|none) grid(bool) labels(bool)
|
|
16
|
+
ymin ymax refs([{"value":100,"label":"Target"}]) highlight("East"|[..]) sort(asc|desc)
|
|
17
|
+
stack(true|"percent") curve(linear|smooth|step) zero dots font bg("none")
|
|
18
|
+
pie/donut: max_slices hole center center_label. sparkline: area dot (default 120x32)
|
|
19
|
+
|
|
20
|
+
Example: `jigstore chart '{"type":"bar","data":{"N":12,"S":9},"highlight":"N"}' -o s.png`
|
jigstore/chart/png.py
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"""Optional PNG output. Uses cairosvg if installed, else the rsvg-convert binary."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import shutil
|
|
7
|
+
import subprocess
|
|
8
|
+
|
|
9
|
+
from .render import SpecError, render
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def to_png(svg: str, scale: float = 2.0) -> bytes:
|
|
13
|
+
"""Rasterise an SVG string. scale=2 gives crisp output on high-DPI screens."""
|
|
14
|
+
try:
|
|
15
|
+
import cairosvg # type: ignore
|
|
16
|
+
except ImportError:
|
|
17
|
+
cairosvg = None
|
|
18
|
+
if cairosvg is not None:
|
|
19
|
+
return cairosvg.svg2png(bytestring=svg.encode(), scale=scale)
|
|
20
|
+
exe = shutil.which("rsvg-convert")
|
|
21
|
+
if exe:
|
|
22
|
+
r = subprocess.run([exe, "-z", str(scale), "-f", "png"], input=svg.encode(), capture_output=True, check=False)
|
|
23
|
+
if r.returncode == 0:
|
|
24
|
+
return r.stdout
|
|
25
|
+
raise SpecError(f"rsvg-convert failed: {r.stderr.decode(errors='replace').strip()}")
|
|
26
|
+
raise SpecError(
|
|
27
|
+
"PNG needs cairosvg (pip install 'jigstore[png]') or rsvg-convert "
|
|
28
|
+
"(brew install librsvg / apt install librsvg2-bin); or write .svg instead"
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def save(spec, path: str, scale: float = 2.0) -> str:
|
|
33
|
+
"""Render spec to path. The extension (.svg or .png) picks the format. Returns the path."""
|
|
34
|
+
svg = render(spec)
|
|
35
|
+
ext = os.path.splitext(path)[1].lower()
|
|
36
|
+
if ext == ".png":
|
|
37
|
+
data = to_png(svg, scale)
|
|
38
|
+
with open(path, "wb") as f:
|
|
39
|
+
f.write(data)
|
|
40
|
+
elif ext in (".svg", ""):
|
|
41
|
+
with open(path, "w", encoding="utf-8") as f:
|
|
42
|
+
f.write(svg)
|
|
43
|
+
else:
|
|
44
|
+
raise SpecError(f"output must end in .svg or .png, got {path!r}")
|
|
45
|
+
return path
|