@codeguide/core 0.0.27 → 0.0.29

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.
Files changed (92) hide show
  1. package/README.md +50 -41
  2. package/__tests__/services/codespace/codespace-v2.test.ts +29 -18
  3. package/__tests__/services/usage/usage-service.test.ts +597 -85
  4. package/codeguide.ts +6 -0
  5. package/dist/codeguide.d.ts +3 -1
  6. package/dist/codeguide.js +2 -0
  7. package/dist/index.d.ts +4 -3
  8. package/dist/services/base/base-service.d.ts +21 -0
  9. package/dist/services/base/base-service.js +114 -0
  10. package/dist/services/codespace/codespace-service.d.ts +55 -1
  11. package/dist/services/codespace/codespace-service.js +260 -5
  12. package/dist/services/codespace/codespace-types.d.ts +193 -13
  13. package/dist/services/codespace/index.d.ts +1 -1
  14. package/dist/services/index.d.ts +4 -0
  15. package/dist/services/index.js +7 -1
  16. package/dist/services/projects/project-types.d.ts +66 -32
  17. package/dist/services/repository-analysis/repository-types.d.ts +1 -0
  18. package/dist/services/starter-kits/index.d.ts +2 -0
  19. package/dist/services/starter-kits/index.js +20 -0
  20. package/dist/services/starter-kits/starter-kits-service.d.ts +13 -0
  21. package/dist/services/starter-kits/starter-kits-service.js +27 -0
  22. package/dist/services/starter-kits/starter-kits-types.d.ts +34 -0
  23. package/dist/services/starter-kits/starter-kits-types.js +2 -0
  24. package/dist/services/tasks/task-service.d.ts +2 -1
  25. package/dist/services/tasks/task-service.js +8 -0
  26. package/dist/services/tasks/task-types.d.ts +26 -7
  27. package/dist/services/usage/usage-service.d.ts +5 -2
  28. package/dist/services/usage/usage-service.js +58 -9
  29. package/dist/services/usage/usage-types.d.ts +207 -34
  30. package/dist/services/users/index.d.ts +2 -0
  31. package/dist/services/users/index.js +20 -0
  32. package/dist/services/users/user-service.d.ts +12 -0
  33. package/dist/services/users/user-service.js +17 -0
  34. package/dist/services/users/user-types.d.ts +55 -0
  35. package/dist/services/users/user-types.js +2 -0
  36. package/docs/.vitepress/README.md +51 -0
  37. package/docs/.vitepress/config.ts +139 -0
  38. package/docs/.vitepress/theme/custom.css +80 -0
  39. package/docs/.vitepress/theme/index.ts +13 -0
  40. package/docs/.vitepress/tsconfig.json +19 -0
  41. package/docs/QUICKSTART.md +77 -0
  42. package/docs/README.md +134 -0
  43. package/docs/README_SETUP.md +46 -0
  44. package/docs/authentication.md +351 -0
  45. package/docs/codeguide-client.md +350 -0
  46. package/docs/codespace-models.md +1004 -0
  47. package/docs/codespace-service.md +558 -81
  48. package/docs/index.md +135 -0
  49. package/docs/package.json +14 -0
  50. package/docs/projects-service.md +688 -0
  51. package/docs/security-keys-service.md +773 -0
  52. package/docs/starter-kits-service.md +249 -0
  53. package/docs/task-service.md +955 -0
  54. package/docs/testsprite_tests/TC001_Homepage_Load_and_Hero_Section_Display.py +70 -0
  55. package/docs/testsprite_tests/TC002_Sidebar_Navigation_ExpandCollapse_Functionality.py +73 -0
  56. package/docs/testsprite_tests/TC003_Full_Text_Local_Search_with_Keyboard_Shortcut.py +90 -0
  57. package/docs/testsprite_tests/TC004_Dark_Mode_Toggle_and_Persistence.py +73 -0
  58. package/docs/testsprite_tests/TC005_Mobile_Responsiveness_and_Touch_Navigation.py +113 -0
  59. package/docs/testsprite_tests/TC006_GitHub_Integration_Edit_this_page_Links.py +73 -0
  60. package/docs/testsprite_tests/TC007_Syntax_Highlighting_and_Code_Copy_Functionality.py +73 -0
  61. package/docs/testsprite_tests/TC008_Auto_Generated_Table_of_Contents_Accuracy.py +73 -0
  62. package/docs/testsprite_tests/TC009_SEO_and_Content_Discoverability_Verification.py +73 -0
  63. package/docs/testsprite_tests/TC010_Accessibility_Compliance_WCAG_AA.py +73 -0
  64. package/docs/testsprite_tests/TC011_Local_Development_Workflow_Build_and_Hot_Reload.py +74 -0
  65. package/docs/testsprite_tests/TC012_Performance_Metrics_Compliance.py +73 -0
  66. package/docs/testsprite_tests/standard_prd.json +122 -0
  67. package/docs/testsprite_tests/testsprite-mcp-test-report.html +2508 -0
  68. package/docs/testsprite_tests/testsprite-mcp-test-report.md +273 -0
  69. package/docs/testsprite_tests/testsprite_frontend_test_plan.json +390 -0
  70. package/docs/usage-service.md +616 -0
  71. package/index.ts +11 -3
  72. package/package.json +16 -2
  73. package/plans/CODESPACE_LOGS_STREAMING_GUIDE.md +320 -0
  74. package/plans/CODESPACE_TASK_LOGS_API_COMPLETE_GUIDE.md +821 -0
  75. package/services/base/base-service.ts +130 -0
  76. package/services/codespace/codespace-service.ts +347 -8
  77. package/services/codespace/codespace-types.ts +263 -14
  78. package/services/codespace/index.ts +16 -1
  79. package/services/index.ts +4 -0
  80. package/services/projects/README.md +107 -34
  81. package/services/projects/project-types.ts +69 -32
  82. package/services/repository-analysis/repository-types.ts +1 -0
  83. package/services/starter-kits/index.ts +2 -0
  84. package/services/starter-kits/starter-kits-service.ts +33 -0
  85. package/services/starter-kits/starter-kits-types.ts +38 -0
  86. package/services/tasks/task-service.ts +10 -0
  87. package/services/tasks/task-types.ts +29 -7
  88. package/services/usage/usage-service.ts +59 -10
  89. package/services/usage/usage-types.ts +239 -34
  90. package/services/users/index.ts +2 -0
  91. package/services/users/user-service.ts +15 -0
  92. package/services/users/user-types.ts +59 -0
