agentsys 5.3.4 → 5.3.6

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 (74) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/CHANGELOG.md +11 -0
  4. package/bin/cli.js +40 -28
  5. package/lib/adapter-transforms.js +3 -3
  6. package/package.json +1 -1
  7. package/site/content.json +32 -8
  8. package/.cursor/commands/audit-project-agents.md +0 -454
  9. package/.cursor/commands/audit-project-github.md +0 -141
  10. package/.cursor/commands/audit-project.md +0 -330
  11. package/.cursor/commands/consult.md +0 -417
  12. package/.cursor/commands/debate.md +0 -381
  13. package/.cursor/commands/delivery-approval.md +0 -334
  14. package/.cursor/commands/deslop.md +0 -142
  15. package/.cursor/commands/drift-detect.md +0 -259
  16. package/.cursor/commands/enhance.md +0 -172
  17. package/.cursor/commands/learn.md +0 -165
  18. package/.cursor/commands/next-task.md +0 -519
  19. package/.cursor/commands/perf.md +0 -464
  20. package/.cursor/commands/repo-map.md +0 -124
  21. package/.cursor/commands/ship-ci-review-loop.md +0 -468
  22. package/.cursor/commands/ship-deployment.md +0 -348
  23. package/.cursor/commands/ship-error-handling.md +0 -265
  24. package/.cursor/commands/ship.md +0 -517
  25. package/.cursor/commands/sync-docs.md +0 -171
  26. package/.cursor/commands/web-ctl.md +0 -101
  27. package/.cursor/skills/consult/SKILL.md +0 -425
  28. package/.cursor/skills/debate/SKILL.md +0 -316
  29. package/.cursor/skills/deslop/SKILL.md +0 -204
  30. package/.cursor/skills/discover-tasks/SKILL.md +0 -297
  31. package/.cursor/skills/drift-analysis/SKILL.md +0 -324
  32. package/.cursor/skills/enhance-agent-prompts/SKILL.md +0 -277
  33. package/.cursor/skills/enhance-claude-memory/SKILL.md +0 -387
  34. package/.cursor/skills/enhance-cross-file/SKILL.md +0 -110
  35. package/.cursor/skills/enhance-docs/SKILL.md +0 -298
  36. package/.cursor/skills/enhance-hooks/SKILL.md +0 -554
  37. package/.cursor/skills/enhance-orchestrator/SKILL.md +0 -255
  38. package/.cursor/skills/enhance-plugins/SKILL.md +0 -319
  39. package/.cursor/skills/enhance-prompts/SKILL.md +0 -340
  40. package/.cursor/skills/enhance-skills/SKILL.md +0 -436
  41. package/.cursor/skills/learn/SKILL.md +0 -349
  42. package/.cursor/skills/orchestrate-review/SKILL.md +0 -260
  43. package/.cursor/skills/perf-analyzer/SKILL.md +0 -37
  44. package/.cursor/skills/perf-baseline-manager/SKILL.md +0 -30
  45. package/.cursor/skills/perf-benchmarker/SKILL.md +0 -52
  46. package/.cursor/skills/perf-code-paths/SKILL.md +0 -32
  47. package/.cursor/skills/perf-investigation-logger/SKILL.md +0 -41
  48. package/.cursor/skills/perf-profiler/SKILL.md +0 -42
  49. package/.cursor/skills/perf-theory-gatherer/SKILL.md +0 -35
  50. package/.cursor/skills/perf-theory-tester/SKILL.md +0 -36
  51. package/.cursor/skills/repo-mapping/SKILL.md +0 -83
  52. package/.cursor/skills/sync-docs/SKILL.md +0 -351
  53. package/.cursor/skills/validate-delivery/SKILL.md +0 -186
  54. package/.cursor/skills/web-auth/SKILL.md +0 -177
  55. package/.cursor/skills/web-browse/SKILL.md +0 -516
  56. package/.kiro/steering/audit-project-agents.md +0 -459
  57. package/.kiro/steering/audit-project-github.md +0 -146
  58. package/.kiro/steering/audit-project.md +0 -330
  59. package/.kiro/steering/consult.md +0 -422
  60. package/.kiro/steering/debate.md +0 -386
  61. package/.kiro/steering/delivery-approval.md +0 -339
  62. package/.kiro/steering/deslop.md +0 -149
  63. package/.kiro/steering/drift-detect.md +0 -264
  64. package/.kiro/steering/enhance.md +0 -177
  65. package/.kiro/steering/learn.md +0 -166
  66. package/.kiro/steering/next-task.md +0 -481
  67. package/.kiro/steering/perf.md +0 -469
  68. package/.kiro/steering/repo-map.md +0 -126
  69. package/.kiro/steering/ship-ci-review-loop.md +0 -473
  70. package/.kiro/steering/ship-deployment.md +0 -353
  71. package/.kiro/steering/ship-error-handling.md +0 -270
  72. package/.kiro/steering/ship.md +0 -522
  73. package/.kiro/steering/sync-docs.md +0 -178
  74. package/.kiro/steering/web-ctl.md +0 -106
