amicooked 0.0.0-stage → 0.1.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/LICENSE +23 -0
- package/README.md +87 -2
- package/dist/auth.js +171 -0
- package/dist/browser.js +141 -0
- package/dist/cdp.js +62 -0
- package/dist/cli/manage.js +89 -0
- package/dist/cli/serve.js +84 -0
- package/dist/cli/setup.js +211 -0
- package/dist/cli.js +80 -0
- package/dist/client.js +129 -0
- package/dist/clients/chatgpt.js +30 -0
- package/dist/clients/claudeCode.js +43 -0
- package/dist/clients/claudeDesktop.js +118 -0
- package/dist/clients/self.js +26 -0
- package/dist/config.js +76 -0
- package/dist/courseResolver.js +80 -0
- package/dist/extract.js +60 -0
- package/dist/instructions.js +6 -0
- package/dist/library.js +186 -0
- package/dist/remote/http.js +150 -0
- package/dist/remote/oauth.js +159 -0
- package/dist/remote/service.js +119 -0
- package/dist/remote/tunnel.js +99 -0
- package/dist/schools.js +82 -0
- package/dist/server.js +40 -0
- package/dist/skill.js +2 -0
- package/dist/tools/content.js +24 -0
- package/dist/tools/cooked.js +287 -0
- package/dist/tools/courses.js +28 -0
- package/dist/tools/deadlines.js +59 -0
- package/dist/tools/files.js +143 -0
- package/dist/tools/types.js +1 -0
- package/dist/utils/dateEvent.js +239 -0
- package/dist/utils/marshal.js +247 -0
- package/dist/version.js +2 -0
- package/package.json +54 -4
- package/skill/SKILL.md +58 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// DateEvent classification for D2L Brightspace API dates
|
|
2
|
+
export var DateType;
|
|
3
|
+
(function (DateType) {
|
|
4
|
+
DateType["DUE"] = "due";
|
|
5
|
+
DateType["AVAILABLE_FROM"] = "available_from";
|
|
6
|
+
DateType["CLOSES"] = "closes";
|
|
7
|
+
DateType["OPENS"] = "opens";
|
|
8
|
+
DateType["FEEDBACK_RELEASE"] = "feedback_release";
|
|
9
|
+
DateType["EXAM"] = "exam";
|
|
10
|
+
DateType["LECTURE"] = "lecture";
|
|
11
|
+
DateType["UNKNOWN"] = "unknown";
|
|
12
|
+
})(DateType || (DateType = {}));
|
|
13
|
+
export var Confidence;
|
|
14
|
+
(function (Confidence) {
|
|
15
|
+
Confidence["HIGH"] = "high";
|
|
16
|
+
Confidence["MEDIUM"] = "medium";
|
|
17
|
+
Confidence["LOW"] = "low";
|
|
18
|
+
})(Confidence || (Confidence = {}));
|
|
19
|
+
// Classification patterns
|
|
20
|
+
const PATTERNS = {
|
|
21
|
+
due: {
|
|
22
|
+
high: [
|
|
23
|
+
/\bdue\b/i,
|
|
24
|
+
/\bdeadline\b/i,
|
|
25
|
+
/\bsubmit by\b/i,
|
|
26
|
+
/\bmust be submitted\b/i,
|
|
27
|
+
/\bno later than\b/i,
|
|
28
|
+
/\bdue date\b/i,
|
|
29
|
+
/\bsubmission deadline\b/i,
|
|
30
|
+
],
|
|
31
|
+
medium: [
|
|
32
|
+
/\bsubmit\b/i,
|
|
33
|
+
/\bhand in\b/i,
|
|
34
|
+
/\bturn in\b/i,
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
available_from: {
|
|
38
|
+
high: [
|
|
39
|
+
/\bavailable from\b/i,
|
|
40
|
+
/\bopens\b/i,
|
|
41
|
+
/\breleased\b/i,
|
|
42
|
+
/\bposted\b/i,
|
|
43
|
+
/\bwill be available\b/i,
|
|
44
|
+
/\bstarts\b/i,
|
|
45
|
+
/\bbegins\b/i,
|
|
46
|
+
/\bavailability\b/i,
|
|
47
|
+
],
|
|
48
|
+
medium: [
|
|
49
|
+
/\bavailable\b/i,
|
|
50
|
+
],
|
|
51
|
+
},
|
|
52
|
+
closes: {
|
|
53
|
+
high: [
|
|
54
|
+
/\bcloses\b/i,
|
|
55
|
+
/\bavailable until\b/i,
|
|
56
|
+
/\bwindow closes\b/i,
|
|
57
|
+
/\bwill close\b/i,
|
|
58
|
+
/\bends\b/i,
|
|
59
|
+
/\bexpires\b/i,
|
|
60
|
+
/\bfinal date\b/i,
|
|
61
|
+
/\blast day\b/i,
|
|
62
|
+
],
|
|
63
|
+
medium: [
|
|
64
|
+
/\buntil\b/i,
|
|
65
|
+
/\bby\b/i,
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
feedback_release: {
|
|
69
|
+
high: [
|
|
70
|
+
/\bfeedback\b/i,
|
|
71
|
+
/\bgrade release\b/i,
|
|
72
|
+
/\bresults available\b/i,
|
|
73
|
+
/\bscores posted\b/i,
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
exam: {
|
|
77
|
+
high: [
|
|
78
|
+
/\bexam\b/i,
|
|
79
|
+
/\btest\b/i,
|
|
80
|
+
/\bmidterm\b/i,
|
|
81
|
+
/\bfinal\b/i,
|
|
82
|
+
/\bquiz\b/i,
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
lecture: {
|
|
86
|
+
high: [
|
|
87
|
+
/\blecture\b/i,
|
|
88
|
+
/\bclass\b/i,
|
|
89
|
+
/\blesson\b/i,
|
|
90
|
+
/\bseminar\b/i,
|
|
91
|
+
/\btutorial\b/i,
|
|
92
|
+
],
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Classify a date event based on title, description, and context
|
|
97
|
+
*/
|
|
98
|
+
export function classifyDateEvent(title, description = '', eventType = null) {
|
|
99
|
+
const text = `${title} ${description}`.toLowerCase();
|
|
100
|
+
// Check each pattern category in priority order
|
|
101
|
+
for (const [type, levels] of Object.entries(PATTERNS)) {
|
|
102
|
+
// Check high confidence patterns first
|
|
103
|
+
if (levels.high) {
|
|
104
|
+
for (const pattern of levels.high) {
|
|
105
|
+
if (pattern.test(text)) {
|
|
106
|
+
const match = text.match(pattern);
|
|
107
|
+
return {
|
|
108
|
+
dateType: type,
|
|
109
|
+
confidence: Confidence.HIGH,
|
|
110
|
+
snippet: match ? match[0] : text.substring(0, 50),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
// Then medium confidence patterns
|
|
116
|
+
if ('medium' in levels && levels.medium) {
|
|
117
|
+
for (const pattern of levels.medium) {
|
|
118
|
+
if (pattern.test(text)) {
|
|
119
|
+
const match = text.match(pattern);
|
|
120
|
+
return {
|
|
121
|
+
dateType: type,
|
|
122
|
+
confidence: Confidence.MEDIUM,
|
|
123
|
+
snippet: match ? match[0] : text.substring(0, 50),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
// Fallback based on event type
|
|
130
|
+
if (eventType) {
|
|
131
|
+
if (eventType.includes('Dropbox') || eventType.includes('Assignment')) {
|
|
132
|
+
return {
|
|
133
|
+
dateType: DateType.DUE,
|
|
134
|
+
confidence: Confidence.MEDIUM,
|
|
135
|
+
snippet: 'inferred from assignment type',
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
if (eventType.includes('Quiz')) {
|
|
139
|
+
return {
|
|
140
|
+
dateType: DateType.EXAM,
|
|
141
|
+
confidence: Confidence.MEDIUM,
|
|
142
|
+
snippet: 'inferred from quiz type',
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
dateType: DateType.UNKNOWN,
|
|
148
|
+
confidence: Confidence.LOW,
|
|
149
|
+
snippet: text.substring(0, 50),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Deduplicate date events by assignment ID, prioritizing due dates
|
|
154
|
+
*/
|
|
155
|
+
export function deduplicateDateEvents(events) {
|
|
156
|
+
// Group by assignmentId
|
|
157
|
+
const grouped = new Map();
|
|
158
|
+
const nonAssignment = [];
|
|
159
|
+
for (const event of events) {
|
|
160
|
+
if (event.assignmentId) {
|
|
161
|
+
const group = grouped.get(event.assignmentId) || [];
|
|
162
|
+
group.push(event);
|
|
163
|
+
grouped.set(event.assignmentId, group);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
nonAssignment.push(event);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// For each assignment, pick the best date
|
|
170
|
+
const deduplicated = [];
|
|
171
|
+
for (const [_, group] of grouped) {
|
|
172
|
+
if (group.length === 1) {
|
|
173
|
+
deduplicated.push(group[0]);
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
// Priority: DUE with high confidence > DUE with medium > other types
|
|
177
|
+
const dueHighConf = group.find(e => e.dateType === DateType.DUE && e.confidence === Confidence.HIGH);
|
|
178
|
+
if (dueHighConf) {
|
|
179
|
+
deduplicated.push(dueHighConf);
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
const dueMedConf = group.find(e => e.dateType === DateType.DUE && e.confidence === Confidence.MEDIUM);
|
|
183
|
+
if (dueMedConf) {
|
|
184
|
+
deduplicated.push(dueMedConf);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
// If no clear due date, take the middle date (sorted chronologically)
|
|
188
|
+
const sorted = [...group].sort((a, b) => new Date(a.datetime).getTime() - new Date(b.datetime).getTime());
|
|
189
|
+
const middleIndex = Math.floor(sorted.length / 2);
|
|
190
|
+
deduplicated.push(sorted[middleIndex]);
|
|
191
|
+
}
|
|
192
|
+
return [...deduplicated, ...nonAssignment];
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Group date events by category for presentation
|
|
196
|
+
*/
|
|
197
|
+
export function groupDateEventsByCategory(events) {
|
|
198
|
+
const now = new Date();
|
|
199
|
+
const sevenDaysFromNow = new Date(now.getTime() + 7 * 24 * 60 * 60 * 1000);
|
|
200
|
+
const dueSoon = [];
|
|
201
|
+
const opensSoon = [];
|
|
202
|
+
const closesSoon = [];
|
|
203
|
+
const needsConfirmation = [];
|
|
204
|
+
const other = [];
|
|
205
|
+
for (const event of events) {
|
|
206
|
+
const eventDate = new Date(event.datetime);
|
|
207
|
+
const isWithinWeek = eventDate <= sevenDaysFromNow;
|
|
208
|
+
if (event.dateType === DateType.UNKNOWN || event.confidence === Confidence.LOW) {
|
|
209
|
+
needsConfirmation.push(event);
|
|
210
|
+
}
|
|
211
|
+
else if (event.dateType === DateType.DUE && isWithinWeek) {
|
|
212
|
+
dueSoon.push(event);
|
|
213
|
+
}
|
|
214
|
+
else if (event.dateType === DateType.AVAILABLE_FROM && isWithinWeek) {
|
|
215
|
+
opensSoon.push(event);
|
|
216
|
+
}
|
|
217
|
+
else if (event.dateType === DateType.CLOSES && isWithinWeek) {
|
|
218
|
+
closesSoon.push(event);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
other.push(event);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
// Sort each group by date
|
|
225
|
+
const sortByDate = (a, b) => new Date(a.datetime).getTime() - new Date(b.datetime).getTime();
|
|
226
|
+
return {
|
|
227
|
+
dueSoon: dueSoon.sort(sortByDate),
|
|
228
|
+
opensSoon: opensSoon.sort(sortByDate),
|
|
229
|
+
closesSoon: closesSoon.sort(sortByDate),
|
|
230
|
+
needsConfirmation: needsConfirmation.sort(sortByDate),
|
|
231
|
+
other: other.sort(sortByDate),
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Convert DateEvent to Task (only for high-confidence due dates)
|
|
236
|
+
*/
|
|
237
|
+
export function shouldConvertToTask(event) {
|
|
238
|
+
return event.dateType === DateType.DUE && event.confidence === Confidence.HIGH;
|
|
239
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// Utility functions for marshalling D2L API responses to LLM-friendly formats
|
|
2
|
+
import { DateType, classifyDateEvent, deduplicateDateEvents } from './dateEvent.js';
|
|
3
|
+
// Strip HTML tags and decode entities
|
|
4
|
+
export function stripHtml(html) {
|
|
5
|
+
if (!html)
|
|
6
|
+
return '';
|
|
7
|
+
return html
|
|
8
|
+
.replace(/<[^>]*>/g, '')
|
|
9
|
+
.replace(/ /g, ' ')
|
|
10
|
+
.replace(/&/g, '&')
|
|
11
|
+
.replace(/</g, '<')
|
|
12
|
+
.replace(/>/g, '>')
|
|
13
|
+
.replace(/"/g, '"')
|
|
14
|
+
.replace(/'/g, "'")
|
|
15
|
+
.replace(/\r\n/g, '\n')
|
|
16
|
+
.replace(/\n{3,}/g, '\n\n')
|
|
17
|
+
.trim();
|
|
18
|
+
}
|
|
19
|
+
// Format date to readable string
|
|
20
|
+
export function formatDate(isoDate) {
|
|
21
|
+
if (!isoDate)
|
|
22
|
+
return null;
|
|
23
|
+
const date = new Date(isoDate);
|
|
24
|
+
return date.toLocaleDateString('en-US', {
|
|
25
|
+
weekday: 'short',
|
|
26
|
+
month: 'short',
|
|
27
|
+
day: 'numeric',
|
|
28
|
+
year: 'numeric',
|
|
29
|
+
hour: 'numeric',
|
|
30
|
+
minute: '2-digit',
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
// Format date relative to now
|
|
34
|
+
export function formatRelativeDate(isoDate) {
|
|
35
|
+
if (!isoDate)
|
|
36
|
+
return null;
|
|
37
|
+
const date = new Date(isoDate);
|
|
38
|
+
const now = new Date();
|
|
39
|
+
const diffMs = date.getTime() - now.getTime();
|
|
40
|
+
const diffDays = Math.round(diffMs / (1000 * 60 * 60 * 24));
|
|
41
|
+
if (diffDays === 0)
|
|
42
|
+
return 'today';
|
|
43
|
+
if (diffDays === 1)
|
|
44
|
+
return 'tomorrow';
|
|
45
|
+
if (diffDays === -1)
|
|
46
|
+
return 'yesterday';
|
|
47
|
+
if (diffDays > 0 && diffDays <= 7)
|
|
48
|
+
return `in ${diffDays} days`;
|
|
49
|
+
if (diffDays < 0 && diffDays >= -7)
|
|
50
|
+
return `${Math.abs(diffDays)} days ago`;
|
|
51
|
+
return formatDate(isoDate);
|
|
52
|
+
}
|
|
53
|
+
// Format file size
|
|
54
|
+
export function formatFileSize(bytes) {
|
|
55
|
+
if (bytes < 1024)
|
|
56
|
+
return `${bytes} B`;
|
|
57
|
+
if (bytes < 1024 * 1024)
|
|
58
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
59
|
+
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
60
|
+
}
|
|
61
|
+
// Remove null, undefined, empty strings, and empty arrays from object
|
|
62
|
+
export function removeEmpty(obj) {
|
|
63
|
+
const result = {};
|
|
64
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
65
|
+
if (value === null || value === undefined)
|
|
66
|
+
continue;
|
|
67
|
+
if (value === '')
|
|
68
|
+
continue;
|
|
69
|
+
if (Array.isArray(value) && value.length === 0)
|
|
70
|
+
continue;
|
|
71
|
+
result[key] = value;
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
75
|
+
export function marshalGrades(grades) {
|
|
76
|
+
return grades.map((g) => removeEmpty({
|
|
77
|
+
name: g.GradeObjectName,
|
|
78
|
+
score: g.PointsNumerator !== null && g.PointsDenominator !== null
|
|
79
|
+
? `${g.PointsNumerator}/${g.PointsDenominator}`
|
|
80
|
+
: null,
|
|
81
|
+
percentage: g.DisplayedGrade?.trim() || null,
|
|
82
|
+
weight: g.WeightedDenominator ? Math.round(g.WeightedDenominator * 10) / 10 : null,
|
|
83
|
+
feedback: g.Comments?.Text?.trim() || null,
|
|
84
|
+
lastModified: formatDate(g.LastModified),
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
export function marshalAnnouncements(announcements) {
|
|
88
|
+
return announcements.map((a) => removeEmpty({
|
|
89
|
+
id: a.Id,
|
|
90
|
+
title: a.Title,
|
|
91
|
+
body: stripHtml(a.Body.Text || a.Body.Html),
|
|
92
|
+
date: formatDate(a.CreatedDate),
|
|
93
|
+
attachments: a.Attachments?.length > 0
|
|
94
|
+
? a.Attachments.map((att) => ({ name: att.FileName, size: formatFileSize(att.Size) }))
|
|
95
|
+
: undefined,
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
export function marshalCalendarEvents(response) {
|
|
99
|
+
// Convert all calendar events to DateEvent objects
|
|
100
|
+
const dateEvents = response.Objects.map((e) => {
|
|
101
|
+
const entityType = e.AssociatedEntity?.AssociatedEntityType;
|
|
102
|
+
let type = null;
|
|
103
|
+
if (entityType?.includes('Dropbox'))
|
|
104
|
+
type = 'assignment';
|
|
105
|
+
else if (entityType?.includes('Quiz'))
|
|
106
|
+
type = 'quiz';
|
|
107
|
+
else if (entityType?.includes('Discussion'))
|
|
108
|
+
type = 'discussion';
|
|
109
|
+
else if (entityType)
|
|
110
|
+
type = entityType.split('.').pop() || null;
|
|
111
|
+
// Classify the date event
|
|
112
|
+
const classification = classifyDateEvent(e.Title, e.Description, entityType);
|
|
113
|
+
return {
|
|
114
|
+
courseId: e.OrgUnitId,
|
|
115
|
+
courseName: e.OrgUnitName,
|
|
116
|
+
title: e.Title,
|
|
117
|
+
datetime: e.EndDateTime,
|
|
118
|
+
dateType: classification.dateType,
|
|
119
|
+
source: 'calendar',
|
|
120
|
+
url: e.CalendarEventViewUrl,
|
|
121
|
+
confidence: classification.confidence,
|
|
122
|
+
rawSnippet: classification.snippet,
|
|
123
|
+
assignmentId: e.AssociatedEntity?.AssociatedEntityId || null,
|
|
124
|
+
};
|
|
125
|
+
});
|
|
126
|
+
// Deduplicate using the DateEvent system
|
|
127
|
+
const deduplicated = deduplicateDateEvents(dateEvents);
|
|
128
|
+
// Convert back to MarshalledDueDate format for backward compatibility
|
|
129
|
+
return deduplicated.map((event) => {
|
|
130
|
+
let type = null;
|
|
131
|
+
switch (event.dateType) {
|
|
132
|
+
case DateType.DUE:
|
|
133
|
+
type = 'assignment';
|
|
134
|
+
break;
|
|
135
|
+
case DateType.EXAM:
|
|
136
|
+
type = 'quiz';
|
|
137
|
+
break;
|
|
138
|
+
default:
|
|
139
|
+
// Infer from source or leave as unknown
|
|
140
|
+
type = event.source === 'calendar' ? 'event' : null;
|
|
141
|
+
}
|
|
142
|
+
return removeEmpty({
|
|
143
|
+
title: event.title,
|
|
144
|
+
dueDate: formatDate(event.datetime),
|
|
145
|
+
dueDateRelative: formatRelativeDate(event.datetime),
|
|
146
|
+
course: event.courseName,
|
|
147
|
+
type,
|
|
148
|
+
assignmentId: event.assignmentId,
|
|
149
|
+
viewUrl: event.url || '',
|
|
150
|
+
submitUrl: null,
|
|
151
|
+
// Add classification metadata for debugging
|
|
152
|
+
dateType: event.dateType,
|
|
153
|
+
confidence: event.confidence,
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
export function marshalEnrollments(response) {
|
|
158
|
+
return response.Items
|
|
159
|
+
.filter((e) => e.OrgUnit.Type.Code === 'Course Offering')
|
|
160
|
+
.map((e) => removeEmpty({
|
|
161
|
+
id: e.OrgUnit.Id,
|
|
162
|
+
name: e.OrgUnit.Name,
|
|
163
|
+
code: e.OrgUnit.Code,
|
|
164
|
+
type: e.OrgUnit.Type.Name,
|
|
165
|
+
homeUrl: e.OrgUnit.HomeUrl,
|
|
166
|
+
isActive: e.Access.IsActive,
|
|
167
|
+
canAccess: e.Access.CanAccess,
|
|
168
|
+
lastAccessed: formatDate(e.Access.LastAccessed),
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
171
|
+
export function marshalAssignments(assignments) {
|
|
172
|
+
return assignments.map((a) => marshalAssignment(a));
|
|
173
|
+
}
|
|
174
|
+
export function marshalAssignment(a) {
|
|
175
|
+
let fileTypes = null;
|
|
176
|
+
if (a.AllowableFileType === 0)
|
|
177
|
+
fileTypes = 'any';
|
|
178
|
+
else if (a.AllowableFileType === 5 && a.CustomAllowableFileTypes?.length) {
|
|
179
|
+
fileTypes = a.CustomAllowableFileTypes.join(', ');
|
|
180
|
+
}
|
|
181
|
+
return removeEmpty({
|
|
182
|
+
id: a.Id,
|
|
183
|
+
name: a.Name,
|
|
184
|
+
dueDate: formatDate(a.DueDate),
|
|
185
|
+
dueDateRelative: formatRelativeDate(a.DueDate),
|
|
186
|
+
points: a.Assessment?.ScoreDenominator ?? 0,
|
|
187
|
+
instructions: stripHtml(a.CustomInstructions?.Text || a.CustomInstructions?.Html) || null,
|
|
188
|
+
attachments: a.Attachments?.length > 0
|
|
189
|
+
? a.Attachments.map((att) => ({ name: att.FileName, size: formatFileSize(att.Size) }))
|
|
190
|
+
: undefined,
|
|
191
|
+
links: a.LinkAttachments?.length > 0
|
|
192
|
+
? a.LinkAttachments.map((l) => ({ name: l.Name, url: l.Url }))
|
|
193
|
+
: undefined,
|
|
194
|
+
allowedFileTypes: fileTypes,
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
/** D2L dropbox status: 0 unsubmitted, 1 submitted, 2 draft, 3 feedback published (so also submitted). */
|
|
198
|
+
export function isSubmitted(s) {
|
|
199
|
+
return s.Status === 1 || s.Status === 3 || (s.Submissions?.length ?? 0) > 0;
|
|
200
|
+
}
|
|
201
|
+
export function marshalSubmissions(submissions) {
|
|
202
|
+
return submissions.map((s) => {
|
|
203
|
+
const latestSubmission = s.Submissions?.[0];
|
|
204
|
+
return removeEmpty({
|
|
205
|
+
submitted: isSubmitted(s),
|
|
206
|
+
submittedBy: s.Entity.DisplayName,
|
|
207
|
+
submissionDate: formatDate(latestSubmission?.SubmissionDate),
|
|
208
|
+
submissionDateRelative: formatRelativeDate(latestSubmission?.SubmissionDate),
|
|
209
|
+
files: latestSubmission?.Files?.map((f) => ({
|
|
210
|
+
name: f.FileName,
|
|
211
|
+
size: formatFileSize(f.Size),
|
|
212
|
+
})) || [],
|
|
213
|
+
comment: latestSubmission?.Comment?.Text?.trim() || null,
|
|
214
|
+
grade: s.Feedback?.Score ?? null,
|
|
215
|
+
feedback: stripHtml(s.Feedback?.Feedback?.Text || s.Feedback?.Feedback?.Html) || null,
|
|
216
|
+
});
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
export function marshalContentModules(modules) {
|
|
220
|
+
return modules.map((m) => marshalContentModule(m));
|
|
221
|
+
}
|
|
222
|
+
export function marshalContentModule(m) {
|
|
223
|
+
return removeEmpty({
|
|
224
|
+
id: m.ModuleId,
|
|
225
|
+
title: m.Title,
|
|
226
|
+
description: stripHtml(m.Description?.Text || m.Description?.Html) || null,
|
|
227
|
+
topics: m.Topics?.map((t) => removeEmpty({
|
|
228
|
+
id: t.TopicId,
|
|
229
|
+
title: t.Title,
|
|
230
|
+
url: t.Url || null,
|
|
231
|
+
type: t.TypeIdentifier || null,
|
|
232
|
+
})),
|
|
233
|
+
modules: m.Modules?.length ? marshalContentModules(m.Modules) : undefined,
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
export function marshalToc(toc) {
|
|
237
|
+
return marshalContentModules(toc.Modules || []);
|
|
238
|
+
}
|
|
239
|
+
export function marshalTopic(t) {
|
|
240
|
+
return removeEmpty({
|
|
241
|
+
id: t.TopicId,
|
|
242
|
+
title: t.Title,
|
|
243
|
+
description: stripHtml(t.Description?.Text || t.Description?.Html) || null,
|
|
244
|
+
url: t.Url || null,
|
|
245
|
+
type: t.TypeIdentifier || null,
|
|
246
|
+
});
|
|
247
|
+
}
|
package/dist/version.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,56 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "amicooked",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Ask your AI if you're cooked. A local MCP server for D2L Brightspace: grades, deadlines and announcements in Claude and ChatGPT.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"amicooked": "dist/cli.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"skill"
|
|
12
|
+
],
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=22"
|
|
15
|
+
},
|
|
16
|
+
"scripts": {
|
|
17
|
+
"sync:skill": "node scripts/sync-skill.mjs",
|
|
18
|
+
"build": "node scripts/sync-skill.mjs && tsc",
|
|
19
|
+
"test": "vitest run",
|
|
20
|
+
"test:watch": "vitest",
|
|
21
|
+
"prepack": "npm run build",
|
|
22
|
+
"build:bin": "node scripts/sync-skill.mjs && node scripts/build-binaries.mjs"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"mcp",
|
|
26
|
+
"d2l",
|
|
27
|
+
"brightspace",
|
|
28
|
+
"students",
|
|
29
|
+
"claude",
|
|
30
|
+
"chatgpt"
|
|
31
|
+
],
|
|
32
|
+
"author": "Uday Singh Kanwar",
|
|
33
|
+
"contributors": [
|
|
34
|
+
"Hamza Ammar (https://github.com/hamzakammar)",
|
|
35
|
+
"Bence Redmond (https://github.com/General-Mudkip)",
|
|
36
|
+
"alanxue1 (https://github.com/alanxue1)"
|
|
37
|
+
],
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/udaysinghkanwar/amicooked"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@clack/prompts": "^1.8.1",
|
|
45
|
+
"@modelcontextprotocol/sdk": "1.32.2",
|
|
46
|
+
"jszip": "^3.10.1",
|
|
47
|
+
"mammoth": "^1.11.0",
|
|
48
|
+
"unpdf": "^1.9.1",
|
|
49
|
+
"zod": "^3.25.76"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@types/node": "^22.20.5",
|
|
53
|
+
"typescript": "^5.9.3",
|
|
54
|
+
"vitest": "^5.1.0"
|
|
55
|
+
}
|
|
56
|
+
}
|
package/skill/SKILL.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: amicooked
|
|
3
|
+
description: Use when a student asks about their D2L Brightspace courses, grades, deadlines, assignments, announcements or course files, asks "am I cooked?", or wants to set up Am I Cooked.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Am I Cooked
|
|
7
|
+
|
|
8
|
+
Am I Cooked connects an AI assistant to a student's D2L Brightspace account (Avenue to Learn, LEARN, onQ, OWL Brightspace, CourseLink, MyLearningSpace and others). It runs on the student's own computer and is read-only.
|
|
9
|
+
|
|
10
|
+
## Setting it up (for agents)
|
|
11
|
+
|
|
12
|
+
1. Ask the student which school they go to. Presets: mcmaster, waterloo, western, queens, guelph, laurier, tmu, uottawa, carleton, brock, windsor, laurentian, lakehead. Any other Brightspace school works with the URL they log in through.
|
|
13
|
+
2. Install it:
|
|
14
|
+
- macOS / Linux: `curl -fsSL https://amicooked-mcp.vercel.app/install.sh | sh -s -- --no-setup`
|
|
15
|
+
- Windows (PowerShell): `$env:AMICOOKED_NO_SETUP=1; irm https://amicooked-mcp.vercel.app/install.ps1 | iex`
|
|
16
|
+
- With Node.js installed, `npx -y amicooked@0` works in place of `amicooked` below.
|
|
17
|
+
3. Run setup with flags, and a long command timeout (at least 5 minutes), because the student signs in through a browser window that opens:
|
|
18
|
+
`amicooked setup --school mcmaster --clients desktop,code`
|
|
19
|
+
Use `--school https://...` for schools without a preset. Add `chatgpt` to `--clients` if they use ChatGPT.
|
|
20
|
+
4. Tell the student to sign in to their school in the browser window. Never ask for their password; you never need it.
|
|
21
|
+
5. If something fails, run `amicooked status` and read what it says.
|
|
22
|
+
|
|
23
|
+
<!-- server-instructions -->
|
|
24
|
+
## Answering questions
|
|
25
|
+
|
|
26
|
+
- Start broad questions ("am I cooked?", "what should I work on?", "how am I doing?", "what's due?") with `am_i_cooked`. It covers every current course in one call.
|
|
27
|
+
- Other tools take a course code directly, like `course: "3BB4"`. Only call `get_my_courses` when a code is ambiguous or the student asks what they're enrolled in.
|
|
28
|
+
- Check `get_announcements` for a course before a final verdict on it; deadlines and exam details often change there.
|
|
29
|
+
- To read slides, handouts or assignment PDFs: `get_course_content` to find the file, then `download_file`. Use `read_file` for files already downloaded.
|
|
30
|
+
- If a tool says a login window opened, tell the student to sign in there and ask again.
|
|
31
|
+
|
|
32
|
+
## The verdict
|
|
33
|
+
|
|
34
|
+
Use `summary.heatLabel` from `am_i_cooked` to set the tone. Be playful, never mean, and always useful.
|
|
35
|
+
|
|
36
|
+
| heatLabel | Tone |
|
|
37
|
+
|---|---|
|
|
38
|
+
| raw | Relaxed. Nothing urgent; maybe get ahead on something. |
|
|
39
|
+
| warming up | Light nudge. One or two things to handle soon. |
|
|
40
|
+
| toasty | Focused. A real plan for the next few days. |
|
|
41
|
+
| cooked | Direct and supportive. Triage what matters most. |
|
|
42
|
+
| well done | Calm and practical. Damage control, and who to talk to. |
|
|
43
|
+
|
|
44
|
+
1. Lead with a one-line verdict, e.g. "Toasty, not cooked."
|
|
45
|
+
2. Then the top 3 actions, each with course, item and due time in the student's local time (D2L times are UTC).
|
|
46
|
+
3. Say whether a grade is `final_calculated` or `estimated_from_items`; estimates ignore dropped and bonus items.
|
|
47
|
+
- For an estimate, say how much is left, like "67.6% so far. 60% of your grade is still to come." Use `weightRemaining` for that number.
|
|
48
|
+
- Name the `keyItems` when a grade needs explaining, with their weight: "the midterm (59.5%, worth 25%) is pulling it down."
|
|
49
|
+
- Never work weights out backwards from a result. Use the `weight` values the tools return.
|
|
50
|
+
- `basis: "points"` means the gradebook has no weights. Say the estimate is by points and the real weighting may differ. If the student asks how the grade is calculated, find the course outline with `get_course_content` and read the weights from it.
|
|
51
|
+
4. `late_window_open` means a missed assignment can still be submitted: say so first, it's the easiest win.
|
|
52
|
+
5. If `partial_data` appears, mention that some of a course couldn't be loaded.
|
|
53
|
+
6. For grades under 60%, suggest office hours, the TA, or an academic advisor.
|
|
54
|
+
|
|
55
|
+
## Integrity
|
|
56
|
+
|
|
57
|
+
Am I Cooked only reads. Help the student understand material and plan their time, but don't write graded work for them to submit.
|
|
58
|
+
<!-- /server-instructions -->
|