clauderc 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clauderc",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "Setup Claude Code with best practices - agents, skills, commands, and templates",
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,7 +9,8 @@
9
9
  "scripts": {
10
10
  "dev": "node bin/cli.js",
11
11
  "test": "node test/test-detector.js",
12
- "test:cli": "node bin/cli.js --help && node bin/cli.js list"
12
+ "test:cli": "node bin/cli.js --help && node bin/cli.js list",
13
+ "semantic-release": "semantic-release"
13
14
  },
14
15
  "keywords": [
15
16
  "claude",
@@ -40,5 +41,10 @@
40
41
  "darwin",
41
42
  "linux",
42
43
  "win32"
43
- ]
44
+ ],
45
+ "devDependencies": {
46
+ "@semantic-release/changelog": "^6.0.3",
47
+ "@semantic-release/git": "^10.0.1",
48
+ "semantic-release": "^24.2.1"
49
+ }
44
50
  }
package/src/detector.js CHANGED
@@ -146,31 +146,35 @@ IMPORTANT:
146
146
  - Return commands that will actually work for this project`;
147
147
 
148
148
  try {
149
- // Escape the prompt for shell
150
- const escapedPrompt = prompt
151
- .replace(/\\/g, '\\\\')
152
- .replace(/"/g, '\\"')
153
- .replace(/\$/g, '\\$')
154
- .replace(/`/g, '\\`');
155
-
156
- const result = execSync(
157
- `claude -p --model haiku "${escapedPrompt}"`,
158
- {
159
- encoding: 'utf-8',
160
- maxBuffer: 1024 * 1024 * 10,
161
- timeout: 120000, // 2 minute timeout
162
- cwd: projectPath,
163
- }
164
- );
149
+ // Use stdin to avoid shell escaping issues with large prompts
150
+ const result = execSync('claude -p --model haiku', {
151
+ input: prompt,
152
+ encoding: 'utf-8',
153
+ maxBuffer: 1024 * 1024 * 10,
154
+ timeout: 120000, // 2 minute timeout
155
+ cwd: projectPath,
156
+ });
165
157
 
166
158
  // Extract JSON from response
167
159
  const jsonMatch = result.match(/\{[\s\S]*\}/);
168
160
  if (!jsonMatch) {
169
- console.warn(' ⚠ Could not parse Claude response');
161
+ console.warn(' ⚠ Could not parse Claude response - no JSON found in output');
162
+ return null;
163
+ }
164
+
165
+ let analysis;
166
+ try {
167
+ analysis = JSON.parse(jsonMatch[0]);
168
+ } catch (parseError) {
169
+ console.warn(' ⚠ Could not parse JSON from Claude response:', parseError.message);
170
170
  return null;
171
171
  }
172
172
 
173
- const analysis = JSON.parse(jsonMatch[0]);
173
+ // Validate the analysis has the expected structure
174
+ if (!analysis.stack || !analysis.commands) {
175
+ console.warn(' ⚠ Claude response missing required fields (stack, commands)');
176
+ return null;
177
+ }
174
178
 
175
179
  // Convert to detectStack compatible format
176
180
  return {
@@ -180,7 +184,11 @@ IMPORTANT:
180
184
  preferences: analysis.preferences,
181
185
  };
182
186
  } catch (error) {
183
- console.warn(' ⚠ Claude analysis failed:', error.message);
187
+ if (error.code === 'ENOENT') {
188
+ console.warn(' ⚠ Claude CLI not found - install from https://claude.com/code');
189
+ } else {
190
+ console.warn(' ⚠ Claude analysis failed:', error.message);
191
+ }
184
192
  return null;
185
193
  }
186
194
  }
package/src/project.js CHANGED
@@ -39,19 +39,27 @@ IMPORTANT RULES:
39
39
  Output the merged ${fileType}:`;
40
40
 
41
41
  try {
42
- // Use Claude CLI in print mode for non-interactive merge
43
- const result = execSync(
44
- `claude -p --model haiku "${prompt.replace(/"/g, '\\"').replace(/\n/g, '\\n')}"`,
45
- {
46
- encoding: 'utf-8',
47
- maxBuffer: 1024 * 1024 * 10, // 10MB buffer
48
- timeout: 60000, // 60 second timeout
49
- }
50
- );
51
- return result.trim();
42
+ // Use stdin to avoid shell escaping issues with large prompts
43
+ const result = execSync('claude -p --model haiku', {
44
+ input: prompt,
45
+ encoding: 'utf-8',
46
+ maxBuffer: 1024 * 1024 * 10, // 10MB buffer
47
+ timeout: 60000, // 60 second timeout
48
+ });
49
+
50
+ const trimmed = result.trim();
51
+
52
+ // Validate the response is not an error message
53
+ if (trimmed.includes('Error:') || trimmed.includes('error:') || trimmed.length < 100) {
54
+ console.warn(' ⚠ Claude merge returned invalid response, using new content');
55
+ return newContent;
56
+ }
57
+
58
+ return trimmed;
52
59
  } catch (error) {
53
60
  // If Claude CLI fails, return new content with a warning
54
- console.warn(' ⚠ Could not use Claude for merge, using new content');
61
+ console.warn(' ⚠ Could not use Claude for merge (CLI not available), using new content');
62
+ console.warn(` ⚠ Error: ${error.message}`);
55
63
  return newContent;
56
64
  }
57
65
  }
@@ -474,7 +482,7 @@ export async function runProjectWizard(options = {}) {
474
482
  if (hasExisting || hasExistingClaudeMd) {
475
483
  log('\n Existing configuration detected.\n');
476
484
  const mergeChoice = await prompt.select(' How would you like to proceed?', [
477
- { label: 'Merge', description: 'Use Claude to intelligently merge with existing config (recommended)' },
485
+ { label: 'Merge', description: 'Use Claude CLI to intelligently merge with existing config (recommended)' },
478
486
  { label: 'Overwrite', description: 'Replace all existing configuration' },
479
487
  { label: 'Cancel', description: 'Keep existing configuration unchanged' },
480
488
  ]);
@@ -488,7 +496,8 @@ export async function runProjectWizard(options = {}) {
488
496
  useMerge = mergeChoice.label === 'Merge';
489
497
 
490
498
  if (useMerge) {
491
- log('\n Will use Claude to merge configurations intelligently.\n');
499
+ log('\n Will use Claude CLI to merge configurations intelligently.');
500
+ log(' Note: If Claude CLI is not available, new content will be used.\n');
492
501
  }
493
502
  }
494
503