suppa-mcp-2 1.42.5 → 1.43.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 (81) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +4 -2
  3. package/dist/httpClient.js +2 -2
  4. package/dist/server.js +126 -48
  5. package/dist/toolTable.js +2 -2
  6. package/dist/tools/automation.js +150 -24
  7. package/dist/tools/docs.js +5 -1
  8. package/dist/tools/entity.js +68 -0
  9. package/dist/tools/formLifecycle.js +103 -13
  10. package/dist/tools/formV2.js +297 -15
  11. package/dist/tools/migrate.js +1 -1
  12. package/dist/tools/query.js +129 -50
  13. package/dist/tools/queryAnalyze.js +617 -0
  14. package/dist/tools/sqlKb.js +324 -0
  15. package/dist/tools/tasks.js +12 -2
  16. package/dist/utils.js +10 -3
  17. package/dist/version.js +24 -0
  18. package/package.json +7 -1
  19. package/skills/suppa-cli/SKILL.md +1 -1
  20. package/skills/suppa-entity-code/SKILL.md +55 -17
  21. package/skills/suppa-entity-code/references/enforcement.md +1 -1
  22. package/skills/suppa-entity-code/references/entities.md +11 -7
  23. package/skills/suppa-entity-code/references/form-seeds.md +106 -0
  24. package/skills/suppa-entity-code/references/permission-seeds.md +122 -0
  25. package/skills/suppa-entity-code/references/registration.md +276 -274
  26. package/skills/suppa-entity-code/references/runtime.md +72 -9
  27. package/skills/suppa-entity-code/references/seeds.md +182 -173
  28. package/skills/suppa-entity-code/references/v1-mapping.md +102 -102
  29. package/skills/suppa-entity-code/scripts/house-rules.mjs +11 -5
  30. package/skills/suppa-entity-code/scripts/validate-suppa-schema.mjs +613 -40
  31. package/skills/suppa-entity-code/templates/AGENTS.entity-code.md +6 -4
  32. package/skills/suppa-entity-code/templates/entity-extension.template.ts +1 -1
  33. package/skills/suppa-entity-code/templates/entity.template.ts +130 -126
  34. package/skills/suppa-entity-code/templates/seed.template.ts +57 -61
  35. package/skills/suppa-entity-code/templates/tabular-part.template.ts +101 -101
  36. package/skills/suppa-form-v2/CARD_KIT.json +53 -0
  37. package/skills/suppa-form-v2/CELL_RULES.json +31 -0
  38. package/skills/suppa-form-v2/SKILL.md +71 -57
  39. package/skills/suppa-form-v2/SOURCE.json +4 -4
  40. package/skills/suppa-form-v2/assets/card-kit/form-639.json +8877 -0
  41. package/skills/suppa-form-v2/data/base-props.json +12 -0
  42. package/skills/suppa-form-v2/data/cell-widget-rules.fixtures.json +299 -0
  43. package/skills/suppa-form-v2/data/component-index.json +7 -19
  44. package/skills/suppa-form-v2/data/component-props.json +331 -51
  45. package/skills/suppa-form-v2/data/templates/entity-workspace.json +11 -0
  46. package/skills/suppa-form-v2/data/templates/hero-registration.json +1 -0
  47. package/skills/suppa-form-v2/data/templates/kpi-dashboard.json +268 -48
  48. package/skills/suppa-form-v2/data/templates/list-management.json +11 -0
  49. package/skills/suppa-form-v2/data/templates/record-detail-side-panel.json +74 -8
  50. package/skills/suppa-form-v2/data/templates/simple-form.json +59 -3
  51. package/skills/suppa-form-v2/data/templates/tabbed-settings.json +114 -7
  52. package/skills/suppa-form-v2/data/templates/wizard.json +30 -0
  53. package/skills/suppa-form-v2/notes/chart.md +4 -4
  54. package/skills/suppa-form-v2/notes/dynamicComponent.md +159 -0
  55. package/skills/suppa-form-v2/notes/table.md +2 -0
  56. package/skills/suppa-form-v2/references/binding.md +8 -2
  57. package/skills/suppa-form-v2/references/card-kit.md +258 -0
  58. package/skills/suppa-form-v2/references/charts.md +32 -7
  59. package/skills/suppa-form-v2/references/choosing-elements.md +2 -2
  60. package/skills/suppa-form-v2/references/custom-chart.md +77 -19
  61. package/skills/suppa-form-v2/references/layout.md +15 -1
  62. package/skills/suppa-form-v2/references/publishing.md +15 -0
  63. package/skills/suppa-form-v2/references/styling.md +42 -6
  64. package/skills/suppa-form-v2/references/tables.md +48 -3
  65. package/skills/suppa-form-v2/scripts/card-kit/card-check.mjs +136 -0
  66. package/skills/suppa-form-v2/scripts/card-kit/card-kit.mjs +181 -0
  67. package/skills/suppa-form-v2/scripts/card-kit/kit-form.mjs +167 -0
  68. package/skills/suppa-form-v2/scripts/cell-rules.mjs +35 -0
  69. package/skills/suppa-form-v2/scripts/form-core.mjs +2310 -549
  70. package/skills/suppa-form-v2/scripts/form-rules.mjs +20 -8
  71. package/skills/suppa-form-v2/scripts/validate-form-schema.mjs +1137 -21
  72. package/skills/suppa-form-v2/scripts/widget-code.mjs +1120 -449
  73. package/skills/writing-suppa-sql/SKILL.md +175 -0
  74. package/skills/writing-suppa-sql/SOURCE.json +28 -0
  75. package/skills/writing-suppa-sql/references/actions.md +53 -0
  76. package/skills/writing-suppa-sql/references/analytics.md +121 -0
  77. package/skills/writing-suppa-sql/references/http-api.md +78 -0
  78. package/skills/writing-suppa-sql/references/language.md +429 -0
  79. package/skills/writing-suppa-sql/references/performance.md +256 -0
  80. package/skills/writing-suppa-sql/references/practices.md +165 -0
  81. package/skills/writing-suppa-sql/references/unsupported.md +111 -0
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Andrii Herasymchuk
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Andrii Herasymchuk
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -30,7 +30,7 @@ No API key needed to start — the server authenticates interactively via the `s
30
30
 
31
31
  ## The `suppa` command
32
32
 
33
- The same 104 operations the MCP server exposes are available as a command, for
33
+ The same 106 operations the MCP server exposes are available as a command, for
34
34
  shells, scripts and CI:
35
35
 
36
36
  ```bash
