-
Notifications
You must be signed in to change notification settings - Fork 25
Add status command, validation script, troubleshooting guide, and CI/CD (fixes #2) #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
surajsahani
wants to merge
4
commits into
gemini-cli-extensions:main
Choose a base branch
from
surajsahani:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a2b057a
Add status command, validation script, troubleshooting guide, and CI/CD
surajsahani 89884e7
Fix: Strip /ralph:loop prefix from stored prompt
surajsahani d1e5425
Address code review feedback
surajsahani 25c1d8e
Improve test isolation in status_test.sh
surajsahani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| name: Test Ralph Extension | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
| pull_request: | ||
| branches: [ main ] | ||
|
|
||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - name: Install dependencies | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y jq | ||
|
|
||
| - name: Make scripts executable | ||
| run: | | ||
| chmod +x scripts/*.sh | ||
| chmod +x hooks/*.sh | ||
| chmod +x tests/*.sh | ||
|
|
||
| - name: Run setup tests | ||
| run: bash tests/setup_test.sh | ||
|
|
||
| - name: Run hook tests | ||
| run: bash tests/hook_test.sh | ||
|
|
||
| - name: Run status tests | ||
| run: bash tests/status_test.sh | ||
|
|
||
| - name: Validate scripts | ||
| run: | | ||
| bash -n scripts/setup.sh | ||
| bash -n scripts/cancel.sh | ||
| bash -n scripts/status.sh | ||
| bash -n scripts/validate.sh | ||
| bash -n hooks/stop-hook.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,85 @@ | ||
| # Troubleshooting Ralph | ||
|
|
||
| ## Common Issues | ||
|
|
||
| ### Loop Won't Start | ||
|
|
||
| **Symptom**: Running `/ralph:loop` doesn't start the loop. | ||
|
|
||
| **Solutions**: | ||
| 1. Verify hooks are enabled in `~/.gemini/settings.json`: | ||
| ```json | ||
| { | ||
| "hooksConfig": { | ||
| "enabled": true | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| 2. Check that the extension directory is included: | ||
| ```json | ||
| { | ||
| "context": { | ||
| "includeDirectories": ["~/.gemini/extensions/ralph"] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| 3. Ensure `jq` is installed: `brew install jq` | ||
|
|
||
| ### Loop Won't Stop | ||
|
|
||
| **Symptom**: Loop continues even after completion promise is output. | ||
|
|
||
| **Solutions**: | ||
| 1. Verify the promise format is exact: `<promise>YOUR_TEXT</promise>` | ||
| 2. Check the state file: `cat .gemini/ralph/state.json` | ||
| 3. Manually cancel: `/ralph:cancel` | ||
|
|
||
| ### Ghost Loop | ||
|
|
||
| **Symptom**: Old loop interferes with new tasks. | ||
|
|
||
| **Solution**: The hook should auto-detect this, but you can manually clean up: | ||
| ```bash | ||
| rm -rf .gemini/ralph | ||
| ``` | ||
|
|
||
| ### Permission Errors | ||
|
|
||
| **Symptom**: Scripts fail with permission denied. | ||
|
|
||
| **Solution**: Make scripts executable: | ||
| ```bash | ||
| chmod +x ~/.gemini/extensions/ralph/scripts/*.sh | ||
| chmod +x ~/.gemini/extensions/ralph/hooks/*.sh | ||
| ``` | ||
|
|
||
| ## Debugging | ||
|
|
||
| ### Check Loop Status | ||
| ```bash | ||
| /ralph:status | ||
| ``` | ||
|
|
||
| ### View State File | ||
| ```bash | ||
| cat .gemini/ralph/state.json | jq | ||
| ``` | ||
|
|
||
| ### Enable Debug Logging | ||
| Add to your prompt: | ||
| ``` | ||
| Before each action, output the current iteration number and your plan. | ||
| ``` | ||
|
|
||
| ## Getting Help | ||
|
|
||
| If you encounter issues not covered here: | ||
| 1. Check the [README](README.md) for configuration details | ||
| 2. Review test files in `tests/` for expected behavior | ||
| 3. Open an issue on GitHub with: | ||
| - Your `~/.gemini/settings.json` (redact sensitive info) | ||
| - The command you ran | ||
| - Contents of `.gemini/ralph/state.json` (if exists) | ||
| - Error messages | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| description = "Check the status of the current Ralph loop." | ||
| prompt = """ | ||
| You are checking the Ralph loop status. | ||
|
|
||
| Run the status script to display the current loop state: | ||
| ```bash | ||
| bash "${extensionPath}/scripts/status.sh" | ||
| ``` | ||
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| #!/bin/bash | ||
| # Copyright 2026 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # Bump version in gemini-extension.json | ||
|
|
||
| if [[ $# -ne 1 ]]; then | ||
| echo "Usage: $0 <new_version>" | ||
| echo "Example: $0 1.1.0" | ||
| exit 1 | ||
| fi | ||
|
|
||
| NEW_VERSION="$1" | ||
|
|
||
| if [[ ! "$NEW_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| echo "Error: Version must be in format X.Y.Z" | ||
| exit 1 | ||
| fi | ||
|
|
||
| jq --arg version "$NEW_VERSION" '.version = $version' gemini-extension.json > gemini-extension.json.tmp | ||
| mv gemini-extension.json.tmp gemini-extension.json | ||
|
surajsahani marked this conversation as resolved.
Outdated
|
||
|
|
||
| echo "✅ Version bumped to $NEW_VERSION" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #!/bin/bash | ||
| # Copyright 2026 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| STATE_FILE=".gemini/ralph/state.json" | ||
|
|
||
| if [[ ! -f "$STATE_FILE" ]]; then | ||
| echo "Ralph: I'm not doing anything right now!" >&2 | ||
| exit 0 | ||
| fi | ||
|
|
||
| echo "🔄 Ralph Loop Status" >&2 | ||
| echo "===================" >&2 | ||
| echo "" >&2 | ||
|
|
||
| ACTIVE=$(jq -r '.active' "$STATE_FILE") | ||
| CURRENT=$(jq -r '.current_iteration' "$STATE_FILE") | ||
| MAX=$(jq -r '.max_iterations' "$STATE_FILE") | ||
| PROMISE=$(jq -r '.completion_promise' "$STATE_FILE") | ||
| PROMPT=$(jq -r '.original_prompt' "$STATE_FILE") | ||
| STARTED=$(jq -r '.started_at' "$STATE_FILE") | ||
|
|
||
| echo "Status: $([ "$ACTIVE" = "true" ] && echo "🟢 Active" || echo "🔴 Inactive")" >&2 | ||
| echo "Iteration: $CURRENT / $MAX" >&2 | ||
| echo "Started: $STARTED" >&2 | ||
| echo "Task: $PROMPT" >&2 | ||
|
|
||
| if [[ -n "$PROMISE" ]]; then | ||
| echo "Completion Promise: $PROMISE" >&2 | ||
| fi | ||
|
|
||
| echo "" >&2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| #!/bin/bash | ||
| # Copyright 2026 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| # Validate Ralph prerequisites | ||
|
|
||
| echo "🔍 Validating Ralph prerequisites..." | ||
|
|
||
| # Check for jq | ||
| if ! command -v jq &> /dev/null; then | ||
| echo "❌ Error: jq is not installed. Install it with: brew install jq" | ||
|
surajsahani marked this conversation as resolved.
Outdated
|
||
| exit 1 | ||
| fi | ||
|
|
||
| # Check for bash version (need 4.0+) | ||
| if [[ "${BASH_VERSINFO[0]}" -lt 4 ]]; then | ||
| echo "⚠️ Warning: Bash version ${BASH_VERSION} detected. Bash 4.0+ recommended." | ||
| fi | ||
|
|
||
| # Check hooks configuration | ||
| SETTINGS_FILE="$HOME/.gemini/settings.json" | ||
| if [[ -f "$SETTINGS_FILE" ]]; then | ||
| HOOKS_ENABLED=$(jq -r '.hooksConfig.enabled // false' "$SETTINGS_FILE") | ||
| if [[ "$HOOKS_ENABLED" != "true" ]]; then | ||
| echo "⚠️ Warning: Hooks are not enabled in ~/.gemini/settings.json" | ||
| echo " Add: \"hooksConfig\": { \"enabled\": true }" | ||
| fi | ||
| else | ||
| echo "⚠️ Warning: ~/.gemini/settings.json not found" | ||
| fi | ||
|
|
||
| echo "✅ Validation complete!" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| #!/bin/bash | ||
| # Copyright 2026 Google LLC | ||
| # Licensed under the Apache License, Version 2.0 | ||
|
|
||
| STATE_FILE=".gemini/ralph/state.json" | ||
| STATE_DIR=".gemini/ralph" | ||
| STATUS_SCRIPT="./scripts/status.sh" | ||
|
|
||
| setup() { | ||
| mkdir -p "$STATE_DIR" | ||
| } | ||
|
|
||
| cleanup() { | ||
| rm -f "$STATE_FILE" | ||
| if [[ -d "$STATE_DIR" ]]; then | ||
| rmdir "$STATE_DIR" 2>/dev/null || true | ||
| fi | ||
| } | ||
|
|
||
| trap cleanup EXIT | ||
|
|
||
| echo "Running Test 1: No active loop..." | ||
| setup | ||
| OUTPUT=$("$STATUS_SCRIPT" 2>&1) | ||
| if [[ "$OUTPUT" != *"not doing anything"* ]]; then | ||
| echo "FAIL: Expected 'not doing anything' message" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Running Test 2: Active loop status..." | ||
| setup | ||
|
surajsahani marked this conversation as resolved.
|
||
| jq -n '{ | ||
| active: true, | ||
| current_iteration: 3, | ||
| max_iterations: 10, | ||
| completion_promise: "DONE", | ||
| original_prompt: "Test task", | ||
| started_at: "2026-01-27T12:00:00Z" | ||
| }' > "$STATE_FILE" | ||
|
|
||
| OUTPUT=$("$STATUS_SCRIPT" 2>&1) | ||
| if [[ "$OUTPUT" != *"Active"* ]] || [[ "$OUTPUT" != *"3 / 10"* ]]; then | ||
| echo "FAIL: Expected active status with iteration count" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "PASS: All tests passed!" | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.