@qnroa/qtype 0.0.1

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.
Files changed (110) hide show
  1. package/CHANGELOG.md +97 -0
  2. package/CHANGELOG.zh.md +82 -0
  3. package/LICENSE +201 -0
  4. package/README.md +113 -0
  5. package/README.zh.md +114 -0
  6. package/dist/cli/bootstrap.js +190 -0
  7. package/dist/cli/commands/check/action.js +56 -0
  8. package/dist/cli/commands/check/i18n.js +26 -0
  9. package/dist/cli/commands/check/index.js +20 -0
  10. package/dist/cli/commands/config/action.js +236 -0
  11. package/dist/cli/commands/config/i18n.js +64 -0
  12. package/dist/cli/commands/config/index.js +72 -0
  13. package/dist/cli/commands/content/index.js +22 -0
  14. package/dist/cli/commands/content/lint/action.js +102 -0
  15. package/dist/cli/commands/content/lint/i18n.js +32 -0
  16. package/dist/cli/commands/content/lint/index.js +19 -0
  17. package/dist/cli/commands/content/search/action.js +64 -0
  18. package/dist/cli/commands/content/search/i18n.js +20 -0
  19. package/dist/cli/commands/content/search/index.js +24 -0
  20. package/dist/cli/commands/content/validate/action.js +145 -0
  21. package/dist/cli/commands/content/validate/i18n.js +32 -0
  22. package/dist/cli/commands/content/validate/index.js +19 -0
  23. package/dist/cli/commands/index.js +19 -0
  24. package/dist/cli/commands/init/index.js +53 -0
  25. package/dist/cli/commands/pack/i18n.js +20 -0
  26. package/dist/cli/commands/pack/index.js +48 -0
  27. package/dist/cli/commands/plugin/i18n.js +28 -0
  28. package/dist/cli/commands/plugin/index.js +41 -0
  29. package/dist/cli/commands/publish/build/action.js +208 -0
  30. package/dist/cli/commands/publish/build/i18n.js +50 -0
  31. package/dist/cli/commands/publish/build/index.js +24 -0
  32. package/dist/cli/commands/publish/build/mermaidPass.js +93 -0
  33. package/dist/cli/commands/publish/build/mermaidPrerender.js +199 -0
  34. package/dist/cli/commands/publish/index.js +21 -0
  35. package/dist/cli/commands/publish/init/action.js +74 -0
  36. package/dist/cli/commands/publish/init/i18n.js +22 -0
  37. package/dist/cli/commands/publish/init/index.js +26 -0
  38. package/dist/cli/commands/publish/password/action.js +158 -0
  39. package/dist/cli/commands/publish/password/i18n.js +44 -0
  40. package/dist/cli/commands/publish/password/index.js +35 -0
  41. package/dist/cli/commands/publish/serve/action.js +117 -0
  42. package/dist/cli/commands/publish/serve/i18n.js +32 -0
  43. package/dist/cli/commands/publish/serve/index.js +37 -0
  44. package/dist/cli/commands/repo/index.js +19 -0
  45. package/dist/cli/commands/repo/new/action.js +98 -0
  46. package/dist/cli/commands/repo/new/i18n.js +46 -0
  47. package/dist/cli/commands/repo/new/index.js +57 -0
  48. package/dist/cli/commands/repo/sync/action.js +202 -0
  49. package/dist/cli/commands/repo/sync/i18n.js +44 -0
  50. package/dist/cli/commands/repo/sync/index.js +47 -0
  51. package/dist/cli/commands/repo/templates.js +87 -0
  52. package/dist/cli/i18n/index.js +141 -0
  53. package/dist/cli/i18n/shared.js +142 -0
  54. package/dist/cli/index.js +79 -0
  55. package/dist/cli/registry/command.js +1 -0
  56. package/dist/cli/registry/commander-i18n.js +76 -0
  57. package/dist/cli/registry/help.js +142 -0
  58. package/dist/cli/registry/mount.js +71 -0
  59. package/dist/cli/utils/output.js +92 -0
  60. package/dist/cli/utils/paths.js +13 -0
  61. package/dist/cli/utils/prompt.js +72 -0
  62. package/dist/cli/utils/repoGuard.js +41 -0
  63. package/dist/core/encrypt.js +113 -0
  64. package/dist/core/index.js +8 -0
  65. package/dist/core/keystroke/asciiMap.js +39 -0
  66. package/dist/core/keystroke/chineseMap.js +32 -0
  67. package/dist/core/keystroke/fullwidthMap.js +41 -0
  68. package/dist/core/keystroke/index.js +22 -0
  69. package/dist/core/keystroke/textNormalize.js +68 -0
  70. package/dist/core/keystroke/types.js +1 -0
  71. package/dist/core/parser/frontmatter.js +58 -0
  72. package/dist/core/parser/index.js +2 -0
  73. package/dist/core/parser/parseMaterial.js +42 -0
  74. package/dist/core/types.js +1 -0
  75. package/dist/core/typing/engine.js +112 -0
  76. package/dist/core/typing/index.js +2 -0
  77. package/dist/core/typing/metrics.js +20 -0
  78. package/dist/store/index.js +44 -0
  79. package/dist/store/kv.js +276 -0
  80. package/dist/store/storage/browser.js +61 -0
  81. package/dist/store/storage/json.js +113 -0
  82. package/dist/store/storage/memory.js +24 -0
  83. package/dist/store/types.js +47 -0
  84. package/dist/store/validators.js +71 -0
  85. package/dist/view/assets/index-DBABH3dG.js +111 -0
  86. package/dist/view/assets/index-RTLZ-zOC.css +1 -0
  87. package/dist/view/index.html +14 -0
  88. package/dist/view/qtype-logo.svg +49 -0
  89. package/dist/view/qtype-mark.svg +21 -0
  90. package/docs/README.md +23 -0
  91. package/docs/README.zh.md +20 -0
  92. package/docs/en/authoring.md +138 -0
  93. package/docs/en/cli-reference.md +171 -0
  94. package/docs/zh/authoring.md +131 -0
  95. package/docs/zh/cli-reference.md +162 -0
  96. package/package.json +85 -0
  97. package/templates/en/QTYPE.md +618 -0
  98. package/templates/en/README.md +64 -0
  99. package/templates/en/TODO.md +7 -0
  100. package/templates/en/index.md +7 -0
  101. package/templates/en/log.md +3 -0
  102. package/templates/en/material/.gitkeep +0 -0
  103. package/templates/en/material/example.md +47 -0
  104. package/templates/zh/QTYPE.md +618 -0
  105. package/templates/zh/README.md +64 -0
  106. package/templates/zh/TODO.md +7 -0
  107. package/templates/zh/index.md +7 -0
  108. package/templates/zh/log.md +3 -0
  109. package/templates/zh/material/.gitkeep +0 -0
  110. package/templates/zh/material/example.md +47 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,97 @@
