Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion conf/bash/scripts/jj-split-on-bookmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ perform_split() {
if "$AI_COMMIT_CONTEXT_SCRIPT" "$rev" | aichat --role git-commit -S -c | "$JJ_AI_COMMIT_SCRIPT" "$rev"; then
echo "Successfully applied AI-generated commit message to revision: $rev"
else
echo "Warning: AI commit message generation failed, keeping default message" >&2
ai_exit_code=$?
echo "Warning: AI commit message generation failed (exit code: $ai_exit_code), keeping default message" >&2
fi
fi

Expand Down
64 changes: 48 additions & 16 deletions conf/fish/funcs/_fzf-jj-bookmarks.fish
Original file line number Diff line number Diff line change
@@ -1,21 +1,53 @@
function _fzf-jj-bookmarks --description "Search for jujutsu bookmarks"
jj root --quiet &>/dev/null; or return
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 \
--scheme=path \
--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)
function _fzf-jj-bookmarks --description "Search for jujutsu bookmarks or git branches"
# Get the current token as initial query
set -l query ""
if status is-interactive
set query (commandline --current-token)
end

# Try jj first
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 \
--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
end
# Fallback to git if not in a jj repo
else 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 bookmark (echo $lines | cut -d: -f1 | string trim)
if status is-interactive
commandline --current-token --replace $bookmark
commandline --function repaint
else
echo $bookmark
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
end
else
echo "Not in a jj or git repository" >&2
return 1
end
end

Expand Down
2 changes: 1 addition & 1 deletion conf/fish/funcs/jj-fork-main.fish
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function jj-fork-main --description "Fork main branch"
set -l bookmark_name (aichat --role git-branch -S -c "$description")
or return

set -l date_now (date +%m%d)
set -l date_now (date +%m%d%H)
set -l bookmark_name "$bookmark_name-$date_now"

# check if the bookmark name is already used
Expand Down
2 changes: 1 addition & 1 deletion conf/fish/funcs/jj-fork-master.fish
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function jj-fork-master --description "Fork master branch"
set -l bookmark_name (aichat --role git-branch -S -c "$description")
or return

set -l date_now (date +%m%d)
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
Expand Down
113 changes: 108 additions & 5 deletions conf/llm/aichat/roles/gen-prompt.md

Large diffs are not rendered by default.

80 changes: 80 additions & 0 deletions conf/llm/docs/coding-rules.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Coding Rules

## General coding preferences

- Do not add sensitive information about the user or the user's machine to the code or comments
- Use SOLID principles whenever possible, but do not religiously follow them
- Break down large tasks into smaller steps. After completing each step, verify it works before continuing. Do not attempt to complete the entire task in one pass without intermediate validation.
- Prefer rg or fd command when grepping file content or searching for files
- Before running a package manager in the project, please detect which package manager is currently being used, like npm or pnpm
- You can run killport <port> to kill the process that owns a port
- Follow the DRY coding rule
- Never use a variable or method that you are not sure exists
- Do not change the implementation to satisfy the tests
- Consider the impact of changes across the module or file
- Avoid duplicating logic across abstraction boundaries
- Consolidate similar logic into reusable functions
- Maintain a single source of truth for business rules
- Make function contracts clear
- First ,makethe code correct, then make it efficient
- When refactoring, validate behavior preservation
- Favor explicit control flow over hidden dependencies
- Preserve existing code structures and adhere to project coding styles, unless the existing code is flawed.
- Whether responding in code comments, documentation, or UI prompts, always aim to be concise and focused. Eliminate unnecessary details that don't aid understanding or action
- Never remove or modify code in a way that could break existing functionality without fully understanding how those changes will affect the code.
- Please feel free to ask for help if you need more details to decide.
- When searching for relevant modules, first look for relevant files by their file names. Then, use grep to search for specific content. Utilize the fd command to list files in a case-insensitive manner.
- When searching for relevant modules or components in a directory, make sure your search is case insensitive to achieve broader results.
- In Agent mode, automatically apply edits without prompting for confirmation on the first pass
- Always check your implementation and changes against the available documentation or existing code to ensure accuracy and adherence to standards.
- Review the existing style and conventions used in the surrounding code to ensure that the new code aligns well and maintains readability.
- Do not rely on a single example; always verify consistent patterns to ensure accuracy and reliability.
- Avoid making assumptions about how components function without analyzing their actual usage.
- Avoid reproducing only part of a pattern; ensure all critical fields and behaviors are included to maintain integrity and accuracy.
- When changing existing code, do not remove code that you do not understand what it does
- Ensure error handling is consistent and graceful; prefer explicit error propagation over silent failure
- When adding significant logic or refactoring, update or write accompanying documentation if necessary
- Add or update tests to reflect critical logic paths affected by your changes
- Constants Over Magic Numbers
- Replace hard-coded values with named constants
- Use descriptive constant names that explain the value's purpose
- Keep constants at the top of the file or in a dedicated constants file
- Meaningful Names
- Variables, functions, and classes should reveal their purpose
- Names should explain why something exists and how it's used
- Avoid abbreviations unless they're universally understood
- Smart Comments
- Don't comment on what the code does - make the code self-documenting
- Use comments to explain why something is done a certain way
- Document APIs, complex algorithms, and non-obvious side effects

