vskill 1.2.10 → 1.2.12
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/agents.json +1 -1
- package/dist/commands/submit.d.ts +2 -0
- package/dist/commands/submit.js +4 -0
- package/dist/commands/submit.js.map +1 -1
- package/dist/eval-server/install-engine-routes.d.ts +12 -7
- package/dist/eval-server/install-engine-routes.js +2 -39
- package/dist/eval-server/install-engine-routes.js.map +1 -1
- package/dist/eval-server/install-jobs.js +31 -19
- package/dist/eval-server/install-jobs.js.map +1 -1
- package/dist/eval-server/install-skill-routes.js +7 -6
- package/dist/eval-server/install-skill-routes.js.map +1 -1
- package/dist/eval-server/install-state-routes.d.ts +2 -2
- package/dist/eval-server/install-state-routes.js +22 -9
- package/dist/eval-server/install-state-routes.js.map +1 -1
- package/dist/eval-server/remove-skill-routes.js +226 -156
- package/dist/eval-server/remove-skill-routes.js.map +1 -1
- package/dist/eval-server/skill-authoring-engine.d.ts +10 -0
- package/dist/eval-server/skill-authoring-engine.js +58 -0
- package/dist/eval-server/skill-authoring-engine.js.map +1 -0
- package/dist/eval-server/skill-authoring-path.d.ts +15 -0
- package/dist/eval-server/skill-authoring-path.js +38 -0
- package/dist/eval-server/skill-authoring-path.js.map +1 -0
- package/dist/eval-server/skill-authoring-route.d.ts +3 -0
- package/dist/eval-server/skill-authoring-route.js +37 -0
- package/dist/eval-server/skill-authoring-route.js.map +1 -0
- package/dist/eval-server/skill-create-routes.d.ts +74 -2
- package/dist/eval-server/skill-create-routes.js +59 -160
- package/dist/eval-server/skill-create-routes.js.map +1 -1
- package/dist/eval-server/skill-generate-route.d.ts +2 -0
- package/dist/eval-server/skill-generate-route.js +130 -0
- package/dist/eval-server/skill-generate-route.js.map +1 -0
- package/dist/eval-server/skill-install-paths.d.ts +39 -0
- package/dist/eval-server/skill-install-paths.js +167 -0
- package/dist/eval-server/skill-install-paths.js.map +1 -0
- package/dist/eval-server/skill-md-emitter.js +4 -2
- package/dist/eval-server/skill-md-emitter.js.map +1 -1
- package/dist/eval-server/supported-agents-routes.d.ts +8 -2
- package/dist/eval-server/supported-agents-routes.js +10 -2
- package/dist/eval-server/supported-agents-routes.js.map +1 -1
- package/dist/eval-ui/assets/{AdvancedTab-6VlfqCuD.js → AdvancedTab-DX3v5Q7O.js} +1 -1
- package/dist/eval-ui/assets/CreateSkillPage-CwreCn22.js +151 -0
- package/dist/eval-ui/assets/{FindSkillsPalette-M6Ot4Qeq.js → FindSkillsPalette-B5-3ZLEo.js} +2 -2
- package/dist/eval-ui/assets/{GeneralTab-BpFlJ2ue.js → GeneralTab-BfFbcbuP.js} +1 -1
- package/dist/eval-ui/assets/{PrivacyTab-UfO7QLy_.js → PrivacyTab-Bq2N7Iam.js} +1 -1
- package/dist/eval-ui/assets/{SearchPaletteCore-CufFV6OR.js → SearchPaletteCore-Bgld3QTz.js} +1 -1
- package/dist/eval-ui/assets/SkillDetailPanel-B5LYvcry.js +1 -0
- package/dist/eval-ui/assets/{UpdateDropdown-CVM2xW6V.js → UpdateDropdown-VRCYPtXG.js} +1 -1
- package/dist/eval-ui/assets/{UpdatesTab-C38-n7V3.js → UpdatesTab-w6h18GPp.js} +1 -1
- package/dist/eval-ui/assets/core-DgHXlyD_.js +1 -0
- package/dist/eval-ui/assets/{event-QtOCMXAv.js → event-CABB5pUM.js} +1 -1
- package/dist/eval-ui/assets/{fonts-i7Lkz2zN.css → fonts-BZeyWEAn.css} +1 -1
- package/dist/eval-ui/assets/{index-DlQYQHDO.js → index-Bje294df.js} +1 -1
- package/dist/eval-ui/assets/{index-DDNzcrhv.js → index-D0lWXViJ.js} +1 -1
- package/dist/eval-ui/assets/{index-CUEYzTVL.js → index-DCV9_0X4.js} +1 -1
- package/dist/eval-ui/assets/main-DIkxEshL.js +86 -0
- package/dist/eval-ui/assets/{preferences-BN-jNWS0.js → preferences-VTBvoXmM.js} +2 -2
- package/dist/eval-ui/assets/source-serif-4-cyrillic-ext-wght-normal-DHTKMUil.woff2 +0 -0
- package/dist/eval-ui/assets/source-serif-4-cyrillic-wght-normal-B1g8a0vD.woff2 +0 -0
- package/dist/eval-ui/assets/source-serif-4-greek-wght-normal-BpXpdlRW.woff2 +0 -0
- package/dist/eval-ui/assets/source-serif-4-latin-ext-wght-normal-BVZ5su8S.woff2 +0 -0
- package/dist/eval-ui/assets/source-serif-4-latin-wght-normal-DMe4EKeb.woff2 +0 -0
- package/dist/eval-ui/assets/source-serif-4-vietnamese-wght-normal-BsaNuasd.woff2 +0 -0
- package/dist/eval-ui/assets/{useDesktopBridge-Cm4zPght.js → useDesktopBridge-C8dT34x9.js} +2 -2
- package/dist/eval-ui/index.html +3 -3
- package/dist/eval-ui/lifecycle.html +2 -2
- package/dist/eval-ui/preferences.html +3 -3
- package/dist/index.js +8 -4
- package/dist/index.js.map +1 -1
- package/dist/shared/authoring-engine-commands.d.ts +14 -0
- package/dist/shared/authoring-engine-commands.js +10 -0
- package/dist/shared/authoring-engine-commands.js.map +1 -0
- package/dist/shared/skill-authoring-document.d.ts +28 -0
- package/dist/shared/skill-authoring-document.js +187 -0
- package/dist/shared/skill-authoring-document.js.map +1 -0
- package/dist/studio/routes/index.js +1 -1
- package/dist/studio/routes/index.js.map +1 -1
- package/dist/utils/semver.d.ts +1 -0
- package/dist/utils/semver.js +18 -0
- package/dist/utils/semver.js.map +1 -1
- package/dist/utils/skill-builder-detection.js +4 -9
- package/dist/utils/skill-builder-detection.js.map +1 -1
- package/package.json +5 -4
- package/dist/eval-ui/assets/CreateSkillPage-e3YH0sBH.js +0 -13
- package/dist/eval-ui/assets/SkillDetailPanel-B7f3UPBT.js +0 -1
- package/dist/eval-ui/assets/core-DZjBCfjp.js +0 -1
- package/dist/eval-ui/assets/main-C30fpcFP.js +0 -86
- package/dist/eval-ui/assets/source-serif-4-cyrillic-ext-wght-normal-cHuGMAiY.woff2 +0 -0
- package/dist/eval-ui/assets/source-serif-4-cyrillic-wght-normal-DwHjdM4S.woff2 +0 -0
- package/dist/eval-ui/assets/source-serif-4-greek-wght-normal-ece1310W.woff2 +0 -0
- package/dist/eval-ui/assets/source-serif-4-latin-ext-wght-normal-CxNHBx-q.woff2 +0 -0
- package/dist/eval-ui/assets/source-serif-4-latin-wght-normal-D9elroTD.woff2 +0 -0
- package/dist/eval-ui/assets/source-serif-4-vietnamese-wght-normal-D-yuW59g.woff2 +0 -0
- /package/dist/eval-ui/assets/{lifecycle-n00yue6r.js → lifecycle-DC0khFSd.js} +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
type AuthoringLayout = 1 | 2 | 3;
|
|
2
|
+
export declare class AuthoringPathError extends Error {
|
|
3
|
+
readonly status: number;
|
|
4
|
+
constructor(message: string, status: number);
|
|
5
|
+
}
|
|
6
|
+
export declare function computeSkillDir(root: string, layout: AuthoringLayout, plugin: string, name: string): string;
|
|
7
|
+
/** The load and update endpoints share both layout and real filesystem checks.
|
|
8
|
+
* Check before reading provenance, and again before writing: a prior successful
|
|
9
|
+
* GET is not authorization to follow a path that has since moved outside. */
|
|
10
|
+
export declare function resolveAuthoringSkillPath(root: string, plugin: string, skill: string, requestedLayout?: AuthoringLayout): {
|
|
11
|
+
dir: string;
|
|
12
|
+
file: string;
|
|
13
|
+
layout: AuthoringLayout;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { existsSync, realpathSync } from "node:fs";
|
|
2
|
+
import { isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
3
|
+
import { resolveSkillDir } from "./skill-resolver.js";
|
|
4
|
+
export class AuthoringPathError extends Error {
|
|
5
|
+
status;
|
|
6
|
+
constructor(message, status) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.status = status;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export function computeSkillDir(root, layout, plugin, name) {
|
|
12
|
+
switch (layout) {
|
|
13
|
+
case 1: return join(root, plugin, "skills", name);
|
|
14
|
+
case 2: return join(root, "plugins", plugin, "skills", name);
|
|
15
|
+
case 3: return join(root, "skills", name);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
/** The load and update endpoints share both layout and real filesystem checks.
|
|
19
|
+
* Check before reading provenance, and again before writing: a prior successful
|
|
20
|
+
* GET is not authorization to follow a path that has since moved outside. */
|
|
21
|
+
export function resolveAuthoringSkillPath(root, plugin, skill, requestedLayout) {
|
|
22
|
+
const dir = requestedLayout ? computeSkillDir(root, requestedLayout, plugin, skill) : resolveSkillDir(root, plugin, skill);
|
|
23
|
+
const layout = requestedLayout ?? [1, 2, 3].find((candidate) => resolve(computeSkillDir(root, candidate, plugin, skill)) === resolve(dir));
|
|
24
|
+
if (!layout)
|
|
25
|
+
throw new AuthoringPathError("Only workspace-authored skills can be updated here", 403);
|
|
26
|
+
const file = join(dir, "SKILL.md");
|
|
27
|
+
if (!existsSync(file))
|
|
28
|
+
throw new AuthoringPathError("Skill to update was not found", 404);
|
|
29
|
+
const realRoot = realpathSync.native(root);
|
|
30
|
+
for (const target of [dir, file]) {
|
|
31
|
+
const location = relative(realRoot, realpathSync.native(target));
|
|
32
|
+
if (!location || location === ".." || location.startsWith(`..${sep}`) || isAbsolute(location)) {
|
|
33
|
+
throw new AuthoringPathError("Only workspace-authored skills can be updated here", 403);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return { dir, file, layout };
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=skill-authoring-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-authoring-path.js","sourceRoot":"","sources":["../../src/eval-server/skill-authoring-path.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAGtD,MAA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,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IACnC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;QAAE,MAAM,IAAI,kBAAkB,CAAC,+BAA+B,EAAE,GAAG,CAAC,CAAC;IAC1F,MAAM,QAAQ,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3C,KAAK,MAAM,MAAM,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC;QACjC,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QACjE,IAAI,CAAC,QAAQ,IAAI,QAAQ,KAAK,IAAI,IAAI,QAAQ,CAAC,UAAU,CAAC,KAAK,GAAG,EAAE,CAAC,IAAI,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC9F,MAAM,IAAI,kBAAkB,CAAC,oDAAoD,EAAE,GAAG,CAAC,CAAC;QAC1F,CAAC;IACH,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { sendJson } from "./router.js";
|
|
3
|
+
import { AuthoringPathError, resolveAuthoringSkillPath } from "./skill-authoring-path.js";
|
|
4
|
+
import { readNativeSkillDocument } from "../shared/skill-authoring-document.js";
|
|
5
|
+
import { detectProjectGitHubStatus } from "./skill-create-routes.js";
|
|
6
|
+
import { readAuthoringEngine } from "./skill-authoring-engine.js";
|
|
7
|
+
/** Load authoring fields only for a skill inside the active workspace's layouts. */
|
|
8
|
+
export function registerSkillAuthoringRoute(router, getRoot) {
|
|
9
|
+
router.get("/api/skills/:plugin/:skill/authoring", async (req, res, params) => {
|
|
10
|
+
try {
|
|
11
|
+
if (!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(params.skill) ||
|
|
12
|
+
!/^[a-z0-9]([a-z0-9._-]*[a-z0-9])?$/i.test(params.plugin)) {
|
|
13
|
+
return sendJson(res, { error: "Invalid skill or plugin name" }, 400, req);
|
|
14
|
+
}
|
|
15
|
+
const root = getRoot();
|
|
16
|
+
const { file, layout } = resolveAuthoringSkillPath(root, params.plugin, params.skill);
|
|
17
|
+
const nativeSkillMd = readFileSync(file, "utf8");
|
|
18
|
+
const { fields: fm, version, body } = readNativeSkillDocument(nativeSkillMd);
|
|
19
|
+
const engine = readAuthoringEngine(nativeSkillMd);
|
|
20
|
+
const origin = detectProjectGitHubStatus(root).githubOrigin;
|
|
21
|
+
const ownerRepo = origin?.replace(/^https:\/\/github\.com\//, "").replace(/\.git$/, "");
|
|
22
|
+
sendJson(res, {
|
|
23
|
+
name: params.skill, plugin: layout === 3 ? "" : params.plugin, layout,
|
|
24
|
+
description: typeof fm.description === "string" ? fm.description : "",
|
|
25
|
+
model: typeof fm.model === "string" ? fm.model : "",
|
|
26
|
+
allowedTools: Array.isArray(fm["allowed-tools"]) ? fm["allowed-tools"].join(", ") : fm["allowed-tools"] || "",
|
|
27
|
+
body,
|
|
28
|
+
version: version ?? "1.0.0", engine, nativeSkillMd,
|
|
29
|
+
versionsHref: ownerRepo ? `https://verified-skill.com/skills/${ownerRepo}/${encodeURIComponent(params.skill)}/versions` : undefined,
|
|
30
|
+
}, 200, req);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
sendJson(res, { error: error.message }, error instanceof AuthoringPathError ? error.status : 400, req);
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=skill-authoring-route.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-authoring-route.js","sourceRoot":"","sources":["../../src/eval-server/skill-authoring-route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CA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oring-path.js";
|
|
1
2
|
import type { Router } from "./router.js";
|
|
2
3
|
import type { ProviderName } from "../eval/llm.js";
|
|
3
4
|
interface DetectedLayout {
|
|
@@ -15,18 +16,85 @@ interface ProjectLayoutResponse {
|
|
|
15
16
|
skill: string;
|
|
16
17
|
}>;
|
|
17
18
|
}
|
|
19
|
+
interface AiGenerationMeta {
|
|
20
|
+
prompt: string;
|
|
21
|
+
provider: string;
|
|
22
|
+
model: string;
|
|
23
|
+
reasoning: string;
|
|
24
|
+
}
|
|
18
25
|
/**
|
|
19
26
|
* Authoring engine for the skill (0734). Three first-class peer choices:
|
|
20
27
|
* - "vskill" (default): VSkill skill-builder, cross-universal across 8 agents.
|
|
21
28
|
* - "anthropic-skill-creator": Anthropic's built-in plugin, richer Claude-native
|
|
22
29
|
* schema, Claude-only. Requires the `skill-creator` plugin installed locally.
|
|
23
30
|
* - "none": skip engine assistance, emit the request body verbatim. The
|
|
24
|
-
* `metadata.engine`
|
|
31
|
+
* `metadata.engine` records the explicit unassisted choice.
|
|
25
32
|
*
|
|
26
33
|
* Anthropic and VSkill are peer engines, NOT a fallback chain — the trade-off
|
|
27
34
|
* is "richer Claude-native expressiveness" vs. "portable cross-tool output".
|
|
28
35
|
*/
|
|
29
36
|
export type CreateSkillEngine = "vskill" | "anthropic-skill-creator" | "none";
|
|
37
|
+
export interface CreateSkillRequest {
|
|
38
|
+
name: string;
|
|
39
|
+
plugin: string;
|
|
40
|
+
layout: 1 | 2 | 3;
|
|
41
|
+
description: string;
|
|
42
|
+
model?: string;
|
|
43
|
+
allowedTools?: string;
|
|
44
|
+
body: string;
|
|
45
|
+
/** Authoring engine — see CreateSkillEngine. Defaults to "vskill". */
|
|
46
|
+
engine?: CreateSkillEngine;
|
|
47
|
+
nativeSkillMd?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Explicit `metadata.version` to emit in SKILL.md frontmatter. When omitted:
|
|
50
|
+
* - mode="create" → defaults to "1.0.0"
|
|
51
|
+
* - mode="update" → existing version is read from disk and patch-bumped
|
|
52
|
+
*/
|
|
53
|
+
version?: string;
|
|
54
|
+
/**
|
|
55
|
+
* "create" (default) → fail with 409 if SKILL.md already exists (preserves
|
|
56
|
+
* the legacy guard that prevents accidental overwrite).
|
|
57
|
+
* "update" → overwrite the existing SKILL.md with the new content, bumping
|
|
58
|
+
* the patch version unless `version` is explicitly provided.
|
|
59
|
+
*/
|
|
60
|
+
mode?: "create" | "update";
|
|
61
|
+
/**
|
|
62
|
+
* Spec-compliant (agentskills.io/specification): emitted under `metadata.tags`
|
|
63
|
+
* in SKILL.md frontmatter, NEVER at the top level. Optional.
|
|
64
|
+
*/
|
|
65
|
+
tags?: string[];
|
|
66
|
+
/**
|
|
67
|
+
* Spec-compliant (agentskills.io/specification): emitted under
|
|
68
|
+
* `metadata.target-agents` in SKILL.md frontmatter, NEVER at the top level.
|
|
69
|
+
* Optional.
|
|
70
|
+
*/
|
|
71
|
+
targetAgents?: string[];
|
|
72
|
+
evals?: Array<{
|
|
73
|
+
id: number;
|
|
74
|
+
name: string;
|
|
75
|
+
prompt: string;
|
|
76
|
+
expected_output: string;
|
|
77
|
+
assertions: Array<{
|
|
78
|
+
id: string;
|
|
79
|
+
text: string;
|
|
80
|
+
type: string;
|
|
81
|
+
}>;
|
|
82
|
+
}>;
|
|
83
|
+
aiMeta?: AiGenerationMeta;
|
|
84
|
+
draftDir?: string;
|
|
85
|
+
files?: Record<string, string>;
|
|
86
|
+
secrets?: string[];
|
|
87
|
+
runtime?: {
|
|
88
|
+
python?: string;
|
|
89
|
+
pip?: string[];
|
|
90
|
+
node?: string;
|
|
91
|
+
};
|
|
92
|
+
integrationTests?: {
|
|
93
|
+
runner: "vitest" | "pytest" | "none";
|
|
94
|
+
file?: string;
|
|
95
|
+
requires?: string[];
|
|
96
|
+
};
|
|
97
|
+
}
|
|
30
98
|
export interface PluginSuggestion {
|
|
31
99
|
plugin: string;
|
|
32
100
|
layout: 1 | 2;
|
|
@@ -155,12 +223,17 @@ export declare const EVAL_SYSTEM_PROMPT = "You are an expert AI skill evaluator.
|
|
|
155
223
|
*/
|
|
156
224
|
export declare function buildAgentAwareSystemPrompt(basePrompt: string, targetAgents: string[] | undefined): string;
|
|
157
225
|
export interface GenerateSkillRequest {
|
|
226
|
+
engine?: CreateSkillEngine;
|
|
227
|
+
body?: string;
|
|
158
228
|
prompt: string;
|
|
159
229
|
provider?: ProviderName;
|
|
160
230
|
model?: string;
|
|
161
231
|
targetAgents?: string[];
|
|
162
232
|
}
|
|
163
233
|
export interface GenerateSkillResult {
|
|
234
|
+
nativeSkillMd?: string;
|
|
235
|
+
engine?: CreateSkillEngine;
|
|
236
|
+
emittedTargets?: string[];
|
|
164
237
|
name: string;
|
|
165
238
|
description: string;
|
|
166
239
|
model: string;
|
|
@@ -196,4 +269,3 @@ export declare function parseBodyResponse(raw: string): BodyResult;
|
|
|
196
269
|
export declare function parseEvalsResponse(raw: string): EvalsResult;
|
|
197
270
|
export declare function mergeGenerateResults(bodySettled: PromiseSettledResult<BodyResult>, evalsSettled: PromiseSettledResult<EvalsResult>): GenerateSkillResult;
|
|
198
271
|
export declare function registerSkillCreateRoutes(router: Router, rootArg: string | (() => string)): void;
|
|
199
|
-
export {};
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { authoringRequestError, AuthoringValidationError, readNativeSkillDocument } from "../shared/skill-authoring-document.js";
|
|
2
|
+
import { registerSkillAuthoringRoute } from "./skill-authoring-route.js";
|
|
3
|
+
import { AuthoringPathError, computeSkillDir, resolveAuthoringSkillPath } from "./skill-authoring-path.js";
|
|
4
|
+
export { computeSkillDir } from "./skill-authoring-path.js";
|
|
5
|
+
import { registerSkillGenerateRoute } from "./skill-generate-route.js";
|
|
6
|
+
import { generateWithSkillCreator, mergeNativeSkillMd, readAuthoringEngine } from "./skill-authoring-engine.js";
|
|
1
7
|
import { buildSkillMd } from "./skill-md-emitter.js";
|
|
2
8
|
// ---------------------------------------------------------------------------
|
|
3
9
|
// skill-create-routes.ts -- Skill creation & project layout detection
|
|
@@ -7,13 +13,10 @@ import { join, basename, resolve, sep } from "node:path";
|
|
|
7
13
|
import { spawnSync } from "node:child_process";
|
|
8
14
|
import { isSkillCreatorInstalled } from "../utils/skill-creator-detection.js";
|
|
9
15
|
import { sendJson, readBody } from "./router.js";
|
|
10
|
-
import {
|
|
11
|
-
import { initSSE, sendSSE, sendSSEDone } from "./sse-helpers.js";
|
|
12
|
-
import { classifyError } from "./error-classifier.js";
|
|
16
|
+
import { parseSkillFrontmatter, parseGithubRemote, walkUpForGitRoot } from "./api-routes.js";
|
|
13
17
|
import { writeHistoryEntry } from "../eval/benchmark-history.js";
|
|
14
18
|
import { getAgentCreationProfile } from "../agents/agents-registry.js";
|
|
15
|
-
import {
|
|
16
|
-
import { extractFrontmatterVersion, bumpPatch } from "../utils/version.js";
|
|
19
|
+
import { bumpPatch } from "../utils/version.js";
|
|
17
20
|
import { submitSkillUpdateEvent } from "./platform-proxy.js";
|
|
18
21
|
const VALID_ENGINES = new Set([
|
|
19
22
|
"vskill",
|
|
@@ -391,13 +394,6 @@ export function buildEnvExample(secrets) {
|
|
|
391
394
|
}
|
|
392
395
|
return lines.join("\n") + "\n";
|
|
393
396
|
}
|
|
394
|
-
function computeSkillDir(root, layout, plugin, name) {
|
|
395
|
-
switch (layout) {
|
|
396
|
-
case 1: return join(root, plugin, "skills", name);
|
|
397
|
-
case 2: return join(root, "plugins", plugin, "skills", name);
|
|
398
|
-
case 3: return join(root, "skills", name);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
397
|
/**
|
|
402
398
|
* Check if a resolved path is strictly within a root directory.
|
|
403
399
|
* Uses trailing separator to prevent prefix collision (e.g., /project vs /project-evil).
|
|
@@ -824,43 +820,6 @@ function parseGenerateResponse(raw) {
|
|
|
824
820
|
reasoning,
|
|
825
821
|
};
|
|
826
822
|
}
|
|
827
|
-
/**
|
|
828
|
-
* Merge generator output with a `suggestedPlugin` computed from the existing
|
|
829
|
-
* plugins on disk. Kept out of src/core/skill-generator.ts so the generator
|
|
830
|
-
* stays pure (no filesystem access for plugin suggestion).
|
|
831
|
-
*/
|
|
832
|
-
function attachSuggestedPlugin(parsed, root) {
|
|
833
|
-
const tags = parsed.description
|
|
834
|
-
? parsed.description.toLowerCase().split(/[,;]+/).map((s) => s.trim()).filter(Boolean)
|
|
835
|
-
: [];
|
|
836
|
-
const suggestedPlugin = matchExistingPlugin(parsed.name, parsed.description, tags, root);
|
|
837
|
-
return { ...parsed, suggestedPlugin };
|
|
838
|
-
}
|
|
839
|
-
async function resolveProviderModel(requestedProvider, requestedModel) {
|
|
840
|
-
// Both absent → legacy default (no probe).
|
|
841
|
-
if (!requestedProvider && !requestedModel) {
|
|
842
|
-
return { ok: true, provider: "claude-cli", model: "sonnet" };
|
|
843
|
-
}
|
|
844
|
-
const detected = await detectAvailableProviders();
|
|
845
|
-
const requested = requestedProvider || "claude-cli";
|
|
846
|
-
const match = detected.find((p) => p.id === requested);
|
|
847
|
-
if (!match) {
|
|
848
|
-
return {
|
|
849
|
-
ok: false,
|
|
850
|
-
error: "unknown_provider",
|
|
851
|
-
validProviders: detected.map((p) => p.id),
|
|
852
|
-
};
|
|
853
|
-
}
|
|
854
|
-
const validModelIds = match.models.map((m) => m.id);
|
|
855
|
-
if (requestedModel !== undefined) {
|
|
856
|
-
if (!validModelIds.includes(requestedModel)) {
|
|
857
|
-
return { ok: false, error: "unknown_model", validModels: validModelIds };
|
|
858
|
-
}
|
|
859
|
-
return { ok: true, provider: requested, model: requestedModel };
|
|
860
|
-
}
|
|
861
|
-
// Provider given, model omitted — pick the first model id for that provider.
|
|
862
|
-
return { ok: true, provider: requested, model: validModelIds[0] ?? "sonnet" };
|
|
863
|
-
}
|
|
864
823
|
// ---------------------------------------------------------------------------
|
|
865
824
|
// Route registration
|
|
866
825
|
// ---------------------------------------------------------------------------
|
|
@@ -895,29 +854,30 @@ export function registerSkillCreateRoutes(router, rootArg) {
|
|
|
895
854
|
router.post("/api/skills/create", async (req, res) => {
|
|
896
855
|
const root = getRoot();
|
|
897
856
|
const body = (await readBody(req));
|
|
898
|
-
|
|
899
|
-
if (
|
|
900
|
-
sendJson(res, { error:
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
857
|
+
const validationError = authoringRequestError(body);
|
|
858
|
+
if (validationError)
|
|
859
|
+
return sendJson(res, { error: validationError }, 400, req);
|
|
860
|
+
// 0734: validate authoring engine. Default to "vskill" when omitted.
|
|
861
|
+
const targetDir = computeSkillDir(root, body.layout, body.plugin || "", body.name);
|
|
862
|
+
const skillMdPath = join(targetDir, "SKILL.md");
|
|
863
|
+
if (body.mode === "update") {
|
|
864
|
+
try {
|
|
865
|
+
resolveAuthoringSkillPath(root, body.plugin || "", body.name, body.layout);
|
|
866
|
+
}
|
|
867
|
+
catch (error) {
|
|
868
|
+
sendJson(res, { error: error.message }, error instanceof AuthoringPathError ? error.status : 400, req);
|
|
869
|
+
return;
|
|
870
|
+
}
|
|
910
871
|
}
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
872
|
+
let previousEngine = "vskill";
|
|
873
|
+
try {
|
|
874
|
+
if (body.mode === "update" && existsSync(skillMdPath))
|
|
875
|
+
previousEngine = readAuthoringEngine(readFileSync(skillMdPath, "utf8"));
|
|
914
876
|
}
|
|
915
|
-
|
|
916
|
-
sendJson(res, { error:
|
|
917
|
-
return;
|
|
877
|
+
catch (error) {
|
|
878
|
+
return sendJson(res, { error: error.message }, 400, req);
|
|
918
879
|
}
|
|
919
|
-
|
|
920
|
-
const engine = (body.engine ?? "vskill");
|
|
880
|
+
const engine = body.engine ?? previousEngine;
|
|
921
881
|
if (body.engine !== undefined && !VALID_ENGINES.has(body.engine)) {
|
|
922
882
|
sendJson(res, {
|
|
923
883
|
error: `Invalid engine: ${body.engine}. Must be one of: vskill, anthropic-skill-creator, none.`,
|
|
@@ -931,8 +891,6 @@ export function registerSkillCreateRoutes(router, rootArg) {
|
|
|
931
891
|
}, 400, req);
|
|
932
892
|
return;
|
|
933
893
|
}
|
|
934
|
-
const targetDir = computeSkillDir(root, body.layout, body.plugin || "", body.name);
|
|
935
|
-
const skillMdPath = join(targetDir, "SKILL.md");
|
|
936
894
|
// Check if already exists. Three legitimate ways to overwrite:
|
|
937
895
|
// 1. draft.json marker → finalizing an auto-saved draft
|
|
938
896
|
// 2. mode === "update" → caller intentionally wants to overwrite
|
|
@@ -953,6 +911,10 @@ export function registerSkillCreateRoutes(router, rootArg) {
|
|
|
953
911
|
}, 409, req);
|
|
954
912
|
return;
|
|
955
913
|
}
|
|
914
|
+
if (isUpdateMode && !skillExists) {
|
|
915
|
+
sendJson(res, { error: "Skill to update was not found" }, 404, req);
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
956
918
|
// Resolve the version to emit in SKILL.md.
|
|
957
919
|
// - explicit body.version always wins
|
|
958
920
|
// - update mode reads the existing version + bumps patch
|
|
@@ -963,18 +925,29 @@ export function registerSkillCreateRoutes(router, rootArg) {
|
|
|
963
925
|
}
|
|
964
926
|
else if (skillExists && isUpdateMode) {
|
|
965
927
|
const existing = readFileSync(skillMdPath, "utf-8");
|
|
966
|
-
const previous =
|
|
928
|
+
const previous = readNativeSkillDocument(existing).version ?? "1.0.0";
|
|
967
929
|
resolvedVersion = bumpPatch(previous);
|
|
968
930
|
}
|
|
969
931
|
else {
|
|
970
932
|
resolvedVersion = "1.0.0";
|
|
971
933
|
}
|
|
972
934
|
try {
|
|
973
|
-
//
|
|
935
|
+
// Direct Anthropic requests execute the installed engine. A preview from
|
|
936
|
+
// /generate carries the native document, so saving never generates twice.
|
|
937
|
+
const generated = engine === "anthropic-skill-creator" && !body.nativeSkillMd && !isUpdateMode
|
|
938
|
+
? await generateWithSkillCreator({ prompt: `${body.description}\n\n${body.body}`, model: body.aiMeta?.model }, { root })
|
|
939
|
+
: undefined;
|
|
940
|
+
const native = generated?.nativeSkillMd ?? body.nativeSkillMd ?? (isUpdateMode ? readFileSync(skillMdPath, "utf8") : undefined);
|
|
941
|
+
const content = native
|
|
942
|
+
? mergeNativeSkillMd(native, { ...body, body: generated?.body ?? body.body, version: resolvedVersion, engine })
|
|
943
|
+
: buildSkillMd({ ...body, version: resolvedVersion, engine });
|
|
944
|
+
readNativeSkillDocument(content);
|
|
945
|
+
// Create directories only after generation/validation succeeds.
|
|
946
|
+
if (isUpdateMode)
|
|
947
|
+
resolveAuthoringSkillPath(root, body.plugin || "", body.name, body.layout);
|
|
974
948
|
mkdirSync(targetDir, { recursive: true });
|
|
975
949
|
mkdirSync(join(targetDir, "evals"), { recursive: true });
|
|
976
950
|
// Write SKILL.md (with resolved version + validated engine).
|
|
977
|
-
const content = buildSkillMd({ ...body, version: resolvedVersion, engine });
|
|
978
951
|
writeFileSync(skillMdPath, content, "utf-8");
|
|
979
952
|
// Write evals.json if provided (from AI generation)
|
|
980
953
|
if (body.evals && body.evals.length > 0) {
|
|
@@ -1097,25 +1070,16 @@ export function registerSkillCreateRoutes(router, rootArg) {
|
|
|
1097
1070
|
}
|
|
1098
1071
|
catch (err) {
|
|
1099
1072
|
// On failure, do NOT delete draftDir — preserve user's work
|
|
1100
|
-
sendJson(res, { error: `Failed to create skill: ${err.message}` }, 500, req);
|
|
1073
|
+
sendJson(res, { error: `Failed to create skill: ${err.message}` }, err instanceof AuthoringValidationError ? 400 : 500, req);
|
|
1101
1074
|
}
|
|
1102
1075
|
});
|
|
1103
1076
|
// POST /api/skills/save-draft — auto-save AI-generated skill as draft
|
|
1104
1077
|
router.post("/api/skills/save-draft", async (req, res) => {
|
|
1105
1078
|
const root = getRoot();
|
|
1106
1079
|
const body = (await readBody(req));
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
return;
|
|
1110
|
-
}
|
|
1111
|
-
if (!body.description?.trim()) {
|
|
1112
|
-
sendJson(res, { error: "Description is required" }, 400, req);
|
|
1113
|
-
return;
|
|
1114
|
-
}
|
|
1115
|
-
if (!body.layout || ![1, 2, 3].includes(body.layout)) {
|
|
1116
|
-
sendJson(res, { error: "Layout must be 1, 2, or 3" }, 400, req);
|
|
1117
|
-
return;
|
|
1118
|
-
}
|
|
1080
|
+
const validationError = authoringRequestError(body, true);
|
|
1081
|
+
if (validationError)
|
|
1082
|
+
return sendJson(res, { error: validationError }, 400, req);
|
|
1119
1083
|
const targetDir = computeSkillDir(root, body.layout, body.plugin || "", body.name);
|
|
1120
1084
|
const skillMdPath = join(targetDir, "SKILL.md");
|
|
1121
1085
|
const files = [];
|
|
@@ -1129,18 +1093,19 @@ export function registerSkillCreateRoutes(router, rootArg) {
|
|
|
1129
1093
|
resolvedVersion = body.version.trim();
|
|
1130
1094
|
}
|
|
1131
1095
|
else if (existsSync(skillMdPath)) {
|
|
1132
|
-
resolvedVersion =
|
|
1096
|
+
resolvedVersion = readNativeSkillDocument(readFileSync(skillMdPath, "utf-8")).version ?? "1.0.0";
|
|
1133
1097
|
}
|
|
1134
1098
|
else {
|
|
1135
1099
|
resolvedVersion = "1.0.0";
|
|
1136
1100
|
}
|
|
1137
1101
|
try {
|
|
1138
|
-
|
|
1102
|
+
const content = body.nativeSkillMd
|
|
1103
|
+
? mergeNativeSkillMd(body.nativeSkillMd, { ...body, version: resolvedVersion })
|
|
1104
|
+
: buildSkillMd({ ...body, version: resolvedVersion });
|
|
1105
|
+
readNativeSkillDocument(content);
|
|
1139
1106
|
mkdirSync(targetDir, { recursive: true });
|
|
1140
1107
|
mkdirSync(join(targetDir, "evals"), { recursive: true });
|
|
1141
1108
|
mkdirSync(join(targetDir, "evals", "history"), { recursive: true });
|
|
1142
|
-
// Write SKILL.md
|
|
1143
|
-
const content = buildSkillMd({ ...body, version: resolvedVersion });
|
|
1144
1109
|
writeFileSync(skillMdPath, content, "utf-8");
|
|
1145
1110
|
files.push("SKILL.md");
|
|
1146
1111
|
// Write evals.json if provided
|
|
@@ -1184,7 +1149,7 @@ export function registerSkillCreateRoutes(router, rootArg) {
|
|
|
1184
1149
|
}, 201, req);
|
|
1185
1150
|
}
|
|
1186
1151
|
catch (err) {
|
|
1187
|
-
sendJson(res, { error: `Failed to save draft: ${err.message}` }, 500, req);
|
|
1152
|
+
sendJson(res, { error: `Failed to save draft: ${err.message}` }, err instanceof AuthoringValidationError ? 400 : 500, req);
|
|
1188
1153
|
}
|
|
1189
1154
|
});
|
|
1190
1155
|
// GET /api/skill-creator-status — check if skill-creator is installed
|
|
@@ -1196,73 +1161,7 @@ export function registerSkillCreateRoutes(router, rootArg) {
|
|
|
1196
1161
|
installCommand: "npx vskill install anthropics/skills/skill-creator",
|
|
1197
1162
|
}, 200, _req);
|
|
1198
1163
|
});
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
router.post("/api/skills/generate", async (req, res) => {
|
|
1202
|
-
const root = getRoot();
|
|
1203
|
-
const body = (await readBody(req));
|
|
1204
|
-
if (!body.prompt || !body.prompt.trim())
|
|
1205
|
-
return sendJson(res, { error: "Describe what your skill should do" }, 400, req);
|
|
1206
|
-
if (body.prompt.length > 50000)
|
|
1207
|
-
return sendJson(res, { error: "Prompt is too long (max 50,000 characters)" }, 400, req);
|
|
1208
|
-
const resolved = await resolveProviderModel(body.provider, body.model);
|
|
1209
|
-
if (!resolved.ok) {
|
|
1210
|
-
const payload = { error: resolved.error };
|
|
1211
|
-
if (resolved.validProviders)
|
|
1212
|
-
payload.validProviders = resolved.validProviders;
|
|
1213
|
-
if (resolved.validModels)
|
|
1214
|
-
payload.validModels = resolved.validModels;
|
|
1215
|
-
return sendJson(res, payload, 400, req);
|
|
1216
|
-
}
|
|
1217
|
-
const wantsSSE = req.headers.accept?.includes("text/event-stream") ||
|
|
1218
|
-
(req.url ? new URL(req.url, "http://localhost").searchParams.has("sse") : false);
|
|
1219
|
-
const ac = new AbortController();
|
|
1220
|
-
res.on("close", () => ac.abort());
|
|
1221
|
-
if (wantsSSE)
|
|
1222
|
-
initSSE(res, req);
|
|
1223
|
-
try {
|
|
1224
|
-
const parsed = await generateSkill({ ...body, provider: resolved.provider, model: resolved.model }, {
|
|
1225
|
-
root,
|
|
1226
|
-
abortSignal: ac.signal,
|
|
1227
|
-
onProgress: wantsSSE ? (e) => { if (!ac.signal.aborted)
|
|
1228
|
-
sendSSE(res, "progress", e); } : undefined,
|
|
1229
|
-
});
|
|
1230
|
-
if (ac.signal.aborted)
|
|
1231
|
-
return;
|
|
1232
|
-
const result = attachSuggestedPlugin(parsed, root);
|
|
1233
|
-
// 0711: emit provenance as a SEPARATE SSE event before `done` so the
|
|
1234
|
-
// GenerateSkillResult schema stays clean (parity tests assert on the
|
|
1235
|
-
// legacy shape). The UI's useCreateSkill listens for the `provenance`
|
|
1236
|
-
// event and stamps aiMeta. Best-effort — never blocks generation.
|
|
1237
|
-
if (wantsSSE && (resolved.provider === "anthropic" || resolved.provider === "claude-cli")) {
|
|
1238
|
-
try {
|
|
1239
|
-
const { resolveAnthropicModel } = await import("../eval/model-resolver.js");
|
|
1240
|
-
const r = resolveAnthropicModel(resolved.model);
|
|
1241
|
-
sendSSE(res, "provenance", {
|
|
1242
|
-
resolvedModelId: r.resolvedId || null,
|
|
1243
|
-
snapshotDate: r.snapshotDate,
|
|
1244
|
-
source: r.source,
|
|
1245
|
-
});
|
|
1246
|
-
}
|
|
1247
|
-
catch {
|
|
1248
|
-
/* provenance is best-effort; never block generation */
|
|
1249
|
-
}
|
|
1250
|
-
}
|
|
1251
|
-
if (wantsSSE)
|
|
1252
|
-
sendSSEDone(res, result);
|
|
1253
|
-
else
|
|
1254
|
-
sendJson(res, result, 200, req);
|
|
1255
|
-
}
|
|
1256
|
-
catch (err) {
|
|
1257
|
-
if (wantsSSE && !ac.signal.aborted) {
|
|
1258
|
-
sendSSE(res, "error", classifyError(err, resolved.provider));
|
|
1259
|
-
res.end();
|
|
1260
|
-
}
|
|
1261
|
-
else {
|
|
1262
|
-
const msg = err.message;
|
|
1263
|
-
sendJson(res, { error: msg }, msg.includes("not valid JSON") ? 422 : 500, req);
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
});
|
|
1164
|
+
registerSkillGenerateRoute(router, getRoot);
|
|
1165
|
+
registerSkillAuthoringRoute(router, getRoot);
|
|
1267
1166
|
}
|
|
1268
1167
|
//# sourceMappingURL=skill-create-routes.js.map
|