Skip to content

feat(worktree): add session mapping and improve pre-edit check#29

Merged
marcusquinn merged 1 commit intomainfrom
chore/worktree-session-mapping
Jan 11, 2026
Merged

feat(worktree): add session mapping and improve pre-edit check#29
marcusquinn merged 1 commit intomainfrom
chore/worktree-session-mapping

Conversation

@marcusquinn
Copy link
Owner

@marcusquinn marcusquinn commented Jan 11, 2026

Summary

  • Add worktree-sessions.sh script to map git worktrees to likely OpenCode sessions
  • Strengthen pre-edit git check based on agent-review feedback
  • Document session recovery workflow

Changes

New: worktree-sessions.sh

Maps worktrees to OpenCode sessions using scoring based on:

  • Session title matching branch names (+100 exact, +80 slug, +60 name)
  • Temporal proximity to branch creation (+40 within 1hr, +20 within 4hr)
  • Keyword matching from branch name (+20 per term)

Portability fixes (addressing previous review feedback):

  • Portable date command (GNU -d @ vs BSD -r)
  • Portable stat command (GNU -c vs BSD -f)
  • Dynamic default branch detection (main/master)
  • Input validation for numeric choices
  • Cross-platform OpenCode launch (CLI, app bundle, xdg-open)

Commands:

  • list - Show worktrees with likely matching sessions
  • open - Interactive selection to open worktree in OpenCode

Improved: Pre-Edit Git Check (AGENTS.md)

Based on agent-review analysis of why the check was skipped:

  1. Expanded triggers - Now explicitly lists "Creating new files" alongside editing
  2. Trigger words - Added: create, add, write, update, modify, change, fix, implement, refactor
  3. Self-verification - Added prompt: "Have I run pre-edit-check.sh in this session?"
  4. Dual-location clarity - Explains source (~/Git/aidevops/) vs deployed (~/.aidevops/agents/)

Updated: workflows/worktree.md

Added "Session Recovery" section documenting how to find and resume sessions for worktrees.

Testing

  • ShellCheck passes with zero violations
  • Script correctly handles both GNU and BSD date/stat commands

Summary by CodeRabbit

  • New Features

    • Added session recovery capability to discover and open OpenCode sessions matched to git worktrees with confidence scoring.
  • Documentation

    • Enhanced pre-edit workflow with explicit protected branch detection and handling.
    • Expanded parallel-work guidance with session management commands.
    • Introduced self-verification prompts to ensure workflow compliance.

✏️ Tip: You can customize this high-level summary in your review settings.

- Add worktree-sessions.sh to map worktrees to likely OpenCode sessions
  - Portable date/stat commands (GNU and BSD compatible)
  - Dynamic default branch detection (main/master)
  - Input validation for interactive mode
  - Cross-platform OpenCode launch (CLI, app bundle, xdg-open)
- Strengthen pre-edit check with explicit trigger words
  - Now lists: create, add, write, update, modify, change, fix, implement, refactor
  - Explicitly covers creating new files, not just editing
- Add self-verification prompt for file operations
- Clarify dual-location workflow for aidevops framework
- Document session recovery in worktree.md
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 11, 2026

Walkthrough

This PR enhances agent workflows and introduces session recovery tooling. It expands pre-edit check requirements and procedures in workflow documentation, adds a new Bash script for mapping git worktrees to OpenCode sessions with scoring-based matching logic, and documents session recovery guidance with best practices.

Changes

Cohort / File(s) Summary
Workflow Documentation & Pre-edit Guidance
.agent/AGENTS.md
Expands pre-edit check rules with explicit trigger words and action types; adds handling for STOP - ON PROTECTED BRANCH outputs; introduces self-verification prompts and dual-location working context guidance.
Worktree Session Mapping
.agent/scripts/worktree-sessions.sh, .agent/workflows/worktree.md
New script implements worktree-to-OpenCode session mapping with branch name, slug, and temporal proximity scoring; supports list/open/help commands with GNU/BSD portability. Workflow docs updated with Session Recovery section covering matching logic and best practices.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Script as worktree-sessions.sh
    participant Git
    participant FileSystem as Project Storage
    participant Sessions as Session Files

    User->>Script: cmd_list or cmd_open
    Script->>Git: git worktree list / get_default_branch()
    Script->>FileSystem: Detect repo root & name
    Script->>FileSystem: get_project_id() - scan JSON for match
    Script->>Git: get_branch_start_date() - commit date on branch
    Script->>Sessions: Read ses_*.json files
    Script->>Script: find_matching_sessions() - score candidates<br/>(branch name: 100, slug: 80, terms: 20, temporal: 40)
    Script->>User: Output top 3 matches with confidence levels
    alt cmd_open selected
        User->>Script: Select worktree
        Script->>Script: Resolve OpenCode or fallback editor
        Script->>User: Open session in IDE
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🌳 Worktrees sprout in every branch,
Sessions found with matching search,
Branch-names score and dates align—
Recovery flows so sublime!
Zero debt through shells so fine. ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the primary changes: adding session mapping for worktrees and improving the pre-edit check workflow, both of which are core objectives of this PR.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a new utility to streamline the developer workflow by helping users quickly locate and resume their OpenCode sessions associated with specific Git worktrees. It also refines the existing pre-edit Git check mechanism to ensure better adherence to branching policies and provides clear documentation for these new capabilities, enhancing overall development efficiency and consistency.

