@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/presentation.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a storefront shows for a plugin before anyone installs it: a display
|
|
3
|
+
* name, a logo, an author, a version, a description, a category.
|
|
4
|
+
*
|
|
5
|
+
* This is a read apart from `readPluginPackage` on purpose. The full read
|
|
6
|
+
* decides what Stigmer INSTALLS and refuses what it cannot; a card must
|
|
7
|
+
* render for every entry a catalogue lists, refused or not, and must cost
|
|
8
|
+
* one manifest, not the plugin's whole tree. So this reader opens only the
|
|
9
|
+
* manifests present, takes what they say about appearance, and never
|
|
10
|
+
* reports a finding: an unreadable manifest contributes nothing, a wrong
|
|
11
|
+
* type is treated as absent, and the caller draws a fallback face.
|
|
12
|
+
*
|
|
13
|
+
* Which manifest speaks is the full reader's rule (`MANIFEST_PRECEDENCE`:
|
|
14
|
+
* the root manifest, then Claude, Cursor, Codex), so a plugin shipping two
|
|
15
|
+
* dialects is named the same way on a card and in an install. Identity
|
|
16
|
+
* fields (`name`, `version`, `description`, `author`) come from the first
|
|
17
|
+
* manifest that carries each; the presentation fields come from the
|
|
18
|
+
* dialects that define them: Cursor's top-level `displayName`, `logo` and
|
|
19
|
+
* `category`; the legacy Codex manifest's `interface.displayName`,
|
|
20
|
+
* `interface.logo` and `interface.category`; the open format's
|
|
21
|
+
* `extensions["ai.stigmer"]` with the same three names, the one place that
|
|
22
|
+
* format leaves a client for them (Stigmer's authored catalogue plugins are
|
|
23
|
+
* its first users). Claude Code's manifest defines none.
|
|
24
|
+
*
|
|
25
|
+
* A logo is a path inside the plugin, and the card that shows it fetches it
|
|
26
|
+
* by URL from wherever the tree lives. So the path is kept only when it is
|
|
27
|
+
* contained, names an image by extension, is LISTED in the tree, and its
|
|
28
|
+
* declared size is under `PLUGIN_DOCUMENT_LIMITS.logo`; the library's rule
|
|
29
|
+
* that a cap is checked from declared sizes before a byte moves holds here
|
|
30
|
+
* too. Both spellings the vendors use (`assets/logo.png`, `./assets/logo.png`)
|
|
31
|
+
* are accepted, as the marketplace reader accepts both for a source.
|
|
32
|
+
*
|
|
33
|
+
* `logo` stays an ignored component in the full read: nothing in an
|
|
34
|
+
* Organization carries the image after an install, and the preview's "Not
|
|
35
|
+
* installed" line is true until the stored plugin does.
|
|
36
|
+
*/
|
|
37
|
+
import { MANIFEST_PRECEDENCE } from "./detect.js";
|
|
38
|
+
import { stigmerExtensionOf } from "./dialects/manifest.js";
|
|
39
|
+
import { decodeUtf8, isContainedPath, PLUGIN_DOCUMENT_LIMITS, PluginFileIndex } from "./files.js";
|
|
40
|
+
import { isJsonObject } from "./documents.js";
|
|
41
|
+
import { MANIFEST_LOCATIONS } from "./messages.js";
|
|
42
|
+
/** The image extensions a browser renders in an `<img>`; a logo named otherwise is not shown. */
|
|
43
|
+
const LOGO_EXTENSIONS = new Set(["png", "svg", "jpg", "jpeg", "webp", "gif"]);
|
|
44
|
+
/** The appearance fields of every manifest present, merged in precedence order. */
|
|
45
|
+
export function readPluginPresentation(files) {
|
|
46
|
+
const index = new PluginFileIndex(files);
|
|
47
|
+
const presentation = {};
|
|
48
|
+
for (const dialect of MANIFEST_PRECEDENCE) {
|
|
49
|
+
const object = readManifest(index, MANIFEST_LOCATIONS[dialect]);
|
|
50
|
+
if (object === undefined)
|
|
51
|
+
continue;
|
|
52
|
+
const contribution = contributionOf(dialect, object, index);
|
|
53
|
+
for (const key of Object.keys(contribution)) {
|
|
54
|
+
if (presentation[key] === undefined)
|
|
55
|
+
Object.assign(presentation, { [key]: contribution[key] });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return presentation;
|
|
59
|
+
}
|
|
60
|
+
/** The manifest at `path` as an object, or `undefined` for anything a card should not stumble on. */
|
|
61
|
+
function readManifest(index, path) {
|
|
62
|
+
const entry = index.entry(path);
|
|
63
|
+
if (entry === undefined || entry.size > PLUGIN_DOCUMENT_LIMITS.manifest)
|
|
64
|
+
return undefined;
|
|
65
|
+
let bytes;
|
|
66
|
+
try {
|
|
67
|
+
bytes = index.files.read(path);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
if (bytes.length > PLUGIN_DOCUMENT_LIMITS.manifest)
|
|
73
|
+
return undefined;
|
|
74
|
+
let value;
|
|
75
|
+
try {
|
|
76
|
+
value = JSON.parse(decodeUtf8(bytes));
|
|
77
|
+
}
|
|
78
|
+
catch {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
return isJsonObject(value) ? value : undefined;
|
|
82
|
+
}
|
|
83
|
+
function contributionOf(dialect, object, index) {
|
|
84
|
+
const identity = identityOf(object);
|
|
85
|
+
switch (dialect) {
|
|
86
|
+
case "cursor":
|
|
87
|
+
return { ...identity, ...appearanceOf(object, index) };
|
|
88
|
+
case "codex": {
|
|
89
|
+
const surface = object["interface"];
|
|
90
|
+
return isJsonObject(surface) ? { ...identity, ...appearanceOf(surface, index) } : identity;
|
|
91
|
+
}
|
|
92
|
+
case "agent-plugins": {
|
|
93
|
+
const extension = stigmerExtensionOf(object);
|
|
94
|
+
return extension === undefined ? identity : { ...identity, ...appearanceOf(extension, index) };
|
|
95
|
+
}
|
|
96
|
+
case "claude":
|
|
97
|
+
return identity;
|
|
98
|
+
default: {
|
|
99
|
+
const exhaustive = dialect;
|
|
100
|
+
return exhaustive;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/** The identity fields every dialect shares, typed loosely: a wrong type is absent, never a finding. */
|
|
105
|
+
function identityOf(object) {
|
|
106
|
+
const author = authorOf(object["author"]);
|
|
107
|
+
return {
|
|
108
|
+
...optional("version", object["version"]),
|
|
109
|
+
...optional("description", object["description"]),
|
|
110
|
+
...(author !== undefined && { author }),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/** `displayName`, `logo` and `category` from an object that carries them at its top level (a Cursor manifest, a Codex `interface`, an open manifest's `extensions["ai.stigmer"]`). */
|
|
114
|
+
function appearanceOf(object, index) {
|
|
115
|
+
const logo = logoPath(object["logo"], index);
|
|
116
|
+
return {
|
|
117
|
+
...optional("displayName", object["displayName"]),
|
|
118
|
+
...optional("category", object["category"]),
|
|
119
|
+
...(logo !== undefined && { logo }),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function authorOf(value) {
|
|
123
|
+
if (!isJsonObject(value))
|
|
124
|
+
return undefined;
|
|
125
|
+
const author = {
|
|
126
|
+
...optional("name", value["name"]),
|
|
127
|
+
...optional("email", value["email"]),
|
|
128
|
+
...optional("url", value["url"]),
|
|
129
|
+
};
|
|
130
|
+
return Object.keys(author).length === 0 ? undefined : author;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* A declared logo as a plugin-relative path the tree lists, or nothing.
|
|
134
|
+
* `./` is stripped (Codex's spelling); an absolute path, a `..` segment, a
|
|
135
|
+
* URL, a non-image extension, an unlisted file or an over-cap file all
|
|
136
|
+
* mean "no logo", never a refusal.
|
|
137
|
+
*/
|
|
138
|
+
function logoPath(value, index) {
|
|
139
|
+
if (typeof value !== "string")
|
|
140
|
+
return undefined;
|
|
141
|
+
const path = value.startsWith("./") ? value.slice(2) : value;
|
|
142
|
+
if (!isContainedPath(path))
|
|
143
|
+
return undefined;
|
|
144
|
+
const dot = path.lastIndexOf(".");
|
|
145
|
+
if (dot === -1 || !LOGO_EXTENSIONS.has(path.slice(dot + 1).toLowerCase()))
|
|
146
|
+
return undefined;
|
|
147
|
+
const entry = index.entry(path);
|
|
148
|
+
if (entry === undefined || entry.size > PLUGIN_DOCUMENT_LIMITS.logo)
|
|
149
|
+
return undefined;
|
|
150
|
+
return path;
|
|
151
|
+
}
|
|
152
|
+
/** `{ [key]: value }` when `value` is a non-empty string; `{}` otherwise. */
|
|
153
|
+
function optional(key, value) {
|
|
154
|
+
return typeof value === "string" && value !== "" ? { [key]: value } : {};
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=presentation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation.js","sourceRoot":"","sources":["src/presentation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,sBAAsB,EAAE,eAAe,EAAoB,MAAM,YAAY,CAAC;AACpH,OAAO,EAAE,YAAY,EAAmB,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAgBnD,iGAAiG;AACjG,MAAM,eAAe,GAAwB,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;AAEnG,mFAAmF;AACnF,MAAM,UAAU,sBAAsB,CAAC,KAAkB;IACvD,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC,KAAK,CAAC,CAAC;IACzC,MAAM,YAAY,GAAyE,EAAE,CAAC;IAE9F,KAAK,MAAM,OAAO,IAAI,mBAAmB,EAAE,CAAC;QAC1C,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;QAChE,IAAI,MAAM,KAAK,SAAS;YAAE,SAAS;QACnC,MAAM,YAAY,GAAG,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;QAC5D,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC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AAC,WAAW,EAAE,CAAC;QAAE,OAAO,SAAS,CAAC;IAC5F,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,GAAG,sBAAsB,CAAC,IAAI;QAAE,OAAO,SAAS,CAAC;IACtF,OAAO,IAAI,CAAC;AACd,CAAC;AAED,6EAA6E;AAC7E,SAAS,QAAQ,CAAmB,GAAM,EAAE,KAAc;IACxD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE,CAAC,CAAC,CAAE,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAwB,CAAC,CAAC,CAAC,EAAE,CAAC;AAClG,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one entry: a `PluginFiles` in, a `PluginReadOutcome` out.
|
|
3
|
+
*
|
|
4
|
+
* The read is a fixed sequence, each stage a pure function over the index
|
|
5
|
+
* and the stages before it: containment of the listed paths; manifest
|
|
6
|
+
* detection and identity; skills; MCP servers; hooks; variables (which
|
|
7
|
+
* need the servers' and the hooks' references); sub-agents (which need the
|
|
8
|
+
* skills' names); the main agent a Claude plugin's settings name (which
|
|
9
|
+
* needs the sub-agents); the `ai.stigmer/` folder, which is read by
|
|
10
|
+
* nothing and warned; the ignored components. Every stage records findings and keeps going, so the outcome
|
|
11
|
+
* names every problem in the package at once, and the plugin is returned
|
|
12
|
+
* only when no stage refused.
|
|
13
|
+
*
|
|
14
|
+
* Nothing here throws on a plugin's content. A throw means a reader broke
|
|
15
|
+
* its contract (a listed path that cannot be read) or the library has a bug.
|
|
16
|
+
*/
|
|
17
|
+
import { type PluginFiles } from "./files.js";
|
|
18
|
+
import type { PluginReadOutcome } from "./outcome.js";
|
|
19
|
+
export declare function readPluginPackage(files: PluginFiles): PluginReadOutcome;
|
|
20
|
+
//# sourceMappingURL=read-plugin-package.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-plugin-package.d.ts","sourceRoot":"","sources":["src/read-plugin-package.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EAAoC,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAUhF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGtD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,WAAW,GAAG,iBAAiB,CAgDvE"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one entry: a `PluginFiles` in, a `PluginReadOutcome` out.
|
|
3
|
+
*
|
|
4
|
+
* The read is a fixed sequence, each stage a pure function over the index
|
|
5
|
+
* and the stages before it: containment of the listed paths; manifest
|
|
6
|
+
* detection and identity; skills; MCP servers; hooks; variables (which
|
|
7
|
+
* need the servers' and the hooks' references); sub-agents (which need the
|
|
8
|
+
* skills' names); the main agent a Claude plugin's settings name (which
|
|
9
|
+
* needs the sub-agents); the `ai.stigmer/` folder, which is read by
|
|
10
|
+
* nothing and warned; the ignored components. Every stage records findings and keeps going, so the outcome
|
|
11
|
+
* names every problem in the package at once, and the plugin is returned
|
|
12
|
+
* only when no stage refused.
|
|
13
|
+
*
|
|
14
|
+
* Nothing here throws on a plugin's content. A throw means a reader broke
|
|
15
|
+
* its contract (a listed path that cannot be read) or the library has a bug.
|
|
16
|
+
*/
|
|
17
|
+
import { detectManifests } from "./detect.js";
|
|
18
|
+
import { isContainedPath, PluginFileIndex } from "./files.js";
|
|
19
|
+
import { Findings } from "./messages.js";
|
|
20
|
+
import { normaliseHooks } from "./normalise/hooks.js";
|
|
21
|
+
import { dedupeIgnored, ignoredOnDisk } from "./normalise/ignored.js";
|
|
22
|
+
import { normaliseMcpServers } from "./normalise/mcp-servers.js";
|
|
23
|
+
import { normaliseMainAgent, readsSettings } from "./normalise/settings.js";
|
|
24
|
+
import { normaliseSkills } from "./normalise/skills.js";
|
|
25
|
+
import { warnStigmerFolder } from "./normalise/stigmer-folder.js";
|
|
26
|
+
import { normaliseSubAgents } from "./normalise/sub-agents.js";
|
|
27
|
+
import { normaliseVariables } from "./normalise/variables.js";
|
|
28
|
+
export function readPluginPackage(files) {
|
|
29
|
+
const findings = new Findings();
|
|
30
|
+
for (const entry of files.entries) {
|
|
31
|
+
if (!isContainedPath(entry.path))
|
|
32
|
+
findings.error("path-uncontained", { path: entry.path });
|
|
33
|
+
}
|
|
34
|
+
const index = new PluginFileIndex(files);
|
|
35
|
+
const set = detectManifests(index, findings);
|
|
36
|
+
if (set === undefined) {
|
|
37
|
+
return { ok: false, errors: findings.errors, warnings: findings.warnings };
|
|
38
|
+
}
|
|
39
|
+
const skills = normaliseSkills(index, set, findings);
|
|
40
|
+
const servers = normaliseMcpServers(index, set.mcpSources, findings);
|
|
41
|
+
const mcpServers = servers.servers;
|
|
42
|
+
const hooks = normaliseHooks(index, set, findings);
|
|
43
|
+
const variables = normaliseVariables(set, servers, hooks.references, findings);
|
|
44
|
+
const subAgents = normaliseSubAgents(index, set, skills, findings);
|
|
45
|
+
const mainAgent = normaliseMainAgent(index, set, subAgents, findings);
|
|
46
|
+
warnStigmerFolder(index, findings);
|
|
47
|
+
const ignored = dedupeIgnored([ignoredOnDisk(index, set.readsAgents, readsSettings(set)), ...set.manifests.map((m) => m.ignored)]);
|
|
48
|
+
if (findings.errors.length > 0 || set.name === undefined) {
|
|
49
|
+
return { ok: false, errors: findings.errors, warnings: findings.warnings };
|
|
50
|
+
}
|
|
51
|
+
const identity = set.manifests[0]?.identity ?? {};
|
|
52
|
+
const plugin = {
|
|
53
|
+
name: set.name,
|
|
54
|
+
...(identity.version !== undefined && { version: identity.version }),
|
|
55
|
+
...(identity.description !== undefined && { description: identity.description }),
|
|
56
|
+
...(identity.author !== undefined && { author: identity.author }),
|
|
57
|
+
...(identity.homepage !== undefined && { homepage: identity.homepage }),
|
|
58
|
+
...(identity.repository !== undefined && { repository: identity.repository }),
|
|
59
|
+
...(identity.license !== undefined && { license: identity.license }),
|
|
60
|
+
keywords: identity.keywords ?? [],
|
|
61
|
+
dialect: set.dialect,
|
|
62
|
+
manifestsFound: set.manifests.map((m) => m.path),
|
|
63
|
+
skills,
|
|
64
|
+
mcpServers,
|
|
65
|
+
subAgents,
|
|
66
|
+
variables,
|
|
67
|
+
...(hooks.hooks !== undefined && { hooks: hooks.hooks }),
|
|
68
|
+
...(mainAgent !== undefined && { mainAgent }),
|
|
69
|
+
ignored,
|
|
70
|
+
};
|
|
71
|
+
return { ok: true, plugin, warnings: findings.warnings };
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=read-plugin-package.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read-plugin-package.js","sourceRoot":"","sources":["src/read-plugin-package.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,eAAe,EAAoB,MAAM,YAAY,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAI9D,MAAM,UAAU,iBAAiB,CAAC,KAAkB;IAClD,MAAM,QAAQ,GA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OAAO,EAAE,CAAC;QACpE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,IAAI,EAAE;QACjC,OAAO,EAAE,GAAG,CAAC,OAAO;QACpB,cAAc,EAAE,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;QAChD,MAAM;QACN,UAAU;QACV,SAAS;QACT,SAAS;QACT,GAAG,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC;QACxD,GAAG,CAAC,SAAS,KAAK,SAAS,IAAI,EAAE,SAAS,EAAE,CAAC;QAC7C,OAAO;KACR,CAAC;IACF,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,EAAE,CAAC;AAC3D,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The archive a plugin push sends, and its digest.
|
|
3
|
+
*
|
|
4
|
+
* The server's identity for a plugin version is the SHA-256 of the bytes it
|
|
5
|
+
* receives, so a client that can compute those bytes knows "already
|
|
6
|
+
* installed" and "upgrade available" without pushing. That is only true if
|
|
7
|
+
* every client builds the archive the same way: the selected files in
|
|
8
|
+
* selection order, one DOS-epoch mtime on every entry, one compression
|
|
9
|
+
* level. These are the CLI's original options (the skill packager's
|
|
10
|
+
* discipline, kept byte for byte); changing any of them would make every
|
|
11
|
+
* installed plugin look like an upgrade.
|
|
12
|
+
*
|
|
13
|
+
* The digest is WebCrypto's, which Node 22 and every browser provide, so
|
|
14
|
+
* there is one hash implementation and it is asynchronous everywhere.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { zipSync } from "fflate";
|
|
18
|
+
|
|
19
|
+
import type { PluginFiles } from "../files.js";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The one mtime every entry carries: the DOS epoch, at local midnight so
|
|
23
|
+
* the DOS time field reads 00:00 in every zone. Construct it locally rather
|
|
24
|
+
* than from UTC: fflate converts through the Date's local getters.
|
|
25
|
+
*/
|
|
26
|
+
export const DETERMINISTIC_ZIP_MTIME = new Date(1980, 0, 1);
|
|
27
|
+
|
|
28
|
+
/** The deflate level the skill packager chose; part of the identity. */
|
|
29
|
+
const ARCHIVE_LEVEL = 6;
|
|
30
|
+
|
|
31
|
+
/** Zip the selected files in their listed order. */
|
|
32
|
+
export function archivePlugin(files: PluginFiles): Uint8Array {
|
|
33
|
+
const tree: Record<string, Uint8Array> = {};
|
|
34
|
+
for (const entry of files.entries) {
|
|
35
|
+
tree[entry.path] = files.read(entry.path);
|
|
36
|
+
}
|
|
37
|
+
return zipSync(tree, { level: ARCHIVE_LEVEL, mtime: DETERMINISTIC_ZIP_MTIME });
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Lowercase hex SHA-256 of `bytes`: the server's `status.digest` for these bytes. */
|
|
41
|
+
export async function digestArchive(bytes: Uint8Array): Promise<string> {
|
|
42
|
+
const hash = await globalThis.crypto.subtle.digest("SHA-256", bytes);
|
|
43
|
+
return Array.from(new Uint8Array(hash), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
44
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one source every client lists without being told: Stigmer's official
|
|
3
|
+
* catalogue.
|
|
4
|
+
*
|
|
5
|
+
* The catalogue is curated (`plugins/README.md`, "What the catalogue holds"):
|
|
6
|
+
* every entry is one Stigmer may ship and one whose servers Stigmer can
|
|
7
|
+
* connect to, vendored from a publisher's redistributable set or authored
|
|
8
|
+
* by Stigmer for a vendor's public endpoint. The vendors' own repositories
|
|
9
|
+
* were built in for one release and were taken out again when the audit
|
|
10
|
+
* behind the catalogue measured that more than half of their entries fail
|
|
11
|
+
* that bar: a chip that offers what the catalogue left out re-surfaces
|
|
12
|
+
* what curation removed. A user who wants another catalogue adds it as a
|
|
13
|
+
* source of his own (a repository with a marketplace file, read from
|
|
14
|
+
* GitHub), in the console's Manage sources or with `stigmer marketplace
|
|
15
|
+
* add`; the vendors' repositories are ordinary candidates for that, at the
|
|
16
|
+
* user's word, never on offer by default.
|
|
17
|
+
*
|
|
18
|
+
* The list is code, not stored state: a client's remembered sources hold
|
|
19
|
+
* only what the user added, so the two clients cannot drift from each
|
|
20
|
+
* other. The official name is reserved the way it always was; a user can
|
|
21
|
+
* neither add over it nor remove it.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
import type { GitHubMarketplaceSource } from "./refs.js";
|
|
25
|
+
import { OFFICIAL_MARKETPLACE_NAME } from "./refs.js";
|
|
26
|
+
|
|
27
|
+
/** A source a client ships with: named, and either the official catalogue or a public GitHub tree. */
|
|
28
|
+
export interface BuiltInMarketplace {
|
|
29
|
+
readonly name: string;
|
|
30
|
+
readonly source: { readonly type: "official" } | GitHubMarketplaceSource;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** In listing order. Today one entry; the type keeps the shape a future built-in would take. */
|
|
34
|
+
export const BUILT_IN_MARKETPLACES: readonly BuiltInMarketplace[] = [
|
|
35
|
+
{
|
|
36
|
+
name: OFFICIAL_MARKETPLACE_NAME,
|
|
37
|
+
source: { type: "official" },
|
|
38
|
+
},
|
|
39
|
+
];
|
|
40
|
+
|
|
41
|
+
const BUILT_IN_NAMES: ReadonlySet<string> = new Set(BUILT_IN_MARKETPLACES.map((entry) => entry.name));
|
|
42
|
+
|
|
43
|
+
/** Whether `name` is one a user may neither add nor remove. */
|
|
44
|
+
export function isBuiltInMarketplaceName(name: string): boolean {
|
|
45
|
+
return BUILT_IN_NAMES.has(name);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The one sentence every client refuses with when a user tries to add over or remove a built-in source. */
|
|
49
|
+
export function builtInSourceRefusal(name: string, act: "add" | "remove"): string {
|
|
50
|
+
switch (act) {
|
|
51
|
+
case "add":
|
|
52
|
+
return `'${name}' is a built-in source and cannot be added or replaced; choose another name`;
|
|
53
|
+
case "remove":
|
|
54
|
+
return `'${name}' is a built-in source and cannot be removed`;
|
|
55
|
+
default: {
|
|
56
|
+
const exhaustive: never = act;
|
|
57
|
+
return exhaustive;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
// Built-in security-first ignore patterns, applied (lowest priority) unless
|
|
2
|
+
// disabled. A verbatim port of the Go CLI's DefaultPatterns so `push` excludes
|
|
3
|
+
// the same secrets, VCS metadata, and build artifacts on both CLIs.
|
|
4
|
+
|
|
5
|
+
export const DEFAULT_PATTERNS: readonly string[] = [
|
|
6
|
+
// Version control
|
|
7
|
+
".git/",
|
|
8
|
+
".svn/",
|
|
9
|
+
".hg/",
|
|
10
|
+
".bzr/",
|
|
11
|
+
|
|
12
|
+
// Environment files (often contain secrets)
|
|
13
|
+
".env",
|
|
14
|
+
".env.*",
|
|
15
|
+
"!.env.example",
|
|
16
|
+
"!.env.template",
|
|
17
|
+
"!.env.sample",
|
|
18
|
+
|
|
19
|
+
// Private keys and certificates
|
|
20
|
+
"*.pem",
|
|
21
|
+
"*.key",
|
|
22
|
+
"*.p12",
|
|
23
|
+
"*.pfx",
|
|
24
|
+
"*.keystore",
|
|
25
|
+
"*.jks",
|
|
26
|
+
"id_rsa",
|
|
27
|
+
"id_rsa.*",
|
|
28
|
+
"id_ed25519",
|
|
29
|
+
"id_ed25519.*",
|
|
30
|
+
"id_dsa",
|
|
31
|
+
"id_dsa.*",
|
|
32
|
+
|
|
33
|
+
// Cloud credentials
|
|
34
|
+
"credentials.json",
|
|
35
|
+
"service-account*.json",
|
|
36
|
+
"gcp-credentials*.json",
|
|
37
|
+
"aws-credentials",
|
|
38
|
+
".aws/credentials",
|
|
39
|
+
".aws/config",
|
|
40
|
+
|
|
41
|
+
// Generic secrets
|
|
42
|
+
".secrets",
|
|
43
|
+
".secrets/",
|
|
44
|
+
"*.secret",
|
|
45
|
+
".credentials/",
|
|
46
|
+
"secrets.yaml",
|
|
47
|
+
"secrets.yml",
|
|
48
|
+
"secrets.json",
|
|
49
|
+
|
|
50
|
+
// Package manager auth
|
|
51
|
+
".npmrc",
|
|
52
|
+
".pypirc",
|
|
53
|
+
".gem/credentials",
|
|
54
|
+
".docker/config.json",
|
|
55
|
+
|
|
56
|
+
// IDE and editor
|
|
57
|
+
".idea/",
|
|
58
|
+
".vscode/",
|
|
59
|
+
"*.swp",
|
|
60
|
+
"*.swo",
|
|
61
|
+
"*.swn",
|
|
62
|
+
"*~",
|
|
63
|
+
".project",
|
|
64
|
+
".classpath",
|
|
65
|
+
".settings/",
|
|
66
|
+
"*.sublime-workspace",
|
|
67
|
+
"*.sublime-project",
|
|
68
|
+
".vs/",
|
|
69
|
+
|
|
70
|
+
// Operating system
|
|
71
|
+
".DS_Store",
|
|
72
|
+
".DS_Store?",
|
|
73
|
+
"._*",
|
|
74
|
+
".Spotlight-V100",
|
|
75
|
+
".Trashes",
|
|
76
|
+
"Thumbs.db",
|
|
77
|
+
"Thumbs.db:encryptable",
|
|
78
|
+
"desktop.ini",
|
|
79
|
+
"ehthumbs.db",
|
|
80
|
+
"ehthumbs_vista.db",
|
|
81
|
+
|
|
82
|
+
// Node.js
|
|
83
|
+
"node_modules/",
|
|
84
|
+
"npm-debug.log*",
|
|
85
|
+
"yarn-debug.log*",
|
|
86
|
+
"yarn-error.log*",
|
|
87
|
+
".npm/",
|
|
88
|
+
".yarn/cache/",
|
|
89
|
+
".yarn/unplugged/",
|
|
90
|
+
".pnp.*",
|
|
91
|
+
|
|
92
|
+
// Python
|
|
93
|
+
"__pycache__/",
|
|
94
|
+
"*.py[cod]",
|
|
95
|
+
"*$py.class",
|
|
96
|
+
".Python",
|
|
97
|
+
"*.so",
|
|
98
|
+
".venv/",
|
|
99
|
+
"venv/",
|
|
100
|
+
"env/",
|
|
101
|
+
"ENV/",
|
|
102
|
+
".pytest_cache/",
|
|
103
|
+
".mypy_cache/",
|
|
104
|
+
".ruff_cache/",
|
|
105
|
+
".tox/",
|
|
106
|
+
".nox/",
|
|
107
|
+
"*.egg-info/",
|
|
108
|
+
".eggs/",
|
|
109
|
+
"dist/",
|
|
110
|
+
"build/",
|
|
111
|
+
"develop-eggs/",
|
|
112
|
+
".installed.cfg",
|
|
113
|
+
"*.manifest",
|
|
114
|
+
"*.spec",
|
|
115
|
+
"pip-log.txt",
|
|
116
|
+
"pip-delete-this-directory.txt",
|
|
117
|
+
|
|
118
|
+
// Java/JVM
|
|
119
|
+
"target/",
|
|
120
|
+
"*.class",
|
|
121
|
+
"*.jar",
|
|
122
|
+
"*.war",
|
|
123
|
+
"*.ear",
|
|
124
|
+
".gradle/",
|
|
125
|
+
"gradle-app.setting",
|
|
126
|
+
".gradletasknamecache",
|
|
127
|
+
|
|
128
|
+
// Go
|
|
129
|
+
"vendor/",
|
|
130
|
+
|
|
131
|
+
// Rust
|
|
132
|
+
"target/",
|
|
133
|
+
"Cargo.lock",
|
|
134
|
+
|
|
135
|
+
// Coverage and test reports
|
|
136
|
+
"coverage/",
|
|
137
|
+
".coverage",
|
|
138
|
+
"htmlcov/",
|
|
139
|
+
".nyc_output/",
|
|
140
|
+
"coverage.xml",
|
|
141
|
+
"*.cover",
|
|
142
|
+
".hypothesis/",
|
|
143
|
+
|
|
144
|
+
// Logs
|
|
145
|
+
"*.log",
|
|
146
|
+
"logs/",
|
|
147
|
+
|
|
148
|
+
// Temporary files
|
|
149
|
+
"tmp/",
|
|
150
|
+
"temp/",
|
|
151
|
+
"*.tmp",
|
|
152
|
+
"*.temp",
|
|
153
|
+
"*.bak",
|
|
154
|
+
"*.backup",
|
|
155
|
+
];
|