Skip to content

Commit 4c29aa9

Browse files
Merge pull request #3 from nick1udwig/hf/clean-up
clean up + other many improvements
2 parents d5ef10a + 485da20 commit 4c29aa9

105 files changed

Lines changed: 126003 additions & 305 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
# Rust build artifacts
22
/target/
33
**/*.rs.bk
4-
Cargo.lock
54

65
# Generated files
76
/api/
87
/target/
98

109
# Package directory - IMPORTANT: This is intentionally NOT ignored
11-
# The pkg directory contains the compiled app and should be committed
10+
# The pkg directory contains compiled AND uncompiled; don't commit compiled
1211
# /pkg/
12+
/pkg/*zip
13+
/pkg/*wasm
14+
/pkg/ui
1315

1416
# UI dependencies and build
1517
/ui/node_modules/
@@ -30,4 +32,4 @@ Cargo.lock
3032

3133
# Temporary files
3234
*.tmp
33-
*~
35+
*~

README.md

Lines changed: 117 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,43 @@
11
# Hyperware Skeleton App
22

3-
A minimal, well-commented skeleton application for the Hyperware platform using the Hyperapp framework. This skeleton provides a starting point for building Hyperware applications with a React/TypeScript frontend and Rust backend.
3+
A minimal, well-commented skeleton application for the Hyperware platform using the Hyperapp framework.
4+
This skeleton provides a starting point for building Hyperware applications with a React/TypeScript frontend and Rust backend.
45

5-
## Features
6+
Either prompt your favorite LLM directly with instructions on how to build your app or add them to `instructions.md`!
67

7-
- ✅ Minimal working Hyperware app structure
8-
- ✅ Well-commented code explaining key concepts
9-
- ✅ Basic state management with counter example
10-
- ✅ HTTP endpoints demonstration
11-
- ✅ React/TypeScript UI with Zustand state management
12-
- ✅ Error handling and loading states
13-
- ✅ Automatic WIT generation via hyperprocess macro
14-
- ✅ Persistent state across app restarts
8+
Recommended usage:
9+
- Clone this repo & clean up git-related stuff:
10+
```bash
11+
git clone https://github.com/humanizersequel/hyperapp-skeleton.git
12+
cd hyperapp-skeleton
13+
rm -rf .git
14+
```
15+
- Write a detailed document describing what you want your app to do.
16+
Save this in `instructions.md`.
17+
- Prompt your LLM agent (i.e. Claude Code) with something like:
18+
```
19+
## GOAL
20+
21+
<One-sentence description of app here>
22+
23+
## Instructions
24+
25+
Read the README.md and follow the Instructions > Create an implementation plan
26+
```
27+
28+
- After creating an implementation plan, clear your LLM agent's context and then prompt it again with something like:
29+
30+
```
31+
## GOAL
32+
33+
<One-sentence description of app here>
34+
35+
## Instructions
36+
37+
Read the README.md and follow the Instructions > Implement the plan
38+
```
39+
40+
The rest of this document is aimed at *LLMs* not *humans*.
1541

1642
## Quick Start
1743

@@ -23,33 +49,33 @@ A minimal, well-commented skeleton application for the Hyperware platform using
2349

2450
### Building
2551

26-
```bash
27-
kit b --hyperapp
28-
```
29-
52+
Always build with
53+
```bash
54+
kit build --hyperapp
55+
```
3056

3157
## Project Structure
3258

3359
```
3460
hyperapp-skeleton/
35-
├── Cargo.toml # Workspace configuration
36-
├── metadata.json # App metadata
37-
├── skeleton-app/ # Main Rust process
38-
│ ├── Cargo.toml # Process dependencies
61+
├── Cargo.toml # Workspace configuration
62+
├── metadata.json # App metadata
63+
├── skeleton-app/ # Main Rust process
64+
│ ├── Cargo.toml # Process dependencies
3965
│ └── src/
40-
│ ├── lib.rs # Main app logic (well-commented)
41-
│ └── icon # App icon file
42-
├── ui/ # Frontend application
43-
│ ├── package.json # Node dependencies
44-
│ ├── index.html # Entry point (includes /our.js)
45-
│ ├── vite.config.ts # Build configuration
66+
│ ├── lib.rs # Main app logic (well-commented)
67+
│ └── icon # App icon file
68+
├── ui/ # Frontend application
69+
│ ├── package.json # Node dependencies
70+
│ ├── index.html # Entry point (includes /our.js)
71+
│ ├── vite.config.ts # Build configuration
4672
│ └── src/
47-
│ ├── App.tsx # Main React component
48-
│ ├── store/ # Zustand state management
49-
│ ├── types/ # TypeScript type definitions
50-
│ └── utils/ # API utilities
51-
├── api/ # Generated WIT files (after build)
52-
└── pkg/ # Built package output
73+
│ ├── App.tsx # Main React component
74+
│ ├── store/ # Zustand state management
75+
│ ├── types/ # TypeScript type definitions
76+
│ └── utils/ # API utilities
77+
├── api/ # Generated WIT files (after build)
78+
└── pkg/ # The final build product, including manifest.json, scripts.json and built package output
5379
```
5480

5581
## Key Concepts
@@ -65,10 +91,10 @@ The `#[hyperprocess]` macro is the core of the Hyperapp framework. It provides:
6591
### 2. Required Patterns
6692

6793
#### HTTP Endpoints
68-
ALL HTTP endpoints MUST accept a `_request_body: String` parameter:
94+
ALL HTTP endpoints MUST be tagged with `#[http]`:
6995
```rust
7096
#[http]
71-
async fn my_endpoint(&self, _request_body: String) -> String {
97+
async fn my_endpoint(&self) -> String {
7298
// Implementation
7399
}
74100
```
@@ -79,7 +105,7 @@ Parameters must be sent as tuples for multi-parameter methods:
79105
// Single parameter
80106
{ "MethodName": value }
81107

82-
// Multiple parameters
108+
// Multiple parameters
83109
{ "MethodName": [param1, param2] }
84110
```
85111

@@ -92,9 +118,11 @@ MUST be included in index.html:
92118
### 3. State Persistence
93119

94120
Your app's state is automatically persisted based on the `save_config` option:
95-
- `EveryMessage`: Save after each message (safest)
96-
- `OnInterval(n)`: Save every n seconds
121+
- `OnDiff`: Save when state changes (strongly recommended)
97122
- `Never`: No automatic saves
123+
- `EveryMessage`: Save after each message (safest; slowest)
124+
- `EveeyNMessage(u64)`: Save every N messages received
125+
- `EveeyNSeconds(u64)`: Save every N seconds
98126

99127
## Customization Guide
100128

@@ -121,7 +149,7 @@ async fn my_method(&mut self, request_body: String) -> Result<String, String> {
121149

122150
### 3. Add Capabilities
123151

124-
Add system permissions in `manifest.json`:
152+
Add system permissions in `pkg/manifest.json`:
125153
```json
126154
"request_capabilities": [
127155
"homepage:homepage:sys",
@@ -130,17 +158,24 @@ Add system permissions in `manifest.json`:
130158
]
131159
```
132160

161+
These are required to message other local processes.
162+
They can also be granted so other local processes can message us.
163+
There is also a `request_networking` field that must be true to send messages over the network p2p.
164+
133165
### 4. Update Frontend
134166

135167
1. Add types in `ui/src/types/skeleton.ts`
136168
2. Add API calls in `ui/src/utils/api.ts`
137169
3. Update store in `ui/src/store/skeleton.ts`
138170
4. Modify UI in `ui/src/App.tsx`
139171

172+
### 5. Rename as appropriate
173+
174+
Change names throughout from `skeleton-app` (and variants) as appropriate if user describes app name.
175+
140176
## Common Issues and Solutions
141177

142178
### "Failed to deserialize HTTP request"
143-
- Ensure all HTTP methods have `_request_body` parameter
144179
- Check parameter format (tuple vs object)
145180

146181
### "Node not connected"
@@ -159,31 +194,58 @@ Add system permissions in `manifest.json`:
159194

160195
## Testing Your App
161196

162-
1. Run a Hyperware node:
197+
1. Deploy app to a Hyperware node (after building, if requested):
163198
```bash
164-
kit s
199+
kit start-packages
165200
```
166-
167201
2. Your app will be automatically installed and available at `http://localhost:8080`
168202
3. Check the Hyperware homepage for your app icon
169203

170-
## Next Steps
204+
## Instructions
205+
206+
### Create an implementation plan
207+
208+
Carefully read the prompt; look carefully at `instructions.md` (if it exists) and in the resources/ directory.
209+
In particular, note the example applications `resources/example-apps/sign/`, `resources/example-apps/id/`, and `resources/example-apps/file-explorer`.
210+
`sign` and `id` demonstrate local messaging.
211+
`file-explorer` demonstrates VFS interactions.
212+
213+
Expand the prompt and/or `instructions.md` into a detailed implementation plan.
214+
The implementor will be starting from this existing template that exists at `skeleton-app/` and `ui/`.
215+
216+
Note in particular that bindings for the UI will be generated when the app is built with `kit build --hyperapp`.
217+
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.
218+
Subsequent changes to the interface must follow this pattern as well: start in backend, generate interface, finish in frontend
219+
220+
Do NOT create the API.
221+
The API is machine generated.
222+
You create types that end up in the API by defining and using them in functions in the Rust backend "hyperapp"
223+
224+
Do NOT write code: just create a detailed `IMPLEMENTATION_PLAN.md` that will be used by the implementor.
225+
The implementor will have access to `resources/` but will be working from `IMPLEMENTATION_PLAN.md`, so include all relevant context in the PLAN.
226+
You can refer the implementor to `resources/` but do not assume the implementor has read them unless you refer them there.
227+
228+
### Implement the plan
229+
230+
Look carefully at `IMPLEMENTATION_PLAN.md` and in the `resources/` directory, if relevant.
231+
In particular, note the example applications `resources/example-apps/sign/`, `resources/example-apps/id/`, and `resources/example-apps/file-explorer`.
232+
Use them if useful.
233+
234+
Work from the existing template that exists at `skeleton-app/` and `ui/`.
171235

172-
1. **Study the Code**: Read through the well-commented `lib.rs` file
173-
2. **Experiment**: Try modifying the counter logic or adding new endpoints
174-
3. **Build Features**: Add your own functionality following the patterns
175-
4. **Add Capabilities**: Request system permissions as needed for your features
236+
Note in particular that bindings for the UI will be generated when the app is built with `kit build --hyperapp`.
237+
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.
238+
Subsequent changes to the interface must follow this pattern as well: start in backend, generate interface, finish in frontend
176239

177-
## Resources
240+
Do NOT create the API.
241+
The API is machine generated.
242+
You create types that end up in the API by defining and using them in functions in the Rust backend "hyperapp"
178243

179-
- **Development Guides**: See `resources/guides/` for comprehensive documentation
180-
- [Manifest & Deployment](resources/guides/08-MANIFEST-AND-DEPLOYMENT.md) - Understanding manifest.json
181-
- [Capabilities Guide](resources/guides/09-CAPABILITIES-GUIDE.md) - System permissions reference
182-
- [Complete Guide Index](resources/guides/README.md) - All available guides
183-
- **Example Apps**: Check the `example-apps` folder for working implementations
184-
- **Hyperware Documentation**: [Coming Soon]
185-
- **Community**: [Coming Soon]
244+
Do not worry about serialization/deserialization when using `send` and `send_rmp` functions for p2p communication.
245+
Notice that this all happens within those functions: just take the rust types as args and return rust types as return values.
186246

187-
## License
247+
If you create a GUI for the app you MUST use target/ui/caller-utils.ts for HTTP requests to the backend.
248+
Do NOT edit this file: it is machine generated.
249+
Do NOT do `fetch` or other HTTP requests manually to the backend: use the functions in this machine generated interface.
188250

189-
[Your License Here]
251+
Implement the application described in the `IMPLEMENTATION_PLAN.md`.

pkg/api.zip

-736 Bytes
Binary file not shown.

pkg/manifest.json

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@
33
"process_name": "skeleton-app",
44
"process_wasm_path": "/skeleton-app.wasm",
55
"on_exit": "Restart",
6-
"request_networking": true,
6+
"request_networking": false,
77
"request_capabilities": [
88
"homepage:homepage:sys",
9-
"http-server:distro:sys"
9+
"http-server:distro:sys",
10+
"vfs:distro:sys"
1011
],
11-
"grant_capabilities": [],
12-
"public": true
12+
"grant_capabilities": [
13+
"homepage:homepage:sys",
14+
"http-server:distro:sys",
15+
"vfs:distro:sys"
16+
],
17+
"public": false
1318
}
14-
]
19+
]

pkg/skeleton-app.wasm

-2.57 MB
Binary file not shown.

0 commit comments

Comments
 (0)