diff --git a/README.md b/README.md index 1553ae9..ceb5d6f 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ Get started in minutes: ## How It Works 1. **Security rules** are written in unified markdown format (`sources/` directory) -2. **Conversion tools** translate rules to IDE-specific formats (Cursor, Windsurf, Copilot, Claude Code) +2. **Conversion tools** translate rules to IDE-specific formats (Cursor, Windsurf, Copilot, Claude Code, Antigravity) 3. **Release automation** packages rules into downloadable ZIP files 4. **AI assistants** reference these rules when generating or reviewing code 5. **Secure code** is produced automatically without developer intervention diff --git a/docs/getting-started.md b/docs/getting-started.md index 81add1a..adcb1d0 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -31,6 +31,11 @@ Before you begin, familiarize yourself with how rules work in your IDE: :material-book-open-page-variant: [GitHub Copilot Instructions](https://docs.github.com/en/copilot/how-tos/configure-custom-instructions/add-repository-instructions) +=== "Antigravity" + Antigravity uses `.agent/rules` for rule configuration. + + :material-book-open-page-variant: [Antigravity Instructions](https://codelabs.developers.google.com/getting-started-google-antigravity#8) + ## Installation ### Option 1: Download Pre-built Rules (Recommended) @@ -95,6 +100,7 @@ uv run python src/convert_to_ide_formats.py --source core owasp cp -r dist/.cursor/ /path/to/your/project/ cp -r dist/.windsurf/ /path/to/your/project/ cp -r dist/.github/ /path/to/your/project/ +cp -r dist/.agent/ /path/to/your/project/ ``` ## Verify Installation @@ -103,6 +109,8 @@ After installation, your project structure should include: ``` your-project/ +├── .agent/ +│ └── rules/ ├── .cursor/ │ └── rules/ ├── .windsurf/ diff --git a/src/convert_to_ide_formats.py b/src/convert_to_ide_formats.py index 3c3cab3..1657366 100644 --- a/src/convert_to_ide_formats.py +++ b/src/convert_to_ide_formats.py @@ -16,7 +16,7 @@ from collections import defaultdict from converter import RuleConverter -from formats import CursorFormat, WindsurfFormat, CopilotFormat, ClaudeCodeFormat +from formats import CursorFormat, WindsurfFormat, CopilotFormat, ClaudeCodeFormat, AntigravityFormat from utils import get_version_from_pyproject from validate_versions import set_plugin_version, set_marketplace_version @@ -128,6 +128,7 @@ def convert_rules(input_path: str, output_dir: str = "dist", include_claudecode: CursorFormat(version), WindsurfFormat(version), CopilotFormat(version), + AntigravityFormat(version), ] # Only include Claude Code for core rules (committed plugin) diff --git a/src/formats/__init__.py b/src/formats/__init__.py index 4a2a7db..55cc0d0 100644 --- a/src/formats/__init__.py +++ b/src/formats/__init__.py @@ -30,6 +30,7 @@ from formats.windsurf import WindsurfFormat from formats.copilot import CopilotFormat from formats.claudecode import ClaudeCodeFormat +from formats.antigravity import AntigravityFormat __all__ = [ "BaseFormat", @@ -38,4 +39,5 @@ "WindsurfFormat", "CopilotFormat", "ClaudeCodeFormat", + "AntigravityFormat", ] diff --git a/src/formats/antigravity.py b/src/formats/antigravity.py new file mode 100644 index 0000000..a77ecbd --- /dev/null +++ b/src/formats/antigravity.py @@ -0,0 +1,74 @@ +# Copyright 2025 Cisco Systems, Inc. and its affiliates +# +# SPDX-License-Identifier: Apache-2.0 + +""" +Antigravity Format Implementation + +Generates .md rule files for Antigravity with YAML frontmatter. +""" + +from formats.base import BaseFormat, ProcessedRule + + +class AntigravityFormat(BaseFormat): + """ + Antigravity format implementation (.md rule files). + + Antigravity uses .md files with YAML frontmatter containing: + - trigger: 'always_on' or 'glob' (activation type) + - globs: (if trigger is 'glob') File matching patterns + - description: Rule description + - version: Rule version + + Rules use activation types (Always On or Glob) to determine when + they apply, similar to Windsurf's implementation. + See: https://antigravity.google/docs/rules-workflows + """ + + def get_format_name(self) -> str: + """Return Antigravity format identifier.""" + return "antigravity" + + def get_file_extension(self) -> str: + """Return Antigravity format file extension.""" + return ".md" + + def get_output_subpath(self) -> str: + """Return Antigravity output subdirectory.""" + return ".agent/rules" + + def generate(self, rule: ProcessedRule, globs: str) -> str: + """ + Generate Antigravity .md format with YAML frontmatter. + + Args: + rule: The processed rule to format + globs: Glob patterns for file matching + + Returns: + Formatted .md content with trigger, globs, description, and version + + Note: + Antigravity rules use activation types: + - 'always_on': Rule applies to all files (when alwaysApply is true) + - 'glob': Rule applies to files matching glob patterns (language-specific) + """ + yaml_lines = [] + + # Use trigger: always_on for rules that should always apply + if rule.always_apply: + yaml_lines.append("trigger: always_on") + else: + yaml_lines.append("trigger: glob") + yaml_lines.append(f"globs: {globs}") + + # Add description (required by Antigravity spec) + desc = self._format_yaml_field("description", rule.description) + if desc: + yaml_lines.append(desc) + + # Add version + yaml_lines.append(f"version: {self.version}") + + return self._build_yaml_frontmatter(yaml_lines, rule.content)