autoanki
v1.0.5
Published
CLI tool for newAutoAnki - generate Anki cards from local files
Readme
AutoAnki CLI
把本地 .txt / .md 文件转换成可直接导入 Anki 的 .apkg 卡包。
适合处理课程笔记、文章、章节稿和较长的学习材料。CLI 会自动分块调用 AutoAnki 服务,并把结果合并成一个 Anki 卡包。
安装
npm install -g autoanki@latest要求 Node.js 14 或更高版本。
检查版本:
autoanki --version登录
autoanki login使用 AutoAnki 网页端账号登录。登录后,CLI 会在本机保存登录凭证。
生成卡包
autoanki generate \
--input notes.md \
--cards 5 \
--output notes-deck生成成功后会得到:
notes-deck.apkg在 Anki 中选择“文件 -> 导入”,导入这个 .apkg 文件即可。
长文档规则
CLI 会自动切分长文档:
- 中文:每块约 3500 字
- 英文:每块约 5500 字符
--cards 表示“每块生成多少张卡”,不是整篇文档总卡数。
例如文档被切成 4 块:
autoanki generate --input chapter.txt --cards 5 --output chapter-deck预计生成:
4 块 x 5 张/块 = 约 20 张单块最多 20 张。
模型提供方
默认模型:
autoanki generate \
--input notes.md \
--cards 5 \
--output notes-deck \
--provider defaultLongcat:
autoanki generate \
--input notes.md \
--cards 5 \
--output notes-deck \
--provider longcat当服务端开放 Longcat 时,Longcat 路径不消耗 AutoAnki 积分,预览会显示:
预计消耗:0 积分(Longcat 免费试用)Longcat 是否可用取决于上游服务。如果上游限流,生成可能返回 rate limit 错误。
命令参数
autoanki generate --input <file> --cards <number> --output <name> [options]必填参数:
| 参数 | 说明 |
| --- | --- |
| -i, --input <file> | 输入文件,支持 .txt / .md |
| -c, --cards <number> | 每块卡片数,最多 20 |
| -o, --output <name> | 输出文件名,不需要写 .apkg 后缀 |
可选参数:
| 参数 | 说明 |
| --- | --- |
| -d, --dir <folder> | 输出目录,默认当前目录 |
| -l, --language <zh/en> | 指定语言,默认自动识别 |
| -p, --provider <default/longcat> | 模型提供方,默认 default |
| --deck <name> | Anki 卡组名,支持 :: 分层 |
| -y, --yes | 跳过确认提示 |
常用示例
指定输出目录:
autoanki generate \
--input notes.md \
--cards 5 \
--output notes-deck \
--dir ~/anki-cards指定 Anki 卡组名:
autoanki generate \
--input notes.md \
--cards 5 \
--output notes-deck \
--deck "Study Notes::Chapter 1"跳过确认:
autoanki generate \
--input notes.md \
--cards 5 \
--output notes-deck \
--yes账号命令
查看登录状态:
autoanki whoami退出登录:
autoanki logout积分说明
default使用 AutoAnki 正常积分系统。longcat当前为免费试用路径,CLI 会显示 0 积分。- 实际扣费和可用性以服务端配置为准。
常见问题
unknown option '--provider'
说明全局 CLI 版本过旧。升级:
npm install -g autoanki@latest
hash -r
autoanki --version登录过期
重新登录:
autoanki login为什么生成数量比 --cards 多?
因为 --cards 是每块数量。长文档会被切成多块:
总卡片数 ≈ 分块数 x --cards想要更少、更核心的卡片,可以降低 --cards。
链接
- AutoAnki Web: https://www.autoanki.xyz
- npm: https://www.npmjs.com/package/autoanki
