suppa-mcp-2 1.40.6 → 1.41.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 (46) hide show
  1. package/README.md +35 -8
  2. package/dist/bin.js +68 -1
  3. package/dist/config.js +30 -1
  4. package/dist/customFieldHints.js +19 -22
  5. package/dist/readEconomy.js +32 -3
  6. package/dist/server.js +99 -30
  7. package/dist/toolTable.js +1 -1
  8. package/dist/tools/customFieldSets.js +5 -2
  9. package/dist/tools/customFieldsAsCode.js +51 -16
  10. package/dist/tools/entity.js +376 -114
  11. package/dist/tools/fieldTypeChange.js +364 -0
  12. package/dist/tools/formLifecycle.js +48 -6
  13. package/dist/tools/formV2.js +132 -3
  14. package/dist/tools/nameMap.js +24 -4
  15. package/dist/tools/query.js +10 -0
  16. package/package.json +1 -1
  17. package/skills/suppa-cli/SKILL.md +1 -1
  18. package/skills/suppa-entity-code/SKILL.md +458 -416
  19. package/skills/suppa-entity-code/references/custom-fields.md +4 -1
  20. package/skills/suppa-entity-code/references/enforcement.md +2 -1
  21. package/skills/suppa-entity-code/references/entities.md +503 -482
  22. package/skills/suppa-entity-code/references/extensions.md +1 -1
  23. package/skills/suppa-entity-code/references/registration.md +66 -16
  24. package/skills/suppa-entity-code/references/runtime.md +136 -0
  25. package/skills/suppa-entity-code/references/seeds.md +38 -1
  26. package/skills/suppa-entity-code/references/tabular-parts.md +11 -11
  27. package/skills/suppa-entity-code/references/v1-mapping.md +1 -1
  28. package/skills/suppa-entity-code/scripts/house-rules.mjs +7 -1
  29. package/skills/suppa-entity-code/scripts/validate-suppa-schema.mjs +1104 -38
  30. package/skills/suppa-entity-code/templates/AGENTS.entity-code.md +9 -6
  31. package/skills/suppa-entity-code/templates/custom-fields.template.ts +5 -3
  32. package/skills/suppa-entity-code/templates/entity-extension.template.ts +3 -0
  33. package/skills/suppa-entity-code/templates/relation-target-stub.template.ts +7 -1
  34. package/skills/suppa-entity-code/templates/seed.template.ts +27 -12
  35. package/skills/suppa-entity-code/templates/tabular-part.template.ts +14 -13
  36. package/skills/suppa-form-v2/SKILL.md +8 -7
  37. package/skills/suppa-form-v2/data/component-index.json +1 -1
  38. package/skills/suppa-form-v2/data/component-props.json +2 -1
  39. package/skills/suppa-form-v2/notes/embeddedForm.md +6 -4
  40. package/skills/suppa-form-v2/notes/table.md +1 -1
  41. package/skills/suppa-form-v2/references/layout.md +2 -2
  42. package/skills/suppa-form-v2/references/publishing.md +21 -11
  43. package/skills/suppa-form-v2/references/tables.md +7 -7
  44. package/skills/suppa-form-v2/scripts/form-rules.mjs +8 -7
  45. package/skills/suppa-form-v2/scripts/manifest-corrections.mjs +56 -0
  46. package/skills/suppa-form-v2/scripts/validate-form-schema.mjs +80 -10
@@ -39,10 +39,14 @@
39
39
  * ] }
40
40
  *
41
41
  * IT NEVER DELETES ANYTHING. A custom field removed from the file is REPORTED,
42
- * not dropped: removing one parks its column as <name>_<timestamp> and keeps
43
- * its name reserved forever, so an accidental deletion cannot be undone by
44
- * putting the line back. Convergence is create-and-link only; taking a field
45
- * away stays a deliberate act through suppa_remove_custom_field.
42
+ * not dropped: removing one parks its column as <name>_<timestamp>, and taking a
43
+ * field away stays a deliberate act through suppa_remove_custom_field.
44
+ *
45
+ * NOR DOES IT RE-CREATE A REMOVED ONE. Since entity-builder 08258a57 (2026-09-25)
46
+ * a removed field no longer holds its name, so creating a declared field whose
47
+ * name belongs to a removed one makes a NEW, empty twin — and the removed field,
48
+ * values and all, can then not be restored while the twin lives. Such a field is
49
+ * reported under `parked`, with suppa_restore_custom_field as the way back.
46
50
  *
47
51
  * A TYPE CHANGE IS ALSO ONLY REPORTED. Changing the type of a live column is a
48
52
  * migration with data in it, and guessing at one from a diff is how data is
