concept-atlas-dense-explain 4.1.1 → 4.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 +16 -13
- package/bin/cli.mjs +2 -2
- package/package.json +1 -1
- package/packaged-skill/SKILL.md +50 -50
- package/packaged-skill/references/authoring.md +59 -0
- package/packaged-skill/references/cli.md +77 -0
- package/packaged-skill/references/components.md +144 -12
- package/packaged-skill/references/diagnostics.md +44 -4
- package/template/src/components/MDXComponents.jsx +9 -5
- package/template/src/model/normalize-content.js +3 -3
- package/template/src/model/validate-content.js +13 -2
- package/template/src/styles/core.css +7 -0
- package/template/vite.config.js +14 -5
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ Two page shells share one component library:
|
|
|
12
12
|
## CLI
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
#
|
|
15
|
+
# Optional: learn from a compilable reference; also overwrites assets/ beside the output
|
|
16
16
|
npx concept-atlas-dense-explain guide --mode atlas -o atlas-guide.mdx
|
|
17
17
|
npx concept-atlas-dense-explain guide --mode scroll -o scroll-guide.mdx
|
|
18
18
|
|
|
@@ -26,24 +26,27 @@ npx concept-atlas-dense-explain validate topic.mdx --mode atlas
|
|
|
26
26
|
npx concept-atlas-dense-explain topic.mdx --mode atlas
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
-
Existing outputs are overwritten
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
29
|
+
Existing outputs are overwritten, and `guide` also overwrites `assets/` beside
|
|
30
|
+
its output. `--force` is accepted for compatibility and is a no-op. `create` and
|
|
31
|
+
`guide` default to `scroll`; validation and builds detect the MDX shell when
|
|
32
|
+
`--mode` is omitted. Use `-o` to choose the output path (a directory when passing
|
|
33
|
+
several inputs). Validation errors abort the build; `--no-validate` forces a
|
|
34
|
+
knowingly broken build.
|
|
35
|
+
|
|
36
|
+
Mermaid-syntax diagrams are rendered by Pele, which ships inline: diagrams need
|
|
37
|
+
no chart CDN, and a document without `<Mermaid>` drops the renderer entirely.
|
|
38
|
+
Fonts may still load from Google Fonts and fall back to system fonts offline.
|
|
39
|
+
Appearance defaults can be baked with `--skin`, `--default-mode` and `--style`;
|
|
40
|
+
readers can still switch in the UI. Local figures link by default (small HTML,
|
|
41
|
+
ship `assets/` beside the output); `--inline-assets` bakes them in as base64 for
|
|
42
|
+
a self-contained file, and a per-figure `inline={true|false}` overrides that choice.
|
|
41
43
|
|
|
42
44
|
Run `npx concept-atlas-dense-explain help` for the full flag list.
|
|
43
45
|
|
|
44
46
|
## Links
|
|
45
47
|
|
|
46
48
|
- Repository: https://github.com/wurenrumian/concept-atlas
|
|
49
|
+
- Documentation index: [`docs/README.md`](https://github.com/wurenrumian/concept-atlas/blob/master/docs/README.md)
|
|
47
50
|
- Framework guide: [`docs/FRAMEWORK.md`](https://github.com/wurenrumian/concept-atlas/blob/master/docs/FRAMEWORK.md)
|
|
48
51
|
- Usage recipes: [`docs/USAGE.md`](https://github.com/wurenrumian/concept-atlas/blob/master/docs/USAGE.md)
|
|
49
52
|
|
package/bin/cli.mjs
CHANGED
|
@@ -45,7 +45,7 @@ function usage() {
|
|
|
45
45
|
console.log(' npx concept-atlas-dense-explain guide [--mode atlas|scroll] [-o output.mdx]');
|
|
46
46
|
console.log('');
|
|
47
47
|
console.log(
|
|
48
|
-
'
|
|
48
|
+
' create/guide default to scroll; validate/build detect the MDX shell when --mode is omitted. Existing outputs are overwritten; guide also overwrites assets/ beside its output. --force is a compatibility no-op.'
|
|
49
49
|
);
|
|
50
50
|
console.log(' --help shows this text; --version prints the package version.');
|
|
51
51
|
console.log(
|
|
@@ -55,7 +55,7 @@ function usage() {
|
|
|
55
55
|
' Figures are kept as relative links by default (small HTML; ship the assets/ dir beside it). --inline-assets bakes every local image into the HTML as base64 instead; a per-tag inline={true|false} on <Figure> overrides that for one image. --link-assets is kept as an explicit alias for the default.'
|
|
56
56
|
);
|
|
57
57
|
console.log(
|
|
58
|
-
' Mermaid-syntax diagrams (<Mermaid>) are rendered by Pele and ship inline, so
|
|
58
|
+
' Mermaid-syntax diagrams (<Mermaid>) are rendered by Pele and ship inline, so diagrams need no chart CDN. A document without <Mermaid> drops the renderer entirely. Fonts may load remotely and local images stay linked unless inlined.'
|
|
59
59
|
);
|
|
60
60
|
console.log(
|
|
61
61
|
` --skin bakes a default palette (${SKINS.map(skin => skin.id).join(', ')}); --default-mode bakes a default dark/light mode; --style bakes a default component style (${COMPONENT_STYLES.map(style => style.id).join(', ')}). Readers can still switch in the UI.`
|
package/package.json
CHANGED
package/packaged-skill/SKILL.md
CHANGED
|
@@ -1,74 +1,74 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: concept-atlas-dense-explain
|
|
3
|
-
description:
|
|
3
|
+
description: Build a dense, interactive Concept Atlas page from a topic or source document — semantic MDX compiled to standalone HTML, with concept graphs, math, charts, figures, and citations. Use it when someone wants material turned into an interactive HTML/MDX explainer, tutorial, technical deep-dive, report, concept/knowledge map, or teaching page, including "turn this doc into a page" or "explain this properly as a page"; also 讲解 / 深度长文 / 教程 / 技术文档 / 报告 / 概念图 / 知识地图 / 分层讲解. Not for a short chat answer, summary-only work, a slide deck, or a Word/PDF-only deliverable.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Concept Atlas Dense Explain
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Turn a topic or source document into semantic MDX and compile it with the `concept-atlas-dense-explain` CLI. Everything needed is in this file and the bundled `references/`; do not read the framework repository or installed package files, copy implementation files from the skill directory, or recreate the React/Vite app.
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
If the user only wants the methodology or MDX text, still choose one shell and emit valid MDX. CLI validation and compilation are needed only when producing files.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
## Operating rules
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
- Use the CLI only through `npx`. Do not search for another runner or run the framework repository's own scripts.
|
|
15
|
+
- Use exactly one page shell per file. Keep MDX semantic: no CSS, SVG, custom React, or invented component APIs. Use free-position coordinates only when the user explicitly asks for manual layout.
|
|
16
|
+
- Preserve source claims, citations, counterexamples, and uncertainty. Never invent evidence, measurements, references, or examples to make a page look complete.
|
|
17
|
+
- Protect user files. `create`, `guide`, and compiled outputs overwrite their targets; `guide` also overwrites `assets/` beside its output. Choose a new path or ask before overwriting existing work.
|
|
18
|
+
- Load references by task instead of reading everything: component API, authoring, CLI details, and diagnostics are separate files.
|
|
19
19
|
|
|
20
20
|
## Workflow
|
|
21
21
|
|
|
22
|
-
1.
|
|
23
|
-
2. **
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
5. Validate before rendering:
|
|
22
|
+
1. **Establish the deliverable.** Identify the source material, audience, desired output path, and whether the user wants MDX only or compiled HTML. Ask only when a choice is ambiguous or would overwrite user work.
|
|
23
|
+
2. **Choose the shell.** Use the decision table below. If an `.mdx` file already exists, detect its shell and keep it unless conversion is requested.
|
|
24
|
+
3. **Learn the API before writing tags.** Read `references/components.md` and search it by component name. Unknown props are silently ignored, so do not guess. Use the matching bundled guide as a compilable example: `references/atlas-guide.mdx` or `references/scroll-guide.mdx`.
|
|
25
|
+
4. **Draft the semantic MDX.** Start from `create` when useful, then apply the authoring contract below. Read `references/authoring.md` for document conversion, source-to-component mapping, density checks, and stopping conditions.
|
|
26
|
+
5. **Validate before rendering.**
|
|
28
27
|
```bash
|
|
29
28
|
npx concept-atlas-dense-explain validate <file>.mdx --mode atlas|scroll
|
|
30
|
-
npx concept-atlas-dense-explain validate <file>.mdx --json
|
|
29
|
+
npx concept-atlas-dense-explain validate <file>.mdx --mode atlas|scroll --json
|
|
31
30
|
```
|
|
32
|
-
|
|
33
|
-
6. Compile
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
- `atlas`: `ExplainPage` → `ConceptGraph` → `ConceptNode`, plus `Children`/`ConceptRef` and cross-branch `Relation`s. Exactly one `L0` root, several `L1` branches, depth to `L3`/`L4`. Shared components live inside nodes. `ConceptNode` also takes an optional `kind` (see Authoring rules) that labels a node's knowledge role independently of its level.
|
|
41
|
-
- `scroll`: `ScrollDocument` → `ScrollHeader` + `ScrollSection` (+ `ScrollProse`, `ScrollGrid`). Shared components live inside sections. The shell auto-builds a table of contents and reading progress from section titles — do not hand-build navigation.
|
|
42
|
-
- The browser tab comes from the shell, not the build flags: `ExplainPage title` (atlas) or `ScrollHeader title` (scroll) becomes the `<title>`, so give it a real, specific name — never a placeholder like "主题名称". Every page uses a fixed 📃 favicon.
|
|
43
|
-
- Never make one MDX file both shells. When switching shells, convert only the outer structure.
|
|
31
|
+
Fix every error and re-run. Address warnings when cheap; use `--strict` when the user wants a clean structural contract. See `references/diagnostics.md` for causes and fixes.
|
|
32
|
+
6. **Compile.** Read `references/cli.md` for output, appearance, batching, and asset flags.
|
|
33
|
+
```bash
|
|
34
|
+
npx concept-atlas-dense-explain <file>.mdx --mode atlas|scroll [-o out.html]
|
|
35
|
+
```
|
|
36
|
+
Validation errors block the build. Use `--no-validate` only with an explicit reason.
|
|
37
|
+
7. **Verify the result.** Confirm the HTML exists. When a browser tool is available, open it and check the title, shell navigation, and every diagram, chart, figure, tab, or citation you added. Fix blank widgets or broken interactions; otherwise state what remains unverified.
|
|
38
|
+
8. **Report the outcome.** Name the shell, MDX and HTML paths, validation result, restructured/merged/dropped source material, and limitations that actually apply. Diagrams need no chart CDN, but fonts may load remotely and local images remain linked unless inlined. Do not claim interactions you did not verify.
|
|
44
39
|
|
|
45
|
-
##
|
|
40
|
+
## Shell decision
|
|
46
41
|
|
|
47
|
-
|
|
42
|
+
| Reader task | Shell | Structure |
|
|
43
|
+
| --- | --- | --- |
|
|
44
|
+
| Explore concepts, compare branches, follow relations | `atlas` | `ExplainPage` → `ConceptGraph` → `ConceptNode`, with `Children` / `ConceptRef` and cross-branch `Relation` |
|
|
45
|
+
| Read an argument, tutorial, procedure, or report in order | `scroll` | `ScrollDocument` → `ScrollHeader` + `ScrollSection`, with shared content components inside sections |
|
|
46
|
+
| Existing MDX | Detect and keep | Convert only the outer shell when requested; never combine both shells |
|
|
48
47
|
|
|
49
|
-
|
|
48
|
+
For `atlas`, keep exactly one `L0` root and use `L1`–`L4` for progressively finer detail. For `scroll`, the shell builds the table of contents and reading progress from section titles; do not hand-build navigation. Give `ExplainPage title` or `ScrollHeader title` a real static string because it becomes the browser tab title.
|
|
50
49
|
|
|
51
|
-
|
|
52
|
-
- Give each important node a claim-like title, a one-sentence `summary`, and real substance (`Definition`, `Mechanism`, `Example`, `Boundary`, `Evidence`, a model, a chart, or math). Do not restate the same text across `Overview`, `Definition`, and `Insight`.
|
|
53
|
-
- **`kind` (optional, atlas)**: tag a node's knowledge role independently of `level`. One of `system`, `stage`, `mechanism`, `artifact`, `failure`, `tool`, `boundary`, `decision`. It powers the graph's "知识类型" filter and a node badge, so use it where the role is clear rather than on every node. Two opt-in contracts fire once you declare one: `kind="mechanism"` should contain an `Invariant` or `Evidence`, and `kind="failure"` should contain a `FailureMode` (with `symptom`/`cause`/`evidence`/`remedy`).
|
|
54
|
-
- Array props are arrays of objects: `Flow steps={[{title, description}]}`, `Timeline events={[{label, content}]}`, `MatrixModel cells={[{title, description, tone}]}`, `DecisionMatrix headers={[...]} rows={[[...]]}`, `Chart data={[{label, value}]}`, `References items={[{id, authors, year, title, url, source}]}`. The validator warns (`PROP_EXPECTS_ARRAY`) when an array prop gets a string or non-array.
|
|
55
|
-
- `Relation type` must be one of `prerequisite`, `causes`, `produces`, `uses`, `implements`, `contrasts`, `depends-on`, `exception-of`, `precedes`, and each `Relation` needs a `label`. Parent/child hierarchy is implicit (via `parent` and `Children`/`ConceptRef`) — do not express it with a `Relation`.
|
|
56
|
-
- **Math**: MDX parses `{ ... }` in children as expressions, so pass LaTeX with braces or backslashes through `formula`: `<Math formula="r_{\text{ann}} = (1 + r)^{12} - 1" />`, `<MathBlock formula="I(x) = -\log_2 p(x)" variables={[{symbol, description}]} />`. Brace-free children such as `<Math>\log_2 N</Math>` are fine. The validator warns (`MATH_CHILDREN_BRACES`).
|
|
57
|
-
- **Code**: pass code as a string via `code` (or as children) wrapped in a template literal, so MDX does not read it as expressions: `<CodeBlock language="bash" lineNumbers>{`npm run validate`}</CodeBlock>`. Badges, captions and wrapping are documented in `references/components.md`.
|
|
58
|
-
- **Figures**: always set `alt`; number with an `id` plus `<FigureRef>`, never hand-write "图 N"; relative links versus `--inline-assets` is a size trade-off — decide it with the user instead of choosing silently.
|
|
59
|
-
- **Cite/References**: `<Cite id="..." />` renders `[n]` from the matching item's position in `<References items={...} />`. In `atlas`, keep the cites and the `References` block in the same node, because node content only renders when that node is open.
|
|
60
|
-
- Continuous reading is configured on the shell, not with manual CSS: `spacing="compact|comfortable|airy"` for rhythm, `fontSize="compact|normal|large|xlarge"` (or numeric `scale`/`lineHeight`) for text size.
|
|
50
|
+
## Authoring contract
|
|
61
51
|
|
|
62
|
-
|
|
52
|
+
- Give each important concept a claim-like title, a one-sentence summary where the shell supports it, and substance that adds new information. Merge stubs instead of padding them.
|
|
53
|
+
- Density means information gain, not quotas. Cover what the concept is, why/how it works, evidence or an example when available, and a boundary or trade-off when relevant; stop when the reader's question is answered.
|
|
54
|
+
- Use `kind` only when an atlas node's knowledge role is clear. A `mechanism` should carry an `Invariant` or `Evidence`; a `failure` should carry a structured `FailureMode`.
|
|
55
|
+
- Use relation types for cross-branch meaning, never for parent-child hierarchy. Every `Relation` needs a meaningful `label`.
|
|
56
|
+
- Check array shapes in `components.md`. Pass LaTeX and code through the documented string/template-literal forms so MDX does not parse them as expressions.
|
|
57
|
+
- Always set figure `alt`; use `id` + `FigureRef` for automatic numbering. In `atlas`, keep `Cite` and `References` in the same node.
|
|
58
|
+
- Configure reading rhythm and text size on the shell, not with manual CSS.
|
|
63
59
|
|
|
64
|
-
|
|
60
|
+
## Reference router
|
|
65
61
|
|
|
66
|
-
|
|
62
|
+
| Need | Read |
|
|
63
|
+
| --- | --- |
|
|
64
|
+
| Component props, defaults, array shapes, aliases, traps | `references/components.md` |
|
|
65
|
+
| Document conversion, source fidelity, density, stopping conditions | `references/authoring.md` |
|
|
66
|
+
| Commands, flags, appearance, batching, assets, version mismatch | `references/cli.md` |
|
|
67
|
+
| Diagnostic meaning and repair action | `references/diagnostics.md` |
|
|
68
|
+
| Compilable composition examples | `references/atlas-guide.mdx` or `references/scroll-guide.mdx` |
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
- All `ConceptRef`, `Relation` endpoints, and `ConceptGraph root` point at existing node ids.
|
|
70
|
-
- Every node has `title` + `summary`; every `Relation` has a `label`.
|
|
71
|
-
- Pages with `<Mermaid>` are already fully offline: Pele ships inline, so you never need a CDN flag.
|
|
72
|
-
- The HTML file exists at the reported path.
|
|
70
|
+
## Failure recovery
|
|
73
71
|
|
|
74
|
-
If `npx` cannot reach the registry, report the blocker
|
|
72
|
+
- If `npx` cannot reach the registry, report the blocker; do not switch to a repository build or copy implementation files.
|
|
73
|
+
- If the CLI rejects a component that the current skill documents, check `--version` and report a likely skill/CLI version mismatch rather than inventing a workaround.
|
|
74
|
+
- If validation still fails after the documented fix, report the remaining diagnostic and the file location instead of using `--no-validate` silently.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Authoring and document conversion
|
|
2
|
+
|
|
3
|
+
Use this reference when turning source material into a page, or when deciding whether a draft is complete. Component APIs live in `components.md`; this file governs structure, fidelity, and stopping conditions.
|
|
4
|
+
|
|
5
|
+
## Choose the shell from the reading task
|
|
6
|
+
|
|
7
|
+
- Choose `atlas` when readers need to compare concepts, follow cross-branch relations, or explore details out of order.
|
|
8
|
+
- Choose `scroll` when the source's argument must be read in order: tutorials, reports, procedures, and long-form explanations.
|
|
9
|
+
- If an `.mdx` file already exists, detect and keep its shell unless the user asks to convert it. Never make one file both shells.
|
|
10
|
+
|
|
11
|
+
## Turn a document into a page
|
|
12
|
+
|
|
13
|
+
Restructure the source; do not paste it into one node or section. Map the source's own outline first, then convert each unit into one claim with its supporting material.
|
|
14
|
+
|
|
15
|
+
| Source material | Preferred expression |
|
|
16
|
+
| --- | --- |
|
|
17
|
+
| Chapter or major heading | One `ScrollSection`, or one named concept node in `atlas` |
|
|
18
|
+
| Neutral table or raw observations | `DataTable` |
|
|
19
|
+
| Options compared against criteria | `DecisionMatrix` or `Tradeoff` |
|
|
20
|
+
| Two-dimensional positioning | `MatrixModel` |
|
|
21
|
+
| Ordered process | `Flow` or `WorkedExample` + `Step` |
|
|
22
|
+
| Dated sequence | `Timeline` |
|
|
23
|
+
| Before/after or alternative designs | `Compare` or `CodeDiff` |
|
|
24
|
+
| Headline number | `Metric` |
|
|
25
|
+
| Repeated definition or prose | One `Definition` plus its evidence; merge duplicates |
|
|
26
|
+
| Citation or source claim | `Cite` + `References`, and `Source` where provenance matters |
|
|
27
|
+
|
|
28
|
+
Preserve the source's citations, qualifications, counterexamples, and uncertainty. Do not invent evidence, citations, measurements, or examples to make the page look complete. If the source leaves a material gap, say so in the page or report it to the user.
|
|
29
|
+
|
|
30
|
+
Finish with a short mapping report: what was restructured, merged, dropped, or left unresolved. This lets the user check that the conversion did not silently change the argument.
|
|
31
|
+
|
|
32
|
+
## Density means information gain, not quotas
|
|
33
|
+
|
|
34
|
+
A branch that only restates its title is a stub. A block that repeats the previous block in different styling is also a stub. Fix both by adding new information or merging the unit.
|
|
35
|
+
|
|
36
|
+
For each important concept, ask:
|
|
37
|
+
|
|
38
|
+
1. **What is it?** Give a precise definition or mental model.
|
|
39
|
+
2. **Why or how does it work?** Explain the mechanism, cause, or decision rule.
|
|
40
|
+
3. **What supports it?** Add evidence, a worked example, data, or a citation when available.
|
|
41
|
+
4. **Where does it stop?** State a boundary, failure mode, trade-off, or counterexample when relevant.
|
|
42
|
+
|
|
43
|
+
These are coverage questions, not required block counts. A simple concept may need only a definition and an example; a complex mechanism may need several models and a failure analysis. Stop when the reader can answer the concept's key question and check the important claims. Never split prose or fabricate substance merely to hit a number.
|
|
44
|
+
|
|
45
|
+
In `scroll`, one section should make one claim plus its evidence. Split a section when it changes subject or develops a second independent claim, not because it crosses an arbitrary screen count.
|
|
46
|
+
|
|
47
|
+
## Component selection follows the relationship
|
|
48
|
+
|
|
49
|
+
Use the component whose data shape matches the information, not the one with the most decorative treatment. A `Flow` expresses order; `Timeline` adds time; `StateMachine` adds states and transitions; `DecisionTree` adds conditions; `FeedbackLoop` adds feedback polarity. If two components would show the same text, keep one.
|
|
50
|
+
|
|
51
|
+
## Final content check
|
|
52
|
+
|
|
53
|
+
Before compiling, verify:
|
|
54
|
+
|
|
55
|
+
- Every important unit has a claim-like title and non-duplicated substance.
|
|
56
|
+
- Every node has `title` and `summary`; every relation has a meaningful `label`.
|
|
57
|
+
- All ids, parents, refs, relation endpoints, figures, and citations resolve.
|
|
58
|
+
- Source claims remain traceable, and uncertainty has not been silently upgraded into certainty.
|
|
59
|
+
- The page answers the user's actual reading task rather than merely displaying many components.
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# CLI reference
|
|
2
|
+
|
|
3
|
+
Use this reference when scaffolding, validating, compiling, batching, or configuring appearance. The main workflow is in `SKILL.md`.
|
|
4
|
+
|
|
5
|
+
## Runner
|
|
6
|
+
|
|
7
|
+
Always invoke the CLI through `npx`, from any directory:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx concept-atlas-dense-explain <args>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
This is the only runner. Do not search for a local binary, repository checkout, or installed copy, and do not run the framework repository's own `npm` scripts. The first call may download the package from npm; say so once, then continue. Use `npx concept-atlas-dense-explain help` when a flag is unclear and `--version` when diagnosing a version mismatch.
|
|
14
|
+
|
|
15
|
+
## Core commands
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Optional skeleton; defaults to scroll and overwrites the target.
|
|
19
|
+
npx concept-atlas-dense-explain create <file>.mdx --mode atlas|scroll
|
|
20
|
+
|
|
21
|
+
# Validate before rendering.
|
|
22
|
+
npx concept-atlas-dense-explain validate <file>.mdx --mode atlas|scroll
|
|
23
|
+
npx concept-atlas-dense-explain validate <file>.mdx --mode atlas|scroll --json
|
|
24
|
+
|
|
25
|
+
# Compile; detects the MDX shell when --mode is omitted and writes beside the MDX unless -o is given.
|
|
26
|
+
npx concept-atlas-dense-explain <file>.mdx --mode atlas|scroll [-o out.html]
|
|
27
|
+
|
|
28
|
+
# Build several documents; -o becomes a directory.
|
|
29
|
+
npx concept-atlas-dense-explain a.mdx b.mdx c.mdx -o dist [--concurrency 3]
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`create`, `guide`, and compiled HTML outputs overwrite existing files. `guide` also copies its sample resources into `assets/` beside the output and overwrites matching files. Do not point it at a path containing user work unless overwriting is intended; choose a new path or ask first.
|
|
33
|
+
|
|
34
|
+
`guide` is only needed when the user wants a project-local, compilable copy of the bundled example. The installed skill already contains `references/atlas-guide.mdx` and `references/scroll-guide.mdx`; do not generate another copy just to learn the components.
|
|
35
|
+
|
|
36
|
+
## Flags
|
|
37
|
+
|
|
38
|
+
| Flag | Meaning |
|
|
39
|
+
| --- | --- |
|
|
40
|
+
| `--mode atlas\|scroll` | Selects the page shell. `create` / `guide` default to `scroll`; validation and builds detect the shell when omitted. Keep it consistent across commands when specified. |
|
|
41
|
+
| `-o <path>` | Output HTML file, or output directory for multiple inputs. |
|
|
42
|
+
| `--strict` | Promotes structural warnings to validation errors. |
|
|
43
|
+
| `--json` | Machine-readable validation output. |
|
|
44
|
+
| `--no-validate` | Skips validation and knowingly allows a broken build. Use only with an explicit reason. |
|
|
45
|
+
| `--inline-assets` | Inlines every local image as base64. |
|
|
46
|
+
| `--link-assets` | Explicit alias for the default linked-image behavior; mutually exclusive with `--inline-assets`. |
|
|
47
|
+
| `--concurrency <N>` | Parallel build limit for multiple inputs; default 2, capped at 4. |
|
|
48
|
+
| `--skin <id>` | Bakes a default palette. |
|
|
49
|
+
| `--default-mode dark\|light\|system` | Bakes a default color mode. |
|
|
50
|
+
| `--style <id>` | Bakes a default component style. |
|
|
51
|
+
| `--force` | Compatibility no-op; outputs are overwritten anyway. |
|
|
52
|
+
|
|
53
|
+
## Appearance
|
|
54
|
+
|
|
55
|
+
Pages ship a reader-facing appearance menu: palette (`aurora` indigo, `ember` gold, `verdant` forest, `sakura` pink-plum, `noir` ink), dark/light mode, and component style (`manuscript` editorial marginalia, `classic` boxed cards, `shadcn` hairline-bordered minimal UI, `elastic` bordered observability panels). The shipped default is aurora × manuscript × light, and choices persist in localStorage.
|
|
56
|
+
|
|
57
|
+
Bake different defaults only when the user asks:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npx concept-atlas-dense-explain article.mdx --mode scroll \
|
|
61
|
+
--skin ember --default-mode dark --style classic
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
`--default-mode system` resolves to the carrier default (`light`). Content MDX never sets appearance.
|
|
65
|
+
|
|
66
|
+
## Assets and offline behavior
|
|
67
|
+
|
|
68
|
+
- `<Mermaid>` diagrams are rendered by Pele and inlined, so diagrams need no chart CDN. A page without `<Mermaid>` drops the renderer entirely.
|
|
69
|
+
- Fonts may load from Google Fonts at runtime and fall back to the system stack offline.
|
|
70
|
+
- Local images stay relative links by default. Ship the `assets/` directory beside the HTML, or use `--inline-assets`.
|
|
71
|
+
- A per-figure `inline={true}` / `inline={false}` overrides the global flag for one image.
|
|
72
|
+
- Remote images remain links and require network access.
|
|
73
|
+
- Never add dummy `<Math>` or `<Mermaid>` nodes to enable a renderer; builds include only what the content uses.
|
|
74
|
+
|
|
75
|
+
## Version mismatch
|
|
76
|
+
|
|
77
|
+
The skill documentation and the npm `latest` CLI are released separately. If a documented component is rejected as `UNKNOWN_COMPONENT` after `npx` has fetched `latest`, report the likely version mismatch and the versions involved. Do not copy package implementation files into the skill, invent a replacement API, or silently downgrade the page.
|
|
@@ -1,26 +1,158 @@
|
|
|
1
1
|
# Component and prop reference
|
|
2
2
|
|
|
3
|
-
Search this file by component name before writing a tag the page has not used yet.
|
|
3
|
+
Search this file by component name before writing a tag the page has not used yet. The tables below describe the **effective MDX author API**: renderer props plus fields consumed by the atlas semantic model. Reserved/no-op compatibility props are marked explicitly. Defaults that affect output are included. Array props default to `[]` unless stated otherwise; widget props default to `width="auto"`, `height="auto"`, `x={0}`, `y={0}`, and `position="flow"`.
|
|
4
|
+
|
|
5
|
+
A component missing from the tables does not exist (`UNKNOWN_COMPONENT`). An unknown *prop* is silently ignored — the validator only reports array-shaped props that receive a non-array (`PROP_EXPECTS_ARRAY`) — so check the table instead of guessing. `children` is listed only where the component actually renders it or uses it as a fallback.
|
|
6
|
+
|
|
7
|
+
The rules that hold for every page — semantic MDX, `kind` contracts, relation types, math braces, figure numbering, cite scoping — are in `SKILL.md`; this file adds the per-component detail.
|
|
4
8
|
|
|
5
9
|
## Families
|
|
6
10
|
|
|
11
|
+
- Shell and structure: `ExplainPage`, `ConceptGraph`, `ConceptNode`, `ConceptRef`, `Children`, `Relation`, `ScrollDocument`, `ScrollHeader`, `ScrollSection`, `ScrollProse`, `ScrollPair`, `ScrollGrid`, `ScrollToc`, `Columns`, `Stack`, `Grid`, `Split`
|
|
7
12
|
- Node semantics: `Overview`, `Definition`, `Mechanism`, `Implementation`, `CodeBlock`, `Boundary`, `Example`, `Counterexample`, `Prerequisite`, `Input`, `Output`, `Glossary`
|
|
8
13
|
- Argument and evidence: `Evidence`, `Invariant`, `FailureMode`, `Tradeoff`, `Checklist`, `LearningObjectives`, `KeyQuestion`
|
|
9
14
|
- Learning loop and provenance: `WorkedExample` + `Step`, `Quiz`, `KeyTakeaways`, `Source`, `Confidence`, `LastReviewed`, `Term`
|
|
10
15
|
- Information models: `Flow`, `Timeline`, `Compare`, `DecisionMatrix`, `FrameworkModel`, `MatrixModel`, `FormulaModel`, `PyramidModel`, `FunnelModel`
|
|
11
16
|
- Data and behaviour: `DataTable`, `Metric`, `PropertyList`, `TreeView`, `StateMachine`, `DecisionTree`, `FeedbackLoop`, `CodeDiff`
|
|
12
|
-
- Reading and layout: `Insight`, `Callout`, `Details`, `Quote`, `NoteGrid`, `Tabs
|
|
17
|
+
- Reading and layout: `Insight`, `Callout`, `Details`, `Quote`, `NoteGrid`, `Tabs`
|
|
13
18
|
- Graphics and extensions: `Mermaid`, `RelationMap`, `RelationPath`, `Math`, `MathBlock`, `Chart`, `CodeTabs`, `AnnotatedCode`, `Figure` (alias `Image`), `FigureRef`, `Cite`, `References`
|
|
14
19
|
|
|
15
|
-
## Props
|
|
20
|
+
## Props at a glance
|
|
21
|
+
|
|
22
|
+
### Shell and structure
|
|
23
|
+
|
|
24
|
+
| Component | Props |
|
|
25
|
+
| --- | --- |
|
|
26
|
+
| `ExplainPage` | `id`, `title`, `summary`, `layout` = `editorial`, `density` = `reading`, `children` — `layout` / `density` are reserved data attributes with no current visual or model effect; use a static string for `title` if it must become the browser tab title |
|
|
27
|
+
| `ConceptGraph` | `root`, `children` — `root` is optional; omission infers the root and warns |
|
|
28
|
+
| `ConceptNode` | `id`, `title`, `level` = `L2` (`L0`–`L4`), `parent` = `null`, `summary`, `kind`, `input`, `output`, `children` — `summary`/`kind`/`input`/`output` are consumed by the atlas model |
|
|
29
|
+
| `ConceptRef` | `id` |
|
|
30
|
+
| `Children` | `children` — a list of `ConceptRef` |
|
|
31
|
+
| `Relation` | `from`, `to`, `type` = `depends-on`, `label`, `description`, `children` |
|
|
32
|
+
| `ScrollDocument` | `spacing` = `comfortable` (`compact`\|`comfortable`\|`airy`), `fontSize` = `normal` (`compact`\|`normal`\|`large`\|`xlarge`), `scale`, `lineHeight`, `toc` = `true`, `progress` = `true`, `children` |
|
|
33
|
+
| `ScrollHeader` | `label` = `连续阅读`, `title`, `children` |
|
|
34
|
+
| `ScrollSection` | `title`, `id`, `wide` = `false`, `spacing` = `inherit`, `children` — `wide` is reserved and currently adds no extra width |
|
|
35
|
+
| `ScrollProse`, `ScrollPair`, `Columns` | `children` |
|
|
36
|
+
| `ScrollGrid` | `columns` = `3` (`2`\|`3`\|`4`), `children` |
|
|
37
|
+
| `ScrollToc` | `items` = `[]`, `activeId` = `null`, `title` = `目录`, `onNavigate` — internal shell component; fewer than two items renders nothing |
|
|
38
|
+
| `Stack` | `gap` = `md` (`sm`\|`md`\|`lg`), `children` |
|
|
39
|
+
| `Grid` | `columns` = `auto` (`auto`\|`2`\|`3`\|`4`), `gap` = `md` (`sm`\|`md`\|`lg`), `children` |
|
|
40
|
+
| `Split` | `ratio` = `1fr 1fr`, `children` |
|
|
41
|
+
|
|
42
|
+
### Node semantics
|
|
43
|
+
|
|
44
|
+
| Component | Props |
|
|
45
|
+
| --- | --- |
|
|
46
|
+
| `Overview`, `Definition`, `Mechanism`, `Prerequisite`, `Input`, `Output`, `KeyQuestion` | `children` |
|
|
47
|
+
| `Implementation` | `language` = `text`, `title` = `实现代码`, `children` |
|
|
48
|
+
| `CodeBlock` | `code`, `language` = `text`, `title`, `caption`, `lineNumbers` = `false`, `wrap` = `false`, `children` — `code` or template-literal children |
|
|
49
|
+
| `Boundary`, `Example`, `Counterexample`, `Invariant` | `title`, `children` — defaults: `边界与约束`, `典型示例`, `反例与误区`, `不变量` |
|
|
50
|
+
| `Glossary` | `term`, `children` — the definition goes in children |
|
|
51
|
+
|
|
52
|
+
### Argument, evidence and provenance
|
|
53
|
+
|
|
54
|
+
| Component | Props |
|
|
55
|
+
| --- | --- |
|
|
56
|
+
| `Evidence` | `command`, `observes`, `children` — children can supply `observes` when that prop is omitted |
|
|
57
|
+
| `FailureMode` | `symptom`, `cause`, `evidence`, `remedy`, `children` |
|
|
58
|
+
| `Tradeoff` | `title` = `工程权衡`, `options`, `children` |
|
|
59
|
+
| `Checklist` | `title` = `验证清单`, `items`, `children` |
|
|
60
|
+
| `LearningObjectives` | `items`, `children` — `items` is an array of strings |
|
|
61
|
+
| `WorkedExample` | `title` = `推演过程`, `problem`, `children` — children are `Step` components |
|
|
62
|
+
| `Step` | `number`, `title`, `reason`, `children` — omitted numbers are automatic |
|
|
63
|
+
| `Quiz` | `question`, `answer`, `tone` = `info`, `children` — children are the explanation |
|
|
64
|
+
| `KeyTakeaways` | `title` = `关键要点`, `items`, `children` — `items` is an array of strings |
|
|
65
|
+
| `Source` | `kind` = `reference` (`spec`\|`rfc`\|`implementation`\|`experiment`\|`experience`\|`reference`), `label`, `href`, `children` |
|
|
66
|
+
| `Confidence` | `level` = `medium` (`high`\|`medium`\|`low`), `basis`, `children` |
|
|
67
|
+
| `Term` | `name`, `definition`, `children` — with `name`, children are the definition; without `name`, children are only the term text |
|
|
68
|
+
| `LastReviewed` | `date`, `by`, `note` — renders nothing when all three are empty |
|
|
69
|
+
|
|
70
|
+
### Information models
|
|
71
|
+
|
|
72
|
+
| Component | Props |
|
|
73
|
+
| --- | --- |
|
|
74
|
+
| `Flow` | `steps`, `children` |
|
|
75
|
+
| `Timeline` | `events`, `children` |
|
|
76
|
+
| `Compare` | `items`, `children` |
|
|
77
|
+
| `DecisionMatrix` | `title` = `权衡矩阵`, `headers`, `rows`, `children` |
|
|
78
|
+
| `FrameworkModel` | `title` = `结构化模型`, `type` = `elements` (`elements`\|`stages`\|`layers`\|`cycle`), `elements`, `question`, `children` |
|
|
79
|
+
| `MatrixModel` | `title` = `二维矩阵`, `xLabel` = `横轴`, `yLabel` = `纵轴`, `cells`, `children` |
|
|
80
|
+
| `FormulaModel` | `title` = `公式模型`, `formula`, `variables`, `children` |
|
|
81
|
+
| `PyramidModel` | `title` = `金字塔模型`, `levels`, `children` |
|
|
82
|
+
| `FunnelModel` | `title` = `漏斗模型`, `steps`, `children` |
|
|
16
83
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
84
|
+
### Data and behaviour
|
|
85
|
+
|
|
86
|
+
| Component | Props |
|
|
87
|
+
| --- | --- |
|
|
88
|
+
| `DataTable` | `title`, `caption`, `headers`, `rows`, `children` |
|
|
89
|
+
| `Metric` | `label`, `value`, `unit`, `delta`, `trend` (`up`\|`down`\|`flat`), `note` — omitted `trend` is inferred from `delta` |
|
|
90
|
+
| `PropertyList` | `title`, `items`, `children` |
|
|
91
|
+
| `TreeView` | `title`, `items`, `children` |
|
|
92
|
+
| `StateMachine` | `title` = `状态机`, `initial`, `states`, `transitions`, `children` |
|
|
93
|
+
| `DecisionTree` | `title` = `决策路径`, `question`, `branches`, `children` |
|
|
94
|
+
| `FeedbackLoop` | `title` = `反馈回路`, `type` = `reinforcing` (`reinforcing`\|`balancing`), `nodes`, `children` |
|
|
95
|
+
| `CodeDiff` | `title` = `代码对比`, `language` = `text`, `before`, `after`, `beforeLabel` = `修改前`, `afterLabel` = `修改后`, `caption` |
|
|
96
|
+
|
|
97
|
+
### Reading, layout and graphics
|
|
98
|
+
|
|
99
|
+
| Component | Props |
|
|
100
|
+
| --- | --- |
|
|
101
|
+
| `Insight` | `title` = `关键判断`, `tone` = `info` (`info`\|`success`\|`warn`\|`danger`), `children`, `width` = `auto`, `height` = `auto`, `x` = `0`, `y` = `0`, `position` = `flow` |
|
|
102
|
+
| `Callout` | `type` = `info` (`info`\|`success`\|`warn`\|`danger`), `title`, `children` |
|
|
103
|
+
| `Details` | `summary` = `详细展开`, `children` |
|
|
104
|
+
| `Quote` | `author`, `source`, `href`, `children` |
|
|
105
|
+
| `NoteGrid` | `notes`, `children`, `width` = `auto`, `height` = `auto`, `x` = `0`, `y` = `0`, `position` = `flow` |
|
|
106
|
+
| `Tabs` | `items`, `children` — children are `<details>` blocks |
|
|
107
|
+
| `Mermaid` | `chart` = `''`, `title` = `关系草图`, `width` = `auto`, `height` = `auto`, `x` = `0`, `y` = `0`, `position` = `flow` |
|
|
108
|
+
| `RelationMap` | `title` = `关系速览`, `items`, `children`, `width` = `auto`, `height` = `auto`, `x` = `0`, `y` = `0`, `position` = `flow` |
|
|
109
|
+
| `RelationPath` | `title` = `关系链`, `steps`, `children` |
|
|
110
|
+
| `Math` | `formula`, `children` — children are fine only when they contain no braces; `formula` is safer for backslashes |
|
|
111
|
+
| `MathBlock` | `title` = `公式`, `formula`, `variables`, `children` |
|
|
112
|
+
| `Chart` | `title` = `图表`, `type` = `bar` (`bar`\|`line`\|`pie`), `data`, `series`, `labels`, `unit` = `''`, `showValues` = `true`, `width` = `auto`, `height` = `auto`, `x` = `0`, `y` = `0`, `position` = `flow` |
|
|
113
|
+
| `CodeTabs` | `items`, `title`, `caption`, `lineNumbers` = `false` |
|
|
114
|
+
| `AnnotatedCode` | `code`, `language` = `text`, `title`, `caption`, `notes` |
|
|
115
|
+
| `Figure`, `Image` | `id`, `src`, `alt` = `''`, `caption`, `label`, `inline`, `width` = `auto`, `height` = `auto`, `x` = `0`, `y` = `0`, `position` = `flow` |
|
|
116
|
+
| `FigureRef` | `id`, `children` — children override the automatic label |
|
|
117
|
+
| `Cite` | `id`, `children` — children override the automatic citation number |
|
|
118
|
+
| `References` | `title` = `参考文献`, `items`, `children` |
|
|
119
|
+
|
|
120
|
+
## Shapes and traps
|
|
121
|
+
|
|
122
|
+
Array props are arrays, but not always arrays of objects: some take strings, numbers, or nested arrays. Field names differ per component and are not interchangeable. Unknown props are dropped without a word, so a wrong field name usually shows up as an empty cell, a missing badge, or a card with only its title.
|
|
123
|
+
|
|
124
|
+
- **Booleans:** prefer a bare prop or `{true}` / `{false}`. Runtime booleans such as `toc="false"` and `showValues="false"` are truthy. The asset plugin also accepts quoted `inline="false"`, but use `inline={false}` for consistency.
|
|
125
|
+
- **`Callout` uses `type`, while `Insight` and `Quiz` use `tone`.** Both accept `info` / `success` / `warn` / `danger`; anything else falls back to `info`.
|
|
126
|
+
- **`Compare` puts the row labels on the first item only:** `items={[{label, rows: ['行一','行二'], values: ['…','…']}]}`. `label` is the column header, `rows` is read from `items[0]` and shared by every column, and each item's `values[i]` fills row `i`. A missing cell renders `-`; `0`, `false`, and an empty string are preserved. For a free-form side-by-side block instead, use children (e.g. `Columns` + `Split`).
|
|
127
|
+
- **`Flow`** takes strings or `{title?, label?, description?}` objects. **`Timeline`** takes `{label?, time?, content?, desc?}`: `label` is primary, `time` is shown beside it when both exist, and `desc` is a legacy fallback for `content`.
|
|
128
|
+
- **`FrameworkModel` / `PyramidModel` / `FunnelModel`:** `elements={[{title?, label?, name?, description?}]}`, `levels={[{title?, label?, description?}]}`, and `steps={[{title?, label?, description?}]}`. `FrameworkModel type` labels the model; only `stages` currently adds arrow layout. `cycle` is a semantic label, not a circular layout.
|
|
129
|
+
- **`MatrixModel` is the 2×2 quadrant** (`xLabel`, `yLabel`, `cells={[{title?, label?, description?, tone?}]}`, usually four cells); **`DecisionMatrix` is the weighted table** (`headers`, `rows` as arrays of cells). `cells` on a `DecisionMatrix` is silently ignored.
|
|
130
|
+
- **`Tradeoff` options carry the verdict:** `options={[{name?, label?, benefit?, cost?, when?}]}` — `when` is the condition under which that option wins.
|
|
131
|
+
- **`NoteGrid`** takes `notes={[{title?, label?, content?, text?, description?}]}`; **`Tabs`** takes `items={[{label?, title?, content?}]}` and opens the first tab.
|
|
132
|
+
- **`Evidence` is normally a command/observation pair** (`command`, `observes`); children can supply `observes` when the prop is omitted.
|
|
133
|
+
- **`Checklist` items** are strings or `{text?, status, note?}` with `status` one of `pass` / `fail` / `unknown` / `todo`. Invalid or omitted statuses become `unknown`.
|
|
134
|
+
- **`LearningObjectives` / `KeyTakeaways` items** are arrays of strings.
|
|
135
|
+
- **`PropertyList` items** are strings or `{name?, label?, key?, value?, note?}`; **`TreeView` items** are `{label?, title?, description?, children: […]}` (nest to any depth).
|
|
136
|
+
- **`StateMachine`** needs `states={[{id, label?, description?, terminal?}]}` and `transitions={[{from, to, event?, guard?}]}` whose `from`/`to` are state ids; `initial` marks the entry state.
|
|
137
|
+
- **`DecisionTree` branches** are `{condition?, outcome?, note?, tone?, branches: […]}` — nest `branches` for deeper levels.
|
|
138
|
+
- **`FeedbackLoop` nodes** are `{label?, title?, description?}` and `type="balancing"` flips the loop polarity.
|
|
139
|
+
- **`Chart`** reads `data={[{label?, x?, value?, y?}]}` or numbers for `bar`/`pie`, and `labels` + `series={[{name?, label?, values}]}` for `line`. Invalid `type` values fall back to `bar`. `unit` is shown in the chart's header badge (`CHART · BAR · ms`), not appended to each value.
|
|
140
|
+
- **`RelationMap` items** are `{from?, source?, type, to?, target?, note?}` with `type` from the same whitelist as `Relation`; **`RelationPath` steps** are `{level?, node?, title?, note?, relation?, tone?}`. `node` is the display label (not a node id), and `relation` labels the edge to the next step.
|
|
141
|
+
- **`Math`** requires `formula` when children contain braces — MDX reads `{…}` as an expression. Brace-free children such as `<Math>\log_2 N</Math>` work, but `formula` is safer and more consistent. `MathBlock` adds `variables={[{symbol?, name?, description?, value?}]}` and a title.
|
|
142
|
+
- **`CodeTabs` items** are `{label?, language?, code?}`; **`AnnotatedCode` notes** are `{line, text?}` and `line` is the 1-based line number in `code`.
|
|
143
|
+
- **`Mermaid`** takes the chart as a template literal (`chart={\`flowchart LR …\`}`); keep the backtick wrapper so newlines survive. Readers can open any chart full-screen from the widget head or by clicking the drawing. Pele renders it as an inline SVG, so the page stays offline; its layout differs from Mermaid.js, and `themeVariables` does nothing — colours come from the page theme.
|
|
144
|
+
- **Widget props** (`width`, `height`, `x`, `y`, `position`) exist on `Mermaid`, `Chart`, `Figure`, `Image`, `Insight`, `NoteGrid` and `RelationMap`. `position="absolute"` places the widget at `x`/`y` inside its container; any other value keeps it in the flow and uses `x`/`y` as a translate offset. Leave them alone unless the layout asks for it.
|
|
145
|
+
- **`ConceptNode` content precedence:** `<Input>` / `<Output>` children override the node's `input` / `output` props. A string-only `<Overview>` supplies `summary` when the prop is omitted.
|
|
146
|
+
- **`Relation` precedence differs by carrier:** direct scroll rendering prefers children over `description`; atlas extraction prefers `description` over children. Set `description` explicitly when the same edge must read identically in both carriers.
|
|
147
|
+
- **`Term`:** `<Term name="X">定义</Term>` creates a term with a definition. `<Term>X</Term>` only sets the term text and has no definition.
|
|
148
|
+
- **`FigureRef` / `Cite` children** override the automatic “图 N” / `[n]` text. Use this sparingly; the automatic labels stay correct when content moves.
|
|
149
|
+
|
|
150
|
+
## Figures and assets
|
|
151
|
+
|
|
152
|
+
- A relative `src` (`./assets/diagram.png`) stays a relative link by default; compile with `--inline-assets` to bake every local image in as base64, or set `inline={true}` / `inline={false}` on one figure to override (precedence: per-figure prop > global flag > link). `http(s)` URLs stay links and warn (`ASSET_REMOTE`). Always set `alt`; a missing relative file warns (`ASSET_MISSING`) and shows a placeholder. Readers can click a figure to open it full-screen (zoom, drag, `Esc`) — mention it for diagram-heavy pages.
|
|
24
153
|
- **Figure numbering**: give a figure an `id` and reference it with `<FigureRef id="..." />` to render "图 N". Numbering follows document order (per node in `atlas`, whole document in `scroll`) and reflows automatically, so never hand-write "图 1"; an explicit `label` still wins. A ref with no matching `id` warns (`FIGURE_REF_UNRESOLVED`).
|
|
25
|
-
- **Figure size & cost**: linking keeps the HTML small but
|
|
26
|
-
|
|
154
|
+
- **Figure size & cost**: linking keeps the HTML small, but the relative `src` must resolve from the output HTML location; keep the needed `assets/` beside the HTML or adjust the path. The CLI warns when `-o` points outside the MDX directory. Inlining is what makes a screenshot-heavy page large (a page with no heavy renderers otherwise lands near 250KB). An asset over 512KB warns (`ASSET_LARGE`) when inlined by the global flag or a per-figure `inline` prop. Decide the trade-off with the user instead of choosing silently.
|
|
155
|
+
|
|
156
|
+
## Cite and References
|
|
157
|
+
|
|
158
|
+
`<Cite id="..." />` renders `[n]` from the matching item's position in `<References items={...} />`, where each item is `{id, authors?, year?, title?, url?, source?, note?}`. In `scroll`, `References` can sit anywhere. In `atlas`, keep the cites and the `References` block in the same node, because node content only renders when that node is open.
|
|
@@ -1,15 +1,55 @@
|
|
|
1
1
|
# Validation diagnostics
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Human-readable diagnostics use `error|warn line:column CODE message`; `--json` returns structured objects. Fix every error before building. Warnings usually mean the page still renders but loses structure, provenance, or reader clarity; fix them when cheap, and use `--strict` when a clean result is required.
|
|
4
4
|
|
|
5
5
|
## Errors — fix before building
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
| Code | What it means | What to do |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| `UNKNOWN_COMPONENT` | The tag is not registered. | Replace it with a component from `components.md`; do not invent aliases except `Image` for `Figure`. |
|
|
10
|
+
| `CARRIER_MISSING` | Neither page shell was found. | Add exactly one `ExplainPage` or `ScrollDocument` shell. |
|
|
11
|
+
| `CARRIER_CONFLICT` | Both shells occur in one file. | Keep one shell; convert the outer structure rather than nesting both. |
|
|
12
|
+
| `CARRIER_MODE_MISMATCH` | The file's shell disagrees with `--mode`. | Pass the matching `--mode atlas` or `--mode scroll`, or convert the file. |
|
|
13
|
+
| `NODE_MISSING_ID` | A `ConceptNode` has no stable id. | Add a unique kebab-case id. |
|
|
14
|
+
| `DUPLICATE_NODE_ID` | Two nodes share an id. | Rename one and update `parent`, `ConceptRef`, and `Relation` references. |
|
|
15
|
+
| `NODE_MISSING_TITLE` | A node has no readable title. | Add a claim-like `title`; an id alone is not enough. |
|
|
16
|
+
| `MISSING_PARENT` | A non-root node points to a missing parent. | Correct the parent id or remove it for the root. |
|
|
17
|
+
| `GRAPH_ROOT_UNRESOLVED` | `ConceptGraph root` names no node. | Point it at the `L0` node id. |
|
|
18
|
+
| `REF_MISSING_ID` | `ConceptRef` has no id. | Add the target node id. |
|
|
19
|
+
| `REF_UNRESOLVED` | `ConceptRef` points at no node. | Correct the id or add the missing node. |
|
|
20
|
+
| `RELATION_FROM_UNRESOLVED` | A relation's source id is missing. | Correct `from` or add the source node. |
|
|
21
|
+
| `RELATION_TO_UNRESOLVED` | A relation's target id is missing. | Correct `to` or add the target node. |
|
|
8
22
|
|
|
9
23
|
## Warnings — fix when cheap
|
|
10
24
|
|
|
11
|
-
|
|
25
|
+
| Code | What it means | What to do |
|
|
26
|
+
| --- | --- | --- |
|
|
27
|
+
| `NODE_MISSING_SUMMARY` | A node has no one-sentence summary. | Add `summary`; a string-only `Overview` can supply it in atlas. |
|
|
28
|
+
| `NODE_NO_CORE_CONTENT` | A node only repeats metadata or navigation. | Add definition, mechanism, evidence, example, model, or boundary content; merge it if it is only a stub. |
|
|
29
|
+
| `NO_ROOT_LEVEL` | The atlas has no `L0` root. | Mark exactly one root node `level="L0"`; `--strict` promotes this warning. |
|
|
30
|
+
| `MULTIPLE_ROOT_LEVEL` | More than one node is marked `L0`. | Keep one `L0`; make the other top-level branches `L1`. |
|
|
31
|
+
| `UNKNOWN_LEVEL` | `level` is outside `L0`–`L4`. | Use a declared level that matches the node's cognitive depth. |
|
|
32
|
+
| `UNKNOWN_KIND` | `kind` is outside the whitelist. | Use `system`, `stage`, `mechanism`, `artifact`, `failure`, `tool`, `boundary`, or `decision`, or omit it. |
|
|
33
|
+
| `MECHANISM_KIND_UNVERIFIED` | A mechanism node lacks `Invariant` or `Evidence`. | Add the invariant or evidence that makes the mechanism checkable. |
|
|
34
|
+
| `FAILURE_KIND_UNSTRUCTURED` | A failure node lacks a structured `FailureMode`. | Add `symptom`, `cause`, `evidence`, or `remedy`; `--strict` promotes this warning. |
|
|
35
|
+
| `FAILURE_MODE_EMPTY` | A self-closing `FailureMode` has no fields or children. | Supply at least one failure field or explanatory children. |
|
|
36
|
+
| `UNKNOWN_RELATION_TYPE` | The relation type is not in the whitelist. | Use a type from `SKILL.md`; do not express parent-child hierarchy as a relation. |
|
|
37
|
+
| `RELATION_MISSING_LABEL` | The edge has no reader-facing label. | Add a short `label` that states the relation's meaning. |
|
|
38
|
+
| `RELATION_SELF` | A relation starts and ends at the same node. | Remove it or connect two distinct nodes. |
|
|
39
|
+
| `PROP_EXPECTS_ARRAY` | An array prop received a string or non-array expression. | Pass an array literal such as `steps={[...]}`; check `components.md` for the item shape. |
|
|
40
|
+
| `MATH_CHILDREN_BRACES` | LaTeX in children contains MDX expression syntax. | Move the formula into `formula="..."` or a template literal. |
|
|
41
|
+
| `PROSE_EXPRESSION` | Prose was parsed as a JavaScript expression. | Escape or rewrite the braces; use a code block for literal syntax. |
|
|
42
|
+
| `FRONTMATTER_UNSUPPORTED` | The MDX frontmatter uses fields the renderer does not consume. | Remove the unsupported fields; keep authoring metadata outside the page shell. |
|
|
43
|
+
| `GRAPH_MISSING_ROOT` | `ConceptGraph` has no explicit root. | Add `root="<L0-id>"`; omission currently infers a root and warns. |
|
|
44
|
+
| `FIGURE_MISSING_SRC` | `Figure` has no image source. | Add a valid local path or remote URL. |
|
|
45
|
+
| `ASSET_MISSING` | A relative image path does not exist. | Correct the path relative to the MDX file. |
|
|
46
|
+
| `ASSET_REMOTE` | An image uses an `http(s)` URL. | Keep it only when remote loading is acceptable; otherwise use a local asset. |
|
|
47
|
+
| `ASSET_LARGE` | An asset over 512KB is inlined by `--inline-assets` or a per-figure `inline` prop. | Compress it, link it instead, or set `inline={false}` for that figure. |
|
|
48
|
+
| `FIGURE_REF_UNRESOLVED` | `FigureRef` names no figure id. | Add the matching `id` or correct the reference. |
|
|
49
|
+
| `FIGURE_REF_MISSING_ID` | `FigureRef` has no id. | Add the target figure id. |
|
|
50
|
+
| `FIGURE_DUPLICATE_ID` | Two figures share an id. | Rename one and update its references. |
|
|
51
|
+
| `REF_SELF` | A node lists itself as a child. | Remove the self-reference; use `parent` and `Children` for real hierarchy. |
|
|
12
52
|
|
|
13
53
|
## Promoted by `--strict`
|
|
14
54
|
|
|
15
|
-
`NO_ROOT_LEVEL`, `MULTIPLE_ROOT_LEVEL`, `MECHANISM_KIND_UNVERIFIED` and `FAILURE_KIND_UNSTRUCTURED` are warnings that `--strict` turns into errors.
|
|
55
|
+
`NO_ROOT_LEVEL`, `MULTIPLE_ROOT_LEVEL`, `MECHANISM_KIND_UNVERIFIED` and `FAILURE_KIND_UNSTRUCTURED` are warnings that `--strict` turns into errors. The first two mean the atlas has no `L0` or has more than one; keep exactly one root.
|
|
@@ -298,7 +298,7 @@ export function Compare({ items = [], children }) {
|
|
|
298
298
|
<tr key={rIdx}>
|
|
299
299
|
<td className="compare-row-label">{rowKey}</td>
|
|
300
300
|
{items.map((it, idx) => (
|
|
301
|
-
<td key={idx}>{it.values?.[rIdx]
|
|
301
|
+
<td key={idx}>{it.values?.[rIdx] ?? '-'}</td>
|
|
302
302
|
))}
|
|
303
303
|
</tr>
|
|
304
304
|
))
|
|
@@ -376,7 +376,10 @@ export function Timeline({ events = [], children }) {
|
|
|
376
376
|
{events.map((ev, i) => (
|
|
377
377
|
<div key={i} className="timeline-item">
|
|
378
378
|
<div className="timeline-point" />
|
|
379
|
-
<div className="timeline-label">
|
|
379
|
+
<div className="timeline-label">
|
|
380
|
+
{ev.label || ev.time}
|
|
381
|
+
{ev.label && ev.time && <small className="timeline-time">{ev.time}</small>}
|
|
382
|
+
</div>
|
|
380
383
|
<div className="timeline-content">{ev.content || ev.desc}</div>
|
|
381
384
|
</div>
|
|
382
385
|
))}
|
|
@@ -1750,6 +1753,7 @@ export function Chart({
|
|
|
1750
1753
|
y = 0,
|
|
1751
1754
|
position = 'flow'
|
|
1752
1755
|
}) {
|
|
1756
|
+
const safeType = ['bar', 'line', 'pie'].includes(type) ? type : 'bar';
|
|
1753
1757
|
const points = normalizePoints(data);
|
|
1754
1758
|
const seriesList = (Array.isArray(series) ? series : []).filter(Boolean).map((entry, index) => ({
|
|
1755
1759
|
name: entry.name || entry.label || `系列 ${index + 1}`,
|
|
@@ -1770,7 +1774,7 @@ export function Chart({
|
|
|
1770
1774
|
const ticks = [0, 0.25, 0.5, 0.75, 1].map(ratio => ({ ratio, value: max * ratio }));
|
|
1771
1775
|
|
|
1772
1776
|
const body = (() => {
|
|
1773
|
-
if (
|
|
1777
|
+
if (safeType === 'pie') {
|
|
1774
1778
|
if (!points.length) return null;
|
|
1775
1779
|
const total = points.reduce((sum, point) => sum + Math.max(0, point.value), 0) || 1;
|
|
1776
1780
|
const radius = Math.min(innerW, innerH) / 2;
|
|
@@ -1828,7 +1832,7 @@ export function Chart({
|
|
|
1828
1832
|
</g>
|
|
1829
1833
|
);
|
|
1830
1834
|
|
|
1831
|
-
if (
|
|
1835
|
+
if (safeType === 'line') {
|
|
1832
1836
|
const count = Math.max(1, seriesList[0]?.values.length || 0, labels.length);
|
|
1833
1837
|
const stepX = count > 1 ? innerW / (count - 1) : 0;
|
|
1834
1838
|
const xFor = idx => PAD.left + idx * stepX;
|
|
@@ -1949,7 +1953,7 @@ export function Chart({
|
|
|
1949
1953
|
<div className="semantic-widget-head">
|
|
1950
1954
|
<span>{title}</span>
|
|
1951
1955
|
<code>
|
|
1952
|
-
CHART · {
|
|
1956
|
+
CHART · {safeType.toUpperCase()}
|
|
1953
1957
|
{unit ? ` · ${unit}` : ''}
|
|
1954
1958
|
</code>
|
|
1955
1959
|
</div>
|
|
@@ -162,7 +162,7 @@ function parseConceptNode(nodeElement) {
|
|
|
162
162
|
case 'Implementation':
|
|
163
163
|
node.implementation = {
|
|
164
164
|
language: child.props.language || 'text',
|
|
165
|
-
title: child.props.title || '
|
|
165
|
+
title: child.props.title || '实现代码',
|
|
166
166
|
code: child.props.children
|
|
167
167
|
};
|
|
168
168
|
break;
|
|
@@ -174,13 +174,13 @@ function parseConceptNode(nodeElement) {
|
|
|
174
174
|
break;
|
|
175
175
|
case 'Counterexample':
|
|
176
176
|
node.counterexamples.push({
|
|
177
|
-
title: child.props.title || '
|
|
177
|
+
title: child.props.title || '反例与误区',
|
|
178
178
|
content: child.props.children
|
|
179
179
|
});
|
|
180
180
|
break;
|
|
181
181
|
case 'Boundary':
|
|
182
182
|
node.boundaries.push({
|
|
183
|
-
title: child.props.title || '
|
|
183
|
+
title: child.props.title || '边界与约束',
|
|
184
184
|
content: child.props.children
|
|
185
185
|
});
|
|
186
186
|
break;
|
|
@@ -117,9 +117,11 @@ export const LARGE_ASSET_BYTES = 512 * 1024;
|
|
|
117
117
|
export const ARRAY_PROPS = {
|
|
118
118
|
Flow: ['steps'],
|
|
119
119
|
Timeline: ['events'],
|
|
120
|
+
ScrollToc: ['items'],
|
|
120
121
|
FrameworkModel: ['elements'],
|
|
121
122
|
MatrixModel: ['cells'],
|
|
122
123
|
FormulaModel: ['variables'],
|
|
124
|
+
MathBlock: ['variables'],
|
|
123
125
|
PyramidModel: ['levels'],
|
|
124
126
|
FunnelModel: ['steps'],
|
|
125
127
|
DecisionMatrix: ['headers', 'rows'],
|
|
@@ -136,7 +138,7 @@ export const ARRAY_PROPS = {
|
|
|
136
138
|
RelationMap: ['items'],
|
|
137
139
|
RelationPath: ['steps'],
|
|
138
140
|
References: ['items'],
|
|
139
|
-
Chart: ['data', 'series'],
|
|
141
|
+
Chart: ['data', 'series', 'labels'],
|
|
140
142
|
DataTable: ['headers', 'rows'],
|
|
141
143
|
StateMachine: ['states', 'transitions'],
|
|
142
144
|
KeyTakeaways: ['items'],
|
|
@@ -369,6 +371,14 @@ function attrValue(map, name) {
|
|
|
369
371
|
return attr.value;
|
|
370
372
|
}
|
|
371
373
|
|
|
374
|
+
/** Matches the build-time asset plugin's boolean prop handling. */
|
|
375
|
+
function attrTruthy(attr) {
|
|
376
|
+
if (!attr) return false;
|
|
377
|
+
if (!attr.hasValue) return true;
|
|
378
|
+
const value = String(attr.value).trim();
|
|
379
|
+
return value !== 'false' && value !== '0';
|
|
380
|
+
}
|
|
381
|
+
|
|
372
382
|
/**
|
|
373
383
|
* Statically validate a Concept Atlas MDX document without rendering React.
|
|
374
384
|
* Works in Node (CLI) and in the browser (registry only).
|
|
@@ -478,6 +488,7 @@ export function validateMdxSource(source, options = {}) {
|
|
|
478
488
|
const map = attrsToMap(tag.attrs);
|
|
479
489
|
const src = attrValue(map, 'src');
|
|
480
490
|
const quoted = map.src ? map.src.quoted : false;
|
|
491
|
+
const inlineRequested = map.inline ? attrTruthy(map.inline) : inlineAssets;
|
|
481
492
|
const figureId = attrValue(map, 'id');
|
|
482
493
|
if (figureId) {
|
|
483
494
|
if (figureIds.has(figureId))
|
|
@@ -497,7 +508,7 @@ export function validateMdxSource(source, options = {}) {
|
|
|
497
508
|
const resolved = src.startsWith('.') ? src : `./${src}`;
|
|
498
509
|
if (!assetExists(resolved)) {
|
|
499
510
|
add('warning', 'ASSET_MISSING', `找不到图片文件:${src}(将显示占位符)`, tag.start, src);
|
|
500
|
-
} else if (
|
|
511
|
+
} else if (inlineRequested && assetSize) {
|
|
501
512
|
const bytes = assetSize(resolved);
|
|
502
513
|
if (typeof bytes === 'number' && bytes > LARGE_ASSET_BYTES) {
|
|
503
514
|
add(
|
|
@@ -92,8 +92,15 @@ button:focus-visible, a:focus-visible, [role="button"]:focus-visible {
|
|
|
92
92
|
/* Optional semantic layout primitives */
|
|
93
93
|
.semantic-stack { display: flex; flex-direction: column; }
|
|
94
94
|
.semantic-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
|
|
95
|
+
.semantic-grid.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
96
|
+
.semantic-grid.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
97
|
+
.semantic-grid.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
|
|
95
98
|
.semantic-split { display: grid; grid-template-columns: var(--split-ratio, 1fr 1fr); align-items: start; }
|
|
96
99
|
.gap-sm { gap: 8px; } .gap-md { gap: 16px; } .gap-lg { gap: 28px; }
|
|
100
|
+
.timeline-time { margin-left: 8px; color: var(--text-muted); font-size: 11px; }
|
|
101
|
+
@media (max-width: 720px) {
|
|
102
|
+
.semantic-grid.grid-2, .semantic-grid.grid-3, .semantic-grid.grid-4 { grid-template-columns: 1fr; }
|
|
103
|
+
}
|
|
97
104
|
.semantic-tabs details { border-bottom: 1px solid var(--border-subtle); padding: 8px 0; }
|
|
98
105
|
.semantic-tabs summary { cursor: pointer; font-weight: 700; color: var(--text-primary); }
|
|
99
106
|
.mermaid-tools { display: inline-flex; align-items: center; gap: 6px; }
|
package/template/vite.config.js
CHANGED
|
@@ -32,11 +32,20 @@ const MARKDOWN_IMAGE_RE = /!\[([^\]]*)\]\(([^)\s]+)(\s+["'][^"']*["'])?\)/g;
|
|
|
32
32
|
* mistaken for the prop itself.
|
|
33
33
|
*/
|
|
34
34
|
function readInlineProp(tag) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
// Consume whole attribute values so an `inline` word inside `title="..."` or
|
|
36
|
+
// another quoted string cannot be mistaken for the prop itself.
|
|
37
|
+
const attr = /([:\w-]+)(?:\s*=\s*(\{[^}]*\}|"[^"]*"|'[^']*'|[^\s/>]+))?/g;
|
|
38
|
+
for (const match of tag.matchAll(attr)) {
|
|
39
|
+
if (match[1] !== 'inline') continue;
|
|
40
|
+
if (match[2] === undefined) return true;
|
|
41
|
+
let value = match[2]
|
|
42
|
+
.trim()
|
|
43
|
+
.replace(/^\{|\}$/g, '')
|
|
44
|
+
.trim();
|
|
45
|
+
if (/^(["']).*\1$/.test(value)) value = value.slice(1, -1);
|
|
46
|
+
return value !== 'false' && value !== '0';
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
40
49
|
}
|
|
41
50
|
|
|
42
51
|
/**
|