s9n-devops-agent 1.5.8 → 1.6.0
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 +1 -1
- package/src/session-coordinator.js +104 -1
- package/start-devops-session.sh +1 -1
package/package.json
CHANGED
|
@@ -1681,8 +1681,103 @@ The DevOps agent is monitoring this worktree for changes.
|
|
|
1681
1681
|
console.log(`${CONFIG.colors.dim}Could not check git status${CONFIG.colors.reset}`);
|
|
1682
1682
|
}
|
|
1683
1683
|
|
|
1684
|
+
// Ask about merging to target branch before cleanup
|
|
1685
|
+
let rl = readline.createInterface({
|
|
1686
|
+
input: process.stdin,
|
|
1687
|
+
output: process.stdout
|
|
1688
|
+
});
|
|
1689
|
+
|
|
1690
|
+
console.log(`\n${CONFIG.colors.yellow}Worktree Cleanup Options${CONFIG.colors.reset}`);
|
|
1691
|
+
|
|
1692
|
+
// Get target branch from merge config or default to 'main'
|
|
1693
|
+
let targetBranch = session.mergeConfig?.targetBranch || 'main';
|
|
1694
|
+
|
|
1695
|
+
const mergeFirst = await new Promise(resolve => {
|
|
1696
|
+
rl.question(`\nMerge ${CONFIG.colors.bright}${session.branchName}${CONFIG.colors.reset} → ${CONFIG.colors.bright}${targetBranch}${CONFIG.colors.reset} before cleanup? (y/N): `, resolve);
|
|
1697
|
+
});
|
|
1698
|
+
rl.close();
|
|
1699
|
+
|
|
1700
|
+
if (mergeFirst.toLowerCase() === 'y') {
|
|
1701
|
+
rl = readline.createInterface({
|
|
1702
|
+
input: process.stdin,
|
|
1703
|
+
output: process.stdout
|
|
1704
|
+
});
|
|
1705
|
+
|
|
1706
|
+
const confirmTarget = await new Promise(resolve => {
|
|
1707
|
+
rl.question(`Target branch [${targetBranch}]: `, resolve);
|
|
1708
|
+
});
|
|
1709
|
+
rl.close();
|
|
1710
|
+
|
|
1711
|
+
if (confirmTarget.trim()) {
|
|
1712
|
+
targetBranch = confirmTarget.trim();
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
try {
|
|
1716
|
+
console.log(`\n${CONFIG.colors.blue}Merging ${session.branchName} into ${targetBranch}...${CONFIG.colors.reset}`);
|
|
1717
|
+
|
|
1718
|
+
// Check if target branch exists locally
|
|
1719
|
+
let branchExists = false;
|
|
1720
|
+
try {
|
|
1721
|
+
execSync(`git rev-parse --verify ${targetBranch}`, { cwd: this.repoRoot, stdio: 'pipe' });
|
|
1722
|
+
branchExists = true;
|
|
1723
|
+
} catch (err) {
|
|
1724
|
+
// Branch doesn't exist locally
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
if (!branchExists) {
|
|
1728
|
+
// Check if branch exists on remote
|
|
1729
|
+
try {
|
|
1730
|
+
execSync(`git ls-remote --heads origin ${targetBranch}`, { cwd: this.repoRoot, stdio: 'pipe' });
|
|
1731
|
+
// Branch exists on remote, fetch it
|
|
1732
|
+
console.log(`${CONFIG.colors.dim}Target branch doesn't exist locally, fetching from remote...${CONFIG.colors.reset}`);
|
|
1733
|
+
execSync(`git fetch origin ${targetBranch}:${targetBranch}`, { cwd: this.repoRoot, stdio: 'pipe' });
|
|
1734
|
+
} catch (err) {
|
|
1735
|
+
// Branch doesn't exist on remote either, create it
|
|
1736
|
+
console.log(`${CONFIG.colors.yellow}Target branch '${targetBranch}' doesn't exist. Creating it...${CONFIG.colors.reset}`);
|
|
1737
|
+
execSync(`git checkout -b ${targetBranch}`, { cwd: this.repoRoot, stdio: 'pipe' });
|
|
1738
|
+
execSync(`git push -u origin ${targetBranch}`, { cwd: this.repoRoot, stdio: 'pipe' });
|
|
1739
|
+
console.log(`${CONFIG.colors.green}✓${CONFIG.colors.reset} Created new branch ${targetBranch}`);
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
|
|
1743
|
+
// Switch to target branch in main repo
|
|
1744
|
+
execSync(`git checkout ${targetBranch}`, { cwd: this.repoRoot, stdio: 'pipe' });
|
|
1745
|
+
|
|
1746
|
+
// Pull latest (if branch already existed)
|
|
1747
|
+
if (branchExists) {
|
|
1748
|
+
try {
|
|
1749
|
+
execSync(`git pull origin ${targetBranch}`, { cwd: this.repoRoot, stdio: 'pipe' });
|
|
1750
|
+
} catch (err) {
|
|
1751
|
+
console.log(`${CONFIG.colors.dim}Could not pull latest changes (may be new branch)${CONFIG.colors.reset}`);
|
|
1752
|
+
}
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
// Merge the session branch
|
|
1756
|
+
execSync(`git merge --no-ff ${session.branchName} -m "Merge session ${sessionId}: ${session.task}"`, {
|
|
1757
|
+
cwd: this.repoRoot,
|
|
1758
|
+
stdio: 'pipe'
|
|
1759
|
+
});
|
|
1760
|
+
|
|
1761
|
+
// Push merged changes
|
|
1762
|
+
execSync(`git push origin ${targetBranch}`, { cwd: this.repoRoot, stdio: 'pipe' });
|
|
1763
|
+
|
|
1764
|
+
console.log(`${CONFIG.colors.green}✓${CONFIG.colors.reset} Successfully merged to ${targetBranch}`);
|
|
1765
|
+
|
|
1766
|
+
// Delete remote branch after successful merge
|
|
1767
|
+
try {
|
|
1768
|
+
execSync(`git push origin --delete ${session.branchName}`, { cwd: this.repoRoot, stdio: 'pipe' });
|
|
1769
|
+
console.log(`${CONFIG.colors.green}✓${CONFIG.colors.reset} Deleted remote branch ${session.branchName}`);
|
|
1770
|
+
} catch (err) {
|
|
1771
|
+
console.log(`${CONFIG.colors.dim}Could not delete remote branch${CONFIG.colors.reset}`);
|
|
1772
|
+
}
|
|
1773
|
+
} catch (err) {
|
|
1774
|
+
console.error(`${CONFIG.colors.red}✗ Merge failed: ${err.message}${CONFIG.colors.reset}`);
|
|
1775
|
+
console.log(`${CONFIG.colors.yellow}You may need to resolve conflicts manually${CONFIG.colors.reset}`);
|
|
1776
|
+
}
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1684
1779
|
// Ask about removing worktree
|
|
1685
|
-
|
|
1780
|
+
rl = readline.createInterface({
|
|
1686
1781
|
input: process.stdin,
|
|
1687
1782
|
output: process.stdout
|
|
1688
1783
|
});
|
|
@@ -1698,6 +1793,14 @@ The DevOps agent is monitoring this worktree for changes.
|
|
|
1698
1793
|
execSync(`git worktree remove "${session.worktreePath}" --force`, { stdio: 'pipe' });
|
|
1699
1794
|
console.log(`${CONFIG.colors.green}✓${CONFIG.colors.reset} Worktree removed`);
|
|
1700
1795
|
|
|
1796
|
+
// Delete local branch
|
|
1797
|
+
try {
|
|
1798
|
+
execSync(`git branch -D ${session.branchName}`, { cwd: this.repoRoot, stdio: 'pipe' });
|
|
1799
|
+
console.log(`${CONFIG.colors.green}✓${CONFIG.colors.reset} Deleted local branch ${session.branchName}`);
|
|
1800
|
+
} catch (err) {
|
|
1801
|
+
console.log(`${CONFIG.colors.dim}Could not delete local branch${CONFIG.colors.reset}`);
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1701
1804
|
// Prune worktree list
|
|
1702
1805
|
execSync('git worktree prune', { stdio: 'pipe' });
|
|
1703
1806
|
} catch (err) {
|
package/start-devops-session.sh
CHANGED
|
@@ -41,7 +41,7 @@ show_copyright() {
|
|
|
41
41
|
echo "======================================================================"
|
|
42
42
|
echo
|
|
43
43
|
echo " CS_DevOpsAgent - Intelligent Git Automation System"
|
|
44
|
-
echo " Version 1.
|
|
44
|
+
echo " Version 1.6.0 | Build 20251009.12"
|
|
45
45
|
echo " "
|
|
46
46
|
echo " Copyright (c) 2024 SecondBrain Labs"
|
|
47
47
|
echo " Author: Sachin Dev Duggal"
|