@tsrx/mcp 0.0.4 → 0.0.6

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/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "MCP server for TSRX documentation and project context",
4
4
  "license": "MIT",
5
5
  "author": "Dominic Gannaway",
6
- "version": "0.0.4",
6
+ "version": "0.0.6",
7
7
  "type": "module",
8
8
  "repository": {
9
9
  "type": "git",
@@ -37,8 +37,8 @@
37
37
  "@modelcontextprotocol/sdk": "^1.29.0",
38
38
  "prettier": "^3.8.3",
39
39
  "zod": "^4.3.6",
40
- "@tsrx/core": "0.0.23",
41
- "@tsrx/prettier-plugin": "0.3.43"
40
+ "@tsrx/prettier-plugin": "0.3.45",
41
+ "@tsrx/core": "0.0.25"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@types/node": "^24.3.0",
package/src/analyze.js CHANGED
@@ -1,4 +1,12 @@
1
- import { DIAGNOSTIC_CODES } from '@tsrx/core';
1
+ import {
2
+ COMPONENT_DO_WHILE_STATEMENT_ERROR,
3
+ COMPONENT_FOR_IN_STATEMENT_ERROR,
4
+ COMPONENT_FOR_STATEMENT_ERROR,
5
+ COMPONENT_LOOP_BREAK_ERROR,
6
+ COMPONENT_LOOP_RETURN_ERROR,
7
+ COMPONENT_WHILE_STATEMENT_ERROR,
8
+ DIAGNOSTIC_CODES,
9
+ } from '@tsrx/core';
2
10
  import { compile_tsrx } from './compile.js';
3
11
 
4
12
  /**
@@ -28,6 +36,7 @@ function create_advice(input) {
28
36
  /** @type {TSRXAdvice[]} */
29
37
  const advice = [];
30
38
  const error_codes = new Set(compileResult.errors.map((error) => error.code).filter(Boolean));
39
+ const error_messages = new Set(compileResult.errors.map((error) => error.message));
31
40
 
32
41
  if (!compileResult.target) {
33
42
  advice.push({
@@ -98,6 +107,36 @@ function create_advice(input) {
98
107
  });
99
108
  }
100
109
 
110
+ if (
111
+ error_messages.has(COMPONENT_LOOP_RETURN_ERROR) ||
112
+ error_messages.has(COMPONENT_LOOP_BREAK_ERROR)
113
+ ) {
114
+ advice.push({
115
+ kind: 'component-loop-control-flow',
116
+ severity: 'error',
117
+ title: 'Use continue inside component for...of loops',
118
+ message:
119
+ 'Top-level return and break statements are not valid inside a component for...of loop. Use continue to skip the current rendered item. Nested functions inside the loop keep ordinary JavaScript control flow.',
120
+ documentation: ['tsrx://docs/control-flow.md'],
121
+ });
122
+ }
123
+
124
+ if (
125
+ error_messages.has(COMPONENT_FOR_STATEMENT_ERROR) ||
126
+ error_messages.has(COMPONENT_FOR_IN_STATEMENT_ERROR) ||
127
+ error_messages.has(COMPONENT_WHILE_STATEMENT_ERROR) ||
128
+ error_messages.has(COMPONENT_DO_WHILE_STATEMENT_ERROR)
129
+ ) {
130
+ advice.push({
131
+ kind: 'unsupported-component-loop',
132
+ severity: 'error',
133
+ title: 'Use for...of for component list rendering',
134
+ message:
135
+ 'Component template scope supports for...of loops for rendering lists. Move regular for, for...in, while, and do...while loops into a nested function, event handler, effect, or helper.',
136
+ documentation: ['tsrx://docs/control-flow.md'],
137
+ });
138
+ }
139
+
101
140
  if (advice.length === 0 && compileResult.ok) {
102
141
  advice.push({
103
142
  kind: 'compile-clean',
@@ -43,7 +43,7 @@ export const documentation_sections = [
43
43
  use_cases:
44
44
  'if else, for loops, switch, try catch, conditional rendering, lists, guard returns',
45
45
  content:
46
- '# Control Flow\n\nStandard JavaScript control flow can contain template statements inside component bodies and nested element children.\n\n```tsx\ncomponent List({ items }: { items: string[] }) {\n if (items.length === 0) {\n <p>"No items"</p>\n return;\n }\n\n <ul>\n for (const item of items) {\n <li>{item}</li>\n }\n </ul>\n}\n```\n\nA bare `return;` exits the current render path. A return with a value is invalid inside a TSRX component body.\n\nSource: website-tsrx/src/pages/features.tsrx#if',
46
+ '# Control Flow\n\nStandard JavaScript control flow can contain template statements inside component bodies and nested element children.\n\n```tsx\ncomponent List({ items }: { items: string[] }) {\n if (items.length === 0) {\n <p>"No items"</p>\n return;\n }\n\n <ul>\n for (const item of items; index i; key item) {\n if (!item) continue;\n <li>{item}</li>\n }\n </ul>\n}\n```\n\nA bare `return;` exits the current render path. A return with a value is invalid inside a TSRX component body.\n\nInside a component `for...of` loop, `continue` skips the current rendered iteration and is the only supported top-level loop control-flow statement. Top-level `return` and `break` are invalid inside component `for...of` loops; use `continue` for item skips, `return;` for non-loop guard exits, and `break` only for `switch` cases.\n\nComponent rendering supports `for...of` list loops. Regular `for`, `for...in`, `while`, and `do...while` loops are not supported in component template scope. Move imperative loops into a nested function, event handler, effect, or helper where normal JavaScript control flow rules apply.\n\nSource: website-tsrx/src/pages/features.tsrx#for',
47
47
  },
48
48
  {
49
49
  slug: 'lazy-destructuring',
package/src/server.js CHANGED
@@ -307,6 +307,7 @@ ${project_context_step}
307
307
  3. For syntax uncertainty, use \`list-sections\`, \`get-documentation\`, or read \`tsrx://docs/{slug}.md\`.
308
308
  4. Keep core TSRX advice target-neutral: component declarations, statement templates, control flow, TSX expression values, lazy destructuring, style identifiers, and submodule declarations.
309
309
  5. Use \`tsrx://targets/{target}.md\` as the handoff point for target-specific responsibilities.
310
+ 5a. In component template scope, render lists with \`for...of\`; use \`continue\` to skip an item; do not use top-level \`return\` or \`break\` inside the loop, and do not use regular \`for\`, \`for...in\`, \`while\`, or \`do...while\` loops there.
310
311
  ${file_validation_step}
311
312
  ${compile_step}
312
313
  ${authoring_step}