Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

المهارات

المهارات هي قواعد مطابقة الأنماط التي يستخدمها PRECC لاكتشاف الأوامر وتصحيحها. يمكن أن تكون مدمجة (موزعة كملفات TOML) أو مستخرجة من سجلات الجلسات.

المهارات المدمجة

المهارةيُفعَّل عندالإجراء
cargo-wrong-dircargo build/test/clippy خارج مشروع Rustإضافة cd إلى أقرب دليل Cargo.toml
git-wrong-dirgit * خارج مستودع gitإضافة cd إلى أقرب دليل .git
go-wrong-dirgo build/test خارج وحدة Goإضافة cd إلى أقرب دليل go.mod
make-wrong-dirmake بدون Makefile في الدليل الحاليإضافة cd إلى أقرب دليل Makefile
npm-wrong-dirnpm/npx/pnpm/yarn خارج مشروع Nodeإضافة cd إلى أقرب دليل package.json
python-wrong-dirpython/pytest/pip خارج مشروع Pythonإضافة cd إلى أقرب مشروع Python
jj-translategit * في مستودع jj مشتركإعادة الكتابة إلى أمر jj المكافئ
asciinema-gifasciinema recإعادة الكتابة إلى precc gif

قائمة المهارات

$ precc skills list
  # Name               Type      Triggers
  1 cargo-wrong-dir    built-in  cargo build/test/clippy outside Rust project
  2 git-wrong-dir      built-in  git * outside a repo
  3 go-wrong-dir       built-in  go build/test outside Go module
  4 make-wrong-dir     built-in  make without Makefile in cwd
  5 npm-wrong-dir      built-in  npm/npx/pnpm/yarn outside Node project
  6 python-wrong-dir   built-in  python/pytest/pip outside Python project
  7 jj-translate       built-in  git * in jj-colocated repo
  8 asciinema-gif      built-in  asciinema rec
  9 fix-pytest-path    mined     pytest with wrong test path

عرض تفاصيل المهارة

$ precc skills show cargo-wrong-dir
Name:        cargo-wrong-dir
Type:        built-in
Source:      skills/builtin/cargo-wrong-dir.toml
Description: Detects cargo commands run outside a Rust project and prepends
             cd to the directory containing the nearest Cargo.toml.
Trigger:     ^cargo\s+(build|test|clippy|run|check|bench|doc)
Action:      prepend_cd
Marker:      Cargo.toml
Activations: 12

تصدير مهارة إلى TOML

$ precc skills export cargo-wrong-dir
[skill]
name = "cargo-wrong-dir"
description = "Prepend cd for cargo commands outside a Rust project"
trigger = "^cargo\\s+(build|test|clippy|run|check|bench|doc)"
action = "prepend_cd"
marker = "Cargo.toml"
priority = 10

تحرير مهارة

$ precc skills edit cargo-wrong-dir

يفتح هذا تعريف المهارة في $EDITOR الخاص بك. بعد الحفظ، يتم إعادة تحميل المهارة تلقائيًا.

أمر Advise

يقوم precc skills advise بتحليل جلستك الأخيرة ويقترح مهارات جديدة بناءً على الأنماط المتكررة:

$ precc skills advise
Analyzed 47 commands from the last session.

Suggested skills:
  1. docker-wrong-dir: You ran `docker compose up` outside the project root 3 times.
     Suggested trigger: ^docker\s+compose
     Suggested marker: docker-compose.yml

  2. terraform-wrong-dir: You ran `terraform plan` outside the infra directory 2 times.
     Suggested trigger: ^terraform\s+(plan|apply|init)
     Suggested marker: main.tf

Accept suggestion [1/2/skip]?

تجميع المهارات

$ precc skills cluster

يجمع المهارات المستخرجة المتشابهة معًا للمساعدة في تحديد الأنماط المتكررة أو المتداخلة.

المهارات المستخرجة مقابل المدمجة

المهارات المدمجة تأتي مع PRECC ومحددة في skills/builtin/*.toml. تغطي أكثر أخطاء الدليل الخاطئ شيوعًا.

المهارات المستخرجة يتم إنشاؤها بواسطة precc ingest أو خدمة precc-learner من سجلات جلساتك. يتم تخزينها في ~/.local/share/precc/heuristics.db وهي خاصة بسير عملك. انظر التعدين للتفاصيل.