release-with-ease 1.0.0 → 2.0.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/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 OpenAI to analyze commits.
4
+ notes. Uses Claude to analyze commits.
5
5
 
6
6
  # Usage
7
7
 
@@ -21,10 +21,18 @@ npx release-with-ease --dry-run
21
21
 
22
22
  The script requires these environment variables to be set:
23
23
 
24
- - `OPEN_AI_API_KEY`
24
+ - `ANTHROPIC_API_KEY`
25
25
 
26
- You can get a key from https://platform.openai.com/api-keys.
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
 
30
30
  # Changelog
31
+
32
+ ## 1.0.1
33
+
34
+ - Fix path to README and package.json
35
+
36
+ ## 1.0.0
37
+
38
+ - Initial release
@@ -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 OpenAI
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 OpenAI
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
- - OPENAI_API_KEY environment variable must be set
12
+ - ANTHROPIC_API_KEY environment variable must be set
13
13
 
14
14
  Usage:
15
15
  npx release-with-ease # Normal release
@@ -23,9 +23,8 @@ const readline = require('readline');
23
23
  const os = require('os');
24
24
  const crypto = require('crypto');
25
25
 
26
- const repoRoot = path.resolve(__dirname, '..');
27
- const readmePath = path.join(repoRoot, 'README.md');
28
- const packageJsonPath = path.join(repoRoot, 'package.json');
26
+ const readmePath = path.join(process.cwd(), 'README.md');
27
+ const packageJsonPath = path.join(process.cwd(), 'package.json');
29
28
 
30
29
  function run(cmd, opts = {}) {
31
30
  return execSync(cmd, { stdio: 'pipe', encoding: 'utf8', ...opts });
@@ -75,55 +74,50 @@ function parseCommits(raw) {
75
74
  });
76
75
  }
77
76
 
78
- async function askOpenAIForRelease(commits) {
79
- const apiKey = process.env.OPENAI_API_KEY;
77
+ async function askClaudeForRelease(commits) {
78
+ const apiKey = process.env.ANTHROPIC_API_KEY;
80
79
  if (!apiKey) return null;
81
- const messages = [
82
- {
83
- role: 'system',
84
- content:
85
- '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.',
86
- },
87
- {
88
- role: 'user',
89
- content: commits
90
- .map(c => `- ${c.subject}\n${c.body ? c.body.trim() : ''}`)
91
- .join('\n'),
92
- },
93
- ];
94
80
 
95
- const res = await fetch('https://api.openai.com/v1/chat/completions', {
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', {
96
89
  method: 'POST',
97
90
  headers: {
98
- Authorization: `Bearer ${apiKey}`,
91
+ 'x-api-key': apiKey,
92
+ 'anthropic-version': '2023-06-01',
99
93
  'Content-Type': 'application/json',
100
94
  },
101
95
  body: JSON.stringify({
102
- model: 'gpt-4o-mini',
103
- messages,
104
- temperature: 0.2,
96
+ model: 'claude-haiku-4-5',
105
97
  max_tokens: 500,
98
+ temperature: 0.2,
99
+ system: systemPrompt,
100
+ messages: [{ role: 'user', content: userContent }],
106
101
  }),
107
102
  });
108
103
  if (!res.ok) {
109
- // throw an actionable error here
110
104
  console.error(await res.text());
111
105
  throw new Error(
112
106
  `Failed to determine version bump: ${res.statusText} ${res.status}`,
113
107
  );
114
108
  }
115
109
  const data = await res.json();
116
- const content = (data.choices?.[0]?.message?.content || '').trim();
110
+ const content = (data.content?.[0]?.text || '').trim();
117
111
 
118
112
  const parsed = JSON.parse(content);
119
113
  if (!parsed.bump || !['major', 'minor', 'patch'].includes(parsed.bump)) {
120
- throw new Error('Invalid bump value in OpenAI response');
114
+ throw new Error('Invalid bump value in Claude response');
121
115
  }
122
116
  if (!parsed.reasoning) {
123
- throw new Error('Missing reasoning in OpenAI response');
117
+ throw new Error('Missing reasoning in Claude response');
124
118
  }
125
119
  if (!parsed.notes || !Array.isArray(parsed.notes)) {
126
- throw new Error('Missing or invalid notes array in OpenAI response');
120
+ throw new Error('Missing or invalid notes array in Claude response');
127
121
  }
128
122
 
129
123
  return {
@@ -189,13 +183,13 @@ function parseArgs() {
189
183
  const { dryRun } = parseArgs();
190
184
 
191
185
  // Check for required environment variable early
192
- if (!process.env.OPENAI_API_KEY) {
193
- console.error('❌ OPENAI_API_KEY environment variable is required.');
186
+ if (!process.env.ANTHROPIC_API_KEY) {
187
+ console.error('❌ ANTHROPIC_API_KEY environment variable is required.');
194
188
  console.error(
195
- ' You can get one from https://platform.openai.com/api-keys',
189
+ ' You can get one from https://console.anthropic.com/settings/keys',
196
190
  );
197
191
  console.error(
198
- ' Please add it to your .env file: OPENAI_API_KEY=your_key_here',
192
+ ' Please add it to your .env file: ANTHROPIC_API_KEY=your_key_here',
199
193
  );
200
194
  process.exit(1);
201
195
  }
@@ -223,9 +217,9 @@ function parseArgs() {
223
217
  console.log(` ${shortSha} ${commit.subject}`);
224
218
  });
225
219
 
226
- console.log('\nWaiting for OpenAI to analyze commits...');
220
+ console.log('\nWaiting for Claude to analyze commits...');
227
221
 
228
- const result = await askOpenAIForRelease(commits);
222
+ const result = await askClaudeForRelease(commits);
229
223
 
230
224
  const { bump, reasoning, notes } = result;
231
225
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "release-with-ease",
3
- "version": "1.0.0",
4
- "description": "A script to bump the version of an npm library and update release notes. Uses OpenAI to analyze commits.",
3
+ "version": "2.0.0",
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
- "openai",
18
+ "claude",
19
+ "anthropic",
19
20
  "semver",
20
21
  "bump",
21
22
  "ai"