@@ -1,554 +0,0 @@
1
- ---
2
- name: enhance-hooks
3
- description: "Use when reviewing hooks for safety, timeouts, and correct frontmatter."
4
- version: 5.1.0
5
- argument-hint: "[path] [--fix]"
6
- ---
7
-
8
- # enhance-hooks
9
-
10
- Analyze hook definitions and scripts for safety, correctness, and best practices.
11
-
12
- ## Parse Arguments
13
-
14
- ```javascript
15
- const args = '$ARGUMENTS'.split(' ').filter(Boolean);
16
- const targetPath = args.find(a => !a.startsWith('--')) || '.';
17
- const fix = args.includes('--fix');
18
- ```
19
-
20
- ## Workflow
21
-
22
- 1. **Discover** - Find hook files (.md, .sh, .json)
23
- 2. **Classify** - Identify hook type and event
24
- 3. **Parse** - Extract frontmatter and script content
25
- 4. **Check** - Run all pattern checks against knowledge below
26
- 5. **Filter** - Apply certainty filtering
27
- 6. **Report** - Generate markdown output
28
- 7. **Fix** - Apply auto-fixes if --fix flag present
29
-
30
- ---
31
-
32
- ## Hook Knowledge Reference
33
-
34
- ### What Are Hooks
35
-
36
- Hooks are automated actions triggered at specific points in a Claude Code session. They enable validation, monitoring, and control of Claude's actions through bash commands or LLM-based evaluation.
37
-
38
- ### Hook Lifecycle (Complete Reference)
39
-
40
- Hooks fire in this sequence:
41
-
42
- | Order | Event | Description | Matcher Required |
43
- |-------|-------|-------------|------------------|
44
- | 1 | `SessionStart` | Session begins or resumes | No |
45
- | 2 | `UserPromptSubmit` | User submits a prompt | No |
46
- | 3 | `PreToolUse` | Before tool execution (can modify/block) | Yes |
47
- | 4 | `PermissionRequest` | When permission dialog appears | Yes |
48
- | 5 | `PostToolUse` | After tool succeeds | Yes |
49
- | 6 | `SubagentStart` | When spawning a subagent | No |
50
- | 7 | `SubagentStop` | When subagent finishes | No |
51
- | 8 | `Stop` | Claude finishes responding | No |
52
- | 9 | `PreCompact` | Before context compaction | No |
53
- | 10 | `SessionEnd` | Session terminates | No |
54
- | 11 | `Notification` | Claude Code sends notifications | No |
55
-
56
- ### Hook Types
57
-
58
- **Command Hooks** (`type: "command"`):
59
- - Execute bash commands with full stdin/stdout control
60
- - Available for all events
61
-
62
- **Prompt Hooks** (`type: "prompt"`):
63
- - Use LLM evaluation for intelligent, context-aware decisions
64
- - **Only supported for `Stop` and `SubagentStop` events**
65
-
66
- ### Configuration Locations
67
-
68
- | File | Location | Scope | Committed |
69
- |------|----------|-------|-----------|
70
- | User settings | `~/.claude/settings.json` | All projects | No |
71
- | Project settings | `.claude/settings.json` | Current project | Yes |
72
- | Local settings | `.claude/settings.local.json` | Current project | No |
73
-
74
- ### Configuration Structure
75
-
76
- ```json
77
- {
78
- "hooks": {
79
- "PreToolUse": [
80
- {
81
- "matcher": "Bash",
82
- "hooks": [
83
- {
84
- "type": "command",
85
- "command": ".claude/hooks/validate-bash.sh",
86
- "timeout": 30
87
- }
88
- ]
89
- }
90
- ],
91
- "PostToolUse": [
92
- {
93
- "matcher": "Write|Edit",
94
- "hooks": [
95
- {
96
- "type": "command",
97
- "command": "$CLAUDE_PROJECT_DIR/.claude/hooks/format-code.sh"
98
- }
99
- ]
100
- }
101
- ],
102
- "Stop": [
103
- {
104
- "hooks": [
105
- {
106
- "type": "prompt",
107
- "prompt": "Check if all requested tasks are complete.",
108
- "timeout": 30
109
- }
110
- ]
111
- }
112
- ]
113
- }
114
- }
115
- ```
116
-
117
- ### Matcher Syntax
118
-
119
- | Pattern | Description |
120
- |---------|-------------|
121
- | `Write` | Match exact tool name |
122
- | `Edit\|Write` | Match multiple tools (regex OR) |
123
- | `Notebook.*` | Regex pattern matching |
124
- | `*` or `""` | Match all tools |
125
- | (omitted) | Required for Stop, SubagentStop, UserPromptSubmit |
126
-
127
- ### Input Schema (JSON via stdin)
128
-
129
- All hooks receive this JSON structure:
130
-
131
- ```json
132
- {
133
- "session_id": "abc123",
134
- "transcript_path": "/path/to/transcript",
135
- "cwd": "/project/root",
136
- "permission_mode": "default",
137
- "hook_event_name": "PreToolUse",
138
- "tool_name": "Bash",
139
- "tool_input": {
140
- "command": "npm test",
141
- "description": "Run test suite"
142
- }
143
- }
144
- ```
145
-
146
- ### Exit Codes
147
-
148
- | Exit Code | Behavior |
149
- |-----------|----------|
150
- | 0 | Success - stdout shown to user or added as context |
151
- | 2 | Blocking error - stderr shown, action blocked |
152
- | Other | Non-blocking error - stderr shown in verbose mode |
153
-
154
- ### Output Schemas
155
-
156
- **PreToolUse Decision Control:**
157
- ```json
158
- {
159
- "hookSpecificOutput": {
160
- "hookEventName": "PreToolUse",
161
- "permissionDecision": "allow|deny|ask",
162
- "permissionDecisionReason": "Reason for decision",
163
- "updatedInput": {
164
- "command": "modified command"
165
- },
166
- "additionalContext": "Context for Claude"
167
- }
168
- }
169
- ```
170
-
171
- **Stop/SubagentStop Control:**
172
- ```json
173
- {
174
- "decision": "block",
175
- "reason": "Tasks incomplete: missing test coverage"
176
- }
177
- ```
178
-
179
- ### Environment Variables
180
-
181
- | Variable | Description | Available In |
182
- |----------|-------------|--------------|
183
- | `CLAUDE_PROJECT_DIR` | Absolute path to project root | All hooks |
184
- | `CLAUDE_CODE_REMOTE` | "true" if remote session | All hooks |
185
- | `CLAUDE_ENV_FILE` | Path to persist env vars | SessionStart only |
186
- | `CLAUDE_FILE_PATHS` | Space-separated file paths | PostToolUse (Write/Edit) |
187
-
188
- ### Practical Hook Examples
189
-
190
- **Security Firewall (PreToolUse):**
191
- ```bash
192
- #!/usr/bin/env bash
193
- set -euo pipefail
194
-
195
- cmd=$(jq -r '.tool_input.command // ""')
196
-
197
- # Block dangerous patterns
198
- if echo "$cmd" | grep -qE 'rm -rf|git reset --hard|curl.*\|.*sh'; then
199
- echo '{"decision": "block", "reason": "Dangerous command blocked"}' >&2
200
- exit 2
201
- fi
202
-
203
- exit 0
204
- ```
205
-
206
- **Auto-Formatter (PostToolUse):**
207
- ```bash
208
- #!/usr/bin/env bash
209
- set -euo pipefail
210
-
211
- files=$(jq -r '.tool_input.file_path // ""')
212
-
213
- for file in $files; do
214
- case "$file" in
215
- *.py) black "$file" 2>/dev/null || true ;;
216
- *.js|*.ts) prettier --write "$file" 2>/dev/null || true ;;
217
- esac
218
- done
219
-
220
- exit 0
221
- ```
222
-
223
- **Command Logger (PreToolUse):**
224
- ```bash
225
- #!/usr/bin/env bash
226
- set -euo pipefail
227
- cmd=$(jq -r '.tool_input.command // ""')
228
- printf '%s %s\n' "$(date -Is)" "$cmd" >> .claude/bash-commands.log
229
- exit 0
230
- ```
231
-
232
- **Workflow Orchestration (SubagentStop - prompt type):**
233
- ```json
234
- {
235
- "hooks": {
236
- "SubagentStop": [
237
- {
238
- "hooks": [
239
- {
240
- "type": "prompt",
241
- "prompt": "Review the subagent's work. Did it complete all tasks?"
242
- }
243
- ]
244
- }
245
- ]
246
- }
247
- }
248
- ```
249
-
250
- ---
251
-
252
- ## Detection Patterns
253
-
254
- ### 1. Frontmatter Validation (HIGH Certainty)
255
-
256
- **Required:**
257
- - YAML frontmatter with `---` delimiters
258
- - `name` field in frontmatter
259
- - `description` field in frontmatter
260
-
261
- **Recommended:**
262
- - `timeout` for command hooks (default: 30s)
263
- - Hook type specification
264
-
265
- **Flag:**
266
- - Missing frontmatter delimiters
267
- - Missing name or description
268
-
269
- ### 2. Script Safety (HIGH Certainty)
270
-
271
- **Required Safety Patterns:**
272
- - `set -euo pipefail` at script start
273
- - Error handling for jq/JSON parsing
274
- - Proper quoting of variables
275
-
276
- **Dangerous Patterns to Flag:**
277
-
278
- | Pattern | Risk | Certainty |
279
- |---------|------|-----------|
280
- | `rm -rf` | Destructive without confirmation | HIGH |
281
- | `git reset --hard` | Data loss risk | HIGH |
282
- | `curl \| sh` | Remote code execution | HIGH |
283
- | `eval "$input"` | Arbitrary code execution | HIGH |
284
- | `rm -r` | Recursive delete (may be intentional) | MEDIUM |
285
- | `git push --force` | Force push (may be intentional) | MEDIUM |
286
-
287
- ### 3. Exit Code Handling (HIGH Certainty)
288
-
289
- **Check:** Scripts use correct exit codes
290
-
291
- **Flag:**
292
- - Missing `exit 0` for success path
293
- - Using exit code 1 for blocking (should be 2)
294
- - No exit code at end of script
295
-
296
- ### 4. Hook Type Appropriateness (HIGH Certainty)
297
-
298
- **Check:** Hook type matches event
299
-
300
- **Flag:**
301
- - Prompt hooks used for events other than Stop/SubagentStop
302
- - Missing type specification
303
-
304
- ### 5. Lifecycle Event Appropriateness (MEDIUM Certainty)
305
-
306
- | Event | Appropriate Use Cases |
307
- |-------|----------------------|
308
- | `PreToolUse` | Security validation, command blocking, input modification |
309
- | `PostToolUse` | Formatting, logging, notifications |
310
- | `Stop` | Completion checks, cleanup, summary |
311
- | `SubagentStop` | Workflow orchestration, result validation |
312
- | `SessionStart` | Environment setup, initialization |
313
-
314
- **Flag:**
315
- - PostToolUse hooks trying to block actions (too late)
316
- - PreToolUse hooks doing heavy processing (should be fast)
317
- - Prompt hooks on unsupported events
318
-
319
- ### 6. Timeout Configuration (MEDIUM Certainty)
320
-
321
- **Guidelines:**
322
- - Default: 30 seconds for command hooks
323
- - Network operations: Always set explicit timeout
324
- - External service calls: Set timeout based on expected latency
325
-
326
- **Flag:**
327
- - No timeout for network operations
328
- - Timeout missing for external service calls
329
- - Unreasonably long timeouts (>60s without justification)
330
-
331
- ### 7. Output Format (MEDIUM Certainty)
332
-
333
- **PreToolUse Output Fields:**
334
- - `permissionDecision`: allow, deny, or ask
335
- - `permissionDecisionReason`: Explanation for decision
336
- - `updatedInput`: Modified tool input (optional)
337
- - `additionalContext`: Context for Claude (optional)
338
-
339
- **Flag:**
340
- - Invalid permissionDecision values
341
- - Missing reason for deny decisions
342
- - Malformed JSON output
343
-
344
- ### 8. Matcher Patterns (MEDIUM Certainty)
345
-
346
- **Check:** Matcher syntax is valid
347
-
348
- **Flag:**
349
- - Invalid regex patterns
350
- - Too broad matchers (`*` without justification)
351
- - Matcher on events that don't support it (Stop, SubagentStop)
352
-
353
- ### 9. Anti-Patterns (LOW Certainty)
354
-
355
- - Complex logic in hooks (should be simple and fast)
356
- - Missing documentation/comments
357
- - Hardcoded paths (should use `$CLAUDE_PROJECT_DIR`)
358
- - Network calls without error handling
359
- - Secrets/credentials in hook scripts
360
-
361
- ---
362
-
363
- ## Auto-Fix Implementations
364
-
365
- ### 1. Missing safety header
366
- ```bash
367
- #!/usr/bin/env bash
368
- set -euo pipefail
369
- ```
370
-
371
- ### 2. Missing exit code
372
- Add `exit 0` at end of script
373
-
374
- ### 3. Missing frontmatter fields
375
- ```yaml
376
- ---
377
- name: hook-name
378
- description: Hook description
379
- timeout: 30
380
- ---
381
- ```
382
-
383
- ### 4. Wrong blocking exit code
384
- Replace `exit 1` with `exit 2` for blocking errors
385
-
386
- ---
387
-
388
- ## Output Format
389
-
390
- ```markdown
391
- ## Hook Analysis: {hook-name}
392
-
393
- **File**: {path}
394
- **Type**: {command|prompt|config}
395
- **Event**: {PreToolUse|PostToolUse|Stop|...}
396
-
397
- ### Summary
398
- - HIGH: {count} issues
399
- - MEDIUM: {count} issues
400
-
401
- ### Frontmatter Issues ({n})
402
- | Issue | Fix | Certainty |
403
-
404
- ### Safety Issues ({n})
405
- | Issue | Fix | Certainty |
406
-
407
- ### Exit Code Issues ({n})
408
- | Issue | Fix | Certainty |
409
-
410
- ### Lifecycle Issues ({n})
411
- | Issue | Fix | Certainty |
412
-
413
- ### Output Format Issues ({n})
414
- | Issue | Fix | Certainty |
415
- ```
416
-
417
- ---
418
-
419
- ## Pattern Statistics
420
-
421
- | Category | Patterns | Auto-Fixable |
422
- |----------|----------|--------------|
423
- | Frontmatter | 3 | 2 |
424
- | Safety | 6 | 2 |
425
- | Exit Code | 3 | 2 |
426
- | Hook Type | 2 | 0 |
427
- | Lifecycle | 5 | 0 |
428
- | Timeout | 3 | 0 |
429
- | Output | 3 | 0 |
430
- | Matcher | 3 | 0 |
431
- | Anti-Pattern | 5 | 0 |
432
- | **Total** | **33** | **6** |
433
-
434
- ---
435
-
436
- <examples>
437
- ### Example: Missing Safety Header
438
-
439
- <bad_example>
440
- ```bash
441
- #!/usr/bin/env bash
442
- cmd=$(jq -r '.tool_input.command // ""')
443
- ```
444
- **Why it's bad**: Missing `set -euo pipefail` means errors may silently pass.
445
- </bad_example>
446
-
447
- <good_example>
448
- ```bash
449
- #!/usr/bin/env bash
450
- set -euo pipefail
451
- cmd=$(jq -r '.tool_input.command // ""')
452
- ```
453
- **Why it's good**: Fails fast on errors, unset variables, and pipe failures.
454
- </good_example>
455
-
456
- ### Example: Wrong Exit Code for Blocking
457
-
458
- <bad_example>
459
- ```bash
460
- if [[ "$cmd" == *"rm -rf"* ]]; then
461
- echo "Blocked dangerous command" >&2
462
- exit 1 # Wrong!
463
- fi
464
- ```
465
- **Why it's bad**: Exit code 1 is non-blocking. Action will still proceed.
466
- </bad_example>
467
-
468
- <good_example>
469
- ```bash
470
- if [[ "$cmd" == *"rm -rf"* ]]; then
471
- echo '{"decision": "block", "reason": "Dangerous command"}' >&2
472
- exit 2 # Correct blocking exit code
473
- fi
474
- ```
475
- **Why it's good**: Exit code 2 blocks the action. JSON output provides context.
476
- </good_example>
477
-
478
- ### Example: Prompt Hook on Wrong Event
479
-
480
- <bad_example>
481
- ```json
482
- {
483
- "hooks": {
484
- "PreToolUse": [
485
- {
486
- "hooks": [{ "type": "prompt", "prompt": "Is this safe?" }]
487
- }
488
- ]
489
- }
490
- }
491
- ```
492
- **Why it's bad**: Prompt hooks only work for Stop and SubagentStop events.
493
- </bad_example>
494
-
495
- <good_example>
496
- ```json
497
- {
498
- "hooks": {
499
- "PreToolUse": [
500
- {
501
- "hooks": [{ "type": "command", "command": "./validate.sh" }]
502
- }
503
- ]
504
- }
505
- }
506
- ```
507
- **Why it's good**: Command hooks work for all events.
508
- </good_example>
509
-
510
- ### Example: Dangerous Command Pattern
511
-
512
- <bad_example>
513
- ```bash
514
- if echo "$cmd" | grep -q 'rm'; then
515
- exit 2
516
- fi
517
- ```
518
- **Why it's bad**: Too broad - blocks legitimate `rm file.tmp`.
519
- </bad_example>
520
-
521
- <good_example>
522
- ```bash
523
- if echo "$cmd" | grep -qE 'rm\s+(-rf|-fr)\s+/'; then
524
- exit 2
525
- fi
526
- ```
527
- **Why it's good**: Specific pattern targets actual dangerous commands.
528
- </good_example>
529
-
530
- ### Example: Hardcoded Path
531
-
532
- <bad_example>
533
- ```bash
534
- log_file="/home/user/project/.claude/commands.log"
535
- ```
536
- **Why it's bad**: Hardcoded path breaks on other machines.
537
- </bad_example>
538
-
539
- <good_example>
540
- ```bash
541
- log_file="$CLAUDE_PROJECT_DIR/.claude/commands.log"
542
- ```
543
- **Why it's good**: Uses environment variable for portability.
544
- </good_example>
545
- </examples>
546
-
547
- ---
548
-
549
- ## Constraints
550
-
551
- - Only apply auto-fixes for HIGH certainty issues
552
- - Be cautious about security patterns - false negatives worse than false positives
553
- - Never remove content, only suggest improvements
554
- - Validate against embedded knowledge reference above