Project Scaffolding Server

Panoramica

Il server project-scaffolding automatizza la creazione di nuovi progetti e componenti a partire da template predefiniti. Risolve il problema della configurazione iniziale: ogni nuovo progetto richiede la creazione manuale di package.json, tsconfig.json, struttura delle cartelle e file boilerplate. Questo processo e' ripetitivo e soggetto a errori.

Con questo server, un singolo comando genera un progetto completo, coerente con le best practice del team, pronto per iniziare lo sviluppo.

+------------------------------------------------------------+
|              project-scaffolding server                    |
|                                                            |
|  +-------------------------------------------------------+ |
|  |                  Tool Layer                           | |
|  |                                                       | |
|  |  list-templates  scaffold-project  scaffold-component | |
|  +-------------------------------------------------------+ |
|                         |                                  |
|                         v                                  |
|  +-------------------------------------------------------+ |
|  |              services/templates.ts                    | |
|  |                                                       | |
|  |  TEMPLATES = {                                        | |
|  |    'node-typescript'  -> Node.js + TypeScript + ESM   | |
|  |    'express-api'      -> Express REST API + TS        | |
|  |    'react-app'        -> React + Vite + TypeScript    | |
|  |    'mcp-server'       -> MCP Server + TypeScript      | |
|  |  }                                                    | |
|  |                                                       | |
|  |  substitutePlaceholders(content, values)              | |
|  +-------------------------------------------------------+ |
|                         |                                  |
|                         v                                  |
|                Filesystem (mkdir + writeFile)              |
+------------------------------------------------------------+

Caratteristiche principali

  • 4 template built-in: coprono i casi d'uso piu' comuni
  • Sostituzione placeholder: {{projectName}}, {{author}}, {{description}}, {{license}}
  • Generazione componenti singoli: component, service, controller, model
  • Supporto TypeScript e JavaScript: scelta del linguaggio per i componenti
  • Nessun evento: server puramente generativo, nessuna integrazione Event Bus

Tabella dei Tool

[object Object],[object Object],[object Object] undefined

Architettura

Service Layer: templates.ts

Il cuore del server e' il file services/templates.ts che contiene:

  • L'interfaccia TemplateDefinition: { name, description, files: Record<string, string> }
  • Le definizioni dei 4 template come costanti
  • Il registro TEMPLATES: Record<string, TemplateDefinition>
  • La funzione substitutePlaceholders(content, values) per la sostituzione dei placeholder
  TemplateDefinition
  +-------------------+
  | name: string      |
  | description: str  |
  | files: {          |
  |   "path": content |     substitutePlaceholders()
  |   "path": content | --> {{projectName}} -> "my-app"
  |   ...             |     {{author}}      -> "Mario Rossi"
  | }                 |     {{description}} -> "..."
  +-------------------+     {{license}}     -> "MIT"

Template disponibili

[object Object],[object Object],[object Object] undefined

Tipi di componente generabili

[object Object],[object Object],[object Object] undefined

Flusso di scaffold-project

  1. Validazione template
         |
         v
  2. Preparazione valori placeholder
     { projectName, author, description, license }
         |
         v
  3. Per ogni file nel template:
     a. Calcolo percorso: outputDir/projectName/relativePath
     b. Creazione directory (mkdir recursive)
     c. Sostituzione placeholder nel contenuto
     d. Scrittura file su disco
         |
         v
  4. Restituzione lista file creati

Integrazione Event Bus

Questo server non pubblica ne' sottoscrive eventi. E' un server puramente generativo che opera su richiesta esplicita dell'utente.


Interazioni con altri server

+----------------------+                          +---------------------+
| project-scaffolding  |  genera progetto    ---> | dependency-manager  |
|                      |  analizzabile            |  (check-vulnerab.)  |
+----------------------+                          +---------------------+
         |
         |  genera codice    ------>  +---------------------+
         +------------------------->  | code-review         |
                                      | (analyze/suggest)   |
                                      +---------------------+
         |
         |  genera struttura ------>  +---------------------+
         +------------------------->  | codebase-knowledge  |
                                      | (architecture-map)  |
                                      +---------------------+
[object Object],[object Object],[object Object] undefined

Esempi di utilizzo

Elenco template

Richiesta:

{
  "tool": "list-templates",
  "arguments": {}
}

Risposta:

[
  {
    "name": "node-typescript",
    "description": "Node.js project with TypeScript, ESM, and Vitest",
    "files": ["package.json", "tsconfig.json", "src/index.ts", ".gitignore", "README.md"]
  },
  {
    "name": "express-api",
    "description": "Express REST API with TypeScript, routing, and middleware",
    "files": ["package.json", "tsconfig.json", "src/index.ts", "src/app.ts", "..."]
  },
  {
    "name": "react-app",
    "description": "React application with TypeScript and Vite",
    "files": ["package.json", "tsconfig.json", "vite.config.ts", "index.html", "..."]
  },
  {
    "name": "mcp-server",
    "description": "Model Context Protocol server with TypeScript",
    "files": ["package.json", "tsconfig.json", "src/index.ts", "src/tools.ts", "..."]
  }
]

Generazione progetto

Richiesta:

{
  "tool": "scaffold-project",
  "arguments": {
    "template": "express-api",
    "projectName": "user-service",
    "outputDir": "/home/user/projects",
    "options": {
      "author": "Mario Rossi",
      "description": "Microservizio gestione utenti",
      "license": "MIT"
    }
  }
}

Risposta:

{
  "template": "express-api",
  "projectName": "user-service",
  "outputDir": "/home/user/projects/user-service",
  "filesCreated": [
    "package.json", "tsconfig.json", "src/index.ts", "src/app.ts",
    "src/routes/health.ts", "src/middleware/error-handler.ts",
    ".gitignore", "README.md"
  ],
  "totalFiles": 8
}

Generazione componente

Richiesta:

{
  "tool": "scaffold-component",
  "arguments": {
    "type": "service",
    "name": "User",
    "outputDir": "/home/user/projects/user-service/src/services",
    "language": "typescript"
  }
}

Risposta:

Generated service file: /home/user/projects/user-service/src/services/User.service.ts

export class UserService {
  async findAll(): Promise<unknown[]> {
    throw new Error('Not implemented');
  }
  async findById(id: string): Promise<unknown | null> { ... }
  async create(data: unknown): Promise<unknown> { ... }
  async update(id: string, data: unknown): Promise<unknown> { ... }
  async delete(id: string): Promise<void> { ... }
}

export const userService = new UserService();

Sviluppi futuri

  • Template personalizzati: supporto per template definiti dall'utente in una directory configurabile
  • Variabili condizionali: {{#if useDatabase}} per sezioni opzionali nei template
  • Post-scaffold hooks: esecuzione automatica di npm install, git init dopo la generazione
  • Template compositi: combinazione di piu' template (es. express-api + database + docker)
  • Generazione test: scaffolding automatico di file di test per ogni componente generato
  • Integrazione Event Bus: pubblicazione evento project:created per notificare altri server
  • Validazione nomi: controllo PascalCase per componenti, kebab-case per progetti