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,364 @@
|
|
|
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
|
+
var __require = import.meta.require;
|
|
31
|
+
|
|
32
|
+
// src/core/config.ts
|
|
33
|
+
var exports_config = {};
|
|
34
|
+
__export(exports_config, {
|
|
35
|
+
resolveTargets: () => resolveTargets,
|
|
36
|
+
resolveFeatures: () => resolveFeatures,
|
|
37
|
+
loadWorkspaceConfig: () => loadWorkspaceConfig,
|
|
38
|
+
loadPackManifest: () => loadPackManifest,
|
|
39
|
+
WorkspaceConfigSchema: () => WorkspaceConfigSchema,
|
|
40
|
+
TARGET_IDS: () => TARGET_IDS,
|
|
41
|
+
REPO_MODES: () => REPO_MODES,
|
|
42
|
+
PackManifestSchema: () => PackManifestSchema,
|
|
43
|
+
FEATURE_IDS: () => FEATURE_IDS
|
|
44
|
+
});
|
|
45
|
+
import { z } from "zod";
|
|
46
|
+
import { readFileSync, existsSync } from "fs";
|
|
47
|
+
import { resolve } from "path";
|
|
48
|
+
import { parse as parseJsonc } from "jsonc-parser";
|
|
49
|
+
function loadWorkspaceConfig(projectRoot) {
|
|
50
|
+
for (const filename of CONFIG_FILES) {
|
|
51
|
+
const filepath = resolve(projectRoot, filename);
|
|
52
|
+
if (existsSync(filepath)) {
|
|
53
|
+
const raw = readFileSync(filepath, "utf-8");
|
|
54
|
+
const parsed = parseJsonc(raw);
|
|
55
|
+
return WorkspaceConfigSchema.parse(parsed);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return WorkspaceConfigSchema.parse({});
|
|
59
|
+
}
|
|
60
|
+
function loadPackManifest(packDir) {
|
|
61
|
+
const filepath = resolve(packDir, "pack.json");
|
|
62
|
+
if (!existsSync(filepath)) {
|
|
63
|
+
const dirName = packDir.split("/").pop() ?? "unknown";
|
|
64
|
+
return PackManifestSchema.parse({ name: dirName });
|
|
65
|
+
}
|
|
66
|
+
const raw = readFileSync(filepath, "utf-8");
|
|
67
|
+
const parsed = JSON.parse(raw);
|
|
68
|
+
return PackManifestSchema.parse(parsed);
|
|
69
|
+
}
|
|
70
|
+
function resolveFeatures(config, targetId) {
|
|
71
|
+
const { features } = config;
|
|
72
|
+
if (features === "*") {
|
|
73
|
+
return [...FEATURE_IDS];
|
|
74
|
+
}
|
|
75
|
+
if (Array.isArray(features)) {
|
|
76
|
+
if (features.includes("*"))
|
|
77
|
+
return [...FEATURE_IDS];
|
|
78
|
+
return features.filter((f) => FEATURE_IDS.includes(f));
|
|
79
|
+
}
|
|
80
|
+
const targetFeatures = features[targetId];
|
|
81
|
+
if (!targetFeatures)
|
|
82
|
+
return [];
|
|
83
|
+
if (targetFeatures === "*")
|
|
84
|
+
return [...FEATURE_IDS];
|
|
85
|
+
if (Array.isArray(targetFeatures) && targetFeatures.includes("*"))
|
|
86
|
+
return [...FEATURE_IDS];
|
|
87
|
+
return targetFeatures.filter((f) => FEATURE_IDS.includes(f));
|
|
88
|
+
}
|
|
89
|
+
function resolveTargets(config) {
|
|
90
|
+
if (config.targets === "*")
|
|
91
|
+
return [...TARGET_IDS];
|
|
92
|
+
return config.targets;
|
|
93
|
+
}
|
|
94
|
+
var TARGET_IDS, FEATURE_IDS, REPO_MODES, PackManifestSchema, FeaturesSchema, WorkspaceConfigSchema, CONFIG_FILES;
|
|
95
|
+
var init_config = __esm(() => {
|
|
96
|
+
TARGET_IDS = [
|
|
97
|
+
"opencode",
|
|
98
|
+
"cursor",
|
|
99
|
+
"claudecode",
|
|
100
|
+
"codexcli",
|
|
101
|
+
"geminicli",
|
|
102
|
+
"copilot",
|
|
103
|
+
"agentsmd",
|
|
104
|
+
"cline",
|
|
105
|
+
"kilo",
|
|
106
|
+
"roo",
|
|
107
|
+
"qwencode",
|
|
108
|
+
"kiro",
|
|
109
|
+
"factorydroid",
|
|
110
|
+
"antigravity",
|
|
111
|
+
"junie",
|
|
112
|
+
"augmentcode",
|
|
113
|
+
"windsurf",
|
|
114
|
+
"warp",
|
|
115
|
+
"replit",
|
|
116
|
+
"zed"
|
|
117
|
+
];
|
|
118
|
+
FEATURE_IDS = [
|
|
119
|
+
"rules",
|
|
120
|
+
"commands",
|
|
121
|
+
"agents",
|
|
122
|
+
"skills",
|
|
123
|
+
"hooks",
|
|
124
|
+
"plugins",
|
|
125
|
+
"mcp",
|
|
126
|
+
"ignore"
|
|
127
|
+
];
|
|
128
|
+
REPO_MODES = ["repo", "monorepo", "metarepo"];
|
|
129
|
+
PackManifestSchema = z.object({
|
|
130
|
+
name: z.string().min(1),
|
|
131
|
+
version: z.string().default("1.0.0"),
|
|
132
|
+
description: z.string().default(""),
|
|
133
|
+
author: z.union([
|
|
134
|
+
z.string(),
|
|
135
|
+
z.object({ name: z.string(), email: z.string().optional() })
|
|
136
|
+
]).optional(),
|
|
137
|
+
tags: z.array(z.string()).default([]),
|
|
138
|
+
dependencies: z.array(z.string()).default([]),
|
|
139
|
+
conflicts: z.array(z.string()).default([]),
|
|
140
|
+
targets: z.union([z.literal("*"), z.array(z.string())]).default("*"),
|
|
141
|
+
features: z.union([z.literal("*"), z.array(z.string())]).default("*")
|
|
142
|
+
});
|
|
143
|
+
FeaturesSchema = z.union([
|
|
144
|
+
z.literal("*"),
|
|
145
|
+
z.array(z.string()),
|
|
146
|
+
z.record(z.string(), z.union([z.literal("*"), z.array(z.string())]))
|
|
147
|
+
]);
|
|
148
|
+
WorkspaceConfigSchema = z.object({
|
|
149
|
+
$schema: z.string().optional(),
|
|
150
|
+
packs: z.array(z.string()).default(["./packs/default"]),
|
|
151
|
+
disabled: z.array(z.string()).default([]),
|
|
152
|
+
targets: z.union([z.literal("*"), z.array(z.string())]).default("*"),
|
|
153
|
+
features: FeaturesSchema.default("*"),
|
|
154
|
+
mode: z.enum(REPO_MODES).default("repo"),
|
|
155
|
+
baseDirs: z.array(z.string()).default(["."]),
|
|
156
|
+
global: z.boolean().default(false),
|
|
157
|
+
delete: z.boolean().default(true),
|
|
158
|
+
verbose: z.boolean().default(false),
|
|
159
|
+
silent: z.boolean().default(false),
|
|
160
|
+
overrides: z.record(z.string(), z.record(z.string(), z.string())).default({}),
|
|
161
|
+
sources: z.array(z.object({
|
|
162
|
+
source: z.string(),
|
|
163
|
+
packs: z.array(z.string()).optional(),
|
|
164
|
+
skills: z.array(z.string()).optional()
|
|
165
|
+
})).default([])
|
|
166
|
+
});
|
|
167
|
+
CONFIG_FILES = ["agentpacks.local.jsonc", "agentpacks.jsonc"];
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
// src/utils/filesystem.ts
|
|
171
|
+
import {
|
|
172
|
+
existsSync as existsSync2,
|
|
173
|
+
mkdirSync,
|
|
174
|
+
readFileSync as readFileSync2,
|
|
175
|
+
writeFileSync,
|
|
176
|
+
readdirSync,
|
|
177
|
+
statSync
|
|
178
|
+
} from "fs";
|
|
179
|
+
import { dirname, relative, join } from "path";
|
|
180
|
+
import { removeSync } from "fs-extra";
|
|
181
|
+
var GENERATED_HEADER_MD = "<!-- Generated by agentpacks. DO NOT EDIT. -->";
|
|
182
|
+
var GENERATED_HEADER_JSON = "// Generated by agentpacks. DO NOT EDIT.";
|
|
183
|
+
var GENERATED_HEADER_JS = "// Generated by agentpacks. DO NOT EDIT.";
|
|
184
|
+
function writeGeneratedFile(filepath, content, options = {}) {
|
|
185
|
+
const { header = true, type } = options;
|
|
186
|
+
const ext = type ?? inferFileType(filepath);
|
|
187
|
+
ensureDir(dirname(filepath));
|
|
188
|
+
let output = content;
|
|
189
|
+
if (header) {
|
|
190
|
+
const headerComment = getHeader(ext);
|
|
191
|
+
if (headerComment) {
|
|
192
|
+
output = `${headerComment}
|
|
193
|
+
${content}`;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
writeFileSync(filepath, output, "utf-8");
|
|
197
|
+
}
|
|
198
|
+
function writeGeneratedJson(filepath, data, options = {}) {
|
|
199
|
+
const json = JSON.stringify(data, null, 2);
|
|
200
|
+
writeGeneratedFile(filepath, json + `
|
|
201
|
+
`, { ...options, type: "json" });
|
|
202
|
+
}
|
|
203
|
+
function readFileOrNull(filepath) {
|
|
204
|
+
if (!existsSync2(filepath))
|
|
205
|
+
return null;
|
|
206
|
+
return readFileSync2(filepath, "utf-8");
|
|
207
|
+
}
|
|
208
|
+
function readJsonOrNull(filepath) {
|
|
209
|
+
const content = readFileOrNull(filepath);
|
|
210
|
+
if (content === null)
|
|
211
|
+
return null;
|
|
212
|
+
return JSON.parse(content);
|
|
213
|
+
}
|
|
214
|
+
function ensureDir(dirPath) {
|
|
215
|
+
if (!existsSync2(dirPath)) {
|
|
216
|
+
mkdirSync(dirPath, { recursive: true });
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function removeIfExists(targetPath) {
|
|
220
|
+
if (existsSync2(targetPath)) {
|
|
221
|
+
removeSync(targetPath);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
function listFiles(dirPath, options = {}) {
|
|
225
|
+
const { extension, recursive = false } = options;
|
|
226
|
+
if (!existsSync2(dirPath))
|
|
227
|
+
return [];
|
|
228
|
+
const results = [];
|
|
229
|
+
const entries = readdirSync(dirPath);
|
|
230
|
+
for (const entry of entries) {
|
|
231
|
+
const fullPath = join(dirPath, entry);
|
|
232
|
+
const stat = statSync(fullPath);
|
|
233
|
+
if (stat.isDirectory() && recursive) {
|
|
234
|
+
results.push(...listFiles(fullPath, options));
|
|
235
|
+
} else if (stat.isFile()) {
|
|
236
|
+
if (!extension || entry.endsWith(extension)) {
|
|
237
|
+
results.push(fullPath);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
return results;
|
|
242
|
+
}
|
|
243
|
+
function listDirs(dirPath) {
|
|
244
|
+
if (!existsSync2(dirPath))
|
|
245
|
+
return [];
|
|
246
|
+
return readdirSync(dirPath).map((entry) => join(dirPath, entry)).filter((fullPath) => statSync(fullPath).isDirectory());
|
|
247
|
+
}
|
|
248
|
+
function relPath(projectRoot, filepath) {
|
|
249
|
+
return relative(projectRoot, filepath);
|
|
250
|
+
}
|
|
251
|
+
function isGeneratedFile(filepath) {
|
|
252
|
+
const content = readFileOrNull(filepath);
|
|
253
|
+
if (!content)
|
|
254
|
+
return false;
|
|
255
|
+
return content.startsWith(GENERATED_HEADER_MD) || content.startsWith(GENERATED_HEADER_JSON) || content.startsWith(GENERATED_HEADER_JS);
|
|
256
|
+
}
|
|
257
|
+
function inferFileType(filepath) {
|
|
258
|
+
if (filepath.endsWith(".json") || filepath.endsWith(".jsonc"))
|
|
259
|
+
return "json";
|
|
260
|
+
if (filepath.endsWith(".ts") || filepath.endsWith(".mts"))
|
|
261
|
+
return "ts";
|
|
262
|
+
if (filepath.endsWith(".js") || filepath.endsWith(".mjs"))
|
|
263
|
+
return "js";
|
|
264
|
+
return "md";
|
|
265
|
+
}
|
|
266
|
+
function getHeader(type) {
|
|
267
|
+
switch (type) {
|
|
268
|
+
case "md":
|
|
269
|
+
return GENERATED_HEADER_MD;
|
|
270
|
+
case "json":
|
|
271
|
+
return GENERATED_HEADER_JSON;
|
|
272
|
+
case "js":
|
|
273
|
+
case "ts":
|
|
274
|
+
return GENERATED_HEADER_JS;
|
|
275
|
+
default:
|
|
276
|
+
return null;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// src/cli/pack/validate.ts
|
|
281
|
+
init_config();
|
|
282
|
+
import { existsSync as existsSync3 } from "fs";
|
|
283
|
+
import { resolve as resolve3, join as join2 } from "path";
|
|
284
|
+
import chalk from "chalk";
|
|
285
|
+
function runPackValidate(projectRoot) {
|
|
286
|
+
const config = loadWorkspaceConfig(projectRoot);
|
|
287
|
+
let hasErrors = false;
|
|
288
|
+
for (const packRef of config.packs) {
|
|
289
|
+
const packDir = resolvePackDir(projectRoot, packRef);
|
|
290
|
+
console.log(chalk.bold(`
|
|
291
|
+
Validating pack: ${packRef}`));
|
|
292
|
+
if (!packDir || !existsSync3(packDir)) {
|
|
293
|
+
console.log(chalk.red(` ERROR: Pack directory not found: ${packRef}`));
|
|
294
|
+
hasErrors = true;
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
const packJsonPath = resolve3(packDir, "pack.json");
|
|
298
|
+
if (!existsSync3(packJsonPath)) {
|
|
299
|
+
console.log(chalk.yellow(" warn: No pack.json found. Name will be inferred from directory."));
|
|
300
|
+
} else {
|
|
301
|
+
try {
|
|
302
|
+
loadPackManifest(packDir);
|
|
303
|
+
console.log(chalk.green(" pack.json: valid"));
|
|
304
|
+
} catch (err) {
|
|
305
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
306
|
+
console.log(chalk.red(` ERROR pack.json: ${message}`));
|
|
307
|
+
hasErrors = true;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
const subdirs = ["rules", "commands", "agents", "skills"];
|
|
311
|
+
for (const sub of subdirs) {
|
|
312
|
+
const subDir = join2(packDir, sub);
|
|
313
|
+
if (existsSync3(subDir)) {
|
|
314
|
+
if (sub === "skills") {
|
|
315
|
+
const skillDirs = listDirs(subDir);
|
|
316
|
+
for (const skillDir of skillDirs) {
|
|
317
|
+
const skillMd = join2(skillDir, "SKILL.md");
|
|
318
|
+
if (!existsSync3(skillMd)) {
|
|
319
|
+
console.log(chalk.yellow(` warn: skills/${skillDir.split("/").pop()} missing SKILL.md`));
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
console.log(chalk.green(` ${sub}/: ${skillDirs.length} skill(s)`));
|
|
323
|
+
} else {
|
|
324
|
+
const files = listFiles(subDir, { extension: ".md" });
|
|
325
|
+
console.log(chalk.green(` ${sub}/: ${files.length} file(s)`));
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
const optionalFiles = ["mcp.json", "ignore", ".aiignore"];
|
|
330
|
+
for (const file of optionalFiles) {
|
|
331
|
+
if (existsSync3(join2(packDir, file))) {
|
|
332
|
+
console.log(chalk.green(` ${file}: present`));
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
const hooksJson = join2(packDir, "hooks", "hooks.json");
|
|
336
|
+
if (existsSync3(hooksJson)) {
|
|
337
|
+
console.log(chalk.green(" hooks/hooks.json: present"));
|
|
338
|
+
}
|
|
339
|
+
const pluginsDir = join2(packDir, "plugins");
|
|
340
|
+
if (existsSync3(pluginsDir)) {
|
|
341
|
+
const pluginFiles = [
|
|
342
|
+
...listFiles(pluginsDir, { extension: ".ts" }),
|
|
343
|
+
...listFiles(pluginsDir, { extension: ".js" })
|
|
344
|
+
];
|
|
345
|
+
console.log(chalk.green(` plugins/: ${pluginFiles.length} file(s)`));
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
console.log();
|
|
349
|
+
if (hasErrors) {
|
|
350
|
+
console.log(chalk.red("Validation failed with errors."));
|
|
351
|
+
process.exit(1);
|
|
352
|
+
} else {
|
|
353
|
+
console.log(chalk.green("All packs valid."));
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
function resolvePackDir(projectRoot, packRef) {
|
|
357
|
+
if (packRef.startsWith("./") || packRef.startsWith("../")) {
|
|
358
|
+
return resolve3(projectRoot, packRef);
|
|
359
|
+
}
|
|
360
|
+
return resolve3(projectRoot, packRef);
|
|
361
|
+
}
|
|
362
|
+
export {
|
|
363
|
+
runPackValidate
|
|
364
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* All supported target identifiers.
|
|
4
|
+
*/
|
|
5
|
+
export declare const TARGET_IDS: readonly ["opencode", "cursor", "claudecode", "codexcli", "geminicli", "copilot", "agentsmd", "cline", "kilo", "roo", "qwencode", "kiro", "factorydroid", "antigravity", "junie", "augmentcode", "windsurf", "warp", "replit", "zed"];
|
|
6
|
+
export type TargetId = (typeof TARGET_IDS)[number];
|
|
7
|
+
/**
|
|
8
|
+
* All supported feature types.
|
|
9
|
+
*/
|
|
10
|
+
export declare const FEATURE_IDS: readonly ["rules", "commands", "agents", "skills", "hooks", "plugins", "mcp", "ignore"];
|
|
11
|
+
export type FeatureId = (typeof FEATURE_IDS)[number];
|
|
12
|
+
/**
|
|
13
|
+
* Repository mode.
|
|
14
|
+
*/
|
|
15
|
+
export declare const REPO_MODES: readonly ["repo", "monorepo", "metarepo"];
|
|
16
|
+
export type RepoMode = (typeof REPO_MODES)[number];
|
|
17
|
+
/**
|
|
18
|
+
* Pack manifest schema (pack.json).
|
|
19
|
+
*/
|
|
20
|
+
export declare const PackManifestSchema: z.ZodObject<{
|
|
21
|
+
name: z.ZodString;
|
|
22
|
+
version: z.ZodDefault<z.ZodString>;
|
|
23
|
+
description: z.ZodDefault<z.ZodString>;
|
|
24
|
+
author: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
25
|
+
name: z.ZodString;
|
|
26
|
+
email: z.ZodOptional<z.ZodString>;
|
|
27
|
+
}, z.core.$strip>]>>;
|
|
28
|
+
tags: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
29
|
+
dependencies: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
30
|
+
conflicts: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
31
|
+
targets: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>>;
|
|
32
|
+
features: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>>;
|
|
33
|
+
}, z.core.$strip>;
|
|
34
|
+
export type PackManifest = z.infer<typeof PackManifestSchema>;
|
|
35
|
+
/**
|
|
36
|
+
* Workspace configuration schema (agentpacks.jsonc).
|
|
37
|
+
*/
|
|
38
|
+
export declare const WorkspaceConfigSchema: z.ZodObject<{
|
|
39
|
+
$schema: z.ZodOptional<z.ZodString>;
|
|
40
|
+
packs: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
41
|
+
disabled: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
42
|
+
targets: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>>;
|
|
43
|
+
features: z.ZodDefault<z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>, z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodLiteral<"*">, z.ZodArray<z.ZodString>]>>]>>;
|
|
44
|
+
mode: z.ZodDefault<z.ZodEnum<{
|
|
45
|
+
repo: "repo";
|
|
46
|
+
monorepo: "monorepo";
|
|
47
|
+
metarepo: "metarepo";
|
|
48
|
+
}>>;
|
|
49
|
+
baseDirs: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
50
|
+
global: z.ZodDefault<z.ZodBoolean>;
|
|
51
|
+
delete: z.ZodDefault<z.ZodBoolean>;
|
|
52
|
+
verbose: z.ZodDefault<z.ZodBoolean>;
|
|
53
|
+
silent: z.ZodDefault<z.ZodBoolean>;
|
|
54
|
+
overrides: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
55
|
+
sources: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
56
|
+
source: z.ZodString;
|
|
57
|
+
packs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
58
|
+
skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
59
|
+
}, z.core.$strip>>>;
|
|
60
|
+
}, z.core.$strip>;
|
|
61
|
+
export type WorkspaceConfig = z.infer<typeof WorkspaceConfigSchema>;
|
|
62
|
+
/**
|
|
63
|
+
* Load workspace configuration from the project root.
|
|
64
|
+
*/
|
|
65
|
+
export declare function loadWorkspaceConfig(projectRoot: string): WorkspaceConfig;
|
|
66
|
+
/**
|
|
67
|
+
* Load pack manifest from a pack directory.
|
|
68
|
+
*/
|
|
69
|
+
export declare function loadPackManifest(packDir: string): PackManifest;
|
|
70
|
+
/**
|
|
71
|
+
* Resolve which features to generate for a given target.
|
|
72
|
+
*/
|
|
73
|
+
export declare function resolveFeatures(config: WorkspaceConfig, targetId: string): FeatureId[];
|
|
74
|
+
/**
|
|
75
|
+
* Resolve which targets to generate for.
|
|
76
|
+
*/
|
|
77
|
+
export declare function resolveTargets(config: WorkspaceConfig): string[];
|
|
@@ -0,0 +1,181 @@
|
|
|
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
|
+
var __require = import.meta.require;
|
|
31
|
+
|
|
32
|
+
// src/core/config.ts
|
|
33
|
+
var exports_config = {};
|
|
34
|
+
__export(exports_config, {
|
|
35
|
+
resolveTargets: () => resolveTargets,
|
|
36
|
+
resolveFeatures: () => resolveFeatures,
|
|
37
|
+
loadWorkspaceConfig: () => loadWorkspaceConfig,
|
|
38
|
+
loadPackManifest: () => loadPackManifest,
|
|
39
|
+
WorkspaceConfigSchema: () => WorkspaceConfigSchema,
|
|
40
|
+
TARGET_IDS: () => TARGET_IDS,
|
|
41
|
+
REPO_MODES: () => REPO_MODES,
|
|
42
|
+
PackManifestSchema: () => PackManifestSchema,
|
|
43
|
+
FEATURE_IDS: () => FEATURE_IDS
|
|
44
|
+
});
|
|
45
|
+
import { z } from "zod";
|
|
46
|
+
import { readFileSync, existsSync } from "fs";
|
|
47
|
+
import { resolve } from "path";
|
|
48
|
+
import { parse as parseJsonc } from "jsonc-parser";
|
|
49
|
+
function loadWorkspaceConfig(projectRoot) {
|
|
50
|
+
for (const filename of CONFIG_FILES) {
|
|
51
|
+
const filepath = resolve(projectRoot, filename);
|
|
52
|
+
if (existsSync(filepath)) {
|
|
53
|
+
const raw = readFileSync(filepath, "utf-8");
|
|
54
|
+
const parsed = parseJsonc(raw);
|
|
55
|
+
return WorkspaceConfigSchema.parse(parsed);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return WorkspaceConfigSchema.parse({});
|
|
59
|
+
}
|
|
60
|
+
function loadPackManifest(packDir) {
|
|
61
|
+
const filepath = resolve(packDir, "pack.json");
|
|
62
|
+
if (!existsSync(filepath)) {
|
|
63
|
+
const dirName = packDir.split("/").pop() ?? "unknown";
|
|
64
|
+
return PackManifestSchema.parse({ name: dirName });
|
|
65
|
+
}
|
|
66
|
+
const raw = readFileSync(filepath, "utf-8");
|
|
67
|
+
const parsed = JSON.parse(raw);
|
|
68
|
+
return PackManifestSchema.parse(parsed);
|
|
69
|
+
}
|
|
70
|
+
function resolveFeatures(config, targetId) {
|
|
71
|
+
const { features } = config;
|
|
72
|
+
if (features === "*") {
|
|
73
|
+
return [...FEATURE_IDS];
|
|
74
|
+
}
|
|
75
|
+
if (Array.isArray(features)) {
|
|
76
|
+
if (features.includes("*"))
|
|
77
|
+
return [...FEATURE_IDS];
|
|
78
|
+
return features.filter((f) => FEATURE_IDS.includes(f));
|
|
79
|
+
}
|
|
80
|
+
const targetFeatures = features[targetId];
|
|
81
|
+
if (!targetFeatures)
|
|
82
|
+
return [];
|
|
83
|
+
if (targetFeatures === "*")
|
|
84
|
+
return [...FEATURE_IDS];
|
|
85
|
+
if (Array.isArray(targetFeatures) && targetFeatures.includes("*"))
|
|
86
|
+
return [...FEATURE_IDS];
|
|
87
|
+
return targetFeatures.filter((f) => FEATURE_IDS.includes(f));
|
|
88
|
+
}
|
|
89
|
+
function resolveTargets(config) {
|
|
90
|
+
if (config.targets === "*")
|
|
91
|
+
return [...TARGET_IDS];
|
|
92
|
+
return config.targets;
|
|
93
|
+
}
|
|
94
|
+
var TARGET_IDS, FEATURE_IDS, REPO_MODES, PackManifestSchema, FeaturesSchema, WorkspaceConfigSchema, CONFIG_FILES;
|
|
95
|
+
var init_config = __esm(() => {
|
|
96
|
+
TARGET_IDS = [
|
|
97
|
+
"opencode",
|
|
98
|
+
"cursor",
|
|
99
|
+
"claudecode",
|
|
100
|
+
"codexcli",
|
|
101
|
+
"geminicli",
|
|
102
|
+
"copilot",
|
|
103
|
+
"agentsmd",
|
|
104
|
+
"cline",
|
|
105
|
+
"kilo",
|
|
106
|
+
"roo",
|
|
107
|
+
"qwencode",
|
|
108
|
+
"kiro",
|
|
109
|
+
"factorydroid",
|
|
110
|
+
"antigravity",
|
|
111
|
+
"junie",
|
|
112
|
+
"augmentcode",
|
|
113
|
+
"windsurf",
|
|
114
|
+
"warp",
|
|
115
|
+
"replit",
|
|
116
|
+
"zed"
|
|
117
|
+
];
|
|
118
|
+
FEATURE_IDS = [
|
|
119
|
+
"rules",
|
|
120
|
+
"commands",
|
|
121
|
+
"agents",
|
|
122
|
+
"skills",
|
|
123
|
+
"hooks",
|
|
124
|
+
"plugins",
|
|
125
|
+
"mcp",
|
|
126
|
+
"ignore"
|
|
127
|
+
];
|
|
128
|
+
REPO_MODES = ["repo", "monorepo", "metarepo"];
|
|
129
|
+
PackManifestSchema = z.object({
|
|
130
|
+
name: z.string().min(1),
|
|
131
|
+
version: z.string().default("1.0.0"),
|
|
132
|
+
description: z.string().default(""),
|
|
133
|
+
author: z.union([
|
|
134
|
+
z.string(),
|
|
135
|
+
z.object({ name: z.string(), email: z.string().optional() })
|
|
136
|
+
]).optional(),
|
|
137
|
+
tags: z.array(z.string()).default([]),
|
|
138
|
+
dependencies: z.array(z.string()).default([]),
|
|
139
|
+
conflicts: z.array(z.string()).default([]),
|
|
140
|
+
targets: z.union([z.literal("*"), z.array(z.string())]).default("*"),
|
|
141
|
+
features: z.union([z.literal("*"), z.array(z.string())]).default("*")
|
|
142
|
+
});
|
|
143
|
+
FeaturesSchema = z.union([
|
|
144
|
+
z.literal("*"),
|
|
145
|
+
z.array(z.string()),
|
|
146
|
+
z.record(z.string(), z.union([z.literal("*"), z.array(z.string())]))
|
|
147
|
+
]);
|
|
148
|
+
WorkspaceConfigSchema = z.object({
|
|
149
|
+
$schema: z.string().optional(),
|
|
150
|
+
packs: z.array(z.string()).default(["./packs/default"]),
|
|
151
|
+
disabled: z.array(z.string()).default([]),
|
|
152
|
+
targets: z.union([z.literal("*"), z.array(z.string())]).default("*"),
|
|
153
|
+
features: FeaturesSchema.default("*"),
|
|
154
|
+
mode: z.enum(REPO_MODES).default("repo"),
|
|
155
|
+
baseDirs: z.array(z.string()).default(["."]),
|
|
156
|
+
global: z.boolean().default(false),
|
|
157
|
+
delete: z.boolean().default(true),
|
|
158
|
+
verbose: z.boolean().default(false),
|
|
159
|
+
silent: z.boolean().default(false),
|
|
160
|
+
overrides: z.record(z.string(), z.record(z.string(), z.string())).default({}),
|
|
161
|
+
sources: z.array(z.object({
|
|
162
|
+
source: z.string(),
|
|
163
|
+
packs: z.array(z.string()).optional(),
|
|
164
|
+
skills: z.array(z.string()).optional()
|
|
165
|
+
})).default([])
|
|
166
|
+
});
|
|
167
|
+
CONFIG_FILES = ["agentpacks.local.jsonc", "agentpacks.jsonc"];
|
|
168
|
+
});
|
|
169
|
+
init_config();
|
|
170
|
+
|
|
171
|
+
export {
|
|
172
|
+
resolveTargets,
|
|
173
|
+
resolveFeatures,
|
|
174
|
+
loadWorkspaceConfig,
|
|
175
|
+
loadPackManifest,
|
|
176
|
+
WorkspaceConfigSchema,
|
|
177
|
+
TARGET_IDS,
|
|
178
|
+
REPO_MODES,
|
|
179
|
+
PackManifestSchema,
|
|
180
|
+
FEATURE_IDS
|
|
181
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pack dependency resolution — topological sort and conflict detection.
|
|
3
|
+
* Pure algorithm, no I/O.
|
|
4
|
+
*/
|
|
5
|
+
import type { PackManifest } from './config.js';
|
|
6
|
+
/**
|
|
7
|
+
* A node in the dependency graph.
|
|
8
|
+
*/
|
|
9
|
+
export interface DependencyNode {
|
|
10
|
+
name: string;
|
|
11
|
+
manifest: PackManifest;
|
|
12
|
+
dependencies: string[];
|
|
13
|
+
conflicts: string[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Resolution result.
|
|
17
|
+
*/
|
|
18
|
+
export interface DependencyResolution {
|
|
19
|
+
/** Packs in topological order (dependencies first). */
|
|
20
|
+
sorted: string[];
|
|
21
|
+
/** Circular dependency cycles detected. */
|
|
22
|
+
cycles: string[][];
|
|
23
|
+
/** Conflict pairs: [packA, packB] */
|
|
24
|
+
conflictPairs: [string, string][];
|
|
25
|
+
/** Missing dependencies: [pack, missingDep] */
|
|
26
|
+
missingDeps: [string, string][];
|
|
27
|
+
/** Whether resolution succeeded without errors. */
|
|
28
|
+
ok: boolean;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Build a dependency graph from pack manifests.
|
|
32
|
+
*/
|
|
33
|
+
export declare function buildDependencyGraph(manifests: PackManifest[]): Map<string, DependencyNode>;
|
|
34
|
+
/**
|
|
35
|
+
* Resolve pack dependencies with topological sort, cycle detection,
|
|
36
|
+
* and conflict detection.
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveDependencies(manifests: PackManifest[]): DependencyResolution;
|