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.
96 lines
3.6 KiB
JavaScript
96 lines
3.6 KiB
JavaScript
// Phase 5 kimi-variant disambiguation is verified via install.js subprocess
|
|
// output capture (regex on printed notices), since disambiguateKimiVariant
|
|
// is inline in bin/install.js (not exported) and emits no structured/JSON
|
|
// output. Exporting the function and/or adding a --json notice mode is a
|
|
// production change out of scope here. Tracked under #3090.
|
|
process.env.MSD_TEST_MODE = '1';
|
|
|
|
const { test, describe, before, after } = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
const { spawnSync } = require('node:child_process');
|
|
const fs = require('node:fs');
|
|
const os = require('node:os');
|
|
const path = require('node:path');
|
|
const { cleanup } = require('./helpers.cjs');
|
|
const { PROBE_TIMEOUT_MS } = require('./helpers/timeouts.cjs');
|
|
|
|
const INSTALL_JS = path.join(__dirname, '..', 'bin', 'install.js');
|
|
|
|
function makeDisposableHome() {
|
|
const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'msd-kimi-disambig-'));
|
|
return {
|
|
dir,
|
|
cleanup() { cleanup(dir); },
|
|
};
|
|
}
|
|
|
|
function runInstall(args, home) {
|
|
// spawnSync captures stdout AND stderr separately regardless of exit code
|
|
// (execFileSync drops stderr on success, which hid the console.error warnings).
|
|
const r = spawnSync('node', [INSTALL_JS, ...args], {
|
|
env: { ...process.env, HOME: home, USERPROFILE: home, MSD_TEST_MODE: '1' },
|
|
encoding: 'utf8',
|
|
timeout: PROBE_TIMEOUT_MS,
|
|
});
|
|
return { stdout: r.stdout || '', stderr: r.stderr || '', exit: r.status };
|
|
}
|
|
|
|
describe('Kimi variant disambiguation (#2505 Phase 5 / #2513)', () => {
|
|
let home;
|
|
before(() => { home = makeDisposableHome(); });
|
|
after(() => home.cleanup());
|
|
|
|
test('--kimi prints the Kimi CLI (Python) description', () => {
|
|
const r = runInstall(['--kimi', '--help'], home.dir);
|
|
const combined = r.stdout + r.stderr;
|
|
assert.match(combined, /Kimi CLI \(Python kimi-cli\).*named subagents.*~\/\.kimi\//);
|
|
});
|
|
|
|
test('--kimi-code prints the Kimi Code (Node CLI) description', () => {
|
|
const r = runInstall(['--kimi-code', '--help'], home.dir);
|
|
const combined = r.stdout + r.stderr;
|
|
assert.match(combined, /Kimi Code \(Node CLI\).*coder\/explore\/plan.*~\/\.kimi-code\//);
|
|
});
|
|
|
|
test('--kimi warns when only ~/.kimi-code/config.toml exists', () => {
|
|
const h = makeDisposableHome();
|
|
try {
|
|
fs.mkdirSync(path.join(h.dir, '.kimi-code'), { recursive: true });
|
|
fs.writeFileSync(path.join(h.dir, '.kimi-code', 'config.toml'), '# kimi-code');
|
|
const r = runInstall(['--kimi', '--help'], h.dir);
|
|
const combined = r.stdout + r.stderr;
|
|
assert.match(combined, /variant mismatch/i);
|
|
assert.match(combined, /Detected ~\/\.kimi-code\/config\.toml/);
|
|
assert.match(combined, /Re-run with --kimi-code/);
|
|
} finally {
|
|
h.cleanup();
|
|
}
|
|
});
|
|
|
|
test('--kimi-code warns when only ~/.kimi/config.toml exists', () => {
|
|
const h = makeDisposableHome();
|
|
try {
|
|
fs.mkdirSync(path.join(h.dir, '.kimi'), { recursive: true });
|
|
fs.writeFileSync(path.join(h.dir, '.kimi', 'config.toml'), '# kimi-cli');
|
|
const r = runInstall(['--kimi-code', '--help'], h.dir);
|
|
const combined = r.stdout + r.stderr;
|
|
assert.match(combined, /variant mismatch/i);
|
|
assert.match(combined, /Detected ~\/\.kimi\/config\.toml/);
|
|
assert.match(combined, /Re-run with --kimi/);
|
|
} finally {
|
|
h.cleanup();
|
|
}
|
|
});
|
|
|
|
test('no warning when neither config exists (fresh install)', () => {
|
|
const h = makeDisposableHome();
|
|
try {
|
|
const r = runInstall(['--kimi', '--help'], h.dir);
|
|
const combined = r.stdout + r.stderr;
|
|
assert.doesNotMatch(combined, /variant mismatch/i);
|
|
} finally {
|
|
h.cleanup();
|
|
}
|
|
});
|
|
});
|