Files
msd-core/scripts/changeset/github-release-notes.cjs
Tom Boucher 334a64168e chore(npm): rebrand packages to @opengsd scope (#127)
* chore(npm): rebrand packages to @opengsd scope

Rename:
- get-shit-done-redux → @opengsd/get-shit-done-redux
- @gsd-redux/sdk → @opengsd/gsd-sdk

Add publishConfig.access=public for first-time scoped publish.
CLI binary names (get-shit-done-redux, gsd-sdk, gsd-tools) unchanged.

Sweeps install commands, npx invocations, CI publish/version-check
workflows, tests, docs, READMEs (all translations), and the
PACKAGE_NAME constant in check-latest-version.

Bumps qs 6.15.1 → 6.15.2 to clear a moderate advisory surfaced by
the audit-clean test (GHSA-q8mj-m7cp-5q26).

Closes #126

* chore: pin 2.0.0 release + remove canary workflow

- Bump both packages 1.50.0-canary.0 → 2.0.0 for first @opengsd publish
- Remove .github/workflows/canary.yml and canary dist-tag handling in
  release.yml / release-sdk.yml
- Drop canary section from VERSIONING.md

Refs #126

* chore: address review findings + harden tarball-smoke timeout

- .changeset/opengsd-org-rename.md: match project's custom
  parse.cjs frontmatter (type: Changed / pr: 127); the scoped
  @changesets/cli keys were silently rejected.
- CONTEXT.md: drop two canary-stream policy lines and a dangling
  DEFECT.CANARY-VERSION-LEAK.cross-ref now that canary.yml is gone.
- tests/release-tarball-smoke.install.test.cjs: pass
  timeout: 600_000 for npm pack + global install; the 3-minute
  runNpm default was timing out on slower Docker hosts (cartographer).

Refs #126

* fix(sdk): add missing type/runtime devDependencies for build

prepublishOnly invokes tsc which couldn't resolve @types/node,
@types/ws, or synckit. They had been hoisted from root but were
not declared in sdk/'s own package.json — first publish from a
clean SDK tree failed.

Refs #126

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* fix(ci): use npm pack stdout instead of glob to find tarball

`npm pack --silent` for a scoped package (@opengsd/get-shit-done-redux)
produces `opengsd-get-shit-done-redux-*.tgz`, not `get-shit-done-redux-*.tgz`.
Capture the filename from stdout instead of a hardcoded glob so the step
works regardless of package name format.

Fixes smoke (ubuntu-latest, 22, false) CI failure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

* ci: treat workflow-file changes as test-skip eligible

`.github/workflows/install-smoke.yml` (and other workflow files)
were in neither `test.yml` paths nor `test-skip.yml` paths-ignore,
so neither workflow ran on a workflow-only commit — leaving the
required test-skip check perpetually missing.

Refs #126

* chore: reset version to 1.0.0 for first @opengsd publish

Nothing has been published yet under the @opengsd scope, so the
inaugural release uses 1.0.0 rather than 2.0.0. The "major bump"
in the changeset reflects the breaking install-command change for
users migrating from the prior unscoped `get-shit-done-redux`, not
a numeric continuation from a 1.x line under the new identity.

Refs #126

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 16:22:41 -04:00

199 lines
6.0 KiB
JavaScript

'use strict';
const cp = require('node:child_process');
const path = require('node:path');
const { parseFragment } = require('./parse.cjs');
const SECTION_ORDER = ['Fixed', 'Added', 'Changed', 'Deprecated', 'Removed', 'Security'];
const FIXED_GROUPS = [
{
title: 'Verification, update & review safety',
pattern: /\b(verifier|verification|verify|probe|probes|debt|tbd|fixme|xxx|detect-custom-files|review|summary|blocker|critical)\b/i,
},
{
title: 'State, planning & execution',
pattern: /\b(state|planning|planner|plan-phase|phase|roadmap|execute|executor|worktree|worktrees|resolve-model|init\.progress|model override|human_needed|ship preflight)\b/i,
},
{
title: 'Install & runtime conversion',
pattern: /\b(install|installer|runtime|windows|powershell|codex|gemini|antigravity|hook|hooks|gsd-sdk|sdk readiness|cjs|model-catalog|path|shim)\b/i,
},
];
const REMOVED_GROUPS = [
{
title: 'Intel updater',
pattern: /\b(intel|gsd-intel-updater|layout detection)\b/i,
},
];
function runGit(repo, args) {
return cp.execFileSync('git', args, {
cwd: repo,
encoding: 'utf8',
stdio: ['ignore', 'pipe', 'pipe'],
});
}
function validateGitRef({ repo, ref, label }) {
if (typeof ref !== 'string' || ref.trim() !== ref || ref.length === 0) {
throw new Error(`Invalid git ref for ${label}: expected a non-empty trimmed string`);
}
if (
ref.startsWith('-') ||
ref.includes('..') ||
ref.includes('//') ||
!/^[A-Za-z0-9._/-]+$/.test(ref)
) {
throw new Error(`Invalid git ref for ${label}: ${ref}`);
}
runGit(repo, ['rev-parse', '--verify', `${ref}^{commit}`]);
return ref;
}
function changedFragmentPaths({ repo, fromRef, toRef }) {
const from = validateGitRef({ repo, ref: fromRef, label: 'fromRef' });
const to = validateGitRef({ repo, ref: toRef, label: 'toRef' });
const out = runGit(repo, ['diff', '--name-only', `${from}..${to}`, '--', '.changeset']);
return out
.split(/\r?\n/)
.filter(Boolean)
.filter((file) => /^\.changeset\/[^/]+\.md$/.test(file));
}
function readFileAtRef({ repo, ref, file }) {
return runGit(repo, ['show', `${ref}:${file}`]);
}
function loadFragmentsFromRange({ repo, fromRef, toRef }) {
const files = changedFragmentPaths({ repo, fromRef, toRef });
const fragments = [];
const failures = [];
for (const file of files) {
try {
const src = readFileAtRef({ repo, ref: toRef, file });
const parsed = parseFragment(src);
if (parsed.ok) {
fragments.push({
...parsed.fragment,
file,
slug: path.basename(file, '.md'),
});
} else {
failures.push({ file, reason: parsed.reason, detail: parsed.detail || null });
}
} catch (e) {
failures.push({ file, reason: 'read_failed', detail: e.message });
}
}
return { fragments, failures };
}
function classifyGroup(fragment) {
const haystack = `${fragment.slug || ''}\n${fragment.body || ''}`;
const groups = fragment.type === 'Removed' ? REMOVED_GROUPS : FIXED_GROUPS;
const match = groups.find((group) => group.pattern.test(haystack));
if (match) return match.title;
if (fragment.type === 'Removed') return 'Removed';
if (fragment.type === 'Fixed') return 'Other fixes';
return fragment.type;
}
function buildGithubReleaseNotesIr({ fragments }) {
const sections = [];
for (const type of SECTION_ORDER) {
const typed = fragments.filter((fragment) => fragment.type === type);
if (typed.length === 0) continue;
const groupMap = new Map();
for (const fragment of typed) {
const groupTitle = classifyGroup(fragment);
if (!groupMap.has(groupTitle)) groupMap.set(groupTitle, []);
groupMap.get(groupTitle).push(fragment);
}
sections.push({
type,
groups: Array.from(groupMap, ([title, bullets]) => ({ title, bullets })),
});
}
return { sections };
}
function formatBullet(fragment) {
if (!Number.isInteger(fragment.pr) || fragment.pr <= 0) {
throw new Error(`Fragment ${fragment.slug || fragment.file || '<unknown>'} missing valid pr field`);
}
const body = `${fragment.body.trim()} (#${fragment.pr})`;
const lines = body.split(/\r?\n/);
return lines.map((line, index) => (index === 0 ? `- ${line}` : ` ${line}`)).join('\n');
}
function compareUrl({ repoSlug, fromRef, toRef }) {
const normalizedSlug = String(repoSlug || '').trim();
if (!/^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/.test(normalizedSlug)) {
throw new Error(`Invalid repoSlug format: ${repoSlug} (expected "owner/repo")`);
}
return `https://github.com/${normalizedSlug}/compare/${fromRef}...${toRef}`;
}
function serializeGithubReleaseNotes({
ir,
fromRef,
toRef,
repoSlug = 'open-gsd/get-shit-done-redux',
installCommand = 'npx @opengsd/get-shit-done-redux@latest',
}) {
if (installCommand.includes('`')) {
throw new Error('installCommand cannot contain backtick characters');
}
const lines = [];
for (const section of ir.sections) {
lines.push(`## ${section.type}`);
lines.push('');
for (const group of section.groups) {
lines.push(`### ${group.title}`);
for (const bullet of group.bullets) {
lines.push(formatBullet(bullet));
}
lines.push('');
}
}
lines.push('---');
lines.push('');
lines.push(`Install/upgrade: \`${installCommand}\``);
lines.push('');
lines.push(`**Full Changelog**: ${compareUrl({ repoSlug, fromRef, toRef })}`);
lines.push('');
return lines.join('\n');
}
function renderGithubReleaseNotes(options) {
const { fragments, failures } = loadFragmentsFromRange(options);
if (failures.length > 0) {
return { ok: false, fragments, failures, body: null };
}
const ir = buildGithubReleaseNotesIr({ fragments });
return {
ok: true,
fragments,
failures: [],
ir,
body: serializeGithubReleaseNotes({ ir, ...options }),
};
}
module.exports = {
changedFragmentPaths,
loadFragmentsFromRange,
buildGithubReleaseNotesIr,
serializeGithubReleaseNotes,
renderGithubReleaseNotes,
classifyGroup,
validateGitRef,
};