Skip to content

Commit b137f10

Browse files
committed
🤖 docs: add reusable run_and_report helper for mux bash tools
Add a project-level .mux/tool_env that defines run_and_report so bash invocations can reuse consistent step logging and fail-fast behavior. Document the helper in AGENTS.md with usage examples. --- _Generated with [`mux`](https://github.com/coder/mux) • Model: `openai:gpt-5.3-codex` • Thinking: `xhigh` • Cost: `$0.20`_ <!-- mux-attribution: model=openai:gpt-5.3-codex thinking=xhigh costs=0.20 -->
1 parent 128b222 commit b137f10

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

‎.mux/tool_env‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# .mux/tool_env
2+
# Sourced by Mux before every bash tool invocation.
3+
# Docs: https://mux.coder.com/hooks/tools
4+
5+
run_and_report() {
6+
local step_name="${1:-}"
7+
if [[ -z "${step_name}" ]]; then
8+
echo "assertion failed: run_and_report requires a non-empty step name" >&2
9+
return 97
10+
fi
11+
shift
12+
13+
if [[ "$#" -eq 0 ]]; then
14+
echo "assertion failed: run_and_report requires a command after the step name" >&2
15+
return 97
16+
fi
17+
18+
local safe_name
19+
safe_name="$(printf '%s' "${step_name}" | tr -cs 'A-Za-z0-9._-' '_')"
20+
local workspace_tag="${MUX_WORKSPACE_ID:-local}"
21+
local log_file="/tmp/mux-${workspace_tag}-${safe_name}.log"
22+
23+
echo "==> Running ${step_name}"
24+
if "$@" >"${log_file}" 2>&1; then
25+
echo "==> ${step_name} passed"
26+
return 0
27+
else
28+
local exit_code=$?
29+
echo "==> ${step_name} failed (showing tail from ${log_file})" >&2
30+
tail -n 120 "${log_file}" >&2 || true
31+
return "${exit_code}"
32+
fi
33+
}

‎AGENTS.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,15 @@ Run from repository root.
6969
- **Clean:** `go clean -cache -testcache && rm -f ./coder-k8s && rm -rf ./dist`
7070
- **Shell scripts:** `find . -type f -name '*.sh' -not -path './vendor/*'`
7171

72+
## Mux Tooling Helpers
73+
74+
- `.mux/tool_env` is sourced before every `bash` tool call (Mux docs: `/hooks/tools`).
75+
- Use `run_and_report <step_name> <command...>` for multi-step validation in one bash invocation.
76+
- The helper writes full logs to `/tmp/mux-<workspace>-<step>.log`, prints pass/fail markers, and tails failures.
77+
- Example:
78+
- `run_and_report verify-vendor make verify-vendor`
79+
- `run_and_report test make test`
80+
7281
## Patterns
7382

7483
- **Do** preserve fail-fast assertions for impossible states (nil manager/client/scheme, mismatched fetched objects).

0 commit comments

Comments
 (0)