mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-10 03:14:32 +08:00
Replace external inject-spec.py hook with built-in zero-config skill detection in codeagent-wrapper. The system auto-detects project type from fingerprint files (go.mod, package.json, etc.), maps to installed skills, and injects SKILL.md content directly into sub-agent prompts. Key changes: - Add DetectProjectSkills/ResolveSkillContent in executor/prompt.go - Add Skills field to TaskSpec with parallel config parsing - Add --skills CLI flag for explicit override - Update /do SKILL.md Phase 4 with per-task skill examples - Remove on-stop.py global hook (not needed) - Replace inject-spec.py with no-op (detection now internal) - Add 20 unit tests covering detection, resolution, budget, security Security: path traversal protection via validSkillName regex, 16K char budget with tag overhead accounting, CRLF normalization. Generated with SWE-Agent.ai Co-Authored-By: SWE-Agent.ai <noreply@swe-agent.ai>
31 lines
536 B
Python
31 lines
536 B
Python
#!/usr/bin/env python3
|
|
"""
|
|
Pre-Bash Hook - Block dangerous commands before execution.
|
|
"""
|
|
|
|
import sys
|
|
|
|
DANGEROUS_PATTERNS = [
|
|
'rm -rf /',
|
|
'rm -rf ~',
|
|
'dd if=',
|
|
':(){:|:&};:',
|
|
'mkfs.',
|
|
'> /dev/sd',
|
|
]
|
|
|
|
|
|
def main():
|
|
command = sys.argv[1] if len(sys.argv) > 1 else ''
|
|
|
|
for pattern in DANGEROUS_PATTERNS:
|
|
if pattern in command:
|
|
print(f"[CWF] BLOCKED: Dangerous command detected: {pattern}", file=sys.stderr)
|
|
sys.exit(1)
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|