Skip to content

Commit cf37639

Browse files
authored
Merge pull request #408 from hyperware-ai/hf/new-templates-update-deps
new: update template deps (hyperapp)
2 parents bd8deb1 + 50d123b commit cf37639

14 files changed

Lines changed: 96 additions & 114 deletions

File tree

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/example-apps/file-explorer/explorer/Cargo.toml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
[dependencies]
22
anyhow = "1.0"
33
md5 = "0.7"
4+
hyperapp_macro = "0.1.1"
45
process_macros = "0.1"
56
serde_json = "1.0"
67
serde_urlencoded = "0.7"
78
tracing = "0.1.37"
89
wit-bindgen = "0.42.1"
910

10-
[dependencies.hyperprocess_macro]
11-
git = "https://github.com/hyperware-ai/hyperprocess-macro"
12-
rev = "66884c0"
13-
1411
[dependencies.hyperware_process_lib]
1512
features = ["hyperapp"]
1613
git = "https://github.com/hyperware-ai/process_lib"
17-
rev = "4beff93"
14+
rev = "1a6ad9d"
1815

1916
[dependencies.serde]
2017
features = ["derive"]

src/new/templates/rust/ui/hyperapp-skeleton/example-apps/file-explorer/explorer/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use hyperprocess_macro::hyperprocess;
21
use hyperware_process_lib::hyperapp::{add_response_header, get_path, send, SaveOptions};
32
use hyperware_process_lib::logging::{debug, error, info, init_logging, Level};
43
use hyperware_process_lib::our;
@@ -11,7 +10,6 @@ const ICON: &str = include_str!("./icon");
1110
const PROCESS_ID_LINK: &str = "explorer:file-explorer:sys";
1211

1312
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
14-
#[serde(rename_all = "camelCase")]
1513
pub struct FileInfo {
1614
pub name: String,
1715
pub path: String,
@@ -36,7 +34,7 @@ struct FileExplorerState {
3634
cwd: String,
3735
}
3836

39-
#[hyperprocess(
37+
#[hyperapp_macro::hyperapp(
4038
name = "file-explorer",
4139
ui = Some(HttpBindingConfig::default().secure_subdomain(true)),
4240
endpoints = vec![

src/new/templates/rust/ui/hyperapp-skeleton/example-apps/id/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ panic = "abort"
66
[workspace]
77
members = [
88
"id",
9-
"target/caller-utils",
9+
"target/id-caller-util?",
1010
]
1111
resolver = "2"
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
# id
22

33
For use with https://github.com/nick1udwig/sign
4+
5+
## Building
6+
7+
```
8+
kit b --hyperapp -l ~/git/sign --features "caller-utils"
9+
```
10+
11+
Or some other way of providing the sign dep (e.g. by loading `sign` onto a node running at 8080).

src/new/templates/rust/ui/hyperapp-skeleton/example-apps/id/id/Cargo.toml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
[dependencies]
22
anyhow = "1.0.97"
3+
hyperapp_macro = "0.2.0"
34
process_macros = "0.1"
45
rmp-serde = "1.3.0"
56
serde_json = "1.0"
6-
wit-bindgen = "0.36.0"
7+
wit-bindgen = "0.42.1"
78

8-
[dependencies.caller-utils]
9-
path = "../target/caller-utils"
9+
[dependencies.hyperware_process_lib]
10+
features = ["hyperapp"]
11+
version = "3.0.0"
1012

11-
[dependencies.hyperprocess_macro]
12-
git = "https://github.com/hyperware-ai/hyperprocess-macro"
13-
rev = "4c944b2"
14-
15-
[dependencies.hyperware_app_common]
16-
git = "https://github.com/hyperware-ai/hyperprocess-macro"
17-
rev = "4c944b2"
13+
[dependencies.id_caller_utils]
14+
optional = true
15+
path = "../target/id-caller-utils"
1816

1917
[dependencies.serde]
2018
features = ["derive"]
2119
version = "1.0"
2220

2321
[features]
22+
caller-utils = ["id_caller_utils"]
2423
simulation-mode = []
2524

2625
[lib]

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use caller_utils::sign::{sign_local_rpc, verify_local_rpc};
2-
use hyperprocess_macro::hyperprocess;
1+
use id_caller_utils::sign_app::{sign_local_rpc, verify_local_rpc};
32
use hyperware_process_lib::logging::{init_logging, Level};
43
use hyperware_process_lib::Address;
54

@@ -10,7 +9,7 @@ fn make_sign_sys() -> Address {
109
Address::new("our", ("sign", "sign", "sys"))
1110
}
1211

13-
#[hyperprocess(
12+
#[hyperapp_macro::hyperapp(
1413
name = "id",
1514
ui = Some(HttpBindingConfig::default()),
1615
endpoints = vec![
@@ -23,7 +22,7 @@ fn make_sign_sys() -> Address {
2322
config: WsBindingConfig::default(),
2423
}
2524
],
26-
save_config = SaveOptions::Never,
25+
save_config = hyperware_process_lib::hyperapp::SaveOptions::Never,
2726
wit_world = "id-sys-v0",
2827
)]
2928
impl IdState {

src/new/templates/rust/ui/hyperapp-skeleton/example-apps/id/ui/src/App.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useState, useEffect, useCallback } from "react";
22
import HyperwareClientApi from "@hyperware-ai/client-api";
33
import "./App.css";
44
import useIdStore from "./store/id";
5-
import { sign, verify, ApiError } from "../../target/ui/caller-utils";
5+
import { Id, ApiError } from "../../target/ui/caller-utils";
66

