Dernière activité 1 week 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 a révisé ce gist 1 month ago. Aller à la révision

1 file changed, 188 insertions, 41 deletions

func

@@ -214,40 +214,51 @@ claude() {
214 214 }
215 215
216 216 # -----------------------------------------------------------------------------
217 - # Function: prompt (Enhance a prompt with Auggie)
217 + # Internal: _prompt_confirm_indexing (Confirm project indexing via the terminal)
218 218 # -----------------------------------------------------------------------------
219 - prompt() {
220 - local prompt
221 - local line
219 + _prompt_confirm_indexing() {
220 + local project_root="$1"
221 + local reply
222 +
223 + if ! (: </dev/tty) 2>/dev/null; then
224 + printf "Notice: No interactive terminal available; enhancing without project indexing.\n" >&2
225 + return 1
226 + fi
227 +
228 + printf "Allow Auggie to index and use project context from '%s'? (y/N) " "$project_root" >/dev/tty
229 + if ! IFS= read -r reply </dev/tty; then
230 + printf "\nNotice: Unable to read confirmation; enhancing without project indexing.\n" >&2
231 + return 1
232 + fi
233 +
234 + case "$reply" in
235 + y|Y|yes|YES|Yes)
236 + return 0
237 + ;;
238 + *)
239 + return 1
240 + ;;
241 + esac
242 + }
243 +
244 + # -----------------------------------------------------------------------------
245 + # Internal: _enhance_prompt (Run Auggie and write only the enhanced prompt)
246 + # -----------------------------------------------------------------------------
247 + _enhance_prompt() {
248 + local prompt="$1"
249 + local output_file="$2"
222 250 local run_dir
223 251 local prompt_file
224 252 local workspace
225 253 local cache_dir
226 254 local auth_file
227 255 local log_file
256 + local parsed_file
257 + local project_root
258 + local use_project_context
228 259 local script_pid
229 260 local waited
230 -
231 - require_cli auggie "Auggie CLI" || return 1
232 - require_cli script "script utility" || return 1
233 -
234 - if [ $# -gt 0 ]; then
235 - prompt="$*"
236 - elif [ ! -t 0 ]; then
237 - prompt="$(cat)"
238 - else
239 - echo "Reading prompt... Type 'EOF' on a new line and press Enter when finished."
240 - prompt=""
241 -
242 - while IFS= read -r line; do
243 - [ "$line" = "EOF" ] && break
244 - if [ -z "$prompt" ]; then
245 - prompt="$line"
246 - else
247 - prompt="${prompt}"$'\n'"${line}"
248 - fi
249 - done
250 - fi
261 + local timeout_seconds
251 262
252 263 if [ -z "$prompt" ]; then
253 264 printf "Error: Prompt was empty.\n" >&2
@@ -265,10 +276,38 @@ prompt() {
265 276 cache_dir="$run_dir/cache"
266 277 auth_file="$HOME/.augment/session.json"
267 278 log_file="$run_dir/auggie.log"
279 + parsed_file="$run_dir/enhanced.txt"
268 280 mkdir -p "$workspace" "$cache_dir"
269 281 printf "%s\n" "$prompt" > "$prompt_file"
270 282
271 - 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 >/dev/null 2>&1 &
283 + project_root="$(git rev-parse --show-toplevel 2>/dev/null)" || project_root="$PWD"
284 + use_project_context=0
285 + timeout_seconds=90
286 +
287 + if _prompt_confirm_indexing "$project_root"; then
288 + use_project_context=1
289 + timeout_seconds=300
290 + workspace="$project_root"
291 + cache_dir="$HOME/.augment"
292 + printf "Indexing approved; enhancing with project context from '%s'.\n" "$project_root" >&2
293 + else
294 + printf "Enhancing without project indexing.\n" >&2
295 + fi
296 +
297 + if [ "$use_project_context" -eq 1 ]; then
298 + AUGGIE_PROMPT_FILE="$prompt_file" \
299 + AUGGIE_WORKSPACE="$workspace" \
300 + AUGGIE_CACHE_DIR="$cache_dir" \
301 + AUGGIE_AUTH_FILE="$auth_file" \
302 + script -q -f -O "$log_file" -c 'auggie --print --enhance-prompt --workspace-root "$AUGGIE_WORKSPACE" --augment-cache-dir "$AUGGIE_CACHE_DIR" --augment-session-json "$AUGGIE_AUTH_FILE" --allow-indexing --wait-for-indexing --dont-save-session --instruction-file "$AUGGIE_PROMPT_FILE"' </dev/null >/dev/null 2>&1 &
303 + else
304 + AUGGIE_PROMPT_FILE="$prompt_file" \
305 + AUGGIE_WORKSPACE="$workspace" \
306 + AUGGIE_CACHE_DIR="$cache_dir" \
307 + AUGGIE_AUTH_FILE="$auth_file" \
308 + script -q -f -O "$log_file" -c 'auggie --print --enhance-prompt --no-discover-workspaces --workspace-root "$AUGGIE_WORKSPACE" --augment-cache-dir "$AUGGIE_CACHE_DIR" --augment-session-json "$AUGGIE_AUTH_FILE" --dont-save-session --instruction-file "$AUGGIE_PROMPT_FILE"' </dev/null >/dev/null 2>&1 &
309 + fi
310 +
272 311 script_pid=$!
273 312 waited=0
274 313
@@ -279,7 +318,7 @@ prompt() {
279 318 break
280 319 fi
281 320
282 - if [ "$waited" -ge 90 ]; then
321 + if [ "$waited" -ge "$timeout_seconds" ]; then
283 322 kill "$script_pid" >/dev/null 2>&1
284 323 wait "$script_pid" >/dev/null 2>&1
285 324 printf "Error: Timed out waiting for Auggie to enhance the prompt.\n" >&2
@@ -291,20 +330,85 @@ prompt() {
291 330 waited=$((waited + 1))
292 331 done
293 332
333 + wait "$script_pid" >/dev/null 2>&1 || true
334 +
294 335 perl -ne '
295 336 s/\r$//;
296 - s/\e\]0;[^\a]*\a//g;
337 + s/\e\][^\a]*(?:\a|\e\\)//g;
338 + s/\e\[[0-?]*[ -\/]*[@-~]//g;
297 339 next if /Script started on/ || /Script done on/;
340 + if (/^Enhanced prompt:\s*(.*)$/) {
341 + $capturing = 1;
342 + $output .= "$1\n" if length $1;
343 + next;
344 + }
345 + next unless $capturing;
298 346 exit if /^🤖/ || /Tool call:/ || /Session terminated/;
299 - print;
300 - ' "$log_file"
347 + $output .= $_;
348 + END {
349 + $output =~ s/^\s*\n//;
350 + $output =~ s/\s+\z//;
351 + print "$output\n" if length $output;
352 + }
353 + ' "$log_file" > "$parsed_file"
301 354
302 - if ! grep -aq "Enhanced prompt:" "$log_file"; then
355 + if [ ! -s "$parsed_file" ]; then
356 + printf "Error: Auggie did not return an enhanced prompt.\n" >&2
303 357 rm -rf "$run_dir"
304 358 return 1
305 359 fi
306 360
361 + if ! command cp "$parsed_file" "$output_file"; then
362 + printf "Error: Unable to save the enhanced prompt.\n" >&2
363 + rm -rf "$run_dir"
364 + return 1
365 + fi
307 366 rm -rf "$run_dir"
367 + }
368 +
369 + # -----------------------------------------------------------------------------
370 + # Function: prompt (Enhance a prompt with Auggie and optional project context)
371 + # -----------------------------------------------------------------------------
372 + prompt() {
373 + local prompt
374 + local line
375 + local output_file
376 +
377 + require_cli auggie "Auggie CLI" || return 1
378 + require_cli script "script utility" || return 1
379 +
380 + if [ $# -gt 0 ]; then
381 + prompt="$*"
382 + elif [ ! -t 0 ]; then
383 + prompt="$(cat)"
384 + else
385 + echo "Reading prompt... Type 'EOF' on a new line and press Enter when finished."
386 + prompt=""
387 +
388 + while IFS= read -r line; do
389 + [ "$line" = "EOF" ] && break
390 + if [ -z "$prompt" ]; then
391 + prompt="$line"
392 + else
393 + prompt="${prompt}"$'\n'"${line}"
394 + fi
395 + done
396 + fi
397 +
398 + if [ -z "$prompt" ]; then
399 + printf "Error: Prompt was empty.\n" >&2
400 + return 1
401 + fi
402 +
403 + output_file="$(mktemp "${TMPDIR:-/tmp}/auggie-enhanced-prompt.XXXXXX")" || return 1
404 + if ! _enhance_prompt "$prompt" "$output_file"; then
405 + rm -f "$output_file"
406 + return 1
407 + fi
408 +
409 + printf "Enhanced prompt:\n"
410 + command cat "$output_file"
411 + rm -f "$output_file"
308 412
309 413 command auggie account status
310 414 }
@@ -314,21 +418,44 @@ prompt() {
314 418 # -----------------------------------------------------------------------------
315 419 plan_build() {
316 420 local claude_args=()
317 -
318 - if [[ "${1:-}" == "--yolo" ]]; then
319 - claude_args=(--yolo)
421 + local use_yolo=0
422 + local enhance_payload=0
423 +
424 + while [ $# -gt 0 ]; do
425 + case "$1" in
426 + --yolo)
427 + if [ "$use_yolo" -eq 1 ]; then
428 + echo "Error: Duplicate argument: --yolo"
429 + echo "Usage: plan_build [--yolo] [--prompt]"
430 + return 1
431 + fi
432 + use_yolo=1
433 + claude_args=(--yolo)
434 + ;;
435 + --prompt)
436 + if [ "$enhance_payload" -eq 1 ]; then
437 + echo "Error: Duplicate argument: --prompt"
438 + echo "Usage: plan_build [--yolo] [--prompt]"
439 + return 1
440 + fi
441 + enhance_payload=1
442 + ;;
443 + *)
444 + echo "Error: Unknown argument: $1"
445 + echo "Usage: plan_build [--yolo] [--prompt]"
446 + return 1
447 + ;;
448 + esac
320 449 shift
321 - fi
322 -
323 - if [ $# -gt 0 ]; then
324 - echo "Error: Unknown argument(s): $*"
325 - echo "Usage: plan_build [--yolo]"
326 - return 1
327 - fi
450 + done
328 451
329 452 require_cli claude "Claude Code CLI" || return 1
330 453 require_cli codex "Codex CLI" || return 1
331 454 require_cli coderabbit "CodeRabbit CLI" || return 1
455 + if [ "$enhance_payload" -eq 1 ]; then
456 + require_cli auggie "Auggie CLI" || return 1
457 + require_cli script "script utility" || return 1
458 + fi
332 459
333 460 echo "📥 Reading payload... Type 'EOF' on a new line and press Enter when finished."
334 461
@@ -350,6 +477,26 @@ plan_build() {
350 477 return 1
351 478 fi
352 479
480 + if [ "$enhance_payload" -eq 1 ]; then
481 + local enhanced_file
482 + enhanced_file="$(mktemp "${TMPDIR:-/tmp}/plan-build-enhanced.XXXXXX")" || return 1
483 +
484 + echo "✨ Enhancing payload with Auggie..."
485 + if ! _enhance_prompt "$payload" "$enhanced_file"; then
486 + rm -f "$enhanced_file"
487 + echo "❌ Error: Prompt enhancement failed; Claude was not launched."
488 + return 1
489 + fi
490 +
491 + payload="$(cat "$enhanced_file")"
492 + rm -f "$enhanced_file"
493 +
494 + if [ -z "$payload" ]; then
495 + echo "❌ Error: Enhanced payload was empty; Claude was not launched."
496 + return 1
497 + fi
498 + fi
499 +
353 500 echo "🚀 Launching Claude Code with your multi-agent workflow..."
354 501
355 502 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:

Vernon Wee Hong KOH a révisé ce gist 1 month ago. Aller à la révision

1 file changed, 1 insertion, 1 deletion

func

@@ -268,7 +268,7 @@ prompt() {
268 268 mkdir -p "$workspace" "$cache_dir"
269 269 printf "%s\n" "$prompt" > "$prompt_file"
270 270
271 - 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 &
271 + 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 >/dev/null 2>&1 &
272 272 script_pid=$!
273 273 waited=0
274 274

Vernon Wee Hong KOH a révisé ce gist 1 month ago. Aller à la révision

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 a révisé ce gist 1 month ago. Aller à la révision

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 a révisé ce gist 1 month ago. Aller à la révision

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 a révisé ce gist 1 month ago. Aller à la révision

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 a révisé ce gist 1 month ago. Aller à la révision

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 a révisé ce gist 1 month ago. Aller à la révision

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 a révisé ce gist 1 month ago. Aller à la révision

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 a révisé ce gist 1 month ago. Aller à la révision

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(fichier créé)

@@ -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.