mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 07:03:25 +00:00
fix(coding-agent): normalize @ path prefixes closes #1206
This commit is contained in:
parent
1fbafd6cc7
commit
c9a20a3aa4
2 changed files with 7 additions and 1 deletions
|
|
@ -1130,6 +1130,8 @@ export default function (pi: ExtensionAPI) {
|
||||||
|
|
||||||
Register tools the LLM can call via `pi.registerTool()`. Tools appear in the system prompt and can have custom rendering.
|
Register tools the LLM can call via `pi.registerTool()`. Tools appear in the system prompt and can have custom rendering.
|
||||||
|
|
||||||
|
Note: Some models are idiots and include the @ prefix in tool path arguments. Built-in tools strip a leading @ before resolving paths. If your custom tool accepts a path, normalize a leading @ as well.
|
||||||
|
|
||||||
### Tool Definition
|
### Tool Definition
|
||||||
|
|
||||||
```typescript
|
```typescript
|
||||||
|
|
|
||||||
|
|
@ -32,8 +32,12 @@ function fileExists(filePath: string): boolean {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeAtPrefix(filePath: string): string {
|
||||||
|
return filePath.startsWith("@") ? filePath.slice(1) : filePath;
|
||||||
|
}
|
||||||
|
|
||||||
export function expandPath(filePath: string): string {
|
export function expandPath(filePath: string): string {
|
||||||
const normalized = normalizeUnicodeSpaces(filePath);
|
const normalized = normalizeUnicodeSpaces(normalizeAtPrefix(filePath));
|
||||||
if (normalized === "~") {
|
if (normalized === "~") {
|
||||||
return os.homedir();
|
return os.homedir();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue