## 重構內容 符合 leWOOOgo 積木化原則: - 新增 interfaces.py: MCPToolProvider ABC 定義 - 新增 registry.py: Provider 註冊中心 (DI 模式) - 新增 providers/: K8s, SignOz, Database 具體實作 - 重構 mcp_bridge.py: 透過 ProviderRegistry 委派執行 ## 修復 Code Review 問題 - 🔴 移除 _execute_stdio logging 敏感 parameters - 🔴 修復 conversational-view.tsx i18n 硬編碼 ## 新增檔案 - apps/api/src/plugins/mcp/interfaces.py - apps/api/src/plugins/mcp/registry.py - apps/api/src/plugins/mcp/providers/__init__.py - apps/api/src/plugins/mcp/providers/k8s_provider.py - apps/api/src/plugins/mcp/providers/signoz_provider.py - apps/api/src/plugins/mcp/providers/database_provider.py - docs/adr/ADR-015-mcp-modular-architecture.md - .dependency-cruiser.cjs (Phase 14.2 準備) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
170 lines
5.4 KiB
JavaScript
170 lines
5.4 KiB
JavaScript
/**
|
|
* Dependency Cruiser Configuration - Phase 14.2
|
|
* ==============================================
|
|
*
|
|
* ADR-014: 依賴治理規則
|
|
*
|
|
* Layer Model:
|
|
* - Layer 0: Pages (app/) - 可引用所有
|
|
* - Layer 1: Features (agent/approval/incident/dashboard) - 禁止互相引用
|
|
* - Layer 2: Shared (shared/layout) - 禁止下行引用 Layer 1
|
|
* - Layer 3: Primitives (ui/lib/stores/hooks) - 純工具層
|
|
*
|
|
* @see docs/adr/ADR-014-dependency-governance.md
|
|
*/
|
|
|
|
/** @type {import('dependency-cruiser').IConfiguration} */
|
|
module.exports = {
|
|
forbidden: [
|
|
// =========================================================================
|
|
// Layer 1: Feature Isolation (禁止跨 feature 互相引用)
|
|
// =========================================================================
|
|
{
|
|
name: "feature-isolation-agent",
|
|
comment: "agent 元件禁止引用其他 feature (approval/incident/dashboard)",
|
|
severity: "error",
|
|
from: { path: "apps/web/src/components/agent" },
|
|
to: { path: "apps/web/src/components/(approval|incident|dashboard)" }
|
|
},
|
|
{
|
|
name: "feature-isolation-approval",
|
|
comment: "approval 元件禁止引用其他 feature (agent/incident/dashboard)",
|
|
severity: "error",
|
|
from: { path: "apps/web/src/components/approval" },
|
|
to: { path: "apps/web/src/components/(agent|incident|dashboard)" }
|
|
},
|
|
{
|
|
name: "feature-isolation-incident",
|
|
comment: "incident 元件禁止引用其他 feature (agent/approval/dashboard)",
|
|
severity: "error",
|
|
from: { path: "apps/web/src/components/incident" },
|
|
to: { path: "apps/web/src/components/(agent|approval|dashboard)" }
|
|
},
|
|
{
|
|
name: "feature-isolation-dashboard",
|
|
comment: "dashboard 元件禁止引用其他 feature (agent/approval/incident)",
|
|
severity: "error",
|
|
from: { path: "apps/web/src/components/dashboard" },
|
|
to: { path: "apps/web/src/components/(agent|approval|incident)" }
|
|
},
|
|
|
|
// =========================================================================
|
|
// Layer 2: Shared Isolation (禁止 shared/ui 下行引用 feature)
|
|
// =========================================================================
|
|
{
|
|
name: "shared-no-feature-import",
|
|
comment: "shared 元件禁止引用 feature 層 (agent/approval/incident/dashboard)",
|
|
severity: "error",
|
|
from: { path: "apps/web/src/components/shared" },
|
|
to: { path: "apps/web/src/components/(agent|approval|incident|dashboard)" }
|
|
},
|
|
{
|
|
name: "ui-no-feature-import",
|
|
comment: "ui 元件禁止引用 feature 層",
|
|
severity: "error",
|
|
from: { path: "apps/web/src/components/ui" },
|
|
to: { path: "apps/web/src/components/(agent|approval|incident|dashboard|shared)" }
|
|
},
|
|
{
|
|
name: "layout-no-feature-import",
|
|
comment: "layout 元件禁止引用 feature 層",
|
|
severity: "error",
|
|
from: { path: "apps/web/src/components/layout" },
|
|
to: { path: "apps/web/src/components/(agent|approval|incident|dashboard)" }
|
|
},
|
|
|
|
// =========================================================================
|
|
// Components → App 禁止反向引用
|
|
// =========================================================================
|
|
{
|
|
name: "components-no-app-import",
|
|
comment: "components 禁止引用 app 路由層",
|
|
severity: "error",
|
|
from: { path: "apps/web/src/components" },
|
|
to: { path: "apps/web/src/app" }
|
|
},
|
|
|
|
// =========================================================================
|
|
// 禁止循環依賴
|
|
// =========================================================================
|
|
{
|
|
name: "no-circular",
|
|
comment: "禁止循環依賴",
|
|
severity: "error",
|
|
from: {},
|
|
to: {
|
|
circular: true
|
|
}
|
|
},
|
|
|
|
// =========================================================================
|
|
// Hooks/Stores/Lib 不應引用 Components (純工具層)
|
|
// =========================================================================
|
|
{
|
|
name: "hooks-no-component-import",
|
|
comment: "hooks 禁止引用 components (純工具層)",
|
|
severity: "warn",
|
|
from: { path: "apps/web/src/hooks" },
|
|
to: { path: "apps/web/src/components" }
|
|
},
|
|
{
|
|
name: "stores-no-component-import",
|
|
comment: "stores 禁止引用 components (純工具層)",
|
|
severity: "warn",
|
|
from: { path: "apps/web/src/stores" },
|
|
to: { path: "apps/web/src/components" }
|
|
},
|
|
{
|
|
name: "lib-no-component-import",
|
|
comment: "lib 禁止引用 components (純工具層)",
|
|
severity: "warn",
|
|
from: { path: "apps/web/src/lib" },
|
|
to: { path: "apps/web/src/components" }
|
|
}
|
|
],
|
|
|
|
options: {
|
|
doNotFollow: {
|
|
path: "node_modules"
|
|
},
|
|
|
|
exclude: {
|
|
path: [
|
|
"node_modules",
|
|
"\\.next",
|
|
"\\.turbo",
|
|
"dist",
|
|
"coverage",
|
|
"__tests__",
|
|
"\\.test\\.",
|
|
"\\.spec\\."
|
|
]
|
|
},
|
|
|
|
includeOnly: {
|
|
path: "apps/web/src"
|
|
},
|
|
|
|
tsPreCompilationDeps: true,
|
|
|
|
tsConfig: {
|
|
fileName: "apps/web/tsconfig.json"
|
|
},
|
|
|
|
enhancedResolveOptions: {
|
|
exportsFields: ["exports"],
|
|
conditionNames: ["import", "require", "node", "default"],
|
|
mainFields: ["main", "types"]
|
|
},
|
|
|
|
reporterOptions: {
|
|
dot: {
|
|
collapsePattern: "node_modules/(@[^/]+/[^/]+|[^/]+)"
|
|
},
|
|
text: {
|
|
highlightFocused: true
|
|
}
|
|
}
|
|
}
|
|
};
|