MCPcopy
hub / github.com/wshobson/agents / emit_global

Method emit_global

tools/adapters/cursor.py:153–203  ·  view source on GitHub ↗
(self, plugins: list[PluginSource])

Source from the content-addressed store, hash-verified

151 return result
152
153 def emit_global(self, plugins: list[PluginSource]) -> EmitResult:
154 result = EmitResult()
155 # 1. Marketplace
156 marketplace = self._build_marketplace(plugins)
157 result.written.append(
158 self.write(
159 Path(".cursor-plugin") / "marketplace.json",
160 json.dumps(marketplace, indent=2) + "\n",
161 )
162 )
163
164 # 2. Top-level plugin.json (matches Cursor convention for single-plugin repos
165 # AND advertises the marketplace bundle)
166 if marketplace["plugins"]:
167 top_manifest = {
168 "name": marketplace["name"],
169 "displayName": marketplace["name"].replace("-", " ").title(),
170 "version": marketplace.get("metadata", {}).get("version", "0.0.0"),
171 "description": marketplace.get("metadata", {}).get("description", ""),
172 "author": {
173 "name": marketplace["owner"]["name"],
174 "email": marketplace["owner"].get("email", ""),
175 },
176 "homepage": marketplace["owner"].get("url", ""),
177 "license": "MIT",
178 }
179 result.written.append(
180 self.write(
181 Path(".cursor-plugin") / "plugin.json",
182 json.dumps(top_manifest, indent=2) + "\n",
183 )
184 )
185
186 # 3. Curated rules
187 rules_emitted = 0
188 if _CURATED_RULES_DIR.is_dir():
189 for mdc in sorted(_CURATED_RULES_DIR.glob("*.mdc")):
190 content = read_file(mdc)
191 errors = _validate_mdc_frontmatter(content, mdc)
192 if errors:
193 for err in errors:
194 result.warnings.append(err)
195 continue
196 rel = Path(".cursor") / "rules" / mdc.name
197 result.written.append(self.write(rel, content))
198 rules_emitted += 1
199 if rules_emitted == 0:
200 result.warnings.append(
201 "no curated rules emitted; add MDC files to tools/adapters/cursor_rules/"
202 )
203 return result
204
205 # ── Internals ──────────────────────────────────────────────────────────
206

Calls 5

_build_marketplaceMethod · 0.95
EmitResultClass · 0.90
read_fileFunction · 0.90
writeMethod · 0.80