@stellisoft/stellify-mcp 0.1.30 → 0.1.32

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/dist/index.js CHANGED
@@ -89,7 +89,11 @@ const tools = [
89
89
  For PHP: type='class', 'model', 'controller', or 'middleware'.
90
90
  For Vue: type='js', extension='vue'. Auto-creates app.js and template route.
91
91
 
92
- Pass 'includes' array for framework class dependencies (auto-resolved to UUIDs). Use 'models' array in save_file for project models.`,
92
+ Pass 'includes' array for framework class dependencies (auto-resolved to UUIDs). Use 'models' array in save_file for project models.
93
+
94
+ **IMPORTANT - Check appJs response for Vue components:**
95
+ - If \`appJs.action_required === "create_or_select_mount_file"\`: No mount file exists. You MUST ask the user if they want to create a new app.js mount file before proceeding.
96
+ - If \`appJs.action_required === "register_component"\`: Mount file exists but component isn't registered. Call save_file on the mount file to add the component UUID to its includes array.`,
93
97
  inputSchema: {
94
98
  type: 'object',
95
99
  properties: {
@@ -164,12 +168,12 @@ Pass 'includes' array for framework class dependencies (auto-resolved to UUIDs).
164
168
  },
165
169
  parameters: {
166
170
  type: 'array',
167
- description: 'Method parameters (created as clauses)',
171
+ description: 'Method parameters (created as clauses). Include datatype for TypeScript annotations.',
168
172
  items: {
169
173
  type: 'object',
170
174
  properties: {
171
175
  name: { type: 'string', description: 'Parameter name' },
172
- datatype: { type: 'string', description: 'Data type' },
176
+ datatype: { type: 'string', description: 'TypeScript type (e.g., "number", "string", "MouseEvent", "User"). Outputs as: (param: Type)' },
173
177
  type: { type: 'string', description: 'Clause type (default: variable)' },
174
178
  value: { type: 'string', description: 'Default value' },
175
179
  },
@@ -210,6 +214,8 @@ Pass 'includes' array for framework class dependencies (auto-resolved to UUIDs).
210
214
 
211
215
  **Nested code is handled correctly.** The parser tracks brace/bracket/paren depth and only splits on semicolons at the top level. Arrow functions with block bodies, computed properties, and other nested constructs work as single statements.
212
216
 
217
+ Pass 'types' to specify TypeScript types for variables declared in the code.
218
+
213
219
  IMPORTANT: This APPENDS to existing method statements. To REPLACE a method's code entirely:
214
220
  1. Create a NEW method with create_method (with body parameter)
215
221
  2. Update the file's 'data' array to include new method UUID (remove old one)
@@ -230,6 +236,11 @@ IMPORTANT: This APPENDS to existing method statements. To REPLACE a method's cod
230
236
  type: 'string',
231
237
  description: 'PHP code for the method body (just the statements, no function declaration). Example: "return $a + $b;"',
232
238
  },
239
+ types: {
240
+ type: 'object',
241
+ description: 'Map of variable names to their base TypeScript types (e.g., { "result": "Todo" }). The assembler infers full types from code structure.',
242
+ additionalProperties: { type: 'string' },
243
+ },
233
244
  },
234
245
  required: ['file', 'method', 'code'],
235
246
  },
@@ -515,7 +526,7 @@ Use this to look up a route you created or to find existing routes in the projec
515
526
  name: 'delete_route',
516
527
  description: `Delete a route/page from the project by UUID. This permanently removes the route.
517
528
 
518
- WARNING: This is destructive and cannot be undone. Any elements attached to this route will become orphaned.`,
529
+ WARNING: This is destructive and cannot be undone. Any elements attached to this route will be deleted also.`,
519
530
  inputSchema: {
520
531
  type: 'object',
521
532
  properties: {
@@ -563,8 +574,7 @@ Use the returned UUID with html_to_elements (page parameter) or get_route for fu
563
574
  enum: [
564
575
  's-wrapper', 's-input', 's-form', 's-svg', 's-shape', 's-media', 's-iframe',
565
576
  's-loop', 's-transition', 's-freestyle', 's-motion',
566
- 's-directive',
567
- 's-chart', 's-table', 's-combobox', 's-accordion', 's-calendar', 's-contiguous'
577
+ 's-directive'
568
578
  ],
569
579
  description: 'Element type - must be one of the valid Stellify element types',
570
580
  },
@@ -741,7 +751,12 @@ Prefer SVG icons over emoji (encoding issues).`,
741
751
  },
742
752
  {
743
753
  name: 'create_statement_with_code',
744
- description: `Create a statement with code in one call. Preferred over two-step create_statement + add_statement_code.`,
754
+ description: `Create a statement with code in one call. Preferred over two-step create_statement + add_statement_code.
755
+
756
+ Pass 'types' to specify TypeScript types for variables. The assembler infers the full type from code structure:
757
+ - \`ref([])\` + type "Todo" → outputs \`const todos: Ref<Todo[]>\`
758
+ - \`ref(0)\` + type "number" → outputs \`const count: Ref<number>\`
759
+ - \`reactive({})\` + type "State" → outputs \`const state: State\``,
745
760
  inputSchema: {
746
761
  type: 'object',
747
762
  properties: {
@@ -757,6 +772,11 @@ Prefer SVG icons over emoji (encoding issues).`,
757
772
  type: 'string',
758
773
  description: 'UUID of the method to add the statement to (optional, for method body statements)',
759
774
  },
775
+ types: {
776
+ type: 'object',
777
+ description: 'Map of variable names to their base TypeScript types (e.g., { "todos": "Todo", "count": "number" }). The assembler infers Ref<>, arrays, etc. from the code structure.',
778
+ additionalProperties: { type: 'string' },
779
+ },
760
780
  },
761
781
  required: ['file', 'code'],
762
782
  },
@@ -874,13 +894,18 @@ Required: uuid, name, type. For significant changes, include context fields: sum
874
894
  includes: {
875
895
  type: 'array',
876
896
  items: { type: 'string' },
877
- description: 'Framework class UUIDs or namespaces. Use models array for project models.',
897
+ description: 'File UUIDs for local imports (e.g., Vue components imported by app.js) AND framework class UUIDs/namespaces. CRITICAL: For JS mount files, add imported Vue component UUIDs here or they won\'t be bundled. Use models array for project models.',
878
898
  },
879
899
  models: {
880
900
  type: 'array',
881
901
  items: { type: 'string' },
882
902
  description: 'Project model UUIDs (auto-namespaced). Do NOT duplicate in includes.',
883
903
  },
904
+ frameworkImports: {
905
+ type: 'array',
906
+ items: { type: 'string' },
907
+ description: 'Stellify framework modules to import (e.g., ["Http", "Form", "Collection"]). Auto-generates: import { Http, Form, Collection } from \'stellify-framework\';',
908
+ },
884
909
  summary: {
885
910
  type: 'string',
886
911
  description: 'Context: What this file does and why it exists',
@@ -1348,141 +1373,59 @@ Use this to discover what patterns are available before building UI components.`
1348
1373
  properties: {},
1349
1374
  },
1350
1375
  },
1376
+ {
1377
+ name: 'get_assembled_code',
1378
+ description: `Get the assembled source code for a file. Returns the actual Vue SFC or PHP class as it would be rendered.
1379
+
1380
+ Use this after save_file to verify the component was built correctly:
1381
+ - Check that all methods are included
1382
+ - Verify @click handlers are wired to methods
1383
+ - Confirm imports and reactive state are present
1384
+ - Spot any missing pieces before deployment`,
1385
+ inputSchema: {
1386
+ type: 'object',
1387
+ properties: {
1388
+ uuid: {
1389
+ type: 'string',
1390
+ description: 'UUID of the file to get assembled code for',
1391
+ },
1392
+ },
1393
+ required: ['uuid'],
1394
+ },
1395
+ },
1351
1396
  ];
1352
1397
  // Server instructions for tool discovery (used by MCP Tool Search)
