blocks-cli 0.1.34__tar.gz → 0.1.36__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. blocks-cli-0.1.36/PKG-INFO +131 -0
  2. blocks-cli-0.1.36/README.md +101 -0
  3. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/blocks_cli/commands/push.py +34 -1
  4. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/blocks_cli/config/auth.py +1 -0
  5. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/setup.py +1 -1
  6. blocks-cli-0.1.34/PKG-INFO +0 -69
  7. blocks-cli-0.1.34/README.md +0 -39
  8. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/LICENSE +0 -0
  9. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/MANIFEST.in +0 -0
  10. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/blocks_cli/__init__.py +0 -0
  11. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/blocks_cli/api.py +0 -0
  12. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/blocks_cli/builds.py +0 -0
  13. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/blocks_cli/bundles.py +0 -0
  14. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/blocks_cli/commands/__base__.py +0 -0
  15. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/blocks_cli/commands/__init__.py +0 -0
  16. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/blocks_cli/commands/configure.py +0 -0
  17. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/blocks_cli/commands/create.py +0 -0
  18. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/blocks_cli/commands/init.py +0 -0
  19. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/blocks_cli/commands/test.py +0 -0
  20. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/blocks_cli/config/__init__.py +0 -0
  21. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/blocks_cli/config/config.py +0 -0
  22. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/blocks_cli/console.py +0 -0
  23. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/blocks_cli/fs.py +0 -0
  24. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/blocks_cli/package.py +0 -0
  25. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/blocks_cli/registration.py +0 -0
  26. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/blocks_cli.egg-info/SOURCES.txt +0 -0
  27. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/requirements.txt +0 -0
  28. {blocks-cli-0.1.34 → blocks-cli-0.1.36}/setup.cfg +0 -0
