dsh-nerd-mode 0.4.0 → 0.4.3
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/README.md +19 -16
- package/README.zh.md +19 -16
- package/assets/calibration.svg +2 -2
- package/assets/section.md +15 -0
- package/client.js +93 -77
- package/cordis.patch.yml +10 -14
- package/lib/index.js +223 -213
- package/package.json +1 -1
- package/skills/study/SKILL.md +3 -3
- package/skills/study-plus/SKILL.md +26 -19
- package/skills/study-plus/scripts/book-data.mjs +3 -3
- package/skills/study-plus/scripts/build-book.mjs +5 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: study-plus
|
|
3
3
|
description: Run one tracked session against a dated learning record. Load for an explicit command or after the user chooses tracked study in the upper router.
|
|
4
|
-
argument-hint: "<
|
|
4
|
+
argument-hint: "<course-slug>, or empty to continue the current Course"
|
|
5
5
|
---
|
|
6
6
|
# Study Plus
|
|
7
7
|
|
|
@@ -14,23 +14,29 @@ Two rules override everything below.
|
|
|
14
14
|
|
|
15
15
|
## 1. Find the workspace and material
|
|
16
16
|
|
|
17
|
-
The
|
|
17
|
+
The Course directory is `study/<course>/` in the workspace root, where `<course>` is the Course name in lowercase with hyphens.
|
|
18
18
|
|
|
19
19
|
Find it with a recursive search. Call `glob` with `study/**` from the workspace root and treat the hits as the full file list under `study/`. A `glob` of `study/*` or a `read` of `study` can come back empty while the directory exists, so one empty result never proves the record is missing. When either returns nothing, call `glob` with `**/study/**/graph.md` before you decide. Name the path you searched whenever you say no record exists.
|
|
20
20
|
|
|
21
|
-
- With an argument: resolve the slug. If the directory exists, continue it. If it does not exist, build the graph (section 2). If it exists without a `graph.md`, the folder belongs to something else, so ask before writing.
|
|
22
|
-
- Without an argument:
|
|
21
|
+
- With an argument: resolve the slug. If the directory exists, continue it. If it does not exist, ask once whether to create it, then build the graph (section 2). If it exists without a `graph.md`, the folder belongs to something else, so ask before writing.
|
|
22
|
+
- Without an argument: the first tracked study settles the Course. Exactly one Course is used and named in one line. A new Course from the path item asks for its name once; every other Course is named without a question. Several Courses get one question that lists them and offers a new Course.
|
|
23
23
|
- No `study/` anywhere in the workspace: create it on first use.
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
When the opening question runs, it carries the Course in its path item: one complete answer in this conversation with no Course record, one continue choice for each existing Course, then start a new Course. Show a continue choice only for a Course that exists under `study/`. Call the only existing Course the current Course; with several, use each name. One round for the opening question, with no separate path question. An explicit `/study-plus` skips the opening question, so the Course question stands alone there. Settle the Course once per conversation and never ask again.
|
|
26
|
+
|
|
27
|
+
A new Course from the path item asks for its name once before the graph. Offer the request's subject as the suggested name. When the name matches an existing Course, ask whether to continue that Course or use another name. An explicit `/study-plus <course>` settles the Course with no question. Otherwise, the name comes from the learner's words. Slug it the way the record path is slugged today, show the slug in the confirmation line, and create the folder on first write.
|
|
28
|
+
|
|
29
|
+
When the conversation has a Course and the request is about a different subject, ask one question with two options: add these concepts to the current Course, or start a new Course. The first option runs the existing graph change. Never ask two questions in one turn.
|
|
30
|
+
|
|
31
|
+
Each Course holds `graph.md`, `state.md`, and `log.md`, plus `lectures/`, `diagrams/`, and `lectures/archive/` as needed. Read `graph.md`, `state.md`, and the last two blocks of `log.md` before you speak. A legacy `plan.md` is inert user data: never read it, never write it, never delete it. Do not read or write an unrelated file under `study/` just because the directory search finds it.
|
|
26
32
|
|
|
27
33
|
Use material supplied with the current request as scope and reference. Read it, then check important or uncertain claims when needed. Accuracy wins over the source, and relevant differences must be flagged. Use the approved graph and material by default. Do not research the web for every lecture.
|
|
28
34
|
|
|
29
|
-
The record belongs to this workspace. The same
|
|
35
|
+
The record belongs to this workspace. The same Course studied in another folder starts a separate record. If the learner moves workspaces mid-Course, say so and offer to copy `study/<course>/` across.
|
|
30
36
|
|
|
31
37
|
## 2. Build, migrate, or change the graph
|
|
32
38
|
|
|
33
|
-
For a new
|
|
39
|
+
For a new Course, or when the learner asks for a change, build or rebuild the graph. For a legacy graph that uses `Structure` or `Block`, show a migration preview before continuing. If an existing graph lacks both Chapter/Section metadata and Structure/Block grouping, propose Chapter/Section groupings from its concepts and prerequisites, show the preview, and ask whether to retain or adjust it before writing. Convert legacy groupings to `Chapters`, `Chapter`, and `Section`. If the graph gives no chapter grouping, propose logical groupings. Ask only whether to retain or adjust the preview. After confirmation, write the normalized graph once. Do not change tracker states or lecture bodies.
|
|
34
40
|
|
|
35
41
|
A graph change keeps work the learner already has.
|
|
36
42
|
|
|
@@ -45,8 +51,8 @@ For a new graph:
|
|
|
45
51
|
1. Use supplied material first, then reliable sources when needed, then your own knowledge. Do not research the web for every lecture.
|
|
46
52
|
2. Make a concept table in prerequisite order. Each row has a one-line definition and prerequisite numbers. Keep prerequisite order separate from textbook reading order.
|
|
47
53
|
3. Use the source's book and chapter hierarchy when present. Otherwise, propose logical chapter groupings.
|
|
48
|
-
4.
|
|
49
|
-
5. After approval, run calibration as one `question` call with three items: what the learner wants to be able to do after this
|
|
54
|
+
4. Show the full graph and chapter layout in the reply before the approval question, as a Markdown table. Keep the question text short, because it renders as one paragraph: ask whether to approve, edit, or rebuild the graph shown above, and state that approval starts draft generation for every concept, including any concept the learner then skips, and that drafts are not teaching. Do not put the table in the question text. Do not add another approval step.
|
|
55
|
+
5. After approval, run calibration as one `question` call with up to three items: what the learner wants to be able to do after this Course, what they have already read, studied, or used in this area in their own words, and which concepts in the approved graph they know well enough to skip, as a multi-select list. Items 1 and 2 are free text. Ask the goal and background items only when nothing already answers them: not the current request, not the opening question, not the supplied material. Reuse an opening-question answer verbatim. Derive the level. Then write `graph.md`, create `state.md` with every concept `new` and undated except the concepts selected to skip, which are `skipped`, create an empty `log.md`, and generate one draft per concept (section 3). Do not create `plan.md`.
|
|
50
56
|
|
|
51
57
|
Calibration writes `Goal`, `Background`, and `Teaching level` to `graph.md`. Derive the level from the two answers:
|
|
52
58
|
|
|
@@ -58,15 +64,15 @@ Calibration writes `Goal`, `Background`, and `Teaching level` to `graph.md`. Der
|
|
|
58
64
|
|
|
59
65
|
When the two answers clearly conflict, you may choose an adjacent level and state the reason in one line. When the learner declines or gives no usable answer, write `Teaching level: standard` and omit the `Goal` and `Background` lines. Each selected concept becomes `skipped`, with no date and no passes.
|
|
60
66
|
|
|
61
|
-
Do not ask for calibration on a
|
|
67
|
+
Do not ask for calibration on a Course that already has a `graph.md`. A missing `Teaching level` line means `standard`. A graph rebuild keeps the existing `Goal`, `Background`, and `Teaching level` values and asks for nothing the previous graph already recorded.
|
|
62
68
|
|
|
63
|
-
A mid-
|
|
69
|
+
A mid-Course request such as "too detailed" or "give me the conclusion" changes the level for this session only. Write nothing to `graph.md` and add no log entry. A learner preference is not evidence. When the learner says to keep the change, rewrite the `Teaching level` line and keep the other two lines. This is the only path that changes an existing Course, and the only upgrade path for a Course with no `Teaching level` line.
|
|
64
70
|
|
|
65
71
|
The level never changes the Recall Session, the skipped-prerequisite recap, the unseen questions, the Teach-back, the pass threshold, or any learner state. It affects the lecture only.
|
|
66
72
|
|
|
67
73
|
The hierarchy is Book, Chapter, Section. A graph concept is one Section named after the concept. A lecture is the teaching explanation for one concept in one Concept cycle. It is not a book, chapter, or separate graph concept.
|
|
68
74
|
|
|
69
|
-
`graph.md` keeps `#
|
|
75
|
+
`graph.md` keeps `# Course: <name>`, `Goal`, `Background`, and `Teaching level`, and may add `Book: <title>`. A new file opens with `# Course: <name>`. A reader accepts `# Topic:` as well, so an older graph keeps its title, and the skill never rewrites an existing `# Topic:` heading. The three brief lines are optional. If `Book` is absent, use the Course as the book title. A multi-chapter graph has `## Chapters` followed by numbered rows in book order: `1. <chapter title>: <scope>`. The concept table keeps prerequisite order and adds integer `Chapter` and `Section` columns. Each concept belongs to one chapter and one section. Number sections from 1 within each chapter in textbook order. A single-chapter graph still uses `Chapter = 1` and section numbers, but omits `## Chapters`; use the Book title, or Course fallback, as the displayed chapter title.
|
|
70
76
|
|
|
71
77
|
A wrong order mis-teaches for weeks. Do not skip the approval.
|
|
72
78
|
|
|
@@ -74,7 +80,7 @@ A wrong order mis-teaches for weeks. Do not skip the approval.
|
|
|
74
80
|
|
|
75
81
|
A Lecture draft is complete teaching material written before any Concept cycle. It is not teaching, it carries no teaching date, and it changes no learner state.
|
|
76
82
|
|
|
77
|
-
1. Compute one destination per concept: `study/<
|
|
83
|
+
1. Compute one destination per concept: `study/<course>/lectures/<NN>-<concept-slug>.md`, where `NN` is the graph's concept number padded to at least two digits. The list covers every concept, including skipped concepts.
|
|
78
84
|
2. Hand the approved graph, the relevant supplied material, the three brief lines, and that explicit destination list to `study`. Copy `Goal`, `Background`, and `Teaching level` from `graph.md` verbatim: do not compress, summarize, or rewrite them. Pass one Chapter per request. `study` owns the draft content and its frontmatter, and it never reads tracker files or chooses paths.
|
|
79
85
|
3. Split the Chapters across subagents when they are available. Give each one the `study` draft rules and keep each agent's destination list disjoint. Without subagents, write the Chapters yourself, one at a time.
|
|
80
86
|
4. Check every returned file: path, `status: draft`, the `concept` number, one H1, coverage of every concept in the Chapter, prerequisite consistency, use of the supplied material, and any contradiction across Chapters. Report a contradiction in one line.
|
|
@@ -122,15 +128,15 @@ A tracked lecture belongs in `lectures/<NN>-<slug>.md`, with `date` and `concept
|
|
|
122
128
|
|
|
123
129
|
Teach one concept according to `study`'s lecture rules. Write or update the Markdown file yourself, then show the same lecture content in the conversation. For long source material, give a roadmap and progress. Save the complete lecture file before displaying it in chunks if a platform limit requires chunking. Do not start assessment until the full lecture is displayed.
|
|
124
130
|
|
|
125
|
-
The lecture has no length cap. Teach until the concept is complete at the given level. For visual authoring rules, load `diagram`, but save figures only under the scoped
|
|
131
|
+
The lecture has no length cap. Teach until the concept is complete at the given level. For visual authoring rules, load `diagram`, but save figures only under the scoped Course's `study/<course>/diagrams/<name>.svg`, not its generic default. Sanitize the figure name to one lowercase kebab-case segment with no slashes or dot segments. If it is unclear, choose a safe fallback. Before writing, confirm the resolved parent stays within the scoped Course's `diagrams/` root and the target is not `graph.md`, `state.md`, or `log.md`. Compute every plotted point with the host shell. Use `pwsh` on Windows and `bash` on macOS or Linux. Never place a point by eye. Before replacing a same-name SVG, copy the old file to `<name>.svg.bak`, replacing any older backup.
|
|
126
132
|
|
|
127
133
|
If saving the lecture fails, continue the assessment and record produced evidence. Tell the learner which save path failed.
|
|
128
134
|
|
|
129
135
|
If the row was already `in_process`, say that the last session stopped before the questions, repeat the full lecture, then go to the questions. The configured question slots were never asked, so they are still unseen. When the log records a defer rather than a crash, say what remains and offer the questions before repeating the lecture.
|
|
130
136
|
|
|
131
|
-
**Ask unseen questions.** Use the explicit count or type preference in the current `/study-plus` request when present. Otherwise, use the profile defaults in the top-level Nerd Mode instructions. Plan the configured number of unseen question slots, from 0 to 10. A hint, re-ask, or similar question stays in its current slot and does not add a slot. For each slot, write down the expected answer and criteria for a good answer. Keep both private. A draft never contains them. The criteria test the conclusion and whether each step taken is valid, not the route you had in mind. Ask one question at a time, then wait. Outside `study-plus`, ignore these preferences.
|
|
137
|
+
**Ask unseen questions.** Use the explicit count or type preference in the current `/study-plus` request when present. Otherwise, use the profile defaults in the top-level Nerd Mode instructions. Plan the configured number of unseen question slots, from 0 to 10. A hint, re-ask, or similar question stays in its current slot and does not add a slot. For each slot, write down the expected answer and criteria for a good answer. Keep both private. A draft never contains them. The criteria test the conclusion and whether each step taken is valid, not the route you had in mind. Ask one question at a time, then wait. One call asks one question. Outside `study-plus`, ignore these preferences.
|
|
132
138
|
|
|
133
|
-
For `short-answer`, ask
|
|
139
|
+
For `short-answer`, ask the question in the conversation. For `multiple-choice`, ask it as one `question` call with four options and exactly one correct answer; choosing it is sufficient. Give the labels alone, with no description, and shuffle the four positions for each slot. A host without a `question` tool gets the same four options as a numbered text list. A typed answer that names or repeats one option counts as choosing it. Any other typed answer is graded like a short answer. For `mixed`, choose short-answer or multiple-choice independently at random for each planned slot. Do not add question-type details to the session log. When the configured count is zero, skip unseen questions. A passed Teach-back alone is sufficient to pass. With one or more slots, require a passed Teach-back and `ceil(2 × slot count / 3)` correct slots.
|
|
134
140
|
|
|
135
141
|
A question exists to find the gap, not to stop the session. Nothing in this step blocks the learner.
|
|
136
142
|
|
|
@@ -140,6 +146,7 @@ A question exists to find the gap, not to stop the session. Nothing in this step
|
|
|
140
146
|
- When an answer is wrong, do three things in one message: name the wrong step, work the correct answer with its process, then ask a similar question in the same slot. Mark one miss. Keep the original miss recorded even if the learner answers the similar question correctly.
|
|
141
147
|
- When the learner asks for the answer, do the same: give the worked answer, mark one miss, ask a similar question in the same slot. Keep the original miss recorded even if the learner answers the similar question correctly.
|
|
142
148
|
- When the learner defers a question or asks to move on, accept it at once. Record the defer and the learner's reason in the log. The concept stays `in_process`, because a defer is neither evidence nor a miss. Never argue about time.
|
|
149
|
+
- When the learner closes the question card or the card times out, treat it as no answer. Ask the same question once more. If it happens again, record a defer with no reason. The concept stays `in_process`.
|
|
143
150
|
|
|
144
151
|
**Teach-back.** Ask the learner to explain the idea to someone who has not seen it. Grade two things: the idea is correct, and the explanation would let that person use it. Note whether the language stays plain. Do not ask where the idea stops applying. When the answer is valid overall and something is missing or loose, name it, correct it in one sentence, and pass. A miss is for a wrong idea, not for a gap you can close in the moment.
|
|
145
152
|
|
|
@@ -173,7 +180,7 @@ After a completed cycle, rebuild the Book (section 8) and offer three choices in
|
|
|
173
180
|
`graph.md`:
|
|
174
181
|
|
|
175
182
|
```md
|
|
176
|
-
#
|
|
183
|
+
# Course: <course>
|
|
177
184
|
Goal: <one line, optional>
|
|
178
185
|
Background: <one line, optional>
|
|
179
186
|
Teaching level: beginner | standard | advanced
|
|
@@ -188,7 +195,7 @@ Book: <title, optional>
|
|
|
188
195
|
| 2 | <name> | <one line> | 1 | 1 | 2 |
|
|
189
196
|
```
|
|
190
197
|
|
|
191
|
-
Omit `Book` when the
|
|
198
|
+
Omit `Book` when the Course is the title. Omit `## Chapters` for one chapter. Use that chapter's table value `Chapter = 1` and section numbers within it. `Goal`, `Background`, and `Teaching level` are optional, and the values are lowercase. A missing `Teaching level` means `standard`. The Book shows no `Background` or `Teaching level` line.
|
|
192
199
|
|
|
193
200
|
A dated Lecture and a Lecture draft share one file per concept and differ in frontmatter:
|
|
194
201
|
|
|
@@ -214,7 +221,7 @@ A legacy `plan.md` stays on disk untouched. Nothing reads or writes it.
|
|
|
214
221
|
|
|
215
222
|
Assemble a book by grouping lecture files according to Chapter and Section metadata, in textbook order, including drafts and dated Lectures. Each lecture file remains one concept. The page labels a draft as a draft and never shows learner states.
|
|
216
223
|
|
|
217
|
-
Run `node skills/study-plus/scripts/build-book.mjs study/<
|
|
224
|
+
Run `node skills/study-plus/scripts/build-book.mjs study/<course>` from the workspace root after a complete or partial draft batch, after saving a Lecture, and after a graph rebuild. The learner does not need to ask. The builder copies the current `book.html` to `book.html.bak` before each replacement, and it replaces the older backup. If the builder fails, the current Book stays intact: say which path failed in one line and continue the Concept cycle. If it reports a malformed graph, explain the issue and propose a graph fix for confirmation before changing it.
|
|
218
225
|
|
|
219
226
|
`state.md`:
|
|
220
227
|
|
|
@@ -96,8 +96,8 @@ function readChapterList(text, heading, errors) {
|
|
|
96
96
|
|
|
97
97
|
function graphMetadata(text, topicFallback) {
|
|
98
98
|
const firstHeading = text.match(/^#\s+(.+?)\s*$/m)?.[1]?.trim() || '';
|
|
99
|
-
const headingTopic = firstHeading.replace(/^Topic:\s*/i, '');
|
|
100
|
-
const topic = (headingTopic.toLowerCase() === 'topic' ? '' : headingTopic || topicFallback || '
|
|
99
|
+
const headingTopic = firstHeading.replace(/^(?:Topic|Course):\s*/i, '');
|
|
100
|
+
const topic = (headingTopic.toLowerCase() === 'topic' || headingTopic.toLowerCase() === 'course' ? '' : headingTopic || topicFallback || 'Course').trim();
|
|
101
101
|
const book = (text.match(/^Book:\s*(.+?)\s*$/mi)?.[1] || '').trim();
|
|
102
102
|
const goal = (text.match(/^Goal:\s*(.*?)\s*$/mi)?.[1] || '').trim();
|
|
103
103
|
return { topic, title: book || topic, goal };
|
|
@@ -237,7 +237,7 @@ function demote(body) {
|
|
|
237
237
|
/** Parse a graph and its lecture files into ordered book chapters and sections. */
|
|
238
238
|
export function parseBookData(graphText, lectureFiles, { topicFallback = '' } = {}) {
|
|
239
239
|
const graph = parseGraph(graphText, topicFallback);
|
|
240
|
-
if (!lectureFiles.length) throw new Error('No lecture files found. Add Markdown lectures under the
|
|
240
|
+
if (!lectureFiles.length) throw new Error('No lecture files found. Add Markdown lectures under the Course lectures/ folder.');
|
|
241
241
|
|
|
242
242
|
const lectures = lectureFiles.map(parseLecture);
|
|
243
243
|
const byConcept = new Map();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
// Build study/<
|
|
2
|
+
// Build study/<course>/book.html from the graph and its existing lecture files.
|
|
3
3
|
|
|
4
4
|
import { readFileSync, readdirSync, writeFileSync, existsSync, unlinkSync, realpathSync, statSync, lstatSync, copyFileSync, renameSync } from 'node:fs';
|
|
5
5
|
import { join, resolve, dirname, relative, isAbsolute, sep } from 'node:path';
|
|
@@ -23,7 +23,7 @@ function findTopic(arg) {
|
|
|
23
23
|
try {
|
|
24
24
|
studyStat = lstatSync(studyPath);
|
|
25
25
|
} catch (error) {
|
|
26
|
-
if (error.code === 'ENOENT') die('No study/ folder here. Pass a
|
|
26
|
+
if (error.code === 'ENOENT') die('No study/ folder here. Pass a Course folder under workspace study/.');
|
|
27
27
|
die(`Cannot inspect workspace study/ folder: ${error.message}`);
|
|
28
28
|
}
|
|
29
29
|
if (studyStat.isSymbolicLink()) die(`Refusing to use symlink as workspace study/ folder: ${studyPath}`);
|
|
@@ -38,7 +38,7 @@ function findTopic(arg) {
|
|
|
38
38
|
let topicPath = arg ? resolve(arg) : '';
|
|
39
39
|
if (!arg) {
|
|
40
40
|
const hits = readdirSync(studyRoot).filter((name) => existsSync(join(studyRoot, name, 'graph.md')));
|
|
41
|
-
if (hits.length !== 1) die(`Pass a
|
|
41
|
+
if (hits.length !== 1) die(`Pass a Course folder under workspace study/. Found ${hits.length} Courses under study/: ${hits.join(', ') || 'none'}.`);
|
|
42
42
|
topicPath = join(studyRoot, hits[0]);
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -46,11 +46,11 @@ function findTopic(arg) {
|
|
|
46
46
|
try {
|
|
47
47
|
topicDir = realpathSync(topicPath);
|
|
48
48
|
} catch (error) {
|
|
49
|
-
die(`Cannot resolve
|
|
49
|
+
die(`Cannot resolve Course folder ${topicPath}: ${error.message}`);
|
|
50
50
|
}
|
|
51
51
|
const topicRelative = relative(studyRoot, topicDir);
|
|
52
52
|
if (!statSync(topicDir).isDirectory() || !topicRelative || topicRelative === '..' || topicRelative.startsWith(`..${sep}`) || isAbsolute(topicRelative)) {
|
|
53
|
-
die(`
|
|
53
|
+
die(`Course folder must be a real directory at least one level below workspace study/: ${topicPath}`);
|
|
54
54
|
}
|
|
55
55
|
return topicDir;
|
|
56
56
|
}
|