MCPcopy
hub / github.com/OpenCoworkAI/open-codesign / normalizeLegacyEditmodeBlock

Function normalizeLegacyEditmodeBlock

packages/shared/src/editmode.ts:187–201  ·  view source on GitHub ↗
(source: string)

Source from the content-addressed store, hash-verified

185 * boolean objects that older Open CoDesign bundled templates used.
186 */
187export function normalizeLegacyEditmodeBlock(source: string): string | null {
188 const block = findMarkerBlock(source, 'EDITMODE');
189 if (block === null) return null;
190 const raw = block.inner.trim();
191 if (raw.length === 0) return null;
192 try {
193 JSON.parse(raw);
194 return null;
195 } catch {
196 // Fall through to the legacy flat-object parser.
197 }
198 const tokens = parseLegacyEditmodeObject(raw);
199 if (tokens === null) return null;
200 return replaceMarkerBlock(source, 'EDITMODE', JSON.stringify(tokens, null, 2));
201}
202
203/**
204 * Kept for older runtime call sites. v0.2 no longer repairs missing EDITMODE

Callers 3

runScaffoldFunction · 0.90
editmode.test.tsFile · 0.90

Calls 3

findMarkerBlockFunction · 0.85
replaceMarkerBlockFunction · 0.85

Tested by

no test coverage detected