@camunda8/cli 4.7.0-alpha.20 → 4.7.0-alpha.22

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.
Files changed (91) hide show
  1. package/PLUGIN-HELP.md +1 -1
  2. package/README.md +0 -3
  3. package/dist/command-dispatch.d.ts.map +1 -1
  4. package/dist/command-dispatch.js +0 -8
  5. package/dist/command-dispatch.js.map +1 -1
  6. package/dist/commands/run.d.ts +0 -5
  7. package/dist/commands/run.d.ts.map +1 -1
  8. package/dist/commands/run.js +1 -9
  9. package/dist/commands/run.js.map +1 -1
  10. package/dist/core/errors.d.ts +17 -0
  11. package/dist/core/errors.d.ts.map +1 -1
  12. package/dist/core/errors.js +32 -0
  13. package/dist/core/errors.js.map +1 -1
  14. package/dist/default-plugins/modeler/README.md +12 -0
  15. package/dist/default-plugins/modeler/c8ctl-plugin.js +3042 -0
  16. package/dist/default-plugins/modeler/package.json +8 -0
  17. package/dist/default-plugins/setup/README.md +36 -0
  18. package/dist/default-plugins/setup/c8ctl-plugin.js +6423 -0
  19. package/dist/default-plugins/setup/package.json +8 -0
  20. package/dist/default-plugins/skills/README.md +27 -0
  21. package/dist/default-plugins/skills/c8ctl-plugin.js +985 -0
  22. package/dist/default-plugins/skills/package.json +8 -0
  23. package/dist/framework/argv-parser.d.ts +14 -0
  24. package/dist/framework/argv-parser.d.ts.map +1 -1
  25. package/dist/framework/argv-parser.js +25 -0
  26. package/dist/framework/argv-parser.js.map +1 -1
  27. package/dist/framework/command-registry.d.ts +0 -76
  28. package/dist/framework/command-registry.d.ts.map +1 -1
  29. package/dist/framework/command-registry.js +0 -161
  30. package/dist/framework/command-registry.js.map +1 -1
  31. package/dist/framework/plugins/plugin-loader.d.ts +20 -2
  32. package/dist/framework/plugins/plugin-loader.d.ts.map +1 -1
  33. package/dist/framework/plugins/plugin-loader.js.map +1 -1
  34. package/dist/framework/ui/help.d.ts.map +1 -1
  35. package/dist/framework/ui/help.js +26 -13
  36. package/dist/framework/ui/help.js.map +1 -1
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +64 -11
  39. package/dist/index.js.map +1 -1
  40. package/dist/utils/command-local/mcp-install-helpers.d.ts +17 -0
  41. package/dist/utils/command-local/mcp-install-helpers.d.ts.map +1 -1
  42. package/dist/utils/command-local/mcp-install-helpers.js +23 -9
  43. package/dist/utils/command-local/mcp-install-helpers.js.map +1 -1
  44. package/dist/utils/command-local/process-instance-helpers.d.ts +6 -0
  45. package/dist/utils/command-local/process-instance-helpers.d.ts.map +1 -1
  46. package/dist/utils/command-local/process-instance-helpers.js +9 -0
  47. package/dist/utils/command-local/process-instance-helpers.js.map +1 -1
  48. package/dist/utils/command-local/skills-install-helpers.d.ts.map +1 -1
  49. package/dist/utils/command-local/skills-install-helpers.js +99 -1
  50. package/dist/utils/command-local/skills-install-helpers.js.map +1 -1
  51. package/dist/utils/index.d.ts +0 -6
  52. package/dist/utils/index.d.ts.map +1 -1
  53. package/dist/utils/index.js +0 -6
  54. package/dist/utils/index.js.map +1 -1
  55. package/package.json +1 -1
  56. package/dist/commands/modeler.d.ts +0 -10
  57. package/dist/commands/modeler.d.ts.map +0 -1
  58. package/dist/commands/modeler.js +0 -604
  59. package/dist/commands/modeler.js.map +0 -1
  60. package/dist/commands/setup.d.ts +0 -39
  61. package/dist/commands/setup.d.ts.map +0 -1
  62. package/dist/commands/setup.js +0 -856
  63. package/dist/commands/setup.js.map +0 -1
  64. package/dist/commands/skills.d.ts +0 -2
  65. package/dist/commands/skills.d.ts.map +0 -1
  66. package/dist/commands/skills.js +0 -38
  67. package/dist/commands/skills.js.map +0 -1
  68. package/dist/utils/command-local/blueprint-scaffold.d.ts +0 -151
  69. package/dist/utils/command-local/blueprint-scaffold.d.ts.map +0 -1
  70. package/dist/utils/command-local/blueprint-scaffold.js +0 -547
  71. package/dist/utils/command-local/blueprint-scaffold.js.map +0 -1
  72. package/dist/utils/command-local/modeler-helpers.d.ts +0 -15
  73. package/dist/utils/command-local/modeler-helpers.d.ts.map +0 -1
  74. package/dist/utils/command-local/modeler-helpers.js +0 -67
  75. package/dist/utils/command-local/modeler-helpers.js.map +0 -1
  76. package/dist/utils/command-local/setup-detectors.d.ts +0 -51
  77. package/dist/utils/command-local/setup-detectors.d.ts.map +0 -1
  78. package/dist/utils/command-local/setup-detectors.js +0 -115
  79. package/dist/utils/command-local/setup-detectors.js.map +0 -1
  80. package/dist/utils/command-local/setup-helpers.d.ts +0 -179
  81. package/dist/utils/command-local/setup-helpers.d.ts.map +0 -1
  82. package/dist/utils/command-local/setup-helpers.js +0 -374
  83. package/dist/utils/command-local/setup-helpers.js.map +0 -1
  84. package/dist/utils/command-local/setup-prerequisites.d.ts +0 -67
  85. package/dist/utils/command-local/setup-prerequisites.d.ts.map +0 -1
  86. package/dist/utils/command-local/setup-prerequisites.js +0 -238
  87. package/dist/utils/command-local/setup-prerequisites.js.map +0 -1
  88. package/dist/utils/command-local/setup-removal.d.ts +0 -37
  89. package/dist/utils/command-local/setup-removal.d.ts.map +0 -1
  90. package/dist/utils/command-local/setup-removal.js +0 -82
  91. package/dist/utils/command-local/setup-removal.js.map +0 -1
