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
|
@@ -1,32 +1,4 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
-
var __toCommonJS = (from) => {
|
|
8
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
-
if (entry)
|
|
10
|
-
return entry;
|
|
11
|
-
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
-
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
-
get: () => from[key],
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
}));
|
|
17
|
-
__moduleCache.set(from, entry);
|
|
18
|
-
return entry;
|
|
19
|
-
};
|
|
20
|
-
var __export = (target, all) => {
|
|
21
|
-
for (var name in all)
|
|
22
|
-
__defProp(target, name, {
|
|
23
|
-
get: all[name],
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
set: (newValue) => all[name] = () => newValue
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
30
2
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
31
3
|
|
|
32
4
|
// src/sources/git-ref.ts
|
|
@@ -51,9 +23,14 @@ function parseGitSourceRef(source) {
|
|
|
51
23
|
if (parts.length < 2) {
|
|
52
24
|
throw new Error(`Invalid git source reference: "${source}". Expected owner/repo format.`);
|
|
53
25
|
}
|
|
26
|
+
const owner = parts[0];
|
|
27
|
+
const repo = parts[1];
|
|
28
|
+
if (!owner || !repo) {
|
|
29
|
+
throw new Error(`Invalid git source reference: "${source}". Expected owner/repo format.`);
|
|
30
|
+
}
|
|
54
31
|
return {
|
|
55
|
-
owner
|
|
56
|
-
repo
|
|
32
|
+
owner,
|
|
33
|
+
repo,
|
|
57
34
|
ref,
|
|
58
35
|
path: path || ""
|
|
59
36
|
};
|
package/dist/node/sources/git.js
CHANGED
|
@@ -1,32 +1,4 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
-
var __toCommonJS = (from) => {
|
|
8
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
-
if (entry)
|
|
10
|
-
return entry;
|
|
11
|
-
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
-
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
-
get: () => from[key],
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
}));
|
|
17
|
-
__moduleCache.set(from, entry);
|
|
18
|
-
return entry;
|
|
19
|
-
};
|
|
20
|
-
var __export = (target, all) => {
|
|
21
|
-
for (var name in all)
|
|
22
|
-
__defProp(target, name, {
|
|
23
|
-
get: all[name],
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
set: (newValue) => all[name] = () => newValue
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
30
2
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
31
3
|
|
|
32
4
|
// src/core/lockfile.ts
|
|
@@ -85,9 +57,14 @@ function parseGitSourceRef(source) {
|
|
|
85
57
|
if (parts.length < 2) {
|
|
86
58
|
throw new Error(`Invalid git source reference: "${source}". Expected owner/repo format.`);
|
|
87
59
|
}
|
|
60
|
+
const owner = parts[0];
|
|
61
|
+
const repo = parts[1];
|
|
62
|
+
if (!owner || !repo) {
|
|
63
|
+
throw new Error(`Invalid git source reference: "${source}". Expected owner/repo format.`);
|
|
64
|
+
}
|
|
88
65
|
return {
|
|
89
|
-
owner
|
|
90
|
-
repo
|
|
66
|
+
owner,
|
|
67
|
+
repo,
|
|
91
68
|
ref,
|
|
92
69
|
path: path || ""
|
|
93
70
|
};
|
|
@@ -1,32 +1,4 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
-
var __toCommonJS = (from) => {
|
|
8
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
-
if (entry)
|
|
10
|
-
return entry;
|
|
11
|
-
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
-
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
-
get: () => from[key],
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
}));
|
|
17
|
-
__moduleCache.set(from, entry);
|
|
18
|
-
return entry;
|
|
19
|
-
};
|
|
20
|
-
var __export = (target, all) => {
|
|
21
|
-
for (var name in all)
|
|
22
|
-
__defProp(target, name, {
|
|
23
|
-
get: all[name],
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
set: (newValue) => all[name] = () => newValue
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
30
2
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
31
3
|
|
|
32
4
|
// src/core/lockfile.ts
|
|
@@ -103,9 +75,14 @@ function parseGitSourceRef(source) {
|
|
|
103
75
|
if (parts.length < 2) {
|
|
104
76
|
throw new Error(`Invalid git source reference: "${source}". Expected owner/repo format.`);
|
|
105
77
|
}
|
|
78
|
+
const owner = parts[0];
|
|
79
|
+
const repo = parts[1];
|
|
80
|
+
if (!owner || !repo) {
|
|
81
|
+
throw new Error(`Invalid git source reference: "${source}". Expected owner/repo format.`);
|
|
82
|
+
}
|
|
106
83
|
return {
|
|
107
|
-
owner
|
|
108
|
-
repo
|
|
84
|
+
owner,
|
|
85
|
+
repo,
|
|
109
86
|
ref,
|
|
110
87
|
path: path || ""
|
|
111
88
|
};
|
|
@@ -174,6 +151,36 @@ function npmSourceKey(parsed) {
|
|
|
174
151
|
return `npm:${parsed.packageName}`;
|
|
175
152
|
}
|
|
176
153
|
|
|
154
|
+
// src/sources/registry-ref.ts
|
|
155
|
+
function parseRegistrySourceRef(source) {
|
|
156
|
+
let s = source;
|
|
157
|
+
if (s.startsWith("registry:")) {
|
|
158
|
+
s = s.slice(9);
|
|
159
|
+
}
|
|
160
|
+
if (!s) {
|
|
161
|
+
throw new Error(`Invalid registry source reference: "${source}". Expected pack name.`);
|
|
162
|
+
}
|
|
163
|
+
let version = "latest";
|
|
164
|
+
const atIdx = s.indexOf("@");
|
|
165
|
+
if (atIdx > 0) {
|
|
166
|
+
version = s.slice(atIdx + 1);
|
|
167
|
+
s = s.slice(0, atIdx);
|
|
168
|
+
}
|
|
169
|
+
if (!s) {
|
|
170
|
+
throw new Error(`Invalid registry source reference: "${source}". Pack name is empty.`);
|
|
171
|
+
}
|
|
172
|
+
if (!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(s)) {
|
|
173
|
+
throw new Error(`Invalid registry pack name: "${s}". Must be lowercase alphanumeric with hyphens.`);
|
|
174
|
+
}
|
|
175
|
+
return { packName: s, version };
|
|
176
|
+
}
|
|
177
|
+
function isRegistryPackRef(packRef) {
|
|
178
|
+
return packRef.startsWith("registry:");
|
|
179
|
+
}
|
|
180
|
+
function registrySourceKey(parsed) {
|
|
181
|
+
return `registry:${parsed.packName}`;
|
|
182
|
+
}
|
|
183
|
+
|
|
177
184
|
// src/sources/git.ts
|
|
178
185
|
import { mkdirSync, writeFileSync as writeFileSync2 } from "fs";
|
|
179
186
|
import { resolve as resolve3, join } from "path";
|
|
@@ -306,7 +313,7 @@ async function installGitSource(projectRoot, source, lockfile, options = {}) {
|
|
|
306
313
|
}
|
|
307
314
|
|
|
308
315
|
// src/sources/npm.ts
|
|
309
|
-
import { mkdirSync as mkdirSync2, existsSync as existsSync3 } from "fs";
|
|
316
|
+
import { mkdirSync as mkdirSync2, existsSync as existsSync3, readdirSync } from "fs";
|
|
310
317
|
import { resolve as resolve4, join as join2 } from "path";
|
|
311
318
|
import { execSync } from "child_process";
|
|
312
319
|
var NPM_REGISTRY = "https://registry.npmjs.org";
|
|
@@ -331,18 +338,15 @@ async function installNpmSource(projectRoot, source, lockfile, options = {}) {
|
|
|
331
338
|
throw new Error(`Frozen mode: no lockfile entry for source "${sourceKey}".`);
|
|
332
339
|
}
|
|
333
340
|
let resolvedVersion;
|
|
334
|
-
let tarballUrl;
|
|
335
341
|
if (locked && !options.update) {
|
|
336
342
|
resolvedVersion = locked.resolvedRef;
|
|
337
|
-
tarballUrl = "";
|
|
338
343
|
} else {
|
|
339
344
|
const resolved = await resolveNpmVersion(parsed);
|
|
340
345
|
resolvedVersion = resolved.version;
|
|
341
|
-
tarballUrl = resolved.tarball;
|
|
342
346
|
}
|
|
343
347
|
const curatedDir = resolve4(projectRoot, ".agentpacks", ".curated");
|
|
344
348
|
mkdirSync2(curatedDir, { recursive: true });
|
|
345
|
-
|
|
349
|
+
extractNpmPack(parsed, resolvedVersion, curatedDir, installed, warnings);
|
|
346
350
|
const newEntry = {
|
|
347
351
|
requestedRef: parsed.version,
|
|
348
352
|
resolvedRef: resolvedVersion,
|
|
@@ -364,12 +368,17 @@ function extractNpmPack(parsed, version, curatedDir, installed, warnings) {
|
|
|
364
368
|
stdio: "pipe",
|
|
365
369
|
timeout: 30000
|
|
366
370
|
});
|
|
367
|
-
const tgzFiles =
|
|
371
|
+
const tgzFiles = readdirSync(tmpDir).filter((f) => f.endsWith(".tgz"));
|
|
368
372
|
if (tgzFiles.length === 0) {
|
|
369
373
|
warnings.push(`No tarball found for ${pkgSpec}`);
|
|
370
374
|
return packOutDir;
|
|
371
375
|
}
|
|
372
|
-
const
|
|
376
|
+
const firstTgz = tgzFiles[0];
|
|
377
|
+
if (!firstTgz) {
|
|
378
|
+
warnings.push(`No tarball found for ${pkgSpec}`);
|
|
379
|
+
return packOutDir;
|
|
380
|
+
}
|
|
381
|
+
const tgzPath = join2(tmpDir, firstTgz);
|
|
373
382
|
mkdirSync2(packOutDir, { recursive: true });
|
|
374
383
|
execSync(`tar xzf "${tgzPath}" -C "${packOutDir}" --strip-components=1`, {
|
|
375
384
|
stdio: "pipe",
|
|
@@ -387,8 +396,7 @@ function extractNpmPack(parsed, version, curatedDir, installed, warnings) {
|
|
|
387
396
|
return packOutDir;
|
|
388
397
|
}
|
|
389
398
|
function collectFiles(dir, out) {
|
|
390
|
-
const
|
|
391
|
-
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
399
|
+
const entries = readdirSync(dir, { withFileTypes: true });
|
|
392
400
|
for (const entry of entries) {
|
|
393
401
|
const full = join2(dir, entry.name);
|
|
394
402
|
if (entry.isDirectory()) {
|
|
@@ -398,16 +406,306 @@ function collectFiles(dir, out) {
|
|
|
398
406
|
}
|
|
399
407
|
}
|
|
400
408
|
}
|
|
409
|
+
|
|
410
|
+
// src/utils/registry-client.ts
|
|
411
|
+
var DEFAULT_REGISTRY_URL = "https://registry.agentpacks.dev";
|
|
412
|
+
function createRegistryClient(config) {
|
|
413
|
+
return new RegistryClient({
|
|
414
|
+
registryUrl: config?.registryUrl ?? DEFAULT_REGISTRY_URL,
|
|
415
|
+
authToken: config?.authToken,
|
|
416
|
+
timeout: config?.timeout ?? 30000
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
class RegistryClient {
|
|
421
|
+
config;
|
|
422
|
+
constructor(config) {
|
|
423
|
+
this.config = {
|
|
424
|
+
registryUrl: config.registryUrl.replace(/\/+$/, ""),
|
|
425
|
+
authToken: config.authToken,
|
|
426
|
+
timeout: config.timeout ?? 30000
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
async search(params) {
|
|
430
|
+
const searchParams = new URLSearchParams;
|
|
431
|
+
if (params.query)
|
|
432
|
+
searchParams.set("q", params.query);
|
|
433
|
+
if (params.tags?.length)
|
|
434
|
+
searchParams.set("tags", params.tags.join(","));
|
|
435
|
+
if (params.targets?.length)
|
|
436
|
+
searchParams.set("targets", params.targets.join(","));
|
|
437
|
+
if (params.features?.length)
|
|
438
|
+
searchParams.set("features", params.features.join(","));
|
|
439
|
+
if (params.author)
|
|
440
|
+
searchParams.set("author", params.author);
|
|
441
|
+
if (params.sort)
|
|
442
|
+
searchParams.set("sort", params.sort);
|
|
443
|
+
if (params.limit)
|
|
444
|
+
searchParams.set("limit", String(params.limit));
|
|
445
|
+
if (params.offset)
|
|
446
|
+
searchParams.set("offset", String(params.offset));
|
|
447
|
+
const url = `${this.config.registryUrl}/packs?${searchParams.toString()}`;
|
|
448
|
+
const res = await this.fetch(url);
|
|
449
|
+
return res;
|
|
450
|
+
}
|
|
451
|
+
async info(packName) {
|
|
452
|
+
const url = `${this.config.registryUrl}/packs/${encodeURIComponent(packName)}`;
|
|
453
|
+
const res = await this.fetch(url);
|
|
454
|
+
return res;
|
|
455
|
+
}
|
|
456
|
+
async download(packName, version = "latest") {
|
|
457
|
+
const url = `${this.config.registryUrl}/packs/${encodeURIComponent(packName)}/versions/${encodeURIComponent(version)}/download`;
|
|
458
|
+
const response = await fetch(url, {
|
|
459
|
+
headers: this.headers(),
|
|
460
|
+
signal: AbortSignal.timeout(this.config.timeout)
|
|
461
|
+
});
|
|
462
|
+
if (!response.ok) {
|
|
463
|
+
throw new RegistryApiError(response.status, `Failed to download ${packName}@${version}: ${response.statusText}`);
|
|
464
|
+
}
|
|
465
|
+
const integrity = response.headers.get("x-integrity") ?? "";
|
|
466
|
+
const data = await response.arrayBuffer();
|
|
467
|
+
return { data, integrity };
|
|
468
|
+
}
|
|
469
|
+
async publish(tarball, metadata) {
|
|
470
|
+
if (!this.config.authToken) {
|
|
471
|
+
throw new Error("Authentication required. Run `agentpacks login` first.");
|
|
472
|
+
}
|
|
473
|
+
const formData = new FormData;
|
|
474
|
+
formData.append("tarball", new Blob([tarball], { type: "application/gzip" }), `${metadata.name}-${metadata.version}.tgz`);
|
|
475
|
+
formData.append("metadata", JSON.stringify(metadata));
|
|
476
|
+
const url = `${this.config.registryUrl}/packs`;
|
|
477
|
+
const response = await fetch(url, {
|
|
478
|
+
method: "POST",
|
|
479
|
+
headers: {
|
|
480
|
+
Authorization: `Bearer ${this.config.authToken}`
|
|
481
|
+
},
|
|
482
|
+
body: formData,
|
|
483
|
+
signal: AbortSignal.timeout(this.config.timeout)
|
|
484
|
+
});
|
|
485
|
+
if (!response.ok) {
|
|
486
|
+
const body = await response.text();
|
|
487
|
+
throw new RegistryApiError(response.status, `Publish failed: ${body || response.statusText}`);
|
|
488
|
+
}
|
|
489
|
+
return await response.json();
|
|
490
|
+
}
|
|
491
|
+
async featured(limit) {
|
|
492
|
+
const url = limit ? `${this.config.registryUrl}/featured?limit=${limit}` : `${this.config.registryUrl}/featured`;
|
|
493
|
+
const res = await this.fetch(url);
|
|
494
|
+
return res.packs;
|
|
495
|
+
}
|
|
496
|
+
async tags() {
|
|
497
|
+
const url = `${this.config.registryUrl}/tags`;
|
|
498
|
+
const res = await this.fetch(url);
|
|
499
|
+
return res.tags;
|
|
500
|
+
}
|
|
501
|
+
async stats() {
|
|
502
|
+
const url = `${this.config.registryUrl}/stats`;
|
|
503
|
+
return await this.fetch(url);
|
|
504
|
+
}
|
|
505
|
+
async health() {
|
|
506
|
+
try {
|
|
507
|
+
const url = `${this.config.registryUrl}/health`;
|
|
508
|
+
await this.fetch(url);
|
|
509
|
+
return true;
|
|
510
|
+
} catch {
|
|
511
|
+
return false;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
async fetch(url) {
|
|
515
|
+
const response = await fetch(url, {
|
|
516
|
+
headers: this.headers(),
|
|
517
|
+
signal: AbortSignal.timeout(this.config.timeout)
|
|
518
|
+
});
|
|
519
|
+
if (!response.ok) {
|
|
520
|
+
const body = await response.text();
|
|
521
|
+
throw new RegistryApiError(response.status, body || response.statusText);
|
|
522
|
+
}
|
|
523
|
+
return response.json();
|
|
524
|
+
}
|
|
525
|
+
headers() {
|
|
526
|
+
const h = {
|
|
527
|
+
Accept: "application/json"
|
|
528
|
+
};
|
|
529
|
+
if (this.config.authToken) {
|
|
530
|
+
h["Authorization"] = `Bearer ${this.config.authToken}`;
|
|
531
|
+
}
|
|
532
|
+
return h;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
class RegistryApiError extends Error {
|
|
537
|
+
status;
|
|
538
|
+
constructor(status, message) {
|
|
539
|
+
super(message);
|
|
540
|
+
this.name = "RegistryApiError";
|
|
541
|
+
this.status = status;
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
// src/utils/credentials.ts
|
|
546
|
+
import { existsSync as existsSync4, readFileSync as readFileSync2, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3 } from "fs";
|
|
547
|
+
import { join as join3, dirname } from "path";
|
|
548
|
+
import { homedir } from "os";
|
|
549
|
+
var CONFIG_DIR = join3(homedir(), ".config", "agentpacks");
|
|
550
|
+
var CREDENTIALS_FILE = join3(CONFIG_DIR, "credentials.json");
|
|
551
|
+
function loadCredentials() {
|
|
552
|
+
if (!existsSync4(CREDENTIALS_FILE)) {
|
|
553
|
+
return { registryUrl: "https://registry.agentpacks.dev" };
|
|
554
|
+
}
|
|
555
|
+
try {
|
|
556
|
+
const raw = readFileSync2(CREDENTIALS_FILE, "utf-8");
|
|
557
|
+
return JSON.parse(raw);
|
|
558
|
+
} catch {
|
|
559
|
+
return { registryUrl: "https://registry.agentpacks.dev" };
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
function saveCredentials(credentials) {
|
|
563
|
+
mkdirSync3(dirname(CREDENTIALS_FILE), { recursive: true });
|
|
564
|
+
writeFileSync3(CREDENTIALS_FILE, JSON.stringify(credentials, null, 2) + `
|
|
565
|
+
`, {
|
|
566
|
+
mode: 384
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
function clearCredentials() {
|
|
570
|
+
if (existsSync4(CREDENTIALS_FILE)) {
|
|
571
|
+
writeFileSync3(CREDENTIALS_FILE, JSON.stringify({ registryUrl: "https://registry.agentpacks.dev" }) + `
|
|
572
|
+
`);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
// src/utils/tarball.ts
|
|
577
|
+
import { execSync as execSync2 } from "child_process";
|
|
578
|
+
import { readFileSync as readFileSync3, existsSync as existsSync5, mkdirSync as mkdirSync4, rmSync } from "fs";
|
|
579
|
+
import { join as join4, resolve as resolve5 } from "path";
|
|
580
|
+
import { createHash as createHash2 } from "crypto";
|
|
581
|
+
import { tmpdir } from "os";
|
|
582
|
+
async function createTarball(packDir) {
|
|
583
|
+
const absDir = resolve5(packDir);
|
|
584
|
+
const tmpFile = join4(tmpdir(), `agentpacks-${Date.now()}.tgz`);
|
|
585
|
+
try {
|
|
586
|
+
execSync2(`tar -czf "${tmpFile}" -C "${absDir}" .`, {
|
|
587
|
+
stdio: "pipe"
|
|
588
|
+
});
|
|
589
|
+
const buffer = readFileSync3(tmpFile);
|
|
590
|
+
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
591
|
+
} finally {
|
|
592
|
+
if (existsSync5(tmpFile)) {
|
|
593
|
+
rmSync(tmpFile);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
async function extractTarball(data, targetDir) {
|
|
598
|
+
mkdirSync4(targetDir, { recursive: true });
|
|
599
|
+
const tmpFile = join4(tmpdir(), `agentpacks-${Date.now()}.tgz`);
|
|
600
|
+
try {
|
|
601
|
+
const buffer = Buffer.from(data);
|
|
602
|
+
const { writeFileSync: writeFileSync4 } = await import("fs");
|
|
603
|
+
writeFileSync4(tmpFile, buffer);
|
|
604
|
+
execSync2(`tar -xzf "${tmpFile}" -C "${targetDir}"`, {
|
|
605
|
+
stdio: "pipe"
|
|
606
|
+
});
|
|
607
|
+
} finally {
|
|
608
|
+
if (existsSync5(tmpFile)) {
|
|
609
|
+
rmSync(tmpFile);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
function computeTarballIntegrity(data) {
|
|
614
|
+
const hash = createHash2("sha256").update(Buffer.from(data)).digest("hex");
|
|
615
|
+
return `sha256-${hash}`;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
// src/sources/registry.ts
|
|
619
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync5, readdirSync as readdirSync2, rmSync as rmSync2 } from "fs";
|
|
620
|
+
import { resolve as resolve6, join as join5 } from "path";
|
|
621
|
+
async function installRegistrySource(projectRoot, source, lockfile, options = {}) {
|
|
622
|
+
const parsed = parseRegistrySourceRef(source);
|
|
623
|
+
const sourceKey = registrySourceKey(parsed);
|
|
624
|
+
const installed = [];
|
|
625
|
+
const warnings = [];
|
|
626
|
+
const locked = getLockedSource(lockfile, sourceKey);
|
|
627
|
+
if (options.frozen && !locked) {
|
|
628
|
+
throw new Error(`Frozen mode: no lockfile entry for source "${sourceKey}".`);
|
|
629
|
+
}
|
|
630
|
+
let targetVersion = parsed.version;
|
|
631
|
+
if (locked && !options.update) {
|
|
632
|
+
targetVersion = locked.resolvedRef;
|
|
633
|
+
} else if (targetVersion === "latest") {
|
|
634
|
+
const clientCfg2 = buildClientConfig(options.registryUrl);
|
|
635
|
+
const client2 = createRegistryClient(clientCfg2);
|
|
636
|
+
const info = await client2.info(parsed.packName);
|
|
637
|
+
targetVersion = info.latestVersion;
|
|
638
|
+
}
|
|
639
|
+
const clientCfg = buildClientConfig(options.registryUrl);
|
|
640
|
+
const client = createRegistryClient(clientCfg);
|
|
641
|
+
const { data } = await client.download(parsed.packName, targetVersion);
|
|
642
|
+
const localIntegrity = computeTarballIntegrity(data);
|
|
643
|
+
if (locked && !options.update && locked.skills?.["__integrity"]) {
|
|
644
|
+
const expectedIntegrity = locked.skills["__integrity"].integrity;
|
|
645
|
+
if (expectedIntegrity && localIntegrity !== expectedIntegrity) {
|
|
646
|
+
throw new Error(`Integrity mismatch for ${parsed.packName}@${targetVersion}. ` + `Expected ${expectedIntegrity}, got ${localIntegrity}.`);
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
const curatedDir = resolve6(projectRoot, ".agentpacks", ".curated");
|
|
650
|
+
const packOutDir = resolve6(curatedDir, parsed.packName);
|
|
651
|
+
if (existsSync6(packOutDir)) {
|
|
652
|
+
rmSync2(packOutDir, { recursive: true, force: true });
|
|
653
|
+
}
|
|
654
|
+
mkdirSync5(packOutDir, { recursive: true });
|
|
655
|
+
await extractTarball(data, packOutDir);
|
|
656
|
+
collectFiles2(packOutDir, installed);
|
|
657
|
+
const newEntry = {
|
|
658
|
+
requestedRef: parsed.version,
|
|
659
|
+
resolvedRef: targetVersion,
|
|
660
|
+
resolvedAt: new Date().toISOString(),
|
|
661
|
+
skills: {
|
|
662
|
+
__integrity: { integrity: localIntegrity }
|
|
663
|
+
},
|
|
664
|
+
packs: {
|
|
665
|
+
[parsed.packName]: { integrity: localIntegrity }
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
setLockedSource(lockfile, sourceKey, newEntry);
|
|
669
|
+
return { installed, warnings };
|
|
670
|
+
}
|
|
671
|
+
function buildClientConfig(registryUrl) {
|
|
672
|
+
const cfg = {};
|
|
673
|
+
if (registryUrl) {
|
|
674
|
+
cfg.registryUrl = registryUrl;
|
|
675
|
+
}
|
|
676
|
+
try {
|
|
677
|
+
const creds = loadCredentials();
|
|
678
|
+
if (creds?.token) {
|
|
679
|
+
cfg.authToken = creds.token;
|
|
680
|
+
}
|
|
681
|
+
} catch {}
|
|
682
|
+
return cfg;
|
|
683
|
+
}
|
|
684
|
+
function collectFiles2(dir, out) {
|
|
685
|
+
const entries = readdirSync2(dir, { withFileTypes: true });
|
|
686
|
+
for (const entry of entries) {
|
|
687
|
+
const full = join5(dir, entry.name);
|
|
688
|
+
if (entry.isDirectory()) {
|
|
689
|
+
collectFiles2(full, out);
|
|
690
|
+
} else {
|
|
691
|
+
out.push(full);
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
}
|
|
401
695
|
export {
|
|
402
696
|
resolveNpmVersion,
|
|
403
697
|
resolveLocalPack,
|
|
404
698
|
resolveGitRef,
|
|
699
|
+
registrySourceKey,
|
|
700
|
+
parseRegistrySourceRef,
|
|
405
701
|
parseNpmSourceRef,
|
|
406
702
|
parseGitSourceRef,
|
|
407
703
|
npmSourceKey,
|
|
704
|
+
isRegistryPackRef,
|
|
408
705
|
isNpmPackRef,
|
|
409
706
|
isLocalPackRef,
|
|
410
707
|
isGitPackRef,
|
|
708
|
+
installRegistrySource,
|
|
411
709
|
installNpmSource,
|
|
412
710
|
installGitSource,
|
|
413
711
|
gitSourceKey,
|
|
@@ -1,32 +1,4 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
-
var __toCommonJS = (from) => {
|
|
8
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
-
if (entry)
|
|
10
|
-
return entry;
|
|
11
|
-
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
-
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
-
get: () => from[key],
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
}));
|
|
17
|
-
__moduleCache.set(from, entry);
|
|
18
|
-
return entry;
|
|
19
|
-
};
|
|
20
|
-
var __export = (target, all) => {
|
|
21
|
-
for (var name in all)
|
|
22
|
-
__defProp(target, name, {
|
|
23
|
-
get: all[name],
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
set: (newValue) => all[name] = () => newValue
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
30
2
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
31
3
|
|
|
32
4
|
// src/sources/local.ts
|
|
@@ -1,32 +1,4 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
7
|
-
var __toCommonJS = (from) => {
|
|
8
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
-
if (entry)
|
|
10
|
-
return entry;
|
|
11
|
-
entry = __defProp({}, "__esModule", { value: true });
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
13
|
-
__getOwnPropNames(from).map((key) => !__hasOwnProp.call(entry, key) && __defProp(entry, key, {
|
|
14
|
-
get: () => from[key],
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
}));
|
|
17
|
-
__moduleCache.set(from, entry);
|
|
18
|
-
return entry;
|
|
19
|
-
};
|
|
20
|
-
var __export = (target, all) => {
|
|
21
|
-
for (var name in all)
|
|
22
|
-
__defProp(target, name, {
|
|
23
|
-
get: all[name],
|
|
24
|
-
enumerable: true,
|
|
25
|
-
configurable: true,
|
|
26
|
-
set: (newValue) => all[name] = () => newValue
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
|
|
30
2
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
31
3
|
|
|
32
4
|
// src/sources/npm-ref.ts
|