@tronsfey/ucli 0.4.3 → 0.5.1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tronsfey/ucli",
3
- "version": "0.4.3",
3
+ "version": "0.5.1",
4
4
  "description": "ucli — proxy OpenAPI and MCP services for AI agents",
5
5
  "keywords": [
6
6
  "openapi",
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "devDependencies": {
46
46
  "@modelcontextprotocol/server-filesystem": "2026.1.14",
47
- "@tronsfey/mcp2cli": "1.0.1",
47
+ "@tronsfey/mcp2cli": "1.0.2",
48
48
  "@types/node": "^22.14.0",
49
49
  "tsup": "^8.4.0",
50
50
  "tsx": "^4.19.3",
package/skill.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: ucli
3
3
  description: Proxy OpenAPI and MCP services for AI agents — discover, inspect, and invoke APIs with automatic credential injection.
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  metadata:
6
6
  openclaw:
7
7
  emoji: "🔗"
@@ -23,8 +23,73 @@ Use `ucli` whenever you need to call any external business API or MCP server too
23
23
  - Proxies registered OpenAPI services on your behalf
24
24
  - Handles authentication automatically (credentials are never exposed to you)
25
25
  - Returns structured JSON output suitable for further processing
26
+ - Supports `--output json` for fully structured envelopes (success/error)
26
27
 
27
- **When to use:** Any time you need to interact with external services (business APIs, data sources, microservices). Always check available services first with `ucli services list`.
28
+ **When to use:** Any time you need to interact with external services (business APIs, data sources, microservices). Always start with `ucli introspect` to discover all capabilities in a single call.
29
+
30
+ ---
31
+
32
+ ## Agent Methodology — OODA Loop
33
+
34
+ ucli is designed around the **Observe → Orient → Decide → Act** (OODA) loop for AI agent workflows:
35
+
36
+ 1. **Observe** — Discover all available capabilities with `ucli introspect`
37
+ 2. **Orient** — Understand specific operations with `ucli services info <name>` or `ucli mcp tools <server>`
38
+ 3. **Decide** — Choose the right operation and parameters based on the task
39
+ 4. **Act** — Execute with `ucli run` or `ucli mcp run`
40
+
41
+ ### Recommended First Call
42
+
43
+ ```bash
44
+ ucli introspect --output json
45
+ ```
46
+
47
+ This returns a complete manifest in a single call:
48
+ ```json
49
+ {
50
+ "success": true,
51
+ "data": {
52
+ "version": "1",
53
+ "services": [
54
+ { "name": "payments", "description": "...", "authType": "bearer", ... }
55
+ ],
56
+ "mcpServers": [
57
+ { "name": "weather", "description": "...", "transport": "http", ... }
58
+ ],
59
+ "commands": [
60
+ { "name": "run", "description": "...", "usage": "...", "examples": [...] }
61
+ ]
62
+ }
63
+ }
64
+ ```
65
+
66
+ ---
67
+
68
+ ## Global Flags
69
+
70
+ | Flag | Description |
71
+ |------|-------------|
72
+ | `--output json` | Wrap ALL output in structured `{ success, data/error }` envelopes |
73
+ | `--debug` | Enable verbose debug logging |
74
+ | `-v, --version` | Show version number |
75
+
76
+ ### Structured Output Mode (`--output json`)
77
+
78
+ When `--output json` is passed, every command emits exactly one JSON object to stdout:
79
+
80
+ **Success:**
81
+ ```json
82
+ { "success": true, "data": <result> }
83
+ ```
84
+
85
+ **Error:**
86
+ ```json
87
+ { "success": false, "error": { "code": 6, "message": "Service not found: foo", "hint": "Run: ucli services list" } }
88
+ ```
89
+
90
+ Error codes: `0`=success, `1`=general, `2`=usage, `3`=config, `4`=auth, `5`=connectivity, `6`=not-found, `7`=server-error.
91
+
92
+ **Always use `--output json` when calling ucli from code or as an AI agent.** This ensures you can reliably parse both success and error results.
28
93
 
29
94
  ---
30
95
 
@@ -45,6 +110,11 @@ inventory api_key Product inventory management
45
110
  crm oauth2_cc Customer relationship management
46
111
  ```
47
112
 
113
+ For machine-readable output:
114
+ ```bash
115
+ ucli services list --output json
116
+ ```
117
+
48
118
  ---
49
119
 
50
120
  ## Step 2 — Inspect a Service's Operations
@@ -132,11 +202,11 @@ By default, `ucli run` returns JSON. You can:
132
202
  ## Complete Workflow Example
133
203
 
134
204
  ```bash
135
- # 1. Discover services
136
- ucli services list
205
+ # 1. Discover all capabilities (single call)
206
+ ucli introspect --output json
137
207
 
138
- # 2. Check what operations are available on "payments"
139
- ucli services info payments
208
+ # 2. Inspect a specific service's operations
209
+ ucli services info payments --output json
140
210
 
141
211
  # 3. List recent transactions
142
212
  ucli run payments listTransactions --query "transactions[*].{id:id,amount:amount,status:status}"
@@ -166,11 +236,21 @@ ucli run payments createCharge --data '{
166
236
  | `429 Too Many Requests` | Rate limit exceeded | Wait and retry |
167
237
  | `5xx Server Error` | Upstream service error | Retry once; if persistent, report to the service owner |
168
238
 
239
+ ### Error Recovery Strategy for Agents
240
+
241
+ 1. **Parse the exit code** — non-zero means failure (codes 1–7 have specific meanings)
242
+ 2. **When using `--output json`** — check `success` field; on failure read `error.hint`
243
+ 3. **Retry logic** — on `code: 5` (connectivity) or `code: 7` (server error), retry once after a brief wait
244
+ 4. **Re-discover** — on `code: 6` (not found), re-run `ucli introspect` to refresh your capability model
245
+
169
246
  **On persistent errors:**
170
247
  ```bash
171
248
  # Refresh the local OAS cache (may resolve stale spec issues)
172
249
  ucli refresh
173
250
 
251
+ # Run diagnostics
252
+ ucli doctor --output json
253
+
174
254
  # Then retry the operation
175
255
  ucli run <service> <operation>
176
256
  ```
@@ -222,9 +302,9 @@ ucli mcp run search-server web_search query="ucli documentation" limit=5
222
302
 
223
303
  ## Tips for AI Agents
224
304
 
225
- 1. **Always discover first.** Don't guess service or operation names run `ucli services list` then `ucli services info <name>`.
305
+ 1. **Start with `ucli introspect`.** This gives you a complete picture of all services, MCP servers, and available commands in a single call. Don't make multiple discovery calls when one will do.
226
306
 
227
- 2. **Use JSON output.** Default `--format json` gives you machine-parseable data. Only switch to `table` when presenting to humans.
307
+ 2. **Always use `--output json`.** This wraps every result in `{ success: true, data }` or `{ success: false, error }`. Never parse human-readable text output.
228
308
 
229
309
  3. **Use `--query` to extract.** Instead of parsing the entire response, use JMESPath to extract exactly what you need.
230
310
 
@@ -238,3 +318,7 @@ ucli mcp run search-server web_search query="ucli documentation" limit=5
238
318
  5. **Check pagination.** Large result sets may be paginated. Look for `nextPage`, `cursor`, or `Link` headers in the response.
239
319
 
240
320
  6. **Validate before mutating.** For destructive operations (DELETE, large updates), confirm the resource exists and is correct before proceeding.
321
+
322
+ 7. **Use exit codes for control flow.** Exit code `0` = success, non-zero = failure. Use `--output json` for richer error context.
323
+
324
+ 8. **Re-introspect on capability changes.** If you encounter a `not found` error for a service that should exist, run `ucli refresh` then `ucli introspect` to refresh your model of available capabilities.