s9n-devops-agent 1.2.1 → 1.3.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.
- package/README.md +210 -56
- package/docs/INSTALLATION_GUIDE.md +366 -0
- package/docs/houserules.md +51 -0
- package/package.json +5 -1
- package/src/display-utils.cjs +350 -0
- package/src/file-coordinator.cjs +356 -0
- package/src/file-monitor-enhanced.cjs +338 -0
- package/src/house-rules-manager.js +610 -0
- package/src/session-coordinator.js +122 -17
- package/src/setup-cs-devops-agent.js +5 -3
- package/start-devops-session.sh +188 -18
|
@@ -81,6 +81,14 @@ class SessionCoordinator {
|
|
|
81
81
|
|
|
82
82
|
getRepoRoot() {
|
|
83
83
|
try {
|
|
84
|
+
// Check if we're in a submodule
|
|
85
|
+
const superproject = execSync('git rev-parse --show-superproject-working-tree', { encoding: 'utf8' }).trim();
|
|
86
|
+
if (superproject) {
|
|
87
|
+
// We're in a submodule, use the parent repository root
|
|
88
|
+
console.log(`${CONFIG.colors.dim}Running from submodule, using parent repository: ${superproject}${CONFIG.colors.reset}`);
|
|
89
|
+
return superproject;
|
|
90
|
+
}
|
|
91
|
+
// Not in a submodule, use current repository root
|
|
84
92
|
return execSync('git rev-parse --show-toplevel', { encoding: 'utf8' }).trim();
|
|
85
93
|
} catch (error) {
|
|
86
94
|
console.error('Error: Not in a git repository');
|
|
@@ -461,7 +469,13 @@ class SessionCoordinator {
|
|
|
461
469
|
});
|
|
462
470
|
|
|
463
471
|
console.log(`\n${CONFIG.colors.yellow}═══ Auto-merge Configuration ═══${CONFIG.colors.reset}`);
|
|
464
|
-
console.log(`${CONFIG.colors.dim}
|
|
472
|
+
console.log(`${CONFIG.colors.dim}Automatically merge your daily work branches into a target branch.${CONFIG.colors.reset}`);
|
|
473
|
+
console.log();
|
|
474
|
+
console.log(`${CONFIG.colors.bright}How it works:${CONFIG.colors.reset}`);
|
|
475
|
+
console.log(` • The agent creates dated branches (e.g., ${CONFIG.colors.blue}agent_dev_2025-10-01${CONFIG.colors.reset})`);
|
|
476
|
+
console.log(` • At the end of each day, your work is automatically merged`);
|
|
477
|
+
console.log(` • This keeps your target branch (main/develop) up to date`);
|
|
478
|
+
console.log(` • Prevents accumulation of stale feature branches`);
|
|
465
479
|
|
|
466
480
|
// Ask if they want auto-merge
|
|
467
481
|
const autoMerge = await new Promise((resolve) => {
|
|
@@ -705,11 +719,47 @@ class SessionCoordinator {
|
|
|
705
719
|
const branchName = `${agentType}/${devInitials}/${sessionId}/${task.replace(/\s+/g, '-')}`;
|
|
706
720
|
|
|
707
721
|
try {
|
|
722
|
+
// Detect if we're in a submodule and get the parent repository
|
|
723
|
+
let repoRoot = process.cwd();
|
|
724
|
+
let isSubmodule = false;
|
|
725
|
+
let parentRemote = null;
|
|
726
|
+
|
|
727
|
+
try {
|
|
728
|
+
// Check if we're in a submodule
|
|
729
|
+
execSync('git rev-parse --show-superproject-working-tree', { stdio: 'pipe' });
|
|
730
|
+
const superproject = execSync('git rev-parse --show-superproject-working-tree', { encoding: 'utf8' }).trim();
|
|
731
|
+
|
|
732
|
+
if (superproject) {
|
|
733
|
+
isSubmodule = true;
|
|
734
|
+
// Get the parent repository's remote
|
|
735
|
+
parentRemote = execSync(`git -C "${superproject}" remote get-url origin`, { encoding: 'utf8' }).trim();
|
|
736
|
+
console.log(`\n${CONFIG.colors.yellow}Detected submodule - will configure worktree for parent repository${CONFIG.colors.reset}`);
|
|
737
|
+
console.log(`${CONFIG.colors.dim}Parent repository: ${superproject}${CONFIG.colors.reset}`);
|
|
738
|
+
console.log(`${CONFIG.colors.dim}Parent remote: ${parentRemote}${CONFIG.colors.reset}`);
|
|
739
|
+
}
|
|
740
|
+
} catch (e) {
|
|
741
|
+
// Not a submodule, continue normally
|
|
742
|
+
}
|
|
743
|
+
|
|
708
744
|
// Create worktree
|
|
709
745
|
console.log(`\n${CONFIG.colors.yellow}Creating worktree...${CONFIG.colors.reset}`);
|
|
710
746
|
execSync(`git worktree add -b ${branchName} "${worktreePath}" HEAD`, { stdio: 'pipe' });
|
|
711
747
|
console.log(`${CONFIG.colors.green}✓${CONFIG.colors.reset} Worktree created at: ${worktreePath}`);
|
|
712
748
|
|
|
749
|
+
// If we're in a submodule, set up the correct remote for the worktree
|
|
750
|
+
if (isSubmodule && parentRemote) {
|
|
751
|
+
console.log(`${CONFIG.colors.yellow}Configuring worktree to use parent repository remote...${CONFIG.colors.reset}`);
|
|
752
|
+
// Remove the default origin that points to the submodule
|
|
753
|
+
try {
|
|
754
|
+
execSync(`git -C "${worktreePath}" remote remove origin`, { stdio: 'pipe' });
|
|
755
|
+
} catch (e) {
|
|
756
|
+
// Origin might not exist, continue
|
|
757
|
+
}
|
|
758
|
+
// Add the parent repository as origin
|
|
759
|
+
execSync(`git -C "${worktreePath}" remote add origin ${parentRemote}`, { stdio: 'pipe' });
|
|
760
|
+
console.log(`${CONFIG.colors.green}✓${CONFIG.colors.reset} Worktree configured to push to parent repository`);
|
|
761
|
+
}
|
|
762
|
+
|
|
713
763
|
// Create session lock
|
|
714
764
|
const lockData = {
|
|
715
765
|
sessionId,
|
|
@@ -747,7 +797,7 @@ class SessionCoordinator {
|
|
|
747
797
|
branchName,
|
|
748
798
|
lockFile,
|
|
749
799
|
instructionsFile,
|
|
750
|
-
|
|
800
|
+
task
|
|
751
801
|
};
|
|
752
802
|
|
|
753
803
|
} catch (error) {
|
|
@@ -757,7 +807,7 @@ class SessionCoordinator {
|
|
|
757
807
|
}
|
|
758
808
|
|
|
759
809
|
/**
|
|
760
|
-
* Generate instructions for
|
|
810
|
+
* Generate instructions for the coding agent
|
|
761
811
|
*/
|
|
762
812
|
generateClaudeInstructions(sessionData) {
|
|
763
813
|
const { sessionId, worktreePath, branchName, task } = sessionData;
|
|
@@ -784,7 +834,29 @@ INSTRUCTIONS:
|
|
|
784
834
|
- **Worktree Path:** \`${worktreePath}\`
|
|
785
835
|
- **Branch:** \`${branchName}\`
|
|
786
836
|
|
|
787
|
-
##
|
|
837
|
+
## 🚨 CRITICAL: File Coordination Protocol
|
|
838
|
+
|
|
839
|
+
**BEFORE editing any files, you MUST:**
|
|
840
|
+
|
|
841
|
+
1. **Declare your intent** by creating:
|
|
842
|
+
\`\`\`json
|
|
843
|
+
// File: .file-coordination/active-edits/<agent>-${sessionId}.json
|
|
844
|
+
{
|
|
845
|
+
"agent": "<your-name>",
|
|
846
|
+
"session": "${sessionId}",
|
|
847
|
+
"files": ["list", "files", "to", "edit"],
|
|
848
|
+
"operation": "edit",
|
|
849
|
+
"reason": "${task}",
|
|
850
|
+
"declaredAt": "<ISO-8601-timestamp>",
|
|
851
|
+
"estimatedDuration": 300
|
|
852
|
+
}
|
|
853
|
+
\`\`\`
|
|
854
|
+
|
|
855
|
+
2. **Check for conflicts** - read all files in \`.file-coordination/active-edits/\`
|
|
856
|
+
3. **Only proceed if no conflicts** - wait or choose different files if blocked
|
|
857
|
+
4. **Release files when done** - delete your declaration after edits
|
|
858
|
+
|
|
859
|
+
## Instructions for Your Coding Agent
|
|
788
860
|
|
|
789
861
|
### Step 1: Navigate to Your Worktree
|
|
790
862
|
\`\`\`bash
|
|
@@ -797,18 +869,25 @@ git branch --show-current
|
|
|
797
869
|
# Should output: ${branchName}
|
|
798
870
|
\`\`\`
|
|
799
871
|
|
|
800
|
-
### Step 3:
|
|
872
|
+
### Step 3: Declare Files Before Editing
|
|
873
|
+
Create your declaration in \`.file-coordination/active-edits/\`
|
|
874
|
+
|
|
875
|
+
### Step 4: Work on Your Task
|
|
801
876
|
Make changes for: **${task}**
|
|
802
877
|
|
|
803
|
-
### Step
|
|
878
|
+
### Step 5: Commit Your Changes
|
|
804
879
|
Write your commit message to the session-specific file:
|
|
805
880
|
\`\`\`bash
|
|
806
881
|
echo "feat: your commit message here" > .devops-commit-${sessionId}.msg
|
|
807
882
|
\`\`\`
|
|
808
883
|
|
|
809
|
-
### Step
|
|
884
|
+
### Step 6: Release Your File Locks
|
|
885
|
+
Delete your declaration from \`.file-coordination/active-edits/\`
|
|
886
|
+
|
|
887
|
+
### Step 7: Automatic Processing
|
|
810
888
|
The DevOps agent will automatically:
|
|
811
889
|
- Detect your changes
|
|
890
|
+
- Check for coordination conflicts
|
|
812
891
|
- Read your commit message
|
|
813
892
|
- Commit and push to the remote repository
|
|
814
893
|
- Clear the message file
|
|
@@ -839,11 +918,11 @@ The DevOps agent will automatically:
|
|
|
839
918
|
* Display instructions in a user-friendly format
|
|
840
919
|
*/
|
|
841
920
|
displayInstructions(instructions, sessionId, task) {
|
|
842
|
-
console.log(`\n${CONFIG.colors.bgGreen}${CONFIG.colors.bright} Instructions for
|
|
921
|
+
console.log(`\n${CONFIG.colors.bgGreen}${CONFIG.colors.bright} Instructions for Your Coding Agent ${CONFIG.colors.reset}\n`);
|
|
843
922
|
|
|
844
923
|
// Clean separator
|
|
845
924
|
console.log(`${CONFIG.colors.yellow}══════════════════════════════════════════════════════════════${CONFIG.colors.reset}`);
|
|
846
|
-
console.log(`${CONFIG.colors.bright}COPY AND PASTE THIS ENTIRE BLOCK INTO
|
|
925
|
+
console.log(`${CONFIG.colors.bright}COPY AND PASTE THIS ENTIRE BLOCK INTO YOUR CODING AGENT BEFORE YOUR PROMPT:${CONFIG.colors.reset}`);
|
|
847
926
|
console.log(`${CONFIG.colors.yellow}──────────────────────────────────────────────────────────────${CONFIG.colors.reset}`);
|
|
848
927
|
console.log();
|
|
849
928
|
|
|
@@ -853,17 +932,33 @@ The DevOps agent will automatically:
|
|
|
853
932
|
console.log(`- Working Directory: ${instructions.worktreePath}`);
|
|
854
933
|
console.log(`- Task: ${task || 'development'}`);
|
|
855
934
|
console.log(``);
|
|
856
|
-
console.log(
|
|
857
|
-
console.log(
|
|
935
|
+
console.log(`⚠️ IMPORTANT: DO NOT start working yet! Wait for the user's specific instructions.`);
|
|
936
|
+
console.log(``);
|
|
937
|
+
console.log(`CRITICAL FIRST STEP:`);
|
|
938
|
+
console.log(`1. Read and follow the house rules: cat "${instructions.worktreePath}/houserules.md"`);
|
|
939
|
+
console.log(`2. Switch to the working directory: cd "${instructions.worktreePath}"`);
|
|
940
|
+
console.log(``);
|
|
941
|
+
console.log(`FILE COORDINATION PROTOCOL (from house rules at ${instructions.worktreePath}/houserules.md):`);
|
|
942
|
+
console.log(`Before editing ANY files, you MUST:`);
|
|
943
|
+
console.log(`- Declare your intent in .file-coordination/active-edits/<agent>-${sessionId}.json`);
|
|
944
|
+
console.log(`- Check for conflicts with other agents`);
|
|
945
|
+
console.log(`- Only edit files you've declared`);
|
|
946
|
+
console.log(`- Release files when done`);
|
|
858
947
|
console.log(``);
|
|
859
948
|
console.log(`Write commit messages to: .devops-commit-${sessionId}.msg`);
|
|
860
949
|
console.log(`The DevOps agent will automatically commit and push changes.`);
|
|
950
|
+
console.log(``);
|
|
951
|
+
console.log(`Remember: ALWAYS check house rules first, then WAIT for user instructions!`);
|
|
861
952
|
console.log();
|
|
862
953
|
|
|
863
954
|
console.log(`${CONFIG.colors.yellow}══════════════════════════════════════════════════════════════${CONFIG.colors.reset}`);
|
|
955
|
+
console.log();
|
|
956
|
+
|
|
957
|
+
// Pause before continuing
|
|
958
|
+
console.log(`${CONFIG.colors.dim}Press Enter to start the DevOps agent monitoring...${CONFIG.colors.reset}`);
|
|
864
959
|
|
|
865
960
|
// Status info
|
|
866
|
-
console.log(
|
|
961
|
+
console.log(`${CONFIG.colors.green}✓ DevOps agent is starting...${CONFIG.colors.reset}`);
|
|
867
962
|
console.log(`${CONFIG.colors.dim}Full instructions saved to: ${CONFIG.instructionsDir}/${sessionId}.md${CONFIG.colors.reset}`);
|
|
868
963
|
}
|
|
869
964
|
|
|
@@ -1025,11 +1120,11 @@ The DevOps agent is monitoring this worktree for changes.
|
|
|
1025
1120
|
fs.writeFileSync(lockFile, JSON.stringify(session, null, 2));
|
|
1026
1121
|
|
|
1027
1122
|
const instructions = this.generateClaudeInstructions(session);
|
|
1028
|
-
|
|
1123
|
+
// Don't display instructions here - they'll be shown after agent starts
|
|
1029
1124
|
|
|
1030
1125
|
return {
|
|
1031
1126
|
...session,
|
|
1032
|
-
instructions: instructions
|
|
1127
|
+
instructions: instructions
|
|
1033
1128
|
};
|
|
1034
1129
|
}
|
|
1035
1130
|
|
|
@@ -1178,11 +1273,21 @@ The DevOps agent is monitoring this worktree for changes.
|
|
|
1178
1273
|
|
|
1179
1274
|
console.log(`\n${CONFIG.colors.yellow}Starting agent for session ${session.sessionId}...${CONFIG.colors.reset}`);
|
|
1180
1275
|
|
|
1181
|
-
//
|
|
1182
|
-
await new Promise(resolve => setTimeout(resolve, 2000));
|
|
1183
|
-
|
|
1276
|
+
// Start the agent first
|
|
1184
1277
|
await this.startAgent(session.sessionId);
|
|
1185
1278
|
|
|
1279
|
+
// Wait for agent to initialize and show its interactive commands
|
|
1280
|
+
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
1281
|
+
|
|
1282
|
+
// Now display the instructions AFTER the agent is running
|
|
1283
|
+
console.log('\n'.repeat(2)); // Add some spacing
|
|
1284
|
+
// Create instructions object with worktreePath for display
|
|
1285
|
+
const instructionsForDisplay = {
|
|
1286
|
+
worktreePath: session.worktreePath,
|
|
1287
|
+
sessionId: session.sessionId
|
|
1288
|
+
};
|
|
1289
|
+
this.displayInstructions(instructionsForDisplay, session.sessionId, options.task || 'development');
|
|
1290
|
+
|
|
1186
1291
|
return session;
|
|
1187
1292
|
}
|
|
1188
1293
|
|
|
@@ -735,7 +735,8 @@ export AC_MSG_MIN_BYTES="20"
|
|
|
735
735
|
export AC_DEBOUNCE_MS="1500"
|
|
736
736
|
export AC_MSG_DEBOUNCE_MS="3000"
|
|
737
737
|
export AC_CLEAR_MSG_WHEN="push"
|
|
738
|
-
|
|
738
|
+
# Daily rollover is automatic - no prompting needed
|
|
739
|
+
export AC_ROLLOVER_PROMPT="false"
|
|
739
740
|
export AC_DEBUG="false"
|
|
740
741
|
|
|
741
742
|
# Check for debug flag
|
|
@@ -784,7 +785,8 @@ AC_MSG_DEBOUNCE_MS=3000
|
|
|
784
785
|
|
|
785
786
|
# Behavior
|
|
786
787
|
AC_CLEAR_MSG_WHEN=push
|
|
787
|
-
|
|
788
|
+
# Daily rollover is automatic
|
|
789
|
+
AC_ROLLOVER_PROMPT=false
|
|
788
790
|
AC_DEBUG=false
|
|
789
791
|
`;
|
|
790
792
|
|
|
@@ -826,7 +828,7 @@ function printInstructions(initials) {
|
|
|
826
828
|
log.title('🎯 Daily Workflow:');
|
|
827
829
|
console.log('');
|
|
828
830
|
console.log(`• Your daily branches will be: ${colors.bright}dev_${initials}_YYYY-MM-DD${colors.reset}`);
|
|
829
|
-
console.log('• The worker
|
|
831
|
+
console.log('• The worker automatically creates new daily branches at midnight');
|
|
830
832
|
console.log('• Commits require valid conventional format (feat/fix/docs/etc)');
|
|
831
833
|
console.log('• Message file is cleared after successful push');
|
|
832
834
|
console.log('');
|
package/start-devops-session.sh
CHANGED
|
@@ -12,21 +12,27 @@
|
|
|
12
12
|
#
|
|
13
13
|
# ============================================================================
|
|
14
14
|
|
|
15
|
-
# Colors for output
|
|
16
|
-
RED
|
|
17
|
-
GREEN
|
|
18
|
-
YELLOW
|
|
19
|
-
BLUE
|
|
20
|
-
MAGENTA
|
|
21
|
-
BOLD
|
|
22
|
-
DIM
|
|
23
|
-
NC
|
|
24
|
-
BG_BLUE
|
|
25
|
-
BG_GREEN
|
|
26
|
-
BG_YELLOW
|
|
15
|
+
# Colors for output (using printf for better compatibility)
|
|
16
|
+
RED=$'\033[0;31m'
|
|
17
|
+
GREEN=$'\033[0;32m'
|
|
18
|
+
YELLOW=$'\033[1;33m'
|
|
19
|
+
BLUE=$'\033[0;36m'
|
|
20
|
+
MAGENTA=$'\033[0;35m'
|
|
21
|
+
BOLD=$'\033[1m'
|
|
22
|
+
DIM=$'\033[2m'
|
|
23
|
+
NC=$'\033[0m' # No Color
|
|
24
|
+
BG_BLUE=$'\033[44m'
|
|
25
|
+
BG_GREEN=$'\033[42m'
|
|
26
|
+
BG_YELLOW=$'\033[43m'
|
|
27
27
|
|
|
28
|
-
# Get the directory where this script is located
|
|
29
|
-
|
|
28
|
+
# Get the directory where this script is located (compatible with both bash and zsh)
|
|
29
|
+
if [[ -n "${BASH_SOURCE[0]}" ]]; then
|
|
30
|
+
# Running in bash
|
|
31
|
+
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
32
|
+
else
|
|
33
|
+
# Running in zsh
|
|
34
|
+
SCRIPT_DIR="${0:A:h}"
|
|
35
|
+
fi
|
|
30
36
|
SRC_DIR="$SCRIPT_DIR/src"
|
|
31
37
|
|
|
32
38
|
# Function to display copyright
|
|
@@ -64,10 +70,10 @@ display_instructions() {
|
|
|
64
70
|
local task="$4"
|
|
65
71
|
|
|
66
72
|
echo
|
|
67
|
-
echo -e "${BG_GREEN}${BOLD} Instructions for
|
|
73
|
+
echo -e "${BG_GREEN}${BOLD} Instructions for Your Coding Agent ${NC}"
|
|
68
74
|
echo
|
|
69
75
|
echo -e "${YELLOW}══════════════════════════════════════════════════════════════${NC}"
|
|
70
|
-
echo -e "${BOLD}COPY AND PASTE THIS ENTIRE BLOCK INTO
|
|
76
|
+
echo -e "${BOLD}COPY AND PASTE THIS ENTIRE BLOCK INTO YOUR CODING AGENT BEFORE YOUR PROMPT:${NC}"
|
|
71
77
|
echo -e "${YELLOW}──────────────────────────────────────────────────────────────${NC}"
|
|
72
78
|
echo
|
|
73
79
|
echo "I'm working in a DevOps-managed session with the following setup:"
|
|
@@ -215,7 +221,7 @@ select_session() {
|
|
|
215
221
|
echo
|
|
216
222
|
echo -e "${GREEN}Using existing session: ${session_id}${NC}"
|
|
217
223
|
|
|
218
|
-
# Display instructions for
|
|
224
|
+
# Display instructions for coding agent IMMEDIATELY after selection
|
|
219
225
|
display_instructions "$session_id" "$worktree_path" "$branch_name" "$task"
|
|
220
226
|
|
|
221
227
|
# Add a pause and visual separator before starting the agent
|
|
@@ -237,6 +243,167 @@ select_session() {
|
|
|
237
243
|
fi
|
|
238
244
|
}
|
|
239
245
|
|
|
246
|
+
# Function to setup house rules and file coordination
|
|
247
|
+
setup_house_rules() {
|
|
248
|
+
local ROOT="$1"
|
|
249
|
+
local COORD_DIR="$ROOT/.file-coordination"
|
|
250
|
+
|
|
251
|
+
# Check if we need to update existing house rules (even if coordination is set up)
|
|
252
|
+
if [[ -f "$SCRIPT_DIR/src/house-rules-manager.js" ]]; then
|
|
253
|
+
# Check status of house rules
|
|
254
|
+
local STATUS=$(node "$SCRIPT_DIR/src/house-rules-manager.js" status 2>/dev/null || echo '{"needsUpdate": false, "exists": true}')
|
|
255
|
+
local NEEDS_UPDATE=$(echo "$STATUS" | grep -o '"needsUpdate"[[:space:]]*:[[:space:]]*true' || echo "")
|
|
256
|
+
local EXISTS=$(echo "$STATUS" | grep -o '"exists"[[:space:]]*:[[:space:]]*true' || echo "")
|
|
257
|
+
|
|
258
|
+
# Check if house rules were deleted (coordination exists but house rules don't)
|
|
259
|
+
if [[ -d "$COORD_DIR" ]] && [[ -z "$EXISTS" ]]; then
|
|
260
|
+
echo -e "${YELLOW}⚠ House rules file appears to be missing!${NC}"
|
|
261
|
+
echo "The file coordination system is set up, but house rules are gone."
|
|
262
|
+
echo
|
|
263
|
+
echo -n "Recreate house rules? (Y/n): "
|
|
264
|
+
read RECREATE
|
|
265
|
+
if [[ "${RECREATE}" != "n" ]] && [[ "${RECREATE}" != "N" ]]; then
|
|
266
|
+
echo -e "${BLUE}Recreating house rules...${NC}"
|
|
267
|
+
node "$SCRIPT_DIR/src/house-rules-manager.js" update 2>/dev/null
|
|
268
|
+
echo -e "${GREEN}✓ House rules recreated!${NC}"
|
|
269
|
+
echo
|
|
270
|
+
fi
|
|
271
|
+
elif [[ -n "$NEEDS_UPDATE" ]]; then
|
|
272
|
+
echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
273
|
+
echo -e "${BOLD}House Rules Update Available${NC}"
|
|
274
|
+
echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
275
|
+
echo
|
|
276
|
+
echo "The DevOps Agent has updated house rules sections."
|
|
277
|
+
echo "Your custom rules will be preserved."
|
|
278
|
+
echo
|
|
279
|
+
echo -n "Update house rules now? (Y/n): "
|
|
280
|
+
read UPDATE_CHOICE
|
|
281
|
+
|
|
282
|
+
if [[ "${UPDATE_CHOICE}" != "n" ]] && [[ "${UPDATE_CHOICE}" != "N" ]]; then
|
|
283
|
+
echo -e "${BLUE}Updating house rules...${NC}"
|
|
284
|
+
node "$SCRIPT_DIR/src/house-rules-manager.js" update
|
|
285
|
+
echo -e "${GREEN}✓ House rules updated!${NC}"
|
|
286
|
+
echo
|
|
287
|
+
fi
|
|
288
|
+
fi
|
|
289
|
+
fi
|
|
290
|
+
|
|
291
|
+
# Check if coordination system is already set up
|
|
292
|
+
if [[ -d "$COORD_DIR" ]] && [[ -f "$ROOT/check-file-availability.sh" ]]; then
|
|
293
|
+
return 0 # Already set up
|
|
294
|
+
fi
|
|
295
|
+
|
|
296
|
+
echo -e "${YELLOW}═══════════════════════════════════════════════════════════${NC}"
|
|
297
|
+
echo -e "${BOLD}First-time Setup: House Rules & File Coordination${NC}"
|
|
298
|
+
echo -e "${YELLOW}═══════════════════════════════════════════════════════════${NC}"
|
|
299
|
+
echo
|
|
300
|
+
echo "House rules help AI agents understand your project conventions and"
|
|
301
|
+
echo "prevent conflicts when multiple agents work on the same codebase."
|
|
302
|
+
echo
|
|
303
|
+
|
|
304
|
+
# Check for existing house rules
|
|
305
|
+
local HOUSERULES_PATH=""
|
|
306
|
+
local HOUSERULES_FOUND=false
|
|
307
|
+
|
|
308
|
+
# Function to search for house rules file
|
|
309
|
+
find_house_rules() {
|
|
310
|
+
local search_dir="$1"
|
|
311
|
+
local depth="${2:-0}"
|
|
312
|
+
|
|
313
|
+
# Limit search depth
|
|
314
|
+
if [[ $depth -gt 5 ]]; then
|
|
315
|
+
return 1
|
|
316
|
+
fi
|
|
317
|
+
|
|
318
|
+
# First check standard locations
|
|
319
|
+
for possible_path in "houserules.md" "HOUSERULES.md" ".github/HOUSERULES.md" "docs/houserules.md" "docs/HOUSERULES.md"; do
|
|
320
|
+
if [[ -f "$search_dir/$possible_path" ]]; then
|
|
321
|
+
echo "$search_dir/$possible_path"
|
|
322
|
+
return 0
|
|
323
|
+
fi
|
|
324
|
+
done
|
|
325
|
+
|
|
326
|
+
# If not found, search recursively (excluding DevOps directories)
|
|
327
|
+
while IFS= read -r -d '' file; do
|
|
328
|
+
local rel_path="${file#$search_dir/}"
|
|
329
|
+
if [[ ! "$file" =~ "DevOpsAgent" ]] &&
|
|
330
|
+
[[ ! "$file" =~ "CS_DevOpsAgent" ]] &&
|
|
331
|
+
[[ ! "$file" =~ "node_modules" ]] &&
|
|
332
|
+
[[ ! "$file" =~ ".git" ]]; then
|
|
333
|
+
echo "$file"
|
|
334
|
+
return 0
|
|
335
|
+
fi
|
|
336
|
+
done < <(find "$search_dir" -maxdepth 3 -type f \( -iname "houserules.md" -o -iname "HOUSERULES.md" \) -print0 2>/dev/null)
|
|
337
|
+
|
|
338
|
+
return 1
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
# Search for house rules file
|
|
342
|
+
if FOUND_PATH=$(find_house_rules "$ROOT"); then
|
|
343
|
+
HOUSERULES_PATH="$FOUND_PATH"
|
|
344
|
+
HOUSERULES_FOUND=true
|
|
345
|
+
# Make path relative for display
|
|
346
|
+
local REL_PATH="${FOUND_PATH#$ROOT/}"
|
|
347
|
+
echo -e "${GREEN}✓${NC} Found existing house rules at: $REL_PATH"
|
|
348
|
+
else
|
|
349
|
+
echo "No existing house rules found."
|
|
350
|
+
echo
|
|
351
|
+
echo "Would you like to:"
|
|
352
|
+
echo " ${BOLD}1)${NC} Create comprehensive house rules (recommended)"
|
|
353
|
+
echo " ${BOLD}2)${NC} Specify path to existing house rules"
|
|
354
|
+
echo " ${BOLD}3)${NC} Skip for now"
|
|
355
|
+
echo
|
|
356
|
+
echo -n "Your choice [1]: "
|
|
357
|
+
read CHOICE
|
|
358
|
+
|
|
359
|
+
case "${CHOICE:-1}" in
|
|
360
|
+
1)
|
|
361
|
+
HOUSERULES_PATH="$ROOT/houserules.md"
|
|
362
|
+
HOUSERULES_FOUND=false
|
|
363
|
+
echo -e "${GREEN}✓${NC} Will create comprehensive house rules at: houserules.md"
|
|
364
|
+
;;
|
|
365
|
+
2)
|
|
366
|
+
echo -n "Enter path to your house rules (relative to $ROOT): "
|
|
367
|
+
read CUSTOM_PATH
|
|
368
|
+
if [[ -f "$ROOT/$CUSTOM_PATH" ]]; then
|
|
369
|
+
HOUSERULES_PATH="$ROOT/$CUSTOM_PATH"
|
|
370
|
+
HOUSERULES_FOUND=true
|
|
371
|
+
echo -e "${GREEN}✓${NC} Using house rules at: $CUSTOM_PATH"
|
|
372
|
+
else
|
|
373
|
+
echo -e "${YELLOW}File not found. Creating new house rules at: houserules.md${NC}"
|
|
374
|
+
HOUSERULES_PATH="$ROOT/houserules.md"
|
|
375
|
+
HOUSERULES_FOUND=false
|
|
376
|
+
fi
|
|
377
|
+
;;
|
|
378
|
+
3)
|
|
379
|
+
echo -e "${YELLOW}⚠ Skipping house rules setup${NC}"
|
|
380
|
+
echo "You can set them up later by running: ./scripts/setup-file-coordination.sh"
|
|
381
|
+
return 0
|
|
382
|
+
;;
|
|
383
|
+
esac
|
|
384
|
+
fi
|
|
385
|
+
|
|
386
|
+
echo
|
|
387
|
+
echo -e "${BLUE}Setting up file coordination system...${NC}"
|
|
388
|
+
|
|
389
|
+
# Run the actual setup inline (simplified version)
|
|
390
|
+
if [[ -f "$SCRIPT_DIR/scripts/setup-file-coordination.sh" ]]; then
|
|
391
|
+
# Pass the house rules path we already found!
|
|
392
|
+
HOUSERULES_PATH="$HOUSERULES_PATH" bash "$SCRIPT_DIR/scripts/setup-file-coordination.sh"
|
|
393
|
+
else
|
|
394
|
+
# Inline setup if script doesn't exist
|
|
395
|
+
mkdir -p "$COORD_DIR/active-edits" "$COORD_DIR/completed-edits"
|
|
396
|
+
echo -e "${GREEN}✓${NC} File coordination directories created"
|
|
397
|
+
fi
|
|
398
|
+
|
|
399
|
+
echo
|
|
400
|
+
echo -e "${GREEN}✓ Setup complete!${NC} AI agents will now follow house rules and coordinate file edits."
|
|
401
|
+
echo
|
|
402
|
+
echo -e "${DIM}Press Enter to continue...${NC}"
|
|
403
|
+
read -r
|
|
404
|
+
echo
|
|
405
|
+
}
|
|
406
|
+
|
|
240
407
|
# Main function
|
|
241
408
|
main() {
|
|
242
409
|
# Show copyright first
|
|
@@ -256,11 +423,14 @@ main() {
|
|
|
256
423
|
REPO_ROOT=$(git rev-parse --show-toplevel)
|
|
257
424
|
cd "$REPO_ROOT"
|
|
258
425
|
|
|
426
|
+
# Check and setup house rules on first run
|
|
427
|
+
setup_house_rules "$REPO_ROOT"
|
|
428
|
+
|
|
259
429
|
echo -e "${BOLD}Welcome to DevOps Agent Session Manager${NC}"
|
|
260
430
|
echo
|
|
261
431
|
echo "This tool will:"
|
|
262
432
|
echo " 1. Help you create or select a session"
|
|
263
|
-
echo " 2. Generate instructions for
|
|
433
|
+
echo " 2. Generate instructions for your coding agent"
|
|
264
434
|
echo " 3. Start the DevOps agent to monitor changes"
|
|
265
435
|
echo
|
|
266
436
|
|