@jojonax/codex-copilot 1.4.0 → 1.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jojonax/codex-copilot",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "PRD-driven automated development orchestrator for CodeX / Cursor",
5
5
  "bin": {
6
6
  "codex-copilot": "./bin/cli.js"
@@ -95,7 +95,8 @@ export async function run(projectDir) {
95
95
 
96
96
  // ===== Auto-retry blocked tasks =====
97
97
  // On each run, reset blocked tasks to pending so they're retried in order.
98
- // Checkpoint is NOT cleared it stays at the last position for non-blocked tasks.
98
+ // Branches and checkpoint steps are PRESERVED the task resumes from where
99
+ // it left off, keeping all previously developed code.
99
100
  const blockedTasks = tasks.tasks.filter(t => t.status === 'blocked');
100
101
  if (blockedTasks.length > 0) {
101
102
  log.blank();
package/src/utils/git.js CHANGED
@@ -52,24 +52,41 @@ export function getRepoInfo(cwd) {
52
52
  return { owner: match[1], repo: match[2] };
53
53
  }
54
54
 
55
- /**
56
- * Switch to target branch (create if not exists)
57
- */
58
55
  export function checkoutBranch(cwd, branch, baseBranch = 'main') {
59
56
  validateBranch(branch);
60
57
  validateBranch(baseBranch);
61
58
  const current = currentBranch(cwd);
62
59
  if (current === branch) return;
63
60
 
64
- // Switch to base and pull latest
65
- execSafe(`git checkout ${baseBranch}`, cwd);
66
- execSafe(`git pull origin ${baseBranch}`, cwd);
61
+ // Stash any uncommitted changes to allow safe branch switching
62
+ const hasChanges = !isClean(cwd);
63
+ if (hasChanges) {
64
+ execSafe('git stash --include-untracked', cwd);
65
+ }
67
66
 
68
- // Try to switch, create if not exists
69
- const result = execSafe(`git checkout ${branch}`, cwd);
70
- if (!result.ok) {
67
+ // Check if the branch already exists locally
68
+ const branchExists = execSafe(`git rev-parse --verify ${branch}`, cwd).ok;
69
+
70
+ if (branchExists) {
71
+ // Branch exists — just switch to it (preserving all previous work)
72
+ exec(`git checkout ${branch}`, cwd);
73
+
74
+ // Try to rebase onto latest base to pick up any new changes
75
+ execSafe(`git fetch origin ${baseBranch}`, cwd);
76
+ execSafe(`git rebase origin/${baseBranch}`, cwd);
77
+ // If rebase fails (conflicts), abort and continue with existing state
78
+ execSafe('git rebase --abort', cwd);
79
+ } else {
80
+ // Branch doesn't exist — create from latest base
81
+ execSafe(`git checkout ${baseBranch}`, cwd);
82
+ execSafe(`git pull origin ${baseBranch}`, cwd);
71
83
  exec(`git checkout -b ${branch}`, cwd);
72
84
  }
85
+
86
+ // Restore stashed changes if we stashed earlier
87
+ if (hasChanges) {
88
+ execSafe('git stash pop', cwd);
89
+ }
73
90
  }
74
91
 
75
92
  /**