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

Function parseAssertions

src/session/contract.js:220–245  ·  view source on GitHub ↗
(input)

Source from the content-addressed store, hash-verified

218// list. Emits a normalised assertion array.
219
220function parseAssertions(input) {
221 if (!input) return [];
222 if (Array.isArray(input)) {
223 return input
224 .map((s, i) => String(s || '').trim())
225 .filter(Boolean)
226 .map((text, i) => ({ id: newAssertionId(i), text, state: STATES.PENDING, evidence: null, last_check: null }));
227 }
228 const lines = String(input).split(/\r?\n/);
229 const out = [];
230 for (const raw of lines) {
231 const line = raw.trim();
232 if (!line) continue;
233 // Strip leading bullet/number markers
234 const cleaned = line.replace(/^[-*]\s+/, '').replace(/^\d+[.)]\s+/, '').trim();
235 if (!cleaned) continue;
236 out.push({
237 id: newAssertionId(out.length),
238 text: cleaned,
239 state: STATES.PENDING,
240 evidence: null,
241 last_check: null,
242 });
243 }
244 return out;
245}
246
247module.exports = {
248 // constants

Callers 2

contract.test.jsFile · 0.85
createMethod · 0.85

Calls 1

newAssertionIdFunction · 0.85

Tested by

no test coverage detected