@adaptabletools/adaptable-mcp 0.1.0-canary.0 → 0.1.0-canary.1
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/README.md +56 -61
- package/data/manifest.snapshot.json +184 -0
- package/dist/bin.js +16 -0
- package/dist/bin.js.map +1 -0
- package/dist/cli/build-commands.js +200 -0
- package/dist/cli/build-commands.js.map +1 -0
- package/dist/cli/index.js +86 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/render.js +57 -0
- package/dist/cli/render.js.map +1 -0
- package/dist/core/capabilities.js +99 -0
- package/dist/core/capabilities.js.map +1 -0
- package/dist/core/compat/capabilities.js +127 -0
- package/dist/core/compat/capabilities.js.map +1 -0
- package/dist/core/compat/manifest.js +203 -0
- package/dist/core/compat/manifest.js.map +1 -0
- package/dist/core/constants.js +38 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/context/capabilities.js +106 -0
- package/dist/core/context/capabilities.js.map +1 -0
- package/dist/core/context/detect.js +370 -0
- package/dist/core/context/detect.js.map +1 -0
- package/dist/core/context/projects.js +159 -0
- package/dist/core/context/projects.js.map +1 -0
- package/dist/core/context/resolve.js +85 -0
- package/dist/core/context/resolve.js.map +1 -0
- package/dist/core/docs/areas.js +22 -0
- package/dist/core/docs/areas.js.map +1 -0
- package/dist/core/docs/cache.js +133 -0
- package/dist/core/docs/cache.js.map +1 -0
- package/dist/core/docs/capabilities.js +381 -0
- package/dist/core/docs/capabilities.js.map +1 -0
- package/dist/core/docs/corpus.js.map +1 -0
- package/dist/core/docs/demos.js +105 -0
- package/dist/core/docs/demos.js.map +1 -0
- package/dist/core/docs/get-page.js +182 -0
- package/dist/core/docs/get-page.js.map +1 -0
- package/dist/core/docs/hosts.js +74 -0
- package/dist/core/docs/hosts.js.map +1 -0
- package/dist/core/docs/search.js.map +1 -0
- package/dist/core/envelope.js +79 -0
- package/dist/core/envelope.js.map +1 -0
- package/dist/core/index.js +13 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/packages/cache.js +138 -0
- package/dist/core/packages/cache.js.map +1 -0
- package/dist/core/packages/capabilities.js +95 -0
- package/dist/core/packages/capabilities.js.map +1 -0
- package/dist/{adaptable/types.js → core/packages/entry-types.js} +1 -1
- package/dist/core/packages/entry-types.js.map +1 -0
- package/dist/core/packages/exec.js +37 -0
- package/dist/core/packages/exec.js.map +1 -0
- package/dist/core/packages/load-entry.js +123 -0
- package/dist/core/packages/load-entry.js.map +1 -0
- package/dist/core/packages/prepare.js +122 -0
- package/dist/core/packages/prepare.js.map +1 -0
- package/dist/core/packages/registry.js +75 -0
- package/dist/core/packages/registry.js.map +1 -0
- package/dist/core/packages/resolve.js +94 -0
- package/dist/core/packages/resolve.js.map +1 -0
- package/dist/core/packages/versions.js +71 -0
- package/dist/core/packages/versions.js.map +1 -0
- package/dist/core/ping.js +22 -0
- package/dist/core/ping.js.map +1 -0
- package/dist/core/register.js +10 -0
- package/dist/core/register.js.map +1 -0
- package/dist/{checks/stateRules.js → core/state/rules.js} +29 -1
- package/dist/core/state/rules.js.map +1 -0
- package/dist/{checks/stateTypes.js → core/state/type-check.js} +1 -1
- package/dist/core/state/type-check.js.map +1 -0
- package/dist/mcp/index.js +21 -0
- package/dist/mcp/index.js.map +1 -0
- package/package.json +27 -12
- package/dist/adaptable/loadEntry.js +0 -94
- package/dist/adaptable/loadEntry.js.map +0 -1
- package/dist/adaptable/types.js.map +0 -1
- package/dist/cache.js +0 -11
- package/dist/cache.js.map +0 -1
- package/dist/checks/stateRules.js.map +0 -1
- package/dist/checks/stateTypes.js.map +0 -1
- package/dist/context.js +0 -39
- package/dist/context.js.map +0 -1
- package/dist/docs/corpus.js.map +0 -1
- package/dist/docs/search.js.map +0 -1
- package/dist/docs/source.js +0 -151
- package/dist/docs/source.js.map +0 -1
- package/dist/environment.js +0 -181
- package/dist/environment.js.map +0 -1
- package/dist/index.js +0 -7
- package/dist/index.js.map +0 -1
- package/dist/prompts.js +0 -84
- package/dist/prompts.js.map +0 -1
- package/dist/resources.js +0 -59
- package/dist/resources.js.map +0 -1
- package/dist/server.js +0 -23
- package/dist/server.js.map +0 -1
- package/dist/tools/checks.js +0 -250
- package/dist/tools/checks.js.map +0 -1
- package/dist/tools/docs.js +0 -173
- package/dist/tools/docs.js.map +0 -1
- package/dist/tools/environment.js +0 -52
- package/dist/tools/environment.js.map +0 -1
- package/skills/adaptable-dev/SKILL.md +0 -42
- /package/dist/{docs → core/docs}/corpus.js +0 -0
- /package/dist/{docs → core/docs}/search.js +0 -0
package/README.md
CHANGED
|
@@ -1,96 +1,91 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @adaptabletools/adaptable-mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
One package, two modes, for coding agents working on [AdapTable](https://www.adaptabletools.com) projects:
|
|
4
4
|
|
|
5
|
-
It
|
|
5
|
+
- **`adaptable`** — a CLI that the AdapTable Agent Skills call. It reads the docs for the AdapTable version a project actually uses, checks Initial State, AdapTableQL expressions and setup against the installed package, migrates State and expressions between majors, lists what changed between versions, and scaffolds a grid from your data.
|
|
6
|
+
- **`adaptable mcp`** — the same capabilities as an [MCP](https://modelcontextprotocol.io) server over stdio, for harnesses and chat clients that discover MCP tools better than skills, or have no shell.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
- searches the docs for that version and framework
|
|
9
|
-
- validates AdapTableQL expressions and Initial State with the installed AdapTable package
|
|
10
|
-
- migrates expressions and state from older versions
|
|
8
|
+
The agent still writes the code; this package looks things up and checks them. For AG Grid itself (column definitions, AG Grid modules, row models, grid API) use AG Grid's `ag-dev` skill or [ag-mcp](https://www.ag-grid.com/javascript-data-grid/mcp-server/) alongside it.
|
|
11
9
|
|
|
12
|
-
|
|
10
|
+
Requires Node 20+. Full guide: [getting-started-ai-cli](https://www.adaptabletools.com/docs/getting-started-ai-cli).
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
> This package is being rebuilt. The commands below describe the target contract; the published `canary` line fills them in milestone by milestone, and `adaptable --help` lists what the installed version supports.
|
|
15
13
|
|
|
16
|
-
|
|
14
|
+
## Skills first
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
Install the AdapTable Agent Skills into a project; they tell the agent when to run the CLI and how to read its output:
|
|
19
17
|
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
"mcpServers": {
|
|
23
|
-
"adaptable": {
|
|
24
|
-
"command": "npx",
|
|
25
|
-
"args": ["-y", "@adaptabletools/adaptable-mcp"]
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
18
|
+
```bash
|
|
19
|
+
npx skills add https://www.adaptabletools.com
|
|
29
20
|
```
|
|
30
21
|
|
|
31
|
-
|
|
22
|
+
Nothing else is required: the skills invoke `npx -y @adaptabletools/adaptable-mcp@^1 …` on demand.
|
|
23
|
+
|
|
24
|
+
## The CLI
|
|
32
25
|
|
|
33
26
|
```bash
|
|
34
|
-
|
|
27
|
+
npx -y @adaptabletools/adaptable-mcp@^1 <command> [options]
|
|
35
28
|
```
|
|
36
29
|
|
|
37
|
-
|
|
30
|
+
| Command | What it does |
|
|
31
|
+
| --- | --- |
|
|
32
|
+
| `detect` | AdapTable and AG Grid packages, framework, compatibility of the project |
|
|
33
|
+
| `compat --adaptable <major>` | AG Grid pairing, wrapper versions and environment requirements for a major |
|
|
34
|
+
| `docs list\|search\|get\|demos\|demo` | The docs for the project's version and framework, as Markdown |
|
|
35
|
+
| `check state\|expression\|setup` | Initial State, AdapTableQL expressions and Adaptable Options against the installed package |
|
|
36
|
+
| `aql functions` | The AdapTableQL function catalogue, per module |
|
|
37
|
+
| `migrate state\|expression` | From an older major to a newer one, with leftovers reported |
|
|
38
|
+
| `changes --from <major> --to <major>` | What changed between two majors, grepped against the project |
|
|
39
|
+
| `convert coldefs` | AG Grid `columnDefs` → AdapTable Layout and Format Columns |
|
|
40
|
+
| `scaffold` | A new grid project from a CSV / JSON / XLSX sample |
|
|
41
|
+
| `anonymise` | Strip values from a State or Grid Info before sharing it |
|
|
42
|
+
| `cache add\|list\|clear` | Download a major's package for offline use |
|
|
43
|
+
|
|
44
|
+
Global flags: `--cwd <dir>`, `--major <n>`, `--framework <fw>`, `--offline`, `--quiet`, `--json`, `--docs-host <url>`. Output is Markdown by default; `--json` returns a stable envelope. Exit codes: `0` ok · `1` findings · `2` usage · `3` environment.
|
|
45
|
+
|
|
46
|
+
Install it as a devDependency for restricted networks, cold-start avoidance and CI:
|
|
38
47
|
|
|
39
|
-
|
|
48
|
+
```bash
|
|
49
|
+
npm i -D @adaptabletools/adaptable-mcp
|
|
50
|
+
npx adaptable cache add 24 # for machines without registry access later
|
|
51
|
+
```
|
|
40
52
|
|
|
41
|
-
|
|
42
|
-
| --- | --- |
|
|
43
|
-
| `detect_environment` | AdapTable and AG Grid packages, framework, peer range, documented AG Grid pairing, warnings |
|
|
44
|
-
| `search_docs` | Docs sections for the project's version and framework, with URLs |
|
|
45
|
-
| `get_doc` | One docs page (or one section of it) as markdown |
|
|
46
|
-
| `check_expression` | Validates an AdapTableQL expression: syntax, functions, types, aggregation rules, the functions its Module offers, columns |
|
|
47
|
-
| `migrate_expression` | Rewrites a pre-v24 expression to v24 syntax |
|
|
48
|
-
| `list_expression_functions` | Built-in AdapTableQL functions with signatures and examples |
|
|
49
|
-
| `check_state` | Initial State: type check against the installed `InitialState`, pre-v24 shapes, Layouts, column references, embedded expressions |
|
|
50
|
-
| `migrate_state` | Upgrades state from an older major version (`AdaptableUpgradeHelper`) |
|
|
53
|
+
## The MCP server
|
|
51
54
|
|
|
52
|
-
|
|
55
|
+
Point an MCP client at the same binary with the `mcp` argument (without it the binary prints help and exits):
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"mcpServers": {
|
|
60
|
+
"adaptable": { "command": "npx", "args": ["-y", "@adaptabletools/adaptable-mcp@^1", "mcp"] }
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
53
64
|
|
|
54
|
-
|
|
65
|
+
Cursor reads this from `.cursor/mcp.json`, Claude Code from `.mcp.json`; Codex takes the equivalent `[mcp_servers.adaptable]` block in `~/.codex/config.toml`. The server exposes the checking, docs and migration capabilities as tools with the same results as the CLI's `--json` output.
|
|
55
66
|
|
|
56
67
|
## How it works
|
|
57
68
|
|
|
58
|
-
- Docs come from the build-time export of the docs site
|
|
59
|
-
- Checks use the
|
|
69
|
+
- Docs come from the build-time export of the docs site (`/llms/manifest.json`, `pages.json`, one `.md` per page, the demos index), re-validated with a conditional request on every call and cached under `~/.cache/adaptable-mcp/`.
|
|
70
|
+
- Checks and migrations use the installed `@adaptabletools/adaptable` where the project has one, otherwise a cached copy of the right major; nothing is bundled from an older version of AdapTable's types.
|
|
71
|
+
- No telemetry; the only writer is `scaffold --out`.
|
|
60
72
|
|
|
61
73
|
## Environment variables
|
|
62
74
|
|
|
63
75
|
| Variable | Default | Use |
|
|
64
76
|
| --- | --- | --- |
|
|
65
|
-
| `
|
|
66
|
-
| `
|
|
67
|
-
| `
|
|
68
|
-
| `ADAPTABLE_MCP_ADAPTABLE_SRC` | | AdapTable source folder (`packages/adaptable`) instead of the installed package |
|
|
69
|
-
| `ADAPTABLE_MCP_CACHE_DIR` | `~/.cache/adaptable-mcp` | Cache for docs and bundled entries |
|
|
77
|
+
| `ADAPTABLE_MCP_CACHE_DIR` | `$XDG_CACHE_HOME/adaptable-mcp` or `~/.cache/adaptable-mcp` | Cache for docs, packages and bundled entries |
|
|
78
|
+
| `ADAPTABLE_MCP_DOCS_HOST` | matched docs site | Docs site to read instead of the default one |
|
|
79
|
+
| `ADAPTABLE_MCP_ADAPTABLE_SRC` | | AdapTable source folder (`packages/adaptable`) instead of the installed package (development) |
|
|
70
80
|
|
|
71
81
|
## Development
|
|
72
82
|
|
|
73
83
|
```bash
|
|
74
84
|
npm install
|
|
75
85
|
npm run build
|
|
86
|
+
npm run lint
|
|
76
87
|
npm test
|
|
77
|
-
npm run inspect # MCP Inspector
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
### Eval
|
|
81
|
-
|
|
82
|
-
`eval/tasks.json` holds the eval tasks: setup per framework, AdapTableQL, state, option placement and upgrades. `eval/grade.mjs` grades a folder of answers (`<task-id>.md`), checking expressions and Initial State (including the type check) with the same code as the tools.
|
|
83
|
-
|
|
84
|
-
`npm test` checks the checks in both directions: every Initial State in the docs demos must pass `check_state` (`test/docsExamples.test.mjs`; known docs issues are listed there until the demos are fixed), and every answer in `eval/known-wrong` (stale answers from a run without the MCP) must fail grading.
|
|
85
|
-
|
|
86
|
-
Eval runs write their answers to `eval/results/<run>/` (gitignored):
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
node eval/grade.mjs eval/results/baseline
|
|
88
|
+
npm run inspect # MCP Inspector against dist/bin.js mcp
|
|
90
89
|
```
|
|
91
90
|
|
|
92
|
-
`
|
|
93
|
-
|
|
94
|
-
```bash
|
|
95
|
-
ADAPTABLE_MCP_PROJECT=eval/fixture node eval/mcp-call.mjs search_docs '{"query":"pivot layout"}'
|
|
96
|
-
```
|
|
91
|
+
Tests that exercise the AdapTable engine bundle `packages/adaptable/{aql,upgrade}.ts` from source, so build `packages/aql` and install `packages/adaptable`'s dependencies first. The layout, the boundary rule between `src/core` and the two transports, and the task list are in `design_docs/ai-tooling-v2/`.
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schemaVersion": 2,
|
|
3
|
+
"adaptableVersion": "24.0.0-canary.8",
|
|
4
|
+
"major": 24,
|
|
5
|
+
"agGridPeer": ">=36.2.0",
|
|
6
|
+
"agGridPairings": [
|
|
7
|
+
{
|
|
8
|
+
"adaptableVersion": "24",
|
|
9
|
+
"agGridMajor": 36,
|
|
10
|
+
"agGridVersion": "36.2.0"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"adaptableVersion": "23.1",
|
|
14
|
+
"agGridMajor": 36,
|
|
15
|
+
"agGridVersion": "36.2.0"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"adaptableVersion": "22",
|
|
19
|
+
"agGridMajor": 35,
|
|
20
|
+
"agGridVersion": "35.0.0"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"adaptableVersion": "21",
|
|
24
|
+
"agGridMajor": 34,
|
|
25
|
+
"agGridVersion": "34.0.0"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"adaptableVersion": "20",
|
|
29
|
+
"agGridMajor": 33,
|
|
30
|
+
"agGridVersion": "33.0.0"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"adaptableVersion": "19",
|
|
34
|
+
"agGridMajor": 32,
|
|
35
|
+
"agGridVersion": "32.1.0"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"adaptableVersion": "18",
|
|
39
|
+
"agGridMajor": 31,
|
|
40
|
+
"agGridVersion": "31.0.0"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"adaptableVersion": "16",
|
|
44
|
+
"agGridMajor": 30,
|
|
45
|
+
"agGridVersion": "30.0.0"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"adaptableVersion": "15",
|
|
49
|
+
"agGridMajor": 29,
|
|
50
|
+
"agGridVersion": "29.0.0"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"adaptableVersion": "13",
|
|
54
|
+
"agGridMajor": 28,
|
|
55
|
+
"agGridVersion": "28.1.0"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"adaptableVersion": "11",
|
|
59
|
+
"agGridMajor": 27,
|
|
60
|
+
"agGridVersion": "27.0.0"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"adaptableVersion": "10",
|
|
64
|
+
"agGridMajor": 26,
|
|
65
|
+
"agGridVersion": "26.0.0"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"adaptableVersion": "9",
|
|
69
|
+
"agGridMajor": 25,
|
|
70
|
+
"agGridVersion": "25.3.0"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"adaptableVersion": "8",
|
|
74
|
+
"agGridMajor": 24,
|
|
75
|
+
"agGridVersion": "24.1.0"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"adaptableVersion": "7.1",
|
|
79
|
+
"agGridMajor": 23,
|
|
80
|
+
"agGridVersion": "23.0.0"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"adaptableVersion": "7",
|
|
84
|
+
"agGridMajor": 22,
|
|
85
|
+
"agGridVersion": "22.0.0"
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
"environment": {
|
|
89
|
+
"21": {
|
|
90
|
+
"node": ">=18",
|
|
91
|
+
"typescript": ">=5.4",
|
|
92
|
+
"react": ">=18",
|
|
93
|
+
"angular": ">=17.3",
|
|
94
|
+
"vue": ">=3"
|
|
95
|
+
},
|
|
96
|
+
"22": {
|
|
97
|
+
"node": ">=18",
|
|
98
|
+
"typescript": ">=5.5",
|
|
99
|
+
"react": ">=18",
|
|
100
|
+
"angular": ">=18.2.14",
|
|
101
|
+
"vue": ">=3"
|
|
102
|
+
},
|
|
103
|
+
"23": {
|
|
104
|
+
"node": ">=20",
|
|
105
|
+
"typescript": ">=5.5.4",
|
|
106
|
+
"react": ">=18",
|
|
107
|
+
"angular": ">=20",
|
|
108
|
+
"vue": ">=3"
|
|
109
|
+
},
|
|
110
|
+
"24": {
|
|
111
|
+
"node": ">=20",
|
|
112
|
+
"typescript": ">=5.5.4",
|
|
113
|
+
"react": ">=18",
|
|
114
|
+
"angular": ">=20",
|
|
115
|
+
"vue": ">=3"
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
"wrappers": {
|
|
119
|
+
"21": {
|
|
120
|
+
"react": "@adaptabletools/adaptable-react-aggrid",
|
|
121
|
+
"angular": "@adaptabletools/adaptable-angular-aggrid",
|
|
122
|
+
"vue": "@adaptabletools/adaptable-vue3-aggrid"
|
|
123
|
+
},
|
|
124
|
+
"22": {
|
|
125
|
+
"react": "@adaptabletools/adaptable-react-aggrid",
|
|
126
|
+
"angular": "@adaptabletools/adaptable-angular-aggrid",
|
|
127
|
+
"vue": "@adaptabletools/adaptable-vue3-aggrid"
|
|
128
|
+
},
|
|
129
|
+
"23": {
|
|
130
|
+
"react": "@adaptabletools/adaptable-react-aggrid",
|
|
131
|
+
"angular": "@adaptabletools/adaptable-angular-aggrid",
|
|
132
|
+
"vue": "@adaptabletools/adaptable-vue3-aggrid"
|
|
133
|
+
},
|
|
134
|
+
"24": {
|
|
135
|
+
"react": "@adaptabletools/adaptable-react-aggrid",
|
|
136
|
+
"angular": "@adaptabletools/adaptable-angular-aggrid",
|
|
137
|
+
"vue": "@adaptabletools/adaptable-vue3-aggrid"
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
"docsHosts": {
|
|
141
|
+
"21": "https://v21.adaptabletools.com",
|
|
142
|
+
"22": "https://v22.adaptabletools.com",
|
|
143
|
+
"23": "https://v23.adaptabletools.com",
|
|
144
|
+
"24": "https://www.adaptabletools.com"
|
|
145
|
+
},
|
|
146
|
+
"latest": {
|
|
147
|
+
"adaptableMajor": 24,
|
|
148
|
+
"requiredAgGrid": ">=36.2.0"
|
|
149
|
+
},
|
|
150
|
+
"cli": {
|
|
151
|
+
"minVersion": "1.0.0"
|
|
152
|
+
},
|
|
153
|
+
"frameworks": [
|
|
154
|
+
"vanilla",
|
|
155
|
+
"react",
|
|
156
|
+
"angular",
|
|
157
|
+
"vue"
|
|
158
|
+
],
|
|
159
|
+
"baseUrl": "https://www.adaptabletools.com",
|
|
160
|
+
"builtAt": "2026-10-27T16:05:29.588Z",
|
|
161
|
+
"pageCount": 1195,
|
|
162
|
+
"files": {
|
|
163
|
+
"llmsTxt": {
|
|
164
|
+
"path": "/llms.txt",
|
|
165
|
+
"bytes": 122625,
|
|
166
|
+
"sha256": "4cae31d372353235cbcdf537c2d5275549017dfd899319fe39db19ac9f234b08"
|
|
167
|
+
},
|
|
168
|
+
"llmsFullTxt": {
|
|
169
|
+
"path": "/llms-full.txt",
|
|
170
|
+
"bytes": 25094299,
|
|
171
|
+
"sha256": "0279065daf3e462a46f1aaafbb99a0926b51580536ebdb48726760999f0a2370"
|
|
172
|
+
},
|
|
173
|
+
"pages": {
|
|
174
|
+
"path": "/llms/pages.json",
|
|
175
|
+
"bytes": 469761,
|
|
176
|
+
"sha256": "b0ee72b33e92f636ece17005e641fca54562e37add4dfcc6155413a27459cbf9"
|
|
177
|
+
},
|
|
178
|
+
"demos": {
|
|
179
|
+
"path": "/llms/demos.json",
|
|
180
|
+
"bytes": 224096,
|
|
181
|
+
"sha256": "003e62cafe8424ecdd65d28f94e6a22d410096b4b7fcf1d60208e7caf32a5bbc"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// argv → `mcp` → src/mcp, else → src/cli (plan §5). Bare `adaptable` prints help;
|
|
3
|
+
// it never starts the MCP server implicitly (plan §7.1).
|
|
4
|
+
import { runCli } from './cli/index.js';
|
|
5
|
+
import { runMcp } from './mcp/index.js';
|
|
6
|
+
const argv = process.argv.slice(2);
|
|
7
|
+
const io = {
|
|
8
|
+
stdout: (text) => {
|
|
9
|
+
process.stdout.write(text);
|
|
10
|
+
},
|
|
11
|
+
stderr: (text) => {
|
|
12
|
+
process.stderr.write(text);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
process.exitCode = argv[0] === 'mcp' ? await runMcp(argv.slice(1), io) : await runCli(argv, io);
|
|
16
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,kFAAkF;AAClF,yDAAyD;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnC,MAAM,EAAE,GAAG;IACT,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;QACvB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IACD,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;QACvB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;CACF,CAAC;AAEF,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,MAAM,MAAM,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registry → commander tree (plan §6.1, §7.1). Every command, positional and
|
|
3
|
+
* option is derived from the capabilities' zod schemas, so the CLI, the MCP
|
|
4
|
+
* tools and `--help --json` cannot drift from each other.
|
|
5
|
+
*/
|
|
6
|
+
import { Command, InvalidArgumentError, Option } from 'commander';
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { CLI_PACKAGE, CLI_RANGE, CLI_VERSION, SCHEMA_VERSION, listCapabilities, } from '../core/index.js';
|
|
9
|
+
/** Global flags (plan §7.1); `--json` and `--quiet` are rendering flags the CLI owns */
|
|
10
|
+
export const GLOBAL_FLAGS = [
|
|
11
|
+
['--cwd <dir>', 'Project folder; defaults to the current directory'],
|
|
12
|
+
['--major <n>', 'AdapTable major to assume instead of detecting it'],
|
|
13
|
+
['--framework <fw>', 'Framework to assume instead of detecting it (vanilla, react, angular, vue)'],
|
|
14
|
+
['--offline', 'Never touch the network; use caches and bundled snapshots'],
|
|
15
|
+
['--quiet', 'Markdown output without warnings and info issues'],
|
|
16
|
+
['--json', 'Print the response envelope as JSON'],
|
|
17
|
+
['--docs-host <url>', 'Docs host to read instead of the default one'],
|
|
18
|
+
];
|
|
19
|
+
export const GLOBAL_KEYS = ['cwd', 'major', 'framework', 'offline', 'quiet', 'json', 'docsHost'];
|
|
20
|
+
export function inputJsonSchema(schema) {
|
|
21
|
+
return z.toJSONSchema(schema, { io: 'input', unrepresentable: 'any' });
|
|
22
|
+
}
|
|
23
|
+
export function outputJsonSchema(schema) {
|
|
24
|
+
return z.toJSONSchema(schema, { io: 'output', unrepresentable: 'any' });
|
|
25
|
+
}
|
|
26
|
+
const kebab = (name) => name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
27
|
+
function propertyType(prop) {
|
|
28
|
+
if (prop.anyOf) {
|
|
29
|
+
const types = prop.anyOf.map(propertyType).filter((t) => t && t !== 'null');
|
|
30
|
+
return types[0];
|
|
31
|
+
}
|
|
32
|
+
return Array.isArray(prop.type) ? prop.type.find((t) => t !== 'null') : prop.type;
|
|
33
|
+
}
|
|
34
|
+
function parseNumber(value) {
|
|
35
|
+
const number = Number(value);
|
|
36
|
+
if (!Number.isFinite(number) || value.trim() === '') {
|
|
37
|
+
throw new InvalidArgumentError('Expected a number.');
|
|
38
|
+
}
|
|
39
|
+
return number;
|
|
40
|
+
}
|
|
41
|
+
function parseJson(value) {
|
|
42
|
+
try {
|
|
43
|
+
return JSON.parse(value);
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
throw new InvalidArgumentError('Expected JSON.');
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function parserFor(prop) {
|
|
50
|
+
switch (propertyType(prop)) {
|
|
51
|
+
case 'number':
|
|
52
|
+
case 'integer':
|
|
53
|
+
return parseNumber;
|
|
54
|
+
case 'object':
|
|
55
|
+
return parseJson;
|
|
56
|
+
default:
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/** Adds the capability's positionals and options to a leaf command */
|
|
61
|
+
function bindInput(command, capability) {
|
|
62
|
+
const schema = inputJsonSchema(capability.input);
|
|
63
|
+
const properties = schema.properties ?? {};
|
|
64
|
+
const required = new Set(schema.required ?? []);
|
|
65
|
+
const positionals = capability.cli.positionals ?? [];
|
|
66
|
+
positionals.forEach((field, index) => {
|
|
67
|
+
const prop = properties[field] ?? {};
|
|
68
|
+
const variadic = propertyType(prop) === 'array';
|
|
69
|
+
if (variadic && index !== positionals.length - 1) {
|
|
70
|
+
throw new Error(`Capability "${capability.name}": only the last positional ("${field}") may be an array.`);
|
|
71
|
+
}
|
|
72
|
+
const parser = parserFor(variadic && prop.items ? prop.items : prop);
|
|
73
|
+
const name = `${required.has(field) ? '<' : '['}${field}${variadic ? '...' : ''}${required.has(field) ? '>' : ']'}`;
|
|
74
|
+
if (parser && variadic) {
|
|
75
|
+
command.argument(name, prop.description ?? '', (value, previous = []) => [...previous, parser(value)]);
|
|
76
|
+
}
|
|
77
|
+
else if (parser) {
|
|
78
|
+
command.argument(name, prop.description ?? '', parser);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
command.argument(name, prop.description ?? '');
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
for (const [field, prop] of Object.entries(properties)) {
|
|
85
|
+
if (positionals.includes(field)) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const flag = `--${kebab(field)}`;
|
|
89
|
+
const type = propertyType(prop);
|
|
90
|
+
const description = prop.description ?? '';
|
|
91
|
+
if (type === 'boolean') {
|
|
92
|
+
command.addOption(new Option(flag, description));
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
const value = type === 'array' ? `<${field}...>` : `<${field}>`;
|
|
96
|
+
const option = new Option(`${flag} ${value}`, description);
|
|
97
|
+
if (prop.enum?.every((v) => typeof v === 'string')) {
|
|
98
|
+
option.choices(prop.enum);
|
|
99
|
+
}
|
|
100
|
+
const parser = parserFor(type === 'array' && prop.items ? prop.items : prop);
|
|
101
|
+
if (parser && type === 'array') {
|
|
102
|
+
option.argParser((value, previous = []) => [...previous, parser(value)]);
|
|
103
|
+
}
|
|
104
|
+
else if (parser) {
|
|
105
|
+
option.argParser(parser);
|
|
106
|
+
}
|
|
107
|
+
if (required.has(field)) {
|
|
108
|
+
option.makeOptionMandatory();
|
|
109
|
+
}
|
|
110
|
+
command.addOption(option);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function groupCommand(parent, word) {
|
|
114
|
+
const existing = parent.commands.find((c) => c.name() === word);
|
|
115
|
+
if (existing) {
|
|
116
|
+
return existing;
|
|
117
|
+
}
|
|
118
|
+
const group = parent.command(word).description(`${word} commands`);
|
|
119
|
+
group.copyInheritedSettings(parent);
|
|
120
|
+
return group;
|
|
121
|
+
}
|
|
122
|
+
/** The commander program for the current registry */
|
|
123
|
+
export function buildProgram(options) {
|
|
124
|
+
const program = new Command('adaptable')
|
|
125
|
+
.description('AdapTable CLI for coding agents: version-matched docs, State and AdapTableQL checks, migration, scaffolding')
|
|
126
|
+
.version(CLI_VERSION, '-v, --version', 'Print the CLI version')
|
|
127
|
+
.option('--capabilities', 'List the capabilities this version supports')
|
|
128
|
+
.exitOverride()
|
|
129
|
+
.configureOutput({ writeOut: options.writeOut, writeErr: options.writeErr })
|
|
130
|
+
.showHelpAfterError('(add --help for usage; --help --json prints the full contract)')
|
|
131
|
+
.addHelpText('after', `\nPackage: ${CLI_PACKAGE}@${CLI_RANGE} · schema ${SCHEMA_VERSION} · \`adaptable mcp\` starts the MCP server`);
|
|
132
|
+
for (const [flags, description] of GLOBAL_FLAGS) {
|
|
133
|
+
program.option(flags, description);
|
|
134
|
+
}
|
|
135
|
+
for (const capability of listCapabilities({ includeHidden: true })) {
|
|
136
|
+
const words = capability.cli.command;
|
|
137
|
+
let parent = program;
|
|
138
|
+
for (const word of words.slice(0, -1)) {
|
|
139
|
+
parent = groupCommand(parent, word);
|
|
140
|
+
}
|
|
141
|
+
const leaf = parent
|
|
142
|
+
.command(words[words.length - 1], { hidden: capability.hidden })
|
|
143
|
+
.description(capability.description);
|
|
144
|
+
leaf.copyInheritedSettings(parent);
|
|
145
|
+
bindInput(leaf, capability);
|
|
146
|
+
leaf.action(async (...args) => {
|
|
147
|
+
const command = args[args.length - 1];
|
|
148
|
+
const leafOptions = args[args.length - 2];
|
|
149
|
+
const positionalValues = args.slice(0, -2);
|
|
150
|
+
const input = {};
|
|
151
|
+
(capability.cli.positionals ?? []).forEach((field, i) => {
|
|
152
|
+
if (positionalValues[i] !== undefined) {
|
|
153
|
+
input[field] = positionalValues[i];
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
for (const [key, value] of Object.entries(leafOptions)) {
|
|
157
|
+
if (value !== undefined) {
|
|
158
|
+
input[key] = value;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
const all = command.optsWithGlobals();
|
|
162
|
+
const globals = {};
|
|
163
|
+
for (const key of GLOBAL_KEYS) {
|
|
164
|
+
if (all[key] !== undefined) {
|
|
165
|
+
globals[key] = key === 'major' ? parseNumber(String(all[key])) : all[key];
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
await options.onInvoke({ capability, input, globals });
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return program;
|
|
172
|
+
}
|
|
173
|
+
/** `adaptable --help --json`: the full contract, used by the docs command-reference page */
|
|
174
|
+
export function helpContract() {
|
|
175
|
+
return {
|
|
176
|
+
cliVersion: CLI_VERSION,
|
|
177
|
+
schemaVersion: SCHEMA_VERSION,
|
|
178
|
+
package: CLI_PACKAGE,
|
|
179
|
+
range: CLI_RANGE,
|
|
180
|
+
globalOptions: GLOBAL_FLAGS.map(([flags, description]) => ({ flags, description })),
|
|
181
|
+
exitCodes: { 0: 'ok / no findings', 1: 'findings', 2: 'usage', 3: 'environment' },
|
|
182
|
+
capabilities: listCapabilities().map((capability) => ({
|
|
183
|
+
name: capability.name,
|
|
184
|
+
description: capability.description,
|
|
185
|
+
cli: capability.cli,
|
|
186
|
+
mcp: capability.mcp,
|
|
187
|
+
input: inputJsonSchema(capability.input),
|
|
188
|
+
output: outputJsonSchema(capability.output),
|
|
189
|
+
})),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
/** `adaptable --capabilities`: what this version supports, for skills that must not improvise a missing capability */
|
|
193
|
+
export function capabilitiesReport() {
|
|
194
|
+
return {
|
|
195
|
+
cliVersion: CLI_VERSION,
|
|
196
|
+
schemaVersion: SCHEMA_VERSION,
|
|
197
|
+
capabilities: listCapabilities().map(({ name, cli, mcp }) => ({ name, cli, mcp })),
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
//# sourceMappingURL=build-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-commands.js","sourceRoot":"","sources":["../../src/cli/build-commands.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAClE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,WAAW,EACX,SAAS,EACT,WAAW,EACX,cAAc,EACd,gBAAgB,GAGjB,MAAM,kBAAkB,CAAC;AAE1B,wFAAwF;AACxF,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,CAAC,aAAa,EAAE,mDAAmD,CAAC;IACpE,CAAC,aAAa,EAAE,mDAAmD,CAAC;IACpE,CAAC,kBAAkB,EAAE,4EAA4E,CAAC;IAClG,CAAC,WAAW,EAAE,2DAA2D,CAAC;IAC1E,CAAC,SAAS,EAAE,kDAAkD,CAAC;IAC/D,CAAC,QAAQ,EAAE,qCAAqC,CAAC;IACjD,CAAC,mBAAmB,EAAE,8CAA8C,CAAC;CAC7D,CAAC;AAOX,MAAM,CAAC,MAAM,WAAW,GAAyB,CAAC,KAAK,EAAE,O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AE,CAAC,EAAE,aAAa,EAAE;QACjF,YAAY,EAAE,gBAAgB,EAAE,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YACpD,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,WAAW,EAAE,UAAU,CAAC,WAAW;YACnC,GAAG,EAAE,UAAU,CAAC,GAAG;YACnB,GAAG,EAAE,UAAU,CAAC,GAAG;YACnB,KAAK,EAAE,eAAe,CAAC,UAAU,CAAC,KAAK,CAAC;YACxC,MAAM,EAAE,gBAAgB,CAAC,UAAU,CAAC,MAAM,CAAC;SAC5C,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAED,sHAAsH;AACtH,MAAM,UAAU,kBAAkB;IAKhC,OAAO;QACL,UAAU,EAAE,WAAW;QACvB,aAAa,EAAE,cAAc;QAC7B,YAAY,EAAE,gBAAgB,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC;KACnF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI entry: parses argv with the generated commander tree, runs the capability
|
|
3
|
+
* through core, renders the envelope and returns the exit code (plan §7.1).
|
|
4
|
+
* Writes only through `io`, so tests run it in-process.
|
|
5
|
+
*/
|
|
6
|
+
import { CommanderError } from 'commander';
|
|
7
|
+
import { exitCodeFor, runCapability } from '../core/index.js';
|
|
8
|
+
import { buildProgram, capabilitiesReport, helpContract } from './build-commands.js';
|
|
9
|
+
import { renderEnvelope } from './render.js';
|
|
10
|
+
const usageEnvelope = (message, hint) => ({
|
|
11
|
+
schemaVersion: 1,
|
|
12
|
+
ok: false,
|
|
13
|
+
error: { code: 'USAGE', message, hint },
|
|
14
|
+
});
|
|
15
|
+
function emit(io, envelope, globals, capability) {
|
|
16
|
+
const text = renderEnvelope(envelope, { json: globals.json, quiet: globals.quiet, capability });
|
|
17
|
+
if (globals.json || envelope.ok) {
|
|
18
|
+
io.stdout(text);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
io.stderr(text);
|
|
22
|
+
}
|
|
23
|
+
return exitCodeFor(envelope);
|
|
24
|
+
}
|
|
25
|
+
function capabilitiesMarkdown() {
|
|
26
|
+
const report = capabilitiesReport();
|
|
27
|
+
const rows = report.capabilities.map((c) => `| \`${c.name}\` | \`adaptable ${c.cli.command.join(' ')}\` | ${c.mcp ? `\`${c.mcp.tool}\`` : '—'} |`);
|
|
28
|
+
return [
|
|
29
|
+
`adaptable ${report.cliVersion} · schema ${report.schemaVersion}`,
|
|
30
|
+
'',
|
|
31
|
+
'| Capability | CLI | MCP tool |',
|
|
32
|
+
'| --- | --- | --- |',
|
|
33
|
+
...rows,
|
|
34
|
+
'',
|
|
35
|
+
].join('\n');
|
|
36
|
+
}
|
|
37
|
+
/** Runs the CLI for `argv` (without node and script) and returns the exit code */
|
|
38
|
+
export async function runCli(argv, io) {
|
|
39
|
+
const wantsJson = argv.includes('--json');
|
|
40
|
+
if (argv.includes('--help') && wantsJson) {
|
|
41
|
+
io.stdout(`${JSON.stringify(helpContract(), null, 2)}\n`);
|
|
42
|
+
return 0;
|
|
43
|
+
}
|
|
44
|
+
if (argv.includes('--capabilities')) {
|
|
45
|
+
io.stdout(wantsJson ? `${JSON.stringify(capabilitiesReport(), null, 2)}\n` : capabilitiesMarkdown());
|
|
46
|
+
return 0;
|
|
47
|
+
}
|
|
48
|
+
let exitCode = 0;
|
|
49
|
+
const program = buildProgram({
|
|
50
|
+
writeOut: io.stdout,
|
|
51
|
+
writeErr: io.stderr,
|
|
52
|
+
onInvoke: async ({ capability, input, globals }) => {
|
|
53
|
+
const envelope = await runCapability(capability.name, input, {
|
|
54
|
+
cwd: globals.cwd,
|
|
55
|
+
major: globals.major,
|
|
56
|
+
framework: globals.framework,
|
|
57
|
+
offline: globals.offline,
|
|
58
|
+
docsHost: globals.docsHost,
|
|
59
|
+
});
|
|
60
|
+
exitCode = emit(io, envelope, globals, capability);
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
if (!argv.length) {
|
|
64
|
+
io.stdout(program.helpInformation());
|
|
65
|
+
return 0;
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
await program.parseAsync(argv, { from: 'user' });
|
|
69
|
+
return exitCode;
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
if (error instanceof CommanderError) {
|
|
73
|
+
if (error.code === 'commander.helpDisplayed' || error.code === 'commander.version' || error.code === 'commander.help') {
|
|
74
|
+
return 0;
|
|
75
|
+
}
|
|
76
|
+
if (wantsJson) {
|
|
77
|
+
io.stdout(renderEnvelope(usageEnvelope(error.message.trim(), 'Run `adaptable --help` or `adaptable --help --json`.'), {
|
|
78
|
+
json: true,
|
|
79
|
+
}));
|
|
80
|
+
}
|
|
81
|
+
return 2;
|
|
82
|
+
}
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=index.js.map
|