hydro-ai-helper 3.0.0 → 3.0.2

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 CHANGED
@@ -1,11 +1,11 @@
1
- # HydroOJ AI Learning Assistant
1
+ # HydroOJ AI 学习助手
2
2
 
3
3
  <div align="center">
4
4
 
5
- **[中文](README_zh.md) | English**
5
+ **中文 | [English](README_en.md)**
6
6
 
7
- ![GitHub release (latest by date)](https://img.shields.io/github/v/release/AltureT/hydro-ai-helper?label=Release)
8
- ![GitHub all releases](https://img.shields.io/github/downloads/AltureT/hydro-ai-helper/total?label=Downloads&color=brightgreen)
7
+ ![GitHub release (latest by date)](https://img.shields.io/github/v/release/AltureT/hydro-ai-helper?label=版本)
8
+ ![GitHub all releases](https://img.shields.io/github/downloads/AltureT/hydro-ai-helper/total?label=下载量&color=brightgreen)
9
9
  ![Installations](https://img.shields.io/endpoint?url=https://stats.how2learns.com/api/badge-installs)
10
10
  ![Active Users (7d)](https://img.shields.io/endpoint?url=https://stats.how2learns.com/api/badge-active)
11
11
  ![Conversations](https://img.shields.io/endpoint?url=https://stats.how2learns.com/api/badge-conversations)
@@ -15,156 +15,138 @@
15
15
 
16
16
  </div>
17
17
 
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).
18
+ 一个以教学为优先的 [HydroOJ](https://github.com/hydro-dev/Hydro) AI 辅助学习插件 引导思考,不给答案。支持中英文界面。
19
19
 
20
- ## Screenshots
20
+ ## 截图预览
21
21
 
22
- <img src="assets/screenshots/1.png" alt="Student panel - AI chat" width="800">
22
+ <img src="assets/screenshots/1.png" alt="学生端 - AI 对话" width="800">
23
23
 
24
24
  <details>
25
- <summary><b>Batch AI Learning Summary</b></summary>
25
+ <summary><b>AI 生成测试数据</b></summary>
26
26
 
27
- <img src="assets/screenshots/8.png" alt="Batch summary - scoreboard integration" width="800">
27
+ <img src="assets/screenshots/10.png" alt="题目文件页 - AI 生成测试数据面板" width="800">
28
28
 
29
- <img src="assets/screenshots/9.png" alt="Batch summary - generated results" width="800">
29
+ </details>
30
+
31
+ <details>
32
+ <summary><b>批量 AI 学习总结</b></summary>
33
+
34
+ <img src="assets/screenshots/8.png" alt="学习总结 - 成绩表集成" width="800">
35
+
36
+ <img src="assets/screenshots/9.png" alt="学习总结 - 生成结果" width="800">
30
37
 
31
38
  </details>
32
39
 
33
40
  <details>
34
- <summary><b>Admin screenshots</b></summary>
41
+ <summary><b>管理后台截图</b></summary>
35
42
 
36
- <img src="assets/screenshots/4.png" alt="Admin - conversation records" width="800">
43
+ <img src="assets/screenshots/4.png" alt="后台 - 对话记录" width="800">
37
44
 
38
- <img src="assets/screenshots/5.png" alt="Admin - usage analytics" width="800">
45
+ <img src="assets/screenshots/5.png" alt="后台 - 使用统计" width="800">
39
46
 
40
- <img src="assets/screenshots/6.png" alt="Admin - AI configuration" width="800">
47
+ <img src="assets/screenshots/6.png" alt="后台 - AI 配置" width="800">
41
48
 
42
- <img src="assets/screenshots/7.png" alt="Admin - cost dashboard" width="500">
49
+ <img src="assets/screenshots/7.png" alt="后台 - 成本看板" width="500">
43
50
 
44
51
  </details>
45
52
 
46
- ## Features
47
-
48
- ### Students
49
-
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
- - **AI Test Data Generation (Beta)** — generate a full test data set from the Markdown statement on the problem files page (`/p/:pid/files`)
71
- - Supports traditional problems and LeetCode-style function problems (incl. linked-list problems via class or plain-list implementations); generates `template.py` / `template.java` / `template.cc` and `compile.sh`
72
- - Fill-in-the-blank (complete-the-code) problems: auto-detects scaffold code in the statement (manual override available); reference solution and test outputs strictly match the scaffold's print format
73
- - Paste an existing reference solution to make it the single source of truth for all test outputs; it is written alongside as the std file
74
- - Adjustable data scale (small/medium/large); cases must cover statement samples and a boundary group (min scale, scale limits, special values, special structures), each labeled with its intent
75
- - `config.yaml` judge config (`user_extra_files` / `subtasks` / `langs`) is built deterministically by the plugin; judge settings sync automatically once written
76
- - Ships a reference solution; every file is previewed, editable and opt-in before writing, with explicit overwrite warnings
77
- - Same permission model as Hydro problem file management (problem owner or problem-edit permission) — inaccessible to students
78
- - Browse student conversations with filters (time / problem / class / student / userId)
79
- - Autocomplete search for class and problem filters
80
- - Multi-dimensional effectiveness metrics and question-type distribution
81
- - CSV export with optional anonymization and metrics columns
82
-
83
- ### Admins
84
-
85
- - Unified portal: Conversations / Analytics / Configuration tabs
86
- - Multi-endpoint API management with model auto-discovery, drag-to-reorder priority, and automatic failover
87
- - Per-scenario model assignment: dedicate different models to student chat / learning summary / teaching analysis / test data generation, falling back to the global chain when unset
88
- - Cost control: token usage tracking, budget limits, cost dashboard
89
- - Rate limiting, custom system prompt, one-click plugin update
53
+ ## 功能特性
54
+
55
+ ### 学生端
56
+
57
+ - 题目页 AI 对话面板,SSE 实时流式响应,LaTeX 公式自动渲染
58
+ - 差异化问题类型:**理解题意** / **理清思路** / **分析错误** / **代码优化**(AC 后专属)
59
+ - 多轮对话自动恢复;选中不理解的文字一键追问
60
+ - 在成绩表页面查看教师发布的个性化 AI 学习总结
61
+
62
+ ### 教师端
63
+
64
+ - **AI 生成测试数据**在题目文件页(`/p/:pid/files`)根据题面一键生成完整测试数据
65
+ - **沙箱实跑 + 双重验证**:数据生成器与标程在 Hydro 判题沙箱中实际运行产出 `.in`/`.out`,并经过独立暴力解对拍、输入校验、模板实跑与题面样例回归四道机器关卡;验证失败自动带上下文让 AI 修复一轮
66
+ - 支持传统题、LeetCode 风格函数题(自动生成 `template.py/java/cc` `compile.sh`)与填空题(完善代码)
67
+ - 可粘贴已有标准答案作为输出的唯一权威;`config.yaml` 评测配置确定性生成,写入后评测设置自动同步
68
+ - 生成的每个代码文件(std.py、generator.py、validator.py 等)首行注明用途;全量预览、可编辑、勾选确认后才写入
69
+ - ⚠️ 对模型能力非常敏感:请在场景模型中为「测试数据生成」配置最强模型;另有骨架模式(不调用 AI)兜底
70
+ - **教学分析**从全班提交数据发现教学问题,生成可操作的教学建议
71
+ - 8 维度规则引擎(常见错误 / 理解障碍 / 高危学生 / 进步趋势等)+ 错误签名聚类 + 时序行为模式分类
72
+ - LLM 生成 P0/P1/P2 优先级教学建议 具体课堂行动,非泛泛而谈;可从 AC 代码自动生成填空练习
73
+ - **批量 AI 学习总结** 成绩表页面一键为每位学生生成个性化学习总结
74
+ - 跨作业历史追踪 + 基于里程碑的智能提交采样;迟到学生可单独补充生成
75
+ - 草稿/发布工作流,SSE 实时进度,停止/继续/重试控制
76
+ - 对话记录浏览(时间/题目/班级/学生筛选,自动补全)、有效性指标、CSV 导出(支持脱敏)
77
+
78
+ ### 管理员端
79
+
80
+ - 统一入口:对话记录/使用统计/AI 配置 Tab 切换
81
+ - 多端点 API 管理,自动获取模型列表,拖拽排序优先级,自动 Failover
82
+ - 场景模型分配:学生对话/学习总结/教学分析/测试数据生成可分别指定专属模型
83
+ - 成本控制:Token 用量追踪、预算限制、成本看板
84
+ - 频率限制、自定义系统提示词、一键更新
90
85
 
91
86
  <details>
92
- <summary><b>Security</b></summary>
87
+ <summary><b>安全特性</b></summary>
93
88
 
94
- - Multi-layer jailbreak detection (input / prompt / output) with cross-turn protection
95
- - CSRF token validation, SSRF prevention, AES-256-GCM encrypted API key storage
96
- - Paginated jailbreak audit logs
89
+ - 多层级越狱检测(输入/提示词/输出),跨轮次防护
90
+ - CSRF Token 校验、SSRF 防护、API Key AES-256-GCM 加密存储
91
+ - AI 生成的代码只在 go-judge 沙箱中执行,不进入 Web 进程
92
+ - 越狱记录分页审计
97
93
 
98
94
  </details>
99
95
 
100
- ## Installation
96
+ ## 安装
101
97
 
102
98
  ```bash
103
- # Clone (choose one)
99
+ # 克隆(二选一)
104
100
  git clone https://github.com/AltureT/hydro-ai-helper.git # GitHub
105
- git clone https://gitee.com/alture/hydro-ai-helper.git # Gitee (mirror)
101
+ git clone https://gitee.com/alture/hydro-ai-helper.git # Gitee(镜像)
106
102
 
107
103
  cd hydro-ai-helper
108
104
  npm install
109
105
  npm run build:plugin
110
106
 
111
- # Install into HydroOJ
107
+ # 安装到 HydroOJ
112
108
  hydrooj addon add /path/to/hydro-ai-helper
113
109
  pm2 restart hydrooj
114
110
  ```
115
111
 
116
- Verify: visit `/ai-helper/hello` a JSON response means success.
112
+ 验证:访问 `/ai-helper/hello` 返回 JSON 即表示成功。
117
113
 
118
- ## Configuration
114
+ ## 配置
119
115
 
120
- ### Environment Variables
116
+ ### 环境变量
121
117
 
122
- Set `ENCRYPTION_KEY` (32 characters) to encrypt API keys:
118
+ `ENCRYPTION_KEY`(必需,32 字符)— 加密 API Key:
123
119
 
124
120
  ```bash
125
- export ENCRYPTION_KEY="your-32-character-secret-key!!!"
121
+ export ENCRYPTION_KEY="your-32-character-secret-key!!!" # 生成:openssl rand -base64 24 | head -c 32
126
122
  ```
127
123
 
128
- Generate a random key: `openssl rand -base64 24 | head -c 32`
124
+ `AI_HELPER_UPDATE_CHANNEL`(可选)— 应用内一键更新通道:
129
125
 
130
- **Update channel** (optional): the in-app one-click/overwrite update follows `AI_HELPER_UPDATE_CHANNEL`:
126
+ - `stable`(默认)— 只更新到正式发布版本(`vX.Y.Z` tag),经 GPG 签名校验。所有真实用户的服务器都应使用此通道。
127
+ - `edge` — 跟踪 `main` 分支最新代码,**仅限维护者自己的测试服务器**。
131
128
 
132
- - `stable` (default) — updates only to official releases (`git tag vX.Y.Z`), GPG-verified. Recommended for all real-user servers.
133
- - `edge` — tracks the latest `main` branch code. Set this **only on your own test server**; do not set it on users' servers.
129
+ `AI_HELPER_TESTDATA_GENERATION_MODE`(可选)— 测试数据生成是否要求沙箱(`hydrojudge.sandbox_host`):
134
130
 
135
- ```bash
136
- export AI_HELPER_UPDATE_CHANNEL=edge # test server only
137
- ```
138
-
139
- **AI test-data execution** (optional): `AI_HELPER_TESTDATA_GENERATION_MODE` controls whether AI-generated generators run in Hydro's go-judge sandbox (`hydrojudge.sandbox_host`):
140
-
141
- - `auto` (default) — use the sandbox when reachable; otherwise fall back to the legacy direct-output mode with a warning.
142
- - `sandbox` — require the sandbox and fail safely when it is unavailable.
143
- - `direct` — always use the legacy direct-output mode.
144
-
145
- ```bash
146
- export AI_HELPER_TESTDATA_GENERATION_MODE=sandbox
147
- ```
148
-
149
- ### Admin Setup
131
+ - `auto`(默认)— 沙箱可达时实跑验证,不可达时降级直出并明确标注"未验证"
132
+ - `sandbox` 强制要求沙箱,不可用时安全失败
133
+ - `direct` — 始终使用直出模式(不推荐)
150
134
 
151
- Go to **Control Panel → AI Assistant** (`/ai-helper`) → "AI Configuration" tab:
135
+ ### 管理员配置
152
136
 
153
- 1. **Add API endpoints** — endpoint name, API Base URL, API Key click "Fetch Models"
154
- 2. **Select models & priority** — pick models, drag to reorder; failover is automatic
155
- 3. **Adjust settings** — rate limit (default 5/min/user), custom system prompt
156
- 4. **Test & save** — "Test Connection" to verify, then save
137
+ 登录后访问 **控制面板AI 助手**(`/ai-helper`)→「AI 配置」Tab:
157
138
 
158
- ## Telemetry & Privacy
139
+ 1. **添加 API 端点** — 填写端点名称、API Base URL、API Key → 点击「获取模型」
140
+ 2. **选择模型与优先级** — 选择模型,拖拽排序;首选不可用时自动切换
141
+ 3. **场景模型** — 为「测试数据生成」等场景指定专属模型(该场景建议配最强模型)
142
+ 4. **测试并保存** — 点击「测试连接」验证后保存
159
143
 
160
- Collects **anonymous statistics** (installation count, active users over 7/30/90-day windows, conversations, per-day feature usage counters, version) for GitHub badges and development.
144
+ ## 遥测与隐私
161
145
 
162
- - Fully anonymous (random UUID, no PII); domain IDs are SHA-256 hashed
163
- - Records the **country and region** of the reporting request (coarse-grained, inferred by Cloudflare from the server's egress IP; **the IP itself is never stored**), instance-level only
164
- - No code, conversations, or personal data; instance records auto-clean after 270 days without reports (covers school vacations), per-day feature usage kept for 400 days
146
+ 收集**匿名统计数据**(安装数、活跃用户窗口、对话数、按日功能用量、版本),用于 GitHub 徽章和开发参考。完全匿名(随机 UUID,无个人信息,不存储 IP),不收集代码、对话内容或个人数据;仅记录 Cloudflare 粗粒度推断的国家/省份用于地区分布。
165
147
 
166
148
  <details>
167
- <summary><b>Disable telemetry</b></summary>
149
+ <summary><b>关闭遥测</b></summary>
168
150
 
169
151
  ```javascript
170
152
  use your_hydro_db
@@ -176,128 +158,52 @@ db.ai_plugin_install.updateOne(
176
158
 
177
159
  </details>
178
160
 
179
- ## Changelog
161
+ ## 更新日志
180
162
 
181
163
  <details open>
182
- <summary><b>v2.5.0</b> — AI Test Data Generation (Beta)</summary>
183
-
184
- **AI Test Data Generation (problem files page, NEW)**
185
- - One-click generation from the Markdown statement: test cases, function-problem judge templates (template.py/java/cc + compile.sh), config.yaml (judge settings sync automatically) and a reference solution
186
- - Supports traditional problems, LeetCode-style function problems (incl. class Solution signatures and linked lists) and fill-in-the-blank problems
187
- - Paste an existing reference solution as the single source of truth; adjustable data scale with mandatory sample/boundary coverage
188
- - Skeleton mode as an AI-outage fallback (no AI call, deterministic scaffolding)
189
- - Full preview, editable, opt-in writes with overwrite warnings; same permission model as Hydro problem file management
190
- - New "Test Data Generation" AI scenario with its own model chain; unrestricted output length and a 10-minute per-attempt timeout
191
- - Sectioned-text output contract (zero escaping for code); the panel shows an actionable error instead of silently disappearing when loading fails
192
-
193
- </details>
164
+ <summary><b>v3.0.0</b> — 测试数据生成:沙箱实跑 + 双重验证</summary>
194
165
 
195
- <details>
196
- <summary><b>v2.0.0</b> — Teaching Analysis & Design Overhaul</summary>
197
-
198
- **Teaching Analysis System (NEW)**
199
- - 8-dimension class-level analysis: common errors, comprehension gaps, learning strategies, at-risk students, difficulty anomalies, progress trends, cognitive paths, AI tutoring effectiveness
200
- - Rule-engine-first architecture: anomaly detection via data pipeline, LLM for actionable suggestions — 1/30 cost of pure-LLM approach
201
- - Error signature clustering with compiler error normalization
202
- - Temporal behavior pattern analyzer (5-way student classification)
203
- - Cross-dimensional correlation detection (3 priority pairs)
204
- - Auto-generated code fill-in exercises from AC submissions
205
- - Adaptive class-size strategy (<10 / 10-20 / 20-100+ students)
206
- - 60/40 split layout with sticky suggestion sidebar, skeleton loading, confidence badges
207
-
208
- **Batch Summary Enhancement**
209
- - Student history tracking across assignments (error trends, struggle indicators, prior advice)
210
- - Supplemental generation mode for late-arriving students
211
- - Rewritten prompts with educational psychology principles and historical context injection
212
- - Smart primary button state machine (generate new / retry failed / continue)
213
-
214
- **Frontend Redesign**
215
- - Unified design token system with green accent theme for teacher features
216
- - Tab restyling with ARIA accessibility attributes and keyboard navigation
217
- - Finding cards with severity-based color coding (high/medium/low)
218
- - Responsive 60/40 → vertical layout below 768px
166
+ - 测试数据不再由 AI 直接给出:生成器与标程在 go-judge 沙箱中实际运行产出 `.in`/`.out`
167
+ - 四道机器关卡:独立暴力解对拍、输入校验器逐点校验、函数题模板实跑比对、题面样例回归
168
+ - 验证失败自动把失败阶段、出错测试点、输入与 traceback 关键行回喂 AI 修复一轮;教师取消不误报
169
+ - 生成的代码文件首行自带用途注释;文件页与场景模型页醒目提示配置最强模型
170
+ - 遥测增强:错误上报携带 AI 失败详情、启动失败金丝雀告警、功能用量累计与实例来源省份
219
171
 
220
172
  </details>
221
173
 
222
174
  <details>
223
- <summary><b>v1.21.0</b> — Batch AI Learning Summary</summary>
175
+ <summary><b>v2.5.0</b> — AI 生成测试数据(Beta)</summary>
224
176
 
225
- - One-click AI summary generation for all students on homework/contest scoreboard pages
226
- - Smart submission sampling based on milestones (first submit, first AC, score improvements, status changes)
227
- - Real-time SSE progress with stop / continue / retry-failed controls
228
- - Draft → publish workflow; teachers can edit summaries before publishing
229
- - Student view: auto-displays published summary on scoreboard with periodic polling
230
- - Submission reference links in summaries clickable to view code details
231
- - CSV export for generated summaries
177
+ - 根据题面一键生成测试点、函数题评测模板、config.yaml 与参考标程(AI 直出模式)
178
+ - 支持传统题、函数题与填空题;可粘贴标准答案作为唯一权威;骨架模式兜底
179
+ - 新增「测试数据生成」AI 场景(可单独指定模型链)
232
180
 
233
181
  </details>
234
182
 
235
183
  <details>
236
- <summary><b>v1.20.0</b> — Teacher Analytics Enhancement</summary>
184
+ <summary><b>v2.0.0</b> — 教学分析系统 & 设计升级</summary>
237
185
 
238
- - Autocomplete search for class, problem, and student filters
239
- - UserId filtering and unified filter layout
240
- - SVG icon set replacing emoji indicators
241
- - Cost analytics period accuracy fixes
186
+ - 8 维度班级分析 + 错误签名聚类 + 时序行为模式(规则引擎优先,成本约为纯 LLM 方案的 1/30)
187
+ - LLM 生成 P0/P1/P2 教学建议;从 AC 代码自动生成填空练习
188
+ - 学习总结跨作业历史追踪与补充生成;前端统一设计 Token 系统
242
189
 
243
190
  </details>
244
191
 
245
192
  <details>
246
- <summary><b>v1.19.0</b> — i18n & Effectiveness Metrics</summary>
247
-
248
- - Full English/Chinese internationalization (frontend + backend)
249
- - Multi-dimensional conversation effectiveness metrics replacing simple binary flag
250
- - Metrics columns in analytics tables and CSV export
193
+ <summary><b>更早版本</b></summary>
251
194
 
252
- </details>
253
-
254
- <details>
255
- <summary><b>v1.18.0</b> Telemetry Dashboard & Error Diagnostics</summary>
256
-
257
- - Telemetry dashboard SPA for monitoring plugin installations
258
- - Enhanced error diagnostics with endpoint-level context
259
- - Admin feedback collection UI
260
-
261
- </details>
262
-
263
- <details>
264
- <summary><b>v1.16.x</b> — Stability & Security</summary>
265
-
266
- - Stabilize telemetry instanceId for Docker environments
267
- - Upgrade DOMPurify to address XSS vulnerabilities
268
- - Collapse jailbreak logs by default
269
-
270
- </details>
271
-
272
- <details>
273
- <summary><b>v1.14.x</b> — SSE Streaming & Cost Control</summary>
274
-
275
- - SSE streaming output — real-time character-by-character display
276
- - Token usage tracking, budget limits, cost dashboard
277
- - CSRF protection, SSRF prevention, 3-layer prompt injection defense
278
- - Homework/contest mode support
279
-
280
- </details>
281
-
282
- <details>
283
- <summary><b>v1.12.0 and earlier</b></summary>
284
-
285
- - v1.12.0: Judge data integration, contest mode, ~45% token reduction
286
- - v1.11.0: Improved guided response style, cross-turn jailbreak defense
287
- - v1.10.x: Anonymous telemetry, one-click update
288
- - v1.9.0: Security audit and hardening
289
- - v1.8.x: "Code Optimization" question type (AC-only)
290
- - v1.6.0: Unified admin portal with tabs
291
- - v1.4.0: Multi-endpoint config with failover
292
- - v1.2.0: Differentiated question types
293
- - v1.0.0: Initial release
195
+ - v1.21.0:批量 AI 学习总结(里程碑采样、SSE 进度、草稿/发布)
196
+ - v1.19.0–v1.20.0:全面中英文国际化、多维有效性指标、筛选自动补全
197
+ - v1.18.0:遥测看板 SPA、错误诊断增强
198
+ - v1.14.x–v1.16.x:SSE 流式响应、成本控制、CSRF/SSRF/Prompt 注入防御、安全修复
199
+ - v1.0.0–v1.12.0:初始发布、差异化问题类型、多端点 Failover、评测数据集成、竞赛模式
294
200
 
295
201
  </details>
296
202
 
297
- ## About
203
+ ## 关于
298
204
 
299
- A third-party plugin for [HydroOJ](https://github.com/hydro-dev/Hydro). Feel free to open an Issue for questions or suggestions.
205
+ [HydroOJ](https://github.com/hydro-dev/Hydro) 开源在线评测系统的第三方插件。如有问题或建议,欢迎提交 Issue
300
206
 
301
- ## License
207
+ ## 许可证
302
208
 
303
209
  MIT License
package/README_en.md ADDED
@@ -0,0 +1,209 @@
1
+ # HydroOJ AI Learning Assistant
2
+
3
+ <div align="center">
4
+
5
+ **[中文](README.md) | English**
6
+
7
+ ![GitHub release (latest by date)](https://img.shields.io/github/v/release/AltureT/hydro-ai-helper?label=Release)
8
+ ![GitHub all releases](https://img.shields.io/github/downloads/AltureT/hydro-ai-helper/total?label=Downloads&color=brightgreen)
9
+ ![Installations](https://img.shields.io/endpoint?url=https://stats.how2learns.com/api/badge-installs)
10
+ ![Active Users (7d)](https://img.shields.io/endpoint?url=https://stats.how2learns.com/api/badge-active)
11
+ ![Conversations](https://img.shields.io/endpoint?url=https://stats.how2learns.com/api/badge-conversations)
12
+ ![Version (mode)](https://img.shields.io/endpoint?url=https://stats.how2learns.com/api/badge-version)
13
+ ![GitHub stars](https://img.shields.io/github/stars/AltureT/hydro-ai-helper?style=social)
14
+ ![License](https://img.shields.io/github/license/AltureT/hydro-ai-helper)
15
+
16
+ </div>
17
+
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).
19
+
20
+ ## Screenshots
21
+
22
+ <img src="assets/screenshots/1.png" alt="Student panel - AI chat" width="800">
23
+
24
+ <details>
25
+ <summary><b>AI Test Data Generation</b></summary>
26
+
27
+ <img src="assets/screenshots/10.png" alt="Problem files page - AI test data generation panel" width="800">
28
+
29
+ </details>
30
+
31
+ <details>
32
+ <summary><b>Batch AI Learning Summary</b></summary>
33
+
34
+ <img src="assets/screenshots/8.png" alt="Batch summary - scoreboard integration" width="800">
35
+
36
+ <img src="assets/screenshots/9.png" alt="Batch summary - generated results" width="800">
37
+
38
+ </details>
39
+
40
+ <details>
41
+ <summary><b>Admin screenshots</b></summary>
42
+
43
+ <img src="assets/screenshots/4.png" alt="Admin - conversation records" width="800">
44
+
45
+ <img src="assets/screenshots/5.png" alt="Admin - usage analytics" width="800">
46
+
47
+ <img src="assets/screenshots/6.png" alt="Admin - AI configuration" width="800">
48
+
49
+ <img src="assets/screenshots/7.png" alt="Admin - cost dashboard" width="500">
50
+
51
+ </details>
52
+
53
+ ## Features
54
+
55
+ ### Students
56
+
57
+ - AI chat panel on problem pages with real-time streaming (SSE) and LaTeX rendering
58
+ - Choose question type: **Understand** / **Approach** / **Debug** / **Optimize** (AC-only)
59
+ - Multi-turn conversations with history; select confusing text for instant clarification
60
+ - View personalized AI learning summaries on scoreboard pages
61
+
62
+ ### Teachers
63
+
64
+ - **AI Test Data Generation** — generate a full test data set from the statement on the problem files page (`/p/:pid/files`)
65
+ - **Sandbox execution + double verification**: the generator and reference solution actually run in Hydro's judge sandbox to produce `.in`/`.out`, then pass four machine gates — independent brute-force cross-check, input validation, template execution, and statement-sample regression; on failure the AI gets one automatic repair round with full context
66
+ - Supports traditional problems, LeetCode-style function problems (auto-generates `template.py/java/cc` and `compile.sh`) and fill-in-the-blank problems
67
+ - Paste an existing reference solution as the single source of truth; `config.yaml` is built deterministically and judge settings sync automatically
68
+ - Every generated code file (std.py, generator.py, validator.py, …) starts with a purpose comment; everything is previewed, editable and opt-in before writing
69
+ - ⚠️ Highly sensitive to model capability: assign your strongest model to the Test Data Generation scenario; a skeleton mode (no AI) is available as fallback
70
+ - **Teaching Analysis** — class-level insights from collective submission data
71
+ - 8-dimension rule engine (common errors / comprehension gaps / at-risk students / progress trends, …) + error-signature clustering + temporal behavior patterns
72
+ - LLM-powered P0/P1/P2 prioritized suggestions — specific classroom actions, not generic advice; auto-generates fill-in exercises from AC code
73
+ - **Batch AI Summary** — one-click personalized learning summaries for all students on scoreboard pages
74
+ - Longitudinal history tracking + milestone-based submission sampling; supplemental generation for late-arriving students
75
+ - Draft/publish workflow with real-time SSE progress and stop/continue/retry controls
76
+ - Conversation browsing (time / problem / class / student filters with autocomplete), effectiveness metrics, CSV export with optional anonymization
77
+
78
+ ### Admins
79
+
80
+ - Unified portal: Conversations / Analytics / Configuration tabs
81
+ - Multi-endpoint API management with model auto-discovery, drag-to-reorder priority, and automatic failover
82
+ - Per-scenario model assignment: student chat / learning summary / teaching analysis / test data generation
83
+ - Cost control: token usage tracking, budget limits, cost dashboard
84
+ - Rate limiting, custom system prompt, one-click plugin update
85
+
86
+ <details>
87
+ <summary><b>Security</b></summary>
88
+
89
+ - Multi-layer jailbreak detection (input / prompt / output) with cross-turn protection
90
+ - CSRF token validation, SSRF prevention, AES-256-GCM encrypted API key storage
91
+ - AI-generated code runs only inside the go-judge sandbox, never in the web process
92
+ - Paginated jailbreak audit logs
93
+
94
+ </details>
95
+
96
+ ## Installation
97
+
98
+ ```bash
99
+ # Clone (choose one)
100
+ git clone https://github.com/AltureT/hydro-ai-helper.git # GitHub
101
+ git clone https://gitee.com/alture/hydro-ai-helper.git # Gitee (mirror)
102
+
103
+ cd hydro-ai-helper
104
+ npm install
105
+ npm run build:plugin
106
+
107
+ # Install into HydroOJ
108
+ hydrooj addon add /path/to/hydro-ai-helper
109
+ pm2 restart hydrooj
110
+ ```
111
+
112
+ Verify: visit `/ai-helper/hello` — a JSON response means success.
113
+
114
+ ## Configuration
115
+
116
+ ### Environment Variables
117
+
118
+ `ENCRYPTION_KEY` (required, 32 characters) — encrypts API keys:
119
+
120
+ ```bash
121
+ export ENCRYPTION_KEY="your-32-character-secret-key!!!" # generate: openssl rand -base64 24 | head -c 32
122
+ ```
123
+
124
+ `AI_HELPER_UPDATE_CHANNEL` (optional) — in-app update channel:
125
+
126
+ - `stable` (default) — updates only to official releases (`vX.Y.Z` tags), GPG-verified. Use on all real-user servers.
127
+ - `edge` — tracks the latest `main` branch code; for the maintainer's own test server only.
128
+
129
+ `AI_HELPER_TESTDATA_GENERATION_MODE` (optional) — whether test data generation requires the sandbox (`hydrojudge.sandbox_host`):
130
+
131
+ - `auto` (default) — verify in the sandbox when reachable; otherwise fall back to direct output clearly marked "unverified"
132
+ - `sandbox` — require the sandbox and fail safely when unavailable
133
+ - `direct` — always use direct output (not recommended)
134
+
135
+ ### Admin Setup
136
+
137
+ Go to **Control Panel → AI Assistant** (`/ai-helper`) → "AI Configuration" tab:
138
+
139
+ 1. **Add API endpoints** — endpoint name, API Base URL, API Key → click "Fetch Models"
140
+ 2. **Select models & priority** — pick models, drag to reorder; failover is automatic
141
+ 3. **Scenario models** — assign dedicated models per scenario (use your strongest model for Test Data Generation)
142
+ 4. **Test & save** — "Test Connection" to verify, then save
143
+
144
+ ## Telemetry & Privacy
145
+
146
+ Collects **anonymous statistics** (installations, active-user windows, conversations, per-day feature usage, version) for GitHub badges and development. Fully anonymous (random UUID, no PII, IPs never stored); no code, conversations or personal data — only a coarse country/region inferred by Cloudflare for distribution stats.
147
+
148
+ <details>
149
+ <summary><b>Disable telemetry</b></summary>
150
+
151
+ ```javascript
152
+ use your_hydro_db
153
+ db.ai_plugin_install.updateOne(
154
+ { _id: 'install' },
155
+ { $set: { telemetryEnabled: false } }
156
+ )
157
+ ```
158
+
159
+ </details>
160
+
161
+ ## Changelog
162
+
163
+ <details open>
164
+ <summary><b>v3.0.0</b> — Test data generation: sandbox execution + double verification</summary>
165
+
166
+ - Test data is no longer emitted directly by the AI: the generator and reference solution actually run in the go-judge sandbox to produce `.in`/`.out`
167
+ - Four machine gates: independent brute-force cross-check, per-case input validation, function-template execution, statement-sample regression
168
+ - On failure, the failing stage, test case, input and traceback tail are fed back to the AI for one automatic repair round; teacher cancellation is no longer misreported
169
+ - Generated code files start with purpose comments; prominent strongest-model reminders on both the files page and the scenario-model page
170
+ - Telemetry: error reports carry AI failure details, startup-failure canary alerts, cumulative feature usage and instance region
171
+
172
+ </details>
173
+
174
+ <details>
175
+ <summary><b>v2.5.0</b> — AI Test Data Generation (Beta)</summary>
176
+
177
+ - One-click generation of test cases, judge templates, config.yaml and a reference solution from the statement (direct-output mode)
178
+ - Traditional / function / fill-in-the-blank problems; paste a reference solution as the single source of truth; skeleton-mode fallback
179
+ - New "Test Data Generation" AI scenario with its own model chain
180
+
181
+ </details>
182
+
183
+ <details>
184
+ <summary><b>v2.0.0</b> — Teaching Analysis & Design Overhaul</summary>
185
+
186
+ - 8-dimension class analysis + error-signature clustering + temporal behavior patterns (rule-engine first, ~1/30 the cost of pure LLM)
187
+ - LLM-generated P0/P1/P2 teaching suggestions; auto-generated fill-in exercises from AC code
188
+ - Longitudinal summary tracking with supplemental generation; unified frontend design tokens
189
+
190
+ </details>
191
+
192
+ <details>
193
+ <summary><b>Earlier versions</b></summary>
194
+
195
+ - v1.21.0: batch AI learning summaries (milestone sampling, SSE progress, draft/publish)
196
+ - v1.19.0–v1.20.0: full i18n, multi-dimensional effectiveness metrics, filter autocomplete
197
+ - v1.18.0: telemetry dashboard SPA, richer error diagnostics
198
+ - v1.14.x–v1.16.x: SSE streaming, cost control, CSRF/SSRF/prompt-injection defenses, security fixes
199
+ - v1.0.0–v1.12.0: initial release, question types, multi-endpoint failover, judge-data integration, contest mode
200
+
201
+ </details>
202
+
203
+ ## About
204
+
205
+ A third-party plugin for the [HydroOJ](https://github.com/hydro-dev/Hydro) open-source online judge. Issues and suggestions welcome.
206
+
207
+ ## License
208
+
209
+ MIT License