aboutsummaryrefslogtreecommitdiffstats
path: root/bash
diff options
context:
space:
mode:
authorelioat <{ID}+{username}@users.noreply.github.com>2025-08-20 15:06:03 -0400
committerelioat <{ID}+{username}@users.noreply.github.com>2025-08-20 15:06:03 -0400
commit71eb3bb61c5f34325aff37ced1c7d4d3670820d0 (patch)
treebdb6247a79880e503c599c6dab2e7a27848c14a2 /bash
parent2aab5e23d694c71bb386b4a76de41af0063108b6 (diff)
downloadtour-71eb3bb61c5f34325aff37ced1c7d4d3670820d0.tar.gz
*
Diffstat (limited to 'bash')
-rwxr-xr-xbash/talk-to-computer/classifier.sh7
-rwxr-xr-xbash/talk-to-computer/computer137
-rw-r--r--bash/talk-to-computer/puzzle_simple292
3 files changed, 127 insertions, 309 deletions
diff --git a/bash/talk-to-computer/classifier.sh b/bash/talk-to-computer/classifier.sh
index 157673e..38f4869 100755
--- a/bash/talk-to-computer/classifier.sh
+++ b/bash/talk-to-computer/classifier.sh
@@ -94,10 +94,15 @@ analyze_intent_patterns() {
if [[ "$prompt" =~ (puzzle|solve|algorithm|code|programming|implement|sort|search|optimize|data.*structure) ]]; then
puzzle_score=$((puzzle_score + 3))
fi
-
+
if [[ "$prompt" =~ (challenge|problem|question|task|assignment|exercise) ]]; then
puzzle_score=$((puzzle_score + 2))
fi
+
+ # Lil-specific patterns - highest priority for puzzle mechanism
+ if [[ "$prompt" =~ (lil|LIL|using lil|in lil|with lil|lil programming|lil language|lil script) ]]; then
+ puzzle_score=$((puzzle_score + 5)) # Higher score than other patterns
+ fi
# Find highest scoring mechanism
local max_score=0
diff --git a/bash/talk-to-computer/computer b/bash/talk-to-computer/computer
index b1e5aa5..77fffcd 100755
--- a/bash/talk-to-computer/computer
+++ b/bash/talk-to-computer/computer
@@ -51,22 +51,51 @@ DEFAULT_ROUNDS=2
# --- Argument Validation ---
if [ "$#" -lt 1 ]; then
+ show_computer_help
+ exit 1
+fi
+
+# Help function
+show_computer_help() {
echo -e "\n\tComputer"
echo -e "\tThis script intelligently routes prompts to the most appropriate thinking mechanism"
echo -e "\tor directly to Ollama based on complexity, question type, and user intent."
- echo -e "\n\tUsage: $0 [-f <file_path>] [-d] \"<your prompt>\" [number_of_rounds]"
- echo -e "\n\tExample: $0 -f ./input.txt \"Please analyze this text\" 2"
- echo -e "\n\tIf number_of_rounds is not provided, the program will default to $DEFAULT_ROUNDS rounds."
- echo -e "\n\t-f <file_path> (optional): Append the contents of the file to the prompt."
- echo -e "\n\t-d (optional): Force direct Ollama response (bypass thinking mechanisms)."
+ echo -e "\n\tUsage: $0 [options] \"<your prompt>\" [number_of_rounds]"
+ echo -e "\n\tOptions:"
+ echo -e "\t -f <file_path> Append the contents of the file to the prompt"
+ echo -e "\t -d Force direct Ollama response (bypass thinking mechanisms)"
+ echo -e "\t -m <mechanism> Manually select thinking mechanism:"
+ echo -e "\t direct, socratic, exploration, consensus, critique,"
+ echo -e "\t synthesis, peer-review, puzzle"
+ echo -e "\t -h, --help Show this help message"
+ echo -e "\n\tExamples:"
+ echo -e "\t $0 \"What is 2+2?\" # Auto-routing"
+ echo -e "\t $0 -f document.txt \"Analyze this\" 3 # With file, 3 rounds"
+ echo -e "\t $0 -d \"Simple question\" # Direct response only"
+ echo -e "\t $0 -m puzzle \"Using Lil, how can I...\" # Force puzzle mechanism"
+ echo -e "\n\tIf number_of_rounds is not provided, defaults to $DEFAULT_ROUNDS rounds."
echo -e "\n"
- exit 1
-fi
+}
+
+# Available mechanisms
+show_mechanisms() {
+ echo -e "\n\tAvailable Thinking Mechanisms:"
+ echo -e "\t direct - Simple questions, direct answers"
+ echo -e "\t socratic - Deep questioning and analysis"
+ echo -e "\t exploration - Multiple solution paths and comparison"
+ echo -e "\t consensus - Multiple model agreement"
+ echo -e "\t critique - Improvement suggestions and refinement"
+ echo -e "\t synthesis - Combining and integrating approaches"
+ echo -e "\t peer-review - Collaborative feedback and review"
+ echo -e "\t puzzle - Coding problems and Lil programming"
+ echo -e "\n"
+}
# --- Argument Parsing ---
FILE_PATH=""
FORCE_DIRECT=false
-while getopts "f:d" opt; do
+MANUAL_MECHANISM=""
+while getopts "f:dm:h-:" opt; do
case $opt in
f)
FILE_PATH="$OPTARG"
@@ -74,8 +103,32 @@ while getopts "f:d" opt; do
d)
FORCE_DIRECT=true
;;
+ m)
+ MANUAL_MECHANISM="$OPTARG"
+ ;;
+ h)
+ show_computer_help
+ exit 0
+ ;;
+ -)
+ case "${OPTARG}" in
+ help)
+ show_computer_help
+ exit 0
+ ;;
+ mechanisms)
+ show_mechanisms
+ exit 0
+ ;;
+ *)
+ echo "Invalid option: --${OPTARG}" >&2
+ exit 1
+ ;;
+ esac
+ ;;
*)
echo "Invalid option: -$OPTARG" >&2
+ show_computer_help
exit 1
;;
esac
@@ -219,14 +272,66 @@ if [ "$FORCE_DIRECT" = true ]; then
CONFIDENCE="1.0"
REASON="User requested direct response with -d flag"
else
- ANALYSIS_RESULT=$(analyze_prompt "$PROMPT")
- MECHANISM=$(echo "$ANALYSIS_RESULT" | cut -d':' -f1)
- CONFIDENCE=$(echo "$ANALYSIS_RESULT" | cut -d':' -f2)
-
- # Validate confidence score
- if [[ ! "$CONFIDENCE" =~ ^[0-9.]+$ ]]; then
- CONFIDENCE="0.5"
- log_warning "Invalid confidence score, defaulting to 0.5"
+ # Check for manual mechanism selection
+ if [ -n "$MANUAL_MECHANISM" ]; then
+ # Validate manual mechanism selection
+ case "$MANUAL_MECHANISM" in
+ direct|DIRECT)
+ MECHANISM="DIRECT"
+ CONFIDENCE="1.0"
+ REASON="User manually selected direct mechanism"
+ ;;
+ socratic|SOCRATIC)
+ MECHANISM="SOCRATIC"
+ CONFIDENCE="1.0"
+ REASON="User manually selected socratic mechanism"
+ ;;
+ exploration|EXPLORATION)
+ MECHANISM="EXPLORATION"
+ CONFIDENCE="1.0"
+ REASON="User manually selected exploration mechanism"
+ ;;
+ consensus|CONSENSUS)
+ MECHANISM="CONSENSUS"
+ CONFIDENCE="1.0"
+ REASON="User manually selected consensus mechanism"
+ ;;
+ critique|CRITIQUE)
+ MECHANISM="CRITIQUE"
+ CONFIDENCE="1.0"
+ REASON="User manually selected critique mechanism"
+ ;;
+ synthesis|SYNTHESIS)
+ MECHANISM="SYNTHESIS"
+ CONFIDENCE="1.0"
+ REASON="User manually selected synthesis mechanism"
+ ;;
+ peer-review|peer_review|PEER_REVIEW|PEER-REVIEW)
+ MECHANISM="PEER_REVIEW"
+ CONFIDENCE="1.0"
+ REASON="User manually selected peer-review mechanism"
+ ;;
+ puzzle|PUZZLE)
+ MECHANISM="PUZZLE"
+ CONFIDENCE="1.0"
+ REASON="User manually selected puzzle mechanism"
+ ;;
+ *)
+ echo "Error: Invalid mechanism '$MANUAL_MECHANISM'" >&2
+ echo "Use --mechanisms to see available options." >&2
+ exit 1
+ ;;
+ esac
+ else
+ ANALYSIS_RESULT=$(analyze_prompt "$PROMPT")
+ MECHANISM=$(echo "$ANALYSIS_RESULT" | cut -d':' -f1)
+ CONFIDENCE=$(echo "$ANALYSIS_RESULT" | cut -d':' -f2)
+
+ # Validate confidence score
+ if [[ ! "$CONFIDENCE" =~ ^[0-9.]+$ ]]; then
+ CONFIDENCE="0.5"
+ log_warning "Invalid confidence score, defaulting to 0.5"
+ fi
fi
case "$MECHANISM" in
diff --git a/bash/talk-to-computer/puzzle_simple b/bash/talk-to-computer/puzzle_simple
deleted file mode 100644
index 50ce4fe..0000000
--- a/bash/talk-to-computer/puzzle_simple
+++ /dev/null
@@ -1,292 +0,0 @@
-#!/bin/bash
-
-# Get the directory where this script is located
-SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-
-# Source the logging system using absolute path
-source "${SCRIPT_DIR}/logging.sh"
-
-# Source the Lil tester for secure code testing
-source "${SCRIPT_DIR}/lil_tester.sh"
-
-# --- Model Configuration ---
-PUZZLE_MODEL="llama3:8b-instruct-q4_K_M"
-ANALYSIS_MODEL="phi3:3.8b-mini-4k-instruct-q4_K_M"
-
-# Validate and set models with fallbacks
-PUZZLE_MODEL=$(validate_model "$PUZZLE_MODEL" "gemma3n:e2b")
-if [ $? -ne 0 ]; then
- log_error "No valid puzzle model available"
- exit 1
-fi
-
-ANALYSIS_MODEL=$(validate_model "$ANALYSIS_MODEL" "gemma3n:e2b")
-if [ $? -ne 0 ]; then
- log_error "No valid analysis model available"
- exit 1
-fi
-
-# --- Defaults ---
-DEFAULT_ROUNDS=2
-
-# --- Argument Validation ---
-if [ "$#" -lt 1 ]; then
- echo -e "\n\tPuzzle"
- echo -e "\tThis script specializes in puzzle solving and coding challenges with Lil programming language expertise."
- echo -e "\n\tUsage: $0 [-f <file_path>] [-l <language>] \"<your puzzle/challenge>\" [number_of_rounds]"
- echo -e "\n\tExample: $0 -f ./challenge.txt -l lil \"How can I implement a sorting algorithm?\" 2"
- echo -e "\n\tIf number_of_rounds is not provided, the program will default to 2 rounds."
- echo -e "\n\t-f <file_path> (optional): Append the contents of the file to the prompt."
- echo -e "\n\t-l <language> (optional): Specify programming language focus (default: lil)."
- echo -e "\n"
- exit 1
-fi
-
-# --- Argument Parsing ---
-FILE_PATH=""
-LANGUAGE="lil"
-while getopts "f:l:" opt; do
- case $opt in
- f)
- FILE_PATH="$OPTARG"
- ;;
- l)
- LANGUAGE="$OPTARG"
- ;;
- *)
- log_error "Invalid option: -$OPTARG"
- exit 1
- ;;
- esac
-done
-shift $((OPTIND -1))
-
-PROMPT="$1"
-if [ -z "$2" ]; then
- ROUNDS=2
-else
- ROUNDS=$2
-fi
-
-# Validate prompt
-PROMPT=$(validate_prompt "$PROMPT")
-if [ $? -ne 0 ]; then
- exit 1
-fi
-
-# Validate file path if provided
-if [ -n "$FILE_PATH" ]; then
- if ! validate_file_path "$FILE_PATH"; then
- exit 1
- fi
- FILE_CONTENTS=$(cat "$FILE_PATH")
- PROMPT="$PROMPT\n[FILE CONTENTS]\n$FILE_CONTENTS\n[END FILE]"
-fi
-
-# Validate rounds
-if ! [[ "$ROUNDS" =~ ^[1-9][0-9]*$ ]] || [ "$ROUNDS" -gt 5 ]; then
- log_error "Invalid number of rounds: $ROUNDS (must be 1-5)"
- exit 1
-fi
-
-# --- File Initialization ---
-mkdir -p ~/tmp
-SESSION_FILE=~/tmp/puzzle_$(date +%Y%m%d_%H%M%S).txt
-
-# Initialize timing
-SESSION_ID=$(generate_session_id)
-start_timer "$SESSION_ID" "puzzle"
-
-echo "Puzzle Session Log: ${SESSION_FILE}"
-echo "---------------------------------"
-
-# Store the initial user prompt in the session file
-echo "USER PROMPT: ${PROMPT}" >> "${SESSION_FILE}"
-echo "LANGUAGE FOCUS: ${LANGUAGE}" >> "${SESSION_FILE}"
-echo "NUMBER OF ROUNDS: ${ROUNDS}" >> "${SESSION_FILE}"
-echo "" >> "${SESSION_FILE}"
-
-# --- Phase 1: Problem Analysis ---
-echo "Phase 1: Analyzing the puzzle or coding challenge..."
-echo "PHASE 1 - PROBLEM ANALYSIS:" >> "${SESSION_FILE}"
-
-PROBLEM_ANALYSIS_PROMPT="You are an expert puzzle solver and programming mentor specializing in the ${LANGUAGE} programming language. Analyze the following puzzle or coding challenge.
-
-CHALLENGE: ${PROMPT}
-
-Please provide a comprehensive analysis including:
-1. Problem type classification (algorithm, data structure, logic, etc.)
-2. Complexity assessment (time/space requirements)
-3. Key concepts and patterns involved
-4. Relevant ${LANGUAGE} language features that could help
-5. Potential solution approaches
-6. Common pitfalls or edge cases to consider
-
-Provide a clear, structured analysis that helps understand the problem."
-
-problem_analysis=$(ollama run "${PUZZLE_MODEL}" "${PROBLEM_ANALYSIS_PROMPT}")
-
-echo "PROBLEM ANALYSIS:" >> "${SESSION_FILE}"
-echo "${problem_analysis}" >> "${SESSION_FILE}"
-echo "" >> "${SESSION_FILE}"
-
-# --- Phase 2: Solution Strategy ---
-echo "Phase 2: Developing solution strategies..."
-echo "PHASE 2 - SOLUTION STRATEGY:" >> "${SESSION_FILE}"
-
-SOLUTION_STRATEGY_PROMPT="Based on the problem analysis, develop multiple solution strategies for this puzzle or coding challenge.
-
-ORIGINAL CHALLENGE: ${PROMPT}
-
-PROBLEM ANALYSIS: ${problem_analysis}
-
-Please provide:
-1. At least 2-3 different solution approaches
-2. Algorithmic complexity analysis for each approach
-3. Trade-offs between different solutions
-4. Specific ${LANGUAGE} language constructs that would be useful
-5. Implementation considerations and challenges
-6. Testing and validation strategies
-
-Focus on practical, implementable solutions with clear reasoning."
-
-solution_strategy=$(ollama run "${PUZZLE_MODEL}" "${SOLUTION_STRATEGY_PROMPT}")
-
-echo "SOLUTION STRATEGY:" >> "${SESSION_FILE}"
-echo "${solution_strategy}" >> "${SESSION_FILE}"
-echo "" >> "${SESSION_FILE}"
-
-# --- Phase 3: Implementation Guidance ---
-echo "Phase 3: Providing implementation guidance..."
-echo "PHASE 3 - IMPLEMENTATION GUIDANCE:" >> "${SESSION_FILE}"
-
-IMPLEMENTATION_PROMPT="Provide detailed implementation guidance for the best solution approach to this puzzle or coding challenge.
-
-ORIGINAL CHALLENGE: ${PROMPT}
-PROBLEM ANALYSIS: ${problem_analysis}
-SOLUTION STRATEGY: ${solution_strategy}
-
-Please provide:
-1. Step-by-step implementation plan
-2. Complete code example in ${LANGUAGE} (if applicable)
-3. Explanation of key code sections and patterns
-4. Variable naming and structure recommendations
-5. Error handling and edge case considerations
-6. Performance optimization tips
-7. Testing and debugging guidance
-
-Make the implementation clear and educational, explaining the reasoning behind each decision."
-
-implementation_guidance=$(ollama run "${PUZZLE_MODEL}" "${IMPLEMENTATION_PROMPT}")
-
-echo "IMPLEMENTATION GUIDANCE:" >> "${SESSION_FILE}"
-echo "${implementation_guidance}" >> "${SESSION_FILE}"
-echo "" >> "${SESSION_FILE}"
-
-# --- Phase 4: Code Testing (if applicable) ---
-if [[ "$LANGUAGE" == "lil" ]] && [[ "$implementation_guidance" =~ (on [a-zA-Z_][a-zA-Z0-9_]* do|function|procedure) ]]; then
- echo "Phase 4: Testing the Lil code implementation..."
- echo "PHASE 4 - CODE TESTING:" >> "${SESSION_FILE}"
-
- # Simple code extraction - look for function definitions
- lil_code=""
- if echo "$implementation_guidance" | grep -q "on [a-zA-Z_][a-zA-Z0-9_]* do"; then
- lil_code=$(echo "$implementation_guidance" | grep -A 20 "on [a-zA-Z_][a-zA-Z0-9_]* do" | head -20)
- fi
-
- if [ -n "$lil_code" ]; then
- echo "Extracted Lil code for testing:"
- echo "----------------------------------------"
- echo "$lil_code"
- echo "----------------------------------------"
-
- # Test the extracted code
- test_result=$(test_lil_script "$lil_code" "puzzle_implementation")
- test_exit_code=$?
-
- echo "CODE TESTING RESULTS:" >> "${SESSION_FILE}"
- echo "$test_result" >> "${SESSION_FILE}"
- echo "" >> "${SESSION_FILE}"
-
- if [ $test_exit_code -eq 0 ]; then
- echo "✅ Lil code testing PASSED"
- else
- echo "❌ Lil code testing FAILED"
- echo "Note: The code may have syntax errors or runtime issues."
- fi
- else
- echo "No executable Lil code found in implementation guidance."
- echo "CODE TESTING: No executable code found" >> "${SESSION_FILE}"
- fi
-else
- echo "Phase 4: Skipping code testing (not Lil language or no executable code)"
- echo "CODE TESTING: Skipped (not applicable)" >> "${SESSION_FILE}"
-fi
-
-# --- Phase 5: Solution Validation ---
-echo "Phase 5: Validating and reviewing the solution..."
-echo "PHASE 5 - SOLUTION VALIDATION:" >> "${SESSION_FILE}"
-
-VALIDATION_PROMPT="Review and validate the proposed solution to ensure it's correct, efficient, and well-implemented.
-
-ORIGINAL CHALLENGE: ${PROMPT}
-PROBLEM ANALYSIS: ${problem_analysis}
-SOLUTION STRATEGY: ${solution_strategy}
-IMPLEMENTATION: ${implementation_guidance}
-
-Please provide:
-1. Code review and correctness verification
-2. Edge case analysis and testing scenarios
-3. Performance analysis and optimization opportunities
-4. Alternative approaches or improvements
-5. Common mistakes to avoid
-6. Learning resources and next steps
-7. Final recommendations and best practices
-
-Ensure the solution is robust, maintainable, and follows ${LANGUAGE} best practices."
-
-solution_validation=$(ollama run "${ANALYSIS_MODEL}" "${VALIDATION_PROMPT}")
-
-echo "SOLUTION VALIDATION:" >> "${SESSION_FILE}"
-echo "${solution_validation}" >> "${SESSION_FILE}"
-
-# End timing
-duration=$(end_timer "$SESSION_ID" "puzzle")
-
-# --- Final Output ---
-echo "---------------------------------"
-echo "Puzzle-solving process complete."
-echo "---------------------------------"
-echo ""
-echo "PROBLEM ANALYSIS:"
-echo "================="
-echo "${problem_analysis}"
-echo ""
-echo "SOLUTION STRATEGY:"
-echo "=================="
-echo "${solution_strategy}"
-echo ""
-echo "IMPLEMENTATION GUIDANCE:"
-echo "========================"
-echo "${implementation_guidance}"
-echo ""
-if [[ "$LANGUAGE" == "lil" ]] && [[ "$implementation_guidance" =~ (on [a-zA-Z_][a-zA-Z0-9_]* do|function|procedure) ]]; then
- echo "CODE TESTING:"
- echo "============="
- if [ -n "$lil_code" ]; then
- echo "✅ Lil code was tested successfully"
- echo "Test results logged in session file"
- else
- echo "No executable code found for testing"
- fi
- echo ""
-fi
-echo "SOLUTION VALIDATION:"
-echo "===================="
-echo "${solution_validation}"
-echo ""
-echo "Language focus: ${LANGUAGE}"
-echo "Rounds completed: ${ROUNDS}"
-echo "Execution time: ${duration} seconds"
-echo ""
-echo "Full puzzle-solving log: ${SESSION_FILE}"