Fix(cli): Use the correct extensionPath (#11896)

This commit is contained in:
Eric Rahm
2025-10-24 10:45:58 -07:00
committed by GitHub
parent 8bdef8754e
commit a123a813b2
2 changed files with 27 additions and 2 deletions

View File

@@ -474,11 +474,10 @@ export class ExtensionManager {
`Invalid configuration in ${configFilePath}: missing ${!rawConfig.name ? '"name"' : '"version"'}`,
);
}
const installDir = new ExtensionStorage(rawConfig.name).getExtensionDir();
const config = recursivelyHydrateStrings(
rawConfig as unknown as JsonObject,
{
extensionPath: installDir,
extensionPath: extensionDir,
workspacePath: this.workspaceDir,
'/': path.sep,
pathSeparator: path.sep,

View File

@@ -285,6 +285,32 @@ describe('extension tests', () => {
]);
});
it('should hydrate ${extensionPath} correctly for linked extensions', async () => {
const sourceExtDir = createExtension({
extensionsDir: tempWorkspaceDir,
name: 'my-linked-extension-with-path',
version: '1.0.0',
mcpServers: {
'test-server': {
command: 'node',
args: ['${extensionPath}/server/index.js'],
cwd: '${extensionPath}/server',
},
},
});
await extensionManager.installOrUpdateExtension({
source: sourceExtDir,
type: 'link',
});
const extensions = extensionManager.loadExtensions();
expect(extensions).toHaveLength(1);
expect(extensions[0].mcpServers?.['test-server'].cwd).toBe(
path.join(sourceExtDir, 'server'),
);
});
it('should resolve environment variables in extension configuration', () => {
process.env['TEST_API_KEY'] = 'test-api-key-123';
process.env['TEST_DB_URL'] = 'postgresql://localhost:5432/testdb';