From a58b0f6af41aa4562080870620579ff67fafd214 Mon Sep 17 00:00:00 2001 From: Towry Wang Date: Fri, 13 Jun 2025 16:59:19 +0800 Subject: [PATCH 01/10] fix(fish): add --ignore-working-copy flag to jj bookmark list Review notes: - Change prevents potential conflicts with working copy state - No bugs found in the modification - Maintains existing functionality while improving robustness - Good practice to ignore working copy for bookmark operations --- conf/fish/funcs/_fzf-jj-bookmarks.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/fish/funcs/_fzf-jj-bookmarks.fish b/conf/fish/funcs/_fzf-jj-bookmarks.fish index f2f57942..14bc6be7 100644 --- a/conf/fish/funcs/_fzf-jj-bookmarks.fish +++ b/conf/fish/funcs/_fzf-jj-bookmarks.fish @@ -27,7 +27,7 @@ function _fzf-jj-bookmarks --description "Search for jujutsu bookmarks or git br end # Fallback to jj if not in a git repo else if jj root --quiet &>/dev/null - set -f lines (jj bookmark list --sort committer-date- --quiet --no-pager --color always | grep -v '^[[:space:]]' | grep -v '\(deleted\)' | fzf --cycle --tmux 98% --ansi --layout=reverse \ + set -f lines (jj bookmark list --ignore-working-copy --sort committer-date- --quiet --no-pager --color always | grep -v '^[[:space:]]' | grep -v '\(deleted\)' | fzf --cycle --tmux 98% --ansi --layout=reverse \ --scheme=path \ --query="$query" \ --preview='jj log --color=always -r "stack($(echo {} | cut -d: -f2 | awk "{print \\$1}" | string trim))" --no-graph' \ From 849a6da6c7a45f615bf6289f31a1c9ca3e7edfe1 Mon Sep 17 00:00:00 2001 From: Towry Wang Date: Fri, 13 Jun 2025 22:40:38 +0800 Subject: [PATCH 02/10] refactor(fish): split jj/git bookmark functions and add ignore-working-copy flags Review notes: - Good separation of concerns by splitting into _fzf-jj-bookmarks-jj and _fzf-jj-bookmarks-git - Consistent use of --ignore-working-copy flag across all jj commands - Clear error handling with return codes in helper functions - Consider adding comments explaining the priority order in main function - No bugs found in the refactored logic - Good backward compatibility maintained with existing behavior --- conf/fish/funcs/_fzf-jj-bookmarks.fish | 27 +++++++++++++++++++------- conf/fish/funcs/_fzf-jj-revs.fish | 2 +- conf/fish/funcs/jj-fork-main.fish | 4 ++-- conf/fish/funcs/jj-fork-master.fish | 6 +++--- 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/conf/fish/funcs/_fzf-jj-bookmarks.fish b/conf/fish/funcs/_fzf-jj-bookmarks.fish index 14bc6be7..1da0549f 100644 --- a/conf/fish/funcs/_fzf-jj-bookmarks.fish +++ b/conf/fish/funcs/_fzf-jj-bookmarks.fish @@ -1,11 +1,8 @@ -function _fzf-jj-bookmarks --description "Search for jujutsu bookmarks or git branches" - # Get the current token as initial query +function _fzf-jj-bookmarks-git --description "fzf for git branches" set -l query "" if status is-interactive set query (commandline --current-token) end - - # Try git first if git rev-parse --git-dir &>/dev/null set -f lines (git branch --sort=-committerdate --color=always | sed 's/^[* ] //' | fzf --cycle --tmux 98% --ansi --layout=reverse \ --scheme=path \ @@ -24,9 +21,18 @@ function _fzf-jj-bookmarks --description "Search for jujutsu bookmarks or git br else echo $branch end + return 0 end - # Fallback to jj if not in a git repo - else if jj root --quiet &>/dev/null + end + return 1 +end + +function _fzf-jj-bookmarks-jj --description "fzf for jj bookmarks" + set -l query "" + if status is-interactive + set query (commandline --current-token) + end + if jj root --ignore-working-copy --quiet &>/dev/null set -f lines (jj bookmark list --ignore-working-copy --sort committer-date- --quiet --no-pager --color always | grep -v '^[[:space:]]' | grep -v '\(deleted\)' | fzf --cycle --tmux 98% --ansi --layout=reverse \ --scheme=path \ --query="$query" \ @@ -44,8 +50,15 @@ function _fzf-jj-bookmarks --description "Search for jujutsu bookmarks or git br else echo $bookmark end + return 0 end - else + end + return 1 +end + +function _fzf-jj-bookmarks --description "Search for jujutsu bookmarks or git branches" + # Change the order here to switch priority + _fzf-jj-bookmarks-jj; or _fzf-jj-bookmarks-git; or begin echo "Not in a jj or git repository" >&2 return 1 end diff --git a/conf/fish/funcs/_fzf-jj-revs.fish b/conf/fish/funcs/_fzf-jj-revs.fish index b624e400..9cc7f39d 100644 --- a/conf/fish/funcs/_fzf-jj-revs.fish +++ b/conf/fish/funcs/_fzf-jj-revs.fish @@ -1,7 +1,7 @@ # credit: https://github.com/gessen/fzf.fish/blob/master/functions/_fzf-jj-revs.fish function _fzf-jj-revs --description "Search for jujutsu revision ids" - jj root --quiet &>/dev/null; or return + jj root --ignore-working-copy --quiet &>/dev/null; or return set -f lines (jj log --quiet --ignore-working-copy --no-graph --color always \ --revisions 'bookmarks(towry) | (ancestors(@) & author(towry) ~ empty())' \ --template 'committer.timestamp().format("%F/%H:%M") ++ " " ++change_id.shortest(7) ++ " " ++ description.first_line() ++ " " ++ bookmarks ++ "\n"' \ diff --git a/conf/fish/funcs/jj-fork-main.fish b/conf/fish/funcs/jj-fork-main.fish index 4c6d7374..c3905d0d 100755 --- a/conf/fish/funcs/jj-fork-main.fish +++ b/conf/fish/funcs/jj-fork-main.fish @@ -38,14 +38,14 @@ function jj-fork-main --description "Fork main branch" # by running jj log -r $bookmark_name -n 1 # if no error, then the bookmark name is already used # exit with error msg - jj log -r $bookmark_name -n 1 > /dev/null 2>&1 + jj --ignore-working-copy log -r $bookmark_name -n 1 > /dev/null 2>&1 if test $status -eq 0 echo "Bookmark name $bookmark_name is already used" return 1 end # 确保我们能捕获所有输出,包括stderr - set -l output (jj new --no-pager --no-edit -r main@origin -m "$description" 2>&1) + set -l output (jj new --ignore-working-copy --no-pager --no-edit -r main@origin -m "$description" 2>&1) if test $status -ne 0 echo "Failed to create new revision" return 1 diff --git a/conf/fish/funcs/jj-fork-master.fish b/conf/fish/funcs/jj-fork-master.fish index 9abe7a8e..389f3aa8 100644 --- a/conf/fish/funcs/jj-fork-master.fish +++ b/conf/fish/funcs/jj-fork-master.fish @@ -23,7 +23,7 @@ function jj-fork-master --description "Fork master branch" end set -l description $_flag_description - jj git fetch -b master > /dev/null 2>&1 + jj --ignore-working-copy git fetch -b master > /dev/null 2>&1 or return # create bookmark name from aichat @@ -34,14 +34,14 @@ function jj-fork-master --description "Fork master branch" set -l date_now (date +%m%d%H) set -l bookmark_name "$bookmark_name-$date_now" - jj log --quiet -r $bookmark_name -n 1 > /dev/null 2>&1 + jj log --ignore-working-copy --quiet -r $bookmark_name -n 1 > /dev/null 2>&1 if test $status -eq 0 echo "Bookmark name $bookmark_name is already used" return 1 end # 确保我们能捕获所有输出,包括stderr - set -l output (jj new --no-pager --no-edit -r master@origin -m "$description" 2>&1) + set -l output (jj new --ignore-working-copy --no-pager --no-edit -r master@origin -m "$description" 2>&1) if test $status -ne 0 echo "Failed to create new revision" return 1 From 86aa0b5e09af5575491ecc25e993c37b059fda74 Mon Sep 17 00:00:00 2001 From: Towry Wang Date: Fri, 13 Jun 2025 22:50:16 +0800 Subject: [PATCH 03/10] refactor(fish): improve fzf-jj-bookmarks status handling Review notes: - Improved logic flow by early returning when not in git/jj repo - Better status handling by storing fzf status in variable - More consistent return behavior between git and jj functions - No bugs found in the refactored logic - Consider adding error handling for command failures - Recommend adding comments explaining the status handling logic --- conf/fish/funcs/_fzf-jj-bookmarks.fish | 100 ++++++++++++++----------- 1 file changed, 57 insertions(+), 43 deletions(-) diff --git a/conf/fish/funcs/_fzf-jj-bookmarks.fish b/conf/fish/funcs/_fzf-jj-bookmarks.fish index 1da0549f..44a4829c 100644 --- a/conf/fish/funcs/_fzf-jj-bookmarks.fish +++ b/conf/fish/funcs/_fzf-jj-bookmarks.fish @@ -3,28 +3,28 @@ function _fzf-jj-bookmarks-git --description "fzf for git branches" if status is-interactive set query (commandline --current-token) end - if git rev-parse --git-dir &>/dev/null - set -f lines (git branch --sort=-committerdate --color=always | sed 's/^[* ] //' | fzf --cycle --tmux 98% --ansi --layout=reverse \ - --scheme=path \ - --query="$query" \ - --preview='git log --color=always --oneline -10 {}' \ - --preview-label='Recent Commits' \ - --bind='ctrl-y:execute-silent(echo {} | pbcopy)' \ - --header='Enter: select branch, Ctrl-Y: copy branch name' \ - --border=rounded) - - if test $status -eq 0 - set -l branch (echo $lines | string trim) - if status is-interactive - commandline --current-token --replace $branch - commandline --function repaint - else - echo $branch - end - return 0 + if not git rev-parse --git-dir &>/dev/null + return 1 + end + set -f lines (git branch --sort=-committerdate --color=always | sed 's/^[* ] //' | fzf --cycle --tmux 98% --ansi --layout=reverse \ + --scheme=path \ + --query="$query" \ + --preview='git log --color=always --oneline -10 {}' \ + --preview-label='Recent Commits' \ + --bind='ctrl-y:execute-silent(echo {} | pbcopy)' \ + --header='Enter: select branch, Ctrl-Y: copy branch name' \ + --border=rounded) + set -l fzf_status $status + if test $fzf_status -eq 0 + set -l branch (echo $lines | string trim) + if status is-interactive + commandline --current-token --replace $branch + commandline --function repaint + else + echo $branch end end - return 1 + return $fzf_status end function _fzf-jj-bookmarks-jj --description "fzf for jj bookmarks" @@ -32,36 +32,50 @@ function _fzf-jj-bookmarks-jj --description "fzf for jj bookmarks" if status is-interactive set query (commandline --current-token) end - if jj root --ignore-working-copy --quiet &>/dev/null - set -f lines (jj bookmark list --ignore-working-copy --sort committer-date- --quiet --no-pager --color always | grep -v '^[[:space:]]' | grep -v '\(deleted\)' | fzf --cycle --tmux 98% --ansi --layout=reverse \ - --scheme=path \ - --query="$query" \ - --preview='jj log --color=always -r "stack($(echo {} | cut -d: -f2 | awk "{print \\$1}" | string trim))" --no-graph' \ - --preview-label='Commit Details' \ - --bind='ctrl-y:execute-silent(echo {} | cut -d: -f2 | awk "{print \\$1}" | string trim | pbcopy)' \ - --header='Enter: select bookmark, Ctrl-Y: copy revset' \ - --border=rounded) - - if test $status -eq 0 - set -l bookmark (echo $lines | cut -d: -f1 | string trim) - if status is-interactive - commandline --current-token --replace $bookmark - commandline --function repaint - else - echo $bookmark - end - return 0 + if not jj root --ignore-working-copy --quiet &>/dev/null + return 1 + end + set -f lines (jj bookmark list --ignore-working-copy --sort committer-date- --quiet --no-pager --color always | grep -v '^[[:space:]]' | grep -v '\(deleted\)' | fzf --cycle --tmux 98% --ansi --layout=reverse \ + --scheme=path \ + --query="$query" \ + --preview='jj log --color=always -r "stack($(echo {} | cut -d: -f2 | awk "{print \\$1}" | string trim))" --no-graph' \ + --preview-label='Commit Details' \ + --bind='ctrl-y:execute-silent(echo {} | cut -d: -f2 | awk "{print \\$1}" | string trim | pbcopy)' \ + --header='Enter: select bookmark, Ctrl-Y: copy revset' \ + --border=rounded) + set -l fzf_status $status + if test $fzf_status -eq 0 + set -l bookmark (echo $lines | cut -d: -f1 | string trim) + if status is-interactive + commandline --current-token --replace $bookmark + commandline --function repaint + else + echo $bookmark end end - return 1 + return $fzf_status end function _fzf-jj-bookmarks --description "Search for jujutsu bookmarks or git branches" # Change the order here to switch priority - _fzf-jj-bookmarks-jj; or _fzf-jj-bookmarks-git; or begin - echo "Not in a jj or git repository" >&2 - return 1 + _fzf-jj-bookmarks-jj + set -l status_jj $status + if test $status_jj -eq 0 + return 0 + else if test $status_jj -ne 1 + return $status_jj + end + + _fzf-jj-bookmarks-git + set -l status_git $status + if test $status_git -eq 0 + return 0 + else if test $status_git -ne 1 + return $status_git end + + echo "Not in a jj or git repository" >&2 + return 1 end # _fzf-jj-bookmarks From 1c4c38c0c75cf1b557a25e668af236d89d361402 Mon Sep 17 00:00:00 2001 From: Towry Wang Date: Sat, 14 Jun 2025 13:14:54 +0800 Subject: [PATCH 04/10] docs: enhance directory context guidance in prompt generation Review notes: - Significant improvements to directory context documentation - Clearer guidance on working vs target directory distinction - Added critical validation steps for directory navigation - Improved tool recommendations (fd/rg over grep/find) - Better organization of mandatory analysis steps - No bugs found in the documentation updates - Consider adding examples for each technology-specific directory requirement - Might want to add troubleshooting section for common directory context errors --- conf/llm/aichat/roles/gen-prompt.md | 91 ++++++++++++++++++++++------- conf/llm/docs/coding-rules.md | 1 + 2 files changed, 71 insertions(+), 21 deletions(-) diff --git a/conf/llm/aichat/roles/gen-prompt.md b/conf/llm/aichat/roles/gen-prompt.md index 0631e982..d98ddaaf 100644 --- a/conf/llm/aichat/roles/gen-prompt.md +++ b/conf/llm/aichat/roles/gen-prompt.md @@ -112,6 +112,12 @@ Please write an agent task plan in markdown file suffix with `-task-plan.md` in [Technical, time, or resource limitations, including any specific constraints mentioned] **Codebase Analysis Requirements:** +- **CRITICAL: WORKING DIRECTORY CONTEXT ESTABLISHMENT**: **MANDATORY FIRST STEP** - Establish correct directory context to prevent file placement errors + - **Working Directory vs Target Directory Confusion Prevention**: Address the common issue where agents run commands in wrong directory context + - **Example Problem**: If pwd is `/project/monorepo` (project root) but task involves Elixir work in `/project/monorepo/elixir-apps/`, agents often incorrectly run `mix test` from project root instead of navigating to `elixir-apps/` subdirectory + - **Solution**: Always identify current working directory, then determine the correct target directory for the specific technology/task, then specify required navigation commands + - **Directory Context Documentation**: Document both current working directory AND project root with their relationship + - **Target Context Validation**: Verify whether new code should be created in current working directory or elsewhere in project structure - **COMPREHENSIVE PROJECT STRUCTURE ANALYSIS**: Perform deep analysis of the project structure to understand its architecture and organization - **Identify Project Type**: Determine if this is a monorepo, umbrella project, multi-language workspace, or single application - **Elixir Umbrella Projects**: Look for `mix.exs` files and `apps/` directories to identify umbrella projects with multiple applications @@ -156,21 +162,32 @@ Please write an agent task plan in markdown file suffix with `-task-plan.md` in **Project Structure Analysis Tools:** - **MANDATORY STRUCTURE ANALYSIS**: Before writing any task plan, agents must use these tools to understand the project: - - **Directory Tree**: Use `tree -a -L 3` or `find . -type f -name "*.exs" -o -name "*.json" -o -name "*.toml" -o -name "*.yaml" -o -name "*.yml"` to map the project structure - - **Configuration Discovery**: Look for key files like `mix.exs`, `package.json`, `pyproject.toml`, `Cargo.toml`, `composer.json`, etc. - - **Umbrella Project Detection**: For Elixir projects, check for `apps/` directory and multiple `mix.exs` files - - **Workspace Detection**: Look for workspace configuration files and multiple project roots - - **Build System Analysis**: Identify build tools and their configurations across the project -- **MANDATORY DATA FLOW ANALYSIS TOOLS**: Search for parent access anti-patterns: `grep -r "\$parent\|this\.\$parent\|useParent\|\.closest\|\.parent" --include="*.js" --include="*.ts" --include="*.vue"` and analyze component interfaces + - **CRITICAL: Working Directory Context Analysis**: **MANDATORY FIRST STEP** to establish correct directory context + - **Current Working Directory Identification**: Use `pwd` to identify the exact current working directory + - **Project Root Discovery**: Use `fd -t f -d 3 "mix.exs|package.json|pyproject.toml|Cargo.toml" . || fd -t d -d 3 ".git" .` to locate project root markers + - **Directory Relationship Mapping**: Establish the relationship between current working directory and project root, and identify the correct target directory for the specific task (e.g., if pwd is `/project/monorepo` (project root) but task involves Elixir work, the target directory should be `/project/monorepo/elixir-apps` where the Elixir project files are located) + - **Target Context Validation**: **CRITICAL** - Verify whether the task should be implemented in the current working directory or needs to navigate to a different part of the project structure. For example, if pwd is project root but task involves Elixir work, commands like `mix test` must be run from the Elixir subdirectory, not from project root + - **Path Resolution Strategy**: Document whether file paths should be relative to current working directory, project root, or specific sub-project directory + - **Directory Tree**: Use `tree -a -L 3` or `fd -t f -d 3 -e exs -e json -e toml -e yaml -e yml .` to map the project structure FROM THE CURRENT WORKING DIRECTORY + - **Configuration Discovery**: Look for key files like `mix.exs`, `package.json`, `pyproject.toml`, `Cargo.toml`, `composer.json`, etc. in both current directory and parent directories + - **Umbrella Project Detection**: For Elixir projects, check for `apps/` directory and multiple `mix.exs` files, considering both current directory and project root context + - **Workspace Detection**: Look for workspace configuration files and multiple project roots, checking parent directories if not found in current directory + - **Build System Analysis**: Identify build tools and their configurations across the project, understanding which build system applies to the current working directory context + - **Technology-Specific Directory Requirements**: **CRITICAL** - Identify where technology-specific commands must be run + - **Elixir Projects**: Commands like `mix test`, `mix deps.get`, `mix compile` must be run from directories containing `mix.exs` files, not from project root + - **Node.js Projects**: Commands like `npm test`, `npm install` must be run from directories containing `package.json` files + - **Python Projects**: Commands like `pytest`, `pip install` must be run from directories containing `pyproject.toml` or `requirements.txt` + - **Rust Projects**: Commands like `cargo test`, `cargo build` must be run from directories containing `Cargo.toml` files +- **MANDATORY DATA FLOW ANALYSIS TOOLS**: Search for parent access anti-patterns: `rg "\$parent|this\.\$parent|useParent|\.closest|\.parent" -t js -t ts -t vue` and analyze component interfaces - **MANDATORY DEPENDENCY ANALYSIS TOOLS**: **CRITICAL** for preventing architectural violations: - - **Elixir Umbrella Dependency Mapping**: Use `grep -r "deps:" apps/*/mix.exs` and `grep -r "path:" apps/*/mix.exs` to map inter-app dependencies + - **Elixir Umbrella Dependency Mapping**: Use `rg "deps:" apps/*/mix.exs` and `rg "path:" apps/*/mix.exs` to map inter-app dependencies - **JavaScript/Node.js Workspace Dependencies**: Check `package.json` files for workspace dependencies and `pnpm-workspace.yaml` or `lerna.json` configs - **Dependency Visualization**: Use tools like `mix xref graph` for Elixir or `npm ls` for Node.js to visualize dependency trees - - **Import/Require Analysis**: Search for actual module imports/requires across the codebase to understand runtime dependencies + - **Import/Require Analysis**: Use `rg "import|require|from" -t js -t ts -t ex -t py` to search for actual module imports/requires across the codebase to understand runtime dependencies - **Dependency Validation Commands**: Use `mix compile` or equivalent to verify dependency integrity before recommending changes - **MANDATORY ARCHITECTURAL LAYER ANALYSIS TOOLS**: **CRITICAL** for enforcing Single Responsibility Principle and preventing layer boundary violations: - - **Module Responsibility Mapping**: Use `find . -name "*.ex" -o -name "*.js" -o -name "*.ts" -o -name "*.py" | head -20` and analyze file contents to understand current module responsibilities - - **Cross-Cutting Concern Discovery**: Search for cache, logging, metrics, and other infrastructure patterns: `grep -r "cache\|log\|metric\|http\|db" --include="*.ex" --include="*.js" --include="*.ts" --include="*.py" apps/ lib/ src/` + - **Module Responsibility Mapping**: Use `fd -t f -e ex -e js -e ts -e py . | head -20` and analyze file contents to understand current module responsibilities + - **Cross-Cutting Concern Discovery**: Search for cache, logging, metrics, and other infrastructure patterns: `rg "cache|log|metric|http|db" -t ex -t js -t ts -t py apps/ lib/ src/` - **Layer Pattern Analysis**: Identify existing architectural patterns by examining directory structure and module organization - **SRP Violation Detection**: Look for modules that mix concerns by searching for infrastructure + business logic patterns in the same files - **Interface Boundary Analysis**: Examine how different modules communicate to understand current layer boundaries and communication patterns @@ -195,12 +212,19 @@ Use this markdown template for your task plan: [**MANDATORY SECTION** - Identify and document all user-provided information that is required for task implementation. Include any URLs, names, values, commands, paths, configurations, version numbers, or other details necessary to complete the task successfully.] ## Codebase Analysis +- **CRITICAL: Working Directory Context**: [**MANDATORY FIRST SECTION** - Establish correct directory context before any other analysis] + - **Current Working Directory**: [Use `pwd` to document the exact current working directory path] + - **Project Root Location**: [Identify the actual project root directory and its relationship to current working directory] + - **Directory Relationship**: [Clearly document the relationship - e.g., "Current working directory `/project/monorepo` is the project root, but Elixir work must be done in `/project/monorepo/elixir-apps/` subdirectory"] + - **Target Implementation Context**: [**CRITICAL** - Specify the exact directory where work should be performed. If current working directory is project root but task involves specific technology (e.g., Elixir, Node.js), identify the correct subdirectory and specify navigation commands needed] + - **Path Resolution Strategy**: [Document whether file paths in the task plan should be relative to current working directory, project root, or absolute paths] + - **Navigation Requirements**: [**MANDATORY** - If the task requires working in a different directory than current, specify the exact navigation commands needed. For example, if pwd is `/project/monorepo` but Elixir work needs to be done, specify `cd elixir-apps` before running commands like `mix test`] - **Project Type & Architecture**: [Identify if this is a monorepo, umbrella project (e.g., Elixir umbrella), multi-language workspace, or single application. Document the overall architectural approach and organization strategy] - **Current Project Structure**: [Provide detailed directory tree analysis including:] - - **Root Level Structure**: [Document all top-level directories and their purposes] - - **Sub-projects/Applications**: [For umbrella projects or monorepos, list all individual applications/services with their locations (e.g., `apps/web_app`, `apps/api_service`)] - - **Shared Resources**: [Identify shared libraries, configurations, or utilities and their locations] - - **Key Files**: [Document important configuration files at root and sub-project levels] + - **Root Level Structure**: [Document all top-level directories and their purposes, clearly distinguishing between project root and current working directory structure] + - **Sub-projects/Applications**: [For umbrella projects or monorepos, list all individual applications/services with their locations (e.g., `apps/web_app`, `apps/api_service`), specifying paths relative to both project root AND current working directory] + - **Shared Resources**: [Identify shared libraries, configurations, or utilities and their locations relative to both project root and current working directory] + - **Key Files**: [Document important configuration files at root and sub-project levels, with paths clearly specified relative to current working directory] - **CRITICAL: Data Flow Analysis**: [**MANDATORY** section to prevent data flow anti-patterns] - **Anti-Pattern Audit**: [Search for `$parent`, `this.$parent`, `useParent()`, DOM traversal for state access] - **Component Interfaces**: [Document component props/parameters and events/callbacks] @@ -271,7 +295,11 @@ Use this markdown template for your task plan: ### Phase 1: [Phase Name] - **Duration**: [Estimated time with justification] - **Deliverables**: [Specific outputs with exact file paths and locations] -- **Target Directory**: [Specify exactly where in the project structure this phase's work will be done] +- **CRITICAL: Working Directory Context Validation**: [**MANDATORY** - Verify correct directory context for this phase] + - **Target Directory**: [Specify exactly where in the project structure this phase's work will be done, with clear relationship to current working directory] + - **Directory Navigation**: [**CRITICAL** - If work needs to be done in a different directory than current working directory, specify the exact navigation commands needed. For example, if pwd is project root `/project/monorepo` but task involves Elixir work, specify `cd elixir-apps` before running any Elixir commands like `mix test`, `mix deps.get`, etc.] + - **File Path Strategy**: [Specify whether file paths in this phase are relative to current working directory, target directory, or project root] + - **Context Validation Commands**: [Include commands to verify correct directory context before starting work (e.g., `pwd` to confirm current location, `ls -la` to verify expected files exist, and navigation commands like `cd elixir-apps && pwd` to confirm correct target directory)] - **Specific Implementation Steps**: [Include all task-required details provided by the user - URLs, names, values, commands, etc.] - **CRITICAL: Data Flow Validation**: [Ensure no parent access anti-patterns and explicit parameter passing] - **CRITICAL: Dependency Validation**: [**MANDATORY** for each phase that adds new modules or features] @@ -295,7 +323,12 @@ Use this markdown template for your task plan: 1. [Research and evaluate libraries/frameworks using web search and GitHub tools] 2. [Detailed task with clear acceptance criteria and specific file paths] 3. [Next task with dependencies clearly noted and target locations specified] -- **File Placement Strategy**: [Specify exactly where new files will be created relative to project root and existing structure, with dependency compliance verification] +- **File Placement Strategy**: [**CRITICAL** - Specify exactly where new files will be created with explicit directory context] + - **File Creation Context**: [Specify whether files are created relative to current working directory, project root, or target directory] + - **Absolute vs Relative Paths**: [Document whether to use absolute paths or relative paths, and relative to which directory] + - **Directory Creation Requirements**: [If new directories need to be created, specify the exact commands and paths relative to current working directory] + - **Path Validation**: [Include commands to verify correct file placement (e.g., `ls -la target_directory/` to confirm files are in expected location)] + - **Dependency Compliance Verification**: [Ensure file placement respects dependency architecture and doesn't violate project structure rules] - **Risks**: [Potential blockers and mitigation strategies, including directory structure conflicts, dependency violations, and data flow anti-patterns] ### Phase N: [Continue for all phases] @@ -362,11 +395,23 @@ Use this markdown template for your task plan: - **Primitive Argument Preference**: Prefer primitive arguments over complex objects when possible for better testability and clarity - **Complex Object Documentation**: When objects must be passed, require documentation of exactly which properties are used and why - **Anti-Pattern Detection**: Identify and prevent common API design anti-patterns like context object passing and unclear parameter purposes -- **WORKING DIRECTORY AWARENESS**: Always understand and respect the current working directory context - - **Directory Structure Analysis**: Use tools like `tree`, `ls`, or `find` to understand the complete project structure +- **WORKING DIRECTORY AWARENESS**: **CRITICAL** requirement to prevent directory context confusion and ensure correct file placement + - **MANDATORY WORKING DIRECTORY ANALYSIS**: **FIRST STEP** in every task plan - establish correct directory context before any other analysis + - **Current Directory Identification**: Use `pwd` to identify exact current working directory and document it clearly + - **Project Root Discovery**: Use directory traversal and file markers to identify actual project root location + - **Directory Relationship Mapping**: Document the relationship between current working directory and project root (e.g., subdirectory, sibling, parent) + - **Context Validation**: Verify whether the task should be implemented in current working directory or requires navigation to different location + - **Directory Structure Analysis**: Use tools like `tree`, `ls`, or `find` to understand the complete project structure FROM THE CURRENT WORKING DIRECTORY PERSPECTIVE - **Project Root Identification**: Identify the actual project root and understand the relationship between working directory and project structure - - **Target Location Specification**: Always specify exact file paths and directories relative to the project root for any new files or modifications - - **Multi-project Context**: For umbrella projects or monorepos, clearly identify which sub-project or application the task applies to + - **Target Location Specification**: **CRITICAL** - Always specify exact file paths with explicit context about which directory they are relative to + - **Path Context Documentation**: Clearly state whether paths are relative to current working directory, project root, or target directory + - **Navigation Requirements**: If task requires working in different directory, specify exact navigation commands needed + - **File Creation Context**: Document exactly where files will be created and how to verify correct placement + - **Multi-project Context**: For umbrella projects or monorepos, clearly identify which sub-project or application the task applies to and its relationship to current working directory + - **Directory Context Validation**: Include validation steps to ensure agents are working in correct directory context throughout task execution + - **Context Verification Commands**: Include `pwd`, `ls -la`, and other commands to verify correct directory context + - **Path Resolution Validation**: Verify that file paths resolve correctly from the intended directory context + - **Target Directory Confirmation**: Confirm that target directories exist and are accessible from current working directory - Each task must include specific acceptance criteria - Provide effort estimates in hours/days with justification - Identify all dependencies between tasks and phases @@ -425,7 +470,11 @@ When generating prompts: 7. **Enable Review**: Ensure the resulting plan will be reviewable by stakeholders 8. **Focus on Action**: Generate prompts that lead to actionable, implementable plans 9. **Enforce Data Flow**: Ensure proper data flow patterns and prevent anti-patterns in all recommendations -10. **Clean Output**: Output ONLY the prompt itself without any introductory or explanatory text +10. **CRITICAL: Working Directory Context**: **MANDATORY** - Always emphasize the need to establish correct working directory context to prevent file placement errors + - **Context Confusion Prevention**: Explicitly instruct agents to distinguish between current working directory and project root + - **Directory Relationship Documentation**: Require clear documentation of directory relationships and target implementation context + - **Path Resolution Clarity**: Ensure all file paths are specified with explicit context about which directory they are relative to +11. **Clean Output**: Output ONLY the prompt itself without any introductory or explanatory text **CRITICAL SUCCESS FACTOR**: The generated task plan must include all user-provided information that is required for task implementation. Analyze what information is necessary to complete the task successfully, then ensure all relevant URLs, names, values, commands, paths, or implementation details are preserved in the task plan. diff --git a/conf/llm/docs/coding-rules.md b/conf/llm/docs/coding-rules.md index 911fe4ba..3800b727 100644 --- a/conf/llm/docs/coding-rules.md +++ b/conf/llm/docs/coding-rules.md @@ -90,6 +90,7 @@ - Avoid making major changes to the patterns and architecture of how a feature works, after it has shown to work well, unless explicitly instructed - Always think about what other methods and areas of code might be affected by code changes - After each code change, commit the changes following conventional commit for the git message +- Always provide absolute file paths to MCP tools to avoid permission errors ## Testing convention From 3ea77dcf0826627f3e9106f9fb167ce4aa711df3 Mon Sep 17 00:00:00 2001 From: Towry Wang Date: Sun, 15 Jun 2025 20:02:03 +0800 Subject: [PATCH 05/10] refactor: simplify jj.nix aliases Review notes: - Cleaner alias structure with reduced redundancy - Renamed 'mcon' to more descriptive 'split-on' - Consolidated squash operations under 'sq' alias - No functional changes detected - Consider adding comments explaining complex aliases --- nix/hm/jj.nix | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/nix/hm/jj.nix b/nix/hm/jj.nix index a07582f1..1deb9a22 100644 --- a/nix/hm/jj.nix +++ b/nix/hm/jj.nix @@ -351,15 +351,11 @@ in "-n" "8" ]; - sq = [ - "squash" - "-u" - ]; unsq = [ "squash" "--restore-descendants" ]; - mcon = [ + split-on = [ "split" "-i" "-d" @@ -388,7 +384,7 @@ in '' "" ]; - mvc = [ + sq = [ "squash" "-k" "-u" From 55d206741204f35c34ceecd11a39695bf939e52d Mon Sep 17 00:00:00 2001 From: Towry Wang Date: Sun, 15 Jun 2025 20:42:12 +0800 Subject: [PATCH 06/10] refactor: consolidate jj fork commands into single file Review notes: - Good consolidation of duplicate functionality from jj-fork-main.fish and jj-fork-master.fish into jj-fork.fish - Clean removal of redundant files - Consider adding comments explaining the fork command behavior - Verify all git branch operations work as expected after refactor - Nix configuration update matches the new file structure --- conf/fish/funcs/jj-fork-main.fish | 51 +----------- conf/fish/funcs/jj-fork-master.fish | 47 +---------- conf/fish/funcs/jj-fork.fish | 117 ++++++++++++++++++++++++++++ nix/hm/jj.nix | 4 +- 4 files changed, 124 insertions(+), 95 deletions(-) create mode 100644 conf/fish/funcs/jj-fork.fish diff --git a/conf/fish/funcs/jj-fork-main.fish b/conf/fish/funcs/jj-fork-main.fish index c3905d0d..aeda5c86 100755 --- a/conf/fish/funcs/jj-fork-main.fish +++ b/conf/fish/funcs/jj-fork-main.fish @@ -22,53 +22,6 @@ function jj-fork-main --description "Fork main branch" return 1 end - set -l description $_flag_description - jj git fetch -b main > /dev/null 2>&1 - or return - - # create bookmark name from aichat - echo "Generating bookmark name..." - set -l bookmark_name (aichat --role git-branch -S -c "$description") - or return - - set -l date_now (date +%m%d%H) - set -l bookmark_name "$bookmark_name-$date_now" - - # check if the bookmark name is already used - # by running jj log -r $bookmark_name -n 1 - # if no error, then the bookmark name is already used - # exit with error msg - jj --ignore-working-copy log -r $bookmark_name -n 1 > /dev/null 2>&1 - if test $status -eq 0 - echo "Bookmark name $bookmark_name is already used" - return 1 - end - - # 确保我们能捕获所有输出,包括stderr - set -l output (jj new --ignore-working-copy --no-pager --no-edit -r main@origin -m "$description" 2>&1) - if test $status -ne 0 - echo "Failed to create new revision" - return 1 - end - - # 将输出按行分割,然后在每行中查找commit ID - set -l rev - for line in (string split \n -- $output) - set -l match (string match -r 'Created new commit ([a-z]+)' $line) - if test (count $match) -eq 2 - set rev $match[2] - break - end - end - - if test -z "$rev" - echo "Failed to extract revision ID from output: $output" - return 1 - end - - echo "Created new revision: $rev" - - echo "Creating bookmark point to $rev: $bookmark_name" - jj bookmark set -r $rev "$bookmark_name" - or return + # Use the generic jj-fork function with main bookmark + jj-fork -d $_flag_description -b main end diff --git a/conf/fish/funcs/jj-fork-master.fish b/conf/fish/funcs/jj-fork-master.fish index 389f3aa8..da81c7ff 100644 --- a/conf/fish/funcs/jj-fork-master.fish +++ b/conf/fish/funcs/jj-fork-master.fish @@ -22,49 +22,6 @@ function jj-fork-master --description "Fork master branch" return 1 end - set -l description $_flag_description - jj --ignore-working-copy git fetch -b master > /dev/null 2>&1 - or return - - # create bookmark name from aichat - echo "Generating bookmark name..." - set -l bookmark_name (aichat --role git-branch -S -c "$description") - or return - - set -l date_now (date +%m%d%H) - set -l bookmark_name "$bookmark_name-$date_now" - - jj log --ignore-working-copy --quiet -r $bookmark_name -n 1 > /dev/null 2>&1 - if test $status -eq 0 - echo "Bookmark name $bookmark_name is already used" - return 1 - end - - # 确保我们能捕获所有输出,包括stderr - set -l output (jj new --ignore-working-copy --no-pager --no-edit -r master@origin -m "$description" 2>&1) - if test $status -ne 0 - echo "Failed to create new revision" - return 1 - end - - # 将输出按行分割,然后在每行中查找commit ID - set -l rev - for line in (string split \n -- $output) - set -l match (string match -r 'Created new commit ([a-z]+)' $line) - if test (count $match) -eq 2 - set rev $match[2] - break - end - end - - if test -z "$rev" - echo "Failed to extract revision ID from output: $output" - return 1 - end - - echo "Created new revision: $rev" - - echo "Creating bookmark point to $rev: $bookmark_name" - jj bookmark set -r $rev "$bookmark_name" - or return + # Use the generic jj-fork function with master bookmark + jj-fork -d $_flag_description -b master end diff --git a/conf/fish/funcs/jj-fork.fish b/conf/fish/funcs/jj-fork.fish new file mode 100644 index 00000000..5d2f1a17 --- /dev/null +++ b/conf/fish/funcs/jj-fork.fish @@ -0,0 +1,117 @@ +# generic jj-fork function +# take arguments -b for bookmark name, -r for revision. +# if -b is provided, run git fetch first +# if -r is provided, run jj new with the revision + +function jj-fork --description "Fork from a bookmark or revision" + argparse 'h/help' 'd/description=' 'b/bookmark=' 'r/revision=' 'no-new' -- $argv + or return + + # set help string + set -l help_string "Usage: jj-fork -d [-b |-r ] [--no-new] + -d, --description Description for the new revision + -b, --bookmark Bookmark to fork from (will fetch from origin) + -r, --revision Revision to fork from (local revision) + --no-new Create bookmark on existing revision without creating new commit + -h, --help Show this help" + + if set -ql _flag_help + echo $help_string + return 0 + end + + if not set -q _flag_description + echo "Error: Description is required" + echo $help_string + return 1 + end + + # Ensure either bookmark or revision is provided, but not both + if set -q _flag_bookmark; and set -q _flag_revision + echo "Error: Cannot specify both bookmark and revision" + echo $help_string + return 1 + end + + if not set -q _flag_bookmark; and not set -q _flag_revision + echo "Error: Must specify either bookmark or revision" + echo $help_string + return 1 + end + + set -l description $_flag_description + set -l source_ref + + # Handle bookmark case - fetch from origin + if set -q _flag_bookmark + set -l bookmark $_flag_bookmark + echo "Fetching bookmark: $bookmark" + jj --ignore-working-copy git fetch -b $bookmark > /dev/null 2>&1 + or return + set source_ref "$bookmark@origin" + end + + # Handle revision case - use local revision + if set -q _flag_revision + set source_ref $_flag_revision + end + + # Generate bookmark name from aichat + echo "Generating bookmark name..." + set -l bookmark_name (aichat --role git-branch -S -c "$description") + or return + + set -l date_now (date +%m%d%H) + set -l bookmark_name "$bookmark_name-$date_now" + + # Check if the bookmark name is already used + jj --ignore-working-copy log --quiet -r $bookmark_name -n 1 > /dev/null 2>&1 + if test $status -eq 0 + echo "Bookmark name $bookmark_name is already used" + return 1 + end + + set -l rev + + # If --no-new flag is set, use the source revision directly + if set -q _flag_no_new + echo "Creating bookmark on existing revision $source_ref..." + set rev $source_ref + else + # Create new revision + echo "Creating new revision from $source_ref..." + set -l output (jj new --ignore-working-copy --no-pager --no-edit -r $source_ref -m "$description" 2>&1) + if test $status -ne 0 + echo "Failed to create new revision" + echo $output + return 1 + end + + # Extract revision ID from output + for line in (string split \n -- $output) + set -l match (string match -r 'Created new commit ([a-z]+)' $line) + if test (count $match) -eq 2 + set rev $match[2] + break + end + end + + if test -z "$rev" + echo "Failed to extract revision ID from output: $output" + return 1 + end + + echo "Created new revision: $rev" + end + + # Create bookmark pointing to the revision + echo "Creating bookmark pointing to $rev: $bookmark_name" + jj bookmark set -r $rev "$bookmark_name" + or return + + if set -q _flag_no_new + echo "Successfully created bookmark '$bookmark_name' pointing to existing revision $rev" + else + echo "Successfully created bookmark '$bookmark_name' pointing to revision $rev" + end +end diff --git a/nix/hm/jj.nix b/nix/hm/jj.nix index 1deb9a22..61c0c073 100644 --- a/nix/hm/jj.nix +++ b/nix/hm/jj.nix @@ -334,7 +334,6 @@ in ]; rb = [ "rebase" - "--skip-emptied" ]; ds = [ "desc" @@ -903,6 +902,9 @@ in ".config/fish/functions/jj-mega-merge.fish" = { source = ../../conf/fish/funcs/jj-mega-merge.fish; }; + ".config/fish/functions/jj-fork.fish" = { + source = ../../conf/fish/funcs/jj-fork.fish; + }; ".config/fish/functions/jj-fork-main.fish" = { source = ../../conf/fish/funcs/jj-fork-main.fish; }; From bfc41f490e6b1668226a3f680b3f154f75404e26 Mon Sep 17 00:00:00 2001 From: Towry Wang Date: Mon, 16 Jun 2025 10:57:38 +0800 Subject: [PATCH 07/10] feat: add ai-commit wrapper script with error handling Review notes: - Script properly implements error handling with set -euo pipefail - Good separation of pipeline components into variables - Consider adding logging for debugging purposes - Missing error handling for aichat command failure - Recommend adding validation for script dependencies - Good practice to include script usage documentation in header --- conf/bash/scripts/ai-commit-wrapper.sh | 20 ++++++++++++++++++++ nix/hm/git.nix | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 conf/bash/scripts/ai-commit-wrapper.sh diff --git a/conf/bash/scripts/ai-commit-wrapper.sh b/conf/bash/scripts/ai-commit-wrapper.sh new file mode 100755 index 00000000..35cc2344 --- /dev/null +++ b/conf/bash/scripts/ai-commit-wrapper.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +# Wrapper script for ai-commit that properly handles pipeline failures +# This ensures that if any step in the pipeline fails, the entire process stops + +set -euo pipefail + +# Get the directory where this script is located +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Define the pipeline components +CONTEXT_SCRIPT="${SCRIPT_DIR}/git-commit-context.sh" +CHUNK_SCRIPT="${SCRIPT_DIR}/git-commit-chunk-text.sh" + +# First, run the context script and capture its output +# If it fails, the script will exit here due to set -e +context_output=$("$CONTEXT_SCRIPT") + +# If we get here, the context script succeeded, so continue with the pipeline +echo "$context_output" | aichat --role git-commit -S | "$CHUNK_SCRIPT" diff --git a/nix/hm/git.nix b/nix/hm/git.nix index 8ae81482..ba5f5a23 100644 --- a/nix/hm/git.nix +++ b/nix/hm/git.nix @@ -11,7 +11,7 @@ let in { programs.fish.shellAliases = { - ai-commit = "${bashScriptsDir}/git-commit-context.sh | aichat --role git-commit -S | ${bashScriptsDir}/git-commit-chunk-text.sh"; + ai-commit = "${bashScriptsDir}/ai-commit-wrapper.sh"; gcd = "cd-gitroot"; git-conflict-rm = "git status | grep 'deleted by us' | sed 's/deleted by us: //' | xargs git rm"; g = "git"; @@ -311,6 +311,7 @@ in ".direnv/" "Session.vim" ".pyo" + ".goose/" "dist/" ".netrwhist" ".netrwhist~" From 80f1a9a2065b6351c77a010f64d055128b3ece11 Mon Sep 17 00:00:00 2001 From: Towry Wang Date: Mon, 16 Jun 2025 15:50:45 +0800 Subject: [PATCH 08/10] style: update ghostty theme and font size Changed terminal theme from dracula to builtin pastel variants and increased font size from 16 to 17. --- conf/ghostty/config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/ghostty/config b/conf/ghostty/config index f2eec362..8a21aabb 100644 --- a/conf/ghostty/config +++ b/conf/ghostty/config @@ -3,13 +3,13 @@ # https://github.com/ghostty-org/ghostty/blob/b8ffee7acbdd5ee97953f6e6d02e047d4bfda37b/src/input/key.zig#L255 -theme = dark:dracula,light:dracula +theme = dark:Builtin Pastel Dark,light:Builtin Pastel Light font-family = "Berkeley Mono" window-title-font-family = "PT Sans" font-feature = "+calt" # font-family = "Maple Mono" # font-feature = "-zero, +calt, +cv01, +ss03, +ss06, +ss02, -cv35" -font-size = 16 +font-size = 17 font-thicken = false font-codepoint-map = U+4E00-U+9FFF,U+3400-U+4DBF=LXGW WenKai Mono shell-integration-features = no-cursor,sudo,no-title From 5c6aab52d247ee8aee8a6284848aec190d7537c8 Mon Sep 17 00:00:00 2001 From: Towry Wang Date: Mon, 16 Jun 2025 17:20:06 +0800 Subject: [PATCH 09/10] feat(llm): add multiple MCP configurations and private keys Added new Model Context Protocol (MCP) configurations including Context7, server-memory, playwright, deepwiki, filesystem, github, and brave-search integrations. Also added private keys documentation file. Review notes: - Configurations appear properly structured with required parameters - Consider adding descriptions for all MCP services for better maintainability - Ensure all sensitive keys (GITHUB_PERSONAL_ACCESS_TOKEN, BRAVE_API_KEY) are properly secured - Verify timeout values (300ms) are appropriate for each service - Consider adding validation for required environment variables --- conf/llm/aichat/roles/gen-prompt.md | 27 ++++++--- conf/llm/docs/coding-rules.md | 3 + conf/llm/goose/config.yaml | 87 +++++++++++++++++++++++++++++ conf/private_keys.md | 21 +++++++ flake.lock | 17 ++++++ flake.nix | 4 ++ 6 files changed, 152 insertions(+), 7 deletions(-) create mode 100644 conf/private_keys.md diff --git a/conf/llm/aichat/roles/gen-prompt.md b/conf/llm/aichat/roles/gen-prompt.md index d98ddaaf..4997d984 100644 --- a/conf/llm/aichat/roles/gen-prompt.md +++ b/conf/llm/aichat/roles/gen-prompt.md @@ -192,6 +192,12 @@ Please write an agent task plan in markdown file suffix with `-task-plan.md` in - **SRP Violation Detection**: Look for modules that mix concerns by searching for infrastructure + business logic patterns in the same files - **Interface Boundary Analysis**: Examine how different modules communicate to understand current layer boundaries and communication patterns - **Pure Function Identification**: Identify existing pure functions vs functions with side effects to understand current concern separation patterns +- **MANDATORY MCP CONTEXT7 DOCUMENTATION TOOLS**: **CRITICAL** for accessing latest official documentation: + - **Library Documentation Lookup**: Use `mcp_context7_resolve-library-id` to find Context7-compatible library IDs for any frameworks or libraries identified in the codebase + - **Official Documentation Retrieval**: Use `mcp_context7_get-library-docs` to access up-to-date official documentation, API references, and best practices + - **Integration Pattern Research**: Use Context7 to understand official integration patterns, configuration examples, and recommended architectures + - **Version-Specific Guidance**: Access documentation for specific library versions to ensure compatibility with existing project dependencies + - **Security Best Practices**: Retrieve official security guidelines and recommended practices from library maintainers via Context7 **Technical Research Requirements:** - Research and recommend current industry-standard technologies and frameworks **that are compatible with the existing project setup** @@ -200,6 +206,12 @@ Please write an agent task plan in markdown file suffix with `-task-plan.md` in - Consider modern development workflows, CI/CD practices, and deployment strategies **already in use or compatible with current setup** - **USE WEB SEARCH**: Search the web for latest trends, best practices, and technology comparisons - **USE GITHUB SEARCH**: Use GitHub MCP tools to find and evaluate suitable libraries, frameworks, and code examples +- **USE MCP CONTEXT7**: **CRITICAL** - Use MCP Context7 to retrieve the latest official documentation for libraries and frameworks + - **Library Documentation Retrieval**: For any library or framework mentioned in the task, use Context7 to get the most up-to-date official documentation + - **API Reference Access**: Leverage Context7 to access current API references, best practices, and implementation guides + - **Framework Integration Guidance**: Use Context7 to understand proper integration patterns and recommended approaches from official sources + - **Version-Specific Documentation**: Access documentation for specific versions when needed to ensure compatibility + - **Official Best Practices**: Retrieve official guidelines and recommended patterns directly from library maintainers - **LIBRARY EVALUATION**: Research GitHub repositories for popularity, maintenance status, and community adoption **Expected Task Plan Structure:** @@ -320,7 +332,7 @@ Use this markdown template for your task plan: - **Anti-Pattern Prevention**: [Prevent passing entire context objects, component instances (`this`), or stores when only specific values are needed] - **API Contract Documentation**: [Ensure each parameter has a clear, single purpose evident from parameter name and documentation] - **Tasks**: - 1. [Research and evaluate libraries/frameworks using web search and GitHub tools] + 1. [**CRITICAL: Documentation Research** - Use MCP Context7 to retrieve latest official documentation for all libraries/frameworks, then use web search and GitHub tools for additional evaluation] 2. [Detailed task with clear acceptance criteria and specific file paths] 3. [Next task with dependencies clearly noted and target locations specified] - **File Placement Strategy**: [**CRITICAL** - Specify exactly where new files will be created with explicit directory context] @@ -334,14 +346,15 @@ Use this markdown template for your task plan: ### Phase N: [Continue for all phases] ## Technical Architecture -- **Technology Stack**: [Modern, justified technology choices that integrate with existing project setup, with latest stable versions researched via web and GitHub] +- **Technology Stack**: [Modern, justified technology choices that integrate with existing project setup, with latest stable versions researched via Context7, web, and GitHub] +- **Documentation-Driven Design**: [**CRITICAL** - Use MCP Context7 to access official documentation for architectural decisions, ensuring all design choices follow latest official guidelines and best practices] - **System Design**: [High-level architecture using contemporary design patterns that complement existing codebase structure and follow proper data flow principles] - **Data Flow Architecture**: [Design explicit component interfaces with props down, events up pattern] -- **Integration Strategy**: [How new components will integrate with existing systems, APIs, and workflows while maintaining proper data flow] +- **Integration Strategy**: [How new components will integrate with existing systems, APIs, and workflows while maintaining proper data flow, guided by official documentation retrieved via Context7] - **Data Flow**: [Key data interactions and flow with modern protocols, respecting existing data patterns and preventing anti-patterns] -- **Security Considerations**: [Current security best practices, auth, encryption, compliance that work with existing security model] -- **Modern Practices**: [Current industry standards, DevOps practices, and architectural patterns compatible with existing development workflow] -- **Library Selection**: [Researched GitHub repositories with stars, maintenance status, community adoption metrics, and compatibility with existing dependencies] +- **Security Considerations**: [Current security best practices, auth, encryption, compliance that work with existing security model, validated against official security documentation via Context7] +- **Modern Practices**: [Current industry standards, DevOps practices, and architectural patterns compatible with existing development workflow, informed by latest official documentation] +- **Library Selection**: [Researched via Context7 for official documentation, GitHub repositories with stars, maintenance status, community adoption metrics, and compatibility with existing dependencies] ## Testing Strategy - **Unit Testing**: [Coverage approach and tools, including data flow testing] @@ -425,7 +438,7 @@ Use this markdown template for your task plan: - **MODERN TECHNICAL RESEARCH**: Include current best practices, latest stable versions, and contemporary architectural patterns that are compatible with existing setup - **CURRENT TECH STACK**: Recommend modern, well-supported technologies and frameworks that integrate well with existing project infrastructure - **ARCHITECTURE DESIGN**: Provide detailed system architecture using current design patterns that complement existing codebase structure and enforce proper data flow -- **RESEARCH-DRIVEN DECISIONS**: Use web search and GitHub tools to validate technology choices and find optimal libraries that work with existing dependencies +- **RESEARCH-DRIVEN DECISIONS**: **MANDATORY** - Use MCP Context7 to retrieve official documentation first, then validate technology choices with web search and GitHub tools to find optimal libraries that work with existing dependencies - **EVIDENCE-BASED RECOMMENDATIONS**: Include GitHub stars, maintenance activity, community feedback, and compatibility analysis in technology selection **Output Format:** diff --git a/conf/llm/docs/coding-rules.md b/conf/llm/docs/coding-rules.md index 3800b727..3f9aaf73 100644 --- a/conf/llm/docs/coding-rules.md +++ b/conf/llm/docs/coding-rules.md @@ -91,6 +91,9 @@ - Always think about what other methods and areas of code might be affected by code changes - After each code change, commit the changes following conventional commit for the git message - Always provide absolute file paths to MCP tools to avoid permission errors +- Prefer to use `fd` to search for files and `rg` to search for content in files +- Use MCP context7 to search for library and framework documentation +- Use MCP github-mcp-server to search for code in the github repository ## Testing convention diff --git a/conf/llm/goose/config.yaml b/conf/llm/goose/config.yaml index 6975b864..608c8d11 100644 --- a/conf/llm/goose/config.yaml +++ b/conf/llm/goose/config.yaml @@ -20,6 +20,93 @@ extensions: name: tutorial timeout: 500 type: builtin + ## MCPs + context7: + args: + - '@upstash/context7-mcp' + bundled: null + cmd: bunx + description: Connects to Context7.com's documentation database to provide up-to-date library and framework documentation with intelligent project ranking and customizable token limits. + enabled: true + env_keys: [] + envs: {} + name: context7 + timeout: 300 + type: stdio + "@modelcontextprotocol/server-memory": + args: + - "@modelcontextprotocol/server-memory" + bundled: null + cmd: bunx + description: Connects to the memory of the current session. + enabled: true + env_keys: [] + envs: {} + name: "@modelcontextprotocol/server-memory" + timeout: 300 + type: stdio + "@executeautomation/playwright-mcp-server": + args: + - "@executeautomation/playwright-mcp-server" + bundled: null + cmd: bunx + description: null + enabled: true + env_keys: [] + envs: {} + name: "@executeautomation/playwright-mcp-server" + timeout: 300 + type: stdio + mcp-deepwiki: + args: + - mcp-deepwiki@latest + bundled: null + cmd: bunx + description: null + enabled: true + env_keys: [] + envs: {} + name: mcp-deepwiki + timeout: 300 + type: stdio + "filesystem": + args: + - "@modelcontextprotocol/server-filesystem" + - "/Users/towry/workspace" + bundled: null + cmd: bunx + description: null + enabled: true + env_keys: [] + envs: {} + name: "@modelcontextprotocol/server-filesystem" + timeout: 300 + type: stdio + "github-mcp-server": + args: + - stdio + - --toolsets + - all + bundled: null + enabled: true + env_keys: ["GITHUB_PERSONAL_ACCESS_TOKEN"] + envs: {} + cmd: github-mcp-server + name: github-mcp-server + timeout: 300 + type: stdio + brave-search: + args: + - "@modelcontextprotocol/server-brave-search" + bundled: null + cmd: bunx + description: null + enabled: true + env_keys: ["BRAVE_API_KEY"] + envs: {} + name: brave-search + timeout: 300 + type: stdio GOOSE_MODE: auto GOOSE_PROVIDER: github_copilot GOOSE_MODEL: gpt-4o diff --git a/conf/private_keys.md b/conf/private_keys.md new file mode 100644 index 00000000..3af4358c --- /dev/null +++ b/conf/private_keys.md @@ -0,0 +1,21 @@ + +```bash +export HEX_MIRROR="https://hexpm.upyun.com" +export HEX_CDN="https://hexpm.upyun.com" + +export SLACK_BOT_TOKEN="xxx" +export SLACK_APP_TOKEN="xxx" + + +export DEEPSEEK_API_KEY="xxx" +export ARK_API_KEY="xxx" + +export INFLUXDB_V2_TOKEN="xxx" +export INFLUXDB_HOST="127.0.0.1" +export NPM_TOKEN="xxx" + +export GITLAB_HOST="https://git.domain.com" +export GITLAB_TOKEN="xxx" +export GITHUB_PERSONAL_ACCESS_TOKEN="xxx" +export BRAVE_API_KEY="xxx" +``` diff --git a/flake.lock b/flake.lock index 22daa4fc..60fc469a 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,21 @@ { "nodes": { + "asdf-elixir": { + "flake": false, + "locked": { + "lastModified": 1747660407, + "narHash": "sha256-EHNInilc3KSZ1T/L78m8lu/QiLHwnB0iBuqkrHgKWkQ=", + "owner": "asdf-vm", + "repo": "asdf-elixir", + "rev": "89098d5c31fd3a240a25b1dacf881a6eeed426c4", + "type": "github" + }, + "original": { + "owner": "asdf-vm", + "repo": "asdf-elixir", + "type": "github" + } + }, "cl-nix-lite": { "locked": { "lastModified": 1728174978, @@ -597,6 +613,7 @@ }, "root": { "inputs": { + "asdf-elixir": "asdf-elixir", "darwin": "darwin", "fenix": "fenix", "git-smash": "git-smash", diff --git a/flake.nix b/flake.nix index 9ed6ceef..3d954b1c 100644 --- a/flake.nix +++ b/flake.nix @@ -47,6 +47,10 @@ url = "git+ssh://git@github.com/pze/jj.git?shallow=1"; inputs.nixpkgs.follows = "nixpkgs"; }; + asdf-elixir = { + url = "github:asdf-vm/asdf-elixir"; + flake = false; + }; }; outputs = From d7b0a383e222cd9911b29cf0385c66c90b70bc17 Mon Sep 17 00:00:00 2001 From: Towry Wang Date: Mon, 16 Jun 2025 22:23:40 +0800 Subject: [PATCH 10/10] refactor(hm): update elixir and fish configuration - Switch elixir version management to asdf - Add asdf path configuration to fish shell - Clean up fish function formatting Review notes: - No bugs found in the configuration changes - Good move to asdf for version management - Fish shell path handling is implemented correctly - Consider adding comments explaining the asdf setup rationale - Recommend verifying asdf plugin installation in CI --- flake.lock | 17 +++++++++++++++++ flake.nix | 4 ++++ nix/darwin/apps.nix | 2 ++ nix/hm/elixir.nix | 32 ++++++++++++++++++++++++-------- nix/hm/fish.nix | 20 +++++++++++++++++--- 5 files changed, 64 insertions(+), 11 deletions(-) diff --git a/flake.lock b/flake.lock index 60fc469a..267581ee 100644 --- a/flake.lock +++ b/flake.lock @@ -16,6 +16,22 @@ "type": "github" } }, + "asdf-erlang": { + "flake": false, + "locked": { + "lastModified": 1745851456, + "narHash": "sha256-RHBBmuHqYKNTOgeRA+AB/NGG8ahWHxJ4qRLODy3t+6A=", + "owner": "asdf-vm", + "repo": "asdf-erlang", + "rev": "5f27baa62864bb433be9c7f2f7d69b475f534376", + "type": "github" + }, + "original": { + "owner": "asdf-vm", + "repo": "asdf-erlang", + "type": "github" + } + }, "cl-nix-lite": { "locked": { "lastModified": 1728174978, @@ -614,6 +630,7 @@ "root": { "inputs": { "asdf-elixir": "asdf-elixir", + "asdf-erlang": "asdf-erlang", "darwin": "darwin", "fenix": "fenix", "git-smash": "git-smash", diff --git a/flake.nix b/flake.nix index 3d954b1c..d8ea35e2 100644 --- a/flake.nix +++ b/flake.nix @@ -51,6 +51,10 @@ url = "github:asdf-vm/asdf-elixir"; flake = false; }; + asdf-erlang = { + url = "github:asdf-vm/asdf-erlang"; + flake = false; + }; }; outputs = diff --git a/nix/darwin/apps.nix b/nix/darwin/apps.nix index 00c542ba..c184f446 100644 --- a/nix/darwin/apps.nix +++ b/nix/darwin/apps.nix @@ -7,6 +7,8 @@ # brave # ice-bar net-news-wire + # elixir + # elixir-ls ]; homebrew = { diff --git a/nix/hm/elixir.nix b/nix/hm/elixir.nix index 0031e2cb..d9eef3e6 100644 --- a/nix/hm/elixir.nix +++ b/nix/hm/elixir.nix @@ -1,11 +1,27 @@ -{ ... }: +{ pkgs, inputs, ... }: { - imports = [ - ../modules/elixir.nix + # imports = [ + # ../modules/elixir.nix + # ]; + # elixir.enable = true; + home.packages = [ + pkgs.erlang ]; - elixir.enable = true; - home.file.".tool-versions".text = '' - elixir system - erlang system - ''; + home.file = { + ".tool-versions".text = '' + elixir 1.18.4-otp-27 + erlang system + ''; + + asdf-elixir = { + source = inputs.asdf-elixir; + target = "./.asdf/plugins/elixir"; + recursive = true; + }; + asdf-erlang = { + source = inputs.asdf-erlang; + target = "./.asdf/plugins/erlang"; + recursive = true; + }; + }; } diff --git a/nix/hm/fish.nix b/nix/hm/fish.nix index e72a97fd..46911456 100644 --- a/nix/hm/fish.nix +++ b/nix/hm/fish.nix @@ -192,6 +192,20 @@ -p _fifc_preview_process \ -o _fifc_open_process \ -e '^\\h*([0-9]+)' + + # ASDF configuration code + if test -z $ASDF_DATA_DIR + set _asdf_shims "$HOME/.asdf/shims" + else + set _asdf_shims "$ASDF_DATA_DIR/shims" + end + + # Do not use fish_add_path (added in Fish 3.2) because it + # potentially changes the order of items in PATH + if not contains $_asdf_shims $PATH + set -gx --prepend PATH $_asdf_shims + end + set --erase _asdf_shims ''; ## do not forget to run fish --login to generate new fish_variables file. # https://github.com/LnL7/nix-darwin/issues/122 @@ -483,7 +497,7 @@ ''; description = "Cd into current opened finder"; }; - fstatus = { + fstatus = { body = '' # Ensure we are in a git repository set git_root (git rev-parse --show-toplevel) @@ -510,8 +524,8 @@ --bind "ctrl-d:preview-page-down" ''; description = "Use fzf to browse current unstaged changes"; - }; - just-pick-status-file = { + }; + just-pick-status-file = { body = '' # Ensure we are in a git repository if not git rev-parse --is-inside-work-tree >/dev/null 2>&1