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,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stored credentials.
|
|
3
|
+
*/
|
|
4
|
+
export interface Credentials {
|
|
5
|
+
registryUrl: string;
|
|
6
|
+
token?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Load credentials from ~/.config/agentpacks/credentials.json.
|
|
10
|
+
*/
|
|
11
|
+
export declare function loadCredentials(): Credentials;
|
|
12
|
+
/**
|
|
13
|
+
* Save credentials to ~/.config/agentpacks/credentials.json.
|
|
14
|
+
*/
|
|
15
|
+
export declare function saveCredentials(credentials: Credentials): void;
|
|
16
|
+
/**
|
|
17
|
+
* Clear saved credentials.
|
|
18
|
+
*/
|
|
19
|
+
export declare function clearCredentials(): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __require = import.meta.require;
|
|
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/utils/diff.js
CHANGED
|
@@ -1,32 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
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 = import.meta.require;
|
|
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
|
}
|
package/dist/utils/filesystem.js
CHANGED
|
@@ -1,32 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
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 = import.meta.require;
|
|
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
|
// @bun
|
|
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 = import.meta.require;
|
|
31
3
|
|
|
32
4
|
// src/utils/frontmatter.ts
|
package/dist/utils/global.js
CHANGED
|
@@ -1,32 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
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 = import.meta.require;
|
|
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 {
|
package/dist/utils/markdown.js
CHANGED
|
@@ -1,32 +1,4 @@
|
|
|
1
1
|
// @bun
|
|
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 = import.meta.require;
|
|
31
3
|
|
|
32
4
|
// src/utils/markdown.ts
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model ID allowlist validation.
|
|
3
|
+
*
|
|
4
|
+
* Validates model identifiers against known provider patterns.
|
|
5
|
+
* Returns warnings (not errors) for unknown model IDs to allow
|
|
6
|
+
* innovative use of new models.
|
|
7
|
+
*/
|
|
8
|
+
/** Validation result. */
|
|
9
|
+
export interface ModelValidationResult {
|
|
10
|
+
modelId: string;
|
|
11
|
+
known: boolean;
|
|
12
|
+
provider?: string;
|
|
13
|
+
warning?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Validate a single model ID against the allowlist.
|
|
17
|
+
* Returns { known: true, provider } for known IDs,
|
|
18
|
+
* or { known: false, warning } for unknown IDs.
|
|
19
|
+
*/
|
|
20
|
+
export declare function validateModelId(modelId: string): ModelValidationResult;
|
|
21
|
+
/**
|
|
22
|
+
* Scan a models config for unknown model IDs.
|
|
23
|
+
* Returns warnings for any model IDs not matching known patterns.
|
|
24
|
+
* These are advisory only — they don't block publish.
|
|
25
|
+
*/
|
|
26
|
+
export declare function scanModelsForUnknownIds(config: {
|
|
27
|
+
default?: string;
|
|
28
|
+
small?: string;
|
|
29
|
+
agents?: Record<string, {
|
|
30
|
+
model: string;
|
|
31
|
+
}>;
|
|
32
|
+
profiles?: Record<string, {
|
|
33
|
+
default?: string;
|
|
34
|
+
small?: string;
|
|
35
|
+
agents?: Record<string, {
|
|
36
|
+
model: string;
|
|
37
|
+
}>;
|
|
38
|
+
}>;
|
|
39
|
+
}): string[];
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __require = import.meta.require;
|
|
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}" \u2014 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,6 @@
|
|
|
1
|
+
import type { ResolvedModels } from '../core/profile-resolver.js';
|
|
2
|
+
/**
|
|
3
|
+
* Generate a markdown model guidance document from resolved model config.
|
|
4
|
+
* Used by targets that don't have native model configuration (Claude, Copilot, generic).
|
|
5
|
+
*/
|
|
6
|
+
export declare function generateModelGuidanceMarkdown(resolved: ResolvedModels): string | null;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
var __require = import.meta.require;
|
|
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) : "\u2014";
|
|
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 ?? "\u2014"} | ${profile.default ?? "\u2014"} |`);
|
|
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 ?? "\u2014";
|
|
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,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the agentpacks pack registry API.
|
|
3
|
+
* Handles search, info, download, publish, and auth operations.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Registry API client configuration.
|
|
7
|
+
*/
|
|
8
|
+
export interface RegistryClientConfig {
|
|
9
|
+
/** Base URL of the registry API */
|
|
10
|
+
registryUrl: string;
|
|
11
|
+
/** Bearer token for authenticated operations */
|
|
12
|
+
authToken?: string;
|
|
13
|
+
/** Request timeout in milliseconds */
|
|
14
|
+
timeout?: number;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Pack search result from the registry.
|
|
18
|
+
*/
|
|
19
|
+
export interface RegistryPackResult {
|
|
20
|
+
name: string;
|
|
21
|
+
displayName: string;
|
|
22
|
+
description: string;
|
|
23
|
+
author: string;
|
|
24
|
+
downloads: number;
|
|
25
|
+
weeklyDownloads: number;
|
|
26
|
+
tags: string[];
|
|
27
|
+
targets: string[];
|
|
28
|
+
features: string[];
|
|
29
|
+
verified: boolean;
|
|
30
|
+
featured: boolean;
|
|
31
|
+
latestVersion: string;
|
|
32
|
+
updatedAt: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Detailed pack info from the registry.
|
|
36
|
+
*/
|
|
37
|
+
export interface RegistryPackInfo extends RegistryPackResult {
|
|
38
|
+
longDescription?: string;
|
|
39
|
+
license: string;
|
|
40
|
+
homepage?: string;
|
|
41
|
+
repository?: string;
|
|
42
|
+
versions: {
|
|
43
|
+
version: string;
|
|
44
|
+
createdAt: string;
|
|
45
|
+
fileCount: number;
|
|
46
|
+
tarballSize: number;
|
|
47
|
+
}[];
|
|
48
|
+
readme?: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Search parameters.
|
|
52
|
+
*/
|
|
53
|
+
export interface SearchParams {
|
|
54
|
+
query?: string;
|
|
55
|
+
tags?: string[];
|
|
56
|
+
targets?: string[];
|
|
57
|
+
features?: string[];
|
|
58
|
+
author?: string;
|
|
59
|
+
sort?: 'downloads' | 'updated' | 'name' | 'weekly';
|
|
60
|
+
limit?: number;
|
|
61
|
+
offset?: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Publish result.
|
|
65
|
+
*/
|
|
66
|
+
export interface PublishResult {
|
|
67
|
+
name: string;
|
|
68
|
+
version: string;
|
|
69
|
+
integrity: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Create a registry client with the given configuration.
|
|
73
|
+
*/
|
|
74
|
+
export declare function createRegistryClient(config?: Partial<RegistryClientConfig>): RegistryClient;
|
|
75
|
+
/**
|
|
76
|
+
* Registry API client.
|
|
77
|
+
*/
|
|
78
|
+
export declare class RegistryClient {
|
|
79
|
+
private config;
|
|
80
|
+
constructor(config: RegistryClientConfig);
|
|
81
|
+
/**
|
|
82
|
+
* Search for packs in the registry.
|
|
83
|
+
*/
|
|
84
|
+
search(params: SearchParams): Promise<{
|
|
85
|
+
packs: RegistryPackResult[];
|
|
86
|
+
total: number;
|
|
87
|
+
}>;
|
|
88
|
+
/**
|
|
89
|
+
* Get detailed pack info.
|
|
90
|
+
*/
|
|
91
|
+
info(packName: string): Promise<RegistryPackInfo>;
|
|
92
|
+
/**
|
|
93
|
+
* Download a pack tarball. Returns the raw ArrayBuffer.
|
|
94
|
+
*/
|
|
95
|
+
download(packName: string, version?: string): Promise<{
|
|
96
|
+
data: ArrayBuffer;
|
|
97
|
+
integrity: string;
|
|
98
|
+
}>;
|
|
99
|
+
/**
|
|
100
|
+
* Publish a pack tarball to the registry.
|
|
101
|
+
*/
|
|
102
|
+
publish(tarball: ArrayBuffer, metadata: {
|
|
103
|
+
name: string;
|
|
104
|
+
version: string;
|
|
105
|
+
manifest: Record<string, unknown>;
|
|
106
|
+
}): Promise<PublishResult>;
|
|
107
|
+
/**
|
|
108
|
+
* Get featured packs.
|
|
109
|
+
*/
|
|
110
|
+
featured(limit?: number): Promise<RegistryPackResult[]>;
|
|
111
|
+
/**
|
|
112
|
+
* Get available tags.
|
|
113
|
+
*/
|
|
114
|
+
tags(): Promise<{
|
|
115
|
+
tag: string;
|
|
116
|
+
count: number;
|
|
117
|
+
}[]>;
|
|
118
|
+
/**
|
|
119
|
+
* Get registry stats.
|
|
120
|
+
*/
|
|
121
|
+
stats(): Promise<{
|
|
122
|
+
totalPacks: number;
|
|
123
|
+
totalDownloads: number;
|
|
124
|
+
totalVersions: number;
|
|
125
|
+
}>;
|
|
126
|
+
/**
|
|
127
|
+
* Health check.
|
|
128
|
+
*/
|
|
129
|
+
health(): Promise<boolean>;
|
|
130
|
+
/** Internal fetch helper with timeout and error handling. */
|
|
131
|
+
private fetch;
|
|
132
|
+
/** Build headers for requests. */
|
|
133
|
+
private headers;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Registry API error with HTTP status code.
|
|
137
|
+
*/
|
|
138
|
+
export declare class RegistryApiError extends Error {
|
|
139
|
+
readonly status: number;
|
|
140
|
+
constructor(status: number, message: string);
|
|
141
|
+
}
|