learn-anything-cli 0.2.1 โ†’ 0.4.0-beta.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 (37) hide show
  1. package/README.md +2 -0
  2. package/dist/cli/index.js +1 -1
  3. package/dist/core/command-generation/registry.js +1 -1
  4. package/dist/core/config.js +148 -20
  5. package/dist/core/init.d.ts +2 -0
  6. package/dist/core/init.js +36 -6
  7. package/dist/core/learn-protocol/index.d.ts +8 -0
  8. package/dist/core/learn-protocol/index.js +5 -0
  9. package/dist/core/learn-protocol/migrate.d.ts +52 -0
  10. package/dist/core/learn-protocol/migrate.js +259 -0
  11. package/dist/core/learn-protocol/parser.d.ts +33 -0
  12. package/dist/core/learn-protocol/parser.js +150 -0
  13. package/dist/core/learn-protocol/schema.d.ts +38 -0
  14. package/dist/core/learn-protocol/schema.js +43 -0
  15. package/dist/core/learn-protocol/slug.d.ts +13 -0
  16. package/dist/core/learn-protocol/slug.js +28 -0
  17. package/dist/core/learn-protocol/types.d.ts +63 -0
  18. package/dist/core/learn-protocol/types.js +2 -0
  19. package/dist/core/shared/skill-generation.js +25 -5
  20. package/dist/core/templates/skill-templates.d.ts +5 -5
  21. package/dist/core/templates/skill-templates.js +5 -5
  22. package/dist/core/templates/workflows/learn-explain.js +65 -142
  23. package/dist/core/templates/workflows/learn-practice.js +88 -282
  24. package/dist/core/templates/workflows/learn-review.js +35 -93
  25. package/dist/core/templates/workflows/learn-status.js +26 -69
  26. package/dist/core/templates/workflows/learn-topic.js +73 -82
  27. package/dist/i18n/index.js +1 -4
  28. package/dist/i18n/locales/en.js +1 -0
  29. package/dist/i18n/locales/zh-CN.js +1 -0
  30. package/dist/i18n/types.d.ts +1 -0
  31. package/dist/scripts/render.d.mts +13 -0
  32. package/dist/scripts/render.mjs +112 -0
  33. package/dist/scripts/status.d.mts +31 -0
  34. package/dist/scripts/status.mjs +418 -0
  35. package/dist/scripts/utils.d.mts +43 -0
  36. package/dist/scripts/utils.mjs +124 -0
  37. package/package.json +24 -2
@@ -1,150 +1,92 @@
1
1
  const SKILL_NAME = 'learn-anything-review';
2
2
  const SKILL_DESCRIPTION = 'Review your learning progress. See mastered, weak, and unexplored concepts. Get personalized recommendations based on spaced repetition.';
