@drupal-canvas/create 1.0.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,17 +30,33 @@ npx @drupal-canvas/create@latest my-app
30
30
 
31
31
  ### Options
32
32
 
33
- | Option | Description |
34
- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
35
- | `--template -t` | Template to use when scaffolding the app. One of the predefined templates (currently available: `canvas-cc-starter`) or URL to custom template's Git repository. |
36
- | `--ref <ref>` | Custom Git ref to use when cloning the template repository. For example, a branch name or a tag. |
33
+ | Option | Description |
34
+ | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
35
+ | `--template -t` | Template to use when scaffolding the app. One of the predefined templates (currently available: `acquia-nebula`, `balintbrews-canvas-starter`) or URL to custom template's Git repository. |
36
+ | `--ref <ref>` | Custom Git ref to use when cloning the template repository. For example, a branch name or a tag. |
37
+ | `--agents -a` | Comma-separated list of additional agents to support, or `none` to skip compatibility symlink creation. |
37
38
 
38
39
  ### Example
39
40
 
40
41
  ```bash
41
- npx @drupal-canvas/create@latest my-app --template canvas-cc-starter
42
+ npx @drupal-canvas/create@latest my-app --template acquia-nebula
42
43
  ```
43
44
 
45
+ Explicitly skip additional agent compatibility symlinks:
46
+
47
+ ```bash
48
+ npx @drupal-canvas/create@latest my-app --template acquia-nebula --agents none
49
+ ```
50
+
51
+ Provide additional agent compatibility symlinks without prompting:
52
+
53
+ ```bash
54
+ npx @drupal-canvas/create@latest my-app --template acquia-nebula --agents claude-code,roo
55
+ ```
56
+
57
+ If `--agents` is omitted, the CLI keeps the current interactive prompt on TTY
58
+ runs. On non-interactive runs, it skips compatibility setup silently.
59
+
44
60
  ## Development
45
61
 
46
62
  Drupal Canvas Create is designed to be easily extendable with new templates.
package/dist/index.js CHANGED
@@ -1,11 +1,15 @@
1
1
  #!/usr/bin/env node
2
2
  import chalk from 'chalk';
3
3
  import { Command } from 'commander';
4
- import * as p2 from '@clack/prompts';
5
- import { readFile, writeFile } from 'fs/promises';
6
- import { join } from 'path';
4
+ import * as p3 from '@clack/prompts';
5
+ import { readFile, writeFile, access, readdir, mkdir, symlink } from 'fs/promises';
6
+ import { join, dirname, relative } from 'path';
7
7
  import spawn from 'cross-spawn';
8
8
  import { rimraf } from 'rimraf';
9
+ import { platform } from 'os';
10
+ import * as readline from 'readline';
11
+ import { Writable } from 'stream';
12
+ import pc from 'picocolors';
9
13
  import { simpleGit } from 'simple-git';
10
14
  import validate from 'validate-npm-package-name';
11
15
 
@@ -15,7 +19,7 @@ var templates_default = [
15
19
  id: "acquia-nebula",
16
20
  label: "acquia/nebula",
17
21
  repository: {
18
- url: "git@github.com:acquia/nebula.git",
22
+ url: "https://github.com/acquia/nebula.git",
19
23
  ref: "main"
20
24
  }
21
25
  },
@@ -23,12 +27,558 @@ var templates_default = [
23
27
  id: "balintbrews-canvas-starter",
24
28
  label: "balintbrews/canvas-starter",
25
29
  repository: {
26
- url: "git@github.com:balintbrews/canvas-starter.git",
30
+ url: "https://github.com/balintbrews/canvas-starter.git",
27
31
  ref: "main"
28
32
  }
29
33
  }
30
34
  ];
31
35
 
