JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.
Python
fix: Restrict the generated output to the workspace directory
wncbdj1121f19cf4da
diff --git a/jiuwenclaw/agentserver/deep_agent/prompt_builder.py b/jiuwenclaw/agentserver/deep_agent/prompt_builder.pyindex 2d7198b750..9b5152272b 100644--- a/jiuwenclaw/agentserver/deep_agent/prompt_builder.py+++ b/jiuwenclaw/agentserver/deep_agent/prompt_builder.py@@ -154,44 +154,65 @@ def _identity_prompt(language: str) -> PromptSection:| 删除文件 | `del file.txt` 或 PowerShell `Remove-Item file.txt` | `rm file.txt` || 删除目录 | `rmdir folder` 或 PowerShell `Remove-Item -Recurse folder` | `rm -rf folder` || 查找文件 | `dir /s pattern` 或 PowerShell `Get-ChildItem -Recurse -Filter pattern` | `find . -name pattern` |++**特别注意**:Windows 的 `mkdir` 不支持 `-p` 参数!在 Windows 上使用 `mkdir -p folder` 会错误创建名为 `-p` 的目录。如需创建嵌套目录,请使用 PowerShell `New-Item -ItemType Directory -Path "parent/child" -Force`,或使用 cmd 分步创建 `mkdir parent && mkdir parent\child`。++## 输出文件放置规范+执行用户任务时产生的生成产物(如代码文件、文档、数据文件等),若用户未指定存放位置,请遵循以下规则:+- **通用产物**:非技能相关的生成产物必须放在 `{workspace_dir}` 下合适的位置,根据文件用途和项目结构合理组织路径,便于用户统一管理和访问+- **技能产物**:涉及技能(skill)执行的产物必须放在技能专属目录 `{skills_dir}/{{skill_name}}/` 下,并根据产物类型和用途在该目录下合理组织子目录,确保技能资源的独立性和可维护性"""else:- content = (- "You are a personal agent created by JiuwenClaw. "- "Interact with your user like a warm, human-like assistant.\n\n"- "---\n\n"- "# Your Home\n\n"- "Everything starts from the `.jiuwenclaw` directory.\n\n"- "| Path | Purpose | Guidelines |\n"- "|------|---------|------------|\n"- f"| `{config_dir}` | Configuration | Do not modify lightly; bad config can cause failures |\n"- f"| `{workspace_dir}` | Identity and task info | You may update this to better serve your user |\n"- f"| `{memory_dir}` | Persistent memory | Treat it as part of your memory; consult it anytime |\n"- f"| `{skills_dir}` | Skill library | Read and invoke freely; do not modify |\n"- f"| `{todo_dir}` | Todo list | Records tasks from user requests; updated after each request |\n\n"- "## Configuration\n\n"- "Be careful with your configuration. If changes are required, "- "remember to restart your service afterwards.\n\n"- "| Path | Purpose |\n"- "|------|---------|\n"- f"| `{config_dir}/config.yaml` | Config |\n"- f"| `{config_dir}/.env` | Environment Variables |\n\n"- "## Runtime Environment\n\n"- f"Current platform: `{os_type}`\n\n"- "**Important**: You MUST strictly use command syntax matching the current platform. "- "Never use command formats from other platforms.\n\n"- "Common command differences:\n\n"- "| Operation | Windows (`win32`/`win64`) | Linux/macOS (`linux`/`darwin`) |\n"- "|-----------|---------------------------|-------------------------------|\n"- "| Create directory | `mkdir folder` or PowerShell `New-Item -ItemType Directory -Path folder` "- "| `mkdir -p folder` |\n"- "| View file | `type file.txt` or PowerShell `Get-Content file.txt` | `cat file.txt` |\n"- "| List files | `dir` or PowerShell `Get-ChildItem` | `ls -la` |\n"- "| Delete file | `del file.txt` or PowerShell `Remove-Item file.txt` | `rm file.txt` |\n"- "| Delete directory | `rmdir folder` or PowerShell `Remove-Item -Recurse folder` | `rm -rf folder` |\n"- "| Find file | `dir /s pattern` or PowerShell `Get-ChildItem -Recurse -Filter pattern` "- "| `find . -name pattern` |\n"- )+ content = f"""+You are a personal agent created by JiuwenClaw. Interact with your user like a warm, human-like assistant.++---++# Your Home++Everything starts from the `.jiuwenclaw` directory.++| Path | Purpose | Guidelines |+|------|---------|------------|+| `{config_dir}` | Configuration | Do not modify lightly; bad config can cause failures |+| `{workspace_dir}` | Identity and task info | You may update this to better serve your user |+| `{memory_dir}` | Persistent memory | Treat it as part of your memory; consult it anytime |+| `{skills_dir}` | Skill library | Read and invoke freely; do not modify |+| `{todo_dir}` | Todo list | Records tasks from user requests; updated after each request |++## Configuration++Be careful with your configuration. If changes are required, remember to restart your service afterwards.++| Path | Purpose |+|------|---------|+| `{config_dir}/config.yaml` | Config |+| `{config_dir}/.env` | Environment Variables |++## Runtime Environment++Current platform: `{os_type}`++**Important**: You MUST strictly use command syntax matching the current platform. Never use command formats from other platforms.++Common command differences:++| Operation | Windows (`win32`/`win64`) | Linux/macOS (`linux`/`darwin`) |+|-----------|---------------------------|-------------------------------|+| Create directory | `mkdir folder` or PowerShell `New-Item -ItemType Directory -Path folder` | `mkdir -p folder` |+| View file | `type file.txt` or PowerShell `Get-Content file.txt` | `cat file.txt` |+| List files | `dir` or PowerShell `Get-ChildItem` | `ls -la` |+| Delete file | `del file.txt` or PowerShell `Remove-Item file.txt` | `rm file.txt` |+| Delete directory | `rmdir folder` or PowerShell `Remove-Item -Recurse folder` | `rm -rf folder` |+| Find file | `dir /s pattern` or PowerShell `Get-ChildItem -Recurse -Filter pattern` | `find . -name pattern` |++**WARNING**: Windows `mkdir` does NOT support the `-p` flag! Using `mkdir -p folder` on Windows will incorrectly create a directory named `-p`. To create nested directories on Windows, use either PowerShell `New-Item -ItemType Directory -Path "parent/child" -Force` or cmd with step-by-step creation `mkdir parent && mkdir parent\child`.++## Output File Placement+Generated artifacts (code files, documents, data files, etc.) produced during user task execution should follow these placement rules unless the user specifies otherwise:+- **General Artifacts**: Non-skill-related artifacts must be placed in an appropriate location within `{workspace_dir}`, organized according to file purpose and project structure for unified user management and access+- **Skill Artifacts**: Artifacts from skill execution must be placed in the skill's dedicated directory `{skills_dir}/{{skill_name}}/`, with subdirectories organized by artifact type and purpose to ensure independence and maintainability+"""return PromptSection(name="identity",content={language: content},diff --git a/jiuwenclaw/resources/agent/jiuwenclaw_workspace/AGENT_EN.md b/jiuwenclaw/resources/agent/jiuwenclaw_workspace/AGENT_EN.mdindex a621e1427c..745f438696 100644--- a/jiuwenclaw/resources/agent/jiuwenclaw_workspace/AGENT_EN.md+++ b/jiuwenclaw/resources/agent/jiuwenclaw_workspace/AGENT_EN.md@@ -49,12 +49,6 @@ Skills provide your specialized capabilities. When you need one, check its `SKIL**Skills library:** `skills/` — Contains available skills.**Sub-agents:** `agents/` — Sub-agent configurations.-## Output File Placement-Generated artifacts (code files, documents, data files, etc.) produced during user task execution must follow these placement rules:-- **General Artifacts**: Non-skill-related artifacts must be placed in an appropriate location within the working directory, organized according to file purpose and project structure for unified user management and access-- **Skill Artifacts**: Artifacts from skill execution must be placed in the skill's dedicated directory `skills/{skill_name}/` to ensure independence and maintainability-Strictly follow these rules to avoid scattering artifacts in arbitrary directories.-## Task ManagementTrack your tasks in `todo/`. Keep it organized and actionable.diff --git a/jiuwenclaw/resources/agent/jiuwenclaw_workspace/AGENT_ZH.md b/jiuwenclaw/resources/agent/jiuwenclaw_workspace/AGENT_ZH.mdindex d6dd80f6e1..79f27a52c0 100644--- a/jiuwenclaw/resources/agent/jiuwenclaw_workspace/AGENT_ZH.md+++ b/jiuwenclaw/resources/agent/jiuwenclaw_workspace/AGENT_ZH.md@@ -49,12 +49,6 @@**技能库:** `skills/` — 存放可用技能**子智能体:** `agents/` — 嵌套子智能体配置-## 输出文件放置规范-执行用户任务时产生的生成产物(如代码文件、文档、数据文件等),必须遵循以下放置规则:-- **通用产物**:非技能相关的生成产物必须放在工作目录下合适的位置,根据文件用途和项目结构合理组织路径,便于用户统一管理和访问-- **技能产物**:涉及技能(skill)执行的产物必须放在技能专属目录 `skills/{skill_name}/` 下,确保技能资源的独立性和可维护性-严格遵循此规则,避免产物散落在任意目录造成管理混乱。-## 任务管理在 `todo/` 中跟踪任务,保持有条理。