@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.
- package/LICENSE +194 -0
- package/README.md +72 -0
- package/client/archive.d.ts +27 -0
- package/client/archive.d.ts.map +1 -0
- package/client/archive.js +38 -0
- package/client/archive.js.map +1 -0
- package/client/builtin.d.ts +37 -0
- package/client/builtin.d.ts.map +1 -0
- package/client/builtin.js +49 -0
- package/client/builtin.js.map +1 -0
- package/client/ignore/defaults.d.ts +2 -0
- package/client/ignore/defaults.d.ts.map +1 -0
- package/client/ignore/defaults.js +140 -0
- package/client/ignore/defaults.js.map +1 -0
- package/client/ignore/match.d.ts +3 -0
- package/client/ignore/match.d.ts.map +1 -0
- package/client/ignore/match.js +166 -0
- package/client/ignore/match.js.map +1 -0
- package/client/ignore/matcher.d.ts +50 -0
- package/client/ignore/matcher.d.ts.map +1 -0
- package/client/ignore/matcher.js +116 -0
- package/client/ignore/matcher.js.map +1 -0
- package/client/ignore/pattern.d.ts +13 -0
- package/client/ignore/pattern.d.ts.map +1 -0
- package/client/ignore/pattern.js +119 -0
- package/client/ignore/pattern.js.map +1 -0
- package/client/prepare-eval.d.ts +62 -0
- package/client/prepare-eval.d.ts.map +1 -0
- package/client/prepare-eval.js +60 -0
- package/client/prepare-eval.js.map +1 -0
- package/client/prepare.d.ts +99 -0
- package/client/prepare.d.ts.map +1 -0
- package/client/prepare.js +89 -0
- package/client/prepare.js.map +1 -0
- package/client/presentation.d.ts +19 -0
- package/client/presentation.d.ts.map +1 -0
- package/client/presentation.js +44 -0
- package/client/presentation.js.map +1 -0
- package/client/refs.d.ts +76 -0
- package/client/refs.d.ts.map +1 -0
- package/client/refs.js +123 -0
- package/client/refs.js.map +1 -0
- package/client/release.d.ts +20 -0
- package/client/release.d.ts.map +1 -0
- package/client/release.js +28 -0
- package/client/release.js.map +1 -0
- package/client/reroot.d.ts +21 -0
- package/client/reroot.d.ts.map +1 -0
- package/client/reroot.js +37 -0
- package/client/reroot.js.map +1 -0
- package/client/select.d.ts +74 -0
- package/client/select.d.ts.map +1 -0
- package/client/select.js +121 -0
- package/client/select.js.map +1 -0
- package/client/vocabulary.d.ts +13 -0
- package/client/vocabulary.d.ts.map +1 -0
- package/client/vocabulary.js +17 -0
- package/client/vocabulary.js.map +1 -0
- package/client.d.ts +51 -0
- package/client.d.ts.map +1 -0
- package/client.js +51 -0
- package/client.js.map +1 -0
- package/detect.d.ts +83 -0
- package/detect.d.ts.map +1 -0
- package/detect.js +210 -0
- package/detect.js.map +1 -0
- package/dialects/claude.d.ts +34 -0
- package/dialects/claude.d.ts.map +1 -0
- package/dialects/claude.js +84 -0
- package/dialects/claude.js.map +1 -0
- package/dialects/codex.d.ts +20 -0
- package/dialects/codex.d.ts.map +1 -0
- package/dialects/codex.js +21 -0
- package/dialects/codex.js.map +1 -0
- package/dialects/cursor.d.ts +25 -0
- package/dialects/cursor.d.ts.map +1 -0
- package/dialects/cursor.js +66 -0
- package/dialects/cursor.js.map +1 -0
- package/dialects/manifest.d.ts +164 -0
- package/dialects/manifest.d.ts.map +1 -0
- package/dialects/manifest.js +256 -0
- package/dialects/manifest.js.map +1 -0
- package/dialects/open.d.ts +19 -0
- package/dialects/open.d.ts.map +1 -0
- package/dialects/open.js +49 -0
- package/dialects/open.js.map +1 -0
- package/documents.d.ts +58 -0
- package/documents.d.ts.map +1 -0
- package/documents.js +121 -0
- package/documents.js.map +1 -0
- package/evals/eval-dir.d.ts +59 -0
- package/evals/eval-dir.d.ts.map +1 -0
- package/evals/eval-dir.js +84 -0
- package/evals/eval-dir.js.map +1 -0
- package/evals/fields.d.ts +78 -0
- package/evals/fields.d.ts.map +1 -0
- package/evals/fields.js +156 -0
- package/evals/fields.js.map +1 -0
- package/evals/glob.d.ts +40 -0
- package/evals/glob.d.ts.map +1 -0
- package/evals/glob.js +146 -0
- package/evals/glob.js.map +1 -0
- package/evals/graders.d.ts +52 -0
- package/evals/graders.d.ts.map +1 -0
- package/evals/graders.js +279 -0
- package/evals/graders.js.map +1 -0
- package/evals/markdown.d.ts +24 -0
- package/evals/markdown.d.ts.map +1 -0
- package/evals/markdown.js +48 -0
- package/evals/markdown.js.map +1 -0
- package/evals/mocks.d.ts +50 -0
- package/evals/mocks.d.ts.map +1 -0
- package/evals/mocks.js +182 -0
- package/evals/mocks.js.map +1 -0
- package/evals/read-eval-suite.d.ts +110 -0
- package/evals/read-eval-suite.d.ts.map +1 -0
- package/evals/read-eval-suite.js +603 -0
- package/evals/read-eval-suite.js.map +1 -0
- package/evals/summary.d.ts +61 -0
- package/evals/summary.d.ts.map +1 -0
- package/evals/summary.js +69 -0
- package/evals/summary.js.map +1 -0
- package/evals/types.d.ts +203 -0
- package/evals/types.d.ts.map +1 -0
- package/evals/types.js +21 -0
- package/evals/types.js.map +1 -0
- package/files.d.ts +135 -0
- package/files.d.ts.map +1 -0
- package/files.js +209 -0
- package/files.js.map +1 -0
- package/frontmatter.d.ts +51 -0
- package/frontmatter.d.ts.map +1 -0
- package/frontmatter.js +61 -0
- package/frontmatter.js.map +1 -0
- package/index.d.ts +37 -0
- package/index.d.ts.map +1 -0
- package/index.js +33 -0
- package/index.js.map +1 -0
- package/marketplace/messages.d.ts +20 -0
- package/marketplace/messages.d.ts.map +1 -0
- package/marketplace/messages.js +49 -0
- package/marketplace/messages.js.map +1 -0
- package/marketplace/outcome.d.ts +70 -0
- package/marketplace/outcome.d.ts.map +1 -0
- package/marketplace/outcome.js +29 -0
- package/marketplace/outcome.js.map +1 -0
- package/marketplace/read-marketplace.d.ts +52 -0
- package/marketplace/read-marketplace.d.ts.map +1 -0
- package/marketplace/read-marketplace.js +351 -0
- package/marketplace/read-marketplace.js.map +1 -0
- package/messages.d.ts +55 -0
- package/messages.d.ts.map +1 -0
- package/messages.js +167 -0
- package/messages.js.map +1 -0
- package/normalise/hooks.d.ts +91 -0
- package/normalise/hooks.d.ts.map +1 -0
- package/normalise/hooks.js +437 -0
- package/normalise/hooks.js.map +1 -0
- package/normalise/ignored.d.ts +34 -0
- package/normalise/ignored.d.ts.map +1 -0
- package/normalise/ignored.js +78 -0
- package/normalise/ignored.js.map +1 -0
- package/normalise/mcp-servers.d.ts +50 -0
- package/normalise/mcp-servers.d.ts.map +1 -0
- package/normalise/mcp-servers.js +398 -0
- package/normalise/mcp-servers.js.map +1 -0
- package/normalise/settings.d.ts +32 -0
- package/normalise/settings.d.ts.map +1 -0
- package/normalise/settings.js +72 -0
- package/normalise/settings.js.map +1 -0
- package/normalise/skills.d.ts +39 -0
- package/normalise/skills.d.ts.map +1 -0
- package/normalise/skills.js +135 -0
- package/normalise/skills.js.map +1 -0
- package/normalise/stigmer-folder.d.ts +17 -0
- package/normalise/stigmer-folder.d.ts.map +1 -0
- package/normalise/stigmer-folder.js +19 -0
- package/normalise/stigmer-folder.js.map +1 -0
- package/normalise/sub-agents.d.ts +54 -0
- package/normalise/sub-agents.d.ts.map +1 -0
- package/normalise/sub-agents.js +219 -0
- package/normalise/sub-agents.js.map +1 -0
- package/normalise/variables.d.ts +31 -0
- package/normalise/variables.d.ts.map +1 -0
- package/normalise/variables.js +170 -0
- package/normalise/variables.js.map +1 -0
- package/outcome.d.ts +59 -0
- package/outcome.d.ts.map +1 -0
- package/outcome.js +32 -0
- package/outcome.js.map +1 -0
- package/package.json +47 -0
- package/placeholders.d.ts +65 -0
- package/placeholders.d.ts.map +1 -0
- package/placeholders.js +99 -0
- package/placeholders.js.map +1 -0
- package/presentation.d.ts +53 -0
- package/presentation.d.ts.map +1 -0
- package/presentation.js +156 -0
- package/presentation.js.map +1 -0
- package/read-plugin-package.d.ts +20 -0
- package/read-plugin-package.d.ts.map +1 -0
- package/read-plugin-package.js +73 -0
- package/read-plugin-package.js.map +1 -0
- package/src/client/archive.ts +44 -0
- package/src/client/builtin.ts +60 -0
- package/src/client/ignore/defaults.ts +155 -0
- package/src/client/ignore/match.ts +158 -0
- package/src/client/ignore/matcher.ts +156 -0
- package/src/client/ignore/pattern.ts +132 -0
- package/src/client/prepare-eval.ts +92 -0
- package/src/client/prepare.ts +160 -0
- package/src/client/presentation.ts +47 -0
- package/src/client/refs.ts +170 -0
- package/src/client/release.ts +29 -0
- package/src/client/reroot.ts +35 -0
- package/src/client/select.ts +161 -0
- package/src/client/vocabulary.ts +19 -0
- package/src/client.ts +102 -0
- package/src/detect.ts +245 -0
- package/src/dialects/claude.ts +102 -0
- package/src/dialects/codex.ts +26 -0
- package/src/dialects/cursor.ts +77 -0
- package/src/dialects/manifest.ts +316 -0
- package/src/dialects/open.ts +50 -0
- package/src/documents.ts +158 -0
- package/src/evals/eval-dir.ts +101 -0
- package/src/evals/fields.ts +184 -0
- package/src/evals/glob.ts +141 -0
- package/src/evals/graders.ts +293 -0
- package/src/evals/markdown.ts +56 -0
- package/src/evals/mocks.ts +202 -0
- package/src/evals/read-eval-suite.ts +713 -0
- package/src/evals/summary.ts +100 -0
- package/src/evals/types.ts +217 -0
- package/src/files.ts +235 -0
- package/src/frontmatter.ts +70 -0
- package/src/index.ts +129 -0
- package/src/marketplace/messages.ts +61 -0
- package/src/marketplace/outcome.ts +91 -0
- package/src/marketplace/read-marketplace.ts +388 -0
- package/src/messages.ts +248 -0
- package/src/normalise/hooks.ts +469 -0
- package/src/normalise/ignored.ts +79 -0
- package/src/normalise/mcp-servers.ts +423 -0
- package/src/normalise/settings.ts +81 -0
- package/src/normalise/skills.ts +145 -0
- package/src/normalise/stigmer-folder.ts +23 -0
- package/src/normalise/sub-agents.ts +231 -0
- package/src/normalise/variables.ts +181 -0
- package/src/outcome.ts +158 -0
- package/src/placeholders.ts +110 -0
- package/src/presentation.ts +170 -0
- package/src/read-plugin-package.ts +80 -0
- package/src/testing.ts +347 -0
- package/src/tool-names.ts +30 -0
- package/src/trim.ts +10 -0
- package/src/types.ts +214 -0
- package/testing.d.ts +127 -0
- package/testing.d.ts.map +1 -0
- package/testing.js +266 -0
- package/testing.js.map +1 -0
- package/tool-names.d.ts +21 -0
- package/tool-names.d.ts.map +1 -0
- package/tool-names.js +28 -0
- package/tool-names.js.map +1 -0
- package/trim.d.ts +7 -0
- package/trim.d.ts.map +1 -0
- package/trim.js +12 -0
- package/trim.js.map +1 -0
- package/types.d.ts +179 -0
- package/types.d.ts.map +1 -0
- package/types.js +19 -0
- package/types.js.map +1 -0
package/files.js
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The reader the library is pure over, and the path discipline every path in
|
|
3
|
+
* a package obeys.
|
|
4
|
+
*
|
|
5
|
+
* `PluginFiles` is a sorted list of SIZED entries plus `read`. The size is
|
|
6
|
+
* declared up front so the library can refuse an over-cap document before a
|
|
7
|
+
* byte is read: an archive reader may hold a deflated entry whose declared
|
|
8
|
+
* size is the only defence against inflating a bomb, and a cap checked after
|
|
9
|
+
* `read` would be no defence at all. The reader's contract is that `read`
|
|
10
|
+
* never returns more than `size` bytes (a directory reader uses the file's
|
|
11
|
+
* stat size; an archive reader passes the central directory's declared size
|
|
12
|
+
* as its inflate limit). The library checks both sides anyway: the declared
|
|
13
|
+
* size before reading, the returned length after, refusing either as
|
|
14
|
+
* `document-too-large`. Nothing here touches the filesystem or any `node:*`
|
|
15
|
+
* module; the CLI's directory walker and the server's archive reader each
|
|
16
|
+
* implement this interface at their edge.
|
|
17
|
+
*
|
|
18
|
+
* Containment is lexical here and physical in each reader. A listed path
|
|
19
|
+
* that is absolute, contains `..` or a backslash, or has an empty segment is
|
|
20
|
+
* refused by the library; a reader never follows a symlink, and an archive
|
|
21
|
+
* has none. A path DECLARED in a manifest must begin with `./` (or be `.`),
|
|
22
|
+
* the open format's rule for every plugin-relative path.
|
|
23
|
+
*/
|
|
24
|
+
import { trimTrailing } from "./trim.js";
|
|
25
|
+
/**
|
|
26
|
+
* Per-document byte caps, checked from declared sizes. A plugin's documents
|
|
27
|
+
* are small by nature; the caps exist so no reader can be made to inflate
|
|
28
|
+
* a large entry through the library, not to bound legitimate content.
|
|
29
|
+
*/
|
|
30
|
+
export const PLUGIN_DOCUMENT_LIMITS = {
|
|
31
|
+
/** A manifest (`plugin.json` in any dialect). Real manifests are a few KB. */
|
|
32
|
+
manifest: 256 * 1024,
|
|
33
|
+
/** An MCP configuration file. */
|
|
34
|
+
mcpConfig: 256 * 1024,
|
|
35
|
+
/** A hooks file (`hooks/hooks.json` or a declared one): JSON, the manifest's cap. */
|
|
36
|
+
hooks: 256 * 1024,
|
|
37
|
+
/** A Claude plugin's `settings.json`: JSON, the manifest's cap. */
|
|
38
|
+
settings: 256 * 1024,
|
|
39
|
+
/**
|
|
40
|
+
* A `SKILL.md`. The server's skill push gate inflates a `SKILL.md` alone
|
|
41
|
+
* under the same 1 MB cap, so a skill this library accepts is one the push
|
|
42
|
+
* gate accepts.
|
|
43
|
+
*/
|
|
44
|
+
skillMd: 1024 * 1024,
|
|
45
|
+
/** A sub-agent file (`agents/*.md`): a prompt, so the `SKILL.md` cap. */
|
|
46
|
+
subAgent: 1024 * 1024,
|
|
47
|
+
/**
|
|
48
|
+
* A plugin's logo, the image a storefront card shows. Checked from the
|
|
49
|
+
* listing's declared size before a client hands the file's URL to an
|
|
50
|
+
* `<img>`; measured across the three vendors' catalogues on 2026-09-18,
|
|
51
|
+
* the largest published logo is 361 KB and the median 7.5 KB.
|
|
52
|
+
*/
|
|
53
|
+
logo: 1024 * 1024,
|
|
54
|
+
/**
|
|
55
|
+
* A marketplace file in any dialect. The largest public catalogue
|
|
56
|
+
* (`cursor/plugins`, 79 entries with descriptions) is under 32 KB; the cap
|
|
57
|
+
* leaves room for catalogues an order of magnitude larger.
|
|
58
|
+
*/
|
|
59
|
+
marketplace: 1024 * 1024,
|
|
60
|
+
/**
|
|
61
|
+
* A file of a plugin's eval suite the reader opens: a `prompt.md`, a
|
|
62
|
+
* `case.yaml`, a `graders/*.md`. Prompts and rubrics, so the `SKILL.md`
|
|
63
|
+
* cap.
|
|
64
|
+
*/
|
|
65
|
+
evalDocument: 1024 * 1024,
|
|
66
|
+
};
|
|
67
|
+
const encoder = new TextEncoder();
|
|
68
|
+
// `fatal: false` keeps the decoder from throwing on a malformed sequence: a
|
|
69
|
+
// document with bad UTF-8 reaches the JSON or YAML parser, which refuses it
|
|
70
|
+
// with its own sentence, rather than crashing the read.
|
|
71
|
+
const decoder = new TextDecoder("utf-8", { fatal: false });
|
|
72
|
+
/** An in-memory `PluginFiles` over path -> content; the testing builders' product. */
|
|
73
|
+
export function inMemoryPluginFiles(files) {
|
|
74
|
+
const bytes = new Map();
|
|
75
|
+
for (const [path, content] of files) {
|
|
76
|
+
bytes.set(path, typeof content === "string" ? encoder.encode(content) : content);
|
|
77
|
+
}
|
|
78
|
+
const entries = [...bytes.entries()]
|
|
79
|
+
.map(([path, content]) => ({ path, size: content.length }))
|
|
80
|
+
.sort((a, b) => comparePaths(a.path, b.path));
|
|
81
|
+
return {
|
|
82
|
+
entries,
|
|
83
|
+
read(path) {
|
|
84
|
+
const content = bytes.get(path);
|
|
85
|
+
if (content === undefined) {
|
|
86
|
+
throw new Error(`plugin file '${path}' is not listed`);
|
|
87
|
+
}
|
|
88
|
+
return content;
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** Code-point order, the order `entries` is sorted in. */
|
|
93
|
+
export function comparePaths(a, b) {
|
|
94
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
95
|
+
}
|
|
96
|
+
/** UTF-8 text with a leading byte-order mark removed (a manifest saved with a BOM was a known load failure elsewhere). */
|
|
97
|
+
export function decodeUtf8(bytes) {
|
|
98
|
+
const text = decoder.decode(bytes);
|
|
99
|
+
return text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Lexical containment of a LISTED path: relative, forward slashes only, no
|
|
103
|
+
* `.` or `..` segments, no empty segments. Readers produce such paths; the
|
|
104
|
+
* library refuses a reader that did not.
|
|
105
|
+
*/
|
|
106
|
+
export function isContainedPath(path) {
|
|
107
|
+
if (path === "" || path.startsWith("/") || path.includes("\\"))
|
|
108
|
+
return false;
|
|
109
|
+
return path.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
|
|
110
|
+
}
|
|
111
|
+
const GLOB_CHARACTERS = /[*?[\]{}]/;
|
|
112
|
+
/**
|
|
113
|
+
* Normalise a path DECLARED in a manifest (`"./skills/"`, `"."`,
|
|
114
|
+
* `"./agents/reviewer.md"`) to a plugin-relative path with no leading `./`
|
|
115
|
+
* and no trailing slash; the plugin root itself is the empty string. The
|
|
116
|
+
* open format requires the `./` prefix; the vendor dialects document the
|
|
117
|
+
* same rule; a glob is refused because no plugin in the wild uses one and
|
|
118
|
+
* expanding globs is a second path language the library would then have
|
|
119
|
+
* to own.
|
|
120
|
+
*/
|
|
121
|
+
export function resolveDeclaredPath(value) {
|
|
122
|
+
if (GLOB_CHARACTERS.test(value))
|
|
123
|
+
return { ok: false, kind: "path-glob-unsupported" };
|
|
124
|
+
if (value === "." || value === "./")
|
|
125
|
+
return { ok: true, path: "" };
|
|
126
|
+
if (!value.startsWith("./"))
|
|
127
|
+
return { ok: false, kind: "path-not-relative" };
|
|
128
|
+
const trimmed = trimTrailing(value.slice(2), "/");
|
|
129
|
+
if (trimmed === "")
|
|
130
|
+
return { ok: true, path: "" };
|
|
131
|
+
if (!isContainedPath(trimmed))
|
|
132
|
+
return { ok: false, kind: "path-escapes-root" };
|
|
133
|
+
return { ok: true, path: trimmed };
|
|
134
|
+
}
|
|
135
|
+
/** `dir + "/" + name`, or `name` at the plugin root. */
|
|
136
|
+
export function joinPath(dir, name) {
|
|
137
|
+
return dir === "" ? name : `${dir}/${name}`;
|
|
138
|
+
}
|
|
139
|
+
/** The last segment of a plugin-relative path. */
|
|
140
|
+
export function basename(path) {
|
|
141
|
+
const slash = path.lastIndexOf("/");
|
|
142
|
+
return slash === -1 ? path : path.slice(slash + 1);
|
|
143
|
+
}
|
|
144
|
+
/** The path without its last segment; the empty string at the root. */
|
|
145
|
+
export function dirname(path) {
|
|
146
|
+
const slash = path.lastIndexOf("/");
|
|
147
|
+
return slash === -1 ? "" : path.slice(0, slash);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Indexed access over a `PluginFiles`: membership, the files under a
|
|
151
|
+
* directory, a directory's immediate children. Built once per read; every
|
|
152
|
+
* lookup is a map or a prefix walk over the sorted entries.
|
|
153
|
+
*/
|
|
154
|
+
export class PluginFileIndex {
|
|
155
|
+
files;
|
|
156
|
+
byPath;
|
|
157
|
+
constructor(files) {
|
|
158
|
+
this.files = files;
|
|
159
|
+
this.byPath = new Map(files.entries.map((entry) => [entry.path, entry]));
|
|
160
|
+
}
|
|
161
|
+
has(path) {
|
|
162
|
+
return this.byPath.has(path);
|
|
163
|
+
}
|
|
164
|
+
entry(path) {
|
|
165
|
+
return this.byPath.get(path);
|
|
166
|
+
}
|
|
167
|
+
/** Every file under `dir` (recursively), in entry order; every file at the root when `dir` is empty. */
|
|
168
|
+
filesUnder(dir) {
|
|
169
|
+
if (dir === "")
|
|
170
|
+
return this.files.entries.map((entry) => entry.path);
|
|
171
|
+
const prefix = `${dir}/`;
|
|
172
|
+
return this.files.entries.filter((entry) => entry.path.startsWith(prefix)).map((entry) => entry.path);
|
|
173
|
+
}
|
|
174
|
+
/** True when at least one file lives under `dir`. */
|
|
175
|
+
isDirectory(dir) {
|
|
176
|
+
if (dir === "")
|
|
177
|
+
return this.files.entries.length > 0;
|
|
178
|
+
const prefix = `${dir}/`;
|
|
179
|
+
return this.files.entries.some((entry) => entry.path.startsWith(prefix));
|
|
180
|
+
}
|
|
181
|
+
/** The immediate child directory names under `dir`, sorted, deduplicated. */
|
|
182
|
+
childDirectories(dir) {
|
|
183
|
+
const prefix = dir === "" ? "" : `${dir}/`;
|
|
184
|
+
const names = new Set();
|
|
185
|
+
for (const entry of this.files.entries) {
|
|
186
|
+
if (!entry.path.startsWith(prefix))
|
|
187
|
+
continue;
|
|
188
|
+
const rest = entry.path.slice(prefix.length);
|
|
189
|
+
const slash = rest.indexOf("/");
|
|
190
|
+
if (slash !== -1)
|
|
191
|
+
names.add(rest.slice(0, slash));
|
|
192
|
+
}
|
|
193
|
+
return [...names].sort(comparePaths);
|
|
194
|
+
}
|
|
195
|
+
/** The immediate child FILE names under `dir`, sorted. */
|
|
196
|
+
childFiles(dir) {
|
|
197
|
+
const prefix = dir === "" ? "" : `${dir}/`;
|
|
198
|
+
const names = [];
|
|
199
|
+
for (const entry of this.files.entries) {
|
|
200
|
+
if (!entry.path.startsWith(prefix))
|
|
201
|
+
continue;
|
|
202
|
+
const rest = entry.path.slice(prefix.length);
|
|
203
|
+
if (!rest.includes("/"))
|
|
204
|
+
names.push(rest);
|
|
205
|
+
}
|
|
206
|
+
return names.sort(comparePaths);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=files.js.map
|
package/files.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.js","sourceRoot":"","sources":["src/files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAgBzC;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,8EAA8E;IAC9E,QAAQ,EAAE,GAAG,GAAG,IAAI;IACpB,iCAAiC;IACjC,SAAS,EAAE,GAAG,GAAG,IAAI;IACrB,qFAAqF;IACrF,KAAK,EAAE,GAAG,GAAG,IAAI;IACjB,mEAAmE;IACnE,QAAQ,EAAE,GAAG,GAAG,IAAI;IACpB;;;;OAIG;IACH,OAAO,EAAE,IAAI,GAAG,IAAI;IACpB,yEAAyE;IACzE,QAAQ,EAAE,IAAI,GAAG,IAAI;IACrB;;;;;OAKG;IACH,IAAI,EAAE,IAAI,GAAG,IAAI;IACjB;;;;OAIG;IACH,WAAW,EAAE,IAAI,GAAG,IAAI;IACxB;;;;OAIG;IACH,YAAY,EAAE,IAAI,GAAG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,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;gBAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5C,CAAC;QACD,OAAO,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAClC,CAAC;CACF"}
|
package/frontmatter.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* YAML frontmatter extraction for `SKILL.md` and sub-agent files, and the
|
|
3
|
+
* skill name rule.
|
|
4
|
+
*
|
|
5
|
+
* The delimiter discipline is the server's skill push gate's: the file must
|
|
6
|
+
* open with `---` on its first line and close with `---` on a line of its
|
|
7
|
+
* own, both compared after trimming whitespace. Extraction and parsing are
|
|
8
|
+
* separate steps because the two callers differ on what a missing block
|
|
9
|
+
* means: a `SKILL.md` without frontmatter is refused (the Agent Skills
|
|
10
|
+
* format requires it), while a sub-agent file without frontmatter is a
|
|
11
|
+
* prompt named after its file (the Claude Code posture).
|
|
12
|
+
*
|
|
13
|
+
* `SKILL_NAME_PATTERN` is the server's rule for a skill name (kebab-case,
|
|
14
|
+
* optionally dot-scoped), a strict superset of the Agent Skills rule
|
|
15
|
+
* (lowercase alphanumerics and hyphens), so no skill valid under the open
|
|
16
|
+
* format is refused here. This module is meant to become the pattern's one
|
|
17
|
+
* home; the server's `frontmatter.ts` carries the same regex today.
|
|
18
|
+
*/
|
|
19
|
+
import { type JsonObject } from "./documents.js";
|
|
20
|
+
/**
|
|
21
|
+
* Kebab-case, optionally scoped with dot-separated namespaces. Every
|
|
22
|
+
* segment between separators is alphanumeric, so a name cannot start or end
|
|
23
|
+
* with a separator or contain consecutive separators. The derived slug
|
|
24
|
+
* renders dots as hyphens.
|
|
25
|
+
*/
|
|
26
|
+
export declare const SKILL_NAME_PATTERN: RegExp;
|
|
27
|
+
export type FrontmatterExtraction = {
|
|
28
|
+
readonly ok: true;
|
|
29
|
+
readonly yaml: string;
|
|
30
|
+
readonly body: string;
|
|
31
|
+
} | {
|
|
32
|
+
readonly ok: false;
|
|
33
|
+
readonly reason: "missing" | "unclosed";
|
|
34
|
+
};
|
|
35
|
+
/** Split a document into its frontmatter YAML and its body. */
|
|
36
|
+
export declare function extractFrontmatter(content: string): FrontmatterExtraction;
|
|
37
|
+
export type FrontmatterParse = {
|
|
38
|
+
readonly ok: true;
|
|
39
|
+
readonly fields: JsonObject;
|
|
40
|
+
} | {
|
|
41
|
+
readonly ok: false;
|
|
42
|
+
readonly detail: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Parse frontmatter YAML into a field map. An empty block is an empty map
|
|
46
|
+
* (the caller decides whether required fields are missing); a scalar or a
|
|
47
|
+
* list where a map was expected is a parse failure with its own detail.
|
|
48
|
+
* `yaml`'s defaults are the safe ones: no custom tags, aliases capped.
|
|
49
|
+
*/
|
|
50
|
+
export declare function parseFrontmatter(yaml: string): FrontmatterParse;
|
|
51
|
+
//# sourceMappingURL=frontmatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.d.ts","sourceRoot":"","sources":["src/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAIH,OAAO,EAAgB,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE/D;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,QAAgC,CAAC;AAEhE,MAAM,MAAM,qBAAqB,GAC7B;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACnE;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,GAAG,UAAU,CAAA;CAAE,CAAC;AAEpE,+DAA+D;AAC/D,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,qBAAqB,CAWzE;AAED,MAAM,MAAM,gBAAgB,GACxB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;CAAE,GAClD;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB,CAU/D"}
|
package/frontmatter.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* YAML frontmatter extraction for `SKILL.md` and sub-agent files, and the
|
|
3
|
+
* skill name rule.
|
|
4
|
+
*
|
|
5
|
+
* The delimiter discipline is the server's skill push gate's: the file must
|
|
6
|
+
* open with `---` on its first line and close with `---` on a line of its
|
|
7
|
+
* own, both compared after trimming whitespace. Extraction and parsing are
|
|
8
|
+
* separate steps because the two callers differ on what a missing block
|
|
9
|
+
* means: a `SKILL.md` without frontmatter is refused (the Agent Skills
|
|
10
|
+
* format requires it), while a sub-agent file without frontmatter is a
|
|
11
|
+
* prompt named after its file (the Claude Code posture).
|
|
12
|
+
*
|
|
13
|
+
* `SKILL_NAME_PATTERN` is the server's rule for a skill name (kebab-case,
|
|
14
|
+
* optionally dot-scoped), a strict superset of the Agent Skills rule
|
|
15
|
+
* (lowercase alphanumerics and hyphens), so no skill valid under the open
|
|
16
|
+
* format is refused here. This module is meant to become the pattern's one
|
|
17
|
+
* home; the server's `frontmatter.ts` carries the same regex today.
|
|
18
|
+
*/
|
|
19
|
+
import { parse as parseYaml } from "yaml";
|
|
20
|
+
import { isJsonObject } from "./documents.js";
|
|
21
|
+
/**
|
|
22
|
+
* Kebab-case, optionally scoped with dot-separated namespaces. Every
|
|
23
|
+
* segment between separators is alphanumeric, so a name cannot start or end
|
|
24
|
+
* with a separator or contain consecutive separators. The derived slug
|
|
25
|
+
* renders dots as hyphens.
|
|
26
|
+
*/
|
|
27
|
+
export const SKILL_NAME_PATTERN = /^[a-z0-9]+([.-][a-z0-9]+)*$/;
|
|
28
|
+
/** Split a document into its frontmatter YAML and its body. */
|
|
29
|
+
export function extractFrontmatter(content) {
|
|
30
|
+
const lines = content.split(/\r?\n/);
|
|
31
|
+
if (lines.length === 0 || lines[0]?.trim() !== "---") {
|
|
32
|
+
return { ok: false, reason: "missing" };
|
|
33
|
+
}
|
|
34
|
+
for (let i = 1; i < lines.length; i++) {
|
|
35
|
+
if (lines[i]?.trim() === "---") {
|
|
36
|
+
return { ok: true, yaml: lines.slice(1, i).join("\n"), body: lines.slice(i + 1).join("\n") };
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return { ok: false, reason: "unclosed" };
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Parse frontmatter YAML into a field map. An empty block is an empty map
|
|
43
|
+
* (the caller decides whether required fields are missing); a scalar or a
|
|
44
|
+
* list where a map was expected is a parse failure with its own detail.
|
|
45
|
+
* `yaml`'s defaults are the safe ones: no custom tags, aliases capped.
|
|
46
|
+
*/
|
|
47
|
+
export function parseFrontmatter(yaml) {
|
|
48
|
+
let value;
|
|
49
|
+
try {
|
|
50
|
+
value = parseYaml(yaml);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
return { ok: false, detail: error instanceof Error ? error.message : String(error) };
|
|
54
|
+
}
|
|
55
|
+
if (value === null || value === undefined)
|
|
56
|
+
return { ok: true, fields: {} };
|
|
57
|
+
if (!isJsonObject(value))
|
|
58
|
+
return { ok: false, detail: "the frontmatter is not a mapping" };
|
|
59
|
+
return { ok: true, fields: value };
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=frontmatter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frontmatter.js","sourceRoot":"","sources":["src/frontmatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,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KAAK,EAAE,MAAM,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;IACvF,CAAC;IACD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;IAC3E,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,kCAAkC,EAAE,CAAC;IAC3F,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;AACrC,CAAC"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@stigmer/plugin-package`: the public surface.
|
|
3
|
+
*
|
|
4
|
+
* `readPluginPackage` reads one plugin; `readMarketplace` reads a catalogue
|
|
5
|
+
* of them; `readPluginPresentation` reads what a card shows for one entry
|
|
6
|
+
* without opening the rest of it; `readEvalSuite` reads the plugin's own
|
|
7
|
+
* eval suite, which the install summarises and the eval workflow runs. Everything else here is what a consumer needs to supply its
|
|
8
|
+
* input (`PluginFiles`, the caps), route a directory (`MANIFEST_LOCATIONS`,
|
|
9
|
+
* `hasPluginManifest`, `MARKETPLACE_LOCATIONS`, `hasMarketplaceFile`), or
|
|
10
|
+
* render an outcome (the finding kinds and `isErrorKind`). The dialect
|
|
11
|
+
* readers and normalisers are internal: a consumer never composes a partial
|
|
12
|
+
* read.
|
|
13
|
+
*/
|
|
14
|
+
export { hasPluginManifest, isValidPluginName } from "./detect.js";
|
|
15
|
+
export { comparePaths, inMemoryPluginFiles, isContainedPath, PLUGIN_DOCUMENT_LIMITS, resolveDeclaredPath, type DeclaredPathOutcome, type PluginDocumentClass, type PluginFileEntry, type PluginFiles, } from "./files.js";
|
|
16
|
+
export { SKILL_NAME_PATTERN } from "./frontmatter.js";
|
|
17
|
+
export { AGENT_PLUGINS_MANIFEST_SCHEMA, AGENT_PLUGINS_MCP_SCHEMA, errorMessage, isErrorKind, MANIFEST_LOCATIONS, warningMessage, } from "./messages.js";
|
|
18
|
+
export { HOOK_CONDITION_PATTERN, RUN_EVENTS, hookVariableReferences, isValidMatcher } from "./normalise/hooks.js";
|
|
19
|
+
export { isAcceptableServerUrl } from "./normalise/mcp-servers.js";
|
|
20
|
+
export { SUB_AGENT_INSTRUCTIONS_MIN, classifyModel } from "./normalise/sub-agents.js";
|
|
21
|
+
export { PLACEHOLDER_PATTERN, PLATFORM_VARIABLES, RUNNER_FILLED_VARIABLES, VARIABLE_NAME_PATTERN, findPluginRootPlaceholder, } from "./placeholders.js";
|
|
22
|
+
export { HOOK_WARNING_KINDS } from "./outcome.js";
|
|
23
|
+
export type { Finding, FindingContext, PluginErrorKind, PluginFinding, PluginFindingKind, PluginReadOutcome, PluginWarningKind, } from "./outcome.js";
|
|
24
|
+
export { MARKETPLACE_LOCATIONS } from "./marketplace/messages.js";
|
|
25
|
+
export type { Marketplace, MarketplaceDialect, MarketplaceEntry, MarketplaceErrorKind, MarketplaceFinding, MarketplaceFindingKind, MarketplaceOwner, MarketplaceReadOutcome, MarketplaceWarningKind, } from "./marketplace/outcome.js";
|
|
26
|
+
export { hasMarketplaceFile, readMarketplace, readMarketplaceFile } from "./marketplace/read-marketplace.js";
|
|
27
|
+
export { readPluginPackage } from "./read-plugin-package.js";
|
|
28
|
+
export { isToolNameSegment, toolServerSegment } from "./tool-names.js";
|
|
29
|
+
export { DEFAULT_EVAL_DIR, EVAL_CURSOR_UNSUPPORTED_FEATURES, EVAL_MAX_APPEND_SYSTEM_PROMPT, EVAL_MAX_GRADERS, EVAL_UNSUPPORTED_FEATURES, type EvalCursorUnsupportedFeature, type EvalUnsupportedFeature, evalCaseUnsupportedOnCursor, readEvalFolder, readEvalSuite, } from "./evals/read-eval-suite.js";
|
|
30
|
+
export { MOCKS_DIR } from "./evals/mocks.js";
|
|
31
|
+
export { EVAL_ENV_KEY_PATTERN, EVAL_SCHEMA_VERSION } from "./evals/fields.js";
|
|
32
|
+
export { EVAL_SUMMARY_MAX_CASE_TAGS, EVAL_SUMMARY_MAX_CASES, EVAL_SUMMARY_MAX_FINDINGS, EVAL_SUMMARY_MAX_MESSAGE, EVAL_SUMMARY_MAX_PATH, EVAL_SUMMARY_MAX_SUITE_TAGS, EVAL_SUMMARY_MAX_TEXT, type EvalSuiteSummary, type EvalSuiteSummaryCase, summariseEvalSuite, } from "./evals/summary.js";
|
|
33
|
+
export { GLOB_MAX_ALTERNATIVES, GLOB_MAX_BRACE_DEPTH, GLOB_MAX_CLASS_ITEMS, GLOB_MAX_LENGTH, GLOB_MAX_TOKENS, globError } from "./evals/glob.js";
|
|
34
|
+
export type { EvalCase, EvalCaseContext, EvalFocus, EvalGrader, EvalGraderArm, EvalGraderCheck, EvalGraderType, EvalMockServer, EvalMockTool, EvalSuite, EvalSuiteFinding, EvalToolRef, } from "./evals/types.js";
|
|
35
|
+
export { type PluginPresentation, readPluginPresentation } from "./presentation.js";
|
|
36
|
+
export type { HookFormat, IgnoredComponent, IgnoredComponentKind, ModelAlias, ModelHint, PluginAuthor, PluginDialect, PluginHookGroup, PluginHookHandler, PluginHooks, PluginMcpServer, PluginPackage, PluginSkill, PluginSubAgent, PluginVariable, } from "./types.js";
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACtB,mBAAmB,EACnB,KAAK,mBAAmB,EACxB,KAAK,mBA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,KAAK,4BAA4B,EACjC,KAAK,sBAAsB,EAC3B,2BAA2B,EAC3B,cAAc,EACd,aAAa,GACd,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC9E,OAAO,EACL,0BAA0B,EAC1B,sBAAsB,EACtB,yBAAyB,EACzB,wBAAwB,EACxB,qBAAqB,EACrB,2BAA2B,EAC3B,qBAAqB,EACrB,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,EACzB,kBAAkB,GACnB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,eAAe,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjJ,YAAY,EACV,QAAQ,EACR,eAAe,EACf,SAAS,EACT,UAAU,EACV,aAAa,EACb,eAAe,EACf,cAAc,EACd,cAAc,EACd,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,kBAAkB,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AACpF,YAAY,EACV,UAAU,EACV,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,eAAe,EACf,aAAa,EACb,WAAW,EACX,cAAc,EACd,cAAc,GACf,MAAM,YAAY,CAAC"}
|
package/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@stigmer/plugin-package`: the public surface.
|
|
3
|
+
*
|
|
4
|
+
* `readPluginPackage` reads one plugin; `readMarketplace` reads a catalogue
|
|
5
|
+
* of them; `readPluginPresentation` reads what a card shows for one entry
|
|
6
|
+
* without opening the rest of it; `readEvalSuite` reads the plugin's own
|
|
7
|
+
* eval suite, which the install summarises and the eval workflow runs. Everything else here is what a consumer needs to supply its
|
|
8
|
+
* input (`PluginFiles`, the caps), route a directory (`MANIFEST_LOCATIONS`,
|
|
9
|
+
* `hasPluginManifest`, `MARKETPLACE_LOCATIONS`, `hasMarketplaceFile`), or
|
|
10
|
+
* render an outcome (the finding kinds and `isErrorKind`). The dialect
|
|
11
|
+
* readers and normalisers are internal: a consumer never composes a partial
|
|
12
|
+
* read.
|
|
13
|
+
*/
|
|
14
|
+
export { hasPluginManifest, isValidPluginName } from "./detect.js";
|
|
15
|
+
export { comparePaths, inMemoryPluginFiles, isContainedPath, PLUGIN_DOCUMENT_LIMITS, resolveDeclaredPath, } from "./files.js";
|
|
16
|
+
export { SKILL_NAME_PATTERN } from "./frontmatter.js";
|
|
17
|
+
export { AGENT_PLUGINS_MANIFEST_SCHEMA, AGENT_PLUGINS_MCP_SCHEMA, errorMessage, isErrorKind, MANIFEST_LOCATIONS, warningMessage, } from "./messages.js";
|
|
18
|
+
export { HOOK_CONDITION_PATTERN, RUN_EVENTS, hookVariableReferences, isValidMatcher } from "./normalise/hooks.js";
|
|
19
|
+
export { isAcceptableServerUrl } from "./normalise/mcp-servers.js";
|
|
20
|
+
export { SUB_AGENT_INSTRUCTIONS_MIN, classifyModel } from "./normalise/sub-agents.js";
|
|
21
|
+
export { PLACEHOLDER_PATTERN, PLATFORM_VARIABLES, RUNNER_FILLED_VARIABLES, VARIABLE_NAME_PATTERN, findPluginRootPlaceholder, } from "./placeholders.js";
|
|
22
|
+
export { HOOK_WARNING_KINDS } from "./outcome.js";
|
|
23
|
+
export { MARKETPLACE_LOCATIONS } from "./marketplace/messages.js";
|
|
24
|
+
export { hasMarketplaceFile, readMarketplace, readMarketplaceFile } from "./marketplace/read-marketplace.js";
|
|
25
|
+
export { readPluginPackage } from "./read-plugin-package.js";
|
|
26
|
+
export { isToolNameSegment, toolServerSegment } from "./tool-names.js";
|
|
27
|
+
export { DEFAULT_EVAL_DIR, EVAL_CURSOR_UNSUPPORTED_FEATURES, EVAL_MAX_APPEND_SYSTEM_PROMPT, EVAL_MAX_GRADERS, EVAL_UNSUPPORTED_FEATURES, evalCaseUnsupportedOnCursor, readEvalFolder, readEvalSuite, } from "./evals/read-eval-suite.js";
|
|
28
|
+
export { MOCKS_DIR } from "./evals/mocks.js";
|
|
29
|
+
export { EVAL_ENV_KEY_PATTERN, EVAL_SCHEMA_VERSION } from "./evals/fields.js";
|
|
30
|
+
export { EVAL_SUMMARY_MAX_CASE_TAGS, EVAL_SUMMARY_MAX_CASES, EVAL_SUMMARY_MAX_FINDINGS, EVAL_SUMMARY_MAX_MESSAGE, EVAL_SUMMARY_MAX_PATH, EVAL_SUMMARY_MAX_SUITE_TAGS, EVAL_SUMMARY_MAX_TEXT, summariseEvalSuite, } from "./evals/summary.js";
|
|
31
|
+
export { GLOB_MAX_ALTERNATIVES, GLOB_MAX_BRACE_DEPTH, GLOB_MAX_CLASS_ITEMS, GLOB_MAX_LENGTH, GLOB_MAX_TOKENS, globError } from "./evals/glob.js";
|
|
32
|
+
export { readPluginPresentation } from "./presentation.js";
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EACL,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,sBAAsB,EACtB,mBAAmB,GAKpB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACL,6BAA6B,EAC7B,wBAAwB,EACxB,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,cAAc,GACf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,sBAAsB,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|
|
1
|
+
/**
|
|
2
|
+
* The one sentence for every marketplace finding kind, and the collector
|
|
3
|
+
* bound to them.
|
|
4
|
+
*
|
|
5
|
+
* The same rule as the plugin vocabulary: copy lives here and nowhere else,
|
|
6
|
+
* the CLI prints these sentences verbatim, and the `Record` types are
|
|
7
|
+
* exhaustive so a kind without a sentence does not compile. The four
|
|
8
|
+
* locations are named in the not-found sentence because that is the one an
|
|
9
|
+
* author meets first when a file sits in the wrong place (Claude Code's own
|
|
10
|
+
* issue tracker shows how often).
|
|
11
|
+
*/
|
|
12
|
+
import { FindingCollector } from "../messages.js";
|
|
13
|
+
import type { MarketplaceDialect, MarketplaceErrorKind, MarketplaceWarningKind } from "./outcome.js";
|
|
14
|
+
/** The four marketplace file locations, in the precedence the reader applies. */
|
|
15
|
+
export declare const MARKETPLACE_LOCATIONS: Readonly<Record<MarketplaceDialect, string>>;
|
|
16
|
+
/** The marketplace reader's collector, bound to the marketplace vocabulary. */
|
|
17
|
+
export declare class MarketplaceFindings extends FindingCollector<MarketplaceErrorKind, MarketplaceWarningKind> {
|
|
18
|
+
constructor();
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/marketplace/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAM,gBAAgB,EAAoB,MAAM,gBAAgB,CAAC;AACxE,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAErG,iFAAiF;AACjF,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAK9E,CAAC;AAkCF,+EAA+E;AAC/E,qBAAa,mBAAoB,SAAQ,gBAAgB,CAAC,oBAAoB,EAAE,sBAAsB,CAAC;;CAItG"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one sentence for every marketplace finding kind, and the collector
|
|
3
|
+
* bound to them.
|
|
4
|
+
*
|
|
5
|
+
* The same rule as the plugin vocabulary: copy lives here and nowhere else,
|
|
6
|
+
* the CLI prints these sentences verbatim, and the `Record` types are
|
|
7
|
+
* exhaustive so a kind without a sentence does not compile. The four
|
|
8
|
+
* locations are named in the not-found sentence because that is the one an
|
|
9
|
+
* author meets first when a file sits in the wrong place (Claude Code's own
|
|
10
|
+
* issue tracker shows how often).
|
|
11
|
+
*/
|
|
12
|
+
import { at, FindingCollector, q } from "../messages.js";
|
|
13
|
+
/** The four marketplace file locations, in the precedence the reader applies. */
|
|
14
|
+
export const MARKETPLACE_LOCATIONS = {
|
|
15
|
+
stigmer: "marketplace.json",
|
|
16
|
+
claude: ".claude-plugin/marketplace.json",
|
|
17
|
+
cursor: ".cursor-plugin/marketplace.json",
|
|
18
|
+
codex: ".agents/plugins/marketplace.json",
|
|
19
|
+
};
|
|
20
|
+
const locationList = Object.values(MARKETPLACE_LOCATIONS)
|
|
21
|
+
.map((location) => q(location))
|
|
22
|
+
.join(", ");
|
|
23
|
+
const ERROR_MESSAGES = {
|
|
24
|
+
"marketplace-not-found": () => `no marketplace file found: expected one of ${locationList}`,
|
|
25
|
+
"marketplace-too-large": (c) => `${q(c.path)} is ${c.subject ?? ""} bytes, above the ${c.detail ?? ""} byte cap for a marketplace file`,
|
|
26
|
+
"marketplace-unreadable": (c) => `${q(c.path)} is not a readable marketplace file: ${c.detail ?? "parse error"}`,
|
|
27
|
+
"marketplace-field-type": (c) => `${q(c.path)} field ${q(c.subject)} must be ${c.detail ?? "of another type"}`,
|
|
28
|
+
"marketplace-name-missing": (c) => `${q(c.path)} has no 'name'; a marketplace needs one so its plugins can be addressed as '<marketplace>/<plugin>'`,
|
|
29
|
+
"marketplace-name-invalid": (c) => `${q(c.path)} name ${q(c.subject)} is invalid: 1 to 64 characters of a-z, 0-9, '-' and '.', starting and ending alphanumeric, no '--' or '..'`,
|
|
30
|
+
"marketplace-plugins-missing": (c) => `${q(c.path)} has no 'plugins' list`,
|
|
31
|
+
"entry-shape": (c) => `${q(c.path)} plugins[${c.subject ?? ""}] must be an object with 'name' and 'source'`,
|
|
32
|
+
"entry-name-missing": (c) => `${q(c.path)} plugins[${c.subject ?? ""}] has no 'name'`,
|
|
33
|
+
"entry-name-invalid": (c) => `${q(c.path)} plugin ${q(c.subject)} has an invalid name: 1 to 64 characters of a-z, 0-9, '-' and '.', starting and ending alphanumeric, no '--' or '..'`,
|
|
34
|
+
"entry-name-duplicate": (c) => `${q(c.path)} lists plugin ${q(c.subject)} more than once; 'install ${c.subject ?? ""}' would be ambiguous`,
|
|
35
|
+
"entry-source-missing": (c) => `${q(c.path)} plugin ${q(c.subject)} has no 'source'`,
|
|
36
|
+
"entry-source-escapes-root": (c) => `${q(c.path)} plugin ${q(c.subject)} has source ${q(c.detail)} outside the marketplace root; a source is a directory inside the marketplace`,
|
|
37
|
+
};
|
|
38
|
+
const WARNING_MESSAGES = {
|
|
39
|
+
"entry-source-unsupported": (c) => `plugin ${q(c.subject)}${at(c.path)} has source ${q(c.detail)}, a form Stigmer does not fetch (only a directory inside the marketplace); not offered`,
|
|
40
|
+
"entry-directory-missing": (c) => `plugin ${q(c.subject)}${at(c.path)} names directory ${q(c.detail)}, which the marketplace does not contain; not offered`,
|
|
41
|
+
"entry-not-a-plugin": (c) => `plugin ${q(c.subject)}${at(c.path)} names directory ${q(c.detail)}, which holds no plugin manifest; not offered`,
|
|
42
|
+
};
|
|
43
|
+
/** The marketplace reader's collector, bound to the marketplace vocabulary. */
|
|
44
|
+
export class MarketplaceFindings extends FindingCollector {
|
|
45
|
+
constructor() {
|
|
46
|
+
super(ERROR_MESSAGES, WARNING_MESSAGES);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRo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AAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,wFAAwF;IACvJ,yBAAyB,EAAE,CAAC,CAAC,EAAE,EAAE,CAC/B,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,uDAAuD;IAC3H,oBAAoB,EAAE,CAAC,CAAC,EAAE,EAAE,CAC1B,UAAU,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,+CAA+C;CACpH,CAAC;AAEF,+EAA+E;AAC/E,MAAM,OAAO,mBAAoB,SAAQ,gBAA8D;IACrG;QACE,KAAK,CAAC,cAAc,EAAE,gBAAgB,CAAC,CAAC;IAC1C,CAAC;CACF"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a marketplace is once read, and the closed vocabulary of findings a
|
|
3
|
+
* marketplace read can produce.
|
|
4
|
+
*
|
|
5
|
+
* A marketplace is a directory tree with a marketplace file that lists the
|
|
6
|
+
* plugins it offers, each as a name and a directory inside the tree. That is
|
|
7
|
+
* the convention Cursor (`.cursor-plugin/marketplace.json`), Claude Code
|
|
8
|
+
* (`.claude-plugin/marketplace.json`) and Codex (`.agents/plugins/
|
|
9
|
+
* marketplace.json`) already publish, and the agent-plugins.org
|
|
10
|
+
* specification leaves marketplaces client-owned, so there is no open
|
|
11
|
+
* format to defer to; Stigmer's own file sits at the tree root as
|
|
12
|
+
* `marketplace.json`, the position the open plugin manifest takes. The four
|
|
13
|
+
* dialects reduce to one shape here: a client that can read this shape can
|
|
14
|
+
* install from any of the four catalogues.
|
|
15
|
+
*
|
|
16
|
+
* Two error postures, stated as the plugin reader states them. A marketplace
|
|
17
|
+
* FILE that is broken (unreadable, unnamed, no plugin list, a source that
|
|
18
|
+
* escapes the tree, two entries with one name) refuses the marketplace: a
|
|
19
|
+
* catalogue that cannot be trusted as a whole is not offered at all. An
|
|
20
|
+
* ENTRY that cannot be installed (a source form this reader does not fetch,
|
|
21
|
+
* a directory the tree does not hold, a directory with no plugin manifest)
|
|
22
|
+
* is dropped with a warning: a user adding a public catalogue of eighty
|
|
23
|
+
* plugins should still see the seventy-nine that work, and a catalogue's
|
|
24
|
+
* own static suite asserts zero warnings so the publisher hears about the
|
|
25
|
+
* one. Every kind has exactly one sentence in `messages.ts` and exactly one
|
|
26
|
+
* adversarial fixture.
|
|
27
|
+
*/
|
|
28
|
+
import type { Finding } from "../outcome.js";
|
|
29
|
+
/** The marketplace file dialects, in the precedence the reader applies. */
|
|
30
|
+
export type MarketplaceDialect = "stigmer" | "claude" | "cursor" | "codex";
|
|
31
|
+
export type MarketplaceErrorKind = "marketplace-not-found" | "marketplace-too-large" | "marketplace-unreadable" | "marketplace-field-type" | "marketplace-name-missing" | "marketplace-name-invalid" | "marketplace-plugins-missing" | "entry-shape" | "entry-name-missing" | "entry-name-invalid" | "entry-name-duplicate" | "entry-source-missing" | "entry-source-escapes-root";
|
|
32
|
+
export type MarketplaceWarningKind = "entry-source-unsupported" | "entry-directory-missing" | "entry-not-a-plugin";
|
|
33
|
+
export type MarketplaceFindingKind = MarketplaceErrorKind | MarketplaceWarningKind;
|
|
34
|
+
export type MarketplaceFinding = Finding<MarketplaceFindingKind>;
|
|
35
|
+
export interface MarketplaceOwner {
|
|
36
|
+
readonly name?: string;
|
|
37
|
+
readonly email?: string;
|
|
38
|
+
readonly url?: string;
|
|
39
|
+
}
|
|
40
|
+
/** One installable plugin the marketplace offers. */
|
|
41
|
+
export interface MarketplaceEntry {
|
|
42
|
+
/** The name a user installs it by; unique within the marketplace. */
|
|
43
|
+
readonly name: string;
|
|
44
|
+
/** The plugin's directory, marketplace-relative with no leading `./`; the empty string is the tree root. */
|
|
45
|
+
readonly dir: string;
|
|
46
|
+
/** The catalogue's own one-line description, when the file carries one. */
|
|
47
|
+
readonly description?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface Marketplace {
|
|
50
|
+
/** The marketplace's identifier, the prefix in `install <marketplace>/<plugin>`. */
|
|
51
|
+
readonly name: string;
|
|
52
|
+
readonly description?: string;
|
|
53
|
+
readonly owner?: MarketplaceOwner;
|
|
54
|
+
/** The dialect whose file named the marketplace. */
|
|
55
|
+
readonly dialect: MarketplaceDialect;
|
|
56
|
+
/** The marketplace file that was read, tree-relative. */
|
|
57
|
+
readonly path: string;
|
|
58
|
+
/** Installable entries, in the file's order; entries the reader dropped are in the warnings. */
|
|
59
|
+
readonly plugins: readonly MarketplaceEntry[];
|
|
60
|
+
}
|
|
61
|
+
export type MarketplaceReadOutcome = {
|
|
62
|
+
readonly ok: true;
|
|
63
|
+
readonly marketplace: Marketplace;
|
|
64
|
+
readonly warnings: readonly MarketplaceFinding[];
|
|
65
|
+
} | {
|
|
66
|
+
readonly ok: false;
|
|
67
|
+
readonly errors: readonly MarketplaceFinding[];
|
|
68
|
+
readonly warnings: readonly MarketplaceFinding[];
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=outcome.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outcome.d.ts","sourceRoot":"","sources":["../src/marketplace/outcome.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,2EAA2E;AAC3E,MAAM,MAAM,kBAAkB,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE3E,MAAM,MAAM,oBAAoB,GAE5B,uBAAuB,GACvB,uBAAuB,GACvB,wBAAwB,GACxB,wBAAwB,GACxB,0BAA0B,GAC1B,0BAA0B,GAC1B,6BAA6B,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AAQ,EAAE,SAAS,kBAAkB,EAAE,CAAA;CAAE,GAC1G;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,kBAAkB,EAAE,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,kBAAkB,EAAE,CAAA;CAAE,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a marketplace is once read, and the closed vocabulary of findings a
|
|
3
|
+
* marketplace read can produce.
|
|
4
|
+
*
|
|
5
|
+
* A marketplace is a directory tree with a marketplace file that lists the
|
|
6
|
+
* plugins it offers, each as a name and a directory inside the tree. That is
|
|
7
|
+
* the convention Cursor (`.cursor-plugin/marketplace.json`), Claude Code
|
|
8
|
+
* (`.claude-plugin/marketplace.json`) and Codex (`.agents/plugins/
|
|
9
|
+
* marketplace.json`) already publish, and the agent-plugins.org
|
|
10
|
+
* specification leaves marketplaces client-owned, so there is no open
|
|
11
|
+
* format to defer to; Stigmer's own file sits at the tree root as
|
|
12
|
+
* `marketplace.json`, the position the open plugin manifest takes. The four
|
|
13
|
+
* dialects reduce to one shape here: a client that can read this shape can
|
|
14
|
+
* install from any of the four catalogues.
|
|
15
|
+
*
|
|
16
|
+
* Two error postures, stated as the plugin reader states them. A marketplace
|
|
17
|
+
* FILE that is broken (unreadable, unnamed, no plugin list, a source that
|
|
18
|
+
* escapes the tree, two entries with one name) refuses the marketplace: a
|
|
19
|
+
* catalogue that cannot be trusted as a whole is not offered at all. An
|
|
20
|
+
* ENTRY that cannot be installed (a source form this reader does not fetch,
|
|
21
|
+
* a directory the tree does not hold, a directory with no plugin manifest)
|
|
22
|
+
* is dropped with a warning: a user adding a public catalogue of eighty
|
|
23
|
+
* plugins should still see the seventy-nine that work, and a catalogue's
|
|
24
|
+
* own static suite asserts zero warnings so the publisher hears about the
|
|
25
|
+
* one. Every kind has exactly one sentence in `messages.ts` and exactly one
|
|
26
|
+
* adversarial fixture.
|
|
27
|
+
*/
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=outcome.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"outcome.js","sourceRoot":"","sources":["../src/marketplace/outcome.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG"}
|