Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions src/jojo_code/context/lazy_ignore.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,24 @@ def should_ignore(self, path: Path) -> bool:
# 获取适用的模式
patterns = self._get_patterns_for_path(path)

# 检查每个模式
for pattern in patterns:
# 处理否定模式(以 ! 开头)
if pattern.startswith("!"):
# 分离普通模式和否定模式
normal_patterns = [p for p in patterns if not p.startswith("!")]
negation_patterns = [p for p in patterns if p.startswith("!")]

# 先检查普通模式
ignored = False
for pattern in normal_patterns:
if self._match_pattern(path, pattern):
ignored = True
break

# 如果被忽略,检查否定模式
if ignored:
for pattern in negation_patterns:
if self._match_pattern(path, pattern[1:]):
return False
else:
if self._match_pattern(path, pattern):
return True

return False
return ignored

def clear_cache(self) -> None:
"""清空缓存"""
Expand Down
13 changes: 4 additions & 9 deletions src/jojo_code/core/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,10 @@ def add_route(self, method: str, path: str, handler: Any, auth_required: bool =
self.routes.append(route)

# 注册到 aiohttp
method_map = {
"GET": self.app.router.get,
"POST": self.app.router.post,
"PUT": self.app.router.put,
"DELETE": self.app.router.delete,
"PATCH": self.app.router.patch,
}

method_map[method](path, self._wrap_handler(handler))
async def wrapped_handler(request):
return await self._wrap_handler(handler)(request)

self.app.router.add_route(method, path, wrapped_handler)

logger.info(f"Registered route: {method} {path}")

Expand Down
17 changes: 9 additions & 8 deletions src/jojo_code/mcp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,15 @@ async def _discover_tools(self) -> None:
# 发送 tools/list 请求
result = await self._send_request("tools/list")

if "tools" in result:
for tool_data in result["tools"]:
tool = MCPTool(
name=tool_data.get("name", ""),
description=tool_data.get("description", ""),
input_schema=tool_data.get("inputSchema", {}),
)
self._tools[tool.name] = tool
# MCP 协议可能将结果包装在 "result" 字段中
tools_data = result.get("tools") or result.get("result", {}).get("tools", [])
for tool_data in tools_data:
tool = MCPTool(
name=tool_data.get("name", ""),
description=tool_data.get("description", ""),
input_schema=tool_data.get("inputSchema", {}),
)
self._tools[tool.name] = tool

async def _send_request(self, method: str, params: dict | None = None) -> dict:
"""发送 MCP 请求"""
Expand Down
2 changes: 0 additions & 2 deletions src/jojo_code/memory/long_term.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ def __init__(
retention_days: 保留天数
"""
if storage_dir is None:
from pathlib import Path

storage_dir = Path.home() / ".jojo-code" / "memory"

self.storage_dir = Path(storage_dir)
Expand Down
4 changes: 2 additions & 2 deletions src/jojo_code/security/denial.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ def check_with_denial_tracking(
# 检查是否超过阈值
if self._denial_tracker.is_threshold_exceeded(tool_name, args):
threshold = self._denial_tracker.threshold
msg = f"操作被连续拒绝 {threshold} 次,请检查参数或权限配置"
return False, msg
msg = f"操作被连续拒绝 {threshold} 次,请检查参数或权限配置"
return False, msg

return False, result.reason or "权限被拒绝"

Expand Down
Loading