diff --git a/scripts/local-embeddings-runtime-smoke.mjs b/scripts/local-embeddings-runtime-smoke.mjs index 6f1c3657..06f483d5 100644 --- a/scripts/local-embeddings-runtime-smoke.mjs +++ b/scripts/local-embeddings-runtime-smoke.mjs @@ -5,6 +5,11 @@ import { dirname, join, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; import { promisify } from 'node:util'; +import { + PUBLIC_NPM_PACKAGE_NAME, + PUBLIC_NPM_PACKAGE_VERSION, +} from './build-public-npm-package.mjs'; + const execFileAsync = promisify(execFile); const SCRIPT_DIR = dirname(fileURLToPath(import.meta.url)); const DEFAULT_ROOT_DIR = resolve(SCRIPT_DIR, '..'); @@ -12,6 +17,16 @@ const PUBLIC_NPM_ARTIFACT_DIR = join('dist', 'artifacts', 'npm'); const OPT_IN_MESSAGE = 'Set KTX_RUN_LOCAL_EMBEDDINGS_SMOKE=1 or pass --force to run the local embeddings smoke.'; +function escapeRegExp(value) { + return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); +} + +export function expectedPublicKtxVersionPattern() { + return new RegExp( + `${escapeRegExp(PUBLIC_NPM_PACKAGE_NAME)} ${escapeRegExp(PUBLIC_NPM_PACKAGE_VERSION)}`, + ); +} + export function localEmbeddingsSmokeOptIn(env = process.env, args = process.argv.slice(2)) { if (env.KTX_RUN_LOCAL_EMBEDDINGS_SMOKE === '1' || args.includes('--force')) { return { run: true }; @@ -264,7 +279,7 @@ export async function runLocalEmbeddingsRuntimeSmoke(options = {}) { timeoutMs: commands[0].timeoutMs, }); requireSuccess(commands[0].label, version); - requireOutput(commands[0].label, version, /@kaelio\/ktx 0\.0\.0-private/); + requireOutput(commands[0].label, version, expectedPublicKtxVersionPattern()); const missingStatus = parseJsonStdout( commands[1].label, diff --git a/scripts/local-embeddings-runtime-smoke.test.mjs b/scripts/local-embeddings-runtime-smoke.test.mjs index 119fb05a..af9ee6e3 100644 --- a/scripts/local-embeddings-runtime-smoke.test.mjs +++ b/scripts/local-embeddings-runtime-smoke.test.mjs @@ -4,6 +4,7 @@ import { describe, it } from 'node:test'; import { buildLocalEmbeddingsSmokeEnv, + expectedPublicKtxVersionPattern, localEmbeddingsSmokeCommands, localEmbeddingsSmokeOptIn, parseDaemonBaseUrl, @@ -55,6 +56,15 @@ describe('publicKtxTarballName', () => { }); }); +describe('expectedPublicKtxVersionPattern', () => { + it('matches the public package version and rejects the private workspace version', () => { + const pattern = expectedPublicKtxVersionPattern(); + + assert.match('@kaelio/ktx 0.1.0\n', pattern); + assert.doesNotMatch('@kaelio/ktx 0.0.0-private\n', pattern); + }); +}); + describe('buildLocalEmbeddingsSmokeEnv', () => { it('isolates the runtime root and model caches inside the smoke root', () => { const env = buildLocalEmbeddingsSmokeEnv('/tmp/ktx-local-embedding-smoke', {