UNPKG

@earendil-works/pi-coding-agent

Version:

Coding agent CLI with read, bash, edit, write tools and session management

48 lines • 1.85 kB
import { canonicalizePath, getPathComparisonKey } from "../utils/paths.js"; export function getSourcePackageKey(identity) { return JSON.stringify({ source: identity.source, scope: identity.scope, }); } /** Prefix of built-in tool and extension paths, such as `builtin:read` or `builtin:mcp`. */ export const BUILTIN_PATH_PREFIX = "builtin:"; /** * Source of a path that names no file: `builtin` for `builtin:<name>`, or the prefix of an * angle-bracket path such as `inline` for `<inline:name>`. Undefined for file paths. */ export function getSyntheticPathSource(path) { if (path.startsWith(BUILTIN_PATH_PREFIX)) return "builtin"; if (path.startsWith("<") && path.endsWith(">")) return path.slice(1, -1).split(":")[0] || "temporary"; return undefined; } export function isSyntheticPath(path) { return path.startsWith(BUILTIN_PATH_PREFIX) || path.startsWith("<"); } /** Key for deduplicating resource paths: synthetic paths as-is, file paths via realpath and platform casing. */ export function getResourcePathKey(path) { return isSyntheticPath(path) ? path : getPathComparisonKey(canonicalizePath(path)); } export function createSourceInfo(path, metadata) { return { path, source: metadata.source, scope: metadata.scope, origin: metadata.origin, baseDir: metadata.baseDir, ...(metadata.changelogPath ? { changelogPath: metadata.changelogPath } : {}), }; } export function createSyntheticSourceInfo(path, options) { return { path, source: options.source, scope: options.scope ?? "temporary", origin: options.origin ?? "top-level", baseDir: options.baseDir, ...(options.changelogPath ? { changelogPath: options.changelogPath } : {}), }; } //# sourceMappingURL=source-info.js.map