fix(file-reference-resolver): expand env vars in path references

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
YeonGyu-Kim
2026-04-27 17:45:27 +09:00
parent 5e4aa8b827
commit a46b7b8240
2 changed files with 68 additions and 6 deletions
+12 -4
View File
@@ -30,12 +30,20 @@ function findFileReferences(text: string): FileMatch[] {
return matches
}
function resolveFilePath(filePath: string, cwd: string): string {
if (isAbsolute(filePath)) {
return resolve(filePath)
export function resolveFilePath(filePath: string, cwd: string): string {
const expanded = filePath.replace(/\$\{(\w+)\}|\$(\w+)/g, (match, braced: string | undefined, bare: string | undefined) => {
const variableName = braced ?? bare
if (!variableName) {
return match
}
return process.env[variableName] ?? match
})
if (isAbsolute(expanded)) {
return resolve(expanded)
}
return resolve(cwd, filePath)
return resolve(cwd, expanded)
}
function readFileContent(resolvedPath: string): string {