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.
- package/dist/api.js +48 -3658
- package/dist/cli/export-cmd.js +7 -1027
- package/dist/cli/generate.js +39 -2731
- package/dist/cli/import-cmd.js +19 -770
- package/dist/cli/info.js +4 -231
- package/dist/cli/init.js +9 -185
- package/dist/cli/install.js +4 -902
- package/dist/cli/login.js +6 -201
- package/dist/cli/models-explain.js +14 -1266
- package/dist/cli/pack/create.js +4 -146
- package/dist/cli/pack/enable.js +2 -65
- package/dist/cli/pack/list.js +5 -893
- package/dist/cli/pack/validate.js +4 -642
- package/dist/cli/publish.js +8 -679
- package/dist/cli/search.js +4 -209
- package/dist/core/config.d.ts +1 -1
- package/dist/core/config.js +1 -145
- package/dist/core/dependency-resolver.js +1 -126
- package/dist/core/feature-merger.js +3 -398
- package/dist/core/index.js +5 -1129
- package/dist/core/lockfile.js +2 -43
- package/dist/core/metarepo.js +1 -183
- package/dist/core/pack-loader.js +4 -841
- package/dist/core/profile-resolver.js +1 -110
- package/dist/exporters/cursor-plugin.js +6 -404
- package/dist/exporters/index.js +6 -404
- package/dist/features/agents.js +3 -161
- package/dist/features/commands.js +3 -161
- package/dist/features/hooks.js +3 -153
- package/dist/features/ignore.js +2 -43
- package/dist/features/index.js +4 -629
- package/dist/features/mcp.js +3 -143
- package/dist/features/models.js +3 -292
- package/dist/features/plugins.js +3 -139
- package/dist/features/rules.d.ts +0 -1
- package/dist/features/rules.js +3 -169
- package/dist/features/skills.js +3 -228
- package/dist/importers/claude-code.js +6 -195
- package/dist/importers/cursor.js +5 -355
- package/dist/importers/opencode.js +6 -346
- package/dist/importers/rulesync.js +5 -365
- package/dist/index.js +89 -4934
- package/dist/node/api.js +48 -3659
- package/dist/node/cli/export-cmd.js +7 -1028
- package/dist/node/cli/generate.js +39 -2732
- package/dist/node/cli/import-cmd.js +19 -771
- package/dist/node/cli/info.js +4 -232
- package/dist/node/cli/init.js +9 -186
- package/dist/node/cli/install.js +4 -903
- package/dist/node/cli/login.js +6 -202
- package/dist/node/cli/models-explain.js +14 -1267
- package/dist/node/cli/pack/create.js +4 -147
- package/dist/node/cli/pack/enable.js +2 -66
- package/dist/node/cli/pack/list.js +5 -894
- package/dist/node/cli/pack/validate.js +4 -643
- package/dist/node/cli/publish.js +8 -680
- package/dist/node/cli/search.js +4 -210
- package/dist/node/core/config.js +1 -146
- package/dist/node/core/dependency-resolver.js +1 -127
- package/dist/node/core/feature-merger.js +3 -399
- package/dist/node/core/index.js +5 -1130
- package/dist/node/core/lockfile.js +2 -44
- package/dist/node/core/metarepo.js +1 -184
- package/dist/node/core/pack-loader.js +4 -842
- package/dist/node/core/profile-resolver.js +1 -111
- package/dist/node/exporters/cursor-plugin.js +6 -405
- package/dist/node/exporters/index.js +6 -405
- package/dist/node/features/agents.js +3 -162
- package/dist/node/features/commands.js +3 -162
- package/dist/node/features/hooks.js +3 -154
- package/dist/node/features/ignore.js +2 -44
- package/dist/node/features/index.js +4 -630
- package/dist/node/features/mcp.js +3 -144
- package/dist/node/features/models.js +3 -293
- package/dist/node/features/plugins.js +3 -140
- package/dist/node/features/rules.js +3 -170
- package/dist/node/features/skills.js +3 -229
- package/dist/node/importers/claude-code.js +6 -196
- package/dist/node/importers/cursor.js +5 -356
- package/dist/node/importers/opencode.js +6 -347
- package/dist/node/importers/rulesync.js +5 -366
- package/dist/node/index.js +89 -4935
- package/dist/node/sources/git-ref.js +1 -56
- package/dist/node/sources/git.js +2 -222
- package/dist/node/sources/index.js +4 -714
- package/dist/node/sources/local.js +1 -24
- package/dist/node/sources/npm-ref.js +1 -56
- package/dist/node/sources/npm.js +2 -184
- package/dist/node/sources/registry-ref.js +1 -37
- package/dist/node/sources/registry.js +4 -355
- package/dist/node/targets/additional-targets.js +6 -587
- package/dist/node/targets/base-target.js +1 -23
- package/dist/node/targets/claude-code.js +6 -714
- package/dist/node/targets/codex-cli.js +3 -324
- package/dist/node/targets/copilot.js +5 -603
- package/dist/node/targets/cursor.js +6 -700
- package/dist/node/targets/gemini-cli.js +10 -319
- package/dist/node/targets/generic-md-target.js +6 -478
- package/dist/node/targets/index.js +32 -1873
- package/dist/node/targets/mistral-vibe.js +7 -661
- package/dist/node/targets/opencode.js +13 -723
- package/dist/node/targets/registry.js +32 -1864
- package/dist/node/utils/credentials.js +3 -38
- package/dist/node/utils/diff.js +5 -132
- package/dist/node/utils/filesystem.js +3 -124
- package/dist/node/utils/frontmatter.js +1 -24
- package/dist/node/utils/global.js +1 -53
- package/dist/node/utils/markdown.js +3 -30
- package/dist/node/utils/model-allowlist.js +1 -126
- package/dist/node/utils/model-guidance.js +2 -78
- package/dist/node/utils/registry-client.js +1 -142
- package/dist/node/utils/tarball.js +1 -49
- package/dist/sources/git-ref.js +1 -55
- package/dist/sources/git.js +2 -221
- package/dist/sources/index.js +4 -713
- package/dist/sources/local.js +1 -23
- package/dist/sources/npm-ref.js +1 -55
- package/dist/sources/npm.js +2 -183
- package/dist/sources/registry-ref.js +1 -36
- package/dist/sources/registry.js +4 -354
- package/dist/targets/additional-targets.js +6 -586
- package/dist/targets/base-target.js +1 -22
- package/dist/targets/claude-code.js +6 -713
- package/dist/targets/codex-cli.js +3 -323
- package/dist/targets/copilot.js +5 -602
- package/dist/targets/cursor.js +6 -699
- package/dist/targets/gemini-cli.js +10 -318
- package/dist/targets/generic-md-target.js +6 -477
- package/dist/targets/index.d.ts +0 -1
- package/dist/targets/index.js +32 -1872
- package/dist/targets/mistral-vibe.js +7 -660
- package/dist/targets/opencode.js +13 -722
- package/dist/targets/registry.js +32 -1863
- package/dist/utils/credentials.js +3 -37
- package/dist/utils/diff.js +5 -131
- package/dist/utils/filesystem.js +3 -123
- package/dist/utils/frontmatter.js +1 -23
- package/dist/utils/global.js +1 -52
- package/dist/utils/markdown.js +3 -29
- package/dist/utils/model-allowlist.js +1 -125
- package/dist/utils/model-guidance.js +2 -77
- package/dist/utils/registry-client.js +1 -141
- package/dist/utils/tarball.js +1 -48
- package/package.json +4 -16
- package/dist/node/targets/agents-md.js +0 -211
- package/dist/targets/agents-md.d.ts +0 -13
- package/dist/targets/agents-md.js +0 -211
|
@@ -1,162 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// src/utils/filesystem.ts
|
|
5
|
-
import {
|
|
6
|
-
existsSync,
|
|
7
|
-
mkdirSync,
|
|
8
|
-
readdirSync,
|
|
9
|
-
readFileSync,
|
|
10
|
-
rmSync,
|
|
11
|
-
statSync,
|
|
12
|
-
writeFileSync
|
|
13
|
-
} from "fs";
|
|
14
|
-
import { dirname, join, relative } from "path";
|
|
15
|
-
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
16
|
-
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
17
|
-
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
18
|
-
function writeGeneratedFile(filepath, content, options = {}) {
|
|
19
|
-
const { header = true, type } = options;
|
|
20
|
-
const ext = type ?? inferFileType(filepath);
|
|
21
|
-
ensureDir(dirname(filepath));
|
|
22
|
-
let output = content;
|
|
23
|
-
if (header) {
|
|
24
|
-
const headerComment = getHeader(ext);
|
|
25
|
-
if (headerComment) {
|
|
26
|
-
output = `${headerComment}
|
|
27
|
-
${content}`;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
writeFileSync(filepath, output, "utf-8");
|
|
31
|
-
}
|
|
32
|
-
function writeGeneratedJson(filepath, data, options = {}) {
|
|
33
|
-
const json = JSON.stringify(data, null, 2);
|
|
34
|
-
writeGeneratedFile(filepath, json + `
|
|
35
|
-
`, { ...options, type: "json" });
|
|
36
|
-
}
|
|
37
|
-
function readFileOrNull(filepath) {
|
|
38
|
-
if (!existsSync(filepath))
|
|
39
|
-
return null;
|
|
40
|
-
return readFileSync(filepath, "utf-8");
|
|
41
|
-
}
|
|
42
|
-
function readJsonOrNull(filepath) {
|
|
43
|
-
const content = readFileOrNull(filepath);
|
|
44
|
-
if (content === null)
|
|
45
|
-
return null;
|
|
46
|
-
return JSON.parse(content);
|
|
47
|
-
}
|
|
48
|
-
function ensureDir(dirPath) {
|
|
49
|
-
if (!existsSync(dirPath)) {
|
|
50
|
-
mkdirSync(dirPath, { recursive: true });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function removeIfExists(targetPath) {
|
|
54
|
-
if (existsSync(targetPath)) {
|
|
55
|
-
rmSync(targetPath, { recursive: true, force: true });
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function listFiles(dirPath, options = {}) {
|
|
59
|
-
const { extension, recursive = false } = options;
|
|
60
|
-
if (!existsSync(dirPath))
|
|
61
|
-
return [];
|
|
62
|
-
const results = [];
|
|
63
|
-
const entries = readdirSync(dirPath);
|
|
64
|
-
for (const entry of entries) {
|
|
65
|
-
const fullPath = join(dirPath, entry);
|
|
66
|
-
const stat = statSync(fullPath);
|
|
67
|
-
if (stat.isDirectory() && recursive) {
|
|
68
|
-
results.push(...listFiles(fullPath, options));
|
|
69
|
-
} else if (stat.isFile()) {
|
|
70
|
-
if (!extension || entry.endsWith(extension)) {
|
|
71
|
-
results.push(fullPath);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return results;
|
|
76
|
-
}
|
|
77
|
-
function listDirs(dirPath) {
|
|
78
|
-
if (!existsSync(dirPath))
|
|
79
|
-
return [];
|
|
80
|
-
return readdirSync(dirPath).map((entry) => join(dirPath, entry)).filter((fullPath) => statSync(fullPath).isDirectory());
|
|
81
|
-
}
|
|
82
|
-
function relPath(projectRoot, filepath) {
|
|
83
|
-
return relative(projectRoot, filepath);
|
|
84
|
-
}
|
|
85
|
-
function isGeneratedFile(filepath) {
|
|
86
|
-
const content = readFileOrNull(filepath);
|
|
87
|
-
if (!content)
|
|
88
|
-
return false;
|
|
89
|
-
return content.startsWith(GENERATED_HEADER_MD) || content.startsWith(GENERATED_HEADER_JSON) || content.startsWith(GENERATED_HEADER_JS);
|
|
90
|
-
}
|
|
91
|
-
function inferFileType(filepath) {
|
|
92
|
-
if (filepath.endsWith(".json") || filepath.endsWith(".jsonc"))
|
|
93
|
-
return "json";
|
|
94
|
-
if (filepath.endsWith(".ts") || filepath.endsWith(".mts"))
|
|
95
|
-
return "ts";
|
|
96
|
-
if (filepath.endsWith(".js") || filepath.endsWith(".mjs"))
|
|
97
|
-
return "js";
|
|
98
|
-
return "md";
|
|
99
|
-
}
|
|
100
|
-
function getHeader(type) {
|
|
101
|
-
switch (type) {
|
|
102
|
-
case "md":
|
|
103
|
-
return GENERATED_HEADER_MD;
|
|
104
|
-
case "json":
|
|
105
|
-
return GENERATED_HEADER_JSON;
|
|
106
|
-
case "js":
|
|
107
|
-
case "ts":
|
|
108
|
-
return GENERATED_HEADER_JS;
|
|
109
|
-
default:
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// src/utils/frontmatter.ts
|
|
115
|
-
import matter from "gray-matter";
|
|
116
|
-
function parseFrontmatter(source) {
|
|
117
|
-
const { data, content } = matter(source);
|
|
118
|
-
return {
|
|
119
|
-
data,
|
|
120
|
-
content: content.trim(),
|
|
121
|
-
raw: source
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
function serializeFrontmatter(data, content) {
|
|
125
|
-
const filtered = Object.fromEntries(Object.entries(data).filter(([, v]) => v !== undefined));
|
|
126
|
-
if (Object.keys(filtered).length === 0) {
|
|
127
|
-
return content;
|
|
128
|
-
}
|
|
129
|
-
return matter.stringify(content, filtered);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// src/features/commands.ts
|
|
133
|
-
import { readFileSync as readFileSync2 } from "fs";
|
|
134
|
-
import { basename } from "path";
|
|
135
|
-
function parseCommands(commandsDir, packName) {
|
|
136
|
-
const files = listFiles(commandsDir, { extension: ".md" });
|
|
137
|
-
return files.map((filepath) => parseCommandFile(filepath, packName));
|
|
138
|
-
}
|
|
139
|
-
function parseCommandFile(filepath, packName) {
|
|
140
|
-
const raw = readFileSync2(filepath, "utf-8");
|
|
141
|
-
const { data, content } = parseFrontmatter(raw);
|
|
142
|
-
return {
|
|
143
|
-
name: basename(filepath, ".md"),
|
|
144
|
-
sourcePath: filepath,
|
|
145
|
-
packName,
|
|
146
|
-
meta: data,
|
|
147
|
-
content
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
function commandMatchesTarget(cmd, targetId) {
|
|
151
|
-
const { targets } = cmd.meta;
|
|
152
|
-
if (!targets || targets === "*")
|
|
153
|
-
return true;
|
|
154
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
155
|
-
return true;
|
|
156
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
157
|
-
}
|
|
158
|
-
export {
|
|
159
|
-
parseCommands,
|
|
160
|
-
parseCommandFile,
|
|
161
|
-
commandMatchesTarget
|
|
162
|
-
};
|
|
1
|
+
import{createRequire as C}from"node:module";var u=C(import.meta.url);import{existsSync as W,mkdirSync as j,readdirSync as $,readFileSync as G,rmSync as H,statSync as z,writeFileSync as T}from"fs";import{dirname as x,join as I,relative as k}from"path";var M="<!-- Generated by agentpacks. DO NOT EDIT. -->",b="// Generated by agentpacks. DO NOT EDIT.",v="// Generated by agentpacks. DO NOT EDIT.";function F(q,B,K={}){let{header:L=!0,type:Q}=K,X=Q??_(q);A(x(q));let V=B;if(L){let U=N(X);if(U)V=`${U}
|
|
2
|
+
${B}`}T(q,V,"utf-8")}function E(q,B,K={}){let L=JSON.stringify(B,null,2);F(q,L+`
|
|
3
|
+
`,{...K,type:"json"})}function w(q){if(!W(q))return null;return G(q,"utf-8")}function c(q){let B=w(q);if(B===null)return null;return JSON.parse(B)}function A(q){if(!W(q))j(q,{recursive:!0})}function d(q){if(W(q))H(q,{recursive:!0,force:!0})}function Y(q,B={}){let{extension:K,recursive:L=!1}=B;if(!W(q))return[];let Q=[],X=$(q);for(let V of X){let U=I(q,V),Z=z(U);if(Z.isDirectory()&&L)Q.push(...Y(U,B));else if(Z.isFile()){if(!K||V.endsWith(K))Q.push(U)}}return Q}function f(q){if(!W(q))return[];return $(q).map((B)=>I(q,B)).filter((B)=>z(B).isDirectory())}function p(q,B){return k(q,B)}function s(q){let B=w(q);if(!B)return!1;return B.startsWith(M)||B.startsWith(b)||B.startsWith(v)}function _(q){if(q.endsWith(".json")||q.endsWith(".jsonc"))return"json";if(q.endsWith(".ts")||q.endsWith(".mts"))return"ts";if(q.endsWith(".js")||q.endsWith(".mjs"))return"js";return"md"}function N(q){switch(q){case"md":return M;case"json":return b;case"js":case"ts":return v;default:return null}}import J from"gray-matter";function O(q){let{data:B,content:K}=J(q);return{data:B,content:K.trim(),raw:q}}function l(q,B){let K=Object.fromEntries(Object.entries(q).filter(([,L])=>L!==void 0));if(Object.keys(K).length===0)return B;return J.stringify(B,K)}import{readFileSync as R}from"fs";import{basename as g}from"path";function t(q,B){return Y(q,{extension:".md"}).map((L)=>D(L,B))}function D(q,B){let K=R(q,"utf-8"),{data:L,content:Q}=O(K);return{name:g(q,".md"),sourcePath:q,packName:B,meta:L,content:Q}}function qq(q,B){let{targets:K}=q.meta;if(!K||K==="*")return!0;if(Array.isArray(K)&&K.includes("*"))return!0;return Array.isArray(K)&&K.includes(B)}export{t as parseCommands,D as parseCommandFile,qq as commandMatchesTarget};
|
|
@@ -1,154 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// src/utils/filesystem.ts
|
|
5
|
-
import {
|
|
6
|
-
existsSync,
|
|
7
|
-
mkdirSync,
|
|
8
|
-
readdirSync,
|
|
9
|
-
readFileSync,
|
|
10
|
-
rmSync,
|
|
11
|
-
statSync,
|
|
12
|
-
writeFileSync
|
|
13
|
-
} from "fs";
|
|
14
|
-
import { dirname, join, relative } from "path";
|
|
15
|
-
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
16
|
-
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
17
|
-
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
18
|
-
function writeGeneratedFile(filepath, content, options = {}) {
|
|
19
|
-
const { header = true, type } = options;
|
|
20
|
-
const ext = type ?? inferFileType(filepath);
|
|
21
|
-
ensureDir(dirname(filepath));
|
|
22
|
-
let output = content;
|
|
23
|
-
if (header) {
|
|
24
|
-
const headerComment = getHeader(ext);
|
|
25
|
-
if (headerComment) {
|
|
26
|
-
output = `${headerComment}
|
|
27
|
-
${content}`;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
writeFileSync(filepath, output, "utf-8");
|
|
31
|
-
}
|
|
32
|
-
function writeGeneratedJson(filepath, data, options = {}) {
|
|
33
|
-
const json = JSON.stringify(data, null, 2);
|
|
34
|
-
writeGeneratedFile(filepath, json + `
|
|
35
|
-
`, { ...options, type: "json" });
|
|
36
|
-
}
|
|
37
|
-
function readFileOrNull(filepath) {
|
|
38
|
-
if (!existsSync(filepath))
|
|
39
|
-
return null;
|
|
40
|
-
return readFileSync(filepath, "utf-8");
|
|
41
|
-
}
|
|
42
|
-
function readJsonOrNull(filepath) {
|
|
43
|
-
const content = readFileOrNull(filepath);
|
|
44
|
-
if (content === null)
|
|
45
|
-
return null;
|
|
46
|
-
return JSON.parse(content);
|
|
47
|
-
}
|
|
48
|
-
function ensureDir(dirPath) {
|
|
49
|
-
if (!existsSync(dirPath)) {
|
|
50
|
-
mkdirSync(dirPath, { recursive: true });
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function removeIfExists(targetPath) {
|
|
54
|
-
if (existsSync(targetPath)) {
|
|
55
|
-
rmSync(targetPath, { recursive: true, force: true });
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function listFiles(dirPath, options = {}) {
|
|
59
|
-
const { extension, recursive = false } = options;
|
|
60
|
-
if (!existsSync(dirPath))
|
|
61
|
-
return [];
|
|
62
|
-
const results = [];
|
|
63
|
-
const entries = readdirSync(dirPath);
|
|
64
|
-
for (const entry of entries) {
|
|
65
|
-
const fullPath = join(dirPath, entry);
|
|
66
|
-
const stat = statSync(fullPath);
|
|
67
|
-
if (stat.isDirectory() && recursive) {
|
|
68
|
-
results.push(...listFiles(fullPath, options));
|
|
69
|
-
} else if (stat.isFile()) {
|
|
70
|
-
if (!extension || entry.endsWith(extension)) {
|
|
71
|
-
results.push(fullPath);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
return results;
|
|
76
|
-
}
|
|
77
|
-
function listDirs(dirPath) {
|
|
78
|
-
if (!existsSync(dirPath))
|
|
79
|
-
return [];
|
|
80
|
-
return readdirSync(dirPath).map((entry) => join(dirPath, entry)).filter((fullPath) => statSync(fullPath).isDirectory());
|
|
81
|
-
}
|
|
82
|
-
function relPath(projectRoot, filepath) {
|
|
83
|
-
return relative(projectRoot, filepath);
|
|
84
|
-
}
|
|
85
|
-
function isGeneratedFile(filepath) {
|
|
86
|
-
const content = readFileOrNull(filepath);
|
|
87
|
-
if (!content)
|
|
88
|
-
return false;
|
|
89
|
-
return content.startsWith(GENERATED_HEADER_MD) || content.startsWith(GENERATED_HEADER_JSON) || content.startsWith(GENERATED_HEADER_JS);
|
|
90
|
-
}
|
|
91
|
-
function inferFileType(filepath) {
|
|
92
|
-
if (filepath.endsWith(".json") || filepath.endsWith(".jsonc"))
|
|
93
|
-
return "json";
|
|
94
|
-
if (filepath.endsWith(".ts") || filepath.endsWith(".mts"))
|
|
95
|
-
return "ts";
|
|
96
|
-
if (filepath.endsWith(".js") || filepath.endsWith(".mjs"))
|
|
97
|
-
return "js";
|
|
98
|
-
return "md";
|
|
99
|
-
}
|
|
100
|
-
function getHeader(type) {
|
|
101
|
-
switch (type) {
|
|
102
|
-
case "md":
|
|
103
|
-
return GENERATED_HEADER_MD;
|
|
104
|
-
case "json":
|
|
105
|
-
return GENERATED_HEADER_JSON;
|
|
106
|
-
case "js":
|
|
107
|
-
case "ts":
|
|
108
|
-
return GENERATED_HEADER_JS;
|
|
109
|
-
default:
|
|
110
|
-
return null;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// src/features/hooks.ts
|
|
115
|
-
import { join as join2 } from "path";
|
|
116
|
-
var TARGET_OVERRIDE_KEYS = ["cursor", "claudecode", "opencode"];
|
|
117
|
-
function parseHooks(packDir, packName) {
|
|
118
|
-
const hooksPath = join2(packDir, "hooks", "hooks.json");
|
|
119
|
-
const raw = readJsonOrNull(hooksPath);
|
|
120
|
-
if (!raw)
|
|
121
|
-
return null;
|
|
122
|
-
const shared = raw.hooks ?? {};
|
|
123
|
-
const targetOverrides = {};
|
|
124
|
-
for (const key of TARGET_OVERRIDE_KEYS) {
|
|
125
|
-
const override = raw[key];
|
|
126
|
-
if (override && typeof override === "object" && "hooks" in override && override.hooks) {
|
|
127
|
-
targetOverrides[key] = override.hooks;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return {
|
|
131
|
-
packName,
|
|
132
|
-
sourcePath: hooksPath,
|
|
133
|
-
version: raw.version,
|
|
134
|
-
shared,
|
|
135
|
-
targetOverrides
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
function resolveHooksForTarget(hooks, targetId) {
|
|
139
|
-
const merged = {};
|
|
140
|
-
for (const [event, entries] of Object.entries(hooks.shared)) {
|
|
141
|
-
merged[event] = [...entries];
|
|
142
|
-
}
|
|
143
|
-
const overrides = hooks.targetOverrides[targetId];
|
|
144
|
-
if (overrides) {
|
|
145
|
-
for (const [event, entries] of Object.entries(overrides)) {
|
|
146
|
-
merged[event] = [...merged[event] ?? [], ...entries];
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return merged;
|
|
150
|
-
}
|
|
151
|
-
export {
|
|
152
|
-
resolveHooksForTarget,
|
|
153
|
-
parseHooks
|
|
154
|
-
};
|
|
1
|
+
import{createRequire as w}from"node:module";var R=w(import.meta.url);import{existsSync as Z,mkdirSync as j,readdirSync as b,readFileSync as F,rmSync as H,statSync as K,writeFileSync as x}from"fs";import{dirname as G,join as V,relative as O}from"path";var Y="<!-- Generated by agentpacks. DO NOT EDIT. -->",C="// Generated by agentpacks. DO NOT EDIT.",I="// Generated by agentpacks. DO NOT EDIT.";function T(q,z,B={}){let{header:L=!0,type:Q}=B,W=Q??m(q);A(G(q));let X=z;if(L){let U=_(W);if(U)X=`${U}
|
|
2
|
+
${z}`}x(q,X,"utf-8")}function y(q,z,B={}){let L=JSON.stringify(z,null,2);T(q,L+`
|
|
3
|
+
`,{...B,type:"json"})}function M(q){if(!Z(q))return null;return F(q,"utf-8")}function J(q){let z=M(q);if(z===null)return null;return JSON.parse(z)}function A(q){if(!Z(q))j(q,{recursive:!0})}function P(q){if(Z(q))H(q,{recursive:!0,force:!0})}function N(q,z={}){let{extension:B,recursive:L=!1}=z;if(!Z(q))return[];let Q=[],W=b(q);for(let X of W){let U=V(q,X),$=K(U);if($.isDirectory()&&L)Q.push(...N(U,z));else if($.isFile()){if(!B||X.endsWith(B))Q.push(U)}}return Q}function c(q){if(!Z(q))return[];return b(q).map((z)=>V(q,z)).filter((z)=>K(z).isDirectory())}function E(q,z){return O(q,z)}function f(q){let z=M(q);if(!z)return!1;return z.startsWith(Y)||z.startsWith(C)||z.startsWith(I)}function m(q){if(q.endsWith(".json")||q.endsWith(".jsonc"))return"json";if(q.endsWith(".ts")||q.endsWith(".mts"))return"ts";if(q.endsWith(".js")||q.endsWith(".mjs"))return"js";return"md"}function _(q){switch(q){case"md":return Y;case"json":return C;case"js":case"ts":return I;default:return null}}import{join as k}from"path";var v=["cursor","claudecode","codexcli","opencode"];function l(q,z){let B=k(q,"hooks","hooks.json"),L=J(B);if(!L)return null;let Q=L.hooks??{},W={};for(let X of v){let U=L[X];if(U&&typeof U==="object"&&"hooks"in U&&U.hooks)W[X]=U.hooks}return{packName:z,sourcePath:B,version:L.version,shared:Q,targetOverrides:W}}function o(q,z){let B={};for(let[Q,W]of Object.entries(q.shared))B[Q]=[...W];let L=q.targetOverrides[z];if(L)for(let[Q,W]of Object.entries(L))B[Q]=[...B[Q]??[],...W];return B}export{o as resolveHooksForTarget,l as parseHooks};
|
|
@@ -1,44 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
// src/features/ignore.ts
|
|
5
|
-
import { existsSync, readFileSync } from "fs";
|
|
6
|
-
import { join } from "path";
|
|
7
|
-
var IGNORE_FILES = ["ignore", ".aiignore"];
|
|
8
|
-
function parseIgnore(packDir, packName) {
|
|
9
|
-
for (const filename of IGNORE_FILES) {
|
|
10
|
-
const filepath = join(packDir, filename);
|
|
11
|
-
if (existsSync(filepath)) {
|
|
12
|
-
const raw = readFileSync(filepath, "utf-8");
|
|
13
|
-
const patterns = parseIgnoreContent(raw);
|
|
14
|
-
return {
|
|
15
|
-
packName,
|
|
16
|
-
sourcePath: filepath,
|
|
17
|
-
patterns
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
function parseIgnoreContent(content) {
|
|
24
|
-
return content.split(`
|
|
25
|
-
`).map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#"));
|
|
26
|
-
}
|
|
27
|
-
function mergeIgnorePatterns(configs) {
|
|
28
|
-
const seen = new Set;
|
|
29
|
-
const result = [];
|
|
30
|
-
for (const config of configs) {
|
|
31
|
-
for (const pattern of config.patterns) {
|
|
32
|
-
if (!seen.has(pattern)) {
|
|
33
|
-
seen.add(pattern);
|
|
34
|
-
result.push(pattern);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return result;
|
|
39
|
-
}
|
|
40
|
-
export {
|
|
41
|
-
parseIgnoreContent,
|
|
42
|
-
parseIgnore,
|
|
43
|
-
mergeIgnorePatterns
|
|
44
|
-
};
|
|
1
|
+
import{createRequire as P}from"node:module";var Y=P(import.meta.url);import{existsSync as Q,readFileSync as T}from"fs";import{join as U}from"path";var V=["ignore",".aiignore"];function j(z,q){for(let J of V){let B=U(z,J);if(Q(B)){let H=T(B,"utf-8"),K=W(H);return{packName:q,sourcePath:B,patterns:K}}}return null}function W(z){return z.split(`
|
|
2
|
+
`).map((q)=>q.trim()).filter((q)=>q.length>0&&!q.startsWith("#"))}function v(z){let q=new Set,J=[];for(let B of z)for(let H of B.patterns)if(!q.has(H))q.add(H),J.push(H);return J}export{W as parseIgnoreContent,j as parseIgnore,v as mergeIgnorePatterns};
|