Skip to content
Merged
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
13 changes: 13 additions & 0 deletions docs/integrations/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@ The documentation commonly uses `/speckit.*` notation, but your agent may use
hyphenated skills, `$` skills, or another native form. See your integration's
page and the [command invocation comparison](cli.md#command-invocation).

## Generated Skill Versions

Generated `SKILL.md` frontmatter includes `metadata.version` when the supplying
component's version is known. Core skills record the generating Specify CLI
version; extension and preset skills record their respective component versions.
The value is a string, and the key is omitted when the version is unknown.

Existing metadata, including `metadata.author` and `metadata.source`, keeps its
meaning. Skills regenerated through an existing operation, including restoration
after a preset is removed, record the resulting component's version. Skills
already on disk are not rewritten automatically, and this metadata does not
perform stale-skill detection or upgrades.

## Adding Another Agent

In an initialized project, use
Expand Down
16 changes: 15 additions & 1 deletion src/specify_cli/agents.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ def render_skill_command(
project_root: Path,
extension_id: Optional[str] = None,
author: object = "github-spec-kit",
version: str | None = None,
) -> str:
"""Render a command override as a SKILL.md file.

Expand All @@ -419,7 +420,8 @@ def render_skill_command(
Spec-kit currently has multiple SKILL.md generators (template packaging,
init-time conversion, and extension/preset overrides). Keep the skill
frontmatter keys aligned (name/description/compatibility/metadata, with
metadata.author and metadata.source subkeys) to avoid drift across agents.
metadata.author, metadata.source, and optional metadata.version subkeys)
to avoid drift across agents.
"""
if not isinstance(frontmatter, dict):
frontmatter = {}
Expand All @@ -439,6 +441,7 @@ def render_skill_command(
description,
f"{source_id}:{source_file}",
author=author,
version=version,
)
return self.render_frontmatter(skill_frontmatter) + "\n" + body

Expand All @@ -449,6 +452,7 @@ def build_skill_frontmatter(
description: str,
source: str,
author: object = "github-spec-kit",
version: str | None = None,
) -> dict:
"""Build consistent SKILL.md frontmatter across all skill generators."""
normalized_author = (
Expand All @@ -463,6 +467,8 @@ def build_skill_frontmatter(
"source": source,
},
}
if version and version != "unknown":
skill_frontmatter["metadata"]["version"] = version
return skill_frontmatter

@staticmethod
Expand Down Expand Up @@ -651,6 +657,7 @@ def register_commands(
link_outputs: bool = False,
extension_id: Optional[str] = None,
author: object = "github-spec-kit",
version: str | None = None,
) -> List[str]:
"""Register commands for a specific agent.

Expand All @@ -670,6 +677,7 @@ def register_commands(
to a normal file write when symlinks are unavailable.
extension_id: Extension id when rendering extension-owned commands.
author: Author attributed in generated skill metadata.
version: Supplying component version, omitted from skills if unknown.

Returns:
List of registered command names
Expand Down Expand Up @@ -838,6 +846,7 @@ def register_commands(
project_root,
extension_id=extension_id,
author=author,
version=version,
)
elif agent_config["format"] == "markdown":
body = self.resolve_skill_placeholders(
Expand Down Expand Up @@ -930,6 +939,7 @@ def register_commands(
project_root,
extension_id=extension_id,
author=author,
version=version,
)
elif agent_config["format"] == "markdown":
alias_output = self.render_markdown_command(
Expand Down Expand Up @@ -964,6 +974,7 @@ def register_commands(
project_root,
extension_id=extension_id,
author=author,
version=version,
)

alias_file = (
Expand Down Expand Up @@ -1122,6 +1133,7 @@ def register_commands_for_all_agents(
extension_id: Optional[str] = None,
only_agent: Optional[str] = None,
author: object = "github-spec-kit",
version: str | None = None,
) -> Dict[str, List[str]]:
"""Register commands for all detected agents in the project.

Expand All @@ -1140,6 +1152,7 @@ def register_commands_for_all_agents(
creation fails.
extension_id: Extension id when rendering extension-owned commands.
author: Author attributed in generated skill metadata.
version: Supplying component version, omitted from skills if unknown.
only_agent: If set, restrict registration to this single agent
while keeping all detection and recovery safeguards (#2948).

Expand Down Expand Up @@ -1248,6 +1261,7 @@ def register_commands_for_all_agents(
link_outputs=link_outputs,
extension_id=extension_id,
author=author,
version=version,
)
if registered:
results[agent_name] = registered
Expand Down
3 changes: 3 additions & 0 deletions src/specify_cli/extensions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,7 @@ def _replacement(match: re.Match[str]) -> str:
description,
f"extension:{manifest.id}",
author=manifest.data["extension"].get("author"),
version=manifest.version,
)
# Preserve the command's argument-hint in the generated skill,
# mirroring the core template path (ClaudeIntegration.setup injects
Expand Down Expand Up @@ -4393,6 +4394,7 @@ def register_commands_for_agent(
link_outputs=link_outputs,
extension_id=manifest.id,
author=manifest.data["extension"].get("author"),
version=manifest.version,
)

def register_commands_for_all_agents(
Expand All @@ -4417,6 +4419,7 @@ def register_commands_for_all_agents(
only_agent=only_agent,
extension_id=manifest.id,
author=manifest.data["extension"].get("author"),
version=manifest.version,
)

def unregister_commands(
Expand Down
3 changes: 2 additions & 1 deletion src/specify_cli/integrations/alquimia/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ def _render_skill(
return f"---\n{frontmatter_text}\n---\n\n{body.strip()}\n"

def _build_skill_fm(self, name: str, description: str, source: str) -> dict:
from specify_cli import get_speckit_version
from specify_cli.agents import CommandRegistrar

return CommandRegistrar.build_skill_frontmatter(
self.key, name, description, source
self.key, name, description, source, version=get_speckit_version()
)

@staticmethod
Expand Down
36 changes: 27 additions & 9 deletions src/specify_cli/integrations/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2158,6 +2158,29 @@ def post_process_skill_content(self, content: str) -> str:
invocation_prefix = get_invocation_prefix(self.key, True)
return self._inject_hook_command_note(content, invocation_prefix)

def _render_core_skill_frontmatter(
self, skill_name: str, description: str, source: str
) -> str:
"""Render shared core provenance with the native skills' quoted layout."""
from specify_cli import get_speckit_version
from specify_cli.agents import CommandRegistrar

frontmatter = CommandRegistrar.build_skill_frontmatter(
self.key, skill_name, description, source,
version=get_speckit_version(),
)
lines = [
f"{key}: {yaml_quote(value)}"
for key, value in frontmatter.items()
if key != "metadata"
]
lines.append("metadata:")
lines.extend(
f" {key}: {yaml_quote(value)}"
for key, value in frontmatter["metadata"].items()
)
return "\n".join(lines)

def setup(
self,
project_root: Path,
Expand Down Expand Up @@ -2270,17 +2293,12 @@ def setup(
if not description:
description = f"Spec Kit: {command_name} workflow"

# Build SKILL.md with manually formatted frontmatter (stable
# double-quoted values). yaml_quote escapes newlines and control
# characters that a plain quoted f-string cannot carry.
frontmatter_text = self._render_core_skill_frontmatter(
skill_name, description, f"templates/commands/{src_file.name}"
)
skill_content = (
f"---\n"
f"name: {yaml_quote(skill_name)}\n"
f"description: {yaml_quote(description)}\n"
f"compatibility: {yaml_quote('Requires spec-kit project structure with .specify/ directory')}\n"
f"metadata:\n"
f" author: {yaml_quote('github-spec-kit')}\n"
f" source: {yaml_quote('templates/commands/' + src_file.name)}\n"
f"{frontmatter_text}\n"
f"---\n"
f"{processed_body}"
)
Expand Down
3 changes: 2 additions & 1 deletion src/specify_cli/integrations/claude/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,10 @@ def _render_skill(self, template_name: str, frontmatter: dict[str, Any], body: s
return f"---\n{frontmatter_text}\n---\n\n{body.strip()}\n"

def _build_skill_fm(self, name: str, description: str, source: str) -> dict:
from specify_cli import get_speckit_version
from specify_cli.agents import CommandRegistrar
return CommandRegistrar.build_skill_frontmatter(
self.key, name, description, source
self.key, name, description, source, version=get_speckit_version()
)

@staticmethod
Expand Down
12 changes: 5 additions & 7 deletions src/specify_cli/integrations/generic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import yaml

from ..base import IntegrationOption, MarkdownIntegration, SkillsIntegration, yaml_quote
from ..base import IntegrationOption, MarkdownIntegration, SkillsIntegration
from ..manifest import IntegrationManifest


Expand Down Expand Up @@ -201,14 +201,12 @@ def _build_skill_content(
)

description = frontmatter.get("description") or f"Spec Kit: {command_name} workflow"
frontmatter_text = _GenericSkillsHelper()._render_core_skill_frontmatter(
skill_name, description, f"templates/commands/{src_file.name}"
)
skill_content = (
f"---\n"
f"name: {yaml_quote(skill_name)}\n"
f"description: {yaml_quote(description)}\n"
f"compatibility: {yaml_quote('Requires spec-kit project structure with .specify/ directory')}\n"
f"metadata:\n"
f" author: {yaml_quote('github-spec-kit')}\n"
f" source: {yaml_quote('templates/commands/' + src_file.name)}\n"
f"{frontmatter_text}\n"
f"---\n"
f"{processed_body}"
)
Expand Down
16 changes: 5 additions & 11 deletions src/specify_cli/integrations/hermes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import yaml

from ..base import IntegrationOption, SkillsIntegration, yaml_quote
from ..base import IntegrationOption, SkillsIntegration
from ..manifest import IntegrationManifest


Expand Down Expand Up @@ -184,18 +184,12 @@ def setup(
if not description:
description = f"Spec Kit: {command_name} workflow"

# Build SKILL.md with manually formatted frontmatter. yaml_quote
# escapes newlines and control characters that a plain quoted
# f-string cannot carry.
frontmatter_text = self._render_core_skill_frontmatter(
skill_name, description, f"templates/commands/{src_file.name}"
)
skill_content = (
f"---\n"
f"name: {yaml_quote(skill_name)}\n"
f"description: {yaml_quote(description)}\n"
f"compatibility: "
f"{yaml_quote('Requires spec-kit project structure with .specify/ directory')}\n"
f"metadata:\n"
f" author: {yaml_quote('github-spec-kit')}\n"
f" source: {yaml_quote('templates/commands/' + src_file.name)}\n"
f"{frontmatter_text}\n"
f"---\n"
f"{processed_body}"
)
Expand Down
3 changes: 2 additions & 1 deletion src/specify_cli/integrations/vibe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,10 @@ def _render_skill(self, template_name: str, frontmatter: dict[str, Any], body: s
return f"---\n{frontmatter_text}\n---\n\n{body.strip()}\n"

def _build_skill_fm(self, name: str, description: str, source: str) -> dict:
from specify_cli import get_speckit_version
from specify_cli.agents import CommandRegistrar
return CommandRegistrar.build_skill_frontmatter(
self.key, name, description, source
self.key, name, description, source, version=get_speckit_version()
)

@staticmethod
Expand Down
1 change: 1 addition & 0 deletions src/specify_cli/presets/_manager_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ def _register_commands(
self.project_root,
create_missing_active_skills_dir=True,
only_agent=active_agent,
version=manifest.version,
)

def register_enabled_presets_for_agent(self, agent_name: str) -> None:
Expand Down
6 changes: 5 additions & 1 deletion src/specify_cli/presets/_manager_skills.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,7 @@ def _build_extension_skill_restore_index(self) -> Dict[str, Dict[str, Any]]:
"source_file": source_file,
"source": f"extension:{manifest.id}",
"author": manifest.data["extension"].get("author"),
"version": manifest.version,
"extension_id": manifest.id,
"extension_dir": ext_root,
}
Expand Down Expand Up @@ -802,6 +803,7 @@ def _register_skills(
target_skill_name,
enhanced_desc,
f"preset:{manifest.id}",
version=manifest.version,
)
registrar.apply_argument_hint(frontmatter, frontmatter_data, integration)
frontmatter_text = dump_frontmatter(frontmatter_data)
Expand Down Expand Up @@ -1330,7 +1332,7 @@ def _unregister_skills_in_dir(
Returns:
Skill names whose files were restored or removed.
"""
from .. import SKILL_DESCRIPTIONS
from .. import SKILL_DESCRIPTIONS, get_speckit_version
from ..integrations import get_integration
from ..shared_infra import _write_shared_text

Expand Down Expand Up @@ -1465,6 +1467,7 @@ def _unregister_skills_in_dir(
skill_name,
enhanced_desc,
f"templates/commands/{short_name}.md",
version=get_speckit_version(),
)
registrar.apply_argument_hint(frontmatter, frontmatter_data, integration)
frontmatter_text = dump_frontmatter(frontmatter_data)
Expand Down Expand Up @@ -1524,6 +1527,7 @@ def _unregister_skills_in_dir(
frontmatter.get("description", f"Extension command: {command_name}"),
extension_restore["source"],
author=extension_restore.get("author", "github-spec-kit"),
version=extension_restore.get("version"),
)
registrar.apply_argument_hint(frontmatter, frontmatter_data, integration)
frontmatter_text = dump_frontmatter(frontmatter_data)
Expand Down
Loading
Loading