fix(agent): keep default prompt paths relative

This commit is contained in:
chengyongru
2026-08-21 11:45:05 +08:00
committed by chengyongru
parent c7710238a8
commit 8ca4bd9121
11 changed files with 94 additions and 21 deletions
+4 -1
View File
@@ -123,7 +123,10 @@ class ContextBuilder:
if active_content:
parts.append(f"# Active Skills\n\n{active_content}")
skills_summary = self.skills.build_skills_summary(exclude=set(active_skills))
skills_summary = self.skills.build_skills_summary(
exclude=set(active_skills),
workspace=root,
)
if skills_summary:
parts.append(render_template("agent/skills_section.md", skills_summary=skills_summary))
+16 -2
View File
@@ -201,7 +201,12 @@ class SkillsLoader:
),
)
def build_skills_summary(self, exclude: set[str] | None = None) -> str:
def build_skills_summary(
self,
exclude: set[str] | None = None,
*,
workspace: Path | None = None,
) -> str:
"""
Build a summary of all skills (name, description, path, availability).
@@ -210,6 +215,7 @@ class SkillsLoader:
Args:
exclude: Set of skill names to omit from the summary.
workspace: Effective project workspace used to choose safe display paths.
Returns:
Markdown-formatted skills summary.
@@ -218,6 +224,9 @@ class SkillsLoader:
if not all_skills:
return ""
agent_workspace = self.workspace.expanduser().resolve()
project_workspace = (workspace or self.workspace).expanduser().resolve()
use_relative_roots = project_workspace == agent_workspace
sections: list[str] = []
groups = (
("Workspace skills", "workspace", self.workspace_skills),
@@ -233,7 +242,12 @@ class SkillsLoader:
if not entries:
continue
lines = [f"### {label} (`{root.expanduser().resolve()}`)"]
resolved_root = root.expanduser().resolve()
if use_relative_roots:
display_root = Path("plugins" if source == "plugin" else "skills")
else:
display_root = resolved_root
lines = [f"### {label} (`{display_root}`)"]
for entry in entries:
skill_name = entry["name"]
meta = self._get_skill_meta(skill_name)
+7 -2
View File
@@ -540,12 +540,17 @@ class SubagentManager:
skills_summary = SkillsLoader(
self.workspace,
disabled_skills=self.disabled_skills,
).build_skills_summary()
).build_skills_summary(workspace=project_workspace)
history_log = (
str(agent_workspace / "memory" / "history.jsonl")
if agent_workspace != project_workspace
else "memory/history.jsonl"
)
return render_template(
"agent/subagent_system.md",
workspace=str(project_workspace),
agent_workspace=str(agent_workspace),
history_log=str(agent_workspace / "memory" / "history.jsonl"),
history_log=history_log,
skills_summary=skills_summary or "",
)