--- name: localai-apps description: Use when the user asks for an app, a tool, a tracker, a dashboard, a form, a game, a calculator, a planner or anything interactive to use inside LocalAI. Build it as a Page. --- # Apps in LocalAI are Pages Do the work with files, but talk to the user in plain words: say what changed ("I saved your shortcuts", "I added a Reading list page", "Home now shows your open tasks"), not file names, folders, formats or JSON. Name a file only if the user named it or asks where something is, or when you give them a file as a result (a document they asked for). LocalAI has its own app format: a Page. It is one HTML file in the user's home that LocalAI shows under **Pages** in the sidebar. The user can pin it and (with a shared folder) share it. Unless the user names a language or a runtime, "make me an app" means a Page. Do not start a Python, Node or desktop program for it. ## Decide | The user wants | Do | |---|---| | An interactive thing to use here: tracker, to-do list, dashboard, form, game, calculator, planner, converter, timer | A Page (this skill) | | The same, refreshed on a schedule or when a file arrives | A Page plus a trigger: load the `localai-workspace` skill, section "Updates on a schedule" | | A Home widget (a list or a number) | The `localai-workspace` skill, not a Page | | A page that should also show on Home | A Page with a `widget` block and a compact mode (section "On Home"), then the `localai-workspace` skill to add the tile | | A real program: a script, a service, a CLI, something to install or deploy | Write that program as asked. First check the `Commands:` line of this chat: if nothing here runs commands, say so and give the files to run elsewhere | | Data from the web | A Page cannot reach the network. Get the data with your web tools and write it to a file next to the page; the page reads it with `fetch('data.json')` | If the user asked explicitly for Python, Node or another language, do that and skip this skill. A script, test data or a draft that you make on the way goes in the chat's work folder, `"$WORK"` in the shell (the file tools take the path the note names); the page folder holds only the page and its data. ## What a Page is - Folder `/workspace/home/pages//`. The name is lowercase letters, digits and dashes, starting with a letter or digit, at most 64 characters (`reading-tracker`). - `index.html` is required, at most 1 MiB. One file with the markup, style and script is simplest. Split into `app.js`, `style.css` or ES modules next to it only when it grows past what you can keep right; LocalAI puts those files into the page before it runs. - `page.json` is optional: `{"title": "Reading tracker", "icon": "book", "description": "Books to read, with a rating"}`. The icon is one plain lowercase word. Always write it: the title is what the user sees in the list. - Data files sit next to `index.html`, any name, any subfolder (`books.json`). Text only, at most 1 MiB each. Keep data in JSON, so you can read and change it in a chat later. ## The sandbox The page runs in a frame with no network and no access to LocalAI or other files. - Files next to the page work with relative URLs: `fetch('data.json')` and `XMLHttpRequest` (GET only, text and JSON; a missing file is a 404 response), ` ``` ## Example: reading tracker `/workspace/home/pages/reading-tracker/page.json`: ```json {"title": "Reading tracker", "icon": "book", "description": "Books to read and finished, saved in books.json"} ``` `/workspace/home/pages/reading-tracker/index.html`: ```html Reading tracker

``` Seed `books.json` only if the user gave you data: `{"books": [{"id": "b1", "title": "...", "done": false}]}`. ## After you write it Tell the user in one or two lines: the Page is called "" and is under **Pages** in the sidebar, that they can pin it there, and what it cannot do. To change it later, they can open it and use **Ask the assistant to change this**. Call `open_page` with the name to show the page in the dock beside this chat. It asks the user nothing and works only for their own pages. Say what a Page cannot do when it matters for the request: it has no server process, no packages and no network. For work that must happen by itself, offer a trigger (never say one is on until the user confirms its card). For outside data, offer to fetch it with your web tools into a data file. If the idea needs a real program and commands run in this chat, offer the Sandbox. Pages need the `pages` feature. If writing under `pages/` is refused or the Pages screen is missing, say so and keep the files where they are.