@podut/cwescan-tools-ai-sdk
v0.2.2
Published
CWEScan tools for Vercel AI SDK
Maintainers
Readme
podut cwescan AI SDK
@podut/cwescan-tools-ai-sdk provides Vercel AI SDK compatible tools and agents that give your AI applications access to up to date library documentation through cwescan.
Use this package to:
- Add documentation lookup tools to your AI SDK workflows with
generateTextorstreamText - Create documentation aware agents using the pre-configured
cwescanAgent - Build RAG pipelines that retrieve accurate, version specific code examples
The package provides two main tools:
resolveLibrary- Searches cwescan's database to find the correct library IDgetLibraryDocs- Fetches documentation for a specific library with optional topic filtering
Quick Start
Install
npm install @podut/cwescan-tools-ai-sdk @podut/cwescan-sdk ai zodGet API Key
Get your API key from cwescan
Usage
Using Tools with generateText
import { resolveLibrary, getLibraryDocs } from "@podut/cwescan-tools-ai-sdk";
import { generateText, stepCountIs } from "ai";
import { openai } from "@ai-sdk/openai";
const { text } = await generateText({
model: openai("gpt-4o"),
prompt: "How do I use React Server Components?",
tools: {
resolveLibrary: resolveLibrary(),
getLibraryDocs: getLibraryDocs(),
},
stopWhen: stepCountIs(5),
});
console.log(text);Using the cwescan Agent
The package provides a pre-configured agent that handles the multi-step workflow automatically:
import { cwescanAgent } from "@podut/cwescan-tools-ai-sdk";
import { anthropic } from "@ai-sdk/anthropic";
const agent = new cwescanAgent({
model: anthropic("claude-sonnet-4-20250514"),
});
const { text } = await agent.generate({
prompt: "How do I set up routing in Next.js?",
});
console.log(text);Configuration
Environment Variables
Set your API key via environment variable:
cwescan_API_KEY=cwescansk-...Then use tools and agents without explicit configuration:
const tool = resolveLibrary(); // Uses cwescan_API_KEY automaticallyDocs
See the documentation for details.
Contributing
Running tests
pnpm testBuilding
pnpm build