@qnroa/qtype 0.0.4 → 0.0.6
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/CHANGELOG.md +47 -0
- package/CHANGELOG.zh.md +39 -0
- package/dist/cli/commands/publish/build/mermaidPrerender.js +30 -8
- package/package.json +1 -1
- package/templates/en/QTYPE.md +17 -4
- package/templates/zh/QTYPE.md +17 -5
package/CHANGELOG.md
CHANGED
|
@@ -13,6 +13,53 @@ can land in any minor bump (`0.x.0`).
|
|
|
13
13
|
|
|
14
14
|
## [Unreleased]
|
|
15
15
|
|
|
16
|
+
## [0.0.6] - 2026-08-24
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- **`QTYPE.md` template documents nested `material/` folders as
|
|
21
|
+
first-class.** The template already-existing `walkMaterial` recurses
|
|
22
|
+
into `material/<category>/<slug>.md`, and `publish build` even uses
|
|
23
|
+
the first path segment as a fallback `type` when frontmatter omits
|
|
24
|
+
it — but the previous wording ("flat `material/` + `assets/` only",
|
|
25
|
+
rule #9) read as a ban on subdirectories, misleading Agent-driven
|
|
26
|
+
authors into flattening large repos. The template now:
|
|
27
|
+
- shows both flat and nested placements in the Directory Layout
|
|
28
|
+
tree, with a one-line note that both are supported and discovery
|
|
29
|
+
is recursive;
|
|
30
|
+
- adds a **Grouping by folder (optional)** section covering the
|
|
31
|
+
recursive-discovery behavior and the first-segment-as-fallback-`type`
|
|
32
|
+
shortcut (`material/code/hello.md` → `type: code` when frontmatter
|
|
33
|
+
is silent);
|
|
34
|
+
- reworks the Naming section to say each path segment (`<slug>`,
|
|
35
|
+
`<category>`) uses the same kebab-case rules;
|
|
36
|
+
- rewrites rule #9 to enumerate the allowed root-level directories
|
|
37
|
+
(`material/`, `material/assets/`, `raw/`) and cross-reference the
|
|
38
|
+
new subfolder section, replacing the misleading "flat only"
|
|
39
|
+
phrasing.
|
|
40
|
+
Applies to both `templates/en/QTYPE.md` and `templates/zh/QTYPE.md`.
|
|
41
|
+
No runtime code changed; existing repos are unaffected until they
|
|
42
|
+
regenerate their `QTYPE.md` via `qtype repo new` or copy the new
|
|
43
|
+
template in.
|
|
44
|
+
|
|
45
|
+
## [0.0.5] - 2026-08-22
|
|
46
|
+
|
|
47
|
+
### Fixed
|
|
48
|
+
|
|
49
|
+
- **Mermaid pre-render no longer fails under `npx` / hosted CI.**
|
|
50
|
+
`mermaidPrerender.init()` now uses `createRequire(import.meta.url).resolve('mermaid/…')`
|
|
51
|
+
to locate the mermaid ESM, so Node's own module resolver walks the
|
|
52
|
+
actual `node_modules` chain regardless of where qtype was installed
|
|
53
|
+
— user repo, npx cache, Cloudflare Pages build root, monorepo hoist.
|
|
54
|
+
The previous two hard-coded lookup paths remain as fallbacks but
|
|
55
|
+
are no longer the primary strategy. This fixes the
|
|
56
|
+
`mermaid ESM not found in node_modules` error on Cloudflare Pages
|
|
57
|
+
when a deck actually contains ` ```mermaid ` code blocks.
|
|
58
|
+
- **`publish build` now copies `material/assets/**`** into
|
|
59
|
+
`dist/material/assets/` verbatim. Previously the CLI only walked
|
|
60
|
+
`.md` files, so any image the cards referenced via
|
|
61
|
+
`` returned 404 on the deployed site.
|
|
62
|
+
|
|
16
63
|
## [0.0.4] - 2026-08-22
|
|
17
64
|
|
|
18
65
|
### Added
|
package/CHANGELOG.zh.md
CHANGED
|
@@ -12,6 +12,45 @@ English: [CHANGELOG.md](https://www.npmjs.com/package/@qnroa/qtype?activeTab=cod
|
|
|
12
12
|
|
|
13
13
|
## [Unreleased]
|
|
14
14
|
|
|
15
|
+
## [0.0.6] - 2026-08-24
|
|
16
|
+
|
|
17
|
+
### 变更
|
|
18
|
+
|
|
19
|
+
- **`QTYPE.md` 模板把嵌套 `material/` 子目录写成一等公民**。
|
|
20
|
+
`walkMaterial` 一直就是递归的,`publish build` 甚至会用首段路径
|
|
21
|
+
作为 frontmatter 没写 `type` 时的 fallback —— 但之前模板里
|
|
22
|
+
"flat `material/` + `assets/` only"(规则 #9)的措辞读起来像禁止
|
|
23
|
+
子目录,把 Agent 驱动的作者误导成"再大的仓库也只能平铺"。这次:
|
|
24
|
+
- Directory Layout 目录树里同时画出平铺和嵌套两种放法,并加一行
|
|
25
|
+
"两种都支持,发现是递归的";
|
|
26
|
+
- 新增 **按分类分子目录(可选)** 小节,说明递归发现行为,以及
|
|
27
|
+
首段路径当 fallback `type` 的捷径(`material/code/hello.md`
|
|
28
|
+
在 frontmatter 没 `type` 时被视为 `type: code`);
|
|
29
|
+
- 命名节改为"每一段路径(`<slug>`、`<category>`)都用同一套
|
|
30
|
+
kebab-case 规则";
|
|
31
|
+
- 规则 #9 重写为枚举根目录允许的三个位置(`material/` /
|
|
32
|
+
`material/assets/` / `raw/`)并 xref 新的子目录小节,替换掉
|
|
33
|
+
误导性的"平铺"措辞。
|
|
34
|
+
同步改动 `templates/en/QTYPE.md` 和 `templates/zh/QTYPE.md`。
|
|
35
|
+
运行时代码没动;老仓库要拿到新文档需要重跑 `qtype repo new`
|
|
36
|
+
或手动把新模板拷进去。
|
|
37
|
+
|
|
38
|
+
## [0.0.5] - 2026-08-22
|
|
39
|
+
|
|
40
|
+
### 修复
|
|
41
|
+
|
|
42
|
+
- **Mermaid 预渲染在 `npx` / 托管 CI 环境不再失败**。
|
|
43
|
+
`mermaidPrerender.init()` 改用
|
|
44
|
+
`createRequire(import.meta.url).resolve('mermaid/…')`,让 Node
|
|
45
|
+
自己顺着 `node_modules` 链找 mermaid,不管 qtype 是装到用户仓库、
|
|
46
|
+
npx 缓存、Cloudflare Pages build root 还是 monorepo hoist 都能
|
|
47
|
+
找到。之前的两条硬编码查找路径保留作为兜底,但不再是主要策略。
|
|
48
|
+
修复了 deck 里真的有 ` ```mermaid ` 代码块时,Cloudflare Pages 上
|
|
49
|
+
`mermaid ESM not found in node_modules` 报错。
|
|
50
|
+
- **`publish build` 现在会把 `material/assets/**`** 原样拷进
|
|
51
|
+
`dist/material/assets/`。之前 CLI 只遍历 `.md` 文件,导致卡片
|
|
52
|
+
引用的 `` 图片在部署后 404。
|
|
53
|
+
|
|
15
54
|
## [0.0.4] - 2026-08-22
|
|
16
55
|
|
|
17
56
|
### 新增
|
|
@@ -38,15 +38,37 @@ export class MermaidRenderer {
|
|
|
38
38
|
pageDark = null;
|
|
39
39
|
pageLight = null;
|
|
40
40
|
async init() {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
// Ask Node's own module resolver where mermaid actually lives. It
|
|
42
|
+
// walks the `node_modules` chain from this file up, so it works
|
|
43
|
+
// regardless of where the caller installed qtype:
|
|
44
|
+
//
|
|
45
|
+
// * user repo with `npm install @qnroa/qtype` → resolves in
|
|
46
|
+
// `<user>/node_modules/mermaid`
|
|
47
|
+
// * `npx @qnroa/qtype` on any host (Cloudflare, → resolves in
|
|
48
|
+
// Vercel, GitHub Pages) that hoists deps into the npx cache
|
|
49
|
+
// an npx cache
|
|
50
|
+
// * monorepo with hoisted deps → resolves in
|
|
51
|
+
// the hoisted root
|
|
52
|
+
//
|
|
53
|
+
// The two hard-coded fallbacks below only fire if Node's resolver
|
|
54
|
+
// fails entirely (older Node, exotic packaging), which shouldn't
|
|
55
|
+
// happen in any supported deployment.
|
|
45
56
|
let mermaidEsm = null;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
57
|
+
try {
|
|
58
|
+
const { createRequire } = await import('node:module');
|
|
59
|
+
const req = createRequire(import.meta.url);
|
|
60
|
+
mermaidEsm = req.resolve('mermaid/dist/mermaid.esm.min.mjs');
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
const candidates = [
|
|
64
|
+
path.resolve(__dirname, '..', '..', '..', '..', '..', 'node_modules', 'mermaid', 'dist', 'mermaid.esm.min.mjs'),
|
|
65
|
+
path.resolve(process.cwd(), 'node_modules', 'mermaid', 'dist', 'mermaid.esm.min.mjs'),
|
|
66
|
+
];
|
|
67
|
+
for (const c of candidates) {
|
|
68
|
+
if (fs.existsSync(c)) {
|
|
69
|
+
mermaidEsm = c;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
50
72
|
}
|
|
51
73
|
}
|
|
52
74
|
if (!mermaidEsm) {
|
package/package.json
CHANGED
package/templates/en/QTYPE.md
CHANGED
|
@@ -41,7 +41,8 @@ The whole document is organized into four modules: **Concepts / Format / Operati
|
|
|
41
41
|
├── qtype.config.json
|
|
42
42
|
├── material/
|
|
43
43
|
│ ├── .gitkeep
|
|
44
|
-
│ ├── <slug>.md
|
|
44
|
+
│ ├── <slug>.md # flat placement — fine
|
|
45
|
+
│ ├── <category>/<slug>.md # nested placement — also fine
|
|
45
46
|
│ └── assets/<material-slug>/
|
|
46
47
|
└── raw/
|
|
47
48
|
├── .gitkeep
|
|
@@ -49,6 +50,8 @@ The whole document is organized into four modules: **Concepts / Format / Operati
|
|
|
49
50
|
└── assets/<raw-slug>/
|
|
50
51
|
```
|
|
51
52
|
|
|
53
|
+
**Flat and nested placements are both supported.** All `.md` under `material/` are discovered recursively. Choose whichever fits the repo — small repos are usually flat, larger ones group by category folder.
|
|
54
|
+
|
|
52
55
|
---
|
|
53
56
|
|
|
54
57
|
## Format
|
|
@@ -231,11 +234,21 @@ sqrt(pi)
|
|
|
231
234
|
|
|
232
235
|
### Naming
|
|
233
236
|
|
|
234
|
-
Material files: `material/<slug>.md`
|
|
235
|
-
|
|
237
|
+
Material files: `material/<slug>.md` — or `material/<category>/<slug>.md` if grouping by folder.
|
|
238
|
+
|
|
239
|
+
- Each path segment (`<slug>`, `<category>`) uses the same rules: kebab-case, ASCII lowercase + hyphens, ≤ 60 chars
|
|
236
240
|
- Chinese topics: use English translation or pinyin
|
|
237
241
|
- Collision: append `-2` / `-3`
|
|
238
242
|
|
|
243
|
+
### Grouping by folder (optional)
|
|
244
|
+
|
|
245
|
+
`material/` may contain category subfolders. Two things to know when you use them:
|
|
246
|
+
|
|
247
|
+
- **Discovery is recursive.** All `.md` files under `material/` are picked up regardless of depth. Nested folders don't hide their contents.
|
|
248
|
+
- **The first path segment is a fallback `type`.** When a material's frontmatter omits `type`, the first folder name is used instead — e.g. a file at `material/code/hello.md` with no `type:` line is treated as `type: code`. This is a shortcut for repos organized by type folder; explicit `type:` in frontmatter always wins.
|
|
249
|
+
|
|
250
|
+
Group by folder when the repo has many materials of clearly different subjects (e.g. `skills/`, `experience/`, `projects/`, `code/`). Stay flat when there are only a handful of files — extra folders add friction without payoff.
|
|
251
|
+
|
|
239
252
|
### Links
|
|
240
253
|
|
|
241
254
|
- **Markdown link syntax only**, no Wikilinks
|
|
@@ -272,7 +285,7 @@ Ingest, Update, Quiz-gen, Cascade, Check, Level-up — semantics as before. Key
|
|
|
272
285
|
6. **No Wikilinks**
|
|
273
286
|
7. **No absolute paths**
|
|
274
287
|
8. **Never `git commit` / `push`** — the user commits
|
|
275
|
-
9. **No unspec'd directories** —
|
|
288
|
+
9. **No unspec'd directories** — only `material/` (may contain category subfolders, see "Grouping by folder"), `material/assets/`, and `raw/` are allowed at the repo root
|
|
276
289
|
10. **Never fabricate IPA / gloss / translation** — leave blank, report in log
|
|
277
290
|
11. **One `type` per material** — no mixing
|
|
278
291
|
12. **No card-level frontmatter** — per-card info lives in markdown structure
|
package/templates/zh/QTYPE.md
CHANGED
|
@@ -43,8 +43,9 @@ qtype 是一个以 Markdown 为源、以 OS 键盘(含中文 IME)为输入
|
|
|
43
43
|
├── qtype.config.json # 用户可调设置
|
|
44
44
|
├── material/ # 你写的素材
|
|
45
45
|
│ ├── .gitkeep
|
|
46
|
-
│ ├── <slug>.md
|
|
47
|
-
│
|
|
46
|
+
│ ├── <slug>.md # 平铺放法 —— 可以
|
|
47
|
+
│ ├── <category>/<slug>.md # 按分类嵌套 —— 也可以
|
|
48
|
+
│ └── assets/ # 素材引用的图片
|
|
48
49
|
│ └── <material-slug>/
|
|
49
50
|
└── raw/ # (可选)用户扔进来的原始材料
|
|
50
51
|
├── .gitkeep
|
|
@@ -52,6 +53,8 @@ qtype 是一个以 Markdown 为源、以 OS 键盘(含中文 IME)为输入
|
|
|
52
53
|
└── assets/
|
|
53
54
|
```
|
|
54
55
|
|
|
56
|
+
**平铺和嵌套都支持**:`material/` 下所有 `.md` 会被递归发现,深几层都能扫到。文件少时平铺就够了,文件多时按分类开子目录更清爽。
|
|
57
|
+
|
|
55
58
|
---
|
|
56
59
|
|
|
57
60
|
## 格式
|
|
@@ -259,12 +262,21 @@ sqrt(pi)
|
|
|
259
262
|
|
|
260
263
|
### 命名
|
|
261
264
|
|
|
262
|
-
**素材文件名**:`material/<slug>.md`
|
|
265
|
+
**素材文件名**:`material/<slug>.md` —— 或者按分类嵌套时 `material/<category>/<slug>.md`。
|
|
263
266
|
|
|
264
|
-
-
|
|
267
|
+
- 每一段路径(`<slug>`、`<category>`)都用同一套规则:kebab-case,小写,英文字母和短横线,最长 60 字符
|
|
265
268
|
- 中文主题用英译或拼音
|
|
266
269
|
- 同名冲突:末尾追加 `-2` / `-3`
|
|
267
270
|
|
|
271
|
+
### 按分类分子目录(可选)
|
|
272
|
+
|
|
273
|
+
`material/` 下可以开分类子目录。启用时需要知道两件事:
|
|
274
|
+
|
|
275
|
+
- **发现是递归的**。`material/` 下所有 `.md` 文件不论深度都会被扫到,嵌套目录不会被跳过
|
|
276
|
+
- **首段路径充当 `type` 的 fallback**。如果一个 material 的 frontmatter 没有写 `type`,第一段目录名会被当作 type —— 比如 `material/code/hello.md` 不写 `type:` 会被视为 `type: code`。这是给"按 type 分目录"的仓库的捷径;只要 frontmatter 里显式写了 `type`,永远以 frontmatter 为准。
|
|
277
|
+
|
|
278
|
+
素材数量多、主题差异明显时(比如 `skills/` / `experience/` / `projects/` / `code/`)用子目录归类;素材只有几个时保持平铺就好,多开一层目录只会增摩擦不增收益。
|
|
279
|
+
|
|
268
280
|
### 链接
|
|
269
281
|
|
|
270
282
|
- **只用 Markdown link**,不用 Wikilink
|
|
@@ -330,7 +342,7 @@ updated: YYYY-MM-DD
|
|
|
330
342
|
6. **不用 Wikilink**
|
|
331
343
|
7. **不绝对路径**
|
|
332
344
|
8. **不主动 git commit / push**
|
|
333
|
-
9.
|
|
345
|
+
9. **不建规则外的目录**:仓库根下只允许 `material/`(内部可按分类开子目录,见"按分类分子目录")、`material/assets/`、`raw/`
|
|
334
346
|
10. **不凭空造 IPA / 释义 / 翻译**:不确定的宁可空着
|
|
335
347
|
11. **一个 material 只有一个 type**:不能混
|
|
336
348
|
12. **没有 card-level frontmatter**:所有 per-card 信息都用 markdown 结构表达
|