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:
@@ -6,10 +6,10 @@
|
||||
// Why this copy exists: hooks/ runs straight from a raw, unbuilt clone — a
|
||||
// shipped hook must be able to `require('./lib/cli-exit.js')` relative to
|
||||
// its own __dirname and terminate through `terminateNow` without depending
|
||||
// on any build artifact. gsd-core/bin/lib/cli-exit.cjs is gitignored tsc
|
||||
// on any build artifact. msd-core/bin/lib/cli-exit.cjs is gitignored tsc
|
||||
// output and doubles as the build sentinel, so it cannot be required from
|
||||
// here. `.js`, not `.cjs`, to match the hooks/lib/*.js convention. Hence one
|
||||
// source, three emitted locations (gsd-core/bin/lib, scripts/lib, hooks/lib).
|
||||
// source, three emitted locations (msd-core/bin/lib, scripts/lib, hooks/lib).
|
||||
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
@@ -20,7 +20,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
* json-error-mode and contract-version cells.
|
||||
*
|
||||
* Must import nothing but `node:fs` and `./exit-code-registry.cjs` — this
|
||||
* source is emitted to TWO locations, gsd-core/bin/lib/cli-exit.cjs (tsc
|
||||
* source is emitted to TWO locations, msd-core/bin/lib/cli-exit.cjs (tsc
|
||||
* build output) and scripts/lib/cli-exit.cjs (a generated, committed
|
||||
* artifact regenerated by scripts/gen-scripts-cli-exit.cjs), and the latter
|
||||
* must load on an unbuilt clone before anything under ./lib exists. The
|
||||
@@ -50,19 +50,19 @@ const exitCodeFor = (name) => exitCodeRegistryModule.exitCodeFor(name);
|
||||
const EXIT_ENVELOPE_REASON = 'sdk_fail_fast';
|
||||
/**
|
||||
* Process-level flag: when true, error paths emit structured JSON to stderr
|
||||
* instead of plain text. Set by gsd-tools.cjs when the CLI is invoked with
|
||||
* instead of plain text. Set by msd-tools.cjs when the CLI is invoked with
|
||||
* `--json-errors`; re-exported by io.cts, which is where most callers reach it.
|
||||
*
|
||||
* Held in a Symbol-keyed cell on globalThis rather than in module scope, and
|
||||
* that is load-bearing: this module is emitted to TWO locations
|
||||
* (gsd-core/bin/lib/cli-exit.cjs and the generated scripts/lib/cli-exit.cjs),
|
||||
* (msd-core/bin/lib/cli-exit.cjs and the generated scripts/lib/cli-exit.cjs),
|
||||
* so a process that loads both would get two independent module instances. A
|
||||
* module-level `let` would give them two independent flags — one copy could
|
||||
* think json mode is on while the other thought it was off, which is exactly
|
||||
* the divergence class ADR-3889 exists to remove. One cell, keyed by a
|
||||
* registry Symbol, makes that unrepresentable.
|
||||
*/
|
||||
const JSON_ERROR_MODE_KEY = Symbol.for('gsd.exit.jsonErrorMode');
|
||||
const JSON_ERROR_MODE_KEY = Symbol.for('msd.exit.jsonErrorMode');
|
||||
function setJsonErrorMode(v) {
|
||||
globalThis[JSON_ERROR_MODE_KEY] = !!v;
|
||||
}
|
||||
@@ -82,7 +82,7 @@ const HOOK_DENY_CODE = exitCodeFor(HOOK_DENY_NAME);
|
||||
* `resolveContractVersion` is the only writer; `terminateNow`/`runMain`
|
||||
* read it internally when projecting a declared outcome.
|
||||
*/
|
||||
const CONTRACT_VERSION_KEY = Symbol.for('gsd.exit.contractVersion');
|
||||
const CONTRACT_VERSION_KEY = Symbol.for('msd.exit.contractVersion');
|
||||
function setContractVersion(v) {
|
||||
globalThis[CONTRACT_VERSION_KEY] = v;
|
||||
}
|
||||
@@ -90,12 +90,12 @@ function setContractVersion(v) {
|
||||
* Resolve the active exit-contract version, wiring the ambient process to the
|
||||
* two terminators (ADR-3889 §4/§3). Mirrors how JSON_ERROR_MODE_KEY already
|
||||
* works: a process-global cell means no entrypoint needs per-call wiring, so
|
||||
* a `scripts/` tool or a hook gets the same behaviour as `gsd-tools` without
|
||||
* this module touching either (P8 owns `gsd-tools`; P7 owns hooks).
|
||||
* a `scripts/` tool or a hook gets the same behaviour as `msd-tools` without
|
||||
* this module touching either (P8 owns `msd-tools`; P7 owns hooks).
|
||||
*
|
||||
* Precedence: if the cell already holds an explicit version, that wins —
|
||||
* this is what lets `setContractVersion` override the ambient process (a
|
||||
* later `GSD_EXIT_CONTRACT=v2` in the same process must NOT unseat an
|
||||
* later `MSD_EXIT_CONTRACT=v2` in the same process must NOT unseat an
|
||||
* explicit `setContractVersion('v1')` call). Otherwise resolve from argv/env
|
||||
* via `resolveContractVersion`, which itself persists the result into the
|
||||
* cell — so this is a one-time resolution per process; every later read is
|
||||
@@ -178,7 +178,7 @@ function projectOutcome(outcome, version) {
|
||||
* `main()` returning void would inherit a stale DEGRADED from an unrelated,
|
||||
* earlier call — this is the leak #3912 review found and fixed.
|
||||
*/
|
||||
const PENDING_OUTCOME_KEY = Symbol.for('gsd.exit.pendingOutcome');
|
||||
const PENDING_OUTCOME_KEY = Symbol.for('msd.exit.pendingOutcome');
|
||||
function setPendingOutcome(v) {
|
||||
globalThis[PENDING_OUTCOME_KEY] = v;
|
||||
}
|
||||
@@ -202,10 +202,10 @@ function findExitContractFlag(argv) {
|
||||
* against it without re-parsing argv/env itself.
|
||||
*
|
||||
* Precedence: an explicit `--exit-contract=<v>` flag BEATS
|
||||
* `GSD_EXIT_CONTRACT`, in both directions (flag=v1 + env=v2 -> v1; flag=v2 +
|
||||
* `MSD_EXIT_CONTRACT`, in both directions (flag=v1 + env=v2 -> v1; flag=v2 +
|
||||
* env=v1 -> v2). Neither present -> 'v1' (the documented default). An empty
|
||||
* env var reads as UNSET, not as an explicit empty selection — a shell that
|
||||
* exports `GSD_EXIT_CONTRACT=` with nothing after the `=` must not silently
|
||||
* exports `MSD_EXIT_CONTRACT=` with nothing after the `=` must not silently
|
||||
* select a version.
|
||||
*
|
||||
* Casing is decided, not accidental: only the exact lowercase tokens `v1`/
|
||||
@@ -220,7 +220,7 @@ function resolveContractVersion(opts = {}) {
|
||||
const argv = opts.argv ?? process.argv;
|
||||
const env = opts.env ?? process.env;
|
||||
const flagValue = findExitContractFlag(argv);
|
||||
const rawEnvValue = env.GSD_EXIT_CONTRACT;
|
||||
const rawEnvValue = env.MSD_EXIT_CONTRACT;
|
||||
const envValue = rawEnvValue === undefined || rawEnvValue === '' ? undefined : rawEnvValue;
|
||||
const selected = flagValue !== undefined ? flagValue : envValue;
|
||||
let resolved;
|
||||
@@ -406,7 +406,7 @@ function runMain(main) {
|
||||
* fd 2 gets the SAME serialized `payload` fd 1 got — unchanged behavior.
|
||||
* When provided, fd 2 gets THIS instead: a string is written raw
|
||||
* (verbatim, not JSON-stringified), anything else is JSON-stringified
|
||||
* like `payload`. This exists because `hooks/gsd-write-guard.js`'s
|
||||
* like `payload`. This exists because `hooks/msd-write-guard.js`'s
|
||||
* emitBlock does NOT write the same bytes to both streams today — it
|
||||
* writes the full JSON `output` to stdout but only the plain-text
|
||||
* `output.reason` STRING to stderr, because Kimi's native hook bus reads
|
||||
@@ -456,7 +456,7 @@ function terminateNow(outcome, payload, stderrPayload) {
|
||||
throw new Error(`terminateNow: exit code ${HOOK_DENY_CODE} is reserved to the ${HOOK_DENY_NAME} outcome; `
|
||||
+ `got outcome ${JSON.stringify(outcome)}`);
|
||||
}
|
||||
// m2 (round 5, hooks/gsd-write-guard.js:159-175): emission must itself be
|
||||
// m2 (round 5, hooks/msd-write-guard.js:159-175): emission must itself be
|
||||
// exception-safe. A failed write (EPIPE, a full pipe buffer, a throwing
|
||||
// fs.writeSync in a test) must NOT change the exit code — if it propagated
|
||||
// out of this function, a caller whose payload could not be delivered
|
||||
@@ -521,7 +521,7 @@ function terminateNow(outcome, payload, stderrPayload) {
|
||||
process.exit(projected);
|
||||
}
|
||||
catch (err) {
|
||||
// Anything above threw: an unrecognized --exit-contract/GSD_EXIT_CONTRACT
|
||||
// Anything above threw: an unrecognized --exit-contract/MSD_EXIT_CONTRACT
|
||||
// value, a non-string/empty/unregistered `outcome`, or the HOOK_DENY
|
||||
// collision guard. Diagnose on stderr — swallowing this silently would
|
||||
// make a typo'd outcome name or a bad contract-version env var
|
||||
|
||||
Reference in New Issue
Block a user