Skip to content
Merged
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
80 changes: 64 additions & 16 deletions aissist-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,21 +360,9 @@ See [skills/aissist-cli/SKILL.md](./skills/aissist-cli/SKILL.md) for complete do

## Hooks

The plugin includes hooks that enhance Claude Code sessions with useful context.
The plugin includes hooks that enhance Claude Code sessions with useful context and intelligent suggestions.

### DateTime Context Hook

Automatically injects the current date and time into every Claude Code session. This helps Claude understand:
- Relative time references ("today", "this week", "due tomorrow")
- Deadline urgency
- Historical context for entries

The hook triggers on every `UserPromptSubmit` event and outputs:
```
Current date and time: 2025-12-07 10:15:30 CET
```

### Context Injection Hook
### Context Injection Hook (SessionStart)

Injects active goals and recent history at session start, giving Claude immediate awareness of your current priorities. **Disabled by default** to avoid noise.

Expand Down Expand Up @@ -405,6 +393,63 @@ Recent history (last 3 days):
- Provides continuity between sessions
- Helps with deadline awareness and planning

### Prompt Hints Hook (UserPromptSubmit)

Provides datetime context and intelligent command suggestions based on keywords in your prompts. This enhanced hook replaces the simple datetime hook.

**Features:**
- Injects current date and time for temporal awareness
- Detects keywords and suggests relevant aissist commands

**Keyword Detection:**

| User Says | Suggestion |
|-----------|------------|
| "how did I", "previously", "last time" | `/aissist:recall` |
| "my goal", "progress", "deadline" | `/aissist:chat` |
| numbered items, "todo:", "tasks:" | `/aissist:todo` |
| "summary", "report", "what have I done" | `/aissist:report` |

**Example Output:**
```
Current date and time: 2025-12-07 10:15:30 CET
Hint: Use /aissist:recall to search past work
```

### Post-Edit Hook (PostToolUse: Edit/Write)

Reminds you to log work after file modifications. Triggers after Edit or Write tool operations.

**Example Output:**
```
File modified: auth.ts - consider /aissist:log if this completes a task
```

**Benefits:**
- Contextual logging reminders at the right moment
- Helps build consistent history of work
- Non-intrusive - only shows after actual file changes

### Post-Bash Hook (PostToolUse: Bash)

Detects significant shell operations and suggests logging. Triggers after Bash tool operations.

**Detected Operations:**
- Git commits
- Test runs (pytest, npm test, cargo test, etc.)
- Build commands (npm run build, cargo build, make, etc.)
- Deployment commands

**Example Output:**
```
Git commit detected - use /aissist:log to record this work
```

**Benefits:**
- Automatically prompts logging after meaningful milestones
- Catches commits, tests, builds, and deployments
- Silent for routine commands (no noise)

## Directory Structure

```
Expand All @@ -418,8 +463,11 @@ aissist-plugin/
│ ├── recall.md # /aissist:recall
│ └── report.md # /aissist:report
├── hooks/ # Claude Code hooks
│ ├── add-datetime.sh # Injects current datetime
│ └── inject-context.sh # Injects goals/history (configurable)
│ ├── add-datetime.sh # Simple datetime (legacy, kept for compatibility)
│ ├── inject-context.sh # Injects goals/history at session start
│ ├── prompt-hints.sh # Datetime + keyword suggestions (UserPromptSubmit)
│ ├── post-edit.sh # Log reminder after file edits (PostToolUse)
│ └── post-bash.sh # Log reminder after git/test/build (PostToolUse)
├── settings.json # Hook configuration
├── skills/ # Agent skills
│ └── aissist-cli/
Expand Down
43 changes: 43 additions & 0 deletions aissist-plugin/hooks/post-bash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
# PostToolUse hook for Bash tool
# Detects git commits and other significant operations

# Check for jq dependency - exit silently if not available
if ! command -v jq &> /dev/null; then
exit 0
fi

# Read the hook input from stdin
INPUT=$(cat)

# Extract the command that was run
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty' 2>/dev/null)

# Exit if no command extracted
[ -z "$COMMAND" ] && exit 0

# Check for git commit (word boundaries to avoid false positives)
if grep -qE '\bgit\s+commit\b' <<< "$COMMAND"; then
echo "Git commit detected - use /aissist:log to record this work"
exit 0
fi

# Check for test runs (word boundaries)
if grep -qE '\b(pytest|npm\s+test|yarn\s+test|cargo\s+test|go\s+test|make\s+test)\b' <<< "$COMMAND"; then
echo "Tests completed - consider /aissist:log if this concludes a task"
exit 0
fi

# Check for build commands (word boundaries)
if grep -qE '\b(npm|yarn|pnpm)\s+(run\s+)?build\b|\bcargo\s+build\b|\bgo\s+build\b|\bmake\b' <<< "$COMMAND"; then
echo "Build completed - consider /aissist:log if this concludes a task"
exit 0
fi

# Check for deployment commands (word boundaries)
if grep -qE '\b(deploy|publish|release)\b' <<< "$COMMAND"; then
echo "Deployment detected - use /aissist:log to record this milestone"
exit 0
fi

# No significant command detected - silent
22 changes: 22 additions & 0 deletions aissist-plugin/hooks/post-edit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# PostToolUse hook for Edit/Write tools
# Reminds to log work after file modifications

# Check for jq dependency - exit silently if not available
if ! command -v jq &> /dev/null; then
echo "File modified - consider /aissist:log if this completes a task"
exit 0
fi

# Read the hook input from stdin (contains tool info)
INPUT=$(cat)

# Extract file path if available (handles different tool implementations)
FILE=$(echo "$INPUT" | jq -r '.tool_input.file_path // .tool_input.path // .tool_input.target // empty' 2>/dev/null)

if [ -n "$FILE" ]; then
BASENAME=$(basename "$FILE")
echo "File modified: $BASENAME - consider /aissist:log if this completes a task"
else
echo "File modified - consider /aissist:log if this completes a task"
fi
46 changes: 46 additions & 0 deletions aissist-plugin/hooks/prompt-hints.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/bin/bash
# Hook script for UserPromptSubmit - provides datetime and keyword-based aissist suggestions
# Replaces add-datetime.sh with enhanced functionality

# Output datetime first (always works, no dependencies)
echo "Current date and time: $(date '+%Y-%m-%d %H:%M:%S %Z')"

# Check for jq dependency - exit silently if not available
if ! command -v jq &> /dev/null; then
exit 0
fi

# Read the hook input from stdin
INPUT=$(cat)

# Extract user prompt (keep original case, use grep -i for matching)
PROMPT=$(echo "$INPUT" | jq -r '.user_prompt // empty' 2>/dev/null)

# Skip keyword detection if no prompt
[ -z "$PROMPT" ] && exit 0

# Check for recall triggers - asking about past work (case insensitive)
if grep -iqE '(how did i|why did i|previously|last time|before|earlier|remember when|what was|did we)' <<< "$PROMPT"; then
echo "Hint: Use /aissist:recall to search past work"
exit 0
fi

# Check for goal/progress triggers
if grep -iqE '(my goal|my progress|deadline|what.*(working on|should.*do)|priority|milestone)' <<< "$PROMPT"; then
echo "Hint: Use /aissist:chat to discuss goals and progress"
exit 0
fi

# Check for task list triggers (numbered items or explicit list language)
if grep -iqE '(^[0-9]+\.|tasks:|todo:|need to:|things to do|checklist|items:)' <<< "$PROMPT"; then
echo "Hint: Use /aissist:todo to extract and track tasks"
exit 0
fi

# Check for report triggers
if grep -iqE '(summary of|report|what.*done|accomplishment|weekly|standup)' <<< "$PROMPT"; then
echo "Hint: Use /aissist:report to generate accomplishment summary"
exit 0
fi

# No specific trigger - silent (datetime already shown)
28 changes: 24 additions & 4 deletions aissist-plugin/settings.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,43 @@
{
"hooks": {
"UserPromptSubmit": [
"SessionStart": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "bash $CLAUDE_PROJECT_DIR/hooks/add-datetime.sh"
"command": "bash $CLAUDE_PROJECT_DIR/hooks/inject-context.sh"
}
]
}
],
"SessionStart": [
"UserPromptSubmit": [
{
"matcher": "*",
"hooks": [
{
"type": "command",
"command": "bash $CLAUDE_PROJECT_DIR/hooks/inject-context.sh"
"command": "bash $CLAUDE_PROJECT_DIR/hooks/prompt-hints.sh"
}
]
}
],
"PostToolUse": [
{
"matcher": "Edit|Write",
"hooks": [
{
"type": "command",
"command": "bash $CLAUDE_PROJECT_DIR/hooks/post-edit.sh"
}
]
},
{
"matcher": "Bash",
"hooks": [
{
"type": "command",
"command": "bash $CLAUDE_PROJECT_DIR/hooks/post-bash.sh"
}
]
}
Expand Down
Loading