codechart 0.1.3 → 0.3.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/README.md CHANGED
@@ -8,6 +8,7 @@
8
8
  <p align="center">
9
9
  <a href="https://www.npmjs.com/package/codechart"><img alt="npm" src="https://img.shields.io/npm/v/codechart"></a>
10
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
+ <a href="https://skills.sh/freeleex/codechart"><img alt="skills.sh" src="https://skills.sh/b/freeleex/codechart"></a>
11
12
  <img alt="Node 22.12+" src="https://img.shields.io/badge/node-%3E%3D22.12-339933">
12
13
  <a href="LICENSE"><img alt="MIT" src="https://img.shields.io/badge/license-MIT-blue"></a>
13
14
  </p>
@@ -108,26 +109,44 @@ That's it. Open your coding agent in any repo and try:
108
109
 
109
110
  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.
110
111
 
112
+ Already use the [skills CLI](https://skills.sh)? `npx skills add freeleex/codechart` installs the skill, but not the CLI it runs: add `npm i -g codechart` too. Pick one way to install the skill, so your agent doesn't load it twice.
113
+
114
+ ### Optional: help agents remember it
115
+
116
+ Agents load a skill only when they think of it, and in long sessions they sometimes don't. `install-skill` then offers two opt-ins (both off by default; flags skip the question):
117
+
118
+ - **Reminder line** (`--reminder`): one line in your agents' global instructions file (`~/.claude/CLAUDE.md`, `~/.config/opencode/AGENTS.md`, `~/.codex/AGENTS.md`, `~/.gemini/GEMINI.md`) asking them to use codechart for changes that touch 3+ files or add branching behaviour. It sits between `<!-- codechart -->` markers.
119
+ - **Claude Code hook** (`--hook`): adds `codechart hook prompt` (UserPromptSubmit) and `codechart hook stop` (Stop) to `~/.claude/settings.json`. When a turn changed 3+ files and the reply has no diagram, Claude is asked once to follow the skill. Files you had already changed before the turn don't count.
120
+
121
+ ### Uninstall
122
+
123
+ ```bash
124
+ codechart uninstall && npm uninstall -g codechart
125
+ ```
126
+
127
+ `codechart uninstall` removes the skill, the reminder lines and the hooks (`--skill`, `--reminder`, `--hook` to pick some). npm can't run it for you: it has no uninstall scripts since v7. Skill folders holding other files keep them.
128
+
111
129
  **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.
112
130
 
113
131
  ## What you get
114
132
 
115
133
  ### Maps: what changed and how it connects
116
134
 
117
- 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.
135
+ Tables, columns, enums, models, endpoints, components, config and env vars, grouped by layer and marked as new, changed, context or config. Infrastructure too: Terraform, OpenTofu, Helm, Kustomize and Kubernetes changes get a map of resources, modules and what they reference, with no rule to write. They work for **plans** too, so you can catch a wrong design before any code exists. A plan that changes existing code opens as **Now** and **After plan** side by side: same positions, panning together (or apart: header toggle), with what the plan removes in red and what it adds in green.
118
136
 
119
137
  ### Flows: what the code actually does
120
138
 
121
- Decisions, edge cases and outcomes, each pointing at the source lines that implement it. Branches the agent didn't verify go under `gaps` instead of being drawn.
139
+ Decisions, edge cases and outcomes, each pointing at the source lines that implement it. Branches the agent didn't verify go under `gaps` instead of being drawn. A plan that changes existing behaviour also opens as **Now** and **After plan** side by side.
122
140
 
123
141
  ### Terminal first, page when it helps
124
142
 
125
- 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.
143
+ 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. In a change summary, clicking a node shows what changed in its file, read from git, so the agent spends no tokens on it.
126
144
 
127
145
  ## Why you can trust the diagram
128
146
 
129
147
  - **The agent writes data, codechart draws.** LLMs misalign hand-drawn ASCII, so the agent only describes nodes and links. Layout is code.
130
148
  - **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.
149
+ - **Map claims are checked.** Each node's file must exist, a quoted line must be in it, and in a change summary every new, changed or removed node must be in the git diff. A mismatch opens the output with a `✗` line; when everything matches, the footer just says `✓ 10 checked`.
131
150
  - **Gaps are explicit.** Whatever the agent didn't read is listed under `gaps`, not guessed.
132
151
  - **Validated input.** Specs are checked against a schema, with clear errors the agent can act on.
133
152
 
@@ -135,13 +154,15 @@ Small diagrams stay in the reply. Big ones, or rules you mark `output: both`, al
135
154
 
136
155
  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).