1
+ # Changelog
2
+
3
+ Chinese: [CHANGELOG.zh.md](./CHANGELOG.zh.md)
4
+
5
+ All notable changes to this project are documented in this file.
6
+
7
+ The format is loosely based on [Keep a Changelog][keep], and this project
8
+ adheres to [Semantic Versioning][semver]. Pre-1.0 means breaking changes
9
+ can land in any minor bump (`0.x.0`).
10
+
11
+ [keep]: https://keepachangelog.com/en/1.1.0/
12
+ [semver]: https://semver.org/spec/v2.0.0.html
13
+
14
+ ## [Unreleased]
15
+
16
+ ## [0.0.1] - 2026-08-16
17
+
18
+ Initial development release. Everything below is the baseline shipped
19
+ with this version.
20
+
21
+ ### Added
22
+
23
+ - **CLI baseline** — mirrors qrism's `registry / mount / bootstrap`
24
+ pattern one-for-one:
25
+ - `qtype init [dir]` — alias for `repo sync`, creates the material
26
+ scaffold in an existing directory
27
+ - `qtype repo new <name>` / `qtype repo sync [dir]` — scaffold or
28
+ top-up a repo (spec + AGENTS/CLAUDE/GEMINI symlinks + `.qtype/`
29
+ skeleton + example material)
30
+ - `qtype check [dir]` — validate material files, reports cards with
31
+ non-typable characters; non-zero exit on failure
32
+ - `qtype publish build` — assemble the static site into `dist/`
33
+ (per-material page + pre-rendered mermaid + optional password gate)
34
+ - `qtype publish serve` — local HTTP preview
35
+ - `qtype publish init` — write `.gitignore` + GitHub Pages workflow
36
+ - `qtype publish password set/clear/status` — password protection
37
+ lifecycle
38
+ - `qtype pack [-o file]` — bundle the whole material repo into a
39
+ `tar.gz`
40
+ - `qtype content lint / validate / search` — content-oriented lint
41
+ passes and plain-substring search
42
+ - `qtype config get/set/unset/list` — git-style two-layer config
43
+ (user + repo), driven by the store layer with strict-schema mode
44
+ - `qtype plugin` — command skeleton (no plugin execution yet)
45
+
46
+ - **Core layer** (`src/core/`) — pure logic, IO-free at the edges:
47
+ - `parser/parseMaterial` — `## Q:` / `## A:` cards with `\n\n---\n\n`
48
+ separators, YAML frontmatter (tags / type / hint / difficulty /
49
+ phonetic / gloss / translation)
50
+ - `typing/` — `TypingEngine` state machine + WPM/accuracy metrics
51
+ - `keystroke/` — key event normalisation
52
+ - `srs/` — spaced-repetition scaffolding
53
+ - `encrypt.ts` — AES-256-GCM helpers used by `publish password`
54
+
55
+ - **Store layer** (`src/store/`) — `KvStore` on top of a `Storage`
56
+ interface (`JsonStorage` / `BrowserStorage` / `MemoryStorage`).
57
+ Prototype-pollution safe (`__proto__` / `constructor` / `prototype`
58
+ segments are rejected). Includes an i18n-friendly `KvError` with
59
+ structured `code` + `vars`.
60
+
61
+ - **View SPA** (`src/view/`) — React 18 + TanStack Router. Features:
62
+ - Typing arena with progress + WPM/accuracy panel
63
+ - Material list + tag/type filters
64
+ - Command palette (⌘K style)
65
+ - Bilingual UI (`zh` / `en`)
66
+ - Password gate (AES-256-GCM decryption of encrypted materials, key
67
+ derived via Argon2id from the plaintext password)
68
+ - Mermaid diagram rendering (pre-baked SVGs from `publish build` or
69
+ client-side fallback)
70
+
71
+ - **Templates** — bilingual `templates/{zh,en}/` with `QTYPE.md`
72
+ authoring spec, sample `README.md` / `TODO.md` / `index.md` /
73
+ `log.md`, and an example `material/example.md`. Copied verbatim into
74
+ every new repo by `qtype init` / `qtype repo new`.
75
+
76
+ - **i18n** — CLI messages and view UI both bilingual. Language
77
+ resolved from `--lang` > `$QTYPE_LANG` > `cli.lang` config >
78
+ fallback.
79
+
80
+ - **Docs + testing scaffold** — this initial cut of `README.md` /
81
+ `CONTRIBUTING.md` / `TODO.md` / `docs/` / `__tests__/` matches
82
+ qrism's shape, so contributors coming from qrism find the same
83
+ layout.
84
+
85
+ ### Known limitations
86
+
87
+ - View-side password UI is functional but rough; polish pending
88
+ - `TypingArena` doesn't yet accept an injected `engine: TypingEngine`
89
+ prop (the `useTypingEngine` hook exists but the arena manages its
90
+ own state)
91
+ - Icons are still defined inline in components; not yet extracted to
92
+ `components/icons/`
93
+ - `content search` is plain substring — no tag / type filters
94
+ - Welcome feature is a skeleton
95
+ - E2E automation is minimal
96
+
97
+ See [TODO.md](./TODO.md) for the tracked backlog.
@@ -0,0 +1,82 @@
1
+ # 变更记录
2
+
3
+ English: [CHANGELOG.md](./CHANGELOG.md)
4
+
5
+ 本文件记录本项目的所有值得注意的变更。
6
+
7
+ 格式大致沿用 [Keep a Changelog][keep],版本号遵循 [语义化版本][semver]。
8
+ 1.0 之前,破坏性变更可能落在任意 minor 版本(`0.x.0`)里。
9
+
10
+ [keep]: https://keepachangelog.com/zh-CN/1.1.0/
11
+ [semver]: https://semver.org/lang/zh-CN/
12
+
13
+ ## [Unreleased]
14
+
15
+ ## [0.0.1] - 2026-08-16
16
+
17
+ 首个开发版。以下是这个版本的基线内容。
18
+
19
+ ### 新增
20
+
21
+ - **CLI 基线** —— `registry / mount / bootstrap` 模式一比一镜像 qrism:
22
+ - `qtype init [dir]` —— `repo sync` 的别名,在已有目录中补齐资料脚手架
23
+ - `qtype repo new <name>` / `qtype repo sync [dir]` —— 新建仓库或补齐
24
+ 约定文件(规范 + AGENTS/CLAUDE/GEMINI 软链 + `.qtype/` 骨架 + 示例 material)
25
+ - `qtype check [dir]` —— 校验 material 文件,报告含无法打字字符的卡片,
26
+ 失败时以非零码退出
27
+ - `qtype publish build` —— 拼装静态站到 `dist/`(每份 material 一页 +
28
+ 预渲染 mermaid + 可选密码门)
29
+ - `qtype publish serve` —— 本地 HTTP 预览
30
+ - `qtype publish init` —— 写 `.gitignore` + GitHub Pages workflow
31
+ - `qtype publish password set/clear/status` —— 密码保护生命周期
32
+ - `qtype pack [-o file]` —— 打包整个 material 仓库为 `tar.gz`
33
+ - `qtype content lint / validate / search` —— 内容维度的 lint 通道
34
+ 与纯子串搜索
35
+ - `qtype config get/set/unset/list` —— git 风格的双层配置(user +
36
+ repo),由 store 层驱动,配严格 schema 模式
37
+ - `qtype plugin` —— 命令骨架(尚未执行插件)
38
+
39
+ - **核心层**(`src/core/`)—— 边界之外无 IO 的纯逻辑:
40
+ - `parser/parseMaterial` —— `## Q:` / `## A:` 卡片,`\n\n---\n\n`
41
+ 分隔,YAML frontmatter(tags / type / hint / difficulty /
42
+ phonetic / gloss / translation)
43
+ - `typing/` —— `TypingEngine` 状态机 + WPM / 准确率指标
44
+ - `keystroke/` —— 按键事件归一化
45
+ - `srs/` —— 间隔复习脚手架
46
+ - `encrypt.ts` —— `publish password` 使用的 AES-256-GCM 助手
47
+
48
+ - **存储层**(`src/store/`)—— 建立在 `Storage` 接口上的 `KvStore`
49
+ (`JsonStorage` / `BrowserStorage` / `MemoryStorage`)。原型链污染安全
50
+ (拒绝 `__proto__` / `constructor` / `prototype` 段)。带 i18n 友好的
51
+ `KvError`,携带结构化 `code` + `vars`。
52
+
53
+ - **View SPA**(`src/view/`)—— React 18 + TanStack Router。特性:
54
+ - 打字场地 + 进度 + WPM / 准确率面板
55
+ - 材料列表 + tag / type 过滤
56
+ - 命令面板(⌘K 风格)
57
+ - 双语 UI(`zh` / `en`)
58
+ - 密码门(AES-256-GCM 解密加密后的 material,密钥经 Argon2id 从明文密码派生)
59
+ - Mermaid 图渲染(`publish build` 预烘焙 SVG,或 client 端兜底)
60
+
61
+ - **模板** —— 双语 `templates/{zh,en}/`,含 `QTYPE.md` 撰写规范、示例
62
+ `README.md` / `TODO.md` / `index.md` / `log.md`,以及一个示例
63
+ `material/example.md`。`qtype init` / `qtype repo new` 时逐字拷贝到新仓库。
64
+
65
+ - **i18n** —— CLI 消息和 view UI 都双语。语言来源优先级:`--lang` >
66
+ `$QTYPE_LANG` > `cli.lang` 配置 > 默认。
67
+
68
+ - **文档 + 测试脚手架** —— 首版 `README.md` / `CONTRIBUTING.md` /
69
+ `TODO.md` / `docs/` / `__tests__/` 都对齐 qrism 的形态,让从 qrism
70
+ 过来的贡献者能立刻上手。
71
+
72
+ ### 已知限制
73
+
74
+ - View 端密码 UI 可用但粗糙,待打磨
75
+ - `TypingArena` 还没接受注入式 `engine: TypingEngine` prop(`useTypingEngine`
76
+ 钩子已存在但 arena 自己管着状态)
77
+ - 图标还是在组件里内联定义,尚未抽到 `components/icons/`
78
+ - `content search` 是纯子串匹配 —— 没有 tag / type 过滤
79
+ - Welcome 特性只是骨架
80
+ - E2E 自动化很少
81
+
82
+ 追踪清单见 [TODO.zh.md](./TODO.zh.md)。
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,113 @@
1
+ # qtype
2
+
3
+ **English** | [中文](./README.zh.md)
4
+
5
+ **Markdown-driven typing review / practice tool.** Write a `## Q:` / `## A:` card, and qtype makes you **type the answer** to review it.
6
+
7
+ qtype is the sister project of [qrism](https://github.com/qnroa/qrism): qrism focuses on **graph-navigated knowledge reading**, qtype focuses on **active typing to internalise knowledge**. Both share the same "MD is the single source of truth" value.
8
+
9
+ ## Quick start
10
+
11
+ ```bash
12
+ # One-time
13
+ npm install -g @qnroa/qtype
14
+
15
+ # Or run directly via npx
16
+ npx @qnroa/qtype init my-deck
17
+ cd my-deck
18
+ # Author your material/*.md files (see QTYPE.md)
19
+ npx @qnroa/qtype publish build
20
+ npx @qnroa/qtype publish serve # http://localhost:4000
21
+ ```
22
+
23
+ Requires Node ≥ 20.
24
+
25
+ ## CLI
26
+
27
+ | Command | What it does |
28
+ |---|---|
29
+ | `qtype init [dir]` | Scaffold a material repo (with `QTYPE.md` spec + AGENTS/CLAUDE/GEMINI symlinks) |
30
+ | `qtype check [dir]` | Validate card format (read-only) |
31
+ | `qtype publish build` | Assemble the static site into `dist/` |
32
+ | `qtype publish serve` | Local preview |
33
+ | `qtype publish init` | Write `.gitignore` + GitHub Pages workflow |
34
+ | `qtype pack` | Bundle the material repo into `.tar.gz` |
35
+ | `qtype config` | Get / set / unset / list settings (user + repo layers) |
36
+ | `qtype repo new / sync` | Create a new repo / fill in conventions |
37
+
38
+ Run `qtype <cmd> --help` for full options.
39
+
40
+ ## Card format
41
+
42
+ A single card:
43
+
44
+ ```markdown
45
+ ---
46
+ tags: [js, basics]
47
+ type: normal
48
+ ---
49
+
50
+ ## Q:
51
+
52
+ What are the three core concepts of React?
53
+
54
+ ## A:
55
+
56
+ Components, props, and state.
57
+ ```
58
+
59
+ Multiple cards in one file are separated by `\n\n---\n\n` (on its own line).
60
+
61
+ Supported types: `normal | word | sentence`. `word` / `sentence` cards may carry `phonetic` / `gloss` / `translation`. Full spec lives in `templates/{zh,en}/QTYPE.md` (copied into your repo by `qtype init`).
62
+
63
+ ## Naming
64
+
65
+ - `qrism = Q + prism` — the prism of questions, refracting MD into an explorable knowledge graph.
66
+ - `qtype = Q + type` — typing your way through questions, turning MD into typable cards.
67
+
68
+ ## Documentation
69
+
70
+ - [Architecture](./docs/en/architecture.md) — how `core` / `cli` / `view` relate
71
+ - [CLI reference](./docs/en/cli-reference.md) — brief overview of every command
72
+ - [Authoring guide](./docs/en/authoring.md) — quick primer on writing `material/*.md`
73
+ - [`CONTRIBUTING.md`](./CONTRIBUTING.md) — dev setup + PR flow
74
+ - [`CHANGELOG.md`](./CHANGELOG.md) — release history
75
+
76
+ Full authoring spec: [`templates/en/QTYPE.md`](./templates/en/QTYPE.md) / [`templates/zh/QTYPE.md`](./templates/zh/QTYPE.md). Copied into every new repo as `QTYPE.md` based on `qtype init --lang zh|en`.
77
+
78
+ ## Development
79
+
80
+ ```bash
81
+ npm install
82
+ npm run dev:view # http://localhost:5173 (view hot dev)
83
+ npm test # vitest
84
+ npm run build # build:cli + build:view
85
+ npm run lint # tsc --noEmit (cli + view tsconfigs)
86
+ ```
87
+
88
+ ## Repo layout
89
+
90
+ ```
91
+ qtype/
92
+ ├── src/
93
+ │ ├── core/ # pure logic, no IO (parser / typing / keystroke / ...)
94
+ │ ├── view/ # React SPA
95
+ │ ├── store/ # persistence (KvStore + JsonStorage / MemoryStorage / BrowserStorage)
96
+ │ └── cli/ # commander + registry/mount pattern
97
+ ├── templates/{zh,en}/ # copied into user repo by init
98
+ ├── tsconfig.{cli,view}.json
99
+ └── vite.config.ts # outputs to dist/view
100
+ ```
101
+
102
+ Publish structure:
103
+ - `dist/cli/` — CLI executable (`bin: qtype`)
104
+ - `dist/core/` — re-usable for external APIs (`exports "./core"`)
105
+ - `dist/view/` — pre-built SPA; `publish build` copies this into user `dist/`
106
+
107
+ ## Relationship to qrism
108
+
109
+ The CLI structure (registry / mount / i18n / bootstrap) mirrors qrism almost one-for-one. QTYPE.md is the counterpart of QRISM.md — an LLM-authoring spec for structured Markdown. The only real difference is that qtype cards are "meant to be typed" while qrism nodes are "meant to be read".
110
+
111
+ ## License
112
+
113
+ Apache-2.0 — see [LICENSE](./LICENSE).
package/README.zh.md ADDED
@@ -0,0 +1,114 @@
1
+ # qtype
2
+
3
+ [English](./README.md) | **中文**
4
+
5
+ **Markdown 驱动的打字复习/练习工具。** 写一份 `## Q:` / `## A:` 卡片,qtype 让你把答案**打一遍**来复习。
6
+
7
+ qtype 是 [qrism](https://github.com/qnroa/qrism) 的姊妹项目:qrism 关注**图导航的知识阅读**,qtype 关注**主动打字的知识内化**。共享同一个"MD 是唯一真相源"的价值观。
8
+
9
+ ## 快速开始
10
+
11
+ ```bash
12
+ # 一次性
13
+ npm install -g @qnroa/qtype
14
+
15
+ # 或直接 npx
16
+ npx @qnroa/qtype init my-deck
17
+ cd my-deck
18
+ # 用你的编辑器/AI 助手写 material/*.md(详见 QTYPE.md)
19
+ npx @qnroa/qtype publish build
20
+ npx @qnroa/qtype publish serve # http://localhost:4000
21
+ ```
22
+
23
+ 需要 Node ≥ 20。
24
+
25
+ ## CLI
26
+
27
+ | 命令 | 作用 |
28
+ |---|---|
29
+ | `qtype init [dir]` | 初始化资料仓库(含 QTYPE.md 规范 + AGENTS/CLAUDE/GEMINI 软链) |
30
+ | `qtype check [dir]` | 校验卡片格式,只读 |
31
+ | `qtype publish build` | 拼装静态站到 `dist/` |
32
+ | `qtype publish serve` | 本地预览 |
33
+ | `qtype publish init` | 写 `.gitignore` + GitHub Pages workflow |
34
+ | `qtype pack` | 打包整个资料为 `.tar.gz` |
35
+ | `qtype config` | 读 / 写 / 删 / 列配置(user + repo 双层) |
36
+ | `qtype repo new / sync` | 新建仓库 / 补齐约定 |
37
+
38
+ 每个命令 `qtype <cmd> --help` 看完整选项。
39
+
40
+ ## 卡片格式
41
+
42
+ 一张卡:
43
+
44
+ ```markdown
45
+ ---
46
+ tags: [js, basics]
47
+ type: normal
48
+ ---
49
+
50
+ ## Q:
51
+
52
+ React 三大核心概念是什么?
53
+
54
+ ## A:
55
+
56
+ 组件、props 和 state。
57
+ ```
58
+
59
+ 一份 MD 里多张卡片用 `\n\n---\n\n`(独占行)分隔。
60
+
61
+ 支持 `type: normal | word | sentence`,`word` / `sentence` 可带 `phonetic` / `gloss` / `translation`。完整规范见 `templates/{zh,en}/QTYPE.md`(由 `qtype init` 复制到你的仓库)。
62
+
63
+ ## 命名
64
+
65
+ - `qrism = Q + prism`(问题的棱镜)—— 把 MD 折射成可探索的知识图。
66
+ - `qtype = Q + type`(问题的打字)—— 把 MD 转成可打字复现的卡片。
67
+
68
+ ## 文档
69
+
70
+ - [架构总览](./docs/zh/architecture.md) —— `core` / `cli` / `view` 怎么分工
71
+ - [CLI 简介](./docs/zh/cli-reference.md) —— 每个命令的简单说明
72
+ - [撰写指南](./docs/zh/authoring.md) —— `material/*.md` 的快速入门
73
+ - [`CONTRIBUTING.zh.md`](./CONTRIBUTING.zh.md) —— 开发环境 + PR 流程
74
+ - [`CHANGELOG.zh.md`](./CHANGELOG.zh.md) —— 版本历史
75
+
76
+ 规范全文:[`templates/en/QTYPE.md`](./templates/en/QTYPE.md) /
77
+ [`templates/zh/QTYPE.md`](./templates/zh/QTYPE.md)。`qtype init --lang zh|en` 时拷成用户仓库的 `QTYPE.md`。
78
+
79
+ ## 开发
80
+
81
+ ```bash
82
+ npm install
83
+ npm run dev:view # http://localhost:5173(view 端热开发)
84
+ npm test # vitest
85
+ npm run build # build:cli + build:view
86
+ npm run lint # tsc --noEmit(cli + view 两份 tsconfig)
87
+ ```
88
+
89
+ ## 目录结构
90
+
91
+ ```
92
+ qtype/
93
+ ├── src/
94
+ │ ├── core/ # 纯逻辑,无 IO(parser / typing / keystroke / ...)
95
+ │ ├── view/ # React SPA
96
+ │ ├── store/ # 持久化(KvStore + JsonStorage / MemoryStorage / BrowserStorage)
97
+ │ └── cli/ # commander + registry/mount 模式
98
+ ├── templates/{zh,en}/ # init 时复制到用户仓库
99
+ ├── tsconfig.{cli,view}.json
100
+ └── vite.config.ts # 输出到 dist/view
101
+ ```
102
+
103
+ 发布结构:
104
+ - `dist/cli/` — CLI 可执行文件(`bin: qtype`)
105
+ - `dist/core/` — 复用给外部 API(`exports "./core"`)
106
+ - `dist/view/` — 预编译的 SPA,`publish build` 拷贝这里到用户 `dist/`
107
+
108
+ ## 与 qrism 的关系
109
+
110
+ CLI 结构(registry / mount / i18n / bootstrap)几乎一比一镜像 qrism。QTYPE.md 对应 QRISM.md —— 一份让 LLM 生成结构化 Markdown 的规范。区别只在于 qtype 的卡片是"要被打字重现的",而 qrism 的节点是"要被阅读的"。
111
+
112
+ ## License
113
+
114
+ Apache-2.0 —— 详见 [LICENSE](./LICENSE)。