Files
jogos_matheus/.claude/commands/vitruvio-criar-biblioteca.md
2026-09-23 12:29:08 -03:00

101 lines
3.3 KiB
Markdown

# 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 — Create the directory and placeholder file
```bash
mkdir -p libraries/<key>
```
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.md` explaining what belongs here
### JS placeholder
```javascript
/**
* 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
```css
/**
* 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 — Register in vitruvio.json
Read `vitruvio.json`, find or create the `"libraries"` array, and add:
```json
{
"key": "<key>",
"name": "<name>",
"description": "<description>",
"type": "LOCAL",
"authMode": "<authMode>",
"authToken": null,
"mobileEnabled": <mobileEnabled>,
"files": "libraries/<key>/"
}
```
Omit `"description"` if not provided. Preserve the existing file structure and all other entries.
## Step 5 — Report
Tell the user:
- Directory created: `libraries/<key>/`
- Placeholder file(s) created
- Registered in `vitruvio.json` with key `<key>`
- How to get the serving URL at runtime:
```javascript
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