Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,41 @@ It is built for local agent-heavy development setups with tools such as Codex, C
### SwiftBar

1. Install [SwiftBar](https://github.com/swiftbar/SwiftBar).
2. Clone this repo.
3. Symlink the plugin into your SwiftBar plugin folder:
2. Download the latest release plugin into your SwiftBar plugin folder:

```sh
./scripts/install-swiftbar.sh "$HOME/SwiftBarPlugins"
mkdir -p "$HOME/SwiftBarPlugins"
curl -fsSL \
https://github.com/flamerged/agent-watch/releases/latest/download/agent-watch.30s.sh \
-o "$HOME/SwiftBarPlugins/agent-watch.30s.sh"
chmod +x "$HOME/SwiftBarPlugins/agent-watch.30s.sh"
```

SwiftBar will pick up `agent-watch.30s.sh` and refresh every 30 seconds.

### xbar

Agent Watch uses the BitBar/xbar stdout menu format and includes xbar metadata. Install it by copying or symlinking `bin/agent-watch.30s.sh` into your xbar plugin folder.
Agent Watch uses the BitBar/xbar stdout menu format and includes xbar metadata. Install the latest release asset into your xbar plugin folder:

```sh
mkdir -p "$HOME/Library/Application Support/xbar/plugins"
curl -fsSL \
https://github.com/flamerged/agent-watch/releases/latest/download/agent-watch.30s.sh \
-o "$HOME/Library/Application Support/xbar/plugins/agent-watch.30s.sh"
chmod +x "$HOME/Library/Application Support/xbar/plugins/agent-watch.30s.sh"
```

### Development Install

Clone the repo only when you want a source checkout for development:

```sh
git clone https://github.com/flamerged/agent-watch.git
cd agent-watch
./scripts/install-swiftbar.sh "$HOME/SwiftBarPlugins"
```

Release installs show `Update to latest release`, so normal users do not need git. Source checkout installs show the current branch and commit for diagnostics, but hide the menu updater to avoid overwriting checkout-managed files. Development updates should use normal git commands in the checkout.

### Linux

Expand Down Expand Up @@ -77,8 +100,9 @@ The plugin also supports a local config file at `~/.config/agent-watch/config.en
| `AGENTWATCH_UPDATE_CACHE` | `$HOME/.cache/agent-watch/cli-updates.tsv` | Update check cache path |
| `AGENTWATCH_SHOW_CONFIG_ACTIONS` | `0` | Set to `1` to show local config-file open actions |
| `AGENTWATCH_SHOW_BACKEND_ACTIONS` | `0` | Set to `1` to show backend web/log open actions for detected services |
| `AGENTWATCH_REPO_DIR` | empty | Optional Agent Watch git checkout for self-update actions |
| `AGENTWATCH_REPO_DIR` | empty | Optional Agent Watch git checkout for source metadata |
| `AGENTWATCH_REPO_URL` | `https://github.com/flamerged/agent-watch` | Project page opened from the menu |
| `AGENTWATCH_RELEASE_ASSET_URL` | `https://github.com/flamerged/agent-watch/releases/latest/download/agent-watch.30s.sh` | Latest release asset URL used by copied-plugin updates |
| `AGENTWATCH_INTERESTING_PORTS` | `8000,11434,3000,4000,5000` | Comma-separated TCP listening ports to show |

## Privacy And Security
Expand All @@ -95,7 +119,7 @@ The default update-check TTL is one day. Set `AGENTWATCH_UPDATE_TTL_SECONDS` to

The "Watched Local Ports" section is controlled by `AGENTWATCH_INTERESTING_PORTS`. By default it watches the configured oMLX port, the configured Ollama port, and common local development ports `3000`, `4000`, and `5000`.

The Agent Watch section shows the plugin version, config path, and script path. If the plugin can detect a git checkout, it also shows the branch/commit and an `Update from git` action. If the plugin was copied instead of symlinked from a checkout, set `AGENTWATCH_REPO_DIR` to the checkout path or update the copied script manually.
The Agent Watch section shows the plugin version, config path, and script path. Release installs also show `Update to latest release`, which downloads the latest release asset and replaces the plugin script without requiring git. If the plugin can detect a git checkout, it instead shows the branch and commit for diagnostics and leaves updates to normal git commands.

Local config files may reveal model names, provider URLs, and project paths in the menu output. Do not screen-share the menu if those are sensitive.

Expand Down
73 changes: 58 additions & 15 deletions bin/agent-watch.30s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
# <xbar.var>string(AGENTWATCH_UPDATE_TTL_SECONDS="86400"): Seconds between update checks when enabled</xbar.var>
# <xbar.var>boolean(AGENTWATCH_SHOW_CONFIG_ACTIONS=false): Show config-file open actions</xbar.var>
# <xbar.var>boolean(AGENTWATCH_SHOW_BACKEND_ACTIONS=false): Show detected backend web/log open actions</xbar.var>
# <xbar.var>string(AGENTWATCH_REPO_DIR=""): Optional Agent Watch git checkout for self-update actions</xbar.var>
# <xbar.var>string(AGENTWATCH_REPO_DIR=""): Optional Agent Watch git checkout for source metadata</xbar.var>
# <xbar.var>string(AGENTWATCH_REPO_URL="https://github.com/flamerged/agent-watch"): Agent Watch repository URL</xbar.var>
# <xbar.var>string(AGENTWATCH_RELEASE_ASSET_URL="https://github.com/flamerged/agent-watch/releases/latest/download/agent-watch.30s.sh"): Latest release asset URL for copied-plugin updates</xbar.var>
# <xbar.var>string(AGENTWATCH_INTERESTING_PORTS="8000,11434,3000,4000,5000"): TCP ports to show</xbar.var>
# <swiftbar.title>Agent Watch</swiftbar.title>
# <swiftbar.version>v0.3.0</swiftbar.version> # x-release-please-version
Expand Down Expand Up @@ -160,6 +161,7 @@ OPENCODE_CONFIG="${AGENTWATCH_OPENCODE_CONFIG:-$HOME/.config/opencode/opencode.j
SWIFTBAR_PLUGIN_DIR="${AGENTWATCH_SWIFTBAR_PLUGIN_DIR:-$HOME/SwiftBarPlugins}"
AGENTWATCH_REPO_DIR="${AGENTWATCH_REPO_DIR:-}"
AGENTWATCH_REPO_URL="${AGENTWATCH_REPO_URL:-https://github.com/flamerged/agent-watch}"
RELEASE_ASSET_URL="${AGENTWATCH_RELEASE_ASSET_URL:-https://github.com/flamerged/agent-watch/releases/latest/download/agent-watch.30s.sh}"
AGENTMEMORY_LOG="${AGENTWATCH_AGENTMEMORY_LOG:-$HOME/local-agentmemory/logs/agentmemory.log}"
OMLX_URL="$(strip_slash "${AGENTWATCH_OMLX_URL:-http://127.0.0.1:8000}")"
OLLAMA_URL="$(strip_slash "${AGENTWATCH_OLLAMA_URL:-http://127.0.0.1:11434}")"
Expand Down Expand Up @@ -243,17 +245,59 @@ plugin_version_label() {
emit "v${PLUGIN_VERSION}"
}

update_plugin_from_git() {
local root
root="$(plugin_repo_root)"
if [[ -z "$root" ]]; then
print "No Agent Watch git checkout found."
print "Set AGENTWATCH_REPO_DIR to your checkout, or update the copied plugin file manually."
update_plugin_from_release() {
local repo_root
repo_root="$(plugin_repo_root)"
if [[ -n "$repo_root" && "$PLUGIN_PATH" == "$repo_root"/* ]]; then
print "Plugin appears to be running from a git checkout: $repo_root"
print "Use git commands in the checkout for development updates."
return 1
fi

if ! have "$CURL"; then
print "curl is required to update from the latest release."
return 1
fi
print "Updating Agent Watch in $root"
git -C "$root" fetch --tags --prune
git -C "$root" pull --ff-only
if [[ ! -w "$PLUGIN_PATH" || ! -w "$PLUGIN_DIR" ]]; then
print "Plugin file or directory is not writable: $PLUGIN_PATH"
return 1
Comment thread
coderabbitai[bot] marked this conversation as resolved.
fi

local tmp first_line content
tmp="${PLUGIN_DIR}/.agent-watch.30s.sh.$$"
rm -f "$tmp"

print "Downloading latest Agent Watch release asset..."
if ! "$CURL" -fsSL \
--connect-timeout 5 \
--max-time 30 \
--retry 2 \
--retry-delay 1 \
"$RELEASE_ASSET_URL" -o "$tmp"; then
rm -f "$tmp"
print "Download failed: $RELEASE_ASSET_URL"
return 1
fi

IFS= read -r first_line < "$tmp" || first_line=""
content="$(< "$tmp")"
if [[ "$first_line" != "#!/bin/zsh" || "$content" != *"<xbar.title>Agent Watch</xbar.title>"* || "$content" != *"PLUGIN_VERSION=\""* ]]; then
rm -f "$tmp"
print "Downloaded file did not look like an Agent Watch plugin."
return 1
fi

chmod +x "$tmp" || {
rm -f "$tmp"
print "Could not mark downloaded plugin executable."
return 1
}
mv "$tmp" "$PLUGIN_PATH" || {
rm -f "$tmp"
print "Could not replace plugin file: $PLUGIN_PATH"
return 1
}
print "Updated Agent Watch from the latest release."
}

update_cache_age() {
Expand Down Expand Up @@ -323,8 +367,8 @@ case "$ACTION" in
write_default_config && open_text_target "$CONFIG_FILE"
exit $?
;;
update-self)
update_plugin_from_git
update-release)
update_plugin_from_release
exit $?
;;
open)
Expand Down Expand Up @@ -911,10 +955,9 @@ print_plugin_rows() {
git_summary="$(plugin_git_summary "$root")"
emit "--Repo: $(shorten_path "$root") | font=Menlo"
emit "--Git: ${git_summary:-unknown} | font=Menlo"
emit "--Update from git | bash=$PLUGIN_PATH param1=update-self terminal=true refresh=true"
emit "----Use git commands for development updates | color=gray"
else
emit "--No git checkout detected | color=gray"
emit "----Set AGENTWATCH_REPO_DIR to enable git updates | color=gray"
emit "--Update to latest release | bash=$PLUGIN_PATH param1=update-release terminal=true refresh=true"
fi
emit "--Open config file | bash=$PLUGIN_PATH param1=open param2=agent-watch-config terminal=false refresh=true"
emit "--Open project page | bash=$PLUGIN_PATH param1=open param2=agent-watch-repo terminal=false"
Expand Down
Loading