thorns 5.1.9
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/.thornsignore +581 -0
- package/README.md +175 -0
- package/advanced-metrics.js +203 -0
- package/analyzer.js +257 -0
- package/compact-formatter.js +960 -0
- package/dependency-analyzer.js +252 -0
- package/ignore-parser.js +150 -0
- package/index.js +6 -0
- package/lib.js +537 -0
- package/one-liner.sh +24 -0
- package/package.json +71 -0
- package/queries.js +102 -0
- package/run.sh +81 -0
package/queries.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export const QUERIES = {
|
|
2
|
+
javascript: {
|
|
3
|
+
functions: `
|
|
4
|
+
(function_declaration name: (identifier) @name) @def
|
|
5
|
+
(function name: (identifier) @name) @def
|
|
6
|
+
(method_definition name: (property_identifier) @name) @def
|
|
7
|
+
(arrow_function) @def
|
|
8
|
+
`,
|
|
9
|
+
classes: `
|
|
10
|
+
(class_declaration name: (identifier) @name) @def
|
|
11
|
+
`,
|
|
12
|
+
imports: `
|
|
13
|
+
(import_statement) @import
|
|
14
|
+
`,
|
|
15
|
+
exports: `
|
|
16
|
+
(export_statement) @export
|
|
17
|
+
`,
|
|
18
|
+
complexity: `
|
|
19
|
+
(if_statement) @branch
|
|
20
|
+
(while_statement) @loop
|
|
21
|
+
(for_statement) @loop
|
|
22
|
+
(switch_statement) @branch
|
|
23
|
+
(catch_clause) @error
|
|
24
|
+
(conditional_expression) @branch
|
|
25
|
+
`
|
|
26
|
+
},
|
|
27
|
+
python: {
|
|
28
|
+
functions: `
|
|
29
|
+
(function_definition name: (identifier) @name) @def
|
|
30
|
+
`,
|
|
31
|
+
classes: `
|
|
32
|
+
(class_definition name: (identifier) @name) @def
|
|
33
|
+
`,
|
|
34
|
+
imports: `
|
|
35
|
+
(import_statement) @import
|
|
36
|
+
(import_from_statement) @import
|
|
37
|
+
`,
|
|
38
|
+
complexity: `
|
|
39
|
+
(if_statement) @branch
|
|
40
|
+
(while_statement) @loop
|
|
41
|
+
(for_statement) @loop
|
|
42
|
+
(try_statement) @error
|
|
43
|
+
`
|
|
44
|
+
},
|
|
45
|
+
rust: {
|
|
46
|
+
functions: `
|
|
47
|
+
(function_item name: (identifier) @name) @def
|
|
48
|
+
`,
|
|
49
|
+
classes: `
|
|
50
|
+
(struct_item name: (type_identifier) @name) @def
|
|
51
|
+
(enum_item name: (type_identifier) @name) @def
|
|
52
|
+
(impl_item type: (type_identifier) @name) @def
|
|
53
|
+
`,
|
|
54
|
+
imports: `
|
|
55
|
+
(use_declaration) @import
|
|
56
|
+
`,
|
|
57
|
+
complexity: `
|
|
58
|
+
(if_expression) @branch
|
|
59
|
+
(while_expression) @loop
|
|
60
|
+
(loop_expression) @loop
|
|
61
|
+
(for_expression) @loop
|
|
62
|
+
(match_expression) @branch
|
|
63
|
+
`
|
|
64
|
+
},
|
|
65
|
+
go: {
|
|
66
|
+
functions: `
|
|
67
|
+
(function_declaration name: (identifier) @name) @def
|
|
68
|
+
(method_declaration name: (field_identifier) @name) @def
|
|
69
|
+
`,
|
|
70
|
+
classes: `
|
|
71
|
+
(type_declaration (type_spec name: (type_identifier) @name)) @def
|
|
72
|
+
`,
|
|
73
|
+
imports: `
|
|
74
|
+
(import_declaration) @import
|
|
75
|
+
`,
|
|
76
|
+
complexity: `
|
|
77
|
+
(if_statement) @branch
|
|
78
|
+
(for_statement) @loop
|
|
79
|
+
(switch_statement) @branch
|
|
80
|
+
(select_statement) @branch
|
|
81
|
+
`
|
|
82
|
+
},
|
|
83
|
+
java: {
|
|
84
|
+
functions: `
|
|
85
|
+
(method_declaration name: (identifier) @name) @def
|
|
86
|
+
`,
|
|
87
|
+
classes: `
|
|
88
|
+
(class_declaration name: (identifier) @name) @def
|
|
89
|
+
(interface_declaration name: (identifier) @name) @def
|
|
90
|
+
`,
|
|
91
|
+
imports: `
|
|
92
|
+
(import_declaration) @import
|
|
93
|
+
`,
|
|
94
|
+
complexity: `
|
|
95
|
+
(if_statement) @branch
|
|
96
|
+
(while_statement) @loop
|
|
97
|
+
(for_statement) @loop
|
|
98
|
+
(switch_expression) @branch
|
|
99
|
+
(catch_clause) @error
|
|
100
|
+
`
|
|
101
|
+
}
|
|
102
|
+
};
|
package/run.sh
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# One-liner GitHub execution script for Thorns
|
|
3
|
+
# Usage: bash <(curl -fsSL https://raw.githubusercontent.com/AnEntrypoint/mcp-thorns/main/run.sh) [target-path]
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
# Color codes
|
|
8
|
+
RED='\033[0;31m'
|
|
9
|
+
GREEN='\033[0;32m'
|
|
10
|
+
YELLOW='\033[1;33m'
|
|
11
|
+
NC='\033[0m' # No Color
|
|
12
|
+
|
|
13
|
+
# Configuration
|
|
14
|
+
GITHUB_REPO="AnEntrypoint/mcp-thorns"
|
|
15
|
+
GITHUB_BRANCH="main"
|
|
16
|
+
GITHUB_RAW="https://raw.githubusercontent.com/${GITHUB_REPO}/${GITHUB_BRANCH}"
|
|
17
|
+
TARGET_PATH="${1:-.}"
|
|
18
|
+
TEMP_DIR=""
|
|
19
|
+
|
|
20
|
+
# Cleanup on exit
|
|
21
|
+
cleanup() {
|
|
22
|
+
if [ -n "$TEMP_DIR" ] && [ -d "$TEMP_DIR" ]; then
|
|
23
|
+
rm -rf "$TEMP_DIR"
|
|
24
|
+
fi
|
|
25
|
+
}
|
|
26
|
+
trap cleanup EXIT
|
|
27
|
+
|
|
28
|
+
# Detect available runtime
|
|
29
|
+
detect_runtime() {
|
|
30
|
+
if command -v bun &> /dev/null; then
|
|
31
|
+
echo "bun"
|
|
32
|
+
return 0
|
|
33
|
+
elif command -v node &> /dev/null; then
|
|
34
|
+
echo "node"
|
|
35
|
+
return 0
|
|
36
|
+
else
|
|
37
|
+
echo ""
|
|
38
|
+
return 1
|
|
39
|
+
fi
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# Create temp directory
|
|
43
|
+
TEMP_DIR=$(mktemp -d)
|
|
44
|
+
cd "$TEMP_DIR"
|
|
45
|
+
|
|
46
|
+
echo -e "${YELLOW}📦 Downloading Thorns from GitHub...${NC}"
|
|
47
|
+
|
|
48
|
+
# Download all necessary files
|
|
49
|
+
files=("index.js" "lib.js" "analyzer.js" "compact-formatter.js" "dependency-analyzer.js" "advanced-metrics.js" "ignore-parser.js" "queries.js" ".thornsignore" "package.json")
|
|
50
|
+
|
|
51
|
+
for file in "${files[@]}"; do
|
|
52
|
+
echo -n " Fetching $file... "
|
|
53
|
+
if curl -fsSL -o "$file" "${GITHUB_RAW}/${file}"; then
|
|
54
|
+
echo -e "${GREEN}✓${NC}"
|
|
55
|
+
else
|
|
56
|
+
echo -e "${RED}✗ Failed to download $file${NC}"
|
|
57
|
+
exit 1
|
|
58
|
+
fi
|
|
59
|
+
done
|
|
60
|
+
|
|
61
|
+
echo -e "${YELLOW}🔍 Analyzing codebase at: $TARGET_PATH${NC}"
|
|
62
|
+
|
|
63
|
+
# Detect runtime
|
|
64
|
+
RUNTIME=$(detect_runtime)
|
|
65
|
+
|
|
66
|
+
if [ -z "$RUNTIME" ]; then
|
|
67
|
+
echo -e "${RED}Error: Neither 'bun' nor 'node' found in PATH${NC}"
|
|
68
|
+
echo "Please install one of:"
|
|
69
|
+
echo " - Bun: curl -fsSL https://bun.sh/install | bash"
|
|
70
|
+
echo " - Node: https://nodejs.org/"
|
|
71
|
+
exit 1
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
echo -e "${YELLOW}Using runtime: $RUNTIME${NC}"
|
|
75
|
+
|
|
76
|
+
# Execute thorns
|
|
77
|
+
if [ "$RUNTIME" = "bun" ]; then
|
|
78
|
+
bun index.js "$TARGET_PATH"
|
|
79
|
+
else
|
|
80
|
+
node index.js "$TARGET_PATH"
|
|
81
|
+
fi
|