diff --git a/.claude-plugin/marketplace.json b/.claude-plugin/marketplace.json index 1252044..9d46654 100644 --- a/.claude-plugin/marketplace.json +++ b/.claude-plugin/marketplace.json @@ -10,7 +10,7 @@ { "name": "devscope", "description": "Real-time developer activity monitoring for Claude Code sessions", - "version": "0.31.0", + "version": "0.32.0", "author": { "name": "Lucas Dow", "email": "lucdow7@gmail.com" diff --git a/.claude-plugin/plugin.json b/.claude-plugin/plugin.json index f7ccd16..853613c 100644 --- a/.claude-plugin/plugin.json +++ b/.claude-plugin/plugin.json @@ -1,6 +1,6 @@ { "name": "devscope", - "version": "0.31.0", + "version": "0.32.0", "description": "Real-time developer activity monitoring for Claude Code sessions", "author": { "name": "Lucas Dow", diff --git a/CHANGELOG.md b/CHANGELOG.md index 74cc7a9..dd64f89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/). +## [0.32.0] - 2026-10-08 + +### Added +- **Voice says which session it is talking about.** Announcements and auto + voice summaries start with the session's name, the project plus what it is + working on ("api-service, rate limiter fix"), so several sessions can be + told apart by ear. The plugin sends `session_id` to `/api/ai/voice-summary`; + the server names the session from its title, else its branch, and returns + the name as `label`. The first label is kept per session + (`~/.cache/devscope/voice/labels/`) and sent back, so a session keeps one + name even when its title changes. When the server is unreachable the local + sentence starts with the kept label; `private` sessions are named from the + local git branch, which is never sent. The "N sessions need you" sentence + names each as "rate limiter fix in api-service". +- The voice hook now runs after `send-event.sh` resolves the DevScope session + id, so the id voice sends (and keys its labels by) is the one the session's + events are recorded under. +- Needs a DevScope server with session labels for the server-built names; + older servers ignore the new fields and answer as before. + ## [0.31.0] - 2026-10-07 ### Added diff --git a/CLAUDE.md b/CLAUDE.md index 1b2b545..66d29ce 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -219,6 +219,13 @@ claude plugin disable devscope@devscope # Disable no voice or is unreachable it falls back to Piper if installed (`/devscope:voice setup`), else `say`/`spd-say`/`espeak`. What is sent follows the privacy mode: `standard` sends no more than its events do. Tests: `tests/voice/run.sh`. +- **Session labels** (`labels/`): every summary request sends `session_id` and, once known, + the session's `label`. The server answers with text that already starts with the label and returns + `label` ("project, topic" from the session title, else its branch); `_ds_voice_summary` keeps the + first one per session and it is sent back on later calls, so a session's spoken name never changes. + Fallback templates start with the kept label, else project + local branch (`_ds_voice_name`; the + branch is read with `git symbolic-ref` at arm time, stored in the job file, never sent), and the + batch sentence says "topic in project" (`_ds_voice_batch_name`) so labels' commas do not merge. - **Auto voice** (opt-in) is per Claude Code window: `/devscope:voice auto` writes `auto/` (`on`/`off`; the PID comes from Claude Code's `CLAUDE_PID`, else a walk up the process tree, so it survives `/clear`), and windows without one follow `speak_replies` in voice.json (`/devscope:voice auto-default`). diff --git a/README.md b/README.md index 2b51063..24c0da0 100644 --- a/README.md +++ b/README.md @@ -204,11 +204,12 @@ feature can be turned off in `/config` under the plugin's options. The Running several sessions, or working in another window? `/devscope:voice on` makes DevScope tell you out loud when a session has been waiting on you for a while: -> "devscope-cloud wants to run the database migration and is waiting for your approval." +> "devscope-cloud, rate limiter fix. It wants to run the database migration and is waiting for your approval." - **Only when you've lost track.** It speaks after a grace delay (30 s for permission prompts and questions, 10 s for failed turns). Answer in time and it stays silent. If you don't, it reminds you every 5 minutes, up to 3 times. -- **Across all sessions.** Announcements play one at a time, and three or more at once become one sentence ("three sessions need you: ..."). -- **Summaries follow your privacy mode.** Sentences are written by DevScope's AI from what your privacy mode already sends. `private` sessions never leave your machine and use a local template. +- **Says which session.** Every announcement and reply summary starts with the session's name: the project plus what it is working on, from the session's title or its git branch ("devscope-cloud, rate limiter fix"). A session keeps the same name for its whole life, so with several running you know which one is talking. +- **Across all sessions.** Announcements play one at a time, and three or more at once become one sentence ("three sessions need you: rate limiter fix in devscope-cloud, oauth login in web and docs"). +- **Summaries follow your privacy mode.** Sentences are written by DevScope's AI from what your privacy mode already sends. `private` sessions never leave your machine and use a local template, named from the local git branch. - **Natural voice, nothing to install.** Speech is voiced by your DevScope server. Which voices it offers is up to the server; the homelab offers **Chatterbox Turbo** (the default, on its GPU) and **Kokoro** (on its CPU, also the fallback when the GPU is busy). `/devscope:voice model` lists them, `/devscope:voice model kokoro` picks one for you, `model default` goes back to the server's choice. - **Local mode, for Macs.** `/devscope:voice model local` speaks with this computer's own voice instead (`say` on macOS), with no audio from the server. It uses your System voice, so to hear a Siri voice pick one in System Settings → Accessibility → Spoken Content → System voice. The DevScope server still writes the auto voice summaries; only the voice is local. `model chatterbox` (or another server voice) switches back. Speed with `/devscope:voice speed`, volume with `volume` in `voice.json` (how loud the server makes the speech) and `playback_volume` (how loud this computer plays it, without turning up its other sounds). `private` sessions, and any time the server can't be reached, use a local voice instead: [Piper](https://github.com/rhasspy/piper) if you ran `/devscope:voice setup` (Linux; `pipx install piper-tts` on macOS), otherwise the system voice (`say`, `spd-say`, `espeak`). diff --git a/scripts/send-event.sh b/scripts/send-event.sh index 18c5f4b..3477ac5 100755 --- a/scripts/send-event.sh +++ b/scripts/send-event.sh @@ -16,11 +16,6 @@ SESSION_ID=$(echo "$INPUT" | jq -r '.session_id // empty') CWD=$(echo "$INPUT" | jq -r '.cwd // empty') PROJECT_NAME=$(basename "$CWD" 2>/dev/null || echo "unknown") -# Voice announcer: arm or clear this session's "needs you" marker before the -# network round trip, so it never waits on the backend. No-op unless enabled. -# shellcheck disable=SC1091 -{ . "$SCRIPT_DIR/voice/lib.sh" && _ds_voice_on_event "$EVENT_TYPE" "$INPUT"; } 2>/dev/null || true - # Session continuity: use DevScope session ID if available # PPID identifies the Claude Code process, keeping concurrent sessions separate if [ -n "$CWD" ]; then @@ -36,6 +31,13 @@ if [ -n "$CWD" ]; then fi fi +# Voice announcer: arm or clear this session's "needs you" marker before the +# network round trip, so it never waits on the backend. No-op unless enabled. +# Placed after the lookup above so voice names the session by its DevScope id, +# which outlives /clear and resume (Claude Code's own id does not). +# shellcheck disable=SC1091 +{ DS_VOICE_SESSION="$SESSION_ID"; . "$SCRIPT_DIR/voice/lib.sh" && _ds_voice_on_event "$EVENT_TYPE" "$INPUT"; } 2>/dev/null || true + DEV_NAME=$(git -C "$CWD" config user.name 2>/dev/null || echo "$USER") DEV_EMAIL=$(git -C "$CWD" config user.email 2>/dev/null || echo "${USER}@local") # Normalize before hashing so developerId matches the backend's diff --git a/scripts/voice/lib.sh b/scripts/voice/lib.sh index 9a96791..3937e02 100755 --- a/scripts/voice/lib.sh +++ b/scripts/voice/lib.sh @@ -13,6 +13,8 @@ # time keeps the announcer silent. # replies/.json the latest finished turn to summarize, per session. # say/.json an explanation waiting to be spoken. +# labels/ the session's spoken name from the server ("api-service, +# rate limiter fix"), kept so a session keeps one name. # spoke/ this turn already spoke an explanation, so its # reply is not summarized on top of it. # auto/ "on" or "off": auto voice for that Claude Code @@ -82,7 +84,84 @@ DS_VOICE_REPLY_TAIL=1100 # State and log can hold summaries of the user's work: keep them owner-only. _ds_voice_mkdirs() { ( umask 077; mkdir -p "$DS_VOICE_PENDING" "$DS_VOICE_DIR/replies" "$DS_VOICE_DIR/say" \ - "$DS_VOICE_DIR/spoke" "$DS_VOICE_DIR/speakers" "$DS_VOICE_DIR/auto" ) 2>/dev/null + "$DS_VOICE_DIR/spoke" "$DS_VOICE_DIR/speakers" "$DS_VOICE_DIR/auto" "$DS_VOICE_DIR/labels" ) 2>/dev/null +} + +# --- Session labels --- +# Every spoken text starts with the session's name, project plus what it is +# working on, so several sessions can be told apart by ear. The server builds it +# from the session's title or branch and returns it; it is kept per session and +# sent back, so the name does not change when the title does. Private sessions +# and server failures use the project plus the local branch instead. + +_ds_voice_label_file() { printf '%s/labels/%s' "$DS_VOICE_DIR" "$(printf '%s' "$1" | tr -cd 'A-Za-z0-9_-')"; } + +# The label the server gave this session, if any. +_ds_voice_label() { # session-id + [ -n "$1" ] || return 0 + cat "$(_ds_voice_label_file "$1")" 2>/dev/null || true +} + +# Keep the first label the server returns for a session. Labels of sessions +# idle for two days are dropped on the way. +_ds_voice_keep_label() { # session-id label + local f + [ -n "$1" ] && [ -n "$2" ] || return 0 + f=$(_ds_voice_label_file "$1") + [ -s "$f" ] && return 0 + _ds_voice_mkdirs + find "$DS_VOICE_DIR/labels" -type f -mtime +2 -delete 2>/dev/null || true + ( umask 077; printf '%s' "$2" > "$f" ) 2>/dev/null || true +} + +# A branch as spoken words, as the server says it: "feat/oauth-login" -> +# "oauth login". Empty for main and other branches that say nothing. +_ds_voice_branch_words() { # branch + local last="${1##*/}" + case "$(printf '%s' "$last" | tr '[:upper:]' '[:lower:]')" in + ""|main|master|develop|dev|trunk|head|staging|production) return 0 ;; + esac + printf '%s' "$last" | tr -s '_.-' ' ' | awk '{ n = NF > 5 ? 5 : NF; for (i = 1; i <= n; i++) printf "%s%s", (i > 1 ? " " : ""), $i }' +} + +# The current branch of a directory, read locally and never sent anywhere. +_ds_voice_branch() { # dir + [ -n "$1" ] || return 0 + git -C "$1" symbolic-ref --quiet --short HEAD 2>/dev/null || true +} + +# The name to speak for a job file: the server's label, else project plus +# the local branch, else the project. +_ds_voice_name() { # job-file + local sid project branch words label + read -r sid < <(jq -r '.dsSessionId // .sessionId // ""' "$1" 2>/dev/null) || true + label=$(_ds_voice_label "$sid") + if [ -n "$label" ]; then printf '%s' "$label"; return 0; fi + project=$(jq -r '.project' "$1" 2>/dev/null) + branch=$(jq -r '.branch // ""' "$1" 2>/dev/null) + words=$(_ds_voice_branch_words "$branch") + printf '%s%s' "$project" "${words:+, $words}" +} + +# A session in a "N sessions need you" list: "oauth login in web", as a list +# of labels would run their commas together. +_ds_voice_batch_name() { # job-file + local name + name=$(_ds_voice_name "$1") + case "$name" in + *", "*) printf '%s in %s' "${name#*, }" "${name%%, *}" ;; + *) printf '%s' "$name" ;; + esac +} + +# Ask the server for the text, keep the label it returns, print the text. +_ds_voice_summary() { # json-body session-id + local raw text label + raw=$(_ds_api POST /api/ai/voice-summary "$1" "$DS_VOICE_SUMMARY_TIMEOUT") || return 0 + text=$(printf '%s' "$raw" | jq -r '.text // empty' 2>/dev/null) + label=$(printf '%s' "$raw" | jq -r '.label // empty' 2>/dev/null) + [ -n "$text" ] && _ds_voice_keep_label "$2" "$label" + printf '%s' "$text" } _ds_voice_log() { @@ -312,7 +391,7 @@ _ds_voice_on_event() { # (/devscope:voice explain) is not summarized on top of it. _ds_voice_on_reply_event() { # event-type hook-input _ds_voice_replies_on || return 0 - local et="$1" input="$2" sid pid eid job tmp privacy="${DEVSCOPE_PRIVACY:-standard}" last="" + local et="$1" input="$2" sid pid eid job tmp cwd privacy="${DEVSCOPE_PRIVACY:-standard}" last="" case "$et" in prompt.submit) # A turn interrupted after it spoke never reached Stop: forget it. @@ -342,9 +421,10 @@ _ds_voice_on_reply_event() { # event-type hook-input _ds_voice_mkdirs job="$DS_VOICE_DIR/replies/$(printf '%s' "$sid" | tr -cd 'A-Za-z0-9_-').json" tmp="$job.tmp.$$" - jq -n --arg eid "$eid" --arg sid "$sid" --arg privacy "$privacy" --arg last "$last" \ - --arg project "$(basename "$(printf '%s' "$input" | jq -r '.cwd // "session"' 2>/dev/null)")" \ - '{eventId: $eid, sessionId: $sid, project: $project, lastMessage: $last, privacy: $privacy}' \ + cwd=$(printf '%s' "$input" | jq -r '.cwd // ""' 2>/dev/null) + jq -n --arg eid "$eid" --arg sid "$sid" --arg dsid "${DS_VOICE_SESSION:-$sid}" --arg privacy "$privacy" --arg last "$last" \ + --arg project "$(basename "${cwd:-session}")" --arg branch "$(_ds_voice_branch "$cwd")" \ + '{eventId: $eid, sessionId: $sid, dsSessionId: $dsid, project: $project, branch: $branch, lastMessage: $last, privacy: $privacy}' \ > "$tmp" && mv "$tmp" "$job" || { rm -f "$tmp"; return 0; } _ds_voice_spawn "$DS_VOICE_LIB_DIR/speak.sh" reply "$sid" "$eid" } @@ -352,18 +432,19 @@ _ds_voice_on_reply_event() { # event-type hook-input # The text for a queued reply: an AI summary, or the template when the session # is private, the reply was empty or the server fails. _ds_voice_reply_text() { # job-file - local body text="" project privacy + local body text="" privacy sid read -r privacy < <(jq -r '.privacy' "$1" 2>/dev/null) || return 1 - project=$(jq -r '.project' "$1" 2>/dev/null) + sid=$(jq -r '.dsSessionId // .sessionId // ""' "$1" 2>/dev/null) if [ "$privacy" != "private" ] && [ -n "${DEVSCOPE_API_KEY:-}" ]; then - body=$(jq -c --arg length "$(_ds_voice_verbosity auto)" \ - '{trigger: "reply", project: .project, last_message: .lastMessage, length: $length} - | with_entries(select(.value != ""))' "$1" 2>/dev/null) + body=$(jq -c --arg length "$(_ds_voice_verbosity auto)" --arg label "$(_ds_voice_label "$sid")" \ + '{trigger: "reply", project: .project, last_message: .lastMessage, length: $length, + session_id: (.dsSessionId // .sessionId), label: $label} + | with_entries(select(.value != "" and .value != null))' "$1" 2>/dev/null) if printf '%s' "$body" | jq -e '.last_message' >/dev/null 2>&1; then - text=$(_ds_api POST /api/ai/voice-summary "$body" "$DS_VOICE_SUMMARY_TIMEOUT" | jq -r '.text // empty' 2>/dev/null) + text=$(_ds_voice_summary "$body" "$sid") fi fi - [ -n "$text" ] || text=$(_ds_voice_template finished "$project") + [ -n "$text" ] || text=$(_ds_voice_template finished "$(_ds_voice_name "$1")") printf '%s' "$text" } @@ -483,13 +564,13 @@ _ds_voice_arm() { # session-id type hook-input _ds_voice_mkdirs tmp="$m.tmp.$$" jq -n \ - --arg eid "$eid" --arg sid "$sid" --arg type "$type" --arg tool "$tool" \ - --arg project "$(basename "${cwd:-session}")" \ + --arg eid "$eid" --arg sid "$sid" --arg dsid "${DS_VOICE_SESSION:-$sid}" --arg type "$type" --arg tool "$tool" \ + --arg project "$(basename "${cwd:-session}")" --arg branch "$(_ds_voice_branch "$cwd")" \ --arg detail "$(_ds_voice_detail "$type" "$tool" "$input")" \ --arg last "$last" --arg privacy "${DEVSCOPE_PRIVACY:-standard}" \ --arg pid "$pid" --arg match "$match" \ --argjson now "$(date +%s)" \ - '{eventId: $eid, sessionId: $sid, type: $type, tool: $tool, project: $project, + '{eventId: $eid, sessionId: $sid, dsSessionId: $dsid, type: $type, tool: $tool, project: $project, branch: $branch, detail: $detail, lastMessage: $last, privacy: $privacy, armedAt: $now, spoken: 0, claudePid: $pid, match: $match}' \ > "$tmp" && mv "$tmp" "$m" || { rm -f "$tmp"; return 0; } @@ -528,28 +609,33 @@ _ds_voice_due() { # marker-file now # --- Announcing --- -_ds_voice_template() { # type project tool +_ds_voice_template() { # type name tool + # A name with a topic ("api-service, oauth login") is said first, on its own. + local who="$2" + case "$2" in *", "*) printf '%s. ' "$2"; who="It" ;; esac case "$1" in - permission) printf '%s needs permission%s.' "$2" "${3:+ to use $3}" ;; - question) printf '%s has a question for you.' "$2" ;; - failed) printf '%s stopped with an error.' "$2" ;; - *) printf '%s is done and waiting for you.' "$2" ;; + permission) printf '%s needs permission%s.' "$who" "${3:+ to use $3}" ;; + question) printf '%s has a question for you.' "$who" ;; + failed) printf '%s stopped with an error.' "$who" ;; + *) printf '%s is done and waiting for you.' "$who" ;; esac } # The sentence for one marker: an AI summary unless the session is private or # the backend is unreachable, then the local template. _ds_voice_text() { - local f="$1" type project tool privacy spoken body text="" + local f="$1" type tool privacy spoken body text="" sid read -r type privacy spoken < <(jq -r '"\(.type) \(.privacy) \(.spoken)"' "$f" 2>/dev/null) || return 1 - project=$(jq -r '.project' "$f" 2>/dev/null) tool=$(jq -r '.tool' "$f" 2>/dev/null) + sid=$(jq -r '.dsSessionId // .sessionId // ""' "$f" 2>/dev/null) if [ "$privacy" != "private" ] && [ -n "${DEVSCOPE_API_KEY:-}" ]; then - body=$(jq -c '{trigger: .type, project: .project, tool: .tool, detail: .detail, last_message: .lastMessage} - | with_entries(select(.value != ""))' "$f" 2>/dev/null) - text=$(_ds_api POST /api/ai/voice-summary "$body" "$DS_VOICE_SUMMARY_TIMEOUT" | jq -r '.text // empty' 2>/dev/null) + body=$(jq -c --arg label "$(_ds_voice_label "$sid")" \ + '{trigger: .type, project: .project, tool: .tool, detail: .detail, last_message: .lastMessage, + session_id: (.dsSessionId // .sessionId), label: $label} + | with_entries(select(.value != "" and .value != null))' "$f" 2>/dev/null) + text=$(_ds_voice_summary "$body" "$sid") fi - [ -n "$text" ] || text=$(_ds_voice_template "$type" "$project" "$tool") + [ -n "$text" ] || text=$(_ds_voice_template "$type" "$(_ds_voice_name "$f")" "$tool") [ "$spoken" -gt 0 ] 2>/dev/null && text="Still waiting. $text" printf '%s' "$text" } @@ -596,7 +682,7 @@ _ds_voice_announce_due() { if [ $((n + ${#soon[@]})) -ge "$DS_VOICE_BATCH_MIN" ]; then for i in "${!soon[@]}"; do files+=("${soon[$i]}"); eids+=("${soon_eids[$i]}"); done n=${#files[@]} - names=$(for f in "${files[@]}"; do jq -r '.project' "$f"; done | awk ' + names=$(for f in "${files[@]}"; do _ds_voice_batch_name "$f"; echo; done | awk ' { a[NR] = $0 } END { for (i = 1; i <= NR; i++) printf "%s%s", (i == 1 ? "" : (i == NR ? " and " : ", ")), a[i] }') text="$(_ds_voice_count_word "$n") sessions need you: $names." # It names every project, so it is private if any of them is. diff --git a/tests/voice/run.sh b/tests/voice/run.sh index 33a7320..7282c49 100644 --- a/tests/voice/run.sh +++ b/tests/voice/run.sh @@ -446,6 +446,55 @@ jq '.speed = 9' "$CONF" > "$TMP/c" && mv "$TMP/c" "$CONF" [ "$( . "$S/_helpers.sh"; . "$S/voice/lib.sh"; _ds_voice_speed)" = 2 ] && ok "a hand-edited speed is clamped to 2x" || bad "clamp" "" printf ' \n' | "$S/voice/cli.sh" say >/dev/null && bad "empty say" "accepted" || ok "say rejects empty text" +# 15. Session labels: every text starts with which session it is about. +LABELS="$HOME/.cache/devscope/voice/labels" +SA=/api/ai/voice-summary +configure; reset; rm -rf "$LABELS" +respond '{"text": "api, rate limiter fix. It wants to run the migration.", "label": "api, rate limiter fix"}' +hook permission-request.sh lab1 /work/api "$PERM" +wait_spoken 1 5 && [ "$(spoken)" = "api, rate limiter fix. It wants to run the migration." ] && ok "labels: the server's labelled text is spoken" || bad "label spoken" "$(spoken)" +[ "$(last_at $SA .body.session_id)" = lab1 ] && ok "labels: sends the session id" || bad "label sid" "$(last_at $SA .body)" +[ "$(last_at $SA .body.label)" = null ] && ok "labels: no label on the first call" || bad "label first" "$(last_at $SA .body)" +[ "$(cat "$LABELS/lab1" 2>/dev/null)" = "api, rate limiter fix" ] && ok "labels: keeps the label it got back" || bad "label kept" "$(ls "$LABELS" 2>/dev/null)" + +reset; respond '{"text": "api, a newer title. Done.", "label": "api, a newer title"}' +hook permission-request.sh lab1 /work/api "$PERM" +wait_spoken 1 5; [ "$(last_at $SA .body.label)" = "api, rate limiter fix" ] && ok "labels: sends the kept label back" || bad "label resent" "$(last_at $SA .body)" +[ "$(cat "$LABELS/lab1")" = "api, rate limiter fix" ] && ok "labels: the first label stays, so the name never changes" || bad "label stable" "$(cat "$LABELS/lab1")" + +configure; reset +DEVSCOPE_URL=http://127.0.0.1:9 hook response-failed.sh lab1 /work/api '{hook_event_name: "StopFailure", error: "x"}' +wait_spoken 1 8 && [ "$(spoken)" = "api, rate limiter fix. It stopped with an error." ] && ok "labels: server down, the template starts with the kept label" || bad "label template" "$(spoken)" + +# After /clear Claude Code starts a new session id, but DevScope keeps its own +# (the session-state file send-event.sh reads); voice must name that one. +configure; reset; rm -rf "$LABELS"; respond '{"text": "x", "label": "api, kept"}' +STATE_EMAIL=$( . "$S/_helpers.sh"; _ds_normalize_email "${USER}@local") +STATE="$HOME/.cache/devscope/$( . "$S/_helpers.sh"; _ds_sha256 "${STATE_EMAIL}:/work/api:$$").session" +mkdir -p "$(dirname "$STATE")"; printf 'ds-session-1' > "$STATE" +# Called directly, so its parent (part of the state file name) is this shell. +jq -n '{session_id: "claude-new-id", cwd: "/work/api"} + '"$PERM" | "$S/send-event.sh" permission.request '{"toolName": "Bash"}' >/dev/null 2>&1 +wait_spoken 1 5; [ "$(last_at $SA .body.session_id)" = ds-session-1 ] && ok "labels: sends the DevScope session id, which outlives /clear" || bad "label dsid" "$(last_at $SA .body)" +[ -f "$LABELS/ds-session-1" ] && ok "labels: the label is kept under the DevScope session" || bad "label dsid file" "$(ls "$LABELS")" +rm -f "$STATE" + +# A private session is named from the local branch; nothing is sent. +configure; reset +REPO="$TMP/work/secret"; mkdir -p "$REPO"; git -C "$REPO" init -q -b feat/oauth-login 2>/dev/null || { git -C "$REPO" init -q; git -C "$REPO" checkout -q -b feat/oauth-login; } +DEVSCOPE_PRIVACY=private hook permission-request.sh lab2 "$REPO" "$PERM" +wait_spoken 1 5 && [ "$(spoken)" = "secret, oauth login. It needs permission to use Bash." ] && ok "labels: private session named from the local branch" || bad "label private" "$(spoken)" +paths | grep -q voice-summary && bad "label private request" "$(paths | tr '\n' ' ')" || ok "labels: private branch never sent" +git -C "$REPO" checkout -q -b main 2>/dev/null; reset +DEVSCOPE_PRIVACY=private hook permission-request.sh lab3 "$REPO" "$PERM" +wait_spoken 1 5 && [ "$(spoken)" = "secret needs permission to use Bash." ] && ok "labels: main says nothing, just the project" || bad "label main" "$(spoken)" + +# The batch sentence says "topic in project" so labels' commas do not run together. +configure '.delays.permission = 3'; reset; rm -rf "$LABELS"; mkdir -p "$LABELS" +printf 'alpha, oauth login' > "$LABELS/bl-alpha"; printf 'beta, rate limit' > "$LABELS/bl-beta" +for p in alpha beta gamma; do DEVSCOPE_PRIVACY=private hook permission-request.sh "bl-$p" "/work/$p" "$PERM"; done +wait_spoken 1 10; sleep 1 +[ "$(spoken)" = "three sessions need you: oauth login in alpha, rate limit in beta and gamma." ] && ok "labels: batch names topic in project" || bad "label batch" "$(spoken)" + reset echo "---"; echo "$pass passed, $fail failed" [ "$fail" -eq 0 ]