core: load AGENTS.md from foreign environments (#28958)

## Why

Make it possible to load AGENTS.md from remote exec-servers whose OS is
different than app-server.

## What

- keep `AGENTS.md` discovery and provenance as `PathUri`, with
root-aware parent and ancestor traversal
- expose lifecycle instruction sources as legacy app-server path strings
in events while retaining `PathUri` internally
- preserve and test mixed POSIX and Windows paths in model context and
TUI status output
- cover remote Windows loading end to end by seeding the Wine prefix
through host filesystem APIs
- fix bug in `PathUri`'s parent() implementation that would erase
Windows drive letters
This commit is contained in:
Adam Perry @ OpenAI authored and GitHub committed 2026-06-18 15:06:23 -07:00
1 parent 406062c3af
commit dce673905a
38 files changed
+550 -203

No files matched your search

+33 -3
View File
@@ -522,7 +522,7 @@ fn path_buf_uses_the_inferred_native_spelling() {
}
#[test]
fn parent_uses_uri_hierarchy_and_preserves_authority() {
fn parent_stops_at_posix_drive_and_unc_roots() {
for (input, expected) in [
(
"file:///workspace/src/lib.rs",
@@ -531,12 +531,13 @@ fn parent_uses_uri_hierarchy_and_preserves_authority() {
("file:///workspace", Some("file:///")),
("file:///", None),
("file:///C:/Users", Some("file:///C:")),
("file:///C:/", Some("file:///")),
("file:///C:/", None),
("file:///C:", None),
(
"file://server/share/src/main.rs",
Some("file://server/share/src"),
),
("file://server/share", Some("file://server/")),
("file://server/share", None),
] {
let uri = PathUri::parse(input).expect("valid file URI");
let expected = expected.map(|value| PathUri::parse(value).expect("valid expected URI"));
@@ -544,6 +545,35 @@ fn parent_uses_uri_hierarchy_and_preserves_authority() {
}
}
#[test]
fn ancestors_include_self_and_stop_at_native_path_roots() {
for (input, expected) in [
(
"file:///workspace/src",
vec!["file:///workspace/src", "file:///workspace", "file:///"],
),
(
"file:///C:/workspace/src",
vec![
"file:///C:/workspace/src",
"file:///C:/workspace",
"file:///C:",
],
),
(
"file://server/share/project",
vec!["file://server/share/project", "file://server/share"],
),
] {
let uri = PathUri::parse(input).expect("valid file URI");
let ancestors = uri
.ancestors()
.map(|path| path.to_string())
.collect::<Vec<_>>();
assert_eq!(ancestors, expected, "ancestors for {input}");
}
}
#[test]
fn join_normalizes_relative_uri_segments() {
for (base, relative, expected) in [