@ipation/specbridge 1.0.0 → 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/dist/cli.js CHANGED
@@ -3,6 +3,9 @@
3
3
  // src/cli/index.ts
4
4
  import { Command as Command12 } from "commander";
5
5
  import chalk12 from "chalk";
6
+ import { readFileSync } from "fs";
7
+ import { fileURLToPath } from "url";
8
+ import { dirname as dirname3, join as join9 } from "path";
6
9
 
7
10
  // src/core/errors/index.ts
8
11
  var SpecBridgeError = class extends Error {
@@ -331,6 +334,7 @@ import { Project, Node, SyntaxKind } from "ts-morph";
331
334
  // src/utils/glob.ts
332
335
  import fg from "fast-glob";
333
336
  import { minimatch } from "minimatch";
337
+ import { relative, isAbsolute } from "path";
334
338
  async function glob(patterns, options = {}) {
335
339
  const {
336
340
  cwd = process.cwd(),
@@ -346,8 +350,19 @@ async function glob(patterns, options = {}) {
346
350
  dot: false
347
351
  });
348
352
  }
349
- function matchesPattern(filePath, pattern) {
350
- return minimatch(filePath, pattern, { matchBase: true });
353
+ function normalizePath(filePath, basePath = process.cwd()) {
354
+ let resultPath;
355
+ if (!isAbsolute(filePath)) {
356
+ resultPath = filePath;
357
+ } else {
358
+ resultPath = relative(basePath, filePath);
359
+ }
360
+ return resultPath.replace(/\\/g, "/");
361
+ }
362
+ function matchesPattern(filePath, pattern, options = {}) {
363
+ const cwd = options.cwd || process.cwd();
364
+ const normalizedPath = normalizePath(filePath, cwd);
365
+ return minimatch(normalizedPath, pattern, { matchBase: true });
351
366
  }
352
367
 
353
368
  // src/inference/scanner.ts
@@ -2108,7 +2123,7 @@ var VerificationEngine = class {
2108
2123
  let checked = 0;
2109
2124
  let passed = 0;
2110
2125
  let failed = 0;
2111
- let skipped = 0;
2126
+ const skipped = 0;
2112
2127
  const timeoutPromise = new Promise(
2113
2128
  (resolve) => setTimeout(() => resolve("timeout"), timeout)
2114
2129
  );
@@ -2116,6 +2131,7 @@ var VerificationEngine = class {
2116
2131
  filesToVerify,
2117
2132
  decisions,
2118
2133
  severityFilter,
2134
+ cwd,
2119
2135
  (violations) => {
2120
2136
  allViolations.push(...violations);
2121
2137
  checked++;
@@ -2160,7 +2176,7 @@ var VerificationEngine = class {
2160
2176
  /**
2161
2177
  * Verify a single file
2162
2178
  */
2163
- async verifyFile(filePath, decisions, severityFilter) {
2179
+ async verifyFile(filePath, decisions, severityFilter, cwd = process.cwd()) {
2164
2180
  const violations = [];
2165
2181
  let sourceFile = this.project.getSourceFile(filePath);
2166
2182
  if (!sourceFile) {
@@ -2172,13 +2188,13 @@ var VerificationEngine = class {
2172
2188
  }
2173
2189
  for (const decision of decisions) {
2174
2190
  for (const constraint of decision.constraints) {
2175
- if (!matchesPattern(filePath, constraint.scope)) {
2191
+ if (!matchesPattern(filePath, constraint.scope, { cwd })) {
2176
2192
  continue;
2177
2193
  }
2178
2194
  if (severityFilter && !severityFilter.includes(constraint.severity)) {
2179
2195
  continue;
2180
2196
  }
2181
- if (this.isExcepted(filePath, constraint)) {
2197
+ if (this.isExcepted(filePath, constraint, cwd)) {
2182
2198
  continue;
2183
2199
  }
2184
2200
  const verifier = selectVerifierForConstraint(constraint.rule, constraint.verifier);
@@ -2203,16 +2219,16 @@ var VerificationEngine = class {
2203
2219
  /**
2204
2220
  * Verify multiple files
2205
2221
  */
2206
- async verifyFiles(files, decisions, severityFilter, onFileVerified) {
2222
+ async verifyFiles(files, decisions, severityFilter, cwd, onFileVerified) {
2207
2223
  for (const file of files) {
2208
- const violations = await this.verifyFile(file, decisions, severityFilter);
2224
+ const violations = await this.verifyFile(file, decisions, severityFilter, cwd);
2209
2225
  onFileVerified(violations);
2210
2226
  }
2211
2227
  }
2212
2228
  /**
2213
2229
  * Check if file is excepted from constraint
2214
2230
  */
2215
- isExcepted(filePath, constraint) {
2231
+ isExcepted(filePath, constraint, cwd) {
2216
2232
  if (!constraint.exceptions) return false;
2217
2233
  return constraint.exceptions.some((exception) => {
2218
2234
  if (exception.expiresAt) {
@@ -2221,7 +2237,7 @@ var VerificationEngine = class {
2221
2237
  return false;
2222
2238
  }
2223
2239
  }
2224
- return matchesPattern(filePath, exception.pattern);
2240
+ return matchesPattern(filePath, exception.pattern, { cwd });
2225
2241
  });
2226
2242
  }
2227
2243
  /**
@@ -3289,8 +3305,11 @@ var contextCommand = new Command11("context").description("Generate architectura
3289
3305
  });
3290
3306
 
3291
3307
  // src/cli/index.ts
3308
+ var __dirname = dirname3(fileURLToPath(import.meta.url));
3309
+ var packageJsonPath = join9(__dirname, "../package.json");
3310
+ var packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
3292
3311
  var program = new Command12();
3293
- program.name("specbridge").description("Architecture Decision Runtime - Transform architectural decisions into executable, verifiable constraints").version("0.1.0");
3312
+ program.name("specbridge").description("Architecture Decision Runtime - Transform architectural decisions into executable, verifiable constraints").version(packageJson.version);
3294
3313
  program.addCommand(initCommand);
3295
3314
  program.addCommand(inferCommand);
3296
3315
  program.addCommand(verifyCommand);