s9n-devops-agent 1.2.1 → 1.3.1

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.
@@ -237,6 +237,142 @@ select_session() {
237
237
  fi
238
238
  }
239
239
 
240
+ # Function to setup house rules and file coordination
241
+ setup_house_rules() {
242
+ local ROOT="$1"
243
+ local COORD_DIR="$ROOT/.file-coordination"
244
+
245
+ # Check if we need to update existing house rules (even if coordination is set up)
246
+ if [[ -f "$SCRIPT_DIR/src/house-rules-manager.js" ]]; then
247
+ # Check status of house rules
248
+ local STATUS=$(node "$SCRIPT_DIR/src/house-rules-manager.js" status 2>/dev/null || echo '{"needsUpdate": false, "exists": true}')
249
+ local NEEDS_UPDATE=$(echo "$STATUS" | grep -o '"needsUpdate"[[:space:]]*:[[:space:]]*true' || echo "")
250
+ local EXISTS=$(echo "$STATUS" | grep -o '"exists"[[:space:]]*:[[:space:]]*true' || echo "")
251
+
252
+ # Check if house rules were deleted (coordination exists but house rules don't)
253
+ if [[ -d "$COORD_DIR" ]] && [[ -z "$EXISTS" ]]; then
254
+ echo -e "${YELLOW}⚠ House rules file appears to be missing!${NC}"
255
+ echo "The file coordination system is set up, but house rules are gone."
256
+ echo
257
+ echo -n "Recreate house rules? (Y/n): "
258
+ read RECREATE
259
+ if [[ "${RECREATE}" != "n" ]] && [[ "${RECREATE}" != "N" ]]; then
260
+ echo -e "${BLUE}Recreating house rules...${NC}"
261
+ node "$SCRIPT_DIR/src/house-rules-manager.js" update 2>/dev/null
262
+ echo -e "${GREEN}✓ House rules recreated!${NC}"
263
+ echo
264
+ fi
265
+ elif [[ -n "$NEEDS_UPDATE" ]]; then
266
+ echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
267
+ echo -e "${BOLD}House Rules Update Available${NC}"
268
+ echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
269
+ echo
270
+ echo "The DevOps Agent has updated house rules sections."
271
+ echo "Your custom rules will be preserved."
272
+ echo
273
+ echo -n "Update house rules now? (Y/n): "
274
+ read UPDATE_CHOICE
275
+
276
+ if [[ "${UPDATE_CHOICE}" != "n" ]] && [[ "${UPDATE_CHOICE}" != "N" ]]; then
277
+ echo -e "${BLUE}Updating house rules...${NC}"
278
+ node "$SCRIPT_DIR/src/house-rules-manager.js" update
279
+ echo -e "${GREEN}✓ House rules updated!${NC}"
280
+ echo
281
+ fi
282
+ fi
283
+ fi
284
+
285
+ # Check if coordination system is already set up
286
+ if [[ -d "$COORD_DIR" ]] && [[ -f "$ROOT/check-file-availability.sh" ]]; then
287
+ return 0 # Already set up
288
+ fi
289
+
290
+ echo -e "${YELLOW}═══════════════════════════════════════════════════════════${NC}"
291
+ echo -e "${BOLD}First-time Setup: House Rules & File Coordination${NC}"
292
+ echo -e "${YELLOW}═══════════════════════════════════════════════════════════${NC}"
293
+ echo
294
+ echo "House rules help AI agents understand your project conventions and"
295
+ echo "prevent conflicts when multiple agents work on the same codebase."
296
+ echo
297
+
298
+ # Check for existing house rules
299
+ local HOUSERULES_PATH=""
300
+ local HOUSERULES_FOUND=false
301
+
302
+ if [[ -f "$ROOT/houserules.md" ]]; then
303
+ HOUSERULES_PATH="$ROOT/houserules.md"
304
+ HOUSERULES_FOUND=true
305
+ echo -e "${GREEN}✓${NC} Found existing house rules at: houserules.md"
306
+ elif [[ -f "$ROOT/HOUSERULES.md" ]]; then
307
+ HOUSERULES_PATH="$ROOT/HOUSERULES.md"
308
+ HOUSERULES_FOUND=true
309
+ echo -e "${GREEN}✓${NC} Found existing house rules at: HOUSERULES.md"
310
+ elif [[ -f "$ROOT/.github/HOUSERULES.md" ]]; then
311
+ HOUSERULES_PATH="$ROOT/.github/HOUSERULES.md"
312
+ HOUSERULES_FOUND=true
313
+ echo -e "${GREEN}✓${NC} Found existing house rules at: .github/HOUSERULES.md"
314
+ elif [[ -f "$ROOT/docs/houserules.md" ]]; then
315
+ HOUSERULES_PATH="$ROOT/docs/houserules.md"
316
+ HOUSERULES_FOUND=true
317
+ echo -e "${GREEN}✓${NC} Found existing house rules at: docs/houserules.md"
318
+ else
319
+ echo "No existing house rules found."
320
+ echo
321
+ echo "Would you like to:"
322
+ echo " ${BOLD}1)${NC} Create comprehensive house rules (recommended)"
323
+ echo " ${BOLD}2)${NC} Specify path to existing house rules"
324
+ echo " ${BOLD}3)${NC} Skip for now"
325
+ echo
326
+ echo -n "Your choice [1]: "
327
+ read CHOICE
328
+
329
+ case "${CHOICE:-1}" in
330
+ 1)
331
+ HOUSERULES_PATH="$ROOT/houserules.md"
332
+ HOUSERULES_FOUND=false
333
+ echo -e "${GREEN}✓${NC} Will create comprehensive house rules at: houserules.md"
334
+ ;;
335
+ 2)
336
+ echo -n "Enter path to your house rules (relative to $ROOT): "
337
+ read CUSTOM_PATH
338
+ if [[ -f "$ROOT/$CUSTOM_PATH" ]]; then
339
+ HOUSERULES_PATH="$ROOT/$CUSTOM_PATH"
340
+ HOUSERULES_FOUND=true
341
+ echo -e "${GREEN}✓${NC} Using house rules at: $CUSTOM_PATH"
342
+ else
343
+ echo -e "${YELLOW}File not found. Creating new house rules at: houserules.md${NC}"
344
+ HOUSERULES_PATH="$ROOT/houserules.md"
345
+ HOUSERULES_FOUND=false
346
+ fi
347
+ ;;
348
+ 3)
349
+ echo -e "${YELLOW}⚠ Skipping house rules setup${NC}"
350
+ echo "You can set them up later by running: ./scripts/setup-file-coordination.sh"
351
+ return 0
352
+ ;;
353
+ esac
354
+ fi
355
+
356
+ echo
357
+ echo -e "${BLUE}Setting up file coordination system...${NC}"
358
+
359
+ # Run the actual setup inline (simplified version)
360
+ if [[ -f "$SCRIPT_DIR/scripts/setup-file-coordination.sh" ]]; then
361
+ bash "$SCRIPT_DIR/scripts/setup-file-coordination.sh"
362
+ else
363
+ # Inline setup if script doesn't exist
364
+ mkdir -p "$COORD_DIR/active-edits" "$COORD_DIR/completed-edits"
365
+ echo -e "${GREEN}✓${NC} File coordination directories created"
366
+ fi
367
+
368
+ echo
369
+ echo -e "${GREEN}✓ Setup complete!${NC} AI agents will now follow house rules and coordinate file edits."
370
+ echo
371
+ echo -e "${DIM}Press Enter to continue...${NC}"
372
+ read -r
373
+ echo
374
+ }
375
+
240
376
  # Main function
241
377
  main() {
242
378
  # Show copyright first
@@ -256,6 +392,9 @@ main() {
256
392
  REPO_ROOT=$(git rev-parse --show-toplevel)
257
393
  cd "$REPO_ROOT"
258
394
 
395
+ # Check and setup house rules on first run
396
+ setup_house_rules "$REPO_ROOT"
397
+
259
398
  echo -e "${BOLD}Welcome to DevOps Agent Session Manager${NC}"
260
399
  echo
261
400
  echo "This tool will:"