@plasius/ai-rag
v0.1.6
Published
Retrieval, context packing, provenance, and prompt-injection guard contracts for Plasius AI RAG.
Downloads
326
Maintainers
Readme
@plasius/ai-rag
Retrieval, context packing, provenance, and prompt-injection guard contracts for Plasius AI RAG.
Scope
This package is part of the layered @plasius/ai-* package family. It defines the external contracts for retrieval provenance, context packing, trust-aware truncation, and prompt-injection guard behavior.
Install
npm install @plasius/ai-ragContracts
AI_RAG_FEATURE_FLAGSdeclares the feature flags for RAG, provenance, and injection guard behavior.resolveAiRagContextbuilds deterministic packed contexts from scored chunks and emits trust/provenance reason codes.isAiRagChunkSafeprovides a simple trust utility for non-blocking callers.packageDescriptorexposes package name, primary flag, env prefix, and summary.
Usage
import {
AI_RAG_FEATURE_FLAGS,
resolveAiRagContext,
} from "@plasius/ai-rag";
const result = resolveAiRagContext({
query: "What happened in the last hour?",
chunks: [
{
chunkId: "chunk-1",
sourceScope: "knowledge-base",
sourceId: "kb-2026",
text: "A major weather event was recorded near the delta.",
trust: 0.93,
citation: "https://knowledge-base/docs/delta",
},
],
featureFlags: {
[AI_RAG_FEATURE_FLAGS.rag]: true,
[AI_RAG_FEATURE_FLAGS.provenance]: true,
[AI_RAG_FEATURE_FLAGS.injectionGuard]: true,
},
maxContextChars: 1200,
});
console.log(result.packedContext);
console.log(result.status);Development
npm install
npm run build
npm test
npm run test:coverage
npm run pack:checkRelease Workflow
Protected main releases use a two-step flow:
- Run
.github/workflows/cd.ymlwithbump=patch|minor|majorto open or refresh arelease/vX.Y.Zprep PR. - Merge that PR to
main. - Rerun
.github/workflows/cd.ymlonmainwithbump=noneto tag, draft the GitHub release, and publish to npm.
Governance
- Security policy: SECURITY.md
- Code of conduct: CODE_OF_CONDUCT.md
- ADRs: docs/adrs
- CLA and legal docs: legal
License
Apache-2.0
