From eed4eb5393fc86a40b648b9578741f7c9d999e32 Mon Sep 17 00:00:00 2001 From: Morteza Amirkar Date: Sun, 15 Nov 2026 10:24:17 +0330 Subject: [PATCH 1/4] fix(install): resolve PowerShell 5.1 JSON corruption, add CLI flags and WM_FONTCHANGE broadcast - Fix silent ConvertFrom-Json -AsHashtable failure in standard Windows PowerShell 5.1 that wiped out existing user settings - Introduce backward-compatible PSObject property parser ensuring 100% preservation of existing settings.json - Normalize JSON output without escaped single quotes (\u0027) - Add P/Invoke call to AddFontResourceW and SendMessageTimeout (WM_FONTCHANGE) for real-time font activation without reboot - Add CLI switches: -GlobalOnly, -ProjectOnly, -NoFonts, -Silent on Windows and equivalent flags on Bash - Deploy global agent-rtl-fix skill alongside rule to ~/.gemini/config/skills/ - Support -Full / --full flag in uninstaller scripts --- install.ps1 | 366 +++++++++++++++++++++++++++++++----------- install.sh | 300 +++++++++++++++++++++++----------- scripts/install.ps1 | 366 +++++++++++++++++++++++++++++++----------- scripts/install.sh | 300 +++++++++++++++++++++++----------- scripts/uninstall.ps1 | 47 +++++- scripts/uninstall.sh | 50 +++++- 6 files changed, 1038 insertions(+), 391 deletions(-) diff --git a/install.ps1 b/install.ps1 index 643031e..2059b12 100644 --- a/install.ps1 +++ b/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/install.sh b/install.sh index 084d5fc..0613f67 100644 --- a/install.sh +++ b/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/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." From 55eb543a52e3552f5363433cdd26c3dbce25e988 Mon Sep 17 00:00:00 2001 From: Morteza Amirkar Date: Sun, 15 Nov 2026 10:24:24 +0330 Subject: [PATCH 2/4] feat(agents): expand matrix with Zed Editor and Aider rules, refine BiDi edge cases - Add dedicated rules/zed.md configuration for Zed editor typography and assistant rules - Add dedicated rules/aider.md system prompt configuration for Aider CLI - Refine universal AGENTS.md and antigravity.md rules for inline code parentheses orientation, artifact frontmatter isolation, and LaTeX math handling --- rules/AGENTS.md | 8 +++++--- rules/aider.md | 16 ++++++++++++++++ rules/antigravity.md | 4 ++-- rules/zed.md | 20 ++++++++++++++++++++ 4 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 rules/aider.md create mode 100644 rules/zed.md 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. From 4debb42595eec542d390884e73127f0f83afbe47 Mon Sep 17 00:00:00 2001 From: Morteza Amirkar Date: Sun, 15 Nov 2026 10:24:29 +0330 Subject: [PATCH 3/4] ci: add cross-platform test matrix for PowerShell 5.1/7 and Unix shells - Add GitHub Actions CI workflow running on windows-latest, ubuntu-latest, and macos-latest - Validate install.ps1 compatibility and settings.json preservation under both Windows PowerShell 5.1 and pwsh 7 - Validate bash script syntax and project-only execution - Verify synchronization between root installers and scripts/ directory --- .github/workflows/ci.yml | 85 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..af06613 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,85 @@ +name: CI Test Matrix & Quality Verification + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + test-windows: + name: Windows Installer Validation (PS 5.1 & PS 7) + runs-on: windows-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Test Windows PowerShell 5.1 Compatibility + shell: powershell + run: | + Write-Host "Testing install.ps1 on Windows PowerShell $($PSVersionTable.PSVersion)..." + .\install.ps1 -Silent -ProjectOnly + if (-not (Test-Path "AGENTS.md")) { + throw "AGENTS.md was not generated in project workspace!" + } + + - name: Test PowerShell Core (pwsh) Compatibility + shell: pwsh + run: | + Write-Host "Testing install.ps1 on PowerShell Core $($PSVersionTable.PSVersion)..." + .\install.ps1 -Silent -ProjectOnly + + - name: Verify JSON Settings Preservation + shell: powershell + run: | + $testDir = New-Item -ItemType Directory -Path "$env:TEMP\agent-rtl-test" -Force + $testSettings = Join-Path $testDir "settings.json" + $initialJson = '{"existing.custom.key": "preserve_me", "editor.tabSize": 2}' + Set-Content -Path $testSettings -Value $initialJson -Encoding UTF8 + + # Test Update logic in PowerShell 5.1 + $raw = Get-Content $testSettings -Raw | ConvertFrom-Json + $dict = [ordered]@{} + foreach ($p in $raw.PSObject.Properties) { $dict[$p.Name] = $p.Value } + $dict["editor.fontFamily"] = "'Vazirmatn', monospace" + $out = ($dict | ConvertTo-Json) -replace '\\u0027', "'" + Set-Content -Path $testSettings -Value $out -Encoding UTF8 + + $verified = Get-Content $testSettings -Raw | ConvertFrom-Json + if ($verified."existing.custom.key" -ne "preserve_me") { + throw "Existing user settings were wiped out!" + } + Write-Host "Settings preservation test passed." + + test-unix: + name: Unix Shell Validation (${{ matrix.os }}) + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest] + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Check Bash Syntax + run: | + bash -n install.sh + bash -n scripts/install.sh + bash -n scripts/uninstall.sh + + - name: Test Installer Execution (--silent --project-only) + run: | + bash install.sh --silent --project-only + test -f AGENTS.md + + sync-check: + name: Script Consistency & Single Source of Truth Check + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v4 + + - name: Compare Root and Scripts Directory + run: | + diff -u install.ps1 scripts/install.ps1 + diff -u install.sh scripts/install.sh From c9844e73607b7d6d0596c7fab7ad72b2500633dd Mon Sep 17 00:00:00 2001 From: Morteza Amirkar Date: Sun, 15 Nov 2026 10:24:34 +0330 Subject: [PATCH 4/4] docs: update English and Persian documentation with v2.1.0 features and CLI flags - Update supported agent matrix with Zed Editor and Aider - Document new CLI switches (-GlobalOnly, -ProjectOnly, -NoFonts, -Silent) - Highlight real-time font activation without requiring system reboots - Update repository layout tree with new rules, CI workflow, and skill paths --- README.fa.md | 50 ++++++++++++++++++++++++++++++++++++------------- README.md | 53 ++++++++++++++++++++++++++++++++++++++-------------- 2 files changed, 76 insertions(+), 27 deletions(-) diff --git a/README.fa.md b/README.fa.md index 3e2a374..a488fae 100644 --- a/README.fa.md +++ b/README.fa.md @@ -9,9 +9,9 @@

