mirror of
https://github.com/hansjone/oclaw.git
synced 2026-10-10 22:03:15 +08:00
完善 agent/workspace 运行链路与工具结果治理测试覆盖,确保路由、标题生成与上下文截断行为稳定可回归。
同时将 data/wiki 用户数据纳入忽略规则,避免运行态数据被误纳入版本管理。 Made-with: Cursor
This commit is contained in:
parent
45e412b4ab
commit
20362527e2
17 changed files with 974 additions and 41 deletions
|
|
@ -179,6 +179,29 @@ def current_workspace_path_access() -> WorkspacePathAccess:
|
|||
return access_from_env()
|
||||
|
||||
|
||||
@contextmanager
|
||||
def workspace_write_namespace_scope(namespace: str | None) -> Iterator[str]:
|
||||
prev = getattr(_TLS, "write_namespace", None)
|
||||
ns = str(namespace or "").strip()
|
||||
_TLS.write_namespace = ns
|
||||
try:
|
||||
yield ns
|
||||
finally:
|
||||
if prev is None:
|
||||
if hasattr(_TLS, "write_namespace"):
|
||||
delattr(_TLS, "write_namespace")
|
||||
else:
|
||||
_TLS.write_namespace = prev
|
||||
|
||||
|
||||
def current_workspace_write_namespace() -> str:
|
||||
ns = str(getattr(_TLS, "write_namespace", "") or "").strip()
|
||||
if ns:
|
||||
return ns
|
||||
root = workspace_root()
|
||||
return str(root.name or "workspace").strip() or "workspace"
|
||||
|
||||
|
||||
def clear_workspace_path_access_for_tests() -> None:
|
||||
if hasattr(_TLS, "access"):
|
||||
delattr(_TLS, "access")
|
||||
|
|
@ -253,9 +276,11 @@ __all__ = [
|
|||
"build_workspace_path_access",
|
||||
"clear_workspace_path_access_for_tests",
|
||||
"current_workspace_path_access",
|
||||
"current_workspace_write_namespace",
|
||||
"resolve_workspace_path",
|
||||
"sanitize_git_ref",
|
||||
"truncate_text",
|
||||
"workspace_write_namespace_scope",
|
||||
"workspace_path_access_scope",
|
||||
"workspace_root",
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue