hydro-ai-helper 1.20.0 → 2.0.0

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 (51) hide show
  1. package/README.md +130 -99
  2. package/dist/handlers/batchSummaryHandler.js +734 -0
  3. package/dist/handlers/batchSummaryHandler.js.map +1 -0
  4. package/dist/handlers/teachingSummaryHandler.js +338 -0
  5. package/dist/handlers/teachingSummaryHandler.js.map +1 -0
  6. package/dist/index.js +60 -0
  7. package/dist/index.js.map +1 -1
  8. package/dist/models/batchSummaryJob.js +113 -0
  9. package/dist/models/batchSummaryJob.js.map +1 -0
  10. package/dist/models/studentHistory.js +30 -0
  11. package/dist/models/studentHistory.js.map +1 -0
  12. package/dist/models/studentSummary.js +128 -0
  13. package/dist/models/studentSummary.js.map +1 -0
  14. package/dist/models/teachingSummary.js +120 -0
  15. package/dist/models/teachingSummary.js.map +1 -0
  16. package/dist/services/analyzers/classSizeStrategy.js +44 -0
  17. package/dist/services/analyzers/classSizeStrategy.js.map +1 -0
  18. package/dist/services/analyzers/codeSelectionService.js +95 -0
  19. package/dist/services/analyzers/codeSelectionService.js.map +1 -0
  20. package/dist/services/analyzers/correlationAnalyzer.js +243 -0
  21. package/dist/services/analyzers/correlationAnalyzer.js.map +1 -0
  22. package/dist/services/analyzers/errorClusterAnalyzer.js +100 -0
  23. package/dist/services/analyzers/errorClusterAnalyzer.js.map +1 -0
  24. package/dist/services/analyzers/temporalPatternAnalyzer.js +251 -0
  25. package/dist/services/analyzers/temporalPatternAnalyzer.js.map +1 -0
  26. package/dist/services/batchSummaryService.js +421 -0
  27. package/dist/services/batchSummaryService.js.map +1 -0
  28. package/dist/services/submissionSampler.js +248 -0
  29. package/dist/services/submissionSampler.js.map +1 -0
  30. package/dist/services/teachingAnalysisService.js +600 -0
  31. package/dist/services/teachingAnalysisService.js.map +1 -0
  32. package/dist/services/teachingSuggestionService.js +231 -0
  33. package/dist/services/teachingSuggestionService.js.map +1 -0
  34. package/frontend/batchSummary/BatchSummaryPanel.tsx +556 -0
  35. package/frontend/batchSummary/StudentSummaryView.tsx +139 -0
  36. package/frontend/batchSummary/SummaryCard.tsx +268 -0
  37. package/frontend/batchSummary/useBatchSummary.ts +550 -0
  38. package/frontend/batch_summary_scoreboard.page.tsx +6 -0
  39. package/frontend/components/AIHelperDashboard.tsx +7 -2
  40. package/frontend/components/ScoreboardTabContainer.tsx +300 -0
  41. package/frontend/scoreboard_integration.page.tsx +109 -0
  42. package/frontend/teachingSummary/TeachingReviewPanel.tsx +252 -0
  43. package/frontend/teachingSummary/TeachingSummaryPanel.tsx +667 -0
  44. package/frontend/teachingSummary/teachingSummary.page.tsx +5 -0
  45. package/frontend/teachingSummary/useTeachingReview.ts +50 -0
  46. package/frontend/teachingSummary/useTeachingSummary.ts +228 -0
  47. package/frontend/teaching_summary_scoreboard.page.tsx +6 -0
  48. package/frontend/utils/styles.ts +47 -14
  49. package/locales/en.yaml +70 -0
  50. package/locales/zh.yaml +70 -0
  51. package/package.json +1 -1
