@nbakka/mcp-appium 4.0.3 → 4.0.5
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/lib/android.js +26 -8
- package/lib/server.js +35 -2
- package/package.json +1 -1
package/lib/android.js
CHANGED
|
@@ -175,15 +175,33 @@ class AndroidRobot {
|
|
|
175
175
|
collectSimplifiedElements(node) {
|
|
176
176
|
const elements = [];
|
|
177
177
|
|
|
178
|
-
// Recursively traverse
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
178
|
+
// Recursively traverse all child nodes
|
|
179
|
+
// Check all properties to find child elements (they can have any tag name)
|
|
180
|
+
for (const key of Object.keys(node)) {
|
|
181
|
+
// Skip attribute properties (they don't contain child elements)
|
|
182
|
+
if (key === 'text' || key === 'content-desc' || key === 'resource-id' ||
|
|
183
|
+
key === 'class' || key === 'bounds' || key === 'package' ||
|
|
184
|
+
key === 'checkable' || key === 'checked' || key === 'clickable' ||
|
|
185
|
+
key === 'enabled' || key === 'focusable' || key === 'focused' ||
|
|
186
|
+
key === 'long-clickable' || key === 'password' || key === 'scrollable' ||
|
|
187
|
+
key === 'selected' || key === 'index' || key === 'displayed' ||
|
|
188
|
+
key.startsWith('a11y-') || key === 'drawing-order' || key === 'showing-hint' ||
|
|
189
|
+
key === 'text-entry-key' || key === 'dismissable' || key === 'heading' ||
|
|
190
|
+
key === 'live-region' || key === 'context-clickable' || key === 'content-invalid' ||
|
|
191
|
+
key === 'window-id' || key === 'rotation' || key === 'width' || key === 'height' ||
|
|
192
|
+
key === 'screen-reader-focusable' || key === 'hint' || key === 'pane-title') {
|
|
193
|
+
continue;
|
|
184
194
|
}
|
|
185
|
-
|
|
186
|
-
|
|
195
|
+
|
|
196
|
+
const value = node[key];
|
|
197
|
+
if (value && typeof value === 'object') {
|
|
198
|
+
if (Array.isArray(value)) {
|
|
199
|
+
for (const childNode of value) {
|
|
200
|
+
elements.push(...this.collectSimplifiedElements(childNode));
|
|
201
|
+
}
|
|
202
|
+
} else {
|
|
203
|
+
elements.push(...this.collectSimplifiedElements(value));
|
|
204
|
+
}
|
|
187
205
|
}
|
|
188
206
|
}
|
|
189
207
|
|
package/lib/server.js
CHANGED
|
@@ -173,10 +173,43 @@ tool(
|
|
|
173
173
|
|
|
174
174
|
tool(
|
|
175
175
|
"guidelines_to_write_code",
|
|
176
|
-
"Read
|
|
176
|
+
"Read coding guidelienes from ~/guardian/.cursor/rules/mcp-production-grade.json and return them so they can be followed when writing code. These guidelines include coding standards, best practices, patterns to follow, and anti-patterns to avoid. They are mandatory to follow when writing code. NOTE: Only write code after app exploration is complete and locators are fetched.",
|
|
177
177
|
{},
|
|
178
178
|
async () => {
|
|
179
|
-
|
|
179
|
+
try {
|
|
180
|
+
// Construct path: ~/guardian/.cursor/rules/mcp-production-grade.json
|
|
181
|
+
const guidelinesPath = path.join(os.homedir(), 'guardian', '.cursor', 'rules', 'mcp-production-grade.json');
|
|
182
|
+
|
|
183
|
+
// Read the JSON file
|
|
184
|
+
const guidelinesContent = await fs.readFile(guidelinesPath, "utf-8");
|
|
185
|
+
|
|
186
|
+
// Parse and validate JSON
|
|
187
|
+
const guidelines = JSON.parse(guidelinesContent);
|
|
188
|
+
|
|
189
|
+
// Return the guidelines content for the LLM to read and follow
|
|
190
|
+
return `📋 PRODUCTION-GRADE CODING GUIDELINES
|
|
191
|
+
|
|
192
|
+
IMPORTANT: You MUST follow these guidelines when writing ANY code:
|
|
193
|
+
|
|
194
|
+
${JSON.stringify(guidelines, null, 2)}
|
|
195
|
+
|
|
196
|
+
Instructions:
|
|
197
|
+
1. Read and understand ALL guidelines above thoroughly
|
|
198
|
+
2. Apply these guidelines to EVERY piece of code you write
|
|
199
|
+
3. Follow the specified patterns, naming conventions, and best practices
|
|
200
|
+
4. Prioritize code quality, maintainability, and consistency with these guidelines
|
|
201
|
+
|
|
202
|
+
These are mandatory requirements - not suggestions.`;
|
|
203
|
+
|
|
204
|
+
} catch (error) {
|
|
205
|
+
if (error.code === 'ENOENT') {
|
|
206
|
+
return `❌ Error: Guidelines file not found at ~/guardian/.cursor/rules/mcp-production-grade.json\n\nPlease ensure the file exists at this location in your home directory.`;
|
|
207
|
+
}
|
|
208
|
+
if (error instanceof SyntaxError) {
|
|
209
|
+
return `❌ Error: Invalid JSON in guidelines file. Please check the file format.`;
|
|
210
|
+
}
|
|
211
|
+
return `❌ Error reading coding guidelines: ${error.message}`;
|
|
212
|
+
}
|
|
180
213
|
}
|
|
181
214
|
);
|
|
182
215
|
|