matthewwong525/WongStack / .agents/plugins/memory
memory
Verifiedscripts/lib/documents/input.mjs
View on GitHubimport { SCOPES, SLUG } from './corpus.mjs';
const MODES = ['auto', 'keyword'], REMOVED_MODES = ['semantic', 'deep'];
const hasControls = text => Array.from(text).some(char => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127);
export class RetrievalInputError extends Error { constructor(message) { super(message); this.code = 2; } }
// A removed mode stops with its own message: a silent keyword answer would hide the removal.
export function refuseRemovedMode(mode) {
if (REMOVED_MODES.includes(mode)) throw new RetrievalInputError(`Meaning-based search was removed, so mode ${mode} is gone. Search is by words only: leave --mode out.`);
}
export function validateRetrieval(question, values = {}, { recall = false } = {}) {
const allowed = ['scope', 'mode', 'change', 'limit', 'json', 'help', ...(recall ? ['tag', 'type', 'slug', 'since', 'until'] : [])];
if (Object.keys(values).some(key => !allowed.includes(key))) throw new RetrievalInputError('Unsupported retrieval option; fact-wide expansion is not supported');
if (typeof question !== 'string' || !question.trim() || question.length > 4000 || hasControls(question)
|| /(?:^|\s)(?:lex|vec|hyde|intent):/i.test(question)) throw new RetrievalInputError('Question must be 1–4000 characters without newlines or typed query fields');
refuseRemovedMode(values.mode);
const scope = values.scope || 'current', mode = values.mode || 'auto', limit = values.limit === undefined ? 5 : Number(values.limit);
if (!Object.hasOwn(SCOPES, scope) || !MODES.includes(mode) || !Number.isInteger(limit) || limit < 1 || limit > 5)
throw new RetrievalInputError('Use scope current|history|active|all, mode auto|keyword and limit 1–5');
if (values.change !== undefined && (values.change.length > 200 || !SLUG.test(values.change))) throw new RetrievalInputError('Invalid change slug');
if (values.type && !['user', 'feedback', 'project', 'reference', 'thread'].includes(values.type)) throw new RetrievalInputError('Invalid fact type');
const filters = {};
for (const key of ['tag', 'type', 'slug', 'since', 'until']) {
if (values[key] === undefined) continue;
if (typeof values[key] !== 'string' || !values[key].trim() || values[key].length > 200 || hasControls(values[key])) throw new RetrievalInputError('Invalid fact filter');
filters[key] = values[key];
}
return { question: question.trim(), scope, change: values.change, limit, filters, json: Boolean(values.json) };
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |