Skip to content

"CLI-Anything: Making ALL Software Agent-Native" -- CLI-Hub: https://clianything.cc/

Python

fix: address 11 second-round Copilot review comments

fabio.mantelmachere2b7064122b3
diff --git a/wiremock/agent-harness/WIREMOCK.md b/wiremock/agent-harness/WIREMOCK.md
index 5850b7b65..3c1acbb65 100644
--- a/wiremock/agent-harness/WIREMOCK.md
+++ b/wiremock/agent-harness/WIREMOCK.md
@@ -232,6 +232,9 @@ cli-anything-wiremock --json stub list
cli-anything-wiremock --json request count '{"method":"GET","url":"/health"}'
```
-Output envelope:
-- Success: `{ "status": "ok", "message": "...", "data": {...} }`
-- Error: `{ "status": "error", "message": "..." }`
+JSON output varies by command type:
+
+- **Data commands** return the raw WireMock API JSON directly (e.g. `stub list` returns `{"mappings": [...], "total": N}`)
+- **Void operations** (delete, reset, save) return `{"status": "ok"}`
+- **`status` command** returns `{"status": "running"|"stopped", "host": "...", "port": N}`
+- **Errors** return `{"status": "error", "message": "..."}` (printed to stderr in human mode)
diff --git a/wiremock/agent-harness/cli_anything/wiremock/README.md b/wiremock/agent-harness/cli_anything/wiremock/README.md
index d04e6237f..007d14f52 100644
--- a/wiremock/agent-harness/cli_anything/wiremock/README.md
+++ b/wiremock/agent-harness/cli_anything/wiremock/README.md
@@ -44,4 +44,4 @@ export WIREMOCK_PORT=8080
export WIREMOCK_SCHEME=http
```
-See `../WIREMOCK.md` for the full SOP.
+For the full SOP and workflow recipes, see `WIREMOCK.md` in the agent-harness directory (available in the source repository, not in installed packages).
diff --git a/wiremock/agent-harness/cli_anything/wiremock/skills/SKILL.md b/wiremock/agent-harness/cli_anything/wiremock/skills/SKILL.md
index 8d1a18fef..d70d09333 100644
--- a/wiremock/agent-harness/cli_anything/wiremock/skills/SKILL.md
+++ b/wiremock/agent-harness/cli_anything/wiremock/skills/SKILL.md
@@ -100,14 +100,17 @@ cli-anything-wiremock record stop
### Always use `--json` in agent contexts
-Use `--json` for all invocations in scripts or agent tool calls. This returns the raw WireMock API response JSON directly (no envelope wrapper):
+Use `--json` for all invocations in scripts or agent tool calls. JSON output varies by command type (these are distinct response types, not an envelope wrapping all responses):
```bash
-# Example: create a stub and get the raw WireMock response
+# Data commands return raw WireMock API JSON directly:
cli-anything-wiremock --json stub quick GET /api/hello 200 --body '{"hello":"world"}'
# → {"id": "abc-123", "request": {...}, "response": {...}, ...}
-# Commands with no response body return:
+cli-anything-wiremock --json stub list
+# → {"mappings": [...], "total": N}
+
+# Void commands (delete, reset, save) return:
# → {"status": "ok"}
# Errors return:
diff --git a/wiremock/agent-harness/cli_anything/wiremock/utils/client.py b/wiremock/agent-harness/cli_anything/wiremock/utils/client.py
index 38ea76e4a..b6f778095 100644
--- a/wiremock/agent-harness/cli_anything/wiremock/utils/client.py
+++ b/wiremock/agent-harness/cli_anything/wiremock/utils/client.py
@@ -23,34 +23,38 @@ class WireMockClient:
)
def post(self, path: str, json=None, **kwargs) -> requests.Response:
+ timeout = kwargs.pop("timeout", self.timeout)
return requests.post(
f"{self.base_url()}{path}",
json=json,
auth=self.auth,
- timeout=self.timeout,
+ timeout=timeout,
**kwargs,
)
def put(self, path: str, json=None, **kwargs) -> requests.Response:
+ timeout = kwargs.pop("timeout", self.timeout)
return requests.put(
f"{self.base_url()}{path}",
json=json,
auth=self.auth,
- timeout=self.timeout,
+ timeout=timeout,
**kwargs,
)
def delete(self, path: str, **kwargs) -> requests.Response:
+ timeout = kwargs.pop("timeout", self.timeout)
return requests.delete(
- f"{self.base_url()}{path}", auth=self.auth, timeout=self.timeout, **kwargs
+ f"{self.base_url()}{path}", auth=self.auth, timeout=timeout, **kwargs
)
def patch(self, path: str, json=None, **kwargs) -> requests.Response:
+ timeout = kwargs.pop("timeout", self.timeout)
return requests.patch(
f"{self.base_url()}{path}",
json=json,
auth=self.auth,
- timeout=self.timeout,
+ timeout=timeout,
**kwargs,
)
diff --git a/wiremock/agent-harness/cli_anything/wiremock/wiremock_cli.py b/wiremock/agent-harness/cli_anything/wiremock/wiremock_cli.py
index a47f4ddcd..e8aada179 100644
--- a/wiremock/agent-harness/cli_anything/wiremock/wiremock_cli.py
+++ b/wiremock/agent-harness/cli_anything/wiremock/wiremock_cli.py
@@ -1,4 +1,5 @@
import json
+import requests
import click
from cli_anything.wiremock.utils.client import WireMockClient
from cli_anything.wiremock.utils.output import error, print_json, print_table, success
@@ -587,17 +588,20 @@ def shutdown(ctx):
client = ctx.obj
json_mode = ctx.meta.get("json_mode", False)
try:
- client.post("/shutdown")
+ r = client.post("/shutdown")
+ r.raise_for_status()
if json_mode:
print_json({"status": "ok", "message": "Shutdown signal sent"})
else:
- success("Shutdown signal sent")
- except Exception:
- # Server may drop connection before responding
+ click.echo("Shutdown signal sent")
+ except (ConnectionError, requests.exceptions.ConnectionError):
+ # Server drops connection on successful shutdown — this is expected
if json_mode:
print_json({"status": "ok", "message": "Shutdown signal sent"})
else:
- click.echo("Shutdown signal sent (connection may have closed)")
+ click.echo("Shutdown signal sent (server connection closed)")
+ except Exception as e:
+ error(str(e), json_mode)
if __name__ == "__main__":