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
|
@@ -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 = {}) {
|
|
@@ -141,12 +113,12 @@ function getHeader(type) {
|
|
|
141
113
|
|
|
142
114
|
// src/importers/claude-code.ts
|
|
143
115
|
import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2, copyFileSync } from "fs";
|
|
144
|
-
import { resolve
|
|
116
|
+
import { resolve, join as join2, basename } from "path";
|
|
145
117
|
function importFromClaudeCode(projectRoot, outputPackDir) {
|
|
146
118
|
const warnings = [];
|
|
147
119
|
const filesImported = [];
|
|
148
|
-
const claudeDir =
|
|
149
|
-
const hasClaudeMd = existsSync2(
|
|
120
|
+
const claudeDir = resolve(projectRoot, ".claude");
|
|
121
|
+
const hasClaudeMd = existsSync2(resolve(projectRoot, "CLAUDE.md"));
|
|
150
122
|
const hasClaudeDir = existsSync2(claudeDir);
|
|
151
123
|
if (!hasClaudeMd && !hasClaudeDir) {
|
|
152
124
|
return {
|
|
@@ -156,12 +128,12 @@ function importFromClaudeCode(projectRoot, outputPackDir) {
|
|
|
156
128
|
configGenerated: false
|
|
157
129
|
};
|
|
158
130
|
}
|
|
159
|
-
const packDir = outputPackDir ??
|
|
131
|
+
const packDir = outputPackDir ?? resolve(projectRoot, "packs", "claude-import");
|
|
160
132
|
ensureDir(packDir);
|
|
161
|
-
const rulesDir =
|
|
133
|
+
const rulesDir = resolve(packDir, "rules");
|
|
162
134
|
ensureDir(rulesDir);
|
|
163
135
|
if (hasClaudeMd) {
|
|
164
|
-
const raw = readFileSync2(
|
|
136
|
+
const raw = readFileSync2(resolve(projectRoot, "CLAUDE.md"), "utf-8");
|
|
165
137
|
const ruleContent = [
|
|
166
138
|
"---",
|
|
167
139
|
"root: true",
|
|
@@ -176,7 +148,7 @@ function importFromClaudeCode(projectRoot, outputPackDir) {
|
|
|
176
148
|
filesImported.push(dest);
|
|
177
149
|
}
|
|
178
150
|
if (hasClaudeDir) {
|
|
179
|
-
const claudeRulesDir =
|
|
151
|
+
const claudeRulesDir = resolve(claudeDir, "rules");
|
|
180
152
|
if (existsSync2(claudeRulesDir)) {
|
|
181
153
|
const files = listFiles(claudeRulesDir, { extension: ".md" });
|
|
182
154
|
for (const file of files) {
|
|
@@ -185,7 +157,7 @@ function importFromClaudeCode(projectRoot, outputPackDir) {
|
|
|
185
157
|
filesImported.push(dest);
|
|
186
158
|
}
|
|
187
159
|
}
|
|
188
|
-
const settingsPath =
|
|
160
|
+
const settingsPath = resolve(claudeDir, "settings.json");
|
|
189
161
|
if (existsSync2(settingsPath)) {
|
|
190
162
|
try {
|
|
191
163
|
const raw = readFileSync2(settingsPath, "utf-8");
|
package/dist/importers/cursor.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 = {}) {
|
|
@@ -159,9 +131,9 @@ function serializeFrontmatter(data, content) {
|
|
|
159
131
|
|
|
160
132
|
// src/importers/cursor.ts
|
|
161
133
|
import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2, copyFileSync } from "fs";
|
|
162
|
-
import { resolve
|
|
134
|
+
import { resolve, join as join2, basename } from "path";
|
|
163
135
|
function importFromCursor(projectRoot, outputPackDir) {
|
|
164
|
-
const cursorDir =
|
|
136
|
+
const cursorDir = resolve(projectRoot, ".cursor");
|
|
165
137
|
const warnings = [];
|
|
166
138
|
const filesImported = [];
|
|
167
139
|
if (!existsSync2(cursorDir)) {
|
|
@@ -172,11 +144,11 @@ function importFromCursor(projectRoot, outputPackDir) {
|
|
|
172
144
|
configGenerated: false
|
|
173
145
|
};
|
|
174
146
|
}
|
|
175
|
-
const packDir = outputPackDir ??
|
|
147
|
+
const packDir = outputPackDir ?? resolve(projectRoot, "packs", "cursor-import");
|
|
176
148
|
ensureDir(packDir);
|
|
177
|
-
const rulesDir =
|
|
149
|
+
const rulesDir = resolve(cursorDir, "rules");
|
|
178
150
|
if (existsSync2(rulesDir)) {
|
|
179
|
-
const outRulesDir =
|
|
151
|
+
const outRulesDir = resolve(packDir, "rules");
|
|
180
152
|
ensureDir(outRulesDir);
|
|
181
153
|
const files = listFiles(rulesDir, { extension: ".mdc" });
|
|
182
154
|
for (const file of files) {
|
|
@@ -203,9 +175,9 @@ function importFromCursor(projectRoot, outputPackDir) {
|
|
|
203
175
|
filesImported.push(dest);
|
|
204
176
|
}
|
|
205
177
|
}
|
|
206
|
-
const agentsDir =
|
|
178
|
+
const agentsDir = resolve(cursorDir, "agents");
|
|
207
179
|
if (existsSync2(agentsDir)) {
|
|
208
|
-
const outDir =
|
|
180
|
+
const outDir = resolve(packDir, "agents");
|
|
209
181
|
ensureDir(outDir);
|
|
210
182
|
const files = listFiles(agentsDir, { extension: ".md" });
|
|
211
183
|
for (const file of files) {
|
|
@@ -214,9 +186,9 @@ function importFromCursor(projectRoot, outputPackDir) {
|
|
|
214
186
|
filesImported.push(dest);
|
|
215
187
|
}
|
|
216
188
|
}
|
|
217
|
-
const skillsDir =
|
|
189
|
+
const skillsDir = resolve(cursorDir, "skills");
|
|
218
190
|
if (existsSync2(skillsDir)) {
|
|
219
|
-
const outDir =
|
|
191
|
+
const outDir = resolve(packDir, "skills");
|
|
220
192
|
ensureDir(outDir);
|
|
221
193
|
const dirs = listDirs(skillsDir);
|
|
222
194
|
for (const dir of dirs) {
|
|
@@ -230,9 +202,9 @@ function importFromCursor(projectRoot, outputPackDir) {
|
|
|
230
202
|
}
|
|
231
203
|
}
|
|
232
204
|
}
|
|
233
|
-
const commandsDir =
|
|
205
|
+
const commandsDir = resolve(cursorDir, "commands");
|
|
234
206
|
if (existsSync2(commandsDir)) {
|
|
235
|
-
const outDir =
|
|
207
|
+
const outDir = resolve(packDir, "commands");
|
|
236
208
|
ensureDir(outDir);
|
|
237
209
|
const files = listFiles(commandsDir, { extension: ".md" });
|
|
238
210
|
for (const file of files) {
|
|
@@ -241,12 +213,12 @@ function importFromCursor(projectRoot, outputPackDir) {
|
|
|
241
213
|
filesImported.push(dest);
|
|
242
214
|
}
|
|
243
215
|
}
|
|
244
|
-
const mcpJson =
|
|
216
|
+
const mcpJson = resolve(cursorDir, "mcp.json");
|
|
245
217
|
if (existsSync2(mcpJson)) {
|
|
246
218
|
copyFileSync(mcpJson, join2(packDir, "mcp.json"));
|
|
247
219
|
filesImported.push(join2(packDir, "mcp.json"));
|
|
248
220
|
}
|
|
249
|
-
const cursorIgnore =
|
|
221
|
+
const cursorIgnore = resolve(projectRoot, ".cursorignore");
|
|
250
222
|
if (existsSync2(cursorIgnore)) {
|
|
251
223
|
copyFileSync(cursorIgnore, join2(packDir, "ignore"));
|
|
252
224
|
filesImported.push(join2(packDir, "ignore"));
|
|
@@ -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 = {}) {
|
|
@@ -141,11 +113,11 @@ function getHeader(type) {
|
|
|
141
113
|
|
|
142
114
|
// src/importers/opencode.ts
|
|
143
115
|
import { existsSync as existsSync2, readFileSync as readFileSync2, writeFileSync as writeFileSync2, copyFileSync } from "fs";
|
|
144
|
-
import { resolve
|
|
116
|
+
import { resolve, join as join2, basename } from "path";
|
|
145
117
|
function importFromOpenCode(projectRoot, outputPackDir) {
|
|
146
118
|
const warnings = [];
|
|
147
119
|
const filesImported = [];
|
|
148
|
-
const ocDir =
|
|
120
|
+
const ocDir = resolve(projectRoot, ".opencode");
|
|
149
121
|
if (!existsSync2(ocDir)) {
|
|
150
122
|
return {
|
|
151
123
|
packDir: "",
|
|
@@ -154,14 +126,14 @@ function importFromOpenCode(projectRoot, outputPackDir) {
|
|
|
154
126
|
configGenerated: false
|
|
155
127
|
};
|
|
156
128
|
}
|
|
157
|
-
const packDir = outputPackDir ??
|
|
129
|
+
const packDir = outputPackDir ?? resolve(projectRoot, "packs", "opencode-import");
|
|
158
130
|
ensureDir(packDir);
|
|
159
|
-
importDirMd(
|
|
160
|
-
importDirMd(
|
|
161
|
-
importDirMd(
|
|
162
|
-
const skillDir =
|
|
131
|
+
importDirMd(resolve(ocDir, "rules"), resolve(packDir, "rules"), filesImported);
|
|
132
|
+
importDirMd(resolve(ocDir, "commands"), resolve(packDir, "commands"), filesImported);
|
|
133
|
+
importDirMd(resolve(ocDir, "agents"), resolve(packDir, "agents"), filesImported);
|
|
134
|
+
const skillDir = resolve(ocDir, "skill");
|
|
163
135
|
if (existsSync2(skillDir)) {
|
|
164
|
-
const outSkillDir =
|
|
136
|
+
const outSkillDir = resolve(packDir, "skills");
|
|
165
137
|
ensureDir(outSkillDir);
|
|
166
138
|
const dirs = listDirs(skillDir);
|
|
167
139
|
for (const dir of dirs) {
|
|
@@ -177,9 +149,9 @@ function importFromOpenCode(projectRoot, outputPackDir) {
|
|
|
177
149
|
}
|
|
178
150
|
}
|
|
179
151
|
}
|
|
180
|
-
const pluginsDir =
|
|
152
|
+
const pluginsDir = resolve(ocDir, "plugins");
|
|
181
153
|
if (existsSync2(pluginsDir)) {
|
|
182
|
-
const outPluginsDir =
|
|
154
|
+
const outPluginsDir = resolve(packDir, "plugins");
|
|
183
155
|
ensureDir(outPluginsDir);
|
|
184
156
|
const files = listFiles(pluginsDir);
|
|
185
157
|
for (const file of files) {
|
|
@@ -190,9 +162,9 @@ function importFromOpenCode(projectRoot, outputPackDir) {
|
|
|
190
162
|
}
|
|
191
163
|
}
|
|
192
164
|
}
|
|
193
|
-
const agentsMd =
|
|
165
|
+
const agentsMd = resolve(projectRoot, "AGENTS.md");
|
|
194
166
|
if (existsSync2(agentsMd)) {
|
|
195
|
-
const outRulesDir =
|
|
167
|
+
const outRulesDir = resolve(packDir, "rules");
|
|
196
168
|
ensureDir(outRulesDir);
|
|
197
169
|
const raw = readFileSync2(agentsMd, "utf-8");
|
|
198
170
|
const ruleContent = [
|
|
@@ -208,7 +180,7 @@ function importFromOpenCode(projectRoot, outputPackDir) {
|
|
|
208
180
|
writeFileSync2(dest2, ruleContent);
|
|
209
181
|
filesImported.push(dest2);
|
|
210
182
|
}
|
|
211
|
-
const ocJson =
|
|
183
|
+
const ocJson = resolve(projectRoot, "opencode.json");
|
|
212
184
|
if (existsSync2(ocJson)) {
|
|
213
185
|
try {
|
|
214
186
|
const raw = readFileSync2(ocJson, "utf-8");
|
|
@@ -224,7 +196,7 @@ function importFromOpenCode(projectRoot, outputPackDir) {
|
|
|
224
196
|
warnings.push("Failed to parse opencode.json");
|
|
225
197
|
}
|
|
226
198
|
}
|
|
227
|
-
const ocIgnore =
|
|
199
|
+
const ocIgnore = resolve(projectRoot, ".opencodeignore");
|
|
228
200
|
if (existsSync2(ocIgnore)) {
|
|
229
201
|
copyFileSync(ocIgnore, join2(packDir, "ignore"));
|
|
230
202
|
filesImported.push(join2(packDir, "ignore"));
|
|
@@ -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 = {}) {
|
|
@@ -141,10 +113,10 @@ function getHeader(type) {
|
|
|
141
113
|
|
|
142
114
|
// src/importers/rulesync.ts
|
|
143
115
|
import { existsSync as existsSync2, readFileSync as readFileSync2, copyFileSync, writeFileSync as writeFileSync2 } from "fs";
|
|
144
|
-
import { resolve
|
|
116
|
+
import { resolve, join as join2, basename } from "path";
|
|
145
117
|
import { parse as parseJsonc } from "jsonc-parser";
|
|
146
118
|
function importFromRulesync(projectRoot, outputPackDir) {
|
|
147
|
-
const rulesyncDir =
|
|
119
|
+
const rulesyncDir = resolve(projectRoot, ".rulesync");
|
|
148
120
|
const warnings = [];
|
|
149
121
|
const filesImported = [];
|
|
150
122
|
if (!existsSync2(rulesyncDir)) {
|
|
@@ -155,11 +127,11 @@ function importFromRulesync(projectRoot, outputPackDir) {
|
|
|
155
127
|
configGenerated: false
|
|
156
128
|
};
|
|
157
129
|
}
|
|
158
|
-
const packDir = outputPackDir ??
|
|
130
|
+
const packDir = outputPackDir ?? resolve(projectRoot, "packs", "default");
|
|
159
131
|
ensureDir(packDir);
|
|
160
|
-
const rulesDir =
|
|
132
|
+
const rulesDir = resolve(rulesyncDir, "rules");
|
|
161
133
|
if (existsSync2(rulesDir)) {
|
|
162
|
-
const outRulesDir =
|
|
134
|
+
const outRulesDir = resolve(packDir, "rules");
|
|
163
135
|
ensureDir(outRulesDir);
|
|
164
136
|
const files = listFiles(rulesDir, { extension: ".md" });
|
|
165
137
|
for (const file of files) {
|
|
@@ -168,9 +140,9 @@ function importFromRulesync(projectRoot, outputPackDir) {
|
|
|
168
140
|
filesImported.push(dest);
|
|
169
141
|
}
|
|
170
142
|
}
|
|
171
|
-
const commandsDir =
|
|
143
|
+
const commandsDir = resolve(rulesyncDir, "commands");
|
|
172
144
|
if (existsSync2(commandsDir)) {
|
|
173
|
-
const outCommandsDir =
|
|
145
|
+
const outCommandsDir = resolve(packDir, "commands");
|
|
174
146
|
ensureDir(outCommandsDir);
|
|
175
147
|
const files = listFiles(commandsDir, { extension: ".md" });
|
|
176
148
|
for (const file of files) {
|
|
@@ -179,9 +151,9 @@ function importFromRulesync(projectRoot, outputPackDir) {
|
|
|
179
151
|
filesImported.push(dest);
|
|
180
152
|
}
|
|
181
153
|
}
|
|
182
|
-
const subagentsDir =
|
|
154
|
+
const subagentsDir = resolve(rulesyncDir, "subagents");
|
|
183
155
|
if (existsSync2(subagentsDir)) {
|
|
184
|
-
const outAgentsDir =
|
|
156
|
+
const outAgentsDir = resolve(packDir, "agents");
|
|
185
157
|
ensureDir(outAgentsDir);
|
|
186
158
|
const files = listFiles(subagentsDir, { extension: ".md" });
|
|
187
159
|
for (const file of files) {
|
|
@@ -190,9 +162,9 @@ function importFromRulesync(projectRoot, outputPackDir) {
|
|
|
190
162
|
filesImported.push(dest);
|
|
191
163
|
}
|
|
192
164
|
}
|
|
193
|
-
const skillsDir =
|
|
165
|
+
const skillsDir = resolve(rulesyncDir, "skills");
|
|
194
166
|
if (existsSync2(skillsDir)) {
|
|
195
|
-
const outSkillsDir =
|
|
167
|
+
const outSkillsDir = resolve(packDir, "skills");
|
|
196
168
|
ensureDir(outSkillsDir);
|
|
197
169
|
const skillDirs = listDirs(skillsDir);
|
|
198
170
|
for (const skillDir of skillDirs) {
|
|
@@ -208,20 +180,20 @@ function importFromRulesync(projectRoot, outputPackDir) {
|
|
|
208
180
|
}
|
|
209
181
|
}
|
|
210
182
|
}
|
|
211
|
-
const hooksJson =
|
|
183
|
+
const hooksJson = resolve(rulesyncDir, "hooks.json");
|
|
212
184
|
if (existsSync2(hooksJson)) {
|
|
213
|
-
const outHooksDir =
|
|
185
|
+
const outHooksDir = resolve(packDir, "hooks");
|
|
214
186
|
ensureDir(outHooksDir);
|
|
215
187
|
copyFileSync(hooksJson, join2(outHooksDir, "hooks.json"));
|
|
216
188
|
filesImported.push(join2(outHooksDir, "hooks.json"));
|
|
217
189
|
}
|
|
218
|
-
const mcpJson =
|
|
190
|
+
const mcpJson = resolve(rulesyncDir, "mcp.json");
|
|
219
191
|
if (existsSync2(mcpJson)) {
|
|
220
192
|
copyFileSync(mcpJson, join2(packDir, "mcp.json"));
|
|
221
193
|
filesImported.push(join2(packDir, "mcp.json"));
|
|
222
194
|
}
|
|
223
|
-
const aiIgnore =
|
|
224
|
-
const rulesyncIgnore =
|
|
195
|
+
const aiIgnore = resolve(rulesyncDir, ".aiignore");
|
|
196
|
+
const rulesyncIgnore = resolve(projectRoot, ".rulesyncignore");
|
|
225
197
|
if (existsSync2(aiIgnore)) {
|
|
226
198
|
copyFileSync(aiIgnore, join2(packDir, "ignore"));
|
|
227
199
|
filesImported.push(join2(packDir, "ignore"));
|
|
@@ -243,16 +215,16 @@ function importFromRulesync(projectRoot, outputPackDir) {
|
|
|
243
215
|
`);
|
|
244
216
|
filesImported.push(join2(packDir, "pack.json"));
|
|
245
217
|
let configGenerated = false;
|
|
246
|
-
const rulesyncConfig =
|
|
218
|
+
const rulesyncConfig = resolve(projectRoot, "rulesync.jsonc");
|
|
247
219
|
if (existsSync2(rulesyncConfig)) {
|
|
248
|
-
const agentpacksConfig = convertRulesyncConfig(rulesyncConfig, packDir
|
|
249
|
-
const configPath =
|
|
220
|
+
const agentpacksConfig = convertRulesyncConfig(rulesyncConfig, packDir);
|
|
221
|
+
const configPath = resolve(projectRoot, "agentpacks.jsonc");
|
|
250
222
|
writeFileSync2(configPath, agentpacksConfig);
|
|
251
223
|
configGenerated = true;
|
|
252
224
|
}
|
|
253
225
|
return { packDir, filesImported, warnings, configGenerated };
|
|
254
226
|
}
|
|
255
|
-
function convertRulesyncConfig(rulesyncPath,
|
|
227
|
+
function convertRulesyncConfig(rulesyncPath, _packDir) {
|
|
256
228
|
const raw = readFileSync2(rulesyncPath, "utf-8");
|
|
257
229
|
const parsed = parseJsonc(raw);
|
|
258
230
|
const targets = parsed.targets ?? ["opencode", "cursor", "claudecode"];
|