From 8e783e91b7f188a2f7a3ac246c776ab5d61581c8 Mon Sep 17 00:00:00 2001 From: leemour Date: Thu, 19 Nov 2026 14:02:08 +0100 Subject: [PATCH 1/3] fix(kit): the WordPress case syncs an Author's or Contributor's posts WordPress refuses an author or a contributor the pages list with a private status (HTTP 400, 403 inside), and the refusal failed the whole post sync. The case's pages call now names optional.needs on capabilities.edit_pages (cli-core 0.710.0) and checks edit_others_pages for a partial read; posts keep edit_others_posts. The content seed tests every call with optional.needs: a sign-in without that right never sends it (the fake would list it in refusals) and the sync completes with the gap. cli-core 0.707.0 -> 0.710.0. Co-Authored-By: Claude Opus 5.5 --- changes/fix-wordpress-content-roles.md | 6 ++++ .../config/src/content-contracts.test.ts | 27 +++++++++++++++++ .../from-config/wordpress/wirecat.config.ts | 29 +++++++++++++------ package.json | 2 +- pnpm-lock.yaml | 10 +++---- 5 files changed, 59 insertions(+), 15 deletions(-) create mode 100644 changes/fix-wordpress-content-roles.md diff --git a/changes/fix-wordpress-content-roles.md b/changes/fix-wordpress-content-roles.md new file mode 100644 index 0000000..5d973d7 --- /dev/null +++ b/changes/fix-wordpress-content-roles.md @@ -0,0 +1,6 @@ +### Fixed + +- **A content CLI made from a config syncs an Author's or Contributor's posts.** The WordPress case gives the pages + call `optional.needs` on `capabilities.edit_pages` (cli-core 0.710.0): WordPress refuses both roles the pages list, + and that refusal failed the whole post sync. Pages now check `edit_others_pages`, not `edit_others_posts`. A + content CLI's seed tests that a sign-in without a call's right never sends it and still completes its sync. diff --git a/kit/seeds/config/src/content-contracts.test.ts b/kit/seeds/config/src/content-contracts.test.ts index a237d34..863691a 100644 --- a/kit/seeds/config/src/content-contracts.test.ts +++ b/kit/seeds/config/src/content-contracts.test.ts @@ -139,3 +139,30 @@ it("sync before session start says to sign in, and sends nothing", async () => { expect(unsigned.json()).toMatchObject({ error: { code: "authentication_error" } }) expect(sent).toEqual([]) }) + +// A call a role may not make names its right in `optional.needs`: a sign-in without it never sends the call (the fake +// would list it in `refusals`), and the sync ends complete with that gap. +type Needs = { check: string; message: string } +const needs = Object.values(SOURCE.entities as Record) + .flat() + .flatMap((entity) => (entity.optional?.needs ? [entity.optional.needs] : [])) + +if (needs.length) + it("a sign-in without a call's right skips that call, says so, and the sync completes", async () => { + const keyring = memoryKeyring() + // A store of its own: the file's other tests sync every call's rows into the shared one. + const env = { MESSAGING_STORE: join(mkdtempSync(join(tmpdir(), "content-needs-")), "store.db") } + const started = await runCli(["personal", "session", "start", "--site", FAKE_SITE, "--login", login, "--json"], { + keyring, + service: fakeServiceApi(), + stdin: password, + }) + expect(started.code, started.err).toBe(0) + const fake = contentManifestFake(SOURCE, { api: API.manifest, lacks: needs.map((one) => one.check) }) + fakes.push(fake) + const synced = await runCli(["personal", "sync", "--json"], { keyring, service: fake, env }) + expect(synced.code, synced.err).toBe(0) + const report = synced.json().item as { state: string; gaps: { message: string }[] } + expect(report.state).toBe("complete") + expect(report.gaps.map((one) => one.message)).toEqual(expect.arrayContaining(needs.map((one) => one.message))) + }) diff --git a/kit/test/from-config/wordpress/wirecat.config.ts b/kit/test/from-config/wordpress/wirecat.config.ts index 383146c..7ec27c6 100644 --- a/kit/test/from-config/wordpress/wirecat.config.ts +++ b/kit/test/from-config/wordpress/wirecat.config.ts @@ -2,6 +2,7 @@ import { defineCli } from "@wirecat/cli-core/manifest" // WordPress's posts and pages: every status, sorted by id to list and by change time to sync. const STATUSES = "publish,future,draft,pending,private,trash" +const ME = { operation: "getWpV2UsersMe", query: { context: "edit", _fields: "capabilities" } } const posts = (operation: string, type: "post" | "page") => { const list = { operation, query: { context: "edit", status: STATUSES, per_page: 100, orderby: "id", order: "asc" } } return { @@ -44,15 +45,25 @@ const posts = (operation: string, type: "post" | "page") => { format: "wp-blocks" as const, fallback: { path: "content.rendered", format: "html" as const }, }, - optional: { - message: "the sign-in may not read every post: a contributor sees its own", - scope: "edit_others_posts", - requires: { - operation: "getWpV2UsersMe", - query: { context: "edit", _fields: "capabilities" }, - check: "capabilities.edit_others_posts", - }, - }, + optional: + type === "post" + ? { + message: "the sign-in may not read every post: an author or a contributor reads only its own", + scope: "edit_others_posts", + requires: { ...ME, check: "capabilities.edit_others_posts" }, + } + : { + message: "the sign-in may not read every page", + scope: "edit_others_pages", + requires: { ...ME, check: "capabilities.edit_others_pages" }, + // WordPress refuses an author or a contributor pages with a private status (HTTP 400, 403 inside). + needs: { + ...ME, + check: "capabilities.edit_pages", + message: "only an editor or administrator reads the pages", + scope: "edit_pages", + }, + }, } } diff --git a/package.json b/package.json index 65796c5..61fc329 100644 --- a/package.json +++ b/package.json @@ -91,7 +91,7 @@ }, "dependencies": { "@wirecat/cli-base": "0.123.0", - "@wirecat/cli-core": "0.707.0", + "@wirecat/cli-core": "0.710.0", "commander": "15.0.0", "valibot": "1.5.0", "yaml": "2.9.1" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1d1cdb8..d4954d0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -16,8 +16,8 @@ importers: specifier: 0.123.0 version: 0.123.0(@scalar/openapi-upgrader@0.4.6)(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5) '@wirecat/cli-core': - specifier: 0.707.0 - version: 0.707.0(@wirecat/cli-base@0.123.0(@scalar/openapi-upgrader@0.4.6)(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5))(commander@15.0.0)(typescript@7.0.2)(zod@4.6.7) + specifier: 0.710.0 + version: 0.710.0(@wirecat/cli-base@0.123.0(@scalar/openapi-upgrader@0.4.6)(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5))(commander@15.0.0)(typescript@7.0.2)(zod@4.6.7) commander: specifier: 15.0.0 version: 15.0.0 @@ -1207,8 +1207,8 @@ packages: '@wirecat/cli-core-sqlite@1.1.0': resolution: {integrity: sha512-GpGlh/dAIX/nblBYCdT6DfWSLFxav9mxxeELQAfEuw+QZdT9unKxbi5xa02s/s4JS1P7n0PQx2sCABj4FlMRNw==} - '@wirecat/cli-core@0.707.0': - resolution: {integrity: sha512-+8fERPdNxm5g+PZrk+B9DzYhTMTXFQYovzzG2XpTBZkpn5pCjKOu9solPZrCUAkyNmUssKhYHv+QvB/9Fmmmrw==} + '@wirecat/cli-core@0.710.0': + resolution: {integrity: sha512-cZ/eLpANwnL6JyDa/YmmRDCpNEKwbMLjE2OhGKLW8U6itxRCRjF64xYl6C30R9OpqFz/ZvkTLmNuzb+Iqrszwg==} engines: {node: ^22.16.0 || >=24} hasBin: true peerDependencies: @@ -3328,7 +3328,7 @@ snapshots: '@wirecat/cli-core-sqlite@1.1.0': {} - '@wirecat/cli-core@0.707.0(@wirecat/cli-base@0.123.0(@scalar/openapi-upgrader@0.4.6)(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5))(commander@15.0.0)(typescript@7.0.2)(zod@4.6.7)': + '@wirecat/cli-core@0.710.0(@wirecat/cli-base@0.123.0(@scalar/openapi-upgrader@0.4.6)(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5))(commander@15.0.0)(typescript@7.0.2)(zod@4.6.7)': dependencies: '@anthropic-ai/sdk': 1.3.0(zod@4.6.7) '@bomb.sh/tab': 0.0.22(commander@15.0.0) From 5afd85c426c5d6e4b18a120f601868c35b7fafc4 Mon Sep 17 00:00:00 2001 From: leemour Date: Thu, 19 Nov 2026 14:05:58 +0100 Subject: [PATCH 2/3] fix(kit): the WordPress case says their own, not its own Co-Authored-By: Claude Opus 5.5 --- kit/test/from-config/wordpress/wirecat.config.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kit/test/from-config/wordpress/wirecat.config.ts b/kit/test/from-config/wordpress/wirecat.config.ts index 7ec27c6..c168d90 100644 --- a/kit/test/from-config/wordpress/wirecat.config.ts +++ b/kit/test/from-config/wordpress/wirecat.config.ts @@ -48,7 +48,7 @@ const posts = (operation: string, type: "post" | "page") => { optional: type === "post" ? { - message: "the sign-in may not read every post: an author or a contributor reads only its own", + message: "the sign-in may not read every post: an author or a contributor reads only their own", scope: "edit_others_posts", requires: { ...ME, check: "capabilities.edit_others_posts" }, } From 3bdaf1e0535fb43aab1fe583d8c5a4961798f72e Mon Sep 17 00:00:00 2001 From: leemour Date: Thu, 19 Nov 2026 14:13:02 +0100 Subject: [PATCH 3/3] test(contracts): help lists wordpress under Works with (cli-core 0.710.0) Co-Authored-By: Claude Opus 5.5 --- contracts/help.snap | 1 + 1 file changed, 1 insertion(+) diff --git a/contracts/help.snap b/contracts/help.snap index 4e2feae..bd3c87f 100644 --- a/contracts/help.snap +++ b/contracts/help.snap @@ -17,6 +17,7 @@ Works with: pbx Asterisk PBX calls and recordings, searchable with your other WireCat data notion Notion pages and databases as local text, searchable with your other WireCat data ydisk Yandex Disk folders as local text, searchable with your other WireCat data + wordpress WordPress posts and pages, searchable with your other WireCat data Next: clidev commands every command, by section clidev help options output, offline, timeouts, dry run