@ipation/specbridge 1.3.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -0
- package/dist/cli.js +6042 -375
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +82 -2
- package/dist/index.js +5504 -103
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/verifiers/example-custom.ts +206 -0
package/dist/index.d.ts
CHANGED
|
@@ -250,6 +250,17 @@ interface DecisionCompliance {
|
|
|
250
250
|
constraints: number;
|
|
251
251
|
violations: number;
|
|
252
252
|
compliance: number;
|
|
253
|
+
/** Breakdown of violations by severity (v2.0+) */
|
|
254
|
+
violationsBySeverity?: {
|
|
255
|
+
critical: number;
|
|
256
|
+
high: number;
|
|
257
|
+
medium: number;
|
|
258
|
+
low: number;
|
|
259
|
+
};
|
|
260
|
+
/** Raw weighted score before coverage penalty (v2.0+) */
|
|
261
|
+
weightedScore?: number;
|
|
262
|
+
/** Ratio of violations to constraints (v2.0+) */
|
|
263
|
+
coverageRate?: number;
|
|
253
264
|
}
|
|
254
265
|
/**
|
|
255
266
|
* Trend data point
|
|
@@ -1519,6 +1530,8 @@ declare class VerificationEngine {
|
|
|
1519
1530
|
private registry;
|
|
1520
1531
|
private project;
|
|
1521
1532
|
private astCache;
|
|
1533
|
+
private resultsCache;
|
|
1534
|
+
private pluginsLoaded;
|
|
1522
1535
|
constructor(registry?: Registry);
|
|
1523
1536
|
/**
|
|
1524
1537
|
* Run verification
|
|
@@ -1550,6 +1563,10 @@ declare class AstCache {
|
|
|
1550
1563
|
private cache;
|
|
1551
1564
|
get(filePath: string, project: Project): Promise<SourceFile | null>;
|
|
1552
1565
|
clear(): void;
|
|
1566
|
+
getStats(): {
|
|
1567
|
+
entries: number;
|
|
1568
|
+
memoryEstimate: number;
|
|
1569
|
+
};
|
|
1553
1570
|
}
|
|
1554
1571
|
|
|
1555
1572
|
declare function getChangedFiles(cwd: string): Promise<string[]>;
|
|
@@ -1600,6 +1617,60 @@ interface Verifier {
|
|
|
1600
1617
|
*/
|
|
1601
1618
|
verify(ctx: VerificationContext): Promise<Violation[]>;
|
|
1602
1619
|
}
|
|
1620
|
+
/**
|
|
1621
|
+
* Plugin metadata
|
|
1622
|
+
*/
|
|
1623
|
+
interface VerifierPluginMetadata {
|
|
1624
|
+
/** Unique identifier matching /^[a-z][a-z0-9-]*$/ */
|
|
1625
|
+
id: string;
|
|
1626
|
+
/** Semver version string */
|
|
1627
|
+
version: string;
|
|
1628
|
+
/** Plugin author */
|
|
1629
|
+
author?: string;
|
|
1630
|
+
/** Brief description of what this verifier checks */
|
|
1631
|
+
description?: string;
|
|
1632
|
+
}
|
|
1633
|
+
/**
|
|
1634
|
+
* Verifier plugin interface
|
|
1635
|
+
* Custom verifiers must export a default object implementing this interface
|
|
1636
|
+
*/
|
|
1637
|
+
interface VerifierPlugin {
|
|
1638
|
+
/** Plugin metadata */
|
|
1639
|
+
metadata: VerifierPluginMetadata;
|
|
1640
|
+
/** Factory function that creates a new verifier instance */
|
|
1641
|
+
createVerifier: () => Verifier;
|
|
1642
|
+
/** Optional Zod schema for validating constraint.check.params */
|
|
1643
|
+
paramsSchema?: unknown;
|
|
1644
|
+
}
|
|
1645
|
+
/**
|
|
1646
|
+
* Helper to define a verifier plugin with type safety
|
|
1647
|
+
*
|
|
1648
|
+
* @example
|
|
1649
|
+
* ```typescript
|
|
1650
|
+
* import { defineVerifierPlugin, type Verifier } from '@ipation/specbridge';
|
|
1651
|
+
*
|
|
1652
|
+
* class MyVerifier implements Verifier {
|
|
1653
|
+
* readonly id = 'my-custom';
|
|
1654
|
+
* readonly name = 'My Custom Verifier';
|
|
1655
|
+
* readonly description = 'Checks custom patterns';
|
|
1656
|
+
*
|
|
1657
|
+
* async verify(ctx) {
|
|
1658
|
+
* // Implementation
|
|
1659
|
+
* return [];
|
|
1660
|
+
* }
|
|
1661
|
+
* }
|
|
1662
|
+
*
|
|
1663
|
+
* export default defineVerifierPlugin({
|
|
1664
|
+
* metadata: {
|
|
1665
|
+
* id: 'my-custom',
|
|
1666
|
+
* version: '1.0.0',
|
|
1667
|
+
* author: 'Your Name'
|
|
1668
|
+
* },
|
|
1669
|
+
* createVerifier: () => new MyVerifier()
|
|
1670
|
+
* });
|
|
1671
|
+
* ```
|
|
1672
|
+
*/
|
|
1673
|
+
declare function defineVerifierPlugin(plugin: VerifierPlugin): VerifierPlugin;
|
|
1603
1674
|
/**
|
|
1604
1675
|
* Helper to create a violation
|
|
1605
1676
|
*/
|
|
@@ -1696,12 +1767,18 @@ declare class ApiVerifier implements Verifier {
|
|
|
1696
1767
|
declare const builtinVerifiers: Record<string, () => Verifier>;
|
|
1697
1768
|
/**
|
|
1698
1769
|
* Get verifier by ID
|
|
1770
|
+
* Checks custom plugins first, then built-in verifiers
|
|
1771
|
+
* Instances are pooled for performance
|
|
1699
1772
|
*/
|
|
1700
1773
|
declare function getVerifier(id: string): Verifier | null;
|
|
1701
1774
|
/**
|
|
1702
|
-
* Get all verifier IDs
|
|
1775
|
+
* Get all verifier IDs (built-in + plugins)
|
|
1703
1776
|
*/
|
|
1704
1777
|
declare function getVerifierIds(): string[];
|
|
1778
|
+
/**
|
|
1779
|
+
* Clear the verifier instance pool (for testing)
|
|
1780
|
+
*/
|
|
1781
|
+
declare function clearVerifierPool(): void;
|
|
1705
1782
|
/**
|
|
1706
1783
|
* Select appropriate verifier based on constraint
|
|
1707
1784
|
*/
|
|
@@ -1803,6 +1880,8 @@ declare function createPropagationEngine(registry?: Registry): PropagationEngine
|
|
|
1803
1880
|
interface ReportOptions {
|
|
1804
1881
|
includeAll?: boolean;
|
|
1805
1882
|
cwd?: string;
|
|
1883
|
+
/** Use v1.3 compliance formula instead of v2.0 severity-weighted formula */
|
|
1884
|
+
legacyCompliance?: boolean;
|
|
1806
1885
|
}
|
|
1807
1886
|
/**
|
|
1808
1887
|
* Generate a compliance report
|
|
@@ -1871,6 +1950,7 @@ declare class ReportStorage {
|
|
|
1871
1950
|
loadLatest(): Promise<StoredReport | null>;
|
|
1872
1951
|
/**
|
|
1873
1952
|
* Load historical reports for the specified number of days
|
|
1953
|
+
* Uses parallel I/O for better performance
|
|
1874
1954
|
*/
|
|
1875
1955
|
loadHistory(days?: number): Promise<StoredReport[]>;
|
|
1876
1956
|
/**
|
|
@@ -2153,4 +2233,4 @@ declare function matchesAnyPattern(filePath: string, patterns: string[], options
|
|
|
2153
2233
|
cwd?: string;
|
|
2154
2234
|
}): boolean;
|
|
2155
2235
|
|
|
2156
|
-
export { type AffectedFile, type AgentContext, AgentContextGenerator, AlreadyInitializedError, type Analyzer, AnalyzerNotFoundError, ApiVerifier, type ApplicableConstraint, type ApplicableDecision, AstCache, AutofixEngine, type AutofixPatch, type AutofixResult, CodeScanner, ComplexityVerifier, type ComplianceReport, ConfigError, type Constraint, type ConstraintCheck, ConstraintCheckSchema, type ConstraintCheckSchema_, type ConstraintException, ConstraintExceptionSchema, type ConstraintExceptionSchema_, ConstraintSchema, type ConstraintSchema_, type ConstraintType, ConstraintTypeSchema, type ConstraintTypeSchema_, type ContextOptions, type Decision, type DecisionCompliance, type DecisionContent, DecisionContentSchema, type DecisionContentSchema_, type DecisionFilter, type DecisionMetadata, DecisionMetadataSchema, type DecisionMetadataSchema_, DecisionNotFoundError, DecisionSchema, type DecisionStatus, DecisionStatusSchema, type DecisionStatusSchema_, type DecisionTypeSchema, DecisionValidationError, type DependencyGraph, DependencyVerifier, type DriftAnalysis, ErrorsAnalyzer, ErrorsVerifier, FileSystemError, type GlobOptions, type GraphNode, HookError, type ImpactAnalysis, ImportsAnalyzer, ImportsVerifier, InferenceEngine, InferenceError, type InferenceOptions, type InferenceResult, type LevelConfig, LinksSchema, type LoadError, type LoadResult, type LoadedDecision, type McpServerOptions, type MigrationStep, NamingAnalyzer, NamingVerifier, NotInitializedError, type OverallDrift, type Pattern, type PatternExample, type PromptTemplate, PropagationEngine, type PropagationOptions, RegexVerifier, Registry, type RegistryConstraintMatch, RegistryError, type RegistryOptions, type ReportOptions, ReportStorage, Reporter, type ScanOptions, type ScanResult, type ScannedFile, SecurityVerifier, type Severity, SeveritySchema, type SeveritySchema_, type SpecBridgeConfig, SpecBridgeConfigSchema, type SpecBridgeConfigType, SpecBridgeError, SpecBridgeMcpServer, type StoredReport, StructureAnalyzer, type TextEdit, type TrendAnalysis, type TrendData, type TrendDirection, type VerificationConfig, VerificationConfigSchema, type VerificationConfigSchema_, type VerificationContext, VerificationEngine, VerificationError, type VerificationFrequency, VerificationFrequencySchema, type VerificationFrequencySchema_, type VerificationIssue, type VerificationLevel, type VerificationOptions, type VerificationResult, type VerificationWarning, type Verifier, VerifierNotFoundError, type Violation, type ViolationFix, analyzeTrend, buildDependencyGraph, builtinAnalyzers, builtinVerifiers, calculateConfidence, checkDegradation, createInferenceEngine, createPattern, createPropagationEngine, createRegistry, createScannerFromConfig, createVerificationEngine, createViolation, defaultConfig, detectDrift, ensureDir, extractSnippet, formatConsoleReport, formatContextAsJson, formatContextAsMarkdown, formatContextAsMcp, formatError, formatMarkdownReport, formatValidationErrors, generateContext, generateFormattedContext, generateReport, getAffectedFiles, getAffectingDecisions, getAnalyzer, getAnalyzerIds, getChangedFiles, getConfigPath, getDecisionsDir, getInferredDir, getReportsDir, getSpecBridgeDir, getTransitiveDependencies, getVerifier, getVerifierIds, getVerifiersDir, glob, isConstraintExcepted, isDirectory, loadConfig, loadDecisionFile, loadDecisionsFromDir, matchesAnyPattern, matchesPattern, mergeWithDefaults, normalizePath, parseYaml, parseYamlDocument, pathExists, readFilesInDir, readTextFile, runInference, selectVerifierForConstraint, shouldApplyConstraintToFile, stringifyYaml, templates, updateYamlDocument, validateConfig, validateDecision, validateDecisionFile, writeTextFile };
|
|
2236
|
+
export { type AffectedFile, type AgentContext, AgentContextGenerator, AlreadyInitializedError, type Analyzer, AnalyzerNotFoundError, ApiVerifier, type ApplicableConstraint, type ApplicableDecision, AstCache, AutofixEngine, type AutofixPatch, type AutofixResult, CodeScanner, ComplexityVerifier, type ComplianceReport, ConfigError, type Constraint, type ConstraintCheck, ConstraintCheckSchema, type ConstraintCheckSchema_, type ConstraintException, ConstraintExceptionSchema, type ConstraintExceptionSchema_, ConstraintSchema, type ConstraintSchema_, type ConstraintType, ConstraintTypeSchema, type ConstraintTypeSchema_, type ContextOptions, type Decision, type DecisionCompliance, type DecisionContent, DecisionContentSchema, type DecisionContentSchema_, type DecisionFilter, type DecisionMetadata, DecisionMetadataSchema, type DecisionMetadataSchema_, DecisionNotFoundError, DecisionSchema, type DecisionStatus, DecisionStatusSchema, type DecisionStatusSchema_, type DecisionTypeSchema, DecisionValidationError, type DependencyGraph, DependencyVerifier, type DriftAnalysis, ErrorsAnalyzer, ErrorsVerifier, FileSystemError, type GlobOptions, type GraphNode, HookError, type ImpactAnalysis, ImportsAnalyzer, ImportsVerifier, InferenceEngine, InferenceError, type InferenceOptions, type InferenceResult, type LevelConfig, LinksSchema, type LoadError, type LoadResult, type LoadedDecision, type McpServerOptions, type MigrationStep, NamingAnalyzer, NamingVerifier, NotInitializedError, type OverallDrift, type Pattern, type PatternExample, type PromptTemplate, PropagationEngine, type PropagationOptions, RegexVerifier, Registry, type RegistryConstraintMatch, RegistryError, type RegistryOptions, type ReportOptions, ReportStorage, Reporter, type ScanOptions, type ScanResult, type ScannedFile, SecurityVerifier, type Severity, SeveritySchema, type SeveritySchema_, type SpecBridgeConfig, SpecBridgeConfigSchema, type SpecBridgeConfigType, SpecBridgeError, SpecBridgeMcpServer, type StoredReport, StructureAnalyzer, type TextEdit, type TrendAnalysis, type TrendData, type TrendDirection, type VerificationConfig, VerificationConfigSchema, type VerificationConfigSchema_, type VerificationContext, VerificationEngine, VerificationError, type VerificationFrequency, VerificationFrequencySchema, type VerificationFrequencySchema_, type VerificationIssue, type VerificationLevel, type VerificationOptions, type VerificationResult, type VerificationWarning, type Verifier, VerifierNotFoundError, type VerifierPlugin, type VerifierPluginMetadata, type Violation, type ViolationFix, analyzeTrend, buildDependencyGraph, builtinAnalyzers, builtinVerifiers, calculateConfidence, checkDegradation, clearVerifierPool, createInferenceEngine, createPattern, createPropagationEngine, createRegistry, createScannerFromConfig, createVerificationEngine, createViolation, defaultConfig, defineVerifierPlugin, detectDrift, ensureDir, extractSnippet, formatConsoleReport, formatContextAsJson, formatContextAsMarkdown, formatContextAsMcp, formatError, formatMarkdownReport, formatValidationErrors, generateContext, generateFormattedContext, generateReport, getAffectedFiles, getAffectingDecisions, getAnalyzer, getAnalyzerIds, getChangedFiles, getConfigPath, getDecisionsDir, getInferredDir, getReportsDir, getSpecBridgeDir, getTransitiveDependencies, getVerifier, getVerifierIds, getVerifiersDir, glob, isConstraintExcepted, isDirectory, loadConfig, loadDecisionFile, loadDecisionsFromDir, matchesAnyPattern, matchesPattern, mergeWithDefaults, normalizePath, parseYaml, parseYamlDocument, pathExists, readFilesInDir, readTextFile, runInference, selectVerifierForConstraint, shouldApplyConstraintToFile, stringifyYaml, templates, updateYamlDocument, validateConfig, validateDecision, validateDecisionFile, writeTextFile };
|