dracosh 0.0.0-stage → 0.2.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 (70) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +10 -0
  3. package/README.md +100 -2
  4. package/assets/sounds/ask.wav +0 -0
  5. package/assets/sounds/badge-1.wav +0 -0
  6. package/assets/sounds/badge-2.wav +0 -0
  7. package/assets/sounds/badge-3.wav +0 -0
  8. package/assets/sounds/badge-4.wav +0 -0
  9. package/assets/sounds/close.wav +0 -0
  10. package/assets/sounds/combo.wav +0 -0
  11. package/assets/sounds/correct-0.wav +0 -0
  12. package/assets/sounds/correct-1.wav +0 -0
  13. package/assets/sounds/correct-2.wav +0 -0
  14. package/assets/sounds/correct-3.wav +0 -0
  15. package/assets/sounds/correct-4.wav +0 -0
  16. package/assets/sounds/correct-5.wav +0 -0
  17. package/assets/sounds/evolve.wav +0 -0
  18. package/assets/sounds/goal.wav +0 -0
  19. package/assets/sounds/wrong.wav +0 -0
  20. package/data/tips.json +32 -0
  21. package/package.json +47 -4
  22. package/src/alerts.js +38 -0
  23. package/src/anki.js +36 -0
  24. package/src/backup.js +95 -0
  25. package/src/cli.js +197 -0
  26. package/src/commands.js +28 -0
  27. package/src/dates.js +15 -0
  28. package/src/demo.js +11 -0
  29. package/src/diff.js +46 -0
  30. package/src/hint.js +12 -0
  31. package/src/judge.js +78 -0
  32. package/src/library.js +127 -0
  33. package/src/lock.js +63 -0
  34. package/src/manage.js +75 -0
  35. package/src/parse.js +42 -0
  36. package/src/pause.js +23 -0
  37. package/src/progress.js +455 -0
  38. package/src/quiet.js +32 -0
  39. package/src/scheduler.js +94 -0
  40. package/src/session.js +227 -0
  41. package/src/settings.js +38 -0
  42. package/src/starter.js +38 -0
  43. package/src/store.js +100 -0
  44. package/src/tips.js +30 -0
  45. package/src/ui/AddCard.js +172 -0
  46. package/src/ui/AnswerInput.js +85 -0
  47. package/src/ui/App.js +509 -0
  48. package/src/ui/BadgeUnlock.js +50 -0
  49. package/src/ui/Badges.js +122 -0
  50. package/src/ui/Choice.js +33 -0
  51. package/src/ui/Companion.js +45 -0
  52. package/src/ui/Confetti.js +46 -0
  53. package/src/ui/Decks.js +49 -0
  54. package/src/ui/DieRoll.js +104 -0
  55. package/src/ui/Evolution.js +59 -0
  56. package/src/ui/Hatch.js +100 -0
  57. package/src/ui/Header.js +117 -0
  58. package/src/ui/Help.js +68 -0
  59. package/src/ui/Mascot.js +178 -0
  60. package/src/ui/Missed.js +53 -0
  61. package/src/ui/Preview.js +256 -0
  62. package/src/ui/Reset.js +72 -0
  63. package/src/ui/Settings.js +69 -0
  64. package/src/ui/Stats.js +111 -0
  65. package/src/ui/Summary.js +41 -0
  66. package/src/ui/TheOne.js +121 -0
  67. package/src/ui/icons.js +341 -0
  68. package/src/ui/kit.js +120 -0
  69. package/src/vacation.js +56 -0
  70. package/src/words.js +23 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,10 @@