@@ -105,7 +109,7 @@ export function parseDeclaration(input) {
105
109
  * @param live every custom field name on the extension entity → its type
106
110
  * @param offered context value → the set of field names live in that context
107
111
  */
108
- export function diffDeclaration(decl, live, offered) {
112
+ export function diffDeclaration(decl, live, offered, removed = new Map()) {
109
113
  const plan = {
110
114
  entity: decl.entity,
111
115
  extension: customFieldsEntity(decl.entity),
@@ -115,6 +119,7 @@ export function diffDeclaration(decl, live, offered) {
115
119
  unchanged: [],
116
120
  type_drift: [],
117
121
  not_declared: [],
122
+ parked: [],
118
123
  };
119
124
  const byContext = new Map();
120
125
  const declaredAnywhere = new Set();
@@ -127,6 +132,11 @@ export function diffDeclaration(decl, live, offered) {
127
132
  plan.type_drift.push({ field: f.name, declared: f.type, live: liveType });
128
133
  continue; // a type change is a migration; nothing else about it is safe
129
134
  }
135
+ const parked = liveType === undefined ? removed.get(f.name) : undefined;
136
+ if (parked) {
137
+ plan.parked.push({ field: f.name, type: parked.type, removed_at: parked.removed_at });
138
+ continue; // creating it would strand the parked values behind an empty twin
139
+ }
130
140
  let everywhere = true;
131
141
  // Tracked as a local, not re-read from `live`: a field created in THIS run
132
142
  // exists from its second context onward, and treating that second context
@@ -203,15 +213,19 @@ export async function applyCustomFieldsDeclaration(declaration, opts = {}) {
203
213
  return owner.error;
204
214
  const decl = { ...parsed.decl, entity: owner.name };
205
215
  const extension = customFieldsEntity(decl.entity);
206
- const meta = await extensionFields(extension);
216
+ const meta = await extensionFields(extension, { includeRemoved: true });
207
217
  const live = new Map();
218
+ const removed = new Map();
208
219
  for (const [name, row] of meta) {
209
- if (!row.deletedAt)
210
- live.set(name, String(row.type ?? ""));
220
+ const r = row;
221
+ if (!r.deletedAt)
222
+ live.set(name, String(r.type ?? ""));
223
+ else
224
+ removed.set(name, { type: String(r.type ?? ""), removed_at: String(r.deletedAt) });
211
225
  }
212
226
  const contexts = [...new Set(decl.fields.flatMap((f) => f.contexts.map(String)))];
213
227
  const offered = await readOffered(decl.entity, decl.context_field, contexts);
214
- const plan = diffDeclaration(decl, live, offered);
228
+ const plan = diffDeclaration(decl, live, offered, removed);
215
229
  // Where the table stands after convergence — a port of a long list is exactly
216
230
  // how a table is pushed past the cap (migrations.html: the cap "guards the API,
217
231
  // not migrations").
@@ -223,15 +237,22 @@ export async function applyCustomFieldsDeclaration(declaration, opts = {}) {
223
237
  quota = {};
224
238
  }
225
239
  if (!opts.confirm) {
240
+ // A declared field that exists only as a REMOVED one is not converged: nothing can be created
241
+ // for it, and "already matches the file" would be the opposite of the truth.
242
+ const parkedOnly = planIsEmpty(plan) && plan.parked.length > 0;
226
243
  return jsonResponse({
227
- status: planIsEmpty(plan) ? "already_converged" : "dry_run",
244
+ status: parkedOnly ? "parked_only" : planIsEmpty(plan) ? "already_converged" : "dry_run",
228
245
  plan,
229
246
  ...quota,
230
- next: planIsEmpty(plan)
231
- ? "Nothing to do — the tenant already matches the file."
232
- : "Re-call with confirm=true to apply. Nothing has been created yet.",
233
- note: "A field the file no longer lists is reported under not_declared and never removed: removing " +
234
- "one parks its column and reserves its name for good. Use suppa_remove_custom_field deliberately.",
247
+ next: parkedOnly
248
+ ? "Nothing can be created: every field the tenant lacks was REMOVED there (see parked). Restore " +
249
+ "it with suppa_restore_custom_field, or give it a new name in the file."
250
+ : planIsEmpty(plan)
251
+ ? "Nothing to do — the tenant already matches the file."
252
+ : "Re-call with confirm=true to apply. Nothing has been created yet.",
253
+ note: "A field the file no longer lists is reported under not_declared and never removed: use " +
254
+ "suppa_remove_custom_field deliberately.",
255
+ ...removedNote(plan),
235
256
  });
236
257
  }
237
258
  const applied = { created: [], linked: [] };
@@ -263,7 +284,7 @@ export async function applyCustomFieldsDeclaration(declaration, opts = {}) {
263
284
  applied.linked.push(l);
264
285
  }
265
286
  return jsonResponse({
266
- status: "converged",
287
+ status: plan.parked.length ? "converged_except_parked" : "converged",
267
288
  entity: decl.entity,
268
289
  extension,
269
290
  applied,
@@ -271,5 +292,19 @@ export async function applyCustomFieldsDeclaration(declaration, opts = {}) {
271
292
  unchanged: plan.unchanged.length,
272
293
  type_drift: plan.type_drift,
273
294
  not_declared: plan.not_declared,
295
+ ...removedNote(plan),
274
296
  });
275
297
  }
298
+ /** What to do about a declared field that was removed on the tenant — or nothing when there is none. */
299
+ function removedNote(plan) {
300
+ if (!plan.parked.length)
301
+ return {};
302
+ return {
303
+ parked: plan.parked,
304
+ parked_note: "These are declared but were REMOVED on the tenant, so they were not created: a new field with " +
305
+ "a removed field's name is an empty twin, and the removed one — values and all — can then not " +
306
+ "be restored while the twin lives. To bring one back with its values: " +
307
+ "suppa_restore_custom_field, then re-run this. To start it empty instead, give it a new name in " +
308
+ "the file.",
309
+ };
310
+ }