@x-code-cli/core 0.2.10 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (251) hide show
  1. package/dist/agent/compression.d.ts +12 -2
  2. package/dist/agent/compression.d.ts.map +1 -1
  3. package/dist/agent/compression.js +51 -2
  4. package/dist/agent/compression.js.map +1 -1
  5. package/dist/agent/file-ingest.js +2 -2
  6. package/dist/agent/file-ingest.js.map +1 -1
  7. package/dist/agent/loop-state.d.ts +3 -2
  8. package/dist/agent/loop-state.d.ts.map +1 -1
  9. package/dist/agent/loop-state.js.map +1 -1
  10. package/dist/agent/loop.d.ts.map +1 -1
  11. package/dist/agent/loop.js +134 -5
  12. package/dist/agent/loop.js.map +1 -1
  13. package/dist/agent/memory-extractor.js +5 -5
  14. package/dist/agent/memory-extractor.js.map +1 -1
  15. package/dist/agent/plan-storage.js +1 -1
  16. package/dist/agent/plan-storage.js.map +1 -1
  17. package/dist/agent/sub-agents/index.d.ts +2 -1
  18. package/dist/agent/sub-agents/index.d.ts.map +1 -1
  19. package/dist/agent/sub-agents/index.js +1 -1
  20. package/dist/agent/sub-agents/index.js.map +1 -1
  21. package/dist/agent/sub-agents/loader.d.ts +13 -3
  22. package/dist/agent/sub-agents/loader.d.ts.map +1 -1
  23. package/dist/agent/sub-agents/loader.js +36 -9
  24. package/dist/agent/sub-agents/loader.js.map +1 -1
  25. package/dist/agent/sub-agents/registry.d.ts +18 -1
  26. package/dist/agent/sub-agents/registry.d.ts.map +1 -1
  27. package/dist/agent/sub-agents/registry.js +38 -5
  28. package/dist/agent/sub-agents/registry.js.map +1 -1
  29. package/dist/agent/sub-agents/runner.d.ts.map +1 -1
  30. package/dist/agent/sub-agents/runner.js +45 -1
  31. package/dist/agent/sub-agents/runner.js.map +1 -1
  32. package/dist/agent/sub-agents/types.d.ts +4 -1
  33. package/dist/agent/sub-agents/types.d.ts.map +1 -1
  34. package/dist/agent/system-prompt.d.ts +21 -0
  35. package/dist/agent/system-prompt.d.ts.map +1 -1
  36. package/dist/agent/system-prompt.js +68 -2
  37. package/dist/agent/system-prompt.js.map +1 -1
  38. package/dist/agent/tool-execution.d.ts.map +1 -1
  39. package/dist/agent/tool-execution.js +220 -1
  40. package/dist/agent/tool-execution.js.map +1 -1
  41. package/dist/commands/index.d.ts +6 -0
  42. package/dist/commands/index.d.ts.map +1 -0
  43. package/dist/commands/index.js +3 -0
  44. package/dist/commands/index.js.map +1 -0
  45. package/dist/commands/loader.d.ts +13 -0
  46. package/dist/commands/loader.d.ts.map +1 -0
  47. package/dist/commands/loader.js +93 -0
  48. package/dist/commands/loader.js.map +1 -0
  49. package/dist/commands/registry.d.ts +44 -0
  50. package/dist/commands/registry.d.ts.map +1 -0
  51. package/dist/commands/registry.js +102 -0
  52. package/dist/commands/registry.js.map +1 -0
  53. package/dist/commands/types.d.ts +23 -0
  54. package/dist/commands/types.d.ts.map +1 -0
  55. package/dist/commands/types.js +26 -0
  56. package/dist/commands/types.js.map +1 -0
  57. package/dist/config/index.d.ts +9 -0
  58. package/dist/config/index.d.ts.map +1 -1
  59. package/dist/config/index.js +12 -10
  60. package/dist/config/index.js.map +1 -1
  61. package/dist/hooks/bus.d.ts +54 -0
  62. package/dist/hooks/bus.d.ts.map +1 -0
  63. package/dist/hooks/bus.js +165 -0
  64. package/dist/hooks/bus.js.map +1 -0
  65. package/dist/hooks/config-schema.d.ts +854 -0
  66. package/dist/hooks/config-schema.d.ts.map +1 -0
  67. package/dist/hooks/config-schema.js +79 -0
  68. package/dist/hooks/config-schema.js.map +1 -0
  69. package/dist/hooks/executor.d.ts +16 -0
  70. package/dist/hooks/executor.d.ts.map +1 -0
  71. package/dist/hooks/executor.js +183 -0
  72. package/dist/hooks/executor.js.map +1 -0
  73. package/dist/hooks/index.d.ts +10 -0
  74. package/dist/hooks/index.d.ts.map +1 -0
  75. package/dist/hooks/index.js +6 -0
  76. package/dist/hooks/index.js.map +1 -0
  77. package/dist/hooks/registry.d.ts +23 -0
  78. package/dist/hooks/registry.d.ts.map +1 -0
  79. package/dist/hooks/registry.js +49 -0
  80. package/dist/hooks/registry.js.map +1 -0
  81. package/dist/hooks/types.d.ts +165 -0
  82. package/dist/hooks/types.d.ts.map +1 -0
  83. package/dist/hooks/types.js +25 -0
  84. package/dist/hooks/types.js.map +1 -0
  85. package/dist/hooks/variables.d.ts +22 -0
  86. package/dist/hooks/variables.d.ts.map +1 -0
  87. package/dist/hooks/variables.js +80 -0
  88. package/dist/hooks/variables.js.map +1 -0
  89. package/dist/index.d.ts +56 -1
  90. package/dist/index.d.ts.map +1 -1
  91. package/dist/index.js +37 -1
  92. package/dist/index.js.map +1 -1
  93. package/dist/knowledge/auto-memory.d.ts +1 -1
  94. package/dist/knowledge/auto-memory.d.ts.map +1 -1
  95. package/dist/knowledge/auto-memory.js +10 -10
  96. package/dist/knowledge/auto-memory.js.map +1 -1
  97. package/dist/knowledge/loader.js +12 -12
  98. package/dist/knowledge/loader.js.map +1 -1
  99. package/dist/mcp/arg-parser.d.ts +49 -0
  100. package/dist/mcp/arg-parser.d.ts.map +1 -0
  101. package/dist/mcp/arg-parser.js +357 -0
  102. package/dist/mcp/arg-parser.js.map +1 -0
  103. package/dist/mcp/client.d.ts +73 -0
  104. package/dist/mcp/client.d.ts.map +1 -0
  105. package/dist/mcp/client.js +376 -0
  106. package/dist/mcp/client.js.map +1 -0
  107. package/dist/mcp/config-schema.d.ts +64 -0
  108. package/dist/mcp/config-schema.d.ts.map +1 -0
  109. package/dist/mcp/config-schema.js +86 -0
  110. package/dist/mcp/config-schema.js.map +1 -0
  111. package/dist/mcp/config-writer.d.ts +41 -0
  112. package/dist/mcp/config-writer.d.ts.map +1 -0
  113. package/dist/mcp/config-writer.js +138 -0
  114. package/dist/mcp/config-writer.js.map +1 -0
  115. package/dist/mcp/env-safety.d.ts +12 -0
  116. package/dist/mcp/env-safety.d.ts.map +1 -0
  117. package/dist/mcp/env-safety.js +80 -0
  118. package/dist/mcp/env-safety.js.map +1 -0
  119. package/dist/mcp/expand-env.d.ts +14 -0
  120. package/dist/mcp/expand-env.d.ts.map +1 -0
  121. package/dist/mcp/expand-env.js +52 -0
  122. package/dist/mcp/expand-env.js.map +1 -0
  123. package/dist/mcp/loader.d.ts +81 -0
  124. package/dist/mcp/loader.d.ts.map +1 -0
  125. package/dist/mcp/loader.js +223 -0
  126. package/dist/mcp/loader.js.map +1 -0
  127. package/dist/mcp/name-mangling.d.ts +11 -0
  128. package/dist/mcp/name-mangling.d.ts.map +1 -0
  129. package/dist/mcp/name-mangling.js +82 -0
  130. package/dist/mcp/name-mangling.js.map +1 -0
  131. package/dist/mcp/oauth/callback-server.d.ts +25 -0
  132. package/dist/mcp/oauth/callback-server.d.ts.map +1 -0
  133. package/dist/mcp/oauth/callback-server.js +118 -0
  134. package/dist/mcp/oauth/callback-server.js.map +1 -0
  135. package/dist/mcp/oauth/provider.d.ts +80 -0
  136. package/dist/mcp/oauth/provider.d.ts.map +1 -0
  137. package/dist/mcp/oauth/provider.js +292 -0
  138. package/dist/mcp/oauth/provider.js.map +1 -0
  139. package/dist/mcp/oauth/token-storage.d.ts +42 -0
  140. package/dist/mcp/oauth/token-storage.d.ts.map +1 -0
  141. package/dist/mcp/oauth/token-storage.js +121 -0
  142. package/dist/mcp/oauth/token-storage.js.map +1 -0
  143. package/dist/mcp/permissions.d.ts +28 -0
  144. package/dist/mcp/permissions.d.ts.map +1 -0
  145. package/dist/mcp/permissions.js +105 -0
  146. package/dist/mcp/permissions.js.map +1 -0
  147. package/dist/mcp/registry.d.ts +150 -0
  148. package/dist/mcp/registry.d.ts.map +1 -0
  149. package/dist/mcp/registry.js +334 -0
  150. package/dist/mcp/registry.js.map +1 -0
  151. package/dist/mcp/resources.d.ts +7 -0
  152. package/dist/mcp/resources.d.ts.map +1 -0
  153. package/dist/mcp/resources.js +40 -0
  154. package/dist/mcp/resources.js.map +1 -0
  155. package/dist/mcp/tool-bridge.d.ts +16 -0
  156. package/dist/mcp/tool-bridge.d.ts.map +1 -0
  157. package/dist/mcp/tool-bridge.js +56 -0
  158. package/dist/mcp/tool-bridge.js.map +1 -0
  159. package/dist/mcp/trust.d.ts +31 -0
  160. package/dist/mcp/trust.d.ts.map +1 -0
  161. package/dist/mcp/trust.js +103 -0
  162. package/dist/mcp/trust.js.map +1 -0
  163. package/dist/mcp/types.d.ts +73 -0
  164. package/dist/mcp/types.d.ts.map +1 -0
  165. package/dist/mcp/types.js +13 -0
  166. package/dist/mcp/types.js.map +1 -0
  167. package/dist/permissions/session-store.d.ts +4 -1
  168. package/dist/permissions/session-store.d.ts.map +1 -1
  169. package/dist/permissions/session-store.js +6 -1
  170. package/dist/permissions/session-store.js.map +1 -1
  171. package/dist/plugins/consent.d.ts +87 -0
  172. package/dist/plugins/consent.d.ts.map +1 -0
  173. package/dist/plugins/consent.js +181 -0
  174. package/dist/plugins/consent.js.map +1 -0
  175. package/dist/plugins/enable-state.d.ts +34 -0
  176. package/dist/plugins/enable-state.d.ts.map +1 -0
  177. package/dist/plugins/enable-state.js +159 -0
  178. package/dist/plugins/enable-state.js.map +1 -0
  179. package/dist/plugins/installer.d.ts +64 -0
  180. package/dist/plugins/installer.d.ts.map +1 -0
  181. package/dist/plugins/installer.js +416 -0
  182. package/dist/plugins/installer.js.map +1 -0
  183. package/dist/plugins/integration.d.ts +91 -0
  184. package/dist/plugins/integration.d.ts.map +1 -0
  185. package/dist/plugins/integration.js +233 -0
  186. package/dist/plugins/integration.js.map +1 -0
  187. package/dist/plugins/loader.d.ts +69 -0
  188. package/dist/plugins/loader.d.ts.map +1 -0
  189. package/dist/plugins/loader.js +243 -0
  190. package/dist/plugins/loader.js.map +1 -0
  191. package/dist/plugins/manifest.d.ts +23 -0
  192. package/dist/plugins/manifest.d.ts.map +1 -0
  193. package/dist/plugins/manifest.js +143 -0
  194. package/dist/plugins/manifest.js.map +1 -0
  195. package/dist/plugins/marketplace.d.ts +100 -0
  196. package/dist/plugins/marketplace.d.ts.map +1 -0
  197. package/dist/plugins/marketplace.js +529 -0
  198. package/dist/plugins/marketplace.js.map +1 -0
  199. package/dist/plugins/paths.d.ts +44 -0
  200. package/dist/plugins/paths.d.ts.map +1 -0
  201. package/dist/plugins/paths.js +89 -0
  202. package/dist/plugins/paths.js.map +1 -0
  203. package/dist/plugins/refresh.d.ts +61 -0
  204. package/dist/plugins/refresh.d.ts.map +1 -0
  205. package/dist/plugins/refresh.js +98 -0
  206. package/dist/plugins/refresh.js.map +1 -0
  207. package/dist/plugins/registry.d.ts +40 -0
  208. package/dist/plugins/registry.d.ts.map +1 -0
  209. package/dist/plugins/registry.js +80 -0
  210. package/dist/plugins/registry.js.map +1 -0
  211. package/dist/plugins/types.d.ts +225 -0
  212. package/dist/plugins/types.d.ts.map +1 -0
  213. package/dist/plugins/types.js +16 -0
  214. package/dist/plugins/types.js.map +1 -0
  215. package/dist/plugins/user-config.d.ts +22 -0
  216. package/dist/plugins/user-config.d.ts.map +1 -0
  217. package/dist/plugins/user-config.js +96 -0
  218. package/dist/plugins/user-config.js.map +1 -0
  219. package/dist/skills/loader.d.ts +19 -0
  220. package/dist/skills/loader.d.ts.map +1 -0
  221. package/dist/skills/loader.js +197 -0
  222. package/dist/skills/loader.js.map +1 -0
  223. package/dist/skills/registry.d.ts +74 -0
  224. package/dist/skills/registry.d.ts.map +1 -0
  225. package/dist/skills/registry.js +136 -0
  226. package/dist/skills/registry.js.map +1 -0
  227. package/dist/skills/settings.d.ts +13 -0
  228. package/dist/skills/settings.d.ts.map +1 -0
  229. package/dist/skills/settings.js +100 -0
  230. package/dist/skills/settings.js.map +1 -0
  231. package/dist/tools/activate-skill.d.ts +5 -0
  232. package/dist/tools/activate-skill.d.ts.map +1 -0
  233. package/dist/tools/activate-skill.js +33 -0
  234. package/dist/tools/activate-skill.js.map +1 -0
  235. package/dist/tools/index.d.ts +1 -1
  236. package/dist/tools/todo-write.d.ts +1 -1
  237. package/dist/tools/web-fetch.d.ts.map +1 -1
  238. package/dist/tools/web-fetch.js +2 -1
  239. package/dist/tools/web-fetch.js.map +1 -1
  240. package/dist/types/index.d.ts +46 -1
  241. package/dist/types/index.d.ts.map +1 -1
  242. package/dist/types/index.js.map +1 -1
  243. package/dist/utils.d.ts +23 -2
  244. package/dist/utils.d.ts.map +1 -1
  245. package/dist/utils.js +76 -20
  246. package/dist/utils.js.map +1 -1
  247. package/dist/version.d.ts +2 -0
  248. package/dist/version.d.ts.map +1 -0
  249. package/dist/version.js +47 -0
  250. package/dist/version.js.map +1 -0
  251. package/package.json +2 -1
@@ -0,0 +1,529 @@
1
+ // @x-code-cli/core — Marketplace subscription + index parsing
2
+ //
3
+ // A marketplace is a curated catalog of plugins (its `marketplace.json`
4
+ // is a list of `{ name, source, ... }` entries). The CLI doesn't host
5
+ // its own marketplace — see [[plugin-marketplace-design]] §7.1 for the
6
+ // "subscribe to others" rationale. This module:
7
+ //
8
+ // 1. Reads + writes `known_marketplaces.json` (the user's subscription
9
+ // list) with reserved-name protection.
10
+ // 2. Fetches and caches marketplace indexes from either an HTTPS URL
11
+ // pointing to the raw marketplace.json or a git URL (we clone
12
+ // shallow and read `.claude-plugin/marketplace.json`, which is the
13
+ // path real Claude Code marketplaces publish at).
14
+ // 3. Parses marketplace.json into a typed `Marketplace`, normalising
15
+ // each plugin's `source` field from the on-disk wire form
16
+ // (string shortcut, `git-subdir`, `url`, …) into our internal
17
+ // `PluginSource` so the installer only deals with one shape.
18
+ // 4. Looks up `name@marketplace` plugin ids → install sources.
19
+ //
20
+ // Wire format vs internal `PluginSource`: the real Claude Code spec
21
+ // uses `source` as the discriminator with values `'git-subdir'`,
22
+ // `'url'`, etc., plus a plain string shortcut for monorepo subdirs
23
+ // (`"./plugins/foo"`). We map all of those to `PluginSource` so the
24
+ // rest of the system can stay on one shape. See
25
+ // [[normalizeMarketplaceSource]] for the conversion table.
26
+ //
27
+ // All disk + network I/O accepts an AbortSignal so Esc cancellations
28
+ // from the agent loop propagate cleanly.
29
+ import { execa } from 'execa';
30
+ import fs from 'node:fs/promises';
31
+ import os from 'node:os';
32
+ import path from 'node:path';
33
+ import { z } from 'zod';
34
+ import { debugLog } from '../utils.js';
35
+ import { knownMarketplacesPath, marketplaceDir, marketplaceIndexPath } from './paths.js';
36
+ // ── Reserved marketplace names ──────────────────────────────────────────
37
+ /** Names that may only be registered if their source matches the canonical
38
+ * upstream. Prevents a malicious actor from publishing
39
+ * `anthropic-marketplace` from their own repo and impersonating Anthropic.
40
+ * Maps to expected GitHub org. */
41
+ export const RESERVED_MARKETPLACE_NAMES = {
42
+ 'anthropic-marketplace': 'anthropics',
43
+ 'claude-plugins': 'anthropics',
44
+ 'x-code-official': 'woai3c',
45
+ };
46
+ // ── Source normalisation (wire format → internal PluginSource) ──────────
47
+ /** Convert a marketplace `source` field (in its on-disk wire form) into
48
+ * our internal `PluginSource`. Supports every shape we've seen in real
49
+ * Claude Code marketplaces:
50
+ *
51
+ * | Wire form | Normalised PluginSource |
52
+ * |-------------------------------------------------------------|--------------------------------------------------|
53
+ * | `"./plugins/foo"` or `"../shared/x"` | `{kind:'git', url:<marketplace-clone-url>, subdir:'plugins/foo'}` |
54
+ * | `"github:owner/repo[#ref]"` | `{kind:'github', owner, repo, ref?}` |
55
+ * | `"https://…"` or `"git@…"` | `{kind:'git', url}` |
56
+ * | `{source:'git-subdir', url, path, ref?, sha?}` | `{kind:'git', url, ref?, subdir:path}` |
57
+ * | `{source:'url', url, sha?}` | `{kind:'git', url}` |
58
+ * | `{source:'git', url, ref?, subdir?}` | `{kind:'git', url, ref?, subdir?}` |
59
+ * | `{source:'github', owner, repo, ref?, subdir?}` | `{kind:'github', owner, repo, ref?, subdir?}` |
60
+ * | `{source:'local', path}` | `{kind:'local', path}` |
61
+ * | `{kind:'git'\|'github'\|'local', …}` (our legacy form) | passes through |
62
+ *
63
+ * The relative-string form (`./plugins/foo`) needs the marketplace's
64
+ * own clone URL — that's the repo we'll subdir into. Passed in via
65
+ * `ctx.marketplaceCloneUrl`. Throws when the string is relative but
66
+ * no context was provided (HTTPS-fetched marketplaces can't host
67
+ * relative-path plugins for obvious reasons).
68
+ *
69
+ * The `sha` field from `git-subdir` / `url` is intentionally dropped
70
+ * today — we don't yet verify integrity. Reserved for a follow-up. */
71
+ export function normalizeMarketplaceSource(raw, ctx = {}) {
72
+ if (typeof raw === 'string') {
73
+ if (raw.startsWith('./') || raw.startsWith('../')) {
74
+ const cloneUrl = ctx.marketplaceCloneUrl;
75
+ if (!cloneUrl) {
76
+ throw new Error(`relative source "${raw}" requires the marketplace's own clone URL, but the marketplace was fetched without one (typically because it was loaded from a raw HTTPS URL rather than a git repo)`);
77
+ }
78
+ const subdir = raw.replace(/^\.\//, '');
79
+ return { kind: 'git', url: cloneUrl, subdir };
80
+ }
81
+ if (raw.startsWith('github:')) {
82
+ const m = raw.match(/^github:([^/]+)\/(.+?)(?:#(.+))?$/i);
83
+ if (!m)
84
+ throw new Error(`invalid github source: ${raw}`);
85
+ return { kind: 'github', owner: m[1], repo: m[2], ref: m[3] };
86
+ }
87
+ if (/^https?:\/\//i.test(raw) || raw.startsWith('git@')) {
88
+ return { kind: 'git', url: raw };
89
+ }
90
+ throw new Error(`unrecognised source string: ${raw}`);
91
+ }
92
+ if (raw && typeof raw === 'object') {
93
+ const o = raw;
94
+ const disc = (typeof o.source === 'string' ? o.source : o.kind);
95
+ // Capture the optional `sha` integrity pin. We accept it as a hex
96
+ // string ≥7 chars (matches Git's short-sha tolerance; the installer
97
+ // does a prefix compare so a short sha still works). Reject non-hex
98
+ // shapes early — a typo'd value would otherwise mask a real attack.
99
+ const rawSha = typeof o.sha === 'string' ? o.sha.trim().toLowerCase() : undefined;
100
+ const expectedSha = rawSha && /^[0-9a-f]{7,40}$/.test(rawSha) ? rawSha : undefined;
101
+ if (disc === 'git-subdir') {
102
+ if (typeof o.url !== 'string' || typeof o.path !== 'string') {
103
+ throw new Error('git-subdir source requires `url` and `path`');
104
+ }
105
+ return {
106
+ kind: 'git',
107
+ url: o.url,
108
+ subdir: o.path,
109
+ ref: typeof o.ref === 'string' ? o.ref : undefined,
110
+ expectedSha,
111
+ };
112
+ }
113
+ if (disc === 'url') {
114
+ if (typeof o.url !== 'string')
115
+ throw new Error('url source requires `url`');
116
+ return { kind: 'git', url: o.url, expectedSha };
117
+ }
118
+ if (disc === 'git') {
119
+ if (typeof o.url !== 'string')
120
+ throw new Error('git source requires `url`');
121
+ return {
122
+ kind: 'git',
123
+ url: o.url,
124
+ ref: typeof o.ref === 'string' ? o.ref : undefined,
125
+ subdir: typeof o.subdir === 'string' ? o.subdir : undefined,
126
+ expectedSha,
127
+ };
128
+ }
129
+ if (disc === 'github') {
130
+ // Two real-world shapes for github sources:
131
+ // { owner, repo, ref?, subdir? } — separate owner / repo
132
+ // { repo: "owner/repo" } — combined slash-form (seen in real
133
+ // claude-plugins-official entries)
134
+ let owner = typeof o.owner === 'string' ? o.owner : undefined;
135
+ let repo = typeof o.repo === 'string' ? o.repo : undefined;
136
+ if (!owner && repo && repo.includes('/')) {
137
+ const slash = repo.indexOf('/');
138
+ owner = repo.slice(0, slash);
139
+ repo = repo.slice(slash + 1);
140
+ }
141
+ if (!owner || !repo) {
142
+ throw new Error('github source requires `owner` + `repo` or `repo: "owner/repo"`');
143
+ }
144
+ const ref = typeof o.ref === 'string' ? o.ref : typeof o.commit === 'string' ? o.commit : undefined;
145
+ return {
146
+ kind: 'github',
147
+ owner,
148
+ repo,
149
+ ref,
150
+ subdir: typeof o.subdir === 'string' ? o.subdir : undefined,
151
+ expectedSha,
152
+ };
153
+ }
154
+ if (disc === 'local') {
155
+ if (typeof o.path !== 'string')
156
+ throw new Error('local source requires `path`');
157
+ return { kind: 'local', path: o.path };
158
+ }
159
+ throw new Error(`unknown source discriminator: ${disc ?? '(missing)'} — accepted: git-subdir, url, git, github, local`);
160
+ }
161
+ throw new Error('source must be a string or object');
162
+ }
163
+ // ── Zod schemas for marketplace.json ────────────────────────────────────
164
+ // `source` is validated as "string OR object" at the zod layer; the real
165
+ // shape check happens inside `normalizeMarketplaceSource` because the
166
+ // union has too many discriminator forms (some use `source`, some use
167
+ // `kind`) for zod's discriminated union to handle cleanly.
168
+ const wireSourceSchema = z.union([z.string().min(1), z.record(z.string(), z.unknown())]);
169
+ const wireEntrySchema = z.object({
170
+ name: z.string().min(1),
171
+ description: z.string().optional(),
172
+ category: z.string().optional(),
173
+ verified: z.boolean().optional(),
174
+ source: wireSourceSchema,
175
+ version: z.string().optional(),
176
+ homepage: z.string().optional(),
177
+ keywords: z.array(z.string()).optional(),
178
+ // Real Claude Code plugin entries also carry top-level `author`. Not
179
+ // currently part of MarketplaceEntry but accept to avoid rejecting.
180
+ author: z.unknown().optional(),
181
+ });
182
+ const wireMarketplaceSchema = z.object({
183
+ schemaVersion: z.string().optional(),
184
+ name: z.string().min(1),
185
+ displayName: z.string().optional(),
186
+ description: z.string().optional(),
187
+ owner: z
188
+ .object({
189
+ name: z.string().optional(),
190
+ url: z.string().optional(),
191
+ email: z.string().optional(),
192
+ })
193
+ .optional(),
194
+ plugins: z.array(wireEntrySchema),
195
+ });
196
+ export class MarketplaceParseError extends Error {
197
+ sourceLabel;
198
+ constructor(message, sourceLabel) {
199
+ super(message);
200
+ this.sourceLabel = sourceLabel;
201
+ this.name = 'MarketplaceParseError';
202
+ }
203
+ }
204
+ /** Parse + validate a marketplace.json string and normalise every
205
+ * plugin's `source` into our internal `PluginSource`. `sourceLabel` is
206
+ * included in error messages so the user knows which marketplace
207
+ * failed. */
208
+ export function parseMarketplace(raw, sourceLabel, ctx = {}) {
209
+ let json;
210
+ try {
211
+ json = JSON.parse(raw);
212
+ }
213
+ catch (err) {
214
+ throw new MarketplaceParseError(`not valid JSON: ${err instanceof Error ? err.message : String(err)}`, sourceLabel);
215
+ }
216
+ const result = wireMarketplaceSchema.safeParse(json);
217
+ if (!result.success) {
218
+ const issues = result.error.issues.map((i) => `${i.path.join('.') || '(root)'}: ${i.message}`).join('; ');
219
+ throw new MarketplaceParseError(`invalid marketplace.json — ${issues}`, sourceLabel);
220
+ }
221
+ const normalised = [];
222
+ const sourceErrors = [];
223
+ for (let i = 0; i < result.data.plugins.length; i++) {
224
+ const entry = result.data.plugins[i];
225
+ try {
226
+ const source = normalizeMarketplaceSource(entry.source, ctx);
227
+ normalised.push({
228
+ name: entry.name,
229
+ description: entry.description,
230
+ category: entry.category,
231
+ verified: entry.verified,
232
+ version: entry.version,
233
+ homepage: entry.homepage,
234
+ keywords: entry.keywords,
235
+ source,
236
+ });
237
+ }
238
+ catch (err) {
239
+ // One bad plugin entry doesn't kill the marketplace — most users
240
+ // care about other plugins in the catalog. Collect and surface in
241
+ // a single error AFTER trying every entry.
242
+ sourceErrors.push(`plugins.${i} (${entry.name}): ${err instanceof Error ? err.message : String(err)}`);
243
+ }
244
+ }
245
+ if (normalised.length === 0 && sourceErrors.length > 0) {
246
+ throw new MarketplaceParseError(`no plugin entries parsed — ${sourceErrors.join('; ')}`, sourceLabel);
247
+ }
248
+ if (sourceErrors.length > 0) {
249
+ debugLog('plugins.marketplace-source-errors', `${sourceLabel}: ${sourceErrors.join(' | ')}`);
250
+ }
251
+ // `name` is the subscription alias the caller passed (sourceLabel),
252
+ // not the upstream marketplace.json `name` field. Storage paths, install
253
+ // ids, and lookups all key off the alias — having `parseMarketplace`
254
+ // leak the upstream name through here is what caused `plugin marketplace
255
+ // info <alias>` to fail and `plugin search` to tag plugins with the
256
+ // wrong marketplace. We preserve the upstream name on `upstreamName` so
257
+ // `info` can still show it when it differs.
258
+ return {
259
+ schemaVersion: result.data.schemaVersion ?? '1',
260
+ name: sourceLabel,
261
+ upstreamName: result.data.name !== sourceLabel ? result.data.name : undefined,
262
+ displayName: result.data.displayName,
263
+ description: result.data.description,
264
+ owner: result.data.owner ? { name: result.data.owner.name, url: result.data.owner.url } : undefined,
265
+ plugins: normalised,
266
+ };
267
+ }
268
+ // ── known_marketplaces.json: read / write ───────────────────────────────
269
+ /** Fresh empty state. Function (not const) so each call returns a fresh
270
+ * `marketplaces: []` — a shared constant would let one caller's mutation
271
+ * leak into the next caller's "empty" result. */
272
+ function freshKnown() {
273
+ return { marketplaces: [] };
274
+ }
275
+ export async function readKnownMarketplaces() {
276
+ const file = knownMarketplacesPath();
277
+ try {
278
+ const raw = await fs.readFile(file, 'utf-8');
279
+ const parsed = JSON.parse(raw);
280
+ if (!parsed || typeof parsed !== 'object')
281
+ return freshKnown();
282
+ const obj = parsed;
283
+ const list = Array.isArray(obj.marketplaces) ? obj.marketplaces : [];
284
+ return {
285
+ marketplaces: list.filter((m) => m && typeof m.name === 'string' && typeof m.source === 'string'),
286
+ strictKnownMarketplaces: typeof obj.strictKnownMarketplaces === 'boolean' ? obj.strictKnownMarketplaces : undefined,
287
+ blockedPlugins: Array.isArray(obj.blockedPlugins)
288
+ ? obj.blockedPlugins.filter((s) => typeof s === 'string')
289
+ : undefined,
290
+ };
291
+ }
292
+ catch (err) {
293
+ if (err.code === 'ENOENT')
294
+ return freshKnown();
295
+ debugLog('plugins.known-marketplaces-read-failed', String(err));
296
+ return freshKnown();
297
+ }
298
+ }
299
+ async function writeKnownMarketplaces(km) {
300
+ const file = knownMarketplacesPath();
301
+ await fs.mkdir(path.dirname(file), { recursive: true });
302
+ // Read-modify-write so any unrelated future fields aren't clobbered.
303
+ let existing = {};
304
+ try {
305
+ const raw = await fs.readFile(file, 'utf-8');
306
+ const parsed = JSON.parse(raw);
307
+ if (parsed && typeof parsed === 'object')
308
+ existing = parsed;
309
+ }
310
+ catch {
311
+ // first write
312
+ }
313
+ existing.marketplaces = km.marketplaces;
314
+ if (km.strictKnownMarketplaces !== undefined)
315
+ existing.strictKnownMarketplaces = km.strictKnownMarketplaces;
316
+ if (km.blockedPlugins !== undefined)
317
+ existing.blockedPlugins = km.blockedPlugins;
318
+ await fs.writeFile(file, JSON.stringify(existing, null, 2) + '\n', 'utf-8');
319
+ }
320
+ /** Ensure the default marketplace subscriptions exist. Called from CLI
321
+ * startup so a fresh install lands with Anthropic's official
322
+ * marketplace pre-subscribed and `/plugin search` returns hits without
323
+ * the user having to manually add anything. Idempotent — never
324
+ * overwrites an existing entry, so a user who removed the
325
+ * subscription stays unsubscribed.
326
+ *
327
+ * Target is `anthropics/claude-plugins-official` (203 plugins) rather
328
+ * than the smaller bundled marketplace in `anthropics/claude-code`
329
+ * itself — the dedicated repo is the canonical discovery surface. */
330
+ export async function ensureDefaultMarketplaces() {
331
+ const km = await readKnownMarketplaces();
332
+ const haveAnthropic = km.marketplaces.some((m) => m.name === 'anthropic-marketplace');
333
+ if (haveAnthropic)
334
+ return;
335
+ // Use addKnownMarketplace so the reserved-name check fires — it
336
+ // sets `reservedName: true` + `officialSource: 'anthropics'`.
337
+ try {
338
+ await addKnownMarketplace({
339
+ name: 'anthropic-marketplace',
340
+ source: 'github:anthropics/claude-plugins-official',
341
+ });
342
+ }
343
+ catch (err) {
344
+ debugLog('plugins.default-marketplace-add-failed', String(err));
345
+ }
346
+ }
347
+ /** Register a new marketplace subscription. Rejects reserved names whose
348
+ * source doesn't match the canonical upstream — see
349
+ * RESERVED_MARKETPLACE_NAMES. Idempotent: re-adding the same name
350
+ * updates the source. */
351
+ export async function addKnownMarketplace(entry) {
352
+ const reservedOrg = RESERVED_MARKETPLACE_NAMES[entry.name];
353
+ if (reservedOrg !== undefined) {
354
+ if (!sourceMatchesOrg(entry.source, reservedOrg)) {
355
+ throw new Error(`Marketplace name "${entry.name}" is reserved; only sources under github:${reservedOrg}/* may use it. ` +
356
+ `Got: ${entry.source}`);
357
+ }
358
+ entry.reservedName = true;
359
+ entry.officialSource = reservedOrg;
360
+ }
361
+ const km = await readKnownMarketplaces();
362
+ const idx = km.marketplaces.findIndex((m) => m.name === entry.name);
363
+ if (idx >= 0) {
364
+ km.marketplaces[idx] = entry;
365
+ }
366
+ else {
367
+ km.marketplaces.push(entry);
368
+ }
369
+ await writeKnownMarketplaces(km);
370
+ }
371
+ export async function removeKnownMarketplace(name) {
372
+ const km = await readKnownMarketplaces();
373
+ const before = km.marketplaces.length;
374
+ km.marketplaces = km.marketplaces.filter((m) => m.name !== name);
375
+ if (km.marketplaces.length === before)
376
+ return 'noop';
377
+ await writeKnownMarketplaces(km);
378
+ return 'removed';
379
+ }
380
+ function sourceMatchesOrg(source, expectedOrg) {
381
+ // Accepts `github:org/repo[...]` and `https://github.com/org/repo[...]`.
382
+ const ghShort = source.match(/^github:([^/]+)\//i);
383
+ if (ghShort)
384
+ return ghShort[1].toLowerCase() === expectedOrg.toLowerCase();
385
+ const ghHttps = source.match(/^https?:\/\/github\.com\/([^/]+)\//i);
386
+ if (ghHttps)
387
+ return ghHttps[1].toLowerCase() === expectedOrg.toLowerCase();
388
+ return false;
389
+ }
390
+ /** Pull a fresh marketplace.json into the local cache and parse it.
391
+ * Supports two source shapes:
392
+ *
393
+ * - `https://...` or `http://...` — direct URL to marketplace.json
394
+ * - anything else (`github:owner/repo`, git URL) — shallow clone,
395
+ * then read `.claude-plugin/marketplace.json` (the canonical
396
+ * Claude Code path — see `anthropics/claude-code` and
397
+ * `anthropics/claude-plugins-official` for reference layouts)
398
+ *
399
+ * Writes the parsed file to ~/.x-code/plugins/marketplaces/<name>/marketplace.json
400
+ * before returning. */
401
+ export async function fetchMarketplace(entry, opts = {}) {
402
+ const cachedPath = marketplaceIndexPath(entry.name);
403
+ if (opts.maxAgeMs !== undefined) {
404
+ const fresh = await isFreshEnough(cachedPath, opts.maxAgeMs);
405
+ if (fresh) {
406
+ const raw = await fs.readFile(cachedPath, 'utf-8');
407
+ return parseMarketplace(raw, entry.name, contextForKnownEntry(entry));
408
+ }
409
+ }
410
+ const isHttp = /^https?:\/\//i.test(entry.source) && /\.json($|\?)/i.test(entry.source);
411
+ const rawJson = isHttp
412
+ ? await fetchHttpJson(entry.source, opts.signal)
413
+ : await fetchViaShallowClone(entry.source, opts.signal);
414
+ const marketplace = parseMarketplace(rawJson, entry.name, contextForKnownEntry(entry));
415
+ await fs.mkdir(marketplaceDir(entry.name), { recursive: true });
416
+ await fs.writeFile(cachedPath, rawJson, 'utf-8');
417
+ return marketplace;
418
+ }
419
+ /** Build the `ParseMarketplaceContext` from a known marketplace entry.
420
+ * For git-cloned marketplaces this provides the clone URL so plugin
421
+ * entries with relative-string sources like `"./plugins/foo"` resolve
422
+ * to that subdir of the marketplace's own repo. For raw-HTTPS
423
+ * marketplaces no clone URL exists; relative sources in such
424
+ * marketplaces fail to normalise (correctly — there's no repo to
425
+ * refer to). */
426
+ function contextForKnownEntry(entry) {
427
+ const isRawHttps = /^https?:\/\//i.test(entry.source) && /\.json($|\?)/i.test(entry.source);
428
+ if (isRawHttps)
429
+ return {};
430
+ return { marketplaceCloneUrl: resolveCloneUrl(entry.source) };
431
+ }
432
+ async function isFreshEnough(filePath, maxAgeMs) {
433
+ try {
434
+ const stat = await fs.stat(filePath);
435
+ return Date.now() - stat.mtimeMs <= maxAgeMs;
436
+ }
437
+ catch {
438
+ return false;
439
+ }
440
+ }
441
+ async function fetchHttpJson(url, signal) {
442
+ const res = await fetch(url, { signal });
443
+ if (!res.ok) {
444
+ throw new Error(`HTTP ${res.status} ${res.statusText} fetching ${url}`);
445
+ }
446
+ return res.text();
447
+ }
448
+ /** Clone the repo at the given source into a temp dir (depth 1) and
449
+ * return the contents of the marketplace index. Probes the canonical
450
+ * `.claude-plugin/marketplace.json` first and falls back to a
451
+ * root-level `marketplace.json` for non-standard layouts. The clone
452
+ * is removed before returning regardless of success. */
453
+ async function fetchViaShallowClone(source, signal) {
454
+ const cloneUrl = resolveCloneUrl(source);
455
+ const tempDir = await fs.mkdtemp(path.join(os.tmpdir(), 'xc-marketplace-'));
456
+ try {
457
+ await execa('git', ['clone', '--depth', '1', cloneUrl, tempDir], { signal, stdio: 'pipe' });
458
+ const candidates = [
459
+ path.join(tempDir, '.claude-plugin', 'marketplace.json'),
460
+ path.join(tempDir, 'marketplace.json'),
461
+ ];
462
+ for (const candidate of candidates) {
463
+ try {
464
+ return await fs.readFile(candidate, 'utf-8');
465
+ }
466
+ catch {
467
+ // try the next candidate
468
+ }
469
+ }
470
+ throw new Error(`marketplace repo ${cloneUrl} has no .claude-plugin/marketplace.json (also tried root marketplace.json)`);
471
+ }
472
+ finally {
473
+ await fs.rm(tempDir, { recursive: true, force: true }).catch(() => {
474
+ /* best effort */
475
+ });
476
+ }
477
+ }
478
+ /** Turn a source string into something `git clone` understands:
479
+ * `github:owner/repo` → `https://github.com/owner/repo.git`. Anything
480
+ * else is passed through (real git URLs, ssh:, etc.). */
481
+ export function resolveCloneUrl(source) {
482
+ const m = source.match(/^github:([^/]+)\/(.+?)(?:\.git)?$/i);
483
+ if (m) {
484
+ return `https://github.com/${m[1]}/${m[2]}.git`;
485
+ }
486
+ return source;
487
+ }
488
+ // ── Lookup helpers ──────────────────────────────────────────────────────
489
+ /** Read every cached marketplace index. Used by `/plugin search` and
490
+ * `/plugin install <name@marketplace>` lookups. Marketplaces with broken
491
+ * cached indexes are skipped + logged; one bad marketplace doesn't break
492
+ * the others. */
493
+ export async function readAllCachedMarketplaces() {
494
+ const km = await readKnownMarketplaces();
495
+ const out = [];
496
+ for (const entry of km.marketplaces) {
497
+ try {
498
+ const raw = await fs.readFile(marketplaceIndexPath(entry.name), 'utf-8');
499
+ out.push(parseMarketplace(raw, entry.name, contextForKnownEntry(entry)));
500
+ }
501
+ catch (err) {
502
+ debugLog('plugins.marketplace-cache-read-failed', `${entry.name}: ${String(err)}`);
503
+ }
504
+ }
505
+ return out;
506
+ }
507
+ /** Find one plugin entry by `name@marketplace` id. Returns `undefined`
508
+ * when the marketplace isn't subscribed or the plugin isn't listed. */
509
+ export async function lookupPlugin(pluginId) {
510
+ const at = pluginId.lastIndexOf('@');
511
+ if (at <= 0)
512
+ return undefined;
513
+ const pluginName = pluginId.slice(0, at);
514
+ const marketplaceName = pluginId.slice(at + 1);
515
+ const km = await readKnownMarketplaces();
516
+ const known = km.marketplaces.find((m) => m.name === marketplaceName);
517
+ try {
518
+ const raw = await fs.readFile(marketplaceIndexPath(marketplaceName), 'utf-8');
519
+ const m = parseMarketplace(raw, marketplaceName, known ? contextForKnownEntry(known) : {});
520
+ const entry = m.plugins.find((p) => p.name === pluginName);
521
+ if (!entry)
522
+ return undefined;
523
+ return { marketplace: m, entry };
524
+ }
525
+ catch {
526
+ return undefined;
527
+ }
528
+ }
529
+ //# sourceMappingURL=marketplace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marketplace.js","sourceRoot":"","sources":["../../src/plugins/marketplace.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,wEAAwE;AACxE,sEAAsE;AACtE,uEAAuE;AACvE,gDAAgD;AAChD,EAAE;AACF,yEAAyE;AACzE,4CAA4C;AAC5C,uEAAuE;AACvE,mEAAmE;AACnE,wEAAwE;AACxE,uDAAuD;AACvD,uEAAuE;AACvE,+DAA+D;AAC/D,mEAAmE;AACnE,kEAAkE;AAClE,iEAAiE;AACjE,EAAE;AACF,oEAAoE;AACpE,iEAAiE;AACjE,mEAAmE;AACnE,oEAAoE;AACpE,gDAAgD;AAChD,2DAA2D;AAC3D,EAAE;AACF,qEAAqE;AACrE,yCAAyC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAA;AAE7B,OAAO,EAAE,MAAM,kBAAkB,CAAA;AACjC,OAAO,EAAE,MAAM,SAAS,CAAA;AACxB,OAAO,IAAI,MAAM,WAAW,CAAA;AAE5B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,qBAAqB,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAGxF,2EAA2E;AAE3E;;;mCAGmC;AACnC,MAAM,CAAC,MAAM,0BAA0B,GAAqC;IAC1E,uBAAuB,EAAE,YAAY;IACrC,gBAAgB,EAAE,YAAY;IAC9B,iBAAiB,EAAE,QAAQ;CAC5B,CAAA;AAED,2EAA2E;AAE3E;;;;;;;;;;;;;;;;;;;;;;;uEAuBuE;AACvE,MAA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CAChC,QAAgB;IAEhB,MAAM,EAAE,GAAG,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IACpC,IAAI,EAAE,IAAI,CAAC;QAAE,OAAO,SAAS,CAAA;IAC7B,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IACxC,MAAM,eAAe,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA;IAE9C,MAAM,EAAE,GAAG,MAAM,qBAAqB,EAAE,CAAA;IACxC,MAAM,KAAK,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe,CAAC,CAAA;IAErE,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,oBAAoB,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC,CAAA;QAC7E,MAAM,CAAC,GAAG,gBAAgB,CAAC,GAAG,EAAE,eAAe,EAAE,KAAK,CAAC,CAAC,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;QAC1F,MAAM,KAAK,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,CAAA;QAC1D,IAAI,CAAC,KAAK;YAAE,OAAO,SAAS,CAAA;QAC5B,OAAO,EAAE,WAAW,EAAE,CAAC,EAAE,KAAK,EAAE,CAAA;IAClC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC"}
@@ -0,0 +1,44 @@
1
+ /** Root of the plugin subsystem. Two override knobs, checked in order:
2
+ * - `XC_PLUGINS_DIR` — plugin-specific override (parallels
3
+ * `XC_AGENTS_DIR` / `XC_SKILLS_DIR`; preferred when tests want to
4
+ * isolate JUST plugins without redirecting MCP / config / OAuth).
5
+ * - `X_CODE_HOME` — broad override of the whole `~/.x-code/` root
6
+ * (resolved via {@link userXcodeDir}). Reroutes plugins along with
7
+ * config, MCP state, etc. */
8
+ export declare function pluginsRoot(): string;
9
+ /** ~/.x-code/plugins/known_marketplaces.json */
10
+ export declare function knownMarketplacesPath(): string;
11
+ /** ~/.x-code/plugins/marketplaces/<name>/ */
12
+ export declare function marketplaceDir(name: string): string;
13
+ /** ~/.x-code/plugins/marketplaces/<name>/marketplace.json */
14
+ export declare function marketplaceIndexPath(name: string): string;
15
+ /** ~/.x-code/plugins/cache/<marketplace>/<plugin>/ — all versions live
16
+ * under this directory; the active version is whichever the installer
17
+ * recorded most recently in installed_plugins.json. */
18
+ export declare function pluginCacheParent(marketplace: string, plugin: string): string;
19
+ /** ~/.x-code/plugins/cache/<marketplace>/<plugin>/<version>/ */
20
+ export declare function pluginCacheDir(marketplace: string, plugin: string, version: string): string;
21
+ /** ~/.x-code/plugins/data/<sanitised-plugin-id>/ — persistent per-plugin
22
+ * data dir that survives upgrades. Plugin IDs ("name@marketplace") are
23
+ * sanitised so the `@` and any accidental path separators don't break
24
+ * on Windows. */
25
+ export declare function pluginDataDir(pluginId: string): string;
26
+ /** ~/.x-code/plugins/installed_plugins.json */
27
+ export declare function installedPluginsPath(): string;
28
+ /** <cwd>/.x-code/plugins/ — rare; used when a project ships its own
29
+ * plugins committed to the repo (vs. installing from a marketplace).
30
+ * The loader scans this in addition to the user-scope cache. */
31
+ export declare function projectPluginsDir(cwd: string): string;
32
+ /** Relative manifest paths the loader probes, in priority order. The first
33
+ * one found wins. We deliberately accept Claude Code's path so plugins
34
+ * authored for Claude Code install in x-code-cli without modification —
35
+ * see [[plugin-marketplace-design]] §3 (cross-product compatibility). */
36
+ export declare const MANIFEST_CANDIDATES: ReadonlyArray<{
37
+ format: 'native' | 'claude' | 'bare';
38
+ rel: string;
39
+ }>;
40
+ /** Gemini's manifest filename. Probed only to produce a helpful error
41
+ * message when a user tries to install a Gemini-only extension —
42
+ * installer rejects with a pointer to the design doc. */
43
+ export declare const GEMINI_MANIFEST_REL = "gemini-extension.json";
44
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/plugins/paths.ts"],"names":[],"mappings":"AAwBA;;;;;;gCAMgC;AAChC,wBAAgB,WAAW,IAAI,MAAM,CAIpC;AAED,gDAAgD;AAChD,wBAAgB,qBAAqB,IAAI,MAAM,CAE9C;AAED,6CAA6C;AAC7C,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,6DAA6D;AAC7D,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;wDAEwD;AACxD,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAE7E;AAED,gEAAgE;AAChE,wBAAgB,cAAc,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAE3F;AAED;;;kBAGkB;AAClB,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAGtD;AAED,+CAA+C;AAC/C,wBAAgB,oBAAoB,IAAI,MAAM,CAE7C;AAED;;iEAEiE;AACjE,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAErD;AAID;;;0EAG0E;AAC1E,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC;IAAE,MAAM,EAAE,QAAQ,GAAG,QAAQ,GAAG,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAIpG,CAAA;AAED;;0DAE0D;AAC1D,eAAO,MAAM,mBAAmB,0BAA0B,CAAA"}