@comet/cli 9.0.0-beta.1 → 9.0.0-beta.3
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.
|
@@ -100,8 +100,9 @@ function writeFieldType(field, blockNamePostfix) {
|
|
|
100
100
|
content += "{\n";
|
|
101
101
|
field.object.fields.forEach(function (f) {
|
|
102
102
|
content += f.name;
|
|
103
|
-
if (f.nullable)
|
|
103
|
+
if (f.nullable) {
|
|
104
104
|
content += "?";
|
|
105
|
+
}
|
|
105
106
|
content += ": ";
|
|
106
107
|
writeFieldType(f, blockNamePostfix);
|
|
107
108
|
content += ";\n";
|
|
@@ -112,8 +113,9 @@ function writeFieldType(field, blockNamePostfix) {
|
|
|
112
113
|
content += "Array<{\n";
|
|
113
114
|
field.object.fields.forEach(function (f) {
|
|
114
115
|
content += f.name;
|
|
115
|
-
if (f.nullable)
|
|
116
|
+
if (f.nullable) {
|
|
116
117
|
content += "?";
|
|
118
|
+
}
|
|
117
119
|
content += ": ";
|
|
118
120
|
writeFieldType(f, blockNamePostfix);
|
|
119
121
|
content += ";\n";
|
|
@@ -146,8 +148,9 @@ var generateBlockTypes = new commander_1.Command("generate-block-types")
|
|
|
146
148
|
content += "export interface ".concat(block.name, "BlockData {\n");
|
|
147
149
|
block.fields.forEach(function (field) {
|
|
148
150
|
content += field.name;
|
|
149
|
-
if (field.nullable)
|
|
151
|
+
if (field.nullable) {
|
|
150
152
|
content += "?";
|
|
153
|
+
}
|
|
151
154
|
content += ": ";
|
|
152
155
|
writeFieldType(field, "BlockData");
|
|
153
156
|
content += ";\n";
|
|
@@ -159,8 +162,9 @@ var generateBlockTypes = new commander_1.Command("generate-block-types")
|
|
|
159
162
|
content += "export interface ".concat(block.name, "BlockInput {\n");
|
|
160
163
|
block.inputFields.forEach(function (field) {
|
|
161
164
|
content += field.name;
|
|
162
|
-
if (field.nullable)
|
|
165
|
+
if (field.nullable) {
|
|
163
166
|
content += "?";
|
|
167
|
+
}
|
|
164
168
|
content += ": ";
|
|
165
169
|
writeFieldType(field, "BlockInput");
|
|
166
170
|
content += ";\n";
|
|
@@ -86,17 +86,18 @@ function parseRepoUrl(rawUrl) {
|
|
|
86
86
|
}
|
|
87
87
|
return { repoUrl: rawUrl.slice(0, hashIndex), ref: rawUrl.slice(hashIndex + 1) || undefined };
|
|
88
88
|
}
|
|
89
|
+
var SKILL_SOURCE_PATHS = ["skills", "agentic-plugin/skills"];
|
|
89
90
|
function cloneRepo(rawUrl) {
|
|
90
91
|
var _a = parseRepoUrl(rawUrl), repoUrl = _a.repoUrl, ref = _a.ref;
|
|
91
92
|
var tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "comet-agent-skills-"));
|
|
92
|
-
// Use sparse checkout to fetch only the
|
|
93
|
+
// Use sparse checkout to fetch only the skill source folders
|
|
93
94
|
(0, child_process_1.execFileSync)("git", ["init", tmpDir], { stdio: "pipe" });
|
|
94
95
|
(0, child_process_1.execFileSync)("git", ["-C", tmpDir, "remote", "add", "origin", "--", repoUrl], { stdio: "pipe" });
|
|
95
96
|
(0, child_process_1.execFileSync)("git", ["-C", tmpDir, "config", "core.sparseCheckout", "true"], { stdio: "pipe" });
|
|
96
|
-
fs.writeFileSync(path.join(tmpDir, ".git", "info", "sparse-checkout"), "
|
|
97
|
+
fs.writeFileSync(path.join(tmpDir, ".git", "info", "sparse-checkout"), SKILL_SOURCE_PATHS.map(function (p) { return "".concat(p, "/\n"); }).join(""));
|
|
97
98
|
var fetchRef = ref !== null && ref !== void 0 ? ref : "HEAD";
|
|
98
99
|
try {
|
|
99
|
-
console.log("Fetching ".concat(repoUrl, " ref \"").concat(fetchRef, "\" (sparse,
|
|
100
|
+
console.log("Fetching ".concat(repoUrl, " ref \"").concat(fetchRef, "\" (sparse, ").concat(SKILL_SOURCE_PATHS.map(function (p) { return "".concat(p, "/"); }).join(", "), " only)..."));
|
|
100
101
|
(0, child_process_1.execFileSync)("git", ["-C", tmpDir, "fetch", "--depth", "1", "origin", fetchRef], { stdio: "pipe" });
|
|
101
102
|
(0, child_process_1.execFileSync)("git", ["-C", tmpDir, "checkout", "FETCH_HEAD"], { stdio: "pipe" });
|
|
102
103
|
}
|
|
@@ -127,8 +128,9 @@ function isInternalSkill(skillFolderPath) {
|
|
|
127
128
|
return false;
|
|
128
129
|
}
|
|
129
130
|
var frontmatterMatch = skillMdContent.match(/^---\n([\s\S]*?)\n---/);
|
|
130
|
-
if (!frontmatterMatch)
|
|
131
|
+
if (!frontmatterMatch) {
|
|
131
132
|
return false;
|
|
133
|
+
}
|
|
132
134
|
try {
|
|
133
135
|
var parsed = yaml.load(frontmatterMatch[1]);
|
|
134
136
|
return ((_a = parsed === null || parsed === void 0 ? void 0 : parsed.metadata) === null || _a === void 0 ? void 0 : _a.internal) === true;
|
|
@@ -139,8 +141,9 @@ function isInternalSkill(skillFolderPath) {
|
|
|
139
141
|
}
|
|
140
142
|
function listSkillFolders(directory, filterInternal) {
|
|
141
143
|
if (filterInternal === void 0) { filterInternal = false; }
|
|
142
|
-
if (!fs.existsSync(directory))
|
|
144
|
+
if (!fs.existsSync(directory)) {
|
|
143
145
|
return [];
|
|
146
|
+
}
|
|
144
147
|
return fs
|
|
145
148
|
.readdirSync(directory)
|
|
146
149
|
.filter(function (f) { return fs.statSync(path.join(directory, f)).isDirectory(); })
|
|
@@ -173,8 +176,9 @@ function installSkills(sources, targetDirs, _a) {
|
|
|
173
176
|
console.log(" [dry-run] Would ".concat(symlink ? "symlink" : "copy", ": ").concat(srcPath, " -> ").concat(destPath));
|
|
174
177
|
}
|
|
175
178
|
else {
|
|
176
|
-
if (exists)
|
|
179
|
+
if (exists) {
|
|
177
180
|
fs.rmSync(destPath, { recursive: true, force: true });
|
|
181
|
+
}
|
|
178
182
|
if (symlink) {
|
|
179
183
|
fs.symlinkSync(srcPath, destPath);
|
|
180
184
|
}
|
|
@@ -202,12 +206,12 @@ exports.installAgentSkillsCommand = new commander_1.Command("install-agent-skill
|
|
|
202
206
|
.option("--config <path>", "Path to a JSON config file specifying repos to install skills from", "agent-skills.json")
|
|
203
207
|
.option("--dry-run", "Show which symlinks/copies would be created without making changes", false)
|
|
204
208
|
.action(function (options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
205
|
-
var configPath, dryRun, resolvedConfig, repos, cwd, targetDirs, _i, targetDirs_2, dir, sources, tempDirs, _a, repos_1, rawUrl, cloneDir, _b, tempDirs_1, tmpDir;
|
|
206
|
-
var
|
|
207
|
-
return __generator(this, function (
|
|
209
|
+
var configPath, dryRun, resolvedConfig, repos, cwd, targetDirs, _i, targetDirs_2, dir, sources, tempDirs, _a, repos_1, rawUrl, cloneDir, _b, SKILL_SOURCE_PATHS_1, p, _c, tempDirs_1, tmpDir;
|
|
210
|
+
var _d;
|
|
211
|
+
return __generator(this, function (_e) {
|
|
208
212
|
configPath = options.config, dryRun = options.dryRun;
|
|
209
213
|
resolvedConfig = path.resolve(configPath);
|
|
210
|
-
repos = fs.existsSync(resolvedConfig) ? ((
|
|
214
|
+
repos = fs.existsSync(resolvedConfig) ? ((_d = loadConfig(configPath).repos) !== null && _d !== void 0 ? _d : []) : [];
|
|
211
215
|
console.log("=== Installing agent skills".concat(dryRun ? " (dry run)" : "", " ==="));
|
|
212
216
|
cwd = process.cwd();
|
|
213
217
|
targetDirs = [path.join(cwd, ".agents", "skills"), path.join(cwd, ".claude", "skills")];
|
|
@@ -216,25 +220,32 @@ exports.installAgentSkillsCommand = new commander_1.Command("install-agent-skill
|
|
|
216
220
|
dir = targetDirs_2[_i];
|
|
217
221
|
fs.mkdirSync(dir, { recursive: true });
|
|
218
222
|
}
|
|
219
|
-
sources =
|
|
223
|
+
sources = SKILL_SOURCE_PATHS.map(function (p) { return ({
|
|
224
|
+
label: "local ".concat(p, "/"),
|
|
225
|
+
directory: path.join(cwd, p),
|
|
226
|
+
symlink: true,
|
|
227
|
+
}); });
|
|
220
228
|
tempDirs = [];
|
|
221
229
|
try {
|
|
222
230
|
for (_a = 0, repos_1 = repos; _a < repos_1.length; _a++) {
|
|
223
231
|
rawUrl = repos_1[_a];
|
|
224
232
|
cloneDir = cloneRepo(rawUrl);
|
|
225
233
|
tempDirs.push(cloneDir);
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
234
|
+
for (_b = 0, SKILL_SOURCE_PATHS_1 = SKILL_SOURCE_PATHS; _b < SKILL_SOURCE_PATHS_1.length; _b++) {
|
|
235
|
+
p = SKILL_SOURCE_PATHS_1[_b];
|
|
236
|
+
sources.push({
|
|
237
|
+
label: "external ".concat(rawUrl, " (").concat(p, "/)"),
|
|
238
|
+
directory: path.join(cloneDir, p),
|
|
239
|
+
symlink: false,
|
|
240
|
+
filterInternal: true,
|
|
241
|
+
});
|
|
242
|
+
}
|
|
232
243
|
}
|
|
233
244
|
installSkills(sources, targetDirs, { dryRun: dryRun });
|
|
234
245
|
}
|
|
235
246
|
finally {
|
|
236
|
-
for (
|
|
237
|
-
tmpDir = tempDirs_1[
|
|
247
|
+
for (_c = 0, tempDirs_1 = tempDirs; _c < tempDirs_1.length; _c++) {
|
|
248
|
+
tmpDir = tempDirs_1[_c];
|
|
238
249
|
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
239
250
|
}
|
|
240
251
|
}
|
|
@@ -59,14 +59,16 @@ function mockFilesystem(skillMap, existingDests, skillMdContents) {
|
|
|
59
59
|
return { isDirectory: function () { return isDir; } };
|
|
60
60
|
});
|
|
61
61
|
vitest_1.vi.mocked(fs.lstatSync).mockImplementation(function (p) {
|
|
62
|
-
if (existingDests.includes(String(p)))
|
|
62
|
+
if (existingDests.includes(String(p))) {
|
|
63
63
|
return {};
|
|
64
|
+
}
|
|
64
65
|
throw Object.assign(new Error("ENOENT"), { code: "ENOENT" });
|
|
65
66
|
});
|
|
66
67
|
vitest_1.vi.mocked(fs.readFileSync).mockImplementation(function (p) {
|
|
67
68
|
var content = skillMdContents[String(p)];
|
|
68
|
-
if (content !== undefined)
|
|
69
|
+
if (content !== undefined) {
|
|
69
70
|
return content;
|
|
71
|
+
}
|
|
70
72
|
throw Object.assign(new Error("ENOENT"), { code: "ENOENT" });
|
|
71
73
|
});
|
|
72
74
|
}
|
|
@@ -116,7 +116,7 @@ exports.injectSiteConfigsCommand = new commander_1.Command("inject-site-configs"
|
|
|
116
116
|
.option("--base64", "use base64 encoding")
|
|
117
117
|
.option("-f, --site-config-file <file>", "Path to ts-file which provides a default export with (env: string) => SiteConfig[]")
|
|
118
118
|
.action(function (options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
119
|
-
var configFile, getSiteConfigs, str, getUrlFromDomain, replacerFunctions;
|
|
119
|
+
var configFile, getSiteConfigs, siteConfigsCache, getCachedSiteConfigs, str, getUrlFromDomain, replacerFunctions;
|
|
120
120
|
return __generator(this, function (_a) {
|
|
121
121
|
switch (_a.label) {
|
|
122
122
|
case 0:
|
|
@@ -124,6 +124,23 @@ exports.injectSiteConfigsCommand = new commander_1.Command("inject-site-configs"
|
|
|
124
124
|
return [4 /*yield*/, Promise.resolve("".concat(configFile)).then(function (s) { return __importStar(require(s)); })];
|
|
125
125
|
case 1:
|
|
126
126
|
getSiteConfigs = (_a.sent()).default;
|
|
127
|
+
siteConfigsCache = new Map();
|
|
128
|
+
getCachedSiteConfigs = function (env) { return __awaiter(void 0, void 0, void 0, function () {
|
|
129
|
+
var cached;
|
|
130
|
+
return __generator(this, function (_a) {
|
|
131
|
+
switch (_a.label) {
|
|
132
|
+
case 0:
|
|
133
|
+
cached = siteConfigsCache.get(env);
|
|
134
|
+
if (!!cached) return [3 /*break*/, 2];
|
|
135
|
+
return [4 /*yield*/, getSiteConfigs(env)];
|
|
136
|
+
case 1:
|
|
137
|
+
cached = _a.sent();
|
|
138
|
+
siteConfigsCache.set(env, cached);
|
|
139
|
+
_a.label = 2;
|
|
140
|
+
case 2: return [2 /*return*/, cached];
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
}); };
|
|
127
144
|
console.log("inject-site-configs: Replace site-configs in ".concat(options.inFile));
|
|
128
145
|
str = fs_1.default.readFileSync((0, path_1.resolve)(process.cwd(), options.inFile)).toString();
|
|
129
146
|
getUrlFromDomain = function (domain) {
|
|
@@ -151,7 +168,7 @@ exports.injectSiteConfigsCommand = new commander_1.Command("inject-site-configs"
|
|
|
151
168
|
var siteConfigs, ret;
|
|
152
169
|
return __generator(this, function (_a) {
|
|
153
170
|
switch (_a.label) {
|
|
154
|
-
case 0: return [4 /*yield*/,
|
|
171
|
+
case 0: return [4 /*yield*/, getCachedSiteConfigs(env)];
|
|
155
172
|
case 1:
|
|
156
173
|
siteConfigs = _a.sent();
|
|
157
174
|
console.log("inject-site-configs: - ".concat(substr, " (").concat(siteConfigs.length, " sites)"));
|
|
@@ -175,7 +192,7 @@ exports.injectSiteConfigsCommand = new commander_1.Command("inject-site-configs"
|
|
|
175
192
|
var siteConfigs, filteredSiteConfigs;
|
|
176
193
|
return __generator(this, function (_a) {
|
|
177
194
|
switch (_a.label) {
|
|
178
|
-
case 0: return [4 /*yield*/,
|
|
195
|
+
case 0: return [4 /*yield*/, getCachedSiteConfigs(env)];
|
|
179
196
|
case 1:
|
|
180
197
|
siteConfigs = _a.sent();
|
|
181
198
|
console.log("inject-site-domains: - ".concat(substr, " (").concat(siteConfigs.length, " sites)"));
|
|
@@ -199,8 +216,9 @@ exports.injectSiteConfigsCommand = new commander_1.Command("inject-site-configs"
|
|
|
199
216
|
}); });
|
|
200
217
|
var resolveOpReferences = function (input) {
|
|
201
218
|
var opRefs = input.match(/\{\{ op:\/\/[^ }]+ \}\}/g);
|
|
202
|
-
if (!opRefs)
|
|
219
|
+
if (!opRefs) {
|
|
203
220
|
return input;
|
|
221
|
+
}
|
|
204
222
|
try {
|
|
205
223
|
(0, child_process_1.execSync)("op --version", { stdio: "ignore" });
|
|
206
224
|
}
|
|
@@ -208,12 +226,17 @@ var resolveOpReferences = function (input) {
|
|
|
208
226
|
throw new Error("inject-site-configs: Config contains 1Password references (op://) but the 1Password CLI (op) is not installed. " +
|
|
209
227
|
"Install from https://developer.1password.com/docs/cli/");
|
|
210
228
|
}
|
|
229
|
+
var opCache = new Map();
|
|
211
230
|
var result = input;
|
|
212
231
|
for (var _i = 0, opRefs_1 = opRefs; _i < opRefs_1.length; _i++) {
|
|
213
232
|
var ref = opRefs_1[_i];
|
|
214
233
|
var opUri = ref.replace("{{ ", "").replace(" }}", "");
|
|
215
234
|
try {
|
|
216
|
-
var secret =
|
|
235
|
+
var secret = opCache.get(opUri);
|
|
236
|
+
if (!secret) {
|
|
237
|
+
secret = (0, child_process_1.execSync)("op read \"".concat(opUri, "\""), { encoding: "utf-8" }).trim();
|
|
238
|
+
opCache.set(opUri, secret);
|
|
239
|
+
}
|
|
217
240
|
console.log("inject-site-configs: - Resolved ".concat(ref));
|
|
218
241
|
result = result.replace(ref, secret);
|
|
219
242
|
}
|
|
@@ -14,10 +14,12 @@ var mockedExecSync = vitest_1.vi.mocked(child_process_1.execSync);
|
|
|
14
14
|
(0, vitest_1.describe)("resolveOpReferences", function () {
|
|
15
15
|
(0, vitest_1.it)("should resolve op:// references", function () {
|
|
16
16
|
mockedExecSync.mockImplementation(function (cmd) {
|
|
17
|
-
if (cmd === "op --version")
|
|
17
|
+
if (cmd === "op --version") {
|
|
18
18
|
return Buffer.from("2.0.0");
|
|
19
|
-
|
|
19
|
+
}
|
|
20
|
+
if (cmd === 'op read "op://vault/item/password"') {
|
|
20
21
|
return "resolved-secret\n";
|
|
22
|
+
}
|
|
21
23
|
return "";
|
|
22
24
|
});
|
|
23
25
|
var result = (0, site_configs_1.resolveOpReferences)('{"key":"{{ op://vault/item/password }}"}');
|
|
@@ -31,8 +33,9 @@ var mockedExecSync = vitest_1.vi.mocked(child_process_1.execSync);
|
|
|
31
33
|
});
|
|
32
34
|
(0, vitest_1.it)("should throw an error when op reference resolution fails", function () {
|
|
33
35
|
mockedExecSync.mockImplementation(function (cmd) {
|
|
34
|
-
if (cmd === "op --version")
|
|
36
|
+
if (cmd === "op --version") {
|
|
35
37
|
return Buffer.from("2.0.0");
|
|
38
|
+
}
|
|
36
39
|
if (cmd === 'op read "op://vault/item/password"') {
|
|
37
40
|
throw new Error("Item not found");
|
|
38
41
|
}
|
|
@@ -42,14 +45,18 @@ var mockedExecSync = vitest_1.vi.mocked(child_process_1.execSync);
|
|
|
42
45
|
});
|
|
43
46
|
(0, vitest_1.it)("should resolve multiple op:// references", function () {
|
|
44
47
|
mockedExecSync.mockImplementation(function (cmd) {
|
|
45
|
-
if (cmd === "op --version")
|
|
48
|
+
if (cmd === "op --version") {
|
|
46
49
|
return Buffer.from("2.0.0");
|
|
47
|
-
|
|
50
|
+
}
|
|
51
|
+
if (cmd === 'op read "op://vault/item/api-key"') {
|
|
48
52
|
return "resolved-api-key\n";
|
|
49
|
-
|
|
53
|
+
}
|
|
54
|
+
if (cmd === 'op read "op://vault/item/api-secret"') {
|
|
50
55
|
return "resolved-api-secret\n";
|
|
51
|
-
|
|
56
|
+
}
|
|
57
|
+
if (cmd === 'op read "op://vault/database/password"') {
|
|
52
58
|
return "resolved-db-password\n";
|
|
59
|
+
}
|
|
53
60
|
return "";
|
|
54
61
|
});
|
|
55
62
|
var result = (0, site_configs_1.resolveOpReferences)('{"apiKey":"{{ op://vault/item/api-key }}","apiSecret":"{{ op://vault/item/api-secret }}","dbPassword":"{{ op://vault/database/password }}"}');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comet/cli",
|
|
3
|
-
"version": "9.0.0-beta.
|
|
3
|
+
"version": "9.0.0-beta.3",
|
|
4
4
|
"description": "A collection of CLI tools for Comet projects",
|
|
5
5
|
"repository": {
|
|
6
6
|
"directory": "packages/cli",
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"commander": "^9.5.0",
|
|
23
|
-
"js-yaml": "^4.1.
|
|
23
|
+
"js-yaml": "^4.1.1",
|
|
24
24
|
"prettier": "^3.6.2",
|
|
25
25
|
"ts-node": "^10.9.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@types/js-yaml": "^4.0.9",
|
|
29
|
-
"@types/node": "^24.12.
|
|
29
|
+
"@types/node": "^24.12.2",
|
|
30
30
|
"eslint": "^9.39.2",
|
|
31
31
|
"npm-run-all2": "^8.0.4",
|
|
32
32
|
"rimraf": "^6.1.2",
|
|
33
33
|
"typescript": "^5.9.3",
|
|
34
34
|
"vitest": "^4.0.16",
|
|
35
|
-
"@comet/eslint-config": "9.0.0-beta.
|
|
35
|
+
"@comet/eslint-config": "9.0.0-beta.3"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=22.0.0"
|
|
@@ -48,6 +48,9 @@
|
|
|
48
48
|
"lint": "run-p lint:prettier lint:eslint lint:tsc",
|
|
49
49
|
"lint:ci": "pnpm run lint",
|
|
50
50
|
"lint:eslint": "eslint --max-warnings 0 src/ '**/*.json' --no-warn-ignored",
|
|
51
|
+
"lint:fix": "run-p lint:fix:eslint lint:fix:prettier",
|
|
52
|
+
"lint:fix:eslint": "pnpm run lint:eslint --fix",
|
|
53
|
+
"lint:fix:prettier": "pnpm run lint:prettier --write",
|
|
51
54
|
"lint:prettier": "pnpm exec prettier --check '*.{ts,js,json,md,yml,yaml}'",
|
|
52
55
|
"lint:tsc": "tsc",
|
|
53
56
|
"test": "vitest --run",
|