@codeguide/core 0.0.27 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -41
- package/__tests__/services/codespace/codespace-v2.test.ts +29 -18
- package/__tests__/services/usage/usage-service.test.ts +162 -9
- package/codeguide.ts +3 -0
- package/dist/codeguide.d.ts +2 -1
- package/dist/codeguide.js +1 -0
- package/dist/services/codespace/codespace-service.js +3 -5
- package/dist/services/codespace/codespace-types.d.ts +1 -1
- package/dist/services/index.d.ts +2 -0
- package/dist/services/index.js +4 -1
- package/dist/services/repository-analysis/repository-types.d.ts +1 -0
- package/dist/services/usage/usage-types.d.ts +60 -11
- package/dist/services/users/index.d.ts +2 -0
- package/dist/services/users/index.js +20 -0
- package/dist/services/users/user-service.d.ts +12 -0
- package/dist/services/users/user-service.js +17 -0
- package/dist/services/users/user-types.d.ts +55 -0
- package/dist/services/users/user-types.js +2 -0
- package/docs/codespace-service.md +114 -81
- package/docs/usage-service.md +326 -0
- package/package.json +1 -1
- package/services/codespace/codespace-service.ts +10 -8
- package/services/codespace/codespace-types.ts +1 -1
- package/services/index.ts +2 -0
- package/services/repository-analysis/repository-types.ts +1 -0
- package/services/usage/usage-types.ts +65 -11
- package/services/users/index.ts +2 -0
- package/services/users/user-service.ts +15 -0
- package/services/users/user-types.ts +59 -0
|
@@ -31,7 +31,7 @@ const codeguide = new CodeGuide({
|
|
|
31
31
|
// Alternative authentication methods:
|
|
32
32
|
// apiKey: 'your_legacy_api_key',
|
|
33
33
|
// jwtToken: 'your_clerk_jwt_token',
|
|
34
|
-
timeout: 30000
|
|
34
|
+
timeout: 30000,
|
|
35
35
|
})
|
|
36
36
|
|
|
37
37
|
// Access the codespace service
|
|
@@ -62,15 +62,15 @@ The service will automatically use the highest priority authentication method av
|
|
|
62
62
|
|
|
63
63
|
The Codespace Service provides the following methods:
|
|
64
64
|
|
|
65
|
-
| Method
|
|
66
|
-
|
|
67
|
-
| `generateTaskTitle()`
|
|
68
|
-
| `createCodespaceTaskV2()`
|
|
69
|
-
| `createBackgroundCodespaceTask()` | Create task in background
|
|
70
|
-
| `getCodespaceTask()`
|
|
71
|
-
| `getCodespaceTasksByProject()`
|
|
72
|
-
| `getCodespaceTaskDetailed()`
|
|
73
|
-
| `getProjectTasksByCodespace()`
|
|
65
|
+
| Method | Description | Endpoint |
|
|
66
|
+
| --------------------------------- | -------------------------------------- | -------------------------------------- |
|
|
67
|
+
| `generateTaskTitle()` | Generate a title from task description | `POST /codespace/generate-task-title` |
|
|
68
|
+
| `createCodespaceTaskV2()` | Create a new codespace task | `POST /codespace/task` |
|
|
69
|
+
| `createBackgroundCodespaceTask()` | Create task in background | `POST /codespace/task/background` |
|
|
70
|
+
| `getCodespaceTask()` | Get task by ID | `GET /codespace/task/{id}` |
|
|
71
|
+
| `getCodespaceTasksByProject()` | Get tasks for a project | `GET /codespace/tasks/project/{id}` |
|
|
72
|
+
| `getCodespaceTaskDetailed()` | Get detailed task info | `GET /codespace/task/{id}/detailed` |
|
|
73
|
+
| `getProjectTasksByCodespace()` | Get project tasks by codespace | `GET /project-tasks/by-codespace/{id}` |
|
|
74
74
|
|
|
75
75
|
## Detailed Method Documentation
|
|
76
76
|
|
|
@@ -79,14 +79,17 @@ The Codespace Service provides the following methods:
|
|
|
79
79
|
Generates a concise title from a detailed task description using AI or fallback logic.
|
|
80
80
|
|
|
81
81
|
#### Signature
|
|
82
|
+
|
|
82
83
|
```typescript
|
|
83
84
|
async generateTaskTitle(request: GenerateTaskTitleRequest): Promise<GenerateTaskTitleResponse>
|
|
84
85
|
```
|
|
85
86
|
|
|
86
87
|
#### Parameters
|
|
88
|
+
|
|
87
89
|
- `request.task_description` (string, required): The full task description to generate title from
|
|
88
90
|
|
|
89
91
|
#### Response
|
|
92
|
+
|
|
90
93
|
```typescript
|
|
91
94
|
interface GenerateTaskTitleResponse {
|
|
92
95
|
success: boolean
|
|
@@ -97,9 +100,11 @@ interface GenerateTaskTitleResponse {
|
|
|
97
100
|
```
|
|
98
101
|
|
|
99
102
|
#### Example
|
|
103
|
+
|
|
100
104
|
```typescript
|
|
101
105
|
const response = await codespace.generateTaskTitle({
|
|
102
|
-
task_description:
|
|
106
|
+
task_description:
|
|
107
|
+
'Create a user authentication system with login, registration, and password reset functionality using JWT tokens and bcrypt for password hashing',
|
|
103
108
|
})
|
|
104
109
|
|
|
105
110
|
console.log(response.title) // "User Authentication System"
|
|
@@ -111,27 +116,29 @@ console.log(response.fallback_used) // false if AI generated, true if fallback u
|
|
|
111
116
|
Creates a new codespace task with complete workflow including PRD generation, task creation, and Claude Code integration.
|
|
112
117
|
|
|
113
118
|
#### Signature
|
|
119
|
+
|
|
114
120
|
```typescript
|
|
115
121
|
async createCodespaceTaskV2(request: CreateCodespaceTaskRequestV2): Promise<CreateCodespaceTaskResponseV2>
|
|
116
122
|
```
|
|
117
123
|
|
|
118
124
|
#### Parameters
|
|
125
|
+
|
|
119
126
|
```typescript
|
|
120
127
|
interface CreateCodespaceTaskRequestV2 {
|
|
121
|
-
project_id: string
|
|
122
|
-
task_description: string
|
|
123
|
-
project_repository_id?: string
|
|
124
|
-
title?: string
|
|
125
|
-
branch?: string
|
|
126
|
-
working_branch?: string
|
|
127
|
-
base_branch?: string
|
|
128
|
-
docs_url?: string
|
|
129
|
-
model_api_keys?: ModelApiKey[]
|
|
130
|
-
github_token?: string
|
|
131
|
-
codespace_task_id?: string
|
|
132
|
-
execution_mode?: 'implementation' | 'docs-only'
|
|
133
|
-
model_name?: string
|
|
134
|
-
starter_kit_repo?: string
|
|
128
|
+
project_id: string // Required
|
|
129
|
+
task_description: string // Required
|
|
130
|
+
project_repository_id?: string // Optional
|
|
131
|
+
title?: string // Optional
|
|
132
|
+
branch?: string // Optional
|
|
133
|
+
working_branch?: string // Optional
|
|
134
|
+
base_branch?: string // Optional (default: "main")
|
|
135
|
+
docs_url?: string // Optional
|
|
136
|
+
model_api_keys?: ModelApiKey[] // Optional
|
|
137
|
+
github_token?: string // Optional
|
|
138
|
+
codespace_task_id?: string // Optional (for continuation)
|
|
139
|
+
execution_mode?: 'implementation' | 'docs-only' | 'direct' // Optional (default: "implementation")
|
|
140
|
+
model_name?: string // Optional
|
|
141
|
+
starter_kit_repo?: string // Optional
|
|
135
142
|
}
|
|
136
143
|
|
|
137
144
|
interface ModelApiKey {
|
|
@@ -141,6 +148,7 @@ interface ModelApiKey {
|
|
|
141
148
|
```
|
|
142
149
|
|
|
143
150
|
#### Response
|
|
151
|
+
|
|
144
152
|
```typescript
|
|
145
153
|
interface CreateCodespaceTaskResponseV2 {
|
|
146
154
|
success: boolean
|
|
@@ -152,18 +160,19 @@ interface CreateCodespaceTaskResponseV2 {
|
|
|
152
160
|
```
|
|
153
161
|
|
|
154
162
|
#### Example
|
|
163
|
+
|
|
155
164
|
```typescript
|
|
156
165
|
const response = await codespace.createCodespaceTaskV2({
|
|
157
|
-
project_id:
|
|
158
|
-
task_description:
|
|
159
|
-
execution_mode:
|
|
166
|
+
project_id: 'proj_123456',
|
|
167
|
+
task_description: 'Add user profile page with avatar upload and bio editing',
|
|
168
|
+
execution_mode: 'implementation',
|
|
160
169
|
model_api_keys: [
|
|
161
170
|
{
|
|
162
|
-
model_name:
|
|
163
|
-
api_key:
|
|
164
|
-
}
|
|
171
|
+
model_name: 'claude-3-sonnet',
|
|
172
|
+
api_key: 'your_api_key_here',
|
|
173
|
+
},
|
|
165
174
|
],
|
|
166
|
-
github_token:
|
|
175
|
+
github_token: 'ghp_your_github_token',
|
|
167
176
|
})
|
|
168
177
|
|
|
169
178
|
console.log(`Task created with ID: ${response.task_id}`)
|
|
@@ -174,19 +183,22 @@ console.log(`Task created with ID: ${response.task_id}`)
|
|
|
174
183
|
Creates a codespace task that runs in the background, returning immediately with task details while work continues.
|
|
175
184
|
|
|
176
185
|
#### Signature
|
|
186
|
+
|
|
177
187
|
```typescript
|
|
178
188
|
async createBackgroundCodespaceTask(request: CreateBackgroundCodespaceTaskRequest): Promise<CreateBackgroundCodespaceTaskResponse>
|
|
179
189
|
```
|
|
180
190
|
|
|
181
191
|
#### Parameters
|
|
192
|
+
|
|
182
193
|
Same as `createCodespaceTaskV2()` - extends `CreateCodespaceTaskRequestV2`
|
|
183
194
|
|
|
184
195
|
#### Response
|
|
196
|
+
|
|
185
197
|
```typescript
|
|
186
198
|
interface CreateBackgroundCodespaceTaskResponse {
|
|
187
199
|
success: boolean
|
|
188
200
|
task_id: string
|
|
189
|
-
job_id: string
|
|
201
|
+
job_id: string // Background job ID for status checking
|
|
190
202
|
status: string
|
|
191
203
|
message: string
|
|
192
204
|
repository_connected: boolean
|
|
@@ -195,11 +207,12 @@ interface CreateBackgroundCodespaceTaskResponse {
|
|
|
195
207
|
```
|
|
196
208
|
|
|
197
209
|
#### Example
|
|
210
|
+
|
|
198
211
|
```typescript
|
|
199
212
|
const response = await codespace.createBackgroundCodespaceTask({
|
|
200
|
-
project_id:
|
|
201
|
-
task_description:
|
|
202
|
-
execution_mode:
|
|
213
|
+
project_id: 'proj_123456',
|
|
214
|
+
task_description: 'Implement real-time chat functionality',
|
|
215
|
+
execution_mode: 'implementation',
|
|
203
216
|
})
|
|
204
217
|
|
|
205
218
|
console.log(`Background task started: ${response.job_id}`)
|
|
@@ -211,14 +224,17 @@ console.log(`Background task started: ${response.job_id}`)
|
|
|
211
224
|
Retrieves a codespace task by its ID with full details.
|
|
212
225
|
|
|
213
226
|
#### Signature
|
|
227
|
+
|
|
214
228
|
```typescript
|
|
215
229
|
async getCodespaceTask(codespaceTaskId: string): Promise<GetCodespaceTaskResponse>
|
|
216
230
|
```
|
|
217
231
|
|
|
218
232
|
#### Parameters
|
|
233
|
+
|
|
219
234
|
- `codespaceTaskId` (string, required): The ID of the codespace task to retrieve
|
|
220
235
|
|
|
221
236
|
#### Response
|
|
237
|
+
|
|
222
238
|
```typescript
|
|
223
239
|
interface GetCodespaceTaskResponse {
|
|
224
240
|
status: string
|
|
@@ -259,8 +275,9 @@ interface CodespaceTaskData {
|
|
|
259
275
|
```
|
|
260
276
|
|
|
261
277
|
#### Example
|
|
278
|
+
|
|
262
279
|
```typescript
|
|
263
|
-
const response = await codespace.getCodespaceTask(
|
|
280
|
+
const response = await codespace.getCodespaceTask('task_789012')
|
|
264
281
|
const task = response.data
|
|
265
282
|
|
|
266
283
|
console.log(`Task: ${task.title}`)
|
|
@@ -278,23 +295,26 @@ if (task.pull_request_url) {
|
|
|
278
295
|
Retrieves all codespace tasks for a specific project with filtering and pagination support.
|
|
279
296
|
|
|
280
297
|
#### Signature
|
|
298
|
+
|
|
281
299
|
```typescript
|
|
282
300
|
async getCodespaceTasksByProject(params: GetCodespaceTasksByProjectRequest): Promise<GetCodespaceTasksByProjectResponse>
|
|
283
301
|
```
|
|
284
302
|
|
|
285
303
|
#### Parameters
|
|
304
|
+
|
|
286
305
|
```typescript
|
|
287
306
|
interface GetCodespaceTasksByProjectRequest {
|
|
288
|
-
project_id: string
|
|
307
|
+
project_id: string // Required
|
|
289
308
|
status?: 'completed' | 'failed' | 'in_progress' | 'created' | 'cancelled'
|
|
290
|
-
limit?: number
|
|
291
|
-
offset?: number
|
|
292
|
-
sort_by?: string
|
|
293
|
-
sort_order?: 'asc' | 'desc'
|
|
309
|
+
limit?: number // Optional (default: 50)
|
|
310
|
+
offset?: number // Optional (default: 0)
|
|
311
|
+
sort_by?: string // Optional (default: "created_at")
|
|
312
|
+
sort_order?: 'asc' | 'desc' // Optional (default: "desc")
|
|
294
313
|
}
|
|
295
314
|
```
|
|
296
315
|
|
|
297
316
|
#### Response
|
|
317
|
+
|
|
298
318
|
```typescript
|
|
299
319
|
interface GetCodespaceTasksByProjectResponse {
|
|
300
320
|
status: string
|
|
@@ -305,13 +325,14 @@ interface GetCodespaceTasksByProjectResponse {
|
|
|
305
325
|
```
|
|
306
326
|
|
|
307
327
|
#### Example
|
|
328
|
+
|
|
308
329
|
```typescript
|
|
309
330
|
// Get all completed tasks for a project
|
|
310
331
|
const response = await codespace.getCodespaceTasksByProject({
|
|
311
|
-
project_id:
|
|
312
|
-
status:
|
|
332
|
+
project_id: 'proj_123456',
|
|
333
|
+
status: 'completed',
|
|
313
334
|
limit: 20,
|
|
314
|
-
sort_order:
|
|
335
|
+
sort_order: 'desc',
|
|
315
336
|
})
|
|
316
337
|
|
|
317
338
|
console.log(`Found ${response.total_count} completed tasks`)
|
|
@@ -325,30 +346,34 @@ response.data.forEach(task => {
|
|
|
325
346
|
Retrieves comprehensive codespace task details including related project data, repository information, and usage statistics.
|
|
326
347
|
|
|
327
348
|
#### Signature
|
|
349
|
+
|
|
328
350
|
```typescript
|
|
329
351
|
async getCodespaceTaskDetailed(codespaceTaskId: string): Promise<CodespaceTaskDetailedResponse>
|
|
330
352
|
```
|
|
331
353
|
|
|
332
354
|
#### Parameters
|
|
355
|
+
|
|
333
356
|
- `codespaceTaskId` (string, required): The ID of the codespace task to retrieve detailed information for
|
|
334
357
|
|
|
335
358
|
#### Response
|
|
359
|
+
|
|
336
360
|
```typescript
|
|
337
361
|
interface CodespaceTaskDetailedResponse {
|
|
338
362
|
status: string
|
|
339
363
|
data: {
|
|
340
364
|
task: CodespaceTaskData
|
|
341
|
-
project: any
|
|
342
|
-
repository: any
|
|
343
|
-
usage_summary: any
|
|
365
|
+
project: any // Project data structure
|
|
366
|
+
repository: any // Repository data structure
|
|
367
|
+
usage_summary: any // Usage statistics
|
|
344
368
|
}
|
|
345
369
|
message: string
|
|
346
370
|
}
|
|
347
371
|
```
|
|
348
372
|
|
|
349
373
|
#### Example
|
|
374
|
+
|
|
350
375
|
```typescript
|
|
351
|
-
const response = await codespace.getCodespaceTaskDetailed(
|
|
376
|
+
const response = await codespace.getCodespaceTaskDetailed('task_789012')
|
|
352
377
|
const { task, project, repository, usage_summary } = response.data
|
|
353
378
|
|
|
354
379
|
console.log(`Task: ${task.title}`)
|
|
@@ -362,24 +387,28 @@ console.log(`Usage: ${usage_summary.total_requests} requests`)
|
|
|
362
387
|
Retrieves project tasks associated with a specific codespace task.
|
|
363
388
|
|
|
364
389
|
#### Signature
|
|
390
|
+
|
|
365
391
|
```typescript
|
|
366
392
|
async getProjectTasksByCodespace(codespaceTaskId: string): Promise<GetProjectTasksByCodespaceResponse>
|
|
367
393
|
```
|
|
368
394
|
|
|
369
395
|
#### Parameters
|
|
396
|
+
|
|
370
397
|
- `codespaceTaskId` (string, required): The ID of the codespace task
|
|
371
398
|
|
|
372
399
|
#### Response
|
|
400
|
+
|
|
373
401
|
```typescript
|
|
374
402
|
interface GetProjectTasksByCodespaceResponse {
|
|
375
403
|
status: string
|
|
376
|
-
data: any[]
|
|
404
|
+
data: any[] // Array of project task objects
|
|
377
405
|
}
|
|
378
406
|
```
|
|
379
407
|
|
|
380
408
|
#### Example
|
|
409
|
+
|
|
381
410
|
```typescript
|
|
382
|
-
const response = await codespace.getProjectTasksByCodespace(
|
|
411
|
+
const response = await codespace.getProjectTasksByCodespace('task_789012')
|
|
383
412
|
|
|
384
413
|
console.log(`Found ${response.data.length} related project tasks`)
|
|
385
414
|
response.data.forEach(projectTask => {
|
|
@@ -392,6 +421,7 @@ response.data.forEach(projectTask => {
|
|
|
392
421
|
All methods throw errors for various failure conditions. Common error types include:
|
|
393
422
|
|
|
394
423
|
### Validation Errors
|
|
424
|
+
|
|
395
425
|
```typescript
|
|
396
426
|
try {
|
|
397
427
|
await codespace.createCodespaceTaskV2({})
|
|
@@ -401,27 +431,29 @@ try {
|
|
|
401
431
|
```
|
|
402
432
|
|
|
403
433
|
### Network/Server Errors
|
|
434
|
+
|
|
404
435
|
```typescript
|
|
405
436
|
try {
|
|
406
|
-
await codespace.getCodespaceTask(
|
|
437
|
+
await codespace.getCodespaceTask('invalid_id')
|
|
407
438
|
} catch (error) {
|
|
408
439
|
if (error.response?.status === 404) {
|
|
409
|
-
console.error(
|
|
440
|
+
console.error('Task not found')
|
|
410
441
|
} else if (error.response?.status === 401) {
|
|
411
|
-
console.error(
|
|
442
|
+
console.error('Unauthorized - check your API credentials')
|
|
412
443
|
} else {
|
|
413
|
-
console.error(
|
|
444
|
+
console.error('Network error:', error.message)
|
|
414
445
|
}
|
|
415
446
|
}
|
|
416
447
|
```
|
|
417
448
|
|
|
418
449
|
### Timeout Errors
|
|
450
|
+
|
|
419
451
|
```typescript
|
|
420
452
|
try {
|
|
421
453
|
await codespace.createCodespaceTaskV2(largeRequest)
|
|
422
454
|
} catch (error) {
|
|
423
455
|
if (error.code === 'ECONNABORTED') {
|
|
424
|
-
console.error(
|
|
456
|
+
console.error('Request timed out. Consider using background task creation.')
|
|
425
457
|
}
|
|
426
458
|
}
|
|
427
459
|
```
|
|
@@ -435,30 +467,32 @@ import { CodeGuide } from '@codeguide/core'
|
|
|
435
467
|
|
|
436
468
|
const codeguide = new CodeGuide({
|
|
437
469
|
baseUrl: 'https://api.codeguide.dev',
|
|
438
|
-
databaseApiKey: process.env.CODEGUIDE_API_KEY
|
|
470
|
+
databaseApiKey: process.env.CODEGUIDE_API_KEY,
|
|
439
471
|
})
|
|
440
472
|
|
|
441
473
|
async function completeTaskWorkflow() {
|
|
442
474
|
try {
|
|
443
475
|
// 1. Generate a title from description
|
|
444
476
|
const titleResponse = await codeguide.codespace.generateTaskTitle({
|
|
445
|
-
task_description:
|
|
477
|
+
task_description:
|
|
478
|
+
'Implement a REST API for user management with CRUD operations, validation, and authentication middleware',
|
|
446
479
|
})
|
|
447
480
|
|
|
448
481
|
console.log(`Generated title: ${titleResponse.title}`)
|
|
449
482
|
|
|
450
483
|
// 2. Create the task
|
|
451
484
|
const taskResponse = await codeguide.codespace.createCodespaceTaskV2({
|
|
452
|
-
project_id:
|
|
453
|
-
task_description:
|
|
485
|
+
project_id: 'proj_123456',
|
|
486
|
+
task_description:
|
|
487
|
+
'Implement a REST API for user management with CRUD operations, validation, and authentication middleware',
|
|
454
488
|
title: titleResponse.title,
|
|
455
|
-
execution_mode:
|
|
489
|
+
execution_mode: 'implementation',
|
|
456
490
|
model_api_keys: [
|
|
457
491
|
{
|
|
458
|
-
model_name:
|
|
459
|
-
api_key: process.env.CLAUDE_API_KEY
|
|
460
|
-
}
|
|
461
|
-
]
|
|
492
|
+
model_name: 'claude-3-sonnet',
|
|
493
|
+
api_key: process.env.CLAUDE_API_KEY,
|
|
494
|
+
},
|
|
495
|
+
],
|
|
462
496
|
})
|
|
463
497
|
|
|
464
498
|
console.log(`Task created: ${taskResponse.task_id}`)
|
|
@@ -478,9 +512,8 @@ async function completeTaskWorkflow() {
|
|
|
478
512
|
}
|
|
479
513
|
|
|
480
514
|
checkProgress()
|
|
481
|
-
|
|
482
515
|
} catch (error) {
|
|
483
|
-
console.error(
|
|
516
|
+
console.error('Workflow failed:', error.message)
|
|
484
517
|
}
|
|
485
518
|
}
|
|
486
519
|
|
|
@@ -494,9 +527,9 @@ async function backgroundTaskExample() {
|
|
|
494
527
|
try {
|
|
495
528
|
// Create background task
|
|
496
529
|
const response = await codeguide.codespace.createBackgroundCodespaceTask({
|
|
497
|
-
project_id:
|
|
498
|
-
task_description:
|
|
499
|
-
execution_mode:
|
|
530
|
+
project_id: 'proj_123456',
|
|
531
|
+
task_description: 'Add comprehensive test suite for existing authentication module',
|
|
532
|
+
execution_mode: 'implementation',
|
|
500
533
|
})
|
|
501
534
|
|
|
502
535
|
console.log(`Background task started: ${response.job_id}`)
|
|
@@ -509,20 +542,21 @@ async function backgroundTaskExample() {
|
|
|
509
542
|
console.log(`Status: ${task.data.status}`)
|
|
510
543
|
|
|
511
544
|
if (['completed', 'failed'].includes(task.data.status)) {
|
|
512
|
-
console.log(
|
|
545
|
+
console.log(
|
|
546
|
+
`Task ${task.data.status === 'completed' ? 'completed successfully' : 'failed'}`
|
|
547
|
+
)
|
|
513
548
|
return
|
|
514
549
|
}
|
|
515
550
|
|
|
516
551
|
setTimeout(pollStatus, 10000) // Poll every 10 seconds
|
|
517
552
|
} catch (error) {
|
|
518
|
-
console.error(
|
|
553
|
+
console.error('Error checking status:', error.message)
|
|
519
554
|
}
|
|
520
555
|
}
|
|
521
556
|
|
|
522
557
|
pollStatus()
|
|
523
|
-
|
|
524
558
|
} catch (error) {
|
|
525
|
-
console.error(
|
|
559
|
+
console.error('Background task creation failed:', error.message)
|
|
526
560
|
}
|
|
527
561
|
}
|
|
528
562
|
```
|
|
@@ -531,14 +565,14 @@ async function backgroundTaskExample() {
|
|
|
531
565
|
|
|
532
566
|
```typescript
|
|
533
567
|
async function projectTaskManagement() {
|
|
534
|
-
const projectId =
|
|
568
|
+
const projectId = 'proj_123456'
|
|
535
569
|
|
|
536
570
|
try {
|
|
537
571
|
// Get all tasks for the project
|
|
538
572
|
const tasksResponse = await codeguide.codespace.getCodespaceTasksByProject({
|
|
539
573
|
project_id: projectId,
|
|
540
574
|
limit: 100,
|
|
541
|
-
sort_order:
|
|
575
|
+
sort_order: 'desc',
|
|
542
576
|
})
|
|
543
577
|
|
|
544
578
|
console.log(`Project has ${tasksResponse.total_count} total tasks`)
|
|
@@ -549,7 +583,7 @@ async function projectTaskManagement() {
|
|
|
549
583
|
return acc
|
|
550
584
|
}, {})
|
|
551
585
|
|
|
552
|
-
console.log(
|
|
586
|
+
console.log('Tasks by status:', tasksByStatus)
|
|
553
587
|
|
|
554
588
|
// Get detailed info for the most recent task
|
|
555
589
|
if (tasksResponse.data.length > 0) {
|
|
@@ -560,9 +594,8 @@ async function projectTaskManagement() {
|
|
|
560
594
|
console.log(`Project: ${detailedResponse.data.project.name}`)
|
|
561
595
|
console.log(`Repository: ${detailedResponse.data.repository?.repo_url || 'No repository'}`)
|
|
562
596
|
}
|
|
563
|
-
|
|
564
597
|
} catch (error) {
|
|
565
|
-
console.error(
|
|
598
|
+
console.error('Project task management failed:', error.message)
|
|
566
599
|
}
|
|
567
600
|
}
|
|
568
601
|
```
|
|
@@ -594,8 +627,8 @@ import type {
|
|
|
594
627
|
GetProjectTasksByCodespaceResponse,
|
|
595
628
|
GetCodespaceTasksByProjectRequest,
|
|
596
629
|
GetCodespaceTasksByProjectResponse,
|
|
597
|
-
CodespaceTaskDetailedResponse
|
|
630
|
+
CodespaceTaskDetailedResponse,
|
|
598
631
|
} from '@codeguide/core'
|
|
599
632
|
```
|
|
600
633
|
|
|
601
|
-
For more information, visit the [API documentation](https://docs.codeguide.dev) or check the [GitHub repository](https://github.com/codeguide/cli).
|
|
634
|
+
For more information, visit the [API documentation](https://docs.codeguide.dev) or check the [GitHub repository](https://github.com/codeguide/cli).
|