Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/specify_cli/_init_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,28 @@ def load_init_options(project_path: Path) -> dict[str, Any]:
def is_ai_skills_enabled(opts: Mapping[str, Any] | None) -> bool:
"""Return True only when init options explicitly enable AI skills."""
return isinstance(opts, Mapping) and opts.get("ai_skills") is True


def is_agent_skills_enabled(project_path: Path, agent_name: str, opts: Mapping[str, Any] | None) -> bool:
Comment thread
mnriem marked this conversation as resolved.
"""Return True when *agent_name* should render extension skills.

Prefers the per-agent ``skills`` flag recorded in
``.specify/integration.json`` (``integration_settings[agent_name].parsed_options.skills``),
which reflects the ``--skills`` option passed to that specific agent's
install/upgrade/switch. Falls back to the legacy global
``init-options.json`` ``ai_skills`` flag only when *agent_name* is the
active agent recorded there (pre-multi-install behaviour).
"""
from .integration_state import try_read_integration_json, integration_setting

state, _error = try_read_integration_json(project_path)
if state:
setting = integration_setting(state, agent_name)
parsed = setting.get("parsed_options")
if isinstance(parsed, Mapping) and "skills" in parsed:
return parsed.get("skills") is True

if isinstance(opts, Mapping) and opts.get("ai") == agent_name:
return is_ai_skills_enabled(opts)

return False
Loading