Последняя активность 1 day ago

Cross-platform Zsh setup scripts and managed dotfiles with Oh My Zsh framework, Starship prompt, aliases, functions, and path configuration.

Vernon Wee Hong KOH ревизий этого фрагмента 3 months ago. К ревизии

1 file changed, 4 insertions, 4 deletions

func

@@ -443,9 +443,9 @@ create() {
443 443 }
444 444
445 445 # -----------------------------------------------------------------------------
446 - # Function: check_port (Kill or check the process using a port)
446 + # Function: kill_port (Kill or check the process using a port)
447 447 # -----------------------------------------------------------------------------
448 - check_port() {
448 + kill_port() {
449 449 local action="kill"
450 450 local signal="TERM"
451 451 local port
@@ -467,7 +467,7 @@ check_port() {
467 467 shift
468 468 ;;
469 469 -h|--help|"")
470 - printf "Usage: check_port [--check|-c|--kill|-k|--force|-f] <port_number>\n" >&2
470 + printf "Usage: kill_port [--check|-c|--kill|-k|--force|-f] <port_number>\n" >&2
471 471 return 1
472 472 ;;
473 473 esac
@@ -475,7 +475,7 @@ check_port() {
475 475 port="${1:-}"
476 476 if [[ ! "$port" =~ ^[0-9]+$ ]] || [ "$port" -lt 1 ] || [ "$port" -gt 65535 ]; then
477 477 printf "Error: port must be a number between 1 and 65535.\n" >&2
478 - printf "Usage: check_port [--check|-c|--kill|-k|--force|-f] <port_number>\n" >&2
478 + printf "Usage: kill_port [--check|-c|--kill|-k|--force|-f] <port_number>\n" >&2
479 479 return 1
480 480 fi
481 481

Vernon Wee Hong KOH ревизий этого фрагмента 3 months ago. К ревизии

1 file changed, 8 insertions, 4 deletions

func

@@ -443,16 +443,20 @@ create() {
443 443 }
444 444
445 445 # -----------------------------------------------------------------------------
446 - # Function: check_port (Check or kill the process using a port)
446 + # Function: check_port (Kill or check the process using a port)
447 447 # -----------------------------------------------------------------------------
448 448 check_port() {
449 - local action="check"
449 + local action="kill"
450 450 local signal="TERM"
451 451 local port
452 452 local pids
453 453 local pid
454 454
455 455 case "${1:-}" in
456 + -c|--check)
457 + action="check"
458 + shift
459 + ;;
456 460 -k|--kill)
457 461 action="kill"
458 462 shift
@@ -463,7 +467,7 @@ check_port() {
463 467 shift
464 468 ;;
465 469 -h|--help|"")
466 - printf "Usage: check_port [--kill|-k|--force|-f] <port_number>\n" >&2
470 + printf "Usage: check_port [--check|-c|--kill|-k|--force|-f] <port_number>\n" >&2
467 471 return 1
468 472 ;;
469 473 esac
@@ -471,7 +475,7 @@ check_port() {
471 475 port="${1:-}"
472 476 if [[ ! "$port" =~ ^[0-9]+$ ]] || [ "$port" -lt 1 ] || [ "$port" -gt 65535 ]; then
473 477 printf "Error: port must be a number between 1 and 65535.\n" >&2
474 - printf "Usage: check_port [--kill|-k|--force|-f] <port_number>\n" >&2
478 + printf "Usage: check_port [--check|-c|--kill|-k|--force|-f] <port_number>\n" >&2
475 479 return 1
476 480 fi
477 481

Vernon Wee Hong KOH ревизий этого фрагмента 3 months ago. К ревизии

1 file changed, 104 insertions, 8 deletions

func

@@ -214,9 +214,9 @@ claude() {
214 214 }
215 215
216 216 # -----------------------------------------------------------------------------
217 - # Function: auggie_enhance (Enhance a prompt with Auggie)
217 + # Function: prompt (Enhance a prompt with Auggie)
218 218 # -----------------------------------------------------------------------------
219 - auggie_enhance() {
219 + prompt() {
220 220 local prompt
221 221 local line
222 222 local run_dir
@@ -443,19 +443,115 @@ create() {
443 443 }
444 444
445 445 # -----------------------------------------------------------------------------
446 - # Function: check_port
446 + # Function: check_port (Check or kill the process using a port)
447 447 # -----------------------------------------------------------------------------
448 448 check_port() {
449 - local PORT=$1
450 - if [ -z "$PORT" ]; then
451 - printf "Usage: check_port <port_number>\n" >&2
449 + local action="check"
450 + local signal="TERM"
451 + local port
452 + local pids
453 + local pid
454 +
455 + case "${1:-}" in
456 + -k|--kill)
457 + action="kill"
458 + shift
459 + ;;
460 + -f|--force)
461 + action="kill"
462 + signal="KILL"
463 + shift
464 + ;;
465 + -h|--help|"")
466 + printf "Usage: check_port [--kill|-k|--force|-f] <port_number>\n" >&2
467 + return 1
468 + ;;
469 + esac
470 +
471 + port="${1:-}"
472 + if [[ ! "$port" =~ ^[0-9]+$ ]] || [ "$port" -lt 1 ] || [ "$port" -gt 65535 ]; then
473 + printf "Error: port must be a number between 1 and 65535.\n" >&2
474 + printf "Usage: check_port [--kill|-k|--force|-f] <port_number>\n" >&2
452 475 return 1
453 476 fi
454 477
455 478 if [[ "$OSTYPE" == "darwin"* ]]; then
456 - lsof -i :"$PORT" || echo "Port $PORT is FREE"
479 + pids="$(
480 + {
481 + lsof -nP -tiTCP:"$port" -sTCP:LISTEN 2>/dev/null
482 + lsof -nP -tiUDP:"$port" 2>/dev/null
483 + } | sort -u
484 + )"
485 +
486 + if [ -z "$pids" ]; then
487 + printf "Port %s is FREE\n" "$port"
488 + return 0
489 + fi
490 +
491 + printf "Port %s is in use:\n" "$port"
492 + lsof -nP -iTCP:"$port" -sTCP:LISTEN -iUDP:"$port" 2>/dev/null
457 493 else
458 - sudo ss -tulnp | grep ":$PORT " || echo "Port $PORT is FREE"
494 + local port_hex
495 + local inodes
496 +
497 + port_hex="$(printf "%04X" "$port")"
498 + inodes="$(
499 + awk -v port="$port_hex" '
500 + NR > 1 {
501 + split($2, local_addr, ":")
502 + if (toupper(local_addr[length(local_addr)]) == port && ($4 == "0A" || FILENAME ~ /udp/)) {
503 + print $10
504 + }
505 + }
506 + ' /proc/net/tcp /proc/net/tcp6 /proc/net/udp /proc/net/udp6 2>/dev/null | sort -u
507 + )"
508 +
509 + if [ -z "$inodes" ]; then
510 + printf "Port %s is FREE\n" "$port"
511 + return 0
512 + fi
513 +
514 + pids=""
515 + pids="$(
516 + find /proc/[0-9]*/fd -maxdepth 1 -type l -printf "%p %l\n" 2>/dev/null |
517 + awk -v inodes="$inodes" '
518 + BEGIN {
519 + split(inodes, inode_list, " ")
520 + for (i in inode_list) {
521 + wanted["socket:[" inode_list[i] "]"] = 1
522 + }
523 + }
524 + $2 in wanted {
525 + split($1, path, "/")
526 + print path[3]
527 + }
528 + ' | sort -u
529 + )"
530 +
531 + if [ -z "$pids" ]; then
532 + printf "Port %s is in use, but no readable process owner was found.\n" "$port" >&2
533 + return 1
534 + fi
535 +
536 + printf "Port %s is in use:\n" "$port"
537 + for pid in $pids; do
538 + if [ -r "/proc/$pid/cmdline" ]; then
539 + printf " PID %-8s %s\n" "$pid" "$(tr '\0' ' ' < "/proc/$pid/cmdline")"
540 + else
541 + printf " PID %s\n" "$pid"
542 + fi
543 + done
544 + fi
545 +
546 + if [ "$action" = "kill" ]; then
547 + for pid in $pids; do
548 + if kill "-$signal" "$pid" 2>/dev/null; then
549 + printf "Killed PID %s with SIG%s.\n" "$pid" "$signal"
550 + else
551 + printf "Error: failed to kill PID %s. Try with sudo or --force.\n" "$pid" >&2
552 + return 1
553 + fi
554 + done
459 555 fi
460 556 }
461 557

