mirror of
https://github.com/obra/superpowers.git
synced 2026-04-30 05:59:05 +08:00
Compare commits
1 Commits
codex/pri-
...
codex/pri-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
57aa869f53 |
@@ -36,9 +36,6 @@
|
||||
"I've got an idea for something I'd like to build.",
|
||||
"Let's add a feature to this project."
|
||||
],
|
||||
"websiteURL": "https://github.com/obra/superpowers",
|
||||
"privacyPolicyURL": "https://docs.github.com/en/site-policy/privacy-policies/github-general-privacy-statement",
|
||||
"termsOfServiceURL": "https://docs.github.com/en/site-policy/github-terms/github-terms-of-service",
|
||||
"brandColor": "#F59E0B",
|
||||
"composerIcon": "./assets/superpowers-small.svg",
|
||||
"logo": "./assets/app-icon.png",
|
||||
|
||||
26
README.md
26
README.md
@@ -119,32 +119,6 @@ To update:
|
||||
gemini extensions update superpowers
|
||||
```
|
||||
|
||||
### Google Antigravity
|
||||
|
||||
- Clone this repository to `~/.agents/superpowers` (or the location of your choice):
|
||||
|
||||
```bash
|
||||
git clone https://github.com/obra/superpowers.git ~/.agents/superpowers
|
||||
```
|
||||
|
||||
- In Antigravity, open Antigravity -> Settings -> Antigravity Settings -> Customizations -> Skill Custom Paths.
|
||||
- Add `~/.agents/superpowers` (or your chosen checkout path) as a global skills path.
|
||||
- Verify the setup by asking Antigravity whether it can access `superpowers:brainstorming`.
|
||||
|
||||
### Factory Droid
|
||||
|
||||
In Droid, register the marketplace:
|
||||
|
||||
```bash
|
||||
droid plugin marketplace add https://github.com/obra/superpowers
|
||||
```
|
||||
|
||||
Then install:
|
||||
|
||||
```bash
|
||||
droid plugin install superpowers@superpowers
|
||||
```
|
||||
|
||||
## The Basic Workflow
|
||||
|
||||
1. **brainstorming** - Activates before writing code. Refines rough ideas through questions, explores alternatives, presents design in sections for validation. Saves design document.
|
||||
|
||||
@@ -4,8 +4,7 @@
|
||||
#
|
||||
# Sync this superpowers checkout → prime-radiant-inc/openai-codex-plugins.
|
||||
# Clones the fork fresh into a temp dir, rsyncs tracked upstream plugin content
|
||||
# (including committed Codex files under .codex-plugin/ and assets/), preserves
|
||||
# OpenAI-owned marketplace metadata already in the destination plugin, commits,
|
||||
# (including committed Codex files under .codex-plugin/ and assets/), commits,
|
||||
# pushes a sync branch, and opens a PR.
|
||||
# Path/user agnostic — auto-detects upstream from script location.
|
||||
#
|
||||
@@ -224,7 +223,6 @@ fi
|
||||
DEST="$DEST_REPO/$DEST_REL"
|
||||
PREVIEW_REPO="$DEST_REPO"
|
||||
PREVIEW_DEST="$DEST"
|
||||
SYNC_SOURCE=""
|
||||
|
||||
overlay_destination_paths() {
|
||||
local repo="$1"
|
||||
@@ -293,7 +291,7 @@ apply_to_preview_checkout() {
|
||||
mkdir -p "$PREVIEW_DEST"
|
||||
fi
|
||||
|
||||
rsync "${RSYNC_ARGS[@]}" "$SYNC_SOURCE/" "$PREVIEW_DEST/"
|
||||
rsync "${RSYNC_ARGS[@]}" "$UPSTREAM/" "$PREVIEW_DEST/"
|
||||
}
|
||||
|
||||
preview_checkout_has_changes() {
|
||||
@@ -318,36 +316,6 @@ for pat in "${EXCLUDES[@]}"; do RSYNC_ARGS+=(--exclude="$pat"); done
|
||||
append_git_ignored_directory_excludes
|
||||
append_git_ignored_file_excludes
|
||||
|
||||
copy_preserved_destination_metadata() {
|
||||
local destination="$1"
|
||||
local source="$2"
|
||||
local path
|
||||
local rel
|
||||
|
||||
[[ -d "$destination/skills" ]] || return 0
|
||||
|
||||
while IFS= read -r -d '' path; do
|
||||
rel="${path#"$destination"/}"
|
||||
mkdir -p "$source/$(dirname "$rel")"
|
||||
cp -p "$path" "$source/$rel"
|
||||
done < <(find "$destination/skills" -path '*/agents/openai.yaml' -type f -print0)
|
||||
}
|
||||
|
||||
prepare_sync_source() {
|
||||
local destination="$1"
|
||||
|
||||
[[ -n "$CLEANUP_DIR" ]] || CLEANUP_DIR="$(mktemp -d)"
|
||||
|
||||
SYNC_SOURCE="$CLEANUP_DIR/source-overlay"
|
||||
rm -rf "$SYNC_SOURCE"
|
||||
mkdir -p "$SYNC_SOURCE"
|
||||
|
||||
rsync "${RSYNC_ARGS[@]}" "$UPSTREAM/" "$SYNC_SOURCE/" >/dev/null
|
||||
copy_preserved_destination_metadata "$destination" "$SYNC_SOURCE"
|
||||
}
|
||||
|
||||
prepare_sync_source "$PREVIEW_DEST"
|
||||
|
||||
# =============================================================================
|
||||
# Dry run preview (always shown)
|
||||
# =============================================================================
|
||||
@@ -363,7 +331,7 @@ if [[ $BOOTSTRAP -eq 1 ]]; then
|
||||
fi
|
||||
echo ""
|
||||
echo "=== Preview (rsync --dry-run) ==="
|
||||
rsync "${RSYNC_ARGS[@]}" --dry-run --itemize-changes "$SYNC_SOURCE/" "$PREVIEW_DEST/"
|
||||
rsync "${RSYNC_ARGS[@]}" --dry-run --itemize-changes "$UPSTREAM/" "$PREVIEW_DEST/"
|
||||
echo "=== End preview ==="
|
||||
echo ""
|
||||
|
||||
@@ -400,7 +368,7 @@ echo "Syncing upstream content..."
|
||||
if [[ $BOOTSTRAP -eq 1 ]]; then
|
||||
mkdir -p "$DEST"
|
||||
fi
|
||||
rsync "${RSYNC_ARGS[@]}" "$SYNC_SOURCE/" "$DEST/"
|
||||
rsync "${RSYNC_ARGS[@]}" "$UPSTREAM/" "$DEST/"
|
||||
|
||||
# Bail early if nothing actually changed
|
||||
cd "$DEST_REPO"
|
||||
|
||||
@@ -73,19 +73,6 @@ assert_matches() {
|
||||
fi
|
||||
}
|
||||
|
||||
assert_not_matches() {
|
||||
local haystack="$1"
|
||||
local pattern="$2"
|
||||
local description="$3"
|
||||
|
||||
if printf '%s' "$haystack" | grep -Eq -- "$pattern"; then
|
||||
fail "$description"
|
||||
echo " did not expect to match: $pattern"
|
||||
else
|
||||
pass "$description"
|
||||
fi
|
||||
}
|
||||
|
||||
assert_path_absent() {
|
||||
local path="$1"
|
||||
local description="$2"
|
||||
@@ -257,22 +244,6 @@ EOF
|
||||
commit_fixture "$repo" "Initial destination fixture"
|
||||
}
|
||||
|
||||
add_openai_agent_metadata_fixture() {
|
||||
local repo="$1"
|
||||
|
||||
mkdir -p "$repo/plugins/superpowers/skills/example/agents"
|
||||
|
||||
cat > "$repo/plugins/superpowers/skills/example/agents/openai.yaml" <<'EOF'
|
||||
interface:
|
||||
display_name: "Example"
|
||||
short_description: "Destination-owned OpenAI metadata"
|
||||
EOF
|
||||
|
||||
git -C "$repo" add plugins/superpowers/skills/example/agents/openai.yaml
|
||||
|
||||
commit_fixture "$repo" "Add OpenAI agent metadata fixture"
|
||||
}
|
||||
|
||||
dirty_tracked_destination_skill() {
|
||||
local repo="$1"
|
||||
|
||||
@@ -290,7 +261,6 @@ write_synced_destination_fixture() {
|
||||
"$repo/plugins/superpowers/.codex-plugin" \
|
||||
"$repo/plugins/superpowers/.private-journal" \
|
||||
"$repo/plugins/superpowers/assets" \
|
||||
"$repo/plugins/superpowers/skills/example/agents" \
|
||||
"$repo/plugins/superpowers/skills/example"
|
||||
|
||||
cat > "$repo/plugins/superpowers/.codex-plugin/plugin.json" <<EOF
|
||||
@@ -312,19 +282,12 @@ EOF
|
||||
Fixture content.
|
||||
EOF
|
||||
|
||||
cat > "$repo/plugins/superpowers/skills/example/agents/openai.yaml" <<'EOF'
|
||||
interface:
|
||||
display_name: "Example"
|
||||
short_description: "Destination-owned OpenAI metadata"
|
||||
EOF
|
||||
|
||||
printf 'tracked keep\n' > "$repo/plugins/superpowers/.private-journal/keep.txt"
|
||||
|
||||
git -C "$repo" add \
|
||||
plugins/superpowers/.codex-plugin/plugin.json \
|
||||
plugins/superpowers/assets/app-icon.png \
|
||||
plugins/superpowers/assets/superpowers-small.svg \
|
||||
plugins/superpowers/skills/example/agents/openai.yaml \
|
||||
plugins/superpowers/skills/example/SKILL.md \
|
||||
plugins/superpowers/.private-journal/keep.txt
|
||||
|
||||
@@ -452,7 +415,6 @@ main() {
|
||||
local help_output
|
||||
local script_source
|
||||
local dirty_skill_path
|
||||
local noop_openai_metadata_path
|
||||
|
||||
echo "=== Test: sync-to-codex-plugin dry-run regression ==="
|
||||
|
||||
@@ -481,7 +443,6 @@ main() {
|
||||
|
||||
init_repo "$dest"
|
||||
write_destination_fixture "$dest"
|
||||
add_openai_agent_metadata_fixture "$dest"
|
||||
checkout_fixture_branch "$dest" "$dest_branch"
|
||||
dirty_tracked_destination_skill "$dest"
|
||||
|
||||
@@ -529,7 +490,6 @@ main() {
|
||||
preview_section="$(printf '%s\n' "$preview_output" | sed -n '/^=== Preview (rsync --dry-run) ===$/,/^=== End preview ===$/p')"
|
||||
stale_preview_section="$(printf '%s\n' "$stale_preview_output" | sed -n '/^=== Preview (rsync --dry-run) ===$/,/^=== End preview ===$/p')"
|
||||
dirty_skill_path="$dirty_apply_dest/plugins/superpowers/skills/example/SKILL.md"
|
||||
noop_openai_metadata_path="$noop_apply_dest/plugins/superpowers/skills/example/agents/openai.yaml"
|
||||
|
||||
echo ""
|
||||
echo "Preview assertions..."
|
||||
@@ -545,7 +505,6 @@ main() {
|
||||
assert_not_contains "$preview_output" "Overlay file (.codex-plugin/plugin.json) will be regenerated" "Preview omits overlay regeneration note"
|
||||
assert_not_contains "$preview_output" "Assets (superpowers-small.svg, app-icon.png) will be seeded from" "Preview omits assets seeding note"
|
||||
assert_contains "$preview_section" "skills/example/SKILL.md" "Preview reflects dirty tracked destination file"
|
||||
assert_not_matches "$preview_section" "\\*deleting +skills/example/agents/openai\\.yaml" "Preview preserves destination-owned OpenAI agent metadata"
|
||||
assert_current_branch "$dest" "$dest_branch" "Preview leaves destination checkout on its original branch"
|
||||
assert_branch_absent "$dest" "sync/superpowers-*" "Preview does not create sync branch in destination checkout"
|
||||
|
||||
@@ -583,9 +542,6 @@ Locally modified fixture content." "Dirty local apply preserves tracked working-
|
||||
assert_contains "$noop_apply_output" "No changes — embedded plugin was already in sync with upstream" "Clean no-op local apply reports no changes"
|
||||
assert_current_branch "$noop_apply_dest" "$noop_apply_dest_branch" "Clean no-op local apply leaves destination checkout on its original branch"
|
||||
assert_branch_absent "$noop_apply_dest" "sync/superpowers-*" "Clean no-op local apply does not create sync branch in destination checkout"
|
||||
assert_file_equals "$noop_openai_metadata_path" "interface:
|
||||
display_name: \"Example\"
|
||||
short_description: \"Destination-owned OpenAI metadata\"" "Clean no-op local apply preserves OpenAI agent metadata"
|
||||
|
||||
echo ""
|
||||
echo "Missing manifest assertions..."
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
# Test: Skill Priority Resolution
|
||||
# Documents current OpenCode duplicate-name behavior for local and bundled
|
||||
# skills. The desired local-shadowing behavior is tracked separately; this
|
||||
# test keeps the integration suite honest without adding a plugin workaround.
|
||||
# Verifies that skills are resolved with correct priority: project > personal > superpowers
|
||||
# NOTE: These tests require OpenCode to be installed and configured
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
OPENCODE_TEST_TIMEOUT_SECONDS="${OPENCODE_TEST_TIMEOUT_SECONDS:-120}"
|
||||
|
||||
echo "=== Test: Skill Priority Resolution ==="
|
||||
|
||||
@@ -99,119 +96,103 @@ if ! command -v opencode &> /dev/null; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
run_opencode() {
|
||||
local result_var="$1"
|
||||
local dir="$2"
|
||||
local prompt="$3"
|
||||
local command_output
|
||||
local exit_code
|
||||
|
||||
set +e
|
||||
command_output=$(cd "$dir" && timeout "${OPENCODE_TEST_TIMEOUT_SECONDS}s" opencode run --print-logs --format json "$prompt" 2>&1)
|
||||
exit_code=$?
|
||||
set -e
|
||||
|
||||
if [ $exit_code -eq 124 ]; then
|
||||
echo " [FAIL] OpenCode timed out after ${OPENCODE_TEST_TIMEOUT_SECONDS}s"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $exit_code -ne 0 ]; then
|
||||
echo " [FAIL] OpenCode returned non-zero exit code: $exit_code"
|
||||
echo " Output was:"
|
||||
awk 'NR <= 80 { print }' <<<"$command_output"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf -v "$result_var" '%s' "$command_output"
|
||||
}
|
||||
|
||||
assert_contains() {
|
||||
local output="$1"
|
||||
local needle="$2"
|
||||
local message="$3"
|
||||
|
||||
if [[ "$output" == *"$needle"* ]]; then
|
||||
echo " [PASS] $message"
|
||||
else
|
||||
echo " [FAIL] $message"
|
||||
echo " Expected to find: $needle"
|
||||
echo " Output was:"
|
||||
awk 'NR <= 80 { print }' <<<"$output"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
first_skill_tool_event() {
|
||||
awk '/"type":"tool_use"/ && /"tool":"skill"/ { print; exit }' <<<"$1"
|
||||
}
|
||||
|
||||
describe_priority_result() {
|
||||
local output="$1"
|
||||
local expected_marker="$2"
|
||||
local fallback_marker="$3"
|
||||
local pass_message="$4"
|
||||
local known_bug_message="$5"
|
||||
local loaded_skill
|
||||
|
||||
loaded_skill="$(first_skill_tool_event "$output")"
|
||||
|
||||
if [[ "$loaded_skill" == *"$expected_marker"* ]]; then
|
||||
echo " [PASS] $pass_message"
|
||||
elif [[ "$loaded_skill" == *"$fallback_marker"* ]]; then
|
||||
echo " [INFO] $known_bug_message"
|
||||
echo " [INFO] Tracked separately: OpenCode bundled skills can shadow local skills with duplicate native names"
|
||||
else
|
||||
echo " [FAIL] Could not verify priority marker in native skill tool output"
|
||||
echo " Output was:"
|
||||
awk 'NR <= 80 { print }' <<<"$output"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Test 2: Document personal vs bundled superpowers priority
|
||||
# Test 2: Test that personal overrides superpowers
|
||||
echo ""
|
||||
echo "Test 2: Documenting personal vs superpowers priority..."
|
||||
echo "Test 2: Testing personal > superpowers priority..."
|
||||
echo " Running from outside project directory..."
|
||||
|
||||
run_opencode output "$HOME" "Call the skill tool with name \"priority-test\". Show the exact content including any PRIORITY_MARKER text."
|
||||
describe_priority_result \
|
||||
"$output" \
|
||||
"PRIORITY_MARKER_PERSONAL_VERSION" \
|
||||
"PRIORITY_MARKER_SUPERPOWERS_VERSION" \
|
||||
"Personal version loaded for duplicate native skill name" \
|
||||
"Current OpenCode behavior loaded bundled superpowers version instead of personal version"
|
||||
# Run from HOME (not in project) - should get personal version
|
||||
cd "$HOME"
|
||||
output=$(timeout 60s opencode run --print-logs "Use the use_skill tool to load the priority-test skill. Show me the exact content including any PRIORITY_MARKER text." 2>&1) || {
|
||||
exit_code=$?
|
||||
if [ $exit_code -eq 124 ]; then
|
||||
echo " [FAIL] OpenCode timed out after 60s"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Test 3: Document project vs bundled superpowers priority
|
||||
if echo "$output" | grep -qi "PRIORITY_MARKER_PERSONAL_VERSION"; then
|
||||
echo " [PASS] Personal version loaded (overrides superpowers)"
|
||||
elif echo "$output" | grep -qi "PRIORITY_MARKER_SUPERPOWERS_VERSION"; then
|
||||
echo " [FAIL] Superpowers version loaded instead of personal"
|
||||
exit 1
|
||||
else
|
||||
echo " [WARN] Could not verify priority marker in output"
|
||||
echo " Output snippet:"
|
||||
echo "$output" | grep -i "priority\|personal\|superpowers" | head -10
|
||||
fi
|
||||
|
||||
# Test 3: Test that project overrides both personal and superpowers
|
||||
echo ""
|
||||
echo "Test 3: Documenting project vs personal/superpowers priority..."
|
||||
echo "Test 3: Testing project > personal > superpowers priority..."
|
||||
echo " Running from project directory..."
|
||||
|
||||
run_opencode output "$TEST_HOME/test-project" "Call the skill tool with name \"priority-test\". Show the exact content including any PRIORITY_MARKER text."
|
||||
describe_priority_result \
|
||||
"$output" \
|
||||
"PRIORITY_MARKER_PROJECT_VERSION" \
|
||||
"PRIORITY_MARKER_SUPERPOWERS_VERSION" \
|
||||
"Project version loaded for duplicate native skill name" \
|
||||
"Current OpenCode behavior loaded bundled superpowers version instead of project version"
|
||||
# Run from project directory - should get project version
|
||||
cd "$TEST_HOME/test-project"
|
||||
output=$(timeout 60s opencode run --print-logs "Use the use_skill tool to load the priority-test skill. Show me the exact content including any PRIORITY_MARKER text." 2>&1) || {
|
||||
exit_code=$?
|
||||
if [ $exit_code -eq 124 ]; then
|
||||
echo " [FAIL] OpenCode timed out after 60s"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Test 4: Test a non-colliding bundled superpowers skill is still available
|
||||
if echo "$output" | grep -qi "PRIORITY_MARKER_PROJECT_VERSION"; then
|
||||
echo " [PASS] Project version loaded (highest priority)"
|
||||
elif echo "$output" | grep -qi "PRIORITY_MARKER_PERSONAL_VERSION"; then
|
||||
echo " [FAIL] Personal version loaded instead of project"
|
||||
exit 1
|
||||
elif echo "$output" | grep -qi "PRIORITY_MARKER_SUPERPOWERS_VERSION"; then
|
||||
echo " [FAIL] Superpowers version loaded instead of project"
|
||||
exit 1
|
||||
else
|
||||
echo " [WARN] Could not verify priority marker in output"
|
||||
echo " Output snippet:"
|
||||
echo "$output" | grep -i "priority\|project\|personal" | head -10
|
||||
fi
|
||||
|
||||
# Test 4: Test explicit superpowers: prefix bypasses priority
|
||||
echo ""
|
||||
echo "Test 4: Testing non-colliding superpowers skill remains available..."
|
||||
echo "Test 4: Testing superpowers: prefix forces superpowers version..."
|
||||
|
||||
mkdir -p "$SUPERPOWERS_SKILLS_DIR/superpowers-only-test"
|
||||
cat > "$SUPERPOWERS_SKILLS_DIR/superpowers-only-test/SKILL.md" <<'EOF'
|
||||
---
|
||||
name: superpowers-only-test
|
||||
description: Superpowers-only priority test skill
|
||||
---
|
||||
# Superpowers Only Test Skill
|
||||
cd "$TEST_HOME/test-project"
|
||||
output=$(timeout 60s opencode run --print-logs "Use the use_skill tool to load superpowers:priority-test specifically. Show me the exact content including any PRIORITY_MARKER text." 2>&1) || {
|
||||
exit_code=$?
|
||||
if [ $exit_code -eq 124 ]; then
|
||||
echo " [FAIL] OpenCode timed out after 60s"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
PRIORITY_MARKER_SUPERPOWERS_ONLY_VERSION
|
||||
EOF
|
||||
if echo "$output" | grep -qi "PRIORITY_MARKER_SUPERPOWERS_VERSION"; then
|
||||
echo " [PASS] superpowers: prefix correctly forces superpowers version"
|
||||
elif echo "$output" | grep -qi "PRIORITY_MARKER_PROJECT_VERSION\|PRIORITY_MARKER_PERSONAL_VERSION"; then
|
||||
echo " [FAIL] superpowers: prefix did not force superpowers version"
|
||||
exit 1
|
||||
else
|
||||
echo " [WARN] Could not verify priority marker in output"
|
||||
fi
|
||||
|
||||
run_opencode output "$TEST_HOME/test-project" "Call the skill tool with name \"superpowers-only-test\". Show the exact content including any PRIORITY_MARKER text."
|
||||
assert_contains "$output" "PRIORITY_MARKER_SUPERPOWERS_ONLY_VERSION" "Non-colliding superpowers skill is still registered"
|
||||
# Test 5: Test explicit project: prefix
|
||||
echo ""
|
||||
echo "Test 5: Testing project: prefix forces project version..."
|
||||
|
||||
cd "$HOME" # Run from outside project but with project: prefix
|
||||
output=$(timeout 60s opencode run --print-logs "Use the use_skill tool to load project:priority-test specifically. Show me the exact content." 2>&1) || {
|
||||
exit_code=$?
|
||||
if [ $exit_code -eq 124 ]; then
|
||||
echo " [FAIL] OpenCode timed out after 60s"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Note: This may fail since we're not in the project directory
|
||||
# The project: prefix only works when in a project context
|
||||
if echo "$output" | grep -qi "not found\|error"; then
|
||||
echo " [PASS] project: prefix correctly fails when not in project context"
|
||||
else
|
||||
echo " [INFO] project: prefix behavior outside project context may vary"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== All priority tests passed ==="
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
# Test: Native Skill Tool Functionality
|
||||
# Verifies that OpenCode's native skill tool can load personal, project,
|
||||
# and bundled superpowers skills.
|
||||
# Test: Tools Functionality
|
||||
# Verifies that use_skill and find_skills tools work correctly
|
||||
# NOTE: These tests require OpenCode to be installed and configured
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
OPENCODE_TEST_TIMEOUT_SECONDS="${OPENCODE_TEST_TIMEOUT_SECONDS:-120}"
|
||||
|
||||
echo "=== Test: Tools Functionality ==="
|
||||
|
||||
@@ -23,73 +21,84 @@ if ! command -v opencode &> /dev/null; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
run_opencode() {
|
||||
local result_var="$1"
|
||||
local dir="$2"
|
||||
local prompt="$3"
|
||||
local command_output
|
||||
local exit_code
|
||||
# Test 1: Test find_skills tool via direct invocation
|
||||
echo "Test 1: Testing find_skills tool..."
|
||||
echo " Running opencode with find_skills request..."
|
||||
|
||||
set +e
|
||||
command_output=$(cd "$dir" && timeout "${OPENCODE_TEST_TIMEOUT_SECONDS}s" opencode run --print-logs --format json "$prompt" 2>&1)
|
||||
# Use timeout to prevent hanging, capture both stdout and stderr
|
||||
output=$(timeout 60s opencode run --print-logs "Use the find_skills tool to list available skills. Just call the tool and show me the raw output." 2>&1) || {
|
||||
exit_code=$?
|
||||
set -e
|
||||
|
||||
if [ $exit_code -eq 124 ]; then
|
||||
echo " [FAIL] OpenCode timed out after ${OPENCODE_TEST_TIMEOUT_SECONDS}s"
|
||||
echo " [FAIL] OpenCode timed out after 60s"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $exit_code -ne 0 ]; then
|
||||
echo " [FAIL] OpenCode returned non-zero exit code: $exit_code"
|
||||
echo " Output was:"
|
||||
awk 'NR <= 80 { print }' <<<"$command_output"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf -v "$result_var" '%s' "$command_output"
|
||||
echo " [WARN] OpenCode returned non-zero exit code: $exit_code"
|
||||
}
|
||||
|
||||
assert_contains() {
|
||||
local output="$1"
|
||||
local needle="$2"
|
||||
local message="$3"
|
||||
# Check for expected patterns in output
|
||||
if echo "$output" | grep -qi "superpowers:brainstorming\|superpowers:using-superpowers\|Available skills"; then
|
||||
echo " [PASS] find_skills tool discovered superpowers skills"
|
||||
else
|
||||
echo " [FAIL] find_skills did not return expected skills"
|
||||
echo " Output was:"
|
||||
echo "$output" | head -50
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$output" == *"$needle"* ]]; then
|
||||
echo " [PASS] $message"
|
||||
else
|
||||
echo " [FAIL] $message"
|
||||
echo " Expected to find: $needle"
|
||||
echo " Output was:"
|
||||
awk 'NR <= 80 { print }' <<<"$output"
|
||||
# Check if personal test skill was found
|
||||
if echo "$output" | grep -qi "personal-test"; then
|
||||
echo " [PASS] find_skills found personal test skill"
|
||||
else
|
||||
echo " [WARN] personal test skill not found in output (may be ok if tool returned subset)"
|
||||
fi
|
||||
|
||||
# Test 2: Test use_skill tool
|
||||
echo ""
|
||||
echo "Test 2: Testing use_skill tool..."
|
||||
echo " Running opencode with use_skill request..."
|
||||
|
||||
output=$(timeout 60s opencode run --print-logs "Use the use_skill tool to load the personal-test skill and show me what you get." 2>&1) || {
|
||||
exit_code=$?
|
||||
if [ $exit_code -eq 124 ]; then
|
||||
echo " [FAIL] OpenCode timed out after 60s"
|
||||
exit 1
|
||||
fi
|
||||
echo " [WARN] OpenCode returned non-zero exit code: $exit_code"
|
||||
}
|
||||
|
||||
# Test 1: Test personal skill loading via OpenCode's native skill tool
|
||||
echo "Test 1: Testing native skill tool with a personal skill..."
|
||||
echo " Running opencode with personal-test request..."
|
||||
# Check for the skill marker we embedded
|
||||
if echo "$output" | grep -qi "PERSONAL_SKILL_MARKER_12345\|Personal Test Skill\|Launching skill"; then
|
||||
echo " [PASS] use_skill loaded personal-test skill content"
|
||||
else
|
||||
echo " [FAIL] use_skill did not load personal-test skill correctly"
|
||||
echo " Output was:"
|
||||
echo "$output" | head -50
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run_opencode output "$TEST_HOME/test-project" "Call the skill tool with name \"personal-test\". Then print the PERSONAL_SKILL_MARKER_12345 marker."
|
||||
assert_contains "$output" '"tool":"skill"' "OpenCode called the native skill tool"
|
||||
assert_contains "$output" "PERSONAL_SKILL_MARKER_12345" "native skill tool loaded personal-test skill content"
|
||||
|
||||
# Test 2: Test project skill loading
|
||||
# Test 3: Test use_skill with superpowers: prefix
|
||||
echo ""
|
||||
echo "Test 2: Testing native skill tool with a project skill..."
|
||||
echo " Running opencode with project-test request..."
|
||||
echo "Test 3: Testing use_skill with superpowers: prefix..."
|
||||
echo " Running opencode with superpowers:brainstorming skill..."
|
||||
|
||||
run_opencode output "$TEST_HOME/test-project" "Call the skill tool with name \"project-test\". Then print the PROJECT_SKILL_MARKER_67890 marker."
|
||||
assert_contains "$output" "PROJECT_SKILL_MARKER_67890" "native skill tool loaded project-test skill content"
|
||||
output=$(timeout 60s opencode run --print-logs "Use the use_skill tool to load superpowers:brainstorming and tell me the first few lines of what you received." 2>&1) || {
|
||||
exit_code=$?
|
||||
if [ $exit_code -eq 124 ]; then
|
||||
echo " [FAIL] OpenCode timed out after 60s"
|
||||
exit 1
|
||||
fi
|
||||
echo " [WARN] OpenCode returned non-zero exit code: $exit_code"
|
||||
}
|
||||
|
||||
# Test 3: Test bundled superpowers skill loading
|
||||
echo ""
|
||||
echo "Test 3: Testing native skill tool with a superpowers skill..."
|
||||
echo " Running opencode with brainstorming skill..."
|
||||
|
||||
run_opencode output "$TEST_HOME/test-project" "Call the skill tool with name \"brainstorming\". Then tell me the loaded skill title."
|
||||
assert_contains "$output" '"name":"brainstorming"' "native skill tool loaded bundled brainstorming skill"
|
||||
assert_contains "$output" "Brainstorming Ideas Into Designs" "brainstorming skill content was returned"
|
||||
# Check for expected content from brainstorming skill
|
||||
if echo "$output" | grep -qi "brainstorming\|Launching skill\|skill.*loaded"; then
|
||||
echo " [PASS] use_skill loaded superpowers:brainstorming skill"
|
||||
else
|
||||
echo " [FAIL] use_skill did not load superpowers:brainstorming correctly"
|
||||
echo " Output was:"
|
||||
echo "$output" | head -50
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "=== All native skill tool tests passed ==="
|
||||
echo "=== All tools tests passed ==="
|
||||
|
||||
Reference in New Issue
Block a user