codechart 0.0.0-stage → 0.1.0

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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 freeleex
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.
package/README.md CHANGED
@@ -1,3 +1,219 @@
1
- # Temporary Holding Version
1
+ <h1 align="center">codechart</h1>
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <p align="center">
4
+ <b>See the shape of a change before you read it.</b><br>
5
+ A skill for AI coding agents that turns their plans and change summaries into maps and flowcharts.
6
+ </p>
7
+
8
+ <p align="center">
9
+ <a href="https://www.npmjs.com/package/codechart"><img alt="npm" src="https://img.shields.io/npm/v/codechart"></a>
10
+ <a href="https://github.com/freeleex/codechart/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/freeleex/codechart/actions/workflows/ci.yml/badge.svg"></a>
11
+ <img alt="Node >= 22.12" src="https://img.shields.io/badge/node-%3E%3D22.12-339933">
12
+ <a href="LICENSE"><img alt="MIT" src="https://img.shields.io/badge/license-MIT-blue"></a>
13
+ </p>
14
+
15
+ <p align="center">
16
+ <a href="#install">Install</a> · <a href="#what-you-get">What you get</a> · <a href="#why-you-can-trust-the-diagram">Trust</a> · <a href="#cost">Cost</a> · <a href="#configure">Configure</a> · <a href="#faq">FAQ</a>
17
+ </p>
18
+
19
+ ---
20
+
21
+ ## The problem
22
+
23
+ Your agent just finished a change. Its summary reads like this:
24
+
25
+ > Done. Migration `0042` adds `coupon_code` to `orders` and changes `orders.status`; adds `refunded` to the `order_status` enum and `bank_transfer` to `payment_method`; creates `invoices` (`order_id`, `method`, `number`) and backfills one invoice per paid order, numbered from `INVOICE_PREFIX`. `OrderStatus` and `PaymentMethod` mirror the new enum values; new `Invoice` model. `POST /orders/{id}/refund` sets `OrderStatus.REFUNDED`, gated by `refundsEnabled`. Didn't read `customers` beyond its id. Tests in `test_invoice_backfill.py`; updated `CHANGELOG.md` and `.env.example`.
26
+
27
+ Every word is correct, and you still don't *see* it. Which of those are new, and which already existed? What does `invoices` point at? What does the flag actually gate? You open the diff and trace it by hand. On a 20-file change, that's where your review time goes.
28
+
29
+ ## The fix
30
+
31
+ With codechart, the same reply starts with this:
32
+
33
+ ```text
34
+ Map (key: + new - removed ~ changed · context ◆ config)
35
+
36
+ database
37
+ ~orders ─customer_id─▶ ·customers
38
+ ─status──────▶ ~enum order_status
39
+ +invoices ─order_id─▶ ~orders
40
+ ─method───▶ ~enum payment_method
41
+
42
+ backend
43
+ ~OrderStatus ─mirrors─▶ ~enum order_status
44
+ +Invoice ─maps─▶ +invoices
45
+ +POST /orders/{id}/refund ─sets refunded─▶ ~model OrderStatus
46
+ ~PaymentMethod ─mirrors─▶ ~enum payment_method
47
+
48
+ config
49
+ +migration: backfill invoices for p… ─backfills─▶ +invoices
50
+ ◆INVOICE_PREFIX ─read by─▶ +migration: backfill invoices for paid orders
51
+ ◆feature flag refundsEnabled ─gates─▶ +endpoint POST /orders/{id}/refund
52
+
53
+ 12 nodes · 4 new · 5 changed · 2 config
54
+ gaps: customers: columns besides id not read
55
+ not on map: tests: test_invoice_backfill.py · docs: CHANGELOG.md, .env.example
56
+
57
+ Open full map
58
+ ```
59
+
60
+ New things are `+`, changed ones `~`, existing ones `·`, config `◆`. Layers are grouped and every relation is drawn. It takes ten seconds to read, and it tells you what the agent *didn't* look at.
61
+
62
+ **Open full map** opens an interactive page with the whole picture. Click any node for its summary, file and fields, with changes marked:
63
+
64
+ ![Full map: clicking the orders table shows its file and changed fields](docs/images/map.png)
65
+
66
+ You don't need to ask for it. The skill fires when the agent summarizes changes, writes a plan, or explains how code behaves, and stays quiet for typo fixes.
67
+
68
+ ## Install
69
+
70
+ ```bash
71
+ npm i -g codechart && codechart install-skill
72
+ ```
73
+
74
+ That's it. Open your coding agent in any repo and try:
75
+
76
+ ```text
77
+ > summarize the uncommitted changes
78
+ > plan adding refunds to orders
79
+ > show me the flow of accepting an invite
80
+ ```
81
+
82
+ Needs Node 22.12+. `install-skill` finds the agents you use and asks which ones get the skill. Existing installs are skipped (`--force` updates them). Skip the question with `--agent codex,gemini`, or use `--dir <skills folder>` for anything else.
83
+
84
+ **Works with** any agent that supports [Agent Skills](https://agentskills.io): Codex, Gemini CLI, GitHub Copilot, Cursor, OpenCode, Goose, Amp, Windsurf, Cline, Roo Code, Kiro, Junie, Factory Droid and Claude Code.
85
+
86
+ ## What you get
87
+
88
+ ### Maps: what changed and how it connects
89
+
90
+ Tables, columns, enums, models, endpoints, components, config and env vars, grouped by layer and marked as new, changed, context or config. They work for **plans** too, so you can catch a wrong design before any code exists.
91
+
92
+ ### Flows: what the code actually does
93
+
94
+ Decisions, edge cases and outcomes, each pointing at the source lines that implement it.
95
+
96
+ ```text
97
+ Flow (key: + new ~ changed ? planned ◇ decision ⤷ shared step)
98
+
99
+ Accept a team invite
100
+ ────────────────────
101
+ +look up invite by token
102
+ ◇ +invite found?
103
+ ├─ no → +404 invite not found
104
+ └─ yes → ◇ +expired?
105
+ ├─ yes → +410 invite expired
106
+ └─ no → ◇ +already a member?
107
+ ├─ yes → +return already a member
108
+ └─ no → +save membership → +return joined
109
+
110
+ 9 steps · 9 new · 0 changed · 0 planned
111
+ gaps: did not check what happens when two requests accept the same invite at
112
+ once
113
+
114
+ Open full map
115
+ ```
116
+
117
+ Its full page shows each step's exact code:
118
+
119
+ ![Full flow: clicking a decision shows its source lines](docs/images/flow.png)
120
+
121
+ ### Terminal first, page when it helps
122
+
123
+ Small diagrams stay in the reply. Big ones, or rules you mark `output: both`, also get the self-contained HTML page: zoom, pan, light and dark themes, nothing loaded from the internet.
124
+
125
+ ## Why you can trust the diagram
126
+
127
+ - **The agent writes data, codechart draws.** LLMs misalign hand-drawn ASCII, so the agent only describes nodes and links. Layout is code.
128
+ - **Flows are anchored to real code.** Every step that exists in code names its `file:line` or quotes the line. If the line doesn't exist, the render fails and the agent has to fix it.
129
+ - **Gaps are explicit.** Whatever the agent didn't read is listed under `gaps`, not guessed.
130
+ - **Validated input.** Specs are checked against a schema, with clear errors the agent can act on.
131
+
132
+ ## Cost
133
+
134
+ A diagram is about **2–3 extra API calls**. In a long session that's roughly 2–3% of your usage per diagram, and nothing for trivial changes. That's an estimate from Claude Code sessions with Sonnet; other agents and models will differ, and shorter sessions pay proportionally more. Measured runs are in [docs/efficiency.md](docs/efficiency.md).
135
+
136
+ The CLI is small: a 46.5 kB package, 5 runtime dependencies, and a cold start around 150 ms.
137
+
138
+ ## Safe to run
139
+
140
+ - No network calls, no telemetry.
141
+ - No shell: only read-only `git` and your OS opener, called with argument arrays.
142
+ - HTML pages load nothing external, and all text is escaped. They're saved to `~/.cache/codechart`, never to your repo.
143
+ - Audited before release across 8 areas, including untrusted repos and prompt-injected specs. See [docs/security-review.md](docs/security-review.md) and [SECURITY.md](SECURITY.md).
144
+
145
+ ## Configure
146
+
147
+ Works with zero config. To tune it, run `codechart init` to write a commented `.codechart.yaml`, then add rules for your repo:
148
+
149
+ ```yaml
150
+ rules:
151
+ - name: models
152
+ paths: ["app/models/**"] # always map model changes
153
+ output: both # terminal + HTML page
154
+ context: full # may read referenced definitions
155
+ - name: frontend-models
156
+ when: "a frontend data model, store, or shared API type changed"
157
+ - name: api-flows
158
+ diagram: flow
159
+ paths: ["app/api/**"]
160
+ ```
161
+
162
+ `codechart config` shows the config in effect and where each value comes from.
163
+
164
+ <details>
165
+ <summary><b>All config keys</b></summary>
166
+
167
+ Repo `.codechart.yaml` and global `~/.config/codechart/config.yaml`. Editor schema: `codechart schema --config` or `config.schema.json`.
168
+
169
+ | Key | Values | Default |
170
+ |---|---|---|
171
+ | `defaults.output` | `auto`, `cli`, `web`, `both`, `none` | `auto` (terminal map; HTML only when the map is too big) |
172
+ | `defaults.context` | `short` (map what the agent already read), `full` (may read referenced definitions) | `short` |
173
+ | `defaults.flows` | `auto` (2+ decisions or edge cases), `always`, `request` | `auto` |
174
+ | `defaults.terminalMaxNodes` | number | `15` |
175
+ | `web.theme` | `auto`, `light`, `dark` | `auto` |
176
+ | `web.minNodes` | HTML from this many nodes on | `8` |
177
+ | `useBuiltinRules` | built-in migration/model path rules, `related-files`, `behaviour-flow` | `true` |
178
+ | `rules` | your own, run before the built-ins | none |
179
+
180
+ Global only: `web.outDir` (`~/.cache/codechart`), `web.keep` (`20`), `web.maxAgeDays` (`7`), `web.open` (`auto`: new pages open in your browser when running inside a VS Code-based editor; `always`, `never`).
181
+
182
+ Rules have a `name` plus exactly one of `paths` (globs: `*`, `**`, `?`, `[..]`; no braces) or `when` (a sentence the agent judges). Optional: `output`, `context` (map rules), `diagram: map|flow`. Per diagram type and file, the first matching path rule wins. `output: none` excludes files.
183
+
184
+ </details>
185
+
186
+ <details>
187
+ <summary><b>CLI commands</b> (the skill calls these; you rarely need to)</summary>
188
+
189
+ | Command | Purpose |
190
+ |---|---|
191
+ | `codechart check` | Which rules apply to changed files. `--files <csv>`, `--git`, `--commit <sha>`, `--since <base>` (+ `--head <ref>`), `--matched <csv>` |
192
+ | `codechart render <spec>` | Render a spec (JSON file or `-` for stdin). `--output auto\|cli\|web\|both`, `--theme auto\|light\|dark`, `--open`, `--md`, `--at <rev>` |
193
+ | `codechart schema` | Spec JSON schema; `--flow` for flow specs, `--config` for the config file |
194
+ | `codechart config` | Config in effect and where each value comes from (`--json`) |
195
+ | `codechart init` | Write a commented starter `.codechart.yaml` at the git root (`--force` to overwrite) |
196
+ | `codechart install-skill` | Install the skill for the agents found in your home folder. `--agent <names>`, `--dir <path>`, `--force` to overwrite |
197
+
198
+ </details>
199
+
200
+ ## FAQ
201
+
202
+ **My agent isn't on the list.**
203
+ If it loads `SKILL.md` skills, run `codechart install-skill --dir <its skills folder>`. If not, the CLI still works for any agent that can run a command and write JSON: point it at `codechart schema` and `codechart render`.
204
+
205
+ **Will it draw a diagram for every tiny change?**
206
+ No. One-file text, comment, formatting or version-bump changes are skipped. Flows only appear for logic with 2+ decisions or edge cases, or when you ask for one.
207
+
208
+ **Does my code leave my machine?**
209
+ Not because of codechart. It makes no network calls. The diagram is built from what your agent already read.
210
+
211
+ **Where do the HTML pages go?**
212
+ `~/.cache/codechart`. It keeps the newest 20 per repo, plus anything under 7 days old.
213
+
214
+ **I use VS Code, Cursor, Windsurf or Antigravity, and "Open full map" shows HTML source.**
215
+ Those editors open file links as text. codechart detects them and opens new pages in your browser instead. Turn it off with `web.open: never` in `~/.config/codechart/config.yaml`.
216
+
217
+ ## License
218
+
219
+ MIT. Depends on elkjs (EPL-2.0): see [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
@@ -0,0 +1,11 @@
1
+ # Third-party notices
2
+
3
+ ## elkjs 0.12.0
4
+
5
+ Eclipse Layout Kernel compiled to JavaScript. A runtime dependency installed from npm; codechart runs it in Node to lay out HTML maps. None of its code is copied into codechart or the generated HTML.
6
+
7
+ - License: EPL-2.0 (elkjs is dual-licensed EPL-2.0 OR GPL-3.0-or-later; codechart uses it under EPL-2.0)
8
+ - Source: <https://github.com/kieler/elkjs>
9
+ - License text: <https://www.eclipse.org/legal/epl-2.0/>
10
+
11
+ The elkjs license file is `node_modules/elkjs/LICENSE.md` after install.
@@ -0,0 +1,142 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "type": "object",
4
+ "properties": {
5
+ "defaults": {
6
+ "type": "object",
7
+ "properties": {
8
+ "output": {
9
+ "type": "string",
10
+ "enum": [
11
+ "auto",
12
+ "cli",
13
+ "web",
14
+ "both",
15
+ "none"
16
+ ]
17
+ },
18
+ "context": {
19
+ "type": "string",
20
+ "enum": [
21
+ "short",
22
+ "full"
23
+ ]
24
+ },
25
+ "flows": {
26
+ "type": "string",
27
+ "enum": [
28
+ "auto",
29
+ "always",
30
+ "request"
31
+ ]
32
+ },
33
+ "terminalMaxNodes": {
34
+ "type": "integer",
35
+ "exclusiveMinimum": 0,
36
+ "maximum": 9007199254740991
37
+ }
38
+ },
39
+ "additionalProperties": false
40
+ },
41
+ "web": {
42
+ "type": "object",
43
+ "properties": {
44
+ "outDir": {
45
+ "type": "string",
46
+ "minLength": 1
47
+ },
48
+ "theme": {
49
+ "type": "string",
50
+ "enum": [
51
+ "auto",
52
+ "light",
53
+ "dark"
54
+ ]
55
+ },
56
+ "minNodes": {
57
+ "type": "integer",
58
+ "exclusiveMinimum": 0,
59
+ "maximum": 9007199254740991
60
+ },
61
+ "keep": {
62
+ "type": "integer",
63
+ "exclusiveMinimum": 0,
64
+ "maximum": 9007199254740991
65
+ },
66
+ "maxAgeDays": {
67
+ "type": "number",
68
+ "minimum": 0
69
+ },
70
+ "open": {
71
+ "type": "string",
72
+ "enum": [
73
+ "auto",
74
+ "always",
75
+ "never"
76
+ ]
77
+ }
78
+ },
79
+ "additionalProperties": false
80
+ },
81
+ "useBuiltinRules": {
82
+ "type": "boolean"
83
+ },
84
+ "rules": {
85
+ "type": "array",
86
+ "items": {
87
+ "type": "object",
88
+ "properties": {
89
+ "name": {
90
+ "type": "string",
91
+ "pattern": "^[a-z0-9][a-z0-9-]{0,63}$"
92
+ },
93
+ "diagram": {
94
+ "type": "string",
95
+ "enum": [
96
+ "map",
97
+ "flow"
98
+ ]
99
+ },
100
+ "paths": {
101
+ "minItems": 1,
102
+ "type": "array",
103
+ "items": {
104
+ "type": "string",
105
+ "minLength": 1,
106
+ "maxLength": 200,
107
+ "pattern": "^[^\\u0000-\\u001f\\u007f-\\u009f\\u200b\\u200c\\u200e\\u200f\\u2028-\\u202e\\u2060-\\u2069\\ufeff]*$"
108
+ }
109
+ },
110
+ "when": {
111
+ "type": "string",
112
+ "minLength": 1,
113
+ "maxLength": 300,
114
+ "pattern": "^[^\\u0000-\\u001f\\u007f-\\u009f\\u200b\\u200c\\u200e\\u200f\\u2028-\\u202e\\u2060-\\u2069\\ufeff]*$"
115
+ },
116
+ "output": {
117
+ "type": "string",
118
+ "enum": [
119
+ "auto",
120
+ "cli",
121
+ "web",
122
+ "both",
123
+ "none"
124
+ ]
125
+ },
126
+ "context": {
127
+ "type": "string",
128
+ "enum": [
129
+ "short",
130
+ "full"
131
+ ]
132
+ }
133
+ },
134
+ "required": [
135
+ "name"
136
+ ],
137
+ "additionalProperties": false
138
+ }
139
+ }
140
+ },
141
+ "additionalProperties": false
142
+ }