Vernon Wee Hong KOH ревизий этого фрагмента 3 months ago. К ревизии

1 file changed, 36 insertions

func

@@ -2,6 +2,42 @@
2 2 # CUSTOM FUNCTIONS
3 3 # =============================================================================
4 4
5 + # -----------------------------------------------------------------------------
6 + # Function: funcs (List available .func functions)
7 + # -----------------------------------------------------------------------------
8 + funcs() {
9 + local func_file="${1:-$HOME/.func}"
10 +
11 + if [ ! -f "$func_file" ]; then
12 + printf "Error: Function file '%s' not found.\n" "$func_file" >&2
13 + return 1
14 + fi
15 +
16 + printf "Available functions in %s:\n" "$func_file"
17 + awk '
18 + /^# Function: / {
19 + line = $0
20 + sub(/^# Function: /, "", line)
21 +
22 + name = line
23 + sub(/ .*/, "", name)
24 +
25 + desc = ""
26 + if (line ~ / \(.+\)$/) {
27 + desc = line
28 + sub(/^[^ ]+ \(/, "", desc)
29 + sub(/\)$/, "", desc)
30 + }
31 +
32 + if (desc != "") {
33 + printf " %-22s %s\n", name, desc
34 + } else {
35 + printf " %s\n", name
36 + }
37 + }
38 + ' "$func_file"
39 + }
40 +
5 41 # -----------------------------------------------------------------------------
6 42 # Function: clip (Cross-platform clipboard)
7 43 # -----------------------------------------------------------------------------

