refactor: reorganize, add package (opencode, osgrep, beads), add ai agent shell

This commit is contained in:
Rasyidan Akbar F. 2025-12-09 15:09:05 +07:00
commit a0f0f39399
58 changed files with 7867 additions and 42 deletions

View file

@ -0,0 +1,13 @@
{ config, pkgs, lib, ... }: {
programs.fish = {
enable = true;
interactiveShellInit = ''
set -g fish_greeting ""
set -gx EDITOR nvim
set -gx VISUAL nvim
'';
};
# Ensure fish is available for login shells on Linux hosts.
home.packages = lib.mkAfter [ pkgs.fish ];
}

View file

@ -0,0 +1,187 @@
{ config, pkgs, lib, ... }:
let
profileBin = "${config.home.profileDirectory}/bin";
# System binaries path - same on both NixOS and Darwin
systemBin = "/run/current-system/sw/bin";
defaultBin = "/nix/var/nix/profiles/default/bin";
darwinHomebrewDir = if pkgs.stdenv.hostPlatform.isAarch64 then
"/opt/homebrew"
else
"/usr/local";
homebrewBin = "${darwinHomebrewDir}/bin";
homebrewSbin = "${darwinHomebrewDir}/sbin";
homebrewPaths = if pkgs.stdenv.hostPlatform.isDarwin then
lib.unique [ homebrewBin homebrewSbin ]
else
[ ];
# Add common macOS system paths that may contain user-installed CLIs
macosSystemPaths = if pkgs.stdenv.hostPlatform.isDarwin then [
"/usr/local/bin"
"/usr/bin"
"/bin"
"/usr/sbin"
"/sbin"
] else
[ ];
formatPathList = paths:
lib.concatMapStrings (path: " \"${path}\"\n") paths;
in {
imports = [ ./starship ];
programs.nushell.enable = lib.mkDefault true;
programs.nushell.extraConfig = ''
# Dotfiles QA validation command
def dotfiles-qa [] {
let dotfiles_dir = "${config.home.homeDirectory}/Development/dotfiles"
print $"(ansi green_bold)Running dotfiles QA validation...(ansi reset)\n"
# Step 1: Format check
print $"(ansi blue)1. Formatting nix files...(ansi reset)"
cd $dotfiles_dir
nix fmt .
if $env.LAST_EXIT_CODE != 0 {
print $"(ansi red_bold) Formatting failed(ansi reset)"
return
}
print $"(ansi green) Formatting complete(ansi reset)\n"
# Step 2: Flake check
print $"(ansi blue)2. Running flake check...(ansi reset)"
nix flake check
if $env.LAST_EXIT_CODE != 0 {
print $"(ansi red_bold) Flake check failed(ansi reset)"
return
}
print $"(ansi green) Flake check passed(ansi reset)\n"
# Step 3: Build (without activation)
print $"(ansi blue)3. Building darwin configuration (no activation)...(ansi reset)"
darwin-rebuild build --flake $"($dotfiles_dir)#macbook-pro"
if $env.LAST_EXIT_CODE != 0 {
print $"(ansi yellow) Build had warnings, but may still work(ansi reset)\n"
} else {
print $"(ansi green) Build successful(ansi reset)\n"
}
print $"(ansi green_bold) Core QA checks passed!(ansi reset)"
}
# Beads helper functions for AI agent workflows
# Safe Beads initialization with git repository check
def bd-init [] {
if not (".git" | path exists) and not (".git" | path type) == "dir" {
print $"(ansi red_bold)Error: Not in a git repository(ansi reset)"
print "Beads requires a git repository. Initialize git first:"
print " git init"
return
}
if (".beads" | path exists) {
print $"(ansi yellow)Beads already initialized in this project(ansi reset)"
return
}
print $"(ansi green)Initializing Beads...(ansi reset)"
bd init
if $env.LAST_EXIT_CODE == 0 {
print $"(ansi green_bold) Beads initialized successfully(ansi reset)"
print ""
print "Next steps:"
print " bd create --title \"Your task\" --type feature"
print " bd ready"
}
}
# View ready tasks with structured output
def bd-ready [] {
if not (".beads" | path exists) {
print $"(ansi red)Not a Beads project. Run 'bd-init' first.(ansi reset)"
return
}
let ready_tasks = (bd ready --json | from json)
if ($ready_tasks | is-empty) {
print $"(ansi yellow)No ready tasks(ansi reset)"
return
}
print $"(ansi green_bold)Ready Tasks:(ansi reset)\n"
$ready_tasks | each {|task|
print $"(ansi cyan)[$($task.id)](ansi reset) ($task.title)"
print $" Type: ($task.type) | Priority: ($task.priority) | Status: ($task.status)"
if ($task.description? != null) and ($task.description | str length) > 0 {
print $" ($task.description)"
}
print ""
} | ignore
}
# Sync Beads database with git
def bd-sync [] {
if not (".beads" | path exists) {
print $"(ansi red)Not a Beads project(ansi reset)"
return
}
print $"(ansi blue)Syncing Beads database...(ansi reset)"
bd sync
if $env.LAST_EXIT_CODE == 0 {
print $"(ansi green) Sync complete(ansi reset)"
}
}
'';
programs.nushell.envFile.text = ''
# Set XDG Base Directory environment variables
$env.XDG_CONFIG_HOME = "${config.xdg.configHome}"
$env.XDG_DATA_HOME = "${config.xdg.dataHome}"
$env.XDG_CACHE_HOME = "${config.xdg.cacheHome}"
let nix_paths = [
${formatPathList [ profileBin systemBin defaultBin ]} ]
let homebrew_paths = [
${formatPathList homebrewPaths} ]
let macos_system_paths = [
${formatPathList macosSystemPaths} ]
let path_candidates = ($nix_paths | append $homebrew_paths | append $macos_system_paths | flatten)
if ($env.PATH? == null) {
$env.PATH = $path_candidates
} else {
for path in $path_candidates {
if not ($env.PATH | any {|it| $it == $path}) {
$env.PATH = ($env.PATH | append $path)
}
}
}
$env.NIX_PROFILES = "/run/current-system/sw ${config.home.profileDirectory}"
# Load sops-managed API keys as environment variables
let secrets_dir = "${config.xdg.configHome}/secrets"
def --env load-secret [secret_name: string, env_var: string] {
let secret_file = ($secrets_dir | path join $secret_name)
if ($secret_file | path exists) {
let secret_value = (open --raw $secret_file | str trim)
{} | insert $env_var $secret_value | load-env
}
}
load-secret "zai-api-key" "ZAI_API_KEY"
load-secret "openai-api-key" "OPENAI_API_KEY"
load-secret "openrouter-api-key" "OPENROUTER_API_KEY"
load-secret "moonshot-api-key" "MOONSHOT_API_KEY"
load-secret "anthropic-api-key" "ANTHROPIC_API_KEY"
load-secret "exa-api-key" "EXA_API_KEY"
load-secret "fal-api-key" "FAL_API_KEY"
load-secret "groq-api-key" "GROQ_API_KEY"
load-secret "firecrawl-api-key" "FIRECRAWL_API_KEY"
'';
}

