Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/skillspector/references.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class ReferenceResolutionResult:


_PLAIN_RELATIVE_PATH = re.compile(
r"(?<![\w:/.-])((?:\./)?(?:[A-Za-z0-9_.-]+/)+[A-Za-z0-9_.-]+(?:\.[A-Za-z0-9]{1,12})?)(?![\w/.-])"
r"(?<![\w:/.-])((?:\./(?:[A-Za-z0-9_.-]+/)+[A-Za-z0-9_.-]+|"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2] Preserve root-level extensionless ./ references. This branch requires at least one additional directory component after the ./ prefix, so ./guide no longer matches even though an explicit ./ is the syntax signal promised by the issue/PR (and the old regex did match it). Allow zero or more directory segments after ./ and add ./guide to the regression matrix.

r"(?:[A-Za-z0-9_.-]+/)+[A-Za-z0-9_.-]+\.[A-Za-z0-9]{1,12}))(?![\w/.-])"
)


Expand Down
35 changes: 35 additions & 0 deletions tests/nodes/test_security_remediation.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,41 @@ def test_full_body_reference_resolver_handles_markdown_and_unique_basename(
assert all(record["status"] == "resolved" for record in records)


def test_plain_slash_separated_prose_is_not_a_reference(tmp_path: Path) -> None:
records = resolve_bundle_references(
tmp_path,
source_path="SKILL.md",
source_text=(
"Compare reads/writes, environment/profile settings, and operation/node behavior."
),
known_paths=["SKILL.md"],
)

assert records == []


@pytest.mark.parametrize(
("source_text", "target_path"),
[
("Read references/guide.md before continuing.", "references/guide.md"),
("Read ./references/guide before continuing.", "references/guide"),
],
)
def test_plain_local_reference_requires_an_explicit_path_signal(
tmp_path: Path, source_text: str, target_path: str
) -> None:
records = resolve_bundle_references(
tmp_path,
source_path="SKILL.md",
source_text=source_text,
known_paths=["SKILL.md", target_path],
)

assert len(records) == 1
assert records[0]["status"] == "resolved"
assert records[0]["target_path"] == target_path


def test_reference_resolver_rejects_external_and_parent_escape(tmp_path: Path) -> None:
records = resolve_bundle_references(
tmp_path,
Expand Down
Loading