mirror of
https://github.com/Kaelio/ktx.git
synced 2026-06-10 08:05:14 +02:00
fix: verify local embeddings smoke
This commit is contained in:
parent
1920afa87f
commit
bf3fc0cb7c
2 changed files with 21 additions and 1 deletions
|
|
@ -7,6 +7,10 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
|
|||
const codeExtensions = new Set(['.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.py']);
|
||||
const runtimeAssetPatterns = [/^packages\/[^/]+\/prompts\/.+\.md$/, /^packages\/[^/]+\/skills\/.+\.md$/];
|
||||
const identifierSkipPrefixes = ['docs/', 'examples/', 'python/ktx-sl/plans/', 'python/ktx-sl/openspec/'];
|
||||
const identifierAllowPatterns = [
|
||||
/^packages\/cli\/src\/(?:index|managed-local-embeddings|managed-python-command|managed-python-daemon|managed-python-runtime|runtime)(?:\.test)?\.ts$/,
|
||||
/^scripts\/(?:build-public-npm-package|build-python-runtime-wheel|local-embeddings-runtime-smoke|package-artifacts|published-package-smoke|release-readiness)(?:\.test)?\.mjs$/,
|
||||
];
|
||||
const forbiddenIdentifierTerms = ['kae' + 'lio', 'Kae' + 'lio', 'KAE' + 'LIO_'];
|
||||
|
||||
const appImportPatterns = [
|
||||
|
|
@ -98,6 +102,10 @@ function skipsIdentifierScan(relativePath) {
|
|||
return identifierSkipPrefixes.some((prefix) => relativePath.startsWith(prefix));
|
||||
}
|
||||
|
||||
function allowsForbiddenIdentifier(relativePath) {
|
||||
return identifierAllowPatterns.some((pattern) => pattern.test(relativePath));
|
||||
}
|
||||
|
||||
export function scanFileContent(relativePath, content) {
|
||||
const normalizedPath = normalizePath(relativePath);
|
||||
const violations = [];
|
||||
|
|
@ -138,7 +146,11 @@ export function scanFileContent(relativePath, content) {
|
|||
}
|
||||
}
|
||||
|
||||
if (scansForForbiddenIdentifiers(normalizedPath) && !skipsIdentifierScan(normalizedPath)) {
|
||||
if (
|
||||
scansForForbiddenIdentifiers(normalizedPath) &&
|
||||
!skipsIdentifierScan(normalizedPath) &&
|
||||
!allowsForbiddenIdentifier(normalizedPath)
|
||||
) {
|
||||
for (const term of forbiddenIdentifierTerms) {
|
||||
if (content.includes(term)) {
|
||||
violations.push({
|
||||
|
|
|
|||
|
|
@ -65,6 +65,14 @@ describe('scanFileContent', () => {
|
|||
assert.equal(scanFileContent('python/ktx-sl/openspec/specs/semantic-layer/spec.md', name).length, 0);
|
||||
});
|
||||
|
||||
it('allows public package identifiers in release packaging and managed runtime source', () => {
|
||||
const name = lowerProductName();
|
||||
|
||||
assert.equal(scanFileContent('scripts/local-embeddings-runtime-smoke.mjs', `@${name}/ktx`).length, 0);
|
||||
assert.equal(scanFileContent('scripts/package-artifacts.test.mjs', `${name}-ktx`).length, 0);
|
||||
assert.equal(scanFileContent('packages/cli/src/managed-python-runtime.ts', `${name}_ktx`).length, 0);
|
||||
});
|
||||
|
||||
it('allows clean source files and clean runtime prompt assets', () => {
|
||||
assert.deepEqual(
|
||||
scanFileContent('packages/context/src/index.ts', "export const packageName = '@ktx/context';"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue