mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-25 12:48:20 +00:00
feat(operations): add create_project operation across agent, mcp, and cli (#529)
* feat(operations): add create_project operation across agent, mcp, and cli * fix(api): remove legacy team creation endpoint * fix(api): preserve ProjectInfo response on POST /teams/:teamId/projects
This commit is contained in:
@@ -19,6 +19,7 @@ export { createComment } from './comment/create-comment'
|
||||
export { resolveComment } from './comment/resolve-comment'
|
||||
export * from './metadata/list-metadata-fields'
|
||||
export * from './metadata/update-asset-metadata'
|
||||
export { createProject } from './project/create-project'
|
||||
export { listProjects } from './project/list-projects'
|
||||
export * from './upload/create-file'
|
||||
export { createVersion } from './upload/create-version'
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
import { z } from 'zod'
|
||||
import { defineOperation } from '../define'
|
||||
import { projectSummarySchema } from '../schemas'
|
||||
|
||||
export const createProject = defineOperation({
|
||||
name: 'create_project',
|
||||
title: 'Create Project',
|
||||
description:
|
||||
'Create a new project in the team. Returns the created project, including its rootFolderId ' +
|
||||
'to use as the parent for asset operations.',
|
||||
input: z.object({
|
||||
name: z.string().trim().min(1).describe('The name of the new project to create.'),
|
||||
teamId: z
|
||||
.string()
|
||||
.min(1)
|
||||
.optional()
|
||||
.describe('Optional team ID. Uses the active or sole team when omitted.'),
|
||||
coverImageKey: z
|
||||
.string()
|
||||
.min(1)
|
||||
.optional()
|
||||
.describe('Optional S3 storage key for the project cover image.'),
|
||||
enableNotification: z
|
||||
.boolean()
|
||||
.optional()
|
||||
.describe('Whether project notifications are enabled (defaults to true).'),
|
||||
}),
|
||||
output: projectSummarySchema,
|
||||
surfaces: ['agent', 'mcp', 'cli'],
|
||||
annotations: { readOnly: false, destructive: false },
|
||||
cli: {
|
||||
command: ['project', 'create'],
|
||||
description: 'Create a new project.',
|
||||
positional: ['name'],
|
||||
flags: { teamId: ['-t', '--team'] },
|
||||
omit: ['coverImageKey', 'enableNotification'],
|
||||
format: (output) =>
|
||||
`Created project "${output.name}" (ID: ${output.id}, rootFolderId: ${output.rootFolderId ?? ''})`,
|
||||
},
|
||||
})
|
||||
@@ -23,6 +23,7 @@ describe('operation registry', () => {
|
||||
'create_comment',
|
||||
'create_file',
|
||||
'create_folder',
|
||||
'create_project',
|
||||
'create_version',
|
||||
'create_version_stack',
|
||||
'delete_asset',
|
||||
@@ -122,6 +123,7 @@ describe('operation registry', () => {
|
||||
.filter((d) => d.cli)
|
||||
.map((d) => [d.name, [...(d.cli?.command ?? []), ...(d.cli?.aliases ?? [])]])
|
||||
expect(commands).toEqual([
|
||||
['create_project', ['project', 'create']],
|
||||
['list_projects', ['project', 'ls']],
|
||||
['list_assets', ['ls']],
|
||||
['search_assets', ['search']],
|
||||
|
||||
@@ -16,6 +16,7 @@ import { resolveComment } from './comment/resolve-comment'
|
||||
import type { AnyOperationDefinition, Surface } from './define'
|
||||
import { listMetadataFields } from './metadata/list-metadata-fields'
|
||||
import { updateAssetMetadata } from './metadata/update-asset-metadata'
|
||||
import { createProject } from './project/create-project'
|
||||
import { listProjects } from './project/list-projects'
|
||||
import { completeUpload } from './upload/complete-upload'
|
||||
import { createFile } from './upload/create-file'
|
||||
@@ -29,6 +30,7 @@ import { removeVersion } from './version/remove-version'
|
||||
* `@shumai/core/src/operations/registry.ts` (enforced by the type checker).
|
||||
*/
|
||||
export const operationDefinitions = [
|
||||
createProject,
|
||||
listProjects,
|
||||
listAssets,
|
||||
searchAssets,
|
||||
|
||||
Reference in New Issue
Block a user