agentpacks 1.7.6 → 1.7.9
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 +69 -742
- package/dist/api.d.ts +15 -15
- package/dist/api.js +2706 -2706
- package/dist/cli/export-cmd.js +364 -364
- package/dist/cli/generate.js +1409 -1409
- package/dist/cli/import-cmd.js +249 -249
- package/dist/cli/info.js +31 -31
- package/dist/cli/init.js +6 -6
- package/dist/cli/install.js +141 -141
- package/dist/cli/login.js +31 -31
- package/dist/cli/models-explain.js +514 -514
- package/dist/cli/pack/create.js +6 -6
- package/dist/cli/pack/enable.js +2 -2
- package/dist/cli/pack/list.js +362 -362
- package/dist/cli/pack/validate.js +119 -119
- package/dist/cli/publish.js +42 -42
- package/dist/cli/search.js +31 -31
- package/dist/core/config.js +3 -3
- package/dist/core/feature-merger.d.ts +5 -5
- package/dist/core/feature-merger.js +4 -4
- package/dist/core/index.d.ts +4 -4
- package/dist/core/index.js +633 -633
- package/dist/core/lockfile.js +1 -1
- package/dist/core/metarepo.js +3 -3
- package/dist/core/pack-loader.d.ts +6 -6
- package/dist/core/pack-loader.js +362 -362
- package/dist/core/profile-resolver.d.ts +1 -1
- package/dist/exporters/cursor-plugin.d.ts +12 -0
- package/dist/exporters/cursor-plugin.js +46 -46
- package/dist/exporters/index.d.ts +1 -1
- package/dist/exporters/index.js +46 -46
- package/dist/features/agents.js +4 -4
- package/dist/features/commands.js +4 -4
- package/dist/features/hooks.js +4 -4
- package/dist/features/index.d.ts +8 -8
- package/dist/features/index.js +350 -350
- package/dist/features/mcp.js +4 -4
- package/dist/features/models.js +4 -4
- package/dist/features/plugins.js +5 -5
- package/dist/features/rules.js +4 -4
- package/dist/features/skills.js +5 -5
- package/dist/importers/claude-code.js +6 -6
- package/dist/importers/cursor.js +7 -7
- package/dist/importers/opencode.js +7 -7
- package/dist/importers/rulesync.js +7 -7
- package/dist/index.js +2674 -2674
- package/dist/node/api.js +2706 -2706
- package/dist/node/cli/export-cmd.js +364 -364
- package/dist/node/cli/generate.js +1409 -1409
- package/dist/node/cli/import-cmd.js +249 -249
- package/dist/node/cli/info.js +31 -31
- package/dist/node/cli/init.js +6 -6
- package/dist/node/cli/install.js +141 -141
- package/dist/node/cli/login.js +31 -31
- package/dist/node/cli/models-explain.js +514 -514
- package/dist/node/cli/pack/create.js +6 -6
- package/dist/node/cli/pack/enable.js +2 -2
- package/dist/node/cli/pack/list.js +362 -362
- package/dist/node/cli/pack/validate.js +119 -119
- package/dist/node/cli/publish.js +42 -42
- package/dist/node/cli/search.js +31 -31
- package/dist/node/core/config.js +3 -3
- package/dist/node/core/feature-merger.js +4 -4
- package/dist/node/core/index.js +633 -633
- package/dist/node/core/lockfile.js +1 -1
- package/dist/node/core/metarepo.js +3 -3
- package/dist/node/core/pack-loader.js +362 -362
- package/dist/node/exporters/cursor-plugin.js +46 -46
- package/dist/node/exporters/index.js +46 -46
- package/dist/node/features/agents.js +4 -4
- package/dist/node/features/commands.js +4 -4
- package/dist/node/features/hooks.js +4 -4
- package/dist/node/features/index.js +350 -350
- package/dist/node/features/mcp.js +4 -4
- package/dist/node/features/models.js +4 -4
- package/dist/node/features/plugins.js +5 -5
- package/dist/node/features/rules.js +4 -4
- package/dist/node/features/skills.js +5 -5
- package/dist/node/importers/claude-code.js +6 -6
- package/dist/node/importers/cursor.js +7 -7
- package/dist/node/importers/opencode.js +7 -7
- package/dist/node/importers/rulesync.js +7 -7
- package/dist/node/index.js +2674 -2674
- package/dist/node/sources/git.js +2 -2
- package/dist/node/sources/index.js +138 -138
- package/dist/node/sources/local.js +1 -1
- package/dist/node/sources/npm.js +3 -3
- package/dist/node/sources/registry.js +35 -35
- package/dist/node/targets/additional-targets.js +43 -43
- package/dist/node/targets/agents-md.js +4 -4
- package/dist/node/targets/claude-code.js +86 -86
- package/dist/node/targets/codex-cli.js +6 -6
- package/dist/node/targets/copilot.js +46 -46
- package/dist/node/targets/cursor.js +68 -68
- package/dist/node/targets/gemini-cli.js +25 -25
- package/dist/node/targets/generic-md-target.js +43 -43
- package/dist/node/targets/index.js +911 -911
- package/dist/node/targets/mistral-vibe.js +46 -46
- package/dist/node/targets/opencode.js +68 -68
- package/dist/node/targets/registry.js +911 -911
- package/dist/node/utils/credentials.js +2 -2
- package/dist/node/utils/filesystem.js +4 -4
- package/dist/node/utils/global.js +1 -1
- package/dist/node/utils/tarball.js +2 -2
- package/dist/sources/git.js +2 -2
- package/dist/sources/index.d.ts +6 -6
- package/dist/sources/index.js +138 -138
- package/dist/sources/local.js +1 -1
- package/dist/sources/npm.d.ts +3 -0
- package/dist/sources/npm.js +3 -3
- package/dist/sources/registry.js +35 -35
- package/dist/targets/additional-targets.js +43 -43
- package/dist/targets/agents-md.js +4 -4
- package/dist/targets/claude-code.js +86 -86
- package/dist/targets/codex-cli.js +6 -6
- package/dist/targets/copilot.js +46 -46
- package/dist/targets/cursor.js +68 -68
- package/dist/targets/gemini-cli.js +25 -25
- package/dist/targets/generic-md-target.js +43 -43
- package/dist/targets/index.d.ts +6 -6
- package/dist/targets/index.js +911 -911
- package/dist/targets/mistral-vibe.js +46 -46
- package/dist/targets/opencode.js +68 -68
- package/dist/targets/registry.js +911 -911
- package/dist/utils/credentials.js +2 -2
- package/dist/utils/filesystem.js +4 -4
- package/dist/utils/global.d.ts +3 -0
- package/dist/utils/global.js +1 -1
- package/dist/utils/tarball.js +2 -2
- package/package.json +5 -5
- package/templates/pack/models.json +36 -36
- package/templates/pack/pack.json +8 -8
- package/templates/workspace/agentpacks.jsonc +24 -24
package/dist/cli/info.js
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var __require = import.meta.require;
|
|
3
3
|
|
|
4
|
+
// src/utils/credentials.ts
|
|
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
|
+
|
|
4
35
|
// src/utils/registry-client.ts
|
|
5
36
|
var DEFAULT_REGISTRY_URL = "https://registry.agentpacks.dev";
|
|
6
37
|
function createRegistryClient(config) {
|
|
@@ -136,37 +167,6 @@ class RegistryApiError extends Error {
|
|
|
136
167
|
}
|
|
137
168
|
}
|
|
138
169
|
|
|
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
170
|
// src/cli/info.ts
|
|
171
171
|
import chalk from "chalk";
|
|
172
172
|
async function runInfo(packName) {
|
package/dist/cli/init.js
CHANGED
|
@@ -5,13 +5,13 @@ var __require = import.meta.require;
|
|
|
5
5
|
import {
|
|
6
6
|
existsSync,
|
|
7
7
|
mkdirSync,
|
|
8
|
-
readFileSync,
|
|
9
|
-
writeFileSync,
|
|
10
8
|
readdirSync,
|
|
9
|
+
readFileSync,
|
|
11
10
|
rmSync,
|
|
12
|
-
statSync
|
|
11
|
+
statSync,
|
|
12
|
+
writeFileSync
|
|
13
13
|
} from "fs";
|
|
14
|
-
import { dirname,
|
|
14
|
+
import { dirname, join, relative } from "path";
|
|
15
15
|
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
16
16
|
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
17
17
|
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
@@ -112,9 +112,9 @@ function getHeader(type) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
// src/cli/init.ts
|
|
115
|
-
import { existsSync as existsSync2, copyFileSync, writeFileSync as writeFileSync2 } from "fs";
|
|
116
|
-
import { resolve, join as join2 } from "path";
|
|
117
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
118
|
function runInit(projectRoot) {
|
|
119
119
|
const configPath = resolve(projectRoot, "agentpacks.jsonc");
|
|
120
120
|
const packsDir = resolve(projectRoot, "packs", "default");
|
package/dist/cli/install.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
var __require = import.meta.require;
|
|
3
3
|
|
|
4
4
|
// src/core/config.ts
|
|
5
|
-
import {
|
|
6
|
-
import { readFileSync, existsSync } from "fs";
|
|
7
|
-
import { resolve } from "path";
|
|
5
|
+
import { existsSync, readFileSync } from "fs";
|
|
8
6
|
import { parse as parseJsonc } from "jsonc-parser";
|
|
7
|
+
import { resolve } from "path";
|
|
8
|
+
import { z } from "zod";
|
|
9
9
|
var TARGET_IDS = [
|
|
10
10
|
"opencode",
|
|
11
11
|
"cursor",
|
|
@@ -135,9 +135,9 @@ function resolveTargets(config) {
|
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
// src/core/lockfile.ts
|
|
138
|
+
import { createHash } from "crypto";
|
|
138
139
|
import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync } from "fs";
|
|
139
140
|
import { resolve as resolve2 } from "path";
|
|
140
|
-
import { createHash } from "crypto";
|
|
141
141
|
var LOCKFILE_VERSION = 1;
|
|
142
142
|
var LOCKFILE_NAME = "agentpacks.lock";
|
|
143
143
|
function loadLockfile(projectRoot) {
|
|
@@ -168,24 +168,6 @@ function isLockfileFrozenValid(lockfile, sourceKeys) {
|
|
|
168
168
|
return { valid: missing.length === 0, missing };
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
// src/sources/local.ts
|
|
172
|
-
import { existsSync as existsSync3 } from "fs";
|
|
173
|
-
import { resolve as resolve3, isAbsolute } from "path";
|
|
174
|
-
function resolveLocalPack(packRef, projectRoot) {
|
|
175
|
-
let resolved;
|
|
176
|
-
if (isAbsolute(packRef)) {
|
|
177
|
-
resolved = packRef;
|
|
178
|
-
} else {
|
|
179
|
-
resolved = resolve3(projectRoot, packRef);
|
|
180
|
-
}
|
|
181
|
-
if (!existsSync3(resolved))
|
|
182
|
-
return null;
|
|
183
|
-
return resolved;
|
|
184
|
-
}
|
|
185
|
-
function isLocalPackRef(packRef) {
|
|
186
|
-
return packRef.startsWith("./") || packRef.startsWith("../") || isAbsolute(packRef);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
171
|
// src/sources/git-ref.ts
|
|
190
172
|
function parseGitSourceRef(source) {
|
|
191
173
|
let s = source;
|
|
@@ -235,88 +217,9 @@ function gitSourceKey(parsed) {
|
|
|
235
217
|
return `${parsed.owner}/${parsed.repo}`;
|
|
236
218
|
}
|
|
237
219
|
|
|
238
|
-
// src/sources/npm-ref.ts
|
|
239
|
-
function parseNpmSourceRef(source) {
|
|
240
|
-
let s = source;
|
|
241
|
-
if (s.startsWith("npm:")) {
|
|
242
|
-
s = s.slice(4);
|
|
243
|
-
}
|
|
244
|
-
let path = "";
|
|
245
|
-
const pathColonIdx = findPathColon(s);
|
|
246
|
-
if (pathColonIdx > -1) {
|
|
247
|
-
path = s.slice(pathColonIdx + 1);
|
|
248
|
-
s = s.slice(0, pathColonIdx);
|
|
249
|
-
}
|
|
250
|
-
let version = "latest";
|
|
251
|
-
const versionAtIdx = findVersionAt(s);
|
|
252
|
-
if (versionAtIdx > -1) {
|
|
253
|
-
version = s.slice(versionAtIdx + 1);
|
|
254
|
-
s = s.slice(0, versionAtIdx);
|
|
255
|
-
}
|
|
256
|
-
if (!s) {
|
|
257
|
-
throw new Error(`Invalid npm source reference: "${source}". Expected package name.`);
|
|
258
|
-
}
|
|
259
|
-
return { packageName: s, version, path };
|
|
260
|
-
}
|
|
261
|
-
function findPathColon(s) {
|
|
262
|
-
const startAfter = s.startsWith("@") ? s.indexOf("/") + 1 : 0;
|
|
263
|
-
const vAt = findVersionAt(s);
|
|
264
|
-
const searchFrom = vAt > -1 ? vAt : startAfter;
|
|
265
|
-
return s.indexOf(":", searchFrom);
|
|
266
|
-
}
|
|
267
|
-
function findVersionAt(s) {
|
|
268
|
-
if (s.startsWith("@")) {
|
|
269
|
-
const slashIdx = s.indexOf("/");
|
|
270
|
-
if (slashIdx === -1)
|
|
271
|
-
return -1;
|
|
272
|
-
return s.indexOf("@", slashIdx + 1);
|
|
273
|
-
}
|
|
274
|
-
return s.indexOf("@");
|
|
275
|
-
}
|
|
276
|
-
function isNpmPackRef(packRef) {
|
|
277
|
-
if (packRef.startsWith("npm:"))
|
|
278
|
-
return true;
|
|
279
|
-
if (packRef.startsWith("@") && packRef.includes("/"))
|
|
280
|
-
return true;
|
|
281
|
-
return false;
|
|
282
|
-
}
|
|
283
|
-
function npmSourceKey(parsed) {
|
|
284
|
-
return `npm:${parsed.packageName}`;
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
// src/sources/registry-ref.ts
|
|
288
|
-
function parseRegistrySourceRef(source) {
|
|
289
|
-
let s = source;
|
|
290
|
-
if (s.startsWith("registry:")) {
|
|
291
|
-
s = s.slice(9);
|
|
292
|
-
}
|
|
293
|
-
if (!s) {
|
|
294
|
-
throw new Error(`Invalid registry source reference: "${source}". Expected pack name.`);
|
|
295
|
-
}
|
|
296
|
-
let version = "latest";
|
|
297
|
-
const atIdx = s.indexOf("@");
|
|
298
|
-
if (atIdx > 0) {
|
|
299
|
-
version = s.slice(atIdx + 1);
|
|
300
|
-
s = s.slice(0, atIdx);
|
|
301
|
-
}
|
|
302
|
-
if (!s) {
|
|
303
|
-
throw new Error(`Invalid registry source reference: "${source}". Pack name is empty.`);
|
|
304
|
-
}
|
|
305
|
-
if (!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(s)) {
|
|
306
|
-
throw new Error(`Invalid registry pack name: "${s}". Must be lowercase alphanumeric with hyphens.`);
|
|
307
|
-
}
|
|
308
|
-
return { packName: s, version };
|
|
309
|
-
}
|
|
310
|
-
function isRegistryPackRef(packRef) {
|
|
311
|
-
return packRef.startsWith("registry:");
|
|
312
|
-
}
|
|
313
|
-
function registrySourceKey(parsed) {
|
|
314
|
-
return `registry:${parsed.packName}`;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
220
|
// src/sources/git.ts
|
|
318
221
|
import { mkdirSync, writeFileSync as writeFileSync2 } from "fs";
|
|
319
|
-
import { resolve as
|
|
222
|
+
import { join, resolve as resolve3 } from "path";
|
|
320
223
|
var GITHUB_API = "https://api.github.com";
|
|
321
224
|
function githubHeaders(token) {
|
|
322
225
|
const h = {
|
|
@@ -394,7 +297,7 @@ async function installGitSource(projectRoot, source, lockfile, options = {}) {
|
|
|
394
297
|
}
|
|
395
298
|
const basePath = parsed.path || "packs";
|
|
396
299
|
const entries = await fetchGitDirectory(parsed, resolvedSha, basePath, options.token);
|
|
397
|
-
const curatedDir =
|
|
300
|
+
const curatedDir = resolve3(projectRoot, ".agentpacks", ".curated");
|
|
398
301
|
mkdirSync(curatedDir, { recursive: true });
|
|
399
302
|
const newLockEntry = {
|
|
400
303
|
requestedRef: parsed.ref,
|
|
@@ -406,7 +309,7 @@ async function installGitSource(projectRoot, source, lockfile, options = {}) {
|
|
|
406
309
|
const packDirs = entries.filter((e) => e.type === "dir");
|
|
407
310
|
for (const packEntry of packDirs) {
|
|
408
311
|
const packName = packEntry.name;
|
|
409
|
-
const packOutDir =
|
|
312
|
+
const packOutDir = resolve3(curatedDir, packName);
|
|
410
313
|
const packFiles = await fetchGitDirectory(parsed, resolvedSha, `${basePath}/${packName}`, options.token);
|
|
411
314
|
mkdirSync(packOutDir, { recursive: true });
|
|
412
315
|
for (const file of packFiles) {
|
|
@@ -428,7 +331,7 @@ async function installGitSource(projectRoot, source, lockfile, options = {}) {
|
|
|
428
331
|
const fileEntries = entries.filter((e) => e.type === "file");
|
|
429
332
|
if (fileEntries.length > 0) {
|
|
430
333
|
const packName = parsed.path.split("/").pop() ?? parsed.repo;
|
|
431
|
-
const packOutDir =
|
|
334
|
+
const packOutDir = resolve3(curatedDir, packName);
|
|
432
335
|
mkdirSync(packOutDir, { recursive: true });
|
|
433
336
|
for (const file of entries) {
|
|
434
337
|
if (file.type === "file" && file.download_url) {
|
|
@@ -445,10 +348,77 @@ async function installGitSource(projectRoot, source, lockfile, options = {}) {
|
|
|
445
348
|
return { installed, warnings };
|
|
446
349
|
}
|
|
447
350
|
|
|
351
|
+
// src/sources/local.ts
|
|
352
|
+
import { existsSync as existsSync3 } from "fs";
|
|
353
|
+
import { isAbsolute, resolve as resolve4 } from "path";
|
|
354
|
+
function resolveLocalPack(packRef, projectRoot) {
|
|
355
|
+
let resolved;
|
|
356
|
+
if (isAbsolute(packRef)) {
|
|
357
|
+
resolved = packRef;
|
|
358
|
+
} else {
|
|
359
|
+
resolved = resolve4(projectRoot, packRef);
|
|
360
|
+
}
|
|
361
|
+
if (!existsSync3(resolved))
|
|
362
|
+
return null;
|
|
363
|
+
return resolved;
|
|
364
|
+
}
|
|
365
|
+
function isLocalPackRef(packRef) {
|
|
366
|
+
return packRef.startsWith("./") || packRef.startsWith("../") || isAbsolute(packRef);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// src/sources/npm-ref.ts
|
|
370
|
+
function parseNpmSourceRef(source) {
|
|
371
|
+
let s = source;
|
|
372
|
+
if (s.startsWith("npm:")) {
|
|
373
|
+
s = s.slice(4);
|
|
374
|
+
}
|
|
375
|
+
let path = "";
|
|
376
|
+
const pathColonIdx = findPathColon(s);
|
|
377
|
+
if (pathColonIdx > -1) {
|
|
378
|
+
path = s.slice(pathColonIdx + 1);
|
|
379
|
+
s = s.slice(0, pathColonIdx);
|
|
380
|
+
}
|
|
381
|
+
let version = "latest";
|
|
382
|
+
const versionAtIdx = findVersionAt(s);
|
|
383
|
+
if (versionAtIdx > -1) {
|
|
384
|
+
version = s.slice(versionAtIdx + 1);
|
|
385
|
+
s = s.slice(0, versionAtIdx);
|
|
386
|
+
}
|
|
387
|
+
if (!s) {
|
|
388
|
+
throw new Error(`Invalid npm source reference: "${source}". Expected package name.`);
|
|
389
|
+
}
|
|
390
|
+
return { packageName: s, version, path };
|
|
391
|
+
}
|
|
392
|
+
function findPathColon(s) {
|
|
393
|
+
const startAfter = s.startsWith("@") ? s.indexOf("/") + 1 : 0;
|
|
394
|
+
const vAt = findVersionAt(s);
|
|
395
|
+
const searchFrom = vAt > -1 ? vAt : startAfter;
|
|
396
|
+
return s.indexOf(":", searchFrom);
|
|
397
|
+
}
|
|
398
|
+
function findVersionAt(s) {
|
|
399
|
+
if (s.startsWith("@")) {
|
|
400
|
+
const slashIdx = s.indexOf("/");
|
|
401
|
+
if (slashIdx === -1)
|
|
402
|
+
return -1;
|
|
403
|
+
return s.indexOf("@", slashIdx + 1);
|
|
404
|
+
}
|
|
405
|
+
return s.indexOf("@");
|
|
406
|
+
}
|
|
407
|
+
function isNpmPackRef(packRef) {
|
|
408
|
+
if (packRef.startsWith("npm:"))
|
|
409
|
+
return true;
|
|
410
|
+
if (packRef.startsWith("@") && packRef.includes("/"))
|
|
411
|
+
return true;
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
414
|
+
function npmSourceKey(parsed) {
|
|
415
|
+
return `npm:${parsed.packageName}`;
|
|
416
|
+
}
|
|
417
|
+
|
|
448
418
|
// src/sources/npm.ts
|
|
449
|
-
import { mkdirSync as mkdirSync2, existsSync as existsSync4, readdirSync } from "fs";
|
|
450
|
-
import { resolve as resolve5, join as join2 } from "path";
|
|
451
419
|
import { execSync } from "child_process";
|
|
420
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync2, readdirSync } from "fs";
|
|
421
|
+
import { join as join2, resolve as resolve5 } from "path";
|
|
452
422
|
var NPM_REGISTRY = "https://registry.npmjs.org";
|
|
453
423
|
async function resolveNpmVersion(parsed) {
|
|
454
424
|
const url = `${NPM_REGISTRY}/${encodeURIComponent(parsed.packageName)}/${parsed.version}`;
|
|
@@ -540,6 +510,67 @@ function collectFiles(dir, out) {
|
|
|
540
510
|
}
|
|
541
511
|
}
|
|
542
512
|
|
|
513
|
+
// src/sources/registry-ref.ts
|
|
514
|
+
function parseRegistrySourceRef(source) {
|
|
515
|
+
let s = source;
|
|
516
|
+
if (s.startsWith("registry:")) {
|
|
517
|
+
s = s.slice(9);
|
|
518
|
+
}
|
|
519
|
+
if (!s) {
|
|
520
|
+
throw new Error(`Invalid registry source reference: "${source}". Expected pack name.`);
|
|
521
|
+
}
|
|
522
|
+
let version = "latest";
|
|
523
|
+
const atIdx = s.indexOf("@");
|
|
524
|
+
if (atIdx > 0) {
|
|
525
|
+
version = s.slice(atIdx + 1);
|
|
526
|
+
s = s.slice(0, atIdx);
|
|
527
|
+
}
|
|
528
|
+
if (!s) {
|
|
529
|
+
throw new Error(`Invalid registry source reference: "${source}". Pack name is empty.`);
|
|
530
|
+
}
|
|
531
|
+
if (!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(s)) {
|
|
532
|
+
throw new Error(`Invalid registry pack name: "${s}". Must be lowercase alphanumeric with hyphens.`);
|
|
533
|
+
}
|
|
534
|
+
return { packName: s, version };
|
|
535
|
+
}
|
|
536
|
+
function isRegistryPackRef(packRef) {
|
|
537
|
+
return packRef.startsWith("registry:");
|
|
538
|
+
}
|
|
539
|
+
function registrySourceKey(parsed) {
|
|
540
|
+
return `registry:${parsed.packName}`;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
// src/utils/credentials.ts
|
|
544
|
+
import { existsSync as existsSync5, mkdirSync as mkdirSync3, readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
545
|
+
import { homedir } from "os";
|
|
546
|
+
import { dirname, join as join3 } from "path";
|
|
547
|
+
var CONFIG_DIR = join3(homedir(), ".config", "agentpacks");
|
|
548
|
+
var CREDENTIALS_FILE = join3(CONFIG_DIR, "credentials.json");
|
|
549
|
+
function loadCredentials() {
|
|
550
|
+
if (!existsSync5(CREDENTIALS_FILE)) {
|
|
551
|
+
return { registryUrl: "https://registry.agentpacks.dev" };
|
|
552
|
+
}
|
|
553
|
+
try {
|
|
554
|
+
const raw = readFileSync3(CREDENTIALS_FILE, "utf-8");
|
|
555
|
+
return JSON.parse(raw);
|
|
556
|
+
} catch {
|
|
557
|
+
return { registryUrl: "https://registry.agentpacks.dev" };
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
function saveCredentials(credentials) {
|
|
561
|
+
mkdirSync3(dirname(CREDENTIALS_FILE), { recursive: true });
|
|
562
|
+
writeFileSync3(CREDENTIALS_FILE, JSON.stringify(credentials, null, 2) + `
|
|
563
|
+
`, {
|
|
564
|
+
mode: 384
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
function clearCredentials() {
|
|
568
|
+
if (existsSync5(CREDENTIALS_FILE)) {
|
|
569
|
+
writeFileSync3(CREDENTIALS_FILE, JSON.stringify({ registryUrl: "https://registry.agentpacks.dev" }) + `
|
|
570
|
+
`);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
|
|
543
574
|
// src/utils/registry-client.ts
|
|
544
575
|
var DEFAULT_REGISTRY_URL = "https://registry.agentpacks.dev";
|
|
545
576
|
function createRegistryClient(config) {
|
|
@@ -675,43 +706,12 @@ class RegistryApiError extends Error {
|
|
|
675
706
|
}
|
|
676
707
|
}
|
|
677
708
|
|
|
678
|
-
// src/utils/credentials.ts
|
|
679
|
-
import { existsSync as existsSync5, readFileSync as readFileSync3, writeFileSync as writeFileSync3, mkdirSync as mkdirSync3 } from "fs";
|
|
680
|
-
import { join as join3, dirname } from "path";
|
|
681
|
-
import { homedir } from "os";
|
|
682
|
-
var CONFIG_DIR = join3(homedir(), ".config", "agentpacks");
|
|
683
|
-
var CREDENTIALS_FILE = join3(CONFIG_DIR, "credentials.json");
|
|
684
|
-
function loadCredentials() {
|
|
685
|
-
if (!existsSync5(CREDENTIALS_FILE)) {
|
|
686
|
-
return { registryUrl: "https://registry.agentpacks.dev" };
|
|
687
|
-
}
|
|
688
|
-
try {
|
|
689
|
-
const raw = readFileSync3(CREDENTIALS_FILE, "utf-8");
|
|
690
|
-
return JSON.parse(raw);
|
|
691
|
-
} catch {
|
|
692
|
-
return { registryUrl: "https://registry.agentpacks.dev" };
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
function saveCredentials(credentials) {
|
|
696
|
-
mkdirSync3(dirname(CREDENTIALS_FILE), { recursive: true });
|
|
697
|
-
writeFileSync3(CREDENTIALS_FILE, JSON.stringify(credentials, null, 2) + `
|
|
698
|
-
`, {
|
|
699
|
-
mode: 384
|
|
700
|
-
});
|
|
701
|
-
}
|
|
702
|
-
function clearCredentials() {
|
|
703
|
-
if (existsSync5(CREDENTIALS_FILE)) {
|
|
704
|
-
writeFileSync3(CREDENTIALS_FILE, JSON.stringify({ registryUrl: "https://registry.agentpacks.dev" }) + `
|
|
705
|
-
`);
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
|
|
709
709
|
// src/utils/tarball.ts
|
|
710
710
|
import { execSync as execSync2 } from "child_process";
|
|
711
|
-
import { readFileSync as readFileSync4, existsSync as existsSync6, mkdirSync as mkdirSync4, rmSync } from "fs";
|
|
712
|
-
import { join as join4, resolve as resolve6 } from "path";
|
|
713
711
|
import { createHash as createHash2 } from "crypto";
|
|
712
|
+
import { existsSync as existsSync6, mkdirSync as mkdirSync4, readFileSync as readFileSync4, rmSync } from "fs";
|
|
714
713
|
import { tmpdir } from "os";
|
|
714
|
+
import { join as join4, resolve as resolve6 } from "path";
|
|
715
715
|
async function createTarball(packDir) {
|
|
716
716
|
const absDir = resolve6(packDir);
|
|
717
717
|
const tmpFile = join4(tmpdir(), `agentpacks-${Date.now()}.tgz`);
|
|
@@ -750,7 +750,7 @@ function computeTarballIntegrity(data) {
|
|
|
750
750
|
|
|
751
751
|
// src/sources/registry.ts
|
|
752
752
|
import { existsSync as existsSync7, mkdirSync as mkdirSync5, readdirSync as readdirSync2, rmSync as rmSync2 } from "fs";
|
|
753
|
-
import {
|
|
753
|
+
import { join as join5, resolve as resolve7 } from "path";
|
|
754
754
|
async function installRegistrySource(projectRoot, source, lockfile, options = {}) {
|
|
755
755
|
const parsed = parseRegistrySourceRef(source);
|
|
756
756
|
const sourceKey = registrySourceKey(parsed);
|
package/dist/cli/login.js
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
var __require = import.meta.require;
|
|
3
3
|
|
|
4
|
+
// src/utils/credentials.ts
|
|
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
|
+
|
|
4
35
|
// src/utils/registry-client.ts
|
|
5
36
|
var DEFAULT_REGISTRY_URL = "https://registry.agentpacks.dev";
|
|
6
37
|
function createRegistryClient(config) {
|
|
@@ -136,37 +167,6 @@ class RegistryApiError extends Error {
|
|
|
136
167
|
}
|
|
137
168
|
}
|
|
138
169
|
|
|
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
170
|
// src/cli/login.ts
|
|
171
171
|
import chalk from "chalk";
|
|
172
172
|
async function runLogin(options) {
|