oh-my-claude-sisyphus 3.6.0 → 3.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/commands/omc-setup.md +3 -3
- package/commands/psm.md +180 -0
- package/commands/release.md +1 -1
- package/dist/__tests__/analytics/transcript-scanner.test.js +69 -27
- package/dist/__tests__/analytics/transcript-scanner.test.js.map +1 -1
- package/dist/__tests__/installer.test.js +2 -1
- package/dist/__tests__/installer.test.js.map +1 -1
- package/dist/analytics/session-manager.d.ts +24 -0
- package/dist/analytics/session-manager.d.ts.map +1 -1
- package/dist/analytics/session-manager.js +98 -9
- package/dist/analytics/session-manager.js.map +1 -1
- package/dist/analytics/transcript-scanner.d.ts +9 -8
- package/dist/analytics/transcript-scanner.d.ts.map +1 -1
- package/dist/analytics/transcript-scanner.js +146 -16
- package/dist/analytics/transcript-scanner.js.map +1 -1
- package/dist/hooks/empty-message-sanitizer/__tests__/index.test.d.ts +2 -0
- package/dist/hooks/empty-message-sanitizer/__tests__/index.test.d.ts.map +1 -0
- package/dist/hooks/empty-message-sanitizer/__tests__/index.test.js +416 -0
- package/dist/hooks/empty-message-sanitizer/__tests__/index.test.js.map +1 -0
- package/dist/hooks/keyword-detector/__tests__/index.test.d.ts +2 -0
- package/dist/hooks/keyword-detector/__tests__/index.test.d.ts.map +1 -0
- package/dist/hooks/keyword-detector/__tests__/index.test.js +427 -0
- package/dist/hooks/keyword-detector/__tests__/index.test.js.map +1 -0
- package/dist/hooks/subagent-tracker/index.d.ts +83 -0
- package/dist/hooks/subagent-tracker/index.d.ts.map +1 -0
- package/dist/hooks/subagent-tracker/index.js +207 -0
- package/dist/hooks/subagent-tracker/index.js.map +1 -0
- package/dist/hooks/think-mode/__tests__/index.test.d.ts +2 -0
- package/dist/hooks/think-mode/__tests__/index.test.d.ts.map +1 -0
- package/dist/hooks/think-mode/__tests__/index.test.js +556 -0
- package/dist/hooks/think-mode/__tests__/index.test.js.map +1 -0
- package/dist/installer/index.d.ts.map +1 -1
- package/dist/installer/index.js +8 -0
- package/dist/installer/index.js.map +1 -1
- package/docs/design/project-session-manager.md +1033 -0
- package/package.json +1 -1
- package/skills/omc-setup/SKILL.md +27 -3
- package/skills/project-session-manager/SKILL.md +410 -0
- package/skills/project-session-manager/lib/config.sh +86 -0
- package/skills/project-session-manager/lib/parse.sh +121 -0
- package/skills/project-session-manager/lib/session.sh +132 -0
- package/skills/project-session-manager/lib/tmux.sh +103 -0
- package/skills/project-session-manager/lib/worktree.sh +171 -0
- package/skills/project-session-manager/psm.sh +629 -0
- package/skills/project-session-manager/templates/feature.md +56 -0
- package/skills/project-session-manager/templates/issue-fix.md +57 -0
- package/skills/project-session-manager/templates/pr-review.md +65 -0
- package/skills/project-session-manager/templates/projects.json +19 -0
- package/skills/release/SKILL.md +1 -1
package/package.json
CHANGED
|
@@ -49,6 +49,14 @@ mkdir -p .claude && echo ".claude directory ready"
|
|
|
49
49
|
# Extract old version before download
|
|
50
50
|
OLD_VERSION=$(grep -m1 "^# oh-my-claudecode" .claude/CLAUDE.md 2>/dev/null | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' || echo "none")
|
|
51
51
|
|
|
52
|
+
# Backup existing CLAUDE.md before overwriting (if it exists)
|
|
53
|
+
if [ -f ".claude/CLAUDE.md" ]; then
|
|
54
|
+
BACKUP_DATE=$(date +%Y-%m-%d)
|
|
55
|
+
BACKUP_PATH=".claude/CLAUDE.md.backup.${BACKUP_DATE}"
|
|
56
|
+
cp .claude/CLAUDE.md "$BACKUP_PATH"
|
|
57
|
+
echo "Backed up existing CLAUDE.md to $BACKUP_PATH"
|
|
58
|
+
fi
|
|
59
|
+
|
|
52
60
|
# Download fresh CLAUDE.md from GitHub
|
|
53
61
|
curl -fsSL "https://raw.githubusercontent.com/Yeachan-Heo/oh-my-claudecode/main/docs/CLAUDE.md" -o .claude/CLAUDE.md && \
|
|
54
62
|
echo "Downloaded CLAUDE.md to .claude/CLAUDE.md"
|
|
@@ -66,6 +74,8 @@ fi
|
|
|
66
74
|
|
|
67
75
|
**Note**: The downloaded CLAUDE.md includes Context Persistence instructions with `<remember>` tags for surviving conversation compaction.
|
|
68
76
|
|
|
77
|
+
**Note**: If an existing CLAUDE.md is found, it will be backed up to `.claude/CLAUDE.md.backup.YYYY-MM-DD` before downloading the new version.
|
|
78
|
+
|
|
69
79
|
**MANDATORY**: Always run this command. Do NOT skip. Do NOT use Write tool.
|
|
70
80
|
|
|
71
81
|
**FALLBACK** if curl fails:
|
|
@@ -84,6 +94,7 @@ After completing local configuration, report:
|
|
|
84
94
|
|
|
85
95
|
**OMC Project Configuration Complete**
|
|
86
96
|
- CLAUDE.md: Updated with latest configuration from GitHub at ./.claude/CLAUDE.md
|
|
97
|
+
- Backup: Previous CLAUDE.md backed up to `.claude/CLAUDE.md.backup.YYYY-MM-DD` (if existed)
|
|
87
98
|
- Scope: **PROJECT** - applies only to this project
|
|
88
99
|
- Hooks: Provided by plugin (no manual installation needed)
|
|
89
100
|
- Agents: 28+ available (base + tiered variants)
|
|
@@ -103,6 +114,14 @@ If `--local` flag was used, **STOP HERE**. Do not continue to HUD setup or other
|
|
|
103
114
|
# Extract old version before download
|
|
104
115
|
OLD_VERSION=$(grep -m1 "^# oh-my-claudecode" ~/.claude/CLAUDE.md 2>/dev/null | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' || echo "none")
|
|
105
116
|
|
|
117
|
+
# Backup existing CLAUDE.md before overwriting (if it exists)
|
|
118
|
+
if [ -f "$HOME/.claude/CLAUDE.md" ]; then
|
|
119
|
+
BACKUP_DATE=$(date +%Y-%m-%d)
|
|
120
|
+
BACKUP_PATH="$HOME/.claude/CLAUDE.md.backup.${BACKUP_DATE}"
|
|
121
|
+
cp "$HOME/.claude/CLAUDE.md" "$BACKUP_PATH"
|
|
122
|
+
echo "Backed up existing CLAUDE.md to $BACKUP_PATH"
|
|
123
|
+
fi
|
|
124
|
+
|
|
106
125
|
# Download fresh CLAUDE.md to global config
|
|
107
126
|
curl -fsSL "https://raw.githubusercontent.com/Yeachan-Heo/oh-my-claudecode/main/docs/CLAUDE.md" -o ~/.claude/CLAUDE.md && \
|
|
108
127
|
echo "Downloaded CLAUDE.md to ~/.claude/CLAUDE.md"
|
|
@@ -118,6 +137,8 @@ else
|
|
|
118
137
|
fi
|
|
119
138
|
```
|
|
120
139
|
|
|
140
|
+
**Note**: If an existing CLAUDE.md is found, it will be backed up to `~/.claude/CLAUDE.md.backup.YYYY-MM-DD` before downloading the new version.
|
|
141
|
+
|
|
121
142
|
### Clean Up Legacy Hooks (if present)
|
|
122
143
|
|
|
123
144
|
Check if old manual hooks exist and remove them to prevent duplicates:
|
|
@@ -147,6 +168,7 @@ After completing global configuration, report:
|
|
|
147
168
|
|
|
148
169
|
**OMC Global Configuration Complete**
|
|
149
170
|
- CLAUDE.md: Updated with latest configuration from GitHub at ~/.claude/CLAUDE.md
|
|
171
|
+
- Backup: Previous CLAUDE.md backed up to `~/.claude/CLAUDE.md.backup.YYYY-MM-DD` (if existed)
|
|
150
172
|
- Scope: **GLOBAL** - applies to all Claude Code sessions
|
|
151
173
|
- Hooks: Provided by plugin (no manual installation needed)
|
|
152
174
|
- Agents: 28+ available (base + tiered variants)
|
|
@@ -282,10 +304,10 @@ Ask user: "Would you like to install the OMC CLI for standalone analytics? (Reco
|
|
|
282
304
|
# Check for bun (preferred) or npm
|
|
283
305
|
if command -v bun &> /dev/null; then
|
|
284
306
|
echo "Installing OMC CLI via bun..."
|
|
285
|
-
bun install -g oh-my-
|
|
307
|
+
bun install -g oh-my-claude-sisyphus
|
|
286
308
|
elif command -v npm &> /dev/null; then
|
|
287
309
|
echo "Installing OMC CLI via npm..."
|
|
288
|
-
npm install -g oh-my-
|
|
310
|
+
npm install -g oh-my-claude-sisyphus
|
|
289
311
|
else
|
|
290
312
|
echo "ERROR: Neither bun nor npm found. Please install Node.js or Bun first."
|
|
291
313
|
exit 1
|
|
@@ -303,7 +325,7 @@ fi
|
|
|
303
325
|
|
|
304
326
|
### If User Chooses NO:
|
|
305
327
|
|
|
306
|
-
Skip this step. User can install later with `npm install -g oh-my-
|
|
328
|
+
Skip this step. User can install later with `npm install -g oh-my-claude-sisyphus`.
|
|
307
329
|
|
|
308
330
|
## Step 4: Verify Plugin Installation
|
|
309
331
|
|
|
@@ -480,11 +502,13 @@ MODES:
|
|
|
480
502
|
|
|
481
503
|
Local Configuration (--local)
|
|
482
504
|
- Downloads fresh CLAUDE.md to ./.claude/
|
|
505
|
+
- Backs up existing CLAUDE.md to .claude/CLAUDE.md.backup.YYYY-MM-DD
|
|
483
506
|
- Project-specific settings
|
|
484
507
|
- Use this to update project config after OMC upgrades
|
|
485
508
|
|
|
486
509
|
Global Configuration (--global)
|
|
487
510
|
- Downloads fresh CLAUDE.md to ~/.claude/
|
|
511
|
+
- Backs up existing CLAUDE.md to ~/.claude/CLAUDE.md.backup.YYYY-MM-DD
|
|
488
512
|
- Applies to all Claude Code sessions
|
|
489
513
|
- Cleans up legacy hooks
|
|
490
514
|
- Use this to update global config after OMC upgrades
|
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: project-session-manager
|
|
3
|
+
description: Manage isolated dev environments with git worktrees and tmux sessions
|
|
4
|
+
aliases: [psm]
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Project Session Manager (PSM) Skill
|
|
8
|
+
|
|
9
|
+
Automate isolated development environments using git worktrees and tmux sessions with Claude Code. Enables parallel work across multiple tasks, projects, and repositories.
|
|
10
|
+
|
|
11
|
+
## Commands
|
|
12
|
+
|
|
13
|
+
| Command | Description | Example |
|
|
14
|
+
|---------|-------------|---------|
|
|
15
|
+
| `review <ref>` | PR review session | `/psm review omc#123` |
|
|
16
|
+
| `fix <ref>` | Issue fix session | `/psm fix omc#42` |
|
|
17
|
+
| `feature <proj> <name>` | Feature development | `/psm feature omc add-webhooks` |
|
|
18
|
+
| `list [project]` | List active sessions | `/psm list` |
|
|
19
|
+
| `attach <session>` | Attach to session | `/psm attach omc:pr-123` |
|
|
20
|
+
| `kill <session>` | Kill session | `/psm kill omc:pr-123` |
|
|
21
|
+
| `cleanup` | Clean merged/closed | `/psm cleanup` |
|
|
22
|
+
| `status` | Current session info | `/psm status` |
|
|
23
|
+
|
|
24
|
+
## Project References
|
|
25
|
+
|
|
26
|
+
Supported formats:
|
|
27
|
+
- **Alias**: `omc#123` (requires `~/.psm/projects.json`)
|
|
28
|
+
- **Full**: `owner/repo#123`
|
|
29
|
+
- **URL**: `https://github.com/owner/repo/pull/123`
|
|
30
|
+
- **Current**: `#123` (uses current directory's repo)
|
|
31
|
+
|
|
32
|
+
## Configuration
|
|
33
|
+
|
|
34
|
+
### Project Aliases (`~/.psm/projects.json`)
|
|
35
|
+
|
|
36
|
+
```json
|
|
37
|
+
{
|
|
38
|
+
"aliases": {
|
|
39
|
+
"omc": {
|
|
40
|
+
"repo": "Yeachan-Heo/oh-my-claudecode",
|
|
41
|
+
"local": "~/Workspace/oh-my-claudecode",
|
|
42
|
+
"default_base": "main"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"defaults": {
|
|
46
|
+
"worktree_root": "~/.psm/worktrees",
|
|
47
|
+
"cleanup_after_days": 14
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Directory Structure
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
~/.psm/
|
|
56
|
+
├── projects.json # Project aliases
|
|
57
|
+
├── sessions.json # Active session registry
|
|
58
|
+
└── worktrees/ # Worktree storage
|
|
59
|
+
└── <project>/
|
|
60
|
+
└── <type>-<id>/
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Session Naming
|
|
64
|
+
|
|
65
|
+
| Type | Tmux Session | Worktree Dir |
|
|
66
|
+
|------|--------------|--------------|
|
|
67
|
+
| PR Review | `psm:omc:pr-123` | `~/.psm/worktrees/omc/pr-123` |
|
|
68
|
+
| Issue Fix | `psm:omc:issue-42` | `~/.psm/worktrees/omc/issue-42` |
|
|
69
|
+
| Feature | `psm:omc:feat-auth` | `~/.psm/worktrees/omc/feat-auth` |
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Implementation Protocol
|
|
74
|
+
|
|
75
|
+
When the user invokes a PSM command, follow this protocol:
|
|
76
|
+
|
|
77
|
+
### Parse Arguments
|
|
78
|
+
|
|
79
|
+
Parse `{{ARGUMENTS}}` to determine:
|
|
80
|
+
1. **Subcommand**: review, fix, feature, list, attach, kill, cleanup, status
|
|
81
|
+
2. **Reference**: project#number, URL, or session ID
|
|
82
|
+
3. **Options**: --branch, --base, --no-claude, --no-tmux, etc.
|
|
83
|
+
|
|
84
|
+
### Subcommand: `review <ref>`
|
|
85
|
+
|
|
86
|
+
**Purpose**: Create PR review session
|
|
87
|
+
|
|
88
|
+
**Steps**:
|
|
89
|
+
|
|
90
|
+
1. **Resolve reference**:
|
|
91
|
+
```bash
|
|
92
|
+
# Read project aliases
|
|
93
|
+
cat ~/.psm/projects.json 2>/dev/null || echo '{"aliases":{}}'
|
|
94
|
+
|
|
95
|
+
# Parse ref format: alias#num, owner/repo#num, or URL
|
|
96
|
+
# Extract: project_alias, repo (owner/repo), pr_number, local_path
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
2. **Fetch PR info**:
|
|
100
|
+
```bash
|
|
101
|
+
gh pr view <pr_number> --repo <repo> --json number,title,author,headRefName,baseRefName,body,files,url
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
3. **Ensure local repo exists**:
|
|
105
|
+
```bash
|
|
106
|
+
# If local path doesn't exist, clone
|
|
107
|
+
if [[ ! -d "$local_path" ]]; then
|
|
108
|
+
git clone "https://github.com/$repo.git" "$local_path"
|
|
109
|
+
fi
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
4. **Create worktree**:
|
|
113
|
+
```bash
|
|
114
|
+
worktree_path="$HOME/.psm/worktrees/$project_alias/pr-$pr_number"
|
|
115
|
+
|
|
116
|
+
# Fetch PR branch
|
|
117
|
+
cd "$local_path"
|
|
118
|
+
git fetch origin "pull/$pr_number/head:pr-$pr_number-review"
|
|
119
|
+
|
|
120
|
+
# Create worktree
|
|
121
|
+
git worktree add "$worktree_path" "pr-$pr_number-review"
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
5. **Create session metadata**:
|
|
125
|
+
```bash
|
|
126
|
+
cat > "$worktree_path/.psm-session.json" << EOF
|
|
127
|
+
{
|
|
128
|
+
"id": "$project_alias:pr-$pr_number",
|
|
129
|
+
"type": "review",
|
|
130
|
+
"project": "$project_alias",
|
|
131
|
+
"ref": "pr-$pr_number",
|
|
132
|
+
"branch": "<head_branch>",
|
|
133
|
+
"base": "<base_branch>",
|
|
134
|
+
"created_at": "$(date -Iseconds)",
|
|
135
|
+
"tmux_session": "psm:$project_alias:pr-$pr_number",
|
|
136
|
+
"worktree_path": "$worktree_path",
|
|
137
|
+
"source_repo": "$local_path",
|
|
138
|
+
"github": {
|
|
139
|
+
"pr_number": $pr_number,
|
|
140
|
+
"pr_title": "<title>",
|
|
141
|
+
"pr_author": "<author>",
|
|
142
|
+
"pr_url": "<url>"
|
|
143
|
+
},
|
|
144
|
+
"state": "active"
|
|
145
|
+
}
|
|
146
|
+
EOF
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
6. **Update sessions registry**:
|
|
150
|
+
```bash
|
|
151
|
+
# Add to ~/.psm/sessions.json
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
7. **Create tmux session**:
|
|
155
|
+
```bash
|
|
156
|
+
tmux new-session -d -s "psm:$project_alias:pr-$pr_number" -c "$worktree_path"
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
8. **Launch Claude Code** (unless --no-claude):
|
|
160
|
+
```bash
|
|
161
|
+
tmux send-keys -t "psm:$project_alias:pr-$pr_number" "claude" Enter
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
9. **Output session info**:
|
|
165
|
+
```
|
|
166
|
+
Session ready!
|
|
167
|
+
|
|
168
|
+
ID: omc:pr-123
|
|
169
|
+
Worktree: ~/.psm/worktrees/omc/pr-123
|
|
170
|
+
Tmux: psm:omc:pr-123
|
|
171
|
+
|
|
172
|
+
To attach: tmux attach -t psm:omc:pr-123
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### Subcommand: `fix <ref>`
|
|
176
|
+
|
|
177
|
+
**Purpose**: Create issue fix session
|
|
178
|
+
|
|
179
|
+
**Steps**:
|
|
180
|
+
|
|
181
|
+
1. **Resolve reference** (same as review)
|
|
182
|
+
|
|
183
|
+
2. **Fetch issue info**:
|
|
184
|
+
```bash
|
|
185
|
+
gh issue view <issue_number> --repo <repo> --json number,title,body,labels,url
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
3. **Create feature branch**:
|
|
189
|
+
```bash
|
|
190
|
+
cd "$local_path"
|
|
191
|
+
git fetch origin main
|
|
192
|
+
branch_name="fix/$issue_number-$(echo "$title" | tr ' ' '-' | tr '[:upper:]' '[:lower:]' | head -c 30)"
|
|
193
|
+
git checkout -b "$branch_name" origin/main
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
4. **Create worktree**:
|
|
197
|
+
```bash
|
|
198
|
+
worktree_path="$HOME/.psm/worktrees/$project_alias/issue-$issue_number"
|
|
199
|
+
git worktree add "$worktree_path" "$branch_name"
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
5. **Create session metadata** (similar to review, type="fix")
|
|
203
|
+
|
|
204
|
+
6. **Update registry, create tmux, launch claude** (same as review)
|
|
205
|
+
|
|
206
|
+
### Subcommand: `feature <project> <name>`
|
|
207
|
+
|
|
208
|
+
**Purpose**: Start feature development
|
|
209
|
+
|
|
210
|
+
**Steps**:
|
|
211
|
+
|
|
212
|
+
1. **Resolve project** (from alias or path)
|
|
213
|
+
|
|
214
|
+
2. **Create feature branch**:
|
|
215
|
+
```bash
|
|
216
|
+
cd "$local_path"
|
|
217
|
+
git fetch origin main
|
|
218
|
+
branch_name="feature/$feature_name"
|
|
219
|
+
git checkout -b "$branch_name" origin/main
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
3. **Create worktree**:
|
|
223
|
+
```bash
|
|
224
|
+
worktree_path="$HOME/.psm/worktrees/$project_alias/feat-$feature_name"
|
|
225
|
+
git worktree add "$worktree_path" "$branch_name"
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
4. **Create session, tmux, launch claude** (same pattern)
|
|
229
|
+
|
|
230
|
+
### Subcommand: `list [project]`
|
|
231
|
+
|
|
232
|
+
**Purpose**: List active sessions
|
|
233
|
+
|
|
234
|
+
**Steps**:
|
|
235
|
+
|
|
236
|
+
1. **Read sessions registry**:
|
|
237
|
+
```bash
|
|
238
|
+
cat ~/.psm/sessions.json 2>/dev/null || echo '{"sessions":{}}'
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
2. **Check tmux sessions**:
|
|
242
|
+
```bash
|
|
243
|
+
tmux list-sessions -F "#{session_name}" 2>/dev/null | grep "^psm:"
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
3. **Check worktrees**:
|
|
247
|
+
```bash
|
|
248
|
+
ls -la ~/.psm/worktrees/*/ 2>/dev/null
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
4. **Format output**:
|
|
252
|
+
```
|
|
253
|
+
Active PSM Sessions:
|
|
254
|
+
|
|
255
|
+
ID | Type | Status | Worktree
|
|
256
|
+
-------------------|---------|----------|---------------------------
|
|
257
|
+
omc:pr-123 | review | active | ~/.psm/worktrees/omc/pr-123
|
|
258
|
+
omc:issue-42 | fix | detached | ~/.psm/worktrees/omc/issue-42
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Subcommand: `attach <session>`
|
|
262
|
+
|
|
263
|
+
**Purpose**: Attach to existing session
|
|
264
|
+
|
|
265
|
+
**Steps**:
|
|
266
|
+
|
|
267
|
+
1. **Parse session ID**: `project:type-number`
|
|
268
|
+
|
|
269
|
+
2. **Verify session exists**:
|
|
270
|
+
```bash
|
|
271
|
+
tmux has-session -t "psm:$session_id" 2>/dev/null
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
3. **Attach**:
|
|
275
|
+
```bash
|
|
276
|
+
tmux attach -t "psm:$session_id"
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Subcommand: `kill <session>`
|
|
280
|
+
|
|
281
|
+
**Purpose**: Kill session and cleanup
|
|
282
|
+
|
|
283
|
+
**Steps**:
|
|
284
|
+
|
|
285
|
+
1. **Kill tmux session**:
|
|
286
|
+
```bash
|
|
287
|
+
tmux kill-session -t "psm:$session_id" 2>/dev/null
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
2. **Remove worktree**:
|
|
291
|
+
```bash
|
|
292
|
+
worktree_path=$(jq -r ".sessions[\"$session_id\"].worktree" ~/.psm/sessions.json)
|
|
293
|
+
source_repo=$(jq -r ".sessions[\"$session_id\"].source_repo" ~/.psm/sessions.json)
|
|
294
|
+
|
|
295
|
+
cd "$source_repo"
|
|
296
|
+
git worktree remove "$worktree_path" --force
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
3. **Update registry**:
|
|
300
|
+
```bash
|
|
301
|
+
# Remove from sessions.json
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
### Subcommand: `cleanup`
|
|
305
|
+
|
|
306
|
+
**Purpose**: Clean up merged PRs and closed issues
|
|
307
|
+
|
|
308
|
+
**Steps**:
|
|
309
|
+
|
|
310
|
+
1. **Read all sessions**
|
|
311
|
+
|
|
312
|
+
2. **For each PR session, check if merged**:
|
|
313
|
+
```bash
|
|
314
|
+
gh pr view <pr_number> --repo <repo> --json merged,state
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
3. **For each issue session, check if closed**:
|
|
318
|
+
```bash
|
|
319
|
+
gh issue view <issue_number> --repo <repo> --json closed,state
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
4. **Clean up merged/closed sessions**:
|
|
323
|
+
- Kill tmux session
|
|
324
|
+
- Remove worktree
|
|
325
|
+
- Update registry
|
|
326
|
+
|
|
327
|
+
5. **Report**:
|
|
328
|
+
```
|
|
329
|
+
Cleanup complete:
|
|
330
|
+
Removed: omc:pr-123 (merged)
|
|
331
|
+
Removed: omc:issue-42 (closed)
|
|
332
|
+
Kept: omc:feat-auth (active)
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
### Subcommand: `status`
|
|
336
|
+
|
|
337
|
+
**Purpose**: Show current session info
|
|
338
|
+
|
|
339
|
+
**Steps**:
|
|
340
|
+
|
|
341
|
+
1. **Detect current session** from tmux or cwd:
|
|
342
|
+
```bash
|
|
343
|
+
tmux display-message -p "#{session_name}" 2>/dev/null
|
|
344
|
+
# or check if cwd is inside a worktree
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
2. **Read session metadata**:
|
|
348
|
+
```bash
|
|
349
|
+
cat .psm-session.json 2>/dev/null
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
3. **Show status**:
|
|
353
|
+
```
|
|
354
|
+
Current Session: omc:pr-123
|
|
355
|
+
Type: review
|
|
356
|
+
PR: #123 - Add webhook support
|
|
357
|
+
Branch: feature/webhooks
|
|
358
|
+
Created: 2 hours ago
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
---
|
|
362
|
+
|
|
363
|
+
## Error Handling
|
|
364
|
+
|
|
365
|
+
| Error | Resolution |
|
|
366
|
+
|-------|------------|
|
|
367
|
+
| Worktree exists | Offer: attach, recreate, or abort |
|
|
368
|
+
| PR not found | Verify URL/number, check permissions |
|
|
369
|
+
| No tmux | Warn and skip session creation |
|
|
370
|
+
| No gh CLI | Error with install instructions |
|
|
371
|
+
|
|
372
|
+
## Requirements
|
|
373
|
+
|
|
374
|
+
- `git` with worktree support (v2.5+)
|
|
375
|
+
- `gh` CLI (authenticated)
|
|
376
|
+
- `tmux`
|
|
377
|
+
- `jq` for JSON parsing
|
|
378
|
+
|
|
379
|
+
## Initialization
|
|
380
|
+
|
|
381
|
+
On first run, create default config:
|
|
382
|
+
|
|
383
|
+
```bash
|
|
384
|
+
mkdir -p ~/.psm/worktrees ~/.psm/logs
|
|
385
|
+
|
|
386
|
+
# Create default projects.json if not exists
|
|
387
|
+
if [[ ! -f ~/.psm/projects.json ]]; then
|
|
388
|
+
cat > ~/.psm/projects.json << 'EOF'
|
|
389
|
+
{
|
|
390
|
+
"aliases": {
|
|
391
|
+
"omc": {
|
|
392
|
+
"repo": "Yeachan-Heo/oh-my-claudecode",
|
|
393
|
+
"local": "~/Workspace/oh-my-claudecode",
|
|
394
|
+
"default_base": "main"
|
|
395
|
+
}
|
|
396
|
+
},
|
|
397
|
+
"defaults": {
|
|
398
|
+
"worktree_root": "~/.psm/worktrees",
|
|
399
|
+
"cleanup_after_days": 14,
|
|
400
|
+
"auto_cleanup_merged": true
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
EOF
|
|
404
|
+
fi
|
|
405
|
+
|
|
406
|
+
# Create sessions.json if not exists
|
|
407
|
+
if [[ ! -f ~/.psm/sessions.json ]]; then
|
|
408
|
+
echo '{"version":1,"sessions":{},"stats":{"total_created":0,"total_cleaned":0}}' > ~/.psm/sessions.json
|
|
409
|
+
fi
|
|
410
|
+
```
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# PSM Configuration Management
|
|
3
|
+
|
|
4
|
+
PSM_ROOT="${HOME}/.psm"
|
|
5
|
+
PSM_WORKTREES="${PSM_ROOT}/worktrees"
|
|
6
|
+
PSM_PROJECTS="${PSM_ROOT}/projects.json"
|
|
7
|
+
PSM_SESSIONS="${PSM_ROOT}/sessions.json"
|
|
8
|
+
PSM_LOGS="${PSM_ROOT}/logs"
|
|
9
|
+
|
|
10
|
+
# Initialize PSM directories and config files
|
|
11
|
+
psm_init() {
|
|
12
|
+
mkdir -p "$PSM_WORKTREES" "$PSM_LOGS"
|
|
13
|
+
|
|
14
|
+
# Create default projects.json if not exists
|
|
15
|
+
if [[ ! -f "$PSM_PROJECTS" ]]; then
|
|
16
|
+
cat > "$PSM_PROJECTS" << 'EOF'
|
|
17
|
+
{
|
|
18
|
+
"aliases": {
|
|
19
|
+
"omc": {
|
|
20
|
+
"repo": "Yeachan-Heo/oh-my-claudecode",
|
|
21
|
+
"local": "~/Workspace/oh-my-claudecode",
|
|
22
|
+
"default_base": "main"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"defaults": {
|
|
26
|
+
"worktree_root": "~/.psm/worktrees",
|
|
27
|
+
"cleanup_after_days": 14,
|
|
28
|
+
"auto_cleanup_merged": true
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
EOF
|
|
32
|
+
echo "Created default projects.json"
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
# Create sessions.json if not exists
|
|
36
|
+
if [[ ! -f "$PSM_SESSIONS" ]]; then
|
|
37
|
+
echo '{"version":1,"sessions":{},"stats":{"total_created":0,"total_cleaned":0}}' > "$PSM_SESSIONS"
|
|
38
|
+
echo "Created sessions.json"
|
|
39
|
+
fi
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
# Get project config by alias
|
|
43
|
+
# Usage: psm_get_project "omc"
|
|
44
|
+
# Returns: repo|local|default_base
|
|
45
|
+
psm_get_project() {
|
|
46
|
+
local alias="$1"
|
|
47
|
+
if [[ ! -f "$PSM_PROJECTS" ]]; then
|
|
48
|
+
return 1
|
|
49
|
+
fi
|
|
50
|
+
|
|
51
|
+
local repo=$(jq -r ".aliases[\"$alias\"].repo // empty" "$PSM_PROJECTS")
|
|
52
|
+
local local_path=$(jq -r ".aliases[\"$alias\"].local // empty" "$PSM_PROJECTS")
|
|
53
|
+
local default_base=$(jq -r ".aliases[\"$alias\"].default_base // \"main\"" "$PSM_PROJECTS")
|
|
54
|
+
|
|
55
|
+
if [[ -z "$repo" ]]; then
|
|
56
|
+
return 1
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
# Expand ~ to $HOME
|
|
60
|
+
local_path="${local_path/#\~/$HOME}"
|
|
61
|
+
|
|
62
|
+
echo "${repo}|${local_path}|${default_base}"
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# Add or update project alias
|
|
66
|
+
psm_set_project() {
|
|
67
|
+
local alias="$1"
|
|
68
|
+
local repo="$2"
|
|
69
|
+
local local_path="$3"
|
|
70
|
+
local default_base="${4:-main}"
|
|
71
|
+
|
|
72
|
+
local tmp=$(mktemp)
|
|
73
|
+
jq ".aliases[\"$alias\"] = {\"repo\": \"$repo\", \"local\": \"$local_path\", \"default_base\": \"$default_base\"}" \
|
|
74
|
+
"$PSM_PROJECTS" > "$tmp" && mv "$tmp" "$PSM_PROJECTS"
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
# Get default worktree root
|
|
78
|
+
psm_get_worktree_root() {
|
|
79
|
+
local root=$(jq -r '.defaults.worktree_root // "~/.psm/worktrees"' "$PSM_PROJECTS")
|
|
80
|
+
echo "${root/#\~/$HOME}"
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
# Get cleanup days setting
|
|
84
|
+
psm_get_cleanup_days() {
|
|
85
|
+
jq -r '.defaults.cleanup_after_days // 14' "$PSM_PROJECTS"
|
|
86
|
+
}
|