mcptools: convert optional positional args to named flags

spawn_agent.sh: --cwd, --prompt
mail_history.sh: --date
mail_search.sh: --pattern, --date
claim_bead.sh: --assignee
mark_pending_approval.sh: --assignee
mark_pending_review.sh: --assignee
fail_bead.sh: --reason
comment_bead.sh: --text

Update beads, anvillm-sessions, anvillm-communication SKILL.md to match.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Levi Neely 2026-03-14 13:24:03 +01:00
parent 014831e500
commit 9ebf90f564
11 changed files with 142 additions and 43 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
# capabilities: beads
# description: Claim a bead for work
# Usage: claim_bead.sh <mount> <bead-id> [assignee]
# Usage: claim_bead.sh <mount> <bead-id> [--assignee <id>]
set -euo pipefail
if cat /etc/shadow >/dev/null 2>&1; then
@ -10,13 +10,22 @@ if cat /etc/shadow >/dev/null 2>&1; then
fi
if [ $# -lt 2 ]; then
echo "usage: claim_bead.sh <mount> <bead-id> [assignee]" >&2
echo "usage: claim_bead.sh <mount> <bead-id> [--assignee <id>]" >&2
exit 1
fi
MOUNT="$1"
BEAD_ID="$2"
ASSIGNEE="${3:-}"
shift 2
ASSIGNEE=""
while [[ $# -gt 0 ]]; do
case "$1" in
--assignee) ASSIGNEE="$2"; shift 2 ;;
*) echo "unknown argument: $1" >&2; exit 1 ;;
esac
done
if [ -n "$ASSIGNEE" ]; then
echo "claim $BEAD_ID $ASSIGNEE" | 9p write anvillm/beads/$MOUNT/ctl

View File

@ -1,7 +1,7 @@
#!/bin/bash
# capabilities: beads
# description: Add a comment to a bead
# Usage: comment_bead.sh <mount> <bead-id> <text>
# Usage: comment_bead.sh <mount> <bead-id> --text <text>
set -euo pipefail
if cat /etc/shadow >/dev/null 2>&1; then
@ -9,15 +9,28 @@ if cat /etc/shadow >/dev/null 2>&1; then
exit 1
fi
if [ $# -lt 3 ]; then
echo "usage: comment_bead.sh <mount> <bead-id> <text>" >&2
if [ $# -lt 2 ]; then
echo "usage: comment_bead.sh <mount> <bead-id> --text <text>" >&2
exit 1
fi
MOUNT="$1"
BEAD_ID="$2"
shift 2
TEXT="$*"
TEXT=""
while [[ $# -gt 0 ]]; do
case "$1" in
--text) TEXT="$2"; shift 2 ;;
*) echo "unknown argument: $1" >&2; exit 1 ;;
esac
done
if [ -z "$TEXT" ]; then
echo "error: --text is required" >&2
exit 1
fi
printf "comment %s '%s'\n" "$BEAD_ID" "$TEXT" | 9p write anvillm/beads/$MOUNT/ctl
echo "commented on $BEAD_ID"

View File

@ -1,7 +1,7 @@
#!/bin/bash
# capabilities: beads
# description: Fail a bead with reason
# Usage: fail_bead.sh <mount> <bead-id> <reason>
# Usage: fail_bead.sh <mount> <bead-id> --reason <reason>
set -euo pipefail
if cat /etc/shadow >/dev/null 2>&1; then
@ -9,15 +9,28 @@ if cat /etc/shadow >/dev/null 2>&1; then
exit 1
fi
if [ $# -lt 3 ]; then
echo "usage: fail_bead.sh <mount> <bead-id> <reason>" >&2
if [ $# -lt 2 ]; then
echo "usage: fail_bead.sh <mount> <bead-id> --reason <reason>" >&2
exit 1
fi
MOUNT="$1"
BEAD_ID="$2"
shift 2
REASON="$*"
REASON=""
while [[ $# -gt 0 ]]; do
case "$1" in
--reason) REASON="$2"; shift 2 ;;
*) echo "unknown argument: $1" >&2; exit 1 ;;
esac
done
if [ -z "$REASON" ]; then
echo "error: --reason is required" >&2
exit 1
fi
printf "fail %s '%s'\n" "$BEAD_ID" "$REASON" | 9p write anvillm/beads/$MOUNT/ctl
echo "failed $BEAD_ID: $REASON"

View File

@ -1,13 +1,23 @@
#!/bin/bash
# Display message history for an agent or user. Pipe through grep -E for search.
# Display message history for an agent or user.
# Usage: mail_history.sh <agent-id|user> [--date YYYYMMdd]
set -euo pipefail
AGENT_ID="${1:-}"
DATE_FILTER="${2:-}"
if [[ -z "$AGENT_ID" ]]; then
echo "Usage: $0 <agent-id|user> [YYYYMMdd]" >&2
echo "Usage: $0 <agent-id|user> [--date YYYYMMdd]" >&2
exit 1
fi
shift
DATE_FILTER=""
while [[ $# -gt 0 ]]; do
case "$1" in
--date) DATE_FILTER="$2"; shift 2 ;;
*) echo "unknown argument: $1" >&2; exit 1 ;;
esac
done
MAIL_DIR="$HOME/.local/share/anvillm/mail/$AGENT_ID"

View File

@ -1,15 +1,29 @@
#!/bin/bash
# Search message history for an agent or user by regex pattern.
# Usage: mail_search.sh <agent-id|user> <pattern> [YYYYMMdd]
# Usage: mail_search.sh <agent-id|user> --pattern <regex> [--date YYYYMMdd]
set -euo pipefail
AGENT_ID="${1:-}"
PATTERN="${2:-}"
DATE_FILTER="${3:-}"
if [[ -z "$AGENT_ID" ]]; then
echo "Usage: $0 <agent-id|user> --pattern <regex> [--date YYYYMMdd]" >&2
exit 1
fi
shift
if [[ -z "$AGENT_ID" || -z "$PATTERN" ]]; then
echo "Usage: $0 <agent-id|user> <pattern> [YYYYMMdd]" >&2
PATTERN=""
DATE_FLAG=""
while [[ $# -gt 0 ]]; do
case "$1" in
--pattern) PATTERN="$2"; shift 2 ;;
--date) DATE_FLAG="--date $2"; shift 2 ;;
*) echo "unknown argument: $1" >&2; exit 1 ;;
esac
done
if [[ -z "$PATTERN" ]]; then
echo "error: --pattern is required" >&2
exit 1
fi
bash <(9p read anvillm/tools/mail_history.sh) "$AGENT_ID" "$DATE_FILTER" | grep -E "$PATTERN"
bash <(9p read anvillm/tools/mail_history.sh) "$AGENT_ID" $DATE_FLAG | grep -E "$PATTERN"

View File

@ -1,7 +1,7 @@
#!/bin/bash
# capabilities: beads
# description: Mark a bead as pending approval
# Usage: mark_pending_approval.sh <mount> <bead-id> [assignee]
# Usage: mark_pending_approval.sh <mount> <bead-id> [--assignee <id>]
set -euo pipefail
if cat /etc/shadow >/dev/null 2>&1; then
@ -10,13 +10,22 @@ if cat /etc/shadow >/dev/null 2>&1; then
fi
if [ $# -lt 2 ]; then
echo "usage: mark_pending_approval.sh <mount> <bead-id> [assignee]" >&2
echo "usage: mark_pending_approval.sh <mount> <bead-id> [--assignee <id>]" >&2
exit 1
fi
MOUNT="$1"
BEAD_ID="$2"
ASSIGNEE="${3:-}"
shift 2
ASSIGNEE=""
while [[ $# -gt 0 ]]; do
case "$1" in
--assignee) ASSIGNEE="$2"; shift 2 ;;
*) echo "unknown argument: $1" >&2; exit 1 ;;
esac
done
if [ -n "$ASSIGNEE" ]; then
echo "pending-approval $BEAD_ID $ASSIGNEE" | 9p write anvillm/beads/$MOUNT/ctl

View File

@ -1,7 +1,7 @@
#!/bin/bash
# capabilities: beads
# description: Mark a bead as pending review
# Usage: mark_pending_review.sh <mount> <bead-id> [assignee]
# Usage: mark_pending_review.sh <mount> <bead-id> [--assignee <id>]
set -euo pipefail
if cat /etc/shadow >/dev/null 2>&1; then
@ -10,13 +10,22 @@ if cat /etc/shadow >/dev/null 2>&1; then
fi
if [ $# -lt 2 ]; then
echo "usage: mark_pending_review.sh <mount> <bead-id> [assignee]" >&2
echo "usage: mark_pending_review.sh <mount> <bead-id> [--assignee <id>]" >&2
exit 1
fi
MOUNT="$1"
BEAD_ID="$2"
ASSIGNEE="${3:-}"
shift 2
ASSIGNEE=""
while [[ $# -gt 0 ]]; do
case "$1" in
--assignee) ASSIGNEE="$2"; shift 2 ;;
*) echo "unknown argument: $1" >&2; exit 1 ;;
esac
done
if [ -n "$ASSIGNEE" ]; then
echo "pending-review $BEAD_ID $ASSIGNEE" | 9p write anvillm/beads/$MOUNT/ctl

View File

@ -1,24 +1,29 @@
#!/bin/bash
# capabilities: agents
# description: Spawn a new agent session (do not use execute_code): <agent-id> [cwd-path] [initial-context-prompt]
# description: Spawn a new agent session
# Usage: spawn_agent.sh <agent-id> [--cwd <path>] [--prompt <initial-context>]
set -euo pipefail
agent_id="${1:?Usage: spawn_agent.sh <agent-id> [cwd-path] [initial-context-prompt]}"
agent_id="${1:?Usage: spawn_agent.sh <agent-id> [--cwd <path>] [--prompt <text>]}"
shift
if [ -d "${2:-}" ]; then
cwd="$2"
prompt="${3:-}"
else
cwd="$PWD"
prompt="${2:-}"
fi
cwd="$PWD"
prompt=""
while [[ $# -gt 0 ]]; do
case "$1" in
--cwd) cwd="$2"; shift 2 ;;
--prompt) prompt="$2"; shift 2 ;;
*) echo "unknown argument: $1" >&2; exit 1 ;;
esac
done
backend=$(9p read "anvillm/$agent_id/backend")
echo "new $backend $cwd" | 9p write anvillm/ctl
if [ -n "$prompt" ]; then
session_id=$(9p read anvillm/list 2>/dev/null | awk -F'\t' -v cwd="$cwd" '$5 == cwd {print $1; exit}')
if [ -n "$session_id" ]; then
echo "$prompt" | 9p write "anvillm/$session_id/context"
fi
session_id=$(9p read anvillm/list 2>/dev/null | awk -F'\t' -v cwd="$cwd" '$5 == cwd {print $1; exit}')
if [ -n "$session_id" ]; then
echo "$prompt" | 9p write "anvillm/$session_id/context"
fi
fi

View File

@ -31,6 +31,22 @@ Tool: execute_code
tool: read_inbox.sh
```
View message history:
```
Tool: execute_code
tool: mail_history.sh
args: ["<agent-id|user>", "--date", "YYYYMMdd"]
```
`--date` is optional. Omit to see all history.
Search message history:
```
Tool: execute_code
tool: mail_search.sh
args: ["<agent-id|user>", "--pattern", "<regex>", "--date", "YYYYMMdd"]
```
`--date` is optional.
## Rules
### Discovering Agents

View File

@ -34,9 +34,10 @@ Spawn agent (requires default sandbox):
```
Tool: execute_code
tool: spawn_agent.sh
args: ["<agent-id>", "<cwd-path>", "<initial-context-prompt>"]
args: ["<agent-id>", "--cwd", "<cwd-path>", "--prompt", "<initial-context>"]
sandbox: default
```
`--cwd` defaults to `$PWD`. `--prompt` is optional.
Kill agent:
```

View File

@ -81,7 +81,7 @@ Claim bead:
```
Tool: execute_code
tool: claim_bead.sh
args: ["<mount>", "<id>", "$AGENT_ID"]
args: ["<mount>", "<id>", "--assignee", "$AGENT_ID"]
```
Complete bead:
@ -95,7 +95,7 @@ Fail bead:
```
Tool: execute_code
tool: fail_bead.sh
args: ["<mount>", "<id>", "<reason>"]
args: ["<mount>", "<id>", "--reason", "<reason>"]
```
Create bead (starts deferred — use open_bead.sh when ready):
@ -154,7 +154,7 @@ Comment on bead:
```
Tool: execute_code
tool: comment_bead.sh
args: ["<mount>", "<id>", "<text>"]
args: ["<mount>", "<id>", "--text", "<text>"]
```
Label bead: