@ipation/specbridge 2.0.0 → 2.2.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/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  import { SourceFile, Project } from 'ts-morph';
3
3
  import { Document } from 'yaml';
4
+ import { Application } from 'express';
4
5
  export { minimatch } from 'minimatch';
5
6
 
6
7
  /**
@@ -179,7 +180,7 @@ interface LevelConfig {
179
180
  * Warning during verification (non-blocking)
180
181
  */
181
182
  interface VerificationWarning {
182
- type: 'missing_verifier' | 'invalid_pattern' | 'other';
183
+ type: 'missing_verifier' | 'invalid_pattern' | 'invalid_params' | 'other';
183
184
  message: string;
184
185
  decisionId: string;
185
186
  constraintId: string;
@@ -1540,7 +1541,7 @@ declare class VerificationEngine {
1540
1541
  /**
1541
1542
  * Verify a single file
1542
1543
  */
1543
- verifyFile(filePath: string, decisions: Decision[], severityFilter?: Severity[], cwd?: string, reporter?: ExplainReporter): Promise<{
1544
+ verifyFile(filePath: string, decisions: Decision[], severityFilter?: Severity[], cwd?: string, reporter?: ExplainReporter, signal?: AbortSignal): Promise<{
1544
1545
  violations: Violation[];
1545
1546
  warnings: VerificationWarning[];
1546
1547
  errors: VerificationIssue[];
@@ -1595,6 +1596,8 @@ interface VerificationContext {
1595
1596
  sourceFile: SourceFile;
1596
1597
  constraint: Constraint;
1597
1598
  decisionId: string;
1599
+ /** Optional AbortSignal for cancellation support */
1600
+ signal?: AbortSignal;
1598
1601
  }
1599
1602
  /**
1600
1603
  * Verifier interface - all verifiers must implement this
@@ -1883,6 +1886,23 @@ interface ReportOptions {
1883
1886
  /** Use v1.3 compliance formula instead of v2.0 severity-weighted formula */
1884
1887
  legacyCompliance?: boolean;
1885
1888
  }
1889
+ /**
1890
+ * Generic verification result shape for Reporter class
1891
+ * Supports various result formats from different verification engines
1892
+ */
1893
+ interface ReporterResult {
1894
+ violations?: Violation[];
1895
+ summary?: {
1896
+ totalViolations?: number;
1897
+ decisionsChecked?: number;
1898
+ filesChecked?: number;
1899
+ critical?: number;
1900
+ high?: number;
1901
+ medium?: number;
1902
+ low?: number;
1903
+ duration?: number;
1904
+ };
1905
+ }
1886
1906
  /**
1887
1907
  * Generate a compliance report
1888
1908
  */
@@ -1901,7 +1921,7 @@ declare class Reporter {
1901
1921
  /**
1902
1922
  * Generate formatted report from verification result
1903
1923
  */
1904
- generate(result: any, options?: {
1924
+ generate(result: ReporterResult, options?: {
1905
1925
  format?: 'table' | 'json' | 'markdown';
1906
1926
  includePassedChecks?: boolean;
1907
1927
  groupBy?: 'severity' | 'file';
@@ -1910,7 +1930,7 @@ declare class Reporter {
1910
1930
  /**
1911
1931
  * Generate compliance overview from multiple results
1912
1932
  */
1913
- generateComplianceReport(results: any[]): string;
1933
+ generateComplianceReport(results: ReporterResult[]): string;
1914
1934
  private formatAsTable;
1915
1935
  private formatAsTableGrouped;
1916
1936
  private formatAsMarkdown;
@@ -2083,7 +2103,7 @@ declare class AgentContextGenerator {
2083
2103
  * Generate context from decisions
2084
2104
  */
2085
2105
  generateContext(options: {
2086
- decisions: any[];
2106
+ decisions: Decision[];
2087
2107
  filePattern?: string;
2088
2108
  format?: 'markdown' | 'plain' | 'json';
2089
2109
  concise?: boolean;
@@ -2094,15 +2114,15 @@ declare class AgentContextGenerator {
2094
2114
  * Generate prompt suffix for AI agents
2095
2115
  */
2096
2116
  generatePromptSuffix(options: {
2097
- decisions: any[];
2117
+ decisions: Decision[];
2098
2118
  }): string;
2099
2119
  /**
2100
2120
  * Extract relevant decisions for a specific file
2101
2121
  */
2102
2122
  extractRelevantDecisions(options: {
2103
- decisions: any[];
2123
+ decisions: Decision[];
2104
2124
  filePath: string;
2105
- }): any[];
2125
+ }): Decision[];
2106
2126
  }
2107
2127
 
2108
2128
  /**
@@ -2233,4 +2253,160 @@ declare function matchesAnyPattern(filePath: string, patterns: string[], options
2233
2253
  cwd?: string;
2234
2254
  }): boolean;
2235
2255
 
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 };
2256
+ /**
2257
+ * Analytics engine - Provide insights into compliance trends and decision impact
2258
+ */
2259
+
2260
+ interface DecisionMetrics {
2261
+ decisionId: string;
2262
+ title: string;
2263
+ totalViolations: number;
2264
+ violationsByFile: Map<string, number>;
2265
+ violationsBySeverity: Record<Severity, number>;
2266
+ mostViolatedConstraint: {
2267
+ id: string;
2268
+ count: number;
2269
+ } | null;
2270
+ averageComplianceScore: number;
2271
+ trendDirection: 'up' | 'down' | 'stable';
2272
+ history: Array<{
2273
+ date: string;
2274
+ compliance: number;
2275
+ violations: number;
2276
+ }>;
2277
+ }
2278
+ interface Insight {
2279
+ type: 'warning' | 'info' | 'success';
2280
+ category: 'compliance' | 'trend' | 'hotspot' | 'suggestion';
2281
+ message: string;
2282
+ details?: string;
2283
+ decisionId?: string;
2284
+ }
2285
+ interface AnalyticsSummary {
2286
+ totalDecisions: number;
2287
+ averageCompliance: number;
2288
+ overallTrend: 'up' | 'down' | 'stable';
2289
+ criticalIssues: number;
2290
+ topDecisions: Array<{
2291
+ decisionId: string;
2292
+ title: string;
2293
+ compliance: number;
2294
+ }>;
2295
+ bottomDecisions: Array<{
2296
+ decisionId: string;
2297
+ title: string;
2298
+ compliance: number;
2299
+ }>;
2300
+ insights: Insight[];
2301
+ }
2302
+ /**
2303
+ * Analytics engine for compliance data
2304
+ */
2305
+ declare class AnalyticsEngine {
2306
+ /**
2307
+ * Analyze a specific decision across historical reports
2308
+ */
2309
+ analyzeDecision(decisionId: string, history: StoredReport[]): Promise<DecisionMetrics>;
2310
+ /**
2311
+ * Generate insights from historical data
2312
+ */
2313
+ generateInsights(history: StoredReport[]): Promise<Insight[]>;
2314
+ /**
2315
+ * Generate analytics summary
2316
+ */
2317
+ generateSummary(history: StoredReport[]): Promise<AnalyticsSummary>;
2318
+ }
2319
+
2320
+ /**
2321
+ * Dashboard server - Compliance dashboard backend with REST API
2322
+ */
2323
+
2324
+ interface DashboardOptions {
2325
+ cwd: string;
2326
+ config: SpecBridgeConfig;
2327
+ }
2328
+ /**
2329
+ * Dashboard Server with caching
2330
+ */
2331
+ declare class DashboardServer {
2332
+ private app;
2333
+ private cwd;
2334
+ private config;
2335
+ private registry;
2336
+ private reportStorage;
2337
+ private cachedReport;
2338
+ private cacheTimestamp;
2339
+ private readonly CACHE_TTL;
2340
+ private refreshInterval;
2341
+ constructor(options: DashboardOptions);
2342
+ /**
2343
+ * Start the server with background cache refresh
2344
+ */
2345
+ start(): Promise<void>;
2346
+ /**
2347
+ * Stop the server and clear intervals
2348
+ */
2349
+ stop(): void;
2350
+ /**
2351
+ * Refresh the cached report
2352
+ */
2353
+ private refreshCache;
2354
+ /**
2355
+ * Get the Express app instance
2356
+ */
2357
+ getApp(): Application;
2358
+ /**
2359
+ * Setup middleware
2360
+ */
2361
+ private setupMiddleware;
2362
+ /**
2363
+ * Setup all routes
2364
+ */
2365
+ private setupRoutes;
2366
+ /**
2367
+ * Setup report-related routes
2368
+ */
2369
+ private setupReportRoutes;
2370
+ /**
2371
+ * Setup decision-related routes
2372
+ */
2373
+ private setupDecisionRoutes;
2374
+ /**
2375
+ * Setup analytics-related routes
2376
+ */
2377
+ private setupAnalyticsRoutes;
2378
+ /**
2379
+ * Setup health check route
2380
+ */
2381
+ private setupHealthRoute;
2382
+ /**
2383
+ * Setup static file serving
2384
+ */
2385
+ private setupStaticFiles;
2386
+ }
2387
+ /**
2388
+ * Create and configure the dashboard server (factory function)
2389
+ * @returns DashboardServer instance
2390
+ */
2391
+ declare function createDashboardServer(options: DashboardOptions): DashboardServer;
2392
+
2393
+ interface LspServerOptions {
2394
+ cwd: string;
2395
+ verbose?: boolean;
2396
+ }
2397
+
2398
+ declare function startLspServer(options: LspServerOptions): Promise<void>;
2399
+
2400
+ /**
2401
+ * GitHub integration helpers (optional)
2402
+ */
2403
+
2404
+ interface GitHubPrCommentOptions {
2405
+ repo: string;
2406
+ pr: number;
2407
+ token: string;
2408
+ }
2409
+ declare function formatViolationsForGitHub(violations: Violation[], limit?: number): string;
2410
+ declare function postPrComment(violations: Violation[], options: GitHubPrCommentOptions): Promise<void>;
2411
+
2412
+ export { type AffectedFile, type AgentContext, AgentContextGenerator, AlreadyInitializedError, AnalyticsEngine, type AnalyticsSummary, 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, DashboardServer, type Decision, type DecisionCompliance, type DecisionContent, DecisionContentSchema, type DecisionContentSchema_, type DecisionFilter, type DecisionMetadata, DecisionMetadataSchema, type DecisionMetadataSchema_, type DecisionMetrics, DecisionNotFoundError, DecisionSchema, type DecisionStatus, DecisionStatusSchema, type DecisionStatusSchema_, type DecisionTypeSchema, DecisionValidationError, type DependencyGraph, DependencyVerifier, type DriftAnalysis, ErrorsAnalyzer, ErrorsVerifier, FileSystemError, type GitHubPrCommentOptions, type GlobOptions, type GraphNode, HookError, type ImpactAnalysis, ImportsAnalyzer, ImportsVerifier, InferenceEngine, InferenceError, type InferenceOptions, type InferenceResult, type Insight, 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 ReporterResult, 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, createDashboardServer, createInferenceEngine, createPattern, createPropagationEngine, createRegistry, createScannerFromConfig, createVerificationEngine, createViolation, defaultConfig, defineVerifierPlugin, detectDrift, ensureDir, extractSnippet, formatConsoleReport, formatContextAsJson, formatContextAsMarkdown, formatContextAsMcp, formatError, formatMarkdownReport, formatValidationErrors, formatViolationsForGitHub, 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, postPrComment, readFilesInDir, readTextFile, runInference, selectVerifierForConstraint, shouldApplyConstraintToFile, startLspServer, stringifyYaml, templates, updateYamlDocument, validateConfig, validateDecision, validateDecisionFile, writeTextFile };