Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 50 additions & 44 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,55 @@
# AGENTS.md

### 1. Creating a New App
- Use the command:
```sh
pixlet create apps/<appname>
This repository contains Pixlet apps in the `apps/` directory.

## 1. Creating a New App
Scaffold a new app: `pixlet create apps/<appname>`

## 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/<appname>/<app_name>.star`.

## 4. Previewing & Rendering
Generate a preview image before publishing:
```sh
pixlet render --webp-level=9 apps/<appname>/<app_name>.star
# For 2x support preview:
pixlet render --2x --webp-level=9 apps/<appname>/<app_name>.star
Comment on lines +19 to +21
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The preview rendering commands use long-form flags (--webp-level=9, --2x) which differ from the short-form flags (-z 9, -2) recommended in the repository style guide. For consistency, update the commands to use the short-form flags.

Suggested change
pixlet render --webp-level=9 apps/<appname>/<app_name>.star
# For 2x support preview:
pixlet render --2x --webp-level=9 apps/<appname>/<app_name>.star
pixlet render -z 9 apps/<appname>/<app_name>.star
# For 2x support preview:
pixlet render -z 9 -2 apps/<appname>/<app_name>.star
References
  1. The repository style guide recommends specific flags for generating preview images: pixlet render -z 9 and pixlet render -z 9 -2. (link)

```
Screenshot paths will be `apps/<appname>/<appname>.webp` and `apps/<appname>/<appname>@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/<appname>/images/example.png`:
```starlark
load("images/example.png", EXAMPLE_IMAGE = "file")
```
This will scaffold a new app directly in the `apps` folder. Replace `<appname>` 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/<appname>/<app_name>.star
```
This helps reviewers and users see what your app looks like. Replace `<appname>` and `<app_name>` 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/<appname>/<app_name>.star
## 6. Configurations
Manage complex settings with a config file/schema. Pass configuration arguments via the CLI during development:
```sh
pixlet render apps/<appname>/<app_name>.star key=value
```
Comment on lines +34 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The 'Configurations' section is missing key guidelines from the repository style guide. Please expand this section to include the following points:

  • For sensitive values like API keys or passwords, schema definitions should use secret = True.
  • For boolean options (from schema.Toggle), values should be retrieved using config.bool("key") instead of config.get("key").
References
  1. The repository style guide specifies that secret configuration options should use secret = True. (link)
  2. The repository style guide specifies that boolean options should be retrieved with config.bool. (link)


## 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`.
```
Loading