Registry / testing / codepolicy

codepolicy

JSON →
library0.2.2jsnpmunverified

LLM-powered semantic lint tool for CI pipelines (v0.2.2). Catches design violations that static analysis can't — naming inconsistencies, misplaced responsibilities, implicit fallbacks, and more. Requires Node.js >= 22. Ships 9 built-in rules with configurable thresholds and supports multiple LLM providers (OpenAI, Anthropic, GitHub Copilot). Filter mode supports diff-only or full-codebase analysis. Written in TypeScript with shipped type definitions. Release cadence: early stage, frequent minor updates.

npm install codepolicy
INSTALL
IMPORT
SIG · CODEPOLICY
C
codepolicy
testingjavascriptv0.2.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import codepolicy from 'codepolicy'
const codepolicy = require('codepolicy')
ESM-only due to Node >= 22 requirement. CommonJS require will fail.
runLint
import { runLint } from 'codepolicy'
Named export for programmatic usage. Only available in ESM.
types
import type { RuleConfig } from 'codepolicy'
TypeScript types are bundled. Use type-only imports for interfaces.

Installation, configuration file creation, CLI run, and programmatic usage example.

// Ensure Node version >= 22 // 1. Install as dev dependency // npm install -D codepolicy // 2. Create .codepolicy.yml in project root: // filter: diff // agent: github-copilot/gpt-4.1 // rules: // function-contract: error // ssot-violation: warn // ignore: // - dist/** // 3. Run: npx codepolicy // Programmatic usage example: import { runLint } from 'codepolicy'; async function lint() { const result = await runLint({ filter: 'diff', agent: 'gpt-4', rules: { 'function-contract': 'error' }, ignore: ['dist/**'] }); console.log(result); }
Debug
Known issues
gotchaRequires Node.js >= 22. Older Node versions will fail at import/require time.
fix
Upgrade Node to >= 22 or use nvm to switch.
affects: <0.1.0
breakingESM-only package. CommonJS require() will throw MODULE_NOT_FOUND or similar error.
fix
Use import syntax or dynamic import(). Set type: 'module' in package.json.
affects: >=0.1.0
gotchaLLM provider detection based on model name pattern may pick wrong provider if names overlap (e.g., 'claude-...' requires ANTHROPIC_API_KEY).
fix
Explicitly set provider via config or environment variable. Ensure correct API key is set.
affects: >=0.1.0
gotchaDefault concurrency is 10 (CLI) or 5 (config). High parallelism may cause rate limit errors with some LLM providers.
fix
Reduce concurrency value in config or CLI argument --concurrency 2.
affects: >=0.1.0
deprecatedFilter mode 'all' may be removed in future versions; 'diff' is recommended.
fix
Use 'diff' filter mode for CI; it processes only changed files.
affects: >=0.2.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module /path/to/codepolicy/index.js from /path/to/your/script.js not supported.
Using CommonJS require() on an ESM-only package.
fix
Switch to ESM: use import syntax or dynamic import(). Set "type": "module" in package.json.
Error: Node.js version 18.x is not supported. Minimum required: 22
Running codepolicy on Node.js < 22.
fix
Upgrade Node.js to >= 22. Use nvm or download from nodejs.org.
Error: Agent name 'gpt-4' could not be resolved to a valid provider.
LLM model name doesn't match any known pattern.
fix
Use full model name with provider prefix, e.g., 'openai/gpt-4' or 'github-copilot/gpt-4.1'. Check docs for supported patterns.
Upgrade
Version history
0.2.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
OpenAI (training)
1
Resources
codepolicy — npm install codepolicy · libregistry