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.
Files changed (85) hide show
  1. package/README.md +47 -0
  2. package/dist/clone-DgXhqC05.mjs +104 -0
  3. package/dist/context/index.d.mts +2 -0
  4. package/dist/context/index.mjs +3 -0
  5. package/dist/context-CAk5kS7q.mjs +59 -0
  6. package/dist/{env-BUegcU7a.js → detect-CDtKsCsD.mjs} +1 -1
  7. package/dist/env/{index.d.ts → index.d.mts} +1 -1
  8. package/dist/env/{index.js → index.mjs} +3 -2
  9. package/dist/env-DeXFcrWN.mjs +1 -0
  10. package/dist/exec/index.d.mts +2 -0
  11. package/dist/exec/index.mjs +3 -0
  12. package/dist/exec-Dzl5r4Ui.mjs +116 -0
  13. package/dist/fs/index.d.mts +2 -0
  14. package/dist/fs/index.mjs +3 -0
  15. package/dist/fs-nJz4v9pE.mjs +269 -0
  16. package/dist/git/{index.d.ts → index.d.mts} +1 -1
  17. package/dist/git/index.mjs +4 -0
  18. package/dist/git-D3qsdy9d.mjs +86 -0
  19. package/dist/hooks/index.d.mts +3 -0
  20. package/dist/hooks/index.mjs +3 -0
  21. package/dist/hooks-335rp9Cp.mjs +9 -0
  22. package/dist/index-BZaywR9E.d.mts +97 -0
  23. package/dist/index-Bd1gSwMB.d.mts +31 -0
  24. package/dist/index-Bd4x_1H9.d.mts +33 -0
  25. package/dist/index-C0ulBa5T.d.mts +21 -0
  26. package/dist/{index-DwU61LUW.d.ts → index-C55JaUgw.d.mts} +10 -10
  27. package/dist/index-Csv1G0zj.d.mts +36 -0
  28. package/dist/index-CvCCCs-_.d.mts +20 -0
  29. package/dist/{index-LzafUiEo.d.ts → index-Cy8LThTV.d.mts} +1 -1
  30. package/dist/index-D5A0wwzb.d.mts +55 -0
  31. package/dist/index-DFqD_DAh.d.mts +80 -0
  32. package/dist/index-DShEKmmL.d.mts +43 -0
  33. package/dist/index-DpFup4kC.d.mts +21 -0
  34. package/dist/index-ucMWydcs.d.mts +19 -0
  35. package/dist/index.d.mts +18 -0
  36. package/dist/index.mjs +24 -0
  37. package/dist/link/{index.d.ts → index.d.mts} +1 -1
  38. package/dist/link/{index.js → index.mjs} +2 -1
  39. package/dist/link-BRZABZ3A.mjs +1 -0
  40. package/dist/lock/{index.d.ts → index.d.mts} +1 -1
  41. package/dist/lock/{index.js → index.mjs} +1 -1
  42. package/dist/{lock-BeR43Izo.js → lock-CB9Xr9pv.mjs} +1 -1
  43. package/dist/{path-nPuHl-f5.js → path-Dm-URQvz.mjs} +3 -3
  44. package/dist/registry/index.d.mts +2 -0
  45. package/dist/registry/index.mjs +3 -0
  46. package/dist/registry-DvxT2enn.mjs +30 -0
  47. package/dist/sandbox/index.d.mts +2 -0
  48. package/dist/sandbox/index.mjs +3 -0
  49. package/dist/sandbox-Dyz9jTaL.mjs +139 -0
  50. package/dist/skill/index.d.mts +2 -0
  51. package/dist/skill/index.mjs +9 -0
  52. package/dist/skill-BnKVgm4n.mjs +358 -0
  53. package/dist/source/{index.d.ts → index.d.mts} +1 -1
  54. package/dist/source/{index.js → index.mjs} +2 -1
  55. package/dist/source-BCRylzkW.mjs +1 -0
  56. package/dist/stop/index.d.mts +3 -0
  57. package/dist/stop/index.mjs +4 -0
  58. package/dist/stop-B9w8PiPj.mjs +39 -0
  59. package/dist/stream/index.d.mts +3 -0
  60. package/dist/stream/index.mjs +3 -0
  61. package/dist/stream-CzGvLSeV.mjs +99 -0
  62. package/dist/tool/index.d.mts +2 -0
  63. package/dist/tool/index.mjs +3 -0
  64. package/dist/tool-CESxMfOv.mjs +45 -0
  65. package/dist/usage/index.d.mts +2 -0
  66. package/dist/usage/index.mjs +3 -0
  67. package/dist/usage-DTaeWIUK.mjs +165 -0
  68. package/dist/utils/{index.d.ts → index.d.mts} +1 -1
  69. package/dist/utils/{index.js → index.mjs} +2 -2
  70. package/package.json +104 -34
  71. package/dist/git/index.js +0 -3
  72. package/dist/git-D4ZclaF6.js +0 -132
  73. package/dist/index-y5JZ6STt.d.ts +0 -36
  74. package/dist/index.d.ts +0 -8
  75. package/dist/index.js +0 -10
  76. package/dist/skill/index.d.ts +0 -2
  77. package/dist/skill/index.js +0 -3
  78. package/dist/skill-BmLJYiQz.js +0 -69
  79. /package/dist/{index-CirIJDiq.d.ts → index-CbYchDwg.d.mts} +0 -0
  80. /package/dist/{index-BW91Ai1Y.d.ts → index-CzgY9GU2.d.mts} +0 -0
  81. /package/dist/{index-CFwFmDD-.d.ts → index-DPt7J0hF.d.mts} +0 -0
  82. /package/dist/{index-DmiDvQ8Q.d.ts → index-wTumcHrH.d.mts} +0 -0
  83. /package/dist/{source-IfQxnt_F.js → parse-CEbeorIB.mjs} +0 -0
  84. /package/dist/{link-C4PSDr4v.js → symlink-CbP-heyc.mjs} +0 -0
  85. /package/dist/{utils-CDyPZons.js → utils-bP3i6rq3.mjs} +0 -0
