@appium/mcp-documentation 1.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +0 -0
  2. package/LICENSE +201 -0
  3. package/README.md +126 -0
  4. package/dist/answer-appium.d.ts +8 -0
  5. package/dist/answer-appium.d.ts.map +1 -0
  6. package/dist/answer-appium.js +38 -0
  7. package/dist/answer-appium.js.map +1 -0
  8. package/dist/appium-skills.d.ts +5 -0
  9. package/dist/appium-skills.d.ts.map +1 -0
  10. package/dist/appium-skills.js +168 -0
  11. package/dist/appium-skills.js.map +1 -0
  12. package/dist/index.d.ts +31 -0
  13. package/dist/index.d.ts.map +1 -0
  14. package/dist/index.js +69 -0
  15. package/dist/index.js.map +1 -0
  16. package/dist/logger.d.ts +4 -0
  17. package/dist/logger.d.ts.map +1 -0
  18. package/dist/logger.js +5 -0
  19. package/dist/logger.js.map +1 -0
  20. package/dist/markdown-header-splitter.d.ts +32 -0
  21. package/dist/markdown-header-splitter.d.ts.map +1 -0
  22. package/dist/markdown-header-splitter.js +180 -0
  23. package/dist/markdown-header-splitter.js.map +1 -0
  24. package/dist/paths.d.ts +2 -0
  25. package/dist/paths.d.ts.map +1 -0
  26. package/dist/paths.js +22 -0
  27. package/dist/paths.js.map +1 -0
  28. package/dist/plugin.d.ts +19 -0
  29. package/dist/plugin.d.ts.map +1 -0
  30. package/dist/plugin.js +18 -0
  31. package/dist/plugin.js.map +1 -0
  32. package/dist/reasoning-rag.d.ts +89 -0
  33. package/dist/reasoning-rag.d.ts.map +1 -0
  34. package/dist/reasoning-rag.js +282 -0
  35. package/dist/reasoning-rag.js.map +1 -0
  36. package/dist/scripts/eval-documentation-rag.d.ts +50 -0
  37. package/dist/scripts/eval-documentation-rag.d.ts.map +1 -0
  38. package/dist/scripts/eval-documentation-rag.js +287 -0
  39. package/dist/scripts/eval-documentation-rag.js.map +1 -0
  40. package/dist/scripts/generate-embeddings-cache.d.ts +13 -0
  41. package/dist/scripts/generate-embeddings-cache.d.ts.map +1 -0
  42. package/dist/scripts/generate-embeddings-cache.js +24 -0
  43. package/dist/scripts/generate-embeddings-cache.js.map +1 -0
  44. package/dist/scripts/rag-eval-dataset.json +516 -0
  45. package/dist/scripts/simple-index-documentation.d.ts +21 -0
  46. package/dist/scripts/simple-index-documentation.d.ts.map +1 -0
  47. package/dist/scripts/simple-index-documentation.js +77 -0
  48. package/dist/scripts/simple-index-documentation.js.map +1 -0
  49. package/dist/scripts/simple-query-documentation.d.ts +13 -0
  50. package/dist/scripts/simple-query-documentation.d.ts.map +1 -0
  51. package/dist/scripts/simple-query-documentation.js +52 -0
  52. package/dist/scripts/simple-query-documentation.js.map +1 -0
  53. package/dist/sentence-transformers-embeddings.d.ts +40 -0
  54. package/dist/sentence-transformers-embeddings.d.ts.map +1 -0
  55. package/dist/sentence-transformers-embeddings.js +119 -0
  56. package/dist/sentence-transformers-embeddings.js.map +1 -0
  57. package/dist/simple-pdf-indexer.d.ts +47 -0
  58. package/dist/simple-pdf-indexer.d.ts.map +1 -0
  59. package/dist/simple-pdf-indexer.js +572 -0
  60. package/dist/simple-pdf-indexer.js.map +1 -0
  61. package/dist/tests/__mocks__/@appium/support.d.ts +92 -0
  62. package/dist/tests/__mocks__/@appium/support.d.ts.map +1 -0
  63. package/dist/tests/__mocks__/@appium/support.js +66 -0
  64. package/dist/tests/__mocks__/@appium/support.js.map +1 -0
  65. package/dist/tests/appium-skills.test.d.ts +2 -0
  66. package/dist/tests/appium-skills.test.d.ts.map +1 -0
  67. package/dist/tests/appium-skills.test.js +26 -0
  68. package/dist/tests/appium-skills.test.js.map +1 -0
  69. package/dist/tests/plugin.test.d.ts +2 -0
  70. package/dist/tests/plugin.test.d.ts.map +1 -0
  71. package/dist/tests/plugin.test.js +18 -0
  72. package/dist/tests/plugin.test.js.map +1 -0
  73. package/dist/tests/simple-pdf-indexer.test.d.ts +2 -0
  74. package/dist/tests/simple-pdf-indexer.test.d.ts.map +1 -0
  75. package/dist/tests/simple-pdf-indexer.test.js +37 -0
  76. package/dist/tests/simple-pdf-indexer.test.js.map +1 -0
  77. package/dist/tool-response.d.ts +4 -0
  78. package/dist/tool-response.d.ts.map +1 -0
  79. package/dist/tool-response.js +12 -0
  80. package/dist/tool-response.js.map +1 -0
  81. package/dist/tools.d.ts +3 -0
  82. package/dist/tools.d.ts.map +1 -0
  83. package/dist/tools.js +3 -0
  84. package/dist/tools.js.map +1 -0
  85. package/dist/uploads/documents.json +1 -0
  86. package/package.json +84 -0
  87. package/scripts/zip-assets.mjs +75 -0
  88. package/src/resources/submodules.zip +0 -0
