MCPcopy Create free account
hub / github.com/QodeXcli/QodeX / coerce

Function coerce

src/schedule/receipt.ts:54–74  ·  view source on GitHub ↗
(o: any)

Source from the content-addressed store, hash-verified

52}
53
54function coerce(o: any): RunReceipt | null {
55 if (!o || typeof o !== 'object') return null;
56 const status = STATUSES.has(o.status) ? o.status : (o.prUrl || o.pr_url ? 'opened' : undefined);
57 if (!status) return null;
58 const checks = Array.isArray(o.verification)
59 ? o.verification.map((c: any) => ({ command: String(c?.command ?? ''), passed: !!c?.passed })).filter((c: ReceiptCheck) => c.command)
60 : undefined;
61 const files = Array.isArray(o.filesChanged ?? o.files)
62 ? (o.filesChanged ?? o.files).map((f: any) => String(f)).filter(Boolean)
63 : undefined;
64 return {
65 status,
66 goal: str(o.goal),
67 branch: str(o.branch),
68 prUrl: str(o.prUrl ?? o.pr_url),
69 reason: str(o.reason),
70 summary: str(o.summary),
71 filesChanged: files,
72 verification: checks,
73 };
74}
75
76const str = (x: any): string | undefined => (typeof x === 'string' && x.trim() ? x.trim() : undefined);
77

Callers 2

parseReceiptFunction · 0.85
readReceiptFileFunction · 0.85

Calls 2

strFunction · 0.85
hasMethod · 0.45

Tested by

no test coverage detected