feat: 优化项目和全局配置的获取逻辑,添加Codex配置支持

This commit is contained in:
catlog22
2025-12-22 10:16:58 +08:00
parent e60d793c8c
commit f3f2051c45
2 changed files with 34 additions and 6 deletions

View File

@@ -3,4 +3,8 @@
- **CLI Tools Usage**: @~/.claude/workflows/cli-tools-usage.md
- **Coding Philosophy**: @~/.claude/workflows/coding-philosophy.md
- **Context Requirements**: @~/.claude/workflows/context-tools.md
- **File Modification**: @~/.claude/workflows/file-modification.md
- **File Modification**: @~/.claude/workflows/file-modification.md
## Agent Execution
- **Always use `run_in_background = false`** for Task tool agent calls to ensure synchronous execution and immediate result visibility

View File

@@ -42,17 +42,41 @@ function getCcwEnabledToolsCodex() {
// Get current CCW_PROJECT_ROOT from config
function getCcwProjectRoot() {
// Try project config first, then global config
const currentPath = projectPath;
const projectData = mcpAllProjects[currentPath] || {};
const ccwConfig = projectData.mcpServers?.['ccw-tools'];
return ccwConfig?.env?.CCW_PROJECT_ROOT || '';
const projectCcwConfig = projectData.mcpServers?.['ccw-tools'];
if (projectCcwConfig?.env?.CCW_PROJECT_ROOT) {
return projectCcwConfig.env.CCW_PROJECT_ROOT;
}
// Fallback to global config
const globalCcwConfig = mcpUserServers?.['ccw-tools'];
return globalCcwConfig?.env?.CCW_PROJECT_ROOT || '';
}
// Get current CCW_ALLOWED_DIRS from config
function getCcwAllowedDirs() {
// Try project config first, then global config
const currentPath = projectPath;
const projectData = mcpAllProjects[currentPath] || {};
const ccwConfig = projectData.mcpServers?.['ccw-tools'];
const projectCcwConfig = projectData.mcpServers?.['ccw-tools'];
if (projectCcwConfig?.env?.CCW_ALLOWED_DIRS) {
return projectCcwConfig.env.CCW_ALLOWED_DIRS;
}
// Fallback to global config
const globalCcwConfig = mcpUserServers?.['ccw-tools'];
return globalCcwConfig?.env?.CCW_ALLOWED_DIRS || '';
}
// Get current CCW_PROJECT_ROOT from Codex config
function getCcwProjectRootCodex() {
const ccwConfig = codexMcpServers?.['ccw-tools'];
return ccwConfig?.env?.CCW_PROJECT_ROOT || '';
}
// Get current CCW_ALLOWED_DIRS from Codex config
function getCcwAllowedDirsCodex() {
const ccwConfig = codexMcpServers?.['ccw-tools'];
return ccwConfig?.env?.CCW_ALLOWED_DIRS || '';
}
@@ -260,7 +284,7 @@ async function renderMcpManager() {
<input type="text"
class="ccw-project-root-input flex-1 px-2 py-1 text-xs bg-background border border-border rounded focus:outline-none focus:ring-1 focus:ring-primary"
placeholder="${projectPath || t('mcp.useCurrentDir')}"
value="${getCcwProjectRoot()}">
value="${getCcwProjectRootCodex()}">
<button class="p-1 text-muted-foreground hover:text-foreground"
onclick="setCcwProjectRootToCurrent()"
title="${t('mcp.useCurrentProject')}">
@@ -272,7 +296,7 @@ async function renderMcpManager() {
<input type="text"
class="ccw-allowed-dirs-input flex-1 px-2 py-1 text-xs bg-background border border-border rounded focus:outline-none focus:ring-1 focus:ring-primary"
placeholder="${t('mcp.allowedDirsPlaceholder')}"
value="${getCcwAllowedDirs()}">
value="${getCcwAllowedDirsCodex()}">
</div>
</div>
</div>