@lore-co/core 0.2.14 → 0.2.15
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/builtin-skills.d.ts +3 -0
- package/dist/builtin-skills.d.ts.map +1 -0
- package/dist/builtin-skills.js +4 -0
- package/dist/builtin-skills.js.map +1 -0
- package/dist/engine.d.ts +6 -1
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +44 -11
- package/dist/engine.js.map +1 -1
- package/dist/guard-evaluation.d.ts +22 -1
- package/dist/guard-evaluation.d.ts.map +1 -1
- package/dist/guard-evaluation.js +159 -4
- package/dist/guard-evaluation.js.map +1 -1
- package/dist/guard-schemas.d.ts +45 -12
- package/dist/guard-schemas.d.ts.map +1 -1
- package/dist/guard-schemas.js +3 -1
- package/dist/guard-schemas.js.map +1 -1
- package/dist/in-memory-repository.d.ts.map +1 -1
- package/dist/in-memory-repository.js +3 -1
- package/dist/in-memory-repository.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/injected-context.d.ts +2 -0
- package/dist/injected-context.d.ts.map +1 -1
- package/dist/injected-context.js +4 -0
- package/dist/injected-context.js.map +1 -1
- package/dist/integration-contract.d.ts +16 -16
- package/dist/knowledge-quality.d.ts.map +1 -1
- package/dist/knowledge-quality.js +3 -0
- package/dist/knowledge-quality.js.map +1 -1
- package/dist/learning-drafts.d.ts +8 -0
- package/dist/learning-drafts.d.ts.map +1 -1
- package/dist/learning-drafts.js +1 -0
- package/dist/learning-drafts.js.map +1 -1
- package/dist/pilot-schemas.d.ts +196 -0
- package/dist/pilot-schemas.d.ts.map +1 -1
- package/dist/pilot-schemas.js +7 -0
- package/dist/pilot-schemas.js.map +1 -1
- package/dist/prepared-context.d.ts +1 -0
- package/dist/prepared-context.d.ts.map +1 -1
- package/dist/prepared-context.js +7 -2
- package/dist/prepared-context.js.map +1 -1
- package/dist/product-usage.d.ts +2 -2
- package/dist/reliability-schemas.d.ts +3 -3
- package/dist/repository-location.d.ts +2 -0
- package/dist/repository-location.d.ts.map +1 -1
- package/dist/repository-location.js +76 -0
- package/dist/repository-location.js.map +1 -1
- package/dist/schemas.d.ts +592 -0
- package/dist/schemas.d.ts.map +1 -1
- package/dist/schemas.js +9 -0
- package/dist/schemas.js.map +1 -1
- package/dist/session-purpose.d.ts +2 -0
- package/dist/session-purpose.d.ts.map +1 -1
- package/dist/session-purpose.js +12 -0
- package/dist/session-purpose.js.map +1 -1
- package/dist/session-schemas.d.ts +83 -12
- package/dist/session-schemas.d.ts.map +1 -1
- package/dist/session-schemas.js +5 -0
- package/dist/session-schemas.js.map +1 -1
- package/dist/skill-context.d.ts +7 -0
- package/dist/skill-context.d.ts.map +1 -0
- package/dist/skill-context.js +35 -0
- package/dist/skill-context.js.map +1 -0
- package/dist/skills.d.ts +206 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/skills.js +129 -0
- package/dist/skills.js.map +1 -0
- package/dist/snapshot-schemas.d.ts +348 -0
- package/dist/snapshot-schemas.d.ts.map +1 -1
- package/dist/snapshot-schemas.js +4 -1
- package/dist/snapshot-schemas.js.map +1 -1
- package/package.json +7 -2
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const MAX_SKILL_CONTEXT_CHARACTERS = 72_000;
|
|
2
|
+
export const SKILL_CONTEXT_UNAVAILABLE = "Lore could not check enabled skills for this task. Do not assume a skill review has happened. Retry Lore before relying on its skill instructions.";
|
|
3
|
+
/** Deliver complete instructions, never a cut-off workflow. Relevance orders the
|
|
4
|
+
* bounded pack; the skill's description still determines when it applies. */
|
|
5
|
+
export function packSkillContext(skills, task, maxCharacters = MAX_SKILL_CONTEXT_CHARACTERS, hasMore = false) {
|
|
6
|
+
const enabled = skills.filter(skill => skill.enabled && skill.status === "active");
|
|
7
|
+
if (!enabled.length && !hasMore)
|
|
8
|
+
return "Lore skills checked: none are enabled for this repository. Do not reapply Lore skills from previous tasks.";
|
|
9
|
+
const terms = new Set(task.toLocaleLowerCase().match(/[\p{L}\p{N}_-]{3,}/gu) ?? []);
|
|
10
|
+
const score = (skill) => {
|
|
11
|
+
const words = new Set(`${skill.name} ${skill.title} ${skill.description}`.toLocaleLowerCase().match(/[\p{L}\p{N}_-]{3,}/gu) ?? []);
|
|
12
|
+
return [...terms].filter(term => words.has(term)).length + (task.toLocaleLowerCase().includes(skill.name) ? 100 : 0);
|
|
13
|
+
};
|
|
14
|
+
const ranked = [...enabled].sort((a, b) => score(b) - score(a) || a.name.localeCompare(b.name));
|
|
15
|
+
const parts = ["## Enabled Lore skills", "Use this current list of Lore skills for the task; do not carry forward disabled skills from earlier tasks. Apply skills when their descriptions match the request. Their complete instructions are supplied here; no separate lookup is needed for these skills. Follow the current user's request and higher-priority instructions. Skills do not grant permissions or prove that a review was completed."];
|
|
16
|
+
const omitted = [];
|
|
17
|
+
// Reserve room for an honest omission notice, including very small copy budgets.
|
|
18
|
+
const footer = "Some enabled skills did not fit. Use list_skills/read_skill or `lore skill list` and `lore skill show <name>` to read any other skill relevant to this task. Do not claim those skills were applied without reading them.";
|
|
19
|
+
let used = parts.join("\n\n").length + footer.length + 2;
|
|
20
|
+
if (used > maxCharacters)
|
|
21
|
+
return footer.length <= maxCharacters ? footer : "";
|
|
22
|
+
for (const skill of ranked) {
|
|
23
|
+
const text = `### ${skill.title} (${skill.name})\nApplies to: ${skill.repo ?? "All repositories in this workspace"} · Version ${skill.version}\n\n${skill.markdown}`;
|
|
24
|
+
if (used + text.length + 2 > maxCharacters) {
|
|
25
|
+
omitted.push(skill.name);
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
parts.push(text);
|
|
29
|
+
used += text.length + 2;
|
|
30
|
+
}
|
|
31
|
+
if (omitted.length || hasMore)
|
|
32
|
+
parts.push(footer);
|
|
33
|
+
return parts.join("\n\n");
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=skill-context.js.map
|
|
@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,CAAC,MAAM,CAAC,CAAC;AAC5B,CAAC"}
|
package/dist/skills.d.ts
ADDED
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const MAX_SKILL_BYTES: number;
|
|
3
|
+
export declare const SkillNameSchema: z.ZodString;
|
|
4
|
+
export declare const SkillRepositorySchema: z.ZodString;
|
|
5
|
+
export declare const SkillAppliesToSchema: z.ZodNullable<z.ZodString>;
|
|
6
|
+
export declare const SkillMarkdownSchema: z.ZodString;
|
|
7
|
+
export declare const SkillSourceSchema: z.ZodObject<{
|
|
8
|
+
kind: z.ZodEnum<{
|
|
9
|
+
file: "file";
|
|
10
|
+
builtin: "builtin";
|
|
11
|
+
github: "github";
|
|
12
|
+
folder: "folder";
|
|
13
|
+
}>;
|
|
14
|
+
reference: z.ZodString;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
export declare const ImportedSkillSourceSchema: z.ZodObject<{
|
|
17
|
+
reference: z.ZodString;
|
|
18
|
+
kind: z.ZodEnum<{
|
|
19
|
+
file: "file";
|
|
20
|
+
github: "github";
|
|
21
|
+
folder: "folder";
|
|
22
|
+
}>;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
export declare const SkillDocumentSchema: z.ZodObject<{
|
|
25
|
+
name: z.ZodString;
|
|
26
|
+
title: z.ZodString;
|
|
27
|
+
description: z.ZodString;
|
|
28
|
+
markdown: z.ZodString;
|
|
29
|
+
}, z.core.$strict>;
|
|
30
|
+
export type SkillDocument = z.infer<typeof SkillDocumentSchema>;
|
|
31
|
+
export type SkillSource = z.infer<typeof SkillSourceSchema>;
|
|
32
|
+
/** Preserve the original document. Metadata describes a skill; it never grants permissions. */
|
|
33
|
+
export declare function parseSkillMarkdown(markdown: string): SkillDocument;
|
|
34
|
+
export declare const SkillSummarySchema: z.ZodObject<{
|
|
35
|
+
name: z.ZodString;
|
|
36
|
+
description: z.ZodString;
|
|
37
|
+
title: z.ZodString;
|
|
38
|
+
repo: z.ZodNullable<z.ZodString>;
|
|
39
|
+
source: z.ZodObject<{
|
|
40
|
+
kind: z.ZodEnum<{
|
|
41
|
+
file: "file";
|
|
42
|
+
builtin: "builtin";
|
|
43
|
+
github: "github";
|
|
44
|
+
folder: "folder";
|
|
45
|
+
}>;
|
|
46
|
+
reference: z.ZodString;
|
|
47
|
+
}, z.core.$strict>;
|
|
48
|
+
status: z.ZodEnum<{
|
|
49
|
+
proposed: "proposed";
|
|
50
|
+
active: "active";
|
|
51
|
+
}>;
|
|
52
|
+
enabled: z.ZodBoolean;
|
|
53
|
+
version: z.ZodNumber;
|
|
54
|
+
digest: z.ZodString;
|
|
55
|
+
authorId: z.ZodNullable<z.ZodUUID>;
|
|
56
|
+
updatedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
57
|
+
}, z.core.$strict>;
|
|
58
|
+
export declare const SkillSchema: z.ZodObject<{
|
|
59
|
+
name: z.ZodString;
|
|
60
|
+
description: z.ZodString;
|
|
61
|
+
title: z.ZodString;
|
|
62
|
+
repo: z.ZodNullable<z.ZodString>;
|
|
63
|
+
source: z.ZodObject<{
|
|
64
|
+
kind: z.ZodEnum<{
|
|
65
|
+
file: "file";
|
|
66
|
+
builtin: "builtin";
|
|
67
|
+
github: "github";
|
|
68
|
+
folder: "folder";
|
|
69
|
+
}>;
|
|
70
|
+
reference: z.ZodString;
|
|
71
|
+
}, z.core.$strict>;
|
|
72
|
+
status: z.ZodEnum<{
|
|
73
|
+
proposed: "proposed";
|
|
74
|
+
active: "active";
|
|
75
|
+
}>;
|
|
76
|
+
enabled: z.ZodBoolean;
|
|
77
|
+
version: z.ZodNumber;
|
|
78
|
+
digest: z.ZodString;
|
|
79
|
+
authorId: z.ZodNullable<z.ZodUUID>;
|
|
80
|
+
updatedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
81
|
+
markdown: z.ZodString;
|
|
82
|
+
}, z.core.$strict>;
|
|
83
|
+
export type Skill = z.infer<typeof SkillSchema>;
|
|
84
|
+
export type SkillSummary = z.infer<typeof SkillSummarySchema>;
|
|
85
|
+
export declare const SkillResponseSchema: z.ZodObject<{
|
|
86
|
+
skill: z.ZodObject<{
|
|
87
|
+
name: z.ZodString;
|
|
88
|
+
description: z.ZodString;
|
|
89
|
+
title: z.ZodString;
|
|
90
|
+
repo: z.ZodNullable<z.ZodString>;
|
|
91
|
+
source: z.ZodObject<{
|
|
92
|
+
kind: z.ZodEnum<{
|
|
93
|
+
file: "file";
|
|
94
|
+
builtin: "builtin";
|
|
95
|
+
github: "github";
|
|
96
|
+
folder: "folder";
|
|
97
|
+
}>;
|
|
98
|
+
reference: z.ZodString;
|
|
99
|
+
}, z.core.$strict>;
|
|
100
|
+
status: z.ZodEnum<{
|
|
101
|
+
proposed: "proposed";
|
|
102
|
+
active: "active";
|
|
103
|
+
}>;
|
|
104
|
+
enabled: z.ZodBoolean;
|
|
105
|
+
version: z.ZodNumber;
|
|
106
|
+
digest: z.ZodString;
|
|
107
|
+
authorId: z.ZodNullable<z.ZodUUID>;
|
|
108
|
+
updatedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
109
|
+
markdown: z.ZodString;
|
|
110
|
+
}, z.core.$strict>;
|
|
111
|
+
}, z.core.$strict>;
|
|
112
|
+
export declare const ListSkillsSchema: z.ZodObject<{
|
|
113
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
114
|
+
enabledOnly: z.ZodOptional<z.ZodEnum<{
|
|
115
|
+
true: "true";
|
|
116
|
+
false: "false";
|
|
117
|
+
}>>;
|
|
118
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
119
|
+
offset: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
120
|
+
}, z.core.$strict>;
|
|
121
|
+
export declare const ListSkillsResponseSchema: z.ZodObject<{
|
|
122
|
+
skills: z.ZodArray<z.ZodObject<{
|
|
123
|
+
name: z.ZodString;
|
|
124
|
+
description: z.ZodString;
|
|
125
|
+
title: z.ZodString;
|
|
126
|
+
repo: z.ZodNullable<z.ZodString>;
|
|
127
|
+
source: z.ZodObject<{
|
|
128
|
+
kind: z.ZodEnum<{
|
|
129
|
+
file: "file";
|
|
130
|
+
builtin: "builtin";
|
|
131
|
+
github: "github";
|
|
132
|
+
folder: "folder";
|
|
133
|
+
}>;
|
|
134
|
+
reference: z.ZodString;
|
|
135
|
+
}, z.core.$strict>;
|
|
136
|
+
status: z.ZodEnum<{
|
|
137
|
+
proposed: "proposed";
|
|
138
|
+
active: "active";
|
|
139
|
+
}>;
|
|
140
|
+
enabled: z.ZodBoolean;
|
|
141
|
+
version: z.ZodNumber;
|
|
142
|
+
digest: z.ZodString;
|
|
143
|
+
authorId: z.ZodNullable<z.ZodUUID>;
|
|
144
|
+
updatedAt: z.ZodNullable<z.ZodISODateTime>;
|
|
145
|
+
}, z.core.$strict>>;
|
|
146
|
+
total: z.ZodNumber;
|
|
147
|
+
canManage: z.ZodBoolean;
|
|
148
|
+
canManageWorkspace: z.ZodBoolean;
|
|
149
|
+
}, z.core.$strict>;
|
|
150
|
+
export declare const PreviewSkillSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
151
|
+
url: z.ZodURL;
|
|
152
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
153
|
+
markdown: z.ZodString;
|
|
154
|
+
source: z.ZodObject<{
|
|
155
|
+
reference: z.ZodString;
|
|
156
|
+
kind: z.ZodEnum<{
|
|
157
|
+
file: "file";
|
|
158
|
+
github: "github";
|
|
159
|
+
folder: "folder";
|
|
160
|
+
}>;
|
|
161
|
+
}, z.core.$strict>;
|
|
162
|
+
}, z.core.$strict>]>;
|
|
163
|
+
export declare const PreviewSkillResponseSchema: z.ZodObject<{
|
|
164
|
+
document: z.ZodObject<{
|
|
165
|
+
name: z.ZodString;
|
|
166
|
+
title: z.ZodString;
|
|
167
|
+
description: z.ZodString;
|
|
168
|
+
markdown: z.ZodString;
|
|
169
|
+
}, z.core.$strict>;
|
|
170
|
+
source: z.ZodObject<{
|
|
171
|
+
kind: z.ZodEnum<{
|
|
172
|
+
file: "file";
|
|
173
|
+
builtin: "builtin";
|
|
174
|
+
github: "github";
|
|
175
|
+
folder: "folder";
|
|
176
|
+
}>;
|
|
177
|
+
reference: z.ZodString;
|
|
178
|
+
}, z.core.$strict>;
|
|
179
|
+
digest: z.ZodString;
|
|
180
|
+
}, z.core.$strict>;
|
|
181
|
+
export declare const ImportSkillSchema: z.ZodObject<{
|
|
182
|
+
repo: z.ZodNullable<z.ZodString>;
|
|
183
|
+
markdown: z.ZodString;
|
|
184
|
+
source: z.ZodObject<{
|
|
185
|
+
reference: z.ZodString;
|
|
186
|
+
kind: z.ZodEnum<{
|
|
187
|
+
file: "file";
|
|
188
|
+
github: "github";
|
|
189
|
+
folder: "folder";
|
|
190
|
+
}>;
|
|
191
|
+
}, z.core.$strict>;
|
|
192
|
+
digest: z.ZodString;
|
|
193
|
+
}, z.core.$strict>;
|
|
194
|
+
export declare const SetSkillEnabledSchema: z.ZodObject<{
|
|
195
|
+
repo: z.ZodNullable<z.ZodString>;
|
|
196
|
+
enabled: z.ZodBoolean;
|
|
197
|
+
expectedVersion: z.ZodNumber;
|
|
198
|
+
}, z.core.$strict>;
|
|
199
|
+
export declare const SkillScopeSchema: z.ZodObject<{
|
|
200
|
+
repo: z.ZodOptional<z.ZodString>;
|
|
201
|
+
}, z.core.$strict>;
|
|
202
|
+
export declare const SkillParamsSchema: z.ZodObject<{
|
|
203
|
+
name: z.ZodString;
|
|
204
|
+
}, z.core.$strict>;
|
|
205
|
+
export declare function skillSummary(skill: Skill): SkillSummary;
|
|
206
|
+
//# sourceMappingURL=skills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../src/skills.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,eAAe,QAAY,CAAC;AACzC,eAAO,MAAM,eAAe,aAGW,CAAC;AACxC,eAAO,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AAC;AACZ,eAAO,MAAM,iBAAiB;;kBAA+C,CAAC;AAE9E,wBAAgB,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,YAAY,CAGvD"}
|
package/dist/skills.js
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { parseDocument } from "yaml";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export const MAX_SKILL_BYTES = 64 * 1024;
|
|
4
|
+
export const SkillNameSchema = z
|
|
5
|
+
.string()
|
|
6
|
+
.max(64)
|
|
7
|
+
.regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/u);
|
|
8
|
+
export const SkillRepositorySchema = z.string().trim().min(1).max(500);
|
|
9
|
+
// null is an explicit workspace-wide scope, never a wildcard repository name.
|
|
10
|
+
export const SkillAppliesToSchema = SkillRepositorySchema.nullable();
|
|
11
|
+
export const SkillMarkdownSchema = z
|
|
12
|
+
.string()
|
|
13
|
+
.min(1)
|
|
14
|
+
.max(MAX_SKILL_BYTES)
|
|
15
|
+
.refine((value) => new TextEncoder().encode(value).length <= MAX_SKILL_BYTES, "Keep SKILL.md under 64 KB.");
|
|
16
|
+
export const SkillSourceSchema = z
|
|
17
|
+
.object({
|
|
18
|
+
kind: z.enum(["builtin", "github", "file", "folder"]),
|
|
19
|
+
reference: z.string().min(1).max(2000),
|
|
20
|
+
})
|
|
21
|
+
.strict();
|
|
22
|
+
export const ImportedSkillSourceSchema = SkillSourceSchema.extend({
|
|
23
|
+
kind: z.enum(["github", "file", "folder"]),
|
|
24
|
+
});
|
|
25
|
+
export const SkillDocumentSchema = z
|
|
26
|
+
.object({
|
|
27
|
+
name: SkillNameSchema,
|
|
28
|
+
title: z.string().min(1).max(120),
|
|
29
|
+
description: z.string().min(1).max(1024),
|
|
30
|
+
markdown: SkillMarkdownSchema,
|
|
31
|
+
})
|
|
32
|
+
.strict();
|
|
33
|
+
/** Preserve the original document. Metadata describes a skill; it never grants permissions. */
|
|
34
|
+
export function parseSkillMarkdown(markdown) {
|
|
35
|
+
SkillMarkdownSchema.parse(markdown);
|
|
36
|
+
const match = /^\uFEFF?---\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)([\s\S]*)$/u.exec(markdown);
|
|
37
|
+
if (!match || !match[2]?.trim())
|
|
38
|
+
throw new Error("Use a SKILL.md file with name, description, and instructions.");
|
|
39
|
+
const document = parseDocument(match[1], { uniqueKeys: true });
|
|
40
|
+
if (document.errors.length)
|
|
41
|
+
throw new Error("The skill’s YAML header is invalid.");
|
|
42
|
+
const metadata = z
|
|
43
|
+
.object({
|
|
44
|
+
name: SkillNameSchema,
|
|
45
|
+
description: z.string().trim().min(1).max(1024),
|
|
46
|
+
})
|
|
47
|
+
.parse(document.toJS({ maxAliasCount: 0 }));
|
|
48
|
+
const heading = /^#\s+(.+)$/mu
|
|
49
|
+
.exec(match[2])?.[1]
|
|
50
|
+
?.trim()
|
|
51
|
+
.replace(/\s+#+$/u, "");
|
|
52
|
+
return SkillDocumentSchema.parse({
|
|
53
|
+
...metadata,
|
|
54
|
+
title: (heading || metadata.name.replaceAll("-", " ")).slice(0, 120),
|
|
55
|
+
markdown,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
export const SkillSummarySchema = SkillDocumentSchema.omit({ markdown: true })
|
|
59
|
+
.extend({
|
|
60
|
+
repo: SkillAppliesToSchema,
|
|
61
|
+
source: SkillSourceSchema,
|
|
62
|
+
status: z.enum(["active", "proposed"]),
|
|
63
|
+
enabled: z.boolean(),
|
|
64
|
+
version: z.number().int().nonnegative(),
|
|
65
|
+
digest: z.string().regex(/^[a-f0-9]{64}$/u),
|
|
66
|
+
authorId: z.uuid().nullable(),
|
|
67
|
+
updatedAt: z.iso.datetime({ offset: true }).nullable(),
|
|
68
|
+
})
|
|
69
|
+
.strict();
|
|
70
|
+
export const SkillSchema = SkillSummarySchema.extend({
|
|
71
|
+
markdown: SkillMarkdownSchema,
|
|
72
|
+
});
|
|
73
|
+
export const SkillResponseSchema = z.object({ skill: SkillSchema }).strict();
|
|
74
|
+
export const ListSkillsSchema = z
|
|
75
|
+
.object({
|
|
76
|
+
repo: SkillRepositorySchema.optional(),
|
|
77
|
+
enabledOnly: z.enum(["true", "false"]).optional(),
|
|
78
|
+
limit: z.coerce.number().int().min(1).max(50).default(20),
|
|
79
|
+
offset: z.coerce.number().int().min(0).default(0),
|
|
80
|
+
})
|
|
81
|
+
.strict();
|
|
82
|
+
export const ListSkillsResponseSchema = z
|
|
83
|
+
.object({
|
|
84
|
+
skills: z.array(SkillSummarySchema),
|
|
85
|
+
total: z.number().int().nonnegative(),
|
|
86
|
+
canManage: z.boolean(),
|
|
87
|
+
canManageWorkspace: z.boolean(),
|
|
88
|
+
})
|
|
89
|
+
.strict();
|
|
90
|
+
export const PreviewSkillSchema = z.union([
|
|
91
|
+
z.object({ url: z.url().max(2000) }).strict(),
|
|
92
|
+
z
|
|
93
|
+
.object({
|
|
94
|
+
markdown: SkillMarkdownSchema,
|
|
95
|
+
source: ImportedSkillSourceSchema.refine((source) => source.kind !== "github", "Use a GitHub link to import from GitHub."),
|
|
96
|
+
})
|
|
97
|
+
.strict(),
|
|
98
|
+
]);
|
|
99
|
+
export const PreviewSkillResponseSchema = z
|
|
100
|
+
.object({
|
|
101
|
+
document: SkillDocumentSchema,
|
|
102
|
+
source: SkillSourceSchema,
|
|
103
|
+
digest: z.string().regex(/^[a-f0-9]{64}$/u),
|
|
104
|
+
})
|
|
105
|
+
.strict();
|
|
106
|
+
export const ImportSkillSchema = z
|
|
107
|
+
.object({
|
|
108
|
+
repo: SkillAppliesToSchema,
|
|
109
|
+
markdown: SkillMarkdownSchema,
|
|
110
|
+
source: ImportedSkillSourceSchema,
|
|
111
|
+
digest: z.string().regex(/^[a-f0-9]{64}$/u),
|
|
112
|
+
})
|
|
113
|
+
.strict();
|
|
114
|
+
export const SetSkillEnabledSchema = z
|
|
115
|
+
.object({
|
|
116
|
+
repo: SkillAppliesToSchema,
|
|
117
|
+
enabled: z.boolean(),
|
|
118
|
+
expectedVersion: z.number().int().nonnegative(),
|
|
119
|
+
})
|
|
120
|
+
.strict();
|
|
121
|
+
export const SkillScopeSchema = z
|
|
122
|
+
.object({ repo: SkillRepositorySchema.optional() })
|
|
123
|
+
.strict();
|
|
124
|
+
export const SkillParamsSchema = z.object({ name: SkillNameSchema }).strict();
|
|
125
|
+
export function skillSummary(skill) {
|
|
126
|
+
const { markdown: _markdown, ...summary } = skill;
|
|
127
|
+
return summary;
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=skills.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.js","sourceRoot":"","sources":["../src/skills.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACrC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,GAAG,IAAI,CAAC;AACzC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC;KAC7B,MAAM,EAAE;KACR,GAAG,CAAC,EAAE,CAAC;KACP,KAAK,CAAC,6BAA6B,CAAC,CAAC;AACxC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACvE,8EAA8E;AAC9E,MAAM,CAAC,MAAM,oBAAoB,GAAG,qBAAqB,CAAC,QAAQ,EAAE,CAAC;AACrE,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC;KACjC,MAAM,EAAE;KACR,GAAG,CAAC,CAAC,CAAC;KACN,GAAG,CAAC,eAAe,CAAC;KACpB,MAAM,CACL,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,IAAI,eAAe,EACpE,4BAA4B,CAC7B,CAAC;AACJ,MAAM,CAAC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