Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .claude-plugin/marketplace.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
{
"name": "devscope",
"description": "Real-time developer activity monitoring for Claude Code sessions",
"version": "0.33.0",
"version": "0.34.0",
"author": {
"name": "Lucas Dow",
"email": "lucdow7@gmail.com"
Expand All @@ -22,7 +22,7 @@
{
"name": "devscope-live",
"description": "DevScope in the live session: team prompt suggestions, team skills, a stuck band, outcome labels and session-to-commit links (Claude Code mod)",
"version": "0.3.0",
"version": "0.4.0",
"author": {
"name": "Lucas Dow",
"email": "lucdow7@gmail.com"
Expand Down
2 changes: 1 addition & 1 deletion .claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "devscope",
"version": "0.33.0",
"version": "0.34.0",
"description": "Real-time developer activity monitoring for Claude Code sessions",
"author": {
"name": "Lucas Dow",
Expand Down
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ 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.34.0] - 2026-10-08

### Added
- **The voice bar shows in the session that is speaking.** `progress.json`
carries `sessionId` (the Claude Code session the speech is about) and, for
replies, the session's spoken name as `project`. Explanations are started by
a command that is not told the session, so the prompt hook records each
window's session in `~/.cache/devscope/voice/sessions/<claude-pid>` (only
when voice is set up or Claude Code passes its PID) and `/devscope:voice
explain` looks it up. Needs devscope-live 0.4.0 to take effect.

## [0.33.0] - 2026-10-08

### Fixed
Expand Down
5 changes: 4 additions & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,10 @@ claude plugin disable devscope@devscope # Disable
- **`progress.json`** is the contract with the devscope-live mod's voice bar: the speak lock
holder (`speak.sh`, `DS_VOICE_PROGRESS_KIND` set) writes `{kind, project, phase:
summarizing|voicing|speaking, piece, pieces, pieceMs, at (epoch ms), pid}` atomically per
phase and piece (`pieceMs` from the WAV header, 0 when unknown) and removes it on exit.
phase and piece (`pieceMs` from the WAV header, 0 when unknown) and removes it on exit. `sessionId`
(Claude Code's id; replies from the job, explanations via `sessions/<claude-pid>`, written by the prompt hook)
makes the bar per session: the mod draws it only where `$.session.id()` matches, a dimmed one-liner elsewhere,
and the whole bar everywhere when the field is absent (older plugins).
The mod parses it in `hooks/voiceBar.ts` and treats a file past its piece's end + 15 s as
dead; change both sides together.

Expand Down
2 changes: 1 addition & 1 deletion mods/devscope-live/.claude-plugin/plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "devscope-live",
"version": "0.3.0",
"version": "0.4.0",
"description": "DevScope in the live session: team prompt suggestions, team skills, a stuck band, outcome labels and session-to-commit links",
"author": {
"name": "Lucas Dow",
Expand Down
9 changes: 9 additions & 0 deletions mods/devscope-live/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).

## [0.4.0] - 2026-10-08

### Changed
- **Voice bar per session.** The bar and its Stop button appear only in the
window whose session is speaking; every other window shows one dimmed line,
"🔊 api-service, rate limiter fix · reading the summary". Progress from a
devscope plugin older than 0.34.0 names no session and still shows the bar
everywhere.

## [0.3.0] - 2026-10-07

### Changed
Expand Down
11 changes: 9 additions & 2 deletions mods/devscope-live/hooks/register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { Suggestion } from './suggestions'
import { USE_IT, matchSkill, skillContext, skillLabel } from './teamSkills'
import type { TeamSkill } from './teamSkills'
import { isPrUrl, linkFromBash, parseGhPr, withTrailer, withoutCredentials } from './vcs'
import { barCells, fraction, isStale, parseProgress, runs, voiceLabel } from './voiceBar'
import { barCells, fraction, isOwnSpeech, isStale, otherSpeechLabel, parseProgress, runs, voiceLabel } from './voiceBar'

const band = atom({ plugin: 'devscope-live', key: 'band' } as const, null as Band)
const voice = atom({ plugin: 'devscope-live', key: 'voice' } as const, null as VoiceView)
Expand Down Expand Up @@ -395,7 +395,14 @@ export const register: Register = (on, pluginOptions) => {
const { Box, Button, Text } = $.ui.resolve(e)
const clear = () => update($, band, () => null)

const voiceRow = speaking ? (
// The bar (and its Stop) belongs to the window whose session is speaking;
// every other window gets one dimmed line naming the session.
const own = speaking ? isOwnSpeech(speaking.progress, await $.session.id()) : false
const voiceRow = speaking && !own ? (
<Box key="voice">
<Text dimColor>{otherSpeechLabel(speaking.progress)}</Text>
</Box>
) : speaking ? (
<Box key="voice" gap={1}>
<Box>
{runs(barCells(fraction(speaking.progress, await $.clock.now()), speaking.frame)).map((run, i) => (
Expand Down
14 changes: 14 additions & 0 deletions mods/devscope-live/hooks/voiceBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export function parseProgress(text: string): VoiceProgress | undefined {
pieceMs: p.pieceMs as number,
at: p.at as number,
pid: p.pid as number,
sessionId: typeof p.sessionId === 'string' ? p.sessionId.slice(0, 200) : '',
}
} catch {
return undefined
Expand Down Expand Up @@ -106,3 +107,16 @@ export function voiceLabel(p: VoiceProgress): string {
const part = p.phase === 'speaking' && p.pieces > 1 ? ` ${Math.min(p.piece + 1, p.pieces)}/${p.pieces}` : ''
return `${p.project ? `${p.project} · ` : ''}${what}${part}`
}

/**
* Whether this window's session is the one speaking. Progress from an older
* plugin names no session and counts as everyone's, as it always did.
*/
export function isOwnSpeech(p: VoiceProgress, sessionId: string): boolean {
return p.sessionId === '' || p.sessionId === sessionId
}

/** The dimmed line other windows show while a session speaks. */
export function otherSpeechLabel(p: VoiceProgress): string {
return `🔊 ${voiceLabel({ ...p, project: p.project || 'Another session' })}`
}
22 changes: 22 additions & 0 deletions mods/devscope-live/tests/hooks.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,28 @@ describe('voice progress bar', () => {
await ui.unmount()
})

test('shows the bar only in the speaking session; other windows get a dimmed line', async ($, on) => {
const files: Files = {}
const { clock } = setup(on, {}, files)
await $.session.start(SESSION)
const own = 'cc-session-1' // the test engine's session id

files[PROGRESS] = progress(clock.now(), { sessionId: own })
await clock.advance(1000)
let ui = await $.ui.mount({ ...ABOVE_PROMPT, surface: 'terminal' })
expect(await ui.find({ key: 'voice-stop' })).toBeDefined()
expect(await ui.find({ type: 'Text', text: /^🔊/ })).toBeUndefined()
await ui.unmount()

files[PROGRESS] = progress(clock.now(), { sessionId: 'some-other-session', kind: 'reply', project: 'api, rate limiter fix' })
await clock.advance(1000)
ui = await $.ui.mount({ ...ABOVE_PROMPT, surface: 'terminal' })
expect(await ui.find({ type: 'Text', text: '🔊 api, rate limiter fix · reading the summary 2/4' })).toBeDefined()
expect(await ui.find({ key: 'voice-stop' })).toBeUndefined()
expect(await ui.find({ type: 'Text', text: /\u283f/ })).toBeUndefined()
await ui.unmount()
})

test('animates while the audio is made, and goes away when the speaker is done', async ($, on) => {
const files: Files = {}
const { clock } = setup(on, {}, files)
Expand Down
19 changes: 18 additions & 1 deletion mods/devscope-live/tests/logic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { SUGGEST, afterPrompt, basename, fitsSuggestion, nextPromptsBody, should
import { matchSkill } from '../hooks/teamSkills'
import type { TeamSkill } from '../hooks/teamSkills'
import { isPrUrl, linkFromBash, parseGhPr, withTrailer, withoutCredentials } from '../hooks/vcs'
import { LEVELS, TRACK, TRACK_COLOR, barCells, fraction, isStale, parseProgress, runs, voiceLabel } from '../hooks/voiceBar'
import { LEVELS, TRACK, TRACK_COLOR, barCells, fraction, isOwnSpeech, isStale, otherSpeechLabel, parseProgress, runs, voiceLabel } from '../hooks/voiceBar'
import type { VoiceProgress } from '../types'

const skill = (id: string, ...triggerPhrases: string[]): TeamSkill => ({
Expand Down Expand Up @@ -171,9 +171,26 @@ describe('voice bar', () => {
pieceMs: 10_000,
at: 1_000_000,
pid: 4242,
sessionId: '',
...over,
})

test('the bar belongs to the session that speaks; older plugins name none', () => {
expect(parseProgress(JSON.stringify({ ...progress(), sessionId: undefined }))?.sessionId).toBe('')
expect(parseProgress(JSON.stringify(progress({ sessionId: 's-1' })))?.sessionId).toBe('s-1')
expect(parseProgress(JSON.stringify({ ...progress(), sessionId: 7 }))?.sessionId).toBe('')
expect(isOwnSpeech(progress({ sessionId: 's-1' }), 's-1')).toBe(true)
expect(isOwnSpeech(progress({ sessionId: 's-1' }), 's-2')).toBe(false)
expect(isOwnSpeech(progress(), 's-2')).toBe(true)
})

test('other windows get one line naming the session', () => {
expect(otherSpeechLabel(progress({ kind: 'reply', project: 'api, rate limiter fix', piece: 0, pieces: 1 }))).toBe(
'🔊 api, rate limiter fix · reading the summary',
)
expect(otherSpeechLabel(progress({ project: '', phase: 'voicing' }))).toBe('🔊 Another session · creating audio')
})

test('parses the speaker file and rejects anything malformed', () => {
expect(parseProgress(JSON.stringify(progress()))).toEqual(progress())
expect(parseProgress('{')).toBeUndefined()
Expand Down
4 changes: 3 additions & 1 deletion mods/devscope-live/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export type Band =
/**
* What the Bash plugin's speaker is doing (~/.cache/devscope/voice/progress.json):
* `at` is when the phase or piece began (epoch ms), `pieceMs` how long the piece
* plays (0 when unknown), `pid` the speaker's process group.
* plays (0 when unknown), `pid` the speaker's process group. `sessionId` is the
* Claude Code session the speech is about ('' from older plugins: shown everywhere).
*/
export type VoiceProgress = {
kind: 'explain' | 'reply'
Expand All @@ -21,6 +22,7 @@ export type VoiceProgress = {
pieceMs: number
at: number
pid: number
sessionId: string
}

/** The voice bar: the latest progress, and a frame counter that animates it. */
Expand Down
3 changes: 2 additions & 1 deletion scripts/voice/cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ say() {
_ds_voice_mkdirs
job="$DS_VOICE_DIR/say/$(cat /proc/sys/kernel/random/uuid 2>/dev/null || uuidgen 2>/dev/null || echo "s-$(_ds_now_ns)").json"
( umask 077; jq -n --arg t "$text" --arg p "${DEVSCOPE_PRIVACY:-standard}" --arg project "$(basename "$PWD")" \
'{text: $t, privacy: $p, project: $project}' > "$job" ) || return 1
--arg sid "$(_ds_voice_this_session)" \
'{text: $t, privacy: $p, project: $project, sessionId: $sid}' > "$job" ) || return 1
# This turn spoke: auto voice does not summarize its reply on top.
pid=$(_ds_voice_claude_pid)
[ -n "$pid" ] && : > "$DS_VOICE_DIR/spoke/$pid"
Expand Down
39 changes: 36 additions & 3 deletions scripts/voice/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
# window (/devscope:voice auto), over the default.
# speakers/<pid> running speak.sh processes, for /devscope:voice stop.
# progress.json what the speaking speak.sh is doing, for the
# devscope-live mod's progress bar.
# devscope-live mod's progress bar; `sessionId` says
# whose speech it is, so only that window shows the bar.
# sessions/<claude-pid> the Claude Code session id of that window, written on
# each prompt, so /devscope:voice explain knows it.
# speak.lock serializes speech across all sessions.
# queue/<ns>-<pid> one ticket per process waiting to speak; the oldest
# live ticket speaks next, so speech is first come,
Expand Down Expand Up @@ -90,7 +93,8 @@ 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" "$DS_VOICE_DIR/labels" "$DS_VOICE_DIR/queue" ) 2>/dev/null
"$DS_VOICE_DIR/spoke" "$DS_VOICE_DIR/speakers" "$DS_VOICE_DIR/auto" "$DS_VOICE_DIR/labels" "$DS_VOICE_DIR/queue" \
"$DS_VOICE_DIR/sessions" ) 2>/dev/null
}

# --- Session labels ---
Expand Down Expand Up @@ -349,6 +353,7 @@ _ds_voice_marker() {

# Arm or clear from one hook event. Arguments: DevScope event type, raw hook input.
_ds_voice_on_event() {
[ "$1" = prompt.submit ] && _ds_voice_note_session "$2"
_ds_voice_on_reply_event "$1" "$2"
_ds_voice_enabled || return 0
local et="$1" input="$2" sid tool m
Expand Down Expand Up @@ -583,6 +588,32 @@ _ds_voice_arm() { # session-id type hook-input
_ds_voice_spawn "$DS_VOICE_LIB_DIR/timer.sh" "$sid" "$eid"
}

# Remember which session this Claude Code window runs, for speech started from a
# command (/devscope:voice explain), which is told no session id. Only when it
# is cheap (Claude Code gave its PID) or voice is set up, so a plugin user who
# never uses voice pays no process lookups.
_ds_voice_note_session() { # hook-input
local sid pid f
[ -n "${CLAUDE_PID:-}" ] || [ -f "$DS_VOICE_CONFIG" ] || return 0
sid=$(printf '%s' "$1" | jq -r '.session_id // empty' 2>/dev/null)
[ -n "$sid" ] || return 0
pid=$(_ds_voice_claude_pid)
[ -n "$pid" ] || return 0
_ds_voice_mkdirs
f="$DS_VOICE_DIR/sessions/$pid"
[ "$(cat "$f" 2>/dev/null)" = "$sid" ] && return 0
find "$DS_VOICE_DIR/sessions" -type f -mtime +2 -delete 2>/dev/null || true
( umask 077; printf '%s' "$sid" > "$f" ) 2>/dev/null || true
}

# The session id of the Claude Code window this command runs in, if known.
_ds_voice_this_session() {
local pid
pid=$(_ds_voice_claude_pid)
[ -n "$pid" ] && cat "$DS_VOICE_DIR/sessions/$pid" 2>/dev/null
return 0
}

# Start a process that outlives the hook (Claude Code may reap the hook's group).
_ds_voice_spawn() {
if command -v setsid >/dev/null 2>&1; then
Expand Down Expand Up @@ -962,10 +993,12 @@ _ds_voice_progress() { # phase [piece pieces [piece-ms]]
[ -n "${DS_VOICE_PROGRESS_KIND:-}" ] || return 0
local tmp="$DS_VOICE_PROGRESS.tmp.$$"
jq -n --arg kind "$DS_VOICE_PROGRESS_KIND" --arg project "${DS_VOICE_PROGRESS_PROJECT:-}" \
--arg session "${DS_VOICE_PROGRESS_SESSION:-}" \
--arg phase "$1" --argjson piece "${2:-0}" --argjson pieces "${3:-0}" --argjson ms "${4:-0}" \
--argjson at "$(( $(_ds_now_ns) / 1000000 ))" --argjson pid "$$" \
'{kind: $kind, project: $project, phase: $phase, piece: $piece, pieces: $pieces,
pieceMs: $ms, at: $at, pid: $pid}' > "$tmp" 2>/dev/null && mv "$tmp" "$DS_VOICE_PROGRESS" || rm -f "$tmp"
pieceMs: $ms, at: $at, pid: $pid}
+ (if $session == "" then {} else {sessionId: $session} end)' > "$tmp" 2>/dev/null && mv "$tmp" "$DS_VOICE_PROGRESS" || rm -f "$tmp"
}

# Remove the progress file if this process wrote it.
Expand Down
9 changes: 6 additions & 3 deletions scripts/voice/speak.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ case "${1:-}" in
current() { [ "$(jq -r '.eventId' "$JOB" 2>/dev/null)" = "$EID" ]; }
current || exit 0
export DS_VOICE_PROGRESS_KIND=reply
DS_VOICE_PROGRESS_PROJECT=$(jq -r '.project // ""' "$JOB" 2>/dev/null)
export DS_VOICE_PROGRESS_PROJECT
# The session's spoken name, and its id so only its window shows the bar.
DS_VOICE_PROGRESS_PROJECT=$(_ds_voice_name "$JOB")
DS_VOICE_PROGRESS_SESSION=$(jq -r '.sessionId // ""' "$JOB" 2>/dev/null)
export DS_VOICE_PROGRESS_PROJECT DS_VOICE_PROGRESS_SESSION
# Summarized before waiting for a turn: sessions that finish together get
# their summaries in parallel instead of each waiting on the others' calls.
TEXT=$(_ds_voice_reply_text "$JOB") || exit 0
Expand All @@ -53,7 +55,8 @@ case "${1:-}" in
[ -f "$JOB" ] || exit 0
export DS_VOICE_PROGRESS_KIND=explain
DS_VOICE_PROGRESS_PROJECT=$(jq -r '.project // ""' "$JOB" 2>/dev/null)
export DS_VOICE_PROGRESS_PROJECT
DS_VOICE_PROGRESS_SESSION=$(jq -r '.sessionId // ""' "$JOB" 2>/dev/null)
export DS_VOICE_PROGRESS_PROJECT DS_VOICE_PROGRESS_SESSION
speak_job() {
_ds_voice_log "speak explanation ($(jq -r '.text | length' "$JOB" 2>/dev/null) chars)"
_ds_voice_speak_long "$(jq -r '.text' "$JOB" 2>/dev/null)" "$(jq -r '.privacy' "$JOB" 2>/dev/null)"
Expand Down
25 changes: 25 additions & 0 deletions tests/voice/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,31 @@ printf 'One short explanation.\n' | "$S/voice/cli.sh" say >/dev/null
wait_spoken 1 5; sleep 0.5
[ ! -f "$HOME/.cache/devscope/voice/progress.json" ] && ok "progress file removed when speech ends" || bad "progress cleanup" "$(cat "$HOME/.cache/devscope/voice/progress.json")"

# 10f. The bar is per session: progress.json names the session speaking.
PJ="$HOME/.cache/devscope/voice/progress.json"
progress_of() { # wait for a speaking progress file, print a jq field
for _ in $(seq 1 60); do [ -f "$PJ" ] && jq -e '.phase == "speaking"' "$PJ" >/dev/null 2>&1 && { jq -r "$1" "$PJ"; return; }; sleep 0.1; done
}
configure; reset; "$S/voice/cli.sh" auto-default on >/dev/null; respond '{"text": "Reply done."}'
DS_VOICE_TEST_SPEAK_SEC=1.5 hook response-stop.sh own-reply /work/api '{hook_event_name: "Stop", last_assistant_message: "Done."}'
[ "$(progress_of .sessionId)" = own-reply ] && ok "bar per session: a reply's progress names its session" || bad "progress reply session" "$(cat "$PJ" 2>/dev/null)"
wait_spoken 1 5; "$S/voice/cli.sh" auto-default off >/dev/null

# An explanation is started by a command, which is not told the session: the
# prompt hook recorded which session that Claude Code window runs.
configure; reset; sleep 60 & fakeclaude=$!
DS_VOICE_CLAUDE_PID=$fakeclaude hook prompt-submit.sh ex-session /work/api '{hook_event_name: "UserPromptSubmit", prompt: "explain it"}'
[ "$(cat "$HOME/.cache/devscope/voice/sessions/$fakeclaude" 2>/dev/null)" = ex-session ] && ok "bar per session: the prompt hook records the window's session" || bad "session record" "$(ls "$HOME/.cache/devscope/voice/sessions" 2>/dev/null)"
printf 'An explanation for one session.\n' | DS_VOICE_CLAUDE_PID=$fakeclaude DS_VOICE_TEST_SPEAK_SEC=1.5 "$S/voice/cli.sh" say >/dev/null
[ "$(progress_of .sessionId)" = ex-session ] && ok "bar per session: an explanation's progress names the session that asked" || bad "progress explain session" "$(cat "$PJ" 2>/dev/null)"
wait_spoken 1 5; kill "$fakeclaude" 2>/dev/null || true

# Someone who never set up voice pays no process lookups for it.
rm -f "$CONF"; rm -rf "$HOME/.cache/devscope/voice/sessions"
( unset CLAUDE_PID; DS_VOICE_CLAUDE_PID=12345 hook prompt-submit.sh nv-session /work/api '{hook_event_name: "UserPromptSubmit", prompt: "hi there"}' )
[ -z "$(ls "$HOME/.cache/devscope/voice/sessions" 2>/dev/null)" ] && ok "bar per session: nothing recorded without voice set up" || bad "session record gate" "$(ls "$HOME/.cache/devscope/voice/sessions")"
configure

# 11b. Screen lock: detection, then each kind of speech.
mkdir -p "$TMP/bin"
cat > "$TMP/bin/loginctl" <<'EOF'
Expand Down
Loading