concept-atlas-dense-explain 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "concept-atlas-dense-explain",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Portable dense-explanation skill and MDX concept atlas template",
5
5
  "type": "module",
6
6
  "bin": {
package/skill/SKILL.md CHANGED
@@ -1,20 +1,47 @@
1
1
  ---
2
2
  name: concept-atlas-dense-explain
3
- description: Generate high-density, navigable concept explanations as semantic MDX for the Concept Atlas template. Use when a user asks for dense explanations, concept maps, layered knowledge, mechanism breakdowns, or a searchable interactive explanation page.
3
+ description: Build high-density, navigable Concept Atlas webpages with the bundled React/Vite/MDX template. Use this skill whenever the user asks for a dense technical explanation, concept map, layered knowledge page, interactive explanation, or webpage resembling the bundled compile-runtime exemplar. Never replace the template with a custom JSX, HTML, CSS, or vertically-scrolling Markdown page.
4
4
  ---
5
5
 
6
6
  # Concept Atlas Dense Explain
7
7
 
8
- Use the bundled template to turn knowledge into a concept tree, semantic relations, and compact reading blocks. The AI writes knowledge semantics; the template owns layout, CSS, graph rendering, navigation, zoom, search, and responsive behavior.
8
+ This is an Agent Skills-compatible skill. Keep the instructions and generated content portable across Claude Code, Codex, Cursor, Gemini CLI, OpenCode, Cline, GitHub Copilot, and other agents that support `SKILL.md`.
9
+
10
+ Use the bundled template to turn knowledge into a concept tree, semantic relations, and compact reading blocks. The AI writes knowledge semantics; the template owns layout, CSS, graph rendering, navigation, zoom, search, and responsive behavior. The required deliverable is a built Concept Atlas webpage, normally `dist/index.html`, not a standalone mockup.
11
+
12
+ ## Mandatory preflight and no-fallback rule
13
+
14
+ Before generating content, resolve the directory containing this `SKILL.md` and verify that these bundled files are readable:
15
+
16
+ - `assets/template/content/compile-runtime.mdx`
17
+ - `assets/template/src/app/App.jsx`
18
+ - `assets/template/src/components/MDXComponents.jsx`
19
+ - `assets/template/src/model/normalize-content.js`
20
+ - `references/components.md`
21
+
22
+ Read the exemplar and the component contract before writing. If the bundled template is unavailable, stop and report that the Concept Atlas template cannot be accessed. Do not create a custom JSX app, standalone HTML, CSS layout, Mermaid-only page, or vertically scrolling Markdown page as a substitute.
23
+
24
+ The template is the implementation boundary. Do not edit `src/`, styles, `index.html`, Vite configuration, or package dependencies for a content task. Only replace the MDX content after the template has been copied into the task workspace.
25
+
26
+ ## Step 0 — Read the exemplar before writing
27
+
28
+ Read [assets/template/content/compile-runtime.mdx](assets/template/content/compile-runtime.mdx) in full first. It is the **reference standard**, not just a file to overwrite. Study its shape before generating anything:
29
+
30
+ - 1 `L0` root, ~5 `L1` branches, 2–3 children per branch, descending to `L3`/`L4` where the topic deserves it.
31
+ - Every `title` is a claim ("ABI 破坏:能链接,不等于能调用"), and every `summary` is a one-sentence judgment.
32
+ - Important nodes carry 3–6 semantic components, not one lone paragraph.
33
+ - Claims are backed by concrete commands, numbers, or named artifacts (`readelf -Ws`, `nm -C`, `objdump -dr`, `.bss`, ASLR).
34
+ - Cross-branch meaning is encoded as labeled `Relation`s, not prose.
9
35
 
10
36
  ## Workflow
11
37
 
12
- 1. Model one `L0` root, then `L1` structure, `L2` mechanisms, and optional `L3/L4` boundaries or failures. Keep each node focused on one claim.
13
- 2. Add `parent`/`Children` for hierarchy and `Relation` for cross-branch meaning. Never encode layout, coordinates, CSS, or SVG in MDX.
14
- 3. Give important nodes a definition, input/output, mechanism, one concrete example, and at least one boundary or evidence item.
15
- 4. Prefer horizontal semantic components (`Grid`, `Split`, `Flow`, `Compare`, `Timeline`, `Tradeoff`) for comparisons and sequences. Use `Details` for secondary detail; do not turn every fact into a card.
16
- 5. Use `LearningObjectives`, `KeyQuestion`, `Evidence`, `Invariant`, and `FailureMode` when they improve understanding or verification. Keep the first screen to the core claim plus 3–5 key facts.
17
- 6. Build with the bundled template and verify node switching, graph mode, search, URL `#node=...`, keyboard navigation, and responsive layout.
38
+ 1. Resolve and copy the complete `assets/template` directory into the task workspace; preserve its React, CSS, graph, and build files.
39
+ 2. Read the exemplar above and [references/components.md](references/components.md) for the component and relation contract.
40
+ 3. Replace only `content/compile-runtime.mdx`. Model one `L0` root, then `L1` structure, `L2` mechanisms, and optional `L3/L4` boundaries or failures. Keep each node focused on one claim.
41
+ 4. Add `parent`/`Children` for hierarchy and `Relation` for cross-branch meaning. Never encode layout, coordinates, CSS, or SVG in MDX.
42
+ 5. Give important nodes a definition, input/output, mechanism, one concrete example, and at least one boundary or evidence item.
43
+ 6. Run the bundled content validator, then run `npm install` and `npm run build`. If validation or build fails, revise the MDX and do not return a substitute page.
44
+ 7. Verify node switching, graph mode, search, URL `#node=...`, keyboard navigation, and responsive layout. Return the built `dist/index.html` path.
18
45
 
19
46
  ## Content rules
20
47
 
@@ -22,10 +49,25 @@ Use the bundled template to turn knowledge into a concept tree, semantic relatio
22
49
  - Use tables/flows for comparison and causality; use short paragraphs only for explanation.
23
50
  - Every dense block should contain a conclusion, evidence, or limitation.
24
51
  - Prefer 2–4 columns on wide screens and natural stacking on narrow screens.
25
- - Do not invent unsupported components. Read `references/components.md` for the supported semantic API.
52
+ - Do not invent unsupported components or relation types. Read [references/components.md](references/components.md) for the supported semantic API.
53
+ - Aim for the exemplar's scale: roughly 1 root, 4–5 `L1` branches, ~15–25 nodes total. A thin graph (few nodes, one paragraph each) is a failure, not a shortcut.
54
+
55
+ ## Self-check before finishing
56
+
57
+ Run this checklist and revise until every item passes. If an item fails, fix the content instead of adding decoration.
58
+
59
+ - [ ] One `L0` root; every `L1` belongs to it; depth reaches `L3`/`L4` where warranted.
60
+ - [ ] Every key node has a claim-style `title`, a one-line `summary`, and at least one of `Definition` / `Mechanism` / `Example` / `Evidence` / `Boundary`.
61
+ - [ ] Several nodes carry concrete, verifiable evidence (real commands, metrics, or named artifacts) rather than generic filler.
62
+ - [ ] Cross-branch meaning is encoded with `Relation` using only the whitelisted types in `references/components.md`.
63
+ - [ ] First screen shows the core claim plus 3–5 key facts; long detail lives in `Details` / `Tabs`.
64
+ - [ ] No CSS, coordinates, SVG, or layout instructions appear in the MDX.
65
+ - [ ] Only the template's MDX content was changed; no replacement JSX or vertical article page was created.
66
+ - [ ] The bundled validator passes before the build.
67
+ - [ ] The template builds and node switching, graph mode, search, `#node=...`, and keyboard navigation all work.
26
68
 
27
69
  ## Portable template
28
70
 
29
- The self-contained React/Vite/MDX implementation is in [assets/template](assets/template). Copy it into a project, replace `content/compile-runtime.mdx`, run `npm install`, then `npm run build`. The template has no dependency on the source repository's absolute paths.
71
+ The self-contained React/Vite/MDX implementation is in [assets/template](assets/template). Copy it into a project, replace `content/compile-runtime.mdx` **after studying it**, run `npm install`, then `npm run build`. The template has no dependency on the source repository's absolute paths. If the host agent cannot access or copy the template, stop and report the missing template; do not return a substitute webpage.
30
72
 
31
- For the component contract and request priorities, read [references/components.md](references/components.md). For AI prompt wording and component selection, read [references/prompting.md](references/prompting.md).
73
+ For the component contract, relation whitelist, and level semantics, read [references/components.md](references/components.md). For the exemplar breakdown, density targets, and prompt wording, read [references/prompting.md](references/prompting.md).
@@ -3,7 +3,7 @@
3
3
  "private": true,
4
4
  "version": "0.1.0",
5
5
  "type": "module",
6
- "scripts": { "dev": "vite", "build": "node scripts/build.mjs", "clean:temp": "node scripts/clean-temp.mjs" },
6
+ "scripts": { "dev": "vite", "validate": "node scripts/validate-content.mjs", "build": "npm run validate && node scripts/build.mjs", "clean:temp": "node scripts/clean-temp.mjs" },
7
7
  "dependencies": {
8
8
  "@mdx-js/rollup": "^3.0.1",
9
9
  "clsx": "^2.1.1",
@@ -0,0 +1,48 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ const scriptDir = path.dirname(fileURLToPath(import.meta.url));
6
+ const rootDir = path.resolve(scriptDir, '..');
7
+ const contentPath = path.join(rootDir, 'content', 'compile-runtime.mdx');
8
+ const source = fs.readFileSync(contentPath, 'utf8');
9
+ const failures = [];
10
+ const nodePattern = /<ConceptNode\b([^>]*)>([\s\S]*?)<\/ConceptNode>/g;
11
+ const relationPattern = /<Relation\b([^>]*)\/>/g;
12
+ const attributes = text => Object.fromEntries([...text.matchAll(/([\w-]+)=(?:"([^"]*)"|'([^']*)')/g)].map(match => [match[1], match[2] ?? match[3] ?? '']));
13
+ const nodes = [...source.matchAll(nodePattern)].map(match => ({ ...attributes(match[1]), body: match[2] }));
14
+ const relations = [...source.matchAll(relationPattern)].map(match => attributes(match[1]));
15
+ const ids = new Set(nodes.map(node => node.id));
16
+ const allowedRelations = new Set(['prerequisite', 'causes', 'produces', 'uses', 'implements', 'contrasts', 'depends-on', 'exception-of', 'precedes']);
17
+
18
+ if (!source.includes('<ExplainPage')) failures.push('missing ExplainPage');
19
+ if (!source.includes('<ConceptGraph')) failures.push('missing ConceptGraph');
20
+ if (nodes.filter(node => node.level === 'L0').length !== 1) failures.push('expected exactly one L0 root');
21
+ if (nodes.filter(node => node.level === 'L1').length < 4) failures.push('expected at least four L1 branches');
22
+ if (nodes.length < 15) failures.push(`expected at least 15 nodes, found ${nodes.length}`);
23
+ if (!nodes.some(node => ['L3', 'L4'].includes(node.level))) failures.push('expected L3 or L4 depth');
24
+ if (relations.length < 8) failures.push(`expected at least 8 relations, found ${relations.length}`);
25
+
26
+ for (const node of nodes) {
27
+ if (!node.id) failures.push('node is missing id');
28
+ if (!node.title) failures.push(`${node.id || '<unknown>'} is missing title`);
29
+ if (!node.summary) failures.push(`${node.id || '<unknown>'} is missing summary`);
30
+ if (node.parent && !ids.has(node.parent)) failures.push(`${node.id} references missing parent ${node.parent}`);
31
+ if (!/(<(Definition|Mechanism|Example|Evidence|Boundary|Details|Callout|Counterexample|Glossary|Input|Output)\b)/.test(node.body)) {
32
+ failures.push(`${node.id} lacks a core semantic component`);
33
+ }
34
+ }
35
+
36
+ for (const relation of relations) {
37
+ if (!ids.has(relation.from) || !ids.has(relation.to)) failures.push(`relation references missing node: ${relation.from} -> ${relation.to}`);
38
+ if (!allowedRelations.has(relation.type)) failures.push(`unsupported relation type: ${relation.type}`);
39
+ if (!relation.label) failures.push(`relation ${relation.from} -> ${relation.to} is missing label`);
40
+ }
41
+
42
+ if (failures.length) {
43
+ console.error('Concept Atlas content validation failed:');
44
+ for (const failure of failures) console.error(`- ${failure}`);
45
+ process.exit(1);
46
+ }
47
+
48
+ console.log(`Concept Atlas content validation passed (${nodes.length} nodes, ${relations.length} relations).`);
@@ -22,6 +22,43 @@ High-value verification components: `LearningObjectives`, `KeyQuestion`, `Eviden
22
22
 
23
23
  Presentation components: `Stack`, `Grid`, `Split`, `Tabs`, `Flow`, `Compare`, `DecisionMatrix`, `Timeline`, `Callout`, `Details`, `RelationMap`, `RelationPath`, `Insight`, and `NoteGrid`.
24
24
 
25
+ ## Relation types (whitelist — only these render)
26
+
27
+ Write cross-branch `Relation`s with `type` from this exact list. Any other value renders no styled edge.
28
+
29
+ | type | label | use for |
30
+ | --- | --- | --- |
31
+ | `prerequisite` | 前置知识 | knowledge required before this concept |
32
+ | `causes` | 因果推动 | one concept triggers a state change in another |
33
+ | `produces` | 产出生成 | a stage outputs an artifact or entity |
34
+ | `uses` | 消费使用 | a concept consumes or calls another |
35
+ | `implements` | 实现关系 | a concrete mechanism implements an abstraction |
36
+ | `contrasts` | 对比关系 | side-by-side contrast (no arrowhead) |
37
+ | `depends-on` | 依赖关系 | runtime/effect depends on an external condition |
38
+ | `exception-of` | 异常/反例 | a boundary case, counterexample, or broken assumption |
39
+ | `precedes` | 时序先后 | pipeline or temporal ordering |
40
+
41
+ Do **not** write `parent-child` as a `Relation`; the tree edge is generated automatically from `parent` / `Children`. Add a short `label` to every relation so the graph edge is readable.
42
+
43
+ ## Levels L0–L4
44
+
45
+ | Level | name | role | typical components |
46
+ | --- | --- | --- | --- |
47
+ | `L0` | 全局概览 | system-wide framing and the root claim | `Definition`, `Prerequisite`, `LearningObjectives`, `KeyQuestion`, `Input`/`Output`, `Callout`, `Tabs` |
48
+ | `L1` | 主要阶段 / 子系统 | major lifecycle stage or subsystem | `Definition`, `Input`/`Output`, `Example`, `Children` |
49
+ | `L2` | 局部机制 | concrete mechanism and flow | `Definition`, `Mechanism`, `Details`, `Evidence`, `Invariant`, `Tradeoff`, `FailureMode` |
50
+ | `L3` | 实现细节 | algorithm, data structure, or code | `Definition`, `Example`, `Glossary` |
51
+ | `L4` | 边界与反例 | boundary, exception, or counterexample | `Callout(danger/warn)`, `Example`, `FailureMode` |
52
+
53
+ ## Density targets
54
+
55
+ Match the exemplar (`assets/template/content/compile-runtime.mdx`):
56
+
57
+ - 1 `L0` root, 4–5 `L1` branches, 2–3 children per branch, ~15–25 nodes total.
58
+ - Every key node: 3–6 semantic components; `L3`/`L4` nodes may be leaner but still concrete.
59
+ - At least a few nodes per document carry `Evidence`, `Invariant`, or `FailureMode` with a real command/observation.
60
+ - ~8–15 cross-branch `Relation`s, each with a `label`.
61
+
25
62
  ## Request priorities
26
63
 
27
64
  The portable template covers the core `req.md` contract, node exploration, graph view, semantic relations, search, level/relation filters, URL node state, browsing history, keyboard shortcuts, Mermaid zoom, and responsive rendering. Evidence-oriented components and compact tradeoffs cover the highest-value `request.md` enhancements without adding permanent side panels.
@@ -3,14 +3,52 @@
3
3
  Include this contract when asking an AI to generate or revise a dense explanation:
4
4
 
5
5
  ```text
6
+ 先通读 content/compile-runtime.mdx(黄金样例),再产出;不要跳过、不要直接覆盖。
6
7
  输出语义 MDX,不要输出 CSS、HTML 布局、坐标、SVG 或交互脚本。
7
8
  先给一个 L0 根节点,再用 L1/L2/L3/L4 表达结构、机制、实现细节和边界。
8
9
  父子层级使用 parent/Children;跨分支含义使用 Relation。
10
+ Relation 的 type 只能是:prerequisite, causes, produces, uses, implements, contrasts, depends-on, exception-of, precedes;每条都要带 label。
9
11
  每个关键节点优先提供:summary、Definition、Input/Output、Mechanism、一个 Example,以及 Evidence 或 Boundary。
10
12
  只在确实有帮助时使用组件:Flow 表示顺序,Compare/Tradeoff 表示选择,Timeline 表示时间,Evidence 表示验证,Invariant 表示必须保持的条件,FailureMode 表示故障定位。
11
13
  首屏只保留核心结论和 3–5 个关键事实;次要解释放进 Details。不要为了“看起来丰富”堆卡片。
14
+ 规模对齐样例:1 个根、4–5 个 L1、总计约 15–25 个节点、8–15 条 Relation。
15
+ 证据要具体:真实命令、指标或命名的产物,不要泛泛而谈。
12
16
  ```
13
17
 
18
+ ## Template availability gate
19
+
20
+ Use this gate before the contract above:
21
+
22
+ ```text
23
+ 先确认当前 skill 目录中的 assets/template 可访问,并读取黄金样例与模板源码。
24
+ 如果模板不可访问,立即停止并说明缺少 Concept Atlas 模板;禁止自行用 JSX、HTML、CSS 或普通 Markdown 页面替代。
25
+ 模板可访问后,复制完整模板,只修改 content/compile-runtime.mdx,最后运行 npm run validate 和 npm run build。
26
+ 交付物必须是模板构建出的 dist/index.html。
27
+ ```
28
+
29
+ ## What "good" looks like (from the exemplar)
30
+
31
+ `assets/template/content/compile-runtime.mdx` is the reference standard. Extract these patterns:
32
+
33
+ - **Scale**: 1 `L0` + 5 `L1` + ~20 nodes, descending to `L4`.
34
+ - **Titles are claims, not nouns**: 「缺页风暴与抖动」, 「ABI 破坏:能链接,不等于能调用」.
35
+ - **Every node opens with a one-sentence judgment** in `summary`, then 3–6 components.
36
+ - **Concrete evidence**: `readelf -Ws`, `nm -C`, `objdump -dr app.o`, `.bss`, ASLR, build-id.
37
+ - **Semantic relations carry the cross-branch meaning**: `produces`, `precedes`, `causes`, `depends-on`, `exception-of`, each labeled.
38
+ - **Detail is layered**: first screen = core claim + 3–5 facts; deep detail lives in `Details`, `Tabs`, `Glossary`.
39
+
40
+ ## Density targets
41
+
42
+ | Metric | Target | Thin (failure) |
43
+ | --- | --- | --- |
44
+ | `L0` roots | 1 | 0 or many |
45
+ | `L1` branches | 4–5 | 1–2 |
46
+ | Nodes total | ~15–25 | < 8 |
47
+ | Components per key node | 3–6 | 1 |
48
+ | Cross-branch `Relation`s | 8–15 | 0–3 |
49
+ | Nodes with concrete evidence | several | none |
50
+ | Max depth | `L3`/`L4` | only `L0`/`L1` |
51
+
14
52
  ## Component selection
15
53
 
16
54
  | Information shape | Component |
@@ -29,10 +67,24 @@ Avoid using more than one primary presentation component in a single node unless
29
67
  ## Minimal generation skeleton
30
68
 
31
69
  ```mdx
32
- <ConceptNode id="mechanism" title="机制" level="L2" parent="structure" summary="一句话结论">
70
+ <ConceptNode id="mechanism" title="机制:输入如何在约束下变成输出" level="L2" parent="structure" summary="一句话结论">
33
71
  <Definition>它是什么,以及为什么重要。</Definition>
34
72
  <Mechanism>输入 → 转换 → 输出。</Mechanism>
73
+ <Example title="一个具体案例">名称 + 数值 + 结果,而不是泛指。</Example>
35
74
  <Evidence command="tool --inspect target" observes="验证哪个不变量或产物。" />
36
75
  <Boundary>何时不成立,或哪些实现细节会改变结论。</Boundary>
37
76
  </ConceptNode>
38
77
  ```
78
+
79
+ ## Anti-patterns
80
+
81
+ - **Thin graph**: a handful of nodes with one paragraph each. Fix by adding `L2`/`L3`/`L4` depth.
82
+ - **Noun titles / no judgment**: `"缓存"` instead of `"缓存一致性与内存序"`; `summary` missing or restating the title.
83
+ - **Generic filler**: "性能会受到影响" instead of a named command, metric, or artifact.
84
+ - **Card stacking**: five decorative blocks with no conclusion, evidence, or limitation.
85
+ - **Invented types**: `Relation type="related"` — not in the whitelist, renders nothing.
86
+ - **Prose instead of structure**: cross-branch links described in a paragraph instead of a labeled `Relation`.
87
+
88
+ ## Before returning the result
89
+
90
+ Verify the self-check list in `SKILL.md`. In short: 1 root, claim titles, one-line summaries, 3–6 components per key node, concrete evidence, whitelisted relations, layered detail, no layout in MDX, template builds.