@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
package/documents.js ADDED
@@ -0,0 +1,121 @@
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
+ import { decodeUtf8, PLUGIN_DOCUMENT_LIMITS } from "./files.js";
14
+ /** The document's text, or `undefined` after a `document-too-large` finding. */
15
+ export function readText(index, path, cls, findings) {
16
+ const bytes = readBytes(index, path, cls, findings);
17
+ return bytes === undefined ? undefined : decodeUtf8(bytes);
18
+ }
19
+ /** The document's bytes, or `undefined` after a `document-too-large` finding. */
20
+ export function readBytes(index, path, cls, findings) {
21
+ const read = readCapped(index, path, cls);
22
+ if (!read.ok) {
23
+ findings.error("document-too-large", { path, subject: String(read.size), detail: String(read.limit) });
24
+ return undefined;
25
+ }
26
+ return read.bytes;
27
+ }
28
+ /**
29
+ * One document through its class's cap, the outcome left to the caller:
30
+ * the declared size is checked before `read`, the returned length after.
31
+ * `readBytes` turns a refusal into a plugin finding; the eval reader turns
32
+ * it into a finding of its own vocabulary.
33
+ */
34
+ export function readCapped(index, path, cls) {
35
+ const limit = PLUGIN_DOCUMENT_LIMITS[cls];
36
+ const entry = index.entry(path);
37
+ if (entry === undefined) {
38
+ throw new Error(`plugin file '${path}' is not listed`);
39
+ }
40
+ if (entry.size > limit)
41
+ return { ok: false, size: entry.size, limit };
42
+ const bytes = index.files.read(path);
43
+ if (bytes.length > limit)
44
+ return { ok: false, size: bytes.length, limit };
45
+ return { ok: true, bytes };
46
+ }
47
+ /** A parsed JSON object (non-null, non-array), or `undefined` after a finding of `kind`. */
48
+ export function parseJsonObject(text, path, kind, findings) {
49
+ let value;
50
+ try {
51
+ value = JSON.parse(text);
52
+ }
53
+ catch (error) {
54
+ findings.error(kind, { path, detail: error instanceof Error ? error.message : String(error) });
55
+ return undefined;
56
+ }
57
+ if (!isJsonObject(value)) {
58
+ findings.error(kind, { path, detail: "the document is not a JSON object" });
59
+ return undefined;
60
+ }
61
+ return value;
62
+ }
63
+ export function isJsonObject(value) {
64
+ return typeof value === "object" && value !== null && !Array.isArray(value);
65
+ }
66
+ export function isStringArray(value) {
67
+ return Array.isArray(value) && value.every((item) => typeof item === "string");
68
+ }
69
+ export function isStringRecord(value) {
70
+ return isJsonObject(value) && Object.values(value).every((item) => typeof item === "string");
71
+ }
72
+ /** A JSON value as a sentence can quote it: a string as itself, anything else serialised. */
73
+ export function describeValue(value) {
74
+ return typeof value === "string" ? value : JSON.stringify(value);
75
+ }
76
+ /**
77
+ * The fields of `object`, in the document's own order. `Object.entries`
78
+ * reads own enumerable properties only, so a `__proto__` key in the JSON is
79
+ * just another entry here and never reaches a prototype.
80
+ */
81
+ export function fields(object) {
82
+ return Object.entries(object);
83
+ }
84
+ /** A string field or `undefined`; a present non-string reports `manifest-field-type`. */
85
+ export function optionalString(object, field, path, findings) {
86
+ const value = object[field];
87
+ if (value === undefined)
88
+ return undefined;
89
+ if (typeof value !== "string") {
90
+ findings.error("manifest-field-type", { path, subject: field, detail: "a string" });
91
+ return undefined;
92
+ }
93
+ return value;
94
+ }
95
+ /** A string-array field or `undefined`; a present non-array-of-strings reports `manifest-field-type`. */
96
+ export function optionalStringArray(object, field, path, findings) {
97
+ const value = object[field];
98
+ if (value === undefined)
99
+ return undefined;
100
+ if (!isStringArray(value)) {
101
+ findings.error("manifest-field-type", { path, subject: field, detail: "an array of strings" });
102
+ return undefined;
103
+ }
104
+ return value;
105
+ }
106
+ /**
107
+ * A field that may be one string or an array of strings (the vendor
108
+ * dialects' path fields), normalised to an array; `undefined` when absent.
109
+ */
110
+ export function stringOrStringArray(object, field, path, findings) {
111
+ const value = object[field];
112
+ if (value === undefined)
113
+ return undefined;
114
+ if (typeof value === "string")
115
+ return [value];
116
+ if (isStringArray(value))
117
+ return value;
118
+ findings.error("manifest-field-type", { path, subject: field, detail: "a string or an array of strings" });
119
+ return undefined;
120
+ }
121
+ //# sourceMappingURL=documents.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documents.js","sourceRoot":"","sources":["src/documents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAkD,MAAM,YAAY,CAAC;AAIhH,gFAAgF;AAChF,M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AS,CAAC;IAC1C,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1B,QAAQ,CAAC,KAAK,CAAC,qBAAqB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,qBAAqB,EAAE,CAAC,CAAC;QAC/F,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CACjC,MAAkB,EAClB,KAAa,EACb,IAAY,EACZ,QAAkB;IAElB,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC5B,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,CAAC,KAAK,CAAC,CAAC;IAC9C,IAAI,aAAa,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACvC,QAAQ,CAAC,KAAK,CAAC,qBAAqB,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,iCAAiC,EAAE,CAAC,CAAC;IAC3G,OAAO,SAAS,CAAC;AACnB,CAAC"}
@@ -0,0 +1,59 @@
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
+ import type { ManifestSet } from "../detect.js";
35
+ /** The suite's directory when the manifest names none. */
36
+ export declare const DEFAULT_EVAL_DIR = "evals";
37
+ /** The open format's fixed skills directory, read whatever the manifests declare. */
38
+ export declare const DEFAULT_SKILLS_DIR = "skills";
39
+ /** The longest suite directory a manifest may name, in UTF-16 code units: the longest case directory the reader takes. */
40
+ export declare const EVAL_DIR_MAX_LENGTH = 1024;
41
+ /** Why a manifest's `experimental.evals` was not used. */
42
+ export type EvalDirUnusableReason = "not-a-plain-path" | "overlaps-skills";
43
+ export interface EvalDirResolution {
44
+ /** The plugin-relative suite directory. */
45
+ readonly dir: string;
46
+ /** The manifest's value when it was present and unusable, so `dir` fell back to `evals/`. */
47
+ readonly unusable?: {
48
+ readonly value: unknown;
49
+ readonly manifest: string;
50
+ readonly reason: EvalDirUnusableReason;
51
+ };
52
+ /** The declared skill path the default `dir` overlaps, and its manifest: the plugin then has no suite. */
53
+ readonly heldBySkills?: {
54
+ readonly path: string;
55
+ readonly manifest: string;
56
+ };
57
+ }
58
+ export declare function resolveEvalDir(set: ManifestSet | undefined): EvalDirResolution;
59
+ //# sourceMappingURL=eval-dir.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eval-dir.d.ts","sourceRoot":"","sources":["../src/evals/eval-dir.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAGhD,0DAA0D;AAC1D,eAAO,MAAM,gBAAgB,UAAU,CAAC;AAExC,qFAAqF;AACrF,eAAO,MAAM,kBAAkB,WAAW,CAAC;AAE3C,0HAA0H;AAC1H,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC,0DAA0D;AAC1D,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,GAAG,iBAAiB,CAAC;AAE3E,MAAM,WAAW,iBAAiB;IAChC,2CAA2C;IAC3C,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,6FAA6F;IAC7F,QAAQ,CAAC,QAAQ,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAA;KAAE,CAAC;IACnH,0GAA0G;IAC1G,QAAQ,CAAC,YAAY,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CAC9E;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,SAAS,GAAG,iBAAiB,CAc9E"}
@@ -0,0 +1,84 @@
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
+ import { isContainedPath } from "../files.js";
35
+ /** The suite's directory when the manifest names none. */
36
+ export const DEFAULT_EVAL_DIR = "evals";
37
+ /** The open format's fixed skills directory, read whatever the manifests declare. */
38
+ export const DEFAULT_SKILLS_DIR = "skills";
39
+ /** The longest suite directory a manifest may name, in UTF-16 code units: the longest case directory the reader takes. */
40
+ export const EVAL_DIR_MAX_LENGTH = 1024;
41
+ export function resolveEvalDir(set) {
42
+ const declared = set?.manifests.find((manifest) => manifest.evalsDir !== undefined)?.evalsDir;
43
+ if (set === undefined)
44
+ return { dir: DEFAULT_EVAL_DIR };
45
+ if (declared === undefined)
46
+ return defaultDir(set);
47
+ const { value, manifest } = declared;
48
+ const dir = declaredEvalDir(value);
49
+ if (dir === undefined) {
50
+ return defaultDir(set, { value, manifest, reason: "not-a-plain-path" });
51
+ }
52
+ const skillDirs = [DEFAULT_SKILLS_DIR, ...set.manifests.flatMap((m) => m.skillPaths.map((p) => p.path))];
53
+ if (skillDirs.some((skillDir) => skillDir !== "" && pathsOverlap(dir, skillDir))) {
54
+ return defaultDir(set, { value, manifest, reason: "overlaps-skills" });
55
+ }
56
+ return { dir };
57
+ }
58
+ /**
59
+ * The plugin-relative directory a manifest's `experimental.evals` names:
60
+ * an array's first entry, one `./` prefix stripped, then a path of plain
61
+ * directory names no longer than {@link EVAL_DIR_MAX_LENGTH}; `undefined`
62
+ * for anything else.
63
+ */
64
+ function declaredEvalDir(value) {
65
+ const entry = Array.isArray(value) ? value[0] : value;
66
+ if (typeof entry !== "string")
67
+ return undefined;
68
+ const path = entry.startsWith("./") ? entry.slice(2) : entry;
69
+ return path.length <= EVAL_DIR_MAX_LENGTH && isContainedPath(path) ? path : undefined;
70
+ }
71
+ /** `evals/`, with why the manifest's value was not used, and the declared skill path that holds it, if any. */
72
+ function defaultDir(set, unusable) {
73
+ const held = set.manifests.flatMap((m) => m.skillPaths).find((p) => p.path !== "" && pathsOverlap(DEFAULT_EVAL_DIR, p.path));
74
+ return {
75
+ dir: DEFAULT_EVAL_DIR,
76
+ ...(unusable !== undefined && { unusable }),
77
+ ...(held !== undefined && { heldBySkills: { path: held.path, manifest: held.manifest } }),
78
+ };
79
+ }
80
+ /** Whether one plugin-relative directory is the other or lies inside it. */
81
+ function pathsOverlap(a, b) {
82
+ return a === b || a.startsWith(`${b}/`) || b.startsWith(`${a}/`);
83
+ }
84
+ //# sourceMappingURL=eval-dir.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eval-dir.js","sourceRoot":"","sources":["../src/evals/eval-dir.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CA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,CAAC;KAC1F,CAAC;AACJ,CAAC;AAED,4EAA4E;AAC5E,SAAS,YAAY,CAAC,CAAS,EAAE,CAAS;IACxC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACnE,CAAC"}
@@ -0,0 +1,78 @@
1
+ /**
2
+ * The field readers every eval document shares: a collector for the
3
+ * sentences a case's files produce, the typed reads over a parsed YAML
4
+ * mapping, and the regex compile check.
5
+ *
6
+ * Every finding is one sentence that starts with the plugin-relative file
7
+ * and names the field, the shape Claude Code's loader prints
8
+ * (`prompt.md: unknown frontmatter key 'foo'`), so the CLI and the plugin
9
+ * page show an author the same words. A read that fails records its finding
10
+ * and returns `undefined`; the caller keeps reading so one pass names every
11
+ * problem in the file, and the case loads only when its collector stayed
12
+ * empty.
13
+ *
14
+ * Regexes are compiled here and never run: compiling a JavaScript pattern
15
+ * is linear in its length, and running author patterns is the grader's
16
+ * job, behind its own time limit.
17
+ *
18
+ * A finding quotes at most {@link QUOTED_TEXT_LIMIT} characters of an
19
+ * author's value, then an ellipsis: the findings are stored on the plugin,
20
+ * and one huge key, pattern or version string in a compressible archive
21
+ * would otherwise bloat that row past what one API message carries. The
22
+ * first characters are enough to find the value in the file.
23
+ */
24
+ import { type JsonObject } from "../documents.js";
25
+ import type { EvalSuiteFinding } from "./types.js";
26
+ export type EvalFindingKind = EvalSuiteFinding["kind"];
27
+ /** The most characters of an author's value one finding quotes. */
28
+ export declare const QUOTED_TEXT_LIMIT = 200;
29
+ /** `text`, cut to {@link QUOTED_TEXT_LIMIT} characters and an ellipsis when longer, never inside a surrogate pair. */
30
+ export declare function excerpt(text: string): string;
31
+ /** `text`, cut to `limit` UTF-16 code units and an ellipsis when longer, never inside a surrogate pair. */
32
+ export declare function cutText(text: string, limit: number): string;
33
+ /** An author's text in single quotes, as a finding names it. */
34
+ export declare function quote(text: string): string;
35
+ /** A value read from YAML, as JSON, as a finding names a value of the wrong kind. */
36
+ export declare function quoteJson(value: unknown): string;
37
+ /** The findings one case's files produced. */
38
+ export declare class CaseFindings {
39
+ readonly list: EvalSuiteFinding[];
40
+ add(kind: EvalFindingKind, path: string, problem: string): void;
41
+ get empty(): boolean;
42
+ }
43
+ /** Where a field is being read: the file, how its fields are named, and the kind a wrong value is. */
44
+ export interface FieldScope {
45
+ readonly path: string;
46
+ /** Prepended to each field name in a sentence, e.g. "execution." or "grader 'x': ". */
47
+ readonly label: string;
48
+ readonly invalid: Extract<EvalFindingKind, "eval-case-invalid" | "eval-grader-invalid" | "eval-mock-invalid">;
49
+ readonly findings: CaseFindings;
50
+ }
51
+ export declare function wrong(scope: FieldScope, field: string, expected: string): undefined;
52
+ /** Report every key of `object` not in `known` as `kind`, in document order. */
53
+ export declare function unknownKeys(object: JsonObject, known: ReadonlySet<string>, scope: FieldScope, kind: EvalFindingKind, noun: string): void;
54
+ export declare function readString(object: JsonObject, field: string, scope: FieldScope): string | undefined;
55
+ export declare function readNonEmptyString(object: JsonObject, field: string, scope: FieldScope): string | undefined;
56
+ export declare function readStringList(object: JsonObject, field: string, scope: FieldScope): readonly string[] | undefined;
57
+ /** A whole number from `min` to `max`, inclusive. */
58
+ export declare function readInteger(object: JsonObject, field: string, min: number, max: number, scope: FieldScope): number | undefined;
59
+ /** Keys an `env` map may carry, the format's rule. */
60
+ export declare const EVAL_ENV_KEY_PATTERN: RegExp;
61
+ /**
62
+ * An `env` map. A scalar value is kept as its string form, since YAML reads
63
+ * `EVAL_LEVEL: 2` as a number and the child process sees text either way.
64
+ */
65
+ export declare function readEnv(object: JsonObject, field: string, scope: FieldScope): Readonly<Record<string, string>> | undefined;
66
+ /** The case format version this reader reads. */
67
+ export declare const EVAL_SCHEMA_VERSION = "1.1";
68
+ /**
69
+ * `schema_version`: `"1.1"`, or the number YAML reads from an unquoted
70
+ * `1.1`. `true` when it is that version, `false` after a finding.
71
+ */
72
+ export declare function checkSchemaVersion(value: unknown, scope: FieldScope): boolean;
73
+ /**
74
+ * The compile error of a JavaScript regex, or `undefined` when it compiles.
75
+ * The engine's message repeats the whole pattern; it is quoted as an excerpt.
76
+ */
77
+ export declare function regexError(pattern: string, flags: string): string | undefined;
78
+ //# sourceMappingURL=fields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../src/evals/fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAA+B,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC/E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,MAAM,eAAe,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;AAEvD,mEAAmE;AACnE,eAAO,MAAM,iBAAiB,MAAM,CAAC;AAErC,sHAAsH;AACtH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5C;AAED,2GAA2G;AAC3G,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI3D;AAED,gEAAgE;AAChE,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1C;AAED,qFAAqF;AACrF,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEhD;AAED,8CAA8C;AAC9C,qBAAa,YAAY;IACvB,QAAQ,CAAC,IAAI,EAAE,gBAAgB,EAAE,CAAM;IAEvC,GAAG,CAAC,IAAI,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAI/D,IAAI,KAAK,IAAI,OAAO,CAEnB;CACF;AAED,sGAAsG;AACtG,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uFAAuF;IACvF,Q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,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,GAAG,SAAS,CAoB1H;AAED,iDAAiD;AACjD,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAEzC;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAQ7E;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQ7E"}
@@ -0,0 +1,156 @@
1
+ /**
2
+ * The field readers every eval document shares: a collector for the
3
+ * sentences a case's files produce, the typed reads over a parsed YAML
4
+ * mapping, and the regex compile check.
5
+ *
6
+ * Every finding is one sentence that starts with the plugin-relative file
7
+ * and names the field, the shape Claude Code's loader prints
8
+ * (`prompt.md: unknown frontmatter key 'foo'`), so the CLI and the plugin
9
+ * page show an author the same words. A read that fails records its finding
10
+ * and returns `undefined`; the caller keeps reading so one pass names every
11
+ * problem in the file, and the case loads only when its collector stayed
12
+ * empty.
13
+ *
14
+ * Regexes are compiled here and never run: compiling a JavaScript pattern
15
+ * is linear in its length, and running author patterns is the grader's
16
+ * job, behind its own time limit.
17
+ *
18
+ * A finding quotes at most {@link QUOTED_TEXT_LIMIT} characters of an
19
+ * author's value, then an ellipsis: the findings are stored on the plugin,
20
+ * and one huge key, pattern or version string in a compressible archive
21
+ * would otherwise bloat that row past what one API message carries. The
22
+ * first characters are enough to find the value in the file.
23
+ */
24
+ import { isJsonObject, isStringArray } from "../documents.js";
25
+ /** The most characters of an author's value one finding quotes. */
26
+ export const QUOTED_TEXT_LIMIT = 200;
27
+ /** `text`, cut to {@link QUOTED_TEXT_LIMIT} characters and an ellipsis when longer, never inside a surrogate pair. */
28
+ export function excerpt(text) {
29
+ return cutText(text, QUOTED_TEXT_LIMIT);
30
+ }
31
+ /** `text`, cut to `limit` UTF-16 code units and an ellipsis when longer, never inside a surrogate pair. */
32
+ export function cutText(text, limit) {
33
+ if (text.length <= limit)
34
+ return text;
35
+ const cut = text.slice(0, limit);
36
+ return `${/[\uD800-\uDBFF]$/.test(cut) ? cut.slice(0, -1) : cut}…`;
37
+ }
38
+ /** An author's text in single quotes, as a finding names it. */
39
+ export function quote(text) {
40
+ return `'${excerpt(text)}'`;
41
+ }
42
+ /** A value read from YAML, as JSON, as a finding names a value of the wrong kind. */
43
+ export function quoteJson(value) {
44
+ return excerpt(JSON.stringify(value));
45
+ }
46
+ /** The findings one case's files produced. */
47
+ export class CaseFindings {
48
+ list = [];
49
+ add(kind, path, problem) {
50
+ this.list.push({ kind, path, message: `${path}: ${problem}` });
51
+ }
52
+ get empty() {
53
+ return this.list.length === 0;
54
+ }
55
+ }
56
+ export function wrong(scope, field, expected) {
57
+ scope.findings.add(scope.invalid, scope.path, `${scope.label}${field} must be ${expected}`);
58
+ return undefined;
59
+ }
60
+ /** Report every key of `object` not in `known` as `kind`, in document order. */
61
+ export function unknownKeys(object, known, scope, kind, noun) {
62
+ for (const key of Object.keys(object)) {
63
+ if (!known.has(key))
64
+ scope.findings.add(kind, scope.path, `unknown ${noun} ${quote(`${scope.label}${key}`)}`);
65
+ }
66
+ }
67
+ export function readString(object, field, scope) {
68
+ const value = object[field];
69
+ if (value === undefined)
70
+ return undefined;
71
+ if (typeof value !== "string")
72
+ return wrong(scope, field, "a string");
73
+ return value;
74
+ }
75
+ export function readNonEmptyString(object, field, scope) {
76
+ const value = object[field];
77
+ if (value === undefined)
78
+ return undefined;
79
+ if (typeof value !== "string" || value.trim() === "")
80
+ return wrong(scope, field, "a non-empty string");
81
+ return value;
82
+ }
83
+ export function readStringList(object, field, scope) {
84
+ const value = object[field];
85
+ if (value === undefined)
86
+ return undefined;
87
+ if (!isStringArray(value))
88
+ return wrong(scope, field, "a list of strings");
89
+ return value;
90
+ }
91
+ /** A whole number from `min` to `max`, inclusive. */
92
+ export function readInteger(object, field, min, max, scope) {
93
+ const value = object[field];
94
+ if (value === undefined)
95
+ return undefined;
96
+ if (typeof value !== "number" || !Number.isInteger(value) || value < min || value > max) {
97
+ return wrong(scope, field, `a whole number from ${min} to ${max}`);
98
+ }
99
+ return value;
100
+ }
101
+ /** Keys an `env` map may carry, the format's rule. */
102
+ export const EVAL_ENV_KEY_PATTERN = /^EVAL_[A-Z0-9_]*$/;
103
+ /**
104
+ * An `env` map. A scalar value is kept as its string form, since YAML reads
105
+ * `EVAL_LEVEL: 2` as a number and the child process sees text either way.
106
+ */
107
+ export function readEnv(object, field, scope) {
108
+ const value = object[field];
109
+ if (value === undefined)
110
+ return undefined;
111
+ if (!isJsonObject(value))
112
+ return wrong(scope, field, "a map of EVAL_* names to values");
113
+ const env = {};
114
+ let ok = true;
115
+ for (const [key, item] of Object.entries(value)) {
116
+ if (!EVAL_ENV_KEY_PATTERN.test(key)) {
117
+ scope.findings.add(scope.invalid, scope.path, `${scope.label}${field} key ${quote(key)} must match EVAL_[A-Z0-9_]*`);
118
+ ok = false;
119
+ continue;
120
+ }
121
+ if (typeof item !== "string" && typeof item !== "number" && typeof item !== "boolean") {
122
+ wrong(scope, `${field}.${excerpt(key)}`, "a string, number or boolean");
123
+ ok = false;
124
+ continue;
125
+ }
126
+ env[key] = String(item);
127
+ }
128
+ return ok ? env : undefined;
129
+ }
130
+ /** The case format version this reader reads. */
131
+ export const EVAL_SCHEMA_VERSION = "1.1";
132
+ /**
133
+ * `schema_version`: `"1.1"`, or the number YAML reads from an unquoted
134
+ * `1.1`. `true` when it is that version, `false` after a finding.
135
+ */
136
+ export function checkSchemaVersion(value, scope) {
137
+ if (value === EVAL_SCHEMA_VERSION || value === 1.1)
138
+ return true;
139
+ scope.findings.add("eval-schema-version-unsupported", scope.path, `schema_version ${quoteJson(value)} is not supported; this reader reads "${EVAL_SCHEMA_VERSION}"`);
140
+ return false;
141
+ }
142
+ /**
143
+ * The compile error of a JavaScript regex, or `undefined` when it compiles.
144
+ * The engine's message repeats the whole pattern; it is quoted as an excerpt.
145
+ */
146
+ export function regexError(pattern, flags) {
147
+ try {
148
+ new RegExp(pattern, flags);
149
+ return undefined;
150
+ }
151
+ catch (error) {
152
+ const message = error instanceof Error ? error.message : String(error);
153
+ return message.replace(`/${pattern}/`, () => `/${excerpt(pattern)}/`);
154
+ }
155
+ }
156
+ //# sourceMappingURL=fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fields.js","sourceRoot":"","sources":["../src/evals/fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAmB,MAAM,iBAAiB,CAAC;AAK/E,mEAAmE;AACnE,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAErC,sHAAsH;AACtH,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,OAAO,CAAC,IAAI,EAAE,iBAAiB,CAAC,CAAC;AAC1C,CAAC;AAED,2GAA2G;AAC3G,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,KAAa;IACjD,IAAI,IAAI,CAAC,MAAM,IAAI,KAAK;QAAE,OAAO,IAAI,CAAC;IACtC,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IACjC,OAAO,GAAG,kBAAkB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;AACrE,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,KAAK,CAAC,IAAY;IAChC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC;AAC9B,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,OAAO,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;AACxC,CAAC;AAED,8CAA8C;AAC9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;IACD,OAAO,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9B,CAAC;AAED,iDAAiD;AACjD,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAEzC;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc,EAAE,KAAiB;IAClE,IAAI,KAAK,KAAK,mBAAmB,IAAI,KAAK,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IAChE,KAAK,CAAC,QAAQ,CAAC,GAAG,CAChB,iCAAiC,EACjC,KAAK,CAAC,IAAI,EACV,kBAAkB,SAAS,CAAC,KAAK,CAAC,yCAAyC,mBAAmB,GAAG,CAClG,CAAC;IACF,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,OAAe,EAAE,KAAa;IACvD,IAAI,CAAC;QACH,IAAI,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;QAC3B,OAAO,SAAS,CAAC;IACnB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,OAAO,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACxE,CAAC;AACH,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Whether a glob is well formed, in the grammar Stigmer's eval graders
3
+ * match with: `*`, `**`, `?`, `[...]` classes with ranges and `!` or `^`
4
+ * negation (a `]` right after the opening or the negation is a member),
5
+ * and `{a,b}` alternatives that may nest, expanding to at most
6
+ * GLOB_MAX_ALTERNATIVES and nesting at most GLOB_MAX_BRACE_DEPTH deep;
7
+ * everything else is literal, a `}` with no `{` included.
8
+ *
9
+ * A glob is also bounded in size, because a match costs its alternatives
10
+ * times their tokens times the path's length: at most GLOB_MAX_LENGTH
11
+ * characters, and at most GLOB_MAX_TOKENS tokens summed over every
12
+ * alternative it expands to. A token is a literal character, a `?`, a
13
+ * class, or a run of stars; a `/` right after `**` counts as its own token,
14
+ * so the count does not depend on whether the glob matches paths or names,
15
+ * and a class counts once per range or character it holds, since the
16
+ * matcher tests a character against each of them. A class holds at most
17
+ * GLOB_MAX_CLASS_ITEMS ranges or characters.
18
+ *
19
+ * Only validity is checked here: the suite reader refuses a `file_exists`
20
+ * grader whose `path` is malformed (too long, a class or a brace never
21
+ * closed, a reversed range, a class too large, too many alternatives or
22
+ * tokens, braces nested too deep), so the author hears it at push rather than as a try left not
23
+ * graded. The server
24
+ * compiles and matches globs with its own matcher over the same grammar,
25
+ * and its tests pin the two readers to one table, error sentences
26
+ * included.
27
+ */
28
+ /** The most alternatives a glob's braces may expand to. */
29
+ export declare const GLOB_MAX_ALTERNATIVES = 64;
30
+ /** The deepest braces may nest. */
31
+ export declare const GLOB_MAX_BRACE_DEPTH = 16;
32
+ /** The most characters (code points) a glob may hold. */
33
+ export declare const GLOB_MAX_LENGTH = 1024;
34
+ /** The most tokens a glob may expand to, summed over its alternatives. */
35
+ export declare const GLOB_MAX_TOKENS = 4096;
36
+ /** The most ranges or characters one `[...]` class may hold. */
37
+ export declare const GLOB_MAX_CLASS_ITEMS = 32;
38
+ /** Why `glob` is malformed, or `undefined` when it is a glob. */
39
+ export declare function globError(glob: string): string | undefined;
40
+ //# sourceMappingURL=glob.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob.d.ts","sourceRoot":"","sources":["../src/evals/glob.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,2DAA2D;AAC3D,eAAO,MAAM,qBAAqB,KAAK,CAAC;AAExC,mCAAmC;AACnC,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,yDAAyD;AACzD,eAAO,MAAM,eAAe,OAAO,CAAC;AAEpC,0EAA0E;AAC1E,eAAO,MAAM,eAAe,OAAO,CAAC;AAEpC,gEAAgE;AAChE,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAkBvC,iEAAiE;AACjE,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgF1D"}