@zephyr424/wb-sdk 0.1.1 → 0.3.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.
@@ -0,0 +1,41 @@
1
+ name: Deploy VitePress site to Pages
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: read
10
+ pages: write
11
+ id-token: write
12
+
13
+ jobs:
14
+ build:
15
+ runs-on: ubuntu-latest
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - uses: actions/setup-node@v4
19
+ with:
20
+ node-version: 20
21
+ - name: Setup Pages
22
+ uses: actions/configure-pages@v4
23
+ - name: Install dependencies
24
+ run: cd docs && npm install
25
+ - name: Build
26
+ run: cd docs && npm run docs:build
27
+ - name: Upload artifact
28
+ uses: actions/upload-pages-artifact@v3
29
+ with:
30
+ path: docs/.vitepress/dist
31
+
32
+ deploy:
33
+ environment:
34
+ name: github-pages
35
+ url: ${{ steps.deployment.outputs.page_url }}
36
+ runs-on: ubuntu-latest
37
+ needs: build
38
+ steps:
39
+ - name: Deploy to GitHub Pages
40
+ id: deployment
41
+ uses: actions/deploy-pages@v4
package/README.md CHANGED
@@ -2,8 +2,8 @@
2
2
 
3
3
  > A developer-friendly spaced repetition engine for vocabulary building
4
4
 
5
- [![npm version](https://img.shields.io/npm/v/wb-sdk.svg)](https://www.npmjs.com/package/@zephyr424/wb-sdk)
6
- [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Zephyr424/wb-sdk/blob/main/LICENSE)
5
+ [![npm version](https://img.shields.io/npm/v/@zephyr424/wb-sdk.svg)](https://www.npmjs.com/package/@zephyr424/wb-sdk)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
7
 
8
8
  **wb-sdk** is a lightweight, plug-and-play spaced repetition engine designed for developers who want to integrate intelligent vocabulary review into their applications.
9
9
 
package/bin/wb.js ADDED
@@ -0,0 +1,82 @@
1
+ const { program } = require('commander');
2
+ const { WordBank } = require('../index');
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ program
7
+ .name('wb')
8
+ .description('📚 wb-sdk CLI — 间隔重复背单词工具')
9
+ .version('0.2.0');
10
+
11
+ // ---------- learn 命令 ----------
12
+ program
13
+ .command('learn')
14
+ .description('开始今天的学习')
15
+ .option('-n, --limit <number>', '限制复习单词数量', 10)
16
+ .action((options) => {
17
+ const wb = new WordBank();
18
+ wb.loadPreset('top5000');
19
+
20
+ const due = wb.review.getDue().slice(0, parseInt(options.limit));
21
+ if (due.length === 0) {
22
+ console.log('🎉 今天没有需要复习的单词!');
23
+ return;
24
+ }
25
+
26
+ console.log(`📚 今天有 ${due.length} 个单词需要复习:\n`);
27
+ due.forEach((word, i) => {
28
+ console.log(` ${i + 1}. ${word.word}`);
29
+ console.log(` 释义: ${word.definition}`);
30
+ console.log(` 难度系数: ${word.easeFactor.toFixed(2)}`);
31
+ console.log(` 复习间隔: ${word.interval} 天`);
32
+ console.log('');
33
+ });
34
+ });
35
+
36
+ // ---------- stats 命令 ----------
37
+ program
38
+ .command('stats')
39
+ .description('查看学习进度统计')
40
+ .action(() => {
41
+ const wb = new WordBank();
42
+ wb.loadPreset('top5000');
43
+ const stats = wb.review.progress();
44
+
45
+ console.log('📊 学习进度统计:');
46
+ console.log(` 总词数: ${stats.total}`);
47
+ console.log(` 已掌握(间隔≥30天): ${stats.mastered}`);
48
+ console.log(` 剩余: ${stats.remaining}`);
49
+ console.log(` 预计全部掌握: ${stats.daysToMaster} 天`);
50
+ });
51
+
52
+ // ---------- remind 命令(艾宾浩斯提醒) ----------
53
+ program
54
+ .command('remind')
55
+ .description('🔔 查看今天应复习的单词数量(艾宾浩斯提醒)')
56
+ .option('-d, --detail', '显示详细单词列表')
57
+ .action((options) => {
58
+ const wb = new WordBank();
59
+ wb.loadPreset('top5000');
60
+ const due = wb.review.getDue();
61
+ const today = new Date().toISOString().slice(0, 10);
62
+
63
+ if (due.length === 0) {
64
+ console.log(`📅 ${today} 没有需要复习的单词,继续保持!🎉`);
65
+ return;
66
+ }
67
+
68
+ console.log(`📅 ${today} 艾宾浩斯复习提醒:`);
69
+ console.log(` 今天有 ${due.length} 个单词需要复习`);
70
+
71
+ if (options.detail) {
72
+ console.log('\n📖 详细列表:');
73
+ due.forEach((word, i) => {
74
+ const last = word.lastReviewed ? new Date(word.lastReviewed).toISOString().slice(0, 10) : '从未';
75
+ console.log(` ${i + 1}. ${word.word}(上次复习: ${last})`);
76
+ });
77
+ }
78
+
79
+ console.log('\n💡 运行 `wb learn` 开始复习');
80
+ });
81
+
82
+ program.parse();