diff --git a/packages/cli/src/client/api.ts b/packages/cli/src/client/api.ts index e78fcc5..e90da48 100644 --- a/packages/cli/src/client/api.ts +++ b/packages/cli/src/client/api.ts @@ -77,6 +77,37 @@ export interface CommandListResponse { stats: { total: number; bySource: Record }; } +// ============ Command CRUD 相关 ============ + +export interface CreateCommandInput { + name: string; + description?: string; + template: string; + agent?: string; + model?: string; + subtask?: boolean; + scope: 'user' | 'project'; +} + +export interface UpdateCommandInput { + description?: string; + template?: string; + agent?: string; + model?: string; + subtask?: boolean; +} + +export interface CommandContent { + name: string; + description?: string; + template: string; + agent?: string; + model?: string; + subtask?: boolean; + source: string; + sourcePath?: string; +} + /** * API Client 类 */ @@ -246,6 +277,35 @@ export class APIClient { }> { return this.request('POST', '/api/commands/reload'); } + + // ============================================================================ + // Commands CRUD + // ============================================================================ + + async createCommand( + input: CreateCommandInput + ): Promise<{ success: boolean; data?: { name: string; path: string }; error?: string }> { + return this.request('POST', '/api/commands', input); + } + + async getCommandContent( + name: string + ): Promise<{ success: boolean; data?: CommandContent; error?: string }> { + return this.request('GET', `/api/commands/${encodeURIComponent(name)}/content`); + } + + async updateCommand( + name: string, + input: UpdateCommandInput + ): Promise<{ success: boolean; data?: { name: string; path: string }; error?: string }> { + return this.request('PUT', `/api/commands/${encodeURIComponent(name)}`, input); + } + + async deleteCommand( + name: string + ): Promise<{ success: boolean; data?: { name: string; path: string }; error?: string }> { + return this.request('DELETE', `/api/commands/${encodeURIComponent(name)}`); + } } /**