feat(statusline): show update indicator when new GSD version available
Adds SessionStart hook that checks npm in background, caches result. Statusline shows "⬆ /gsd:update │" when update available. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -225,12 +225,40 @@ function install(isGlobal) {
|
|||||||
console.log(` ${green}✓${reset} Installed hooks`);
|
console.log(` ${green}✓${reset} Installed hooks`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Configure statusline in settings.json
|
// Configure statusline and hooks in settings.json
|
||||||
const settingsPath = path.join(claudeDir, 'settings.json');
|
const settingsPath = path.join(claudeDir, 'settings.json');
|
||||||
const settings = readSettings(settingsPath);
|
const settings = readSettings(settingsPath);
|
||||||
const statuslineCommand = isGlobal
|
const statuslineCommand = isGlobal
|
||||||
? '$HOME/.claude/hooks/statusline.sh'
|
? '$HOME/.claude/hooks/statusline.sh'
|
||||||
: '.claude/hooks/statusline.sh';
|
: '.claude/hooks/statusline.sh';
|
||||||
|
const updateCheckCommand = isGlobal
|
||||||
|
? '$HOME/.claude/hooks/gsd-check-update.sh'
|
||||||
|
: '.claude/hooks/gsd-check-update.sh';
|
||||||
|
|
||||||
|
// Configure SessionStart hook for update checking
|
||||||
|
if (!settings.hooks) {
|
||||||
|
settings.hooks = {};
|
||||||
|
}
|
||||||
|
if (!settings.hooks.SessionStart) {
|
||||||
|
settings.hooks.SessionStart = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if GSD update hook already exists
|
||||||
|
const hasGsdUpdateHook = settings.hooks.SessionStart.some(entry =>
|
||||||
|
entry.hooks && entry.hooks.some(h => h.command && h.command.includes('gsd-check-update'))
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!hasGsdUpdateHook) {
|
||||||
|
settings.hooks.SessionStart.push({
|
||||||
|
hooks: [
|
||||||
|
{
|
||||||
|
type: 'command',
|
||||||
|
command: updateCheckCommand
|
||||||
|
}
|
||||||
|
]
|
||||||
|
});
|
||||||
|
console.log(` ${green}✓${reset} Configured update check hook`);
|
||||||
|
}
|
||||||
|
|
||||||
return { settingsPath, settings, statuslineCommand };
|
return { settingsPath, settings, statuslineCommand };
|
||||||
}
|
}
|
||||||
@@ -238,16 +266,18 @@ function install(isGlobal) {
|
|||||||
/**
|
/**
|
||||||
* Apply statusline config and print completion message
|
* Apply statusline config and print completion message
|
||||||
*/
|
*/
|
||||||
function finishInstall(settingsPath, settings, statuslineCommand, shouldInstall) {
|
function finishInstall(settingsPath, settings, statuslineCommand, shouldInstallStatusline) {
|
||||||
if (shouldInstall) {
|
if (shouldInstallStatusline) {
|
||||||
settings.statusLine = {
|
settings.statusLine = {
|
||||||
type: 'command',
|
type: 'command',
|
||||||
command: statuslineCommand
|
command: statuslineCommand
|
||||||
};
|
};
|
||||||
writeSettings(settingsPath, settings);
|
|
||||||
console.log(` ${green}✓${reset} Configured statusline`);
|
console.log(` ${green}✓${reset} Configured statusline`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Always write settings (hooks were already configured in install())
|
||||||
|
writeSettings(settingsPath, settings);
|
||||||
|
|
||||||
console.log(`
|
console.log(`
|
||||||
${green}Done!${reset} Launch Claude Code and run ${cyan}/gsd:help${reset}.
|
${green}Done!${reset} Launch Claude Code and run ${cyan}/gsd:help${reset}.
|
||||||
`);
|
`);
|
||||||
|
|||||||
@@ -85,6 +85,12 @@ npx get-shit-done-cc --global
|
|||||||
```
|
```
|
||||||
|
|
||||||
Capture output. If install fails, show error and STOP.
|
Capture output. If install fails, show error and STOP.
|
||||||
|
|
||||||
|
Clear the update cache so statusline indicator disappears:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
rm -f ~/.claude/cache/gsd-update-check.json
|
||||||
|
```
|
||||||
</step>
|
</step>
|
||||||
|
|
||||||
<step name="fetch_changelog">
|
<step name="fetch_changelog">
|
||||||
|
|||||||
20
hooks/gsd-check-update.sh
Executable file
20
hooks/gsd-check-update.sh
Executable file
@@ -0,0 +1,20 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Check for GSD updates in background, write result to cache
|
||||||
|
# Called by SessionStart hook - runs once per session
|
||||||
|
|
||||||
|
CACHE_FILE="$HOME/.claude/cache/gsd-update-check.json"
|
||||||
|
mkdir -p "$HOME/.claude/cache"
|
||||||
|
|
||||||
|
# Run check in background (non-blocking)
|
||||||
|
(
|
||||||
|
installed=$(cat "$HOME/.claude/get-shit-done/VERSION" 2>/dev/null || echo "0.0.0")
|
||||||
|
latest=$(npm view get-shit-done-cc version 2>/dev/null)
|
||||||
|
|
||||||
|
if [[ -n "$latest" && "$installed" != "$latest" ]]; then
|
||||||
|
echo "{\"update_available\":true,\"installed\":\"$installed\",\"latest\":\"$latest\",\"checked\":$(date +%s)}" > "$CACHE_FILE"
|
||||||
|
else
|
||||||
|
echo "{\"update_available\":false,\"installed\":\"$installed\",\"latest\":\"${latest:-unknown}\",\"checked\":$(date +%s)}" > "$CACHE_FILE"
|
||||||
|
fi
|
||||||
|
) &
|
||||||
|
|
||||||
|
exit 0
|
||||||
13
hooks/statusline.sh
Normal file → Executable file
13
hooks/statusline.sh
Normal file → Executable file
@@ -40,10 +40,19 @@ if [[ -f "$todo" ]]; then
|
|||||||
task=$(jq -r '.[] | select(.status=="in_progress") | .activeForm' "$todo" 2>/dev/null | head -1)
|
task=$(jq -r '.[] | select(.status=="in_progress") | .activeForm' "$todo" 2>/dev/null | head -1)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# GSD update available?
|
||||||
|
gsd_update=""
|
||||||
|
if [[ -f "$HOME/.claude/cache/gsd-update-check.json" ]]; then
|
||||||
|
update_available=$(jq -r '.update_available' "$HOME/.claude/cache/gsd-update-check.json" 2>/dev/null)
|
||||||
|
if [[ "$update_available" == "true" ]]; then
|
||||||
|
gsd_update=$'\033[33m⬆ /gsd:update\033[0m │ '
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
# Output
|
# Output
|
||||||
dirname=$(basename "$dir")
|
dirname=$(basename "$dir")
|
||||||
if [[ -n "$task" ]]; then
|
if [[ -n "$task" ]]; then
|
||||||
printf '\033[2m%s\033[0m │ \033[1m%s\033[0m │ \033[2m%s\033[0m%s' "$model" "$task" "$dirname" "$ctx"
|
printf '%s\033[2m%s\033[0m │ \033[1m%s\033[0m │ \033[2m%s\033[0m%s' "$gsd_update" "$model" "$task" "$dirname" "$ctx"
|
||||||
else
|
else
|
||||||
printf '\033[2m%s\033[0m │ \033[2m%s\033[0m%s' "$model" "$dirname" "$ctx"
|
printf '%s\033[2m%s\033[0m │ \033[2m%s\033[0m%s' "$gsd_update" "$model" "$dirname" "$ctx"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user