Skip to content

Commit 5b6562a

Browse files
Merge branch 'main' into naren/fix-NVCARPS-152-doc-context
2 parents d5eb8c8 + f161b70 commit 5b6562a

2 files changed

Lines changed: 39 additions & 1 deletion

File tree

‎src/skillspector/references.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ class ReferenceResolutionResult:
4444

4545

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

5051

‎tests/nodes/test_security_remediation.py‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,43 @@ def test_full_body_reference_resolver_handles_markdown_and_unique_basename(
352352
assert all(record["status"] == "resolved" for record in records)
353353

354354

355+
def test_plain_slash_separated_prose_is_not_a_reference(tmp_path: Path) -> None:
356+
records = resolve_bundle_references(
357+
tmp_path,
358+
source_path="SKILL.md",
359+
source_text=(
360+
"Compare reads/writes, environment/profile settings, operation/node behavior, "
361+
"and model/provider options. SkillSpector 2.10.0 supports node.js; see example.com."
362+
),
363+
known_paths=["SKILL.md"],
364+
)
365+
366+
assert records == []
367+
368+
369+
@pytest.mark.parametrize(
370+
("source_text", "target_path"),
371+
[
372+
("Read references/guide.md before continuing.", "references/guide.md"),
373+
("Read ./guide before continuing.", "guide"),
374+
("Read ./references/guide before continuing.", "references/guide"),
375+
],
376+
)
377+
def test_plain_local_reference_requires_an_explicit_path_signal(
378+
tmp_path: Path, source_text: str, target_path: str
379+
) -> None:
380+
records = resolve_bundle_references(
381+
tmp_path,
382+
source_path="SKILL.md",
383+
source_text=source_text,
384+
known_paths=["SKILL.md", target_path],
385+
)
386+
387+
assert len(records) == 1
388+
assert records[0]["status"] == "resolved"
389+
assert records[0]["target_path"] == target_path
390+
391+
355392
def test_reference_resolver_rejects_external_and_parent_escape(tmp_path: Path) -> None:
356393
records = resolve_bundle_references(
357394
tmp_path,

0 commit comments

Comments
 (0)