@derekhut/alvy 1.0.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.
Files changed (45) hide show
  1. package/README.md +96 -0
  2. package/dist/app.d.ts +6 -0
  3. package/dist/app.js +17 -0
  4. package/dist/components/celebration.d.ts +7 -0
  5. package/dist/components/celebration.js +8 -0
  6. package/dist/components/cjk-test.d.ts +1 -0
  7. package/dist/components/cjk-test.js +57 -0
  8. package/dist/components/daily-session.d.ts +1 -0
  9. package/dist/components/daily-session.js +128 -0
  10. package/dist/components/dashboard.d.ts +7 -0
  11. package/dist/components/dashboard.js +13 -0
  12. package/dist/components/doctor.d.ts +1 -0
  13. package/dist/components/doctor.js +120 -0
  14. package/dist/components/explore.d.ts +1 -0
  15. package/dist/components/explore.js +5 -0
  16. package/dist/components/result.d.ts +7 -0
  17. package/dist/components/result.js +5 -0
  18. package/dist/components/review-session.d.ts +1 -0
  19. package/dist/components/review-session.js +108 -0
  20. package/dist/components/root-lesson.d.ts +9 -0
  21. package/dist/components/root-lesson.js +8 -0
  22. package/dist/components/session-summary.d.ts +8 -0
  23. package/dist/components/session-summary.js +5 -0
  24. package/dist/components/stats.d.ts +1 -0
  25. package/dist/components/stats.js +17 -0
  26. package/dist/components/streak-header.d.ts +7 -0
  27. package/dist/components/streak-header.js +7 -0
  28. package/dist/components/word-detail.d.ts +9 -0
  29. package/dist/components/word-detail.js +17 -0
  30. package/dist/components/word-drill.d.ts +20 -0
  31. package/dist/components/word-drill.js +54 -0
  32. package/dist/data/roots.json +1802 -0
  33. package/dist/index.d.ts +2 -0
  34. package/dist/index.js +29 -0
  35. package/dist/lib/ai.d.ts +1 -0
  36. package/dist/lib/ai.js +5 -0
  37. package/dist/lib/progress.d.ts +17 -0
  38. package/dist/lib/progress.js +103 -0
  39. package/dist/lib/roots-db.d.ts +9 -0
  40. package/dist/lib/roots-db.js +25 -0
  41. package/dist/lib/store.d.ts +6 -0
  42. package/dist/lib/store.js +75 -0
  43. package/dist/lib/types.d.ts +39 -0
  44. package/dist/lib/types.js +1 -0
  45. package/package.json +33 -0
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from "ink";
3
+ export default function SessionSummary({ xpEarned, wordsLearned, rootsStudied, streak, }) {
4
+ return (_jsxs(Box, { flexDirection: "column", paddingLeft: 2, paddingY: 1, children: [_jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "#4E4E4E", paddingX: 2, paddingY: 1, children: [_jsx(Text, { bold: true, color: "#AF5FFF", children: "\u4ECA\u65E5\u5B66\u4E60\u5B8C\u6210\uFF01" }), _jsxs(Box, { flexDirection: "column", marginTop: 1, children: [_jsxs(Text, { children: ["\u2B50 \u83B7\u5F97\u7ECF\u9A8C: ", _jsxs(Text, { bold: true, color: "#FFAF00", children: ["+", xpEarned] }), " XP"] }), _jsxs(Text, { children: ["\uD83D\uDCDA \u5B66\u4E60\u8BCD\u6839: ", _jsx(Text, { bold: true, color: "#FFAF00", children: rootsStudied }), " \u4E2A"] }), _jsxs(Text, { children: ["\uD83D\uDCDA \u5B66\u4E60\u5355\u8BCD: ", _jsx(Text, { bold: true, color: "#FFAF00", children: wordsLearned }), " \u4E2A"] }), _jsxs(Text, { children: ["\uD83D\uDD25 \u8FDE\u7EED\u5B66\u4E60: ", _jsx(Text, { bold: true, color: "#FFAF00", children: streak }), " \u5929"] })] })] }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "\uD83C\uDF19 \u4ECA\u65E5\u76EE\u6807\u5DF2\u5B8C\u6210\uFF0C\u660E\u5929\u7EE7\u7EED\u52A0\u6CB9\uFF01" }) }), _jsx(Box, { children: _jsx(Text, { dimColor: true, children: "\u6309\u56DE\u8F66\u9000\u51FA" }) })] }));
5
+ }
@@ -0,0 +1 @@
1
+ export default function Stats(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect } from "react";
3
+ import { Box, Text, useApp } from "ink";
4
+ import { loadData } from "../lib/store.js";
5
+ import { getRootCount } from "../lib/roots-db.js";
6
+ import { generateStatsSummary } from "../lib/progress.js";
7
+ export default function Stats() {
8
+ const { exit } = useApp();
9
+ const data = loadData();
10
+ const totalRoots = getRootCount();
11
+ const summary = generateStatsSummary(data, totalRoots);
12
+ useEffect(() => {
13
+ console.log(summary);
14
+ exit();
15
+ }, []);
16
+ return (_jsx(Box, { paddingLeft: 2, children: _jsx(Text, { dimColor: true, children: "\u7EDF\u8BA1\u6570\u636E\u5DF2\u8F93\u51FA\uFF08\u53EF\u901A\u8FC7 > stats.md \u4FDD\u5B58\u5230\u6587\u4EF6\uFF09" }) }));
17
+ }
@@ -0,0 +1,7 @@
1
+ import type { UserData } from "../lib/types.js";
2
+ interface StreakHeaderProps {
3
+ data: UserData;
4
+ totalRoots: number;
5
+ }
6
+ export default function StreakHeader({ data, totalRoots }: StreakHeaderProps): import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Box, Text } from "ink";
3
+ import { masteredCount } from "../lib/progress.js";
4
+ export default function StreakHeader({ data, totalRoots }) {
5
+ const mastered = masteredCount(data);
6
+ return (_jsxs(Box, { paddingLeft: 2, paddingTop: 1, gap: 3, children: [_jsxs(Text, { children: ["\uD83D\uDD25 ", _jsx(Text, { bold: true, color: "#FFAF00", children: data.streak.current }), " \u5929"] }), _jsxs(Text, { children: ["\u2B50 ", _jsx(Text, { bold: true, color: "#FFAF00", children: data.xp.total }), " XP"] }), _jsxs(Text, { children: ["\uD83D\uDCDA ", _jsxs(Text, { bold: true, color: "#FFAF00", children: [mastered, "/", totalRoots] })] })] }));
7
+ }
@@ -0,0 +1,9 @@
1
+ import type { RootWord } from "../lib/types.js";
2
+ interface WordDetailProps {
3
+ word: RootWord;
4
+ wordNum: number;
5
+ totalWords: number;
6
+ rootKey: string;
7
+ }
8
+ export default function WordDetail({ word, wordNum, totalWords, rootKey, }: WordDetailProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
@@ -0,0 +1,17 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { Box, Text } from "ink";
3
+ const freqStars = (freq) => {
4
+ switch (freq) {
5
+ case "high":
6
+ return "★★★";
7
+ case "medium":
8
+ return "★★☆";
9
+ case "low":
10
+ return "★☆☆";
11
+ default:
12
+ return "★☆☆";
13
+ }
14
+ };
15
+ export default function WordDetail({ word, wordNum, totalWords, rootKey, }) {
16
+ return (_jsxs(Box, { flexDirection: "column", paddingLeft: 2, paddingY: 1, children: [_jsxs(Text, { dimColor: true, children: [rootKey, " \u2014 \u5355\u8BCD ", wordNum, "/", totalWords] }), _jsxs(Box, { flexDirection: "column", borderStyle: "round", borderColor: "#4E4E4E", paddingX: 2, paddingY: 1, marginTop: 1, children: [_jsxs(Box, { gap: 2, children: [_jsx(Text, { bold: true, children: word.word }), _jsx(Text, { color: "#FFAF00", children: freqStars(word.toefl_frequency) })] }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "\u8BCD\u6839\u62C6\u89E3:" }), _jsxs(Text, { color: "#AF5FFF", children: [" ", word.derivation] })] }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: ["\u91CA\u4E49: ", word.meaning_zh] }) }), _jsx(Box, { children: _jsxs(Text, { dimColor: true, children: ["(", word.meaning_en, ")"] }) }), _jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { dimColor: true, children: "\u4F8B\u53E5:" }), _jsxs(Text, { children: [" ", word.example] }), _jsxs(Text, { dimColor: true, children: [" ", word.example_zh] })] })] }), _jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "\u6309\u56DE\u8F66\u7EE7\u7EED \u2192" }) })] }));
17
+ }
@@ -0,0 +1,20 @@
1
+ import type { RootEntry, RootWord } from "../lib/types.js";
2
+ export interface DrillQuestion {
3
+ word: RootWord;
4
+ rootKey: string;
5
+ choices: {
6
+ label: string;
7
+ meaning_zh: string;
8
+ isCorrect: boolean;
9
+ }[];
10
+ }
11
+ interface WordDrillProps {
12
+ question: DrillQuestion;
13
+ questionNum: number;
14
+ totalQuestions: number;
15
+ onAnswer: (isCorrect: boolean) => void;
16
+ }
17
+ export default function WordDrill({ question, questionNum, totalQuestions, onAnswer, }: WordDrillProps): import("react/jsx-runtime").JSX.Element;
18
+ /** Build drill questions for a root entry */
19
+ export declare function buildDrillQuestions(entry: RootEntry, distractorWords: RootWord[]): DrillQuestion[];
20
+ export {};
@@ -0,0 +1,54 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ import { useState } from "react";
3
+ import { Box, Text, useInput } from "ink";
4
+ export default function WordDrill({ question, questionNum, totalQuestions, onAnswer, }) {
5
+ const [selected, setSelected] = useState(null);
6
+ const labels = ["A", "B", "C", "D"];
7
+ useInput((input, key) => {
8
+ if (selected !== null)
9
+ return; // Already answered
10
+ const upper = input.toUpperCase();
11
+ const idx = labels.indexOf(upper);
12
+ if (idx !== -1 && idx < question.choices.length) {
13
+ setSelected(idx);
14
+ onAnswer(question.choices[idx].isCorrect);
15
+ }
16
+ });
17
+ return (_jsxs(Box, { flexDirection: "column", padding: 1, children: [_jsxs(Text, { dimColor: true, children: ["Question ", questionNum, "/", totalQuestions] }), _jsx(Box, { marginTop: 1, children: _jsxs(Text, { children: ["What does ", _jsxs(Text, { bold: true, color: "cyan", children: ["\"", question.word.word, "\""] }), " mean?"] }) }), _jsx(Box, { flexDirection: "column", marginTop: 1, children: question.choices.map((choice, i) => {
18
+ let color;
19
+ if (selected !== null) {
20
+ if (choice.isCorrect)
21
+ color = "green";
22
+ else if (i === selected && !choice.isCorrect)
23
+ color = "red";
24
+ }
25
+ return (_jsxs(Box, { gap: 1, children: [_jsxs(Text, { color: color, bold: i === selected, children: [labels[i], "."] }), _jsx(Text, { color: color, bold: i === selected, children: choice.label }), selected !== null && (_jsxs(Text, { dimColor: true, children: [" (", choice.meaning_zh, ")"] }))] }, i));
26
+ }) }), selected === null ? (_jsx(Box, { marginTop: 1, children: _jsx(Text, { dimColor: true, children: "Press A, B, C, or D to answer" }) })) : (_jsx(Box, { marginTop: 1, children: question.choices[selected].isCorrect ? (_jsx(Text, { color: "green", bold: true, children: "\u2713 Correct! +10 XP" })) : (_jsx(Text, { color: "red", bold: true, children: "\u2717 Wrong" })) }))] }));
27
+ }
28
+ /** Build drill questions for a root entry */
29
+ export function buildDrillQuestions(entry, distractorWords) {
30
+ return entry.words.map((word) => {
31
+ // Pick 3 random distractors (different from this word)
32
+ const distractors = distractorWords
33
+ .filter((d) => d.word !== word.word)
34
+ .sort(() => Math.random() - 0.5)
35
+ .slice(0, 3)
36
+ .map((d) => ({
37
+ label: d.meaning_en,
38
+ meaning_zh: d.meaning_zh,
39
+ isCorrect: false,
40
+ }));
41
+ const correct = {
42
+ label: word.meaning_en,
43
+ meaning_zh: word.meaning_zh,
44
+ isCorrect: true,
45
+ };
46
+ // Shuffle choices
47
+ const choices = [...distractors, correct].sort(() => Math.random() - 0.5);
48
+ return {
49
+ word,
50
+ rootKey: entry.root,
51
+ choices,
52
+ };
53
+ });
54
+ }