`.
- **Markdown Integrity:** Bullet points, tables, headings, blockquotes, and code blocks inside the `
` container retain standard Markdown syntax (do NOT convert tables to raw HTML).
-- **Code & LTR Isolation:** Keep inline code, code blocks, file paths, URLs, shell commands, and logs strictly LTR. Never reverse or break syntax brackets, slashes, or indentation.
+- **Code & LTR Isolation:** Keep inline code, code blocks, file paths, URLs, shell commands, logs, and LaTeX math formulas strictly LTR. Never reverse or break syntax brackets, slashes, or indentation.
- **Zero Exceptions:** Never produce uncontained or left-aligned RTL text in chat or artifacts.
EOF
+ log " [OK] Global Antigravity rule installed at: $RULES_DIR/rtl-formatting.md"
+
+ cat << 'EOF' > "$SKILLS_DIR/SKILL.md"
+---
+name: agent-rtl-fix
+description: Automatically configures Antigravity IDE, Cursor, and VS Code for native RTL/LTR BiDi support, Vazirmatn fonts, and global agent formatting rules.
+---
+
+# Agent RTL Fix Skill
+
+Configures autonomous coding agents and editors for native Right-to-Left (Persian, Arabic, Urdu, Hebrew) and Left-to-Right bidirectional text support.
+
+## Automated Actions
+1. **Font Setup**: Installs clean Vazirmatn typography for seamless multilingual rendering.
+2. **Editor Settings**: Configures `editor.unicodeHighlight.bidiCharacters: true`, clean font fallback (`'Vazirmatn', 'Fira Code', 'Consolas', monospace`), and balanced line-height.
+3. **Global Agent Rule**: Installs machine-wide rule (`~/.gemini/config/rules/rtl-formatting.md`) so all agent responses render in proper RTL without token overhead.
+EOF
+ log " [OK] Global Antigravity skill installed at: $SKILLS_DIR/SKILL.md"
+else
+ log "[2/4] Skipping global machine rules (per flags)."
+fi
-echo " [OK] Global Antigravity rule installed at: $RULES_DIR/rtl-formatting.md"
-
-# 3. Configure Local Project Rules (Cursor, Windsurf, Copilot, Claude, Cline)
-echo "[3/4] Checking Current Project Directory..."
-CWD="$(pwd)"
-if [ -d "$CWD/.git" ] || [ -f "$CWD/package.json" ] || [ -f "$CWD/go.mod" ] || [ -f "$CWD/Cargo.toml" ] || [ -f "$CWD/pyproject.toml" ]; then
- echo " -> Project workspace detected at $CWD"
-
- # Universal AGENTS.md
- if [ ! -f "$CWD/AGENTS.md" ]; then
- cat << 'EOF' > "$CWD/AGENTS.md"
+# ------------------------------------------------------------------------------
+# 3. Configure Local Project Rules (Universal AGENTS.md, Cursor, Copilot, Zed)
+# ------------------------------------------------------------------------------
+if [ "$GLOBAL_ONLY" = false ]; then
+ log "[3/4] Checking Current Project Directory..."
+ CWD="$(pwd)"
+ IS_SELF_REPO=false
+ if [ -f "$CWD/rules/AGENTS.md" ] && [ -d "$CWD/fonts/Vazirmatn" ]; then
+ IS_SELF_REPO=true
+ fi
+
+ if { [ -d "$CWD/.git" ] || [ -f "$CWD/package.json" ] || [ -f "$CWD/go.mod" ] || [ -f "$CWD/Cargo.toml" ] || [ -f "$CWD/pyproject.toml" ] || [ -d "$CWD/.cursor" ] || [ -d "$CWD/.github" ] || [ -d "$CWD/.zed" ]; } && [ "$IS_SELF_REPO" = false ]; then
+ log " -> Project workspace detected at $CWD"
+
+ # Universal AGENTS.md
+ if [ ! -f "$CWD/AGENTS.md" ]; then
+ cat << 'EOF' > "$CWD/AGENTS.md"
# Universal AI Agent RTL/LTR BiDi Formatting Standard
+This specification defines the universal bidirectional text formatting protocol for autonomous AI agents, coding assistants, and LLM runtimes (including Antigravity, Cursor, Windsurf, Copilot, Claude Code, Cline, Zed, and Aider).
+
+## 1. Rule Definition
+
Whenever responding or generating documentation in right-to-left (RTL) languages (Persian, Arabic, Urdu, Hebrew):
-1. **Outer RTL Boundary**: Wrap the complete response or markdown file inside `
...
`.
+
+1. **Outer RTL Boundary**: Wrap the complete response or markdown file body inside `
...
`.
2. **Markdown Preservation**: Retain standard GitHub Flavored Markdown (GFM) inside the container. Do NOT convert Markdown tables to verbose raw HTML.
-3. **BiDi Code & Log Isolation**: All code blocks (```lang ... ```), inline code (`code`), terminal logs, shell commands, URLs, and file paths must remain strictly LTR.
-4. **Zero Exceptions**: Never emit uncontained or left-aligned RTL text.
+3. **BiDi Code & Log Isolation**: All code blocks (````lang ... ````), inline code (`code`), terminal logs, shell commands, URLs, and file paths must remain strictly LTR. Do not flip brackets, slashes, or indentation.
+4. **Inline Technical Tokens & Punctuation**: When embedding inline code, variables, or commands within RTL sentences, ensure surrounding punctuation (such as parentheses, colons, and quotes) remains properly oriented.
+5. **Frontmatter & Math Isolation**: If generating Markdown files with YAML frontmatter (`---`), place the frontmatter at the very top of the file, then enclose the content body in `
...
`. Keep multi-line math blocks (`$$...$$`) LTR.
+6. **Zero Left-Aligned RTL**: Never emit uncontained right-to-left text.
EOF
- echo " [OK] Added AGENTS.md to current project"
- fi
+ log " [OK] Added AGENTS.md to current project"
+ fi
- # Cursor
- if [ -d "$CWD/.cursor" ]; then
- mkdir -p "$CWD/.cursor/rules"
- cat << 'EOF' > "$CWD/.cursor/rules/bidi.mdc"
+ # Cursor
+ if [ -d "$CWD/.cursor" ]; then
+ mkdir -p "$CWD/.cursor/rules"
+ cat << 'EOF' > "$CWD/.cursor/rules/bidi.mdc"
---
description: Universal RTL/LTR BiDi formatting rule
globs: *
@@ -102,57 +179,88 @@ alwaysApply: true
---
Wrap all responses containing RTL languages (Persian, Arabic, Urdu, Hebrew) in `
...
`. Keep code and terminal blocks strictly LTR.
EOF
- echo " [OK] Added .cursor/rules/bidi.mdc"
- fi
+ log " [OK] Added .cursor/rules/bidi.mdc"
+ fi
- # GitHub Copilot
- if [ -d "$CWD/.github" ]; then
- cat << 'EOF' > "$CWD/.github/copilot-instructions.md"
+ # GitHub Copilot
+ if [ -d "$CWD/.github" ]; then
+ cat << 'EOF' > "$CWD/.github/copilot-instructions.md"
# GitHub Copilot RTL/LTR BiDi Formatting Instructions
Wrap all RTL language responses (Persian, Arabic, Urdu, Hebrew) inside `
...
`. Keep all code snippets, paths, and commands in standard LTR.
EOF
- echo " [OK] Added .github/copilot-instructions.md"
+ log " [OK] Added .github/copilot-instructions.md"
+ fi
+
+ # Zed
+ if [ -d "$CWD/.zed" ]; then
+ if [ ! -f "$CWD/.zed/settings.json" ]; then
+ cat << 'EOF' > "$CWD/.zed/settings.json"
+{
+ "buffer_font_family": "Vazirmatn",
+ "ui_font_family": "Vazirmatn"
+}
+EOF
+ log " [OK] Added .zed/settings.json"
+ fi
+ fi
+ else
+ log " (No project root in current folder; global machine configs applied)"
fi
else
- echo " (No project root in current folder; global machine configs applied)"
+ log "[3/4] Skipping project-level configuration (per flags)."
fi
-# 4. Update VS Code / Antigravity / Cursor settings if present
-echo "[4/4] Updating Editor Settings (Font & BiDi Highlighting)..."
-CONFIG_DIRS=(
- "$HOME/.config/Antigravity/User"
- "$HOME/.config/Code/User"
- "$HOME/.config/Cursor/User"
- "$HOME/Library/Application Support/Antigravity/User"
- "$HOME/Library/Application Support/Code/User"
- "$HOME/Library/Application Support/Cursor/User"
-)
-
-for cdir in "${CONFIG_DIRS[@]}"; do
- if [ -d "$cdir" ]; then
- sfile="$cdir/settings.json"
- if [ ! -f "$sfile" ]; then
- echo "{}" > "$sfile"
- fi
- if command -v python3 >/dev/null 2>&1; then
- python3 -c "
-import json
+# ------------------------------------------------------------------------------
+# 4. Update Editor Settings (VS Code, Cursor, Antigravity, Zed)
+# ------------------------------------------------------------------------------
+if [ "$PROJECT_ONLY" = false ]; then
+ log "[4/4] Updating Editor Settings (Font & BiDi Highlighting)..."
+ CONFIG_DIRS=(
+ "$HOME/.config/Antigravity/User"
+ "$HOME/.config/Code/User"
+ "$HOME/.config/Cursor/User"
+ "$HOME/.config/zed"
+ "$HOME/Library/Application Support/Antigravity/User"
+ "$HOME/Library/Application Support/Code/User"
+ "$HOME/Library/Application Support/Cursor/User"
+ "$HOME/Library/Application Support/Zed"
+ )
+
+ for cdir in "${CONFIG_DIRS[@]}"; do
+ if [ -d "$cdir" ]; then
+ sfile="$cdir/settings.json"
+ if [ ! -f "$sfile" ]; then
+ echo "{}" > "$sfile"
+ fi
+ if command -v python3 >/dev/null 2>&1; then
+ python3 -c "
+import json, sys
+sfile = '$sfile'
try:
- with open('$sfile', 'r', encoding='utf-8') as f:
+ with open(sfile, 'r', encoding='utf-8') as f:
data = json.load(f)
except Exception:
data = {}
-data['editor.fontFamily'] = \"'Vazirmatn', 'Fira Code', 'Cascadia Code', 'Consolas', monospace\"
-data['editor.unicodeHighlight.bidiCharacters'] = True
-data['markdown.preview.fontFamily'] = \"'Vazirmatn', 'Segoe UI', Tahoma, sans-serif\"
-data['chat.editor.fontFamily'] = \"'Vazirmatn', 'Segoe UI', Tahoma, sans-serif\"
-with open('$sfile', 'w', encoding='utf-8') as f:
+
+if 'zed' in sfile.lower():
+ data['buffer_font_family'] = 'Vazirmatn'
+ data['ui_font_family'] = 'Vazirmatn'
+else:
+ data['editor.fontFamily'] = \"'Vazirmatn', 'Fira Code', 'Cascadia Code', 'Consolas', monospace\"
+ data['editor.unicodeHighlight.bidiCharacters'] = True
+ data['markdown.preview.fontFamily'] = \"'Vazirmatn', 'Segoe UI', Tahoma, sans-serif\"
+ data['chat.editor.fontFamily'] = \"'Vazirmatn', 'Segoe UI', Tahoma, sans-serif\"
+
+with open(sfile, 'w', encoding='utf-8') as f:
json.dump(data, f, indent=4, ensure_ascii=False)
-" 2>/dev/null && echo " [OK] Updated $sfile" || true
+" 2>/dev/null && log " [OK] Updated $sfile" || true
+ fi
fi
- fi
-done
+ done
+else
+ log "[4/4] Skipping editor settings update (per flags)."
+fi
-echo "=========================================================="
-echo " Agent RTL Fix installation completed successfully! "
-echo "=========================================================="
+log "=========================================================="
+log " Agent RTL Fix installation completed successfully! "
+log "=========================================================="
diff --git a/rules/AGENTS.md b/rules/AGENTS.md
index e14c811..d2bda1b 100644
--- a/rules/AGENTS.md
+++ b/rules/AGENTS.md
@@ -1,12 +1,14 @@
# Universal AI Agent RTL/LTR BiDi Formatting Standard
-This specification defines the universal bidirectional text formatting protocol for autonomous AI agents, coding assistants, and LLM runtimes (including Antigravity, Cursor, Windsurf, Copilot, Claude Code, Cline, and Aider).
+This specification defines the universal bidirectional text formatting protocol for autonomous AI agents, coding assistants, and LLM runtimes (including Antigravity, Cursor, Windsurf, Copilot, Claude Code, Cline, Zed, and Aider).
## 1. Rule Definition
Whenever responding or generating documentation in right-to-left (RTL) languages (Persian, Arabic, Urdu, Hebrew):
-1. **Outer RTL Boundary**: Wrap the complete response or markdown file inside `
...
`.
+1. **Outer RTL Boundary**: Wrap the complete response or markdown file body inside `
...
`.
2. **Markdown Preservation**: Retain standard GitHub Flavored Markdown (GFM) inside the container. Do NOT convert Markdown tables to verbose raw HTML.
3. **BiDi Code & Log Isolation**: All code blocks (````lang ... ````), inline code (`code`), terminal logs, shell commands, URLs, and file paths must remain strictly LTR. Do not flip brackets, slashes, or indentation.
-4. **Zero Left-Aligned RTL**: Never emit uncontained right-to-left text.
+4. **Inline Technical Tokens & Punctuation**: When embedding inline code, variables, or commands within RTL sentences, ensure surrounding punctuation (such as parentheses, colons, and quotes) remains properly oriented.
+5. **Frontmatter & Math Isolation**: If generating Markdown files with YAML frontmatter (`---`), place the frontmatter at the very top of the file, then enclose the content body in `
...
`. Keep multi-line math blocks (`$$...$$`) LTR.
+6. **Zero Left-Aligned RTL**: Never emit uncontained right-to-left text.
diff --git a/rules/aider.md b/rules/aider.md
new file mode 100644
index 0000000..cc17485
--- /dev/null
+++ b/rules/aider.md
@@ -0,0 +1,16 @@
+# Aider AI Coding Assistant BiDi RTL/LTR Instruction
+
+To configure Aider for clean bidirectional output in terminal sessions:
+
+### 1. Configuration File (`.aider.conf.yml`)
+Add or append to `.aider.conf.yml` in your project or home directory:
+```yaml
+system-prompt: |
+ Whenever responding in right-to-left (RTL) languages (Persian, Arabic, Urdu, Hebrew):
+ 1. Wrap all conversational, explanatory, and documentation text inside `
...
`.
+ 2. Keep all unified diffs, code edits, file paths, and terminal snippets strictly LTR.
+ 3. Never invert brackets, slashes, or syntax markers.
+```
+
+### 2. Universal Project Rule (`AGENTS.md`)
+Alternatively, place `AGENTS.md` in your repository root, which Aider automatically reads when indexing project context.
diff --git a/rules/antigravity.md b/rules/antigravity.md
index 1b160eb..71541d3 100644
--- a/rules/antigravity.md
+++ b/rules/antigravity.md
@@ -3,7 +3,7 @@ trigger: always_on
description: Universal RTL/LTR BiDi formatting rule for right-to-left languages (Persian, Arabic, Urdu, Hebrew)
---
# Universal RTL/LTR BiDi Formatting Rule
-- **Chat & Artifacts:** Every chat response and markdown artifact (.md) containing right-to-left text (Persian, Arabic, Urdu, Hebrew) MUST be wrapped completely inside `
...
` from start to end for native RTL rendering.
+- **Chat & Artifacts:** Every chat response and markdown artifact (.md) containing right-to-left text (Persian, Arabic, Urdu, Hebrew) MUST be wrapped completely inside `
...
` for native RTL rendering. For artifacts with YAML frontmatter, preserve the frontmatter at the top and enclose the markdown body inside `
`.
- **Markdown Integrity:** Bullet points, tables, headings, blockquotes, and code blocks inside the `
` container retain standard Markdown syntax (do NOT convert tables to raw HTML).
-- **Code & LTR Isolation:** Keep inline code, code blocks, file paths, URLs, shell commands, and logs strictly LTR. Never reverse or break syntax brackets, slashes, or indentation.
+- **Code & LTR Isolation:** Keep inline code, code blocks, file paths, URLs, shell commands, logs, and LaTeX math formulas strictly LTR. Never reverse or break syntax brackets, slashes, or indentation.
- **Zero Exceptions:** Never produce uncontained or left-aligned RTL text in chat or artifacts.
diff --git a/rules/zed.md b/rules/zed.md
new file mode 100644
index 0000000..e7151f8
--- /dev/null
+++ b/rules/zed.md
@@ -0,0 +1,20 @@
+# Zed Editor BiDi RTL/LTR & Typography Configuration
+
+To enable clean Vazirmatn typography and bidirectional text support in Zed:
+
+### 1. Editor Configuration (`~/.config/zed/settings.json` or `%APPDATA%\Zed\settings.json`)
+```json
+{
+ "buffer_font_family": "Vazirmatn",
+ "buffer_font_size": 15,
+ "ui_font_family": "Vazirmatn",
+ "ui_font_size": 15
+}
+```
+
+### 2. AI Assistant Rule
+When interacting with Zed's integrated Assistant panel, add this instruction or place `AGENTS.md` in the workspace root:
+
+- Whenever responding in right-to-left languages (Persian, Arabic, Urdu, Hebrew), wrap conversational and explanatory text inside `
...
`.
+- Keep all code blocks, diffs, terminal commands, and file paths strictly LTR.
+- Maintain standard GitHub Flavored Markdown for headings, lists, and tables inside the container.
diff --git a/scripts/install.ps1 b/scripts/install.ps1
index 643031e..2059b12 100644
--- a/scripts/install.ps1
+++ b/scripts/install.ps1
@@ -1,31 +1,31 @@
# ==============================================================================
-# Agent RTL Fix - Universal Windows Installer (v2.0.0)
-# Supports: One-liner remote execution and local offline execution
+# Agent RTL Fix - Universal Windows Installer (v2.1.0)
+# Supports: One-liner remote execution, local offline execution, and CLI flags
# ==============================================================================
+[CmdletBinding()]
+param(
+ [switch]$GlobalOnly,
+ [switch]$ProjectOnly,
+ [switch]$NoFonts,
+ [switch]$Silent
+)
+
$ErrorActionPreference = "Stop"
$RepoOwner = "dalroot"
$RepoName = "agent-rtl-fix"
$Branch = "main"
-Write-Host "==========================================================" -ForegroundColor Cyan
-Write-Host " Agent RTL Fix (v2.0.0) - Universal BiDi Setup Engine " -ForegroundColor Cyan
-Write-Host "==========================================================" -ForegroundColor Cyan
-
-# 1. Install Fonts
-$fontDest = "$env:LOCALAPPDATA\Microsoft\Windows\Fonts"
-if (-not (Test-Path $fontDest)) {
- New-Item -ItemType Directory -Path $fontDest -Force | Out-Null
+function Log-Info {
+ param([string]$Message, [ConsoleColor]$Color = [ConsoleColor]::White)
+ if (-not $Silent) {
+ Write-Host $Message -ForegroundColor $Color
+ }
}
-Write-Host "[1/4] Installing Core Vazirmatn Fonts..." -ForegroundColor Yellow
-
-$coreFonts = @(
- "Vazirmatn-Regular.ttf",
- "Vazirmatn-Medium.ttf",
- "Vazirmatn-SemiBold.ttf",
- "Vazirmatn-Bold.ttf"
-)
+Log-Info "==========================================================" Cyan
+Log-Info " Agent RTL Fix (v2.1.0) - Universal BiDi Setup Engine " Cyan
+Log-Info "==========================================================" Cyan
$ScriptDir = ""
try {
@@ -34,112 +34,292 @@ try {
}
} catch {}
-$regPath = "HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Fonts"
-
-foreach ($fontName in $coreFonts) {
- $target = Join-Path $fontDest $fontName
- $localFile = ""
-
- if ($ScriptDir -and (Test-Path (Join-Path $ScriptDir "fonts\Vazirmatn\$fontName"))) {
- $localFile = Join-Path $ScriptDir "fonts\Vazirmatn\$fontName"
- } elseif ($ScriptDir -and (Test-Path (Join-Path (Split-Path -Parent $ScriptDir) "fonts\Vazirmatn\$fontName"))) {
- $localFile = Join-Path (Split-Path -Parent $ScriptDir) "fonts\Vazirmatn\$fontName"
+# ------------------------------------------------------------------------------
+# 1. Install Fonts & Real-Time Windows Notification
+# ------------------------------------------------------------------------------
+if ((-not $ProjectOnly) -and (-not $NoFonts)) {
+ Log-Info "[1/4] Installing Core Vazirmatn Fonts..." Yellow
+ $fontDest = "$env:LOCALAPPDATA\Microsoft\Windows\Fonts"
+ if (-not (Test-Path $fontDest)) {
+ New-Item -ItemType Directory -Path $fontDest -Force | Out-Null
}
- if ($localFile) {
- try { Copy-Item $localFile $target -Force -ErrorAction SilentlyContinue } catch {}
- } else {
- $fontUrl = "https://raw.githubusercontent.com/$RepoOwner/$RepoName/$Branch/fonts/Vazirmatn/$fontName"
+ $coreFonts = @(
+ "Vazirmatn-Regular.ttf",
+ "Vazirmatn-Medium.ttf",
+ "Vazirmatn-SemiBold.ttf",
+ "Vazirmatn-Bold.ttf"
+ )
+
+ $regPath = "HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Fonts"
+
+ # Define P/Invoke helper for real-time font activation without requiring logoff/reboot
+ try {
+ if (-not ([System.Management.Automation.PSTypeName]'BiDiFontHelper').Type) {
+ Add-Type -TypeDefinition @'
+ using System;
+ using System.Runtime.InteropServices;
+ public class BiDiFontHelper {
+ [DllImport("gdi32.dll", EntryPoint = "AddFontResourceW", SetLastError = true)]
+ public static extern int AddFontResource([In, MarshalAs(UnmanagedType.LPWStr)] string lpFileName);
+
+ [DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
+ public static extern IntPtr SendMessageTimeout(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam, uint fuFlags, uint uTimeout, out IntPtr lpdwResult);
+
+ public const uint WM_FONTCHANGE = 0x001D;
+ public const uint SMTO_ABORTIFHUNG = 0x0002;
+ public static readonly IntPtr HWND_BROADCAST = new IntPtr(0xffff);
+
+ public static void BroadcastChange(string fontPath) {
+ try {
+ AddFontResource(fontPath);
+ IntPtr result;
+ SendMessageTimeout(HWND_BROADCAST, WM_FONTCHANGE, IntPtr.Zero, IntPtr.Zero, SMTO_ABORTIFHUNG, 1000, out result);
+ } catch {}
+ }
+ }
+'@ -ErrorAction SilentlyContinue | Out-Null
+ }
+ } catch {}
+
+ foreach ($fontName in $coreFonts) {
+ $target = Join-Path $fontDest $fontName
+ $localFile = ""
+
+ if ($ScriptDir -and (Test-Path (Join-Path $ScriptDir "fonts\Vazirmatn\$fontName"))) {
+ $localFile = Join-Path $ScriptDir "fonts\Vazirmatn\$fontName"
+ } elseif ($ScriptDir -and (Test-Path (Join-Path (Split-Path -Parent $ScriptDir) "fonts\Vazirmatn\$fontName"))) {
+ $localFile = Join-Path (Split-Path -Parent $ScriptDir) "fonts\Vazirmatn\$fontName"
+ }
+
+ if ($localFile) {
+ try { Copy-Item $localFile $target -Force -ErrorAction SilentlyContinue } catch {}
+ } else {
+ $fontUrl = "https://raw.githubusercontent.com/$RepoOwner/$RepoName/$Branch/fonts/Vazirmatn/$fontName"
+ try {
+ Invoke-WebRequest -Uri $fontUrl -OutFile $target -UseBasicParsing -ErrorAction SilentlyContinue
+ } catch {}
+ }
+
+ $regName = [System.IO.Path]::GetFileNameWithoutExtension($fontName) + " (TrueType)"
+ New-ItemProperty -Path $regPath -Name $regName -Value $target -PropertyType String -Force | Out-Null
+
try {
- Invoke-WebRequest -Uri $fontUrl -OutFile $target -UseBasicParsing -ErrorAction SilentlyContinue
+ [BiDiFontHelper]::BroadcastChange($target)
} catch {}
}
-
- $regName = [System.IO.Path]::GetFileNameWithoutExtension($fontName) + " (TrueType)"
- New-ItemProperty -Path $regPath -Name $regName -Value $target -PropertyType String -Force | Out-Null
+ Log-Info " [OK] Processed Vazirmatn typography system-wide (real-time notification sent)." Green
+} else {
+ Log-Info "[1/4] Skipping typography installation (per flags)." DarkGray
}
-Write-Host " [OK] Processed Vazirmatn typography system-wide." -ForegroundColor Green
-# 2. Configure Global Antigravity AI Machine Rule
-Write-Host "[2/4] Setting Up Global Antigravity AI Rules..." -ForegroundColor Yellow
+# ------------------------------------------------------------------------------
+# 2. Configure Global Antigravity AI Machine Rules & Skills
+# ------------------------------------------------------------------------------
+if (-not $ProjectOnly) {
+ Log-Info "[2/4] Setting Up Global Antigravity AI Rules & Skills..." Yellow
-$globalRulesDir = "$env:USERPROFILE\.gemini\config\rules"
-if (-not (Test-Path $globalRulesDir)) {
- New-Item -ItemType Directory -Path $globalRulesDir -Force | Out-Null
-}
+ $globalConfigDir = "$env:USERPROFILE\.gemini\config"
+ $globalRulesDir = Join-Path $globalConfigDir "rules"
+ $globalSkillsDir = Join-Path $globalConfigDir "skills\agent-rtl-fix"
+
+ if (-not (Test-Path $globalRulesDir)) {
+ New-Item -ItemType Directory -Path $globalRulesDir -Force | Out-Null
+ }
+ if (-not (Test-Path $globalSkillsDir)) {
+ New-Item -ItemType Directory -Path $globalSkillsDir -Force | Out-Null
+ }
-$ruleContent = @'
+ $ruleContent = @'
---
trigger: always_on
description: Universal RTL/LTR BiDi formatting rule for right-to-left languages (Persian, Arabic, Urdu, Hebrew)
---
# Universal RTL/LTR BiDi Formatting Rule
-- **Chat & Artifacts:** Every chat response and markdown artifact (.md) containing right-to-left text (Persian, Arabic, Urdu, Hebrew) MUST be wrapped completely inside `
...
` from start to end for native RTL rendering.
+- **Chat & Artifacts:** Every chat response and markdown artifact (.md) containing right-to-left text (Persian, Arabic, Urdu, Hebrew) MUST be wrapped completely inside `
...
` for native RTL rendering. For artifacts with YAML frontmatter, preserve the frontmatter at the top and enclose the markdown body inside `
`.
- **Markdown Integrity:** Bullet points, tables, headings, blockquotes, and code blocks inside the `
` container retain standard Markdown syntax (do NOT convert tables to raw HTML).
-- **Code & LTR Isolation:** Keep inline code, code blocks, file paths, URLs, shell commands, and logs strictly LTR. Never reverse or break syntax brackets, slashes, or indentation.
+- **Code & LTR Isolation:** Keep inline code, code blocks, file paths, URLs, shell commands, logs, and LaTeX math formulas strictly LTR. Never reverse or break syntax brackets, slashes, or indentation.
- **Zero Exceptions:** Never produce uncontained or left-aligned RTL text in chat or artifacts.
'@
-$targetRule = Join-Path $globalRulesDir "rtl-formatting.md"
-Set-Content -Path $targetRule -Value $ruleContent -Encoding UTF8
-Write-Host " [OK] Installed global agent rule: $targetRule" -ForegroundColor Green
+ $targetRule = Join-Path $globalRulesDir "rtl-formatting.md"
+ Set-Content -Path $targetRule -Value $ruleContent -Encoding UTF8
+ Log-Info " [OK] Installed global agent rule: $targetRule" Green
-# 3. Configure Local Project Rules (Cursor, Windsurf, Copilot, Claude, Cline)
-Write-Host "[3/4] Checking Current Project Directory..." -ForegroundColor Yellow
-$cwd = Get-Location
-$isProject = (Test-Path (Join-Path $cwd ".git")) -or (Test-Path (Join-Path $cwd "package.json")) -or (Test-Path (Join-Path $cwd "go.mod"))
+ $skillContent = @'
+---
+name: agent-rtl-fix
+description: Automatically configures Antigravity IDE, Cursor, and VS Code for native RTL/LTR BiDi support, Vazirmatn fonts, and global agent formatting rules.
+---
+
+# Agent RTL Fix Skill
+
+Configures autonomous coding agents and editors for native Right-to-Left (Persian, Arabic, Urdu, Hebrew) and Left-to-Right bidirectional text support.
+
+## Automated Actions
+1. **Font Setup**: Installs clean Vazirmatn typography for seamless multilingual rendering.
+2. **Editor Settings**: Configures `editor.unicodeHighlight.bidiCharacters: true`, clean font fallback (`'Vazirmatn', 'Fira Code', 'Consolas', monospace`), and balanced line-height.
+3. **Global Agent Rule**: Installs machine-wide rule (`~/.gemini/config/rules/rtl-formatting.md`) so all agent responses render in proper RTL without token overhead.
+'@
+
+ $targetSkill = Join-Path $globalSkillsDir "SKILL.md"
+ Set-Content -Path $targetSkill -Value $skillContent -Encoding UTF8
+ Log-Info " [OK] Installed global skill: $targetSkill" Green
+} else {
+ Log-Info "[2/4] Skipping global machine rules (per flags)." DarkGray
+}
-if ($isProject) {
- Write-Host " -> Project workspace detected at $cwd" -ForegroundColor Cyan
- $agentsPath = Join-Path $cwd "AGENTS.md"
- if (-not (Test-Path $agentsPath)) {
- $agentsRule = @'
+# ------------------------------------------------------------------------------
+# 3. Configure Local Project Rules (Universal AGENTS.md, Cursor, Copilot, Zed)
+# ------------------------------------------------------------------------------
+if (-not $GlobalOnly) {
+ Log-Info "[3/4] Checking Current Project Directory..." Yellow
+ $cwd = Get-Location
+ $isProject = (Test-Path (Join-Path $cwd ".git")) -or
+ (Test-Path (Join-Path $cwd "package.json")) -or
+ (Test-Path (Join-Path $cwd "go.mod")) -or
+ (Test-Path (Join-Path $cwd "Cargo.toml")) -or
+ (Test-Path (Join-Path $cwd "pyproject.toml")) -or
+ (Test-Path (Join-Path $cwd ".cursor")) -or
+ (Test-Path (Join-Path $cwd ".github")) -or
+ (Test-Path (Join-Path $cwd ".zed"))
+
+ $isSelfRepo = (Test-Path (Join-Path $cwd "rules\AGENTS.md")) -and (Test-Path (Join-Path $cwd "fonts\Vazirmatn"))
+
+ if ($isProject -and (-not $isSelfRepo)) {
+ Log-Info " -> Project workspace detected at $cwd" Cyan
+ $agentsPath = Join-Path $cwd "AGENTS.md"
+ if (-not (Test-Path $agentsPath)) {
+ $agentsRule = @'
# Universal AI Agent RTL/LTR BiDi Formatting Standard
+This specification defines the universal bidirectional text formatting protocol for autonomous AI agents, coding assistants, and LLM runtimes (including Antigravity, Cursor, Windsurf, Copilot, Claude Code, Cline, Zed, and Aider).
+
+## 1. Rule Definition
+
Whenever responding or generating documentation in right-to-left (RTL) languages (Persian, Arabic, Urdu, Hebrew):
-1. **Outer RTL Boundary**: Wrap the complete response or markdown file inside `
...
`.
+
+1. **Outer RTL Boundary**: Wrap the complete response or markdown file body inside `
...
`.
2. **Markdown Preservation**: Retain standard GitHub Flavored Markdown (GFM) inside the container. Do NOT convert Markdown tables to verbose raw HTML.
-3. **BiDi Code & Log Isolation**: All code blocks (```lang ... ```), inline code (`code`), terminal logs, shell commands, URLs, and file paths must remain strictly LTR.
-4. **Zero Exceptions**: Never emit uncontained or left-aligned RTL text.
+3. **BiDi Code & Log Isolation**: All code blocks (````lang ... ````), inline code (`code`), terminal logs, shell commands, URLs, and file paths must remain strictly LTR. Do not flip brackets, slashes, or indentation.
+4. **Inline Technical Tokens & Punctuation**: When embedding inline code, variables, or commands within RTL sentences, ensure surrounding punctuation (such as parentheses, colons, and quotes) remains properly oriented.
+5. **Frontmatter & Math Isolation**: If generating Markdown files with YAML frontmatter (`---`), place the frontmatter at the very top of the file, then enclose the content body in `
...
`. Keep multi-line math blocks (`$$...$$`) LTR.
+6. **Zero Left-Aligned RTL**: Never emit uncontained right-to-left text.
'@
- Set-Content -Path $agentsPath -Value $agentsRule -Encoding UTF8
- Write-Host " [OK] Added AGENTS.md to current project" -ForegroundColor Green
+ Set-Content -Path $agentsPath -Value $agentsRule -Encoding UTF8
+ Log-Info " [OK] Added AGENTS.md to current project" Green
+ }
+
+ # Cursor
+ if (Test-Path (Join-Path $cwd ".cursor")) {
+ $cursorRuleDir = Join-Path $cwd ".cursor\rules"
+ if (-not (Test-Path $cursorRuleDir)) { New-Item -ItemType Directory -Path $cursorRuleDir -Force | Out-Null }
+ $cursorRulePath = Join-Path $cursorRuleDir "bidi.mdc"
+ if (-not (Test-Path $cursorRulePath)) {
+ $cursorRule = @'
+---
+description: Universal RTL/LTR BiDi formatting rule for right-to-left languages (Persian, Arabic, Urdu, Hebrew)
+globs: *
+alwaysApply: true
+---
+Wrap all responses containing RTL languages (Persian, Arabic, Urdu, Hebrew) in `
...
`. Keep code and terminal blocks strictly LTR.
+'@
+ Set-Content -Path $cursorRulePath -Value $cursorRule -Encoding UTF8
+ Log-Info " [OK] Added .cursor\rules\bidi.mdc" Green
+ }
+ }
+
+ # GitHub Copilot
+ if (Test-Path (Join-Path $cwd ".github")) {
+ $copilotPath = Join-Path $cwd ".github\copilot-instructions.md"
+ if (-not (Test-Path $copilotPath)) {
+ $copilotRule = @'
+# GitHub Copilot RTL/LTR BiDi Formatting Instructions
+Wrap all RTL language responses (Persian, Arabic, Urdu, Hebrew) inside `
...
`. Keep all code snippets, paths, and commands in standard LTR.
+'@
+ Set-Content -Path $copilotPath -Value $copilotRule -Encoding UTF8
+ Log-Info " [OK] Added .github\copilot-instructions.md" Green
+ }
+ }
+ } else {
+ Log-Info " (No project root in current folder; global machine configs applied)" DarkGray
}
+} else {
+ Log-Info "[3/4] Skipping project-level configuration (per flags)." DarkGray
}
-# 4. Configure IDE Settings
-Write-Host "[4/4] Configuring IDE Bidirectional Settings..." -ForegroundColor Yellow
+# ------------------------------------------------------------------------------
+# 4. Configure IDE Settings (PowerShell 5.1 & Core safe, preserves existing JSON)
+# ------------------------------------------------------------------------------
+if (-not $ProjectOnly) {
+ Log-Info "[4/4] Configuring IDE Bidirectional Settings..." Yellow
-$appDataPaths = @(
- "$env:APPDATA\Antigravity\User",
- "$env:APPDATA\Code\User",
- "$env:APPDATA\Cursor\User"
-)
+ function Update-IdeSettings {
+ param(
+ [string]$DirectoryPath,
+ [hashtable]$NewSettings,
+ [bool]$ForceCreate = $false
+ )
-foreach ($path in $appDataPaths) {
- if (-not (Test-Path $path)) {
- continue
- }
-
- $settingsFile = Join-Path $path "settings.json"
- $existing = @{}
- if (Test-Path $settingsFile) {
- try {
- $existing = Get-Content $settingsFile -Raw | ConvertFrom-Json -AsHashtable
- } catch {
- $existing = @{}
+ if ((-not $ForceCreate) -and (-not (Test-Path $DirectoryPath))) {
+ return
+ }
+
+ if (-not (Test-Path $DirectoryPath)) {
+ New-Item -ItemType Directory -Path $DirectoryPath -Force | Out-Null
+ }
+
+ $settingsFile = Join-Path $DirectoryPath "settings.json"
+ $settings = [ordered]@{}
+
+ if (Test-Path $settingsFile) {
+ try {
+ $jsonRaw = Get-Content $settingsFile -Raw -Encoding UTF8
+ if (-not [string]::IsNullOrWhiteSpace($jsonRaw)) {
+ $parsed = ConvertFrom-Json $jsonRaw
+ if ($parsed) {
+ foreach ($prop in $parsed.PSObject.Properties) {
+ $settings[$prop.Name] = $prop.Value
+ }
+ }
+ }
+ } catch {}
+ }
+
+ foreach ($k in $NewSettings.Keys) {
+ $settings[$k] = $NewSettings[$k]
}
+
+ # Convert to JSON and normalize single quotes (avoid \u0027)
+ $cleanJson = ($settings | ConvertTo-Json -Depth 10) -replace '\\u0027', "'"
+ Set-Content -Path $settingsFile -Value $cleanJson -Encoding UTF8
+ Log-Info " [OK] Updated $settingsFile" Green
+ }
+
+ $vscodeSettings = @{
+ "editor.fontFamily" = "'Vazirmatn', 'Fira Code', 'Cascadia Code', 'Consolas', monospace"
+ "editor.unicodeHighlight.bidiCharacters" = $true
+ "markdown.preview.fontFamily" = "'Vazirmatn', 'Segoe UI', Tahoma, sans-serif"
+ "chat.editor.fontFamily" = "'Vazirmatn', 'Segoe UI', Tahoma, sans-serif"
+ }
+
+ # Ensure Antigravity IDE configuration directory is initialized
+ Update-IdeSettings -DirectoryPath "$env:APPDATA\Antigravity\User" -NewSettings $vscodeSettings -ForceCreate $true
+
+ # Update Code and Cursor if installed
+ Update-IdeSettings -DirectoryPath "$env:APPDATA\Code\User" -NewSettings $vscodeSettings
+ Update-IdeSettings -DirectoryPath "$env:APPDATA\Cursor\User" -NewSettings $vscodeSettings
+
+ # Update Zed if present on Windows
+ $zedSettings = @{
+ "buffer_font_family" = "Vazirmatn"
+ "ui_font_family" = "Vazirmatn"
}
-
- $existing["editor.fontFamily"] = "'Vazirmatn', 'Fira Code', 'Cascadia Code', 'Consolas', monospace"
- $existing["editor.unicodeHighlight.bidiCharacters"] = $true
- $existing["markdown.preview.fontFamily"] = "'Vazirmatn', 'Segoe UI', Tahoma, sans-serif"
- $existing["chat.editor.fontFamily"] = "'Vazirmatn', 'Segoe UI', Tahoma, sans-serif"
-
- $existing | ConvertTo-Json -Depth 10 | Set-Content $settingsFile -Encoding UTF8
- Write-Host " [OK] Updated $settingsFile" -ForegroundColor Green
+ Update-IdeSettings -DirectoryPath "$env:APPDATA\Zed" -NewSettings $zedSettings
+} else {
+ Log-Info "[4/4] Skipping IDE settings update (per flags)." DarkGray
}
-Write-Host "==========================================================" -ForegroundColor Cyan
-Write-Host " Agent RTL Fix installation completed successfully! " -ForegroundColor Green
-Write-Host "==========================================================" -ForegroundColor Cyan
+Log-Info "==========================================================" Cyan
+Log-Info " Agent RTL Fix installation completed successfully! " Green
+Log-Info "==========================================================" Cyan
diff --git a/scripts/install.sh b/scripts/install.sh
index 084d5fc..0613f67 100644
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -1,7 +1,7 @@
#!/usr/bin/env bash
# ==============================================================================
-# Agent RTL Fix - Universal Linux & macOS Installer (v2.0.0)
-# Supports: One-liner remote execution and local offline execution
+# Agent RTL Fix - Universal Linux & macOS Installer (v2.1.0)
+# Supports: One-liner remote execution, local offline execution, and CLI flags
# ==============================================================================
set -e
@@ -10,91 +10,168 @@ REPO_OWNER="dalroot"
REPO_NAME="agent-rtl-fix"
BRANCH="main"
-echo "=========================================================="
-echo " Agent RTL Fix (v2.0.0) - Universal BiDi Setup Engine "
-echo "=========================================================="
+GLOBAL_ONLY=false
+PROJECT_ONLY=false
+NO_FONTS=false
+SILENT=false
-# 1. Install Fonts
-echo "[1/4] Installing Core Vazirmatn Typography..."
-if [ "$(uname)" == "Darwin" ]; then
- FONT_DEST="$HOME/Library/Fonts"
-else
- FONT_DEST="$HOME/.local/share/fonts/Vazirmatn"
-fi
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ --global-only) GLOBAL_ONLY=true; shift ;;
+ --project-only) PROJECT_ONLY=true; shift ;;
+ --no-fonts) NO_FONTS=true; shift ;;
+ --silent) SILENT=true; shift ;;
+ -h|--help)
+ echo "Usage: ./install.sh [OPTIONS]"
+ echo ""
+ echo "Options:"
+ echo " --global-only Install machine-wide rules, skills, and fonts (skip current project)"
+ echo " --project-only Install rules in current workspace only (skip system-wide changes)"
+ echo " --no-fonts Skip font installation"
+ echo " --silent Run silently without banner output"
+ echo " -h, --help Show this help message"
+ exit 0
+ ;;
+ *) shift ;;
+ esac
+done
-mkdir -p "$FONT_DEST"
+log() {
+ if [ "$SILENT" = false ]; then
+ echo -e "$1"
+ fi
+}
-CORE_FONTS=(
- "Vazirmatn-Regular.ttf"
- "Vazirmatn-Medium.ttf"
- "Vazirmatn-SemiBold.ttf"
- "Vazirmatn-Bold.ttf"
-)
+log "=========================================================="
+log " Agent RTL Fix (v2.1.0) - Universal BiDi Setup Engine "
+log "=========================================================="
SCRIPT_DIR=""
if [ -n "${BASH_SOURCE[0]}" ] && [ -f "${BASH_SOURCE[0]}" ]; then
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
fi
-for font in "${CORE_FONTS[@]}"; do
- if [ -n "$SCRIPT_DIR" ] && [ -f "$SCRIPT_DIR/fonts/Vazirmatn/$font" ]; then
- cp -f "$SCRIPT_DIR/fonts/Vazirmatn/$font" "$FONT_DEST/"
- elif [ -n "$SCRIPT_DIR" ] && [ -f "$SCRIPT_DIR/../fonts/Vazirmatn/$font" ]; then
- cp -f "$SCRIPT_DIR/../fonts/Vazirmatn/$font" "$FONT_DEST/"
+# ------------------------------------------------------------------------------
+# 1. Install Fonts
+# ------------------------------------------------------------------------------
+if [ "$PROJECT_ONLY" = false ] && [ "$NO_FONTS" = false ]; then
+ log "[1/4] Installing Core Vazirmatn Typography..."
+ if [ "$(uname)" == "Darwin" ]; then
+ FONT_DEST="$HOME/Library/Fonts"
else
- font_url="https://raw.githubusercontent.com/$REPO_OWNER/$REPO_NAME/$BRANCH/fonts/Vazirmatn/$font"
- curl -fsSL "$font_url" -o "$FONT_DEST/$font" 2>/dev/null || true
+ FONT_DEST="$HOME/.local/share/fonts/Vazirmatn"
fi
-done
-if command -v fc-cache >/dev/null 2>&1; then
- fc-cache -f "$FONT_DEST" >/dev/null 2>&1 || true
+ mkdir -p "$FONT_DEST"
+
+ CORE_FONTS=(
+ "Vazirmatn-Regular.ttf"
+ "Vazirmatn-Medium.ttf"
+ "Vazirmatn-SemiBold.ttf"
+ "Vazirmatn-Bold.ttf"
+ )
+
+ for font in "${CORE_FONTS[@]}"; do
+ if [ -n "$SCRIPT_DIR" ] && [ -f "$SCRIPT_DIR/fonts/Vazirmatn/$font" ]; then
+ cp -f "$SCRIPT_DIR/fonts/Vazirmatn/$font" "$FONT_DEST/"
+ elif [ -n "$SCRIPT_DIR" ] && [ -f "$SCRIPT_DIR/../fonts/Vazirmatn/$font" ]; then
+ cp -f "$SCRIPT_DIR/../fonts/Vazirmatn/$font" "$FONT_DEST/"
+ else
+ font_url="https://raw.githubusercontent.com/$REPO_OWNER/$REPO_NAME/$BRANCH/fonts/Vazirmatn/$font"
+ curl -fsSL "$font_url" -o "$FONT_DEST/$font" 2>/dev/null || true
+ fi
+ done
+
+ if command -v fc-cache >/dev/null 2>&1; then
+ fc-cache -f "$FONT_DEST" >/dev/null 2>&1 || true
+ fi
+ log " [OK] Installed Vazirmatn fonts to $FONT_DEST"
+else
+ log "[1/4] Skipping typography installation (per flags)."
fi
-echo " [OK] Installed Vazirmatn fonts to $FONT_DEST"
-# 2. Configure Global Antigravity Machine Rule
-echo "[2/4] Setting Up Global Antigravity AI Rules..."
-RULES_DIR="$HOME/.gemini/config/rules"
-mkdir -p "$RULES_DIR"
+# ------------------------------------------------------------------------------
+# 2. Configure Global Antigravity AI Machine Rules & Skills
+# ------------------------------------------------------------------------------
+if [ "$PROJECT_ONLY" = false ]; then
+ log "[2/4] Setting Up Global Antigravity AI Rules & Skills..."
+ RULES_DIR="$HOME/.gemini/config/rules"
+ SKILLS_DIR="$HOME/.gemini/config/skills/agent-rtl-fix"
+ mkdir -p "$RULES_DIR"
+ mkdir -p "$SKILLS_DIR"
-cat << 'EOF' > "$RULES_DIR/rtl-formatting.md"
+ cat << 'EOF' > "$RULES_DIR/rtl-formatting.md"
---
trigger: always_on
description: Universal RTL/LTR BiDi formatting rule for right-to-left languages (Persian, Arabic, Urdu, Hebrew)
---
# Universal RTL/LTR BiDi Formatting Rule
-- **Chat & Artifacts:** Every chat response and markdown artifact (.md) containing right-to-left text (Persian, Arabic, Urdu, Hebrew) MUST be wrapped completely inside `
...
` from start to end for native RTL rendering.
+- **Chat & Artifacts:** Every chat response and markdown artifact (.md) containing right-to-left text (Persian, Arabic, Urdu, Hebrew) MUST be wrapped completely inside `
...
` for native RTL rendering. For artifacts with YAML frontmatter, preserve the frontmatter at the top and enclose the markdown body inside `
`.
- **Markdown Integrity:** Bullet points, tables, headings, blockquotes, and code blocks inside the `
` container retain standard Markdown syntax (do NOT convert tables to raw HTML).
-- **Code & LTR Isolation:** Keep inline code, code blocks, file paths, URLs, shell commands, and logs strictly LTR. Never reverse or break syntax brackets, slashes, or indentation.
+- **Code & LTR Isolation:** Keep inline code, code blocks, file paths, URLs, shell commands, logs, and LaTeX math formulas strictly LTR. Never reverse or break syntax brackets, slashes, or indentation.
- **Zero Exceptions:** Never produce uncontained or left-aligned RTL text in chat or artifacts.
EOF
+ log " [OK] Global Antigravity rule installed at: $RULES_DIR/rtl-formatting.md"
+
+ cat << 'EOF' > "$SKILLS_DIR/SKILL.md"
+---
+name: agent-rtl-fix
+description: Automatically configures Antigravity IDE, Cursor, and VS Code for native RTL/LTR BiDi support, Vazirmatn fonts, and global agent formatting rules.
+---
+
+# Agent RTL Fix Skill
+
+Configures autonomous coding agents and editors for native Right-to-Left (Persian, Arabic, Urdu, Hebrew) and Left-to-Right bidirectional text support.
+
+## Automated Actions
+1. **Font Setup**: Installs clean Vazirmatn typography for seamless multilingual rendering.
+2. **Editor Settings**: Configures `editor.unicodeHighlight.bidiCharacters: true`, clean font fallback (`'Vazirmatn', 'Fira Code', 'Consolas', monospace`), and balanced line-height.
+3. **Global Agent Rule**: Installs machine-wide rule (`~/.gemini/config/rules/rtl-formatting.md`) so all agent responses render in proper RTL without token overhead.
+EOF
+ log " [OK] Global Antigravity skill installed at: $SKILLS_DIR/SKILL.md"
+else
+ log "[2/4] Skipping global machine rules (per flags)."
+fi
-echo " [OK] Global Antigravity rule installed at: $RULES_DIR/rtl-formatting.md"
-
-# 3. Configure Local Project Rules (Cursor, Windsurf, Copilot, Claude, Cline)
-echo "[3/4] Checking Current Project Directory..."
-CWD="$(pwd)"
-if [ -d "$CWD/.git" ] || [ -f "$CWD/package.json" ] || [ -f "$CWD/go.mod" ] || [ -f "$CWD/Cargo.toml" ] || [ -f "$CWD/pyproject.toml" ]; then
- echo " -> Project workspace detected at $CWD"
-
- # Universal AGENTS.md
- if [ ! -f "$CWD/AGENTS.md" ]; then
- cat << 'EOF' > "$CWD/AGENTS.md"
+# ------------------------------------------------------------------------------
+# 3. Configure Local Project Rules (Universal AGENTS.md, Cursor, Copilot, Zed)
+# ------------------------------------------------------------------------------
+if [ "$GLOBAL_ONLY" = false ]; then
+ log "[3/4] Checking Current Project Directory..."
+ CWD="$(pwd)"
+ IS_SELF_REPO=false
+ if [ -f "$CWD/rules/AGENTS.md" ] && [ -d "$CWD/fonts/Vazirmatn" ]; then
+ IS_SELF_REPO=true
+ fi
+
+ if { [ -d "$CWD/.git" ] || [ -f "$CWD/package.json" ] || [ -f "$CWD/go.mod" ] || [ -f "$CWD/Cargo.toml" ] || [ -f "$CWD/pyproject.toml" ] || [ -d "$CWD/.cursor" ] || [ -d "$CWD/.github" ] || [ -d "$CWD/.zed" ]; } && [ "$IS_SELF_REPO" = false ]; then
+ log " -> Project workspace detected at $CWD"
+
+ # Universal AGENTS.md
+ if [ ! -f "$CWD/AGENTS.md" ]; then
+ cat << 'EOF' > "$CWD/AGENTS.md"
# Universal AI Agent RTL/LTR BiDi Formatting Standard
+This specification defines the universal bidirectional text formatting protocol for autonomous AI agents, coding assistants, and LLM runtimes (including Antigravity, Cursor, Windsurf, Copilot, Claude Code, Cline, Zed, and Aider).
+
+## 1. Rule Definition
+
Whenever responding or generating documentation in right-to-left (RTL) languages (Persian, Arabic, Urdu, Hebrew):
-1. **Outer RTL Boundary**: Wrap the complete response or markdown file inside `
...
`.
+
+1. **Outer RTL Boundary**: Wrap the complete response or markdown file body inside `
...
`.
2. **Markdown Preservation**: Retain standard GitHub Flavored Markdown (GFM) inside the container. Do NOT convert Markdown tables to verbose raw HTML.
-3. **BiDi Code & Log Isolation**: All code blocks (```lang ... ```), inline code (`code`), terminal logs, shell commands, URLs, and file paths must remain strictly LTR.
-4. **Zero Exceptions**: Never emit uncontained or left-aligned RTL text.
+3. **BiDi Code & Log Isolation**: All code blocks (````lang ... ````), inline code (`code`), terminal logs, shell commands, URLs, and file paths must remain strictly LTR. Do not flip brackets, slashes, or indentation.
+4. **Inline Technical Tokens & Punctuation**: When embedding inline code, variables, or commands within RTL sentences, ensure surrounding punctuation (such as parentheses, colons, and quotes) remains properly oriented.
+5. **Frontmatter & Math Isolation**: If generating Markdown files with YAML frontmatter (`---`), place the frontmatter at the very top of the file, then enclose the content body in `
...
`. Keep multi-line math blocks (`$$...$$`) LTR.
+6. **Zero Left-Aligned RTL**: Never emit uncontained right-to-left text.
EOF
- echo " [OK] Added AGENTS.md to current project"
- fi
+ log " [OK] Added AGENTS.md to current project"
+ fi
- # Cursor
- if [ -d "$CWD/.cursor" ]; then
- mkdir -p "$CWD/.cursor/rules"
- cat << 'EOF' > "$CWD/.cursor/rules/bidi.mdc"
+ # Cursor
+ if [ -d "$CWD/.cursor" ]; then
+ mkdir -p "$CWD/.cursor/rules"
+ cat << 'EOF' > "$CWD/.cursor/rules/bidi.mdc"
---
description: Universal RTL/LTR BiDi formatting rule
globs: *
@@ -102,57 +179,88 @@ alwaysApply: true
---
Wrap all responses containing RTL languages (Persian, Arabic, Urdu, Hebrew) in `
...
`. Keep code and terminal blocks strictly LTR.
EOF
- echo " [OK] Added .cursor/rules/bidi.mdc"
- fi
+ log " [OK] Added .cursor/rules/bidi.mdc"
+ fi
- # GitHub Copilot
- if [ -d "$CWD/.github" ]; then
- cat << 'EOF' > "$CWD/.github/copilot-instructions.md"
+ # GitHub Copilot
+ if [ -d "$CWD/.github" ]; then
+ cat << 'EOF' > "$CWD/.github/copilot-instructions.md"
# GitHub Copilot RTL/LTR BiDi Formatting Instructions
Wrap all RTL language responses (Persian, Arabic, Urdu, Hebrew) inside `
...
`. Keep all code snippets, paths, and commands in standard LTR.
EOF
- echo " [OK] Added .github/copilot-instructions.md"
+ log " [OK] Added .github/copilot-instructions.md"
+ fi
+
+ # Zed
+ if [ -d "$CWD/.zed" ]; then
+ if [ ! -f "$CWD/.zed/settings.json" ]; then
+ cat << 'EOF' > "$CWD/.zed/settings.json"
+{
+ "buffer_font_family": "Vazirmatn",
+ "ui_font_family": "Vazirmatn"
+}
+EOF
+ log " [OK] Added .zed/settings.json"
+ fi
+ fi
+ else
+ log " (No project root in current folder; global machine configs applied)"
fi
else
- echo " (No project root in current folder; global machine configs applied)"
+ log "[3/4] Skipping project-level configuration (per flags)."
fi
-# 4. Update VS Code / Antigravity / Cursor settings if present
-echo "[4/4] Updating Editor Settings (Font & BiDi Highlighting)..."
-CONFIG_DIRS=(
- "$HOME/.config/Antigravity/User"
- "$HOME/.config/Code/User"
- "$HOME/.config/Cursor/User"
- "$HOME/Library/Application Support/Antigravity/User"
- "$HOME/Library/Application Support/Code/User"
- "$HOME/Library/Application Support/Cursor/User"
-)
-
-for cdir in "${CONFIG_DIRS[@]}"; do
- if [ -d "$cdir" ]; then
- sfile="$cdir/settings.json"
- if [ ! -f "$sfile" ]; then
- echo "{}" > "$sfile"
- fi
- if command -v python3 >/dev/null 2>&1; then
- python3 -c "
-import json
+# ------------------------------------------------------------------------------
+# 4. Update Editor Settings (VS Code, Cursor, Antigravity, Zed)
+# ------------------------------------------------------------------------------
+if [ "$PROJECT_ONLY" = false ]; then
+ log "[4/4] Updating Editor Settings (Font & BiDi Highlighting)..."
+ CONFIG_DIRS=(
+ "$HOME/.config/Antigravity/User"
+ "$HOME/.config/Code/User"
+ "$HOME/.config/Cursor/User"
+ "$HOME/.config/zed"
+ "$HOME/Library/Application Support/Antigravity/User"
+ "$HOME/Library/Application Support/Code/User"
+ "$HOME/Library/Application Support/Cursor/User"
+ "$HOME/Library/Application Support/Zed"
+ )
+
+ for cdir in "${CONFIG_DIRS[@]}"; do
+ if [ -d "$cdir" ]; then
+ sfile="$cdir/settings.json"
+ if [ ! -f "$sfile" ]; then
+ echo "{}" > "$sfile"
+ fi
+ if command -v python3 >/dev/null 2>&1; then
+ python3 -c "
+import json, sys
+sfile = '$sfile'
try:
- with open('$sfile', 'r', encoding='utf-8') as f:
+ with open(sfile, 'r', encoding='utf-8') as f:
data = json.load(f)
except Exception:
data = {}
-data['editor.fontFamily'] = \"'Vazirmatn', 'Fira Code', 'Cascadia Code', 'Consolas', monospace\"
-data['editor.unicodeHighlight.bidiCharacters'] = True
-data['markdown.preview.fontFamily'] = \"'Vazirmatn', 'Segoe UI', Tahoma, sans-serif\"
-data['chat.editor.fontFamily'] = \"'Vazirmatn', 'Segoe UI', Tahoma, sans-serif\"
-with open('$sfile', 'w', encoding='utf-8') as f:
+
+if 'zed' in sfile.lower():
+ data['buffer_font_family'] = 'Vazirmatn'
+ data['ui_font_family'] = 'Vazirmatn'
+else:
+ data['editor.fontFamily'] = \"'Vazirmatn', 'Fira Code', 'Cascadia Code', 'Consolas', monospace\"
+ data['editor.unicodeHighlight.bidiCharacters'] = True
+ data['markdown.preview.fontFamily'] = \"'Vazirmatn', 'Segoe UI', Tahoma, sans-serif\"
+ data['chat.editor.fontFamily'] = \"'Vazirmatn', 'Segoe UI', Tahoma, sans-serif\"
+
+with open(sfile, 'w', encoding='utf-8') as f:
json.dump(data, f, indent=4, ensure_ascii=False)
-" 2>/dev/null && echo " [OK] Updated $sfile" || true
+" 2>/dev/null && log " [OK] Updated $sfile" || true
+ fi
fi
- fi
-done
+ done
+else
+ log "[4/4] Skipping editor settings update (per flags)."
+fi
-echo "=========================================================="
-echo " Agent RTL Fix installation completed successfully! "
-echo "=========================================================="
+log "=========================================================="
+log " Agent RTL Fix installation completed successfully! "
+log "=========================================================="
diff --git a/scripts/uninstall.ps1 b/scripts/uninstall.ps1
index 7de5863..54de29f 100644
--- a/scripts/uninstall.ps1
+++ b/scripts/uninstall.ps1
@@ -1,14 +1,51 @@
# ==============================================================================
-# Agent RTL Fix - Uninstaller for Windows
+# Agent RTL Fix - Uninstaller for Windows (v2.1.0)
+# Supports: Standard rule removal and -Full typography cleanup
# ==============================================================================
-Write-Host "Removing Agent RTL Fix global rule..." -ForegroundColor Yellow
+[CmdletBinding()]
+param(
+ [switch]$Full
+)
+
+Write-Host "Removing Agent RTL Fix global configuration..." -ForegroundColor Yellow
+
+# 1. Remove Global Rule & Skill
$targetRule = "$env:USERPROFILE\.gemini\config\rules\rtl-formatting.md"
+$targetSkill = "$env:USERPROFILE\.gemini\config\skills\agent-rtl-fix"
+
if (Test-Path $targetRule) {
Remove-Item $targetRule -Force
- Write-Host "Removed $targetRule" -ForegroundColor Green
-} else {
- Write-Host "Rule not found." -ForegroundColor DarkGray
+ Write-Host " [OK] Removed global rule: $targetRule" -ForegroundColor Green
+}
+
+if (Test-Path $targetSkill) {
+ Remove-Item $targetSkill -Recurse -Force
+ Write-Host " [OK] Removed global skill: $targetSkill" -ForegroundColor Green
+}
+
+# 2. Optional Full Cleanup (Fonts & Registry)
+if ($Full) {
+ Write-Host "Cleaning up Vazirmatn fonts and registry keys..." -ForegroundColor Yellow
+ $fontDest = "$env:LOCALAPPDATA\Microsoft\Windows\Fonts"
+ $regPath = "HKCU:\Software\Microsoft\Windows NT\CurrentVersion\Fonts"
+
+ $coreFonts = @(
+ "Vazirmatn-Regular.ttf",
+ "Vazirmatn-Medium.ttf",
+ "Vazirmatn-SemiBold.ttf",
+ "Vazirmatn-Bold.ttf"
+ )
+
+ foreach ($fontName in $coreFonts) {
+ $fontPath = Join-Path $fontDest $fontName
+ if (Test-Path $fontPath) {
+ try { Remove-Item $fontPath -Force } catch {}
+ }
+ $regName = [System.IO.Path]::GetFileNameWithoutExtension($fontName) + " (TrueType)"
+ try { Remove-ItemProperty -Path $regPath -Name $regName -ErrorAction SilentlyContinue } catch {}
+ }
+ Write-Host " [OK] Removed installed Vazirmatn fonts and registry entries." -ForegroundColor Green
}
Write-Host "Uninstallation complete." -ForegroundColor Green
diff --git a/scripts/uninstall.sh b/scripts/uninstall.sh
index b2bd281..501f957 100644
--- a/scripts/uninstall.sh
+++ b/scripts/uninstall.sh
@@ -1,15 +1,49 @@
#!/usr/bin/env bash
# ==============================================================================
-# Agent RTL Fix - Uninstaller for Linux & macOS
+# Agent RTL Fix - Uninstaller for Linux & macOS (v2.1.0)
+# Supports: Standard rule removal and --full typography cleanup
# ==============================================================================
-echo "Removing Agent RTL Fix global rule..."
-TARGET_RULE="$HOME/.gemini/config/rules/rtl-formatting.md"
-if [ -f "$TARGET_RULE" ]; then
- rm -f "$TARGET_RULE"
- echo "Removed $TARGET_RULE"
-else
- echo "Rule not found."
+set -e
+
+FULL=false
+while [[ $# -gt 0 ]]; do
+ case "$1" in
+ --full) FULL=true; shift ;;
+ *) shift ;;
+ esac
+done
+
+echo "Removing Agent RTL Fix global configuration..."
+
+# 1. Remove Global Rule & Skill
+RULES_FILE="$HOME/.gemini/config/rules/rtl-formatting.md"
+SKILLS_DIR="$HOME/.gemini/config/skills/agent-rtl-fix"
+
+if [ -f "$RULES_FILE" ]; then
+ rm -f "$RULES_FILE"
+ echo " [OK] Removed $RULES_FILE"
+fi
+
+if [ -d "$SKILLS_DIR" ]; then
+ rm -rf "$SKILLS_DIR"
+ echo " [OK] Removed $SKILLS_DIR"
+fi
+
+# 2. Optional Full Cleanup
+if [ "$FULL" = true ]; then
+ echo "Cleaning up Vazirmatn fonts..."
+ if [ "$(uname)" == "Darwin" ]; then
+ FONT_DEST="$HOME/Library/Fonts"
+ rm -f "$FONT_DEST"/Vazirmatn-*.ttf 2>/dev/null || true
+ else
+ FONT_DEST="$HOME/.local/share/fonts/Vazirmatn"
+ rm -rf "$FONT_DEST" 2>/dev/null || true
+ if command -v fc-cache >/dev/null 2>&1; then
+ fc-cache -f >/dev/null 2>&1 || true
+ fi
+ fi
+ echo " [OK] Removed font files"
fi
echo "Uninstallation complete."