36
+ // src/lib/agents.ts
37
+ var agents = {
38
+ amp: {
39
+ displayName: "Amp",
40
+ skillsDir: ".agents/skills"
41
+ },
42
+ antigravity: {
43
+ displayName: "Antigravity",
44
+ skillsDir: ".agents/skills"
45
+ },
46
+ augment: {
47
+ displayName: "Augment",
48
+ skillsDir: ".augment/skills"
49
+ },
50
+ "claude-code": {
51
+ displayName: "Claude Code",
52
+ skillsDir: ".claude/skills"
53
+ },
54
+ openclaw: {
55
+ displayName: "OpenClaw",
56
+ skillsDir: "skills"
57
+ },
58
+ cline: {
59
+ displayName: "Cline",
60
+ skillsDir: ".agents/skills"
61
+ },
62
+ codebuddy: {
63
+ displayName: "CodeBuddy",
64
+ skillsDir: ".codebuddy/skills"
65
+ },
66
+ codex: {
67
+ displayName: "Codex",
68
+ skillsDir: ".agents/skills"
69
+ },
70
+ "command-code": {
71
+ displayName: "Command Code",
72
+ skillsDir: ".commandcode/skills"
73
+ },
74
+ continue: {
75
+ displayName: "Continue",
76
+ skillsDir: ".continue/skills"
77
+ },
78
+ cortex: {
79
+ displayName: "Cortex Code",
80
+ skillsDir: ".cortex/skills"
81
+ },
82
+ crush: {
83
+ displayName: "Crush",
84
+ skillsDir: ".crush/skills"
85
+ },
86
+ cursor: {
87
+ displayName: "Cursor",
88
+ skillsDir: ".agents/skills"
89
+ },
90
+ deepagents: {
91
+ displayName: "Deep Agents",
92
+ skillsDir: ".agents/skills"
93
+ },
94
+ droid: {
95
+ displayName: "Droid",
96
+ skillsDir: ".factory/skills"
97
+ },
98
+ "gemini-cli": {
99
+ displayName: "Gemini CLI",
100
+ skillsDir: ".agents/skills"
101
+ },
102
+ "github-copilot": {
103
+ displayName: "GitHub Copilot",
104
+ skillsDir: ".agents/skills"
105
+ },
106
+ goose: {
107
+ displayName: "Goose",
108
+ skillsDir: ".goose/skills"
109
+ },
110
+ junie: {
111
+ displayName: "Junie",
112
+ skillsDir: ".junie/skills"
113
+ },
114
+ "iflow-cli": {
115
+ displayName: "iFlow CLI",
116
+ skillsDir: ".iflow/skills"
117
+ },
118
+ kilo: {
119
+ displayName: "Kilo Code",
120
+ skillsDir: ".kilocode/skills"
121
+ },
122
+ "kimi-cli": {
123
+ displayName: "Kimi Code CLI",
124
+ skillsDir: ".agents/skills"
125
+ },
126
+ "kiro-cli": {
127
+ displayName: "Kiro CLI",
128
+ skillsDir: ".kiro/skills"
129
+ },
130
+ kode: {
131
+ displayName: "Kode",
132
+ skillsDir: ".kode/skills"
133
+ },
134
+ mcpjam: {
135
+ displayName: "MCPJam",
136
+ skillsDir: ".mcpjam/skills"
137
+ },
138
+ "mistral-vibe": {
139
+ displayName: "Mistral Vibe",
140
+ skillsDir: ".vibe/skills"
141
+ },
142
+ mux: {
143
+ displayName: "Mux",
144
+ skillsDir: ".mux/skills"
145
+ },
146
+ opencode: {
147
+ displayName: "OpenCode",
148
+ skillsDir: ".agents/skills"
149
+ },
150
+ openhands: {
151
+ displayName: "OpenHands",
152
+ skillsDir: ".openhands/skills"
153
+ },
154
+ pi: {
155
+ displayName: "Pi",
156
+ skillsDir: ".pi/skills"
157
+ },
158
+ qoder: {
159
+ displayName: "Qoder",
160
+ skillsDir: ".qoder/skills"
161
+ },
162
+ "qwen-code": {
163
+ displayName: "Qwen Code",
164
+ skillsDir: ".qwen/skills"
165
+ },
166
+ replit: {
167
+ displayName: "Replit",
168
+ skillsDir: ".agents/skills",
169
+ showInUniversalList: false
170
+ },
171
+ roo: {
172
+ displayName: "Roo Code",
173
+ skillsDir: ".roo/skills"
174
+ },
175
+ trae: {
176
+ displayName: "Trae",
177
+ skillsDir: ".trae/skills"
178
+ },
179
+ "trae-cn": {
180
+ displayName: "Trae CN",
181
+ skillsDir: ".trae/skills"
182
+ },
183
+ warp: {
184
+ displayName: "Warp",
185
+ skillsDir: ".agents/skills"
186
+ },
187
+ windsurf: {
188
+ displayName: "Windsurf",
189
+ skillsDir: ".windsurf/skills"
190
+ },
191
+ zencoder: {
192
+ displayName: "Zencoder",
193
+ skillsDir: ".zencoder/skills"
194
+ },
195
+ neovate: {
196
+ displayName: "Neovate",
197
+ skillsDir: ".neovate/skills"
198
+ },
199
+ pochi: {
200
+ displayName: "Pochi",
201
+ skillsDir: ".pochi/skills"
202
+ },
203
+ adal: {
204
+ displayName: "AdaL",
205
+ skillsDir: ".adal/skills"
206
+ }
207
+ };
208
+ Object.entries(agents).map(
209
+ ([value, config]) => ({
210
+ value,
211
+ label: config.displayName,
212
+ hint: config.skillsDir
213
+ })
214
+ );
215
+ function getUniversalAgents() {
216
+ return Object.entries(agents).filter(
217
+ ([_, config]) => config.skillsDir === ".agents/skills" && config.showInUniversalList !== false
218
+ ).map(([type]) => type);
219
+ }
220
+ function getNonUniversalAgents() {
221
+ return Object.entries(agents).filter(([_, config]) => config.skillsDir !== ".agents/skills").map(([type]) => type);
222
+ }
223
+ function isUniversalAgent(type) {
224
+ return agents[type].skillsDir === ".agents/skills";
225
+ }
226
+ function isAgentType(value) {
227
+ return Object.prototype.hasOwnProperty.call(agents, value);
228
+ }
229
+ var silentOutput = new Writable({
230
+ write(_chunk, _encoding, callback) {
231
+ callback();
232
+ }
233
+ });
234
+ var S_STEP_ACTIVE = pc.green("\u25C6");
235
+ var S_STEP_CANCEL = pc.red("\u25A0");
236
+ var S_STEP_SUBMIT = pc.green("\u25C7");
237
+ var S_RADIO_ACTIVE = pc.green("\u25CF");
238
+ var S_RADIO_INACTIVE = pc.dim("\u25CB");
239
+ var S_BULLET = pc.green("\u2022");
240
+ var S_BAR = pc.dim("\u2502");
241
+ var S_BAR_H = pc.dim("\u2500");
242
+ var cancelSymbol = /* @__PURE__ */ Symbol("cancel");
243
+ async function searchMultiselect(options) {
244
+ const {
245
+ message,
246
+ items,
247
+ maxVisible = 8,
248
+ initialSelected = [],
249
+ required = false,
250
+ lockedSection
251
+ } = options;
252
+ return new Promise((resolve) => {
253
+ const rl = readline.createInterface({
254
+ input: process.stdin,
255
+ output: silentOutput,
256
+ terminal: false
257
+ });
258
+ if (process.stdin.isTTY) {
259
+ process.stdin.setRawMode(true);
260
+ }
261
+ readline.emitKeypressEvents(process.stdin, rl);
262
+ let query = "";
263
+ let cursor = 0;
264
+ const selected = new Set(initialSelected);
265
+ let lastRenderHeight = 0;
266
+ const lockedValues = lockedSection ? lockedSection.items.map((i) => i.value) : [];
267
+ const filter = (item, q) => {
268
+ if (!q) return true;
269
+ const lowerQ = q.toLowerCase();
270
+ return item.label.toLowerCase().includes(lowerQ) || String(item.value).toLowerCase().includes(lowerQ);
271
+ };
272
+ const getFiltered = () => {
273
+ return items.filter((item) => filter(item, query));
274
+ };
275
+ const clearRender = () => {
276
+ if (lastRenderHeight > 0) {
277
+ process.stdout.write(`\x1B[${lastRenderHeight}A`);
278
+ for (let i = 0; i < lastRenderHeight; i++) {
279
+ process.stdout.write("\x1B[2K\x1B[1B");
280
+ }
281
+ process.stdout.write(`\x1B[${lastRenderHeight}A`);
282
+ }
283
+ };
284
+ const render = (state = "active") => {
285
+ clearRender();
286
+ const lines = [];
287
+ const filtered = getFiltered();
288
+ const icon = state === "active" ? S_STEP_ACTIVE : state === "cancel" ? S_STEP_CANCEL : S_STEP_SUBMIT;
289
+ lines.push(`${icon} ${pc.bold(message)}`);
290
+ if (state === "active") {
291
+ if (lockedSection && lockedSection.items.length > 0) {
292
+ lines.push(`${S_BAR}`);
293
+ const lockedTitle = `${pc.bold(lockedSection.title)} ${pc.dim("\u2500\u2500 always included")}`;
294
+ lines.push(
295
+ `${S_BAR} ${S_BAR_H}${S_BAR_H} ${lockedTitle} ${S_BAR_H.repeat(12)}`
296
+ );
297
+ for (const item of lockedSection.items) {
298
+ lines.push(`${S_BAR} ${S_BULLET} ${pc.bold(item.label)}`);
299
+ }
300
+ lines.push(`${S_BAR}`);
301
+ lines.push(
302
+ `${S_BAR} ${S_BAR_H}${S_BAR_H} ${pc.bold("Additional agents")} ${S_BAR_H.repeat(29)}`
303
+ );
304
+ }
305
+ const searchLine = `${S_BAR} ${pc.dim("Search:")} ${query}${pc.inverse(" ")}`;
306
+ lines.push(searchLine);
307
+ lines.push(
308
+ `${S_BAR} ${pc.dim("\u2191\u2193 move, space select, enter confirm")}`
309
+ );
310
+ lines.push(`${S_BAR}`);
311
+ const visibleStart = Math.max(
312
+ 0,
313
+ Math.min(
314
+ cursor - Math.floor(maxVisible / 2),
315
+ filtered.length - maxVisible
316
+ )
317
+ );
318
+ const visibleEnd = Math.min(filtered.length, visibleStart + maxVisible);
319
+ const visibleItems = filtered.slice(visibleStart, visibleEnd);
320
+ if (filtered.length === 0) {
321
+ lines.push(`${S_BAR} ${pc.dim("No matches found")}`);
322
+ } else {
323
+ for (let i = 0; i < visibleItems.length; i++) {
324
+ const item = visibleItems[i];
325
+ const actualIndex = visibleStart + i;
326
+ const isSelected = selected.has(item.value);
327
+ const isCursor = actualIndex === cursor;
328
+ const radio = isSelected ? S_RADIO_ACTIVE : S_RADIO_INACTIVE;
329
+ const label = isCursor ? pc.underline(item.label) : item.label;
330
+ const hint = item.hint ? pc.dim(` (${item.hint})`) : "";
331
+ const prefix = isCursor ? pc.cyan("\u276F") : " ";
332
+ lines.push(`${S_BAR} ${prefix} ${radio} ${label}${hint}`);
333
+ }
334
+ const hiddenBefore = visibleStart;
335
+ const hiddenAfter = filtered.length - visibleEnd;
336
+ if (hiddenBefore > 0 || hiddenAfter > 0) {
337
+ const parts = [];
338
+ if (hiddenBefore > 0) parts.push(`\u2191 ${hiddenBefore} more`);
339
+ if (hiddenAfter > 0) parts.push(`\u2193 ${hiddenAfter} more`);
340
+ lines.push(`${S_BAR} ${pc.dim(parts.join(" "))}`);
341
+ }
342
+ }
343
+ lines.push(`${S_BAR}`);
344
+ const allSelectedLabels = [
345
+ ...lockedSection ? lockedSection.items.map((i) => i.label) : [],
346
+ ...items.filter((item) => selected.has(item.value)).map((item) => item.label)
347
+ ];
348
+ if (allSelectedLabels.length === 0) {
349
+ lines.push(`${S_BAR} ${pc.dim("Selected: (none)")}`);
350
+ } else {
351
+ const summary = allSelectedLabels.length <= 3 ? allSelectedLabels.join(", ") : `${allSelectedLabels.slice(0, 3).join(", ")} +${allSelectedLabels.length - 3} more`;
352
+ lines.push(`${S_BAR} ${pc.green("Selected:")} ${summary}`);
353
+ }
354
+ lines.push(`${pc.dim("\u2514")}`);
355
+ } else if (state === "submit") {
356
+ const allSelectedLabels = [
357
+ ...lockedSection ? lockedSection.items.map((i) => i.label) : [],
358
+ ...items.filter((item) => selected.has(item.value)).map((item) => item.label)
359
+ ];
360
+ lines.push(`${S_BAR} ${pc.dim(allSelectedLabels.join(", "))}`);
361
+ } else if (state === "cancel") {
362
+ lines.push(`${S_BAR} ${pc.strikethrough(pc.dim("Cancelled"))}`);
363
+ }
364
+ process.stdout.write(lines.join("\n") + "\n");
365
+ lastRenderHeight = lines.length;
366
+ };
367
+ const cleanup = () => {
368
+ process.stdin.removeListener("keypress", keypressHandler);
369
+ if (process.stdin.isTTY) {
370
+ process.stdin.setRawMode(false);
371
+ }
372
+ rl.close();
373
+ };
374
+ const submit = () => {
375
+ if (required && selected.size === 0 && lockedValues.length === 0) {
376
+ return;
377
+ }
378
+ render("submit");
379
+ cleanup();
380
+ resolve([...lockedValues, ...Array.from(selected)]);
381
+ };
382
+ const cancel2 = () => {
383
+ render("cancel");
384
+ cleanup();
385
+ resolve(cancelSymbol);
386
+ };
387
+ const keypressHandler = (_str, key) => {
388
+ if (!key) return;
389
+ const filtered = getFiltered();
390
+ if (key.name === "return") {
391
+ submit();
392
+ return;
393
+ }
394
+ if (key.name === "escape" || key.ctrl && key.name === "c") {
395
+ cancel2();
396
+ return;
397
+ }
398
+ if (key.name === "up") {
399
+ cursor = Math.max(0, cursor - 1);
400
+ render();
401
+ return;
402
+ }
403
+ if (key.name === "down") {
404
+ cursor = Math.min(filtered.length - 1, cursor + 1);
405
+ render();
406
+ return;
407
+ }
408
+ if (key.name === "space") {
409
+ const item = filtered[cursor];
410
+ if (item) {
411
+ if (selected.has(item.value)) {
412
+ selected.delete(item.value);
413
+ } else {
414
+ selected.add(item.value);
415
+ }
416
+ }
417
+ render();
418
+ return;
419
+ }
420
+ if (key.name === "backspace") {
421
+ query = query.slice(0, -1);
422
+ cursor = 0;
423
+ render();
424
+ return;
425
+ }
426
+ if (key.sequence && !key.ctrl && !key.meta && key.sequence.length === 1) {
427
+ query += key.sequence;
428
+ cursor = 0;
429
+ render();
430
+ return;
431
+ }
432
+ };
433
+ process.stdin.on("keypress", keypressHandler);
434
+ render();
435
+ });
436
+ }
437
+
438
+ // src/lib/text.ts
439
+ function pluralize(word, count) {
440
+ return count === 1 ? word : `${word}s`;
441
+ }
442
+
443
+ // src/lib/agent-skills-setup.ts
444
+ var DEFAULT_SKILLS_DIR = ".agents/skills";
445
+ async function setupAgentSkills(projectDir, options = {}) {
446
+ const info = options.onInfo ?? p3.log.info;
447
+ const warning = options.onWarning ?? p3.log.warn;
448
+ const interactive = options.interactive ?? true;
449
+ const hasExplicitSelection = options.selectedAgents !== void 0;
450
+ try {
451
+ if (!hasExplicitSelection && !interactive) {
452
+ return;
453
+ }
454
+ const canonicalSkillsDir = join(projectDir, DEFAULT_SKILLS_DIR);
455
+ const hasSkillsDir = await pathExists(canonicalSkillsDir);
456
+ if (!hasSkillsDir) {
457
+ return;
458
+ }
459
+ const skillNames = await discoverSkillNames(canonicalSkillsDir);
460
+ if (skillNames.length === 0) {
461
+ info("No skills found in .agents/skills. Skipping compatibility setup.");
462
+ return;
463
+ }
464
+ let selected = options.selectedAgents;
465
+ if (selected === void 0) {
466
+ const promptForAgents = options.promptForAgents ?? defaultPromptForAgents;
467
+ selected = await promptForAgents();
468
+ }
469
+ if (p3.isCancel(selected) || typeof selected === "symbol") {
470
+ info("Skipped compatibility setup.");
471
+ return;
472
+ }
473
+ if (selected.length === 0) {
474
+ info("No additional agents selected. Skipping compatibility setup.");
475
+ return;
476
+ }
477
+ const nonUniversalAgents = selected.filter(
478
+ (agent) => !isUniversalAgent(agent)
479
+ );
480
+ if (nonUniversalAgents.length === 0) {
481
+ info(
482
+ "Selected agents already use .agents/skills. No compatibility symlinks needed."
483
+ );
484
+ return;
485
+ }
486
+ const results = await createAgentSkillSymlinks({
487
+ projectDir,
488
+ canonicalSkillsDir,
489
+ skillNames,
490
+ selectedAgents: nonUniversalAgents
491
+ });
492
+ const selectedAgentNames = selected.map((agent) => agents[agent].displayName).join(", ");
493
+ info(`Selected agent support: ${selectedAgentNames}.`);
494
+ if (results.created.length > 0) {
495
+ info(
496
+ `Created compatibility ${pluralize("symlink", results.created.length)} (${skillNames.length} ${pluralize("skill", skillNames.length)} \xD7 ${nonUniversalAgents.length} ${pluralize("agent", nonUniversalAgents.length)}).`
497
+ );
498
+ }
499
+ if (results.skipped.length > 0) {
500
+ warning(
501
+ `Skipped ${results.skipped.length} existing ${pluralize("path", results.skipped.length)}: ${results.skipped.map((entry) => entry.linkPath).join(", ")}`
502
+ );
503
+ }
504
+ if (results.failed.length > 0) {
505
+ warning(
506
+ `Failed to create ${results.failed.length} ${pluralize("symlink", results.failed.length)}: ${results.failed.map((entry) => `${entry.linkPath} (${entry.reason})`).join(", ")}`
507
+ );
508
+ }
509
+ } catch (error) {
510
+ const warning2 = options.onWarning ?? p3.log.warn;
511
+ const message = error instanceof Error ? error.message : "Unknown error during compatibility setup";
512
+ warning2(`Compatibility setup skipped: ${message}`);
513
+ }
514
+ }
515
+ async function defaultPromptForAgents() {
516
+ const universalAgents = getUniversalAgents();
517
+ const additionalAgents = getNonUniversalAgents();
518
+ const selected = await searchMultiselect({
519
+ message: "Which additional agents should this codebase support?",
520
+ items: additionalAgents.map((agent) => ({
521
+ value: agent,
522
+ label: agents[agent].displayName,
523
+ hint: agents[agent].skillsDir
524
+ })),
525
+ lockedSection: {
526
+ title: "Universal (.agents/skills)",
527
+ items: universalAgents.map((agent) => ({
528
+ value: agent,
529
+ label: agents[agent].displayName
530
+ }))
531
+ }
532
+ });
533
+ if (selected === cancelSymbol) {
534
+ return selected;
535
+ }
536
+ return selected;
537
+ }
538
+ async function discoverSkillNames(canonicalSkillsDir) {
539
+ const entries = await readdir(canonicalSkillsDir, { withFileTypes: true });
540
+ return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort((a, b) => a.localeCompare(b));
541
+ }
542
+ async function createAgentSkillSymlinks(options) {
543
+ const created = [];
544
+ const skipped = [];
545
+ const failed = [];
546
+ for (const agent of options.selectedAgents) {
547
+ const agentSkillsDir = join(options.projectDir, agents[agent].skillsDir);
548
+ for (const skill of options.skillNames) {
549
+ const targetPath = join(options.canonicalSkillsDir, skill);
550
+ const linkPath = join(agentSkillsDir, skill);
551
+ await mkdir(dirname(linkPath), { recursive: true });
552
+ if (await pathExists(linkPath)) {
553
+ skipped.push({ agent, skill, linkPath });
554
+ continue;
555
+ }
556
+ try {
557
+ const relativeTarget = relative(dirname(linkPath), targetPath);
558
+ const symlinkType = platform() === "win32" ? "junction" : void 0;
559
+ await symlink(relativeTarget, linkPath, symlinkType);
560
+ created.push({ agent, skill, linkPath });
561
+ } catch (error) {
562
+ failed.push({
563
+ agent,
564
+ skill,
565
+ linkPath,
566
+ reason: error instanceof Error ? error.message : "Unknown error"
567
+ });
568
+ }
569
+ }
570
+ }
571
+ return { created, skipped, failed };
572
+ }
573
+ async function pathExists(path) {
574
+ try {
575
+ await access(path);
576
+ return true;
577
+ } catch {
578
+ return false;
579
+ }
580
+ }
581
+
32
582
  // src/lib/detect-package-manager.ts
