spec-driven workflow framework for AI-assisted development
npm install specflow
const { Workflow, SpecRunner } = require('specflow');
// define a spec-driven workflow
const workflow = new Workflow({
name: 'feature-implementation',
spec: './specs/user-auth.md'
});
// register handlers for different spec sections
workflow.on('requirement', async (req) => {
console.log(`processing: ${req.title}`);
return await generateImplementation(req);
});
workflow.on('test', async (test) => {
return await runTestCase(test);
});
// execute the workflow
const result = await workflow.run();
console.log(`completed ${result.steps} steps in ${result.duration}ms`);creates a new workflow instance.
options:
name(string): workflow identifierspec(string): path to specification fileparallel(boolean): run steps concurrently, defaultfalsetimeout(number): step timeout in ms, default30000
methods:
on(event, handler): register event handlerrun(): execute workflowpause(): pause executionresume(): resume paused workflow
parses and executes specification files.
const runner = new SpecRunner('./spec.md');
const parsed = runner.parse();
// { requirements: [...], tests: [...], metadata: {...} }requirement: fired for each requirement in spectest: fired for each test casevalidation: fired for validation stepscomplete: fired when workflow finisheserror: fired on failures
standalone parser for spec files. returns structured data.
const { parseSpec } = require('specflow');
const spec = parseSpec('./docs/feature.md');prs welcome. open an issue first for big changes.
run tests with npm test. make sure coverage doesn't drop.
MIT