Vernon Wee Hong KOH ревизий этого фрагмента 3 months ago. К ревизии

1 file changed, 96 insertions

func

@@ -177,6 +177,102 @@ claude() {
177 177 command claude "$@"
178 178 }
179 179
180 + # -----------------------------------------------------------------------------
181 + # Function: auggie_enhance (Enhance a prompt with Auggie)
182 + # -----------------------------------------------------------------------------
183 + auggie_enhance() {
184 + local prompt
185 + local line
186 + local run_dir
187 + local prompt_file
188 + local workspace
189 + local cache_dir
190 + local auth_file
191 + local log_file
192 + local script_pid
193 + local waited
194 +
195 + require_cli auggie "Auggie CLI" || return 1
196 + require_cli script "script utility" || return 1
197 +
198 + if [ $# -gt 0 ]; then
199 + prompt="$*"
200 + elif [ ! -t 0 ]; then
201 + prompt="$(cat)"
202 + else
203 + echo "Reading prompt... Type 'EOF' on a new line and press Enter when finished."
204 + prompt=""
205 +
206 + while IFS= read -r line; do
207 + [ "$line" = "EOF" ] && break
208 + if [ -z "$prompt" ]; then
209 + prompt="$line"
210 + else
211 + prompt="${prompt}"$'\n'"${line}"
212 + fi
213 + done
214 + fi
215 +
216 + if [ -z "$prompt" ]; then
217 + printf "Error: Prompt was empty.\n" >&2
218 + return 1
219 + fi
220 +
221 + if [ ! -s "$HOME/.augment/session.json" ]; then
222 + printf "Error: Auggie session file not found. Run 'auggie login' first.\n" >&2
223 + return 1
224 + fi
225 +
226 + run_dir="$(mktemp -d "${TMPDIR:-/tmp}/auggie-enhance.XXXXXX")" || return 1
227 + prompt_file="$run_dir/prompt.txt"
228 + workspace="$run_dir/workspace"
229 + cache_dir="$run_dir/cache"
230 + auth_file="$HOME/.augment/session.json"
231 + log_file="$run_dir/auggie.log"
232 + mkdir -p "$workspace" "$cache_dir"
233 + printf "%s\n" "$prompt" > "$prompt_file"
234 +
235 + script -q -f -O "$log_file" -c "auggie --print --enhance-prompt --no-discover-workspaces --workspace-root '$workspace' --augment-cache-dir '$cache_dir' --augment-session-json '$auth_file' --dont-save-session --instruction-file '$prompt_file'" >/dev/null 2>&1 &
236 + script_pid=$!
237 + waited=0
238 +
239 + while kill -0 "$script_pid" >/dev/null 2>&1; do
240 + if grep -aq "🤖" "$log_file" 2>/dev/null || grep -aq "Tool call:" "$log_file" 2>/dev/null; then
241 + kill "$script_pid" >/dev/null 2>&1
242 + wait "$script_pid" >/dev/null 2>&1
243 + break
244 + fi
245 +
246 + if [ "$waited" -ge 90 ]; then
247 + kill "$script_pid" >/dev/null 2>&1
248 + wait "$script_pid" >/dev/null 2>&1
249 + printf "Error: Timed out waiting for Auggie to enhance the prompt.\n" >&2
250 + rm -rf "$run_dir"
251 + return 124
252 + fi
253 +
254 + sleep 1
255 + waited=$((waited + 1))
256 + done
257 +
258 + perl -ne '
259 + s/\r$//;
260 + s/\e\]0;[^\a]*\a//g;
261 + next if /Script started on/ || /Script done on/;
262 + exit if /^🤖/ || /Tool call:/ || /Session terminated/;
263 + print;
264 + ' "$log_file"
265 +
266 + if ! grep -aq "Enhanced prompt:" "$log_file"; then
267 + rm -rf "$run_dir"
268 + return 1
269 + fi
270 +
271 + rm -rf "$run_dir"
272 +
273 + command auggie account status
274 + }
275 +
180 276 # -----------------------------------------------------------------------------
181 277 # Function: plan_build (Claude Code multi-agent workflow orchestrator)
182 278 # -----------------------------------------------------------------------------

