@relipa/ai-flow-kit 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (204) hide show
  1. package/AIFLOW.md +432 -0
  2. package/CHANGELOG.md +78 -0
  3. package/CONTRIBUTING.md +351 -0
  4. package/IMPLEMENTATION_SUMMARY.md +348 -0
  5. package/QUICK_START.md +392 -0
  6. package/README.md +323 -0
  7. package/bin/aiflow.js +178 -0
  8. package/custom/mcp-presets/README.md +138 -0
  9. package/custom/mcp-presets/backlog.json +15 -0
  10. package/custom/mcp-presets/figma.json +15 -0
  11. package/custom/mcp-presets/google-sheets.json +14 -0
  12. package/custom/mcp-presets/jira.json +16 -0
  13. package/custom/prompts/bug-fix.md +149 -0
  14. package/custom/prompts/feature.md +190 -0
  15. package/custom/prompts/investigation.md +164 -0
  16. package/custom/rules/code-style.md +7 -0
  17. package/custom/rules/java/code-style.md +11 -0
  18. package/custom/rules/java/naming.md +17 -0
  19. package/custom/rules/java/review-checklist.md +36 -0
  20. package/custom/rules/javascript/code-style.md +12 -0
  21. package/custom/rules/javascript/naming.md +14 -0
  22. package/custom/rules/naming.md +9 -0
  23. package/custom/rules/php/code-style.md +10 -0
  24. package/custom/rules/php/naming.md +15 -0
  25. package/custom/rules/review-checklist.md +9 -0
  26. package/custom/skills/figma-to-component/SKILL.md +207 -0
  27. package/custom/skills/generate-spec/SKILL.md +97 -0
  28. package/custom/skills/impact-analysis/SKILL.md +94 -0
  29. package/custom/skills/investigate-bug/SKILL.md +93 -0
  30. package/custom/skills/report-customer/SKILL.md +95 -0
  31. package/custom/skills/review-plan/SKILL.md +158 -0
  32. package/custom/skills/validate-ticket/SKILL.md +240 -0
  33. package/custom/templates/laravel.md +90 -0
  34. package/custom/templates/nextjs.md +89 -0
  35. package/custom/templates/reactjs.md +567 -0
  36. package/custom/templates/spring-boot.md +598 -0
  37. package/custom/templates/vue-nuxt.md +89 -0
  38. package/docs/architecture.md +395 -0
  39. package/docs/cli-reference.md +438 -0
  40. package/docs/configuration.md +412 -0
  41. package/docs/getting-started.md +248 -0
  42. package/docs/troubleshooting.md +587 -0
  43. package/docs/workflows/bug-fix.md +126 -0
  44. package/docs/workflows/feature.md +123 -0
  45. package/docs/workflows/impact-analysis.md +13 -0
  46. package/docs/workflows/investigation.md +13 -0
  47. package/docs/workflows/refactor.md +13 -0
  48. package/index.js +27 -0
  49. package/package.json +70 -0
  50. package/scripts/config.js +317 -0
  51. package/scripts/context.js +117 -0
  52. package/scripts/detect.js +239 -0
  53. package/scripts/doctor.js +48 -0
  54. package/scripts/guide.js +282 -0
  55. package/scripts/hooks/session-start.js +140 -0
  56. package/scripts/init.js +453 -0
  57. package/scripts/memory.js +247 -0
  58. package/scripts/prompt.js +392 -0
  59. package/scripts/remove.js +170 -0
  60. package/scripts/update.js +111 -0
  61. package/scripts/use.js +570 -0
  62. package/scripts/validate.js +303 -0
  63. package/upstream/.claude-plugin/marketplace.json +20 -0
  64. package/upstream/.claude-plugin/plugin.json +20 -0
  65. package/upstream/.codex/INSTALL.md +67 -0
  66. package/upstream/.cursor-plugin/plugin.json +25 -0
  67. package/upstream/.gitattributes +18 -0
  68. package/upstream/.github/FUNDING.yml +3 -0
  69. package/upstream/.github/ISSUE_TEMPLATE/bug_report.md +52 -0
  70. package/upstream/.github/ISSUE_TEMPLATE/config.yml +5 -0
  71. package/upstream/.github/ISSUE_TEMPLATE/feature_request.md +34 -0
  72. package/upstream/.github/ISSUE_TEMPLATE/platform_support.md +23 -0
  73. package/upstream/.github/PULL_REQUEST_TEMPLATE.md +87 -0
  74. package/upstream/.opencode/INSTALL.md +83 -0
  75. package/upstream/.opencode/plugins/superpowers.js +112 -0
  76. package/upstream/.version-bump.json +19 -0
  77. package/upstream/AGENTS.md +1 -0
  78. package/upstream/CHANGELOG.md +13 -0
  79. package/upstream/CLAUDE.md +85 -0
  80. package/upstream/CODE_OF_CONDUCT.md +128 -0
  81. package/upstream/GEMINI.md +2 -0
  82. package/upstream/LICENSE +21 -0
  83. package/upstream/README.md +190 -0
  84. package/upstream/RELEASE-NOTES.md +1096 -0
  85. package/upstream/agents/code-reviewer.md +48 -0
  86. package/upstream/commands/brainstorm.md +5 -0
  87. package/upstream/commands/execute-plan.md +5 -0
  88. package/upstream/commands/write-plan.md +5 -0
  89. package/upstream/docs/README.codex.md +126 -0
  90. package/upstream/docs/README.opencode.md +130 -0
  91. package/upstream/docs/plans/2025-11-22-opencode-support-design.md +294 -0
  92. package/upstream/docs/plans/2025-11-22-opencode-support-implementation.md +1095 -0
  93. package/upstream/docs/plans/2025-11-28-skills-improvements-from-user-feedback.md +711 -0
  94. package/upstream/docs/plans/2026-01-17-visual-brainstorming.md +571 -0
  95. package/upstream/docs/superpowers/plans/2026-01-22-document-review-system.md +301 -0
  96. package/upstream/docs/superpowers/plans/2026-02-19-visual-brainstorming-refactor.md +523 -0
  97. package/upstream/docs/superpowers/plans/2026-03-11-zero-dep-brainstorm-server.md +479 -0
  98. package/upstream/docs/superpowers/plans/2026-03-23-codex-app-compatibility.md +564 -0
  99. package/upstream/docs/superpowers/specs/2026-01-22-document-review-system-design.md +136 -0
  100. package/upstream/docs/superpowers/specs/2026-02-19-visual-brainstorming-refactor-design.md +162 -0
  101. package/upstream/docs/superpowers/specs/2026-03-11-zero-dep-brainstorm-server-design.md +118 -0
  102. package/upstream/docs/superpowers/specs/2026-03-23-codex-app-compatibility-design.md +244 -0
  103. package/upstream/docs/testing.md +303 -0
  104. package/upstream/docs/windows/polyglot-hooks.md +212 -0
  105. package/upstream/gemini-extension.json +6 -0
  106. package/upstream/hooks/hooks-cursor.json +10 -0
  107. package/upstream/hooks/hooks.json +16 -0
  108. package/upstream/hooks/run-hook.cmd +46 -0
  109. package/upstream/hooks/session-start +57 -0
  110. package/upstream/package.json +6 -0
  111. package/upstream/scripts/bump-version.sh +220 -0
  112. package/upstream/skills/brainstorming/SKILL.md +164 -0
  113. package/upstream/skills/brainstorming/scripts/frame-template.html +214 -0
  114. package/upstream/skills/brainstorming/scripts/helper.js +88 -0
  115. package/upstream/skills/brainstorming/scripts/server.cjs +354 -0
  116. package/upstream/skills/brainstorming/scripts/start-server.sh +148 -0
  117. package/upstream/skills/brainstorming/scripts/stop-server.sh +56 -0
  118. package/upstream/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  119. package/upstream/skills/brainstorming/visual-companion.md +287 -0
  120. package/upstream/skills/dispatching-parallel-agents/SKILL.md +182 -0
  121. package/upstream/skills/executing-plans/SKILL.md +70 -0
  122. package/upstream/skills/finishing-a-development-branch/SKILL.md +200 -0
  123. package/upstream/skills/receiving-code-review/SKILL.md +213 -0
  124. package/upstream/skills/requesting-code-review/SKILL.md +105 -0
  125. package/upstream/skills/requesting-code-review/code-reviewer.md +146 -0
  126. package/upstream/skills/subagent-driven-development/SKILL.md +277 -0
  127. package/upstream/skills/subagent-driven-development/code-quality-reviewer-prompt.md +26 -0
  128. package/upstream/skills/subagent-driven-development/implementer-prompt.md +113 -0
  129. package/upstream/skills/subagent-driven-development/spec-reviewer-prompt.md +61 -0
  130. package/upstream/skills/systematic-debugging/CREATION-LOG.md +119 -0
  131. package/upstream/skills/systematic-debugging/SKILL.md +296 -0
  132. package/upstream/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  133. package/upstream/skills/systematic-debugging/condition-based-waiting.md +115 -0
  134. package/upstream/skills/systematic-debugging/defense-in-depth.md +122 -0
  135. package/upstream/skills/systematic-debugging/find-polluter.sh +63 -0
  136. package/upstream/skills/systematic-debugging/root-cause-tracing.md +169 -0
  137. package/upstream/skills/systematic-debugging/test-academic.md +14 -0
  138. package/upstream/skills/systematic-debugging/test-pressure-1.md +58 -0
  139. package/upstream/skills/systematic-debugging/test-pressure-2.md +68 -0
  140. package/upstream/skills/systematic-debugging/test-pressure-3.md +69 -0
  141. package/upstream/skills/test-driven-development/SKILL.md +371 -0
  142. package/upstream/skills/test-driven-development/testing-anti-patterns.md +299 -0
  143. package/upstream/skills/using-git-worktrees/SKILL.md +218 -0
  144. package/upstream/skills/using-superpowers/SKILL.md +117 -0
  145. package/upstream/skills/using-superpowers/references/codex-tools.md +100 -0
  146. package/upstream/skills/using-superpowers/references/copilot-tools.md +52 -0
  147. package/upstream/skills/using-superpowers/references/gemini-tools.md +33 -0
  148. package/upstream/skills/verification-before-completion/SKILL.md +139 -0
  149. package/upstream/skills/writing-plans/SKILL.md +152 -0
  150. package/upstream/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
  151. package/upstream/skills/writing-skills/SKILL.md +655 -0
  152. package/upstream/skills/writing-skills/anthropic-best-practices.md +1150 -0
  153. package/upstream/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  154. package/upstream/skills/writing-skills/graphviz-conventions.dot +172 -0
  155. package/upstream/skills/writing-skills/persuasion-principles.md +187 -0
  156. package/upstream/skills/writing-skills/render-graphs.js +168 -0
  157. package/upstream/skills/writing-skills/testing-skills-with-subagents.md +384 -0
  158. package/upstream/tests/brainstorm-server/package-lock.json +36 -0
  159. package/upstream/tests/brainstorm-server/package.json +10 -0
  160. package/upstream/tests/brainstorm-server/server.test.js +427 -0
  161. package/upstream/tests/brainstorm-server/windows-lifecycle.test.sh +351 -0
  162. package/upstream/tests/brainstorm-server/ws-protocol.test.js +392 -0
  163. package/upstream/tests/claude-code/README.md +158 -0
  164. package/upstream/tests/claude-code/analyze-token-usage.py +168 -0
  165. package/upstream/tests/claude-code/run-skill-tests.sh +187 -0
  166. package/upstream/tests/claude-code/test-document-review-system.sh +177 -0
  167. package/upstream/tests/claude-code/test-helpers.sh +202 -0
  168. package/upstream/tests/claude-code/test-subagent-driven-development-integration.sh +314 -0
  169. package/upstream/tests/claude-code/test-subagent-driven-development.sh +165 -0
  170. package/upstream/tests/explicit-skill-requests/prompts/action-oriented.txt +3 -0
  171. package/upstream/tests/explicit-skill-requests/prompts/after-planning-flow.txt +17 -0
  172. package/upstream/tests/explicit-skill-requests/prompts/claude-suggested-it.txt +11 -0
  173. package/upstream/tests/explicit-skill-requests/prompts/i-know-what-sdd-means.txt +8 -0
  174. package/upstream/tests/explicit-skill-requests/prompts/mid-conversation-execute-plan.txt +3 -0
  175. package/upstream/tests/explicit-skill-requests/prompts/please-use-brainstorming.txt +1 -0
  176. package/upstream/tests/explicit-skill-requests/prompts/skip-formalities.txt +3 -0
  177. package/upstream/tests/explicit-skill-requests/prompts/subagent-driven-development-please.txt +1 -0
  178. package/upstream/tests/explicit-skill-requests/prompts/use-systematic-debugging.txt +1 -0
  179. package/upstream/tests/explicit-skill-requests/run-all.sh +70 -0
  180. package/upstream/tests/explicit-skill-requests/run-claude-describes-sdd.sh +100 -0
  181. package/upstream/tests/explicit-skill-requests/run-extended-multiturn-test.sh +113 -0
  182. package/upstream/tests/explicit-skill-requests/run-haiku-test.sh +144 -0
  183. package/upstream/tests/explicit-skill-requests/run-multiturn-test.sh +143 -0
  184. package/upstream/tests/explicit-skill-requests/run-test.sh +136 -0
  185. package/upstream/tests/opencode/run-tests.sh +163 -0
  186. package/upstream/tests/opencode/setup.sh +88 -0
  187. package/upstream/tests/opencode/test-plugin-loading.sh +82 -0
  188. package/upstream/tests/opencode/test-priority.sh +198 -0
  189. package/upstream/tests/opencode/test-tools.sh +104 -0
  190. package/upstream/tests/skill-triggering/prompts/dispatching-parallel-agents.txt +8 -0
  191. package/upstream/tests/skill-triggering/prompts/executing-plans.txt +1 -0
  192. package/upstream/tests/skill-triggering/prompts/requesting-code-review.txt +3 -0
  193. package/upstream/tests/skill-triggering/prompts/systematic-debugging.txt +11 -0
  194. package/upstream/tests/skill-triggering/prompts/test-driven-development.txt +7 -0
  195. package/upstream/tests/skill-triggering/prompts/writing-plans.txt +10 -0
  196. package/upstream/tests/skill-triggering/run-all.sh +60 -0
  197. package/upstream/tests/skill-triggering/run-test.sh +88 -0
  198. package/upstream/tests/subagent-driven-dev/go-fractals/design.md +81 -0
  199. package/upstream/tests/subagent-driven-dev/go-fractals/plan.md +172 -0
  200. package/upstream/tests/subagent-driven-dev/go-fractals/scaffold.sh +45 -0
  201. package/upstream/tests/subagent-driven-dev/run-test.sh +106 -0
  202. package/upstream/tests/subagent-driven-dev/svelte-todo/design.md +70 -0
  203. package/upstream/tests/subagent-driven-dev/svelte-todo/plan.md +222 -0
  204. package/upstream/tests/subagent-driven-dev/svelte-todo/scaffold.sh +46 -0