package/README.md CHANGED
@@ -46,7 +46,7 @@ import { CodeGuide } from '@codeguide/core'
46
46
 
47
47
  const codeguide = new CodeGuide({
48
48
  baseUrl: 'https://api.codeguide.ai',
49
- databaseApiKey: 'sk_your_database_api_key'
49
+ databaseApiKey: 'sk_your_database_api_key',
50
50
  })
51
51
 
52
52
  // Get all API keys
@@ -55,7 +55,7 @@ console.log(`Found ${keysResponse.data.length} API keys`)
55
55
 
56
56
  // Create a new API key
57
57
  const newKey = await codeguide.apiKeyEnhanced.createApiKey({
58
- name: 'My Application'
58
+ name: 'My Application',
59
59
  })
60
60
  console.log(`Created key: ${newKey.data.api_key}`)
61
61
  ```
@@ -67,20 +67,20 @@ import { CodeGuide } from '@codeguide/core'
67
67
 
68
68
  const codeguide = new CodeGuide({
69
69
  baseUrl: 'https://api.codeguide.ai',
70
- databaseApiKey: 'sk_your_database_api_key'
70
+ databaseApiKey: 'sk_your_database_api_key',
71
71
  })
72
72
 
73
73
  // Create a new codespace task for implementation
74
74
  const codespaceTask = await codeguide.codespace.createCodespaceTaskV2({
75
- project_id: "your_project_id",
76
- task_description: "Implement a new feature for real-time notifications",
77
- execution_mode: "implementation"
78
- });
79
- console.log(`Created codespace task: ${codespaceTask.task_id}`);
75
+ project_id: 'your_project_id',
76
+ task_description: 'Implement a new feature for real-time notifications',
77
+ execution_mode: 'implementation',
78
+ })
79
+ console.log(`Created codespace task: ${codespaceTask.task_id}`)
80
80
 
81
81
  // Get task details
82
- const taskDetails = await codeguide.codespace.getCodespaceTask(codespaceTask.task_id);
83
- console.log(`Task status: ${taskDetails.data.status}`);
82
+ const taskDetails = await codeguide.codespace.getCodespaceTask(codespaceTask.task_id)
83
+ console.log(`Task status: ${taskDetails.data.status}`)
84
84
  ```
85
85
 
86
86
  ### Subscription Management
@@ -90,16 +90,18 @@ import { CodeGuide } from '@codeguide/core'
90
90
 
