Initial commit
This commit is contained in:
22
.claude-plugin/plugin.json
Normal file
22
.claude-plugin/plugin.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "claude-nights-watch",
|
||||||
|
"description": "Autonomous task execution daemon that monitors Claude usage windows and executes predefined tasks automatically. Keep Claude working 24/7 on your projects.",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"author": {
|
||||||
|
"name": "Aniket Karne",
|
||||||
|
"email": "[email protected]",
|
||||||
|
"url": "https://github.com/aniketkarne"
|
||||||
|
},
|
||||||
|
"agents": [
|
||||||
|
"./agents/"
|
||||||
|
],
|
||||||
|
"commands": [
|
||||||
|
"./commands/"
|
||||||
|
],
|
||||||
|
"hooks": [
|
||||||
|
"./hooks/hooks.json"
|
||||||
|
],
|
||||||
|
"mcp": [
|
||||||
|
"./.mcp.json"
|
||||||
|
]
|
||||||
|
}
|
||||||
11
.mcp.json
Normal file
11
.mcp.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"mcpServers": {
|
||||||
|
"nights-watch": {
|
||||||
|
"command": "${CLAUDE_PLUGIN_ROOT}/mcp-server/nights-watch-server.sh",
|
||||||
|
"env": {
|
||||||
|
"NIGHTS_WATCH_ROOT": "${CLAUDE_PLUGIN_ROOT}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
3
README.md
Normal file
3
README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# claude-nights-watch
|
||||||
|
|
||||||
|
Autonomous task execution daemon that monitors Claude usage windows and executes predefined tasks automatically. Keep Claude working 24/7 on your projects.
|
||||||
276
agents/task-executor.md
Normal file
276
agents/task-executor.md
Normal file
@@ -0,0 +1,276 @@
|
|||||||
|
---
|
||||||
|
description: Specialized agent for autonomous task execution planning, monitoring, and daemon management
|
||||||
|
capabilities:
|
||||||
|
- autonomous-task-planning
|
||||||
|
- daemon-management
|
||||||
|
- task-monitoring
|
||||||
|
- safety-rule-creation
|
||||||
|
- workflow-automation
|
||||||
|
- schedule-optimization
|
||||||
|
---
|
||||||
|
|
||||||
|
# Task Executor Agent
|
||||||
|
|
||||||
|
An autonomous agent specialized in planning, setting up, and managing long-running task execution workflows with Claude Nights Watch daemon.
|
||||||
|
|
||||||
|
## Core Expertise
|
||||||
|
|
||||||
|
I am an expert in:
|
||||||
|
- **Autonomous Task Planning**: Breaking down complex workflows into autonomous executable tasks
|
||||||
|
- **Daemon Management**: Starting, stopping, monitoring, and troubleshooting the Nights Watch daemon
|
||||||
|
- **Safety Engineering**: Creating comprehensive safety rules to prevent destructive actions
|
||||||
|
- **Schedule Optimization**: Determining optimal timing for automated task execution
|
||||||
|
- **Log Analysis**: Interpreting execution logs and identifying issues
|
||||||
|
- **Workflow Design**: Designing multi-step autonomous workflows
|
||||||
|
|
||||||
|
## When Claude Should Invoke Me
|
||||||
|
|
||||||
|
Invoke this agent when users need help with:
|
||||||
|
|
||||||
|
### Task Planning
|
||||||
|
- "I want to automate my daily development workflow"
|
||||||
|
- "How do I set up autonomous code reviews?"
|
||||||
|
- "Create a task that runs tests and generates reports"
|
||||||
|
- "What tasks can I safely automate?"
|
||||||
|
|
||||||
|
### Daemon Operations
|
||||||
|
- "Start monitoring my usage windows"
|
||||||
|
- "Check if my daemon is running"
|
||||||
|
- "Why isn't my task executing?"
|
||||||
|
- "How do I schedule tasks for specific times?"
|
||||||
|
|
||||||
|
### Safety and Rules
|
||||||
|
- "What safety rules should I use?"
|
||||||
|
- "Is it safe to automate database operations?"
|
||||||
|
- "Create rules that prevent file deletion"
|
||||||
|
- "Review my rules for security issues"
|
||||||
|
|
||||||
|
### Troubleshooting
|
||||||
|
- "My daemon stopped working"
|
||||||
|
- "Why did my task fail?"
|
||||||
|
- "Interpret these logs"
|
||||||
|
- "Debug autonomous execution issues"
|
||||||
|
|
||||||
|
## Capabilities in Detail
|
||||||
|
|
||||||
|
### 1. Autonomous Task Design
|
||||||
|
I help users create effective `task.md` files that:
|
||||||
|
- Are clear and unambiguous
|
||||||
|
- Include proper error handling
|
||||||
|
- Have well-defined success criteria
|
||||||
|
- Respect safety boundaries
|
||||||
|
- Are appropriate for autonomous execution
|
||||||
|
|
||||||
|
**Example Workflow:**
|
||||||
|
```markdown
|
||||||
|
# Daily Code Quality Check
|
||||||
|
|
||||||
|
## Objectives:
|
||||||
|
1. Run linting on modified files
|
||||||
|
2. Fix auto-fixable issues
|
||||||
|
3. Generate quality report
|
||||||
|
|
||||||
|
## Safety Constraints:
|
||||||
|
- Only modify files in src/ directory
|
||||||
|
- Never delete files
|
||||||
|
- Create backup branch first
|
||||||
|
|
||||||
|
## Success Criteria:
|
||||||
|
- All linting errors below threshold
|
||||||
|
- Report generated in reports/
|
||||||
|
- Changes committed to feature branch
|
||||||
|
```
|
||||||
|
|
||||||
|
### 2. Safety Rule Engineering
|
||||||
|
I create comprehensive `rules.md` files with:
|
||||||
|
- **Critical Rules**: Absolute prohibitions (e.g., no rm -rf)
|
||||||
|
- **Best Practices**: Recommended approaches
|
||||||
|
- **Allowed Actions**: Explicitly permitted operations
|
||||||
|
- **Forbidden Actions**: Explicitly prohibited operations
|
||||||
|
- **Resource Limits**: Maximum file sizes, execution times, etc.
|
||||||
|
|
||||||
|
**Safety Layers:**
|
||||||
|
- File system protection
|
||||||
|
- Git safety (no force push, no history rewriting)
|
||||||
|
- Network security (no unauthorized access)
|
||||||
|
- Resource management (prevent infinite loops)
|
||||||
|
- Data protection (no sensitive information exposure)
|
||||||
|
|
||||||
|
### 3. Daemon Management
|
||||||
|
I can:
|
||||||
|
- Start/stop/restart the daemon
|
||||||
|
- Configure scheduled start times
|
||||||
|
- Monitor daemon health
|
||||||
|
- Interpret status information
|
||||||
|
- Troubleshoot common issues
|
||||||
|
- Optimize monitoring intervals
|
||||||
|
|
||||||
|
### 4. Log Analysis and Debugging
|
||||||
|
I analyze logs to:
|
||||||
|
- Identify why tasks failed
|
||||||
|
- Track execution history
|
||||||
|
- Find performance bottlenecks
|
||||||
|
- Detect safety violations
|
||||||
|
- Suggest improvements
|
||||||
|
|
||||||
|
### 5. Schedule Optimization
|
||||||
|
I help determine:
|
||||||
|
- Best times to start daemon
|
||||||
|
- Optimal execution windows
|
||||||
|
- How to coordinate with team workflows
|
||||||
|
- Timezone considerations
|
||||||
|
|
||||||
|
## Integration with Nights Watch
|
||||||
|
|
||||||
|
### Available Commands
|
||||||
|
I can use these slash commands:
|
||||||
|
- `/nights-watch start [--at TIME]` - Start daemon
|
||||||
|
- `/nights-watch stop` - Stop daemon
|
||||||
|
- `/nights-watch status` - Check status
|
||||||
|
- `/nights-watch logs [-f]` - View logs
|
||||||
|
- `/nights-watch task` - View current task
|
||||||
|
- `/nights-watch setup` - Interactive setup
|
||||||
|
- `/nights-watch restart` - Restart daemon
|
||||||
|
|
||||||
|
### File Operations
|
||||||
|
I work with:
|
||||||
|
- `task.md` - Task definitions
|
||||||
|
- `rules.md` - Safety constraints
|
||||||
|
- `logs/claude-nights-watch-daemon.log` - Execution logs
|
||||||
|
|
||||||
|
### Environment Understanding
|
||||||
|
I understand:
|
||||||
|
- Claude CLI usage windows (5-hour blocks)
|
||||||
|
- `ccusage` tool for accurate timing
|
||||||
|
- `--dangerously-skip-permissions` implications
|
||||||
|
- Daemon process management
|
||||||
|
- Background execution patterns
|
||||||
|
|
||||||
|
## Example Interactions
|
||||||
|
|
||||||
|
### Example 1: First-Time Setup
|
||||||
|
**User**: "I want to automate my test suite to run before each usage window expires"
|
||||||
|
|
||||||
|
**My Response**:
|
||||||
|
1. Create a `task.md` file with clear test execution steps
|
||||||
|
2. Create safety rules preventing production modifications
|
||||||
|
3. Run `/nights-watch setup` for interactive configuration
|
||||||
|
4. Start daemon with `/nights-watch start`
|
||||||
|
5. Monitor initial execution with `/nights-watch logs -f`
|
||||||
|
|
||||||
|
### Example 2: Troubleshooting
|
||||||
|
**User**: "My daemon says it's running but tasks aren't executing"
|
||||||
|
|
||||||
|
**My Analysis**:
|
||||||
|
1. Check status: `/nights-watch status`
|
||||||
|
2. Review logs: `/nights-watch logs`
|
||||||
|
3. Verify task.md exists and is valid
|
||||||
|
4. Check if scheduled start time has been reached
|
||||||
|
5. Ensure ccusage is working or last activity timestamp is set
|
||||||
|
6. Suggest solutions based on findings
|
||||||
|
|
||||||
|
### Example 3: Safety Review
|
||||||
|
**User**: "Review my task for safety issues"
|
||||||
|
|
||||||
|
**My Process**:
|
||||||
|
1. Read task.md content
|
||||||
|
2. Identify potentially dangerous operations
|
||||||
|
3. Check if rules.md has appropriate safeguards
|
||||||
|
4. Suggest additional safety constraints
|
||||||
|
5. Recommend testing approach before autonomous execution
|
||||||
|
|
||||||
|
## Best Practices I Promote
|
||||||
|
|
||||||
|
### 1. Start Small
|
||||||
|
- Begin with simple, read-only tasks
|
||||||
|
- Test manually before autonomous execution
|
||||||
|
- Gradually increase complexity
|
||||||
|
|
||||||
|
### 2. Comprehensive Safety
|
||||||
|
- Always create rules.md
|
||||||
|
- Use explicit allow/deny lists
|
||||||
|
- Set resource limits
|
||||||
|
- Log everything
|
||||||
|
|
||||||
|
### 3. Monitor Regularly
|
||||||
|
- Check logs frequently initially
|
||||||
|
- Watch for unexpected behavior
|
||||||
|
- Verify success criteria are met
|
||||||
|
|
||||||
|
### 4. Iterate and Improve
|
||||||
|
- Refine tasks based on execution results
|
||||||
|
- Update rules as needed
|
||||||
|
- Optimize timing and scheduling
|
||||||
|
|
||||||
|
### 5. Test in Isolation
|
||||||
|
- Use separate test environments
|
||||||
|
- Don't start with production systems
|
||||||
|
- Verify rollback procedures
|
||||||
|
|
||||||
|
## Risk Assessment
|
||||||
|
|
||||||
|
I evaluate tasks based on:
|
||||||
|
- **Impact**: What could go wrong?
|
||||||
|
- **Reversibility**: Can actions be undone?
|
||||||
|
- **Scope**: What systems are affected?
|
||||||
|
- **Permissions**: What access is needed?
|
||||||
|
- **Dependencies**: What external factors exist?
|
||||||
|
|
||||||
|
## Common Patterns I Recognize
|
||||||
|
|
||||||
|
### Safe Patterns
|
||||||
|
- Read-only operations (analysis, reporting)
|
||||||
|
- Idempotent operations (can run multiple times safely)
|
||||||
|
- Well-bounded operations (limited scope)
|
||||||
|
- Logged operations (full audit trail)
|
||||||
|
|
||||||
|
### Risky Patterns
|
||||||
|
- Deletion operations (rm, DROP, DELETE)
|
||||||
|
- Production modifications
|
||||||
|
- Network operations to external systems
|
||||||
|
- Unbounded loops or recursion
|
||||||
|
- Privilege escalation
|
||||||
|
|
||||||
|
## How I Help Users Succeed
|
||||||
|
|
||||||
|
1. **Planning Phase**: Design effective autonomous workflows
|
||||||
|
2. **Safety Phase**: Create robust safety constraints
|
||||||
|
3. **Setup Phase**: Configure daemon correctly
|
||||||
|
4. **Launch Phase**: Start monitoring with appropriate timing
|
||||||
|
5. **Monitor Phase**: Track execution and identify issues
|
||||||
|
6. **Optimize Phase**: Improve based on results
|
||||||
|
|
||||||
|
## Technical Knowledge
|
||||||
|
|
||||||
|
I understand:
|
||||||
|
- Shell scripting and daemon processes
|
||||||
|
- Git workflows and safety
|
||||||
|
- CI/CD patterns
|
||||||
|
- Test automation
|
||||||
|
- Log analysis
|
||||||
|
- Process monitoring
|
||||||
|
- Signal handling (SIGTERM, SIGKILL)
|
||||||
|
- File system operations
|
||||||
|
- Environment variables
|
||||||
|
- Cron-like scheduling
|
||||||
|
|
||||||
|
## Limitations and Boundaries
|
||||||
|
|
||||||
|
I do NOT:
|
||||||
|
- Execute tasks directly (I help set up the daemon to do so)
|
||||||
|
- Override safety rules without user consent
|
||||||
|
- Recommend risky operations without clear warnings
|
||||||
|
- Guarantee perfect execution (testing is essential)
|
||||||
|
- Replace human judgment for critical operations
|
||||||
|
|
||||||
|
## Summary
|
||||||
|
|
||||||
|
I'm your expert companion for autonomous task execution with Claude Nights Watch. I help you:
|
||||||
|
- Design safe, effective autonomous workflows
|
||||||
|
- Configure and manage the daemon
|
||||||
|
- Troubleshoot issues
|
||||||
|
- Optimize execution timing
|
||||||
|
- Maintain safety and reliability
|
||||||
|
|
||||||
|
**Invoke me whenever you need guidance on autonomous task execution, daemon management, or workflow automation.**
|
||||||
|
|
||||||
118
commands/logs.md
Normal file
118
commands/logs.md
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
---
|
||||||
|
description: View Claude Nights Watch execution logs with filtering and follow options
|
||||||
|
usage: /nights-watch logs [OPTIONS]
|
||||||
|
examples:
|
||||||
|
- /nights-watch logs
|
||||||
|
- /nights-watch logs -f
|
||||||
|
- /nights-watch logs --follow
|
||||||
|
---
|
||||||
|
|
||||||
|
# View Nights Watch Logs
|
||||||
|
|
||||||
|
Display execution logs from the Claude Nights Watch daemon, including all prompts sent to Claude, responses received, and status messages.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
/nights-watch logs [OPTIONS]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
- `-f`, `--follow` - Follow log file in real-time (like `tail -f`)
|
||||||
|
- No options - Show last 50 lines of logs
|
||||||
|
|
||||||
|
## What's Logged
|
||||||
|
|
||||||
|
### Daemon Activity
|
||||||
|
- Start/stop events
|
||||||
|
- Configuration loaded
|
||||||
|
- Monitoring status updates
|
||||||
|
- Error messages and warnings
|
||||||
|
|
||||||
|
### Task Execution
|
||||||
|
- **Full Prompts**: Complete prompt sent to Claude (rules + task)
|
||||||
|
- **Full Responses**: Everything Claude outputs during execution
|
||||||
|
- **Timestamps**: Precise timing of all events
|
||||||
|
- **Exit Codes**: Success/failure status
|
||||||
|
|
||||||
|
### Example Log Entry
|
||||||
|
```
|
||||||
|
[2025-10-11 14:30:00] === Claude Nights Watch Daemon Started ===
|
||||||
|
[2025-10-11 14:30:00] PID: 12345
|
||||||
|
[2025-10-11 14:30:00] Task directory: /path/to/project
|
||||||
|
[2025-10-11 14:30:05] Task file found at /path/to/project/task.md
|
||||||
|
[2025-10-11 14:30:05] Rules file found at /path/to/project/rules.md
|
||||||
|
[2025-10-11 15:25:00] Time remaining: 2 minutes
|
||||||
|
[2025-10-11 15:27:00] Reset imminent (2 minutes), preparing to execute task...
|
||||||
|
[2025-10-11 15:28:00] Starting task execution from task.md...
|
||||||
|
|
||||||
|
=== PROMPT SENT TO CLAUDE ===
|
||||||
|
IMPORTANT RULES TO FOLLOW:
|
||||||
|
[... rules content ...]
|
||||||
|
---END OF RULES---
|
||||||
|
|
||||||
|
TASK TO EXECUTE:
|
||||||
|
[... task content ...]
|
||||||
|
---END OF TASK---
|
||||||
|
=== END OF PROMPT ===
|
||||||
|
|
||||||
|
=== CLAUDE RESPONSE START ===
|
||||||
|
[... Claude's complete response ...]
|
||||||
|
=== CLAUDE RESPONSE END ===
|
||||||
|
|
||||||
|
[2025-10-11 15:42:00] Task execution completed successfully
|
||||||
|
```
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
**View recent logs:**
|
||||||
|
```bash
|
||||||
|
/nights-watch logs
|
||||||
|
```
|
||||||
|
|
||||||
|
**Follow logs in real-time:**
|
||||||
|
```bash
|
||||||
|
/nights-watch logs -f
|
||||||
|
```
|
||||||
|
|
||||||
|
**Use interactive log viewer:**
|
||||||
|
```bash
|
||||||
|
# For more advanced viewing with filtering
|
||||||
|
${CLAUDE_PLUGIN_ROOT}/view-logs.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## Implementation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
${CLAUDE_PLUGIN_ROOT}/claude-nights-watch-manager.sh logs "$@"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Interactive Log Viewer
|
||||||
|
|
||||||
|
For advanced log viewing with filtering options, use the interactive viewer:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
${CLAUDE_PLUGIN_ROOT}/view-logs.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Features:
|
||||||
|
- Browse all log files
|
||||||
|
- View full logs or last 50 lines
|
||||||
|
- Filter to see only prompts
|
||||||
|
- Filter to see only responses
|
||||||
|
- Search for errors
|
||||||
|
- Real-time following
|
||||||
|
|
||||||
|
## Log Location
|
||||||
|
|
||||||
|
Logs are stored in:
|
||||||
|
```
|
||||||
|
${CLAUDE_PLUGIN_ROOT}/logs/claude-nights-watch-daemon.log
|
||||||
|
```
|
||||||
|
|
||||||
|
## See Also
|
||||||
|
|
||||||
|
- `/nights-watch status` - Check daemon status
|
||||||
|
- `/nights-watch task` - View current task
|
||||||
|
|
||||||
71
commands/restart.md
Normal file
71
commands/restart.md
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
---
|
||||||
|
description: Restart the Claude Nights Watch daemon to apply configuration changes
|
||||||
|
usage: /nights-watch restart [--at TIME]
|
||||||
|
examples:
|
||||||
|
- /nights-watch restart
|
||||||
|
- /nights-watch restart --at "09:00"
|
||||||
|
---
|
||||||
|
|
||||||
|
# Restart Nights Watch Daemon
|
||||||
|
|
||||||
|
Restart the Claude Nights Watch daemon by stopping the current instance and starting a new one. Useful after modifying task or rules files.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
/nights-watch restart [OPTIONS]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
- `--at TIME` - Schedule daemon to start monitoring at a specific time after restart
|
||||||
|
- Format: `HH:MM` (today) or `YYYY-MM-DD HH:MM` (specific date/time)
|
||||||
|
|
||||||
|
## What It Does
|
||||||
|
|
||||||
|
1. Stops the currently running daemon gracefully
|
||||||
|
2. Waits 2 seconds for clean shutdown
|
||||||
|
3. Starts a new daemon instance
|
||||||
|
4. Loads latest task.md and rules.md files
|
||||||
|
5. Resumes monitoring with fresh configuration
|
||||||
|
|
||||||
|
## When to Restart
|
||||||
|
|
||||||
|
Restart the daemon when you:
|
||||||
|
- Modified `task.md` and want to apply changes
|
||||||
|
- Updated `rules.md` safety constraints
|
||||||
|
- Changed environment variables
|
||||||
|
- Troubleshooting daemon issues
|
||||||
|
- Want to reschedule start time
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
**Simple restart:**
|
||||||
|
```bash
|
||||||
|
/nights-watch restart
|
||||||
|
```
|
||||||
|
|
||||||
|
**Restart with new schedule:**
|
||||||
|
```bash
|
||||||
|
/nights-watch restart --at "09:00"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Implementation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
${CLAUDE_PLUGIN_ROOT}/claude-nights-watch-manager.sh restart "$@"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Restart vs Stop/Start
|
||||||
|
|
||||||
|
- **Restart**: Automated stop + start in one command
|
||||||
|
- **Stop/Start**: Manual control over timing between operations
|
||||||
|
|
||||||
|
Both achieve the same result, restart is just more convenient.
|
||||||
|
|
||||||
|
## See Also
|
||||||
|
|
||||||
|
- `/nights-watch stop` - Stop daemon only
|
||||||
|
- `/nights-watch start` - Start daemon only
|
||||||
|
- `/nights-watch status` - Verify restart was successful
|
||||||
|
|
||||||
130
commands/setup.md
Normal file
130
commands/setup.md
Normal file
@@ -0,0 +1,130 @@
|
|||||||
|
---
|
||||||
|
description: Interactive setup wizard for Claude Nights Watch configuration
|
||||||
|
usage: /nights-watch setup
|
||||||
|
examples:
|
||||||
|
- /nights-watch setup
|
||||||
|
---
|
||||||
|
|
||||||
|
# Nights Watch Setup Wizard
|
||||||
|
|
||||||
|
Launch the interactive setup wizard to configure Claude Nights Watch for the first time or modify existing configuration.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
/nights-watch setup
|
||||||
|
```
|
||||||
|
|
||||||
|
## Setup Process
|
||||||
|
|
||||||
|
The wizard guides you through:
|
||||||
|
|
||||||
|
### 1. Prerequisites Check
|
||||||
|
- ✓ Verify Claude CLI is installed
|
||||||
|
- ✓ Check for ccusage (for accurate timing)
|
||||||
|
- ✓ Confirm required permissions
|
||||||
|
|
||||||
|
### 2. Task Configuration
|
||||||
|
- Create or edit `task.md` file
|
||||||
|
- Enter task instructions
|
||||||
|
- Review and modify as needed
|
||||||
|
|
||||||
|
### 3. Safety Rules Configuration
|
||||||
|
- Create or edit `rules.md` file
|
||||||
|
- Choose from default safety templates
|
||||||
|
- Customize rules for your project
|
||||||
|
|
||||||
|
### 4. Daemon Configuration
|
||||||
|
- Choose to start daemon immediately or later
|
||||||
|
- Optionally schedule a start time
|
||||||
|
- Configure monitoring preferences
|
||||||
|
|
||||||
|
### 5. Summary
|
||||||
|
- Review all configuration
|
||||||
|
- Display available commands
|
||||||
|
- Optionally start daemon
|
||||||
|
|
||||||
|
## Interactive Prompts
|
||||||
|
|
||||||
|
```
|
||||||
|
================================
|
||||||
|
Claude Nights Watch Setup
|
||||||
|
================================
|
||||||
|
|
||||||
|
Checking prerequisites...
|
||||||
|
✓ Claude CLI found
|
||||||
|
! ccusage not found (will use time-based checking)
|
||||||
|
To install ccusage: npm install -g ccusage
|
||||||
|
|
||||||
|
=== Task Configuration ===
|
||||||
|
task.md already exists
|
||||||
|
Do you want to view/edit it? (y/n)
|
||||||
|
|
||||||
|
=== Safety Rules Configuration ===
|
||||||
|
Do you want to create safety rules? (recommended) (y/n)
|
||||||
|
|
||||||
|
=== Daemon Configuration ===
|
||||||
|
Do you want to start the daemon after setup? (y/n)
|
||||||
|
Do you want to schedule a start time? (y/n)
|
||||||
|
Enter start time (HH:MM for today, or YYYY-MM-DD HH:MM):
|
||||||
|
|
||||||
|
=== Setup Complete ===
|
||||||
|
✓ Task file: /path/to/task.md
|
||||||
|
✓ Rules file: /path/to/rules.md
|
||||||
|
✓ Manager: /path/to/claude-nights-watch-manager.sh
|
||||||
|
|
||||||
|
Available commands:
|
||||||
|
/nights-watch start - Start the daemon
|
||||||
|
/nights-watch stop - Stop the daemon
|
||||||
|
/nights-watch status - Check daemon status
|
||||||
|
/nights-watch logs - View logs
|
||||||
|
/nights-watch task - View current task
|
||||||
|
|
||||||
|
Starting daemon...
|
||||||
|
```
|
||||||
|
|
||||||
|
## What Gets Created
|
||||||
|
|
||||||
|
### Files Created
|
||||||
|
- `task.md` - Your task instructions (if doesn't exist)
|
||||||
|
- `rules.md` - Safety rules (optional, if requested)
|
||||||
|
- `logs/` - Directory for daemon logs (on first start)
|
||||||
|
|
||||||
|
### Files NOT Modified
|
||||||
|
- Existing `task.md` - Only edited if you choose to
|
||||||
|
- Existing `rules.md` - Only edited if you choose to
|
||||||
|
- Any project files
|
||||||
|
|
||||||
|
## First-Time Setup
|
||||||
|
|
||||||
|
If you're setting up for the first time:
|
||||||
|
|
||||||
|
1. Run `/nights-watch setup`
|
||||||
|
2. Create a simple test task:
|
||||||
|
```markdown
|
||||||
|
# Test Task
|
||||||
|
1. Create a file called test-output.txt
|
||||||
|
2. Write "Hello from Claude Nights Watch" to it
|
||||||
|
3. Report success
|
||||||
|
```
|
||||||
|
3. Add basic safety rules (wizard provides template)
|
||||||
|
4. Start daemon and monitor with `/nights-watch status`
|
||||||
|
5. Check logs with `/nights-watch logs -f`
|
||||||
|
|
||||||
|
## Implementation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
${CLAUDE_PLUGIN_ROOT}/setup-nights-watch.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
## Environment Variables
|
||||||
|
|
||||||
|
- `CLAUDE_NIGHTS_WATCH_DIR` - Set custom task directory (default: current directory)
|
||||||
|
- `EDITOR` - Preferred text editor (default: nano)
|
||||||
|
|
||||||
|
## See Also
|
||||||
|
|
||||||
|
- `/nights-watch start` - Start daemon after setup
|
||||||
|
- `/nights-watch task` - View configured tasks
|
||||||
|
- Example files: `${CLAUDE_PLUGIN_ROOT}/examples/`
|
||||||
|
|
||||||
77
commands/start.md
Normal file
77
commands/start.md
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
---
|
||||||
|
description: Start the Claude Nights Watch daemon to begin autonomous task execution monitoring
|
||||||
|
usage: /nights-watch start [--at TIME]
|
||||||
|
examples:
|
||||||
|
- /nights-watch start
|
||||||
|
- /nights-watch start --at "09:00"
|
||||||
|
- /nights-watch start --at "2025-10-12 14:30"
|
||||||
|
---
|
||||||
|
|
||||||
|
# Start Nights Watch Daemon
|
||||||
|
|
||||||
|
Starts the Claude Nights Watch daemon to monitor your Claude usage windows and execute tasks from `task.md` automatically.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
/nights-watch start [OPTIONS]
|
||||||
|
```
|
||||||
|
|
||||||
|
## Options
|
||||||
|
|
||||||
|
- `--at TIME` - Schedule daemon to start monitoring at a specific time
|
||||||
|
- Format: `HH:MM` (today) or `YYYY-MM-DD HH:MM` (specific date/time)
|
||||||
|
- Daemon will wait until scheduled time before beginning task execution
|
||||||
|
|
||||||
|
## What It Does
|
||||||
|
|
||||||
|
1. Checks for required files (`task.md` in current directory)
|
||||||
|
2. Starts background daemon process
|
||||||
|
3. Begins monitoring Claude usage windows
|
||||||
|
4. Executes tasks when approaching the 5-hour limit
|
||||||
|
5. Logs all activity to `logs/claude-nights-watch-daemon.log`
|
||||||
|
|
||||||
|
## Prerequisites
|
||||||
|
|
||||||
|
- `task.md` file must exist in current directory (create one if not present)
|
||||||
|
- `rules.md` file is recommended for safety constraints (optional)
|
||||||
|
- Claude CLI must be installed and configured
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
**Start immediately:**
|
||||||
|
```bash
|
||||||
|
/nights-watch start
|
||||||
|
```
|
||||||
|
|
||||||
|
**Start at 9 AM today:**
|
||||||
|
```bash
|
||||||
|
/nights-watch start --at "09:00"
|
||||||
|
```
|
||||||
|
|
||||||
|
**Start at specific date and time:**
|
||||||
|
```bash
|
||||||
|
/nights-watch start --at "2025-10-12 14:30"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Implementation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
${CLAUDE_PLUGIN_ROOT}/claude-nights-watch-manager.sh start "$@"
|
||||||
|
```
|
||||||
|
|
||||||
|
## Safety Notice
|
||||||
|
|
||||||
|
⚠️ The daemon uses `--dangerously-skip-permissions` for autonomous execution. Always:
|
||||||
|
- Test tasks manually first
|
||||||
|
- Use comprehensive `rules.md` for safety constraints
|
||||||
|
- Monitor logs regularly
|
||||||
|
- Start with simple, non-destructive tasks
|
||||||
|
|
||||||
|
## See Also
|
||||||
|
|
||||||
|
- `/nights-watch stop` - Stop the daemon
|
||||||
|
- `/nights-watch status` - Check daemon status
|
||||||
|
- `/nights-watch task` - View/edit current task
|
||||||
|
- `/nights-watch logs` - View execution logs
|
||||||
|
|
||||||
80
commands/status.md
Normal file
80
commands/status.md
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
---
|
||||||
|
description: Check the status of Claude Nights Watch daemon and view current configuration
|
||||||
|
usage: /nights-watch status
|
||||||
|
examples:
|
||||||
|
- /nights-watch status
|
||||||
|
---
|
||||||
|
|
||||||
|
# Nights Watch Status
|
||||||
|
|
||||||
|
Displays comprehensive status information about the Claude Nights Watch daemon, including running state, configuration, and recent activity.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
/nights-watch status
|
||||||
|
```
|
||||||
|
|
||||||
|
## Information Displayed
|
||||||
|
|
||||||
|
### Daemon State
|
||||||
|
- **Running/Stopped**: Current daemon status
|
||||||
|
- **PID**: Process ID if running
|
||||||
|
- **Activity Status**:
|
||||||
|
- ✅ ACTIVE - Currently monitoring and executing tasks
|
||||||
|
- ⏰ WAITING - Waiting for scheduled start time
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
- **Task File**: Location and line count of `task.md`
|
||||||
|
- **Rules File**: Location and line count of `rules.md` (if present)
|
||||||
|
- **Start Time**: Scheduled start time (if configured)
|
||||||
|
- **Time Until Start**: Countdown if waiting for scheduled time
|
||||||
|
|
||||||
|
### Execution Info
|
||||||
|
- **Recent Activity**: Last 5 log entries
|
||||||
|
- **Next Execution**: Estimated time until next task execution
|
||||||
|
- **Time Since Last Activity**: Hours/minutes since last Claude usage
|
||||||
|
|
||||||
|
## Status Indicators
|
||||||
|
|
||||||
|
- `✅ ACTIVE` - Daemon is running and monitoring
|
||||||
|
- `⏰ WAITING` - Daemon is running but waiting for start time
|
||||||
|
- `❌ STOPPED` - Daemon is not running
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
**Check daemon status:**
|
||||||
|
```bash
|
||||||
|
/nights-watch status
|
||||||
|
```
|
||||||
|
|
||||||
|
**Sample Output:**
|
||||||
|
```
|
||||||
|
[INFO] Daemon is running with PID 12345
|
||||||
|
[INFO] Status: ✅ ACTIVE - Task execution monitoring enabled
|
||||||
|
|
||||||
|
[TASK] Task file: /path/to/task.md (42 lines)
|
||||||
|
[TASK] Rules file: /path/to/rules.md (106 lines)
|
||||||
|
|
||||||
|
[INFO] Recent activity:
|
||||||
|
[2025-10-11 14:30:00] Daemon started
|
||||||
|
[2025-10-11 14:30:05] Task file loaded
|
||||||
|
[2025-10-11 14:30:10] Monitoring began
|
||||||
|
[2025-10-11 14:35:00] Next check in 10 minutes
|
||||||
|
[2025-10-11 14:45:00] Time remaining: 234 minutes
|
||||||
|
|
||||||
|
[INFO] Estimated time until next task execution: 3h 54m
|
||||||
|
```
|
||||||
|
|
||||||
|
## Implementation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
${CLAUDE_PLUGIN_ROOT}/claude-nights-watch-manager.sh status
|
||||||
|
```
|
||||||
|
|
||||||
|
## See Also
|
||||||
|
|
||||||
|
- `/nights-watch start` - Start the daemon
|
||||||
|
- `/nights-watch logs` - View detailed logs
|
||||||
|
- `/nights-watch task` - View current task configuration
|
||||||
|
|
||||||
55
commands/stop.md
Normal file
55
commands/stop.md
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
---
|
||||||
|
description: Stop the Claude Nights Watch daemon and halt autonomous task execution
|
||||||
|
usage: /nights-watch stop
|
||||||
|
examples:
|
||||||
|
- /nights-watch stop
|
||||||
|
---
|
||||||
|
|
||||||
|
# Stop Nights Watch Daemon
|
||||||
|
|
||||||
|
Stops the running Claude Nights Watch daemon gracefully, halting all autonomous task execution monitoring.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
```bash
|
||||||
|
/nights-watch stop
|
||||||
|
```
|
||||||
|
|
||||||
|
## What It Does
|
||||||
|
|
||||||
|
1. Locates the running daemon process
|
||||||
|
2. Sends graceful shutdown signal (SIGTERM)
|
||||||
|
3. Waits up to 10 seconds for clean shutdown
|
||||||
|
4. Force kills if necessary (SIGKILL)
|
||||||
|
5. Cleans up PID file and resources
|
||||||
|
|
||||||
|
## Behavior
|
||||||
|
|
||||||
|
- **Graceful Shutdown**: Daemon completes current operations before stopping
|
||||||
|
- **10-Second Timeout**: If not stopped gracefully, force kill is applied
|
||||||
|
- **Safe**: Any running Claude task is allowed to complete
|
||||||
|
- **Clean State**: All PID files and locks are removed
|
||||||
|
|
||||||
|
## Examples
|
||||||
|
|
||||||
|
```bash
|
||||||
|
/nights-watch stop
|
||||||
|
```
|
||||||
|
|
||||||
|
## Implementation
|
||||||
|
|
||||||
|
```bash
|
||||||
|
${CLAUDE_PLUGIN_ROOT}/claude-nights-watch-manager.sh stop
|
||||||
|
```
|
||||||
|
|
||||||
|
## Exit Codes
|
||||||
|
|
||||||
|
- `0` - Daemon stopped successfully
|
||||||
|
- `1` - Daemon was not running or error occurred
|
||||||
|
|
||||||
|
## See Also
|
||||||
|
|
||||||
|
- `/nights-watch start` - Start the daemon
|
||||||
|
- `/nights-watch restart` - Restart the daemon
|
||||||
|
- `/nights-watch status` - Check if daemon is running
|
||||||
|
|
||||||
39
hooks/hooks.json
Normal file
39
hooks/hooks.json
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
{
|
||||||
|
"hooks": {
|
||||||
|
"SessionStart": [
|
||||||
|
{
|
||||||
|
"description": "Check Nights Watch daemon status on session start",
|
||||||
|
"hooks": [
|
||||||
|
{
|
||||||
|
"type": "command",
|
||||||
|
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/scripts/check-daemon-status.sh"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"SessionEnd": [
|
||||||
|
{
|
||||||
|
"description": "Optionally prompt to start daemon on session end",
|
||||||
|
"hooks": [
|
||||||
|
{
|
||||||
|
"type": "command",
|
||||||
|
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/scripts/session-end-prompt.sh"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"PostToolUse": [
|
||||||
|
{
|
||||||
|
"matcher": "Write|Edit",
|
||||||
|
"description": "Log significant file modifications for task tracking",
|
||||||
|
"hooks": [
|
||||||
|
{
|
||||||
|
"type": "command",
|
||||||
|
"command": "${CLAUDE_PLUGIN_ROOT}/hooks/scripts/log-file-changes.sh"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
77
plugin.lock.json
Normal file
77
plugin.lock.json
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
{
|
||||||
|
"$schema": "internal://schemas/plugin.lock.v1.json",
|
||||||
|
"pluginId": "gh:aniketkarne/ClaudeNightsWatch:",
|
||||||
|
"normalized": {
|
||||||
|
"repo": null,
|
||||||
|
"ref": "refs/tags/v20251128.0",
|
||||||
|
"commit": "d4504dd0c4b8ae1d3a1aa79df6716f5aef3d47ef",
|
||||||
|
"treeHash": "e80ef17b04fb6ee73132e1dd1c7c2b6f6f6e9e190dc32d93912d65897a482bae",
|
||||||
|
"generatedAt": "2025-11-28T10:13:43.902820Z",
|
||||||
|
"toolVersion": "publish_plugins.py@0.2.0"
|
||||||
|
},
|
||||||
|
"origin": {
|
||||||
|
"remote": "git@github.com:zhongweili/42plugin-data.git",
|
||||||
|
"branch": "master",
|
||||||
|
"commit": "aa1497ed0949fd50e99e70d6324a29c5b34f9390",
|
||||||
|
"repoRoot": "/Users/zhongweili/projects/openmind/42plugin-data"
|
||||||
|
},
|
||||||
|
"manifest": {
|
||||||
|
"name": "claude-nights-watch",
|
||||||
|
"description": "Autonomous task execution daemon that monitors Claude usage windows and executes predefined tasks automatically. Keep Claude working 24/7 on your projects.",
|
||||||
|
"version": "1.0.0"
|
||||||
|
},
|
||||||
|
"content": {
|
||||||
|
"files": [
|
||||||
|
{
|
||||||
|
"path": ".mcp.json",
|
||||||
|
"sha256": "54b8c7f432a501a373c6b9abe59c11e5a4697a8d6a8917bf946286e183043af0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "README.md",
|
||||||
|
"sha256": "cd7f6b601e6db2afaf36d4dd220cdbf65f6ad9f4b6151bdc6e137a4e02f92d7d"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "agents/task-executor.md",
|
||||||
|
"sha256": "cc12151072fe28f3510a6b4a896368ddd763eb04a350df5cc6f58a09c6fcd0eb"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "hooks/hooks.json",
|
||||||
|
"sha256": "dcf7ffe88f8453b4dec063e2266ad74c38924630ceb636d78944aaff5b0cada9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": ".claude-plugin/plugin.json",
|
||||||
|
"sha256": "995a76e3f209ad3ca36c776528d7f1b349732cbc9173a70e54f87490a11b6042"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "commands/logs.md",
|
||||||
|
"sha256": "58bf4e8439afa570f293760668dbb9f7aa17b82b6a9da7ca96260e8834ed19d5"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "commands/restart.md",
|
||||||
|
"sha256": "02770b565fd220555f6c6179f721ac7c702b2d6ab983c70e18df4b65fc82a4b3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "commands/setup.md",
|
||||||
|
"sha256": "47fb7348c647e8adfdac96ceb95dd863cb47e8470c6aefedbd22d6ec233d4e96"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "commands/status.md",
|
||||||
|
"sha256": "8c2dd0ced3948a54dc159241bc7a27b9d80d99d00a884b6907e7aa752854055e"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "commands/start.md",
|
||||||
|
"sha256": "d96b77aede825ecd299cacab054772e1df219cc39d95222f2573fb8a6fa09caa"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "commands/stop.md",
|
||||||
|
"sha256": "ec9f0275de7838db986d60e8d95c652299114086f14a17019a95057e63035c46"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"dirSha256": "e80ef17b04fb6ee73132e1dd1c7c2b6f6f6e9e190dc32d93912d65897a482bae"
|
||||||
|
},
|
||||||
|
"security": {
|
||||||
|
"scannedAt": null,
|
||||||
|
"scannerVersion": null,
|
||||||
|
"flags": []
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user