mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-12-01 05:14:25 +00:00
Rebuild the CLI on commander. Commands for every cli-surface Operation (project ls, ls, mkdir, rename, move/mv, delete/rm) are generated from @shumai/operations: positionals, options, choices, numeric parsing and help text come from the Zod input schema. They call POST /api/ops/:name with x-shumai-client: cli. Existing invocations keep working. Adds --json, ls --type/--first/ --after, typo suggestions, and generated help. upload and create-version stay hand-written. Drops the unused @shumai/core dependency.
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
import { z } from 'zod'
|
|
import { defineOperation } from '../define'
|
|
import { assetSummarySchema, MAX_PAGE_SIZE, pageInfoSchema } from '../schemas'
|
|
|
|
export const listAssets = defineOperation({
|
|
name: 'list_assets',
|
|
title: 'List Assets',
|
|
description:
|
|
'List the assets (files and folders) inside a parent folder. Results are paginated: when ' +
|
|
'pageInfo.hasNextPage is true, call again with after set to pageInfo.endCursor.',
|
|
input: z.object({
|
|
parent: z.string().min(1).describe('The parent folder ID to list assets from.'),
|
|
type: z
|
|
.enum(['file', 'folder', 'all'])
|
|
.optional()
|
|
.describe("Filter assets by type: 'file', 'folder', or 'all'. Default is 'all'."),
|
|
first: z
|
|
.number()
|
|
.int()
|
|
.min(1)
|
|
.max(MAX_PAGE_SIZE)
|
|
.optional()
|
|
.describe(`Maximum number of assets to return (at most ${MAX_PAGE_SIZE}).`),
|
|
after: z
|
|
.string()
|
|
.optional()
|
|
.describe('Cursor from a previous response (pageInfo.endCursor) to fetch the next page.'),
|
|
}),
|
|
output: z.object({
|
|
data: z.array(assetSummarySchema),
|
|
pageInfo: pageInfoSchema,
|
|
total: z.number(),
|
|
}),
|
|
surfaces: ['agent', 'mcp', 'cli'],
|
|
annotations: { readOnly: true, destructive: false, idempotent: true },
|
|
cli: {
|
|
command: ['ls'],
|
|
description: 'List the files and folders inside a parent folder.',
|
|
flags: { parent: ['-p', '--parent'] },
|
|
// The CLI shows up to the maximum page by default; agents use the smaller default.
|
|
defaults: { first: MAX_PAGE_SIZE },
|
|
},
|
|
})
|