Skip to content

Craft Anything: understand how any software works, and craft your own.

Rust

Keep what a project edited in place is built with, read from its own files (#755)

Aek7a0d7de0e434
diff --git a/crates/ai/src/rebuild/mod.rs b/crates/ai/src/rebuild/mod.rs
index 0a9afcd4..4108e0b0 100644
--- a/crates/ai/src/rebuild/mod.rs
+++ b/crates/ai/src/rebuild/mod.rs
@@ -627,8 +627,7 @@ impl Worker {
};
if ws.manifest.stack.is_empty() {
let deep = !self.engine.session().clean_room();
- let (_, stack) = opts.kinds.choose(&ws.manifest.request, &ws.manifest.target, deep).ok_or_else(no_kind)?;
- ws.manifest.stack = stack.to_string();
+ ws.manifest.stack = project::first_stack(&opts.kinds, ws, deep).ok_or_else(no_kind)?.to_string();
ws.save()?;
}
let kind = opts.kinds.detect(&ws.manifest.request, &ws.manifest.target, &ws.manifest.stack).ok_or_else(no_kind)?;
diff --git a/crates/ai/src/rebuild/project.rs b/crates/ai/src/rebuild/project.rs
index 7b856f88..2fd72bc3 100644
--- a/crates/ai/src/rebuild/project.rs
+++ b/crates/ai/src/rebuild/project.rs
@@ -25,6 +25,15 @@ pub fn build_with(name: &str) -> Result<&'static stacks::Stack, ToolError> {
})
}
+/// The stack a project starts with. One edited in place keeps what its files are built with,
+/// unless its request names another; any other goes by its request and target.
+pub(super) fn first_stack(kinds: &KindRegistry, ws: &Workspace, deep: bool) -> Option<&'static str> {
+ let m = &ws.manifest;
+ let own = m.app_in_root && kinds.named(&m.request, &m.target).is_none();
+ let found = own.then(|| stacks::found_in(&ws.app_dir())).flatten();
+ found.map(|s| s.name.as_str()).or_else(|| kinds.choose(&m.request, &m.target, deep).map(|(_, stack)| stack))
+}
+
/// A new project for `request` about `target` (a web address, an absolute path, or `-` for none),
/// at `place`, with the stack the person
/// picked (`build_with`), the asset budget from settings, and `generate_assets`: the person lets the
diff --git a/crates/ai/src/rebuild/stacks.rs b/crates/ai/src/rebuild/stacks.rs
index 2a6b6183..0fbeaa04 100644
--- a/crates/ai/src/rebuild/stacks.rs
+++ b/crates/ai/src/rebuild/stacks.rs
@@ -21,9 +21,17 @@ pub struct Stack {
/// the generic instruction.
#[serde(default)]
pub steps: Option<String>,
- /// package.json dependencies that show a build uses this stack (`next`, `vite`).
+ /// package.json dependencies that show a build uses this stack (`next`, `vite`); in a
+ /// person's own project, Cargo.toml's too (`eframe`).
#[serde(default)]
pub uses: Vec<String>,
+ /// What a person's own project must depend on as well to count as this stack (`react`).
+ #[serde(default)]
+ pub needs: Vec<String>,
+ /// Files, relative to a folder, that show a person's own project is built with this stack
+ /// (`project.godot`); a leading `*` matches by the name's ending (`*.uproject`).
+ #[serde(default)]
+ pub found_by: Vec<String>,
}
/// The stack that leaves the choice to the builder (a website's default); [`used_in`] then
@@ -97,6 +105,23 @@ pub fn used_in(app: &std::path::Path) -> Option<&'static Stack> {
catalogue().iter().find(|s| s.uses.iter().any(|d| deps.contains(d)))
}
+/// The stack a folder of the person's own files is built with: an engine's project file says
+/// most, then the dependencies, then the other files that name a stack. None when nothing does.
+pub fn found_in(dir: &std::path::Path) -> Option<&'static Stack> {
+ let by_file = |engine: bool| catalogue().iter().filter(|s| s.engine.is_some() == engine).find(|s| s.found_by.iter().any(|f| has_file(dir, f)));
+ let mut deps = craft_anything_engine::outputs::npm_dependencies(dir);
+ deps.extend(craft_anything_engine::outputs::cargo_dependencies(dir));
+ let by_deps = || catalogue().iter().find(|s| s.uses.iter().any(|d| deps.contains(d)) && s.needs.iter().all(|d| deps.contains(d)));
+ by_file(true).or_else(by_deps).or_else(|| by_file(false))
+}
+
+fn has_file(dir: &std::path::Path, name: &str) -> bool {
+ match name.strip_prefix('*') {
+ Some(ending) => std::fs::read_dir(dir).into_iter().flatten().flatten().any(|e| e.file_name().to_string_lossy().ends_with(ending)),
+ None => dir.join(name).is_file(),
+ }
+}
+
/// The libraries `request` asks for that work with `stack`, in table order.
pub fn libraries_for(request: &str, stack: &str) -> Vec<&'static Library> {
let w = words(request);
@@ -127,6 +152,43 @@ pub fn steps(stack: &str, editor: Option<&std::path::Path>) -> String {
mod tests {
use super::*;
+ #[test]
+ fn a_folder_says_what_it_is_built_with() {
+ // Each case in a folder of its own.
+ let found = |files: &[(&str, &str)]| {
+ let d = tempfile::tempdir().unwrap();
+ for (name, text) in files {
+ let path = d.path().join(name);
+ std::fs::create_dir_all(path.parent().unwrap()).unwrap();
+ std::fs::write(path, text).unwrap();
+ }
+ found_in(d.path()).map(|s| s.name.as_str())
+ };
+ let vite = r#"{"dependencies":{"react":"19"},"devDependencies":{"vite":"7"}}"#;
+ assert_eq!(found(&[("project.godot", "")]), Some("Godot"));
+ assert_eq!(found(&[("ProjectSettings/ProjectVersion.txt", "")]), Some("Unity"));
+ assert_eq!(found(&[("Game.uproject", "{}")]), Some("Unreal Engine"));
+ assert_eq!(found(&[("project.godot", ""), ("package.json", vite)]), Some("Godot"), "an engine's file says most");
+ assert_eq!(found(&[("package.json", vite), ("index.html", "")]), Some("React + TypeScript (Vite)"));
+ assert_eq!(
+ found(&[("package.json", r#"{"dependencies":{"vue":"3"},"devDependencies":{"vite":"7"}}"#)]),
+ Some(BUILDERS_CHOICE),
+ "Vite alone isn't React"
+ );
+ assert_eq!(found(&[("package.json", r#"{"dependencies":{"svelte":"5"}}"#), ("index.html", "")]), Some(BUILDERS_CHOICE));
+ assert_eq!(found(&[("Cargo.toml", "[dependencies]\neframe = \"0.30\"\n")]), Some("Rust + egui (eframe)"));
+ assert_eq!(found(&[("Cargo.toml", "[dependencies]\nmacroquad = \"0.4\"\n")]), Some("Rust + macroquad"));
+ assert_eq!(found(&[("Cargo.toml", "[dependencies]\nmacroquad = \"0.4\"\negui = \"0.30\"\n")]), Some("Rust + macroquad"), "a game with an egui overlay");
+ assert_eq!(found(&[("Cargo.toml", "[dependencies]\niced = \"0.13\"\n")]), Some(BUILDERS_CHOICE));
+ assert_eq!(found(&[("Cargo.toml", "not [ toml")]), Some(BUILDERS_CHOICE));
+ assert_eq!(found(&[("pyproject.toml", "")]), Some("Python"));
+ assert_eq!(found(&[("requirements.txt", "")]), Some("Python"));
+ assert_eq!(found(&[("go.mod", "")]), Some(BUILDERS_CHOICE));
+ assert_eq!(found(&[("App.csproj", "")]), Some(BUILDERS_CHOICE));
+ assert_eq!(found(&[("index.html", "")]), Some("Plain HTML and CSS"));
+ assert_eq!(found(&[("notes.md", "")]), None);
+ }
+
#[test]
fn the_table_parses_and_covers_every_engine() {
let names: Vec<&str> = catalogue().iter().map(|s| s.name.as_str()).collect();
@@ -150,6 +212,8 @@ mod tests {
.is_some_and(|s| s.steps.as_deref().is_some_and(|t| t.starts_with("Use what their request names; otherwise choose the stack yourself")))
);
assert!(used_in(d.path()).is_none(), "no package.json");
+ std::fs::write(d.path().join("Cargo.toml"), "[dependencies]\neframe = \"0.30\"\n").unwrap();
+ assert!(used_in(d.path()).is_none(), "Cargo.toml never replaces a stack the request named");
std::fs::write(d.path().join("package.json"), "not json").unwrap();
assert!(used_in(d.path()).is_none(), "a broken package.json is no stack, not a crash");
std::fs::write(d.path().join("package.json"), r#"{"dependencies": {"next": "16", "react": "19"}, "devDependencies": {"vite": "7"}}"#).unwrap();
diff --git a/crates/ai/src/rebuild/stacks.toml b/crates/ai/src/rebuild/stacks.toml
index 79c8f835..b2c0dd28 100644
--- a/crates/ai/src/rebuild/stacks.toml
+++ b/crates/ai/src/rebuild/stacks.toml
@@ -6,13 +6,21 @@
# spaces and padded with spaces ("Next.js," reads " next js "), first stack in this order wins.
#
# `uses` lists package.json dependencies that show a build was made with the stack, so a build
-# left to the builder ("Builder's choice") is recorded under the stack it really used.
+# left to the builder ("Builder's choice") is recorded under the stack it really used. They, and
+# Cargo.toml dependencies, also show what a person's own project is built with; `needs` lists what
+# must be there too before it counts (Vite alone could be Vue or Svelte).
+#
+# `found_by` lists files, relative to a folder, that show a person's own project is built with
+# the stack (`*.uproject` matches by its ending). An engine's file says most, then `uses`, then
+# the others in this order, so "Builder's choice" takes any project whose dependencies name no
+# stack here: the builder keeps to what's there.
#
# A `[[library]]` is a component or styling library asked for on top of a stack ("shadcn",
# "tailwind"): its `steps` are added to the stack's for the `stacks` it works with.
[[stack]]
name = "Builder's choice"
+found_by = ["package.json", "Cargo.toml", "go.mod", "pom.xml", "build.gradle", "build.gradle.kts", "*.sln", "*.csproj", "Gemfile", "composer.json", "CMakeLists.txt", "Makefile"]
steps = "Use what their request names; otherwise choose the stack yourself: the one that best fits the request and the original. If the request names none and the capture shows what the original is built with (the script and stylesheet addresses in capture.json and page.html, for example /_next/ for Next.js or /_nuxt/ for Nuxt), use the same. For a website, create the project in app/ with a \"build\" script in package.json, then run `npm install` and `npm run build` from app/ until it succeeds: the output must be static files in app/dist, app/out or app/build (index.html at its top and each other page at its own path) that work when served as static files."
[[stack]]
@@ -30,16 +38,19 @@ steps = "Use Next.js (App Router) + React + TypeScript, exported as a static sit
[[stack]]
name = "Python"
asked_by = [" in python", " with python"]
+found_by = ["pyproject.toml", "requirements.txt", "setup.py"]
[[stack]]
name = "React + TypeScript (Vite)"
asked_by = [" in typescript", " in react", " with react", " in javascript", " vite "]
uses = ["vite"]
+needs = ["react"]
steps = "Use Vite + React + TypeScript. Create the project files directly in app/ (package.json with scripts \"build\": \"tsc -b && vite build\" or \"vite build\", vite.config.ts with base './', index.html, src/). Then run `npm install` and `npm run build` from app/ until it succeeds; the output must be app/dist and must work when served as static files."
[[stack]]
name = "Plain HTML and CSS"
asked_by = [" html and css ", " plain html ", " no frameworks ", " no javascript ", " no build step ", " static html "]
+found_by = ["index.html"]
steps = "Use plain HTML, CSS and a little JavaScript only if the page needs it: no framework, no bundler, no build step. Create the project directly in app/: index.html at the top, one .css file (and .js only if needed) beside it, with each other page at its own path (about.html, contact.html). Link the stylesheet with a relative path. Then check that the pages open and look right when served as static files; there is nothing to build."
[[stack]]
@@ -47,28 +58,33 @@ name = "Rust (console)"
uses = []
steps = "Use Rust for a console program: create a cargo project in app/ itself (app/Cargo.toml and app/src/main.rs, not a folder inside app/), read its arguments (std::env::args, or clap if it has many options), print to standard output and standard error the way the original does, exit with the original's exit codes, and draw no window. Run `cargo build` until it succeeds."
-[[stack]]
-name = "Rust + egui (eframe)"
-steps = "Use Rust with eframe/egui for the window and UI. Create a cargo project in app/ itself (app/Cargo.toml, not a folder inside app/) and run `cargo build` until it succeeds."
-
[[stack]]
name = "Rust + macroquad"
engine = "rust"
+uses = ["macroquad"]
steps = "Use Rust with macroquad (a small game library). Create a cargo project in app/ itself (app/Cargo.toml and app/src/main.rs, not a folder inside app/), keep assets procedural (shapes, colours) unless the person provides some, and run `cargo build` until it succeeds."
+[[stack]]
+name = "Rust + egui (eframe)"
+uses = ["eframe", "egui"]
+steps = "Use Rust with eframe/egui for the window and UI. Create a cargo project in app/ itself (app/Cargo.toml, not a folder inside app/) and run `cargo build` until it succeeds."
+
[[stack]]
name = "Unity"
engine = "unity"
+found_by = ["ProjectSettings/ProjectVersion.txt"]
steps = "Use Unity (the editor is {editor}). Create the project in app/: Assets/, Packages/manifest.json (built-in packages unless you need more) and ProjectSettings/ProjectVersion.txt with the editor's version. Write the game in C# under Assets/Scripts/. Scenes are hard to write by hand, so build them from code: an editor script Assets/Editor/CraftBuild.cs with a static `Build()` method that creates the scene(s) under Assets/Scenes/, adds them to the build settings and builds a {player} player to app/Build/Game.{ext} with BuildPipeline.BuildPlayer, calling EditorApplication.Exit(1) when the build fails. Build with `\"{editor}\" -batchmode -quit -nographics -projectPath app -executeMethod CraftBuild.Build -logFile app/Logs/build.log` and read that log when it fails. The first run imports the project and takes a few minutes."
[[stack]]
name = "Unreal Engine"
engine = "unreal"
+found_by = ["*.uproject"]
steps = "Use Unreal Engine (the editor is {editor}) with C++: Blueprint and level files are binary and can't be written by hand. Create app/Game.uproject (its EngineAssociation set to the installed version, one C++ module) and Source/Game/ with the module, its Build.cs and the Target.cs files. Make levels from code (a GameMode that spawns the geometry, lights and actors at start, with a small empty default map) rather than editing .umap files. Craft Anything packages it with Unreal's BuildCookRun into app/Build after each round; the first package takes a long time, so compile your C++ with the engine's build tool first and fix errors there."
[[stack]]
name = "Godot"
engine = "godot"
+found_by = ["project.godot"]
steps = "Use Godot (the editor is {editor}) with GDScript. Create the project in app/: project.godot (config_version=5, with run/main_scene set), scenes as .tscn text files and scripts as .gd files; Godot's files are plain text, so write scenes directly. Check it with `\"{editor}\" --headless --path app --import` and then `\"{editor}\" --headless --path app --quit-after 120`, and fix every SCRIPT ERROR or ERROR line."
[[library]]
diff --git a/crates/ai/src/rebuild/tests.rs b/crates/ai/src/rebuild/tests.rs
index 9b55f35a..4bc62f84 100644
--- a/crates/ai/src/rebuild/tests.rs
+++ b/crates/ai/src/rebuild/tests.rs
@@ -2574,6 +2574,22 @@ fn a_project_started_in_a_picked_folder_stays_in_the_list() {
assert!(listed.iter().any(|w| w.root == ws.root));
}
+#[test]
+fn a_project_edited_in_place_keeps_what_its_files_are_built_with() {
+ use craft_anything_engine::workspace::ExistingFiles::{Edit, StartFrom};
+ let first = |file: &str, request: &str, existing| {
+ let d = tempfile::tempdir().unwrap();
+ std::fs::write(d.path().join(file), "").unwrap();
+ let ws = Workspace::create_at(d.path(), "Mine", request, TargetRef::None, Some(existing)).unwrap();
+ project::first_stack(&KindRegistry::built_in(), &ws, false)
+ };
+ assert_eq!(first("project.godot", "Fix my game's jump", Edit), Some("Godot"), "not the Unity its words would get");
+ assert_eq!(first("requirements.txt", "Add a settings page", Edit), Some("Python"), "not the app kind's default");
+ assert_eq!(first("requirements.txt", "Move it to Electron", Edit), Some("Electron"), "the person's words come first");
+ assert_eq!(first("notes.md", "Fix my game's jump", Edit), Some("Unity"), "nothing to read: as for a new project");
+ assert_eq!(first("project.godot", "Fix my game's jump", StartFrom), Some("Unity"), "material to start from doesn't decide");
+}
+
#[test]
fn the_extractors_transcript_is_one_of_craft_anythings_own_files() {
assert!(craft_anything_engine::workspace::OWN_NAMES.contains(&brief::EXTRACT_TRANSCRIPT), "a picked folder with this name would be overwritten");
diff --git a/crates/engine/src/outputs.rs b/crates/engine/src/outputs.rs
index 096ac1fe..4be4daf7 100644
--- a/crates/engine/src/outputs.rs
+++ b/crates/engine/src/outputs.rs
@@ -154,6 +154,12 @@ pub fn npm_dependencies(app: &Path) -> Vec<String> {
["dependencies", "devDependencies"].iter().filter_map(|k| pkg.as_ref()?.get(k)?.as_object()).flat_map(|d| d.keys().cloned()).collect()
}
+/// The crates `app`'s Cargo.toml depends on; none without a readable one.
+pub fn cargo_dependencies(app: &Path) -> Vec<String> {
+ let manifest: Option<toml::Table> = std::fs::read_to_string(app.join("Cargo.toml")).ok().and_then(|t| t.parse().ok());
+ manifest.as_ref().and_then(|m| m.get("dependencies")?.as_table()).map(|d| d.keys().cloned().collect()).unwrap_or_default()
+}
+
fn uses_electron(app: &Path) -> bool {
npm_dependencies(app).iter().any(|d| d == "electron")
}
diff --git a/crates/ui-egui/src/engine_ui.rs b/crates/ui-egui/src/engine_ui.rs
index 7e349c2b..eeb87bc1 100644
--- a/crates/ui-egui/src/engine_ui.rs
+++ b/crates/ui-egui/src/engine_ui.rs
@@ -594,13 +594,16 @@ pub fn assets_settings(app: &mut CraftApp, ui: &mut Ui) {
}
}
-/// The engine to build this draft with: the person's pick, else the one the request names, else
-/// none when the request names another way to build ("…in Electron"), else the original's own
-/// or Unity.
+/// The engine to build this draft with: the person's pick, else the one their own files use, else
+/// the one the request names, else none when the request names another way to build ("…in
+/// Electron"), else the original's own or Unity.
pub fn chosen(kinds: &KindRegistry, d: &MakeDraft) -> Option<Builder> {
if d.builder.is_some() {
return d.builder;
}
+ if let Some(stack) = crate::make::own_stack(kinds, d) {
+ return Builder::from_stack(stack);
+ }
match kinds.named(&d.request, &crate::make::resolve_target(d)) {
Some(stack) => Builder::from_stack(stack),
None => Some(Builder::for_game(d.found.as_ref().map(|f| f.engine))),
diff --git a/crates/ui-egui/src/folders.rs b/crates/ui-egui/src/folders.rs
index 8e09d6e0..8edeafe4 100644
--- a/crates/ui-egui/src/folders.rs
+++ b/crates/ui-egui/src/folders.rs
@@ -6,6 +6,7 @@ use crate::i18n::{tr, trf};
use crate::state::Modal;
use crate::theme::{self, Tokens};
use crate::{CraftApp, Pick, widgets};
+use craft_anything_ai::rebuild::stacks;
use craft_anything_engine::workspace::{self, ExistingFiles, FolderState, Workspace};
use egui::{RichText, Ui, Vec2};
use std::path::PathBuf;
@@ -58,6 +59,7 @@ fn clear(app: &mut CraftApp) {
let d = &mut app.state.make;
d.folder = None;
d.folder_files = None;
+ d.folder_stack = None;
d.existing = None;
}
@@ -123,7 +125,10 @@ fn choose(app: &mut CraftApp, choice: ExistingFiles) {
let Some(folder) = app.state.make.folder.clone() else { return };
let clash = workspace::clashes(&folder, choice);
if clash.is_empty() {
- app.state.make.existing = Some(choice);
+ let d = &mut app.state.make;
+ d.existing = Some(choice);
+ // Read here, once: the screens that use it are drawn every frame.
+ d.folder_stack = (choice == ExistingFiles::Edit).then(|| stacks::found_in(&folder)).flatten().map(|s| s.name.clone());
} else {
clear(app);
let names = clash.join(", ");
diff --git a/crates/ui-egui/src/make.rs b/crates/ui-egui/src/make.rs
index 61e17894..721a31d9 100644
--- a/crates/ui-egui/src/make.rs
+++ b/crates/ui-egui/src/make.rs
@@ -61,11 +61,21 @@ pub fn resolve_target(d: &MakeDraft) -> TargetRef {
/// A game is being copied or made, so it's built with a game engine ("Build with").
pub fn is_game(kinds: &craft_anything_ai::rebuild::KindRegistry, d: &MakeDraft) -> bool {
use craft_anything_ai::rebuild::GameKind;
+ if let Some(stack) = own_stack(kinds, d) {
+ return craft_anything_engines::game::Builder::from_stack(stack).is_some();
+ }
d.found.is_some()
|| (d.game && matches!(d.target, TargetRef::Local { .. }))
|| kinds.choose(&d.request, &resolve_target(d), false).is_some_and(|(k, _)| k.id() == GameKind::ID)
}
+/// What the person's own files are built with, when they're the app and the request names no
+/// other stack (the run decides the same way: `project::first_stack`).
+pub fn own_stack<'a>(kinds: &craft_anything_ai::rebuild::KindRegistry, d: &'a MakeDraft) -> Option<&'a str> {
+ let own = d.existing == Some(ExistingFiles::Edit) && kinds.named(&d.request, &resolve_target(d)).is_none();
+ d.folder_stack.as_deref().filter(|_| own)
+}
+
/// The front door: make your own version of something, work on a project you already have, or
/// just look inside something.
pub fn hero(app: &mut CraftApp, ui: &mut Ui, w: f32) {
@@ -522,6 +532,27 @@ mod tests {
}
}
+ #[test]
+ fn the_persons_own_files_say_whether_it_is_a_game() {
+ use crate::engine_ui::chosen;
+ use craft_anything_engines::game::Builder;
+ let kinds = craft_anything_ai::rebuild::KindRegistry::built_in();
+ let own = |stack: Option<&str>, request: &str| MakeDraft {
+ folder_stack: stack.map(str::to_string),
+ existing: Some(ExistingFiles::Edit),
+ request: request.into(),
+ ..Default::default()
+ };
+ let godot = own(Some("Godot"), "Fix the jump");
+ assert!(is_game(&kinds, &godot), "whatever the request's words say");
+ assert_eq!(chosen(&kinds, &godot), Some(Builder::Godot));
+ assert!(!is_game(&kinds, &own(Some("Python"), "Fix my game")), "no engine to get for a Python game");
+ assert_eq!(chosen(&kinds, &own(Some("Python"), "Fix my game with Godot")), Some(Builder::Godot), "the person's words come first");
+ assert!(is_game(&kinds, &own(None, "Fix my game")), "nothing read from the folder: the words decide");
+ let start_from = MakeDraft { existing: Some(ExistingFiles::StartFrom), ..own(Some("Python"), "Fix my game") };
+ assert!(is_game(&kinds, &start_from), "material to start from doesn't decide");
+ }
+
#[test]
fn targets_from_the_draft() {
let mut d = MakeDraft { request: "Please recreate https://example.com/pricing.".into(), ..Default::default() };
diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs
index c5bc3a73..73202b50 100644
--- a/crates/ui-egui/src/state.rs
+++ b/crates/ui-egui/src/state.rs
@@ -61,6 +61,9 @@ pub struct MakeDraft {
/// What's already in that folder: the first names and how many.
#[serde(default)]
pub folder_files: Option<(Vec<String>, usize)>,
+ /// The stack those files are built with, read when they're chosen as the app.
+ #[serde(default)]
+ pub folder_stack: Option<String>,
/// What those files are to the project.
#[serde(default)]
pub existing: Option<craft_anything_engine::workspace::ExistingFiles>,
@@ -92,6 +95,7 @@ impl Default for MakeDraft {
mine: false,
folder: None,
folder_files: None,
+ folder_stack: None,
existing: None,
remember_existing: false,
ai: None,
diff --git a/crates/ui-egui/tests/smoke.rs b/crates/ui-egui/tests/smoke.rs
index 493db0c7..0188ddb2 100644
--- a/crates/ui-egui/tests/smoke.rs
+++ b/crates/ui-egui/tests/smoke.rs
@@ -2089,6 +2089,31 @@ fn the_front_door_works_on_a_project_the_person_already_has() {
h.run_steps(2);
}
+/// A Godot project's files decide its engine: Start gets Godot, never the Unity that a request
+/// reading as a game would.
+#[test]
+fn work_on_my_project_builds_with_the_engine_its_folder_uses() {
+ use craft_anything_engines::game::{Builder, Inventory};
+ use craft_anything_ui_egui::state::Modal;
+ let mine = tempfile::tempdir().unwrap();
+ std::fs::write(mine.path().join("project.godot"), "").unwrap();
+ let mut h = harness_sized(egui::vec2(1280.0, 1120.0), || {
+ let mut a = demo::app(demo::engine(Mode::Beginner, true));
+ a.game_engines = Some(Inventory::default());
+ a
+ });
+ h.run_steps(3);
+ h.get_by_label("Work on my project").click();
+ h.run_steps(3);
+ craft_anything_ui_egui::folders::picked_own(h.state_mut(), mine.path().to_path_buf());
+ h.state_mut().state.make.request = "Fix my game's jump".into();
+ h.run_steps(3);
+ assert_eq!(h.state().state.make.folder_stack.as_deref(), Some("Godot"));
+ h.get_by_label("Start").click();
+ h.run_steps(4);
+ assert_eq!(h.state().state.modal, Some(Modal::Engine(Builder::Godot)));
+}
+
#[test]
fn settings_list_projects_from_more_folders_and_remove_them_from_the_list_only() {
use craft_anything_engine::workspace::{TargetRef, Workspace};
diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md
index de5c57bd..69ba2ccf 100644
--- a/docs/ROADMAP.md
+++ b/docs/ROADMAP.md
@@ -170,6 +170,9 @@ only when it's green and a maintainer has fully reviewed it, code as well as wor
- [ ] `a_helper_is_judged_by_whether_it_runs` (ai crate) sometimes fails when several crates'
tests run at once and passes alone: it writes a script and runs it straight away, which a
busy machine can refuse while another test's child still holds the file open
+- [ ] `a_remote_query_expands_only_the_remote_working_directory` (ai crate) fails on a Mac: the
+ temp folder is `/var/…`, a link to `/private/var/…`, and the shell's `$PWD` gives the second.
+ Compare with the folder's canonical path
- [ ] Revisit the two advisory exceptions in `deny.toml`: `rsa` (no fix; we only verify with public
keys) when rsa 0.10 lands, and unmaintained `zbus_names`/`zvariant` (Linux-only via keyring
and accesskit) when those move on. `deny.toml`'s comments say this is tracked in R0.3: point
@@ -574,12 +577,16 @@ Owner: open · Status: in progress
- [x] The website check's missing-site note names every place `site_dir` accepts (dist/, build/,
out/, or a plain index.html with no package.json) and the app's real place, "app/" or "the
project folder" (#494)
-- [ ] A project edited in place (Work on my project, or `rebuild --existing edit`) gets its stack
- from the request's words, as a new one does: a request that reads as a game asks for Unity
- unless it names another engine, even when the folder is a Godot project, and a run with no
- stack picks the kind's default (`kinds.choose`); `stacks::used_in` reads only package.json,
- after the first turn. Read the stack from the folder's own files first (`project.godot`,
- `Cargo.toml`, `pyproject.toml`, `package.json`…)
+- [x] A project edited in place (Work on my project, or `rebuild --existing edit`) keeps what its
+ files are built with, unless the request names another stack: an engine's project file, then
+ package.json and Cargo.toml dependencies, then `found_by` in `stacks.toml`, and a project
+ whose dependencies name no stack there is left to the builder. A request that read as a game
+ used to ask for Unity even in a Godot project, and an app got the kind's default
+ — claimed: xerenon, branch bugfix/r2.7-stack-from-files; PR #755
+- [ ] What a project edited in place is checked by: its kind still comes from the request's words,
+ so a website or a Python tool whose request doesn't say so is an app, and the app check then
+ fails with "There's no built program to start yet" (read in the code, not run). Let the
+ folder's stack decide the kind too, and say what "ready" means for a person's own project
### R2.8 Clean room means clean room
Owner: maintainers · Status: in progress
diff --git a/docs/STATUS.md b/docs/STATUS.md
index d6f05425..f66231b9 100644
--- a/docs/STATUS.md
+++ b/docs/STATUS.md
@@ -46,7 +46,7 @@ workspace clippy, layers, fmt and the secret scan of all history were clean. Chi
| WebAssembly tag interfaces | `formats_wasm_compare` resolves retained imported and defined tag exports to their declared parameter types. Identical unresolved or invalid diagnostics may still count as unchanged; those counts do not establish interface compatibility, and invalid/partial limitations remain present | Synthetic core modules with tag changes and re-exports, mixed index spaces, import/tag limits, and missing or non-function type references; formats and engine tests. No real module corpus or WebAssembly execution was used for this correction |
| Questions and approvals | A file inbox per project; `core_person_ask`, `core_action_approve` and MCP consent requests become cards in the app | Cross-handle round-trip tests, a full approval round trip through the engine |
| Runtime assets in pinned builds | Frozen and light pins, size estimates and project copies keep runtime files in `obj` folders. An `obj` directory beside a regular C#, F# or Visual Basic project file is still recognised as compiler output; ambiguous folders are retained. New pins record the direct-launch program relative to the copy so a newer helper cannot replace it; older pins retain discovery behavior | Synthetic filesystem tests cover both pin modes, model bytes, compiler-output controls and project duplication. A Linux tool-level regression starts temporary scripts through `project_pin_open`, with a newer `Build/obj/helper`, and verifies the originally selected program and its output; a missing recorded program is refused. No real pinned application was launched for this correction |
-| Desktop app | Simple mode: sidebar with New project and the project history (kept across restarts); New project makes something, works on a project the person already has (Work on my project: its folder's files are the app, edited in place without a question, and the project takes the folder's name), or just looks inside an app or file, a website or a game's files; a Game files screen (a game's archives; pictures from Unreal paks, Unity .assets files and Unity bundles saved as PNG after the person confirms they may unpack the game; uncompressed textures and the block formats DXT1, DXT5 and BC4–BC7), make prompt with picture attachments (picked, dropped, or pasted with Ctrl+V, shown as picture tiles) and, for anything recreated, a Clean room / Deep choice (also in the title bar; in Clean room, Just look inside, Game files, opening a file and the workbench ask for Deep mode instead), project screen (steps with the time spent and the AI cost and tokens of every build, saved in the project's usage.json by the run (a coding agent's figure is shown as an estimate at API prices, not the bill), what the build is on now and its activity as it arrives (kept in `build-activity.log`), pinned builder checklist, feed, question and approval cards, a Continue card when a build was paused or stopped part-way (the app or computer closed; the project shows Interrupted) that carries on the builder's own session instead of starting over, and "It's done" beside Continue or Try again to keep the build as it is (`project_build_finish`), checks with screenshots and the requirements not met yet, the builder's open questions, preview, play, folder, follow-ups while it builds, which Claude Code takes at its next step; Up in the prompt box takes back the last note still waiting). Projects can start in a folder the person picks, whose files are either the app, edited in place, or material to start from (asked, or the answer remembered in Settings), and are listed from any number of folders (`project_folders`, `project_list`, `rebuild --project-folder`). Make says which AI builds ("Built by": automatic, or any AI that can build, by name); a pick stays with the project and builds its later changes. With nothing to build with, Start offers the coding agents found on the computer. Settings → AI turns an AI off or removes it, and sets how hard the Claude API or Claude Code thinks (every Claude level, low to max; also `ai effort` in the CLI). Each Claude Code AI can keep its sign-in in a folder of its own (its `CLAUDE_CONFIG_DIR`, so its own account; `ai folder` in the CLI, a folder on that computer over SSH), used for its runs, its sign-in check and its kept session, and Add another adds a second Claude Code for a second account. In the prompt box, Up at the very start and Down at the very end go through earlier prompts when no note is waiting. Questions about a build ("Just ask" under the prompt box, or a message starting with `/btw`, the first slash command; `rebuild_question_ask`) are answered in the conversation, where each folds away and is kept in the project, without a build or a round and changing nothing: Claude Code answers from a read-only copy of the builder's own session. Under each project's prompt box, "Builder's questions: Ask me / Decide yourself" chooses whether the builder's questions come to the person as cards or are decided by the builder, which says what it chose (`project_questions_set`; the default is in Settings and follows Auto mode until picked). Projects can be renamed, duplicated and deleted (right-click in the sidebar, or the project's page; a delete keeps the person's own files). A build can be pinned (Pin this build on its page, or `project_pin_*` from the CLI and MCP): a frozen copy in the project's pinned/ folder (the default) or a light one that shares dependencies and media with the project through hard links (each one's size shown first), opened from the sidebar's collapsible Pinned section (icons with a running dot when folded); a pin or Play runs once per folder unless another copy is asked for, and a start that quits at once says so with its last output. Typed drafts survive a restart. In a narrow window the sidebar folds to icons and the project's details move above its feed; messages float over the screen and errors stay until dismissed. Advanced mode: workbench with every panel wired to real tools, as a screen beside the projects (builds and their questions stay a click away) | UI unit and smoke tests (egui_kittest), offscreen snapshots of every screen |
+| Desktop app | Simple mode: sidebar with New project and the project history (kept across restarts); New project makes something, works on a project the person already has (Work on my project: its folder's files are the app, edited in place without a question, and the project takes the folder's name), or just looks inside an app or file, a website or a game's files; a Game files screen (a game's archives; pictures from Unreal paks, Unity .assets files and Unity bundles saved as PNG after the person confirms they may unpack the game; uncompressed textures and the block formats DXT1, DXT5 and BC4–BC7), make prompt with picture attachments (picked, dropped, or pasted with Ctrl+V, shown as picture tiles) and, for anything recreated, a Clean room / Deep choice (also in the title bar; in Clean room, Just look inside, Game files, opening a file and the workbench ask for Deep mode instead), project screen (steps with the time spent and the AI cost and tokens of every build, saved in the project's usage.json by the run (a coding agent's figure is shown as an estimate at API prices, not the bill), what the build is on now and its activity as it arrives (kept in `build-activity.log`), pinned builder checklist, feed, question and approval cards, a Continue card when a build was paused or stopped part-way (the app or computer closed; the project shows Interrupted) that carries on the builder's own session instead of starting over, and "It's done" beside Continue or Try again to keep the build as it is (`project_build_finish`), checks with screenshots and the requirements not met yet, the builder's open questions, preview, play, folder, follow-ups while it builds, which Claude Code takes at its next step; Up in the prompt box takes back the last note still waiting). Projects can start in a folder the person picks, whose files are either the app, edited in place (its stack read from those files unless the request names another), or material to start from (asked, or the answer remembered in Settings), and are listed from any number of folders (`project_folders`, `project_list`, `rebuild --project-folder`). Make says which AI builds ("Built by": automatic, or any AI that can build, by name); a pick stays with the project and builds its later changes. With nothing to build with, Start offers the coding agents found on the computer. Settings → AI turns an AI off or removes it, and sets how hard the Claude API or Claude Code thinks (every Claude level, low to max; also `ai effort` in the CLI). Each Claude Code AI can keep its sign-in in a folder of its own (its `CLAUDE_CONFIG_DIR`, so its own account; `ai folder` in the CLI, a folder on that computer over SSH), used for its runs, its sign-in check and its kept session, and Add another adds a second Claude Code for a second account. In the prompt box, Up at the very start and Down at the very end go through earlier prompts when no note is waiting. Questions about a build ("Just ask" under the prompt box, or a message starting with `/btw`, the first slash command; `rebuild_question_ask`) are answered in the conversation, where each folds away and is kept in the project, without a build or a round and changing nothing: Claude Code answers from a read-only copy of the builder's own session. Under each project's prompt box, "Builder's questions: Ask me / Decide yourself" chooses whether the builder's questions come to the person as cards or are decided by the builder, which says what it chose (`project_questions_set`; the default is in Settings and follows Auto mode until picked). Projects can be renamed, duplicated and deleted (right-click in the sidebar, or the project's page; a delete keeps the person's own files). A build can be pinned (Pin this build on its page, or `project_pin_*` from the CLI and MCP): a frozen copy in the project's pinned/ folder (the default) or a light one that shares dependencies and media with the project through hard links (each one's size shown first), opened from the sidebar's collapsible Pinned section (icons with a running dot when folded); a pin or Play runs once per folder unless another copy is asked for, and a start that quits at once says so with its last output. Typed drafts survive a restart. In a narrow window the sidebar folds to icons and the project's details move above its feed; messages float over the screen and errors stay until dismissed. Advanced mode: workbench with every panel wired to real tools, as a screen beside the projects (builds and their questions stay a click away) | UI unit and smoke tests (egui_kittest), offscreen snapshots of every screen |
| CLI | Every tool, `--deep` or `--clean-room` for one run (never saved), `rebuild` (including `--continue-in`, and `--resume` to carry on a stopped build), `mcp --inbox`, `ai`, `setup`, `doctor`, `report` | CLI integration tests |
| SQLite database files (`db_sqlite_show`) | A rowid alias column (`INTEGER PRIMARY KEY`, including the table-constraint form) shows the rowid; `DESC`, non-`INTEGER` and composite keys keep their stored values | Hand-built fixtures; generated files compared with the official SQLite library |
| SQLite WITHOUT ROWID tables | Read from the index b-tree, interior records and overflow included; rows in primary-key order, values in declaration order, `rowid` null | Hand-built fixtures; generated files compared with the official SQLite library |
diff --git a/docs/extending.md b/docs/extending.md
index 1b337d0a..1aa74aa8 100644
--- a/docs/extending.md
+++ b/docs/extending.md
@@ -10,7 +10,7 @@ place to add yours. Follow `AGENTS.md` (never crash, layers, external programs t
| A tool from a higher layer | that crate, e.g. `crates/ai/src/rebuild/tools.rs` | Static `ToolSpec`s passed to `Engine::shared(session, extra)`; reach the engine through `ctx.session.ext.get::<EngineRef>()`. Never block a tool on work that calls back into the engine: start it and return. |
| A kind of thing to make | `crates/ai/src/rebuild/kinds/` | Implement `TargetKind` (detection score, default stack, brief sections, checks, refine message, the app's words) and `KindRegistry::register` it. |
| A way to judge a build | `crates/ai/src/rebuild/kinds/` | Implement `Check` (`run(&mut CheckCx) -> CheckResult`; `applies` to skip it in some runs, or wrap it in `DeepOnly`); return it from your kind's `checks`. Decide on `passed`/`similarity`, never on text. |
-| A stack | `crates/ai/src/rebuild/stacks.toml` | One `[[stack]]` entry: name, the builder's steps, the phrases that ask for it, its engine, the package.json dependencies that show a build uses it. A component or styling library is a `[[library]]` entry (name, phrases, the stacks it works with, steps). |
+| A stack | `crates/ai/src/rebuild/stacks.toml` | One `[[stack]]` entry: name, the builder's steps, the phrases that ask for it, its engine, the package.json or Cargo.toml dependencies that show a build uses it, the files that show a person's own folder is built with it. A component or styling library is a `[[library]]` entry (name, phrases, the stacks it works with, steps). |
| A coding agent | `crates/ai/src/cli_agents/adapters.rs` | Implement `AgentAdapter` (args, required flags, stream parsing, resume, sign-in check) and register it in `AgentAdapters`. Use `has_model_catalog`, `model_catalog`, `validate_model` and the shared `AgentModel`/`ModelContext` picker and tools for model/thinking selection; set `model_catalog_depends_on_selection` when metadata depends on the selected model. ACP agents also get a row in `cli_agents::acp::ACP_AGENTS`; if their ACP mode takes the backend's model, a row in `ACP_MODEL_FLAGS` too. Override ACP startup options, process setup or `requires_acp` when needed; verify actual tool exposure, not only startup. |
| An asset provider | `crates/engines/src/assets/` | Implement `AssetProvider` (`key_env` names its environment variable); add its models and prices to `assets.toml`. Its key is its own: `assets_key_set` with `provider`, kept as `assets:<id>`. |
| An external engine | `crates/engines/src/table.rs` | One `ExternalEngine` entry (exes, known paths, what it's for, install pins with SHA-256 checked against the publisher), plus a `tool_paths!` id in `settings.rs` if people can point at their own install. |