@generacy-ai/generacy-plugin-copilot 0.0.0-preview-20260304013206

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 (47) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +140 -0
  3. package/dist/errors.d.ts +70 -0
  4. package/dist/errors.d.ts.map +1 -0
  5. package/dist/errors.js +116 -0
  6. package/dist/errors.js.map +1 -0
  7. package/dist/github/client.d.ts +46 -0
  8. package/dist/github/client.d.ts.map +1 -0
  9. package/dist/github/client.js +165 -0
  10. package/dist/github/client.js.map +1 -0
  11. package/dist/github/types.d.ts +91 -0
  12. package/dist/github/types.d.ts.map +1 -0
  13. package/dist/github/types.js +7 -0
  14. package/dist/github/types.js.map +1 -0
  15. package/dist/index.d.ts +19 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +22 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/plugin/copilot-plugin.d.ts +90 -0
  20. package/dist/plugin/copilot-plugin.d.ts.map +1 -0
  21. package/dist/plugin/copilot-plugin.js +289 -0
  22. package/dist/plugin/copilot-plugin.js.map +1 -0
  23. package/dist/polling/status-poller.d.ts +36 -0
  24. package/dist/polling/status-poller.d.ts.map +1 -0
  25. package/dist/polling/status-poller.js +142 -0
  26. package/dist/polling/status-poller.js.map +1 -0
  27. package/dist/polling/types.d.ts +62 -0
  28. package/dist/polling/types.d.ts.map +1 -0
  29. package/dist/polling/types.js +16 -0
  30. package/dist/polling/types.js.map +1 -0
  31. package/dist/schemas.d.ts +341 -0
  32. package/dist/schemas.d.ts.map +1 -0
  33. package/dist/schemas.js +176 -0
  34. package/dist/schemas.js.map +1 -0
  35. package/dist/types.d.ts +161 -0
  36. package/dist/types.d.ts.map +1 -0
  37. package/dist/types.js +21 -0
  38. package/dist/types.js.map +1 -0
  39. package/dist/workspace/types.d.ts +61 -0
  40. package/dist/workspace/types.d.ts.map +1 -0
  41. package/dist/workspace/types.js +7 -0
  42. package/dist/workspace/types.js.map +1 -0
  43. package/dist/workspace/workspace-manager.d.ts +65 -0
  44. package/dist/workspace/workspace-manager.d.ts.map +1 -0
  45. package/dist/workspace/workspace-manager.js +294 -0
  46. package/dist/workspace/workspace-manager.js.map +1 -0
  47. package/package.json +58 -0
