Reads the original method from the source configuration and generates .bsl-interceptor of a borrowed object: with the correct context directive, full signature, enclosing preprocessor instructions, and regions. For ИзменениеИКонтроль copies the entire body of the original. Creates a module file, appends to an existing one, or updates an already borrowed method.
Precondition
The object must be borrowed into the extension (/cfe-borrow). Access to the sources of the base configuration is required (-ConfigPath) — the original method is read from there. NamePrefix is taken from Configuration.xml of the extension.
Auto-detection of ConfigPath
If the user has not specified -ConfigPath — try to determine automatically:
- Read
.v8-project.jsonfrom the project root - Resolve the target base (by name, branch, or
default— the algorithm from/db-list) - If the base has a field
configSrc— use as-ConfigPath - If
configSrcis absent — ask the user
Parameters
| Parameter | Description | Default |
|---|---|---|
ExtensionPath |
Path to the extension (required) | — |
ConfigPath |
Path to the source configuration | required, except for the case when ModulePath — path to the file |
ModulePath |
Logical name (Тип.Имя.Модуль) or path to the module file .bsl |
required for generation |
MethodName |
Name of the method being intercepted | required for generation |
InterceptorType |
Before / After / Instead / ModificationAndControl |
required for generation |
Check |
Check controlled methods for drift (report only) | — |
Actualize |
Update drifted controlled methods | — |
ModulePath format
| ModulePath | File |
|---|---|
Catalog.X.ObjectModule |
Catalogs/X/Ext/ObjectModule.bsl |
Catalog.X.ManagerModule |
Catalogs/X/Ext/ManagerModule.bsl |
Catalog.X.Form.Y |
Catalogs/X/Forms/Y/Ext/Form/Module.bsl |
CommonModule.X |
CommonModules/X/Ext/Module.bsl |
CommonForm.X |
CommonForms/X/Ext/Form/Module.bsl |
Document.X.ObjectModule |
Documents/X/Ext/ObjectModule.bsl |
Document.X.Form.Y |
Documents/X/Forms/Y/Ext/Form/Module.bsl |
Similarly for Report, DataProcessor, InformationRegister, and other types.
Instead of the logical name in ModulePath you can pass file path source module .bsl — then -ConfigPath does not need to be specified (the original is read directly from this file). The extension module path is determined automatically from the standard folder in the path.
Interception types
| InterceptorType | Decorator | Purpose | Applicable to |
|---|---|---|---|
Before |
&Перед |
Code before calling the original method | procedures |
After |
&После |
Code after calling the original method | procedures |
Instead |
&Вместо |
Method replacement; in the body — scaffold ПродолжитьВызов(...) |
procedures and functions |
ModificationAndControl |
&ИзменениеИКонтроль |
Copy of the original body for editing with markers #Вставка/#Удаление |
procedures and functions |
Markers #Вставка / #Удаление (for ModificationAndControl)
&ИзменениеИКонтроль inserts into the interceptor a copy of the original body. Then edit the body for your modification, marking each change — this is how the platform distinguishes your edit from the unchanged original:
- You add code → wrap it
#Вставка…#КонецВставки. - You delete original code → wrap the lines being deleted
#Удаление…#КонецУдаления, but leave the lines themselves between the markers (the platform compares them with the original). - You replace →
#Удалениеthe old#КонецУдаленияimmediately after it#Вставкаthe new#КонецВставки.
Example:
&ИзменениеИКонтроль("ПриЗаписи")
Процедура Расш_ПриЗаписи(Отказ)
СуммаДокумента = РассчитатьСумму();
#Вставка
// доработка: округляем
СуммаДокумента = Окр(СуммаДокумента, 2);
#КонецВставки
#Удаление
Записать();
#КонецУдаления
#Вставка
ЗаписатьСПроверкой(Отказ);
#КонецВставки
КонецПроцедуры
Rules:
- Markers — on a separate line from column 0 (without indentation), even inside indentation and query text (
|…). - Unmarked lines must match the original verbatim — this is the "control". Verbatim — including comments, case, and spaces within the line (
Х = Х + 1≠Х=Х+1); only indentation and empty lines are free. If the original in the source configuration changes, the unmarked context will diverge → the method will require updating (see below; check in bulk —-Check). - You change only your own
#Вставка/#Удаление; do not touch someone else's original.
Updating
After changing the original in the source configuration, the interceptor &ИзменениеИКонтроль may become out of sync — the unmarked context will diverge from the new original. The platform stays silent about this on load, so update it yourself:
- Check —
-Check: report on all controlled extension methods, writes nothing (exit 1, if there is drift or a conflict). - Update —
-Actualize: transfers the edits (#Вставка/#Удаление) to the new original across the entire extension. Narrow the scope:-ModulePath— one module,+ -MethodName— one method. For a single method, the same is done by calling again with-InterceptorType ModificationAndControl.
Statuses in the output:
[АКТУАЛЕН]— the original has not changed, there are no edits;[АКТУАЛИЗИРОВАН]— the body has been updated to the new original, the edits are preserved (the output contains a summary);[АКТУАЛИЗИРОВАН-ЧАСТИЧНО]— some edits could not be placed (the anchor changed in the new original). They are marked// [РЕСИНК-КОНФЛИКТ]in the module and are not lost; the path to the merge workspace is in the output (start withindex.md, then for each conflict itsconflict.md, place the blocks manually in.bslof the extension);[ПЕРЕНЕСЕНО В ОСНОВНУЮ]— the edit is already present in the new original (the inserted code was added by the vendor) or the block being deleted has already been cut out. The edit is no longer relevant — it is removed from the body, there is no need to duplicate/conflict. If this is the case for all edits of the method — the interceptor can be deleted.-Checkdoes not dropexit.
Calling again Before/After/Instead for an already intercepted method does not create a duplicate ([ПРОПУЩЕН]).
-Check looks at the sources. The platform's verdict comes only after loading into the database: /db-cfe-admin check.
Command
powershell.exe -NoProfile -File "${CLAUDE_SKILL_DIR}/scripts/cfe-patch-method.ps1" -ExtensionPath src\cfe\extname -ConfigPath src\cf -ModulePath "Catalog.Контрагенты.ObjectModule" -MethodName "ПриЗаписи" -InterceptorType Before
Examples
# Код перед записью
... -ExtensionPath src\cfe\extname -ConfigPath src\cf -ModulePath "Catalog.Контрагенты.ObjectModule" -MethodName "ПриЗаписи" -InterceptorType Before
# Перехват После на форме
... -ExtensionPath src\cfe\extname -ConfigPath src\cf -ModulePath "Document.Заказ.Form.ФормаДокумента" -MethodName "ПослеЗаписиНаСервере" -InterceptorType After
# Замена функции (ПродолжитьВызов)
... -ExtensionPath src\cfe\extname -ConfigPath src\cf -ModulePath "CommonModule.ОбщийМодуль" -MethodName "ПолучитьДанные" -InterceptorType Instead
# ИзменениеИКонтроль — копия тела для правки маркерами
... -ExtensionPath src\cfe\extname -ConfigPath src\cf -ModulePath "Document.РеализацияТоваров.ObjectModule" -MethodName "ОбработкаПроведения" -InterceptorType ModificationAndControl
# ModulePath как путь к файлу модуля-источника (без -ConfigPath)
... -ExtensionPath src\cfe\extname -ModulePath "src\cf\CommonModules\ОбщийМодуль\Ext\Module.bsl" -MethodName "ПолучитьДанные" -InterceptorType Instead
# Проверить все контролируемые методы расширения на дрейф
... -ExtensionPath src\cfe\extname -ConfigPath src\cf -Check
# Актуализировать дрейфнувшие контролируемые методы пачкой
... -ExtensionPath src\cfe\extname -ConfigPath src\cf -Actualize
Verification
/cfe-validate <ExtensionPath> -ConfigPath <ConfigPath>