MCPcopy Index your code
hub / github.com/Noumena-Network/code / loadOutputStyleFromFile

Function loadOutputStyleFromFile

src/utils/plugins/loadPluginOutputStyles.ts:37–86  ·  view source on GitHub ↗
(
  filePath: string,
  pluginName: string,
  loadedPaths: Set<string>,
)

Source from the content-addressed store, hash-verified

35}
36
37async function loadOutputStyleFromFile(
38 filePath: string,
39 pluginName: string,
40 loadedPaths: Set<string>,
41): Promise<OutputStyleConfig | null> {
42 const fs = getFsImplementation()
43 if (isDuplicatePath(fs, filePath, loadedPaths)) {
44 return null
45 }
46 try {
47 const content = await fs.readFile(filePath, { encoding: 'utf-8' })
48 const { frontmatter, content: markdownContent } = parseFrontmatter(
49 content,
50 filePath,
51 )
52
53 const fileName = basename(filePath, '.md')
54 const baseStyleName = (frontmatter.name as string) || fileName
55 // Namespace output styles with plugin name, consistent with commands and agents
56 const name = `${pluginName}:${baseStyleName}`
57 const description =
58 coerceDescriptionToString(frontmatter.description, name) ??
59 extractDescriptionFromMarkdown(
60 markdownContent,
61 `Output style from ${pluginName} plugin`,
62 )
63
64 // Parse forceForPlugin flag (supports both boolean and string values)
65 const forceRaw = frontmatter['force-for-plugin']
66 const forceForPlugin =
67 forceRaw === true || forceRaw === 'true'
68 ? true
69 : forceRaw === false || forceRaw === 'false'
70 ? false
71 : undefined
72
73 return {
74 name,
75 description,
76 prompt: markdownContent.trim(),
77 source: 'plugin',
78 forceForPlugin,
79 }
80 } catch (error) {
81 logForDebugging(`Failed to load output style from ${filePath}: ${error}`, {
82 level: 'error',
83 })
84 return null
85 }
86}
87
88export const loadPluginOutputStyles = memoize(
89 async (): Promise<OutputStyleConfig[]> => {

Callers 2

Calls 7

getFsImplementationFunction · 0.85
isDuplicatePathFunction · 0.85
parseFrontmatterFunction · 0.85
readFileMethod · 0.80
logForDebuggingFunction · 0.50

Tested by

no test coverage detected