91
91
  const codeguide = new CodeGuide({
92
92
  baseUrl: 'https://api.codeguide.ai',
93
- databaseApiKey: 'sk_your_database_api_key'
93
+ databaseApiKey: 'sk_your_database_api_key',
94
94
  })
95
95
 
96
96
  // Get current subscription
97
- const subscription = await codeguide.subscription.getCurrentSubscription();
98
- console.log(`Current plan: ${subscription.data.product.name} (${subscription.data.subscription.status})`);
97
+ const subscription = await codeguide.subscription.getCurrentSubscription()
98
+ console.log(
99
+ `Current plan: ${subscription.data.product.name} (${subscription.data.subscription.status})`
100
+ )
99
101
 
100
102
  // Get all subscriptions (including historical)
101
- const allSubscriptions = await codeguide.subscription.getAllSubscriptions();
102
- console.log(`Found ${allSubscriptions.data.length} total subscriptions.`);
103
+ const allSubscriptions = await codeguide.subscription.getAllSubscriptions()
104
+ console.log(`Found ${allSubscriptions.data.length} total subscriptions.`)
103
105
  ```
104
106
 
105
107
  ### External Token Management
@@ -109,7 +111,7 @@ import { CodeGuide } from '@codeguide/core'
109
111
 
110
112
  const codeguide = new CodeGuide({
111
113
  baseUrl: 'https://api.codeguide.ai',
112
- databaseApiKey: 'sk_your_database_api_key'
114
+ databaseApiKey: 'sk_your_database_api_key',
113
115
  })
114
116
 
115
117
  // Store a GitHub token
@@ -117,13 +119,13 @@ const storedToken = await codeguide.externalTokens.storeExternalToken({
117
119
  platform: 'github',
118
120
  token: 'ghp_your_github_token',
119
121
  token_name: 'My Personal GitHub Token',
120
- token_type: 'personal_access_token'
121
- });
122
- console.log(`Stored token with ID: ${storedToken.id}`);
122
+ token_type: 'personal_access_token',
123
+ })
124
+ console.log(`Stored token with ID: ${storedToken.id}`)
123
125
 
124
126
  // List all stored GitHub tokens
125
- const githubTokens = await codeguide.externalTokens.listTokens({ platform: 'github' });
126
- console.log(`Found ${githubTokens.tokens.length} GitHub tokens.`);
127
+ const githubTokens = await codeguide.externalTokens.listTokens({ platform: 'github' })
128
+ console.log(`Found ${githubTokens.tokens.length} GitHub tokens.`)
127
129
  ```
128
130
 
129
131
  ## Authentication
@@ -137,7 +139,7 @@ Recommended method. The key must be prefixed with `sk_`.
137
139
  ```typescript
138
140
  const codeguide = new CodeGuide({
139
141
  baseUrl: 'https://api.codeguide.ai',
140
- databaseApiKey: 'sk_your_database_api_key'
142
+ databaseApiKey: 'sk_your_database_api_key',
141
143
  })
142
144
  ```
143
145
 
@@ -149,7 +151,7 @@ For backward compatibility.
149
151
  const codeguide = new CodeGuide({
150
152
  baseUrl: 'https://api.codeguide.ai',
151
153
  apiKey: 'your_api_key',
152
- userId: 'your_user_id'
154
+ userId: 'your_user_id',
153
155
  })
154
156
  ```
155
157
 
@@ -160,7 +162,7 @@ For applications using Clerk for authentication.
160
162
  ```typescript
161
163
  const codeguide = new CodeGuide({
162
164
  baseUrl: 'https://api.codeguide.ai',
163
- jwtToken: 'your_jwt_token'
165
+ jwtToken: 'your_jwt_token',
164
166
  })
165
167
  ```
166
168
 
@@ -171,10 +173,10 @@ The client automatically falls back through authentication methods based on the
171
173
  ```typescript
172
174
  const codeguide = new CodeGuide({
173
175
  baseUrl: 'https://api.codeguide.ai',
174
- databaseApiKey: 'sk_key', // Will try this first
175
- apiKey: 'legacy_key', // Fallback if database key is invalid or missing
176
- userId: 'user_id', // Required for legacy auth
177
- jwtToken: 'jwt_token' // Final fallback
176
+ databaseApiKey: 'sk_key', // Will try this first
177
+ apiKey: 'legacy_key', // Fallback if database key is invalid or missing
178
+ userId: 'user_id', // Required for legacy auth
179
+ jwtToken: 'jwt_token', // Final fallback
178
180
  })