@@ -414,7 +414,7 @@ extension table is created outside that check and is not subject to it.
414
414
 
415
415
  ## Available tools
416
416
 
417
- 104 tools across the areas below.
417
+ 106 tools across the areas below.
418
418
 
419
419
  ### Session & identity
420
420
 
@@ -482,6 +482,8 @@ extension table is created outside that check and is not subject to it.
482
482
  | `suppa_search_records` | Search / filter records in any entity — nested AND/OR groups, auto-diagnoses an empty result (`deleted_scope` finds soft-deleted rows) |
483
483
  | `suppa_validate_select` | Check a select/filter payload against the entity without running it — names the field that does not resolve |
484
484
  | `suppa_query` | Run one read-only SuppaSQL statement (SELECT/WITH) with the caller's read permissions — check a SQL chart or table source before writing the form |
485
+ | `suppa_sql_kb` | The SuppaSQL skill offline (`skills/writing-suppa-sql`): rules, cheat sheet, common mistakes, references by section, and `check` — what the platform refuses and the measured slow shapes a draft's text shows |
486
+ | `suppa_query_analyze` | One analysis of a final query: its plan for you and every role, the tables' storage and indexes, the index / rewrite actions to propose (none applied). Plan only; needs `DATABASE_ANALYTICS.VIEW` |
485
487
  | `suppa_get_record` | Get a single record (`deleted_scope` reads a soft-deleted one) |
486
488
  | `suppa_create_entity` | Create a new entity (`options_json`: comments / globalSearch / hierarchy …) |
487
489
  | `suppa_create_tabular_part` | Create a tabular part (owned rows) of a parent |
@@ -314,7 +314,7 @@ async function sendWithReauth(ctx, buildHeaders, method, url, data, timeout, opt
314
314
  }
315
315
  let refreshed = false;
316
316
  let transientRetried = false;
317
- const retriable = isSafeRequest(method, url);
317
+ const retriable = opts.retryTransient !== false && isSafeRequest(method, url);
318
318
  // eslint-disable-next-line no-constant-condition
319
319
  while (true) {
320
320
  const token = ctx.getToken();
@@ -574,7 +574,7 @@ export async function makeRequest(method, path, body = null, opts = {}) {
574
574
  data = JSON.stringify(body);
575
575
  extra["Content-Type"] = "application/json; charset=UTF-8";
576
576
  }
577
- return sendWithReauth(ctx, (t) => headers(ctx, t, extra), method, url, data, timeout, { unwrap: !opts.raw });
577
+ return sendWithReauth(ctx, (t) => headers(ctx, t, extra), method, url, data, timeout, { unwrap: !opts.raw, retryTransient: opts.retryTransient });
578
578
  }
579
579
  /** Make a raw-bytes request (for multipart uploads). */
