refactor: rf-10/rf-03 ask-gate wiring and skills frontmatter consolidation

- rf-10: Wire gateAskUserQuestions (ask-gate.js) into ask-user-questions execute() via dynamic import; blocks autonomous ask_user_questions calls at tool layer
- rf-03: Replace FRONTMATTER_RE + manual body extraction in skills/frontmatter.js with shared splitFrontmatter(); keep custom parseYaml() for skill-specific YAML handling

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Mikael Hugo 2026-05-11 09:09:24 +02:00
parent 9756edfe0b
commit 9dc244eb68
2 changed files with 12 additions and 9 deletions

View file

@ -231,6 +231,14 @@ export default function AskUserQuestions(pi) {
],
parameters: AskUserQuestionsParams,
async execute(_toolCallId, params, signal, _onUpdate, ctx) {
// ── Autonomous mode gate ─────────────────────────────────────────────
const { gateAskUserQuestions } = await import(
"./sf/bootstrap/ask-gate.js"
);
const gate = gateAskUserQuestions(params);
if (!gate.allow) {
return { content: [{ type: "text", text: gate.reason }] };
}
// ── Per-turn dedup: return cached result for identical question sets ──
const sig = questionSignature(params.questions);
const cached = turnCache.get(sig);

View file

@ -7,8 +7,7 @@
*
* Consumer: skill loader, auto-skill creation, and permission gating.
*/
const FRONTMATTER_RE = /^---\s*\n([\s\S]*?)\n---\s*\n/;
import { splitFrontmatter } from "../../shared/frontmatter.js";
/**
* Parse YAML frontmatter from skill markdown content.
@ -17,13 +16,9 @@ const FRONTMATTER_RE = /^---\s*\n([\s\S]*?)\n---\s*\n/;
*/
export function parseSkillFrontmatter(content) {
if (!content) return null;
const match = content.match(FRONTMATTER_RE);
if (!match) return null;
const yamlText = match[1];
const body = content.slice(match[0].length);
const frontmatter = parseYaml(yamlText);
const [fmLines, body] = splitFrontmatter(content);
if (!fmLines) return null;
const frontmatter = parseYaml(fmLines.join("\n"));
return { frontmatter, body };
}