3.9 KiB
name, description
| name | description |
|---|---|
| vitruvio-criar-biblioteca | 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/<key>/ 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
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? —
trueif mobile clients need to load these files;falseotherwise (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
vitruvio new library <key> --name "<name>"
This creates the libraries/<key>/ 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/<key>/<key>.js - For a CSS library:
libraries/<key>/<key>.css - For an image/mixed library:
libraries/<key>/README.mdexplaining what belongs here
JS placeholder
/**
* Library: <name>
* Key: <key>
* Description: <description>
*
* These files are served as static HTTP resources.
* Access URL: vBibliotecaService.buildEndpointUrl('<key>', '<key>.js')
*/
// Add your client-side JavaScript here.
// This runs in the browser — full ES6+ is supported (unlike server-side Rhino scripts).
CSS placeholder
/**
* Library: <name>
* Key: <key>
* Description: <description>
*
* These files are served as static HTTP resources.
* Access URL: vBibliotecaService.buildEndpointUrl('<key>', '<key>.css')
*/
/* Add your styles here */
Step 4 — Update vitruvio.json entry
vitruvio new already added the library entry. The full entry shape is:
{
"key": "<key>",
"name": "<name>",
"description": "<description>",
"type": "LOCAL",
"authMode": "PUBLIC",
"authToken": null,
"mobileEnabled": false,
"files": "libraries/<key>/"
}
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/<key>/ - Placeholder file(s) created
- Registered in
vitruvio.jsonwith key<key> - How to get the serving URL at runtime:
var url = vBibliotecaService.buildEndpointUrl('<key>', '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