utcp-cli 1.0.2__tar.gz → 1.1.1__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.
@@ -0,0 +1,274 @@
1
+ Metadata-Version: 2.4
2
+ Name: utcp-cli
3
+ Version: 1.1.1
4
+ Summary: UTCP communication protocol plugin for wrapping local command-line tools.
5
+ Author: UTCP Contributors
6
+ License-Expression: MPL-2.0
7
+ Project-URL: Homepage, https://utcp.io
8
+ Project-URL: Source, https://github.com/universal-tool-calling-protocol/python-utcp
9
+ Project-URL: Issues, https://github.com/universal-tool-calling-protocol/python-utcp/issues
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Operating System :: OS Independent
14
+ Requires-Python: >=3.10
15
+ Description-Content-Type: text/markdown
16
+ Requires-Dist: pydantic>=2.0
17
+ Requires-Dist: pyyaml>=6.0
18
+ Requires-Dist: utcp>=1.1
19
+ Provides-Extra: dev
20
+ Requires-Dist: build; extra == "dev"
21
+ Requires-Dist: pytest; extra == "dev"
22
+ Requires-Dist: pytest-asyncio; extra == "dev"
23
+ Requires-Dist: pytest-cov; extra == "dev"
24
+ Requires-Dist: coverage; extra == "dev"
25
+ Requires-Dist: twine; extra == "dev"
26
+
27
+ # UTCP CLI Plugin
28
+
29
+ [![PyPI Downloads](https://static.pepy.tech/badge/utcp-cli)](https://pepy.tech/projects/utcp-cli)
30
+
31
+ Command-line interface plugin for UTCP, enabling integration with command-line tools and processes.
32
+
33
+ ## Features
34
+
35
+ - **Multi-Command Execution**: Execute multiple commands sequentially in a single subprocess
36
+ - **State Preservation**: Directory changes and environment persist between commands
37
+ - **Cross-Platform Script Generation**: PowerShell on Windows, Bash on Unix/Linux/macOS
38
+ - **Flexible Output Control**: Choose which command outputs to include in final result
39
+ - **Argument Substitution**: `UTCP_ARG_argname_UTCP_END` placeholder system
40
+ - **Output Referencing**: Access previous command outputs with `$CMD_0_OUTPUT`, `$CMD_1_OUTPUT`
41
+ - **Environment Variables**: Secure credential and configuration passing
42
+ - **Working Directory Control**: Execute commands in specific directories
43
+ - **Timeout Management**: Configurable execution timeouts
44
+ - **Error Handling**: Comprehensive subprocess error management
45
+
46
+ ## Installation
47
+
48
+ ```bash
49
+ pip install utcp-cli
50
+ ```
51
+
52
+ ## Quick Start
53
+
54
+ ```python
55
+ from utcp.utcp_client import UtcpClient
56
+
57
+ # Multi-step CLI tool
58
+ client = await UtcpClient.create(config={
59
+ "manual_call_templates": [{
60
+ "name": "file_analysis",
61
+ "call_template_type": "cli",
62
+ "commands": [
63
+ {
64
+ "command": "cd UTCP_ARG_target_dir_UTCP_END",
65
+ "append_to_final_output": false
66
+ },
67
+ {
68
+ "command": "find . -type f -name '*.py' | wc -l"
69
+ }
70
+ ]
71
+ }]
72
+ })
73
+
74
+ result = await client.call_tool("file_analysis.count_python_files", {"target_dir": "/project"})
75
+ ```
76
+
77
+ ## Configuration Examples
78
+
79
+ ### Basic Multi-Command Operation
80
+ ```json
81
+ {
82
+ "name": "file_analysis",
83
+ "call_template_type": "cli",
84
+ "commands": [
85
+ {
86
+ "command": "cd UTCP_ARG_target_dir_UTCP_END",
87
+ "append_to_final_output": false
88
+ },
89
+ {
90
+ "command": "ls -la"
91
+ }
92
+ ],
93
+ "working_dir": "/tmp"
94
+ }
95
+ ```
96
+
97
+ ### With Environment Variables and Output Control
98
+ ```json
99
+ {
100
+ "name": "python_pipeline",
101
+ "call_template_type": "cli",
102
+ "commands": [
103
+ {
104
+ "command": "python setup.py install",
105
+ "append_to_final_output": false
106
+ },
107
+ {
108
+ "command": "python script.py --input UTCP_ARG_input_file_UTCP_END --result \"$CMD_0_OUTPUT\"",
109
+ "append_to_final_output": true
110
+ }
111
+ ],
112
+ "env_vars": {
113
+ "PYTHONPATH": "/custom/path",
114
+ "API_KEY": "${API_KEY}"
115
+ }
116
+ }
117
+ ```
118
+
119
+ ### Cross-Platform Git Operations
120
+ ```json
121
+ {
122
+ "name": "git_analysis",
123
+ "call_template_type": "cli",
124
+ "commands": [
125
+ {
126
+ "command": "git clone UTCP_ARG_repo_url_UTCP_END temp_repo",
127
+ "append_to_final_output": false
128
+ },
129
+ {
130
+ "command": "cd temp_repo",
131
+ "append_to_final_output": false
132
+ },
133
+ {
134
+ "command": "git log --oneline -10",
135
+ "append_to_final_output": true
136
+ },
137
+ {
138
+ "command": "echo \"Repository has $(find . -name '*.py' | wc -l) Python files\"",
139
+ "append_to_final_output": true
140
+ }
141
+ ],
142
+ "env_vars": {
143
+ "GIT_AUTHOR_NAME": "UTCP Bot",
144
+ "GIT_AUTHOR_EMAIL": "bot@utcp.dev"
145
+ }
146
+ }
147
+ ```
148
+
149
+ ### Referencing Previous Command Output
150
+ ```json
151
+ {
152
+ "name": "conditional_processor",
153
+ "call_template_type": "cli",
154
+ "commands": [
155
+ {
156
+ "command": "git status --porcelain",
157
+ "append_to_final_output": false
158
+ },
159
+ {
160
+ "command": "echo \"Changes detected: $CMD_0_OUTPUT\"",
161
+ "append_to_final_output": true
162
+ }
163
+ ]
164
+ }
165
+ ```
166
+
167
+ ## Cross-Platform Considerations
168
+
169
+ ### Command Syntax
170
+ Commands should use appropriate syntax for the target platform:
171
+
172
+ **Windows (PowerShell):**
173
+ ```json
174
+ {
175
+ "commands": [
176
+ {"command": "Get-ChildItem UTCP_ARG_path_UTCP_END"},
177
+ {"command": "Set-Location UTCP_ARG_dir_UTCP_END"}
178
+ ]
179
+ }
180
+ ```
181
+
182
+ **Unix/Linux/macOS (Bash):**
183
+ ```json
184
+ {
185
+ "commands": [
186
+ {"command": "ls -la UTCP_ARG_path_UTCP_END"},
187
+ {"command": "cd UTCP_ARG_dir_UTCP_END"}
188
+ ]
189
+ }
190
+ ```
191
+
192
+ ### Universal Commands
193
+ Some commands work across platforms:
194
+ ```json
195
+ {
196
+ "commands": [
197
+ {"command": "git status"},
198
+ {"command": "python --version"},
199
+ {"command": "node -v"}
200
+ ]
201
+ }
202
+ ```
203
+
204
+ ## Security Considerations
205
+
206
+ - Commands execute in isolated subprocesses with controlled environment
207
+ - Environment variables provide secure credential passing
208
+ - Previous command outputs should be used carefully to avoid injection
209
+ - Commands should use platform-appropriate syntax
210
+
211
+ ## Error Handling
212
+
213
+ ```python
214
+ from utcp.exceptions import ToolCallError
215
+
216
+ try:
217
+ result = await client.call_tool("cli_tool.multi_command", {
218
+ "repo_url": "https://github.com/example/repo.git",
219
+ "target_dir": "analysis_temp"
220
+ })
221
+ except ToolCallError as e:
222
+ print(f"CLI tool execution failed: {e}")
223
+ # Script execution failed - check individual command outputs
224
+ ```
225
+
226
+ ## Common Use Cases
227
+
228
+ - **Multi-step Builds**: setup → compile → test → package
229
+ - **Git Workflows**: clone → analyze → commit → push
230
+ - **Data Pipelines**: fetch → transform → validate → output
231
+ - **File Operations**: navigate → search → process → report
232
+ - **Development Tools**: install dependencies → run tests → generate docs
233
+ - **System Administration**: check status → backup → cleanup → verify
234
+ - **Custom Workflows**: Any sequence of command-line operations
235
+
236
+ ## Testing CLI Tools
237
+
238
+ ```python
239
+ import pytest
240
+ from utcp.utcp_client import UtcpClient
241
+
242
+ @pytest.mark.asyncio
243
+ async def test_multi_command_cli_tool():
244
+ client = await UtcpClient.create(config={
245
+ "manual_call_templates": [{
246
+ "name": "test_cli",
247
+ "call_template_type": "cli",
248
+ "commands": [
249
+ {
250
+ "command": "echo UTCP_ARG_message_UTCP_END",
251
+ "append_to_final_output": false
252
+ },
253
+ {
254
+ "command": "echo \"Previous: $CMD_0_OUTPUT\""
255
+ }
256
+ ]
257
+ }]
258
+ })
259
+
260
+ result = await client.call_tool("test_cli.echo_chain", {"message": "hello"})
261
+ assert "Previous: hello" in result
262
+ ```
263
+
264
+ ## Related Documentation
265
+
266
+ - [Main UTCP Documentation](../../../README.md)
267
+ - [Core Package Documentation](../../../core/README.md)
268
+ - [HTTP Plugin](../http/README.md)
269
+ - [MCP Plugin](../mcp/README.md)
270
+ - [Text Plugin](../text/README.md)
271
+
272
+ ## Examples
273
+
274
+ For complete examples, see the [UTCP examples repository](https://github.com/universal-tool-calling-protocol/utcp-examples).
@@ -0,0 +1,248 @@
1
+ # UTCP CLI Plugin
2
+
3
+ [![PyPI Downloads](https://static.pepy.tech/badge/utcp-cli)](https://pepy.tech/projects/utcp-cli)
4
+
5
+ Command-line interface plugin for UTCP, enabling integration with command-line tools and processes.
6
+
7
+ ## Features
8
+
9
+ - **Multi-Command Execution**: Execute multiple commands sequentially in a single subprocess
10
+ - **State Preservation**: Directory changes and environment persist between commands
11
+ - **Cross-Platform Script Generation**: PowerShell on Windows, Bash on Unix/Linux/macOS
12
+ - **Flexible Output Control**: Choose which command outputs to include in final result
13
+ - **Argument Substitution**: `UTCP_ARG_argname_UTCP_END` placeholder system
14
+ - **Output Referencing**: Access previous command outputs with `$CMD_0_OUTPUT`, `$CMD_1_OUTPUT`
15
+ - **Environment Variables**: Secure credential and configuration passing
16
+ - **Working Directory Control**: Execute commands in specific directories
17
+ - **Timeout Management**: Configurable execution timeouts
18
+ - **Error Handling**: Comprehensive subprocess error management
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ pip install utcp-cli
24
+ ```
25
+
26
+ ## Quick Start
27
+
28
+ ```python
29
+ from utcp.utcp_client import UtcpClient
30
+
31
+ # Multi-step CLI tool
32
+ client = await UtcpClient.create(config={
33
+ "manual_call_templates": [{
34
+ "name": "file_analysis",
35
+ "call_template_type": "cli",
36
+ "commands": [
37
+ {
38
+ "command": "cd UTCP_ARG_target_dir_UTCP_END",
39
+ "append_to_final_output": false
40
+ },
41
+ {
42
+ "command": "find . -type f -name '*.py' | wc -l"
43
+ }
44
+ ]
45
+ }]
46
+ })
47
+
48
+ result = await client.call_tool("file_analysis.count_python_files", {"target_dir": "/project"})
49
+ ```
50
+
51
+ ## Configuration Examples
52
+
53
+ ### Basic Multi-Command Operation
54
+ ```json
55
+ {
56
+ "name": "file_analysis",
57
+ "call_template_type": "cli",
58
+ "commands": [
59
+ {
60
+ "command": "cd UTCP_ARG_target_dir_UTCP_END",
61
+ "append_to_final_output": false
62
+ },
63
+ {
64
+ "command": "ls -la"
65
+ }
66
+ ],
67
+ "working_dir": "/tmp"
68
+ }
69
+ ```
70
+
71
+ ### With Environment Variables and Output Control
72
+ ```json
73
+ {
74
+ "name": "python_pipeline",
75
+ "call_template_type": "cli",
76
+ "commands": [
77
+ {
78
+ "command": "python setup.py install",
79
+ "append_to_final_output": false
80
+ },
81
+ {
82
+ "command": "python script.py --input UTCP_ARG_input_file_UTCP_END --result \"$CMD_0_OUTPUT\"",
83
+ "append_to_final_output": true
84
+ }
85
+ ],
86
+ "env_vars": {
87
+ "PYTHONPATH": "/custom/path",
88
+ "API_KEY": "${API_KEY}"
89
+ }
90
+ }
91
+ ```
92
+
93
+ ### Cross-Platform Git Operations
94
+ ```json
95
+ {
96
+ "name": "git_analysis",
97
+ "call_template_type": "cli",
98
+ "commands": [
99
+ {
100
+ "command": "git clone UTCP_ARG_repo_url_UTCP_END temp_repo",
101
+ "append_to_final_output": false
102
+ },
103
+ {
104
+ "command": "cd temp_repo",
105
+ "append_to_final_output": false
106
+ },
107
+ {
108
+ "command": "git log --oneline -10",
109
+ "append_to_final_output": true
110
+ },
111
+ {
112
+ "command": "echo \"Repository has $(find . -name '*.py' | wc -l) Python files\"",
113
+ "append_to_final_output": true
114
+ }
115
+ ],
116
+ "env_vars": {
117
+ "GIT_AUTHOR_NAME": "UTCP Bot",
118
+ "GIT_AUTHOR_EMAIL": "bot@utcp.dev"
119
+ }
120
+ }
121
+ ```
122
+
123
+ ### Referencing Previous Command Output
124
+ ```json
125
+ {
126
+ "name": "conditional_processor",
127
+ "call_template_type": "cli",
128
+ "commands": [
129
+ {
130
+ "command": "git status --porcelain",
131
+ "append_to_final_output": false
132
+ },
133
+ {
134
+ "command": "echo \"Changes detected: $CMD_0_OUTPUT\"",
135
+ "append_to_final_output": true
136
+ }
137
+ ]
138
+ }
139
+ ```
140
+
141
+ ## Cross-Platform Considerations
142
+
143
+ ### Command Syntax
144
+ Commands should use appropriate syntax for the target platform:
145
+
146
+ **Windows (PowerShell):**
147
+ ```json
148
+ {
149
+ "commands": [
150
+ {"command": "Get-ChildItem UTCP_ARG_path_UTCP_END"},
151
+ {"command": "Set-Location UTCP_ARG_dir_UTCP_END"}
152
+ ]
153
+ }
154
+ ```
155
+
156
+ **Unix/Linux/macOS (Bash):**
157
+ ```json
158
+ {
159
+ "commands": [
160
+ {"command": "ls -la UTCP_ARG_path_UTCP_END"},
161
+ {"command": "cd UTCP_ARG_dir_UTCP_END"}
162
+ ]
163
+ }
164
+ ```
165
+
166
+ ### Universal Commands
167
+ Some commands work across platforms:
168
+ ```json
169
+ {
170
+ "commands": [
171
+ {"command": "git status"},
172
+ {"command": "python --version"},
173
+ {"command": "node -v"}
174
+ ]
175
+ }
176
+ ```
177
+
178
+ ## Security Considerations
179
+
180
+ - Commands execute in isolated subprocesses with controlled environment
181
+ - Environment variables provide secure credential passing
182
+ - Previous command outputs should be used carefully to avoid injection
183
+ - Commands should use platform-appropriate syntax
184
+
185
+ ## Error Handling
186
+
187
+ ```python
188
+ from utcp.exceptions import ToolCallError
189
+
190
+ try:
191
+ result = await client.call_tool("cli_tool.multi_command", {
192
+ "repo_url": "https://github.com/example/repo.git",
193
+ "target_dir": "analysis_temp"
194
+ })
195
+ except ToolCallError as e:
196
+ print(f"CLI tool execution failed: {e}")
197
+ # Script execution failed - check individual command outputs
198
+ ```
199
+
200
+ ## Common Use Cases
201
+
202
+ - **Multi-step Builds**: setup → compile → test → package
203
+ - **Git Workflows**: clone → analyze → commit → push
204
+ - **Data Pipelines**: fetch → transform → validate → output
205
+ - **File Operations**: navigate → search → process → report
206
+ - **Development Tools**: install dependencies → run tests → generate docs
207
+ - **System Administration**: check status → backup → cleanup → verify
208
+ - **Custom Workflows**: Any sequence of command-line operations
209
+
210
+ ## Testing CLI Tools
211
+
212
+ ```python
213
+ import pytest
214
+ from utcp.utcp_client import UtcpClient
215
+
216
+ @pytest.mark.asyncio
217
+ async def test_multi_command_cli_tool():
218
+ client = await UtcpClient.create(config={
219
+ "manual_call_templates": [{
220
+ "name": "test_cli",
221
+ "call_template_type": "cli",
222
+ "commands": [
223
+ {
224
+ "command": "echo UTCP_ARG_message_UTCP_END",
225
+ "append_to_final_output": false
226
+ },
227
+ {
228
+ "command": "echo \"Previous: $CMD_0_OUTPUT\""
229
+ }
230
+ ]
231
+ }]
232
+ })
233
+
234
+ result = await client.call_tool("test_cli.echo_chain", {"message": "hello"})
235
+ assert "Previous: hello" in result
236
+ ```
237
+
238
+ ## Related Documentation
239
+
240
+ - [Main UTCP Documentation](../../../README.md)
241
+ - [Core Package Documentation](../../../core/README.md)
242
+ - [HTTP Plugin](../http/README.md)
243
+ - [MCP Plugin](../mcp/README.md)
244
+ - [Text Plugin](../text/README.md)
245
+
246
+ ## Examples
247
+
248
+ For complete examples, see the [UTCP examples repository](https://github.com/universal-tool-calling-protocol/utcp-examples).
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "utcp-cli"
7
- version = "1.0.2"
7
+ version = "1.1.1"
8
8
  authors = [
9
9
  { name = "UTCP Contributors" },
10
10
  ]
@@ -14,7 +14,7 @@ requires-python = ">=3.10"
14
14
  dependencies = [
15
15
  "pydantic>=2.0",
16
16
  "pyyaml>=6.0",
17
- "utcp>=1.0"
17
+ "utcp>=1.1"
18
18
  ]
19
19
  classifiers = [
20
20
  "Development Status :: 4 - Beta",