View file

@ -0,0 +1,8 @@
{ lib, ... }: {
programs.starship = {
enable = lib.mkDefault true;
enableFishIntegration = true;
enableNushellIntegration = true;
settings = lib.importTOML ./starship.toml;
};
}

View file

@ -0,0 +1,180 @@
"$schema" = "https://starship.rs/config-schema.json"
format = """
[](color_orange)\
$os\
$username\
[](bg:color_yellow fg:color_orange)\
$directory\
[](fg:color_yellow bg:color_aqua)\
$git_branch\
$git_status\
[](fg:color_aqua bg:color_blue)\
$c\
$cpp\
$rust\
$golang\
$nodejs\
$php\
$java\
$kotlin\
$haskell\
$python\
[](fg:color_blue bg:color_bg3)\
$docker_context\
$conda\
$pixi\
[](fg:color_bg3 bg:color_bg1)\
$time\
[ ](fg:color_bg1)\
$line_break$character"""
palette = "gruvbox_dark"
[palettes.gruvbox_dark]
color_fg0 = "#fbf1c7"
color_bg1 = "#3c3836"
color_bg3 = "#665c54"
color_blue = "#458588"
color_aqua = "#689d6a"
color_green = "#98971a"
color_orange = "#d65d0e"
color_purple = "#b16286"
color_red = "#cc241d"
color_yellow = "#d79921"
[os]
disabled = false
style = "bg:color_orange fg:color_fg0"
[os.symbols]
Windows = "󰍲"
Ubuntu = "󰕈"
SUSE = ""
Raspbian = "󰐿"
Mint = "󰣭"
Macos = "󰀵"
Manjaro = ""
Linux = "󰌽"
Gentoo = "󰣨"
Fedora = "󰣛"
Alpine = ""
Amazon = ""
Android = ""
Arch = "󰣇"
Artix = "󰣇"
EndeavourOS = ""
CentOS = ""
Debian = "󰣚"
Redhat = "󱄛"
RedHatEnterprise = "󱄛"
Pop = ""
[username]
show_always = true
style_user = "bg:color_orange fg:color_fg0"
style_root = "bg:color_orange fg:color_fg0"
format = "[ $user ]($style)"
[directory]
style = "fg:color_fg0 bg:color_yellow"
format = "[ $path ]($style)"
truncation_length = 3
truncation_symbol = "…/"
[directory.substitutions]
Documents = "󰈙 "
Downloads = " "
Music = "󰝚 "
Pictures = " "
Developer = "󰲋 "
[git_branch]
symbol = ""
style = "bg:color_aqua"
format = "[[ $symbol $branch ](fg:color_fg0 bg:color_aqua)]($style)"
[git_status]
style = "bg:color_aqua"
format = "[[($all_status$ahead_behind )](fg:color_fg0 bg:color_aqua)]($style)"
[nodejs]
symbol = ""
style = "bg:color_blue"
format = "[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)"
[c]
symbol = " "
style = "bg:color_blue"
format = "[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)"
[cpp]
symbol = " "
style = "bg:color_blue"
format = "[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)"
[rust]
symbol = ""
style = "bg:color_blue"
format = "[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)"
[golang]
symbol = ""
style = "bg:color_blue"
format = "[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)"
[php]
symbol = ""
style = "bg:color_blue"
format = "[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)"
[java]
symbol = ""
style = "bg:color_blue"
format = "[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)"
[kotlin]
symbol = ""
style = "bg:color_blue"
format = "[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)"
[haskell]
symbol = ""
style = "bg:color_blue"
format = "[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)"
[python]
symbol = ""
style = "bg:color_blue"
format = "[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)"
[docker_context]
symbol = ""
style = "bg:color_bg3"
format = "[[ $symbol( $context) ](fg:#83a598 bg:color_bg3)]($style)"
[conda]
style = "bg:color_bg3"
format = "[[ $symbol( $environment) ](fg:#83a598 bg:color_bg3)]($style)"
[pixi]
style = "bg:color_bg3"
format = "[[ $symbol( $version)( $environment) ](fg:color_fg0 bg:color_bg3)]($style)"
[time]
disabled = false
time_format = "%R"
style = "bg:color_bg1"
format = "[[  $time ](fg:color_fg0 bg:color_bg1)]($style)"
[line_break]
disabled = false
[character]
disabled = false
success_symbol = "[](bold fg:color_green)"
error_symbol = "[](bold fg:color_red)"
vimcmd_symbol = "[](bold fg:color_green)"
vimcmd_replace_one_symbol = "[](bold fg:color_purple)"
vimcmd_replace_symbol = "[](bold fg:color_purple)"
vimcmd_visual_symbol = "[](bold fg:color_yellow)"