package/LICENSE ADDED
@@ -0,0 +1,191 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to the Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by the Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding any notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2026 The Generacy AI Authors
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,140 @@
1
+ # @generacy-ai/generacy-plugin-copilot
2
+
3
+ GitHub Copilot Workspace agent platform plugin for Generacy.
4
+
5
+ ## Overview
6
+
7
+ This plugin provides tracking and monitoring of GitHub Copilot Workspace sessions. Due to the current lack of a public Copilot Workspace API, this plugin operates in a tracking/monitoring mode, inferring workspace status from GitHub Issues and Pull Requests.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pnpm add @generacy-ai/generacy-plugin-copilot
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```typescript
18
+ import { CopilotPlugin } from '@generacy-ai/generacy-plugin-copilot';
19
+
20
+ // Initialize the plugin
21
+ const copilot = new CopilotPlugin({
22
+ githubToken: process.env.GITHUB_TOKEN!,
23
+ polling: {
24
+ initialIntervalMs: 5000,
25
+ maxIntervalMs: 60000,
26
+ backoffMultiplier: 1.5,
27
+ },
28
+ });
29
+
30
+ // Create a workspace to track an issue
31
+ const workspace = await copilot.createWorkspace({
32
+ issueUrl: 'https://github.com/owner/repo/issues/123',
33
+ options: {
34
+ autoMerge: false,
35
+ reviewRequired: true,
36
+ },
37
+ });
38
+
39
+ console.log(`Tracking workspace: ${workspace.id}`);
40
+
41
+ // Poll for status updates
42
+ const status = await copilot.pollWorkspaceStatus(workspace.id);
43
+ console.log(`Current status: ${status}`);
44
+
45
+ // Or stream status changes
46
+ for await (const event of copilot.streamStatus(workspace.id)) {
47
+ console.log(`Status changed: ${event.previousStatus} -> ${event.status}`);
48
+
49
+ if (event.details?.pullRequestUrl) {
50
+ console.log(`PR created: ${event.details.pullRequestUrl}`);
51
+ }
52
+ }
53
+
54
+ // Get file changes when workspace reaches review_ready or merged status
55
+ if (status === 'review_ready' || status === 'merged') {
56
+ const changes = await copilot.getChanges(workspace.id);
57
+ for (const change of changes) {
58
+ console.log(`${change.type}: ${change.path} (+${change.additions}/-${change.deletions})`);
59
+ }
60
+
61
+ const pr = await copilot.getPullRequest(workspace.id);
62
+ if (pr) {
63
+ console.log(`PR #${pr.number}: ${pr.title}`);
64
+ }
65
+ }
66
+
67
+ // Cleanup when done
68
+ await copilot.dispose();
69
+ ```
70
+
71
+ ## API
72
+
73
+ ### CopilotPlugin
74
+
75
+ The main plugin class.
76
+
77
+ #### Constructor Options
78
+
79
+ ```typescript
80
+ interface CopilotPluginOptions {
81
+ // Required: GitHub personal access token or GitHub App token
82
+ githubToken: string;
83
+
84
+ // Optional: GitHub API base URL (for GitHub Enterprise)
85
+ apiBaseUrl?: string;
86
+
87
+ // Optional: Pino logger instance
88
+ logger?: Logger;
89
+
90
+ // Optional: Polling configuration
91
+ polling?: {
92
+ initialIntervalMs?: number; // Default: 5000
93
+ maxIntervalMs?: number; // Default: 60000
94
+ backoffMultiplier?: number; // Default: 1.5
95
+ maxRetries?: number; // Default: 100
96
+ timeoutMs?: number; // Default: 3600000 (1 hour)
97
+ };
98
+
99
+ // Optional: Default workspace options
100
+ workspaceDefaults?: {
101
+ autoMerge?: boolean;
102
+ reviewRequired?: boolean;
103
+ timeoutMs?: number;
104
+ prLabels?: string[];
105
+ };
106
+ }
107
+ ```
108
+
109
+ #### Methods
110
+
111
+ - `createWorkspace(params)` - Create a workspace for tracking
112
+ - `getWorkspace(workspaceId)` - Get workspace by ID
113
+ - `pollWorkspaceStatus(workspaceId)` - Poll current status
114
+ - `getChanges(workspaceId)` - Get file changes (review_ready/merged only)
115
+ - `getPullRequest(workspaceId)` - Get associated PR
116
+ - `streamStatus(workspaceId)` - Async generator for status events
117
+ - `dispose()` - Cleanup resources
118
+
119
+ ### WorkspaceStatus
120
+
121
+ ```typescript
122
+ type WorkspaceStatus =
123
+ | 'pending' // Tracking initiated, awaiting manual workspace trigger
124
+ | 'planning' // Copilot is analyzing the issue
125
+ | 'implementing' // Copilot is generating code
126
+ | 'review_ready' // PR created, ready for review
127
+ | 'merged' // PR has been merged
128
+ | 'failed' // Workspace failed or was cancelled
129
+ | 'not_available'; // Copilot API not available
130
+ ```
131
+
132
+ ## Limitations
133
+
134
+ - **No Direct API**: This plugin infers status from GitHub API since Copilot Workspace has no public API
135
+ - **Manual Trigger**: Users must manually trigger Copilot Workspace; this plugin tracks progress afterward
136
+ - **GitHub Only**: Works with GitHub.com and GitHub Enterprise
137
+
138
+ ## License
139
+
140
+ MIT
@@ -0,0 +1,70 @@
1
+ /**
2
+ * @generacy-ai/generacy-plugin-copilot
3
+ *
4
+ * Custom error classes for the Copilot plugin.
5
+ */
6
+ import type { ErrorCode, WorkspaceStatus } from './types.js';
7
+ /**
8
+ * Base error class for all plugin errors.
9
+ */
10
+ export declare class PluginError extends Error {
11
+ readonly code: ErrorCode;
12
+ readonly isTransient: boolean;
13
+ readonly context?: Record<string, unknown>;
14
+ constructor(message: string, code: ErrorCode, isTransient: boolean, context?: Record<string, unknown>);
15
+ toPluginErrorData(): {
16
+ code: ErrorCode;
17
+ isTransient: boolean;
18
+ message: string;
19
+ context: Record<string, unknown> | undefined;
20
+ };
21
+ }
22
+ /**
23
+ * Error thrown when a workspace is not found.
24
+ */
25
+ export declare class WorkspaceNotFoundError extends PluginError {
26
+ readonly workspaceId: string;
27
+ constructor(workspaceId: string);
28
+ }
29
+ /**
30
+ * Error thrown when an operation is attempted on a workspace in an invalid state.
31
+ */
32
+ export declare class WorkspaceInvalidStateError extends PluginError {
33
+ readonly workspaceId: string;
34
+ readonly currentState: WorkspaceStatus;
35
+ readonly expectedStates: WorkspaceStatus[];
36
+ constructor(workspaceId: string, currentState: WorkspaceStatus, expectedStates: WorkspaceStatus[], operation: string);
37
+ }
38
+ /**
39
+ * Error thrown when a GitHub API call fails.
40
+ */
41
+ export declare class GitHubAPIError extends PluginError {
42
+ readonly statusCode?: number;
43
+ readonly endpoint?: string;
44
+ constructor(message: string, statusCode?: number, endpoint?: string);
45
+ }
46
+ /**
47
+ * Error thrown when polling times out.
48
+ */
49
+ export declare class PollingTimeoutError extends PluginError {
50
+ readonly workspaceId: string;
51
+ readonly timeoutMs: number;
52
+ readonly pollCount: number;
53
+ constructor(workspaceId: string, timeoutMs: number, pollCount: number);
54
+ }
55
+ /**
56
+ * Error thrown when a feature is not implemented.
57
+ */
58
+ export declare class NotImplementedError extends PluginError {
59
+ readonly feature: string;
60
+ constructor(feature: string);
61
+ }
62
+ /**
63
+ * Check if an error is a plugin error.
64
+ */
65
+ export declare function isPluginError(error: unknown): error is PluginError;
66
+ /**
67
+ * Wrap any error as a PluginError.
68
+ */
69
+ export declare function wrapError(error: unknown): PluginError;
70
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7D;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAGzC,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,SAAS,EACf,WAAW,EAAE,OAAO,EACpB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAWnC,iBAAiB;;;;;;CAQlB;AAED;;GAEG;AACH,qBAAa,sBAAuB,SAAQ,WAAW;IACrD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;gBAEjB,WAAW,EAAE,MAAM;CAUhC;AAED;;GAEG;AACH,qBAAa,0BAA2B,SAAQ,WAAW;IACzD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,EAAE,eAAe,CAAC;IACvC,QAAQ,CAAC,cAAc,EAAE,eAAe,EAAE,CAAC;gBAGzC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,eAAe,EAC7B,cAAc,EAAE,eAAe,EAAE,EACjC,SAAS,EAAE,MAAM;CAapB;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,WAAW;IAC7C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;gBAEf,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM;CAWpE;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;IAClD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAEf,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAYtE;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,WAAW;IAClD,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;gBAEb,OAAO,EAAE,MAAM;CAU5B;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,WAAW,CAElE;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,CASrD"}
package/dist/errors.js ADDED
@@ -0,0 +1,116 @@
1
+ /**
2
+ * @generacy-ai/generacy-plugin-copilot
3
+ *
4
+ * Custom error classes for the Copilot plugin.
5
+ */
6
+ /**
7
+ * Base error class for all plugin errors.
8
+ */
9
+ export class PluginError extends Error {
10
+ code;
11
+ isTransient;
12
+ context;
13
+ constructor(message, code, isTransient, context) {
14
+ super(message);
15
+ this.name = 'PluginError';
16
+ this.code = code;
17
+ this.isTransient = isTransient;
18
+ this.context = context;
19
+ Error.captureStackTrace?.(this, this.constructor);
20
+ }
21
+ toPluginErrorData() {
22
+ return {
23
+ code: this.code,
24
+ isTransient: this.isTransient,
25
+ message: this.message,
26
+ context: this.context,
27
+ };
28
+ }
29
+ }
30
+ /**
31
+ * Error thrown when a workspace is not found.
32
+ */
33
+ export class WorkspaceNotFoundError extends PluginError {
34
+ workspaceId;
35
+ constructor(workspaceId) {
36
+ super(`Workspace not found: ${workspaceId}`, 'WORKSPACE_NOT_FOUND', false, { workspaceId });
37
+ this.name = 'WorkspaceNotFoundError';
38
+ this.workspaceId = workspaceId;
39
+ }
40
+ }
41
+ /**
42
+ * Error thrown when an operation is attempted on a workspace in an invalid state.
43
+ */
44
+ export class WorkspaceInvalidStateError extends PluginError {
45
+ workspaceId;
46
+ currentState;
47
+ expectedStates;
48
+ constructor(workspaceId, currentState, expectedStates, operation) {
49
+ super(`Cannot ${operation} workspace ${workspaceId}: expected state ${expectedStates.join(' or ')}, but was ${currentState}`, 'WORKSPACE_INVALID_STATE', false, { workspaceId, currentState, expectedStates, operation });
50
+ this.name = 'WorkspaceInvalidStateError';
51
+ this.workspaceId = workspaceId;
52
+ this.currentState = currentState;
53
+ this.expectedStates = expectedStates;
54
+ }
55
+ }
56
+ /**
57
+ * Error thrown when a GitHub API call fails.
58
+ */
59
+ export class GitHubAPIError extends PluginError {
60
+ statusCode;
61
+ endpoint;
62
+ constructor(message, statusCode, endpoint) {
63
+ const isTransient = statusCode === 429 || (statusCode !== undefined && statusCode >= 500);
64
+ const code = statusCode === 429 ? 'RATE_LIMITED' :
65
+ statusCode === 401 || statusCode === 403 ? 'AUTH_FAILED' :
66
+ 'GITHUB_API_ERROR';
67
+ super(message, code, isTransient, { statusCode, endpoint });
68
+ this.name = 'GitHubAPIError';
69
+ this.statusCode = statusCode;
70
+ this.endpoint = endpoint;
71
+ }
72
+ }
73
+ /**
74
+ * Error thrown when polling times out.
75
+ */
76
+ export class PollingTimeoutError extends PluginError {
77
+ workspaceId;
78
+ timeoutMs;
79
+ pollCount;
80
+ constructor(workspaceId, timeoutMs, pollCount) {
81
+ super(`Polling timed out for workspace ${workspaceId} after ${timeoutMs}ms (${pollCount} attempts)`, 'POLLING_TIMEOUT', false, { workspaceId, timeoutMs, pollCount });
82
+ this.name = 'PollingTimeoutError';
83
+ this.workspaceId = workspaceId;
84
+ this.timeoutMs = timeoutMs;
85
+ this.pollCount = pollCount;
86
+ }
87
+ }
88
+ /**
89
+ * Error thrown when a feature is not implemented.
90
+ */
91
+ export class NotImplementedError extends PluginError {
92
+ feature;
93
+ constructor(feature) {
94
+ super(`Feature not implemented: ${feature}. Copilot Workspace API is not publicly available.`, 'NOT_IMPLEMENTED', false, { feature });
95
+ this.name = 'NotImplementedError';
96
+ this.feature = feature;
97
+ }
98
+ }
99
+ /**
100
+ * Check if an error is a plugin error.
101
+ */
102
+ export function isPluginError(error) {
103
+ return error instanceof PluginError;
104
+ }
105
+ /**
106
+ * Wrap any error as a PluginError.
107
+ */
108
+ export function wrapError(error) {
109
+ if (error instanceof PluginError) {
110
+ return error;
111
+ }
112
+ const message = error instanceof Error ? error.message : String(error);
113
+ const context = error instanceof Error ? { originalError: error.name, stack: error.stack } : undefined;
114
+ return new PluginError(message, 'UNKNOWN', false, context);
115
+ }
116
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC3B,IAAI,CAAY;IAChB,WAAW,CAAU;IACrB,OAAO,CAA2B;IAE3C,YACE,OAAe,EACf,IAAe,EACf,WAAoB,EACpB,OAAiC;QAEjC,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,KAAK,CAAC,iBAAiB,E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AC;QACF,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,OAAO,KAAK,YAAY,WAAW,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,IAAI,KAAK,YAAY,WAAW,EAAE,CAAC;QACjC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IAEvG,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAC7D,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @generacy-ai/generacy-plugin-copilot
3
+ *
4
+ * GitHub API client wrapper using Octokit.
5
+ */
6
+ import type { GitHubClientConfig, GitHubIssue, GitHubPullRequest, GitHubPRFile, GitHubReview, ParsedIssueUrl } from './types.js';
7
+ /**
8
+ * Parse a GitHub issue URL into its components.
9
+ */
10
+ export declare function parseIssueUrl(url: string): ParsedIssueUrl;
11
+ /**
12
+ * GitHub API client for issue and PR operations.
13
+ */
14
+ export declare class GitHubClient {
15
+ private readonly octokit;
16
+ constructor(config: GitHubClientConfig);
17
+ /**
18
+ * Get an issue by owner/repo/number.
19
+ */
20
+ getIssue(owner: string, repo: string, issueNumber: number): Promise<GitHubIssue>;
21
+ /**
22
+ * List pull requests linked to an issue.
23
+ */
24
+ listLinkedPullRequests(owner: string, repo: string, issueNumber: number): Promise<GitHubPullRequest[]>;
25
+ /**
26
+ * Get a pull request by owner/repo/number.
27
+ */
28
+ getPullRequest(owner: string, repo: string, prNumber: number): Promise<GitHubPullRequest>;
29
+ /**
30
+ * Get files changed in a pull request.
31
+ */
32
+ getPullRequestFiles(owner: string, repo: string, prNumber: number): Promise<GitHubPRFile[]>;
33
+ /**
34
+ * Get reviews for a pull request.
35
+ */
36
+ getPullRequestReviews(owner: string, repo: string, prNumber: number): Promise<GitHubReview[]>;
37
+ /**
38
+ * Get file content from a repository.
39
+ */
40
+ getFileContent(owner: string, repo: string, path: string, ref?: string): Promise<string>;
41
+ /**
42
+ * Convert Octokit errors to GitHubAPIError.
43
+ */
44
+ private wrapOctokitError;
45
+ }
46
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/github/client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,OAAO,KAAK,EACV,kBAAkB,EAClB,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,cAAc,EACf,MAAM,YAAY,CAAC;AAIpB;;GAEG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAUzD;AAED;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAU;gBAEtB,MAAM,EAAE,kBAAkB;IAOtC;;OAEG;IACG,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAatF;;OAEG;IACG,sBAAsB,CAC1B,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,iBAAiB,EAAE,CAAC;IA8B/B;;OAEG;IACG,cAAc,CAClB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAA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