feat: persist & restore per-project input mode (#14)

The input mode always started in simple; a learner who quit in advanced
had to re-toggle every launch. Store the mode per-project in project.yaml
(project.mode:, optional, default simple) and restore it on every open.

Mode is live UI state, not schema: the worker stamps the current mode
into project.yaml on every write, so a later command rewrites the live
value rather than clobbering it — no db round-trip needed. The mode is
persisted on unload (quit + project switch) so the mode you leave a
project in is always what reopens; the `mode` command also persists
immediately. A switch saves the outgoing mode, then restores the
incoming project's stored mode.

New --mode simple|advanced CLI flag (precedence --mode > stored >
simple; combines with --resume). A teacher can ship a project that
opens in advanced mode and export it to students (the mode travels in
the zip).

ADR-0015 Amendment 1; ADR-0003 note; help banner; requirements L1b.
This commit is contained in:
claude@clouddev1
2026-06-02 06:47:34 +00:00
parent ae57c6fc82
commit 4cd574b909
16 changed files with 769 additions and 14 deletions
+29
View File
@@ -583,6 +583,35 @@ mod tests {
assert_eq!(inspect.top_folder, "MyProject");
}
#[test]
fn export_carries_the_stored_input_mode() {
// ADR-0015 mode-restore amendment (issue #14): the input
// mode is part of project.yaml, so it travels in the export
// verbatim — this is the teacher-prepares-an-advanced-mode
// project, hands it to students workflow.
use std::io::Read as _;
let tmp = tempdir();
let project = make_project(tmp.path(), "Advanced");
// Re-write project.yaml with an explicit advanced mode.
fs::write(
project.join(PROJECT_YAML),
"version: 1\nproject:\n created_at: 2026-01-01T00:00:00Z\n mode: advanced\ntables: []\nrelationships: []\n",
)
.unwrap();
let zip_path = tmp.path().join("export.zip");
export_project(&project, "Advanced", &zip_path).unwrap();
let f = fs::File::open(&zip_path).unwrap();
let mut archive = ZipArchive::new(f).unwrap();
let mut entry = archive.by_name("Advanced/project.yaml").unwrap();
let mut body = String::new();
entry.read_to_string(&mut body).unwrap();
assert!(
body.contains("mode: advanced"),
"exported project.yaml must carry the stored mode: {body}"
);
}
#[test]
fn inspect_rejects_zip_without_project_yaml() {
let tmp = tempdir();