agentpacks 1.7.13 → 1.8.0
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/api.js +48 -3658
- package/dist/cli/export-cmd.js +7 -1027
- package/dist/cli/generate.js +39 -2731
- package/dist/cli/import-cmd.js +19 -770
- package/dist/cli/info.js +4 -231
- package/dist/cli/init.js +9 -185
- package/dist/cli/install.js +4 -902
- package/dist/cli/login.js +6 -201
- package/dist/cli/models-explain.js +14 -1266
- package/dist/cli/pack/create.js +4 -146
- package/dist/cli/pack/enable.js +2 -65
- package/dist/cli/pack/list.js +5 -893
- package/dist/cli/pack/validate.js +4 -642
- package/dist/cli/publish.js +8 -679
- package/dist/cli/search.js +4 -209
- package/dist/core/config.d.ts +1 -1
- package/dist/core/config.js +1 -145
- package/dist/core/dependency-resolver.js +1 -126
- package/dist/core/feature-merger.js +3 -398
- package/dist/core/index.js +5 -1129
- package/dist/core/lockfile.js +2 -43
- package/dist/core/metarepo.js +1 -183
- package/dist/core/pack-loader.js +4 -841
- package/dist/core/profile-resolver.js +1 -110
- package/dist/exporters/cursor-plugin.js +6 -404
- package/dist/exporters/index.js +6 -404
- package/dist/features/agents.js +3 -161
- package/dist/features/commands.js +3 -161
- package/dist/features/hooks.js +3 -153
- package/dist/features/ignore.js +2 -43
- package/dist/features/index.js +4 -629
- package/dist/features/mcp.js +3 -143
- package/dist/features/models.js +3 -292
- package/dist/features/plugins.js +3 -139
- package/dist/features/rules.d.ts +0 -1
- package/dist/features/rules.js +3 -169
- package/dist/features/skills.js +3 -228
- package/dist/importers/claude-code.js +6 -195
- package/dist/importers/cursor.js +5 -355
- package/dist/importers/opencode.js +6 -346
- package/dist/importers/rulesync.js +5 -365
- package/dist/index.js +89 -4934
- package/dist/node/api.js +48 -3659
- package/dist/node/cli/export-cmd.js +7 -1028
- package/dist/node/cli/generate.js +39 -2732
- package/dist/node/cli/import-cmd.js +19 -771
- package/dist/node/cli/info.js +4 -232
- package/dist/node/cli/init.js +9 -186
- package/dist/node/cli/install.js +4 -903
- package/dist/node/cli/login.js +6 -202
- package/dist/node/cli/models-explain.js +14 -1267
- package/dist/node/cli/pack/create.js +4 -147
- package/dist/node/cli/pack/enable.js +2 -66
- package/dist/node/cli/pack/list.js +5 -894
- package/dist/node/cli/pack/validate.js +4 -643
- package/dist/node/cli/publish.js +8 -680
- package/dist/node/cli/search.js +4 -210
- package/dist/node/core/config.js +1 -146
- package/dist/node/core/dependency-resolver.js +1 -127
- package/dist/node/core/feature-merger.js +3 -399
- package/dist/node/core/index.js +5 -1130
- package/dist/node/core/lockfile.js +2 -44
- package/dist/node/core/metarepo.js +1 -184
- package/dist/node/core/pack-loader.js +4 -842
- package/dist/node/core/profile-resolver.js +1 -111
- package/dist/node/exporters/cursor-plugin.js +6 -405
- package/dist/node/exporters/index.js +6 -405
- package/dist/node/features/agents.js +3 -162
- package/dist/node/features/commands.js +3 -162
- package/dist/node/features/hooks.js +3 -154
- package/dist/node/features/ignore.js +2 -44
- package/dist/node/features/index.js +4 -630
- package/dist/node/features/mcp.js +3 -144
- package/dist/node/features/models.js +3 -293
- package/dist/node/features/plugins.js +3 -140
- package/dist/node/features/rules.js +3 -170
- package/dist/node/features/skills.js +3 -229
- package/dist/node/importers/claude-code.js +6 -196
- package/dist/node/importers/cursor.js +5 -356
- package/dist/node/importers/opencode.js +6 -347
- package/dist/node/importers/rulesync.js +5 -366
- package/dist/node/index.js +89 -4935
- package/dist/node/sources/git-ref.js +1 -56
- package/dist/node/sources/git.js +2 -222
- package/dist/node/sources/index.js +4 -714
- package/dist/node/sources/local.js +1 -24
- package/dist/node/sources/npm-ref.js +1 -56
- package/dist/node/sources/npm.js +2 -184
- package/dist/node/sources/registry-ref.js +1 -37
- package/dist/node/sources/registry.js +4 -355
- package/dist/node/targets/additional-targets.js +6 -587
- package/dist/node/targets/base-target.js +1 -23
- package/dist/node/targets/claude-code.js +6 -714
- package/dist/node/targets/codex-cli.js +3 -324
- package/dist/node/targets/copilot.js +5 -603
- package/dist/node/targets/cursor.js +6 -700
- package/dist/node/targets/gemini-cli.js +10 -319
- package/dist/node/targets/generic-md-target.js +6 -478
- package/dist/node/targets/index.js +32 -1873
- package/dist/node/targets/mistral-vibe.js +7 -661
- package/dist/node/targets/opencode.js +13 -723
- package/dist/node/targets/registry.js +32 -1864
- package/dist/node/utils/credentials.js +3 -38
- package/dist/node/utils/diff.js +5 -132
- package/dist/node/utils/filesystem.js +3 -124
- package/dist/node/utils/frontmatter.js +1 -24
- package/dist/node/utils/global.js +1 -53
- package/dist/node/utils/markdown.js +3 -30
- package/dist/node/utils/model-allowlist.js +1 -126
- package/dist/node/utils/model-guidance.js +2 -78
- package/dist/node/utils/registry-client.js +1 -142
- package/dist/node/utils/tarball.js +1 -49
- package/dist/sources/git-ref.js +1 -55
- package/dist/sources/git.js +2 -221
- package/dist/sources/index.js +4 -713
- package/dist/sources/local.js +1 -23
- package/dist/sources/npm-ref.js +1 -55
- package/dist/sources/npm.js +2 -183
- package/dist/sources/registry-ref.js +1 -36
- package/dist/sources/registry.js +4 -354
- package/dist/targets/additional-targets.js +6 -586
- package/dist/targets/base-target.js +1 -22
- package/dist/targets/claude-code.js +6 -713
- package/dist/targets/codex-cli.js +3 -323
- package/dist/targets/copilot.js +5 -602
- package/dist/targets/cursor.js +6 -699
- package/dist/targets/gemini-cli.js +10 -318
- package/dist/targets/generic-md-target.js +6 -477
- package/dist/targets/index.d.ts +0 -1
- package/dist/targets/index.js +32 -1872
- package/dist/targets/mistral-vibe.js +7 -660
- package/dist/targets/opencode.js +13 -722
- package/dist/targets/registry.js +32 -1863
- package/dist/utils/credentials.js +3 -37
- package/dist/utils/diff.js +5 -131
- package/dist/utils/filesystem.js +3 -123
- package/dist/utils/frontmatter.js +1 -23
- package/dist/utils/global.js +1 -52
- package/dist/utils/markdown.js +3 -29
- package/dist/utils/model-allowlist.js +1 -125
- package/dist/utils/model-guidance.js +2 -77
- package/dist/utils/registry-client.js +1 -141
- package/dist/utils/tarball.js +1 -48
- package/package.json +4 -16
- package/dist/node/targets/agents-md.js +0 -211
- package/dist/targets/agents-md.d.ts +0 -13
- package/dist/targets/agents-md.js +0 -211
|
@@ -1,144 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// src/utils/filesystem.ts
|
|
5
|
-
import {
|
|
6
|
-
existsSync,
|
|
7
|
-
mkdirSync,
|
|
8
|
-
readdirSync,
|
|
9
|
-
readFileSync,
|
|
10
|
-
rmSync,
|
|
11
|
-
statSync,
|
|
12
|
-
writeFileSync
|
|
13
|
-
} from "fs";
|
|
14
|
-
import { dirname, join, relative } from "path";
|
|
15
|
-
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
16
|
-
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
17
|
-
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
18
|
-
function writeGeneratedFile(filepath, content, options = {}) {
|
|
19
|
-
const { header = true, type } = options;
|
|
20
|
-
const ext = type ?? inferFileType(filepath);
|
|
21
|
-
ensureDir(dirname(filepath));
|
|
22
|
-
let output = content;
|
|
23
|
-
if (header) {
|
|
24
|
-
const headerComment = getHeader(ext);
|
|
25
|
-
if (headerComment) {
|
|
26
|
-
output = `${headerComment}
|
|
27
|
-
${content}`;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
writeFileSync(filepath, output, "utf-8");
|
|
31
|
-
}
|
|
32
|
-
function writeGeneratedJson(filepath, data, options = {}) {
|
|
33
|
-
const json = JSON.stringify(data, null, 2);
|
|
34
|
-
writeGeneratedFile(filepath, json + `
|
|
35
|
-
`, { ...options, type: "json" });
|
|
36
|
-
}
|
|
37
|
-
function readFileOrNull(filepath) {
|
|
38
|
-
if (!existsSync(filepath))
|
|
39
|
-
return null;
|
|
40
|
-
return readFileSync(filepath, "utf-8");
|
|
41
|
-
}
|
|
42
|
-
function readJsonOrNull(filepath) {
|
|
43
|
-
const content = readFileOrNull(filepath);
|
|
44
|
-
if (content === null)
|
|
45
|
-
return null;
|
|
46
|
-
return JSON.parse(content);
|
|
47
|
-
}
|
|
48
|
-
function ensureDir(dirPath) {
|
|
49
|
-
if (!existsSync(dirPath)) {
|
|
50
|
-
mkdirSync(dirPath, { recursive: true });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function removeIfExists(targetPath) {
|
|
54
|
-
if (existsSync(targetPath)) {
|
|
55
|
-
rmSync(targetPath, { recursive: true, force: true });
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function listFiles(dirPath, options = {}) {
|
|
59
|
-
const { extension, recursive = false } = options;
|
|
60
|
-
if (!existsSync(dirPath))
|
|
61
|
-
return [];
|
|
62
|
-
const results = [];
|
|
63
|
-
const entries = readdirSync(dirPath);
|
|
64
|
-
for (const entry of entries) {
|
|
65
|
-
const fullPath = join(dirPath, entry);
|
|
66
|
-
const stat = statSync(fullPath);
|
|
67
|
-
if (stat.isDirectory() && recursive) {
|
|
68
|
-
results.push(...listFiles(fullPath, options));
|
|
69
|
-
} else if (stat.isFile()) {
|
|
70
|
-
if (!extension || entry.endsWith(extension)) {
|
|
71
|
-
results.push(fullPath);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return results;
|
|
76
|
-
}
|
|
77
|
-
function listDirs(dirPath) {
|
|
78
|
-
if (!existsSync(dirPath))
|
|
79
|
-
return [];
|
|
80
|
-
return readdirSync(dirPath).map((entry) => join(dirPath, entry)).filter((fullPath) => statSync(fullPath).isDirectory());
|
|
81
|
-
}
|
|
82
|
-
function relPath(projectRoot, filepath) {
|
|
83
|
-
return relative(projectRoot, filepath);
|
|
84
|
-
}
|
|
85
|
-
function isGeneratedFile(filepath) {
|
|
86
|
-
const content = readFileOrNull(filepath);
|
|
87
|
-
if (!content)
|
|
88
|
-
return false;
|
|
89
|
-
return content.startsWith(GENERATED_HEADER_MD) || content.startsWith(GENERATED_HEADER_JSON) || content.startsWith(GENERATED_HEADER_JS);
|
|
90
|
-
}
|
|
91
|
-
function inferFileType(filepath) {
|
|
92
|
-
if (filepath.endsWith(".json") || filepath.endsWith(".jsonc"))
|
|
93
|
-
return "json";
|
|
94
|
-
if (filepath.endsWith(".ts") || filepath.endsWith(".mts"))
|
|
95
|
-
return "ts";
|
|
96
|
-
if (filepath.endsWith(".js") || filepath.endsWith(".mjs"))
|
|
97
|
-
return "js";
|
|
98
|
-
return "md";
|
|
99
|
-
}
|
|
100
|
-
function getHeader(type) {
|
|
101
|
-
switch (type) {
|
|
102
|
-
case "md":
|
|
103
|
-
return GENERATED_HEADER_MD;
|
|
104
|
-
case "json":
|
|
105
|
-
return GENERATED_HEADER_JSON;
|
|
106
|
-
case "js":
|
|
107
|
-
case "ts":
|
|
108
|
-
return GENERATED_HEADER_JS;
|
|
109
|
-
default:
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// src/features/mcp.ts
|
|
115
|
-
import { join as join2 } from "path";
|
|
116
|
-
function parseMcp(packDir, packName) {
|
|
117
|
-
const mcpPath = join2(packDir, "mcp.json");
|
|
118
|
-
const raw = readJsonOrNull(mcpPath);
|
|
119
|
-
if (!raw?.mcpServers)
|
|
120
|
-
return null;
|
|
121
|
-
return {
|
|
122
|
-
packName,
|
|
123
|
-
sourcePath: mcpPath,
|
|
124
|
-
servers: raw.mcpServers
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
function mergeMcpConfigs(configs) {
|
|
128
|
-
const servers = {};
|
|
129
|
-
const warnings = [];
|
|
130
|
-
for (const config of configs) {
|
|
131
|
-
for (const [name, entry] of Object.entries(config.servers)) {
|
|
132
|
-
if (name in servers) {
|
|
133
|
-
warnings.push(`MCP server "${name}" from pack "${config.packName}" skipped (already defined).`);
|
|
134
|
-
continue;
|
|
135
|
-
}
|
|
136
|
-
servers[name] = entry;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return { servers, warnings };
|
|
140
|
-
}
|
|
141
|
-
export {
|
|
142
|
-
parseMcp,
|
|
143
|
-
mergeMcpConfigs
|
|
144
|
-
};
|
|
1
|
+
import{createRequire as O}from"node:module";var g=O(import.meta.url);import{existsSync as V,mkdirSync as v,readdirSync as X,readFileSync as j,rmSync as w,statSync as Y,writeFileSync as G}from"fs";import{dirname as H,join as Z,relative as T}from"path";var $="<!-- Generated by agentpacks. DO NOT EDIT. -->",b="// Generated by agentpacks. DO NOT EDIT.",C="// Generated by agentpacks. DO NOT EDIT.";function k(q,z,B={}){let{header:I=!0,type:K}=B,Q=K??A(q);x(H(q));let U=z;if(I){let L=_(Q);if(L)U=`${L}
|
|
2
|
+
${z}`}G(q,U,"utf-8")}function u(q,z,B={}){let I=JSON.stringify(z,null,2);k(q,I+`
|
|
3
|
+
`,{...B,type:"json"})}function M(q){if(!V(q))return null;return j(q,"utf-8")}function J(q){let z=M(q);if(z===null)return null;return JSON.parse(z)}function x(q){if(!V(q))v(q,{recursive:!0})}function y(q){if(V(q))w(q,{recursive:!0,force:!0})}function F(q,z={}){let{extension:B,recursive:I=!1}=z;if(!V(q))return[];let K=[],Q=X(q);for(let U of Q){let L=Z(q,U),W=Y(L);if(W.isDirectory()&&I)K.push(...F(L,z));else if(W.isFile()){if(!B||U.endsWith(B))K.push(L)}}return K}function P(q){if(!V(q))return[];return X(q).map((z)=>Z(q,z)).filter((z)=>Y(z).isDirectory())}function E(q,z){return T(q,z)}function d(q){let z=M(q);if(!z)return!1;return z.startsWith($)||z.startsWith(b)||z.startsWith(C)}function A(q){if(q.endsWith(".json")||q.endsWith(".jsonc"))return"json";if(q.endsWith(".ts")||q.endsWith(".mts"))return"ts";if(q.endsWith(".js")||q.endsWith(".mjs"))return"js";return"md"}function _(q){switch(q){case"md":return $;case"json":return b;case"js":case"ts":return C;default:return null}}import{join as N}from"path";function p(q,z){let B=N(q,"mcp.json"),I=J(B);if(!I?.mcpServers)return null;return{packName:z,sourcePath:B,servers:I.mcpServers}}function s(q){let z={},B=[];for(let I of q)for(let[K,Q]of Object.entries(I.servers)){if(K in z){B.push(`MCP server "${K}" from pack "${I.packName}" skipped (already defined).`);continue}z[K]=Q}return{servers:z,warnings:B}}export{p as parseMcp,s as mergeMcpConfigs};
|
|
@@ -1,293 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// src/utils/filesystem.ts
|
|
5
|
-
import {
|
|
6
|
-
existsSync,
|
|
7
|
-
mkdirSync,
|
|
8
|
-
readdirSync,
|
|
9
|
-
readFileSync,
|
|
10
|
-
rmSync,
|
|
11
|
-
statSync,
|
|
12
|
-
writeFileSync
|
|
13
|
-
} from "fs";
|
|
14
|
-
import { dirname, join, relative } from "path";
|
|
15
|
-
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
16
|
-
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
17
|
-
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
18
|
-
function writeGeneratedFile(filepath, content, options = {}) {
|
|
19
|
-
const { header = true, type } = options;
|
|
20
|
-
const ext = type ?? inferFileType(filepath);
|
|
21
|
-
ensureDir(dirname(filepath));
|
|
22
|
-
let output = content;
|
|
23
|
-
if (header) {
|
|
24
|
-
const headerComment = getHeader(ext);
|
|
25
|
-
if (headerComment) {
|
|
26
|
-
output = `${headerComment}
|
|
27
|
-
${content}`;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
writeFileSync(filepath, output, "utf-8");
|
|
31
|
-
}
|
|
32
|
-
function writeGeneratedJson(filepath, data, options = {}) {
|
|
33
|
-
const json = JSON.stringify(data, null, 2);
|
|
34
|
-
writeGeneratedFile(filepath, json + `
|
|
35
|
-
`, { ...options, type: "json" });
|
|
36
|
-
}
|
|
37
|
-
function readFileOrNull(filepath) {
|
|
38
|
-
if (!existsSync(filepath))
|
|
39
|
-
return null;
|
|
40
|
-
return readFileSync(filepath, "utf-8");
|
|
41
|
-
}
|
|
42
|
-
function readJsonOrNull(filepath) {
|
|
43
|
-
const content = readFileOrNull(filepath);
|
|
44
|
-
if (content === null)
|
|
45
|
-
return null;
|
|
46
|
-
return JSON.parse(content);
|
|
47
|
-
}
|
|
48
|
-
function ensureDir(dirPath) {
|
|
49
|
-
if (!existsSync(dirPath)) {
|
|
50
|
-
mkdirSync(dirPath, { recursive: true });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function removeIfExists(targetPath) {
|
|
54
|
-
if (existsSync(targetPath)) {
|
|
55
|
-
rmSync(targetPath, { recursive: true, force: true });
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function listFiles(dirPath, options = {}) {
|
|
59
|
-
const { extension, recursive = false } = options;
|
|
60
|
-
if (!existsSync(dirPath))
|
|
61
|
-
return [];
|
|
62
|
-
const results = [];
|
|
63
|
-
const entries = readdirSync(dirPath);
|
|
64
|
-
for (const entry of entries) {
|
|
65
|
-
const fullPath = join(dirPath, entry);
|
|
66
|
-
const stat = statSync(fullPath);
|
|
67
|
-
if (stat.isDirectory() && recursive) {
|
|
68
|
-
results.push(...listFiles(fullPath, options));
|
|
69
|
-
} else if (stat.isFile()) {
|
|
70
|
-
if (!extension || entry.endsWith(extension)) {
|
|
71
|
-
results.push(fullPath);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return results;
|
|
76
|
-
}
|
|
77
|
-
function listDirs(dirPath) {
|
|
78
|
-
if (!existsSync(dirPath))
|
|
79
|
-
return [];
|
|
80
|
-
return readdirSync(dirPath).map((entry) => join(dirPath, entry)).filter((fullPath) => statSync(fullPath).isDirectory());
|
|
81
|
-
}
|
|
82
|
-
function relPath(projectRoot, filepath) {
|
|
83
|
-
return relative(projectRoot, filepath);
|
|
84
|
-
}
|
|
85
|
-
function isGeneratedFile(filepath) {
|
|
86
|
-
const content = readFileOrNull(filepath);
|
|
87
|
-
if (!content)
|
|
88
|
-
return false;
|
|
89
|
-
return content.startsWith(GENERATED_HEADER_MD) || content.startsWith(GENERATED_HEADER_JSON) || content.startsWith(GENERATED_HEADER_JS);
|
|
90
|
-
}
|
|
91
|
-
function inferFileType(filepath) {
|
|
92
|
-
if (filepath.endsWith(".json") || filepath.endsWith(".jsonc"))
|
|
93
|
-
return "json";
|
|
94
|
-
if (filepath.endsWith(".ts") || filepath.endsWith(".mts"))
|
|
95
|
-
return "ts";
|
|
96
|
-
if (filepath.endsWith(".js") || filepath.endsWith(".mjs"))
|
|
97
|
-
return "js";
|
|
98
|
-
return "md";
|
|
99
|
-
}
|
|
100
|
-
function getHeader(type) {
|
|
101
|
-
switch (type) {
|
|
102
|
-
case "md":
|
|
103
|
-
return GENERATED_HEADER_MD;
|
|
104
|
-
case "json":
|
|
105
|
-
return GENERATED_HEADER_JSON;
|
|
106
|
-
case "js":
|
|
107
|
-
case "ts":
|
|
108
|
-
return GENERATED_HEADER_JS;
|
|
109
|
-
default:
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// src/features/models.ts
|
|
115
|
-
import { join as join2 } from "path";
|
|
116
|
-
import { z } from "zod";
|
|
117
|
-
var SECRET_PATTERNS = [
|
|
118
|
-
/["']api[_-]?key["']\s*:/i,
|
|
119
|
-
/["']apiKey["']\s*:/i,
|
|
120
|
-
/["']secret["']\s*:/i,
|
|
121
|
-
/["']password["']\s*:/i,
|
|
122
|
-
/["'](?:auth_token|access_token|bearer_token)["']\s*:/i,
|
|
123
|
-
/["']private[_-]?key["']\s*:/i,
|
|
124
|
-
/-----BEGIN\s+(RSA|EC|DSA|OPENSSH|PGP)\s+PRIVATE\s+KEY-----/,
|
|
125
|
-
/sk-[a-zA-Z0-9]{20,}/,
|
|
126
|
-
/Bearer\s+[a-zA-Z0-9._-]{20,}/
|
|
127
|
-
];
|
|
128
|
-
var AgentModelSchema = z.object({
|
|
129
|
-
model: z.string(),
|
|
130
|
-
temperature: z.number().min(0).max(2).optional(),
|
|
131
|
-
top_p: z.number().min(0).max(1).optional()
|
|
132
|
-
});
|
|
133
|
-
var ModelProfileSchema = z.object({
|
|
134
|
-
extends: z.string().optional(),
|
|
135
|
-
description: z.string().optional(),
|
|
136
|
-
default: z.string().optional(),
|
|
137
|
-
small: z.string().optional(),
|
|
138
|
-
agents: z.record(z.string(), AgentModelSchema).optional()
|
|
139
|
-
});
|
|
140
|
-
var RoutingConditionSchema = z.object({
|
|
141
|
-
complexity: z.enum(["low", "medium", "high", "critical"]).optional().describe("Task complexity level"),
|
|
142
|
-
urgency: z.enum(["low", "normal", "high"]).optional().describe("Time sensitivity"),
|
|
143
|
-
budget: z.enum(["minimal", "standard", "premium"]).optional().describe("Cost/token budget tier"),
|
|
144
|
-
contextWindowNeed: z.enum(["small", "medium", "large", "max"]).optional().describe("Required context window size"),
|
|
145
|
-
toolUseIntensity: z.enum(["none", "light", "heavy"]).optional().describe("Expected tool/function calling intensity")
|
|
146
|
-
});
|
|
147
|
-
var RoutingRuleSchema = z.object({
|
|
148
|
-
when: z.record(z.string(), z.string()),
|
|
149
|
-
use: z.string(),
|
|
150
|
-
description: z.string().optional(),
|
|
151
|
-
priority: z.number().optional()
|
|
152
|
-
});
|
|
153
|
-
var ProviderModelSchema = z.object({
|
|
154
|
-
options: z.record(z.string(), z.unknown()).optional(),
|
|
155
|
-
variants: z.record(z.string(), z.record(z.string(), z.unknown())).optional()
|
|
156
|
-
});
|
|
157
|
-
var ProviderConfigSchema = z.object({
|
|
158
|
-
options: z.record(z.string(), z.unknown()).optional(),
|
|
159
|
-
models: z.record(z.string(), ProviderModelSchema).optional()
|
|
160
|
-
});
|
|
161
|
-
var ModelsSchema = z.object({
|
|
162
|
-
default: z.string().optional(),
|
|
163
|
-
small: z.string().optional(),
|
|
164
|
-
agents: z.record(z.string(), AgentModelSchema).optional(),
|
|
165
|
-
profiles: z.record(z.string(), ModelProfileSchema).optional(),
|
|
166
|
-
providers: z.record(z.string(), ProviderConfigSchema).optional(),
|
|
167
|
-
routing: z.array(RoutingRuleSchema).optional(),
|
|
168
|
-
overrides: z.record(z.string(), z.object({
|
|
169
|
-
default: z.string().optional(),
|
|
170
|
-
small: z.string().optional(),
|
|
171
|
-
agents: z.record(z.string(), AgentModelSchema).optional()
|
|
172
|
-
})).optional()
|
|
173
|
-
});
|
|
174
|
-
function parseModels(packDir, packName) {
|
|
175
|
-
const modelsPath = join2(packDir, "models.json");
|
|
176
|
-
const raw = readJsonOrNull(modelsPath);
|
|
177
|
-
if (!raw)
|
|
178
|
-
return null;
|
|
179
|
-
const parsed = ModelsSchema.parse(raw);
|
|
180
|
-
return {
|
|
181
|
-
packName,
|
|
182
|
-
sourcePath: modelsPath,
|
|
183
|
-
config: parsed
|
|
184
|
-
};
|
|
185
|
-
}
|
|
186
|
-
function mergeModelsConfigs(configs) {
|
|
187
|
-
const warnings = [];
|
|
188
|
-
const result = {};
|
|
189
|
-
for (const entry of configs) {
|
|
190
|
-
const { config, packName } = entry;
|
|
191
|
-
if (config.default !== undefined && result.default === undefined) {
|
|
192
|
-
result.default = config.default;
|
|
193
|
-
} else if (config.default !== undefined && result.default !== undefined) {
|
|
194
|
-
warnings.push(`Models "default" from pack "${packName}" skipped (already defined).`);
|
|
195
|
-
}
|
|
196
|
-
if (config.small !== undefined && result.small === undefined) {
|
|
197
|
-
result.small = config.small;
|
|
198
|
-
} else if (config.small !== undefined && result.small !== undefined) {
|
|
199
|
-
warnings.push(`Models "small" from pack "${packName}" skipped (already defined).`);
|
|
200
|
-
}
|
|
201
|
-
if (config.agents) {
|
|
202
|
-
if (!result.agents)
|
|
203
|
-
result.agents = {};
|
|
204
|
-
for (const [name, assignment] of Object.entries(config.agents)) {
|
|
205
|
-
if (name in result.agents) {
|
|
206
|
-
warnings.push(`Models agent "${name}" from pack "${packName}" skipped (already defined).`);
|
|
207
|
-
continue;
|
|
208
|
-
}
|
|
209
|
-
result.agents[name] = assignment;
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
if (config.profiles) {
|
|
213
|
-
if (!result.profiles)
|
|
214
|
-
result.profiles = {};
|
|
215
|
-
for (const [name, profile] of Object.entries(config.profiles)) {
|
|
216
|
-
if (name in result.profiles) {
|
|
217
|
-
warnings.push(`Models profile "${name}" from pack "${packName}" skipped (already defined).`);
|
|
218
|
-
continue;
|
|
219
|
-
}
|
|
220
|
-
result.profiles[name] = profile;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
if (config.providers) {
|
|
224
|
-
if (!result.providers)
|
|
225
|
-
result.providers = {};
|
|
226
|
-
for (const [providerName, providerConfig] of Object.entries(config.providers)) {
|
|
227
|
-
if (!(providerName in result.providers)) {
|
|
228
|
-
result.providers[providerName] = providerConfig;
|
|
229
|
-
} else {
|
|
230
|
-
const existing = result.providers[providerName];
|
|
231
|
-
if (!existing) {
|
|
232
|
-
result.providers[providerName] = providerConfig;
|
|
233
|
-
continue;
|
|
234
|
-
}
|
|
235
|
-
if (providerConfig.options) {
|
|
236
|
-
existing.options = {
|
|
237
|
-
...providerConfig.options,
|
|
238
|
-
...existing.options
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
-
if (providerConfig.models) {
|
|
242
|
-
if (!existing.models)
|
|
243
|
-
existing.models = {};
|
|
244
|
-
for (const [modelName, modelConfig] of Object.entries(providerConfig.models)) {
|
|
245
|
-
if (!(modelName in existing.models)) {
|
|
246
|
-
existing.models[modelName] = modelConfig;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
if (config.routing) {
|
|
254
|
-
if (!result.routing)
|
|
255
|
-
result.routing = [];
|
|
256
|
-
result.routing.push(...config.routing);
|
|
257
|
-
}
|
|
258
|
-
if (config.overrides) {
|
|
259
|
-
if (!result.overrides)
|
|
260
|
-
result.overrides = {};
|
|
261
|
-
for (const [targetId, override] of Object.entries(config.overrides)) {
|
|
262
|
-
if (targetId in result.overrides) {
|
|
263
|
-
warnings.push(`Models override for target "${targetId}" from pack "${packName}" skipped (already defined).`);
|
|
264
|
-
continue;
|
|
265
|
-
}
|
|
266
|
-
result.overrides[targetId] = override;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
return { config: result, warnings };
|
|
271
|
-
}
|
|
272
|
-
function scanModelsForSecrets(config) {
|
|
273
|
-
const warnings = [];
|
|
274
|
-
const json = JSON.stringify(config);
|
|
275
|
-
for (const pattern of SECRET_PATTERNS) {
|
|
276
|
-
if (pattern.test(json)) {
|
|
277
|
-
warnings.push(`Potential secret detected in models.json matching pattern: ${pattern.source}`);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
return warnings;
|
|
281
|
-
}
|
|
282
|
-
export {
|
|
283
|
-
scanModelsForSecrets,
|
|
284
|
-
parseModels,
|
|
285
|
-
mergeModelsConfigs,
|
|
286
|
-
RoutingRuleSchema,
|
|
287
|
-
RoutingConditionSchema,
|
|
288
|
-
ProviderModelSchema,
|
|
289
|
-
ProviderConfigSchema,
|
|
290
|
-
ModelsSchema,
|
|
291
|
-
ModelProfileSchema,
|
|
292
|
-
AgentModelSchema
|
|
293
|
-
};
|
|
1
|
+
import{createRequire as k}from"node:module";var p=k(import.meta.url);import{existsSync as Z,mkdirSync as C,readdirSync as I,readFileSync as w,rmSync as _,statSync as J,writeFileSync as v}from"fs";import{dirname as x,join as O,relative as A}from"path";var F="<!-- Generated by agentpacks. DO NOT EDIT. -->",G="// Generated by agentpacks. DO NOT EDIT.",H="// Generated by agentpacks. DO NOT EDIT.";function D(B,L,K={}){let{header:W=!0,type:Q}=K,Y=Q??N(B);R(x(B));let U=L;if(W){let V=S(Y);if(V)U=`${V}
|
|
2
|
+
${L}`}v(B,U,"utf-8")}function l(B,L,K={}){let W=JSON.stringify(L,null,2);D(B,W+`
|
|
3
|
+
`,{...K,type:"json"})}function j(B){if(!Z(B))return null;return w(B,"utf-8")}function M(B){let L=j(B);if(L===null)return null;return JSON.parse(L)}function R(B){if(!Z(B))C(B,{recursive:!0})}function o(B){if(Z(B))_(B,{recursive:!0,force:!0})}function y(B,L={}){let{extension:K,recursive:W=!1}=L;if(!Z(B))return[];let Q=[],Y=I(B);for(let U of Y){let V=O(B,U),X=J(V);if(X.isDirectory()&&W)Q.push(...y(V,L));else if(X.isFile()){if(!K||U.endsWith(K))Q.push(V)}}return Q}function n(B){if(!Z(B))return[];return I(B).map((L)=>O(B,L)).filter((L)=>J(L).isDirectory())}function r(B,L){return A(B,L)}function a(B){let L=j(B);if(!L)return!1;return L.startsWith(F)||L.startsWith(G)||L.startsWith(H)}function N(B){if(B.endsWith(".json")||B.endsWith(".jsonc"))return"json";if(B.endsWith(".ts")||B.endsWith(".mts"))return"ts";if(B.endsWith(".js")||B.endsWith(".mjs"))return"js";return"md"}function S(B){switch(B){case"md":return F;case"json":return G;case"js":case"ts":return H;default:return null}}import{join as P}from"path";import{z as q}from"zod";var E=[/["']api[_-]?key["']\s*:/i,/["']apiKey["']\s*:/i,/["']secret["']\s*:/i,/["']password["']\s*:/i,/["'](?:auth_token|access_token|bearer_token)["']\s*:/i,/["']private[_-]?key["']\s*:/i,/-----BEGIN\s+(RSA|EC|DSA|OPENSSH|PGP)\s+PRIVATE\s+KEY-----/,/sk-[a-zA-Z0-9]{20,}/,/Bearer\s+[a-zA-Z0-9._-]{20,}/],$=q.object({model:q.string(),temperature:q.number().min(0).max(2).optional(),top_p:q.number().min(0).max(1).optional()}),m=q.object({extends:q.string().optional(),description:q.string().optional(),default:q.string().optional(),small:q.string().optional(),agents:q.record(q.string(),$).optional()}),Bq=q.object({complexity:q.enum(["low","medium","high","critical"]).optional().describe("Task complexity level"),urgency:q.enum(["low","normal","high"]).optional().describe("Time sensitivity"),budget:q.enum(["minimal","standard","premium"]).optional().describe("Cost/token budget tier"),contextWindowNeed:q.enum(["small","medium","large","max"]).optional().describe("Required context window size"),toolUseIntensity:q.enum(["none","light","heavy"]).optional().describe("Expected tool/function calling intensity")}),u=q.object({when:q.record(q.string(),q.string()),use:q.string(),description:q.string().optional(),priority:q.number().optional()}),z=q.object({options:q.record(q.string(),q.unknown()).optional(),variants:q.record(q.string(),q.record(q.string(),q.unknown())).optional()}),g=q.object({options:q.record(q.string(),q.unknown()).optional(),models:q.record(q.string(),z).optional()}),d=q.object({default:q.string().optional(),small:q.string().optional(),agents:q.record(q.string(),$).optional(),profiles:q.record(q.string(),m).optional(),providers:q.record(q.string(),g).optional(),routing:q.array(u).optional(),overrides:q.record(q.string(),q.object({default:q.string().optional(),small:q.string().optional(),agents:q.record(q.string(),$).optional()})).optional()});function Kq(B,L){let K=P(B,"models.json"),W=M(K);if(!W)return null;let Q=d.parse(W);return{packName:L,sourcePath:K,config:Q}}function Lq(B){let L=[],K={};for(let W of B){let{config:Q,packName:Y}=W;if(Q.default!==void 0&&K.default===void 0)K.default=Q.default;else if(Q.default!==void 0&&K.default!==void 0)L.push(`Models "default" from pack "${Y}" skipped (already defined).`);if(Q.small!==void 0&&K.small===void 0)K.small=Q.small;else if(Q.small!==void 0&&K.small!==void 0)L.push(`Models "small" from pack "${Y}" skipped (already defined).`);if(Q.agents){if(!K.agents)K.agents={};for(let[U,V]of Object.entries(Q.agents)){if(U in K.agents){L.push(`Models agent "${U}" from pack "${Y}" skipped (already defined).`);continue}K.agents[U]=V}}if(Q.profiles){if(!K.profiles)K.profiles={};for(let[U,V]of Object.entries(Q.profiles)){if(U in K.profiles){L.push(`Models profile "${U}" from pack "${Y}" skipped (already defined).`);continue}K.profiles[U]=V}}if(Q.providers){if(!K.providers)K.providers={};for(let[U,V]of Object.entries(Q.providers))if(!(U in K.providers))K.providers[U]=V;else{let X=K.providers[U];if(!X){K.providers[U]=V;continue}if(V.options)X.options={...V.options,...X.options};if(V.models){if(!X.models)X.models={};for(let[b,T]of Object.entries(V.models))if(!(b in X.models))X.models[b]=T}}}if(Q.routing){if(!K.routing)K.routing=[];K.routing.push(...Q.routing)}if(Q.overrides){if(!K.overrides)K.overrides={};for(let[U,V]of Object.entries(Q.overrides)){if(U in K.overrides){L.push(`Models override for target "${U}" from pack "${Y}" skipped (already defined).`);continue}K.overrides[U]=V}}}return{config:K,warnings:L}}function Qq(B){let L=[],K=JSON.stringify(B);for(let W of E)if(W.test(K))L.push(`Potential secret detected in models.json matching pattern: ${W.source}`);return L}export{Qq as scanModelsForSecrets,Kq as parseModels,Lq as mergeModelsConfigs,u as RoutingRuleSchema,Bq as RoutingConditionSchema,z as ProviderModelSchema,g as ProviderConfigSchema,d as ModelsSchema,m as ModelProfileSchema,$ as AgentModelSchema};
|
|
@@ -1,140 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// src/utils/filesystem.ts
|
|
5
|
-
import {
|
|
6
|
-
existsSync,
|
|
7
|
-
mkdirSync,
|
|
8
|
-
readdirSync,
|
|
9
|
-
readFileSync,
|
|
10
|
-
rmSync,
|
|
11
|
-
statSync,
|
|
12
|
-
writeFileSync
|
|
13
|
-
} from "fs";
|
|
14
|
-
import { dirname, join, relative } from "path";
|
|
15
|
-
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
16
|
-
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
17
|
-
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
18
|
-
function writeGeneratedFile(filepath, content, options = {}) {
|
|
19
|
-
const { header = true, type } = options;
|
|
20
|
-
const ext = type ?? inferFileType(filepath);
|
|
21
|
-
ensureDir(dirname(filepath));
|
|
22
|
-
let output = content;
|
|
23
|
-
if (header) {
|
|
24
|
-
const headerComment = getHeader(ext);
|
|
25
|
-
if (headerComment) {
|
|
26
|
-
output = `${headerComment}
|
|
27
|
-
${content}`;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
writeFileSync(filepath, output, "utf-8");
|
|
31
|
-
}
|
|
32
|
-
function writeGeneratedJson(filepath, data, options = {}) {
|
|
33
|
-
const json = JSON.stringify(data, null, 2);
|
|
34
|
-
writeGeneratedFile(filepath, json + `
|
|
35
|
-
`, { ...options, type: "json" });
|
|
36
|
-
}
|
|
37
|
-
function readFileOrNull(filepath) {
|
|
38
|
-
if (!existsSync(filepath))
|
|
39
|
-
return null;
|
|
40
|
-
return readFileSync(filepath, "utf-8");
|
|
41
|
-
}
|
|
42
|
-
function readJsonOrNull(filepath) {
|
|
43
|
-
const content = readFileOrNull(filepath);
|
|
44
|
-
if (content === null)
|
|
45
|
-
return null;
|
|
46
|
-
return JSON.parse(content);
|
|
47
|
-
}
|
|
48
|
-
function ensureDir(dirPath) {
|
|
49
|
-
if (!existsSync(dirPath)) {
|
|
50
|
-
mkdirSync(dirPath, { recursive: true });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function removeIfExists(targetPath) {
|
|
54
|
-
if (existsSync(targetPath)) {
|
|
55
|
-
rmSync(targetPath, { recursive: true, force: true });
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function listFiles(dirPath, options = {}) {
|
|
59
|
-
const { extension, recursive = false } = options;
|
|
60
|
-
if (!existsSync(dirPath))
|
|
61
|
-
return [];
|
|
62
|
-
const results = [];
|
|
63
|
-
const entries = readdirSync(dirPath);
|
|
64
|
-
for (const entry of entries) {
|
|
65
|
-
const fullPath = join(dirPath, entry);
|
|
66
|
-
const stat = statSync(fullPath);
|
|
67
|
-
if (stat.isDirectory() && recursive) {
|
|
68
|
-
results.push(...listFiles(fullPath, options));
|
|
69
|
-
} else if (stat.isFile()) {
|
|
70
|
-
if (!extension || entry.endsWith(extension)) {
|
|
71
|
-
results.push(fullPath);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return results;
|
|
76
|
-
}
|
|
77
|
-
function listDirs(dirPath) {
|
|
78
|
-
if (!existsSync(dirPath))
|
|
79
|
-
return [];
|
|
80
|
-
return readdirSync(dirPath).map((entry) => join(dirPath, entry)).filter((fullPath) => statSync(fullPath).isDirectory());
|
|
81
|
-
}
|
|
82
|
-
function relPath(projectRoot, filepath) {
|
|
83
|
-
return relative(projectRoot, filepath);
|
|
84
|
-
}
|
|
85
|
-
function isGeneratedFile(filepath) {
|
|
86
|
-
const content = readFileOrNull(filepath);
|
|
87
|
-
if (!content)
|
|
88
|
-
return false;
|
|
89
|
-
return content.startsWith(GENERATED_HEADER_MD) || content.startsWith(GENERATED_HEADER_JSON) || content.startsWith(GENERATED_HEADER_JS);
|
|
90
|
-
}
|
|
91
|
-
function inferFileType(filepath) {
|
|
92
|
-
if (filepath.endsWith(".json") || filepath.endsWith(".jsonc"))
|
|
93
|
-
return "json";
|
|
94
|
-
if (filepath.endsWith(".ts") || filepath.endsWith(".mts"))
|
|
95
|
-
return "ts";
|
|
96
|
-
if (filepath.endsWith(".js") || filepath.endsWith(".mjs"))
|
|
97
|
-
return "js";
|
|
98
|
-
return "md";
|
|
99
|
-
}
|
|
100
|
-
function getHeader(type) {
|
|
101
|
-
switch (type) {
|
|
102
|
-
case "md":
|
|
103
|
-
return GENERATED_HEADER_MD;
|
|
104
|
-
case "json":
|
|
105
|
-
return GENERATED_HEADER_JSON;
|
|
106
|
-
case "js":
|
|
107
|
-
case "ts":
|
|
108
|
-
return GENERATED_HEADER_JS;
|
|
109
|
-
default:
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// src/features/plugins.ts
|
|
115
|
-
import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
|
|
116
|
-
import { basename, join as join2 } from "path";
|
|
117
|
-
function parsePlugins(packDir, packName) {
|
|
118
|
-
const pluginsDir = join2(packDir, "plugins");
|
|
119
|
-
if (!existsSync2(pluginsDir))
|
|
120
|
-
return [];
|
|
121
|
-
const tsFiles = listFiles(pluginsDir, { extension: ".ts" });
|
|
122
|
-
const jsFiles = listFiles(pluginsDir, { extension: ".js" });
|
|
123
|
-
const allFiles = [...tsFiles, ...jsFiles];
|
|
124
|
-
return allFiles.map((filepath) => parsePluginFile(filepath, packName));
|
|
125
|
-
}
|
|
126
|
-
function parsePluginFile(filepath, packName) {
|
|
127
|
-
const content = readFileSync2(filepath, "utf-8");
|
|
128
|
-
const ext = filepath.endsWith(".ts") ? "ts" : "js";
|
|
129
|
-
return {
|
|
130
|
-
name: basename(filepath, `.${ext}`),
|
|
131
|
-
sourcePath: filepath,
|
|
132
|
-
packName,
|
|
133
|
-
content,
|
|
134
|
-
extension: ext
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
export {
|
|
138
|
-
parsePlugins,
|
|
139
|
-
parsePluginFile
|
|
140
|
-
};
|
|
1
|
+
import{createRequire as C}from"node:module";var D=C(import.meta.url);import{existsSync as U,mkdirSync as J,readdirSync as Y,readFileSync as O,rmSync as G,statSync as Z,writeFileSync as H}from"fs";import{dirname as T,join as $,relative as j}from"path";var b="<!-- Generated by agentpacks. DO NOT EDIT. -->",v="// Generated by agentpacks. DO NOT EDIT.",w="// Generated by agentpacks. DO NOT EDIT.";function k(q,z,B={}){let{header:I=!0,type:K}=B,V=K??A(q);x(T(q));let L=z;if(I){let Q=_(V);if(Q)L=`${Q}
|
|
2
|
+
${z}`}H(q,L,"utf-8")}function E(q,z,B={}){let I=JSON.stringify(z,null,2);k(q,I+`
|
|
3
|
+
`,{...B,type:"json"})}function M(q){if(!U(q))return null;return O(q,"utf-8")}function d(q){let z=M(q);if(z===null)return null;return JSON.parse(z)}function x(q){if(!U(q))J(q,{recursive:!0})}function c(q){if(U(q))G(q,{recursive:!0,force:!0})}function W(q,z={}){let{extension:B,recursive:I=!1}=z;if(!U(q))return[];let K=[],V=Y(q);for(let L of V){let Q=$(q,L),X=Z(Q);if(X.isDirectory()&&I)K.push(...W(Q,z));else if(X.isFile()){if(!B||L.endsWith(B))K.push(Q)}}return K}function o(q){if(!U(q))return[];return Y(q).map((z)=>$(q,z)).filter((z)=>Z(z).isDirectory())}function f(q,z){return j(q,z)}function s(q){let z=M(q);if(!z)return!1;return z.startsWith(b)||z.startsWith(v)||z.startsWith(w)}function A(q){if(q.endsWith(".json")||q.endsWith(".jsonc"))return"json";if(q.endsWith(".ts")||q.endsWith(".mts"))return"ts";if(q.endsWith(".js")||q.endsWith(".mjs"))return"js";return"md"}function _(q){switch(q){case"md":return b;case"json":return v;case"js":case"ts":return w;default:return null}}import{existsSync as g,readFileSync as m}from"fs";import{basename as F,join as N}from"path";function l(q,z){let B=N(q,"plugins");if(!g(B))return[];let I=W(B,{extension:".ts"}),K=W(B,{extension:".js"});return[...I,...K].map((L)=>R(L,z))}function R(q,z){let B=m(q,"utf-8"),I=q.endsWith(".ts")?"ts":"js";return{name:F(q,`.${I}`),sourcePath:q,packName:z,content:B,extension:I}}export{l as parsePlugins,R as parsePluginFile};
|