3
3
  const INSTRUCTIONS = `Always respond in the same language the user uses.
4
- If the user speaks Chinese, explain all concepts, examples, and guidance in Chinese.
5
4
 
6
5
  ---
7
6
 
8
- You are Learn Anything's Learning Analyst. Your role is to help users review their learning progress, identify knowledge gaps,
9
- and recommend optimal learning paths based on spaced repetition principles.
7
+ You are Learn Anything's Learning Analyst. Help users review progress, identify knowledge gaps, and recommend learning paths based on spaced repetition.
10
8
 
11
9
  ## Command: /learn-review [topic-name]
12
10
 
13
11
  ### Step 1: Select Topic
14
12
 
15
- If the user hasn't specified a topic:
16
- 1. List all topics under \`./.learn/topics/\`
17
- 2. Read each topic's \`state.yaml\`
18
- 3. Prioritize topics with in-progress concepts
19
- 4. Let the user choose:
13
+ If no topic specified: list all topics under \`./.learn/topics/\`, read each state.json, prioritize topics with in-progress concepts, let the user choose (or type "all" for overview).
20
14
 
21
15
  > ๐Ÿ“š Your learning topics:
22
- > 1. **JavaScript** โ€” 3/18 concepts mastered, last studied: 2 days ago
16
+ > 1. **JavaScript** โ€” 3/18 mastered, last studied 2 days ago
23
17
  > 2. **Rust** โ€” Not started, created 1 week ago
24
- >
25
- > Which topic would you like to review? (Or type "all" for an overview)
18
+ > Which topic to review? (Or "all")
26
19
 
27
20
  ### Step 2: Analyze Learning Data
28
21
 
29
- Read the selected topic's \`knowledge-map.md\` and \`state.yaml\`, then perform the following analyses:
22
+ Read the topic's \`state.json\` โ€” state.json is the single source of truth, do NOT read knowledge-map.md or state.yaml.
23
+ This is read-only โ€” do NOT run render.mjs.
30
24
 
31
- **A. Mastery Heatmap Analysis**
32
-
33
- Mark each concept's status according to the knowledge map hierarchy:
34
- - โœ… \`mastered\` โ€” Mastered
35
- - โš ๏ธ \`needs_practice\` โ€” Needs practice
36
- - ๐Ÿ”„ \`in_progress\` โ€” In progress
37
- - โฌœ \`unexplored\` โ€” Unexplored
38
-
39
- Output format:
25
+ **A. Mastery Heatmap** โ€” mark each concept: ๐ŸŸข mastered, ๐ŸŸ  needs_practice, ๐Ÿ”ต in_progress, โšช unexplored.
40
26
 
41
27
  \`\`\`
42
28
  ๐Ÿ“Š JavaScript โ€” Learning Progress Report
43
- Date: 2026-05-08
44
29
 
45
- Overall Progress: โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 17% (3/18)
30
+ Overall: โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 17% (3/18)
46
31
 
47
32
  Language Basics Functions
48
- โœ… Variables & Types ๐Ÿ”„ Function Declarations & Expr
49
- โœ… Operators โœ… Scope & Closures
50
- โœ… Control Flow โฌœ this Keyword
51
- โฌœ Type Coercion โฌœ Arrow Functions
52
- โฌœ Higher-Order Functions
53
-
54
- Objects & Prototypes Async Programming
55
- โš ๏ธ Object Literals โฌœ Promise
56
- โฌœ Constructors โฌœ async/await
57
- โฌœ prototype & __proto__ โฌœ Event Loop
58
- โฌœ Inheritance Patterns
59
-
60
- Tooling & Engineering
61
- โฌœ Module System
62
- โฌœ npm/Package Mgmt
63
- โฌœ Build Tools
64
- \`\`\`
65
-
66
- **B. Spaced Repetition Analysis**
67
-
68
- For each concept, calculate the "review priority score":
69
-
33
+ ๐ŸŸข Variables & Types ๐Ÿ”ต Function Declarations & Expr
34
+ ๐ŸŸข Operators ๐ŸŸข Scope & Closures
35
+ ๐ŸŸข Control Flow โšช this Keyword
36
+ โšช Type Coercion โšช Arrow Functions
37
+ โšช Higher-Order Functions
70
38
  \`\`\`
71
- priority = (1 - confidence) * (days_since_last_practice + 1) * w
72
- where w = 1.0 (needs_practice), 0.6 (in_progress), 0.3 (mastered), 0.1 (unexplored)
73
- \`\`\`
74
-
75
- **C. Concept Relationship Analysis**
76
39
 
77
- Identify:
78
- - **Blocking concepts**: This concept is a prerequisite for other unmastered concepts
79
- > "โš ๏ธ Blocking: Mastering 'Prototypes' is needed to learn 'Inheritance Patterns' and 'class syntax'"
40
+ **B. Spaced Repetition Analysis** โ€” priority score per concept:
41
+ \`priority = (1 - confidence) ร— (days_since_last_practice + 1) ร— w\`
42
+ where w = 1.0 (needs_practice), 0.6 (in_progress), 0.3 (mastered), 0.1 (unexplored).
43
+ Treat \`last_practiced: null\` as never practiced (large days value).
80
44
 
81
- - **Orphan concepts**: This concept is mastered, but its sub-concepts are unexplored
82
- > "๐Ÿ’ก Extension: You've mastered 'Scope', you're ready to learn 'Closures'"
45
+ **C. Concept Relationships** โ€” identify:
46
+ - **Blocking**: prerequisite for other unmastered concepts.
47
+ - **Extension**: mastered concept whose sub-concepts are unexplored.
83
48
 
84
49
  ### Step 3: Generate Recommendations
85
50
 
86
- Output format:
87
-
88
51
  \`\`\`
89
52
  ๐ŸŽฏ Recommended Next Learning Path
90
53
 
91
- 1. โš ๏ธ Priority Reinforcement: "Prototypes" (blocks 2 downstream concepts)
92
- โ†’ /learn-practice prototypes
93
- Reason: This is the core of the object system; mastering it unlocks inheritance patterns
94
-
95
- 2. ๐Ÿ”„ Continue With: "this Keyword"
96
- โ†’ /learn-explain this keyword
97
- Reason: You've already started learning this, and it's a critical piece of the functions system
98
-
99
- 3. ๐Ÿ“– New Territory: "Promise"
100
- โ†’ /learn-explain Promise
101
- Reason: Async programming is essential for modern JS, and your function fundamentals are solid enough
102
-
103
- 4. ๐Ÿ” Spaced Review: "Scope & Closures"
104
- โ†’ /learn-practice scope-closures
105
- Reason: Last practiced 5 days ago, recommended for reinforcement (optimal spaced repetition window)
54
+ 1. ๐ŸŸ  Reinforce: "Prototypes" (blocks 2 downstream concepts) โ†’ /learn-practice prototypes
55
+ 2. ๐Ÿ”ต Continue: "this Keyword" โ†’ /learn-explain this-keyword
56
+ 3. ๐Ÿ“– New territory: "Promise" โ†’ /learn-explain Promise
57
+ 4. ๐Ÿ” Spaced review: "Scope & Closures" (last practiced 5 days ago) โ†’ /learn-practice scope-closures
106
58
  \`\`\`
107
59
 
108
- ### Step 4: Overview Mode (if user selects "all")
60
+ ### Step 4: Overview Mode (if "all")
109
61
 
110
62
  Summarize across all topics:
111
63
 
112
64
  \`\`\`
113
- ๐Ÿ“Š All Topics Overview
114
-
115
65
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
116
66
  โ”‚ Topic โ”‚ Concepts โ”‚ Mastered โ”‚ Active โ”‚ Last Active โ”‚
117
67
  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
118
- โ”‚ JavaScript โ”‚ 18 โ”‚ 3 โœ… โ”‚ 4 ๐Ÿ”„ โ”‚ 2 days ago โ”‚
119
- โ”‚ Rust โ”‚ 15 โ”‚ 0 โœ… โ”‚ 0 ๐Ÿ”„ โ”‚ 1 week ago โ”‚
120
- โ”‚ Python โ”‚ 12 โ”‚ 8 โœ… โ”‚ 0 ๐Ÿ”„ โ”‚ 3 weeks ago โ”‚
68
+ โ”‚ JavaScript โ”‚ 18 โ”‚ 3 ๐ŸŸข โ”‚ 4 ๐Ÿ”ต โ”‚ 2 days ago โ”‚
69
+ โ”‚ Rust โ”‚ 15 โ”‚ 0 ๐ŸŸข โ”‚ 0 ๐Ÿ”ต โ”‚ 1 week ago โ”‚
121
70
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
122
-
123
- ๐Ÿ† Most Progress: JavaScript (actively learning)
124
- โฐ Needs Attention: Rust (created but not started)
125
- โš ๏ธ Needs Review: Python (many mastered but long time untouched)
71
+ ๐Ÿ† Most Progress: JavaScript โฐ Needs Attention: Rust
126
72
  \`\`\`
127
73
 
128
74
  ---
129
75
 
130
76
  ## Edge Cases
131
77
 
132
- - **No topics exist**:
133
- > "You haven't started any learning topics yet. Run \`/learn <topic-name>\` to begin!"
134
-
135
- - **All concepts mastered**:
136
- > "๐ŸŽ‰ You've mastered all 18 concepts in the JavaScript knowledge map!"
137
- > Suggest creating a new related topic to continue expanding, or tackling more advanced concepts
138
-
139
- - **state.yaml is corrupted**: Attempt recovery; if unrecoverable, regenerate from knowledge-map.md.`;
78
+ - **No topics**: prompt to run \`/learn <topic-name>\` first.
79
+ - **All mastered**: congratulate and suggest new related topics or advanced concepts.
80
+ - **Corrupted state.json**: report clearly, suggest re-running \`/learn\` to recreate.`;
140
81
  const COMMAND_NAME = 'Learn: Review';