580
580
  export async function makeRequestRawBytes(method, path, data, contentType, opts = {}) {
package/dist/server.js CHANGED
@@ -26,12 +26,14 @@ import * as migrate from "./tools/migrate.js";
26
26
  import * as workspace from "./tools/workspace.js";
27
27
  import * as automation from "./tools/automation.js";
28
28
  import * as query from "./tools/query.js";
29
+ import * as sqlKb from "./tools/sqlKb.js";
30
+ import * as queryAnalyze from "./tools/queryAnalyze.js";
29
31
  import * as auth from "./auth.js";
30
32
  import * as tenants from "./tenants.js";
31
33
  import { confirmRequired, jsonResponse } from "./utils.js";
32
34
  import { suggestName } from "./cli/flags.js";
33
35
  import { installToolsListEconomy } from "./toolsListEconomy.js";
34
- import { PACKAGE_NAME, PACKAGE_VERSION, knownLatest, isOutdated, refreshLatestVersion, upgradeNotice, } from "./version.js";
36
+ import { PACKAGE_CAPABILITIES, PACKAGE_NAME, PACKAGE_VERSION, knownLatest, isOutdated, refreshLatestVersion, upgradeNotice, } from "./version.js";
35
37
  export { PACKAGE_VERSION };
36
38
  // ---------------------------------------------------------------------------
37
39
  // Tool-behavior hints (MCP spec): clients use these for auto-approval policies.
@@ -624,7 +626,7 @@ export function buildToolTable() {
624
626
  name: z
625
627
  .string()
626
628
  .default("")
627
- .describe("Substring of the full name; returned ids feed assigned_to_id and mentions."),
629
+ .describe("Words of the full name, any order; returned ids feed assigned_to_id and mentions."),
628
630
  limit: z.number().int().default(20),
629
631
  },
630
632
  annotations: _READ,
@@ -643,7 +645,7 @@ export function buildToolTable() {
643
645
  fields_json: FieldsJsonOpt,
644
646
  },
645
647
  annotations: _READ,
646
- }, async (a) => text(await docs.listDocs(a.search, a.limit)));
648
+ }, async (a) => text(await docs.listDocs(a.search, a.limit, a.fields_json ?? null)));
647
649
  reg("suppa_get_doc", {
648
650
  description: "Get a document by ID including its page tree, or only fields_json.",
649
651
  inputSchema: { doc_id: z.number().int(), fields_json: FieldsJsonOpt },
@@ -944,8 +946,10 @@ export function buildToolTable() {
944
946
  }, async (a) => text(await entity.listTabularParts(a.entity_name)));
945
947
  reg("suppa_search_records", {
946
948
  description: "Search records of any entity. filters_json: [{field, value, comparator}]. fields_json: {field: true}.\n" +
947
- " Comparators: =, !=, <, >, <=, >=, like, in, is null, is not null. 'like' needs SQL\n" +
948
- " wildcards ('%substring%'); 'in' takes a JSON array. Field paths may be dotted —\n" +
949
+ " Comparators: =, !=, <, >, <=, >=, like, not like, in, not in, between, not between,\n" +
950
+ " is null, is not null. 'like' is a case-insensitive CONTAINS — send the bare text; the\n" +
951
+ " platform adds % and escapes yours, so 'LMS.%' matches nothing. 'in' takes a JSON array,\n" +
952
+ " 'between' [from, to] or a period like \"$this_month\". Field paths may be dotted —\n" +
949
953
  ' "stage.status.value", "owner.id" — and the value "$current-user" resolves to the\n' +
950
954
  " signed-in user's id.\n" +
951
955
  " match_any=true combines filters with OR instead of AND.\n" +
@@ -967,7 +971,7 @@ export function buildToolTable() {
967
971
  filters_json: z
968
972
  .string()
969
973
  .default("[]")
970
- .describe('JSON array of filters: [{"field": "status.value", "value": "active", "comparator": "="}]. \'like\' needs %wildcards%; dotted paths allowed. ' +
974
+ .describe('JSON array of filters: [{"field": "status.value", "value": "active", "comparator": "="}]. \'like\' = contains, bare text, no %; dotted paths allowed. ' +
971
975
  'An entry may also be a NESTED GROUP {"operator": "and"|"or", "filters": [...]} (shorthand {"or": [...]}), so (a AND b) OR c is one call.'),
972
976
  fields_json: ProjectionJson.default('{"id": true}'),
973
977
  limit: z.number().int().default(20),
@@ -1020,17 +1024,21 @@ export function buildToolTable() {
1020
1024
  description: "Run ONE read-only SuppaSQL statement — POST /core/data/query, the endpoint the\n" +
1021
1025
  " builder's SQL charts and tables use. Check a chart/table SQL source with it before\n" +
1022
1026
  " writing the form: an incomplete one shows demo data, a wrong one fails at runtime.\n\n" +
1023
- " SELECT / WITH only, one statement; anything else is refused and nothing is sent.\n" +
1024
- " Runs with the caller's read permissions; deleted rows are excluded. A missing LIMIT\n" +
1025
- " is added and a bigger literal one clamped, so at most `limit` rows come back, with\n" +
1026
- " `truncated` and `columns` — the result keys, nested ones as dot paths\n" +
1027
- " (owner.firstName): a TABLE column's key. A CHART's sqlCategoryColumn and\n" +
1028
- " sqlValueColumns[].key take the alias, else the last segment (firstName); a dot path\n" +
1029
- " there matches nothing and the chart shows demo data.",
1027
+ " SELECT / WITH only, one statement, no comments (SuppaSQL has none); anything else is\n" +
1028
+ " refused and nothing is sent. Runs with the caller's read permissions; deleted rows are\n" +
1029
+ " excluded. A missing LIMIT is added and a bigger literal one clamped, so at most `limit`\n" +
1030
+ " rows come back, with `truncated` and `columns` — the keys of every row, nested ones as\n" +
1031
+ " dot paths (owner.firstName): a TABLE column's key. `chart_note` says when the same\n" +
1032
+ " text fails as a CHART source: a chart needs LIMIT 10000 or less (it sends LIMIT 10001,\n" +
1033
+ " refused with query.row_limit). A CHART's sqlCategoryColumn / sqlValueColumns[].key is a\n" +
1034
+ " field's last segment (firstName) or the alias of a COMPUTED item (COUNT, CASE,\n" +
1035
+ " TO_CHAR…); never alias a plain field in a chart query — the chart reads it by its path\n" +
1036
+ " and shows nothing. Writing one: suppa_sql_kb (check a draft offline first); slow, or\n" +
1037
+ " failing for some role: suppa_query_analyze, once.",
1030
1038
  inputSchema: {
1031
1039
  query: z
1032
1040
  .string()
1033
- .describe('The SuppaSQL statement, e.g. SELECT "stage.name" AS stage, COUNT(id) AS n FROM Tasks GROUP BY "stage.name".'),
1041
+ .describe('The SuppaSQL statement, e.g. SELECT "stage.name", COUNT("id") AS "n" FROM Tasks GROUP BY "stage.name" LIMIT 100 — as a chart: sqlCategoryColumn "name", sqlValueColumns [{"key": "n"}].'),
1034
1042
  bind_params_json: z
1035
1043
  .string()
1036
1044
  .optional()
@@ -1045,6 +1053,50 @@ export function buildToolTable() {
1045
1053
  },
1046
1054
  annotations: _READ,
1047
1055
  }, async (a) => text(await query.runQuery(a.query, a.bind_params_json ?? null, a.limit)));
1056
+ reg("suppa_sql_kb", {
1057
+ description: "The SuppaSQL skill (skills/writing-suppa-sql): write, check and tune a query for\n" +
1058
+ " suppa_query, a chart / table SQL source or an application. Offline; touches no tenant.\n\n" +
1059
+ " rules the cycle, request discipline, the five rules cheatsheet goal → query\n" +
1060
+ " mistakes common mistakes and their fix\n" +
1061
+ " check a draft's TEXT: what the platform refuses ($now, CURRENT_DATE, LEFT JOIN,\n" +
1062
+ " LIMIT > 10000…) and the measured slow shapes it shows (P1–P14)\n" +
1063
+ " ref topic language|unsupported|performance|practices|analytics|actions|http-api,\n" +
1064
+ " section = a heading (e.g. P14); a long topic without one lists its sections",
1065
+ inputSchema: {
1066
+ mode: z.enum(["rules", "cheatsheet", "mistakes", "check", "ref"]).describe("Which part of the skill to read, or 'check' a draft."),
1067
+ topic: z.string().optional().describe("mode='ref': the reference. Omit to list them with their sections."),
1068
+ section: z.string().optional().describe("mode='ref': words of a heading ('P14', 'Bind parameters'); '*' = the whole reference."),
1069
+ query: z.string().optional().describe("mode='check': the SuppaSQL text."),
1070
+ bind_params_json: z.string().optional().describe("mode='check': the bind values you will send, so a bound $name is not flagged."),
1071
+ },
1072
+ annotations: _READ,
1073
+ }, async (a) => text(await sqlKb.sqlKb(a.mode, a.topic ?? null, a.section ?? null, a.query ?? null, a.bind_params_json ?? null)));
1074
+ reg("suppa_query_analyze", {
1075
+ description: "ONE analysis of a FINAL SuppaSQL query on the active tenant: the plan for you and for every\n" +
1076
+ " role (× the full-rights cost, the access rules' share, the roles it FAILS for), the size\n" +
1077
+ " and indexes of the tables it reads, and the actions to PROPOSE — create / rebuild / drop an\n" +
1078
+ " index, rewrite the query; none is applied. Plan only: nothing runs unless run_query=true.\n" +
1079
+ " Needs the owner group or DATABASE_ANALYTICS.VIEW. Up to 13 requests; /query-analyze allows\n" +
1080
+ " 10 calls a minute per user — iterate on drafts with suppa_sql_kb mode='check', analyse the\n" +
1081
+ " final one once. On a rate limit it stops and reports what it has: do not repeat it.",
1082
+ inputSchema: {
1083
+ query: z.string().describe("The SuppaSQL statement, as the chart, table or application sends it."),
1084
+ bind_params_json: z.string().optional().describe('JSON object of bind values for $name, e.g. {"from": "2026-10-01"}.'),
1085
+ run_query: z
1086
+ .boolean()
1087
+ .default(false)
1088
+ .describe("true RUNS the query on the tenant's database (EXPLAIN ANALYZE, rolled back) for real numbers — only when the user asked."),
1089
+ role_plans: z
1090
+ .number()
1091
+ .int()
1092
+ .min(0)
1093
+ .max(queryAnalyze.MAX_ROLE_PLANS)
1094
+ .default(queryAnalyze.MAX_ROLE_PLANS)
1095
+ .describe("Detailed plans for the slowest roles (0-2)."),
1096
+ format: z.enum(["text", "json"]).default("text").describe("text: the report; json: every answer, whole."),
1097
+ },
1098
+ annotations: _READ,
1099
+ }, async (a) => text(await queryAnalyze.analyzeQuery(a.query, a.bind_params_json ?? null, a.run_query ?? false, a.role_plans ?? queryAnalyze.MAX_ROLE_PLANS, a.format ?? "text")));
1048
1100
  reg("suppa_get_record", {
1049
1101
  description: "Get a single record of any entity by id. fields_json: {field: true} projection —\n" +
1050
1102
  ' request only the fields you need (relations as nested objects, e.g. {"owner": {"id": true, "fullName": true}}).\n\n' +
@@ -1744,7 +1796,8 @@ export function buildToolTable() {
1744
1796
  " returns {created, requested, entity, records} and is validated as a unit:\n" +
1745
1797
  " if any record is malformed, nothing is inserted.\n\n" +
1746
1798
  ' Write relations as {"id": N} and enum fields as {"id": <enumValueId>} —\n' +
1747
- " a bare number/string returns HTTP 201 but silently stores null.",
1799
+ " a bare number/string returns HTTP 201 but silently stores null. A Forms widget with a\n" +
1800
+ " stale compiledRender is refused.",
1748
1801
  inputSchema: {
1749
1802
  entity_name: EntityName,
1750
1803
  fields_json: RecordValuesOrBatchJson,
@@ -1759,6 +1812,7 @@ export function buildToolTable() {
1759
1812
  ' [{"id": 15}]} makes 15 the ONLY watcher — every other watcher is dropped.\n' +
1760
1813
  ' To ADD the listed items instead, pass merge_json=["watchers"]; to REMOVE\n' +
1761
1814
  ' only the listed items, pass unmerge_json=["watchers"].\n\n' +
1815
+ " A form's draft is suppa_write_form_draft; a Forms widget with a stale compiledRender is refused.\n\n" +
1762
1816
  " APPROVAL GATE: without confirm=true this returns a confirmation request and changes nothing.",
1763
1817
  inputSchema: {
1764
1818
  entity_name: EntityName,
@@ -2076,9 +2130,11 @@ export function buildToolTable() {
2076
2130
  reg("suppa_create_automation", {
2077
2131
  description: "Create a DRAFT automation workflow (AutomationWorkflow). Writes only draft\n" +
2078
2132
  " columns (name/nodes/connections/settings) with isActive=false — it is NOT live\n" +
2079
- " until published (suppa_publish_automation). Runs pre-flight validation (one\n" +
2080
- " trigger first, unique node ids, connections reference known nodes, DAG, suppa\n" +
2081
- " node params); on failure nothing is written and the errors are returned.",
2133
+ " until published (suppa_publish_automation). Runs pre-flight validation (at least\n" +
2134
+ " one trigger — triggerEntity, triggerManual, triggerWebhook, triggerSchedule,\n" +
2135
+ " formSubmission or any the live catalog lists; several are allowed, in any position —\n" +
2136
+ " unique node ids, connections reference known nodes, DAG, trigger and suppa node\n" +
2137
+ " params); on failure nothing is written and the errors are returned.",
2082
2138
  inputSchema: {
2083
2139
  name: z.string().describe("Automation name."),
2084
2140
  nodes_json: z
@@ -2160,14 +2216,15 @@ export function buildToolTable() {
2160
2216
  reg("suppa_publish_automation", {
2161
2217
  description: "Publish (activate) an automation — promotes the draft to the live snapshot via\n" +
2162
2218
  " the automation-service. Requires the automation-service deployed on the tenant;\n" +
2163
- " if absent the call 404s and the error is returned (never crashes). A typed 400\n" +
2164
- " returns {published:false, errors, warnings, message}.\n\n" +
2165
- " APPROVAL GATE: without confirm=true this returns a confirmation request and changes nothing.",
2219
+ " if absent the call 404s and the error is returned. A typed 400 returns\n" +
2220
+ " {published:false, errors, warnings, message}.\n\n" +
2221
+ " APPROVAL GATE: without confirm=true nothing changes; the answer carries the\n" +
2222
+ " draft's pre-flight (E1–E21 run on publish).",
2166
2223
  inputSchema: { automation_id: AutomationId, confirm: Confirm },
2167
2224
  annotations: _MUT,
2168
2225
  }, async (a) => {
2169
2226
  if (!a.confirm) {
2170
- return text(confirmRequired("publish automation", { automation_id: a.automation_id }));
2227
+ return text(await automation.previewPublishAutomation(a.automation_id));
2171
2228
  }
2172
2229
  return text(await automation.publishAutomation(a.automation_id));
2173
2230
  });
@@ -2399,7 +2456,8 @@ export function buildToolTable() {
2399
2456
  annotations: _READ,
2400
2457
  }, async (a) => text(await forms.listForms(a.entity_name, a.form_type, a.limit)));
2401
2458
  reg("suppa_get_form", {
2402
- description: "Get a form by ID with full schema (data.formShema) and settings.",
2459
+ description: "Get a SUPPA 1.0 form by ID (data.formShema, settings). A 2.x form's draft is the schema\n" +
2460
+ " COLUMN: read Forms or FormVersions (snapshot) with suppa_search_records.",
2403
2461
  inputSchema: { form_id: z.number().int() },
2404
2462
  annotations: _READ,
2405
2463
  }, async (a) => text(await forms.getForm(a.form_id)));
@@ -2409,7 +2467,7 @@ export function buildToolTable() {
2409
2467
  " (without entity_name it is refused, rather than creating an empty form).\n" +
2410
2468
  " Form names are UNIQUE platform-wide — a duplicate name fails; pick a distinct one.\n" +
2411
2469
  "\n SUPPA 1.0 FORM. This writes data.formShema and the v1 field types. A Suppa 2.0\n" +
2412
- " (entity-builder) form is a different product — the `schema` column, 58 types:\n" +
2470
+ " (entity-builder) form is a different product — the `schema` column, 56 types:\n" +
2413
2471
  " use suppa_form_kb and suppa_validate_form_schema.",
2414
2472
  inputSchema: {
2415
2473
  name: z.string(),
@@ -2561,6 +2619,7 @@ export function buildToolTable() {
2561
2619
  ' returned JSON includes a URL to open manually. Returns {"status":"ok", ...}\n' +
2562
2620
  ' on success, or {"error": ...} (e.g. the localhost origin isn\'t whitelisted in\n' +
2563
2621
  " the Google OAuth client, or the account isn't a member of that tenant).\n" +
2622
+ " A successful login also makes that tenant the ACTIVE one for every later call.\n" +
2564
2623
  " After a successful login, retry whatever the user originally asked for.\n\n" +
2565
2624
  " tenant: alias / host / URL (default: the active tenant).",
2566
2625
  inputSchema: { tenant: TenantArg.default("") },
@@ -2579,16 +2638,19 @@ export function buildToolTable() {
2579
2638
  }, async () => text(tenants.listTenants()));
2580
2639
  reg("suppa_form_kb", {
2581
2640
  description: "The Suppa 2.0 (entity-builder) FORM knowledge base. Offline; touches no tenant.\n\n" +
2582
- " components the 58 element types (start here) api prop table for the types you name\n" +
2641
+ " components the 56 element types (start here) api prop table for the types you name\n" +
2583
2642
  " base props every element supports note one type's BEHAVIOUR\n" +
2584
2643
  " ref layout|binding|tables|charts|custom-chart|conditions|styling|publishing|\n" +
2585
2644
  " choosing-elements\n" +
2586
- " template a starting draft by name rules the nine rules and what blocks\n\n" +
2587
- " No mode returns all 58 prop tables: they are 13,412 tokens stripped, and not carrying\n" +
2645
+ " template a starting draft by name rules the nine rules and what blocks\n" +
2646
+ " kit the look of every record card, create form, window: the card kit's\n" +
2647
+ " patterns (topic='p_block,…' = their elements); rules: ref card-kit\n" +
2648
+ " note dynamicComponent = the widget contract (sandbox, formAPI, styles, translations)\n\n" +
2649
+ " No mode returns all 56 prop tables: they are ~14,200 tokens stripped, and not carrying\n" +
2588
2650
  " them is what this skill is for. Full skill: skills/suppa-form-v2/SKILL.md.",
2589
2651
  inputSchema: {
2590
2652
  mode: z
2591
- .enum(["components", "api", "base", "note", "ref", "template", "rules"])
2653
+ .enum(["components", "api", "base", "note", "ref", "template", "rules", "kit"])
2592
2654
  .describe("Which part of the knowledge base to read."),
2593
2655
  types: z
2594
2656
  .array(z.string())
@@ -2597,7 +2659,7 @@ export function buildToolTable() {
2597
2659
  topic: z
2598
2660
  .string()
2599
2661
  .optional()
2600
- .describe("mode='note'/'ref'/'template': the type, reference topic or template name. Omit to list what exists."),
2662
+ .describe("mode='note'/'ref'/'template'/'kit': the type, topic, template or pattern(s). Omit to list what exists."),
2601
2663
  },
2602
2664
  annotations: _READ,
2603
2665
  }, async (a) => text(await formV2.formKb(a.mode, a.types ?? null, a.topic ?? null)));
@@ -2606,8 +2668,10 @@ export function buildToolTable() {
2606
2668
  " The platform form builder's own STRUCTURAL checker: 37 error codes — unknown types and\n" +
2607
2669
  " props, bindings that resolve to nothing, malformed geometry and containment, bad option\n" +
2608
2670
  " values, collisions. It does NOT carry the authoring lints (an unbound select, an empty\n" +
2609
- " container, a chart with no height, a second Save): those live in the source agent's\n" +
2610
- " uxVerify pass, which is not vendored here. Passing is structural, not editorial.\n\n" +
2671
+ " container, a second Save): those live in the source agent's uxVerify pass, which is\n" +
2672
+ " not vendored here. Passing is structural, not editorial. It also refuses chart SQL the\n" +
2673
+ " runtime refuses or reads empty, warns on low contrast and heightless charts, and\n" +
2674
+ " compiles every widget's compiledRender as the builder does.\n\n" +
2611
2675
  " FOR AN EDIT PASS baseline_path, the form as it exists on the tenant: the component\n" +
2612
2676
  " manifest lags the live platform, so without it the tenant's own props read as errors.\n" +
2613
2677
  " Measured on every live form of a dev tenant: 59 of 96 cold, 73 as an edit.\n\n" +
@@ -2619,14 +2683,18 @@ export function buildToolTable() {
2619
2683
  baseline_path: z
2620
2684
  .string()
2621
2685
  .optional()
2622
- .describe("Absolute path to the CURRENT form, for an edit. Omit only when authoring a brand-new form."),
2686
+ .describe("Absolute path to the CURRENT form, for an edit: a draft envelope, a one-record suppa_search_records answer, or a FormVersions row with `snapshot`. Omit only for a brand-new form."),
2623
2687
  normalize: z
2624
2688
  .boolean()
2625
2689
  .optional()
2626
- .describe("Run the repair pipeline (geometry, spans, container heights, grid settings) before checking, to see what the platform will make of the draft. Default false: report what was authored."),
2690
+ .describe("Run the repair pipeline first: it expands theme/styleIntent, re-packs geometry, AND snaps font size, radius, spacing and colour to this gate's own scales — never over a look taken from a design kit or a live form. Default false."),
2691
+ purpose: z
2692
+ .enum(["create", "record"])
2693
+ .optional()
2694
+ .describe("A create form or an existing record's card: the card kit then judges each field's look. Writes take it from the form's type."),
2627
2695
  },
2628
2696
  annotations: _READ,
2629
- }, async (a) => text(await formV2.validateFormSchema(a.path, a.baseline_path ?? null, a.normalize ?? false)));
2697
+ }, async (a) => text(await formV2.validateFormSchema(a.path, a.baseline_path ?? null, a.normalize ?? false, a.purpose ?? null)));
2630
2698
  reg("suppa_write_form_draft", {
2631
2699
  description: "Save a Suppa 2.0 form as a DRAFT on the tenant, through the builder's own save\n" +
2632
2700
  " (PUT /core/forms/:id/schema). It never publishes: what others see stays the published\n" +
@@ -2655,7 +2723,7 @@ export function buildToolTable() {
2655
2723
  normalize: z
2656
2724
  .boolean()
2657
2725
  .optional()
2658
- .describe("Run the repair pipeline before checking AND saving, so what is stored is what was verified."),
2726
+ .describe("Run the repair pipeline (see suppa_validate_form_schema) before checking AND saving — it rewrites a kit's or a live form's fonts, radii and colours to the gate's scales."),
2659
2727
  expected_revision: z
2660
2728
  .string()
2661
2729
  .optional()
@@ -2665,21 +2733,25 @@ export function buildToolTable() {
2665
2733
  }, async (a) => text(await formV2.writeFormDraft(a.form_id, a.path, a.confirm ?? false, a.normalize ?? false, a.expected_revision ?? null)));
2666
2734
  reg("suppa_create_form_v2", {
2667
2735
  description: "Create a Suppa 2.0 form: the row and its draft in one transaction (POST /core/forms/schema),\n" +
2668
- " as the builder does — isFormBuilderV2 stamped, the default variable added (a relation named\n" +
2669
- " after the entity, or `submitData` on an entity-less form). A draft, nothing is published.\n" +
2670
- " `path` (optional) is a draft file, gated first. A duplicate name or an unknown entity or\n" +
2671
- " folder is refused before any write. `workspace` forms inherit the base form: builder only.\n" +
2672
- " A dashboard is `custom` with folder='dashboards'. Without confirm=true: the plan only.",
2736
+ " as the builder does — isFormBuilderV2 stamped. The default variable of a form with an\n" +
2737
+ " entity is the record (a relation named after it; a draft's entity-less `submitData`\n" +
2738
+ " default is replaced, and refused if fields bind into it); `submitData` otherwise. A\n" +
2739
+ " draft, nothing is published. `path` (optional) is a draft file, gated against those\n" +
2740
+ " variables. A duplicate name or an unknown entity or folder is refused before any write.\n" +
2741
+ " `workspace` forms inherit the base form: builder only. A dashboard is `custom` with\n" +
2742
+ " folder='dashboards'. A create / update form takes the record-card kit's look\n" +
2743
+ " (suppa_form_kb mode='kit'), judged by `type`. Without confirm=true: the plan only.",
2673
2744
  inputSchema: {
2674
2745
  name: z.string().describe("Unique on the tenant."),
2675
2746
  type: z.enum(formLifecycle.CREATABLE_FORM_TYPES).describe("create / update need an entity; custom may have none."),
2676
2747
  entity: z.string().optional().describe("Entity system name the form edits."),
2677
2748
  path: z.string().optional().describe("Absolute path to a draft JSON { schema, settings, variables }."),
2678
2749
  folder: z.string().optional().describe("FormsFolders alias or id to file the form into."),
2750
+ alias: z.string().optional().describe("Forms.alias — a drill-down details form is chartDetails_<Entity>_<8 hex>."),
2679
2751
  confirm: z.boolean().default(false).describe("true = create. Omitted means NO."),
2680
2752
  },
2681
2753
  annotations: _ADD,
2682
- }, async (a) => text(await formLifecycle.createFormV2(a.name, a.type, a.entity ?? null, a.path ?? null, a.folder ?? null, a.confirm ?? false)));
2754
+ }, async (a) => text(await formLifecycle.createFormV2(a.name, a.type, a.entity ?? null, a.path ?? null, a.folder ?? null, a.confirm ?? false, false, a.alias ?? null)));
2683
2755
  reg("suppa_form_versions", {
2684
2756
  description: "A Suppa 2.0 form's published versions (newest first, which one users see), optionally the\n" +
2685
2757
  " component diff between two of THIS form's versions, and a summary of the last N draft\n" +
@@ -2704,10 +2776,11 @@ export function buildToolTable() {
2704
2776
  form_id: z.number().int(),
2705
2777
  action: z.enum(formLifecycle.LIFECYCLE_ACTIONS),
2706
2778
  version_id: z.number().int().optional().describe("rollback / promote: the FormVersions id (suppa_form_versions)."),
2779
+ description: z.string().optional().describe("publish / rollback: the new version's description."),
2707
2780
  confirm: z.boolean().default(false).describe("true = do it. Omitted means NO."),
2708
2781
  },
2709
2782
  annotations: _ONCE,
2710
- }, async (a) => text(await formLifecycle.formLifecycle(a.form_id, a.action, a.version_id ?? null, a.confirm ?? false)));
2783
+ }, async (a) => text(await formLifecycle.formLifecycle(a.form_id, a.action, a.version_id ?? null, a.confirm ?? false, a.description ?? null)));
2711
2784
  reg("suppa_validate_entity_code", {
2712
2785
  description: "Run the schema gate over an application repo's *.entity.ts / *.seed.ts / module files.\n\n" +
2713
2786
  " CALL THIS BEFORE REPORTING ANY ENTITY OR SEED FILE DONE. It is the same checker the\n" +
@@ -2720,7 +2793,7 @@ export function buildToolTable() {
2720
2793
  " * enum member keys are PascalCase;\n" +
2721
2794
  " * no field option may be written at its default (canGroup/canSort/showInTable/\n" +
2722
2795
  " editFromTable/canFilter are already true, readOnly/searchable already false);\n" +
2723
- " * @Enum/@MultiEnum take a global name ONLY when the enum is shared or seed-referenced;\n" +
2796
+ " * @Enum/@MultiEnum take a global name ONLY when another entity shares the enum;\n" +
2724
2797
  " * a relation target that already exists on the tenant gets a STUB — @Entity({name,key})\n" +
2725
2798
  " + extends SystemBaseEntity, EMPTY body, its own file, registered in forFeature();\n" +
2726
2799
  " a bare 'export class Accounts {}' registers nothing (E116), and stubs sharing a file\n" +
@@ -2746,7 +2819,7 @@ export function buildToolTable() {
2746
2819
  strict: z
2747
2820
  .boolean()
2748
2821
  .default(true)
2749
- .describe("true (default): the house rules above (W607/W609-W613, W615, W616) fail the gate. false: " +
2822
+ .describe("true (default): the house rules above (W607/W609-W613, W615-W623, W625, W626, W628, W634-W637, W640) fail the gate. false: " +
2750
2823
  "they are reported as advisory — for a legacy repo you are not cleaning up in this pass, " +
2751
2824
  "never for a file you just wrote. Errors, E116 included, block either way."),
2752
2825
  },
@@ -2758,7 +2831,8 @@ export function buildToolTable() {
2758
2831
  " missing or behaves the old way: an MCP client keeps whatever version it started with\n" +
2759
2832
  " (npx cache / node_modules) for the whole session, so a release changes nothing until\n" +
2760
2833
  " the client is restarted on the new package. Reports running, latest, whether an\n" +
2761
- " upgrade is available, and the command to run.",
2834
+ " upgrade is available, the command to run, and capabilities (cellWidgets = the\n" +
2835
+ " form gate checks table cell widgets).",
2762
2836
  annotations: _READ,
2763
2837
  }, async () => {
2764
2838
  // Force a live lookup: this tool is the one place staleness must be
@@ -2768,6 +2842,8 @@ export function buildToolTable() {
2768
2842
  return text(jsonResponse({
2769
2843
  package: PACKAGE_NAME,
2770
2844
  running: PACKAGE_VERSION,
2845
+ // package.json `suppa.capabilities` of THIS build — what the suppa plugin's hooks gate on.
2846
+ capabilities: PACKAGE_CAPABILITIES,
2771
2847
  latest: latest ?? knownLatest(),
2772
2848
  up_to_date: latest ? !outdated : null,
2773
2849
  checked: latest !== null,
@@ -2960,7 +3036,7 @@ export function buildServer() {
2960
3036
  },
2961
3037
  }, (a) => `Write Suppa 2.0 application schema code for: ${a.entity_purpose}\n\n` +
2962
3038
  "Follow the bundled 'suppa-entity-code' skill (skills/suppa-entity-code/SKILL.md inside the installed suppa-mcp-2 package):\n" +
2963
- "1. Pre-flight: the target app repo exists, its src/index.ts exports a named AppModule, @suppa/sdk is in dependencies at the version extension-runner ships (1.38.7 as of 2026-09-29 — newer APIs compile but are missing at runtime), " +
3039
+ "1. Pre-flight: the target app repo exists, its src/index.ts exports a named AppModule, @suppa/sdk is in dependencies at the LOWEST version the runners of its target stands ship (dev = extension-runner develop 1.40.2, stage = release 1.38.7, prod = tag v1.7.0 1.38.7 — newer APIs compile but are missing at runtime there; 1.38.7 reaches every stand), " +
2964
3040
  "every runtime import is in dependencies, imports are relative (the platform build ignores the app tsconfig's paths/baseUrl), and its tsconfig enables experimentalDecorators + emitDecoratorMetadata for local tsc.\n" +
2965
3041
  "2. Resolve the blocking questions BEFORE writing any file: importKeyFields (the stable business key — wrong means duplicate seed rows on every restart), " +
2966
3042
  "representativeFieldName, and per-field nullable.\n" +
@@ -2969,8 +3045,8 @@ export function buildServer() {
2969
3045
  "TYPE every relation property to match its decorator (@ManyToOne -> `owner: Target;`, or `owner?: Target` when the relation is nullable; " +
2970
3046
  "@ManyToMany/@OneToMany/@ManyToManyBackRef -> `peers: Target[];`) — an untyped relation is `any` to every caller. " +
2971
3047
  "Fixed choices via @Enum(StatusEnum, StatusTitles, { ... }) with PascalCase member keys (Active = 'active') and NO global name — " +
2972
- "the decorator derives <ClassName>.<propertyName>; add the '<Entity>.<field>' first argument ONLY when the value set is shared across " +
2973
- "entities or referenced from a seed record. Attachments via @File/@MultiFile; " +
3048
+ "the decorator derives <@Entity name>.<field name> (the entity's name, not its class); add the '<Entity>.<field>' first argument ONLY when one value set is shared " +
3049
+ "by several entities — a seed writes the bare value (status: StatusEnum.Active) and needs no global name; key the titles map by VALUE ([StatusEnum.Active]: { title }) and type the property { id?: number; value?: StatusEnum }. Attachments via @File/@MultiFile; " +
2974
3050
  "NEVER write a field option that already holds its default — canGroup/canSort/showInTable/editFromTable/canFilter are true and " +
2975
3051
  "readOnly/searchable are false already, so declare one only where the field DEPARTS from that. If the repo's existing entities " +
2976
3052
  "restate those defaults on every field, do not copy that habit into the new file. " +
@@ -3023,7 +3099,9 @@ async function healthCheck(deep = true) {
3023
3099
  form_v2_core: await formV2.coreStatus(),
3024
3100
  form_v2_gate: formV2.skillFile("scripts", "validate-form-schema.mjs") ? "present" : "MISSING",
3025
3101
  form_v2_widget_compiler: await formV2.widgetCompilerStatus(),
3102
+ form_v2_cell_rules: await formV2.cellRulesStatus(),
3026
3103
  entity_code_validator: await entityCode.validatorStatus(),
3104
+ sql_skill: sqlKb.sqlSkillFile("SKILL.md") && sqlKb.sqlSkillFile("references") ? "present" : "MISSING",
3027
3105
  },
3028
3106
  };
3029
3107
  if (!token) {
package/dist/toolTable.js CHANGED
@@ -1,6 +1,6 @@
1
1
  export const PROFILES = {
2
2
  core: ["login", "logout", "use_tenant", "list_tenants", "get_me", "health_check", "diagnostics", "version"],
3
- data: ["search_records", "get_record", "create_record", "update_record", "delete_record", "restore_record", "copy_record", "validate_select", "query", "search_entities", "list_entities", "describe_entity", "search_users"],
3
+ data: ["search_records", "get_record", "create_record", "update_record", "delete_record", "restore_record", "copy_record", "validate_select", "query", "sql_kb", "query_analyze", "search_entities", "list_entities", "describe_entity", "search_users"],
4
4
  tasks: ["search_tasks", "get_task", "create_task", "update_task", "close_task", "delete_task", "move_task", "count_tasks", "list_stages", "list_task_types", "list_workflows", "add_comment", "get_comments", "create_workspace", "add_menu_item"],
5
5
  files: ["attach_file", "attach_file_to_record", "download_file", "download_files_zip", "list_record_files"],
6
6
  schema: ["create_entity", "add_field", "update_field", "change_field_type", "update_entity_options", "set_title_field", "create_tabular_part", "list_tabular_parts", "list_field_types", "add_enum_values", "add_custom_field", "add_custom_fields_batch", "remove_custom_field", "restore_custom_field", "resolve_custom_fields", "link_custom_field", "apply_custom_fields", "validate_entity_code", "migrate_entities_from_v1", "read_v1_entities", "read_v1_entity_props", "read_v1_enum"],
@@ -8,7 +8,7 @@ export const PROFILES = {
8
8
  // Two form PRODUCTS live in this group, and the split is the thing to know before reading the
9
9
  // list. The first seven are Suppa 1.0: they read and write `data.formShema` (the platform's
10
10
  // misspelling) and the v1 field types. `form_kb` and `validate_form_schema` serve the 2.0
11
- // entity-builder canvas — the `schema` COLUMN on the row since 2.1, 58 component
11
+ // entity-builder canvas — the `schema` COLUMN on the row since 2.1, 56 component
12
12
  // types — and share nothing with them.
13
13
  forms: ["create_form", "get_form", "list_forms", "update_form", "add_field_to_form", "generate_form_schema", "list_form_field_types", "form_kb", "validate_form_schema",
14
14
  "write_form_draft", "create_form_v2", "form_versions", "form_lifecycle"],