@@ -0,0 +1,136 @@
1
+ #!/usr/bin/env bash
2
+ # Test explicit skill requests (user names a skill directly)
3
+ # Usage: ./run-test.sh <skill-name> <prompt-file>
4
+ #
5
+ # Tests whether Claude invokes a skill when the user explicitly requests it by name
6
+ # (without using the plugin namespace prefix)
7
+ #
8
+ # Uses isolated HOME to avoid user context interference
9
+
10
+ set -e
11
+
12
+ SKILL_NAME="$1"
13
+ PROMPT_FILE="$2"
14
+ MAX_TURNS="${3:-3}"
15
+
16
+ if [ -z "$SKILL_NAME" ] || [ -z "$PROMPT_FILE" ]; then
17
+ echo "Usage: $0 <skill-name> <prompt-file> [max-turns]"
18
+ echo "Example: $0 subagent-driven-development ./prompts/subagent-driven-development-please.txt"
19
+ exit 1
20
+ fi
21
+
22
+ # Get the directory where this script lives
23
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
24
+ # Get the superpowers plugin root (two levels up)
25
+ PLUGIN_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)"
26
+
27
+ TIMESTAMP=$(date +%s)
28
+ OUTPUT_DIR="/tmp/superpowers-tests/${TIMESTAMP}/explicit-skill-requests/${SKILL_NAME}"
29
+ mkdir -p "$OUTPUT_DIR"
30
+
31
+ # Read prompt from file
32
+ PROMPT=$(cat "$PROMPT_FILE")
33
+
34
+ echo "=== Explicit Skill Request Test ==="
35
+ echo "Skill: $SKILL_NAME"
36
+ echo "Prompt file: $PROMPT_FILE"
37
+ echo "Max turns: $MAX_TURNS"
38
+ echo "Output dir: $OUTPUT_DIR"
39
+ echo ""
40
+
41
+ # Copy prompt for reference
42
+ cp "$PROMPT_FILE" "$OUTPUT_DIR/prompt.txt"
43
+
44
+ # Create a minimal project directory for the test
45
+ PROJECT_DIR="$OUTPUT_DIR/project"
46
+ mkdir -p "$PROJECT_DIR/docs/superpowers/plans"
47
+
48
+ # Create a dummy plan file for mid-conversation tests
49
+ cat > "$PROJECT_DIR/docs/superpowers/plans/auth-system.md" << 'EOF'
50
+ # Auth System Implementation Plan
51
+
52
+ ## Task 1: Add User Model
53
+ Create user model with email and password fields.
54
+
55
+ ## Task 2: Add Auth Routes
56
+ Create login and register endpoints.
57
+
58
+ ## Task 3: Add JWT Middleware
59
+ Protect routes with JWT validation.
60
+ EOF
61
+
62
+ # Run Claude with isolated environment
63
+ LOG_FILE="$OUTPUT_DIR/claude-output.json"
64
+ cd "$PROJECT_DIR"
65
+
66
+ echo "Plugin dir: $PLUGIN_DIR"
67
+ echo "Running claude -p with explicit skill request..."
68
+ echo "Prompt: $PROMPT"
69
+ echo ""
70
+
71
+ timeout 300 claude -p "$PROMPT" \
72
+ --plugin-dir "$PLUGIN_DIR" \
73
+ --dangerously-skip-permissions \
74
+ --max-turns "$MAX_TURNS" \
75
+ --output-format stream-json \
76
+ > "$LOG_FILE" 2>&1 || true
77
+
78
+ echo ""
79
+ echo "=== Results ==="
80
+
81
+ # Check if skill was triggered (look for Skill tool invocation)
82
+ # Match either "skill":"skillname" or "skill":"namespace:skillname"
83
+ SKILL_PATTERN='"skill":"([^"]*:)?'"${SKILL_NAME}"'"'
84
+ if grep -q '"name":"Skill"' "$LOG_FILE" && grep -qE "$SKILL_PATTERN" "$LOG_FILE"; then
85
+ echo "PASS: Skill '$SKILL_NAME' was triggered"
86
+ TRIGGERED=true
87
+ else
88
+ echo "FAIL: Skill '$SKILL_NAME' was NOT triggered"
89
+ TRIGGERED=false
90
+ fi
91
+
92
+ # Show what skills WERE triggered
93
+ echo ""
94
+ echo "Skills triggered in this run:"
95
+ grep -o '"skill":"[^"]*"' "$LOG_FILE" 2>/dev/null | sort -u || echo " (none)"
96
+
97
+ # Check if Claude took action BEFORE invoking the skill (the failure mode)
98
+ echo ""
99
+ echo "Checking for premature action..."
100
+
101
+ # Look for tool invocations before the Skill invocation
102
+ # This detects the failure mode where Claude starts doing work without loading the skill
103
+ FIRST_SKILL_LINE=$(grep -n '"name":"Skill"' "$LOG_FILE" | head -1 | cut -d: -f1)
104
+ if [ -n "$FIRST_SKILL_LINE" ]; then
105
+ # Check if any non-Skill, non-system tools were invoked before the first Skill invocation
106
+ # Filter out system messages, TodoWrite (planning is ok), and other non-action tools
107
+ PREMATURE_TOOLS=$(head -n "$FIRST_SKILL_LINE" "$LOG_FILE" | \
108
+ grep '"type":"tool_use"' | \
109
+ grep -v '"name":"Skill"' | \
110
+ grep -v '"name":"TodoWrite"' || true)
111
+ if [ -n "$PREMATURE_TOOLS" ]; then
112
+ echo "WARNING: Tools invoked BEFORE Skill tool:"
113
+ echo "$PREMATURE_TOOLS" | head -5
114
+ echo ""
115
+ echo "This indicates Claude started working before loading the requested skill."
116
+ else
117
+ echo "OK: No premature tool invocations detected"
118
+ fi
119
+ else
120
+ echo "WARNING: No Skill invocation found at all"
121
+ fi
122
+
123
+ # Show first assistant message
124
+ echo ""
125
+ echo "First assistant response (truncated):"
126
+ grep '"type":"assistant"' "$LOG_FILE" | head -1 | jq -r '.message.content[0].text // .message.content' 2>/dev/null | head -c 500 || echo " (could not extract)"
127
+
128
+ echo ""
129
+ echo "Full log: $LOG_FILE"
130
+ echo "Timestamp: $TIMESTAMP"
131
+
132
+ if [ "$TRIGGERED" = "true" ]; then
133
+ exit 0
134
+ else
135
+ exit 1
136
+ fi
@@ -0,0 +1,163 @@
1
+ #!/usr/bin/env bash
2
+ # Main test runner for OpenCode plugin test suite
3
+ # Runs all tests and reports results
4
+ set -euo pipefail
5
+
6
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
7
+ cd "$SCRIPT_DIR"
8
+
9
+ echo "========================================"
10
+ echo " OpenCode Plugin Test Suite"
11
+ echo "========================================"
12
+ echo ""
13
+ echo "Repository: $(cd ../.. && pwd)"
14
+ echo "Test time: $(date)"
15
+ echo ""
16
+
17
+ # Parse command line arguments
18
+ RUN_INTEGRATION=false
19
+ VERBOSE=false
20
+ SPECIFIC_TEST=""
21
+
22
+ while [[ $# -gt 0 ]]; do
23
+ case $1 in
24
+ --integration|-i)
25
+ RUN_INTEGRATION=true
26
+ shift
27
+ ;;
28
+ --verbose|-v)
29
+ VERBOSE=true
30
+ shift
31
+ ;;
32
+ --test|-t)
33
+ SPECIFIC_TEST="$2"
34
+ shift 2
35
+ ;;
36
+ --help|-h)
37
+ echo "Usage: $0 [options]"
38
+ echo ""
39
+ echo "Options:"
40
+ echo " --integration, -i Run integration tests (requires OpenCode)"
41
+ echo " --verbose, -v Show verbose output"
42
+ echo " --test, -t NAME Run only the specified test"
43
+ echo " --help, -h Show this help"
44
+ echo ""
45
+ echo "Tests:"
46
+ echo " test-plugin-loading.sh Verify plugin installation and structure"
47
+ echo " test-tools.sh Test use_skill and find_skills tools (integration)"
48
+ echo " test-priority.sh Test skill priority resolution (integration)"
49
+ exit 0
50
+ ;;
51
+ *)
52
+ echo "Unknown option: $1"
53
+ echo "Use --help for usage information"
54
+ exit 1
55
+ ;;
56
+ esac
57
+ done
58
+
59
+ # List of tests to run (no external dependencies)
60
+ tests=(
61
+ "test-plugin-loading.sh"
62
+ )
63
+
64
+ # Integration tests (require OpenCode)
65
+ integration_tests=(
66
+ "test-tools.sh"
67
+ "test-priority.sh"
68
+ )
69
+
70
+ # Add integration tests if requested
71
+ if [ "$RUN_INTEGRATION" = true ]; then
72
+ tests+=("${integration_tests[@]}")
73
+ fi
74
+
75
+ # Filter to specific test if requested
76
+ if [ -n "$SPECIFIC_TEST" ]; then
77
+ tests=("$SPECIFIC_TEST")
78
+ fi
79
+
80
+ # Track results
81
+ passed=0
82
+ failed=0
83
+ skipped=0
84
+
85
+ # Run each test
86
+ for test in "${tests[@]}"; do
87
+ echo "----------------------------------------"
88
+ echo "Running: $test"
89
+ echo "----------------------------------------"
90
+
91
+ test_path="$SCRIPT_DIR/$test"
92
+
93
+ if [ ! -f "$test_path" ]; then
94
+ echo " [SKIP] Test file not found: $test"
95
+ skipped=$((skipped + 1))
96
+ continue
97
+ fi
98
+
99
+ if [ ! -x "$test_path" ]; then
100
+ echo " Making $test executable..."
101
+ chmod +x "$test_path"
102
+ fi
103
+
104
+ start_time=$(date +%s)
105
+
106
+ if [ "$VERBOSE" = true ]; then
107
+ if bash "$test_path"; then
108
+ end_time=$(date +%s)
109
+ duration=$((end_time - start_time))
110
+ echo ""
111
+ echo " [PASS] $test (${duration}s)"
112
+ passed=$((passed + 1))
113
+ else
114
+ end_time=$(date +%s)
115
+ duration=$((end_time - start_time))
116
+ echo ""
117
+ echo " [FAIL] $test (${duration}s)"
118
+ failed=$((failed + 1))
119
+ fi
120
+ else
121
+ # Capture output for non-verbose mode
122
+ if output=$(bash "$test_path" 2>&1); then
123
+ end_time=$(date +%s)
124
+ duration=$((end_time - start_time))
125
+ echo " [PASS] (${duration}s)"
126
+ passed=$((passed + 1))
127
+ else
128
+ end_time=$(date +%s)
129
+ duration=$((end_time - start_time))
130
+ echo " [FAIL] (${duration}s)"
131
+ echo ""
132
+ echo " Output:"
133
+ echo "$output" | sed 's/^/ /'
134
+ failed=$((failed + 1))
135
+ fi
136
+ fi
137
+
138
+ echo ""
139
+ done
140
+
141
+ # Print summary
142
+ echo "========================================"
143
+ echo " Test Results Summary"
144
+ echo "========================================"
145
+ echo ""
146
+ echo " Passed: $passed"
147
+ echo " Failed: $failed"
148
+ echo " Skipped: $skipped"
149
+ echo ""
150
+
151
+ if [ "$RUN_INTEGRATION" = false ] && [ ${#integration_tests[@]} -gt 0 ]; then
152
+ echo "Note: Integration tests were not run."
153
+ echo "Use --integration flag to run tests that require OpenCode."
154
+ echo ""
155
+ fi
156
+
157
+ if [ $failed -gt 0 ]; then
158
+ echo "STATUS: FAILED"
159
+ exit 1
160
+ else
161
+ echo "STATUS: PASSED"
162
+ exit 0
163
+ fi
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env bash
2
+ # Setup script for OpenCode plugin tests
3
+ # Creates an isolated test environment with proper plugin installation
4
+ set -euo pipefail
5
+
6
+ # Get the repository root (two levels up from tests/opencode/)
7
+ REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
8
+
9
+ # Create temp home directory for isolation
10
+ export TEST_HOME
11
+ TEST_HOME=$(mktemp -d)
12
+ export HOME="$TEST_HOME"
13
+ export XDG_CONFIG_HOME="$TEST_HOME/.config"
14
+ export OPENCODE_CONFIG_DIR="$TEST_HOME/.config/opencode"
15
+
16
+ # Standard install layout:
17
+ # $OPENCODE_CONFIG_DIR/superpowers/ ← package root
18
+ # $OPENCODE_CONFIG_DIR/superpowers/skills/ ← skills dir (../../skills from plugin)
19
+ # $OPENCODE_CONFIG_DIR/superpowers/.opencode/plugins/superpowers.js ← plugin file
20
+ # $OPENCODE_CONFIG_DIR/plugins/superpowers.js ← symlink OpenCode reads
21
+
22
+ SUPERPOWERS_DIR="$OPENCODE_CONFIG_DIR/superpowers"
23
+ SUPERPOWERS_SKILLS_DIR="$SUPERPOWERS_DIR/skills"
24
+ SUPERPOWERS_PLUGIN_FILE="$SUPERPOWERS_DIR/.opencode/plugins/superpowers.js"
25
+
26
+ # Install skills
27
+ mkdir -p "$SUPERPOWERS_DIR"
28
+ cp -r "$REPO_ROOT/skills" "$SUPERPOWERS_DIR/"
29
+
30
+ # Install plugin
31
+ mkdir -p "$(dirname "$SUPERPOWERS_PLUGIN_FILE")"
32
+ cp "$REPO_ROOT/.opencode/plugins/superpowers.js" "$SUPERPOWERS_PLUGIN_FILE"
33
+
34
+ # Register plugin via symlink (what OpenCode actually reads)
35
+ mkdir -p "$OPENCODE_CONFIG_DIR/plugins"
36
+ ln -sf "$SUPERPOWERS_PLUGIN_FILE" "$OPENCODE_CONFIG_DIR/plugins/superpowers.js"
37
+
38
+ # Create test skills in different locations for testing
39
+
40
+ # Personal test skill
41
+ mkdir -p "$OPENCODE_CONFIG_DIR/skills/personal-test"
42
+ cat > "$OPENCODE_CONFIG_DIR/skills/personal-test/SKILL.md" <<'EOF'
43
+ ---
44
+ name: personal-test
45
+ description: Test personal skill for verification
46
+ ---
47
+ # Personal Test Skill
48
+
49
+ This is a personal skill used for testing.
50
+
51
+ PERSONAL_SKILL_MARKER_12345
52
+ EOF
53
+
54
+ # Create a project directory for project-level skill tests
55
+ mkdir -p "$TEST_HOME/test-project/.opencode/skills/project-test"
56
+ cat > "$TEST_HOME/test-project/.opencode/skills/project-test/SKILL.md" <<'EOF'
57
+ ---
58
+ name: project-test
59
+ description: Test project skill for verification
60
+ ---
61
+ # Project Test Skill
62
+
63
+ This is a project skill used for testing.
64
+
65
+ PROJECT_SKILL_MARKER_67890
66
+ EOF
67
+
68
+ echo "Setup complete: $TEST_HOME"
69
+ echo "OPENCODE_CONFIG_DIR: $OPENCODE_CONFIG_DIR"
70
+ echo "Superpowers dir: $SUPERPOWERS_DIR"
71
+ echo "Skills dir: $SUPERPOWERS_SKILLS_DIR"
72
+ echo "Plugin file: $SUPERPOWERS_PLUGIN_FILE"
73
+ echo "Plugin registered at: $OPENCODE_CONFIG_DIR/plugins/superpowers.js"
74
+ echo "Test project at: $TEST_HOME/test-project"
75
+
76
+ # Helper function for cleanup (call from tests or trap)
77
+ cleanup_test_env() {
78
+ if [ -n "${TEST_HOME:-}" ] && [ -d "$TEST_HOME" ]; then
79
+ rm -rf "$TEST_HOME"
80
+ fi
81
+ }
82
+
83
+ # Export for use in tests
84
+ export -f cleanup_test_env
85
+ export REPO_ROOT
86
+ export SUPERPOWERS_DIR
87
+ export SUPERPOWERS_SKILLS_DIR
88
+ export SUPERPOWERS_PLUGIN_FILE
@@ -0,0 +1,82 @@
1
+ #!/usr/bin/env bash
2
+ # Test: Plugin Loading
3
+ # Verifies that the superpowers plugin loads correctly in OpenCode
4
+ set -euo pipefail
5
+
6
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
7
+
8
+ echo "=== Test: Plugin Loading ==="
9
+
10
+ # Source setup to create isolated environment
11
+ source "$SCRIPT_DIR/setup.sh"
12
+
13
+ # Trap to cleanup on exit
14
+ trap cleanup_test_env EXIT
15
+
16
+ plugin_link="$OPENCODE_CONFIG_DIR/plugins/superpowers.js"
17
+
18
+ # Test 1: Verify plugin file exists and is registered
19
+ echo "Test 1: Checking plugin registration..."
20
+ if [ -L "$plugin_link" ]; then
21
+ echo " [PASS] Plugin symlink exists"
22
+ else
23
+ echo " [FAIL] Plugin symlink not found at $plugin_link"
24
+ exit 1
25
+ fi
26
+
27
+ # Verify symlink target exists
28
+ if [ -f "$(readlink -f "$plugin_link")" ]; then
29
+ echo " [PASS] Plugin symlink target exists"
30
+ else
31
+ echo " [FAIL] Plugin symlink target does not exist"
32
+ exit 1
33
+ fi
34
+
35
+ # Test 2: Verify skills directory is populated
36
+ echo "Test 2: Checking skills directory..."
37
+ skill_count=$(find "$SUPERPOWERS_SKILLS_DIR" -name "SKILL.md" | wc -l)
38
+ if [ "$skill_count" -gt 0 ]; then
39
+ echo " [PASS] Found $skill_count skills"
40
+ else
41
+ echo " [FAIL] No skills found in $SUPERPOWERS_SKILLS_DIR"
42
+ exit 1
43
+ fi
44
+
45
+ # Test 3: Check using-superpowers skill exists (critical for bootstrap)
46
+ echo "Test 3: Checking using-superpowers skill (required for bootstrap)..."
47
+ if [ -f "$SUPERPOWERS_SKILLS_DIR/using-superpowers/SKILL.md" ]; then
48
+ echo " [PASS] using-superpowers skill exists"
49
+ else
50
+ echo " [FAIL] using-superpowers skill not found (required for bootstrap)"
51
+ exit 1
52
+ fi
53
+
54
+ # Test 4: Verify plugin JavaScript syntax (basic check)
55
+ echo "Test 4: Checking plugin JavaScript syntax..."
56
+ if node --check "$SUPERPOWERS_PLUGIN_FILE" 2>/dev/null; then
57
+ echo " [PASS] Plugin JavaScript syntax is valid"
58
+ else
59
+ echo " [FAIL] Plugin has JavaScript syntax errors"
60
+ exit 1
61
+ fi
62
+
63
+ # Test 5: Verify bootstrap text does not reference a hardcoded skills path
64
+ echo "Test 5: Checking bootstrap does not advertise a wrong skills path..."
65
+ if grep -q 'configDir}/skills/superpowers/' "$SUPERPOWERS_PLUGIN_FILE"; then
66
+ echo " [FAIL] Plugin still references old configDir skills path"
67
+ exit 1
68
+ else
69
+ echo " [PASS] Plugin does not advertise a misleading skills path"
70
+ fi
71
+
72
+ # Test 6: Verify personal test skill was created
73
+ echo "Test 6: Checking test fixtures..."
74
+ if [ -f "$OPENCODE_CONFIG_DIR/skills/personal-test/SKILL.md" ]; then
75
+ echo " [PASS] Personal test skill fixture created"
76
+ else
77
+ echo " [FAIL] Personal test skill fixture not found"
78
+ exit 1
79
+ fi
80
+
81
+ echo ""
82
+ echo "=== All plugin loading tests passed ==="
@@ -0,0 +1,198 @@
1
+ #!/usr/bin/env bash
2
+ # Test: Skill Priority Resolution
3
+ # Verifies that skills are resolved with correct priority: project > personal > superpowers
4
+ # NOTE: These tests require OpenCode to be installed and configured
5
+ set -euo pipefail
6
+
7
+ SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
8
+
9
+ echo "=== Test: Skill Priority Resolution ==="
10
+
11
+ # Source setup to create isolated environment
12
+ source "$SCRIPT_DIR/setup.sh"
13
+
14
+ # Trap to cleanup on exit
15
+ trap cleanup_test_env EXIT
16
+
17
+ # Create same skill "priority-test" in all three locations with different markers
18
+ echo "Setting up priority test fixtures..."
19
+
20
+ # 1. Create in superpowers location (lowest priority)
21
+ mkdir -p "$SUPERPOWERS_SKILLS_DIR/priority-test"
22
+ cat > "$SUPERPOWERS_SKILLS_DIR/priority-test/SKILL.md" <<'EOF'
23
+ ---
24
+ name: priority-test
25
+ description: Superpowers version of priority test skill
26
+ ---
27
+ # Priority Test Skill (Superpowers Version)
28
+
29
+ This is the SUPERPOWERS version of the priority test skill.
30
+
31
+ PRIORITY_MARKER_SUPERPOWERS_VERSION
32
+ EOF
33
+
34
+ # 2. Create in personal location (medium priority)
35
+ mkdir -p "$OPENCODE_CONFIG_DIR/skills/priority-test"
36
+ cat > "$OPENCODE_CONFIG_DIR/skills/priority-test/SKILL.md" <<'EOF'
37
+ ---
38
+ name: priority-test
39
+ description: Personal version of priority test skill
40
+ ---
41
+ # Priority Test Skill (Personal Version)
42
+
43
+ This is the PERSONAL version of the priority test skill.
44
+
45
+ PRIORITY_MARKER_PERSONAL_VERSION
46
+ EOF
47
+
48
+ # 3. Create in project location (highest priority)
49
+ mkdir -p "$TEST_HOME/test-project/.opencode/skills/priority-test"
50
+ cat > "$TEST_HOME/test-project/.opencode/skills/priority-test/SKILL.md" <<'EOF'
51
+ ---
52
+ name: priority-test
53
+ description: Project version of priority test skill
54
+ ---
55
+ # Priority Test Skill (Project Version)
56
+
57
+ This is the PROJECT version of the priority test skill.
58
+
59
+ PRIORITY_MARKER_PROJECT_VERSION
60
+ EOF
61
+
62
+ echo " Created priority-test skill in all three locations"
63
+
64
+ # Test 1: Verify fixture setup
65
+ echo ""
66
+ echo "Test 1: Verifying test fixtures..."
67
+
68
+ if [ -f "$SUPERPOWERS_SKILLS_DIR/priority-test/SKILL.md" ]; then
69
+ echo " [PASS] Superpowers version exists"
70
+ else
71
+ echo " [FAIL] Superpowers version missing"
72
+ exit 1
73
+ fi
74
+
75
+ if [ -f "$OPENCODE_CONFIG_DIR/skills/priority-test/SKILL.md" ]; then
76
+ echo " [PASS] Personal version exists"
77
+ else
78
+ echo " [FAIL] Personal version missing"
79
+ exit 1
80
+ fi
81
+
82
+ if [ -f "$TEST_HOME/test-project/.opencode/skills/priority-test/SKILL.md" ]; then
83
+ echo " [PASS] Project version exists"
84
+ else
85
+ echo " [FAIL] Project version missing"
86
+ exit 1
87
+ fi
88
+
89
+ # Check if opencode is available for integration tests
90
+ if ! command -v opencode &> /dev/null; then
91
+ echo ""
92
+ echo " [SKIP] OpenCode not installed - skipping integration tests"
93
+ echo " To run these tests, install OpenCode: https://opencode.ai"
94
+ echo ""
95
+ echo "=== Priority fixture tests passed (integration tests skipped) ==="
96
+ exit 0
97
+ fi
98
+
99
+ # Test 2: Test that personal overrides superpowers
100
+ echo ""
101
+ echo "Test 2: Testing personal > superpowers priority..."
102
+ echo " Running from outside project directory..."
103
+
104
+ # Run from HOME (not in project) - should get personal version
105
+ cd "$HOME"
106
+ 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) || {
107
+ exit_code=$?
108
+ if [ $exit_code -eq 124 ]; then
109
+ echo " [FAIL] OpenCode timed out after 60s"
110
+ exit 1
111
+ fi
112
+ }
113
+
114
+ if echo "$output" | grep -qi "PRIORITY_MARKER_PERSONAL_VERSION"; then
115
+ echo " [PASS] Personal version loaded (overrides superpowers)"
116
+ elif echo "$output" | grep -qi "PRIORITY_MARKER_SUPERPOWERS_VERSION"; then
117
+ echo " [FAIL] Superpowers version loaded instead of personal"
118
+ exit 1
119
+ else
120
+ echo " [WARN] Could not verify priority marker in output"
121
+ echo " Output snippet:"
122
+ echo "$output" | grep -i "priority\|personal\|superpowers" | head -10
123
+ fi
124
+
125
+ # Test 3: Test that project overrides both personal and superpowers
126
+ echo ""
127
+ echo "Test 3: Testing project > personal > superpowers priority..."
128
+ echo " Running from project directory..."
129
+
130
+ # Run from project directory - should get project version
131
+ cd "$TEST_HOME/test-project"
132
+ 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) || {
133
+ exit_code=$?
134
+ if [ $exit_code -eq 124 ]; then
135
+ echo " [FAIL] OpenCode timed out after 60s"
136
+ exit 1
137
+ fi
138
+ }
139
+
140
+ if echo "$output" | grep -qi "PRIORITY_MARKER_PROJECT_VERSION"; then
141
+ echo " [PASS] Project version loaded (highest priority)"
142
+ elif echo "$output" | grep -qi "PRIORITY_MARKER_PERSONAL_VERSION"; then
143
+ echo " [FAIL] Personal version loaded instead of project"
144
+ exit 1
145
+ elif echo "$output" | grep -qi "PRIORITY_MARKER_SUPERPOWERS_VERSION"; then
146
+ echo " [FAIL] Superpowers version loaded instead of project"
147
+ exit 1
148
+ else
149
+ echo " [WARN] Could not verify priority marker in output"
150
+ echo " Output snippet:"
151
+ echo "$output" | grep -i "priority\|project\|personal" | head -10
152
+ fi
153
+
154
+ # Test 4: Test explicit superpowers: prefix bypasses priority
155
+ echo ""
156
+ echo "Test 4: Testing superpowers: prefix forces superpowers version..."
157
+
158
+ cd "$TEST_HOME/test-project"
159
+ 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) || {
160
+ exit_code=$?
161
+ if [ $exit_code -eq 124 ]; then
162
+ echo " [FAIL] OpenCode timed out after 60s"
163
+ exit 1
164
+ fi
165
+ }
166
+
167
+ if echo "$output" | grep -qi "PRIORITY_MARKER_SUPERPOWERS_VERSION"; then
168
+ echo " [PASS] superpowers: prefix correctly forces superpowers version"
169
+ elif echo "$output" | grep -qi "PRIORITY_MARKER_PROJECT_VERSION\|PRIORITY_MARKER_PERSONAL_VERSION"; then
170
+ echo " [FAIL] superpowers: prefix did not force superpowers version"
171
+ exit 1
172
+ else
173
+ echo " [WARN] Could not verify priority marker in output"
174
+ fi
175
+
176
+ # Test 5: Test explicit project: prefix
177
+ echo ""
178
+ echo "Test 5: Testing project: prefix forces project version..."
179
+
180
+ cd "$HOME" # Run from outside project but with project: prefix
181
+ 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) || {
182
+ exit_code=$?
183
+ if [ $exit_code -eq 124 ]; then
184
+ echo " [FAIL] OpenCode timed out after 60s"
185
+ exit 1
186
+ fi
187
+ }
188
+
189
+ # Note: This may fail since we're not in the project directory
190
+ # The project: prefix only works when in a project context
191
+ if echo "$output" | grep -qi "not found\|error"; then
192
+ echo " [PASS] project: prefix correctly fails when not in project context"
193
+ else
194
+ echo " [INFO] project: prefix behavior outside project context may vary"
195
+ fi
196
+
197
+ echo ""
198
+ echo "=== All priority tests passed ==="