@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,248 @@
1
+ /**
2
+ * The one sentence for every finding kind, and the collector that composes
3
+ * findings from a kind and its context.
4
+ *
5
+ * Copy lives here and nowhere else: the CLI and the server print these
6
+ * sentences verbatim, so a plugin refused offline is refused by the server
7
+ * with the same words, and a consumer never composes refusal copy of its
8
+ * own. Every sentence says what is wrong and, where the fix is not obvious,
9
+ * what Stigmer needs instead. Identifiers are single-quoted (the ts-server
10
+ * quoting rule for new copy). The `Record` types are exhaustive over the
11
+ * kind unions, so a kind without a sentence does not compile.
12
+ */
13
+
14
+ import type { Finding, FindingContext, PluginErrorKind, PluginFindingKind, PluginWarningKind } from "./outcome.js";
15
+
16
+ /** The canonical `$schema` identifiers the open format pins per version. */
17
+ export const AGENT_PLUGINS_MANIFEST_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json";
18
+ export const AGENT_PLUGINS_MCP_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json";
19
+
20
+ /** The four manifest locations, in the precedence the reader applies when there is no root manifest. */
21
+ export const MANIFEST_LOCATIONS = {
22
+ "agent-plugins": "plugin.json",
23
+ claude: ".claude-plugin/plugin.json",
24
+ cursor: ".cursor-plugin/plugin.json",
25
+ codex: ".codex-plugin/plugin.json",
26
+ } as const;
27
+
28
+ /** Single-quote an identifier for a sentence (the ts-server quoting rule); shared with the marketplace vocabulary. */
29
+ export const q = (value: string | undefined): string => `'${value ?? ""}'`;
30
+ /** ` in '<path>'`, or nothing when the finding names no file. */
31
+ export const at = (path: string | undefined): string => (path === undefined ? "" : ` in ${q(path)}`);
32
+
33
+ export type Sentence = (ctx: FindingContext) => string;
34
+
35
+ const ERROR_MESSAGES: Record<PluginErrorKind, Sentence> = {
36
+ "no-manifest": () =>
37
+ `no plugin manifest found: expected one of ${Object.values(MANIFEST_LOCATIONS)
38
+ .map((p) => q(p))
39
+ .join(", ")}`,
40
+ "manifest-unreadable": (c) => `manifest ${q(c.path)} is not valid JSON: ${c.detail ?? "parse error"}`,
41
+ "manifest-schema-missing": (c) =>
42
+ `manifest ${q(c.path)} is missing the required '$schema' field; an Agent Plugins manifest declares ${q(AGENT_PLUGINS_MANIFEST_SCHEMA)}`,
43
+ "manifest-schema-unsupported": (c) =>
44
+ `manifest ${q(c.path)} declares an unsupported '$schema' ${q(c.detail)}; this reader supports ${q(AGENT_PLUGINS_MANIFEST_SCHEMA)}`,
45
+ "manifest-name-missing": (c) => `manifest ${q(c.path)} is missing the required 'name' field`,
46
+ "manifest-name-invalid": (c) =>
47
+ `plugin name ${q(c.subject)}${at(c.path)} is invalid: 1 to 64 characters of lowercase letters, digits, hyphens and periods, starting and ending alphanumeric, with no '--' or '..'`,
48
+ "manifest-name-conflict": (c) =>
49
+ `manifests disagree on the plugin name: ${q(c.subject)} in ${q(c.path)} versus ${c.detail ?? "another manifest"}`,
50
+ "manifest-field-type": (c) => `field ${q(c.subject)}${at(c.path)} has the wrong type: expected ${c.detail ?? "a different type"}`,
51
+
52
+ "path-not-relative": (c) =>
53
+ `path ${q(c.subject)}${at(c.path)} must be plugin-relative and begin with './'`,
54
+ "path-escapes-root": (c) => `path ${q(c.subject)}${at(c.path)} escapes the plugin root`,
55
+ "path-glob-unsupported": (c) =>
56
+ `path ${q(c.subject)}${at(c.path)} is a glob pattern; declare directories and files by path`,
57
+ "path-uncontained": (c) => `the reader listed a path outside the plugin root: ${q(c.path)}`,
58
+ "document-too-large": (c) =>
59
+ `${q(c.path)} is ${c.subject ?? "too many"} bytes, over the ${c.detail ?? ""}-byte limit for this kind of document`,
60
+
61
+ "skill-frontmatter-missing": (c) => `${q(c.path)} must start with YAML frontmatter ('---')`,
62
+ "skill-frontmatter-unclosed": (c) => `${q(c.path)} frontmatter is not closed (missing the closing '---')`,
63
+ "skill-frontmatter-unreadable": (c) => `${q(c.path)} frontmatter is not valid YAML: ${c.detail ?? "parse error"}`,
64
+ "skill-name-invalid": (c) =>
65
+ `skill name ${q(c.subject)}${at(c.path)} is invalid: lowercase letters, digits and hyphens, optionally dot-scoped, with every segment alphanumeric`,
66
+ "skill-name-duplicate": (c) => `skill name ${q(c.subject)} appears more than once (again${at(c.path)})`,
67
+
68
+ "mcp-config-unreadable": (c) => `MCP configuration ${q(c.path)} is not valid JSON: ${c.detail ?? "parse error"}`,
69
+ "mcp-config-shape": (c) => `MCP configuration ${q(c.path)} must be an object with an 'mcpServers' object`,
70
+ "mcp-config-schema-missing": (c) =>
71
+ `MCP configuration ${q(c.path)} is missing the required '$schema' field; an Agent Plugins configuration declares ${q(AGENT_PLUGINS_MCP_SCHEMA)}`,
72
+ "mcp-config-schema-unsupported": (c) =>
73
+ `MCP configuration ${q(c.path)} declares an unsupported '$schema' ${q(c.detail)}; this reader supports ${q(AGENT_PLUGINS_MCP_SCHEMA)}`,
74
+ "mcp-config-field-unknown": (c) =>
75
+ `MCP configuration ${q(c.path)} has an unexpected top-level field ${q(c.subject)}; only '$schema' and 'mcpServers' are allowed`,
76
+
77
+ "mcp-server-shape": (c) => `MCP server ${q(c.subject)}${at(c.path)} must be an object`,
78
+ "mcp-server-type-missing": (c) =>
79
+ `MCP server ${q(c.subject)}${at(c.path)} is missing the 'type' field the Agent Plugins format requires ('stdio', 'streamable-http' or 'sse')`,
80
+ "mcp-server-transport-unknown": (c) =>
81
+ `MCP server ${q(c.subject)}${at(c.path)} has no 'type' and neither a 'command' nor a 'url' to infer it from`,
82
+ "mcp-server-type-ambiguous": (c) =>
83
+ `MCP server ${q(c.subject)}${at(c.path)} declares both 'command' and 'url'; a server is either stdio or HTTP`,
84
+ "mcp-server-type-unknown": (c) =>
85
+ `MCP server ${q(c.subject)}${at(c.path)} has an unknown 'type' ${q(c.detail)}; expected 'stdio', 'http', 'streamable-http' or 'sse'`,
86
+ "mcp-server-field-unknown": (c) =>
87
+ `MCP server ${q(c.subject)}${at(c.path)} has a field ${q(c.detail)} that its transport does not define`,
88
+ "mcp-server-field-type": (c) => `MCP server ${q(c.subject)}${at(c.path)} field ${q(c.detail)} has the wrong type`,
89
+ "mcp-server-url-missing": (c) => `MCP server ${q(c.subject)}${at(c.path)} is missing the 'url' its HTTP transport requires`,
90
+ "mcp-server-url-invalid": (c) =>
91
+ `MCP server ${q(c.subject)}${at(c.path)} has an invalid 'url' ${q(c.detail)}: expected an absolute HTTPS URL (HTTP only for localhost) with no user information or fragment`,
92
+ "mcp-server-url-variable": (c) =>
93
+ `MCP server ${q(c.subject)}${at(c.path)} has a variable in its 'url'; Stigmer sends the URL as written, so write the URL out and put variables in 'headers'`,
94
+ "mcp-server-command-missing": (c) =>
95
+ `MCP server ${q(c.subject)}${at(c.path)} is missing the 'command' its stdio transport requires`,
96
+ "mcp-server-command-invalid": (c) =>
97
+ `MCP server ${q(c.subject)}${at(c.path)} has a 'command' that is not a single executable name; put arguments in 'args'`,
98
+ "mcp-server-command-relative": (c) =>
99
+ `MCP server ${q(c.subject)}${at(c.path)} runs a command bundled in the plugin ${q(c.detail)}; Stigmer runs only commands on the runner's PATH (for example 'npx' or 'uvx')`,
100
+ "mcp-server-plugin-root-reference": (c) =>
101
+ `MCP server ${q(c.subject)}${at(c.path)} references the plugin's own files through ${q(c.detail)}; Stigmer does not mount plugin files into the runner`,
102
+ "mcp-server-cwd-unsupported": (c) =>
103
+ `MCP server ${q(c.subject)}${at(c.path)} sets a working directory; Stigmer does not mount plugin files, so a bundled directory cannot be reached`,
104
+ "mcp-server-env-literal": (c) =>
105
+ `MCP server ${q(c.subject)}${at(c.path)} sets environment variable ${q(c.detail)} to a literal value; Stigmer passes declared variables by name, so write ${q(`${c.detail ?? "KEY"}: "\${${c.detail ?? "KEY"}}"`)} and declare the variable`,
106
+ "mcp-server-env-rename": (c) =>
107
+ `MCP server ${q(c.subject)}${at(c.path)} maps environment variable ${q(c.detail)} to a differently named variable; Stigmer passes declared variables by name, so use the same name on both sides`,
108
+ "mcp-server-name-duplicate": (c) => `MCP server name ${q(c.subject)} appears more than once (again${at(c.path)})`,
109
+ "mcp-server-header-duplicate": (c) =>
110
+ `MCP server ${q(c.subject)}${at(c.path)} declares header ${q(c.detail)} more than once (header names are case-insensitive)`,
111
+ "mcp-server-header-invalid": (c) => `MCP server ${q(c.subject)}${at(c.path)} has an invalid header name ${q(c.detail)}`,
112
+
113
+ "sub-agent-frontmatter-unreadable": (c) => `${q(c.path)} frontmatter is not valid YAML: ${c.detail ?? "parse error"}`,
114
+ "sub-agent-instructions-short": (c) =>
115
+ `subagent ${q(c.subject)}${at(c.path)} has instructions under ${c.detail ?? ""} characters; the body of the file is the subagent's prompt`,
116
+ "sub-agent-name-duplicate": (c) => `subagent name ${q(c.subject)} appears more than once (again${at(c.path)})`,
117
+ "sub-agent-tool-list-invalid": (c) =>
118
+ `subagent ${q(c.subject)}${at(c.path)} has a ${q(c.detail)} field that is neither a comma-separated string nor a list of strings`,
119
+
120
+ "hooks-unreadable": (c) => `hooks file ${q(c.path)} is not valid JSON: ${c.detail ?? "parse error"}`,
121
+ "hooks-shape": (c) => `hooks ${q(c.path)} are not in a shape Stigmer reads: ${c.detail ?? "unexpected shape"}`,
122
+ "hook-command-missing": (c) => `a hook${at(c.path)} on ${q(c.subject)} has no 'command'; a command hook names the command it runs`,
123
+ "hook-matcher-invalid": (c) =>
124
+ `a hook${at(c.path)} on ${q(c.subject)} has a matcher ${q(c.detail)} that is neither '*', a list of names, nor a valid regular expression`,
125
+ "hook-condition-invalid": (c) =>
126
+ `a hook${at(c.path)} on ${q(c.subject)} has an 'if' ${q(c.detail)} that is not a permission rule such as 'Bash' or 'Bash(git push *)'`,
127
+
128
+ "settings-unreadable": (c) => `plugin settings ${q(c.path)} are not valid JSON: ${c.detail ?? "parse error"}`,
129
+
130
+ "variable-name-invalid": (c) =>
131
+ `variable name ${q(c.subject)}${at(c.path)} is invalid: an environment variable name is letters, digits and underscores, not starting with a digit`,
132
+
133
+ };
134
+
135
+ const WARNING_MESSAGES: Record<PluginWarningKind, Sentence> = {
136
+ "manifest-field-unknown": (c) => `manifest ${q(c.path)} has an unknown field ${q(c.subject)}, ignored`,
137
+ "manifest-extensions-invalid": (c) => `manifest ${q(c.path)} has an 'extensions' field that is not an object, ignored`,
138
+ "path-missing": (c) => `path ${q(c.subject)} declared${at(c.path)} does not exist in the plugin`,
139
+ "skill-name-defaulted": (c) =>
140
+ `${q(c.path)} has no 'name' in its frontmatter; the skill is named after its directory, ${q(c.subject)}`,
141
+ "skill-name-differs-from-directory": (c) =>
142
+ `skill ${q(c.subject)}${at(c.path)} is named differently from its directory ${q(c.detail)}`,
143
+ "skill-description-missing": (c) => `skill ${q(c.subject)}${at(c.path)} has no 'description'`,
144
+ "mcp-config-field-ignored": (c) =>
145
+ `MCP configuration ${q(c.path)} has a top-level field ${q(c.subject)} Stigmer does not read, ignored`,
146
+ "mcp-server-sse-mapped": (c) =>
147
+ `MCP server ${q(c.subject)}${at(c.path)} declares the legacy 'sse' transport; Stigmer connects over Streamable HTTP and falls back to SSE only when the server rejects it`,
148
+ "mcp-server-field-ignored": (c) => `MCP server ${q(c.subject)}${at(c.path)} has a field ${q(c.detail)} Stigmer does not read, ignored`,
149
+ "mcp-server-auth-ignored": (c) =>
150
+ `MCP server ${q(c.subject)}${at(c.path)} has an 'auth' block Stigmer does not read; a person signs in to a server at its address`,
151
+ "variable-inferred": (c) =>
152
+ `variable ${q(c.subject)} is referenced by MCP server ${q(c.detail)} but not declared; it is declared as a required secret`,
153
+ "variable-unreferenced": (c) => `variable ${q(c.subject)}${at(c.path)} is declared but no MCP server or hook references it`,
154
+ "variable-default-dropped": (c) =>
155
+ `variable ${q(c.subject)}${at(c.path)} has a default value, which Stigmer does not carry; the user supplies the value`,
156
+ "variable-type-narrowed": (c) =>
157
+ `variable ${q(c.subject)}${at(c.path)} is typed ${q(c.detail)}; Stigmer variables are strings`,
158
+ "variable-option-dropped": (c) =>
159
+ `variable ${q(c.subject)}${at(c.path)} has a ${q(c.detail)} constraint, which Stigmer does not carry`,
160
+ "sub-agent-name-defaulted": (c) =>
161
+ `${q(c.path)} has no 'name' in its frontmatter; the subagent is named after the file, ${q(c.subject)}`,
162
+ "sub-agent-skill-unknown": (c) =>
163
+ `subagent ${q(c.subject)}${at(c.path)} asks for skill ${q(c.detail)}, which the plugin does not ship`,
164
+ "sub-agent-model-unknown": (c) =>
165
+ `subagent ${q(c.subject)}${at(c.path)} names model ${q(c.detail)}, which is not a model alias Stigmer knows; the subagent runs on it only where the conversation's engine lists it as a model, else on the conversation's model`,
166
+ "sub-agent-field-ignored": (c) =>
167
+ `subagent ${q(c.subject)}${at(c.path)} has a field ${q(c.detail)} Stigmer does not read, ignored${
168
+ PLUGIN_AGENT_FIELDS_CLAUDE_IGNORES.has(c.detail ?? "") ? "; Claude Code ignores it on a plugin's agents too" : ""
169
+ }`,
170
+ "hook-event-not-run": (c) => `hooks${at(c.path)} on ${q(c.subject)} are not run on Stigmer, which reads hooks on tool calls only`,
171
+ "hook-handler-not-run": (c) => `a hook${at(c.path)} on ${q(c.subject)} is not run on Stigmer: ${c.detail ?? "unsupported handler"}`,
172
+ "hook-field-ignored": (c) =>
173
+ `hooks${at(c.path)}${c.subject === undefined ? "" : ` on ${q(c.subject)}`} have a field ${q(c.detail)} Stigmer does not read, ignored`,
174
+ "hooks-format-not-run": (c) =>
175
+ `hooks${at(c.path)} are in ${c.detail ?? "another"} format and are not run, because the plugin's Claude Code hooks are`,
176
+ "skill-hooks-not-run": (c) =>
177
+ `skill ${q(c.subject)}${at(c.path)} declares hooks in its frontmatter, which Stigmer does not run`,
178
+ "hooks-not-read": (c) =>
179
+ `${c.path ?? "hooks/"} is not read: Stigmer reads hooks in the Claude Code, Codex and Cursor layouts`,
180
+ "settings-agent-unknown": (c) =>
181
+ `plugin settings${at(c.path)} name ${q(c.detail)} as the main agent, which is not one of the plugin's agents, ignored`,
182
+ "settings-key-ignored": (c) => `plugin settings${at(c.path)} have a key ${q(c.subject)} Stigmer does not apply, ignored`,
183
+ "stigmer-folder-ignored": (c) =>
184
+ `${q(c.path)} is not read: Stigmer installs a plugin from its skills, agents, hooks and MCP configuration, as every other client does`,
185
+ };
186
+
187
+ /** Sub-agent fields Claude Code itself ignores when the agent comes from a plugin (its sub-agents reference). */
188
+ const PLUGIN_AGENT_FIELDS_CLAUDE_IGNORES: ReadonlySet<string> = new Set(["hooks", "mcpServers", "permissionMode", "initialPrompt"]);
189
+
190
+ export function errorMessage(kind: PluginErrorKind, ctx: FindingContext): string {
191
+ return ERROR_MESSAGES[kind](ctx);
192
+ }
193
+
194
+ export function warningMessage(kind: PluginWarningKind, ctx: FindingContext): string {
195
+ return WARNING_MESSAGES[kind](ctx);
196
+ }
197
+
198
+ /** True for the kinds that refuse a package. */
199
+ export function isErrorKind(kind: PluginFindingKind): kind is PluginErrorKind {
200
+ return kind in ERROR_MESSAGES;
201
+ }
202
+
203
+ /** A sentence table over a closed kind vocabulary; `Record` so a kind without a sentence does not compile. */
204
+ export type SentenceTable<K extends string> = Readonly<Record<K, Sentence>>;
205
+
206
+ /**
207
+ * Collects findings while a read proceeds. A reader never throws on the
208
+ * content it reads: every problem becomes a finding here, and the read
209
+ * continues so the outcome carries them all. Generic over the two kind
210
+ * vocabularies so the plugin reader and the marketplace reader share one
211
+ * collector and one finding shape while each owns its sentences.
212
+ */
213
+ export class FindingCollector<E extends string, W extends string> {
214
+ readonly errors: Finding<E>[] = [];
215
+ readonly warnings: Finding<W>[] = [];
216
+
217
+ constructor(
218
+ private readonly errorSentences: SentenceTable<E>,
219
+ private readonly warningSentences: SentenceTable<W>,
220
+ ) {}
221
+
222
+ error(kind: E, ctx: FindingContext = {}): void {
223
+ this.errors.push(compose(kind, ctx, this.errorSentences[kind](ctx)));
224
+ }
225
+
226
+ warn(kind: W, ctx: FindingContext = {}): void {
227
+ this.warnings.push(compose(kind, ctx, this.warningSentences[kind](ctx)));
228
+ }
229
+ }
230
+
231
+ /** The plugin reader's collector, bound to the plugin vocabulary. */
232
+ export class Findings extends FindingCollector<PluginErrorKind, PluginWarningKind> {
233
+ constructor() {
234
+ super(ERROR_MESSAGES, WARNING_MESSAGES);
235
+ }
236
+ }
237
+
238
+ // Optional fields are omitted rather than set to `undefined` so a finding
239
+ // serialises to JSON without `null`s and compares structurally in tests.
240
+ function compose<K extends string>(kind: K, ctx: FindingContext, message: string): Finding<K> {
241
+ return {
242
+ kind,
243
+ ...(ctx.path !== undefined && { path: ctx.path }),
244
+ ...(ctx.subject !== undefined && { subject: ctx.subject }),
245
+ ...(ctx.detail !== undefined && { detail: ctx.detail }),
246
+ message,
247
+ };
248
+ }