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

20 lines (19 loc) • 794 B
// 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/. /** * Compute the symmetric-valence attention score for one asset's feedback. * * Deterministic: depends only on the integer counts. No clock, no randomness. */ export function computeValenceScore(counts) { const positive = Math.max(0, counts.positive); const negative = Math.max(0, counts.negative); const total = positive + negative; if (total === 0) { return { valence: 0, magnitude: 0, attention: 0 }; } const valence = (positive - negative) / total; const magnitude = Math.abs(valence); return { valence, magnitude, attention: magnitude }; }