UNPKG

@code-yeongyu/senpi

Version:

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

29 lines • 1 kB
import { readFileSync } from "node:fs"; import { stripBom } from "../utils/text.js"; const RESOURCE_FIELDS = ["extensions", "skills", "prompts", "themes", "hooks"]; 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 = {}; if (typeof pkg.pi.system === "boolean") { manifest.system = pkg.pi.system; } for (const field of RESOURCE_FIELDS) { const entries = pkg.pi[field]; if (Array.isArray(entries) && entries.every((entry) => typeof entry === "string")) { manifest[field] = entries; } } return manifest; } catch { return null; } } //# sourceMappingURL=pi-manifest.js.map