Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).

- Make `rune install`, `deploy`, `drift`, `prune`, `doctor`, `validate`, and `spec` work on Windows. Hooks, `rune exec` of a shell script, and `rune sign queue` still need a Unix shell.
- Write manifest keys with `/` on Windows. `rune install` refused every skill there, and `rune doctor` reported every deployed file as an orphan.
- Read a manifest key and its provenance path that hold `\` on Windows as their `/` form, so a manifest a Windows build wrote that way still names the files it deployed.
- Record the module as the provenance source of a single-module source in `.rune`. The source was empty, and every install from one warned that the source snapshot remains unverified.
- Follow `HOME` on Windows, as git does there. `rune.exe` read only the profile folder of the account, so nothing could point it at another home.
- Print a path on Windows without the `\\?\` prefix and with one kind of separator, and name `rune`, not `rune.exe`, in the usage line.
- Treat a file more than 260 characters deep as inside its folder on Windows. rune wrote the two paths in different forms, and a check that a path stays inside a folder gave the wrong answer.
Expand Down
17 changes: 11 additions & 6 deletions src/cli/dotrune/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,17 @@ pub fn resolve_sources(
),
));
}
filter_to_requested(
sources::collect(module_root, valid_qualifiers)?,
rune_list,
source_label,
module_root,
)?
// The module names its own source, as a deck entry does
// below. Without it provenance falls back to the consumer's
// root, which has no module.yaml, and records an empty source.
let source_uri = crate::cli::config::load_source_uri(module_root);
let mut files = sources::collect(module_root, valid_qualifiers)?;
if !source_uri.is_empty() {
for file in &mut files {
file.source_uri = Some(source_uri.clone());
}
}
filter_to_requested(files, rune_list, source_label, module_root)?
}
CanonicalSource::Deck(deck) => {
let mut files = Vec::new();
Expand Down
11 changes: 9 additions & 2 deletions src/manifest/read.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use super::ManifestEntry;
use std::collections::HashMap;
use std::path::Path;

/// Deserialize a nested YAML manifest tree into a flat `HashMap`.
///
Expand Down Expand Up @@ -36,9 +37,13 @@ fn flatten_tree(
let Some(key_string) = key.as_str() else {
continue;
};
// A manifest written on Windows with `\` between the parts of a key
// names the same file as the `/` form. Elsewhere `\` is a character
// of a name and stays.
let key_string = super::slash_lossy(Path::new(key_string));

let full_path = if prefix.is_empty() {
key_string.to_string()
key_string
} else {
format!("{prefix}/{key_string}")
};
Expand All @@ -49,7 +54,9 @@ fn flatten_tree(

if child_map.contains_key("fingerprint") {
let fingerprint = super::extract::string_field(value, "fingerprint", &full_path)?;
let provenance = super::extract::string_field(value, "provenance", &full_path).ok();
let provenance = super::extract::string_field(value, "provenance", &full_path)
.ok()
.map(|path| super::slash_lossy(Path::new(&path)));

entries.insert(
full_path,
Expand Down
30 changes: 30 additions & 0 deletions src/manifest/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,36 @@ fn read_parses_all_entries() {
assert!(entries.contains_key("rules/CodeStyle.md"));
}

const MANIFEST_WITH_BACKSLASHES: &str = "skills:\n Explain\\SKILL.md:\n fingerprint: abc\n provenance: skills/Explain\\.provenance\\SKILL.md.yaml\n";

#[cfg(windows)]
#[test]
fn read_takes_a_backslash_in_a_key_as_a_separator_on_windows() {
let entries = read(MANIFEST_WITH_BACKSLASHES).unwrap();

let entry = entries
.get("skills/Explain/SKILL.md")
.expect("the key reads with slashes");
assert_eq!(
entry.provenance.as_deref(),
Some("skills/Explain/.provenance/SKILL.md.yaml")
);
}

#[cfg(not(windows))]
#[test]
fn read_keeps_a_backslash_in_a_key_where_it_is_a_name_character() {
let entries = read(MANIFEST_WITH_BACKSLASHES).unwrap();

let entry = entries
.get("skills/Explain\\SKILL.md")
.expect("the key keeps its backslash");
assert_eq!(
entry.provenance.as_deref(),
Some("skills/Explain\\.provenance\\SKILL.md.yaml")
);
}

#[test]
fn read_ignores_entries_without_fingerprint() {
let entries = read(MANIFEST_INVALID).unwrap();
Expand Down
34 changes: 34 additions & 0 deletions tests/dotrune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,40 @@ fn single_module_source_still_resolves_bare_name() {
);
}

#[test]
fn single_module_source_names_the_module_as_provenance_source() {
let producer = tempfile::tempdir().unwrap();
let consumer = tempfile::tempdir().unwrap();
scaffold_producer(producer.path(), "producer");
write_skill(producer.path(), "Sourced");
write_dotrune(
consumer.path(),
&format!(
"version: 1\nsources:\n producer:\n local: {}\nrunes:\n producer:\n skills: [Sourced]\n",
producer.path().display()
),
);

let output = install(consumer.path()).success().get_output().clone();

let printed = format!(
"{}{}",
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr)
);
assert!(!printed.contains("remains unverified"), "{printed}");
let statement = fs::read_to_string(
consumer
.path()
.join(".claude/skills/Sourced/.provenance/SKILL.md.yaml"),
)
.unwrap();
assert!(
statement.contains("https://github.com/example/producer"),
"{statement}"
);
}

#[test]
fn dotrune_manifest_inside_a_rune_directory_installs_too() {
let producer = tempfile::tempdir().unwrap();
Expand Down
Loading