release-with-ease 1.0.1 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/bin/release-with-ease.js +30 -34
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# release-with-ease
|
|
2
2
|
|
|
3
3
|
A script that helps you bump the version of an npm library and update release
|
|
4
|
-
notes. Uses
|
|
4
|
+
notes. Uses Claude to analyze commits.
|
|
5
5
|
|
|
6
6
|
# Usage
|
|
7
7
|
|
|
@@ -21,9 +21,9 @@ npx release-with-ease --dry-run
|
|
|
21
21
|
|
|
22
22
|
The script requires these environment variables to be set:
|
|
23
23
|
|
|
24
|
-
- `
|
|
24
|
+
- `ANTHROPIC_API_KEY`
|
|
25
25
|
|
|
26
|
-
You can get a key from https://
|
|
26
|
+
You can get a key from https://console.anthropic.com/settings/keys.
|
|
27
27
|
|
|
28
28
|
The script also assumes that your README.md file has a `# Changelog` section.
|
|
29
29
|
|
package/bin/release-with-ease.js
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
/*
|
|
3
3
|
Release helper script
|
|
4
4
|
|
|
5
|
-
- Analyzes git history and suggests semver bump (major/minor/patch) using
|
|
5
|
+
- Analyzes git history and suggests semver bump (major/minor/patch) using Claude
|
|
6
6
|
- Prompts for confirmation or choice override
|
|
7
|
-
- Generates concise release notes using
|
|
7
|
+
- Generates concise release notes using Claude
|
|
8
8
|
- Inserts a new entry at the top of the Changelog in README.md
|
|
9
9
|
- Commits changelog update, bumps version via npm, and pushes with tags
|
|
10
10
|
|
|
11
11
|
Requirements:
|
|
12
|
-
-
|
|
12
|
+
- ANTHROPIC_API_KEY environment variable must be set
|
|
13
13
|
|
|
14
14
|
Usage:
|
|
15
15
|
npx release-with-ease # Normal release
|
|
@@ -74,55 +74,51 @@ function parseCommits(raw) {
|
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
async function
|
|
78
|
-
const apiKey = process.env.
|
|
77
|
+
async function askClaudeForRelease(commits) {
|
|
78
|
+
const apiKey = process.env.ANTHROPIC_API_KEY;
|
|
79
79
|
if (!apiKey) return null;
|
|
80
|
-
const messages = [
|
|
81
|
-
{
|
|
82
|
-
role: 'system',
|
|
83
|
-
content:
|
|
84
|
-
'You are a release assistant. Given recent git commits, decide one of: major, minor, or patch following semver. Consider conventional commits, breaking changes, and scope. Also generate concise release notes for a public changelog. Respond with JSON containing "bump" (major/minor/patch), "reasoning" (brief explanation for version bump), and "notes" (array of 3-8 short bullet points of the most important user-facing changes). Use present tense for release notes (e.g. "Add script" not "Added script" or "Adds script"). Do not wrap the JSON in ```json or anything else.',
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
role: 'user',
|
|
88
|
-
content: commits
|
|
89
|
-
.map(c => `- ${c.subject}\n${c.body ? c.body.trim() : ''}`)
|
|
90
|
-
.join('\n'),
|
|
91
|
-
},
|
|
92
|
-
];
|
|
93
80
|
|
|
94
|
-
const
|
|
81
|
+
const systemPrompt =
|
|
82
|
+
'You are a release assistant. Given recent git commits, decide one of: major, minor, or patch following semver. Consider conventional commits, breaking changes, and scope. Also generate concise release notes for a public changelog. Respond with JSON containing "bump" (major/minor/patch), "reasoning" (brief explanation for version bump), and "notes" (array of 3-8 short bullet points of the most important user-facing changes). Use present tense for release notes (e.g. "Add script" not "Added script" or "Adds script"). Do not wrap the JSON in ```json or anything else.';
|
|
83
|
+
|
|
84
|
+
const userContent = commits
|
|
85
|
+
.map(c => `- ${c.subject}\n${c.body ? c.body.trim() : ''}`)
|
|
86
|
+
.join('\n');
|
|
87
|
+
|
|
88
|
+
const res = await fetch('https://api.anthropic.com/v1/messages', {
|
|
95
89
|
method: 'POST',
|
|
96
90
|
headers: {
|
|
97
|
-
|
|
91
|
+
'x-api-key': apiKey,
|
|
92
|
+
'anthropic-version': '2023-06-01',
|
|
98
93
|
'Content-Type': 'application/json',
|
|
99
94
|
},
|
|
100
95
|
body: JSON.stringify({
|
|
101
|
-
model: '
|
|
102
|
-
messages,
|
|
103
|
-
temperature: 0.2,
|
|
96
|
+
model: 'claude-haiku-4-5',
|
|
104
97
|
max_tokens: 500,
|
|
98
|
+
temperature: 0.2,
|
|
99
|
+
system: systemPrompt,
|
|
100
|
+
messages: [{ role: 'user', content: userContent }],
|
|
105
101
|
}),
|
|
106
102
|
});
|
|
107
103
|
if (!res.ok) {
|
|
108
|
-
// throw an actionable error here
|
|
109
104
|
console.error(await res.text());
|
|
110
105
|
throw new Error(
|
|
111
106
|
`Failed to determine version bump: ${res.statusText} ${res.status}`,
|
|
112
107
|
);
|
|
113
108
|
}
|
|
114
109
|
const data = await res.json();
|
|
115
|
-
const
|
|
110
|
+
const raw = (data.content?.[0]?.text || '').trim();
|
|
111
|
+
const content = raw.replace(/^```(?:json)?\s*\n?/, '').replace(/\n?```\s*$/, '');
|
|
116
112
|
|
|
117
113
|
const parsed = JSON.parse(content);
|
|
118
114
|
if (!parsed.bump || !['major', 'minor', 'patch'].includes(parsed.bump)) {
|
|
119
|
-
throw new Error('Invalid bump value in
|
|
115
|
+
throw new Error('Invalid bump value in Claude response');
|
|
120
116
|
}
|
|
121
117
|
if (!parsed.reasoning) {
|
|
122
|
-
throw new Error('Missing reasoning in
|
|
118
|
+
throw new Error('Missing reasoning in Claude response');
|
|
123
119
|
}
|
|
124
120
|
if (!parsed.notes || !Array.isArray(parsed.notes)) {
|
|
125
|
-
throw new Error('Missing or invalid notes array in
|
|
121
|
+
throw new Error('Missing or invalid notes array in Claude response');
|
|
126
122
|
}
|
|
127
123
|
|
|
128
124
|
return {
|
|
@@ -188,13 +184,13 @@ function parseArgs() {
|
|
|
188
184
|
const { dryRun } = parseArgs();
|
|
189
185
|
|
|
190
186
|
// Check for required environment variable early
|
|
191
|
-
if (!process.env.
|
|
192
|
-
console.error('❌
|
|
187
|
+
if (!process.env.ANTHROPIC_API_KEY) {
|
|
188
|
+
console.error('❌ ANTHROPIC_API_KEY environment variable is required.');
|
|
193
189
|
console.error(
|
|
194
|
-
' You can get one from https://
|
|
190
|
+
' You can get one from https://console.anthropic.com/settings/keys',
|
|
195
191
|
);
|
|
196
192
|
console.error(
|
|
197
|
-
' Please add it to your .env file:
|
|
193
|
+
' Please add it to your .env file: ANTHROPIC_API_KEY=your_key_here',
|
|
198
194
|
);
|
|
199
195
|
process.exit(1);
|
|
200
196
|
}
|
|
@@ -222,9 +218,9 @@ function parseArgs() {
|
|
|
222
218
|
console.log(` ${shortSha} ${commit.subject}`);
|
|
223
219
|
});
|
|
224
220
|
|
|
225
|
-
console.log('\nWaiting for
|
|
221
|
+
console.log('\nWaiting for Claude to analyze commits...');
|
|
226
222
|
|
|
227
|
-
const result = await
|
|
223
|
+
const result = await askClaudeForRelease(commits);
|
|
228
224
|
|
|
229
225
|
const { bump, reasoning, notes } = result;
|
|
230
226
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "release-with-ease",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "A script to bump the version of an npm library and update release notes. Uses
|
|
3
|
+
"version": "2.0.1",
|
|
4
|
+
"description": "A script to bump the version of an npm library and update release notes. Uses Claude to analyze commits.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"release-with-ease": "bin/release-with-ease.js"
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"release",
|
|
18
|
-
"
|
|
18
|
+
"claude",
|
|
19
|
+
"anthropic",
|
|
19
20
|
"semver",
|
|
20
21
|
"bump",
|
|
21
22
|
"ai"
|