@stigmer/plugin-package 0.1.0-dev.20261017020314.g644422724c27

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 (273) hide show
  1. package/LICENSE +194 -0
  2. package/README.md +72 -0
  3. package/client/archive.d.ts +27 -0
  4. package/client/archive.d.ts.map +1 -0
  5. package/client/archive.js +38 -0
  6. package/client/archive.js.map +1 -0
  7. package/client/builtin.d.ts +37 -0
  8. package/client/builtin.d.ts.map +1 -0
  9. package/client/builtin.js +49 -0
  10. package/client/builtin.js.map +1 -0
  11. package/client/ignore/defaults.d.ts +2 -0
  12. package/client/ignore/defaults.d.ts.map +1 -0
  13. package/client/ignore/defaults.js +140 -0
  14. package/client/ignore/defaults.js.map +1 -0
  15. package/client/ignore/match.d.ts +3 -0
  16. package/client/ignore/match.d.ts.map +1 -0
  17. package/client/ignore/match.js +166 -0
  18. package/client/ignore/match.js.map +1 -0
  19. package/client/ignore/matcher.d.ts +50 -0
  20. package/client/ignore/matcher.d.ts.map +1 -0
  21. package/client/ignore/matcher.js +116 -0
  22. package/client/ignore/matcher.js.map +1 -0
  23. package/client/ignore/pattern.d.ts +13 -0
  24. package/client/ignore/pattern.d.ts.map +1 -0
  25. package/client/ignore/pattern.js +119 -0
  26. package/client/ignore/pattern.js.map +1 -0
  27. package/client/prepare-eval.d.ts +62 -0
  28. package/client/prepare-eval.d.ts.map +1 -0
  29. package/client/prepare-eval.js +60 -0
  30. package/client/prepare-eval.js.map +1 -0
  31. package/client/prepare.d.ts +99 -0
  32. package/client/prepare.d.ts.map +1 -0
  33. package/client/prepare.js +89 -0
  34. package/client/prepare.js.map +1 -0
  35. package/client/presentation.d.ts +19 -0
  36. package/client/presentation.d.ts.map +1 -0
  37. package/client/presentation.js +44 -0
  38. package/client/presentation.js.map +1 -0
  39. package/client/refs.d.ts +76 -0
  40. package/client/refs.d.ts.map +1 -0
  41. package/client/refs.js +123 -0
  42. package/client/refs.js.map +1 -0
  43. package/client/release.d.ts +20 -0
  44. package/client/release.d.ts.map +1 -0
  45. package/client/release.js +28 -0
  46. package/client/release.js.map +1 -0
  47. package/client/reroot.d.ts +21 -0
  48. package/client/reroot.d.ts.map +1 -0
  49. package/client/reroot.js +37 -0
  50. package/client/reroot.js.map +1 -0
  51. package/client/select.d.ts +74 -0
  52. package/client/select.d.ts.map +1 -0
  53. package/client/select.js +121 -0
  54. package/client/select.js.map +1 -0
  55. package/client/vocabulary.d.ts +13 -0
  56. package/client/vocabulary.d.ts.map +1 -0
  57. package/client/vocabulary.js +17 -0
  58. package/client/vocabulary.js.map +1 -0
  59. package/client.d.ts +51 -0
  60. package/client.d.ts.map +1 -0
  61. package/client.js +51 -0
  62. package/client.js.map +1 -0
  63. package/detect.d.ts +83 -0
  64. package/detect.d.ts.map +1 -0
  65. package/detect.js +210 -0
  66. package/detect.js.map +1 -0
  67. package/dialects/claude.d.ts +34 -0
  68. package/dialects/claude.d.ts.map +1 -0
  69. package/dialects/claude.js +84 -0
  70. package/dialects/claude.js.map +1 -0
  71. package/dialects/codex.d.ts +20 -0
  72. package/dialects/codex.d.ts.map +1 -0
  73. package/dialects/codex.js +21 -0
  74. package/dialects/codex.js.map +1 -0
  75. package/dialects/cursor.d.ts +25 -0
  76. package/dialects/cursor.d.ts.map +1 -0
  77. package/dialects/cursor.js +66 -0
  78. package/dialects/cursor.js.map +1 -0
  79. package/dialects/manifest.d.ts +164 -0
  80. package/dialects/manifest.d.ts.map +1 -0
  81. package/dialects/manifest.js +256 -0
  82. package/dialects/manifest.js.map +1 -0
  83. package/dialects/open.d.ts +19 -0
  84. package/dialects/open.d.ts.map +1 -0
  85. package/dialects/open.js +49 -0
  86. package/dialects/open.js.map +1 -0
  87. package/documents.d.ts +58 -0
  88. package/documents.d.ts.map +1 -0
  89. package/documents.js +121 -0
  90. package/documents.js.map +1 -0
  91. package/evals/eval-dir.d.ts +59 -0
  92. package/evals/eval-dir.d.ts.map +1 -0
  93. package/evals/eval-dir.js +84 -0
  94. package/evals/eval-dir.js.map +1 -0
  95. package/evals/fields.d.ts +78 -0
  96. package/evals/fields.d.ts.map +1 -0
  97. package/evals/fields.js +156 -0
  98. package/evals/fields.js.map +1 -0
  99. package/evals/glob.d.ts +40 -0
  100. package/evals/glob.d.ts.map +1 -0
  101. package/evals/glob.js +146 -0
  102. package/evals/glob.js.map +1 -0
  103. package/evals/graders.d.ts +52 -0
  104. package/evals/graders.d.ts.map +1 -0
  105. package/evals/graders.js +279 -0
  106. package/evals/graders.js.map +1 -0
  107. package/evals/markdown.d.ts +24 -0
  108. package/evals/markdown.d.ts.map +1 -0
  109. package/evals/markdown.js +48 -0
  110. package/evals/markdown.js.map +1 -0
  111. package/evals/mocks.d.ts +50 -0
  112. package/evals/mocks.d.ts.map +1 -0
  113. package/evals/mocks.js +182 -0
  114. package/evals/mocks.js.map +1 -0
  115. package/evals/read-eval-suite.d.ts +110 -0
  116. package/evals/read-eval-suite.d.ts.map +1 -0
  117. package/evals/read-eval-suite.js +603 -0
  118. package/evals/read-eval-suite.js.map +1 -0
  119. package/evals/summary.d.ts +61 -0
  120. package/evals/summary.d.ts.map +1 -0
  121. package/evals/summary.js +69 -0
  122. package/evals/summary.js.map +1 -0
  123. package/evals/types.d.ts +203 -0
  124. package/evals/types.d.ts.map +1 -0
  125. package/evals/types.js +21 -0
  126. package/evals/types.js.map +1 -0
  127. package/files.d.ts +135 -0
  128. package/files.d.ts.map +1 -0
  129. package/files.js +209 -0
  130. package/files.js.map +1 -0
  131. package/frontmatter.d.ts +51 -0
  132. package/frontmatter.d.ts.map +1 -0
  133. package/frontmatter.js +61 -0
  134. package/frontmatter.js.map +1 -0
  135. package/index.d.ts +37 -0
  136. package/index.d.ts.map +1 -0
  137. package/index.js +33 -0
  138. package/index.js.map +1 -0
  139. package/marketplace/messages.d.ts +20 -0
  140. package/marketplace/messages.d.ts.map +1 -0
  141. package/marketplace/messages.js +49 -0
  142. package/marketplace/messages.js.map +1 -0
  143. package/marketplace/outcome.d.ts +70 -0
  144. package/marketplace/outcome.d.ts.map +1 -0
  145. package/marketplace/outcome.js +29 -0
  146. package/marketplace/outcome.js.map +1 -0
  147. package/marketplace/read-marketplace.d.ts +52 -0
  148. package/marketplace/read-marketplace.d.ts.map +1 -0
  149. package/marketplace/read-marketplace.js +351 -0
  150. package/marketplace/read-marketplace.js.map +1 -0
  151. package/messages.d.ts +55 -0
  152. package/messages.d.ts.map +1 -0
  153. package/messages.js +167 -0
  154. package/messages.js.map +1 -0
  155. package/normalise/hooks.d.ts +91 -0
  156. package/normalise/hooks.d.ts.map +1 -0
  157. package/normalise/hooks.js +437 -0
  158. package/normalise/hooks.js.map +1 -0
  159. package/normalise/ignored.d.ts +34 -0
  160. package/normalise/ignored.d.ts.map +1 -0
  161. package/normalise/ignored.js +78 -0
  162. package/normalise/ignored.js.map +1 -0
  163. package/normalise/mcp-servers.d.ts +50 -0
  164. package/normalise/mcp-servers.d.ts.map +1 -0
  165. package/normalise/mcp-servers.js +398 -0
  166. package/normalise/mcp-servers.js.map +1 -0
  167. package/normalise/settings.d.ts +32 -0
  168. package/normalise/settings.d.ts.map +1 -0
  169. package/normalise/settings.js +72 -0
  170. package/normalise/settings.js.map +1 -0
  171. package/normalise/skills.d.ts +39 -0
  172. package/normalise/skills.d.ts.map +1 -0
  173. package/normalise/skills.js +135 -0
  174. package/normalise/skills.js.map +1 -0
  175. package/normalise/stigmer-folder.d.ts +17 -0
  176. package/normalise/stigmer-folder.d.ts.map +1 -0
  177. package/normalise/stigmer-folder.js +19 -0
  178. package/normalise/stigmer-folder.js.map +1 -0
  179. package/normalise/sub-agents.d.ts +54 -0
  180. package/normalise/sub-agents.d.ts.map +1 -0
  181. package/normalise/sub-agents.js +219 -0
  182. package/normalise/sub-agents.js.map +1 -0
  183. package/normalise/variables.d.ts +31 -0
  184. package/normalise/variables.d.ts.map +1 -0
  185. package/normalise/variables.js +170 -0
  186. package/normalise/variables.js.map +1 -0
  187. package/outcome.d.ts +59 -0
  188. package/outcome.d.ts.map +1 -0
  189. package/outcome.js +32 -0
  190. package/outcome.js.map +1 -0
  191. package/package.json +47 -0
  192. package/placeholders.d.ts +65 -0
  193. package/placeholders.d.ts.map +1 -0
  194. package/placeholders.js +99 -0
  195. package/placeholders.js.map +1 -0
  196. package/presentation.d.ts +53 -0
  197. package/presentation.d.ts.map +1 -0
  198. package/presentation.js +156 -0
  199. package/presentation.js.map +1 -0
  200. package/read-plugin-package.d.ts +20 -0
  201. package/read-plugin-package.d.ts.map +1 -0
  202. package/read-plugin-package.js +73 -0
  203. package/read-plugin-package.js.map +1 -0
  204. package/src/client/archive.ts +44 -0
  205. package/src/client/builtin.ts +60 -0
  206. package/src/client/ignore/defaults.ts +155 -0
  207. package/src/client/ignore/match.ts +158 -0
  208. package/src/client/ignore/matcher.ts +156 -0
  209. package/src/client/ignore/pattern.ts +132 -0
  210. package/src/client/prepare-eval.ts +92 -0
  211. package/src/client/prepare.ts +160 -0
  212. package/src/client/presentation.ts +47 -0
  213. package/src/client/refs.ts +170 -0
  214. package/src/client/release.ts +29 -0
  215. package/src/client/reroot.ts +35 -0
  216. package/src/client/select.ts +161 -0
  217. package/src/client/vocabulary.ts +19 -0
  218. package/src/client.ts +102 -0
  219. package/src/detect.ts +245 -0
  220. package/src/dialects/claude.ts +102 -0
  221. package/src/dialects/codex.ts +26 -0
  222. package/src/dialects/cursor.ts +77 -0
  223. package/src/dialects/manifest.ts +316 -0
  224. package/src/dialects/open.ts +50 -0
  225. package/src/documents.ts +158 -0
  226. package/src/evals/eval-dir.ts +101 -0
  227. package/src/evals/fields.ts +184 -0
  228. package/src/evals/glob.ts +141 -0
  229. package/src/evals/graders.ts +293 -0
  230. package/src/evals/markdown.ts +56 -0
  231. package/src/evals/mocks.ts +202 -0
  232. package/src/evals/read-eval-suite.ts +713 -0
  233. package/src/evals/summary.ts +100 -0
  234. package/src/evals/types.ts +217 -0
  235. package/src/files.ts +235 -0
  236. package/src/frontmatter.ts +70 -0
  237. package/src/index.ts +129 -0
  238. package/src/marketplace/messages.ts +61 -0
  239. package/src/marketplace/outcome.ts +91 -0
  240. package/src/marketplace/read-marketplace.ts +388 -0
  241. package/src/messages.ts +248 -0
  242. package/src/normalise/hooks.ts +469 -0
  243. package/src/normalise/ignored.ts +79 -0
  244. package/src/normalise/mcp-servers.ts +423 -0
  245. package/src/normalise/settings.ts +81 -0
  246. package/src/normalise/skills.ts +145 -0
  247. package/src/normalise/stigmer-folder.ts +23 -0
  248. package/src/normalise/sub-agents.ts +231 -0
  249. package/src/normalise/variables.ts +181 -0
  250. package/src/outcome.ts +158 -0
  251. package/src/placeholders.ts +110 -0
  252. package/src/presentation.ts +170 -0
  253. package/src/read-plugin-package.ts +80 -0
  254. package/src/testing.ts +347 -0
  255. package/src/tool-names.ts +30 -0
  256. package/src/trim.ts +10 -0
  257. package/src/types.ts +214 -0
  258. package/testing.d.ts +127 -0
  259. package/testing.d.ts.map +1 -0
  260. package/testing.js +266 -0
  261. package/testing.js.map +1 -0
  262. package/tool-names.d.ts +21 -0
  263. package/tool-names.d.ts.map +1 -0
  264. package/tool-names.js +28 -0
  265. package/tool-names.js.map +1 -0
  266. package/trim.d.ts +7 -0
  267. package/trim.d.ts.map +1 -0
  268. package/trim.js +12 -0
  269. package/trim.js.map +1 -0
  270. package/types.d.ts +179 -0
  271. package/types.d.ts.map +1 -0
  272. package/types.js +19 -0
  273. package/types.js.map +1 -0