77
const BASE_URL = import.meta.env.BASE_URL;
88
if (window.our) window.our.process = BASE_URL?.replace("/", "");
@@ -61,7 +61,7 @@ function App() {
6161

6262
// Send a message to the node via the sign function
6363
try {
64-
const signature = await sign(messageArray);
64+
const signature = await Id.sign(messageArray);
6565

6666
// Add the message and its signature to the store
6767
addSignedMessage(message, signature);
@@ -89,7 +89,7 @@ function App() {
8989

9090
// Send a verification request via the verify function
9191
try {
92-
const isValid = await verify(messageArray, signedMessage.signature);
92+
const isValid = await Id.verify(messageArray, signedMessage.signature);
9393

9494
// Update the verification status in the store
9595
updateVerificationStatus(index, isValid);

src/new/templates/rust/ui/hyperapp-skeleton/example-apps/sign/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ panic = "abort"
66
[workspace]
77
members = [
88
"sign",
9-
"target/caller-utils",
9+
"target/sign-caller-util?",
1010
]
1111
resolver = "2"

src/new/templates/rust/ui/hyperapp-skeleton/example-apps/sign/sign/Cargo.toml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
[dependencies]
22
anyhow = "1.0.97"
3+
hyperapp_macro = "0.2.0"
34
process_macros = "0.1"
45
rmp-serde = "1.1.2"
56
serde_json = "1.0"
6-
wit-bindgen = "0.36.0"
7+
wit-bindgen = "0.42.1"
78

8-
[dependencies.caller-utils]
9-
path = "../target/caller-utils"
10-
11-
[dependencies.hyperprocess_macro]
12-
git = "https://github.com/hyperware-ai/hyperprocess-macro"
13-
rev = "4c944b2"
14-
15-
[dependencies.hyperware_app_common]
16-
git = "https://github.com/hyperware-ai/hyperprocess-macro"
17-
rev = "4c944b2"
9+
[dependencies.hyperware_process_lib]
10+
features = ["hyperapp"]
11+
version = "3.0.0"
1812

1913
[dependencies.serde]
2014
features = ["derive"]
2115
version = "1.0"
2216

17+
[dependencies.sign_caller_utils]
18+
optional = true
19+
path = "../target/sign-caller-utils"
20+
2321
[features]
22+
caller-utils = ["sign_caller_utils"]
2423
simulation-mode = []
2524

2625
[lib]

0 commit comments

Comments
 (0)