bonzai-tree 1.0.125 → 1.0.126
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.
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
const { ROOT } = require('../config');
|
|
4
|
+
|
|
5
|
+
function detectClaudeHandler(req, res) {
|
|
6
|
+
try {
|
|
7
|
+
// Check if CLAUDE.md exists at repo root
|
|
8
|
+
const claudeMdPath = path.join(ROOT, 'CLAUDE.md');
|
|
9
|
+
const claudeMd = fs.existsSync(claudeMdPath) ? 'CLAUDE.md' : null;
|
|
10
|
+
|
|
11
|
+
// Scan .claude/commands/ recursively for .md files
|
|
12
|
+
const skills = [];
|
|
13
|
+
const commandsDir = path.join(ROOT, '.claude', 'commands');
|
|
14
|
+
|
|
15
|
+
if (fs.existsSync(commandsDir)) {
|
|
16
|
+
(function scanDir(dir) {
|
|
17
|
+
const entries = fs.readdirSync(dir, { withFileTypes: true });
|
|
18
|
+
for (const entry of entries) {
|
|
19
|
+
const fullPath = path.join(dir, entry.name);
|
|
20
|
+
if (entry.isDirectory()) {
|
|
21
|
+
scanDir(fullPath);
|
|
22
|
+
} else if (entry.isFile() && entry.name.endsWith('.md')) {
|
|
23
|
+
skills.push(path.relative(ROOT, fullPath));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
})(commandsDir);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
res.json({ claudeMd, skills });
|
|
30
|
+
} catch (e) {
|
|
31
|
+
res.status(500).send(e.message);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = detectClaudeHandler;
|