agentpacks 0.2.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/dist/api.d.ts +32 -0
- package/dist/api.js +2852 -0
- package/dist/cli/export-cmd.d.ts +12 -0
- package/dist/cli/export-cmd.js +786 -0
- package/dist/cli/generate.d.ts +13 -0
- package/dist/cli/generate.js +2018 -0
- package/dist/cli/import-cmd.d.ts +9 -0
- package/dist/cli/import-cmd.js +691 -0
- package/dist/cli/init.d.ts +5 -0
- package/dist/cli/init.js +214 -0
- package/dist/cli/install.d.ts +11 -0
- package/dist/cli/install.js +610 -0
- package/dist/cli/pack/create.d.ts +4 -0
- package/dist/cli/pack/create.js +175 -0
- package/dist/cli/pack/enable.d.ts +8 -0
- package/dist/cli/pack/enable.js +96 -0
- package/dist/cli/pack/list.d.ts +4 -0
- package/dist/cli/pack/list.js +699 -0
- package/dist/cli/pack/validate.d.ts +4 -0
- package/dist/cli/pack/validate.js +364 -0
- package/dist/core/config.d.ts +77 -0
- package/dist/core/config.js +181 -0
- package/dist/core/dependency-resolver.d.ts +38 -0
- package/dist/core/dependency-resolver.js +151 -0
- package/dist/core/feature-merger.d.ts +61 -0
- package/dist/core/feature-merger.js +139 -0
- package/dist/core/index.d.ts +5 -0
- package/dist/core/index.js +924 -0
- package/dist/core/lockfile.d.ts +50 -0
- package/dist/core/lockfile.js +72 -0
- package/dist/core/metarepo.d.ts +26 -0
- package/dist/core/metarepo.js +218 -0
- package/dist/core/pack-loader.d.ts +61 -0
- package/dist/core/pack-loader.js +646 -0
- package/dist/exporters/cursor-plugin.d.ts +29 -0
- package/dist/exporters/cursor-plugin.js +258 -0
- package/dist/exporters/index.d.ts +1 -0
- package/dist/exporters/index.js +258 -0
- package/dist/features/agents.d.ts +48 -0
- package/dist/features/agents.js +190 -0
- package/dist/features/commands.d.ts +33 -0
- package/dist/features/commands.js +190 -0
- package/dist/features/hooks.d.ts +33 -0
- package/dist/features/hooks.js +182 -0
- package/dist/features/ignore.d.ts +21 -0
- package/dist/features/ignore.js +72 -0
- package/dist/features/index.d.ts +8 -0
- package/dist/features/index.js +426 -0
- package/dist/features/mcp.d.ts +34 -0
- package/dist/features/mcp.js +172 -0
- package/dist/features/plugins.d.ts +23 -0
- package/dist/features/plugins.js +168 -0
- package/dist/features/rules.d.ts +53 -0
- package/dist/features/rules.js +198 -0
- package/dist/features/skills.d.ts +42 -0
- package/dist/features/skills.js +198 -0
- package/dist/importers/claude-code.d.ts +5 -0
- package/dist/importers/claude-code.js +224 -0
- package/dist/importers/cursor.d.ts +5 -0
- package/dist/importers/cursor.js +288 -0
- package/dist/importers/opencode.d.ts +5 -0
- package/dist/importers/opencode.js +261 -0
- package/dist/importers/rulesync.d.ts +14 -0
- package/dist/importers/rulesync.js +280 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3464 -0
- package/dist/node/api.js +2852 -0
- package/dist/node/cli/export-cmd.js +786 -0
- package/dist/node/cli/generate.js +2018 -0
- package/dist/node/cli/import-cmd.js +691 -0
- package/dist/node/cli/init.js +214 -0
- package/dist/node/cli/install.js +610 -0
- package/dist/node/cli/pack/create.js +175 -0
- package/dist/node/cli/pack/enable.js +96 -0
- package/dist/node/cli/pack/list.js +699 -0
- package/dist/node/cli/pack/validate.js +364 -0
- package/dist/node/core/config.js +181 -0
- package/dist/node/core/dependency-resolver.js +151 -0
- package/dist/node/core/feature-merger.js +139 -0
- package/dist/node/core/index.js +924 -0
- package/dist/node/core/lockfile.js +72 -0
- package/dist/node/core/metarepo.js +218 -0
- package/dist/node/core/pack-loader.js +646 -0
- package/dist/node/exporters/cursor-plugin.js +258 -0
- package/dist/node/exporters/index.js +258 -0
- package/dist/node/features/agents.js +190 -0
- package/dist/node/features/commands.js +190 -0
- package/dist/node/features/hooks.js +182 -0
- package/dist/node/features/ignore.js +72 -0
- package/dist/node/features/index.js +426 -0
- package/dist/node/features/mcp.js +172 -0
- package/dist/node/features/plugins.js +168 -0
- package/dist/node/features/rules.js +198 -0
- package/dist/node/features/skills.js +198 -0
- package/dist/node/importers/claude-code.js +224 -0
- package/dist/node/importers/cursor.js +288 -0
- package/dist/node/importers/opencode.js +261 -0
- package/dist/node/importers/rulesync.js +280 -0
- package/dist/node/index.js +3464 -0
- package/dist/node/sources/git-ref.js +79 -0
- package/dist/node/sources/git.js +245 -0
- package/dist/node/sources/index.js +416 -0
- package/dist/node/sources/local.js +52 -0
- package/dist/node/sources/npm-ref.js +84 -0
- package/dist/node/sources/npm.js +211 -0
- package/dist/node/targets/additional-targets.js +428 -0
- package/dist/node/targets/agents-md.js +239 -0
- package/dist/node/targets/base-target.js +51 -0
- package/dist/node/targets/claude-code.js +490 -0
- package/dist/node/targets/codex-cli.js +297 -0
- package/dist/node/targets/copilot.js +390 -0
- package/dist/node/targets/cursor.js +441 -0
- package/dist/node/targets/gemini-cli.js +352 -0
- package/dist/node/targets/generic-md-target.js +319 -0
- package/dist/node/targets/index.js +1351 -0
- package/dist/node/targets/opencode.js +556 -0
- package/dist/node/targets/registry.js +1343 -0
- package/dist/node/utils/diff.js +144 -0
- package/dist/node/utils/filesystem.js +152 -0
- package/dist/node/utils/frontmatter.js +52 -0
- package/dist/node/utils/global.js +81 -0
- package/dist/node/utils/markdown.js +62 -0
- package/dist/sources/git-ref.d.ts +27 -0
- package/dist/sources/git-ref.js +79 -0
- package/dist/sources/git.d.ts +29 -0
- package/dist/sources/git.js +245 -0
- package/dist/sources/index.d.ts +5 -0
- package/dist/sources/index.js +416 -0
- package/dist/sources/local.d.ts +8 -0
- package/dist/sources/local.js +52 -0
- package/dist/sources/npm-ref.d.ts +30 -0
- package/dist/sources/npm-ref.js +84 -0
- package/dist/sources/npm.d.ts +20 -0
- package/dist/sources/npm.js +211 -0
- package/dist/targets/additional-targets.d.ts +65 -0
- package/dist/targets/additional-targets.js +428 -0
- package/dist/targets/agents-md.d.ts +13 -0
- package/dist/targets/agents-md.js +239 -0
- package/dist/targets/base-target.d.ts +61 -0
- package/dist/targets/base-target.js +51 -0
- package/dist/targets/claude-code.d.ts +13 -0
- package/dist/targets/claude-code.js +490 -0
- package/dist/targets/codex-cli.d.ts +12 -0
- package/dist/targets/codex-cli.js +297 -0
- package/dist/targets/copilot.d.ts +12 -0
- package/dist/targets/copilot.js +390 -0
- package/dist/targets/cursor.d.ts +13 -0
- package/dist/targets/cursor.js +441 -0
- package/dist/targets/gemini-cli.d.ts +12 -0
- package/dist/targets/gemini-cli.js +352 -0
- package/dist/targets/generic-md-target.d.ts +25 -0
- package/dist/targets/generic-md-target.js +319 -0
- package/dist/targets/index.d.ts +9 -0
- package/dist/targets/index.js +1351 -0
- package/dist/targets/opencode.d.ts +13 -0
- package/dist/targets/opencode.js +556 -0
- package/dist/targets/registry.d.ts +17 -0
- package/dist/targets/registry.js +1343 -0
- package/dist/utils/diff.d.ts +13 -0
- package/dist/utils/diff.js +144 -0
- package/dist/utils/filesystem.d.ts +49 -0
- package/dist/utils/filesystem.js +152 -0
- package/dist/utils/frontmatter.d.ts +19 -0
- package/dist/utils/frontmatter.js +52 -0
- package/dist/utils/global.d.ts +17 -0
- package/dist/utils/global.js +81 -0
- package/dist/utils/markdown.d.ts +20 -0
- package/dist/utils/markdown.js +62 -0
- package/package.json +808 -0
- package/templates/pack/pack.json +10 -0
- package/templates/pack/rules/overview.md +22 -0
- package/templates/workspace/agentpacks.jsonc +34 -0
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
31
|
+
|
|
32
|
+
// src/sources/git-ref.ts
|
|
33
|
+
function parseGitSourceRef(source) {
|
|
34
|
+
let s = source;
|
|
35
|
+
if (s.startsWith("github:")) {
|
|
36
|
+
s = s.slice(7);
|
|
37
|
+
}
|
|
38
|
+
let path = "";
|
|
39
|
+
const atIdx = s.indexOf("@");
|
|
40
|
+
const colonIdx = s.indexOf(":", atIdx > -1 ? atIdx : 0);
|
|
41
|
+
if (colonIdx > -1) {
|
|
42
|
+
path = s.slice(colonIdx + 1);
|
|
43
|
+
s = s.slice(0, colonIdx);
|
|
44
|
+
}
|
|
45
|
+
let ref = "main";
|
|
46
|
+
if (atIdx > -1) {
|
|
47
|
+
ref = s.slice(atIdx + 1);
|
|
48
|
+
s = s.slice(0, atIdx);
|
|
49
|
+
}
|
|
50
|
+
const parts = s.split("/");
|
|
51
|
+
if (parts.length < 2) {
|
|
52
|
+
throw new Error(`Invalid git source reference: "${source}". Expected owner/repo format.`);
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
owner: parts[0],
|
|
56
|
+
repo: parts[1],
|
|
57
|
+
ref,
|
|
58
|
+
path: path || ""
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function isGitPackRef(packRef) {
|
|
62
|
+
if (packRef.startsWith("github:"))
|
|
63
|
+
return true;
|
|
64
|
+
if (packRef.startsWith("./") || packRef.startsWith("../") || packRef.startsWith("/")) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if (packRef.startsWith("@") || packRef.startsWith("npm:"))
|
|
68
|
+
return false;
|
|
69
|
+
const parts = packRef.split("/");
|
|
70
|
+
return parts.length === 2 && !packRef.includes("node_modules");
|
|
71
|
+
}
|
|
72
|
+
function gitSourceKey(parsed) {
|
|
73
|
+
return `${parsed.owner}/${parsed.repo}`;
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
parseGitSourceRef,
|
|
77
|
+
isGitPackRef,
|
|
78
|
+
gitSourceKey
|
|
79
|
+
};
|
|
@@ -0,0 +1,245 @@
|
|
|
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
|
+
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
31
|
+
|
|
32
|
+
// src/core/lockfile.ts
|
|
33
|
+
import { existsSync, readFileSync, writeFileSync } from "fs";
|
|
34
|
+
import { resolve } from "path";
|
|
35
|
+
import { createHash } from "crypto";
|
|
36
|
+
var LOCKFILE_VERSION = 1;
|
|
37
|
+
var LOCKFILE_NAME = "agentpacks.lock";
|
|
38
|
+
function loadLockfile(projectRoot) {
|
|
39
|
+
const filepath = resolve(projectRoot, LOCKFILE_NAME);
|
|
40
|
+
if (!existsSync(filepath)) {
|
|
41
|
+
return { lockfileVersion: LOCKFILE_VERSION, sources: {} };
|
|
42
|
+
}
|
|
43
|
+
const raw = readFileSync(filepath, "utf-8");
|
|
44
|
+
return JSON.parse(raw);
|
|
45
|
+
}
|
|
46
|
+
function saveLockfile(projectRoot, lockfile) {
|
|
47
|
+
const filepath = resolve(projectRoot, LOCKFILE_NAME);
|
|
48
|
+
writeFileSync(filepath, JSON.stringify(lockfile, null, 2) + `
|
|
49
|
+
`);
|
|
50
|
+
}
|
|
51
|
+
function getLockedSource(lockfile, sourceKey) {
|
|
52
|
+
return lockfile.sources[sourceKey];
|
|
53
|
+
}
|
|
54
|
+
function setLockedSource(lockfile, sourceKey, entry) {
|
|
55
|
+
lockfile.sources[sourceKey] = entry;
|
|
56
|
+
}
|
|
57
|
+
function computeIntegrity(content) {
|
|
58
|
+
const hash = createHash("sha256").update(content).digest("hex");
|
|
59
|
+
return `sha256-${hash}`;
|
|
60
|
+
}
|
|
61
|
+
function isLockfileFrozenValid(lockfile, sourceKeys) {
|
|
62
|
+
const missing = sourceKeys.filter((key) => !(key in lockfile.sources));
|
|
63
|
+
return { valid: missing.length === 0, missing };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// src/sources/git-ref.ts
|
|
67
|
+
function parseGitSourceRef(source) {
|
|
68
|
+
let s = source;
|
|
69
|
+
if (s.startsWith("github:")) {
|
|
70
|
+
s = s.slice(7);
|
|
71
|
+
}
|
|
72
|
+
let path = "";
|
|
73
|
+
const atIdx = s.indexOf("@");
|
|
74
|
+
const colonIdx = s.indexOf(":", atIdx > -1 ? atIdx : 0);
|
|
75
|
+
if (colonIdx > -1) {
|
|
76
|
+
path = s.slice(colonIdx + 1);
|
|
77
|
+
s = s.slice(0, colonIdx);
|
|
78
|
+
}
|
|
79
|
+
let ref = "main";
|
|
80
|
+
if (atIdx > -1) {
|
|
81
|
+
ref = s.slice(atIdx + 1);
|
|
82
|
+
s = s.slice(0, atIdx);
|
|
83
|
+
}
|
|
84
|
+
const parts = s.split("/");
|
|
85
|
+
if (parts.length < 2) {
|
|
86
|
+
throw new Error(`Invalid git source reference: "${source}". Expected owner/repo format.`);
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
owner: parts[0],
|
|
90
|
+
repo: parts[1],
|
|
91
|
+
ref,
|
|
92
|
+
path: path || ""
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function isGitPackRef(packRef) {
|
|
96
|
+
if (packRef.startsWith("github:"))
|
|
97
|
+
return true;
|
|
98
|
+
if (packRef.startsWith("./") || packRef.startsWith("../") || packRef.startsWith("/")) {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
if (packRef.startsWith("@") || packRef.startsWith("npm:"))
|
|
102
|
+
return false;
|
|
103
|
+
const parts = packRef.split("/");
|
|
104
|
+
return parts.length === 2 && !packRef.includes("node_modules");
|
|
105
|
+
}
|
|
106
|
+
function gitSourceKey(parsed) {
|
|
107
|
+
return `${parsed.owner}/${parsed.repo}`;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// src/sources/git.ts
|
|
111
|
+
import { mkdirSync, writeFileSync as writeFileSync2 } from "fs";
|
|
112
|
+
import { resolve as resolve2, join } from "path";
|
|
113
|
+
var GITHUB_API = "https://api.github.com";
|
|
114
|
+
function githubHeaders(token) {
|
|
115
|
+
const h = {
|
|
116
|
+
Accept: "application/vnd.github.v3+json",
|
|
117
|
+
"User-Agent": "agentpacks"
|
|
118
|
+
};
|
|
119
|
+
if (token)
|
|
120
|
+
h.Authorization = `token ${token}`;
|
|
121
|
+
return h;
|
|
122
|
+
}
|
|
123
|
+
async function resolveGitRef(parsed, token) {
|
|
124
|
+
const base = `${GITHUB_API}/repos/${parsed.owner}/${parsed.repo}/git/ref`;
|
|
125
|
+
const res = await fetch(`${base}/heads/${parsed.ref}`, {
|
|
126
|
+
headers: githubHeaders(token)
|
|
127
|
+
});
|
|
128
|
+
if (!res.ok) {
|
|
129
|
+
const tagRes = await fetch(`${base}/tags/${parsed.ref}`, {
|
|
130
|
+
headers: githubHeaders(token)
|
|
131
|
+
});
|
|
132
|
+
if (!tagRes.ok) {
|
|
133
|
+
throw new Error(`Could not resolve ref "${parsed.ref}" for ${parsed.owner}/${parsed.repo}: ${res.status}`);
|
|
134
|
+
}
|
|
135
|
+
const tagData = await tagRes.json();
|
|
136
|
+
return tagData.object.sha;
|
|
137
|
+
}
|
|
138
|
+
const data = await res.json();
|
|
139
|
+
return data.object.sha;
|
|
140
|
+
}
|
|
141
|
+
async function fetchGitDirectory(parsed, sha, subpath, token) {
|
|
142
|
+
const path = parsed.path ? `${parsed.path}/${subpath}` : subpath;
|
|
143
|
+
const url = `${GITHUB_API}/repos/${parsed.owner}/${parsed.repo}/contents/${path}?ref=${sha}`;
|
|
144
|
+
const res = await fetch(url, { headers: githubHeaders(token) });
|
|
145
|
+
if (!res.ok)
|
|
146
|
+
return [];
|
|
147
|
+
return await res.json();
|
|
148
|
+
}
|
|
149
|
+
async function fetchGitFile(downloadUrl, token) {
|
|
150
|
+
const headers = { "User-Agent": "agentpacks" };
|
|
151
|
+
if (token)
|
|
152
|
+
headers.Authorization = `token ${token}`;
|
|
153
|
+
const res = await fetch(downloadUrl, { headers });
|
|
154
|
+
if (!res.ok) {
|
|
155
|
+
throw new Error(`Failed to fetch ${downloadUrl}: ${res.status}`);
|
|
156
|
+
}
|
|
157
|
+
return res.text();
|
|
158
|
+
}
|
|
159
|
+
async function fetchAndWriteSubdir(parsed, sha, remotePath, localDir, installed, token) {
|
|
160
|
+
mkdirSync(localDir, { recursive: true });
|
|
161
|
+
const entries = await fetchGitDirectory(parsed, sha, remotePath, token);
|
|
162
|
+
for (const entry of entries) {
|
|
163
|
+
if (entry.type === "file" && entry.download_url) {
|
|
164
|
+
const content = await fetchGitFile(entry.download_url, token);
|
|
165
|
+
const filepath = join(localDir, entry.name);
|
|
166
|
+
writeFileSync2(filepath, content);
|
|
167
|
+
installed.push(filepath);
|
|
168
|
+
} else if (entry.type === "dir") {
|
|
169
|
+
await fetchAndWriteSubdir(parsed, sha, `${remotePath}/${entry.name}`, join(localDir, entry.name), installed, token);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
async function installGitSource(projectRoot, source, lockfile, options = {}) {
|
|
174
|
+
const parsed = parseGitSourceRef(source);
|
|
175
|
+
const sourceKey = gitSourceKey(parsed);
|
|
176
|
+
const installed = [];
|
|
177
|
+
const warnings = [];
|
|
178
|
+
let resolvedSha;
|
|
179
|
+
const locked = getLockedSource(lockfile, sourceKey);
|
|
180
|
+
if (options.frozen && !locked) {
|
|
181
|
+
throw new Error(`Frozen mode: no lockfile entry for source "${sourceKey}".`);
|
|
182
|
+
}
|
|
183
|
+
if (locked && !options.update) {
|
|
184
|
+
resolvedSha = locked.resolvedRef;
|
|
185
|
+
} else {
|
|
186
|
+
resolvedSha = await resolveGitRef(parsed, options.token);
|
|
187
|
+
}
|
|
188
|
+
const basePath = parsed.path || "packs";
|
|
189
|
+
const entries = await fetchGitDirectory(parsed, resolvedSha, basePath, options.token);
|
|
190
|
+
const curatedDir = resolve2(projectRoot, ".agentpacks", ".curated");
|
|
191
|
+
mkdirSync(curatedDir, { recursive: true });
|
|
192
|
+
const newLockEntry = {
|
|
193
|
+
requestedRef: parsed.ref,
|
|
194
|
+
resolvedRef: resolvedSha,
|
|
195
|
+
resolvedAt: new Date().toISOString(),
|
|
196
|
+
skills: {},
|
|
197
|
+
packs: {}
|
|
198
|
+
};
|
|
199
|
+
const packDirs = entries.filter((e) => e.type === "dir");
|
|
200
|
+
for (const packEntry of packDirs) {
|
|
201
|
+
const packName = packEntry.name;
|
|
202
|
+
const packOutDir = resolve2(curatedDir, packName);
|
|
203
|
+
const packFiles = await fetchGitDirectory(parsed, resolvedSha, `${basePath}/${packName}`, options.token);
|
|
204
|
+
mkdirSync(packOutDir, { recursive: true });
|
|
205
|
+
for (const file of packFiles) {
|
|
206
|
+
if (file.type === "file" && file.download_url) {
|
|
207
|
+
const content = await fetchGitFile(file.download_url, options.token);
|
|
208
|
+
writeFileSync2(join(packOutDir, file.name), content);
|
|
209
|
+
installed.push(join(packOutDir, file.name));
|
|
210
|
+
if (newLockEntry.packs) {
|
|
211
|
+
newLockEntry.packs[packName] = {
|
|
212
|
+
integrity: computeIntegrity(content)
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
} else if (file.type === "dir") {
|
|
216
|
+
await fetchAndWriteSubdir(parsed, resolvedSha, `${basePath}/${packName}/${file.name}`, join(packOutDir, file.name), installed, options.token);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (packDirs.length === 0) {
|
|
221
|
+
const fileEntries = entries.filter((e) => e.type === "file");
|
|
222
|
+
if (fileEntries.length > 0) {
|
|
223
|
+
const packName = parsed.path.split("/").pop() ?? parsed.repo;
|
|
224
|
+
const packOutDir = resolve2(curatedDir, packName);
|
|
225
|
+
mkdirSync(packOutDir, { recursive: true });
|
|
226
|
+
for (const file of entries) {
|
|
227
|
+
if (file.type === "file" && file.download_url) {
|
|
228
|
+
const content = await fetchGitFile(file.download_url, options.token);
|
|
229
|
+
writeFileSync2(join(packOutDir, file.name), content);
|
|
230
|
+
installed.push(join(packOutDir, file.name));
|
|
231
|
+
} else if (file.type === "dir") {
|
|
232
|
+
await fetchAndWriteSubdir(parsed, resolvedSha, `${basePath}/${file.name}`, join(packOutDir, file.name), installed, options.token);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
setLockedSource(lockfile, sourceKey, newLockEntry);
|
|
238
|
+
return { installed, warnings };
|
|
239
|
+
}
|
|
240
|
+
export {
|
|
241
|
+
resolveGitRef,
|
|
242
|
+
installGitSource,
|
|
243
|
+
fetchGitFile,
|
|
244
|
+
fetchGitDirectory
|
|
245
|
+
};
|