Highlights

  • New Worktree Session Mapping Script: Introduced worktree-sessions.sh to intelligently map Git worktrees to OpenCode sessions based on branch names, temporal proximity, and keywords, offering list and open commands.
  • Enhanced Pre-Edit Git Check: Strengthened the pre-edit-check.sh guidelines in AGENTS.md by expanding trigger conditions to include file creation and writing, adding a comprehensive list of trigger words, and incorporating a self-verification prompt.
  • Improved Portability: The new worktree-sessions.sh script includes robust portability fixes for date (GNU vs. BSD) and stat commands, along with dynamic default branch detection for main or master.
  • Documented Session Recovery Workflow: Added a new 'Session Recovery' section in workflows/worktree.md detailing how to use the new script for finding and resuming sessions, complete with an explanation of the session matching logic and confidence levels.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@sonarqubecloud
Copy link

@github-actions
Copy link

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 223 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Sun Jan 11 01:16:44 UTC 2026: Code review monitoring started
Sun Jan 11 01:16:45 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 223
Sun Jan 11 01:16:45 UTC 2026: Qlty - 0 issues found, auto-formatting applied
Sun Jan 11 01:16:47 UTC 2026: Codacy analysis completed with auto-fixes
Sun Jan 11 01:16:48 UTC 2026: Applied 1 automatic fixes

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 223
  • VULNERABILITIES: 0

Generated on: Sun Jan 11 01:17:23 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a very useful worktree-sessions.sh script for mapping git worktrees to OpenCode sessions, along with improved documentation for the pre-edit check and worktree workflows. The new script is well-structured and demonstrates good practices for portability.

My review focuses on the new script. I've identified a few areas for improvement:

  • Portability: The script hardcodes paths that are specific to Linux, which could be improved to support other operating systems like macOS.
  • Correctness: The session scoring logic has a flaw where scores for different name matches accumulate, which can lead to counter-intuitive results.
  • Maintainability: There's some code duplication and an unused function that could be cleaned up.
  • Robustness: The script could be made more robust by checking for its jq dependency.

I've provided specific suggestions to address these points. The documentation changes are clear and valuable.

Comment on lines +34 to +35
readonly SESSION_BASE="$HOME/.local/share/opencode/storage/session"
readonly PROJECT_BASE="$HOME/.local/share/opencode/storage/project"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The script hardcodes paths to ~/.local/share/opencode/..., which is specific to Linux systems following the XDG standard. On macOS, these paths are different (typically under ~/Library/Application Support). To improve portability, which is a goal of this PR, the script should dynamically determine the correct base path for OpenCode data.

Suggested change
readonly SESSION_BASE="$HOME/.local/share/opencode/storage/session"
readonly PROJECT_BASE="$HOME/.local/share/opencode/storage/project"
opencode_data_dir="${XDG_DATA_HOME:-$HOME/.local/share}/opencode"
if [[ "$(uname)" == "Darwin" ]]; then
opencode_data_dir="$HOME/Library/Application Support/opencode"
fi
readonly SESSION_BASE="$opencode_data_dir/storage/session"
readonly PROJECT_BASE="$opencode_data_dir/storage/project"

Comment on lines +191 to +203
if [[ "$session_title" == "$branch" ]]; then
score=$((score + 100))
fi

# Scoring: branch slug in title (case-insensitive)
if echo "$session_title" | grep -qi "$branch_slug"; then
score=$((score + 80))
fi

# Scoring: branch name (without type prefix) in title
if echo "$session_title" | grep -qi "$branch_name"; then
score=$((score + 60))
fi

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The scoring logic for matching session titles is cumulative. For example, if a session title is an exact match for the branch name (+100), it will also likely match the branch name without the prefix (+60) and some key terms (+20 each), leading to an inflated and less predictable score. The documentation in worktree.md implies these are alternative matching strategies. To make the scoring more intuitive, you should use if/elif/else for the name-based scoring so that only the best possible name match is counted.

