yuhwa 1.11.0 → 1.13.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.
Files changed (48) hide show
  1. package/README.md +25 -11
  2. package/dist/{api-C3G57UWP.d.ts → api-B4MhXD5r.d.ts} +116 -3
  3. package/dist/{api-DgN94Ia1.js → api-CvcW76ln.js} +2740 -34
  4. package/dist/astro.d.ts +1 -1
  5. package/dist/astro.js +1 -1
  6. package/dist/browser.d.ts +2 -2
  7. package/dist/browser.js +5 -5
  8. package/dist/cli.js +2305 -14
  9. package/dist/{edit-CGlOr7JF.js → edit-Cm8DW_KO.js} +1 -1
  10. package/dist/editor/assets/{index-BwZSlP7B.js → index-B2_IDuGn.js} +88 -64
  11. package/dist/editor/assets/index-BEvk0xaI.css +1 -0
  12. package/dist/editor/assets/{lsp.worker-dqJH5PcT.js → lsp.worker-IGttpwSP.js} +41 -41
  13. package/dist/editor/index.html +26 -6
  14. package/dist/{figure-DX7Wgxue.d.ts → figure-B2E8CnNn.d.ts} +1 -1
  15. package/dist/index.d.ts +2 -2
  16. package/dist/index.js +5 -5
  17. package/dist/ironmark.d.ts +1 -1
  18. package/dist/ironmark.js +1 -1
  19. package/dist/llms.txt +3 -0
  20. package/dist/lsp-browser.js +1 -1
  21. package/dist/lsp-node.js +1 -1
  22. package/dist/lsp-server.js +1 -1
  23. package/dist/lsp.js +1 -1
  24. package/dist/markdown-it.d.ts +1 -1
  25. package/dist/markdown-it.js +2 -2
  26. package/dist/{node-CT1lI4A1.js → node-hhZr8r_F.js} +2 -2
  27. package/dist/{plugin-0SWraI4f.js → plugin-BCLARrq1.js} +20 -9
  28. package/dist/plugin.js +1 -1
  29. package/dist/{plugins-3oYK28f5.js → plugins-Dwt5Qgzs.js} +35 -14
  30. package/dist/plugins.js +2 -2
  31. package/dist/remark.d.ts +1 -1
  32. package/dist/remark.js +1 -1
  33. package/dist/satteri.d.ts +1 -1
  34. package/dist/satteri.js +1 -1
  35. package/dist/{server-DqKDSDjt.js → server-DQz_f9N-.js} +2 -2
  36. package/dist/{service-C01nJa8B.js → service-DmbUk4C1.js} +3 -3
  37. package/dist/{shared-pKyDW6fZ.js → shared-C3N1_jLr.js} +826 -38
  38. package/dist/slim.d.ts +2 -2
  39. package/dist/slim.js +3 -3
  40. package/dist/{src-DmT2jkJ-.js → src-HtHsgFUt.js} +5 -2
  41. package/dist/vite.d.ts +1 -1
  42. package/dist/vite.js +3 -3
  43. package/dist/vuepress.d.ts +1 -1
  44. package/dist/vuepress.js +1 -1
  45. package/dist/yuhwa.iife.js +101 -70
  46. package/package.json +4 -2
  47. package/skills/yuhwa/SKILL.md +6 -3
  48. package/dist/editor/assets/index-BS6hb9gg.css +0 -1
package/README.md CHANGED
@@ -4,10 +4,15 @@
4
4
 
5
5
  # yuhwa
6
6
 
7
- **Text diagrams that look good and stay where you put them.**
7
+ **Beautiful text diagrams, styled your way, that stay where you put them.**
8
8
 
