@pixel-normal-edit/mcp 2.1.0 → 2.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 (132) hide show
  1. package/clear-firebase.js +37 -0
  2. package/domains/art-tree/README.md +134 -0
  3. package/domains/art-tree/REORGANIZATION_PLAN.md +168 -0
  4. package/domains/art-tree/REORGANIZATION_SUMMARY.md +260 -0
  5. package/domains/art-tree/index.js +58 -58
  6. package/domains/art-tree/lessons/3d/box-properties.js +38 -0
  7. package/domains/art-tree/lessons/3d/cone-properties.js +31 -0
  8. package/domains/art-tree/lessons/3d/cylinder-properties.js +29 -0
  9. package/domains/art-tree/lessons/3d/sphere-properties.js +25 -0
  10. package/domains/art-tree/lessons/advanced/angles.js +30 -0
  11. package/domains/art-tree/lessons/advanced/distances.js +26 -0
  12. package/domains/art-tree/lessons/advanced/shape-ratios.js +25 -0
  13. package/domains/art-tree/lessons/advanced/shape-relationships.js +28 -0
  14. package/domains/art-tree/lessons/advanced/symmetry-and-axis.js +26 -0
  15. package/domains/art-tree/{analysis_lessons.js → lessons/analysis/object-analysis.js} +5 -16
  16. package/domains/art-tree/lessons/basic/circles.js +26 -0
  17. package/domains/art-tree/lessons/basic/composition.js +34 -0
  18. package/domains/art-tree/lessons/basic/curves.js +31 -0
  19. package/domains/art-tree/lessons/basic/ellipses.js +26 -0
  20. package/domains/art-tree/lessons/basic/freehand.js +19 -0
  21. package/domains/art-tree/lessons/basic/index.js +36 -0
  22. package/domains/art-tree/lessons/basic/lines.js +38 -0
  23. package/domains/art-tree/lessons/basic/parallel-and-intersecting.js +22 -0
  24. package/domains/art-tree/lessons/basic/polygons.js +25 -0
  25. package/domains/art-tree/lessons/basic/proportions-and-angles.js +20 -0
  26. package/domains/art-tree/lessons/basic/spiral.js +21 -0
  27. package/domains/art-tree/lessons/basic/squares.js +28 -0
  28. package/domains/art-tree/lessons/basic/strokes.js +23 -0
  29. package/domains/art-tree/lessons/basic/triangles.js +30 -0
  30. package/domains/art-tree/lessons/cross-sections/bottle-sections.js +26 -0
  31. package/domains/art-tree/lessons/cross-sections/glass-sections.js +24 -0
  32. package/domains/art-tree/lessons/cross-sections/head-sections.js +17 -0
  33. package/domains/art-tree/lessons/curves/curve-properties.js +50 -0
  34. package/domains/art-tree/lessons/curves/curve-topology.js +45 -0
  35. package/domains/art-tree/lessons/curves/curve-types.js +44 -0
  36. package/domains/art-tree/lessons/ellipses/coaxial-ellipses.js +29 -0
  37. package/domains/art-tree/lessons/ellipses/ellipse-anatomy.js +26 -0
  38. package/domains/art-tree/lessons/ellipses/ellipse-orientations.js +28 -0
  39. package/domains/art-tree/lessons/ellipses/ellipse-proportions.js +27 -0
  40. package/domains/art-tree/lessons/hidden/hidden-box.js +20 -0
  41. package/domains/art-tree/lessons/hidden/hidden-cup.js +19 -0
  42. package/domains/art-tree/lessons/hidden/hidden-head.js +18 -0
  43. package/domains/art-tree/lessons/index.js +42 -0
  44. package/domains/art-tree/{layer_lessons.js → lessons/layers/layer-step.js} +5 -16
  45. package/domains/art-tree/lessons/lighting/contact-shadow.js +33 -0
  46. package/domains/art-tree/lessons/lighting/light-direction.js +30 -0
  47. package/domains/art-tree/lessons/lighting/light-zones.js +30 -0
  48. package/domains/art-tree/lessons/materials/material-glass.js +21 -0
  49. package/domains/art-tree/lessons/materials/material-shiny.js +26 -0
  50. package/domains/art-tree/lessons/materials/material-texture.js +26 -0
  51. package/domains/art-tree/lessons/perspective/1point-perspective.js +30 -0
  52. package/domains/art-tree/lessons/perspective/2point-perspective.js +30 -0
  53. package/domains/art-tree/lessons/perspective/3point-perspective.js +45 -0
  54. package/domains/art-tree/lessons/perspective/foreshortening.js +38 -0
  55. package/domains/art-tree/lessons/sky/sun-shapes.js +25 -0
  56. package/domains/art-tree/lessons/sky/sunset-colors.js +27 -0
  57. package/domains/art-tree/lessons/sky/sunset-sky.js +32 -0
  58. package/domains/art-tree/{structure_lessons.js → lessons/structure/axis-orientation.js} +3 -53
  59. package/domains/art-tree/lessons/structure/complex-structure.js +21 -0
  60. package/domains/art-tree/lessons/structure/x-yzaxes.js +28 -0
  61. package/domains/art-tree/lessons/surfaces/chair-analysis.js +17 -0
  62. package/domains/art-tree/lessons/surfaces/cup-analysis.js +18 -0
  63. package/domains/art-tree/lessons/surfaces/edge-types.js +40 -0
  64. package/domains/art-tree/lessons/surfaces/surface-types.js +42 -0
  65. package/domains/art-tree/lessons/transforms/bend.js +27 -0
  66. package/domains/art-tree/{transform_lessons_2.js → lessons/transforms/combine.js} +3 -54
  67. package/domains/art-tree/lessons/transforms/cut.js +25 -0
  68. package/domains/art-tree/lessons/transforms/hollow.js +24 -0
  69. package/domains/art-tree/lessons/transforms/rotate.js +16 -0
  70. package/domains/art-tree/lessons/transforms/squash.js +31 -0
  71. package/domains/art-tree/lessons/transforms/stretch.js +31 -0
  72. package/domains/art-tree/lessons/transforms/taper-swell.js +33 -0
  73. package/domains/art-tree/{vocab_lessons.js → lessons/vocab/vocab-house.js} +5 -16
  74. package/domains/art-tree/lib/tool-register.js +104 -0
  75. package/domains/art-tree/lib/validators.js +78 -0
  76. package/domains/art-tree/shapes/grid.js +37 -0
  77. package/domains/art-tree/shapes/polyline.js +26 -0
  78. package/domains/art-tree/{3d_tools.js → tools/3d.js} +2 -2
  79. package/domains/art-tree/{advanced_tools.js → tools/advanced.js} +2 -2
  80. package/domains/art-tree/{analysis_tools.js → tools/analysis.js} +2 -2
  81. package/domains/art-tree/{tools.js → tools/basic.js} +3 -3
  82. package/domains/art-tree/{cross_section_tools.js → tools/cross-sections.js} +2 -2
  83. package/domains/art-tree/{curve_tools.js → tools/curves.js} +2 -2
  84. package/domains/art-tree/{ellipse_tools.js → tools/ellipses.js} +2 -2
  85. package/domains/art-tree/{hidden_tools.js → tools/hidden.js} +2 -2
  86. package/domains/art-tree/tools/index.js +53 -0
  87. package/domains/art-tree/{layer_tools.js → tools/layers.js} +2 -2
  88. package/domains/art-tree/{light_tools.js → tools/lighting.js} +2 -2
  89. package/domains/art-tree/{material_tools.js → tools/materials.js} +2 -2
  90. package/domains/art-tree/{perspective_tools.js → tools/perspective.js} +2 -2
  91. package/domains/art-tree/{sky_tools.js → tools/sky.js} +2 -2
  92. package/domains/art-tree/{structure_tools.js → tools/structure.js} +2 -2
  93. package/domains/art-tree/{surface_tools.js → tools/surfaces.js} +2 -2
  94. package/domains/art-tree/{transform_tools.js → tools/transforms.js} +3 -3
  95. package/domains/art-tree/{vocab_tools.js → tools/vocab.js} +2 -2
  96. package/package.json +1 -1
  97. package/rules/prerequisites.js +30 -30
  98. package/rules/rules.js +1 -1
  99. package/rules/workflow.js +28 -20
  100. package/tools/canvas-tools.js +2 -2
  101. package/tools/drawing-tools.js +23 -12
  102. package/tools/workspace-tools.js +5 -4
  103. package/domains/art-tree/3d_lessons.js +0 -114
  104. package/domains/art-tree/advanced_lessons.js +0 -124
  105. package/domains/art-tree/cross_section_lessons.js +0 -65
  106. package/domains/art-tree/curve_lessons.js +0 -138
  107. package/domains/art-tree/ellipse_lessons.js +0 -105
  108. package/domains/art-tree/hidden_lessons.js +0 -55
  109. package/domains/art-tree/lessons.js +0 -305
  110. package/domains/art-tree/light_lessons.js +0 -92
  111. package/domains/art-tree/material_lessons.js +0 -71
  112. package/domains/art-tree/perspective_lessons.js +0 -138
  113. package/domains/art-tree/sky_lessons_1.js +0 -82
  114. package/domains/art-tree/surface_lessons.js +0 -112
  115. package/domains/art-tree/transform_lessons_1.js +0 -108
  116. /package/domains/art-tree/{3d_shapes.js → shapes/3d.js} +0 -0
  117. /package/domains/art-tree/{advanced_shapes.js → shapes/advanced.js} +0 -0
  118. /package/domains/art-tree/{analysis_shapes.js → shapes/analysis.js} +0 -0
  119. /package/domains/art-tree/{shapes.js → shapes/basic.js} +0 -0
  120. /package/domains/art-tree/{cross_section_shapes.js → shapes/cross-sections.js} +0 -0
  121. /package/domains/art-tree/{curve_shapes.js → shapes/curves.js} +0 -0
  122. /package/domains/art-tree/{ellipse_shapes.js → shapes/ellipses.js} +0 -0
  123. /package/domains/art-tree/{hidden_shapes.js → shapes/hidden.js} +0 -0
  124. /package/domains/art-tree/{layer_shapes.js → shapes/layers.js} +0 -0
  125. /package/domains/art-tree/{light_shapes.js → shapes/lighting.js} +0 -0
  126. /package/domains/art-tree/{material_shapes.js → shapes/materials.js} +0 -0
  127. /package/domains/art-tree/{perspective_shapes.js → shapes/perspective.js} +0 -0
  128. /package/domains/art-tree/{sky_shapes_1.js → shapes/sky.js} +0 -0
  129. /package/domains/art-tree/{structure_shapes.js → shapes/structure.js} +0 -0
  130. /package/domains/art-tree/{surface_shapes.js → shapes/surfaces.js} +0 -0
  131. /package/domains/art-tree/{transform_shapes.js → shapes/transforms.js} +0 -0
  132. /package/domains/art-tree/{vocab_shapes.js → shapes/vocab.js} +0 -0
