Skip to content

Commit 850bb61

Browse files
jammy0903claude
andcommitted
refactor: Dead code cleanup and automate scripts consolidation
## Changes ### Backend Cleanup - Delete 10 root-level JS debug/test files - Delete 19 scripts (old generators, one-off utilities) - Delete src/scripts/ directory entirely (6 one-time scripts) - Remove 4 dead package.json script references - Delete 47-file Python lessons backup directory ### Frontend Cleanup - Delete 3 unused UI components (input, table, stat-card) - Delete unused notes.ts service and useSlidingPages hook - Delete lessonHistoryStore stub and its test - Delete entire stories/ directory (26 Storybook templates) - Delete 4 Java visualizer files (JavaMessagesView, DeviceCard, RemoteControl, examples) - Delete playwright-report/ and add to .gitignore ### Root Level Cleanup - Delete 10 root test/analysis scripts (test-*.mjs, *.py) - Delete 17 non-Render deploy files (Fly.io, Railway, Docker) - Delete 5 misc files (android plan, setup docs, shell scripts) - Consolidate 3 language-specific automation guides into 1 unified guide ### Script Refactoring (Phase 4) - Create scripts/lib/lesson-automation.ts with shared logic - Reduce each automate-*-lessons.ts from 400+ lines to 50-90 lines - Each script now only defines language-specific config and calls runWithCleanup() - All 4 languages (Python, C, JavaScript, Java) use same pipeline ### Verification - Backend build: PASS - Frontend build: PASS - No stale import references found Total: ~105 files deleted, 4 scripts refactored, 1 new shared library Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
1 parent 51c6572 commit 850bb61

213 files changed

Lines changed: 15052 additions & 13300 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.claude/LESSON_AUTOMATION_GUIDE.md

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# Lesson Automation Guide (All Languages)
2+
3+
**Purpose**: YAML -> JSON -> DB lesson automation for all supported languages
4+
5+
---
6+
7+
## Overview
8+
9+
All languages follow the same automation pipeline:
10+
11+
```
12+
YAML Template -> Simulator Execution -> JSON Generation -> DB Import
13+
```
14+
15+
**Pipeline**: `pnpm run automate:<language>`
16+
17+
---
18+
19+
## Directory Structure
20+
21+
```
22+
packages/backend/
23+
├── lesson-templates/<language>/ # YAML templates
24+
│ ├── <lang>-1-1.yaml
25+
│ └── ...
26+
├── scripts/
27+
│ ├── automate-python-lessons.ts
28+
│ ├── automate-c-lessons.ts
29+
│ ├── automate-js-lessons.ts
30+
│ ├── automate-java-lessons.ts
31+
│ └── lib/lesson-automation.ts # Shared automation logic
32+
└── prisma/content/<language>/lessons/ # Generated JSON
33+
├── <lang>-1-1.json
34+
└── ...
35+
```
36+
37+
---
38+
39+
## YAML Template Structure
40+
41+
All languages use the same YAML schema:
42+
43+
```yaml
44+
lessonId: "<lang>-<chapter>-<lesson>"
45+
title: "Lesson Title"
46+
concept: "Core concept explanation"
47+
48+
code: |
49+
# Language-specific code here
50+
51+
annotations:
52+
- line: 1
53+
title: "Step title"
54+
explanation: |
55+
Markdown explanation of this line
56+
57+
quiz:
58+
question: "Quiz question?"
59+
options: ["A", "B", "C", "D"]
60+
correctIndex: 0
61+
explanation: "Why this answer is correct"
62+
63+
misconceptions:
64+
- wrong: "Common misconception"
65+
correct: "Correct understanding"
66+
why: "Explanation"
67+
68+
keyTakeaway: "One-line summary"
69+
```
70+
71+
---
72+
73+
## Language-Specific Differences
74+
75+
| Language | Simulator | Memory State Key | Visualization Type | Lesson ID Prefix |
76+
|----------|-----------|------------------|--------------------|-----------------|
77+
| Python | PythonSimulationService | pythonMemoryState | pythonMemory | py- |
78+
| C | CSimulationService | cMemoryState | cMemory | c- |
79+
| JavaScript | JsSimulationService | jsMemoryState | jsMemory | js- |
80+
| Java | JavaSimulationService | javaMemoryState | javaMemory | java- |
81+
82+
### Chapter ID Parsing
83+
84+
- **Python**: `py-1-1` -> chapter 1
85+
- **C**: `c-1-1` -> chapter 1
86+
- **JavaScript**: `js-1-1` -> chapter 1
87+
- **Java**: `java-1-1` -> chapter 1
88+
89+
---
90+
91+
## Running Automation
92+
93+
```bash
94+
cd packages/backend
95+
96+
# Run for specific language
97+
pnpm run automate:python
98+
pnpm run automate:c
99+
pnpm run automate:js
100+
pnpm run automate:java
101+
```
102+
103+
### Expected Output
104+
105+
```
106+
Step 1: Find YAML files
107+
Step 2: YAML -> JSON conversion (runs simulator)
108+
Step 3: JSON -> DB import
109+
Final stats: N files processed, M succeeded, K failed
110+
```
111+
112+
---
113+
114+
## Troubleshooting
115+
116+
### "Lesson not found in DB" (skipped)
117+
118+
Lesson metadata doesn't exist in DB. Create the lesson entry first via Prisma.
119+
120+
### Simulation failed
121+
122+
1. Check simulator service for the language
123+
2. Verify compiler/runtime is installed (GCC for C, JDK for Java, etc.)
124+
3. Check code syntax in YAML template
125+
126+
### Type mismatch
127+
128+
Ensure `visualizationType` and memory state keys match the language config.
129+
130+
---
131+
132+
## Checklist for Adding a New Language
133+
134+
1. Create `lesson-templates/<language>/` directory
135+
2. Write YAML templates following the schema above
136+
3. Create `automate-<language>-lessons.ts` (or add config to shared lib)
137+
4. Add `automate:<language>` script to `package.json`
138+
5. Run and verify: `pnpm run automate:<language>`
139+
6. Check browser: lessons appear in course page

0 commit comments

Comments
 (0)