Skip to content

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(jiuwenclaw): jiuwenclaw-init --name qq not create sub folder fix:: (HTTP 403): {"error": "forbidden_path"}

openJiuwen-botd1567f5245de
diff --git a/jiuwenclaw/init_workspace.py b/jiuwenclaw/init_workspace.py
index 665bb861fc..8555980693 100644
--- a/jiuwenclaw/init_workspace.py
+++ b/jiuwenclaw/init_workspace.py
@@ -20,7 +20,6 @@ from __future__ import annotations
import argparse
import logging
-import os
import sys
from typing import Optional
@@ -91,10 +90,9 @@ def run_init(force: bool = False, name: Optional[str] = None) -> int:
print(f"[jiuwenclaw-init] Stop it first with: jiuwenclaw-start --stop default")
return 1
- # 4. Set environment variable, then call init_user_workspace
+ # 4. Call init_user_workspace with workspace path
# (deletion and confirmation handled by init_user_workspace)
- os.environ["JIUWENCLAW_DATA_DIR"] = str(workspace_path)
- target = init_user_workspace(overwrite=force)
+ target = init_user_workspace(overwrite=force, workspace_dir=workspace_path)
# 5. Post-init: create bootstrap .env and update instances.yaml for named instance
if name and target != "cancelled":
diff --git a/jiuwenclaw/utils.py b/jiuwenclaw/utils.py
index 7361467cbd..676372117d 100644
--- a/jiuwenclaw/utils.py
+++ b/jiuwenclaw/utils.py
@@ -655,12 +655,16 @@ def cleanup_team_files(workspace_dir: Path) -> None:
def prepare_workspace(
overwrite: bool = True,
preferred_language: Optional[str] = None,
+ workspace_dir: Optional[Path] = None,
) -> None:
package_root = _find_package_root()
if not package_root:
raise RuntimeError("package root not found")
- workspace_dir = get_user_workspace_dir()
+ if workspace_dir is None:
+ workspace_dir = get_user_workspace_dir()
+ else:
+ workspace_dir = Path(workspace_dir)
workspace_dir.mkdir(parents=True, exist_ok=True)
# Check for legacy workspace migration or cleanup
@@ -840,7 +844,9 @@ def _close_log_handlers() -> None:
pass # Ignore errors during cleanup
-def init_user_workspace(overwrite: bool = True) -> Path | Literal["cancelled"]:
+def init_user_workspace(
+ overwrite: bool = True, workspace_dir: Optional[Path] = None
+) -> Path | Literal["cancelled"]:
"""Initialize ~/.jiuwenclaw from package or source resources.
资源布局:
@@ -862,8 +868,12 @@ def init_user_workspace(overwrite: bool = True) -> Path | Literal["cancelled"]:
Args:
overwrite: True 时强制清理整个工作空间目录后初始化;
False 时保留原有数据,执行迁移合并逻辑。
+ workspace_dir: 工作空间目录路径,若不指定则使用 get_user_workspace_dir() 获取。
"""
- workspace_dir = get_user_workspace_dir()
+ if workspace_dir is None:
+ workspace_dir = get_user_workspace_dir()
+ else:
+ workspace_dir = Path(workspace_dir)
if workspace_dir.exists():
if overwrite:
# Force mode: explain both modes and ask for confirmation
@@ -909,7 +919,7 @@ def init_user_workspace(overwrite: bool = True) -> Path | Literal["cancelled"]:
print("[jiuwenclaw-init] Initialization cancelled. Exiting.")
return "cancelled"
print(f"[jiuwenclaw-init] 将使用语言 / Language: {lang}")
- prepare_workspace(overwrite, preferred_language=lang)
+ prepare_workspace(overwrite, preferred_language=lang, workspace_dir=workspace_dir)
return workspace_dir
diff --git a/jiuwenclaw/web/src/components/LogsPanel/index.tsx b/jiuwenclaw/web/src/components/LogsPanel/index.tsx
index 697c384610..81aeda916b 100644
--- a/jiuwenclaw/web/src/components/LogsPanel/index.tsx
+++ b/jiuwenclaw/web/src/components/LogsPanel/index.tsx
@@ -65,7 +65,7 @@ export function LogsPanel({ isConnected: _isConnected }: LogsPanelProps) {
const fetchLogs = useCallback(async () => {
setLoading(true);
try {
- const filePath = encodeURIComponent('.logs/ws-dev.log');
+ const filePath = encodeURIComponent('agent/.logs/ws-dev.log');
const response = await fetch(`/file-api/file-content?path=${filePath}`);
if (!response.ok) {
const detail = await response.text();
@@ -165,7 +165,7 @@ export function LogsPanel({ isConnected: _isConnected }: LogsPanelProps) {
<div>
<h2 className="text-lg font-semibold">{t('logsPanel.title')}</h2>
<p className="text-sm text-text-muted mt-1">
- {t('logsPanel.dataSource')}: <span className="mono text-xs">logs/ws-dev.log</span>
+ {t('logsPanel.dataSource')}: <span className="mono text-xs">agent/.logs/ws-dev.log</span>
</p>
</div>
<div className="flex items-center gap-2">