mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-09 21:00:56 -07:00
feat(cli): add support for the ${extensionPath} variable in extension TOML commands (#22681)
This commit is contained in:
committed by
Jerop Kipruto
parent
d78af8202a
commit
39361bce1f
@@ -39,6 +39,7 @@ interface CommandDirectory {
|
||||
kind: CommandKind;
|
||||
extensionName?: string;
|
||||
extensionId?: string;
|
||||
extensionPath?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,6 +115,7 @@ export class FileCommandLoader implements ICommandLoader {
|
||||
dirInfo.kind,
|
||||
dirInfo.extensionName,
|
||||
dirInfo.extensionId,
|
||||
dirInfo.extensionPath,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -175,6 +177,7 @@ export class FileCommandLoader implements ICommandLoader {
|
||||
kind: CommandKind.EXTENSION_FILE,
|
||||
extensionName: ext.name,
|
||||
extensionId: ext.id,
|
||||
extensionPath: ext.path,
|
||||
}));
|
||||
|
||||
dirs.push(...extensionCommandDirs);
|
||||
@@ -197,6 +200,7 @@ export class FileCommandLoader implements ICommandLoader {
|
||||
kind: CommandKind,
|
||||
extensionName?: string,
|
||||
extensionId?: string,
|
||||
extensionPath?: string,
|
||||
): Promise<SlashCommand | null> {
|
||||
let fileContent: string;
|
||||
try {
|
||||
@@ -235,6 +239,14 @@ export class FileCommandLoader implements ICommandLoader {
|
||||
|
||||
const validDef = validationResult.data;
|
||||
|
||||
// Hydrate extensionPath if this is an extension command
|
||||
if (extensionPath) {
|
||||
validDef.prompt = validDef.prompt.replace(
|
||||
/\$\{extensionPath\}/g,
|
||||
() => extensionPath,
|
||||
);
|
||||
}
|
||||
|
||||
const relativePathWithExt = path.relative(baseDir, filePath);
|
||||
const relativePath = relativePathWithExt.substring(
|
||||
0,
|
||||
|
||||
Reference in New Issue
Block a user