@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/src/detect.ts
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which manifests a package carries, which one gives it its identity, and
|
|
3
|
+
* what they agree on.
|
|
4
|
+
*
|
|
5
|
+
* A root `plugin.json` (the open format) is the identity when present, and
|
|
6
|
+
* any vendor manifests beside it contribute only their dialect data
|
|
7
|
+
* (declared paths, variables, inline servers). Without a root manifest the
|
|
8
|
+
* precedence is Claude, Cursor, Codex: the first present names the plugin.
|
|
9
|
+
* Every present manifest is read, so a plugin that ships two dialects has
|
|
10
|
+
* both honoured; a `name` present in two manifests with different values is
|
|
11
|
+
* refused, because a plugin that is two plugins depending on who reads it
|
|
12
|
+
* is exactly the drift Stigmer will not carry.
|
|
13
|
+
*
|
|
14
|
+
* The plugin name obeys the open format's rule in every dialect (1 to 64
|
|
15
|
+
* characters of `a-z 0-9 - .`, alphanumeric at both ends, no `--` or `..`);
|
|
16
|
+
* Cursor's published pattern is the same rule minus the repetition clause.
|
|
17
|
+
* Slugging is the installer's, not the reader's.
|
|
18
|
+
*
|
|
19
|
+
* MCP configuration sources are resolved here too, because a default
|
|
20
|
+
* location is a cross-manifest fact: `mcp.json` is read under the open
|
|
21
|
+
* rules when a root manifest exists; a Claude or Codex manifest that
|
|
22
|
+
* declares no `mcpServers` reads `.mcp.json` when present; Cursor reads
|
|
23
|
+
* only what it declares. Hooks sources resolve the same way: every vendor
|
|
24
|
+
* manifest's declared sources, then `hooks/hooks.json` when it exists (the
|
|
25
|
+
* default Claude Code, Cursor and Codex all read, merged with what is
|
|
26
|
+
* declared), each file read once and tagged with the hook formats of the
|
|
27
|
+
* manifests that reach it. Sub-agent files (`agents/*.md`) are a vendor
|
|
28
|
+
* component: they are read when any vendor manifest is present and recorded
|
|
29
|
+
* as ignored otherwise, since the open format defines no such component.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
import { readClaudeManifest, CLAUDE_DEFAULT_MCP_CONFIG } from "./dialects/claude.js";
|
|
33
|
+
import { readCodexManifest } from "./dialects/codex.js";
|
|
34
|
+
import { readCursorManifest } from "./dialects/cursor.js";
|
|
35
|
+
import type { DialectManifest, McpConfigSource } from "./dialects/manifest.js";
|
|
36
|
+
import { readOpenManifest } from "./dialects/open.js";
|
|
37
|
+
import { type JsonObject, parseJsonObject, readText } from "./documents.js";
|
|
38
|
+
import type { PluginFileIndex } from "./files.js";
|
|
39
|
+
import { type Findings, MANIFEST_LOCATIONS } from "./messages.js";
|
|
40
|
+
import type { HookFormat, PluginDialect } from "./types.js";
|
|
41
|
+
|
|
42
|
+
/** The open format's `mcp.json`, a fixed location. */
|
|
43
|
+
export const OPEN_MCP_CONFIG = "mcp.json";
|
|
44
|
+
|
|
45
|
+
/** The hooks file every vendor reads by default. */
|
|
46
|
+
export const DEFAULT_HOOKS_FILE = "hooks/hooks.json";
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* A hooks source after resolution. A file carries every format a manifest
|
|
50
|
+
* reaching it reads, so a file whose shape is none of them is refused; an
|
|
51
|
+
* inline object has the one format of the manifest that holds it.
|
|
52
|
+
*/
|
|
53
|
+
export type ResolvedHookSource =
|
|
54
|
+
| { readonly kind: "file"; readonly path: string; readonly formats: readonly HookFormat[]; readonly manifest: string }
|
|
55
|
+
| { readonly kind: "inline"; readonly manifest: string; readonly value: JsonObject; readonly format: HookFormat };
|
|
56
|
+
|
|
57
|
+
/** The hook format a vendor dialect reads; Codex reads Claude Code's. */
|
|
58
|
+
export function hookFormatOf(dialect: PluginDialect): HookFormat {
|
|
59
|
+
return dialect === "cursor" ? "cursor" : "claude-code";
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** The vendor precedence when no root manifest exists. */
|
|
63
|
+
const VENDOR_PRECEDENCE: readonly Exclude<PluginDialect, "agent-plugins">[] = ["claude", "cursor", "codex"];
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Every manifest location in the order that names a plugin: the root
|
|
67
|
+
* manifest, then the vendors. The one precedence the reader applies,
|
|
68
|
+
* exported so a partial read (`presentation.ts`) cannot rank the manifests
|
|
69
|
+
* differently from the full one.
|
|
70
|
+
*/
|
|
71
|
+
export const MANIFEST_PRECEDENCE: readonly PluginDialect[] = ["agent-plugins", ...VENDOR_PRECEDENCE];
|
|
72
|
+
|
|
73
|
+
const NAME_MAX_LENGTH = 64;
|
|
74
|
+
const NAME_PATTERN = /^[a-z0-9]([a-z0-9.-]*[a-z0-9])?$/;
|
|
75
|
+
|
|
76
|
+
export interface ManifestSet {
|
|
77
|
+
/** The dialect that gave the plugin its identity. */
|
|
78
|
+
readonly dialect: PluginDialect;
|
|
79
|
+
/** Identity first, then the others in location order. */
|
|
80
|
+
readonly manifests: readonly DialectManifest[];
|
|
81
|
+
/** The validated plugin name; `undefined` after a name finding. */
|
|
82
|
+
readonly name: string | undefined;
|
|
83
|
+
/** True when a vendor manifest is present, so `agents/*.md` is a component. */
|
|
84
|
+
readonly readsAgents: boolean;
|
|
85
|
+
readonly mcpSources: readonly McpConfigSource[];
|
|
86
|
+
readonly hookSources: readonly ResolvedHookSource[];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** True when the directory holds any of the four manifests; the CLI's routing test. */
|
|
90
|
+
export function hasPluginManifest(paths: Iterable<string>): boolean {
|
|
91
|
+
const locations = new Set<string>(Object.values(MANIFEST_LOCATIONS));
|
|
92
|
+
for (const path of paths) if (locations.has(path)) return true;
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Read every present manifest; `undefined` (after `no-manifest`) when there is none. */
|
|
97
|
+
export function detectManifests(index: PluginFileIndex, findings: Findings): ManifestSet | undefined {
|
|
98
|
+
const manifests: DialectManifest[] = [];
|
|
99
|
+
const present = (dialect: PluginDialect): DialectManifest | undefined => {
|
|
100
|
+
const path = MANIFEST_LOCATIONS[dialect];
|
|
101
|
+
if (!index.has(path)) return undefined;
|
|
102
|
+
const object = readManifestObject(index, path, findings);
|
|
103
|
+
// An unreadable manifest still counts as present: the finding already
|
|
104
|
+
// says why, and an empty contribution keeps the read going.
|
|
105
|
+
const manifest = object === undefined ? emptyManifest(dialect, path) : readDialect(dialect, object, path, findings);
|
|
106
|
+
manifests.push(manifest);
|
|
107
|
+
return manifest;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const root = present("agent-plugins");
|
|
111
|
+
const vendors = VENDOR_PRECEDENCE.map(present).filter((m): m is DialectManifest => m !== undefined);
|
|
112
|
+
if (manifests.length === 0) {
|
|
113
|
+
findings.error("no-manifest");
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const identity = root ?? vendors[0];
|
|
118
|
+
if (identity === undefined) {
|
|
119
|
+
// Unreachable: manifests is non-empty, so root or vendors[0] exists.
|
|
120
|
+
throw new Error("manifest set without an identity manifest");
|
|
121
|
+
}
|
|
122
|
+
const ordered = [identity, ...manifests.filter((m) => m !== identity)];
|
|
123
|
+
const name = resolveName(identity, ordered, findings);
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
dialect: identity.dialect,
|
|
127
|
+
manifests: ordered,
|
|
128
|
+
name,
|
|
129
|
+
readsAgents: vendors.length > 0,
|
|
130
|
+
mcpSources: resolveMcpSources(index, root, vendors),
|
|
131
|
+
hookSources: resolveHookSources(index, vendors),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function readManifestObject(index: PluginFileIndex, path: string, findings: Findings): JsonObject | undefined {
|
|
136
|
+
const text = readText(index, path, "manifest", findings);
|
|
137
|
+
return text === undefined ? undefined : parseJsonObject(text, path, "manifest-unreadable", findings);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
function readDialect(dialect: PluginDialect, object: JsonObject, path: string, findings: Findings): DialectManifest {
|
|
141
|
+
switch (dialect) {
|
|
142
|
+
case "agent-plugins":
|
|
143
|
+
return readOpenManifest(object, path, findings);
|
|
144
|
+
case "claude":
|
|
145
|
+
return readClaudeManifest(object, path, findings);
|
|
146
|
+
case "cursor":
|
|
147
|
+
return readCursorManifest(object, path, findings);
|
|
148
|
+
case "codex":
|
|
149
|
+
return readCodexManifest(object, path, findings);
|
|
150
|
+
default: {
|
|
151
|
+
const exhaustive: never = dialect;
|
|
152
|
+
throw new Error(`unknown dialect ${String(exhaustive)}`);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function emptyManifest(dialect: PluginDialect, path: string): DialectManifest {
|
|
158
|
+
return { dialect, path, identity: {}, skillPaths: [], mcpConfigs: [], hookSources: [], ignored: [] };
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function resolveName(identity: DialectManifest, all: readonly DialectManifest[], findings: Findings): string | undefined {
|
|
162
|
+
const name = identity.identity.name;
|
|
163
|
+
if (name === undefined) {
|
|
164
|
+
// An unreadable identity manifest already reported itself; a second
|
|
165
|
+
// finding about its missing name would blame the author twice.
|
|
166
|
+
if (findings.errors.some((f) => f.kind === "manifest-unreadable" && f.path === identity.path)) return undefined;
|
|
167
|
+
findings.error("manifest-name-missing", { path: identity.path });
|
|
168
|
+
return undefined;
|
|
169
|
+
}
|
|
170
|
+
let valid = true;
|
|
171
|
+
if (!isValidPluginName(name)) {
|
|
172
|
+
findings.error("manifest-name-invalid", { path: identity.path, subject: name });
|
|
173
|
+
valid = false;
|
|
174
|
+
}
|
|
175
|
+
for (const other of all) {
|
|
176
|
+
if (other === identity) continue;
|
|
177
|
+
const otherName = other.identity.name;
|
|
178
|
+
if (otherName !== undefined && otherName !== name) {
|
|
179
|
+
findings.error("manifest-name-conflict", {
|
|
180
|
+
path: identity.path,
|
|
181
|
+
subject: name,
|
|
182
|
+
detail: `'${otherName}' in '${other.path}'`,
|
|
183
|
+
});
|
|
184
|
+
valid = false;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return valid ? name : undefined;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/** The open format's name rule, applied in every dialect. */
|
|
191
|
+
export function isValidPluginName(name: string): boolean {
|
|
192
|
+
return name.length <= NAME_MAX_LENGTH && NAME_PATTERN.test(name) && !name.includes("--") && !name.includes("..");
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function resolveMcpSources(
|
|
196
|
+
index: PluginFileIndex,
|
|
197
|
+
root: DialectManifest | undefined,
|
|
198
|
+
vendors: readonly DialectManifest[],
|
|
199
|
+
): readonly McpConfigSource[] {
|
|
200
|
+
const sources: McpConfigSource[] = [];
|
|
201
|
+
if (root !== undefined && index.has(OPEN_MCP_CONFIG)) {
|
|
202
|
+
sources.push({ kind: "file", path: OPEN_MCP_CONFIG, dialect: "agent-plugins", manifest: root.path });
|
|
203
|
+
}
|
|
204
|
+
for (const vendor of vendors) {
|
|
205
|
+
if (vendor.mcpConfigs.length > 0) {
|
|
206
|
+
sources.push(...vendor.mcpConfigs);
|
|
207
|
+
} else if (vendor.dialect !== "cursor" && index.has(CLAUDE_DEFAULT_MCP_CONFIG)) {
|
|
208
|
+
sources.push({ kind: "file", path: CLAUDE_DEFAULT_MCP_CONFIG, dialect: vendor.dialect, manifest: vendor.path });
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
// Two manifests may name the same file (Claude and Codex both defaulting
|
|
212
|
+
// to `.mcp.json`); reading it twice would report every server twice.
|
|
213
|
+
const seen = new Set<string>();
|
|
214
|
+
return sources.filter((source) => {
|
|
215
|
+
if (source.kind === "inline") return true;
|
|
216
|
+
if (seen.has(source.path)) return false;
|
|
217
|
+
seen.add(source.path);
|
|
218
|
+
return true;
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function resolveHookSources(index: PluginFileIndex, vendors: readonly DialectManifest[]): readonly ResolvedHookSource[] {
|
|
223
|
+
const sources: ResolvedHookSource[] = [];
|
|
224
|
+
const files = new Map<string, { path: string; formats: HookFormat[]; manifest: string }>();
|
|
225
|
+
const addFile = (path: string, format: HookFormat, manifest: string): void => {
|
|
226
|
+
const existing = files.get(path);
|
|
227
|
+
if (existing !== undefined) {
|
|
228
|
+
if (!existing.formats.includes(format)) existing.formats.push(format);
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
const entry = { path, formats: [format], manifest };
|
|
232
|
+
files.set(path, entry);
|
|
233
|
+
sources.push({ kind: "file", path, formats: entry.formats, manifest });
|
|
234
|
+
};
|
|
235
|
+
// Vendors only: the open manifest declares no hooks.
|
|
236
|
+
for (const vendor of vendors) {
|
|
237
|
+
const format = hookFormatOf(vendor.dialect);
|
|
238
|
+
for (const source of vendor.hookSources) {
|
|
239
|
+
if (source.kind === "inline") sources.push({ kind: "inline", manifest: source.manifest, value: source.value, format });
|
|
240
|
+
else addFile(source.path, format, source.manifest);
|
|
241
|
+
}
|
|
242
|
+
if (index.has(DEFAULT_HOOKS_FILE)) addFile(DEFAULT_HOOKS_FILE, format, vendor.path);
|
|
243
|
+
}
|
|
244
|
+
return sources;
|
|
245
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Claude Code manifest (`.claude-plugin/plugin.json`), and the shape the
|
|
3
|
+
* Codex compatibility manifest shares with it.
|
|
4
|
+
*
|
|
5
|
+
* Claude's manifest is optional in its own tool (without one, the directory
|
|
6
|
+
* name is the plugin name) and `name` is its only required field. Path
|
|
7
|
+
* fields are a string or an array of strings, `./`-prefixed: `skills` ADDS
|
|
8
|
+
* to the default `skills/` scan and may name a directory that is itself a
|
|
9
|
+
* skill; `agents` REPLACES the default `agents/` and its entries are files
|
|
10
|
+
* or directories. `mcpServers` is a path, an inline object, or an array of
|
|
11
|
+
* either, defaulting to `.mcp.json` at the plugin root. `hooks` is the same
|
|
12
|
+
* three forms, merged with `hooks/hooks.json` when that file exists.
|
|
13
|
+
* `userConfig` declares the variables a user is prompted for. `settings`
|
|
14
|
+
* is the inline form of the plugin's `settings.json` (only its `agent` key
|
|
15
|
+
* takes effect on Stigmer; `normalise/settings.ts`). LSP servers, channels,
|
|
16
|
+
* output styles, workflows and the experimental components are recorded as
|
|
17
|
+
* ignored, except `experimental.evals`, the eval suite's directory, which is
|
|
18
|
+
* carried raw for the eval reader.
|
|
19
|
+
*
|
|
20
|
+
* The reader is exported with its known-field set so the Codex dialect,
|
|
21
|
+
* whose legacy manifest is this shape plus `apps` and `interface` and minus
|
|
22
|
+
* `settings`, reuses it rather than restating it.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { isJsonObject, type JsonObject } from "../documents.js";
|
|
26
|
+
import type { Findings } from "../messages.js";
|
|
27
|
+
import type { PluginDialect } from "../types.js";
|
|
28
|
+
import {
|
|
29
|
+
type DialectManifest,
|
|
30
|
+
ignoredFieldComponents,
|
|
31
|
+
readDeclaredPaths,
|
|
32
|
+
readHookSources,
|
|
33
|
+
readIdentity,
|
|
34
|
+
readMcpSources,
|
|
35
|
+
warnUnknownFields,
|
|
36
|
+
} from "./manifest.js";
|
|
37
|
+
|
|
38
|
+
export const CLAUDE_KNOWN_FIELDS: ReadonlySet<string> = new Set([
|
|
39
|
+
"name",
|
|
40
|
+
"version",
|
|
41
|
+
"description",
|
|
42
|
+
"author",
|
|
43
|
+
"homepage",
|
|
44
|
+
"repository",
|
|
45
|
+
"license",
|
|
46
|
+
"keywords",
|
|
47
|
+
"skills",
|
|
48
|
+
"commands",
|
|
49
|
+
"agents",
|
|
50
|
+
"workflows",
|
|
51
|
+
"hooks",
|
|
52
|
+
"mcpServers",
|
|
53
|
+
"outputStyles",
|
|
54
|
+
"lspServers",
|
|
55
|
+
"experimental",
|
|
56
|
+
"userConfig",
|
|
57
|
+
"channels",
|
|
58
|
+
"dependencies",
|
|
59
|
+
"defaultEnabled",
|
|
60
|
+
"settings",
|
|
61
|
+
]);
|
|
62
|
+
|
|
63
|
+
/** The default MCP configuration file when the manifest declares none. */
|
|
64
|
+
export const CLAUDE_DEFAULT_MCP_CONFIG = ".mcp.json";
|
|
65
|
+
|
|
66
|
+
export function readClaudeManifest(object: JsonObject, path: string, findings: Findings): DialectManifest {
|
|
67
|
+
return readClaudeShapedManifest(object, path, "claude", CLAUDE_KNOWN_FIELDS, findings);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The Claude shape under a given dialect and known-field set (Codex reuses it). */
|
|
71
|
+
export function readClaudeShapedManifest(
|
|
72
|
+
object: JsonObject,
|
|
73
|
+
path: string,
|
|
74
|
+
dialect: PluginDialect,
|
|
75
|
+
known: ReadonlySet<string>,
|
|
76
|
+
findings: Findings,
|
|
77
|
+
): DialectManifest {
|
|
78
|
+
warnUnknownFields(object, known, path, findings);
|
|
79
|
+
const identity = readIdentity(object, path, findings);
|
|
80
|
+
const skillPaths = readDeclaredPaths(object, "skills", path, findings) ?? [];
|
|
81
|
+
const agentPaths = readDeclaredPaths(object, "agents", path, findings);
|
|
82
|
+
const declaredMcp = readMcpSources(object, "mcpServers", path, dialect, findings);
|
|
83
|
+
const manifest: { -readonly [K in keyof DialectManifest]: DialectManifest[K] } = {
|
|
84
|
+
dialect,
|
|
85
|
+
path,
|
|
86
|
+
identity,
|
|
87
|
+
skillPaths,
|
|
88
|
+
mcpConfigs: declaredMcp,
|
|
89
|
+
hookSources: readHookSources(object, path, dialect, findings),
|
|
90
|
+
ignored: ignoredFieldComponents(object, path),
|
|
91
|
+
};
|
|
92
|
+
if (agentPaths !== undefined) manifest.agentPaths = agentPaths;
|
|
93
|
+
if (dialect === "claude" && object["settings"] !== undefined) manifest.settings = object["settings"];
|
|
94
|
+
if (object["userConfig"] !== undefined) {
|
|
95
|
+
manifest.variables = { dialect: "claude", value: object["userConfig"], manifest: path };
|
|
96
|
+
}
|
|
97
|
+
const experimental = object["experimental"];
|
|
98
|
+
if (isJsonObject(experimental) && experimental["evals"] !== undefined) {
|
|
99
|
+
manifest.evalsDir = { value: experimental["evals"], manifest: path };
|
|
100
|
+
}
|
|
101
|
+
return manifest;
|
|
102
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Codex compatibility manifest (`.codex-plugin/plugin.json`).
|
|
3
|
+
*
|
|
4
|
+
* New Codex packages are the open form: a root `plugin.json` with
|
|
5
|
+
* OpenAI-specific presentation, app mappings and hooks under
|
|
6
|
+
* `extensions["com.openai"]`, which the open reader records as an ignored
|
|
7
|
+
* extension. The legacy `.codex-plugin/plugin.json` that Codex still
|
|
8
|
+
* accepts is the Claude shape (`skills`, `mcpServers`, `hooks`) plus two
|
|
9
|
+
* fields of its own: `apps` (registered ChatGPT app mappings, `.app.json`)
|
|
10
|
+
* and `interface` (marketplace presentation). Its hooks are Claude Code's
|
|
11
|
+
* format, defaulting to `hooks/hooks.json`. Nothing else Codex-specific maps
|
|
12
|
+
* to a Stigmer resource, so the reader is the Claude reader under the
|
|
13
|
+
* `codex` dialect with the two extra fields known, `apps` ignored, and
|
|
14
|
+
* Claude's `settings` left unknown (Codex documents no such field).
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { JsonObject } from "../documents.js";
|
|
18
|
+
import type { Findings } from "../messages.js";
|
|
19
|
+
import { CLAUDE_KNOWN_FIELDS, readClaudeShapedManifest } from "./claude.js";
|
|
20
|
+
import type { DialectManifest } from "./manifest.js";
|
|
21
|
+
|
|
22
|
+
const KNOWN_FIELDS: ReadonlySet<string> = new Set([...[...CLAUDE_KNOWN_FIELDS].filter((field) => field !== "settings"), "apps", "interface"]);
|
|
23
|
+
|
|
24
|
+
export function readCodexManifest(object: JsonObject, path: string, findings: Findings): DialectManifest {
|
|
25
|
+
return readClaudeShapedManifest(object, path, "codex", KNOWN_FIELDS, findings);
|
|
26
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Cursor manifest (`.cursor-plugin/plugin.json`).
|
|
3
|
+
*
|
|
4
|
+
* Cursor publishes a draft-07 schema for this file (`additionalProperties:
|
|
5
|
+
* false`, only `name` required); the known-field set below is that schema's
|
|
6
|
+
* key list, and `author` there carries `name` and `email` only. Component
|
|
7
|
+
* fields `skills`, `agents`, `rules`, `commands` are a path or an array of
|
|
8
|
+
* paths (the schema says "glob pattern(s) or path(s)"; every published
|
|
9
|
+
* plugin uses a `./`-prefixed directory, and a glob is refused rather than
|
|
10
|
+
* expanded). `mcpServers` is a path, an inline object, or an array of
|
|
11
|
+
* either. `variables` is a JSON Schema object whose `properties` are the
|
|
12
|
+
* variables a user is prompted for and whose `required` list marks the
|
|
13
|
+
* mandatory ones; Cursor has no sensitivity flag, so Stigmer treats every
|
|
14
|
+
* Cursor variable as a secret. `hooks` is a path, an inline object or an
|
|
15
|
+
* array of either, merged with `hooks/hooks.json` when that file exists.
|
|
16
|
+
* `rules`, `commands`, `logo` and `minClientVersions` are recorded as
|
|
17
|
+
* ignored; `displayName`, `publisher`,
|
|
18
|
+
* `category` and `tags` are marketplace metadata Stigmer neither carries
|
|
19
|
+
* nor warns about.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import type { JsonObject } from "../documents.js";
|
|
23
|
+
import type { Findings } from "../messages.js";
|
|
24
|
+
import {
|
|
25
|
+
type DialectManifest,
|
|
26
|
+
ignoredFieldComponents,
|
|
27
|
+
readDeclaredPaths,
|
|
28
|
+
readHookSources,
|
|
29
|
+
readIdentity,
|
|
30
|
+
readMcpSources,
|
|
31
|
+
warnUnknownFields,
|
|
32
|
+
} from "./manifest.js";
|
|
33
|
+
|
|
34
|
+
const KNOWN_FIELDS: ReadonlySet<string> = new Set([
|
|
35
|
+
"name",
|
|
36
|
+
"displayName",
|
|
37
|
+
"description",
|
|
38
|
+
"version",
|
|
39
|
+
"minClientVersions",
|
|
40
|
+
"author",
|
|
41
|
+
"publisher",
|
|
42
|
+
"homepage",
|
|
43
|
+
"repository",
|
|
44
|
+
"license",
|
|
45
|
+
"logo",
|
|
46
|
+
"keywords",
|
|
47
|
+
"category",
|
|
48
|
+
"tags",
|
|
49
|
+
"commands",
|
|
50
|
+
"agents",
|
|
51
|
+
"skills",
|
|
52
|
+
"rules",
|
|
53
|
+
"hooks",
|
|
54
|
+
"variables",
|
|
55
|
+
"mcpServers",
|
|
56
|
+
]);
|
|
57
|
+
|
|
58
|
+
export function readCursorManifest(object: JsonObject, path: string, findings: Findings): DialectManifest {
|
|
59
|
+
warnUnknownFields(object, KNOWN_FIELDS, path, findings);
|
|
60
|
+
const identity = readIdentity(object, path, findings);
|
|
61
|
+
const skillPaths = readDeclaredPaths(object, "skills", path, findings) ?? [];
|
|
62
|
+
const agentPaths = readDeclaredPaths(object, "agents", path, findings);
|
|
63
|
+
const manifest: { -readonly [K in keyof DialectManifest]: DialectManifest[K] } = {
|
|
64
|
+
dialect: "cursor",
|
|
65
|
+
path,
|
|
66
|
+
identity,
|
|
67
|
+
skillPaths,
|
|
68
|
+
mcpConfigs: readMcpSources(object, "mcpServers", path, "cursor", findings),
|
|
69
|
+
hookSources: readHookSources(object, path, "cursor", findings),
|
|
70
|
+
ignored: ignoredFieldComponents(object, path),
|
|
71
|
+
};
|
|
72
|
+
if (agentPaths !== undefined) manifest.agentPaths = agentPaths;
|
|
73
|
+
if (object["variables"] !== undefined) {
|
|
74
|
+
manifest.variables = { dialect: "cursor", value: object["variables"], manifest: path };
|
|
75
|
+
}
|
|
76
|
+
return manifest;
|
|
77
|
+
}
|