akm-cli
Version:
akm (Agent Knowledge Manager) — a portable, local-first capability library for AI agents. Discover, load, share, and improve reusable skills, scripts, workflows, and knowledge across any shell-capable coding agent, including Claude Code, OpenCode, and Cur
26 lines (25 loc) • 1.21 kB
JavaScript
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
/**
* The content of a proposal's PRIMARY change (WI-6.2 envelope read path).
*
* By construction `changes[0].after === payload.content` for a `create` or
* `update` change; consumers read through this accessor so the
* single-content assumption lives in ONE place. A `delete` primary change (a
* consolidate retire proposal, alpha.9) writes no content by definition, so
* it reads as `""` here rather than throwing — every generic proposal scan
* (dedup-by-body-hash, the triage drain's diff-size filter, the quality
* validators) can call this on ANY pending proposal, retire included,
* without special-casing the op first. Typed structurally (not against
* `Proposal`) so this module stays dependency-free.
*/
export function proposalContent(p) {
const primary = p.changes[0];
if (primary?.op === "delete")
return "";
const content = primary?.after;
if (content === undefined)
throw new Error("Proposal primary change has no content.");
return content;
}