agentpacks 0.3.0 → 0.4.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/README.md +168 -8
- package/dist/api.d.ts +2 -0
- package/dist/api.js +929 -409
- package/dist/cli/export-cmd.js +281 -149
- package/dist/cli/generate.js +740 -247
- package/dist/cli/import-cmd.js +57 -85
- package/dist/cli/info.d.ts +4 -0
- package/dist/cli/info.js +232 -0
- package/dist/cli/init.js +8 -36
- package/dist/cli/install.js +414 -129
- package/dist/cli/login.d.ts +9 -0
- package/dist/cli/login.js +202 -0
- package/dist/cli/models-explain.d.ts +16 -0
- package/dist/cli/models-explain.js +1205 -0
- package/dist/cli/pack/create.js +4 -32
- package/dist/cli/pack/enable.js +1 -29
- package/dist/cli/pack/list.js +266 -134
- package/dist/cli/pack/validate.js +274 -127
- package/dist/cli/publish.d.ts +8 -0
- package/dist/cli/publish.js +672 -0
- package/dist/cli/search.d.ts +12 -0
- package/dist/cli/search.js +210 -0
- package/dist/core/config.d.ts +2 -1
- package/dist/core/config.js +74 -117
- package/dist/core/dependency-resolver.js +4 -28
- package/dist/core/feature-merger.d.ts +7 -0
- package/dist/core/feature-merger.js +289 -29
- package/dist/core/index.js +283 -140
- package/dist/core/lockfile.js +0 -28
- package/dist/core/metarepo.js +74 -116
- package/dist/core/pack-loader.d.ts +2 -0
- package/dist/core/pack-loader.js +266 -133
- package/dist/core/profile-resolver.d.ts +75 -0
- package/dist/core/profile-resolver.js +111 -0
- package/dist/exporters/cursor-plugin.js +4 -32
- package/dist/exporters/index.js +4 -32
- package/dist/features/agents.d.ts +5 -0
- package/dist/features/agents.js +2 -30
- package/dist/features/commands.js +2 -30
- package/dist/features/hooks.js +2 -30
- package/dist/features/ignore.js +0 -28
- package/dist/features/index.d.ts +1 -0
- package/dist/features/index.js +176 -31
- package/dist/features/mcp.js +2 -30
- package/dist/features/models.d.ts +167 -0
- package/dist/features/models.js +293 -0
- package/dist/features/plugins.js +2 -30
- package/dist/features/rules.js +2 -30
- package/dist/features/skills.js +2 -30
- package/dist/importers/claude-code.js +10 -38
- package/dist/importers/cursor.js +15 -43
- package/dist/importers/opencode.js +16 -44
- package/dist/importers/rulesync.js +22 -50
- package/dist/index.js +1710 -538
- package/dist/node/api.js +929 -409
- package/dist/node/cli/export-cmd.js +281 -149
- package/dist/node/cli/generate.js +740 -247
- package/dist/node/cli/import-cmd.js +57 -85
- package/dist/node/cli/info.js +232 -0
- package/dist/node/cli/init.js +8 -36
- package/dist/node/cli/install.js +414 -129
- package/dist/node/cli/login.js +202 -0
- package/dist/node/cli/models-explain.js +1205 -0
- package/dist/node/cli/pack/create.js +4 -32
- package/dist/node/cli/pack/enable.js +1 -29
- package/dist/node/cli/pack/list.js +266 -134
- package/dist/node/cli/pack/validate.js +274 -127
- package/dist/node/cli/publish.js +672 -0
- package/dist/node/cli/search.js +210 -0
- package/dist/node/core/config.js +74 -117
- package/dist/node/core/dependency-resolver.js +4 -28
- package/dist/node/core/feature-merger.js +289 -29
- package/dist/node/core/index.js +283 -140
- package/dist/node/core/lockfile.js +0 -28
- package/dist/node/core/metarepo.js +74 -116
- package/dist/node/core/pack-loader.js +266 -133
- package/dist/node/core/profile-resolver.js +111 -0
- package/dist/node/exporters/cursor-plugin.js +4 -32
- package/dist/node/exporters/index.js +4 -32
- package/dist/node/features/agents.js +2 -30
- package/dist/node/features/commands.js +2 -30
- package/dist/node/features/hooks.js +2 -30
- package/dist/node/features/ignore.js +0 -28
- package/dist/node/features/index.js +176 -31
- package/dist/node/features/mcp.js +2 -30
- package/dist/node/features/models.js +293 -0
- package/dist/node/features/plugins.js +2 -30
- package/dist/node/features/rules.js +2 -30
- package/dist/node/features/skills.js +2 -30
- package/dist/node/importers/claude-code.js +10 -38
- package/dist/node/importers/cursor.js +15 -43
- package/dist/node/importers/opencode.js +16 -44
- package/dist/node/importers/rulesync.js +22 -50
- package/dist/node/index.js +1710 -538
- package/dist/node/sources/git-ref.js +7 -30
- package/dist/node/sources/git.js +7 -30
- package/dist/node/sources/index.js +337 -39
- package/dist/node/sources/local.js +0 -28
- package/dist/node/sources/npm-ref.js +0 -28
- package/dist/node/sources/npm.js +10 -37
- package/dist/node/sources/registry-ref.js +37 -0
- package/dist/node/sources/registry.js +355 -0
- package/dist/node/targets/additional-targets.js +196 -37
- package/dist/node/targets/agents-md.js +5 -33
- package/dist/node/targets/base-target.js +0 -28
- package/dist/node/targets/claude-code.js +211 -41
- package/dist/node/targets/codex-cli.js +7 -35
- package/dist/node/targets/copilot.js +202 -41
- package/dist/node/targets/cursor.js +188 -40
- package/dist/node/targets/gemini-cli.js +10 -38
- package/dist/node/targets/generic-md-target.js +196 -37
- package/dist/node/targets/index.js +414 -106
- package/dist/node/targets/opencode.js +171 -51
- package/dist/node/targets/registry.js +414 -106
- package/dist/node/utils/credentials.js +38 -0
- package/dist/node/utils/diff.js +22 -34
- package/dist/node/utils/filesystem.js +2 -30
- package/dist/node/utils/frontmatter.js +0 -28
- package/dist/node/utils/global.js +3 -31
- package/dist/node/utils/markdown.js +0 -28
- package/dist/node/utils/model-allowlist.js +110 -0
- package/dist/node/utils/model-guidance.js +78 -0
- package/dist/node/utils/registry-client.js +142 -0
- package/dist/node/utils/tarball.js +49 -0
- package/dist/sources/git-ref.js +7 -30
- package/dist/sources/git.d.ts +2 -2
- package/dist/sources/git.js +7 -30
- package/dist/sources/index.d.ts +2 -0
- package/dist/sources/index.js +337 -39
- package/dist/sources/local.js +0 -28
- package/dist/sources/npm-ref.js +0 -28
- package/dist/sources/npm.js +10 -37
- package/dist/sources/registry-ref.d.ts +30 -0
- package/dist/sources/registry-ref.js +37 -0
- package/dist/sources/registry.d.ts +18 -0
- package/dist/sources/registry.js +355 -0
- package/dist/targets/additional-targets.js +196 -37
- package/dist/targets/agents-md.js +5 -33
- package/dist/targets/base-target.d.ts +2 -0
- package/dist/targets/base-target.js +0 -28
- package/dist/targets/claude-code.js +211 -41
- package/dist/targets/codex-cli.js +7 -35
- package/dist/targets/copilot.js +202 -41
- package/dist/targets/cursor.js +188 -40
- package/dist/targets/gemini-cli.js +10 -38
- package/dist/targets/generic-md-target.js +196 -37
- package/dist/targets/index.js +414 -106
- package/dist/targets/opencode.js +171 -51
- package/dist/targets/registry.js +414 -106
- package/dist/utils/credentials.d.ts +19 -0
- package/dist/utils/credentials.js +38 -0
- package/dist/utils/diff.js +22 -34
- package/dist/utils/filesystem.js +2 -30
- package/dist/utils/frontmatter.js +0 -28
- package/dist/utils/global.js +3 -31
- package/dist/utils/markdown.js +0 -28
- package/dist/utils/model-allowlist.d.ts +39 -0
- package/dist/utils/model-allowlist.js +110 -0
- package/dist/utils/model-guidance.d.ts +6 -0
- package/dist/utils/model-guidance.js +78 -0
- package/dist/utils/registry-client.d.ts +141 -0
- package/dist/utils/registry-client.js +142 -0
- package/dist/utils/tarball.d.ts +13 -0
- package/dist/utils/tarball.js +49 -0
- package/package.json +171 -5
- package/templates/pack/models.json +38 -0
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __require = import.meta.require;
|
|
3
|
+
|
|
4
|
+
// src/utils/registry-client.ts
|
|
5
|
+
var DEFAULT_REGISTRY_URL = "https://registry.agentpacks.dev";
|
|
6
|
+
function createRegistryClient(config) {
|
|
7
|
+
return new RegistryClient({
|
|
8
|
+
registryUrl: config?.registryUrl ?? DEFAULT_REGISTRY_URL,
|
|
9
|
+
authToken: config?.authToken,
|
|
10
|
+
timeout: config?.timeout ?? 30000
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
class RegistryClient {
|
|
15
|
+
config;
|
|
16
|
+
constructor(config) {
|
|
17
|
+
this.config = {
|
|
18
|
+
registryUrl: config.registryUrl.replace(/\/+$/, ""),
|
|
19
|
+
authToken: config.authToken,
|
|
20
|
+
timeout: config.timeout ?? 30000
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
async search(params) {
|
|
24
|
+
const searchParams = new URLSearchParams;
|
|
25
|
+
if (params.query)
|
|
26
|
+
searchParams.set("q", params.query);
|
|
27
|
+
if (params.tags?.length)
|
|
28
|
+
searchParams.set("tags", params.tags.join(","));
|
|
29
|
+
if (params.targets?.length)
|
|
30
|
+
searchParams.set("targets", params.targets.join(","));
|
|
31
|
+
if (params.features?.length)
|
|
32
|
+
searchParams.set("features", params.features.join(","));
|
|
33
|
+
if (params.author)
|
|
34
|
+
searchParams.set("author", params.author);
|
|
35
|
+
if (params.sort)
|
|
36
|
+
searchParams.set("sort", params.sort);
|
|
37
|
+
if (params.limit)
|
|
38
|
+
searchParams.set("limit", String(params.limit));
|
|
39
|
+
if (params.offset)
|
|
40
|
+
searchParams.set("offset", String(params.offset));
|
|
41
|
+
const url = `${this.config.registryUrl}/packs?${searchParams.toString()}`;
|
|
42
|
+
const res = await this.fetch(url);
|
|
43
|
+
return res;
|
|
44
|
+
}
|
|
45
|
+
async info(packName) {
|
|
46
|
+
const url = `${this.config.registryUrl}/packs/${encodeURIComponent(packName)}`;
|
|
47
|
+
const res = await this.fetch(url);
|
|
48
|
+
return res;
|
|
49
|
+
}
|
|
50
|
+
async download(packName, version = "latest") {
|
|
51
|
+
const url = `${this.config.registryUrl}/packs/${encodeURIComponent(packName)}/versions/${encodeURIComponent(version)}/download`;
|
|
52
|
+
const response = await fetch(url, {
|
|
53
|
+
headers: this.headers(),
|
|
54
|
+
signal: AbortSignal.timeout(this.config.timeout)
|
|
55
|
+
});
|
|
56
|
+
if (!response.ok) {
|
|
57
|
+
throw new RegistryApiError(response.status, `Failed to download ${packName}@${version}: ${response.statusText}`);
|
|
58
|
+
}
|
|
59
|
+
const integrity = response.headers.get("x-integrity") ?? "";
|
|
60
|
+
const data = await response.arrayBuffer();
|
|
61
|
+
return { data, integrity };
|
|
62
|
+
}
|
|
63
|
+
async publish(tarball, metadata) {
|
|
64
|
+
if (!this.config.authToken) {
|
|
65
|
+
throw new Error("Authentication required. Run `agentpacks login` first.");
|
|
66
|
+
}
|
|
67
|
+
const formData = new FormData;
|
|
68
|
+
formData.append("tarball", new Blob([tarball], { type: "application/gzip" }), `${metadata.name}-${metadata.version}.tgz`);
|
|
69
|
+
formData.append("metadata", JSON.stringify(metadata));
|
|
70
|
+
const url = `${this.config.registryUrl}/packs`;
|
|
71
|
+
const response = await fetch(url, {
|
|
72
|
+
method: "POST",
|
|
73
|
+
headers: {
|
|
74
|
+
Authorization: `Bearer ${this.config.authToken}`
|
|
75
|
+
},
|
|
76
|
+
body: formData,
|
|
77
|
+
signal: AbortSignal.timeout(this.config.timeout)
|
|
78
|
+
});
|
|
79
|
+
if (!response.ok) {
|
|
80
|
+
const body = await response.text();
|
|
81
|
+
throw new RegistryApiError(response.status, `Publish failed: ${body || response.statusText}`);
|
|
82
|
+
}
|
|
83
|
+
return await response.json();
|
|
84
|
+
}
|
|
85
|
+
async featured(limit) {
|
|
86
|
+
const url = limit ? `${this.config.registryUrl}/featured?limit=${limit}` : `${this.config.registryUrl}/featured`;
|
|
87
|
+
const res = await this.fetch(url);
|
|
88
|
+
return res.packs;
|
|
89
|
+
}
|
|
90
|
+
async tags() {
|
|
91
|
+
const url = `${this.config.registryUrl}/tags`;
|
|
92
|
+
const res = await this.fetch(url);
|
|
93
|
+
return res.tags;
|
|
94
|
+
}
|
|
95
|
+
async stats() {
|
|
96
|
+
const url = `${this.config.registryUrl}/stats`;
|
|
97
|
+
return await this.fetch(url);
|
|
98
|
+
}
|
|
99
|
+
async health() {
|
|
100
|
+
try {
|
|
101
|
+
const url = `${this.config.registryUrl}/health`;
|
|
102
|
+
await this.fetch(url);
|
|
103
|
+
return true;
|
|
104
|
+
} catch {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async fetch(url) {
|
|
109
|
+
const response = await fetch(url, {
|
|
110
|
+
headers: this.headers(),
|
|
111
|
+
signal: AbortSignal.timeout(this.config.timeout)
|
|
112
|
+
});
|
|
113
|
+
if (!response.ok) {
|
|
114
|
+
const body = await response.text();
|
|
115
|
+
throw new RegistryApiError(response.status, body || response.statusText);
|
|
116
|
+
}
|
|
117
|
+
return response.json();
|
|
118
|
+
}
|
|
119
|
+
headers() {
|
|
120
|
+
const h = {
|
|
121
|
+
Accept: "application/json"
|
|
122
|
+
};
|
|
123
|
+
if (this.config.authToken) {
|
|
124
|
+
h["Authorization"] = `Bearer ${this.config.authToken}`;
|
|
125
|
+
}
|
|
126
|
+
return h;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
class RegistryApiError extends Error {
|
|
131
|
+
status;
|
|
132
|
+
constructor(status, message) {
|
|
133
|
+
super(message);
|
|
134
|
+
this.name = "RegistryApiError";
|
|
135
|
+
this.status = status;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// src/utils/credentials.ts
|
|
140
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
141
|
+
import { join, dirname } from "path";
|
|
142
|
+
import { homedir } from "os";
|
|
143
|
+
var CONFIG_DIR = join(homedir(), ".config", "agentpacks");
|
|
144
|
+
var CREDENTIALS_FILE = join(CONFIG_DIR, "credentials.json");
|
|
145
|
+
function loadCredentials() {
|
|
146
|
+
if (!existsSync(CREDENTIALS_FILE)) {
|
|
147
|
+
return { registryUrl: "https://registry.agentpacks.dev" };
|
|
148
|
+
}
|
|
149
|
+
try {
|
|
150
|
+
const raw = readFileSync(CREDENTIALS_FILE, "utf-8");
|
|
151
|
+
return JSON.parse(raw);
|
|
152
|
+
} catch {
|
|
153
|
+
return { registryUrl: "https://registry.agentpacks.dev" };
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function saveCredentials(credentials) {
|
|
157
|
+
mkdirSync(dirname(CREDENTIALS_FILE), { recursive: true });
|
|
158
|
+
writeFileSync(CREDENTIALS_FILE, JSON.stringify(credentials, null, 2) + `
|
|
159
|
+
`, {
|
|
160
|
+
mode: 384
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
function clearCredentials() {
|
|
164
|
+
if (existsSync(CREDENTIALS_FILE)) {
|
|
165
|
+
writeFileSync(CREDENTIALS_FILE, JSON.stringify({ registryUrl: "https://registry.agentpacks.dev" }) + `
|
|
166
|
+
`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// src/cli/login.ts
|
|
171
|
+
import chalk from "chalk";
|
|
172
|
+
async function runLogin(options) {
|
|
173
|
+
const registryUrl = options.registry ?? "https://registry.agentpacks.dev";
|
|
174
|
+
if (!options.token) {
|
|
175
|
+
console.log(chalk.bold(`agentpacks login
|
|
176
|
+
`));
|
|
177
|
+
console.log("To authenticate, you need an API token.");
|
|
178
|
+
console.log(`Get one at: ${chalk.cyan(`${registryUrl}/account/tokens`)}
|
|
179
|
+
`);
|
|
180
|
+
console.log("Then run:");
|
|
181
|
+
console.log(chalk.dim(` agentpacks login --token <your-token>
|
|
182
|
+
`));
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
const client = createRegistryClient({
|
|
186
|
+
registryUrl,
|
|
187
|
+
authToken: options.token
|
|
188
|
+
});
|
|
189
|
+
const healthy = await client.health();
|
|
190
|
+
if (!healthy) {
|
|
191
|
+
console.log(chalk.yellow(`Warning: Could not reach registry at ${registryUrl}`));
|
|
192
|
+
}
|
|
193
|
+
saveCredentials({
|
|
194
|
+
registryUrl,
|
|
195
|
+
token: options.token
|
|
196
|
+
});
|
|
197
|
+
console.log(chalk.green(`Authenticated with ${registryUrl}`));
|
|
198
|
+
console.log(chalk.dim("Credentials saved to ~/.config/agentpacks/credentials.json"));
|
|
199
|
+
}
|
|
200
|
+
export {
|
|
201
|
+
runLogin
|
|
202
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
interface ModelsExplainOptions {
|
|
2
|
+
config?: string;
|
|
3
|
+
profile?: string;
|
|
4
|
+
target?: string;
|
|
5
|
+
task?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Explain model profile and routing resolution for a given context.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* agentpacks models explain
|
|
12
|
+
* agentpacks models explain --profile performance
|
|
13
|
+
* agentpacks models explain --task "complex refactor" --target opencode
|
|
14
|
+
*/
|
|
15
|
+
export declare function runModelsExplain(options: ModelsExplainOptions): void;
|
|
16
|
+
export {};
|