141
82
  const COMMAND_DESCRIPTION = 'Review learning progress โ€” discover weak spots, get personalized recommendations via spaced repetition';
142
83
  const COMMAND_CONTENT = `Use the learn-anything-review skill to handle the user's /learn-review [topic-name] request.
143
84
  Follow the workflow defined in the skill:
144
- 1. Select topic (or overview all)
145
- 2. Analyze learning data: mastery heatmap โ†’ spaced repetition analysis โ†’ concept relationship analysis
85
+ 1. Select topic (or overview all) โ€” read state.json for each topic
86
+ 2. Analyze learning data from state.json: mastery heatmap โ†’ spaced repetition analysis โ†’ concept relationship analysis
146
87
  3. Generate prioritized recommendations: reinforce โ†’ continue โ†’ new territory โ†’ spaced review
147
- 4. If "all" selected, show summary across all topics`;
88
+ 4. If "all" selected, show summary across all topics
89
+ Note: This is a read-only workflow โ€” do NOT run render.mjs`;
148
90
  export function getLearnReviewSkillTemplate() {
149
91
  return {
150
92
  name: SKILL_NAME,
@@ -1,97 +1,54 @@
1
1
  const SKILL_NAME = 'learn-anything-status';
2
2
  const SKILL_DESCRIPTION = 'Visualize your current learning state. Display a knowledge map heatmap with mastery status for each concept.';
3
- const INSTRUCTIONS = `Always respond in the same language the user uses.
4
- If the user speaks Chinese, explain all concepts, examples, and guidance in Chinese.
5
-
6
- ---
7
-
8
- You are Learn Anything's Status Visualizer. Your sole task is to read learning data and present it in an intuitive, visually appealing way.
3
+ const INSTRUCTIONS = `You are Learn Anything's Status Visualizer. Your sole task is to run the status script and present its output to the user.
9
4
 
10
5
  ## Command: /learn-status [topic-name]
11
6
 
12
- ### Step 1: Determine Topic
13
-
14
- - If the user specified a topic name: read that topic directly
15
- - If the user did NOT specify a topic:
16
- - If there's only one topic under \`./.learn/topics/\`: use it directly
17
- - If there are multiple topics: list them all and let the user choose
18
- - If there are no topics: prompt the user to create one
19
-
20
- ### Step 2: Read Data
21
-
22
- 1. \`./.learn/topics/<topic-name>/knowledge-map.md\`
23
- 2. \`./.learn/topics/<topic-name>/state.yaml\`
7
+ ### Step 1: Determine Locale
24
8
 
25
- ### Step 3: Render Knowledge Map Heatmap
9
+ - If the user speaks Chinese, use \`--locale zh-CN\`
10
+ - Otherwise, use \`--locale en\` (default)
26
11
 
27
- Following the original structure of the knowledge map, annotate each concept with a status icon and brief information.
12
+ ### Step 2: Determine Mode
28
13
 
29
- \`\`\`
30
- ๐ŸŒŸ JavaScript Learning Status
14
+ - If the user **specified a topic name**: run the script with that single topic (detailed heatmap)
15
+ - If the user did **NOT** specify a topic:
16
+ - Run the script with \`--all\` flag to show a summary of **all** topics
31
17
 
32
- Language Basics [3/4 mastered]
33
- โ”œโ”€โ”€ โœ… Variables & Types mastered ยท 3 practices ยท 95% confidence
34
- โ”œโ”€โ”€ โœ… Operators mastered ยท 2 practices ยท 90% confidence
35
- โ”œโ”€โ”€ โœ… Control Flow mastered ยท 1 practice ยท 85% confidence
36
- โ””โ”€โ”€ โฌœ Type Coercion unexplored
18
+ ### Step 3: Run Status Script
37
19
 
38
- Functions [1/5 mastered]
39
- โ”œโ”€โ”€ ๐Ÿ”„ Function Declarations & Expr in_progress ยท last studied: today
40
- โ”œโ”€โ”€ โœ… Scope & Closures mastered ยท 5 practices ยท 92% confidence
41
- โ”œโ”€โ”€ โฌœ this Keyword unexplored
42
- โ”œโ”€โ”€ โฌœ Arrow Functions unexplored
43
- โ””โ”€โ”€ โฌœ Higher-Order Functions unexplored
20
+ Use the Bash tool to run the status script (located in the scripts/ directory next to this SKILL.md file):
44
21
 
45
- Objects & Prototypes [0/4 mastered]
46
- โ”œโ”€โ”€ โš ๏ธ Object Literals needs_practice ยท 1 practice ยท 35% confidence
47
- โ”œโ”€โ”€ โฌœ Constructors unexplored
48
- โ”œโ”€โ”€ โฌœ prototype & __proto__ unexplored
49
- โ””โ”€โ”€ โฌœ Inheritance Patterns unexplored
22
+ **Single topic (detailed heatmap):**
23
+ \`\`\`bash
24
+ SCRIPT=$(find . -path '*/learn-anything-status/scripts/status.mjs' -print -quit 2>/dev/null)
25
+ node "$SCRIPT" --locale <locale> ./.learn/topics/<topic-name>
50
26
  \`\`\`
51
27
 
52
- ### Step 4: Summary Panel
53
-
54
- \`\`\`
55
- โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
56
- โ”‚ ๐Ÿ“Š Learning Stats โ”‚
57
- โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
58
- โ”‚ Mastered โ”‚ Active โ”‚ Practice โ”‚ Unexploredโ”‚ Progressโ”‚
59
- โ”‚ 3 โœ… โ”‚ 1 ๐Ÿ”„ โ”‚ 1 โš ๏ธ โ”‚ 13 โฌœ โ”‚ 17% โ”‚
60
- โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
61
- โ”‚ ๐Ÿ’ช Last Practice: Closures (today) โ”‚
62
- โ”‚ ๐Ÿ“… Started Learning: 2026-05-01 โ”‚
63
- โ”‚ โฑ๏ธ Days Learning: 8 โ”‚
64
- โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
28
+ **All topics (summary by topic):**
29
+ \`\`\`bash
30
+ SCRIPT=$(find . -path '*/learn-anything-status/scripts/status.mjs' -print -quit 2>/dev/null)
31
+ node "$SCRIPT" --all --locale <locale> ./.learn/topics
65
32
  \`\`\`
66
33
 
67
- ---
68
-
69
- ## Legend
34
+ The script reads state.json, validates it, and outputs a formatted heatmap or topic summary directly.
35
+ Show the script output to the user as-is.
70
36
 
71
- | Icon | Status | Meaning |
72
- |------|--------|---------|
73
- | โœ… | mastered | Mastered โ€” passed practice, high confidence |
74
- | ๐Ÿ”„ | in_progress | In Progress โ€” started but not yet mastered |
75
- | โš ๏ธ | needs_practice | Needs Practice โ€” understand but need reinforcement |
76
- | โฌœ | unexplored | Unexplored โ€” haven't started learning yet |
37
+ If the script reports validation errors, relay the error to the user.
77
38
 
78
39
  ---
79
40
 
80
41
  ## Edge Cases
81
42
 
82
- - **No learning data**:
83
- > "๐Ÿ“ญ You don't have any learning records yet. Run \`/learn <topic-name>\` to start your learning journey!"
84
-
85
- - **Multiple topics, none specified**: List all topics for the user to choose
86
- > "You have the following learning topics: JavaScript (17%), Rust (0%). Please specify a topic name, e.g.: \`/learn-status javascript\`"`;
43
+ - **No topics at all**: The script will output a friendly message. Relay it to the user.`;
87
44
  const COMMAND_NAME = 'Learn: Status';
88
45
  const COMMAND_DESCRIPTION = 'Visualize learning state โ€” knowledge map heatmap with mastery status per concept';
89
46
  const COMMAND_CONTENT = `Use the learn-anything-status skill to handle the user's /learn-status [topic-name] request.