@@ -0,0 +1,131 @@
1
+ Metadata-Version: 2.1
2
+ Name: blocks-cli
3
+ Version: 0.1.36
4
+ Summary: 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.
5
+ Home-page: https://github.com/BlocksOrg/sdk
6
+ Author: BlocksOrg
7
+ Author-email: dev@blocksorg.com
8
+ License: AGPL
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: GNU Affero General Public License v3
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.8
15
+ Classifier: Programming Language :: Python :: 3.9
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Topic :: Software Development :: Libraries
20
+ Classifier: Topic :: Software Development :: Build Tools
21
+ Classifier: Topic :: Software Development :: Bug Tracking
22
+ Classifier: Topic :: Software Development :: Debuggers
23
+ Classifier: Topic :: Software Development :: Code Generators
24
+ Classifier: Topic :: Software Development :: Version Control :: Git
25
+ Classifier: Topic :: Communications :: Chat
26
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
27
+ Requires-Python: >=3.9
28
+ Description-Content-Type: text/markdown
29
+ License-File: LICENSE
30
+
31
+ # Blocks CLI
32
+
33
+ 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.
34
+
35
+ Status: Private alpha. Please keep your SDK updated to get the latest fixes and features.
36
+
37
+ ## Prerequisites
38
+
39
+ - Python >= 3.9
40
+ - `pip` available in your environment
41
+
42
+ ## Installation
43
+
44
+ Blocks CLI is packaged with the Python SDK.
45
+
46
+ ```bash
47
+ pip install blocks-sdk
48
+ ```
49
+
50
+ Verify installation:
51
+
52
+ ```bash
53
+ blocks --help
54
+ ```
55
+
56
+ ## Quick Start
57
+
58
+ 1) Initialize in your repository (creates a `.blocks` directory and optionally saves your API key):
59
+
60
+ ```bash
61
+ # Option A: Provide key now
62
+ blocks init --key <your-api-key>
63
+
64
+ # Option B: Initialize, then configure later
65
+ blocks init
66
+ blocks configure --key <your-api-key>
67
+ ```
68
+
69
+ 2) Create a new automation scaffold:
70
+
71
+ ```bash
72
+ blocks create my_automation
73
+ ```
74
+
75
+ This generates `.blocks/my_automation/` with a starter `main.py` and `requirements.txt`.
76
+
77
+ 3) Edit the generated automation to set an event and repository:
78
+
79
+ ```python
80
+ # .blocks/my_automation/main.py
81
+ from blocks import task, on
82
+
83
+ @task(name="my_automation")
84
+ @on("github.pull_request", repos=["MyOrg/MyRepo"])
85
+ def my_automation(event):
86
+ print(event)
87
+ ```
88
+
89
+ 4) Test the automation locally with a sample event:
90
+
91
+ ```bash
92
+ blocks test .blocks/my_automation/main.py
93
+ # If your file defines multiple automations, specify one by name:
94
+ # blocks test .blocks/my_automation/main.py --name my_automation
95
+ ```
96
+
97
+ 5) Push the automation to Blocks:
98
+
99
+ ```bash
100
+ blocks push .blocks/my_automation/main.py
101
+ ```
102
+
103
+ ## Command Reference
104
+
105
+ - `blocks init [--key <api-key>]`: Initializes Blocks in the current repo by creating a `.blocks` directory. When `--key` is provided, verifies and saves your API key.
106
+ - `blocks configure --key <api-key>`: Verifies and saves/updates your API key.
107
+ - `blocks create <name>`: Creates a new automation under `.blocks/<name>/` with a starter template and `requirements.txt`.
108
+ - `blocks test <file> [--name <automation>]`: Loads the automation from `<file>`, fetches a sample event for the configured trigger, and invokes it locally.
109
+ - `blocks push <file>`: Packages dependencies and source, uploads the bundle, registers the automation, and triggers a build.
110
+
111
+ ## Naming Rules
112
+
113
+ - Automation names must start with a letter and can include letters, numbers, dashes, and underscores.
114
+ - Example valid names: `my_automation`, `code-reviewer`, `build_123`.
115
+
116
+ ## Troubleshooting
117
+
118
+ - Already initialized: If `.blocks` exists, `blocks init` will report it. Use `blocks configure --key <api-key>` to update your key.
119
+ - Invalid API key: Ensure your key is correct. You can manage keys at https://app.blocksorg.com
120
+ - Missing event: The `@on("...")` decorator must specify a supported event. See events at https://docs.blocksorg.com/docs/events
121
+ - Multiple automations in a file: Use `--name <automation>` with `blocks test` to choose one.
122
+
123
+ ## Upgrading
124
+
125
+ ```bash
126
+ pip install -U blocks-sdk
127
+ ```
128
+
129
+ ## License
130
+
131
+ AGPL-3.0. See `LICENSE` for details.
@@ -0,0 +1,101 @@
1
+ # Blocks CLI
2
+
3
+ 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.
4
+
5
+ Status: Private alpha. Please keep your SDK updated to get the latest fixes and features.
6
+
7
+ ## Prerequisites
8
+
9
+ - Python >= 3.9
10
+ - `pip` available in your environment
11
+
12
+ ## Installation
13
+
14
+ Blocks CLI is packaged with the Python SDK.
15
+
16
+ ```bash
17
+ pip install blocks-sdk
18
+ ```
19
+
20
+ Verify installation:
21
+
22
+ ```bash
23
+ blocks --help
24
+ ```
25
+
26
+ ## Quick Start
27
+
28
+ 1) Initialize in your repository (creates a `.blocks` directory and optionally saves your API key):
29
+
30
+ ```bash
31
+ # Option A: Provide key now
32
+ blocks init --key <your-api-key>
33
+
34
+ # Option B: Initialize, then configure later
35
+ blocks init
36
+ blocks configure --key <your-api-key>
37
+ ```
38
+
39
+ 2) Create a new automation scaffold:
40
+
41
+ ```bash
42
+ blocks create my_automation
43
+ ```
44
+
45
+ This generates `.blocks/my_automation/` with a starter `main.py` and `requirements.txt`.
46
+
47
+ 3) Edit the generated automation to set an event and repository:
48
+
49
+ ```python
50
+ # .blocks/my_automation/main.py
51
+ from blocks import task, on
52
+
53
+ @task(name="my_automation")
54
+ @on("github.pull_request", repos=["MyOrg/MyRepo"])
55
+ def my_automation(event):
56
+ print(event)
57
+ ```
58
+
59
+ 4) Test the automation locally with a sample event:
60
+
61
+ ```bash
62
+ blocks test .blocks/my_automation/main.py
63
+ # If your file defines multiple automations, specify one by name:
64
+ # blocks test .blocks/my_automation/main.py --name my_automation
65
+ ```
66
+
67
+ 5) Push the automation to Blocks:
68
+
69
+ ```bash
70
+ blocks push .blocks/my_automation/main.py
71
+ ```
72
+
73
+ ## Command Reference
74
+
75
+ - `blocks init [--key <api-key>]`: Initializes Blocks in the current repo by creating a `.blocks` directory. When `--key` is provided, verifies and saves your API key.
76
+ - `blocks configure --key <api-key>`: Verifies and saves/updates your API key.
77
+ - `blocks create <name>`: Creates a new automation under `.blocks/<name>/` with a starter template and `requirements.txt`.
78
+ - `blocks test <file> [--name <automation>]`: Loads the automation from `<file>`, fetches a sample event for the configured trigger, and invokes it locally.
79
+ - `blocks push <file>`: Packages dependencies and source, uploads the bundle, registers the automation, and triggers a build.
80
+
81
+ ## Naming Rules
82
+
83
+ - Automation names must start with a letter and can include letters, numbers, dashes, and underscores.
84
+ - Example valid names: `my_automation`, `code-reviewer`, `build_123`.
85
+
86
+ ## Troubleshooting
87
+
88
+ - Already initialized: If `.blocks` exists, `blocks init` will report it. Use `blocks configure --key <api-key>` to update your key.
89
+ - Invalid API key: Ensure your key is correct. You can manage keys at https://app.blocksorg.com
90
+ - Missing event: The `@on("...")` decorator must specify a supported event. See events at https://docs.blocksorg.com/docs/events
91
+ - Multiple automations in a file: Use `--name <automation>` with `blocks test` to choose one.
92
+
93
+ ## Upgrading
94
+
95
+ ```bash
96
+ pip install -U blocks-sdk
97
+ ```
98
+
99
+ ## License
100
+
101
+ AGPL-3.0. See `LICENSE` for details.
@@ -17,10 +17,31 @@ from blocks_cli.registration import get_blocks_state_and_module_from_file
17
17
  from blocks_cli.package import warn_current_package_version
