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.
Files changed (147) hide show
  1. package/dist/api.js +48 -3658
  2. package/dist/cli/export-cmd.js +7 -1027
  3. package/dist/cli/generate.js +39 -2731
  4. package/dist/cli/import-cmd.js +19 -770
  5. package/dist/cli/info.js +4 -231
  6. package/dist/cli/init.js +9 -185
  7. package/dist/cli/install.js +4 -902
  8. package/dist/cli/login.js +6 -201
  9. package/dist/cli/models-explain.js +14 -1266
  10. package/dist/cli/pack/create.js +4 -146
  11. package/dist/cli/pack/enable.js +2 -65
  12. package/dist/cli/pack/list.js +5 -893
  13. package/dist/cli/pack/validate.js +4 -642
  14. package/dist/cli/publish.js +8 -679
  15. package/dist/cli/search.js +4 -209
  16. package/dist/core/config.d.ts +1 -1
  17. package/dist/core/config.js +1 -145
  18. package/dist/core/dependency-resolver.js +1 -126
  19. package/dist/core/feature-merger.js +3 -398
  20. package/dist/core/index.js +5 -1129
  21. package/dist/core/lockfile.js +2 -43
  22. package/dist/core/metarepo.js +1 -183
  23. package/dist/core/pack-loader.js +4 -841
  24. package/dist/core/profile-resolver.js +1 -110
  25. package/dist/exporters/cursor-plugin.js +6 -404
  26. package/dist/exporters/index.js +6 -404
  27. package/dist/features/agents.js +3 -161
  28. package/dist/features/commands.js +3 -161
  29. package/dist/features/hooks.js +3 -153
  30. package/dist/features/ignore.js +2 -43
  31. package/dist/features/index.js +4 -629
  32. package/dist/features/mcp.js +3 -143
  33. package/dist/features/models.js +3 -292
  34. package/dist/features/plugins.js +3 -139
  35. package/dist/features/rules.d.ts +0 -1
  36. package/dist/features/rules.js +3 -169
  37. package/dist/features/skills.js +3 -228
  38. package/dist/importers/claude-code.js +6 -195
  39. package/dist/importers/cursor.js +5 -355
  40. package/dist/importers/opencode.js +6 -346
  41. package/dist/importers/rulesync.js +5 -365
  42. package/dist/index.js +89 -4934
  43. package/dist/node/api.js +48 -3659
  44. package/dist/node/cli/export-cmd.js +7 -1028
  45. package/dist/node/cli/generate.js +39 -2732
  46. package/dist/node/cli/import-cmd.js +19 -771
  47. package/dist/node/cli/info.js +4 -232
  48. package/dist/node/cli/init.js +9 -186
  49. package/dist/node/cli/install.js +4 -903
  50. package/dist/node/cli/login.js +6 -202
  51. package/dist/node/cli/models-explain.js +14 -1267
  52. package/dist/node/cli/pack/create.js +4 -147
  53. package/dist/node/cli/pack/enable.js +2 -66
  54. package/dist/node/cli/pack/list.js +5 -894
  55. package/dist/node/cli/pack/validate.js +4 -643
  56. package/dist/node/cli/publish.js +8 -680
  57. package/dist/node/cli/search.js +4 -210
  58. package/dist/node/core/config.js +1 -146
  59. package/dist/node/core/dependency-resolver.js +1 -127
  60. package/dist/node/core/feature-merger.js +3 -399
  61. package/dist/node/core/index.js +5 -1130
  62. package/dist/node/core/lockfile.js +2 -44
  63. package/dist/node/core/metarepo.js +1 -184
  64. package/dist/node/core/pack-loader.js +4 -842
  65. package/dist/node/core/profile-resolver.js +1 -111
  66. package/dist/node/exporters/cursor-plugin.js +6 -405
  67. package/dist/node/exporters/index.js +6 -405
  68. package/dist/node/features/agents.js +3 -162
  69. package/dist/node/features/commands.js +3 -162
  70. package/dist/node/features/hooks.js +3 -154
  71. package/dist/node/features/ignore.js +2 -44
  72. package/dist/node/features/index.js +4 -630
  73. package/dist/node/features/mcp.js +3 -144
  74. package/dist/node/features/models.js +3 -293
  75. package/dist/node/features/plugins.js +3 -140
  76. package/dist/node/features/rules.js +3 -170
  77. package/dist/node/features/skills.js +3 -229
  78. package/dist/node/importers/claude-code.js +6 -196
  79. package/dist/node/importers/cursor.js +5 -356
  80. package/dist/node/importers/opencode.js +6 -347
  81. package/dist/node/importers/rulesync.js +5 -366
  82. package/dist/node/index.js +89 -4935
  83. package/dist/node/sources/git-ref.js +1 -56
  84. package/dist/node/sources/git.js +2 -222
  85. package/dist/node/sources/index.js +4 -714
  86. package/dist/node/sources/local.js +1 -24
  87. package/dist/node/sources/npm-ref.js +1 -56
  88. package/dist/node/sources/npm.js +2 -184
  89. package/dist/node/sources/registry-ref.js +1 -37
  90. package/dist/node/sources/registry.js +4 -355
  91. package/dist/node/targets/additional-targets.js +6 -587
  92. package/dist/node/targets/base-target.js +1 -23
  93. package/dist/node/targets/claude-code.js +6 -714
  94. package/dist/node/targets/codex-cli.js +3 -324
  95. package/dist/node/targets/copilot.js +5 -603
  96. package/dist/node/targets/cursor.js +6 -700
  97. package/dist/node/targets/gemini-cli.js +10 -319
  98. package/dist/node/targets/generic-md-target.js +6 -478
  99. package/dist/node/targets/index.js +32 -1873
  100. package/dist/node/targets/mistral-vibe.js +7 -661
  101. package/dist/node/targets/opencode.js +13 -723
  102. package/dist/node/targets/registry.js +32 -1864
  103. package/dist/node/utils/credentials.js +3 -38
  104. package/dist/node/utils/diff.js +5 -132
  105. package/dist/node/utils/filesystem.js +3 -124
  106. package/dist/node/utils/frontmatter.js +1 -24
  107. package/dist/node/utils/global.js +1 -53
  108. package/dist/node/utils/markdown.js +3 -30
  109. package/dist/node/utils/model-allowlist.js +1 -126
  110. package/dist/node/utils/model-guidance.js +2 -78
  111. package/dist/node/utils/registry-client.js +1 -142
  112. package/dist/node/utils/tarball.js +1 -49
  113. package/dist/sources/git-ref.js +1 -55
  114. package/dist/sources/git.js +2 -221
  115. package/dist/sources/index.js +4 -713
  116. package/dist/sources/local.js +1 -23
  117. package/dist/sources/npm-ref.js +1 -55
  118. package/dist/sources/npm.js +2 -183
  119. package/dist/sources/registry-ref.js +1 -36
  120. package/dist/sources/registry.js +4 -354
  121. package/dist/targets/additional-targets.js +6 -586
  122. package/dist/targets/base-target.js +1 -22
  123. package/dist/targets/claude-code.js +6 -713
  124. package/dist/targets/codex-cli.js +3 -323
  125. package/dist/targets/copilot.js +5 -602
  126. package/dist/targets/cursor.js +6 -699
  127. package/dist/targets/gemini-cli.js +10 -318
  128. package/dist/targets/generic-md-target.js +6 -477
  129. package/dist/targets/index.d.ts +0 -1
  130. package/dist/targets/index.js +32 -1872
  131. package/dist/targets/mistral-vibe.js +7 -660
  132. package/dist/targets/opencode.js +13 -722
  133. package/dist/targets/registry.js +32 -1863
  134. package/dist/utils/credentials.js +3 -37
  135. package/dist/utils/diff.js +5 -131
  136. package/dist/utils/filesystem.js +3 -123
  137. package/dist/utils/frontmatter.js +1 -23
  138. package/dist/utils/global.js +1 -52
  139. package/dist/utils/markdown.js +3 -29
  140. package/dist/utils/model-allowlist.js +1 -125
  141. package/dist/utils/model-guidance.js +2 -77
  142. package/dist/utils/registry-client.js +1 -141
  143. package/dist/utils/tarball.js +1 -48
  144. package/package.json +4 -16
  145. package/dist/node/targets/agents-md.js +0 -211
  146. package/dist/targets/agents-md.d.ts +0 -13
  147. package/dist/targets/agents-md.js +0 -211
