@zhouchangui/math-ati 0.1.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 (46) hide show
  1. package/.env.local.example +6 -0
  2. package/AGENTS.md +273 -0
  3. package/README.md +34 -0
  4. package/bin/math-ati.js +194 -0
  5. package/dist/assets/index-BYFoutza.js +22 -0
  6. package/dist/assets/index-Bk2WFPoL.css +1 -0
  7. package/dist/index.html +13 -0
  8. package/package.json +72 -0
  9. package/prompts/grading.system.md +129 -0
  10. package/prompts/knowledge-extract.system.md +123 -0
  11. package/prompts/knowledge-summarize.system.md +127 -0
  12. package/prompts/learning-summary.system.md +123 -0
  13. package/prompts/pdf-grading.system.md +80 -0
  14. package/prompts/pdf-page-extract.system.md +52 -0
  15. package/prompts/pdf-recheck.system.md +43 -0
  16. package/prompts/practice-generate.system.md +161 -0
  17. package/prompts/practice-review.system.md +65 -0
  18. package/prompts/practice-revise.system.md +56 -0
  19. package/server/abilityService.js +259 -0
  20. package/server/agentClient.js +202 -0
  21. package/server/env.js +4 -0
  22. package/server/fileStore.js +726 -0
  23. package/server/grading.js +116 -0
  24. package/server/index.js +655 -0
  25. package/server/jobStore.js +169 -0
  26. package/server/knowledgeBase.js +30 -0
  27. package/server/knowledgeExtractor.js +360 -0
  28. package/server/knowledgeFeedback.js +299 -0
  29. package/server/llmConfig.js +96 -0
  30. package/server/mistakeLifecycle.js +251 -0
  31. package/server/pdfSubmissionGrader.js +846 -0
  32. package/server/practiceGenerator.js +908 -0
  33. package/server/practicePaperHtml.js +313 -0
  34. package/server/practiceReviewer.js +307 -0
  35. package/server/practiceService.js +331 -0
  36. package/server/promptStore.js +16 -0
  37. package/server/submissionService.js +184 -0
  38. package/templates/workspace/.env.local.example +6 -0
  39. package/templates/workspace/data/global/ability_index.json +5 -0
  40. package/templates/workspace/data/global/chapters.json +621 -0
  41. package/templates/workspace/data/global/mastery_index.json +6 -0
  42. package/templates/workspace/data/global/mistakes_index.json +7 -0
  43. package/templates/workspace/data/global/student_profile.json +11 -0
  44. package/templates/workspace/data/knowledge_points.json +1264 -0
  45. package/templates/workspace/data/mistakes.json +1 -0
  46. package/vite.config.js +21 -0
@@ -0,0 +1,116 @@
1
+ import { callChatAgent, callVisionAgent } from './agentClient.js';
2
+ import { promptPayload, readPrompt } from './promptStore.js';
3
+
4
+ function gradingError(reason, detail = '') {
5
+ const error = new Error(`grading_failed:${reason}`);
6
+ error.status = 502;
7
+ error.reason = reason;
8
+ error.detail = detail;
9
+ return error;
10
+ }
11
+
12
+ export async function gradeSubmission({ practice, profile, files, notes }) {
13
+ const systemPrompt = await readPrompt('grading.system.md');
14
+ const agent = await callChatAgent({
15
+ timeoutMs: 60000,
16
+ system: systemPrompt,
17
+ user: promptPayload({
18
+ task: '根据练习卷题干、标准答案、知识点标签、上传照片文件信息和家长备注生成批改总结。练习 JSON 必须提供答案元数据;不能臆造看不清的手写内容。',
19
+ context: {
20
+ student: profile,
21
+ practice,
22
+ uploadedFiles: files.map((file) => ({
23
+ originalName: file.originalname,
24
+ storedName: file.filename,
25
+ path: file.path,
26
+ mimetype: file.mimetype,
27
+ size: file.size
28
+ })),
29
+ notes
30
+ },
31
+ schema: {
32
+ summary: 'string',
33
+ masterySignals: ['string'],
34
+ nextPracticeSuggestion: 'string',
35
+ grading: [
36
+ {
37
+ questionId: 'q1',
38
+ recognizedAnswer: 'string',
39
+ status: 'correct|partial|wrong|unrecognized|needs_review',
40
+ score: 0,
41
+ maxScore: 6,
42
+ errorTypes: ['string'],
43
+ comment: 'string',
44
+ referenceAnswer: 'string',
45
+ solutionMethod: ['string'],
46
+ teachingHint: 'string'
47
+ }
48
+ ]
49
+ }
50
+ })
51
+ });
52
+ if (!agent.ok || !Array.isArray(agent.data?.grading)) {
53
+ throw gradingError(agent.reason || 'invalid_agent_response', agent.detail || '');
54
+ }
55
+ return {
56
+ ...agent.data,
57
+ source: 'agent',
58
+ uploadedPhotos: files.length
59
+ };
60
+ }
61
+
62
+ export async function gradeSubmissionImages({ practice, profile, imagePaths, notes }) {
63
+ const files = imagePaths.map((imagePath) => ({
64
+ originalname: imagePath.split('/').pop(),
65
+ filename: imagePath.split('/').pop(),
66
+ path: imagePath,
67
+ mimetype: 'image/*',
68
+ size: 0
69
+ }));
70
+ const systemPrompt = await readPrompt('grading.system.md');
71
+ const agent = await callVisionAgent({
72
+ timeoutMs: 90000,
73
+ system: systemPrompt,
74
+ text: promptPayload({
75
+ task: '根据练习卷题干、标准答案、知识点标签和上传的学生作答照片生成批改总结。练习 JSON 必须提供答案元数据;不能臆造看不清的手写内容。',
76
+ context: {
77
+ student: profile,
78
+ practice,
79
+ uploadedFiles: files.map((file) => ({
80
+ originalName: file.originalname,
81
+ path: file.path,
82
+ mimetype: file.mimetype
83
+ })),
84
+ notes
85
+ },
86
+ schema: {
87
+ summary: 'string',
88
+ masterySignals: ['string'],
89
+ nextPracticeSuggestion: 'string',
90
+ grading: [
91
+ {
92
+ questionId: 'q1',
93
+ recognizedAnswer: 'string',
94
+ status: 'correct|partial|wrong|unrecognized|needs_review',
95
+ score: 0,
96
+ maxScore: 6,
97
+ errorTypes: ['string'],
98
+ comment: 'string',
99
+ referenceAnswer: 'string',
100
+ solutionMethod: ['string'],
101
+ teachingHint: 'string'
102
+ }
103
+ ]
104
+ }
105
+ }),
106
+ imagePaths
107
+ });
108
+ if (!agent.ok || !Array.isArray(agent.data?.grading)) {
109
+ throw gradingError(agent.reason || 'invalid_agent_response', agent.detail || '');
110
+ }
111
+ return {
112
+ ...agent.data,
113
+ source: 'agent',
114
+ uploadedPhotos: imagePaths.length
115
+ };
116
+ }