App developer guide
An ordinary PocketPi App is a small source package, not a firmware module. You write raw JavaScript and SQL, package it into one .pocketapp, install it through the product review flow, and iterate without rebuilding PocketJS or flashing the device.
The developer loop
Define the App boundary
↓
Design SQLite as durable product truth
↓
Implement actor-neutral Actions
↓
Project bounded Data into a fixed View
↓
Package → upload → review → install
↓
Exercise through Agent Tool + UI + schedule
↓
Change source → package update → preserve DataOne responsibility per file
| File | Owns | Must not own |
|---|---|---|
app.json | Identity, versions, capabilities, Tools, schedules, service policy and resources | Executable product behavior or secret values |
schema.sql | Final SQLite shape for a fresh install | Historical migration sequence or runtime transaction control |
actions.js | Validation, native service calls, normalization, SQLite writes and domain results | Foreground layout or actor-specific duplicate logic |
view.js | Bounded Projections, presentation state, interaction and fixed UI | Provider calls, credentials or direct SQLite writes |
assets/*.json | Manifest-declared frozen source data | Secrets, executable modules or undeclared files |
migrations/N.sql | One forward SQLite step from N−1 to N | BEGIN, COMMIT or PRAGMA user_version |
Design from product state outward
Start by asking what a person should still see after the device restarts. Those facts belong in App-owned SQLite. Next, list every way that state changes. Each change becomes a named Action. Expose only the Actions the Agent needs as public Tools. Finally, bind bounded queries to a fixed View.
This order prevents two common mistakes: turning the View into the business runtime, and treating the Agent as a workflow interpreter for deterministic product behavior.
Choose the right trigger
| Need | Use | Why |
|---|---|---|
| The Agent may decide whether/when to act | Public Tool → Action | Reasoning selects a deterministic capability |
| A person directly requests behavior | UI event → same Action | No duplicate business path |
| Periodic deterministic work | App schedule → same Action | No model turn or foreground View required |
| Reasoned follow-up across Apps | Agent wake schedule | Runs a prompt through the resident Agent loop |
Development sequence
- Complete Build your first App without adding networking.
- Read App source and package before changing file layout.
- Model durable state with Data and migrations.
- Define behavior through Actions and Tools.
- Build the human surface with View and interaction.
- Add external access only through Networking and native services.
- Exercise install, restart, update and failure paths in Testing and debugging.
Ordinary App packaging has no Bun, TypeScript, JSX or PocketJS compile step today. The device evaluates
actions.jsandview.jsas source inside bounded Guests.