@stackbilt/git 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 +90 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # @stackbilt/git
2
+
3
+ Git trailer parsing, commit risk scoring, and governance suggestion generation for [Charter Kit](https://github.com/Stackbilt-dev/charter) -- a local-first governance toolkit for software repos.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @stackbilt/git
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Parse trailers from a commit message
14
+
15
+ ```ts
16
+ import { parseTrailersFromMessage } from '@stackbilt/git';
17
+
18
+ const trailers = parseTrailersFromMessage('abc1234', `feat(api): add user endpoint
19
+
20
+ Governed-By: ADR-0012
21
+ Resolves-Request: REQ-0045
22
+ `);
23
+
24
+ console.log(trailers.governedBy);
25
+ // [{ commitSha: 'abc1234', reference: 'ADR-0012' }]
26
+ ```
27
+
28
+ ### Assess commit risk
29
+
30
+ ```ts
31
+ import { assessCommitRisk } from '@stackbilt/git';
32
+
33
+ assessCommitRisk(['migrations/002_add_table.sql'], 'feat: add table');
34
+ // => 'HIGH'
35
+
36
+ assessCommitRisk(['lib/utils.ts'], 'refactor: extract helper');
37
+ // => 'MEDIUM'
38
+
39
+ assessCommitRisk(['README.md'], 'docs: update readme');
40
+ // => 'LOW'
41
+ ```
42
+
43
+ **Risk classification:**
44
+
45
+ | Level | File patterns |
46
+ | ------ | ------------- |
47
+ | HIGH | `migrations/`, `*.sql`, `worker/handlers/`, `worker/services/` |
48
+ | MEDIUM | `lib/`, `components/`, `context/`, `worker/lib/` |
49
+ | LOW | `*.md`, `*.json`, `*.yml`, `test/`, `*.test.*`, `.github/` |
50
+
51
+ ### Generate governance suggestions
52
+
53
+ ```ts
54
+ import { generateSuggestions } from '@stackbilt/git';
55
+
56
+ const suggestions = generateSuggestions(trailers, unlinkedCommits, totalCommits);
57
+ // ['No commits have governance trailers. Consider linking significant changes to ADRs.']
58
+ ```
59
+
60
+ ## API Reference
61
+
62
+ ### `parseTrailersFromMessage(commitSha, message): ParsedTrailers`
63
+
64
+ Parse `Governed-By` and `Resolves-Request` trailers from a single commit message.
65
+
66
+ ### `parseAllTrailers(commits: GitCommit[]): ParsedTrailers`
67
+
68
+ Parse trailers from an array of commits, returning combined results.
69
+
70
+ ### `assessCommitRisk(filesChanged, commitMessage): CommitRiskLevel`
71
+
72
+ Score a commit as `HIGH`, `MEDIUM`, or `LOW`. Falls back to message keyword analysis when no files are provided.
73
+
74
+ ### `generateSuggestions(trailers, unlinkedCommits, totalCommits): string[]`
75
+
76
+ Generate governance suggestions based on trailer coverage and unlinked high-risk commits.
77
+
78
+ ## Requirements
79
+
80
+ - Node >= 18
81
+ - Peer dependency: `@stackbilt/types`
82
+
83
+ ## License
84
+
85
+ Apache-2.0
86
+
87
+ ## Links
88
+
89
+ - [Repository](https://github.com/Stackbilt-dev/charter)
90
+ - [Issues](https://github.com/Stackbilt-dev/charter/issues)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stackbilt/git",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Git trailer parsing, commit risk scoring, and PR validation",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",