r-markdown-cli 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,334 @@
1
+ # Rich Markdown Blocks (v0.2)
2
+
3
+ Complete reference for the 14 blocks supported by the current renderer
4
+ (`packages/blocks-core`). Use the smallest set that conveys meaning. Prefer
5
+ plain Markdown for narrative.
6
+
7
+ Identifiers are case-sensitive. Attribute order does not matter; positional
8
+ arguments come immediately after the block name.
9
+
10
+ ---
11
+
12
+ ## chart
13
+
14
+ Compact data visualization. Each line is `{label} {value} [{value2} ...]`,
15
+ space-separated. Multi-value rows become multi-series.
16
+
17
+ ```rmd
18
+ :::chart bar title="P99 latency (ms)" emphasis=primary
19
+ TokenBucket 23
20
+ LeakyBucket 19
21
+ SlidingWindow 41
22
+ :::
23
+ ```
24
+
25
+ Types (positional, required): `bar`, `line`, `pie`, `scatter`, `radar`, `area`,
26
+ `donut`, `heatmap`. `pie` requires single value per row.
27
+
28
+ | attribute | values | default | notes |
29
+ |---|---|---|---|
30
+ | `title` | string | empty | chart title |
31
+ | `x` / `y` / `y2` | string | null | axis labels (use `y2` for dual axis) |
32
+ | `legend` | `top` / `bottom` / `left` / `right` / `none` | `bottom` | legend position |
33
+ | `tooltip` | `true` / `false` | `true` | hover tooltip |
34
+ | `emphasis` | `primary` / `secondary` / `none` | `none` | theme-controlled accent |
35
+
36
+ Multi-series + dual axis:
37
+
38
+ ```rmd
39
+ :::chart area title="Revenue vs MAU" y="Revenue($M)" y2="MAU(K)" legend=top
40
+ Q1_2025 120 40
41
+ Q2_2025 150 45
42
+ Q3_2025 180 60
43
+ Q4_2025 240 85
44
+ :::
45
+ ```
46
+
47
+ ---
48
+
49
+ ## grid
50
+
51
+ Multi-column layout. Cells separated by `---` on their own line.
52
+
53
+ ```rmd
54
+ :::grid 3
55
+ ### Option A
56
+ Fast, simple.
57
+ ---
58
+ ### Option B
59
+ Flexible, heavier.
60
+ ---
61
+ ### Option C
62
+ Safe, slower.
63
+ :::
64
+ ```
65
+
66
+ Positional: column count (1–12) or comma-separated responsive breakpoints
67
+ (e.g. `1,2,4` for mobile/tablet/desktop).
68
+
69
+ | attribute | values | default | notes |
70
+ |---|---|---|---|
71
+ | `gap` | `sm` / `md` / `lg` | `md` | column spacing |
72
+ | `layout` | `default` / `masonry` | `default` | masonry uses CSS columns (no JS) |
73
+
74
+ `grid` cannot nest inside another `grid`. Maximum 12 cells.
75
+
76
+ ---
77
+
78
+ ## callout
79
+
80
+ Emphasized note, decision, or warning.
81
+
82
+ ```rmd
83
+ :::callout tip title="Recommendation"
84
+ Pick token bucket for burst-friendly traffic.
85
+ :::
86
+ ```
87
+
88
+ Positional kind: `info` / `tip` / `warning` / `danger` / `success`.
89
+ Optional `title`.
90
+
91
+ ---
92
+
93
+ ## slider
94
+
95
+ Reader-adjustable number. Pair with `export` to copy the tuned value back.
96
+
97
+ ```rmd
98
+ :::slider name=capacity min=10 max=1000 step=10 default=200 unit=req
99
+ :::
100
+ ```
101
+
102
+ Range slider (two values):
103
+
104
+ ```rmd
105
+ :::slider name=qps_range label="QPS window" min=10 max=1000 step=10 default=100,500 scale=log marks=10,100,500,1000
106
+ :::
107
+ ```
108
+
109
+ Required: `name` (matches `^[a-zA-Z_][a-zA-Z0-9_]*$`), `min`, `max` (`max > min`).
110
+
111
+ | attribute | type | default | notes |
112
+ |---|---|---|---|
113
+ | `step` | number > 0 | `1` | |
114
+ | `default` | number or `n,m` | `min` | range slider when comma value |
115
+ | `unit` | string | empty | suffix shown after value |
116
+ | `label` | string | name | display label |
117
+ | `scale` | `linear` / `log` / `pow` | `linear` | |
118
+ | `marks` | comma-separated numbers | empty | discrete snap points |
119
+
120
+ Slider names must be unique per document. Block body must be empty.
121
+
122
+ ---
123
+
124
+ ## export
125
+
126
+ Copy/export template. References slider values with `{{name}}` and supports
127
+ `{{name | int}}` formatting.
128
+
129
+ ```rmd
130
+ :::export label="Copy config" format=text
131
+ rate_limiter:
132
+ capacity: {{capacity | int}}
133
+ refill_rate: {{refill_rate | int}}
134
+ :::
135
+ ```
136
+
137
+ | attribute | values | default | notes |
138
+ |---|---|---|---|
139
+ | `label` | string | `复制` | button text |
140
+ | `format` | `text` / `markdown` / `json` | `text` | clipboard MIME |
141
+
142
+ Unknown variables render as `[未定义:name]` and warn in the console.
143
+
144
+ ---
145
+
146
+ ## flow
147
+
148
+ Directed flow with linear and branching paths.
149
+
150
+ ```rmd
151
+ :::flow direction=lr
152
+ Design -> Review -> Canary -> Full rollout
153
+ Canary -> Incident -> Rollback
154
+ :::
155
+ ```
156
+
157
+ Each line: `Node -> Node -> ...`. Same-name nodes merge.
158
+ `direction`: `lr` (default) or `tb`.
159
+
160
+ ---
161
+
162
+ ## diff
163
+
164
+ Unified-diff style. `+` add, `-` remove, leading space context.
165
+ `@注: ...` adds an inline note (placed at end of `+`/`-` line).
166
+
167
+ ```rmd
168
+ :::diff lang=python title="Limiter change"
169
+ - @rate_limit(window=60, max=100)
170
+ + @token_bucket(capacity=200, refill=50) @注: adds burst protection
171
+ :::
172
+ ```
173
+
174
+ ---
175
+
176
+ ## tabs
177
+
178
+ Multiple views in one area. `@label` on its own line starts a panel.
179
+
180
+ ```rmd
181
+ :::tabs default=Summary
182
+ @Summary
183
+ Plain-language explanation.
184
+ @Details
185
+ Implementation details.
186
+ :::
187
+ ```
188
+
189
+ Cannot nest inside another `tabs`.
190
+
191
+ ---
192
+
193
+ ## timeline
194
+
195
+ Vertical or horizontal sequence of dated events.
196
+
197
+ ```rmd
198
+ :::timeline
199
+ @ 2026-01-01 [title="Kickoff"] [status="success"]
200
+ Initial planning done, team formed.
201
+
202
+ @ 2026-03-15 [title="v0.1"] [status="success"]
203
+ Core parser shipped.
204
+
205
+ @ 2026-05-10 [title="v0.2"] [status="pending"]
206
+ Advanced blocks + masonry grid.
207
+ :::
208
+ ```
209
+
210
+ Each item begins with `@ {time} [title="..."] [status="..."]` on its own line.
211
+ Body is normal Markdown until the next `@`.
212
+
213
+ `status`: `success` / `warning` / `danger` / `pending` / `default`.
214
+ `direction`: `vertical` (default) or `horizontal`.
215
+
216
+ ---
217
+
218
+ ## kanban
219
+
220
+ Columns of cards. `@ {column title}` on its own line starts a column.
221
+
222
+ ```rmd
223
+ :::kanban
224
+ @ Todo
225
+ - [ ] Write the report
226
+ - [ ] Run perf tests
227
+
228
+ @ In progress
229
+ - [x] Update parser
230
+ - [x] Refactor theme
231
+
232
+ @ Done
233
+ * All conformance tests pass
234
+ * Carousel uses pure CSS
235
+ :::
236
+ ```
237
+
238
+ Use lists (Markdown task lists or bullets) for cards.
239
+
240
+ ---
241
+
242
+ ## details
243
+
244
+ Collapsible block. Wraps a native `<details>`.
245
+
246
+ ```rmd
247
+ :::details title="Architecture changelog" open=true
248
+ 1. Parser: custom rule dispatch on top of markdown-it.
249
+ 2. Validator: 20+ new rules for new tree shapes.
250
+ 3. Renderer: pure HTML output, no React/Vue dependency.
251
+ :::
252
+ ```
253
+
254
+ | attribute | values | default |
255
+ |---|---|---|
256
+ | `title` | string | empty |
257
+ | `open` | `true` / `false` | `false` |
258
+
259
+ ---
260
+
261
+ ## carousel
262
+
263
+ Touch / scroll-snap carousel. Cells separated by `---`.
264
+
265
+ ```rmd
266
+ :::carousel autoplay=true interval=4000
267
+ ### Slide 1
268
+ First content
269
+ ---
270
+ ### Slide 2
271
+ Second content
272
+ :::
273
+ ```
274
+
275
+ | attribute | values | default |
276
+ |---|---|---|
277
+ | `autoplay` | `true` / `false` | `false` |
278
+ | `interval` | number (ms) | `3000` |
279
+
280
+ ---
281
+
282
+ ## embed
283
+
284
+ Embed external media (video, map, app). Aspect ratio is theme-controlled.
285
+
286
+ ```rmd
287
+ :::embed type=video id="https://www.youtube.com/embed/XXXX" aspect-ratio="16/9"
288
+ :::
289
+ ```
290
+
291
+ | attribute | values | default |
292
+ |---|---|---|
293
+ | `type` | `video` / `map` / `iframe` | `unknown` |
294
+ | `id` | URL or external id | empty |
295
+ | `aspect-ratio` | `16/9` / `4/3` / etc. | null |
296
+
297
+ Block body is ignored.
298
+
299
+ ---
300
+
301
+ ## math
302
+
303
+ LaTeX math block. Renderer outputs as math container; the active theme
304
+ decides whether to typeset (KaTeX/MathJax) or fall back to monospace.
305
+
306
+ ```rmd
307
+ :::math
308
+ \mathcal{L} = \sum_{i=1}^{N} \left( y_i \log(\hat{y}_i) + (1-y_i) \log(1-\hat{y}_i) \right)
309
+ :::
310
+ ```
311
+
312
+ ---
313
+
314
+ ## Choosing Blocks
315
+
316
+ | Goal | Suggested blocks |
317
+ |---|---|
318
+ | Compare options | `grid` + `chart` + `callout` |
319
+ | Explain a PR | `diff` + `tabs` + `callout` |
320
+ | Tunable prototype | `slider` + `export` |
321
+ | Release / workflow | `flow` + `callout` + `timeline` |
322
+ | Status report | `chart` + `timeline` + `kanban` |
323
+ | Research brief | `chart` + `grid` + `callout` + `details` |
324
+ | Long doc with appendix | `details` + `tabs` |
325
+ | Visual gallery | `carousel` + `grid layout=masonry` |
326
+ | Math / formal | `math` + `callout` |
327
+
328
+ ## Don't
329
+
330
+ - Don't add CSS, color, pixel, or font attributes — they belong to the theme.
331
+ - Don't nest `grid` in `grid`, or `tabs` in `tabs`.
332
+ - Don't put body content inside `:::slider` or `:::embed`.
333
+ - Don't invent positional arguments beyond what's listed here.
334
+ - Don't use experimental block names that aren't in this file.
@@ -0,0 +1,92 @@
1
+ ---
2
+ name: rich-markdown
3
+ description: Generate Rich Markdown (.rmd) documents and self-contained Rich Markdown HTML artifacts for AI-authored reports, plans, comparisons, PR explanations, prototypes, research briefs, timelines, kanbans, and tunable interactive demos. Use when the user asks for rmd, Rich Markdown, rich interactive Markdown, token-efficient rich docs, shareable AI documents, charts, sliders, export/copy blocks, flow diagrams, timelines, kanban boards, collapsible details, carousels, embeds, math blocks, or wants a Codex response rendered with the local Rich Markdown renderer.
4
+ ---
5
+
6
+ # Rich Markdown
7
+
8
+ Use this skill when the user wants a rich, readable, interactive document
9
+ instead of plain Markdown or hand-written HTML. The local renderer
10
+ (`packages/cli`) turns `.rmd` source into a self-contained HTML artifact.
11
+
12
+ ## Output Choice
13
+
14
+ - User wants a file or artifact: write a `.rmd` file first, then build HTML.
15
+ - User wants something viewable inside Codex or shareable as one file:
16
+ build a self-contained HTML artifact from the `.rmd`.
17
+ - User wants source only: output `.rmd` source, do not build HTML.
18
+ - User wants a multi-file site (assets they can inspect or host): use `--mode split`.
19
+
20
+ ## Workflow
21
+
22
+ 1. Choose the smallest useful block set from `references/blocks.md`.
23
+ Plain Markdown for narrative, `:::` blocks only when they add density,
24
+ structure, or interaction.
25
+ 2. Write the `.rmd` to a sensible path under `examples/` (or wherever the
26
+ user asks). Always include a YAML frontmatter with at least `title`.
27
+ 3. Validate the source. Fail fast if the parser reports issues:
28
+
29
+ ```bash
30
+ npm run rmd -- validate path/to/doc.rmd
31
+ ```
32
+
33
+ 4. Build for the chosen consumption mode:
34
+
35
+ ```bash
36
+ # Single self-contained HTML — best default for Codex Desktop / sharing
37
+ npm run rmd -- build path/to/doc.rmd --mode self-contained --out path/to/doc.html
38
+
39
+ # CDN-loaded variant — small artifact, requires network at view time
40
+ npm run rmd -- build path/to/doc.rmd --mode cdn --version 0.1.0 --out path/to/doc.html
41
+
42
+ # Split mode — index.html + rmd.min.js + themes/<name>.css for inspection / hosting
43
+ npm run rmd -- build path/to/doc.rmd --mode split --out path/to/dist/index.html
44
+ ```
45
+
46
+ 5. For local interactive preview (will start a local HTTP server):
47
+
48
+ ```bash
49
+ npm run rmd -- open path/to/doc.rmd --port 0 --no-open true
50
+ ```
51
+
52
+ 6. Report the generated HTML path back to the user.
53
+
54
+ ## Rules
55
+
56
+ - Never put colors, pixels, fonts, or layout styling into `.rmd`. Use
57
+ `emphasis=primary|secondary|none` and let the theme decide visuals.
58
+ - Keep source diff clean: one semantic edit should touch only nearby lines.
59
+ Do not reorder unrelated attributes or rewrite whole files for tiny changes.
60
+ - Unknown or fragile content (rare formats, edge cases) must fall back to
61
+ plain Markdown rather than invented block names.
62
+ - Use `:::slider` + `:::export` whenever the reader should tune values and
63
+ copy the result back to Codex or to code.
64
+ - Validation failures are not warnings: fix the source, do not ship the file.
65
+
66
+ ## Block Selection Cheatsheet
67
+
68
+ Map the user's intent to the smallest block set that delivers value:
69
+
70
+ | Intent | Blocks |
71
+ |---|---|
72
+ | Compare options / approaches | `grid` + `chart` + `callout` |
73
+ | PR / code review explainer | `diff` + `tabs` + `callout` |
74
+ | Tunable prototype | `slider` + `export` |
75
+ | Release / workflow | `flow` + `callout` + `timeline` |
76
+ | Project status report | `chart` + `timeline` + `kanban` |
77
+ | Research brief | `chart` + `grid` + `details` |
78
+ | Showcase / gallery | `carousel` + `grid layout=masonry` |
79
+ | Long doc with appendix | `details` + `tabs` |
80
+ | Math / formal explanation | `math` + `callout` |
81
+
82
+ Full block reference: `references/blocks.md`.
83
+ Build mode reference: `references/artifacts.md`.
84
+
85
+ ## Default Recipe
86
+
87
+ For Codex-visible rich output:
88
+
89
+ 1. Write `examples/<short-name>.rmd` with appropriate blocks.
90
+ 2. `npm run rmd -- validate examples/<short-name>.rmd`
91
+ 3. `npm run rmd -- build examples/<short-name>.rmd --mode self-contained --out examples/<short-name>.html`
92
+ 4. Return `examples/<short-name>.html` as the deliverable.
@@ -0,0 +1,8 @@
1
+ interface:
2
+ display_name: "Rich Markdown"
3
+ short_description: "Generate interactive .rmd documents"
4
+ brand_color: "#2563EB"
5
+ default_prompt: "Use $rich-markdown to create a self-contained interactive .rmd HTML report."
6
+
7
+ policy:
8
+ allow_implicit_invocation: true
@@ -0,0 +1,107 @@
1
+ # Rich Markdown Artifacts
2
+
3
+ ## Source First
4
+
5
+ Always write `.rmd` source first. It is the canonical artifact and must remain
6
+ readable in plain Markdown tools. The HTML build is a derived view.
7
+
8
+ ## Three Build Modes
9
+
10
+ The CLI supports three output modes via `--mode`. Pick based on where the
11
+ artifact will be viewed.
12
+
13
+ ### self-contained (default)
14
+
15
+ ```bash
16
+ npm run rmd -- build path/to/doc.rmd --mode self-contained --out path/to/doc.html
17
+ ```
18
+
19
+ Produces a single HTML file with the renderer, theme CSS, runtime, and `.rmd`
20
+ source all inlined. Zero external dependencies. Best for:
21
+
22
+ - Codex Desktop (loads inside the app sandbox)
23
+ - Email attachments
24
+ - Offline / archival
25
+ - S3 / static-host one-click sharing
26
+ - Any place where the consumer cannot install or fetch the renderer
27
+
28
+ Tradeoff: file size is larger (~50–150 KB) because the renderer ships in-line.
29
+
30
+ ### cdn
31
+
32
+ ```bash
33
+ npm run rmd -- build path/to/doc.rmd --mode cdn --version 0.1.0 --out path/to/doc.html
34
+ ```
35
+
36
+ Produces a small HTML shell containing only the `.rmd` source and a script tag
37
+ pointing at a pinned CDN version. Best for:
38
+
39
+ - Blog posts / Notion / web pages where the renderer can be fetched from CDN
40
+ - Cases where token economy of the artifact itself matters most
41
+
42
+ Requires `--version` to be a complete semver (e.g. `0.1.0`); `latest` is rejected
43
+ because sandboxed viewers must not depend on a moving CDN target.
44
+
45
+ ### split
46
+
47
+ ```bash
48
+ npm run rmd -- build path/to/doc.rmd --mode split --out path/to/dist/index.html
49
+ ```
50
+
51
+ Writes the HTML alongside `rmd.min.js` and `themes/<theme>.css` as separate
52
+ files. Best for:
53
+
54
+ - Local development / hot reload
55
+ - Custom hosting where you want to serve the renderer from your own origin
56
+ - Inspecting the generated assets
57
+
58
+ Cannot be opened in sandboxed environments (Codex Desktop artifact, email)
59
+ because relative asset paths will 404.
60
+
61
+ ## Validation
62
+
63
+ Always validate before building or returning to the user:
64
+
65
+ ```bash
66
+ npm run rmd -- validate path/to/doc.rmd
67
+ ```
68
+
69
+ If validation fails, fix the source. Do not ship a file that fails validation.
70
+
71
+ ## Recommended Default for Codex
72
+
73
+ For most Codex-driven requests:
74
+
75
+ ```bash
76
+ npm run rmd -- validate examples/my-doc.rmd
77
+ npm run rmd -- build examples/my-doc.rmd --mode self-contained --out examples/my-doc.html
78
+ ```
79
+
80
+ Return the path `examples/my-doc.html`.
81
+
82
+ ## Local Preview
83
+
84
+ When the user wants to interact with the artifact during the session:
85
+
86
+ ```bash
87
+ npm run rmd -- open path/to/doc.rmd --port 0 --host 127.0.0.1 --no-open true
88
+ ```
89
+
90
+ The CLI prints the bound URL. Use `--no-open true` so the agent does not try
91
+ to launch a desktop browser.
92
+
93
+ ## Frontmatter Tips
94
+
95
+ Every `.rmd` should start with a frontmatter block. Useful fields:
96
+
97
+ ```yaml
98
+ ---
99
+ title: Quarterly Roadmap # Required for sharing & metadata
100
+ theme: default # Theme id; only `default` ships today
101
+ share: private # private / team / public
102
+ description: Short summary... # Used by share cards / OG
103
+ lang: zh-CN # BCP 47 — affects type/font defaults
104
+ ---
105
+ ```
106
+
107
+ Unknown fields are kept but ignored; custom fields should use `x-` prefix.