This repository has been archived on 2026-06-13. You can view files and clone it, but cannot push or open issues or pull requests.
anvillm/workflows/Planning

134 lines
5.3 KiB
Bash
Executable File

#!/bin/bash
# Planning - Research/Architect/Techeditor workflow
# Usage: ./scripts/Planning <backend> <workdir>
set -e
if [ $# -ne 2 ]; then
echo "Usage: $0 <backend> <workdir>"
echo " backend: claude, kiro-cli"
exit 1
fi
BACKEND="$1"
DOC_PATH="$2"
# Generate random alias prefix
RANDOM_WORD=$(shuf -n1 -e alpha beta gamma delta zeta theta kappa sigma omega lambda)
RANDOM_NUM=$(printf "%02d" $((RANDOM % 100)))
ALIAS_PREFIX="${RANDOM_WORD}${RANDOM_NUM}"
NAMESPACE=$(namespace)
if [ -z "$NAMESPACE" ]; then
echo "Error: No namespace found. Is anvillm running?"
exit 1
fi
AGENT_MOUNT="agent"
echo "Creating research session..."
before=$(9p read $AGENT_MOUNT/list | awk '{print $1}' | sort)
echo "new $BACKEND $DOC_PATH role=research tasks=plan9,agent-q" | 9p write $AGENT_MOUNT/ctl
after=$(9p read $AGENT_MOUNT/list | awk '{print $1}' | sort)
RESEARCH_ID=$(comm -13 <(echo "$before") <(echo "$after") | head -1)
echo " ID: $RESEARCH_ID"
echo "Creating architect session..."
before=$(9p read $AGENT_MOUNT/list | awk '{print $1}' | sort)
echo "new $BACKEND $DOC_PATH role=architect tasks=git,plan9,agent-q" | 9p write $AGENT_MOUNT/ctl
after=$(9p read $AGENT_MOUNT/list | awk '{print $1}' | sort)
ARCH_ID=$(comm -13 <(echo "$before") <(echo "$after") | head -1)
echo " ID: $ARCH_ID"
echo "Creating techeditor session..."
before=$(9p read $AGENT_MOUNT/list | awk '{print $1}' | sort)
echo "new $BACKEND $DOC_PATH role=techeditor tasks=git,plan9,agent-q" | 9p write $AGENT_MOUNT/ctl
after=$(9p read $AGENT_MOUNT/list | awk '{print $1}' | sort)
EDITOR_ID=$(comm -13 <(echo "$before") <(echo "$after") | head -1)
echo " ID: $EDITOR_ID"
# Set aliases
echo "${ALIAS_PREFIX}-research" | 9p write $AGENT_MOUNT/$RESEARCH_ID/alias
echo "${ALIAS_PREFIX}-architect" | 9p write $AGENT_MOUNT/$ARCH_ID/alias
echo "${ALIAS_PREFIX}-techeditor" | 9p write $AGENT_MOUNT/$EDITOR_ID/alias
# Research context
cat <<EOF | 9p write $AGENT_MOUNT/$RESEARCH_ID/context
Your job is to provide answers to questions by researching existing knowledge base documents, the web, and the code base.
You are a research agent in a three-agent AnviLLM workflow. Your peers are the architect and techeditor.
- Input: knowledge base (agent-kb) and relevant code
- Output: concrete human- and LLM-readable knowledge about the system
- Prefer updating existing kb documents over creating new ones
- Only create new KB documents if the knowledge discovered is significant and reusable
When you receive a query from the architect, research and respond using shell tool with these exact commands:
cat > /tmp/msg.json <<'ENDMSG'
{"to":"$ARCH_ID","type":"QUERY_RESPONSE","subject":"Research results","body":"YOUR_ANSWER_HERE"}
ENDMSG
9p write agent/$RESEARCH_ID/mail < /tmp/msg.json
Replace YOUR_ANSWER_HERE with actual answer
Do not actively await responses, but stop working until you receive an explicit request to conduct research.
EOF
# Architect context
cat <<EOF | 9p write $AGENT_MOUNT/$ARCH_ID/context
Your job is to update design documentation in $DOC_PATH. Follow agent-kb conventions. Search the knowledge base for relevant documents.
You are an architect agent in a three-agent AnviLLM workflow. Your peers are the research agent and techeditor.
If documentation is insufficient, query the research bot using shell tool with these exact commands:
cat > /tmp/msg.json <<'ENDMSG'
{"to":"$RESEARCH_ID","type":"QUERY_REQUEST","subject":"Research request","body":"YOUR_QUESTION_HERE"}
ENDMSG
9p write agent/$ARCH_ID/mail < /tmp/msg.json
Replace YOUR_QUESTION_HERE (include question, context, request for docs path or answer)
Wait for the research agent to send the answer back
You will receive edit requests from the techeditor. Apply changes and send acknowledgment using shell tool:
cat > /tmp/msg.json <<'ENDMSG'
{"to":"$EDITOR_ID","type":"LOG_INFO","subject":"Changes applied","body":"YOUR_ACKNOWLEDGMENT"}
ENDMSG
9p write agent/$ARCH_ID/mail < /tmp/msg.json
Replace YOUR_ACKNOWLEDGMENT with actual acknowledgment
Do not actively await responses, but stop working until you receive an explicit request to make a change from the techeditor.
EOF
# Tech-editor context
cat <<EOF | 9p write $AGENT_MOUNT/$EDITOR_ID/context
You are a professional technical writer in a three-agent AnviLLM workflow. Your peers are the research agent and architect. Ensure documentation in $DOC_PATH is high quality, readable, and at the right detail level for software engineers.
Do not edit documents directly. Send recommended changes to the architect using shell tool with these exact commands:
cat > /tmp/msg.json <<'ENDMSG'
{"to":"$ARCH_ID","type":"REVIEW_REQUEST","subject":"Documentation review","body":"YOUR_RECOMMENDATIONS"}
ENDMSG
9p write agent/$EDITOR_ID/mail < /tmp/msg.json
Replace YOUR_RECOMMENDATIONS with actual recommendations
Request acknowledgment from the architect
When the architect acknowledges, proofread again. Iterate until satisfied.
Do not actively await responses, but stop working until you receive an explicit request to perform work.
EOF
echo ""
echo "✓ Planning workflow ready ($ALIAS_PREFIX)"
echo ""
echo "Sessions:"
echo " ${ALIAS_PREFIX}-research: $RESEARCH_ID"
echo " ${ALIAS_PREFIX}-architect: $ARCH_ID"
echo " ${ALIAS_PREFIX}-techeditor: $EDITOR_ID"
echo ""
echo "Start by giving the architect a task, or techeditor a document to review."