codechart 0.2.0 → 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 +6 -3
- package/dist/cli.js +88 -26
- package/package.json +4 -1
- package/skills/codechart/SKILL.md +3 -2
- package/skills/codechart/spec-guide.md +33 -0
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,6 +109,8 @@ 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
|
+
|
|
111
114
|
### Optional: help agents remember it
|
|
112
115
|
|
|
113
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):
|
|
@@ -129,7 +132,7 @@ codechart uninstall && npm uninstall -g codechart
|
|
|
129
132
|
|
|
130
133
|
### Maps: what changed and how it connects
|
|
131
134
|
|
|
132
|
-
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. A plan that changes existing code opens as **Now** and **After plan** side by side: same positions, panning together, with what the plan removes in red and what it adds in green.
|
|
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.
|
|
133
136
|
|
|
134
137
|
### Flows: what the code actually does
|
|
135
138
|
|
|
@@ -151,7 +154,7 @@ Small diagrams stay in the reply. Big ones, or rules you mark `output: both`, al
|
|
|
151
154
|
|
|
152
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).
|
|
153
156
|
|
|
154
|
-
The CLI is small: a
|
|
157
|
+
The CLI is small: a 68.8 kB package, 5 runtime dependencies, and a cold start around 150 ms.
|
|
155
158
|
|
|
156
159
|
## Safe to run
|
|
157
160
|
|
|
@@ -194,7 +197,7 @@ Repo `.codechart.yaml` and global `~/.config/codechart/config.yaml`. Editor sche
|
|
|
194
197
|
| `defaults.terminalMaxNodes` | number | `15` |
|
|
195
198
|
| `web.theme` | `auto`, `light`, `dark` | `auto` |
|
|
196
199
|
| `web.minNodes` | HTML from this many nodes on | `8` |
|
|
197
|
-
| `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` |
|
|
198
201
|
| `rules` | your own, run before the built-ins | none |
|
|
199
202
|
|
|
200
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`).
|
package/dist/cli.js
CHANGED
|
@@ -52,6 +52,31 @@ var MAP_RULES = [
|
|
|
52
52
|
"**/app/models/**"
|
|
53
53
|
]
|
|
54
54
|
},
|
|
55
|
+
{
|
|
56
|
+
name: "infrastructure",
|
|
57
|
+
// No bare charts/** or templates/**: UI chart components and non-Helm templates live there too.
|
|
58
|
+
paths: [
|
|
59
|
+
"**/*.tf",
|
|
60
|
+
"**/*.tofu",
|
|
61
|
+
"**/*.tf.json",
|
|
62
|
+
"**/*.tfvars",
|
|
63
|
+
"**/*.tfvars.json",
|
|
64
|
+
"**/terragrunt.hcl",
|
|
65
|
+
"**/Chart.yaml",
|
|
66
|
+
"**/values.yaml",
|
|
67
|
+
"**/values-*.yaml",
|
|
68
|
+
"**/charts/**/*.yaml",
|
|
69
|
+
"**/charts/**/*.tpl",
|
|
70
|
+
"**/helm/**/*.yaml",
|
|
71
|
+
"**/helm/**/*.tpl",
|
|
72
|
+
"**/kustomization.yaml",
|
|
73
|
+
"**/kustomization.yml",
|
|
74
|
+
"**/k8s/**/*.yaml",
|
|
75
|
+
"**/k8s/**/*.yml",
|
|
76
|
+
"**/kubernetes/**/*.yaml",
|
|
77
|
+
"**/kubernetes/**/*.yml"
|
|
78
|
+
]
|
|
79
|
+
},
|
|
55
80
|
{
|
|
56
81
|
name: "related-files",
|
|
57
82
|
when: "more than 2 changed files depend on each other"
|
|
@@ -2227,9 +2252,13 @@ var SIDE_KEY = {
|
|
|
2227
2252
|
};
|
|
2228
2253
|
function hasNowAfter(spec) {
|
|
2229
2254
|
if (spec.kind !== "plan") return false;
|
|
2230
|
-
|
|
2255
|
+
if (spec.edges.some((e) => e.change !== void 0) || spec.nodes.some((n) => n.status === "removed")) return true;
|
|
2256
|
+
const fields = spec.nodes.flatMap((n) => n.fields ?? []);
|
|
2257
|
+
const touches = spec.nodes.some((n) => n.status === "changed") || fields.some((f) => f.change === "removed" || f.change === "modified");
|
|
2258
|
+
const differs = spec.nodes.some((n) => n.status === "new") || fields.some(differsOnSides);
|
|
2259
|
+
return touches && differs;
|
|
2231
2260
|
}
|
|
2232
|
-
var
|
|
2261
|
+
var differsOnSides = (f) => f.change === "added" || f.change === "removed" || f.was !== void 0;
|
|
2233
2262
|
var nodeOn = (side, status) => side === "now" ? status !== "new" : status !== "removed";
|
|
2234
2263
|
function edgeChange(e, statusOf) {
|
|
2235
2264
|
if (e.change) return e.change;
|
|
@@ -2429,9 +2458,22 @@ function wrapText(text, chars, maxLines) {
|
|
|
2429
2458
|
}
|
|
2430
2459
|
return lines;
|
|
2431
2460
|
}
|
|
2432
|
-
|
|
2461
|
+
var LABEL_CHARS = 22;
|
|
2462
|
+
var LABEL_MORE_CHARS = 30;
|
|
2463
|
+
var LABEL_LINE_HEIGHT = 14;
|
|
2464
|
+
var LABEL_BREAKS = ["_", ".", "/", "-", " "];
|
|
2465
|
+
function labelLines(label) {
|
|
2466
|
+
if (label.length <= LABEL_CHARS) return [label];
|
|
2467
|
+
const head = label.slice(0, LABEL_CHARS);
|
|
2468
|
+
const cut2 = Math.max(...LABEL_BREAKS.map((c) => head.lastIndexOf(c))) + 1;
|
|
2469
|
+
const at = cut2 >= LABEL_CHARS / 2 ? cut2 : LABEL_CHARS;
|
|
2470
|
+
const rest = label.slice(at).trim();
|
|
2471
|
+
return [label.slice(0, at).trimEnd(), rest.length > LABEL_MORE_CHARS ? rest.slice(0, LABEL_MORE_CHARS - 1) + "\u2026" : rest];
|
|
2472
|
+
}
|
|
2473
|
+
var headerHeight = (label) => HEADER_HEIGHT + LABEL_LINE_HEIGHT * (labelLines(label).length - 1);
|
|
2474
|
+
function nodeHeight(label, fields, summary) {
|
|
2433
2475
|
const summaryLines = summary ? wrapSummary(summary).length : 0;
|
|
2434
|
-
return
|
|
2476
|
+
return headerHeight(label) + LINE_HEIGHT * (fields + summaryLines);
|
|
2435
2477
|
}
|
|
2436
2478
|
var FIT_CANVASES = [
|
|
2437
2479
|
[1140, 800],
|
|
@@ -2467,7 +2509,7 @@ async function layoutIn(elk, spec, direction) {
|
|
|
2467
2509
|
children: spec.nodes.filter((n) => n.layer === layer).map((n) => ({
|
|
2468
2510
|
id: n.id,
|
|
2469
2511
|
width: NODE_WIDTH,
|
|
2470
|
-
height: nodeHeight(n.fields?.length ?? 0, n.summary)
|
|
2512
|
+
height: nodeHeight(n.label, n.fields?.length ?? 0, n.summary)
|
|
2471
2513
|
}))
|
|
2472
2514
|
}));
|
|
2473
2515
|
const edges = spec.edges.map((e, i) => ({
|
|
@@ -2550,7 +2592,7 @@ main{flex:1;display:flex;min-height:0}
|
|
|
2550
2592
|
aside{width:clamp(300px,35vw,600px);min-width:300px;max-width:80vw;border-left:1px solid var(--line);background:var(--panel);overflow:auto;padding:10px 14px}
|
|
2551
2593
|
#resize{flex:none;width:5px;margin-right:-5px;position:relative;z-index:1;cursor:col-resize;touch-action:none}
|
|
2552
2594
|
#resize:hover,#resize:focus-visible,#resize.drag{background:var(--edge);outline:none}
|
|
2553
|
-
aside h2{margin:0 0 6px;font-size:13px}
|
|
2595
|
+
aside h2{margin:0 0 6px;font-size:13px;overflow-wrap:anywhere}
|
|
2554
2596
|
aside h3{margin:12px 0 4px;font-size:11px;text-transform:uppercase;color:var(--muted)}
|
|
2555
2597
|
aside ul{margin:0;padding-left:18px}
|
|
2556
2598
|
aside .fields-note{color:var(--muted);font-size:11.5px;font-style:italic;margin:6px 0 0}
|
|
@@ -2592,8 +2634,8 @@ header .check{font-size:11px;color:var(--new-t)}header .check.bad{color:var(--re
|
|
|
2592
2634
|
.field-added-t{color:var(--add)}.field-removed-t{color:var(--muted);text-decoration:line-through}.field-modified-t{color:var(--chg-t)}
|
|
2593
2635
|
|
|
2594
2636
|
#info-toggle[aria-expanded="true"]{border-color:var(--edge)}
|
|
2595
|
-
#info-toggle,#theme-toggle{align-self:center;padding:4px 10px;font:11px system-ui,sans-serif;color:var(--text);background:var(--panel);border:1px solid var(--line);border-radius:12px;cursor:pointer}
|
|
2596
|
-
#info-toggle:hover,#theme-toggle:hover{border-color:var(--edge)}
|
|
2637
|
+
#info-toggle,#link-toggle,#theme-toggle{align-self:center;padding:4px 10px;font:11px system-ui,sans-serif;color:var(--text);background:var(--panel);border:1px solid var(--line);border-radius:12px;cursor:pointer}
|
|
2638
|
+
#info-toggle:hover,#link-toggle:hover,#theme-toggle:hover{border-color:var(--edge)}
|
|
2597
2639
|
`;
|
|
2598
2640
|
|
|
2599
2641
|
// src/render/web/client.ts
|
|
@@ -2605,32 +2647,37 @@ var CLIENT_JS = `
|
|
|
2605
2647
|
var panel = document.getElementById('panel');
|
|
2606
2648
|
var info = document.getElementById('page-info');
|
|
2607
2649
|
var infoBtn = document.getElementById('info-toggle');
|
|
2608
|
-
// One transform
|
|
2609
|
-
var
|
|
2650
|
+
// One transform per pane; while linked, a move in one is copied to all so Now and After stay aligned.
|
|
2651
|
+
var ts = canvases.map(function () { return { x: 0, y: 0, k: 1 }; });
|
|
2652
|
+
var linked = true, last = 0;
|
|
2610
2653
|
function apply() {
|
|
2611
|
-
vps.forEach(function (vp) { vp.setAttribute('transform', 'translate(' + t.x + ',' + t.y + ') scale(' + t.k + ')'); });
|
|
2654
|
+
vps.forEach(function (vp, i) { var t = ts[i]; vp.setAttribute('transform', 'translate(' + t.x + ',' + t.y + ') scale(' + t.k + ')'); });
|
|
2655
|
+
}
|
|
2656
|
+
function move(i, t) {
|
|
2657
|
+
last = i;
|
|
2658
|
+
ts = ts.map(function (old, j) { return linked || j === i ? { x: t.x, y: t.y, k: t.k } : old; });
|
|
2659
|
+
apply();
|
|
2612
2660
|
}
|
|
2613
2661
|
function fit() {
|
|
2614
2662
|
var r = canvases[0].querySelector('svg').getBoundingClientRect();
|
|
2615
2663
|
var k = Math.min(r.width / data.width, r.height / data.height, 1) || 1;
|
|
2616
|
-
t = { k: k, x: (r.width - data.width * k) / 2, y: (r.height - data.height * k) / 2 };
|
|
2664
|
+
var t = { k: k, x: (r.width - data.width * k) / 2, y: (r.height - data.height * k) / 2 };
|
|
2665
|
+
ts = ts.map(function () { return { x: t.x, y: t.y, k: t.k }; });
|
|
2617
2666
|
apply();
|
|
2618
2667
|
}
|
|
2619
2668
|
var drag = null, moved = false;
|
|
2620
|
-
canvases.forEach(function (canvas) {
|
|
2669
|
+
canvases.forEach(function (canvas, i) {
|
|
2621
2670
|
var svg = canvas.querySelector('svg');
|
|
2622
2671
|
canvas.addEventListener('wheel', function (e) {
|
|
2623
2672
|
e.preventDefault();
|
|
2673
|
+
var t = ts[i];
|
|
2624
2674
|
var r = svg.getBoundingClientRect();
|
|
2625
2675
|
var px = e.clientX - r.left, py = e.clientY - r.top;
|
|
2626
2676
|
var k = Math.min(4, Math.max(0.1, t.k * Math.exp(-e.deltaY * 0.0015)));
|
|
2627
|
-
|
|
2628
|
-
t.y = py - ((py - t.y) / t.k) * k;
|
|
2629
|
-
t.k = k;
|
|
2630
|
-
apply();
|
|
2677
|
+
move(i, { x: px - ((px - t.x) / t.k) * k, y: py - ((py - t.y) / t.k) * k, k: k });
|
|
2631
2678
|
}, { passive: false });
|
|
2632
2679
|
canvas.addEventListener('pointerdown', function (e) {
|
|
2633
|
-
drag = { x: e.clientX -
|
|
2680
|
+
drag = { i: i, x: e.clientX - ts[i].x, y: e.clientY - ts[i].y, sx: e.clientX, sy: e.clientY, canvas: canvas };
|
|
2634
2681
|
moved = false;
|
|
2635
2682
|
});
|
|
2636
2683
|
});
|
|
@@ -2638,8 +2685,22 @@ var CLIENT_JS = `
|
|
|
2638
2685
|
if (!drag) return;
|
|
2639
2686
|
if (Math.abs(e.clientX - drag.sx) + Math.abs(e.clientY - drag.sy) > 3) { moved = true; drag.canvas.classList.add('drag'); }
|
|
2640
2687
|
if (!moved) return;
|
|
2641
|
-
|
|
2688
|
+
move(drag.i, { x: e.clientX - drag.x, y: e.clientY - drag.y, k: ts[drag.i].k });
|
|
2642
2689
|
});
|
|
2690
|
+
var linkBtn = document.getElementById('link-toggle');
|
|
2691
|
+
function setLinked(on, save) {
|
|
2692
|
+
linked = on;
|
|
2693
|
+
linkBtn.textContent = 'Panes: ' + (on ? 'linked' : 'separate');
|
|
2694
|
+
linkBtn.setAttribute('aria-pressed', String(on));
|
|
2695
|
+
if (on) move(last, ts[last]);
|
|
2696
|
+
if (save) { try { localStorage.setItem('codechart.panes.linked', on ? '1' : '0'); } catch (e) {} }
|
|
2697
|
+
}
|
|
2698
|
+
if (linkBtn) {
|
|
2699
|
+
var savedLink = null;
|
|
2700
|
+
try { savedLink = localStorage.getItem('codechart.panes.linked'); } catch (e) {}
|
|
2701
|
+
setLinked(savedLink !== '0', false);
|
|
2702
|
+
linkBtn.addEventListener('click', function () { setLinked(!linked, true); });
|
|
2703
|
+
}
|
|
2643
2704
|
function endDrag() {
|
|
2644
2705
|
if (drag) drag.canvas.classList.remove('drag');
|
|
2645
2706
|
drag = null;
|
|
@@ -2779,7 +2840,7 @@ function renderPage(p) {
|
|
|
2779
2840
|
<title>${esc(p.title)}</title>
|
|
2780
2841
|
<style>${CSS}${p.extraCss ?? ""}</style></head>
|
|
2781
2842
|
<body>
|
|
2782
|
-
<header><h1>${esc(p.title)}</h1>${p.headerNote ?? ""}<span class="meta">${esc(p.meta.repo)} \xB7 ${esc(p.meta.generatedAt.toISOString())}</span>${p.infoButton}<button id="theme-toggle" type="button" title="Cycle theme: auto, light, dark"></button></header>
|
|
2843
|
+
<header><h1>${esc(p.title)}</h1>${p.headerNote ?? ""}<span class="meta">${esc(p.meta.repo)} \xB7 ${esc(p.meta.generatedAt.toISOString())}</span>${p.infoButton}${p.panes ? '<button id="link-toggle" type="button" title="Linked: panning or zooming one pane moves both"></button>' : ""}<button id="theme-toggle" type="button" title="Cycle theme: auto, light, dark"></button></header>
|
|
2783
2844
|
<main>
|
|
2784
2845
|
${body}
|
|
2785
2846
|
<div id="resize" role="separator" aria-orientation="vertical" aria-label="Resize panel" tabindex="0" title="Drag to resize the panel"></div>
|
|
@@ -3010,7 +3071,7 @@ function stepPanel(spec, step, snippets, byId, check) {
|
|
|
3010
3071
|
return `<template class="card-panel" data-for="${esc(step.id)}">${out}</template>`;
|
|
3011
3072
|
}
|
|
3012
3073
|
function pageInfo(spec, anyPlanned, sides, check) {
|
|
3013
|
-
let out = `<p>Click a step for its status, source and code. Scroll to zoom, drag to pan${sides ?
|
|
3074
|
+
let out = `<p>Click a step for its status, source and code. Scroll to zoom, drag to pan${sides ? '; while "Panes: linked", both panes move together' : ""}.</p>`;
|
|
3014
3075
|
out += checkSection(check);
|
|
3015
3076
|
if (anyPlanned) out += '<p class="planned-note">Dashed steps and arrows are planned: not in the code yet.</p>';
|
|
3016
3077
|
if (spec.steps.some((s) => s.status === "removed") || spec.links.some((l) => l.removed)) {
|
|
@@ -3085,7 +3146,8 @@ function renderNode(n, box, flagged, fields) {
|
|
|
3085
3146
|
const y = Math.round(box.y * 10) / 10;
|
|
3086
3147
|
const w = box.w;
|
|
3087
3148
|
const lines = [];
|
|
3088
|
-
|
|
3149
|
+
const head = headerHeight(n.label);
|
|
3150
|
+
let row = head;
|
|
3089
3151
|
const text = (cls, s) => {
|
|
3090
3152
|
lines.push(`<text class="${cls}" x="${x + 8}" y="${y + row + 12}">${esc(s)}</text>`);
|
|
3091
3153
|
row += 16;
|
|
@@ -3095,7 +3157,7 @@ function renderNode(n, box, flagged, fields) {
|
|
|
3095
3157
|
text(f.change ? `field field-${f.change}` : "field", clip3(fieldText(f), FIELD_CHARS));
|
|
3096
3158
|
}
|
|
3097
3159
|
const height = Math.max(row, Math.round(box.h * 10) / 10);
|
|
3098
|
-
return `<g class="node status-${n.status}" data-id="${esc(n.id)}" tabindex="0" role="button" aria-label="${esc(`${n.label} (${n.status}${flagged ? ", doesn't match the code" : ""})`)}"><rect class="card" x="${x}" y="${y}" width="${w}" height="${height}" rx="6"/><line class="head" x1="${x}" y1="${y +
|
|
3160
|
+
return `<g class="node status-${n.status}" data-id="${esc(n.id)}" tabindex="0" role="button" aria-label="${esc(`${n.label} (${n.status}${flagged ? ", doesn't match the code" : ""})`)}"><rect class="card" x="${x}" y="${y}" width="${w}" height="${height}" rx="6"/><line class="head" x1="${x}" y1="${y + head}" x2="${x + w}" y2="${y + head}"/>` + labelLines(n.label).map((l, i) => `<text class="label" x="${x + 8}" y="${y + 18 + i * LABEL_LINE_HEIGHT}">${esc(l)}</text>`).join("") + `<text class="badge" x="${x + w - 8}" y="${y + 18}">${esc(n.status)}</text>` + lines.join("") + (flagged ? flagMark(x + w, y) : "") + `</g>`;
|
|
3099
3161
|
}
|
|
3100
3162
|
var FIELDS_NOTE = "Only the fields the agent saw are listed. Set <code>defaults.context: full</code> in <code>.codechart.yaml</code> to let it read the full definition.";
|
|
3101
3163
|
var DIFF_MARK = { add: "+", del: "-", ctx: " " };
|
|
@@ -3118,7 +3180,7 @@ function fieldsHtml(n, sides) {
|
|
|
3118
3180
|
return `<h3>Fields now</h3>${fieldList(now)}<h3>Fields after</h3>${fieldList(after)}`;
|
|
3119
3181
|
}
|
|
3120
3182
|
function cardPanel(n, check, previews, sides) {
|
|
3121
|
-
let out = `<h2>${esc(`${n.label} (${n.status} ${n.kind})`)}</h2>`;
|
|
3183
|
+
let out = `<h2>${esc(`${n.label} (${n.kind === "other" ? n.status : `${n.status} ${n.kind}`})`)}</h2>`;
|
|
3122
3184
|
out += mismatchNote(check, n.id);
|
|
3123
3185
|
const match = check?.matches.get(n.id);
|
|
3124
3186
|
if (match) out += snippetHtml(match);
|
|
@@ -3134,7 +3196,7 @@ function cardPanel(n, check, previews, sides) {
|
|
|
3134
3196
|
return `<template class="card-panel" data-for="${esc(n.id)}">${out}</template>`;
|
|
3135
3197
|
}
|
|
3136
3198
|
function pageInfo2(spec, check, sides) {
|
|
3137
|
-
let out = `<p>Click a node for details. Scroll to zoom, drag to pan${sides ?
|
|
3199
|
+
let out = `<p>Click a node for details. Scroll to zoom, drag to pan${sides ? '; while "Panes: linked", both panes move together' : ""}.</p>`;
|
|
3138
3200
|
out += checkSection(check);
|
|
3139
3201
|
if (spec.gaps?.length) out += `<h3>Gaps</h3>${list(spec.gaps)}`;
|
|
3140
3202
|
if (spec.omitted?.length) out += `<h3>Not on map</h3>${list(spec.omitted)}`;
|
|
@@ -3629,7 +3691,7 @@ function buildProgram(opts = {}) {
|
|
|
3629
3691
|
const stdout = opts.stdout ?? ((s) => process.stdout.write(s));
|
|
3630
3692
|
const rawStderr = opts.stderr ?? ((s) => process.stderr.write(s));
|
|
3631
3693
|
const stderr = (s) => rawStderr(sanitizeText(s));
|
|
3632
|
-
const program = new Command9().name("codechart").version("0.
|
|
3694
|
+
const program = new Command9().name("codechart").version("0.3.0");
|
|
3633
3695
|
const cmdOpts = { ...opts, stdout, stderr };
|
|
3634
3696
|
program.addCommand(checkCommand(cmdOpts));
|
|
3635
3697
|
program.addCommand(renderCommand(cmdOpts));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "codechart",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Agent skill + CLI: maps and flowcharts of code changes for AI coding agents, in terminal, chat and HTML",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent-skills",
|
|
@@ -72,5 +72,8 @@
|
|
|
72
72
|
"typescript": "^6.0.3",
|
|
73
73
|
"typescript-eslint": "^8.72.1",
|
|
74
74
|
"vitest": "^5.0.5"
|
|
75
|
+
},
|
|
76
|
+
"overrides": {
|
|
77
|
+
"minimatch": "^11.0.1"
|
|
75
78
|
}
|
|
76
79
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: codechart
|
|
3
|
-
description: 'Use whenever you are about to describe code changes or a plan for them, whether you made the changes or not. Triggers include "summarize the changes", "summarize the staged/uncommitted changes", "what changed", "what did you change", "recap", "walk me through the diff", "explain this diff/commit/branch", "write the PR description", "review what we did", "wrap up", and finishing a task with a summary; also "make a plan", "how would you implement", "plan this feature/migration/refactor", "design the schema change", any request for a map, diagram or overview of how files, tables, models, services or config relate; and any request to see how code behaves: "show me the flow", "how does this work", "walk me through the logic", "what are the edge cases", "what happens when…", "draw the decision flow". Not needed when the change is a single file with only text, comments, formatting, a typo or a version bump: if there is a diff, look at it first and skip this skill then.'
|
|
3
|
+
description: 'Use whenever you are about to describe code changes or a plan for them, whether you made the changes or not. Triggers include "summarize the changes", "summarize the staged/uncommitted changes", "what changed", "what did you change", "recap", "walk me through the diff", "explain this diff/commit/branch", "write the PR description", "review what we did", "wrap up", and finishing a task with a summary; also "make a plan", "how would you implement", "plan this feature/migration/refactor", "design the schema change", any request for a map, diagram or overview of how files, tables, models, services, infrastructure or config relate; and any request to see how code behaves: "show me the flow", "how does this work", "walk me through the logic", "what are the edge cases", "what happens when…", "draw the decision flow". Not needed when the change is a single file with only text, comments, formatting, a typo or a version bump: if there is a diff, look at it first and skip this skill then.'
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# codechart
|
|
@@ -9,7 +9,7 @@ Renders maps and flows from JSON specs you write, for a **plan** or **change sum
|
|
|
9
9
|
|
|
10
10
|
A flow the user asked for ("show me the flow"): skip step 1, write a flow spec without `rules` (`summary`, unchanged code `existing`), render as in step 2 with `--output both`.
|
|
11
11
|
|
|
12
|
-
Skip it for a trivial change (see description), a question not about code changes or behaviour, or if the user said no diagram. If `codechart` is "not found", say once "codechart is not installed, so no map" and go on; never install it.
|
|
12
|
+
Skip it for a trivial change (see description), a question not about code changes or behaviour, or if the user said no diagram. If `codechart` is "not found", say once "the codechart CLI is not installed (`npm i -g codechart`), so no map" and go on; never install it.
|
|
13
13
|
|
|
14
14
|
## 1. Check
|
|
15
15
|
|
|
@@ -82,6 +82,7 @@ Draw only branches you saw in the code or (plan) will build; unverified ones go
|
|
|
82
82
|
```
|
|
83
83
|
|
|
84
84
|
- One node per table, model, file, service or endpoint, never merged: `new`, `changed`, `removed`, `config` (config/env), `context` (untouched neighbour the reader needs). Under 15; tests and docs go in `omitted`.
|
|
85
|
+
- Infrastructure: one node per resource, module or Kubernetes object, labelled as the code names it (`aws_s3_bucket.logs`, `module.vpc`, `Deployment api`), `kind` `other`, `path` the file that declares it; variables and values `config`; `terraform plan not run` goes in `gaps`. See [spec-guide.md](spec-guide.md#infrastructure).
|
|
85
86
|
- `layer` required, from a small set. `kind`: `table` `enum` `model` `service` `endpoint` `component` `file` (default with `path`) `config` `other`. Migration label: `migration: <what it does>`.
|
|
86
87
|
- `fields`: all you read, `change`: `added`/`removed`/`modified`; `fieldsComplete: true` only if you read the whole definition.
|
|
87
88
|
- Optional on a `new`/`changed` node with `path`: `match`, a distinctive piece of one line from the diff, as proof (shown in the HTML).
|
|
@@ -53,6 +53,39 @@ Rules:
|
|
|
53
53
|
- `false`: you list only what you saw, such as the changed columns in a migration. The map then says only some fields are shown.
|
|
54
54
|
- In `full` context, open the definition so you can list every field and set `true`.
|
|
55
55
|
|
|
56
|
+
## Infrastructure
|
|
57
|
+
|
|
58
|
+
Terraform, OpenTofu, Terragrunt, Helm, Kustomize and Kubernetes files match the built-in `infrastructure` rule. No special kinds:
|
|
59
|
+
|
|
60
|
+
| Thing | Node |
|
|
61
|
+
|---|---|
|
|
62
|
+
| Resource or data source | `kind: other`, label as the code names it (`aws_s3_bucket.logs`), `path` its `.tf` file, `match` its block line (`resource "aws_s3_bucket" "logs"`) |
|
|
63
|
+
| Module call | `kind: other`, label `module.vpc`, `path` the file with the `module` block, `match` its line (`module "vpc"`) |
|
|
64
|
+
| Local module's code, when the change edits it | `kind: file`, label `modules/vpc`, `path` its folder |
|
|
65
|
+
| Kubernetes object (manifest or Helm template) | `kind: other`, label `Deployment api`, `path` its file |
|
|
66
|
+
| Chart | `kind: file`, label `chart: api`, `path` its folder |
|
|
67
|
+
| Variable, output, tfvars or values key, ConfigMap or Secret | `kind: config`, status `config` |
|
|
68
|
+
|
|
69
|
+
- `layer` by role: `network`, `compute`, `storage`, `iam`, `dns`, `config`; not by file or environment.
|
|
70
|
+
- Edges: dependent → dependency, labelled with the attribute that refers (`vpc_id`, `role`, `serviceName`). `reads` for a reference or a variable, `configures` for values or inputs fed into a module or template, `other` for `depends_on`.
|
|
71
|
+
- `fields`: the attributes you changed or that matter, with `was` on a changed value (`"name": "instance_type", "type": "t3.small", "change": "modified", "was": "t3.micro"`); `fieldsComplete: false` unless you listed the whole block.
|
|
72
|
+
- `gaps`: resources and remote modules you didn't read, and `terraform plan not run` (you can't tell an in-place update from a replacement without it). A rename or a replacement you did spot is a risk for your prose.
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{ "kind": "summary", "title": "Access logs bucket for the load balancer", "rules": ["infrastructure"],
|
|
76
|
+
"nodes": [
|
|
77
|
+
{ "id": "logs", "label": "aws_s3_bucket.logs", "kind": "other", "status": "new", "layer": "storage", "path": "infra/logs.tf", "match": "resource \"aws_s3_bucket\" \"logs\"" },
|
|
78
|
+
{ "id": "alb", "label": "aws_lb.api", "kind": "other", "status": "changed", "layer": "network", "path": "infra/alb.tf", "fieldsComplete": false,
|
|
79
|
+
"fields": [{ "name": "access_logs.enabled", "type": "true", "change": "modified", "was": "false" }] },
|
|
80
|
+
{ "id": "retention", "label": "var.log_retention_days", "kind": "config", "status": "config", "layer": "config", "path": "infra/variables.tf" }
|
|
81
|
+
],
|
|
82
|
+
"edges": [
|
|
83
|
+
{ "from": "alb", "to": "logs", "label": "access_logs.bucket", "kind": "reads" },
|
|
84
|
+
{ "from": "logs", "to": "retention", "label": "expiration.days", "kind": "reads" }
|
|
85
|
+
],
|
|
86
|
+
"gaps": ["terraform plan not run"] }
|
|
87
|
+
```
|
|
88
|
+
|
|
56
89
|
## What `render` checks
|
|
57
90
|
|
|
58
91
|
Warnings, not failures (`--strict` makes them exit 1). Each mismatch is named in a `✗` line at the top of the output.
|