Skip to content

refactor(acp): consolidate AGENT_SKILLS_DIRS into ACP_BACKENDS_ALL#1913

Merged
piorpua merged 2 commits intomainfrom
refactor/consolidate-agent-skills-dirs
Mar 30, 2026
Merged

refactor(acp): consolidate AGENT_SKILLS_DIRS into ACP_BACKENDS_ALL#1913
piorpua merged 2 commits intomainfrom
refactor/consolidate-agent-skills-dirs

Conversation

@kaizhou-lab
Copy link
Copy Markdown
Collaborator

Summary

  • Add skillsDirs field to AcpBackendConfig interface in acpTypes.ts
  • Move skill directory mappings from standalone AGENT_SKILLS_DIRS into ACP_BACKENDS_ALL
  • Add hasNativeSkillSupport() and getSkillsDirsForBackend() utility functions to acpTypes.ts
  • Update setupAssistantWorkspace and AcpAgentManager to use centralized config
  • Re-export hasNativeSkillSupport from initAgent.ts for backward compatibility
  • Add 11 unit tests covering new functions

Closes #1911

Test plan

  • tests/unit/acpTypesSkillsDirs.test.ts — 11 tests for hasNativeSkillSupport and getSkillsDirsForBackend
  • tests/unit/initAgent.skills.test.ts — 19 existing tests pass (re-export compatibility)
  • tests/unit/AcpAgentManagerSkillInjection.test.ts — 4 existing tests pass
  • tests/unit/acpAgentManagerCronGuard.test.ts — 9 existing tests pass
  • bunx tsc --noEmit — no type errors

zk added 2 commits March 30, 2026 15:23
…illsDirs field

Move native skill directory mapping from the standalone AGENT_SKILLS_DIRS
constant in initAgent.ts into the AcpBackendConfig.skillsDirs field within
ACP_BACKENDS_ALL. This eliminates data duplication — adding a new agent
backend now only requires editing one configuration table.

- Add skillsDirs field to AcpBackendConfig interface
- Add hasNativeSkillSupport() and getSkillsDirsForBackend() to acpTypes.ts
- Update setupAssistantWorkspace to read from ACP_BACKENDS_ALL
- Re-export hasNativeSkillSupport from initAgent.ts for backward compat
- Add unit tests for new utility functions (acpTypesSkillsDirs.test.ts)
@piorpua piorpua added the bot:reviewing Review in progress (mutex) label Mar 30, 2026
@piorpua
Copy link
Copy Markdown
Contributor

piorpua commented Mar 30, 2026

