@vvedantb/server 0.18.0 → 0.20.1
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/CHANGELOG.md +18 -0
- package/dist/ai/errors.d.ts +0 -2
- package/dist/ai/errors.js +0 -16
- package/dist/ai/serviceTier.d.ts +0 -4
- package/dist/ai/serviceTier.js +0 -4
- package/dist/artifacts/document.d.ts +0 -2
- package/dist/artifacts/document.js +0 -1
- package/dist/artifacts/protocol.d.ts +0 -5
- package/dist/artifacts/schemas.d.ts +0 -6
- package/dist/artifacts/storageShim.js +0 -2
- package/dist/convex/authFunctions.d.ts +0 -57
- package/dist/convex/clerkBilling.d.ts +2 -18
- package/dist/convex/clerkBilling.js +0 -9
- package/dist/convex/clerkBillingFunctions.d.ts +0 -35
- package/dist/convex/clerkBillingFunctions.js +0 -8
- package/dist/convex/clerkBillingNodeFunctions.d.ts +0 -29
- package/dist/convex/clerkBillingNodeFunctions.js +0 -1
- package/dist/convex/clerkUserAuth.d.ts +0 -18
- package/dist/convex/clerkUserAuth.js +0 -14
- package/dist/convex/clerkWebhook.d.ts +0 -2
- package/dist/convex/convexAdminClient.d.ts +0 -30
- package/dist/convex/convexAdminClient.js +0 -34
- package/dist/convex/convexQueryLimits.d.ts +0 -8
- package/dist/convex/convexQueryLimits.js +0 -8
- package/dist/convex/createMcpAuthActions.d.ts +0 -31
- package/dist/convex/expoPush.d.ts +0 -24
- package/dist/convex/expoPush.js +0 -4
- package/dist/convex/homepageRoutes.d.ts +42 -0
- package/dist/convex/homepageRoutes.js +46 -0
- package/dist/convex/index.d.ts +2 -0
- package/dist/convex/index.js +2 -0
- package/dist/convex/mcpServerInfo.d.ts +0 -2
- package/dist/convex/mcpTokenCache.d.ts +0 -17
- package/dist/convex/mcpTokenCache.js +0 -2
- package/dist/convex/memoryStore.js +0 -6
- package/dist/convex/originAllowlistCors.d.ts +0 -8
- package/dist/convex/productEmails.d.ts +22 -0
- package/dist/convex/productEmails.js +37 -0
- package/dist/convex/tempId.js +0 -2
- package/dist/convex/vPlan.d.ts +0 -4
- package/dist/convex/vProModule.d.ts +0 -27
- package/dist/convex/vProModule.js +0 -11
- package/dist/convex/verifyClerkAccessToken.d.ts +3 -13
- package/dist/convex/verifyClerkOAuthJwt.d.ts +0 -18
- package/dist/convex/verifyClerkOAuthJwt.js +0 -6
- package/dist/crypto/aesGcm.d.ts +0 -2
- package/dist/crypto/aesGcm.js +0 -2
- package/dist/crypto/encoding.d.ts +0 -8
- package/dist/crypto/encoding.js +0 -3
- package/dist/generative-ui/catalog.d.ts +0 -17
- package/dist/generative-ui/catalog.js +0 -18
- package/dist/generative-ui/spec.d.ts +0 -8
- package/dist/generative-ui/spec.js +0 -12
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/mcp/dispatcher.d.ts +0 -7
- package/dist/mcp/dispatcher.js +0 -1
- package/dist/mcp/explorer.d.ts +0 -21
- package/dist/mcp/http.d.ts +3 -30
- package/dist/mcp/http.js +14 -0
- package/dist/mcp/index.d.ts +2 -1
- package/dist/mcp/index.js +2 -1
- package/dist/mcp/json.d.ts +0 -1
- package/dist/mcp/jsonRpc.d.ts +0 -2
- package/dist/mcp/metadata.d.ts +0 -15
- package/dist/mcp/routes.d.ts +2 -12
- package/dist/mcp/routes.js +6 -2
- package/dist/mcp/sdk.d.ts +0 -12
- package/dist/mcp/tools.d.ts +0 -18
- package/dist/mcp/tools.js +0 -1
- package/dist/mcp/zodJsonSchema.d.ts +14 -0
- package/dist/mcp/zodJsonSchema.js +98 -0
- package/dist/mcp-oauth-client/loopback.d.ts +0 -5
- package/dist/mcp-oauth-client/loopback.js +0 -6
- package/dist/mcp-oauth-client/oauth.d.ts +0 -14
- package/dist/mcp-oauth-client/oauth.js +0 -16
- package/dist/mcp-oauth-client/state.d.ts +0 -3
- package/dist/sandbox/runtime.d.ts +0 -15
- package/dist/sandbox/runtime.js +0 -25
- package/dist/skills/githubSkills.d.ts +51 -0
- package/dist/skills/githubSkills.js +172 -0
- package/dist/skills/index.d.ts +2 -0
- package/dist/skills/index.js +2 -0
- package/dist/skills/skillRef.d.ts +18 -0
- package/dist/skills/skillRef.js +168 -0
- package/package.json +1 -1
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { bytesToBase64 } from "../crypto/encoding.js";
|
|
2
|
+
import { SKILL_FILE_NAME, discoverSkillFolders, hashSkillText, normalizeSkillText, parseSkillFrontmatter, skillFolderFiles, } from "./skillRef.js";
|
|
3
|
+
export const SKILL_MAX_FILES = 100;
|
|
4
|
+
export const SKILL_MAX_TEXT_BYTES = 256 * 1024;
|
|
5
|
+
export const SKILL_MAX_BINARY_BYTES = 2 * 1024 * 1024;
|
|
6
|
+
export const SKILL_MAX_TOTAL_BYTES = 4 * 1024 * 1024;
|
|
7
|
+
export const SKILL_CHOOSER_MAX = 25;
|
|
8
|
+
const GITHUB_API = "https://api.github.com";
|
|
9
|
+
function isRepoJson(data) {
|
|
10
|
+
return typeof data?.default_branch === "string";
|
|
11
|
+
}
|
|
12
|
+
function isCommitJson(data) {
|
|
13
|
+
return typeof data?.sha === "string";
|
|
14
|
+
}
|
|
15
|
+
function isTreeJson(data) {
|
|
16
|
+
return (Array.isArray(data?.tree) &&
|
|
17
|
+
data.tree.every((entry) => typeof entry.path === "string" &&
|
|
18
|
+
typeof entry.type === "string" &&
|
|
19
|
+
typeof entry.sha === "string"));
|
|
20
|
+
}
|
|
21
|
+
function isBlobJson(data) {
|
|
22
|
+
return typeof data?.content === "string" && typeof data.encoding === "string";
|
|
23
|
+
}
|
|
24
|
+
export class GithubSkillError extends Error {
|
|
25
|
+
}
|
|
26
|
+
async function githubJson(gh, url, isValid, what) {
|
|
27
|
+
const res = await gh(url);
|
|
28
|
+
if (res.status === 404 || res.status === 401 || res.status === 403) {
|
|
29
|
+
throw new GithubSkillError(`${what} not found, private or rate limited (GitHub ${res.status}). For a private repository, connect an authenticated GitHub account and use the MCP install tools.`);
|
|
30
|
+
}
|
|
31
|
+
if (!res.ok) {
|
|
32
|
+
throw new GithubSkillError(`${what} failed (GitHub ${res.status}).`);
|
|
33
|
+
}
|
|
34
|
+
const data = await res.json();
|
|
35
|
+
if (!isValid(data)) {
|
|
36
|
+
throw new GithubSkillError(`${what} returned an unexpected response.`);
|
|
37
|
+
}
|
|
38
|
+
return data;
|
|
39
|
+
}
|
|
40
|
+
function repoUrl(owner, repo, rest) {
|
|
41
|
+
return `${GITHUB_API}/repos/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}${rest}`;
|
|
42
|
+
}
|
|
43
|
+
export async function resolveGithubSkillRepo(gh, skillRef) {
|
|
44
|
+
const { owner, repo } = skillRef;
|
|
45
|
+
const ref = skillRef.ref ??
|
|
46
|
+
(await githubJson(gh, repoUrl(owner, repo, ""), isRepoJson, "Repository")).default_branch;
|
|
47
|
+
const commit = await githubJson(gh, repoUrl(owner, repo, `/commits/${encodeURIComponent(ref)}`), isCommitJson, "Commit");
|
|
48
|
+
const tree = await githubJson(gh, repoUrl(owner, repo, `/git/trees/${commit.sha}?recursive=1`), isTreeJson, "Repository tree");
|
|
49
|
+
if (tree.truncated === true) {
|
|
50
|
+
throw new GithubSkillError("Repository is too large to scan. Link to the skill folder or use a smaller repository.");
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
owner,
|
|
54
|
+
repo,
|
|
55
|
+
ref,
|
|
56
|
+
explicitRef: skillRef.ref !== undefined,
|
|
57
|
+
commitSha: commit.sha,
|
|
58
|
+
files: tree.tree
|
|
59
|
+
.filter((entry) => entry.type === "blob")
|
|
60
|
+
.map((entry) => ({
|
|
61
|
+
path: entry.path,
|
|
62
|
+
sha: entry.sha,
|
|
63
|
+
size: entry.size ?? 0,
|
|
64
|
+
})),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function baseName(path) {
|
|
68
|
+
return path.slice(path.lastIndexOf("/") + 1);
|
|
69
|
+
}
|
|
70
|
+
export function findSkillFolders(repo, skillRef) {
|
|
71
|
+
const folders = discoverSkillFolders(repo.files.map((file) => file.path), skillRef.path);
|
|
72
|
+
if (skillRef.skill === undefined)
|
|
73
|
+
return folders;
|
|
74
|
+
const wanted = skillRef.skill.toLowerCase();
|
|
75
|
+
return folders.filter((folder) => baseName(folder).toLowerCase() === wanted);
|
|
76
|
+
}
|
|
77
|
+
async function fetchBlobBytes(gh, repo, file) {
|
|
78
|
+
const blob = await githubJson(gh, repoUrl(repo.owner, repo.repo, `/git/blobs/${file.sha}`), isBlobJson, `File ${file.path}`);
|
|
79
|
+
if (blob.encoding !== "base64") {
|
|
80
|
+
throw new GithubSkillError(`File ${file.path} has an unknown encoding.`);
|
|
81
|
+
}
|
|
82
|
+
const binary = atob(blob.content.replace(/\s/g, ""));
|
|
83
|
+
const bytes = new Uint8Array(binary.length);
|
|
84
|
+
for (let i = 0; i < binary.length; i += 1)
|
|
85
|
+
bytes[i] = binary.charCodeAt(i);
|
|
86
|
+
return bytes;
|
|
87
|
+
}
|
|
88
|
+
function folderFilePath(folder, relative) {
|
|
89
|
+
return folder === "" ? relative : `${folder}/${relative}`;
|
|
90
|
+
}
|
|
91
|
+
function decodeText(bytes) {
|
|
92
|
+
if (bytes.includes(0))
|
|
93
|
+
return null;
|
|
94
|
+
try {
|
|
95
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
export async function readSkillCandidate(gh, repo, folder) {
|
|
102
|
+
const file = repo.files.find((entry) => entry.path === folderFilePath(folder, SKILL_FILE_NAME));
|
|
103
|
+
if (file === undefined) {
|
|
104
|
+
throw new GithubSkillError(`No ${SKILL_FILE_NAME} in ${folder}.`);
|
|
105
|
+
}
|
|
106
|
+
const bytes = await fetchBlobBytes(gh, repo, file);
|
|
107
|
+
const text = normalizeSkillText(new TextDecoder().decode(bytes));
|
|
108
|
+
const meta = parseSkillFrontmatter(text, baseName(folder) || repo.repo);
|
|
109
|
+
return { ...meta, path: folder, text };
|
|
110
|
+
}
|
|
111
|
+
export async function listSkillCandidates(gh, repo, folders) {
|
|
112
|
+
const out = [];
|
|
113
|
+
for (const folder of folders.slice(0, SKILL_CHOOSER_MAX)) {
|
|
114
|
+
const { name, path, description } = await readSkillCandidate(gh, repo, folder);
|
|
115
|
+
out.push({ name, path, description });
|
|
116
|
+
}
|
|
117
|
+
return out;
|
|
118
|
+
}
|
|
119
|
+
export async function readSkillBundle(gh, repo, folder) {
|
|
120
|
+
const candidate = await readSkillCandidate(gh, repo, folder);
|
|
121
|
+
const relatives = skillFolderFiles(repo.files.map((file) => file.path), folder).filter((relative) => relative !== SKILL_FILE_NAME);
|
|
122
|
+
if (relatives.length + 1 > SKILL_MAX_FILES) {
|
|
123
|
+
throw new GithubSkillError(`Skill has more than ${SKILL_MAX_FILES} files.`);
|
|
124
|
+
}
|
|
125
|
+
const files = [];
|
|
126
|
+
const skipped = [];
|
|
127
|
+
let total = new TextEncoder().encode(candidate.text).length;
|
|
128
|
+
for (const relative of relatives) {
|
|
129
|
+
const entry = repo.files.find((file) => file.path === folderFilePath(folder, relative));
|
|
130
|
+
if (entry === undefined)
|
|
131
|
+
continue;
|
|
132
|
+
if (entry.size > SKILL_MAX_BINARY_BYTES) {
|
|
133
|
+
skipped.push(relative);
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
const bytes = await fetchBlobBytes(gh, repo, entry);
|
|
137
|
+
const text = decodeText(bytes);
|
|
138
|
+
const limit = text === null ? SKILL_MAX_BINARY_BYTES : SKILL_MAX_TEXT_BYTES;
|
|
139
|
+
if (bytes.length > limit) {
|
|
140
|
+
skipped.push(relative);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
total += bytes.length;
|
|
144
|
+
if (total > SKILL_MAX_TOTAL_BYTES) {
|
|
145
|
+
throw new GithubSkillError("Skill files are larger than 4 MB in total.");
|
|
146
|
+
}
|
|
147
|
+
files.push(text === null
|
|
148
|
+
? {
|
|
149
|
+
path: relative,
|
|
150
|
+
kind: "binary",
|
|
151
|
+
base64: bytesToBase64(bytes),
|
|
152
|
+
size: bytes.length,
|
|
153
|
+
}
|
|
154
|
+
: { path: relative, kind: "text", text, size: bytes.length });
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
name: candidate.name,
|
|
158
|
+
description: candidate.description,
|
|
159
|
+
path: folder,
|
|
160
|
+
instructions: candidate.text,
|
|
161
|
+
contentHash: await hashSkillText(candidate.text),
|
|
162
|
+
files,
|
|
163
|
+
skipped,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
export async function fetchSkillContentHash(gh, repo, folder) {
|
|
167
|
+
const exists = repo.files.some((entry) => entry.path === folderFilePath(folder, SKILL_FILE_NAME));
|
|
168
|
+
if (!exists)
|
|
169
|
+
return null;
|
|
170
|
+
const { text } = await readSkillCandidate(gh, repo, folder);
|
|
171
|
+
return hashSkillText(text);
|
|
172
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { discoverSkillFolders, hashSkillText, normalizeSkillText, parseSkillFrontmatter, parseSkillRef, skillFolderFiles, SKILL_FILE_NAME, type SkillFrontmatter, type SkillRef, } from "./skillRef.js";
|
|
2
|
+
export { GithubSkillError, SKILL_CHOOSER_MAX, SKILL_MAX_BINARY_BYTES, SKILL_MAX_FILES, SKILL_MAX_TEXT_BYTES, SKILL_MAX_TOTAL_BYTES, fetchSkillContentHash, findSkillFolders, listSkillCandidates, readSkillBundle, readSkillCandidate, resolveGithubSkillRepo, type GithubFetch, type GithubSkillRepo, type GithubTreeFile, type SkillCandidate, type SkillBundle, type SkillBundleFile, } from "./githubSkills.js";
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { discoverSkillFolders, hashSkillText, normalizeSkillText, parseSkillFrontmatter, parseSkillRef, skillFolderFiles, SKILL_FILE_NAME, } from "./skillRef.js";
|
|
2
|
+
export { GithubSkillError, SKILL_CHOOSER_MAX, SKILL_MAX_BINARY_BYTES, SKILL_MAX_FILES, SKILL_MAX_TEXT_BYTES, SKILL_MAX_TOTAL_BYTES, fetchSkillContentHash, findSkillFolders, listSkillCandidates, readSkillBundle, readSkillCandidate, resolveGithubSkillRepo, } from "./githubSkills.js";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const SKILL_FILE_NAME = "SKILL.md";
|
|
2
|
+
export interface SkillRef {
|
|
3
|
+
owner: string;
|
|
4
|
+
repo: string;
|
|
5
|
+
ref?: string;
|
|
6
|
+
path?: string;
|
|
7
|
+
skill?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface SkillFrontmatter {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
}
|
|
13
|
+
export declare function parseSkillRef(input: string): SkillRef | null;
|
|
14
|
+
export declare function normalizeSkillText(text: string): string;
|
|
15
|
+
export declare function hashSkillText(text: string): Promise<string>;
|
|
16
|
+
export declare function parseSkillFrontmatter(text: string, folderName: string): SkillFrontmatter;
|
|
17
|
+
export declare function discoverSkillFolders(filePaths: string[], basePath: string | undefined): string[];
|
|
18
|
+
export declare function skillFolderFiles(filePaths: string[], folder: string): string[];
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { sha256Hex } from "../crypto/sha256.js";
|
|
2
|
+
export const SKILL_FILE_NAME = "SKILL.md";
|
|
3
|
+
const SKILL_ROOTS = ["skills", ".agents/skills", ".claude/skills"];
|
|
4
|
+
const SEGMENT = /^[A-Za-z0-9._-]+$/;
|
|
5
|
+
const SHORT_REF = /^([A-Za-z0-9._-]+)\/([A-Za-z0-9._-]+)(?:@(\S+))?$/;
|
|
6
|
+
function stripGitSuffix(repo) {
|
|
7
|
+
return repo.endsWith(".git") ? repo.slice(0, -4) : repo;
|
|
8
|
+
}
|
|
9
|
+
function cleanPath(segments) {
|
|
10
|
+
const joined = segments.filter((part) => part.length > 0).join("/");
|
|
11
|
+
return joined.length > 0 ? joined : undefined;
|
|
12
|
+
}
|
|
13
|
+
function withoutSkillFile(path) {
|
|
14
|
+
if (path === undefined)
|
|
15
|
+
return undefined;
|
|
16
|
+
const parts = path.split("/");
|
|
17
|
+
if (parts[parts.length - 1] === SKILL_FILE_NAME)
|
|
18
|
+
parts.pop();
|
|
19
|
+
return cleanPath(parts);
|
|
20
|
+
}
|
|
21
|
+
function parseGithubPath(owner, repo, rest) {
|
|
22
|
+
if (!SEGMENT.test(owner) || !SEGMENT.test(repo))
|
|
23
|
+
return null;
|
|
24
|
+
const base = { owner, repo: stripGitSuffix(repo) };
|
|
25
|
+
const [kind, ref, ...pathParts] = rest;
|
|
26
|
+
if (kind === undefined)
|
|
27
|
+
return base;
|
|
28
|
+
if ((kind !== "tree" && kind !== "blob") || ref === undefined)
|
|
29
|
+
return null;
|
|
30
|
+
const path = withoutSkillFile(cleanPath(pathParts));
|
|
31
|
+
return { ...base, ref: decodeURIComponent(ref), path };
|
|
32
|
+
}
|
|
33
|
+
export function parseSkillRef(input) {
|
|
34
|
+
const trimmed = input.trim();
|
|
35
|
+
if (trimmed.length === 0)
|
|
36
|
+
return null;
|
|
37
|
+
const short = SHORT_REF.exec(trimmed);
|
|
38
|
+
if (short !== null && !trimmed.includes("://")) {
|
|
39
|
+
const [, owner, repo, ref] = short;
|
|
40
|
+
if (owner === undefined || repo === undefined)
|
|
41
|
+
return null;
|
|
42
|
+
return { owner, repo: stripGitSuffix(repo), ref };
|
|
43
|
+
}
|
|
44
|
+
let url;
|
|
45
|
+
try {
|
|
46
|
+
url = new URL(trimmed);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
if (url.protocol !== "https:")
|
|
52
|
+
return null;
|
|
53
|
+
const host = url.hostname.toLowerCase();
|
|
54
|
+
const segments = url.pathname.split("/").filter((part) => part.length > 0);
|
|
55
|
+
const [owner, repo, ...rest] = segments;
|
|
56
|
+
if (owner === undefined || repo === undefined)
|
|
57
|
+
return null;
|
|
58
|
+
if (host === "github.com" || host === "www.github.com") {
|
|
59
|
+
return parseGithubPath(owner, repo, rest);
|
|
60
|
+
}
|
|
61
|
+
if (host === "skills.sh" || host === "www.skills.sh") {
|
|
62
|
+
if (!SEGMENT.test(owner) || !SEGMENT.test(repo))
|
|
63
|
+
return null;
|
|
64
|
+
const [skill, ...extra] = rest;
|
|
65
|
+
if (extra.length > 0)
|
|
66
|
+
return null;
|
|
67
|
+
return { owner, repo: stripGitSuffix(repo), skill };
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
export function normalizeSkillText(text) {
|
|
72
|
+
const withoutBom = text.charCodeAt(0) === 0xfeff ? text.slice(1) : text;
|
|
73
|
+
return withoutBom.replace(/\r\n?/g, "\n");
|
|
74
|
+
}
|
|
75
|
+
export async function hashSkillText(text) {
|
|
76
|
+
return sha256Hex(normalizeSkillText(text));
|
|
77
|
+
}
|
|
78
|
+
function unquote(value) {
|
|
79
|
+
const trimmed = value.trim();
|
|
80
|
+
const first = trimmed.charAt(0);
|
|
81
|
+
if (trimmed.length >= 2 && (first === '"' || first === "'") && trimmed.endsWith(first)) {
|
|
82
|
+
return trimmed.slice(1, -1);
|
|
83
|
+
}
|
|
84
|
+
return trimmed;
|
|
85
|
+
}
|
|
86
|
+
function readFrontmatterBlock(lines) {
|
|
87
|
+
if (lines[0]?.trim() !== "---")
|
|
88
|
+
return null;
|
|
89
|
+
const end = lines.findIndex((line, index) => index > 0 && line.trim() === "---");
|
|
90
|
+
if (end === -1)
|
|
91
|
+
return null;
|
|
92
|
+
return lines.slice(1, end);
|
|
93
|
+
}
|
|
94
|
+
function readScalar(block, key) {
|
|
95
|
+
const index = block.findIndex((line) => line.startsWith(`${key}:`));
|
|
96
|
+
if (index === -1)
|
|
97
|
+
return undefined;
|
|
98
|
+
const first = block[index]?.slice(key.length + 1).trim() ?? "";
|
|
99
|
+
if (first === ">" || first === "|" || first === ">-" || first === "|-") {
|
|
100
|
+
const parts = [];
|
|
101
|
+
for (const line of block.slice(index + 1)) {
|
|
102
|
+
if (line.length > 0 && !line.startsWith(" ") && !line.startsWith("\t")) {
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
parts.push(line.trim());
|
|
106
|
+
}
|
|
107
|
+
const joiner = first.startsWith("|") ? "\n" : " ";
|
|
108
|
+
return parts.filter((part) => part.length > 0).join(joiner);
|
|
109
|
+
}
|
|
110
|
+
return unquote(first);
|
|
111
|
+
}
|
|
112
|
+
function firstContentLine(lines) {
|
|
113
|
+
for (const line of lines) {
|
|
114
|
+
const text = line.replace(/^#+\s*/, "").trim();
|
|
115
|
+
if (text.length > 0)
|
|
116
|
+
return text;
|
|
117
|
+
}
|
|
118
|
+
return "";
|
|
119
|
+
}
|
|
120
|
+
export function parseSkillFrontmatter(text, folderName) {
|
|
121
|
+
const lines = normalizeSkillText(text).split("\n");
|
|
122
|
+
const block = readFrontmatterBlock(lines);
|
|
123
|
+
const body = block === null ? lines : lines.slice(block.length + 2);
|
|
124
|
+
const name = block === null ? undefined : readScalar(block, "name");
|
|
125
|
+
const description = block === null ? undefined : readScalar(block, "description");
|
|
126
|
+
return {
|
|
127
|
+
name: name !== undefined && name.length > 0 ? name : folderName,
|
|
128
|
+
description: description !== undefined && description.length > 0 ? description : firstContentLine(body),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
function dirOf(filePath) {
|
|
132
|
+
const index = filePath.lastIndexOf("/");
|
|
133
|
+
return index === -1 ? "" : filePath.slice(0, index);
|
|
134
|
+
}
|
|
135
|
+
function isInside(dir, base) {
|
|
136
|
+
return base === "" || dir === base || dir.startsWith(`${base}/`);
|
|
137
|
+
}
|
|
138
|
+
function isCommonRoot(dir) {
|
|
139
|
+
const parent = dirOf(dir);
|
|
140
|
+
return SKILL_ROOTS.some((root) => parent === root || parent.endsWith(`/${root}`));
|
|
141
|
+
}
|
|
142
|
+
export function discoverSkillFolders(filePaths, basePath) {
|
|
143
|
+
const base = (basePath ?? "").replace(/^\/+|\/+$/g, "");
|
|
144
|
+
const dirs = filePaths
|
|
145
|
+
.filter((file) => file === SKILL_FILE_NAME || file.endsWith(`/${SKILL_FILE_NAME}`))
|
|
146
|
+
.map(dirOf)
|
|
147
|
+
.filter((dir) => isInside(dir, base));
|
|
148
|
+
const unique = [...new Set(dirs)].sort();
|
|
149
|
+
if (unique.includes(base))
|
|
150
|
+
return [base];
|
|
151
|
+
const common = unique.filter(isCommonRoot);
|
|
152
|
+
return common.length > 0 ? common : unique;
|
|
153
|
+
}
|
|
154
|
+
export function skillFolderFiles(filePaths, folder) {
|
|
155
|
+
const nested = filePaths
|
|
156
|
+
.filter((file) => file === SKILL_FILE_NAME || file.endsWith(`/${SKILL_FILE_NAME}`))
|
|
157
|
+
.map(dirOf)
|
|
158
|
+
.filter((dir) => dir !== folder && isInside(dir, folder));
|
|
159
|
+
const prefix = folder === "" ? "" : `${folder}/`;
|
|
160
|
+
return filePaths
|
|
161
|
+
.filter((file) => file.startsWith(prefix))
|
|
162
|
+
.filter((file) => {
|
|
163
|
+
const dir = dirOf(file);
|
|
164
|
+
return !nested.some((skillDir) => isInside(dir, skillDir));
|
|
165
|
+
})
|
|
166
|
+
.map((file) => file.slice(prefix.length))
|
|
167
|
+
.sort();
|
|
168
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Shared Convex backend helpers, MCP server scaffolding and Node-side MCP OAuth client helpers from one root import: query-limit errors, Clerk auth and token verification, an MCP bearer-token cache, Expo push token storage, batched send and receipts, Clerk-user lookups and ensure-user for Convex functions, V Pro plan checks and Clerk Billing webhook helpers, bearer tokens, env, CORS, JSON responses, MCP route registration, a bearer-auth MCP HTTP handler, OAuth metadata, a JSON-RPC dispatcher, explorer tools, WebCrypto primitives, Convex optimistic-update helpers, MCP OAuth client helpers (provider, sign-in, refresh, revocation, loopback redirect server) for desktop apps, a QuickJS code sandbox that bridges script tool calls to host handlers, and a pure artifacts core (Zod contract, state limits and ops, quiz and flashcards pages, a sandboxed document wrapper with CSP and a guest state bridge); and, from the `@vvedantb/server/ai` subpath, Vercel AI Gateway helpers (service tier provider options, cost from provider metadata, error classification).",
|
|
6
6
|
"type": "module",
|