Suggested change
if [[ "$session_title" == "$branch" ]]; then
score=$((score + 100))
fi
# Scoring: branch slug in title (case-insensitive)
if echo "$session_title" | grep -qi "$branch_slug"; then
score=$((score + 80))
fi
# Scoring: branch name (without type prefix) in title
if echo "$session_title" | grep -qi "$branch_name"; then
score=$((score + 60))
fi
if [[ "$session_title" == "$branch" ]]; then
score=$((score + 100))
elif echo "$session_title" | grep -qi "$branch_slug"; then
score=$((score + 80))
elif echo "$session_title" | grep -qi "$branch_name"; then
score=$((score + 60))
fi

readonly BOLD='\033[1m'
readonly DIM='\033[2m'
readonly NC='\033[0m'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This script depends on jq for parsing JSON files, but it doesn't check if jq is installed. If jq is missing, the script will fail with potentially confusing errors. It's good practice to add a check for dependencies at the beginning of the script and provide a clear error message if they are not found.

Suggested change
if ! command -v jq &>/dev/null; then
echo -e "${RED}Error: 'jq' is not installed. Please install it to use this script.${NC}" >&2
exit 1
fi

Comment on lines +45 to +51
get_repo_name() {
local root
root=$(get_repo_root)
if [[ -n "$root" ]]; then
basename "$root"
fi
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The function get_repo_name is defined but is not used anywhere in the script. It should be removed to eliminate dead code and improve maintainability.

time_diff=$((time_diff * -1))
fi
# Within 1 hour
if [[ $time_diff -lt 3600000 ]]; then

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The script uses magic numbers 3600000 and 14400000 for time durations in milliseconds. To improve readability and maintainability, these should be defined as named constants at the top of the find_matching_sessions function (e.g., local readonly ONE_HOUR_MS=3600000).

Comment on lines +386 to +401
while IFS= read -r line; do
if [[ "$line" =~ ^worktree\ (.+)$ ]]; then
worktree_path="${BASH_REMATCH[1]}"
elif [[ "$line" =~ ^branch\ refs/heads/(.+)$ ]]; then
worktree_branch="${BASH_REMATCH[1]}"
elif [[ -z "$line" ]]; then
if [[ -n "$worktree_path" ]] && [[ -n "$worktree_branch" ]]; then
if [[ "$worktree_branch" != "main" ]] && [[ "$worktree_branch" != "master" ]]; then
worktrees+=("$worktree_path")
branches+=("$worktree_branch")
fi
fi
worktree_path=""
worktree_branch=""
fi
done < <(git worktree list --porcelain; echo "")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The logic for parsing the output of git worktree list --porcelain is duplicated in cmd_list (lines 276-350) and here in cmd_open. To improve maintainability and reduce redundancy, this parsing logic should be extracted into a dedicated helper function. This function could populate the worktrees and branches arrays, which can then be used by both cmd_list and cmd_open.

@augmentcode
Copy link

augmentcode bot commented Jan 11, 2026

🤖 Augment PR Summary

Summary: Adds tooling and documentation to better recover and resume OpenCode sessions when working with multiple Git worktrees.

Changes:

  • Introduces .agent/scripts/worktree-sessions.sh to map worktrees to likely OpenCode sessions via a weighted scoring model (branch/title/keywords + time proximity).
  • Adds an interactive open flow to select a worktree and launch OpenCode (CLI/app/xdg-open fallbacks).
  • Improves portability by handling GNU vs BSD variants of date and stat, and detects the default branch via origin/HEAD with main/master fallbacks.
  • Strengthens .agent/AGENTS.md guidance so pre-edit checks are triggered for create/write actions and adds a self-verification reminder + source vs deployed location clarity.
  • Updates .agent/workflows/worktree.md with a “Session Recovery” section describing how to use the new script and interpret confidence scores.

Technical Notes: Branch “start time” is inferred from the first commit unique to the branch (or worktree mtime if none), then compared to session timestamps to boost likely matches.

🤖 Was this summary useful? React with 👍 or 👎

Copy link

@augmentcode augmentcode bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 3 suggestions posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

fi

# Scoring: branch slug in title (case-insensitive)
if echo "$session_title" | grep -qi "$branch_slug"; then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

grep -qi "$branch_slug" treats the branch value as a regex, so branch names containing regex metacharacters can mis-score (or emit regex errors). Consider using fixed-string matching (e.g., grep -Fqi) here (also applies to the other grep -qi checks below).

Other Locations
  • .agent/scripts/worktree-sessions.sh:201
  • .agent/scripts/worktree-sessions.sh:207

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

return 1
fi

local index=$((choice - 1))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In bash arithmetic, numbers with leading zeros can be parsed as octal (e.g., 08), which can error under set -e when computing index. Consider forcing base-10 parsing of choice before local index=$((choice - 1)).

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

for project_file in "$PROJECT_BASE"/*.json; do
if [[ -f "$project_file" ]]; then
local project_dir
project_dir=$(jq -r '.worktree // .path // .directory // ""' "$project_file" 2>/dev/null)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script assumes jq exists; if it’s missing, set -e will terminate with a non-obvious “command not found”. Consider adding an explicit dependency check early (similar to other .agent/scripts/*-helper.sh scripts) so failures are user-friendly.

Fix This in Augment

🤖 Was this useful? React with 👍 or 👎

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
.agent/scripts/worktree-sessions.sh (1)

71-86: Minor: Redundant stderr redirection.

Line 76 has &>/dev/null 2>&1 where &>/dev/null alone suffices (it already redirects both stdout and stderr). The script functions correctly, but this is a small cleanup opportunity.

🧹 Optional cleanup
-        if date --version &>/dev/null 2>&1; then
+        if date --version &>/dev/null; then
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f291a14 and 63b8a6e.

📒 Files selected for processing (3)
  • .agent/AGENTS.md
  • .agent/scripts/worktree-sessions.sh
  • .agent/workflows/worktree.md
🧰 Additional context used
📓 Path-based instructions (1)
.agent/scripts/*.sh

⚙️ CodeRabbit configuration file

.agent/scripts/*.sh: Automation scripts - focus on:

  • Reliability and robustness
  • Clear logging and feedback
  • Proper exit codes
  • Error recovery mechanisms

Files:

  • .agent/scripts/worktree-sessions.sh
🧠 Learnings (14)
📓 Common learnings
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: templates/home/AGENTS.md:0-0
Timestamp: 2025-12-22T01:24:53.937Z
Learning: Follow all security protocols and working directory specifications defined in ~/Git/aidevops/AGENTS.md
📚 Learning: 2026-01-06T15:57:56.008Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-06T15:57:56.008Z
Learning: Applies to **/AGENTS.md : Limit root AGENTS.md to ~50-100 max instructions with universal applicability to >80% of tasks

Applied to files:

  • .agent/AGENTS.md
📚 Learning: 2025-11-29T04:34:42.033Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: AGENT.md:0-0
Timestamp: 2025-11-29T04:34:42.033Z
Learning: Reference AGENTS.md (authoritative) instead of AGENT.md for AI assistant guidance

Applied to files:

  • .agent/AGENTS.md
📚 Learning: 2025-11-29T04:34:27.158Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-29T04:34:27.158Z
Learning: All instructions, documentation, and operational guidance should be maintained in AGENTS.md as the single source of truth

Applied to files:

  • .agent/AGENTS.md
📚 Learning: 2025-11-29T04:34:30.742Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: GEMINI.md:0-0
Timestamp: 2025-11-29T04:34:30.742Z
Learning: Maintain all instructions, documentation, and operational guidance in AGENTS.md as the single source of truth

Applied to files:

  • .agent/AGENTS.md
📚 Learning: 2026-01-06T15:57:56.007Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-01-06T15:57:56.007Z
Learning: Applies to **/.agent/scripts/linters-local.sh : Run quality checks before committing using .agent/scripts/linters-local.sh

Applied to files:

  • .agent/AGENTS.md
📚 Learning: 2025-12-22T01:24:53.937Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: templates/home/AGENTS.md:0-0
Timestamp: 2025-12-22T01:24:53.937Z
Learning: Follow all security protocols and working directory specifications defined in ~/Git/aidevops/AGENTS.md

Applied to files:

  • .agent/AGENTS.md
📚 Learning: 2025-11-29T04:34:30.742Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: GEMINI.md:0-0
Timestamp: 2025-11-29T04:34:30.742Z
Learning: Reference AGENTS.md for authoritative AI assistant guidance instead of GEMINI.md

Applied to files:

  • .agent/AGENTS.md
📚 Learning: 2025-11-29T04:34:42.033Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: AGENT.md:0-0
Timestamp: 2025-11-29T04:34:42.033Z
Learning: Maintain all AI assistant instructions, documentation, and operational guidance in AGENTS.md as the single source of truth

Applied to files:

  • .agent/AGENTS.md
📚 Learning: 2025-12-22T01:25:03.138Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: templates/home/git/AGENTS.md:0-0
Timestamp: 2025-12-22T01:25:03.138Z
Learning: Follow security protocols for all git and DevOps operations

Applied to files:

  • .agent/AGENTS.md
📚 Learning: 2025-12-22T01:24:53.937Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: templates/home/AGENTS.md:0-0
Timestamp: 2025-12-22T01:24:53.937Z
Learning: Never store credentials in working directories (~/.aidevops/.agent-workspace/), Git repositories, home directory root, or hardcoded in code and scripts

Applied to files:

  • .agent/AGENTS.md
📚 Learning: 2025-12-22T01:24:53.937Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: templates/home/AGENTS.md:0-0
Timestamp: 2025-12-22T01:24:53.937Z
Learning: Reference the authoritative repository at ~/Git/aidevops/ for all detailed AI assistant instructions and configurations

Applied to files:

  • .agent/AGENTS.md
📚 Learning: 2025-12-22T01:25:03.138Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: templates/home/git/AGENTS.md:0-0
Timestamp: 2025-12-22T01:25:03.138Z
Learning: NEVER store credentials or API keys in ~/.aidevops/.agent-workspace/ directories - working files are not secure

Applied to files:

  • .agent/AGENTS.md
📚 Learning: 2025-12-22T01:24:53.937Z
Learnt from: CR
Repo: marcusquinn/aidevops PR: 0
File: templates/home/AGENTS.md:0-0
Timestamp: 2025-12-22T01:24:53.937Z
Learning: Use only the specified working directories: ~/.aidevops/.agent-workspace/work/[project]/ for work files, ~/.aidevops/.agent-workspace/tmp/ for temporary files, and ~/.aidevops/.agent-workspace/memory/ for persistent memory

Applied to files:

  • .agent/AGENTS.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (11)
.agent/workflows/worktree.md (1)

290-318: LGTM! Well-documented session recovery workflow.

The scoring system and confidence levels are clearly explained and match the implementation in worktree-sessions.sh. The best practice recommendation for session-rename_sync_branch helps ensure reliable future lookups.

.agent/AGENTS.md (3)

13-24: LGTM! Comprehensive pre-edit triggers.

The expanded trigger list and explicit trigger words provide clear, actionable guidance. This helps ensure consistent pre-edit checks across all file modification scenarios.


54-61: LGTM! Essential dual-location clarification.

The self-verification prompt and dual-location guidance address a real source of confusion when working on the aidevops framework itself. This prevents accidental commits to protected branches from the deployed (non-git) location.


177-178: LGTM! Good integration with existing worktree workflow.

The new session listing command fits naturally alongside the existing worktree commands, providing a clear path to session recovery.

.agent/scripts/worktree-sessions.sh (7)

1-35: LGTM! Solid script foundation with strict mode enabled.

The set -euo pipefail ensures fail-fast behavior. The ShellCheck disables are justified—SC2034 for potentially unused color constants and SC2155 for the common local var=$(...) pattern.


41-69: LGTM! Robust utility functions with good defensive parsing.

The jq fallback chain (.worktree // .path // .directory) handles schema variations gracefully. The [[ -f "$project_file" ]] guard correctly handles the case when no JSON files exist.


98-144: LGTM! Well-designed fallback chains for cross-platform compatibility.

The default branch detection gracefully handles remote HEAD, then falls back to checking for main or master. The || true on line 131 correctly prevents set -e from terminating the script when the branch has no unique commits.

Same minor note: line 138 has redundant &>/dev/null 2>&1.


146-243: LGTM! Well-implemented scoring algorithm.

The scoring system is comprehensive and matches the documented behavior in worktree.md. The portable grep -qi for case-insensitive matching and the manual absolute value calculation are appropriate. The 2>/dev/null on the printf correctly handles empty arrays.


249-366: LGTM! Clean command implementation with good UX.

The git worktree list --porcelain parsing is robust, and the trailing echo "" ensures the final entry is processed. Clear error messages, informative output, and helpful tips make this user-friendly.


368-462: LGTM! Solid interactive selection with cross-platform launch support.

Input validation is thorough—checking for numeric input and valid range. The multi-tier launch strategy (CLI → macOS app bundle → xdg-open → manual instructions) provides good fallback coverage across platforms.


464-535: LGTM! Clean command dispatch with helpful aliases.

The quoted heredoc 'EOF' correctly prevents variable expansion in the help text. Command aliases (ls, o, -h) provide convenient shortcuts, and all paths return appropriate exit codes.

@marcusquinn marcusquinn merged commit 2624e84 into main Jan 11, 2026
18 of 21 checks passed
@marcusquinn marcusquinn deleted the chore/worktree-session-mapping branch January 11, 2026 05:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant