Three files had hardcoded `.claude` paths that break OpenCode and Gemini installations where the config directory is `.config/opencode`, `.opencode`, or `.gemini` respectively. Changes: - hooks/gsd-check-update.js: add detectConfigDir() helper that checks all runtime directories for get-shit-done/VERSION, falling back to .claude. Used for cache dir, project VERSION, and global VERSION. - commands/gsd/reapply-patches.md: detect runtime directory for both global and local patch directories instead of hardcoding ~/.claude/ and ./.claude/ - workflows/update.md: detect runtime directory for local and global VERSION/marker files, and clear cache across all runtime directories Closes #682 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
76 lines
2.5 KiB
JavaScript
Executable File
76 lines
2.5 KiB
JavaScript
Executable File
#!/usr/bin/env node
|
|
// Check for GSD updates in background, write result to cache
|
|
// Called by SessionStart hook - runs once per session
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const os = require('os');
|
|
const { spawn } = require('child_process');
|
|
|
|
const homeDir = os.homedir();
|
|
const cwd = process.cwd();
|
|
|
|
// Detect runtime config directory (supports Claude, OpenCode, Gemini)
|
|
function detectConfigDir(baseDir) {
|
|
for (const dir of ['.config/opencode', '.opencode', '.gemini', '.claude']) {
|
|
if (fs.existsSync(path.join(baseDir, dir, 'get-shit-done', 'VERSION'))) {
|
|
return path.join(baseDir, dir);
|
|
}
|
|
}
|
|
return path.join(baseDir, '.claude');
|
|
}
|
|
|
|
const globalConfigDir = detectConfigDir(homeDir);
|
|
const projectConfigDir = detectConfigDir(cwd);
|
|
const cacheDir = path.join(globalConfigDir, 'cache');
|
|
const cacheFile = path.join(cacheDir, 'gsd-update-check.json');
|
|
|
|
// VERSION file locations (check project first, then global)
|
|
const projectVersionFile = path.join(projectConfigDir, 'get-shit-done', 'VERSION');
|
|
const globalVersionFile = path.join(globalConfigDir, 'get-shit-done', 'VERSION');
|
|
|
|
// Ensure cache directory exists
|
|
if (!fs.existsSync(cacheDir)) {
|
|
fs.mkdirSync(cacheDir, { recursive: true });
|
|
}
|
|
|
|
// Run check in background (spawn background process, windowsHide prevents console flash)
|
|
const child = spawn(process.execPath, ['-e', `
|
|
const fs = require('fs');
|
|
const { execSync } = require('child_process');
|
|
|
|
const cacheFile = ${JSON.stringify(cacheFile)};
|
|
const projectVersionFile = ${JSON.stringify(projectVersionFile)};
|
|
const globalVersionFile = ${JSON.stringify(globalVersionFile)};
|
|
|
|
// Check project directory first (local install), then global
|
|
let installed = '0.0.0';
|
|
try {
|
|
if (fs.existsSync(projectVersionFile)) {
|
|
installed = fs.readFileSync(projectVersionFile, 'utf8').trim();
|
|
} else if (fs.existsSync(globalVersionFile)) {
|
|
installed = fs.readFileSync(globalVersionFile, 'utf8').trim();
|
|
}
|
|
} catch (e) {}
|
|
|
|
let latest = null;
|
|
try {
|
|
latest = execSync('npm view get-shit-done-cc version', { encoding: 'utf8', timeout: 10000, windowsHide: true }).trim();
|
|
} catch (e) {}
|
|
|
|
const result = {
|
|
update_available: latest && installed !== latest,
|
|
installed,
|
|
latest: latest || 'unknown',
|
|
checked: Math.floor(Date.now() / 1000)
|
|
};
|
|
|
|
fs.writeFileSync(cacheFile, JSON.stringify(result));
|
|
`], {
|
|
stdio: 'ignore',
|
|
windowsHide: true,
|
|
detached: true // Required on Windows for proper process detachment
|
|
});
|
|
|
|
child.unref();
|