refactor: hard-fork GSD -> MSD (Make Software Done)
Mechanical rename produced by scripts/msd-rename.cjs: gsd/Gsd/GSD -> msd/Msd/MSD across contents and paths, upstream package/repo coordinates -> @golem15/msd-core and golem15com/msd-core. Deep links into upstream history, sibling upstream packages, the GSD-2 import feature, CHANGELOG.md and .changeset/ are kept as-is. Hand edits on top: MSD block-letter banner and logos, LICENSE copyright line, package/plugin identity, regenerated lockfile, install-tree fixtures, derived registries and benchmark baseline; migration checksum baseline re-locked (MSD keeps its own install state, so no install had applied the old sums); sort-order and regex-escaped expectations in tests adjusted.
This commit is contained in:
@@ -2,15 +2,15 @@
|
||||
/**
|
||||
* sync-runtime-launcher.cjs
|
||||
*
|
||||
* Idempotent transform: for every gsd-core/workflows/*.md (and subdirs)
|
||||
* Idempotent transform: for every msd-core/workflows/*.md (and subdirs)
|
||||
* AND every agents/*.md, rewrite all bash/sh/shell fenced blocks to:
|
||||
* 1. Strip ALL old resolver forms from every bash block (GSD_TOOLS=,
|
||||
* GSD_SDK=, the if/elif/else/fi resolver, _GSD_SHIM_NAME=, and any
|
||||
* previously-inserted gsd_run preamble).
|
||||
* 2. Replace $GSD_SDK tokens with gsd_run (idempotent).
|
||||
* 1. Strip ALL old resolver forms from every bash block (MSD_TOOLS=,
|
||||
* MSD_SDK=, the if/elif/else/fi resolver, _MSD_SHIM_NAME=, and any
|
||||
* previously-inserted msd_run preamble).
|
||||
* 2. Replace $MSD_SDK tokens with msd_run (idempotent).
|
||||
* 3. Insert the canonical preamble at the TOP of ONLY the FIRST bash block
|
||||
* (document order) that contains a gsd_run call. All other bash blocks
|
||||
* keep their gsd_run calls with NO preamble. (Define once per file,
|
||||
* (document order) that contains a msd_run call. All other bash blocks
|
||||
* keep their msd_run calls with NO preamble. (Define once per file,
|
||||
* use across blocks — original footprint.)
|
||||
*
|
||||
* Run: node scripts/sync-runtime-launcher.cjs
|
||||
@@ -19,9 +19,9 @@
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
const { escapeRegex: escapeRegExp } = require('../gsd-core/bin/lib/pattern.cjs');
|
||||
const { escapeRegex: escapeRegExp } = require('../msd-core/bin/lib/pattern.cjs');
|
||||
|
||||
const WORKFLOWS_DIR = path.join(__dirname, '..', 'gsd-core', 'workflows');
|
||||
const WORKFLOWS_DIR = path.join(__dirname, '..', 'msd-core', 'workflows');
|
||||
const AGENTS_DIR = path.join(__dirname, '..', 'agents');
|
||||
const SNIPPET_FILE = path.join(WORKFLOWS_DIR, '_runtime-launcher.snippet.sh');
|
||||
|
||||
@@ -55,7 +55,7 @@ function collectFiles(dir) {
|
||||
|
||||
/**
|
||||
* Given the lines of a bash block (without fence markers), strip all resolver
|
||||
* boilerplate (old and new preamble forms) and replace $GSD_SDK tokens.
|
||||
* boilerplate (old and new preamble forms) and replace $MSD_SDK tokens.
|
||||
* Does NOT insert preamble — that is done by the file-level transform.
|
||||
*
|
||||
* Returns the stripped lines array.
|
||||
@@ -66,8 +66,8 @@ function stripAndReplace(lines, preamble) {
|
||||
// Step 1: Remove ALL resolver boilerplate lines (including existing preamble).
|
||||
result = removeResolverLines(result, preamble);
|
||||
|
||||
// Step 2: Replace $GSD_SDK tokens with gsd_run
|
||||
result = result.map((line) => replaceGsdSdk(line));
|
||||
// Step 2: Replace $MSD_SDK tokens with msd_run
|
||||
result = result.map((line) => replaceMsdSdk(line));
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -77,21 +77,21 @@ function stripAndReplace(lines, preamble) {
|
||||
*
|
||||
* Patterns to remove:
|
||||
* A) Multi-line if block:
|
||||
* GSD_TOOLS="...gsd-tools.cjs" (or ...${_GSD_SHIM_NAME})
|
||||
* if [ -f "$GSD_TOOLS" ]; then
|
||||
* MSD_TOOLS="...msd-tools.cjs" (or ...${_MSD_SHIM_NAME})
|
||||
* if [ -f "$MSD_TOOLS" ]; then
|
||||
* ...
|
||||
* fi
|
||||
*
|
||||
* B) One-liner form:
|
||||
* GSD_TOOLS=...; if [ -f "$GSD_TOOLS" ]; then GSD_SDK=...; elif ...; else ...; fi
|
||||
* MSD_TOOLS=...; if [ -f "$MSD_TOOLS" ]; then MSD_SDK=...; elif ...; else ...; fi
|
||||
*
|
||||
* C) _GSD_SHIM_NAME= line
|
||||
* C) _MSD_SHIM_NAME= line
|
||||
*
|
||||
* D) Bare GSD_SDK= line
|
||||
* D) Bare MSD_SDK= line
|
||||
*
|
||||
* E) The canonical preamble comment line (so we strip old inserted preambles too)
|
||||
*
|
||||
* F) The gsd_run() function definitions that are part of the preamble
|
||||
* F) The msd_run() function definitions that are part of the preamble
|
||||
* (so previously-inserted preambles are stripped and will be re-inserted
|
||||
* exactly once at the right location)
|
||||
*/
|
||||
@@ -103,10 +103,10 @@ function removeResolverLines(lines, preamble) {
|
||||
const line = lines[i];
|
||||
const trimmed = line.trim();
|
||||
|
||||
// B) One-liner form: GSD_TOOLS=... ; if ... GSD_SDK=... fi
|
||||
// B) One-liner form: MSD_TOOLS=... ; if ... MSD_SDK=... fi
|
||||
if (
|
||||
/^GSD_TOOLS=.*gsd-tools\.cjs.*;\s*if\s+\[/.test(trimmed) ||
|
||||
/^GSD_TOOLS=.*\/\$\{_GSD_SHIM_NAME\}.*;\s*if\s+\[/.test(trimmed)
|
||||
/^MSD_TOOLS=.*msd-tools\.cjs.*;\s*if\s+\[/.test(trimmed) ||
|
||||
/^MSD_TOOLS=.*\/\$\{_MSD_SHIM_NAME\}.*;\s*if\s+\[/.test(trimmed)
|
||||
) {
|
||||
// Skip the whole one-liner, and any adjacent SDK comment above it
|
||||
const lastIdx = result.length - 1;
|
||||
@@ -117,8 +117,8 @@ function removeResolverLines(lines, preamble) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// C) _GSD_SHIM_NAME= line
|
||||
if (/^_GSD_SHIM_NAME=/.test(trimmed)) {
|
||||
// C) _MSD_SHIM_NAME= line
|
||||
if (/^_MSD_SHIM_NAME=/.test(trimmed)) {
|
||||
// Check if there's a canonical preamble comment just before it
|
||||
const lastIdx = result.length - 1;
|
||||
if (lastIdx >= 0 && isCanonicalPreambleComment(result[lastIdx])) {
|
||||
@@ -130,10 +130,10 @@ function removeResolverLines(lines, preamble) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// A) Multi-line form: starts with GSD_TOOLS=...gsd-tools.cjs or GSD_TOOLS=...${_GSD_SHIM_NAME}
|
||||
// A) Multi-line form: starts with MSD_TOOLS=...msd-tools.cjs or MSD_TOOLS=...${_MSD_SHIM_NAME}
|
||||
if (
|
||||
/^GSD_TOOLS=.*gsd-tools\.cjs"$/.test(trimmed) ||
|
||||
/^GSD_TOOLS=.*\/\$\{_GSD_SHIM_NAME\}"$/.test(trimmed)
|
||||
/^MSD_TOOLS=.*msd-tools\.cjs"$/.test(trimmed) ||
|
||||
/^MSD_TOOLS=.*\/\$\{_MSD_SHIM_NAME\}"$/.test(trimmed)
|
||||
) {
|
||||
// Check if there's a canonical preamble comment just before it (preamble already installed)
|
||||
// or an old SDK comment — either way, remove the whole block
|
||||
@@ -144,9 +144,9 @@ function removeResolverLines(lines, preamble) {
|
||||
|
||||
// Consume the if block that follows (if it exists)
|
||||
const ahead = lines[i + 1] ? lines[i + 1].trim() : '';
|
||||
if (/^if\s+\[\s+-f\s+"\$GSD_TOOLS"\s*\]/.test(ahead)) {
|
||||
if (/^if\s+\[\s+-f\s+"\$MSD_TOOLS"\s*\]/.test(ahead)) {
|
||||
// Consume until matching `fi`
|
||||
i += 2; // skip GSD_TOOLS= and `if [...]`
|
||||
i += 2; // skip MSD_TOOLS= and `if [...]`
|
||||
let depth = 1;
|
||||
while (i < lines.length && depth > 0) {
|
||||
const t = lines[i].trim();
|
||||
@@ -166,21 +166,21 @@ function removeResolverLines(lines, preamble) {
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
// Just skip the GSD_TOOLS= line
|
||||
// Just skip the MSD_TOOLS= line
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// D) Bare GSD_SDK= line (not inside an if block, defensive)
|
||||
if (/^GSD_SDK=/.test(trimmed) && !/gsd_run/.test(trimmed)) {
|
||||
// D) Bare MSD_SDK= line (not inside an if block, defensive)
|
||||
if (/^MSD_SDK=/.test(trimmed) && !/msd_run/.test(trimmed)) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// E+F) Strip lines that are part of the canonical preamble (to remove previously-inserted preambles).
|
||||
// We match the canonical preamble comment, _GSD_SHIM_NAME (handled above at C),
|
||||
// and gsd_run() function definition lines.
|
||||
// We match the canonical preamble comment, _MSD_SHIM_NAME (handled above at C),
|
||||
// and msd_run() function definition lines.
|
||||
if (isCanonicalPreambleComment(trimmed.startsWith('#') ? line : '')) {
|
||||
// Start of a previously-inserted canonical preamble — skip preamble lines
|
||||
// by consuming lines that match the preamble array in order.
|
||||
@@ -221,7 +221,7 @@ function removeResolverLines(lines, preamble) {
|
||||
function isSdkComment(line) {
|
||||
// The new canonical preamble comment starts with "# Runtime launcher:" — preserve it.
|
||||
if (isCanonicalPreambleComment(line)) return false;
|
||||
return /^\s*#\s*SDK resolution/.test(line) || /^\s*#.*prefer local.*gsd-tools/.test(line);
|
||||
return /^\s*#\s*SDK resolution/.test(line) || /^\s*#.*prefer local.*msd-tools/.test(line);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,15 +229,15 @@ function isSdkComment(line) {
|
||||
* This identifies the start of the new multi-line canonical preamble.
|
||||
*/
|
||||
function isCanonicalPreambleComment(line) {
|
||||
return /^\s*#\s*Runtime launcher:.*prefer local gsd-tools\.cjs.*installed gsd-tools on PATH/.test(line);
|
||||
return /^\s*#\s*Runtime launcher:.*prefer local msd-tools\.cjs.*installed msd-tools on PATH/.test(line);
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace all $GSD_SDK tokens with gsd_run in a line.
|
||||
* Handles: $GSD_SDK, ${GSD_SDK} forms.
|
||||
* Replace all $MSD_SDK tokens with msd_run in a line.
|
||||
* Handles: $MSD_SDK, ${MSD_SDK} forms.
|
||||
*/
|
||||
function replaceGsdSdk(line) {
|
||||
return line.replace(/\$\{?GSD_SDK\}?(?=\s|$|;|"|'|\))/g, 'gsd_run');
|
||||
function replaceMsdSdk(line) {
|
||||
return line.replace(/\$\{?MSD_SDK\}?(?=\s|$|;|"|'|\))/g, 'msd_run');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -278,7 +278,7 @@ function insertPreamble(lines, preamble) {
|
||||
*
|
||||
* Strategy:
|
||||
* 1. Parse all shell blocks, strip resolver boilerplate from each.
|
||||
* 2. Find the FIRST block (document order) that has a gsd_run call.
|
||||
* 2. Find the FIRST block (document order) that has a msd_run call.
|
||||
* 3. Insert preamble into that block only.
|
||||
* 4. Reconstruct the file.
|
||||
*
|
||||
@@ -328,37 +328,37 @@ function transformFile(content, preamble) {
|
||||
|
||||
const outputLines = allLines.slice();
|
||||
let changed = false;
|
||||
let firstGsdRunBlockIdx = -1; // index into shellBlockRanges of the first gsd_run block (after strip)
|
||||
let firstMsdRunBlockIdx = -1; // index into shellBlockRanges of the first msd_run block (after strip)
|
||||
|
||||
// A file may place the preamble in a bootstrap-only block that defines
|
||||
// gsd_run without calling it (gsd-core/workflows/explore.md Step 1, which
|
||||
// documents exactly why). Stripping empties that block of gsd_run calls, so
|
||||
// a pure "first block that CALLS gsd_run" target silently relocates the
|
||||
// msd_run without calling it (msd-core/workflows/explore.md Step 1, which
|
||||
// documents exactly why). Stripping empties that block of msd_run calls, so
|
||||
// a pure "first block that CALLS msd_run" target silently relocates the
|
||||
// preamble forward and breaks define-before-use. Honour where it already is.
|
||||
const existingPreambleBlockIdx = shellBlockRanges.findIndex((range) =>
|
||||
allLines
|
||||
.slice(range.contentStart, range.contentEnd)
|
||||
.some((l) => /^\s*_GSD_SHIM_NAME=/.test(l)));
|
||||
.some((l) => /^\s*_MSD_SHIM_NAME=/.test(l)));
|
||||
|
||||
// First: strip + replace in all blocks, find first gsd_run block
|
||||
// First: strip + replace in all blocks, find first msd_run block
|
||||
const strippedBlocks = shellBlockRanges.map((range) => {
|
||||
const blockLines = outputLines.slice(range.contentStart, range.contentEnd);
|
||||
const stripped = stripAndReplace(blockLines, preamble);
|
||||
return stripped;
|
||||
});
|
||||
|
||||
// Find the first block that has a gsd_run call (after stripping)
|
||||
// Find the first block that has a msd_run call (after stripping)
|
||||
for (let bi = 0; bi < strippedBlocks.length; bi++) {
|
||||
if (strippedBlocks[bi].some((l) => /\bgsd_run\b/.test(l))) {
|
||||
firstGsdRunBlockIdx = bi;
|
||||
if (strippedBlocks[bi].some((l) => /\bmsd_run\b/.test(l))) {
|
||||
firstMsdRunBlockIdx = bi;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If the preamble already existed in a specific block before stripping,
|
||||
// keep it there (even if that block no longer calls gsd_run after
|
||||
// stripping). Otherwise fall back to the first gsd_run-calling block.
|
||||
const preambleTargetIdx = existingPreambleBlockIdx >= 0 ? existingPreambleBlockIdx : firstGsdRunBlockIdx;
|
||||
// keep it there (even if that block no longer calls msd_run after
|
||||
// stripping). Otherwise fall back to the first msd_run-calling block.
|
||||
const preambleTargetIdx = existingPreambleBlockIdx >= 0 ? existingPreambleBlockIdx : firstMsdRunBlockIdx;
|
||||
|
||||
// Insert preamble into the target block only — UNLESS this file
|
||||
// delegates to the shared resolver reference (@-include). Delegating files keep
|
||||
@@ -391,8 +391,8 @@ function transformFile(content, preamble) {
|
||||
}
|
||||
|
||||
/**
|
||||
* A file "delegates to the shared resolver" when it pulls the canonical gsd_run
|
||||
* preamble in from gsd-core/references/gsd-run-resolver.md via an @-include
|
||||
* A file "delegates to the shared resolver" when it pulls the canonical msd_run
|
||||
* preamble in from msd-core/references/msd-run-resolver.md via an @-include
|
||||
* instead of inlining the snippet (see onboard.md / issue #1990).
|
||||
*
|
||||
* These files must NOT carry an inline preamble: the resolver reference ships the
|
||||
@@ -402,7 +402,7 @@ function transformFile(content, preamble) {
|
||||
* runtime-launcher-parity.test.cjs (subtest B / B2).
|
||||
*/
|
||||
function delegatesToResolverReference(content) {
|
||||
return content.includes('references/gsd-run-resolver.md');
|
||||
return content.includes('references/msd-run-resolver.md');
|
||||
}
|
||||
|
||||
// Main
|
||||
|
||||
Reference in New Issue
Block a user