Some checks failed
Tests / PR mergeability (push) Successful in 1m37s
Tests / Base branch health (push) Successful in 11s
Tests / Detect test scope (push) Successful in 17s
Tests / lint-tests (push) Failing after 2m16s
Tests / plugin-validate (push) Successful in 1m6s
Tests / test (ubuntu-latest, 24, shard 1/3) (push) Failing after 25s
Tests / test (ubuntu-latest, 24, shard 2/3) (push) Failing after 20s
Tests / test (ubuntu-latest, 24, shard 3/3) (push) Failing after 20s
Tests / test (ubuntu-latest, 24) (push) Failing after 19s
Tests / test (inert CI) (push) Has been skipped
Tests / QA loop walk (smell ratchet) (push) Failing after 19s
Tests / Coverage gate (merged shards) (push) Has been skipped
Tests / Publish emitted-baseline artifact (push) Has been skipped
Dismiss Unauthorized PR Approvals / dismiss-unauthorized-approval (push) Successful in 9s
Close Draft PRs (sweep) / Sweep open draft PRs (push) Successful in 8s
Tests / conformance test (macos-latest, 24) (push) Has been cancelled
Tests / conformance test (windows-latest, 24, shard 1/3) (push) Has been cancelled
Tests / conformance test (windows-latest, 24, shard 2/3) (push) Has been cancelled
Tests / conformance test (windows-latest, 24, shard 3/3) (push) Has been cancelled
Tests / Required tests (push) Has been cancelled
The fork lives on the golem15 Gitea forge, not GitHub. Package identity now parses either host and derives in-place raw URLs for Gitea; the identity-drift lint accepts the new host; README drops GitHub-only badges and the npm quickstart in favour of the checkout installer.
278 lines
12 KiB
JavaScript
278 lines
12 KiB
JavaScript
'use strict';
|
|
process.env.MSD_TEST_MODE = '1';
|
|
|
|
// Issue #498: the drift-guard lint. Every MSD package/repo coordinate that
|
|
// appears as a literal anywhere in the runtime/code surface must equal the
|
|
// value the Package Identity seam derives from package.json. This is what
|
|
// makes a repoint a one-line change: rename package.json, regenerate the seam,
|
|
// and any stale literal fails CI until it is updated.
|
|
|
|
const { test, describe } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const path = require('node:path');
|
|
|
|
const ROOT = path.join(__dirname, '..');
|
|
const { findCoordinateDrift } = require(
|
|
path.join(ROOT, 'scripts', 'lint-package-identity-drift.cjs'),
|
|
);
|
|
|
|
const SEAM = { packageName: '@opengsd/get-shit-done-redux', repoSlug: 'open-gsd/get-shit-done-redux' };
|
|
|
|
describe('Issue #498: findCoordinateDrift (pure)', () => {
|
|
test('a correct package literal is not drift', () => {
|
|
const v = findCoordinateDrift('run npx -y @opengsd/get-shit-done-redux@latest', SEAM);
|
|
assert.deepEqual(v, []);
|
|
});
|
|
|
|
test('a stale package literal (post-rename) is flagged', () => {
|
|
const v = findCoordinateDrift('npx @opengsd/get-shit-done-classic@latest', SEAM);
|
|
assert.equal(v.length, 1);
|
|
assert.equal(v[0].found, '@opengsd/get-shit-done-classic');
|
|
assert.equal(v[0].expected, SEAM.packageName);
|
|
assert.equal(v[0].kind, 'package');
|
|
});
|
|
|
|
test('a different package (@opengsd/gsd-sdk) is NOT a msd-core coordinate', () => {
|
|
assert.deepEqual(findCoordinateDrift("require('@opengsd/gsd-sdk')", SEAM), []);
|
|
});
|
|
|
|
test('a correct github repo slug is not drift', () => {
|
|
const v = findCoordinateDrift('https://github.com/open-gsd/get-shit-done-redux/issues', SEAM);
|
|
assert.deepEqual(v, []);
|
|
});
|
|
|
|
test('a stale repo slug in a github url is flagged', () => {
|
|
const v = findCoordinateDrift('https://github.com/tches/get-shit-done-classic.git', SEAM);
|
|
assert.equal(v.length, 1);
|
|
assert.equal(v[0].kind, 'slug');
|
|
assert.equal(v[0].found, 'tches/get-shit-done-classic');
|
|
});
|
|
|
|
test('reports 1-based line numbers', () => {
|
|
const text = 'line1\nnpx @opengsd/get-shit-done-OLD@latest\nline3';
|
|
const v = findCoordinateDrift(text, SEAM);
|
|
assert.equal(v[0].line, 2);
|
|
});
|
|
});
|
|
|
|
describe('Issue #498: the live repo passes the drift lint', () => {
|
|
test('scanRepo finds zero drift against the current seam', () => {
|
|
const { scanRepo } = require(path.join(ROOT, 'scripts', 'lint-package-identity-drift.cjs'));
|
|
const violations = scanRepo(ROOT);
|
|
assert.deepEqual(
|
|
violations,
|
|
[],
|
|
'stale MSD coordinate literal(s) found:\n' +
|
|
violations.map((d) => ` ${d.file}:${d.line} ${d.kind} '${d.found}' != '${d.expected}'`).join('\n'),
|
|
);
|
|
});
|
|
});
|
|
|
|
|
|
// ────────────────────────────────────────────────────────────────────────
|
|
// Folded from tests/bug-170-workflow-fallback-install-hint.test.cjs — consolidation epic #1969 (B4 #1973)
|
|
// ────────────────────────────────────────────────────────────────────────
|
|
{
|
|
const { describe: __foldDescribe } = require('node:test');
|
|
__foldDescribe("folded:bug-170-workflow-fallback-install-hint (consolidation epic #1969 B4 #1973)", () => {
|
|
'use strict';
|
|
// allow-test-rule: source-text-is-the-product (see #170)
|
|
// Workflow markdown is shipped product text; this test validates fallback
|
|
// hint literals across all workflow files.
|
|
|
|
const { test } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
|
|
const WORKFLOWS_DIR = path.join(__dirname, '..', 'msd-core', 'workflows');
|
|
const LEGACY_HINT = 'npx get-shit-done-cc@latest --claude --local';
|
|
const CURRENT_HINT = 'npx -y @golem15/msd-core@latest --claude --local';
|
|
|
|
function findMarkdownFiles(dir) {
|
|
const out = [];
|
|
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
const full = path.join(dir, entry.name);
|
|
if (entry.isDirectory()) out.push(...findMarkdownFiles(full));
|
|
else if (entry.isFile() && full.endsWith('.md')) out.push(full);
|
|
}
|
|
return out;
|
|
}
|
|
|
|
test('bug #170: workflow fallback hints do not reference get-shit-done-cc', () => {
|
|
const files = findMarkdownFiles(WORKFLOWS_DIR);
|
|
let legacyCount = 0;
|
|
let currentCount = 0;
|
|
|
|
for (const file of files) {
|
|
const src = fs.readFileSync(file, 'utf8');
|
|
if (src.includes(LEGACY_HINT)) legacyCount += 1;
|
|
if (src.includes(CURRENT_HINT)) currentCount += 1;
|
|
}
|
|
|
|
assert.equal(
|
|
legacyCount,
|
|
0,
|
|
`workflow fallback hints must not reference legacy package (${LEGACY_HINT})`
|
|
);
|
|
assert.ok(
|
|
currentCount > 0,
|
|
`expected at least one workflow fallback hint to use current package (${CURRENT_HINT})`
|
|
);
|
|
});
|
|
});
|
|
}
|
|
|
|
|
|
// ────────────────────────────────────────────────────────────────────────
|
|
// Folded from tests/issue-498-package-identity.test.cjs — H3 Wave 5 (#3337)
|
|
// ────────────────────────────────────────────────────────────────────────
|
|
{
|
|
const { describe: __foldDescribe } = require('node:test');
|
|
__foldDescribe('folded:issue-498-package-identity (H3 Wave 5 #3337)', () => {
|
|
'use strict';
|
|
// Issue #498: single Package Identity seam.
|
|
// The package coordinates (npm name, bin name, repo slug, changelog URL) are
|
|
// DERIVED from package.json, not re-typed. deriveIdentity is the pure core;
|
|
// the generated runtime module msd-core/bin/lib/package-identity.cjs
|
|
// bakes those values at build time so it survives the install layout, where no
|
|
// package.json carries a .name — the only ones MSD stages are synthetic
|
|
// {"type":"commonjs"} markers, and since #2544 those live in MSD's own
|
|
// directories (hooks/, the native plugin dir) rather than the config root.
|
|
|
|
const { test, describe } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const path = require('node:path');
|
|
|
|
const ROOT = path.join(__dirname, '..');
|
|
const { deriveIdentity, formatManualInstall, slugifyPackageName } = require(
|
|
path.join(ROOT, 'scripts', 'generate-package-identity.cjs'),
|
|
);
|
|
const GENERATED = path.join(ROOT, 'msd-core', 'bin', 'lib', 'package-identity.cjs');
|
|
|
|
describe('Issue #498: deriveIdentity (pure, package.json -> coordinates)', () => {
|
|
const FAKE_PKG = {
|
|
name: '@scope/example-pkg',
|
|
bin: { 'example-pkg': 'bin/install.js', 'extra-tool': 'x.cjs' },
|
|
repository: { type: 'git', url: 'git+https://github.com/acme/example-pkg.git' },
|
|
};
|
|
|
|
test('packageName is package.json .name', () => {
|
|
assert.equal(deriveIdentity(FAKE_PKG).packageName, '@scope/example-pkg');
|
|
});
|
|
|
|
test('binName is the FIRST bin key (primary launcher)', () => {
|
|
assert.equal(deriveIdentity(FAKE_PKG).binName, 'example-pkg');
|
|
});
|
|
|
|
test('repoSlug is owner/name parsed from repository.url (git+ and .git stripped)', () => {
|
|
assert.equal(deriveIdentity(FAKE_PKG).repoSlug, 'acme/example-pkg');
|
|
});
|
|
|
|
test('repoUrl is the cleaned https github url', () => {
|
|
assert.equal(deriveIdentity(FAKE_PKG).repoUrl, 'https://github.com/acme/example-pkg');
|
|
});
|
|
|
|
test('a git.golem15.com repository yields in-place raw URLs on the next branch', () => {
|
|
const id = deriveIdentity({ ...FAKE_PKG, repository: 'git+https://git.golem15.com/golem15/msd-core.git' });
|
|
assert.equal(id.repoSlug, 'golem15/msd-core');
|
|
assert.equal(id.repoUrl, 'https://git.golem15.com/golem15/msd-core');
|
|
assert.equal(id.changelogRawUrl, 'https://git.golem15.com/golem15/msd-core/raw/branch/next/CHANGELOG.md');
|
|
});
|
|
|
|
test('changelogRawUrl points at raw.githubusercontent main CHANGELOG', () => {
|
|
assert.equal(
|
|
deriveIdentity(FAKE_PKG).changelogRawUrl,
|
|
'https://raw.githubusercontent.com/acme/example-pkg/main/CHANGELOG.md',
|
|
);
|
|
});
|
|
|
|
test('derives the real MSD coordinates from the repo package.json', () => {
|
|
const real = require(path.join(ROOT, 'package.json'));
|
|
const id = deriveIdentity(real);
|
|
assert.equal(id.packageName, '@golem15/msd-core');
|
|
assert.equal(id.binName, 'msd-core');
|
|
assert.equal(id.repoSlug, 'golem15/msd-core');
|
|
});
|
|
|
|
test('deriveIdentity returns cacheSlug for @golem15/msd-core', () => {
|
|
const real = require(path.join(ROOT, 'package.json'));
|
|
const id = deriveIdentity(real);
|
|
assert.equal(id.cacheSlug, 'golem15-msd-core');
|
|
});
|
|
|
|
test('deriveIdentity returns updateCacheFileName for @golem15/msd-core', () => {
|
|
const real = require(path.join(ROOT, 'package.json'));
|
|
const id = deriveIdentity(real);
|
|
assert.equal(id.updateCacheFileName, 'msd-update-check-golem15-msd-core.json');
|
|
});
|
|
});
|
|
|
|
describe('Issue #498: slugifyPackageName (pure helper for cache filename)', () => {
|
|
test('slugifyPackageName strips leading @, replaces / with -, for @golem15/msd-core', () => {
|
|
assert.equal(slugifyPackageName('@golem15/msd-core'), 'golem15-msd-core');
|
|
});
|
|
|
|
test('slugifyPackageName returns empty string for empty input', () => {
|
|
assert.equal(slugifyPackageName(''), '');
|
|
});
|
|
});
|
|
|
|
describe('Issue #498: formatManualInstall (the npx fallback command)', () => {
|
|
test('global scope, no runtime -> npx with --global only', () => {
|
|
assert.equal(
|
|
formatManualInstall({ packageName: '@scope/example-pkg', binName: 'example-pkg', scope: 'global' }),
|
|
'npx -y --package=@scope/example-pkg@latest -- example-pkg --global',
|
|
);
|
|
});
|
|
|
|
test('local scope with runtime -> --<runtime> before --<scope>', () => {
|
|
assert.equal(
|
|
formatManualInstall({ packageName: '@scope/example-pkg', binName: 'example-pkg', scope: 'local', runtime: 'claude' }),
|
|
'npx -y --package=@scope/example-pkg@latest -- example-pkg --claude --local',
|
|
);
|
|
});
|
|
|
|
test('matches the literal update.md uses for the real package (global+claude)', () => {
|
|
const id = deriveIdentity(require(path.join(ROOT, 'package.json')));
|
|
assert.equal(
|
|
formatManualInstall({ packageName: id.packageName, binName: id.binName, scope: 'global', runtime: 'claude' }),
|
|
'npx -y --package=@golem15/msd-core@latest -- msd-core --claude --global',
|
|
);
|
|
});
|
|
});
|
|
|
|
describe('Issue #498: generated runtime module (baked)', () => {
|
|
// The committed-generated-file freshness guard moved to
|
|
// `npm run lint:generated-sync` (generate-package-identity.cjs --check), where
|
|
// it runs against the committed file in both local and CI lint lanes instead
|
|
// of being masked by msd-test's `npm run build` leg regenerating the artifact.
|
|
|
|
test('requiring the generated module exposes the real coordinates', () => {
|
|
const id = require(GENERATED);
|
|
assert.equal(id.packageName, '@golem15/msd-core');
|
|
assert.equal(id.binName, 'msd-core');
|
|
assert.equal(id.repoSlug, 'golem15/msd-core');
|
|
});
|
|
|
|
test('generated module exports cacheSlug matching @golem15/msd-core', () => {
|
|
const id = require(GENERATED);
|
|
assert.equal(id.cacheSlug, 'golem15-msd-core');
|
|
});
|
|
|
|
test('generated module exports updateCacheFileName matching @golem15/msd-core', () => {
|
|
const id = require(GENERATED);
|
|
assert.equal(id.updateCacheFileName, 'msd-update-check-golem15-msd-core.json');
|
|
});
|
|
|
|
test('generated manualInstallCommand closes over the baked coordinates', () => {
|
|
const id = require(GENERATED);
|
|
assert.equal(
|
|
id.manualInstallCommand({ scope: 'global', runtime: 'claude' }),
|
|
'npx -y --package=@golem15/msd-core@latest -- msd-core --claude --global',
|
|
);
|
|
});
|
|
});
|
|
});
|
|
}
|