@comet/cli 9.0.0-beta.2 → 9.0.0-beta.4

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.
@@ -1,278 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
36
- /* eslint-disable no-console */
37
- var fs = __importStar(require("fs"));
38
- var path = __importStar(require("path"));
39
- var vitest_1 = require("vitest");
40
- var install_agent_skills_1 = require("./install-agent-skills");
41
- vitest_1.vi.mock("fs");
42
- var defaultOptions = { dryRun: false };
43
- var targetDirs = [".agents/skills", ".claude/skills"];
44
- /**
45
- * Sets up fs mocks so that each key in skillMap is a readable directory
46
- * containing the listed skill folder names. Destination paths do not exist
47
- * unless listed under a target dir key.
48
- */
49
- function mockFilesystem(skillMap, existingDests, skillMdContents) {
50
- if (existingDests === void 0) { existingDests = []; }
51
- if (skillMdContents === void 0) { skillMdContents = {}; }
52
- vitest_1.vi.mocked(fs.existsSync).mockImplementation(function (p) { return String(p) in skillMap; });
53
- vitest_1.vi.mocked(fs.readdirSync).mockImplementation(function (p) { var _a; return (_a = skillMap[String(p)]) !== null && _a !== void 0 ? _a : []; });
54
- vitest_1.vi.mocked(fs.statSync).mockImplementation(function (p) {
55
- var _a;
56
- var parentDir = path.dirname(String(p));
57
- var name = path.basename(String(p));
58
- var isDir = ((_a = skillMap[parentDir]) !== null && _a !== void 0 ? _a : []).includes(name);
59
- return { isDirectory: function () { return isDir; } };
60
- });
61
- vitest_1.vi.mocked(fs.lstatSync).mockImplementation(function (p) {
62
- if (existingDests.includes(String(p)))
63
- return {};
64
- throw Object.assign(new Error("ENOENT"), { code: "ENOENT" });
65
- });
66
- vitest_1.vi.mocked(fs.readFileSync).mockImplementation(function (p) {
67
- var content = skillMdContents[String(p)];
68
- if (content !== undefined)
69
- return content;
70
- throw Object.assign(new Error("ENOENT"), { code: "ENOENT" });
71
- });
72
- }
73
- (0, vitest_1.beforeEach)(function () {
74
- vitest_1.vi.mocked(fs.symlinkSync).mockImplementation(function () { return undefined; });
75
- vitest_1.vi.mocked(fs.cpSync).mockImplementation(function () { return undefined; });
76
- vitest_1.vi.mocked(fs.rmSync).mockImplementation(function () { return undefined; });
77
- vitest_1.vi.mocked(fs.readFileSync).mockImplementation(function () {
78
- throw Object.assign(new Error("ENOENT"), { code: "ENOENT" });
79
- });
80
- vitest_1.vi.spyOn(console, "log").mockImplementation(function () { return undefined; });
81
- vitest_1.vi.spyOn(console, "warn").mockImplementation(function () { return undefined; });
82
- });
83
- (0, vitest_1.afterEach)(function () {
84
- vitest_1.vi.clearAllMocks();
85
- vitest_1.vi.restoreAllMocks();
86
- });
87
- (0, vitest_1.describe)("installSkills – symlink vs copy", function () {
88
- (0, vitest_1.it)("symlinks skill folders into target folder if symlink: true", function () {
89
- mockFilesystem({ "/local/skills": ["my-skill"] });
90
- var sources = [{ label: "local skills/", directory: "/local/skills", symlink: true }];
91
- (0, install_agent_skills_1.installSkills)(sources, targetDirs, defaultOptions);
92
- (0, vitest_1.expect)(fs.symlinkSync).toHaveBeenCalledTimes(2);
93
- (0, vitest_1.expect)(fs.symlinkSync).toHaveBeenCalledWith(path.resolve("/local/skills/my-skill"), ".agents/skills/my-skill");
94
- (0, vitest_1.expect)(fs.symlinkSync).toHaveBeenCalledWith(path.resolve("/local/skills/my-skill"), ".claude/skills/my-skill");
95
- (0, vitest_1.expect)(fs.cpSync).not.toHaveBeenCalled();
96
- });
97
- (0, vitest_1.it)("copies skill folders into target folder if symlink: false", function () {
98
- mockFilesystem({ "/remote/skills": ["remote-skill"] });
99
- var sources = [{ label: "external repo", directory: "/remote/skills", symlink: false }];
100
- (0, install_agent_skills_1.installSkills)(sources, targetDirs, defaultOptions);
101
- (0, vitest_1.expect)(fs.cpSync).toHaveBeenCalledTimes(2);
102
- (0, vitest_1.expect)(fs.cpSync).toHaveBeenCalledWith(path.resolve("/remote/skills/remote-skill"), ".agents/skills/remote-skill", {
103
- recursive: true,
104
- });
105
- (0, vitest_1.expect)(fs.symlinkSync).not.toHaveBeenCalled();
106
- });
107
- (0, vitest_1.it)("ignores files in the source directory, only installs subdirectories", function () {
108
- mockFilesystem({ "/local/skills": ["real-skill"] });
109
- // statSync returns isDirectory: false for "not-a-skill.md" (not in the skillMap)
110
- vitest_1.vi.mocked(fs.readdirSync).mockImplementation(function () { return ["real-skill", "not-a-skill.md"]; });
111
- var sources = [{ label: "local skills/", directory: "/local/skills", symlink: true }];
112
- (0, install_agent_skills_1.installSkills)(sources, targetDirs, defaultOptions);
113
- (0, vitest_1.expect)(fs.symlinkSync).toHaveBeenCalledTimes(2);
114
- (0, vitest_1.expect)(fs.symlinkSync).toHaveBeenCalledWith(path.resolve("/local/skills/real-skill"), vitest_1.expect.any(String));
115
- (0, vitest_1.expect)(fs.symlinkSync).not.toHaveBeenCalledWith(path.resolve("/local/skills/not-a-skill.md"), vitest_1.expect.any(String));
116
- });
117
- });
118
- (0, vitest_1.describe)("installSkills – missing source directory", function () {
119
- (0, vitest_1.it)("logs 'No skills found' and does nothing when source directory does not exist", function () {
120
- mockFilesystem({}); // existsSync returns false for all paths
121
- var sources = [{ label: "local skills/", directory: "/local/skills", symlink: true }];
122
- (0, install_agent_skills_1.installSkills)(sources, targetDirs, defaultOptions);
123
- (0, vitest_1.expect)(fs.symlinkSync).not.toHaveBeenCalled();
124
- (0, vitest_1.expect)(fs.cpSync).not.toHaveBeenCalled();
125
- (0, vitest_1.expect)(console.log).toHaveBeenCalledWith(vitest_1.expect.stringContaining("No skills found"));
126
- });
127
- (0, vitest_1.it)("logs 'No skills found' and does nothing when source directory is empty", function () {
128
- mockFilesystem({ "/local/skills": [] }); // dir exists but has no entries
129
- var sources = [{ label: "local skills/", directory: "/local/skills", symlink: true }];
130
- (0, install_agent_skills_1.installSkills)(sources, targetDirs, defaultOptions);
131
- (0, vitest_1.expect)(fs.symlinkSync).not.toHaveBeenCalled();
132
- (0, vitest_1.expect)(fs.cpSync).not.toHaveBeenCalled();
133
- (0, vitest_1.expect)(console.log).toHaveBeenCalledWith(vitest_1.expect.stringContaining("No skills found"));
134
- });
135
- (0, vitest_1.it)("logs 'No skills found' and does nothing when cloned external repo has no skills/ folder", function () {
136
- mockFilesystem({}); // cloned tmp dir exists but contains no skills/ subdirectory
137
- var sources = [
138
- { label: "external git@github.com:org/repo.git (skills/)", directory: "/tmp/cloned-repo/skills", symlink: false },
139
- ];
140
- (0, install_agent_skills_1.installSkills)(sources, targetDirs, defaultOptions);
141
- (0, vitest_1.expect)(fs.cpSync).not.toHaveBeenCalled();
142
- (0, vitest_1.expect)(console.log).toHaveBeenCalledWith(vitest_1.expect.stringContaining("No skills found"));
143
- });
144
- });
145
- (0, vitest_1.describe)("installSkills – dry-run mode", function () {
146
- (0, vitest_1.it)("does not write any files or symlinks", function () {
147
- mockFilesystem({ "/local/skills": ["my-skill"] });
148
- var sources = [{ label: "local skills/", directory: "/local/skills", symlink: true }];
149
- (0, install_agent_skills_1.installSkills)(sources, targetDirs, { dryRun: true });
150
- (0, vitest_1.expect)(fs.symlinkSync).not.toHaveBeenCalled();
151
- (0, vitest_1.expect)(fs.cpSync).not.toHaveBeenCalled();
152
- (0, vitest_1.expect)(fs.rmSync).not.toHaveBeenCalled();
153
- });
154
- (0, vitest_1.it)("logs what would be symlinked", function () {
155
- mockFilesystem({ "/local/skills": ["my-skill"] });
156
- var sources = [{ label: "local skills/", directory: "/local/skills", symlink: true }];
157
- (0, install_agent_skills_1.installSkills)(sources, targetDirs, { dryRun: true });
158
- (0, vitest_1.expect)(console.log).toHaveBeenCalledWith(vitest_1.expect.stringContaining("[dry-run] Would symlink: ".concat(path.resolve("/local/skills/my-skill"))));
159
- });
160
- (0, vitest_1.it)("logs what would be copied for external sources", function () {
161
- mockFilesystem({ "/remote/skills": ["remote-skill"] });
162
- var sources = [{ label: "external repo", directory: "/remote/skills", symlink: false }];
163
- (0, install_agent_skills_1.installSkills)(sources, targetDirs, { dryRun: true });
164
- (0, vitest_1.expect)(console.log).toHaveBeenCalledWith(vitest_1.expect.stringContaining("[dry-run] Would copy: ".concat(path.resolve("/remote/skills/remote-skill"))));
165
- });
166
- });
167
- (0, vitest_1.describe)("installSkills – overwrites existing destinations", function () {
168
- (0, vitest_1.it)("removes existing destination before writing", function () {
169
- mockFilesystem({ "/local/skills": ["my-skill"] }, [".agents/skills/my-skill", ".claude/skills/my-skill"]);
170
- var sources = [{ label: "local skills/", directory: "/local/skills", symlink: true }];
171
- (0, install_agent_skills_1.installSkills)(sources, targetDirs, defaultOptions);
172
- (0, vitest_1.expect)(fs.rmSync).toHaveBeenCalledWith(".agents/skills/my-skill", { recursive: true, force: true });
173
- (0, vitest_1.expect)(fs.rmSync).toHaveBeenCalledWith(".claude/skills/my-skill", { recursive: true, force: true });
174
- (0, vitest_1.expect)(fs.symlinkSync).toHaveBeenCalledTimes(2);
175
- });
176
- });
177
- (0, vitest_1.describe)("installSkills – conflict: local vs remote", function () {
178
- (0, vitest_1.it)("local skill wins: symlinks local, skips remote with a CONFLICT warning", function () {
179
- mockFilesystem({
180
- "/local/skills": ["shared-skill"],
181
- "/remote/skills": ["shared-skill"],
182
- });
183
- var sources = [
184
- { label: "local skills/", directory: "/local/skills", symlink: true },
185
- { label: "external repo", directory: "/remote/skills", symlink: false },
186
- ];
187
- (0, install_agent_skills_1.installSkills)(sources, targetDirs, defaultOptions);
188
- (0, vitest_1.expect)(fs.symlinkSync).toHaveBeenCalled();
189
- (0, vitest_1.expect)(fs.cpSync).not.toHaveBeenCalled();
190
- (0, vitest_1.expect)(console.warn).toHaveBeenCalledWith(vitest_1.expect.stringContaining('CONFLICT: "shared-skill"'));
191
- (0, vitest_1.expect)(console.warn).toHaveBeenCalledWith(vitest_1.expect.stringContaining("external repo"));
192
- });
193
- });
194
- (0, vitest_1.describe)("installSkills – conflict: remote vs remote", function () {
195
- (0, vitest_1.it)("first remote wins: copies remote1 skill, skips remote2 with a CONFLICT warning", function () {
196
- mockFilesystem({
197
- "/remote1/skills": ["shared-skill"],
198
- "/remote2/skills": ["shared-skill"],
199
- });
200
- var sources = [
201
- { label: "external repo1", directory: "/remote1/skills", symlink: false },
202
- { label: "external repo2", directory: "/remote2/skills", symlink: false },
203
- ];
204
- (0, install_agent_skills_1.installSkills)(sources, targetDirs, defaultOptions);
205
- // Only 2 calls (one per target dir from remote1), not 4
206
- (0, vitest_1.expect)(fs.cpSync).toHaveBeenCalledTimes(2);
207
- (0, vitest_1.expect)(fs.cpSync).toHaveBeenCalledWith(path.resolve("/remote1/skills/shared-skill"), vitest_1.expect.any(String), { recursive: true });
208
- (0, vitest_1.expect)(fs.cpSync).not.toHaveBeenCalledWith(path.resolve("/remote2/skills/shared-skill"), vitest_1.expect.any(String), vitest_1.expect.any(Object));
209
- (0, vitest_1.expect)(console.warn).toHaveBeenCalledWith(vitest_1.expect.stringContaining('CONFLICT: "shared-skill"'));
210
- (0, vitest_1.expect)(console.warn).toHaveBeenCalledWith(vitest_1.expect.stringContaining("external repo2"));
211
- });
212
- });
213
- (0, vitest_1.describe)("isInternalSkill", function () {
214
- (0, vitest_1.it)("returns true when metadata.internal is true", function () {
215
- mockFilesystem({}, [], { "/skills/my-skill/SKILL.md": "---\nmetadata:\n internal: true\n---\n# My Skill" });
216
- (0, vitest_1.expect)((0, install_agent_skills_1.isInternalSkill)("/skills/my-skill")).toBe(true);
217
- });
218
- (0, vitest_1.it)("returns false when metadata.internal is false", function () {
219
- mockFilesystem({}, [], { "/skills/my-skill/SKILL.md": "---\nmetadata:\n internal: false\n---\n# My Skill" });
220
- (0, vitest_1.expect)((0, install_agent_skills_1.isInternalSkill)("/skills/my-skill")).toBe(false);
221
- });
222
- (0, vitest_1.it)("returns false when frontmatter has no metadata field", function () {
223
- mockFilesystem({}, [], { "/skills/my-skill/SKILL.md": "---\ntitle: My Skill\n---\n# My Skill" });
224
- (0, vitest_1.expect)((0, install_agent_skills_1.isInternalSkill)("/skills/my-skill")).toBe(false);
225
- });
226
- (0, vitest_1.it)("returns false when SKILL.md has no frontmatter", function () {
227
- mockFilesystem({}, [], { "/skills/my-skill/SKILL.md": "# My Skill\nJust plain markdown, no frontmatter." });
228
- (0, vitest_1.expect)((0, install_agent_skills_1.isInternalSkill)("/skills/my-skill")).toBe(false);
229
- });
230
- (0, vitest_1.it)("returns false when SKILL.md does not exist", function () {
231
- mockFilesystem({}, [], {});
232
- (0, vitest_1.expect)((0, install_agent_skills_1.isInternalSkill)("/skills/my-skill")).toBe(false);
233
- });
234
- (0, vitest_1.it)("returns false when SKILL.md frontmatter contains malformed YAML", function () {
235
- mockFilesystem({}, [], { "/skills/my-skill/SKILL.md": "---\n: invalid: yaml: [\n---\n# My Skill" });
236
- (0, vitest_1.expect)((0, install_agent_skills_1.isInternalSkill)("/skills/my-skill")).toBe(false);
237
- });
238
- });
239
- (0, vitest_1.describe)("installSkills – filterInternal", function () {
240
- (0, vitest_1.it)("excludes internal skills when filterInternal: true, installs only non-internal skills", function () {
241
- mockFilesystem({ "/remote/skills": ["public-skill", "internal-skill"] }, [], {
242
- "/remote/skills/internal-skill/SKILL.md": "---\nmetadata:\n internal: true\n---\n# Internal Skill",
243
- });
244
- var sources = [{ label: "external repo (skills/)", directory: "/remote/skills", symlink: false, filterInternal: true }];
245
- (0, install_agent_skills_1.installSkills)(sources, targetDirs, defaultOptions);
246
- (0, vitest_1.expect)(fs.cpSync).toHaveBeenCalledTimes(2);
247
- (0, vitest_1.expect)(fs.cpSync).toHaveBeenCalledWith(path.resolve("/remote/skills/public-skill"), vitest_1.expect.any(String), { recursive: true });
248
- (0, vitest_1.expect)(fs.cpSync).not.toHaveBeenCalledWith(path.resolve("/remote/skills/internal-skill"), vitest_1.expect.any(String), vitest_1.expect.any(Object));
249
- });
250
- (0, vitest_1.it)("installs all skills including internal ones when filterInternal is omitted", function () {
251
- mockFilesystem({ "/local/skills": ["public-skill", "internal-skill"] }, [], {
252
- "/local/skills/internal-skill/SKILL.md": "---\nmetadata:\n internal: true\n---\n# Internal Skill",
253
- });
254
- var sources = [{ label: "local skills/", directory: "/local/skills", symlink: true }];
255
- (0, install_agent_skills_1.installSkills)(sources, targetDirs, defaultOptions);
256
- (0, vitest_1.expect)(fs.symlinkSync).toHaveBeenCalledTimes(4);
257
- (0, vitest_1.expect)(fs.symlinkSync).toHaveBeenCalledWith(path.resolve("/local/skills/public-skill"), vitest_1.expect.any(String));
258
- (0, vitest_1.expect)(fs.symlinkSync).toHaveBeenCalledWith(path.resolve("/local/skills/internal-skill"), vitest_1.expect.any(String));
259
- });
260
- (0, vitest_1.it)("logs 'No skills found' when filterInternal: true and all skills are internal", function () {
261
- mockFilesystem({ "/remote/skills": ["internal-skill"] }, [], {
262
- "/remote/skills/internal-skill/SKILL.md": "---\nmetadata:\n internal: true\n---\n# Internal Skill",
263
- });
264
- var sources = [{ label: "external repo (skills/)", directory: "/remote/skills", symlink: false, filterInternal: true }];
265
- (0, install_agent_skills_1.installSkills)(sources, targetDirs, defaultOptions);
266
- (0, vitest_1.expect)(fs.cpSync).not.toHaveBeenCalled();
267
- (0, vitest_1.expect)(console.log).toHaveBeenCalledWith(vitest_1.expect.stringContaining("No skills found"));
268
- });
269
- (0, vitest_1.it)("excludes internal skills from dry-run output when filterInternal: true", function () {
270
- mockFilesystem({ "/remote/skills": ["public-skill", "internal-skill"] }, [], {
271
- "/remote/skills/internal-skill/SKILL.md": "---\nmetadata:\n internal: true\n---\n# Internal Skill",
272
- });
273
- var sources = [{ label: "external repo (skills/)", directory: "/remote/skills", symlink: false, filterInternal: true }];
274
- (0, install_agent_skills_1.installSkills)(sources, targetDirs, { dryRun: true });
275
- (0, vitest_1.expect)(console.log).toHaveBeenCalledWith(vitest_1.expect.stringContaining("public-skill"));
276
- (0, vitest_1.expect)(console.log).not.toHaveBeenCalledWith(vitest_1.expect.stringContaining("internal-skill"));
277
- });
278
- });