weehong ревизий этого фрагмента 3 months ago. К ревизии

1 file changed, 14 insertions, 2 deletions

func

@@ -80,11 +80,23 @@ clear_history() {
80 80
81 81 codex)
82 82 local codex_home="${CODEX_HOME:-$HOME/.codex}"
83 + local codex_session_file
84 + local codex_session_id
83 85
84 86 mkdir -p "$codex_home"
85 87 : > "$codex_home/history.jsonl"
86 - rm -rf "$codex_home/sessions" "$codex_home/shell_snapshots"
87 - mkdir -p "$codex_home/sessions" "$codex_home/shell_snapshots"
88 +
89 + if command -v codex >/dev/null 2>&1; then
90 + find "$codex_home/sessions" "$codex_home/archived_sessions" -type f -name '*.jsonl' -print 2>/dev/null | while IFS= read -r codex_session_file; do
91 + codex_session_id="$(sed -n 's/.*"session_id":"\([^"]*\)".*/\1/p; q' "$codex_session_file")"
92 + if [ -n "$codex_session_id" ]; then
93 + codex delete --force "$codex_session_id" >/dev/null 2>&1 || true
94 + fi
95 + done
96 + fi
97 +
98 + rm -rf "$codex_home/sessions" "$codex_home/archived_sessions" "$codex_home/shell_snapshots"
99 + mkdir -p "$codex_home/sessions" "$codex_home/archived_sessions" "$codex_home/shell_snapshots"
88 100
89 101 echo "Codex history cleared."
90 102 ;;

weehong ревизий этого фрагмента 3 months ago. К ревизии

1 file changed, 30 insertions, 3 deletions

func

@@ -66,10 +66,10 @@ open_file() {
66 66 alias open='open_file'
67 67
68 68 # -----------------------------------------------------------------------------
69 - # Function: clear_history (Supports shell and Claude)
69 + # Function: clear_history (Supports shell, Claude, Codex, and OpenCode)
70 70 # -----------------------------------------------------------------------------
71 71 clear_history() {
72 - case "$1" in
72 + case "${1:-}" in
73 73 claude)
74 74 if [ -d "$HOME/.claude/projects" ]; then
75 75 # Use 'yes' to skip prompts and -f to ignore non-existent files
@@ -77,7 +77,34 @@ clear_history() {
77 77 echo "Claude project history/cache cleared."
78 78 fi
79 79 ;;
80 -
80 +
81 + codex)
82 + local codex_home="${CODEX_HOME:-$HOME/.codex}"
83 +
84 + mkdir -p "$codex_home"
85 + : > "$codex_home/history.jsonl"
86 + rm -rf "$codex_home/sessions" "$codex_home/shell_snapshots"
87 + mkdir -p "$codex_home/sessions" "$codex_home/shell_snapshots"
88 +
89 + echo "Codex history cleared."
90 + ;;
91 +
92 + opencode)
93 + local opencode_state_home="${XDG_STATE_HOME:-$HOME/.local/state}/opencode"
94 + local opencode_data_home="${XDG_DATA_HOME:-$HOME/.local/share}/opencode"
95 +
96 + mkdir -p "$opencode_state_home" "$opencode_data_home"
97 + : > "$opencode_state_home/prompt-history.jsonl"
98 + rm -f \
99 + "$opencode_data_home/opencode.db" \
100 + "$opencode_data_home/opencode.db-shm" \
101 + "$opencode_data_home/opencode.db-wal"
102 + rm -rf "$opencode_data_home/repos" "$opencode_data_home/log"
103 + mkdir -p "$opencode_data_home/repos" "$opencode_data_home/log"
104 +
105 + echo "OpenCode history cleared."
106 + ;;
107 +
81 108 *)
82 109 # 1. Truncate the file
83 110 : > "$HISTFILE"

Vernon Wee Hong KOH ревизий этого фрагмента 3 months ago. К ревизии

2 files changed, 97 insertions, 1 deletion

func

@@ -181,7 +181,7 @@ plan_build() {
181 181
182 182 echo "🚀 Launching Claude Code with your multi-agent workflow..."
183 183
184 - claude "${claude_args[@]}" "Please read \`skills.md\` and strictly follow the 6-step multi-agent workflow to implement the following task:
184 + claude "${claude_args[@]}" "Please read \`~/.claude/skills/plan-build/SKILL.md\` and strictly follow the 7-step multi-agent workflow to implement the following task:
185 185
186 186 $payload"
187 187 }

orchestrate-loop.md(файл создан)

@@ -0,0 +1,96 @@
1 + # Plan-Build Orchestrate Loop
2 +
3 + Use this workflow when `plan_build` hands Claude Code an implementation task. The goal is to keep Claude as the orchestrator while using Codex and CodeRabbit as independent review and validation agents.
4 +
5 + ## Operating Rules
6 +
7 + - Run from the project root. Treat the current working directory as the project to modify.
8 + - Preserve user work. Check `git status` before edits and do not revert unrelated changes.
9 + - Keep implementation scoped to the payload unless repository context proves a wider change is required.
10 + - Prefer existing project conventions, scripts, test commands, and dependency managers.
11 + - Do not call the task complete until validation has run or the reason it cannot run is documented.
12 + - If any agent reports a plausible correctness, security, data-loss, migration, or test risk, resolve it or explicitly document why it is not applicable.
13 +
14 + ## The 7-Step Workflow
15 +
16 + ### 1. Intake
17 +
18 + Read the user payload fully. Identify:
19 +
20 + - Objective and expected user-visible behavior.
21 + - Files, modules, commands, and frameworks likely involved.
22 + - Constraints from repository docs, package scripts, CI config, and existing patterns.
23 + - Any ambiguity that blocks safe execution.
24 +
25 + Only ask the user a question when no reasonable project-local assumption is safe.
26 +
27 + ### 2. Baseline
28 +
29 + Inspect the repository before changing files:
30 +
31 + ```bash
32 + git status --short
33 + rg --files
34 + ```
35 +
36 + Then read the smallest useful set of files. Prefer `rg`, package manifests, tests, routing files, and nearby implementations over broad file dumps.
37 +
38 + ### 3. Plan
39 +
40 + Create a short implementation plan with concrete steps. Include validation commands. If the task touches behavior, data, auth, payments, destructive actions, or shared infrastructure, include a rollback or compatibility note.
41 +
42 + ### 4. Implement
43 +
44 + Make the change in small, reviewable edits:
45 +
46 + - Follow existing style and abstractions.
47 + - Add or update tests when behavior changes.
48 + - Update docs only when user-facing usage changes.
49 + - Avoid unrelated refactors and formatting churn.
50 +
51 + After each meaningful edit group, re-check the diff for accidental changes.
52 +
53 + ### 5. Codex Review Pass
54 +
55 + Ask Codex for an independent review of the local diff before finalizing. Provide the task, constraints, and current diff. Ask it to focus on bugs, edge cases, missing tests, regressions, and simpler project-native alternatives.
56 +
57 + Recommended prompt shape:
58 +
59 + ```text
60 + Review this change for correctness and risk. Prioritize bugs, regressions, missing tests, and mismatches with existing project patterns. Do not rewrite the whole solution unless a specific issue requires it.
61 +
62 + Task:
63 + <payload>
64 +
65 + Diff:
66 + <git diff>
67 + ```
68 +
69 + Apply fixes for valid findings, then repeat this review pass if the fixes are non-trivial.
70 +
71 + ### 6. CodeRabbit Review Pass
72 +
73 + Run CodeRabbit on the branch or diff when available. Treat its output as advisory but investigate every concrete finding.
74 +
75 + If CodeRabbit cannot run locally, record the command attempted and the failure. Continue with manual validation rather than blocking indefinitely.
76 +
77 + ### 7. Validate And Close
78 +
79 + Run the planned validation commands, such as:
80 +
81 + ```bash
82 + npm test
83 + npm run lint
84 + pytest
85 + cargo test
86 + go test ./...
87 + ```
88 +
89 + Use the commands that actually exist in the project. If validation fails, fix the issue and rerun the relevant command. If a failure is unrelated or environmental, capture the evidence.
90 +
91 + Before final response:
92 +
93 + - Confirm `git diff` contains only intended changes.
94 + - Summarize what changed.
95 + - Report validation run and result.
96 + - Note any remaining risks or commands that could not run.

weehong ревизий этого фрагмента 3 months ago. К ревизии

1 file changed, 2 insertions, 2 deletions

func

@@ -139,7 +139,7 @@ claude() {
139 139 }
140 140
141 141 # -----------------------------------------------------------------------------
142 - # Function: plan-build (Claude Code multi-agent workflow orchestrator)
142 + # Function: plan_build (Claude Code multi-agent workflow orchestrator)
143 143 # -----------------------------------------------------------------------------
144 144 plan_build() {
145 145 local claude_args=()
@@ -151,7 +151,7 @@ plan_build() {
151 151
152 152 if [ $# -gt 0 ]; then
153 153 echo "Error: Unknown argument(s): $*"
154 - echo "Usage: plan-build [--yolo]"
154 + echo "Usage: plan_build [--yolo]"
155 155 return 1
156 156 fi
157 157

weehong ревизий этого фрагмента 3 months ago. К ревизии

1 file changed, 1 insertion, 1 deletion

func

@@ -141,7 +141,7 @@ claude() {
141 141 # -----------------------------------------------------------------------------
142 142 # Function: plan-build (Claude Code multi-agent workflow orchestrator)
143 143 # -----------------------------------------------------------------------------
144 - plan-build() {
144 + plan_build() {
145 145 local claude_args=()
146 146
147 147 if [[ "${1:-}" == "--yolo" ]]; then