Closing the intent-to-code chasm - specification-driven development with BDD verification chain
95
Does it follow best practices?
Validation for skill structure
'use strict';
const fs = require('fs');
const path = require('path');
const { parseChecklistsDetailed } = require('./parser');
/**
* Map a percentage (0-100) to a color bracket.
* @param {number} percentage
* @returns {string} "red" | "yellow" | "green"
*/
function percentageToColor(percentage) {
if (percentage <= 33) return 'red';
if (percentage <= 66) return 'yellow';
return 'green';
}
/**
* Compute gate status from an array of file objects with percentage fields.
* Uses worst-case precedence: red if any at 0%, yellow if all 1-99%, green if all 100%.
*
* @param {Array<{percentage: number}>} files
* @returns {{status: string, level: string, label: string}}
*/
function computeGateStatus(files) {
if (files.length === 0) {
return { status: 'blocked', level: 'red', label: 'GATE: BLOCKED' };
}
const anyAtZero = files.some(f => f.percentage === 0);
if (anyAtZero) {
return { status: 'blocked', level: 'red', label: 'GATE: BLOCKED' };
}
const allComplete = files.every(f => f.percentage === 100);
if (allComplete) {
return { status: 'open', level: 'green', label: 'GATE: OPEN' };
}
return { status: 'blocked', level: 'yellow', label: 'GATE: BLOCKED' };
}
/**
* Compute checklist view state for a feature.
* Returns per-file detail with items, percentage, color, and aggregate gate status.
*
* @param {string} projectPath - Path to the project root
* @param {string} featureId - Feature directory name (e.g., "001-kanban-board")
* @returns {{files: Array, gate: {status: string, level: string, label: string}}}
*/
function computeChecklistViewState(projectPath, featureId) {
const checklistDir = path.join(projectPath, 'specs', featureId, 'checklists');
// Include requirements.md only if checklist phase was run
let checklistReviewed = false;
const contextPath = path.join(projectPath, '.specify', 'context.json');
if (fs.existsSync(contextPath)) {
try {
const ctx = JSON.parse(fs.readFileSync(contextPath, 'utf-8'));
checklistReviewed = !!ctx.checklist_reviewed_at;
} catch { /* malformed */ }
}
const parsed = parseChecklistsDetailed(checklistDir, { includeRequirements: checklistReviewed });
const files = parsed.map(file => {
const percentage = file.total > 0 ? Math.round((file.checked / file.total) * 100) : 0;
return {
...file,
percentage,
color: percentageToColor(percentage)
};
});
const gate = computeGateStatus(files);
return { files, gate };
}
module.exports = { computeChecklistViewState };Install with Tessl CLI
npx tessl i tessl-labs/intent-integrity-kit@2.7.12rules
skills
iikit-00-constitution
scripts
iikit-01-specify
iikit-02-plan
iikit-03-checklist
scripts
dashboard
iikit-04-testify
iikit-05-tasks
iikit-06-analyze
iikit-07-implement
iikit-08-taskstoissues
iikit-bugfix
scripts
dashboard
iikit-clarify
iikit-core
scripts
bash
dashboard
powershell
templates