diff --git a/mcptools/claim_bead.sh b/mcptools/claim_bead.sh index d5fe4ae..569809b 100755 --- a/mcptools/claim_bead.sh +++ b/mcptools/claim_bead.sh @@ -1,7 +1,7 @@ #!/bin/bash # capabilities: beads # description: Claim a bead for work -# Usage: claim_bead.sh [assignee] +# Usage: claim_bead.sh [--assignee ] 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 [assignee]" >&2 + echo "usage: claim_bead.sh [--assignee ]" >&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 diff --git a/mcptools/comment_bead.sh b/mcptools/comment_bead.sh index c46ca38..8ecdb91 100755 --- a/mcptools/comment_bead.sh +++ b/mcptools/comment_bead.sh @@ -1,7 +1,7 @@ #!/bin/bash # capabilities: beads # description: Add a comment to a bead -# Usage: comment_bead.sh +# Usage: comment_bead.sh --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 " >&2 +if [ $# -lt 2 ]; then + echo "usage: comment_bead.sh --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" diff --git a/mcptools/fail_bead.sh b/mcptools/fail_bead.sh index 547b95d..c898136 100755 --- a/mcptools/fail_bead.sh +++ b/mcptools/fail_bead.sh @@ -1,7 +1,7 @@ #!/bin/bash # capabilities: beads # description: Fail a bead with reason -# Usage: fail_bead.sh +# Usage: fail_bead.sh --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 " >&2 +if [ $# -lt 2 ]; then + echo "usage: fail_bead.sh --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" diff --git a/mcptools/mail_history.sh b/mcptools/mail_history.sh index 9c8a8f6..7ff368d 100755 --- a/mcptools/mail_history.sh +++ b/mcptools/mail_history.sh @@ -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 [--date YYYYMMdd] set -euo pipefail AGENT_ID="${1:-}" -DATE_FILTER="${2:-}" if [[ -z "$AGENT_ID" ]]; then - echo "Usage: $0 [YYYYMMdd]" >&2 + echo "Usage: $0 [--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" diff --git a/mcptools/mail_search.sh b/mcptools/mail_search.sh index fab2e46..6796376 100755 --- a/mcptools/mail_search.sh +++ b/mcptools/mail_search.sh @@ -1,15 +1,29 @@ #!/bin/bash # Search message history for an agent or user by regex pattern. -# Usage: mail_search.sh [YYYYMMdd] +# Usage: mail_search.sh --pattern [--date YYYYMMdd] set -euo pipefail AGENT_ID="${1:-}" -PATTERN="${2:-}" -DATE_FILTER="${3:-}" +if [[ -z "$AGENT_ID" ]]; then + echo "Usage: $0 --pattern [--date YYYYMMdd]" >&2 + exit 1 +fi +shift -if [[ -z "$AGENT_ID" || -z "$PATTERN" ]]; then - echo "Usage: $0 [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" diff --git a/mcptools/mark_pending_approval.sh b/mcptools/mark_pending_approval.sh index 91c1d36..e70dd1a 100755 --- a/mcptools/mark_pending_approval.sh +++ b/mcptools/mark_pending_approval.sh @@ -1,7 +1,7 @@ #!/bin/bash # capabilities: beads # description: Mark a bead as pending approval -# Usage: mark_pending_approval.sh [assignee] +# Usage: mark_pending_approval.sh [--assignee ] 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 [assignee]" >&2 + echo "usage: mark_pending_approval.sh [--assignee ]" >&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 diff --git a/mcptools/mark_pending_review.sh b/mcptools/mark_pending_review.sh index c6d2b7e..0934b94 100755 --- a/mcptools/mark_pending_review.sh +++ b/mcptools/mark_pending_review.sh @@ -1,7 +1,7 @@ #!/bin/bash # capabilities: beads # description: Mark a bead as pending review -# Usage: mark_pending_review.sh [assignee] +# Usage: mark_pending_review.sh [--assignee ] 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 [assignee]" >&2 + echo "usage: mark_pending_review.sh [--assignee ]" >&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 diff --git a/mcptools/spawn_agent.sh b/mcptools/spawn_agent.sh index 07db198..452f397 100755 --- a/mcptools/spawn_agent.sh +++ b/mcptools/spawn_agent.sh @@ -1,24 +1,29 @@ #!/bin/bash # capabilities: agents -# description: Spawn a new agent session (do not use execute_code): [cwd-path] [initial-context-prompt] +# description: Spawn a new agent session +# Usage: spawn_agent.sh [--cwd ] [--prompt ] set -euo pipefail -agent_id="${1:?Usage: spawn_agent.sh [cwd-path] [initial-context-prompt]}" +agent_id="${1:?Usage: spawn_agent.sh [--cwd ] [--prompt ]}" +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 diff --git a/skills/anvillm-communication/SKILL.md b/skills/anvillm-communication/SKILL.md index 5f80136..e6ff66d 100644 --- a/skills/anvillm-communication/SKILL.md +++ b/skills/anvillm-communication/SKILL.md @@ -31,6 +31,22 @@ Tool: execute_code tool: read_inbox.sh ``` +View message history: +``` +Tool: execute_code +tool: mail_history.sh +args: ["", "--date", "YYYYMMdd"] +``` +`--date` is optional. Omit to see all history. + +Search message history: +``` +Tool: execute_code +tool: mail_search.sh +args: ["", "--pattern", "", "--date", "YYYYMMdd"] +``` +`--date` is optional. + ## Rules ### Discovering Agents diff --git a/skills/anvillm-sessions/SKILL.md b/skills/anvillm-sessions/SKILL.md index 45144fe..63eb885 100644 --- a/skills/anvillm-sessions/SKILL.md +++ b/skills/anvillm-sessions/SKILL.md @@ -34,9 +34,10 @@ Spawn agent (requires default sandbox): ``` Tool: execute_code tool: spawn_agent.sh -args: ["", "", ""] +args: ["", "--cwd", "", "--prompt", ""] sandbox: default ``` +`--cwd` defaults to `$PWD`. `--prompt` is optional. Kill agent: ``` diff --git a/skills/beads/SKILL.md b/skills/beads/SKILL.md index e63f65d..dc7e5f4 100644 --- a/skills/beads/SKILL.md +++ b/skills/beads/SKILL.md @@ -81,7 +81,7 @@ Claim bead: ``` Tool: execute_code tool: claim_bead.sh -args: ["", "", "$AGENT_ID"] +args: ["", "", "--assignee", "$AGENT_ID"] ``` Complete bead: @@ -95,7 +95,7 @@ Fail bead: ``` Tool: execute_code tool: fail_bead.sh -args: ["", "", ""] +args: ["", "", "--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: ["", "", ""] +args: ["", "", "--text", ""] ``` Label bead: