This commit is contained in:
@@ -368,7 +368,7 @@ def _build_project_backend(ctx: BuilderContext, *, settings: Settings) -> Any |
|
||||
except Exception: # noqa: BLE001
|
||||
return _with_builder_skills(StateBackend())
|
||||
return _with_builder_skills(
|
||||
WorkspaceBackend(ctx.workspace),
|
||||
_workspace_backend_with_grep_compat(WorkspaceBackend, ctx.workspace),
|
||||
artifacts_root=f"/{prefix}/{_BUILDER_ARTIFACT_DIR}",
|
||||
)
|
||||
try:
|
||||
@@ -404,11 +404,41 @@ def _build_project_backend(ctx: BuilderContext, *, settings: Settings) -> Any |
|
||||
)
|
||||
)
|
||||
return _with_builder_skills(
|
||||
WorkspaceBackend(workspace),
|
||||
_workspace_backend_with_grep_compat(WorkspaceBackend, workspace),
|
||||
artifacts_root=f"/{prefix}/{_BUILDER_ARTIFACT_DIR}",
|
||||
)
|
||||
|
||||
|
||||
def _workspace_backend_with_grep_compat(workspace_backend_cls: Any, workspace: Any) -> Any:
|
||||
"""Patch older a2a-pack WorkspaceBackend grep glob behavior.
|
||||
|
||||
Older ``WorkspaceBackend.grep`` only matched ``glob`` against the full
|
||||
workspace key. DeepAgents commonly calls ``grep(path="/agents/name",
|
||||
glob="agent.py")``, which should match ``agents/name/agent.py``.
|
||||
"""
|
||||
|
||||
class BuilderWorkspaceBackend(workspace_backend_cls): # type: ignore[misc, valid-type]
|
||||
def grep(
|
||||
self,
|
||||
pattern: str,
|
||||
path: str | None = None,
|
||||
glob: str | None = None,
|
||||
) -> Any:
|
||||
result = super().grep(pattern, path=path, glob=glob)
|
||||
if not glob or not path or getattr(result, "matches", None):
|
||||
return result
|
||||
norm = getattr(self, "_norm", None)
|
||||
base = norm(path) if callable(norm) else path.strip("/")
|
||||
if not base:
|
||||
return result
|
||||
scoped_glob = f"{base.rstrip('/')}/{glob.lstrip('/')}"
|
||||
if scoped_glob == glob:
|
||||
return result
|
||||
return super().grep(pattern, path=path, glob=scoped_glob)
|
||||
|
||||
return BuilderWorkspaceBackend(workspace)
|
||||
|
||||
|
||||
def _with_builder_skills(default_backend: Any, *, artifacts_root: str = "/") -> Any:
|
||||
skill_store = InMemoryStore()
|
||||
for path, content in _builder_skill_files().items():
|
||||
|
||||
Reference in New Issue
Block a user