fix(installer): use correct config path for local OpenCode installs
Local OpenCode installs were overwriting ~/.config/opencode/opencode.json instead of ./.opencode/opencode.json. This fix threads the isGlobal flag through the install/uninstall chain so permissions are written to the correct location. Fixes #435 Co-Authored-By: Gary Trakhman <gtrak@users.noreply.github.com>
This commit is contained in:
@@ -957,7 +957,11 @@ function uninstall(isGlobal, runtime = 'claude') {
|
|||||||
|
|
||||||
// 6. For OpenCode, clean up permissions from opencode.json
|
// 6. For OpenCode, clean up permissions from opencode.json
|
||||||
if (isOpencode) {
|
if (isOpencode) {
|
||||||
const opencodeConfigDir = getOpencodeGlobalDir();
|
// For local uninstalls, clean up ./.opencode/opencode.json
|
||||||
|
// For global uninstalls, clean up ~/.config/opencode/opencode.json
|
||||||
|
const opencodeConfigDir = isGlobal
|
||||||
|
? getOpencodeGlobalDir()
|
||||||
|
: path.join(process.cwd(), '.opencode');
|
||||||
const configPath = path.join(opencodeConfigDir, 'opencode.json');
|
const configPath = path.join(opencodeConfigDir, 'opencode.json');
|
||||||
if (fs.existsSync(configPath)) {
|
if (fs.existsSync(configPath)) {
|
||||||
try {
|
try {
|
||||||
@@ -1071,10 +1075,14 @@ function parseJsonc(content) {
|
|||||||
/**
|
/**
|
||||||
* Configure OpenCode permissions to allow reading GSD reference docs
|
* Configure OpenCode permissions to allow reading GSD reference docs
|
||||||
* This prevents permission prompts when GSD accesses the get-shit-done directory
|
* This prevents permission prompts when GSD accesses the get-shit-done directory
|
||||||
|
* @param {boolean} isGlobal - Whether this is a global or local install
|
||||||
*/
|
*/
|
||||||
function configureOpencodePermissions() {
|
function configureOpencodePermissions(isGlobal = true) {
|
||||||
// OpenCode config file is at ~/.config/opencode/opencode.json
|
// For local installs, use ./.opencode/opencode.json
|
||||||
const opencodeConfigDir = getOpencodeGlobalDir();
|
// For global installs, use ~/.config/opencode/opencode.json
|
||||||
|
const opencodeConfigDir = isGlobal
|
||||||
|
? getOpencodeGlobalDir()
|
||||||
|
: path.join(process.cwd(), '.opencode');
|
||||||
const configPath = path.join(opencodeConfigDir, 'opencode.json');
|
const configPath = path.join(opencodeConfigDir, 'opencode.json');
|
||||||
|
|
||||||
// Ensure config directory exists
|
// Ensure config directory exists
|
||||||
@@ -1548,7 +1556,7 @@ function install(isGlobal, runtime = 'claude') {
|
|||||||
/**
|
/**
|
||||||
* Apply statusline config, then print completion message
|
* Apply statusline config, then print completion message
|
||||||
*/
|
*/
|
||||||
function finishInstall(settingsPath, settings, statuslineCommand, shouldInstallStatusline, runtime = 'claude') {
|
function finishInstall(settingsPath, settings, statuslineCommand, shouldInstallStatusline, runtime = 'claude', isGlobal = true) {
|
||||||
const isOpencode = runtime === 'opencode';
|
const isOpencode = runtime === 'opencode';
|
||||||
|
|
||||||
if (shouldInstallStatusline && !isOpencode) {
|
if (shouldInstallStatusline && !isOpencode) {
|
||||||
@@ -1564,7 +1572,7 @@ function finishInstall(settingsPath, settings, statuslineCommand, shouldInstallS
|
|||||||
|
|
||||||
// Configure OpenCode permissions
|
// Configure OpenCode permissions
|
||||||
if (isOpencode) {
|
if (isOpencode) {
|
||||||
configureOpencodePermissions();
|
configureOpencodePermissions(isGlobal);
|
||||||
}
|
}
|
||||||
|
|
||||||
let program = 'Claude Code';
|
let program = 'Claude Code';
|
||||||
@@ -1740,21 +1748,21 @@ function installAllRuntimes(runtimes, isGlobal, isInteractive) {
|
|||||||
|
|
||||||
handleStatusline(primaryResult.settings, isInteractive, (shouldInstallStatusline) => {
|
handleStatusline(primaryResult.settings, isInteractive, (shouldInstallStatusline) => {
|
||||||
if (claudeResult) {
|
if (claudeResult) {
|
||||||
finishInstall(claudeResult.settingsPath, claudeResult.settings, claudeResult.statuslineCommand, shouldInstallStatusline, 'claude');
|
finishInstall(claudeResult.settingsPath, claudeResult.settings, claudeResult.statuslineCommand, shouldInstallStatusline, 'claude', isGlobal);
|
||||||
}
|
}
|
||||||
if (geminiResult) {
|
if (geminiResult) {
|
||||||
finishInstall(geminiResult.settingsPath, geminiResult.settings, geminiResult.statuslineCommand, shouldInstallStatusline, 'gemini');
|
finishInstall(geminiResult.settingsPath, geminiResult.settings, geminiResult.statuslineCommand, shouldInstallStatusline, 'gemini', isGlobal);
|
||||||
}
|
}
|
||||||
|
|
||||||
const opencodeResult = results.find(r => r.runtime === 'opencode');
|
const opencodeResult = results.find(r => r.runtime === 'opencode');
|
||||||
if (opencodeResult) {
|
if (opencodeResult) {
|
||||||
finishInstall(opencodeResult.settingsPath, opencodeResult.settings, opencodeResult.statuslineCommand, false, 'opencode');
|
finishInstall(opencodeResult.settingsPath, opencodeResult.settings, opencodeResult.statuslineCommand, false, 'opencode', isGlobal);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// Only OpenCode
|
// Only OpenCode
|
||||||
const opencodeResult = results[0];
|
const opencodeResult = results[0];
|
||||||
finishInstall(opencodeResult.settingsPath, opencodeResult.settings, opencodeResult.statuslineCommand, false, 'opencode');
|
finishInstall(opencodeResult.settingsPath, opencodeResult.settings, opencodeResult.statuslineCommand, false, 'opencode', isGlobal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user