unagent 0.0.1 → 0.0.4
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/README.md +47 -0
- package/dist/clone-DgXhqC05.mjs +104 -0
- package/dist/context/index.d.mts +2 -0
- package/dist/context/index.mjs +3 -0
- package/dist/context-CAk5kS7q.mjs +59 -0
- package/dist/{env-BUegcU7a.js → detect-CDtKsCsD.mjs} +1 -1
- package/dist/env/{index.d.ts → index.d.mts} +1 -1
- package/dist/env/{index.js → index.mjs} +3 -2
- package/dist/env-DeXFcrWN.mjs +1 -0
- package/dist/exec/index.d.mts +2 -0
- package/dist/exec/index.mjs +3 -0
- package/dist/exec-Dzl5r4Ui.mjs +116 -0
- package/dist/fs/index.d.mts +2 -0
- package/dist/fs/index.mjs +3 -0
- package/dist/fs-nJz4v9pE.mjs +269 -0
- package/dist/git/{index.d.ts → index.d.mts} +1 -1
- package/dist/git/index.mjs +4 -0
- package/dist/git-D3qsdy9d.mjs +86 -0
- package/dist/hooks/index.d.mts +3 -0
- package/dist/hooks/index.mjs +3 -0
- package/dist/hooks-335rp9Cp.mjs +9 -0
- package/dist/index-BZaywR9E.d.mts +97 -0
- package/dist/index-Bd1gSwMB.d.mts +31 -0
- package/dist/index-Bd4x_1H9.d.mts +33 -0
- package/dist/index-C0ulBa5T.d.mts +21 -0
- package/dist/{index-DwU61LUW.d.ts → index-C55JaUgw.d.mts} +10 -10
- package/dist/index-Csv1G0zj.d.mts +36 -0
- package/dist/index-CvCCCs-_.d.mts +20 -0
- package/dist/{index-LzafUiEo.d.ts → index-Cy8LThTV.d.mts} +1 -1
- package/dist/index-D5A0wwzb.d.mts +55 -0
- package/dist/index-DFqD_DAh.d.mts +80 -0
- package/dist/index-DShEKmmL.d.mts +43 -0
- package/dist/index-DpFup4kC.d.mts +21 -0
- package/dist/index-ucMWydcs.d.mts +19 -0
- package/dist/index.d.mts +18 -0
- package/dist/index.mjs +24 -0
- package/dist/link/{index.d.ts → index.d.mts} +1 -1
- package/dist/link/{index.js → index.mjs} +2 -1
- package/dist/link-BRZABZ3A.mjs +1 -0
- package/dist/lock/{index.d.ts → index.d.mts} +1 -1
- package/dist/lock/{index.js → index.mjs} +1 -1
- package/dist/{lock-BeR43Izo.js → lock-CB9Xr9pv.mjs} +1 -1
- package/dist/{path-nPuHl-f5.js → path-Dm-URQvz.mjs} +3 -3
- package/dist/registry/index.d.mts +2 -0
- package/dist/registry/index.mjs +3 -0
- package/dist/registry-DvxT2enn.mjs +30 -0
- package/dist/sandbox/index.d.mts +2 -0
- package/dist/sandbox/index.mjs +3 -0
- package/dist/sandbox-Dyz9jTaL.mjs +139 -0
- package/dist/skill/index.d.mts +2 -0
- package/dist/skill/index.mjs +9 -0
- package/dist/skill-BnKVgm4n.mjs +358 -0
- package/dist/source/{index.d.ts → index.d.mts} +1 -1
- package/dist/source/{index.js → index.mjs} +2 -1
- package/dist/source-BCRylzkW.mjs +1 -0
- package/dist/stop/index.d.mts +3 -0
- package/dist/stop/index.mjs +4 -0
- package/dist/stop-B9w8PiPj.mjs +39 -0
- package/dist/stream/index.d.mts +3 -0
- package/dist/stream/index.mjs +3 -0
- package/dist/stream-CzGvLSeV.mjs +99 -0
- package/dist/tool/index.d.mts +2 -0
- package/dist/tool/index.mjs +3 -0
- package/dist/tool-CESxMfOv.mjs +45 -0
- package/dist/usage/index.d.mts +2 -0
- package/dist/usage/index.mjs +3 -0
- package/dist/usage-DTaeWIUK.mjs +165 -0
- package/dist/utils/{index.d.ts → index.d.mts} +1 -1
- package/dist/utils/{index.js → index.mjs} +2 -2
- package/package.json +104 -34
- package/dist/git/index.js +0 -3
- package/dist/git-D4ZclaF6.js +0 -132
- package/dist/index-y5JZ6STt.d.ts +0 -36
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -10
- package/dist/skill/index.d.ts +0 -2
- package/dist/skill/index.js +0 -3
- package/dist/skill-BmLJYiQz.js +0 -69
- /package/dist/{index-CirIJDiq.d.ts → index-CbYchDwg.d.mts} +0 -0
- /package/dist/{index-BW91Ai1Y.d.ts → index-CzgY9GU2.d.mts} +0 -0
- /package/dist/{index-CFwFmDD-.d.ts → index-DPt7J0hF.d.mts} +0 -0
- /package/dist/{index-DmiDvQ8Q.d.ts → index-wTumcHrH.d.mts} +0 -0
- /package/dist/{source-IfQxnt_F.js → parse-CEbeorIB.mjs} +0 -0
- /package/dist/{link-C4PSDr4v.js → symlink-CbP-heyc.mjs} +0 -0
- /package/dist/{utils-CDyPZons.js → utils-bP3i6rq3.mjs} +0 -0
package/dist/git-D4ZclaF6.js
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { existsSync, mkdirSync, rmSync } from "node:fs";
|
|
2
|
-
import { tmpdir } from "node:os";
|
|
3
|
-
import { join } from "pathe";
|
|
4
|
-
import { simpleGit } from "simple-git";
|
|
5
|
-
|
|
6
|
-
//#region src/git/clone.ts
|
|
7
|
-
var GitCloneError = class extends Error {
|
|
8
|
-
url;
|
|
9
|
-
cause;
|
|
10
|
-
constructor(message, url, cause) {
|
|
11
|
-
super(message);
|
|
12
|
-
this.name = "GitCloneError";
|
|
13
|
-
this.url = url;
|
|
14
|
-
this.cause = cause;
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
async function cloneRepo(url, dest, options = {}) {
|
|
18
|
-
const { depth = 1, branch, timeout = 6e4 } = options;
|
|
19
|
-
try {
|
|
20
|
-
const git = simpleGit({ timeout: { block: timeout } });
|
|
21
|
-
const cloneOptions = [];
|
|
22
|
-
if (depth > 0) cloneOptions.push("--depth", String(depth));
|
|
23
|
-
if (branch) cloneOptions.push("--branch", branch);
|
|
24
|
-
const destDir = join(dest, "..");
|
|
25
|
-
if (!existsSync(destDir)) mkdirSync(destDir, { recursive: true });
|
|
26
|
-
await git.clone(url, dest, cloneOptions);
|
|
27
|
-
return {
|
|
28
|
-
success: true,
|
|
29
|
-
path: dest
|
|
30
|
-
};
|
|
31
|
-
} catch (error) {
|
|
32
|
-
return {
|
|
33
|
-
success: false,
|
|
34
|
-
path: dest,
|
|
35
|
-
error: error instanceof Error ? error.message : "Unknown error"
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
async function cloneToTemp(url, options = {}) {
|
|
40
|
-
const { tempDir = tmpdir() } = options;
|
|
41
|
-
return cloneRepo(url, join(tempDir, `unagent-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`), options);
|
|
42
|
-
}
|
|
43
|
-
function cleanupTempDir(path) {
|
|
44
|
-
const temp = tmpdir();
|
|
45
|
-
if (!path.startsWith(temp)) return false;
|
|
46
|
-
try {
|
|
47
|
-
if (existsSync(path)) rmSync(path, {
|
|
48
|
-
recursive: true,
|
|
49
|
-
force: true
|
|
50
|
-
});
|
|
51
|
-
return true;
|
|
52
|
-
} catch {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function isTempDir(path) {
|
|
57
|
-
return path.startsWith(tmpdir());
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
//#endregion
|
|
61
|
-
//#region src/git/operations.ts
|
|
62
|
-
async function getGitStatus(dir) {
|
|
63
|
-
if (!existsSync(dir)) return void 0;
|
|
64
|
-
try {
|
|
65
|
-
const git = simpleGit(dir);
|
|
66
|
-
if (!await git.checkIsRepo()) return void 0;
|
|
67
|
-
const status = await git.status();
|
|
68
|
-
return {
|
|
69
|
-
isRepo: true,
|
|
70
|
-
branch: status.current || "HEAD",
|
|
71
|
-
ahead: status.ahead,
|
|
72
|
-
behind: status.behind,
|
|
73
|
-
staged: status.staged,
|
|
74
|
-
modified: status.modified,
|
|
75
|
-
untracked: status.not_added,
|
|
76
|
-
hasChanges: !status.isClean()
|
|
77
|
-
};
|
|
78
|
-
} catch {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
async function getCurrentBranch(dir) {
|
|
83
|
-
try {
|
|
84
|
-
return (await simpleGit(dir).revparse(["--abbrev-ref", "HEAD"])).trim();
|
|
85
|
-
} catch {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
async function checkout(dir, ref) {
|
|
90
|
-
try {
|
|
91
|
-
await simpleGit(dir).checkout(ref);
|
|
92
|
-
return true;
|
|
93
|
-
} catch {
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
async function pull(dir) {
|
|
98
|
-
try {
|
|
99
|
-
await simpleGit(dir).pull();
|
|
100
|
-
return true;
|
|
101
|
-
} catch {
|
|
102
|
-
return false;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
async function fetch(dir, remote = "origin") {
|
|
106
|
-
try {
|
|
107
|
-
await simpleGit(dir).fetch(remote);
|
|
108
|
-
return true;
|
|
109
|
-
} catch {
|
|
110
|
-
return false;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
async function getRemoteUrl(dir, remote = "origin") {
|
|
114
|
-
try {
|
|
115
|
-
return (await simpleGit(dir).getRemotes(true)).find((r) => r.name === remote)?.refs.fetch;
|
|
116
|
-
} catch {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
async function getLatestCommitHash(dir) {
|
|
121
|
-
try {
|
|
122
|
-
return (await simpleGit(dir).log({ maxCount: 1 })).latest?.hash;
|
|
123
|
-
} catch {
|
|
124
|
-
return;
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
async function hasUncommittedChanges(dir) {
|
|
128
|
-
return (await getGitStatus(dir))?.hasChanges ?? false;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
//#endregion
|
|
132
|
-
export { getLatestCommitHash as a, pull as c, cloneRepo as d, cloneToTemp as f, getGitStatus as i, GitCloneError as l, fetch as n, getRemoteUrl as o, isTempDir as p, getCurrentBranch as r, hasUncommittedChanges as s, checkout as t, cleanupTempDir as u };
|
package/dist/index-y5JZ6STt.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
//#region src/skill/parse.d.ts
|
|
2
|
-
interface SkillFrontmatter {
|
|
3
|
-
name?: string;
|
|
4
|
-
description?: string;
|
|
5
|
-
version?: string;
|
|
6
|
-
author?: string;
|
|
7
|
-
globs?: string | string[];
|
|
8
|
-
alwaysApply?: boolean;
|
|
9
|
-
tags?: string[];
|
|
10
|
-
[key: string]: unknown;
|
|
11
|
-
}
|
|
12
|
-
interface ParsedSkill {
|
|
13
|
-
frontmatter: SkillFrontmatter;
|
|
14
|
-
content: string;
|
|
15
|
-
raw: string;
|
|
16
|
-
}
|
|
17
|
-
declare function parseSkillMd(content: string): ParsedSkill;
|
|
18
|
-
declare function extractSkillName(frontmatter: SkillFrontmatter, filename?: string): string;
|
|
19
|
-
declare function validateSkillMd(parsed: ParsedSkill): string[];
|
|
20
|
-
//#endregion
|
|
21
|
-
//#region src/skill/discover.d.ts
|
|
22
|
-
interface DiscoveredSkill {
|
|
23
|
-
path: string;
|
|
24
|
-
filename: string;
|
|
25
|
-
name: string;
|
|
26
|
-
parsed: ParsedSkill;
|
|
27
|
-
}
|
|
28
|
-
interface DiscoverOptions {
|
|
29
|
-
recursive?: boolean;
|
|
30
|
-
extensions?: string[];
|
|
31
|
-
}
|
|
32
|
-
declare function discoverSkills(dir: string, options?: DiscoverOptions): DiscoveredSkill[];
|
|
33
|
-
declare function filterSkills(skills: DiscoveredSkill[], query: string): DiscoveredSkill[];
|
|
34
|
-
declare function findSkillByName(skills: DiscoveredSkill[], name: string): DiscoveredSkill | undefined;
|
|
35
|
-
//#endregion
|
|
36
|
-
export { findSkillByName as a, extractSkillName as c, filterSkills as i, parseSkillMd as l, DiscoveredSkill as n, ParsedSkill as o, discoverSkills as r, SkillFrontmatter as s, DiscoverOptions as t, validateSkillMd as u };
|
package/dist/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { _ as getAgentConfig, a as getAgentSkillsDir, c as isCI, d as detectAgentByEnv, f as detectCurrentAgent, g as agents, h as AgentConfig, i as getAgentRulesPath, l as isTTY, m as isRunningInAgent, n as agentConfigExists, o as getXDGPaths, p as detectInstalledAgents, r as getAgentConfigDir, s as hasTTY, t as XDGPaths, u as DetectedAgent, v as getAgentIds, y as getAllAgents } from "./index-BW91Ai1Y.js";
|
|
2
|
-
import { a as getGitStatus, c as hasUncommittedChanges, d as CloneResult, f as GitCloneError, g as isTempDir, h as cloneToTemp, i as getCurrentBranch, l as pull, m as cloneRepo, n as checkout, o as getLatestCommitHash, p as cleanupTempDir, r as fetch, s as getRemoteUrl, t as GitStatus, u as CloneOptions } from "./index-DwU61LUW.js";
|
|
3
|
-
import { a as removeSymlink, c as validateSymlinkTarget, d as copyDirectory, f as copyFile, i as isSymlink, l as CopyOptions, n as SymlinkResult, o as isPathSafe, p as getDirectorySize, r as createSymlink, s as sanitizeName, t as SymlinkOptions, u as CopyResult } from "./index-CFwFmDD-.js";
|
|
4
|
-
import { a as getSkillFromLock, c as listSkillsInLock, d as writeSkillLock, f as computeContentHash, i as createEmptyLock, l as readSkillLock, m as computeFileHash, n as SkillLockEntry, o as hasSkillInLock, p as computeDirectoryHash, r as addSkillToLock, s as isSkillOutdated, t as SkillLock, u as removeSkillFromLock } from "./index-LzafUiEo.js";
|
|
5
|
-
import { a as findSkillByName, c as extractSkillName, i as filterSkills, l as parseSkillMd, n as DiscoveredSkill, o as ParsedSkill, r as discoverSkills, s as SkillFrontmatter, t as DiscoverOptions, u as validateSkillMd } from "./index-y5JZ6STt.js";
|
|
6
|
-
import { a as parseOwnerRepo, c as SourceProvider, d as getProviderFromUrl, f as parseGitHubUrl, i as isUrl, l as buildGitHubCloneUrl, n as getOwnerRepo, o as parseSource, p as parseGitLabUrl, r as isLocalPath, s as ProviderInfo, t as ParsedSource, u as buildGitLabCloneUrl } from "./index-DmiDvQ8Q.js";
|
|
7
|
-
import { a as truncate, c as bold, d as gray, f as green, h as yellow, i as pluralize, l as cyan, m as stripAnsi, n as shortenPath, o as ANSI, p as red, r as formatList, s as blue, t as expandPath, u as dim } from "./index-CirIJDiq.js";
|
|
8
|
-
export { ANSI, AgentConfig, CloneOptions, CloneResult, CopyOptions, CopyResult, DetectedAgent, DiscoverOptions, DiscoveredSkill, GitCloneError, GitStatus, ParsedSkill, ParsedSource, ProviderInfo, SkillFrontmatter, SkillLock, SkillLockEntry, SourceProvider, SymlinkOptions, SymlinkResult, XDGPaths, addSkillToLock, agentConfigExists, agents, blue, bold, buildGitHubCloneUrl, buildGitLabCloneUrl, checkout, cleanupTempDir, cloneRepo, cloneToTemp, computeContentHash, computeDirectoryHash, computeFileHash, copyDirectory, copyFile, createEmptyLock, createSymlink, cyan, detectAgentByEnv, detectCurrentAgent, detectInstalledAgents, dim, discoverSkills, expandPath, extractSkillName, fetch, filterSkills, findSkillByName, formatList, getAgentConfig, getAgentConfigDir, getAgentIds, getAgentRulesPath, getAgentSkillsDir, getAllAgents, getCurrentBranch, getDirectorySize, getGitStatus, getLatestCommitHash, getOwnerRepo, getProviderFromUrl, getRemoteUrl, getSkillFromLock, getXDGPaths, gray, green, hasSkillInLock, hasTTY, hasUncommittedChanges, isCI, isLocalPath, isPathSafe, isRunningInAgent, isSkillOutdated, isSymlink, isTTY, isTempDir, isUrl, listSkillsInLock, parseGitHubUrl, parseGitLabUrl, parseOwnerRepo, parseSkillMd, parseSource, pluralize, pull, readSkillLock, red, removeSkillFromLock, removeSymlink, sanitizeName, shortenPath, stripAnsi, truncate, validateSkillMd, validateSymlinkTarget, writeSkillLock, yellow };
|
package/dist/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { a as agentConfigExists, c as getAgentSkillsDir, d as isCI, f as isTTY, g as getAllAgents, h as getAgentIds, i as isRunningInAgent, l as getXDGPaths, m as getAgentConfig, n as detectCurrentAgent, o as getAgentConfigDir, p as agents, r as detectInstalledAgents, s as getAgentRulesPath, t as detectAgentByEnv, u as hasTTY } from "./env-BUegcU7a.js";
|
|
2
|
-
import { n as shortenPath, t as expandPath } from "./path-nPuHl-f5.js";
|
|
3
|
-
import { a as getLatestCommitHash, c as pull, d as cloneRepo, f as cloneToTemp, i as getGitStatus, l as GitCloneError, n as fetch, o as getRemoteUrl, p as isTempDir, r as getCurrentBranch, s as hasUncommittedChanges, t as checkout, u as cleanupTempDir } from "./git-D4ZclaF6.js";
|
|
4
|
-
import { a as sanitizeName, c as copyFile, i as isPathSafe, l as getDirectorySize, n as isSymlink, o as validateSymlinkTarget, r as removeSymlink, s as copyDirectory, t as createSymlink } from "./link-C4PSDr4v.js";
|
|
5
|
-
import { a as isSkillOutdated, c as removeSkillFromLock, d as computeDirectoryHash, f as computeFileHash, i as hasSkillInLock, l as writeSkillLock, n as createEmptyLock, o as listSkillsInLock, r as getSkillFromLock, s as readSkillLock, t as addSkillToLock, u as computeContentHash } from "./lock-BeR43Izo.js";
|
|
6
|
-
import { a as parseSkillMd, i as extractSkillName, n as filterSkills, o as validateSkillMd, r as findSkillByName, t as discoverSkills } from "./skill-BmLJYiQz.js";
|
|
7
|
-
import { a as parseSource, c as getProviderFromUrl, i as parseOwnerRepo, l as parseGitHubUrl, n as isLocalPath, o as buildGitHubCloneUrl, r as isUrl, s as buildGitLabCloneUrl, t as getOwnerRepo, u as parseGitLabUrl } from "./source-IfQxnt_F.js";
|
|
8
|
-
import { a as blue, c as dim, d as red, f as stripAnsi, i as ANSI, l as gray, n as pluralize, o as bold, p as yellow, r as truncate, s as cyan, t as formatList, u as green } from "./utils-CDyPZons.js";
|
|
9
|
-
|
|
10
|
-
export { ANSI, GitCloneError, addSkillToLock, agentConfigExists, agents, blue, bold, buildGitHubCloneUrl, buildGitLabCloneUrl, checkout, cleanupTempDir, cloneRepo, cloneToTemp, computeContentHash, computeDirectoryHash, computeFileHash, copyDirectory, copyFile, createEmptyLock, createSymlink, cyan, detectAgentByEnv, detectCurrentAgent, detectInstalledAgents, dim, discoverSkills, expandPath, extractSkillName, fetch, filterSkills, findSkillByName, formatList, getAgentConfig, getAgentConfigDir, getAgentIds, getAgentRulesPath, getAgentSkillsDir, getAllAgents, getCurrentBranch, getDirectorySize, getGitStatus, getLatestCommitHash, getOwnerRepo, getProviderFromUrl, getRemoteUrl, getSkillFromLock, getXDGPaths, gray, green, hasSkillInLock, hasTTY, hasUncommittedChanges, isCI, isLocalPath, isPathSafe, isRunningInAgent, isSkillOutdated, isSymlink, isTTY, isTempDir, isUrl, listSkillsInLock, parseGitHubUrl, parseGitLabUrl, parseOwnerRepo, parseSkillMd, parseSource, pluralize, pull, readSkillLock, red, removeSkillFromLock, removeSymlink, sanitizeName, shortenPath, stripAnsi, truncate, validateSkillMd, validateSymlinkTarget, writeSkillLock, yellow };
|
package/dist/skill/index.d.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { a as findSkillByName, c as extractSkillName, i as filterSkills, l as parseSkillMd, n as DiscoveredSkill, o as ParsedSkill, r as discoverSkills, s as SkillFrontmatter, t as DiscoverOptions, u as validateSkillMd } from "../index-y5JZ6STt.js";
|
|
2
|
-
export { DiscoverOptions, DiscoveredSkill, ParsedSkill, SkillFrontmatter, discoverSkills, extractSkillName, filterSkills, findSkillByName, parseSkillMd, validateSkillMd };
|
package/dist/skill/index.js
DELETED
package/dist/skill-BmLJYiQz.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
2
|
-
import { basename, extname, join } from "pathe";
|
|
3
|
-
import matter from "gray-matter";
|
|
4
|
-
|
|
5
|
-
//#region src/skill/parse.ts
|
|
6
|
-
function parseSkillMd(content) {
|
|
7
|
-
const { data, content: body } = matter(content);
|
|
8
|
-
return {
|
|
9
|
-
frontmatter: data,
|
|
10
|
-
content: body.trim(),
|
|
11
|
-
raw: content
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function extractSkillName(frontmatter, filename) {
|
|
15
|
-
if (frontmatter.name) return frontmatter.name;
|
|
16
|
-
if (filename) return filename.replace(/\.md$/i, "").replace(/^SKILL[._-]?/i, "").replace(/[._-]/g, " ").trim();
|
|
17
|
-
return "Unnamed Skill";
|
|
18
|
-
}
|
|
19
|
-
function validateSkillMd(parsed) {
|
|
20
|
-
const errors = [];
|
|
21
|
-
if (!parsed.content) errors.push("Skill content is empty");
|
|
22
|
-
if (parsed.frontmatter.globs) {
|
|
23
|
-
const globs = Array.isArray(parsed.frontmatter.globs) ? parsed.frontmatter.globs : [parsed.frontmatter.globs];
|
|
24
|
-
for (const glob of globs) if (typeof glob !== "string") errors.push(`Invalid glob pattern: ${glob}`);
|
|
25
|
-
}
|
|
26
|
-
return errors;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
//#endregion
|
|
30
|
-
//#region src/skill/discover.ts
|
|
31
|
-
const DEFAULT_EXTENSIONS = [".md"];
|
|
32
|
-
function discoverSkills(dir, options = {}) {
|
|
33
|
-
const { recursive = false, extensions = DEFAULT_EXTENSIONS } = options;
|
|
34
|
-
if (!existsSync(dir)) return [];
|
|
35
|
-
const skills = [];
|
|
36
|
-
const entries = readdirSync(dir);
|
|
37
|
-
for (const entry of entries) {
|
|
38
|
-
const fullPath = join(dir, entry);
|
|
39
|
-
const stat = statSync(fullPath);
|
|
40
|
-
if (stat.isDirectory() && recursive) skills.push(...discoverSkills(fullPath, options));
|
|
41
|
-
else if (stat.isFile() && extensions.includes(extname(entry).toLowerCase())) try {
|
|
42
|
-
const parsed = parseSkillMd(readFileSync(fullPath, "utf-8"));
|
|
43
|
-
const filename = basename(entry, extname(entry));
|
|
44
|
-
skills.push({
|
|
45
|
-
path: fullPath,
|
|
46
|
-
filename,
|
|
47
|
-
name: extractSkillName(parsed.frontmatter, filename),
|
|
48
|
-
parsed
|
|
49
|
-
});
|
|
50
|
-
} catch {}
|
|
51
|
-
}
|
|
52
|
-
return skills;
|
|
53
|
-
}
|
|
54
|
-
function filterSkills(skills, query) {
|
|
55
|
-
const lowerQuery = query.toLowerCase();
|
|
56
|
-
return skills.filter((skill) => {
|
|
57
|
-
const nameMatch = skill.name.toLowerCase().includes(lowerQuery);
|
|
58
|
-
const filenameMatch = skill.filename.toLowerCase().includes(lowerQuery);
|
|
59
|
-
const tagMatch = skill.parsed.frontmatter.tags?.some((tag) => tag.toLowerCase().includes(lowerQuery));
|
|
60
|
-
return nameMatch || filenameMatch || tagMatch;
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
function findSkillByName(skills, name) {
|
|
64
|
-
const lowerName = name.toLowerCase();
|
|
65
|
-
return skills.find((skill) => skill.name.toLowerCase() === lowerName || skill.filename.toLowerCase() === lowerName);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
//#endregion
|
|
69
|
-
export { parseSkillMd as a, extractSkillName as i, filterSkills as n, validateSkillMd as o, findSkillByName as r, discoverSkills as t };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|