mirror of
https://github.com/glittercowboy/get-shit-done
synced 2026-04-25 17:25:23 +02:00
* fix: replace /gsd: command format with /gsd- skill format in all suggestions All next-step suggestions shown to users were still using the old colon format (/gsd:xxx) which cannot be copy-pasted as skills. Migrated all occurrences across agents/, commands/, get-shit-done/, docs/, README files, bin/install.js (hardcoded defaults for claude runtime), and get-shit-done/bin/lib/*.cjs (generate-claude-md templates and error messages). Updated tests to assert new hyphen format instead of old colon format. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: migrate remaining /gsd: format to /gsd- in hooks, workflows, and sdk Addresses remaining user-facing occurrences missed in the initial migration: - hooks/: fix 4 user-facing messages (pause-work, update, fast, quick) and 2 comments in gsd-workflow-guard.js - get-shit-done/workflows/: fix 21 Skill() literal calls that Claude executes directly (installer does not transform workflow content) - sdk/prompt-sanitizer.ts: update regex to strip /gsd- format in addition to legacy /gsd: format; update JSDoc comment - tests/: update autonomous-ui-steps, prompt-sanitizer to assert new format Note: commands/gsd/*.md frontmatter (name: gsd:xxx) intentionally unchanged — installer derives skillName from directory path, not the name field. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(plan-phase): preserve --chain flag in auto-advance sync and handle ui-phase gate in chain mode Bug 1: step 15 sync-flag check only guarded against --auto, causing _auto_chain_active to be cleared when plan-phase is invoked without --auto in ARGUMENTS even though a --chain pipeline was active. Added --chain to the guard condition, matching discuss-phase behaviour. Bug 2: UI Design Contract gate (step 5.6) always exited the workflow when UI-SPEC was missing, breaking the discuss --chain pipeline silently. When _auto_chain_active is true, the gate now auto-invokes gsd-ui-phase --auto via Skill() and continues to step 6 without prompting. Manual invocations retain the existing AskUserQuestion flow. * fix: remove <sub>/clear</sub> pattern and duplicate old-format command in discuss-phase.md --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
127 lines
5.2 KiB
JavaScript
Executable File
127 lines
5.2 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
// gsd-hook-version: {{GSD_VERSION}}
|
|
// Claude Code Statusline - GSD Edition
|
|
// Shows: model | current task | directory | context usage
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const os = require('os');
|
|
|
|
// Read JSON from stdin
|
|
let input = '';
|
|
// Timeout guard: if stdin doesn't close within 3s (e.g. pipe issues on
|
|
// Windows/Git Bash), exit silently instead of hanging. See #775.
|
|
const stdinTimeout = setTimeout(() => process.exit(0), 3000);
|
|
process.stdin.setEncoding('utf8');
|
|
process.stdin.on('data', chunk => input += chunk);
|
|
process.stdin.on('end', () => {
|
|
clearTimeout(stdinTimeout);
|
|
try {
|
|
const data = JSON.parse(input);
|
|
const model = data.model?.display_name || 'Claude';
|
|
const dir = data.workspace?.current_dir || process.cwd();
|
|
const session = data.session_id || '';
|
|
const remaining = data.context_window?.remaining_percentage;
|
|
|
|
// Context window display (shows USED percentage scaled to usable context)
|
|
// Claude Code reserves ~16.5% for autocompact buffer, so usable context
|
|
// is 83.5% of the total window. We normalize to show 100% at that point.
|
|
const AUTO_COMPACT_BUFFER_PCT = 16.5;
|
|
let ctx = '';
|
|
if (remaining != null) {
|
|
// Normalize: subtract buffer from remaining, scale to usable range
|
|
const usableRemaining = Math.max(0, ((remaining - AUTO_COMPACT_BUFFER_PCT) / (100 - AUTO_COMPACT_BUFFER_PCT)) * 100);
|
|
const used = Math.max(0, Math.min(100, Math.round(100 - usableRemaining)));
|
|
|
|
// Write context metrics to bridge file for the context-monitor PostToolUse hook.
|
|
// The monitor reads this file to inject agent-facing warnings when context is low.
|
|
// Reject session IDs with path separators or traversal sequences to prevent
|
|
// a malicious session_id from writing files outside the temp directory.
|
|
const sessionSafe = session && !/[/\\]|\.\./.test(session);
|
|
if (sessionSafe) {
|
|
try {
|
|
const bridgePath = path.join(os.tmpdir(), `claude-ctx-${session}.json`);
|
|
const bridgeData = JSON.stringify({
|
|
session_id: session,
|
|
remaining_percentage: remaining,
|
|
used_pct: used,
|
|
timestamp: Math.floor(Date.now() / 1000)
|
|
});
|
|
fs.writeFileSync(bridgePath, bridgeData);
|
|
} catch (e) {
|
|
// Silent fail -- bridge is best-effort, don't break statusline
|
|
}
|
|
}
|
|
|
|
// Build progress bar (10 segments)
|
|
const filled = Math.floor(used / 10);
|
|
const bar = '█'.repeat(filled) + '░'.repeat(10 - filled);
|
|
|
|
// Color based on usable context thresholds
|
|
if (used < 50) {
|
|
ctx = ` \x1b[32m${bar} ${used}%\x1b[0m`;
|
|
} else if (used < 65) {
|
|
ctx = ` \x1b[33m${bar} ${used}%\x1b[0m`;
|
|
} else if (used < 80) {
|
|
ctx = ` \x1b[38;5;208m${bar} ${used}%\x1b[0m`;
|
|
} else {
|
|
ctx = ` \x1b[5;31m💀 ${bar} ${used}%\x1b[0m`;
|
|
}
|
|
}
|
|
|
|
// Current task from todos
|
|
let task = '';
|
|
const homeDir = os.homedir();
|
|
// Respect CLAUDE_CONFIG_DIR for custom config directory setups (#870)
|
|
const claudeDir = process.env.CLAUDE_CONFIG_DIR || path.join(homeDir, '.claude');
|
|
const todosDir = path.join(claudeDir, 'todos');
|
|
if (session && fs.existsSync(todosDir)) {
|
|
try {
|
|
const files = fs.readdirSync(todosDir)
|
|
.filter(f => f.startsWith(session) && f.includes('-agent-') && f.endsWith('.json'))
|
|
.map(f => ({ name: f, mtime: fs.statSync(path.join(todosDir, f)).mtime }))
|
|
.sort((a, b) => b.mtime - a.mtime);
|
|
|
|
if (files.length > 0) {
|
|
try {
|
|
const todos = JSON.parse(fs.readFileSync(path.join(todosDir, files[0].name), 'utf8'));
|
|
const inProgress = todos.find(t => t.status === 'in_progress');
|
|
if (inProgress) task = inProgress.activeForm || '';
|
|
} catch (e) {}
|
|
}
|
|
} catch (e) {
|
|
// Silently fail on file system errors - don't break statusline
|
|
}
|
|
}
|
|
|
|
// GSD update available?
|
|
// Check shared cache first (#1421), fall back to runtime-specific cache for
|
|
// backward compatibility with older gsd-check-update.js versions.
|
|
let gsdUpdate = '';
|
|
const sharedCacheFile = path.join(homeDir, '.cache', 'gsd', 'gsd-update-check.json');
|
|
const legacyCacheFile = path.join(claudeDir, 'cache', 'gsd-update-check.json');
|
|
const cacheFile = fs.existsSync(sharedCacheFile) ? sharedCacheFile : legacyCacheFile;
|
|
if (fs.existsSync(cacheFile)) {
|
|
try {
|
|
const cache = JSON.parse(fs.readFileSync(cacheFile, 'utf8'));
|
|
if (cache.update_available) {
|
|
gsdUpdate = '\x1b[33m⬆ /gsd-update\x1b[0m │ ';
|
|
}
|
|
if (cache.stale_hooks && cache.stale_hooks.length > 0) {
|
|
gsdUpdate += '\x1b[31m⚠ stale hooks — run /gsd-update\x1b[0m │ ';
|
|
}
|
|
} catch (e) {}
|
|
}
|
|
|
|
// Output
|
|
const dirname = path.basename(dir);
|
|
if (task) {
|
|
process.stdout.write(`${gsdUpdate}\x1b[2m${model}\x1b[0m │ \x1b[1m${task}\x1b[0m │ \x1b[2m${dirname}\x1b[0m${ctx}`);
|
|
} else {
|
|
process.stdout.write(`${gsdUpdate}\x1b[2m${model}\x1b[0m │ \x1b[2m${dirname}\x1b[0m${ctx}`);
|
|
}
|
|
} catch (e) {
|
|
// Silent fail - don't break statusline on parse errors
|
|
}
|
|
});
|