@alstate/fsrs 0.1.0 → 0.1.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 (3) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +62 -5
  3. package/package.json +36 -36
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Alstate contributors
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alstate contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,15 +1,72 @@
1
1
  # `@alstate/fsrs`
2
2
 
3
- Experimental first-party adapter from `ts-fsrs` to `@alstate/core`.
3
+ Experimental first-party adapter from `ts-fsrs` to the `@alstate/core`
4
+ algorithm contract. The package delegates scheduling mathematics to `ts-fsrs`
5
+ and owns the Alstate rating mapping, JSON persistence format and date
6
+ conversion.
7
+
8
+ ## Install
9
+
10
+ ```bash
11
+ npm install @alstate/core @alstate/fsrs
12
+ ```
13
+
14
+ Add a `LearningStore` separately; `@alstate/sqlite` is the first-party choice.
15
+
16
+ ## Use
4
17
 
5
18
  ```ts
6
19
  import { FsrsAlgorithm } from "@alstate/fsrs";
7
20
 
8
- const algorithm = new FsrsAlgorithm({ requestRetention: 0.9 });
21
+ const algorithm = new FsrsAlgorithm({
22
+ requestRetention: 0.9,
23
+ maximumInterval: 36_500,
24
+ enableFuzz: true,
25
+ enableShortTerm: true,
26
+ learningSteps: ["1m", "10m"],
27
+ relearningSteps: ["10m"],
28
+ });
9
29
  ```
10
30
 
11
- This package does not reimplement FSRS. It delegates scheduling to `ts-fsrs`
12
- and owns the Alstate rating mapping, JSON persistence format and date
13
- conversion.
31
+ Pass it to `LearningEngine.create({ store, algorithm })`. The adapter exposes
32
+ these exact rating values:
33
+
34
+ ```text
35
+ again hard good easy
36
+ ```
37
+
38
+ Pass a lower-case value to `engine.review()`. Use the previews returned by
39
+ `engine.due()` to display the next due time for each choice.
40
+
41
+ ## Options
42
+
43
+ | Option | Purpose |
44
+ | --- | --- |
45
+ | `requestRetention` | Target recall probability; higher values generally increase review load. |
46
+ | `maximumInterval` | Maximum scheduled interval in days. |
47
+ | `weights` | Complete FSRS model weight array. |
48
+ | `enableFuzz` | Randomizes longer intervals slightly. |
49
+ | `enableShortTerm` | Enables short-term scheduling behavior. |
50
+ | `learningSteps` | Steps for new items, using values such as `"1m"`, `"10m"` and `"1d"`. |
51
+ | `relearningSteps` | Steps used after a lapse. |
52
+
53
+ Omitted options use the defaults from the installed `ts-fsrs` version.
54
+ `algorithm.configuration` exposes the complete normalized configuration that
55
+ Alstate registers.
56
+
57
+ ## Persistence compatibility
58
+
59
+ Algorithm name, `ts-fsrs` version and normalized configuration identify how
60
+ persisted FSRS state is interpreted. Reopening an existing database with changed
61
+ options or a changed FSRS version raises `AlgorithmMismatchError`; migrate state
62
+ explicitly or use another database. Alstate `0.1.x` has no general state
63
+ migration API.
64
+
65
+ The exported `FsrsState` and `FsrsReviewData` types describe persisted JSON for
66
+ typed inspection. Applications should treat those formats as algorithm-owned.
67
+
68
+ - [SQLite and FSRS adapter guide](https://github.com/laiqfun/alstate/blob/main/docs/adapters.md)
69
+ - [Complete API reference](https://github.com/laiqfun/alstate/blob/main/docs/api-reference.md)
70
+ - [Getting started](https://github.com/laiqfun/alstate/blob/main/docs/getting-started.md)
14
71
 
15
72
  MIT
package/package.json CHANGED
@@ -1,36 +1,36 @@
1
- {
2
- "name": "@alstate/fsrs",
3
- "version": "0.1.0",
4
- "description": "First-party ts-fsrs adapter for Alstate.",
5
- "keywords": ["learning", "scheduling", "fsrs", "spaced-repetition"],
6
- "type": "module",
7
- "main": "./dist/index.js",
8
- "types": "./dist/index.d.ts",
9
- "exports": {
10
- ".": {
11
- "types": "./dist/index.d.ts",
12
- "import": "./dist/index.js"
13
- }
14
- },
15
- "files": ["dist", "README.md", "LICENSE"],
16
- "sideEffects": false,
17
- "scripts": {
18
- "build": "tsc --project tsconfig.build.json",
19
- "clean": "node --eval \"require('node:fs').rmSync('dist', { recursive: true, force: true }); require('node:fs').rmSync('.test-dist', { recursive: true, force: true })\"",
20
- "test": "tsc --project tsconfig.test.json && node --test \".test-dist/test/**/*.test.js\"",
21
- "typecheck": "tsc --project tsconfig.json --noEmit"
22
- },
23
- "dependencies": {
24
- "@alstate/core": "0.1.0",
25
- "ts-fsrs": "^5.4.1"
26
- },
27
- "license": "MIT",
28
- "repository": {
29
- "type": "git",
30
- "url": "git+https://github.com/laiqfun/alstate.git",
31
- "directory": "packages/fsrs"
32
- },
33
- "homepage": "https://github.com/laiqfun/alstate#readme",
34
- "bugs": { "url": "https://github.com/laiqfun/alstate/issues" },
35
- "publishConfig": { "access": "public" }
36
- }
1
+ {
2
+ "name": "@alstate/fsrs",
3
+ "version": "0.1.1",
4
+ "description": "First-party ts-fsrs adapter for Alstate.",
5
+ "keywords": ["learning", "scheduling", "fsrs", "spaced-repetition"],
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": ["dist", "README.md", "LICENSE"],
16
+ "sideEffects": false,
17
+ "scripts": {
18
+ "build": "tsc --project tsconfig.build.json",
19
+ "clean": "node --eval \"require('node:fs').rmSync('dist', { recursive: true, force: true }); require('node:fs').rmSync('.test-dist', { recursive: true, force: true })\"",
20
+ "test": "tsc --project tsconfig.test.json && node --test \".test-dist/test/**/*.test.js\"",
21
+ "typecheck": "tsc --project tsconfig.json --noEmit"
22
+ },
23
+ "dependencies": {
24
+ "@alstate/core": "0.1.1",
25
+ "ts-fsrs": "^5.4.1"
26
+ },
27
+ "license": "MIT",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/laiqfun/alstate.git",
31
+ "directory": "packages/fsrs"
32
+ },
33
+ "homepage": "https://github.com/laiqfun/alstate#readme",
34
+ "bugs": { "url": "https://github.com/laiqfun/alstate/issues" },
35
+ "publishConfig": { "access": "public" }
36
+ }