33
583
  function detectPackageManager() {
34
584
  const userAgent = process.env.npm_config_user_agent || "";
@@ -47,7 +597,7 @@ function detectPackageManager() {
47
597
  // package.json
48
598
  var package_default = {
49
599
  name: "@drupal-canvas/create",
50
- version: "1.0.1",
600
+ version: "1.3.0",
51
601
  description: "CLI to scaffold a codebase for working with Drupal Canvas Code Components"};
52
602
 
53
603
  // src/lib/meta-info.ts
@@ -59,9 +609,10 @@ var use_git_default = (baseDir) => simpleGit(baseDir).env({ ...process.env, GIT_
59
609
 
60
610
  // src/create.ts
61
611
  async function createApp(ctx) {
62
- const { template, appName } = ctx;
612
+ const { template, appName, selectedAgents } = ctx;
613
+ const projectDir = `${process.cwd()}/${appName}`;
63
614
  try {
64
- const s1 = p2.spinner();
615
+ const s1 = p3.spinner();
65
616
  s1.start("Fetching initial codebase");
66
617
  const hasCommitSHARef = /^[a-f0-9]{40}$/i.test(template.repository.ref);
67
618
  const git = use_git_default();
@@ -72,13 +623,13 @@ async function createApp(ctx) {
72
623
  options["--branch"] = template.repository.ref;
73
624
  }
74
625
  await git.clone(template.repository.url, appName, options);
75
- const gitAppDir = use_git_default(`${process.cwd()}/${appName}`);
626
+ const gitAppDir = use_git_default(projectDir);
76
627
  if (hasCommitSHARef) {
77
628
  await gitAppDir.fetch("origin", template.repository.ref);
78
629
  await gitAppDir.checkout(template.repository.ref);
79
630
  }
80
- await rimraf(`${process.cwd()}/${appName}/.git`);
81
- const packageJsonPath = join(process.cwd(), appName, "package.json");
631
+ await rimraf(`${projectDir}/.git`);
632
+ const packageJsonPath = join(projectDir, "package.json");
82
633
  const packageJsonContent = await readFile(packageJsonPath, "utf-8");
83
634
  const packageJson = JSON.parse(packageJsonContent);
84
635
  packageJson.name = appName;
@@ -87,7 +638,11 @@ async function createApp(ctx) {
87
638
  JSON.stringify(packageJson, null, 2) + "\n"
88
639
  );
89
640
  s1.stop(chalk.green("Fetched initial codebase"));
90
- const s2 = p2.spinner();
641
+ await setupAgentSkills(projectDir, {
642
+ selectedAgents,
643
+ interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY)
644
+ });
645
+ const s2 = p3.spinner();
91
646
  const packageManager = detectPackageManager();
92
647
  s2.start(`Installing dependencies using ${packageManager}`);
93
648
  await new Promise((resolve, reject) => {
@@ -121,7 +676,7 @@ ${stderrOutput}` : ""}`
121
676
  });
122
677
  });
123
678
  s2.stop(chalk.green("Installed dependencies"));
124
- const s3 = p2.spinner();
679
+ const s3 = p3.spinner();
125
680
  s3.start("Preparing your repository");
126
681
  await git.init(["--initial-branch=main", appName]);
127
682
  await gitAppDir.add(["--all"]);
@@ -132,18 +687,56 @@ Template repository: ${template.repository.url}
132
687
  Ref: ${template.repository.ref}`
133
688
  );
134
689
  s3.stop(chalk.green("Prepared repository"));
135
- p2.note(`$ cd ${appName}
690
+ p3.note(`$ cd ${appName}
136
691
  $ ${packageManager} run dev`, "Get started");
137
- p2.outro("\u{1F680} App created successfully");
692
+ p3.outro("\u{1F680} App created successfully");
138
693
  } catch (error) {
139
694
  if (error instanceof Error) {
140
- p2.log.error(`Error: ${error.message}`);
695
+ p3.log.error(`Error: ${error.message}`);
141
696
  } else {
142
- p2.log.error(`Unknown error: ${String(error)}`);
697
+ p3.log.error(`Unknown error: ${String(error)}`);
143
698
  }
144
699
  process.exit(1);
145
700
  }
146
701
  }
702
+
703
+ // src/lib/agent-selection.ts
704
+ var NONE_VALUE = "none";
705
+ function parseAgentSelection(value) {
706
+ if (value === void 0) {
707
+ return void 0;
708
+ }
709
+ const selectedAgents = Array.from(
710
+ new Set(
711
+ value.split(",").map((agent) => agent.trim()).filter(Boolean)
712
+ )
713
+ );
714
+ if (selectedAgents.length === 0) {
715
+ throw new Error(
716
+ 'Invalid --agents value. Provide a comma-separated list or "none".'
717
+ );
718
+ }
719
+ if (selectedAgents.includes(NONE_VALUE)) {
720
+ if (selectedAgents.length > 1) {
721
+ throw new Error(
722
+ 'Invalid --agents value. "none" cannot be combined with other agents.'
723
+ );
724
+ }
725
+ return [];
726
+ }
727
+ const nonUniversalAgents = new Set(getNonUniversalAgents());
728
+ return selectedAgents.map((agent) => {
729
+ if (!isAgentType(agent)) {
730
+ throw new Error(`Invalid --agents value. Unknown agent "${agent}".`);
731
+ }
732
+ if (isUniversalAgent(agent) || !nonUniversalAgents.has(agent)) {
733
+ throw new Error(
734
+ `Invalid --agents value. Agent "${agent}" already uses .agents/skills.`
735
+ );
736
+ }
737
+ return agent;
738
+ });
739
+ }
147
740
  function validateName(name) {
148
741
  const nameValidation = validate(name);
149
742
  if (nameValidation.validForNewPackages) {
@@ -168,9 +761,13 @@ program.name(getName()).description(getDescription()).version(getVersion()).argu
168
761
  ).option(
169
762
  "-r, --ref <ref>",
170
763
  "use Git ref when cloning template repository (for example, branch name or tag)"
764
+ ).option(
765
+ "-a, --agents <agents>",
766
+ 'comma-separated list of additional agents to support, or "none" to skip compatibility symlinks'
171
767
  ).action(async (appNameArg, options) => {
172
- p2.intro(chalk.bold("Drupal Canvas Create"));
768
+ p3.intro(chalk.bold("Drupal Canvas Create"));
173
769
  try {
770
+ const selectedAgents = parseAgentSelection(options.agents);
174
771
  if (options.template) {
175
772
  const template2 = templates_default.find(
176
773
  (t) => t.id === options.template
@@ -195,13 +792,13 @@ program.name(getName()).description(getDescription()).version(getVersion()).argu
195
792
  }
196
793
  });
197
794
  } else if (!template2) {
198
- p2.log.error(`Template "${options.template}" not found`);
795
+ p3.log.error(`Template "${options.template}" not found`);
199
796
  process.exit(1);
200
797
  }
201
798
  }
202
799
  let appName = appNameArg;
203
800
  if (!appName) {
204
- const name = await p2.text({
801
+ const name = await p3.text({
205
802
  message: "Enter the app name",
206
803
  initialValue: "my-canvas-app",
207
804
  validate: (value) => {
@@ -213,15 +810,15 @@ program.name(getName()).description(getDescription()).version(getVersion()).argu
213
810
  return;
214
811
  }
215
812
  });
216
- if (p2.isCancel(name)) {
217
- p2.cancel("Operation cancelled");
813
+ if (p3.isCancel(name)) {
814
+ p3.cancel("Operation cancelled");
218
815
  process.exit(0);
219
816
  }
220
817
  appName = name;
221
818
  } else {
222
819
  const { valid, problems } = validateName(appName);
223
820
  if (!valid) {
224
- p2.log.error(`Invalid app name: ${problems.join(", ")}`);
821
+ p3.log.error(`Invalid app name: ${problems.join(", ")}`);
225
822
  process.exit(1);
226
823
  }
227
824
  }
@@ -230,15 +827,15 @@ program.name(getName()).description(getDescription()).version(getVersion()).argu
230
827
  if (templates_default.length === 1) {
231
828
  templateId = templates_default[0].id;
232
829
  } else {
233
- const selected = await p2.select({
830
+ const selected = await p3.select({
234
831
  message: "Select a template",
235
832
  options: templates_default.map((t, index) => ({
236
833
  value: t.id,
237
834
  label: index === 0 ? `${t.label} (Recommended)` : t.label
238
835
  }))
239
836
  });
240
- if (p2.isCancel(selected)) {
241
- p2.cancel("Operation cancelled");
837
+ if (p3.isCancel(selected)) {
838
+ p3.cancel("Operation cancelled");
242
839
  process.exit(0);
243
840
  }
244
841
  templateId = selected;
@@ -250,14 +847,14 @@ program.name(getName()).description(getDescription()).version(getVersion()).argu
250
847
  if (options.ref) {
251
848
  template.repository.ref = options.ref;
252
849
  }
253
- p2.note(`Template: ${template.label}
850
+ p3.note(`Template: ${template.label}
254
851
  App name: ${appName}`);
255
- await createApp({ template, appName });
852
+ await createApp({ template, appName, selectedAgents });
256
853
  } catch (error) {
257
854
  if (error instanceof Error) {
258
- p2.log.error(`Error: ${error.message}`);
855
+ p3.log.error(`Error: ${error.message}`);
259
856
  } else {
260
- p2.log.error(`Unknown error: ${String(error)}`);
857
+ p3.log.error(`Unknown error: ${String(error)}`);
261
858
  }
262
859
  process.exit(1);
263
860
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drupal-canvas/create",
3
- "version": "1.0.1",
3
+ "version": "1.3.0",
4
4
  "description": "CLI to scaffold a codebase for working with Drupal Canvas Code Components",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -30,20 +30,25 @@
30
30
  "chalk": "^5.6.2",
31
31
  "commander": "^14.0.2",
32
32
  "cross-spawn": "^7.0.6",
33
+ "picocolors": "^1.1.1",
33
34
  "rimraf": "^6.1.2",
34
35
  "simple-git": "^3.30.0",
36
+ "string-width": "^7.2.0",
35
37
  "validate-npm-package-name": "^7.0.0"
36
38
  },
37
39
  "devDependencies": {
38
40
  "@types/cross-spawn": "^6.0.6",
39
41
  "@types/validate-npm-package-name": "^4.0.2",
40
42
  "tsup": "^8.5.1",
41
- "typescript": "^5.9.3"
43
+ "typescript": "^5.9.3",
44
+ "vitest": "^4.0.18"
42
45
  },
43
46
  "scripts": {
44
47
  "start": "node dist/index.js",
45
48
  "build": "NODE_ENV=production tsup",
46
49
  "dev": "NODE_ENV=development tsup --watch",
47
- "type-check": "tsc --noEmit --pretty"
50
+ "type-check": "tsc --noEmit --pretty",
51
+ "test": "vitest run",
52
+ "test:watch": "vitest watch"
48
53
  }
49
54
  }
package/templates.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "id": "acquia-nebula",
4
4
  "label": "acquia/nebula",
5
5
  "repository": {
6
- "url": "git@github.com:acquia/nebula.git",
6
+ "url": "https://github.com/acquia/nebula.git",
7
7
  "ref": "main"
8
8
  }
9
9
  },
@@ -11,7 +11,7 @@
11
11
  "id": "balintbrews-canvas-starter",
12
12
  "label": "balintbrews/canvas-starter",
13
13
  "repository": {
14
- "url": "git@github.com:balintbrews/canvas-starter.git",
14
+ "url": "https://github.com/balintbrews/canvas-starter.git",
15
15
  "ref": "main"
16
16
  }
17
17
  }