feat(cli): 添加命令 CRUD API 方法
This commit is contained in:
@@ -77,6 +77,37 @@ export interface CommandListResponse {
|
||||
stats: { total: number; bySource: Record<string, number> };
|
||||
}
|
||||
|
||||
// ============ 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)}`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user