179
181
  ```
180
182
 
@@ -252,9 +254,11 @@ const codeguide = new CodeGuide({
252
254
  - `getCreditBalance(): Promise<CreditBalanceResponse>`
253
255
  - `getUsageSummary(params?: UsageSummaryRequest): Promise<UsageSummaryResponse>`
254
256
  - `checkCredits(params: CreditCheckRequest): Promise<CreditCheckResponse>`
257
+ - `getAuthorization(): Promise<AuthorizationResponse>`
255
258
  - `healthCheck(): Promise<boolean>`
256
259
 
257
260
  ### CancellationFunnelService
261
+
258
262
  - `initiateCancellation(request: CancellationFunnelInitiateRequest): Promise<CancellationFunnelInitiateResponse>`
259
263
  - `logSurveyResponse(request: CancellationFunnelSurveyRequest): Promise<CancellationFunnelSurveyResponse>`
260
264
  - `getCancellationFunnelStatus(subscriptionId: string): Promise<any>`
@@ -264,14 +268,15 @@ const codeguide = new CodeGuide({
264
268
  The package exports all necessary types for requests and responses.
265
269
 
266
270
  ### Core Types
271
+
267
272
  ```typescript
268
273
  interface APIServiceConfig {
269
274
  baseUrl: string
270
- databaseApiKey?: string // Highest priority (sk_...)
271
- apiKey?: string // Legacy API key
272
- userId?: string // Required for legacy auth
273
- jwtToken?: string // Clerk JWT token
274
- timeout?: number // Default: 3600000 (1 hour)
275
+ databaseApiKey?: string // Highest priority (sk_...)
276
+ apiKey?: string // Legacy API key
277
+ userId?: string // Required for legacy auth
278
+ jwtToken?: string // Clerk JWT token
279
+ timeout?: number // Default: 3600000 (1 hour)
275
280
  }
276
281
 
