Onescript

From SteelMorgan/1c-agent-based-dev-framework · View interactive version

Onescript is an AI agent skill from the GitHub repository SteelMorgan/1c-agent-based-dev-framework. Writes and structures code in OneScript (BSL without 1C). Use when working with .os files, OneScript projects, packagedef, opm, the #Использовать directive, classes, and modules.

How to use this skill

Skill file

OneScript

A skill for writing and structuring code in OneScript, a cross-platform interpreter for 1C:Enterprise 8 without the 1C platform. Code is executed from text .os files, similar to Python or Node.js.

Structure of a Module

A module is a text file with the .os extension. Three sections (top to bottom):

  1. Variable section — Перем ИмяПеременной;
  2. Method section — procedures and functions
  3. Module body section — code executed at startup (must be at the bottom of the file)

Minimal script:

Сообщить("Привет, Мир!");

Procedures and functions:

Процедура МояПроцедура(Параметр1, Параметр2)
    // операторы
КонецПроцедуры

Функция МояФункция(Параметр1, Параметр2)
    Возврат Параметр1 + Параметр2;
КонецФункции

Types and Literals

Typing is dynamic. Primitives: Строка, Число, Булево, Дата; special: Неопределено, Null.

Code Blocks

Condition:

Если Условие Тогда
    // ...
ИначеЕсли ДругоеУсловие Тогда
    // ...
Иначе
    // ...
КонецЕсли;

Loops:

Для Счетчик = 0 По 10 Цикл
    Сообщить(Счетчик);
КонецЦикла;

Для Каждого Элемент Из Массив Цикл
    Сообщить(Элемент);
КонецЦикла;

Пока Условие Цикл
    // ...
КонецЦикла;

Exceptions:

Попытка
    // код
Исключение
    Сообщить(ОписаниеОшибки());
    ВызватьИсключение;  // rethrow
КонецПопытки;

ВызватьИсключение "Текст ошибки";

Project Structure

Recommended directory structure:

The entry point (for example src/main.os) must import its directory:

#Использовать "."

// далее использование классов и модулей
Сообщить(МойМодуль.Метод());

packagedef Manifest

At the project root there is a file without an extension, packagedef. Minimum: name, version, contents.

Описание.Имя("my-package")
    .Версия("1.0.0")
    .ВерсияСреды("2.0.0")
    .ЗависитОт("fs", "1.0.0")
    .ЗависитОт("asserts", "1.3.0")
    .ВключитьФайл("packagedef")
    .ВключитьФайл("src")
    .ВключитьФайл("oscript_modules")
    .ИсполняемыйФайл("src/my-script.os");

Main properties: Имя, Версия, ВерсияСреды, ЗависитОт, ВключитьФайл, ИсполняемыйФайл.

Libraries and #Использовать

Include at the beginning of the module (before variables):

A class from a library is a new type, created through Новый ИмяКласса(). A module is a global object with methods: ИмяМодуля.Метод().

Standard loader: files from the Классы subdirectory are registered as classes, and files from Модули as modules. The file name (without .os) = the class/module identifier.

OPM

Additional

Details of syntax, differences from 1C (Format/DF, constructor call in an expression, parameterized exceptions, rethrow with ИнформацияОбОшибке) — in reference.md.

Documentation: oscript.io/learn.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.