@stigmer/plugin-package 3.15.3-dev.20260916211208
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 +190 -0
- package/README.md +66 -0
- package/detect.d.ts +50 -0
- package/detect.d.ts.map +1 -0
- package/detect.js +164 -0
- package/detect.js.map +1 -0
- package/dialects/claude.d.ts +30 -0
- package/dialects/claude.d.ts.map +1 -0
- package/dialects/claude.js +71 -0
- package/dialects/claude.js.map +1 -0
- package/dialects/codex.d.ts +18 -0
- package/dialects/codex.d.ts.map +1 -0
- package/dialects/codex.js +19 -0
- package/dialects/codex.js.map +1 -0
- package/dialects/cursor.d.ts +23 -0
- package/dialects/cursor.d.ts.map +1 -0
- package/dialects/cursor.js +63 -0
- package/dialects/cursor.js.map +1 -0
- package/dialects/manifest.d.ts +109 -0
- package/dialects/manifest.d.ts.map +1 -0
- package/dialects/manifest.js +194 -0
- package/dialects/manifest.js.map +1 -0
- package/dialects/open.d.ts +18 -0
- package/dialects/open.d.ts.map +1 -0
- package/dialects/open.js +47 -0
- package/dialects/open.js.map +1 -0
- package/documents.d.ts +43 -0
- package/documents.d.ts.map +1 -0
- package/documents.js +111 -0
- package/documents.js.map +1 -0
- package/files.d.ts +114 -0
- package/files.d.ts.map +1 -0
- package/files.js +187 -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 +19 -0
- package/index.d.ts.map +1 -0
- package/index.js +17 -0
- package/index.js.map +1 -0
- package/messages.d.ts +39 -0
- package/messages.d.ts.map +1 -0
- package/messages.js +135 -0
- package/messages.js.map +1 -0
- package/normalise/ignored.d.ts +24 -0
- package/normalise/ignored.d.ts.map +1 -0
- package/normalise/ignored.js +68 -0
- package/normalise/ignored.js.map +1 -0
- package/normalise/mcp-servers.d.ts +47 -0
- package/normalise/mcp-servers.d.ts.map +1 -0
- package/normalise/mcp-servers.js +397 -0
- package/normalise/mcp-servers.js.map +1 -0
- package/normalise/overlay.d.ts +27 -0
- package/normalise/overlay.d.ts.map +1 -0
- package/normalise/overlay.js +67 -0
- package/normalise/overlay.js.map +1 -0
- package/normalise/skills.d.ts +31 -0
- package/normalise/skills.d.ts.map +1 -0
- package/normalise/skills.js +116 -0
- package/normalise/skills.js.map +1 -0
- package/normalise/sub-agents.d.ts +44 -0
- package/normalise/sub-agents.d.ts.map +1 -0
- package/normalise/sub-agents.js +168 -0
- package/normalise/sub-agents.js.map +1 -0
- package/normalise/variables.d.ts +27 -0
- package/normalise/variables.d.ts.map +1 -0
- package/normalise/variables.js +155 -0
- package/normalise/variables.js.map +1 -0
- package/outcome.d.ts +46 -0
- package/outcome.d.ts.map +1 -0
- package/outcome.js +21 -0
- package/outcome.js.map +1 -0
- package/package.json +40 -0
- package/placeholders.d.ts +41 -0
- package/placeholders.d.ts.map +1 -0
- package/placeholders.js +68 -0
- package/placeholders.js.map +1 -0
- package/read-plugin-package.d.ts +19 -0
- package/read-plugin-package.d.ts.map +1 -0
- package/read-plugin-package.js +67 -0
- package/read-plugin-package.js.map +1 -0
- package/src/__test-utils__/directory-files.ts +29 -0
- package/src/__test-utils__/read.ts +55 -0
- package/src/__tests__/adversarial.test.ts +434 -0
- package/src/__tests__/detect.test.ts +133 -0
- package/src/__tests__/files.test.ts +119 -0
- package/src/__tests__/fixtures/cursor-plugins/NOTICE +22 -0
- package/src/__tests__/fixtures/cursor-plugins/advisor/.cursor-plugin/plugin.json +33 -0
- package/src/__tests__/fixtures/cursor-plugins/advisor/CHANGELOG.md +8 -0
- package/src/__tests__/fixtures/cursor-plugins/advisor/LICENSE +21 -0
- package/src/__tests__/fixtures/cursor-plugins/advisor/README.md +87 -0
- package/src/__tests__/fixtures/cursor-plugins/advisor/agents/advisor-subagent.md +48 -0
- package/src/__tests__/fixtures/cursor-plugins/advisor/assets/avatar.png +0 -0
- package/src/__tests__/fixtures/cursor-plugins/advisor/hooks/capture-response.sh +20 -0
- package/src/__tests__/fixtures/cursor-plugins/advisor/hooks/hooks.json +27 -0
- package/src/__tests__/fixtures/cursor-plugins/advisor/hooks/lib.sh +61 -0
- package/src/__tests__/fixtures/cursor-plugins/advisor/hooks/mark-pending.sh +27 -0
- package/src/__tests__/fixtures/cursor-plugins/advisor/hooks/record-consult.sh +41 -0
- package/src/__tests__/fixtures/cursor-plugins/advisor/hooks/stop-hook.sh +48 -0
- package/src/__tests__/fixtures/cursor-plugins/advisor/skills/advisor/SKILL.md +123 -0
- package/src/__tests__/fixtures/cursor-plugins/advisor/skills/advisor/references/briefing-template.md +44 -0
- package/src/__tests__/fixtures/cursor-plugins/github/.cursor-plugin/plugin.json +45 -0
- package/src/__tests__/fixtures/cursor-plugins/github/CHANGELOG.md +9 -0
- package/src/__tests__/fixtures/cursor-plugins/github/LICENSE +21 -0
- package/src/__tests__/fixtures/cursor-plugins/github/README.md +64 -0
- package/src/__tests__/fixtures/cursor-plugins/github/assets/logo.svg +0 -0
- package/src/__tests__/fixtures/cursor-plugins/github/mcp.json +11 -0
- package/src/__tests__/fixtures/cursor-plugins/playwright/.cursor-plugin/plugin.json +35 -0
- package/src/__tests__/fixtures/cursor-plugins/playwright/CHANGELOG.md +8 -0
- package/src/__tests__/fixtures/cursor-plugins/playwright/LICENSE +21 -0
- package/src/__tests__/fixtures/cursor-plugins/playwright/README.md +46 -0
- package/src/__tests__/fixtures/cursor-plugins/playwright/assets/logo.svg +0 -0
- package/src/__tests__/fixtures/cursor-plugins/playwright/mcp.json +8 -0
- package/src/__tests__/fixtures/cursor-plugins/salesforce/.cursor-plugin/plugin.json +48 -0
- package/src/__tests__/fixtures/cursor-plugins/salesforce/CHANGELOG.md +10 -0
- package/src/__tests__/fixtures/cursor-plugins/salesforce/LICENSE +21 -0
- package/src/__tests__/fixtures/cursor-plugins/salesforce/README.md +95 -0
- package/src/__tests__/fixtures/cursor-plugins/salesforce/assets/logo.svg +0 -0
- package/src/__tests__/fixtures/cursor-plugins/salesforce/mcp.json +12 -0
- package/src/__tests__/fixtures/cursor-plugins/thermos/.cursor-plugin/plugin.json +32 -0
- package/src/__tests__/fixtures/cursor-plugins/thermos/CHANGELOG.md +8 -0
- package/src/__tests__/fixtures/cursor-plugins/thermos/LICENSE +21 -0
- package/src/__tests__/fixtures/cursor-plugins/thermos/README.md +70 -0
- package/src/__tests__/fixtures/cursor-plugins/thermos/agents/thermo-nuclear-code-quality-review-subagent.md +23 -0
- package/src/__tests__/fixtures/cursor-plugins/thermos/agents/thermo-nuclear-review-subagent.md +28 -0
- package/src/__tests__/fixtures/cursor-plugins/thermos/assets/logo.png +0 -0
- package/src/__tests__/fixtures/cursor-plugins/thermos/skills/thermo-nuclear-code-quality-review/SKILL.md +192 -0
- package/src/__tests__/fixtures/cursor-plugins/thermos/skills/thermo-nuclear-review/SKILL.md +51 -0
- package/src/__tests__/fixtures/cursor-plugins/thermos/skills/thermos/SKILL.md +21 -0
- package/src/__tests__/fixtures/cursor-plugins/xero/.cursor-plugin/plugin.json +53 -0
- package/src/__tests__/fixtures/cursor-plugins/xero/CHANGELOG.md +9 -0
- package/src/__tests__/fixtures/cursor-plugins/xero/LICENSE +21 -0
- package/src/__tests__/fixtures/cursor-plugins/xero/README.md +79 -0
- package/src/__tests__/fixtures/cursor-plugins/xero/assets/logo.png +0 -0
- package/src/__tests__/fixtures/cursor-plugins/xero/mcp.json +16 -0
- package/src/__tests__/fixtures.test.ts +198 -0
- package/src/__tests__/mcp-servers.test.ts +120 -0
- package/src/__tests__/overlay-and-ignored.test.ts +65 -0
- package/src/__tests__/skills.test.ts +89 -0
- package/src/__tests__/sub-agents.test.ts +111 -0
- package/src/__tests__/variables.test.ts +94 -0
- package/src/detect.ts +189 -0
- package/src/dialects/claude.ts +90 -0
- package/src/dialects/codex.ts +24 -0
- package/src/dialects/cursor.ts +73 -0
- package/src/dialects/manifest.ts +237 -0
- package/src/dialects/open.ts +48 -0
- package/src/documents.ts +145 -0
- package/src/files.ts +213 -0
- package/src/frontmatter.ts +70 -0
- package/src/index.ts +59 -0
- package/src/messages.ts +206 -0
- package/src/normalise/ignored.ts +70 -0
- package/src/normalise/mcp-servers.ts +427 -0
- package/src/normalise/overlay.ts +71 -0
- package/src/normalise/skills.ts +126 -0
- package/src/normalise/sub-agents.ts +184 -0
- package/src/normalise/variables.ts +161 -0
- package/src/outcome.ts +122 -0
- package/src/placeholders.ts +74 -0
- package/src/read-plugin-package.ts +74 -0
- package/src/testing.ts +258 -0
- package/src/types.ts +189 -0
- package/testing.d.ts +106 -0
- package/testing.d.ts.map +1 -0
- package/testing.js +182 -0
- package/testing.js.map +1 -0
- package/types.d.ts +152 -0
- package/types.d.ts.map +1 -0
- package/types.js +19 -0
- package/types.js.map +1 -0
package/documents.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documents.js","sourceRoot":"","sources":["../src/documents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAkD,MAAM,YAAY,CAAC;AAIhH,gFAAgF;AAChF,MAAM,UAAU,QAAQ,CACtB,KAAsB,EACtB,IAAY,EACZ,GAAwB,EACxB,QAAkB;IAElB,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,CAAC;IACpD,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;AAC7D,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,SAAS,CACvB,KAAsB,EACtB,IAAY,EACZ,GAAwB,EACxB,QAAkB;IAElB,MAAM,KAAK,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;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114 @@
|
|
|
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 type { PluginErrorKind } from "./outcome.js";
|
|
25
|
+
export interface PluginFileEntry {
|
|
26
|
+
/** Plugin-relative POSIX path, no leading `./`, files only. */
|
|
27
|
+
readonly path: string;
|
|
28
|
+
/** The entry's declared size in bytes; `read` returns at most this many. */
|
|
29
|
+
readonly size: number;
|
|
30
|
+
}
|
|
31
|
+
export interface PluginFiles {
|
|
32
|
+
/** Sorted by path (code-point order), files only, every path contained. */
|
|
33
|
+
readonly entries: readonly PluginFileEntry[];
|
|
34
|
+
/** The bytes of one listed path. */
|
|
35
|
+
read(path: string): Uint8Array;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Per-document byte caps, checked from declared sizes. A plugin's documents
|
|
39
|
+
* are small by nature; the caps exist so no reader can be made to inflate
|
|
40
|
+
* a large entry through the library, not to bound legitimate content.
|
|
41
|
+
*/
|
|
42
|
+
export declare const PLUGIN_DOCUMENT_LIMITS: {
|
|
43
|
+
/** A manifest (`plugin.json` in any dialect). Real manifests are a few KB. */
|
|
44
|
+
readonly manifest: number;
|
|
45
|
+
/** An MCP configuration file. */
|
|
46
|
+
readonly mcpConfig: number;
|
|
47
|
+
/**
|
|
48
|
+
* A `SKILL.md`. The server's skill push gate inflates a `SKILL.md` alone
|
|
49
|
+
* under the same 1 MB cap, so a skill this library accepts is one the push
|
|
50
|
+
* gate accepts.
|
|
51
|
+
*/
|
|
52
|
+
readonly skillMd: number;
|
|
53
|
+
/** A sub-agent file (`agents/*.md`): a prompt, so the `SKILL.md` cap. */
|
|
54
|
+
readonly subAgent: number;
|
|
55
|
+
/** A document under `ai.stigmer/`: a resource YAML. */
|
|
56
|
+
readonly overlay: number;
|
|
57
|
+
};
|
|
58
|
+
export type PluginDocumentClass = keyof typeof PLUGIN_DOCUMENT_LIMITS;
|
|
59
|
+
/** An in-memory `PluginFiles` over path -> content; the testing builders' product. */
|
|
60
|
+
export declare function inMemoryPluginFiles(files: ReadonlyMap<string, Uint8Array | string>): PluginFiles;
|
|
61
|
+
/** Code-point order, the order `entries` is sorted in. */
|
|
62
|
+
export declare function comparePaths(a: string, b: string): number;
|
|
63
|
+
/** UTF-8 text with a leading byte-order mark removed (a manifest saved with a BOM was a known load failure elsewhere). */
|
|
64
|
+
export declare function decodeUtf8(bytes: Uint8Array): string;
|
|
65
|
+
/**
|
|
66
|
+
* Lexical containment of a LISTED path: relative, forward slashes only, no
|
|
67
|
+
* `.` or `..` segments, no empty segments. Readers produce such paths; the
|
|
68
|
+
* library refuses a reader that did not.
|
|
69
|
+
*/
|
|
70
|
+
export declare function isContainedPath(path: string): boolean;
|
|
71
|
+
export type DeclaredPathOutcome = {
|
|
72
|
+
readonly ok: true;
|
|
73
|
+
readonly path: string;
|
|
74
|
+
} | {
|
|
75
|
+
readonly ok: false;
|
|
76
|
+
readonly kind: Extract<PluginErrorKind, "path-not-relative" | "path-escapes-root" | "path-glob-unsupported">;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Normalise a path DECLARED in a manifest (`"./skills/"`, `"."`,
|
|
80
|
+
* `"./agents/reviewer.md"`) to a plugin-relative path with no leading `./`
|
|
81
|
+
* and no trailing slash; the plugin root itself is the empty string. The
|
|
82
|
+
* open format requires the `./` prefix; the vendor dialects document the
|
|
83
|
+
* same rule; a glob is refused because no plugin in the wild uses one and
|
|
84
|
+
* expanding globs is a second path language the library would then have
|
|
85
|
+
* to own.
|
|
86
|
+
*/
|
|
87
|
+
export declare function resolveDeclaredPath(value: string): DeclaredPathOutcome;
|
|
88
|
+
/** `dir + "/" + name`, or `name` at the plugin root. */
|
|
89
|
+
export declare function joinPath(dir: string, name: string): string;
|
|
90
|
+
/** The last segment of a plugin-relative path. */
|
|
91
|
+
export declare function basename(path: string): string;
|
|
92
|
+
/** The path without its last segment; the empty string at the root. */
|
|
93
|
+
export declare function dirname(path: string): string;
|
|
94
|
+
/**
|
|
95
|
+
* Indexed access over a `PluginFiles`: membership, the files under a
|
|
96
|
+
* directory, a directory's immediate children. Built once per read; every
|
|
97
|
+
* lookup is a map or a prefix walk over the sorted entries.
|
|
98
|
+
*/
|
|
99
|
+
export declare class PluginFileIndex {
|
|
100
|
+
readonly files: PluginFiles;
|
|
101
|
+
private readonly byPath;
|
|
102
|
+
constructor(files: PluginFiles);
|
|
103
|
+
has(path: string): boolean;
|
|
104
|
+
entry(path: string): PluginFileEntry | undefined;
|
|
105
|
+
/** Every file under `dir` (recursively), in entry order; every file at the root when `dir` is empty. */
|
|
106
|
+
filesUnder(dir: string): readonly string[];
|
|
107
|
+
/** True when at least one file lives under `dir`. */
|
|
108
|
+
isDirectory(dir: string): boolean;
|
|
109
|
+
/** The immediate child directory names under `dir`, sorted, deduplicated. */
|
|
110
|
+
childDirectories(dir: string): readonly string[];
|
|
111
|
+
/** The immediate child FILE names under `dir`, sorted. */
|
|
112
|
+
childFiles(dir: string): readonly string[];
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=files.d.ts.map
|
package/files.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../src/files.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,WAAW,eAAe;IAC9B,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,4EAA4E;IAC5E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IAC7C,oCAAoC;IACpC,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;CAChC;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;IACjC,8EAA8E;;IAE9E,iCAAiC;;IAEjC;;;;OAIG;;IAEH,yEAAyE;;IAEzE,uDAAuD;;CAE/C,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,sBAAsB,CAAC;AAQtE,sFAAsF;AACtF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,GAAG,WAAW,CAkBhG;AAED,0DAA0D;AAC1D,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED,0HAA0H;AAC1H,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAGpD;AAED;;;;GAIG;AACH,wBAAgB,eAAe,C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U3C"}
|
package/files.js
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
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
|
+
/**
|
|
25
|
+
* Per-document byte caps, checked from declared sizes. A plugin's documents
|
|
26
|
+
* are small by nature; the caps exist so no reader can be made to inflate
|
|
27
|
+
* a large entry through the library, not to bound legitimate content.
|
|
28
|
+
*/
|
|
29
|
+
export const PLUGIN_DOCUMENT_LIMITS = {
|
|
30
|
+
/** A manifest (`plugin.json` in any dialect). Real manifests are a few KB. */
|
|
31
|
+
manifest: 256 * 1024,
|
|
32
|
+
/** An MCP configuration file. */
|
|
33
|
+
mcpConfig: 256 * 1024,
|
|
34
|
+
/**
|
|
35
|
+
* A `SKILL.md`. The server's skill push gate inflates a `SKILL.md` alone
|
|
36
|
+
* under the same 1 MB cap, so a skill this library accepts is one the push
|
|
37
|
+
* gate accepts.
|
|
38
|
+
*/
|
|
39
|
+
skillMd: 1024 * 1024,
|
|
40
|
+
/** A sub-agent file (`agents/*.md`): a prompt, so the `SKILL.md` cap. */
|
|
41
|
+
subAgent: 1024 * 1024,
|
|
42
|
+
/** A document under `ai.stigmer/`: a resource YAML. */
|
|
43
|
+
overlay: 1024 * 1024,
|
|
44
|
+
};
|
|
45
|
+
const encoder = new TextEncoder();
|
|
46
|
+
// `fatal: false` keeps the decoder from throwing on a malformed sequence: a
|
|
47
|
+
// document with bad UTF-8 reaches the JSON or YAML parser, which refuses it
|
|
48
|
+
// with its own sentence, rather than crashing the read.
|
|
49
|
+
const decoder = new TextDecoder("utf-8", { fatal: false });
|
|
50
|
+
/** An in-memory `PluginFiles` over path -> content; the testing builders' product. */
|
|
51
|
+
export function inMemoryPluginFiles(files) {
|
|
52
|
+
const bytes = new Map();
|
|
53
|
+
for (const [path, content] of files) {
|
|
54
|
+
bytes.set(path, typeof content === "string" ? encoder.encode(content) : content);
|
|
55
|
+
}
|
|
56
|
+
const entries = [...bytes.entries()]
|
|
57
|
+
.map(([path, content]) => ({ path, size: content.length }))
|
|
58
|
+
.sort((a, b) => comparePaths(a.path, b.path));
|
|
59
|
+
return {
|
|
60
|
+
entries,
|
|
61
|
+
read(path) {
|
|
62
|
+
const content = bytes.get(path);
|
|
63
|
+
if (content === undefined) {
|
|
64
|
+
throw new Error(`plugin file '${path}' is not listed`);
|
|
65
|
+
}
|
|
66
|
+
return content;
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/** Code-point order, the order `entries` is sorted in. */
|
|
71
|
+
export function comparePaths(a, b) {
|
|
72
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
73
|
+
}
|
|
74
|
+
/** UTF-8 text with a leading byte-order mark removed (a manifest saved with a BOM was a known load failure elsewhere). */
|
|
75
|
+
export function decodeUtf8(bytes) {
|
|
76
|
+
const text = decoder.decode(bytes);
|
|
77
|
+
return text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Lexical containment of a LISTED path: relative, forward slashes only, no
|
|
81
|
+
* `.` or `..` segments, no empty segments. Readers produce such paths; the
|
|
82
|
+
* library refuses a reader that did not.
|
|
83
|
+
*/
|
|
84
|
+
export function isContainedPath(path) {
|
|
85
|
+
if (path === "" || path.startsWith("/") || path.includes("\\"))
|
|
86
|
+
return false;
|
|
87
|
+
return path.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
|
|
88
|
+
}
|
|
89
|
+
const GLOB_CHARACTERS = /[*?[\]{}]/;
|
|
90
|
+
/**
|
|
91
|
+
* Normalise a path DECLARED in a manifest (`"./skills/"`, `"."`,
|
|
92
|
+
* `"./agents/reviewer.md"`) to a plugin-relative path with no leading `./`
|
|
93
|
+
* and no trailing slash; the plugin root itself is the empty string. The
|
|
94
|
+
* open format requires the `./` prefix; the vendor dialects document the
|
|
95
|
+
* same rule; a glob is refused because no plugin in the wild uses one and
|
|
96
|
+
* expanding globs is a second path language the library would then have
|
|
97
|
+
* to own.
|
|
98
|
+
*/
|
|
99
|
+
export function resolveDeclaredPath(value) {
|
|
100
|
+
if (GLOB_CHARACTERS.test(value))
|
|
101
|
+
return { ok: false, kind: "path-glob-unsupported" };
|
|
102
|
+
if (value === "." || value === "./")
|
|
103
|
+
return { ok: true, path: "" };
|
|
104
|
+
if (!value.startsWith("./"))
|
|
105
|
+
return { ok: false, kind: "path-not-relative" };
|
|
106
|
+
const trimmed = value.slice(2).replace(/\/+$/, "");
|
|
107
|
+
if (trimmed === "")
|
|
108
|
+
return { ok: true, path: "" };
|
|
109
|
+
if (!isContainedPath(trimmed))
|
|
110
|
+
return { ok: false, kind: "path-escapes-root" };
|
|
111
|
+
return { ok: true, path: trimmed };
|
|
112
|
+
}
|
|
113
|
+
/** `dir + "/" + name`, or `name` at the plugin root. */
|
|
114
|
+
export function joinPath(dir, name) {
|
|
115
|
+
return dir === "" ? name : `${dir}/${name}`;
|
|
116
|
+
}
|
|
117
|
+
/** The last segment of a plugin-relative path. */
|
|
118
|
+
export function basename(path) {
|
|
119
|
+
const slash = path.lastIndexOf("/");
|
|
120
|
+
return slash === -1 ? path : path.slice(slash + 1);
|
|
121
|
+
}
|
|
122
|
+
/** The path without its last segment; the empty string at the root. */
|
|
123
|
+
export function dirname(path) {
|
|
124
|
+
const slash = path.lastIndexOf("/");
|
|
125
|
+
return slash === -1 ? "" : path.slice(0, slash);
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Indexed access over a `PluginFiles`: membership, the files under a
|
|
129
|
+
* directory, a directory's immediate children. Built once per read; every
|
|
130
|
+
* lookup is a map or a prefix walk over the sorted entries.
|
|
131
|
+
*/
|
|
132
|
+
export class PluginFileIndex {
|
|
133
|
+
files;
|
|
134
|
+
byPath;
|
|
135
|
+
constructor(files) {
|
|
136
|
+
this.files = files;
|
|
137
|
+
this.byPath = new Map(files.entries.map((entry) => [entry.path, entry]));
|
|
138
|
+
}
|
|
139
|
+
has(path) {
|
|
140
|
+
return this.byPath.has(path);
|
|
141
|
+
}
|
|
142
|
+
entry(path) {
|
|
143
|
+
return this.byPath.get(path);
|
|
144
|
+
}
|
|
145
|
+
/** Every file under `dir` (recursively), in entry order; every file at the root when `dir` is empty. */
|
|
146
|
+
filesUnder(dir) {
|
|
147
|
+
if (dir === "")
|
|
148
|
+
return this.files.entries.map((entry) => entry.path);
|
|
149
|
+
const prefix = `${dir}/`;
|
|
150
|
+
return this.files.entries.filter((entry) => entry.path.startsWith(prefix)).map((entry) => entry.path);
|
|
151
|
+
}
|
|
152
|
+
/** True when at least one file lives under `dir`. */
|
|
153
|
+
isDirectory(dir) {
|
|
154
|
+
if (dir === "")
|
|
155
|
+
return this.files.entries.length > 0;
|
|
156
|
+
const prefix = `${dir}/`;
|
|
157
|
+
return this.files.entries.some((entry) => entry.path.startsWith(prefix));
|
|
158
|
+
}
|
|
159
|
+
/** The immediate child directory names under `dir`, sorted, deduplicated. */
|
|
160
|
+
childDirectories(dir) {
|
|
161
|
+
const prefix = dir === "" ? "" : `${dir}/`;
|
|
162
|
+
const names = new Set();
|
|
163
|
+
for (const entry of this.files.entries) {
|
|
164
|
+
if (!entry.path.startsWith(prefix))
|
|
165
|
+
continue;
|
|
166
|
+
const rest = entry.path.slice(prefix.length);
|
|
167
|
+
const slash = rest.indexOf("/");
|
|
168
|
+
if (slash !== -1)
|
|
169
|
+
names.add(rest.slice(0, slash));
|
|
170
|
+
}
|
|
171
|
+
return [...names].sort(comparePaths);
|
|
172
|
+
}
|
|
173
|
+
/** The immediate child FILE names under `dir`, sorted. */
|
|
174
|
+
childFiles(dir) {
|
|
175
|
+
const prefix = dir === "" ? "" : `${dir}/`;
|
|
176
|
+
const names = [];
|
|
177
|
+
for (const entry of this.files.entries) {
|
|
178
|
+
if (!entry.path.startsWith(prefix))
|
|
179
|
+
continue;
|
|
180
|
+
const rest = entry.path.slice(prefix.length);
|
|
181
|
+
if (!rest.includes("/"))
|
|
182
|
+
names.push(rest);
|
|
183
|
+
}
|
|
184
|
+
return names.sort(comparePaths);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
//# 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;AAkBH;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,8EAA8E;IAC9E,QAAQ,EAAE,GAAG,GAAG,IAAI;IACpB,iCAAiC;IACjC,SAAS,EAAE,GAAG,GAAG,IAAI;IACrB;;;;OAIG;IACH,OAAO,EAAE,IAAI,GAAG,IAAI;IACpB,yEAAyE;IACzE,QAAQ,EAAE,IAAI,GAAG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C,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC7C,IAAI,CAAC,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"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CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,EAAE,EAAE,EAAE,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,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@stigmer/plugin-package`: the public surface.
|
|
3
|
+
*
|
|
4
|
+
* `readPluginPackage` is the entry; everything else here is what a consumer
|
|
5
|
+
* needs to supply its input (`PluginFiles`, the caps), route a directory
|
|
6
|
+
* (`MANIFEST_LOCATIONS`, `hasPluginManifest`), or render the outcome (the
|
|
7
|
+
* finding kinds and `isErrorKind`). The dialect readers and normalisers are
|
|
8
|
+
* internal: a consumer never composes a partial read.
|
|
9
|
+
*/
|
|
10
|
+
export { hasPluginManifest, isValidPluginName } from "./detect.js";
|
|
11
|
+
export { comparePaths, inMemoryPluginFiles, isContainedPath, PLUGIN_DOCUMENT_LIMITS, resolveDeclaredPath, type DeclaredPathOutcome, type PluginDocumentClass, type PluginFileEntry, type PluginFiles, } from "./files.js";
|
|
12
|
+
export { SKILL_NAME_PATTERN } from "./frontmatter.js";
|
|
13
|
+
export { AGENT_PLUGINS_MANIFEST_SCHEMA, AGENT_PLUGINS_MCP_SCHEMA, errorMessage, isErrorKind, MANIFEST_LOCATIONS, warningMessage, } from "./messages.js";
|
|
14
|
+
export { SUB_AGENT_INSTRUCTIONS_MIN, classifyModel } from "./normalise/sub-agents.js";
|
|
15
|
+
export { PLACEHOLDER_PATTERN, VARIABLE_NAME_PATTERN } from "./placeholders.js";
|
|
16
|
+
export type { FindingContext, PluginErrorKind, PluginFinding, PluginFindingKind, PluginReadOutcome, PluginWarningKind, } from "./outcome.js";
|
|
17
|
+
export { readPluginPackage } from "./read-plugin-package.js";
|
|
18
|
+
export type { IgnoredComponent, IgnoredComponentKind, ModelAlias, ModelHint, OverlayDocument, OverlayNamedDocument, OverlayServerDocument, PluginAuthor, PluginDialect, PluginMcpServer, PluginPackage, PluginSkill, PluginSubAgent, PluginVariable, StigmerOverlay, } from "./types.js";
|
|
19
|
+
//# 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;;;;;;;;GAQG;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,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,WAAW,GACjB,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,0BAA0B,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/E,YAAY,EACV,cAAc,EACd,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,YAAY,EACV,gBAAgB,EAChB,oBAAoB,EACpB,UAAU,EACV,SAAS,EACT,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,aAAa,EACb,WAAW,EACX,cAAc,EACd,cAAc,EACd,cAAc,GACf,MAAM,YAAY,CAAC"}
|
package/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@stigmer/plugin-package`: the public surface.
|
|
3
|
+
*
|
|
4
|
+
* `readPluginPackage` is the entry; everything else here is what a consumer
|
|
5
|
+
* needs to supply its input (`PluginFiles`, the caps), route a directory
|
|
6
|
+
* (`MANIFEST_LOCATIONS`, `hasPluginManifest`), or render the outcome (the
|
|
7
|
+
* finding kinds and `isErrorKind`). The dialect readers and normalisers are
|
|
8
|
+
* internal: a consumer never composes a partial read.
|
|
9
|
+
*/
|
|
10
|
+
export { hasPluginManifest, isValidPluginName } from "./detect.js";
|
|
11
|
+
export { comparePaths, inMemoryPluginFiles, isContainedPath, PLUGIN_DOCUMENT_LIMITS, resolveDeclaredPath, } from "./files.js";
|
|
12
|
+
export { SKILL_NAME_PATTERN } from "./frontmatter.js";
|
|
13
|
+
export { AGENT_PLUGINS_MANIFEST_SCHEMA, AGENT_PLUGINS_MCP_SCHEMA, errorMessage, isErrorKind, MANIFEST_LOCATIONS, warningMessage, } from "./messages.js";
|
|
14
|
+
export { SUB_AGENT_INSTRUCTIONS_MIN, classifyModel } from "./normalise/sub-agents.js";
|
|
15
|
+
export { PLACEHOLDER_PATTERN, VARIABLE_NAME_PATTERN } from "./placeholders.js";
|
|
16
|
+
export { readPluginPackage } from "./read-plugin-package.js";
|
|
17
|
+
//# 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;;;;;;;;GAQG;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,0BAA0B,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAS/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC"}
|
package/messages.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one sentence for every finding kind, and the collector that composes
|
|
3
|
+
* findings from a kind and its context.
|
|
4
|
+
*
|
|
5
|
+
* Copy lives here and nowhere else: the CLI and the server print these
|
|
6
|
+
* sentences verbatim, so a plugin refused offline is refused by the server
|
|
7
|
+
* with the same words, and a consumer never composes refusal copy of its
|
|
8
|
+
* own. Every sentence says what is wrong and, where the fix is not obvious,
|
|
9
|
+
* what Stigmer needs instead. Identifiers are single-quoted (the ts-server
|
|
10
|
+
* quoting rule for new copy). The `Record` types are exhaustive over the
|
|
11
|
+
* kind unions, so a kind without a sentence does not compile.
|
|
12
|
+
*/
|
|
13
|
+
import type { FindingContext, PluginErrorKind, PluginFinding, PluginFindingKind, PluginWarningKind } from "./outcome.js";
|
|
14
|
+
/** The canonical `$schema` identifiers the open format pins per version. */
|
|
15
|
+
export declare const AGENT_PLUGINS_MANIFEST_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/plugin.schema.json";
|
|
16
|
+
export declare const AGENT_PLUGINS_MCP_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json";
|
|
17
|
+
/** The four manifest locations, in the precedence the reader applies when there is no root manifest. */
|
|
18
|
+
export declare const MANIFEST_LOCATIONS: {
|
|
19
|
+
readonly "agent-plugins": "plugin.json";
|
|
20
|
+
readonly claude: ".claude-plugin/plugin.json";
|
|
21
|
+
readonly cursor: ".cursor-plugin/plugin.json";
|
|
22
|
+
readonly codex: ".codex-plugin/plugin.json";
|
|
23
|
+
};
|
|
24
|
+
export declare function errorMessage(kind: PluginErrorKind, ctx: FindingContext): string;
|
|
25
|
+
export declare function warningMessage(kind: PluginWarningKind, ctx: FindingContext): string;
|
|
26
|
+
/** True for the kinds that refuse a package. */
|
|
27
|
+
export declare function isErrorKind(kind: PluginFindingKind): kind is PluginErrorKind;
|
|
28
|
+
/**
|
|
29
|
+
* Collects findings while a read proceeds. The reader never throws on a
|
|
30
|
+
* plugin's content: every problem becomes a finding here, and the read
|
|
31
|
+
* continues so the outcome carries them all.
|
|
32
|
+
*/
|
|
33
|
+
export declare class Findings {
|
|
34
|
+
readonly errors: PluginFinding[];
|
|
35
|
+
readonly warnings: PluginFinding[];
|
|
36
|
+
error(kind: PluginErrorKind, ctx?: FindingContext): void;
|
|
37
|
+
warn(kind: PluginWarningKind, ctx?: FindingContext): void;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,cAAc,EACd,eAAe,EACf,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EAClB,MAAM,cAAc,CAAC;AAEtB,4EAA4E;AAC5E,eAAO,MAAM,6BAA6B,+DAA+D,CAAC;AAC1G,eAAO,MAAM,wBAAwB,4DAA4D,CAAC;AAElG,wGAAwG;AACxG,eAAO,MAAM,kBAAkB;;;;;CAKrB,CAAC;AAqIX,wBAAgB,YAAY,CAAC,IAAI,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,GAAG,MAAM,CAE/E;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,iBAAiB,EAAE,GAAG,EAAE,cAAc,GAAG,MAAM,CAEnF;AAED,gDAAgD;AAChD,wBAAgB,WAAW,CAAC,IAAI,EAAE,iBAAiB,GAAG,IAAI,IAAI,eAAe,CAE5E;AAED;;;;GAIG;AACH,qBAAa,QAAQ;IACnB,QAAQ,CAAC,MAAM,EAAE,aAAa,EAAE,CAAM;IACtC,QAAQ,CAAC,QAAQ,EAAE,aAAa,EAAE,CAAM;IAExC,KAAK,CAAC,IAAI,EAAE,eAAe,EAAE,GAAG,GAAE,cAAmB,GAAG,IAAI;IAI5D,IAAI,CAAC,IAAI,EAAE,iBAAiB,EAAE,GAAG,GAAE,cAAmB,GAAG,IAAI;CAG9D"}
|