Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .claude/context/PROJECT.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Replace the sections below with information about your project.

---

## Project: azlin
## Project: task-unnamed-1774842804

## Overview

Expand All @@ -29,7 +29,6 @@ Replace the sections below with information about your project.
- **Language**: Python
- **Language**: JavaScript/TypeScript
- **Language**: Rust
- **Language**: Go
- **Framework**: [Main framework if applicable]
- **Database**: [Database system if applicable]

Expand Down
47 changes: 47 additions & 0 deletions .github/hooks/amplihack-hooks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"version": 1,
"hooks": {
"sessionStart": [
{
"type": "command",
"bash": ".github/hooks/session-start",
"timeoutSec": 30
}
],
"sessionEnd": [
{
"type": "command",
"bash": ".github/hooks/session-stop",
"timeoutSec": 30
}
],
"userPromptSubmitted": [
{
"type": "command",
"bash": ".github/hooks/user-prompt-submit",
"timeoutSec": 10
}
],
"preToolUse": [
{
"type": "command",
"bash": ".github/hooks/pre-tool-use",
"timeoutSec": 15
}
],
"postToolUse": [
{
"type": "command",
"bash": ".github/hooks/post-tool-use",
"timeoutSec": 10
}
],
"errorOccurred": [
{
"type": "command",
"bash": ".github/hooks/error-occurred",
"timeoutSec": 10
}
]
}
}
21 changes: 21 additions & 0 deletions .github/hooks/error-occurred
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Copilot hook: error-occurred
# Logs error to runtime log. No dedicated Python hook exists for this event;
# error_protocol.py is a utility module, not a hook entry point.

AMPLIHACK_HOOKS="$HOME/.amplihack/.claude/tools/amplihack/hooks"
LOG_DIR="$HOME/.amplihack/.claude/runtime/logs"

# If a dedicated error_occurred.py hook exists, use it
if [[ -f "${AMPLIHACK_HOOKS}/error_occurred.py" ]]; then
python3 "${AMPLIHACK_HOOKS}/error_occurred.py" "$@"
elif REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null)" && [[ -f "${REPO_ROOT}/.claude/tools/amplihack/hooks/error_occurred.py" ]]; then
python3 "${REPO_ROOT}/.claude/tools/amplihack/hooks/error_occurred.py" "$@"
else
# Fallback: log the error from stdin
mkdir -p "$LOG_DIR"
INPUT=$(cat)
ERROR_MSG=$(echo "$INPUT" | python3 -c "import sys,json; print(json.load(sys.stdin).get('error',{}).get('message','unknown'))" 2>/dev/null || echo "unknown")
echo "$(date -Iseconds): ERROR - $ERROR_MSG" >> "${LOG_DIR}/errors.log"
echo "{}"
fi
12 changes: 12 additions & 0 deletions .github/hooks/post-tool-use
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# Copilot hook wrapper - generated by amplihack
HOOK="post_tool_use.py"
AMPLIHACK_HOOKS="$HOME/.amplihack/.claude/tools/amplihack/hooks"

if [[ -f "${AMPLIHACK_HOOKS}/${HOOK}" ]]; then
exec python3 "${AMPLIHACK_HOOKS}/${HOOK}" "$@"
elif REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null)" && [[ -f "${REPO_ROOT}/.claude/tools/amplihack/hooks/${HOOK}" ]]; then
exec python3 "${REPO_ROOT}/.claude/tools/amplihack/hooks/${HOOK}" "$@"
else
echo "{}"
fi
73 changes: 73 additions & 0 deletions .github/hooks/pre-tool-use
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/usr/bin/env bash
# Copilot hook wrapper - generated by amplihack (python engine)
# Aggregates amplihack and XPIA pre-tool validation into one JSON response
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null)" || REPO_ROOT=""
INPUT=$(cat)

AMPLIHACK_OUTPUT="{}"
AMPLIHACK_HOOKS="$HOME/.amplihack/.claude/tools/amplihack/hooks"
if [[ -f "${AMPLIHACK_HOOKS}/pre_tool_use.py" ]]; then
AMPLIHACK_OUTPUT=$(echo "$INPUT" | python3 "${AMPLIHACK_HOOKS}/pre_tool_use.py" "$@" 2>/dev/null || printf '{}')
elif [[ -n "$REPO_ROOT" ]] && [[ -f "${REPO_ROOT}/.claude/tools/amplihack/hooks/pre_tool_use.py" ]]; then
AMPLIHACK_OUTPUT=$(echo "$INPUT" | python3 "${REPO_ROOT}/.claude/tools/amplihack/hooks/pre_tool_use.py" "$@" 2>/dev/null || printf '{}')
fi

XPIA_OUTPUT="{}"
XPIA_HOOKS="$HOME/.amplihack/.claude/tools/xpia/hooks"
if [[ -f "${XPIA_HOOKS}/pre_tool_use.py" ]]; then
XPIA_OUTPUT=$(echo "$INPUT" | python3 "${XPIA_HOOKS}/pre_tool_use.py" "$@" 2>/dev/null || printf '{}')
elif [[ -n "$REPO_ROOT" ]] && [[ -f "${REPO_ROOT}/.claude/tools/xpia/hooks/pre_tool_use.py" ]]; then
XPIA_OUTPUT=$(echo "$INPUT" | python3 "${REPO_ROOT}/.claude/tools/xpia/hooks/pre_tool_use.py" "$@" 2>/dev/null || printf '{}')
fi

