diff --git a/AGENTS.md b/AGENTS.md index 1eda819e..797455eb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,49 +1,55 @@ # AGENTS.md -### 1. Creating a New App -- Use the command: - ```sh - pixlet create apps/ +This repository contains Pixlet apps in the `apps/` directory. + +## 1. Creating a New App +Scaffold a new app: `pixlet create apps/` + +## 2. Code Quality +- `pixlet lint`: Checks for common issues and style problems. +- `pixlet check`: Validates correctness and best practices. +- `pixlet format`: Auto-formats code for consistency. + +## 3. Local Development Server +Run a live-reloading local server for rapid iteration: `pixlet serve apps//.star`. + +## 4. Previewing & Rendering +Generate a preview image before publishing: +```sh +pixlet render --webp-level=9 apps//.star +# For 2x support preview: +pixlet render --2x --webp-level=9 apps//.star +``` +Screenshot paths will be `apps//.webp` and `apps//@2x.webp`. + +## 5. Starlark Guidelines +- **No `try/catch`**: Starlark lacks exception handling. Use conditional checks instead. +- **Skipping Rendering**: Return an empty array (`return []`) in your main function to skip rendering for the current cycle (e.g., when data is unavailable). +- **Loading Local Files:** Load local assets directly into global variables using the `file` target. For example, this loads `apps//images/example.png`: + ```starlark + load("images/example.png", EXAMPLE_IMAGE = "file") ``` - This will scaffold a new app directly in the `apps` folder. Replace `` with your desired app name. - -### 2. Ensuring Code Quality -- Use the following commands to maintain high code quality: - - `pixlet lint` — Checks your app for common issues and style problems. - - `pixlet check` — Validates your app for correctness and best practices. - - `pixlet format` — Automatically formats your code for consistency. - -### 3. Previewing Your App -- Before publishing, generate a preview image: - ```sh - pixlet render apps//.star - ``` - This helps reviewers and users see what your app looks like. Replace `` and `` as appropriate. - -### 4. Starlark Coding Guidelines -- **Do not use `try/catch`**: Starlark does not support exception handling with try/catch. Use conditional checks and error handling patterns supported by Starlark. - -### 5. Reference Documentation -- For available modules and APIs, consult: - - [Tidbyt Modules Reference](https://tidbyt.dev/docs/reference/modules) - - [Tidbyt Widgets Reference](https://tidbyt.dev/docs/reference/widgets) - -These resources provide details on supported functions, widgets, and best practices for app development. - -### 6. Running a Local Server -- Use `pixlet serve` to run a local development server and preview your app live as you make changes. This is useful for rapid iteration and testing. - ```sh - pixlet serve apps//.star +## 6. Configurations +Manage complex settings with a config file/schema. Pass configuration arguments via the CLI during development: +```sh +pixlet render apps//.star key=value +``` + +## 7. 2x Rendering Support +- 2x apps render at 128x64 instead of the standard 64x32. +- Check the `canvas` module: `canvas.size()` returns `(width, height)`; `canvas.width()`, `canvas.height()`, `canvas.is2x()`. +- **Common patterns:** + ```starlark + WIDTH, HEIGHT = canvas.size() + SCALE = 2 if canvas.is2x() else 1 ``` - You can then view your app in a browser or compatible device. - -### 7. Using a Config File for Longer Configurations -- For apps with longer or more complex configurations, use a config file to manage settings. This keeps your code clean and makes it easier to update or share configurations. - - Reference your config file in your app as needed, following Pixlet and Starlark best practices. - - -### 8. Skipping Rendering When Not Needed -- In your main app function, you can return an empty array (`return []`) to skip rendering for the current cycle. This is useful if your app should only display content when it's relevant or useful, such as hiding the screen when a device is offline or data is unavailable. - -By following these steps, you can ensure your app is well-structured, high-quality, and ready for review or publication. Happy coding! +- Multiply/divide sizes by `SCALE` (use `//` or convert to `int`; floats are rejected). +- Default 1x font is `tb-8`; default 2x font is `terminus-16`. +- **Animations:** If using `render.Marquee`, halve the delay for 2x to maintain scroll speed. If halving the delay speeds up embedded `render.Image` animations, use the image's `hold_frames` parameter to slow it back down. + +## 8. Reference Documentation +- [Modules](https://raw.githubusercontent.com/tronbyt/pixlet/refs/heads/main/docs/modules.md) | [Widgets](https://raw.githubusercontent.com/tronbyt/pixlet/refs/heads/main/docs/widgets.md) | [Animation](https://raw.githubusercontent.com/tronbyt/pixlet/refs/heads/main/docs/animation.md) | [Schema](https://raw.githubusercontent.com/tronbyt/pixlet/refs/heads/main/docs/schema/schema.md) | [Filters](https://raw.githubusercontent.com/tronbyt/pixlet/refs/heads/main/docs/filters.md) +- **Fonts**: Run `pixlet community list-fonts` or view the [Fonts Reference](https://raw.githubusercontent.com/tronbyt/pixlet/refs/heads/main/docs/fonts.md). +- **Icons**: Run `pixlet community list-icons`. +```