package/dist/index.mjs ADDED
@@ -0,0 +1,24 @@
1
+ import { i as truncateToFit, n as estimateTokens, r as splitByTokens, t as buildContext } from "./context-CAk5kS7q.mjs";
2
+ 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 "./detect-CDtKsCsD.mjs";
3
+ import { n as shortenPath, t as expandPath } from "./path-Dm-URQvz.mjs";
4
+ import "./env-DeXFcrWN.mjs";
5
+ import { n as execSafeSync, t as execSafe } from "./exec-Dzl5r4Ui.mjs";
6
+ import { i as createFSFromStorage, n as OverlayFS, r as RealFS, t as InMemoryFS } from "./fs-nJz4v9pE.mjs";
7
+ import { a as isTempDir, i as cloneToTemp, n as cleanupTempDir, r as cloneRepo, t as GitCloneError } from "./clone-DgXhqC05.mjs";
8
+ import { a as getLatestCommitHash, c as pull, i as getGitStatus, n as fetch, o as getRemoteUrl, r as getCurrentBranch, s as hasUncommittedChanges, t as checkout } from "./git-D3qsdy9d.mjs";
9
+ import { n as createHookable, t as createAgentHooks } from "./hooks-335rp9Cp.mjs";
10
+ 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 "./symlink-CbP-heyc.mjs";
11
+ import "./link-BRZABZ3A.mjs";
12
+ 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-CB9Xr9pv.mjs";
13
+ import { n as defineProvider, t as createRegistry } from "./registry-DvxT2enn.mjs";
14
+ import { n as detectSandbox, r as isSandboxAvailable, t as createSandbox } from "./sandbox-Dyz9jTaL.mjs";
15
+ import { a as discoverSkills, c as extractSkillName, i as installSkill, l as parseSkillMd, n as uninstallSkill, o as filterSkills, r as toPromptXml, s as findSkillByName, t as validateSkill, u as validateSkillMd } from "./skill-BnKVgm4n.mjs";
16
+ 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 "./parse-CEbeorIB.mjs";
17
+ import "./source-BCRylzkW.mjs";
18
+ import { i as getRatesForModel, n as aggregateUsage, r as calculateCost, t as MODEL_PRICING } from "./usage-DTaeWIUK.mjs";
19
+ import { a as or, i as not, n as costIs, o as timeout, r as iterationCountIs, s as tokenCountIs, t as and } from "./stop-B9w8PiPj.mjs";
20
+ import { i as parseSSE, n as createStreamResult, r as formatSSE, t as SSEParser } from "./stream-CzGvLSeV.mjs";
21
+ import { n as toolToSchema, r as toolsToSchema, t as defineTool } from "./tool-CESxMfOv.mjs";
22
+ 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-bP3i6rq3.mjs";
23
+
24
+ export { ANSI, GitCloneError, InMemoryFS, MODEL_PRICING, OverlayFS, RealFS, SSEParser, addSkillToLock, agentConfigExists, agents, aggregateUsage, and, blue, bold, buildContext, buildGitHubCloneUrl, buildGitLabCloneUrl, calculateCost, checkout, cleanupTempDir, cloneRepo, cloneToTemp, computeContentHash, computeDirectoryHash, computeFileHash, copyDirectory, copyFile, costIs, createAgentHooks, createEmptyLock, createFSFromStorage, createHookable as createHooks, createRegistry, createSandbox, createStreamResult, createSymlink, cyan, defineProvider, defineTool, detectAgentByEnv, detectCurrentAgent, detectInstalledAgents, detectSandbox, dim, discoverSkills, estimateTokens, execSafe, execSafeSync, expandPath, extractSkillName, fetch, filterSkills, findSkillByName, formatList, formatSSE, getAgentConfig, getAgentConfigDir, getAgentIds, getAgentRulesPath, getAgentSkillsDir, getAllAgents, getCurrentBranch, getDirectorySize, getGitStatus, getLatestCommitHash, getOwnerRepo, getProviderFromUrl, getRatesForModel, getRemoteUrl, getSkillFromLock, getXDGPaths, gray, green, hasSkillInLock, hasTTY, hasUncommittedChanges, installSkill, isCI, isLocalPath, isPathSafe, isRunningInAgent, isSandboxAvailable, isSkillOutdated, isSymlink, isTTY, isTempDir, isUrl, iterationCountIs, listSkillsInLock, not, or, parseGitHubUrl, parseGitLabUrl, parseOwnerRepo, parseSSE, parseSkillMd, parseSource, pluralize, pull, readSkillLock, red, removeSkillFromLock, removeSymlink, sanitizeName, shortenPath, splitByTokens, stripAnsi, timeout, toPromptXml, tokenCountIs, toolToSchema, toolsToSchema, truncate, truncateToFit, uninstallSkill, validateSkill, validateSkillMd, validateSymlinkTarget, writeSkillLock, yellow };
@@ -1,2 +1,2 @@
1
- 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";
1
+ 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-DPt7J0hF.mjs";
2
2
  export { CopyOptions, CopyResult, SymlinkOptions, SymlinkResult, copyDirectory, copyFile, createSymlink, getDirectorySize, isPathSafe, isSymlink, removeSymlink, sanitizeName, validateSymlinkTarget };
