context-mode 0.4.0
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.
- package/.claude-plugin/plugin.json +29 -0
- package/.mcp.json +8 -0
- package/LICENSE +21 -0
- package/README.md +304 -0
- package/build/cli.d.ts +10 -0
- package/build/cli.js +193 -0
- package/build/executor.d.ts +27 -0
- package/build/executor.js +255 -0
- package/build/runtime.d.ts +24 -0
- package/build/runtime.js +167 -0
- package/build/server.d.ts +2 -0
- package/build/server.js +457 -0
- package/build/store.d.ts +39 -0
- package/build/store.js +212 -0
- package/package.json +64 -0
- package/skills/context-mode/SKILL.md +124 -0
- package/skills/context-mode/references/anti-patterns.md +257 -0
- package/skills/context-mode/references/patterns-javascript.md +298 -0
- package/skills/context-mode/references/patterns-python.md +304 -0
- package/skills/context-mode/references/patterns-shell.md +277 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
# Shell Patterns for execute
|
|
2
|
+
|
|
3
|
+
Practical patterns for using `execute` with `language: shell`.
|
|
4
|
+
Best for piping, filtering, and leveraging native OS tools.
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## Build Output Filtering
|
|
9
|
+
|
|
10
|
+
### Capture build errors only
|
|
11
|
+
|
|
12
|
+
```shell
|
|
13
|
+
npm run build 2>&1 | tee /tmp/build-output.txt
|
|
14
|
+
EXIT_CODE=${PIPESTATUS[0]}
|
|
15
|
+
|
|
16
|
+
echo "=== Build Result ==="
|
|
17
|
+
echo "Exit code: $EXIT_CODE"
|
|
18
|
+
|
|
19
|
+
if [ "$EXIT_CODE" -ne 0 ]; then
|
|
20
|
+
echo ""
|
|
21
|
+
echo "=== Errors ==="
|
|
22
|
+
grep -iE '(error|failed|FAIL)' /tmp/build-output.txt | head -50
|
|
23
|
+
echo ""
|
|
24
|
+
echo "=== Warnings ==="
|
|
25
|
+
grep -iE '(warning|warn)' /tmp/build-output.txt | head -20
|
|
26
|
+
else
|
|
27
|
+
echo "Build succeeded."
|
|
28
|
+
echo ""
|
|
29
|
+
echo "=== Warnings (if any) ==="
|
|
30
|
+
grep -iE '(warning|warn)' /tmp/build-output.txt | head -10
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
echo ""
|
|
34
|
+
echo "=== Output Size ==="
|
|
35
|
+
wc -l < /tmp/build-output.txt | xargs -I{} echo "{} total lines of output"
|
|
36
|
+
rm -f /tmp/build-output.txt
|
|
37
|
+
```
|
|
38
|
+
> summary_prompt: "Report build success/failure, list all errors with file paths, and count warnings"
|
|
39
|
+
> timeout_ms: 120000
|
|
40
|
+
|
|
41
|
+
### TypeScript compilation check
|
|
42
|
+
|
|
43
|
+
```shell
|
|
44
|
+
npx tsc --noEmit 2>&1 | tee /tmp/tsc-output.txt
|
|
45
|
+
EXIT_CODE=${PIPESTATUS[0]}
|
|
46
|
+
|
|
47
|
+
echo "=== TypeScript Check ==="
|
|
48
|
+
echo "Exit code: $EXIT_CODE"
|
|
49
|
+
|
|
50
|
+
TOTAL_ERRORS=$(grep -c 'error TS' /tmp/tsc-output.txt 2>/dev/null || echo 0)
|
|
51
|
+
echo "Total errors: $TOTAL_ERRORS"
|
|
52
|
+
|
|
53
|
+
if [ "$TOTAL_ERRORS" -gt 0 ]; then
|
|
54
|
+
echo ""
|
|
55
|
+
echo "=== Errors by Code ==="
|
|
56
|
+
grep -oP 'error TS\d+' /tmp/tsc-output.txt | sort | uniq -c | sort -rn | head -20
|
|
57
|
+
|
|
58
|
+
echo ""
|
|
59
|
+
echo "=== Errors by File ==="
|
|
60
|
+
grep 'error TS' /tmp/tsc-output.txt | cut -d'(' -f1 | sort | uniq -c | sort -rn | head -20
|
|
61
|
+
|
|
62
|
+
echo ""
|
|
63
|
+
echo "=== First 30 Errors ==="
|
|
64
|
+
grep 'error TS' /tmp/tsc-output.txt | head -30
|
|
65
|
+
fi
|
|
66
|
+
|
|
67
|
+
rm -f /tmp/tsc-output.txt
|
|
68
|
+
```
|
|
69
|
+
> summary_prompt: "Report type error count, most common error codes, and most affected files"
|
|
70
|
+
> timeout_ms: 60000
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## Test Result Summarization
|
|
75
|
+
|
|
76
|
+
### Jest test summary
|
|
77
|
+
|
|
78
|
+
```shell
|
|
79
|
+
npx jest --verbose 2>&1 | tee /tmp/test-output.txt
|
|
80
|
+
EXIT_CODE=${PIPESTATUS[0]}
|
|
81
|
+
|
|
82
|
+
echo ""
|
|
83
|
+
echo "=== Test Summary ==="
|
|
84
|
+
echo "Exit code: $EXIT_CODE"
|
|
85
|
+
|
|
86
|
+
# Extract summary line
|
|
87
|
+
grep -E '(Tests:|Test Suites:|Snapshots:|Time:)' /tmp/test-output.txt
|
|
88
|
+
|
|
89
|
+
echo ""
|
|
90
|
+
echo "=== Failed Tests ==="
|
|
91
|
+
grep -A 2 'FAIL ' /tmp/test-output.txt | head -40
|
|
92
|
+
|
|
93
|
+
echo ""
|
|
94
|
+
echo "=== Slow Tests (if reported) ==="
|
|
95
|
+
grep -i 'slow' /tmp/test-output.txt | head -10
|
|
96
|
+
|
|
97
|
+
rm -f /tmp/test-output.txt
|
|
98
|
+
```
|
|
99
|
+
> summary_prompt: "Report pass/fail ratio, list all failing test names with suite, note any slow tests"
|
|
100
|
+
> timeout_ms: 120000
|
|
101
|
+
|
|
102
|
+
### Pytest summary
|
|
103
|
+
|
|
104
|
+
```shell
|
|
105
|
+
python -m pytest --tb=short -q 2>&1 | tee /tmp/pytest-output.txt
|
|
106
|
+
EXIT_CODE=${PIPESTATUS[0]}
|
|
107
|
+
|
|
108
|
+
echo ""
|
|
109
|
+
echo "=== Pytest Summary ==="
|
|
110
|
+
echo "Exit code: $EXIT_CODE"
|
|
111
|
+
|
|
112
|
+
# Last 20 lines usually contain the summary
|
|
113
|
+
tail -20 /tmp/pytest-output.txt
|
|
114
|
+
|
|
115
|
+
echo ""
|
|
116
|
+
echo "=== Failures ==="
|
|
117
|
+
grep -E '(FAILED|ERROR)' /tmp/pytest-output.txt | head -30
|
|
118
|
+
|
|
119
|
+
rm -f /tmp/pytest-output.txt
|
|
120
|
+
```
|
|
121
|
+
> summary_prompt: "Report test results, list all failures with file and test name"
|
|
122
|
+
> timeout_ms: 120000
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Log File Analysis
|
|
127
|
+
|
|
128
|
+
### Filter application logs by severity
|
|
129
|
+
|
|
130
|
+
```shell
|
|
131
|
+
LOG_FILE="${1:-/var/log/app.log}"
|
|
132
|
+
|
|
133
|
+
echo "=== Log File: $LOG_FILE ==="
|
|
134
|
+
echo "Total lines: $(wc -l < "$LOG_FILE")"
|
|
135
|
+
echo ""
|
|
136
|
+
|
|
137
|
+
echo "=== Level Distribution ==="
|
|
138
|
+
grep -oE '\b(DEBUG|INFO|WARN|ERROR|FATAL)\b' "$LOG_FILE" | sort | uniq -c | sort -rn
|
|
139
|
+
|
|
140
|
+
echo ""
|
|
141
|
+
echo "=== Last 20 Errors ==="
|
|
142
|
+
grep -i 'ERROR\|FATAL' "$LOG_FILE" | tail -20
|
|
143
|
+
|
|
144
|
+
echo ""
|
|
145
|
+
echo "=== Error Timeline (hourly) ==="
|
|
146
|
+
grep -i 'ERROR' "$LOG_FILE" | grep -oE '\d{4}-\d{2}-\d{2} \d{2}' | sort | uniq -c | tail -24
|
|
147
|
+
```
|
|
148
|
+
> summary_prompt: "Report error frequency, identify patterns, and note any error spikes"
|
|
149
|
+
|
|
150
|
+
### Analyze access logs
|
|
151
|
+
|
|
152
|
+
```shell
|
|
153
|
+
LOG_FILE="${1:-/var/log/access.log}"
|
|
154
|
+
|
|
155
|
+
echo "=== Access Log Summary ==="
|
|
156
|
+
echo "Total requests: $(wc -l < "$LOG_FILE")"
|
|
157
|
+
|
|
158
|
+
echo ""
|
|
159
|
+
echo "=== HTTP Status Codes ==="
|
|
160
|
+
awk '{print $9}' "$LOG_FILE" | sort | uniq -c | sort -rn | head -10
|
|
161
|
+
|
|
162
|
+
echo ""
|
|
163
|
+
echo "=== Top 20 Paths ==="
|
|
164
|
+
awk '{print $7}' "$LOG_FILE" | sort | uniq -c | sort -rn | head -20
|
|
165
|
+
|
|
166
|
+
echo ""
|
|
167
|
+
echo "=== Top 10 IPs ==="
|
|
168
|
+
awk '{print $1}' "$LOG_FILE" | sort | uniq -c | sort -rn | head -10
|
|
169
|
+
|
|
170
|
+
echo ""
|
|
171
|
+
echo "=== 5xx Errors ==="
|
|
172
|
+
awk '$9 ~ /^5/' "$LOG_FILE" | tail -20
|
|
173
|
+
|
|
174
|
+
echo ""
|
|
175
|
+
echo "=== Requests per Hour ==="
|
|
176
|
+
awk '{print $4}' "$LOG_FILE" | cut -d: -f1-2 | sort | uniq -c | tail -24
|
|
177
|
+
```
|
|
178
|
+
> summary_prompt: "Report traffic patterns, error rates, most hit endpoints, and suspicious IPs"
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Directory Size and Structure Analysis
|
|
183
|
+
|
|
184
|
+
### Project structure overview
|
|
185
|
+
|
|
186
|
+
```shell
|
|
187
|
+
echo "=== Directory Structure ==="
|
|
188
|
+
find . -maxdepth 3 -type d \
|
|
189
|
+
! -path '*/node_modules/*' \
|
|
190
|
+
! -path '*/.git/*' \
|
|
191
|
+
! -path '*/dist/*' \
|
|
192
|
+
! -path '*/.next/*' \
|
|
193
|
+
! -path '*/__pycache__/*' \
|
|
194
|
+
| sort
|
|
195
|
+
|
|
196
|
+
echo ""
|
|
197
|
+
echo "=== File Type Distribution ==="
|
|
198
|
+
find . -type f \
|
|
199
|
+
! -path '*/node_modules/*' \
|
|
200
|
+
! -path '*/.git/*' \
|
|
201
|
+
! -path '*/dist/*' \
|
|
202
|
+
| sed 's/.*\.//' | sort | uniq -c | sort -rn | head -20
|
|
203
|
+
|
|
204
|
+
echo ""
|
|
205
|
+
echo "=== Largest Files (top 20) ==="
|
|
206
|
+
find . -type f \
|
|
207
|
+
! -path '*/node_modules/*' \
|
|
208
|
+
! -path '*/.git/*' \
|
|
209
|
+
-exec ls -la {} \; | sort -k5 -rn | head -20 | awk '{print $5, $9}'
|
|
210
|
+
|
|
211
|
+
echo ""
|
|
212
|
+
echo "=== Directory Sizes ==="
|
|
213
|
+
du -sh */ 2>/dev/null | sort -rh | head -15
|
|
214
|
+
```
|
|
215
|
+
> summary_prompt: "Describe the project structure, identify large files that may need attention, report file type distribution"
|
|
216
|
+
|
|
217
|
+
### Disk usage investigation
|
|
218
|
+
|
|
219
|
+
```shell
|
|
220
|
+
echo "=== Top-Level Disk Usage ==="
|
|
221
|
+
du -sh */ 2>/dev/null | sort -rh
|
|
222
|
+
|
|
223
|
+
echo ""
|
|
224
|
+
echo "=== node_modules Size ==="
|
|
225
|
+
if [ -d "node_modules" ]; then
|
|
226
|
+
du -sh node_modules
|
|
227
|
+
echo ""
|
|
228
|
+
echo "=== Largest node_modules packages ==="
|
|
229
|
+
du -sh node_modules/*/ 2>/dev/null | sort -rh | head -20
|
|
230
|
+
else
|
|
231
|
+
echo "No node_modules directory"
|
|
232
|
+
fi
|
|
233
|
+
|
|
234
|
+
echo ""
|
|
235
|
+
echo "=== Build Artifacts ==="
|
|
236
|
+
for dir in dist build .next out .cache; do
|
|
237
|
+
if [ -d "$dir" ]; then
|
|
238
|
+
echo " $dir: $(du -sh "$dir" | cut -f1)"
|
|
239
|
+
fi
|
|
240
|
+
done
|
|
241
|
+
|
|
242
|
+
echo ""
|
|
243
|
+
echo "=== Git Objects Size ==="
|
|
244
|
+
if [ -d ".git" ]; then
|
|
245
|
+
du -sh .git
|
|
246
|
+
fi
|
|
247
|
+
```
|
|
248
|
+
> summary_prompt: "Report total project size, largest contributors, and recommend cleanup targets"
|
|
249
|
+
|
|
250
|
+
---
|
|
251
|
+
|
|
252
|
+
## Git Analysis
|
|
253
|
+
|
|
254
|
+
### Commit activity analysis
|
|
255
|
+
|
|
256
|
+
```shell
|
|
257
|
+
echo "=== Recent Commits (last 30 days) ==="
|
|
258
|
+
git log --since="30 days ago" --oneline | wc -l | xargs -I{} echo "{} commits in last 30 days"
|
|
259
|
+
|
|
260
|
+
echo ""
|
|
261
|
+
echo "=== Commits by Author ==="
|
|
262
|
+
git shortlog -sn --since="30 days ago" | head -15
|
|
263
|
+
|
|
264
|
+
echo ""
|
|
265
|
+
echo "=== Most Changed Files (last 30 days) ==="
|
|
266
|
+
git log --since="30 days ago" --pretty=format: --name-only | sort | uniq -c | sort -rn | head -20
|
|
267
|
+
|
|
268
|
+
echo ""
|
|
269
|
+
echo "=== Branches ==="
|
|
270
|
+
echo "Local: $(git branch | wc -l | xargs)"
|
|
271
|
+
echo "Remote: $(git branch -r | wc -l | xargs)"
|
|
272
|
+
|
|
273
|
+
echo ""
|
|
274
|
+
echo "=== Stale Branches (merged, excluding main/master) ==="
|
|
275
|
+
git branch --merged main 2>/dev/null | grep -v 'main\|master\|\*' | head -10
|
|
276
|
+
```
|
|
277
|
+
> summary_prompt: "Report development velocity, active contributors, hotspot files, and cleanup opportunities"
|