@zibby/skills 0.1.38 → 0.1.39
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/dist/github.d.ts +171 -57
- package/dist/github.js +7 -4
- package/dist/gitlab.d.ts +137 -3
- package/dist/gitlab.js +7 -2
- package/dist/index.js +110 -101
- package/dist/package.json +3 -3
- package/dist/reviewMemory.js +3 -2
- package/dist/trackers/github-adapter.js +7 -4
- package/dist/trackers/index.js +29 -26
- package/package.json +3 -3
package/dist/github.d.ts
CHANGED
|
@@ -29,15 +29,16 @@ export namespace githubSkill {
|
|
|
29
29
|
type: string;
|
|
30
30
|
properties: {
|
|
31
31
|
owner?: undefined;
|
|
32
|
+
query?: undefined;
|
|
32
33
|
type?: undefined;
|
|
33
34
|
sort?: undefined;
|
|
34
35
|
direction?: undefined;
|
|
35
36
|
limit?: undefined;
|
|
36
37
|
repo?: undefined;
|
|
37
38
|
destination?: undefined;
|
|
38
|
-
query?: undefined;
|
|
39
39
|
language?: undefined;
|
|
40
40
|
number?: undefined;
|
|
41
|
+
commentId?: undefined;
|
|
41
42
|
body?: undefined;
|
|
42
43
|
event?: undefined;
|
|
43
44
|
comments?: undefined;
|
|
@@ -65,6 +66,10 @@ export namespace githubSkill {
|
|
|
65
66
|
type: string;
|
|
66
67
|
description: string;
|
|
67
68
|
};
|
|
69
|
+
query: {
|
|
70
|
+
type: string;
|
|
71
|
+
description: string;
|
|
72
|
+
};
|
|
68
73
|
type: {
|
|
69
74
|
type: string;
|
|
70
75
|
enum: string[];
|
|
@@ -86,9 +91,9 @@ export namespace githubSkill {
|
|
|
86
91
|
};
|
|
87
92
|
repo?: undefined;
|
|
88
93
|
destination?: undefined;
|
|
89
|
-
query?: undefined;
|
|
90
94
|
language?: undefined;
|
|
91
95
|
number?: undefined;
|
|
96
|
+
commentId?: undefined;
|
|
92
97
|
body?: undefined;
|
|
93
98
|
event?: undefined;
|
|
94
99
|
comments?: undefined;
|
|
@@ -124,13 +129,14 @@ export namespace githubSkill {
|
|
|
124
129
|
type: string;
|
|
125
130
|
description: string;
|
|
126
131
|
};
|
|
132
|
+
query?: undefined;
|
|
127
133
|
type?: undefined;
|
|
128
134
|
sort?: undefined;
|
|
129
135
|
direction?: undefined;
|
|
130
136
|
limit?: undefined;
|
|
131
|
-
query?: undefined;
|
|
132
137
|
language?: undefined;
|
|
133
138
|
number?: undefined;
|
|
139
|
+
commentId?: undefined;
|
|
134
140
|
body?: undefined;
|
|
135
141
|
event?: undefined;
|
|
136
142
|
comments?: undefined;
|
|
@@ -170,6 +176,7 @@ export namespace githubSkill {
|
|
|
170
176
|
destination?: undefined;
|
|
171
177
|
language?: undefined;
|
|
172
178
|
number?: undefined;
|
|
179
|
+
commentId?: undefined;
|
|
173
180
|
body?: undefined;
|
|
174
181
|
event?: undefined;
|
|
175
182
|
comments?: undefined;
|
|
@@ -215,6 +222,7 @@ export namespace githubSkill {
|
|
|
215
222
|
direction?: undefined;
|
|
216
223
|
destination?: undefined;
|
|
217
224
|
number?: undefined;
|
|
225
|
+
commentId?: undefined;
|
|
218
226
|
body?: undefined;
|
|
219
227
|
event?: undefined;
|
|
220
228
|
comments?: undefined;
|
|
@@ -250,12 +258,59 @@ export namespace githubSkill {
|
|
|
250
258
|
type: string;
|
|
251
259
|
description: string;
|
|
252
260
|
};
|
|
261
|
+
query?: undefined;
|
|
253
262
|
type?: undefined;
|
|
254
263
|
sort?: undefined;
|
|
255
264
|
direction?: undefined;
|
|
256
265
|
limit?: undefined;
|
|
257
266
|
destination?: undefined;
|
|
267
|
+
language?: undefined;
|
|
268
|
+
commentId?: undefined;
|
|
269
|
+
body?: undefined;
|
|
270
|
+
event?: undefined;
|
|
271
|
+
comments?: undefined;
|
|
272
|
+
branch?: undefined;
|
|
273
|
+
path?: undefined;
|
|
274
|
+
sha?: undefined;
|
|
275
|
+
ref?: undefined;
|
|
276
|
+
title?: undefined;
|
|
277
|
+
state?: undefined;
|
|
278
|
+
labels?: undefined;
|
|
279
|
+
since?: undefined;
|
|
280
|
+
assignee?: undefined;
|
|
281
|
+
stateReason?: undefined;
|
|
282
|
+
mode?: undefined;
|
|
283
|
+
};
|
|
284
|
+
required: string[];
|
|
285
|
+
};
|
|
286
|
+
} | {
|
|
287
|
+
name: string;
|
|
288
|
+
description: string;
|
|
289
|
+
input_schema: {
|
|
290
|
+
type: string;
|
|
291
|
+
properties: {
|
|
292
|
+
owner: {
|
|
293
|
+
type: string;
|
|
294
|
+
description: string;
|
|
295
|
+
};
|
|
296
|
+
repo: {
|
|
297
|
+
type: string;
|
|
298
|
+
description: string;
|
|
299
|
+
};
|
|
300
|
+
number: {
|
|
301
|
+
type: string;
|
|
302
|
+
description: string;
|
|
303
|
+
};
|
|
304
|
+
commentId: {
|
|
305
|
+
type: string;
|
|
306
|
+
description: string;
|
|
307
|
+
};
|
|
258
308
|
query?: undefined;
|
|
309
|
+
type?: undefined;
|
|
310
|
+
sort?: undefined;
|
|
311
|
+
direction?: undefined;
|
|
312
|
+
limit?: undefined;
|
|
313
|
+
destination?: undefined;
|
|
259
314
|
language?: undefined;
|
|
260
315
|
body?: undefined;
|
|
261
316
|
event?: undefined;
|
|
@@ -274,6 +329,101 @@ export namespace githubSkill {
|
|
|
274
329
|
};
|
|
275
330
|
required: string[];
|
|
276
331
|
};
|
|
332
|
+
} | {
|
|
333
|
+
name: string;
|
|
334
|
+
description: string;
|
|
335
|
+
input_schema: {
|
|
336
|
+
type: string;
|
|
337
|
+
properties: {
|
|
338
|
+
owner: {
|
|
339
|
+
type: string;
|
|
340
|
+
description: string;
|
|
341
|
+
};
|
|
342
|
+
repo: {
|
|
343
|
+
type: string;
|
|
344
|
+
description: string;
|
|
345
|
+
};
|
|
346
|
+
number: {
|
|
347
|
+
type: string;
|
|
348
|
+
description: string;
|
|
349
|
+
};
|
|
350
|
+
commentId: {
|
|
351
|
+
type: string;
|
|
352
|
+
description: string;
|
|
353
|
+
};
|
|
354
|
+
body: {
|
|
355
|
+
type: string;
|
|
356
|
+
description: string;
|
|
357
|
+
};
|
|
358
|
+
query?: undefined;
|
|
359
|
+
type?: undefined;
|
|
360
|
+
sort?: undefined;
|
|
361
|
+
direction?: undefined;
|
|
362
|
+
limit?: undefined;
|
|
363
|
+
destination?: undefined;
|
|
364
|
+
language?: undefined;
|
|
365
|
+
event?: undefined;
|
|
366
|
+
comments?: undefined;
|
|
367
|
+
branch?: undefined;
|
|
368
|
+
path?: undefined;
|
|
369
|
+
sha?: undefined;
|
|
370
|
+
ref?: undefined;
|
|
371
|
+
title?: undefined;
|
|
372
|
+
state?: undefined;
|
|
373
|
+
labels?: undefined;
|
|
374
|
+
since?: undefined;
|
|
375
|
+
assignee?: undefined;
|
|
376
|
+
stateReason?: undefined;
|
|
377
|
+
mode?: undefined;
|
|
378
|
+
};
|
|
379
|
+
required: string[];
|
|
380
|
+
};
|
|
381
|
+
} | {
|
|
382
|
+
name: string;
|
|
383
|
+
description: string;
|
|
384
|
+
input_schema: {
|
|
385
|
+
type: string;
|
|
386
|
+
properties: {
|
|
387
|
+
owner: {
|
|
388
|
+
type: string;
|
|
389
|
+
description: string;
|
|
390
|
+
};
|
|
391
|
+
repo: {
|
|
392
|
+
type: string;
|
|
393
|
+
description: string;
|
|
394
|
+
};
|
|
395
|
+
number: {
|
|
396
|
+
type: string;
|
|
397
|
+
description: string;
|
|
398
|
+
};
|
|
399
|
+
body: {
|
|
400
|
+
type: string;
|
|
401
|
+
description: string;
|
|
402
|
+
};
|
|
403
|
+
query?: undefined;
|
|
404
|
+
type?: undefined;
|
|
405
|
+
sort?: undefined;
|
|
406
|
+
direction?: undefined;
|
|
407
|
+
limit?: undefined;
|
|
408
|
+
destination?: undefined;
|
|
409
|
+
language?: undefined;
|
|
410
|
+
commentId?: undefined;
|
|
411
|
+
event?: undefined;
|
|
412
|
+
comments?: undefined;
|
|
413
|
+
branch?: undefined;
|
|
414
|
+
path?: undefined;
|
|
415
|
+
sha?: undefined;
|
|
416
|
+
ref?: undefined;
|
|
417
|
+
title?: undefined;
|
|
418
|
+
state?: undefined;
|
|
419
|
+
labels?: undefined;
|
|
420
|
+
since?: undefined;
|
|
421
|
+
assignee?: undefined;
|
|
422
|
+
stateReason?: undefined;
|
|
423
|
+
mode?: undefined;
|
|
424
|
+
};
|
|
425
|
+
required: string[];
|
|
426
|
+
};
|
|
277
427
|
} | {
|
|
278
428
|
name: string;
|
|
279
429
|
description: string;
|
|
@@ -328,13 +478,14 @@ export namespace githubSkill {
|
|
|
328
478
|
required: string[];
|
|
329
479
|
};
|
|
330
480
|
};
|
|
481
|
+
query?: undefined;
|
|
331
482
|
type?: undefined;
|
|
332
483
|
sort?: undefined;
|
|
333
484
|
direction?: undefined;
|
|
334
485
|
limit?: undefined;
|
|
335
486
|
destination?: undefined;
|
|
336
|
-
query?: undefined;
|
|
337
487
|
language?: undefined;
|
|
488
|
+
commentId?: undefined;
|
|
338
489
|
branch?: undefined;
|
|
339
490
|
path?: undefined;
|
|
340
491
|
sha?: undefined;
|
|
@@ -375,13 +526,14 @@ export namespace githubSkill {
|
|
|
375
526
|
type: string;
|
|
376
527
|
description: string;
|
|
377
528
|
};
|
|
529
|
+
query?: undefined;
|
|
378
530
|
type?: undefined;
|
|
379
531
|
sort?: undefined;
|
|
380
532
|
direction?: undefined;
|
|
381
533
|
destination?: undefined;
|
|
382
|
-
query?: undefined;
|
|
383
534
|
language?: undefined;
|
|
384
535
|
number?: undefined;
|
|
536
|
+
commentId?: undefined;
|
|
385
537
|
body?: undefined;
|
|
386
538
|
event?: undefined;
|
|
387
539
|
comments?: undefined;
|
|
@@ -415,14 +567,15 @@ export namespace githubSkill {
|
|
|
415
567
|
type: string;
|
|
416
568
|
description: string;
|
|
417
569
|
};
|
|
570
|
+
query?: undefined;
|
|
418
571
|
type?: undefined;
|
|
419
572
|
sort?: undefined;
|
|
420
573
|
direction?: undefined;
|
|
421
574
|
limit?: undefined;
|
|
422
575
|
destination?: undefined;
|
|
423
|
-
query?: undefined;
|
|
424
576
|
language?: undefined;
|
|
425
577
|
number?: undefined;
|
|
578
|
+
commentId?: undefined;
|
|
426
579
|
body?: undefined;
|
|
427
580
|
event?: undefined;
|
|
428
581
|
comments?: undefined;
|
|
@@ -461,14 +614,15 @@ export namespace githubSkill {
|
|
|
461
614
|
type: string;
|
|
462
615
|
description: string;
|
|
463
616
|
};
|
|
617
|
+
query?: undefined;
|
|
464
618
|
type?: undefined;
|
|
465
619
|
sort?: undefined;
|
|
466
620
|
direction?: undefined;
|
|
467
621
|
limit?: undefined;
|
|
468
622
|
destination?: undefined;
|
|
469
|
-
query?: undefined;
|
|
470
623
|
language?: undefined;
|
|
471
624
|
number?: undefined;
|
|
625
|
+
commentId?: undefined;
|
|
472
626
|
body?: undefined;
|
|
473
627
|
event?: undefined;
|
|
474
628
|
comments?: undefined;
|
|
@@ -506,14 +660,15 @@ export namespace githubSkill {
|
|
|
506
660
|
type: string;
|
|
507
661
|
description: string;
|
|
508
662
|
};
|
|
663
|
+
query?: undefined;
|
|
509
664
|
type?: undefined;
|
|
510
665
|
sort?: undefined;
|
|
511
666
|
direction?: undefined;
|
|
512
667
|
limit?: undefined;
|
|
513
668
|
destination?: undefined;
|
|
514
|
-
query?: undefined;
|
|
515
669
|
language?: undefined;
|
|
516
670
|
number?: undefined;
|
|
671
|
+
commentId?: undefined;
|
|
517
672
|
event?: undefined;
|
|
518
673
|
comments?: undefined;
|
|
519
674
|
branch?: undefined;
|
|
@@ -577,11 +732,12 @@ export namespace githubSkill {
|
|
|
577
732
|
type: string;
|
|
578
733
|
description: string;
|
|
579
734
|
};
|
|
735
|
+
query?: undefined;
|
|
580
736
|
type?: undefined;
|
|
581
737
|
destination?: undefined;
|
|
582
|
-
query?: undefined;
|
|
583
738
|
language?: undefined;
|
|
584
739
|
number?: undefined;
|
|
740
|
+
commentId?: undefined;
|
|
585
741
|
body?: undefined;
|
|
586
742
|
event?: undefined;
|
|
587
743
|
comments?: undefined;
|
|
@@ -617,58 +773,14 @@ export namespace githubSkill {
|
|
|
617
773
|
type: string;
|
|
618
774
|
description: string;
|
|
619
775
|
};
|
|
620
|
-
type?: undefined;
|
|
621
|
-
sort?: undefined;
|
|
622
|
-
direction?: undefined;
|
|
623
|
-
destination?: undefined;
|
|
624
776
|
query?: undefined;
|
|
625
|
-
language?: undefined;
|
|
626
|
-
body?: undefined;
|
|
627
|
-
event?: undefined;
|
|
628
|
-
comments?: undefined;
|
|
629
|
-
branch?: undefined;
|
|
630
|
-
path?: undefined;
|
|
631
|
-
sha?: undefined;
|
|
632
|
-
ref?: undefined;
|
|
633
|
-
title?: undefined;
|
|
634
|
-
state?: undefined;
|
|
635
|
-
labels?: undefined;
|
|
636
|
-
since?: undefined;
|
|
637
|
-
assignee?: undefined;
|
|
638
|
-
stateReason?: undefined;
|
|
639
|
-
mode?: undefined;
|
|
640
|
-
};
|
|
641
|
-
required: string[];
|
|
642
|
-
};
|
|
643
|
-
} | {
|
|
644
|
-
name: string;
|
|
645
|
-
description: string;
|
|
646
|
-
input_schema: {
|
|
647
|
-
type: string;
|
|
648
|
-
properties: {
|
|
649
|
-
owner: {
|
|
650
|
-
type: string;
|
|
651
|
-
description: string;
|
|
652
|
-
};
|
|
653
|
-
repo: {
|
|
654
|
-
type: string;
|
|
655
|
-
description: string;
|
|
656
|
-
};
|
|
657
|
-
number: {
|
|
658
|
-
type: string;
|
|
659
|
-
description: string;
|
|
660
|
-
};
|
|
661
|
-
body: {
|
|
662
|
-
type: string;
|
|
663
|
-
description: string;
|
|
664
|
-
};
|
|
665
777
|
type?: undefined;
|
|
666
778
|
sort?: undefined;
|
|
667
779
|
direction?: undefined;
|
|
668
|
-
limit?: undefined;
|
|
669
780
|
destination?: undefined;
|
|
670
|
-
query?: undefined;
|
|
671
781
|
language?: undefined;
|
|
782
|
+
commentId?: undefined;
|
|
783
|
+
body?: undefined;
|
|
672
784
|
event?: undefined;
|
|
673
785
|
comments?: undefined;
|
|
674
786
|
branch?: undefined;
|
|
@@ -708,13 +820,14 @@ export namespace githubSkill {
|
|
|
708
820
|
enum: string[];
|
|
709
821
|
description: string;
|
|
710
822
|
};
|
|
823
|
+
query?: undefined;
|
|
711
824
|
type?: undefined;
|
|
712
825
|
sort?: undefined;
|
|
713
826
|
direction?: undefined;
|
|
714
827
|
limit?: undefined;
|
|
715
828
|
destination?: undefined;
|
|
716
|
-
query?: undefined;
|
|
717
829
|
language?: undefined;
|
|
830
|
+
commentId?: undefined;
|
|
718
831
|
body?: undefined;
|
|
719
832
|
event?: undefined;
|
|
720
833
|
comments?: undefined;
|
|
@@ -761,13 +874,14 @@ export namespace githubSkill {
|
|
|
761
874
|
enum: string[];
|
|
762
875
|
description: string;
|
|
763
876
|
};
|
|
877
|
+
query?: undefined;
|
|
764
878
|
type?: undefined;
|
|
765
879
|
sort?: undefined;
|
|
766
880
|
direction?: undefined;
|
|
767
881
|
limit?: undefined;
|
|
768
882
|
destination?: undefined;
|
|
769
|
-
query?: undefined;
|
|
770
883
|
language?: undefined;
|
|
884
|
+
commentId?: undefined;
|
|
771
885
|
body?: undefined;
|
|
772
886
|
event?: undefined;
|
|
773
887
|
comments?: undefined;
|
package/dist/github.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{existsSync as
|
|
1
|
+
import{existsSync as J}from"fs";import{fileURLToPath as I}from"url";import{dirname as E,resolve as k}from"path";import{resolveIntegrationToken as q}from"@zibby/core/backend-client.js";var P=Object.freeze({SENTRY:"sentry",JIRA:"jira",GITHUB:"github",GITLAB:"gitlab",SLACK:"slack",LARK:"lark",OPENAI_BILLING:"openai_billing",ANTHROPIC_BILLING:"anthropic_billing",CURSOR_ADMIN:"cursor_admin",NOTION:"notion",PLANE:"plane",LINEAR:"linear"}),L=Object.freeze({sentry:{id:"sentry",name:"Sentry",connectPath:"/integrations?provider=sentry"},jira:{id:"jira",name:"Jira",connectPath:"/integrations?provider=jira"},github:{id:"github",name:"GitHub",connectPath:"/integrations?provider=github"},gitlab:{id:"gitlab",name:"GitLab",connectPath:"/integrations?provider=gitlab"},slack:{id:"slack",name:"Slack",connectPath:"/integrations?provider=slack"},lark:{id:"lark",name:"Lark",connectPath:"/integrations?provider=lark"},openai_billing:{id:"openai_billing",name:"OpenAI Admin",connectPath:"/integrations?provider=openai_billing"},anthropic_billing:{id:"anthropic_billing",name:"Anthropic Admin",connectPath:"/integrations?provider=anthropic_billing"},cursor_admin:{id:"cursor_admin",name:"Cursor Admin",connectPath:"/integrations?provider=cursor_admin"},notion:{id:"notion",name:"Notion",connectPath:"/integrations?provider=notion"},plane:{id:"plane",name:"Plane",connectPath:"/integrations?provider=plane"},linear:{id:"linear",name:"Linear",connectPath:"/integrations?provider=linear"}});function C(){if(process.env.MCP_SKILL_PATH)return process.env.MCP_SKILL_PATH;let y=E(I(import.meta.url)),a=k(y,"..","bin","mcp-skill.mjs");return J(a)?a:null}async function l(y,a={}){let{token:t}=await q("github"),n=y.startsWith("https://")?y:`https://api.github.com${y}`,i={Authorization:`Bearer ${t}`,Accept:a.accept||"application/vnd.github.v3+json","User-Agent":"Zibby-App",...a.body?{"Content-Type":"application/json"}:{}},e=await fetch(n,{method:a.method||"GET",headers:i,body:a.body?JSON.stringify(a.body):void 0});if(!e.ok){let r=await e.text().catch(()=>"");throw new Error(`GitHub API ${e.status}: ${r.slice(0,300)}`)}return a.raw?e.text():e.json()}var z={id:"github",serverName:"github",allowedTools:["mcp__github__*"],requiresIntegration:P.GITHUB,envKeys:["GITHUB_TOKEN"],description:"GitHub \u2014 issues, PRs, commits, code search, file reading",promptFragment:`## GitHub (connected)
|
|
2
2
|
You have access to the user's GitHub repositories. Available tools:
|
|
3
3
|
|
|
4
4
|
### Discovery
|
|
5
|
-
- github_list_repos: Lists ALL accessible repos (personal + orgs, private + public, up to 200 repos)
|
|
5
|
+
- github_list_repos: Lists ALL accessible repos (personal + orgs, private + public, up to 200 repos). Use to find a RELATED repo worth cloning for cross-repo context.
|
|
6
6
|
- github_search_repos: Search for a specific repo by name (e.g., "electron", "my-app")
|
|
7
7
|
- github_get_user: Get authenticated user's profile
|
|
8
8
|
- github_list_orgs: List organizations with accessible repos
|
|
@@ -20,6 +20,9 @@ You have access to the user's GitHub repositories. Available tools:
|
|
|
20
20
|
- github_get_pr_diff: Get PR diff
|
|
21
21
|
- github_list_pr_files: List PR changed files
|
|
22
22
|
- github_list_pr_comments: Get PR comments
|
|
23
|
+
- github_get_review_thread: Read a review-comment THREAD (root + replies) with its diff context, given any comment id in it
|
|
24
|
+
- github_reply_review_thread: Reply IN-THREAD to an existing review-comment thread (conversational reply, not a new review)
|
|
25
|
+
- github_reply_issue_comment: Reply on the PR's top-level conversation (for non-inline/summary comments)
|
|
23
26
|
- github_create_review: Post a review on a PR \u2014 a summary body plus optional inline comments on specific file/line positions, with an event (COMMENT, APPROVE, or REQUEST_CHANGES)
|
|
24
27
|
- github_create_issue: Create new issue
|
|
25
28
|
- github_list_issues: List issues in a repo (filter by state/labels/since cursor) \u2014 excludes PRs
|
|
@@ -36,6 +39,6 @@ When user says "check out repo-name" or "clone repo-name":
|
|
|
36
39
|
3. STOP. Do not offer to inspect files or ask what to do next.
|
|
37
40
|
|
|
38
41
|
When user just wants to "look at" or "read" files (not clone):
|
|
39
|
-
- Use github_get_file to read individual files via API`,resolve(){let
|
|
42
|
+
- Use github_get_file to read individual files via API`,resolve(){let y=C();if(!y)return{command:null,args:[],env:{},description:this.description};let a={};for(let t of this.envKeys)process.env[t]&&(a[t]=process.env[t]);return{type:"stdio",command:"node",args:[y,"../dist/github.js","githubSkill"],env:a,description:this.description,alwaysLoad:!0}},async handleToolCall(y,a){try{switch(y){case"github_search_issues":{let t=a.query;if(!t)return JSON.stringify({error:"query is required"});let n=await l(`/search/issues?q=${encodeURIComponent(t)}&per_page=${a.limit||20}`),i=(n.items||[]).map(e=>({number:e.number,title:e.title,state:e.state,repo:e.repository_url?.split("/").slice(-2).join("/"),url:e.html_url,user:e.user?.login,isPR:!!e.pull_request,labels:(e.labels||[]).map(r=>r.name),createdAt:e.created_at}));return JSON.stringify({total:n.total_count,items:i})}case"github_search_code":{let t=a.query;if(!t)return JSON.stringify({error:"query is required"});let n=a.repo?`+repo:${a.repo}`:"",i=a.language?`+language:${a.language}`:"",e=await l(`/search/code?q=${encodeURIComponent(t)}${n}${i}&per_page=${a.limit||15}`),r=(e.items||[]).map(s=>({name:s.name,path:s.path,repo:s.repository?.full_name,url:s.html_url,score:s.score}));return JSON.stringify({total:e.total_count,items:r})}case"github_get_pr":{let{owner:t,repo:n,number:i}=a;if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await l(`/repos/${t}/${n}/pulls/${i}`);return JSON.stringify({number:e.number,title:e.title,state:e.state,merged:e.merged,body:e.body?.slice(0,5e3),user:e.user?.login,branch:e.head?.ref,headSha:e.head?.sha,base:e.base?.ref,changedFiles:e.changed_files,additions:e.additions,deletions:e.deletions,createdAt:e.created_at,mergedAt:e.merged_at,url:e.html_url,labels:(e.labels||[]).map(r=>r.name)})}case"github_get_pr_diff":{let{owner:t,repo:n,number:i}=a;if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await l(`/repos/${t}/${n}/pulls/${i}`,{accept:"application/vnd.github.v3.diff",raw:!0}),r=e.length>15e3;return JSON.stringify({number:i,diff:r?e.slice(0,15e3):e,truncated:r,totalLength:e.length})}case"github_list_pr_files":{let{owner:t,repo:n,number:i}=a;if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await l(`/repos/${t}/${n}/pulls/${i}/files?per_page=100`);return JSON.stringify({total:e.length,files:e.map(r=>({filename:r.filename,status:r.status,additions:r.additions,deletions:r.deletions,patch:r.patch?.slice(0,3e3)}))})}case"github_list_pr_comments":{let{owner:t,repo:n,number:i}=a;if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await l(`/repos/${t}/${n}/pulls/${i}/comments?per_page=50`),r=await l(`/repos/${t}/${n}/issues/${i}/comments?per_page=50`),s=[...e.map(o=>({type:"review",user:o.user?.login,body:o.body?.slice(0,1e3),path:o.path,line:o.line,createdAt:o.created_at})),...r.map(o=>({type:"issue",user:o.user?.login,body:o.body?.slice(0,1e3),createdAt:o.created_at}))].sort((o,d)=>new Date(o.createdAt)-new Date(d.createdAt));return JSON.stringify({total:s.length,comments:s})}case"github_get_review_thread":{let{owner:t,repo:n,number:i,commentId:e}=a||{};if(!t||!n||!i||!e)return JSON.stringify({error:"owner, repo, number, and commentId are required"});let r=await l(`/repos/${t}/${n}/pulls/comments/${e}`),s=r.in_reply_to_id||r.id,o=[];try{o=await l(`/repos/${t}/${n}/pulls/${i}/comments?per_page=100`)}catch{o=[r]}(!Array.isArray(o)||o.length===0)&&(o=[r]);let d=o.filter(u=>u.id===s||u.in_reply_to_id===s).sort((u,h)=>new Date(u.created_at)-new Date(h.created_at)),c=d.length?d:[r],p=c.find(u=>u.id===s)||c[0];return JSON.stringify({rootCommentId:s,path:p.path,line:p.line??p.original_line??null,side:p.side||"RIGHT",diffHunk:typeof p.diff_hunk=="string"?p.diff_hunk.slice(0,3e3):null,commitId:p.commit_id||p.original_commit_id||null,notes:c.map(u=>({id:u.id,user:u.user?.login,body:(u.body||"").slice(0,4e3),createdAt:u.created_at,isRoot:u.id===s,url:u.html_url}))})}case"github_reply_review_thread":{let{owner:t,repo:n,number:i,commentId:e,body:r}=a||{};if(!t||!n||!i||!e||!r)return JSON.stringify({error:"owner, repo, number, commentId, and body are required"});let s=await l(`/repos/${t}/${n}/pulls/${i}/comments/${e}/replies`,{method:"POST",body:{body:String(r)}});return JSON.stringify({ok:!0,id:s.id,url:s.html_url,inReplyTo:s.in_reply_to_id})}case"github_reply_issue_comment":{let{owner:t,repo:n,number:i,body:e}=a||{};if(!t||!n||!i||!e)return JSON.stringify({error:"owner, repo, number, and body are required"});let r=await l(`/repos/${t}/${n}/issues/${i}/comments`,{method:"POST",body:{body:String(e)}});return JSON.stringify({ok:!0,id:r.id,url:r.html_url})}case"github_create_review":{let{owner:t,repo:n,number:i,body:e,event:r,comments:s}=a||{};if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let o=(r||"COMMENT").toUpperCase();if(!["COMMENT","APPROVE","REQUEST_CHANGES"].includes(o))return JSON.stringify({error:`event must be COMMENT, APPROVE, or REQUEST_CHANGES (got ${r})`});let d=Array.isArray(s)?s.filter(u=>u&&u.path&&u.body&&(u.line!=null||u.position!=null)).map(u=>{let h={path:u.path,body:String(u.body)};return u.line!=null?(h.line=Number(u.line),h.side=u.side==="LEFT"?"LEFT":"RIGHT"):h.position=Number(u.position),h}):[];if(o!=="APPROVE"&&!e&&d.length===0)return JSON.stringify({error:"a COMMENT or REQUEST_CHANGES review needs a body and/or inline comments"});let c={event:o};e&&(c.body=String(e)),d.length>0&&(c.comments=d);let p=await l(`/repos/${t}/${n}/pulls/${i}/reviews`,{method:"POST",body:c});return JSON.stringify({ok:!0,id:p.id,state:p.state,event:o,commentsPosted:d.length,url:p.html_url})}case"github_list_commits":{let{owner:t,repo:n,branch:i,path:e,limit:r}=a;if(!t||!n)return JSON.stringify({error:"owner and repo are required"});let s=`/repos/${t}/${n}/commits?per_page=${r||20}`;i&&(s+=`&sha=${encodeURIComponent(i)}`),e&&(s+=`&path=${encodeURIComponent(e)}`);let o=await l(s);return JSON.stringify({total:o.length,commits:o.map(d=>({sha:d.sha?.slice(0,8),fullSha:d.sha,message:d.commit?.message?.slice(0,300),author:d.commit?.author?.name,date:d.commit?.author?.date,url:d.html_url}))})}case"github_get_commit":{let{owner:t,repo:n,sha:i}=a;if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and sha are required"});let e=await l(`/repos/${t}/${n}/commits/${i}`);return JSON.stringify({sha:e.sha?.slice(0,8),message:e.commit?.message,author:e.commit?.author?.name,date:e.commit?.author?.date,stats:e.stats,files:(e.files||[]).map(r=>({filename:r.filename,status:r.status,additions:r.additions,deletions:r.deletions,patch:r.patch?.slice(0,3e3)}))})}case"github_get_file":{let{owner:t,repo:n,path:i,ref:e}=a;if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and path are required"});let r=`/repos/${t}/${n}/contents/${encodeURIComponent(i)}`;e&&(r+=`?ref=${encodeURIComponent(e)}`);let s=await l(r);if(s.type!=="file")return Array.isArray(s)?JSON.stringify({type:"directory",path:i,entries:s.map(c=>({name:c.name,type:c.type,size:c.size,path:c.path}))}):JSON.stringify({error:`Not a file: ${s.type}`});let o=Buffer.from(s.content||"","base64").toString("utf-8"),d=o.length>2e4;return JSON.stringify({path:s.path,size:s.size,sha:s.sha?.slice(0,8),content:d?o.slice(0,2e4):o,truncated:d})}case"github_get_user":try{let t=await l("/installation/repositories?per_page=1");if(t.repositories&&t.repositories.length>0){let n=t.repositories[0],i=n.owner.login,e=n.owner.type,r=e==="Organization"?`/orgs/${i}`:`/users/${i}`,s=await l(r);return JSON.stringify({login:s.login,name:s.name||s.login,avatar:s.avatar_url,bio:s.bio||s.description,type:e,isOrg:e==="Organization",publicRepos:s.public_repos,message:"Showing GitHub App installation owner (GitHub Apps cannot access /user endpoint)"})}return JSON.stringify({error:"No repositories accessible to this GitHub App installation"})}catch(t){return JSON.stringify({error:`GitHub App cannot access /user endpoint. Use github_list_repos instead. (${t.message})`})}case"github_list_orgs":try{let n=(await l("/installation/repositories?per_page=100")).repositories||[],i=new Map;for(let r of n)r.owner.type==="Organization"&&(i.has(r.owner.login)||i.set(r.owner.login,{login:r.owner.login,description:null,url:r.owner.url}));let e=Array.from(i.values());return JSON.stringify({count:e.length,orgs:e,message:"Extracted from accessible repositories (GitHub Apps cannot access /user/orgs directly)"})}catch(t){return JSON.stringify({error:`GitHub App cannot list orgs via /user/orgs. Error: ${t.message}`})}case"github_clone":{let g=function(_){let S=_.replace(/^~(?=$|\/|\\)/,h);return s(S)},{owner:t,repo:n,destination:i}=a;if(!t||!n)return JSON.stringify({error:"owner and repo are required"});let{execSync:e}=await import("child_process"),{join:r,resolve:s}=await import("path"),{existsSync:o,mkdirSync:d}=await import("fs"),{homedir:c,platform:p}=await import("os"),{token:u}=await q("github"),h=c(),b=i?g(i):r(h,"zibby-repos"),f=r(b,n);if(d(b,{recursive:!0}),o(f))return JSON.stringify({error:`Directory ${f} already exists. Remove it first or use a different destination.`,existingPath:f});try{let _=`https://x-access-token:${u}@github.com/${t}/${n}.git`;e(`git clone ${_} "${f}"`,{stdio:"pipe"});let S=p()==="win32",m;return S?m=e(`dir "${f}"`,{encoding:"utf-8",shell:"cmd.exe"}):m=e(`ls -la "${f}"`,{encoding:"utf-8"}),JSON.stringify({success:!0,path:f,message:`Cloned ${t}/${n} to ${f}`,contents:m.split(`
|
|
40
43
|
`).slice(0,30).join(`
|
|
41
|
-
`),instructions:"IMPORTANT: Show the contents field to the user - it contains the directory listing."})}catch(_){return JSON.stringify({error:`Clone failed: ${_.message}`})}}case"github_search_repos":{let{query:t,limit:i}=a;if(!t)return JSON.stringify({error:"query is required"});let r=await this.handleToolCall("github_list_repos",{limit:200},{}),e=JSON.parse(r);if(e.error)return JSON.stringify(e);let s=t.toLowerCase(),n=e.repos.filter(o=>o.name.toLowerCase().includes(s)||o.fullName.toLowerCase().includes(s)||o.description&&o.description.toLowerCase().includes(s));return JSON.stringify({query:t,count:n.length,repos:n.slice(0,i||20)})}case"github_list_repos":{let{owner:t,type:i,sort:r,direction:e,limit:s}=a,n=100,o=s||200,p=[];if(!t){let u=1,b=!0;for(;b&&p.length<o;){let g=`/installation/repositories?per_page=${n}&page=${u}`,S=(await l(g)).repositories||[];if(S.length===0)break;p=p.concat(S),b=S.length===n,u++}let h=p.slice(0,o).map(g=>({name:g.name,fullName:g.full_name,private:g.private,description:g.description,language:g.language,defaultBranch:g.default_branch,updatedAt:g.updated_at,stars:g.stargazers_count,url:g.html_url})),_=h.filter(g=>g.private).length,w=h.filter(g=>!g.private).length;return JSON.stringify({count:h.length,repos:h,privateCount:_,publicCount:w,message:`Found ${_} private and ${w} public repos`})}let d=await l(`/orgs/${t}`).then(()=>!0).catch(()=>!1),c=1,m=!0;for(;m&&p.length<o;){let u;d?u=`/orgs/${t}/repos?per_page=${n}&page=${c}&type=${i||"all"}&sort=${r||"updated"}&direction=${e||"desc"}`:u=`/users/${t}/repos?per_page=${n}&page=${c}&type=${i||"all"}&sort=${r||"updated"}&direction=${e||"desc"}`;let b=await l(u),h=Array.isArray(b)?b:[];if(h.length===0)break;p=p.concat(h),m=h.length===n,c++}let y=p.slice(0,o).map(u=>({name:u.name,fullName:u.full_name,private:u.private,description:u.description,language:u.language,defaultBranch:u.default_branch,updatedAt:u.updated_at,stars:u.stargazers_count,url:u.html_url}));return JSON.stringify({count:y.length,repos:y})}case"github_create_issue":{let{owner:t,repo:i,title:r,body:e}=a;if(!t||!i||!r)return JSON.stringify({error:"owner, repo, and title are required"});let s=await l(`/repos/${t}/${i}/issues`,{method:"POST",body:{title:r,body:e||""}});return JSON.stringify({number:s.number,url:s.html_url,title:s.title})}case"github_list_issues":{let{owner:t,repo:i,state:r,labels:e,since:s,assignee:n,sort:o,direction:p,limit:d}=a||{};if(!t||!i)return JSON.stringify({error:"owner and repo are required"});let c=new URLSearchParams;c.set("state",r||"open"),c.set("per_page",String(d||30)),c.set("sort",o||"updated"),c.set("direction",p||"desc"),e&&c.set("labels",Array.isArray(e)?e.join(","):e),s&&c.set("since",s),n&&c.set("assignee",n);let m=await l(`/repos/${t}/${i}/issues?${c.toString()}`),y=(Array.isArray(m)?m:[]).filter(u=>!u.pull_request).map(u=>({number:u.number,title:u.title,state:u.state,labels:(u.labels||[]).map(b=>typeof b=="string"?b:b.name),assignee:u.assignee?.login||null,assignees:(u.assignees||[]).map(b=>b.login),user:u.user?.login,comments:u.comments,url:u.html_url,createdAt:u.created_at,updatedAt:u.updated_at}));return JSON.stringify({count:y.length,issues:y})}case"github_get_issue":{let{owner:t,repo:i,number:r}=a||{};if(!t||!i||!r)return JSON.stringify({error:"owner, repo, and number are required"});let e=await l(`/repos/${t}/${i}/issues/${r}`);return e.pull_request?JSON.stringify({error:`#${r} is a pull request, not an issue`,isPR:!0}):JSON.stringify({number:e.number,title:e.title,body:e.body||"",state:e.state,stateReason:e.state_reason||null,labels:(e.labels||[]).map(s=>typeof s=="string"?s:s.name),assignee:e.assignee?.login||null,assignees:(e.assignees||[]).map(s=>s.login),user:e.user?.login,milestone:e.milestone?.title||null,comments:e.comments,url:e.html_url,createdAt:e.created_at,updatedAt:e.updated_at,closedAt:e.closed_at})}case"github_get_issue_comments":{let{owner:t,repo:i,number:r,limit:e}=a||{};if(!t||!i||!r)return JSON.stringify({error:"owner, repo, and number are required"});let s=await l(`/repos/${t}/${i}/issues/${r}/comments?per_page=${e||100}`),n=(Array.isArray(s)?s:[]).map(o=>({id:o.id,user:o.user?.login,body:o.body||"",createdAt:o.created_at,updatedAt:o.updated_at,url:o.html_url}));return JSON.stringify({count:n.length,comments:n})}case"github_add_issue_comment":{let{owner:t,repo:i,number:r,body:e}=a||{};if(!t||!i||!r||!e)return JSON.stringify({error:"owner, repo, number, and body are required"});let s=await l(`/repos/${t}/${i}/issues/${r}/comments`,{method:"POST",body:{body:e}});return JSON.stringify({ok:!0,id:s.id,url:s.html_url})}case"github_close_issue":{let{owner:t,repo:i,number:r,stateReason:e}=a||{};if(!t||!i||!r)return JSON.stringify({error:"owner, repo, and number are required"});let s={state:"closed"};e&&(s.state_reason=e);let n=await l(`/repos/${t}/${i}/issues/${r}`,{method:"PATCH",body:s});return JSON.stringify({ok:!0,number:n.number,state:n.state,stateReason:n.state_reason||null,url:n.html_url})}case"github_reopen_issue":{let{owner:t,repo:i,number:r}=a||{};if(!t||!i||!r)return JSON.stringify({error:"owner, repo, and number are required"});let e=await l(`/repos/${t}/${i}/issues/${r}`,{method:"PATCH",body:{state:"open"}});return JSON.stringify({ok:!0,number:e.number,state:e.state,url:e.html_url})}case"github_label_issue":{let{owner:t,repo:i,number:r,labels:e,mode:s}=a||{};if(!t||!i||!r)return JSON.stringify({error:"owner, repo, and number are required"});let n=Array.isArray(e)?e:e?[e]:[];if(!n.length)return JSON.stringify({error:"labels (string or array) is required"});let o=s||"add";if(o==="set"){let d=await l(`/repos/${t}/${i}/issues/${r}`,{method:"PATCH",body:{labels:n}});return JSON.stringify({ok:!0,number:d.number,labels:(d.labels||[]).map(c=>typeof c=="string"?c:c.name)})}if(o==="remove"){for(let c of n)await l(`/repos/${t}/${i}/issues/${r}/labels/${encodeURIComponent(c)}`,{method:"DELETE"});let d=await l(`/repos/${t}/${i}/issues/${r}`);return JSON.stringify({ok:!0,number:d.number,labels:(d.labels||[]).map(c=>typeof c=="string"?c:c.name)})}let p=await l(`/repos/${t}/${i}/issues/${r}/labels`,{method:"POST",body:{labels:n}});return JSON.stringify({ok:!0,number:r,labels:(Array.isArray(p)?p:[]).map(d=>typeof d=="string"?d:d.name)})}default:return JSON.stringify({error:`Unknown tool: ${f}`})}}catch(t){return JSON.stringify({error:t.message})}},tools:[{name:"github_get_user",description:"Get the authenticated GitHub user profile and their organizations",input_schema:{type:"object",properties:{}}},{name:"github_list_orgs",description:"List GitHub organizations the authenticated user belongs to",input_schema:{type:"object",properties:{}}},{name:"github_list_repos",description:"List repositories for a user or org. If no owner given, lists the authenticated user's repos.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Org or user login. Omit to list your own repos."},type:{type:"string",enum:["all","public","private","forks","sources","member"],description:"Filter by type (default: all)"},sort:{type:"string",enum:["created","updated","pushed","full_name"],description:"Sort field (default: updated)"},direction:{type:"string",enum:["asc","desc"],description:"Sort direction (default: desc)"},limit:{type:"number",description:"Max repos to return (default: 30)"}}}},{name:"github_clone",description:'Clone a GitHub repository to the local filesystem. Use when user says "check out" or "clone" a repo.',input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner (user or org name)"},repo:{type:"string",description:"Repository name"},destination:{type:"string",description:"Destination directory. Accepts absolute paths, ~-prefixed paths, or relative names. Defaults to ~/zibby-repos/<repo>."}},required:["owner","repo"]}},{name:"github_search_repos",description:"Search accessible repositories by name or description. Use this when the user asks to find a specific repo.",input_schema:{type:"object",properties:{query:{type:"string",description:'Search term to match against repo name or description (e.g., "electron", "my-app")'},limit:{type:"number",description:"Max results (default: 20)"}},required:["query"]}},{name:"github_search_issues",description:"Search GitHub issues and pull requests",input_schema:{type:"object",properties:{query:{type:"string",description:'GitHub search query (e.g. "SCRUM-123", "login bug repo:org/app")'},limit:{type:"number",description:"Max results (default: 20)"}},required:["query"]}},{name:"github_search_code",description:"Search code across GitHub repositories by keyword",input_schema:{type:"object",properties:{query:{type:"string",description:'Code search query (e.g. "handleLogin", "class AuthService")'},repo:{type:"string",description:'Scope to a specific repo (e.g. "org/app"). Optional.'},language:{type:"string",description:'Filter by language (e.g. "javascript", "python"). Optional.'},limit:{type:"number",description:"Max results (default: 15)"}},required:["query"]}},{name:"github_get_pr",description:"Get details of a pull request \u2014 title, description, branch, stats",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"}},required:["owner","repo","number"]}},{name:"github_get_pr_diff",description:"Get the unified diff of a pull request \u2014 the actual code changes",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"}},required:["owner","repo","number"]}},{name:"github_list_pr_files",description:"List files changed in a PR with per-file patches",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"}},required:["owner","repo","number"]}},{name:"github_list_pr_comments",description:"Get all review and issue comments on a PR",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"}},required:["owner","repo","number"]}},{name:"github_create_review",description:"Post a review on a pull request: a summary body plus optional inline comments anchored to file/line, with an event (COMMENT, APPROVE, or REQUEST_CHANGES). Use this to deliver a code review back to the PR.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"},body:{type:"string",description:"The review summary (markdown). Shown as the top-level review comment."},event:{type:"string",enum:["COMMENT","APPROVE","REQUEST_CHANGES"],description:"Review verdict. Default COMMENT (no approval state). Use REQUEST_CHANGES for blocking issues."},comments:{type:"array",description:"Optional inline comments, each anchored to a changed line.",items:{type:"object",properties:{path:{type:"string",description:"File path as it appears in the diff"},line:{type:"number",description:"Line number in the file's NEW version (the right side of the diff)"},side:{type:"string",enum:["LEFT","RIGHT"],description:"RIGHT (new) or LEFT (old). Default RIGHT."},body:{type:"string",description:"The inline comment text (markdown)"}},required:["path","line","body"]}}},required:["owner","repo","number"]}},{name:"github_list_commits",description:"List recent commits on a branch, optionally filtered by file path",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},branch:{type:"string",description:"Branch name (default: repo default branch)"},path:{type:"string",description:"Filter commits touching this file path"},limit:{type:"number",description:"Max commits (default: 20)"}},required:["owner","repo"]}},{name:"github_get_commit",description:"Get details of a specific commit \u2014 message, stats, file diffs",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},sha:{type:"string",description:"Commit SHA (full or short)"}},required:["owner","repo","sha"]}},{name:"github_get_file",description:"Read a file (or list a directory) from a GitHub repo. Works on any branch/ref.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},path:{type:"string",description:'File or directory path (e.g. "src/auth/login.ts")'},ref:{type:"string",description:"Branch, tag, or commit SHA (default: repo default branch)"}},required:["owner","repo","path"]}},{name:"github_create_issue",description:"Create a GitHub issue",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},title:{type:"string",description:"Issue title"},body:{type:"string",description:"Issue body (markdown)"}},required:["owner","repo","title"]}},{name:"github_list_issues",description:"List issues in a repo (excludes pull requests). Filter by state, labels, and an updated-since cursor for polling.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},state:{type:"string",enum:["open","closed","all"],description:"Filter by state (default: open)"},labels:{type:"array",items:{type:"string"},description:"Only issues carrying ALL of these labels"},since:{type:"string",description:"ISO-8601 timestamp; only issues updated at/after this (polling cursor)"},assignee:{type:"string",description:'Filter by assignee login, "none", or "*"'},sort:{type:"string",enum:["created","updated","comments"],description:"Sort field (default: updated)"},direction:{type:"string",enum:["asc","desc"],description:"Sort direction (default: desc)"},limit:{type:"number",description:"Max issues (default: 30, max 100 per page)"}},required:["owner","repo"]}},{name:"github_get_issue",description:"Get a single GitHub issue with full detail (title, body, state, labels, assignee, url)",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"Issue number"}},required:["owner","repo","number"]}},{name:"github_get_issue_comments",description:"Get the comment thread on a GitHub issue (chronological)",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"Issue number"},limit:{type:"number",description:"Max comments (default: 100)"}},required:["owner","repo","number"]}},{name:"github_add_issue_comment",description:"Add a comment to a GitHub issue. Also the way to record a PR link on an issue (post a markdown link).",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"Issue number"},body:{type:"string",description:"Comment body (markdown)"}},required:["owner","repo","number","body"]}},{name:"github_close_issue",description:"Close a GitHub issue. Optionally set the close reason (completed or not_planned).",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"Issue number"},stateReason:{type:"string",enum:["completed","not_planned"],description:"Why the issue was closed (optional)"}},required:["owner","repo","number"]}},{name:"github_reopen_issue",description:"Reopen a closed GitHub issue",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"Issue number"}},required:["owner","repo","number"]}},{name:"github_label_issue",description:"Add, set (replace all), or remove labels on a GitHub issue. Labels back state-like transitions on GitHub.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"Issue number"},labels:{type:"array",items:{type:"string"},description:"Label name(s)"},mode:{type:"string",enum:["add","set","remove"],description:"add appends, set replaces all, remove deletes (default: add)"}},required:["owner","repo","number","labels"]}}]};export{L as githubSkill};
|
|
44
|
+
`),instructions:"IMPORTANT: Show the contents field to the user - it contains the directory listing."})}catch(_){return JSON.stringify({error:`Clone failed: ${_.message}`})}}case"github_search_repos":{let{query:t,limit:n}=a;if(!t)return JSON.stringify({error:"query is required"});let i=await this.handleToolCall("github_list_repos",{limit:200},{}),e=JSON.parse(i);if(e.error)return JSON.stringify(e);let r=t.toLowerCase(),s=e.repos.filter(o=>o.name.toLowerCase().includes(r)||o.fullName.toLowerCase().includes(r)||o.description&&o.description.toLowerCase().includes(r));return JSON.stringify({query:t,count:s.length,repos:s.slice(0,n||20)})}case"github_list_repos":{let{owner:t,type:n,sort:i,direction:e,limit:r,query:s}=a,o=100,d=r||200,c=[],p=m=>({name:m.name,fullName:m.full_name,private:m.private,description:m.description,language:m.language,defaultBranch:m.default_branch,updatedAt:m.updated_at,stars:m.stargazers_count,url:m.html_url,fullPath:m.full_name,webUrl:m.html_url,visibility:m.visibility||(m.private?"private":"public")}),u=m=>{if(!s)return!0;let w=String(s).toLowerCase();return m.name&&m.name.toLowerCase().includes(w)||m.fullName&&m.fullName.toLowerCase().includes(w)||m.description&&m.description.toLowerCase().includes(w)};if(!t){let m=1,w=!0;for(;w&&c.length<d;){let v=`/installation/repositories?per_page=${o}&page=${m}`,O=(await l(v)).repositories||[];if(O.length===0)break;c=c.concat(O),w=O.length===o,m++}let R=c.map(p).filter(u),$=R.slice(0,d),T=R.length>$.length,N=$.filter(v=>v.private).length,A=$.filter(v=>!v.private).length;return JSON.stringify({count:$.length,repos:$,truncated:T,privateCount:N,publicCount:A,message:`Found ${N} private and ${A} public repos`})}let h=await l(`/orgs/${t}`).then(()=>!0).catch(()=>!1),g=1,b=!0;for(;b&&c.length<d;){let m;h?m=`/orgs/${t}/repos?per_page=${o}&page=${g}&type=${n||"all"}&sort=${i||"updated"}&direction=${e||"desc"}`:m=`/users/${t}/repos?per_page=${o}&page=${g}&type=${n||"all"}&sort=${i||"updated"}&direction=${e||"desc"}`;let w=await l(m),R=Array.isArray(w)?w:[];if(R.length===0)break;c=c.concat(R),b=R.length===o,g++}let f=c.map(p).filter(u),_=f.slice(0,d),S=f.length>_.length;return JSON.stringify({count:_.length,repos:_,truncated:S})}case"github_create_issue":{let{owner:t,repo:n,title:i,body:e}=a;if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and title are required"});let r=await l(`/repos/${t}/${n}/issues`,{method:"POST",body:{title:i,body:e||""}});return JSON.stringify({number:r.number,url:r.html_url,title:r.title})}case"github_list_issues":{let{owner:t,repo:n,state:i,labels:e,since:r,assignee:s,sort:o,direction:d,limit:c}=a||{};if(!t||!n)return JSON.stringify({error:"owner and repo are required"});let p=new URLSearchParams;p.set("state",i||"open"),p.set("per_page",String(c||30)),p.set("sort",o||"updated"),p.set("direction",d||"desc"),e&&p.set("labels",Array.isArray(e)?e.join(","):e),r&&p.set("since",r),s&&p.set("assignee",s);let u=await l(`/repos/${t}/${n}/issues?${p.toString()}`),h=(Array.isArray(u)?u:[]).filter(g=>!g.pull_request).map(g=>({number:g.number,title:g.title,state:g.state,labels:(g.labels||[]).map(b=>typeof b=="string"?b:b.name),assignee:g.assignee?.login||null,assignees:(g.assignees||[]).map(b=>b.login),user:g.user?.login,comments:g.comments,url:g.html_url,createdAt:g.created_at,updatedAt:g.updated_at}));return JSON.stringify({count:h.length,issues:h})}case"github_get_issue":{let{owner:t,repo:n,number:i}=a||{};if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await l(`/repos/${t}/${n}/issues/${i}`);return e.pull_request?JSON.stringify({error:`#${i} is a pull request, not an issue`,isPR:!0}):JSON.stringify({number:e.number,title:e.title,body:e.body||"",state:e.state,stateReason:e.state_reason||null,labels:(e.labels||[]).map(r=>typeof r=="string"?r:r.name),assignee:e.assignee?.login||null,assignees:(e.assignees||[]).map(r=>r.login),user:e.user?.login,milestone:e.milestone?.title||null,comments:e.comments,url:e.html_url,createdAt:e.created_at,updatedAt:e.updated_at,closedAt:e.closed_at})}case"github_get_issue_comments":{let{owner:t,repo:n,number:i,limit:e}=a||{};if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let r=await l(`/repos/${t}/${n}/issues/${i}/comments?per_page=${e||100}`),s=(Array.isArray(r)?r:[]).map(o=>({id:o.id,user:o.user?.login,body:o.body||"",createdAt:o.created_at,updatedAt:o.updated_at,url:o.html_url}));return JSON.stringify({count:s.length,comments:s})}case"github_add_issue_comment":{let{owner:t,repo:n,number:i,body:e}=a||{};if(!t||!n||!i||!e)return JSON.stringify({error:"owner, repo, number, and body are required"});let r=await l(`/repos/${t}/${n}/issues/${i}/comments`,{method:"POST",body:{body:e}});return JSON.stringify({ok:!0,id:r.id,url:r.html_url})}case"github_close_issue":{let{owner:t,repo:n,number:i,stateReason:e}=a||{};if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let r={state:"closed"};e&&(r.state_reason=e);let s=await l(`/repos/${t}/${n}/issues/${i}`,{method:"PATCH",body:r});return JSON.stringify({ok:!0,number:s.number,state:s.state,stateReason:s.state_reason||null,url:s.html_url})}case"github_reopen_issue":{let{owner:t,repo:n,number:i}=a||{};if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let e=await l(`/repos/${t}/${n}/issues/${i}`,{method:"PATCH",body:{state:"open"}});return JSON.stringify({ok:!0,number:e.number,state:e.state,url:e.html_url})}case"github_label_issue":{let{owner:t,repo:n,number:i,labels:e,mode:r}=a||{};if(!t||!n||!i)return JSON.stringify({error:"owner, repo, and number are required"});let s=Array.isArray(e)?e:e?[e]:[];if(!s.length)return JSON.stringify({error:"labels (string or array) is required"});let o=r||"add";if(o==="set"){let c=await l(`/repos/${t}/${n}/issues/${i}`,{method:"PATCH",body:{labels:s}});return JSON.stringify({ok:!0,number:c.number,labels:(c.labels||[]).map(p=>typeof p=="string"?p:p.name)})}if(o==="remove"){for(let p of s)await l(`/repos/${t}/${n}/issues/${i}/labels/${encodeURIComponent(p)}`,{method:"DELETE"});let c=await l(`/repos/${t}/${n}/issues/${i}`);return JSON.stringify({ok:!0,number:c.number,labels:(c.labels||[]).map(p=>typeof p=="string"?p:p.name)})}let d=await l(`/repos/${t}/${n}/issues/${i}/labels`,{method:"POST",body:{labels:s}});return JSON.stringify({ok:!0,number:i,labels:(Array.isArray(d)?d:[]).map(c=>typeof c=="string"?c:c.name)})}default:return JSON.stringify({error:`Unknown tool: ${y}`})}}catch(t){return JSON.stringify({error:t.message})}},tools:[{name:"github_get_user",description:"Get the authenticated GitHub user profile and their organizations",input_schema:{type:"object",properties:{}}},{name:"github_list_orgs",description:"List GitHub organizations the authenticated user belongs to",input_schema:{type:"object",properties:{}}},{name:"github_list_repos",description:"List the repositories this token/installation can access (omit owner) \u2014 or a specific user/org's repos (pass owner). Use this to discover a RELATED repo worth cloning when a change's correctness depends on another accessible repo. Each repo carries a normalized { fullPath, name, webUrl, defaultBranch, visibility } shape (identical to gitlab_list_projects) alongside legacy fields, plus a truncated flag.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Org or user login. Omit to list every repo your token/installation can access."},query:{type:"string",description:"Optional term matched against repo name/full-name/description"},type:{type:"string",enum:["all","public","private","forks","sources","member"],description:"Filter by type (default: all)"},sort:{type:"string",enum:["created","updated","pushed","full_name"],description:"Sort field (default: updated)"},direction:{type:"string",enum:["asc","desc"],description:"Sort direction (default: desc)"},limit:{type:"number",description:"Max repos to return (default: 200, hard-capped at the fetch ceiling)"}}}},{name:"github_clone",description:'Clone a GitHub repository to the local filesystem. Use when user says "check out" or "clone" a repo.',input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner (user or org name)"},repo:{type:"string",description:"Repository name"},destination:{type:"string",description:"Destination directory. Accepts absolute paths, ~-prefixed paths, or relative names. Defaults to ~/zibby-repos/<repo>."}},required:["owner","repo"]}},{name:"github_search_repos",description:"Search accessible repositories by name or description. Use this when the user asks to find a specific repo.",input_schema:{type:"object",properties:{query:{type:"string",description:'Search term to match against repo name or description (e.g., "electron", "my-app")'},limit:{type:"number",description:"Max results (default: 20)"}},required:["query"]}},{name:"github_search_issues",description:"Search GitHub issues and pull requests",input_schema:{type:"object",properties:{query:{type:"string",description:'GitHub search query (e.g. "SCRUM-123", "login bug repo:org/app")'},limit:{type:"number",description:"Max results (default: 20)"}},required:["query"]}},{name:"github_search_code",description:"Search code across GitHub repositories by keyword",input_schema:{type:"object",properties:{query:{type:"string",description:'Code search query (e.g. "handleLogin", "class AuthService")'},repo:{type:"string",description:'Scope to a specific repo (e.g. "org/app"). Optional.'},language:{type:"string",description:'Filter by language (e.g. "javascript", "python"). Optional.'},limit:{type:"number",description:"Max results (default: 15)"}},required:["query"]}},{name:"github_get_pr",description:"Get details of a pull request \u2014 title, description, branch, stats",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"}},required:["owner","repo","number"]}},{name:"github_get_pr_diff",description:"Get the unified diff of a pull request \u2014 the actual code changes",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"}},required:["owner","repo","number"]}},{name:"github_list_pr_files",description:"List files changed in a PR with per-file patches",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"}},required:["owner","repo","number"]}},{name:"github_list_pr_comments",description:"Get all review and issue comments on a PR",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"}},required:["owner","repo","number"]}},{name:"github_get_review_thread",description:"Read a PR review-comment THREAD given any comment id in it: the root review comment + all its replies, plus the anchored diff context (file, line, the original diff hunk). Use this to understand a human's reply to a previous review comment before replying in-thread.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"},commentId:{type:"number",description:"Any review-comment id in the thread (the root or any reply)"}},required:["owner","repo","number","commentId"]}},{name:"github_reply_review_thread",description:"Reply IN-THREAD to an existing PR review-comment thread (a conversational reply nested under the thread the human commented on \u2014 NOT a fresh full review). Pass any comment id in the thread.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"},commentId:{type:"number",description:"Any review-comment id in the thread to reply to"},body:{type:"string",description:"The reply text (markdown)"}},required:["owner","repo","number","commentId","body"]}},{name:"github_reply_issue_comment",description:"Post a reply on a PR's top-level conversation (a new issue comment on the PR). Use when the human replied to a non-inline/summary comment rather than an inline review thread. Quote or @-mention for context since issue comments are not threaded.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"},body:{type:"string",description:"The reply text (markdown)"}},required:["owner","repo","number","body"]}},{name:"github_create_review",description:"Post a review on a pull request: a summary body plus optional inline comments anchored to file/line, with an event (COMMENT, APPROVE, or REQUEST_CHANGES). Use this to deliver a code review back to the PR.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"PR number"},body:{type:"string",description:"The review summary (markdown). Shown as the top-level review comment."},event:{type:"string",enum:["COMMENT","APPROVE","REQUEST_CHANGES"],description:"Review verdict. Default COMMENT (no approval state). Use REQUEST_CHANGES for blocking issues."},comments:{type:"array",description:"Optional inline comments, each anchored to a changed line.",items:{type:"object",properties:{path:{type:"string",description:"File path as it appears in the diff"},line:{type:"number",description:"Line number in the file's NEW version (the right side of the diff)"},side:{type:"string",enum:["LEFT","RIGHT"],description:"RIGHT (new) or LEFT (old). Default RIGHT."},body:{type:"string",description:"The inline comment text (markdown)"}},required:["path","line","body"]}}},required:["owner","repo","number"]}},{name:"github_list_commits",description:"List recent commits on a branch, optionally filtered by file path",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},branch:{type:"string",description:"Branch name (default: repo default branch)"},path:{type:"string",description:"Filter commits touching this file path"},limit:{type:"number",description:"Max commits (default: 20)"}},required:["owner","repo"]}},{name:"github_get_commit",description:"Get details of a specific commit \u2014 message, stats, file diffs",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},sha:{type:"string",description:"Commit SHA (full or short)"}},required:["owner","repo","sha"]}},{name:"github_get_file",description:"Read a file (or list a directory) from a GitHub repo. Works on any branch/ref.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},path:{type:"string",description:'File or directory path (e.g. "src/auth/login.ts")'},ref:{type:"string",description:"Branch, tag, or commit SHA (default: repo default branch)"}},required:["owner","repo","path"]}},{name:"github_create_issue",description:"Create a GitHub issue",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},title:{type:"string",description:"Issue title"},body:{type:"string",description:"Issue body (markdown)"}},required:["owner","repo","title"]}},{name:"github_list_issues",description:"List issues in a repo (excludes pull requests). Filter by state, labels, and an updated-since cursor for polling.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},state:{type:"string",enum:["open","closed","all"],description:"Filter by state (default: open)"},labels:{type:"array",items:{type:"string"},description:"Only issues carrying ALL of these labels"},since:{type:"string",description:"ISO-8601 timestamp; only issues updated at/after this (polling cursor)"},assignee:{type:"string",description:'Filter by assignee login, "none", or "*"'},sort:{type:"string",enum:["created","updated","comments"],description:"Sort field (default: updated)"},direction:{type:"string",enum:["asc","desc"],description:"Sort direction (default: desc)"},limit:{type:"number",description:"Max issues (default: 30, max 100 per page)"}},required:["owner","repo"]}},{name:"github_get_issue",description:"Get a single GitHub issue with full detail (title, body, state, labels, assignee, url)",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"Issue number"}},required:["owner","repo","number"]}},{name:"github_get_issue_comments",description:"Get the comment thread on a GitHub issue (chronological)",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"Issue number"},limit:{type:"number",description:"Max comments (default: 100)"}},required:["owner","repo","number"]}},{name:"github_add_issue_comment",description:"Add a comment to a GitHub issue. Also the way to record a PR link on an issue (post a markdown link).",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"Issue number"},body:{type:"string",description:"Comment body (markdown)"}},required:["owner","repo","number","body"]}},{name:"github_close_issue",description:"Close a GitHub issue. Optionally set the close reason (completed or not_planned).",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"Issue number"},stateReason:{type:"string",enum:["completed","not_planned"],description:"Why the issue was closed (optional)"}},required:["owner","repo","number"]}},{name:"github_reopen_issue",description:"Reopen a closed GitHub issue",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"Issue number"}},required:["owner","repo","number"]}},{name:"github_label_issue",description:"Add, set (replace all), or remove labels on a GitHub issue. Labels back state-like transitions on GitHub.",input_schema:{type:"object",properties:{owner:{type:"string",description:"Repository owner"},repo:{type:"string",description:"Repository name"},number:{type:"number",description:"Issue number"},labels:{type:"array",items:{type:"string"},description:"Label name(s)"},mode:{type:"string",enum:["add","set","remove"],description:"add appends, set replaces all, remove deletes (default: add)"}},required:["owner","repo","number","labels"]}}]};export{z as githubSkill};
|