@ipation/specbridge 1.3.0 → 2.1.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 +6136 -381
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +86 -4
- package/dist/index.js +5566 -83
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/verifiers/example-custom.ts +211 -0
package/dist/index.d.ts
CHANGED
|
@@ -179,7 +179,7 @@ interface LevelConfig {
|
|
|
179
179
|
* Warning during verification (non-blocking)
|
|
180
180
|
*/
|
|
181
181
|
interface VerificationWarning {
|
|
182
|
-
type: 'missing_verifier' | 'invalid_pattern' | 'other';
|
|
182
|
+
type: 'missing_verifier' | 'invalid_pattern' | 'invalid_params' | 'other';
|
|
183
183
|
message: string;
|
|
184
184
|
decisionId: string;
|
|
185
185
|
constraintId: string;
|
|
@@ -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
|
|
@@ -1527,7 +1540,7 @@ declare class VerificationEngine {
|
|
|
1527
1540
|
/**
|
|
1528
1541
|
* Verify a single file
|
|
1529
1542
|
*/
|
|
1530
|
-
verifyFile(filePath: string, decisions: Decision[], severityFilter?: Severity[], cwd?: string, reporter?: ExplainReporter): Promise<{
|
|
1543
|
+
verifyFile(filePath: string, decisions: Decision[], severityFilter?: Severity[], cwd?: string, reporter?: ExplainReporter, signal?: AbortSignal): Promise<{
|
|
1531
1544
|
violations: Violation[];
|
|
1532
1545
|
warnings: VerificationWarning[];
|
|
1533
1546
|
errors: VerificationIssue[];
|
|
@@ -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[]>;
|
|
@@ -1578,6 +1595,8 @@ interface VerificationContext {
|
|
|
1578
1595
|
sourceFile: SourceFile;
|
|
1579
1596
|
constraint: Constraint;
|
|
1580
1597
|
decisionId: string;
|
|
1598
|
+
/** Optional AbortSignal for cancellation support */
|
|
1599
|
+
signal?: AbortSignal;
|
|
1581
1600
|
}
|
|
1582
1601
|
/**
|
|
1583
1602
|
* Verifier interface - all verifiers must implement this
|
|
@@ -1600,6 +1619,60 @@ interface Verifier {
|
|
|
1600
1619
|
*/
|
|
1601
1620
|
verify(ctx: VerificationContext): Promise<Violation[]>;
|
|
1602
1621
|
}
|
|
1622
|
+
/**
|
|
1623
|
+
* Plugin metadata
|
|
1624
|
+
*/
|
|
1625
|
+
interface VerifierPluginMetadata {
|
|
1626
|
+
/** Unique identifier matching /^[a-z][a-z0-9-]*$/ */
|
|
1627
|
+
id: string;
|
|
1628
|
+
/** Semver version string */
|
|
1629
|
+
version: string;
|
|
1630
|
+
/** Plugin author */
|
|
1631
|
+
author?: string;
|
|
1632
|
+
/** Brief description of what this verifier checks */
|
|
1633
|
+
description?: string;
|
|
1634
|
+
}
|
|
1635
|
+
/**
|
|
1636
|
+
* Verifier plugin interface
|
|
1637
|
+
* Custom verifiers must export a default object implementing this interface
|
|
1638
|
+
*/
|
|
1639
|
+
interface VerifierPlugin {
|
|
1640
|
+
/** Plugin metadata */
|
|
1641
|
+
metadata: VerifierPluginMetadata;
|
|
1642
|
+
/** Factory function that creates a new verifier instance */
|
|
1643
|
+
createVerifier: () => Verifier;
|
|
1644
|
+
/** Optional Zod schema for validating constraint.check.params */
|
|
1645
|
+
paramsSchema?: unknown;
|
|
1646
|
+
}
|
|
1647
|
+
/**
|
|
1648
|
+
* Helper to define a verifier plugin with type safety
|
|
1649
|
+
*
|
|
1650
|
+
* @example
|
|
1651
|
+
* ```typescript
|
|
1652
|
+
* import { defineVerifierPlugin, type Verifier } from '@ipation/specbridge';
|
|
1653
|
+
*
|
|
1654
|
+
* class MyVerifier implements Verifier {
|
|
1655
|
+
* readonly id = 'my-custom';
|
|
1656
|
+
* readonly name = 'My Custom Verifier';
|
|
1657
|
+
* readonly description = 'Checks custom patterns';
|
|
1658
|
+
*
|
|
1659
|
+
* async verify(ctx) {
|
|
1660
|
+
* // Implementation
|
|
1661
|
+
* return [];
|
|
1662
|
+
* }
|
|
1663
|
+
* }
|
|
1664
|
+
*
|
|
1665
|
+
* export default defineVerifierPlugin({
|
|
1666
|
+
* metadata: {
|
|
1667
|
+
* id: 'my-custom',
|
|
1668
|
+
* version: '1.0.0',
|
|
1669
|
+
* author: 'Your Name'
|
|
1670
|
+
* },
|
|
1671
|
+
* createVerifier: () => new MyVerifier()
|
|
1672
|
+
* });
|
|
1673
|
+
* ```
|
|
1674
|
+
*/
|
|
1675
|
+
declare function defineVerifierPlugin(plugin: VerifierPlugin): VerifierPlugin;
|
|
1603
1676
|
/**
|
|
1604
1677
|
* Helper to create a violation
|
|
1605
1678
|
*/
|
|
@@ -1696,12 +1769,18 @@ declare class ApiVerifier implements Verifier {
|
|
|
1696
1769
|
declare const builtinVerifiers: Record<string, () => Verifier>;
|
|
1697
1770
|
/**
|
|
1698
1771
|
* Get verifier by ID
|
|
1772
|
+
* Checks custom plugins first, then built-in verifiers
|
|
1773
|
+
* Instances are pooled for performance
|
|
1699
1774
|
*/
|
|
1700
1775
|
declare function getVerifier(id: string): Verifier | null;
|
|
1701
1776
|
/**
|
|
1702
|
-
* Get all verifier IDs
|
|
1777
|
+
* Get all verifier IDs (built-in + plugins)
|
|
1703
1778
|
*/
|
|
1704
1779
|
declare function getVerifierIds(): string[];
|
|
1780
|
+
/**
|
|
1781
|
+
* Clear the verifier instance pool (for testing)
|
|
1782
|
+
*/
|
|
1783
|
+
declare function clearVerifierPool(): void;
|
|
1705
1784
|
/**
|
|
1706
1785
|
* Select appropriate verifier based on constraint
|
|
1707
1786
|
*/
|
|
@@ -1803,6 +1882,8 @@ declare function createPropagationEngine(registry?: Registry): PropagationEngine
|
|
|
1803
1882
|
interface ReportOptions {
|
|
1804
1883
|
includeAll?: boolean;
|
|
1805
1884
|
cwd?: string;
|
|
1885
|
+
/** Use v1.3 compliance formula instead of v2.0 severity-weighted formula */
|
|
1886
|
+
legacyCompliance?: boolean;
|
|
1806
1887
|
}
|
|
1807
1888
|
/**
|
|
1808
1889
|
* Generate a compliance report
|
|
@@ -1871,6 +1952,7 @@ declare class ReportStorage {
|
|
|
1871
1952
|
loadLatest(): Promise<StoredReport | null>;
|
|
1872
1953
|
/**
|
|
1873
1954
|
* Load historical reports for the specified number of days
|
|
1955
|
+
* Uses parallel I/O for better performance
|
|
1874
1956
|
*/
|
|
1875
1957
|
loadHistory(days?: number): Promise<StoredReport[]>;
|
|
1876
1958
|
/**
|
|
@@ -2153,4 +2235,4 @@ declare function matchesAnyPattern(filePath: string, patterns: string[], options
|
|
|
2153
2235
|
cwd?: string;
|
|
2154
2236
|
}): boolean;
|
|
2155
2237
|
|
|
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 };
|
|
2238
|
+
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 };
|