diff --git a/changes/release-1.0.md b/changes/release-1.0.md new file mode 100644 index 0000000..066c832 --- /dev/null +++ b/changes/release-1.0.md @@ -0,0 +1,22 @@ +### Changed — may break callers + +- **mail builds on cli-core 1.0.0 and cli-base 1.0.0.** The store moves to version 73 on its first open: an id is never + handed out twice, and only tools on cli-core 1.0 open the store after that. Upgrade every installed WireCat CLI + before you run this version. The migration writes a rollback copy first and refuses to run without one. +- **An MCP call that names a refused place answers `permission_error`**, not `validation_error`. Before any MCP call + runs, each option and argument that takes a local file or folder is checked by its real path: a call cannot name a + credential folder, a folder of a WireCat tool or the message store. A shell run is unchanged. +- **`schedule exec` is no longer offered over MCP.** It runs only a schedule file in the tool's own schedules folder. + An agent runs a saved schedule with `schedule run `. +- **An unreadable config file now answers `config.unreadable`**, not `mail.config-unreadable`: the one name the + WireCat family uses for it. + +### Fixed + +- **A sync no longer marks mail deleted that the server's search found and its listing left out.** When a folder's + listing returns fewer messages than its search, the run skips the deletion check and says why in + `deletionsSkipped`. +- **A mailbox folder named over MCP stays the server's name.** `--folder` of `sync`, `session start`, + `account inspect`, `messages move`, `messages copy` and `messages export`, and the folder of `folders create`, + `folders rename` and `folders delete`, name a folder on the mail server, not on this computer, so `serve` passes + them on as given. diff --git a/package.json b/package.json index 232c111..5bf7882 100644 --- a/package.json +++ b/package.json @@ -58,8 +58,8 @@ "docs:spell": "cspell lint --config cspell.json --no-progress --no-summary README.md SECURITY.md CHANGELOG.md AGENTS.md CLAUDE.md 'docs/*.md' 'skills/**/*.md'" }, "dependencies": { - "@wirecat/cli-base": "0.125.1", - "@wirecat/cli-core": "0.753.0", + "@wirecat/cli-base": "1.0.0", + "@wirecat/cli-core": "1.0.0", "commander": "15.0.0", "imapflow": "2.9.1", "nodemailer": "10.1.7", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cabff98..9a1f9f0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -13,11 +13,11 @@ importers: .: dependencies: '@wirecat/cli-base': - specifier: 0.125.1 - version: 0.125.1(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5) + specifier: 1.0.0 + version: 1.0.0(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5) '@wirecat/cli-core': - specifier: 0.753.0 - version: 0.753.0(@wirecat/cli-base@0.125.1(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: 1.0.0 + version: 1.0.0(@wirecat/cli-base@1.0.0(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 @@ -1183,16 +1183,16 @@ packages: '@wasm-audio-decoders/opus-ml@0.0.3': resolution: {integrity: sha512-SEeTmk0eb3q5etJA/NHCRWW6BivTx9tqvNTmG0kg2ynuATEQRUZnwQE6Ibvl1BBvqIGHqI57+qyJMWmJBwb5XQ==} - '@wirecat/cli-base@0.125.1': - resolution: {integrity: sha512-EsVQeaHXP2I8+sRP7Mkg8qgLOzYDItPVzKParRt38SWJdPXpxWuQTIV3nq8rCIe5qc7BLfsyB6vLD0/YX8nDCQ==} - engines: {node: '>=22'} + '@wirecat/cli-base@1.0.0': + resolution: {integrity: sha512-PJ61d6z0CsWOmoWgf7uvlEo3EstpL2DplXiORPIqgmh0bn/ZGMOhRpDqN43Kh7WickaFSmeX74YQigHXkRO6rA==} + engines: {node: ^22.16.0 || >=24} hasBin: true peerDependencies: '@scalar/openapi-upgrader': ^0.4.6 - commander: '>=15' + commander: ^15.0.0 esbuild: ^0.28.0 swagger-converter: ^2.1.0 - vitest: '>=5' + vitest: ^5.0.0 peerDependenciesMeta: '@scalar/openapi-upgrader': optional: true @@ -1211,14 +1211,14 @@ packages: '@wirecat/cli-core-sqlite@1.1.0': resolution: {integrity: sha512-GpGlh/dAIX/nblBYCdT6DfWSLFxav9mxxeELQAfEuw+QZdT9unKxbi5xa02s/s4JS1P7n0PQx2sCABj4FlMRNw==} - '@wirecat/cli-core@0.753.0': - resolution: {integrity: sha512-jW9Sc/eDgRTmFvP+8Mc7+lyqwtuVZwphKkfCGi9H6t6RvBzfQOOIrSVN3lyVD21mChTGtOrRFRoWHQkPfI+UgQ==} + '@wirecat/cli-core@1.0.0': + resolution: {integrity: sha512-0avQTqu3FAFKE0s+8Pz1Up/TMHTYqCdDn37lcZmkH30sMCMrgJwHzoG4Q0fjVzPsB85u+zBVHHhtQjF/eSTpuw==} engines: {node: ^22.16.0 || >=24} hasBin: true peerDependencies: '@napi-rs/canvas': '>=0.1.69 <2' - '@wirecat/cli-base': '>=0.125.0 <1.0.0' - commander: '>=15' + '@wirecat/cli-base': ^1.0.0-0 + commander: ^15.0.0 mysql2: ^3.24.6 pg: ^8.23.1 ssh2: ^1.17.0 @@ -3402,7 +3402,7 @@ snapshots: dependencies: '@wasm-audio-decoders/common': 9.0.7 - '@wirecat/cli-base@0.125.1(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5)': + '@wirecat/cli-base@1.0.0(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5)': dependencies: '@valibot/to-json-schema': 1.8.0(valibot@1.5.0(typescript@7.0.2)) cli-table3: 0.6.5 @@ -3423,7 +3423,7 @@ snapshots: '@wirecat/cli-core-sqlite@1.1.0': {} - '@wirecat/cli-core@0.753.0(@wirecat/cli-base@0.125.1(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@1.0.0(@wirecat/cli-base@1.0.0(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) @@ -3433,7 +3433,7 @@ snapshots: '@valibot/to-json-schema': 1.8.0(valibot@1.5.0(typescript@7.0.2)) '@wasm-audio-decoders/flac': 0.2.11 '@wasm-audio-decoders/ogg-vorbis': 0.1.20 - '@wirecat/cli-base': 0.125.1(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5) + '@wirecat/cli-base': 1.0.0(commander@15.0.0)(esbuild@0.28.2)(typescript@7.0.2)(vitest@5.0.5) '@wirecat/cli-core-onnx': 1.2.0 '@wirecat/cli-core-sqlite': 1.1.0 '@xmldom/xmldom': 0.9.12 diff --git a/src/commands/export.ts b/src/commands/export.ts index 78a7517..53d5462 100644 --- a/src/commands/export.ts +++ b/src/commands/export.ts @@ -15,7 +15,7 @@ import { } from "@wirecat/cli-core/cli" import { type Quick, searchMail } from "@wirecat/cli-core/mail" import { refusedPlace } from "@wirecat/cli-core/sends" -import type { FolderEmail } from "@wirecat/cli-core/store" +import type { FolderEmail } from "@wirecat/cli-core/store/areas" import { Command, Option } from "commander" import * as v from "valibot" import { configuration } from "../config.js" diff --git a/src/commands/messages.ts b/src/commands/messages.ts index c5e887e..3a4e91c 100644 --- a/src/commands/messages.ts +++ b/src/commands/messages.ts @@ -1,7 +1,7 @@ import { CliError } from "@wirecat/cli-base" import { annotate } from "@wirecat/cli-base/commands" import { timezoneOf, zonedMoment } from "@wirecat/cli-base/query" -import { answerEntity, envName, REMOTE_WRITE } from "@wirecat/cli-core/cli" +import { answerEntity, envName, notLocalPaths, REMOTE_WRITE } from "@wirecat/cli-core/cli" import { decide, factsOf, listedOf, type MailRule, storedMailRules } from "@wirecat/cli-core/mail" import { Command } from "commander" import { IDENTITY } from "../identity.js" @@ -332,8 +332,8 @@ export const messageWrites = (): Command[] => [ flagCommand("star", "star messages (the \\Flagged flag)", { add: ["\\Flagged"], remove: [] }, REF), flagCommand("unstar", "take the star away", { add: [], remove: ["\\Flagged"] }, REF), updateCommand(), - moveCommand("move"), - moveCommand("copy"), + notLocalPaths(moveCommand("move"), "folder"), + notLocalPaths(moveCommand("copy"), "folder"), deleteCommand(), restoreCommand(), ] diff --git a/src/commands/read.ts b/src/commands/read.ts index 7117ee3..bb83c47 100644 --- a/src/commands/read.ts +++ b/src/commands/read.ts @@ -1,6 +1,6 @@ import { existsSync } from "node:fs" import { CliError } from "@wirecat/cli-base" -import { baseContext } from "@wirecat/cli-core/cli" +import { baseContext, notLocalPaths } from "@wirecat/cli-core/cli" import { mailAccountKey, readEmailWhole } from "@wirecat/cli-core/mail" import { type MailReads, mailInboxCommand, mailReadCommands } from "@wirecat/cli-core/mail/cli" import { storePath } from "@wirecat/cli-core/store" @@ -70,7 +70,7 @@ export const readCommands = () => { const commands = mailReadCommands(reads) commands .find((command) => command.name() === "messages") - ?.addCommand(exportLeaf()) + ?.addCommand(notLocalPaths(exportLeaf(), "folder")) .addCommand(importLeaf()) // mail has no `models` group: the AI model is chosen with memo or WireCat Desktop. return [...commands, mailInboxCommand(reads, { modelsCommand: "memo" })] diff --git a/src/commands/session.ts b/src/commands/session.ts index 34e2728..ea1c809 100644 --- a/src/commands/session.ts +++ b/src/commands/session.ts @@ -8,6 +8,7 @@ import { LOCAL_WRITE, listOf, logsInOrOut, + notLocalPaths, outputFor, profileFree, profilesHere, @@ -227,7 +228,7 @@ const listCommand = () => export const sessionCommand = (): Command => annotate(new Command("session"), { effects: LOCAL_READ }) .description("keep this profile's app password in the OS keyring") - .addCommand(sessionStartCommand()) + .addCommand(notLocalPaths(sessionStartCommand(), "folder")) .addCommand(statusCommand()) .addCommand(endCommand()) .addCommand(listCommand()) diff --git a/src/commands/tags.ts b/src/commands/tags.ts index 5613a93..699d567 100644 --- a/src/commands/tags.ts +++ b/src/commands/tags.ts @@ -14,7 +14,8 @@ import { termField, withQuery, } from "@wirecat/cli-core/cli" -import type { AccountKey, MessageStore, TagTarget } from "@wirecat/cli-core/store" +import type { AccountKey, MessageStore } from "@wirecat/cli-core/store" +import type { TagTarget } from "@wirecat/cli-core/store/areas" import { Command } from "commander" import * as v from "valibot" import { IDENTITY } from "../identity.js" diff --git a/src/commands/words.ts b/src/commands/words.ts index 74be765..56a35f1 100644 --- a/src/commands/words.ts +++ b/src/commands/words.ts @@ -17,7 +17,7 @@ const WORDS: Record `${message}; to let an agent mail others: ${IDENTITY.command} ${profile} config set permissions.${SEND_OTHERS_KEY} allow`, "mail.no-submission": (message, profile) => `${message} with ${run(profile, "config set")}`, - "mail.config-unreadable": (message) => `${message}; run \`${IDENTITY.command} doctor\``, + "config.unreadable": (message) => `${message}; run \`${IDENTITY.command} doctor\``, "mail.profile-exists": (message) => `${message}; pass --replace to overwrite it`, "download.exists": (message) => `${message}; pass --replace to overwrite it`, "mail.server-unknown": (message) => diff --git a/src/profile.ts b/src/profile.ts index 7fdf4cd..de0364a 100644 --- a/src/profile.ts +++ b/src/profile.ts @@ -34,7 +34,7 @@ export const writeProfile = ( const path = configPath(env) const read = readConfigFile(path) if ("issue" in read) - throw new CliError("configuration_error", `${path} cannot be read`, { reason: "mail.config-unreadable" }) + throw new CliError("configuration_error", `${path} cannot be read`, { reason: "config.unreadable" }) const config = isRecord(read.raw) ? read.raw : {} const profiles = isRecord(config.profiles) ? config.profiles : {} const existed = name in profiles diff --git a/src/program.ts b/src/program.ts index 33b73f9..b5e8375 100644 --- a/src/program.ts +++ b/src/program.ts @@ -9,6 +9,7 @@ import { createProgram as createSharedProgram, environmentOf, type GlobalFlags, + notLocalPaths, outputFor, type ProgramDefinition, type ProgramOptions, @@ -64,9 +65,9 @@ export const definition = (): ProgramDefinition => ({ commands: () => [ commandsCommand(IDENTITY), sessionCommand(), - accountCommand(), - foldersCommand(), - syncCommand(), + notLocalPaths(accountCommand(), "folder"), + notLocalPaths(foldersCommand(), "folder"), + notLocalPaths(syncCommand(), "folder"), rulesCommand(), statusCommand(), ...withWrites(readCommands()), diff --git a/src/reasons.ts b/src/reasons.ts index 44cbf6e..aa36bb3 100644 --- a/src/reasons.ts +++ b/src/reasons.ts @@ -39,7 +39,6 @@ const ENTRIES: [reason: string, code: string, message: string][] = [ ["mail.original-gone", "not_found", "the message is not where the store last saw it on the server"], ["mail.others-for-agent", "permission_error", "over MCP the profile mails only its owner"], ["mail.no-submission", "configuration_error", "the profile names no submission server"], - ["mail.config-unreadable", "configuration_error", "the config file cannot be read"], ["mail.profile-exists", "validation_error", "a profile of this name already exists"], ["mail.server-unknown", "not_found", "no mail server was found for the address's domain"], ["mail.export-other", "validation_error", "the export folder holds an export of another format or mailbox"], diff --git a/src/send.test.ts b/src/send.test.ts index c2160e8..e577e7b 100644 --- a/src/send.test.ts +++ b/src/send.test.ts @@ -848,7 +848,8 @@ describe("sending over MCP", { timeout: 20_000 }, () => { ) const refused = await send({ file: key }) expect(refused.isError).toBe(true) - expect(JSON.stringify(refused.content)).toContain("--allow-any-file") + expect(JSON.stringify(refused.content)).toContain("permission_error") + expect(JSON.stringify(refused.content)).toContain("access.denied") expect((await send({ file: key, allow_any_file: true })).isError).toBe(true) } finally { expect(await close()).toBe(0)