@bastani/atomic 0.8.1-0 → 0.8.1-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/CHANGELOG.md +6 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +6 -5
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/utils/changelog.d.ts +8 -6
- package/dist/utils/changelog.d.ts.map +1 -1
- package/dist/utils/changelog.js +75 -26
- package/dist/utils/changelog.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
export interface
|
|
1
|
+
export interface VersionParts {
|
|
2
2
|
major: number;
|
|
3
3
|
minor: number;
|
|
4
4
|
patch: number;
|
|
5
|
+
prerelease: number | null;
|
|
6
|
+
}
|
|
7
|
+
export interface ChangelogEntry extends VersionParts {
|
|
8
|
+
version: string;
|
|
5
9
|
content: string;
|
|
6
10
|
}
|
|
7
11
|
/**
|
|
@@ -12,10 +16,8 @@ export declare function parseChangelog(changelogPath: string): ChangelogEntry[];
|
|
|
12
16
|
/**
|
|
13
17
|
* Compare versions. Returns: -1 if v1 < v2, 0 if v1 === v2, 1 if v1 > v2
|
|
14
18
|
*/
|
|
15
|
-
export declare function compareVersions(v1:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
export declare function getNewEntries(entries: ChangelogEntry[], lastVersion: string): ChangelogEntry[];
|
|
19
|
+
export declare function compareVersions(v1: VersionParts, v2: VersionParts): number;
|
|
20
|
+
export declare function getNewEntries(entries: ChangelogEntry[], lastVersion: string, currentVersion?: string): ChangelogEntry[];
|
|
21
|
+
export declare function getEntriesForVersion(entries: ChangelogEntry[], version: string): ChangelogEntry[];
|
|
20
22
|
export { getChangelogPath } from "../config.js";
|
|
21
23
|
//# sourceMappingURL=changelog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changelog.d.ts","sourceRoot":"","sources":["../../src/utils/changelog.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"changelog.d.ts","sourceRoot":"","sources":["../../src/utils/changelog.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,YAAY;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,cAAe,SAAQ,YAAY;IACnD,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CAChB;AAqCD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,cAAc,EAAE,CA+CtE;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,YAAY,GAAG,MAAM,CAQ1E;AAiBD,wBAAgB,aAAa,CAC5B,OAAO,EAAE,cAAc,EAAE,EACzB,WAAW,EAAE,MAAM,EACnB,cAAc,CAAC,EAAE,MAAM,GACrB,cAAc,EAAE,CAgBlB;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,EAAE,CAIjG;AAGD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["import { existsSync, readFileSync } from \"fs\";\n\nexport interface VersionParts {\n\tmajor: number;\n\tminor: number;\n\tpatch: number;\n\tprerelease: number | null;\n}\n\nexport interface ChangelogEntry extends VersionParts {\n\tversion: string;\n\tcontent: string;\n}\n\nconst RELEASE_VERSION_RE = /^(?:v)?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-(0|[1-9]\\d*))?$/;\nconst CHANGELOG_VERSION_HEADER_RE = /^##\\s+\\[?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-(0|[1-9]\\d*))?\\]?/;\n\nfunction formatVersion(parts: VersionParts): string {\n\tconst base = `${parts.major}.${parts.minor}.${parts.patch}`;\n\treturn parts.prerelease === null ? base : `${base}-${parts.prerelease}`;\n}\n\nfunction partsFromMatch(match: RegExpMatchArray): VersionParts {\n\treturn {\n\t\tmajor: Number.parseInt(match[1] as string, 10),\n\t\tminor: Number.parseInt(match[2] as string, 10),\n\t\tpatch: Number.parseInt(match[3] as string, 10),\n\t\tprerelease: match[4] === undefined ? null : Number.parseInt(match[4], 10),\n\t};\n}\n\nfunction parseVersion(version: string): VersionParts | null {\n\tconst match = version.trim().match(RELEASE_VERSION_RE);\n\treturn match ? partsFromMatch(match) : null;\n}\n\nfunction parseVersionHeader(line: string): VersionParts | null {\n\tconst match = line.match(CHANGELOG_VERSION_HEADER_RE);\n\treturn match ? partsFromMatch(match) : null;\n}\n\nfunction createChangelogEntry(version: VersionParts, lines: string[]): ChangelogEntry {\n\treturn {\n\t\t...version,\n\t\tversion: formatVersion(version),\n\t\tcontent: lines.join(\"\\n\").trim(),\n\t};\n}\n\n/**\n * Parse changelog entries from CHANGELOG.md\n * Scans for ## lines and collects content until next ## or EOF\n */\nexport function parseChangelog(changelogPath: string): ChangelogEntry[] {\n\tif (!existsSync(changelogPath)) {\n\t\treturn [];\n\t}\n\n\ttry {\n\t\tconst content = readFileSync(changelogPath, \"utf-8\");\n\t\tconst lines = content.split(\"\\n\");\n\t\tconst entries: ChangelogEntry[] = [];\n\n\t\tlet currentLines: string[] = [];\n\t\tlet currentVersion: VersionParts | null = null;\n\n\t\tfor (const line of lines) {\n\t\t\t// Check if this is a version header (## [x.y.z] ...)\n\t\t\tif (line.startsWith(\"## \")) {\n\t\t\t\t// Save previous entry if exists\n\t\t\t\tif (currentVersion && currentLines.length > 0) {\n\t\t\t\t\tentries.push(createChangelogEntry(currentVersion, currentLines));\n\t\t\t\t}\n\n\t\t\t\t// Try to parse version from this line\n\t\t\t\tconst versionParts = parseVersionHeader(line);\n\t\t\t\tif (versionParts) {\n\t\t\t\t\tcurrentVersion = versionParts;\n\t\t\t\t\tcurrentLines = [line];\n\t\t\t\t} else {\n\t\t\t\t\t// Reset if we can't parse version\n\t\t\t\t\tcurrentVersion = null;\n\t\t\t\t\tcurrentLines = [];\n\t\t\t\t}\n\t\t\t} else if (currentVersion) {\n\t\t\t\t// Collect lines for current version\n\t\t\t\tcurrentLines.push(line);\n\t\t\t}\n\t\t}\n\n\t\t// Save last entry\n\t\tif (currentVersion && currentLines.length > 0) {\n\t\t\tentries.push(createChangelogEntry(currentVersion, currentLines));\n\t\t}\n\n\t\treturn entries;\n\t} catch (error) {\n\t\tconsole.error(`Warning: Could not parse changelog: ${error}`);\n\t\treturn [];\n\t}\n}\n\n/**\n * Compare versions. Returns: -1 if v1 < v2, 0 if v1 === v2, 1 if v1 > v2\n */\nexport function compareVersions(v1: VersionParts, v2: VersionParts): number {\n\tif (v1.major !== v2.major) return v1.major - v2.major;\n\tif (v1.minor !== v2.minor) return v1.minor - v2.minor;\n\tif (v1.patch !== v2.patch) return v1.patch - v2.patch;\n\tif (v1.prerelease === v2.prerelease) return 0;\n\tif (v1.prerelease === null) return 1;\n\tif (v2.prerelease === null) return -1;\n\treturn v1.prerelease - v2.prerelease;\n}\n\n/**\n * Get entries newer than lastVersion, optionally bounded by currentVersion.\n *\n * Atomic uses numeric prereleases (for example, 0.8.1-0) and started its own\n * version line above the upstream Pi changelog history. When currentVersion is\n * provided, changelog order wins over semantic version filtering so historical\n * upstream entries like 0.74.0 or an old 0.10.0 section are not treated as\n * newer Atomic releases.\n */\nfunction findVersionIndex(entries: ChangelogEntry[], version: string): number {\n\tconst target = parseVersion(version);\n\tif (!target) return -1;\n\treturn entries.findIndex((entry) => compareVersions(entry, target) === 0);\n}\n\nexport function getNewEntries(\n\tentries: ChangelogEntry[],\n\tlastVersion: string,\n\tcurrentVersion?: string,\n): ChangelogEntry[] {\n\tif (currentVersion) {\n\t\tconst currentIndex = findVersionIndex(entries, currentVersion);\n\t\tif (currentIndex === -1) return [];\n\n\t\tconst lastIndex = findVersionIndex(entries, lastVersion);\n\t\tif (lastIndex !== -1) {\n\t\t\treturn currentIndex < lastIndex ? entries.slice(currentIndex, lastIndex) : [];\n\t\t}\n\n\t\tconst currentEntry = entries[currentIndex];\n\t\treturn currentIndex === 0 && currentEntry ? [currentEntry] : [];\n\t}\n\n\tconst last = parseVersion(lastVersion) ?? { major: 0, minor: 0, patch: 0, prerelease: null };\n\treturn entries.filter((entry) => compareVersions(entry, last) > 0);\n}\n\nexport function getEntriesForVersion(entries: ChangelogEntry[], version: string): ChangelogEntry[] {\n\tconst target = parseVersion(version);\n\tif (!target) return [];\n\treturn entries.filter((entry) => compareVersions(entry, target) === 0);\n}\n\n// Re-export getChangelogPath from paths.ts for convenience\nexport { getChangelogPath } from \"../config.js\";\n"]}
|
package/dist/utils/changelog.js
CHANGED
|
@@ -1,4 +1,33 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "fs";
|
|
2
|
+
const RELEASE_VERSION_RE = /^(?:v)?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-(0|[1-9]\d*))?$/;
|
|
3
|
+
const CHANGELOG_VERSION_HEADER_RE = /^##\s+\[?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-(0|[1-9]\d*))?\]?/;
|
|
4
|
+
function formatVersion(parts) {
|
|
5
|
+
const base = `${parts.major}.${parts.minor}.${parts.patch}`;
|
|
6
|
+
return parts.prerelease === null ? base : `${base}-${parts.prerelease}`;
|
|
7
|
+
}
|
|
8
|
+
function partsFromMatch(match) {
|
|
9
|
+
return {
|
|
10
|
+
major: Number.parseInt(match[1], 10),
|
|
11
|
+
minor: Number.parseInt(match[2], 10),
|
|
12
|
+
patch: Number.parseInt(match[3], 10),
|
|
13
|
+
prerelease: match[4] === undefined ? null : Number.parseInt(match[4], 10),
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function parseVersion(version) {
|
|
17
|
+
const match = version.trim().match(RELEASE_VERSION_RE);
|
|
18
|
+
return match ? partsFromMatch(match) : null;
|
|
19
|
+
}
|
|
20
|
+
function parseVersionHeader(line) {
|
|
21
|
+
const match = line.match(CHANGELOG_VERSION_HEADER_RE);
|
|
22
|
+
return match ? partsFromMatch(match) : null;
|
|
23
|
+
}
|
|
24
|
+
function createChangelogEntry(version, lines) {
|
|
25
|
+
return {
|
|
26
|
+
...version,
|
|
27
|
+
version: formatVersion(version),
|
|
28
|
+
content: lines.join("\n").trim(),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
2
31
|
/**
|
|
3
32
|
* Parse changelog entries from CHANGELOG.md
|
|
4
33
|
* Scans for ## lines and collects content until next ## or EOF
|
|
@@ -18,19 +47,12 @@ export function parseChangelog(changelogPath) {
|
|
|
18
47
|
if (line.startsWith("## ")) {
|
|
19
48
|
// Save previous entry if exists
|
|
20
49
|
if (currentVersion && currentLines.length > 0) {
|
|
21
|
-
entries.push(
|
|
22
|
-
...currentVersion,
|
|
23
|
-
content: currentLines.join("\n").trim(),
|
|
24
|
-
});
|
|
50
|
+
entries.push(createChangelogEntry(currentVersion, currentLines));
|
|
25
51
|
}
|
|
26
52
|
// Try to parse version from this line
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
29
|
-
currentVersion =
|
|
30
|
-
major: Number.parseInt(versionMatch[1], 10),
|
|
31
|
-
minor: Number.parseInt(versionMatch[2], 10),
|
|
32
|
-
patch: Number.parseInt(versionMatch[3], 10),
|
|
33
|
-
};
|
|
53
|
+
const versionParts = parseVersionHeader(line);
|
|
54
|
+
if (versionParts) {
|
|
55
|
+
currentVersion = versionParts;
|
|
34
56
|
currentLines = [line];
|
|
35
57
|
}
|
|
36
58
|
else {
|
|
@@ -46,10 +68,7 @@ export function parseChangelog(changelogPath) {
|
|
|
46
68
|
}
|
|
47
69
|
// Save last entry
|
|
48
70
|
if (currentVersion && currentLines.length > 0) {
|
|
49
|
-
entries.push(
|
|
50
|
-
...currentVersion,
|
|
51
|
-
content: currentLines.join("\n").trim(),
|
|
52
|
-
});
|
|
71
|
+
entries.push(createChangelogEntry(currentVersion, currentLines));
|
|
53
72
|
}
|
|
54
73
|
return entries;
|
|
55
74
|
}
|
|
@@ -66,22 +85,52 @@ export function compareVersions(v1, v2) {
|
|
|
66
85
|
return v1.major - v2.major;
|
|
67
86
|
if (v1.minor !== v2.minor)
|
|
68
87
|
return v1.minor - v2.minor;
|
|
69
|
-
|
|
88
|
+
if (v1.patch !== v2.patch)
|
|
89
|
+
return v1.patch - v2.patch;
|
|
90
|
+
if (v1.prerelease === v2.prerelease)
|
|
91
|
+
return 0;
|
|
92
|
+
if (v1.prerelease === null)
|
|
93
|
+
return 1;
|
|
94
|
+
if (v2.prerelease === null)
|
|
95
|
+
return -1;
|
|
96
|
+
return v1.prerelease - v2.prerelease;
|
|
70
97
|
}
|
|
71
98
|
/**
|
|
72
|
-
* Get entries newer than lastVersion
|
|
99
|
+
* Get entries newer than lastVersion, optionally bounded by currentVersion.
|
|
100
|
+
*
|
|
101
|
+
* Atomic uses numeric prereleases (for example, 0.8.1-0) and started its own
|
|
102
|
+
* version line above the upstream Pi changelog history. When currentVersion is
|
|
103
|
+
* provided, changelog order wins over semantic version filtering so historical
|
|
104
|
+
* upstream entries like 0.74.0 or an old 0.10.0 section are not treated as
|
|
105
|
+
* newer Atomic releases.
|
|
73
106
|
*/
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
107
|
+
function findVersionIndex(entries, version) {
|
|
108
|
+
const target = parseVersion(version);
|
|
109
|
+
if (!target)
|
|
110
|
+
return -1;
|
|
111
|
+
return entries.findIndex((entry) => compareVersions(entry, target) === 0);
|
|
112
|
+
}
|
|
113
|
+
export function getNewEntries(entries, lastVersion, currentVersion) {
|
|
114
|
+
if (currentVersion) {
|
|
115
|
+
const currentIndex = findVersionIndex(entries, currentVersion);
|
|
116
|
+
if (currentIndex === -1)
|
|
117
|
+
return [];
|
|
118
|
+
const lastIndex = findVersionIndex(entries, lastVersion);
|
|
119
|
+
if (lastIndex !== -1) {
|
|
120
|
+
return currentIndex < lastIndex ? entries.slice(currentIndex, lastIndex) : [];
|
|
121
|
+
}
|
|
122
|
+
const currentEntry = entries[currentIndex];
|
|
123
|
+
return currentIndex === 0 && currentEntry ? [currentEntry] : [];
|
|
124
|
+
}
|
|
125
|
+
const last = parseVersion(lastVersion) ?? { major: 0, minor: 0, patch: 0, prerelease: null };
|
|
83
126
|
return entries.filter((entry) => compareVersions(entry, last) > 0);
|
|
84
127
|
}
|
|
128
|
+
export function getEntriesForVersion(entries, version) {
|
|
129
|
+
const target = parseVersion(version);
|
|
130
|
+
if (!target)
|
|
131
|
+
return [];
|
|
132
|
+
return entries.filter((entry) => compareVersions(entry, target) === 0);
|
|
133
|
+
}
|
|
85
134
|
// Re-export getChangelogPath from paths.ts for convenience
|
|
86
135
|
export { getChangelogPath } from "../config.js";
|
|
87
136
|
//# sourceMappingURL=changelog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"changelog.js","sourceRoot":"","sources":["../../src/utils/changelog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAS9C;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,aAAqB;IACnD,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;QAChC,OAAO,EAAE,CAAC;IACX,CAAC;IAED,IAAI,CAAC;QACJ,MAAM,OAAO,GAAG,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAA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AAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,2DAA2D;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["import { existsSync, readFileSync } from \"fs\";\n\nexport interface ChangelogEntry {\n\tmajor: number;\n\tminor: number;\n\tpatch: number;\n\tcontent: string;\n}\n\n/**\n * Parse changelog entries from CHANGELOG.md\n * Scans for ## lines and collects content until next ## or EOF\n */\nexport function parseChangelog(changelogPath: string): ChangelogEntry[] {\n\tif (!existsSync(changelogPath)) {\n\t\treturn [];\n\t}\n\n\ttry {\n\t\tconst content = readFileSync(changelogPath, \"utf-8\");\n\t\tconst lines = content.split(\"\\n\");\n\t\tconst entries: ChangelogEntry[] = [];\n\n\t\tlet currentLines: string[] = [];\n\t\tlet currentVersion: { major: number; minor: number; patch: number } | null = null;\n\n\t\tfor (const line of lines) {\n\t\t\t// Check if this is a version header (## [x.y.z] ...)\n\t\t\tif (line.startsWith(\"## \")) {\n\t\t\t\t// Save previous entry if exists\n\t\t\t\tif (currentVersion && currentLines.length > 0) {\n\t\t\t\t\tentries.push({\n\t\t\t\t\t\t...currentVersion,\n\t\t\t\t\t\tcontent: currentLines.join(\"\\n\").trim(),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// Try to parse version from this line\n\t\t\t\tconst versionMatch = line.match(/##\\s+\\[?(\\d+)\\.(\\d+)\\.(\\d+)\\]?/);\n\t\t\t\tif (versionMatch) {\n\t\t\t\t\tcurrentVersion = {\n\t\t\t\t\t\tmajor: Number.parseInt(versionMatch[1], 10),\n\t\t\t\t\t\tminor: Number.parseInt(versionMatch[2], 10),\n\t\t\t\t\t\tpatch: Number.parseInt(versionMatch[3], 10),\n\t\t\t\t\t};\n\t\t\t\t\tcurrentLines = [line];\n\t\t\t\t} else {\n\t\t\t\t\t// Reset if we can't parse version\n\t\t\t\t\tcurrentVersion = null;\n\t\t\t\t\tcurrentLines = [];\n\t\t\t\t}\n\t\t\t} else if (currentVersion) {\n\t\t\t\t// Collect lines for current version\n\t\t\t\tcurrentLines.push(line);\n\t\t\t}\n\t\t}\n\n\t\t// Save last entry\n\t\tif (currentVersion && currentLines.length > 0) {\n\t\t\tentries.push({\n\t\t\t\t...currentVersion,\n\t\t\t\tcontent: currentLines.join(\"\\n\").trim(),\n\t\t\t});\n\t\t}\n\n\t\treturn entries;\n\t} catch (error) {\n\t\tconsole.error(`Warning: Could not parse changelog: ${error}`);\n\t\treturn [];\n\t}\n}\n\n/**\n * Compare versions. Returns: -1 if v1 < v2, 0 if v1 === v2, 1 if v1 > v2\n */\nexport function compareVersions(v1: ChangelogEntry, v2: ChangelogEntry): number {\n\tif (v1.major !== v2.major) return v1.major - v2.major;\n\tif (v1.minor !== v2.minor) return v1.minor - v2.minor;\n\treturn v1.patch - v2.patch;\n}\n\n/**\n * Get entries newer than lastVersion\n */\nexport function getNewEntries(entries: ChangelogEntry[], lastVersion: string): ChangelogEntry[] {\n\t// Parse lastVersion\n\tconst parts = lastVersion.split(\".\").map(Number);\n\tconst last: ChangelogEntry = {\n\t\tmajor: parts[0] || 0,\n\t\tminor: parts[1] || 0,\n\t\tpatch: parts[2] || 0,\n\t\tcontent: \"\",\n\t};\n\n\treturn entries.filter((entry) => compareVersions(entry, last) > 0);\n}\n\n// Re-export getChangelogPath from paths.ts for convenience\nexport { getChangelogPath } from \"../config.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"changelog.js","sourceRoot":"","sources":["../../src/utils/changelog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAc9C,MAAM,kBAAkB,GAAG,oEAAoE,CAAC;AAChG,MAAM,2BAA2B,GAAG,wEAAwE,CAAC;AAE7G,SAAS,aAAa,CAAC,KAAmB;IACzC,MAAM,IAAI,GAAG,GAAG,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAA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AAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,eAAe,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AACxE,CAAC;AAED,2DAA2D;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC","sourcesContent":["import { existsSync, readFileSync } from \"fs\";\n\nexport interface VersionParts {\n\tmajor: number;\n\tminor: number;\n\tpatch: number;\n\tprerelease: number | null;\n}\n\nexport interface ChangelogEntry extends VersionParts {\n\tversion: string;\n\tcontent: string;\n}\n\nconst RELEASE_VERSION_RE = /^(?:v)?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-(0|[1-9]\\d*))?$/;\nconst CHANGELOG_VERSION_HEADER_RE = /^##\\s+\\[?(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-(0|[1-9]\\d*))?\\]?/;\n\nfunction formatVersion(parts: VersionParts): string {\n\tconst base = `${parts.major}.${parts.minor}.${parts.patch}`;\n\treturn parts.prerelease === null ? base : `${base}-${parts.prerelease}`;\n}\n\nfunction partsFromMatch(match: RegExpMatchArray): VersionParts {\n\treturn {\n\t\tmajor: Number.parseInt(match[1] as string, 10),\n\t\tminor: Number.parseInt(match[2] as string, 10),\n\t\tpatch: Number.parseInt(match[3] as string, 10),\n\t\tprerelease: match[4] === undefined ? null : Number.parseInt(match[4], 10),\n\t};\n}\n\nfunction parseVersion(version: string): VersionParts | null {\n\tconst match = version.trim().match(RELEASE_VERSION_RE);\n\treturn match ? partsFromMatch(match) : null;\n}\n\nfunction parseVersionHeader(line: string): VersionParts | null {\n\tconst match = line.match(CHANGELOG_VERSION_HEADER_RE);\n\treturn match ? partsFromMatch(match) : null;\n}\n\nfunction createChangelogEntry(version: VersionParts, lines: string[]): ChangelogEntry {\n\treturn {\n\t\t...version,\n\t\tversion: formatVersion(version),\n\t\tcontent: lines.join(\"\\n\").trim(),\n\t};\n}\n\n/**\n * Parse changelog entries from CHANGELOG.md\n * Scans for ## lines and collects content until next ## or EOF\n */\nexport function parseChangelog(changelogPath: string): ChangelogEntry[] {\n\tif (!existsSync(changelogPath)) {\n\t\treturn [];\n\t}\n\n\ttry {\n\t\tconst content = readFileSync(changelogPath, \"utf-8\");\n\t\tconst lines = content.split(\"\\n\");\n\t\tconst entries: ChangelogEntry[] = [];\n\n\t\tlet currentLines: string[] = [];\n\t\tlet currentVersion: VersionParts | null = null;\n\n\t\tfor (const line of lines) {\n\t\t\t// Check if this is a version header (## [x.y.z] ...)\n\t\t\tif (line.startsWith(\"## \")) {\n\t\t\t\t// Save previous entry if exists\n\t\t\t\tif (currentVersion && currentLines.length > 0) {\n\t\t\t\t\tentries.push(createChangelogEntry(currentVersion, currentLines));\n\t\t\t\t}\n\n\t\t\t\t// Try to parse version from this line\n\t\t\t\tconst versionParts = parseVersionHeader(line);\n\t\t\t\tif (versionParts) {\n\t\t\t\t\tcurrentVersion = versionParts;\n\t\t\t\t\tcurrentLines = [line];\n\t\t\t\t} else {\n\t\t\t\t\t// Reset if we can't parse version\n\t\t\t\t\tcurrentVersion = null;\n\t\t\t\t\tcurrentLines = [];\n\t\t\t\t}\n\t\t\t} else if (currentVersion) {\n\t\t\t\t// Collect lines for current version\n\t\t\t\tcurrentLines.push(line);\n\t\t\t}\n\t\t}\n\n\t\t// Save last entry\n\t\tif (currentVersion && currentLines.length > 0) {\n\t\t\tentries.push(createChangelogEntry(currentVersion, currentLines));\n\t\t}\n\n\t\treturn entries;\n\t} catch (error) {\n\t\tconsole.error(`Warning: Could not parse changelog: ${error}`);\n\t\treturn [];\n\t}\n}\n\n/**\n * Compare versions. Returns: -1 if v1 < v2, 0 if v1 === v2, 1 if v1 > v2\n */\nexport function compareVersions(v1: VersionParts, v2: VersionParts): number {\n\tif (v1.major !== v2.major) return v1.major - v2.major;\n\tif (v1.minor !== v2.minor) return v1.minor - v2.minor;\n\tif (v1.patch !== v2.patch) return v1.patch - v2.patch;\n\tif (v1.prerelease === v2.prerelease) return 0;\n\tif (v1.prerelease === null) return 1;\n\tif (v2.prerelease === null) return -1;\n\treturn v1.prerelease - v2.prerelease;\n}\n\n/**\n * Get entries newer than lastVersion, optionally bounded by currentVersion.\n *\n * Atomic uses numeric prereleases (for example, 0.8.1-0) and started its own\n * version line above the upstream Pi changelog history. When currentVersion is\n * provided, changelog order wins over semantic version filtering so historical\n * upstream entries like 0.74.0 or an old 0.10.0 section are not treated as\n * newer Atomic releases.\n */\nfunction findVersionIndex(entries: ChangelogEntry[], version: string): number {\n\tconst target = parseVersion(version);\n\tif (!target) return -1;\n\treturn entries.findIndex((entry) => compareVersions(entry, target) === 0);\n}\n\nexport function getNewEntries(\n\tentries: ChangelogEntry[],\n\tlastVersion: string,\n\tcurrentVersion?: string,\n): ChangelogEntry[] {\n\tif (currentVersion) {\n\t\tconst currentIndex = findVersionIndex(entries, currentVersion);\n\t\tif (currentIndex === -1) return [];\n\n\t\tconst lastIndex = findVersionIndex(entries, lastVersion);\n\t\tif (lastIndex !== -1) {\n\t\t\treturn currentIndex < lastIndex ? entries.slice(currentIndex, lastIndex) : [];\n\t\t}\n\n\t\tconst currentEntry = entries[currentIndex];\n\t\treturn currentIndex === 0 && currentEntry ? [currentEntry] : [];\n\t}\n\n\tconst last = parseVersion(lastVersion) ?? { major: 0, minor: 0, patch: 0, prerelease: null };\n\treturn entries.filter((entry) => compareVersions(entry, last) > 0);\n}\n\nexport function getEntriesForVersion(entries: ChangelogEntry[], version: string): ChangelogEntry[] {\n\tconst target = parseVersion(version);\n\tif (!target) return [];\n\treturn entries.filter((entry) => compareVersions(entry, target) === 0);\n}\n\n// Re-export getChangelogPath from paths.ts for convenience\nexport { getChangelogPath } from \"../config.js\";\n"]}
|