chore: polish for FOL contract delivery (CHANGELOG, CLI guardrails, metadata)
- Update CHANGELOG.md for 1.1.0 (date, refactoring, repository fixes) - Add overwrite guardrails to imhotep-cli init — skips existing files - Add bugs/homepage/keywords metadata to 5 public packages - Mark imhotep-bench and imhotep-fixtures as private packages - Add selector field to SourceReference interface (core types) - Remove 7 casts from check-all.ts (folAst.position, cardinality results) - Generate package-lock.json for reproducible installs
This commit is contained in:
@@ -29,5 +29,6 @@
|
||||
"dependencies": {
|
||||
"imhotep-core": "^1.0.0",
|
||||
"imhotep-solver": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"private": true
|
||||
}
|
||||
|
||||
@@ -37,5 +37,21 @@
|
||||
"@types/node": "^20.19.39",
|
||||
"playwright": "^1.59.1",
|
||||
"typescript": "^5.9.3"
|
||||
}
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://gitea.com/anomalyco/imhotep/issues"
|
||||
},
|
||||
"homepage": "https://docs.imhotep.dev",
|
||||
"keywords": [
|
||||
"testing",
|
||||
"visual-testing",
|
||||
"layout-testing",
|
||||
"relational-testing",
|
||||
"playwright",
|
||||
"geometry",
|
||||
"fol",
|
||||
"first-order-logic",
|
||||
"e2e",
|
||||
"property-testing"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -50,8 +50,15 @@ function main(): void {
|
||||
: process.cwd();
|
||||
|
||||
try {
|
||||
initProject({ preset, targetDir });
|
||||
const result = initProject({ preset, targetDir });
|
||||
console.log(`✓ Scaffolded ${preset} project in ${targetDir}`);
|
||||
|
||||
if (result.created.length > 0) {
|
||||
console.log(` Created: ${result.created.map(f => f.replace(targetDir, '.')).join(', ')}`);
|
||||
}
|
||||
if (result.skipped.length > 0) {
|
||||
console.warn(` Skipped (already exists): ${result.skipped.map(f => f.replace(targetDir, '.')).join(', ')}`);
|
||||
}
|
||||
console.log(` Run: cd ${targetDir} && npm install && npm test`);
|
||||
} catch (error: any) {
|
||||
console.error(`Error: ${error.message}`);
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
// Public API exports for imhotep-cli
|
||||
export { initProject, type InitOptions } from './init.js';
|
||||
export { initProject, type InitOptions, type InitResult } from './init.js';
|
||||
export { presets, getPresetNames, getPreset, type PresetName } from './presets/index.js';
|
||||
@@ -1,5 +1,5 @@
|
||||
// Core init logic for scaffolding Imhotep projects from presets
|
||||
import { mkdirSync, writeFileSync } from 'node:fs';
|
||||
import { mkdirSync, writeFileSync, existsSync } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import { getPreset } from './presets/index.js';
|
||||
|
||||
@@ -8,49 +8,59 @@ export interface InitOptions {
|
||||
targetDir: string;
|
||||
}
|
||||
|
||||
export function initProject(options: InitOptions): void {
|
||||
export interface InitResult {
|
||||
created: string[];
|
||||
skipped: string[];
|
||||
}
|
||||
|
||||
function safeWrite(filePath: string, content: string, results: { created: string[]; skipped: string[] }): void {
|
||||
if (existsSync(filePath)) {
|
||||
results.skipped.push(filePath)
|
||||
} else {
|
||||
writeFileSync(filePath, content, 'utf-8')
|
||||
results.created.push(filePath)
|
||||
}
|
||||
}
|
||||
|
||||
export function initProject(options: InitOptions): InitResult {
|
||||
const { preset, targetDir } = options;
|
||||
|
||||
// Resolve preset template
|
||||
const results: InitResult = { created: [], skipped: [] };
|
||||
|
||||
const template = getPreset(preset);
|
||||
|
||||
// Create directory structure
|
||||
|
||||
mkdirSync(targetDir, { recursive: true });
|
||||
mkdirSync(join(targetDir, 'tests'), { recursive: true });
|
||||
mkdirSync(join(targetDir, 'fixtures'), { recursive: true });
|
||||
|
||||
// Write config file
|
||||
writeFileSync(
|
||||
|
||||
safeWrite(
|
||||
join(targetDir, 'imhotep.config.js'),
|
||||
template.configFile,
|
||||
'utf-8'
|
||||
results
|
||||
);
|
||||
|
||||
// Write test file
|
||||
writeFileSync(
|
||||
|
||||
safeWrite(
|
||||
join(targetDir, 'tests', 'example.test.ts'),
|
||||
template.testFile,
|
||||
'utf-8'
|
||||
results
|
||||
);
|
||||
|
||||
// Write fixture file
|
||||
writeFileSync(
|
||||
|
||||
safeWrite(
|
||||
join(targetDir, 'fixtures', 'example.html'),
|
||||
template.fixtureFile,
|
||||
'utf-8'
|
||||
results
|
||||
);
|
||||
|
||||
// Write package.json
|
||||
writeFileSync(
|
||||
|
||||
safeWrite(
|
||||
join(targetDir, 'package.json'),
|
||||
JSON.stringify(template.packageJson, null, 2),
|
||||
'utf-8'
|
||||
results
|
||||
);
|
||||
|
||||
// Write README
|
||||
writeFileSync(
|
||||
|
||||
safeWrite(
|
||||
join(targetDir, 'README.md'),
|
||||
template.readme,
|
||||
'utf-8'
|
||||
results
|
||||
);
|
||||
|
||||
return results
|
||||
}
|
||||
@@ -41,5 +41,21 @@
|
||||
"types": "./dist/world.d.ts",
|
||||
"default": "./dist/world.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://gitea.com/anomalyco/imhotep/issues"
|
||||
},
|
||||
"homepage": "https://docs.imhotep.dev",
|
||||
"keywords": [
|
||||
"testing",
|
||||
"visual-testing",
|
||||
"layout-testing",
|
||||
"relational-testing",
|
||||
"playwright",
|
||||
"geometry",
|
||||
"fol",
|
||||
"first-order-logic",
|
||||
"e2e",
|
||||
"property-testing"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -251,6 +251,8 @@ export interface SourceReference {
|
||||
specLine?: number
|
||||
/** 1-based column number in the dense spec string */
|
||||
specColumn?: number
|
||||
/** CSS or semantic selector for cardinality assertions */
|
||||
selector?: string
|
||||
}
|
||||
|
||||
export interface ClauseResult {
|
||||
|
||||
@@ -28,5 +28,21 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"imhotep-core": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://gitea.com/anomalyco/imhotep/issues"
|
||||
},
|
||||
"homepage": "https://docs.imhotep.dev",
|
||||
"keywords": [
|
||||
"testing",
|
||||
"visual-testing",
|
||||
"layout-testing",
|
||||
"relational-testing",
|
||||
"playwright",
|
||||
"geometry",
|
||||
"fol",
|
||||
"first-order-logic",
|
||||
"e2e",
|
||||
"property-testing"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -35,5 +35,6 @@
|
||||
"dependencies": {
|
||||
"imhotep-cdp": "^1.0.0",
|
||||
"imhotep-playwright": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"private": true
|
||||
}
|
||||
|
||||
@@ -37,5 +37,21 @@
|
||||
"imhotep-dsl": "^1.0.0",
|
||||
"imhotep-solver": "^1.0.0",
|
||||
"imhotep-reporter": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://gitea.com/anomalyco/imhotep/issues"
|
||||
},
|
||||
"homepage": "https://docs.imhotep.dev",
|
||||
"keywords": [
|
||||
"testing",
|
||||
"visual-testing",
|
||||
"layout-testing",
|
||||
"relational-testing",
|
||||
"playwright",
|
||||
"geometry",
|
||||
"fol",
|
||||
"first-order-logic",
|
||||
"e2e",
|
||||
"property-testing"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -121,6 +121,7 @@ export function makeCheckAll(deps: CheckAllDeps): ImhotepUi['checkAll'] {
|
||||
const validationClauseResults: ClauseResult[] = []
|
||||
|
||||
for (let i = 0; i < assertions.length; i++) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const assertion = assertions[i] as any
|
||||
// Cardinality assertions are evaluated outside the FOL engine.
|
||||
if (assertion && ['exactlyOne', 'atLeastN', 'atMostN'].includes(assertion.kind)) {
|
||||
@@ -240,8 +241,8 @@ export function makeCheckAll(deps: CheckAllDeps): ImhotepUi['checkAll'] {
|
||||
for (const folAst of folFormulas) {
|
||||
const solverFormula = compileDenseFOLToFormula(folAst)
|
||||
const selectors = getSelectorsFromFormula(solverFormula)
|
||||
const sourceRef: SourceReference = (folAst as any).position?.start
|
||||
? { specLine: (folAst as any).position.start.line, specColumn: (folAst as any).position.start.column }
|
||||
const sourceRef: SourceReference = folAst.position?.start
|
||||
? { specLine: folAst.position.start.line, specColumn: folAst.position.start.column }
|
||||
: {}
|
||||
checks.push({
|
||||
clauseId: `clause_${specBase++}`,
|
||||
@@ -420,11 +421,10 @@ export function makeCheckAll(deps: CheckAllDeps): ImhotepUi['checkAll'] {
|
||||
metrics: {
|
||||
observedCount: 0,
|
||||
expectedCount: cardResult.expectedCount,
|
||||
selector: cardResult.selector,
|
||||
} as any,
|
||||
},
|
||||
witness: { subjectId: 0, frameId: 0 },
|
||||
diagnostics: cardResult.diagnostics.map((d) => d.code),
|
||||
sourceRef: { selector: cardResult.selector } as any,
|
||||
sourceRef: { selector: cardResult.selector },
|
||||
clauseLabel: cardResult.label,
|
||||
})
|
||||
cardDiagnostics.push(...cardResult.diagnostics)
|
||||
@@ -481,11 +481,10 @@ export function makeCheckAll(deps: CheckAllDeps): ImhotepUi['checkAll'] {
|
||||
metrics: {
|
||||
observedCount: selectorToIds.get(cardResult.selector)?.length ?? 0,
|
||||
expectedCount: cardResult.expectedCount,
|
||||
selector: cardResult.selector,
|
||||
} as any,
|
||||
},
|
||||
witness: { subjectId: 0, frameId: 0 },
|
||||
diagnostics: cardResult.diagnostics.map((d) => d.code),
|
||||
sourceRef: { selector: cardResult.selector } as any,
|
||||
sourceRef: { selector: cardResult.selector },
|
||||
clauseLabel: cardResult.label,
|
||||
})
|
||||
allDiagnostics.push(...cardResult.diagnostics)
|
||||
|
||||
@@ -984,7 +984,7 @@ describe('Selector Cardinality Contracts (P2.1)', () => {
|
||||
if (cardClause) {
|
||||
assert.strictEqual(cardClause.metrics.observedCount, 0)
|
||||
assert.strictEqual(cardClause.metrics.expectedCount, 1)
|
||||
assert.strictEqual(cardClause.metrics.selector, '.does-not-exist')
|
||||
assert.strictEqual(cardClause.sourceRef?.selector, '.does-not-exist')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -45,5 +45,21 @@
|
||||
"peerDependencies": {
|
||||
"@playwright/test": "^1.40.0",
|
||||
"playwright": "^1.40.0"
|
||||
}
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://gitea.com/anomalyco/imhotep/issues"
|
||||
},
|
||||
"homepage": "https://docs.imhotep.dev",
|
||||
"keywords": [
|
||||
"testing",
|
||||
"visual-testing",
|
||||
"layout-testing",
|
||||
"relational-testing",
|
||||
"playwright",
|
||||
"geometry",
|
||||
"fol",
|
||||
"first-order-logic",
|
||||
"e2e",
|
||||
"property-testing"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user