@@ -0,0 +1,316 @@
1
+ /**
2
+ * The intermediate every dialect reader reduces its manifest to, and the
3
+ * field-reading helpers they share.
4
+ *
5
+ * A `DialectManifest` says what one manifest CONTRIBUTES: identity fields,
6
+ * declared component paths, MCP configuration and hooks sources, a
7
+ * variables block, Claude's inline settings, and the fields it carries that
8
+ * Stigmer records as ignored. It does not
9
+ * decide anything across manifests: precedence, name conflicts and default
10
+ * locations are `detect.ts`'s, and turning declarations into skills,
11
+ * servers and variables is `normalise/`'s. Keeping the readers to "what
12
+ * does this file say" is what lets a plugin carry a root manifest and a
13
+ * vendor manifest at once and have both read.
14
+ *
15
+ * Unknown fields WARN in every dialect (the open format says report and
16
+ * ignore; Cursor's own validator would reject them, but a warning serves
17
+ * the author and the install still works). A known field of the wrong type
18
+ * is fatal (`manifest-field-type`), the open format's rule for any
19
+ * violation other than an unknown field.
20
+ */
21
+
22
+ import { fields, isJsonObject, type JsonObject, optionalString, optionalStringArray, stringOrStringArray } from "../documents.js";
23
+ import { resolveDeclaredPath } from "../files.js";
24
+ import type { Findings } from "../messages.js";
25
+ import type { IgnoredComponent, IgnoredComponentKind, PluginAuthor, PluginDialect } from "../types.js";
26
+
27
+ export interface PluginIdentity {
28
+ readonly name?: string;
29
+ readonly version?: string;
30
+ readonly description?: string;
31
+ readonly author?: PluginAuthor;
32
+ readonly homepage?: string;
33
+ readonly repository?: string;
34
+ readonly license?: string;
35
+ readonly keywords?: readonly string[];
36
+ }
37
+
38
+ /** A component path a manifest declared, normalised, with where it was declared. */
39
+ export interface DeclaredPath {
40
+ /** Plugin-relative, no leading `./`, no trailing slash; the root is `""`. */
41
+ readonly path: string;
42
+ /** The manifest that declared it, for messages. */
43
+ readonly manifest: string;
44
+ }
45
+
46
+ /** Where MCP server entries come from: a configuration file, or an object inline in a manifest. */
47
+ export type McpConfigSource =
48
+ | { readonly kind: "file"; readonly path: string; readonly dialect: PluginDialect; readonly manifest: string }
49
+ | { readonly kind: "inline"; readonly manifest: string; readonly servers: unknown; readonly dialect: PluginDialect };
50
+
51
+ /**
52
+ * Where hooks come from: a hooks file, or an object inline in a manifest.
53
+ * An inline object from a Claude or Codex manifest is the bare event map
54
+ * (Claude's plugins reference); Cursor documents no inline form, so a
55
+ * Cursor inline object is read in its file's shape.
56
+ */
57
+ export type HookSource =
58
+ | { readonly kind: "file"; readonly path: string; readonly dialect: PluginDialect; readonly manifest: string }
59
+ | { readonly kind: "inline"; readonly manifest: string; readonly value: JsonObject; readonly dialect: PluginDialect };
60
+
61
+ /** A variables block, raw, tagged with the dialect whose shape it takes. */
62
+ export type VariablesDeclaration =
63
+ | { readonly dialect: "cursor"; readonly value: unknown; readonly manifest: string }
64
+ | { readonly dialect: "claude"; readonly value: unknown; readonly manifest: string };
65
+
66
+ export interface DialectManifest {
67
+ readonly dialect: PluginDialect;
68
+ readonly path: string;
69
+ readonly identity: PluginIdentity;
70
+ /** Declared skill paths; the default `skills/` is scanned regardless. */
71
+ readonly skillPaths: readonly DeclaredPath[];
72
+ /** Declared agent paths; `undefined` leaves the default `agents/` scan in force. */
73
+ readonly agentPaths?: readonly DeclaredPath[];
74
+ readonly mcpConfigs: readonly McpConfigSource[];
75
+ /** Declared hooks sources; the default `hooks/hooks.json` is added by `detect.ts`. */
76
+ readonly hookSources: readonly HookSource[];
77
+ readonly variables?: VariablesDeclaration;
78
+ /** A Claude manifest's inline `settings` object, raw. */
79
+ readonly settings?: unknown;
80
+ /**
81
+ * A Claude-shaped manifest's `experimental.evals`, raw: where the plugin's
82
+ * eval suite lives when not `evals/`. The eval reader validates it; the
83
+ * install never reads it.
84
+ */
85
+ readonly evalsDir?: { readonly value: unknown; readonly manifest: string };
86
+ readonly ignored: readonly IgnoredComponent[];
87
+ }
88
+
89
+ /** Warn once per field the dialect does not define. */
90
+ export function warnUnknownFields(object: JsonObject, known: ReadonlySet<string>, path: string, findings: Findings): void {
91
+ for (const [name] of fields(object)) {
92
+ if (!known.has(name)) findings.warn("manifest-field-unknown", { path, subject: name });
93
+ }
94
+ }
95
+
96
+ /**
97
+ * The identity fields every dialect shares. `author` is an object in every
98
+ * dialect (Cursor's schema has no `url`; the extra key is a warning there,
99
+ * reported by the caller's known-field set for `author`).
100
+ */
101
+ export function readIdentity(object: JsonObject, path: string, findings: Findings): PluginIdentity {
102
+ const identity: { -readonly [K in keyof PluginIdentity]: PluginIdentity[K] } = {};
103
+ const name = optionalString(object, "name", path, findings);
104
+ if (name !== undefined) identity.name = name;
105
+ const version = optionalString(object, "version", path, findings);
106
+ if (version !== undefined) identity.version = version;
107
+ const description = optionalString(object, "description", path, findings);
108
+ if (description !== undefined) identity.description = description;
109
+ const homepage = optionalString(object, "homepage", path, findings);
110
+ if (homepage !== undefined) identity.homepage = homepage;
111
+ const repository = optionalString(object, "repository", path, findings);
112
+ if (repository !== undefined) identity.repository = repository;
113
+ const license = optionalString(object, "license", path, findings);
114
+ if (license !== undefined) identity.license = license;
115
+ const keywords = optionalStringArray(object, "keywords", path, findings);
116
+ if (keywords !== undefined) identity.keywords = keywords;
117
+ const author = readAuthor(object, path, findings);
118
+ if (author !== undefined) identity.author = author;
119
+ return identity;
120
+ }
121
+
122
+ function readAuthor(object: JsonObject, path: string, findings: Findings): PluginAuthor | undefined {
123
+ const value = object["author"];
124
+ if (value === undefined) return undefined;
125
+ if (!isJsonObject(value)) {
126
+ findings.error("manifest-field-type", { path, subject: "author", detail: "an object" });
127
+ return undefined;
128
+ }
129
+ const author: { -readonly [K in keyof PluginAuthor]: PluginAuthor[K] } = {};
130
+ const name = optionalString(value, "name", path, findings);
131
+ if (name !== undefined) author.name = name;
132
+ const email = optionalString(value, "email", path, findings);
133
+ if (email !== undefined) author.email = email;
134
+ const url = optionalString(value, "url", path, findings);
135
+ if (url !== undefined) author.url = url;
136
+ return author;
137
+ }
138
+
139
+ /**
140
+ * A path field (`skills`, `agents`, ...) as declared paths. A value that is
141
+ * not a path (wrong prefix, escape, glob) is reported and dropped; the
142
+ * rest are kept, so one bad entry does not hide the others.
143
+ */
144
+ export function readDeclaredPaths(
145
+ object: JsonObject,
146
+ field: string,
147
+ path: string,
148
+ findings: Findings,
149
+ ): readonly DeclaredPath[] | undefined {
150
+ const values = stringOrStringArray(object, field, path, findings);
151
+ if (values === undefined) return undefined;
152
+ const declared: DeclaredPath[] = [];
153
+ for (const value of values) {
154
+ const resolved = resolveDeclaredPath(value);
155
+ if (!resolved.ok) {
156
+ findings.error(resolved.kind, { path, subject: value });
157
+ continue;
158
+ }
159
+ declared.push({ path: resolved.path, manifest: path });
160
+ }
161
+ return declared;
162
+ }
163
+
164
+ /**
165
+ * A vendor `mcpServers` field: a path, an inline `mcpServers` object, or an
166
+ * array of either. Each becomes one source under the dialect's rules.
167
+ */
168
+ export function readMcpSources(
169
+ object: JsonObject,
170
+ field: string,
171
+ path: string,
172
+ dialect: PluginDialect,
173
+ findings: Findings,
174
+ ): readonly McpConfigSource[] {
175
+ const value = object[field];
176
+ if (value === undefined) return [];
177
+ const items = Array.isArray(value) ? value : [value];
178
+ const sources: McpConfigSource[] = [];
179
+ for (const item of items) {
180
+ if (typeof item === "string") {
181
+ const resolved = resolveDeclaredPath(item);
182
+ if (!resolved.ok) {
183
+ findings.error(resolved.kind, { path, subject: item });
184
+ continue;
185
+ }
186
+ sources.push({ kind: "file", path: resolved.path, dialect, manifest: path });
187
+ } else if (isJsonObject(item)) {
188
+ sources.push({ kind: "inline", manifest: path, servers: item, dialect });
189
+ } else {
190
+ findings.error("manifest-field-type", { path, subject: field, detail: "a path, an object, or an array of either" });
191
+ }
192
+ }
193
+ return sources;
194
+ }
195
+
196
+ /**
197
+ * A vendor `hooks` field: a path, an inline hooks object, or an array of
198
+ * either, read like `mcpServers`. Each becomes one source under the
199
+ * dialect's rules.
200
+ */
201
+ export function readHookSources(object: JsonObject, path: string, dialect: PluginDialect, findings: Findings): readonly HookSource[] {
202
+ const value = object["hooks"];
203
+ if (value === undefined) return [];
204
+ const items = Array.isArray(value) ? value : [value];
205
+ const sources: HookSource[] = [];
206
+ for (const item of items) {
207
+ if (typeof item === "string") {
208
+ const resolved = resolveDeclaredPath(item);
209
+ if (!resolved.ok) {
210
+ findings.error(resolved.kind, { path, subject: item });
211
+ continue;
212
+ }
213
+ sources.push({ kind: "file", path: resolved.path, dialect, manifest: path });
214
+ } else if (isJsonObject(item)) {
215
+ sources.push({ kind: "inline", manifest: path, value: item, dialect });
216
+ } else {
217
+ findings.error("manifest-field-type", { path, subject: "hooks", detail: "a path, an object, or an array of either" });
218
+ }
219
+ }
220
+ return sources;
221
+ }
222
+
223
+ /**
224
+ * Manifest fields Stigmer reads past, recorded as ignored components at
225
+ * `<manifest>#<field>` when present. Shared across dialects; each names the
226
+ * fields it knows through `known` so the same field is never also an
227
+ * unknown-field warning.
228
+ */
229
+ export const IGNORED_FIELD_KINDS: Readonly<Record<string, IgnoredComponentKind>> = {
230
+ rules: "rules",
231
+ commands: "commands",
232
+ workflows: "workflows",
233
+ outputStyles: "output-styles",
234
+ lspServers: "lsp-servers",
235
+ channels: "channels",
236
+ dependencies: "dependencies",
237
+ defaultEnabled: "default-enabled",
238
+ minClientVersions: "min-client-versions",
239
+ logo: "logo",
240
+ apps: "apps",
241
+ };
242
+
243
+ export function ignoredFieldComponents(object: JsonObject, path: string): IgnoredComponent[] {
244
+ const ignored: IgnoredComponent[] = [];
245
+ for (const [name, value] of fields(object)) {
246
+ const kind = IGNORED_FIELD_KINDS[name];
247
+ if (kind !== undefined) ignored.push({ kind, path: `${path}#${name}` });
248
+ if (name === "experimental" && isJsonObject(value)) {
249
+ for (const [sub] of fields(value)) {
250
+ const subKind = EXPERIMENTAL_KINDS[sub];
251
+ if (subKind !== undefined) ignored.push({ kind: subKind, path: `${path}#experimental.${sub}` });
252
+ }
253
+ }
254
+ }
255
+ return ignored;
256
+ }
257
+
258
+ // `experimental.evals` is not here: it names the eval suite's directory,
259
+ // which the eval reader reads (`evals/read-eval-suite.ts`).
260
+ const EXPERIMENTAL_KINDS: Readonly<Record<string, IgnoredComponentKind>> = {
261
+ themes: "themes",
262
+ monitors: "monitors",
263
+ };
264
+
265
+ /**
266
+ * Stigmer's own namespace under a root manifest's `extensions`. The open
267
+ * format has no appearance fields, so this is where an open-format plugin
268
+ * says what a storefront card shows: the same three the Cursor manifest
269
+ * carries at its top level, read by `presentation.ts` and treated by the
270
+ * install exactly as Cursor's are (`logo` an ignored component, because
271
+ * nothing in an Organization carries the image; `displayName` and
272
+ * `category` silent). The FOLDER `ai.stigmer/` (`normalise/stigmer-folder.ts`)
273
+ * is the same name in a different place, and is read by nothing.
274
+ */
275
+ export const STIGMER_EXTENSION_NAMESPACE = "ai.stigmer";
276
+ export const STIGMER_EXTENSION_FIELDS: ReadonlySet<string> = new Set(["displayName", "logo", "category"]);
277
+
278
+ /** The `ai.stigmer` extension object of a root manifest, or `undefined` when absent or not an object. */
279
+ export function stigmerExtensionOf(object: JsonObject): JsonObject | undefined {
280
+ const extensions = object["extensions"];
281
+ if (!isJsonObject(extensions)) return undefined;
282
+ const content = extensions[STIGMER_EXTENSION_NAMESPACE];
283
+ return isJsonObject(content) ? content : undefined;
284
+ }
285
+
286
+ /**
287
+ * `extensions` in a root manifest: every foreign namespace with content is
288
+ * an ignored component (a client ignores namespaces it does not implement
289
+ * without validating them); an empty object is silent. Stigmer's own
290
+ * namespace is read field by field: `logo` is recorded as the `logo`
291
+ * component Cursor's would be, the other appearance fields are silent, and
292
+ * any field beyond `STIGMER_EXTENSION_FIELDS` makes the namespace an
293
+ * ignored `extension` component so a misspelled key stays visible. A
294
+ * non-object `extensions` is the open format's one non-fatal type
295
+ * violation: reported and ignored.
296
+ */
297
+ export function extensionComponents(object: JsonObject, path: string, findings: Findings): IgnoredComponent[] {
298
+ const value = object["extensions"];
299
+ if (value === undefined) return [];
300
+ if (!isJsonObject(value)) {
301
+ findings.warn("manifest-extensions-invalid", { path });
302
+ return [];
303
+ }
304
+ const ignored: IgnoredComponent[] = [];
305
+ for (const [namespace, content] of fields(value)) {
306
+ if (isJsonObject(content) && fields(content).length === 0) continue;
307
+ const at = `${path}#extensions.${namespace}`;
308
+ if (namespace === STIGMER_EXTENSION_NAMESPACE && isJsonObject(content)) {
309
+ if (content["logo"] !== undefined) ignored.push({ kind: "logo", path: `${at}.logo` });
310
+ if (fields(content).some(([name]) => !STIGMER_EXTENSION_FIELDS.has(name))) ignored.push({ kind: "extension", path: at });
311
+ continue;
312
+ }
313
+ ignored.push({ kind: "extension", path: at });
314
+ }
315
+ return ignored;
316
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * The Agent Plugins 1.0.0 root manifest (`plugin.json`).
3
+ *
4
+ * The open format's manifest is closed and versioned: `$schema` is required
5
+ * and must be the canonical 1.0.0 identifier, the ten permitted fields are
6
+ * fixed, an unknown field is reported and ignored, and any other violation
7
+ * is fatal. Components live at fixed locations only (`skills/`, `mcp.json`),
8
+ * so this manifest declares no paths and no inline servers; `mcp.json` is
9
+ * read under the open format's rules by `detect.ts` when it exists.
10
+ * Client-specific data belongs under `extensions`, which Stigmer records as
11
+ * ignored per foreign namespace; its own `ai.stigmer` namespace carries the
12
+ * appearance fields a storefront card shows (`manifest.ts`,
13
+ * `STIGMER_EXTENSION_FIELDS`), the open format's only place for them.
14
+ */
15
+
16
+ import { describeValue, type JsonObject } from "../documents.js";
17
+ import { AGENT_PLUGINS_MANIFEST_SCHEMA, type Findings } from "../messages.js";
18
+ import { type DialectManifest, extensionComponents, readIdentity, warnUnknownFields } from "./manifest.js";
19
+
20
+ const KNOWN_FIELDS: ReadonlySet<string> = new Set([
21
+ "$schema",
22
+ "name",
23
+ "version",
24
+ "description",
25
+ "author",
26
+ "homepage",
27
+ "repository",
28
+ "license",
29
+ "keywords",
30
+ "extensions",
31
+ ]);
32
+
33
+ export function readOpenManifest(object: JsonObject, path: string, findings: Findings): DialectManifest {
34
+ const schema = object["$schema"];
35
+ if (schema === undefined) {
36
+ findings.error("manifest-schema-missing", { path });
37
+ } else if (schema !== AGENT_PLUGINS_MANIFEST_SCHEMA) {
38
+ findings.error("manifest-schema-unsupported", { path, detail: describeValue(schema) });
39
+ }
40
+ warnUnknownFields(object, KNOWN_FIELDS, path, findings);
41
+ return {
42
+ dialect: "agent-plugins",
43
+ path,
44
+ identity: readIdentity(object, path, findings),
45
+ skillPaths: [],
46
+ mcpConfigs: [],
47
+ hookSources: [],
48
+ ignored: extensionComponents(object, path, findings),
49
+ };
50
+ }
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Reading one document through its cap, and the JSON shape checks every
3
+ * dialect reader repeats.
4
+ *
5
+ * `readText` is the only place the library calls `PluginFiles.read`: the
6
+ * declared size is checked against the document class's cap first, the
7
+ * returned length second, and an over-cap document becomes a
8
+ * `document-too-large` finding instead of a read. The JSON helpers turn a
9
+ * parse failure into a finding of the caller's kind and leave the value
10
+ * `unknown`, so each reader narrows fields with the `expect*` helpers and
11
+ * reports a wrong type with the field's name rather than trusting a cast.
12
+ */
13
+
14
+ import { decodeUtf8, PLUGIN_DOCUMENT_LIMITS, type PluginDocumentClass, type PluginFileIndex } from "./files.js";
15
+ import type { Findings } from "./messages.js";
16
+ import type { PluginErrorKind } from "./outcome.js";
17
+
18
+ /** The document's text, or `undefined` after a `document-too-large` finding. */
19
+ export function readText(
20
+ index: PluginFileIndex,
21
+ path: string,
22
+ cls: PluginDocumentClass,
23
+ findings: Findings,
24
+ ): string | undefined {
25
+ const bytes = readBytes(index, path, cls, findings);
26
+ return bytes === undefined ? undefined : decodeUtf8(bytes);
27
+ }
28
+
29
+ /** The document's bytes, or `undefined` after a `document-too-large` finding. */
30
+ export function readBytes(
31
+ index: PluginFileIndex,
32
+ path: string,
33
+ cls: PluginDocumentClass,
34
+ findings: Findings,
35
+ ): Uint8Array | undefined {
36
+ const read = readCapped(index, path, cls);
37
+ if (!read.ok) {
38
+ findings.error("document-too-large", { path, subject: String(read.size), detail: String(read.limit) });
39
+ return undefined;
40
+ }
41
+ return read.bytes;
42
+ }
43
+
44
+ export type CappedRead =
45
+ | { readonly ok: true; readonly bytes: Uint8Array }
46
+ | { readonly ok: false; readonly size: number; readonly limit: number };
47
+
48
+ /**
49
+ * One document through its class's cap, the outcome left to the caller:
50
+ * the declared size is checked before `read`, the returned length after.
51
+ * `readBytes` turns a refusal into a plugin finding; the eval reader turns
52
+ * it into a finding of its own vocabulary.
53
+ */
54
+ export function readCapped(index: PluginFileIndex, path: string, cls: PluginDocumentClass): CappedRead {
55
+ const limit = PLUGIN_DOCUMENT_LIMITS[cls];
56
+ const entry = index.entry(path);
57
+ if (entry === undefined) {
58
+ throw new Error(`plugin file '${path}' is not listed`);
59
+ }
60
+ if (entry.size > limit) return { ok: false, size: entry.size, limit };
61
+ const bytes = index.files.read(path);
62
+ if (bytes.length > limit) return { ok: false, size: bytes.length, limit };
63
+ return { ok: true, bytes };
64
+ }
65
+
66
+ /** A parsed JSON object (non-null, non-array), or `undefined` after a finding of `kind`. */
67
+ export function parseJsonObject(
68
+ text: string,
69
+ path: string,
70
+ kind: Extract<PluginErrorKind, "manifest-unreadable" | "mcp-config-unreadable" | "hooks-unreadable" | "settings-unreadable">,
71
+ findings: Findings,
72
+ ): JsonObject | undefined {
73
+ let value: unknown;
74
+ try {
75
+ value = JSON.parse(text);
76
+ } catch (error) {
77
+ findings.error(kind, { path, detail: error instanceof Error ? error.message : String(error) });
78
+ return undefined;
79
+ }
80
+ if (!isJsonObject(value)) {
81
+ findings.error(kind, { path, detail: "the document is not a JSON object" });
82
+ return undefined;
83
+ }
84
+ return value;
85
+ }
86
+
87
+ export type JsonObject = Readonly<Record<string, unknown>>;
88
+
89
+ export function isJsonObject(value: unknown): value is JsonObject {
90
+ return typeof value === "object" && value !== null && !Array.isArray(value);
91
+ }
92
+
93
+ export function isStringArray(value: unknown): value is readonly string[] {
94
+ return Array.isArray(value) && value.every((item) => typeof item === "string");
95
+ }
96
+
97
+ export function isStringRecord(value: unknown): value is Readonly<Record<string, string>> {
98
+ return isJsonObject(value) && Object.values(value).every((item) => typeof item === "string");
99
+ }
100
+
101
+ /** A JSON value as a sentence can quote it: a string as itself, anything else serialised. */
102
+ export function describeValue(value: unknown): string {
103
+ return typeof value === "string" ? value : JSON.stringify(value);
104
+ }
105
+
106
+ /**
107
+ * The fields of `object`, in the document's own order. `Object.entries`
108
+ * reads own enumerable properties only, so a `__proto__` key in the JSON is
109
+ * just another entry here and never reaches a prototype.
110
+ */
111
+ export function fields(object: JsonObject): readonly (readonly [string, unknown])[] {
112
+ return Object.entries(object);
113
+ }
114
+
115
+ /** A string field or `undefined`; a present non-string reports `manifest-field-type`. */
116
+ export function optionalString(object: JsonObject, field: string, path: string, findings: Findings): string | undefined {
117
+ const value = object[field];
118
+ if (value === undefined) return undefined;
119
+ if (typeof value !== "string") {
120
+ findings.error("manifest-field-type", { path, subject: field, detail: "a string" });
121
+ return undefined;
122
+ }
123
+ return value;
124
+ }
125
+
126
+ /** A string-array field or `undefined`; a present non-array-of-strings reports `manifest-field-type`. */
127
+ export function optionalStringArray(
128
+ object: JsonObject,
129
+ field: string,
130
+ path: string,
131
+ findings: Findings,
132
+ ): readonly string[] | undefined {
133
+ const value = object[field];
134
+ if (value === undefined) return undefined;
135
+ if (!isStringArray(value)) {
136
+ findings.error("manifest-field-type", { path, subject: field, detail: "an array of strings" });
137
+ return undefined;
138
+ }
139
+ return value;
140
+ }
141
+
142
+ /**
143
+ * A field that may be one string or an array of strings (the vendor
144
+ * dialects' path fields), normalised to an array; `undefined` when absent.
145
+ */
146
+ export function stringOrStringArray(
147
+ object: JsonObject,
148
+ field: string,
149
+ path: string,
150
+ findings: Findings,
151
+ ): readonly string[] | undefined {
152
+ const value = object[field];
153
+ if (value === undefined) return undefined;
154
+ if (typeof value === "string") return [value];
155
+ if (isStringArray(value)) return value;
156
+ findings.error("manifest-field-type", { path, subject: field, detail: "a string or an array of strings" });
157
+ return undefined;
158
+ }
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Where a plugin's eval suite lives: the one rule the suite reader and the
3
+ * skill listing share, so a suite the reader grades from is exactly what
4
+ * the skill archives leave out.
5
+ *
6
+ * The directory is `evals/`, or a Claude-shaped manifest's
7
+ * `experimental.evals` when that is a relative path of plain directory
8
+ * names (the first manifest in the set's order that carries the key) that
9
+ * does not overlap the plugin's skills. The value is written with or
10
+ * without a `./` prefix, which is stripped, and may be an array, whose
11
+ * first entry is used, as Claude Code's manifest reference reads it. A
12
+ * path longer than {@link EVAL_DIR_MAX_LENGTH} characters is refused, since
13
+ * the plugin stores it whole. Any other value is unusable and
14
+ * `evals/` is used, the format's rule; the resolution says why, and the
15
+ * suite reader turns it into its finding.
16
+ *
17
+ * Overlapping means the directory is `skills/` or a path any manifest
18
+ * declares for skills, lies inside one, or holds one: the skill listing
19
+ * leaves the suite out of every skill's files, so a suite there would strip
20
+ * a skill, its `SKILL.md` included. A path declared as the plugin's root
21
+ * (`./`, the whole plugin as one skill) is not counted, since every
22
+ * directory lies inside it and the default `evals/` is left out of it the
23
+ * same way. The runner's mount applies this rule to the archive's own
24
+ * manifests (`runner` `shared/plugin-mount.ts` `manifestEvalDir`), and
25
+ * both run one shared table (`__tests__/fixtures/eval-dir-parity.json`).
26
+ *
27
+ * The default can overlap too: a manifest may declare skills under
28
+ * `./evals/`. Then the plugin has no usable suite directory (unless a
29
+ * usable `experimental.evals` moves it clear), the resolution names the
30
+ * skill path that holds it, the skill listing strips nothing, so no skill
31
+ * loses its files, and the suite reader reads no case.
32
+ * Pinned through `__tests__/eval-suite.test.ts` and `__tests__/skills.test.ts`.
33
+ */
34
+
35
+ import type { ManifestSet } from "../detect.js";
36
+ import { isContainedPath } from "../files.js";
37
+
38
+ /** The suite's directory when the manifest names none. */
39
+ export const DEFAULT_EVAL_DIR = "evals";
40
+
41
+ /** The open format's fixed skills directory, read whatever the manifests declare. */
42
+ export const DEFAULT_SKILLS_DIR = "skills";
43
+
44
+ /** The longest suite directory a manifest may name, in UTF-16 code units: the longest case directory the reader takes. */
45
+ export const EVAL_DIR_MAX_LENGTH = 1024;
46
+
47
+ /** Why a manifest's `experimental.evals` was not used. */
48
+ export type EvalDirUnusableReason = "not-a-plain-path" | "overlaps-skills";
49
+
50
+ export interface EvalDirResolution {
51
+ /** The plugin-relative suite directory. */
52
+ readonly dir: string;
53
+ /** The manifest's value when it was present and unusable, so `dir` fell back to `evals/`. */
54
+ readonly unusable?: { readonly value: unknown; readonly manifest: string; readonly reason: EvalDirUnusableReason };
55
+ /** The declared skill path the default `dir` overlaps, and its manifest: the plugin then has no suite. */
56
+ readonly heldBySkills?: { readonly path: string; readonly manifest: string };
57
+ }
58
+
59
+ export function resolveEvalDir(set: ManifestSet | undefined): EvalDirResolution {
60
+ const declared = set?.manifests.find((manifest) => manifest.evalsDir !== undefined)?.evalsDir;
61
+ if (set === undefined) return { dir: DEFAULT_EVAL_DIR };
62
+ if (declared === undefined) return defaultDir(set);
63
+ const { value, manifest } = declared;
64
+ const dir = declaredEvalDir(value);
65
+ if (dir === undefined) {
66
+ return defaultDir(set, { value, manifest, reason: "not-a-plain-path" });
67
+ }
68
+ const skillDirs = [DEFAULT_SKILLS_DIR, ...set.manifests.flatMap((m) => m.skillPaths.map((p) => p.path))];
69
+ if (skillDirs.some((skillDir) => skillDir !== "" && pathsOverlap(dir, skillDir))) {
70
+ return defaultDir(set, { value, manifest, reason: "overlaps-skills" });
71
+ }
72
+ return { dir };
73
+ }
74
+
75
+ /**
76
+ * The plugin-relative directory a manifest's `experimental.evals` names:
77
+ * an array's first entry, one `./` prefix stripped, then a path of plain
78
+ * directory names no longer than {@link EVAL_DIR_MAX_LENGTH}; `undefined`
79
+ * for anything else.
80
+ */
81
+ function declaredEvalDir(value: unknown): string | undefined {
82
+ const entry: unknown = Array.isArray(value) ? value[0] : value;
83
+ if (typeof entry !== "string") return undefined;
84
+ const path = entry.startsWith("./") ? entry.slice(2) : entry;
85
+ return path.length <= EVAL_DIR_MAX_LENGTH && isContainedPath(path) ? path : undefined;
86
+ }
87
+
88
+ /** `evals/`, with why the manifest's value was not used, and the declared skill path that holds it, if any. */
89
+ function defaultDir(set: ManifestSet, unusable?: EvalDirResolution["unusable"]): EvalDirResolution {
90
+ const held = set.manifests.flatMap((m) => m.skillPaths).find((p) => p.path !== "" && pathsOverlap(DEFAULT_EVAL_DIR, p.path));
91
+ return {
92
+ dir: DEFAULT_EVAL_DIR,
93
+ ...(unusable !== undefined && { unusable }),
94
+ ...(held !== undefined && { heldBySkills: { path: held.path, manifest: held.manifest } }),
95
+ };
96
+ }
97
+
98
+ /** Whether one plugin-relative directory is the other or lies inside it. */
99
+ function pathsOverlap(a: string, b: string): boolean {
100
+ return a === b || a.startsWith(`${b}/`) || b.startsWith(`${a}/`);
101
+ }