codechart 0.1.1 → 0.1.2
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 +30 -28
- package/dist/cli.js +41 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +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
|
-
<img alt="Node
|
|
11
|
+
<img alt="Node 22.12+" src="https://img.shields.io/badge/node-%3E%3D22.12-339933">
|
|
12
12
|
<a href="LICENSE"><img alt="MIT" src="https://img.shields.io/badge/license-MIT-blue"></a>
|
|
13
13
|
</p>
|
|
14
14
|
|
|
@@ -63,6 +63,33 @@ New things are `+`, changed ones `~`, existing ones `·`, config `◆`. Layers a
|
|
|
63
63
|
|
|
64
64
|

|
|
65
65
|
|
|
66
|
+
Ask how something works and you get a **flow** instead. Every step points at the code that implements it:
|
|
67
|
+
|
|
68
|
+
```text
|
|
69
|
+
Flow (key: + new ~ changed ? planned ◇ decision ⤷ shared step)
|
|
70
|
+
|
|
71
|
+
Accept a team invite
|
|
72
|
+
────────────────────
|
|
73
|
+
+look up invite by token
|
|
74
|
+
◇ +invite found?
|
|
75
|
+
├─ no → +404 invite not found
|
|
76
|
+
└─ yes → ◇ +expired?
|
|
77
|
+
├─ yes → +410 invite expired
|
|
78
|
+
└─ no → ◇ +already a member?
|
|
79
|
+
├─ yes → +return already a member
|
|
80
|
+
└─ no → +save membership → +return joined
|
|
81
|
+
|
|
82
|
+
9 steps · 9 new · 0 changed · 0 planned
|
|
83
|
+
gaps: did not check what happens when two requests accept the same invite at
|
|
84
|
+
once
|
|
85
|
+
|
|
86
|
+
Open full map
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Its full page shows the exact code behind each step. Click any step:
|
|
90
|
+
|
|
91
|
+

|
|
92
|
+
|
|
66
93
|
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
94
|
|
|
68
95
|
## Install
|
|
@@ -91,32 +118,7 @@ Tables, columns, enums, models, endpoints, components, config and env vars, grou
|
|
|
91
118
|
|
|
92
119
|
### Flows: what the code actually does
|
|
93
120
|
|
|
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
|
-

|
|
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.
|
|
120
122
|
|
|
121
123
|
### Terminal first, page when it helps
|
|
122
124
|
|
|
@@ -212,7 +214,7 @@ Not because of codechart. It makes no network calls. The diagram is built from w
|
|
|
212
214
|
`~/.cache/codechart`. It keeps the newest 20 per repo, plus anything under 7 days old.
|
|
213
215
|
|
|
214
216
|
**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
|
|
217
|
+
Those editors open file links as text. codechart detects them and opens new pages in your browser instead. Where the editor doesn't allow that (Antigravity sandboxes agent commands), the reply includes the page's address to paste into your browser. Turn auto-open off with `web.open: never` in `~/.config/codechart/config.yaml`.
|
|
216
218
|
|
|
217
219
|
## License
|
|
218
220
|
|
package/dist/cli.js
CHANGED
|
@@ -1152,6 +1152,18 @@ ${fence}`);
|
|
|
1152
1152
|
return `${lines.join("\n")}
|
|
1153
1153
|
`;
|
|
1154
1154
|
}
|
|
1155
|
+
function openBlockedNote(htmlPath, md) {
|
|
1156
|
+
const href = pathToFileURL(resolve4(htmlPath)).href;
|
|
1157
|
+
const say = "Your editor didn't let codechart open the page. Paste this into your browser's address bar:";
|
|
1158
|
+
return md ? `${say}
|
|
1159
|
+
|
|
1160
|
+
\`\`\`text
|
|
1161
|
+
${href}
|
|
1162
|
+
\`\`\`
|
|
1163
|
+
` : `${say}
|
|
1164
|
+
${href}
|
|
1165
|
+
`;
|
|
1166
|
+
}
|
|
1155
1167
|
|
|
1156
1168
|
// src/render/output-path.ts
|
|
1157
1169
|
import { createHash } from "crypto";
|
|
@@ -2022,7 +2034,7 @@ function specJsonSchema() {
|
|
|
2022
2034
|
}
|
|
2023
2035
|
|
|
2024
2036
|
// src/commands/open.ts
|
|
2025
|
-
import { spawn } from "child_process";
|
|
2037
|
+
import { spawn, spawnSync } from "child_process";
|
|
2026
2038
|
import { win32 as win322 } from "path";
|
|
2027
2039
|
function openArgv(platform, file, env = process.env) {
|
|
2028
2040
|
if (platform === "darwin") return ["open", [file]];
|
|
@@ -2034,12 +2046,22 @@ function openArgv(platform, file, env = process.env) {
|
|
|
2034
2046
|
function inCodeEditor(env) {
|
|
2035
2047
|
return Boolean(env.VSCODE_PID) || env.TERM_PROGRAM === "vscode";
|
|
2036
2048
|
}
|
|
2037
|
-
function openInBrowser(file) {
|
|
2038
|
-
const [cmd, args] = openArgv(
|
|
2049
|
+
function openInBrowser(file, { platform = process.platform, run = spawnSync, detach = spawn } = {}) {
|
|
2050
|
+
const [cmd, args] = openArgv(platform, file);
|
|
2039
2051
|
try {
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2052
|
+
if (platform === "linux") {
|
|
2053
|
+
detach(cmd, args, { detached: true, stdio: "ignore" }).on("error", () => {
|
|
2054
|
+
}).unref();
|
|
2055
|
+
return void 0;
|
|
2056
|
+
}
|
|
2057
|
+
const r = run(cmd, args, { stdio: ["ignore", "ignore", "pipe"], timeout: 1e4, encoding: "utf8" });
|
|
2058
|
+
if (r.error?.code === "ETIMEDOUT") return void 0;
|
|
2059
|
+
if (r.error) return r.error.message;
|
|
2060
|
+
if (r.status === 0) return void 0;
|
|
2061
|
+
const why = (r.stderr ?? "").trim().split("\n")[0]?.slice(0, 200);
|
|
2062
|
+
return `${cmd} exited with ${r.status ?? r.signal}${why ? `: ${why}` : ""}`;
|
|
2063
|
+
} catch (e) {
|
|
2064
|
+
return e.message;
|
|
2043
2065
|
}
|
|
2044
2066
|
}
|
|
2045
2067
|
|
|
@@ -2563,6 +2585,8 @@ function renderCommand(opts) {
|
|
|
2563
2585
|
const print = (text) => opts.stdout(o.md ? `${text}
|
|
2564
2586
|
` : text);
|
|
2565
2587
|
const slug = fileSlug(spec.title, diagram);
|
|
2588
|
+
let blocked;
|
|
2589
|
+
const printBlocked = () => blocked && print(openBlockedNote(blocked, o.md === true));
|
|
2566
2590
|
const writeHtml = async (build) => {
|
|
2567
2591
|
const now = opts.now?.() ?? /* @__PURE__ */ new Date();
|
|
2568
2592
|
const file = htmlOutputPath(config, repoFolder(root), slug, now);
|
|
@@ -2575,12 +2599,20 @@ function renderCommand(opts) {
|
|
|
2575
2599
|
writeFileSync(file, html, { mode: 384 });
|
|
2576
2600
|
pruneHtml(dirname4(file), { ...config.web, now, replaceSlug: slug });
|
|
2577
2601
|
const mode = config.web.open;
|
|
2578
|
-
if (o.open || mode === "always" || mode === "auto" && inCodeEditor(opts.env ?? process.env))
|
|
2602
|
+
if (o.open || mode === "always" || mode === "auto" && inCodeEditor(opts.env ?? process.env)) {
|
|
2603
|
+
const failed = (opts.open ?? openInBrowser)(file);
|
|
2604
|
+
if (failed) {
|
|
2605
|
+
opts.stderr(`codechart: could not open the browser (${failed})
|
|
2606
|
+
`);
|
|
2607
|
+
blocked = file;
|
|
2608
|
+
}
|
|
2609
|
+
}
|
|
2579
2610
|
return file;
|
|
2580
2611
|
};
|
|
2581
2612
|
if (spec.diagram === "flow") {
|
|
2582
2613
|
const tree = { maxNodes, width, color, md: o.md };
|
|
2583
2614
|
print(await renderFlow(spec, snippets, { output, minNodes: config.web.minNodes, tree, writeHtml }));
|
|
2615
|
+
printBlocked();
|
|
2584
2616
|
return;
|
|
2585
2617
|
}
|
|
2586
2618
|
const { hidden } = selectTerminalNodes(spec, maxNodes);
|
|
@@ -2601,6 +2633,7 @@ function renderCommand(opts) {
|
|
|
2601
2633
|
if (o.md) print(markdown(map, htmlPath));
|
|
2602
2634
|
else print(map ?? `${fullMapLine(htmlPath)}
|
|
2603
2635
|
`);
|
|
2636
|
+
printBlocked();
|
|
2604
2637
|
} catch (e) {
|
|
2605
2638
|
const message = e instanceof Error ? e.message : String(e);
|
|
2606
2639
|
const lines = e instanceof InvalidSpec ? e.errors : message.split("\n").map((l) => `codechart: ${l}`);
|
|
@@ -2625,7 +2658,7 @@ function buildProgram(opts = {}) {
|
|
|
2625
2658
|
const stdout = opts.stdout ?? ((s) => process.stdout.write(s));
|
|
2626
2659
|
const rawStderr = opts.stderr ?? ((s) => process.stderr.write(s));
|
|
2627
2660
|
const stderr = (s) => rawStderr(sanitizeText(s));
|
|
2628
|
-
const program = new Command7().name("codechart").version("0.1.
|
|
2661
|
+
const program = new Command7().name("codechart").version("0.1.2");
|
|
2629
2662
|
const cmdOpts = { ...opts, stdout, stderr };
|
|
2630
2663
|
program.addCommand(checkCommand(cmdOpts));
|
|
2631
2664
|
program.addCommand(renderCommand(cmdOpts));
|