Code Review:refactor(acp): consolidate AGENT_SKILLS_DIRS into ACP_BACKENDS_ALL (#1913)

变更概述

本 PR 将 initAgent.ts 中独立维护的 AGENT_SKILLS_DIRS 常量合并进 ACP_BACKENDS_ALLskillsDirs 字段,消除了数据重复,并将相关逻辑(hasNativeSkillSupportgetSkillsDirsForBackend)集中到 acpTypes.ts 中。同时为向后兼容性保留了 initAgent.ts 中的 re-export,并新增 11 个单元测试覆盖新函数。


方案评估

结论:✅ 方案合理

重构方向正确——skill 目录配置理应与 backend 配置放在一起,避免两处维护同步。新的 skillsDirs?: string[] 字段语义清晰,hasNativeSkillSupportgetSkillsDirsForBackend 函数职责单一。行为等价性经由测试充分验证,无设计盲点。


问题清单

🔵 LOW — initAgent.ts 中 export 语句插入在 import 块之间

文件src/process/utils/initAgent.ts,第 13–17 行

问题代码

import { uuid } from '@/common/utils';

// Re-export for backward compatibility (tests mock this path)
export { hasNativeSkillSupport };
import { existsSync } from 'fs';   // ← import 出现在 export 之后
import fs from 'fs/promises';

问题说明export 语句插在两个 import 分组之间,不符合常规排列惯例(所有 import 集中在文件顶部,export 跟随其后)。虽然 TypeScript/ESM 会对 import 进行提升,运行时不受影响,但可能引起 linter 或格式化工具告警,也降低了可读性。

修复建议:将 re-export 移到所有 import 语句之后:

import type { ICreateConversationParams } from '@/common/adapter/ipcBridge';
import type { TChatConversation, TProviderWithModel } from '@/common/config/storage';
import type { PresetAgentType } from '@/common/types/acpTypes';
import { getSkillsDirsForBackend, hasNativeSkillSupport } from '@/common/types/acpTypes';
import { uuid } from '@/common/utils';
import { existsSync } from 'fs';
import fs from 'fs/promises';
import path from 'path';
import { getSkillsDir, getBuiltinSkillsCopyDir, getAutoSkillsDir, getSystemDir } from './initStorage';
import { computeOpenClawIdentityHash } from './openclawUtils';

// Re-export for backward compatibility (tests mock this path)
export { hasNativeSkillSupport };

汇总

# 严重级别 文件 问题
1 🔵 LOW src/process/utils/initAgent.ts:14 export 语句插入在 import 块之间

结论

批准合并 — 无阻塞性问题,仅一处代码排列风格问题(LOW),不影响功能和正确性。


本报告由本地 pr-review skill 生成,包含完整项目上下文,无截断限制。

CONCLUSION: APPROVED
IS_CRITICAL_PATH: false
PR_NUMBER: 1913

@piorpua
Copy link
Copy Markdown
Contributor

piorpua commented Mar 30, 2026

✅ 已自动 review,无阻塞性问题,正在触发自动合并。

@piorpua piorpua merged commit d50e91b into main Mar 30, 2026
17 checks passed
@piorpua piorpua deleted the refactor/consolidate-agent-skills-dirs branch March 30, 2026 09:24
@piorpua piorpua added bot:done Auto-merged by bot and removed bot:reviewing Review in progress (mutex) labels Mar 30, 2026
wuhao1477 added a commit to wuhao1477/AionUi that referenced this pull request Mar 30, 2026
* 'main' of github.com:wuhao1477/AionUi: (40 commits)
  fix(agents): prevent unhandled promise rejection in bootstrap initialization (iOfficeAI#1933)
  fix(gemini): restore context after stopping a reply (iOfficeAI#1932)
  fix(codex): reject start promise immediately on process exit during startup (iOfficeAI#1929)
  fix(conversation): sync renamed titles with detail view (iOfficeAI#1927)
  fix(paste): deduplicate filenames when pasting multiple images simultaneously
  fix(mobile): add SafeArea support and update app icon (iOfficeAI#1926)
  fix(database): guard against undefined params in databaseBridge providers (iOfficeAI#1924)
  fix(conversation): validate type field before creating conversation (iOfficeAI#1921)
  fix(docs): restore wechat_group_5.png reference to wx-5.png in readme
  fix(snapshot): add maxBuffer to git add/commit exec calls (iOfficeAI#1914)
  refactor(acp): consolidate AGENT_SKILLS_DIRS into ACP_BACKENDS_ALL (iOfficeAI#1913)
  fix(gemini): guard against EACCES in workspace realpath during init (ELECTRON-BM) (iOfficeAI#1912)
  fix(channels): send raw QR ticket instead of page URL in WeChat WebUI login SSE (iOfficeAI#1910)
  .md format
  chore(pr-automation): fix missed sleep 5 in comment to sleep 10
  chore(pr-automation): increase auto-merge retry delay to 10s
  chore(pr-automation): add 5s retry for transient GitHub mergeStateStatus UNKNOWN
  fix(docs): remove trailing whitespace in OfficeCLI readmes
  chore(pr-automation): verify auto-merge success before labeling bot:done
  fix(snapshot): guard against non-existent workspace in WorkspaceSnapshotService.init (iOfficeAI#1906)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:done Auto-merged by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor: consolidate AGENT_SKILLS_DIRS into ACP_BACKENDS_ALL

2 participants