@earendil-works/pi-coding-agent
Version:
Coding agent CLI with read, bash, edit, write tools and session management
30 lines • 1.05 kB
JavaScript
import { readFileSync } from "node:fs";
import { stripBom } from "../utils/text.js";
const RESOURCE_FIELDS = ["extensions", "skills", "prompts", "themes"];
function isObject(value) {
return typeof value === "object" && value !== null && !Array.isArray(value);
}
export function readPiManifest(packageJsonPath) {
try {
const pkg = JSON.parse(stripBom(readFileSync(packageJsonPath, "utf-8")));
if (!isObject(pkg) || !isObject(pkg.pi)) {
return null;
}
const manifest = {};
for (const field of RESOURCE_FIELDS) {
const entries = pkg.pi[field];
if (Array.isArray(entries) && entries.every((entry) => typeof entry === "string")) {
manifest[field] = entries;
}
}
const changelogPath = pkg.pi.changelogPath;
if (typeof changelogPath === "string") {
manifest.changelogPath = changelogPath;
}
return manifest;
}
catch {
return null;
}
}
//# sourceMappingURL=pi-manifest.js.map