# Extension Quick Start ## Function This page starts with a `calc` compute extension example, demonstrating how to create the extension development directory, build the `.bts` package, install it into the project and call it in `main.bt`. Users with no basic knowledge are recommended to run through the process according to this page first, and then read [Operating Mechanism ](/en/docs/extensions/mechanism). ## Syntax quick start will use these commands: ```text bt ext new calc bt ext build calc -o calc.bts bt ext check calc.bts bt ext info calc.bts bt ext install calc.bts project bt main.bt ``` ## Parameters | Parameter | Description | | ------ | ------ | | `calc` | Extended development directory name, will also be used as the default extension. | | `calc.bts` | Build output expansion pack file. | | `project` | The target BT project directory to install the extension. | | `main.bt` | Project entry script. | ## Prepare the project First prepare a common BT project directory: ```text project/ └── main.bt ``` `main.bt` to call the extension: ```bt result = calc(1).add(2).value() // Output: 3 print result ``` The `calc` extension has not been installed at this time. If you run it directly, you will not find `calc`. The next step is to create the extension. ## Create an extension and execute: ```text bt ext new calc ``` This will generate a pure BT extension development directory: ```text calc/ ├── manifest.json ├── bindings.json └── src/ └── lib.bt ``` The default scaffolding already contains a chained calculation object: `calc(1).add(2).value()`. ## Build the extension package and execute it outside the `calc` directory: When building, ```text bt ext build calc -o calc.bts ``` will read `manifest.json` and `bindings.json`, check the entry source code, and package the development directory into `calc.bts`. After is built, you can check the package information first: ```text bt ext check calc.bts bt ext info calc.bts ``` ## Install into the project Install the extension into the project directory: ```text bt ext install calc.bts project ``` The structure after installation is: ```text project/ ├── main.bt └── extensions/ └── calc.bts ``` Then run the project in the `project` directory: ```text bt main.bt ``` The output should be: ```text 3 ``` ## Return Value `bt ext` When the command is successful, the creation, build, check or installation results will be output in the terminal; when it fails, a Chinese error will be output. `calc(1).add(2).value()` in the example script returns the integer `3`. ## Code Examples extension object can continue to be called in the chain: ```bt num = calc(10) value = num.add(5).add(2).value() closed = num.close() // Output: [17,true] print [value, closed] ``` ## Notes - `bt ext new calc` will generate an extension name based on the directory name. The directory name must use lowercase letters, numbers and underscores, and start with a lowercase letter. - `bt ext install calc.bts project` will copy the package to `project/extensions/calc.bts`; extensions with the same name will be overwritten. - The `.bts` package under `extensions/` will be loaded only when the project is started. The development directory `calc/` will not be automatically loaded by the project. - If the BT build used for running does not enable the `extensions` feature, projects that exist in the `extensions/` directory will report an error indicating that the extension capability is not available.