9
- A few lines of text become a clean SVG. A friendlier alternative to Mermaid,
10
- with a visual editor that writes your tweaks back into the source.
9
+ A few lines of text become a clean SVG that looks great out of the box. Make
10
+ it your own with themes, colours, shapes and icons, and drag things into place
11
+ in a visual editor that writes your tweaks back into the source. Like Mermaid,
12
+ only friendlier.
13
+
14
+ Write a diagram yourself or ask your AI agent to draft one. The CLI gives it
15
+ a syntax reference and diagnostics it can use to check and revise the draft.
11
16
 
12
17
  [![npm](https://img.shields.io/npm/v/yuhwa?color=2563eb)](https://www.npmjs.com/package/yuhwa)
13
18
  [![license](https://img.shields.io/npm/l/yuhwa?color=9333ea)](https://github.com/ph1p/yuhwa/blob/main/LICENSE)
@@ -30,6 +35,8 @@ with a visual editor that writes your tweaks back into the source.
30
35
  <details>
31
36
  <summary><b>The source of this picture</b>: one <code>.yu</code> file</summary>
32
37
 
38
+ The render times in the illustration are sample values.
39
+
33
40
  ```yuhwa
34
41
  title: How **yuhwa** works
35
42
  subtitle: one text file: graphs, windows, charts, sequences and more
@@ -168,19 +175,24 @@ Full reference: [syntax](https://ph1p.github.io/yuhwa/guide/syntax) ·
168
175
 
169
176
  ## Why yuhwa
170
177
 
178
+ - **Your agent can draw too.** Claude, Codex and Cursor can use `yuhwa guide`
179
+ for syntax, `yuhwa check` for diagnostics and `yuhwa render --text` for a
180
+ terminal preview. [Set it up](https://ph1p.github.io/yuhwa/guide/ai).
171
181
  - **Looks good with zero styling.** Clean auto-layout, curved routing, soft
172
182
  colours. Twelve built-in themes, or define your own in a `theme { }` block.
173
183
  - **Layout you control.** Drag boxes and bend edges in the visual editor.
174
184
  Positions land in the source as a small `layout { }` block, so the diagram
175
185
  stays put on every re-render and in every diff.
176
- - **One language, every diagram.** Flowcharts, sequence, timeline, gantt,
177
- kanban, mindmap, quadrant, file trees, git history and charts, side by side
178
- in one file.
186
+ - **Combine diagram types.** Put a flowchart or swimlane alongside sequence
187
+ diagrams, timelines, charts and other panels in one file.
188
+ [Browse the 24 diagram types](https://ph1p.github.io/yuhwa/diagrams/).
179
189
  - **Built for docs.** Plugins for VitePress, Astro, Docusaurus, VuePress, MDX
180
190
  and more. Light and dark variants, and a broken diagram fails the build.
181
- - **Built for AI agents.** `yuhwa guide` prints the language reference.
182
- `yuhwa check --json` returns diagnostics that name the fix.
183
- - **Speaks Mermaid.** Mermaid flowcharts render as-is and convert to yuhwa.
191
+ - **Speaks Mermaid.** Render supported Mermaid diagrams directly or convert
192
+ them to yuhwa source. [See which types convert](https://ph1p.github.io/yuhwa/guide/mermaid#what-converts).
193
+ - **Draws what you already have.** `yuhwa from git`, `sql`, `deps`, `class`
194
+ and `data` turn a repository, a schema, a workspace or a CSV export into a
195
+ diagram. [From real data](https://ph1p.github.io/yuhwa/guide/real-data).
184
196
  - **Small and deterministic.** TypeScript, no runtime dependencies, same
185
197
  input gives the same SVG.
186
198
 
@@ -248,11 +260,13 @@ Also: an [HTTP render service](https://ph1p.github.io/yuhwa/guide/embedding) for
248
260
  ```bash
249
261
  npx yuhwa guide # language reference, written for agents
250
262
  npx yuhwa check x.yu --json # diagnostics that name the fix
263
+ npx yuhwa render x.yu --text # a text preview the agent can read
251
264
  # pnpm: pnpm dlx yuhwa guide, pnpm dlx yuhwa check x.yu --json
252
265
  ```
253
266
 
254
- Point your agent at `yuhwa guide`, let it write source, loop on `check --json`
255
- until clean. The docs site also serves `llms.txt` and `llms-full.txt`.
267
+ Point your agent at `yuhwa guide` and have it check its draft with
268
+ `check --strict --json`. Use `render --text` to preview graphs and panels with
269
+ a text form before writing the SVG. The docs site also serves `llms.txt` and `llms-full.txt`.
256
270
  Rules-file and skill snippets: [AI guide](https://ph1p.github.io/yuhwa/guide/ai).
257
271
 
258
272
  ## Editor support
@@ -273,6 +273,118 @@ interface ConvertResult {
273
273
  declare function isMermaid(source: string): boolean;
274
274
  /** Converts Mermaid source to yuhwa: flowcharts here, every other type through `CONVERTERS`. */
275
275
  declare function fromMermaid(source: string): ConvertResult;
276
+ /** the `--format` the importer reads: short hash, parents, refs, subject */
277
+ declare const GIT_LOG_FORMAT = "%h%x09%p%x09%D%x09%s";
278
+ interface GitLogOptions {
279
+ /** panel title, default "git log" */
280
+ title?: string;
281
+ /** the trunk branch; default main, master, trunk or develop, whichever is there */
282
+ main?: string;
283
+ /** `down` (default, like `git log --graph`) or `right` */
284
+ direction?: string;
285
+ }
286
+ /** true when every non-empty line is a `GIT_LOG_FORMAT` record */
287
+ declare function isGitLog(input: string): boolean;
288
+ declare function fromGitLog(text: string, opts?: GitLogOptions): ConvertResult;
289
+ interface GitActivityOptions {
290
+ /** panel title, default "commits" */
291
+ title?: string;
292
+ /** first and last day drawn, YYYY-MM-DD; default the first and last commit */
293
+ from?: string;
294
+ to?: string;
295
+ }
296
+ /**
297
+ * Commits per day as a calendar heatmap. Reads one date per line, as
298
+ * `git log --format=%ad --date=short` prints them; other lines are skipped.
299
+ */
300
+ declare function fromGitActivity(log: string, opts?: GitActivityOptions): ConvertResult;
301
+ interface Table {
302
+ columns: string[];
303
+ rows: string[][];
304
+ }
305
+ declare const TABLE_KINDS: readonly string[];
306
+ type TableKind = "chart" | "gantt" | "kanban" | "orgchart" | "calendar" | "timeline" | "treemap" | "sankey" | "quadrant";
307
+ /** what a column means to a panel */
308
+ type Role = "id" | "label" | "value" | "start" | "end" | "duration" | "status" | "section" | "owner" | "priority" | "progress" | "manager" | "role" | "date" | "text" | "source" | "target" | "x" | "y" | "color";
309
+ declare const TABLE_ROLES: readonly Role[];
310
+ interface TableOptions {
311
+ /** the panel to draw; guessed from the columns when left out */
312
+ as?: TableKind;
313
+ title?: string;
314
+ /** chart type (bar, column, line, area, pie, donut, funnel, …) */
315
+ type?: string;
316
+ /** role → column header, for columns the names do not give away; `value` may list several, comma-separated */
317
+ columns?: Partial<Record<Role, string>>;
318
+ }
319
+ /** reads CSV, TSV, Markdown-style pipe tables or JSON (an array of objects, or an object holding one) */
320
+ declare function parseTable(text: string): Table;
321
+ /** a number as people write it: 1,234.50 · 1.234,50 € · $12k · 45% · (300) */
322
+ declare function parseNumber(raw: string): number | undefined;
323
+ /** a day as `YYYY-MM-DD`: ISO (with time), 2025/01/31, 31.01.2025, 01/31/2025 or 31/01/2025 */
324
+ declare function parseDate(raw: string): string | undefined;
325
+ /** a table (CSV, TSV, Markdown or JSON text, or a parsed `Table`) as a yuhwa panel */
326
+ declare function fromTable(input: string | Table, opts?: TableOptions): ConvertResult;
327
+ interface PackageFile {
328
+ /** where the file is, such as packages/core/package.json; shown on warnings */
329
+ path: string;
330
+ text: string;
331
+ }
332
+ interface DepsOptions {
333
+ title?: string;
334
+ /** draw dependencies from outside the workspace too (always on for one package) */
335
+ external?: boolean;
336
+ /** leave dev dependencies out */
337
+ production?: boolean;
338
+ direction?: "down" | "right";
339
+ }
340
+ /** builds yuhwa source from package.json files */
341
+ declare function fromPackages(files: PackageFile[], opts?: DepsOptions): ConvertResult;
342
+ declare function isSql(input: string): boolean;
343
+ declare function fromSql(text: string, opts?: {
344
+ title?: string;
345
+ direction?: string;
346
+ }): ConvertResult;
347
+ type FileStatus = "added" | "modified" | "deleted" | "renamed" | "ignored";
348
+ interface FilesOptions {
349
+ /** panel title, default "files" */
350
+ title?: string;
351
+ /** git status by path, as `parseGitStatus` reads it */
352
+ status?: Record<string, FileStatus>;
353
+ /** file sizes in bytes by path: adds the size column */
354
+ sizes?: Record<string, number>;
355
+ /** folders deeper than this are drawn closed, with their file count */
356
+ depth?: number;
357
+ }
358
+ /** `git status --porcelain` (v1) → status by path; untracked files count as added */
359
+ declare function parseGitStatus(porcelain: string): Record<string, FileStatus>;
360
+ /** `1536` → `1.5 KB` */
361
+ declare function formatSize(bytes: number): string;
362
+ declare function fromFiles(paths: string[], opts?: FilesOptions): ConvertResult;
363
+ /**
364
+ * A small TypeScript declaration scanner: enough of the language to list the
365
+ * top-level classes, interfaces, enums and object type aliases of a file with
366
+ * their members. Function bodies and initializers are skipped by bracket
367
+ * matching, so it needs no type checker and no `typescript` package.
368
+ *
369
+ * The lexer knows comments, strings, template literals, regular expressions
370
+ * and (in .tsx/.jsx) JSX, the places where a bracket does not count.
371
+ */
372
+ interface SourceFile {
373
+ path: string;
374
+ text: string;
375
+ }
376
+ interface TypeScriptOptions {
377
+ title?: string;
378
+ /** diagram direction, default `down` */
379
+ direction?: string;
380
+ /** only exported declarations (default false) */
381
+ exported?: boolean;
382
+ /** draw an edge for a property whose type names another declared type (default true) */
383
+ associations?: boolean;
384
+ /** one group per file; default: on when more than one file has declarations */
385
+ groups?: boolean;
386
+ }
387
+ declare function fromTypeScript(files: SourceFile[], opts?: TypeScriptOptions): ConvertResult;
276
388
  declare const NODE_PROPS: string[];
277
389
  declare const EDGE_PROPS: string[];
278
390
  declare const GROUP_PROPS: string[];
@@ -314,12 +426,13 @@ interface Result {
314
426
  layout: Layout;
315
427
  diagnostics: Diagnostic[];
316
428
  }
317
- type InputFormat = "yuhwa" | "mermaid" | "json";
429
+ type InputFormat = "yuhwa" | "mermaid" | "json" | "git" | "sql";
318
430
  /** Stable short hash, used for deterministic SVG ids. */
319
431
  declare function hash(s: string): string;
320
432
  /**
321
433
  * Normalise any accepted input to yuhwa source.
322
- * Accepts yuhwa text, a Mermaid flowchart, a JSON string or a DiagramJSON object.
434
+ * Accepts yuhwa text, a Mermaid flowchart, a JSON string or a DiagramJSON object,
435
+ * `git log --format=%h%x09%p%x09%D%x09%s` output or SQL `CREATE TABLE` statements.
323
436
  */
324
437
  declare function toSource(input: string | DiagramJSON): {
325
438
  source: string;
@@ -336,4 +449,4 @@ declare function renderText(input: string | DiagramJSON, opts?: Options & TextOp
336
449
  };
337
450
  /** Parse, lay out and render a diagram to an SVG string. Never throws on bad input. */
338
451
  declare function render(input: string | DiagramJSON, opts?: Options): Result;
339
- export { isYuhwaPath as $, embedFonts as A, setPartTone as B, MdOptions as C, replaceBlockSource as D, processMarkdown as E, addNode as F, ALIGN_SIDES as G, setSetting as H, editPart as I, JsonResult as J, GRID as K, formatLayout as L, svgToCanvas as M, Target as N, FontSource as O, addEdge as P, parse as Q, removeElement as R, MdBlock as S, findBlocks as T, writeLayout as U, setProp as V, writePanelDrag as W, renderSvg as X, fromJSON as Y, layout as Z, lint as _, render as a, ParseOptions as at, isMermaid as b, BOOLS as c, ENUMS as d, joinPath as et, GROUP_PROPS as f, PANEL_PROP_HELP as g, PANEL_PROPS as h, hash as i, SETTING_VALUES as it, loadFonts as j, RasterOptions as k, COLORS as l, NUMBERS as m, Options as n, KNOWN_SETTINGS as nt, renderText as o, NODE_PROPS as p, DiagramJSON as q, Result as r, SETTING_HELP as rt, toSource as s, InputFormat as t, PANELS as tt, EDGE_PROPS as u, ConvertResult as v, MdResult as w, MD_LANGUAGES as x, fromMermaid as y, setLabel as z };
452
+ export { MdResult as $, fromPackages as A, PANELS as At, parseTable as B, formatSize as C, JsonResult as Ct, isSql as D, parse as Dt, fromSql as E, layout as Et, TableKind as F, fromGitLog as G, GitActivityOptions as H, TableOptions as I, fromMermaid as J, isGitLog as K, fromTable as L, TABLE_KINDS as M, SETTING_HELP as Mt, TABLE_ROLES as N, SETTING_VALUES as Nt, DepsOptions as O, isYuhwaPath as Ot, Table as P, ParseOptions as Pt, MdOptions as Q, parseDate as R, FilesOptions as S, DiagramJSON as St, parseGitStatus as T, renderSvg as Tt, GitLogOptions as U, GIT_LOG_FORMAT as V, fromGitActivity as W, MD_LANGUAGES as X, isMermaid as Y, MdBlock as Z, lint as _, setSetting as _t, render as a, embedFonts as at, SourceFile as b, ALIGN_SIDES as bt, BOOLS as c, Target as ct, ENUMS as d, editPart as dt, findBlocks as et, GROUP_PROPS as f, formatLayout as ft, PANEL_PROP_HELP as g, setProp as gt, PANEL_PROPS as h, setPartTone as ht, hash as i, RasterOptions as it, Role as j, KNOWN_SETTINGS as jt, PackageFile as k, joinPath as kt, COLORS as l, addEdge as lt, NUMBERS as m, setLabel as mt, Options as n, replaceBlockSource as nt, renderText as o, loadFonts as ot, NODE_PROPS as p, removeElement as pt, ConvertResult as q, Result as r, FontSource as rt, toSource as s, svgToCanvas as st, InputFormat as t, processMarkdown as tt, EDGE_PROPS as u, addNode as ut, TypeScriptOptions as v, writeLayout as vt, fromFiles as w, fromJSON as wt, FileStatus as x, GRID as xt, fromTypeScript as y, writePanelDrag as yt, parseNumber as z };