@ipation/specbridge 0.2.2 → 1.0.1
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/CHANGELOG.md +87 -1
- package/dist/cli.js +30 -11
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +13 -4
- package/dist/index.js +26 -12
- package/dist/index.js.map +1 -1
- package/package.json +2 -5
package/dist/index.d.ts
CHANGED
|
@@ -1391,7 +1391,7 @@ declare class VerificationEngine {
|
|
|
1391
1391
|
/**
|
|
1392
1392
|
* Verify a single file
|
|
1393
1393
|
*/
|
|
1394
|
-
verifyFile(filePath: string, decisions: Decision[], severityFilter?: Severity[]): Promise<Violation[]>;
|
|
1394
|
+
verifyFile(filePath: string, decisions: Decision[], severityFilter?: Severity[], cwd?: string): Promise<Violation[]>;
|
|
1395
1395
|
/**
|
|
1396
1396
|
* Verify multiple files
|
|
1397
1397
|
*/
|
|
@@ -1790,13 +1790,22 @@ interface GlobOptions {
|
|
|
1790
1790
|
* Find files matching glob patterns
|
|
1791
1791
|
*/
|
|
1792
1792
|
declare function glob(patterns: string | string[], options?: GlobOptions): Promise<string[]>;
|
|
1793
|
+
/**
|
|
1794
|
+
* Normalize a file path to be relative to a base directory
|
|
1795
|
+
* Handles both absolute and relative paths, cross-platform
|
|
1796
|
+
*/
|
|
1797
|
+
declare function normalizePath(filePath: string, basePath?: string): string;
|
|
1793
1798
|
/**
|
|
1794
1799
|
* Check if a file path matches a glob pattern
|
|
1795
1800
|
*/
|
|
1796
|
-
declare function matchesPattern(filePath: string, pattern: string
|
|
1801
|
+
declare function matchesPattern(filePath: string, pattern: string, options?: {
|
|
1802
|
+
cwd?: string;
|
|
1803
|
+
}): boolean;
|
|
1797
1804
|
/**
|
|
1798
1805
|
* Check if a file path matches any of the given patterns
|
|
1799
1806
|
*/
|
|
1800
|
-
declare function matchesAnyPattern(filePath: string, patterns: string[]
|
|
1807
|
+
declare function matchesAnyPattern(filePath: string, patterns: string[], options?: {
|
|
1808
|
+
cwd?: string;
|
|
1809
|
+
}): boolean;
|
|
1801
1810
|
|
|
1802
|
-
export { type AffectedFile, type AgentContext, AgentContextGenerator, AlreadyInitializedError, type Analyzer, AnalyzerNotFoundError, type ApplicableConstraint, type ApplicableDecision, CodeScanner, type ComplianceReport, ConfigError, type Constraint, 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, 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 MigrationStep, NamingAnalyzer, NamingVerifier, NotInitializedError, type Pattern, type PatternExample, PropagationEngine, type PropagationOptions, RegexVerifier, Registry, type RegistryConstraintMatch, RegistryError, type RegistryOptions, type ReportOptions, Reporter, type ScanOptions, type ScanResult, type ScannedFile, type Severity, SeveritySchema, type SeveritySchema_, type SpecBridgeConfig, SpecBridgeConfigSchema, type SpecBridgeConfigType, SpecBridgeError, StructureAnalyzer, type TrendData, type VerificationConfig, VerificationConfigSchema, type VerificationConfigSchema_, type VerificationContext, VerificationEngine, VerificationError, type VerificationFrequency, VerificationFrequencySchema, type VerificationFrequencySchema_, type VerificationLevel, type VerificationOptions, type VerificationResult, type Verifier, VerifierNotFoundError, type Violation, type ViolationFix, buildDependencyGraph, builtinAnalyzers, builtinVerifiers, calculateConfidence, checkDegradation, createInferenceEngine, createPattern, createPropagationEngine, createRegistry, createScannerFromConfig, createVerificationEngine, createViolation, defaultConfig, ensureDir, extractSnippet, formatConsoleReport, formatContextAsJson, formatContextAsMarkdown, formatContextAsMcp, formatError, formatMarkdownReport, formatValidationErrors, generateContext, generateFormattedContext, generateReport, getAffectedFiles, getAffectingDecisions, getAnalyzer, getAnalyzerIds, getConfigPath, getDecisionsDir, getInferredDir, getReportsDir, getSpecBridgeDir, getTransitiveDependencies, getVerifier, getVerifierIds, getVerifiersDir, glob, isDirectory, loadConfig, loadDecisionFile, loadDecisionsFromDir, matchesAnyPattern, matchesPattern, mergeWithDefaults, parseYaml, parseYamlDocument, pathExists, readFilesInDir, readTextFile, runInference, selectVerifierForConstraint, stringifyYaml, updateYamlDocument, validateConfig, validateDecision, validateDecisionFile, writeTextFile };
|
|
1811
|
+
export { type AffectedFile, type AgentContext, AgentContextGenerator, AlreadyInitializedError, type Analyzer, AnalyzerNotFoundError, type ApplicableConstraint, type ApplicableDecision, CodeScanner, type ComplianceReport, ConfigError, type Constraint, 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, 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 MigrationStep, NamingAnalyzer, NamingVerifier, NotInitializedError, type Pattern, type PatternExample, PropagationEngine, type PropagationOptions, RegexVerifier, Registry, type RegistryConstraintMatch, RegistryError, type RegistryOptions, type ReportOptions, Reporter, type ScanOptions, type ScanResult, type ScannedFile, type Severity, SeveritySchema, type SeveritySchema_, type SpecBridgeConfig, SpecBridgeConfigSchema, type SpecBridgeConfigType, SpecBridgeError, StructureAnalyzer, type TrendData, type VerificationConfig, VerificationConfigSchema, type VerificationConfigSchema_, type VerificationContext, VerificationEngine, VerificationError, type VerificationFrequency, VerificationFrequencySchema, type VerificationFrequencySchema_, type VerificationLevel, type VerificationOptions, type VerificationResult, type Verifier, VerifierNotFoundError, type Violation, type ViolationFix, buildDependencyGraph, builtinAnalyzers, builtinVerifiers, calculateConfidence, checkDegradation, createInferenceEngine, createPattern, createPropagationEngine, createRegistry, createScannerFromConfig, createVerificationEngine, createViolation, defaultConfig, ensureDir, extractSnippet, formatConsoleReport, formatContextAsJson, formatContextAsMarkdown, formatContextAsMcp, formatError, formatMarkdownReport, formatValidationErrors, generateContext, generateFormattedContext, generateReport, getAffectedFiles, getAffectingDecisions, getAnalyzer, getAnalyzerIds, getConfigPath, getDecisionsDir, getInferredDir, getReportsDir, getSpecBridgeDir, getTransitiveDependencies, getVerifier, getVerifierIds, getVerifiersDir, glob, isDirectory, loadConfig, loadDecisionFile, loadDecisionsFromDir, matchesAnyPattern, matchesPattern, mergeWithDefaults, normalizePath, parseYaml, parseYamlDocument, pathExists, readFilesInDir, readTextFile, runInference, selectVerifierForConstraint, stringifyYaml, updateYamlDocument, validateConfig, validateDecision, validateDecisionFile, writeTextFile };
|
package/dist/index.js
CHANGED
|
@@ -450,6 +450,7 @@ async function validateDecisionFile(filePath) {
|
|
|
450
450
|
// src/utils/glob.ts
|
|
451
451
|
import fg from "fast-glob";
|
|
452
452
|
import { minimatch } from "minimatch";
|
|
453
|
+
import { relative, isAbsolute } from "path";
|
|
453
454
|
async function glob(patterns, options = {}) {
|
|
454
455
|
const {
|
|
455
456
|
cwd = process.cwd(),
|
|
@@ -465,11 +466,22 @@ async function glob(patterns, options = {}) {
|
|
|
465
466
|
dot: false
|
|
466
467
|
});
|
|
467
468
|
}
|
|
468
|
-
function
|
|
469
|
-
|
|
469
|
+
function normalizePath(filePath, basePath = process.cwd()) {
|
|
470
|
+
let resultPath;
|
|
471
|
+
if (!isAbsolute(filePath)) {
|
|
472
|
+
resultPath = filePath;
|
|
473
|
+
} else {
|
|
474
|
+
resultPath = relative(basePath, filePath);
|
|
475
|
+
}
|
|
476
|
+
return resultPath.replace(/\\/g, "/");
|
|
470
477
|
}
|
|
471
|
-
function
|
|
472
|
-
|
|
478
|
+
function matchesPattern(filePath, pattern, options = {}) {
|
|
479
|
+
const cwd = options.cwd || process.cwd();
|
|
480
|
+
const normalizedPath = normalizePath(filePath, cwd);
|
|
481
|
+
return minimatch(normalizedPath, pattern, { matchBase: true });
|
|
482
|
+
}
|
|
483
|
+
function matchesAnyPattern(filePath, patterns, options = {}) {
|
|
484
|
+
return patterns.some((pattern) => matchesPattern(filePath, pattern, options));
|
|
473
485
|
}
|
|
474
486
|
|
|
475
487
|
// src/registry/registry.ts
|
|
@@ -2017,7 +2029,7 @@ var VerificationEngine = class {
|
|
|
2017
2029
|
let checked = 0;
|
|
2018
2030
|
let passed = 0;
|
|
2019
2031
|
let failed = 0;
|
|
2020
|
-
|
|
2032
|
+
const skipped = 0;
|
|
2021
2033
|
const timeoutPromise = new Promise(
|
|
2022
2034
|
(resolve) => setTimeout(() => resolve("timeout"), timeout)
|
|
2023
2035
|
);
|
|
@@ -2025,6 +2037,7 @@ var VerificationEngine = class {
|
|
|
2025
2037
|
filesToVerify,
|
|
2026
2038
|
decisions,
|
|
2027
2039
|
severityFilter,
|
|
2040
|
+
cwd,
|
|
2028
2041
|
(violations) => {
|
|
2029
2042
|
allViolations.push(...violations);
|
|
2030
2043
|
checked++;
|
|
@@ -2069,7 +2082,7 @@ var VerificationEngine = class {
|
|
|
2069
2082
|
/**
|
|
2070
2083
|
* Verify a single file
|
|
2071
2084
|
*/
|
|
2072
|
-
async verifyFile(filePath, decisions, severityFilter) {
|
|
2085
|
+
async verifyFile(filePath, decisions, severityFilter, cwd = process.cwd()) {
|
|
2073
2086
|
const violations = [];
|
|
2074
2087
|
let sourceFile = this.project.getSourceFile(filePath);
|
|
2075
2088
|
if (!sourceFile) {
|
|
@@ -2081,13 +2094,13 @@ var VerificationEngine = class {
|
|
|
2081
2094
|
}
|
|
2082
2095
|
for (const decision of decisions) {
|
|
2083
2096
|
for (const constraint of decision.constraints) {
|
|
2084
|
-
if (!matchesPattern(filePath, constraint.scope)) {
|
|
2097
|
+
if (!matchesPattern(filePath, constraint.scope, { cwd })) {
|
|
2085
2098
|
continue;
|
|
2086
2099
|
}
|
|
2087
2100
|
if (severityFilter && !severityFilter.includes(constraint.severity)) {
|
|
2088
2101
|
continue;
|
|
2089
2102
|
}
|
|
2090
|
-
if (this.isExcepted(filePath, constraint)) {
|
|
2103
|
+
if (this.isExcepted(filePath, constraint, cwd)) {
|
|
2091
2104
|
continue;
|
|
2092
2105
|
}
|
|
2093
2106
|
const verifier = selectVerifierForConstraint(constraint.rule, constraint.verifier);
|
|
@@ -2112,16 +2125,16 @@ var VerificationEngine = class {
|
|
|
2112
2125
|
/**
|
|
2113
2126
|
* Verify multiple files
|
|
2114
2127
|
*/
|
|
2115
|
-
async verifyFiles(files, decisions, severityFilter, onFileVerified) {
|
|
2128
|
+
async verifyFiles(files, decisions, severityFilter, cwd, onFileVerified) {
|
|
2116
2129
|
for (const file of files) {
|
|
2117
|
-
const violations = await this.verifyFile(file, decisions, severityFilter);
|
|
2130
|
+
const violations = await this.verifyFile(file, decisions, severityFilter, cwd);
|
|
2118
2131
|
onFileVerified(violations);
|
|
2119
2132
|
}
|
|
2120
2133
|
}
|
|
2121
2134
|
/**
|
|
2122
2135
|
* Check if file is excepted from constraint
|
|
2123
2136
|
*/
|
|
2124
|
-
isExcepted(filePath, constraint) {
|
|
2137
|
+
isExcepted(filePath, constraint, cwd) {
|
|
2125
2138
|
if (!constraint.exceptions) return false;
|
|
2126
2139
|
return constraint.exceptions.some((exception) => {
|
|
2127
2140
|
if (exception.expiresAt) {
|
|
@@ -2130,7 +2143,7 @@ var VerificationEngine = class {
|
|
|
2130
2143
|
return false;
|
|
2131
2144
|
}
|
|
2132
2145
|
}
|
|
2133
|
-
return matchesPattern(filePath, exception.pattern);
|
|
2146
|
+
return matchesPattern(filePath, exception.pattern, { cwd });
|
|
2134
2147
|
});
|
|
2135
2148
|
}
|
|
2136
2149
|
/**
|
|
@@ -3042,6 +3055,7 @@ export {
|
|
|
3042
3055
|
matchesPattern,
|
|
3043
3056
|
mergeWithDefaults,
|
|
3044
3057
|
minimatch,
|
|
3058
|
+
normalizePath,
|
|
3045
3059
|
parseYaml,
|
|
3046
3060
|
parseYamlDocument,
|
|
3047
3061
|
pathExists,
|