@comet/cli 9.0.0-beta.3 → 9.0.0-beta.5
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/lib/comet.js +2 -2
- package/lib/commands/install-agent-features.d.ts +7 -0
- package/lib/commands/install-agent-features.js +434 -0
- package/lib/commands/install-agent-features.test.js +325 -0
- package/package.json +5 -4
- package/lib/commands/install-agent-skills.d.ts +0 -15
- package/lib/commands/install-agent-skills.js +0 -255
- package/lib/commands/install-agent-skills.test.js +0 -280
- /package/lib/commands/{install-agent-skills.test.d.ts → install-agent-features.test.d.ts} +0 -0
package/lib/comet.js
CHANGED
|
@@ -4,12 +4,12 @@ var commander_1 = require("commander");
|
|
|
4
4
|
var download_mitmproxy_1 = require("./commands/download-mitmproxy");
|
|
5
5
|
var download_oauth2_proxy_1 = require("./commands/download-oauth2-proxy");
|
|
6
6
|
var generate_block_types_1 = require("./commands/generate-block-types");
|
|
7
|
-
var
|
|
7
|
+
var install_agent_features_1 = require("./commands/install-agent-features");
|
|
8
8
|
var site_configs_1 = require("./commands/site-configs");
|
|
9
9
|
var program = new commander_1.Command();
|
|
10
10
|
program.addCommand(generate_block_types_1.generateBlockTypes);
|
|
11
11
|
program.addCommand(site_configs_1.injectSiteConfigsCommand);
|
|
12
12
|
program.addCommand(download_oauth2_proxy_1.downloadOAuth2ProxyCommand);
|
|
13
13
|
program.addCommand(download_mitmproxy_1.downloadMitmproxyCommand);
|
|
14
|
-
program.addCommand(
|
|
14
|
+
program.addCommand(install_agent_features_1.installAgentFeaturesCommand);
|
|
15
15
|
program.parse();
|
|
@@ -0,0 +1,434 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
45
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
46
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
47
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
48
|
+
function step(op) {
|
|
49
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
50
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
51
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
52
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
53
|
+
switch (op[0]) {
|
|
54
|
+
case 0: case 1: t = op; break;
|
|
55
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
56
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
57
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
58
|
+
default:
|
|
59
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
60
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
61
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
62
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
63
|
+
if (t[2]) _.ops.pop();
|
|
64
|
+
_.trys.pop(); continue;
|
|
65
|
+
}
|
|
66
|
+
op = body.call(thisArg, _);
|
|
67
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
68
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
72
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
73
|
+
if (ar || !(i in from)) {
|
|
74
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
75
|
+
ar[i] = from[i];
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
79
|
+
};
|
|
80
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
81
|
+
exports.installAgentFeaturesCommand = void 0;
|
|
82
|
+
exports.installFeatures = installFeatures;
|
|
83
|
+
/* eslint-disable no-console */
|
|
84
|
+
var child_process_1 = require("child_process");
|
|
85
|
+
var commander_1 = require("commander");
|
|
86
|
+
var fs = __importStar(require("fs"));
|
|
87
|
+
var yaml = __importStar(require("js-yaml"));
|
|
88
|
+
var os = __importStar(require("os"));
|
|
89
|
+
var path = __importStar(require("path"));
|
|
90
|
+
var SKILL_SOURCE_PATHS = ["skills", "agentic-plugin/skills"];
|
|
91
|
+
var RULE_SOURCE_PATHS = ["rules"];
|
|
92
|
+
function discoverNodeModulesPackages(cwd) {
|
|
93
|
+
var nodeModulesDir = path.join(cwd, "node_modules");
|
|
94
|
+
if (!fs.existsSync(nodeModulesDir)) {
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
var packageDirs = [];
|
|
98
|
+
var entries;
|
|
99
|
+
try {
|
|
100
|
+
entries = fs.readdirSync(nodeModulesDir);
|
|
101
|
+
}
|
|
102
|
+
catch (_a) {
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
106
|
+
var entry = entries_1[_i];
|
|
107
|
+
if (entry.startsWith(".")) {
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
var fullPath = path.join(nodeModulesDir, entry);
|
|
111
|
+
if (entry.startsWith("@")) {
|
|
112
|
+
// Scoped package: read one level deeper
|
|
113
|
+
var scopedEntries = void 0;
|
|
114
|
+
try {
|
|
115
|
+
scopedEntries = fs.readdirSync(fullPath);
|
|
116
|
+
}
|
|
117
|
+
catch (_b) {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
for (var _c = 0, scopedEntries_1 = scopedEntries; _c < scopedEntries_1.length; _c++) {
|
|
121
|
+
var scopedEntry = scopedEntries_1[_c];
|
|
122
|
+
if (scopedEntry.startsWith(".")) {
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
var scopedPath = path.join(fullPath, scopedEntry);
|
|
126
|
+
try {
|
|
127
|
+
if (fs.statSync(scopedPath).isDirectory()) {
|
|
128
|
+
packageDirs.push(scopedPath);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
catch (_d) {
|
|
132
|
+
// skip unreadable entries
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
try {
|
|
138
|
+
if (fs.statSync(fullPath).isDirectory()) {
|
|
139
|
+
packageDirs.push(fullPath);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
catch (_e) {
|
|
143
|
+
// skip unreadable entries
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return packageDirs;
|
|
148
|
+
}
|
|
149
|
+
function parseRepoUrl(rawUrl) {
|
|
150
|
+
var hashIndex = rawUrl.lastIndexOf("#");
|
|
151
|
+
if (hashIndex === -1) {
|
|
152
|
+
return { repoUrl: rawUrl, ref: undefined };
|
|
153
|
+
}
|
|
154
|
+
return { repoUrl: rawUrl.slice(0, hashIndex), ref: rawUrl.slice(hashIndex + 1) || undefined };
|
|
155
|
+
}
|
|
156
|
+
function cloneRepo(rawUrl, sparsePatterns) {
|
|
157
|
+
var _a = parseRepoUrl(rawUrl), repoUrl = _a.repoUrl, ref = _a.ref;
|
|
158
|
+
var tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "comet-agent-install-"));
|
|
159
|
+
(0, child_process_1.execFileSync)("git", ["init", tmpDir], { stdio: "pipe" });
|
|
160
|
+
(0, child_process_1.execFileSync)("git", ["-C", tmpDir, "remote", "add", "origin", "--", repoUrl], { stdio: "pipe" });
|
|
161
|
+
(0, child_process_1.execFileSync)("git", ["-C", tmpDir, "config", "core.sparseCheckout", "true"], { stdio: "pipe" });
|
|
162
|
+
fs.writeFileSync(path.join(tmpDir, ".git", "info", "sparse-checkout"), sparsePatterns.map(function (p) { return "".concat(p, "\n"); }).join(""));
|
|
163
|
+
var fetchRef = ref !== null && ref !== void 0 ? ref : "HEAD";
|
|
164
|
+
try {
|
|
165
|
+
console.log("Fetching ".concat(repoUrl, " ref \"").concat(fetchRef, "\" (sparse: ").concat(sparsePatterns.join(", "), ")..."));
|
|
166
|
+
(0, child_process_1.execFileSync)("git", ["-C", tmpDir, "fetch", "--depth", "1", "origin", fetchRef], { stdio: "pipe" });
|
|
167
|
+
(0, child_process_1.execFileSync)("git", ["-C", tmpDir, "checkout", "FETCH_HEAD"], { stdio: "pipe" });
|
|
168
|
+
}
|
|
169
|
+
catch (_b) {
|
|
170
|
+
console.log("Shallow fetch failed for ref \"".concat(fetchRef, "\"; falling back to full fetch..."));
|
|
171
|
+
(0, child_process_1.execFileSync)("git", ["-C", tmpDir, "fetch", "origin", fetchRef], { stdio: "pipe" });
|
|
172
|
+
(0, child_process_1.execFileSync)("git", ["-C", tmpDir, "checkout", "FETCH_HEAD"], { stdio: "pipe" });
|
|
173
|
+
}
|
|
174
|
+
return tmpDir;
|
|
175
|
+
}
|
|
176
|
+
function pathExists(p) {
|
|
177
|
+
try {
|
|
178
|
+
fs.lstatSync(p);
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
catch (_a) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
function isInternalMarkdown(mdPath) {
|
|
186
|
+
var _a;
|
|
187
|
+
var content;
|
|
188
|
+
try {
|
|
189
|
+
content = fs.readFileSync(mdPath, "utf-8");
|
|
190
|
+
}
|
|
191
|
+
catch (_b) {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
var match = content.match(/^---\n([\s\S]*?)\n---/);
|
|
195
|
+
if (!match) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
try {
|
|
199
|
+
var parsed = yaml.load(match[1]);
|
|
200
|
+
return ((_a = parsed === null || parsed === void 0 ? void 0 : parsed.metadata) === null || _a === void 0 ? void 0 : _a.internal) === true;
|
|
201
|
+
}
|
|
202
|
+
catch (_c) {
|
|
203
|
+
return false;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
function listFolders(directory, filterInternal) {
|
|
207
|
+
return fs
|
|
208
|
+
.readdirSync(directory)
|
|
209
|
+
.filter(function (entry) { return fs.statSync(path.join(directory, entry)).isDirectory(); })
|
|
210
|
+
.filter(function (folder) { return !filterInternal || !isInternalMarkdown(path.join(directory, folder, "SKILL.md")); })
|
|
211
|
+
.sort();
|
|
212
|
+
}
|
|
213
|
+
function listMarkdownFiles(directory, filterInternal) {
|
|
214
|
+
var results = [];
|
|
215
|
+
var walk = function (currentDir, relativePath) {
|
|
216
|
+
for (var _i = 0, _a = fs.readdirSync(currentDir); _i < _a.length; _i++) {
|
|
217
|
+
var entry = _a[_i];
|
|
218
|
+
var fullPath = path.join(currentDir, entry);
|
|
219
|
+
var relPath = relativePath ? path.join(relativePath, entry) : entry;
|
|
220
|
+
var stat = fs.statSync(fullPath);
|
|
221
|
+
if (stat.isDirectory()) {
|
|
222
|
+
walk(fullPath, relPath);
|
|
223
|
+
}
|
|
224
|
+
else if (stat.isFile() && entry.endsWith(".md")) {
|
|
225
|
+
if (!filterInternal || !isInternalMarkdown(fullPath)) {
|
|
226
|
+
results.push(relPath);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
};
|
|
231
|
+
walk(directory, "");
|
|
232
|
+
return results.sort();
|
|
233
|
+
}
|
|
234
|
+
function symlinkOrCopy(src, dest, symlink) {
|
|
235
|
+
if (symlink) {
|
|
236
|
+
try {
|
|
237
|
+
fs.symlinkSync(src, dest);
|
|
238
|
+
return "symlinked";
|
|
239
|
+
}
|
|
240
|
+
catch (err) {
|
|
241
|
+
if (err.code !== "EPERM") {
|
|
242
|
+
throw err;
|
|
243
|
+
}
|
|
244
|
+
// Windows without symlink privilege — fall back to copy
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
fs.cpSync(src, dest, { recursive: true });
|
|
248
|
+
return "copied";
|
|
249
|
+
}
|
|
250
|
+
function installItems(sources, targetDirs, _a) {
|
|
251
|
+
var dryRun = _a.dryRun;
|
|
252
|
+
var totalInstalled = 0;
|
|
253
|
+
for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) {
|
|
254
|
+
var source = sources_1[_i];
|
|
255
|
+
var label = source.label, directory = source.directory, discover = source.discover, symlink = source.symlink, filterInternal = source.filterInternal, installed = source.installed, itemLabelSingular = source.itemLabelSingular, itemLabelPlural = source.itemLabelPlural;
|
|
256
|
+
if (!fs.existsSync(directory)) {
|
|
257
|
+
console.log("No ".concat(itemLabelPlural, " found in ").concat(label));
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
260
|
+
var items = discover === "folders" ? listFolders(directory, filterInternal !== null && filterInternal !== void 0 ? filterInternal : false) : listMarkdownFiles(directory, filterInternal !== null && filterInternal !== void 0 ? filterInternal : false);
|
|
261
|
+
if (items.length === 0) {
|
|
262
|
+
console.log("No ".concat(itemLabelPlural, " found in ").concat(label));
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
console.log("Installing ".concat(items.length, " ").concat(items.length === 1 ? itemLabelSingular : itemLabelPlural, " from ").concat(label, "..."));
|
|
266
|
+
for (var _b = 0, items_1 = items; _b < items_1.length; _b++) {
|
|
267
|
+
var item = items_1[_b];
|
|
268
|
+
if (installed.has(item)) {
|
|
269
|
+
console.warn(" CONFLICT: \"".concat(item, "\" from ").concat(label, " skipped (already installed from a higher-priority source)"));
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
var srcPath = path.resolve(path.join(directory, item));
|
|
273
|
+
for (var _c = 0, targetDirs_1 = targetDirs; _c < targetDirs_1.length; _c++) {
|
|
274
|
+
var targetDir = targetDirs_1[_c];
|
|
275
|
+
var destPath = path.join(targetDir, item);
|
|
276
|
+
if (dryRun) {
|
|
277
|
+
console.log(" [dry-run] Would ".concat(symlink ? "symlink" : "copy", ": ").concat(srcPath, " -> ").concat(destPath));
|
|
278
|
+
}
|
|
279
|
+
else {
|
|
280
|
+
if (pathExists(destPath)) {
|
|
281
|
+
fs.rmSync(destPath, { recursive: true, force: true });
|
|
282
|
+
}
|
|
283
|
+
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
|
284
|
+
var action = symlinkOrCopy(srcPath, destPath, symlink);
|
|
285
|
+
console.log(" ".concat(action === "symlinked" ? "Symlinked" : "Copied", ": ").concat(item));
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
installed.add(item);
|
|
289
|
+
totalInstalled++;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return totalInstalled;
|
|
293
|
+
}
|
|
294
|
+
function loadConfig(configPath) {
|
|
295
|
+
var resolved = path.resolve(configPath);
|
|
296
|
+
if (!fs.existsSync(resolved)) {
|
|
297
|
+
throw new Error("Config file not found: ".concat(resolved));
|
|
298
|
+
}
|
|
299
|
+
var raw = fs.readFileSync(resolved, "utf-8");
|
|
300
|
+
return JSON.parse(raw);
|
|
301
|
+
}
|
|
302
|
+
function installFeatures(cwd, repos, options) {
|
|
303
|
+
var skillsTargetDirs = [path.join(cwd, ".agents", "skills"), path.join(cwd, ".claude", "skills")];
|
|
304
|
+
var rulesTargetDirs = [
|
|
305
|
+
path.join(cwd, ".agents", "rules"),
|
|
306
|
+
path.join(cwd, ".claude", "rules"),
|
|
307
|
+
path.join(cwd, ".cursor", "rules"),
|
|
308
|
+
path.join(cwd, ".github", "instructions"),
|
|
309
|
+
];
|
|
310
|
+
for (var _i = 0, _a = __spreadArray(__spreadArray([], skillsTargetDirs, true), rulesTargetDirs, true); _i < _a.length; _i++) {
|
|
311
|
+
var dir = _a[_i];
|
|
312
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
313
|
+
}
|
|
314
|
+
var installedSkills = new Set();
|
|
315
|
+
var installedRules = new Set();
|
|
316
|
+
var skillSources = SKILL_SOURCE_PATHS.map(function (p) { return ({
|
|
317
|
+
label: "local ".concat(p, "/"),
|
|
318
|
+
directory: path.join(cwd, p),
|
|
319
|
+
discover: "folders",
|
|
320
|
+
symlink: true,
|
|
321
|
+
installed: installedSkills,
|
|
322
|
+
itemLabelSingular: "skill",
|
|
323
|
+
itemLabelPlural: "skills",
|
|
324
|
+
}); });
|
|
325
|
+
var ruleSources = RULE_SOURCE_PATHS.map(function (p) { return ({
|
|
326
|
+
label: "local ".concat(p, "/"),
|
|
327
|
+
directory: path.join(cwd, p),
|
|
328
|
+
discover: "files",
|
|
329
|
+
symlink: true,
|
|
330
|
+
installed: installedRules,
|
|
331
|
+
itemLabelSingular: "rule",
|
|
332
|
+
itemLabelPlural: "rules",
|
|
333
|
+
}); });
|
|
334
|
+
// Discover skills/rules from node_modules (direct dependencies only, including @scoped packages)
|
|
335
|
+
var nodeModulesPackages = discoverNodeModulesPackages(cwd);
|
|
336
|
+
for (var _b = 0, nodeModulesPackages_1 = nodeModulesPackages; _b < nodeModulesPackages_1.length; _b++) {
|
|
337
|
+
var pkgDir = nodeModulesPackages_1[_b];
|
|
338
|
+
var pkgName = pkgDir.includes("".concat(path.sep, "@")) ? pkgDir.split(path.sep).slice(-2).join("/") : path.basename(pkgDir);
|
|
339
|
+
for (var _c = 0, SKILL_SOURCE_PATHS_1 = SKILL_SOURCE_PATHS; _c < SKILL_SOURCE_PATHS_1.length; _c++) {
|
|
340
|
+
var p = SKILL_SOURCE_PATHS_1[_c];
|
|
341
|
+
var dir = path.join(pkgDir, p);
|
|
342
|
+
if (fs.existsSync(dir)) {
|
|
343
|
+
skillSources.push({
|
|
344
|
+
label: "node_modules ".concat(pkgName, " (").concat(p, "/)"),
|
|
345
|
+
directory: dir,
|
|
346
|
+
discover: "folders",
|
|
347
|
+
symlink: true,
|
|
348
|
+
filterInternal: true,
|
|
349
|
+
installed: installedSkills,
|
|
350
|
+
itemLabelSingular: "skill",
|
|
351
|
+
itemLabelPlural: "skills",
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
for (var _d = 0, RULE_SOURCE_PATHS_1 = RULE_SOURCE_PATHS; _d < RULE_SOURCE_PATHS_1.length; _d++) {
|
|
356
|
+
var p = RULE_SOURCE_PATHS_1[_d];
|
|
357
|
+
var dir = path.join(pkgDir, p);
|
|
358
|
+
if (fs.existsSync(dir)) {
|
|
359
|
+
ruleSources.push({
|
|
360
|
+
label: "node_modules ".concat(pkgName, " (").concat(p, "/)"),
|
|
361
|
+
directory: dir,
|
|
362
|
+
discover: "files",
|
|
363
|
+
symlink: true,
|
|
364
|
+
filterInternal: true,
|
|
365
|
+
installed: installedRules,
|
|
366
|
+
itemLabelSingular: "rule",
|
|
367
|
+
itemLabelPlural: "rules",
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
var sparsePatterns = __spreadArray(__spreadArray([], SKILL_SOURCE_PATHS, true), RULE_SOURCE_PATHS, true).map(function (p) { return "".concat(p, "/"); });
|
|
373
|
+
var tempDirs = [];
|
|
374
|
+
try {
|
|
375
|
+
for (var _e = 0, repos_1 = repos; _e < repos_1.length; _e++) {
|
|
376
|
+
var rawUrl = repos_1[_e];
|
|
377
|
+
var cloneDir = cloneRepo(rawUrl, sparsePatterns);
|
|
378
|
+
tempDirs.push(cloneDir);
|
|
379
|
+
for (var _f = 0, SKILL_SOURCE_PATHS_2 = SKILL_SOURCE_PATHS; _f < SKILL_SOURCE_PATHS_2.length; _f++) {
|
|
380
|
+
var p = SKILL_SOURCE_PATHS_2[_f];
|
|
381
|
+
skillSources.push({
|
|
382
|
+
label: "external ".concat(rawUrl, " (").concat(p, "/)"),
|
|
383
|
+
directory: path.join(cloneDir, p),
|
|
384
|
+
discover: "folders",
|
|
385
|
+
symlink: false,
|
|
386
|
+
filterInternal: true,
|
|
387
|
+
installed: installedSkills,
|
|
388
|
+
itemLabelSingular: "skill",
|
|
389
|
+
itemLabelPlural: "skills",
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
for (var _g = 0, RULE_SOURCE_PATHS_2 = RULE_SOURCE_PATHS; _g < RULE_SOURCE_PATHS_2.length; _g++) {
|
|
393
|
+
var p = RULE_SOURCE_PATHS_2[_g];
|
|
394
|
+
ruleSources.push({
|
|
395
|
+
label: "external ".concat(rawUrl, " (").concat(p, "/)"),
|
|
396
|
+
directory: path.join(cloneDir, p),
|
|
397
|
+
discover: "files",
|
|
398
|
+
symlink: false,
|
|
399
|
+
filterInternal: true,
|
|
400
|
+
installed: installedRules,
|
|
401
|
+
itemLabelSingular: "rule",
|
|
402
|
+
itemLabelPlural: "rules",
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
var skillCount = installItems(skillSources, skillsTargetDirs, options);
|
|
407
|
+
var ruleCount = installItems(ruleSources, rulesTargetDirs, options);
|
|
408
|
+
console.log("\nTotal skills installed: ".concat(skillCount));
|
|
409
|
+
console.log("Total rules installed: ".concat(ruleCount));
|
|
410
|
+
}
|
|
411
|
+
finally {
|
|
412
|
+
for (var _h = 0, tempDirs_1 = tempDirs; _h < tempDirs_1.length; _h++) {
|
|
413
|
+
var tmpDir = tempDirs_1[_h];
|
|
414
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
exports.installAgentFeaturesCommand = new commander_1.Command("install-agent-features")
|
|
419
|
+
.description("Install agent features (skills and rules) from local directories and optional external git repos")
|
|
420
|
+
.option("--config <path>", "Path to a JSON config file specifying repos to install features from", "agent-features.json")
|
|
421
|
+
.option("--dry-run", "Show which symlinks/copies would be created without making changes", false)
|
|
422
|
+
.action(function (options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
423
|
+
var configPath, dryRun, resolvedConfig, repos;
|
|
424
|
+
var _a;
|
|
425
|
+
return __generator(this, function (_b) {
|
|
426
|
+
configPath = options.config, dryRun = options.dryRun;
|
|
427
|
+
resolvedConfig = path.resolve(configPath);
|
|
428
|
+
repos = fs.existsSync(resolvedConfig) ? ((_a = loadConfig(configPath).repos) !== null && _a !== void 0 ? _a : []) : [];
|
|
429
|
+
console.log("=== Installing agent features".concat(dryRun ? " (dry run)" : "", " ==="));
|
|
430
|
+
installFeatures(process.cwd(), repos, { dryRun: dryRun });
|
|
431
|
+
console.log("=== Finished ===");
|
|
432
|
+
return [2 /*return*/];
|
|
433
|
+
});
|
|
434
|
+
}); });
|