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

Function validateEditCompiled

bin/features_adapter.js:248–265  ·  view source on GitHub ↗

* Ask model if the edit result looks correct. * @returns {{ ok: boolean, issues: string[] }}

(filePath, content, originalTask)

Source from the content-addressed store, hash-verified

246 * @returns {{ ok: boolean, issues: string[] }}
247 */
248async function validateEditCompiled(filePath, content, originalTask) {
249 const prompts = _getPrompts();
250 if (!prompts) return { ok: true, issues: [] }; // graceful: don't block on unavailable
251 try {
252 const traceId = require('crypto').randomUUID();
253 const result = await prompts.callPrompt('validate_edit', {
254 file_path: filePath,
255 content: content.slice(0, 4000),
256 original_task: String(originalTask || '').slice(0, 500),
257 }, { trace_id: traceId });
258 const text = String(result).toLowerCase();
259 const passed = text.includes('ok') || text.includes('correct') || text.includes('looks good') ||
260 text.includes('valid') || text.includes('pass') || !text.includes('error');
261 return { ok: passed, issues: passed ? [] : [String(result).slice(0, 200)] };
262 } catch {
263 return { ok: true, issues: [] }; // fail open
264 }
265}
266
267// ─── Feature Rank 4: diagnoseError ───────────────────────────────────────────
268

Callers 1

runAgentLoopFunction · 0.85

Calls 1

_getPromptsFunction · 0.85

Tested by

no test coverage detected