dsh-plugin-lookatstudy 0.12.3 → 0.12.5
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.
- package/lib/client.js +94 -19
- package/lib/client.js.map +1 -1
- package/lib/index.mjs +41 -1
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -945,7 +945,10 @@ function setMemory(state, category, content, lessonId) {
|
|
|
945
945
|
function addNote(state, lessonId, zone, title, text, source, quote, now) {
|
|
946
946
|
const ref = findLesson(state, lessonId);
|
|
947
947
|
const note = {
|
|
948
|
-
id: `${lessonId}:n${ref.lesson.notes.
|
|
948
|
+
id: `${lessonId}:n${ref.lesson.notes.reduce((max, n) => {
|
|
949
|
+
const m = /:n(\d+)$/.exec(n.id);
|
|
950
|
+
return m !== null ? Math.max(max, Number(m[1])) : max;
|
|
951
|
+
}, -1) + 1}`,
|
|
949
952
|
zone,
|
|
950
953
|
title,
|
|
951
954
|
text,
|
|
@@ -957,6 +960,19 @@ function addNote(state, lessonId, zone, title, text, source, quote, now) {
|
|
|
957
960
|
return note;
|
|
958
961
|
}
|
|
959
962
|
/**
|
|
963
|
+
* Delete one notebook entry from a lesson's Cornell zones.
|
|
964
|
+
* @param state - state to mutate.
|
|
965
|
+
* @param lessonId - lesson the note belongs to.
|
|
966
|
+
* @param noteId - id of the note to remove.
|
|
967
|
+
* @throws when the lesson or the note id is unknown (fail loud, like every id lookup).
|
|
968
|
+
*/
|
|
969
|
+
function deleteNote(state, lessonId, noteId) {
|
|
970
|
+
const ref = findLesson(state, lessonId);
|
|
971
|
+
const index = ref.lesson.notes.findIndex((n) => n.id === noteId);
|
|
972
|
+
if (index === -1) throw new Error(`lookatstudy-plugin: note ${JSON.stringify(noteId)} not found on lesson ${JSON.stringify(lessonId)}`);
|
|
973
|
+
ref.lesson.notes.splice(index, 1);
|
|
974
|
+
}
|
|
975
|
+
/**
|
|
960
976
|
* Propose early mastery graduation for the learner to accept or reject in chat.
|
|
961
977
|
* @param state - state to mutate.
|
|
962
978
|
* @param lessonId - lesson judged mastered.
|
|
@@ -1597,6 +1613,28 @@ function registerDashboard(webServer, deps) {
|
|
|
1597
1613
|
}
|
|
1598
1614
|
return;
|
|
1599
1615
|
}
|
|
1616
|
+
if (req.method === "POST" && pathname === "/lookatstudy/api/note/delete") {
|
|
1617
|
+
const body = await readJsonBodySafe(req, res);
|
|
1618
|
+
if (body === void 0) return;
|
|
1619
|
+
if (typeof body.lessonId !== "string" || typeof body.noteId !== "string") {
|
|
1620
|
+
sendJson(res, 400, {
|
|
1621
|
+
ok: false,
|
|
1622
|
+
error: "lessonId and noteId (strings) required"
|
|
1623
|
+
});
|
|
1624
|
+
return;
|
|
1625
|
+
}
|
|
1626
|
+
try {
|
|
1627
|
+
deleteNote(deps.store.get(), body.lessonId, body.noteId);
|
|
1628
|
+
deps.store.save();
|
|
1629
|
+
sendJson(res, 200, { ok: true });
|
|
1630
|
+
} catch (error) {
|
|
1631
|
+
sendJson(res, 404, {
|
|
1632
|
+
ok: false,
|
|
1633
|
+
error: error instanceof Error ? error.message : String(error)
|
|
1634
|
+
});
|
|
1635
|
+
}
|
|
1636
|
+
return;
|
|
1637
|
+
}
|
|
1600
1638
|
if (req.method === "POST" && pathname === "/lookatstudy/api/lesson-session") {
|
|
1601
1639
|
const body = await readJsonBodySafe(req, res);
|
|
1602
1640
|
if (body === void 0) return;
|
|
@@ -1687,6 +1725,8 @@ const ZH = {
|
|
|
1687
1725
|
"rail.delete": "删除本课程",
|
|
1688
1726
|
"rail.delete.confirm": "确认删除?",
|
|
1689
1727
|
"rail.delete.title.confirm": "再点一次确认删除(含全部进度与笔记)。反悔前可先在设置页备份状态文件",
|
|
1728
|
+
"note.delete": "删除本条笔记",
|
|
1729
|
+
"note.delete.confirm": "确认删除?",
|
|
1690
1730
|
"rail.section.collapse": "折叠本章节",
|
|
1691
1731
|
"rail.section.expand": "展开本章节({count} 课时)",
|
|
1692
1732
|
"rail.section.count": "{count} 课",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-lookatstudy",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.5",
|
|
4
4
|
"packageManager": "pnpm@11.7.0",
|
|
5
5
|
"description": "Turn any markdown, local folder, or GitHub learning repo into a guided course inside DeepSeek Harness: gated skill-tree progression, BKT mastery tracking, SM-2 spaced repetition.",
|
|
6
6
|
"type": "module",
|