@codeguide/core 0.0.22 → 0.0.23

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/index.ts CHANGED
@@ -12,13 +12,21 @@ export * from './services'
12
12
  export * from './types'
13
13
 
14
14
  // Export commonly used types for convenience
15
- export type { ConnectRepositoryRequest, ConnectRepositoryResponse } from './services/projects/project-types'
15
+ export type {
16
+ ConnectRepositoryRequest,
17
+ ConnectRepositoryResponse,
18
+ ProjectRepository,
19
+ GetProjectsRequest,
20
+ PaginatedProjectsRequest,
21
+ PaginatedProjectsResponse
22
+ } from './services/projects/project-types'
16
23
  export type {
17
24
  CreateCodespaceTaskRequestV2 as CreateCodespaceTaskRequest,
18
25
  CreateCodespaceTaskResponseV2 as CreateCodespaceTaskResponse,
19
26
  CreateBackgroundCodespaceTaskRequest,
20
27
  CreateBackgroundCodespaceTaskResponse,
21
28
  ModelApiKey,
29
+ Attachment,
22
30
  GetCodespaceTaskResponse,
23
31
  CodespaceTaskData,
24
32
  TechnicalDocument,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeguide/core",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "description": "Core package for code guidance with programmatic API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,6 +10,9 @@ import {
10
10
  CreateBackgroundCodespaceTaskResponse,
11
11
  GetCodespaceTaskResponse,
12
12
  GetProjectTasksByCodespaceResponse,
13
+ GetCodespaceTasksByProjectRequest,
14
+ GetCodespaceTasksByProjectResponse,
15
+ CodespaceTaskDetailedResponse,
13
16
  } from './codespace-types'
14
17
 
15
18
  export class CodespaceService extends BaseService {
@@ -17,16 +20,22 @@ export class CodespaceService extends BaseService {
17
20
  return this.post<GenerateTaskTitleResponse>('/codespace/generate-task-title', request)
18
21
  }
19
22
 
20
- async createCodespaceTask(request: CreateCodespaceTaskRequest): Promise<CreateCodespaceTaskResponse> {
23
+ async createCodespaceTask(
24
+ request: CreateCodespaceTaskRequest
25
+ ): Promise<CreateCodespaceTaskResponse> {
21
26
  return this.post<CreateCodespaceTaskResponse>('/codespace/create-task', request)
22
27
  }
23
28
 
24
- async createCodespaceTaskV2(request: CreateCodespaceTaskRequestV2): Promise<CreateCodespaceTaskResponseV2> {
29
+ async createCodespaceTaskV2(
30
+ request: CreateCodespaceTaskRequestV2
31
+ ): Promise<CreateCodespaceTaskResponseV2> {
25
32
  this.validateCodespaceTaskRequest(request)
26
33
  return this.post<CreateCodespaceTaskResponseV2>('/codespace/task', request)
27
34
  }
28
35
 
29
- async createBackgroundCodespaceTask(request: CreateBackgroundCodespaceTaskRequest): Promise<CreateBackgroundCodespaceTaskResponse> {
36
+ async createBackgroundCodespaceTask(
37
+ request: CreateBackgroundCodespaceTaskRequest
38
+ ): Promise<CreateBackgroundCodespaceTaskResponse> {
30
39
  this.validateCodespaceTaskRequest(request)
31
40
  return this.post<CreateBackgroundCodespaceTaskResponse>('/codespace/task/background', request)
32
41
  }
@@ -38,11 +47,41 @@ export class CodespaceService extends BaseService {
38
47
  return this.get<GetCodespaceTaskResponse>(`/codespace/task/${codespaceTaskId}`)
39
48
  }
40
49
 
41
- async getProjectTasksByCodespace(codespaceTaskId: string): Promise<GetProjectTasksByCodespaceResponse> {
50
+ async getProjectTasksByCodespace(
51
+ codespaceTaskId: string
52
+ ): Promise<GetProjectTasksByCodespaceResponse> {
42
53
  if (!codespaceTaskId) {
43
54
  throw new Error('codespace_task_id is required')
44
55
  }
45
- return this.get<GetProjectTasksByCodespaceResponse>(`/project-tasks/by-codespace/${codespaceTaskId}`)
56
+ return this.get<GetProjectTasksByCodespaceResponse>(
57
+ `/project-tasks/by-codespace/${codespaceTaskId}`
58
+ )
59
+ }
60
+
61
+ async getCodespaceTasksByProject(
62
+ params: GetCodespaceTasksByProjectRequest
63
+ ): Promise<GetCodespaceTasksByProjectResponse> {
64
+ if (!params.project_id) {
65
+ throw new Error('project_id is required')
66
+ }
67
+
68
+ const queryParams = new URLSearchParams()
69
+
70
+ if (params.status) queryParams.append('status', params.status)
71
+ if (params.limit !== undefined) queryParams.append('limit', params.limit.toString())
72
+ if (params.offset !== undefined) queryParams.append('offset', params.offset.toString())
73
+ if (params.sort_by) queryParams.append('sort_by', params.sort_by)
74
+ if (params.sort_order) queryParams.append('sort_order', params.sort_order)
75
+
76
+ const url = `/codespace/tasks/project/${params.project_id}${queryParams.toString() ? `?${queryParams.toString()}` : ''}`
77
+ return this.get<GetCodespaceTasksByProjectResponse>(url)
78
+ }
79
+
80
+ async getCodespaceTaskDetailed(codespaceTaskId: string): Promise<CodespaceTaskDetailedResponse> {
81
+ if (!codespaceTaskId) {
82
+ throw new Error('codespace_task_id is required')
83
+ }
84
+ return this.get<CodespaceTaskDetailedResponse>(`/codespace/task/${codespaceTaskId}/detailed`)
46
85
  }
47
86
 
48
87
  private validateCodespaceTaskRequest(request: CreateCodespaceTaskRequestV2): void {
@@ -54,7 +93,10 @@ export class CodespaceService extends BaseService {
54
93
  throw new Error('task_description is required')
55
94
  }
56
95
 
57
- if (request.execution_mode && !['implementation', 'docs-only'].includes(request.execution_mode)) {
96
+ if (
97
+ request.execution_mode &&
98
+ !['implementation', 'docs-only'].includes(request.execution_mode)
99
+ ) {
58
100
  throw new Error('execution_mode must be either "implementation" or "docs-only"')
59
101
  }
60
102
 
@@ -79,4 +121,4 @@ export class CodespaceService extends BaseService {
79
121
  request.base_branch = 'main'
80
122
  }
81
123
  }
82
- }
124
+ }
@@ -25,6 +25,14 @@ export interface ModelApiKey {
25
25
  api_key: string
26
26
  }
27
27
 
28
+ export interface Attachment {
29
+ filename: string
30
+ file_data: string // bytes (base64)
31
+ mime_type: string
32
+ file_size: number
33
+ description?: string
34
+ }
35
+
28
36
  export interface CreateCodespaceTaskRequestV2 {
29
37
  project_id: string
30
38
  project_repository_id?: string
@@ -40,6 +48,8 @@ export interface CreateCodespaceTaskRequestV2 {
40
48
  execution_mode?: 'implementation' | 'docs-only'
41
49
  model_name?: string
42
50
  starter_kit_repo?: string
51
+ use_enhanced_summary?: boolean
52
+ attachments?: Attachment[]
43
53
  }
44
54
 
45
55
  export interface CreateCodespaceTaskResponseV2 {
@@ -124,4 +134,34 @@ export interface GetProjectTasksByCodespaceResponse {
124
134
 
125
135
  export interface CreateBackgroundCodespaceTaskRequest extends CreateCodespaceTaskRequestV2 {}
126
136
 
127
- export interface CreateBackgroundCodespaceTaskResponse extends CreateCodespaceTaskResponseV2 {}
137
+ export interface CreateBackgroundCodespaceTaskResponse extends CreateCodespaceTaskResponseV2 {}
138
+
139
+ // Request parameters for getting codespace tasks by project
140
+ export interface GetCodespaceTasksByProjectRequest {
141
+ project_id: string
142
+ status?: 'completed' | 'failed' | 'in_progress' | 'created' | 'cancelled'
143
+ limit?: number
144
+ offset?: number
145
+ sort_by?: string
146
+ sort_order?: 'asc' | 'desc'
147
+ }
148
+
149
+ // Response for getting codespace tasks by project
150
+ export interface GetCodespaceTasksByProjectResponse {
151
+ status: string
152
+ data: CodespaceTaskData[]
153
+ total_count: number
154
+ message: string
155
+ }
156
+
157
+ // Response for getting detailed codespace task with relations
158
+ export interface CodespaceTaskDetailedResponse {
159
+ status: string
160
+ data: {
161
+ task: CodespaceTaskData
162
+ project: any // Project data structure
163
+ repository: any // Repository data structure
164
+ usage_summary: any // Usage statistics
165
+ }
166
+ message: string
167
+ }
@@ -8,6 +8,7 @@ export type {
8
8
  CreateBackgroundCodespaceTaskRequest,
9
9
  CreateBackgroundCodespaceTaskResponse,
10
10
  ModelApiKey,
11
+ Attachment,
11
12
  GetCodespaceTaskResponse,
12
13
  CodespaceTaskData,
13
14
  TechnicalDocument,
@@ -0,0 +1,226 @@
1
+ # Projects Service
2
+
3
+ The Projects Service provides functionality for managing projects and their associated repositories. This service includes filtering capabilities to retrieve projects based on whether they have connected repositories.
4
+
5
+ ## Features
6
+
7
+ ### Project Filtering by Repository Status
8
+
9
+ The service supports filtering projects based on whether they have connected repositories using the `has_repository` parameter.
10
+
11
+ #### API Methods
12
+
13
+ ##### `getAllProjects(params?: GetProjectsRequest): Promise<Project[]>`
14
+
15
+ Retrieves a list of all projects with optional filtering.
16
+
17
+ ```typescript
18
+ // Get all projects with repositories
19
+ const projectsWithRepos = await codeGuide.project.getAllProjects({
20
+ has_repository: true
21
+ })
22
+
23
+ // Get all projects without repositories
24
+ const projectsWithoutRepos = await codeGuide.project.getAllProjects({
25
+ has_repository: false
26
+ })
27
+ ```
28
+
29
+ ##### `getPaginatedProjects(params: PaginatedProjectsRequest): Promise<PaginatedProjectsResponse>`
30
+
31
+ Retrieves paginated projects with advanced filtering options.
32
+
33
+ ```typescript
34
+ // Combine repository filter with other filters
35
+ const paginatedProjects = await codeGuide.project.getPaginatedProjects({
36
+ page: 1,
37
+ page_size: 10,
38
+ has_repository: true,
39
+ status: 'active',
40
+ search_query: 'web',
41
+ sort_by_date: 'desc'
42
+ })
43
+ ```
44
+
45
+ ### Types
46
+
47
+ #### `GetProjectsRequest`
48
+
49
+ ```typescript
50
+ interface GetProjectsRequest {
51
+ has_repository?: boolean // Filter by repository status
52
+ }
53
+ ```
54
+
55
+ #### `PaginatedProjectsRequest`
56
+
57
+ ```typescript
58
+ interface PaginatedProjectsRequest {
59
+ page?: number
60
+ page_size?: number
61
+ search_query?: string
62
+ status?: string
63
+ start_date?: string
64
+ end_date?: string
65
+ sort_by_date?: 'asc' | 'desc'
66
+ has_repository?: boolean // Filter by repository status
67
+ }
68
+ ```
69
+
70
+ #### `ProjectRepository`
71
+
72
+ ```typescript
73
+ interface ProjectRepository {
74
+ id: string
75
+ project_id: string
76
+ repo_url: string
77
+ branch: string
78
+ author: string
79
+ name: string
80
+ connection_status: 'pending' | 'connected' | 'failed'
81
+ created_at: string
82
+ updated_at: string
83
+ }
84
+ ```
85
+
86
+ #### `Project`
87
+
88
+ ```typescript
89
+ interface Project {
90
+ id: string
91
+ title: string
92
+ description: string
93
+ user_id: string
94
+ created_at: string
95
+ updated_at: string
96
+ project_documents: ProjectDocument[]
97
+ project_repositories: ProjectRepository[] // Added for repository information
98
+ category?: Category
99
+ codie_tool?: CodieTool
100
+ github_url?: string
101
+ status?: string
102
+ tools_selected?: string[]
103
+ ai_questionaire?: Record<string, any>
104
+ project_outline?: Record<string, any>
105
+ }
106
+ ```
107
+
108
+ ## Usage Examples
109
+
110
+ ### Basic Filtering
111
+
112
+ ```typescript
113
+ import { CodeGuide } from '@codeguide/core'
114
+
115
+ const codeGuide = new CodeGuide({
116
+ baseURL: 'https://api.example.com',
117
+ apiKey: 'your-api-key'
118
+ })
119
+
120
+ // Get projects that have repositories connected
121
+ const projectsWithRepos = await codeGuide.project.getAllProjects({
122
+ has_repository: true
123
+ })
124
+
125
+ console.log('Projects with repositories:', projectsWithRepos.length)
126
+ projectsWithRepos.forEach(project => {
127
+ console.log(`${project.title} - ${project.project_repositories.length} repositories`)
128
+ })
129
+ ```
130
+
131
+ ### Advanced Filtering
132
+
133
+ ```typescript
134
+ // Get paginated projects without repositories, filtered by status and search
135
+ const filteredProjects = await codeGuide.project.getPaginatedProjects({
136
+ page: 1,
137
+ page_size: 20,
138
+ has_repository: false,
139
+ status: 'in_progress',
140
+ search_query: 'mobile'
141
+ })
142
+
143
+ console.log(`Found ${filteredProjects.pagination.total} projects`)
144
+ filteredProjects.data.forEach(project => {
145
+ console.log(`${project.title} - No repositories connected`)
146
+ })
147
+ ```
148
+
149
+ ### Combining with Other Features
150
+
151
+ ```typescript
152
+ // Connect a repository to a project
153
+ const connectionResult = await codeGuide.project.connectRepository(
154
+ projectId,
155
+ {
156
+ repo_url: 'https://github.com/user/repo',
157
+ branch: 'main',
158
+ github_token: 'optional-token'
159
+ }
160
+ )
161
+
162
+ // After connecting, verify the project appears in filtered results
163
+ const updatedProjects = await codeGuide.project.getAllProjects({
164
+ has_repository: true
165
+ })
166
+
167
+ const isProjectInFilteredResults = updatedProjects.some(
168
+ project => project.id === projectId
169
+ )
170
+ ```
171
+
172
+ ## Response Format
173
+
174
+ The API response includes project data with repository information:
175
+
176
+ ```json
177
+ {
178
+ "status": "success",
179
+ "data": [
180
+ {
181
+ "id": "project-uuid",
182
+ "title": "My Project",
183
+ "description": "Project description",
184
+ "project_repositories": [
185
+ {
186
+ "id": "repo-uuid",
187
+ "project_id": "project-uuid",
188
+ "repo_url": "https://github.com/user/repo",
189
+ "branch": "main",
190
+ "author": "user",
191
+ "name": "repo",
192
+ "connection_status": "connected",
193
+ "created_at": "2023-01-01T00:00:00Z",
194
+ "updated_at": "2023-01-01T00:00:00Z"
195
+ }
196
+ ],
197
+ "created_at": "2023-01-01T00:00:00Z",
198
+ "updated_at": "2023-01-01T00:00:00Z"
199
+ }
200
+ ]
201
+ }
202
+ ```
203
+
204
+ ## Error Handling
205
+
206
+ The service includes validation for repository connections:
207
+
208
+ ```typescript
209
+ try {
210
+ await codeGuide.project.connectRepository(projectId, {
211
+ repo_url: 'invalid-url',
212
+ branch: 'main'
213
+ })
214
+ } catch (error) {
215
+ console.error('Connection failed:', error.message)
216
+ // Example: "Repository URL must be a valid GitHub URL (e.g., https://github.com/user/repo)"
217
+ }
218
+ ```
219
+
220
+ ## Notes
221
+
222
+ - The `has_repository` parameter is optional
223
+ - When `has_repository=true`, only projects with at least one connected repository are returned
224
+ - When `has_repository=false`, only projects with no connected repositories are returned
225
+ - Repository information is included in the `project_repositories` field of each project
226
+ - The filtering works with both basic project listing and paginated queries
@@ -7,6 +7,7 @@ import {
7
7
  ProjectResponse,
8
8
  PaginatedProjectsRequest,
9
9
  PaginatedProjectsResponse,
10
+ GetProjectsRequest,
10
11
  GetProjectDocumentsRequest,
11
12
  GetProjectDocumentsResponse,
12
13
  ConnectRepositoryRequest,
@@ -14,8 +15,15 @@ import {
14
15
  } from './project-types'
15
16
 
16
17
  export class ProjectService extends BaseService {
17
- async getAllProjects(): Promise<Project[]> {
18
- const response = await this.get<ProjectListResponse>('/projects')
18
+ async getAllProjects(params?: GetProjectsRequest): Promise<Project[]> {
19
+ const queryParams = new URLSearchParams()
20
+
21
+ if (params?.has_repository !== undefined) {
22
+ queryParams.append('has_repository', params.has_repository.toString())
23
+ }
24
+
25
+ const url = `/projects${queryParams.toString() ? `?${queryParams.toString()}` : ''}`
26
+ const response = await this.get<ProjectListResponse>(url)
19
27
  return response.data
20
28
  }
21
29
 
@@ -29,6 +37,7 @@ export class ProjectService extends BaseService {
29
37
  if (params.start_date) queryParams.append('start_date', params.start_date)
30
38
  if (params.end_date) queryParams.append('end_date', params.end_date)
31
39
  if (params.sort_by_date) queryParams.append('sort_by_date', params.sort_by_date)
40
+ if (params.has_repository !== undefined) queryParams.append('has_repository', params.has_repository.toString())
32
41
 
33
42
  const url = `/projects/paginated${queryParams.toString() ? `?${queryParams.toString()}` : ''}`
34
43
  return this.get<PaginatedProjectsResponse>(url)
@@ -1,3 +1,15 @@
1
+ export interface ProjectRepository {
2
+ id: string
3
+ project_id: string
4
+ repo_url: string
5
+ branch: string
6
+ author: string
7
+ name: string
8
+ connection_status: 'pending' | 'connected' | 'failed'
9
+ created_at: string
10
+ updated_at: string
11
+ }
12
+
1
13
  export interface Project {
2
14
  id: string
3
15
  title: string
@@ -6,6 +18,7 @@ export interface Project {
6
18
  created_at: string
7
19
  updated_at: string
8
20
  project_documents: ProjectDocument[]
21
+ project_repositories: ProjectRepository[]
9
22
  category?: Category
10
23
  codie_tool?: CodieTool
11
24
  github_url?: string
@@ -86,6 +99,10 @@ export interface ProjectResponse {
86
99
  data: Project
87
100
  }
88
101
 
102
+ export interface GetProjectsRequest {
103
+ has_repository?: boolean
104
+ }
105
+
89
106
  export interface PaginatedProjectsRequest {
90
107
  page?: number
91
108
  page_size?: number
@@ -94,6 +111,7 @@ export interface PaginatedProjectsRequest {
94
111
  start_date?: string
95
112
  end_date?: string
96
113
  sort_by_date?: 'asc' | 'desc'
114
+ has_repository?: boolean
97
115
  }
98
116
 
99
117
  export interface PaginatedProjectsResponse {
@@ -1,8 +1,22 @@
1
+ import { Attachment } from '../codespace/codespace-types'
2
+
1
3
  export interface AnalyzeRepositoryRequest {
2
- repository_url: string
4
+ github_url: string
5
+ github_token?: string
3
6
  generate_documents?: boolean
4
7
  create_codespace_task?: boolean
5
8
  project_id?: string
9
+ codespace_task_description?: string
10
+ codespace_branch?: string
11
+ codespace_base_branch?: string
12
+ model_api_keys?: {
13
+ model_name: string
14
+ api_key: string
15
+ }[]
16
+ model_name?: string
17
+ starter_kit_repo?: string
18
+ use_enhanced_summary?: boolean
19
+ attachments?: Attachment[]
6
20
  }
7
21
 
8
22
  export interface AnalyzeRepositoryResponse {