Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions changes/release-1.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
### Changed — may break callers

- **drive runs on cli-core 1.0 and cli-base 1.0** (cli-core 1.0.0, was 0.750.0; cli-base 1.0.0, was 0.132.0).
cli-core 1.0 moves the message store to version 74 the first time it opens it: an id is never handed out twice,
and a JSON column holds valid JSON. After that, only tools on cli-core 1.0 open the store. Watch for: upgrade every
installed WireCat CLI to its 1.0 release first, and stop `serve`, `mcp` and every sync while the store migrates;
the migration writes a rollback copy first and refuses to run without one. See
[cli-core's changelog](https://github.com/WireCatLabs/cli-core/blob/main/CHANGELOG.md).

### Fixed

- **Over MCP, a Drive file or folder is passed as the agent wrote it.** The file id or URL of `drive files get`,
`copy`, `move`, `trash`, `download` and `export`, of `drive comments`, `permissions`, `revisions` and
`activities`, the folder of `drive catalog tree`, and the command path of `drive commands` were made absolute
against the client's folder, as if they named a file on this computer.

### Security

- **An MCP call cannot name a credential folder, a WireCat tool's folder or the message store.** Every option and
argument that takes a local file or folder (`drive files upload <path>`, `drive files download --output`,
`--body-file` and the rest) is checked by its real path before the call runs, so neither a link nor `..` gets
past. A refused call answers `permission_error` (`access.denied`) with the option in `param`. A run in a terminal
is unchanged.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@
"@googleapis/drive": "27.0.0",
"@googleapis/driveactivity": "11.0.1",
"@googleapis/sheets": "18.1.1",
"@wirecat/cli-base": "0.132.0",
"@wirecat/cli-core": "0.750.0",
"@wirecat/cli-base": "1.0.0",
"@wirecat/cli-core": "1.0.0",
"commander": "15.0.0",
"google-auth-library": "11.3.1",
"mammoth": "1.13.0",
Expand Down
32 changes: 16 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/api-contract.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CliError } from "@wirecat/cli-base"
import type { ManifestOperation } from "@wirecat/cli-base/codegen"
import type { ManifestOperation } from "@wirecat/cli-base/codegen/runtime"
import { apiJson, apiPlainJson, checkApiBody, checkApiParameter, parseApiJson } from "@wirecat/cli-core/cli"
import { operations } from "./generated/manifest.js"
import { schemas } from "./generated/schemas.js"
Expand Down
2 changes: 1 addition & 1 deletion src/catalog.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CatalogEntry, CatalogInput, CatalogQuery } from "@wirecat/cli-core/store"
import type { CatalogEntry, CatalogInput, CatalogQuery } from "@wirecat/cli-core/store/areas"
import { type FileMetadata, FOLDER } from "./model.js"

export const catalogInput = (file: FileMetadata): CatalogInput => ({
Expand Down
4 changes: 4 additions & 0 deletions src/commands/catalog.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { notLocalPaths } from "@wirecat/cli-core/cli"
import { addDocumentCatalogCommands } from "@wirecat/cli-core/documents/cli"
import type { Command } from "commander"
import { catalogFiles } from "../catalog.js"
Expand Down Expand Up @@ -52,4 +53,7 @@ export const installCatalogCommands = (program: Command, helpers: Helpers) => {
id: fileId,
roots: () => activeProfile(env, selected()).roots,
})
// cli-core marks only catalog's <file>; `catalog tree [folder]` takes a Drive folder too.
const catalog = program.commands.find((command) => command.name() === "catalog")
if (catalog) notLocalPaths(catalog, "folder")
}
5 changes: 4 additions & 1 deletion src/commands/discovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
DISCOVERY_DESCRIPTIONS,
environmentOf,
NO_EFFECTS,
notLocalPaths,
sharedCommandTemplate,
} from "@wirecat/cli-core/cli"
import type { Command } from "commander"
Expand All @@ -15,7 +16,9 @@ import type { CommandContext } from "./context.js"