@@ -1,24 +1,2 @@
1
1
  // @bun
2
- var __require = import.meta.require;
3
-
4
- // src/sources/local.ts
5
- import { existsSync } from "fs";
6
- import { isAbsolute, resolve } from "path";
7
- function resolveLocalPack(packRef, projectRoot) {
8
- let resolved;
9
- if (isAbsolute(packRef)) {
10
- resolved = packRef;
11
- } else {
12
- resolved = resolve(projectRoot, packRef);
13
- }
14
- if (!existsSync(resolved))
15
- return null;
16
- return resolved;
17
- }
18
- function isLocalPackRef(packRef) {
19
- return packRef.startsWith("./") || packRef.startsWith("../") || isAbsolute(packRef);
20
- }
21
- export {
22
- resolveLocalPack,
23
- isLocalPackRef
24
- };
2
+ var D=import.meta.require;import{existsSync as z}from"fs";import{isAbsolute as q,resolve as B}from"path";function H(g,w){let m;if(q(g))m=g;else m=B(w,g);if(!z(m))return null;return m}function I(g){return g.startsWith("./")||g.startsWith("../")||q(g)}export{H as resolveLocalPack,I as isLocalPackRef};
@@ -1,56 +1,2 @@
1
1
  // @bun
2
- var __require = import.meta.require;
3
-
4
- // src/sources/npm-ref.ts
5
- function parseNpmSourceRef(source) {
6
- let s = source;
7
- if (s.startsWith("npm:")) {
8
- s = s.slice(4);
9
- }
10
- let path = "";
11
- const pathColonIdx = findPathColon(s);
12
- if (pathColonIdx > -1) {
13
- path = s.slice(pathColonIdx + 1);
14
- s = s.slice(0, pathColonIdx);
15
- }
16
- let version = "latest";
17
- const versionAtIdx = findVersionAt(s);
18
- if (versionAtIdx > -1) {
19
- version = s.slice(versionAtIdx + 1);
20
- s = s.slice(0, versionAtIdx);
21
- }
22
- if (!s) {
23
- throw new Error(`Invalid npm source reference: "${source}". Expected package name.`);
24
- }
25
- return { packageName: s, version, path };
26
- }
27
- function findPathColon(s) {
28
- const startAfter = s.startsWith("@") ? s.indexOf("/") + 1 : 0;
29
- const vAt = findVersionAt(s);
30
- const searchFrom = vAt > -1 ? vAt : startAfter;
31
- return s.indexOf(":", searchFrom);
32
- }
33
- function findVersionAt(s) {
34
- if (s.startsWith("@")) {
35
- const slashIdx = s.indexOf("/");
36
- if (slashIdx === -1)
37
- return -1;
38
- return s.indexOf("@", slashIdx + 1);
39
- }
40
- return s.indexOf("@");
41
- }
42
- function isNpmPackRef(packRef) {
43
- if (packRef.startsWith("npm:"))
44
- return true;
45
- if (packRef.startsWith("@") && packRef.includes("/"))
46
- return true;
47
- return false;
48
- }
49
- function npmSourceKey(parsed) {
50
- return `npm:${parsed.packageName}`;
51
- }
52
- export {
53
- parseNpmSourceRef,
54
- npmSourceKey,
55
- isNpmPackRef
56
- };
2
+ var G=import.meta.require;function J(b){let g=b;if(g.startsWith("npm:"))g=g.slice(4);let j="",q=E(g);if(q>-1)j=g.slice(q+1),g=g.slice(0,q);let z="latest",w=D(g);if(w>-1)z=g.slice(w+1),g=g.slice(0,w);if(!g)throw Error(`Invalid npm source reference: "${b}". Expected package name.`);return{packageName:g,version:z,path:j}}function E(b){let g=b.startsWith("@")?b.indexOf("/")+1:0,j=D(b),q=j>-1?j:g;return b.indexOf(":",q)}function D(b){if(b.startsWith("@")){let g=b.indexOf("/");if(g===-1)return-1;return b.indexOf("@",g+1)}return b.indexOf("@")}function K(b){if(b.startsWith("npm:"))return!0;if(b.startsWith("@")&&b.includes("/"))return!0;return!1}function L(b){return`npm:${b.packageName}`}export{J as parseNpmSourceRef,L as npmSourceKey,K as isNpmPackRef};
@@ -1,184 +1,3 @@
1
1
  // @bun
