Skip to content

Commit 46b2b90

Browse files
committed
CM-65100-address-review
1 parent a4069de commit 46b2b90

5 files changed

Lines changed: 23 additions & 22 deletions

File tree

cycode/cli/apps/ai_guardrails/ides/_plugin_utils.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ def walk_enabled_plugins(
4444
is_enabled: Callable[[Any], bool],
4545
locate_dir: Callable[[str, str], Optional[Path]],
4646
read_plugin: Callable[[Path], tuple[dict, dict]],
47-
) -> tuple[dict, dict]:
48-
"""Iterate enabled plugins; merge their MCP servers and metadata.
47+
) -> dict:
48+
"""Iterate enabled plugins and build their inventory metadata.
4949
5050
Args:
5151
plugin_entries: ``{<plugin>@<marketplace>: settings}`` map from the IDE config.
@@ -55,13 +55,13 @@ def walk_enabled_plugins(
5555
filesystem path or None if it can't be resolved.
5656
read_plugin: given the plugin path, returns ``(entry_fields, servers)``:
5757
``entry_fields`` are extra metadata to attach to the inventory entry
58-
(name/version/description/...), ``servers`` are MCP servers contributed.
58+
(name/version/description/...); ``servers`` are the plugin's MCP
59+
servers, which ``read_plugin`` uses to derive that metadata.
5960
60-
Returns ``(merged_mcp_servers, enriched_plugins)``. Plugin keys without
61-
``@`` (or that fail to resolve to a directory) still appear in the
62-
inventory with just ``{'enabled': True}`` so we don't silently drop them.
61+
Returns ``enriched_plugins``. Plugin keys without ``@`` (or that fail to
62+
resolve to a directory) still appear in the inventory with just
63+
``{'enabled': True}`` so we don't silently drop them.
6364
"""
64-
merged_mcp: dict = {}
6565
enriched: dict = {}
6666

6767
for plugin_key, settings in plugin_entries.items():
@@ -79,8 +79,7 @@ def walk_enabled_plugins(
7979
if plugin_dir is None:
8080
continue
8181

82-
plugin_fields, servers = read_plugin(plugin_dir)
82+
plugin_fields, _ = read_plugin(plugin_dir)
8383
entry.update(plugin_fields)
84-
merged_mcp.update(servers)
8584

86-
return merged_mcp, enriched
85+
return enriched

cycode/cli/apps/ai_guardrails/ides/claude_code.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ def _read_claude_plugin(plugin_dir: Path) -> tuple[dict, dict]:
198198
return entry, servers
199199

200200

201-
def resolve_plugins(settings: dict) -> tuple[dict, dict]:
201+
def resolve_plugins(settings: dict) -> dict:
202202
"""Walk Claude Code's ``enabledPlugins`` via the shared plugin walker.
203203
204204
Each enabled plugin's marketplace is resolved through
@@ -366,9 +366,6 @@ def get_session_context(self) -> tuple[Optional[dict], dict]:
366366
global_config_file = build_global_config_file(_CLAUDE_CONFIG_PATH, get_mcp_servers(config)) if config else None
367367

368368
settings = load_claude_settings()
369-
if settings:
370-
_, enriched_plugins = resolve_plugins(settings)
371-
else:
372-
enriched_plugins = {}
369+
enriched_plugins = resolve_plugins(settings) if settings else {}
373370

374371
return global_config_file, enriched_plugins

cycode/cli/apps/ai_guardrails/ides/codex.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def _read_codex_plugin(plugin_dir: Path) -> tuple[dict, dict]:
145145
return entry, servers
146146

147147

148-
def _resolve_codex_plugins(config: dict) -> tuple[dict, dict]:
148+
def _resolve_codex_plugins(config: dict) -> dict:
149149
"""Walk enabled ``[plugins."<plugin>@<marketplace>"]`` entries."""
150150
return walk_enabled_plugins(
151151
plugin_entries=config.get('plugins') or {},
@@ -311,7 +311,7 @@ def get_session_context(self) -> tuple[Optional[dict], dict]:
311311
# Codex stores MCP servers under `[mcp_servers.<name>]`; the global config
312312
# file becomes its own session-context file. Plugins (via
313313
# `[plugins."<plugin>@<marketplace>"]`) carry their own config files.
314-
config_path = _codex_home() / _CONFIG_TOML_NAME
314+
config_path = _codex_config_toml_path('user')
315315
global_config_file = build_global_config_file(config_path, config.get('mcp_servers'))
316-
_, enriched_plugins = _resolve_codex_plugins(config)
316+
enriched_plugins = _resolve_codex_plugins(config)
317317
return global_config_file, enriched_plugins

cycode/cli/apps/ai_guardrails/ides/cursor.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,14 @@ def _user_hooks_dir() -> Path:
4040
return Path.home() / '.config' / 'Cursor'
4141

4242

43+
def _cursor_mcp_config_path() -> Path:
44+
"""User-scope Cursor MCP config path (``~/.cursor/mcp.json``, all platforms)."""
45+
return Path.home() / '.cursor' / _MCP_CONFIG_FILENAME
46+
47+
4348
def _load_cursor_mcp_config(config_path: Optional[Path] = None) -> Optional[dict]:
4449
"""Load and parse `~/.cursor/mcp.json`. Returns None if missing/invalid."""
45-
path = config_path or (Path.home() / '.cursor' / _MCP_CONFIG_FILENAME)
50+
path = config_path or _cursor_mcp_config_path()
4651
if not path.exists():
4752
logger.debug('Cursor MCP config file not found, %s', {'path': str(path)})
4853
return None
@@ -118,6 +123,6 @@ def get_session_context(self) -> tuple[Optional[dict], dict]:
118123
config = _load_cursor_mcp_config()
119124
if not config:
120125
return None, {}
121-
config_path = Path.home() / '.cursor' / _MCP_CONFIG_FILENAME
126+
config_path = _cursor_mcp_config_path()
122127
global_config_file = build_global_config_file(config_path, config.get('mcpServers'))
123128
return global_config_file, {}

cycode/cli/apps/ai_guardrails/session_start_command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Handle AI guardrails session start: auth, conversation creation, session context."""
22

3-
import getpass
3+
import os
44
import platform
55
import socket
66
import sys
@@ -26,7 +26,7 @@
2626
def _get_logged_in_user() -> Optional[str]:
2727
"""Best-effort OS account name (whoami). None if it can't be resolved."""
2828
try:
29-
return getpass.getuser()
29+
return os.getlogin()
3030
except Exception:
3131
return None
3232

0 commit comments

Comments
 (0)