- Release v2.0.0 + Release v2.1.0 Platforms - Supported Agents + Supported Agents License MIT

@@ -23,7 +23,7 @@ ## ⚡ ریشه مشکل چیست؟ -هنگامی که ایجنت‌های هوش مصنوعی برنامه‌نویسی (مانند **Google Antigravity**، **Cursor**، **Windsurf**، **GitHub Copilot** یا **Claude Code**) به زبان‌های راست‌چین (فارسی، عربی، اردو، عبری) پاسخ می‌دهند، چالش‌های زیر رخ می‌دهد: +هنگامی که ایجنت‌های هوش مصنوعی برنامه‌نویسی (مانند **Google Antigravity**، **Cursor**، **Windsurf**، **Zed**، **Aider**، **GitHub Copilot** یا **Claude Code**) به زبان‌های راست‌چین (فارسی، عربی، اردو، عبری) پاسخ می‌دهند، چالش‌های زیر رخ می‌دهد: ۱. **جابجایی پرانتزها و علائم نگارشی:** پرانتزها `()`، کروشه‌ها `[]` و علائم نگارشی بین خطوط معلق و جابجا می‌شوند. ۲. **معکوس شدن مسیر فایل‌ها و لینک‌ها:** آدرس فایل‌ها (`/var/log/...` یا `C:\Users\...`) و URLها به صورت معکوس و درهم‌ریخته رندر می‌شوند. @@ -36,7 +36,7 @@ ## 💬 فعال‌سازی مستقیم با ۱ پرامپت در چت (بدون نیاز به ترمینال) -نیازی به باز کردن ترمینال نیست! کافیست پرامپت زیر را کپی کرده و مستقیماً در پنجره چت ایجنت هوش مصنوعی خود (در Antigravity، Cursor، Windsurf، Claude Code یا Copilot) ارسال کنید: +نیازی به باز کردن ترمینال نیست! کافیست پرامپت زیر را کپی کرده و مستقیماً در پنجره چت ایجنت هوش مصنوعی خود (در Antigravity، Cursor، Windsurf، Zed، Claude Code یا Copilot) ارسال کنید: ```text لطفاً استاندارد راست‌چین‌سازی و فرمت‌بندی دوطرفه (BiDi/RTL) را از نشانی زیر بخوان و به عنوان قانون دائم (Always-on Rule) در این محیط/پروژه اعمال کن: @@ -47,7 +47,7 @@ https://raw.githubusercontent.com/dalroot/agent-rtl-fix/main/rules/AGENTS.md ## 🚀 نصب سریع از طریق ترمینال (دستور تک‌خطی) -اجرای اسکریپت نصب به صورت خودکار فونت‌های بهینه وزیرمتن را نصب کرده، قابلیت BiDi را در ادیتور فعال می‌سازد و قانون سراسری را برای Antigravity و پروژه‌ها ثبت می‌کند: +اجرای اسکریپت نصب به صورت خودکار فونت‌های بهینه وزیرمتن را نصب کرده (همراه با فراخوانی سیستمی جهت فعال‌سازی آنی بدون نیاز به ریستارت سیستم)، قابلیت BiDi را در ادیتور فعال می‌سازد و قوانین سراسری و پروژه را ثبت می‌کند: ### در ویندوز (PowerShell) ```powershell @@ -59,6 +59,22 @@ irm https://raw.githubusercontent.com/dalroot/agent-rtl-fix/main/install.ps1 | i curl -fsSL https://raw.githubusercontent.com/dalroot/agent-rtl-fix/main/install.sh | bash ``` +### سوییچ‌های پیشرفته خط فرمان (CLI Flags) + +نصب‌کننده‌ها از سوییچ‌های اختیاری زیر پشتیبانی می‌کنند: + +| سوییچ در PowerShell | فلگ در Bash | توضیحات | +| :--- | :--- | :--- | +| `-GlobalOnly` | `--global-only` | فقط اعمال تنظیمات، فونت‌ها و قوانین سراسری سیستم (نادیده گرفتن پوشه پروژه فعلی) | +| `-ProjectOnly` | `--project-only` | فقط ایجاد فایل‌های قانون `AGENTS.md` در پروژه فعلی (بدون دستکاری تنظیمات سراسری سیستم) | +| `-NoFonts` | `--no-fonts` | عدم نصب فونت (مناسب برای سرورها، خطوط CI/CD و کانتینرهای داکر) | +| `-Silent` | `--silent` | اجرای بی‌صدا و بدون نمایش بنر و لاگ‌های اضافی | + +*نمونه استفاده:* +```powershell +.\install.ps1 -ProjectOnly +``` + ### نصب آفلاین / با یک کلیک 1. فایل زیپ پکیج را از [صفحه آخرین نسخه](https://github.com/dalroot/agent-rtl-fix/releases/latest) دانلود کنید. 2. فایل را از حالت فشرده خارج کرده و روی `install.bat` (ویندوز) یا `bash install.sh` (لینوکس/مک) کلیک کنید. @@ -69,9 +85,11 @@ curl -fsSL https://raw.githubusercontent.com/dalroot/agent-rtl-fix/main/install. | ایجنت برنامه‌نویسی | محل قرارگیری فایل کانفیگ | فایل قانون در این ریپازیتوری | نحوه فعال‌سازی | | :--- | :--- | :--- | :--- | -| **Google Antigravity** | `~/.gemini/config/rules/` | [`rules/antigravity.md`](rules/antigravity.md) | نصب خودکار سراسری روی کل سیستم (`trigger: always_on`) | +| **Google Antigravity** | `~/.gemini/config/rules/` و `skills/` | [`rules/antigravity.md`](rules/antigravity.md) | نصب خودکار سراسری روی کل سیستم (`trigger: always_on`) | | **Cursor IDE** | `.cursor/rules/` یا ریشه پروژه | [`rules/cursor.mdc`](rules/cursor.mdc) | کپی در `.cursor/rules/bidi.mdc` یا `.cursorrules` | | **Windsurf (Codeium)** | ریشه پروژه | [`rules/windsurf.rules`](rules/windsurf.rules) | کپی در `.windsurfrules` | +| **Zed Editor** | `.zed/settings.json` یا ریشه پروژه | [`rules/zed.md`](rules/zed.md) | تنظیم فونت وزیرمتن در Zed و قرار دادن `AGENTS.md` | +| **Aider CLI** | `.aider.conf.yml` یا ریشه پروژه | [`rules/aider.md`](rules/aider.md) | افزودن متن پرامپت به `.aider.conf.yml` یا قرار دادن `AGENTS.md` | | **GitHub Copilot** | پوشه `.github/` | [`rules/copilot-instructions.md`](rules/copilot-instructions.md) | کپی در `.github/copilot-instructions.md` | | **Claude Code** | ریشه پروژه | [`rules/claude.md`](rules/claude.md) | اضافه کردن به فایل `CLAUDE.md` | | **Cline / Roo Code** | ریشه پروژه | [`rules/cline.md`](rules/cline.md) | کپی در `.clinerules` | @@ -87,8 +105,9 @@ curl -fsSL https://raw.githubusercontent.com/dalroot/agent-rtl-fix/main/install. - Whenever responding in RTL languages (Persian, Arabic, Urdu, Hebrew): 1. Wrap the complete response inside
...
. 2. Keep standard Markdown syntax for headings, bullet points, and tables. - 3. Keep all code blocks, logs, terminal outputs, and file paths strictly LTR. - 4. Never produce uncontained or left-aligned RTL text. + 3. Keep all code blocks, logs, terminal outputs, file paths, and LaTeX math strictly LTR. + 4. Ensure surrounding punctuation around inline code does not flip. + 5. Never produce uncontained or left-aligned RTL text. ``` --- @@ -99,15 +118,21 @@ curl -fsSL https://raw.githubusercontent.com/dalroot/agent-rtl-fix/main/install. agent-rtl-fix/ ├── .github/ │ └── workflows/ +│ ├── ci.yml # ماتریس تست خودکار در Windows، Ubuntu و macOS │ └── release.yml # انتشار خودکار پکیج زیپ و صفحه ریلیز ├── rules/ # قوانین تفکیک‌شده برای تمام ایجنت‌ها │ ├── antigravity.md # قانون سراسری Antigravity │ ├── cursor.mdc # قانون اختصاصی Cursor │ ├── windsurf.rules # قانون Windsurf +│ ├── zed.md # راهنمای تنظیمات ادیتور Zed +│ ├── aider.md # دستور پرامپت دستیار کدنویسی Aider │ ├── copilot-instructions.md # دستورالعمل GitHub Copilot │ ├── claude.md # دستورالعمل Claude Code │ ├── cline.md # قانون Cline و Roo Code │ └── AGENTS.md # استاندارد جهانی AGENTS.md +├── skills/ # مهارت‌های سفارشی Antigravity AI +│ └── agent-rtl-fix/ +│ └── SKILL.md # تعریف سراسری مهارت ├── fonts/ # فونت سبک وزیرمتن (~۵۰۰ کیلوبایت) │ └── Vazirmatn/ │ ├── Vazirmatn-Regular.ttf @@ -115,23 +140,22 @@ agent-rtl-fix/ │ ├── Vazirmatn-SemiBold.ttf │ └── Vazirmatn-Bold.ttf ├── scripts/ -│ ├── install.ps1 # اسکریپت نصب ویندوز +│ ├── install.ps1 # اسکریپت نصب ویندوز (همراه با حل باگ PS5.1) │ ├── install.sh # اسکریپت نصب لینوکس و مک -│ ├── uninstall.ps1 # اسکریپت حذف ویندوز -│ └── uninstall.sh # اسکریپت حذف لینوکس و مک +│ ├── uninstall.ps1 # اسکریپت حذف ویندوز (با پشتیبانی از سوییچ Full) +│ └── uninstall.sh # اسکریپت حذف لینوکس و مک (با پشتیبانی از سوییچ full) ├── install.bat # لانچر اجرای تک‌کلیکی ویندوز ├── install.ps1 # اسکریپت اصلی پاورشل ├── install.sh # اسکریپت اصلی بش ├── LICENSE # مجوز رسمی MIT ├── README.md # مستندات رسمی انگلیسی └── README.fa.md # مستندات رسمی فارسی -
``` --- ## 🔍 کلمات کلیدی و جستجوهای مرتبط -`راست‌چین‌سازی هوش مصنوعی` • `حل مشکل پرانتز در چت و ادیتور` • `فونت وزیرمتن در VS Code` • `قوانین RTL برای Cursor و Windsurf` • `اصلاح متون دوطرفه BiDi` • `آنتی‌گراویتی فارسی` • `اصلاح فونت و چینش Copilot و Claude Code` +`راست‌چین‌سازی هوش مصنوعی` • `حل مشکل پرانتز در چت و ادیتور` • `فونت وزیرمتن در VS Code` • `قوانین RTL برای Cursor و Windsurf` • `اصلاح متون دوطرفه BiDi` • `آنتی‌گراویتی فارسی` • `پشتیبانی ادیتور Zed و Aider` • `اصلاح فونت و چینش Copilot و Claude Code` --- diff --git a/README.md b/README.md index 3ddf874..dc6e950 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@

