opencode-sdlc-plugin 1.1.0 → 1.1.2

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.
@@ -406,15 +406,28 @@ var GitHubClient = class {
406
406
  // Repositories
407
407
  // ==========================================================================
408
408
  /**
409
- * Create a new repository
409
+ * Create a new repository (personal or in an organization)
410
410
  */
411
411
  async createRepository(options) {
412
- const { data } = await this.octokit.repos.createForAuthenticatedUser({
413
- name: options.name,
414
- description: options.description,
415
- private: options.private ?? false,
416
- auto_init: options.autoInit ?? false
417
- });
412
+ let data;
413
+ if (options.org) {
414
+ const response = await this.octokit.repos.createInOrg({
415
+ org: options.org,
416
+ name: options.name,
417
+ description: options.description,
418
+ private: options.private ?? false,
419
+ auto_init: options.autoInit ?? false
420
+ });
421
+ data = response.data;
422
+ } else {
423
+ const response = await this.octokit.repos.createForAuthenticatedUser({
424
+ name: options.name,
425
+ description: options.description,
426
+ private: options.private ?? false,
427
+ auto_init: options.autoInit ?? false
428
+ });
429
+ data = response.data;
430
+ }
418
431
  return {
419
432
  id: data.id,
420
433
  name: data.name,
@@ -424,6 +437,32 @@ var GitHubClient = class {
424
437
  defaultBranch: data.default_branch || "main"
425
438
  };
426
439
  }
440
+ /**
441
+ * List organizations the authenticated user belongs to
442
+ */
443
+ async listOrganizations() {
444
+ const query = `
445
+ query {
446
+ viewer {
447
+ organizations(first: 100) {
448
+ nodes {
449
+ id
450
+ databaseId
451
+ login
452
+ name
453
+ }
454
+ }
455
+ }
456
+ }
457
+ `;
458
+ const result = await this.octokit.graphql(query);
459
+ return result.viewer.organizations.nodes.map((org) => ({
460
+ id: String(org.databaseId),
461
+ nodeId: org.id,
462
+ login: org.login,
463
+ name: org.name
464
+ }));
465
+ }
427
466
  /**
428
467
  * Get repository details
429
468
  */
@@ -505,6 +544,163 @@ var GitHubClient = class {
505
544
  return null;
506
545
  }
507
546
  }
547
+ /**
548
+ * Get project by number for an organization
549
+ */
550
+ async getOrgProject(orgLogin, projectNumber) {
551
+ const query = `
552
+ query($login: String!, $number: Int!) {
553
+ organization(login: $login) {
554
+ projectV2(number: $number) {
555
+ id
556
+ number
557
+ title
558
+ url
559
+ }
560
+ }
561
+ }
562
+ `;
563
+ try {
564
+ const result = await this.octokit.graphql(query, { login: orgLogin, number: projectNumber });
565
+ return result.organization.projectV2;
566
+ } catch {
567
+ return null;
568
+ }
569
+ }
570
+ /**
571
+ * List projects for an organization
572
+ */
573
+ async listOrgProjects(orgLogin, limit = 20) {
574
+ const query = `
575
+ query($login: String!, $first: Int!) {
576
+ organization(login: $login) {
577
+ projectsV2(first: $first) {
578
+ nodes {
579
+ id
580
+ number
581
+ title
582
+ url
583
+ }
584
+ }
585
+ }
586
+ }
587
+ `;
588
+ try {
589
+ const result = await this.octokit.graphql(query, { login: orgLogin, first: limit });
590
+ return result.organization.projectsV2.nodes;
591
+ } catch {
592
+ return [];
593
+ }
594
+ }
595
+ /**
596
+ * Create a new project
597
+ */
598
+ async createProject(options) {
599
+ let ownerId;
600
+ if (options.isOrg) {
601
+ const query = `
602
+ query($login: String!) {
603
+ organization(login: $login) {
604
+ id
605
+ }
606
+ }
607
+ `;
608
+ const result2 = await this.octokit.graphql(query, { login: options.ownerLogin });
609
+ ownerId = result2.organization.id;
610
+ } else {
611
+ const query = `
612
+ query($login: String!) {
613
+ user(login: $login) {
614
+ id
615
+ }
616
+ }
617
+ `;
618
+ const result2 = await this.octokit.graphql(query, { login: options.ownerLogin });
619
+ ownerId = result2.user.id;
620
+ }
621
+ const mutation = `
622
+ mutation($ownerId: ID!, $title: String!) {
623
+ createProjectV2(input: { ownerId: $ownerId, title: $title }) {
624
+ projectV2 {
625
+ id
626
+ number
627
+ title
628
+ url
629
+ }
630
+ }
631
+ }
632
+ `;
633
+ const result = await this.octokit.graphql(mutation, { ownerId, title: options.title });
634
+ return result.createProjectV2.projectV2;
635
+ }
636
+ /**
637
+ * Copy an existing project
638
+ */
639
+ async copyProject(options) {
640
+ let sourceProject;
641
+ if (options.sourceIsOrg) {
642
+ sourceProject = await this.getOrgProject(
643
+ options.sourceOwnerLogin,
644
+ options.sourceProjectNumber
645
+ );
646
+ } else {
647
+ sourceProject = await this.getUserProject(
648
+ options.sourceOwnerLogin,
649
+ options.sourceProjectNumber
650
+ );
651
+ }
652
+ if (!sourceProject) {
653
+ throw new Error(
654
+ `Source project #${options.sourceProjectNumber} not found for ${options.sourceOwnerLogin}`
655
+ );
656
+ }
657
+ let targetOwnerId;
658
+ if (options.targetIsOrg) {
659
+ const query = `
660
+ query($login: String!) {
661
+ organization(login: $login) {
662
+ id
663
+ }
664
+ }
665
+ `;
666
+ const result2 = await this.octokit.graphql(query, { login: options.targetOwnerLogin });
667
+ targetOwnerId = result2.organization.id;
668
+ } else {
669
+ const query = `
670
+ query($login: String!) {
671
+ user(login: $login) {
672
+ id
673
+ }
674
+ }
675
+ `;
676
+ const result2 = await this.octokit.graphql(query, { login: options.targetOwnerLogin });
677
+ targetOwnerId = result2.user.id;
678
+ }
679
+ const mutation = `
680
+ mutation($projectId: ID!, $ownerId: ID!, $title: String!, $includeDraftIssues: Boolean) {
681
+ copyProjectV2(input: {
682
+ projectId: $projectId,
683
+ ownerId: $ownerId,
684
+ title: $title,
685
+ includeDraftIssues: $includeDraftIssues
686
+ }) {
687
+ projectV2 {
688
+ id
689
+ number
690
+ title
691
+ url
692
+ }
693
+ }
694
+ }
695
+ `;
696
+ const result = await this.octokit.graphql(mutation, {
697
+ projectId: sourceProject.id,
698
+ ownerId: targetOwnerId,
699
+ title: options.title,
700
+ includeDraftIssues: options.includeDraftIssues ?? false
701
+ });
702
+ return result.copyProjectV2.projectV2;
703
+ }
508
704
  /**
509
705
  * Link a repository to a project
510
706
  * Note: This creates a linked repository in the project