fix: web_fetch encoding

This commit is contained in:
zhayujie
2026-03-11 19:42:37 +08:00
parent fa61744c6d
commit d8374d0fa5
5 changed files with 80 additions and 0 deletions

View File

@@ -386,10 +386,39 @@ def _build_workspace_section(workspace_dir: str, language: str) -> List[str]:
"- 例如用自然表达例如「我已记住」而不是「已更新 MEMORY.md」",
"",
]
# Cloud deployment: inject websites directory info and access URL
cloud_website_lines = _build_cloud_website_section(workspace_dir)
if cloud_website_lines:
lines.extend(cloud_website_lines)
return lines
def _build_cloud_website_section(workspace_dir: str) -> List[str]:
"""Build cloud website access prompt when cloud deployment is configured."""
try:
from common.cloud_client import get_website_base_url
except Exception:
return []
base_url = get_website_base_url()
if not base_url:
return []
return [
"**网页/网站生成规则** (非常重要):",
"",
f"- 当需要编写网页、网站、H5页面等前端代码时**必须**将所有文件统一放到工作空间的 `websites/` 目录中(路径: `{workspace_dir}/websites/`",
f"- 云端已为该目录配置好路由映射,访问地址为: `{base_url}`",
f" - 例如: 你在 `websites/index.html` 创建了页面,访问地址就是 `{base_url}/index.html`",
f" - 例如: 你在 `websites/my-app/index.html` 创建了页面,访问地址就是 `{base_url}/my-app/index.html`",
"- **生成网页后,必须将完整的访问链接直接发送给用户**,让用户可以直接点击访问",
"- 建议为每个独立项目在 `websites/` 下创建子目录,保持结构清晰",
"",
]
def _build_context_files_section(context_files: List[ContextFile], language: str) -> List[str]:
"""构建项目上下文文件section"""
if not context_files:

View File

@@ -61,6 +61,10 @@ def ensure_workspace(workspace_dir: str, create_templates: bool = True) -> Works
# 创建skills子目录 (for workspace-level skills installed by agent)
skills_dir = os.path.join(workspace_dir, "skills")
os.makedirs(skills_dir, exist_ok=True)
# 创建websites子目录 (for web pages / sites generated by agent)
websites_dir = os.path.join(workspace_dir, "websites")
os.makedirs(websites_dir, exist_ok=True)
# 如果需要,创建模板文件
if create_templates: