MCPcopy
hub / github.com/Doorman11991/smallcode / checkNeedsClarification

Function checkNeedsClarification

bin/features_adapter.js:224–242  ·  view source on GitHub ↗

* Check if a user message is too vague to act on. * MarrowScript Feature #1: compiled intent_clarifier replaces hand-rolled regex * in src/session/clarify.js. Falls back to the regex version if the model is * unavailable (e.g. first turn before model is warmed up). * * @returns {Promise<boolean

(userMessage)

Source from the content-addressed store, hash-verified

222 * @returns {Promise<boolean>} true = needs clarification
223 */
224async function checkNeedsClarification(userMessage) {
225 const prompts = _getPrompts();
226 if (!prompts) {
227 // Fallback to regex (src/session/clarify.js)
228 const { needsClarification } = require('../src/session/clarify');
229 return needsClarification(userMessage);
230 }
231 try {
232 const traceId = require('crypto').randomUUID();
233 const result = await prompts.callPrompt('intent_clarifier', {
234 user_message: userMessage,
235 }, { trace_id: traceId });
236 return String(result).trim().toLowerCase().startsWith('vague');
237 } catch {
238 // On any model failure, fall back to regex — never block on clarifier errors
239 const { needsClarification } = require('../src/session/clarify');
240 return needsClarification(userMessage);
241 }
242}
243
244/**
245 * Ask model if the edit result looks correct.

Callers 1

runAgentLoopFunction · 0.85

Calls 2

_getPromptsFunction · 0.85
needsClarificationFunction · 0.85

Tested by

no test coverage detected