Hồi quy đã vá
-------------
F-12 Kéo–thả hoặc dán tệp vào ô chat ném NameError. R08 tách `_Input` sang
`chat_input_box.py` nhưng để `_paths_from_mime()` ở lại
`composer_widget.py`, nên hai hàm sự kiện Qt gọi một cái tên không tồn
tại. Bốn hàm dùng chung chuyển sang `composer_mime.py` — module thứ ba
là chỗ duy nhất không lặp lại được lỗi này. Đo lại: cả thả lẫn dán đều
gắn 1 tệp, khớp bản trước refactor.
F-01 Đổi provider thì bộ chọn model AI-Edit không làm gì. Hook cũ kiểm
`folder.ai_model_combo`, thuộc tính R08-T12 đã dời sang
`ai_panel.resolver`. Làm mới vô điều kiện, đúng như tab cũ: lần lấy đầu
tiên hỏng thì đổi provider chính là lúc phải thử lại.
F-07 Hàng chọn kỳ của Dashboard bị đẩy xuống dưới các thẻ số liệu. Hàng này
lọc CẢ BA thẻ con chứ không riêng biểu đồ, nên để nó nằm dưới là bắt
người dùng đọc con số trước khi thấy con số đó tính cho kỳ nào. Kèm
theo: `TokenUsageCardWidget` bị bỏ sót `setContentsMargins(0,0,0,0)`
mà hai thẻ con còn lại đã có, đẩy cả hàng thẻ lệch 9px.
`check_layout_geometry` nay khớp TỪNG BYTE với bản trước refactor.
F-11 Hai lớp khai trùng tên phương thức; Python giữ bản sau nên bản đầu là
mã chết. `co4e_tab.py::showEvent` bản đầu gọi `_narrow_guard.attach()`
và không bao giờ chạy.
Tách file (F-09)
----------------
Bốn file chạm trần 400 dòng, mỗi lần cắt ra một trách nhiệm thật:
graph_renderer.py -> graph_scene_builder.py + graph_export.py
co4e_workflow_service.py -> co4e_run_history.py
json_config_repository.py -> config_sections.py
agents_admin_tab.py -> shared/agent_kind_visuals.py
File cuối còn xoá 3 bản sao của hàm đã có trong `shared/formatters.py`,
giống hệt đến từng dòng — nay định dạng thời gian và avatar không lệch nhau
giữa các bảng Giám sát nữa.
Docstring
---------
41,6% -> 100% (3.478/3.478 định nghĩa production), kể cả module dormant và
phương thức dunder. Toàn bộ phần bổ sung viết bằng tiếng Việt; comment tiếng
Anh có sẵn giữ nguyên — dịch ngược là một đợt riêng.
Seam chưa nối dây (F-05)
------------------------
9 seam mang nhãn `SEAM · dựng <ngày>` kèm hai câu: được nối khi nào, và để
dormant thì hỏng gì. Ngày lấy từ lịch sử git, không phải hạn tự đặt. Gate O
đọc nhãn đó và nhắc khi quá 30 ngày.
859 test xanh · 4/4 cổng CASAN · 19/24 checker khớp từng byte bản cũ.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
58 lines
2.5 KiB
Python
58 lines
2.5 KiB
Python
"""Fetch tools - fetch_url, jira_search, jira_get_issue (R05-T02).
|
|
|
|
Moved verbatim out of ``core/tools.py`` (see ``file_tools.py`` for why). The
|
|
network access these three carry is exactly what the ``ToolCapability.NETWORK``
|
|
tag added in R05-T01/domain/tools/tool_registry.py describes.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any, Dict
|
|
|
|
from .tool_context import ToolContext
|
|
|
|
|
|
def fetch_url(ctx: ToolContext, args: Dict[str, Any]) -> Dict[str, Any]:
|
|
"""Fetch a URL's text content (web page / online document / SharePoint-
|
|
OneDrive share link) via link_fetch — the same parser task-link attachments
|
|
use. Honors the Sandbox Security Layer's "Block network" policy."""
|
|
url = str(args.get("url", "")).strip()
|
|
if not url:
|
|
return {"ok": False, "output": "fetch_url: 'url' is required."}
|
|
if not url.lower().startswith(("http://", "https://")):
|
|
return {"ok": False, "output": f"fetch_url: not an http(s) URL: {url}"}
|
|
if not ctx.allow_url_fetch:
|
|
return {"ok": False,
|
|
"output": ("fetch_url: URL fetching is turned off in Settings → Security "
|
|
"(\"Allow the agent to fetch URLs\").")}
|
|
# A pasted Jira issue link on the CONNECTED Jira host is read via the
|
|
# authenticated API (so private issues resolve, not a login page). Public
|
|
# links / any other URL fall through to the normal fetcher below.
|
|
from cowork_local.core import jira_tool
|
|
if jira_tool.is_jira_issue_url(ctx.jira, url):
|
|
return {"ok": True, "output": jira_tool.get_issue_by_url(ctx.jira, url)}
|
|
from cowork_local.core.link_fetch import fetch_link_preview
|
|
|
|
return {"ok": True, "output": fetch_link_preview(url)}
|
|
|
|
|
|
def jira_search(ctx: ToolContext, args: Dict[str, Any]) -> Dict[str, Any]:
|
|
"""Tìm issue trên Jira bằng JQL."""
|
|
from cowork_local.core import jira_tool
|
|
|
|
out = jira_tool.search(ctx.jira, str(args.get("jql", "")),
|
|
int(args.get("max_results", 25) or 25))
|
|
return {"ok": not out.lower().startswith(("jira is not configured", "jira search failed")),
|
|
"output": out}
|
|
|
|
|
|
def jira_get_issue(ctx: ToolContext, args: Dict[str, Any]) -> Dict[str, Any]:
|
|
"""Lấy chi tiết một issue Jira theo mã."""
|
|
from cowork_local.core import jira_tool
|
|
|
|
out = jira_tool.get_issue(ctx.jira, str(args.get("key", "")))
|
|
return {"ok": not out.lower().startswith(("jira is not configured", "could not fetch")),
|
|
"output": out}
|
|
|
|
|
|
__all__ = ["fetch_url", "jira_search", "jira_get_issue"]
|