18
18
 
19
19
  @blocks_cli.command()
20
- def push(file: Path = typer.Argument(..., help="Name of blocks file to push.")):
20
+ def push(
21
+ file: Path = typer.Argument(..., help="Name of blocks file to push."),
22
+ bump: Optional[str] = typer.Option(
23
+ None,
24
+ "--bump",
25
+ flag_value="patch",
26
+ help="Bump version for public automations. Options: major, minor, patch. Defaults to patch if no value provided.",
27
+ ),
28
+ force_build: bool = typer.Option(False, "--force-build", help="Force a new build even if a successful build already exists")
29
+ ):
21
30
  try:
22
31
  warn_current_package_version()
23
32
 
33
+ bump_type = None
34
+ if bump is not None:
35
+ bump_val = bump.lower()
36
+ if bump_val not in ("major", "minor", "patch"):
37
+ raise Exception(
38
+ f"Invalid bump type '{bump}'. Valid options are: major, minor, patch"
39
+ )
40
+ bump_type = bump_val
41
+ console.print(
42
+ f"[yellow]Version bump requested: {bump_type} (applies to public automations only)[/yellow]"
43
+ )
44
+
24
45
  # Create automation
25
46
  with Progress(
26
47
  SpinnerColumn(),
@@ -105,7 +126,10 @@ def push(file: Path = typer.Argument(..., help="Name of blocks file to push.")):
105
126
  "pip_dependencies": pip_dependencies,
106
127
  "bundle_id": bundle_id,
107
128
  "automations": [],
129
+ "force_build": force_build,
108
130
  }
131
+ if bump_type is not None:
132
+ registration_payload["bump_type"] = bump_type
109
133
 
110
134
  for automation in state.automations:
111
135
  trigger_kwargs = automation.get("trigger_kwargs", {})
@@ -130,12 +154,21 @@ def push(file: Path = typer.Argument(..., help="Name of blocks file to push.")):
130
154
 
131
155
  function_name = automation.get("function_name")
132
156
  function_source_code = automation.get("function_source_code")
157
+ function_hash = automation.get("function_hash")
158
+ function_arg_count = automation.get("function_arg_count")
159
+ function_kwarg_count = automation.get("function_kwarg_count")
160
+ function_kwargs_info = automation.get("function_kwargs_info")
133
161
  config_schema = automation.get("config_class").model_json_schema() if automation.get("config_class") else None
134
162
  trigger_alias = automation.get("trigger_alias")
135
163
 
136
164
  # Extract known fields
