-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin-structure-test.sh
More file actions
executable file
·265 lines (224 loc) · 13.1 KB
/
Copy pathplugin-structure-test.sh
File metadata and controls
executable file
·265 lines (224 loc) · 13.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#!/usr/bin/env bash
set -euo pipefail
# plugin-structure-test.sh - Essential structural validation for multi-plugin marketplace
# Tests marketplace manifest and all 4 plugins (stepwise-core, stepwise-git, stepwise-web, stepwise-research)
# Get script directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
# Source test helpers
# shellcheck source=test/test-helpers.sh
source "$SCRIPT_DIR/test-helpers.sh"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "🔍 Multi-Plugin Marketplace Structure Tests"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Project root: $PROJECT_ROOT"
echo ""
cd "$PROJECT_ROOT"
# ============================================================================
# Test 1: Marketplace manifest is valid
# ============================================================================
section "Test 1: Marketplace manifest"
assert_file_exists ".claude-plugin/marketplace.json" "marketplace.json exists"
if command -v jq >/dev/null 2>&1; then
if jq empty .claude-plugin/marketplace.json 2>/dev/null; then
TESTS_RUN=$((TESTS_RUN + 1))
TESTS_PASSED=$((TESTS_PASSED + 1))
echo -e "${GREEN}✓${NC} marketplace.json is valid JSON"
else
TESTS_RUN=$((TESTS_RUN + 1))
TESTS_FAILED=$((TESTS_FAILED + 1))
echo -e "${RED}✗${NC} marketplace.json is invalid JSON"
fi
NAME=$(jq -r '.name // empty' .claude-plugin/marketplace.json)
assert_not_empty "$NAME" "marketplace.json has name field"
OWNER_NAME=$(jq -r '.owner.name // empty' .claude-plugin/marketplace.json)
assert_not_empty "$OWNER_NAME" "marketplace.json has owner.name field"
PLUGINS_COUNT=$(jq '.plugins | length' .claude-plugin/marketplace.json)
if [ "$PLUGINS_COUNT" -ge 3 ]; then
TESTS_RUN=$((TESTS_RUN + 1))
TESTS_PASSED=$((TESTS_PASSED + 1))
echo -e "${GREEN}✓${NC} marketplace.json has $PLUGINS_COUNT plugins (expected: 3+)"
else
TESTS_RUN=$((TESTS_RUN + 1))
TESTS_FAILED=$((TESTS_FAILED + 1))
echo -e "${RED}✗${NC} marketplace.json should have at least 3 plugins, has $PLUGINS_COUNT"
fi
fi
# ============================================================================
# Test 2: Core plugin structure (stepwise-core)
# ============================================================================
section "Test 2: stepwise-core plugin"
assert_file_exists "core/.claude-plugin/plugin.json" "core/plugin.json exists"
assert_file_exists "core/README.md" "core/README.md exists"
# Skills (workflow)
assert_file_exists "core/skills/research-codebase/SKILL.md" "research-codebase skill"
assert_file_exists "core/skills/create-plan/SKILL.md" "create-plan skill"
assert_file_exists "core/skills/iterate-plan/SKILL.md" "iterate-plan skill"
assert_file_exists "core/skills/implement-plan/SKILL.md" "implement-plan skill"
assert_file_exists "core/skills/validate-plan/SKILL.md" "validate-plan skill"
# Skills (practices)
assert_file_exists "core/skills/tdd/SKILL.md" "tdd skill"
assert_file_exists "core/skills/grill-me/SKILL.md" "grill-me skill"
assert_file_exists "core/skills/bugmagnet/SKILL.md" "bugmagnet skill"
assert_file_exists "core/skills/hamburger-method/SKILL.md" "hamburger-method skill"
assert_file_exists "core/skills/small-safe-steps/SKILL.md" "small-safe-steps skill"
assert_file_exists "core/skills/story-splitting/SKILL.md" "story-splitting skill"
assert_file_exists "core/skills/test-desiderata/SKILL.md" "test-desiderata skill"
# Agents
assert_file_exists "core/agents/codebase-locator.md" "codebase-locator agent"
assert_file_exists "core/agents/codebase-analyzer.md" "codebase-analyzer agent"
assert_file_exists "core/agents/codebase-pattern-finder.md" "codebase-pattern-finder agent"
assert_file_exists "core/agents/thoughts-locator.md" "thoughts-locator agent"
assert_file_exists "core/agents/thoughts-analyzer.md" "thoughts-analyzer agent"
# Skill structure
assert_dir_exists "core/skills/thoughts-management" "Skill directory exists"
assert_dir_exists "core/skills/thoughts-management/scripts" "scripts directory exists"
assert_file_exists "core/skills/thoughts-management/SKILL.md" "SKILL.md exists"
assert_contains "core/skills/thoughts-management/SKILL.md" "name: thoughts-management" "SKILL.md has name"
# Scripts are executable
assert_file_exists "core/skills/thoughts-management/scripts/thoughts-init" "thoughts-init exists"
assert_executable "core/skills/thoughts-management/scripts/thoughts-init" "thoughts-init is executable"
assert_file_exists "core/skills/thoughts-management/scripts/thoughts-metadata" "thoughts-metadata exists"
assert_executable "core/skills/thoughts-management/scripts/thoughts-metadata" "thoughts-metadata is executable"
# ============================================================================
# Test 3: Git plugin structure (stepwise-git)
# ============================================================================
section "Test 3: stepwise-git plugin"
assert_file_exists "git/.claude-plugin/plugin.json" "git/plugin.json exists"
assert_file_exists "git/README.md" "git/README.md exists"
assert_file_exists "git/skills/commit/SKILL.md" "commit skill exists"
assert_file_exists "git/skills/review-pr-comments/SKILL.md" "review-pr-comments skill exists"
# ============================================================================
# Test 4: Web plugin structure (stepwise-web)
# ============================================================================
section "Test 4: stepwise-web plugin"
assert_file_exists "web/.claude-plugin/plugin.json" "web/plugin.json exists"
assert_file_exists "web/README.md" "web/README.md exists"
assert_file_exists "web/agents/web-search-researcher.md" "web-search-researcher agent exists"
# ============================================================================
# Test 5: Research plugin structure (stepwise-research)
# ============================================================================
section "Test 5: stepwise-research plugin"
assert_file_exists "research/.claude-plugin/plugin.json" "research/plugin.json exists"
assert_file_exists "research/README.md" "research/README.md exists"
assert_file_exists "research/skills/deep-research/SKILL.md" "deep-research skill exists"
assert_file_exists "research/skills/deep-research/scripts/generate-report" "generate-report exists"
assert_executable "research/skills/deep-research/scripts/generate-report" "generate-report is executable"
assert_file_exists "research/agents/research-lead.md" "research-lead agent exists"
assert_file_exists "research/agents/research-worker.md" "research-worker agent exists"
assert_file_exists "research/agents/citation-analyst.md" "citation-analyst agent exists"
# ============================================================================
# Test 6: Slides plugin structure (stepwise-slides, vendored)
# ============================================================================
section "Test 6: stepwise-slides plugin"
assert_file_exists "slides/LICENSE" "slides/LICENSE exists"
assert_contains "slides/LICENSE" "MIT License" "slides/LICENSE is MIT"
assert_file_exists "slides/plugins/frontend-slides/.claude-plugin/plugin.json" "vendored plugin.json exists"
assert_file_exists "slides/plugins/frontend-slides/skills/frontend-slides/SKILL.md" "frontend-slides SKILL.md exists"
assert_contains "slides/plugins/frontend-slides/skills/frontend-slides/SKILL.md" "^name: frontend-slides" "SKILL.md declares name"
if command -v jq >/dev/null 2>&1; then
UPSTREAM_NAME=$(jq -r '.name // empty' slides/plugins/frontend-slides/.claude-plugin/plugin.json)
if [ "$UPSTREAM_NAME" = "frontend-slides" ]; then
TESTS_RUN=$((TESTS_RUN + 1))
TESTS_PASSED=$((TESTS_PASSED + 1))
echo -e "${GREEN}✓${NC} vendored plugin.json .name == frontend-slides"
else
TESTS_RUN=$((TESTS_RUN + 1))
TESTS_FAILED=$((TESTS_FAILED + 1))
echo -e "${RED}✗${NC} vendored plugin.json .name is '$UPSTREAM_NAME'"
fi
SLIDES_SOURCE=$(jq -r '.plugins[] | select(.name=="stepwise-slides") | .source' .claude-plugin/marketplace.json)
if [ "$SLIDES_SOURCE" = "./slides/plugins/frontend-slides" ]; then
TESTS_RUN=$((TESTS_RUN + 1))
TESTS_PASSED=$((TESTS_PASSED + 1))
echo -e "${GREEN}✓${NC} marketplace entry stepwise-slides points at vendored dir"
else
TESTS_RUN=$((TESTS_RUN + 1))
TESTS_FAILED=$((TESTS_FAILED + 1))
echo -e "${RED}✗${NC} stepwise-slides source is '$SLIDES_SOURCE'"
fi
fi
# ============================================================================
# Test 7: Diagrams plugin structure (stepwise-diagrams, vendored)
# ============================================================================
section "Test 7: stepwise-diagrams plugin"
assert_file_exists "diagrams/LICENSE" "diagrams/LICENSE exists"
assert_contains "diagrams/LICENSE" "MIT License" "diagrams/LICENSE is MIT"
assert_file_exists "diagrams/.claude-plugin/plugin.json" "vendored plugin.json exists"
assert_file_exists "diagrams/skills/diagram-design/SKILL.md" "diagram-design SKILL.md exists"
assert_contains "diagrams/skills/diagram-design/SKILL.md" "^name: diagram-design" "SKILL.md declares name"
if command -v jq >/dev/null 2>&1; then
UPSTREAM_NAME=$(jq -r '.name // empty' diagrams/.claude-plugin/plugin.json)
if [ "$UPSTREAM_NAME" = "diagram-design" ]; then
TESTS_RUN=$((TESTS_RUN + 1))
TESTS_PASSED=$((TESTS_PASSED + 1))
echo -e "${GREEN}✓${NC} vendored plugin.json .name == diagram-design"
else
TESTS_RUN=$((TESTS_RUN + 1))
TESTS_FAILED=$((TESTS_FAILED + 1))
echo -e "${RED}✗${NC} vendored plugin.json .name is '$UPSTREAM_NAME'"
fi
DIAGRAMS_SOURCE=$(jq -r '.plugins[] | select(.name=="stepwise-diagrams") | .source' .claude-plugin/marketplace.json)
if [ "$DIAGRAMS_SOURCE" = "./diagrams" ]; then
TESTS_RUN=$((TESTS_RUN + 1))
TESTS_PASSED=$((TESTS_PASSED + 1))
echo -e "${GREEN}✓${NC} marketplace entry stepwise-diagrams points at vendored dir"
else
TESTS_RUN=$((TESTS_RUN + 1))
TESTS_FAILED=$((TESTS_FAILED + 1))
echo -e "${RED}✗${NC} stepwise-diagrams source is '$DIAGRAMS_SOURCE'"
fi
fi
# ============================================================================
# Test 8: Codex compatibility layer
# ============================================================================
section "Test 8: codex/"
assert_file_exists "codex/transpile-agents.sh" "transpile-agents.sh exists"
assert_executable "codex/transpile-agents.sh" "transpile-agents.sh is executable"
assert_file_exists "codex/install.sh" "install.sh exists"
assert_executable "codex/install.sh" "install.sh is executable"
for agent in codebase-locator codebase-analyzer codebase-pattern-finder \
thoughts-locator thoughts-analyzer \
research-lead research-worker citation-analyst web-search-researcher; do
assert_file_exists "codex/agents/$agent.toml" "$agent.toml is generated"
# An empty file would satisfy existence alone; require real generated content.
assert_contains "codex/agents/$agent.toml" "^name = \"$agent\"$" "$agent.toml declares its name"
assert_contains "codex/agents/$agent.toml" "^developer_instructions" "$agent.toml has instructions"
done
# Every skill that declares an implicit-invocation policy for Claude Code must
# carry the same policy for Codex, so both harnesses behave alike. The list is
# derived from the frontmatter rather than hardcoded, so a skill whose
# openai.yaml is missing or disagrees with its SKILL.md fails here.
POLICY_SKILLS="$(grep -rl '^disable-model-invocation:' --include="SKILL.md" core git research web | sort)"
assert_not_empty "$POLICY_SKILLS" "found skills that declare an implicit-invocation policy"
while IFS= read -r skill_md; do
skill="$(dirname "$skill_md")"
if grep -q '^disable-model-invocation: *true' "$skill_md"; then
codex_policy="allow_implicit_invocation: false"
else
codex_policy="allow_implicit_invocation: true"
fi
assert_contains "$skill/agents/openai.yaml" "$codex_policy" \
"$(basename "$skill") declares the same invocation policy for Codex"
done <<< "$POLICY_SKILLS"
# ============================================================================
# Test 9: Root documentation
# ============================================================================
section "Test 9: Root documentation"
assert_file_exists "README.md" "README.md exists"
assert_file_exists "AGENTS.md" "AGENTS.md exists"
assert_file_exists "CLAUDE.md" "CLAUDE.md exists"
assert_file_exists ".gitignore" ".gitignore exists"
assert_contains "README.md" "stepwise-dev" "README documents marketplace"
# ============================================================================
# Summary
# ============================================================================
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
print_summary
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
if [ "$TESTS_FAILED" -eq 0 ]; then
exit 0
else
exit 1
fi