@michaelfromyeg/weft-adapter-kit 1.0.0 → 1.1.0
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/dist/index.d.ts +25 -1
- package/dist/index.js +38 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -145,6 +145,12 @@ interface HarnessAdapter {
|
|
|
145
145
|
readonly version: string;
|
|
146
146
|
/** The harness manifest schema version this adapter emits against. */
|
|
147
147
|
readonly targetSchema: string;
|
|
148
|
+
/**
|
|
149
|
+
* Place artifacts directly under the scope's category dirs without the
|
|
150
|
+
* `plugins/<name>/` grouping. For directory-convention harnesses that load
|
|
151
|
+
* skills flatly from `.agents/skills/<leaf>/` rather than per-plugin.
|
|
152
|
+
*/
|
|
153
|
+
readonly flat?: boolean;
|
|
148
154
|
/** Resolve install directories for a scope on this machine. */
|
|
149
155
|
detect(scope: Scope, cwd: string): InstallPaths;
|
|
150
156
|
/** Compile one canonical component to its native artifacts. */
|
|
@@ -183,4 +189,22 @@ declare function parseFrontmatter(md: string): Frontmatter;
|
|
|
183
189
|
/** Re-emit a Markdown document with the given frontmatter data and body. */
|
|
184
190
|
declare function withFrontmatter(data: Record<string, unknown>, body: string): string;
|
|
185
191
|
|
|
186
|
-
|
|
192
|
+
interface GenericSkillsConfig {
|
|
193
|
+
/** The Target this adapter compiles for (must be a known Target). */
|
|
194
|
+
target: Target;
|
|
195
|
+
/** Project-scope root that holds `skills/`, relative to cwd (e.g. `.agents`). */
|
|
196
|
+
projectRoot: string;
|
|
197
|
+
/** User-scope root that holds `skills/`, tilde-prefixed (e.g. `~/.gemini`). */
|
|
198
|
+
globalRoot: string;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* A skills-only adapter for the directory-convention harnesses that load
|
|
202
|
+
* `SKILL.md` files from a shared `<root>/skills/<leaf>/` layout (the `.agents`
|
|
203
|
+
* family: Zed, Cline, Gemini CLI, Amp, Warp, …). It places each skill flatly
|
|
204
|
+
* (no `plugins/<name>/` grouping, hence `flat: true`) and emits nothing for the
|
|
205
|
+
* richer component kinds these harnesses don't accept (mcp/agent/hook/command/
|
|
206
|
+
* passthrough). Deep, full-plugin harnesses keep their own dedicated adapters.
|
|
207
|
+
*/
|
|
208
|
+
declare function genericSkillsAdapter(cfg: GenericSkillsConfig): HarnessAdapter;
|
|
209
|
+
|
|
210
|
+
export { type ArtifactKind, type CatalogEntry, type CompiledArtifact, type Frontmatter, type GenericSkillsConfig, type HarnessAdapter, type HarnessDriver, type ImportOptions, type ImportResult, type ImportedMarketplace, type ImportedPlugin, type InstallPaths, type PluginCtx, type ResolvedMarketplace, type RunOptions, type ToolCall, type Transcript, artifact, expandTilde, genericSkillsAdapter, parseFrontmatter, resolveUnder, withFrontmatter };
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as YAML from 'yaml';
|
|
2
|
+
import { join, isAbsolute } from 'path';
|
|
3
|
+
import { kindOf, refOf, leafNameOf } from '@michaelfromyeg/weft-schema';
|
|
2
4
|
import { homedir } from 'os';
|
|
3
5
|
export { homedir } from 'os';
|
|
4
|
-
import { join, isAbsolute } from 'path';
|
|
5
6
|
|
|
6
7
|
// src/artifact.ts
|
|
7
8
|
function artifact(relPath, contents, opts = {}) {
|
|
@@ -32,6 +33,41 @@ function resolveUnder(base, p) {
|
|
|
32
33
|
return isAbsolute(expanded) ? expanded : join(base, expanded);
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
|
|
36
|
+
// src/generic.ts
|
|
37
|
+
function genericSkillsAdapter(cfg) {
|
|
38
|
+
return {
|
|
39
|
+
target: cfg.target,
|
|
40
|
+
version: "1.0.0",
|
|
41
|
+
targetSchema: "agents-skills/1",
|
|
42
|
+
flat: true,
|
|
43
|
+
detect(scope, cwd) {
|
|
44
|
+
const root = scope === "user" ? expandTilde(cfg.globalRoot) : join(cwd, cfg.projectRoot);
|
|
45
|
+
const skills = join(root, "skills");
|
|
46
|
+
return {
|
|
47
|
+
root,
|
|
48
|
+
plugins: root,
|
|
49
|
+
skills,
|
|
50
|
+
mcp: root,
|
|
51
|
+
agents: root,
|
|
52
|
+
commands: root,
|
|
53
|
+
hooks: root,
|
|
54
|
+
catalog: root
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
transform(component, ctx) {
|
|
58
|
+
if (kindOf(component) !== "skill") return [];
|
|
59
|
+
const ref = refOf(component);
|
|
60
|
+
const leaf = leafNameOf(component);
|
|
61
|
+
return ctx.list(ref).map((file) => {
|
|
62
|
+
const within = file.startsWith(`${ref}/`) ? file.slice(ref.length + 1) : file;
|
|
63
|
+
return artifact(`skills/${leaf}/${within}`, ctx.read(file), { kind: "skill" });
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
emitManifest: () => [],
|
|
67
|
+
emitCatalog: () => []
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { artifact, expandTilde, genericSkillsAdapter, parseFrontmatter, resolveUnder, withFrontmatter };
|
|
36
72
|
//# sourceMappingURL=index.js.map
|
|
37
73
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/artifact.ts","../src/frontmatter.ts","../src/paths.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/artifact.ts","../src/frontmatter.ts","../src/paths.ts","../src/generic.ts"],"names":["join"],"mappings":";;;;;;;AA6BO,SAAS,QAAA,CACd,OAAA,EACA,QAAA,EACA,IAAA,GAAsD,EAAC,EACrC;AAClB,EAAA,OAAO,EAAE,OAAA,EAAS,QAAA,EAAU,GAAG,IAAA,EAAK;AACtC;AC5BA,IAAM,KAAA,GAAQ,mCAAA;AAMP,SAAS,iBAAiB,EAAA,EAAyB;AACxD,EAAA,MAAM,CAAA,GAAI,KAAA,CAAM,IAAA,CAAK,EAAE,CAAA;AACvB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AC/E,CAAC,CAAA;AAAA,IACH,CAAA;AAAA,IACA,YAAA,EAAc,MAAM,EAAC;AAAA,IACrB,WAAA,EAAa,MAAM;AAAC,GACtB;AACF","file":"index.js","sourcesContent":["/**\n * Classifies an artifact for the trust summary and lockfile grouping. This is\n * metadata only -- it never decides placement (relPath does that).\n */\nexport type ArtifactKind =\n | \"skill\"\n | \"mcp\"\n | \"agent\"\n | \"command\"\n | \"hook\"\n | \"manifest\"\n | \"catalog\"\n | \"other\";\n\n/**\n * One file an adapter emits. `relPath` is relative to the native plugin/output\n * root the adapter targets (e.g. \"skills/greet/SKILL.md\",\n * \".claude-plugin/plugin.json\"). Core decides the absolute base per build mode\n * and scope; the adapter never hard-codes absolute paths.\n */\nexport interface CompiledArtifact {\n relPath: string;\n contents: string | Buffer;\n kind?: ArtifactKind;\n /** Passthrough executables. Placed DISABLED; activation is a separate opt-in (spec §11). */\n executable?: boolean;\n}\n\n/** Convenience builder so adapters read declaratively. */\nexport function artifact(\n relPath: string,\n contents: string | Buffer,\n opts: { kind?: ArtifactKind; executable?: boolean } = {},\n): CompiledArtifact {\n return { relPath, contents, ...opts };\n}\n","import * as YAML from \"yaml\";\n\nexport interface Frontmatter {\n data: Record<string, unknown>;\n body: string;\n}\n\nconst FM_RE = /^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?/;\n\n/**\n * Split a Markdown document (SKILL.md, agent .md, rules .mdc) into its YAML\n * frontmatter and body. Returns empty data when there is no frontmatter block.\n */\nexport function parseFrontmatter(md: string): Frontmatter {\n const m = FM_RE.exec(md);\n if (!m) return { data: {}, body: md };\n const data = (YAML.parse(m[1], { version: \"1.2\", schema: \"core\" }) ?? {}) as Record<\n string,\n unknown\n >;\n return { data, body: md.slice(m[0].length) };\n}\n\n/** Re-emit a Markdown document with the given frontmatter data and body. */\nexport function withFrontmatter(data: Record<string, unknown>, body: string): string {\n const yaml = YAML.stringify(data, { version: \"1.2\" }).trimEnd();\n const cleanBody = body.startsWith(\"\\n\") ? body.slice(1) : body;\n return `---\\n${yaml}\\n---\\n${cleanBody}`;\n}\n","import { homedir } from \"node:os\";\nimport { isAbsolute, join } from \"node:path\";\n\n/**\n * Resolved install directories for one harness at one scope. Category dirs serve\n * adapters that scatter components into convention dirs; `plugins` serves adapters\n * that drop a whole compiled plugin tree. `root` is the scope base.\n */\nexport interface InstallPaths {\n root: string;\n plugins: string;\n skills: string;\n mcp: string;\n agents: string;\n commands: string;\n hooks: string;\n /** Where the per-harness marketplace catalog goes. */\n catalog: string;\n}\n\n/** Expand a leading `~` to the user's home directory. */\nexport function expandTilde(p: string): string {\n if (p === \"~\") return homedir();\n if (p.startsWith(\"~/\")) return join(homedir(), p.slice(2));\n return p;\n}\n\n/** Resolve a path that may be tilde-prefixed or relative to a base. */\nexport function resolveUnder(base: string, p: string): string {\n const expanded = expandTilde(p);\n return isAbsolute(expanded) ? expanded : join(base, expanded);\n}\n\nexport { homedir };\n","import { join } from \"node:path\";\nimport type { Component, Scope, Target } from \"@michaelfromyeg/weft-schema\";\nimport { kindOf, leafNameOf, refOf } from \"@michaelfromyeg/weft-schema\";\nimport type { HarnessAdapter, PluginCtx } from \"./adapter\";\nimport { artifact, type CompiledArtifact } from \"./artifact\";\nimport { expandTilde, type InstallPaths } from \"./paths\";\n\nexport interface GenericSkillsConfig {\n /** The Target this adapter compiles for (must be a known Target). */\n target: Target;\n /** Project-scope root that holds `skills/`, relative to cwd (e.g. `.agents`). */\n projectRoot: string;\n /** User-scope root that holds `skills/`, tilde-prefixed (e.g. `~/.gemini`). */\n globalRoot: string;\n}\n\n/**\n * A skills-only adapter for the directory-convention harnesses that load\n * `SKILL.md` files from a shared `<root>/skills/<leaf>/` layout (the `.agents`\n * family: Zed, Cline, Gemini CLI, Amp, Warp, …). It places each skill flatly\n * (no `plugins/<name>/` grouping, hence `flat: true`) and emits nothing for the\n * richer component kinds these harnesses don't accept (mcp/agent/hook/command/\n * passthrough). Deep, full-plugin harnesses keep their own dedicated adapters.\n */\nexport function genericSkillsAdapter(cfg: GenericSkillsConfig): HarnessAdapter {\n return {\n target: cfg.target,\n version: \"1.0.0\",\n targetSchema: \"agents-skills/1\",\n flat: true,\n detect(scope: Scope, cwd: string): InstallPaths {\n const root = scope === \"user\" ? expandTilde(cfg.globalRoot) : join(cwd, cfg.projectRoot);\n const skills = join(root, \"skills\");\n // Only `skills` is meaningful; the other category dirs point at root.\n return {\n root,\n plugins: root,\n skills,\n mcp: root,\n agents: root,\n commands: root,\n hooks: root,\n catalog: root,\n };\n },\n transform(component: Component, ctx: PluginCtx): CompiledArtifact[] {\n if (kindOf(component) !== \"skill\") return []; // skills-only\n const ref = refOf(component);\n const leaf = leafNameOf(component);\n return ctx.list(ref).map((file) => {\n const within = file.startsWith(`${ref}/`) ? file.slice(ref.length + 1) : file;\n return artifact(`skills/${leaf}/${within}`, ctx.read(file), { kind: \"skill\" });\n });\n },\n emitManifest: () => [],\n emitCatalog: () => [],\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@michaelfromyeg/weft-adapter-kit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Public HarnessAdapter / HarnessDriver interfaces and helpers. The contract a community adapter implements.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"yaml": "^2.6.1",
|
|
20
|
-
"@michaelfromyeg/weft-schema": "1.
|
|
20
|
+
"@michaelfromyeg/weft-schema": "1.1.0"
|
|
21
21
|
},
|
|
22
22
|
"license": "MIT",
|
|
23
23
|
"author": "Michael DeMarco",
|