1353
- const SERVER_INSTRUCTIONS = `Stellify is a coding platform where you code alongside AI on a codebase maintained and curated by AI. Build Laravel, stellify-framework, and Vue.js applications.
1354
-
1355
- Use Stellify tools when:
1356
- - Building PHP controllers, models, middleware, or classes
1357
- - Creating Vue.js components with reactive state and UI
1358
- - Managing UI elements (HTML stored as structured JSON)
1359
- - Working with a Stellify project (user will mention "Stellify" or provide project UUID)
1360
-
1361
- Key concepts:
1362
- - Code is stored as structured JSON, enabling surgical AI edits at the statement level
1363
- - Files contain methods and statements (code outside methods)
1364
- - Vue components link to UI elements via the 'template' field
1365
- - Event handlers (click, submit) wire UI elements to methods by UUID
1366
-
1367
- ## General Workflow (all file types)
1368
-
1369
- 1. create_file → empty shell, returns file UUID
1370
- 2. create_method → signature only, returns method UUID
1371
- 3. add_method_body → implementation code
1372
- 4. create_statement + add_statement_code → for imports, variables, refs
1373
- 5. save_file → finalize with template/data/statements arrays
1398
+ const SERVER_INSTRUCTIONS = `Stellify is a coding platform where code is stored as structured JSON in a database, enabling surgical AI edits. Build Laravel (PHP) applications with StellifyJS (a front-end Laravel extension framework that has adaptors for reactive frameworks such as Vue, React and library wrappers for chart.js etc.).
1374
1399
 
1375
- ## Vue Component Workflow
1400
+ ## Architecture
1376
1401
 
