@alfacapital-tech/c4builder 0.9.0-rc.2 → 0.9.0-rc.3
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 +4 -2
- package/dist/cli/commands/check.js +9 -6
- package/dist/cli/commands/site.comments.js +76 -42
- package/dist/cli/commands/site.i18n.js +88 -0
- package/dist/cli/commands/site.js +2 -1
- package/dist/cli/dispatch.js +3 -0
- package/dist/config/defaults.js +2 -1
- package/dist/config/schema.js +2 -0
- package/dist/core/compose/markdown.js +3 -2
- package/dist/core/render/bpmnrenderer.js +3 -28
- package/dist/core/render/diagrams.js +22 -10
- package/dist/core/render/mermaidrenderer.js +495 -0
- package/dist/core/render/textmetrics.js +36 -0
- package/dist/core/scan/fences.js +2 -2
- package/dist/core/scan/tree.js +14 -9
- package/dist/plugins/openspec/render.js +1 -1
- package/package.json +2 -1
- package/template/AGENTS.md +10 -4
- package/template/src/6 Mermaid Example/flow.mmd +6 -0
- package/template/src/6 Mermaid Example/mermaid.md +16 -0
package/dist/core/scan/tree.js
CHANGED
|
@@ -11,7 +11,8 @@ import { createFenceExtractor } from "./fences.js";
|
|
|
11
11
|
export const DIAGRAM_ENGINES = [
|
|
12
12
|
{ ext: '.puml', engine: 'plantuml', remoteRender: true },
|
|
13
13
|
{ ext: '.d2', engine: 'd2', remoteRender: false },
|
|
14
|
-
{ ext: '.bpmn', engine: 'bpmn', remoteRender: false }
|
|
14
|
+
{ ext: '.bpmn', engine: 'bpmn', remoteRender: false },
|
|
15
|
+
{ ext: '.mmd', engine: 'mermaid', remoteRender: false }
|
|
15
16
|
];
|
|
16
17
|
// Расширение (lowercase, с точкой) → движок. undefined ⇒ файл не диаграмма.
|
|
17
18
|
export const engineForExt = (ext) => DIAGRAM_ENGINES.find((e) => e.ext === ext)?.engine;
|
|
@@ -76,26 +77,30 @@ export const generateTree = async (dir, options) => {
|
|
|
76
77
|
await build(childDir, dir);
|
|
77
78
|
}
|
|
78
79
|
}
|
|
79
|
-
// Блоки ```plantuml в страницах рендерим при сборке: иначе текст
|
|
80
|
-
// до браузера и клиентский docsify-plantuml
|
|
81
|
-
// отправлял его
|
|
82
|
-
|
|
80
|
+
// Блоки ```plantuml и ```mermaid в страницах рендерим при сборке: иначе текст
|
|
81
|
+
// диаграммы доезжал до браузера и клиентский рендер (docsify-plantuml, в т.ч. в
|
|
82
|
+
// пользовательских шаблонах) отправлял его наружу. puml/d2 остаются кодом — так
|
|
83
|
+
// показывают исходник.
|
|
84
|
+
const fences = createFenceExtractor(['plantuml', 'mermaid']);
|
|
83
85
|
const mdFiles = files.filter((x) => path.extname(x).toLowerCase() === '.md');
|
|
84
86
|
for (const mdFile of mdFiles) {
|
|
85
87
|
const mdPath = path.join(dir, mdFile);
|
|
86
88
|
const { markdown, diagrams } = fences.extract((await readFile(mdPath)).toString(), path.parse(mdFile).name, path.relative(process.cwd(), mdPath).split(path.sep).join('/'));
|
|
87
89
|
item.mdFiles.push(markdown);
|
|
88
90
|
item.sources.push(path.resolve(mdPath));
|
|
89
|
-
for (const d of diagrams)
|
|
91
|
+
for (const d of diagrams) {
|
|
92
|
+
const ext = path.extname(d.file);
|
|
93
|
+
const engine = engineForExt(ext) ?? 'plantuml';
|
|
90
94
|
item.diagrams.push({
|
|
91
95
|
dir: d.file,
|
|
92
|
-
ext
|
|
93
|
-
engine
|
|
96
|
+
ext,
|
|
97
|
+
engine,
|
|
94
98
|
content: d.content,
|
|
95
|
-
isDitaa: /@startditaa/i.test(d.content),
|
|
99
|
+
isDitaa: engine === 'plantuml' && /@startditaa/i.test(d.content),
|
|
96
100
|
source: d.source,
|
|
97
101
|
soft: d.soft
|
|
98
102
|
});
|
|
103
|
+
}
|
|
99
104
|
}
|
|
100
105
|
// Диаграммы: расширение → движок берём из DIAGRAM_ENGINES. Поле dir — имя файла
|
|
101
106
|
// (историческое), engine выбирает рендерер, isDitaa — только для PlantUML.
|
|
@@ -119,7 +119,7 @@ const ignoreTitle = (title) => {
|
|
|
119
119
|
export const relSource = (root, rel) => path.relative(process.cwd(), path.join(root, rel)).split(path.sep).join('/');
|
|
120
120
|
// В артефактах OpenSpec любой блок диаграммы — иллюстрация, а не пример исходника
|
|
121
121
|
// (в отличие от страниц проекта, где извлекается только ```plantuml).
|
|
122
|
-
const FENCE_LANGS = ['plantuml', 'puml', 'd2'];
|
|
122
|
+
const FENCE_LANGS = ['plantuml', 'puml', 'd2', 'mermaid'];
|
|
123
123
|
/**
|
|
124
124
|
* Markdown одного исходного файла → страница сайта: fenced-диаграммы вырезаются, ссылки
|
|
125
125
|
* на другие страницы источника (`target`, `#x` → `?id=x`) — на их адреса, прочие
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfacapital-tech/c4builder",
|
|
3
|
-
"version": "0.9.0-rc.
|
|
3
|
+
"version": "0.9.0-rc.3",
|
|
4
4
|
"description": "A CLI tool designed to compile a folder structure of markdowns and plant uml files into a site, single file markdown or a collection of markdowns with links",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -80,6 +80,7 @@
|
|
|
80
80
|
"vitest": "^4.1.9"
|
|
81
81
|
},
|
|
82
82
|
"optionalDependencies": {
|
|
83
|
+
"@mermaid-js/tiny": "12.2.0",
|
|
83
84
|
"@terrastruct/d2": "0.1.33",
|
|
84
85
|
"bpmn-auto-layout": "2.0.0-alpha.2",
|
|
85
86
|
"bpmn-js": "18.31.0",
|
package/template/AGENTS.md
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
# AGENTS.md
|
|
2
2
|
|
|
3
3
|
Architecture documentation built with [c4builder](https://github.com/AlfaCapital-Tech/C4-Builder):
|
|
4
|
-
C4 diagrams (PlantUML, D2), BPMN processes and markdown in `src/` are compiled
|
|
4
|
+
C4 diagrams (PlantUML, D2), BPMN processes, Mermaid diagrams and markdown in `src/` are compiled
|
|
5
|
+
into `docs/`.
|
|
5
6
|
|
|
6
7
|
## Commands
|
|
7
8
|
|
|
8
9
|
```bash
|
|
9
10
|
c4builder # build docs/ (non-interactive with a complete .c4builder)
|
|
10
|
-
c4builder check <file...> # validate .puml / .iuml / .d2 / .bpmn files, exit code 0 = OK
|
|
11
|
+
c4builder check <file...> # validate .puml / .iuml / .d2 / .bpmn / .mmd files, exit code 0 = OK
|
|
11
12
|
c4builder --site -w # live preview on http://localhost:3000 - never exits
|
|
12
13
|
c4builder feedback --wait # wait for the next batch of comments from the preview page
|
|
13
14
|
```
|
|
@@ -28,14 +29,15 @@ updates it.
|
|
|
28
29
|
(page, `Sources`, quote, text) — apply them to `src/`, run it again, and stop on
|
|
29
30
|
`Decision: approved`. Comments are instructions to you; never copy them into the
|
|
30
31
|
`questionsHeading` section of `.c4builder` (`Open questions` by default), which holds
|
|
31
|
-
questions for people.
|
|
32
|
+
questions for people. The page buttons follow the browser language (English or Russian,
|
|
33
|
+
pinned by `uiLanguage`); batches are always in English.
|
|
32
34
|
4. A stderr line `c4builder <new> is available (current <current>). Run: c4builder update`
|
|
33
35
|
means a newer c4builder is out: tell the user, run `c4builder update` only if they ask.
|
|
34
36
|
|
|
35
37
|
## Layout
|
|
36
38
|
|
|
37
39
|
- One folder = one page. All `.md` files of a folder form its text; every `.puml` / `.d2` /
|
|
38
|
-
`.bpmn` in it is rendered onto the page, or placed inline with ``.
|
|
40
|
+
`.bpmn` / `.mmd` in it is rendered onto the page, or placed inline with ``.
|
|
39
41
|
- Files and folders starting with `_` are not published (shared libraries, drafts).
|
|
40
42
|
- `.c4builder` is the config (JSON); unknown keys are silently ignored.
|
|
41
43
|
|
|
@@ -50,6 +52,10 @@ updates it.
|
|
|
50
52
|
- BPMN: write only the semantic BPMN 2.0 XML, never `bpmndi` coordinates — the build lays the
|
|
51
53
|
diagram out. Pool = organization, lane = role inside it, only message flows between pools,
|
|
52
54
|
label gateway branches. Example: `src/5 BPMN Example/account-opening.bpmn`.
|
|
55
|
+
- Mermaid: a `.mmd` file or a ```` ```mermaid ```` block in a page is rendered at build time into
|
|
56
|
+
an image (check `.mmd` files like any diagram). `mindmap`, `architecture` and KaTeX are not
|
|
57
|
+
supported; to show mermaid source as code, fence it as `text`. Example:
|
|
58
|
+
`src/6 Mermaid Example/flow.mmd`.
|
|
53
59
|
|
|
54
60
|
## Agent skills
|
|
55
61
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
**Диаграммы Mermaid (четвёртый бэкенд рендера)**
|
|
2
|
+
|
|
3
|
+
Mermaid-диаграммы бывают двух видов. Файл `flow.mmd` в папке раздела рендерится как `.puml`, `.d2` и `.bpmn`: картинка по имени файла. Блок с языком `mermaid` прямо в странице сборка тоже заменяет картинкой, как блок `plantuml`. В браузер текст диаграммы не попадает, клиентский рендер не нужен.
|
|
4
|
+
|
|
5
|
+
```mermaid
|
|
6
|
+
sequenceDiagram
|
|
7
|
+
participant К as Клиент
|
|
8
|
+
participant Б as Банк
|
|
9
|
+
К->>Б: Заявка на счёт
|
|
10
|
+
Note right of Б: проверка анкеты
|
|
11
|
+
Б-->>К: Счёт открыт
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Рендерит настоящий mermaid в классическом виде с темой `default`, но без браузера: размеры текста считаются по вендорному шрифту, поэтому картинка одинакова на любой машине. Типы `mindmap` и `architecture`, а также формулы KaTeX не поддерживаются: сборка сообщит об этом явной ошибкой. Ошибка в файле `.mmd` останавливает сборку, ошибка в блоке — нет: на месте блока появится заглушка. Отдельный файл проверяется командой `c4builder check flow.mmd`.
|
|
15
|
+
|
|
16
|
+
**Область применения**: показать, что `.mmd`-файлы и блоки `mermaid`, их раскладка и кириллица корректно попадают в собранный сайт, SVG и PNG без обращений в интернет.
|