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

Function extractPlanSteps

bin/features_adapter.js:167–180  ·  view source on GitHub ↗

* Extract structured plan steps from any text format using LLM. * MarrowScript Feature #3: replaces regex-based parsePlan() in plan_tracker.js * with a compiled classifier that handles prose-embedded plans. * * @param {string} response - Model response that may contain a plan * @returns {Promis

(response)

Source from the content-addressed store, hash-verified

165 * @returns {Promise<string[]|null>} array of step strings, or null
166 */
167async function extractPlanSteps(response) {
168 const prompts = _getPrompts();
169 if (!prompts) return null;
170 try {
171 const traceId = require('crypto').randomUUID();
172 const result = await prompts.callPrompt('extract_plan', { response }, { trace_id: traceId });
173 const clean = String(result).trim().replace(/^```[a-z]*\n?/, '').replace(/\n?```$/, '');
174 const parsed = JSON.parse(clean);
175 if (!Array.isArray(parsed) || parsed.length < 2) return null;
176 return parsed.slice(0, 8).map(s => String(s).slice(0, 200));
177 } catch {
178 return null; // fall back to regex parser in plan_tracker.js
179 }
180}
181
182/**
183 * Generate a conventional commit message for the auto-commit feature.

Callers 1

ingestResponseAsyncMethod · 0.85

Calls 1

_getPromptsFunction · 0.85

Tested by

no test coverage detected