Skip to content

An AI-powered task-management system you can drop into Cursor, Lovable, Windsurf, Roo, and others.

feat: add changelog highlights to auto-update notifications (#1286)

Ralph Khreishf12a16d09649
diff --git a/.changeset/auto-update-changelog-highlights.md b/.changeset/auto-update-changelog-highlights.md
new file mode 100644
index 00000000..7cbc2d42
--- /dev/null
+++ b/.changeset/auto-update-changelog-highlights.md
@@ -0,0 +1,7 @@
+---
+"task-master-ai": minor
+---
+
+Add changelog highlights to auto-update notifications
+
+When the CLI auto-updates to a new version, it now displays a "What's New" section.
\ No newline at end of file
diff --git a/apps/cli/src/utils/auto-update.ts b/apps/cli/src/utils/auto-update.ts
index 3ad0f911..f62088c1 100644
--- a/apps/cli/src/utils/auto-update.ts
+++ b/apps/cli/src/utils/auto-update.ts
@@ -12,6 +12,7 @@ export interface UpdateInfo {
currentVersion: string;
latestVersion: string;
needsUpdate: boolean;
+ highlights?: string[];
}
/**
@@ -59,6 +60,116 @@ export function compareVersions(v1: string, v2: string): number {
return a.pre < b.pre ? -1 : 1; // basic prerelease tie-break
}
+/**
+ * Fetch CHANGELOG.md from GitHub and extract highlights for a specific version
+ */
+async function fetchChangelogHighlights(version: string): Promise<string[]> {
+ return new Promise((resolve) => {
+ const options = {
+ hostname: 'raw.githubusercontent.com',
+ path: '/eyaltoledano/claude-task-master/main/CHANGELOG.md',
+ method: 'GET',
+ headers: {
+ 'User-Agent': `task-master-ai/${version}`
+ }
+ };
+
+ const req = https.request(options, (res) => {
+ let data = '';
+
+ res.on('data', (chunk) => {
+ data += chunk;
+ });
+
+ res.on('end', () => {
+ try {
+ if (res.statusCode !== 200) {
+ resolve([]);
+ return;
+ }
+
+ const highlights = parseChangelogHighlights(data, version);
+ resolve(highlights);
+ } catch (error) {
+ resolve([]);
+ }
+ });
+ });
+
+ req.on('error', () => {
+ resolve([]);
+ });
+
+ req.setTimeout(3000, () => {
+ req.destroy();
+ resolve([]);
+ });
+
+ req.end();
+ });
+}
+
+/**
+ * Parse changelog markdown to extract Minor Changes for a specific version
+ * @internal - Exported for testing purposes only
+ */
+export function parseChangelogHighlights(
+ changelog: string,
+ version: string
+): string[] {
+ try {
+ // Validate version format (basic semver pattern) to prevent ReDoS
+ if (!/^\d+\.\d+\.\d+(-[a-zA-Z0-9.-]+)?$/.test(version)) {
+ return [];
+ }
+
+ // Find the version section
+ const versionRegex = new RegExp(
+ `## ${version.replace(/\./g, '\\.')}\\s*\\n`,
+ 'i'
+ );
+ const versionMatch = changelog.match(versionRegex);
+
+ if (!versionMatch) {
+ return [];
+ }
+
+ // Extract content from this version to the next version heading
+ const startIdx = versionMatch.index! + versionMatch[0].length;
+ const nextVersionIdx = changelog.indexOf('\n## ', startIdx);
+ const versionContent =
+ nextVersionIdx > 0
+ ? changelog.slice(startIdx, nextVersionIdx)
+ : changelog.slice(startIdx);
+
+ // Find Minor Changes section
+ const minorChangesMatch = versionContent.match(
+ /### Minor Changes\s*\n([\s\S]*?)(?=\n###|\n##|$)/i
+ );
+
+ if (!minorChangesMatch) {
+ return [];
+ }
+
+ const minorChangesContent = minorChangesMatch[1];
+ const highlights: string[] = [];
+
+ // Extract all bullet points (lines starting with -)
+ // Format: - [#PR](...) Thanks [@author]! - Description
+ const bulletRegex = /^-\s+\[#\d+\][^\n]*?!\s+-\s+(.+?)$/gm;
+ let match;
+
+ while ((match = bulletRegex.exec(minorChangesContent)) !== null) {
+ const desc = match[1].trim();
+ highlights.push(desc);
+ }
+
+ return highlights;
+ } catch (error) {
+ return [];
+ }
+}
+
/**
* Check for newer version of task-master-ai
*/
@@ -85,7 +196,7 @@ export async function checkForUpdate(
data += chunk;
});
- res.on('end', () => {
+ res.on('end', async () => {
try {
if (res.statusCode !== 200)
throw new Error(`npm registry status ${res.statusCode}`);
@@ -95,10 +206,17 @@ export async function checkForUpdate(
const needsUpdate =
compareVersions(currentVersion, latestVersion) < 0;
+ // Fetch highlights if update is needed
+ let highlights: string[] | undefined;
+ if (needsUpdate) {
+ highlights = await fetchChangelogHighlights(latestVersion);
+ }
+
resolve({
currentVersion,
latestVersion,
- needsUpdate
+ needsUpdate,
+ highlights
});
} catch (error) {
resolve({
@@ -136,18 +254,29 @@ export async function checkForUpdate(
*/
export function displayUpgradeNotification(
currentVersion: string,
- latestVersion: string
+ latestVersion: string,
+ highlights?: string[]
) {
- const message = boxen(
- `${chalk.blue.bold('Update Available!')} ${chalk.dim(currentVersion)} → ${chalk.green(latestVersion)}\n\n` +
- `Auto-updating to the latest version with new features and bug fixes...`,
- {
- padding: 1,
- margin: { top: 1, bottom: 1 },
- borderColor: 'yellow',
- borderStyle: 'round'
+ let content = `${chalk.blue.bold('Update Available!')} ${chalk.dim(currentVersion)} → ${chalk.green(latestVersion)}`;
+
+ if (highlights && highlights.length > 0) {
+ content += '\n\n' + chalk.bold("What's New:");
+ for (const highlight of highlights) {
+ content += '\n' + chalk.cyan('• ') + highlight;
}
- );
+ content += '\n\n' + 'Auto-updating to the latest version...';
+ } else {
+ content +=
+ '\n\n' +
+ 'Auto-updating to the latest version with new features and bug fixes...';
+ }
+
+ const message = boxen(content, {
+ padding: 1,
+ margin: { top: 1, bottom: 1 },
+ borderColor: 'yellow',
+ borderStyle: 'round'
+ });
console.log(message);
}
diff --git a/package.json b/package.json
index ad5866f6..fb2090fb 100644
--- a/package.json
+++ b/package.json
@@ -118,7 +118,13 @@
"bugs": {
"url": "https://github.com/eyaltoledano/claude-task-master/issues"
},
- "files": ["dist/**", "README-task-master.md", "README.md", "LICENSE"],
+ "files": [
+ "dist/**",
+ "README-task-master.md",
+ "README.md",
+ "LICENSE",
+ "CHANGELOG.md"
+ ],
"overrides": {
"node-fetch": "^2.6.12",
"whatwg-url": "^11.0.0"
diff --git a/scripts/modules/commands.js b/scripts/modules/commands.js
index f9a45f67..9d36315e 100644
--- a/scripts/modules/commands.js
+++ b/scripts/modules/commands.js
@@ -5111,7 +5111,8 @@ async function runCLI(argv = process.argv) {
// Display the upgrade notification first
displayUpgradeNotification(
updateInfo.currentVersion,
- updateInfo.latestVersion
+ updateInfo.latestVersion,
+ updateInfo.highlights
);
// Then automatically perform the update
diff --git a/tests/unit/commands.test.js b/tests/unit/commands.test.js
index 19a9abb4..d29292a3 100644
--- a/tests/unit/commands.test.js
+++ b/tests/unit/commands.test.js
@@ -279,12 +279,14 @@ describe('Version comparison utility', () => {
describe('Update check functionality', () => {
let displayUpgradeNotification;
+ let parseChangelogHighlights;
let consoleLogSpy;
beforeAll(async () => {
// Import from @tm/cli instead of commands.js
const cliModule = await import('../../apps/cli/src/utils/auto-update.js');
displayUpgradeNotification = cliModule.displayUpgradeNotification;
+ parseChangelogHighlights = cliModule.parseChangelogHighlights;
});
beforeEach(() => {
@@ -302,6 +304,61 @@ describe('Update check functionality', () => {
expect(consoleLogSpy.mock.calls[0][0]).toContain('1.0.0');
expect(consoleLogSpy.mock.calls[0][0]).toContain('1.1.0');
});
+
+ test('displays upgrade notification with highlights when provided', () => {
+ const highlights = [
+ 'Add Codex CLI provider with OAuth authentication',
+ 'Cursor IDE custom slash command support',
+ 'Move to AI SDK v5'
+ ];
+ displayUpgradeNotification('1.0.0', '1.1.0', highlights);
+ expect(consoleLogSpy).toHaveBeenCalled();
+ const output = consoleLogSpy.mock.calls[0][0];
+ expect(output).toContain('Update Available!');
+ expect(output).toContain('1.0.0');
+ expect(output).toContain('1.1.0');
+ expect(output).toContain("What's New:");
+ expect(output).toContain(
+ 'Add Codex CLI provider with OAuth authentication'
+ );
+ expect(output).toContain('Cursor IDE custom slash command support');
+ expect(output).toContain('Move to AI SDK v5');
+ });
+
+ test('displays upgrade notification without highlights section when empty array', () => {
+ displayUpgradeNotification('1.0.0', '1.1.0', []);
+ expect(consoleLogSpy).toHaveBeenCalled();
+ const output = consoleLogSpy.mock.calls[0][0];
+ expect(output).toContain('Update Available!');
+ expect(output).not.toContain("What's New:");
+ expect(output).toContain(
+ 'Auto-updating to the latest version with new features and bug fixes'
+ );
+ });
+
+ test('parseChangelogHighlights validates version format to prevent ReDoS', () => {
+ const mockChangelog = `
+## 1.0.0
+
+### Minor Changes
+
+- [#123](https://example.com) Thanks [@user](https://example.com)! - Test feature
+ `;
+
+ // Valid versions should work
+ expect(parseChangelogHighlights(mockChangelog, '1.0.0')).toEqual([
+ 'Test feature'
+ ]);
+ expect(parseChangelogHighlights(mockChangelog, '1.0.0-rc.1')).toEqual([]);
+
+ // Invalid versions should return empty array (ReDoS protection)
+ expect(parseChangelogHighlights(mockChangelog, 'invalid')).toEqual([]);
+ expect(parseChangelogHighlights(mockChangelog, '1.0')).toEqual([]);
+ expect(parseChangelogHighlights(mockChangelog, 'a.b.c')).toEqual([]);
+ expect(
+ parseChangelogHighlights(mockChangelog, '((((((((((((((((((((((((((((((a')
+ ).toEqual([]);
+ });
});
// -----------------------------------------------------------------------------