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(auto-harness): fix auto harness config edit

ray_le2b7b887603b7
diff --git a/jiuwenswarm/agents/harness/common/auto_harness/config_validator.py b/jiuwenswarm/agents/harness/common/auto_harness/config_validator.py
index b3afbee2bc..97a0da2552 100644
--- a/jiuwenswarm/agents/harness/common/auto_harness/config_validator.py
+++ b/jiuwenswarm/agents/harness/common/auto_harness/config_validator.py
@@ -19,9 +19,8 @@ class ConfigValidator:
"""Validates git and gitcode configuration for scheduled tasks.
Required fields:
- - git.user_name: Git commit username
+ - git.user_name: Git commit username (同时设置 fork_owner 和 gitcode.username)
- git.user_email: Git commit email
- - git.fork_owner: Fork repository owner
- gitcode.access_token: GitCode API token (optional, can use env var)
"""
@@ -29,9 +28,14 @@ class ConfigValidator:
{
"id": "git.user_name",
"key": "user_name",
- "prompt": "请输入 git 用户名(用于 commit)",
+ "prompt": "请输入用户名(用于 git commit、创建 PR、GitCode 登录)",
"section": "git",
"optional": False,
+ # 合并标记:此字段值同时设置 fork_owner 和 gitcode.username
+ "also_set": [
+ {"section": "git", "key": "fork_owner"},
+ {"section": "gitcode", "key": "username"},
+ ],
},
{
"id": "git.user_email",
@@ -40,13 +44,6 @@ class ConfigValidator:
"section": "git",
"optional": False,
},
- {
- "id": "git.fork_owner",
- "key": "fork_owner",
- "prompt": "请输入 fork 仓库所有者(如 'SnapeK')",
- "section": "git",
- "optional": False,
- },
{
"id": "gitcode.access_token",
"key": "access_token",
@@ -114,6 +111,20 @@ class ConfigValidator:
if not value:
missing.append(field)
+ # For merged user_name field, also check if fork_owner/gitcode.username exist
+ # (they may have been set before the merge, so treat as valid if present)
+ user_name_missing = any(f["id"] == "git.user_name" for f in missing)
+ if user_name_missing:
+ # Check if fork_owner or gitcode.username exist as fallback
+ fork_owner = self._get_config_value("git", "fork_owner")
+ gitcode_username = self._get_config_value("gitcode", "username")
+ if fork_owner or gitcode_username:
+ # Remove user_name from missing - we can use existing values
+ missing = [f for f in missing if f["id"] != "git.user_name"]
+ logger.info(
+ "[ConfigValidator] git.user_name missing but fork_owner/gitcode.username exists, treating as valid"
+ )
+
return {
"valid": len(missing) == 0,
"missing_fields": missing,
@@ -125,7 +136,7 @@ class ConfigValidator:
Args:
fields: Dict mapping field_id to user-provided value
- e.g., {"git.user_name": "SnapeK"}
+ e.g., {"git.user_name": "auto-harness"}
Returns:
{"success": bool, "updated_fields": list}
@@ -145,6 +156,19 @@ class ConfigValidator:
config[section][key] = value
updated.append(field_id)
+
+ # Handle also_set: propagate value to related fields
+ also_set = field_def.get("also_set", [])
+ for target in also_set:
+ target_section = target["section"]
+ target_key = target["key"]
+ if target_section not in config:
+ config[target_section] = {}
+ config[target_section][target_key] = value
+ logger.info(
+ "[ConfigValidator] Also set %s.%s = %s",
+ target_section, target_key, value,
+ )
break
self._save_config_yaml(config)
diff --git a/jiuwenswarm/channels/web/frontend/src/components/HarnessPackagePanel/index.tsx b/jiuwenswarm/channels/web/frontend/src/components/HarnessPackagePanel/index.tsx
index 8b44dd056b..5a39f0026a 100644
--- a/jiuwenswarm/channels/web/frontend/src/components/HarnessPackagePanel/index.tsx
+++ b/jiuwenswarm/channels/web/frontend/src/components/HarnessPackagePanel/index.tsx
@@ -103,9 +103,10 @@ export function HarnessPackagePanel({ sessionId }: HarnessPackagePanelProps) {
}
}, [setLoadingPackages, setPackages, t]);
+ // Initial load - scan packages directory (refresh) on mount
useEffect(() => {
- fetchPackages();
- }, [fetchPackages]);
+ scanPackages();
+ }, [scanPackages]);
// Get selected package info
const getSelectedPackage = useCallback((): PackageInfo | null => {
diff --git a/jiuwenswarm/gateway/channel_manager/tui/tui_connect.py b/jiuwenswarm/gateway/channel_manager/tui/tui_connect.py
index 6282ef3431..69921700e2 100644
--- a/jiuwenswarm/gateway/channel_manager/tui/tui_connect.py
+++ b/jiuwenswarm/gateway/channel_manager/tui/tui_connect.py
@@ -122,11 +122,19 @@ def _save_auto_harness_config(config: dict[str, Any]) -> None:
def _update_auto_harness_git_user_name(value: str) -> None:
- """Update git.user_name in auto-harness config."""
+ """Update git.user_name, fork_owner, and gitcode.username in auto-harness config.
+ - git.user_name: 用于 git commit
+ - git.fork_owner: 用于创建 PR
+ - gitcode.username: GitCode 登录用户名
+ """
config = _get_auto_harness_config()
if "git" not in config:
config["git"] = {}
config["git"]["user_name"] = value
+ config["git"]["fork_owner"] = value # 合并:用户名同时作为 fork_owner
+ if "gitcode" not in config:
+ config["gitcode"] = {}
+ config["gitcode"]["username"] = value # 合并:用户名同时作为 gitcode.username
_save_auto_harness_config(config)
@@ -139,15 +147,6 @@ def _update_auto_harness_git_user_email(value: str) -> None:
_save_auto_harness_config(config)
-def _update_auto_harness_git_fork_owner(value: str) -> None:
- """Update git.fork_owner in auto-harness config."""
- config = _get_auto_harness_config()
- if "git" not in config:
- config["git"] = {}
- config["git"]["fork_owner"] = value
- _save_auto_harness_config(config)
-
-
def _update_auto_harness_gitcode_access_token(value: str) -> None:
"""Update gitcode.access_token in auto-harness config."""
config = _get_auto_harness_config()
@@ -156,15 +155,6 @@ def _update_auto_harness_gitcode_access_token(value: str) -> None:
config["gitcode"]["access_token"] = value
_save_auto_harness_config(config)
-
-def _update_auto_harness_gitcode_username(value: str) -> None:
- """Update gitcode.username in auto-harness config."""
- config = _get_auto_harness_config()
- if "gitcode" not in config:
- config["gitcode"] = {}
- config["gitcode"]["username"] = value
- _save_auto_harness_config(config)
-
# ── 需要转发到 Agent 的方法集合 ──────────────────────────────
CLI_FORWARD_REQ_METHODS = frozenset(
@@ -408,11 +398,10 @@ _CLI_CONFIG_YAML_SETTERS: dict[str, Any] = {
"memory_forbidden_enabled": update_memory_forbidden_enabled_in_config,
"preferred_language": update_preferred_language_in_config,
# Auto-Harness config items (stored in ~/.jiuwenswarm/auto-harness/config.yaml)
+ # 用户名同时设置 git.user_name, fork_owner, gitcode.username(三者合一)
"auto_harness_git_user_name": _update_auto_harness_git_user_name,
"auto_harness_git_user_email": _update_auto_harness_git_user_email,
- "auto_harness_git_fork_owner": _update_auto_harness_git_fork_owner,
"auto_harness_gitcode_access_token": _update_auto_harness_gitcode_access_token,
- "auto_harness_gitcode_username": _update_auto_harness_gitcode_username,
}
_CLI_CONFIG_YAML_KEYS = frozenset(_CLI_CONFIG_YAML_SETTERS.keys())
@@ -513,22 +502,16 @@ def _build_config_schema() -> list[dict]:
"options": ["zh", "en"], "source": "yaml", "default": "zh"},
{"key": "evolution_auto_scan", "label": "自动扫描技能", "group": "Features",
"type": "toggle", "source": "env", "default": "false"},
- # Auto-Harness (定时任务配置)
- {"key": "auto_harness_git_user_name", "label": "Git 用户名", "group": "Auto-Harness",
- "type": "string", "source": "yaml", "default": empty,
- "description": "用于定时任务执行时的 git commit"},
- {"key": "auto_harness_git_user_email", "label": "Git 邮箱", "group": "Auto-Harness",
- "type": "string", "source": "yaml", "default": empty,
- "description": "用于定时任务执行时的 git commit"},
- {"key": "auto_harness_git_fork_owner", "label": "Fork 仓库所有者", "group": "Auto-Harness",
- "type": "string", "source": "yaml", "default": empty,
- "description": "如 'auto-harness',用于创建 PR"},
- {"key": "auto_harness_gitcode_access_token", "label": "GitCode Access Token", "group": "Auto-Harness",
- "type": "password", "sensitive": True, "source": "yaml", "default": empty,
- "description": "也可通过环境变量 GITCODE_ACCESS_TOKEN 配置"},
- {"key": "auto_harness_gitcode_username", "label": "GitCode 用户名", "group": "Auto-Harness",
- "type": "string", "source": "yaml", "default": empty,
- "description": "GitCode 登录用户名;为空时回退到 git.fork_owner"},
+ # Auto-Harness (定时任务配置) - 合并为三项
+ {"key": "auto_harness_git_user_name", "label": "用户名", "group": "Auto-Harness",
+ "type": "string", "source": "yaml", "default": empty,
+ "description": "GitCode用户名,用于 git commit、创建 PR"},
+ {"key": "auto_harness_git_user_email", "label": "邮箱", "group": "Auto-Harness",
+ "type": "string", "source": "yaml", "default": empty,
+ "description": "GitCode用户邮箱,用于 git commit"},
+ {"key": "auto_harness_gitcode_access_token", "label": "GitCode Access Token", "group": "Auto-Harness",
+ "type": "password", "sensitive": True, "source": "yaml", "default": empty,
+ "description": "GitCode Access token,也可通过环境变量 GITCODE_ACCESS_TOKEN 配置"},
]
@@ -716,24 +699,21 @@ def register_cli_handlers(bind: CliHandlersBindParams) -> None:
payload.setdefault("memory_forbidden_enabled", "false")
payload.setdefault("preferred_language", "zh")
- # Auto-Harness config values (from ~/.jiuwenclaw/auto-harness/config.yaml)
- try:
- ah_config = _get_auto_harness_config()
- git_cfg = ah_config.get("git") or {}
- gitcode_cfg = ah_config.get("gitcode") or {}
- payload["auto_harness_git_user_name"] = git_cfg.get("user_name") or ""
- payload["auto_harness_git_user_email"] = git_cfg.get("user_email") or ""
- payload["auto_harness_git_fork_owner"] = git_cfg.get("fork_owner") or ""
- # Check env var first for access_token
- ah_token = os.getenv("GITCODE_ACCESS_TOKEN") or gitcode_cfg.get("access_token") or ""
- payload["auto_harness_gitcode_access_token"] = ah_token
- payload["auto_harness_gitcode_username"] = gitcode_cfg.get("username") or ""
- except Exception:
- payload.setdefault("auto_harness_git_user_name", "")
- payload.setdefault("auto_harness_git_user_email", "")
- payload.setdefault("auto_harness_git_fork_owner", "")
- payload.setdefault("auto_harness_gitcode_access_token", "")
- payload.setdefault("auto_harness_gitcode_username", "")
+ # Auto-Harness config values (from ~/.jiuwenclaw/auto-harness/config.yaml)
+ # 合并显示:用户名、邮箱、Access Token 三项
+ try:
+ ah_config = _get_auto_harness_config()
+ git_cfg = ah_config.get("git") or {}
+ gitcode_cfg = ah_config.get("gitcode") or {}
+ payload["auto_harness_git_user_name"] = git_cfg.get("user_name") or ""
+ payload["auto_harness_git_user_email"] = git_cfg.get("user_email") or ""
+ # Check env var first for access_token
+ ah_token = os.getenv("GITCODE_ACCESS_TOKEN") or gitcode_cfg.get("access_token") or ""
+ payload["auto_harness_gitcode_access_token"] = ah_token
+ except Exception:
+ payload.setdefault("auto_harness_git_user_name", "")
+ payload.setdefault("auto_harness_git_user_email", "")
+ payload.setdefault("auto_harness_gitcode_access_token", "")
payload["schema"] = _build_config_schema()
await channel.send_response(ws, req_id, ok=True, payload=payload)