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/cli/info.js
CHANGED
|
@@ -1,232 +1,5 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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/info.ts
|
|
171
|
-
import chalk from "chalk";
|
|
172
|
-
async function runInfo(packName) {
|
|
173
|
-
const credentials = loadCredentials();
|
|
174
|
-
const client = createRegistryClient({
|
|
175
|
-
registryUrl: credentials.registryUrl,
|
|
176
|
-
authToken: credentials.token
|
|
177
|
-
});
|
|
178
|
-
try {
|
|
179
|
-
const pack = await client.info(packName);
|
|
180
|
-
console.log(chalk.bold(`
|
|
181
|
-
${pack.displayName}`));
|
|
182
|
-
console.log(chalk.dim(` ${pack.name}`));
|
|
183
|
-
console.log(` ${pack.description}`);
|
|
184
|
-
console.log();
|
|
185
|
-
console.log(` ${chalk.dim("Author:")} ${pack.author}`);
|
|
186
|
-
console.log(` ${chalk.dim("License:")} ${pack.license}`);
|
|
187
|
-
console.log(` ${chalk.dim("Downloads:")} ${pack.downloads}`);
|
|
188
|
-
if (pack.homepage) {
|
|
189
|
-
console.log(` ${chalk.dim("Homepage:")} ${pack.homepage}`);
|
|
190
|
-
}
|
|
191
|
-
if (pack.repository) {
|
|
192
|
-
console.log(` ${chalk.dim("Repository:")} ${pack.repository}`);
|
|
193
|
-
}
|
|
194
|
-
console.log();
|
|
195
|
-
if (pack.tags.length > 0) {
|
|
196
|
-
console.log(` ${chalk.dim("Tags:")} ${pack.tags.join(", ")}`);
|
|
197
|
-
}
|
|
198
|
-
if (pack.targets.length > 0) {
|
|
199
|
-
console.log(` ${chalk.dim("Targets:")} ${pack.targets.join(", ")}`);
|
|
200
|
-
}
|
|
201
|
-
if (pack.features.length > 0) {
|
|
202
|
-
console.log(` ${chalk.dim("Features:")} ${pack.features.join(", ")}`);
|
|
203
|
-
}
|
|
204
|
-
console.log();
|
|
205
|
-
if (pack.versions.length > 0) {
|
|
206
|
-
console.log(chalk.bold(" Versions:"));
|
|
207
|
-
for (const v of pack.versions.slice(0, 10)) {
|
|
208
|
-
console.log(` ${v.version} \u2014 ${v.createdAt} (${v.fileCount} files, ${formatBytes(v.tarballSize)})`);
|
|
209
|
-
}
|
|
210
|
-
if (pack.versions.length > 10) {
|
|
211
|
-
console.log(chalk.dim(` ... and ${pack.versions.length - 10} more`));
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
console.log();
|
|
215
|
-
console.log(chalk.bold(" Install:"));
|
|
216
|
-
console.log(` registry:${pack.name}`);
|
|
217
|
-
console.log();
|
|
218
|
-
} catch (err) {
|
|
219
|
-
console.log(chalk.red(`Failed to get pack info: ${err instanceof Error ? err.message : String(err)}`));
|
|
220
|
-
process.exit(1);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
function formatBytes(bytes) {
|
|
224
|
-
if (bytes < 1024)
|
|
225
|
-
return `${bytes} B`;
|
|
226
|
-
if (bytes < 1024 * 1024)
|
|
227
|
-
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
228
|
-
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
229
|
-
}
|
|
230
|
-
export {
|
|
231
|
-
runInfo
|
|
232
|
-
};
|
|
2
|
+
var v=import.meta.require;import{existsSync as Z,mkdirSync as O,readFileSync as V,writeFileSync as $}from"fs";import{homedir as x}from"os";import{dirname as j,join as B}from"path";var w=B(x(),".config","agentpacks"),W=B(w,"credentials.json");function G(){if(!Z(W))return{registryUrl:"https://registry.agentpacks.dev"};try{let q=V(W,"utf-8");return JSON.parse(q)}catch{return{registryUrl:"https://registry.agentpacks.dev"}}}function C(q){O(j(W),{recursive:!0}),$(W,JSON.stringify(q,null,2)+`
|
|
3
|
+
`,{mode:384})}function L(){if(Z(W))$(W,JSON.stringify({registryUrl:"https://registry.agentpacks.dev"})+`
|
|
4
|
+
`)}function H(q){return new M({registryUrl:q?.registryUrl??"https://registry.agentpacks.dev",authToken:q?.authToken,timeout:q?.timeout??30000})}class M{config;constructor(q){this.config={registryUrl:q.registryUrl.replace(/\/+$/,""),authToken:q.authToken,timeout:q.timeout??30000}}async search(q){let J=new URLSearchParams;if(q.query)J.set("q",q.query);if(q.tags?.length)J.set("tags",q.tags.join(","));if(q.targets?.length)J.set("targets",q.targets.join(","));if(q.features?.length)J.set("features",q.features.join(","));if(q.author)J.set("author",q.author);if(q.sort)J.set("sort",q.sort);if(q.limit)J.set("limit",String(q.limit));if(q.offset)J.set("offset",String(q.offset));let Q=`${this.config.registryUrl}/packs?${J.toString()}`;return await this.fetch(Q)}async info(q){let J=`${this.config.registryUrl}/packs/${encodeURIComponent(q)}`;return await this.fetch(J)}async download(q,J="latest"){let Q=`${this.config.registryUrl}/packs/${encodeURIComponent(q)}/versions/${encodeURIComponent(J)}/download`,z=await fetch(Q,{headers:this.headers(),signal:AbortSignal.timeout(this.config.timeout)});if(!z.ok)throw new X(z.status,`Failed to download ${q}@${J}: ${z.statusText}`);let U=z.headers.get("x-integrity")??"";return{data:await z.arrayBuffer(),integrity:U}}async publish(q,J){if(!this.config.authToken)throw Error("Authentication required. Run `agentpacks login` first.");let Q=new FormData;Q.append("tarball",new Blob([q],{type:"application/gzip"}),`${J.name}-${J.version}.tgz`),Q.append("metadata",JSON.stringify(J));let z=`${this.config.registryUrl}/packs`,U=await fetch(z,{method:"POST",headers:{Authorization:`Bearer ${this.config.authToken}`},body:Q,signal:AbortSignal.timeout(this.config.timeout)});if(!U.ok){let Y=await U.text();throw new X(U.status,`Publish failed: ${Y||U.statusText}`)}return await U.json()}async featured(q){let J=q?`${this.config.registryUrl}/featured?limit=${q}`:`${this.config.registryUrl}/featured`;return(await this.fetch(J)).packs}async tags(){let q=`${this.config.registryUrl}/tags`;return(await this.fetch(q)).tags}async stats(){let q=`${this.config.registryUrl}/stats`;return await this.fetch(q)}async health(){try{let q=`${this.config.registryUrl}/health`;return await this.fetch(q),!0}catch{return!1}}async fetch(q){let J=await fetch(q,{headers:this.headers(),signal:AbortSignal.timeout(this.config.timeout)});if(!J.ok){let Q=await J.text();throw new X(J.status,Q||J.statusText)}return J.json()}headers(){let q={Accept:"application/json"};if(this.config.authToken)q.Authorization=`Bearer ${this.config.authToken}`;return q}}class X extends Error{status;constructor(q,J){super(J);this.name="RegistryApiError",this.status=q}}import K from"chalk";async function u(q){let J=G(),Q=H({registryUrl:J.registryUrl,authToken:J.token});try{let z=await Q.info(q);if(console.log(K.bold(`
|
|
5
|
+
${z.displayName}`)),console.log(K.dim(` ${z.name}`)),console.log(` ${z.description}`),console.log(),console.log(` ${K.dim("Author:")} ${z.author}`),console.log(` ${K.dim("License:")} ${z.license}`),console.log(` ${K.dim("Downloads:")} ${z.downloads}`),z.homepage)console.log(` ${K.dim("Homepage:")} ${z.homepage}`);if(z.repository)console.log(` ${K.dim("Repository:")} ${z.repository}`);if(console.log(),z.tags.length>0)console.log(` ${K.dim("Tags:")} ${z.tags.join(", ")}`);if(z.targets.length>0)console.log(` ${K.dim("Targets:")} ${z.targets.join(", ")}`);if(z.features.length>0)console.log(` ${K.dim("Features:")} ${z.features.join(", ")}`);if(console.log(),z.versions.length>0){console.log(K.bold(" Versions:"));for(let U of z.versions.slice(0,10))console.log(` ${U.version} \u2014 ${U.createdAt} (${U.fileCount} files, ${_(U.tarballSize)})`);if(z.versions.length>10)console.log(K.dim(` ... and ${z.versions.length-10} more`))}console.log(),console.log(K.bold(" Install:")),console.log(` registry:${z.name}`),console.log()}catch(z){console.log(K.red(`Failed to get pack info: ${z instanceof Error?z.message:String(z)}`)),process.exit(1)}}function _(q){if(q<1024)return`${q} B`;if(q<1048576)return`${(q/1024).toFixed(1)} KB`;return`${(q/1048576).toFixed(1)} MB`}export{u as runInfo};
|
package/dist/cli/init.js
CHANGED
|
@@ -1,186 +1,10 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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/cli/init.ts
|
|
115
|
-
import chalk from "chalk";
|
|
116
|
-
import { copyFileSync, existsSync as existsSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
117
|
-
import { join as join2, resolve } from "path";
|
|
118
|
-
function runInit(projectRoot) {
|
|
119
|
-
const configPath = resolve(projectRoot, "agentpacks.jsonc");
|
|
120
|
-
const packsDir = resolve(projectRoot, "packs", "default");
|
|
121
|
-
if (existsSync2(configPath)) {
|
|
122
|
-
console.log(chalk.yellow("agentpacks.jsonc already exists. Skipping config creation."));
|
|
123
|
-
} else {
|
|
124
|
-
const templateDir = resolve(import.meta.dirname, "..", "..", "templates");
|
|
125
|
-
const templateConfig = resolve(templateDir, "workspace", "agentpacks.jsonc");
|
|
126
|
-
if (existsSync2(templateConfig)) {
|
|
127
|
-
copyFileSync(templateConfig, configPath);
|
|
128
|
-
} else {
|
|
129
|
-
const config = {
|
|
130
|
-
$schema: "https://unpkg.com/agentpacks/schema.json",
|
|
131
|
-
packs: ["./packs/default"],
|
|
132
|
-
disabled: [],
|
|
133
|
-
targets: [
|
|
134
|
-
"opencode",
|
|
135
|
-
"cursor",
|
|
136
|
-
"claudecode",
|
|
137
|
-
"geminicli",
|
|
138
|
-
"codexcli",
|
|
139
|
-
"copilot"
|
|
140
|
-
],
|
|
141
|
-
features: ["*"],
|
|
142
|
-
mode: "repo",
|
|
143
|
-
baseDirs: ["."],
|
|
144
|
-
global: false,
|
|
145
|
-
delete: true
|
|
146
|
-
};
|
|
147
|
-
writeFileSync2(configPath, JSON.stringify(config, null, 2) + `
|
|
148
|
-
`);
|
|
149
|
-
}
|
|
150
|
-
console.log(chalk.green("Created agentpacks.jsonc"));
|
|
151
|
-
}
|
|
152
|
-
if (existsSync2(packsDir)) {
|
|
153
|
-
console.log(chalk.yellow("packs/default/ already exists. Skipping pack scaffold."));
|
|
154
|
-
} else {
|
|
155
|
-
ensureDir(packsDir);
|
|
156
|
-
ensureDir(join2(packsDir, "rules"));
|
|
157
|
-
ensureDir(join2(packsDir, "commands"));
|
|
158
|
-
ensureDir(join2(packsDir, "agents"));
|
|
159
|
-
ensureDir(join2(packsDir, "skills"));
|
|
160
|
-
const packJson = {
|
|
161
|
-
name: "default",
|
|
162
|
-
version: "1.0.0",
|
|
163
|
-
description: "Default project pack",
|
|
164
|
-
tags: [],
|
|
165
|
-
dependencies: [],
|
|
166
|
-
conflicts: [],
|
|
167
|
-
targets: "*",
|
|
168
|
-
features: "*"
|
|
169
|
-
};
|
|
170
|
-
writeFileSync2(join2(packsDir, "pack.json"), JSON.stringify(packJson, null, 2) + `
|
|
171
|
-
`);
|
|
172
|
-
const templateRule = resolve(import.meta.dirname, "..", "..", "templates", "pack", "rules", "overview.md");
|
|
173
|
-
if (existsSync2(templateRule)) {
|
|
174
|
-
copyFileSync(templateRule, join2(packsDir, "rules", "overview.md"));
|
|
175
|
-
}
|
|
176
|
-
console.log(chalk.green("Created packs/default/ with scaffold"));
|
|
177
|
-
}
|
|
178
|
-
console.log(chalk.cyan(`
|
|
179
|
-
Next steps:`), `
|
|
180
|
-
1. Edit packs/default/rules/overview.md with your project guidelines`, `
|
|
181
|
-
2. Run`, chalk.bold("agentpacks generate"), "to generate tool configs", `
|
|
182
|
-
3. Or run`, chalk.bold("agentpacks import --from rulesync"), "to migrate from rulesync");
|
|
183
|
-
}
|
|
184
|
-
export {
|
|
185
|
-
runInit
|
|
186
|
-
};
|
|
2
|
+
var u=import.meta.require;import{existsSync as X,mkdirSync as N,readdirSync as M,readFileSync as F,rmSync as g,statSync as O,writeFileSync as x}from"fs";import{dirname as A,join as w,relative as _}from"path";var J="<!-- Generated by agentpacks. DO NOT EDIT. -->",C="// Generated by agentpacks. DO NOT EDIT.",G="// Generated by agentpacks. DO NOT EDIT.";function m(q,z,B={}){let{header:K=!0,type:I}=B,Z=I??k(q);L(A(q));let W=z;if(K){let U=R(Z);if(U)W=`${U}
|
|
3
|
+
${z}`}x(q,W,"utf-8")}function E(q,z,B={}){let K=JSON.stringify(z,null,2);m(q,K+`
|
|
4
|
+
`,{...B,type:"json"})}function H(q){if(!X(q))return null;return F(q,"utf-8")}function y(q){let z=H(q);if(z===null)return null;return JSON.parse(z)}function L(q){if(!X(q))N(q,{recursive:!0})}function d(q){if(X(q))g(q,{recursive:!0,force:!0})}function j(q,z={}){let{extension:B,recursive:K=!1}=z;if(!X(q))return[];let I=[],Z=M(q);for(let W of Z){let U=w(q,W),b=O(U);if(b.isDirectory()&&K)I.push(...j(U,z));else if(b.isFile()){if(!B||W.endsWith(B))I.push(U)}}return I}function f(q){if(!X(q))return[];return M(q).map((z)=>w(q,z)).filter((z)=>O(z).isDirectory())}function c(q,z){return _(q,z)}function p(q){let z=H(q);if(!z)return!1;return z.startsWith(J)||z.startsWith(C)||z.startsWith(G)}function k(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 R(q){switch(q){case"md":return J;case"json":return C;case"js":case"ts":return G;default:return null}}import Q from"chalk";import{copyFileSync as T,existsSync as $,writeFileSync as v}from"fs";import{join as V,resolve as Y}from"path";function r(q){let z=Y(q,"agentpacks.jsonc"),B=Y(q,"packs","default");if($(z))console.log(Q.yellow("agentpacks.jsonc already exists. Skipping config creation."));else{let K=Y(import.meta.dirname,"..","..","templates"),I=Y(K,"workspace","agentpacks.jsonc");if($(I))T(I,z);else v(z,JSON.stringify({$schema:"https://unpkg.com/agentpacks/schema.json",packs:["./packs/default"],disabled:[],targets:["opencode","cursor","claudecode","geminicli","codexcli","copilot"],features:["*"],mode:"repo",baseDirs:["."],global:!1,delete:!0},null,2)+`
|
|
5
|
+
`);console.log(Q.green("Created agentpacks.jsonc"))}if($(B))console.log(Q.yellow("packs/default/ already exists. Skipping pack scaffold."));else{L(B),L(V(B,"rules")),L(V(B,"commands")),L(V(B,"agents")),L(V(B,"skills"));let K={name:"default",version:"1.0.0",description:"Default project pack",tags:[],dependencies:[],conflicts:[],targets:"*",features:"*"};v(V(B,"pack.json"),JSON.stringify(K,null,2)+`
|
|
6
|
+
`);let I=Y(import.meta.dirname,"..","..","templates","pack","rules","overview.md");if($(I))T(I,V(B,"rules","overview.md"));console.log(Q.green("Created packs/default/ with scaffold"))}console.log(Q.cyan(`
|
|
7
|
+
Next steps:`),`
|
|
8
|
+
1. Edit packs/default/rules/overview.md with your project guidelines`,`
|
|
9
|
+
2. Run`,Q.bold("agentpacks generate"),"to generate tool configs",`
|
|
10
|
+
3. Or run`,Q.bold("agentpacks import --from rulesync"),"to migrate from rulesync")}export{r as runInit};
|