From 4c6ce1513000e6026312f3958a1f119fdc7156a0 Mon Sep 17 00:00:00 2001 From: Offending Commit Date: Mon, 21 Sep 2026 16:16:23 -0500 Subject: [PATCH] fix(plugins): stop claiming Hermes cannot serve companion files The kit warned that a skill's references_dir "will not be surfaced to the agent until the host adds support". Hermes has served those files all along -- through its skills tool rather than register_skill -- returning references/, templates/, assets/ and scripts/ as linked_files alongside the skill body. Verified present at both the pinned f80f453 and upstream main; an upstream refactor moved the module, not the capability. A signature probe cannot establish that a capability is missing, only that one function does not take one argument. The kit asserted the stronger claim and a fleet survey traced the cost: the warning fired on every pod boot, a plugin built plugin_reference_tool to work around it, and those tools were called zero times in eight days across three profiles while the real route sat available and unmentioned. The capability check returns True or unknown -- never False. The kit knows a few private module paths and those move; a name it cannot find says nothing about the host. That is the lesson encoded in the return type rather than left to a comment. It is no longer a warning either way, because nothing is wrong. Two smaller defects with the same shape, both reported with fleet evidence. plugin_reference_tool's default description named no files, so an agent had to spend a speculative call to learn whether anything was worth reading; references_dir is known at build time, so the names are now in the description with a cap and overflow count. And an example on an *optional* argument was collected and then dropped, because _augment_description iterated required keys only -- one fleet plugin shipped a usable example no agent ever saw while its handler refused calls that omitted the field. Neither the signature probe nor a recorded plugin context would have caught the first one: both reason about shape. Only reading the host's other tool did. Worth remembering when the harness tempts the same inference. Reported-by: hermes-plugin-memory-sync fleet survey --- hermes_plugin_kit/__init__.py | 132 +++++++++++-- .../.openspec.yaml | 13 ++ .../design.md | 72 ++++++++ .../proposal.md | 57 ++++++ .../tasks.md | 25 +++ tests/test_kit.py | 20 +- tests/test_testing_harness.py | 174 ++++++++++++++++++ 7 files changed, 469 insertions(+), 24 deletions(-) create mode 100644 openspec/changes/stop-claiming-references-dir-unsupported/.openspec.yaml create mode 100644 openspec/changes/stop-claiming-references-dir-unsupported/design.md create mode 100644 openspec/changes/stop-claiming-references-dir-unsupported/proposal.md create mode 100644 openspec/changes/stop-claiming-references-dir-unsupported/tasks.md diff --git a/hermes_plugin_kit/__init__.py b/hermes_plugin_kit/__init__.py index c8e80c9..0484f5c 100644 --- a/hermes_plugin_kit/__init__.py +++ b/hermes_plugin_kit/__init__.py @@ -200,6 +200,42 @@ def _call_session_db( return method(*args, **kwargs) +#: Where Hermes has exposed its skill companion-file support, newest first. +#: +#: The host serves `references/`, `templates/`, `assets/` and `scripts/` +#: alongside a skill body through its own skills tool -- it has done so since +#: at least the revision this kit pins -- and returns them as `linked_files`. +#: That route has nothing to do with `register_skill`'s signature, so probing +#: the signature alone cannot see it. +#: +#: The module moved during an upstream refactor, hence a list rather than one +#: path. A name missing from every candidate means "could not tell", never +#: "the host cannot do it". +_HOST_COMPANION_FILE_PROBES = ( + ("tools.skills_tool_plugin", "_plugin_skill_linked_files"), + ("tools.skills_tool", "_plugin_skill_linked_files"), +) + + +def _host_serves_skill_companion_files() -> bool | None: + """Whether the host serves skill companion files through its skills tool. + + ``True`` when a known support routine is importable, ``None`` when that + cannot be determined. Never ``False``: absence of a private helper the kit + happens to know about is not evidence the host lacks the capability, and + treating it as such is what produced a warning telling plugin authors to + build a workaround for something that already worked. + """ + for module_name, attribute in _HOST_COMPANION_FILE_PROBES: + try: + module = importlib.import_module(module_name) + except Exception: + continue + if getattr(module, attribute, None) is not None: + return True + return None + + def _signature_accepts_kwarg(callable_obj: Any, name: str) -> bool: """Return whether ``callable_obj``'s live signature has ``name`` or accepts ``**kwargs``. @@ -776,13 +812,31 @@ def _split_params(params: dict | None) -> tuple[dict, list, dict]: def _augment_description(description: str, required: list, examples: dict) -> str: - if not required: - return description - bits = [ - f"`{key}`" + (f" (e.g. {examples[key]!r})" if key in examples else "") - for key in required + """Surface required keys and every supplied example. + + Examples used to reach the model only for required keys: an example on an + optional key was collected and then dropped, so a plugin could ship a + perfectly good one that no agent ever saw. An example is guidance about + shape; whether the key is mandatory is a separate fact, and conflating + them silently discarded the guidance. + """ + parts = [description] + if required: + bits = [ + f"`{key}`" + (f" (e.g. {examples[key]!r})" if key in examples else "") + for key in required + ] + parts.append(f"Required: {', '.join(bits)}.") + + optional_examples = [ + f"`{key}` (e.g. {examples[key]!r})" + for key in examples + if key not in required ] - return f"{description} Required: {', '.join(bits)}." + if optional_examples: + parts.append(f"Optional: {', '.join(optional_examples)}.") + + return " ".join(parts) def build_schema(name: str, description: str, params: dict | None) -> dict: @@ -1371,6 +1425,10 @@ def _default_reference_tool_name(skill_name: str) -> str: return f"{normalized}_read_reference" +#: How many reference filenames to name before summarising the rest. +_REFERENCE_NAMES_IN_DESCRIPTION = 8 + + def plugin_reference_tool( skill: PluginSkill, *, @@ -1412,11 +1470,37 @@ def plugin_reference_tool( references_dir = skill.references_dir tool_name = name or _default_reference_tool_name(skill.name) - tool_description = description or ( - f"List or read companion reference files for the {skill.name!r} skill. Omit file_path " - "to list every available file; pass either a listed path or its skill-relative " - "references/ form to read one file's content." + # Name the files in the default description. An agent selects tools by + # description at call time, so a tool that lists nothing asks it to spend a + # speculative no-argument call to discover whether anything is worth + # reading -- a cost it will not pay for a tool that promises nothing. Two + # readers built this way were registered on three deployed profiles and + # called zero times in eight days. references_dir is known here, so the + # names cost nothing. + available = sorted( + candidate.relative_to(references_dir.resolve()).as_posix() + for candidate in references_dir.resolve().rglob("*") + if candidate.is_file() ) + if description: + tool_description = description + elif available: + shown = ", ".join(available[:_REFERENCE_NAMES_IN_DESCRIPTION]) + if len(available) > _REFERENCE_NAMES_IN_DESCRIPTION: + shown += f", and {len(available) - _REFERENCE_NAMES_IN_DESCRIPTION} more" + tool_description = ( + f"Read the {skill.name!r} skill's companion reference files: {shown}. " + f"Consult these before acting on that skill when the details matter. " + f"Omit file_path to list every file; pass a listed path, or its " + f"skill-relative references/ form, to read one." + ) + else: + tool_description = ( + f"List or read companion reference files for the {skill.name!r} skill. " + f"No files are present yet. Omit file_path to list every available " + f"file; pass either a listed path or its skill-relative " + f"references/ form to read one file's content." + ) def _read_plugin_reference(args: dict, **_: Any) -> dict: file_path = args.get("file_path") @@ -2559,13 +2643,27 @@ def register_plugin( if wants_references_dir and _signature_accepts_kwarg(ctx.register_skill, "references_dir"): skill_kwargs["references_dir"] = skill.references_dir elif wants_references_dir: - log.warning( - "hermes_plugin_kit: host register_skill() does not yet accept references_dir; " - "name=%s references_dir=%s will not be surfaced to the agent until the host " - "adds support", - skill.name, - skill.references_dir, - ) + # Say only what was observed. register_skill not taking the kwarg + # means the kwarg was not taken -- it does not mean the files go + # unserved, because the host's skills tool serves them by another + # route entirely. + if _host_serves_skill_companion_files(): + log.debug( + "hermes_plugin_kit: host register_skill() does not accept references_dir; " + "name=%s references_dir=%s is served by the host's skills tool instead " + "(returned as linked_files alongside the skill body)", + skill.name, + skill.references_dir, + ) + else: + log.info( + "hermes_plugin_kit: host register_skill() does not accept references_dir; " + "name=%s references_dir=%s was not passed through it. Hermes may still " + "serve these files through its skills tool -- check skill_view before " + "assuming otherwise. Use plugin_reference_tool only if it does not", + skill.name, + skill.references_dir, + ) # The signature probe above can be fooled by a permissive **kwargs shape (a bare # Mock(spec=...) test double, or a decorator applied without functools.wraps) that diff --git a/openspec/changes/stop-claiming-references-dir-unsupported/.openspec.yaml b/openspec/changes/stop-claiming-references-dir-unsupported/.openspec.yaml new file mode 100644 index 0000000..8d38d78 --- /dev/null +++ b/openspec/changes/stop-claiming-references-dir-unsupported/.openspec.yaml @@ -0,0 +1,13 @@ +schema: spec-driven +created: 2026-09-21 + +# This changes observable behaviour -- what the kit claims about the host and +# what it surfaces to an agent -- but there is no capability spec covering the +# registration-claims surface to modify. openspec/specs/ is empty until the +# first change archives, and the only spec in flight covers the test harness. +# +# Writing a delta here would mean inventing a capability to satisfy the +# validator, which the shipped template explicitly warns against. The honest +# marker is skip_specs, and this surface deserves a real spec once the store +# has one to modify. +skip_specs: true diff --git a/openspec/changes/stop-claiming-references-dir-unsupported/design.md b/openspec/changes/stop-claiming-references-dir-unsupported/design.md new file mode 100644 index 0000000..2c652f6 --- /dev/null +++ b/openspec/changes/stop-claiming-references-dir-unsupported/design.md @@ -0,0 +1,72 @@ +## Context + +Evidence came from a fleet survey of 11 `state.db` stores across 5 pods over 8 +days (1,681 plugin tool calls), reported by the memory-sync maintainer, plus +direct verification against two Hermes checkouts here. + +The host-side capability is real and not new. `_plugin_skill_linked_files` +exists at `tools/skills_tool.py` in the pinned revision `f80f453` and at +`tools/skills_tool_plugin.py` on main after an upstream refactor. Support dirs +are enumerated in both. + +## Goals / Non-Goals + +**Goals:** + +- Stop asserting a negative the kit cannot establish. +- Give an agent a reason to call the reference tool. +- Stop discarding examples. + +**Non-Goals:** + +- Removing `plugin_reference_tool`. It remains the right answer where the host + genuinely does not serve files, and consumers depend on it. +- Changing registration behaviour. The kwarg is still dropped when the host + does not take it, and the skill still registers. +- Any upstream Hermes change. + +## Decisions + +**Probe positively; treat "cannot tell" as unknown, never as absent.** The +check returns `True` or `None` — never `False`. The kit knows a handful of +private module paths, and those move; a name it cannot find is not evidence +about the host. This is the whole lesson of the defect, encoded in the return +type rather than left to a comment. + +**Not a warning.** When the host serves the files, this is a debug detail. +When the kit cannot tell, it is informational and names the check an author +can run. A warning asserts something is wrong, and nothing is. + +**Name files in the default description, not just the mechanism.** An agent +selects on description at call time. `references_dir` is known at build time, +so enumeration is free. Capped, with an overflow count, so a large directory +does not flood the tool list. + +**Examples belong to the argument, not to its required-ness.** An example is +guidance about shape; whether a key is mandatory is a separate fact. Rendering +optional examples under their own heading keeps both legible. + +## Risks / Trade-offs + +- The probe reads private host names, which can move again — it already has + once. That is why it is a candidate list and why failure means unknown. The + cost of a stale probe is a slightly less specific log line, not a wrong + claim. +- Naming files makes the description depend on directory contents, so adding a + file changes the tool description. That is intended; a stale description is + what caused the original problem. +- Neither the probe nor a recorded plugin context would have caught this: both + reason about shape. Only reading the host's other tool did. Worth holding + onto when the harness tempts a similar inference. + +## Migration + +None. Consumers already using `plugin_reference_tool` keep working; those who +adopted it because of the false warning may now find the host route sufficient, +but nothing forces that decision. + +## Open Questions + +- Whether the kit should expose the capability check publicly so a plugin can + branch on it rather than always registering a reference tool. Deferred: one + consumer's behaviour is not yet enough to design an API around. diff --git a/openspec/changes/stop-claiming-references-dir-unsupported/proposal.md b/openspec/changes/stop-claiming-references-dir-unsupported/proposal.md new file mode 100644 index 0000000..4801b8a --- /dev/null +++ b/openspec/changes/stop-claiming-references-dir-unsupported/proposal.md @@ -0,0 +1,57 @@ +## Why + +The kit told plugin authors a host capability was missing that has existed all +along, and one of them built a workaround that then went unused. + +`register_plugin` probes `register_skill`'s signature for a `references_dir` +keyword. When it is absent the kit warns that the directory "will not be +surfaced to the agent until the host adds support". Hermes serves skill +companion files through its *skills tool*, not through `register_skill` — +`_plugin_skill_linked_files` returns `references/`, `templates/`, `assets/` +and `scripts/` as `linked_files` in the same response as the skill body. +Verified present at both the pinned revision `f80f453` and upstream main; the +module moved during a refactor but the capability did not appear or disappear. + +A signature probe cannot establish that a capability is missing. It can only +establish that one function does not take one argument. The kit asserted the +stronger claim, and a fleet survey traced the consequence: the warning fired +on every pod boot, a plugin built `plugin_reference_tool` to work around it, +and the resulting tools were called zero times in eight days across three +profiles while the real route sat available and unmentioned. + +Two smaller defects share that theme of guidance never reaching the agent. The +reference tool's default description names no files, so an agent must spend a +speculative call to learn whether anything is worth reading. And an example +supplied for an *optional* argument is collected and then dropped, so a plugin +can ship good guidance no agent ever sees. + +## What Changes + +- The kit stops claiming the capability is missing. It checks whether the host + serves companion files and, when it cannot tell, says what it observed + instead of asserting absence. Not a warning either way: nothing is wrong. +- `plugin_reference_tool`'s default description names the available files and + says when to consult them. +- Examples on optional arguments reach the description, under their own + `Optional:` heading so required and optional stay distinguishable. + +## Capabilities + +### New Capabilities + + + +### Modified Capabilities + + + +## Impact + +- `hermes_plugin_kit/__init__.py` — capability probe, corrected log, default + description, `_augment_description`. +- `tests/test_kit.py` — two existing assertions updated: the behaviour they + guard is unchanged, only the claim in the log. +- `tests/test_testing_harness.py` — new coverage for all three. +- No host change required. That is the point: the capability already exists. diff --git a/openspec/changes/stop-claiming-references-dir-unsupported/tasks.md b/openspec/changes/stop-claiming-references-dir-unsupported/tasks.md new file mode 100644 index 0000000..668a707 --- /dev/null +++ b/openspec/changes/stop-claiming-references-dir-unsupported/tasks.md @@ -0,0 +1,25 @@ +## 1. Stop asserting the capability is missing + +- [x] 1.1 Add a capability check that looks for the host's companion-file + support across its known module locations, returning unknown rather than + false when it cannot tell. Verify: it reports the capability present + against both the pinned revision and upstream main, and unknown with no + host importable. +- [x] 1.2 Replace the warning with what was actually observed, at a level that + does not claim something is wrong. Verify: no run asserts the files go + unserved, and the message points at the host's skills tool. +- [x] 1.3 Update the two existing assertions that pinned the old wording, + preserving the behaviour they guard. Verify: the kwarg is still dropped + and the skill still registers, with and without a host importable. + +## 2. Give the reference tool a reason to be called + +- [x] 2.1 Name the available files in the default description, capped with an + overflow count, and say when to consult them. Verify: the filenames + appear, and an explicitly supplied description is left untouched. + +## 3. Stop discarding examples on optional arguments + +- [x] 3.1 Surface optional examples under their own heading. Verify: an + example on an optional key reaches the description without being + labelled required, and required examples are unchanged. diff --git a/tests/test_kit.py b/tests/test_kit.py index 612b7fc..6502ae1 100644 --- a/tests/test_kit.py +++ b/tests/test_kit.py @@ -1949,7 +1949,7 @@ def test_register_plugin_warns_and_drops_references_dir_missing_since_declaratio ) ctx = FakePluginCtx() - with self.assertLogs(level="WARNING") as logs: + with self.assertLogs(level="DEBUG") as logs: summary = hpk.register_plugin(ctx, self._module(), skills=(skill,)) self.assertEqual(summary.skills, ("sample",)) @@ -1984,11 +1984,14 @@ def test_register_plugin_falls_back_gracefully_when_host_lacks_references_dir_su skill = hpk.plugin_skill("sample", skill_path, "Sample.", references_dir=references_dir) ctx = RecordingPluginContext(supports_references_dir=False) - with self.assertLogs(level="WARNING") as logs: + with self.assertLogs(level="DEBUG") as logs: hpk.register_plugin(ctx, self._module(), skills=(skill,)) self.assertNotIn("references_dir", ctx.skills[0]) - self.assertIn("does not yet accept references_dir", "\n".join(logs.output)) + self.assertIn("does not accept references_dir", "\n".join(logs.output)) + # The kit no longer claims the files go unserved: Hermes serves them + # through its skills tool regardless of this signature. + self.assertNotIn("until the host adds support", "\n".join(logs.output)) def test_register_plugin_drops_references_dir_removed_after_declaration_for_optional_skill( self, @@ -2006,7 +2009,7 @@ def test_register_plugin_drops_references_dir_removed_after_declaration_for_opti references_dir.rmdir() ctx = FakePluginCtx() - with self.assertLogs(level="WARNING") as logs: + with self.assertLogs(level="DEBUG") as logs: summary = hpk.register_plugin(ctx, self._module(), skills=(skill,)) self.assertEqual(summary.skills, ("sample",)) @@ -2042,7 +2045,7 @@ def test_register_plugin_treats_uninspectable_register_skill_as_unsupported(self ctx = FakePluginCtx() with ( patch.object(hpk, "inspect") as fake_inspect, - self.assertLogs(level="WARNING") as logs, + self.assertLogs(level="DEBUG") as logs, ): fake_inspect.signature.side_effect = ValueError("no signature found") fake_inspect.Parameter = inspect.Parameter @@ -2050,7 +2053,10 @@ def test_register_plugin_treats_uninspectable_register_skill_as_unsupported(self self.assertEqual(summary.skills, ("sample",)) self.assertNotIn("references_dir", ctx.skills[0]) - self.assertIn("does not yet accept references_dir", "\n".join(logs.output)) + self.assertIn("does not accept references_dir", "\n".join(logs.output)) + # The kit no longer claims the files go unserved: Hermes serves them + # through its skills tool regardless of this signature. + self.assertNotIn("until the host adds support", "\n".join(logs.output)) def test_register_plugin_passes_references_dir_to_a_host_with_an_explicit_parameter( self, @@ -2086,7 +2092,7 @@ def test_register_plugin_retries_without_references_dir_when_host_rejects_it_at_ skill = hpk.plugin_skill("sample", skill_path, "Sample.", references_dir=references_dir) ctx = RecordingPluginContext(references_dir_probe_lies=True) - with self.assertLogs(level="WARNING") as logs: + with self.assertLogs(level="DEBUG") as logs: summary = hpk.register_plugin(ctx, self._module(), skills=(skill,)) self.assertEqual(summary.skills, ("sample",)) diff --git a/tests/test_testing_harness.py b/tests/test_testing_harness.py index c396edd..3ad45f8 100644 --- a/tests/test_testing_harness.py +++ b/tests/test_testing_harness.py @@ -8,11 +8,14 @@ from __future__ import annotations +import contextlib +import types import re import subprocess import sys import tempfile import unittest +from unittest.mock import patch from pathlib import Path import hermes_plugin_kit as hpk @@ -706,3 +709,174 @@ def test_every_unavailable_path_yields_an_unchecked_report(self) -> None: report = ctx.check_against_host(resolved.plugin_context_class()) self.assertFalse(report.checked) self.assertFalse(report.clean) + + +class CompanionFileCapabilityTests(unittest.TestCase): + """`register_skill`'s signature is not the only way a host serves files. + + Hermes has served skill companion files through its own skills tool since + at least the pinned revision -- `_plugin_skill_linked_files` returns them + as `linked_files` alongside the skill body. The kit probed only + `register_skill`'s signature and announced the capability missing, which + is a false negative that sent at least one plugin off to build a + workaround it did not need. + """ + + def setUp(self) -> None: + self._tmp = tempfile.TemporaryDirectory() + self.addCleanup(self._tmp.cleanup) + root = Path(self._tmp.name) + (root / "SKILL.md").write_text( + "---\nname: probe-skill\ndescription: A probe skill.\n---\n\n# probe\n" + ) + (root / "references").mkdir() + self.skill = hpk.plugin_skill( + name="probe-skill", + path=str(root / "SKILL.md"), + description="A probe skill.", + references_dir=str(root / "references"), + ) + + def _register(self, ctx): + with self.assertLogs("hermes_plugin_kit", level="INFO") as captured: + hpk.register_plugin(ctx, [], skills=[self.skill], plugin_name="probe-plugin") + return "\n".join(captured.output) + + def test_no_unsupported_claim_when_the_host_serves_companion_files(self) -> None: + ctx = hpk_testing.RecordingPluginContext( + name="probe-plugin", supports_references_dir=False + ) + + with _host_serving_companion_files(): + logs = self._register(ctx) + + self.assertNotIn("does not yet accept references_dir", logs) + self.assertNotIn("until the host adds support", logs) + + def test_an_undetectable_host_is_not_declared_unsupported(self) -> None: + """Not being able to tell is not the same as knowing it is missing.""" + ctx = hpk_testing.RecordingPluginContext( + name="probe-plugin", supports_references_dir=False + ) + + with _no_host_modules(): + logs = self._register(ctx) + + self.assertNotIn("until the host adds support", logs) + self.assertIn("plugin_reference_tool", logs) + + def test_the_skill_still_registers_either_way(self) -> None: + ctx = hpk_testing.RecordingPluginContext( + name="probe-plugin", supports_references_dir=False + ) + + self._register(ctx) + + self.assertEqual(["probe-skill"], [s["name"] for s in ctx.skills]) + + +@contextlib.contextmanager +def _no_host_modules(): + """Hide any ambient Hermes checkout, so the probe genuinely cannot tell.""" + hidden = {k: None for k in list(sys.modules) if k.split(".")[0] == "tools"} + hidden.setdefault("tools", None) + with patch.dict(sys.modules, hidden): + yield + + +@contextlib.contextmanager +def _host_serving_companion_files(): + """Stand in for a Hermes host whose skills tool serves linked files.""" + module = types.ModuleType("tools.skills_tool") + module._plugin_skill_linked_files = lambda root: {"references": ["a.md"]} + tools = types.ModuleType("tools") + tools.skills_tool = module + with patch.dict(sys.modules, {"tools": tools, "tools.skills_tool": module}): + yield + + +class DiscardedExampleTests(unittest.TestCase): + """An example on an optional key never reached the agent. + + `_split_params` collects it, then `_augment_description` iterates only + `required` and the validation error path is required-only too. A plugin + with a good example on a genuinely optional field lost it silently -- one + fleet plugin had a usable example no agent ever saw, while its handler + refused calls that omitted the field. + """ + + def _schema(self, **params): + return hpk.build_schema("probe_example", "Do a thing.", params) + + def test_an_example_on_an_optional_key_reaches_the_description(self) -> None: + schema = self._schema( + needed=hpk.str_arg("req", required=True, example="abc"), + optional=hpk.str_arg("opt", required=False, example="xyz"), + ) + + self.assertIn("xyz", schema["description"]) + + def test_required_examples_still_render_as_required(self) -> None: + schema = self._schema( + needed=hpk.str_arg("req", required=True, example="abc"), + ) + + self.assertIn("Required:", schema["description"]) + self.assertIn("abc", schema["description"]) + + def test_an_optional_example_is_not_labelled_required(self) -> None: + schema = self._schema( + optional=hpk.str_arg("opt", required=False, example="xyz"), + ) + + description = schema["description"] + self.assertIn("xyz", description) + self.assertNotIn("Required:", description) + + def test_a_description_without_examples_is_unchanged(self) -> None: + schema = self._schema(plain=hpk.str_arg("plain")) + + self.assertEqual("Do a thing.", schema["description"]) + + +class ReferenceToolDescriptionTests(unittest.TestCase): + """A tool that names no files gives an agent no reason to call it. + + Two fleet reference readers were registered on three profiles and called + zero times in eight days. `references_dir` is known at build time, so the + filenames cost nothing to include. + """ + + def setUp(self) -> None: + self._tmp = tempfile.TemporaryDirectory() + self.addCleanup(self._tmp.cleanup) + root = Path(self._tmp.name) + (root / "SKILL.md").write_text( + "---\nname: probe-skill\ndescription: A probe skill.\n---\n\n# probe\n" + ) + refs = root / "references" + refs.mkdir() + (refs / "schema.md").write_text("schema") + (refs / "nested").mkdir() + (refs / "nested" / "rules.md").write_text("rules") + self.skill = hpk.plugin_skill( + name="probe-skill", path=str(root / "SKILL.md"), + description="A probe skill.", references_dir=str(refs), + ) + + def test_the_default_description_names_the_available_files(self) -> None: + reader = hpk.plugin_reference_tool(self.skill, toolset="probe") + description = getattr(reader, "_hpk_tool_spec")["schema"]["description"] + + self.assertIn("schema.md", description) + self.assertIn("nested/rules.md", description) + + def test_an_explicit_description_is_left_alone(self) -> None: + reader = hpk.plugin_reference_tool( + self.skill, toolset="probe", description="My own wording." + ) + + self.assertEqual( + "My own wording.", + getattr(reader, "_hpk_tool_spec")["schema"]["description"], + )