-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·196 lines (160 loc) · 5.35 KB
/
install.sh
File metadata and controls
executable file
·196 lines (160 loc) · 5.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#!/bin/bash
#
# agent-worklog installer
#
# Usage:
# ./install.sh # Install with defaults
# ./install.sh --uninstall # Remove installation
#
# What this does:
# 1. Initializes the database if needed
# 2. Creates ~/.cursor/rules/always-agent-worklog.mdc (Cursor rule)
# 3. Adds bin directory to PATH in ~/.zshrc (if zsh is available)
#
set -e
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Paths
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BIN_DIR="$SCRIPT_DIR/bin"
CURSOR_RULES_DIR="$HOME/.cursor/rules"
MDC_FILE="$CURSOR_RULES_DIR/always-agent-worklog.mdc"
ZSHRC="$HOME/.zshrc"
BASHRC="$HOME/.bashrc"
echo -e "${BLUE}agent-worklog installer${NC}"
echo "========================"
echo ""
# Uninstall mode
if [[ "$1" == "--uninstall" ]]; then
echo -e "${YELLOW}Uninstalling agent-worklog...${NC}"
# Remove MDC file
if [[ -f "$MDC_FILE" ]]; then
rm "$MDC_FILE"
echo -e "${GREEN}✓${NC} Removed $MDC_FILE"
fi
# Remove PATH entry from .zshrc
if [[ -f "$ZSHRC" ]] && grep -q "agent-worklog" "$ZSHRC"; then
sed -i.bak '/# agent-worklog/d' "$ZSHRC"
sed -i.bak "/$(echo "$BIN_DIR" | sed 's/\//\\\//g')/d" "$ZSHRC"
rm -f "$ZSHRC.bak"
echo -e "${GREEN}✓${NC} Removed PATH entry from $ZSHRC"
fi
# Remove PATH entry from .bashrc
if [[ -f "$BASHRC" ]] && grep -q "agent-worklog" "$BASHRC"; then
sed -i.bak '/# agent-worklog/d' "$BASHRC"
sed -i.bak "/$(echo "$BIN_DIR" | sed 's/\//\\\//g')/d" "$BASHRC"
rm -f "$BASHRC.bak"
echo -e "${GREEN}✓${NC} Removed PATH entry from $BASHRC"
fi
echo ""
echo -e "${GREEN}Uninstall complete.${NC}"
echo "Note: Database and skills are preserved. Delete the repo to fully remove."
exit 0
fi
# Step 1: Initialize database
echo -e "${BLUE}Step 1: Database${NC}"
DB_PATH="$HOME/.agent-worklog.db"
if [[ -f "$DB_PATH" ]]; then
echo -e "${GREEN}✓${NC} Database already exists at $DB_PATH"
else
python3 "$SCRIPT_DIR/init_db.py"
echo -e "${GREEN}✓${NC} Database initialized at $DB_PATH"
fi
echo ""
# Step 2: Create Cursor rules directory and MDC file
echo -e "${BLUE}Step 2: Cursor Integration${NC}"
mkdir -p "$CURSOR_RULES_DIR"
cat > "$MDC_FILE" << 'MDCEOF'
---
description: Agent Worklog - Track AI agent work
globs:
alwaysApply: true
---
# Agent Worklog Integration
You have access to the agent-worklog system for tracking your work.
## Quick Reference
- **AGENTS.md location**: AGENT_WORKLOG_PATH/AGENTS.md
- **Skills directory**: AGENT_WORKLOG_PATH/skills/
- **Database**: ~/.agent-worklog.db
- **CLI**: `agent-worklog` (if in PATH)
## When You See `<work>` in a Prompt
Follow the `do_work` skill at `AGENT_WORKLOG_PATH/skills/do_work.md`:
1. Parse task and extract hashtags from the prompt
2. Execute the coding task
3. Create a git commit
4. Log work to the database
## Logging Work Manually
Use the CLI:
```bash
agent-worklog log -t "Task description" -H "#tag1,#tag2"
```
Or follow `AGENT_WORKLOG_PATH/skills/log_work.md` for direct database insertion.
## Querying Past Work
Use the CLI:
```bash
agent-worklog list # Recent entries
agent-worklog stats # Statistics
agent-worklog show <id> # Entry details
```
Or follow `AGENT_WORKLOG_PATH/skills/query_work.md` for natural language queries.
## Available Skills
1. **do_work.md** - Complete workflow triggered by `<work>`
2. **log_work.md** - Manual work logging
3. **summarize_work.md** - Generate summaries
4. **query_work.md** - Query historical work
MDCEOF
# Replace placeholder with actual path
sed -i.bak "s|AGENT_WORKLOG_PATH|$SCRIPT_DIR|g" "$MDC_FILE"
rm -f "$MDC_FILE.bak"
echo -e "${GREEN}✓${NC} Created $MDC_FILE"
echo ""
# Step 3: Add to PATH
echo -e "${BLUE}Step 3: PATH Configuration${NC}"
PATH_EXPORT="export PATH=\"\$PATH:$BIN_DIR\""
PATH_COMMENT="# agent-worklog CLI"
add_to_shell_rc() {
local rc_file="$1"
local shell_name="$2"
if [[ -f "$rc_file" ]]; then
if grep -q "agent-worklog" "$rc_file"; then
echo -e "${YELLOW}!${NC} PATH already configured in $rc_file"
else
echo "" >> "$rc_file"
echo "$PATH_COMMENT" >> "$rc_file"
echo "$PATH_EXPORT" >> "$rc_file"
echo -e "${GREEN}✓${NC} Added to $rc_file"
fi
else
echo -e "${YELLOW}!${NC} $rc_file not found, skipping"
fi
}
# Detect shell and add to appropriate rc file
if [[ -n "$ZSH_VERSION" ]] || [[ "$SHELL" == *"zsh"* ]] || [[ -f "$ZSHRC" ]]; then
add_to_shell_rc "$ZSHRC" "zsh"
fi
if [[ -n "$BASH_VERSION" ]] || [[ "$SHELL" == *"bash"* ]] || [[ -f "$BASHRC" ]]; then
# Only add to bashrc if zshrc wasn't found or if bash is the default shell
if [[ ! -f "$ZSHRC" ]] || [[ "$SHELL" == *"bash"* ]]; then
add_to_shell_rc "$BASHRC" "bash"
fi
fi
echo ""
# Summary
echo -e "${GREEN}Installation complete!${NC}"
echo ""
echo "Configuration:"
echo " Install directory: $SCRIPT_DIR"
echo " Skills directory: $SCRIPT_DIR/skills"
echo " Database: $DB_PATH"
echo " CLI: $BIN_DIR/agent-worklog"
echo " Cursor rule: $MDC_FILE"
echo ""
echo -e "${YELLOW}Next steps:${NC}"
echo " 1. Open a new terminal (or run: source ~/.zshrc)"
echo " 2. Verify installation: agent-worklog"
echo " 3. Start using <work> in prompts!"
echo ""