@adaptabletools/adaptable-mcp 0.1.0-canary.1 → 0.1.0-canary.2

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 (271) hide show
  1. package/README.md +3 -1
  2. package/data/changes/21-22.json +542 -0
  3. package/data/changes/22-23.json +639 -0
  4. package/data/changes/23-24.json +1874 -0
  5. package/data/manifest.snapshot.json +28 -10
  6. package/data/templates/angular/src/app/adaptableOptions.ts +40 -0
  7. package/data/templates/angular/src/app/agGridModules.ts +7 -0
  8. package/data/templates/angular/src/app/app.component.ts +66 -0
  9. package/data/templates/angular/src/app/app.module.ts +14 -0
  10. package/data/templates/angular/src/app/columnDefs.ts +121 -0
  11. package/data/templates/angular/src/app/gridOptions.ts +32 -0
  12. package/data/templates/angular/src/app/onAdaptableReady.ts +11 -0
  13. package/data/templates/angular/src/app/rowData.ts +851 -0
  14. package/data/templates/angular/src/app/styles.css +50 -0
  15. package/data/templates/angular/src/index.html +17 -0
  16. package/data/templates/angular/src/main.ts +18 -0
  17. package/data/templates/angular/src/polyfills.ts +1 -0
  18. package/data/templates/angular/tsconfig.json +16 -0
  19. package/data/templates/manifest.json +406 -0
  20. package/data/templates/react/src/App.tsx +71 -0
  21. package/data/templates/react/src/adaptableOptions.ts +40 -0
  22. package/data/templates/react/src/agGridModules.ts +7 -0
  23. package/data/templates/react/src/columnDefs.ts +121 -0
  24. package/data/templates/react/src/gridOptions.ts +32 -0
  25. package/data/templates/react/src/index.tsx +8 -0
  26. package/data/templates/react/src/onAdaptableReady.ts +11 -0
  27. package/data/templates/react/src/rowData.ts +851 -0
  28. package/data/templates/react/src/styles.css +50 -0
  29. package/data/templates/react/tsconfig.json +9 -0
  30. package/data/templates/vanilla/index.html +18 -0
  31. package/data/templates/vanilla/src/adaptableOptions.ts +40 -0
  32. package/data/templates/vanilla/src/agGridModules.ts +7 -0
  33. package/data/templates/vanilla/src/columnDefs.ts +121 -0
  34. package/data/templates/vanilla/src/gridOptions.ts +32 -0
  35. package/data/templates/vanilla/src/index.ts +41 -0
  36. package/data/templates/vanilla/src/onAdaptableReady.ts +11 -0
  37. package/data/templates/vanilla/src/rowData.ts +851 -0
  38. package/data/templates/vanilla/src/styles.css +50 -0
  39. package/data/templates/vanilla/tsconfig.json +14 -0
  40. package/data/templates/vue/.babelrc +3 -0
  41. package/data/templates/vue/public/index.html +19 -0
  42. package/data/templates/vue/src/App.vue +35 -0
  43. package/data/templates/vue/src/adaptableOptions.ts +40 -0
  44. package/data/templates/vue/src/agGridModules.ts +7 -0
  45. package/data/templates/vue/src/columnDefs.ts +121 -0
  46. package/data/templates/vue/src/gridOptions.ts +32 -0
  47. package/data/templates/vue/src/main.ts +6 -0
  48. package/data/templates/vue/src/onAdaptableReady.ts +11 -0
  49. package/data/templates/vue/src/rowData.ts +851 -0
  50. package/data/templates/vue/src/shims-vue.d.ts +6 -0
  51. package/data/templates/vue/src/styles.css +50 -0
  52. package/data/templates/vue/tsconfig.json +30 -0
  53. package/dist/bin.js +7 -0
  54. package/dist/bin.js.map +1 -1
  55. package/dist/cli/index.js +8 -0
  56. package/dist/cli/index.js.map +1 -1
  57. package/dist/core/anonymise/anonymise.js +315 -0
  58. package/dist/core/anonymise/anonymise.js.map +1 -0
  59. package/dist/core/anonymise/capabilities.js +94 -0
  60. package/dist/core/anonymise/capabilities.js.map +1 -0
  61. package/dist/core/aql/capabilities.js +339 -0
  62. package/dist/core/aql/capabilities.js.map +1 -0
  63. package/dist/core/aql/check.js +204 -0
  64. package/dist/core/aql/check.js.map +1 -0
  65. package/dist/core/aql/engine.js +92 -0
  66. package/dist/core/aql/engine.js.map +1 -0
  67. package/dist/core/aql/functions.js +108 -0
  68. package/dist/core/aql/functions.js.map +1 -0
  69. package/dist/core/aql/migrate.js +62 -0
  70. package/dist/core/aql/migrate.js.map +1 -0
  71. package/dist/core/capabilities.js +9 -3
  72. package/dist/core/capabilities.js.map +1 -1
  73. package/dist/core/changes/capabilities.js +92 -0
  74. package/dist/core/changes/capabilities.js.map +1 -0
  75. package/dist/core/changes/changes.js +101 -0
  76. package/dist/core/changes/changes.js.map +1 -0
  77. package/dist/core/changes/grep.js +183 -0
  78. package/dist/core/changes/grep.js.map +1 -0
  79. package/dist/core/changes/records.js +172 -0
  80. package/dist/core/changes/records.js.map +1 -0
  81. package/dist/core/changes/render-md.js +101 -0
  82. package/dist/core/changes/render-md.js.map +1 -0
  83. package/dist/core/changes/with-docs.js +86 -0
  84. package/dist/core/changes/with-docs.js.map +1 -0
  85. package/dist/core/compat/capabilities.js +1 -1
  86. package/dist/core/compat/capabilities.js.map +1 -1
  87. package/dist/core/context/capabilities.js +1 -1
  88. package/dist/core/context/capabilities.js.map +1 -1
  89. package/dist/core/convert/capabilities.js +86 -0
  90. package/dist/core/convert/capabilities.js.map +1 -0
  91. package/dist/core/convert/coldefs.js +313 -0
  92. package/dist/core/convert/coldefs.js.map +1 -0
  93. package/dist/core/docs/cache.js +1 -1
  94. package/dist/core/docs/capabilities.js +1 -5
  95. package/dist/core/docs/capabilities.js.map +1 -1
  96. package/dist/core/docs/hosts.js +2 -2
  97. package/dist/core/docs/hosts.js.map +1 -1
  98. package/dist/core/extract/imports.js +163 -0
  99. package/dist/core/extract/imports.js.map +1 -0
  100. package/dist/core/extract/input.js +140 -0
  101. package/dist/core/extract/input.js.map +1 -0
  102. package/dist/core/extract/line-map.js +90 -0
  103. package/dist/core/extract/line-map.js.map +1 -0
  104. package/dist/core/extract/ts-literal.js +963 -0
  105. package/dist/core/extract/ts-literal.js.map +1 -0
  106. package/dist/core/migrate/capabilities.js +143 -0
  107. package/dist/core/migrate/capabilities.js.map +1 -0
  108. package/dist/core/migrate/leftovers.js +119 -0
  109. package/dist/core/migrate/leftovers.js.map +1 -0
  110. package/dist/core/migrate/state.js +295 -0
  111. package/dist/core/migrate/state.js.map +1 -0
  112. package/dist/core/packages/cache.js +2 -1
  113. package/dist/core/packages/cache.js.map +1 -1
  114. package/dist/core/register.js +8 -0
  115. package/dist/core/register.js.map +1 -1
  116. package/dist/core/scaffold/capabilities.js +434 -0
  117. package/dist/core/scaffold/capabilities.js.map +1 -0
  118. package/dist/core/scaffold/generate.js +409 -0
  119. package/dist/core/scaffold/generate.js.map +1 -0
  120. package/dist/core/scaffold/infer.js +441 -0
  121. package/dist/core/scaffold/infer.js.map +1 -0
  122. package/dist/core/scaffold/overlay.js +290 -0
  123. package/dist/core/scaffold/overlay.js.map +1 -0
  124. package/dist/core/scaffold/readers/csv.js +146 -0
  125. package/dist/core/scaffold/readers/csv.js.map +1 -0
  126. package/dist/core/scaffold/readers/dataset.js +53 -0
  127. package/dist/core/scaffold/readers/dataset.js.map +1 -0
  128. package/dist/core/scaffold/readers/index.js +62 -0
  129. package/dist/core/scaffold/readers/index.js.map +1 -0
  130. package/dist/core/scaffold/readers/json.js +101 -0
  131. package/dist/core/scaffold/readers/json.js.map +1 -0
  132. package/dist/core/scaffold/readers/xlsx.js +81 -0
  133. package/dist/core/scaffold/readers/xlsx.js.map +1 -0
  134. package/dist/core/scaffold/suggestions.js +57 -0
  135. package/dist/core/scaffold/suggestions.js.map +1 -0
  136. package/dist/core/scaffold/templates.js +59 -0
  137. package/dist/core/scaffold/templates.js.map +1 -0
  138. package/dist/core/setup/audit.js +91 -0
  139. package/dist/core/setup/audit.js.map +1 -0
  140. package/dist/core/setup/capabilities.js +80 -0
  141. package/dist/core/setup/capabilities.js.map +1 -0
  142. package/dist/core/setup/context.js +118 -0
  143. package/dist/core/setup/context.js.map +1 -0
  144. package/dist/core/setup/rules/cell-data-type.js +40 -0
  145. package/dist/core/setup/rules/cell-data-type.js.map +1 -0
  146. package/dist/core/setup/rules/coldef-ownership.js +67 -0
  147. package/dist/core/setup/rules/coldef-ownership.js.map +1 -0
  148. package/dist/core/setup/rules/css-import.js +34 -0
  149. package/dist/core/setup/rules/css-import.js.map +1 -0
  150. package/dist/core/setup/rules/direct-grid.js +42 -0
  151. package/dist/core/setup/rules/direct-grid.js.map +1 -0
  152. package/dist/core/setup/rules/index.js +53 -0
  153. package/dist/core/setup/rules/index.js.map +1 -0
  154. package/dist/core/setup/rules/licence-literal.js +23 -0
  155. package/dist/core/setup/rules/licence-literal.js.map +1 -0
  156. package/dist/core/setup/rules/modules.js +86 -0
  157. package/dist/core/setup/rules/modules.js.map +1 -0
  158. package/dist/core/setup/rules/react-stable-refs.js +20 -0
  159. package/dist/core/setup/rules/react-stable-refs.js.map +1 -0
  160. package/dist/core/setup/rules/ready-hook.js +33 -0
  161. package/dist/core/setup/rules/ready-hook.js.map +1 -0
  162. package/dist/core/setup/rules/required-options.js +43 -0
  163. package/dist/core/setup/rules/required-options.js.map +1 -0
  164. package/dist/core/setup/rules/rule.js +10 -0
  165. package/dist/core/setup/rules/rule.js.map +1 -0
  166. package/dist/core/setup/rules/version-skew.js +65 -0
  167. package/dist/core/setup/rules/version-skew.js.map +1 -0
  168. package/dist/core/state/capabilities.js +78 -0
  169. package/dist/core/state/capabilities.js.map +1 -0
  170. package/dist/core/state/check.js +216 -0
  171. package/dist/core/state/check.js.map +1 -0
  172. package/dist/core/state/columns.js +130 -0
  173. package/dist/core/state/columns.js.map +1 -0
  174. package/dist/core/state/did-you-mean.js +83 -0
  175. package/dist/core/state/did-you-mean.js.map +1 -0
  176. package/dist/core/state/expressions.js +170 -0
  177. package/dist/core/state/expressions.js.map +1 -0
  178. package/dist/core/state/known-names.js +96 -0
  179. package/dist/core/state/known-names.js.map +1 -0
  180. package/dist/core/state/rules/aql-legacy-shape.js +42 -0
  181. package/dist/core/state/rules/aql-legacy-shape.js.map +1 -0
  182. package/dist/core/state/rules/aql-missing.js +21 -0
  183. package/dist/core/state/rules/aql-missing.js.map +1 -0
  184. package/dist/core/state/rules/aql-syntax.js +77 -0
  185. package/dist/core/state/rules/aql-syntax.js.map +1 -0
  186. package/dist/core/state/rules/calculated-settings.js +23 -0
  187. package/dist/core/state/rules/calculated-settings.js.map +1 -0
  188. package/dist/core/state/rules/column-id-exists.js +29 -0
  189. package/dist/core/state/rules/column-id-exists.js.map +1 -0
  190. package/dist/core/state/rules/dashboard-module-names.js +31 -0
  191. package/dist/core/state/rules/dashboard-module-names.js.map +1 -0
  192. package/dist/core/state/rules/dashboard-toolbar-names.js +48 -0
  193. package/dist/core/state/rules/dashboard-toolbar-names.js.map +1 -0
  194. package/dist/core/state/rules/format-column-pivot-display-format.js +43 -0
  195. package/dist/core/state/rules/format-column-pivot-display-format.js.map +1 -0
  196. package/dist/core/state/rules/helpers.js +39 -0
  197. package/dist/core/state/rules/helpers.js.map +1 -0
  198. package/dist/core/state/rules/index.js +80 -0
  199. package/dist/core/state/rules/index.js.map +1 -0
  200. package/dist/core/state/rules/layout-column-refs.js +60 -0
  201. package/dist/core/state/rules/layout-column-refs.js.map +1 -0
  202. package/dist/core/state/rules/layout-current-exists.js +27 -0
  203. package/dist/core/state/rules/layout-current-exists.js.map +1 -0
  204. package/dist/core/state/rules/layout-non-empty.js +32 -0
  205. package/dist/core/state/rules/layout-non-empty.js.map +1 -0
  206. package/dist/core/state/rules/rule.js +2 -0
  207. package/dist/core/state/rules/rule.js.map +1 -0
  208. package/dist/core/state/rules/scope-column-refs.js +32 -0
  209. package/dist/core/state/rules/scope-column-refs.js.map +1 -0
  210. package/dist/core/state/rules/scope-shape.js +61 -0
  211. package/dist/core/state/rules/scope-shape.js.map +1 -0
  212. package/dist/core/state/rules/state-unique-name.js +40 -0
  213. package/dist/core/state/rules/state-unique-name.js.map +1 -0
  214. package/dist/core/state/rules/state-unknown-section.js +30 -0
  215. package/dist/core/state/rules/state-unknown-section.js.map +1 -0
  216. package/dist/core/state/rules/type-discriminator.js +70 -0
  217. package/dist/core/state/rules/type-discriminator.js.map +1 -0
  218. package/dist/core/state/type-check.js +349 -83
  219. package/dist/core/state/type-check.js.map +1 -1
  220. package/dist/mcp/index.js +104 -16
  221. package/dist/mcp/index.js.map +1 -1
  222. package/dist/mcp/server.js +110 -0
  223. package/dist/mcp/server.js.map +1 -0
  224. package/dist/skills/adaptable-debug/SKILL.md +145 -0
  225. package/dist/skills/adaptable-debug/VERSION.md +1 -0
  226. package/dist/skills/adaptable-debug/references/_shared/agents-snippet.md +3 -0
  227. package/dist/skills/adaptable-debug/references/_shared/capabilities.md +35 -0
  228. package/dist/skills/adaptable-debug/references/_shared/conversation.md +20 -0
  229. package/dist/skills/adaptable-debug/references/_shared/docs-protocol.md +36 -0
  230. package/dist/skills/adaptable-debug/references/_shared/grounding.md +54 -0
  231. package/dist/skills/adaptable-debug/references/_shared/guards.md +20 -0
  232. package/dist/skills/adaptable-debug/references/_shared/validation-loop.md +42 -0
  233. package/dist/skills/adaptable-debug/references/devtools-api.md +36 -0
  234. package/dist/skills/adaptable-debug/references/feedback-template.md +36 -0
  235. package/dist/skills/adaptable-debug/references/symptoms.md +37 -0
  236. package/dist/skills/adaptable-debug/references/ticket-template.md +50 -0
  237. package/dist/skills/adaptable-dev/SKILL.md +97 -0
  238. package/dist/skills/adaptable-dev/VERSION.md +1 -0
  239. package/dist/skills/adaptable-dev/references/_shared/agents-snippet.md +3 -0
  240. package/dist/skills/adaptable-dev/references/_shared/capabilities.md +35 -0
  241. package/dist/skills/adaptable-dev/references/_shared/conversation.md +20 -0
  242. package/dist/skills/adaptable-dev/references/_shared/docs-protocol.md +36 -0
  243. package/dist/skills/adaptable-dev/references/_shared/grounding.md +54 -0
  244. package/dist/skills/adaptable-dev/references/_shared/guards.md +20 -0
  245. package/dist/skills/adaptable-dev/references/_shared/validation-loop.md +42 -0
  246. package/dist/skills/adaptable-dev/references/recommendations.md +93 -0
  247. package/dist/skills/adaptable-setup/SKILL.md +158 -0
  248. package/dist/skills/adaptable-setup/VERSION.md +1 -0
  249. package/dist/skills/adaptable-setup/references/_shared/agents-snippet.md +3 -0
  250. package/dist/skills/adaptable-setup/references/_shared/capabilities.md +35 -0
  251. package/dist/skills/adaptable-setup/references/_shared/conversation.md +20 -0
  252. package/dist/skills/adaptable-setup/references/_shared/docs-protocol.md +36 -0
  253. package/dist/skills/adaptable-setup/references/_shared/grounding.md +54 -0
  254. package/dist/skills/adaptable-setup/references/_shared/guards.md +20 -0
  255. package/dist/skills/adaptable-setup/references/_shared/validation-loop.md +42 -0
  256. package/dist/skills/adaptable-setup/references/paths.md +45 -0
  257. package/dist/skills/adaptable-upgrade/SKILL.md +269 -0
  258. package/dist/skills/adaptable-upgrade/VERSION.md +1 -0
  259. package/dist/skills/adaptable-upgrade/references/_shared/agents-snippet.md +3 -0
  260. package/dist/skills/adaptable-upgrade/references/_shared/capabilities.md +35 -0
  261. package/dist/skills/adaptable-upgrade/references/_shared/conversation.md +20 -0
  262. package/dist/skills/adaptable-upgrade/references/_shared/docs-protocol.md +36 -0
  263. package/dist/skills/adaptable-upgrade/references/_shared/grounding.md +54 -0
  264. package/dist/skills/adaptable-upgrade/references/_shared/guards.md +20 -0
  265. package/dist/skills/adaptable-upgrade/references/_shared/validation-loop.md +42 -0
  266. package/dist/skills/adaptable-upgrade/references/apply-order.md +171 -0
  267. package/dist/skills/adaptable-upgrade/references/plan-preamble.md +151 -0
  268. package/dist/skills/adaptable-upgrade/scripts/adaptable.mjs +24 -0
  269. package/package.json +11 -5
  270. package/dist/core/state/rules.js +0 -417
  271. package/dist/core/state/rules.js.map +0 -1