2
- var __require = import.meta.require;
3
-
4
- // src/core/lockfile.ts
5
- import { createHash } from "crypto";
6
- import { existsSync, readFileSync, writeFileSync } from "fs";
7
- import { resolve } from "path";
8
- var LOCKFILE_VERSION = 1;
9
- var LOCKFILE_NAME = "agentpacks.lock";
10
- function loadLockfile(projectRoot) {
11
- const filepath = resolve(projectRoot, LOCKFILE_NAME);
12
- if (!existsSync(filepath)) {
13
- return { lockfileVersion: LOCKFILE_VERSION, sources: {} };
14
- }
15
- const raw = readFileSync(filepath, "utf-8");
16
- return JSON.parse(raw);
17
- }
18
- function saveLockfile(projectRoot, lockfile) {
19
- const filepath = resolve(projectRoot, LOCKFILE_NAME);
20
- writeFileSync(filepath, JSON.stringify(lockfile, null, 2) + `
21
- `);
22
- }
23
- function getLockedSource(lockfile, sourceKey) {
24
- return lockfile.sources[sourceKey];
25
- }
26
- function setLockedSource(lockfile, sourceKey, entry) {
27
- lockfile.sources[sourceKey] = entry;
28
- }
29
- function computeIntegrity(content) {
30
- const hash = createHash("sha256").update(content).digest("hex");
31
- return `sha256-${hash}`;
32
- }
33
- function isLockfileFrozenValid(lockfile, sourceKeys) {
34
- const missing = sourceKeys.filter((key) => !(key in lockfile.sources));
35
- return { valid: missing.length === 0, missing };
36
- }
37
-
38
- // src/sources/npm-ref.ts
39
- function parseNpmSourceRef(source) {
40
- let s = source;
41
- if (s.startsWith("npm:")) {
42
- s = s.slice(4);
43
- }
44
- let path = "";
45
- const pathColonIdx = findPathColon(s);
46
- if (pathColonIdx > -1) {
47
- path = s.slice(pathColonIdx + 1);
48
- s = s.slice(0, pathColonIdx);
49
- }
50
- let version = "latest";
51
- const versionAtIdx = findVersionAt(s);
52
- if (versionAtIdx > -1) {
53
- version = s.slice(versionAtIdx + 1);
54
- s = s.slice(0, versionAtIdx);
55
- }
56
- if (!s) {
57
- throw new Error(`Invalid npm source reference: "${source}". Expected package name.`);
58
- }
59
- return { packageName: s, version, path };
60
- }
61
- function findPathColon(s) {
62
- const startAfter = s.startsWith("@") ? s.indexOf("/") + 1 : 0;
63
- const vAt = findVersionAt(s);
64
- const searchFrom = vAt > -1 ? vAt : startAfter;
65
- return s.indexOf(":", searchFrom);
66
- }
67
- function findVersionAt(s) {
68
- if (s.startsWith("@")) {
69
- const slashIdx = s.indexOf("/");
70
- if (slashIdx === -1)
71
- return -1;
72
- return s.indexOf("@", slashIdx + 1);
73
- }
74
- return s.indexOf("@");
75
- }
76
- function isNpmPackRef(packRef) {
77
- if (packRef.startsWith("npm:"))
78
- return true;
79
- if (packRef.startsWith("@") && packRef.includes("/"))
80
- return true;
81
- return false;
82
- }
83
- function npmSourceKey(parsed) {
84
- return `npm:${parsed.packageName}`;
85
- }
86
-
87
- // src/sources/npm.ts
88
- import { execSync } from "child_process";
89
- import { existsSync as existsSync2, mkdirSync, readdirSync } from "fs";
90
- import { join, resolve as resolve2 } from "path";
91
- var NPM_REGISTRY = "https://registry.npmjs.org";
92
- async function resolveNpmVersion(parsed) {
93
- const url = `${NPM_REGISTRY}/${encodeURIComponent(parsed.packageName)}/${parsed.version}`;
94
- const res = await fetch(url, {
95
- headers: { Accept: "application/json" }
96
- });
97
- if (!res.ok) {
98
- throw new Error(`Could not resolve npm package "${parsed.packageName}@${parsed.version}": ${res.status}`);
99
- }
100
- const data = await res.json();
101
- return { version: data.version, tarball: data.dist.tarball };
102
- }
103
- async function installNpmSource(projectRoot, source, lockfile, options = {}) {
104
- const parsed = parseNpmSourceRef(source);
105
- const sourceKey = npmSourceKey(parsed);
106
- const installed = [];
107
- const warnings = [];
108
- const locked = getLockedSource(lockfile, sourceKey);
109
- if (options.frozen && !locked) {
110
- throw new Error(`Frozen mode: no lockfile entry for source "${sourceKey}".`);
111
- }
112
- let resolvedVersion;
113
- if (locked && !options.update) {
114
- resolvedVersion = locked.resolvedRef;
115
- } else {
116
- const resolved = await resolveNpmVersion(parsed);
117
- resolvedVersion = resolved.version;
118
- }
119
- const curatedDir = resolve2(projectRoot, ".agentpacks", ".curated");
120
- mkdirSync(curatedDir, { recursive: true });
121
- extractNpmPack(parsed, resolvedVersion, curatedDir, installed, warnings);
122
- const newEntry = {
123
- requestedRef: parsed.version,
124
- resolvedRef: resolvedVersion,
125
- resolvedAt: new Date().toISOString(),
126
- skills: {},
127
- packs: {}
128
- };
129
- setLockedSource(lockfile, sourceKey, newEntry);
130
- return { installed, warnings };
131
- }
132
- function extractNpmPack(parsed, version, curatedDir, installed, warnings) {
133
- const pkgSpec = `${parsed.packageName}@${version}`;
134
- const packName = parsed.packageName.replace(/^@/, "").replace(/\//g, "-");
135
- const packOutDir = resolve2(curatedDir, packName);
136
- try {
137
- const tmpDir = resolve2(curatedDir, ".tmp-npm");
138
- mkdirSync(tmpDir, { recursive: true });
139
- execSync(`npm pack ${pkgSpec} --pack-destination "${tmpDir}"`, {
140
- stdio: "pipe",
141
- timeout: 30000
142
- });
143
- const tgzFiles = readdirSync(tmpDir).filter((f) => f.endsWith(".tgz"));
144
- if (tgzFiles.length === 0) {
145
- warnings.push(`No tarball found for ${pkgSpec}`);
146
- return packOutDir;
147
- }
148
- const firstTgz = tgzFiles[0];
149
- if (!firstTgz) {
150
- warnings.push(`No tarball found for ${pkgSpec}`);
151
- return packOutDir;
152
- }
153
- const tgzPath = join(tmpDir, firstTgz);
154
- mkdirSync(packOutDir, { recursive: true });
155
- execSync(`tar xzf "${tgzPath}" -C "${packOutDir}" --strip-components=1`, {
156
- stdio: "pipe",
157
- timeout: 15000
158
- });
159
- execSync(`rm -rf "${tmpDir}"`, { stdio: "pipe" });
160
- const subpath = parsed.path || "";
161
- const targetDir = subpath ? join(packOutDir, subpath) : packOutDir;
162
- if (existsSync2(targetDir)) {
163
- collectFiles(targetDir, installed);
164
- }
165
- } catch (err) {
166
- warnings.push(`Failed to extract npm pack ${pkgSpec}: ${err instanceof Error ? err.message : String(err)}`);
167
- }
168
- return packOutDir;
169
- }
170
- function collectFiles(dir, out) {
171
- const entries = readdirSync(dir, { withFileTypes: true });
172
- for (const entry of entries) {
173
- const full = join(dir, entry.name);
174
- if (entry.isDirectory()) {
175
- collectFiles(full, out);
176
- } else {
177
- out.push(full);
178
- }
179
- }
180
- }
181
- export {
182
- resolveNpmVersion,
183
- installNpmSource
184
- };
2
+ var y=import.meta.require;import{createHash as I}from"crypto";import{existsSync as K,readFileSync as x,writeFileSync as m}from"fs";import{resolve as C}from"path";var R=1,E="agentpacks.lock";function p(q){let J=C(q,E);if(!K(J))return{lockfileVersion:R,sources:{}};let Q=x(J,"utf-8");return JSON.parse(Q)}function n(q,J){let Q=C(q,E);m(Q,JSON.stringify(J,null,2)+`
3
+ `)}function L(q,J){return q.sources[J]}function N(q,J,Q){q.sources[J]=Q}function l(q){return`sha256-${I("sha256").update(q).digest("hex")}`}function a(q,J){let Q=J.filter((U)=>!(U in q.sources));return{valid:Q.length===0,missing:Q}}function V(q){let J=q;if(J.startsWith("npm:"))J=J.slice(4);let Q="",U=D(J);if(U>-1)Q=J.slice(U+1),J=J.slice(0,U);let W="latest",Z=A(J);if(Z>-1)W=J.slice(Z+1),J=J.slice(0,Z);if(!J)throw Error(`Invalid npm source reference: "${q}". Expected package name.`);return{packageName:J,version:W,path:Q}}function D(q){let J=q.startsWith("@")?q.indexOf("/")+1:0,Q=A(q),U=Q>-1?Q:J;return q.indexOf(":",U)}function A(q){if(q.startsWith("@")){let J=q.indexOf("/");if(J===-1)return-1;return q.indexOf("@",J+1)}return q.indexOf("@")}function i(q){if(q.startsWith("npm:"))return!0;if(q.startsWith("@")&&q.includes("/"))return!0;return!1}function F(q){return`npm:${q.packageName}`}import{execSync as M}from"child_process";import{existsSync as h,mkdirSync as T,readdirSync as j}from"fs";import{join as P,resolve as z}from"path";var v="https://registry.npmjs.org";async function g(q){let J=`${v}/${encodeURIComponent(q.packageName)}/${q.version}`,Q=await fetch(J,{headers:{Accept:"application/json"}});if(!Q.ok)throw Error(`Could not resolve npm package "${q.packageName}@${q.version}": ${Q.status}`);let U=await Q.json();return{version:U.version,tarball:U.dist.tarball}}async function Jq(q,J,Q,U={}){let W=V(J),Z=F(W),H=[],$=[],X=L(Q,Z);if(U.frozen&&!X)throw Error(`Frozen mode: no lockfile entry for source "${Z}".`);let B;if(X&&!U.update)B=X.resolvedRef;else B=(await g(W)).version;let G=z(q,".agentpacks",".curated");T(G,{recursive:!0}),S(W,B,G,H,$);let Y={requestedRef:W.version,resolvedRef:B,resolvedAt:new Date().toISOString(),skills:{},packs:{}};return N(Q,Z,Y),{installed:H,warnings:$}}function S(q,J,Q,U,W){let Z=`${q.packageName}@${J}`,H=q.packageName.replace(/^@/,"").replace(/\//g,"-"),$=z(Q,H);try{let X=z(Q,".tmp-npm");T(X,{recursive:!0}),M(`npm pack ${Z} --pack-destination "${X}"`,{stdio:"pipe",timeout:30000});let B=j(X).filter((O)=>O.endsWith(".tgz"));if(B.length===0)return W.push(`No tarball found for ${Z}`),$;let G=B[0];if(!G)return W.push(`No tarball found for ${Z}`),$;let Y=P(X,G);T($,{recursive:!0}),M(`tar xzf "${Y}" -C "${$}" --strip-components=1`,{stdio:"pipe",timeout:15000}),M(`rm -rf "${X}"`,{stdio:"pipe"});let b=q.path||"",_=b?P($,b):$;if(h(_))w(_,U)}catch(X){W.push(`Failed to extract npm pack ${Z}: ${X instanceof Error?X.message:String(X)}`)}return $}function w(q,J){let Q=j(q,{withFileTypes:!0});for(let U of Q){let W=P(q,U.name);if(U.isDirectory())w(W,J);else J.push(W)}}export{g as resolveNpmVersion,Jq as installNpmSource};
@@ -1,37 +1,2 @@
1
1
  // @bun
2
- var __require = import.meta.require;
3
-
4
- // src/sources/registry-ref.ts
5
- function parseRegistrySourceRef(source) {
6
- let s = source;
7
- if (s.startsWith("registry:")) {
8
- s = s.slice(9);
9
- }
10
- if (!s) {
11
- throw new Error(`Invalid registry source reference: "${source}". Expected pack name.`);
12
- }
13
- let version = "latest";
14
- const atIdx = s.indexOf("@");
15
- if (atIdx > 0) {
16
- version = s.slice(atIdx + 1);
17
- s = s.slice(0, atIdx);
18
- }
19
- if (!s) {
20
- throw new Error(`Invalid registry source reference: "${source}". Pack name is empty.`);
21
- }
22
- if (!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(s)) {
23
- throw new Error(`Invalid registry pack name: "${s}". Must be lowercase alphanumeric with hyphens.`);
24
- }
25
- return { packName: s, version };
26
- }
27
- function isRegistryPackRef(packRef) {
28
- return packRef.startsWith("registry:");
29
- }
30
- function registrySourceKey(parsed) {
31
- return `registry:${parsed.packName}`;
32
- }
33
- export {
34
- registrySourceKey,
35
- parseRegistrySourceRef,
36
- isRegistryPackRef
37
- };
2
+ var m=import.meta.require;function w(g){let b=g;if(b.startsWith("registry:"))b=b.slice(9);if(!b)throw Error(`Invalid registry source reference: "${g}". Expected pack name.`);let j="latest",h=b.indexOf("@");if(h>0)j=b.slice(h+1),b=b.slice(0,h);if(!b)throw Error(`Invalid registry source reference: "${g}". Pack name is empty.`);if(!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(b))throw Error(`Invalid registry pack name: "${b}". Must be lowercase alphanumeric with hyphens.`);return{packName:b,version:j}}function z(g){return g.startsWith("registry:")}function A(g){return`registry:${g.packName}`}export{A as registrySourceKey,w as parseRegistrySourceRef,z as isRegistryPackRef};
@@ -1,355 +1,5 @@
1
1
  // @bun
2
- var __require = import.meta.require;
3
-
4
- // src/core/lockfile.ts
5
- import { createHash } from "crypto";
6
- import { existsSync, readFileSync, writeFileSync } from "fs";
7
- import { resolve } from "path";
8
- var LOCKFILE_VERSION = 1;
9
- var LOCKFILE_NAME = "agentpacks.lock";
10
- function loadLockfile(projectRoot) {
11
- const filepath = resolve(projectRoot, LOCKFILE_NAME);
12
- if (!existsSync(filepath)) {
13
- return { lockfileVersion: LOCKFILE_VERSION, sources: {} };
14
- }
15
- const raw = readFileSync(filepath, "utf-8");
16
- return JSON.parse(raw);
17
- }
18
- function saveLockfile(projectRoot, lockfile) {
19
- const filepath = resolve(projectRoot, LOCKFILE_NAME);
20
- writeFileSync(filepath, JSON.stringify(lockfile, null, 2) + `
21
- `);
22
- }
23
- function getLockedSource(lockfile, sourceKey) {
24
- return lockfile.sources[sourceKey];
25
- }
26
- function setLockedSource(lockfile, sourceKey, entry) {
27
- lockfile.sources[sourceKey] = entry;
28
- }
29
- function computeIntegrity(content) {
30
- const hash = createHash("sha256").update(content).digest("hex");
31
- return `sha256-${hash}`;
32
- }
33
- function isLockfileFrozenValid(lockfile, sourceKeys) {
34
- const missing = sourceKeys.filter((key) => !(key in lockfile.sources));
35
- return { valid: missing.length === 0, missing };
36
- }
37
-
38
- // src/sources/registry-ref.ts
39
- function parseRegistrySourceRef(source) {
40
- let s = source;
41
- if (s.startsWith("registry:")) {
42
- s = s.slice(9);
43
- }
44
- if (!s) {
45
- throw new Error(`Invalid registry source reference: "${source}". Expected pack name.`);
46
- }
47
- let version = "latest";
48
- const atIdx = s.indexOf("@");
49
- if (atIdx > 0) {
50
- version = s.slice(atIdx + 1);
51
- s = s.slice(0, atIdx);
52
- }
53
- if (!s) {
54
- throw new Error(`Invalid registry source reference: "${source}". Pack name is empty.`);
55
- }
56
- if (!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(s)) {
57
- throw new Error(`Invalid registry pack name: "${s}". Must be lowercase alphanumeric with hyphens.`);
58
- }
59
- return { packName: s, version };
60
- }
61
- function isRegistryPackRef(packRef) {
62
- return packRef.startsWith("registry:");
63
- }
64
- function registrySourceKey(parsed) {
65
- return `registry:${parsed.packName}`;
66
- }
67
-
68
- // src/utils/credentials.ts
69
- import { existsSync as existsSync2, mkdirSync, readFileSync as readFileSync2, writeFileSync as writeFileSync2 } from "fs";
70
- import { homedir } from "os";
71
- import { dirname, join } from "path";
72
- var CONFIG_DIR = join(homedir(), ".config", "agentpacks");
73
- var CREDENTIALS_FILE = join(CONFIG_DIR, "credentials.json");
74
- function loadCredentials() {
75
- if (!existsSync2(CREDENTIALS_FILE)) {
76
- return { registryUrl: "https://registry.agentpacks.dev" };
77
- }
78
- try {
79
- const raw = readFileSync2(CREDENTIALS_FILE, "utf-8");
80
- return JSON.parse(raw);
81
- } catch {
82
- return { registryUrl: "https://registry.agentpacks.dev" };
83
- }
84
- }
85
- function saveCredentials(credentials) {
86
- mkdirSync(dirname(CREDENTIALS_FILE), { recursive: true });
87
- writeFileSync2(CREDENTIALS_FILE, JSON.stringify(credentials, null, 2) + `
88
- `, {
89
- mode: 384
90
- });
91
- }
92
- function clearCredentials() {
93
- if (existsSync2(CREDENTIALS_FILE)) {
94
- writeFileSync2(CREDENTIALS_FILE, JSON.stringify({ registryUrl: "https://registry.agentpacks.dev" }) + `
95
- `);
96
- }
97
- }
98
-
99
- // src/utils/registry-client.ts
100
- var DEFAULT_REGISTRY_URL = "https://registry.agentpacks.dev";
101
- function createRegistryClient(config) {
102
- return new RegistryClient({
103
- registryUrl: config?.registryUrl ?? DEFAULT_REGISTRY_URL,
104
- authToken: config?.authToken,
105
- timeout: config?.timeout ?? 30000
106
- });
107
- }
108
-
109
- class RegistryClient {
110
- config;
111
- constructor(config) {
112
- this.config = {
113
- registryUrl: config.registryUrl.replace(/\/+$/, ""),
114
- authToken: config.authToken,
115
- timeout: config.timeout ?? 30000
116
- };
117
- }
118
- async search(params) {
119
- const searchParams = new URLSearchParams;
120
- if (params.query)
121
- searchParams.set("q", params.query);
122
- if (params.tags?.length)
123
- searchParams.set("tags", params.tags.join(","));
124
- if (params.targets?.length)
125
- searchParams.set("targets", params.targets.join(","));
126
- if (params.features?.length)
127
- searchParams.set("features", params.features.join(","));
128
- if (params.author)
129
- searchParams.set("author", params.author);
130
- if (params.sort)
131
- searchParams.set("sort", params.sort);
132
- if (params.limit)
133
- searchParams.set("limit", String(params.limit));
134
- if (params.offset)
135
- searchParams.set("offset", String(params.offset));
136
- const url = `${this.config.registryUrl}/packs?${searchParams.toString()}`;
137
- const res = await this.fetch(url);
138
- return res;
139
- }
140
- async info(packName) {
141
- const url = `${this.config.registryUrl}/packs/${encodeURIComponent(packName)}`;
142
- const res = await this.fetch(url);
143
- return res;
144
- }
145
- async download(packName, version = "latest") {
146
- const url = `${this.config.registryUrl}/packs/${encodeURIComponent(packName)}/versions/${encodeURIComponent(version)}/download`;
147
- const response = await fetch(url, {
148
- headers: this.headers(),
149
- signal: AbortSignal.timeout(this.config.timeout)
150
- });
151
- if (!response.ok) {
152
- throw new RegistryApiError(response.status, `Failed to download ${packName}@${version}: ${response.statusText}`);
153
- }
154
- const integrity = response.headers.get("x-integrity") ?? "";
155
- const data = await response.arrayBuffer();
156
- return { data, integrity };
157
- }
158
- async publish(tarball, metadata) {
159
- if (!this.config.authToken) {
160
- throw new Error("Authentication required. Run `agentpacks login` first.");
161
- }
162
- const formData = new FormData;
163
- formData.append("tarball", new Blob([tarball], { type: "application/gzip" }), `${metadata.name}-${metadata.version}.tgz`);
164
- formData.append("metadata", JSON.stringify(metadata));
165
- const url = `${this.config.registryUrl}/packs`;
166
- const response = await fetch(url, {
167
- method: "POST",
168
- headers: {
169
- Authorization: `Bearer ${this.config.authToken}`
170
- },
171
- body: formData,
172
- signal: AbortSignal.timeout(this.config.timeout)
173
- });
174
- if (!response.ok) {
175
- const body = await response.text();
176
- throw new RegistryApiError(response.status, `Publish failed: ${body || response.statusText}`);
177
- }
178
- return await response.json();
179
- }
180
- async featured(limit) {
181
- const url = limit ? `${this.config.registryUrl}/featured?limit=${limit}` : `${this.config.registryUrl}/featured`;
182
- const res = await this.fetch(url);
183
- return res.packs;
184
- }
185
- async tags() {
186
- const url = `${this.config.registryUrl}/tags`;
187
- const res = await this.fetch(url);
188
- return res.tags;
189
- }
190
- async stats() {
191
- const url = `${this.config.registryUrl}/stats`;
192
- return await this.fetch(url);
193
- }
194
- async health() {
195
- try {
196
- const url = `${this.config.registryUrl}/health`;
197
- await this.fetch(url);
198
- return true;
199
- } catch {
200
- return false;
201
- }
202
- }
203
- async fetch(url) {
204
- const response = await fetch(url, {
205
- headers: this.headers(),
206
- signal: AbortSignal.timeout(this.config.timeout)
207
- });
208
- if (!response.ok) {
209
- const body = await response.text();
210
- throw new RegistryApiError(response.status, body || response.statusText);
211
- }
212
- return response.json();
213
- }
214
- headers() {
215
- const h = {
216
- Accept: "application/json"
217
- };
218
- if (this.config.authToken) {
219
- h["Authorization"] = `Bearer ${this.config.authToken}`;
220
- }
221
- return h;
222
- }
223
- }
224
-
225
- class RegistryApiError extends Error {
226
- status;
227
- constructor(status, message) {
228
- super(message);
229
- this.name = "RegistryApiError";
230
- this.status = status;
231
- }
232
- }
233
-
234
- // src/utils/tarball.ts
235
- import { execSync } from "child_process";
236
- import { createHash as createHash2 } from "crypto";
237
- import { existsSync as existsSync3, mkdirSync as mkdirSync2, readFileSync as readFileSync3, rmSync } from "fs";
238
- import { tmpdir } from "os";
239
- import { join as join2, resolve as resolve2 } from "path";
240
- async function createTarball(packDir) {
241
- const absDir = resolve2(packDir);
242
- const tmpFile = join2(tmpdir(), `agentpacks-${Date.now()}.tgz`);
243
- try {
244
- execSync(`tar -czf "${tmpFile}" -C "${absDir}" .`, {
245
- stdio: "pipe"
246
- });
247
- const buffer = readFileSync3(tmpFile);
248
- return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
249
- } finally {
250
- if (existsSync3(tmpFile)) {
251
- rmSync(tmpFile);
252
- }
253
- }
254
- }
255
- async function extractTarball(data, targetDir) {
256
- mkdirSync2(targetDir, { recursive: true });
257
- const tmpFile = join2(tmpdir(), `agentpacks-${Date.now()}.tgz`);
258
- try {
259
- const buffer = Buffer.from(data);
260
- const { writeFileSync: writeFileSync3 } = await import("fs");
261
- writeFileSync3(tmpFile, buffer);
262
- execSync(`tar -xzf "${tmpFile}" -C "${targetDir}"`, {
263
- stdio: "pipe"
264
- });
265
- } finally {
266
- if (existsSync3(tmpFile)) {
267
- rmSync(tmpFile);
268
- }
269
- }
270
- }
271
- function computeTarballIntegrity(data) {
272
- const hash = createHash2("sha256").update(Buffer.from(data)).digest("hex");
273
- return `sha256-${hash}`;
274
- }
275
-
276
- // src/sources/registry.ts
277
- import { existsSync as existsSync4, mkdirSync as mkdirSync3, readdirSync, rmSync as rmSync2 } from "fs";
278
- import { join as join3, resolve as resolve3 } from "path";
279
- async function installRegistrySource(projectRoot, source, lockfile, options = {}) {
280
- const parsed = parseRegistrySourceRef(source);
281
- const sourceKey = registrySourceKey(parsed);
282
- const installed = [];
283
- const warnings = [];
284
- const locked = getLockedSource(lockfile, sourceKey);
285
- if (options.frozen && !locked) {
286
- throw new Error(`Frozen mode: no lockfile entry for source "${sourceKey}".`);
287
- }
288
- let targetVersion = parsed.version;
289
- if (locked && !options.update) {
290
- targetVersion = locked.resolvedRef;
291
- } else if (targetVersion === "latest") {
292
- const clientCfg2 = buildClientConfig(options.registryUrl);
293
- const client2 = createRegistryClient(clientCfg2);
294
- const info = await client2.info(parsed.packName);
295
- targetVersion = info.latestVersion;
296
- }
297
- const clientCfg = buildClientConfig(options.registryUrl);
298
- const client = createRegistryClient(clientCfg);
299
- const { data } = await client.download(parsed.packName, targetVersion);
300
- const localIntegrity = computeTarballIntegrity(data);
301
- if (locked && !options.update && locked.skills?.["__integrity"]) {
302
- const expectedIntegrity = locked.skills["__integrity"].integrity;
303
- if (expectedIntegrity && localIntegrity !== expectedIntegrity) {
304
- throw new Error(`Integrity mismatch for ${parsed.packName}@${targetVersion}. ` + `Expected ${expectedIntegrity}, got ${localIntegrity}.`);
305
- }
306
- }
307
- const curatedDir = resolve3(projectRoot, ".agentpacks", ".curated");
308
- const packOutDir = resolve3(curatedDir, parsed.packName);
309
- if (existsSync4(packOutDir)) {
310
- rmSync2(packOutDir, { recursive: true, force: true });
311
- }
312
- mkdirSync3(packOutDir, { recursive: true });
313
- await extractTarball(data, packOutDir);
314
- collectFiles(packOutDir, installed);
315
- const newEntry = {
316
- requestedRef: parsed.version,
317
- resolvedRef: targetVersion,
318
- resolvedAt: new Date().toISOString(),
319
- skills: {
320
- __integrity: { integrity: localIntegrity }
321
- },
322
- packs: {
323
- [parsed.packName]: { integrity: localIntegrity }
324
- }
325
- };
326
- setLockedSource(lockfile, sourceKey, newEntry);
327
- return { installed, warnings };
328
- }
329
- function buildClientConfig(registryUrl) {
330
- const cfg = {};
331
- if (registryUrl) {
332
- cfg.registryUrl = registryUrl;
333
- }
334
- try {
335
- const creds = loadCredentials();
336
- if (creds?.token) {
337
- cfg.authToken = creds.token;
338
- }
339
- } catch {}
340
- return cfg;
341
- }
342
- function collectFiles(dir, out) {
343
- const entries = readdirSync(dir, { withFileTypes: true });
344
- for (const entry of entries) {
345
- const full = join3(dir, entry.name);
346
- if (entry.isDirectory()) {
347
- collectFiles(full, out);
348
- } else {
349
- out.push(full);
350
- }
351
- }
352
- }
353
- export {
354
- installRegistrySource
355
- };
2
+ var m=import.meta.require;import{createHash as p}from"crypto";import{existsSync as n,readFileSync as l,writeFileSync as c}from"fs";import{resolve as O}from"path";var o=1,T="agentpacks.lock";function Vq(q){let z=O(q,T);if(!n(z))return{lockfileVersion:o,sources:{}};let J=l(z,"utf-8");return JSON.parse(J)}function wq(q,z){let J=O(q,T);c(J,JSON.stringify(z,null,2)+`
3
+ `)}function P(q,z){return q.sources[z]}function _(q,z,J){q.sources[z]=J}function Oq(q){return`sha256-${p("sha256").update(q).digest("hex")}`}function Tq(q,z){let J=z.filter((Q)=>!(Q in q.sources));return{valid:J.length===0,missing:J}}function K(q){let z=q;if(z.startsWith("registry:"))z=z.slice(9);if(!z)throw Error(`Invalid registry source reference: "${q}". Expected pack name.`);let J="latest",Q=z.indexOf("@");if(Q>0)J=z.slice(Q+1),z=z.slice(0,Q);if(!z)throw Error(`Invalid registry source reference: "${q}". Pack name is empty.`);if(!/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(z))throw Error(`Invalid registry pack name: "${z}". Must be lowercase alphanumeric with hyphens.`);return{packName:z,version:J}}function _q(q){return q.startsWith("registry:")}function v(q){return`registry:${q.packName}`}import{existsSync as b,mkdirSync as i,readFileSync as t,writeFileSync as x}from"fs";import{homedir as a}from"os";import{dirname as s,join as j}from"path";var r=j(a(),".config","agentpacks"),$=j(r,"credentials.json");function N(){if(!b($))return{registryUrl:"https://registry.agentpacks.dev"};try{let q=t($,"utf-8");return JSON.parse(q)}catch{return{registryUrl:"https://registry.agentpacks.dev"}}}function jq(q){i(s($),{recursive:!0}),x($,JSON.stringify(q,null,2)+`
4
+ `,{mode:384})}function Nq(){if(b($))x($,JSON.stringify({registryUrl:"https://registry.agentpacks.dev"})+`
5
+ `)}function U(q){return new A({registryUrl:q?.registryUrl??"https://registry.agentpacks.dev",authToken:q?.authToken,timeout:q?.timeout??30000})}class A{config;constructor(q){this.config={registryUrl:q.registryUrl.replace(/\/+$/,""),authToken:q.authToken,timeout:q.timeout??30000}}async search(q){let z=new URLSearchParams;if(q.query)z.set("q",q.query);if(q.tags?.length)z.set("tags",q.tags.join(","));if(q.targets?.length)z.set("targets",q.targets.join(","));if(q.features?.length)z.set("features",q.features.join(","));if(q.author)z.set("author",q.author);if(q.sort)z.set("sort",q.sort);if(q.limit)z.set("limit",String(q.limit));if(q.offset)z.set("offset",String(q.offset));let J=`${this.config.registryUrl}/packs?${z.toString()}`;return await this.fetch(J)}async info(q){let z=`${this.config.registryUrl}/packs/${encodeURIComponent(q)}`;return await this.fetch(z)}async download(q,z="latest"){let J=`${this.config.registryUrl}/packs/${encodeURIComponent(q)}/versions/${encodeURIComponent(z)}/download`,Q=await fetch(J,{headers:this.headers(),signal:AbortSignal.timeout(this.config.timeout)});if(!Q.ok)throw new H(Q.status,`Failed to download ${q}@${z}: ${Q.statusText}`);let W=Q.headers.get("x-integrity")??"";return{data:await Q.arrayBuffer(),integrity:W}}async publish(q,z){if(!this.config.authToken)throw Error("Authentication required. Run `agentpacks login` first.");let J=new FormData;J.append("tarball",new Blob([q],{type:"application/gzip"}),`${z.name}-${z.version}.tgz`),J.append("metadata",JSON.stringify(z));let Q=`${this.config.registryUrl}/packs`,W=await fetch(Q,{method:"POST",headers:{Authorization:`Bearer ${this.config.authToken}`},body:J,signal:AbortSignal.timeout(this.config.timeout)});if(!W.ok){let X=await W.text();throw new H(W.status,`Publish failed: ${X||W.statusText}`)}return await W.json()}async featured(q){let z=q?`${this.config.registryUrl}/featured?limit=${q}`:`${this.config.registryUrl}/featured`;return(await this.fetch(z)).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 z=await fetch(q,{headers:this.headers(),signal:AbortSignal.timeout(this.config.timeout)});if(!z.ok){let J=await z.text();throw new H(z.status,J||z.statusText)}return z.json()}headers(){let q={Accept:"application/json"};if(this.config.authToken)q.Authorization=`Bearer ${this.config.authToken}`;return q}}class H extends Error{status;constructor(q,z){super(z);this.name="RegistryApiError",this.status=q}}import{execSync as L}from"child_process";import{createHash as e}from"crypto";import{existsSync as D,mkdirSync as qq,readFileSync as zq,rmSync as C}from"fs";import{tmpdir as h}from"os";import{join as F,resolve as Jq}from"path";async function Rq(q){let z=Jq(q),J=F(h(),`agentpacks-${Date.now()}.tgz`);try{L(`tar -czf "${J}" -C "${z}" .`,{stdio:"pipe"});let Q=zq(J);return Q.buffer.slice(Q.byteOffset,Q.byteOffset+Q.byteLength)}finally{if(D(J))C(J)}}async function I(q,z){qq(z,{recursive:!0});let J=F(h(),`agentpacks-${Date.now()}.tgz`);try{let Q=Buffer.from(q),{writeFileSync:W}=await import("fs");W(J,Q),L(`tar -xzf "${J}" -C "${z}"`,{stdio:"pipe"})}finally{if(D(J))C(J)}}function R(q){return`sha256-${e("sha256").update(Buffer.from(q)).digest("hex")}`}import{existsSync as Qq,mkdirSync as Wq,readdirSync as Xq,rmSync as Yq}from"fs";import{join as Zq,resolve as E}from"path";async function mq(q,z,J,Q={}){let W=K(z),X=v(W),V=[],u=[],Y=P(J,X);if(Q.frozen&&!Y)throw Error(`Frozen mode: no lockfile entry for source "${X}".`);let Z=W.version;if(Y&&!Q.update)Z=Y.resolvedRef;else if(Z==="latest"){let B=S(Q.registryUrl);Z=(await U(B).info(W.packName)).latestVersion}let g=S(Q.registryUrl),f=U(g),{data:w}=await f.download(W.packName,Z),M=R(w);if(Y&&!Q.update&&Y.skills?.__integrity){let B=Y.skills.__integrity.integrity;if(B&&M!==B)throw Error(`Integrity mismatch for ${W.packName}@${Z}. Expected ${B}, got ${M}.`)}let d=E(q,".agentpacks",".curated"),G=E(d,W.packName);if(Qq(G))Yq(G,{recursive:!0,force:!0});Wq(G,{recursive:!0}),await I(w,G),k(G,V);let y={requestedRef:W.version,resolvedRef:Z,resolvedAt:new Date().toISOString(),skills:{__integrity:{integrity:M}},packs:{[W.packName]:{integrity:M}}};return _(J,X,y),{installed:V,warnings:u}}function S(q){let z={};if(q)z.registryUrl=q;try{let J=N();if(J?.token)z.authToken=J.token}catch{}return z}function k(q,z){let J=Xq(q,{withFileTypes:!0});for(let Q of J){let W=Zq(q,Q.name);if(Q.isDirectory())k(W,z);else z.push(W)}}export{mq as installRegistrySource};