MCPcopy Create free account
hub / github.com/anus-dev/ANUS / annotateActiveExtensions

Function annotateActiveExtensions

packages/cli/src/config/extension.ts:116–170  ·  view source on GitHub ↗
(
  extensions: Extension[],
  enabledExtensionNames: string[],
)

Source from the content-addressed store, hash-verified

114}
115
116export function annotateActiveExtensions(
117 extensions: Extension[],
118 enabledExtensionNames: string[],
119): AnusCLIExtension[] {
120 const annotatedExtensions: AnusCLIExtension[] = [];
121
122 if (enabledExtensionNames.length === 0) {
123 return extensions.map((extension) => ({
124 name: extension.config.name,
125 version: extension.config.version,
126 isActive: true,
127 path: extension.path,
128 }));
129 }
130
131 const lowerCaseEnabledExtensions = new Set(
132 enabledExtensionNames.map((e) => e.trim().toLowerCase()),
133 );
134
135 if (
136 lowerCaseEnabledExtensions.size === 1 &&
137 lowerCaseEnabledExtensions.has('none')
138 ) {
139 return extensions.map((extension) => ({
140 name: extension.config.name,
141 version: extension.config.version,
142 isActive: false,
143 path: extension.path,
144 }));
145 }
146
147 const notFoundNames = new Set(lowerCaseEnabledExtensions);
148
149 for (const extension of extensions) {
150 const lowerCaseName = extension.config.name.toLowerCase();
151 const isActive = lowerCaseEnabledExtensions.has(lowerCaseName);
152
153 if (isActive) {
154 notFoundNames.delete(lowerCaseName);
155 }
156
157 annotatedExtensions.push({
158 name: extension.config.name,
159 version: extension.config.version,
160 isActive,
161 path: extension.path,
162 });
163 }
164
165 for (const requestedName of notFoundNames) {
166 console.error(`Extension not found: ${requestedName}`);
167 }
168
169 return annotatedExtensions;
170}

Callers 2

loadCliConfigFunction · 0.85
extension.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected