coursecode 0.1.26 → 0.1.27

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.
@@ -662,9 +662,9 @@ Runs **in Node.js** during build (via `vite.framework-dev.config.js` `closeBundl
662
662
 
663
663
  **Errors fail the build; warnings print but don't block.**
664
664
 
665
- ### MCP `coursecode_lint` — Unified Results
665
+ ### MCP `coursecode_lint` — Build-Time Only
666
666
 
667
- The MCP `coursecode_lint` tool always runs the build linter. When the preview server is running and the headless browser is connected, it also merges runtime errors from the preview server's error log into the same response. These are the same errors shown in the debug panel's Errors tab and returned by `coursecode_state` LMS API misuse, console errors, uncaught exceptions, and data limit warnings. Runtime-sourced items are tagged with `source: 'runtime'` and `rule: 'runtime-error'`. The `runtimeLintIncluded` flag in the response indicates whether runtime errors were included. This gives AI agents a single tool for both static lint and runtime errors without needing a separate `coursecode_state` call.
667
+ The MCP `coursecode_lint` tool runs the build linter (config validation, CSS class verification, structure checks). It does NOT include runtime errors. For runtime errors, contrast warnings, and other dynamic issues, use `coursecode_state` which returns `frameworkLogs` and `errors` from the preview server.
668
668
 
669
669
  ### Shared Rules (`lib/validation-rules.js`)
670
670
 
@@ -308,13 +308,12 @@ Use to discover available interactions before creating assessments.`,
308
308
  name: 'coursecode_lint',
309
309
  description: `Run the course linter and get structured results.
310
310
 
311
- Always runs build-time lint (config, CSS classes, structure). When the preview server is running and the headless browser is connected, also includes runtime errors from the preview server (same errors shown in coursecode_state and the debug panel Errors tab).
311
+ Always runs build-time lint (config, CSS classes, structure). Does NOT include runtime errors use coursecode_state for runtime errors and contrast warnings when the preview server is running.
312
312
 
313
313
  Returns:
314
- - errors: [{slideId?, rule, message, severity, source?, hint?}]
315
- - warnings: [{slideId?, rule, message, severity, source?, class?, suggestion?, hint?}]
314
+ - errors: [{slideId?, rule, message, severity, hint?}]
315
+ - warnings: [{slideId?, rule, message, severity, hint?}]
316
316
  - passed: boolean
317
- - runtimeLintIncluded: boolean (true when runtime errors were included)
318
317
 
319
318
  Build-time rules (always checked):
320
319
  - undefined-css-class: hallucinated or stale class names (with fix suggestions)
@@ -325,18 +324,6 @@ Build-time rules (always checked):
325
324
  - assessment-id-mismatch: config ID doesn't match assessment ID
326
325
  - invalid-gating: bad gating condition configuration
327
326
 
328
- Runtime errors (included when preview is running, source='runtime'):
329
- - LMS API misuse (GetValue before Initialize, SetValue after Terminate, etc.)
330
- - Console errors and warnings from the course
331
- - Uncaught exceptions and unhandled promise rejections
332
- - Suspend data size warnings
333
-
334
- Suppression: Add data-lint-ignore to any HTML element to suppress warnings for it and children.
335
- data-lint-ignore — suppress all warnings
336
- data-lint-ignore="spacing" — suppress only spacing warnings
337
- data-lint-ignore="spacing,contrast" — suppress multiple categories
338
- Categories: spacing, contrast, target-size, proximity, overlap, list-style, css-class
339
-
340
327
  Use AFTER making changes to validate the course.`,
341
328
  inputSchema: {
342
329
  type: 'object',
package/lib/mcp-server.js CHANGED
@@ -105,14 +105,23 @@ export async function startMcpServer(options = {}) {
105
105
  lmsState: api.getLmsState()
106
106
  };
107
107
  });
108
- // Read last 20 API log entries from parent window (stub player diagnostic)
109
- result.apiLog = await headless.evaluateParent(() => {
110
- return window._stubPlayerState?.apiLog?.slice(0, 20) || [];
111
- });
112
- // Read error log from parent window (stub player diagnostic)
113
- result.errors = await headless.evaluateParent(() => {
114
- return window._stubPlayerState?.errorLog || [];
115
- });
108
+ // Read API log and error log from preview server (same data user sees in debug panel)
109
+ try {
110
+ const [logResp, errResp] = await Promise.all([
111
+ fetch(`http://localhost:${port}/__lms/log`),
112
+ fetch(`http://localhost:${port}/__lms/errors`)
113
+ ]);
114
+ result.apiLog = logResp.ok ? (await logResp.json()).entries?.slice(0, 20) || [] : [];
115
+ if (errResp.ok) {
116
+ const errData = await errResp.json();
117
+ result.errors = [...(errData.errors || []), ...(errData.warnings || [])];
118
+ } else {
119
+ result.errors = [];
120
+ }
121
+ } catch {
122
+ result.apiLog = [];
123
+ result.errors = [];
124
+ }
116
125
  // Append console errors/warnings captured from the page
117
126
  result.consoleLogs = headless.getConsoleLogs();
118
127
  break;
@@ -247,48 +256,6 @@ export async function startMcpServer(options = {}) {
247
256
  break;
248
257
  case 'coursecode_lint':
249
258
  result = await lintCourse();
250
- // Merge runtime errors if headless browser is already connected
251
- if (headless.isRunning()) {
252
- try {
253
- const runtimeErrors = await headless.evaluateParent(() => {
254
- return window._stubPlayerState?.errorLog || [];
255
- });
256
- result.runtimeLintIncluded = true;
257
- if (runtimeErrors.length > 0) {
258
- const runtimeWarnings = runtimeErrors.filter(e => e.isWarning);
259
- const runtimeErrs = runtimeErrors.filter(e => !e.isWarning);
260
- if (runtimeWarnings.length > 0) {
261
- result.warnings = (result.warnings || []).concat(
262
- runtimeWarnings.map(e => ({
263
- severity: 'warning',
264
- type: e.type,
265
- message: e.message,
266
- hint: e.hint,
267
- rule: 'runtime-error',
268
- source: 'runtime'
269
- }))
270
- );
271
- result.warningCount = result.warnings.length;
272
- }
273
- if (runtimeErrs.length > 0) {
274
- result.errors = (result.errors || []).concat(
275
- runtimeErrs.map(e => ({
276
- severity: 'error',
277
- type: e.type,
278
- message: e.message,
279
- hint: e.hint,
280
- rule: 'runtime-error',
281
- source: 'runtime'
282
- }))
283
- );
284
- result.errorCount = result.errors.length;
285
- result.passed = result.errors.length === 0;
286
- }
287
- }
288
- } catch {
289
- // Headless browser may have disconnected — non-fatal, build lint still valid
290
- }
291
- }
292
259
  break;
293
260
 
294
261
  case 'coursecode_export_content':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coursecode",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "description": "Multi-format course authoring framework with CLI tools (SCORM 2004, SCORM 1.2, cmi5, LTI 1.3)",
5
5
  "type": "module",
6
6
  "bin": {