feat(kugetsu): add KUGETSU_VERBOSITY for PM agent output control #95

Closed
shoko wants to merge 3 commits from feat/issue-46-verbosity-v2 into main
Showing only changes of commit 534cd95993 - Show all commits

View File

@@ -9,6 +9,7 @@ INDEX_FILE="$KUGETSU_DIR/index.json"
NOTIFICATIONS_FILE="$KUGETSU_DIR/notifications.json" NOTIFICATIONS_FILE="$KUGETSU_DIR/notifications.json"
LOGS_DIR="$KUGETSU_DIR/logs" LOGS_DIR="$KUGETSU_DIR/logs"
ENV_DIR="${ENV_DIR:-$KUGETSU_DIR/env}" ENV_DIR="${ENV_DIR:-$KUGETSU_DIR/env}"
VERBOSITY_DIR="$KUGETSU_DIR/verbosity"
MAX_CONCURRENT_AGENTS="${MAX_CONCURRENT_AGENTS:-3}" MAX_CONCURRENT_AGENTS="${MAX_CONCURRENT_AGENTS:-3}"
KUGETSU_VERBOSITY="${KUGETSU_VERBOSITY:-total}" KUGETSU_VERBOSITY="${KUGETSU_VERBOSITY:-total}"
@@ -546,6 +547,62 @@ cmd_status() {
echo "ok" echo "ok"
} }
get_verbosity_context() {
local verbosity="${KUGETSU_VERBOSITY:-total}"
local verbosity_file="$VERBOSITY_DIR/${verbosity}.md"
if [ -f "$verbosity_file" ]; then
cat "$verbosity_file"
else
echo "## Verbosity: $verbosity"
echo "Verbosity level: $verbosity"
fi
}
init_verbosity_templates() {
mkdir -p "$VERBOSITY_DIR"
if [ ! -f "$VERBOSITY_DIR/total.md" ]; then
cat > "$VERBOSITY_DIR/total.md" << 'EOF'
## Verbosity: Total
You are operating in HIGH verbosity mode. Include ALL available context:
- Full command outputs and their results
- Detailed reasoning and thinking process
- All file changes with diffs when relevant
- Complete log excerpts
- Comprehensive status updates
- Ask clarifying questions when uncertain
EOF
fi
if [ ! -f "$VERBOSITY_DIR/medium.md" ]; then
cat > "$VERBOSITY_DIR/medium.md" << 'EOF'
## Verbosity: Medium
You are operating in MEDIUM verbosity mode. Provide balanced output:
- Standard command outputs and key results
- Moderate reasoning detail
- Important file changes summarized
- Relevant log excerpts (not full)
- Regular status updates
EOF
fi
if [ ! -f "$VERBOSITY_DIR/quiet.md" ]; then
cat > "$VERBOSITY_DIR/quiet.md" << 'EOF'
## Verbosity: Quiet
You are operating in QUIET/MINIMAL verbosity mode. Keep output minimal:
- Only essential information
- Brief status updates (1-2 sentences)
- Final decisions only
- Yes/No answers when appropriate
- Skip detailed explanations unless requested
EOF
fi
}
cmd_delegate() { cmd_delegate() {
local message="${1:-}" local message="${1:-}"
local verbosity="${KUGETSU_VERBOSITY:-total}" local verbosity="${KUGETSU_VERBOSITY:-total}"
@@ -568,6 +625,13 @@ cmd_delegate() {
local temp_dir="${KUGETSU_TEMP_DIR:-$HOME/.local/share/opencode/tool-output}" local temp_dir="${KUGETSU_TEMP_DIR:-$HOME/.local/share/opencode/tool-output}"
mkdir -p "$ENV_DIR" mkdir -p "$ENV_DIR"
init_verbosity_templates
local verbosity_context=$(get_verbosity_context)
local full_message="${verbosity_context}
${message}"
local env_sh="set -a; export KUGETSU_TEMP_DIR='$temp_dir'; export KUGETSU_VERBOSITY='$verbosity'; " local env_sh="set -a; export KUGETSU_TEMP_DIR='$temp_dir'; export KUGETSU_VERBOSITY='$verbosity'; "
if [ -f "$ENV_DIR/pm-agent.env" ]; then if [ -f "$ENV_DIR/pm-agent.env" ]; then
env_sh="${env_sh}source '$ENV_DIR/pm-agent.env'; " env_sh="${env_sh}source '$ENV_DIR/pm-agent.env'; "
@@ -576,7 +640,7 @@ cmd_delegate() {
fi fi
env_sh="${env_sh}set +a; " env_sh="${env_sh}set +a; "
nohup sh -c "${env_sh}opencode run '$message' --continue --session '$pm_session' >> '$log_file' 2>&1" > /dev/null 2>&1 & nohup sh -c "${env_sh}opencode run '$full_message' --continue --session '$pm_session' >> '$log_file' 2>&1" > /dev/null 2>&1 &
disown disown
echo "Delegated to PM agent (logged to $(basename "$log_file"))" echo "Delegated to PM agent (logged to $(basename "$log_file"))"
echo "Verbosity: $verbosity" echo "Verbosity: $verbosity"