tst-changelog 0.1.0 → 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.
- package/dist/index.d.ts +35 -3
- package/dist/index.js +277 -58
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
package/dist/index.d.ts
CHANGED
|
@@ -2,13 +2,23 @@ interface AIConfig {
|
|
|
2
2
|
provider: 'openrouter';
|
|
3
3
|
model: string;
|
|
4
4
|
token: string;
|
|
5
|
+
prompt?: string;
|
|
5
6
|
}
|
|
6
7
|
interface ChangelogConfig {
|
|
7
8
|
file: string;
|
|
8
9
|
format: 'keepachangelog' | 'simple';
|
|
9
10
|
includeDate: boolean;
|
|
11
|
+
includeTime?: boolean;
|
|
12
|
+
includeAuthor?: boolean;
|
|
13
|
+
includeCommitLink?: boolean;
|
|
14
|
+
repoUrl?: string;
|
|
10
15
|
groupBy: 'type' | 'scope' | 'none';
|
|
11
16
|
}
|
|
17
|
+
interface ChangelogMetadata {
|
|
18
|
+
author?: string;
|
|
19
|
+
commitHash?: string;
|
|
20
|
+
timestamp?: Date;
|
|
21
|
+
}
|
|
12
22
|
interface GitConfig {
|
|
13
23
|
baseBranch: string;
|
|
14
24
|
analyzeDepth: number;
|
|
@@ -47,12 +57,22 @@ interface CLIOptions {
|
|
|
47
57
|
config?: string;
|
|
48
58
|
dryRun?: boolean;
|
|
49
59
|
verbose?: boolean;
|
|
60
|
+
fromCommits?: number;
|
|
50
61
|
}
|
|
51
62
|
|
|
52
63
|
/**
|
|
53
64
|
* Load configuration from yaml file
|
|
54
65
|
*/
|
|
55
66
|
declare function loadConfig(configPath?: string): Config;
|
|
67
|
+
interface InitResult {
|
|
68
|
+
configPath: string;
|
|
69
|
+
huskyConfigured: boolean;
|
|
70
|
+
huskyHook?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Initialize a new config file with defaults
|
|
74
|
+
*/
|
|
75
|
+
declare function initConfig(fileName?: string): InitResult;
|
|
56
76
|
|
|
57
77
|
declare class GitService {
|
|
58
78
|
private git;
|
|
@@ -90,6 +110,14 @@ declare class GitService {
|
|
|
90
110
|
* Check if we're in a git repository
|
|
91
111
|
*/
|
|
92
112
|
isGitRepo(): Promise<boolean>;
|
|
113
|
+
/**
|
|
114
|
+
* Get current git user name
|
|
115
|
+
*/
|
|
116
|
+
getCurrentUser(): Promise<string>;
|
|
117
|
+
/**
|
|
118
|
+
* Get HEAD commit hash
|
|
119
|
+
*/
|
|
120
|
+
getHeadCommit(): Promise<string>;
|
|
93
121
|
}
|
|
94
122
|
|
|
95
123
|
declare class AIService {
|
|
@@ -115,13 +143,17 @@ declare class ChangelogService {
|
|
|
115
143
|
/**
|
|
116
144
|
* Generate new changelog entry
|
|
117
145
|
*/
|
|
118
|
-
formatEntry(generated: GeneratedChangelog, version?: string): string;
|
|
146
|
+
formatEntry(generated: GeneratedChangelog, version?: string, metadata?: ChangelogMetadata): string;
|
|
119
147
|
private sortSections;
|
|
120
148
|
private formatSection;
|
|
121
149
|
/**
|
|
122
150
|
* Update or create changelog with new entry
|
|
123
151
|
*/
|
|
124
|
-
update(generated: GeneratedChangelog, version?: string): string;
|
|
152
|
+
update(generated: GeneratedChangelog, version?: string, metadata?: ChangelogMetadata): string;
|
|
153
|
+
/**
|
|
154
|
+
* Merge new entries into existing Unreleased section
|
|
155
|
+
*/
|
|
156
|
+
private mergeUnreleasedSection;
|
|
125
157
|
private findSectionEnd;
|
|
126
158
|
/**
|
|
127
159
|
* Write changelog to file
|
|
@@ -133,4 +165,4 @@ declare class ChangelogService {
|
|
|
133
165
|
getFilePath(): string;
|
|
134
166
|
}
|
|
135
167
|
|
|
136
|
-
export { type AIConfig, AIService, type CLIOptions, type ChangeType, type ChangelogConfig, type ChangelogEntry, type ChangelogSection, ChangelogService, type CommitInfo, type Config, type GeneratedChangelog, type GitConfig, GitService, type StagedChanges, loadConfig };
|
|
168
|
+
export { type AIConfig, AIService, type CLIOptions, type ChangeType, type ChangelogConfig, type ChangelogEntry, type ChangelogMetadata, type ChangelogSection, ChangelogService, type CommitInfo, type Config, type GeneratedChangelog, type GitConfig, GitService, type InitResult, type StagedChanges, initConfig, loadConfig };
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,55 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
+
import "dotenv/config";
|
|
4
5
|
import { Command } from "commander";
|
|
5
6
|
|
|
6
7
|
// src/config.ts
|
|
7
|
-
import { readFileSync, existsSync } from "fs";
|
|
8
|
+
import { readFileSync, existsSync, writeFileSync, appendFileSync } from "fs";
|
|
8
9
|
import { resolve } from "path";
|
|
9
|
-
import { parse } from "yaml";
|
|
10
|
+
import { parse, stringify } from "yaml";
|
|
11
|
+
var DEFAULT_PROMPT = `You are a changelog generator. Your task is to analyze git commits and staged changes to generate changelog entries following the Keep a Changelog format.
|
|
12
|
+
|
|
13
|
+
Output Format:
|
|
14
|
+
Return ONLY a JSON object with the following structure:
|
|
15
|
+
{
|
|
16
|
+
"sections": [
|
|
17
|
+
{
|
|
18
|
+
"type": "Added" | "Changed" | "Deprecated" | "Removed" | "Fixed" | "Security",
|
|
19
|
+
"items": ["description 1", "description 2"]
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Guidelines:
|
|
25
|
+
- Use present tense (e.g., "Add feature" not "Added feature")
|
|
26
|
+
- Be concise but descriptive
|
|
27
|
+
- Group related changes together
|
|
28
|
+
- Focus on user-facing changes
|
|
29
|
+
- Ignore merge commits and trivial changes
|
|
30
|
+
- Parse conventional commits (feat:, fix:, etc.) into appropriate sections:
|
|
31
|
+
- feat: -> Added
|
|
32
|
+
- fix: -> Fixed
|
|
33
|
+
- docs:, style:, refactor:, perf:, test:, chore: -> Changed
|
|
34
|
+
- BREAKING CHANGE: -> Changed (mention breaking)
|
|
35
|
+
- deprecate: -> Deprecated
|
|
36
|
+
- remove: -> Removed
|
|
37
|
+
- security: -> Security`;
|
|
10
38
|
var DEFAULT_CONFIG = {
|
|
11
39
|
ai: {
|
|
12
40
|
provider: "openrouter",
|
|
13
|
-
model: "anthropic/claude-
|
|
14
|
-
token: ""
|
|
41
|
+
model: "anthropic/claude-sonnet-4.5",
|
|
42
|
+
token: "",
|
|
43
|
+
prompt: DEFAULT_PROMPT
|
|
15
44
|
},
|
|
16
45
|
changelog: {
|
|
17
46
|
file: "CHANGELOG.md",
|
|
18
47
|
format: "keepachangelog",
|
|
19
48
|
includeDate: true,
|
|
49
|
+
includeTime: true,
|
|
50
|
+
includeAuthor: true,
|
|
51
|
+
includeCommitLink: true,
|
|
52
|
+
repoUrl: "",
|
|
20
53
|
groupBy: "type"
|
|
21
54
|
},
|
|
22
55
|
git: {
|
|
@@ -82,6 +115,65 @@ function loadConfig(configPath) {
|
|
|
82
115
|
const merged = deepMerge(DEFAULT_CONFIG, parsed);
|
|
83
116
|
return resolveConfigEnvVars(merged);
|
|
84
117
|
}
|
|
118
|
+
function initConfig(fileName = "tst-changelog.yaml") {
|
|
119
|
+
const filePath = resolve(process.cwd(), fileName);
|
|
120
|
+
if (existsSync(filePath)) {
|
|
121
|
+
throw new Error(`Config file already exists: ${filePath}`);
|
|
122
|
+
}
|
|
123
|
+
const configTemplate = {
|
|
124
|
+
ai: {
|
|
125
|
+
provider: "openrouter",
|
|
126
|
+
model: "anthropic/claude-sonnet-4.5",
|
|
127
|
+
token: "${OPENROUTER_API_KEY}",
|
|
128
|
+
prompt: DEFAULT_PROMPT
|
|
129
|
+
},
|
|
130
|
+
changelog: {
|
|
131
|
+
file: "CHANGELOG.md",
|
|
132
|
+
format: "keepachangelog",
|
|
133
|
+
includeDate: true,
|
|
134
|
+
includeTime: true,
|
|
135
|
+
includeAuthor: true,
|
|
136
|
+
includeCommitLink: true,
|
|
137
|
+
repoUrl: "",
|
|
138
|
+
groupBy: "type"
|
|
139
|
+
},
|
|
140
|
+
git: {
|
|
141
|
+
baseBranch: "main",
|
|
142
|
+
analyzeDepth: 50
|
|
143
|
+
}
|
|
144
|
+
};
|
|
145
|
+
const content = stringify(configTemplate, { lineWidth: 0 });
|
|
146
|
+
writeFileSync(filePath, content, "utf-8");
|
|
147
|
+
const huskyResult = configureHusky();
|
|
148
|
+
return {
|
|
149
|
+
configPath: filePath,
|
|
150
|
+
...huskyResult
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
function configureHusky() {
|
|
154
|
+
const huskyDir = resolve(process.cwd(), ".husky");
|
|
155
|
+
if (!existsSync(huskyDir)) {
|
|
156
|
+
return { huskyConfigured: false };
|
|
157
|
+
}
|
|
158
|
+
const preCommitPath = resolve(huskyDir, "pre-commit");
|
|
159
|
+
const command = "npx tst-changelog";
|
|
160
|
+
if (existsSync(preCommitPath)) {
|
|
161
|
+
const content = readFileSync(preCommitPath, "utf-8");
|
|
162
|
+
if (content.includes("tst-changelog")) {
|
|
163
|
+
return { huskyConfigured: false };
|
|
164
|
+
}
|
|
165
|
+
appendFileSync(preCommitPath, `
|
|
166
|
+
${command}
|
|
167
|
+
`);
|
|
168
|
+
} else {
|
|
169
|
+
writeFileSync(preCommitPath, `#!/usr/bin/env sh
|
|
170
|
+
. "$(dirname -- "$0")/_/husky.sh"
|
|
171
|
+
|
|
172
|
+
${command}
|
|
173
|
+
`, { mode: 493 });
|
|
174
|
+
}
|
|
175
|
+
return { huskyConfigured: true, huskyHook: preCommitPath };
|
|
176
|
+
}
|
|
85
177
|
|
|
86
178
|
// src/git.ts
|
|
87
179
|
import simpleGit from "simple-git";
|
|
@@ -190,37 +282,32 @@ var GitService = class {
|
|
|
190
282
|
return false;
|
|
191
283
|
}
|
|
192
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* Get current git user name
|
|
287
|
+
*/
|
|
288
|
+
async getCurrentUser() {
|
|
289
|
+
try {
|
|
290
|
+
const name = await this.git.getConfig("user.name");
|
|
291
|
+
return name.value ?? "";
|
|
292
|
+
} catch {
|
|
293
|
+
return "";
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Get HEAD commit hash
|
|
298
|
+
*/
|
|
299
|
+
async getHeadCommit() {
|
|
300
|
+
try {
|
|
301
|
+
const hash = await this.git.revparse(["HEAD"]);
|
|
302
|
+
return hash.trim();
|
|
303
|
+
} catch {
|
|
304
|
+
return "";
|
|
305
|
+
}
|
|
306
|
+
}
|
|
193
307
|
};
|
|
194
308
|
|
|
195
309
|
// src/ai.ts
|
|
196
310
|
var OPENROUTER_API_URL = "https://openrouter.ai/api/v1/chat/completions";
|
|
197
|
-
var SYSTEM_PROMPT = `You are a changelog generator. Your task is to analyze git commits and staged changes to generate changelog entries following the Keep a Changelog format.
|
|
198
|
-
|
|
199
|
-
Output Format:
|
|
200
|
-
Return ONLY a JSON object with the following structure:
|
|
201
|
-
{
|
|
202
|
-
"sections": [
|
|
203
|
-
{
|
|
204
|
-
"type": "Added" | "Changed" | "Deprecated" | "Removed" | "Fixed" | "Security",
|
|
205
|
-
"items": ["description 1", "description 2"]
|
|
206
|
-
}
|
|
207
|
-
]
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
Guidelines:
|
|
211
|
-
- Use present tense (e.g., "Add feature" not "Added feature")
|
|
212
|
-
- Be concise but descriptive
|
|
213
|
-
- Group related changes together
|
|
214
|
-
- Focus on user-facing changes
|
|
215
|
-
- Ignore merge commits and trivial changes
|
|
216
|
-
- Parse conventional commits (feat:, fix:, etc.) into appropriate sections:
|
|
217
|
-
- feat: -> Added
|
|
218
|
-
- fix: -> Fixed
|
|
219
|
-
- docs:, style:, refactor:, perf:, test:, chore: -> Changed
|
|
220
|
-
- BREAKING CHANGE: -> Changed (mention breaking)
|
|
221
|
-
- deprecate: -> Deprecated
|
|
222
|
-
- remove: -> Removed
|
|
223
|
-
- security: -> Security`;
|
|
224
311
|
var AIService = class {
|
|
225
312
|
config;
|
|
226
313
|
constructor(config) {
|
|
@@ -272,7 +359,7 @@ var AIService = class {
|
|
|
272
359
|
body: JSON.stringify({
|
|
273
360
|
model: this.config.model,
|
|
274
361
|
messages: [
|
|
275
|
-
{ role: "system", content:
|
|
362
|
+
{ role: "system", content: this.config.prompt ?? "" },
|
|
276
363
|
{ role: "user", content: prompt }
|
|
277
364
|
],
|
|
278
365
|
temperature: 0.3,
|
|
@@ -320,7 +407,7 @@ var AIService = class {
|
|
|
320
407
|
};
|
|
321
408
|
|
|
322
409
|
// src/changelog.ts
|
|
323
|
-
import { readFileSync as readFileSync2, writeFileSync, existsSync as existsSync2 } from "fs";
|
|
410
|
+
import { readFileSync as readFileSync2, writeFileSync as writeFileSync2, existsSync as existsSync2 } from "fs";
|
|
324
411
|
import { resolve as resolve2 } from "path";
|
|
325
412
|
var KEEPACHANGELOG_HEADER = `# Changelog
|
|
326
413
|
|
|
@@ -350,10 +437,31 @@ var ChangelogService = class {
|
|
|
350
437
|
/**
|
|
351
438
|
* Generate new changelog entry
|
|
352
439
|
*/
|
|
353
|
-
formatEntry(generated, version) {
|
|
354
|
-
const date = this.config.includeDate ? (/* @__PURE__ */ new Date()).toISOString().split("T")[0] : "";
|
|
440
|
+
formatEntry(generated, version, metadata) {
|
|
355
441
|
const versionStr = version ?? "Unreleased";
|
|
356
|
-
const
|
|
442
|
+
const headerParts = [`## [${versionStr}]`];
|
|
443
|
+
if (this.config.includeDate) {
|
|
444
|
+
const now = metadata?.timestamp ?? /* @__PURE__ */ new Date();
|
|
445
|
+
let dateStr = now.toISOString().split("T")[0];
|
|
446
|
+
if (this.config.includeTime) {
|
|
447
|
+
const timeStr = now.toTimeString().split(" ")[0].slice(0, 5);
|
|
448
|
+
dateStr += ` ${timeStr}`;
|
|
449
|
+
}
|
|
450
|
+
headerParts.push(`- ${dateStr}`);
|
|
451
|
+
}
|
|
452
|
+
if (this.config.includeAuthor && metadata?.author) {
|
|
453
|
+
headerParts.push(`by ${metadata.author}`);
|
|
454
|
+
}
|
|
455
|
+
if (this.config.includeCommitLink && metadata?.commitHash) {
|
|
456
|
+
const shortHash = metadata.commitHash.slice(0, 7);
|
|
457
|
+
if (this.config.repoUrl) {
|
|
458
|
+
const commitUrl = `${this.config.repoUrl.replace(/\/$/, "")}/commit/${metadata.commitHash}`;
|
|
459
|
+
headerParts.push(`([${shortHash}](${commitUrl}))`);
|
|
460
|
+
} else {
|
|
461
|
+
headerParts.push(`(${shortHash})`);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
const headerLine = headerParts.join(" ");
|
|
357
465
|
const sections = this.sortSections(generated.sections);
|
|
358
466
|
const sectionLines = sections.map((section) => this.formatSection(section)).join("\n\n");
|
|
359
467
|
return `${headerLine}
|
|
@@ -376,11 +484,11 @@ ${items}`;
|
|
|
376
484
|
/**
|
|
377
485
|
* Update or create changelog with new entry
|
|
378
486
|
*/
|
|
379
|
-
update(generated, version) {
|
|
380
|
-
const newEntry = this.formatEntry(generated, version);
|
|
487
|
+
update(generated, version, metadata) {
|
|
381
488
|
const existing = this.read();
|
|
382
489
|
if (!existing) {
|
|
383
|
-
|
|
490
|
+
const newEntry2 = this.formatEntry(generated, version, metadata);
|
|
491
|
+
return KEEPACHANGELOG_HEADER + newEntry2 + "\n";
|
|
384
492
|
}
|
|
385
493
|
const lines = existing.split("\n");
|
|
386
494
|
let insertIndex = -1;
|
|
@@ -388,15 +496,18 @@ ${items}`;
|
|
|
388
496
|
const line = lines[i];
|
|
389
497
|
if (line.startsWith("## [Unreleased]")) {
|
|
390
498
|
const endIndex = this.findSectionEnd(lines, i + 1);
|
|
499
|
+
const existingSectionLines = lines.slice(i, endIndex);
|
|
500
|
+
const mergedSection = this.mergeUnreleasedSection(existingSectionLines, generated, metadata);
|
|
391
501
|
const before2 = lines.slice(0, i).join("\n");
|
|
392
502
|
const after2 = lines.slice(endIndex).join("\n");
|
|
393
|
-
return before2 + (before2.endsWith("\n") ? "" : "\n") +
|
|
503
|
+
return before2 + (before2.endsWith("\n") ? "" : "\n") + mergedSection + "\n" + after2;
|
|
394
504
|
}
|
|
395
505
|
if (line.startsWith("## [") && insertIndex === -1) {
|
|
396
506
|
insertIndex = i;
|
|
397
507
|
break;
|
|
398
508
|
}
|
|
399
509
|
}
|
|
510
|
+
const newEntry = this.formatEntry(generated, version, metadata);
|
|
400
511
|
if (insertIndex === -1) {
|
|
401
512
|
return existing.trimEnd() + "\n\n" + newEntry + "\n";
|
|
402
513
|
}
|
|
@@ -404,6 +515,67 @@ ${items}`;
|
|
|
404
515
|
const after = lines.slice(insertIndex).join("\n");
|
|
405
516
|
return before + (before.endsWith("\n") ? "" : "\n") + newEntry + "\n\n" + after;
|
|
406
517
|
}
|
|
518
|
+
/**
|
|
519
|
+
* Merge new entries into existing Unreleased section
|
|
520
|
+
*/
|
|
521
|
+
mergeUnreleasedSection(existingLines, generated, metadata) {
|
|
522
|
+
const existingSections = /* @__PURE__ */ new Map();
|
|
523
|
+
let currentSection = null;
|
|
524
|
+
for (const line of existingLines) {
|
|
525
|
+
if (line.startsWith("### ")) {
|
|
526
|
+
currentSection = line.slice(4).trim();
|
|
527
|
+
if (!existingSections.has(currentSection)) {
|
|
528
|
+
existingSections.set(currentSection, []);
|
|
529
|
+
}
|
|
530
|
+
} else if (currentSection && line.startsWith("- ")) {
|
|
531
|
+
existingSections.get(currentSection).push(line.slice(2));
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
for (const section of generated.sections) {
|
|
535
|
+
const existing = existingSections.get(section.type) ?? [];
|
|
536
|
+
for (const item of section.items) {
|
|
537
|
+
if (!existing.includes(item)) {
|
|
538
|
+
existing.push(item);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
existingSections.set(section.type, existing);
|
|
542
|
+
}
|
|
543
|
+
const versionStr = "Unreleased";
|
|
544
|
+
const headerParts = [`## [${versionStr}]`];
|
|
545
|
+
if (this.config.includeDate) {
|
|
546
|
+
const now = metadata?.timestamp ?? /* @__PURE__ */ new Date();
|
|
547
|
+
let dateStr = now.toISOString().split("T")[0];
|
|
548
|
+
if (this.config.includeTime) {
|
|
549
|
+
const timeStr = now.toTimeString().split(" ")[0].slice(0, 5);
|
|
550
|
+
dateStr += ` ${timeStr}`;
|
|
551
|
+
}
|
|
552
|
+
headerParts.push(`- ${dateStr}`);
|
|
553
|
+
}
|
|
554
|
+
if (this.config.includeAuthor && metadata?.author) {
|
|
555
|
+
headerParts.push(`by ${metadata.author}`);
|
|
556
|
+
}
|
|
557
|
+
if (this.config.includeCommitLink && metadata?.commitHash) {
|
|
558
|
+
const shortHash = metadata.commitHash.slice(0, 7);
|
|
559
|
+
if (this.config.repoUrl) {
|
|
560
|
+
const commitUrl = `${this.config.repoUrl.replace(/\/$/, "")}/commit/${metadata.commitHash}`;
|
|
561
|
+
headerParts.push(`([${shortHash}](${commitUrl}))`);
|
|
562
|
+
} else {
|
|
563
|
+
headerParts.push(`(${shortHash})`);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
const headerLine = headerParts.join(" ");
|
|
567
|
+
const sortedSections = [];
|
|
568
|
+
for (const type of SECTION_ORDER) {
|
|
569
|
+
const items = existingSections.get(type);
|
|
570
|
+
if (items && items.length > 0) {
|
|
571
|
+
sortedSections.push({ type, items });
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
const sectionLines = sortedSections.map((section) => this.formatSection(section)).join("\n\n");
|
|
575
|
+
return `${headerLine}
|
|
576
|
+
|
|
577
|
+
${sectionLines}`;
|
|
578
|
+
}
|
|
407
579
|
findSectionEnd(lines, startIndex) {
|
|
408
580
|
for (let i = startIndex; i < lines.length; i++) {
|
|
409
581
|
if (lines[i].startsWith("## [")) {
|
|
@@ -416,7 +588,7 @@ ${items}`;
|
|
|
416
588
|
* Write changelog to file
|
|
417
589
|
*/
|
|
418
590
|
write(content) {
|
|
419
|
-
|
|
591
|
+
writeFileSync2(this.filePath, content, "utf-8");
|
|
420
592
|
}
|
|
421
593
|
/**
|
|
422
594
|
* Get the file path
|
|
@@ -428,7 +600,26 @@ ${items}`;
|
|
|
428
600
|
|
|
429
601
|
// src/index.ts
|
|
430
602
|
var program = new Command();
|
|
431
|
-
program.name("tst-changelog").description("AI-powered changelog generator using OpenRouter").version("0.1.0")
|
|
603
|
+
program.name("tst-changelog").description("AI-powered changelog generator using OpenRouter").version("0.1.0");
|
|
604
|
+
program.command("init").description("Create a default configuration file").option("-f, --file <name>", "Config file name", "tst-changelog.yaml").action((options) => {
|
|
605
|
+
try {
|
|
606
|
+
const result = initConfig(options.file);
|
|
607
|
+
console.log(`Created config file: ${result.configPath}`);
|
|
608
|
+
if (result.huskyConfigured) {
|
|
609
|
+
console.log(`Configured husky hook: ${result.huskyHook}`);
|
|
610
|
+
}
|
|
611
|
+
console.log("\nNext steps:");
|
|
612
|
+
console.log("1. Set the OPENROUTER_API_KEY environment variable");
|
|
613
|
+
console.log("2. Adjust settings in the config file as needed");
|
|
614
|
+
if (!result.huskyConfigured) {
|
|
615
|
+
console.log("3. Run: npx tst-changelog generate");
|
|
616
|
+
}
|
|
617
|
+
} catch (error) {
|
|
618
|
+
console.error("Error:", error instanceof Error ? error.message : error);
|
|
619
|
+
process.exit(1);
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
program.command("generate", { isDefault: true }).description("Generate changelog from staged changes or commit history").option("-c, --config <path>", "Path to config file").option("-d, --dry-run", "Preview without modifying files").option("-v, --verbose", "Enable verbose output").option("--from-commits <count>", "Generate from last N commits instead of staged changes", parseInt).action(run);
|
|
432
623
|
async function run(options) {
|
|
433
624
|
const verbose = options.verbose ?? false;
|
|
434
625
|
try {
|
|
@@ -442,19 +633,32 @@ async function run(options) {
|
|
|
442
633
|
console.error("Error: Not a git repository");
|
|
443
634
|
process.exit(1);
|
|
444
635
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
if (
|
|
448
|
-
console.log(
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
636
|
+
let commits;
|
|
637
|
+
let staged;
|
|
638
|
+
if (options.fromCommits) {
|
|
639
|
+
if (verbose) console.log(`Getting last ${options.fromCommits} commits...`);
|
|
640
|
+
commits = await git.getRecentCommits(options.fromCommits);
|
|
641
|
+
if (commits.length === 0) {
|
|
642
|
+
console.log("No commits found.");
|
|
643
|
+
process.exit(0);
|
|
644
|
+
}
|
|
645
|
+
if (verbose) console.log(`Found ${commits.length} commits`);
|
|
646
|
+
staged = { files: [], diff: "" };
|
|
647
|
+
} else {
|
|
648
|
+
if (verbose) console.log("Getting staged changes...");
|
|
649
|
+
staged = await git.getStagedChanges();
|
|
650
|
+
if (staged.files.length === 0) {
|
|
651
|
+
console.log("No staged changes found. Stage some changes first.");
|
|
652
|
+
process.exit(0);
|
|
653
|
+
}
|
|
654
|
+
if (verbose) {
|
|
655
|
+
console.log(`Staged files: ${staged.files.join(", ")}`);
|
|
656
|
+
console.log(`Diff length: ${staged.diff.length} chars`);
|
|
657
|
+
}
|
|
658
|
+
if (verbose) console.log("Getting recent commits...");
|
|
659
|
+
commits = await git.getUnmergedCommits();
|
|
660
|
+
if (verbose) console.log(`Found ${commits.length} unmerged commits`);
|
|
454
661
|
}
|
|
455
|
-
if (verbose) console.log("Getting recent commits...");
|
|
456
|
-
const commits = await git.getUnmergedCommits();
|
|
457
|
-
if (verbose) console.log(`Found ${commits.length} unmerged commits`);
|
|
458
662
|
console.log("Generating changelog with AI...");
|
|
459
663
|
const generated = await ai.generateChangelog(commits, staged);
|
|
460
664
|
if (generated.sections.length === 0) {
|
|
@@ -471,19 +675,33 @@ async function run(options) {
|
|
|
471
675
|
}
|
|
472
676
|
}
|
|
473
677
|
}
|
|
474
|
-
const
|
|
678
|
+
const [author, commitHash] = await Promise.all([
|
|
679
|
+
git.getCurrentUser(),
|
|
680
|
+
git.getHeadCommit()
|
|
681
|
+
]);
|
|
682
|
+
const metadata = {
|
|
683
|
+
author: author || void 0,
|
|
684
|
+
commitHash: commitHash || void 0,
|
|
685
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
686
|
+
};
|
|
687
|
+
if (verbose) {
|
|
688
|
+
console.log("Metadata:", metadata);
|
|
689
|
+
}
|
|
690
|
+
const newContent = changelog.update(generated, void 0, metadata);
|
|
475
691
|
if (options.dryRun) {
|
|
476
692
|
console.log("\n--- DRY RUN ---");
|
|
477
693
|
console.log("Would update changelog at:", changelog.getFilePath());
|
|
478
694
|
console.log("\n--- New entry ---");
|
|
479
|
-
console.log(changelog.formatEntry(generated));
|
|
695
|
+
console.log(changelog.formatEntry(generated, void 0, metadata));
|
|
480
696
|
console.log("--- End ---\n");
|
|
481
697
|
process.exit(0);
|
|
482
698
|
}
|
|
483
699
|
changelog.write(newContent);
|
|
484
700
|
console.log(`Updated: ${changelog.getFilePath()}`);
|
|
485
|
-
|
|
486
|
-
|
|
701
|
+
if (!options.fromCommits) {
|
|
702
|
+
await git.stageFile(config.changelog.file);
|
|
703
|
+
console.log("Staged changelog file");
|
|
704
|
+
}
|
|
487
705
|
console.log("Done!");
|
|
488
706
|
} catch (error) {
|
|
489
707
|
console.error("Error:", error instanceof Error ? error.message : error);
|
|
@@ -498,6 +716,7 @@ export {
|
|
|
498
716
|
AIService,
|
|
499
717
|
ChangelogService,
|
|
500
718
|
GitService,
|
|
719
|
+
initConfig,
|
|
501
720
|
loadConfig
|
|
502
721
|
};
|
|
503
722
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/config.ts","../src/git.ts","../src/ai.ts","../src/changelog.ts"],"sourcesContent":["import { Command } from 'commander';\nimport { loadConfig } from './config.js';\nimport { GitService } from './git.js';\nimport { AIService } from './ai.js';\nimport { ChangelogService } from './changelog.js';\nimport type { CLIOptions } from './types.js';\n\nconst program = new Command();\n\nprogram\n .name('tst-changelog')\n .description('AI-powered changelog generator using OpenRouter')\n .version('0.1.0')\n .option('-c, --config <path>', 'Path to config file')\n .option('-d, --dry-run', 'Preview without modifying files')\n .option('-v, --verbose', 'Enable verbose output')\n .action(run);\n\nasync function run(options: CLIOptions): Promise<void> {\n const verbose = options.verbose ?? false;\n\n try {\n // Load configuration\n if (verbose) console.log('Loading configuration...');\n const config = loadConfig(options.config);\n if (verbose) console.log('Config loaded:', JSON.stringify(config, null, 2));\n\n // Initialize services\n const git = new GitService(config.git);\n const ai = new AIService(config.ai);\n const changelog = new ChangelogService(config.changelog);\n\n // Check if we're in a git repo\n if (!(await git.isGitRepo())) {\n console.error('Error: Not a git repository');\n process.exit(1);\n }\n\n // Get staged changes\n if (verbose) console.log('Getting staged changes...');\n const staged = await git.getStagedChanges();\n\n if (staged.files.length === 0) {\n console.log('No staged changes found. Stage some changes first.');\n process.exit(0);\n }\n\n if (verbose) {\n console.log(`Staged files: ${staged.files.join(', ')}`);\n console.log(`Diff length: ${staged.diff.length} chars`);\n }\n\n // Get recent commits for context\n if (verbose) console.log('Getting recent commits...');\n const commits = await git.getUnmergedCommits();\n if (verbose) console.log(`Found ${commits.length} unmerged commits`);\n\n // Generate changelog using AI\n console.log('Generating changelog with AI...');\n const generated = await ai.generateChangelog(commits, staged);\n\n if (generated.sections.length === 0) {\n console.log('No changelog entries generated.');\n if (verbose) console.log('Raw AI response:', generated.raw);\n process.exit(0);\n }\n\n if (verbose) {\n console.log('Generated sections:');\n for (const section of generated.sections) {\n console.log(` ${section.type}:`);\n for (const item of section.items) {\n console.log(` - ${item}`);\n }\n }\n }\n\n // Update changelog\n const newContent = changelog.update(generated);\n\n if (options.dryRun) {\n console.log('\\n--- DRY RUN ---');\n console.log('Would update changelog at:', changelog.getFilePath());\n console.log('\\n--- New entry ---');\n console.log(changelog.formatEntry(generated));\n console.log('--- End ---\\n');\n process.exit(0);\n }\n\n // Write and stage\n changelog.write(newContent);\n console.log(`Updated: ${changelog.getFilePath()}`);\n\n await git.stageFile(config.changelog.file);\n console.log('Staged changelog file');\n\n console.log('Done!');\n } catch (error) {\n console.error('Error:', error instanceof Error ? error.message : error);\n if (verbose && error instanceof Error) {\n console.error(error.stack);\n }\n process.exit(1);\n }\n}\n\nprogram.parse();\n\n// Export for programmatic usage\nexport { loadConfig } from './config.js';\nexport { GitService } from './git.js';\nexport { AIService } from './ai.js';\nexport { ChangelogService } from './changelog.js';\nexport * from './types.js';\n","import { readFileSync, existsSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { parse } from 'yaml';\nimport type { Config } from './types.js';\n\nconst DEFAULT_CONFIG: Config = {\n ai: {\n provider: 'openrouter',\n model: 'anthropic/claude-3-haiku',\n token: '',\n },\n changelog: {\n file: 'CHANGELOG.md',\n format: 'keepachangelog',\n includeDate: true,\n groupBy: 'type',\n },\n git: {\n baseBranch: 'main',\n analyzeDepth: 50,\n },\n};\n\n/**\n * Resolve environment variables in config values\n * Supports ${ENV_VAR} syntax\n */\nfunction resolveEnvVars(value: string): string {\n return value.replace(/\\$\\{([^}]+)\\}/g, (_, envVar) => {\n const envValue = process.env[envVar];\n if (!envValue) {\n throw new Error(`Environment variable ${envVar} is not set`);\n }\n return envValue;\n });\n}\n\n/**\n * Recursively resolve env vars in object\n */\nfunction resolveConfigEnvVars<T>(obj: T): T {\n if (typeof obj === 'string') {\n return resolveEnvVars(obj) as T;\n }\n if (Array.isArray(obj)) {\n return obj.map(resolveConfigEnvVars) as T;\n }\n if (obj && typeof obj === 'object') {\n const resolved: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n resolved[key] = resolveConfigEnvVars(value);\n }\n return resolved as T;\n }\n return obj;\n}\n\n/**\n * Deep merge two objects\n */\nfunction deepMerge(target: Config, source: Partial<Config>): Config {\n return {\n ai: { ...target.ai, ...source.ai },\n changelog: { ...target.changelog, ...source.changelog },\n git: { ...target.git, ...source.git },\n };\n}\n\n/**\n * Load configuration from yaml file\n */\nexport function loadConfig(configPath?: string): Config {\n const defaultPaths = ['tst-changelog.yaml', 'tst-changelog.yml', '.tst-changelog.yaml'];\n\n let filePath: string | undefined;\n\n if (configPath) {\n filePath = resolve(process.cwd(), configPath);\n if (!existsSync(filePath)) {\n throw new Error(`Config file not found: ${filePath}`);\n }\n } else {\n for (const p of defaultPaths) {\n const fullPath = resolve(process.cwd(), p);\n if (existsSync(fullPath)) {\n filePath = fullPath;\n break;\n }\n }\n }\n\n if (!filePath) {\n console.warn('No config file found, using defaults');\n return resolveConfigEnvVars(DEFAULT_CONFIG);\n }\n\n const content = readFileSync(filePath, 'utf-8');\n const parsed = parse(content) as Partial<Config>;\n\n const merged = deepMerge(DEFAULT_CONFIG, parsed);\n return resolveConfigEnvVars(merged);\n}\n","import simpleGit, { SimpleGit } from 'simple-git';\nimport type { CommitInfo, StagedChanges, GitConfig } from './types.js';\n\nexport class GitService {\n private git: SimpleGit;\n private config: GitConfig;\n\n constructor(config: GitConfig, cwd?: string) {\n this.git = simpleGit(cwd);\n this.config = config;\n }\n\n /**\n * Get list of staged files\n */\n async getStagedFiles(): Promise<string[]> {\n const status = await this.git.status();\n return status.staged;\n }\n\n /**\n * Get diff of staged changes\n */\n async getStagedDiff(): Promise<string> {\n const diff = await this.git.diff(['--cached']);\n return diff;\n }\n\n /**\n * Get staged changes (files + diff)\n */\n async getStagedChanges(): Promise<StagedChanges> {\n const [files, diff] = await Promise.all([\n this.getStagedFiles(),\n this.getStagedDiff(),\n ]);\n return { files, diff };\n }\n\n /**\n * Get recent commits from the base branch\n */\n async getRecentCommits(count?: number): Promise<CommitInfo[]> {\n const limit = count ?? this.config.analyzeDepth;\n const log = await this.git.log({\n maxCount: limit,\n format: {\n hash: '%H',\n message: '%s',\n author: '%an',\n date: '%aI',\n body: '%b',\n },\n });\n\n return log.all.map((commit) => ({\n hash: commit.hash,\n message: commit.message,\n author: commit.author,\n date: commit.date,\n body: commit.body?.trim() || undefined,\n }));\n }\n\n /**\n * Get commits not yet in base branch (for feature branches)\n */\n async getUnmergedCommits(): Promise<CommitInfo[]> {\n try {\n const log = await this.git.log({\n from: this.config.baseBranch,\n to: 'HEAD',\n format: {\n hash: '%H',\n message: '%s',\n author: '%an',\n date: '%aI',\n body: '%b',\n },\n });\n\n return log.all.map((commit) => ({\n hash: commit.hash,\n message: commit.message,\n author: commit.author,\n date: commit.date,\n body: commit.body?.trim() || undefined,\n }));\n } catch {\n // If base branch doesn't exist, return empty\n return [];\n }\n }\n\n /**\n * Get current branch name\n */\n async getCurrentBranch(): Promise<string> {\n const branch = await this.git.revparse(['--abbrev-ref', 'HEAD']);\n return branch.trim();\n }\n\n /**\n * Stage a file\n */\n async stageFile(filePath: string): Promise<void> {\n await this.git.add(filePath);\n }\n\n /**\n * Check if we're in a git repository\n */\n async isGitRepo(): Promise<boolean> {\n try {\n await this.git.revparse(['--git-dir']);\n return true;\n } catch {\n return false;\n }\n }\n}\n","import type { AIConfig, CommitInfo, StagedChanges, GeneratedChangelog, ChangelogSection, ChangeType } from './types.js';\n\nconst OPENROUTER_API_URL = 'https://openrouter.ai/api/v1/chat/completions';\n\nconst SYSTEM_PROMPT = `You are a changelog generator. Your task is to analyze git commits and staged changes to generate changelog entries following the Keep a Changelog format.\n\nOutput Format:\nReturn ONLY a JSON object with the following structure:\n{\n \"sections\": [\n {\n \"type\": \"Added\" | \"Changed\" | \"Deprecated\" | \"Removed\" | \"Fixed\" | \"Security\",\n \"items\": [\"description 1\", \"description 2\"]\n }\n ]\n}\n\nGuidelines:\n- Use present tense (e.g., \"Add feature\" not \"Added feature\")\n- Be concise but descriptive\n- Group related changes together\n- Focus on user-facing changes\n- Ignore merge commits and trivial changes\n- Parse conventional commits (feat:, fix:, etc.) into appropriate sections:\n - feat: -> Added\n - fix: -> Fixed\n - docs:, style:, refactor:, perf:, test:, chore: -> Changed\n - BREAKING CHANGE: -> Changed (mention breaking)\n - deprecate: -> Deprecated\n - remove: -> Removed\n - security: -> Security`;\n\ninterface OpenRouterResponse {\n choices: Array<{\n message: {\n content: string;\n };\n }>;\n}\n\nexport class AIService {\n private config: AIConfig;\n\n constructor(config: AIConfig) {\n this.config = config;\n }\n\n /**\n * Generate changelog entries from commits and staged changes\n */\n async generateChangelog(\n commits: CommitInfo[],\n staged: StagedChanges\n ): Promise<GeneratedChangelog> {\n const userPrompt = this.buildPrompt(commits, staged);\n const response = await this.callOpenRouter(userPrompt);\n return this.parseResponse(response);\n }\n\n private buildPrompt(commits: CommitInfo[], staged: StagedChanges): string {\n const parts: string[] = [];\n\n if (commits.length > 0) {\n parts.push('## Recent Commits:');\n for (const commit of commits.slice(0, 20)) {\n parts.push(`- ${commit.message}`);\n if (commit.body) {\n parts.push(` ${commit.body}`);\n }\n }\n }\n\n if (staged.files.length > 0) {\n parts.push('\\n## Staged Files:');\n parts.push(staged.files.join('\\n'));\n }\n\n if (staged.diff) {\n // Limit diff size to avoid token limits\n const maxDiffLength = 4000;\n const truncatedDiff = staged.diff.length > maxDiffLength\n ? staged.diff.slice(0, maxDiffLength) + '\\n... (truncated)'\n : staged.diff;\n parts.push('\\n## Staged Diff:');\n parts.push('```diff');\n parts.push(truncatedDiff);\n parts.push('```');\n }\n\n parts.push('\\nGenerate changelog entries for these changes.');\n\n return parts.join('\\n');\n }\n\n private async callOpenRouter(prompt: string): Promise<string> {\n const response = await fetch(OPENROUTER_API_URL, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.config.token}`,\n 'HTTP-Referer': 'https://github.com/testudosrl/tst-libs',\n 'X-Title': 'tst-changelog',\n },\n body: JSON.stringify({\n model: this.config.model,\n messages: [\n { role: 'system', content: SYSTEM_PROMPT },\n { role: 'user', content: prompt },\n ],\n temperature: 0.3,\n max_tokens: 1000,\n }),\n });\n\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`OpenRouter API error: ${response.status} - ${error}`);\n }\n\n const data = (await response.json()) as OpenRouterResponse;\n return data.choices[0]?.message?.content ?? '';\n }\n\n private parseResponse(response: string): GeneratedChangelog {\n try {\n // Extract JSON from response (handle markdown code blocks or raw JSON)\n let jsonStr = response;\n\n // Try markdown code block first\n const codeBlockMatch = response.match(/```(?:json)?\\s*([\\s\\S]*?)```/);\n if (codeBlockMatch) {\n jsonStr = codeBlockMatch[1];\n } else {\n // Try to find JSON object in the response\n const jsonObjectMatch = response.match(/\\{[\\s\\S]*\"sections\"[\\s\\S]*\\}/);\n if (jsonObjectMatch) {\n jsonStr = jsonObjectMatch[0];\n }\n }\n\n const parsed = JSON.parse(jsonStr.trim()) as { sections: ChangelogSection[] };\n\n // Validate and normalize sections\n const validTypes: ChangeType[] = ['Added', 'Changed', 'Deprecated', 'Removed', 'Fixed', 'Security'];\n const sections = parsed.sections\n .filter((s) => validTypes.includes(s.type))\n .map((s) => ({\n type: s.type,\n items: Array.isArray(s.items) ? s.items.filter((i) => typeof i === 'string') : [],\n }))\n .filter((s) => s.items.length > 0);\n\n return {\n raw: response,\n sections,\n };\n } catch (error) {\n console.error('Failed to parse AI response:', error);\n console.error('Raw response:', response);\n return {\n raw: response,\n sections: [],\n };\n }\n }\n}\n","import { readFileSync, writeFileSync, existsSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport type { ChangelogConfig, ChangelogSection, GeneratedChangelog } from './types.js';\n\nconst KEEPACHANGELOG_HEADER = `# Changelog\n\nAll notable changes to this project will be documented in this file.\n\nThe format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),\nand this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n\n`;\n\nconst SECTION_ORDER = ['Added', 'Changed', 'Deprecated', 'Removed', 'Fixed', 'Security'] as const;\n\nexport class ChangelogService {\n private config: ChangelogConfig;\n private filePath: string;\n\n constructor(config: ChangelogConfig, cwd?: string) {\n this.config = config;\n this.filePath = resolve(cwd ?? process.cwd(), config.file);\n }\n\n /**\n * Read existing changelog content\n */\n read(): string | null {\n if (!existsSync(this.filePath)) {\n return null;\n }\n return readFileSync(this.filePath, 'utf-8');\n }\n\n /**\n * Generate new changelog entry\n */\n formatEntry(generated: GeneratedChangelog, version?: string): string {\n const date = this.config.includeDate\n ? new Date().toISOString().split('T')[0]\n : '';\n\n const versionStr = version ?? 'Unreleased';\n const headerLine = date ? `## [${versionStr}] - ${date}` : `## [${versionStr}]`;\n\n const sections = this.sortSections(generated.sections);\n const sectionLines = sections\n .map((section) => this.formatSection(section))\n .join('\\n\\n');\n\n return `${headerLine}\\n\\n${sectionLines}`;\n }\n\n private sortSections(sections: ChangelogSection[]): ChangelogSection[] {\n return [...sections].sort((a, b) => {\n const indexA = SECTION_ORDER.indexOf(a.type as typeof SECTION_ORDER[number]);\n const indexB = SECTION_ORDER.indexOf(b.type as typeof SECTION_ORDER[number]);\n return indexA - indexB;\n });\n }\n\n private formatSection(section: ChangelogSection): string {\n const items = section.items.map((item) => `- ${item}`).join('\\n');\n return `### ${section.type}\\n\\n${items}`;\n }\n\n /**\n * Update or create changelog with new entry\n */\n update(generated: GeneratedChangelog, version?: string): string {\n const newEntry = this.formatEntry(generated, version);\n const existing = this.read();\n\n if (!existing) {\n // Create new changelog\n return KEEPACHANGELOG_HEADER + newEntry + '\\n';\n }\n\n // Find where to insert new entry (after header, before first version)\n const lines = existing.split('\\n');\n let insertIndex = -1;\n\n // Look for ## [Unreleased] or first ## [ section\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (line.startsWith('## [Unreleased]')) {\n // Replace unreleased section\n const endIndex = this.findSectionEnd(lines, i + 1);\n const before = lines.slice(0, i).join('\\n');\n const after = lines.slice(endIndex).join('\\n');\n return before + (before.endsWith('\\n') ? '' : '\\n') + newEntry + '\\n\\n' + after;\n }\n if (line.startsWith('## [') && insertIndex === -1) {\n insertIndex = i;\n break;\n }\n }\n\n if (insertIndex === -1) {\n // No version sections found, append after header\n return existing.trimEnd() + '\\n\\n' + newEntry + '\\n';\n }\n\n // Insert before first version\n const before = lines.slice(0, insertIndex).join('\\n');\n const after = lines.slice(insertIndex).join('\\n');\n return before + (before.endsWith('\\n') ? '' : '\\n') + newEntry + '\\n\\n' + after;\n }\n\n private findSectionEnd(lines: string[], startIndex: number): number {\n for (let i = startIndex; i < lines.length; i++) {\n if (lines[i].startsWith('## [')) {\n return i;\n }\n }\n return lines.length;\n }\n\n /**\n * Write changelog to file\n */\n write(content: string): void {\n writeFileSync(this.filePath, content, 'utf-8');\n }\n\n /**\n * Get the file path\n */\n getFilePath(): string {\n return this.filePath;\n }\n}\n"],"mappings":";;;AAAA,SAAS,eAAe;;;ACAxB,SAAS,cAAc,kBAAkB;AACzC,SAAS,eAAe;AACxB,SAAS,aAAa;AAGtB,IAAM,iBAAyB;AAAA,EAC7B,IAAI;AAAA,IACF,UAAU;AAAA,IACV,OAAO;AAAA,IACP,OAAO;AAAA,EACT;AAAA,EACA,WAAW;AAAA,IACT,MAAM;AAAA,IACN,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,SAAS;AAAA,EACX;AAAA,EACA,KAAK;AAAA,IACH,YAAY;AAAA,IACZ,cAAc;AAAA,EAChB;AACF;AAMA,SAAS,eAAe,OAAuB;AAC7C,SAAO,MAAM,QAAQ,kBAAkB,CAAC,GAAG,WAAW;AACpD,UAAM,WAAW,QAAQ,IAAI,MAAM;AACnC,QAAI,CAAC,UAAU;AACb,YAAM,IAAI,MAAM,wBAAwB,MAAM,aAAa;AAAA,IAC7D;AACA,WAAO;AAAA,EACT,CAAC;AACH;AAKA,SAAS,qBAAwB,KAAW;AAC1C,MAAI,OAAO,QAAQ,UAAU;AAC3B,WAAO,eAAe,GAAG;AAAA,EAC3B;AACA,MAAI,MAAM,QAAQ,GAAG,GAAG;AACtB,WAAO,IAAI,IAAI,oBAAoB;AAAA,EACrC;AACA,MAAI,OAAO,OAAO,QAAQ,UAAU;AAClC,UAAM,WAAoC,CAAC;AAC3C,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,GAAG,GAAG;AAC9C,eAAS,GAAG,IAAI,qBAAqB,KAAK;AAAA,IAC5C;AACA,WAAO;AAAA,EACT;AACA,SAAO;AACT;AAKA,SAAS,UAAU,QAAgB,QAAiC;AAClE,SAAO;AAAA,IACL,IAAI,EAAE,GAAG,OAAO,IAAI,GAAG,OAAO,GAAG;AAAA,IACj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,UAAU,UAAU;AACxC,gBAAQ,IAAI,KAAK,QAAQ,IAAI,GAAG;AAChC,mBAAW,QAAQ,QAAQ,OAAO;AAChC,kBAAQ,IAAI,SAAS,IAAI,EAAE;AAAA,QAC7B;AAAA,MACF;AAAA,IACF;AAGA,UAAM,aAAa,UAAU,OAAO,SAAS;AAE7C,QAAI,QAAQ,QAAQ;AAClB,cAAQ,IAAI,mBAAmB;AAC/B,cAAQ,IAAI,8BAA8B,UAAU,YAAY,CAAC;AACjE,cAAQ,IAAI,qBAAqB;AACjC,cAAQ,IAAI,UAAU,YAAY,SAAS,CAAC;AAC5C,cAAQ,IAAI,eAAe;AAC3B,cAAQ,KAAK,CAAC;AAAA,IAChB;AAGA,cAAU,MAAM,UAAU;AAC1B,YAAQ,IAAI,YAAY,UAAU,YAAY,CAAC,EAAE;AAEjD,UAAM,IAAI,UAAU,OAAO,UAAU,IAAI;AACzC,YAAQ,IAAI,uBAAuB;AAEnC,YAAQ,IAAI,OAAO;AAAA,EACrB,SAAS,OAAO;AACd,YAAQ,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,KAAK;AACtE,QAAI,WAAW,iBAAiB,OAAO;AACrC,cAAQ,MAAM,MAAM,KAAK;AAAA,IAC3B;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEA,QAAQ,MAAM;","names":["readFileSync","existsSync","resolve","before","after"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/config.ts","../src/git.ts","../src/ai.ts","../src/changelog.ts"],"sourcesContent":["import 'dotenv/config';\nimport { Command } from 'commander';\nimport { loadConfig, initConfig } from './config.js';\nimport { GitService } from './git.js';\nimport { AIService } from './ai.js';\nimport { ChangelogService } from './changelog.js';\nimport type { CLIOptions, ChangelogMetadata } from './types.js';\n\nconst program = new Command();\n\nprogram\n .name('tst-changelog')\n .description('AI-powered changelog generator using OpenRouter')\n .version('0.1.0');\n\nprogram\n .command('init')\n .description('Create a default configuration file')\n .option('-f, --file <name>', 'Config file name', 'tst-changelog.yaml')\n .action((options: { file: string }) => {\n try {\n const result = initConfig(options.file);\n console.log(`Created config file: ${result.configPath}`);\n\n if (result.huskyConfigured) {\n console.log(`Configured husky hook: ${result.huskyHook}`);\n }\n\n console.log('\\nNext steps:');\n console.log('1. Set the OPENROUTER_API_KEY environment variable');\n console.log('2. Adjust settings in the config file as needed');\n if (!result.huskyConfigured) {\n console.log('3. Run: npx tst-changelog generate');\n }\n } catch (error) {\n console.error('Error:', error instanceof Error ? error.message : error);\n process.exit(1);\n }\n });\n\nprogram\n .command('generate', { isDefault: true })\n .description('Generate changelog from staged changes or commit history')\n .option('-c, --config <path>', 'Path to config file')\n .option('-d, --dry-run', 'Preview without modifying files')\n .option('-v, --verbose', 'Enable verbose output')\n .option('--from-commits <count>', 'Generate from last N commits instead of staged changes', parseInt)\n .action(run);\n\nasync function run(options: CLIOptions): Promise<void> {\n const verbose = options.verbose ?? false;\n\n try {\n // Load configuration\n if (verbose) console.log('Loading configuration...');\n const config = loadConfig(options.config);\n if (verbose) console.log('Config loaded:', JSON.stringify(config, null, 2));\n\n // Initialize services\n const git = new GitService(config.git);\n const ai = new AIService(config.ai);\n const changelog = new ChangelogService(config.changelog);\n\n // Check if we're in a git repo\n if (!(await git.isGitRepo())) {\n console.error('Error: Not a git repository');\n process.exit(1);\n }\n\n let commits;\n let staged;\n\n if (options.fromCommits) {\n // Generate from commit history\n if (verbose) console.log(`Getting last ${options.fromCommits} commits...`);\n commits = await git.getRecentCommits(options.fromCommits);\n\n if (commits.length === 0) {\n console.log('No commits found.');\n process.exit(0);\n }\n\n if (verbose) console.log(`Found ${commits.length} commits`);\n\n // Empty staged for history mode\n staged = { files: [], diff: '' };\n } else {\n // Get staged changes (default behavior)\n if (verbose) console.log('Getting staged changes...');\n staged = await git.getStagedChanges();\n\n if (staged.files.length === 0) {\n console.log('No staged changes found. Stage some changes first.');\n process.exit(0);\n }\n\n if (verbose) {\n console.log(`Staged files: ${staged.files.join(', ')}`);\n console.log(`Diff length: ${staged.diff.length} chars`);\n }\n\n // Get recent commits for context\n if (verbose) console.log('Getting recent commits...');\n commits = await git.getUnmergedCommits();\n if (verbose) console.log(`Found ${commits.length} unmerged commits`);\n }\n\n // Generate changelog using AI\n console.log('Generating changelog with AI...');\n const generated = await ai.generateChangelog(commits, staged);\n\n if (generated.sections.length === 0) {\n console.log('No changelog entries generated.');\n if (verbose) console.log('Raw AI response:', generated.raw);\n process.exit(0);\n }\n\n if (verbose) {\n console.log('Generated sections:');\n for (const section of generated.sections) {\n console.log(` ${section.type}:`);\n for (const item of section.items) {\n console.log(` - ${item}`);\n }\n }\n }\n\n // Collect metadata for changelog entry\n const [author, commitHash] = await Promise.all([\n git.getCurrentUser(),\n git.getHeadCommit(),\n ]);\n\n const metadata: ChangelogMetadata = {\n author: author || undefined,\n commitHash: commitHash || undefined,\n timestamp: new Date(),\n };\n\n if (verbose) {\n console.log('Metadata:', metadata);\n }\n\n // Update changelog\n const newContent = changelog.update(generated, undefined, metadata);\n\n if (options.dryRun) {\n console.log('\\n--- DRY RUN ---');\n console.log('Would update changelog at:', changelog.getFilePath());\n console.log('\\n--- New entry ---');\n console.log(changelog.formatEntry(generated, undefined, metadata));\n console.log('--- End ---\\n');\n process.exit(0);\n }\n\n // Write changelog\n changelog.write(newContent);\n console.log(`Updated: ${changelog.getFilePath()}`);\n\n // Only auto-stage when using staged changes mode (not --from-commits)\n if (!options.fromCommits) {\n await git.stageFile(config.changelog.file);\n console.log('Staged changelog file');\n }\n\n console.log('Done!');\n } catch (error) {\n console.error('Error:', error instanceof Error ? error.message : error);\n if (verbose && error instanceof Error) {\n console.error(error.stack);\n }\n process.exit(1);\n }\n}\n\nprogram.parse();\n\n// Export for programmatic usage\nexport { loadConfig, initConfig, type InitResult } from './config.js';\nexport { GitService } from './git.js';\nexport { AIService } from './ai.js';\nexport { ChangelogService } from './changelog.js';\nexport * from './types.js';\n","import { readFileSync, existsSync, writeFileSync, appendFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { parse, stringify } from 'yaml';\nimport type { Config } from './types.js';\n\nconst DEFAULT_PROMPT = `You are a changelog generator. Your task is to analyze git commits and staged changes to generate changelog entries following the Keep a Changelog format.\n\nOutput Format:\nReturn ONLY a JSON object with the following structure:\n{\n \"sections\": [\n {\n \"type\": \"Added\" | \"Changed\" | \"Deprecated\" | \"Removed\" | \"Fixed\" | \"Security\",\n \"items\": [\"description 1\", \"description 2\"]\n }\n ]\n}\n\nGuidelines:\n- Use present tense (e.g., \"Add feature\" not \"Added feature\")\n- Be concise but descriptive\n- Group related changes together\n- Focus on user-facing changes\n- Ignore merge commits and trivial changes\n- Parse conventional commits (feat:, fix:, etc.) into appropriate sections:\n - feat: -> Added\n - fix: -> Fixed\n - docs:, style:, refactor:, perf:, test:, chore: -> Changed\n - BREAKING CHANGE: -> Changed (mention breaking)\n - deprecate: -> Deprecated\n - remove: -> Removed\n - security: -> Security`;\n\nconst DEFAULT_CONFIG: Config = {\n ai: {\n provider: 'openrouter',\n model: 'anthropic/claude-sonnet-4.5',\n token: '',\n prompt: DEFAULT_PROMPT,\n },\n changelog: {\n file: 'CHANGELOG.md',\n format: 'keepachangelog',\n includeDate: true,\n includeTime: true,\n includeAuthor: true,\n includeCommitLink: true,\n repoUrl: '',\n groupBy: 'type',\n },\n git: {\n baseBranch: 'main',\n analyzeDepth: 50,\n },\n};\n\n/**\n * Resolve environment variables in config values\n * Supports ${ENV_VAR} syntax\n */\nfunction resolveEnvVars(value: string): string {\n return value.replace(/\\$\\{([^}]+)\\}/g, (_, envVar) => {\n const envValue = process.env[envVar];\n if (!envValue) {\n throw new Error(`Environment variable ${envVar} is not set`);\n }\n return envValue;\n });\n}\n\n/**\n * Recursively resolve env vars in object\n */\nfunction resolveConfigEnvVars<T>(obj: T): T {\n if (typeof obj === 'string') {\n return resolveEnvVars(obj) as T;\n }\n if (Array.isArray(obj)) {\n return obj.map(resolveConfigEnvVars) as T;\n }\n if (obj && typeof obj === 'object') {\n const resolved: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(obj)) {\n resolved[key] = resolveConfigEnvVars(value);\n }\n return resolved as T;\n }\n return obj;\n}\n\n/**\n * Deep merge two objects\n */\nfunction deepMerge(target: Config, source: Partial<Config>): Config {\n return {\n ai: { ...target.ai, ...source.ai },\n changelog: { ...target.changelog, ...source.changelog },\n git: { ...target.git, ...source.git },\n };\n}\n\n/**\n * Load configuration from yaml file\n */\nexport function loadConfig(configPath?: string): Config {\n const defaultPaths = ['tst-changelog.yaml', 'tst-changelog.yml', '.tst-changelog.yaml'];\n\n let filePath: string | undefined;\n\n if (configPath) {\n filePath = resolve(process.cwd(), configPath);\n if (!existsSync(filePath)) {\n throw new Error(`Config file not found: ${filePath}`);\n }\n } else {\n for (const p of defaultPaths) {\n const fullPath = resolve(process.cwd(), p);\n if (existsSync(fullPath)) {\n filePath = fullPath;\n break;\n }\n }\n }\n\n if (!filePath) {\n console.warn('No config file found, using defaults');\n return resolveConfigEnvVars(DEFAULT_CONFIG);\n }\n\n const content = readFileSync(filePath, 'utf-8');\n const parsed = parse(content) as Partial<Config>;\n\n const merged = deepMerge(DEFAULT_CONFIG, parsed);\n return resolveConfigEnvVars(merged);\n}\n\nexport interface InitResult {\n configPath: string;\n huskyConfigured: boolean;\n huskyHook?: string;\n}\n\n/**\n * Initialize a new config file with defaults\n */\nexport function initConfig(fileName = 'tst-changelog.yaml'): InitResult {\n const filePath = resolve(process.cwd(), fileName);\n\n if (existsSync(filePath)) {\n throw new Error(`Config file already exists: ${filePath}`);\n }\n\n const configTemplate: Config = {\n ai: {\n provider: 'openrouter',\n model: 'anthropic/claude-sonnet-4.5',\n token: '${OPENROUTER_API_KEY}',\n prompt: DEFAULT_PROMPT,\n },\n changelog: {\n file: 'CHANGELOG.md',\n format: 'keepachangelog',\n includeDate: true,\n includeTime: true,\n includeAuthor: true,\n includeCommitLink: true,\n repoUrl: '',\n groupBy: 'type',\n },\n git: {\n baseBranch: 'main',\n analyzeDepth: 50,\n },\n };\n\n const content = stringify(configTemplate, { lineWidth: 0 });\n writeFileSync(filePath, content, 'utf-8');\n\n // Check for husky and configure hook\n const huskyResult = configureHusky();\n\n return {\n configPath: filePath,\n ...huskyResult,\n };\n}\n\n/**\n * Configure husky pre-commit hook if husky is present\n */\nfunction configureHusky(): { huskyConfigured: boolean; huskyHook?: string } {\n const huskyDir = resolve(process.cwd(), '.husky');\n\n if (!existsSync(huskyDir)) {\n return { huskyConfigured: false };\n }\n\n const preCommitPath = resolve(huskyDir, 'pre-commit');\n const command = 'npx tst-changelog';\n\n // Check if hook already exists\n if (existsSync(preCommitPath)) {\n const content = readFileSync(preCommitPath, 'utf-8');\n if (content.includes('tst-changelog')) {\n return { huskyConfigured: false }; // Already configured\n }\n // Append to existing hook\n appendFileSync(preCommitPath, `\\n${command}\\n`);\n } else {\n // Create new hook\n writeFileSync(preCommitPath, `#!/usr/bin/env sh\\n. \"$(dirname -- \"$0\")/_/husky.sh\"\\n\\n${command}\\n`, { mode: 0o755 });\n }\n\n return { huskyConfigured: true, huskyHook: preCommitPath };\n}\n","import simpleGit, { SimpleGit } from 'simple-git';\nimport type { CommitInfo, StagedChanges, GitConfig } from './types.js';\n\nexport class GitService {\n private git: SimpleGit;\n private config: GitConfig;\n\n constructor(config: GitConfig, cwd?: string) {\n this.git = simpleGit(cwd);\n this.config = config;\n }\n\n /**\n * Get list of staged files\n */\n async getStagedFiles(): Promise<string[]> {\n const status = await this.git.status();\n return status.staged;\n }\n\n /**\n * Get diff of staged changes\n */\n async getStagedDiff(): Promise<string> {\n const diff = await this.git.diff(['--cached']);\n return diff;\n }\n\n /**\n * Get staged changes (files + diff)\n */\n async getStagedChanges(): Promise<StagedChanges> {\n const [files, diff] = await Promise.all([\n this.getStagedFiles(),\n this.getStagedDiff(),\n ]);\n return { files, diff };\n }\n\n /**\n * Get recent commits from the base branch\n */\n async getRecentCommits(count?: number): Promise<CommitInfo[]> {\n const limit = count ?? this.config.analyzeDepth;\n const log = await this.git.log({\n maxCount: limit,\n format: {\n hash: '%H',\n message: '%s',\n author: '%an',\n date: '%aI',\n body: '%b',\n },\n });\n\n return log.all.map((commit) => ({\n hash: commit.hash,\n message: commit.message,\n author: commit.author,\n date: commit.date,\n body: commit.body?.trim() || undefined,\n }));\n }\n\n /**\n * Get commits not yet in base branch (for feature branches)\n */\n async getUnmergedCommits(): Promise<CommitInfo[]> {\n try {\n const log = await this.git.log({\n from: this.config.baseBranch,\n to: 'HEAD',\n format: {\n hash: '%H',\n message: '%s',\n author: '%an',\n date: '%aI',\n body: '%b',\n },\n });\n\n return log.all.map((commit) => ({\n hash: commit.hash,\n message: commit.message,\n author: commit.author,\n date: commit.date,\n body: commit.body?.trim() || undefined,\n }));\n } catch {\n // If base branch doesn't exist, return empty\n return [];\n }\n }\n\n /**\n * Get current branch name\n */\n async getCurrentBranch(): Promise<string> {\n const branch = await this.git.revparse(['--abbrev-ref', 'HEAD']);\n return branch.trim();\n }\n\n /**\n * Stage a file\n */\n async stageFile(filePath: string): Promise<void> {\n await this.git.add(filePath);\n }\n\n /**\n * Check if we're in a git repository\n */\n async isGitRepo(): Promise<boolean> {\n try {\n await this.git.revparse(['--git-dir']);\n return true;\n } catch {\n return false;\n }\n }\n\n /**\n * Get current git user name\n */\n async getCurrentUser(): Promise<string> {\n try {\n const name = await this.git.getConfig('user.name');\n return name.value ?? '';\n } catch {\n return '';\n }\n }\n\n /**\n * Get HEAD commit hash\n */\n async getHeadCommit(): Promise<string> {\n try {\n const hash = await this.git.revparse(['HEAD']);\n return hash.trim();\n } catch {\n return '';\n }\n }\n}\n","import type { AIConfig, CommitInfo, StagedChanges, GeneratedChangelog, ChangelogSection, ChangeType } from './types.js';\n\nconst OPENROUTER_API_URL = 'https://openrouter.ai/api/v1/chat/completions';\n\ninterface OpenRouterResponse {\n choices: Array<{\n message: {\n content: string;\n };\n }>;\n}\n\nexport class AIService {\n private config: AIConfig;\n\n constructor(config: AIConfig) {\n this.config = config;\n }\n\n /**\n * Generate changelog entries from commits and staged changes\n */\n async generateChangelog(\n commits: CommitInfo[],\n staged: StagedChanges\n ): Promise<GeneratedChangelog> {\n const userPrompt = this.buildPrompt(commits, staged);\n const response = await this.callOpenRouter(userPrompt);\n return this.parseResponse(response);\n }\n\n private buildPrompt(commits: CommitInfo[], staged: StagedChanges): string {\n const parts: string[] = [];\n\n if (commits.length > 0) {\n parts.push('## Recent Commits:');\n for (const commit of commits.slice(0, 20)) {\n parts.push(`- ${commit.message}`);\n if (commit.body) {\n parts.push(` ${commit.body}`);\n }\n }\n }\n\n if (staged.files.length > 0) {\n parts.push('\\n## Staged Files:');\n parts.push(staged.files.join('\\n'));\n }\n\n if (staged.diff) {\n // Limit diff size to avoid token limits\n const maxDiffLength = 4000;\n const truncatedDiff = staged.diff.length > maxDiffLength\n ? staged.diff.slice(0, maxDiffLength) + '\\n... (truncated)'\n : staged.diff;\n parts.push('\\n## Staged Diff:');\n parts.push('```diff');\n parts.push(truncatedDiff);\n parts.push('```');\n }\n\n parts.push('\\nGenerate changelog entries for these changes.');\n\n return parts.join('\\n');\n }\n\n private async callOpenRouter(prompt: string): Promise<string> {\n const response = await fetch(OPENROUTER_API_URL, {\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${this.config.token}`,\n 'HTTP-Referer': 'https://github.com/testudosrl/tst-libs',\n 'X-Title': 'tst-changelog',\n },\n body: JSON.stringify({\n model: this.config.model,\n messages: [\n { role: 'system', content: this.config.prompt ?? '' },\n { role: 'user', content: prompt },\n ],\n temperature: 0.3,\n max_tokens: 1000,\n }),\n });\n\n if (!response.ok) {\n const error = await response.text();\n throw new Error(`OpenRouter API error: ${response.status} - ${error}`);\n }\n\n const data = (await response.json()) as OpenRouterResponse;\n return data.choices[0]?.message?.content ?? '';\n }\n\n private parseResponse(response: string): GeneratedChangelog {\n try {\n // Extract JSON from response (handle markdown code blocks or raw JSON)\n let jsonStr = response;\n\n // Try markdown code block first\n const codeBlockMatch = response.match(/```(?:json)?\\s*([\\s\\S]*?)```/);\n if (codeBlockMatch) {\n jsonStr = codeBlockMatch[1];\n } else {\n // Try to find JSON object in the response\n const jsonObjectMatch = response.match(/\\{[\\s\\S]*\"sections\"[\\s\\S]*\\}/);\n if (jsonObjectMatch) {\n jsonStr = jsonObjectMatch[0];\n }\n }\n\n const parsed = JSON.parse(jsonStr.trim()) as { sections: ChangelogSection[] };\n\n // Validate and normalize sections\n const validTypes: ChangeType[] = ['Added', 'Changed', 'Deprecated', 'Removed', 'Fixed', 'Security'];\n const sections = parsed.sections\n .filter((s) => validTypes.includes(s.type))\n .map((s) => ({\n type: s.type,\n items: Array.isArray(s.items) ? s.items.filter((i) => typeof i === 'string') : [],\n }))\n .filter((s) => s.items.length > 0);\n\n return {\n raw: response,\n sections,\n };\n } catch (error) {\n console.error('Failed to parse AI response:', error);\n console.error('Raw response:', response);\n return {\n raw: response,\n sections: [],\n };\n }\n }\n}\n","import { readFileSync, writeFileSync, existsSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport type { ChangelogConfig, ChangelogSection, GeneratedChangelog, ChangelogMetadata } from './types.js';\n\nconst KEEPACHANGELOG_HEADER = `# Changelog\n\nAll notable changes to this project will be documented in this file.\n\nThe format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),\nand this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n\n`;\n\nconst SECTION_ORDER = ['Added', 'Changed', 'Deprecated', 'Removed', 'Fixed', 'Security'] as const;\n\nexport class ChangelogService {\n private config: ChangelogConfig;\n private filePath: string;\n\n constructor(config: ChangelogConfig, cwd?: string) {\n this.config = config;\n this.filePath = resolve(cwd ?? process.cwd(), config.file);\n }\n\n /**\n * Read existing changelog content\n */\n read(): string | null {\n if (!existsSync(this.filePath)) {\n return null;\n }\n return readFileSync(this.filePath, 'utf-8');\n }\n\n /**\n * Generate new changelog entry\n */\n formatEntry(generated: GeneratedChangelog, version?: string, metadata?: ChangelogMetadata): string {\n const versionStr = version ?? 'Unreleased';\n const headerParts: string[] = [`## [${versionStr}]`];\n\n // Date and time\n if (this.config.includeDate) {\n const now = metadata?.timestamp ?? new Date();\n let dateStr = now.toISOString().split('T')[0];\n if (this.config.includeTime) {\n const timeStr = now.toTimeString().split(' ')[0].slice(0, 5); // HH:MM\n dateStr += ` ${timeStr}`;\n }\n headerParts.push(`- ${dateStr}`);\n }\n\n // Author\n if (this.config.includeAuthor && metadata?.author) {\n headerParts.push(`by ${metadata.author}`);\n }\n\n // Commit link\n if (this.config.includeCommitLink && metadata?.commitHash) {\n const shortHash = metadata.commitHash.slice(0, 7);\n if (this.config.repoUrl) {\n const commitUrl = `${this.config.repoUrl.replace(/\\/$/, '')}/commit/${metadata.commitHash}`;\n headerParts.push(`([${shortHash}](${commitUrl}))`);\n } else {\n headerParts.push(`(${shortHash})`);\n }\n }\n\n const headerLine = headerParts.join(' ');\n\n const sections = this.sortSections(generated.sections);\n const sectionLines = sections\n .map((section) => this.formatSection(section))\n .join('\\n\\n');\n\n return `${headerLine}\\n\\n${sectionLines}`;\n }\n\n private sortSections(sections: ChangelogSection[]): ChangelogSection[] {\n return [...sections].sort((a, b) => {\n const indexA = SECTION_ORDER.indexOf(a.type as typeof SECTION_ORDER[number]);\n const indexB = SECTION_ORDER.indexOf(b.type as typeof SECTION_ORDER[number]);\n return indexA - indexB;\n });\n }\n\n private formatSection(section: ChangelogSection): string {\n const items = section.items.map((item) => `- ${item}`).join('\\n');\n return `### ${section.type}\\n\\n${items}`;\n }\n\n /**\n * Update or create changelog with new entry\n */\n update(generated: GeneratedChangelog, version?: string, metadata?: ChangelogMetadata): string {\n const existing = this.read();\n\n if (!existing) {\n // Create new changelog\n const newEntry = this.formatEntry(generated, version, metadata);\n return KEEPACHANGELOG_HEADER + newEntry + '\\n';\n }\n\n // Find where to insert new entry (after header, before first version)\n const lines = existing.split('\\n');\n let insertIndex = -1;\n\n // Look for ## [Unreleased] or first ## [ section\n for (let i = 0; i < lines.length; i++) {\n const line = lines[i];\n if (line.startsWith('## [Unreleased]')) {\n // Merge with existing unreleased section\n const endIndex = this.findSectionEnd(lines, i + 1);\n const existingSectionLines = lines.slice(i, endIndex);\n const mergedSection = this.mergeUnreleasedSection(existingSectionLines, generated, metadata);\n const before = lines.slice(0, i).join('\\n');\n const after = lines.slice(endIndex).join('\\n');\n return before + (before.endsWith('\\n') ? '' : '\\n') + mergedSection + '\\n' + after;\n }\n if (line.startsWith('## [') && insertIndex === -1) {\n insertIndex = i;\n break;\n }\n }\n\n const newEntry = this.formatEntry(generated, version, metadata);\n\n if (insertIndex === -1) {\n // No version sections found, append after header\n return existing.trimEnd() + '\\n\\n' + newEntry + '\\n';\n }\n\n // Insert before first version\n const before = lines.slice(0, insertIndex).join('\\n');\n const after = lines.slice(insertIndex).join('\\n');\n return before + (before.endsWith('\\n') ? '' : '\\n') + newEntry + '\\n\\n' + after;\n }\n\n /**\n * Merge new entries into existing Unreleased section\n */\n private mergeUnreleasedSection(\n existingLines: string[],\n generated: GeneratedChangelog,\n metadata?: ChangelogMetadata\n ): string {\n // Parse existing sections\n const existingSections: Map<string, string[]> = new Map();\n let currentSection: string | null = null;\n\n for (const line of existingLines) {\n if (line.startsWith('### ')) {\n currentSection = line.slice(4).trim();\n if (!existingSections.has(currentSection)) {\n existingSections.set(currentSection, []);\n }\n } else if (currentSection && line.startsWith('- ')) {\n existingSections.get(currentSection)!.push(line.slice(2));\n }\n }\n\n // Merge new sections\n for (const section of generated.sections) {\n const existing = existingSections.get(section.type) ?? [];\n // Add new items that don't already exist\n for (const item of section.items) {\n if (!existing.includes(item)) {\n existing.push(item);\n }\n }\n existingSections.set(section.type, existing);\n }\n\n // Build merged entry\n const versionStr = 'Unreleased';\n const headerParts: string[] = [`## [${versionStr}]`];\n\n if (this.config.includeDate) {\n const now = metadata?.timestamp ?? new Date();\n let dateStr = now.toISOString().split('T')[0];\n if (this.config.includeTime) {\n const timeStr = now.toTimeString().split(' ')[0].slice(0, 5);\n dateStr += ` ${timeStr}`;\n }\n headerParts.push(`- ${dateStr}`);\n }\n\n if (this.config.includeAuthor && metadata?.author) {\n headerParts.push(`by ${metadata.author}`);\n }\n\n if (this.config.includeCommitLink && metadata?.commitHash) {\n const shortHash = metadata.commitHash.slice(0, 7);\n if (this.config.repoUrl) {\n const commitUrl = `${this.config.repoUrl.replace(/\\/$/, '')}/commit/${metadata.commitHash}`;\n headerParts.push(`([${shortHash}](${commitUrl}))`);\n } else {\n headerParts.push(`(${shortHash})`);\n }\n }\n\n const headerLine = headerParts.join(' ');\n\n // Sort and format sections\n const sortedSections: ChangelogSection[] = [];\n for (const type of SECTION_ORDER) {\n const items = existingSections.get(type);\n if (items && items.length > 0) {\n sortedSections.push({ type, items });\n }\n }\n\n const sectionLines = sortedSections\n .map((section) => this.formatSection(section))\n .join('\\n\\n');\n\n return `${headerLine}\\n\\n${sectionLines}`;\n }\n\n private findSectionEnd(lines: string[], startIndex: number): number {\n for (let i = startIndex; i < lines.length; i++) {\n if (lines[i].startsWith('## [')) {\n return i;\n }\n }\n return lines.length;\n }\n\n /**\n * Write changelog to file\n */\n write(content: string): void {\n writeFileSync(this.filePath, content, 'utf-8');\n }\n\n /**\n * Get the file path\n */\n getFilePath(): string {\n return this.filePath;\n }\n}\n"],"mappings":";;;AAAA,OAAO;AACP,SAAS,eAAe;;;ACDxB,SAAS,cAAc,YAAY,eAAe,sBAAsB;AACxE,SAAS,eAAe;AACxB,SAAS,OAAO,iBAAiB;AAGjC,IAAM,iBAAiB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA4BvB,IAAM,iBAAyB;AAAA,EAC7B,IAAI;AAAA,IACF,UAAU;AAAA,IACV,OAAO;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,EACV;AAAA,EACA,WAAW;AAAA,IACT,MAA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ACtE,QAAI,WAAW,iBAAiB,OAAO;AACrC,cAAQ,MAAM,MAAM,KAAK;AAAA,IAC3B;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AACF;AAEA,QAAQ,MAAM;","names":["readFileSync","writeFileSync","existsSync","resolve","newEntry","before","after"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tst-changelog",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "AI-powered changelog generator using OpenRouter",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -18,14 +18,15 @@
|
|
|
18
18
|
"dist"
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"
|
|
21
|
+
"commander": "^12.1.0",
|
|
22
|
+
"dotenv": "^17.2.3",
|
|
22
23
|
"simple-git": "^3.27.0",
|
|
23
|
-
"
|
|
24
|
+
"yaml": "^2.7.0"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
|
-
"
|
|
27
|
+
"@types/node": "^20.17.14",
|
|
27
28
|
"tsup": "^8.3.5",
|
|
28
|
-
"
|
|
29
|
+
"typescript": "^5.7.3"
|
|
29
30
|
},
|
|
30
31
|
"keywords": [
|
|
31
32
|
"changelog",
|