From 29733697789ec311d7a1b6ec356609ea5bc4ffea Mon Sep 17 00:00:00 2001 From: kurihada Date: Fri, 12 Dec 2025 18:53:25 +0800 Subject: [PATCH] =?UTF-8?q?feat(cli):=20=E6=B7=BB=E5=8A=A0=E5=91=BD?= =?UTF-8?q?=E4=BB=A4=20CRUD=20API=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cli/src/client/api.ts | 60 ++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) 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)}`); + } } /**