277
282
  interface CodeGuideOptions {
@@ -282,6 +287,7 @@ interface CodeGuideOptions {
282
287
  ```
283
288
 
284
289
  ### Key Service Types
290
+
285
291
  ```typescript
286
292
  // projects/project-types.ts
287
293
  interface Project {
@@ -296,7 +302,7 @@ interface Project {
296
302
  interface CreateCodespaceTaskRequestV2 {
297
303
  project_id: string
298
304
  task_description: string
299
- execution_mode?: 'implementation' | 'docs-only'
305
+ execution_mode?: 'implementation' | 'docs-only' | 'direct'
300
306
  // ... and more
301
307
  }
302
308
 
@@ -350,7 +356,7 @@ You can configure the request timeout (in milliseconds). The default is 1 hour.
350
356
  const codeguide = new CodeGuide({
351
357
  baseUrl: 'https://api.codeguide.ai',
352
358
  databaseApiKey: 'sk_your_key',
353
- timeout: 1800000 // 30 minutes
359
+ timeout: 1800000, // 30 minutes
354
360
  })
355
361
  ```
356
362
 
@@ -359,12 +365,15 @@ const codeguide = new CodeGuide({
359
365
  Enable verbose logging to see detailed request and response information in the console.
360
366
 
361
367
  ```typescript
362
- const codeguide = new CodeGuide({
363
- baseUrl: 'https://api.codeguide.ai',
364
- databaseApiKey: 'sk_your_key'
365
- }, {
366
- verbose: true // Enable detailed logging
367
- })
368
+ const codeguide = new CodeGuide(
369
+ {
370
+ baseUrl: 'https://api.codeguide.ai',
371
+ databaseApiKey: 'sk_your_key',
372
+ },
373
+ {
374
+ verbose: true, // Enable detailed logging
375
+ }
376
+ )
368
377
  ```
369
378
 
370
379
  ## Contributing
@@ -2,7 +2,7 @@ import { CodespaceService } from '../../../services/codespace/codespace-service'
2
2
  import {
3
3
  CreateCodespaceTaskRequestV2,
4
4
  CreateBackgroundCodespaceTaskRequest,
5
- ModelApiKey
5
+ ModelApiKey,
6
6
  } from '../../../services/codespace/codespace-types'
7
7
  import { APIServiceConfig } from '../../../types'
8
8
  import axios from 'axios'
@@ -55,8 +55,9 @@ describe('CodespaceService - V2 Task Endpoints', () => {
55
55
  task_description: 'Create a new feature',
56
56
  }
57
57
 
58
- await expect(codespaceService.createCodespaceTaskV2(invalidRequest as any))
59
- .rejects.toThrow('project_id is required')
58
+ await expect(codespaceService.createCodespaceTaskV2(invalidRequest as any)).rejects.toThrow(
59
+ 'project_id is required'
60
+ )
60
61
  })
61
62
 
62
63
  it('should throw error for missing task_description', async () => {
@@ -64,8 +65,9 @@ describe('CodespaceService - V2 Task Endpoints', () => {
64
65
  project_id: 'project-123',
65
66
  }
66
67
 
67
- await expect(codespaceService.createCodespaceTaskV2(invalidRequest as any))
68
- .rejects.toThrow('task_description is required')
68
+ await expect(codespaceService.createCodespaceTaskV2(invalidRequest as any)).rejects.toThrow(
69
+ 'task_description is required'
70
+ )
69
71
  })
70
72
 
71
73
  it('should set default base_branch to main', async () => {
@@ -80,9 +82,14 @@ describe('CodespaceService - V2 Task Endpoints', () => {
80
82
  message: 'Task created successfully',
81
83
  }
82
84
 
83
- mockAxios.onPost('/codespace/task', expect.objectContaining({
84
- base_branch: 'main'
85
- })).reply(200, mockResponse)
85
+ mockAxios
86
+ .onPost(
87
+ '/codespace/task',
88
+ expect.objectContaining({
89
+ base_branch: 'main',
90
+ })
91
+ )
92
+ .reply(200, mockResponse)
86
93
 
87
94
  const result = await codespaceService.createCodespaceTaskV2(requestWithoutBaseBranch)
88
95
 
@@ -96,12 +103,13 @@ describe('CodespaceService - V2 Task Endpoints', () => {
96
103
  execution_mode: 'invalid-mode' as any,
97
104
  }
98
105
 
99
- await expect(codespaceService.createCodespaceTaskV2(invalidRequest))
100
- .rejects.toThrow('execution_mode must be either "implementation" or "docs-only"')
106
+ await expect(codespaceService.createCodespaceTaskV2(invalidRequest)).rejects.toThrow(
107
+ 'execution_mode must be either "implementation", "docs-only", or "direct"'
108
+ )
101
109
  })
102
110
 
103
111
  it('should accept valid execution modes', async () => {
104
- const validModes = ['implementation', 'docs-only'] as const
112
+ const validModes = ['implementation', 'docs-only', 'direct'] as const
105
113
 
106
114
  for (const mode of validModes) {
107
115
  const request = {
@@ -130,8 +138,9 @@ describe('CodespaceService - V2 Task Endpoints', () => {
130
138
  model_api_keys: 'not-an-array' as any,
131
139
  }
132
140
 
133
- await expect(codespaceService.createCodespaceTaskV2(invalidRequest))
134
- .rejects.toThrow('model_api_keys must be an array')
141
+ await expect(codespaceService.createCodespaceTaskV2(invalidRequest)).rejects.toThrow(
142
+ 'model_api_keys must be an array'
143
+ )
135
144
  })
136
145
 
137
146
  it('should validate individual model_api_key entries', async () => {
@@ -144,8 +153,9 @@ describe('CodespaceService - V2 Task Endpoints', () => {
144
153
  ],
145
154
  }
146
155
 
147
- await expect(codespaceService.createCodespaceTaskV2(invalidRequest))
148
- .rejects.toThrow('Each model_api_key must have a valid model_name string')
156
+ await expect(codespaceService.createCodespaceTaskV2(invalidRequest)).rejects.toThrow(
157
+ 'Each model_api_key must have a valid model_name string'
158
+ )
149
159
  })
150
160
 
151
161
  it('should accept valid model_api_keys', async () => {
@@ -233,8 +243,9 @@ describe('CodespaceService - V2 Task Endpoints', () => {
233
243
  task_description: 'Missing project_id',
234
244
  }
235
245
 
236
- await expect(codespaceService.createBackgroundCodespaceTask(invalidRequest as any))
237
- .rejects.toThrow('project_id is required')
246
+ await expect(
247
+ codespaceService.createBackgroundCodespaceTask(invalidRequest as any)
248
+ ).rejects.toThrow('project_id is required')
238
249
  })
239
250
 
240
251
  it('should work with docs-only mode', async () => {
@@ -257,4 +268,4 @@ describe('CodespaceService - V2 Task Endpoints', () => {
257
268
  expect(result).toEqual(mockResponse)
258
269
  })
259
270
  })
260
- })
271
+ })