1377
- 1. get_project find 'js' directory UUID (or create it)
1378
- 2. create_file → type='js', extension='vue' for the component
1379
- - **Auto-creates app.js** and **template route** (check response for appJs and templateRoute fields)
1380
- 3. Create statements for imports using **create_statement_with_code** (ONE call each):
1381
- - create_statement_with_code(file, "import { ref, onMounted } from 'vue';")
1382
- - create_statement_with_code(file, "import { Http } from 'stellify-framework';")
1383
- 4. Create statements for reactive data: create_statement_with_code(file, "const notes = ref([]);")
1384
- 5. **create_method with body** (async auto-detected from \`await\`). Example:
1385
- \`\`\`
1386
- create_method({
1387
- file: fileUuid,
1388
- name: "fetchNotes",
1389
- body: "const response = await Http.get('/api/notes');\\nnotes.value = response.data || [];"
1390
- })
1391
- \`\`\`
1392
- 6. Create statement for onMounted: create_statement_with_code(file, "onMounted(fetchData);")
1393
- 7. **Create UI interaction methods** for any button that changes state:
1394
- \`\`\`
1395
- create_method({ file: fileUuid, name: "openModal", body: "showModal.value = true;" })
1396
- create_method({ file: fileUuid, name: "closeModal", body: "showModal.value = false;" })
1397
- \`\`\`
1398
- 8. html_to_elements with @click handlers auto-wired:
1399
- \`\`\`
1400
- html_to_elements({
1401
- elements: '<button @click="openModal">Open</button>',
1402
- page: templateRoute.uuid,
1403
- file: fileUuid // Auto-wires @click="openModal" to the method UUID
1404
- })
1405
- \`\`\`
1406
- 9. save_file with: extension='vue', template=[elementUuid], data=[methodUuids], statements=[importUuids, refUuids, onMountedUuid]
1407
- 11. Create web route for the display page (e.g., "/notes")
1408
- 12. Add \`<div id="app"></div>\` to the display page: html_to_elements(page=routeUuid, elements='<div id="app"></div>')
1402
+ - Files are stored as json. The json has a data key that references its methods (using uuids), and each method has a data key that references statements, and each statement has a data key that references clauses.
1409
1403
 
1410
- ## Fetching Paginated Data
1404
+ ## Example Workflow
1405
+ 1. Research: Call the get_project tool to understand the current project structure, existing files, and directories. This helps avoid duplicates and informs where to create new files.
1406
+ 2. Plan: If the user is in plan mode, create a plan and prompt the user to accept before starting.
1407
+ 3. Execute: Map out the solution in full before calling any tools. Use the tools to verify assumptions and gather information about the project as needed.
1408
+ 4. Create: create_file, create_method (with body), create_statement_with_code
1409
+ 5. Wire: html_to_elements (pass file UUID to auto-wire @click handlers)
1410
+ 6. Finalize: save_file with template/data/statements arrays
1411
+ 7. Verify: Call \`get_assembled_code\` to see the actual rendered output and fix any issues
1412
+ 8. Test: Use run_code to execute methods and verify behavior. For UI components, use broadcast_element_command to demonstrate functionality in real-time.
1411
1413
 
1412
- Use \`Http.items()\` for paginated endpoints - it auto-extracts the array from Laravel responses:
1414
+ ## Component Response Handling (IMPORTANT)
1413
1415
 
1414
- \`\`\`javascript
1415
- // Recommended - auto-extracts .data from paginated response
1416
- notes.value = await Http.items('/api/notes');
1416
+ When creating Vue/ React etc. components, ALWAYS check the \`appJs\` field in the response:
1417
1417
 
1418
- // Alternative - manual extraction
1419
- const response = await Http.get('/api/notes');
1420
- notes.value = response.data || [];
1421
- \`\`\`
1418
+ 1. **appJs.action_required === "create_or_select_mount_file"**: No mount file exists. You MUST immediately ask the user: "Would you like me to create an app.js mount file for this component?" Do NOT proceed without user confirmation.
1422
1419
 
1423
- ## Editing Existing Code
1420
+ 2. **appJs.action_required === "register_component"**: Mount file exists but component isn't registered. Call save_file on the mount file (appJs.uuid) to add the component UUID to its includes array.
1424
1421
 
1425
- - **Edit at the right level:** To change code, edit the statement or clause - never delete an entire method just to change a line.
1426
-
1427
- ## Common Pitfalls
1428
-
1429
- - **@click auto-wiring:** Pass the file UUID to html_to_elements to auto-wire @click handlers. Methods must be created BEFORE calling html_to_elements.
1430
- - **Stellify imports:** Use "stellify-framework" package (NOT @stellify/core)
1431
- CORRECT: import { Http, Collection, Form } from 'stellify-framework';
1432
- WRONG: import { Http } from '@stellify/core';
1433
- - v-model requires ref(), NOT Form class: const formData = ref({title: ''})
1434
- - Collection is iterable and works directly with v-for (no .toArray() needed)
1435
- - add_method_body APPENDS, doesn't replace - create new method to replace
1436
- - 'data' array = method UUIDs, 'statements' array = import/variable UUIDs
1437
- - For buttons in forms, set inputType: "button" to prevent auto-submit
1438
- - **Async methods:** Auto-detected when body contains \`await\`. Response includes \`is_async: true\` if detected.
1439
- - **onMounted:** Use direct method reference: "onMounted(fetchNotes);"
1440
- The assembler automatically outputs lifecycle hooks after method definitions.
1441
-
1442
- ## Nullable Refs: Use explicit v-if, NOT v-else
1443
-
1444
- When using nullable refs (e.g., \`const editingItem = ref(null)\`) with v-model, use explicit v-if guards:
1445
- - WRONG: \`<template v-else><input v-model="editingItem.title"/></template>\`
1446
- - CORRECT: \`<template v-if="editingItem && editingItem.id === item.id"><input v-model="editingItem.title"/></template>\`
1447
-
1448
- Vue evaluates v-model bindings before v-else is applied, causing "Cannot read properties of null" errors.
1449
-
1450
- ## Stack and Business Logic
1451
-
1452
- **Default stack:** Laravel (PHP), stellify-framework (JS), and Vue.js. Available capabilities (optional packages/libraries) are returned by \`get_project\`. Use \`get_stellify_framework_api\` for the stellify-framework API reference.
1453
-
1454
- **All business logic** (controllers, models, middleware, etc.) goes in the tenant DB via MCP tools. If a required capability is not available, use \`request_capability\` to log it.
1455
-
1456
- **Prefer Laravel methods:** When Laravel provides a helper (Str, Arr, Hash, Number, Collection), use it instead of native PHP functions.
1457
-
1458
- ## JavaScript Entry File (app.js) - Auto-Generated
1459
-
1460
- When you create a Vue component, **app.js is automatically created/updated** with component registration. The create_file response will confirm this with an \`appJs\` field.
1461
-
1462
- **Page mount point:** Each page using Vue needs \`<div id="app"></div>\`:
1463
- - html_to_elements(page=routeUuid, elements='<div id="app"></div>')
1464
-
1465
- ## Context Documentation
1466
-
1467
- Add context fields to significant changes (methods, files, routes, elements) to help future AI sessions understand the application.
1468
-
1469
- **When to add context:** New features, significant changes, multi-entity implementations.
1470
- **Skip context for:** Trivial changes, temporary code, unchanged context.
1471
-
1472
- **Context fields** (flat in data object, used with save_method, save_file, save_route, update_element):
1473
- - \`summary\`: What this does
1474
- - \`rationale\`: Why it was built this way
1475
- - \`references\`: [{uuid, type, relationship, note}] - links to related entities
1476
- - \`decisions\`: Array of design decisions
1477
-
1478
- Reference types: model, route, method, file, setting, element
1479
- Relationships: uses, creates, updates, calls, contains, triggers
1480
-
1481
- Context is preserved across updates - the backend merges fields.`;
1422
+ 3. **No action_required**: Component is already registered in a mount file. Proceed normally.
1423
+ `;
1424
+ // Legacy detailed instructions preserved as comments for reference if needed
1482
1425
  // Create MCP server
1483
1426
  const server = new Server({
1484
1427
  name: 'stellify-mcp',
1485
- version: '0.1.30',
1428
+ version: '0.1.32',
1486
1429
  }, {
1487
1430
  capabilities: {
1488
1431
  tools: {},
@@ -2349,6 +2292,20 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
2349
2292
  ],
2350
2293
  };
2351
2294
  }
2295
+ case 'get_assembled_code': {
2296
+ const result = await stellify.getAssembledCode(args.uuid);
2297
+ // Return just the code content for easy reading
2298
+ const code = result.files?.[0]?.content || result.data?.code || 'No code available';
2299
+ const fileName = result.files?.[0]?.path || result.entryPoint || 'unknown';
2300
+ return {
2301
+ content: [
2302
+ {
2303
+ type: 'text',
2304
+ text: `// ${fileName}\n\n${code}`,
2305
+ },
2306
+ ],
2307
+ };
2308
+ }
2352
2309
  default:
2353
2310
  throw new Error(`Unknown tool: ${name}`);
2354
2311
  }
@@ -32,6 +32,7 @@ export interface AddMethodBodyParams {
32
32
  file: string;
33
33
  method: string;
34
34
  code: string;
35
+ types?: Record<string, string>;
35
36
  }
36
37
  export interface SearchMethodsParams {
37
38
  name?: string;
@@ -93,6 +94,7 @@ export declare class StellifyClient {
93
94
  file: string;
94
95
  code: string;
95
96
  method?: string;
97
+ types?: Record<string, string>;
96
98
  }): Promise<any>;
97
99
  getStatement(statement: string): Promise<any>;
98
100
  deleteStatement(file: string, method: string, statement: string): Promise<any>;
@@ -195,4 +197,5 @@ export declare class StellifyClient {
195
197
  example?: string;
196
198
  }): Promise<any>;
197
199
  listPatterns(): Promise<any>;
200
+ getAssembledCode(uuid: string): Promise<any>;
198
201
  }
@@ -238,4 +238,9 @@ export class StellifyClient {
238
238
  const response = await this.client.get('/pattern');
239
239
  return response.data;
240
240
  }
241
+ // Code Assembly - get rendered source code for a file
242
+ async getAssembledCode(uuid) {
243
+ const response = await this.client.get(`/file/${uuid}/source`);
244
+ return response.data;
245
+ }
241
246
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stellisoft/stellify-mcp",
3
- "version": "0.1.30",
3
+ "version": "0.1.32",
4
4
  "mcpName": "io.github.MattStellisoft/stellify-mcp",
5
5
  "description": "MCP server for Stellify - AI-native code generation platform",
6
6
  "main": "dist/index.js",
package/server.json CHANGED
@@ -6,12 +6,12 @@
6
6
  "url": "https://github.com/Stellify-Software-Ltd/stellify-mcp",
7
7
  "source": "github"
8
8
  },
9
- "version": "0.1.30",
9
+ "version": "0.1.32",
10
10
  "packages": [
11
11
  {
12
12
  "registryType": "npm",
13
13
  "identifier": "@stellisoft/stellify-mcp",
14
- "version": "0.1.30",
14
+ "version": "0.1.32",
15
15
  "transport": {
16
16
  "type": "stdio"
17
17
  },