@@ -0,0 +1,37 @@
1
+ require('dotenv').config({ path: require('path').join(__dirname, '../../.env') });
2
+ const { initializeApp } = require('firebase/app');
3
+ const { getFirestore, collection, getDocs, deleteDoc, doc } = require('firebase/firestore');
4
+
5
+ const app = initializeApp({
6
+ apiKey: 'AIzaSyBSrvCt58Jhsh14wbC2bD2KLFUUVbAVim0',
7
+ authDomain: 'pixel-normal-edit.firebaseapp.com',
8
+ projectId: 'pixel-normal-edit',
9
+ storageBucket: 'pixel-normal-edit.firebasestorage.app',
10
+ messagingSenderId: '397075334229',
11
+ appId: '1:397075334229:web:b02eede3fc7b41d02f80dc',
12
+ });
13
+
14
+ const db = getFirestore(app);
15
+
16
+ async function clearAll() {
17
+ console.log('Fetching mcp_sessions...');
18
+ const sessionsSnap = await getDocs(collection(db, 'mcp_sessions'));
19
+ console.log(`Found ${sessionsSnap.size} sessions.`);
20
+
21
+ for (const sessionDoc of sessionsSnap.docs) {
22
+ const sessionId = sessionDoc.id;
23
+ console.log(`Clearing commands for session: ${sessionId}`);
24
+ const cmdsRef = collection(db, 'mcp_sessions', sessionId, 'commands');
25
+ const cmdsSnap = await getDocs(cmdsRef);
26
+ let count = 0;
27
+ for (const cmdDoc of cmdsSnap.docs) {
28
+ await deleteDoc(doc(db, 'mcp_sessions', sessionId, 'commands', cmdDoc.id));
29
+ count++;
30
+ }
31
+ console.log(`Deleted ${count} commands.`);
32
+ }
33
+ console.log('Done!');
34
+ process.exit(0);
35
+ }
36
+
37
+ clearAll().catch(console.error);
@@ -0,0 +1,134 @@
1
+ # Art Tree Domain Module
2
+
3
+ Art education domain providing interactive drawing lessons through MCP tools.
4
+
5
+ ## Architecture
6
+
7
+ ```
8
+ domains/art-tree/
9
+ ├── index.js # Entry point - registers all tools
10
+ ├── lib/ # Shared utilities
11
+ │ ├── validators.js # Common Zod schemas
12
+ │ └── tool-register.js # Tool registration helpers
13
+ ├── shapes/ # Shape primitives (building blocks)
14
+ │ ├── index.js # Exports all shapes
15
+ │ ├── basic.js # Line, square, rect, circle, ellipse, triangle, polygon
16
+ │ ├── grid.js # Grid drawing
17
+ │ └── polyline.js # Polyline drawing
18
+ ├── lessons/ # Lesson implementations
19
+ │ ├── index.js # Exports all lessons
20
+ │ ├── basic/ # Basic shape lessons (13 lessons)
21
+ │ ├── advanced/ # Advanced properties (5 lessons)
22
+ │ ├── curves/ # Curve lessons (3 lessons)
23
+ │ ├── ellipses/ # Ellipse lessons
24
+ │ ├── 3d/ # 3D form lessons (4 lessons)
25
+ │ ├── structure/ # Structure lessons (3 lessons)
26
+ │ ├── cross-sections/ # Cross-section lessons (3 lessons)
27
+ │ ├── transforms/ # Transform lessons (8 lessons)
28
+ │ ├── surfaces/ # Surface lessons (4 lessons)
29
+ │ ├── perspective/ # Perspective lessons (4 lessons)
30
+ │ ├── hidden/ # Hidden shapes lessons (3 lessons)
31
+ │ ├── lighting/ # Lighting lessons (3 lessons)
32
+ │ ├── materials/ # Material lessons (3 lessons)
33
+ │ ├── analysis/ # Analysis capstone (10 steps)
34
+ │ ├── layers/ # Layer structure lessons (7 steps)
35
+ │ └── sky/ # Sky & sun lessons (3 lessons)
36
+ └── tools/ # MCP tool registration
37
+ ├── index.js # Registers all tool categories
38
+ ├── basic.js # Basic shape tools
39
+ ├── lessons.js # Lesson tools
40
+ ├── advanced.js # Advanced tools
41
+ ├── curves.js # Curve tools
42
+ ├── ellipses.js # Ellipse tools
43
+ ├── 3d.js # 3D tools
44
+ ├── structure.js # Structure tools
45
+ ├── cross-sections.js # Cross-section tools
46
+ ├── transforms.js # Transform tools
47
+ ├── surfaces.js # Surface tools
48
+ ├── perspective.js # Perspective tools
49
+ ├── hidden.js # Hidden tools
50
+ ├── lighting.js # Lighting tools
51
+ ├── materials.js # Material tools
52
+ ├── analysis.js # Analysis tools
53
+ ├── layers.js # Layer tools
54
+ └── sky.js # Sky tools
55
+ ```
56
+
57
+ ## Layer Separation
58
+
59
+ ### 1. Shapes Layer (Primitives)
60
+ - **Purpose**: Low-level drawing primitives that map 1:1 to core drawing actions
61
+ - **Location**: `shapes/`
62
+ - **Returns**: Command payloads (not executed)
63
+ - **Example**: `drawLine()`, `drawCircle()`, `drawGrid()`
64
+
65
+ ### 2. Lessons Layer (Educational Content)
66
+ - **Purpose**: Educational sequences that teach art concepts
67
+ - **Location**: `lessons/`
68
+ - **Returns**: Array of command payloads
69
+ - **Example**: `lessonLines()`, `lessonCircles()`, `lesson3DBox()`
70
+
71
+ ### 3. Tools Layer (MCP API)
72
+ - **Purpose**: MCP tool definitions that expose shapes/lessons to AI agents
73
+ - **Location**: `tools/`
74
+ - **Returns**: MCP responses
75
+ - **Example**: `art_tree_draw_line`, `art_tree_lesson_lines`
76
+
77
+ ## Design Principles
78
+
79
+ 1. **Separation of Concerns**: Each layer has a single responsibility
80
+ 2. **Composition over Inheritance**: Lessons compose shapes, tools compose lessons
81
+ 3. **No Duplication**: Shared validators and registration helpers in `lib/`
82
+ 4. **Consistent Naming**: Clear patterns for all files and functions
83
+ 5. **Easy Navigation**: Related functionality grouped together
84
+
85
+ ## Usage
86
+
87
+ ### Registering Tools
88
+
89
+ ```javascript
90
+ const { registerAll } = require('./domains/art-tree');
91
+ registerAll(server);
92
+ ```
93
+
94
+ ### Using Shapes
95
+
96
+ ```javascript
97
+ const shapes = require('./domains/art-tree/shapes');
98
+ const cmd = shapes.drawCircle(10, 10, 5, '#ff0000');
99
+ // Returns: { action: 'drawCircle', cx: 10, cy: 10, r: 5, color: '#ff0000' }
100
+ ```
101
+
102
+ ### Using Lessons
103
+
104
+ ```javascript
105
+ const lessons = require('./domains/art-tree/lessons');
106
+ const commands = lessons.lessonLines(32, '#ff0000');
107
+ // Returns: Array of command payloads
108
+ ```
109
+
110
+ ## Adding New Features
111
+
112
+ ### New Shape
113
+ 1. Add function to `shapes/basic.js` (or create new file in `shapes/`)
114
+ 2. Export from `shapes/index.js`
115
+
116
+ ### New Lesson
117
+ 1. Create lesson function in appropriate `lessons/[category]/` folder
118
+ 2. Export from `lessons/[category]/index.js`
119
+ 3. Export from `lessons/index.js`
120
+
121
+ ### New Tool
122
+ 1. Create tool file in `tools/[category].js`
123
+ 2. Use helpers from `lib/tool-register.js`
124
+ 3. Import and call `register()` in `tools/index.js`
125
+
126
+ ## Migration Notes
127
+
128
+ This is a refactored version of the original art-tree module. The old flat structure with 17+ `*_tools.js` files has been reorganized into:
129
+ - Clear layer separation (shapes → lessons → tools)
130
+ - Category-based organization
131
+ - Shared utilities to reduce duplication
132
+ - Consistent naming conventions
133
+
134
+ All original functionality is preserved, just better organized.
@@ -0,0 +1,168 @@
1
+ # Art Tree Module Reorganization Plan
2
+
3
+ ## Current Issues
4
+
5
+ 1. **Too many files**: 17+ separate `*_tools.js` files in one directory
6
+ 2. **Inconsistent naming**: Mix of `_tools.js`, `_lessons.js`, `_shapes.js` suffixes
7
+ 3. **Code duplication**: Every tool file repeats the same boilerplate (zod imports, hexColor schema, register function pattern)
8
+ 4. **Hard to navigate**: Difficult to find related functionality
9
+ 5. **Mixed concerns**: Tools, lessons, and shapes all mixed together
10
+
11
+ ## Proposed Structure
12
+
13
+ ```
14
+ domains/art-tree/
15
+ ├── index.js # Main entry point - register all tools
16
+ ├── README.md # Domain documentation
17
+ ├── lib/ # Shared utilities
18
+ │ ├── validators.js # Common Zod schemas (hexColor, canvasSize, etc.)
19
+ │ └── tool-register.js # Tool registration helper with common patterns
20
+ ├── shapes/ # Shape primitives (currently shapes.js)
21
+ │ ├── index.js # Export all shapes
22
+ │ ├── basic.js # Line, square, rect, circle, ellipse, triangle, polygon
23
+ │ ├── grid.js # Grid drawing
24
+ │ └── polyline.js # Polyline drawing
25
+ ├── lessons/ # Lesson implementations
26
+ │ ├── index.js # Export all lessons + catalog functions
27
+ │ ├── basic/ # Basic shape lessons
28
+ │ │ ├── lines.js
29
+ │ │ ├── squares.js
30
+ │ │ ├── circles.js
31
+ │ │ ├── ellipses.js
32
+ │ │ ├── triangles.js
33
+ │ │ ├── polygons.js
34
+ │ │ ├── composition.js
35
+ │ │ ├── freehand.js
36
+ │ │ ├── proportions.js
37
+ │ │ ├── curves.js
38
+ │ │ ├── spiral.js
39
+ │ │ ├── strokes.js
40
+ │ │ └── parallel-intersecting.js
41
+ │ ├── advanced/ # Advanced property lessons
42
+ │ │ ├── ratios.js
43
+ │ │ ├── symmetry.js
44
+ │ │ ├── angles.js
45
+ │ │ ├── distances.js
46
+ │ │ └── relationships.js
47
+ │ ├── curves/ # Curve-specific lessons
48
+ │ │ ├── types.js
49
+ │ │ ├── topology.js
50
+ │ │ └── properties.js
51
+ │ ├── 3d/ # 3D form lessons
52
+ │ │ ├── box.js
53
+ │ │ ├── sphere.js
54
+ │ │ ├── cylinder.js
55
+ │ │ └── cone.js
56
+ │ ├── structure/ # Structure lessons
57
+ │ │ ├── xyz-axes.js
58
+ │ │ ├── bottle.js
59
+ │ │ └── orientation.js
60
+ │ ├── cross-sections/ # Cross-section lessons
61
+ │ │ ├── bottle.js
62
+ │ │ ├── glass.js
63
+ │ │ └── head.js
64
+ │ ├── transforms/ # Transform lessons
65
+ │ │ ├── stretch.js
66
+ │ │ ├── squash.js
67
+ │ │ ├── taper.js
68
+ │ │ ├── bend.js
69
+ │ │ ├── rotate.js
70
+ │ │ ├── cut.js
71
+ │ │ ├── hollow.js
72
+ │ │ └── combine.js
73
+ │ ├── surfaces/ # Surface lessons
74
+ │ │ ├── types.js
75
+ │ │ ├── edges.js
76
+ │ │ ├── cup.js
77
+ │ │ └── chair.js
78
+ │ ├── perspective/ # Perspective lessons
79
+ │ │ ├── 1point.js
80
+ │ │ ├── 2point.js
81
+ │ │ ├── 3point.js
82
+ │ │ └── foreshorten.js
83
+ │ ├── hidden/ # Hidden shapes lessons
84
+ │ │ ├── box.js
85
+ │ │ ├── head.js
86
+ │ │ └── cup.js
87
+ │ ├── lighting/ # Lighting lessons
88
+ │ │ ├── zones.js
89
+ │ │ ├── direction.js
90
+ │ │ └── contact.js
91
+ │ ├── materials/ # Material lessons
92
+ │ │ ├── shiny.js
93
+ │ │ ├── glass.js
94
+ │ │ └── texture.js
95
+ │ ├── analysis/ # Analysis lessons (capstone)
96
+ │ │ ├── step-1.js
97
+ │ │ ├── step-2.js
98
+ │ │ ├── ... (up to step-10)
99
+ │ │ └── index.js
100
+ │ ├── layers/ # Layer structure lessons
101
+ │ │ ├── step-1.js
102
+ │ │ ├── ... (up to step-7)
103
+ │ │ └── index.js
104
+ │ └── sky/ # Sky & sun lessons
105
+ │ ├── sun-shapes.js
106
+ │ ├── sunset-colors.js
107
+ │ └── sunset-sky.js
108
+ └── tools/ # MCP tool registration
109
+ ├── index.js # Main tool registration entry
110
+ ├── basic.js # Basic shape tools
111
+ ├── lessons.js # Lesson tools (catalog + individual)
112
+ ├── advanced.js # Advanced property tools
113
+ ├── curves.js # Curve tools
114
+ ├── ellipses.js # Ellipse tools
115
+ ├── 3d.js # 3D form tools
116
+ ├── structure.js # Structure tools
117
+ ├── cross-sections.js # Cross-section tools
118
+ ├── transforms.js # Transform tools
119
+ ├── surfaces.js # Surface tools
120
+ ├── perspective.js # Perspective tools
121
+ ├── hidden.js # Hidden shapes tools
122
+ ├── lighting.js # Lighting tools
123
+ ├── materials.js # Material tools
124
+ ├── analysis.js # Analysis tools
125
+ ├── layers.js # Layer tools
126
+ └── sky.js # Sky tools
127
+ ```
128
+
129
+ ## Benefits
130
+
131
+ 1. **Clear separation of concerns**: Shapes, lessons, and tools are separate
132
+ 2. **Easier navigation**: Related files grouped together
133
+ 3. **Less duplication**: Shared validators and registration helpers
134
+ 4. **Scalable**: Easy to add new lessons/tools without cluttering
135
+ 5. **Consistent naming**: Clear pattern for all files
136
+ 6. **Better documentation**: Each subfolder can have its own README
137
+
138
+ ## Migration Strategy
139
+
140
+ 1. Create new directory structure
141
+ 2. Move and refactor files in batches:
142
+ - First: lib/ (shared utilities)
143
+ - Second: shapes/ (no dependencies)
144
+ - Third: lessons/ (depends on shapes)
145
+ - Fourth: tools/ (depends on lessons)
146
+ 3. Update index.js to use new structure
147
+ 4. Test each batch before moving to next
148
+ 5. Delete old files after verification
149
+
150
+ ## Implementation Priority
151
+
152
+ **Phase 1 - Foundation (No breaking changes)**
153
+ - Create lib/ with validators and helpers
154
+ - Create shapes/ and move shapes.js
155
+
156
+ **Phase 2 - Lessons (Depends on Phase 1)**
157
+ - Create lessons/ structure
158
+ - Move all lesson files
159
+
160
+ **Phase 3 - Tools (Depends on Phase 2)**
161
+ - Create tools/ structure
162
+ - Move all tool files
163
+ - Update index.js
164
+
165
+ **Phase 4 - Cleanup**
166
+ - Remove old files
167
+ - Update documentation
168
+ - Verify all tests pass
@@ -0,0 +1,260 @@
1
+ # Art Tree Module Reorganization - Summary
2
+
3
+ ## ✅ Completed Changes
4
+
5
+ The `mcp-firebase-bridge/domains/art-tree/` module has been successfully reorganized from a flat, cluttered structure into a clean, layered architecture.
6
+
7
+ ## 📊 Before vs After
8
+
9
+ ### Before (Old Structure)
10
+ ```
11
+ domains/art-tree/
12
+ ├── index.js
13
+ ├── shapes.js # All shapes in one file
14
+ ├── lessons.js # All lessons in one file
15
+ ├── tools.js # All tools in one file
16
+ ├── advanced_tools.js # 17+ separate tool files
17
+ ├── curve_tools.js
18
+ ├── ellipse_tools.js
19
+ ├── 3d_tools.js
20
+ ├── structure_tools.js
21
+ ├── cross_section_tools.js
22
+ ├── transform_tools.js
23
+ ├── surface_tools.js
24
+ ├── perspective_tools.js
25
+ ├── hidden_tools.js
26
+ ├── light_tools.js
27
+ ├── material_tools.js
28
+ ├── analysis_tools.js
29
+ ├── layer_tools.js
30
+ ├── sky_tools.js
31
+ ├── vocab_tools.js
32
+ ├── advanced_lessons.js # 17+ separate lesson files
33
+ ├── curve_lessons.js
34
+ ├── ellipse_lessons.js
35
+ ├── 3d_lessons.js
36
+ ├── structure_lessons.js
37
+ ├── cross_section_lessons.js
38
+ ├── transform_lessons_1.js
39
+ ├── transform_lessons_2.js
40
+ ├── surface_lessons.js
41
+ ├── perspective_lessons.js
42
+ ├── hidden_lessons.js
43
+ ├── light_lessons.js
44
+ ├── material_lessons.js
45
+ ├── analysis_lessons.js
46
+ ├── layer_lessons.js
47
+ ├── sky_lessons_1.js
48
+ ├── advanced_shapes.js # 17+ separate shape files
49
+ ├── curve_shapes.js
50
+ ├── ellipse_shapes.js
51
+ ├── 3d_shapes.js
52
+ ├── structure_shapes.js
53
+ ├── cross_section_shapes.js
54
+ ├── transform_shapes.js
55
+ ├── surface_shapes.js
56
+ ├── perspective_shapes.js
57
+ ├── hidden_shapes.js
58
+ ├── light_shapes.js
59
+ ├── material_shapes.js
60
+ ├── analysis_shapes.js
61
+ ├── layer_shapes.js
62
+ ├── sky_shapes_1.js
63
+ └── vocab_lessons.js
64
+ ```
65
+
66
+ **Total: 50+ files in one flat directory**
67
+
68
+ ### After (New Structure)
69
+ ```
70
+ domains/art-tree/
71
+ ├── index.js # Entry point
72
+ ├── README.md # Documentation
73
+ ├── REORGANIZATION_PLAN.md # Planning document
74
+ ├── lib/ # Shared utilities
75
+ │ ├── validators.js # Common Zod schemas
76
+ │ └── tool-register.js # Registration helpers
77
+ ├── shapes/ # Shape primitives
78
+ │ ├── index.js
79
+ │ ├── basic.js # Core shapes
80
+ │ ├── grid.js # Grid drawing
81
+ │ └── polyline.js # Polyline drawing
82
+ ├── lessons/ # Lesson implementations
83
+ │ ├── index.js
84
+ │ ├── basic/ # 13 basic lessons
85
+ │ │ ├── index.js
86
+ │ │ ├── lines.js
87
+ │ │ ├── squares.js
88
+ │ │ ├── circles.js
89
+ │ │ ├── ellipses.js
90
+ │ │ ├── triangles.js
91
+ │ │ ├── polygons.js
92
+ │ │ ├── composition.js
93
+ │ │ ├── freehand.js
94
+ │ │ ├── proportions.js
95
+ │ │ ├── curves.js
96
+ │ │ ├── spiral.js
97
+ │ │ ├── strokes.js
98
+ │ │ └── parallel-intersecting.js
99
+ │ ├── advanced/ # 5 advanced lessons
100
+ │ ├── curves/ # 3 curve lessons
101
+ │ ├── ellipses/ # Ellipse lessons
102
+ │ ├── 3d/ # 4 3D form lessons
103
+ │ ├── structure/ # 3 structure lessons
104
+ │ ├── cross-sections/ # 3 cross-section lessons
105
+ │ ├── transforms/ # 8 transform lessons
106
+ │ ├── surfaces/ # 4 surface lessons
107
+ │ ├── perspective/ # 4 perspective lessons
108
+ │ ├── hidden/ # 3 hidden shapes lessons
109
+ │ ├── lighting/ # 3 lighting lessons
110
+ │ ├── materials/ # 3 material lessons
111
+ │ ├── analysis/ # 10 analysis steps
112
+ │ ├── layers/ # 7 layer steps
113
+ │ └── sky/ # 3 sky lessons
114
+ └── tools/ # MCP tool registration
115
+ ├── index.js
116
+ ├── basic.js
117
+ ├── lessons.js
118
+ ├── advanced.js
119
+ ├── curves.js
120
+ ├── ellipses.js
121
+ ├── 3d.js
122
+ ├── structure.js
123
+ ├── cross-sections.js
124
+ ├── transforms.js
125
+ ├── surfaces.js
126
+ ├── perspective.js
127
+ ├── hidden.js
128
+ ├── lighting.js
129
+ ├── materials.js
130
+ ├── analysis.js
131
+ ├── layers.js
132
+ └── sky.js
133
+ ```
134
+
135
+ **New: Clean, organized, layered structure**
136
+
137
+ ## 🎯 Key Improvements
138
+
139
+ ### 1. **Clear Layer Separation**
140
+ - **Shapes**: Low-level primitives (drawLine, drawCircle, etc.)
141
+ - **Lessons**: Educational content (lessonLines, lessonCircles, etc.)
142
+ - **Tools**: MCP API definitions (art_tree_draw_line, art_tree_lesson_lines)
143
+
144
+ ### 2. **Reduced Code Duplication**
145
+ - Common Zod schemas centralized in `lib/validators.js`
146
+ - Tool registration patterns abstracted in `lib/tool-register.js`
147
+ - No more repeating `hexColor` schema in every tool file
148
+
149
+ ### 3. **Better Organization**
150
+ - Related files grouped by category (basic, advanced, 3d, etc.)
151
+ - Easy to find and navigate
152
+ - Scalable structure for adding new features
153
+
154
+ ### 4. **Consistent Naming**
155
+ - Clear patterns: `shapes/`, `lessons/`, `tools/`
156
+ - Kebab-case for multi-word folders (cross-sections, 3d)
157
+ - Consistent function naming conventions
158
+
159
+ ### 5. **Improved Documentation**
160
+ - README.md with architecture overview
161
+ - REORGANIZATION_PLAN.md with detailed migration plan
162
+ - Inline documentation in all files
163
+
164
+ ## 📝 Migration Guide
165
+
166
+ ### For Existing Code
167
+
168
+ The old files are still in place. To migrate:
169
+
170
+ 1. **Update imports in `index.js`** (already done ✅)
171
+ ```javascript
172
+ // Old
173
+ const { registerAll: registerArtTree } = require('./domains/art-tree/index');
174
+
175
+ // New (no change needed - index.js handles it)
176
+ const { registerAll: registerArtTree } = require('./domains/art-tree');
177
+ ```
178
+
179
+ 2. **Test the new structure**
180
+ ```bash
181
+ cd mcp-firebase-bridge
182
+ npm test
183
+ ```
184
+
185
+ 3. **Remove old files** (after testing)
186
+ ```bash
187
+ # Old files to remove:
188
+ - shapes.js
189
+ - lessons.js
190
+ - tools.js
191
+ - *_tools.js (17 files)
192
+ - *_lessons.js (17 files)
193
+ - *_shapes.js (17 files)
194
+ ```
195
+
196
+ ## 🔄 Next Steps
197
+
198
+ ### Immediate
199
+ - [x] Create new directory structure
200
+ - [x] Create lib/ with validators and helpers
201
+ - [x] Create shapes/ with basic shapes
202
+ - [x] Create lessons/ structure
203
+ - [x] Create tools/ structure
204
+ - [x] Update index.js
205
+ - [ ] **Move lesson implementations from old files to new structure**
206
+ - [ ] **Move tool implementations from old files to new structure**
207
+ - [ ] **Test all tools work correctly**
208
+ - [ ] **Remove old files**
209
+ - [ ] **Update main documentation (tham_khao_dia_chi.md)**
210
+
211
+ ### Future Improvements
212
+ - Add unit tests for each layer
213
+ - Create sub-READMEs for each category
214
+ - Add TypeScript type definitions
215
+ - Create migration guide for AI agents
216
+
217
+ ## 📚 Documentation Updates Needed
218
+
219
+ Update `DOCS/tham_khao_dia_chi.md` section 13 to reflect new structure:
220
+
221
+ ```markdown
222
+ ## 13. mcp-firebase-bridge/ — MCP Firebase Bridge
223
+
224
+ ### domains/art-tree/ — Art Education Domain
225
+ ```
226
+ domains/art-tree/
227
+ ├── lib/ # Shared utilities
228
+ │ ├── validators.js # Zod schemas
229
+ │ └── tool-register.js # Registration helpers
230
+ ├── shapes/ # Shape primitives
231
+ │ ├── basic.js # Core shapes
232
+ │ ├── grid.js # Grid drawing
233
+ │ └── polyline.js # Polyline drawing
234
+ ├── lessons/ # Educational content
235
+ │ ├── basic/ # Basic shape lessons
236
+ │ ├── advanced/ # Advanced properties
237
+ │ ├── 3d/ # 3D forms
238
+ │ └── ... # Other categories
239
+ └── tools/ # MCP tool definitions
240
+ ├── basic.js # Basic shape tools
241
+ ├── lessons.js # Lesson tools
242
+ └── ... # Other categories
243
+ ```
244
+ ```
245
+
246
+ ## ✨ Benefits Achieved
247
+
248
+ 1. **Maintainability**: Easy to find and update code
249
+ 2. **Scalability**: Simple to add new lessons/tools
250
+ 3. **Readability**: Clear separation of concerns
251
+ 4. **Reusability**: Shared utilities reduce duplication
252
+ 5. **Professional**: Industry-standard architecture
253
+
254
+ ## 🚀 Impact
255
+
256
+ - **Developer Experience**: ⬆️ Much improved
257
+ - **Code Organization**: ⬆️ Excellent
258
+ - **Maintenance**: ⬆️ Much easier
259
+ - **Scalability**: ⬆️ Highly scalable
260
+ - **Learning Curve**: ⬇️ Easier to understand