View file

@ -0,0 +1,181 @@
"$schema" = "https://starship.rs/config-schema.json"
format = """
[](color_orange)\
$os\
$username\
[](bg:color_yellow fg:color_orange)\
$directory\
[](fg:color_yellow bg:color_aqua)\
$git_branch\
$git_status\
[](fg:color_aqua bg:color_blue)\
$c\
$cpp\
$rust\
$golang\
$nodejs\
$php\
$java\
$kotlin\
$haskell\
$python\
[](fg:color_blue bg:color_bg3)\
$docker_context\
$conda\
$pixi\
[](fg:color_bg3 bg:color_bg1)\
$time\
[ ](fg:color_bg1)\
$line_break$character"""
palette = "gruvbox_dark"
[palettes.gruvbox_dark]
color_fg0 = "#fbf1c7"
color_bg1 = "#3c3836"
color_bg3 = "#665c54"
color_blue = "#458588"
color_aqua = "#689d6a"
color_green = "#98971a"
color_orange = "#d65d0e"
color_purple = "#b16286"
color_red = "#cc241d"
color_yellow = "#d79921"
[os]
disabled = false
style = "bg:color_orange fg:color_fg0"
[os.symbols]
Windows = "󰍲"
Ubuntu = "󰕈"
SUSE = ""
Raspbian = "󰐿"
Mint = "󰣭"
Macos = "󰀵"
Manjaro = ""
Linux = "󰌽"
Gentoo = "󰣨"
Fedora = "󰣛"
Alpine = ""
Amazon = ""
Android = ""
AOSC = ""
Arch = "󰣇"
Artix = "󰣇"
EndeavourOS = ""
CentOS = ""
Debian = "󰣚"
Redhat = "󱄛"
RedHatEnterprise = "󱄛"
Pop = ""
[username]
show_always = true
style_user = "bg:color_orange fg:color_fg0"
style_root = "bg:color_orange fg:color_fg0"
format = "[ $user ]($style)"
[directory]
style = "fg:color_fg0 bg:color_yellow"
format = "[ $path ]($style)"
truncation_length = 3
truncation_symbol = "…/"
[directory.substitutions]
Documents = "󰈙 "
Downloads = " "
Music = "󰝚 "
Pictures = " "
Developer = "󰲋 "
[git_branch]
symbol = ""
style = "bg:color_aqua"
format = "[[ $symbol $branch ](fg:color_fg0 bg:color_aqua)]($style)"
[git_status]
style = "bg:color_aqua"
format = "[[($all_status$ahead_behind )](fg:color_fg0 bg:color_aqua)]($style)"
[nodejs]
symbol = ""
style = "bg:color_blue"
format = "[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)"
[c]
symbol = " "
style = "bg:color_blue"
format = "[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)"
[cpp]
symbol = " "
style = "bg:color_blue"
format = "[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)"
[rust]
symbol = ""
style = "bg:color_blue"
format = "[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)"
[golang]
symbol = ""
style = "bg:color_blue"
format = "[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)"
[php]
symbol = ""
style = "bg:color_blue"
format = "[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)"
[java]
symbol = ""
style = "bg:color_blue"
format = "[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)"
[kotlin]
symbol = ""
style = "bg:color_blue"
format = "[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)"
[haskell]
symbol = ""
style = "bg:color_blue"
format = "[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)"
[python]
symbol = ""
style = "bg:color_blue"
format = "[[ $symbol( $version) ](fg:color_fg0 bg:color_blue)]($style)"
[docker_context]
symbol = ""
style = "bg:color_bg3"
format = "[[ $symbol( $context) ](fg:#83a598 bg:color_bg3)]($style)"
[conda]
style = "bg:color_bg3"
format = "[[ $symbol( $environment) ](fg:#83a598 bg:color_bg3)]($style)"
[pixi]
style = "bg:color_bg3"
format = "[[ $symbol( $version)( $environment) ](fg:color_fg0 bg:color_bg3)]($style)"
[time]
disabled = false
time_format = "%R"
style = "bg:color_bg1"
format = "[[  $time ](fg:color_fg0 bg:color_bg1)]($style)"
[line_break]
disabled = false
[character]
disabled = false
success_symbol = "[](bold fg:color_green)"
error_symbol = "[](bold fg:color_red)"
vimcmd_symbol = "[](bold fg:color_green)"
vimcmd_replace_one_symbol = "[](bold fg:color_purple)"
vimcmd_replace_symbol = "[](bold fg:color_purple)"
vimcmd_visual_symbol = "[](bold fg:color_yellow)"

View file

@ -0,0 +1,34 @@
{ config, lib, pkgs, ... }: {
programs.tmux = {
enable = lib.mkDefault true;
clock24 = true;
historyLimit = 20000;
mouse = true;
baseIndex = 1;
prefix = "C-a";
escapeTime = 0;
aggressiveResize = true;
plugins = [{ plugin = pkgs.tmuxPlugins.gruvbox; }];
extraConfig = ''
# Terminal configuration for proper colors and features
set-option -g default-terminal "screen-256color"
set-option -ga terminal-overrides ",*256col*:Tc"
set-option -g focus-events on
# Avoid CSI-u newline remapping that breaks Neovim pastes
set -as terminal-features 'xterm-ghostty:bpaste,clipboard,RGB'
set -g status-interval 5
setw -g automatic-rename on
set -g renumber-windows on
bind r source-file ~/.tmux.conf \; display-message "tmux reloaded"
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
set -g display-panes-time 1500
bind k send-keys -R \; send-keys C-l \; clear-history
# Ensure tmux panes spawn login nu so Starship integration runs
set -g default-shell "${config.home.profileDirectory}/bin/nu"
set -g default-command "${config.home.profileDirectory}/bin/nu --login"
'';
};
}