agentpacks 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +168 -8
- package/dist/api.d.ts +2 -0
- package/dist/api.js +929 -409
- package/dist/cli/export-cmd.js +281 -149
- package/dist/cli/generate.js +740 -247
- package/dist/cli/import-cmd.js +57 -85
- package/dist/cli/info.d.ts +4 -0
- package/dist/cli/info.js +232 -0
- package/dist/cli/init.js +8 -36
- package/dist/cli/install.js +414 -129
- package/dist/cli/login.d.ts +9 -0
- package/dist/cli/login.js +202 -0
- package/dist/cli/models-explain.d.ts +16 -0
- package/dist/cli/models-explain.js +1205 -0
- package/dist/cli/pack/create.js +4 -32
- package/dist/cli/pack/enable.js +1 -29
- package/dist/cli/pack/list.js +266 -134
- package/dist/cli/pack/validate.js +274 -127
- package/dist/cli/publish.d.ts +8 -0
- package/dist/cli/publish.js +672 -0
- package/dist/cli/search.d.ts +12 -0
- package/dist/cli/search.js +210 -0
- package/dist/core/config.d.ts +2 -1
- package/dist/core/config.js +74 -117
- package/dist/core/dependency-resolver.js +4 -28
- package/dist/core/feature-merger.d.ts +7 -0
- package/dist/core/feature-merger.js +289 -29
- package/dist/core/index.js +283 -140
- package/dist/core/lockfile.js +0 -28
- package/dist/core/metarepo.js +74 -116
- package/dist/core/pack-loader.d.ts +2 -0
- package/dist/core/pack-loader.js +266 -133
- package/dist/core/profile-resolver.d.ts +75 -0
- package/dist/core/profile-resolver.js +111 -0
- package/dist/exporters/cursor-plugin.js +4 -32
- package/dist/exporters/index.js +4 -32
- package/dist/features/agents.d.ts +5 -0
- package/dist/features/agents.js +2 -30
- package/dist/features/commands.js +2 -30
- package/dist/features/hooks.js +2 -30
- package/dist/features/ignore.js +0 -28
- package/dist/features/index.d.ts +1 -0
- package/dist/features/index.js +176 -31
- package/dist/features/mcp.js +2 -30
- package/dist/features/models.d.ts +167 -0
- package/dist/features/models.js +293 -0
- package/dist/features/plugins.js +2 -30
- package/dist/features/rules.js +2 -30
- package/dist/features/skills.js +2 -30
- package/dist/importers/claude-code.js +10 -38
- package/dist/importers/cursor.js +15 -43
- package/dist/importers/opencode.js +16 -44
- package/dist/importers/rulesync.js +22 -50
- package/dist/index.js +1710 -538
- package/dist/node/api.js +929 -409
- package/dist/node/cli/export-cmd.js +281 -149
- package/dist/node/cli/generate.js +740 -247
- package/dist/node/cli/import-cmd.js +57 -85
- package/dist/node/cli/info.js +232 -0
- package/dist/node/cli/init.js +8 -36
- package/dist/node/cli/install.js +414 -129
- package/dist/node/cli/login.js +202 -0
- package/dist/node/cli/models-explain.js +1205 -0
- package/dist/node/cli/pack/create.js +4 -32
- package/dist/node/cli/pack/enable.js +1 -29
- package/dist/node/cli/pack/list.js +266 -134
- package/dist/node/cli/pack/validate.js +274 -127
- package/dist/node/cli/publish.js +672 -0
- package/dist/node/cli/search.js +210 -0
- package/dist/node/core/config.js +74 -117
- package/dist/node/core/dependency-resolver.js +4 -28
- package/dist/node/core/feature-merger.js +289 -29
- package/dist/node/core/index.js +283 -140
- package/dist/node/core/lockfile.js +0 -28
- package/dist/node/core/metarepo.js +74 -116
- package/dist/node/core/pack-loader.js +266 -133
- package/dist/node/core/profile-resolver.js +111 -0
- package/dist/node/exporters/cursor-plugin.js +4 -32
- package/dist/node/exporters/index.js +4 -32
- package/dist/node/features/agents.js +2 -30
- package/dist/node/features/commands.js +2 -30
- package/dist/node/features/hooks.js +2 -30
- package/dist/node/features/ignore.js +0 -28
- package/dist/node/features/index.js +176 -31
- package/dist/node/features/mcp.js +2 -30
- package/dist/node/features/models.js +293 -0
- package/dist/node/features/plugins.js +2 -30
- package/dist/node/features/rules.js +2 -30
- package/dist/node/features/skills.js +2 -30
- package/dist/node/importers/claude-code.js +10 -38
- package/dist/node/importers/cursor.js +15 -43
- package/dist/node/importers/opencode.js +16 -44
- package/dist/node/importers/rulesync.js +22 -50
- package/dist/node/index.js +1710 -538
- package/dist/node/sources/git-ref.js +7 -30
- package/dist/node/sources/git.js +7 -30
- package/dist/node/sources/index.js +337 -39
- package/dist/node/sources/local.js +0 -28
- package/dist/node/sources/npm-ref.js +0 -28
- package/dist/node/sources/npm.js +10 -37
- package/dist/node/sources/registry-ref.js +37 -0
- package/dist/node/sources/registry.js +355 -0
- package/dist/node/targets/additional-targets.js +196 -37
- package/dist/node/targets/agents-md.js +5 -33
- package/dist/node/targets/base-target.js +0 -28
- package/dist/node/targets/claude-code.js +211 -41
- package/dist/node/targets/codex-cli.js +7 -35
- package/dist/node/targets/copilot.js +202 -41
- package/dist/node/targets/cursor.js +188 -40
- package/dist/node/targets/gemini-cli.js +10 -38
- package/dist/node/targets/generic-md-target.js +196 -37
- package/dist/node/targets/index.js +414 -106
- package/dist/node/targets/opencode.js +171 -51
- package/dist/node/targets/registry.js +414 -106
- package/dist/node/utils/credentials.js +38 -0
- package/dist/node/utils/diff.js +22 -34
- package/dist/node/utils/filesystem.js +2 -30
- package/dist/node/utils/frontmatter.js +0 -28
- package/dist/node/utils/global.js +3 -31
- package/dist/node/utils/markdown.js +0 -28
- package/dist/node/utils/model-allowlist.js +110 -0
- package/dist/node/utils/model-guidance.js +78 -0
- package/dist/node/utils/registry-client.js +142 -0
- package/dist/node/utils/tarball.js +49 -0
- package/dist/sources/git-ref.js +7 -30
- package/dist/sources/git.d.ts +2 -2
- package/dist/sources/git.js +7 -30
- package/dist/sources/index.d.ts +2 -0
- package/dist/sources/index.js +337 -39
- package/dist/sources/local.js +0 -28
- package/dist/sources/npm-ref.js +0 -28
- package/dist/sources/npm.js +10 -37
- package/dist/sources/registry-ref.d.ts +30 -0
- package/dist/sources/registry-ref.js +37 -0
- package/dist/sources/registry.d.ts +18 -0
- package/dist/sources/registry.js +355 -0
- package/dist/targets/additional-targets.js +196 -37
- package/dist/targets/agents-md.js +5 -33
- package/dist/targets/base-target.d.ts +2 -0
- package/dist/targets/base-target.js +0 -28
- package/dist/targets/claude-code.js +211 -41
- package/dist/targets/codex-cli.js +7 -35
- package/dist/targets/copilot.js +202 -41
- package/dist/targets/cursor.js +188 -40
- package/dist/targets/gemini-cli.js +10 -38
- package/dist/targets/generic-md-target.js +196 -37
- package/dist/targets/index.js +414 -106
- package/dist/targets/opencode.js +171 -51
- package/dist/targets/registry.js +414 -106
- package/dist/utils/credentials.d.ts +19 -0
- package/dist/utils/credentials.js +38 -0
- package/dist/utils/diff.js +22 -34
- package/dist/utils/filesystem.js +2 -30
- package/dist/utils/frontmatter.js +0 -28
- package/dist/utils/global.js +3 -31
- package/dist/utils/markdown.js +0 -28
- package/dist/utils/model-allowlist.d.ts +39 -0
- package/dist/utils/model-allowlist.js +110 -0
- package/dist/utils/model-guidance.d.ts +6 -0
- package/dist/utils/model-guidance.js +78 -0
- package/dist/utils/registry-client.d.ts +141 -0
- package/dist/utils/registry-client.js +142 -0
- package/dist/utils/tarball.d.ts +13 -0
- package/dist/utils/tarball.js +49 -0
- package/package.json +171 -5
- package/templates/pack/models.json +38 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/utils/credentials.ts
|
|
5
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync } from "fs";
|
|
6
|
+
import { join, dirname } from "path";
|
|
7
|
+
import { homedir } from "os";
|
|
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
|
+
export {
|
|
35
|
+
saveCredentials,
|
|
36
|
+
loadCredentials,
|
|
37
|
+
clearCredentials
|
|
38
|
+
};
|
package/dist/node/utils/diff.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/utils/diff.ts
|
|
@@ -84,14 +56,29 @@ function findHunks(oldLines, newLines) {
|
|
|
84
56
|
let ni = 0;
|
|
85
57
|
while (oi < oldLines.length || ni < newLines.length) {
|
|
86
58
|
if (oi < oldLines.length && ni < newLines.length && oldLines[oi] === newLines[ni]) {
|
|
87
|
-
changes.push({
|
|
59
|
+
changes.push({
|
|
60
|
+
type: " ",
|
|
61
|
+
line: oldLines[oi] ?? "",
|
|
62
|
+
oldIdx: oi,
|
|
63
|
+
newIdx: ni
|
|
64
|
+
});
|
|
88
65
|
oi++;
|
|
89
66
|
ni++;
|
|
90
|
-
} else if (ni < newLines.length && (oi >= oldLines.length || !newLines.slice(ni).includes(oldLines[oi]))) {
|
|
91
|
-
changes.push({
|
|
67
|
+
} else if (ni < newLines.length && (oi >= oldLines.length || !newLines.slice(ni).includes(oldLines[oi] ?? ""))) {
|
|
68
|
+
changes.push({
|
|
69
|
+
type: "+",
|
|
70
|
+
line: newLines[ni] ?? "",
|
|
71
|
+
oldIdx: oi,
|
|
72
|
+
newIdx: ni
|
|
73
|
+
});
|
|
92
74
|
ni++;
|
|
93
75
|
} else {
|
|
94
|
-
changes.push({
|
|
76
|
+
changes.push({
|
|
77
|
+
type: "-",
|
|
78
|
+
line: oldLines[oi] ?? "",
|
|
79
|
+
oldIdx: oi,
|
|
80
|
+
newIdx: oi
|
|
81
|
+
});
|
|
95
82
|
oi++;
|
|
96
83
|
}
|
|
97
84
|
}
|
|
@@ -120,8 +107,9 @@ function findHunks(oldLines, newLines) {
|
|
|
120
107
|
lines: []
|
|
121
108
|
};
|
|
122
109
|
for (let i = contextStart;i < changes.indexOf(change); i++) {
|
|
123
|
-
|
|
124
|
-
|
|
110
|
+
const entry = changes[i];
|
|
111
|
+
if (entry?.type === " ") {
|
|
112
|
+
currentHunk.lines.push(` ${entry.line}`);
|
|
125
113
|
currentHunk.oldCount++;
|
|
126
114
|
currentHunk.newCount++;
|
|
127
115
|
}
|
|
@@ -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/utils/filesystem.ts
|
|
@@ -36,10 +8,10 @@ import {
|
|
|
36
8
|
readFileSync,
|
|
37
9
|
writeFileSync,
|
|
38
10
|
readdirSync,
|
|
11
|
+
rmSync,
|
|
39
12
|
statSync
|
|
40
13
|
} from "fs";
|
|
41
14
|
import { dirname, relative, join } from "path";
|
|
42
|
-
import { removeSync } from "fs-extra";
|
|
43
15
|
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
44
16
|
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
45
17
|
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
@@ -80,7 +52,7 @@ function ensureDir(dirPath) {
|
|
|
80
52
|
}
|
|
81
53
|
function removeIfExists(targetPath) {
|
|
82
54
|
if (existsSync(targetPath)) {
|
|
83
|
-
|
|
55
|
+
rmSync(targetPath, { recursive: true, force: true });
|
|
84
56
|
}
|
|
85
57
|
}
|
|
86
58
|
function listFiles(dirPath, options = {}) {
|
|
@@ -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/utils/frontmatter.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/utils/global.ts
|
|
@@ -62,15 +34,15 @@ function globalTargetDir(targetId, platform = process.platform) {
|
|
|
62
34
|
}
|
|
63
35
|
}
|
|
64
36
|
function xdgConfig(platform, home) {
|
|
65
|
-
if (process.env.XDG_CONFIG_HOME) {
|
|
66
|
-
return process.env.XDG_CONFIG_HOME;
|
|
67
|
-
}
|
|
68
37
|
if (platform === "darwin") {
|
|
69
38
|
return join(home, "Library", "Application Support");
|
|
70
39
|
}
|
|
71
40
|
if (platform === "win32") {
|
|
72
41
|
return process.env.APPDATA ?? join(home, "AppData", "Roaming");
|
|
73
42
|
}
|
|
43
|
+
if (process.env.XDG_CONFIG_HOME) {
|
|
44
|
+
return process.env.XDG_CONFIG_HOME;
|
|
45
|
+
}
|
|
74
46
|
return join(home, ".config");
|
|
75
47
|
}
|
|
76
48
|
export {
|
|
@@ -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/utils/markdown.ts
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/utils/model-allowlist.ts
|
|
5
|
+
var KNOWN_MODEL_PATTERNS = [
|
|
6
|
+
{
|
|
7
|
+
provider: "Anthropic",
|
|
8
|
+
pattern: /^(anthropic\/)?claude-(opus|sonnet|haiku|instant|3|3\.5|4)[-.\w]*/i,
|
|
9
|
+
examples: ["claude-sonnet-4-20250514", "anthropic/claude-opus-4-6"]
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
provider: "OpenAI",
|
|
13
|
+
pattern: /^(openai\/)?(gpt-4|gpt-3\.5|o[1-9]|o[1-9]-\w+|chatgpt-4o|gpt-4o)[-.\w]*/i,
|
|
14
|
+
examples: ["gpt-4o", "openai/gpt-4-turbo", "o1-preview"]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
provider: "Google",
|
|
18
|
+
pattern: /^(google\/)?gemini-(pro|ultra|nano|flash|1\.5|2\.0|2\.5|exp)[-.\w]*/i,
|
|
19
|
+
examples: ["gemini-2.5-flash", "google/gemini-pro"]
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
provider: "Meta",
|
|
23
|
+
pattern: /^(meta\/)?(llama|codellama)[-.\w]*/i,
|
|
24
|
+
examples: ["llama-3.1-70b", "meta/llama-3-8b"]
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
provider: "Mistral",
|
|
28
|
+
pattern: /^(mistral(ai)?\/)?(mistral|mixtral|codestral|pixtral)[-.\w]*/i,
|
|
29
|
+
examples: ["mistral-large", "mixtral-8x7b"]
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
provider: "Cohere",
|
|
33
|
+
pattern: /^(cohere\/)?command[-.\w]*/i,
|
|
34
|
+
examples: ["command-r-plus", "cohere/command-r"]
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
provider: "DeepSeek",
|
|
38
|
+
pattern: /^(deepseek\/)?deepseek[-.\w]*/i,
|
|
39
|
+
examples: ["deepseek-coder", "deepseek/deepseek-chat"]
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
provider: "Qwen",
|
|
43
|
+
pattern: /^(qwen\/)?qwen[-.\w]*/i,
|
|
44
|
+
examples: ["qwen-2.5-72b"]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
provider: "xAI",
|
|
48
|
+
pattern: /^(xai\/)?grok[-.\w]*/i,
|
|
49
|
+
examples: ["grok-2", "xai/grok-3"]
|
|
50
|
+
}
|
|
51
|
+
];
|
|
52
|
+
function validateModelId(modelId) {
|
|
53
|
+
if (!modelId || typeof modelId !== "string") {
|
|
54
|
+
return {
|
|
55
|
+
modelId: modelId ?? "",
|
|
56
|
+
known: false,
|
|
57
|
+
warning: "Empty model ID"
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
for (const entry of KNOWN_MODEL_PATTERNS) {
|
|
61
|
+
if (entry.pattern.test(modelId)) {
|
|
62
|
+
return {
|
|
63
|
+
modelId,
|
|
64
|
+
known: true,
|
|
65
|
+
provider: entry.provider
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
modelId,
|
|
71
|
+
known: false,
|
|
72
|
+
warning: `Unknown model ID "${modelId}" — not in any known provider pattern. This may be a new or custom model.`
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function scanModelsForUnknownIds(config) {
|
|
76
|
+
const warnings = [];
|
|
77
|
+
const checked = new Set;
|
|
78
|
+
function check(modelId, context) {
|
|
79
|
+
if (!modelId || checked.has(modelId))
|
|
80
|
+
return;
|
|
81
|
+
checked.add(modelId);
|
|
82
|
+
const result = validateModelId(modelId);
|
|
83
|
+
if (!result.known) {
|
|
84
|
+
warnings.push(`${context}: ${result.warning}`);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
check(config.default, "default model");
|
|
88
|
+
check(config.small, "small model");
|
|
89
|
+
if (config.agents) {
|
|
90
|
+
for (const [name, assignment] of Object.entries(config.agents)) {
|
|
91
|
+
check(assignment.model, `agent "${name}"`);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (config.profiles) {
|
|
95
|
+
for (const [profileName, profile] of Object.entries(config.profiles)) {
|
|
96
|
+
check(profile.default, `profile "${profileName}" default`);
|
|
97
|
+
check(profile.small, `profile "${profileName}" small`);
|
|
98
|
+
if (profile.agents) {
|
|
99
|
+
for (const [name, assignment] of Object.entries(profile.agents)) {
|
|
100
|
+
check(assignment.model, `profile "${profileName}" agent "${name}"`);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return warnings;
|
|
106
|
+
}
|
|
107
|
+
export {
|
|
108
|
+
validateModelId,
|
|
109
|
+
scanModelsForUnknownIds
|
|
110
|
+
};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/utils/model-guidance.ts
|
|
5
|
+
function generateModelGuidanceMarkdown(resolved) {
|
|
6
|
+
if (!resolved.default && !resolved.small && Object.keys(resolved.agents).length === 0 && Object.keys(resolved.profiles).length === 0) {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
const lines = [];
|
|
10
|
+
lines.push("# Model Configuration");
|
|
11
|
+
lines.push("");
|
|
12
|
+
lines.push("Use the following model preferences when working in this project.");
|
|
13
|
+
lines.push("");
|
|
14
|
+
if (resolved.default || resolved.small) {
|
|
15
|
+
lines.push("## Default Models");
|
|
16
|
+
lines.push("");
|
|
17
|
+
if (resolved.default) {
|
|
18
|
+
lines.push(`- **Primary model**: ${resolved.default}`);
|
|
19
|
+
}
|
|
20
|
+
if (resolved.small) {
|
|
21
|
+
lines.push(`- **Lightweight tasks** (titles, summaries): ${resolved.small}`);
|
|
22
|
+
}
|
|
23
|
+
lines.push("");
|
|
24
|
+
}
|
|
25
|
+
const agentEntries = Object.entries(resolved.agents);
|
|
26
|
+
if (agentEntries.length > 0) {
|
|
27
|
+
lines.push("## Agent Model Assignments");
|
|
28
|
+
lines.push("");
|
|
29
|
+
lines.push("| Agent | Model | Temperature |");
|
|
30
|
+
lines.push("| --- | --- | --- |");
|
|
31
|
+
for (const [name, assignment] of agentEntries) {
|
|
32
|
+
const temp = assignment.temperature !== undefined ? String(assignment.temperature) : "—";
|
|
33
|
+
lines.push(`| ${name} | ${assignment.model} | ${temp} |`);
|
|
34
|
+
}
|
|
35
|
+
lines.push("");
|
|
36
|
+
}
|
|
37
|
+
if (Object.keys(resolved.profiles).length > 0) {
|
|
38
|
+
lines.push("## Available Profiles");
|
|
39
|
+
lines.push("");
|
|
40
|
+
lines.push("| Profile | Description | Default Model |");
|
|
41
|
+
lines.push("| --- | --- | --- |");
|
|
42
|
+
for (const [name, profile] of Object.entries(resolved.profiles)) {
|
|
43
|
+
lines.push(`| ${name} | ${profile.description ?? "—"} | ${profile.default ?? "—"} |`);
|
|
44
|
+
}
|
|
45
|
+
lines.push("");
|
|
46
|
+
}
|
|
47
|
+
if (resolved.activeProfile) {
|
|
48
|
+
lines.push(`**Active profile**: \`${resolved.activeProfile}\``);
|
|
49
|
+
lines.push("");
|
|
50
|
+
}
|
|
51
|
+
if (resolved.routing.length > 0) {
|
|
52
|
+
lines.push("## Task-Aware Routing");
|
|
53
|
+
lines.push("");
|
|
54
|
+
lines.push("Select the appropriate profile based on the task context:");
|
|
55
|
+
lines.push("");
|
|
56
|
+
lines.push("| Condition | Profile | Description |");
|
|
57
|
+
lines.push("| --- | --- | --- |");
|
|
58
|
+
for (const rule of resolved.routing) {
|
|
59
|
+
const conditions = Object.entries(rule.when).map(([k, v]) => `${k}=${v}`).join(", ");
|
|
60
|
+
const desc = rule.description ?? "—";
|
|
61
|
+
lines.push(`| ${conditions} | ${rule.use} | ${desc} |`);
|
|
62
|
+
}
|
|
63
|
+
lines.push("");
|
|
64
|
+
lines.push("### Condition Reference");
|
|
65
|
+
lines.push("");
|
|
66
|
+
lines.push("- **complexity**: low | medium | high | critical");
|
|
67
|
+
lines.push("- **urgency**: low | normal | high");
|
|
68
|
+
lines.push("- **budget**: minimal | standard | premium");
|
|
69
|
+
lines.push("- **contextWindowNeed**: small | medium | large | max");
|
|
70
|
+
lines.push("- **toolUseIntensity**: none | light | heavy");
|
|
71
|
+
lines.push("");
|
|
72
|
+
}
|
|
73
|
+
return lines.join(`
|
|
74
|
+
`);
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
generateModelGuidanceMarkdown
|
|
78
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/utils/registry-client.ts
|
|
5
|
+
var DEFAULT_REGISTRY_URL = "https://registry.agentpacks.dev";
|
|
6
|
+
function createRegistryClient(config) {
|
|
7
|
+
return new RegistryClient({
|
|
8
|
+
registryUrl: config?.registryUrl ?? DEFAULT_REGISTRY_URL,
|
|
9
|
+
authToken: config?.authToken,
|
|
10
|
+
timeout: config?.timeout ?? 30000
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
class RegistryClient {
|
|
15
|
+
config;
|
|
16
|
+
constructor(config) {
|
|
17
|
+
this.config = {
|
|
18
|
+
registryUrl: config.registryUrl.replace(/\/+$/, ""),
|
|
19
|
+
authToken: config.authToken,
|
|
20
|
+
timeout: config.timeout ?? 30000
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
async search(params) {
|
|
24
|
+
const searchParams = new URLSearchParams;
|
|
25
|
+
if (params.query)
|
|
26
|
+
searchParams.set("q", params.query);
|
|
27
|
+
if (params.tags?.length)
|
|
28
|
+
searchParams.set("tags", params.tags.join(","));
|
|
29
|
+
if (params.targets?.length)
|
|
30
|
+
searchParams.set("targets", params.targets.join(","));
|
|
31
|
+
if (params.features?.length)
|
|
32
|
+
searchParams.set("features", params.features.join(","));
|
|
33
|
+
if (params.author)
|
|
34
|
+
searchParams.set("author", params.author);
|
|
35
|
+
if (params.sort)
|
|
36
|
+
searchParams.set("sort", params.sort);
|
|
37
|
+
if (params.limit)
|
|
38
|
+
searchParams.set("limit", String(params.limit));
|
|
39
|
+
if (params.offset)
|
|
40
|
+
searchParams.set("offset", String(params.offset));
|
|
41
|
+
const url = `${this.config.registryUrl}/packs?${searchParams.toString()}`;
|
|
42
|
+
const res = await this.fetch(url);
|
|
43
|
+
return res;
|
|
44
|
+
}
|
|
45
|
+
async info(packName) {
|
|
46
|
+
const url = `${this.config.registryUrl}/packs/${encodeURIComponent(packName)}`;
|
|
47
|
+
const res = await this.fetch(url);
|
|
48
|
+
return res;
|
|
49
|
+
}
|
|
50
|
+
async download(packName, version = "latest") {
|
|
51
|
+
const url = `${this.config.registryUrl}/packs/${encodeURIComponent(packName)}/versions/${encodeURIComponent(version)}/download`;
|
|
52
|
+
const response = await fetch(url, {
|
|
53
|
+
headers: this.headers(),
|
|
54
|
+
signal: AbortSignal.timeout(this.config.timeout)
|
|
55
|
+
});
|
|
56
|
+
if (!response.ok) {
|
|
57
|
+
throw new RegistryApiError(response.status, `Failed to download ${packName}@${version}: ${response.statusText}`);
|
|
58
|
+
}
|
|
59
|
+
const integrity = response.headers.get("x-integrity") ?? "";
|
|
60
|
+
const data = await response.arrayBuffer();
|
|
61
|
+
return { data, integrity };
|
|
62
|
+
}
|
|
63
|
+
async publish(tarball, metadata) {
|
|
64
|
+
if (!this.config.authToken) {
|
|
65
|
+
throw new Error("Authentication required. Run `agentpacks login` first.");
|
|
66
|
+
}
|
|
67
|
+
const formData = new FormData;
|
|
68
|
+
formData.append("tarball", new Blob([tarball], { type: "application/gzip" }), `${metadata.name}-${metadata.version}.tgz`);
|
|
69
|
+
formData.append("metadata", JSON.stringify(metadata));
|
|
70
|
+
const url = `${this.config.registryUrl}/packs`;
|
|
71
|
+
const response = await fetch(url, {
|
|
72
|
+
method: "POST",
|
|
73
|
+
headers: {
|
|
74
|
+
Authorization: `Bearer ${this.config.authToken}`
|
|
75
|
+
},
|
|
76
|
+
body: formData,
|
|
77
|
+
signal: AbortSignal.timeout(this.config.timeout)
|
|
78
|
+
});
|
|
79
|
+
if (!response.ok) {
|
|
80
|
+
const body = await response.text();
|
|
81
|
+
throw new RegistryApiError(response.status, `Publish failed: ${body || response.statusText}`);
|
|
82
|
+
}
|
|
83
|
+
return await response.json();
|
|
84
|
+
}
|
|
85
|
+
async featured(limit) {
|
|
86
|
+
const url = limit ? `${this.config.registryUrl}/featured?limit=${limit}` : `${this.config.registryUrl}/featured`;
|
|
87
|
+
const res = await this.fetch(url);
|
|
88
|
+
return res.packs;
|
|
89
|
+
}
|
|
90
|
+
async tags() {
|
|
91
|
+
const url = `${this.config.registryUrl}/tags`;
|
|
92
|
+
const res = await this.fetch(url);
|
|
93
|
+
return res.tags;
|
|
94
|
+
}
|
|
95
|
+
async stats() {
|
|
96
|
+
const url = `${this.config.registryUrl}/stats`;
|
|
97
|
+
return await this.fetch(url);
|
|
98
|
+
}
|
|
99
|
+
async health() {
|
|
100
|
+
try {
|
|
101
|
+
const url = `${this.config.registryUrl}/health`;
|
|
102
|
+
await this.fetch(url);
|
|
103
|
+
return true;
|
|
104
|
+
} catch {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async fetch(url) {
|
|
109
|
+
const response = await fetch(url, {
|
|
110
|
+
headers: this.headers(),
|
|
111
|
+
signal: AbortSignal.timeout(this.config.timeout)
|
|
112
|
+
});
|
|
113
|
+
if (!response.ok) {
|
|
114
|
+
const body = await response.text();
|
|
115
|
+
throw new RegistryApiError(response.status, body || response.statusText);
|
|
116
|
+
}
|
|
117
|
+
return response.json();
|
|
118
|
+
}
|
|
119
|
+
headers() {
|
|
120
|
+
const h = {
|
|
121
|
+
Accept: "application/json"
|
|
122
|
+
};
|
|
123
|
+
if (this.config.authToken) {
|
|
124
|
+
h["Authorization"] = `Bearer ${this.config.authToken}`;
|
|
125
|
+
}
|
|
126
|
+
return h;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
class RegistryApiError extends Error {
|
|
131
|
+
status;
|
|
132
|
+
constructor(status, message) {
|
|
133
|
+
super(message);
|
|
134
|
+
this.name = "RegistryApiError";
|
|
135
|
+
this.status = status;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
export {
|
|
139
|
+
createRegistryClient,
|
|
140
|
+
RegistryClient,
|
|
141
|
+
RegistryApiError
|
|
142
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
// src/utils/tarball.ts
|
|
5
|
+
import { execSync } from "child_process";
|
|
6
|
+
import { readFileSync, existsSync, mkdirSync, rmSync } from "fs";
|
|
7
|
+
import { join, resolve } from "path";
|
|
8
|
+
import { createHash } from "crypto";
|
|
9
|
+
import { tmpdir } from "os";
|
|
10
|
+
async function createTarball(packDir) {
|
|
11
|
+
const absDir = resolve(packDir);
|
|
12
|
+
const tmpFile = join(tmpdir(), `agentpacks-${Date.now()}.tgz`);
|
|
13
|
+
try {
|
|
14
|
+
execSync(`tar -czf "${tmpFile}" -C "${absDir}" .`, {
|
|
15
|
+
stdio: "pipe"
|
|
16
|
+
});
|
|
17
|
+
const buffer = readFileSync(tmpFile);
|
|
18
|
+
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
19
|
+
} finally {
|
|
20
|
+
if (existsSync(tmpFile)) {
|
|
21
|
+
rmSync(tmpFile);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function extractTarball(data, targetDir) {
|
|
26
|
+
mkdirSync(targetDir, { recursive: true });
|
|
27
|
+
const tmpFile = join(tmpdir(), `agentpacks-${Date.now()}.tgz`);
|
|
28
|
+
try {
|
|
29
|
+
const buffer = Buffer.from(data);
|
|
30
|
+
const { writeFileSync } = await import("fs");
|
|
31
|
+
writeFileSync(tmpFile, buffer);
|
|
32
|
+
execSync(`tar -xzf "${tmpFile}" -C "${targetDir}"`, {
|
|
33
|
+
stdio: "pipe"
|
|
34
|
+
});
|
|
35
|
+
} finally {
|
|
36
|
+
if (existsSync(tmpFile)) {
|
|
37
|
+
rmSync(tmpFile);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function computeTarballIntegrity(data) {
|
|
42
|
+
const hash = createHash("sha256").update(Buffer.from(data)).digest("hex");
|
|
43
|
+
return `sha256-${hash}`;
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
extractTarball,
|
|
47
|
+
createTarball,
|
|
48
|
+
computeTarballIntegrity
|
|
49
|
+
};
|