package/CHANGELOG.md ADDED
File without changes
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright OpenJS Foundation and other contributors, https://openjsf.org/
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,126 @@
1
+ # @appium/mcp-documentation
2
+
3
+ Appium MCP documentation query tools and indexed documentation assets.
4
+
5
+ This package provides an Appium documentation plugin for MCP servers. It exposes
6
+ tools that can answer Appium documentation questions and return ordered setup or
7
+ troubleshooting guidance from the vendored Appium skills content.
8
+
9
+ ## Tools
10
+
11
+ - `appium_documentation_query`: queries indexed Appium documentation with RAG.
12
+ - `appium_skills`: returns ordered Appium setup or troubleshooting skills for
13
+ Android and iOS local environments.
14
+
15
+ ## Use With appium-mcp
16
+
17
+ Install this package alongside `appium-mcp` in the server project that starts
18
+ your MCP server.
19
+
20
+ ```bash
21
+ npm install appium-mcp
22
+ npm install @appium/mcp-documentation
23
+ ```
24
+
25
+ When developing against a local checkout, build this package first and install
26
+ it by path from the appium-mcp server project:
27
+
28
+ ```bash
29
+ cd /path/to/appium-mcp-documentation
30
+ npm install
31
+ npm run build
32
+
33
+ cd /path/to/your-appium-mcp-server
34
+ npm install /path/to/appium-mcp-documentation
35
+ ```
36
+
37
+ Register the documentation plugin when creating the Appium MCP server:
38
+
39
+ ```ts
40
+ import { createAppiumMcpServer } from 'appium-mcp/core';
41
+ import { AppiumDocumentation } from '@appium/mcp-documentation';
42
+
43
+ const server = createAppiumMcpServer({
44
+ plugins: [new AppiumDocumentation()],
45
+ });
46
+
47
+ await server.start({
48
+ transportType: 'stdio',
49
+ });
50
+ ```
51
+
52
+ For HTTP stream transport:
53
+
54
+ ```ts
55
+ await server.start({
56
+ transportType: 'httpStream',
57
+ httpStream: {
58
+ endpoint: '/sse',
59
+ port: 8080,
60
+ },
61
+ });
62
+ ```
63
+
64
+ Once registered, the Appium MCP server exposes the normal Appium automation
65
+ tools plus `appium_documentation_query` and `appium_skills`.
66
+
67
+ Note that the default appium-mcp server enables the documentation plugin if available, so you may not need to explicitly register it.
68
+
69
+ ## Direct API
70
+
71
+ You can also use the documentation query API directly:
72
+
73
+ ```ts
74
+ import {
75
+ answerAppiumQuery,
76
+ initializeAppiumDocumentation,
77
+ } from '@appium/mcp-documentation';
78
+
79
+ await initializeAppiumDocumentation();
80
+
81
+ const result = await answerAppiumQuery({
82
+ query: 'How do I configure UiAutomator2 capabilities?',
83
+ });
84
+
85
+ console.log(result.answer);
86
+ ```
87
+
88
+ ## Development
89
+
90
+ Install dependencies:
91
+
92
+ ```bash
93
+ npm install
94
+ ```
95
+
96
+ Build the package:
97
+
98
+ ```bash
99
+ npm run build
100
+ ```
101
+
102
+ Run tests and lint:
103
+
104
+ ```bash
105
+ npm test
106
+ npm run lint
107
+ ```
108
+
109
+ Rebuild the documentation index:
110
+
111
+ ```bash
112
+ npm run build
113
+ npm run index-docs
114
+ ```
115
+
116
+ Query the built index from the command line:
117
+
118
+ ```bash
119
+ npm run query-docs -- "How do I start an Appium session?"
120
+ ```
121
+
122
+ ## Dependency Notes
123
+
124
+ The runtime dependencies are the packages used by the shipped tools and RAG
125
+ implementation. `fastmcp` is a development dependency here because this package
126
+ only imports its types.
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Tool to query indexed Appium documentation.
3
+ */
4
+ import type { FastMCP } from 'fastmcp';
5
+ type ToolDef = Parameters<FastMCP['addTool']>[0];
6
+ export declare const appiumDocumentationQueryTool: ToolDef;
7
+ export {};
8
+ //# sourceMappingURL=answer-appium.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"answer-appium.d.ts","sourceRoot":"","sources":["../src/answer-appium.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAMvC,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAEjD,eAAO,MAAM,4BAA4B,EAAE,OAmC1C,CAAC"}
@@ -0,0 +1,38 @@
1
+ import { z } from 'zod';
2
+ import { answerAppiumQuery, initializeAppiumDocumentation } from './index.js';
3
+ import log from './logger.js';
4
+ import { errorResult, textResult } from './tool-response.js';
5
+ export const appiumDocumentationQueryTool = {
6
+ name: 'appium_documentation_query',
7
+ description: `Query Appium documentation using RAG (Retrieval-Augmented Generation).
8
+ This tool searches through indexed Appium documentation to answer questions about Appium features, setup, configuration, drivers, and usage.
9
+ `,
10
+ parameters: z.object({
11
+ query: z
12
+ .string()
13
+ .describe('The question or query about Appium documentation'),
14
+ }),
15
+ execute: async (args, _context) => {
16
+ const query = args.query;
17
+ if (!query) {
18
+ return errorResult('Query parameter is required');
19
+ }
20
+ try {
21
+ const result = await answerAppiumQuery({ query });
22
+ return textResult(result.answer);
23
+ }
24
+ catch (_docError) {
25
+ // If documentation query fails, try to initialize and retry once
26
+ try {
27
+ log.info('Documentation not initialized, initializing now...');
28
+ await initializeAppiumDocumentation();
29
+ const result = await answerAppiumQuery({ query });
30
+ return textResult(result.answer);
31
+ }
32
+ catch (retryError) {
33
+ return errorResult(`Error querying Appium documentation: ${retryError.message}. Please ensure the documentation is indexed first.`);
34
+ }
35
+ }
36
+ },
37
+ };
38
+ //# sourceMappingURL=answer-appium.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"answer-appium.js","s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C;QACH,CAAC;IACH,CAAC;CACF,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { FastMCP } from 'fastmcp';
2
+ type ToolDef = Parameters<FastMCP['addTool']>[0];
3
+ export declare const appiumSkillsTool: ToolDef;
4
+ export {};
5
+ //# sourceMappingURL=appium-skills.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appium-skills.d.ts","sourceRoot":"","sources":["../src/appium-skills.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAUvC,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAkCjD,eAAO,MAAM,gBAAgB,EAAE,OAqG9B,CAAC"}
@@ -0,0 +1,168 @@
1
+ import { readFile } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ import { z } from 'zod';
4
+ import log from './logger.js';
5
+ import { resolveAppiumResourcesPath } from './paths.js';
6
+ import { textResult } from './tool-response.js';
7
+ const ROOT = resolveAppiumResourcesPath('submodules', 'appium-skills');
8
+ const AGENTS_PATH = path.join(ROOT, 'AGENTS.md');
9
+ const SKILL_PATH = (name) => path.join(ROOT, 'skills', name, 'SKILL.md');
10
+ const SETUP_SKILLS = {
11
+ android: {
12
+ uiautomator2: [
13
+ 'environment-setup-node',
14
+ 'environment-setup-android',
15
+ 'environment-setup-uiautomator2',
16
+ ],
17
+ espresso: [
18
+ 'environment-setup-node',
19
+ 'environment-setup-android',
20
+ 'environment-setup-espresso',
21
+ ],
22
+ },
23
+ ios: {
24
+ xcuitest: ['environment-setup-node', 'environment-setup-xcuitest'],
25
+ },
26
+ };
27
+ const TEMPLATE_HEADINGS = {
28
+ 'setup:uiautomator2': 'UiAutomator2',
29
+ 'setup:espresso': 'Espresso',
30
+ 'setup:xcuitest': 'XCUITest',
31
+ 'setup:xcuitest:real': 'XCUITest Real Device',
32
+ 'troubleshoot:uiautomator2': 'Troubleshooting',
33
+ 'troubleshoot:xcuitest': 'Troubleshooting',
34
+ };
35
+ export const appiumSkillsTool = {
36
+ name: 'appium_skills',
37
+ description: `Return ordered Appium setup or troubleshooting skills from the vendored appium/skills repository.
38
+ Use this before preparing a LOCAL Appium environment or diagnosing local prerequisite issues.`,
39
+ parameters: z.object({
40
+ platform: z.enum(['android', 'ios']).describe('Target local platform.'),
41
+ driver: z
42
+ .enum(['uiautomator2', 'espresso', 'xcuitest'])
43
+ .describe('Target Appium automation driver.'),
44
+ mode: z
45
+ .enum(['setup', 'troubleshoot'])
46
+ .optional()
47
+ .default('setup')
48
+ .describe('Whether to prepare an environment or troubleshoot an existing failure.'),
49
+ realDevice: z
50
+ .boolean()
51
+ .optional()
52
+ .default(false)
53
+ .describe('For ios + xcuitest only: true for a physical device, false for simulator setup.'),
54
+ includeOptional: z
55
+ .array(z.enum(['ffmpeg', 'bundletool']))
56
+ .optional()
57
+ .default([])
58
+ .describe('Optional shared skills to include when explicitly requested.'),
59
+ }),
60
+ annotations: {
61
+ readOnlyHint: true,
62
+ openWorldHint: false,
63
+ },
64
+ execute: async (rawArgs) => {
65
+ const parsed = (rawArgs ?? {});
66
+ const args = {
67
+ platform: parsed.platform,
68
+ driver: parsed.driver,
69
+ mode: parsed.mode ?? 'setup',
70
+ realDevice: parsed.realDevice ?? false,
71
+ includeOptional: Array.isArray(parsed.includeOptional)
72
+ ? parsed.includeOptional
73
+ : [],
74
+ };
75
+ const { skillNames, ignoredOptional } = getSkillNames(args);
76
+ log.info(`Loading Appium skills for ${args.platform}/${args.driver} (${args.mode}) from ${ROOT}`);
77
+ const agentsMarkdown = await readMarkdown(AGENTS_PATH);
78
+ const promptTemplate = getPromptTemplate(agentsMarkdown, getTemplateHeading(args.mode, args.driver, args.realDevice));
79
+ const skillContents = await Promise.all(skillNames.map(async (skillName) => ({
80
+ name: skillName,
81
+ markdown: await readMarkdown(SKILL_PATH(skillName)),
82
+ })));
83
+ const lines = [
84
+ `Appium skills for ${args.platform}/${args.driver}`,
85
+ `Mode: ${args.mode}`,
86
+ `Real device: ${args.realDevice ? 'yes' : 'no'}`,
87
+ '',
88
+ 'Recommended skill order:',
89
+ ...skillNames.map((skillName, index) => `${index + 1}. ${skillName}`),
90
+ ];
91
+ if (ignoredOptional.length) {
92
+ lines.push('', `Ignored optional skills: ${ignoredOptional.join(', ')}`);
93
+ }
94
+ lines.push('', 'Source files:', '- AGENTS.md');
95
+ lines.push(...skillNames.map((skillName) => `- skills/${skillName}/SKILL.md`));
96
+ if (promptTemplate) {
97
+ lines.push('', 'Prompt template:', '```text', promptTemplate, '```');
98
+ }
99
+ lines.push('', '--- AGENTS.md ---', agentsMarkdown.trim());
100
+ for (const skill of skillContents) {
101
+ lines.push('', `--- skills/${skill.name}/SKILL.md ---`, skill.markdown.trim());
102
+ }
103
+ return textResult(lines.join('\n'));
104
+ },
105
+ };
106
+ /**
107
+ * Get the list of skill names to return based on the input arguments,
108
+ * and determine which optional skills were ignored.
109
+ * @param args
110
+ * @returns
111
+ */
112
+ function getSkillNames(args) {
113
+ const { platform, driver, mode, realDevice, includeOptional } = args;
114
+ if (realDevice && platform !== 'ios') {
115
+ throw new Error('realDevice=true is only supported for ios targets');
116
+ }
117
+ if (mode === 'troubleshoot' && driver === 'espresso') {
118
+ throw new Error('Troubleshooting guidance is currently scoped to uiautomator2 or xcuitest, matching the upstream appium/skills repository.');
119
+ }
120
+ const baseSkills = SETUP_SKILLS[platform][driver];
121
+ if (!baseSkills) {
122
+ throw new Error(platform === 'android'
123
+ ? 'xcuitest is only valid for iOS local environments'
124
+ : 'Only xcuitest is valid for iOS local environments');
125
+ }
126
+ const skillNames = [...baseSkills];
127
+ if (realDevice) {
128
+ skillNames.push('xcuitest-real-device-config');
129
+ }
130
+ if (mode === 'troubleshoot') {
131
+ skillNames.push('appium-troubleshooting');
132
+ }
133
+ const ignoredOptional = [];
134
+ for (const optional of includeOptional) {
135
+ if (optional === 'ffmpeg') {
136
+ skillNames.push('environment-setup-ffmpeg');
137
+ continue;
138
+ }
139
+ if (optional === 'bundletool' && platform === 'android') {
140
+ skillNames.push('environment-setup-bundletool');
141
+ continue;
142
+ }
143
+ ignoredOptional.push(optional);
144
+ }
145
+ return { skillNames, ignoredOptional };
146
+ }
147
+ function getTemplateHeading(mode, driver, realDevice) {
148
+ return (TEMPLATE_HEADINGS[`${mode}:${driver}${realDevice && mode === 'setup' ? ':real' : ''}`] ?? null);
149
+ }
150
+ function getPromptTemplate(agentsMarkdown, heading) {
151
+ if (!heading) {
152
+ return null;
153
+ }
154
+ const section = agentsMarkdown.split(`### Template: ${heading}\n`)[1];
155
+ if (!section) {
156
+ return null;
157
+ }
158
+ return section.match(/```text\n([\s\S]*?)```/)?.[1]?.trim() ?? null;
159
+ }
160
+ async function readMarkdown(filePath) {
161
+ try {
162
+ return await readFile(filePath, 'utf8');
163
+ }
164
+ catch {
165
+ throw new Error(`Failed to load ${path.relative(ROOT, filePath)}. Ensure the appium-skills submodule is initialized.`);
166
+ }
167
+ }
168
+ //# sourceMappingURL=appium-skills.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"appium-skills.js","sourceRoot":"","sources":["../src/appium-skills.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,GAAG,MAAM,aAAa,CAAC;AAC9B,OAAO,EAAE,0BAA0B,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAQhD,MAAM,IAAI,GAAG,0BAA0B,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC;AACvE,MAAM,WAAW,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;AACjD,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,EAAE,CAClC,IAAI,CAAC,I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about Appium
5
+ * by retrieving relevant information from indexed documentation.
6
+ */
7
+ /**
8
+ * Interface for the query response
9
+ */
10
+ interface QueryResponse {
11
+ answer: string;
12
+ sources?: string[];
13
+ chunks?: string[];
14
+ }
15
+ /**
16
+ * Initialize the Appium documentation index
17
+ * @param resourcesPath Path to the resources directory containing markdown files
18
+ */
19
+ export declare function initializeAppiumDocumentation(resourcesPath?: string): Promise<void>;
20
+ /**
21
+ * Answer a query about Appium using indexed documentation
22
+ * @param options Query options
23
+ * @returns Response with relevant chunks for the client LLM to process
24
+ */
25
+ export declare function answerAppiumQuery(options: {
26
+ query: string;
27
+ }): Promise<QueryResponse>;
28
+ export { appiumDocumentationQueryTool } from './answer-appium.js';
29
+ export { appiumSkillsTool } from './appium-skills.js';
30
+ export { AppiumDocumentation } from './plugin.js';
31
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AASH;;GAEG;AACH,UAAU,aAAa;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;GAGG;AACH,wBAAsB,6BAA6B,CACjD,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,IAAI,CAAC,CAaf;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,OAAO,EAAE;IAC/C,KAAK,EAAE,MAAM,CAAC;CACf,GAAG,OAAO,CAAC,aAAa,CAAC,CA+CzB;AAED,OAAO,EAAE,4BAA4B,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}