mozaic-mcp-server 1.1.0 → 2.0.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.
@@ -4,7 +4,7 @@
4
4
 
5
5
  COMPONENT_NAME="$1"
6
6
  PROPS_JSON="${2:-{}}"
7
- DB_PATH="${HOME}/.claude/mozaic.db"
7
+ DB_PATH="${MOZAIC_DB_PATH:-${HOME}/.claude/mozaic.db}"
8
8
 
9
9
  if [ -z "$COMPONENT_NAME" ]; then
10
10
  echo "Error: Component name required"
@@ -18,28 +18,39 @@ if [ ! -f "$DB_PATH" ]; then
18
18
  exit 1
19
19
  fi
20
20
 
21
- # Get component template
22
- TEMPLATE=$(sqlite3 "$DB_PATH" <<EOF
21
+ # Verify component exists
22
+ COMPONENT_EXISTS=$(sqlite3 "$DB_PATH" "SELECT COUNT(*) FROM components WHERE name = '$COMPONENT_NAME' AND frameworks LIKE '%react%'")
23
+
24
+ if [ "$COMPONENT_EXISTS" = "0" ]; then
25
+ echo "Error: Component '$COMPONENT_NAME' not found"
26
+ exit 1
27
+ fi
28
+
29
+ # Build props string from examples (use first example as base)
30
+ FIRST_EXAMPLE=$(sqlite3 "$DB_PATH" <<EOF
23
31
  .mode list
24
- SELECT template FROM components
25
- WHERE name = '$COMPONENT_NAME'
26
- AND frameworks LIKE '%react%'
27
- LIMIT 1;
32
+ SELECT code FROM component_examples
33
+ WHERE component_id = (
34
+ SELECT id FROM components
35
+ WHERE name = '$COMPONENT_NAME'
36
+ AND frameworks LIKE '%react%'
37
+ )
38
+ ORDER BY id LIMIT 1;
28
39
  EOF
29
40
  )
30
41
 
31
- if [ -z "$TEMPLATE" ]; then
32
- echo "Error: Component '$COMPONENT_NAME' not found or has no template"
33
- exit 1
42
+ # Generate component code
43
+ if [ -n "$FIRST_EXAMPLE" ]; then
44
+ CODE="<${COMPONENT_NAME}\n ${FIRST_EXAMPLE}\n/>"
45
+ else
46
+ CODE="<${COMPONENT_NAME} />"
34
47
  fi
35
48
 
36
- # For now, return the basic template
37
- # In a full implementation, this would merge props-json with the template
38
49
  cat <<EOF
39
50
  {
40
51
  "component": "$COMPONENT_NAME",
41
52
  "framework": "react",
42
- "code": $(echo "$TEMPLATE" | jq -Rs .),
53
+ "code": $(printf '%s' "$CODE" | jq -Rs .),
43
54
  "import": "import { ${COMPONENT_NAME} } from '@mozaic-ds/react'",
44
55
  "cssImport": "import '@mozaic-ds/react/dist/styles.css'"
45
56
  }
@@ -3,7 +3,7 @@
3
3
  # Usage: ./get-component.sh <component-name>
4
4
 
5
5
  COMPONENT_NAME="$1"
6
- DB_PATH="${HOME}/.claude/mozaic.db"
6
+ DB_PATH="${MOZAIC_DB_PATH:-${HOME}/.claude/mozaic.db}"
7
7
 
8
8
  if [ -z "$COMPONENT_NAME" ]; then
9
9
  echo "Error: Component name required"
@@ -17,7 +17,6 @@ if [ ! -f "$DB_PATH" ]; then
17
17
  exit 1
18
18
  fi
19
19
 
20
- # Get component basic info
21
20
  COMPONENT_INFO=$(sqlite3 "$DB_PATH" <<EOF
22
21
  .mode json
23
22
  SELECT * FROM components
@@ -27,65 +26,47 @@ LIMIT 1;
27
26
  EOF
28
27
  )
29
28
 
30
- if [ "$COMPONENT_INFO" = "[]" ]; then
29
+ if [ -z "$COMPONENT_INFO" ] || [ "$COMPONENT_INFO" = "[]" ]; then
31
30
  echo "Error: Component '$COMPONENT_NAME' not found"
32
31
  exit 1
33
32
  fi
34
33
 
35
- # Get component props
36
34
  PROPS=$(sqlite3 "$DB_PATH" <<EOF
37
35
  .mode json
38
- SELECT
39
- name,
40
- type,
41
- default_value,
42
- required,
43
- description
36
+ SELECT name, type, default_value, required, description
44
37
  FROM component_props
45
38
  WHERE component_id = (
46
- SELECT id FROM components
47
- WHERE name = '$COMPONENT_NAME'
48
- AND frameworks LIKE '%react%'
39
+ SELECT id FROM components WHERE name = '$COMPONENT_NAME' AND frameworks LIKE '%react%'
49
40
  )
50
41
  ORDER BY required DESC, name;
51
42
  EOF
52
43
  )
44
+ PROPS="${PROPS:-[]}"
53
45
 
54
- # Get component events
55
46
  EVENTS=$(sqlite3 "$DB_PATH" <<EOF
56
47
  .mode json
57
- SELECT
58
- name,
59
- payload,
60
- description
48
+ SELECT name, payload, description
61
49
  FROM component_events
62
50
  WHERE component_id = (
63
- SELECT id FROM components
64
- WHERE name = '$COMPONENT_NAME'
65
- AND frameworks LIKE '%react%'
51
+ SELECT id FROM components WHERE name = '$COMPONENT_NAME' AND frameworks LIKE '%react%'
66
52
  )
67
53
  ORDER BY name;
68
54
  EOF
69
55
  )
56
+ EVENTS="${EVENTS:-[]}"
70
57
 
71
- # Get component examples
72
58
  EXAMPLES=$(sqlite3 "$DB_PATH" <<EOF
73
59
  .mode json
74
- SELECT
75
- title,
76
- code,
77
- description
60
+ SELECT title, code, description
78
61
  FROM component_examples
79
62
  WHERE component_id = (
80
- SELECT id FROM components
81
- WHERE name = '$COMPONENT_NAME'
82
- AND frameworks LIKE '%react%'
63
+ SELECT id FROM components WHERE name = '$COMPONENT_NAME' AND frameworks LIKE '%react%'
83
64
  )
84
65
  ORDER BY id;
85
66
  EOF
86
67
  )
68
+ EXAMPLES="${EXAMPLES:-[]}"
87
69
 
88
- # Combine all information into a single JSON output
89
70
  cat <<EOF
90
71
  {
91
72
  "component": $COMPONENT_INFO,
@@ -4,7 +4,7 @@
4
4
 
5
5
  COMPONENT_NAME="$1"
6
6
  PACKAGE_MANAGER="${2:-pnpm}"
7
- DB_PATH="${HOME}/.claude/mozaic.db"
7
+ DB_PATH="${MOZAIC_DB_PATH:-${HOME}/.claude/mozaic.db}"
8
8
 
9
9
  if [ -z "$COMPONENT_NAME" ]; then
10
10
  echo "Error: Component name required"
@@ -4,7 +4,7 @@
4
4
  # Categories: form, navigation, feedback, layout, data-display, action, all (default)
5
5
 
6
6
  CATEGORY="${1:-all}"
7
- DB_PATH="${HOME}/.claude/mozaic.db"
7
+ DB_PATH="${MOZAIC_DB_PATH:-${HOME}/.claude/mozaic.db}"
8
8
 
9
9
  # Check if database exists
10
10
  if [ ! -f "$DB_PATH" ]; then
@@ -4,7 +4,7 @@
4
4
 
5
5
  COMPONENT_NAME="$1"
6
6
  PROPS_JSON="${2:-{}}"
7
- DB_PATH="${HOME}/.claude/mozaic.db"
7
+ DB_PATH="${MOZAIC_DB_PATH:-${HOME}/.claude/mozaic.db}"
8
8
 
9
9
  if [ -z "$COMPONENT_NAME" ]; then
10
10
  echo "Error: Component name required"
@@ -18,29 +18,40 @@ if [ ! -f "$DB_PATH" ]; then
18
18
  exit 1
19
19
  fi
20
20
 
21
- # Get component template
22
- TEMPLATE=$(sqlite3 "$DB_PATH" <<EOF
21
+ # Verify component exists
22
+ COMPONENT_EXISTS=$(sqlite3 "$DB_PATH" "SELECT COUNT(*) FROM components WHERE name = '$COMPONENT_NAME' AND frameworks LIKE '%vue%'")
23
+
24
+ if [ "$COMPONENT_EXISTS" = "0" ]; then
25
+ echo "Error: Component '$COMPONENT_NAME' not found"
26
+ exit 1
27
+ fi
28
+
29
+ # Build props string from examples (use first example as base)
30
+ FIRST_EXAMPLE=$(sqlite3 "$DB_PATH" <<EOF
23
31
  .mode list
24
- SELECT template FROM components
25
- WHERE name = '$COMPONENT_NAME'
26
- AND frameworks LIKE '%vue%'
27
- LIMIT 1;
32
+ SELECT code FROM component_examples
33
+ WHERE component_id = (
34
+ SELECT id FROM components
35
+ WHERE name = '$COMPONENT_NAME'
36
+ AND frameworks LIKE '%vue%'
37
+ )
38
+ ORDER BY id LIMIT 1;
28
39
  EOF
29
40
  )
30
41
 
31
- if [ -z "$TEMPLATE" ]; then
32
- echo "Error: Component '$COMPONENT_NAME' not found or has no template"
33
- exit 1
42
+ # Generate component code
43
+ if [ -n "$FIRST_EXAMPLE" ]; then
44
+ CODE="<${COMPONENT_NAME}\n ${FIRST_EXAMPLE}\n/>"
45
+ else
46
+ CODE="<${COMPONENT_NAME} />"
34
47
  fi
35
48
 
36
- # For now, return the basic template
37
- # In a full implementation, this would merge props-json with the template
38
49
  cat <<EOF
39
50
  {
40
51
  "component": "$COMPONENT_NAME",
41
52
  "framework": "vue",
42
- "code": $(echo "$TEMPLATE" | jq -Rs .),
43
- "import": "import { M${COMPONENT_NAME} } from '@mozaic-ds/vue-3'",
53
+ "code": $(printf '%s' "$CODE" | jq -Rs .),
54
+ "import": "import { ${COMPONENT_NAME} } from '@mozaic-ds/vue-3'",
44
55
  "cssImport": "import '@mozaic-ds/vue-3/dist/style.css'"
45
56
  }
46
57
  EOF
@@ -3,7 +3,7 @@
3
3
  # Usage: ./get-component.sh <component-name>
4
4
 
5
5
  COMPONENT_NAME="$1"
6
- DB_PATH="${HOME}/.claude/mozaic.db"
6
+ DB_PATH="${MOZAIC_DB_PATH:-${HOME}/.claude/mozaic.db}"
7
7
 
8
8
  if [ -z "$COMPONENT_NAME" ]; then
9
9
  echo "Error: Component name required"
@@ -17,7 +17,6 @@ if [ ! -f "$DB_PATH" ]; then
17
17
  exit 1
18
18
  fi
19
19
 
20
- # Get component basic info
21
20
  COMPONENT_INFO=$(sqlite3 "$DB_PATH" <<EOF
22
21
  .mode json
23
22
  SELECT * FROM components
@@ -27,81 +26,59 @@ LIMIT 1;
27
26
  EOF
28
27
  )
29
28
 
30
- if [ "$COMPONENT_INFO" = "[]" ]; then
29
+ if [ -z "$COMPONENT_INFO" ] || [ "$COMPONENT_INFO" = "[]" ]; then
31
30
  echo "Error: Component '$COMPONENT_NAME' not found"
32
31
  exit 1
33
32
  fi
34
33
 
35
- # Get component props
36
34
  PROPS=$(sqlite3 "$DB_PATH" <<EOF
37
35
  .mode json
38
- SELECT
39
- name,
40
- type,
41
- default_value,
42
- required,
43
- description
36
+ SELECT name, type, default_value, required, description
44
37
  FROM component_props
45
38
  WHERE component_id = (
46
- SELECT id FROM components
47
- WHERE name = '$COMPONENT_NAME'
48
- AND frameworks LIKE '%vue%'
39
+ SELECT id FROM components WHERE name = '$COMPONENT_NAME' AND frameworks LIKE '%vue%'
49
40
  )
50
41
  ORDER BY required DESC, name;
51
42
  EOF
52
43
  )
44
+ PROPS="${PROPS:-[]}"
53
45
 
54
- # Get component slots
55
46
  SLOTS=$(sqlite3 "$DB_PATH" <<EOF
56
47
  .mode json
57
- SELECT
58
- name,
59
- description
48
+ SELECT name, description
60
49
  FROM component_slots
61
50
  WHERE component_id = (
62
- SELECT id FROM components
63
- WHERE name = '$COMPONENT_NAME'
64
- AND frameworks LIKE '%vue%'
51
+ SELECT id FROM components WHERE name = '$COMPONENT_NAME' AND frameworks LIKE '%vue%'
65
52
  )
66
53
  ORDER BY name;
67
54
  EOF
68
55
  )
56
+ SLOTS="${SLOTS:-[]}"
69
57
 
70
- # Get component events
71
58
  EVENTS=$(sqlite3 "$DB_PATH" <<EOF
72
59
  .mode json
73
- SELECT
74
- name,
75
- payload,
76
- description
60
+ SELECT name, payload, description
77
61
  FROM component_events
78
62
  WHERE component_id = (
79
- SELECT id FROM components
80
- WHERE name = '$COMPONENT_NAME'
81
- AND frameworks LIKE '%vue%'
63
+ SELECT id FROM components WHERE name = '$COMPONENT_NAME' AND frameworks LIKE '%vue%'
82
64
  )
83
65
  ORDER BY name;
84
66
  EOF
85
67
  )
68
+ EVENTS="${EVENTS:-[]}"
86
69
 
87
- # Get component examples
88
70
  EXAMPLES=$(sqlite3 "$DB_PATH" <<EOF
89
71
  .mode json
90
- SELECT
91
- title,
92
- code,
93
- description
72
+ SELECT title, code, description
94
73
  FROM component_examples
95
74
  WHERE component_id = (
96
- SELECT id FROM components
97
- WHERE name = '$COMPONENT_NAME'
98
- AND frameworks LIKE '%vue%'
75
+ SELECT id FROM components WHERE name = '$COMPONENT_NAME' AND frameworks LIKE '%vue%'
99
76
  )
100
77
  ORDER BY id;
101
78
  EOF
102
79
  )
80
+ EXAMPLES="${EXAMPLES:-[]}"
103
81
 
104
- # Combine all information into a single JSON output
105
82
  cat <<EOF
106
83
  {
107
84
  "component": $COMPONENT_INFO,
@@ -4,7 +4,7 @@
4
4
 
5
5
  COMPONENT_NAME="$1"
6
6
  PACKAGE_MANAGER="${2:-pnpm}"
7
- DB_PATH="${HOME}/.claude/mozaic.db"
7
+ DB_PATH="${MOZAIC_DB_PATH:-${HOME}/.claude/mozaic.db}"
8
8
 
9
9
  if [ -z "$COMPONENT_NAME" ]; then
10
10
  echo "Error: Component name required"
@@ -4,7 +4,7 @@
4
4
  # Categories: form, navigation, feedback, layout, data-display, action, all (default)
5
5
 
6
6
  CATEGORY="${1:-all}"
7
- DB_PATH="${HOME}/.claude/mozaic.db"
7
+ DB_PATH="${MOZAIC_DB_PATH:-${HOME}/.claude/mozaic.db}"
8
8
 
9
9
  # Check if database exists
10
10
  if [ ! -f "$DB_PATH" ]; then
Binary file
File without changes