|
|
@@ -17,6 +17,7 @@ describe('loadPluginConfig', () => {
|
|
|
userConfigDir = path.join(tempDir, 'user-config');
|
|
|
originalEnv = { ...process.env };
|
|
|
// Isolate from real user config
|
|
|
+ delete process.env.OPENCODE_CONFIG_DIR;
|
|
|
process.env.XDG_CONFIG_HOME = userConfigDir;
|
|
|
});
|
|
|
|
|
|
@@ -152,6 +153,31 @@ describe('loadPluginConfig', () => {
|
|
|
);
|
|
|
expect(loadPluginConfig(projectDir)).toEqual({});
|
|
|
});
|
|
|
+
|
|
|
+ test('respects OPENCODE_CONFIG_DIR for user config location', () => {
|
|
|
+ const customDir = fs.mkdtempSync(
|
|
|
+ path.join(os.tmpdir(), 'omc-opencode-config-'),
|
|
|
+ );
|
|
|
+ process.env.OPENCODE_CONFIG_DIR = customDir;
|
|
|
+
|
|
|
+ // Write plugin config in the custom directory
|
|
|
+ fs.writeFileSync(
|
|
|
+ path.join(customDir, 'oh-my-opencode-slim.json'),
|
|
|
+ JSON.stringify({
|
|
|
+ agents: { oracle: { model: 'custom/model-from-opencode-config-dir' } },
|
|
|
+ }),
|
|
|
+ );
|
|
|
+
|
|
|
+ const projectDir = path.join(tempDir, 'project');
|
|
|
+ fs.mkdirSync(projectDir, { recursive: true });
|
|
|
+
|
|
|
+ const config = loadPluginConfig(projectDir);
|
|
|
+ expect(config.agents?.oracle?.model).toBe(
|
|
|
+ 'custom/model-from-opencode-config-dir',
|
|
|
+ );
|
|
|
+
|
|
|
+ fs.rmSync(customDir, { recursive: true, force: true });
|
|
|
+ });
|
|
|
});
|
|
|
|
|
|
describe('deepMerge behavior', () => {
|
|
|
@@ -165,6 +191,7 @@ describe('deepMerge behavior', () => {
|
|
|
originalEnv = { ...process.env };
|
|
|
|
|
|
// Set XDG_CONFIG_HOME to control user config location
|
|
|
+ delete process.env.OPENCODE_CONFIG_DIR;
|
|
|
process.env.XDG_CONFIG_HOME = userConfigDir;
|
|
|
});
|
|
|
|
|
|
@@ -408,6 +435,7 @@ describe('preset resolution', () => {
|
|
|
beforeEach(() => {
|
|
|
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'preset-test-'));
|
|
|
originalEnv = { ...process.env };
|
|
|
+ delete process.env.OPENCODE_CONFIG_DIR;
|
|
|
process.env.XDG_CONFIG_HOME = path.join(tempDir, 'user-config');
|
|
|
});
|
|
|
|
|
|
@@ -587,6 +615,7 @@ describe('environment variable preset override', () => {
|
|
|
beforeEach(() => {
|
|
|
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'env-preset-test-'));
|
|
|
originalEnv = { ...process.env };
|
|
|
+ delete process.env.OPENCODE_CONFIG_DIR;
|
|
|
process.env.XDG_CONFIG_HOME = path.join(tempDir, 'user-config');
|
|
|
});
|
|
|
|
|
|
@@ -712,6 +741,7 @@ describe('JSONC config support', () => {
|
|
|
beforeEach(() => {
|
|
|
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'jsonc-test-'));
|
|
|
originalEnv = { ...process.env };
|
|
|
+ delete process.env.OPENCODE_CONFIG_DIR;
|
|
|
process.env.XDG_CONFIG_HOME = path.join(tempDir, 'user-config');
|
|
|
});
|
|
|
|
|
|
@@ -898,6 +928,7 @@ describe('loadAgentPrompt', () => {
|
|
|
beforeEach(() => {
|
|
|
tempDir = fs.mkdtempSync(path.join(os.tmpdir(), 'prompt-test-'));
|
|
|
originalEnv = { ...process.env };
|
|
|
+ delete process.env.OPENCODE_CONFIG_DIR;
|
|
|
process.env.XDG_CONFIG_HOME = tempDir;
|
|
|
});
|
|
|
|
|
|
@@ -1086,4 +1117,23 @@ describe('loadAgentPrompt', () => {
|
|
|
const result = loadAgentPrompt('xdg-agent');
|
|
|
expect(result.prompt).toBe('xdg prompt');
|
|
|
});
|
|
|
+
|
|
|
+ test('respects OPENCODE_CONFIG_DIR for prompt location', () => {
|
|
|
+ const customDir = fs.mkdtempSync(
|
|
|
+ path.join(os.tmpdir(), 'omc-prompt-config-'),
|
|
|
+ );
|
|
|
+ process.env.OPENCODE_CONFIG_DIR = customDir;
|
|
|
+
|
|
|
+ const promptsDir = path.join(customDir, 'oh-my-opencode-slim');
|
|
|
+ fs.mkdirSync(promptsDir, { recursive: true });
|
|
|
+ fs.writeFileSync(
|
|
|
+ path.join(promptsDir, 'oracle.md'),
|
|
|
+ 'prompt from OPENCODE_CONFIG_DIR dir',
|
|
|
+ );
|
|
|
+
|
|
|
+ const result = loadAgentPrompt('oracle');
|
|
|
+ expect(result.prompt).toBe('prompt from OPENCODE_CONFIG_DIR dir');
|
|
|
+
|
|
|
+ fs.rmSync(customDir, { recursive: true, force: true });
|
|
|
+ });
|
|
|
});
|