@wbern/claude-instructions 1.1.0 → 1.2.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 (2) hide show
  1. package/bin/cli.js +46 -2
  2. package/package.json +1 -1
package/bin/cli.js CHANGED
@@ -23,6 +23,7 @@ var DIRECTORIES = {
23
23
  COMMANDS: "commands",
24
24
  DOWNLOADS: "downloads"
25
25
  };
26
+ var TEMPLATE_SOURCE_FILES = ["CLAUDE.md", "AGENTS.md"];
26
27
  var VARIANT_OPTIONS = [
27
28
  { value: VARIANTS.WITH_BEADS, label: "With Beads" },
28
29
  { value: VARIANTS.WITHOUT_BEADS, label: "Without Beads" }
@@ -43,7 +44,21 @@ function getDestinationPath(outputPath, scope) {
43
44
  }
44
45
  return void 0;
45
46
  }
46
- async function generateToDirectory(outputPath, variant, scope) {
47
+ function extractTemplateBlocks(content) {
48
+ const matchWithCommands = content.match(/<claude-commands-template\s+commands="([^"]+)">([\s\S]*?)<\/claude-commands-template>/);
49
+ if (matchWithCommands) {
50
+ return {
51
+ content: matchWithCommands[2].trim(),
52
+ commands: matchWithCommands[1].split(",").map((c) => c.trim())
53
+ };
54
+ }
55
+ const match = content.match(/<claude-commands-template>([\s\S]*?)<\/claude-commands-template>/);
56
+ if (!match) {
57
+ return null;
58
+ }
59
+ return { content: match[1].trim() };
60
+ }
61
+ async function generateToDirectory(outputPath, variant, scope, options) {
47
62
  const sourcePath = path.join(__dirname, "..", DIRECTORIES.DOWNLOADS, variant || VARIANTS.WITH_BEADS);
48
63
  const destinationPath = getDestinationPath(outputPath, scope);
49
64
  if (!destinationPath) {
@@ -51,10 +66,39 @@ async function generateToDirectory(outputPath, variant, scope) {
51
66
  }
52
67
  const files = await fs.readdir(sourcePath);
53
68
  await fs.copy(sourcePath, destinationPath, {});
69
+ let templateInjected = false;
70
+ if (!options?.skipTemplateInjection) {
71
+ let templateSourcePath = null;
72
+ for (const filename of TEMPLATE_SOURCE_FILES) {
73
+ const candidatePath = path.join(process.cwd(), filename);
74
+ if (await fs.pathExists(candidatePath)) {
75
+ templateSourcePath = candidatePath;
76
+ break;
77
+ }
78
+ }
79
+ if (templateSourcePath) {
80
+ const sourceContent = await fs.readFile(templateSourcePath, "utf-8");
81
+ const template = extractTemplateBlocks(sourceContent);
82
+ if (template) {
83
+ for (const file of files) {
84
+ const commandName = path.basename(file, ".md");
85
+ if (template.commands && !template.commands.includes(commandName)) {
86
+ continue;
87
+ }
88
+ const filePath = path.join(destinationPath, file);
89
+ const content = await fs.readFile(filePath, "utf-8");
90
+ await fs.writeFile(filePath, content + "\n\n" + template.content);
91
+ }
92
+ templateInjected = true;
93
+ }
94
+ }
95
+ }
54
96
  return {
55
97
  success: true,
56
98
  filesGenerated: files.length,
57
- variant
99
+ variant,
100
+ templateInjectionSkipped: options?.skipTemplateInjection,
101
+ templateInjected
58
102
  };
59
103
  }
60
104
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wbern/claude-instructions",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "TDD workflow commands for Claude Code CLI",
5
5
  "type": "module",
6
6
  "bin": "./bin/cli.js",