CLI tool for Blocks, a platform for writing custom AI-enabled codebase automations in Python. Leverage a full codebase-aware API. Automatically trigger automations from Github, Slack, and other providers.
Project description
Blocks CLI
A CLI tool for Blocks, a platform for writing custom AI-enabled codebase automations in Python. Leverage a full codebase-aware API. Automatically trigger automations from GitHub, Slack, and other providers.
Status: Private alpha. Please keep your SDK updated to get the latest fixes and features.
Prerequisites
- Python >= 3.9
pipavailable in your environment
Installation
Blocks CLI is packaged with the Python SDK.
pip install blocks-sdk
Verify installation:
blocks --help
Quick Start
- Initialize in your repository (creates a
.blocksdirectory and optionally saves your API key):
# Option A: Provide key now
blocks init --key <your-api-key>
# Option B: Initialize, then configure later
blocks init
blocks configure --key <your-api-key>
- Create a new automation scaffold:
blocks create my_automation
This generates .blocks/my_automation/ with a starter main.py and requirements.txt.
- Edit the generated automation to set an event and repository:
# .blocks/my_automation/main.py
from blocks import task, on
@task(name="my_automation")
@on("github.pull_request", repos=["MyOrg/MyRepo"])
def my_automation(event):
print(event)
- Test the automation locally with a sample event:
blocks test .blocks/my_automation/main.py
# If your file defines multiple automations, specify one by name:
# blocks test .blocks/my_automation/main.py --name my_automation
- Push the automation to Blocks:
blocks push .blocks/my_automation/main.py
Command Reference
blocks init [--key <api-key>]: Initializes Blocks in the current repo by creating a.blocksdirectory. When--keyis provided, verifies and saves your API key.blocks configure --key <api-key>: Verifies and saves/updates your API key.blocks create <name>: Creates a new automation under.blocks/<name>/with a starter template andrequirements.txt.blocks test <file> [--name <automation>]: Loads the automation from<file>, fetches a sample event for the configured trigger, and invokes it locally.blocks push <file>: Packages dependencies and source, uploads the bundle, registers the automation, and triggers a build.
Naming Rules
- Automation names must start with a letter and can include letters, numbers, dashes, and underscores.
- Example valid names:
my_automation,code-reviewer,build_123.
Troubleshooting
- Already initialized: If
.blocksexists,blocks initwill report it. Useblocks configure --key <api-key>to update your key. - Invalid API key: Ensure your key is correct. You can manage keys at https://app.blocksorg.com
- Missing event: The
@on("...")decorator must specify a supported event. See events at https://docs.blocksorg.com/docs/events - Multiple automations in a file: Use
--name <automation>withblocks testto choose one.
Upgrading
pip install -U blocks-sdk
License
AGPL-3.0. See LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file blocks-cli-0.1.41.tar.gz.
File metadata
- Download URL: blocks-cli-0.1.41.tar.gz
- Upload date:
- Size: 26.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dce492fa5fc1be37131310ea4ff56d8aa411ed8f787a71bc0a8b7c0b359a7ed4
|
|
| MD5 |
d4f9e3bfa37d36d892768bc92a2126d3
|
|
| BLAKE2b-256 |
33f3fa4b7e787ec7fc3231049d6a6e0143df0e4485400b59e92622d84634a838
|