python3 - "$AMPLIHACK_OUTPUT" "$XPIA_OUTPUT" <<'PY'
import json
import sys


def parse_payload(raw: str) -> dict:
raw = raw.strip()
if not raw:
return {}
for line in reversed(raw.splitlines()):
line = line.strip()
if not line:
continue
try:
value = json.loads(line)
except json.JSONDecodeError:
continue
if isinstance(value, dict):
return value
return {}


amplihack = parse_payload(sys.argv[1])
xpia = parse_payload(sys.argv[2])

permission = xpia.get("permissionDecision")
if permission in {"allow", "deny", "ask"}:
print(json.dumps(xpia))
raise SystemExit(0)

permission = amplihack.get("permissionDecision")
if permission in {"allow", "deny", "ask"}:
print(json.dumps(amplihack))
raise SystemExit(0)

if amplihack.get("block"):
print(
json.dumps(
{
"permissionDecision": "deny",
"message": amplihack.get(
"message",
"Blocked by amplihack pre-tool-use hook.",
),
}
)
)
raise SystemExit(0)

print("{}")
PY
12 changes: 12 additions & 0 deletions .github/hooks/session-start
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env bash
# Copilot hook wrapper - generated by amplihack
HOOK="session_start.py"
AMPLIHACK_HOOKS="$HOME/.amplihack/.claude/tools/amplihack/hooks"

if [[ -f "${AMPLIHACK_HOOKS}/${HOOK}" ]]; then
exec python3 "${AMPLIHACK_HOOKS}/${HOOK}" "$@"
elif REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null)" && [[ -f "${REPO_ROOT}/.claude/tools/amplihack/hooks/${HOOK}" ]]; then
exec python3 "${REPO_ROOT}/.claude/tools/amplihack/hooks/${HOOK}" "$@"
else
echo "{}"
fi
18 changes: 18 additions & 0 deletions .github/hooks/session-stop
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Copilot hook wrapper - generated by amplihack
# Runs multiple hook scripts for this event
AMPLIHACK_HOOKS="$HOME/.amplihack/.claude/tools/amplihack/hooks"
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null)" || REPO_ROOT=""
INPUT=$(cat)

if [[ -f "${AMPLIHACK_HOOKS}/stop.py" ]]; then
echo "$INPUT" | python3 "${AMPLIHACK_HOOKS}/stop.py" "$@" 2>/dev/null || true
elif [[ -n "$REPO_ROOT" ]] && [[ -f "${REPO_ROOT}/.claude/tools/amplihack/hooks/stop.py" ]]; then
echo "$INPUT" | python3 "${REPO_ROOT}/.claude/tools/amplihack/hooks/stop.py" "$@" 2>/dev/null || true
fi

if [[ -f "${AMPLIHACK_HOOKS}/session_stop.py" ]]; then
echo "$INPUT" | python3 "${AMPLIHACK_HOOKS}/session_stop.py" "$@" 2>/dev/null || true
elif [[ -n "$REPO_ROOT" ]] && [[ -f "${REPO_ROOT}/.claude/tools/amplihack/hooks/session_stop.py" ]]; then
echo "$INPUT" | python3 "${REPO_ROOT}/.claude/tools/amplihack/hooks/session_stop.py" "$@" 2>/dev/null || true
fi
18 changes: 18 additions & 0 deletions .github/hooks/user-prompt-submit
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash
# Copilot hook wrapper - generated by amplihack
# Runs multiple hook scripts for this event
AMPLIHACK_HOOKS="$HOME/.amplihack/.claude/tools/amplihack/hooks"
REPO_ROOT="$(git rev-parse --show-toplevel 2>/dev/null)" || REPO_ROOT=""
INPUT=$(cat)

if [[ -f "${AMPLIHACK_HOOKS}/user_prompt_submit.py" ]]; then
echo "$INPUT" | python3 "${AMPLIHACK_HOOKS}/user_prompt_submit.py" "$@" 2>/dev/null || true
elif [[ -n "$REPO_ROOT" ]] && [[ -f "${REPO_ROOT}/.claude/tools/amplihack/hooks/user_prompt_submit.py" ]]; then
echo "$INPUT" | python3 "${REPO_ROOT}/.claude/tools/amplihack/hooks/user_prompt_submit.py" "$@" 2>/dev/null || true
fi

if [[ -f "${AMPLIHACK_HOOKS}/workflow_classification_reminder.py" ]]; then
echo "$INPUT" | python3 "${AMPLIHACK_HOOKS}/workflow_classification_reminder.py" "$@" 2>/dev/null || true
elif [[ -n "$REPO_ROOT" ]] && [[ -f "${REPO_ROOT}/.claude/tools/amplihack/hooks/workflow_classification_reminder.py" ]]; then
echo "$INPUT" | python3 "${REPO_ROOT}/.claude/tools/amplihack/hooks/workflow_classification_reminder.py" "$@" 2>/dev/null || true
fi
Loading
Loading