## Coding workflow preferences

- Focus on the areas of code relevant to the task
- Do not touch code that is unrelated to the task
- Follow Test-Driven Development (TDD) principles, i.e. start with the test and then implement the code
- 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

## Testing convention

- Behavior-Driven Development (BDD) testing methodology
- Clean code and test design principles
- Structure each test with clear GIVEN, WHEN, THEN sections
- Use descriptive test method names that reflect the scenario
- Implement test setup with meaningful variable names
- Ensure tests are isolated and focused on a single behavior
- If some files are needed to implement the test, ask the user to include them in the context
- Avoid deduplicating mock logic in tests; reimplement when needed to preserve clarity

### Tests Output Format

- Clear section comments (// GIVEN, // WHEN, // THEN)
- Create test methods using the BDD pattern
- Descriptive method and variable names
- Use `actual` as variable name if the tested method returns something
- Use `expected` as variable name for the expected output
- Helper methods prefixed with `given_` for test setup and `then_` for test assertions where appropriate


25 changes: 25 additions & 0 deletions conf/llm/goose/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
extensions:
developer:
bundled: true
display_name: Developer
enabled: true
name: developer
timeout: 300
type: builtin
memory:
bundled: true
display_name: Memory
enabled: true
name: memory
timeout: 500
type: builtin
tutorial:
bundled: true
display_name: Tutorial
enabled: true
name: tutorial
timeout: 500
type: builtin
GOOSE_MODE: auto
GOOSE_PROVIDER: github_copilot
GOOSE_MODEL: gpt-4o
6 changes: 3 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions nix/hm/ai.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ in
ollama
aider-chat
github-mcp-server
goose-cli
];

programs.fish = {
Expand All @@ -37,6 +38,15 @@ in
};
};

xdg.configFile = {
"goose/config.yaml" = {
source = ../../conf/llm/goose/config.yaml;
};
"goose/.goosehint" = {
source = ../../conf/llm/docs/coding-rules.md;
};
};

home.file = {
"${configDir}/roles" = {
# link to ../../conf/llm/aichat/roles dir
Expand Down
23 changes: 23 additions & 0 deletions nix/hm/docker.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
pkgs,
config,
lib,
...
}:
{
home.packages = with pkgs; [
## Docker
docker
docker-credential-helpers
colima
];

# Docker configuration can be added here
xdg.configFile = {
colima = {
enable = true;
source = ../../conf/colima;
recursive = true;
};
};
}
Loading