Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "visioncraft"
version = "0.2.0"
version = "0.3.0"
edition = "2024"
rust-version = "1.88"
description = "Explicit quality plans, bounded execution receipts and deterministic evidence gates"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ Rust 1.88 or later is required. Native execution currently supports Linux with g
the deterministic library remains independent of the operating system.

```sh
cargo install visioncraft --locked --version 0.2.0
cargo install visioncraft --locked --version 0.3.0
visioncraft --help
```

For the pure Rust library without CLI/process dependencies:

```toml
[dependencies]
visioncraft = { version = "0.2.0", default-features = false }
visioncraft = { version = "0.3.0", default-features = false }
```

For a coding agent, install the complete `skills/visioncraft/` directory from the
Expand Down
5 changes: 3 additions & 2 deletions skills/visioncraft/SKILL.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
---
name: visioncraft
description: Builds features with proportionate tests and evidence, diagnoses persistent bugs, and checks engineering designs and release gates. Use for expectation-driven development, difficult debugging, imported review findings, Rust changes, browser-targeted code (Rust compiled to WebAssembly by default), or a requested quality review. Simple edits and standalone prose changes do not need the full workflow.
description: Builds features with proportionate tests and evidence, diagnoses persistent bugs, and checks engineering designs and release gates. Use for expectation-driven development, difficult debugging, imported review findings, Rust changes, browser-targeted code (Rust compiled to WebAssembly by default), Rust-native desktop and web UI with the Rune GPU framework, or a requested quality review. Simple edits and standalone prose changes do not need the full workflow.
license: MIT OR Apache-2.0
metadata:
version: "0.2.0"
version: "0.3.0"
category: "engineering-quality"
---

Expand Down Expand Up @@ -35,6 +35,7 @@ command surface.
| Candidate tests, coverage gaps or measured quality tools would help | [Optional Agentic QE](references/agentic-qe.md) |
| Rust is being written, reviewed or ported | [Steering](references/rust/steering.md), [review](references/rust/review.md), [port](references/rust/port.md) |
| Code will run in a browser | [Browser targets: Rust to WebAssembly](references/rust/browser-wasm.md) |
| The UI itself should be Rust, on desktop and web | [Rune UI](references/rust/rune.md), [Rune scaffold](assets/rune-web/) |
| Several participants are actually available | [Logical roles](references/roles.md) |
| A concrete project example helps scope the work | [Five worked examples](references/worked-examples.md) |

