--- name: vitruvio-criar-biblioteca description: > Use when the user wants to create a new static file library in a Vitruvio repository. Triggers: "create library", "new library", "criar biblioteca", "nova biblioteca", "add library", "static files", "JS library", "CSS library", or any request to scaffold a libraries// directory and register it in vitruvio.json. --- # Create Vitruvio Library > All messages shown to the user must be written in Portuguese. You are creating a new static file library inside a Vitruvio repository. Libraries are static file bundles (JS, CSS, images) served by the platform as HTTP resources. They are different from scripts — scripts run server-side on Rhino; libraries are served to clients as-is. Follow these steps in order. ## Step 1 — Confirm you are inside a Vitruvio repo ```bash ls vitruvio.json 2>/dev/null && echo "OK" || echo "NOT_A_VITRUVIO_REPO" ``` If `NOT_A_VITRUVIO_REPO`, stop and tell the user to `cd` into the correct repo. ## Step 2 — Collect library details Ask the user (in a single message, only ask what is missing from their original request): - **Key (sigla)** — kebab-case unique identifier. Used to reference the library and build its endpoint URL. Stable — changing it breaks any code that references it. - **Name** — human-readable label shown in the Vitruvio UI. - **Description** — one sentence about what this library provides (optional). - **Auth mode** — one of: - `PUBLIC` — accessible without authentication (default; use for most JS/CSS bundles) - `STATIC_TOKEN` — token required; use when files must not be publicly accessible - **Mobile enabled?** — `true` if mobile clients need to load these files; `false` otherwise (default: `false`). - **What files will this library contain?** — brief description so you can create a useful starting placeholder (e.g. "custom JS utilities for panels", "CSS theme overrides", "image assets"). ## Step 3 — Scaffold and create files ```bash vitruvio new library --name "" ``` This creates the `libraries//` directory and registers it in `vitruvio.json` with `authMode: "PUBLIC"` and `mobileEnabled: false`. Then create a placeholder file appropriate to what the user described: - For a **JS library**: `libraries//.js` - For a **CSS library**: `libraries//.css` - For an **image/mixed library**: `libraries//README.md` explaining what belongs here ### JS placeholder ```javascript /** * Library: * Key: * Description: * * These files are served as static HTTP resources. * Access URL: vBibliotecaService.buildEndpointUrl('', '.js') */ // Add your client-side JavaScript here. // This runs in the browser — full ES6+ is supported (unlike server-side Rhino scripts). ``` ### CSS placeholder ```css /** * Library: * Key: * Description: * * These files are served as static HTTP resources. * Access URL: vBibliotecaService.buildEndpointUrl('', '.css') */ /* Add your styles here */ ``` ## Step 4 — Update vitruvio.json entry `vitruvio new` already added the library entry. The full entry shape is: ```json { "key": "", "name": "", "description": "", "type": "LOCAL", "authMode": "PUBLIC", "authToken": null, "mobileEnabled": false, "files": "libraries//" } ``` Update only what differs: set `"authMode"` if not `"PUBLIC"`; set `"mobileEnabled": true` if mobile clients need this library; add `"description"` if provided. ## Step 5 — Report Tell the user: - Directory created: `libraries//` - Placeholder file(s) created - Registered in `vitruvio.json` with key `` - How to get the serving URL at runtime: ```javascript var url = vBibliotecaService.buildEndpointUrl('', 'filename.js'); ``` - Remind them: files in this directory are served as-is — client-side JS here can use modern ES6+, unlike server-side Rhino scripts