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
package/dist/node/cli/search.js
CHANGED
|
@@ -1,210 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
6
|
-
import { homedir } from "os";
|
|
7
|
-
import { dirname, join } from "path";
|
|
8
|
-
var CONFIG_DIR = join(homedir(), ".config", "agentpacks");
|
|
9
|
-
var CREDENTIALS_FILE = join(CONFIG_DIR, "credentials.json");
|
|
10
|
-
function loadCredentials() {
|
|
11
|
-
if (!existsSync(CREDENTIALS_FILE)) {
|
|
12
|
-
return { registryUrl: "https://registry.agentpacks.dev" };
|
|
13
|
-
}
|
|
14
|
-
try {
|
|
15
|
-
const raw = readFileSync(CREDENTIALS_FILE, "utf-8");
|
|
16
|
-
return JSON.parse(raw);
|
|
17
|
-
} catch {
|
|
18
|
-
return { registryUrl: "https://registry.agentpacks.dev" };
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
function saveCredentials(credentials) {
|
|
22
|
-
mkdirSync(dirname(CREDENTIALS_FILE), { recursive: true });
|
|
23
|
-
writeFileSync(CREDENTIALS_FILE, JSON.stringify(credentials, null, 2) + `
|
|
24
|
-
`, {
|
|
25
|
-
mode: 384
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
function clearCredentials() {
|
|
29
|
-
if (existsSync(CREDENTIALS_FILE)) {
|
|
30
|
-
writeFileSync(CREDENTIALS_FILE, JSON.stringify({ registryUrl: "https://registry.agentpacks.dev" }) + `
|
|
31
|
-
`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// src/utils/registry-client.ts
|
|
36
|
-
var DEFAULT_REGISTRY_URL = "https://registry.agentpacks.dev";
|
|
37
|
-
function createRegistryClient(config) {
|
|
38
|
-
return new RegistryClient({
|
|
39
|
-
registryUrl: config?.registryUrl ?? DEFAULT_REGISTRY_URL,
|
|
40
|
-
authToken: config?.authToken,
|
|
41
|
-
timeout: config?.timeout ?? 30000
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
class RegistryClient {
|
|
46
|
-
config;
|
|
47
|
-
constructor(config) {
|
|
48
|
-
this.config = {
|
|
49
|
-
registryUrl: config.registryUrl.replace(/\/+$/, ""),
|
|
50
|
-
authToken: config.authToken,
|
|
51
|
-
timeout: config.timeout ?? 30000
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
async search(params) {
|
|
55
|
-
const searchParams = new URLSearchParams;
|
|
56
|
-
if (params.query)
|
|
57
|
-
searchParams.set("q", params.query);
|
|
58
|
-
if (params.tags?.length)
|
|
59
|
-
searchParams.set("tags", params.tags.join(","));
|
|
60
|
-
if (params.targets?.length)
|
|
61
|
-
searchParams.set("targets", params.targets.join(","));
|
|
62
|
-
if (params.features?.length)
|
|
63
|
-
searchParams.set("features", params.features.join(","));
|
|
64
|
-
if (params.author)
|
|
65
|
-
searchParams.set("author", params.author);
|
|
66
|
-
if (params.sort)
|
|
67
|
-
searchParams.set("sort", params.sort);
|
|
68
|
-
if (params.limit)
|
|
69
|
-
searchParams.set("limit", String(params.limit));
|
|
70
|
-
if (params.offset)
|
|
71
|
-
searchParams.set("offset", String(params.offset));
|
|
72
|
-
const url = `${this.config.registryUrl}/packs?${searchParams.toString()}`;
|
|
73
|
-
const res = await this.fetch(url);
|
|
74
|
-
return res;
|
|
75
|
-
}
|
|
76
|
-
async info(packName) {
|
|
77
|
-
const url = `${this.config.registryUrl}/packs/${encodeURIComponent(packName)}`;
|
|
78
|
-
const res = await this.fetch(url);
|
|
79
|
-
return res;
|
|
80
|
-
}
|
|
81
|
-
async download(packName, version = "latest") {
|
|
82
|
-
const url = `${this.config.registryUrl}/packs/${encodeURIComponent(packName)}/versions/${encodeURIComponent(version)}/download`;
|
|
83
|
-
const response = await fetch(url, {
|
|
84
|
-
headers: this.headers(),
|
|
85
|
-
signal: AbortSignal.timeout(this.config.timeout)
|
|
86
|
-
});
|
|
87
|
-
if (!response.ok) {
|
|
88
|
-
throw new RegistryApiError(response.status, `Failed to download ${packName}@${version}: ${response.statusText}`);
|
|
89
|
-
}
|
|
90
|
-
const integrity = response.headers.get("x-integrity") ?? "";
|
|
91
|
-
const data = await response.arrayBuffer();
|
|
92
|
-
return { data, integrity };
|
|
93
|
-
}
|
|
94
|
-
async publish(tarball, metadata) {
|
|
95
|
-
if (!this.config.authToken) {
|
|
96
|
-
throw new Error("Authentication required. Run `agentpacks login` first.");
|
|
97
|
-
}
|
|
98
|
-
const formData = new FormData;
|
|
99
|
-
formData.append("tarball", new Blob([tarball], { type: "application/gzip" }), `${metadata.name}-${metadata.version}.tgz`);
|
|
100
|
-
formData.append("metadata", JSON.stringify(metadata));
|
|
101
|
-
const url = `${this.config.registryUrl}/packs`;
|
|
102
|
-
const response = await fetch(url, {
|
|
103
|
-
method: "POST",
|
|
104
|
-
headers: {
|
|
105
|
-
Authorization: `Bearer ${this.config.authToken}`
|
|
106
|
-
},
|
|
107
|
-
body: formData,
|
|
108
|
-
signal: AbortSignal.timeout(this.config.timeout)
|
|
109
|
-
});
|
|
110
|
-
if (!response.ok) {
|
|
111
|
-
const body = await response.text();
|
|
112
|
-
throw new RegistryApiError(response.status, `Publish failed: ${body || response.statusText}`);
|
|
113
|
-
}
|
|
114
|
-
return await response.json();
|
|
115
|
-
}
|
|
116
|
-
async featured(limit) {
|
|
117
|
-
const url = limit ? `${this.config.registryUrl}/featured?limit=${limit}` : `${this.config.registryUrl}/featured`;
|
|
118
|
-
const res = await this.fetch(url);
|
|
119
|
-
return res.packs;
|
|
120
|
-
}
|
|
121
|
-
async tags() {
|
|
122
|
-
const url = `${this.config.registryUrl}/tags`;
|
|
123
|
-
const res = await this.fetch(url);
|
|
124
|
-
return res.tags;
|
|
125
|
-
}
|
|
126
|
-
async stats() {
|
|
127
|
-
const url = `${this.config.registryUrl}/stats`;
|
|
128
|
-
return await this.fetch(url);
|
|
129
|
-
}
|
|
130
|
-
async health() {
|
|
131
|
-
try {
|
|
132
|
-
const url = `${this.config.registryUrl}/health`;
|
|
133
|
-
await this.fetch(url);
|
|
134
|
-
return true;
|
|
135
|
-
} catch {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
async fetch(url) {
|
|
140
|
-
const response = await fetch(url, {
|
|
141
|
-
headers: this.headers(),
|
|
142
|
-
signal: AbortSignal.timeout(this.config.timeout)
|
|
143
|
-
});
|
|
144
|
-
if (!response.ok) {
|
|
145
|
-
const body = await response.text();
|
|
146
|
-
throw new RegistryApiError(response.status, body || response.statusText);
|
|
147
|
-
}
|
|
148
|
-
return response.json();
|
|
149
|
-
}
|
|
150
|
-
headers() {
|
|
151
|
-
const h = {
|
|
152
|
-
Accept: "application/json"
|
|
153
|
-
};
|
|
154
|
-
if (this.config.authToken) {
|
|
155
|
-
h["Authorization"] = `Bearer ${this.config.authToken}`;
|
|
156
|
-
}
|
|
157
|
-
return h;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
class RegistryApiError extends Error {
|
|
162
|
-
status;
|
|
163
|
-
constructor(status, message) {
|
|
164
|
-
super(message);
|
|
165
|
-
this.name = "RegistryApiError";
|
|
166
|
-
this.status = status;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// src/cli/search.ts
|
|
171
|
-
import chalk from "chalk";
|
|
172
|
-
async function runSearch(query, options) {
|
|
173
|
-
const credentials = loadCredentials();
|
|
174
|
-
const client = createRegistryClient({
|
|
175
|
-
registryUrl: credentials.registryUrl,
|
|
176
|
-
authToken: credentials.token
|
|
177
|
-
});
|
|
178
|
-
try {
|
|
179
|
-
const { packs, total } = await client.search({
|
|
180
|
-
query,
|
|
181
|
-
tags: options.tags?.split(","),
|
|
182
|
-
targets: options.targets?.split(","),
|
|
183
|
-
sort: options.sort,
|
|
184
|
-
limit: options.limit ? Number(options.limit) : 20
|
|
185
|
-
});
|
|
186
|
-
if (packs.length === 0) {
|
|
187
|
-
console.log(chalk.dim("No packs found."));
|
|
188
|
-
return;
|
|
189
|
-
}
|
|
190
|
-
console.log(chalk.bold(`Found ${total} pack(s)${query ? ` matching "${query}"` : ""}:
|
|
191
|
-
`));
|
|
192
|
-
for (const pack of packs) {
|
|
193
|
-
const verified = pack.verified ? chalk.green(" [verified]") : "";
|
|
194
|
-
const featured = pack.featured ? chalk.yellow(" [featured]") : "";
|
|
195
|
-
console.log(` ${chalk.bold(pack.name)}${verified}${featured}`);
|
|
196
|
-
console.log(` ${pack.description}`);
|
|
197
|
-
console.log(chalk.dim(` v${pack.latestVersion} | ${pack.downloads} downloads | by ${pack.author}`));
|
|
198
|
-
if (options.verbose && pack.tags.length > 0) {
|
|
199
|
-
console.log(chalk.dim(` tags: ${pack.tags.join(", ")}`));
|
|
200
|
-
}
|
|
201
|
-
console.log();
|
|
202
|
-
}
|
|
203
|
-
} catch (err) {
|
|
204
|
-
console.log(chalk.red(`Search failed: ${err instanceof Error ? err.message : String(err)}`));
|
|
205
|
-
process.exit(1);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
export {
|
|
209
|
-
runSearch
|
|
210
|
-
};
|
|
1
|
+
import{createRequire as j}from"node:module";var F=j(import.meta.url);import{existsSync as Y,mkdirSync as w,readFileSync as q,writeFileSync as Z}from"fs";import{homedir as v}from"os";import{dirname as _,join as $}from"path";var T=$(v(),".config","agentpacks"),V=$(T,"credentials.json");function G(){if(!Y(V))return{registryUrl:"https://registry.agentpacks.dev"};try{let z=q(V,"utf-8");return JSON.parse(z)}catch{return{registryUrl:"https://registry.agentpacks.dev"}}}function N(z){w(_(V),{recursive:!0}),Z(V,JSON.stringify(z,null,2)+`
|
|
2
|
+
`,{mode:384})}function S(){if(Y(V))Z(V,JSON.stringify({registryUrl:"https://registry.agentpacks.dev"})+`
|
|
3
|
+
`)}function H(z){return new O({registryUrl:z?.registryUrl??"https://registry.agentpacks.dev",authToken:z?.authToken,timeout:z?.timeout??30000})}class O{config;constructor(z){this.config={registryUrl:z.registryUrl.replace(/\/+$/,""),authToken:z.authToken,timeout:z.timeout??30000}}async search(z){let B=new URLSearchParams;if(z.query)B.set("q",z.query);if(z.tags?.length)B.set("tags",z.tags.join(","));if(z.targets?.length)B.set("targets",z.targets.join(","));if(z.features?.length)B.set("features",z.features.join(","));if(z.author)B.set("author",z.author);if(z.sort)B.set("sort",z.sort);if(z.limit)B.set("limit",String(z.limit));if(z.offset)B.set("offset",String(z.offset));let J=`${this.config.registryUrl}/packs?${B.toString()}`;return await this.fetch(J)}async info(z){let B=`${this.config.registryUrl}/packs/${encodeURIComponent(z)}`;return await this.fetch(B)}async download(z,B="latest"){let J=`${this.config.registryUrl}/packs/${encodeURIComponent(z)}/versions/${encodeURIComponent(B)}/download`,M=await fetch(J,{headers:this.headers(),signal:AbortSignal.timeout(this.config.timeout)});if(!M.ok)throw new X(M.status,`Failed to download ${z}@${B}: ${M.statusText}`);let K=M.headers.get("x-integrity")??"";return{data:await M.arrayBuffer(),integrity:K}}async publish(z,B){if(!this.config.authToken)throw Error("Authentication required. Run `agentpacks login` first.");let J=new FormData;J.append("tarball",new Blob([z],{type:"application/gzip"}),`${B.name}-${B.version}.tgz`),J.append("metadata",JSON.stringify(B));let M=`${this.config.registryUrl}/packs`,K=await fetch(M,{method:"POST",headers:{Authorization:`Bearer ${this.config.authToken}`},body:J,signal:AbortSignal.timeout(this.config.timeout)});if(!K.ok){let W=await K.text();throw new X(K.status,`Publish failed: ${W||K.statusText}`)}return await K.json()}async featured(z){let B=z?`${this.config.registryUrl}/featured?limit=${z}`:`${this.config.registryUrl}/featured`;return(await this.fetch(B)).packs}async tags(){let z=`${this.config.registryUrl}/tags`;return(await this.fetch(z)).tags}async stats(){let z=`${this.config.registryUrl}/stats`;return await this.fetch(z)}async health(){try{let z=`${this.config.registryUrl}/health`;return await this.fetch(z),!0}catch{return!1}}async fetch(z){let B=await fetch(z,{headers:this.headers(),signal:AbortSignal.timeout(this.config.timeout)});if(!B.ok){let J=await B.text();throw new X(B.status,J||B.statusText)}return B.json()}headers(){let z={Accept:"application/json"};if(this.config.authToken)z.Authorization=`Bearer ${this.config.authToken}`;return z}}class X extends Error{status;constructor(z,B){super(B);this.name="RegistryApiError",this.status=z}}import U from"chalk";async function E(z,B){let J=G(),M=H({registryUrl:J.registryUrl,authToken:J.token});try{let{packs:K,total:W}=await M.search({query:z,tags:B.tags?.split(","),targets:B.targets?.split(","),sort:B.sort,limit:B.limit?Number(B.limit):20});if(K.length===0){console.log(U.dim("No packs found."));return}console.log(U.bold(`Found ${W} pack(s)${z?` matching "${z}"`:""}:
|
|
4
|
+
`));for(let Q of K){let x=Q.verified?U.green(" [verified]"):"",b=Q.featured?U.yellow(" [featured]"):"";if(console.log(` ${U.bold(Q.name)}${x}${b}`),console.log(` ${Q.description}`),console.log(U.dim(` v${Q.latestVersion} | ${Q.downloads} downloads | by ${Q.author}`)),B.verbose&&Q.tags.length>0)console.log(U.dim(` tags: ${Q.tags.join(", ")}`));console.log()}}catch(K){console.log(U.red(`Search failed: ${K instanceof Error?K.message:String(K)}`)),process.exit(1)}}export{E as runSearch};
|
package/dist/node/core/config.js
CHANGED
|
@@ -1,146 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
-
|
|
4
|
-
// src/core/config.ts
|
|
5
|
-
import { existsSync, readFileSync } from "fs";
|
|
6
|
-
import { parse as parseJsonc } from "jsonc-parser";
|
|
7
|
-
import { resolve } from "path";
|
|
8
|
-
import { z } from "zod";
|
|
9
|
-
var TARGET_IDS = [
|
|
10
|
-
"opencode",
|
|
11
|
-
"cursor",
|
|
12
|
-
"claudecode",
|
|
13
|
-
"codexcli",
|
|
14
|
-
"mistralvibe",
|
|
15
|
-
"geminicli",
|
|
16
|
-
"copilot",
|
|
17
|
-
"agentsmd",
|
|
18
|
-
"cline",
|
|
19
|
-
"kilo",
|
|
20
|
-
"roo",
|
|
21
|
-
"qwencode",
|
|
22
|
-
"kiro",
|
|
23
|
-
"factorydroid",
|
|
24
|
-
"antigravity",
|
|
25
|
-
"junie",
|
|
26
|
-
"augmentcode",
|
|
27
|
-
"windsurf",
|
|
28
|
-
"warp",
|
|
29
|
-
"replit",
|
|
30
|
-
"zed"
|
|
31
|
-
];
|
|
32
|
-
var FEATURE_IDS = [
|
|
33
|
-
"rules",
|
|
34
|
-
"commands",
|
|
35
|
-
"agents",
|
|
36
|
-
"skills",
|
|
37
|
-
"hooks",
|
|
38
|
-
"plugins",
|
|
39
|
-
"mcp",
|
|
40
|
-
"ignore",
|
|
41
|
-
"models"
|
|
42
|
-
];
|
|
43
|
-
var REPO_MODES = ["repo", "monorepo", "metarepo"];
|
|
44
|
-
var PackManifestSchema = z.object({
|
|
45
|
-
name: z.string().min(1),
|
|
46
|
-
version: z.string().default("1.0.0"),
|
|
47
|
-
description: z.string().default(""),
|
|
48
|
-
author: z.union([
|
|
49
|
-
z.string(),
|
|
50
|
-
z.object({ name: z.string(), email: z.string().optional() })
|
|
51
|
-
]).optional(),
|
|
52
|
-
homepage: z.string().optional(),
|
|
53
|
-
repository: z.union([
|
|
54
|
-
z.string(),
|
|
55
|
-
z.object({ url: z.string(), type: z.string().optional() })
|
|
56
|
-
]).optional(),
|
|
57
|
-
license: z.string().optional(),
|
|
58
|
-
logo: z.string().optional(),
|
|
59
|
-
tags: z.array(z.string()).default([]),
|
|
60
|
-
dependencies: z.array(z.string()).default([]),
|
|
61
|
-
conflicts: z.array(z.string()).default([]),
|
|
62
|
-
targets: z.union([z.literal("*"), z.array(z.string())]).default("*"),
|
|
63
|
-
features: z.union([z.literal("*"), z.array(z.string())]).default("*")
|
|
64
|
-
});
|
|
65
|
-
var FeaturesSchema = z.union([
|
|
66
|
-
z.literal("*"),
|
|
67
|
-
z.array(z.string()),
|
|
68
|
-
z.record(z.string(), z.union([z.literal("*"), z.array(z.string())]))
|
|
69
|
-
]);
|
|
70
|
-
var WorkspaceConfigSchema = z.object({
|
|
71
|
-
$schema: z.string().optional(),
|
|
72
|
-
packs: z.array(z.string()).default(["./packs/default"]),
|
|
73
|
-
disabled: z.array(z.string()).default([]),
|
|
74
|
-
targets: z.union([z.literal("*"), z.array(z.string())]).default("*"),
|
|
75
|
-
features: FeaturesSchema.default("*"),
|
|
76
|
-
mode: z.enum(REPO_MODES).default("repo"),
|
|
77
|
-
baseDirs: z.array(z.string()).default(["."]),
|
|
78
|
-
global: z.boolean().default(false),
|
|
79
|
-
delete: z.boolean().default(true),
|
|
80
|
-
verbose: z.boolean().default(false),
|
|
81
|
-
silent: z.boolean().default(false),
|
|
82
|
-
overrides: z.record(z.string(), z.record(z.string(), z.string())).default({}),
|
|
83
|
-
sources: z.array(z.object({
|
|
84
|
-
source: z.string(),
|
|
85
|
-
packs: z.array(z.string()).optional(),
|
|
86
|
-
skills: z.array(z.string()).optional()
|
|
87
|
-
})).default([]),
|
|
88
|
-
modelProfile: z.string().optional()
|
|
89
|
-
});
|
|
90
|
-
var CONFIG_FILES = ["agentpacks.local.jsonc", "agentpacks.jsonc"];
|
|
91
|
-
function loadWorkspaceConfig(projectRoot) {
|
|
92
|
-
for (const filename of CONFIG_FILES) {
|
|
93
|
-
const filepath = resolve(projectRoot, filename);
|
|
94
|
-
if (existsSync(filepath)) {
|
|
95
|
-
const raw = readFileSync(filepath, "utf-8");
|
|
96
|
-
const parsed = parseJsonc(raw);
|
|
97
|
-
return WorkspaceConfigSchema.parse(parsed);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return WorkspaceConfigSchema.parse({});
|
|
101
|
-
}
|
|
102
|
-
function loadPackManifest(packDir) {
|
|
103
|
-
const filepath = resolve(packDir, "pack.json");
|
|
104
|
-
if (!existsSync(filepath)) {
|
|
105
|
-
const dirName = packDir.split("/").pop() ?? "unknown";
|
|
106
|
-
return PackManifestSchema.parse({ name: dirName });
|
|
107
|
-
}
|
|
108
|
-
const raw = readFileSync(filepath, "utf-8");
|
|
109
|
-
const parsed = JSON.parse(raw);
|
|
110
|
-
return PackManifestSchema.parse(parsed);
|
|
111
|
-
}
|
|
112
|
-
function resolveFeatures(config, targetId) {
|
|
113
|
-
const { features } = config;
|
|
114
|
-
if (features === "*") {
|
|
115
|
-
return [...FEATURE_IDS];
|
|
116
|
-
}
|
|
117
|
-
if (Array.isArray(features)) {
|
|
118
|
-
if (features.includes("*"))
|
|
119
|
-
return [...FEATURE_IDS];
|
|
120
|
-
return features.filter((f) => FEATURE_IDS.includes(f));
|
|
121
|
-
}
|
|
122
|
-
const targetFeatures = features[targetId];
|
|
123
|
-
if (!targetFeatures)
|
|
124
|
-
return [];
|
|
125
|
-
if (targetFeatures === "*")
|
|
126
|
-
return [...FEATURE_IDS];
|
|
127
|
-
if (Array.isArray(targetFeatures) && targetFeatures.includes("*"))
|
|
128
|
-
return [...FEATURE_IDS];
|
|
129
|
-
return targetFeatures.filter((f) => FEATURE_IDS.includes(f));
|
|
130
|
-
}
|
|
131
|
-
function resolveTargets(config) {
|
|
132
|
-
if (config.targets === "*")
|
|
133
|
-
return [...TARGET_IDS];
|
|
134
|
-
return config.targets;
|
|
135
|
-
}
|
|
136
|
-
export {
|
|
137
|
-
resolveTargets,
|
|
138
|
-
resolveFeatures,
|
|
139
|
-
loadWorkspaceConfig,
|
|
140
|
-
loadPackManifest,
|
|
141
|
-
WorkspaceConfigSchema,
|
|
142
|
-
TARGET_IDS,
|
|
143
|
-
REPO_MODES,
|
|
144
|
-
PackManifestSchema,
|
|
145
|
-
FEATURE_IDS
|
|
146
|
-
};
|
|
1
|
+
import{createRequire as L}from"node:module";var w=L(import.meta.url);import{existsSync as Z,readFileSync as $}from"fs";import{parse as x}from"jsonc-parser";import{resolve as J}from"path";import{z as b}from"zod";var G=["opencode","cursor","claudecode","codexcli","mistralvibe","geminicli","copilot","cline","kilo","roo","qwencode","kiro","factorydroid","antigravity","junie","augmentcode","windsurf","warp","replit","zed"],V=["rules","commands","agents","skills","hooks","plugins","mcp","ignore","models"],N=["repo","monorepo","metarepo"],X=b.object({name:b.string().min(1),version:b.string().default("1.0.0"),description:b.string().default(""),author:b.union([b.string(),b.object({name:b.string(),email:b.string().optional()})]).optional(),homepage:b.string().optional(),repository:b.union([b.string(),b.object({url:b.string(),type:b.string().optional()})]).optional(),license:b.string().optional(),logo:b.string().optional(),tags:b.array(b.string()).default([]),dependencies:b.array(b.string()).default([]),conflicts:b.array(b.string()).default([]),targets:b.union([b.literal("*"),b.array(b.string())]).default("*"),features:b.union([b.literal("*"),b.array(b.string())]).default("*")}),W=b.union([b.literal("*"),b.array(b.string()),b.record(b.string(),b.union([b.literal("*"),b.array(b.string())]))]),Y=b.object({$schema:b.string().optional(),packs:b.array(b.string()).default(["./packs/default"]),disabled:b.array(b.string()).default([]),targets:b.union([b.literal("*"),b.array(b.string())]).default("*"),features:W.default("*"),mode:b.enum(N).default("repo"),baseDirs:b.array(b.string()).default(["."]),global:b.boolean().default(!1),delete:b.boolean().default(!0),verbose:b.boolean().default(!1),silent:b.boolean().default(!1),overrides:b.record(b.string(),b.record(b.string(),b.string())).default({}),sources:b.array(b.object({source:b.string(),packs:b.array(b.string()).optional(),skills:b.array(b.string()).optional()})).default([]),modelProfile:b.string().optional()}),j=["agentpacks.local.jsonc","agentpacks.jsonc"];function U(B){for(let Q of j){let q=J(B,Q);if(Z(q)){let H=$(q,"utf-8"),K=x(H);return Y.parse(K)}}return Y.parse({})}function m(B){let Q=J(B,"pack.json");if(!Z(Q)){let K=B.split("/").pop()??"unknown";return X.parse({name:K})}let q=$(Q,"utf-8"),H=JSON.parse(q);return X.parse(H)}function A(B,Q){let{features:q}=B;if(q==="*")return[...V];if(Array.isArray(q)){if(q.includes("*"))return[...V];return q.filter((K)=>V.includes(K))}let H=q[Q];if(!H)return[];if(H==="*")return[...V];if(Array.isArray(H)&&H.includes("*"))return[...V];return H.filter((K)=>V.includes(K))}function d(B){if(B.targets==="*")return[...G];return B.targets}export{d as resolveTargets,A as resolveFeatures,U as loadWorkspaceConfig,m as loadPackManifest,Y as WorkspaceConfigSchema,G as TARGET_IDS,N as REPO_MODES,X as PackManifestSchema,V as FEATURE_IDS};
|
|
@@ -1,127 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
-
|
|
4
|
-
// src/core/dependency-resolver.ts
|
|
5
|
-
function buildDependencyGraph(manifests) {
|
|
6
|
-
const graph = new Map;
|
|
7
|
-
for (const m of manifests) {
|
|
8
|
-
graph.set(m.name, {
|
|
9
|
-
name: m.name,
|
|
10
|
-
manifest: m,
|
|
11
|
-
dependencies: m.dependencies,
|
|
12
|
-
conflicts: m.conflicts
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
return graph;
|
|
16
|
-
}
|
|
17
|
-
function resolveDependencies(manifests) {
|
|
18
|
-
const graph = buildDependencyGraph(manifests);
|
|
19
|
-
const allNames = new Set(graph.keys());
|
|
20
|
-
const missingDeps = [];
|
|
21
|
-
for (const [name, node] of graph) {
|
|
22
|
-
for (const dep of node.dependencies) {
|
|
23
|
-
if (!allNames.has(dep)) {
|
|
24
|
-
missingDeps.push([name, dep]);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
const { sorted, cycles } = topologicalSort(graph);
|
|
29
|
-
const conflictPairs = detectConflicts(graph);
|
|
30
|
-
const ok = cycles.length === 0 && conflictPairs.length === 0 && missingDeps.length === 0;
|
|
31
|
-
return { sorted, cycles, conflictPairs, missingDeps, ok };
|
|
32
|
-
}
|
|
33
|
-
function topologicalSort(graph) {
|
|
34
|
-
const inDegree = new Map;
|
|
35
|
-
for (const name of graph.keys()) {
|
|
36
|
-
inDegree.set(name, 0);
|
|
37
|
-
}
|
|
38
|
-
for (const [, node] of graph) {
|
|
39
|
-
for (const dep of node.dependencies) {
|
|
40
|
-
if (graph.has(dep)) {
|
|
41
|
-
inDegree.set(dep, (inDegree.get(dep) ?? 0) + 1);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
const queue = [];
|
|
46
|
-
for (const [name, degree] of inDegree) {
|
|
47
|
-
if (degree === 0)
|
|
48
|
-
queue.push(name);
|
|
49
|
-
}
|
|
50
|
-
const sorted = [];
|
|
51
|
-
while (queue.length > 0) {
|
|
52
|
-
const current = queue.shift();
|
|
53
|
-
if (!current)
|
|
54
|
-
continue;
|
|
55
|
-
sorted.push(current);
|
|
56
|
-
const node = graph.get(current);
|
|
57
|
-
if (!node)
|
|
58
|
-
continue;
|
|
59
|
-
for (const dep of node.dependencies) {
|
|
60
|
-
if (!graph.has(dep))
|
|
61
|
-
continue;
|
|
62
|
-
const newDegree = (inDegree.get(dep) ?? 1) - 1;
|
|
63
|
-
inDegree.set(dep, newDegree);
|
|
64
|
-
if (newDegree === 0) {
|
|
65
|
-
queue.push(dep);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
const cycles = [];
|
|
70
|
-
if (sorted.length < graph.size) {
|
|
71
|
-
const remaining = new Set;
|
|
72
|
-
for (const name of graph.keys()) {
|
|
73
|
-
if (!sorted.includes(name))
|
|
74
|
-
remaining.add(name);
|
|
75
|
-
}
|
|
76
|
-
const visited = new Set;
|
|
77
|
-
for (const start of remaining) {
|
|
78
|
-
if (visited.has(start))
|
|
79
|
-
continue;
|
|
80
|
-
const cycle = traceCycle(start, graph, remaining);
|
|
81
|
-
if (cycle.length > 0) {
|
|
82
|
-
cycles.push(cycle);
|
|
83
|
-
for (const n of cycle)
|
|
84
|
-
visited.add(n);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
return { sorted: sorted.reverse(), cycles };
|
|
89
|
-
}
|
|
90
|
-
function traceCycle(start, graph, remaining) {
|
|
91
|
-
const path = [];
|
|
92
|
-
const pathSet = new Set;
|
|
93
|
-
let current = start;
|
|
94
|
-
while (current && !pathSet.has(current)) {
|
|
95
|
-
path.push(current);
|
|
96
|
-
pathSet.add(current);
|
|
97
|
-
const node = graph.get(current);
|
|
98
|
-
if (!node)
|
|
99
|
-
break;
|
|
100
|
-
current = node.dependencies.find((d) => remaining.has(d) && graph.has(d));
|
|
101
|
-
}
|
|
102
|
-
if (current && pathSet.has(current)) {
|
|
103
|
-
const cycleStart = path.indexOf(current);
|
|
104
|
-
return path.slice(cycleStart);
|
|
105
|
-
}
|
|
106
|
-
return path;
|
|
107
|
-
}
|
|
108
|
-
function detectConflicts(graph) {
|
|
109
|
-
const conflicts = [];
|
|
110
|
-
const seen = new Set;
|
|
111
|
-
for (const [name, node] of graph) {
|
|
112
|
-
for (const conflict of node.conflicts) {
|
|
113
|
-
if (graph.has(conflict)) {
|
|
114
|
-
const key = [name, conflict].sort().join(":");
|
|
115
|
-
if (!seen.has(key)) {
|
|
116
|
-
seen.add(key);
|
|
117
|
-
conflicts.push([name, conflict]);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
return conflicts;
|
|
123
|
-
}
|
|
124
|
-
export {
|
|
125
|
-
resolveDependencies,
|
|
126
|
-
buildDependencyGraph
|
|
127
|
-
};
|
|
1
|
+
import{createRequire as L}from"node:module";var U=L(import.meta.url);function M(A){let z=new Map;for(let B of A)z.set(B.name,{name:B.name,manifest:B,dependencies:B.dependencies,conflicts:B.conflicts});return z}function W(A){let z=M(A),B=new Set(z.keys()),E=[];for(let[I,J]of z)for(let K of J.dependencies)if(!B.has(K))E.push([I,K]);let{sorted:H,cycles:j}=O(z),x=R(z),F=j.length===0&&x.length===0&&E.length===0;return{sorted:H,cycles:j,conflictPairs:x,missingDeps:E,ok:F}}function O(A){let z=new Map;for(let j of A.keys())z.set(j,0);for(let[,j]of A)for(let x of j.dependencies)if(A.has(x))z.set(x,(z.get(x)??0)+1);let B=[];for(let[j,x]of z)if(x===0)B.push(j);let E=[];while(B.length>0){let j=B.shift();if(!j)continue;E.push(j);let x=A.get(j);if(!x)continue;for(let F of x.dependencies){if(!A.has(F))continue;let I=(z.get(F)??1)-1;if(z.set(F,I),I===0)B.push(F)}}let H=[];if(E.length<A.size){let j=new Set;for(let F of A.keys())if(!E.includes(F))j.add(F);let x=new Set;for(let F of j){if(x.has(F))continue;let I=Q(F,A,j);if(I.length>0){H.push(I);for(let J of I)x.add(J)}}}return{sorted:E.reverse(),cycles:H}}function Q(A,z,B){let E=[],H=new Set,j=A;while(j&&!H.has(j)){E.push(j),H.add(j);let x=z.get(j);if(!x)break;j=x.dependencies.find((F)=>B.has(F)&&z.has(F))}if(j&&H.has(j)){let x=E.indexOf(j);return E.slice(x)}return E}function R(A){let z=[],B=new Set;for(let[E,H]of A)for(let j of H.conflicts)if(A.has(j)){let x=[E,j].sort().join(":");if(!B.has(x))B.add(x),z.push([E,j])}return z}export{W as resolveDependencies,M as buildDependencyGraph};
|