package/dist/mcp/index.js CHANGED
@@ -1,21 +1,109 @@
1
1
  /**
2
- * MCP entry. A6.1 replaces this with the stdio server generated from the
3
- * registry (plan §9); until then `adaptable mcp` fails with `NOT_FOUND` and
4
- * exit 2 so a client configuration that points here reports a clear error
5
- * instead of hanging.
2
+ * `adaptable mcp [--cwd <dir>] [--major <n>] [--framework <fw>] [--offline] [--docs-host <url>]`
3
+ * — the stdio MCP server (plan §8.14, §9). The flags are defaults for every tool
4
+ * call; a tool argument of the same name wins. stdout belongs to the transport, so
5
+ * everything else goes to stderr. The returned promise settles when the client
6
+ * closes the connection.
6
7
  */
8
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
7
9
  import { exitCodeFor } from '../core/index.js';
8
- export async function runMcp(_argv, io) {
9
- const envelope = {
10
- schemaVersion: 1,
11
- ok: false,
12
- error: {
13
- code: 'NOT_FOUND',
14
- message: 'The MCP server is not available in this build of @adaptabletools/adaptable-mcp.',
15
- hint: 'Use the `adaptable` CLI (`adaptable --help`), or upgrade to a version whose `adaptable --capabilities` lists MCP tools.',
16
- },
17
- };
18
- io.stderr(`${JSON.stringify(envelope, null, 2)}\n`);
19
- return exitCodeFor(envelope);
10
+ import { createServer, mcpCapabilities } from './server.js';
11
+ const FRAMEWORKS = ['vanilla', 'react', 'angular', 'vue'];
12
+ const usage = (message) => ({
13
+ schemaVersion: 1,
14
+ ok: false,
15
+ error: { code: 'USAGE', message, hint: 'Usage: adaptable mcp [--cwd <dir>] [--major <n>] [--framework <fw>] [--offline] [--docs-host <url>]' },
16
+ });
17
+ /** Parses the server flags; returns a usage envelope for anything it does not know */
18
+ export function parseMcpArgs(argv) {
19
+ const defaults = {};
20
+ for (let i = 0; i < argv.length; i++) {
21
+ const arg = argv[i];
22
+ const [flag, inline] = arg.includes('=') ? [arg.slice(0, arg.indexOf('=')), arg.slice(arg.indexOf('=') + 1)] : [arg, undefined];
23
+ const value = () => inline ?? argv[++i];
24
+ switch (flag) {
25
+ case '--help':
26
+ case '-h':
27
+ return { help: true };
28
+ case '--offline':
29
+ defaults.offline = true;
30
+ break;
31
+ case '--cwd': {
32
+ const v = value();
33
+ if (!v) {
34
+ return { error: usage('--cwd needs a folder.') };
35
+ }
36
+ defaults.cwd = v;
37
+ break;
38
+ }
39
+ case '--docs-host': {
40
+ const v = value();
41
+ if (!v) {
42
+ return { error: usage('--docs-host needs a URL.') };
43
+ }
44
+ defaults.docsHost = v;
45
+ break;
46
+ }
47
+ case '--major': {
48
+ const v = value();
49
+ const n = Number(v);
50
+ if (!v || !Number.isInteger(n)) {
51
+ return { error: usage(`--major needs a whole number${v ? ` (got "${v}")` : ''}.`) };
52
+ }
53
+ defaults.major = n;
54
+ break;
55
+ }
56
+ case '--framework': {
57
+ const v = value();
58
+ if (!v || !FRAMEWORKS.includes(v)) {
59
+ return { error: usage(`--framework must be one of ${FRAMEWORKS.join(', ')}${v ? ` (got "${v}")` : ''}.`) };
60
+ }
61
+ defaults.framework = v;
62
+ break;
63
+ }
64
+ default:
65
+ return { error: usage(`Unknown option "${arg}".`) };
66
+ }
67
+ }
68
+ return { defaults };
69
+ }
70
+ export function mcpHelp() {
71
+ const tools = mcpCapabilities('stdio').map((c) => ` ${c.mcp.tool.padEnd(26)} ${c.description}`);
72
+ return [
73
+ 'Usage: adaptable mcp [options]',
74
+ '',
75
+ 'Starts the AdapTable MCP server on stdio. Configure it in your MCP client as',
76
+ ' { "command": "npx", "args": ["-y", "@adaptabletools/adaptable-mcp@^1", "mcp"] }',
77
+ '',
78
+ 'Options (defaults for every tool call; a tool argument of the same name wins):',
79
+ ' --cwd <dir> Project folder; defaults to the current directory',
80
+ ' --major <n> AdapTable major to assume instead of detecting it',
81
+ ' --framework <fw> Framework to assume instead of detecting it (vanilla, react, angular, vue)',
82
+ ' --offline Never touch the network; use caches and bundled snapshots',
83
+ ' --docs-host <url> Docs host to read instead of the default one',
84
+ '',
85
+ 'Tools:',
86
+ ...tools,
87
+ '',
88
+ ].join('\n');
89
+ }
90
+ export async function runMcp(argv, io) {
91
+ const parsed = parseMcpArgs(argv);
92
+ if ('help' in parsed) {
93
+ io.stderr(mcpHelp());
94
+ return 0;
95
+ }
96
+ if ('error' in parsed) {
97
+ io.stderr(`${JSON.stringify(parsed.error, null, 2)}\n`);
98
+ return exitCodeFor(parsed.error);
99
+ }
100
+ const server = createServer({ defaults: parsed.defaults, transport: 'stdio' });
101
+ const transport = new StdioServerTransport();
102
+ const closed = new Promise((resolve) => {
103
+ server.server.onclose = () => resolve();
104
+ });
105
+ await server.connect(transport);
106
+ await closed;
107
+ return 0;
20
108
  }
21
109
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"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
2
+ * The MCP server, generated from the capability registry (plan §9): one tool per
3
+ * capability with an `mcp` binding, the input schema taken from the capability's
4
+ * zod schema plus the global options, the result the same envelope the CLI prints
5
+ * with `--json`. No prompts, no resources, no write tools.
6
+ *
7
+ * Freshness (§9): the server outlives docs deploys, so every call passes the 60 s
8
+ * manifest re-validation window to core; the engine and types packages are
9
+ * resolved per call by core itself (§7.3), never from a cache keyed on the first
10
+ * project the server saw.
11
+ */
12
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
13
+ import { z } from 'zod';
14
+ import { CLI_PACKAGE, CLI_VERSION, SCHEMA_VERSION, listCapabilities, runCapability, } from '../core/index.js';
15
+ /** How long the long-lived server trusts a validated docs manifest before the next conditional GET (§9) */
16
+ export const MANIFEST_MAX_AGE_MS = 60_000;
17
+ /**
18
+ * The global options a tool call may carry (plan §7.1). `--json` and `--quiet`
19
+ * are CLI rendering flags with no meaning over MCP. Mirrors the CLI's
20
+ * `GLOBAL_FLAGS`; the names are the `GlobalOptions` keys core validates.
21
+ */
22
+ export const TOOL_GLOBALS = {
23
+ cwd: z.string().optional().describe('Project folder (absolute path); defaults to the folder the server was started in'),
24
+ major: z.number().int().optional().describe('AdapTable major to assume instead of detecting it from the project'),
25
+ framework: z.enum(['vanilla', 'react', 'angular', 'vue']).optional().describe('Framework to assume instead of detecting it'),
26
+ offline: z.boolean().optional().describe('Never touch the network; use caches and bundled snapshots'),
27
+ docsHost: z.string().optional().describe('Docs host to read instead of the default one'),
28
+ };
29
+ export const GLOBAL_KEYS = Object.keys(TOOL_GLOBALS);
30
+ const SERVER_INSTRUCTIONS = [
31
+ `AdapTable developer tooling (${CLI_PACKAGE} ${CLI_VERSION}, response schema ${SCHEMA_VERSION}).`,
32
+ 'Every tool returns the same envelope as the `adaptable` CLI with `--json`: `ok`, `data`, `issues`, `warnings`, `resolvedContext`, or `error { code, message, hint }`.',
33
+ 'Call `detect_environment` first so later calls run against the project\'s AdapTable version; pass `cwd` when the project is not the server\'s working directory.',
34
+ 'Workflows (setup, development, debugging, upgrades) live in the adaptable-* skills, not in this server.',
35
+ ].join(' ');
36
+ /** The zod object a capability's input is declared with; the registry only accepts objects */
37
+ function inputShape(capability) {
38
+ const input = capability.input;
39
+ if (!input.shape || typeof input.shape !== 'object') {
40
+ throw new Error(`Capability "${capability.name}": the MCP binding needs an object input schema.`);
41
+ }
42
+ return input.shape;
43
+ }
44
+ /** The tool's input schema: the capability's fields plus the global options (a capability field of the same name wins) */
45
+ export function toolInputSchema(capability) {
46
+ return z.object({ ...TOOL_GLOBALS, ...inputShape(capability) });
47
+ }
48
+ /** Splits the raw tool arguments into the capability input and the global options */
49
+ export function splitArguments(args, capability) {
50
+ const own = new Set(Object.keys(inputShape(capability)));
51
+ const input = {};
52
+ const globals = {};
53
+ for (const [key, value] of Object.entries(args)) {
54
+ if (value === undefined) {
55
+ continue;
56
+ }
57
+ if (!own.has(key) && GLOBAL_KEYS.includes(key)) {
58
+ globals[key] = value;
59
+ }
60
+ else {
61
+ input[key] = value;
62
+ }
63
+ }
64
+ return { input, globals: globals };
65
+ }
66
+ /** The envelope as a tool result: the JSON as text (what the skills parse), the object as structured content */
67
+ export function toolResult(envelope) {
68
+ return {
69
+ content: [{ type: 'text', text: JSON.stringify(envelope) }],
70
+ structuredContent: envelope,
71
+ isError: !envelope.ok,
72
+ };
73
+ }
74
+ /** The capabilities the server exposes for a transport, in registry order */
75
+ export function mcpCapabilities(transport = 'stdio') {
76
+ return listCapabilities().filter((c) => c.mcp && (transport === 'stdio' || !c.mcp.stdioOnly));
77
+ }
78
+ /** Network-reading tools get `openWorldHint`; every tool is read-only and idempotent */
79
+ function annotationsFor(capability) {
80
+ const reachesDocs = ['docs', 'compat', 'changes', 'detect'].includes(capability.cli.command[0]);
81
+ return {
82
+ title: `adaptable ${capability.cli.command.join(' ')}`,
83
+ readOnlyHint: true,
84
+ destructiveHint: false,
85
+ idempotentHint: true,
86
+ openWorldHint: reachesDocs,
87
+ };
88
+ }
89
+ /** Builds the server; the caller connects a transport */
90
+ export function createServer(options = {}) {
91
+ const transport = options.transport ?? 'stdio';
92
+ const defaults = options.defaults ?? {};
93
+ const manifestMaxAgeMs = options.manifestMaxAgeMs ?? MANIFEST_MAX_AGE_MS;
94
+ const server = new McpServer({ name: CLI_PACKAGE, version: CLI_VERSION }, { instructions: SERVER_INSTRUCTIONS });
95
+ for (const capability of mcpCapabilities(transport)) {
96
+ const tool = capability.mcp.tool;
97
+ server.registerTool(tool, {
98
+ title: annotationsFor(capability).title,
99
+ description: capability.description,
100
+ inputSchema: toolInputSchema(capability),
101
+ annotations: annotationsFor(capability),
102
+ }, async (args) => {
103
+ const { input, globals } = splitArguments(args, capability);
104
+ const envelope = await runCapability(capability.name, input, { ...defaults, ...globals }, { manifestMaxAgeMs });
105
+ return toolResult(envelope);
106
+ });
107
+ }
108
+ return server;
109
+ }
110
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,WAAW,EACX,WAAW,EACX,cAAc,EACd,gBAAgB,EAChB,aAAa,GAId,MAAM,kBAAkB,CAAC;AAE1B,2GAA2G;AAC3G,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC;AAa1C;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kFAAkF,CAAC;IACvH,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,oEAAoE,CAAC;IACjH,SAAS,EAAE,CAAC,CAAC,IAAI,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AE,KAAK,EAAE,EAAE,GAAG,QAAQ,EAAE,GAAG,OAAO,EAAE,EAAE,EAAE,gBAAgB,EAAE,CAAC,CAAC;YAChH,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC;QAC9B,CAAC,CACF,CAAC;IACJ,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,145 @@
1
+ ---
2
+ name: adaptable-debug
3
+ description: "Use when a running AdapTable grid misbehaves or the user asks what the grid is doing right now: a Layout, Column Filter, Grid Filter, Format Column, Styled Column, Calculated Column or Alert not applied; wrong columns or rows; State not persisting, loading or migrating; AdapTable console errors; or to extract Adaptable State, columns, logs or Grid Info from a page — and, when a problem cannot be resolved, to assemble an anonymised support case or feedback package. Works through window.__ADAPTABLE_DEVTOOLS__ with whatever browser tool is available. Not for compile/type errors or new features (adaptable-dev)."
4
+ ---
5
+
6
+ # adaptable-debug — diagnose a running AdapTable grid
7
+
8
+ The grid is the evidence. Everything below reads it through
9
+ `window.__ADAPTABLE_DEVTOOLS__` before touching source. Shared protocol, read
10
+ once: [grounding](references/_shared/grounding.md) (always first),
11
+ [validation loop](references/_shared/validation-loop.md),
12
+ [conversation](references/_shared/conversation.md),
13
+ [guards](references/_shared/guards.md). Command bindings are in
14
+ [capabilities](references/_shared/capabilities.md); the in-page API is
15
+ [devtools-api](references/devtools-api.md); the triage table is
16
+ [symptoms](references/symptoms.md).
17
+
18
+ ## Phase 1 — Ground
19
+
20
+ Run `detect` (see grounding) so the checks later target the installed major.
21
+ **Tell** the user which app and page you expect the grid on, and confirm it
22
+ is running; a stale dev server diagnoses a grid that is not the one on screen.
23
+
24
+ ## Phase 2 — Access
25
+
26
+ Use the harness's browser tool when one exists — any tool that can evaluate
27
+ JavaScript on the page can call the DevTools global.
28
+
29
+ With no browser tool, **tell** the user to paste these three calls into the
30
+ browser console and paste the results back (the global is `window.__ADAPTABLE_DEVTOOLS__`):
31
+
32
+ ```js
33
+ __ADAPTABLE_DEVTOOLS__.getPersistentState()
34
+ __ADAPTABLE_DEVTOOLS__.getColumns()
35
+ __ADAPTABLE_DEVTOOLS__.getLogs(undefined, { level: ['error', 'warn'] })
36
+ ```
37
+
38
+ Save whatever comes back to scratch files. Files the user already collected
39
+ with these calls (a support bundle: `persistent-state.json`, `columns.json`,
40
+ `logs.json`, `grid-info.json`) are the same evidence — start at phase 4 with
41
+ them rather than asking for a fresh capture. Never write ad-hoc in-page
42
+ scripts that reach into grid internals — the DevTools calls are the
43
+ supported surface; `help()` on the global prints its own usage.
44
+
45
+ ## Phase 3 — Collect
46
+
47
+ Save each result to a scratch file (not into the conversation):
48
+
49
+ 1. `listInstances()` — several ids means **ask** which grid is misbehaving;
50
+ diagnosing the wrong instance wastes the whole cycle.
51
+ 2. `getGridInfo(id)` — versions, options summary, environment. **Strip the
52
+ licence key before the file is shown, quoted or attached** (guards).
53
+ 3. `getLogs(id, { level: ['error', 'warn'], limit: 100 })` — errors and
54
+ warnings first; widen only when they are empty.
55
+ 4. `getRecentActions(id, 50)` — what changed last ("who moved the Layout").
56
+ 5. `getColumns(id)` → `columns.json` — the effective columns, the file every
57
+ later check uses. `getColumnInfo(id, '<colId>')` when one column is
58
+ implicated; it is cheaper than reading everything.
59
+ 6. Only the implicated section: `getState(id, '<Section>')`. **Never** fetch
60
+ the whole State when one section is in question.
61
+ 7. `getPersistentState(id)` when the symptom concerns persistence or
62
+ migration, or whenever live behaviour contradicts the source.
63
+
64
+ Calling any of these before the grid mounts returns nothing useful — if the
65
+ instance list is empty, the problem is mounting, not State (symptoms.md).
66
+
67
+ ## Phase 4 — Validate what you collected
68
+
69
+ ```bash
70
+ npx -y @adaptabletools/adaptable-mcp@canary check state persistent.json --columns columns.json --kind persistent
71
+ npx -y @adaptabletools/adaptable-mcp@canary check expression "<suspect rule>" --module <Module> --columns columns.json
72
+ ```
73
+
74
+ A persisted State that fails explains most "impossible" behaviour in one
75
+ run. Rules extracted from live State get the same expression check a new one
76
+ would (validation loop).
77
+
78
+ ## Phase 5 — Triage
79
+
80
+ Work the symptom through [symptoms](references/symptoms.md): symptom →
81
+ where to look → likely causes → docs.
82
+
83
+ Always compare the live State against the source `initialState`. Persisted
84
+ State shadowing source edits is the most common impossible bug: the user (or
85
+ an earlier session) saved a Layout, and every source edit since has merged
86
+ *underneath* it. When that is the story, explain in plain terms before
87
+ proposing anything — the user's saved work is in that State (guards): the
88
+ state key decides which saved State loads; a section's `Revision` in
89
+ `initialState` (a number, or `{ Key, UpdateStrategy: 'Override' |
90
+ 'KeepUserDefined' }`) is how a source change deliberately replaces that one
91
+ persisted section on the next load
92
+ (`docs get dev-guide-adaptable-state-updating-initial-state`); and
93
+ `stateApi.reloadInitialState()` discards the whole saved State. The usual fix
94
+ is a `Revision` bump on the section the user is editing, not a cleared store.
95
+
96
+ Distinguish AdapTable's Layout from AG Grid's own column state: a column
97
+ AG Grid reports as moved is not evidence the Layout changed; `getState(id,
98
+ 'Layout')` is.
99
+
100
+ ## Phase 6 — Fix at the source
101
+
102
+ Fixes land where the behaviour is owned: `initialState` for State, Options
103
+ for wiring, `columnDefs` for typing (adaptable-dev rules). Hand-editing
104
+ persisted State in storage is not a fix — it desynchronises the user from
105
+ their own saved State and the next save overwrites it.
106
+
107
+ When wiring is suspect (modules, wrapper, direct grid use, ColDef
108
+ ownership), run `check setup` and fix what it names.
109
+
110
+ ## Phase 7 — Verify
111
+
112
+ Reload the page and repeat the phase-3 reads that showed the problem: the
113
+ section now matches the source, the logs are clean, the column set is the
114
+ expected one. `restoreState` is an experiment, not a fix — only with the
115
+ user's explicit confirmation, and say what it discards before running it
116
+ (guards).
117
+
118
+ ## Phase 8 — Support case or feedback (unresolved, or on request)
119
+
120
+ After one full collect → validate → triage cycle without a root cause, or
121
+ whenever the user asks, assemble the package from
122
+ [ticket-template](references/ticket-template.md): symptom, expected vs
123
+ actual, steps; the relevant State section and `columns.json`; the Options
124
+ snippet with keys stripped; the logs.
125
+
126
+ **Ask** before including any row-data values. The default is scrubbed:
127
+
128
+ ```bash
129
+ npx -y @adaptabletools/adaptable-mcp@canary anonymise <bundle file> --out anonymised.json
130
+ ```
131
+
132
+ Try to reproduce the symptom in the public support template linked from
133
+ `getting-started-integration` before filing. Write
134
+ `ADAPTABLE_SUPPORT_CASE.md` (destination: the form on the
135
+ `adaptable-support-ticket` support page). **The skill never sends anything**
136
+ — the user reviews the file and submits it.
137
+
138
+ For feedback about this tooling itself, use
139
+ [feedback-template](references/feedback-template.md) →
140
+ `ADAPTABLE_FEEDBACK.md`: which skill and its `VERSION.md`, what the agent
141
+ did, what the user corrected, and the docs page that would have prevented it.
142
+
143
+ **Done when:** the root cause is stated with the evidence that proves it, a
144
+ source fix is applied or proposed, and verification ran or is handed over —
145
+ or a reviewed `ADAPTABLE_SUPPORT_CASE.md` / `ADAPTABLE_FEEDBACK.md` exists.
@@ -0,0 +1 @@
1
+ 0.1.0-canary.1
@@ -0,0 +1,3 @@
1
+ <!-- BEGIN:adaptable-agent-rules -->
2
+ AdapTable (`@adaptabletools/*`) is used in this project. Its Options, State shapes, API and AdapTableQL change between majors, so do not rely on recalled knowledge. Before writing or changing AdapTable code use the `adaptable-dev` skill; for first-time integration `adaptable-setup`; for a misbehaving running grid `adaptable-debug`; for version upgrades `adaptable-upgrade`. Validate State, expressions and setup with `npx -y @adaptabletools/adaptable-mcp@canary check …` (or the `check_*` MCP tools when configured); read the docs for the installed version with `npx -y @adaptabletools/adaptable-mcp@canary docs search "<topic>"`. Pure AG Grid questions go to the `ag-dev` skill or AG Grid's documentation.
3
+ <!-- END:adaptable-agent-rules -->
@@ -0,0 +1,35 @@
1
+ <!-- Generated by scripts/generate-bindings.ts from the capability registry. Do not edit; run `npm run generate`. -->
2
+
3
+ # Capabilities and their bindings
4
+
5
+ Every capability of `@adaptabletools/adaptable-mcp` (response schema 1) has a CLI command and, where listed, an MCP tool. Both run the same code and return the same envelope.
6
+
7
+ | Capability | MCP tool | CLI command | What it does |
8
+ | --- | --- | --- | --- |
9
+ | `anonymise` | — | `adaptable anonymise <file>` | Replaces the values of a State, Options, Grid Info, columns or row-data JSON with shape-preserving placeholders — names, column ids, expressions and structure kept, licence keys and user names redacted, row data scrubbed — for a support case. |
10
+ | `check-expression` | `check_expression` | `adaptable check expression <expression>` | Validates an AdapTableQL expression with the 24 engine: syntax, functions, kinds the module accepts, column references; exact rewrites for JavaScript-style operators and pre-24 syntax. |
11
+ | `migrate-expression` | `migrate_expression` | `adaptable migrate expression <expression>` | Rewrites one pre-24 AdapTableQL expression to the target major's syntax with the library's own migration (brace aggregations, named operands, legacy observable rules) and validates the result. |
12
+ | `aql-functions` | `list_expression_functions` | `adaptable aql functions` | Lists the AdapTableQL functions, aggregations, observable functions and clauses the engine accepts, with signatures, examples and docs slugs; filter by group, module or text. |
13
+ | `changes` | `list_changes` | `adaptable changes` | Lists the changes between two AdapTable majors from the release-note records; with --repo keeps the ones the project's code hits (file:line) and the ones that always apply. |
14
+ | `compat` | `get_compatibility` | `adaptable compat` | AG Grid pairing, wrapper packages and environment requirements for an AdapTable major, from the docs manifest. |
15
+ | `detect` | `detect_environment` | `adaptable detect` | Detects the AdapTable projects at or below the folder: versions, framework, AG Grid, source layout hints. |
16
+ | `convert-coldefs` | — | `adaptable convert coldefs <file>` | Turns AG Grid columnDefs into an AdapTable Layout (order, hidden columns, sizing, pinning, sorts, row groups, aggregations, pivots), lists the ColDef properties to remove with file:line, and the cellStyle / valueFormatter / valueGetter / cellRenderer snippets to re-express as Format, Calculated, Styled or Action Columns. The Layout is run through check state first. |
17
+ | `docs-list` | — | `adaptable docs list` | Lists the docs pages for the project’s AdapTable version, grouped by sidebar section: the feature index. |
18
+ | `docs-search` | `search_docs` | `adaptable docs search <query>` | Searches the docs for the project’s AdapTable version and framework; returns matching sections with slugs and URLs. |
19
+ | `docs-get` | `get_doc` | `adaptable docs get <pages...>` | Reads docs pages as Markdown for the project’s version and framework; one section with --section, demo code trimmed unless --full. |
20
+ | `docs-demos` | — | `adaptable docs demos <page>` | Lists the demos embedded in a docs page, with the files each demo owns. |
21
+ | `docs-demo` | `get_demo` | `adaptable docs demo <name>` | Returns one demo’s own files (adaptableOptions.ts by default; --files for others). Template files are never returned. |
22
+ | `migrate-state` | `migrate_state` | `adaptable migrate state <file>` | Migrates Adaptable State between majors with the library's own migration engine; reports the log, what the target major does not know (leftovers) and the check state result for the target. |
23
+ | `cache-add` | — | `adaptable cache add <spec>` | Downloads a @adaptabletools/adaptable version into the cache so checks and migrations for that major work offline. |
24
+ | `cache-list` | — | `adaptable cache list` | Shows cached library packages, bundled entries and docs corpora with sizes and ages. |
25
+ | `cache-clear` | — | `adaptable cache clear` | Removes cached docs corpora and/or library packages (with their entry bundles); everything when no flag is given. |
26
+ | `scaffold` | — | `adaptable scaffold` | Overlays the AdapTable files the docs demos run on onto a creator project (Vite or Angular CLI): columns, row data and an Initial State inferred from a CSV / JSON / XLSX file, dependencies pinned from the docs manifest, an AGENTS.md snippet. Never overwrites without --force. |
27
+ | `check-setup` | `check_setup` | `adaptable check setup` | Audits how AdapTable is wired into a project: stylesheet, required options, licence literal, version skew, AG Grid modules, column typing, direct grid use, ColDef ownership, React refs, ready hook, and the Options shape against the major’s types. |
28
+ | `check-state` | `check_state` | `adaptable check state <file>` | Validates Adaptable State (a JSON file or the literal in a .ts/.tsx/.js/.jsx/.vue file) against the checked major: shape, semantics, column references and AdapTableQL. |
29
+
30
+ ## Choosing a binding
31
+
32
+ - Prefer the MCP tool when the harness has the `adaptable` MCP server configured. Otherwise run the CLI command as `npx -y @adaptabletools/adaptable-mcp@canary <command> [options]`; add `--json` to read fields instead of Markdown.
33
+ - If neither binding exists for what you need — the capability is not in this table, not in `adaptable --capabilities`, or not in the MCP tool list — say so and fall back to the docs (see `docs-protocol.md`). Never improvise the result a missing capability would have produced.
34
+ - All bindings return the same envelope: `ok`, `data`, `issues`, `warnings`, and on failure `error { code, message, hint }`. CLI exit codes: `0` ok, `1` findings, `2` usage, `3` environment.
35
+ - Skill scripts cannot reach the agent's MCP session: a script only ever runs the CLI. When the CLI is unavailable, the agent performs the fallback itself.
@@ -0,0 +1,20 @@
1
+ # How to talk to the user
2
+
3
+ The skills mark instructions **Tell** and **Ask**; treat them literally.
4
+
5
+ - **"Tell the user X"** → show X in the conversation and continue working.
6
+ - **"Ask the user X"** → show the question and stop. Use the harness's
7
+ question tool when one exists. Do not answer your own question from context,
8
+ however obvious the answer looks — every Ask in these skills guards a choice
9
+ that is expensive to reverse (licence handling, ColDef migration, persisted
10
+ State, a package upgrade).
11
+
12
+ Phases that produce an artefact **write the file before the next phase
13
+ starts**, so a long task can be resumed from disk rather than from memory.
14
+
15
+ Never dump whole State objects, whole `getGridInfo()` results or full log
16
+ buffers into the conversation: extract the one section or the few lines the
17
+ decision needs, and keep the rest in the scratch file it was saved to.
18
+
19
+ End in plain prose: what changed, what was validated (name the check and its
20
+ result), and what remains manual. No envelope JSON in the final message.
@@ -0,0 +1,36 @@
1
+ # Reading the docs — don't guess
2
+
3
+ Training data is wrong for the installed version surprisingly often: option
4
+ names, State shapes and AdapTableQL syntax all move between majors. The docs
5
+ for the *detected* major are the source of truth, and they are one command
6
+ away. The bindings (CLI or MCP) are listed in `capabilities.md`.
7
+
8
+ ## The lookup order
9
+
10
+ 1. **Find the feature.** `docs list --section` groups every page by sidebar
11
+ section; `docs search "<topic>"` ranks matching sections. Start here —
12
+ AdapTable usually has a feature for what looks like a hand-rolled job.
13
+ 2. **Behaviour.** `docs get <handbook slug> --section "<heading>"` for how a
14
+ feature behaves; read the whole page only when the section is not obvious.
15
+ 3. **Shape.** `docs get technical-reference-<feature>` for the exact
16
+ State / Options object: property names, types, which are required.
17
+ 4. **A working example.** `docs demos <page>` lists a page's demos;
18
+ `docs demo <name>` returns the demo's own files. Adapt a demo's shape to
19
+ the project's columns rather than inventing one.
20
+ 5. **Expressions.** Before using an AdapTableQL function you are not certain
21
+ exists for the installed version, ask the engine: `aql functions --module
22
+ <Module> --query <text>` returns the name, call form and signatures the
23
+ version actually accepts.
24
+
25
+ With no shell, fetch `https://<docs host>/docs/<slug>/index.md` directly.
26
+
27
+ ## Rules
28
+
29
+ - Unfamiliar does not mean unsupported. If a page or function is absent from
30
+ the detected version's docs and catalogue, say so plainly instead of
31
+ writing it from memory.
32
+ - Before building anything from a primitive — a `valueGetter`, a custom cell
33
+ renderer, hand-rolled persisted state — check the feature index for an
34
+ AdapTable feature that already does it. Initial State, not code, is where
35
+ user-facing grid behaviour belongs.
36
+ - Cite the slug you used when reporting, so the user can read the same page.
@@ -0,0 +1,54 @@
1
+ # Grounding — do this first in every skill
2
+
3
+ AdapTable's Options, State shapes, API and AdapTableQL differ between majors,
4
+ and recalled knowledge is unreliable for any of them. Before writing, changing
5
+ or diagnosing anything, establish what is actually installed.
6
+
7
+ ## 1. Detect the project
8
+
9
+ ```bash
10
+ npx -y @adaptabletools/adaptable-mcp@canary detect --json
11
+ ```
12
+
13
+ (or the `detect_environment` MCP tool when the `adaptable` MCP server is
14
+ configured). Record from the result:
15
+
16
+ - the AdapTable major and exact version, and the paired AG Grid version,
17
+ - the framework (React, Angular, Vue or vanilla) and the wrapper package,
18
+ - the row model when one can be told (client-side vs server-side),
19
+ - every project found — in a monorepo, work in the project the task is about.
20
+
21
+ If detection reports no AdapTable (exit 3), the project either has AG Grid only
22
+ or nothing yet; the calling skill says which path to take from there.
23
+
24
+ With no shell and no MCP server, read `package.json` and the lockfile by hand —
25
+ `@adaptabletools/*` and `ag-grid-*` entries — and say in the report that the
26
+ versions were read by hand rather than detected.
27
+
28
+ ## 2. Freshness of this skill
29
+
30
+ Compare this skill's `VERSION.md` with
31
+ `https://<docs host>/.well-known/skills/VERSION` (best effort — skip silently
32
+ when it cannot be fetched). The docs host is the one `detect` resolved for the
33
+ project's major; a browser fetch or the shell both work.
34
+
35
+ - Skill older by a **minor**: tell the user, suggest
36
+ `npx skills add https://<docs host>`, then continue.
37
+ - Skill older by a **major**: tell the user to update the skill and stop —
38
+ instructions written for another major are worse than none.
39
+
40
+ One caveat on a project whose AdapTable major is not yet released (a canary
41
+ build, or a `24.x` range before the 24 release): the default docs host still
42
+ serves the current released major's docs. The symptoms are a `docs` command
43
+ failing with `DOCS_NOT_AVAILABLE`, or a warning that the docs host "is for
44
+ AdapTable N, not M". Pass `--docs-host https://<branch>.adaptabletools.com`
45
+ (or set `ADAPTABLE_MCP_DOCS_HOST`) on every command from then on so each
46
+ lookup below reads the pre-release docs.
47
+
48
+ ## 3. AG Grid siblings
49
+
50
+ Note whether the `ag-dev` and `ag-update` skills are installed. Column
51
+ definitions, AG Grid modules, row models, themes and the grid API belong to
52
+ AG Grid: hand that work to `ag-dev`, and AG Grid version bumps to `ag-update`,
53
+ rather than improvising either here. Everything that imports from
54
+ `@adaptabletools/*` stays in these skills.
@@ -0,0 +1,20 @@
1
+ # Guards — never cross these
2
+
3
+ - **No licence keys in source.** AdapTable and AG Grid keys come from
4
+ environment variables (`VITE_ADAPTABLE_LICENSE_KEY` /
5
+ `VITE_AG_GRID_LICENSE_KEY` in a Vite shell, the shell's own convention
6
+ elsewhere). A key pasted into a file, an example or a chat answer stays in
7
+ version control forever. When the user pastes a key, use it to configure the
8
+ environment file and do not echo it back.
9
+ - **Persisted State is the user's.** Never call `restoreState`, clear
10
+ `localStorage`, or change the state key (`adaptableId` / `stateKey` /
11
+ user name) without explicit confirmation in this conversation. Each of
12
+ those discards or orphans a user's saved Layouts, filters and settings.
13
+ - **Planning phases do not touch source.** A phase whose artefact is a plan
14
+ or a report writes only its own artefacts; application source changes wait
15
+ for the apply step the user approved.
16
+ - **Never echo a licence key out of a running grid.** `getGridInfo()` results
17
+ are saved with the key stripped before they are shown, attached or quoted.
18
+ - **Upgrade discovery does not read the codebase.** During an upgrade plan,
19
+ the CLI searches the code; reading whole source files defeats that and
20
+ burns context. Read a file only when a named change record points at it.
@@ -0,0 +1,42 @@
1
+ # The validation loop
2
+
3
+ Nothing AdapTable-shaped is "done" until the checker for the project's
4
+ detected major has seen it. The commands below are the CLI bindings; the MCP
5
+ tools named in `capabilities.md` return the same envelope.
6
+
7
+ ## What gets checked
8
+
9
+ - **Every AdapTableQL string** → `check expression "<expr>" --module <Module>`,
10
+ with `--columns <file>` when a columns file exists. The module matters: the
11
+ same text can be valid in one module and the wrong expression kind in
12
+ another.
13
+ - **Every State literal** (Initial State in source, or a persisted State
14
+ export) → `check state <file> [--columns <file>]`; persisted exports add
15
+ `--kind persistent`.
16
+ - **Setup and wiring** — after any change to Adaptable Options, the wrapper
17
+ components, `columnDefs` or modules → `check setup`.
18
+
19
+ ## The loop
20
+
21
+ 1. Run the check with `--json` and read `issues`, not just the exit code.
22
+ 2. Fix what it names. Each issue carries a rule id and, for the common cases,
23
+ an exact fix — apply that fix rather than a paraphrase.
24
+ 3. Re-check while the result shows `requiresAnotherCheckAfterFix`, at most
25
+ **three rounds**. If issues remain after that, stop and report the
26
+ remaining issues verbatim; do not summarise them into a false "clean".
27
+
28
+ ## Column lists
29
+
30
+ Column references are checked against a columns file: the `columnDefs` source
31
+ file, or `getColumns()` output from the running grid (debug skill) saved to a
32
+ file. Never retype a column list from memory or from the conversation — a
33
+ retyped list silently drifts from the grid it describes.
34
+
35
+ A `columnDefs` file knows the grid's own columns only. Ids that the State
36
+ defines — Calculated Columns above all — are known to `check state`, which
37
+ reads them from the literal it checks, but not to a standalone
38
+ `check expression --columns <columnDefs file>`: an `AQL_UNKNOWN_COLUMN` on a
39
+ Calculated Column id there is the missing context, not a wrong expression.
40
+ Validate such expressions through `check state` on the literal that holds
41
+ them, or pass `getColumns()` output (which lists Calculated Columns) as the
42
+ columns file.