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,324 +1,16 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
2
|
+
var Vq=import.meta.require;import{existsSync as H,mkdirSync as d,readdirSync as T,readFileSync as h,rmSync as p,statSync as G,writeFileSync as f}from"fs";import{dirname as o,join as N,relative as n}from"path";var v="<!-- Generated by agentpacks. DO NOT EDIT. -->",F="// Generated by agentpacks. DO NOT EDIT.",S="// Generated by agentpacks. DO NOT EDIT.";function M(q,K,Q={}){let{header:U=!0,type:X}=Q,C=X??l(q);b(o(q));let z=K;if(U){let Y=s(C);if(Y)z=`${Y}
|
|
3
|
+
${K}`}f(q,z,"utf-8")}function P(q,K,Q={}){let U=JSON.stringify(K,null,2);M(q,U+`
|
|
4
|
+
`,{...Q,type:"json"})}function R(q){if(!H(q))return null;return h(q,"utf-8")}function $q(q){let K=R(q);if(K===null)return null;return JSON.parse(K)}function b(q){if(!H(q))d(q,{recursive:!0})}function A(q){if(H(q))p(q,{recursive:!0,force:!0})}function W(q,K={}){let{extension:Q,recursive:U=!1}=K;if(!H(q))return[];let X=[],C=T(q);for(let z of C){let Y=N(q,z),B=G(Y);if(B.isDirectory()&&U)X.push(...W(Y,K));else if(B.isFile()){if(!Q||z.endsWith(Q))X.push(Y)}}return X}function zq(q){if(!H(q))return[];return T(q).map((K)=>N(q,K)).filter((K)=>G(K).isDirectory())}function Bq(q,K){return n(q,K)}function Lq(q){let K=R(q);if(!K)return!1;return K.startsWith(v)||K.startsWith(F)||K.startsWith(S)}function l(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 s(q){switch(q){case"md":return v;case"json":return F;case"js":case"ts":return S;default:return null}}import y from"gray-matter";function x(q){let{data:K,content:Q}=y(q);return{data:K,content:Q.trim(),raw:q}}function Cq(q,K){let Q=Object.fromEntries(Object.entries(q).filter(([,U])=>U!==void 0));if(Object.keys(Q).length===0)return K;return y.stringify(K,Q)}import{readFileSync as i}from"fs";import{basename as r}from"path";function xq(q,K){return W(q,{extension:".md"}).map((U)=>a(U,K))}function a(q,K){let Q=i(q,"utf-8"),{data:U,content:X}=x(Q);return{name:r(q,".md"),sourcePath:q,packName:K,meta:U,content:X}}function E(q,K){let{targets:Q}=q.meta;if(!Q||Q==="*")return!0;if(Array.isArray(Q)&&Q.includes("*"))return!0;return Array.isArray(Q)&&Q.includes(K)}import{readFileSync as t}from"fs";import{basename as e}from"path";function Tq(q,K){return W(q,{extension:".md"}).map((U)=>qq(U,K))}function qq(q,K){let Q=t(q,"utf-8"),{data:U,content:X}=x(Q);return{name:e(q,".md"),sourcePath:q,packName:K,meta:U,content:X}}function g(q,K){let{targets:Q}=q.meta;if(!Q||Q==="*")return!0;if(Array.isArray(Q)&&Q.includes("*"))return!0;return Array.isArray(Q)&&Q.includes(K)}function D(q){return q.filter((K)=>K.meta.root===!0)}function u(q){return q.filter((K)=>K.meta.root!==!0)}class _{supportsFeature(q){return this.supportedFeatures.includes(q)}getEffectiveFeatures(q){return q.filter((K)=>this.supportsFeature(K))}createResult(q=[],K=[],Q=[]){return{targetId:this.id,filesWritten:q,filesDeleted:K,warnings:Q}}}import{join as m,resolve as O}from"path";var j="geminicli";class Kq extends _{id=j;name="Gemini CLI";supportedFeatures=["rules","commands","mcp","ignore","skills","hooks"];generate(q){let{projectRoot:K,baseDir:Q,features:U,enabledFeatures:X,deleteExisting:C}=q,z=O(K,Q),Y=this.getEffectiveFeatures(X),B=[],w=[],c=[],k=O(z,".gemini");if(Y.includes("rules")){let Z=U.rules.filter(($)=>g($,j)),L=D(Z),V=u(Z);if(L.length>0){let $=L.map((I)=>I.content).join(`
|
|
3
5
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
159
|
-
// src/features/rules.ts
|
|
160
|
-
import { readFileSync as readFileSync3 } from "fs";
|
|
161
|
-
import { basename as basename2 } from "path";
|
|
162
|
-
function parseRules(rulesDir, packName) {
|
|
163
|
-
const files = listFiles(rulesDir, { extension: ".md" });
|
|
164
|
-
return files.map((filepath) => parseRuleFile(filepath, packName));
|
|
165
|
-
}
|
|
166
|
-
function parseRuleFile(filepath, packName) {
|
|
167
|
-
const raw = readFileSync3(filepath, "utf-8");
|
|
168
|
-
const { data, content } = parseFrontmatter(raw);
|
|
169
|
-
return {
|
|
170
|
-
name: basename2(filepath, ".md"),
|
|
171
|
-
sourcePath: filepath,
|
|
172
|
-
packName,
|
|
173
|
-
meta: data,
|
|
174
|
-
content
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
function ruleMatchesTarget(rule, targetId) {
|
|
178
|
-
const { targets } = rule.meta;
|
|
179
|
-
if (!targets || targets === "*")
|
|
180
|
-
return true;
|
|
181
|
-
if (Array.isArray(targets) && targets.includes("*"))
|
|
182
|
-
return true;
|
|
183
|
-
return Array.isArray(targets) && targets.includes(targetId);
|
|
184
|
-
}
|
|
185
|
-
function getRootRules(rules) {
|
|
186
|
-
return rules.filter((r) => r.meta.root === true);
|
|
187
|
-
}
|
|
188
|
-
function getDetailRules(rules) {
|
|
189
|
-
return rules.filter((r) => r.meta.root !== true);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// src/targets/base-target.ts
|
|
193
|
-
class BaseTarget {
|
|
194
|
-
supportsFeature(feature) {
|
|
195
|
-
return this.supportedFeatures.includes(feature);
|
|
196
|
-
}
|
|
197
|
-
getEffectiveFeatures(enabledFeatures) {
|
|
198
|
-
return enabledFeatures.filter((f) => this.supportsFeature(f));
|
|
199
|
-
}
|
|
200
|
-
createResult(filesWritten = [], filesDeleted = [], warnings = []) {
|
|
201
|
-
return {
|
|
202
|
-
targetId: this.id,
|
|
203
|
-
filesWritten,
|
|
204
|
-
filesDeleted,
|
|
205
|
-
warnings
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// src/targets/gemini-cli.ts
|
|
211
|
-
import { join as join2, resolve } from "path";
|
|
212
|
-
var TARGET_ID = "geminicli";
|
|
213
|
-
|
|
214
|
-
class GeminiCliTarget extends BaseTarget {
|
|
215
|
-
id = TARGET_ID;
|
|
216
|
-
name = "Gemini CLI";
|
|
217
|
-
supportedFeatures = [
|
|
218
|
-
"rules",
|
|
219
|
-
"commands",
|
|
220
|
-
"mcp",
|
|
221
|
-
"ignore",
|
|
222
|
-
"skills",
|
|
223
|
-
"hooks"
|
|
224
|
-
];
|
|
225
|
-
generate(options) {
|
|
226
|
-
const { projectRoot, baseDir, features, enabledFeatures, deleteExisting } = options;
|
|
227
|
-
const root = resolve(projectRoot, baseDir);
|
|
228
|
-
const effective = this.getEffectiveFeatures(enabledFeatures);
|
|
229
|
-
const filesWritten = [];
|
|
230
|
-
const filesDeleted = [];
|
|
231
|
-
const warnings = [];
|
|
232
|
-
const geminiDir = resolve(root, ".gemini");
|
|
233
|
-
if (effective.includes("rules")) {
|
|
234
|
-
const rules = features.rules.filter((r) => ruleMatchesTarget(r, TARGET_ID));
|
|
235
|
-
const rootRules = getRootRules(rules);
|
|
236
|
-
const detailRules = getDetailRules(rules);
|
|
237
|
-
if (rootRules.length > 0) {
|
|
238
|
-
const geminiMd = rootRules.map((r) => r.content).join(`
|
|
239
|
-
|
|
240
|
-
`);
|
|
241
|
-
const filepath = resolve(root, "GEMINI.md");
|
|
242
|
-
writeGeneratedFile(filepath, geminiMd);
|
|
243
|
-
filesWritten.push(filepath);
|
|
244
|
-
}
|
|
245
|
-
if (detailRules.length > 0) {
|
|
246
|
-
const memoriesDir = resolve(geminiDir, "memories");
|
|
247
|
-
if (deleteExisting) {
|
|
248
|
-
removeIfExists(memoriesDir);
|
|
249
|
-
filesDeleted.push(memoriesDir);
|
|
250
|
-
}
|
|
251
|
-
ensureDir(memoriesDir);
|
|
252
|
-
for (const rule of detailRules) {
|
|
253
|
-
const filepath = join2(memoriesDir, `${rule.name}.md`);
|
|
254
|
-
writeGeneratedFile(filepath, rule.content);
|
|
255
|
-
filesWritten.push(filepath);
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
if (effective.includes("commands")) {
|
|
260
|
-
const commandsDir = resolve(geminiDir, "commands");
|
|
261
|
-
if (deleteExisting) {
|
|
262
|
-
removeIfExists(commandsDir);
|
|
263
|
-
filesDeleted.push(commandsDir);
|
|
264
|
-
}
|
|
265
|
-
ensureDir(commandsDir);
|
|
266
|
-
const commands = features.commands.filter((c) => commandMatchesTarget(c, TARGET_ID));
|
|
267
|
-
for (const cmd of commands) {
|
|
268
|
-
const toml = buildGeminiCommand(cmd.name, cmd.meta.description ?? "", cmd.content);
|
|
269
|
-
const filepath = join2(commandsDir, `${cmd.name}.toml`);
|
|
270
|
-
writeGeneratedFile(filepath, toml, { type: "md" });
|
|
271
|
-
filesWritten.push(filepath);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
if (effective.includes("mcp")) {
|
|
275
|
-
const mcpEntries = Object.entries(features.mcpServers);
|
|
276
|
-
if (mcpEntries.length > 0) {
|
|
277
|
-
const settings = buildGeminiSettings(features.mcpServers);
|
|
278
|
-
const filepath = resolve(geminiDir, "settings.json");
|
|
279
|
-
writeGeneratedJson(filepath, settings, { header: false });
|
|
280
|
-
filesWritten.push(filepath);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
if (effective.includes("ignore")) {
|
|
284
|
-
if (features.ignorePatterns.length > 0) {
|
|
285
|
-
const filepath = resolve(root, ".geminiignore");
|
|
286
|
-
const content = features.ignorePatterns.join(`
|
|
287
|
-
`) + `
|
|
288
|
-
`;
|
|
289
|
-
writeGeneratedFile(filepath, content);
|
|
290
|
-
filesWritten.push(filepath);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
return this.createResult(filesWritten, filesDeleted, warnings);
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
function buildGeminiCommand(name, description, content) {
|
|
297
|
-
return `[command]
|
|
298
|
-
name = "${name}"
|
|
299
|
-
description = "${description}"
|
|
6
|
+
`),J=O(z,"GEMINI.md");M(J,$),B.push(J)}if(V.length>0){let $=O(k,"memories");if(C)A($),w.push($);b($);for(let J of V){let I=m($,`${J.name}.md`);M(I,J.content),B.push(I)}}}if(Y.includes("commands")){let Z=O(k,"commands");if(C)A(Z),w.push(Z);b(Z);let L=U.commands.filter((V)=>E(V,j));for(let V of L){let $=Qq(V.name,V.meta.description??"",V.content),J=m(Z,`${V.name}.toml`);M(J,$,{type:"md"}),B.push(J)}}if(Y.includes("mcp")){if(Object.entries(U.mcpServers).length>0){let L=Uq(U.mcpServers),V=O(k,"settings.json");P(V,L,{header:!1}),B.push(V)}}if(Y.includes("ignore")){if(U.ignorePatterns.length>0){let Z=O(z,".geminiignore"),L=U.ignorePatterns.join(`
|
|
7
|
+
`)+`
|
|
8
|
+
`;M(Z,L),B.push(Z)}}return this.createResult(B,w,c)}}function Qq(q,K,Q){return`[command]
|
|
9
|
+
name = "${q}"
|
|
10
|
+
description = "${K}"
|
|
300
11
|
|
|
301
12
|
[prompt]
|
|
302
13
|
content = """
|
|
303
|
-
${
|
|
14
|
+
${Q}
|
|
304
15
|
"""
|
|
305
|
-
|
|
306
|
-
}
|
|
307
|
-
function buildGeminiSettings(servers) {
|
|
308
|
-
const mcpServers = {};
|
|
309
|
-
for (const [name, entry] of Object.entries(servers)) {
|
|
310
|
-
if (entry.command) {
|
|
311
|
-
mcpServers[name] = {
|
|
312
|
-
command: entry.command,
|
|
313
|
-
...entry.args ? { args: entry.args } : {},
|
|
314
|
-
...entry.env ? { env: entry.env } : {}
|
|
315
|
-
};
|
|
316
|
-
} else if (entry.url) {
|
|
317
|
-
mcpServers[name] = { url: entry.url };
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
return { mcpServers };
|
|
321
|
-
}
|
|
322
|
-
export {
|
|
323
|
-
GeminiCliTarget
|
|
324
|
-
};
|
|
16
|
+
`}function Uq(q){let K={};for(let[Q,U]of Object.entries(q))if(U.command)K[Q]={command:U.command,...U.args?{args:U.args}:{},...U.env?{env:U.env}:{}};else if(U.url)K[Q]={url:U.url};return{mcpServers:K}}export{Kq as GeminiCliTarget};
|