@stackbilt/drift 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. package/README.md +73 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # @stackbilt/drift
2
+
3
+ Blessed-stack drift detection for [Charter Kit](https://github.com/Stackbilt-dev/charter) -- a local-first governance toolkit for software repos. Scans source files against anti-patterns defined in `.charter/patterns/*.json` and produces a drift score with per-line violation details.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @stackbilt/drift
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Scan files for drift
14
+
15
+ ```ts
16
+ import { scanForDrift } from '@stackbilt/drift';
17
+
18
+ const files = {
19
+ 'src/app.ts': 'import { createApp } from "vue";\ncreateApp({});',
20
+ 'src/utils.ts': 'export const add = (a: number, b: number) => a + b;',
21
+ };
22
+
23
+ const patterns = [
24
+ { name: 'React Only', antiPatterns: 'Do not use `angular` or /vue\\.createApp/i' },
25
+ ];
26
+
27
+ const report = scanForDrift(files, patterns);
28
+
29
+ console.log(report.score); // 0.0 - 1.0 (1.0 = no drift)
30
+ console.log(report.violations); // Array of DriftViolation
31
+ console.log(report.scannedFiles); // 2
32
+ ```
33
+
34
+ ### Extract rules independently
35
+
36
+ ```ts
37
+ import { extractRules } from '@stackbilt/drift';
38
+
39
+ const rules = extractRules('Avoid /console\\.log/g and `eval`');
40
+ // => [/console\.log/g, /eval/]
41
+ ```
42
+
43
+ ## API Reference
44
+
45
+ ### `scanForDrift(files, patterns): DriftReport`
46
+
47
+ Scan file contents against blessed-stack patterns.
48
+
49
+ | Field | Type | Description |
50
+ |---|---|---|
51
+ | `score` | `number` | 0.0 (high drift) to 1.0 (clean) |
52
+ | `violations` | `DriftViolation[]` | Anti-pattern matches found |
53
+ | `scannedFiles` | `number` | Total files scanned |
54
+ | `scannedPatterns` | `number` | Total patterns evaluated |
55
+ | `timestamp` | `string` | ISO 8601 scan timestamp |
56
+
57
+ ### `extractRules(antiPatternText: string): RegExp[]`
58
+
59
+ Parse an anti-pattern definition into regex rules. Supports `/pattern/flags` and `` `keyword` `` syntax.
60
+
61
+ ## Requirements
62
+
63
+ - Node >= 18
64
+ - Peer dependency: `@stackbilt/types`
65
+
66
+ ## License
67
+
68
+ Apache-2.0
69
+
70
+ ## Links
71
+
72
+ - [Repository](https://github.com/Stackbilt-dev/charter)
73
+ - [Issues](https://github.com/Stackbilt-dev/charter/issues)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackbilt/drift",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Drift scanner — detects codebase divergence from governance patterns",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",