- Release v2.0.0 + Release v2.1.0 Platforms - Supported Agents + Supported Agents License MIT

@@ -21,7 +21,7 @@ ## ⚡ The Problem -When AI coding assistants (like Google Antigravity, Cursor, Windsurf, Copilot, or Claude Code) generate responses in right-to-left (RTL) languages like **Persian, Arabic, Urdu, or Hebrew**, severe text-rendering bugs occur: +When AI coding assistants (like Google Antigravity, Cursor, Windsurf, Zed, Aider, Copilot, or Claude Code) generate responses in right-to-left (RTL) languages like **Persian, Arabic, Urdu, or Hebrew**, severe text-rendering bugs occur: 1. **Inverted Punctuation & Brackets**: Parentheses `()`, brackets `[]`, and quotation marks get inverted and jump across lines. 2. **Reversed Paths & URLs**: File paths (`/var/log/...` or `C:\Users\...`) and URLs get scrambled backward. @@ -34,7 +34,7 @@ When AI coding assistants (like Google Antigravity, Cursor, Windsurf, Copilot, o ## 💬 1-Prompt In-Chat Activation (No Terminal Needed) -You don't need to open a terminal to enable this. Simply copy and paste this single prompt directly into your AI agent's chat window (in Antigravity, Cursor, Windsurf, Claude Code, or Copilot): +You don't need to open a terminal to enable this. Simply copy and paste this single prompt directly into your AI agent's chat window (in Antigravity, Cursor, Windsurf, Zed, Claude Code, or Copilot): ```text Please read the universal BiDi formatting standard from: @@ -46,7 +46,7 @@ and save it as an always-on rule in this workspace/environment. ## 🚀 Quick Install via Terminal (1-Liner) -Running the installer script automatically installs core Vazirmatn fonts, enables BiDi highlighting in your editor settings, and registers the global machine-wide rule: +Running the installer script automatically installs core Vazirmatn fonts (with instant Windows/Linux cache activation without needing a reboot), enables BiDi highlighting in your editor settings, and registers the global machine-wide rule and skill: ### Windows (PowerShell) ```powershell @@ -58,8 +58,24 @@ irm https://raw.githubusercontent.com/dalroot/agent-rtl-fix/main/install.ps1 | i curl -fsSL https://raw.githubusercontent.com/dalroot/agent-rtl-fix/main/install.sh | bash ``` +### Advanced CLI Flags + +Both installers support optional command-line switches: + +| PowerShell Switch | Bash Flag | Description | +| :--- | :--- | :--- | +| `-GlobalOnly` | `--global-only` | Apply only machine-wide rules, skills, fonts, and IDE settings (skip current project workspace) | +| `-ProjectOnly` | `--project-only` | Add `AGENTS.md` and workspace rules to current folder only (skip system-wide changes) | +| `-NoFonts` | `--no-fonts` | Skip font installation (useful in headless servers, CI/CD, or Docker containers) | +| `-Silent` | `--silent` | Run quietly without banners or non-essential logs | + +*Example:* +```powershell +.\install.ps1 -ProjectOnly +``` + ### Offline / 1-Click -1. Download `agent-rtl-fix-v2.0.0.zip` from the [Latest Release](https://github.com/dalroot/agent-rtl-fix/releases/latest). +1. Download `agent-rtl-fix-v2.1.0.zip` from the [Latest Release](https://github.com/dalroot/agent-rtl-fix/releases/latest). 2. Extract the archive and run `install.bat` (Windows) or `bash install.sh` (Linux/macOS). --- @@ -68,9 +84,11 @@ curl -fsSL https://raw.githubusercontent.com/dalroot/agent-rtl-fix/main/install. | AI Coding Agent | Configuration Location | Rule File in this Repo | Setup Action | | :--- | :--- | :--- | :--- | -| **Google Antigravity** | `~/.gemini/config/rules/` | [`rules/antigravity.md`](rules/antigravity.md) | Installed automatically system-wide (`trigger: always_on`) | +| **Google Antigravity** | `~/.gemini/config/rules/` & `skills/` | [`rules/antigravity.md`](rules/antigravity.md) | Installed automatically system-wide (`trigger: always_on`) | | **Cursor IDE** | `.cursor/rules/` or project root | [`rules/cursor.mdc`](rules/cursor.mdc) | Copy to `.cursor/rules/bidi.mdc` or `.cursorrules` | | **Windsurf (Codeium)** | Project root | [`rules/windsurf.rules`](rules/windsurf.rules) | Copy to `.windsurfrules` | +| **Zed Editor** | `.zed/settings.json` or project root | [`rules/zed.md`](rules/zed.md) | Configure font in Zed settings & place `AGENTS.md` | +| **Aider CLI** | `.aider.conf.yml` or project root | [`rules/aider.md`](rules/aider.md) | Append system prompt to `.aider.conf.yml` or place `AGENTS.md` | | **GitHub Copilot** | `.github/` | [`rules/copilot-instructions.md`](rules/copilot-instructions.md) | Copy to `.github/copilot-instructions.md` | | **Claude Code** | Project root | [`rules/claude.md`](rules/claude.md) | Append to `CLAUDE.md` | | **Cline / Roo Code** | Project root | [`rules/cline.md`](rules/cline.md) | Copy to `.clinerules` | @@ -86,8 +104,9 @@ The standard universal instruction enforced across all agents: - Whenever responding in RTL languages (Persian, Arabic, Urdu, Hebrew): 1. Wrap the complete response inside
...
. 2. Keep standard Markdown syntax for headings, bullet points, and tables. - 3. Keep all code blocks, logs, terminal outputs, and file paths strictly LTR. - 4. Never produce uncontained or left-aligned RTL text. + 3. Keep all code blocks, logs, terminal outputs, file paths, and LaTeX math strictly LTR. + 4. Ensure surrounding punctuation around inline code does not flip. + 5. Never produce uncontained or left-aligned RTL text. ``` --- @@ -98,15 +117,21 @@ The standard universal instruction enforced across all agents: agent-rtl-fix/ ├── .github/ │ └── workflows/ +│ ├── ci.yml # Automated CI test matrix (PS5.1, PS7, Ubuntu, macOS) │ └── release.yml # Automated release and zip packager ├── rules/ # Modular rules for every agent │ ├── antigravity.md # Antigravity always_on global rule │ ├── cursor.mdc # Cursor IDE rule │ ├── windsurf.rules # Windsurf rules +│ ├── zed.md # Zed Editor configuration & rules +│ ├── aider.md # Aider AI coding assistant prompt │ ├── copilot-instructions.md # GitHub Copilot instructions │ ├── claude.md # Claude Code instructions │ ├── cline.md # Cline / Roo Code rules │ └── AGENTS.md # Universal AI Agent specification +├── skills/ # Antigravity AI custom skills +│ └── agent-rtl-fix/ +│ └── SKILL.md # Machine-wide agent skill ├── fonts/ # Core Vazirmatn typography (~500 KB) │ └── Vazirmatn/ │ ├── Vazirmatn-Regular.ttf @@ -114,10 +139,10 @@ agent-rtl-fix/ │ ├── Vazirmatn-SemiBold.ttf │ └── Vazirmatn-Bold.ttf ├── scripts/ -│ ├── install.ps1 # Modular Windows installer -│ ├── install.sh # Modular Linux/macOS installer -│ ├── uninstall.ps1 # Windows cleanup script -│ └── uninstall.sh # Linux/macOS cleanup script +│ ├── install.ps1 # Modular Windows installer with flags & PS5.1 fix +│ ├── install.sh # Modular Linux/macOS installer with flags +│ ├── uninstall.ps1 # Windows cleanup script (-Full support) +│ └── uninstall.sh # Linux/macOS cleanup script (--full support) ├── install.bat # 1-Click Windows launcher ├── install.ps1 # Root PowerShell installer ├── install.sh # Root Bash installer @@ -129,7 +154,7 @@ agent-rtl-fix/ --- ## 🔍 Search Keywords & Indexing Topics -`ai-agent-rtl` • `cursor-rules-rtl` • `antigravity-persian` • `vazirmatn-vscode` • `bidi-markdown` • `copilot-rtl` • `windsurf-rules` • `claude-code-persian` • `persian-arabic-urdu-hebrew` • `inverted-parentheses-fix` • `bidirectional-text-formatting` +`ai-agent-rtl` • `cursor-rules-rtl` • `antigravity-persian` • `vazirmatn-vscode` • `bidi-markdown` • `copilot-rtl` • `windsurf-rules` • `zed-editor-rtl` • `aider-rtl` • `claude-code-persian` • `persian-arabic-urdu-hebrew` • `inverted-parentheses-fix` • `bidirectional-text-formatting` ---