MCPcopy Create free account
hub / github.com/dwgx/WindsurfAPI / decodeKnowledgeBaseItemText

Function decodeKnowledgeBaseItemText

src/windsurf.js:999–1025  ·  view source on GitHub ↗
(docBuf)

Source from the content-addressed store, hash-verified

997 const results = [];
998
999 const decodeKnowledgeBaseItemText = (docBuf) => {
1000 try {
1001 const doc = parseFields(docBuf);
1002 const text = getField(doc, 2, 2)?.value?.toString('utf8') || '';
1003 if (text) return text;
1004 const chunks = getAllFields(doc, 6)
1005 .filter(x => x.wireType === 2)
1006 .map((chunkField) => {
1007 try {
1008 const chunk = parseFields(chunkField.value);
1009 const chunkText = getField(chunk, 1, 2)?.value?.toString('utf8') || '';
1010 if (chunkText) return chunkText;
1011 const markdown = getField(chunk, 3, 2);
1012 if (!markdown) return '';
1013 const md = parseFields(markdown.value);
1014 return getField(md, 2, 2)?.value?.toString('utf8') || '';
1015 } catch {
1016 return '';
1017 }
1018 })
1019 .filter(Boolean);
1020 if (chunks.length) return chunks.join('\n');
1021 return getField(doc, 7, 2)?.value?.toString('utf8') || '';
1022 } catch {
1023 return '';
1024 }
1025 };
1026
1027 const isLikelyPathOrFileUri = (value) => {
1028 const s = String(value || '').trim();

Callers 1

parseTrajectoryStepsFunction · 0.85

Calls 3

parseFieldsFunction · 0.90
getFieldFunction · 0.90
getAllFieldsFunction · 0.90

Tested by

no test coverage detected