@@ -1,3 +1,4 @@
1
- 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";
1
+ 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 "../symlink-CbP-heyc.mjs";
2
+ import "../link-BRZABZ3A.mjs";
2
3
 
3
4
  export { copyDirectory, copyFile, createSymlink, getDirectorySize, isPathSafe, isSymlink, removeSymlink, sanitizeName, validateSymlinkTarget };
@@ -0,0 +1 @@
1
+ export { };
@@ -1,2 +1,2 @@
1
- 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";
1
+ 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-Cy8LThTV.mjs";
2
2
  export { SkillLock, SkillLockEntry, addSkillToLock, computeContentHash, computeDirectoryHash, computeFileHash, createEmptyLock, getSkillFromLock, hasSkillInLock, isSkillOutdated, listSkillsInLock, readSkillLock, removeSkillFromLock, writeSkillLock };
@@ -1,3 +1,3 @@
1
- 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";
1
+ 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-CB9Xr9pv.mjs";
2
2
 
3
3
  export { addSkillToLock, computeContentHash, computeDirectoryHash, computeFileHash, createEmptyLock, getSkillFromLock, hasSkillInLock, isSkillOutdated, listSkillsInLock, readSkillLock, removeSkillFromLock, writeSkillLock };
@@ -35,7 +35,7 @@ function hashDirectory(dir, hash, exclude) {
35
35
  }
36
36
 
37
37
  //#endregion
38
- //#region src/lock/lock.ts
38
+ //#region src/lock/index.ts
39
39
  const LOCK_VERSION = 1;
40
40
  const DEFAULT_LOCK_FILE = "skill.lock";
