Files
msd-core/tests/repo-layout.test.cjs
Jakub Zych 6cfa0c55d2 refactor: drop 12 runtimes, keep Claude, Codex, OpenCode, Cursor, ZCode, Antigravity
Removes kilo, kimi, kimi-code, copilot, windsurf, augment, trae, qwen, hermes,
cline, codebuddy and pi end to end: capability descriptors, installer branches
and converters (bin/install.js 14.9k -> 11.2k lines), TypeScript converters,
hook surfaces and runtime homes, review lanes qwen/kimi-code, the two pi
migrations, Kimi payload normalization in the hook guards, dead hostBehaviors
vocabulary, launcher home probes, fixtures, runtime-specific tests and the
prose that presented them as supported.

Installer output for the six kept runtimes is byte-identical to before the
prune. The Kimi tool-vocabulary tests in workflow-guard, read-guard and
read-injection-scanner are left in place pending a decision.
2026-10-06 20:02:40 +02:00

125 lines
5.5 KiB
JavaScript

'use strict';
/**
* Governance tests for the msd-core repository root layout.
*
* Invariant: the repository root must not contain ad-hoc AI instruction files
* (such as AGENTS.md) that would become an untracked source of truth running
* in parallel with the canonical CONTEXT.md and docs/adr/ records.
*
* Context: historically bin/install.js (the since-retired local Copilot install
* path, issue #786) wrote an AGENTS.md to process.cwd() when run inside a repo
* checkout. If such a file is ever committed, editors and AI tools that auto-load
* repo-root instruction files will silently pick up an installer-generated
* stub rather than the authoritative documentation. This test ensures that
* artefact never lands in source control.
*/
const test = require('node:test');
const assert = require('node:assert/strict');
const path = require('path');
const { runGit } = require('./helpers/process-seam.cjs');
const { GIT_TIMEOUT_MS } = require('./helpers/timeouts.cjs');
const ROOT = path.resolve(__dirname, '..');
test('repo-layout: root AGENTS.md is not git-tracked — no ad-hoc AI instruction file committed alongside CONTEXT.md', () => {
// An installer-generated AGENTS.md may exist on disk after a local install
// (historically the Copilot path, issue #786). What must NOT happen is
// committing it to git, where editors and AI tools would silently pick up
// the installer-generated stub instead of CONTEXT.md.
const r = runGit(['ls-files', '--error-unmatch', 'AGENTS.md'], {
cwd: ROOT, timeoutMs: GIT_TIMEOUT_MS,
});
const tracked = r.exitCode === 0;
assert.equal(
tracked,
false,
[
'root AGENTS.md must not be git-tracked.',
'Installer-generated instruction stubs (historically issue #786) may land on disk',
'when the installer runs inside a repo checkout — their presence on disk is fine,',
'but they must never be committed.',
'The repository source of truth for architecture and contributor guidance is',
'CONTEXT.md and docs/adr/ — not an installer-generated instruction stub.',
'Run `git rm --cached AGENTS.md` to untrack it if accidentally staged.',
].join(' '),
);
});
// ────────────────────────────────────────────────────────────────────────
// Folded from tests/enh-191-retire-sdk-package.test.cjs — consolidation epic #1969 (B5 #1974)
// ────────────────────────────────────────────────────────────────────────
{
const { describe: __foldDescribe } = require('node:test');
__foldDescribe("folded:enh-191-retire-sdk-package (consolidation epic #1969 B5 #1974)", () => {
'use strict';
const test = require('node:test');
const assert = require('node:assert/strict');
const fs = require('fs');
const path = require('path');
const ROOT = path.resolve(__dirname, '..');
const PKG_PATH = path.join(ROOT, 'package.json');
const INSTALL_PATH = path.join(ROOT, 'bin', 'install.js');
const ACTIVE_GUIDANCE_PATHS = [
'docs/contributing/bootstrap.md',
];
function readPackageJson() {
return JSON.parse(fs.readFileSync(PKG_PATH, 'utf8'));
}
test('enhancement #191: sdk package artifacts are removed from repository layout', () => {
const sdkDir = path.join(ROOT, 'sdk');
const shimPath = path.join(ROOT, 'bin', 'msd-sdk.js');
assert.equal(fs.existsSync(sdkDir), false, 'sdk/ directory must be deleted');
assert.equal(fs.existsSync(shimPath), false, 'bin/msd-sdk.js must be deleted');
});
test('enhancement #191: published package no longer exposes msd-sdk artifacts', () => {
const pkg = readPackageJson();
assert.equal(Object.prototype.hasOwnProperty.call(pkg.bin || {}, 'msd-sdk'), false,
'package.json bin must not expose msd-sdk');
assert.equal(pkg.bin && pkg.bin['msd-tools'], 'msd-core/bin/msd-tools.cjs',
'package.json bin.msd-tools must point to msd-core/bin/msd-tools.cjs');
const publishedFiles = Array.isArray(pkg.files) ? pkg.files : [];
const hasSdkPublishedPaths = publishedFiles.some((entry) => String(entry).startsWith('sdk'));
assert.equal(hasSdkPublishedPaths, false,
'package.json files must not include sdk artifacts');
});
test('enhancement #191: installer does not maintain msd-sdk shim compatibility path', () => {
// allow-test-rule: structural-regression-guard (#3545) — asserting the
// ABSENCE of a retired flag/function reference from install.js is a source
// structure fact (dead-code regression), not something observable by
// exercising the installer's runtime behavior.
const installJs = fs.readFileSync(INSTALL_PATH, 'utf8');
assert.equal(/\b--sdk\b/.test(installJs), false,
'bin/install.js must not expose --sdk flag');
assert.equal(/\b--no-sdk\b/.test(installJs), false,
'bin/install.js must not expose --no-sdk flag');
assert.equal(/installSdkIfNeeded\(\{/.test(installJs), false,
'bin/install.js must not run installSdkIfNeeded during installation');
});
test('enhancement #191: active contributor guidance does not reference retired SDK build steps', () => {
for (const relPath of ACTIVE_GUIDANCE_PATHS) {
const body = fs.readFileSync(path.join(ROOT, relPath), 'utf8');
assert.equal(
/\bbuild:sdk\b|\bcd sdk\b|\bsdk\/dist\b|\bsdk\/src\b/.test(body),
false,
`${relPath} must not direct contributors or agents to use the retired SDK package workflow`,
);
}
});
});
}