1
+ Dracosh
2
+ Copyright 2026 Tomasz Przyborowski
3
+
4
+ This product includes software developed by Tomasz Przyborowski
5
+ (https://github.com/lynthius/dracosh).
6
+
7
+ "Dracosh" and the Dracosh dragon mascot are trademarks of Tomasz
8
+ Przyborowski. The Apache License 2.0 does not grant permission to use
9
+ them (see Section 6 of the license); forks and derived projects must
10
+ use a different name and identity.
package/README.md CHANGED
@@ -1,3 +1,101 @@
1
- # Temporary Holding Version
1
+ # Dracosh
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A gamified language or definitions trainer for your terminal. It sits in a spare pane, challenges you every few minutes, and a small pixel dragon grows up as you keep your streak going.
4
+
5
+ ## Why Dracosh
6
+
7
+ Learning a language usually means another hour in the evening, after a full day at the computer. I spent plenty of those evenings myself, and I wanted something that fits into the working day instead.
8
+
9
+ The day is full of short waits: a build that takes a minute, tests running, an AI agent finishing a task for you. Dracosh turns those moments into practice. Instead of reaching for your phone, you answer a word or two, the dragon cheers, and you're back to work. A few minutes here and there add up, and your evenings stay yours.
10
+
11
+ It's made for people who live in a terminal or spend most of the day at a computer, and it's meant to be fun, not one more chore.
12
+
13
+ ## Features
14
+
15
+ - Your cards live in Dracosh's own library, organised in decks; no other app needs to be running
16
+ - Add cards, start decks and switch between them right in the app (`/add`, `/decks`)
17
+ - Each deck is asked both ways (kot → cat and cat → kot) or one way only, as you choose when you make it
18
+ - Forgiving answer checks: case and punctuation don't matter, a missing Polish letter (ż, ó, ł…) still counts and shows the right spelling, one typo is fine on longer words, and after a miss you see letter by letter where you went wrong
19
+ - Leitner boxes, so the cards you know come back less and less often; a card is only asked when it's due
20
+ - Daily goal, streaks (weekends and days off don't break them) and 36 badges (one of them a secret)
21
+ - A pixel dragon that hatches from an egg, evolves over a year of streaks, blinks, and falls asleep if you ignore it
22
+ - 8-bit sound effects, generated from code
23
+ - A short tip about Dracosh while you wait for the next card
24
+
25
+ ## Install
26
+
27
+ You need Node 22 or newer.
28
+
29
+ ```bash
30
+ npm install -g dracosh
31
+ ```
32
+
33
+ A fresh install starts with a short "Getting started" deck: a tour where every card tells you what to type and shows you one more thing Dracosh can do. When you're through, `/add` starts your own deck and the tour makes room for it. Importing decks (from Anki, CSV and more) is on the way, see [What's next](#whats-next).
34
+
35
+ Want a look first? `dracosh --preview` shows every screen and animation on made-up data.
36
+
37
+ ## Usage
38
+
39
+ ```bash
40
+ dracosh --deck "Polish" # quiz this deck, this run only (otherwise the one picked in /decks)
41
+ dracosh --every 5m # a card every 5 minutes instead of 10, this run only
42
+ dracosh --no-sound
43
+ dracosh --stats # print your progress and exit
44
+ dracosh --data # show where your cards, progress and backups are kept
45
+ dracosh --preview
46
+ dracosh restore # list your backups; dracosh restore 2 brings one back
47
+ ```
48
+
49
+ Type the answer and press Enter; don't know it? Press Enter with nothing typed to see the answer. Press `/` for commands:
50
+
51
+ | Command | What it does |
52
+ | --- | --- |
53
+ | `/add` | add cards to one of your decks, or start a new deck |
54
+ | `/decks` | switch to another deck (Dracosh remembers it), or start a new one |
55
+ | `/hint` | reveal one more letter |
56
+ | `/correct` | your answer was right after all; it's accepted from now on |
57
+ | `/settings` | interval, daily goal, sound, quiet hours, weekends, tips, and a reset |
58
+ | `/stats` | streak and a calendar of your month |
59
+ | `/badges` | all badges and how to get them |
60
+ | `/companion` | your dragon, its element and the forms ahead |
61
+ | `/missed` | cards you got wrong today |
62
+ | `/pause 30m` | a break: `30m`, `2h`; or days off that keep your streak: `3d`, `24.12 2.01`; `off` ends it |
63
+ | `/help` | the keys, how cards come back, the streak |
64
+ | `/quit` | quit (you'll get a short session summary) |
65
+
66
+ They're slash commands because "pause" and "quit" are perfectly good English answers.
67
+
68
+ ## Your data
69
+
70
+ Everything stays on your machine, in `~/.dracosh`; `dracosh --data` shows what's there. Progress is saved after every answer, so you can quit any time. One quiz runs at a time: a second window on the same data is refused, so the two can't overwrite each other's progress. The first start of each day also saves a backup of your cards, progress and settings to `~/.dracosh/backups` (the last 7 are kept); `dracosh restore` brings one back, and backs up what you have first, so a restore can be undone too. To start over, `/settings` → Reset clears your progress only (badges, streak, the dragon) or everything; a backup is made first. To use Dracosh on two computers, put that folder somewhere synced and point `DRACOSH_HOME` at it.
71
+
72
+ Sounds currently play on macOS only.
73
+
74
+ ## Development
75
+
76
+ ```bash
77
+ git clone https://github.com/lynthius/dracosh.git
78
+ cd dracosh
79
+ npm install
80
+ npm link # puts `dracosh` on your PATH
81
+ npm test
82
+ ```
83
+
84
+ The quiz logic in `src/session.js` and `src/progress.js` does no I/O, which keeps it easy to test. The UI is built with [Ink](https://github.com/vadimdemedes/ink) and lives in `src/ui/`. Sound effects are generated by `scripts/make-sounds.js` (`npm run sounds`).
85
+
86
+ ## What's next
87
+
88
+ Dracosh now keeps its own card library, with a short tour and `/add` to start your own deck. Coming next, roughly in this order:
89
+
90
+ - Card types: definitions and question and answer decks, not just words. For each deck you choose whether you type the answer or just check yourself.
91
+ - More languages: decks in any language, with answer checking that forgives a missing accent in European languages and Cyrillic (other scripts are checked exactly), and the app itself in English, Polish, German, French and Ukrainian.
92
+ - Import and export: Anki (plain-text exports and `.apkg` decks from AnkiWeb), CSV, JSON and pasted lists, and export back to Anki.
93
+ - Decks and cards in the app: browse, edit and delete with undo, plus a welcome flow for new users.
94
+ - Optional AI help for writing cards, with your own API key or a local model.
95
+ - Linux and Windows.
96
+
97
+ ## License
98
+
99
+ The code is licensed under [Apache 2.0](LICENSE), so feel free to use it, change it and build on it. The name "Dracosh" and the dragon mascot aren't covered by the license, so forks need their own name. See [NOTICE](NOTICE).
100
+
101
+ Contributions are welcome!
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/data/tips.json ADDED
@@ -0,0 +1,32 @@
1
+ [
2
+ { "id": "keys-enter", "cat": "Keys", "text": "Don't want to wait? Press Enter between cards and the next one comes right away." },
3
+ { "id": "keys-esc", "cat": "Keys", "text": "Esc clears what you typed. Press it on an empty line to quit." },
4
+ { "id": "keys-wake", "cat": "Keys", "text": "Leave Dracosh alone for a few minutes and your dragon dozes off. Any key wakes it." },
5
+ { "id": "keys-filter", "cat": "Keys", "text": "Type / and a letter or two to narrow the commands: /pa finds /pause." },
6
+ { "id": "cards-decks", "cat": "Cards", "text": "/decks switches to another deck or starts a new one. Dracosh opens that deck next time too." },
7
+ { "id": "cards-add", "cat": "Cards", "text": "/add puts new cards into the deck you're practising. Esc when you're done." },
8
+ { "id": "cards-typo", "cat": "Cards", "text": "One wrong letter in a longer word still counts as right. Dracosh shows you the correct spelling." },
9
+ { "id": "cards-boxes", "cat": "Cards", "text": "A right answer sends a card to a later box: it comes back in 1, 3, 7, 14, then 30 days." },
10
+ { "id": "cards-miss", "cat": "Cards", "text": "A missed card goes back to the first box and comes back within minutes, until it sticks." },
11
+ { "id": "cards-hint", "cat": "Cards", "text": "Stuck on a card? /hint reveals one more letter. The card still counts, but stays in its box." },
12
+ { "id": "cards-correct", "cat": "Cards", "text": "Marked wrong although you were right? Type /correct before the next card and it counts." },
13
+ { "id": "cards-dont-know", "cat": "Cards", "text": "Don't know it? Press Enter with nothing typed and the answer shows up. The card comes back soon." },
14
+ { "id": "cards-missed", "cat": "Cards", "text": "/missed lists the cards you got wrong today. Use ← and → to look at earlier days." },
15
+ { "id": "cards-new", "cat": "Cards", "text": "Dracosh mixes new cards in with your reviews, up to 20 new ones a day." },
16
+ { "id": "streak-goal", "cat": "Streak", "text": "Reach your daily goal to keep your streak going. You can change the goal in /settings." },
17
+ { "id": "streak-freeze", "cat": "Streak", "text": "A freeze saves your streak on a day you missed. You start with two and get one back each week." },
18
+ { "id": "streak-weekends", "cat": "Streak", "text": "Weekends are rest days by default: skipping them never breaks your streak. Change it in /settings." },
19
+ { "id": "streak-days-off", "cat": "Streak", "text": "Going away? /pause 7d keeps your streak safe for a week. /pause 24.12 2.01 takes dates." },
20
+ { "id": "streak-stats", "cat": "Streak", "text": "/stats shows your streak and a calendar of the month. Use ← and → to see other months." },
21
+ { "id": "dragon-forms", "cat": "Your dragon", "text": "Your dragon grows with your best streak: a new form at 7, 30, 90, 180 and 365 days." },
22
+ { "id": "dragon-companion", "cat": "Your dragon", "text": "/companion shows your dragon and the forms still ahead of it." },
23
+ { "id": "dragon-combo", "cat": "Your dragon", "text": "Three right answers in a row and your dragon starts to glow. Keep the combo going!" },
24
+ { "id": "dragon-badges", "cat": "Your dragon", "text": "/badges shows every badge and what unlocks it. One of them stays secret until you win it." },
25
+ { "id": "pause-break", "cat": "Breaks", "text": "Need some focus? /pause 30m or /pause 2h holds the cards. /pause off brings them back." },
26
+ { "id": "pause-quiet", "cat": "Breaks", "text": "Set quiet hours in /settings and Dracosh stays silent while you sleep." },
27
+ { "id": "settings-every", "cat": "Settings", "text": "Cards too often, or not often enough? Change the interval in /settings." },
28
+ { "id": "settings-sound", "cat": "Settings", "text": "Sound and volume are in /settings. dracosh --no-sound turns sound off for one run." },
29
+ { "id": "data-backup", "cat": "Your data", "text": "Dracosh backs up your cards and progress every day. dracosh restore brings a backup back." },
30
+ { "id": "data-sync", "cat": "Your data", "text": "dracosh --data shows where your cards live. Point DRACOSH_HOME at a synced folder to use two computers." },
31
+ { "id": "data-deck", "cat": "Your data", "text": "dracosh --deck \"Polish\" starts with another deck, for this run only." }
32
+ ]
package/package.json CHANGED
@@ -1,6 +1,49 @@
1
1
  {
2
2
  "name": "dracosh",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "A gamified language or definitions trainer for your terminal. Your personal pixel dragon grows with your progress.",
5
+ "author": "Tomasz Przyborowski (https://github.com/lynthius)",
6
+ "license": "Apache-2.0",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/lynthius/dracosh.git"
10
+ },
11
+ "homepage": "https://github.com/lynthius/dracosh#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/lynthius/dracosh/issues"
14
+ },
15
+ "keywords": [
16
+ "cli",
17
+ "tui",
18
+ "vocabulary",
19
+ "flashcards",
20
+ "spaced-repetition",
21
+ "anki",
22
+ "ink",
23
+ "pixel-art",
24
+ "language-learning"
25
+ ],
26
+ "type": "module",
27
+ "bin": {
28
+ "dracosh": "src/cli.js"
29
+ },
30
+ "files": [
31
+ "src",
32
+ "assets",
33
+ "data",
34
+ "NOTICE"
35
+ ],
36
+ "engines": {
37
+ "node": ">=22"
38
+ },
39
+ "scripts": {
40
+ "start": "node src/cli.js",
41
+ "test": "node --test test/",
42
+ "sounds": "node scripts/make-sounds.js"
43
+ },
44
+ "dependencies": {
45
+ "htm": "3.1.1",
46
+ "ink": "7.1.1",
47
+ "react": "19.2.4"
48
+ }
49
+ }
package/src/alerts.js ADDED
@@ -0,0 +1,38 @@
1
+ import { execFile } from "node:child_process";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ // 8-bit chiptune effects generated by scripts/make-sounds.js (see `npm run sounds`)
6
+ const SOUND_DIR = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "assets", "sounds");
7
+ const LADDER_STEPS = 6; // correct-0 … correct-5: the pitch climbs with your combo
8
+
9
+ export function createAlerts(initial = {}) {
10
+ const enabled = process.platform === "darwin";
11
+ const config = { sound: true, volume: 0.5, ...initial };
12
+
13
+ const play = (name) => {
14
+ if (!config.sound || !enabled) return;
15
+ execFile("afplay", ["-v", String(config.volume), path.join(SOUND_DIR, `${name}.wav`)], () => {});
16
+ };
17
+
18
+ return {
19
+ play,
20
+ configure: (patch) => Object.assign(config, patch),
21
+ // a new question while you're in another window: sound plus a Notification Center banner
22
+ ask() {
23
+ play("ask");
24
+ if (enabled) execFile("osascript", ["-e", 'display notification "A new word is waiting" with title "Dracosh"'], () => {});
25
+ },
26
+ // The biggest thing that just happened wins: evolution > goal > combo cheer > the answer itself.
27
+ // On a plain correct answer the pitch rises with the combo and resets on a miss. Badges ring
28
+ // on their own, each as its line lights up (see BadgeUnlock).
29
+ result(result, { cheers = [], combo = 0 } = {}) {
30
+ if (result === "wrong") return play("wrong");
31
+ for (const kind of ["evolve", "goal", "combo"]) {
32
+ if (cheers.includes(kind)) return play(kind);
33
+ }
34
+ if (result === "typo") return play("close");
35
+ play(`correct-${Math.min(Math.max(combo - 1, 0), LADDER_STEPS - 1)}`);
36
+ }
37
+ };
38
+ }
package/src/anki.js ADDED
@@ -0,0 +1,36 @@
1
+ // Read-only AnkiConnect client: the quiz never writes to Anki.
2
+ const ANKI_URL = process.env.ANKI_CONNECT_URL || "http://localhost:8765";
3
+
4
+ async function invoke(action, params = {}) {
5
+ let res;
6
+ try {
7
+ res = await fetch(ANKI_URL, {
8
+ method: "POST",
9
+ headers: { "Content-Type": "application/json" },
10
+ body: JSON.stringify({ action, version: 6, params }),
11
+ signal: AbortSignal.timeout(10000)
12
+ });
13
+ } catch {
14
+ throw new Error("Can't reach Anki. Make sure Anki is running with AnkiConnect.");
15
+ }
16
+ const data = await res.json();
17
+ if (data.error) throw new Error(data.error);
18
+ return data.result;
19
+ }
20
+
21
+ const escapeQuery = (s) => s.replace(/[\\"]/g, "\\$&");
22
+
23
+ export async function fetchNotes(deck) {
24
+ const ids = await invoke("findNotes", { query: `deck:"${escapeQuery(deck)}"` });
25
+ if (!ids.length) return [];
26
+ const infos = await invoke("notesInfo", { notes: ids });
27
+ return infos.map(toFrontBack).filter(Boolean);
28
+ }
29
+
30
+ // The first two fields of a note, by position: field names depend on the note type and on
31
+ // Anki's UI language ("Front"/"Back", "Przód"/"Tył", "Vorderseite"/"Rückseite"…).
32
+ export function toFrontBack(info) {
33
+ const fields = Object.values(info.fields ?? {}).sort((a, b) => a.order - b.order);
34
+ if (fields.length < 2) return null;
35
+ return { noteId: info.noteId, front: fields[0].value, back: fields[1].value };
36
+ }
package/src/backup.js ADDED
@@ -0,0 +1,95 @@
1
+ import { copyFile, readdir, rm } from "node:fs/promises";
2
+ import { join } from "node:path";
3
+ import { dayKey } from "./dates.js";
4
+ import { DATA_FILES, HOME, readJson, writeJson } from "./store.js";
5
+
6
+ // A backup is one JSON file in ~/.dracosh/backups holding the library, progress and settings as they
7
+ // were. One is taken on the first start of each day, and right before anything that changes a lot at
8
+ // once (a restore now; imports, deletions and resets later).
9
+ export const BACKUP_DIR = join(HOME, "backups");
10
+ const BACKUP_FORMAT = 1;
11
+ export const KEEP = 7; // per kind: the last 7 daily ones, and the last 7 taken before an operation
12
+
13
+ // "2026-10-09T21:15:03.120Z" → "2026-10-09_21-15-03", so file names sort by time
14
+ const stamp = (now) => new Date(now).toISOString().slice(0, 19).replace("T", "_").replaceAll(":", "-");
15
+
16
+ // → the file it wrote, or null when there is nothing to back up (or, with `skipDamaged`, when a data file
17
+ // is too damaged to read: a backup missing the library would push the good ones out). Otherwise a damaged
18
+ // file is set aside as it is (library.json.damaged-<day>, one a day) and the backup goes on, so a
19
+ // restore still works.
20
+ export async function backupNow(reason, now = Date.now(), { skipDamaged = false } = {}) {
21
+ const files = {};
22
+ for (const [name, file] of Object.entries(DATA_FILES)) {
23
+ try {
24
+ const data = await readJson(file, null);
25
+ if (data) files[name] = data;
26
+ } catch {
27
+ if (name === "settings") continue; // broken settings just mean the defaults: back up the rest
28
+ if (skipDamaged) return null;
29
+ await copyFile(file, `${file}.damaged-${dayKey(now)}`);
30
+ }
31
+ }
32
+ if (!Object.keys(files).length) return null;
33
+ const file = join(BACKUP_DIR, `${stamp(now)}-${reason}.json`);
34
+ await writeJson(file, { format: BACKUP_FORMAT, created: now, reason, files });
35
+ await prune();
36
+ return file;
37
+ }
38
+
39
+ async function backupFiles() {
40
+ try {
41
+ return (await readdir(BACKUP_DIR)).filter((name) => name.endsWith(".json")).sort().reverse(); // newest first
42
+ } catch (err) {
43
+ if (err.code === "ENOENT") return [];
44
+ throw err;
45
+ }
46
+ }
47
+
48
+ const isDaily = (name) => name.endsWith("-daily.json");
49
+
50
+ async function prune() {
51
+ const names = await backupFiles();
52
+ const old = [...names.filter(isDaily).slice(KEEP), ...names.filter((name) => !isDaily(name)).slice(KEEP)];
53
+ await Promise.all(old.map((name) => rm(join(BACKUP_DIR, name), { force: true })));
54
+ }
55
+
56
+ // the first start of a day backs up what the day before left behind
57
+ export async function dailyBackup(now = Date.now()) {
58
+ const today = dayKey(now);
59
+ const backups = await listBackups();
60
+ if (backups.some((b) => b.reason === "daily" && dayKey(b.created) === today)) return null;
61
+ return backupNow("daily", now, { skipDamaged: true });
62
+ }
63
+
64
+ // → newest first: { file, created, reason, decks, cards, practiced }
65
+ export async function listBackups() {
66
+ const list = [];
67
+ for (const name of await backupFiles()) {
68
+ const file = join(BACKUP_DIR, name);
69
+ const backup = await readJson(file, null).catch(() => null); // a damaged file just isn't offered
70
+ if (backup?.format !== BACKUP_FORMAT || !backup.files || typeof backup.files !== "object") continue;
71
+ const { library, state } = backup.files;
72
+ list.push({
73
+ file,
74
+ created: backup.created,
75
+ reason: backup.reason,
76
+ decks: library?.decks?.length ?? 0,
77
+ cards: library?.cards?.length ?? 0,
78
+ practiced: Object.keys(state?.items ?? {}).length,
79
+ hasState: Boolean(state),
80
+ hasSettings: Boolean(backup.files.settings)
81
+ });
82
+ }
83
+ return list.sort((a, b) => b.created - a.created); // file names only go down to the second
84
+ }
85
+
86
+ // Puts a backup's files back. What's there now is backed up first, so a restore can be undone too.
87
+ // A file the backup doesn't have is left as it is: a restore never deletes your cards or progress.
88
+ export async function restoreBackup(file, now = Date.now()) {
89
+ const backup = await readJson(file, null);
90
+ if (backup?.format !== BACKUP_FORMAT || !backup.files) throw new Error(`${file} isn't a Dracosh backup.`);
91
+ await backupNow("before-restore", now);
92
+ for (const [name, target] of Object.entries(DATA_FILES)) {
93
+ if (backup.files[name]) await writeJson(target, backup.files[name]);
94
+ }
95
+ }