mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-18 00:02:45 +00:00
Support pi-internal:// scheme in read tool
Resolves pi-internal:// paths to the coding-agent package directory, allowing the model to read internal documentation. Appends a hint showing the filesystem path and instructing to use it for further reads.
This commit is contained in:
parent
be26d362fa
commit
012319e15a
3 changed files with 433 additions and 2 deletions
|
|
@ -1,9 +1,11 @@
|
|||
import { accessSync, constants } from "node:fs";
|
||||
import * as os from "node:os";
|
||||
import { isAbsolute, resolve as resolvePath } from "node:path";
|
||||
import { getPackageDir } from "../../config.js";
|
||||
|
||||
const UNICODE_SPACES = /[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g;
|
||||
const NARROW_NO_BREAK_SPACE = "\u202F";
|
||||
export const PI_INTERNAL_SCHEME = "pi-internal://";
|
||||
|
||||
function normalizeUnicodeSpaces(str: string): string {
|
||||
return str.replace(UNICODE_SPACES, " ");
|
||||
|
|
@ -46,6 +48,12 @@ export function resolveToCwd(filePath: string, cwd: string): string {
|
|||
}
|
||||
|
||||
export function resolveReadPath(filePath: string, cwd: string): string {
|
||||
// Handle pi-internal:// scheme for Pi package documentation
|
||||
if (filePath.startsWith(PI_INTERNAL_SCHEME)) {
|
||||
const relativePath = filePath.slice(PI_INTERNAL_SCHEME.length);
|
||||
return resolvePath(getPackageDir(), relativePath);
|
||||
}
|
||||
|
||||
const resolved = resolveToCwd(filePath, cwd);
|
||||
|
||||
if (fileExists(resolved)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue