### Install OpenCode Shell Strategy Plugin Source: https://context7.com/jredeker/opencode-shell-strategy/llms.txt Instructions to clone the plugin repository and configure OpenCode to load its rules. This involves adding the plugin's markdown file to the OpenCode configuration JSON. ```bash # Clone the repository to OpenCode plugin directory git clone https://github.com/JRedeker/opencode-shell-strategy.git ~/.config/opencode/plugin/shell-strategy # Add to OpenCode config (~/.config/opencode/opencode.json) { "instructions": [ "~/.config/opencode/plugin/shell-strategy/shell_strategy.md" ] } # Restart OpenCode to load the rules automatically ``` -------------------------------- ### Clone Repository - Bash Source: https://github.com/jredeker/opencode-shell-strategy/blob/trunk/README.md Clones the opencode-shell-strategy repository into the specified OpenCode configuration directory. This is the first step in installing the plugin. ```bash git clone https://github.com/JRedeker/opencode-shell-strategy.git ~/.config/opencode/plugin/shell-strategy ``` -------------------------------- ### Execute Python and Node.js Code Non-Interactively Source: https://context7.com/jredeker/opencode-shell-strategy/llms.txt Provides examples of running Python and Node.js code directly from the command line using the `-c` flag for inline execution or by running script files. This avoids launching interactive REPL sessions, which is essential for automation. ```bash # Python - Execute code inline python -c "print('Hello, World!')" # Output: Hello, World! ``` ```bash # Python - Run script file python script.py --arg1 value1 # Output: Script executed with arg1=value1 ``` ```bash # Node.js - Execute code inline node -e "console.log('Hello from Node')" # Output: Hello from Node ``` ```bash # Node.js - Run script file node app.js # Output: Server running on port 3000 ``` ```bash # Python one-liner for JSON processing python -c "import json; data = {'key': 'value'}; print(json.dumps(data))" # Output: {"key": "value"} ``` ```bash # Node.js one-liner for calculations node -e "console.log(Array.from({length: 5}, (_, i) => i * 2))" # Output: [ 0, 2, 4, 6, 8 ] ``` -------------------------------- ### Run Docker Containers Non-Interactively Source: https://context7.com/jredeker/opencode-shell-strategy/llms.txt Shows how to execute Docker commands without interactive flags (-it). This is crucial for automated scripts and CI/CD pipelines where user interaction is not possible. Includes running containers, executing commands within them, building images with plain progress, and starting compose in detached mode. ```bash # Run container non-interactively (no -it flags) docker run --rm alpine echo "Hello from container" # Output: Hello from container ``` ```bash # Execute command in container (no -it flags) docker exec my_container cat /etc/hostname # Output: my_container ``` ```bash # Build with plain progress for CI logs docker build --progress=plain -t myapp:latest . # Output: #1 [internal] load build definition from Dockerfile # #2 [1/3] FROM alpine:latest # #3 [2/3] RUN apk add --no-cache nodejs # #4 exporting to image ``` ```bash # Compose in detached mode docker-compose up -d # Output: Creating network "app_default" with the default driver # Creating app_web_1 ... done ``` -------------------------------- ### Non-Interactive Package Manager Commands Source: https://context7.com/jredeker/opencode-shell-strategy/llms.txt Demonstrates using non-interactive flags and environment variables with various package managers (npm, yarn, pnpm, bun, apt, pip, homebrew) to ensure automated installations and updates without user intervention. ```bash # NPM - Initialize project without prompts npm init -y # Output: Wrote to /project/package.json # NPM - Install packages with automatic yes npm install --yes express lodash # Output: added 57 packages in 2.3s # Yarn - Non-interactive install yarn install --non-interactive # Output: Done in 1.42s # PNPM - Silent reporter for CI pnpm install --reporter=silent # Output: (no output, packages installed) # Bun - Initialize without prompts bun init -y # Output: Done! A package.json file was saved. # APT - Install with automatic yes apt-get install -y curl wget # Output: Setting up curl... Setting up wget... # PIP - Install without input prompts pip install --no-input requests numpy # Output: Successfully installed requests-2.31.0 numpy-1.24.0 # Homebrew - Skip auto-update HOMEBREW_NO_AUTO_UPDATE=1 brew install jq # Output: ==> Installing jq... ==> Pouring jq... ``` -------------------------------- ### Add to OpenCode Config - JSON Source: https://github.com/jredeker/opencode-shell-strategy/blob/trunk/README.md Adds the shell strategy instruction file to the OpenCode configuration. This ensures the rules are loaded at the start of every session. ```json { "instructions": [ "~/.config/opencode/plugin/shell-strategy/shell_strategy.md" ] } ``` -------------------------------- ### Non-Interactive Git Operations Source: https://context7.com/jredeker/opencode-shell-strategy/llms.txt Provides examples of Git commands executed with flags that bypass interactive prompts, such as commit messages, merges, pulls, and rebasing, ensuring smooth operation in automated scripts. ```bash # Commit with inline message (avoids editor) git commit -m "Add new feature" # Output: [main abc1234] Add new feature # 1 file changed, 10 insertions(+) # Merge without edit prompt git merge --no-edit feature-branch # Output: Merge made by the 'ort' strategy. # Pull without edit prompt git pull --no-edit origin main # Output: Already up to date. (or merge output) # Rebase non-interactively (no -i flag) git rebase main # Output: Successfully rebased and updated refs/heads/feature. # Add all files (no interactive -p flag) git add . # Output: (no output, files staged) # Log without pager git --no-pager log -n 5 --oneline # Output: abc1234 Add new feature # def5678 Fix bug # ghi9012 Initial commit # Diff without pager git --no-pager diff HEAD~1 # Output: diff --git a/file.js b/file.js # +console.log("new line"); ``` -------------------------------- ### Handle Prompts Non-Interactively with Pipes and Heredocs Source: https://context7.com/jredeker/opencode-shell-strategy/llms.txt Demonstrates techniques for handling commands that require user input by using pipes (`yes`, `echo`), heredocs (`<