MCPcopy Create free account
hub / github.com/massCodeIO/massCode / parseRaycastSnippetFiles

Function parseRaycastSnippetFiles

src/main/import/snippets/raycast.ts:82–131  ·  view source on GitHub ↗
(
  files: ImportFile[],
)

Source from the content-addressed store, hash-verified

80}
81
82export function parseRaycastSnippetFiles(
83 files: ImportFile[],
84): SnippetImportParseResult {
85 const snippets: SnippetImportCandidate[] = []
86 const warnings: SnippetImportParseResult['warnings'] = []
87
88 for (const file of files) {
89 const parsed = parseJsonFile(file)
90 const records = getSnippetRecords(parsed)
91
92 if (!records) {
93 warnings.push({
94 code: 'raycast.invalidExport',
95 source: file.name,
96 })
97 continue
98 }
99
100 records.forEach((record, index) => {
101 const content = readString(record, ['text', 'content', 'snippet'])
102 if (!content) {
103 warnings.push({
104 code: 'raycast.emptyText',
105 source: `${file.name}/${index + 1}`,
106 })
107 return
108 }
109
110 snippets.push({
111 contents: [
112 {
113 label: 'Fragment 1',
114 language: 'plain_text',
115 value: content,
116 },
117 ],
118 description: readString(record, ['description']) ?? null,
119 folderPath: getFolderPath(record),
120 name: normalizeImportEntryName(
121 readString(record, ['name', 'title']),
122 `Raycast snippet ${index + 1}`,
123 ),
124 sourceId: readString(record, ['id']) ?? `${file.name}:${index + 1}`,
125 tags: getTags(record),
126 })
127 })
128 }
129
130 return { snippets, warnings }
131}

Callers 3

detectSnippetSourceFunction · 0.90
parsers.test.tsFile · 0.90

Calls 6

normalizeImportEntryNameFunction · 0.90
getSnippetRecordsFunction · 0.85
parseJsonFileFunction · 0.70
readStringFunction · 0.70
getFolderPathFunction · 0.70
getTagsFunction · 0.70

Tested by

no test coverage detected