Expand Down
30 changes: 30 additions & 0 deletions skills/visioncraft/assets/provenance.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,30 @@
"treatment": "newly written file-level provenance manifest",
"behavioural_sources": []
},
{
"path": "assets/rune-web/Cargo.toml.tmpl",
"licence": "MIT OR Apache-2.0",
"treatment": "newly written verified scaffold: Rune desktop and web app crate",
"behavioural_sources": []
},
{
"path": "assets/rune-web/lib.rs.tmpl",
"licence": "MIT OR Apache-2.0",
"treatment": "newly written verified scaffold: Rune desktop and web app crate",
"behavioural_sources": []
},
{
"path": "assets/rune-web/main.rs.tmpl",
"licence": "MIT OR Apache-2.0",
"treatment": "newly written verified scaffold: Rune desktop and web app crate",
"behavioural_sources": []
},
{
"path": "assets/rune-web/smoke.json",
"licence": "MIT OR Apache-2.0",
"treatment": "newly written verified scaffold: Rune desktop and web app crate",
"behavioural_sources": []
},
{
"path": "assets/traceability.md",
"licence": "MIT OR Apache-2.0",
Expand Down Expand Up @@ -269,6 +293,12 @@
"sha256": "8803404fbe00f2d6bdaa8c00555a2b37a4ad8f5570157bae94af8c7d5dfec29f"
}
},
{
"path": "references/rust/rune.md",
"licence": "MIT OR Apache-2.0",
"treatment": "newly written guidance: Rune Rust-native UI selection, crate shape and evidence",
"behavioural_sources": []
},
{
"path": "references/rust/sources/effective-rust.md",
"licence": "MIT",
Expand Down
19 changes: 19 additions & 0 deletions skills/visioncraft/assets/rune-web/Cargo.toml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copy to Cargo.toml in a new crate, rename the package, and bump `rev` deliberately.
[package]
name = "rune_web_app"
version = "0.1.0"
edition = "2024"
publish = false

[lib]
# cdylib for the browser bundle, rlib so native tests and the binary share the code.
crate-type = ["cdylib", "rlib"]

[dependencies]
# Rune is pre-release and not on crates.io; the registry's `rune` is an unrelated
# scripting language. Pin one revision of its fast-forward-only `dev` branch.
rune = { git = "https://github.com/anomalyco/rune", rev = "781e2b6d87cd5f32d6f4365956fad4baaf24ee50" }

[target.'cfg(target_arch = "wasm32")'.dependencies]
# Must equal the installed wasm-bindgen CLI; a mismatch fails when the page loads.
wasm-bindgen = "=0.2.129"
209 changes: 209 additions & 0 deletions skills/visioncraft/assets/rune-web/lib.rs.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
//! A Rune app that builds for the desktop, headless tooling and the browser from one crate.
//!
//! `core` holds the behaviour and has no Rune types, so plain `cargo test` covers it.
//! `view` renders it; `start` is the browser entrypoint and `spec` feeds the native binary.

pub mod core {
/// Which tasks the list shows.
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub enum Filter {
#[default]
All,
Open,
Done,
}

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Task {
pub id: u32,
pub title: String,
pub done: bool,
}

#[derive(Debug, PartialEq, Eq)]
pub enum AddError {
EmptyTitle,
}

#[derive(Debug, Default)]
pub struct Tasks {
items: Vec<Task>,
next_id: u32,
pub filter: Filter,
}

impl Tasks {
/// Adds a task with a trimmed title; an empty title leaves the list unchanged.
pub fn add(&mut self, title: &str) -> Result<u32, AddError> {
let title = title.trim();
if title.is_empty() {
return Err(AddError::EmptyTitle);
}
let id = self.next_id;
self.next_id += 1;
self.items.push(Task { id, title: title.to_owned(), done: false });
Ok(id)
}

pub fn toggle(&mut self, id: u32) {
if let Some(task) = self.items.iter_mut().find(|t| t.id == id) {
task.done = !task.done;
}
}

/// Filtering hides tasks; it never removes them.
pub fn visible(&self) -> impl Iterator<Item = &Task> {
self.items.iter().filter(move |t| match self.filter {
Filter::All => true,
Filter::Open => !t.done,
Filter::Done => t.done,
})
}

pub fn len(&self) -> usize {
self.items.len()
}

pub fn is_empty(&self) -> bool {
self.items.is_empty()
}
}
}

use core::{Filter, Tasks};
use rune::tok::{self, type_};
use rune::{AppSpec, Cx, El, ScrollSpec, TextEdit, col, el, row, text, text_input};

pub struct App {
pub tasks: Tasks,
pub draft: TextEdit,
}

impl Default for App {
fn default() -> Self {
let mut tasks = Tasks::default();
for title in ["Read the Rune README", "Render a headless PNG", "Ship the wasm bundle"] {
tasks.add(title).expect("seed titles are not empty");
}
Self { tasks, draft: TextEdit::new("") }
}
}

fn submit(app: &mut App, _: &mut rune::Tx) {
if app.tasks.add(&app.draft.text).is_ok() {
app.draft.clear();
}
}

fn chip(label: &'static str, key: &'static str, filter: Filter, current: Filter, dark: bool) -> El {
let t = tok::theme(dark);
let on = filter == current;
el().key(key).role("button").label(label).focusable(true)
.h(32.0).px(12.0).center().radius(16.0)
.fill(if on { tok::accent(0, dark) } else { t.control_off })
.child(text(label).font(type_::LABEL).color(t.text))
.on_press(move |app: &mut App| app.tasks.filter = filter)
}

pub fn view(app: &App, cx: &mut Cx<App>) -> El {
let dark = cx.system_dark();
let t = tok::theme(dark);
let [top, right, bottom, left] = cx.safe_area();

let mut list = col().w_full().gap(8.0);
for task in app.tasks.visible() {
let id = task.id;
let mark = if task.done { "Done" } else { "Open" };
list = list.child(
row().key(format!("task-{id}")).role("checkbox").label(task.title.clone())
.checked(task.done).focusable(true)
.w_full().gap(12.0).padding(12.0).radius(10.0).fill(t.card)
.child(text(task.title.clone()).font(type_::BODY).color(t.text).grow(1.0))
.child(text(mark).font(type_::LABEL).color(t.text_secondary))
.on_press(move |app: &mut App| app.tasks.toggle(id)),
);
}

let input = text_input(&app.draft, type_::BODY).key("draft")
.placeholder("New task", t.text_secondary).color(t.text)
.grow(1.0).h(44.0).padding(12.0).radius(10.0).fill(t.card)
.on_edit(|app: &mut App| &mut app.draft).on_submit(submit);
let filters = row().gap(8.0)
.child(chip("All", "filter-all", Filter::All, app.tasks.filter, dark))
.child(chip("Open", "filter-open", Filter::Open, app.tasks.filter, dark))
.child(chip("Done", "filter-done", Filter::Done, app.tasks.filter, dark));

col().w_full().h_full().gap(12.0).fill(t.bg)
.pt(16.0 + top).pr(16.0 + right).pb(16.0 + bottom).pl(16.0 + left)
.child(text("Tasks").font(type_::TITLE).color(t.text))
.child(input)
.child(filters)
.child(col().key("tasks").w_full().grow(1.0).shrink()
.scroll(ScrollSpec { stick_bottom: false }).child(list))
}

/// One spec for every host. Scenes name states that headless `--snap --scene` renders.
pub fn spec() -> AppSpec<App> {
AppSpec::<App> {
scenes: &[
("first-done", |app| app.tasks.toggle(0)),
("done-only", |app| {
app.tasks.toggle(0);
app.tasks.filter = Filter::Done;
}),
],
..AppSpec::new("Tasks", (390.0, 640.0), App::default, view)
}
}

/// Browser entrypoint; on native the binary calls it.
#[cfg_attr(target_arch = "wasm32", wasm_bindgen::prelude::wasm_bindgen(start))]
pub fn start() {
rune::run(spec());
}

#[cfg(test)]
mod tests {
use super::core::{AddError, Filter, Tasks};
use super::*;
use rune::{Env, Runtime};

#[test]
fn an_empty_title_is_rejected_without_changing_the_list() {
let mut tasks = Tasks::default();
tasks.add("one").unwrap();
assert_eq!(tasks.add(" "), Err(AddError::EmptyTitle));
assert_eq!(tasks.len(), 1);
}

#[test]
fn filtering_hides_tasks_but_keeps_them() {
let mut tasks = Tasks::default();
let a = tasks.add("a").unwrap();
tasks.add("b").unwrap();
tasks.toggle(a);
tasks.filter = Filter::Done;
assert_eq!(tasks.visible().count(), 1);
tasks.filter = Filter::All;
assert_eq!(tasks.visible().count(), 2);
}

#[test]
fn tapping_a_task_marks_it_done_through_the_real_view() {
let env = Env { system_dark: true, scale: 2.0 };
let mut rt = Runtime::new(App::default(), view, (390.0, 640.0), env);
rt.frame(0.0);
let (x, y) = rt.find("task-1").expect("the second task is mounted");
rt.pointer_down(x, y);
rt.pointer_up(x, y);
rt.frame(1.0 / 60.0);
assert!(rt.state.tasks.visible().any(|t| t.id == 1 && t.done));

let (x, y) = rt.find("filter-open").expect("the Open chip is mounted");
rt.pointer_down(x, y);
rt.pointer_up(x, y);
rt.frame(1.0 / 60.0);
assert!(rt.find("task-1").is_none(), "a done task leaves the Open view");
assert!(rt.find("task-0").is_some());
}
}
5 changes: 5 additions & 0 deletions skills/visioncraft/assets/rune-web/main.rs.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
//! Native window, or headless tooling: `--snap out.png --scene first-done`, `--tree tree.json`,
//! `--script smoke.json --frames 30 --out frames/`.
fn main() {
rune_web_app::start();
}
5 changes: 5 additions & 0 deletions skills/visioncraft/assets/rune-web/smoke.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{"events": [
{"t": 0.1, "type": "tap", "key": "task-1"},
{"t": 0.4, "type": "tap", "key": "filter-done"},
{"t": 0.8, "type": "mark", "name": "end"}
]}
1 change: 1 addition & 0 deletions skills/visioncraft/references/rust/browser-wasm.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ Use what the project already ships. Common pairings:
|---|---|---|
| Vite/React or another JS framework | `wasm-pack build --target web` or `wasm-bindgen` CLI, then `vite-plugin-wasm` | A small typed bridge module owns `init()` and re-exports the API |
| Rust-only front end | `trunk` with Leptos, Yew, Dioxus or plain `web-sys` | Suitable when there is no existing JS shell to keep |
| Rust-native GPU UI, desktop and web from one crate | Rune's `scripts/web-build.sh` (git-pinned `rev`) | Canvas and WebGPU only; see [rune.md](rune.md) for when it fits and its evidence gates |
| Worker or WebGPU compute | `wasm-bindgen` with `--target web`, or `wgpu` | Keep GPU resource ownership on one side of the boundary |

Pin `wasm-bindgen` to the same version as the CLI that generates the bindings;
Expand Down
Loading
Loading