الإعداد

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

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

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

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

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

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

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

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

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

  • read: قراءة الملفات والمجلدات
  • edit: تعديل الملفات (يمكن تقييدها بـ fileRegex)
  • browser: استخدام أتمتة المتصفح
  • command: تنفيذ أوامر الطرفية
  • mcp: الوصول إلى خوادم MCP

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

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

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

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

أنشئ أو عدّل ~/.bob/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
      - command
      - 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
      - command

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

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

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

# Combine with other options
bob --chat-mode=deploy-helper --sandbox

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

في الوضع التفاعلي، بدّل بين الأوضاع باستخدام أوامر slash:

# Switch to a custom mode
/mode shell-debug

# Or use the mode's slug directly
/shell-debug

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

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

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

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 command 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
      - command

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

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

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

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 command or edit groups - read-only mode

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

استخدم إعداد أدوات allowed في Bob Shell مع الأوضاع المخصصة في ملف إعداداتك:

{
  "tools": {
    "allowed": [
      "run_shell_command(git status)",
      "run_shell_command(git log)",
      "run_shell_command(git diff)"
    ]
  }
}

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

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

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

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
      - command

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

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

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

# Combine with output processing
bob --chat-mode=test-runner -p "Run tests" --hide-intermediary-output > results.txt

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

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

أنشئ ملفات تعليمات خاصة بالوضع في .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

تعليمات ملف واحد (بديل)

بدلاً من ذلك، استخدم ملفًا واحدًا .bobrules-{mode-slug} في جذر مساحة عملك.

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

تُطبَّق إعدادات الوضع بهذا الترتيب:

  1. وسيطات سطر الأوامر (--chat-mode=mode-slug)
  2. الأوضاع على مستوى المشروع (.bob/custom_modes.yaml
  3. الأوضاع على مستوى المستخدم (~/.bob/custom_modes.yaml)
  4. الأوضاع على مستوى النظام (مواقع خاصة بالمنصة)
  5. الأوضاع الافتراضية

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

ادمج الأوضاع المخصصة مع ميزة sandbox في Bob Shell للتجريب الآمن:

# Start a custom mode in sandbox
bob --chat-mode=script-dev --sandbox

# Use with Docker sandbox
bob --chat-mode=deploy-helper --sandbox

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

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

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

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

قائمة التكيف

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

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

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

وضع 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
      - command  # Added for git operations
      - browser
ما رأيك في هذا الموضوع؟