feat(ultraplan-local): extend brief-validator to accept type:ultrareview
This commit is contained in:
parent
f6e61e92cd
commit
1c22452e81
2 changed files with 80 additions and 3 deletions
|
|
@ -6,9 +6,15 @@ import { parseDocument } from '../util/frontmatter.mjs';
|
|||
import { issue, ok, fail } from '../util/result.mjs';
|
||||
|
||||
export const BRIEF_REQUIRED_FRONTMATTER = ['type', 'brief_version', 'task', 'slug', 'research_topics', 'research_status'];
|
||||
export const REVIEW_AS_BRIEF_REQUIRED_FRONTMATTER = ['type', 'task', 'slug', 'project_dir', 'findings'];
|
||||
export const BRIEF_TYPE_VALUES = Object.freeze(['ultrabrief', 'ultrareview']);
|
||||
export const BRIEF_RESEARCH_STATUS_VALUES = ['pending', 'in_progress', 'complete', 'skipped'];
|
||||
export const BRIEF_BODY_SECTIONS = ['Intent', 'Goal', 'Success Criteria'];
|
||||
|
||||
function getRequiredFields(type) {
|
||||
return type === 'ultrareview' ? REVIEW_AS_BRIEF_REQUIRED_FRONTMATTER : BRIEF_REQUIRED_FRONTMATTER;
|
||||
}
|
||||
|
||||
export function validateBriefContent(text, opts = {}) {
|
||||
const strict = opts.strict !== false;
|
||||
const doc = parseDocument(text);
|
||||
|
|
@ -19,14 +25,25 @@ export function validateBriefContent(text, opts = {}) {
|
|||
const errors = [];
|
||||
const warnings = [];
|
||||
|
||||
for (const k of BRIEF_REQUIRED_FRONTMATTER) {
|
||||
for (const k of getRequiredFields(fm.type)) {
|
||||
if (!(k in fm)) {
|
||||
errors.push(issue('BRIEF_MISSING_FIELD', `Required frontmatter field missing: ${k}`));
|
||||
}
|
||||
}
|
||||
|
||||
if (fm.type !== undefined && fm.type !== 'ultrabrief') {
|
||||
errors.push(issue('BRIEF_WRONG_TYPE', `frontmatter.type must be "ultrabrief", got "${fm.type}"`));
|
||||
if (fm.type !== undefined && !BRIEF_TYPE_VALUES.includes(fm.type)) {
|
||||
errors.push(issue(
|
||||
'BRIEF_WRONG_TYPE',
|
||||
`frontmatter.type must be one of [${BRIEF_TYPE_VALUES.join(', ')}], got "${fm.type}"`,
|
||||
));
|
||||
}
|
||||
|
||||
if (fm.type === 'ultrareview' && fm.findings !== undefined && !Array.isArray(fm.findings)) {
|
||||
errors.push(issue(
|
||||
'BRIEF_BAD_FINDINGS_TYPE',
|
||||
'Field "findings" must be an array of finding-IDs for type:ultrareview',
|
||||
'Use block-style YAML: `findings:\\n - <id1>\\n - <id2>`',
|
||||
));
|
||||
}
|
||||
|
||||
if (fm.research_status !== undefined && !BRIEF_RESEARCH_STATUS_VALUES.includes(fm.research_status)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue