@callumvass/forgeflow-dev 0.4.1 → 0.4.3

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 (2) hide show
  1. package/extensions/index.js +42 -40
  2. package/package.json +1 -1
@@ -422,9 +422,15 @@ var JIRA_BRANCH_RE = /feat\/([A-Z]+-\d+)/;
422
422
  async function ensureBranch(cwd, branch) {
423
423
  const currentBranch = await exec("git branch --show-current", cwd);
424
424
  if (currentBranch === branch) return;
425
- const exists = await exec(`git rev-parse --verify ${branch} 2>/dev/null && echo yes || echo no`, cwd);
426
- if (exists === "yes") {
425
+ const localExists = await exec(`git rev-parse --verify ${branch} 2>/dev/null && echo yes || echo no`, cwd);
426
+ if (localExists === "yes") {
427
427
  await exec(`git checkout ${branch}`, cwd);
428
+ return;
429
+ }
430
+ await exec("git fetch origin", cwd);
431
+ const remoteExists = await exec(`git rev-parse --verify origin/${branch} 2>/dev/null && echo yes || echo no`, cwd);
432
+ if (remoteExists === "yes") {
433
+ await exec(`git checkout -b ${branch} origin/${branch}`, cwd);
428
434
  } else {
429
435
  await exec(`git checkout -b ${branch}`, cwd);
430
436
  }
@@ -749,14 +755,11 @@ ${flags.customPrompt}` : "";
749
755
  };
750
756
  }
751
757
  if (resolved.branch) {
752
- const branchExists = await exec(
753
- `git rev-parse --verify ${resolved.branch} 2>/dev/null && echo yes || echo no`,
754
- cwd
755
- );
756
- if (branchExists === "yes") {
757
- await ensureBranch(cwd, resolved.branch);
758
+ const localExists = await exec(`git rev-parse --verify ${resolved.branch} 2>/dev/null && echo yes || echo no`, cwd);
759
+ if (localExists === "yes") {
758
760
  const ahead = await exec(`git rev-list main..${resolved.branch} --count`, cwd);
759
761
  if (parseInt(ahead, 10) > 0) {
762
+ await ensureBranch(cwd, resolved.branch);
760
763
  await exec(`git push -u origin ${resolved.branch}`, cwd);
761
764
  const prBody = buildPrBody(cwd, resolved);
762
765
  await createPr(cwd, resolved.title, prBody, resolved.branch);
@@ -767,6 +770,37 @@ ${flags.customPrompt}` : "";
767
770
  details: { pipeline: "implement", stages: stages2 }
768
771
  };
769
772
  }
773
+ await exec(`git branch -D ${resolved.branch}`, cwd);
774
+ }
775
+ const currentBranch = await exec("git branch --show-current", cwd);
776
+ if (currentBranch === "main" || currentBranch === "master") {
777
+ const dirty = await exec("git status --porcelain", cwd);
778
+ if (dirty) {
779
+ return {
780
+ content: [
781
+ {
782
+ type: "text",
783
+ text: `Cannot switch to ${resolved.branch} \u2014 working tree is dirty. Please commit or stash your changes first.`
784
+ }
785
+ ],
786
+ details: { pipeline: "implement", stages: [] },
787
+ isError: true
788
+ };
789
+ }
790
+ }
791
+ await ensureBranch(cwd, resolved.branch);
792
+ const afterBranch = await exec("git branch --show-current", cwd);
793
+ if (afterBranch !== resolved.branch) {
794
+ return {
795
+ content: [
796
+ {
797
+ type: "text",
798
+ text: `Failed to switch to ${resolved.branch} (still on ${afterBranch}). Check git state and retry.`
799
+ }
800
+ ],
801
+ details: { pipeline: "implement", stages: [] },
802
+ isError: true
803
+ };
770
804
  }
771
805
  }
772
806
  const stageList = [];
@@ -807,38 +841,6 @@ ${issueContext}${customPromptSection}`,
807
841
  }
808
842
  }
809
843
  }
810
- if (resolved.branch) {
811
- const currentBranch = await exec("git branch --show-current", cwd);
812
- if (currentBranch === "main" || currentBranch === "master") {
813
- const dirty = await exec("git status --porcelain", cwd);
814
- if (dirty) {
815
- return {
816
- content: [
817
- {
818
- type: "text",
819
- text: `Cannot switch to ${resolved.branch} \u2014 working tree is dirty. Please commit or stash your changes first.`
820
- }
821
- ],
822
- details: { pipeline: "implement", stages: [] },
823
- isError: true
824
- };
825
- }
826
- await ensureBranch(cwd, resolved.branch);
827
- const afterBranch = await exec("git branch --show-current", cwd);
828
- if (afterBranch !== resolved.branch) {
829
- return {
830
- content: [
831
- {
832
- type: "text",
833
- text: `Failed to switch to ${resolved.branch} (still on ${afterBranch}). Check git state and retry.`
834
- }
835
- ],
836
- details: { pipeline: "implement", stages: [] },
837
- isError: true
838
- };
839
- }
840
- }
841
- }
842
844
  cleanSignal(cwd, "blocked");
843
845
  const planSection = plan ? `
844
846
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@callumvass/forgeflow-dev",
3
- "version": "0.4.1",
3
+ "version": "0.4.3",
4
4
  "type": "module",
5
5
  "description": "Dev pipeline for Pi — TDD implementation, code review, architecture, and skill discovery.",
6
6
  "keywords": [