@drupal-canvas/create 1.1.0 → 1.4.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.
Files changed (3) hide show
  1. package/README.md +42 -5
  2. package/dist/index.js +157 -57
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -30,15 +30,52 @@ 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
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
+
60
+ ### `agents` command
61
+
62
+ Set up compatibility symlinks for additional agent skills directories in an
63
+ existing project:
64
+
65
+ ```bash
66
+ npx @drupal-canvas/create@latest agents
67
+ ```
68
+
69
+ You can also provide the agents as an argument:
70
+
71
+ ```bash
72
+ npx @drupal-canvas/create@latest agents claude-code,roo
73
+ ```
74
+
75
+ Skip compatibility symlinks:
76
+
77
+ ```bash
78
+ npx @drupal-canvas/create@latest agents none
42
79
  ```
43
80
 
44
81
  ## Development
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env node
2
- import chalk from 'chalk';
2
+ import chalk2 from 'chalk';
3
3
  import { Command } from 'commander';
4
- import * as p3 from '@clack/prompts';
4
+ import * as p4 from '@clack/prompts';
5
5
  import { readFile, writeFile, access, readdir, mkdir, symlink } from 'fs/promises';
6
- import { join, dirname, relative } from 'path';
7
- import spawn from 'cross-spawn';
8
- import { rimraf } from 'rimraf';
9
6
  import { platform } from 'os';
7
+ import { join, dirname, relative } from 'path';
10
8
  import * as readline from 'readline';
11
9
  import { Writable } from 'stream';
12
10
  import pc from 'picocolors';
11
+ import spawn from 'cross-spawn';
12
+ import { rimraf } from 'rimraf';
13
13
  import { simpleGit } from 'simple-git';
14
14
  import validate from 'validate-npm-package-name';
15
15
 
@@ -41,7 +41,7 @@ var agents = {
41
41
  },
42
42
  antigravity: {
43
43
  displayName: "Antigravity",
44
- skillsDir: ".agent/skills"
44
+ skillsDir: ".agents/skills"
45
45
  },