137
165
  automation_config = {
138
166
  "name": automation_name,
167
+ "function_hash": function_hash,
168
+ "function_source_code": function_source_code,
169
+ "function_arg_count": function_arg_count,
170
+ "function_kwarg_count": function_kwarg_count,
171
+ "function_kwargs_info": function_kwargs_info,
139
172
  "import_path": f"{file.name}:{function_name}",
140
173
  "runner": runner,
141
174
  "runtime": runtime,
@@ -10,6 +10,7 @@ class AuthConfig(BaseModel):
10
10
  wid: Optional[str] = ""
11
11
  # Corresponds to env variable BLOCKS_AUTH__API_KEY
12
12
  api_key: Optional[str] = ""
13
+ job_session_token: Optional[str] = ""
13
14
 
14
15
  def save_api_key(self, api_key: str) -> None:
15
16
  """Save the API key to the config file."""
@@ -6,7 +6,7 @@ with open("requirements.txt") as f:
6
6
 
7
7
  setup(
8
8
  name="blocks-cli",
9
- version="0.1.34",
9
+ version="0.1.36",
10
10
  packages=find_packages(),
11
11
  include_package_data=True,
12
12
  install_requires=requirements,
@@ -1,69 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: blocks-cli
3
- Version: 0.1.34
4
- Summary: 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.
5
- Home-page: https://github.com/BlocksOrg/sdk
6
- Author: BlocksOrg
7
- Author-email: dev@blocksorg.com
8
- License: AGPL
9
- Classifier: Development Status :: 3 - Alpha
10
- Classifier: Intended Audience :: Developers
11
- Classifier: License :: OSI Approved :: GNU Affero General Public License v3
12
- Classifier: Programming Language :: Python
13
- Classifier: Programming Language :: Python :: 3
14
- Classifier: Programming Language :: Python :: 3.8
15
- Classifier: Programming Language :: Python :: 3.9
16
- Classifier: Programming Language :: Python :: 3.10
17
- Classifier: Programming Language :: Python :: 3.11
18
- Classifier: Operating System :: OS Independent
19
- Classifier: Topic :: Software Development :: Libraries
20
- Classifier: Topic :: Software Development :: Build Tools
21
- Classifier: Topic :: Software Development :: Bug Tracking
22
- Classifier: Topic :: Software Development :: Debuggers
23
- Classifier: Topic :: Software Development :: Code Generators
24
- Classifier: Topic :: Software Development :: Version Control :: Git
25
- Classifier: Topic :: Communications :: Chat
26
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
27
- Requires-Python: >=3.9
28
- Description-Content-Type: text/markdown
29
- License-File: LICENSE
30
-
31
- # Blocks CLI
32
-
33
- 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.
34
-
35
- > We're currently in private alpha, we recommend consistently updating your SDK to the latest version to get the latest features and fixes.
36
-
37
- ## Getting Started
38
-
39
- ### 1. Install CLI (Packaged with SDK)
40
-
41
- ```bash
42
- pip install blocks-sdk
43
- ```
44
-
45
- ### 2. Create a new Blocks project
46
-
47
- ```bash
48
- mkdir -p .blocks/myautomation
49
- cd .blocks/myautomation
50
- ```
51
-
52
- ### 3. Create a new automation
53
-
54
- ```python
55
- # automation.py
56
- from blocks import task, on
57
-
58
- @task(name="my_automation")
59
- @on("github.pull_request", repos=["MyOrg/MyRepo"])
60
- def my_automation(event):
61
- print(event)
62
- ```
63
-
64
- ### 5. Upload your automation
65
-
66
- ```bash
67
- blocks init --api-key <your-api-key>
68
- blocks push automation.py
69
- ```
@@ -1,39 +0,0 @@
1
- # Blocks CLI
2
-
3
- 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.
4
-
5
- > We're currently in private alpha, we recommend consistently updating your SDK to the latest version to get the latest features and fixes.
6
-
7
- ## Getting Started
8
-
9
- ### 1. Install CLI (Packaged with SDK)
10
-
11
- ```bash
12
- pip install blocks-sdk
13
- ```
14
-
15
- ### 2. Create a new Blocks project
16
-
17
- ```bash
18
- mkdir -p .blocks/myautomation
19
- cd .blocks/myautomation
20
- ```
21
-
22
- ### 3. Create a new automation
23
-
24
- ```python
25
- # automation.py
26
- from blocks import task, on
27
-
28
- @task(name="my_automation")
29
- @on("github.pull_request", repos=["MyOrg/MyRepo"])
30
- def my_automation(event):
31
- print(event)
32
- ```
33
-
34
- ### 5. Upload your automation
35
-
36
- ```bash
37
- blocks init --api-key <your-api-key>
38
- blocks push automation.py
39
- ```
File without changes
File without changes
File without changes