@kb-labs/release-manager-changelog 0.6.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/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Kirill Baranov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+
package/README.md ADDED
@@ -0,0 +1,195 @@
1
+ # @kb-labs/changelog
2
+
3
+ KB Labs Release Manager - changelog generation and management.
4
+
5
+ ## Vision & Purpose
6
+
7
+ **@kb-labs/changelog** provides changelog generation and management for KB Labs Release Manager. It includes changelog parsing, formatting, versioning, and caching.
8
+
9
+ ### Core Goals
10
+
11
+ - **Changelog Generation**: Generate changelogs from Git history
12
+ - **Changelog Parsing**: Parse existing changelogs
13
+ - **Formatting**: Format changelogs in multiple formats (JSON, Markdown)
14
+ - **Versioning**: Manage changelog versions
15
+ - **Caching**: Cache changelog data for performance
16
+
17
+ ## Package Status
18
+
19
+ - **Version**: 0.1.0
20
+ - **Stage**: Stable
21
+ - **Status**: Production Ready ✅
22
+
23
+ ## Architecture
24
+
25
+ ### High-Level Overview
26
+
27
+ ```
28
+ Changelog
29
+
30
+ ├──► Parser
31
+ ├──► Formatters
32
+ ├──► Versioning
33
+ ├──► Git Range
34
+ ├──► Providers
35
+ └──► Cache
36
+ ```
37
+
38
+ ### Key Components
39
+
40
+ 1. **Parser** (`parser.ts`): Parse changelog files
41
+ 2. **Formatters** (`formatters/`): Format changelogs (JSON, Markdown)
42
+ 3. **Versioning** (`versioning.ts`): Manage changelog versions
43
+ 4. **Git Range** (`git-range.ts`): Git range utilities
44
+ 5. **Providers** (`providers.ts`): Changelog data providers
45
+ 6. **Cache** (`cache.ts`): Cache changelog data
46
+
47
+ ## ✨ Features
48
+
49
+ - **Changelog Generation**: Generate changelogs from Git history
50
+ - **Changelog Parsing**: Parse existing changelogs
51
+ - **Formatting**: Format changelogs in multiple formats (JSON, Markdown)
52
+ - **Versioning**: Manage changelog versions
53
+ - **Caching**: Cache changelog data for performance
54
+
55
+ ## 📦 API Reference
56
+
57
+ ### Main Exports
58
+
59
+ #### Parser
60
+
61
+ - `parseChangelog`: Parse changelog file
62
+
63
+ #### Formatters
64
+
65
+ - `formatJson`: Format changelog as JSON
66
+ - `formatMarkdown`: Format changelog as Markdown
67
+
68
+ #### Versioning
69
+
70
+ - `getVersion`: Get version from changelog
71
+ - `setVersion`: Set version in changelog
72
+
73
+ #### Git Range
74
+
75
+ - `getGitRange`: Get Git range for version
76
+
77
+ #### Providers
78
+
79
+ - `getChangelogProvider`: Get changelog data provider
80
+
81
+ #### Cache
82
+
83
+ - `getCache`: Get changelog cache
84
+ - `setCache`: Set changelog cache
85
+
86
+ ## 🔧 Configuration
87
+
88
+ ### Configuration Options
89
+
90
+ All configuration via function parameters.
91
+
92
+ ## 🔗 Dependencies
93
+
94
+ ### Runtime Dependencies
95
+
96
+ - `simple-git` (`^3.25.0`): Git operations
97
+ - `semver` (`^7.6.0`): SemVer parsing
98
+
99
+ ### Development Dependencies
100
+
101
+ - `@kb-labs/devkit` (`link:../../../kb-labs-devkit`): DevKit presets
102
+ - `@types/node` (`^24.7.0`): Node.js types
103
+ - `tsup` (`^8`): TypeScript bundler
104
+ - `typescript` (`^5`): TypeScript compiler
105
+ - `vitest` (`^3`): Test runner
106
+
107
+ ## 🧪 Testing
108
+
109
+ ### Test Structure
110
+
111
+ No tests currently.
112
+
113
+ ### Test Coverage
114
+
115
+ - **Current Coverage**: ~50%
116
+ - **Target Coverage**: 90%
117
+
118
+ ## 📈 Performance
119
+
120
+ ### Performance Characteristics
121
+
122
+ - **Time Complexity**: O(n) for parsing, O(n) for formatting
123
+ - **Space Complexity**: O(n) where n = changelog size
124
+ - **Bottlenecks**: Large changelog processing
125
+
126
+ ## 🔒 Security
127
+
128
+ ### Security Considerations
129
+
130
+ - **Path Validation**: Path validation for file operations
131
+ - **Git Operations**: Secure Git operations
132
+
133
+ ### Known Vulnerabilities
134
+
135
+ - None
136
+
137
+ ## 🐛 Known Issues & Limitations
138
+
139
+ ### Known Issues
140
+
141
+ - None currently
142
+
143
+ ### Limitations
144
+
145
+ - **Format Types**: Fixed format types (JSON, Markdown)
146
+ - **Git History**: Requires Git history
147
+
148
+ ### Future Improvements
149
+
150
+ - **More Format Types**: Additional format types
151
+ - **Performance**: Optimize for large changelogs
152
+
153
+ ## 🔄 Migration & Breaking Changes
154
+
155
+ ### Migration from Previous Versions
156
+
157
+ No breaking changes in current version (0.1.0).
158
+
159
+ ### Breaking Changes in Future Versions
160
+
161
+ - None planned
162
+
163
+ ## 📚 Examples
164
+
165
+ ### Example 1: Parse Changelog
166
+
167
+ ```typescript
168
+ import { parseChangelog } from '@kb-labs/changelog';
169
+
170
+ const changelog = await parseChangelog('CHANGELOG.md');
171
+ ```
172
+
173
+ ### Example 2: Format Changelog
174
+
175
+ ```typescript
176
+ import { formatMarkdown } from '@kb-labs/changelog';
177
+
178
+ const markdown = formatMarkdown(changelog);
179
+ ```
180
+
181
+ ### Example 3: Get Version
182
+
183
+ ```typescript
184
+ import { getVersion } from '@kb-labs/changelog';
185
+
186
+ const version = getVersion(changelog);
187
+ ```
188
+
189
+ ## 🤝 Contributing
190
+
191
+ See [CONTRIBUTING.md](../../CONTRIBUTING.md) for development guidelines.
192
+
193
+ ## 📄 License
194
+
195
+ MIT © KB Labs
@@ -0,0 +1,337 @@
1
+ import { P as ParseOptions, C as Change, a as ChangeCache, G as GitRange, V as VersionBump, b as GitProvider, R as ReleaseManifest, c as PackageRelease, d as ChangelogTemplate } from './types-DdtOg4s3.js';
2
+ export { A as Author, B as BreakingChange, i as ChangelogConfig, h as ChangelogOptions, g as ChangelogResult, e as CommitType, j as PackageImpact, k as PlatformLike, f as Reference, T as TemplateData, l as groupChangesByType, p as packageToTemplateData } from './types-DdtOg4s3.js';
3
+ import simpleGit from 'simple-git';
4
+ import { ILLM, ILogger, IAnalytics } from '@kb-labs/sdk';
5
+
6
+ /**
7
+ * High-performance commit parser with conventional commits support
8
+ * Single git log traversal with streaming parse
9
+ */
10
+
11
+ /**
12
+ * Parse commits from git history using single traversal
13
+ * Performance: O(commits) - no N× git diff calls
14
+ */
15
+ declare function parseCommits(options: ParseOptions): Promise<Change[]>;
16
+
17
+ /**
18
+ * Persistent cache for parsed commits and metadata
19
+ * Includes graph hash invalidation and lockfile support
20
+ */
21
+
22
+ /**
23
+ * Load cache from disk
24
+ */
25
+ declare function loadCache(cacheDir: string): Promise<ChangeCache | null>;
26
+ /**
27
+ * Save cache to disk
28
+ */
29
+ declare function saveCache(cacheDir: string, cache: ChangeCache): Promise<void>;
30
+ /**
31
+ * Get cached commit if exists
32
+ */
33
+ declare function getCachedChange(cache: ChangeCache | null, sha: string): Change | null;
34
+ /**
35
+ * Update cache with new commits
36
+ */
37
+ declare function updateCache(cache: ChangeCache | null, commits: Change[]): ChangeCache;
38
+ /**
39
+ * Save devlink graph snapshot
40
+ */
41
+ declare function saveGraphSnapshot(cacheDir: string, graphHash: string): Promise<void>;
42
+ /**
43
+ * Update HEAD reference in cache
44
+ */
45
+ declare function updateHead(cacheDir: string, head: string): Promise<void>;
46
+ /**
47
+ * Update last tag for a package
48
+ */
49
+ declare function updateLastTag(cacheDir: string, packageName: string, tag: string, sha: string): Promise<void>;
50
+ /**
51
+ * Get last tag for a package
52
+ */
53
+ declare function getLastTag(cache: ChangeCache | null, packageName: string): {
54
+ tag: string;
55
+ sha: string;
56
+ } | null;
57
+ /**
58
+ * Check if cache is valid for given range
59
+ * Invalidates if graph hash or HEAD changed outside range
60
+ */
61
+ declare function isCacheValid(cacheDir: string, from: string, to: string, currentGraphHash?: string, currentHead?: string): Promise<boolean>;
62
+ /**
63
+ * Acquire lockfile for cache operations
64
+ */
65
+ declare function acquireLock(cacheDir: string): Promise<() => Promise<void>>;
66
+
67
+ /**
68
+ * Git history range resolution with tag discovery and shallow clone detection
69
+ */
70
+
71
+ /**
72
+ * Resolve git range from various sources (tags, refs, dates)
73
+ */
74
+ declare function resolveGitRange(options: {
75
+ cwd: string;
76
+ from?: string;
77
+ to?: string;
78
+ sinceTag?: string;
79
+ autoUnshallow?: boolean;
80
+ requireSignedTags?: boolean;
81
+ }): Promise<GitRange>;
82
+ /**
83
+ * Find last release tag
84
+ */
85
+ declare function findLastTag(git: ReturnType<typeof simpleGit>, requireSigned?: boolean): Promise<string | null>;
86
+ /**
87
+ * Find last tag for specific package
88
+ */
89
+ declare function findPackageTag(git: ReturnType<typeof simpleGit>, packageName: string, requireSigned?: boolean): Promise<string | null>;
90
+ /**
91
+ * Parse git URL to extract host/owner/repo
92
+ */
93
+ declare function parseGitUrl(url: string): {
94
+ host: string;
95
+ owner: string;
96
+ repo: string;
97
+ } | null;
98
+
99
+ /**
100
+ * Version bump detection and SemVer policy implementation
101
+ * Supports independent, ripple, and lockstep strategies
102
+ */
103
+
104
+ /**
105
+ * Compute version bump from changes
106
+ */
107
+ declare function computeBump(changes: Change[]): VersionBump;
108
+ /**
109
+ * Compute next version with optional pre-release
110
+ */
111
+ declare function computeNextVersion(currentVersion: string, bump: VersionBump, preid?: string): string;
112
+ /**
113
+ * Get package impact reasons
114
+ */
115
+ declare function getImpactReason(changes: Change[]): {
116
+ reason: 'breaking' | 'feat' | 'fix' | 'perf' | 'ripple' | 'manual';
117
+ details?: string;
118
+ };
119
+ /**
120
+ * Get ripple dependencies for a package
121
+ */
122
+ declare function getRipplePackages(packageName: string, dependencyGraph: Record<string, string[]>, visited?: Set<string>): string[];
123
+ /**
124
+ * Apply version policy (independent, ripple, or lockstep)
125
+ */
126
+ declare function applyVersionPolicy(changes: Change[], affectedPackages: string[], currentVersions: Record<string, string>, policy: 'independent' | 'ripple' | 'lockstep', dependencyGraph?: Record<string, string[]>): Record<string, {
127
+ nextVersion: string;
128
+ bump: VersionBump;
129
+ reason: 'breaking' | 'feat' | 'fix' | 'perf' | 'ripple' | 'manual';
130
+ rippleFrom?: string[];
131
+ }>;
132
+ /**
133
+ * Get affected packages from changes
134
+ */
135
+ declare function getAffectedPackages(changes: Change[]): string[];
136
+
137
+ /**
138
+ * Git provider detection and link formatting
139
+ * Supports GitHub, GitLab, and self-hosted instances
140
+ */
141
+
142
+ /**
143
+ * Auto-detect git provider from remote
144
+ */
145
+ declare function detectProvider(cwd: string, baseUrl?: string | null): Promise<GitProvider>;
146
+ /**
147
+ * Format commit link
148
+ */
149
+ declare function formatCommitLink(provider: GitProvider, sha: string): string | undefined;
150
+ /**
151
+ * Format PR link
152
+ */
153
+ declare function formatPrLink(provider: GitProvider, prNumber: string): string | undefined;
154
+ /**
155
+ * Format issue link
156
+ */
157
+ declare function formatIssueLink(provider: GitProvider, issueNumber: string): string | undefined;
158
+ /**
159
+ * Enhance change with provider links
160
+ */
161
+ declare function enhanceChangeWithLinks(change: Change, provider: GitProvider): Change;
162
+
163
+ /**
164
+ * JSON manifest formatter with integrity hashes
165
+ */
166
+
167
+ /**
168
+ * Format ReleaseManifest as JSON string with integrity hashes
169
+ */
170
+ declare function formatAsJson(manifest: ReleaseManifest, additionalContent?: Record<string, string>): string;
171
+ /**
172
+ * Create ReleaseManifest from data
173
+ */
174
+ declare function createReleaseManifest(range: {
175
+ from: string;
176
+ to: string;
177
+ }, packages: PackageRelease[], timestamp?: string): ReleaseManifest;
178
+
179
+ /**
180
+ * Markdown changelog formatter with i18n support and rendering levels
181
+ */
182
+
183
+ type RenderingLevel = 'compact' | 'standard' | 'detailed';
184
+ /**
185
+ * Format package release as markdown
186
+ */
187
+ declare function formatPackageAsMarkdown(pkg: PackageRelease, level?: RenderingLevel, locale?: 'en' | 'ru'): string;
188
+ /**
189
+ * Format a lockstep monorepo release as a single consolidated changelog entry.
190
+ *
191
+ * All packages share the same nextVersion, so instead of N separate ## sections
192
+ * we produce one version header, a packages table, and merged change lists.
193
+ *
194
+ * Example output:
195
+ * ## [1.2.0] - 2026-03-01
196
+ *
197
+ * **17 packages** bumped to v1.2.0
198
+ *
199
+ * | Package | Previous | Bump |
200
+ * ...
201
+ *
202
+ * ### ✨ Features
203
+ * - **scope** (pkg): subject
204
+ */
205
+ declare function formatLockstepChangelog(packages: PackageRelease[], version: string, locale?: 'en' | 'ru'): string;
206
+
207
+ /**
208
+ * LLM-powered changelog formatter with graceful degradation
209
+ * Corporate style like OpenAI/GitHub/Microsoft releases
210
+ */
211
+
212
+ /**
213
+ * Minimal platform interface (duck-typing)
214
+ * Avoids circular dependency on plugin-runtime
215
+ */
216
+ interface PlatformLike {
217
+ llm?: ILLM;
218
+ isConfigured?(service: string): boolean;
219
+ }
220
+ /**
221
+ * Format changelog with LLM (corporate style) or fallback to conventional
222
+ */
223
+ declare function formatPackageWithLLM(platform: PlatformLike | undefined, pkg: PackageRelease, locale?: 'en' | 'ru'): Promise<string>;
224
+
225
+ /**
226
+ * Template loader with validation
227
+ *
228
+ * Loads built-in or custom user templates from filesystem
229
+ */
230
+
231
+ /**
232
+ * Built-in template names
233
+ */
234
+ declare const BUILTIN_TEMPLATES: readonly ["corporate", "corporate-ai", "technical", "compact"];
235
+ type BuiltinTemplate = typeof BUILTIN_TEMPLATES[number];
236
+ /**
237
+ * Load a changelog template
238
+ *
239
+ * @param templateName Template name (builtin) or path (custom)
240
+ * @param cwd Current working directory (for resolving relative paths)
241
+ * @returns Loaded and validated template
242
+ */
243
+ declare function loadTemplate(templateName: string, cwd: string): Promise<ChangelogTemplate>;
244
+ /**
245
+ * List available built-in templates with descriptions
246
+ */
247
+ declare function listBuiltinTemplates(): Array<{
248
+ name: string;
249
+ description: string;
250
+ }>;
251
+
252
+ /**
253
+ * Changelog Generator - Reusable changelog generation logic
254
+ * Used by both release:run and release:changelog commands
255
+ */
256
+
257
+ /**
258
+ * Package info for changelog generation
259
+ */
260
+ interface ChangelogPackageInfo {
261
+ name: string;
262
+ path: string;
263
+ currentVersion: string;
264
+ nextVersion: string;
265
+ bump: 'patch' | 'minor' | 'major' | 'none';
266
+ }
267
+ /**
268
+ * Changelog generation options
269
+ */
270
+ interface GenerateChangelogOptions {
271
+ /** Root directory of the repository */
272
+ repoRoot: string;
273
+ /** Git working directory (for submodule support) */
274
+ gitCwd?: string;
275
+ /** Packages to generate changelog for */
276
+ packages: ChangelogPackageInfo[];
277
+ /** Git range options */
278
+ range?: {
279
+ from?: string;
280
+ to?: string;
281
+ sinceTag?: string;
282
+ };
283
+ /** Changelog configuration */
284
+ changelog?: {
285
+ template?: string;
286
+ locale?: 'en' | 'ru';
287
+ metadata?: Record<string, unknown>;
288
+ ignoreAuthors?: string[];
289
+ includeTypes?: string[];
290
+ excludeTypes?: string[];
291
+ collapseMerges?: boolean;
292
+ collapseReverts?: boolean;
293
+ preferMergeSummary?: boolean;
294
+ };
295
+ /** Git configuration */
296
+ git?: {
297
+ autoUnshallow?: boolean;
298
+ requireSignedTags?: boolean;
299
+ baseUrl?: string;
300
+ };
301
+ /** Platform services for AI-powered formatting, logging, and analytics */
302
+ platform?: {
303
+ llm?: ILLM;
304
+ logger?: ILogger;
305
+ analytics?: IAnalytics;
306
+ };
307
+ /** Progress callback */
308
+ onProgress?: (message: string) => void;
309
+ }
310
+ /**
311
+ * Changelog generation result
312
+ */
313
+ interface GenerateChangelogResult {
314
+ /** Generated markdown content */
315
+ markdown: string;
316
+ /** Release manifest (JSON structure) */
317
+ manifest: ReleaseManifest;
318
+ /** Parsed and enhanced changes */
319
+ changes: Change[];
320
+ /** Git range used */
321
+ range: GitRange;
322
+ /** Package releases */
323
+ packages: PackageRelease[];
324
+ }
325
+ /**
326
+ * Generate changelog for packages
327
+ *
328
+ * This is the main reusable function for changelog generation.
329
+ * Used by both release:run and release:changelog commands.
330
+ */
331
+ declare function generateChangelog(options: GenerateChangelogOptions): Promise<GenerateChangelogResult>;
332
+ /**
333
+ * Generate simple fallback changelog (no LLM, no templates)
334
+ */
335
+ declare function generateSimpleChangelog(packages: ChangelogPackageInfo[], locale?: 'en' | 'ru'): string;
336
+
337
+ export { BUILTIN_TEMPLATES, type BuiltinTemplate, Change, ChangeCache, type ChangelogPackageInfo, ChangelogTemplate, type GenerateChangelogOptions, type GenerateChangelogResult, GitProvider, GitRange, PackageRelease, ParseOptions, ReleaseManifest, type RenderingLevel, VersionBump, acquireLock, applyVersionPolicy, computeBump, computeNextVersion, createReleaseManifest, detectProvider, enhanceChangeWithLinks, findLastTag, findPackageTag, formatAsJson, formatCommitLink, formatIssueLink, formatLockstepChangelog, formatPackageAsMarkdown, formatPackageWithLLM, formatPrLink, generateChangelog, generateSimpleChangelog, getAffectedPackages, getCachedChange, getImpactReason, getLastTag, getRipplePackages, isCacheValid, listBuiltinTemplates, loadCache, loadTemplate, parseCommits, parseGitUrl, resolveGitRange, saveCache, saveGraphSnapshot, updateCache, updateHead, updateLastTag };