const installCommandsCommandDefinition = (program: Command, { print, streams }: CommandContext) => {
examples(
annotate(program.command("commands"), { effects: NO_EFFECTS }).description(DISCOVERY_DESCRIPTIONS.commands),
notLocalPaths(annotate(program.command("commands"), { effects: NO_EFFECTS }), "path").description(
DISCOVERY_DESCRIPTIONS.commands,
),
["drive commands", "drive commands files copy --json"],
)
.argument("[path...]", "only this command or group, as words")
Expand Down
12 changes: 7 additions & 5 deletions src/commands/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
LOCAL_READ,
listOf,
NO_EFFECTS,
notLocalPaths,
queryTerms,
readApiBody,
snakeKeys,
Expand Down Expand Up @@ -170,7 +171,7 @@ export const installRemoteCommands = (program: Command, helpers: RemoteCommands)
api.addCommand(child)
}
installSheetsCommands(program, helpers)
const files = annotate(program.command("files"), { effects: GOOGLE_READ }).description(
const files = notLocalPaths(annotate(program.command("files"), { effects: GOOGLE_READ }), "file").description(
"read and change files in Google Drive; nothing is imported",
)
for (const exporting of [false, true]) {
Expand Down Expand Up @@ -426,9 +427,10 @@ export const installRemoteCommands = (program: Command, helpers: RemoteCommands)
.action(async (id: string, args) =>
output(itemOf(await call("docs.documents.batchUpdate", { documentId: fileId(id) }, args.body))),
)
const activities = annotate(program.command("activities"), { effects: GOOGLE_READ }).description(
"read who did what with a file in Google Drive",
)
const activities = notLocalPaths(
annotate(program.command("activities"), { effects: GOOGLE_READ }),
"file",
).description("read who did what with a file in Google Drive")
const activityRow = v.looseObject({ timestamp: v.optional(v.string()) })
const activityQuery = unfilteredQuery("drive_remote_activity", activityRow)
bindQuery(
Expand Down Expand Up @@ -460,7 +462,7 @@ export const installRemoteCommands = (program: Command, helpers: RemoteCommands)
})
for (const resource of ["comments", "permissions", "revisions"] as const) {
const one = resource.slice(0, -1)
const group = annotate(program.command(resource), { effects: GOOGLE_READ }).description(
const group = notLocalPaths(annotate(program.command(resource), { effects: GOOGLE_READ }), "file").description(
`read the ${resource} of a file in Google Drive`,
)
if (resource === "comments") {
Expand Down
2 changes: 1 addition & 1 deletion src/documents-add.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CliError, isCliError } from "@wirecat/cli-base"
import type { AddedSource, AddedSourceInput } from "@wirecat/cli-core/store"
import type { AddedSource, AddedSourceInput } from "@wirecat/cli-core/store/areas"
import {
activeProfile,
fileId,
Expand Down
7 changes: 7 additions & 0 deletions src/file-edit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,4 +362,11 @@ describe("the MCP catalogue", () => {
"files history": false,
})
})

it("offers no sheets or documents create: Google Drive names a new file by the id it gives", () => {
const tools = toolsFromCommands(describeProgram(commandTree()), { includeUnavailable: true, exclude: [["mcp"]] })
const paths = tools.map((tool) => tool.path.join(" "))
expect(paths).not.toContain("files sheets create")
expect(paths).not.toContain("files documents create")
})
})
2 changes: 1 addition & 1 deletion src/generated/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Source: spec/google/*.json, verified by provenance.json
// Run: pnpm generate

import type { SchemaNode } from "@wirecat/cli-base/codegen"
import type { SchemaNode } from "@wirecat/cli-base/codegen/runtime"

export const definitions: Readonly<Record<string, SchemaNode>> = {
DriveOperation: {
Expand Down
2 changes: 1 addition & 1 deletion src/generated/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Source: spec/google/*.json, verified by provenance.json
// Run: pnpm generate

import type { ManifestOperation, SecurityScheme } from "@wirecat/cli-base/codegen"
import type { ManifestOperation, SecurityScheme } from "@wirecat/cli-base/codegen/runtime"

export const operations: readonly ManifestOperation[] = [
{
Expand Down
3 changes: 2 additions & 1 deletion src/knowledge.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { listQuery } from "@wirecat/cli-core/cli"
import { proposalRegistry } from "@wirecat/cli-core/services"
import { IMPORTED_DOCUMENT_QUERY, openStore } from "@wirecat/cli-core/store"
import { openStore } from "@wirecat/cli-core/store"
import { IMPORTED_DOCUMENT_QUERY } from "@wirecat/cli-core/store/areas"
import { describe, expect, it } from "vitest"
import { openIndex } from "./store.js"
import { content, file, fixture } from "./testing.js"
Expand Down
3 changes: 2 additions & 1 deletion src/knowledge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
documentKnowledge as sharedKnowledge,
} from "@wirecat/cli-core/documents"
import { factItem, memoryItem } from "@wirecat/cli-core/documents/cli"
import type { LinkInput, MessageStore, PersonRecord } from "@wirecat/cli-core/store"
import type { MessageStore, PersonRecord } from "@wirecat/cli-core/store"
import type { LinkInput } from "@wirecat/cli-core/store/areas"
import type { FileMetadata, GoogleUser } from "./model.js"
export interface DocumentKnowledge extends SharedDocumentKnowledge {
context(principal: string, ref: string): Promise<unknown>
Expand Down
2 changes: 1 addition & 1 deletion src/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type {
SourceWork,
} from "@wirecat/cli-core/documents"
import type { DocumentHistoryPort } from "@wirecat/cli-core/documents/cli"
import type { AddedSource, AddedSourceInput } from "@wirecat/cli-core/store"
import type { AddedSource, AddedSourceInput } from "@wirecat/cli-core/store/areas"

export type { PictureWriter, TabText } from "@wirecat/cli-core/documents"
export const FOLDER = "application/vnd.google-apps.folder"
Expand Down
2 changes: 1 addition & 1 deletion src/schema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { identifier, type SchemaNode } from "@wirecat/cli-base/codegen"
import { identifier, type SchemaNode } from "@wirecat/cli-base/codegen/runtime"
import { operationOf } from "./api-contract.js"
import { definitions } from "./generated/definitions.js"
export const requestSchema = (method: string) => {
Expand Down