@@ -0,0 +1,985 @@
1
+ // src/core/config.ts
2
+ import { homedir, platform } from "node:os";
3
+
4
+ // src/core/runtime.ts
5
+ import { readFileSync } from "node:fs";
6
+ import { dirname, join } from "node:path";
7
+ import { fileURLToPath } from "node:url";
8
+ var __filename = fileURLToPath(import.meta.url);
9
+ var __dirname = dirname(__filename);
10
+ var UNVERSIONED_DEV_BUILD = "0.0.0-semantically-released";
11
+ function getVersion() {
12
+ try {
13
+ const packageJsonPath = join(__dirname, "..", "..", "package.json");
14
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
15
+ return packageJson.version || UNVERSIONED_DEV_BUILD;
16
+ } catch {
17
+ return UNVERSIONED_DEV_BUILD;
18
+ }
19
+ }
20
+ var C8ctl = class {
21
+ _activeProfile;
22
+ _activeTenant;
23
+ _outputMode = "text";
24
+ _fields;
25
+ _dryRun;
26
+ _verbose;
27
+ _quiet;
28
+ _resolvedBaseUrl;
29
+ _deps;
30
+ env = {
31
+ version: getVersion(),
32
+ nodeVersion: process.version,
33
+ platform: process.platform,
34
+ arch: process.arch,
35
+ cwd: process.cwd(),
36
+ rootDir: join(__dirname, "..", "..")
37
+ };
38
+ /**
39
+ * Inject dependencies that cannot be imported at module level
40
+ * due to circular imports. Must be called once during startup,
41
+ * before any plugin or command accesses createClient/resolveTenantId/getLogger.
42
+ */
43
+ init(deps) {
44
+ if (this._deps) {
45
+ throw new Error("c8ctl.init() must only be called once");
46
+ }
47
+ this._deps = deps;
48
+ }
49
+ createClient(profileFlag, additionalSdkConfig) {
50
+ if (!this._deps) {
51
+ throw new Error("c8ctl.init() must be called before createClient()");
52
+ }
53
+ return this._deps.createClient(profileFlag, additionalSdkConfig);
54
+ }
55
+ resolveTenantId(profileFlag) {
56
+ if (!this._deps) {
57
+ throw new Error("c8ctl.init() must be called before resolveTenantId()");
58
+ }
59
+ return this._deps.resolveTenantId(profileFlag);
60
+ }
61
+ getLogger(mode) {
62
+ if (!this._deps) {
63
+ throw new Error("c8ctl.init() must be called before getLogger()");
64
+ }
65
+ return this._deps.getLogger(mode);
66
+ }
67
+ getUserDataDir() {
68
+ if (!this._deps) {
69
+ throw new Error("c8ctl.init() must be called before getUserDataDir()");
70
+ }
71
+ return this._deps.getUserDataDir();
72
+ }
73
+ getModelerDataDir() {
74
+ if (!this._deps) {
75
+ throw new Error("c8ctl.init() must be called before getModelerDataDir()");
76
+ }
77
+ return this._deps.getModelerDataDir();
78
+ }
79
+ npm(options) {
80
+ if (!this._deps) {
81
+ throw new Error("c8ctl.init() must be called before npm()");
82
+ }
83
+ return options.stdout === true ? this._deps.npm(options) : this._deps.npm(options);
84
+ }
85
+ // Expose env properties directly for plugin compatibility
86
+ get version() {
87
+ return this.env.version;
88
+ }
89
+ get nodeVersion() {
90
+ return this.env.nodeVersion;
91
+ }
92
+ get platform() {
93
+ return this.env.platform;
94
+ }
95
+ get arch() {
96
+ return this.env.arch;
97
+ }
98
+ get cwd() {
99
+ return this.env.cwd;
100
+ }
101
+ get activeProfile() {
102
+ return this._activeProfile;
103
+ }
104
+ set activeProfile(value) {
105
+ this._activeProfile = value;
106
+ }
107
+ get activeTenant() {
108
+ return this._activeTenant;
109
+ }
110
+ set activeTenant(value) {
111
+ this._activeTenant = value;
112
+ }
113
+ get outputMode() {
114
+ return this._outputMode;
115
+ }
116
+ set outputMode(value) {
117
+ this._outputMode = value;
118
+ }
119
+ get fields() {
120
+ return this._fields;
121
+ }
122
+ set fields(value) {
123
+ this._fields = value;
124
+ }
125
+ get dryRun() {
126
+ return this._dryRun;
127
+ }
128
+ set dryRun(value) {
129
+ this._dryRun = value;
130
+ }
131
+ get verbose() {
132
+ return this._verbose;
133
+ }
134
+ set verbose(value) {
135
+ this._verbose = value;
136
+ }
137
+ get quiet() {
138
+ return this._quiet;
139
+ }
140
+ set quiet(value) {
141
+ this._quiet = value;
142
+ }
143
+ get resolvedBaseUrl() {
144
+ return this._resolvedBaseUrl;
145
+ }
146
+ set resolvedBaseUrl(value) {
147
+ this._resolvedBaseUrl = value;
148
+ }
149
+ };
150
+ var c8ctl = new C8ctl();
151
+
152
+ // src/core/logger.ts
153
+ function isRecord(value) {
154
+ return value != null && typeof value === "object" && !Array.isArray(value);
155
+ }
156
+
157
+ // src/core/config.ts
158
+ var VALIDATION_PATTERNS = {
159
+ URL: /^https?:\/\//,
160
+ CAMUNDA_CLOUD_REST_URL: /^https:\/\/[a-z]+-\d+\.zeebe\.camunda\.io(:443|)\/[a-z\d-]+\/?$/
161
+ };
162
+ var CAMUNDA_CLOUD_URL_PATTERN = VALIDATION_PATTERNS.CAMUNDA_CLOUD_REST_URL;
163
+ var isWindows = platform() === "win32";
164
+
165
+ // src/core/errors.ts
166
+ var SilentError = class extends Error {
167
+ constructor(message) {
168
+ super(message);
169
+ this.name = "SilentError";
170
+ }
171
+ };
172
+ function normalizeToError(error, fallbackMessage = "Operation failed") {
173
+ if (error instanceof Error) {
174
+ return error;
175
+ }
176
+ const raw = isRecord(error) ? error : {};
177
+ const title = typeof raw.title === "string" ? raw.title : void 0;
178
+ const detail = typeof raw.detail === "string" ? raw.detail : void 0;
179
+ const status = typeof raw.status === "number" ? raw.status : void 0;
180
+ const head = [title ?? fallbackMessage, detail].filter((p) => Boolean(p)).join(": ");
181
+ const message = status !== void 0 ? `${head} (status ${status})` : head;
182
+ return new Error(message, { cause: error });
183
+ }
184
+ function renderCommandFailure(logger, message, error, { verbose = false } = {}) {
185
+ const normalizedError = normalizeToError(error, message);
186
+ if (verbose) {
187
+ throw normalizedError;
188
+ }
189
+ if (error instanceof SilentError) {
190
+ return;
191
+ }
192
+ if (normalizedError.message === message) {
193
+ logger.error(message);
194
+ } else {
195
+ logger.error(message, normalizedError);
196
+ }
197
+ logger.info("For more details on the error, run with the --verbose flag", {
198
+ essential: true
199
+ });
200
+ }
201
+
202
+ // src/core/update-check.ts
203
+ var CHECK_INTERVAL_MS = 60 * 60 * 1e3;
204
+
205
+ // src/utils/command-local/skills-install-helpers.ts
206
+ import { spawn } from "node:child_process";
207
+ import {
208
+ existsSync,
209
+ lstatSync,
210
+ realpathSync,
211
+ rmSync,
212
+ statSync,
213
+ unlinkSync
214
+ } from "node:fs";
215
+ import { homedir as homedir2 } from "node:os";
216
+ import {
217
+ basename,
218
+ dirname as dirname2,
219
+ isAbsolute,
220
+ posix,
221
+ relative,
222
+ resolve,
223
+ sep,
224
+ win32
225
+ } from "node:path";
226
+ var HARNESS_DETECTORS = [
227
+ { id: "claude-code", executable: "claude" },
228
+ { id: "github-copilot", executable: "copilot" }
229
+ ];
230
+ var HARNESS_ALIASES = {
231
+ claude: "claude-code",
232
+ copilot: "github-copilot"
233
+ };
234
+ var HARNESS_USER_SKILL_DIRS = {
235
+ "github-copilot": ".copilot/skills",
236
+ "claude-code": ".claude/skills",
237
+ cursor: ".cursor/skills",
238
+ codex: ".agents/skills",
239
+ "gemini-cli": ".gemini/skills",
240
+ antigravity: ".gemini/antigravity/skills",
241
+ "antigravity-cli": ".gemini/antigravity-cli/skills",
242
+ "antigravity2.0": ".gemini/config/skills",
243
+ adal: ".adal/skills",
244
+ amp: ".config/agents/skills",
245
+ augment: ".augment/skills",
246
+ bob: ".bob/skills",
247
+ cline: ".agents/skills",
248
+ codebuddy: ".codebuddy/skills",
249
+ "command-code": ".commandcode/skills",
250
+ continue: ".continue/skills",
251
+ cortex: ".snowflake/cortex/skills",
252
+ crush: ".config/crush/skills",
253
+ deepagents: ".deepagents/agent/skills",
254
+ devin: ".devin/skills",
255
+ droid: ".factory/skills",
256
+ firebender: ".firebender/skills",
257
+ goose: ".config/goose/skills",
258
+ grok: ".grok/skills",
259
+ "iflow-cli": ".iflow/skills",
260
+ junie: ".junie/skills",
261
+ kilo: ".kilocode/skills",
262
+ "kimi-cli": ".config/agents/skills",
263
+ "kiro-cli": ".kiro/skills",
264
+ kode: ".kode/skills",
265
+ mcpjam: ".mcpjam/skills",
266
+ "mistral-vibe": ".vibe/skills",
267
+ mux: ".mux/skills",
268
+ neovate: ".neovate/skills",
269
+ openclaw: ".openclaw/skills",
270
+ opencode: ".config/opencode/skills",
271
+ openhands: ".openhands/skills",
272
+ pi: ".pi/agent/skills",
273
+ pochi: ".pochi/skills",
274
+ qoder: ".qoder/skills",
275
+ "qwen-code": ".qwen/skills",
276
+ replit: ".config/agents/skills",
277
+ roo: ".roo/skills",
278
+ trae: ".trae/skills",
279
+ "trae-cn": ".trae-cn/skills",
280
+ universal: ".agents/skills",
281
+ warp: ".agents/skills",
282
+ zencoder: ".zencoder/skills"
283
+ };
284
+ var CAMUNDA_SKILLS_REPOSITORY = "camunda/skills";
285
+ var CAMUNDA_SKILLS_URL = `https://github.com/${CAMUNDA_SKILLS_REPOSITORY}`;
286
+ function normalizeSkillHarness(value) {
287
+ const normalized = value.trim().toLowerCase();
288
+ if (!/^[a-z0-9][a-z0-9.-]*$/.test(normalized)) {
289
+ throw new Error(
290
+ "Invalid harness ID. Use a non-empty GitHub CLI skill agent ID, such as claude-code, github-copilot, or cursor."
291
+ );
292
+ }
293
+ return Object.hasOwn(HARNESS_ALIASES, normalized) ? HARNESS_ALIASES[normalized] : normalized;
294
+ }
295
+ function buildSkillInstallArgs(harness) {
296
+ return [
297
+ "skill",
298
+ "install",
299
+ CAMUNDA_SKILLS_REPOSITORY,
300
+ "--all",
301
+ "--agent",
302
+ harness,
303
+ "--scope",
304
+ "user"
305
+ ];
306
+ }
307
+ function buildSkillListArgs(harness) {
308
+ return [
309
+ "skill",
310
+ "list",
311
+ "--agent",
312
+ harness,
313
+ "--scope",
314
+ "user",
315
+ "--json",
316
+ "skillName,sourceURL,path"
317
+ ];
318
+ }
319
+ function buildSkillDiscoveryArgs() {
320
+ return ["skill", "install", CAMUNDA_SKILLS_REPOSITORY];
321
+ }
322
+ function buildSkillInstallSpecificArgs({
323
+ harness,
324
+ skill
325
+ }) {
326
+ return [
327
+ "skill",
328
+ "install",
329
+ CAMUNDA_SKILLS_REPOSITORY,
330
+ skill,
331
+ "--agent",
332
+ harness,
333
+ "--scope",
334
+ "user"
335
+ ];
336
+ }
337
+ function buildSkillUpdateArgs(skills, directory) {
338
+ return ["skill", "update", "--all", "--dir", directory, ...skills];
339
+ }
340
+ function installedCamundaSkills(stdout) {
341
+ let parsed;
342
+ try {
343
+ parsed = JSON.parse(stdout);
344
+ } catch {
345
+ throw new Error("GitHub CLI returned invalid JSON while listing skills.");
346
+ }
347
+ if (!Array.isArray(parsed)) {
348
+ throw new Error("GitHub CLI returned an invalid installed-skills list.");
349
+ }
350
+ const skills = [];
351
+ for (const entry of parsed) {
352
+ if (!isRecord(entry) || typeof entry.sourceURL !== "string") continue;
353
+ if (entry.sourceURL.replace(/\/+$/, "").toLowerCase() !== CAMUNDA_SKILLS_URL)
354
+ continue;
355
+ if (typeof entry.skillName !== "string" || entry.skillName.length === 0 || typeof entry.path !== "string" || entry.path.length === 0) {
356
+ throw new Error("GitHub CLI returned incomplete Camunda skill metadata.");
357
+ }
358
+ skills.push({
359
+ name: entry.skillName,
360
+ directory: dirname2(entry.path),
361
+ path: entry.path
362
+ });
363
+ }
364
+ return skills;
365
+ }
366
+ function availableCamundaSkills(stdout) {
367
+ const names = stdout.split(/\r?\n/).filter((line) => line.includes(" ")).map((line) => line.split(" ", 1)[0].trim()).filter((name) => name.length > 0);
368
+ if (names.length === 0) {
369
+ throw new Error("GitHub CLI returned no available Camunda skills.");
370
+ }
371
+ if (names.some((name) => !/^[a-z0-9][a-z0-9._/-]*$/i.test(name))) {
372
+ throw new Error(
373
+ "GitHub CLI returned an invalid available Camunda skills list."
374
+ );
375
+ }
376
+ return [...new Set(names)];
377
+ }
378
+ function joinForPlatform(platform2, ...paths) {
379
+ return platform2 === "win32" ? win32.join(...paths) : posix.join(...paths);
380
+ }
381
+ function harnessConfigDirectories({
382
+ harness,
383
+ env,
384
+ home,
385
+ platform: platform2
386
+ }) {
387
+ if (harness === "claude-code") {
388
+ return [
389
+ ...env.CLAUDE_CONFIG_DIR ? [env.CLAUDE_CONFIG_DIR] : [],
390
+ joinForPlatform(platform2, home, ".claude")
391
+ ];
392
+ }
393
+ if (harness === "github-copilot") {
394
+ return [joinForPlatform(platform2, home, ".copilot")];
395
+ }
396
+ return [];
397
+ }
398
+ function executableIsOnPath({
399
+ name,
400
+ env,
401
+ platform: platform2
402
+ }) {
403
+ const pathSeparator = platform2 === "win32" ? ";" : ":";
404
+ const directories = (env.PATH ?? "").split(pathSeparator).filter((directory) => directory.length > 0);
405
+ const extensions = platform2 === "win32" ? (env.PATHEXT ?? ".COM;.EXE;.BAT;.CMD").split(";").filter((extension) => extension.length > 0) : [""];
406
+ return directories.some(
407
+ (directory) => extensions.some(
408
+ (extension) => existsSync(joinForPlatform(platform2, directory, `${name}${extension}`))
409
+ )
410
+ );
411
+ }
412
+ function detectInstalledHarnesses({
413
+ env = process.env,
414
+ home,
415
+ platform: platform2 = process.platform
416
+ } = {}) {
417
+ const userHome = home ?? (platform2 === "win32" ? env.USERPROFILE || env.HOME || homedir2() : env.HOME || homedir2());
418
+ return HARNESS_DETECTORS.filter(
419
+ ({ id, executable }) => harnessConfigDirectories({
420
+ harness: id,
421
+ env,
422
+ home: userHome,
423
+ platform: platform2
424
+ }).some((directory) => existsSync(directory)) || executableIsOnPath({ name: executable, env, platform: platform2 })
425
+ ).map(({ id }) => id);
426
+ }
427
+ function runCommand(command, args) {
428
+ return new Promise((resolveRun) => {
429
+ const child = spawn(command, args);
430
+ let stdout = "";
431
+ let stderr = "";
432
+ child.stdout?.setEncoding("utf8");
433
+ child.stderr?.setEncoding("utf8");
434
+ child.stdout?.on("data", (chunk) => {
435
+ stdout += chunk;
436
+ });
437
+ child.stderr?.on("data", (chunk) => {
438
+ stderr += chunk;
439
+ });
440
+ let settled = false;
441
+ const done = (result) => {
442
+ if (settled) return;
443
+ settled = true;
444
+ resolveRun(result);
445
+ };
446
+ child.on("error", (error) => done({ status: null, stdout, stderr, error }));
447
+ child.on("close", (status) => done({ status, stdout, stderr }));
448
+ });
449
+ }
450
+ async function listCamundaSkills(harness, runner = runCommand) {
451
+ const listed = await runner("gh", buildSkillListArgs(harness));
452
+ requireSuccessfulSkillCommand(listed, "check for installed");
453
+ return installedCamundaSkills(listed.stdout).map((skill) => ({
454
+ ...skill,
455
+ harness
456
+ }));
457
+ }
458
+ function isWithinPath(root, candidate) {
459
+ const relativePath = relative(root, candidate);
460
+ return relativePath === "" || relativePath !== ".." && !relativePath.startsWith(`..${sep}`) && !isAbsolute(relativePath);
461
+ }
462
+ function harnessSkillDirectories({
463
+ harness,
464
+ env,
465
+ home,
466
+ platform: platform2
467
+ }) {
468
+ const directories = [];
469
+ if (harness === "claude-code" && env.CLAUDE_CONFIG_DIR) {
470
+ directories.push(
471
+ joinForPlatform(platform2, env.CLAUDE_CONFIG_DIR, "skills")
472
+ );
473
+ }
474
+ if (harness === "pi" && env.PI_CODING_AGENT_DIR) {
475
+ directories.push(
476
+ joinForPlatform(platform2, env.PI_CODING_AGENT_DIR, "skills")
477
+ );
478
+ }
479
+ const userDir = HARNESS_USER_SKILL_DIRS[harness];
480
+ if (userDir) {
481
+ directories.push(joinForPlatform(platform2, home, userDir));
482
+ }
483
+ return directories.map((directory) => resolve(directory));
484
+ }
485
+ function skillRemovalLocation(skill, { env = process.env, home, platform: platform2 = process.platform }) {
486
+ const userHome = home ?? (platform2 === "win32" ? env.USERPROFILE || env.HOME || homedir2() : env.HOME || homedir2());
487
+ if (!isAbsolute(skill.path)) {
488
+ throw new Error(
489
+ `Cannot safely remove Camunda skill "${skill.name}": GitHub CLI returned a non-absolute path.`
490
+ );
491
+ }
492
+ const directory = resolve(skill.path);
493
+ const skillName = skill.name.split(/[\\/]/).at(-1);
494
+ if (!skillName || basename(directory) !== skillName) {
495
+ throw new Error(
496
+ `Cannot safely remove Camunda skill "${skill.name}": its listed path does not match the skill name.`
497
+ );
498
+ }
499
+ const roots = harnessSkillDirectories({
500
+ harness: skill.harness,
501
+ env,
502
+ home: userHome,
503
+ platform: platform2
504
+ });
505
+ const root = roots.find(
506
+ (candidate) => candidate !== directory && isWithinPath(candidate, directory)
507
+ );
508
+ if (!root) {
509
+ throw new Error(
510
+ `Cannot safely remove Camunda skill "${skill.name}" from ${skill.path}: the path is outside the ${skill.harness} user skills directory.`
511
+ );
512
+ }
513
+ if (statSync(root, { throwIfNoEntry: false })?.isDirectory()) {
514
+ const rootRealPath = realpathSync(root);
515
+ const envRoots = [
516
+ ...skill.harness === "claude-code" && env.CLAUDE_CONFIG_DIR ? [env.CLAUDE_CONFIG_DIR] : [],
517
+ ...skill.harness === "pi" && env.PI_CODING_AGENT_DIR ? [env.PI_CODING_AGENT_DIR] : []
518
+ ];
519
+ const isEnvRoot = envRoots.some(
520
+ (envRoot) => resolve(envRoot) === resolve(dirname2(root))
521
+ );
522
+ if (!isEnvRoot && (!statSync(userHome, { throwIfNoEntry: false })?.isDirectory() || !isWithinPath(realpathSync(resolve(userHome)), rootRealPath))) {
523
+ throw new Error(
524
+ `Cannot safely remove Camunda skill "${skill.name}": the ${skill.harness} user skills directory resolves outside the home directory.`
525
+ );
526
+ }
527
+ const directoryInfo = lstatSync(directory, { throwIfNoEntry: false });
528
+ if (directoryInfo && !directoryInfo.isSymbolicLink()) {
529
+ const directoryRealPath = realpathSync(directory);
530
+ if (!isWithinPath(rootRealPath, directoryRealPath) || directoryRealPath === rootRealPath) {
531
+ throw new Error(
532
+ `Cannot safely remove Camunda skill "${skill.name}": its directory resolves outside the ${skill.harness} user skills directory.`
533
+ );
534
+ }
535
+ }
536
+ }
537
+ return { directory, root };
538
+ }
539
+ function camundaSkillRemovalPath(skill, options = {}) {
540
+ return skillRemovalLocation(skill, options).directory;
541
+ }
542
+ function removeCamundaSkill(skill, options = {}) {
543
+ const { directory, root } = skillRemovalLocation(skill, options);
544
+ const directoryInfo = lstatSync(directory, { throwIfNoEntry: false });
545
+ if (!directoryInfo) return;
546
+ if (directoryInfo.isSymbolicLink()) {
547
+ const rootInfo2 = statSync(root, { throwIfNoEntry: false });
548
+ if (!rootInfo2?.isDirectory()) {
549
+ throw new Error(
550
+ `Cannot safely remove Camunda skill "${skill.name}": its user skills directory is unavailable.`
551
+ );
552
+ }
553
+ const rootRealPath2 = realpathSync(root);
554
+ const parentRealPath = realpathSync(dirname2(directory));
555
+ if (!isWithinPath(rootRealPath2, parentRealPath)) {
556
+ throw new Error(
557
+ `Cannot safely remove Camunda skill "${skill.name}": its parent directory resolves outside the user skills directory.`
558
+ );
559
+ }
560
+ unlinkSync(directory);
561
+ return;
562
+ }
563
+ if (!directoryInfo.isDirectory()) {
564
+ throw new Error(
565
+ `Cannot safely remove Camunda skill "${skill.name}": its listed path is not a directory.`
566
+ );
567
+ }
568
+ const rootInfo = statSync(root, { throwIfNoEntry: false });
569
+ if (!rootInfo?.isDirectory()) {
570
+ throw new Error(
571
+ `Cannot safely remove Camunda skill "${skill.name}": its user skills directory is unavailable.`
572
+ );
573
+ }
574
+ const rootRealPath = realpathSync(root);
575
+ const directoryRealPath = realpathSync(directory);
576
+ if (!isWithinPath(rootRealPath, directoryRealPath) || directoryRealPath === rootRealPath) {
577
+ throw new Error(
578
+ `Cannot safely remove Camunda skill "${skill.name}": its directory resolves outside the user skills directory.`
579
+ );
580
+ }
581
+ rmSync(directory, { recursive: true });
582
+ }
583
+ async function runSkillInstall(harness, runner = runCommand) {
584
+ const installed = await listCamundaSkills(harness, runner);
585
+ if (installed.length === 0) {
586
+ requireSuccessfulSkillCommand(
587
+ await runner("gh", buildSkillInstallArgs(harness)),
588
+ "install"
589
+ );
590
+ return;
591
+ }
592
+ const availableResult = await runner("gh", buildSkillDiscoveryArgs());
593
+ requireSuccessfulSkillCommand(availableResult, "list available");
594
+ const available = availableCamundaSkills(availableResult.stdout);
595
+ const installedNames = new Set(installed.map(({ name }) => name));
596
+ const missing = available.filter((skill) => !installedNames.has(skill));
597
+ const byDirectory = /* @__PURE__ */ new Map();
598
+ for (const skill of installed) {
599
+ const skills = byDirectory.get(skill.directory) ?? [];
600
+ if (!skills.includes(skill.name)) skills.push(skill.name);
601
+ byDirectory.set(skill.directory, skills);
602
+ }
603
+ for (const [directory, skills] of byDirectory) {
604
+ requireSuccessfulSkillCommand(
605
+ await runner("gh", buildSkillUpdateArgs(skills, directory)),
606
+ "update"
607
+ );
608
+ }
609
+ for (const skill of missing) {
610
+ requireSuccessfulSkillCommand(
611
+ await runner("gh", buildSkillInstallSpecificArgs({ harness, skill })),
612
+ "install"
613
+ );
614
+ }
615
+ }
616
+ function requireSuccessfulSkillCommand(result, action) {
617
+ if (result.error) {
618
+ const errorCode = "code" in result.error && typeof result.error.code === "string" ? result.error.code : void 0;
619
+ if (errorCode === "ENOENT") {
620
+ throw new Error(
621
+ "GitHub CLI was not found. Install GitHub CLI 2.90 or later from https://cli.github.com/."
622
+ );
623
+ }
624
+ throw new Error(`Could not run GitHub CLI: ${result.error.message}`);
625
+ }
626
+ if (result.status === 0) return;
627
+ const details = [result.stderr.trim(), result.stdout.trim()].filter((output) => output.length > 0).join("\n");
628
+ if (/unknown command\s+["']?skill\b/i.test(details)) {
629
+ throw new Error(
630
+ "`gh skill` requires GitHub CLI 2.90 or later. Upgrade GitHub CLI from https://cli.github.com/."
631
+ );
632
+ }
633
+ throw new Error(
634
+ `GitHub CLI failed to ${action} Camunda skills${result.status === null ? "" : ` (exit code ${result.status})`}: ${details || "No details were reported."}`
635
+ );
636
+ }
637
+
638
+ // default-plugins/skills/c8ctl-plugin.ts
639
+ var HARNESS_LABELS = {
640
+ "claude-code": "Claude Code",
641
+ "github-copilot": "GitHub Copilot CLI",
642
+ cursor: "Cursor"
643
+ };
644
+ var metadata = {
645
+ name: "skills",
646
+ description: "Manage Camunda AI coding skills",
647
+ commands: {
648
+ skills: {
649
+ description: "Manage Camunda AI coding skills",
650
+ helpDescription: `Manage Camunda skills installed in AI coding harnesses.
651
+
652
+ Requires GitHub CLI 2.90 or later; its skill commands are in preview.
653
+ Re-run to update the same skill directories without duplicates when upstream changes. Local edits to up-to-date skills are preserved; upstream updates may replace edited files.
654
+ To restore one skill's upstream files, use \`gh skill update --force --dir <skills-root> <skill-name>\`; pass the parent skills directory (for example \`~/.claude/skills\`), not the listed skill directory. Find names with \`gh skill list --scope user --agent <agent-id>\`. Extra local files are retained.
655
+ Use \`skills list\` to inspect installed skills and \`skills remove\` to remove them. Removal deletes the full skill directories, including local edits. Use a GitHub CLI agent ID for --harness; see \`gh skill install --help\` for supported IDs. Pass \`--yes\` for non-interactive removal; \`--dry-run\` previews without deleting.`,
656
+ subcommands: [
657
+ {
658
+ name: "install",
659
+ description: "Install or update skills for detected harnesses"
660
+ },
661
+ {
662
+ name: "list",
663
+ description: "List installed Camunda skills by harness"
664
+ },
665
+ {
666
+ name: "remove",
667
+ description: "Remove installed Camunda skills"
668
+ }
669
+ ],
670
+ examples: [
671
+ {
672
+ command: "c8ctl skills install",
673
+ description: "Install or update skills for detected harnesses"
674
+ },
675
+ {
676
+ command: "c8ctl skills install --harness claude-code",
677
+ description: "Install or update skills for Claude Code"
678
+ },
679
+ {
680
+ command: "c8ctl skills install --harness github-copilot",
681
+ description: "Install or update skills for GitHub Copilot CLI"
682
+ },
683
+ {
684
+ command: "c8ctl skills list",
685
+ description: "List installed Camunda skills by harness"
686
+ },
687
+ {
688
+ command: "c8ctl skills remove --dry-run",
689
+ description: "Preview Camunda skills removal"
690
+ },
691
+ {
692
+ command: "c8ctl skills remove --harness claude-code --yes",
693
+ description: "Remove Camunda skills from Claude Code"
694
+ }
695
+ ]
696
+ }
697
+ }
698
+ };
699
+ function resolveHarnesses(rawHarness) {
700
+ if (rawHarness !== void 0 && (typeof rawHarness !== "string" || rawHarness === "")) {
701
+ throw new Error("Invalid --harness: value must not be empty");
702
+ }
703
+ const requestedHarness = typeof rawHarness === "string" ? normalizeSkillHarness(rawHarness) : void 0;
704
+ const harnesses = requestedHarness ? [requestedHarness] : detectInstalledHarnesses();
705
+ if (harnesses.length === 0) {
706
+ throw new Error(
707
+ "No supported AI coding harness was detected. Install Claude Code or GitHub Copilot CLI, or pass --harness <agent-id>."
708
+ );
709
+ }
710
+ return { harnesses, requestedHarness };
711
+ }
712
+ async function inspectSkills(harnesses) {
713
+ const skills = [];
714
+ for (const harness of harnesses) {
715
+ skills.push(...await listCamundaSkills(harness));
716
+ }
717
+ return skills;
718
+ }
719
+ function skillRows(skills) {
720
+ return skills.map(({ name, harness, path }) => ({ name, harness, path }));
721
+ }
722
+ function emitRowsJson(ctx, envelope, rows) {
723
+ if (ctx.fields && ctx.fields.length > 0) {
724
+ ctx.logger.json(rows);
725
+ } else {
726
+ ctx.logger.json(envelope);
727
+ }
728
+ }
729
+ async function listSkills(rawHarness, ctx) {
730
+ const { logger } = ctx;
731
+ try {
732
+ const { harnesses } = resolveHarnesses(rawHarness);
733
+ const skills = await inspectSkills(harnesses);
734
+ const rows = skillRows(skills);
735
+ if (ctx.outputMode === "json") {
736
+ emitRowsJson(
737
+ ctx,
738
+ { command: "skills list", harnesses, skills: rows },
739
+ rows
740
+ );
741
+ } else if (rows.length === 0) {
742
+ const labels = harnesses.map((harness) => HARNESS_LABELS[harness] ?? harness).join(", ");
743
+ logger.info(`No Camunda skills are installed for ${labels}.`, {
744
+ essential: true
745
+ });
746
+ } else {
747
+ logger.table(rows);
748
+ }
749
+ } catch (error) {
750
+ renderCommandFailure(logger, "Failed to skills list", error, {
751
+ verbose: ctx.verbose
752
+ });
753
+ process.exitCode = 1;
754
+ }
755
+ }
756
+ async function removeSkills(rawHarness, extraArgs, ctx) {
757
+ const { logger } = ctx;
758
+ try {
759
+ if (ctx.unrecognizedFlags && ctx.unrecognizedFlags.length > 0) {
760
+ throw new Error(
761
+ `Unknown flag${ctx.unrecognizedFlags.length === 1 ? "" : "s"} ${ctx.unrecognizedFlags.join(", ")} for 'skills remove'. Only --harness selects the removal scope; fix or remove the flag before deleting skills.`
762
+ );
763
+ }
764
+ const swallowed = ctx.suspiciousFlagValues?.[0];
765
+ if (swallowed) {
766
+ throw new Error(
767
+ `"${swallowed}" looks like a flag but was passed as a value. Only --harness selects the removal scope; fix the invocation before deleting skills.`
768
+ );
769
+ }
770
+ if (extraArgs.length > 0) {
771
+ throw new Error(
772
+ `skills remove does not accept positional arguments ("${extraArgs.join(" ")}"). Use --harness <agent-id> to select a harness; removal otherwise covers all detected harnesses.`
773
+ );
774
+ }
775
+ const { harnesses, requestedHarness } = resolveHarnesses(rawHarness);
776
+ const skills = await inspectSkills(harnesses);
777
+ for (const skill of skills) camundaSkillRemovalPath(skill);
778
+ const items = skills.map(({ name, harness, path }) => ({
779
+ type: "skill",
780
+ harness,
781
+ name,
782
+ path
783
+ }));
784
+ const preview = {
785
+ command: "skills remove",
786
+ action: "remove",
787
+ preview: true,
788
+ items
789
+ };
790
+ if (ctx.dryRun) {
791
+ emitRowsJson(ctx, { dryRun: true, ...preview }, items);
792
+ return;
793
+ }
794
+ if (skills.length === 0) {
795
+ if (ctx.outputMode === "json") {
796
+ emitRowsJson(
797
+ ctx,
798
+ { command: "skills remove", harnesses, removed: [] },
799
+ []
800
+ );
801
+ } else {
802
+ const labels = harnesses.map((harness) => HARNESS_LABELS[harness] ?? harness).join(", ");
803
+ logger.info(`No Camunda skills are installed for ${labels}.`, {
804
+ essential: true
805
+ });
806
+ }
807
+ return;
808
+ }
809
+ if (ctx.outputMode === "text") {
810
+ logger.output(
811
+ [
812
+ "Skills removal preview:",
813
+ ...skills.map(
814
+ ({ name, harness, path }) => ` Remove Camunda skill "${name}" for ${HARNESS_LABELS[harness] ?? harness} (${path}; all contents will be removed)`
815
+ )
816
+ ].join("\n")
817
+ );
818
+ } else if (!ctx.yes) {
819
+ emitRowsJson(ctx, preview, items);
820
+ return;
821
+ }
822
+ if (!ctx.yes) {
823
+ if (!ctx.quiet && ctx.prompt.isInteractive()) {
824
+ const confirmation = await ctx.prompt.select({
825
+ message: "Remove the listed Camunda skills?",
826
+ options: [
827
+ { label: "Keep these skills", value: false },
828
+ { label: "Remove the listed skills", value: true }
829
+ ]
830
+ });
831
+ if (confirmation.cancelled || !confirmation.value) {
832
+ logger.info("Cancelled \u2014 nothing was removed.", {
833
+ essential: true
834
+ });
835
+ return;
836
+ }
837
+ } else {
838
+ const command = [
839
+ "c8ctl",
840
+ "skills",
841
+ "remove",
842
+ ...requestedHarness ? ["--harness", requestedHarness] : [],
843
+ "--yes"
844
+ ].join(" ");
845
+ logger.info(`Nothing was removed. Run "${command}" to confirm.`, {
846
+ essential: true
847
+ });
848
+ return;
849
+ }
850
+ }
851
+ const revalidated = await inspectSkills(harnesses);
852
+ const listedKeys = new Set(
853
+ revalidated.map((skill) => `${skill.harness} ${skill.path}`)
854
+ );
855
+ const stale = skills.filter(
856
+ (skill) => !listedKeys.has(`${skill.harness} ${skill.path}`)
857
+ );
858
+ if (stale.length > 0) {
859
+ throw new Error(
860
+ `The installed-skills inventory changed after the preview: ${stale.map((skill) => `"${skill.name}" (${skill.path})`).join(
861
+ ", "
862
+ )}. Run "c8ctl skills remove" again for a fresh preview before deleting.`
863
+ );
864
+ }
865
+ const removed = [];
866
+ const failures = [];
867
+ for (const skill of skills) {
868
+ try {
869
+ removeCamundaSkill(skill);
870
+ removed.push(skill);
871
+ } catch (error) {
872
+ failures.push({ skill, error });
873
+ }
874
+ }
875
+ if (ctx.outputMode === "json") {
876
+ emitRowsJson(
877
+ ctx,
878
+ { command: "skills remove", removed: skillRows(removed) },
879
+ skillRows(removed)
880
+ );
881
+ } else {
882
+ for (const skill of removed) {
883
+ logger.info(
884
+ `Removed Camunda skill "${skill.name}" for ${HARNESS_LABELS[skill.harness] ?? skill.harness} (${skill.path}).`,
885
+ { essential: true }
886
+ );
887
+ }
888
+ logger.info(
889
+ failures.length === 0 ? "Skills removal finished." : `Skills removal finished with ${failures.length} failed action(s).`,
890
+ { essential: true }
891
+ );
892
+ }
893
+ for (const { skill, error } of failures) {
894
+ renderCommandFailure(
895
+ logger,
896
+ `Could not remove Camunda skill "${skill.name}" for ${skill.harness}`,
897
+ error,
898
+ { verbose: ctx.verbose }
899
+ );
900
+ }
901
+ if (failures.length > 0) process.exitCode = 1;
902
+ } catch (error) {
903
+ renderCommandFailure(logger, "Failed to skills remove", error, {
904
+ verbose: ctx.verbose
905
+ });
906
+ process.exitCode = 1;
907
+ }
908
+ }
909
+ async function skillsHandler(args, flags, ctx) {
910
+ if (!ctx) throw new Error("skills requires the plugin host context");
911
+ const { logger } = ctx;
912
+ if (args[0] === "list") {
913
+ await listSkills(flags?.harness, ctx);
914
+ return;
915
+ }
916
+ if (args[0] === "remove") {
917
+ await removeSkills(flags?.harness, args.slice(1), ctx);
918
+ return;
919
+ }
920
+ if (args[0] !== "install") {
921
+ if (args[0] === void 0) {
922
+ logger.info(
923
+ "\nUsage: c8ctl skills <install|list|remove> [--harness <agent-id>]\n\nAvailable commands:\n install\n list\n remove",
924
+ {
925
+ essential: true
926
+ }
927
+ );
928
+ } else {
929
+ logger.error(`Unknown command: skills ${args.join(" ")}`);
930
+ logger.info('Run "c8 help" for usage information', { essential: true });
931
+ }
932
+ process.exitCode = 1;
933
+ return;
934
+ }
935
+ try {
936
+ const rawHarness = flags?.harness;
937
+ if (rawHarness !== void 0 && (typeof rawHarness !== "string" || rawHarness === "")) {
938
+ logger.error("Invalid --harness: value must not be empty");
939
+ process.exitCode = 1;
940
+ return;
941
+ }
942
+ const requestedHarness = typeof rawHarness === "string" ? normalizeSkillHarness(rawHarness) : void 0;
943
+ const harnesses = requestedHarness ? [requestedHarness] : detectInstalledHarnesses();
944
+ if (harnesses.length === 0) {
945
+ throw new Error(
946
+ "No supported AI coding harness was detected. Install Claude Code or GitHub Copilot CLI, or pass --harness <agent-id>."
947
+ );
948
+ }
949
+ if (ctx.dryRun) {
950
+ logger.json({
951
+ dryRun: true,
952
+ command: "skills install",
953
+ source: CAMUNDA_SKILLS_REPOSITORY,
954
+ harnesses
955
+ });
956
+ return;
957
+ }
958
+ for (const harness of harnesses) {
959
+ await runSkillInstall(harness);
960
+ }
961
+ const labels = harnesses.map((harness) => HARNESS_LABELS[harness] ?? harness).join(", ");
962
+ logger.success(`Installed or updated Camunda skills for ${labels}.`);
963
+ } catch (error) {
964
+ renderCommandFailure(logger, "Failed to skills install", error, {
965
+ verbose: ctx.verbose
966
+ });
967
+ process.exitCode = 1;
968
+ }
969
+ }
970
+ var commands = {
971
+ skills: {
972
+ flags: {
973
+ harness: {
974
+ type: "string",
975
+ rejectEmpty: true,
976
+ description: "GitHub CLI agent ID to target (auto-detects Claude Code and GitHub Copilot CLI when omitted)"
977
+ }
978
+ },
979
+ handler: skillsHandler
980
+ }
981
+ };
982
+ export {
983
+ commands,
984
+ metadata
985
+ };