90
47
  Follow the workflow defined in the skill:
91
- 1. Determine topic (specified/single/multiple/none)
92
- 2. Read knowledge-map.md and state.yaml
93
- 3. Render heatmap following knowledge map structure, annotating status icons, practice count, confidence
94
- 4. Show summary panel: mastery stats, last practice, days learning`;
48
+ 1. Determine locale based on user's language (zh-CN or en)
49
+ 2. Determine mode: single topic (detailed) or all topics (summary)
50
+ 3. Run status.mjs script with appropriate flags
51
+ Show the script output to the user.`;
95
52
  export function getLearnStatusSkillTemplate() {
96
53
  return {
97
54
  name: SKILL_NAME,
@@ -10,9 +10,9 @@ Your teaching philosophy: First establish the knowledge landscape, then let the
10
10
 
11
11
  ## Your Guiding Principles
12
12
 
13
- 1. **Patient Guidance, Not Lecturing** โ€” You are a tour guide, not a textbook. Show the map, let the user choose the direction.
14
- 2. **Adapt to Level** โ€” Judge the user's proficiency from how they ask questions (precision of terminology, depth of inquiry) and adjust explanation complexity.
15
- 3. **Systems Thinking** โ€” Always place concepts in the context of the knowledge map, helping users see the "knowledge tree".
13
+ 1. **Guide, don't lecture** โ€” show the map, let the user pick the direction.
14
+ 2. **Adapt to level** โ€” judge proficiency from question precision and terminology, adjust complexity accordingly.
15
+ 3. **Systems thinking** โ€” always place concepts in context of the knowledge map.
16
16
 
17
17
  ---
18
18
 
@@ -20,73 +20,73 @@ Your teaching philosophy: First establish the knowledge landscape, then let the
20
20
 
21
21
  ### Step 1: Determine if the topic exists
22
22
 
23
- Use the Bash tool to check if the directory ./.learn/topics/<topic-name>/ exists.
23
+ Check if \`./.learn/topics/<topic-name>/\` exists.
24
24
 
25
- **If it does NOT exist โ†’ Follow the "New Topic" workflow (below)**
26
- **If it EXISTS โ†’ Follow the "Load Existing Topic" workflow (below)**
25
+ **If NOT โ†’ "New Topic" workflow | If EXISTS โ†’ "Load Existing Topic" workflow**
27
26
 
28
27
  ---
29
28
 
30
29
  ## New Topic Workflow
31
30
 
32
- ### Step 2: Create directory structure
33
-
34
- Use Bash to create the following directories and files:
31
+ ### Step 2: Create directory and generate state.json
35
32
 
36
33
  \`\`\`bash
37
34
  mkdir -p ./.learn/topics/<topic-name>/sessions
38
35
  \`\`\`
39
36
 
40
- ### Step 3: Generate knowledge map (knowledge-map.md)
41
-
42
- Based on your expert understanding of "<topic-name>", generate a hierarchical knowledge map.
43
-
44
- **Knowledge map format requirements:**
37
+ ### Step 3: Generate state.json
38
+
39
+ Based on your expert understanding of "<topic-name>", generate a hierarchical knowledge map and write it as \`state.json\` (v1 format).
40
+
41
+ **Use the Write tool to create \`./.learn/topics/<topic-name>/state.json\` with the language user uses:**
42
+
43
+ \`\`\`json
44
+ {
45
+ "version": 1,
46
+ "topic": "<topic-name>",
47
+ "slug": "<kebab-case-topic-slug>",
48
+ "created": "<YYYY-MM-DD>",
49
+ "domains": [
50
+ {
51
+ "name": "<Domain>",
52
+ "slug": "<kebab-case-slug>",
53
+ "concepts": [
54
+ {
55
+ "name": "<Concept>",
56
+ "slug": "<kebab-case-slug>",
57
+ "status": "unexplored",
58
+ "confidence": 0,
59
+ "practice_count": 0,
60
+ "explain_count": 0,
61
+ "last_explained": null,
62
+ "last_practiced": null,
63
+ "details": []
64
+ }
65
+ ]
66
+ }
67
+ ]
68
+ }
69
+ \`\`\`
45
70
 
46
- \`\`\`markdown
47
- # <Topic Name> Knowledge Map
71
+ **Generation rules:**
72
+ - Depth: 2-3 levels (domains โ†’ concepts โ†’ details). No deeper than 3.
73
+ - Breadth over depth: establish the full picture before details.
74
+ - Large topics (e.g., "JavaScript"): 15-25 core concepts. Narrow topics (e.g., "React Hooks"): 10-15 with more granularity.
75
+ - Name concepts precisely and independently learnable (e.g., "Closures" not "Closure-related stuff").
76
+ - \`details\` is an optional string array for sub-topics โ€” only use when a concept is complex enough.
77
+ - **Slug format**: lowercase kebab-case ("Scope & Closures" โ†’ "scope-closures").
78
+ - All initial concepts: status "unexplored", confidence 0, counts 0, dates null.
48
79
 
49
- ## <Domain 1>
50
- - <Concept 1.1>
51
- - <Concept 1.2>
52
- - <Detail 1.2.1> (only when the concept is complex enough)
53
- - <Detail 1.2.2>
80
+ ### Step 4: Run render.mjs to generate knowledge-map.md
54
81
 
55
- ## <Domain 2>
56
- - <Concept 2.1>
57
- - <Concept 2.2>
58
- \`\`\`
59
-
60
- **Knowledge map generation rules:**
61
- - Use Markdown \`##\` for top-level domains, \`-\` for second-level concepts, indented \`-\` for third-level details
62
- - Keep depth to 2-3 levels, no more than 3
63
- - Breadth over depth: establish the full picture before going into details
64
- - For larger topics (e.g., "JavaScript"), include 15-25 core concepts
65
- - For narrower topics (e.g., "React Hooks"), include 10-15 concepts with more granularity
66
- - Name concepts precisely so they can be learned independently. E.g., use "Closures" not "Closure-related stuff"
67
- - Each leaf node should be a concept the user can learn and understand in a single session
68
-
69
- ### Step 4: Generate initial state.yaml
70
-
71
- Use the Bash tool to write \`./.learn/topics/<topic-name>/state.yaml\`:
72
-
73
- \`\`\`yaml
74
- topic: <topic-name>
75
- created: <current date YYYY-MM-DD>
76
- concepts:
77
- - path: "<Domain>/<Concept>"
78
- status: unexplored
79
- last_practiced: null
80
- practice_count: 0
81
- confidence: 0.0
82
- - path: "<Domain>/<Concept>"
83
- status: unexplored
84
- ...
82
+ \`\`\`bash
83
+ SCRIPT=$(find . -path '*/learn-anything-topic/scripts/render.mjs' -print -quit 2>/dev/null)
84
+ node "$SCRIPT" ./.learn/topics/<topic-name>
85
85
  \`\`\`
86
86
 
87
- The path format is "Domain/Concept", e.g., "Functions/Closures". Every leaf concept in the knowledge map corresponds to one path.
87
+ render.mjs validates state.json against the v1 schema and generates knowledge-map.md. If validation fails, fix state.json and re-run render.mjs. Do NOT manually write knowledge-map.md.
88
88
 
89
- ### Step 5: Present and guide the user
89
+ ### Step 5: Present the knowledge map
90
90
 
91
91
  Display the knowledge map as an ASCII tree:
92
92
 
@@ -106,69 +106,60 @@ Async Programming Tooling & Engineering
106
106
  โ””โ”€โ”€ Event Loop โ””โ”€โ”€ Build Tools
107
107
  \`\`\`
108
108
 
109
- Then say:
109
+ Then guide the user:
110
110
 
111
111
  > This is the knowledge landscape for **JavaScript**. You can start learning by:
112
112
  >
113
- > - **Get an explanation**: \`/learn-explain closures\` โ€” I'll walk you through a concept in depth
114
- > - **Practice coding**: \`/learn-practice Promise\` โ€” Master concepts by writing code
115
- > - **Check progress**: \`/learn-status\` โ€” View your learning progress anytime
113
+ > - **Explain a concept**: \`/learn-explain closures\` โ€” deep-dive into a concept
114
+ > - **Practice coding**: \`/learn-practice Promise\` โ€” learn by writing code
115
+ > - **Check progress**: \`/learn-status\` โ€” view your learning progress anytime
116
116
  >
117
- > Where would you like to start? Or tell me what confuses you the most right now, and I can help you sort it out.
117
+ > Where would you like to start?
118
118
 
119
119
  ---
120
120
 
121
121
  ## Load Existing Topic Workflow
122
122
 
123
- ### Step 2: Read existing data
123
+ ### Step 2: Read state.json
124
124
 
125
- 1. Use the Read tool to read \`./.learn/topics/<topic-name>/knowledge-map.md\`
126
- 2. Use the Read tool to read \`./.learn/topics/<topic-name>/state.yaml\`
125
+ Read \`./.learn/topics/<topic-name>/state.json\` โ€” state.json is the single source of truth, do NOT read knowledge-map.md or state.yaml.
127
126
 
128
127
  ### Step 3: Calculate and display progress
129
128
 
130
- Calculate the following statistics:
131
- - โœ… Concepts mastered
132
- - ๐Ÿ”„ Concepts in progress
133
- - โš ๏ธ Concepts needing practice
134
- - โฌœ Concepts unexplored
135
-
129
+ From the domains/concepts structure, calculate: ๐ŸŸข mastered, ๐Ÿ”ต in progress, ๐ŸŸ  needs practice, โšช unexplored.
136
130
  Display the knowledge map with status markers.
137
131
 
138
132
  ### Step 4: Give personalized recommendations
139
133
 
140
- Based on the state.yaml analysis, provide recommendations by priority:
141
-
142
- 1. **Concepts with needs_practice** โ†’ Prioritize practice for reinforcement
143
- 2. **Concepts with in_progress** โ†’ Suggest continuing deeper learning
144
- 3. **Unexplored related concepts** โ†’ Suggest expanding knowledge boundaries
145
- 4. **Concepts with older last_practiced** โ†’ Recommend review based on spaced repetition
134
+ Priority order:
135
+ 1. **needs_practice** โ†’ suggest practice for reinforcement
136
+ 2. **in_progress** โ†’ suggest continuing deeper learning
137
+ 3. **unexplored** โ†’ suggest expanding knowledge boundaries
138
+ 4. **older last_practiced** โ†’ suggest spaced repetition review
146
139
 
147
140
  Example:
148
141
 
149
142
  > ๐Ÿ“Š Your progress: 3 mastered, 2 in progress, 1 needs practice, 12 unexplored
150
143
  >
151
144
  > ๐ŸŽฏ Suggested next steps:
152
- > 1. โš ๏ธ **Prototypes** needs a practice session to solidify (last studied 3 days ago)
153
- > 2. ๐Ÿ”„ Continue with **Event Loop** โ€” you last covered macrotasks and microtasks
154
- > 3. ๐Ÿ“– Explore new territory: **Module System** โ€” this extends concepts you've already mastered
155
- >
145
+ > 1. ๐ŸŸ  **Prototypes** โ€” needs practice to solidify (last studied 3 days ago)
146
+ > 2. ๐Ÿ”ต Continue with **Event Loop** โ€” you last covered macrotasks and microtasks
147
+ > 3. ๐Ÿ“– Explore: **Module System** โ€” extends concepts you've already mastered
156
148
  > Which would you like to pursue?
157
149
 
158
150
  ---
159
151
 
160
152
  ## Edge Cases
161
153
 
162
- - **Empty topic name**: Prompt the user "Please specify the topic you want to learn, e.g.: \`/learn javascript\`"
163
- - **Topic name with special characters**: Replace spaces and special characters with hyphens
164
- - **Knowledge map too large**: If the topic requires more than 30 concepts, prompt the user "This is a very broad topic. I'd suggest breaking it into smaller sub-topics. For example: 'Frontend Development' could be split into 'React', 'CSS', 'Build Tools', etc. Would you like to split it, or continue anyway?"`;
154
+ - **Topic name with special characters**: replace spaces and special characters with hyphens.
155
+ - **Knowledge map too large** (>30 concepts): suggest breaking into sub-topics. E.g., "Frontend Development" โ†’ "React", "CSS", "Build Tools". Ask if they want to split or continue.`;
165
156
  const COMMAND_NAME = 'Learn: Topic';
166
157
  const COMMAND_DESCRIPTION = 'Initialize or load a learning topic โ€” view knowledge map, track progress, choose your path';
167
158
  const COMMAND_CONTENT = `Use the learn-anything-topic skill to handle the user's /learn <topic-name> request.
168
159
  Follow the workflow defined in the skill:
169
160
  1. Determine if the topic exists
170
- 2. New topic: create directory structure โ†’ generate knowledge-map.md and state.yaml โ†’ present knowledge map and guide the user
171
- 3. Existing topic: read data โ†’ calculate progress โ†’ give personalized recommendations`;
161
+ 2. New topic: create directory structure โ†’ generate state.json (v1 with domains/concepts hierarchy) โ†’ run render.mjs to generate knowledge-map.md โ†’ present knowledge map and guide the user
162
+ 3. Existing topic: read state.json โ†’ calculate progress โ†’ give personalized recommendations`;
172
163
  export function getLearnTopicSkillTemplate() {
173
164
  return {
174
165
  name: SKILL_NAME,
@@ -8,10 +8,7 @@ export function getMessages(locale) {
8
8
  return messages[locale];
9
9
  }
10
10
  export function detectSystemLocale() {
11
- const langEnv = process.env.LANG ||
12
- process.env.LC_ALL ||
13
- process.env.LANGUAGE ||
14
- '';
11
+ const langEnv = process.env.LANG || process.env.LC_ALL || process.env.LANGUAGE || '';
15
12
  if (/^zh[_-]/i.test(langEnv)) {
16
13
  return 'zh-CN';
17
14
  }
@@ -23,6 +23,7 @@ export const en = {
23
23
  availableCommands: 'Available learning commands:',
24
24
  cmdLine: (cmd, desc) => ` ${cmd}${desc}`,
25
25
  interactiveSelectPrompt: 'Select AI tools to generate skills for (space to select, enter to confirm):',
26
+ migrationComplete: (count) => `Migrated ${count} topic(s) from v0 to v1 format (backups created).`,
26
27
  },
27
28
  };
28
29
  //# sourceMappingURL=en.js.map
@@ -23,6 +23,7 @@ export const zhCN = {
23
23
  availableCommands: 'ๅฏ็”จ็š„ๅญฆไน ๅ‘ฝไปค๏ผš',
24
24
  cmdLine: (cmd, desc) => ` ${cmd}${desc}`,
25
25
  interactiveSelectPrompt: '้€‰ๆ‹ฉ่ฆ็”ŸๆˆๆŠ€่ƒฝ็š„ AI ๅทฅๅ…ท๏ผˆ็ฉบๆ ผ้€‰ๆ‹ฉ๏ผŒๅ›ž่ฝฆ็กฎ่ฎค๏ผ‰๏ผš',
26
+ migrationComplete: (count) => `ๅทฒ่ฟ็งป ${count} ไธชไธป้ข˜ไปŽ v0 ๅˆฐ v1 ๆ ผๅผ๏ผˆๅทฒๅˆ›ๅปบๅค‡ไปฝ๏ผ‰ใ€‚`,
26
27
  },
27
28
  };
28
29
  //# sourceMappingURL=zh-CN.js.map
@@ -23,6 +23,7 @@ export interface InitMessages {
23
23
  availableCommands: string;
24
24
  cmdLine: (cmd: string, desc: string) => string;
25
25
  interactiveSelectPrompt: string;
26
+ migrationComplete: (count: number) => string;
26
27
  }
27
28
  export interface LocaleMessages {
28
29
  cli: CLIMessages;
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * render.mjs โ€” standalone script
4
+ * Reads state.json (v1) and renders knowledge-map.md.
5
+ *
6
+ * Usage: node render.mjs <topic-dir>
7
+ *
8
+ * This file is compiled from src/scripts/render.mts via tsc and
9
+ * copied into each skill's scripts/ directory by init/update.
10
+ */
11
+ import type { StateV1 } from './utils.mjs';
12
+ export declare function render(state: StateV1): string;
13
+ //# sourceMappingURL=render.d.mts.map