الإعداد

الأوضاع المخصصة

يمكنك إنشاء أوضاع مخصصة لتخصيص سلوك Bob لمهام أو سير عمل محددة. تعمل الأوضاع المخصصة في Bob Shell بشكل مشابه لأوضاع Bob IDE.

لماذا تستخدم الأوضاع المخصصة في Bob Shell

  • سير عمل مُحسَّن للشل: أنشئ أوضاعًا مصممة خصيصًا لمهام التطوير المعتمدة على الطرفية
  • أمان سطر الأوامر: قيّد الأوضاع بعمليات آمنة عند العمل في بيئات الإنتاج
  • سلوك خاص بالبيئة: اضبط أوضاعًا تتكيف مع بيئات شل مختلفة
  • صديق للأتمتة: صمّم أوضاعًا تعمل بسلاسة في الجلسات التفاعلية وغير التفاعلية
  • توحيد الفريق: شارك أوضاعًا خاصة بالشل عبر فريقك لسير عمل متسق

ما يتضمنه الوضع المخصص

تستخدم الأوضاع المخصصة في Bob Shell نفس البنية الأساسية لأوضاع Bob IDE:

الخاصيةالوصفاعتبارات خاصة بالشل
slugمعرف داخلي فريديُستخدم في وسيطات سطر الأوامر:
bob --mode my-mode
nameالاسم المعروض في واجهة المستخدميظهر في محدد الوضع بالوضع التفاعلي
descriptionوصف قصير يظهر في محدد الوضعاشرح غرض وضعك بإيجاز
roleDefinitionالهوية الأساسية والخبرةيجب مراعاة سياق الشل وسير عمل سطر الأوامر
groupsمجموعات الأدوات المسموحة والوصول للملفاتأذونات تشغيل الأوامر حاسمة في بيئات الشل
whenToUseإرشادات اختيار الوضعتساعد Bob Shell في اختيار الأوضاع المناسبة للمهام
customInstructionsإرشادات سلوكية محددة أو قواعد للوضعيمكن الإشارة إلى أنماط تطوير Bob Shell

الأدوات المتاحة

مجموعات الأدوات المتاحة

  • read: قراءة الملفات والمجلدات
  • edit: تعديل الملفات (يمكن تقييدها بـ fileRegex)
  • execute: تنفيذ أوامر الطرفية (يُقبَل command كاسم بديل قديم)
  • browser: جلب صفحات الويب العامة (تجريبي؛ يتطلب experiments.webFetch)
  • mcp: الوصول إلى خوادم MCP
  • skill: تفعيل المهارات
  • todo: تحديث قائمة المهام
  • subagent: إنشاء subagents
  • mode: تبديل الأوضاع

إنشاء الأوضاع المخصصة

ملفات الإعداد

يستخدم Bob Shell نفس تنسيق الإعداد كـ Bob IDE، مع دعم تنسيقَي YAML (المفضل) وJSON.

الأوضاع العامة

أنشئ أو عدّل ~/.bob/settings/custom_modes.yaml للأوضاع المتاحة عبر جميع المشاريع:

customModes:
  - slug: shell-debug
    name: 🐛 Shell Debugger
    roleDefinition: >-
      You are a debugging specialist focused on command-line troubleshooting.
      You excel at analyzing shell output, environment variables, and system logs.
    whenToUse: Use for debugging shell scripts, command failures, and environment issues.
    customInstructions: |-
      When debugging:
      - Always check environment variables first
      - Examine command exit codes
      - Review relevant log files
      - Test commands in isolation before suggesting fixes
    groups:
      - read
      - execute
      - browser

الأوضاع الخاصة بالمشروع

أنشئ أو عدّل .bob/custom_modes.yaml في جذر مشروعك:

customModes:
  - slug: deploy-helper
    name: 🚀 Deployment Assistant
    roleDefinition: You are a deployment specialist for this project's infrastructure.
    whenToUse: Use for deployment tasks, infrastructure changes, and release management.
    customInstructions: |-
      Deployment guidelines:
      - Always verify the target environment before running commands
      - Check for running processes that might be affected
      - Validate configuration files before applying changes
      - Create backups before destructive operations
    groups:
      - read
      - - edit
        - fileRegex: \.(yaml|yml|sh|env)$
          description: Configuration and script files only
      - execute

اختيار الوضع من سطر الأوامر

حدد وضعًا عند بدء Bob Shell:

# Start Bob Shell in a specific mode
bob --mode shell-debug

# Combine with other options
bob --mode deploy-helper --max-turns 20

التبديل التفاعلي بين الأوضاع

في الوضع التفاعلي، اكتب /mode لفتح محدد الوضع، ثم اختر وضعك المخصص. تظهر الأوضاع المخصصة في المحدد إلى جانب الأوضاع المدمجة Agent وPlan وAsk.

الإعدادات الخاصة بالشل

وضع أمان الإنتاج

أنشئ وضعًا مُركَّزًا على الأمان لبيئات الإنتاج:

customModes:
  - slug: prod-ops
    name: 🔒 Production Operations
    roleDefinition: >-
      You are a production operations specialist with a strong focus on safety.
      You never run destructive commands without explicit confirmation.
    whenToUse: Use when working with production systems or sensitive environments.
    customInstructions: |-
      Production safety rules:
      - NEVER run destructive commands without explicit user confirmation
      - Always verify the target environment before any operation
      - Suggest dry-run options when available
      - Check for active connections or processes before changes
      - Recommend backup procedures before modifications
    groups:
      - read
      - browser
      # Note: No edit or execute groups for maximum safety

وضع تطوير السكريبتات

أنشئ وضعًا لتطوير سكريبتات الشل:

customModes:
  - slug: script-dev
    name: 📜 Script Developer
    roleDefinition: >-
      You are a shell scripting expert specializing in bash, zsh, and POSIX-compliant scripts.
    whenToUse: Use for creating, debugging, or improving shell scripts.
    customInstructions: |-
      Shell scripting best practices:
      - Use shellcheck-compliant syntax
      - Include proper error handling with set -e and set -u
      - Add usage documentation at the top of scripts
      - Quote variables to prevent word splitting
      - Provide exit codes for different error conditions
    groups:
      - read
      - - edit
        - fileRegex: \.(sh|bash|zsh)$
          description: Shell script files only
      - execute

أذونات تشغيل الأوامر

تقييد الوصول للأوامر

تحكم في ما إذا كان بإمكان وضع ما تشغيل الأوامر بحذف مجموعة execute:

customModes:
  - slug: safe-reviewer
    name: 👀 Safe Code Reviewer
    roleDefinition: You are a code reviewer focused on analysis, not modification.
    whenToUse: Use for code reviews and analysis without making changes.
    groups:
      - read
      - browser
      # No execute or edit groups - read-only mode

السماح بأوامر محددة

للموافقة التلقائية على أوامر محددة، أضف "execute" إلى approval.allowed_permissions واسرد الأوامر في approval.allowedExecutors لأداة execute_command في ~/.bob/settings/settings.json:

{
  "approval": {
    "allowed_permissions": ["read", "execute"],
    "allowedExecutors": [
      {
        "toolId": "execute_command",
        "approvedCommands": ["git status", "git log", "git diff"],
        "deniedCommands": []
      }
    ]
  }
}

يؤدي تعيين allowedExecutors إلى استبدال القائمة الافتراضية للأوامر المعتمدة، لذا أدرج أي أوامر افتراضية تريد الاحتفاظ بها. لمزيد من التفاصيل، راجع إعدادات الموافقة.

السلوك التفاعلي وغير التفاعلي

التصميم للوضعين معًا

أنشئ أوضاعًا تعمل بشكل جيد في الجلسات التفاعلية وغير التفاعلية:

customModes:
  - slug: test-runner
    name: 🧪 Test Runner
    roleDefinition: >-
      You are a testing specialist who runs and analyzes test suites.
      You adapt your output based on the running context.
    whenToUse: Use for running tests, analyzing test results, and debugging test failures.
    customInstructions: |-
      Testing guidelines:
      - In interactive mode: Provide detailed explanations and suggestions
      - In non-interactive mode: Focus on concise, actionable output
      - Always report test results clearly
      - Suggest fixes for failing tests
    groups:
      - read
      - execute

الاستخدام غير التفاعلي

استخدم الأوضاع في الوضع غير التفاعلي:

# Use a mode designed for automation
bob run --mode test-runner "Run the test suite and report failures"

# Combine with output processing
bob run --mode test-runner --format json "Run tests" > results.json

تعليمات خاصة بالوضع عبر الملفات

التعليمات القائمة على المجلدات

أنشئ ملفات تعليمات خاصة بالوضع في .bob/rules-{mode-slug}/:

01-environment-checks.md
02-common-issues.md
03-debugging-steps.md
custom_modes.yaml

مثال على ملف التعليمات (.bob/rules-shell-debug/01-environment-checks.md):

# Environment Debugging Checklist

When debugging shell issues, always check:

1. **Environment Variables**: PATH, SHELL, TERM, and application-specific variables
2. **Shell Configuration**: .bashrc, .zshrc, .profile files
3. **System State**: Current working directory, file permissions, disk space
4. **Command Availability**: Use `command -v <cmd>` to verify commands exist

أولوية الإعداد

إذا تشارك وضعان نفس الـ slug، يستخدم Bob Shell أول وضع يجده، بهذا الترتيب:

  1. الأوضاع المدمجة (agent وplan وask)
  2. الأوضاع على مستوى المستخدم (~/.bob/settings/custom_modes.yaml)
  3. الأوضاع على مستوى المشروع (.bob/custom_modes.yaml)

استخدم slug فريدًا لكل وضع مخصص. علامة --mode تحدد فقط الوضع الذي تبدأ به.

ترحيل الأوضاع من Bob IDE

الاختلافات الرئيسية

عند ترحيل الأوضاع المخصصة من Bob IDE إلى Bob Shell:

الجانبBob IDEBob Shell
تفاعل واجهة المستخدمواجهة مرئية بلوحاتواجهة قائمة على الطرفية
تحرير الملفاتفروق وعروض معاينة في المحررعرض فروق CLI أو محرر خارجي
تشغيل الأوامرطرفية متكاملةتشغيل مباشر في الشل
تبديل الوضعالقائمة المنسدلة لمحدد الوضعمحدد /mode أو علامة CLI --mode
الإعدادواجهة إعدادات + ملفاتملفات إعداد فقط

قائمة التكيف

عند تكييف أوضاع Bob IDE لـ Bob Shell:

  • راجع roleDefinition للسياق الخاص بالشل
  • حدّث customInstructions للإشارة إلى سير عمل سطر الأوامر
  • ضع في الاعتبار أمان تشغيل الأوامر في إعداد groups
  • اختبر الوضع في كل من الجلسات التفاعلية وغير التفاعلية
  • تحقق من أن معالجة مسارات الملفات تعمل في سياق الشل

مثال على الترحيل

وضع Bob IDE الأصلي:

customModes:
  - slug: code-reviewer
    name: 👀 Code Reviewer
    roleDefinition: You are a code reviewer who provides detailed feedback.
    groups:
      - read
      - browser

مُكيَّف لـ Bob Shell:

customModes:
  - slug: code-reviewer
    name: 👀 Code Reviewer
    roleDefinition: >-
      You are a code reviewer who provides detailed feedback.
      You work efficiently in terminal environments and provide clear, actionable suggestions.
    whenToUse: Use for code reviews, pull request analysis, and code quality checks.
    customInstructions: |-
      Code review guidelines:
      - Provide feedback in a structured format suitable for terminal output
      - Reference specific line numbers and file paths
      - Suggest concrete improvements with examples
      - Format output for easy parsing if used in non-interactive mode
    groups:
      - read
      - execute  # Added for git operations
      - browser
ما رأيك في هذا الموضوع؟