specweave 0.24.6 → 0.24.9
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/CLAUDE.md +64 -0
- package/README.md +34 -0
- package/dist/src/cli/commands/init.d.ts.map +1 -1
- package/dist/src/cli/commands/init.js +3 -1
- package/dist/src/cli/commands/init.js.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/github-multi-repo.d.ts +5 -2
- package/dist/src/cli/helpers/issue-tracker/github-multi-repo.d.ts.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/github-multi-repo.js +90 -8
- package/dist/src/cli/helpers/issue-tracker/github-multi-repo.js.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/github.d.ts +2 -1
- package/dist/src/cli/helpers/issue-tracker/github.d.ts.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/github.js +4 -3
- package/dist/src/cli/helpers/issue-tracker/github.js.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/index.d.ts.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/index.js +26 -9
- package/dist/src/cli/helpers/issue-tracker/index.js.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/types.d.ts +1 -0
- package/dist/src/cli/helpers/issue-tracker/types.d.ts.map +1 -1
- package/dist/src/cli/helpers/issue-tracker/types.js.map +1 -1
- package/dist/src/core/repo-structure/git-error-handler.d.ts +37 -0
- package/dist/src/core/repo-structure/git-error-handler.d.ts.map +1 -0
- package/dist/src/core/repo-structure/git-error-handler.js +214 -0
- package/dist/src/core/repo-structure/git-error-handler.js.map +1 -0
- package/dist/src/core/repo-structure/git-provider.d.ts +183 -0
- package/dist/src/core/repo-structure/git-provider.d.ts.map +1 -0
- package/dist/src/core/repo-structure/git-provider.js +57 -0
- package/dist/src/core/repo-structure/git-provider.js.map +1 -0
- package/dist/src/core/repo-structure/github-validator.d.ts +1 -0
- package/dist/src/core/repo-structure/github-validator.d.ts.map +1 -1
- package/dist/src/core/repo-structure/github-validator.js +35 -9
- package/dist/src/core/repo-structure/github-validator.js.map +1 -1
- package/dist/src/core/repo-structure/platform-registry.d.ts +114 -0
- package/dist/src/core/repo-structure/platform-registry.d.ts.map +1 -0
- package/dist/src/core/repo-structure/platform-registry.js +206 -0
- package/dist/src/core/repo-structure/platform-registry.js.map +1 -0
- package/dist/src/core/repo-structure/prompt-consolidator.d.ts +42 -0
- package/dist/src/core/repo-structure/prompt-consolidator.d.ts.map +1 -1
- package/dist/src/core/repo-structure/prompt-consolidator.js +102 -0
- package/dist/src/core/repo-structure/prompt-consolidator.js.map +1 -1
- package/dist/src/core/repo-structure/providers/azure-devops-provider.d.ts +64 -0
- package/dist/src/core/repo-structure/providers/azure-devops-provider.d.ts.map +1 -0
- package/dist/src/core/repo-structure/providers/azure-devops-provider.js +263 -0
- package/dist/src/core/repo-structure/providers/azure-devops-provider.js.map +1 -0
- package/dist/src/core/repo-structure/providers/bitbucket-provider.d.ts +55 -0
- package/dist/src/core/repo-structure/providers/bitbucket-provider.d.ts.map +1 -0
- package/dist/src/core/repo-structure/providers/bitbucket-provider.js +238 -0
- package/dist/src/core/repo-structure/providers/bitbucket-provider.js.map +1 -0
- package/dist/src/core/repo-structure/providers/github-provider.d.ts +53 -0
- package/dist/src/core/repo-structure/providers/github-provider.d.ts.map +1 -0
- package/dist/src/core/repo-structure/providers/github-provider.js +239 -0
- package/dist/src/core/repo-structure/providers/github-provider.js.map +1 -0
- package/dist/src/core/repo-structure/providers/gitlab-provider.d.ts +51 -0
- package/dist/src/core/repo-structure/providers/gitlab-provider.d.ts.map +1 -0
- package/dist/src/core/repo-structure/providers/gitlab-provider.js +251 -0
- package/dist/src/core/repo-structure/providers/gitlab-provider.js.map +1 -0
- package/dist/src/core/repo-structure/providers/index.d.ts +35 -0
- package/dist/src/core/repo-structure/providers/index.d.ts.map +1 -0
- package/dist/src/core/repo-structure/providers/index.js +68 -0
- package/dist/src/core/repo-structure/providers/index.js.map +1 -0
- package/dist/src/core/repo-structure/providers/local-provider.d.ts +61 -0
- package/dist/src/core/repo-structure/providers/local-provider.d.ts.map +1 -0
- package/dist/src/core/repo-structure/providers/local-provider.js +148 -0
- package/dist/src/core/repo-structure/providers/local-provider.js.map +1 -0
- package/dist/src/core/repo-structure/repo-structure-manager.d.ts +21 -4
- package/dist/src/core/repo-structure/repo-structure-manager.d.ts.map +1 -1
- package/dist/src/core/repo-structure/repo-structure-manager.js +380 -113
- package/dist/src/core/repo-structure/repo-structure-manager.js.map +1 -1
- package/dist/src/core/repo-structure/url-generator.d.ts +80 -0
- package/dist/src/core/repo-structure/url-generator.d.ts.map +1 -0
- package/dist/src/core/repo-structure/url-generator.js +110 -0
- package/dist/src/core/repo-structure/url-generator.js.map +1 -0
- package/package.json +1 -1
- package/plugins/specweave/hooks/post-task-completion.sh +69 -175
- package/plugins/specweave/lib/hooks/consolidated-sync.js +183 -0
- package/plugins/specweave-github/hooks/.specweave/logs/hooks-debug.log +64 -0
- package/plugins/specweave-release/hooks/.specweave/logs/dora-tracking.log +96 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git Provider Error Handler
|
|
3
|
+
*
|
|
4
|
+
* Provides actionable error messages for common Git API errors (401, 403, 404, etc.)
|
|
5
|
+
* with platform-specific guidance and troubleshooting steps.
|
|
6
|
+
*
|
|
7
|
+
* @module git-error-handler
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Convert API error to actionable error with suggestions
|
|
11
|
+
*
|
|
12
|
+
* @param error - Git API error details
|
|
13
|
+
* @returns Actionable error with troubleshooting steps
|
|
14
|
+
*/
|
|
15
|
+
export function getActionableError(error) {
|
|
16
|
+
switch (error.status) {
|
|
17
|
+
case 401:
|
|
18
|
+
return handle401Unauthorized(error);
|
|
19
|
+
case 403:
|
|
20
|
+
return handle403Forbidden(error);
|
|
21
|
+
case 404:
|
|
22
|
+
return handle404NotFound(error);
|
|
23
|
+
case 422:
|
|
24
|
+
return handle422UnprocessableEntity(error);
|
|
25
|
+
default:
|
|
26
|
+
return handleGenericError(error);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Handle 401 Unauthorized errors
|
|
31
|
+
*/
|
|
32
|
+
function handle401Unauthorized(error) {
|
|
33
|
+
const platformName = getPlatformDisplayName(error.platform);
|
|
34
|
+
return {
|
|
35
|
+
title: 'Authentication Failed (401)',
|
|
36
|
+
message: `Your ${platformName} token is invalid or has expired.`,
|
|
37
|
+
suggestions: [
|
|
38
|
+
`Verify your ${platformName} token is correct`,
|
|
39
|
+
'Check if the token has expired',
|
|
40
|
+
'Ensure the token has not been revoked',
|
|
41
|
+
`Generate a new token at: ${getTokenUrl(error.platform)}`,
|
|
42
|
+
'Update your .env file with the new token',
|
|
43
|
+
`Required scopes: ${getRequiredScopes(error.platform)}`
|
|
44
|
+
],
|
|
45
|
+
helpUrl: getTokenUrl(error.platform)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Handle 403 Forbidden errors
|
|
50
|
+
*/
|
|
51
|
+
function handle403Forbidden(error) {
|
|
52
|
+
const platformName = getPlatformDisplayName(error.platform);
|
|
53
|
+
const suggestions = [
|
|
54
|
+
`Your ${platformName} token lacks required permissions`,
|
|
55
|
+
'Check token scopes/permissions',
|
|
56
|
+
`Required scopes: ${getRequiredScopes(error.platform)}`,
|
|
57
|
+
];
|
|
58
|
+
if (error.operation === 'create_repo' && error.resourceType === 'organization') {
|
|
59
|
+
suggestions.push('For organizations: Ensure you have admin access', 'Organization may restrict repository creation', 'Contact organization admin if needed');
|
|
60
|
+
}
|
|
61
|
+
suggestions.push(`Regenerate token with correct scopes: ${getTokenUrl(error.platform)}`);
|
|
62
|
+
return {
|
|
63
|
+
title: 'Permission Denied (403)',
|
|
64
|
+
message: `You don't have permission to perform this operation on ${platformName}.`,
|
|
65
|
+
suggestions,
|
|
66
|
+
helpUrl: getTokenUrl(error.platform)
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Handle 404 Not Found errors
|
|
71
|
+
*/
|
|
72
|
+
function handle404NotFound(error) {
|
|
73
|
+
const platformName = getPlatformDisplayName(error.platform);
|
|
74
|
+
const resourceType = error.resourceType || 'resource';
|
|
75
|
+
const resourceName = error.resourceName || 'unknown';
|
|
76
|
+
let message;
|
|
77
|
+
let suggestions;
|
|
78
|
+
if (error.operation === 'validate_owner') {
|
|
79
|
+
message = `${resourceType === 'organization' ? 'Organization' : 'User'} "${resourceName}" not found on ${platformName}.`;
|
|
80
|
+
suggestions = [
|
|
81
|
+
'Check the spelling of the username/organization',
|
|
82
|
+
`Verify the account exists on ${platformName}`,
|
|
83
|
+
'Ensure it\'s a public account or you have access',
|
|
84
|
+
'Use your personal username if unsure'
|
|
85
|
+
];
|
|
86
|
+
}
|
|
87
|
+
else if (error.operation === 'validate_repo') {
|
|
88
|
+
message = `Repository "${resourceName}" not found on ${platformName}.`;
|
|
89
|
+
suggestions = [
|
|
90
|
+
'Check the repository name spelling',
|
|
91
|
+
'Verify the repository exists',
|
|
92
|
+
'Ensure you have access to private repositories',
|
|
93
|
+
'Repository may have been deleted or renamed'
|
|
94
|
+
];
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
message = `${resourceType} "${resourceName}" not found on ${platformName}.`;
|
|
98
|
+
suggestions = [
|
|
99
|
+
'Double-check the name/path',
|
|
100
|
+
'Verify it exists on the platform',
|
|
101
|
+
'Check your access permissions'
|
|
102
|
+
];
|
|
103
|
+
}
|
|
104
|
+
return {
|
|
105
|
+
title: 'Resource Not Found (404)',
|
|
106
|
+
message,
|
|
107
|
+
suggestions
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Handle 422 Unprocessable Entity errors (e.g., repo already exists)
|
|
112
|
+
*/
|
|
113
|
+
function handle422UnprocessableEntity(error) {
|
|
114
|
+
const platformName = getPlatformDisplayName(error.platform);
|
|
115
|
+
return {
|
|
116
|
+
title: 'Validation Error (422)',
|
|
117
|
+
message: `${platformName} could not process the request.`,
|
|
118
|
+
suggestions: [
|
|
119
|
+
'Repository name may already exist',
|
|
120
|
+
'Check if the repository was already created',
|
|
121
|
+
'Choose a different repository name',
|
|
122
|
+
'Invalid characters in repository name',
|
|
123
|
+
'Repository name may be too long'
|
|
124
|
+
]
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Handle generic errors
|
|
129
|
+
*/
|
|
130
|
+
function handleGenericError(error) {
|
|
131
|
+
const platformName = getPlatformDisplayName(error.platform);
|
|
132
|
+
return {
|
|
133
|
+
title: `API Error (${error.status})`,
|
|
134
|
+
message: error.message || `An error occurred while communicating with ${platformName}.`,
|
|
135
|
+
suggestions: [
|
|
136
|
+
'Check your internet connection',
|
|
137
|
+
`Verify ${platformName} is accessible`,
|
|
138
|
+
'Try again in a few moments',
|
|
139
|
+
'Check ${platformName} status page for outages'
|
|
140
|
+
]
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Get platform display name
|
|
145
|
+
*/
|
|
146
|
+
function getPlatformDisplayName(platform) {
|
|
147
|
+
switch (platform) {
|
|
148
|
+
case 'github':
|
|
149
|
+
return 'GitHub';
|
|
150
|
+
case 'gitlab':
|
|
151
|
+
return 'GitLab';
|
|
152
|
+
case 'bitbucket':
|
|
153
|
+
return 'Bitbucket';
|
|
154
|
+
case 'azure-devops':
|
|
155
|
+
return 'Azure DevOps';
|
|
156
|
+
default:
|
|
157
|
+
return platform;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Get token creation URL for platform
|
|
162
|
+
*/
|
|
163
|
+
function getTokenUrl(platform) {
|
|
164
|
+
switch (platform) {
|
|
165
|
+
case 'github':
|
|
166
|
+
return 'https://github.com/settings/tokens/new';
|
|
167
|
+
case 'gitlab':
|
|
168
|
+
return 'https://gitlab.com/-/profile/personal_access_tokens';
|
|
169
|
+
case 'bitbucket':
|
|
170
|
+
return 'https://bitbucket.org/account/settings/app-passwords/';
|
|
171
|
+
case 'azure-devops':
|
|
172
|
+
return 'https://dev.azure.com/{organization}/_usersSettings/tokens';
|
|
173
|
+
default:
|
|
174
|
+
return `https://${platform}.com`;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Get required token scopes for platform
|
|
179
|
+
*/
|
|
180
|
+
function getRequiredScopes(platform) {
|
|
181
|
+
switch (platform) {
|
|
182
|
+
case 'github':
|
|
183
|
+
return 'repo, admin:org (for organizations)';
|
|
184
|
+
case 'gitlab':
|
|
185
|
+
return 'api, read_repository, write_repository';
|
|
186
|
+
case 'bitbucket':
|
|
187
|
+
return 'repository:read, repository:write';
|
|
188
|
+
case 'azure-devops':
|
|
189
|
+
return 'Code (Read & Write), Project and Team (Read, Write, & Manage)';
|
|
190
|
+
default:
|
|
191
|
+
return 'Full repository access';
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Format actionable error for display
|
|
196
|
+
*
|
|
197
|
+
* @param error - Actionable error
|
|
198
|
+
* @returns Formatted error message
|
|
199
|
+
*/
|
|
200
|
+
export function formatActionableError(error) {
|
|
201
|
+
const lines = [
|
|
202
|
+
`❌ ${error.title}`,
|
|
203
|
+
'',
|
|
204
|
+
error.message,
|
|
205
|
+
'',
|
|
206
|
+
'💡 Troubleshooting Steps:',
|
|
207
|
+
...error.suggestions.map((s, i) => ` ${i + 1}. ${s}`)
|
|
208
|
+
];
|
|
209
|
+
if (error.helpUrl) {
|
|
210
|
+
lines.push('', `🔗 Help: ${error.helpUrl}`);
|
|
211
|
+
}
|
|
212
|
+
return lines.join('\n');
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=git-error-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-error-handler.js","sourceRoot":"","sources":["../../../../src/core/repo-structure/git-error-handler.ts"],"names":[],"mappings":"AA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GitLab, Bitbucket, Azure DevOps).
|
|
5
|
+
* Enables SpecWeave to work seamlessly across multiple Git platforms.
|
|
6
|
+
*
|
|
7
|
+
* @module git-provider
|
|
8
|
+
*/
|
|
9
|
+
import type { UrlType } from './url-generator.js';
|
|
10
|
+
/**
|
|
11
|
+
* Git platform type
|
|
12
|
+
*/
|
|
13
|
+
export type GitPlatformType = 'github' | 'gitlab' | 'bitbucket' | 'azure-devops' | 'local' | 'custom';
|
|
14
|
+
/**
|
|
15
|
+
* Repository visibility
|
|
16
|
+
*/
|
|
17
|
+
export type RepoVisibility = 'private' | 'public' | 'internal';
|
|
18
|
+
/**
|
|
19
|
+
* Account type (user or organization)
|
|
20
|
+
*/
|
|
21
|
+
export type AccountType = 'user' | 'organization';
|
|
22
|
+
/**
|
|
23
|
+
* Platform configuration
|
|
24
|
+
*/
|
|
25
|
+
export interface PlatformConfig {
|
|
26
|
+
/** Platform type */
|
|
27
|
+
type: GitPlatformType;
|
|
28
|
+
/** Platform display name */
|
|
29
|
+
name: string;
|
|
30
|
+
/** Default hostname (e.g., 'github.com', 'gitlab.com') */
|
|
31
|
+
host: string;
|
|
32
|
+
/** API base URL */
|
|
33
|
+
apiBaseUrl: string;
|
|
34
|
+
/** Whether this is a self-hosted instance */
|
|
35
|
+
selfHosted: boolean;
|
|
36
|
+
/** Custom domain for self-hosted instances */
|
|
37
|
+
customDomain?: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Repository creation options
|
|
41
|
+
*/
|
|
42
|
+
export interface CreateRepoOptions {
|
|
43
|
+
/** Repository name */
|
|
44
|
+
name: string;
|
|
45
|
+
/** Repository owner (user or organization) */
|
|
46
|
+
owner: string;
|
|
47
|
+
/** Repository description */
|
|
48
|
+
description: string;
|
|
49
|
+
/** Visibility (private/public/internal) */
|
|
50
|
+
visibility: RepoVisibility;
|
|
51
|
+
/** Whether to initialize with README */
|
|
52
|
+
autoInit?: boolean;
|
|
53
|
+
/** Whether to enable issues */
|
|
54
|
+
hasIssues?: boolean;
|
|
55
|
+
/** Whether to enable wiki */
|
|
56
|
+
hasWiki?: boolean;
|
|
57
|
+
/** Default branch name */
|
|
58
|
+
defaultBranch?: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Repository validation result
|
|
62
|
+
*/
|
|
63
|
+
export interface RepoValidationResult {
|
|
64
|
+
/** Whether repository exists */
|
|
65
|
+
exists: boolean;
|
|
66
|
+
/** Whether validation was successful */
|
|
67
|
+
valid: boolean;
|
|
68
|
+
/** Repository URL if exists */
|
|
69
|
+
url?: string;
|
|
70
|
+
/** Error message if validation failed */
|
|
71
|
+
error?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Owner validation result
|
|
75
|
+
*/
|
|
76
|
+
export interface OwnerValidationResult {
|
|
77
|
+
/** Whether owner is valid */
|
|
78
|
+
valid: boolean;
|
|
79
|
+
/** Account type (user or organization) */
|
|
80
|
+
type?: AccountType;
|
|
81
|
+
/** Error message if validation failed */
|
|
82
|
+
error?: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Git Provider Interface
|
|
86
|
+
*
|
|
87
|
+
* Abstract interface that all Git platform providers must implement.
|
|
88
|
+
* Enables platform-agnostic repository management.
|
|
89
|
+
*/
|
|
90
|
+
export interface GitProvider {
|
|
91
|
+
/**
|
|
92
|
+
* Platform configuration
|
|
93
|
+
*/
|
|
94
|
+
readonly config: PlatformConfig;
|
|
95
|
+
/**
|
|
96
|
+
* Validate if a repository exists
|
|
97
|
+
*
|
|
98
|
+
* @param owner - Repository owner
|
|
99
|
+
* @param repo - Repository name
|
|
100
|
+
* @param token - Authentication token (optional)
|
|
101
|
+
* @returns Validation result
|
|
102
|
+
*/
|
|
103
|
+
validateRepository(owner: string, repo: string, token?: string): Promise<RepoValidationResult>;
|
|
104
|
+
/**
|
|
105
|
+
* Validate if an owner (user or organization) exists
|
|
106
|
+
*
|
|
107
|
+
* @param owner - Owner name to validate
|
|
108
|
+
* @param token - Authentication token (optional)
|
|
109
|
+
* @returns Owner validation result
|
|
110
|
+
*/
|
|
111
|
+
validateOwner(owner: string, token?: string): Promise<OwnerValidationResult>;
|
|
112
|
+
/**
|
|
113
|
+
* Create a new repository
|
|
114
|
+
*
|
|
115
|
+
* @param options - Repository creation options
|
|
116
|
+
* @param token - Authentication token (required)
|
|
117
|
+
* @returns Repository URL
|
|
118
|
+
*/
|
|
119
|
+
createRepository(options: CreateRepoOptions, token: string): Promise<string>;
|
|
120
|
+
/**
|
|
121
|
+
* Generate Git remote URL
|
|
122
|
+
*
|
|
123
|
+
* @param owner - Repository owner
|
|
124
|
+
* @param repo - Repository name
|
|
125
|
+
* @param urlType - URL type (ssh or https)
|
|
126
|
+
* @returns Formatted remote URL
|
|
127
|
+
*/
|
|
128
|
+
getRemoteUrl(owner: string, repo: string, urlType: UrlType): string;
|
|
129
|
+
/**
|
|
130
|
+
* Check if an account is an organization
|
|
131
|
+
*
|
|
132
|
+
* @param account - Account name
|
|
133
|
+
* @param token - Authentication token (optional)
|
|
134
|
+
* @returns Whether account is an organization
|
|
135
|
+
*/
|
|
136
|
+
isOrganization(account: string, token?: string): Promise<boolean>;
|
|
137
|
+
/**
|
|
138
|
+
* Get token creation URL
|
|
139
|
+
*
|
|
140
|
+
* @returns URL where users can create access tokens
|
|
141
|
+
*/
|
|
142
|
+
getTokenUrl(): string;
|
|
143
|
+
/**
|
|
144
|
+
* Get required token scopes/permissions
|
|
145
|
+
*
|
|
146
|
+
* @param isOrganization - Whether creating repos in organization
|
|
147
|
+
* @returns List of required scopes
|
|
148
|
+
*/
|
|
149
|
+
getRequiredScopes(isOrganization?: boolean): string[];
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Base Git Provider (abstract implementation)
|
|
153
|
+
*
|
|
154
|
+
* Provides common functionality that all providers can extend.
|
|
155
|
+
*/
|
|
156
|
+
export declare abstract class BaseGitProvider implements GitProvider {
|
|
157
|
+
readonly config: PlatformConfig;
|
|
158
|
+
constructor(config: PlatformConfig);
|
|
159
|
+
abstract validateRepository(owner: string, repo: string, token?: string): Promise<RepoValidationResult>;
|
|
160
|
+
abstract validateOwner(owner: string, token?: string): Promise<OwnerValidationResult>;
|
|
161
|
+
abstract createRepository(options: CreateRepoOptions, token: string): Promise<string>;
|
|
162
|
+
abstract isOrganization(account: string, token?: string): Promise<boolean>;
|
|
163
|
+
abstract getTokenUrl(): string;
|
|
164
|
+
abstract getRequiredScopes(isOrganization?: boolean): string[];
|
|
165
|
+
/**
|
|
166
|
+
* Generate Git remote URL (common implementation)
|
|
167
|
+
*/
|
|
168
|
+
getRemoteUrl(owner: string, repo: string, urlType: UrlType): string;
|
|
169
|
+
/**
|
|
170
|
+
* Get SSH user for the platform
|
|
171
|
+
* Override for platforms that use different SSH users
|
|
172
|
+
*/
|
|
173
|
+
protected getSSHUser(): string;
|
|
174
|
+
/**
|
|
175
|
+
* Get full API URL
|
|
176
|
+
*/
|
|
177
|
+
protected getApiUrl(path: string): string;
|
|
178
|
+
/**
|
|
179
|
+
* Create authorization headers
|
|
180
|
+
*/
|
|
181
|
+
protected getAuthHeaders(token: string): Record<string, string>;
|
|
182
|
+
}
|
|
183
|
+
//# sourceMappingURL=git-provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-provider.d.ts","sourceRoot":"","sources":["../../../../src/core/repo-structure/git-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElD;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,GAAG,cAAc,GAAG,OAAO,GAAG,QAAQ,CAAC;AAEtG;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,cAAc,CAAC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AAM,GACZ,OAAO,CAAC,MAAM,CAAC;IAElB,QAAQ,CAAC,cAAc,CACrB,OAAO,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,OAAO,CAAC;IAEnB,QAAQ,CAAC,WAAW,IAAI,MAAM;IAE9B,QAAQ,CAAC,iBAAiB,CAAC,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE;IAE9D;;OAEG;IACH,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM;IAWnE;;;OAGG;IACH,SAAS,CAAC,UAAU,IAAI,MAAM;IAI9B;;OAEG;IACH,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM;IAKzC;;OAEG;IACH,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAQhE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git Provider Abstraction Layer
|
|
3
|
+
*
|
|
4
|
+
* Platform-agnostic interface for Git hosting providers (GitHub, GitLab, Bitbucket, Azure DevOps).
|
|
5
|
+
* Enables SpecWeave to work seamlessly across multiple Git platforms.
|
|
6
|
+
*
|
|
7
|
+
* @module git-provider
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Base Git Provider (abstract implementation)
|
|
11
|
+
*
|
|
12
|
+
* Provides common functionality that all providers can extend.
|
|
13
|
+
*/
|
|
14
|
+
export class BaseGitProvider {
|
|
15
|
+
constructor(config) {
|
|
16
|
+
this.config = config;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Generate Git remote URL (common implementation)
|
|
20
|
+
*/
|
|
21
|
+
getRemoteUrl(owner, repo, urlType) {
|
|
22
|
+
const host = this.config.customDomain || this.config.host;
|
|
23
|
+
const sshUser = this.getSSHUser();
|
|
24
|
+
if (urlType === 'ssh') {
|
|
25
|
+
return `${sshUser}@${host}:${owner}/${repo}.git`;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
return `https://${host}/${owner}/${repo}.git`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Get SSH user for the platform
|
|
33
|
+
* Override for platforms that use different SSH users
|
|
34
|
+
*/
|
|
35
|
+
getSSHUser() {
|
|
36
|
+
return 'git';
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get full API URL
|
|
40
|
+
*/
|
|
41
|
+
getApiUrl(path) {
|
|
42
|
+
const baseUrl = this.config.apiBaseUrl;
|
|
43
|
+
return `${baseUrl}${path}`;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Create authorization headers
|
|
47
|
+
*/
|
|
48
|
+
getAuthHeaders(token) {
|
|
49
|
+
// Default implementation (Bearer token)
|
|
50
|
+
// Override for platform-specific auth (e.g., GitLab uses 'PRIVATE-TOKEN')
|
|
51
|
+
return {
|
|
52
|
+
'Authorization': `Bearer ${token}`,
|
|
53
|
+
'Accept': 'application/json'
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=git-provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git-provider.js","sourceRoot":"","sources":["../../../../src/core/repo-structure/git-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkMH;;;;GAIG;AACH,MAAM,OAAgB,eAAe;IACnC,YAA4B,MAAsB;QAAtB,WAAM,GAAN,MAAM,CAAgB;IAAG,CAAC;IA2BtD;;OAEG;IACH,YAAY,CAAC,KAAa,EAAE,IAAY,EAAE,OAAgB;QACxD,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QAC1D,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QAElC,IAAI,OAAO,KAAK,KAAK,EAAE,CAAC;YACtB,OAAO,GAAG,OAAO,IAAI,IAAI,IAAI,KAAK,IAAI,IAAI,MAAM,CAAC;QACnD,CAAC;aAAM,CAAC;YACN,OAAO,WAAW,IAAI,IAAI,KAAK,IAAI,IAAI,MAAM,CAAC;QAChD,CAAC;IACH,CAAC;IAED;;;OAGG;IACO,UAAU;QAClB,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;OAEG;IACO,SAAS,CAAC,IAAY;QAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC;QACvC,OAAO,GAAG,OAAO,GAAG,IAAI,EAAE,CAAC;IAC7B,CAAC;IAED;;OAEG;IACO,cAAc,CAAC,KAAa;QACpC,wCAAwC;QACxC,0EAA0E;QAC1E,OAAO;YACL,eAAe,EAAE,UAAU,KAAK,EAAE;YAClC,QAAQ,EAAE,kBAAkB;SAC7B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-validator.d.ts","sourceRoot":"","sources":["../../../../src/core/repo-structure/github-validator.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"github-validator.d.ts","sourceRoot":"","sources":["../../../../src/core/repo-structure/github-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,UAAU,WAAW;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAOD;;;;;;;GAOG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,gBAAgB,CAAC,CAoE3B;AAED;;;;;;GAMG;AACH,wBAAsB,aAAa,CACjC,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,qBAAqB,CAAC,CAiDhC;AAED;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EACvC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,MAAM,GAAE,WAAkC,GACzC,OAAO,CAAC,CAAC,CAAC,CAkBZ;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5D,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,IAAI,CAAC;CACf,CAAC,CAwBD"}
|
|
@@ -9,9 +9,11 @@
|
|
|
9
9
|
* - Owner/organization validation
|
|
10
10
|
* - Retry logic with exponential backoff
|
|
11
11
|
* - Rate limit awareness
|
|
12
|
+
* - Actionable error messages with troubleshooting steps
|
|
12
13
|
*
|
|
13
14
|
* @module github-validator
|
|
14
15
|
*/
|
|
16
|
+
import { getActionableError, formatActionableError } from './git-error-handler.js';
|
|
15
17
|
const DEFAULT_RETRY_CONFIG = {
|
|
16
18
|
maxAttempts: 3,
|
|
17
19
|
baseDelay: 1000 // 1 second
|
|
@@ -49,17 +51,32 @@ export async function validateRepository(owner, repo, token) {
|
|
|
49
51
|
};
|
|
50
52
|
}
|
|
51
53
|
if (response.status === 401 || response.status === 403) {
|
|
52
|
-
// Authentication or permission error
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
:
|
|
56
|
-
|
|
54
|
+
// Authentication or permission error - use actionable error handler
|
|
55
|
+
const apiError = {
|
|
56
|
+
status: response.status,
|
|
57
|
+
message: response.statusText,
|
|
58
|
+
platform: 'github',
|
|
59
|
+
operation: 'validate_repo',
|
|
60
|
+
resourceType: 'repository',
|
|
61
|
+
resourceName: `${owner}/${repo}`
|
|
62
|
+
};
|
|
63
|
+
const actionable = getActionableError(apiError);
|
|
64
|
+
return { exists: false, valid: false, error: formatActionableError(actionable) };
|
|
57
65
|
}
|
|
58
|
-
// Other error
|
|
66
|
+
// Other error - use actionable error handler
|
|
67
|
+
const apiError = {
|
|
68
|
+
status: response.status,
|
|
69
|
+
message: response.statusText,
|
|
70
|
+
platform: 'github',
|
|
71
|
+
operation: 'validate_repo',
|
|
72
|
+
resourceType: 'repository',
|
|
73
|
+
resourceName: `${owner}/${repo}`
|
|
74
|
+
};
|
|
75
|
+
const actionable = getActionableError(apiError);
|
|
59
76
|
return {
|
|
60
77
|
exists: false,
|
|
61
78
|
valid: false,
|
|
62
|
-
error:
|
|
79
|
+
error: formatActionableError(actionable)
|
|
63
80
|
};
|
|
64
81
|
}
|
|
65
82
|
catch (error) {
|
|
@@ -101,8 +118,17 @@ export async function validateOwner(owner, token) {
|
|
|
101
118
|
if (orgResponse.status === 200) {
|
|
102
119
|
return { valid: true, type: 'org' };
|
|
103
120
|
}
|
|
104
|
-
// Not found
|
|
105
|
-
|
|
121
|
+
// Not found - use actionable error handler
|
|
122
|
+
const apiError = {
|
|
123
|
+
status: 404,
|
|
124
|
+
message: 'Not Found',
|
|
125
|
+
platform: 'github',
|
|
126
|
+
operation: 'validate_owner',
|
|
127
|
+
resourceType: 'user',
|
|
128
|
+
resourceName: owner
|
|
129
|
+
};
|
|
130
|
+
const actionable = getActionableError(apiError);
|
|
131
|
+
return { valid: false, error: formatActionableError(actionable) };
|
|
106
132
|
}
|
|
107
133
|
catch (error) {
|
|
108
134
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"github-validator.js","sourceRoot":"","sources":["../../../../src/core/repo-structure/github-validator.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"github-validator.js","sourceRoot":"","sources":["../../../../src/core/repo-structure/github-validator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAoB,MAAM,wBAAwB,CAAC;AA6BrG,MAAM,oBAAoB,GAAgB;IACxC,WAAW,EAAE,CAAC;IACd,SAAS,EAAE,IAAI,CAAC,WAAW;CAC5B,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,KAAa,EACb,IAAY,EACZ,KAAc;IAEd,IAAI,CAAC;QACH,MAAM,OAAO,GAA2B;YACtC,QAAQ,EAAE,gCAAgC;SAC3C,CAAC;QAEF,IAAI,KAAK,EAAE,CAAC;YACV,OAAO,CAAC,eAAe,CAAC,GAAG,SAAS,KAAK,EAAE,CAAC;QAC9C,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,gCAAgC,KAAK,IAAI,IAAI,EAAE,EAAE;YAC5E,OAAO;SACR,CAAC,CAAC;QAEH,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC5B,gDAAgD;YAChD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QACxC,CAAC;QAED,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YAC5B,4BAA4B;YAC5B,MAAM,IAAI,GAAQ,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACxC,OAAO;gBACL,MAAM,EAAE,IAAI;gBACZ,KAAK,EAAE,IAAI;gBACX,GAAG,EAAE,IAAI,CAAC,QAAQ;aACnB,CAAC;QACJ,CAAC;QAED,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;YACvD,oEAAoE;YACpE,MAAM,QA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