package/README.md CHANGED
@@ -11,67 +11,79 @@
11
11
  ![Conversations](https://img.shields.io/endpoint?url=https://stats.how2learns.com/api/badge-conversations)
12
12
  ![Version (mode)](https://img.shields.io/endpoint?url=https://stats.how2learns.com/api/badge-version)
13
13
  ![GitHub stars](https://img.shields.io/github/stars/AltureT/hydro-ai-helper?style=social)
14
- ![GitHub forks](https://img.shields.io/github/forks/AltureT/hydro-ai-helper?style=social)
15
14
  ![License](https://img.shields.io/github/license/AltureT/hydro-ai-helper)
16
15
 
17
16
  </div>
18
17
 
19
- A teaching-first AI tutoring plugin for [HydroOJ](https://github.com/hydro-dev/Hydro) that provides guided hints and thought-provoking questions never complete solutions.
18
+ A teaching-first AI tutoring plugin for [HydroOJ](https://github.com/hydro-dev/Hydro) guided hints and thought-provoking questions, never complete solutions. Supports English and Chinese (i18n).
20
19
 
21
20
  ## Screenshots
22
21
 
23
- **Student chat panel integrated with problem view:**
22
+ <img src="assets/screenshots/1.png" alt="Student panel - AI chat" width="800">
24
23
 
25
- <img src="assets/screenshots/1.png" alt="Student panel - wide screen" width="800">
26
-
27
- <img src="assets/screenshots/2.png" alt="Student panel - narrow screen" width="400">
28
-
29
- **Admin dashboard:**
24
+ <details>
25
+ <summary><b>Batch AI Learning Summary</b></summary>
30
26
 
31
- <img src="assets/screenshots/3.png" alt="Admin - conversations" width="800">
27
+ <img src="assets/screenshots/8.png" alt="Batch summary - scoreboard integration" width="800">
32
28
 
33
- <img src="assets/screenshots/4.png" alt="Admin - analytics" width="800">
29
+ <img src="assets/screenshots/9.png" alt="Batch summary - generated results" width="800">
34
30
 
35
- <img src="assets/screenshots/5.png" alt="Admin - configuration" width="800">
31
+ </details>
36
32
 
37
- <img src="assets/screenshots/6.png" alt="Admin - jailbreak logs" width="400">
33
+ <details>
34
+ <summary><b>Admin screenshots</b></summary>
38
35
 
39
- <img src="assets/screenshots/7.png" alt="Admin - cost dashboard" width="500">
36
+ <img src="assets/screenshots/4.png" alt="Admin - conversation records" width="800">
40
37
 
41
- ## Features
38
+ <img src="assets/screenshots/5.png" alt="Admin - usage analytics" width="800">
42
39
 
43
- ### For Students
40
+ <img src="assets/screenshots/6.png" alt="Admin - AI configuration" width="800">
44
41
 
45
- - **AI chat panel on problem pages** — auto-reads the problem statement and supports optional code attachment
46
- - **Differentiated question types** — choose "Understand the Problem", "Organize Approach", "Debug Errors", or "Code Optimization" (AC-only) for tailored guidance
47
- - **Multi-turn conversations** — ask follow-ups within the same conversation; history persists across page refreshes
48
- - **"I Don't Understand"** — select confusing text in an AI reply for a concise, targeted explanation
49
- - **Real-time streaming** — AI responses appear character-by-character via SSE
50
- - **LaTeX rendering** — math formulas in AI responses are rendered automatically
51
- - **Responsive UI** — LeetCode-style three-column layout on wide screens; floating panel on narrow screens
42
+ <img src="assets/screenshots/7.png" alt="Admin - cost dashboard" width="500">
52
43
 
53
- ### For Teachers
44
+ </details>
54
45
 
55
- - **Conversation viewer** — browse student conversation history with filters (time / problem / class / student)
56
- - **Usage analytics** — multi-dimensional stats with sortable tables and question-type distribution
57
- - **Data export** — CSV export with optional anonymization
46
+ ## Features
58
47
 
59
- ### For Admins
48
+ ### Students
60
49
 
61
- - **Unified management portal** one "AI Assistant" entry with tab navigation (Conversations / Analytics / Configuration)
62
- - **Multi-endpoint & model management** add multiple API endpoints, auto-discover models, drag to set priority with automatic failover
63
- - **Cost control** token usage tracking, budget limits, cost dashboard
64
- - **Rate limiting** configurable per-user request limits
65
- - **Custom system prompt** — override the built-in tutoring prompt
66
- - **One-click update** — check and install new versions from the admin panel
50
+ - AI chat panel on problem pages with real-time streaming (SSE) and LaTeX rendering
51
+ - Choose question type: **Understand** / **Approach** / **Debug** / **Optimize** (AC-only)
52
+ - Multi-turn conversations with history; select confusing text for instant clarification
53
+ - View personalized AI learning summaries on scoreboard pages
54
+
55
+ ### Teachers
56
+
57
+ - **Teaching Analysis** — class-level insights from collective submission data, helping teachers discover teaching problems and take action
58
+ - 8-dimension rule-engine analysis: common errors, comprehension gaps, learning strategies, at-risk students, difficulty anomalies, progress trends, cognitive paths, AI tutoring effectiveness
59
+ - Error signature clustering: groups similar compile/runtime errors across students to surface shared misconceptions
60
+ - Temporal behavior patterns: classifies students into 5 patterns (strategic solver, disengaged, burst-then-quit, stuck-silent, persistent learner)
61
+ - Cross-dimensional correlation: detects compound risk patterns (e.g., high AI usage + low AC rate)
62
+ - Code fill-in exercises: auto-generates blanked-code exercises from AC submissions for targeted practice
63
+ - LLM-powered actionable suggestions with priority framework (P0/P1/P2) — specific classroom actions, not generic advice
64
+ - 60/40 split layout with sticky AI suggestion sidebar, skeleton loading, confidence badges
65
+ - **Batch AI Summary** — one-click personalized learning summaries for all students on scoreboard pages
66
+ - Longitudinal student history tracking: records error trends, struggle indicators, and actionable advice across assignments
67
+ - Smart submission sampling based on milestones (first submit, first AC, score improvements, status changes)
68
+ - Supplemental generation for late-arriving students without regenerating existing summaries
69
+ - Draft/publish workflow with real-time SSE progress, stop/continue/retry controls
70
+ - Browse student conversations with filters (time / problem / class / student / userId)
71
+ - Autocomplete search for class and problem filters
72
+ - Multi-dimensional effectiveness metrics and question-type distribution
73
+ - CSV export with optional anonymization and metrics columns
74
+
75
+ ### Admins
76
+
77
+ - Unified portal: Conversations / Analytics / Configuration tabs
78
+ - Multi-endpoint API management with model auto-discovery, drag-to-reorder priority, and automatic failover
79
+ - Cost control: token usage tracking, budget limits, cost dashboard
80
+ - Rate limiting, custom system prompt, one-click plugin update
67
81
 
68
82
  <details>
69
83
  <summary><b>Security</b></summary>
70
84
 
71
85
  - Multi-layer jailbreak detection (input / prompt / output) with cross-turn protection
72
- - CSRF token validation on critical operations
73
- - SSRF prevention on API endpoint configuration
74
- - AES-256-GCM encrypted API key storage
86
+ - CSRF token validation, SSRF prevention, AES-256-GCM encrypted API key storage
75
87
  - Paginated jailbreak audit logs
76
88
 
77
89
  </details>
@@ -92,7 +104,7 @@ hydrooj addon add /path/to/hydro-ai-helper
92
104
  pm2 restart hydrooj
93
105
  ```
94
106
 
95
- Verify: visit `/ai-helper/hello` — a JSON response indicates success.
107
+ Verify: visit `/ai-helper/hello` — a JSON response means success.
96
108
 
97
109
  ## Configuration
98
110
 
@@ -106,117 +118,136 @@ export ENCRYPTION_KEY="your-32-character-secret-key!!!"
106
118
 
107
119
  Generate a random key: `openssl rand -base64 24 | head -c 32`
108
120
 
109
- ### Admin Configuration
110
-
111
- After logging in, go to **Control Panel → AI Assistant** (`/ai-helper`), then switch to the "AI Configuration" tab:
112
-
113
- 1. **Add API endpoints** — fill in endpoint name, API Base URL, and API Key, then click "Fetch Models"
114
- 2. **Select models & set priority** — pick models from enabled endpoints and drag to reorder; failover is automatic
115
- 3. **Adjust settings** — rate limit (default: 5/min/user), custom system prompt
116
- 4. **Test & save** — click "Test Connection" to verify, then save
117
-
118
- ## Usage
121
+ ### Admin Setup
119
122
 
120
- ### Students
121
-
122
- 1. Open a problem page; expand the AI panel from the bottom-right corner (wide screens show it as a side panel)
123
- 2. Choose a question type (Understand / Approach / Debug)
124
- 3. Optional: describe your understanding and what you've tried
125
- 4. Optional: attach your current code
126
- 5. Send and receive guided AI responses
127
- 6. If something is unclear, select the text and click "I don't understand" for a follow-up
128
- 7. After AC, use the "Code Optimization" feature for performance improvement suggestions
129
-
130
- ### Teachers / Admins
131
-
132
- Go to **Control Panel → AI Assistant** (`/ai-helper`) and switch between tabs:
123
+ Go to **Control Panel → AI Assistant** (`/ai-helper`) → "AI Configuration" tab:
133
124
 
134
- - **Conversations** — view student conversation history with multi-dimensional filters
135
- - **Analytics** — AI usage statistics and question-type distribution
136
- - **AI Configuration** (admins only) API endpoints, model priority, system prompt, cost dashboard
125
+ 1. **Add API endpoints** — endpoint name, API Base URL, API Key → click "Fetch Models"
126
+ 2. **Select models & priority** — pick models, drag to reorder; failover is automatic
127
+ 3. **Adjust settings** rate limit (default 5/min/user), custom system prompt
128
+ 4. **Test & save** — "Test Connection" to verify, then save
137
129
 
138
130
  ## Telemetry & Privacy
139
131
 
140
- This plugin collects **anonymous statistics** (installation count, active users, conversation count, plugin version) to display GitHub badges and guide feature development.
132
+ Collects **anonymous statistics** (installation count, active users, conversations, version) for GitHub badges and development.
141
133
 
142
134
  - Fully anonymous (random UUID, no PII); domain IDs are SHA-256 hashed
143
- - Only aggregated counts — no code, conversations, or personal data
144
- - Auto-cleanup after 90 days of inactivity
135
+ - No code, conversations, or personal data; auto-cleanup after 90 days
145
136
 
146
137
  <details>
147
- <summary><b>How to disable telemetry</b></summary>
138
+ <summary><b>Disable telemetry</b></summary>
148
139
 
149
140
  ```javascript
150
- // Connect to MongoDB
151
141
  use your_hydro_db
152
-
153
- // Disable telemetry
154
142
  db.ai_plugin_install.updateOne(
155
143
  { _id: 'install' },
156
144
  { $set: { telemetryEnabled: false } }
157
145
  )
158
146
  ```
159
147
 
160
- The plugin continues to work normally after disabling.
161
-
162
148
  </details>
163
149
 
164
150
  ## Changelog
165
151
 
152
+ <details open>
153
+ <summary><b>v2.0.0</b> — Teaching Analysis & Design Overhaul</summary>
154
+
155
+ **Teaching Analysis System (NEW)**
156
+ - 8-dimension class-level analysis: common errors, comprehension gaps, learning strategies, at-risk students, difficulty anomalies, progress trends, cognitive paths, AI tutoring effectiveness
157
+ - Rule-engine-first architecture: anomaly detection via data pipeline, LLM for actionable suggestions — 1/30 cost of pure-LLM approach
158
+ - Error signature clustering with compiler error normalization
159
+ - Temporal behavior pattern analyzer (5-way student classification)
160
+ - Cross-dimensional correlation detection (3 priority pairs)
161
+ - Auto-generated code fill-in exercises from AC submissions
162
+ - Adaptive class-size strategy (<10 / 10-20 / 20-100+ students)
163
+ - 60/40 split layout with sticky suggestion sidebar, skeleton loading, confidence badges
164
+
165
+ **Batch Summary Enhancement**
166
+ - Student history tracking across assignments (error trends, struggle indicators, prior advice)
167
+ - Supplemental generation mode for late-arriving students
168
+ - Rewritten prompts with educational psychology principles and historical context injection
169
+ - Smart primary button state machine (generate new / retry failed / continue)
170
+
171
+ **Frontend Redesign**
172
+ - Unified design token system with green accent theme for teacher features
173
+ - Tab restyling with ARIA accessibility attributes and keyboard navigation
174
+ - Finding cards with severity-based color coding (high/medium/low)
175
+ - Responsive 60/40 → vertical layout below 768px
176
+
177
+ </details>
178
+
179
+ <details>
180
+ <summary><b>v1.21.0</b> — Batch AI Learning Summary</summary>
181
+
182
+ - One-click AI summary generation for all students on homework/contest scoreboard pages
183
+ - Smart submission sampling based on milestones (first submit, first AC, score improvements, status changes)
184
+ - Real-time SSE progress with stop / continue / retry-failed controls
185
+ - Draft → publish workflow; teachers can edit summaries before publishing
186
+ - Student view: auto-displays published summary on scoreboard with periodic polling
187
+ - Submission reference links in summaries clickable to view code details
188
+ - CSV export for generated summaries
189
+
190
+ </details>
191
+
166
192
  <details>
167
- <summary><b>v1.14.1</b> — Streaming Fix</summary>
193
+ <summary><b>v1.20.0</b> — Teacher Analytics Enhancement</summary>
168
194
 
169
- - Fix SSE streaming response path issue, restoring real-time output
195
+ - Autocomplete search for class, problem, and student filters
196
+ - UserId filtering and unified filter layout
197
+ - SVG icon set replacing emoji indicators
198
+ - Cost analytics period accuracy fixes
170
199
 
171
200
  </details>
172
201
 
173
202
  <details>
174
- <summary><b>v1.14.0</b> — SSE Streaming & Cost Control & Security Hardening</summary>
203
+ <summary><b>v1.19.0</b> — i18n & Effectiveness Metrics</summary>
175
204
 
176
- - SSE streaming output AI responses display character-by-character in real time
177
- - API cost control: token usage tracking, budget limits, cost dashboard
178
- - Error classification in frontend with retry/cancel support
179
- - Security hardening: CSRF protection, SSRF prevention, 3-layer prompt injection defense
180
- - Support AI assistant in homework/contest mode
205
+ - Full English/Chinese internationalization (frontend + backend)
206
+ - Multi-dimensional conversation effectiveness metrics replacing simple binary flag
207
+ - Metrics columns in analytics tables and CSV export
181
208
 
182
209
  </details>
183
210
 
184
211
  <details>
185
- <summary><b>v1.12.0</b> — Judge Data Integration & Prompt Optimization</summary>
212
+ <summary><b>v1.18.0</b> — Telemetry Dashboard & Error Diagnostics</summary>
186
213
 
187
- - Integrate judge data to help AI analyze errors
188
- - Contest mode restrictions on AI usage
189
- - Prompt optimization ~45% token reduction
214
+ - Telemetry dashboard SPA for monitoring plugin installations
215
+ - Enhanced error diagnostics with endpoint-level context
216
+ - Admin feedback collection UI
190
217
 
191
218
  </details>
192
219
 
193
220
  <details>
194
- <summary><b>v1.11.0</b> — AI Response Style & Anti-Jailbreak Enhancement</summary>
221
+ <summary><b>v1.16.x</b> — Stability & Security</summary>
195
222
 
196
- - More natural guided AI responses
197
- - Strengthen multi-turn anti-jailbreak detection
223
+ - Stabilize telemetry instanceId for Docker environments
224
+ - Upgrade DOMPurify to address XSS vulnerabilities
225
+ - Collapse jailbreak logs by default
198
226
 
199
227
  </details>
200
228
 
201
229
  <details>
202
- <summary><b>v1.10.x</b> — Telemetry & One-click Update</summary>
230
+ <summary><b>v1.14.x</b> — SSE Streaming & Cost Control</summary>
203
231
 
204
- - Anonymous telemetry statistics and GitHub badges
205
- - One-click update with streaming progress display
232
+ - SSE streaming output real-time character-by-character display
233
+ - Token usage tracking, budget limits, cost dashboard
234
+ - CSRF protection, SSRF prevention, 3-layer prompt injection defense
235
+ - Homework/contest mode support
206
236
 
207
237
  </details>
208
238
 
209
239
  <details>
210
- <summary><b>v1.9.0 and earlier</b></summary>
211
-
212
- - v1.9.0: Comprehensive security audit and hardening
213
- - v1.8.x: "Code Optimization" question type (AC-only), real-time AC detection
214
- - v1.6.0: Unified management portal with tab navigation
215
- - v1.5.0: Draggable AI panel width
216
- - v1.4.0: Multi-endpoint configuration with model priority fallback
217
- - v1.3.0: One-click plugin update, domain isolation
240
+ <summary><b>v1.12.0 and earlier</b></summary>
241
+
242
+ - v1.12.0: Judge data integration, contest mode, ~45% token reduction
243
+ - v1.11.0: Improved guided response style, cross-turn jailbreak defense
244
+ - v1.10.x: Anonymous telemetry, one-click update
245
+ - v1.9.0: Security audit and hardening
246
+ - v1.8.x: "Code Optimization" question type (AC-only)
247
+ - v1.6.0: Unified admin portal with tabs
248
+ - v1.4.0: Multi-endpoint config with failover
218
249
  - v1.2.0: Differentiated question types
219
- - v1.0.0: Initial release — AI chat, multi-turn conversations, selection-based Q&A
250
+ - v1.0.0: Initial release
220
251
 
221
252
  </details>
222
253