Skip to content

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

Rust

Check a person's own project by its own build and tests, in any language (#760)

Aek42f459ccf918
diff --git a/crates/ai/src/rebuild/brief.rs b/crates/ai/src/rebuild/brief.rs
index 15ae226f..25ab6bdb 100644
--- a/crates/ai/src/rebuild/brief.rs
+++ b/crates/ai/src/rebuild/brief.rs
@@ -40,10 +40,16 @@ pub(super) fn stack_steps(stack: &str, editor: Option<&Path>) -> String {
}
/// The stack's steps, then those of each library the request asks for that works with it
-/// ("use nextjs and shadcn" adds shadcn/ui's).
-fn stack_and_library_steps(request: &str, stack: &str, editor: Option<&Path>) -> String {
- let mut s = stack_steps(stack, editor);
- for l in stacks::libraries_for(request, stack) {
+/// ("use nextjs and shadcn" adds shadcn/ui's). A stack's steps make a new project (Unity's say to
+/// write a build script into it), so a person's own project keeps to what it has.
+fn stack_and_library_steps(m: &craft_anything_engine::workspace::Manifest, editor: Option<&Path>) -> String {
+ let mut s = if m.own_project() {
+ let editor = editor.map(|e| format!(" The editor is {}.", e.display())).unwrap_or_default();
+ format!("keep to what the project already uses.{editor}")
+ } else {
+ stack_steps(&m.stack, editor)
+ };
+ for l in stacks::libraries_for(&m.request, &m.stack) {
s.push(' ');
s.push_str(&l.steps);
}
@@ -81,14 +87,15 @@ pub(super) fn brief(kind: &dyn TargetKind, cx: &BriefCx, extra: Option<&str>) ->
}
TargetRef::None => "There is no target to study.",
};
+ let goal = if m.own_project() { "what their request asks of the project in this folder" } else { kind.goal() };
let mut s = format!(
"You are the builder inside Craft Anything, rebuilding software for a person who doesn't code.\n\n\
Their request: \"{}\"\nTarget: {target}\nYour working folder is the project workspace ({}).\n\n{capture}\n\n\
What to build: {}.\n\nHow to build it, unless their request says otherwise: {}\n\n{}\n\n{RULES}",
m.request,
ws.root.display(),
- kind.goal(),
- stack_and_library_steps(&m.request, &m.stack, cx.editor),
+ goal,
+ stack_and_library_steps(m, cx.editor),
steps(cx.deep),
);
for section in kind.brief_sections(cx) {
@@ -115,8 +122,9 @@ pub(super) fn start_files_note(m: &craft_anything_engine::workspace::Manifest) -
let names = m.start_files.join(", ");
let own = craft_anything_engine::workspace::OWN_NAMES.join(", ");
Some(if m.app_in_root {
+ let checked = if m.own_project() { " It's checked by running its own build and tests: add nothing to it for Craft Anything's sake." } else { "" };
format!(
- "This project's app is the person's own folder, the project workspace itself, and it already has their files ({names}). Wherever these instructions say app/, use the workspace folder itself (./): work on their files in place, keep what works and change only what the request needs; never start over, delete or replace their work, and don't create an app/ folder. Craft Anything keeps its own records beside their files ({own}): leave those alone."
+ "This project's app is the person's own folder, the project workspace itself, and it already has their files ({names}). Wherever these instructions say app/, use the workspace folder itself (./): work on their files in place, keep what works and change only what the request needs; never start over, delete or replace their work, and don't create an app/ folder. Craft Anything keeps its own records beside their files ({own}): leave those alone.{checked}"
)
} else {
format!(
@@ -259,7 +267,7 @@ pub(super) fn pictures_note(ws: &Workspace, kind: &dyn TargetKind) -> Option<Str
"The person added {} picture(s) of the original: {names}. They show the result they expect. Open every one with the Read tool before you plan, and match what they show: the camera or view, the on-screen layout (menus, HUD, panels) and where each part sits, the colours and lighting, the look of surfaces and characters, and the proportions and scale. Make your own artwork in that style; don't trace or copy logos, characters or other artwork from them.",
pics.len()
);
- if kind.self_screenshots() {
+ if kind.self_screenshots() && !ws.manifest.own_project() {
s.push_str(" After each build, run the program with --screenshot to a file inside app/ (for example app/shots/now.png), open that picture with Read, compare it with each picture of the original, and fix the biggest differences first.");
}
Some(s)
diff --git a/crates/ai/src/rebuild/check.rs b/crates/ai/src/rebuild/check.rs
index b5433c3a..c7537a72 100644
--- a/crates/ai/src/rebuild/check.rs
+++ b/crates/ai/src/rebuild/check.rs
@@ -1,26 +1,110 @@
//! Building a project with its own tools (cargo, npm, or the game engine's), for [`BuildCheck`].
-//! A plain static site has no build, and passes as it is.
+//! A plain static site has no build, and passes as it is. A person's own project builds and tests
+//! itself the way its toolchain says.
use super::*;
+/// Run a step of a project's build in `app`: whether it succeeded, and what it printed.
+fn run_in(app: &Path, prog: &Path, args: &[String], minutes: u64, stop: &CancelToken) -> Result<(bool, String), String> {
+ let s = stop.clone();
+ craft_anything_platform::Process::new(prog)
+ .args(args)
+ .cwd(app)
+ .timeout(Duration::from_secs(minutes * 60))
+ // Engines go quiet for long stretches (shader compiles, cooking, a cold cargo build).
+ .idle_timeout(Duration::from_secs(60 * 60))
+ .stdout_cap(8 << 20)
+ .cancel_when(move || s.is_cancelled())
+ .run()
+ .map(|o| (o.success, format!("{}{}", o.stdout_text(), o.stderr_text())))
+ .map_err(|e| e.message)
+}
+
+/// Run one of a toolchain's commands in `app`.
+fn run_tool(app: &Path, tool: &stacks::Toolchain, command: &[String], minutes: u64, stop: &CancelToken) -> Result<(bool, String), String> {
+ let Some((program, args)) = command.split_first() else { return Err(format!("{} has no such command.", tool.name)) };
+ let here = |p: &&String| cfg!(windows) == [".bat", ".cmd", ".exe"].iter().any(|e| p.ends_with(e));
+ let local = tool.local_programs.iter().filter(here).map(|p| app.join(p)).find(|p| p.is_file());
+ let system = tool.windows_program.as_ref().filter(|_| cfg!(windows)).unwrap_or(program);
+ run_in(app, local.as_deref().unwrap_or(Path::new(system)), args, minutes, stop)
+}
+
+/// What a Unity without a licence prints, and what to tell the person.
+const UNITY_NO_LICENCE: &str = "No valid Unity Editor license";
+const UNITY_LICENCE_FIX: &str = "Unity needs its free licence first: open Unity Hub, sign in and accept the Personal licence, then try again.";
+
+/// A person's own project: its engine's build, else its toolchain's, else a static site. One we
+/// know no way to build isn't a failure, and the note says nothing ran.
+pub(super) fn own_build_check(app: &Path, place: &str, stack: &str, editor: Option<&Path>, stop: &CancelToken) -> (bool, String) {
+ let engine = engine_for(stack, app);
+ if let (Some(game::Builder::Unity), Some(ed)) = (engine, editor) {
+ return own_unity_check(app, ed, stop);
+ }
+ match stacks::toolchain_in(app).filter(|_| engine.is_none()) {
+ Some(tool) => own_build(app, tool, stop),
+ None if engine.is_some() || static_site(app) => build_check(app, place, stack, editor, stop),
+ None => (true, "Nothing was built: Craft Anything doesn't know how to build this kind of project.".into()),
+ }
+}
+
+/// How a Unity project we didn't make is opened: in batch mode, which compiles its scripts. There's
+/// no `CraftBuild.Build` to call, as there is in one we made ([`build_check`]).
+fn own_unity_args(app: &Path) -> Vec<String> {
+ ["-batchmode", "-quit", "-nographics", "-projectPath", &app.display().to_string(), "-logFile", "-"].map(String::from).to_vec()
+}
+
+fn own_unity_check(app: &Path, editor: &Path, stop: &CancelToken) -> (bool, String) {
+ match run_in(app, editor, &own_unity_args(app), 4 * 60, stop) {
+ Ok((_, out)) if out.contains(UNITY_NO_LICENCE) => (false, UNITY_LICENCE_FIX.into()),
+ Ok((true, _)) => (true, "The Unity project opened and its scripts compiled.".into()),
+ Ok((false, out)) => (false, format!("Build failed: {}", error_lines(&out))),
+ Err(e) => (false, format!("Couldn't run the build: {e}")),
+ }
+}
+
+fn own_build(app: &Path, tool: &stacks::Toolchain, stop: &CancelToken) -> (bool, String) {
+ match run_tool(app, tool, &tool.build, 2 * 60, stop) {
+ Ok((true, _)) => (true, format!("`{}` passed.", tool.build.join(" "))),
+ Ok((false, out)) => (false, format!("Build failed: {}", error_lines(&out))),
+ Err(e) => (false, format!("Couldn't run the build: {e}")),
+ }
+}
+
+/// A person's own project: run its tests. Output that says none ran isn't a failure, and neither
+/// is a project we know no way to test, and the note says so.
+pub(super) fn own_tests_check(app: &Path, tool: Option<&stacks::Toolchain>, stop: &CancelToken) -> (bool, String) {
+ let Some(tool) = tool else { return (true, "No tests ran: Craft Anything doesn't know how to test this kind of project.".into()) };
+ let says_none = |text: &str| tool.no_tests.iter().find(|n| text.contains(n.as_str())).cloned();
+ if let Some(name) = &tool.test_script {
+ // shortcut: `workspaces=true` in .npmrc can give a root with no script tests; they aren't
+ // run, and the note says so. Read .npmrc if that turns up.
+ let script = craft_anything_engine::outputs::npm_script(app, name).unwrap_or_default();
+ if script.is_empty() || tool.no_tests.iter().any(|n| n == script.trim()) {
+ return (true, format!("No tests ran: package.json has no `{name}` script to run."));
+ }
+ }
+ match run_tool(app, tool, &tool.test, 30, stop) {
+ Ok((true, _)) => (true, format!("`{}` passed.", tool.test.join(" "))),
+ Ok((false, out)) => match says_none(&out).filter(|_| tool.test_script.is_none()) {
+ Some(why) => (true, format!("No tests ran: {}.", why.trim_end_matches('.'))),
+ None => (false, format!("The project's tests failed:\n{}", last_lines(&out, 20))),
+ },
+ Err(e) => (false, format!("Couldn't run the tests: {e}")),
+ }
+}
+
+/// The last `n` lines with something on them: where a test run sums up what failed.
+fn last_lines(out: &str, n: usize) -> String {
+ let mut lines: Vec<&str> = out.lines().rev().filter(|l| !l.trim().is_empty()).take(n).collect();
+ lines.reverse();
+ lines.join("\n")
+}
+
/// For non-website builds: run the project's build (its engine's own, for Unity, Unreal and
/// Godot) and report whether it succeeded, with a note (the first error lines when it didn't).
/// `place` says where `app` is, for messages (`Workspace::app_place`).
pub(super) fn build_check(app: &Path, place: &str, stack: &str, editor: Option<&Path>, stop: &CancelToken) -> (bool, String) {
- let run = |prog: &Path, args: &[String], minutes: u64| {
- let s = stop.clone();
- craft_anything_platform::Process::new(prog)
- .args(args)
- .cwd(app)
- .timeout(Duration::from_secs(minutes * 60))
- // Engines go quiet for long stretches (shader compiles, cooking, a cold cargo build).
- .idle_timeout(Duration::from_secs(60 * 60))
- .stdout_cap(8 << 20)
- .cancel_when(move || s.is_cancelled())
- .run()
- .map(|o| (o.success, format!("{}{}", o.stdout_text(), o.stderr_text())))
- .map_err(|e| format!("Couldn't run the build: {}", e.message))
- };
+ let run = |prog: &Path, args: &[String], minutes: u64| run_in(app, prog, args, minutes, stop).map_err(|e| format!("Couldn't run the build: {e}"));
let app_s = app.display().to_string();
let built = || packaged_program(&app.join("Build")).is_some();
let result: Result<(bool, String), String> = match (engine_for(stack, app), editor) {
@@ -29,13 +113,7 @@ pub(super) fn build_check(app: &Path, place: &str, stack: &str, editor: Option<&
return (false, missing(app, place, format!("No Unity project found in {place} yet.")));
}
let args = ["-batchmode", "-quit", "-nographics", "-projectPath", &app_s, "-executeMethod", "CraftBuild.Build", "-logFile", "-"].map(String::from);
- run(ed, &args, 4 * 60).map(|(ok, out)| {
- if out.contains("No valid Unity Editor license") {
- (false, "Unity needs its free licence first: open Unity Hub, sign in and accept the Personal licence, then try again.".into())
- } else {
- (ok && built(), out)
- }
- })
+ run(ed, &args, 4 * 60).map(|(ok, out)| if out.contains(UNITY_NO_LICENCE) { (false, UNITY_LICENCE_FIX.into()) } else { (ok && built(), out) })
}
(Some(game::Builder::Unreal), Some(ed)) => {
let Some(uproject) = uproject(app) else {
@@ -164,6 +242,113 @@ pub(super) fn error_lines(out: &str) -> String {
mod tests {
use super::*;
+ /// A stand-in toolchain whose build and tests are this shell line.
+ #[cfg(unix)]
+ fn stand_in(line: &str, no_tests: &[&str]) -> stacks::Toolchain {
+ let command = ["sh", "-c", line].map(String::from).to_vec();
+ stacks::Toolchain { build: command.clone(), test: command, no_tests: no_tests.iter().map(|s| s.to_string()).collect(), ..Default::default() }
+ }
+
+ #[cfg(unix)]
+ #[test]
+ fn a_persons_own_tests_decide_and_no_tests_is_no_failure() {
+ let (d, stop) = (tempfile::tempdir().unwrap(), CancelToken::default());
+ let tests = |tool: &stacks::Toolchain| own_tests_check(d.path(), Some(tool), &stop);
+ assert!(tests(&stand_in("exit 0", &[])).0);
+ let (passed, note) = tests(&stand_in("echo 'adds: 4 is not 5'; echo; echo '1 failed'; exit 1", &[]));
+ assert!(!passed && note.ends_with("adds: 4 is not 5\n1 failed"), "the summary, not only lines saying error: {note}");
+ let (passed, note) = tests(&stand_in("echo no tests here; exit 5", &["no tests here"]));
+ assert!(passed && note.starts_with("No tests ran"), "{note}");
+ let missing = stacks::Toolchain { test: vec!["no-such-program-here".into()], ..Default::default() };
+ let (passed, note) = tests(&missing);
+ assert!(!passed && note.starts_with("Couldn't run the tests"), "{note}");
+ let (passed, note) = own_tests_check(d.path(), None, &stop);
+ assert!(passed && note.starts_with("No tests ran"), "{note}");
+ }
+
+ #[cfg(unix)]
+ #[test]
+ fn a_projects_own_copy_of_the_program_comes_first() {
+ let (d, stop) = (tempfile::tempdir().unwrap(), CancelToken::default());
+ std::os::unix::fs::symlink("/bin/sh", d.path().join("own-sh")).unwrap();
+ std::fs::write(d.path().join("own-sh.bat"), "not for this system").unwrap();
+ let test = ["no-such-program-here", "-c", "echo 'error: from its own copy'; exit 1"].map(String::from).to_vec();
+ let tool = stacks::Toolchain { test, local_programs: vec!["not-here".into(), "own-sh.bat".into(), "own-sh".into()], ..Default::default() };
+ let (passed, note) = own_tests_check(d.path(), Some(&tool), &stop);
+ assert!(!passed && note.contains("from its own copy"), "{note}");
+ }
+
+ /// The table's own words, on what the real make (3.81; 4.x quotes alike) and npm (11) print.
+ #[cfg(unix)]
+ #[test]
+ fn only_the_tests_own_absence_means_no_tests() {
+ let (d, stop) = (tempfile::tempdir().unwrap(), CancelToken::default());
+ let named_by = |file: &str| {
+ let f = tempfile::tempdir().unwrap();
+ std::fs::write(f.path().join(file), "").unwrap();
+ stacks::toolchain_in(f.path()).expect("the table has it")
+ };
+ let printing = |tool: &stacks::Toolchain, line: &str| {
+ let test = ["sh", "-c", "printf '%s\\n' \"$1\"; exit 2", "sh", line].map(String::from).to_vec();
+ own_tests_check(d.path(), Some(&stacks::Toolchain { test, ..tool.clone() }), &stop).0
+ };
+ let (make, node) = (named_by("Makefile"), named_by("package.json"));
+ assert!(printing(make, "make: *** No rule to make target `test'. Stop."));
+ assert!(printing(make, "make: *** No rule to make target 'test'. Stop."));
+ assert!(!printing(make, "make: *** No rule to make target `fixture.txt', needed by `test'. Stop."), "a prerequisite is a failure");
+ assert!(!printing(make, "make: *** No rule to make target 'fixture.txt', needed by 'test'. Stop."));
+ assert!(!printing(make, "make[1]: *** No rule to make target `test'. Stop."), "a make it runs is a failure");
+ std::fs::write(d.path().join("package.json"), r#"{"scripts":{"test":"npm test --workspaces"}}"#).unwrap();
+ assert!(!printing(node, "npm error Missing script: \"test\""), "one package of several, maybe beside a real failure");
+ assert!(!printing(node, "npm error Missing script: \"verify\""), "a script its tests call is a failure");
+ }
+
+ #[test]
+ fn a_node_project_says_in_its_package_json_whether_it_has_tests() {
+ let (d, stop) = (tempfile::tempdir().unwrap(), CancelToken::default());
+ std::fs::write(d.path().join("package.json"), "").unwrap();
+ let table = stacks::toolchain_in(d.path()).expect("the table has Node.js");
+ let node = stacks::Toolchain { test: vec!["no-such-program-here".into()], ..table.clone() };
+ for json in [r#"{"name":"x"}"#, r#"{"scripts":{"test":"echo \"Error: no test specified\" && exit 1"}}"#] {
+ std::fs::write(d.path().join("package.json"), json).unwrap();
+ let (passed, note) = own_tests_check(d.path(), Some(&node), &stop);
+ assert!(passed && note.starts_with("No tests ran"), "nothing is started: {note}");
+ }
+ let real = r#"{"scripts":{"test":"jest && echo 'no test specified for integration'"}}"#;
+ std::fs::write(d.path().join("package.json"), real).unwrap();
+ let (passed, note) = own_tests_check(d.path(), Some(&node), &stop);
+ assert!(!passed && note.starts_with("Couldn't run the tests"), "it's started: {note}");
+ }
+
+ #[test]
+ fn a_persons_own_unity_project_is_opened_not_built_with_our_script() {
+ let args = own_unity_args(Path::new("/x/game"));
+ assert!(args.iter().any(|a| a == "-batchmode") && args.iter().any(|a| a == "/x/game"), "{args:?}");
+ assert!(!args.iter().any(|a| a == "-executeMethod" || a.contains("CraftBuild")), "{args:?}");
+ }
+
+ #[cfg(unix)]
+ #[test]
+ fn a_persons_own_build_is_judged_by_its_toolchain() {
+ let (d, stop) = (tempfile::tempdir().unwrap(), CancelToken::default());
+ assert!(own_build(d.path(), &stand_in("exit 0", &[]), &stop).0);
+ let (passed, note) = own_build(d.path(), &stand_in("echo 'error: no such file'; exit 2", &[]), &stop);
+ assert!(!passed && note.contains("no such file"), "{note}");
+ }
+
+ #[test]
+ fn a_persons_own_project_with_nothing_to_build_says_so() {
+ let stop = CancelToken::default();
+ let notes = tempfile::tempdir().unwrap();
+ std::fs::write(notes.path().join("notes.md"), "ideas").unwrap();
+ let (passed, note) = own_build_check(notes.path(), "the project folder", stacks::BUILDERS_CHOICE, None, &stop);
+ assert!(passed && note.starts_with("Nothing was built"), "{note}");
+ let site = tempfile::tempdir().unwrap();
+ std::fs::write(site.path().join("index.html"), "<p>hi</p>").unwrap();
+ let (passed, note) = own_build_check(site.path(), "the project folder", "Plain HTML and CSS", None, &stop);
+ assert!(passed && note.contains("static site"), "{note}");
+ }
+
#[test]
fn the_build_follows_what_was_built_not_the_stack_picked_first() {
let d = tempfile::tempdir().unwrap();
diff --git a/crates/ai/src/rebuild/kinds/app.rs b/crates/ai/src/rebuild/kinds/app.rs
index 37da40f7..a7c1fde5 100644
--- a/crates/ai/src/rebuild/kinds/app.rs
+++ b/crates/ai/src/rebuild/kinds/app.rs
@@ -46,6 +46,9 @@ impl TargetKind for AppKind {
fn brief_sections(&self, cx: &BriefCx) -> Vec<String> {
let mut s = Vec::new();
+ if cx.ws.manifest.own_project() {
+ return s;
+ }
if cx.deep && matches!(cx.ws.manifest.target, TargetRef::Local { .. }) {
s.push(decompile_note(false, cx.ghidra).trim_start().to_string());
s.push(mechanics::MECHANICS_CONTRACT.to_string());
diff --git a/crates/ai/src/rebuild/kinds/game.rs b/crates/ai/src/rebuild/kinds/game.rs
index 22075647..2984d144 100644
--- a/crates/ai/src/rebuild/kinds/game.rs
+++ b/crates/ai/src/rebuild/kinds/game.rs
@@ -78,6 +78,9 @@ impl TargetKind for GameKind {
}
// Paid, so only when the person turned it on for this project and a key is set up.
let generated = cx.assets && cx.ws.manifest.generate_assets;
+ if cx.ws.manifest.own_project() {
+ return generated.then(|| assets_note(cx.ws, cx.image_model)).into_iter().collect();
+ }
let mut s = vec![game_steps(cx.deep, cx.ghidra, matches!(target, TargetRef::Local { .. }), generated)];
if generated {
s.push(assets_note(cx.ws, cx.image_model));
diff --git a/crates/ai/src/rebuild/kinds/mod.rs b/crates/ai/src/rebuild/kinds/mod.rs
index 24fbd858..87a28567 100644
--- a/crates/ai/src/rebuild/kinds/mod.rs
+++ b/crates/ai/src/rebuild/kinds/mod.rs
@@ -6,6 +6,7 @@
mod app;
mod game;
pub mod mechanics;
+pub mod own;
pub mod plugin_check;
pub mod runs;
pub mod screenshot;
@@ -184,7 +185,8 @@ impl Worker {
.into_iter()
.filter(|c| c.kinds.is_empty() || c.kinds.iter().any(|k| k == kind.id()))
.map(|check| Box::new(plugin_check::PluginJudge { check, kind: kind.id() }) as Box<dyn Check>);
- for c in kind.checks(ws).into_iter().chain(plugin_checks) {
+ let checks = if ws.manifest.own_project() { own::checks() } else { kind.checks(ws) };
+ for c in checks.into_iter().chain(plugin_checks) {
if !c.applies(&cx) {
continue;
}
diff --git a/crates/ai/src/rebuild/kinds/own.rs b/crates/ai/src/rebuild/kinds/own.rs
new file mode 100644
index 00000000..17c28a55
--- /dev/null
+++ b/crates/ai/src/rebuild/kinds/own.rs
@@ -0,0 +1,42 @@
+//! A person's own project, edited in place with nothing to recreate. There's no original to
+//! compare it with and nothing may be added to it for our sake (no `--screenshot` option, no
+//! mechanics sheet), so it's judged by what it does for itself: its build, then its tests.
+
+use super::super::check::{own_build_check, own_tests_check};
+use super::*;
+
+pub struct OwnBuildCheck;
+
+impl Check for OwnBuildCheck {
+ fn id(&self) -> &'static str {
+ CheckResult::BUILD
+ }
+
+ fn run(&self, cx: &mut CheckCx) -> Result<CheckResult, ToolError> {
+ let (passed, note) = own_build_check(&cx.ws.app_dir(), cx.ws.app_place(), &cx.ws.manifest.stack, cx.editor(), cx.stop());
+ Ok(CheckResult::new(self.id(), cx.round, passed, note))
+ }
+}
+
+pub struct OwnTestsCheck;
+
+impl OwnTestsCheck {
+ pub const ID: &'static str = "own-tests";
+}
+
+impl Check for OwnTestsCheck {
+ fn id(&self) -> &'static str {
+ Self::ID
+ }
+
+ fn run(&self, cx: &mut CheckCx) -> Result<CheckResult, ToolError> {
+ let app = cx.ws.app_dir();
+ let (passed, note) = own_tests_check(&app, stacks::toolchain_in(&app), cx.stop());
+ Ok(CheckResult::new(self.id(), cx.round, passed, note))
+ }
+}
+
+/// What judges a person's own project, whatever kind it is.
+pub(super) fn checks() -> Vec<Box<dyn Check>> {
+ vec![Box::new(OwnBuildCheck), Box::new(OwnTestsCheck)]
+}
diff --git a/crates/ai/src/rebuild/kinds/website.rs b/crates/ai/src/rebuild/kinds/website.rs
index afb45946..db18d94c 100644
--- a/crates/ai/src/rebuild/kinds/website.rs
+++ b/crates/ai/src/rebuild/kinds/website.rs
@@ -147,6 +147,9 @@ impl TargetKind for WebsiteKind {
} else if cx.says(&[" website", " web page", " webpage", " landing page", " site ", " webseite", " internetseite", "网站", "網站", "网页", "網頁"])
{
Some(50)
+ } else if matches!(cx.target, TargetRef::None) && stacks::get(cx.stack).is_some_and(|s| s.site) {
+ // Built as a site with nothing to recreate: "add a contact form" never says website.
+ Some(30)
} else {
None
}
diff --git a/crates/ai/src/rebuild/mod.rs b/crates/ai/src/rebuild/mod.rs
index 4108e0b0..e8652c58 100644
--- a/crates/ai/src/rebuild/mod.rs
+++ b/crates/ai/src/rebuild/mod.rs
@@ -776,7 +776,8 @@ impl Worker {
}
}
round += 1;
- self.step(ws, Step::Check, Status::Checking, "Checking the build against the original…")?;
+ let checking = if ws.manifest.target == TargetRef::None { "Checking the build…" } else { "Checking the build against the original…" };
+ self.step(ws, Step::Check, Status::Checking, checking)?;
let checks = self.checks_with_a_retry(ws, kind, round)?;
ws.manifest.checks.extend(checks.iter().cloned());
ws.manifest.awaiting_check = false;
diff --git a/crates/ai/src/rebuild/self_check.rs b/crates/ai/src/rebuild/self_check.rs
index fe79a6cd..378f88f2 100644
--- a/crates/ai/src/rebuild/self_check.rs
+++ b/crates/ai/src/rebuild/self_check.rs
@@ -119,7 +119,12 @@ impl Worker {
let Some((kind, good_enough)) = self.self_check.clone() else { return Ok(()) };
let asks = Inbox::new(asks_dir(&ws.root));
for r in asks.pending() {
- self.step(ws, Step::Build, Status::Building, "The builder is checking its work against the original…")?;
+ let checking = if ws.manifest.target == TargetRef::None {
+ "The builder is checking its work…"
+ } else {
+ "The builder is checking its work against the original…"
+ };
+ self.step(ws, Step::Build, Status::Building, checking)?;
let (text, line) = match self.run_checks(ws, kind.as_ref(), SELF_CHECK_ROUND) {
Ok(checks) => {
let line = format!("The builder checked its work: {}.", summary(&checks, good_enough));
diff --git a/crates/ai/src/rebuild/stacks.rs b/crates/ai/src/rebuild/stacks.rs
index 0fbeaa04..05ffa788 100644
--- a/crates/ai/src/rebuild/stacks.rs
+++ b/crates/ai/src/rebuild/stacks.rs
@@ -32,6 +32,37 @@ pub struct Stack {
/// (`project.godot`); a leading `*` matches by the name's ending (`*.uproject`).
#[serde(default)]
pub found_by: Vec<String>,
+ /// Its build is a website: a project built with it and nothing to recreate is one.
+ #[serde(default)]
+ pub site: bool,
+}
+
+/// How a project builds and tests itself, whatever it's written in.
+#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Deserialize)]
+pub struct Toolchain {
+ pub name: String,
+ /// The files that name it, matched like [`Stack::found_by`].
+ pub found_by: Vec<String>,
+ /// The program that builds it and its arguments, run in the project's folder.
+ #[serde(default)]
+ pub build: Vec<String>,
+ /// The same for its tests.
+ #[serde(default)]
+ pub test: Vec<String>,
+ /// What its output says when no tests ran, which isn't a failure.
+ #[serde(default)]
+ pub no_tests: Vec<String>,
+ /// The package.json script that is its tests. Whether there are any is then read from that
+ /// file, as what a script prints can be about one it runs, and `no_tests` are whole scripts
+ /// that are only placeholders.
+ #[serde(default)]
+ pub test_script: Option<String>,
+ /// The project's own copies of the program, used first when one's there (`.venv/bin/python`).
+ #[serde(default)]
+ pub local_programs: Vec<String>,
+ /// The program's name on Windows, where it differs (`python`).
+ #[serde(default)]
+ pub windows_program: Option<String>,
}
/// The stack that leaves the choice to the builder (a website's default); [`used_in`] then
@@ -58,6 +89,8 @@ struct Table {
stack: Vec<Stack>,
#[serde(default)]
library: Vec<Library>,
+ #[serde(default)]
+ toolchain: Vec<Toolchain>,
}
/// The built-in table. A table that doesn't parse (a broken edit) leaves it empty, so every
@@ -115,6 +148,11 @@ pub fn found_in(dir: &std::path::Path) -> Option<&'static Stack> {
by_file(true).or_else(by_deps).or_else(|| by_file(false))
}
+/// How the project in `dir` builds and tests itself: the first toolchain a file there names.
+pub fn toolchain_in(dir: &std::path::Path) -> Option<&'static Toolchain> {
+ table().toolchain.iter().find(|t| t.found_by.iter().any(|f| has_file(dir, f)))
+}
+
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)),
@@ -189,6 +227,28 @@ mod tests {
assert_eq!(found(&[("notes.md", "")]), None);
}
+ #[test]
+ fn a_folder_says_how_it_builds_and_tests_itself() {
+ let tool = |file: &str| {
+ let d = tempfile::tempdir().unwrap();
+ std::fs::write(d.path().join(file), "").unwrap();
+ toolchain_in(d.path()).map(|t| t.name.as_str())
+ };
+ assert_eq!(tool("Cargo.toml"), Some("Rust"));
+ assert_eq!(tool("package.json"), Some("Node.js"));
+ assert_eq!(tool("requirements.txt"), Some("Python"));
+ assert_eq!(tool("go.mod"), Some("Go"));
+ assert_eq!(tool("App.csproj"), Some(".NET"));
+ assert_eq!(tool("Shop.sln"), Some(".NET"));
+ assert_eq!(tool("pom.xml"), Some("Maven"));
+ assert_eq!(tool("build.gradle.kts"), Some("Gradle"));
+ assert_eq!(tool("Makefile"), Some("Make"));
+ assert_eq!(tool("notes.md"), None);
+ for t in &table().toolchain {
+ assert!(!t.found_by.is_empty() && !t.build.is_empty() && !t.test.is_empty(), "{}", t.name);
+ }
+ }
+
#[test]
fn the_table_parses_and_covers_every_engine() {
let names: Vec<&str> = catalogue().iter().map(|s| s.name.as_str()).collect();
diff --git a/crates/ai/src/rebuild/stacks.toml b/crates/ai/src/rebuild/stacks.toml
index b2c0dd28..68c67040 100644
--- a/crates/ai/src/rebuild/stacks.toml
+++ b/crates/ai/src/rebuild/stacks.toml
@@ -15,8 +15,22 @@
# 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.
#
+# `site` marks a stack whose build is a website, so a project built with it and with nothing to
+# recreate is one, whatever its request says.
+#
# 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.
+#
+# A `[[toolchain]]` says how a project builds and tests itself, by the file that names the tool
+# (the first in this order wins), so a person's own project can be checked in any language.
+# `build` and `test` are a program and its arguments, run in the project's folder; `no_tests` is
+# what its output says when no tests ran, which isn't a failure (with `test_script`, the
+# package.json script that is its tests, whole scripts that are only placeholders: whether there
+# are any is read from the file, as a script that runs others can print the same);
+# `local_programs` are the
+# project's own copies of the program, used first when one's there (`.bat`, `.cmd` and `.exe`
+# ones on Windows, the others elsewhere); `windows_program` is its name on Windows, where it
+# differs.
[[stack]]
name = "Builder's choice"
@@ -31,6 +45,7 @@ steps = "Use Electron, with TypeScript or JavaScript (a bundler such as Vite is
[[stack]]
name = "Next.js + TypeScript"
+site = true
asked_by = [" nextjs ", " next js ", " use next ", " using next ", " in next "]
uses = ["next"]
steps = "Use Next.js (App Router) + React + TypeScript, exported as a static site. Create the project files directly in app/: package.json with next, react and react-dom and the script \"build\": \"next build\"; next.config.mjs with output: 'export', trailingSlash: true and images: { unoptimized: true }; tsconfig.json; src/app/layout.tsx and src/app/page.tsx, with one folder per other page under src/app/. Load the original's fonts with next/font. Use nothing a static export can't serve (API routes, server actions, middleware, dynamic routes without generateStaticParams). Then run `npm install` and `npm run build` from app/ until it succeeds; the output must be app/out and must work when served as static files."
@@ -42,6 +57,7 @@ found_by = ["pyproject.toml", "requirements.txt", "setup.py"]
[[stack]]
name = "React + TypeScript (Vite)"
+site = true
asked_by = [" in typescript", " in react", " with react", " in javascript", " vite "]
uses = ["vite"]
needs = ["react"]
@@ -49,6 +65,7 @@ steps = "Use Vite + React + TypeScript. Create the project files directly in app
[[stack]]
name = "Plain HTML and CSS"
+site = true
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."
@@ -98,3 +115,60 @@ name = "Tailwind CSS"
asked_by = [" tailwind ", " tailwindcss "]
stacks = ["Next.js + TypeScript", "React + TypeScript (Vite)", "Electron", "Builder's choice"]
steps = "Style with Tailwind CSS (v4, through @tailwindcss/postcss for Next.js or @tailwindcss/vite for Vite), with the original's colours, fonts, text sizes, spacing and breakpoints from capture.json as theme tokens in an @theme block."
+
+[[toolchain]]
+name = "Rust"
+found_by = ["Cargo.toml"]
+build = ["cargo", "build", "--quiet"]
+test = ["cargo", "test", "--quiet"]
+
+[[toolchain]]
+name = "Node.js"
+found_by = ["package.json"]
+build = ["npm", "run", "build", "--if-present"]
+test = ["npm", "test"]
+test_script = "test"
+no_tests = ['echo "Error: no test specified" && exit 1']
+windows_program = "npm.cmd"
+
+[[toolchain]]
+name = "Python"
+found_by = ["pyproject.toml", "requirements.txt", "setup.py"]
+build = ["python3", "-m", "compileall", "-q", "-x", '[\\/](\.?venv|node_modules|\.git)[\\/]', "."]
+test = ["python3", "-m", "pytest", "-q", "-p", "no:cacheprovider"]
+no_tests = ["no tests ran", "No module named pytest"]
+local_programs = [".venv/bin/python", "venv/bin/python", ".venv/Scripts/python.exe", "venv/Scripts/python.exe"]
+windows_program = "python"
+
+[[toolchain]]
+name = "Go"
+found_by = ["go.mod"]
+build = ["go", "build", "./..."]
+test = ["go", "test", "./..."]
+
+[[toolchain]]
+name = ".NET"
+found_by = ["*.sln", "*.csproj"]
+build = ["dotnet", "build", "--nologo", "-v", "q"]
+test = ["dotnet", "test", "--nologo", "-v", "q"]
+
+[[toolchain]]
+name = "Maven"
+found_by = ["pom.xml"]
+build = ["mvn", "-q", "-B", "compile"]
+test = ["mvn", "-q", "-B", "test"]
+local_programs = ["mvnw", "mvnw.cmd"]
+
+[[toolchain]]
+name = "Gradle"
+found_by = ["build.gradle", "build.gradle.kts"]
+build = ["gradle", "-q", "assemble"]
+test = ["gradle", "-q", "test"]
+local_programs = ["gradlew", "gradlew.bat"]
+
+[[toolchain]]
+name = "Make"
+found_by = ["Makefile"]
+build = ["make"]
+test = ["make", "test"]
+no_tests = ["make: *** No rule to make target `test'.", "make: *** No rule to make target 'test'.", "make: don't know how to make test."]
diff --git a/crates/ai/src/rebuild/tests.rs b/crates/ai/src/rebuild/tests.rs
index 4bc62f84..b4fdc903 100644
--- a/crates/ai/src/rebuild/tests.rs
+++ b/crates/ai/src/rebuild/tests.rs
@@ -2590,6 +2590,55 @@ fn a_project_edited_in_place_keeps_what_its_files_are_built_with() {
assert_eq!(first("project.godot", "Fix my game's jump", StartFrom), Some("Unity"), "material to start from doesn't decide");
}
+/// A folder of the person's own with this file in it, as a project of `existing`.
+fn own_folder(file: &str, existing: craft_anything_engine::workspace::ExistingFiles) -> (tempfile::TempDir, Workspace) {
+ let d = tempfile::tempdir().unwrap();
+ std::fs::write(d.path().join(file), "<p>hi</p>").unwrap();
+ let ws = Workspace::create_at(d.path(), "Mine", "Add a contact form", TargetRef::None, Some(existing)).unwrap();
+ (d, ws)
+}
+
+#[test]
+fn a_persons_own_project_is_judged_by_its_own_build_and_tests_whatever_its_kind() {
+ use craft_anything_engine::workspace::ExistingFiles::Edit;
+ let (_d, ws) = own_folder("index.html", Edit);
+ let r = check_worker(&ws, false).run_checks(&ws, &GameKind, 1).unwrap();
+ assert_eq!(r.iter().map(|c| c.check.as_str()).collect::<Vec<_>>(), [CheckResult::BUILD, kinds::own::OwnTestsCheck::ID]);
+ assert!(r.iter().all(|c| c.passed), "{r:?}");
+ assert!(r[1].note.starts_with("No tests ran"), "says what wasn't run: {}", r[1].note);
+}
+
+#[test]
+fn a_persons_own_project_is_asked_for_nothing_it_would_add_for_our_sake() {
+ use craft_anything_engine::workspace::ExistingFiles::{Edit, StartFrom};
+ let (_d, mut own) = own_folder("main.py", Edit);
+ for k in ["app", "game"] {
+ let b = brief(&own, k, false, false, None, false, None);
+ assert!(!b.contains("--screenshot") && !b.contains("--self-test") && !b.contains("MECHANICS.md"), "{k}: {b}");
+ assert!(b.contains("its own build and tests") && !b.contains(kind(k).goal()), "{k}: {b}");
+ }
+ own.manifest.stack = "Unity".into();
+ let b = brief(&own, "game", false, false, Some(Path::new("/x/Unity")), false, None);
+ assert!(!b.contains("CraftBuild") && b.contains("keep to what the project already uses") && b.contains("/x/Unity"), "{b}");
+ own.manifest.generate_assets = true;
+ let b = brief(&own, "game", false, false, None, true, None);
+ assert!(b.contains("Assets/Generated/") && !b.contains("--screenshot"), "what the person turned on still reaches it: {b}");
+ let (_d, beside) = own_folder("main.py", StartFrom);
+ let b = brief(&beside, "app", false, false, None, false, None);
+ assert!(b.contains("--screenshot") && !b.contains("its own build and tests"), "a new app beside the files proves itself: {b}");
+}
+
+#[test]
+fn a_site_stack_with_nothing_to_recreate_is_a_website() {
+ let vite = "React + TypeScript (Vite)";
+ assert_eq!(kind_of("Add a contact form", &TargetRef::None, "Plain HTML and CSS"), "website");
+ assert_eq!(kind_of("A calculator in react", &TargetRef::None, vite), "website", "it can't be started as a program");
+ assert_eq!(kind_of("Add a high score to my game", &TargetRef::None, vite), "game", "the person's words come first");
+ assert_eq!(kind_of("Add a settings page", &TargetRef::None, "Python"), "app");
+ assert_eq!(kind_of("Add a settings page", &TargetRef::None, "Electron"), "app", "a window, not a site");
+ assert_eq!(kind_of("Copy this tool", &TargetRef::Local { path: "/x/tool".into() }, vite), "app", "an original decides");
+}
+
#[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 4be4daf7..eef80771 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()
}
+/// What `app`'s package.json runs for `script`; none without a readable one or that script.
+pub fn npm_script(app: &Path, script: &str) -> Option<String> {
+ let pkg: serde_json::Value = serde_json::from_slice(&std::fs::read(app.join("package.json")).ok()?).ok()?;
+ pkg.get("scripts")?.get(script)?.as_str().map(str::to_string)
+}
+
/// 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());
diff --git a/crates/engine/src/workspace.rs b/crates/engine/src/workspace.rs
index 1cdfe0f2..bd650cd5 100644
--- a/crates/engine/src/workspace.rs
+++ b/crates/engine/src/workspace.rs
@@ -420,6 +420,11 @@ pub struct Manifest {
}
impl Manifest {
+ /// The person's own project: their files are the app, edited in place, with nothing to recreate.
+ pub fn own_project(&self) -> bool {
+ self.app_in_root && self.target == TargetRef::None
+ }
+
fn new(name: &str, request: &str, target: TargetRef) -> Manifest {
let now = now_ms();
Manifest {
diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md
index 69ba2ccf..fcbfa553 100644
--- a/docs/ROADMAP.md
+++ b/docs/ROADMAP.md
@@ -583,10 +583,21 @@ Owner: open · Status: in progress
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
+- [x] A person's own project (edited in place, nothing to recreate) is judged by what it does for
+ itself: its own build, then its own tests, through `[[toolchain]]` in `stacks.toml` (Rust,
+ Node.js, Python, Go, .NET, Maven, Gradle, Make). Nothing is added to it for our sake: no
+ `--screenshot`, `--self-test` or mechanics sheet. A site stack with nothing to recreate is a
+ website, whatever the request says
+ — claimed: xerenon, branch feature/r2.7-own-project-checks; PR #760
+- [ ] Run the Go, .NET, Maven and Gradle rows of `[[toolchain]]` on real projects, and every row
+ on Windows (`windows_program`): Rust, Node.js, Python and Make were run for real, on a Mac
+ only. Also a person's own Unity project: it's opened in batch mode, which should exit with
+ an error when its scripts don't compile (not run: no Unity on that machine)
+- [ ] A person's own tests that already failed before their request fail the check too, so the
+ builder is sent to fix them. If that proves a nuisance, run them once before the first turn
+ and hold it only to what it broke
+- [ ] A new project in Python, Go or the like still fails the build check ("No project to build
+ found") and has no program for the screenshot check: `[[toolchain]]` could build it too
### R2.8 Clean room means clean room
Owner: maintainers · Status: in progress
diff --git a/docs/STATUS.md b/docs/STATUS.md
index f66231b9..4b216038 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 (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 |
+| 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, and, with nothing to recreate, judged by its own build and tests, whatever it's written in), 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 1aa74aa8..be52cd1f 100644
--- a/docs/extending.md
+++ b/docs/extending.md
@@ -11,6 +11,7 @@ place to add yours. Follow `AGENTS.md` (never crash, layers, external programs t
| 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 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 way to build and test someone's own project | `crates/ai/src/rebuild/stacks.toml` | One `[[toolchain]]` entry: name, the files that name it, its build and test commands, what it prints when no tests ran. Earlier entries win. |
| 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. |