@thecms/cli 0.20.1-dev.125 → 0.20.1-dev.126

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.
@@ -175,7 +175,7 @@ function realContext(env = process.env) {
175
175
  import { parseArgs } from "util";
176
176
 
177
177
  // src/context.ts
178
- var CLI_VERSION = "0.20.1-dev.125";
178
+ var CLI_VERSION = "0.20.1-dev.126";
179
179
  function call(ctx, path, init = {}) {
180
180
  const { token, client = "cli", ...rest } = init;
181
181
  const headers = new Headers(rest.headers);
@@ -3597,7 +3597,7 @@ function diffSet(present, wanted, ids) {
3597
3597
  if (changed) touched = true;
3598
3598
  else plan.keep.push(`shape ${want.shape}`);
3599
3599
  }
3600
- for (const s of present.shapes ?? []) if (!wanted.shapes.some((w) => w.shape === s.id)) plan.keep.push(`shape ${s.id} (not in the wanted set: never removed here)`);
3600
+ for (const s of present.shapes ?? []) if (!wanted.shapes.some((w) => w.shape === s.id) && !wanted.remove?.includes(s.id)) plan.keep.push(`shape ${s.id} (not in the wanted set: never removed here)`);
3601
3601
  if (touched) update.shapes = shapes;
3602
3602
  }
3603
3603
  if (wanted.slots) {
@@ -5463,7 +5463,31 @@ async function applySet(session, input) {
5463
5463
  if (titles.some((t) => !t.trim())) diff.refused.push("presets: each needs its title (how it is found again)");
5464
5464
  if (new Set(titles).size !== titles.length) diff.refused.push("presets: two with the same title");
5465
5465
  }
5466
- return settle(type === "entity" ? `set ${slug}` : `container ${slug}`, confirm, diff.plan, diff.refused, async (written) => {
5466
+ const blocked = [];
5467
+ const freed = [];
5468
+ for (const name of [...new Set(wanted.remove ?? [])]) {
5469
+ if (wanted.shapes?.some((s) => s.shape === name)) {
5470
+ diff.refused.push(`remove: shape ${name} is also in shapes`);
5471
+ continue;
5472
+ }
5473
+ if (!present?.shapes?.some((s) => s.id === name)) {
5474
+ diff.plan.keep.push(`shape ${name}: already gone`);
5475
+ continue;
5476
+ }
5477
+ const impact = await session.send("POST", "/impact", { target: { kind: "shape", widget: present.id, shape: name } });
5478
+ const ref = (r) => [r.source, r.path].filter(Boolean).join(" ");
5479
+ if (impact.blocking.length) {
5480
+ blocked.push(...impact.blocking.map((b) => `shape ${name} stays: ${ref(b)} uses it \u2014 move that block to another shape first`));
5481
+ continue;
5482
+ }
5483
+ freed.push(name);
5484
+ diff.plan.change.push(`REMOVE shape ${name}`, ...impact.fixable.map((f) => `shape ${name}: ${ref(f)} goes with it`));
5485
+ }
5486
+ if (freed.length && present) {
5487
+ const shapes = (diff.update?.shapes ?? present.shapes ?? []).filter((s) => !freed.includes(s.id));
5488
+ diff.update = { ...diff.update ?? {}, shapes };
5489
+ }
5490
+ const answer2 = await settle(type === "entity" ? `set ${slug}` : `container ${slug}`, confirm, diff.plan, diff.refused, async (written) => {
5467
5491
  if (diff.create) {
5468
5492
  const made = await session.send("POST", "/widgets", diff.create);
5469
5493
  if (wanted.presets?.length) await session.send("PUT", `/widgets/${enc2(made.id)}`, { presets: wanted.presets.map((p) => ({ widget: made.id, ...p })) });
@@ -5474,6 +5498,8 @@ async function applySet(session, input) {
5474
5498
  written.push(...diff.plan.create, ...diff.plan.change);
5475
5499
  }
5476
5500
  }, "Written: in force at once \u2014 a set has no draft; the pages that place it deliver it so (the site's answers are kept up to 60 s)");
5501
+ if (!blocked.length) return answer2;
5502
+ return { ...answer2, refused: [...answer2.refused, ...blocked], note: `${answer2.note} \u2014 ${blocked.length} shape(s) stay: a block uses them` };
5477
5503
  }
5478
5504
  async function applyPage(session, input) {
5479
5505
  const known = await names(session);
@@ -10153,11 +10179,15 @@ async function remove(session, input) {
10153
10179
  path = `/layouts/${enc4(input.id)}`;
10154
10180
  what = `layout ${input.id}`;
10155
10181
  break;
10156
- case "set":
10157
- target = { kind: "widget", id: input.id };
10158
- path = `/widgets/${enc4(input.id)}`;
10182
+ case "set": {
10183
+ const sets = await session.ws("/widgets");
10184
+ const set = sets.find((w) => w.entity === input.id || w.slug === input.id || w.name === input.id || w.id === input.id);
10185
+ if (!set) return settle("delete", false, plan, [`No set ${input.id}`], async () => void 0, "");
10186
+ target = { kind: "widget", id: set.id };
10187
+ path = `/widgets/${enc4(set.id)}`;
10159
10188
  what = `set ${input.id}`;
10160
10189
  break;
10190
+ }
10161
10191
  case "file":
10162
10192
  target = { kind: "asset", id: input.id };
10163
10193
  path = input.forever ? `/assets/${enc4(input.id)}/hard` : `/assets/${enc4(input.id)}`;
@@ -12455,12 +12485,13 @@ async function createMcp(ctx, opts = {}) {
12455
12485
  annotations: write
12456
12486
  }, guarded(planned("apply_schema", "A new schema is published as version 1; a change to one already there goes to its draft (publish makes it in force); nothing is deleted and calling again changes nothing", (input) => applySchema(session, input)))));
12457
12487
  gated.push(server.registerTool("apply_set", {
12458
- description: "A set as wanted: DESIGNING A SHAPE, decide from its context whether the visitor submits something (a request for an appointment, a booking, a candidacy, a review, a contact request): then the shape says `writes` (the schema its submissions create, and whether the person wants other limits than 3 per visitor per 10 minutes and 300 per hour) \u2014 ask the person when it is not clear; the plan prepares the workspace for the site's server (never a file of the site's code). The set of a schema's records (one per schema) with its shapes, each shape's own fields, the record fields it delivers and, for each relation, which fields of the related record travel (relations \u2014 a menu's items: label, link and their own menu_items; an article's author: name, role, photo); or a container (by name) with its slots \u2014 ONLY slots: a container has no shapes and no fields, what a page shows is a record, in a set's block, in a slot (a plan with shapes or without a slot is refused). A container is found by its address (the name's slug): a new name changes the name, never the address. Shapes, fields and relations left out stay. In force at once (a set has no draft). Without confirm: the plan only",
12488
+ description: "A set as wanted: DESIGNING A SHAPE, decide from its context whether the visitor submits something (a request for an appointment, a booking, a candidacy, a review, a contact request): then the shape says `writes` (the schema its submissions create, and whether the person wants other limits than 3 per visitor per 10 minutes and 300 per hour) \u2014 ask the person when it is not clear; the plan prepares the workspace for the site's server (never a file of the site's code). The set of a schema's records (one per schema) with its shapes, each shape's own fields, the record fields it delivers and, for each relation, which fields of the related record travel (relations \u2014 a menu's items: label, link and their own menu_items; an article's author: name, role, photo); or a container (by name) with its slots \u2014 ONLY slots: a container has no shapes and no fields, what a page shows is a record, in a set's block, in a slot (a plan with shapes or without a slot is refused). A container is found by its address (the name's slug): a new name changes the name, never the address. Shapes, fields and relations left out stay; `remove` lists the shapes to take out, by name (one already gone is left as it is): the plan says who places each (pages, drafts, layouts, presets) \u2014 a shape a block places is never removed, the free ones are. In force at once (a set has no draft). Without confirm: the plan only",
12459
12489
  inputSchema: {
12460
12490
  type: z.enum(["entity", "container"]).optional().describe("entity (default): records of a schema; container: only other sets in its slots, never shapes or fields"),
12461
12491
  schema: z.string().optional(),
12462
12492
  name: z.string().optional().describe("a container's name (its address is its slug and stays); a set of records' display name"),
12463
12493
  shapes: z.array(z.object({ shape: z.string(), fields: z.array(z.object({ name: z.string(), type: z.string(), fields: z.array(z.object({ name: z.string(), type: z.string() })).optional().describe("type list: kept only on a shape that already has it as it is; a new or changed list is refused \u2014 repeated items are records of a schema") })).optional().describe("the shape's own fields: a value's type. Repeated items (cards, steps, stats, logos) are records of a schema, shown by their set \u2014 neither list nor json is declared on a shape"), applications: z.array(z.string()).optional().describe("application slugs; none = every one"), writes: SHAPE_WRITES.optional() })).optional(),
12494
+ remove: z.array(z.string()).optional().describe("shapes to take out of the set, by name: only a shape no page or layout places is removed (the plan lists the blocks that stay), its presets go with it; one already gone changes nothing. A rename is: add the new shape, move the blocks, then remove the old one"),
12464
12495
  delivers: z.array(z.string()).optional().describe("the record fields the blocks deliver"),
12465
12496
  relations: z.record(z.string(), RELATION).optional().describe("relation field \u2192 which fields of the related record travel ({ fields, limit, relations } \u2014 nested relations such as a menu item's menu_items up to 3 levels); a relation not here travels as ids only. Each relation given replaces its own tree; the others stay"),
12466
12497
  presets: z.array(z.object({
@@ -12479,7 +12510,7 @@ async function createMcp(ctx, opts = {}) {
12479
12510
  confirm
12480
12511
  },
12481
12512
  annotations: write
12482
- }, guarded(planned("apply_set", "A set is in force at once (no draft): only what differs is written, nothing is deleted and calling again changes nothing", (input) => writesIn(input) ? applySetWrites(session, input) : applySet(session, input)))));
12513
+ }, guarded(planned("apply_set", "A set is in force at once (no draft): only what differs is written, nothing is deleted but the shapes `remove` names (a shape in use stays) and calling again changes nothing", (input) => writesIn(input) ? applySetWrites(session, input) : applySet(session, input)))));
12483
12514
  gated.push(server.registerTool("apply_page", {
12484
12515
  description: "A page of an application as wanted (found by its slug): title, SEO, layout, the blocks as set \xB7 shape, and its translations \u2014 written to the page's draft (publish makes it public). A translation is compared with the page as read in that language: one identical to the page in the default language is not written (it would change nothing a reader sees). Without confirm: the plan only",
12485
12516
  inputSchema: {
@@ -12755,7 +12786,7 @@ async function createMcp(ctx, opts = {}) {
12755
12786
  annotations: write
12756
12787
  }, guarded(planned("grant_access", "The reader's access changes at once", (input) => grantAccess(session, input)))));
12757
12788
  gated.push(server.registerTool("delete", {
12758
- description: "Deletes a record (to the trash, 30 days), a page, a layout, a set, a file, a product or a schema (id = its name; only without records \u2014 irreversible, the relations pointing at it go with it); and, by the name a person uses: an application (its slug; only without pages), a role (its name; never a system role), a pending invitation (the email), a member (the email; never the owner, never yourself), an API key (its name), a readers' sign-in method (its key), a webhook (its address or id), an inbound notice (hook: its name). A record with version: that one old version leaves its history; a file with forever: removed for good from the storage \u2014 the plan first: what goes with it and what blocks it (blocking: nothing deleted). Without confirm: the plan only",
12789
+ description: "Deletes a record (to the trash, 30 days), a page, a layout, a set (id = its name as `sets` shows it: the schema, or a container's name; the plan lists the blocks that place it), a file, a product or a schema (id = its name; only without records \u2014 irreversible, the relations pointing at it go with it); and, by the name a person uses: an application (its slug; only without pages), a role (its name; never a system role), a pending invitation (the email), a member (the email; never the owner, never yourself), an API key (its name), a readers' sign-in method (its key), a webhook (its address or id), an inbound notice (hook: its name). A record with version: that one old version leaves its history; a file with forever: removed for good from the storage \u2014 the plan first: what goes with it and what blocks it (blocking: nothing deleted). Without confirm: the plan only",
12759
12790
  inputSchema: {
12760
12791
  kind: z.enum(["record", "page", "layout", "set", "file", "product", "schema", "application", "role", "invite", "member", "api_key", "sign_in_method", "webhook", "hook"]),
12761
12792
  id: z.string(),
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  run
4
- } from "./chunk-4QKB6PKR.js";
4
+ } from "./chunk-CI6BYK5Z.js";
5
5
 
6
6
  // src/cli.ts
7
7
  run(process.argv.slice(2)).then((code) => process.exit(code)).catch((err) => {
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  personalToken,
4
4
  run
5
- } from "./chunk-4QKB6PKR.js";
5
+ } from "./chunk-CI6BYK5Z.js";
6
6
  export {
7
7
  personalToken,
8
8
  run
@@ -212,6 +212,7 @@ A page's block reads the workspace as its set, shape and settings say; the model
212
212
  - `{context.<field>}` is the open record's value (a link → its id; a link to many → `in`); `{context._id}` is the open record itself: with `neq` it never lists itself. They hold only on a template page (a page of a record).
213
213
  - A relation of a schema with itself is **only** a tree. A "related" relation of a schema to itself (`related_services`) is a mistake the plan of `apply_schema` points at (structures: `related`).
214
214
  - Repeated items (cards, steps, numbers, logos) are records of a schema, in the editor's order (`position`); a block's shape holds only what holds in that place of the page.
215
+ - A shape is never renamed in place: add the new one to the set (`apply_set`), move the blocks of pages, layouts and presets to it as drafts and publish them site by site once the site's code knows the new name, then remove the old one (`apply_set` with `remove`: refused while a block, even only a published one, still uses it). For example `menu · header` → `menu · navbar`.
215
216
  <!-- src: packages/presentation/src/resolver/widget-resolver.ts resolveQueryPlaceholders (`{context.<field>}`, `_id` included; eq/neq on a list → in/nin); packages/api/tests/integration/presentation/context-id-neq.test.ts; docs/internal/invariants/relations.md (MODEL-FOR-PRESENTATION, D496 descendantsOf); packages/cli/src/mcp/structures.ts (related, menu, categories); packages/core/src/shape-values.ts (a shape's list field); docs/internal/invariants/field-formats.md -->
216
217
 
217
218
  ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecms/cli",
3
- "version": "0.20.1-dev.125",
3
+ "version": "0.20.1-dev.126",
4
4
  "license": "UNLICENSED",
5
5
  "description": "theCMS. command line: the standard's starter, checks, brand, the method's docs, sign-in with a personal token",
6
6
  "type": "module",
@@ -36,7 +36,7 @@
36
36
  "dependencies": {
37
37
  "@modelcontextprotocol/sdk": "1.32.1",
38
38
  "@resvg/resvg-wasm": "2.6.2",
39
- "@thecms/sdk": "0.20.1-dev.125",
39
+ "@thecms/sdk": "0.20.1-dev.126",
40
40
  "libpg-query": "18.2.0",
41
41
  "zod": "4.6.5"
42
42
  },