jigstore 0.2.0__tar.gz

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-0.2.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ankit Sharma
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.
@@ -0,0 +1,211 @@
1
+ Metadata-Version: 2.4
2
+ Name: jigstore
3
+ Version: 0.2.0
4
+ Summary: Deterministic tools for AI agents: write a short spec instead of generating the output.
5
+ Author: Ankit Sharma
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/jigstore/jigstore
8
+ Project-URL: Issues, https://github.com/jigstore/jigstore/issues
9
+ Project-URL: Changelog, https://github.com/jigstore/jigstore/blob/main/CHANGELOG.md
10
+ Keywords: ai-agents,llm,tools,charts,svg,token-efficient
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Typing :: Typed
18
+ Classifier: Topic :: Scientific/Engineering :: Visualization
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Provides-Extra: png
23
+ Requires-Dist: cairosvg>=2.5; extra == "png"
24
+ Dynamic: license-file
25
+
26
+ <p>
27
+ <picture>
28
+ <source media="(prefers-color-scheme: dark)" srcset="docs/brand/wordmark-on-dark.svg">
29
+ <img alt="jigstore" src="docs/brand/wordmark-on-light.svg" height="56">
30
+ </picture>
31
+ </p>
32
+
33
+ [![ci](https://github.com/jigstore/jigstore/actions/workflows/ci.yml/badge.svg)](https://github.com/jigstore/jigstore/actions/workflows/ci.yml)
34
+ [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
35
+ [![Sponsor](https://img.shields.io/badge/sponsor-GitHub%20Sponsors-ea4aaa.svg)](https://github.com/sponsors/ankit22sharma)
36
+ [![Buy me a coffee](https://img.shields.io/badge/buy%20me%20a%20coffee-support-e8590c.svg)](https://buymeacoffee.com/ankit22sharma)
37
+
38
+ Ready-made tools for AI agents. In a workshop, a jig lets you repeat a precise job every
39
+ time without redoing the setup. Jigstore does the same for agents: instead of having a
40
+ model generate an SVG, a chart script or a document token by token, the agent writes a
41
+ short spec and a deterministic tool does the rest. The output is the same every time,
42
+ the model writes about 20 times fewer tokens, and the result arrives in under a second
43
+ instead of 5 to 30 seconds of streaming.
44
+
45
+ Each tool is a jig in this catalog. The first one is a chart builder.
46
+
47
+ | jig | what it does |
48
+ |---|---|
49
+ | [`chart`](src/jigstore/chart/USAGE.md) | 12 chart types (bar, line, area, scatter, pie, donut, histogram, waterfall, funnel, heatmap, sparkline) from JSON to SVG or PNG |
50
+ | [`table`](src/jigstore/table/USAGE.md) | Rows, or a CSV/JSON file, to Markdown, SVG, PNG, HTML or CSV, with totals, formats, sorting and in-cell bars and sparklines |
51
+
52
+ ## Install
53
+
54
+ ```sh
55
+ pip install jigstore
56
+ # PNG output: also install cairosvg, or have rsvg-convert on PATH
57
+ pip install "jigstore[png]"
58
+ ```
59
+
60
+ No runtime dependencies. Python 3.10+.
61
+
62
+ ## Chart builder
63
+
64
+ ```sh
65
+ jigstore chart '{"type":"bar","title":"Revenue by region","data":{"North":1240000,"South":905000,"East":1530000,"West":712000},"prefix":"$"}' -o revenue.png
66
+ # prints: revenue.png
67
+ ```
68
+
69
+ ![bar](examples/bar.svg)
70
+
71
+ The CLI prints only the output path, so the result costs the agent a few tokens.
72
+ Errors are one line on stderr that say what to fix, with exit code 2.
73
+
74
+ From Python:
75
+
76
+ ```python
77
+ from jigstore.chart import render, save
78
+
79
+ svg = render({"type": "donut", "data": {"Compute": 48, "Storage": 15}})
80
+ save({"type": "line", "x": ["Q1", "Q2"], "series": {"Web": [3, 5]}}, "out.png")
81
+ ```
82
+
83
+ ### Gallery
84
+
85
+ | | | |
86
+ |---|---|---|
87
+ | ![](examples/bar-grouped.svg) | ![](examples/bar-stacked.svg) | ![](examples/hbar.svg) |
88
+ | ![](examples/line.svg) | ![](examples/area.svg) | ![](examples/area-stacked.svg) |
89
+ | ![](examples/scatter.svg) | ![](examples/pie.svg) | ![](examples/donut.svg) |
90
+ | ![](examples/histogram.svg) | ![](examples/dark.svg) | ![](examples/negative.svg) |
91
+ | ![](examples/waterfall.svg) | ![](examples/funnel.svg) | ![](examples/heatmap.svg) |
92
+ | ![](examples/bar-highlight.svg) | ![](examples/bar-percent.svg) | ![](examples/line-smooth.svg) |
93
+
94
+ Sparkline, for tables and text: ![](examples/sparkline.svg)
95
+
96
+ Specs for every chart above are in [`examples/specs.json`](examples/specs.json).
97
+
98
+ ### Options that tell a story
99
+
100
+ | Option | Example | What it does |
101
+ |---|---|---|
102
+ | `highlight` | `"highlight": "East"` | Keeps one category in color and greys out the rest |
103
+ | `refs` | `"refs": [{"value": 1000, "label": "Target"}]` | Dashed reference line with a label |
104
+ | `stack` | `"stack": "percent"` | 100% stacked bars or areas |
105
+ | `curve` | `"curve": "smooth"` or `"step"` | Smooth lines that never overshoot the data, or steps |
106
+ | `ymin`, `ymax` | `"ymin": 0` | Fix the value axis |
107
+ | `legend` | `"legend": "bottom"` | `top`, `bottom` or `none` |
108
+ | `palette` | `"palette": "colorblind"` | `default`, `colorblind` (Okabe-Ito), `mono`, `warm`, `cool` |
109
+ | `decimals`, `grid`, `font` | `"decimals": 1, "grid": false` | Number format, gridlines, font family |
110
+
111
+ ### What it handles for you
112
+
113
+ - Round axis ticks and compact numbers (`$1.5M`, `40K`, `12%`).
114
+ - Labels that fit: long category names are rotated or shortened, crowded axes skip labels.
115
+ - Pie slices beyond 8 are grouped into "Other". Slice and cell labels pick black or white text for contrast.
116
+ - Gaps in line data (`null`) break the line instead of dropping to zero.
117
+ - Light and dark themes, colorblind-friendly palettes, accessible `<title>`.
118
+ - Small output: most example SVGs are 2 to 4 KB with no scripts or external fonts.
119
+ - Safe with untrusted specs: text is escaped and colors are validated. See [SECURITY.md](SECURITY.md).
120
+
121
+ ### Tokens and time
122
+
123
+ Tokens are estimated as characters / 4. "By hand" is what a model would write to produce
124
+ the same chart itself. Time assumes 50 to 100 output tokens a second; rendering takes
125
+ about 0.1 ms and is left out. Run `python scripts/build_examples.py` to reproduce.
126
+
127
+ | chart | spec tokens | SVG by hand | saved | time by hand | time with a spec |
128
+ |---|---:|---:|---:|---:|---:|
129
+ | bar | 37 | 553 | 94% | 5.5 to 11 s | 0.4 to 0.7 s |
130
+ | line | 49 | 896 | 95% | 9 to 18 s | 0.5 to 1 s |
131
+ | waterfall | 44 | 827 | 95% | 8.3 to 17 s | 0.4 to 0.9 s |
132
+ | heatmap | 50 | 1,586 | 97% | 16 to 32 s | 0.5 to 1 s |
133
+ | pie | 29 | 586 | 96% | 5.9 to 12 s | 0.3 to 0.6 s |
134
+
135
+ Writing matplotlib code instead usually takes 150 to 400 tokens of code, plus a heavy
136
+ install and a second round trip when the code fails.
137
+
138
+ ## Table jig
139
+
140
+ ```sh
141
+ jigstore table '{"from":"q3.csv","total":{"Region":"Total","Revenue":"sum"}}' # prints Markdown
142
+ jigstore table @spec.json -o q3.png # or .svg .html .csv .md
143
+ ```
144
+
145
+ ![revenue table](examples/table-revenue.svg) ![scorecard table](examples/table-scorecard.svg)
146
+
147
+ Why an agent would use it rather than write a Markdown table itself:
148
+
149
+ - **It reads the data from a file.** `"from": "q3.csv"` (or `.json`) means the agent never
150
+ retypes rows it already saved from a query: 17 tokens instead of about 200 for a 20-row
151
+ table, and no copying mistakes. Only the CLI and the local MCP server read files, and
152
+ only inside the working folder (or `JIGSTORE_OUT_DIR`).
153
+ - **Numbers come out right.** Totals, averages, sorting and rounding are computed, not guessed.
154
+ Each column uses one unit (`$0.91M`, `$1.24M`) so values line up.
155
+ - **It renders where Markdown doesn't.** Slack and most email clients don't show Markdown
156
+ tables. PNG and inline-styled HTML do. Writing that HTML by hand costs 750 to 2,350
157
+ tokens in the examples; the spec costs 78 to 111.
158
+ - **Safe output.** Text is escaped in every format, and CSV cells that start with `=`, `+`,
159
+ `-` or `@` are neutralised so spreadsheets don't run them as formulas.
160
+
161
+ Percentages are written as whole or decimal numbers (`12`, `95.5`) and shown with 2 decimals
162
+ unless `decimals` says otherwise. Images show 25 rows by default (`max_rows` up to 200);
163
+ Markdown, HTML and CSV keep up to 1,000.
164
+
165
+ ## Using it from an agent
166
+
167
+ **Shell access (cheapest).** Copy [`docs/agent-prompt.md`](docs/agent-prompt.md) into your agent's instructions,
168
+ or let the agent run `jigstore docs chart` or `jigstore docs table` when it needs the
169
+ spec format (about 250 tokens each). Nothing is loaded into context until it's used.
170
+
171
+ **MCP.** Add the server to any MCP client (Claude, Kiro, Cursor, VS Code and others):
172
+
173
+ ```json
174
+ {
175
+ "mcpServers": {
176
+ "jigstore": {
177
+ "command": "uvx",
178
+ "args": ["jigstore", "mcp"],
179
+ "env": { "JIGSTORE_OUT_DIR": "/path/to/charts" }
180
+ }
181
+ }
182
+ }
183
+ ```
184
+
185
+ The server exposes one `jig` tool for every jig, so its schema stays about 145 tokens
186
+ per turn however many jigs exist. The full spec format of a jig is returned only when a
187
+ call fails, so it costs nothing while the model gets specs right. Arguments: `jig`
188
+ (`chart` or `table`), `spec`, `out` (a file path whose extension picks the format), and
189
+ `view: true` to also get a PNG back so the model can check the result. A table with no
190
+ `out` comes back as Markdown text. When `JIGSTORE_OUT_DIR` is set, files are read and
191
+ written only inside it.
192
+
193
+ The server has no dependencies and supports both the 2026-07-28 stateless MCP protocol
194
+ and the older `initialize` handshake (2024-11-05 to 2025-11-25).
195
+
196
+ ## Adding a tool
197
+
198
+ Each tool lives in `src/jigstore/<name>/` with a `USAGE.md` of 300 tokens or less,
199
+ a CLI subcommand, an entry in `CATALOG` and in `JIGS` in `mcp.py`, examples and tests.
200
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
201
+
202
+ ## Support the project
203
+
204
+ Jigstore is built and maintained by one person. If it saves your agents tokens, you can
205
+ [sponsor it on GitHub](https://github.com/sponsors/ankit22sharma) or
206
+ [buy me a coffee](https://buymeacoffee.com/ankit22sharma). Bug reports, tool ideas and pull
207
+ requests help just as much.
208
+
209
+ ## License
210
+
211
+ MIT
@@ -0,0 +1,186 @@
1
+ <p>
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="docs/brand/wordmark-on-dark.svg">
4
+ <img alt="jigstore" src="docs/brand/wordmark-on-light.svg" height="56">
5
+ </picture>
6
+ </p>
7
+
8
+ [![ci](https://github.com/jigstore/jigstore/actions/workflows/ci.yml/badge.svg)](https://github.com/jigstore/jigstore/actions/workflows/ci.yml)
9
+ [![license: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
10
+ [![Sponsor](https://img.shields.io/badge/sponsor-GitHub%20Sponsors-ea4aaa.svg)](https://github.com/sponsors/ankit22sharma)
11
+ [![Buy me a coffee](https://img.shields.io/badge/buy%20me%20a%20coffee-support-e8590c.svg)](https://buymeacoffee.com/ankit22sharma)
12
+
13
+ Ready-made tools for AI agents. In a workshop, a jig lets you repeat a precise job every
14
+ time without redoing the setup. Jigstore does the same for agents: instead of having a
15
+ model generate an SVG, a chart script or a document token by token, the agent writes a
16
+ short spec and a deterministic tool does the rest. The output is the same every time,
17
+ the model writes about 20 times fewer tokens, and the result arrives in under a second
18
+ instead of 5 to 30 seconds of streaming.
19
+
20
+ Each tool is a jig in this catalog. The first one is a chart builder.
21
+
22
+ | jig | what it does |
23
+ |---|---|
24
+ | [`chart`](src/jigstore/chart/USAGE.md) | 12 chart types (bar, line, area, scatter, pie, donut, histogram, waterfall, funnel, heatmap, sparkline) from JSON to SVG or PNG |
25
+ | [`table`](src/jigstore/table/USAGE.md) | Rows, or a CSV/JSON file, to Markdown, SVG, PNG, HTML or CSV, with totals, formats, sorting and in-cell bars and sparklines |
26
+
27
+ ## Install
28
+
29
+ ```sh
30
+ pip install jigstore
31
+ # PNG output: also install cairosvg, or have rsvg-convert on PATH
32
+ pip install "jigstore[png]"
33
+ ```
34
+
35
+ No runtime dependencies. Python 3.10+.
36
+
37
+ ## Chart builder
38
+
39
+ ```sh
40
+ jigstore chart '{"type":"bar","title":"Revenue by region","data":{"North":1240000,"South":905000,"East":1530000,"West":712000},"prefix":"$"}' -o revenue.png
41
+ # prints: revenue.png
42
+ ```
43
+
44
+ ![bar](examples/bar.svg)
45
+
46
+ The CLI prints only the output path, so the result costs the agent a few tokens.
47
+ Errors are one line on stderr that say what to fix, with exit code 2.
48
+
49
+ From Python:
50
+
51
+ ```python
52
+ from jigstore.chart import render, save
53
+
54
+ svg = render({"type": "donut", "data": {"Compute": 48, "Storage": 15}})
55
+ save({"type": "line", "x": ["Q1", "Q2"], "series": {"Web": [3, 5]}}, "out.png")
56
+ ```
57
+
58
+ ### Gallery
59
+
60
+ | | | |
61
+ |---|---|---|
62
+ | ![](examples/bar-grouped.svg) | ![](examples/bar-stacked.svg) | ![](examples/hbar.svg) |
63
+ | ![](examples/line.svg) | ![](examples/area.svg) | ![](examples/area-stacked.svg) |
64
+ | ![](examples/scatter.svg) | ![](examples/pie.svg) | ![](examples/donut.svg) |
65
+ | ![](examples/histogram.svg) | ![](examples/dark.svg) | ![](examples/negative.svg) |
66
+ | ![](examples/waterfall.svg) | ![](examples/funnel.svg) | ![](examples/heatmap.svg) |
67
+ | ![](examples/bar-highlight.svg) | ![](examples/bar-percent.svg) | ![](examples/line-smooth.svg) |
68
+
69
+ Sparkline, for tables and text: ![](examples/sparkline.svg)
70
+
71
+ Specs for every chart above are in [`examples/specs.json`](examples/specs.json).
72
+
73
+ ### Options that tell a story
74
+
75
+ | Option | Example | What it does |
76
+ |---|---|---|
77
+ | `highlight` | `"highlight": "East"` | Keeps one category in color and greys out the rest |
78
+ | `refs` | `"refs": [{"value": 1000, "label": "Target"}]` | Dashed reference line with a label |
79
+ | `stack` | `"stack": "percent"` | 100% stacked bars or areas |
80
+ | `curve` | `"curve": "smooth"` or `"step"` | Smooth lines that never overshoot the data, or steps |
81
+ | `ymin`, `ymax` | `"ymin": 0` | Fix the value axis |
82
+ | `legend` | `"legend": "bottom"` | `top`, `bottom` or `none` |
83
+ | `palette` | `"palette": "colorblind"` | `default`, `colorblind` (Okabe-Ito), `mono`, `warm`, `cool` |
84
+ | `decimals`, `grid`, `font` | `"decimals": 1, "grid": false` | Number format, gridlines, font family |
85
+
86
+ ### What it handles for you
87
+
88
+ - Round axis ticks and compact numbers (`$1.5M`, `40K`, `12%`).
89
+ - Labels that fit: long category names are rotated or shortened, crowded axes skip labels.
90
+ - Pie slices beyond 8 are grouped into "Other". Slice and cell labels pick black or white text for contrast.
91
+ - Gaps in line data (`null`) break the line instead of dropping to zero.
92
+ - Light and dark themes, colorblind-friendly palettes, accessible `<title>`.
93
+ - Small output: most example SVGs are 2 to 4 KB with no scripts or external fonts.
94
+ - Safe with untrusted specs: text is escaped and colors are validated. See [SECURITY.md](SECURITY.md).
95
+
96
+ ### Tokens and time
97
+
98
+ Tokens are estimated as characters / 4. "By hand" is what a model would write to produce
99
+ the same chart itself. Time assumes 50 to 100 output tokens a second; rendering takes
100
+ about 0.1 ms and is left out. Run `python scripts/build_examples.py` to reproduce.
101
+
102
+ | chart | spec tokens | SVG by hand | saved | time by hand | time with a spec |
103
+ |---|---:|---:|---:|---:|---:|
104
+ | bar | 37 | 553 | 94% | 5.5 to 11 s | 0.4 to 0.7 s |
105
+ | line | 49 | 896 | 95% | 9 to 18 s | 0.5 to 1 s |
106
+ | waterfall | 44 | 827 | 95% | 8.3 to 17 s | 0.4 to 0.9 s |
107
+ | heatmap | 50 | 1,586 | 97% | 16 to 32 s | 0.5 to 1 s |
108
+ | pie | 29 | 586 | 96% | 5.9 to 12 s | 0.3 to 0.6 s |
109
+
110
+ Writing matplotlib code instead usually takes 150 to 400 tokens of code, plus a heavy
111
+ install and a second round trip when the code fails.
112
+
113
+ ## Table jig
114
+
115
+ ```sh
116
+ jigstore table '{"from":"q3.csv","total":{"Region":"Total","Revenue":"sum"}}' # prints Markdown
117
+ jigstore table @spec.json -o q3.png # or .svg .html .csv .md
118
+ ```
119
+
120
+ ![revenue table](examples/table-revenue.svg) ![scorecard table](examples/table-scorecard.svg)
121
+
122
+ Why an agent would use it rather than write a Markdown table itself:
123
+
124
+ - **It reads the data from a file.** `"from": "q3.csv"` (or `.json`) means the agent never
125
+ retypes rows it already saved from a query: 17 tokens instead of about 200 for a 20-row
126
+ table, and no copying mistakes. Only the CLI and the local MCP server read files, and
127
+ only inside the working folder (or `JIGSTORE_OUT_DIR`).
128
+ - **Numbers come out right.** Totals, averages, sorting and rounding are computed, not guessed.
129
+ Each column uses one unit (`$0.91M`, `$1.24M`) so values line up.
130
+ - **It renders where Markdown doesn't.** Slack and most email clients don't show Markdown
131
+ tables. PNG and inline-styled HTML do. Writing that HTML by hand costs 750 to 2,350
132
+ tokens in the examples; the spec costs 78 to 111.
133
+ - **Safe output.** Text is escaped in every format, and CSV cells that start with `=`, `+`,
134
+ `-` or `@` are neutralised so spreadsheets don't run them as formulas.
135
+
136
+ Percentages are written as whole or decimal numbers (`12`, `95.5`) and shown with 2 decimals
137
+ unless `decimals` says otherwise. Images show 25 rows by default (`max_rows` up to 200);
138
+ Markdown, HTML and CSV keep up to 1,000.
139
+
140
+ ## Using it from an agent
141
+
142
+ **Shell access (cheapest).** Copy [`docs/agent-prompt.md`](docs/agent-prompt.md) into your agent's instructions,
143
+ or let the agent run `jigstore docs chart` or `jigstore docs table` when it needs the
144
+ spec format (about 250 tokens each). Nothing is loaded into context until it's used.
145
+
146
+ **MCP.** Add the server to any MCP client (Claude, Kiro, Cursor, VS Code and others):
147
+
148
+ ```json
149
+ {
150
+ "mcpServers": {
151
+ "jigstore": {
152
+ "command": "uvx",
153
+ "args": ["jigstore", "mcp"],
154
+ "env": { "JIGSTORE_OUT_DIR": "/path/to/charts" }
155
+ }
156
+ }
157
+ }
158
+ ```
159
+
160
+ The server exposes one `jig` tool for every jig, so its schema stays about 145 tokens
161
+ per turn however many jigs exist. The full spec format of a jig is returned only when a
162
+ call fails, so it costs nothing while the model gets specs right. Arguments: `jig`
163
+ (`chart` or `table`), `spec`, `out` (a file path whose extension picks the format), and
164
+ `view: true` to also get a PNG back so the model can check the result. A table with no
165
+ `out` comes back as Markdown text. When `JIGSTORE_OUT_DIR` is set, files are read and
166
+ written only inside it.
167
+
168
+ The server has no dependencies and supports both the 2026-07-28 stateless MCP protocol
169
+ and the older `initialize` handshake (2024-11-05 to 2025-11-25).
170
+
171
+ ## Adding a tool
172
+
173
+ Each tool lives in `src/jigstore/<name>/` with a `USAGE.md` of 300 tokens or less,
174
+ a CLI subcommand, an entry in `CATALOG` and in `JIGS` in `mcp.py`, examples and tests.
175
+ See [CONTRIBUTING.md](CONTRIBUTING.md).
176
+
177
+ ## Support the project
178
+
179
+ Jigstore is built and maintained by one person. If it saves your agents tokens, you can
180
+ [sponsor it on GitHub](https://github.com/sponsors/ankit22sharma) or
181
+ [buy me a coffee](https://buymeacoffee.com/ankit22sharma). Bug reports, tool ideas and pull
182
+ requests help just as much.
183
+
184
+ ## License
185
+
186
+ MIT
@@ -0,0 +1,53 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "jigstore"
7
+ version = "0.2.0"
8
+ description = "Deterministic tools for AI agents: write a short spec instead of generating the output."
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ authors = [{ name = "Ankit Sharma" }]
12
+ requires-python = ">=3.10"
13
+ dependencies = []
14
+ keywords = ["ai-agents", "llm", "tools", "charts", "svg", "token-efficient"]
15
+ classifiers = [
16
+ "License :: OSI Approved :: MIT License",
17
+ "Development Status :: 3 - Alpha",
18
+ "Intended Audience :: Developers",
19
+ "Operating System :: OS Independent",
20
+ "Programming Language :: Python :: 3",
21
+ "Programming Language :: Python :: 3 :: Only",
22
+ "Typing :: Typed",
23
+ "Topic :: Scientific/Engineering :: Visualization",
24
+ ]
25
+
26
+ [project.optional-dependencies]
27
+ png = ["cairosvg>=2.5"]
28
+
29
+ [project.scripts]
30
+ jigstore = "jigstore.cli:main"
31
+
32
+ [project.urls]
33
+ Homepage = "https://github.com/jigstore/jigstore"
34
+ Issues = "https://github.com/jigstore/jigstore/issues"
35
+ Changelog = "https://github.com/jigstore/jigstore/blob/main/CHANGELOG.md"
36
+
37
+ [tool.setuptools.packages.find]
38
+ where = ["src"]
39
+
40
+ [tool.setuptools.package-data]
41
+ "*" = ["USAGE.md", "py.typed"]
42
+
43
+ [tool.ruff]
44
+ line-length = 120
45
+ target-version = "py310"
46
+
47
+ [tool.ruff.lint]
48
+ select = ["E", "F", "W", "I", "B", "UP", "S"]
49
+ ignore = ["E731", "S603", "S607", "B905"]
50
+
51
+ [tool.ruff.lint.per-file-ignores]
52
+ "tests/*" = ["S", "E501"]
53
+ "scripts/*" = ["S"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -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
+ }
@@ -0,0 +1,3 @@
1
+ from .cli import main
2
+
3
+ raise SystemExit(main())
@@ -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`
@@ -0,0 +1,6 @@
1
+ """Chart builder: compact JSON spec in, clean SVG (or PNG) out."""
2
+
3
+ from .png import save, to_png
4
+ from .render import TYPES, SpecError, render
5
+
6
+ __all__ = ["render", "save", "to_png", "SpecError", "TYPES"]
@@ -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