mesh-utils.sh — Shared utility library for Mesh Protocol tools
mesh mesh-utils
# mesh-utils
Shared utility library for Mesh Protocol tools. Eliminates duplicated patterns across 6+ tools.
## Functions
- `mesh_root` — Detect hive root directory
- `mesh_find_ledgers [root]` — Find all JSONL ledgers (excludes archived/backups/exports/git)
- `mesh_find_ledger <pattern> [root]` — Find specific ledger by name
- `mesh_count_ledgers [root]` — Count active ledgers
- `mesh_list_tools [root]` — List active mesh tool directories
- `mesh_count_tools [root]` — Count active tools
- `mesh_ts` / `mesh_ts_local` — UTC/local ISO-8601 timestamps
- `mesh_hostname` — Cached hostname
- `mesh_agent_id [root]` — Read agent identity
- `mesh_json_get <json> <key>` — Extract JSON field
- `mesh_log <level> <msg>` — Stderr logging with timestamp
- `mesh_require <cmd...>` — Assert commands exist
- `mesh_commons_dir` / `mesh_tool_commons <tool>` — Commons paths
## Usage
```bash
source "$(dirname "$0")/../mesh-utils/mesh-utils.sh"
```
## Wired Into
log-aggregator, backup, changelog, search, export, health-check
## Tags
library, shared, infrastructure, DRY