UNPKG

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

77 lines (76 loc) • 3.13 kB
// 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/. /** * Valid proposal `source` values (#385): typed sources keep accept-rate per * source aggregatable (PROV-DM). An unknown value is accepted with a warning. */ export const PROPOSAL_SOURCES = [ "reflect", "distill", "consolidate", /** The consolidate pair pass's own retire proposals (alpha.9, S6) — kept apart from `consolidate`'s promotions so a bulk `accept --generator consolidate` never sweeps a retirement, and the reverse. */ "consolidate-pair", "extract", "improve", "feedback", "propose", "remember", "import", "distill_quality_rejected", "schema-repair", ]; /** Automated sources, which should carry a `sourceRun`. */ export const AUTOMATED_PROPOSAL_SOURCES = [ "reflect", "distill", "consolidate", "consolidate-pair", "extract", "improve", "schema-repair", ]; export function isValidProposalSource(source) { return PROPOSAL_SOURCES.includes(source); } export function isAutomatedProposalSource(source) { return AUTOMATED_PROPOSAL_SOURCES.includes(source); } /** * When a pending proposal's wait for review began: its last reopen (#997), else * its creation. Every age-based sweep — retention expiry, and `--older-than` on * bulk accept/reject and on `drain` — counts from here, so a proposal just put * back in the queue is not swept as if it had been waiting since it was first * created (a scheduled `drain --older-than 7 --promote` would otherwise take * it at once). */ export function proposalWaitingSince(proposal) { return proposal.reviewHistory?.at(-1)?.reopenedAt ?? proposal.createdAt; } /** A pending or accepted proposal whose primary change deletes its target (a consolidate retire proposal, alpha.9). */ export function isRetireProposal(proposal) { return proposal.changes[0]?.op === "delete"; } /** A promote refused because the target changed after mint (STALE, R20) — not a merit judgement. */ export const STALE_TARGET_GATE_REASON = "stale-target"; /** The gate on a retire proposal the triage drain may accept unattended: a staged pair-judged retirement. */ export const PAIR_PASS_GATE = "consolidate-pair"; export const EXPIRED_GATE_REASON = "expired"; export const ASSET_MISSING_GATE_REASON = "asset-missing"; const PROCEDURAL_GATE_REASONS = new Set([ STALE_TARGET_GATE_REASON, EXPIRED_GATE_REASON, ASSET_MISSING_GATE_REASON, ]); /** * A rejection nobody judged on its content (stale target, expiry, orphan * purge). The "previously rejected" prompt context and the accept-rate metric * leave these out. Expiries archived before the gate reason existed are known * by their review reason. */ export function isProceduralRejection(proposal) { if (proposal.gateDecision?.outcome === "auto-rejected" && PROCEDURAL_GATE_REASONS.has(proposal.gateDecision.reason)) { return true; } return proposal.review?.reason?.startsWith("expired:") === true; }