Skip to content

Commit 50d123b

Browse files
committed
new: update README and SaveOption for skeleton
1 parent 76fad83 commit 50d123b

2 files changed

Lines changed: 23 additions & 43 deletions

File tree

  • src/new/templates/rust/ui/hyperapp-skeleton

src/new/templates/rust/ui/hyperapp-skeleton/README.md

Lines changed: 22 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,15 @@ Insert your app spec here, e.g.:
1212
Todo List with P2P Sync.
1313
A collaborative TODO list where items sync between nodes.
1414
15-
Write a spec, and then implement it step by step. Use the README.md given in hyperapp-skeleton to find instructions on specific details.
16-
At the end, I should be able to run `kit bs —hyperapp` and manually test that the app works.
15+
Write a spec, and then implement it step by step.
16+
Use the README.md given in hyperapp-skeleton to find instructions on specific details.
17+
At the end, I should be able to run `kit build --hyperapp && kit s` and manually test that the app works.
1718
```
1819

1920
The rest of this document is aimed at *LLMs* not *humans*.
2021

2122
## Quick Start
2223

23-
### Prerequisites
24-
25-
- Hyperware development environment (`kit` command)
26-
- Rust toolchain
27-
- Node.js and npm
28-
2924
### Building
3025

3126
Always build with
@@ -61,7 +56,8 @@ hyperapp-skeleton/
6156

6257
### 1. The Hyperprocess Macro
6358

64-
The `#[hyperprocess]` macro is the core of the Hyperapp framework. It provides:
59+
The `#[hyperapp_macro::hyperapp]` macro is the core of the Hyperapp framework.
60+
It provides:
6561
- Async/await support without tokio
6662
- Automatic WIT generation
6763
- State persistence
@@ -79,7 +75,7 @@ async fn my_endpoint(&self) -> String {
7975
```
8076

8177
#### Remote Requests
82-
All remote requests must use `.expects_response(30)`, where the value 30 sets a 30‑second response timeout.
78+
All remote requests must set `.expects_response(time)`, where `time` is the response timeout, in seconds.
8379
```rust
8480
let req = Request::to(("friend.os", "some-hyperapp", "some-hyperapp", "publisher.os"))
8581
.expects_response(30)
@@ -101,7 +97,8 @@ Parameters must be sent as tuples for multi-parameter methods:
10197
```
10298

10399
#### Frontend keys in snake_case
104-
All keys in TypeScript need to stay in snake_case (`node_id`), camelCase (`nodeId`) will break the app!
100+
All keys in TypeScript need to stay in snake_case (e.g. `node_id`).
101+
camelCase (e.g. `nodeId`) will break the app!
105102
```typescript
106103
export interface StatusSnapshot {
107104
node_id: string;
@@ -154,7 +151,7 @@ Add system permissions in `pkg/manifest.json`:
154151
"request_capabilities": [
155152
"homepage:homepage:sys",
156153
"http-server:distro:sys",
157-
"vfs:distro:sys" // Add as needed
154+
"vfs:distro:sys"
158155
]
159156
```
160157

@@ -182,47 +179,29 @@ If sending messages between nodes, set:
182179
- Check that the app is running in Hyperware environment
183180

184181
### WIT Generation Errors
185-
- Use simple types or return JSON strings
186-
- No HashMap (use Vec<(K,V)>)
187182
- No fixed arrays (use Vec<T>)
188183
- Add #[derive(PartialEq)] to structs
189184

190-
### Import Errors
191-
- Import the most important structs and functions from `hyperware_process_lib`, e.g. `Request`, `LazyLoadBlob`, `ProcessId`
192-
193-
### manifest.json missing
194-
- Run `kit b --hyperapp` to generate it
195-
196185
### Naming Restrictions
197186
- No struct/enum/interface name is allowed to contain digits or the substring "stream", because WIT doesn't allow it
198187
- No record/variant/enum name is allowed to end with `Request`, `Response`, `RequestWrapper`, `ResponseWrapper`, because TS caller utils are autogenerated with those suffixes
199188

200189
## Instructions
201190

202-
### Create an implementation plan
203-
204191
Carefully read the prompt; look carefully at `instructions.md` (if it exists) and in the example-apps directory.
205-
In particular, note the example applications `example-apps/sign/`, `example-apps/id/`, and `example-apps/file-explorer`.
206-
Note that `file-explorer` example contains an `api` folder, which is generated by the compiler, and not human or LLM written.
207-
`sign` and `id` demonstrate local messaging.
208-
`file-explorer` demonstrates VFS interactions.
209-
210-
Note in particular that bindings for the UI will be generated when the app is built with `kit build --hyperapp`.
211-
As such, first design and implement the backend; the interface will be generated from the backend; finally design and implement the frontend to consume the interface.
212-
Subsequent changes to the interface must follow this pattern as well: start in backend, generate interface, finish in frontend
213-
214-
Do NOT create the API.
215-
The API is machine generated.
216-
You create types that end up in the API by defining and using them in functions in the Rust backend "hyperapp"
217192

218-
### Implement the plan
193+
In `example-apps/`:
194+
- `sign` and `id` demonstrate local messaging.
195+
- `file-explorer` demonstrates VFS interactions.
196+
The `file-explorer` example contains an `api` folder, which is generated by the compiler, and not human or LLM written.
219197

220-
Look carefully at `IMPLEMENTATION_PLAN.md` and in the `example-apps/` directory, if relevant.
198+
Look at the `hyperware_process_lib` and in particular at `hyperapp`.
199+
If not provided with local repo look at https://github.com/hyperware-ai/process_lib/tree/main/src and https://raw.githubusercontent.com/hyperware-ai/process_lib/refs/heads/main/src/hyperapp.rs
221200

222-
Work from the existing template that exists at `hyperapp-skeleton/` and `ui/`.
201+
Work from the existing template, whose backend lives at `my-app-name/` and frontend at `ui/`.
223202

224-
Note in particular that bindings for the UI will be generated when the app is built with `kit build --hyperapp`.
225-
As such, first design and implement the backend; the interface will be generated from the backend; finally design and implement the frontend to consume the interface.
203+
Bindings for the UI will be generated when the app is built with `kit build --hyperapp`.
204+
Thus, first design and implement the backend; the interface will be generated from the backend; finally design and implement the frontend to consume the interface.
226205
Subsequent changes to the interface must follow this pattern as well: start in backend, generate interface, finish in frontend
227206

228207
Do NOT create the API.
@@ -231,10 +210,11 @@ You create types that end up in the API by defining and using them in functions
231210

232211
When sending p2p always send using `hyperware_process_lib::hyperapp::send` or `hyperware_process_lib::hyperapp::send_rmp` when expecting a Response, never `.send_and_await_response`.
233212
Example usage of `send` and `send_rmp` are shown in example_apps.
234-
If not expecting a response, use `.send`.
213+
If not expecting a response, use `hyperware_process_lib::Request::send`.
235214

236-
Do not worry about serialization/deserialization when using `send` and `send_rmp` functions for p2p communication.
237-
Notice that this all happens within those functions: just take the rust types as args and return rust types as return values.
215+
`send` and `send_rmp` handle (de)serialization.
216+
Just put Rust types as args and return Rust types as return values.
217+
Do not return String or JSON if a more specific Rust type will work.
238218

239219
If you create a GUI for the app you MUST use target/ui/caller-utils.ts for HTTP requests to the backend.
240220
Do NOT edit this file: it is machine generated.

src/new/templates/rust/ui/hyperapp-skeleton/hyperapp-skeleton/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub struct Status {
4040
config: hyperware_process_lib::http::server::HttpBindingConfig::new(false, false, false, None),
4141
},
4242
],
43-
save_config = hyperware_process_lib::hyperapp::SaveOptions::EveryMessage,
43+
save_config = hyperware_process_lib::hyperapp::SaveOptions::OnDiff,
4444
wit_world = "hyperapp-skeleton-template-dot-os-v0"
4545
)]
4646
impl AppState {

0 commit comments

Comments
 (0)