41
41
  function createEmptyLock() {
@@ -1,9 +1,9 @@
1
1
  import { homedir } from "node:os";
2
- import { relative, resolve } from "pathe";
2
+ import { normalize, relative, resolve } from "pathe";
3
3
 
4
4
  //#region src/utils/path.ts
5
5
  function shortenPath(filepath, cwd) {
6
- const home = homedir();
6
+ const home = normalize(homedir());
7
7
  const resolved = resolve(filepath);
8
8
  if (cwd) {
9
9
  const rel = relative(cwd, resolved);
@@ -13,7 +13,7 @@ function shortenPath(filepath, cwd) {
13
13
  return resolved;
14
14
  }
15
15
  function expandPath(filepath) {
16
- if (filepath.startsWith("~")) return `${homedir()}${filepath.slice(1)}`;
16
+ if (filepath.startsWith("~")) return `${normalize(homedir())}${filepath.slice(1)}`;
17
17
  return resolve(filepath);
18
18
  }
19
19
 
@@ -0,0 +1,2 @@
1
+ import { a as defineProvider, i as createRegistry, n as Registry, r as RegistryOptions, t as Provider } from "../index-CvCCCs-_.mjs";
2
+ export { Provider, Registry, RegistryOptions, createRegistry, defineProvider };
@@ -0,0 +1,3 @@
1
+ import { n as defineProvider, t as createRegistry } from "../registry-DvxT2enn.mjs";
2
+
3
+ export { createRegistry, defineProvider };
@@ -0,0 +1,30 @@
1
+ //#region src/registry/index.ts
2
+ function createRegistry(options = {}) {
3
+ const { defaultPriority = 0 } = options;
4
+ const providers = [];
5
+ return {
6
+ register(provider) {
7
+ if (provider.priority === void 0) provider.priority = defaultPriority;
8
+ providers.push(provider);
9
+ providers.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
10
+ },
11
+ unregister(id) {
12
+ const idx = providers.findIndex((p) => p.id === id);
13
+ if (idx === -1) return false;
14
+ providers.splice(idx, 1);
15
+ return true;
16
+ },
17
+ async resolve(input) {
18
+ for (const provider of providers) if (provider.match(input)) return await provider.resolve(input);
19
+ },
20
+ list() {
21
+ return [...providers];
22
+ }
23
+ };
24
+ }
25
+ function defineProvider(provider) {
26
+ return provider;
27
+ }
28
+
29
+ //#endregion
30
+ export { defineProvider as n, createRegistry as t };
@@ -0,0 +1,2 @@
1
+ import { a as SandboxProvider, c as detectSandbox, i as SandboxOptions, l as isSandboxAvailable, n as SandboxDetection, o as SandboxType, r as SandboxExecResult, s as createSandbox, t as Sandbox } from "../index-Bd4x_1H9.mjs";
2
+ export { Sandbox, SandboxDetection, SandboxExecResult, SandboxOptions, SandboxProvider, SandboxType, createSandbox, detectSandbox, isSandboxAvailable };
@@ -0,0 +1,3 @@
1
+ import { n as detectSandbox, r as isSandboxAvailable, t as createSandbox } from "../sandbox-Dyz9jTaL.mjs";
2
+
3
+ export { createSandbox, detectSandbox, isSandboxAvailable };
@@ -0,0 +1,139 @@
1
+ import { createRequire } from "node:module";
2
+ import { accessSync } from "node:fs";
3
+
4
+ //#region src/sandbox/index.ts
5
+ function detectSandbox() {
6
+ if (process.env.CLOUDFLARE_WORKER || process.env.CF_PAGES) return {
7
+ type: "cloudflare",
8
+ details: { runtime: "workers" }
9
+ };
10
+ if (process.env.VERCEL || process.env.VERCEL_ENV) return {
11
+ type: "vercel",
12
+ details: { env: process.env.VERCEL_ENV ?? "unknown" }
13
+ };
14
+ if (process.env.DOCKER_CONTAINER || existsSync$1("/.dockerenv")) return { type: "docker" };
15
+ return { type: "none" };
16
+ }
17
+ function existsSync$1(path) {
18
+ try {
19
+ accessSync(path);
20
+ return true;
21
+ } catch {
22
+ return false;
23
+ }
24
+ }
25
+ const _require = createRequire(import.meta.url);
26
+ async function loadVercelSandbox() {
27
+ const moduleName = "@vercel/sandbox";
28
+ try {
29
+ return await import(
30
+ /* @vite-ignore */
31
+ moduleName
32
+ );
33
+ } catch {
34
+ throw new Error(`${moduleName} not installed. Add as peer dependency: pnpm add ${moduleName}`);
35
+ }
36
+ }
37
+ async function loadCloudflareSandbox() {
38
+ const moduleName = "@cloudflare/sandbox";
39
+ try {
40
+ return await import(
41
+ /* @vite-ignore */
42
+ moduleName
43
+ );
44
+ } catch {
45
+ throw new Error(`${moduleName} not installed. Add as peer dependency.`);
46
+ }
47
+ }
48
+ var VercelSandbox = class {
49
+ id;
50
+ provider = "vercel";
51
+ instance;
52
+ constructor(id, instance) {
53
+ this.id = id;
54
+ this.instance = instance;
55
+ }
56
+ async exec(command, args) {
57
+ const result = await this.instance.exec(command, args);
58
+ return {
59
+ ok: result.exitCode === 0,
60
+ stdout: result.stdout ?? "",
61
+ stderr: result.stderr ?? "",
62
+ code: result.exitCode
63
+ };
64
+ }
65
+ async writeFile(path, content) {
66
+ await this.instance.writeFile(path, content);
67
+ }
68
+ async readFile(path) {
69
+ return await this.instance.readFile(path);
70
+ }
71
+ async stop() {
72
+ await this.instance.close?.();
73
+ }
74
+ };
75
+ function shellQuote(arg) {
76
+ if (!/[^\w\-./=]/.test(arg)) return arg;
77
+ return `'${arg.replace(/'/g, `'\\''`)}'`;
78
+ }
79
+ var CloudflareSandbox = class {
80
+ id;
81
+ provider = "cloudflare";
82
+ instance;
83
+ constructor(id, instance) {
84
+ this.id = id;
85
+ this.instance = instance;
86
+ }
87
+ async exec(command, args) {
88
+ const quotedArgs = args.map(shellQuote).join(" ");
89
+ const result = await this.instance.run(`${shellQuote(command)} ${quotedArgs}`);
90
+ return {
91
+ ok: result.exitCode === 0,
92
+ stdout: result.stdout ?? "",
93
+ stderr: result.stderr ?? "",
94
+ code: result.exitCode
95
+ };
96
+ }
97
+ async writeFile(path, content) {
98
+ await this.instance.writeFile(path, content);
99
+ }
100
+ async readFile(path) {
101
+ return await this.instance.readFile(path);
102
+ }
103
+ async stop() {
104
+ await this.instance.close?.();
105
+ }
106
+ };
107
+ async function createSandbox(options) {
108
+ const { provider, runtime, timeout, memory, cpu } = options;
109
+ const id = `${provider}-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
110
+ if (provider === "vercel") return new VercelSandbox(id, await (await loadVercelSandbox()).createSandbox({
111
+ runtime: runtime ?? "node24",
112
+ timeout: timeout ?? 3e5,
113
+ ...memory && { memory },
114
+ ...cpu && { cpu }
115
+ }));
116
+ if (provider === "cloudflare") return new CloudflareSandbox(id, await (await loadCloudflareSandbox()).createSandbox({
117
+ runtime: runtime ?? "python",
118
+ timeout: timeout ?? 6e5
119
+ }));
120
+ throw new Error(`Unknown sandbox provider: ${provider}`);
121
+ }
122
+ function isSandboxAvailable(provider) {
123
+ try {
124
+ if (provider === "vercel") {
125
+ _require.resolve("@vercel/sandbox");
126
+ return true;
127
+ }
128
+ if (provider === "cloudflare") {
129
+ _require.resolve("@cloudflare/sandbox");
130
+ return true;
131
+ }
132
+ return false;
133
+ } catch {
134
+ return false;
135
+ }
136
+ }
137
+
138
+ //#endregion
139
+ export { detectSandbox as n, isSandboxAvailable as r, createSandbox as t };
@@ -0,0 +1,2 @@
1
+ import { C as validateSkillMd, S as parseSkillMd, _ as filterSkills, a as UninstallSkillResult, b as SkillFrontmatter, c as toPromptXml, d as InstallSkillResult, f as InstallSkillResultEntry, g as discoverSkills, h as DiscoveredSkill, i as UninstallSkillOptions, l as InstallSkillErrorEntry, m as DiscoverOptions, n as validateSkill, o as UninstallSkillResultEntry, p as installSkill, r as UninstallSkillErrorEntry, s as uninstallSkill, t as ValidationResult, u as InstallSkillOptions, v as findSkillByName, x as extractSkillName, y as ParsedSkill } from "../index-BZaywR9E.mjs";
2
+ export { DiscoverOptions, DiscoveredSkill, InstallSkillErrorEntry, InstallSkillOptions, InstallSkillResult, InstallSkillResultEntry, ParsedSkill, SkillFrontmatter, UninstallSkillErrorEntry, UninstallSkillOptions, UninstallSkillResult, UninstallSkillResultEntry, ValidationResult, discoverSkills, extractSkillName, filterSkills, findSkillByName, installSkill, parseSkillMd, toPromptXml, uninstallSkill, validateSkill, validateSkillMd };
@@ -0,0 +1,9 @@
1
+ import "../detect-CDtKsCsD.mjs";
2
+ import "../path-Dm-URQvz.mjs";
3
+ import "../clone-DgXhqC05.mjs";
4
+ import "../symlink-CbP-heyc.mjs";
5
+ import "../lock-CB9Xr9pv.mjs";
6
+ import { a as discoverSkills, c as extractSkillName, i as installSkill, l as parseSkillMd, n as uninstallSkill, o as filterSkills, r as toPromptXml, s as findSkillByName, t as validateSkill, u as validateSkillMd } from "../skill-BnKVgm4n.mjs";
7
+ import "../parse-CEbeorIB.mjs";
8
+
9
+ export { discoverSkills, extractSkillName, filterSkills, findSkillByName, installSkill, parseSkillMd, toPromptXml, uninstallSkill, validateSkill, validateSkillMd };
@@ -0,0 +1,358 @@
1
+ import { c as getAgentSkillsDir, m as getAgentConfig, r as detectInstalledAgents } from "./detect-CDtKsCsD.mjs";
2
+ import { t as expandPath } from "./path-Dm-URQvz.mjs";
3
+ import { a as isTempDir, i as cloneToTemp } from "./clone-DgXhqC05.mjs";
4
+ import { n as isSymlink, r as removeSymlink, s as copyDirectory, t as createSymlink } from "./symlink-CbP-heyc.mjs";
5
+ import { c as removeSkillFromLock, d as computeDirectoryHash, l as writeSkillLock, s as readSkillLock, t as addSkillToLock } from "./lock-CB9Xr9pv.mjs";
6
+ import { a as parseSource } from "./parse-CEbeorIB.mjs";
7
+ import { existsSync, readFileSync, readdirSync, rmSync, statSync } from "node:fs";
8
+ import { basename, join } from "pathe";
9
+ import { parse } from "yaml";
10
+
11
+ //#region src/skill/_frontmatter.ts
12
+ function parseFrontmatter(input) {
13
+ const match = input.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/);
14
+ if (!match) return {
15
+ data: {},
16
+ content: input.trim()
17
+ };
18
+ return {
19
+ data: parse(match[1]),
20
+ content: match[2].trim()
21
+ };
22
+ }
23
+
24
+ //#endregion
25
+ //#region src/skill/parse.ts
26
+ function parseSkillMd(content) {
27
+ const { data, content: body } = parseFrontmatter(content);
28
+ return {
29
+ frontmatter: data,
30
+ content: body,
31
+ raw: content
32
+ };
33
+ }
34
+ function extractSkillName(frontmatter, filename) {
35
+ if (frontmatter.name) return frontmatter.name;
36
+ if (filename) return filename.replace(/\.md$/i, "").replace(/^SKILL[._-]?/i, "").replace(/[._-]/g, " ").trim();
37
+ return "Unnamed Skill";
38
+ }
39
+ /** @deprecated Use validateSkill from './validate' for spec-compliant validation */
40
+ function validateSkillMd(parsed) {
41
+ const errors = [];
42
+ if (!parsed.content) errors.push("Skill content is empty");
43
+ if (parsed.frontmatter.globs) {
44
+ const globs = Array.isArray(parsed.frontmatter.globs) ? parsed.frontmatter.globs : [parsed.frontmatter.globs];
45
+ for (const glob of globs) if (typeof glob !== "string") errors.push(`Invalid glob pattern: ${glob}`);
46
+ }
47
+ return errors;
48
+ }
49
+
50
+ //#endregion
51
+ //#region src/skill/discover.ts
52
+ const SKILL_FILE = "SKILL.md";
53
+ function discoverSkills(dir, options = {}) {
54
+ const { recursive = false } = options;
55
+ if (!existsSync(dir)) return [];
56
+ const skills = [];
57
+ const entries = readdirSync(dir);
58
+ for (const entry of entries) {
59
+ const fullPath = join(dir, entry);
60
+ if (!statSync(fullPath).isDirectory()) continue;
61
+ const skillFile = join(fullPath, SKILL_FILE);
62
+ if (existsSync(skillFile)) try {
63
+ const parsed = parseSkillMd(readFileSync(skillFile, "utf-8"));
64
+ skills.push({
65
+ path: fullPath,
66
+ name: basename(fullPath),
67
+ parsed
68
+ });
69
+ } catch {}
70
+ else if (recursive) skills.push(...discoverSkills(fullPath, options));
71
+ }
72
+ return skills;
73
+ }
74
+ function filterSkills(skills, query) {
75
+ const lowerQuery = query.toLowerCase();
76
+ return skills.filter((skill) => {
77
+ const nameMatch = skill.name.toLowerCase().includes(lowerQuery);
78
+ const descMatch = skill.parsed.frontmatter.description?.toLowerCase().includes(lowerQuery);
79
+ const tagMatch = skill.parsed.frontmatter.tags?.some((tag) => tag.toLowerCase().includes(lowerQuery));
80
+ return nameMatch || descMatch || tagMatch;
81
+ });
82
+ }
83
+ function findSkillByName(skills, name) {
84
+ const lowerName = name.toLowerCase();
85
+ return skills.find((skill) => skill.name.toLowerCase() === lowerName);
86
+ }
87
+
88
+ //#endregion
89
+ //#region src/skill/resolve.ts
90
+ function resolveTargetAgents(agentIds) {
91
+ if (agentIds && agentIds.length > 0) return agentIds.map((id) => {
92
+ const config = getAgentConfig(id);
93
+ return config ? {
94
+ id,
95
+ config
96
+ } : null;
97
+ }).filter((a) => !!a);
98
+ return detectInstalledAgents().filter((d) => d.config.skillsDir).map((d) => ({
99
+ id: d.id,
100
+ config: d.config
101
+ }));
102
+ }
103
+
104
+ //#endregion
105
+ //#region src/skill/install.ts
106
+ const SKILL_NAME_PATTERN$1 = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;
107
+ async function installSkill(options) {
108
+ const { source, skills: skillNames, agents: agentIds, global: isGlobal = true, cwd = process.cwd(), mode = "symlink" } = options;
109
+ const installed = [];
110
+ const errors = [];
111
+ const parsed = parseSource(source);
112
+ let skillsDir;
113
+ let shouldCleanup = false;
114
+ if (parsed.isLocal) skillsDir = expandPath(parsed.raw);
115
+ else {
116
+ const result = cloneToTemp(parsed.type === "github" ? `https://github.com/${parsed.owner}/${parsed.repo}.git` : parsed.type === "gitlab" ? `https://gitlab.com/${parsed.owner}/${parsed.repo}.git` : parsed.url || parsed.raw, {
117
+ branch: parsed.ref,
118
+ depth: 1
119
+ });
120
+ if (!result.success) return {
121
+ success: false,
122
+ installed,
123
+ errors: [{
124
+ skill: "*",
125
+ agent: "*",
126
+ error: result.error || "Failed to clone"
127
+ }]
128
+ };
129
+ skillsDir = parsed.path ? join(result.path, parsed.path) : result.path;
130
+ shouldCleanup = true;
131
+ }
132
+ const discovered = discoverSkills(skillsDir, { recursive: true });
133
+ if (discovered.length === 0) {
134
+ if (shouldCleanup) cleanupTemp(skillsDir);
135
+ return {
136
+ success: false,
137
+ installed,
138
+ errors: [{
139
+ skill: "*",
140
+ agent: "*",
141
+ error: "No skills found in source"
142
+ }]
143
+ };
144
+ }
145
+ let targetSkills;
146
+ if (skillNames && skillNames.length > 0) {
147
+ targetSkills = skillNames.map((name) => findSkillByName(discovered, name)).filter((s) => !!s);
148
+ const notFound = skillNames.filter((name) => !targetSkills.some((s) => s.name === name));
149
+ for (const name of notFound) errors.push({
150
+ skill: name,
151
+ agent: "*",
152
+ error: "Skill not found in source"
153
+ });
154
+ } else targetSkills = discovered;
155
+ const targetAgents = resolveTargetAgents(agentIds);
156
+ if (targetAgents.length === 0) {
157
+ if (shouldCleanup) cleanupTemp(skillsDir);
158
+ return {
159
+ success: false,
160
+ installed,
161
+ errors: [{
162
+ skill: "*",
163
+ agent: "*",
164
+ error: "No agents found or specified"
165
+ }]
166
+ };
167
+ }
168
+ for (const skill of targetSkills) for (const agent of targetAgents) {
169
+ const result = installSkillToAgent(skill, agent, {
170
+ source: parsed.raw,
171
+ isGlobal,
172
+ cwd,
173
+ mode
174
+ });
175
+ if (result.success) installed.push({
176
+ skill: skill.name,
177
+ agent: agent.id,
178
+ path: result.path
179
+ });
180
+ else errors.push({
181
+ skill: skill.name,
182
+ agent: agent.id,
183
+ error: result.error
184
+ });
185
+ }
186
+ if (shouldCleanup) cleanupTemp(skillsDir);
187
+ return {
188
+ success: errors.length === 0,
189
+ installed,
190
+ errors
191
+ };
192
+ }
193
+ function installSkillToAgent(skill, agent, ctx) {
194
+ const skillsDir = getAgentSkillsDir(agent.config);
195
+ if (!skillsDir) return {
196
+ success: false,
197
+ error: `Agent ${agent.id} does not support skills`
198
+ };
199
+ if (!SKILL_NAME_PATTERN$1.test(skill.name) || skill.name.length > 64) return {
200
+ success: false,
201
+ error: `Invalid skill name: ${skill.name}`
202
+ };
203
+ const destPath = join(skillsDir, skill.name);
204
+ if (ctx.mode === "symlink") {
205
+ const result = createSymlink(skill.path, destPath, {
206
+ force: true,
207
+ relative: true
208
+ });
209
+ if (!result.success) return {
210
+ success: false,
211
+ error: result.error
212
+ };
213
+ } else {
214
+ const result = copyDirectory(skill.path, destPath, { force: true });
215
+ if (!result.success) return {
216
+ success: false,
217
+ error: result.error
218
+ };
219
+ }
220
+ const lock = readSkillLock(skillsDir);
221
+ const hash = computeDirectoryHash(skill.path) || "";
222
+ writeSkillLock(skillsDir, addSkillToLock(lock, skill.name, {
223
+ name: skill.name,
224
+ source: ctx.source,
225
+ hash
226
+ }));
227
+ return {
228
+ success: true,
229
+ path: destPath
230
+ };
231
+ }
232
+ function cleanupTemp(path) {
233
+ if (isTempDir(path)) try {
234
+ rmSync(path, {
235
+ recursive: true,
236
+ force: true
237
+ });
238
+ } catch {}
239
+ }
240
+
241
+ //#endregion
242
+ //#region src/skill/prompt.ts
243
+ function toPromptXml(skills) {
244
+ if (skills.length === 0) return "";
245
+ return `<available_skills>\n${skills.map((skill) => {
246
+ return ` <skill>
247
+ <name>${escapeXml(skill.name)}</name>
248
+ <description>${escapeXml(skill.parsed.frontmatter.description || "")}</description>
249
+ <location>${escapeXml(skill.path)}</location>
250
+ </skill>`;
251
+ }).join("\n")}\n</available_skills>`;
252
+ }
253
+ function escapeXml(str) {
254
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&apos;");
255
+ }
256
+
257
+ //#endregion
258
+ //#region src/skill/uninstall.ts
259
+ const SKILL_NAME_PATTERN = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;
260
+ async function uninstallSkill(options) {
261
+ const { skill: skillName, agents: agentIds } = options;
262
+ const removed = [];
263
+ const errors = [];
264
+ const targetAgents = resolveTargetAgents(agentIds);
265
+ if (targetAgents.length === 0) return {
266
+ success: false,
267
+ removed,
268
+ errors: [{
269
+ skill: skillName,
270
+ agent: "*",
271
+ error: "No agents found or specified"
272
+ }]
273
+ };
274
+ for (const agent of targetAgents) {
275
+ const result = uninstallSkillFromAgent(skillName, agent);
276
+ if (result.success) removed.push({
277
+ skill: skillName,
278
+ agent: agent.id,
279
+ path: result.path
280
+ });
281
+ else if (result.error !== "Skill not installed") errors.push({
282
+ skill: skillName,
283
+ agent: agent.id,
284
+ error: result.error
285
+ });
286
+ }
287
+ return {
288
+ success: errors.length === 0 && removed.length > 0,
289
+ removed,
290
+ errors
291
+ };
292
+ }
293
+ function uninstallSkillFromAgent(skillName, agent) {
294
+ const skillsDir = getAgentSkillsDir(agent.config);
295
+ if (!skillsDir) return {
296
+ success: false,
297
+ error: `Agent ${agent.id} does not support skills`
298
+ };
299
+ if (!SKILL_NAME_PATTERN.test(skillName) || skillName.length > 64) return {
300
+ success: false,
301
+ error: `Invalid skill name: ${skillName}`
302
+ };
303
+ const skillPath = join(skillsDir, skillName);
304
+ if (!existsSync(skillPath)) return {
305
+ success: false,
306
+ error: "Skill not installed"
307
+ };
308
+ if (isSymlink(skillPath)) {
309
+ if (!removeSymlink(skillPath)) return {
310
+ success: false,
311
+ error: "Failed to remove symlink"
312
+ };
313
+ } else try {
314
+ rmSync(skillPath, {
315
+ recursive: true,
316
+ force: true
317
+ });
318
+ } catch (e) {
319
+ return {
320
+ success: false,
321
+ error: e instanceof Error ? e.message : "Failed to remove directory"
322
+ };
323
+ }
324
+ writeSkillLock(skillsDir, removeSkillFromLock(readSkillLock(skillsDir), skillName));
325
+ return {
326
+ success: true,
327
+ path: skillPath
328
+ };
329
+ }
330
+
331
+ //#endregion
332
+ //#region src/skill/validate.ts
333
+ const NAME_PATTERN = /^[a-z][a-z0-9-]*[a-z0-9]$|^[a-z]$/;
334
+ function validateSkill(skill, dirName) {
335
+ const errors = [];
336
+ const warnings = [];
337
+ const { frontmatter, content } = skill;
338
+ if (!frontmatter.name) errors.push("name is required");
339
+ else {
340
+ const name = frontmatter.name;
341
+ if (name.length < 1 || name.length > 64) errors.push("name must be 1-64 characters");
342
+ if (!NAME_PATTERN.test(name)) errors.push("name must be lowercase letters, numbers, and hyphens; cannot start/end with hyphen");
343
+ if (name.includes("--")) errors.push("name cannot contain consecutive hyphens");
344
+ if (dirName && name !== dirName) errors.push(`name "${name}" must match directory name "${dirName}"`);
345
+ }
346
+ if (!frontmatter.description) errors.push("description is required");
347
+ else if (frontmatter.description.length < 1 || frontmatter.description.length > 1024) errors.push("description must be 1-1024 characters");
348
+ if (frontmatter.compatibility && frontmatter.compatibility.length > 500) errors.push("compatibility must be max 500 characters");
349
+ if (!content) warnings.push("skill content is empty");
350
+ return {
351
+ valid: errors.length === 0,
352
+ errors,
353
+ warnings
354
+ };
355
+ }
356
+
357
+ //#endregion
358
+ export { discoverSkills as a, extractSkillName as c, installSkill as i, parseSkillMd as l, uninstallSkill as n, filterSkills as o, toPromptXml as r, findSkillByName as s, validateSkill as t, validateSkillMd as u };
@@ -1,2 +1,2 @@
1
- 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";
1
+ 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-wTumcHrH.mjs";
2
2
  export { ParsedSource, ProviderInfo, SourceProvider, buildGitHubCloneUrl, buildGitLabCloneUrl, getOwnerRepo, getProviderFromUrl, isLocalPath, isUrl, parseGitHubUrl, parseGitLabUrl, parseOwnerRepo, parseSource };
@@ -1,3 +1,4 @@
1
- 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";
1
+ 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 "../parse-CEbeorIB.mjs";
2
+ import "../source-BCRylzkW.mjs";
2
3
 
3
4
  export { buildGitHubCloneUrl, buildGitLabCloneUrl, getOwnerRepo, getProviderFromUrl, isLocalPath, isUrl, parseGitHubUrl, parseGitLabUrl, parseOwnerRepo, parseSource };
@@ -0,0 +1 @@
1
+ export { };
@@ -0,0 +1,3 @@
1
+ import "../index-ucMWydcs.mjs";
2
+ import { a as not, c as tokenCountIs, i as iterationCountIs, n as and, o as or, r as costIs, s as timeout, t as StopCondition } from "../index-DpFup4kC.mjs";
3
+ export { StopCondition, and, costIs, iterationCountIs, not, or, timeout, tokenCountIs };