Initial commit: Flutter 无书应用项目
This commit is contained in:
16
.trae/skills/planning-with-files/.gemini/hooks/after-tool.sh
Normal file
16
.trae/skills/planning-with-files/.gemini/hooks/after-tool.sh
Normal file
@@ -0,0 +1,16 @@
|
||||
#!/bin/bash
|
||||
# planning-with-files: AfterTool hook for Gemini CLI
|
||||
# Reminds the agent to update progress after file writes.
|
||||
# Reads stdin JSON, outputs JSON to stdout.
|
||||
|
||||
INPUT=$(cat)
|
||||
|
||||
PLAN_FILE="task_plan.md"
|
||||
|
||||
if [ ! -f "$PLAN_FILE" ]; then
|
||||
echo '{}'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo '{"additionalContext":"[planning-with-files] Update progress.md with what you just did. If a phase is now complete, update task_plan.md status."}'
|
||||
exit 0
|
||||
@@ -0,0 +1,27 @@
|
||||
#!/bin/bash
|
||||
# planning-with-files: BeforeModel hook for Gemini CLI
|
||||
# Injects plan awareness before every model call.
|
||||
# This is UNIQUE to Gemini CLI — no other IDE has a BeforeModel event.
|
||||
# Reads stdin JSON, outputs JSON to stdout.
|
||||
|
||||
INPUT=$(cat)
|
||||
|
||||
PLAN_FILE="task_plan.md"
|
||||
|
||||
if [ ! -f "$PLAN_FILE" ]; then
|
||||
echo '{}'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Only inject a lightweight reminder (not the full plan — that's BeforeTool's job)
|
||||
CURRENT_PHASE=$(grep -m1 "^## Current Phase" "$PLAN_FILE" 2>/dev/null || grep -m1 "in_progress" "$PLAN_FILE" 2>/dev/null || echo "")
|
||||
|
||||
if [ -n "$CURRENT_PHASE" ]; then
|
||||
PYTHON=$(command -v python3 || command -v python)
|
||||
ESCAPED=$($PYTHON -c "import sys,json; print(json.dumps(sys.stdin.read(), ensure_ascii=False))" <<< "[planning-with-files] Current: $CURRENT_PHASE" 2>/dev/null || echo "\"\"")
|
||||
echo "{\"additionalContext\":$ESCAPED}"
|
||||
else
|
||||
echo '{}'
|
||||
fi
|
||||
|
||||
exit 0
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
# planning-with-files: BeforeTool hook for Gemini CLI
|
||||
# Reads the first 30 lines of task_plan.md before tool use.
|
||||
# Receives JSON on stdin, must output ONLY JSON to stdout.
|
||||
|
||||
INPUT=$(cat)
|
||||
|
||||
PLAN_FILE="task_plan.md"
|
||||
|
||||
if [ ! -f "$PLAN_FILE" ]; then
|
||||
echo '{}'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
CONTEXT=$(head -30 "$PLAN_FILE" 2>/dev/null || echo "")
|
||||
|
||||
if [ -z "$CONTEXT" ]; then
|
||||
echo '{}'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
PYTHON=$(command -v python3 || command -v python)
|
||||
if [ -n "$PYTHON" ]; then
|
||||
ESCAPED=$($PYTHON -c "import sys,json; print(json.dumps(sys.stdin.read(), ensure_ascii=False))" <<< "$CONTEXT" 2>/dev/null)
|
||||
if [ -n "$ESCAPED" ] && [ "$ESCAPED" != "\"\"" ]; then
|
||||
echo "{\"systemMessage\":$ESCAPED}"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
echo '{}'
|
||||
exit 0
|
||||
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
# planning-with-files: SessionEnd hook for Gemini CLI
|
||||
# Checks all phases are complete before session ends.
|
||||
# Receives JSON on stdin, must output ONLY JSON to stdout.
|
||||
|
||||
INPUT=$(cat)
|
||||
|
||||
PLAN_FILE="task_plan.md"
|
||||
SCRIPT_DIR="${GEMINI_PROJECT_DIR:-.}/.gemini/skills/planning-with-files/scripts"
|
||||
|
||||
if [ ! -f "$PLAN_FILE" ]; then
|
||||
echo '{}'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Run check-complete script
|
||||
if [ -f "$SCRIPT_DIR/check-complete.sh" ]; then
|
||||
RESULT=$(sh "$SCRIPT_DIR/check-complete.sh" 2>/dev/null || true)
|
||||
if [ -n "$RESULT" ]; then
|
||||
PYTHON=$(command -v python3 || command -v python)
|
||||
ESCAPED=$($PYTHON -c "import sys,json; print(json.dumps(sys.stdin.read(), ensure_ascii=False))" <<< "$RESULT" 2>/dev/null || echo "\"\"")
|
||||
echo "{\"systemMessage\":$ESCAPED}"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
echo '{}'
|
||||
exit 0
|
||||
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
# planning-with-files: SessionStart hook for Gemini CLI
|
||||
# Checks for previous session and recovers context.
|
||||
# Receives JSON on stdin, must output ONLY JSON to stdout.
|
||||
# Stderr is for logging only.
|
||||
|
||||
INPUT=$(cat)
|
||||
|
||||
PLAN_FILE="task_plan.md"
|
||||
SCRIPT_DIR="${GEMINI_PROJECT_DIR:-.}/.gemini/skills/planning-with-files/scripts"
|
||||
|
||||
# If no plan file, nothing to recover
|
||||
if [ ! -f "$PLAN_FILE" ]; then
|
||||
echo '{}'
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Try session catchup
|
||||
PYTHON=$(command -v python3 || command -v python)
|
||||
CATCHUP=""
|
||||
if [ -n "$PYTHON" ] && [ -f "$SCRIPT_DIR/session-catchup.py" ]; then
|
||||
CATCHUP=$($PYTHON "$SCRIPT_DIR/session-catchup.py" "$(pwd)" 2>/dev/null || true)
|
||||
fi
|
||||
|
||||
if [ -n "$CATCHUP" ]; then
|
||||
ESCAPED=$($PYTHON -c "import sys,json; print(json.dumps(sys.stdin.read(), ensure_ascii=False))" <<< "$CATCHUP" 2>/dev/null || echo "\"[planning-with-files] Session recovery data available. Read task_plan.md, progress.md, and findings.md.\"")
|
||||
echo "{\"hookSpecificOutput\":{\"additionalContext\":$ESCAPED}}"
|
||||
else
|
||||
echo '{"hookSpecificOutput":{"additionalContext":"[planning-with-files] Active plan detected. Read task_plan.md, progress.md, and findings.md before proceeding."}}'
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Reference in New Issue
Block a user