46
46
  augment: {
47
47
  displayName: "Augment",
@@ -57,7 +57,7 @@ var agents = {
57
57
  },
58
58
  cline: {
59
59
  displayName: "Cline",
60
- skillsDir: ".cline/skills"
60
+ skillsDir: ".agents/skills"
61
61
  },
62
62
  codebuddy: {
63
63
  displayName: "CodeBuddy",
@@ -75,13 +75,21 @@ var agents = {
75
75
  displayName: "Continue",
76
76
  skillsDir: ".continue/skills"
77
77
  },
78
+ cortex: {
79
+ displayName: "Cortex Code",
80
+ skillsDir: ".cortex/skills"
81
+ },
78
82
  crush: {
79
83
  displayName: "Crush",
80
84
  skillsDir: ".crush/skills"
81
85
  },
82
86
  cursor: {
83
87
  displayName: "Cursor",
84
- skillsDir: ".cursor/skills"
88
+ skillsDir: ".agents/skills"
89
+ },
90
+ deepagents: {
91
+ displayName: "Deep Agents",
92
+ skillsDir: ".agents/skills"
85
93
  },
86
94
  droid: {
87
95
  displayName: "Droid",
@@ -172,6 +180,10 @@ var agents = {
172
180
  displayName: "Trae CN",
173
181
  skillsDir: ".trae/skills"
174
182
  },
183
+ warp: {
184
+ displayName: "Warp",
185
+ skillsDir: ".agents/skills"
186
+ },
175
187
  windsurf: {
176
188
  displayName: "Windsurf",
177
189
  skillsDir: ".windsurf/skills"
@@ -211,6 +223,47 @@ function getNonUniversalAgents() {
211
223
  function isUniversalAgent(type) {
212
224
  return agents[type].skillsDir === ".agents/skills";
213
225
  }
226
+ function isAgentType(value) {
227
+ return Object.prototype.hasOwnProperty.call(agents, value);
228
+ }
229
+
230
+ // src/lib/agent-selection.ts
231
+ var NONE_VALUE = "none";
232
+ function parseAgentSelection(value, label = "--agents") {
233
+ if (value === void 0) {
234
+ return void 0;
235
+ }
236
+ const selectedAgents = Array.from(
237
+ new Set(
238
+ value.split(",").map((agent) => agent.trim()).filter(Boolean)
239
+ )
240
+ );
241
+ if (selectedAgents.length === 0) {
242
+ throw new Error(
243
+ `Invalid ${label} value. Provide a comma-separated list or "none".`
244
+ );
245
+ }
246
+ if (selectedAgents.includes(NONE_VALUE)) {
247
+ if (selectedAgents.length > 1) {
248
+ throw new Error(
249
+ `Invalid ${label} value. "none" cannot be combined with other agents.`
250
+ );
251
+ }
252
+ return [];
253
+ }
254
+ const nonUniversalAgents = new Set(getNonUniversalAgents());
255
+ return selectedAgents.map((agent) => {
256
+ if (!isAgentType(agent)) {
257
+ throw new Error(`Invalid ${label} value. Unknown agent "${agent}".`);
258
+ }
259
+ if (isUniversalAgent(agent) || !nonUniversalAgents.has(agent)) {
260
+ throw new Error(
261
+ `Invalid ${label} value. Agent "${agent}" already uses .agents/skills.`
262
+ );
263
+ }
264
+ return agent;
265
+ });
266
+ }
214
267
  var silentOutput = new Writable({
215
268
  write(_chunk, _encoding, callback) {
216
269
  callback();
@@ -221,7 +274,7 @@ var S_STEP_CANCEL = pc.red("\u25A0");
221
274
  var S_STEP_SUBMIT = pc.green("\u25C7");
222
275
  var S_RADIO_ACTIVE = pc.green("\u25CF");
223
276
  var S_RADIO_INACTIVE = pc.dim("\u25CB");
224
- var S_CHECKBOX_LOCKED = pc.green("\u2713");
277
+ var S_BULLET = pc.green("\u2022");
225
278
  var S_BAR = pc.dim("\u2502");
226
279
  var S_BAR_H = pc.dim("\u2500");
227
280
  var cancelSymbol = /* @__PURE__ */ Symbol("cancel");
@@ -275,15 +328,16 @@ async function searchMultiselect(options) {
275
328
  if (state === "active") {
276
329
  if (lockedSection && lockedSection.items.length > 0) {
277
330
  lines.push(`${S_BAR}`);
331
+ const lockedTitle = `${pc.bold(lockedSection.title)} ${pc.dim("\u2500\u2500 always included")}`;
278
332
  lines.push(
279
- `${S_BAR} ${S_BAR_H}${S_BAR_H} ${pc.bold(lockedSection.title)} ${S_BAR_H.repeat(30)}`
333
+ `${S_BAR} ${S_BAR_H}${S_BAR_H} ${lockedTitle} ${S_BAR_H.repeat(12)}`
280
334
  );
281
335
  for (const item of lockedSection.items) {
282
- lines.push(`${S_BAR} ${S_CHECKBOX_LOCKED} ${item.label}`);
336
+ lines.push(`${S_BAR} ${S_BULLET} ${pc.bold(item.label)}`);
283
337
  }
284
338
  lines.push(`${S_BAR}`);
285
339
  lines.push(
286
- `${S_BAR} ${S_BAR_H}${S_BAR_H} ${pc.bold("Other agents")} ${S_BAR_H.repeat(34)}`
340
+ `${S_BAR} ${S_BAR_H}${S_BAR_H} ${pc.bold("Additional agents")} ${S_BAR_H.repeat(29)}`
287
341
  );
288
342
  }
289
343
  const searchLine = `${S_BAR} ${pc.dim("Search:")} ${query}${pc.inverse(" ")}`;
@@ -427,36 +481,45 @@ function pluralize(word, count) {
427
481
  // src/lib/agent-skills-setup.ts
428
482
  var DEFAULT_SKILLS_DIR = ".agents/skills";
429
483
  async function setupAgentSkills(projectDir, options = {}) {
430
- const info = options.onInfo ?? p3.log.info;
431
- const warning = options.onWarning ?? p3.log.warn;
484
+ const info = options.onInfo ?? p4.log.info;
485
+ const warning = options.onWarning ?? p4.log.warn;
486
+ const interactive = options.interactive ?? true;
487
+ const hasExplicitSelection = options.selectedAgents !== void 0;
432
488
  try {
489
+ if (!hasExplicitSelection && !interactive) {
490
+ return;
491
+ }
433
492
  const canonicalSkillsDir = join(projectDir, DEFAULT_SKILLS_DIR);
434
493
  const hasSkillsDir = await pathExists(canonicalSkillsDir);
435
494
  if (!hasSkillsDir) {
495
+ info("No .agents/skills directory found. Skipping compatibility setup.");
436
496
  return;
437
497
  }
438
498
  const skillNames = await discoverSkillNames(canonicalSkillsDir);
439
499
  if (skillNames.length === 0) {
440
- info(
441
- "No skills found in .agents/skills. Skipping agent compatibility setup."
442
- );
500
+ info("No skills found in .agents/skills. Skipping compatibility setup.");
443
501
  return;
444
502
  }
445
- const promptForAgents = options.promptForAgents ?? defaultPromptForAgents;
446
- const selected = await promptForAgents();
447
- if (p3.isCancel(selected) || typeof selected === "symbol") {
448
- info("Skipped agent compatibility setup.");
503
+ let selected = options.selectedAgents;
504
+ if (selected === void 0) {
505
+ const promptForAgents = options.promptForAgents ?? defaultPromptForAgents;
506
+ selected = await promptForAgents();
507
+ }
508
+ if (p4.isCancel(selected) || typeof selected === "symbol") {
509
+ info("Skipped compatibility setup.");
449
510
  return;
450
511
  }
451
512
  if (selected.length === 0) {
452
- info("No agents selected. Skipping agent compatibility setup.");
513
+ info("No additional agents selected. Skipping compatibility setup.");
453
514
  return;
454
515
  }
455
516
  const nonUniversalAgents = selected.filter(
456
517
  (agent) => !isUniversalAgent(agent)
457
518
  );
458
519
  if (nonUniversalAgents.length === 0) {
459
- info("Selected agents already use .agents/skills. No symlinks needed.");
520
+ info(
521
+ "Selected agents already use .agents/skills. No compatibility symlinks needed."
522
+ );
460
523
  return;
461
524
  }
462
525
  const results = await createAgentSkillSymlinks({
@@ -466,7 +529,7 @@ async function setupAgentSkills(projectDir, options = {}) {
466
529
  selectedAgents: nonUniversalAgents
467
530
  });
468
531
  const selectedAgentNames = selected.map((agent) => agents[agent].displayName).join(", ");
469
- info(`Agent skill support selected: ${selectedAgentNames}.`);
532
+ info(`Selected agent support: ${selectedAgentNames}.`);
470
533
  if (results.created.length > 0) {
471
534
  info(
472
535
  `Created compatibility ${pluralize("symlink", results.created.length)} (${skillNames.length} ${pluralize("skill", skillNames.length)} \xD7 ${nonUniversalAgents.length} ${pluralize("agent", nonUniversalAgents.length)}).`
@@ -483,17 +546,18 @@ async function setupAgentSkills(projectDir, options = {}) {
483
546
  );
484
547
  }
485
548
  } catch (error) {
486
- const warning2 = options.onWarning ?? p3.log.warn;
487
- const message = error instanceof Error ? error.message : "Unknown error during agent compatibility setup";
488
- warning2(`Agent compatibility setup skipped: ${message}`);
549
+ const warning2 = options.onWarning ?? p4.log.warn;
550
+ const message = error instanceof Error ? error.message : "Unknown error during compatibility setup";
551
+ warning2(`Compatibility setup skipped: ${message}`);
489
552
  }
490
553
  }
491
554
  async function defaultPromptForAgents() {
492
555
  const universalAgents = getUniversalAgents();
493
- const otherAgents = getNonUniversalAgents();
556
+ const additionalAgents = getNonUniversalAgents();
557
+ p4.log.message("");
494
558
  const selected = await searchMultiselect({
495
- message: "Which coding agents should this codebase support?",
496
- items: otherAgents.map((agent) => ({
559
+ message: "Which additional agents should this codebase support?",
560
+ items: additionalAgents.map((agent) => ({
497
561
  value: agent,
498
562
  label: agents[agent].displayName,
499
563
  hint: agents[agent].skillsDir
@@ -555,6 +619,34 @@ async function pathExists(path) {
555
619
  }
556
620
  }
557
621
 
622
+ // src/agents.ts
623
+ function agentsCommand(program2) {
624
+ program2.command("agents").description(
625
+ "set up compatibility symlinks for additional agent skills directories"
626
+ ).argument(
627
+ "[agents]",
628
+ 'comma-separated list of additional agents to support, or "none" to skip compatibility symlinks'
629
+ ).action(async (agentsArg) => {
630
+ p4.intro(chalk2.bold("Drupal Canvas Create - agents setup"));
631
+ try {
632
+ const selectedAgents = parseAgentSelection(agentsArg, "agents");
633
+ const projectDir = process.cwd();
634
+ await setupAgentSkills(projectDir, {
635
+ selectedAgents,
636
+ interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY)
637
+ });
638
+ p4.outro("\u{1F916} Done.");
639
+ } catch (error) {
640
+ if (error instanceof Error) {
641
+ p4.log.error(`Error: ${error.message}`);
642
+ } else {
643
+ p4.log.error(`Unknown error: ${String(error)}`);
644
+ }
645
+ process.exit(1);
646
+ }
647
+ });
648
+ }
649
+
558
650
  // src/lib/detect-package-manager.ts
559
651
  function detectPackageManager() {
560
652
  const userAgent = process.env.npm_config_user_agent || "";
@@ -573,7 +665,7 @@ function detectPackageManager() {
573
665
  // package.json
574
666
  var package_default = {
575
667
  name: "@drupal-canvas/create",
576
- version: "1.0.1",
668
+ version: "1.4.0",
577
669
  description: "CLI to scaffold a codebase for working with Drupal Canvas Code Components"};
578
670
 
579
671
  // src/lib/meta-info.ts
@@ -585,10 +677,10 @@ var use_git_default = (baseDir) => simpleGit(baseDir).env({ ...process.env, GIT_
585
677
 
586
678
  // src/create.ts
587
679
  async function createApp(ctx) {
588
- const { template, appName } = ctx;
680
+ const { template, appName, selectedAgents } = ctx;
589
681
  const projectDir = `${process.cwd()}/${appName}`;
590
682
  try {
591
- const s1 = p3.spinner();
683
+ const s1 = p4.spinner();
592
684
  s1.start("Fetching initial codebase");
593
685
  const hasCommitSHARef = /^[a-f0-9]{40}$/i.test(template.repository.ref);
594
686
  const git = use_git_default();
@@ -613,9 +705,12 @@ async function createApp(ctx) {
613
705
  packageJsonPath,
614
706
  JSON.stringify(packageJson, null, 2) + "\n"
615
707
  );
616
- s1.stop(chalk.green("Fetched initial codebase"));
617
- await setupAgentSkills(projectDir);
618
- const s2 = p3.spinner();
708
+ s1.stop(chalk2.green("Fetched initial codebase"));
709
+ await setupAgentSkills(projectDir, {
710
+ selectedAgents,
711
+ interactive: Boolean(process.stdin.isTTY && process.stdout.isTTY)
712
+ });
713
+ const s2 = p4.spinner();
619
714
  const packageManager = detectPackageManager();
620
715
  s2.start(`Installing dependencies using ${packageManager}`);
621
716
  await new Promise((resolve, reject) => {
@@ -648,8 +743,8 @@ ${stderrOutput}` : ""}`
648
743
  }
649
744
  });
650
745
  });
651
- s2.stop(chalk.green("Installed dependencies"));
652
- const s3 = p3.spinner();
746
+ s2.stop(chalk2.green("Installed dependencies"));
747
+ const s3 = p4.spinner();
653
748
  s3.start("Preparing your repository");
654
749
  await git.init(["--initial-branch=main", appName]);
655
750
  await gitAppDir.add(["--all"]);
@@ -659,15 +754,15 @@ ${stderrOutput}` : ""}`
659
754
  Template repository: ${template.repository.url}
660
755
  Ref: ${template.repository.ref}`
661
756
  );
662
- s3.stop(chalk.green("Prepared repository"));
663
- p3.note(`$ cd ${appName}
757
+ s3.stop(chalk2.green("Prepared repository"));
758
+ p4.note(`$ cd ${appName}
664
759
  $ ${packageManager} run dev`, "Get started");
665
- p3.outro("\u{1F680} App created successfully");
760
+ p4.outro("\u{1F680} App created successfully");
666
761
  } catch (error) {
667
762
  if (error instanceof Error) {
668
- p3.log.error(`Error: ${error.message}`);
763
+ p4.log.error(`Error: ${error.message}`);
669
764
  } else {
670
- p3.log.error(`Unknown error: ${String(error)}`);
765
+ p4.log.error(`Unknown error: ${String(error)}`);
671
766
  }
672
767
  process.exit(1);
673
768
  }
@@ -696,9 +791,13 @@ program.name(getName()).description(getDescription()).version(getVersion()).argu
696
791
  ).option(
697
792
  "-r, --ref <ref>",
698
793
  "use Git ref when cloning template repository (for example, branch name or tag)"
794
+ ).option(
795
+ "-a, --agents <agents>",
796
+ 'comma-separated list of additional agents to support, or "none" to skip compatibility symlinks'
699
797
  ).action(async (appNameArg, options) => {
700
- p3.intro(chalk.bold("Drupal Canvas Create"));
798
+ p4.intro(chalk2.bold("Drupal Canvas Create"));
701
799
  try {
800
+ const selectedAgents = parseAgentSelection(options.agents);
702
801
  if (options.template) {
703
802
  const template2 = templates_default.find(
704
803
  (t) => t.id === options.template
@@ -723,13 +822,13 @@ program.name(getName()).description(getDescription()).version(getVersion()).argu
723
822
  }
724
823
  });
725
824
  } else if (!template2) {
726
- p3.log.error(`Template "${options.template}" not found`);
825
+ p4.log.error(`Template "${options.template}" not found`);
727
826
  process.exit(1);
728
827
  }
729
828
  }
730
829
  let appName = appNameArg;
731
830
  if (!appName) {
732
- const name = await p3.text({
831
+ const name = await p4.text({
733
832
  message: "Enter the app name",
734
833
  initialValue: "my-canvas-app",
735
834
  validate: (value) => {
@@ -741,15 +840,15 @@ program.name(getName()).description(getDescription()).version(getVersion()).argu
741
840
  return;
742
841
  }
743
842
  });
744
- if (p3.isCancel(name)) {
745
- p3.cancel("Operation cancelled");
843
+ if (p4.isCancel(name)) {
844
+ p4.cancel("Operation cancelled");
746
845
  process.exit(0);
747
846
  }
748
847
  appName = name;
749
848
  } else {
750
849
  const { valid, problems } = validateName(appName);
751
850
  if (!valid) {
752
- p3.log.error(`Invalid app name: ${problems.join(", ")}`);
851
+ p4.log.error(`Invalid app name: ${problems.join(", ")}`);
753
852
  process.exit(1);
754
853
  }
755
854
  }
@@ -758,15 +857,15 @@ program.name(getName()).description(getDescription()).version(getVersion()).argu
758
857
  if (templates_default.length === 1) {
759
858
  templateId = templates_default[0].id;
760
859
  } else {
761
- const selected = await p3.select({
860
+ const selected = await p4.select({
762
861
  message: "Select a template",
763
862
  options: templates_default.map((t, index) => ({
764
863
  value: t.id,
765
864
  label: index === 0 ? `${t.label} (Recommended)` : t.label
766
865
  }))
767
866
  });
768
- if (p3.isCancel(selected)) {
769
- p3.cancel("Operation cancelled");
867
+ if (p4.isCancel(selected)) {
868
+ p4.cancel("Operation cancelled");
770
869
  process.exit(0);
771
870
  }
772
871
  templateId = selected;
@@ -778,25 +877,26 @@ program.name(getName()).description(getDescription()).version(getVersion()).argu
778
877
  if (options.ref) {
779
878
  template.repository.ref = options.ref;
780
879
  }
781
- p3.note(`Template: ${template.label}
880
+ p4.note(`Template: ${template.label}
782
881
  App name: ${appName}`);
783
- await createApp({ template, appName });
882
+ await createApp({ template, appName, selectedAgents });
784
883
  } catch (error) {
785
884
  if (error instanceof Error) {
786
- p3.log.error(`Error: ${error.message}`);
885
+ p4.log.error(`Error: ${error.message}`);
787
886
  } else {
788
- p3.log.error(`Unknown error: ${String(error)}`);
887
+ p4.log.error(`Unknown error: ${String(error)}`);
789
888
  }
790
889
  process.exit(1);
791
890
  }
792
891
  });
892
+ agentsCommand(program);
793
893
  program.showHelpAfterError();
794
894
  program.showSuggestionAfterError(true);
795
895
  try {
796
896
  await program.parseAsync(process.argv);
797
897
  } catch (error) {
798
898
  if (error instanceof Error) {
799
- console.error(chalk.red(`Error: ${error.message}`));
899
+ console.error(chalk2.red(`Error: ${error.message}`));
800
900
  process.exit(1);
801
901
  }
802
902
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drupal-canvas/create",
3
- "version": "1.1.0",
3
+ "version": "1.4.0",
4
4
  "description": "CLI to scaffold a codebase for working with Drupal Canvas Code Components",
5
5
  "license": "MIT",
6
6
  "repository": {