137
156
 
138
- The CLI is small: a 46.5 kB package, 5 runtime dependencies, and a cold start around 150 ms.
157
+ The CLI is small: a 68.8 kB package, 5 runtime dependencies, and a cold start around 150 ms.
139
158
 
140
159
  ## Safe to run
141
160
 
142
161
  - No network calls, no telemetry.
143
162
  - No shell: only read-only `git` and your OS opener, called with argument arrays.
144
163
  - HTML pages load nothing external, and all text is escaped. They're saved to `~/.cache/codechart`, never to your repo.
164
+ - A summary page rendered with `--git`, `--since` or `--commit` holds your code: each changed node's panel shows the start of its diff. Share such a page only where you'd share the diff.
165
+ - The optional hook keeps, per session, the names and content hashes of your changed files in `~/.cache/codechart/turns` (removed after 7 days), never their contents.
145
166
  - 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).
146
167
 
147
168
  ## Configure
@@ -176,7 +197,7 @@ Repo `.codechart.yaml` and global `~/.config/codechart/config.yaml`. Editor sche
176
197
  | `defaults.terminalMaxNodes` | number | `15` |
177
198
  | `web.theme` | `auto`, `light`, `dark` | `auto` |
178
199
  | `web.minNodes` | HTML from this many nodes on | `8` |
179
- | `useBuiltinRules` | built-in migration/model path rules, `related-files`, `behaviour-flow` | `true` |
200
+ | `useBuiltinRules` | built-in migration/model/infrastructure path rules, `related-files`, `behaviour-flow` | `true` |
180
201
  | `rules` | your own, run before the built-ins | none |
181
202
 
182
203
  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`).
@@ -191,11 +212,13 @@ Rules have a `name` plus exactly one of `paths` (globs: `*`, `**`, `?`, `[..]`;
191
212
  | Command | Purpose |
192
213
  |---|---|
193
214
  | `codechart check` | Which rules apply to changed files. `--files <csv>`, `--git`, `--commit <sha>`, `--since <base>` (+ `--head <ref>`), `--matched <csv>` |
194
- | `codechart render <spec>` | Render a spec (JSON file or `-` for stdin). `--output auto\|cli\|web\|both`, `--theme auto\|light\|dark`, `--open`, `--md`, `--at <rev>` |
215
+ | `codechart render <spec>` | Render a spec (JSON file or `-` for stdin). `--output auto\|cli\|web\|both`, `--theme auto\|light\|dark`, `--open`, `--md`, `--at <rev>`; `--git`, `--commit <sha>`, `--since <base>` (+ `--head <ref>`) to check claims against the diff; `--strict` to exit 1 on a mismatch |
195
216
  | `codechart schema` | Spec JSON schema; `--flow` for flow specs, `--config` for the config file |
196
217
  | `codechart config` | Config in effect and where each value comes from (`--json`) |
197
218
  | `codechart init` | Write a commented starter `.codechart.yaml` at the git root (`--force` to overwrite) |
198
- | `codechart install-skill` | Install the skill for the agents found in your home folder. `--agent <names>`, `--dir <path>`, `--force` to overwrite |
219
+ | `codechart install-skill` | Install the skill for the agents found in your home folder. `--agent <names>`, `--dir <path>`, `--force` to overwrite, `--reminder`, `--hook` |
220
+ | `codechart uninstall` | Remove the skill, reminder lines and hooks; `--skill`, `--reminder`, `--hook` to pick some |
221
+ | `codechart hook prompt\|stop` | Run by the Claude Code hook; reads the hook's JSON on stdin |
199
222
 
200
223
  </details>
201
224
 
@@ -204,6 +227,9 @@ Rules have a `name` plus exactly one of `paths` (globs: `*`, `**`, `?`, `[..]`;
204
227
  **My agent isn't on the list.**
205
228
  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`.
206
229
 
230
+ **My agent asks permission for every render, even though I allowed `codechart`.**
231
+ The skill pipes the spec in with a heredoc (`codechart render --md - <<'EOF'`). In Claude Code, an allow rule like `Bash(codechart:*)` didn't cover that in our tests, so Claude Code asks before each render: approve it.
232
+
207
233
  **Will it draw a diagram for every tiny change?**
208
234
  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.
209
235