Refine drive skill prompt output

This commit is contained in:
Yanli 盐粒 2026-06-25 23:31:27 +08:00
parent 12ed444889
commit d67b0bb615
2 changed files with 9 additions and 3 deletions

View File

@ -128,7 +128,7 @@ class DifyDriveLayer(PlainLayer[DifyDriveDeps, DifyDriveLayerConfig, EmptyRuntim
continue
local_path = Path(pulled_skill_path).parent
loaded_skill_sections.append(
f"Path: {skill.path}\nLocal path: {local_path}\nName: {skill.name}\nSKILL.md:\n{body}"
f"Path: {skill.path}\nLocal path: {local_path}\nSKILL.md:\n{body}"
)
if loaded_skill_sections:
sections.append("Loaded mentioned skills:\n\n" + "\n\n".join(loaded_skill_sections))
@ -158,7 +158,8 @@ class DifyDriveLayer(PlainLayer[DifyDriveDeps, DifyDriveLayerConfig, EmptyRuntim
"Other available skills:\n"
+ "\n".join(other_skills)
+ "\n\nTo use one, pull it and read its SKILL.md in one command: "
'`cat "$(dify-agent drive pull <SKILL_PATH> --to /tmp/drive)/SKILL.md"`.'
'`skill_dir="$(dify-agent drive pull <SKILL_PATH> --to /tmp/drive)"; '
'printf "%s\\n" "$skill_dir"; cat "$skill_dir/SKILL.md"`.'
)
sections.append(_AGENT_STUB_CLI_USAGE_PROMPT)
return "\n\n".join(sections)

View File

@ -102,7 +102,10 @@ def test_drive_layer_exposes_agent_stub_cli_usage_suffix_prompt(tmp_path: Path)
assert "Other available skills" in prompt
assert "other-skill: Other Skill — Fallback catalog entry." in prompt
assert "`dify-agent drive pull other-skill/`" not in prompt
assert '`cat "$(dify-agent drive pull <SKILL_PATH> --to /tmp/drive)/SKILL.md"`' in prompt
assert (
'`skill_dir="$(dify-agent drive pull <SKILL_PATH> --to /tmp/drive)"; '
'printf "%s\\n" "$skill_dir"; cat "$skill_dir/SKILL.md"`'
) in prompt
assert "dify-agent drive list [REMOTE_PREFIX]" in prompt
assert "dify-agent drive pull [REMOTE ...] [--to LOCAL_DIR]" in prompt
assert "--to ." in prompt
@ -152,6 +155,7 @@ async def test_on_context_create_loads_mentioned_targets_into_prompt(
prompt = layer.build_prompt_context()
assert "Loaded mentioned skills" in prompt
assert f"Local path: {tmp_path / 'tender-analyzer'}" in prompt
assert "Name: Tender Analyzer" not in prompt
assert "# Tender Analyzer\nUse carefully." in prompt
assert f"files/report.pdf -> {tmp_path / 'files' / 'report.pdf'}" in prompt
assert "Other available skills" not in prompt
@ -193,6 +197,7 @@ async def test_on_context_resume_loads_mentioned_targets_into_prompt(
prompt = layer.build_prompt_context()
assert "Loaded mentioned skills" in prompt
assert f"Local path: {tmp_path / 'tender-analyzer'}" in prompt
assert "Name: Tender Analyzer" not in prompt
assert "# Tender Analyzer\nUse carefully." in prompt
assert f"files/report.pdf -> {tmp_path / 'files' / 'report.pdf'}" in prompt
assert "Other available skills" not in prompt