Files
msd-core/tests/sdk-smoke.test.cjs
Jakub Zych a9a7a328e6 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.
2026-10-06 01:47:40 +02:00

68 lines
2.9 KiB
JavaScript

'use strict';
/**
* SDK smoke test — ADR-1239 Phase E / #1683 Slice 2.
*
* Proves the Host-Integration Interface is PUBLISHED: an external developer can
* author + wire a new host-plugin against the SDK surface ONLY (no imports of
* msd-core internal paths). This test imports exclusively from the SDK entry —
* if a host-plugin author needs a symbol that ISN'T here, the SDK is incomplete.
*/
const { test } = require('node:test');
const assert = require('node:assert/strict');
// EXTERNAL-AUTHOR CONTRACT: import ONLY from the published SDK entry.
const SDK = require('../msd-core/bin/lib/host-integration-sdk.cjs');
test('SDK exports the full public surface a host-plugin author needs', () => {
assert.equal(typeof SDK.PROTOCOL_VERSION, 'number');
assert.ok(SDK.HOST_INTEGRATION_AXES, 'negotiated schema (axes)');
assert.ok(SDK.INTERFACE_POINTS, 'interface points');
assert.ok(SDK.PROFILE_BASELINES, 'profile baselines');
const fns = [
'negotiateHostCapabilities', 'profileOf', 'degradationFor',
'hookEventSurfaceFor', 'extensionEventSurfaceFor', 'shouldFlattenDispatch',
'createDeclarativeAdapter', 'createImperativeAdapter',
'createModelAdapter', 'createHookBus', 'createStateIO',
'buildHandshakeRequest', 'handleHandshakeRequest',
];
for (const fn of fns) {
assert.equal(typeof SDK[fn], 'function', `SDK must export function: ${fn}`);
}
assert.equal(typeof SDK.HANDSHAKE_METHOD, 'string');
});
test('the SDK surface is frozen (immutable public contract)', () => {
assert.equal(Object.isFrozen(SDK), true);
});
test('an external author can build a host-plugin against the SDK surface ONLY', () => {
// Compose a minimal host-plugin using EXCLUSIVELY the SDK entry — mirrors what
// an external author writes. No require() of any internal path succeeds here.
const model = SDK.createModelAdapter({ modelMode: 'passive' });
const bus = SDK.createHookBus({ bus: 'engine' });
const io = SDK.createStateIO({ io: 'filesystem' });
const adapter = SDK.createImperativeAdapter({ runtime: 'my-third-party-host' });
// Negotiate this host's capabilities via the SDK handshake.
const req = SDK.buildHandshakeRequest({ embeddingMode: 'imperative', runtime: 'node' });
const result = SDK.handleHandshakeRequest(req);
const profile = SDK.profileOf(result.effective);
assert.equal(model.mode, 'passive');
assert.equal(bus.bus, 'engine');
assert.equal(io.io, 'filesystem');
assert.equal(adapter.kind, 'imperative');
assert.equal(adapter.runtime, 'my-third-party-host');
assert.equal(profile, 'programmatic-cli');
assert.ok(result.effective && result.points, 'handshake yields a negotiated result');
});
test('the SDK handshake round-trips for a declarative host authored externally', () => {
const req = SDK.buildHandshakeRequest({ embeddingMode: 'declarative', commandSurface: 'slash-file' });
const result = SDK.handleHandshakeRequest(req);
assert.equal(SDK.profileOf(result.effective), 'declarative-cli');
});