@sooink/ai-session-tidy 0.1.1
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/.prettierrc +7 -0
- package/LICENSE +21 -0
- package/README.ko.md +171 -0
- package/README.md +169 -0
- package/assets/demo-interactive.gif +0 -0
- package/assets/demo.gif +0 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1917 -0
- package/dist/index.js.map +1 -0
- package/eslint.config.js +29 -0
- package/package.json +54 -0
- package/src/cli.ts +21 -0
- package/src/commands/clean.ts +335 -0
- package/src/commands/config.ts +144 -0
- package/src/commands/list.ts +86 -0
- package/src/commands/scan.ts +200 -0
- package/src/commands/watch.ts +359 -0
- package/src/core/cleaner.test.ts +125 -0
- package/src/core/cleaner.ts +181 -0
- package/src/core/service.ts +236 -0
- package/src/core/trash.test.ts +100 -0
- package/src/core/trash.ts +40 -0
- package/src/core/watcher.test.ts +210 -0
- package/src/core/watcher.ts +194 -0
- package/src/index.ts +5 -0
- package/src/scanners/claude-code.test.ts +112 -0
- package/src/scanners/claude-code.ts +452 -0
- package/src/scanners/cursor.test.ts +140 -0
- package/src/scanners/cursor.ts +133 -0
- package/src/scanners/index.ts +39 -0
- package/src/scanners/types.ts +34 -0
- package/src/utils/config.ts +132 -0
- package/src/utils/logger.ts +29 -0
- package/src/utils/paths.test.ts +95 -0
- package/src/utils/paths.ts +92 -0
- package/src/utils/size.test.ts +80 -0
- package/src/utils/size.ts +50 -0
- package/tsconfig.json +28 -0
- package/tsup.config.ts +11 -0
- package/vitest.config.ts +14 -0
package/.prettierrc
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 sooink
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.ko.md
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# AI Session Tidy
|
|
4
|
+
|
|
5
|
+
**AI 코딩 도구의 방치된 세션을 정리합니다**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@sooink/ai-session-tidy)
|
|
8
|
+
[](https://nodejs.org/)
|
|
9
|
+
[](https://github.com/sooink/ai-session-tidy)
|
|
10
|
+
[](https://opensource.org/licenses/MIT)
|
|
11
|
+
|
|
12
|
+
[English](README.md) · [한국어](README.ko.md)
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 문제점
|
|
19
|
+
|
|
20
|
+
**Claude Code**나 **Cursor** 같은 AI 코딩 도구는 세션 데이터를 로컬에 저장합니다—대화 기록, 파일 스냅샷, Todo 등.
|
|
21
|
+
|
|
22
|
+
프로젝트를 삭제, 이동, 이름 변경하면 세션 데이터가 방치됩니다:
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
~/.claude/
|
|
26
|
+
├── projects/
|
|
27
|
+
│ ├── -Users-you-deleted-project/ # 👈 지난주 삭제한 프로젝트
|
|
28
|
+
│ ├── -Users-you-temp-worktree/ # 👈 제거한 worktree
|
|
29
|
+
│ └── -Users-you-renamed-project/ # 👈 이름 바꾼 프로젝트
|
|
30
|
+
├── todos/ # 방치된 Todo 파일
|
|
31
|
+
└── file-history/ # 방치된 Rewind 스냅샷
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Claude Code는 30일 후 오래된 세션을 삭제하지만, **Cursor는 자동 정리 기능이 없습니다.** Claude Code도 30일간은 방치된 데이터가 남아있습니다.
|
|
35
|
+
|
|
36
|
+
**이 도구는 방치된 세션을 즉시 찾아서 정리합니다.**
|
|
37
|
+
|
|
38
|
+
## 빠른 시작
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install -g @sooink/ai-session-tidy
|
|
42
|
+
|
|
43
|
+
ai-session-tidy # 방치된 세션 스캔
|
|
44
|
+
ai-session-tidy clean # 휴지통으로 이동
|
|
45
|
+
ai-session-tidy watch start # 자동 정리 데몬
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+

|
|
49
|
+
|
|
50
|
+
## 활용 사례
|
|
51
|
+
|
|
52
|
+
### Git Worktree 워크플로우
|
|
53
|
+
|
|
54
|
+
[Git worktree](https://git-scm.com/docs/git-worktree)로 여러 브랜치에서 동시에 작업할 수 있습니다. 하지만 worktree를 제거해도 세션 데이터는 남습니다.
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
git worktree add ../feature-branch feature
|
|
58
|
+
cd ../feature-branch && claude # 세션 데이터 생성
|
|
59
|
+
|
|
60
|
+
git worktree remove ../feature-branch
|
|
61
|
+
# ~/.claude/projects/-...-feature-branch/ 가 그대로 남음
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
**watch 모드를 사용하면** 자동으로 정리됩니다:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
ai-session-tidy watch start # 한 번 실행, 로그인 시 자동 시작
|
|
68
|
+
|
|
69
|
+
git worktree remove ../feature # watch가 감지 → 5분 후 정리
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### 멀티 에이전트 오케스트레이션
|
|
73
|
+
|
|
74
|
+
[최신 AI 워크플로우](https://www.anthropic.com/engineering/multi-agent-research-system)는 여러 에이전트를 병렬로 실행하며, 각각 격리된 worktree에서 작업합니다.
|
|
75
|
+
|
|
76
|
+
이로 인해 세션 데이터 축적이 배가됩니다. watch 모드가 시스템을 자동으로 깔끔하게 유지합니다.
|
|
77
|
+
|
|
78
|
+
## 지원 도구
|
|
79
|
+
|
|
80
|
+
| 도구 | 상태 |
|
|
81
|
+
|-----|------|
|
|
82
|
+
| Claude Code | ✅ 지원 |
|
|
83
|
+
| Cursor | ✅ 지원 |
|
|
84
|
+
|
|
85
|
+
## 명령어
|
|
86
|
+
|
|
87
|
+
### `scan` (기본)
|
|
88
|
+
|
|
89
|
+
삭제 없이 방치된 세션을 찾습니다.
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
ai-session-tidy # 기본 스캔
|
|
93
|
+
ai-session-tidy -v # 상세 출력
|
|
94
|
+
ai-session-tidy --json # JSON 출력
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### `clean`
|
|
98
|
+
|
|
99
|
+
방치된 세션을 삭제합니다.
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
ai-session-tidy clean # 휴지통으로 이동 (확인 필요)
|
|
103
|
+
ai-session-tidy clean -i # 대화형 선택
|
|
104
|
+
ai-session-tidy clean -f # 확인 생략
|
|
105
|
+
ai-session-tidy clean -n # 드라이런 (삭제 대상만 표시)
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+

|
|
109
|
+
|
|
110
|
+
### `watch`
|
|
111
|
+
|
|
112
|
+
감시하고 자동으로 정리합니다.
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
ai-session-tidy watch # 포그라운드 모드
|
|
116
|
+
ai-session-tidy watch start # 백그라운드 데몬 (로그인 시 자동 시작)
|
|
117
|
+
ai-session-tidy watch stop # 데몬 중지
|
|
118
|
+
ai-session-tidy watch status # 상태 확인
|
|
119
|
+
ai-session-tidy watch status -l # 최근 로그 표시
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
### `config`
|
|
123
|
+
|
|
124
|
+
설정을 관리합니다.
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
ai-session-tidy config show # 전체 설정 보기
|
|
128
|
+
ai-session-tidy config paths add ~/projects # 감시 경로 추가
|
|
129
|
+
ai-session-tidy config paths list # 감시 경로 목록
|
|
130
|
+
ai-session-tidy config delay 1 # 정리 딜레이 설정 (분)
|
|
131
|
+
ai-session-tidy config depth 5 # 감시 깊이 설정
|
|
132
|
+
ai-session-tidy config reset # 기본값으로 초기화
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## 정리 대상
|
|
136
|
+
|
|
137
|
+
### Claude Code
|
|
138
|
+
|
|
139
|
+
| 위치 | 설명 | 조건 |
|
|
140
|
+
|-----|------|-----|
|
|
141
|
+
| `~/.claude/projects/{path}/` | 세션 폴더 | 프로젝트 삭제됨 |
|
|
142
|
+
| `~/.claude.json` | Config 항목 | 프로젝트 삭제됨 |
|
|
143
|
+
| `~/.claude/session-env/{uuid}/` | 세션 환경 | 빈 폴더 |
|
|
144
|
+
| `~/.claude/todos/{uuid}-*.json` | Todo 파일 | 세션 없음 |
|
|
145
|
+
| `~/.claude/file-history/{uuid}/` | Rewind 스냅샷 | 세션 없음 |
|
|
146
|
+
|
|
147
|
+
### Cursor
|
|
148
|
+
|
|
149
|
+
| 위치 | 설명 | 조건 |
|
|
150
|
+
|-----|------|-----|
|
|
151
|
+
| `~/Library/.../workspaceStorage/{hash}/` | 워크스페이스 데이터 | 프로젝트 삭제됨 |
|
|
152
|
+
|
|
153
|
+
## 안전장치
|
|
154
|
+
|
|
155
|
+
> [!NOTE]
|
|
156
|
+
> 모든 작업은 기본적으로 안전합니다—명시적 조치 없이는 영구 삭제되지 않습니다.
|
|
157
|
+
|
|
158
|
+
- **스캔은 읽기 전용** — `scan`은 아무것도 삭제하지 않음
|
|
159
|
+
- **휴지통 우선** — `clean`은 휴지통으로 이동 (복구 가능)
|
|
160
|
+
- **확인 필요** — `-f` 없이는 삭제 전 확인
|
|
161
|
+
- **5분 딜레이** — watch 모드는 정리 전 대기 (설정 가능)
|
|
162
|
+
|
|
163
|
+
## 개발
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
git clone https://github.com/sooink/ai-session-tidy.git
|
|
167
|
+
cd ai-session-tidy
|
|
168
|
+
pnpm install
|
|
169
|
+
pnpm build
|
|
170
|
+
pnpm test
|
|
171
|
+
```
|
package/README.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# AI Session Tidy
|
|
4
|
+
|
|
5
|
+
**Clean up orphaned sessions from AI coding tools**
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@sooink/ai-session-tidy)
|
|
8
|
+
[](https://nodejs.org/)
|
|
9
|
+
[](https://github.com/sooink/ai-session-tidy)
|
|
10
|
+
[](https://opensource.org/licenses/MIT)
|
|
11
|
+
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## The Problem
|
|
17
|
+
|
|
18
|
+
AI coding tools like **Claude Code** and **Cursor** store session data locally—conversation history, file snapshots, todos, and more.
|
|
19
|
+
|
|
20
|
+
When you delete, move, or rename a project, the session data becomes orphaned:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
~/.claude/
|
|
24
|
+
├── projects/
|
|
25
|
+
│ ├── -Users-you-deleted-project/ # 👈 Project deleted last week
|
|
26
|
+
│ ├── -Users-you-temp-worktree/ # 👈 Worktree removed
|
|
27
|
+
│ └── -Users-you-renamed-project/ # 👈 Project renamed
|
|
28
|
+
├── todos/ # Orphaned todo files
|
|
29
|
+
└── file-history/ # Orphaned rewind snapshots
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
While Claude Code cleans up old sessions after 30 days, **Cursor has no automatic cleanup**. And even with Claude Code, you're left with orphaned data for up to a month.
|
|
33
|
+
|
|
34
|
+
**This tool finds and cleans up orphaned sessions immediately.**
|
|
35
|
+
|
|
36
|
+
## Quick Start
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install -g @sooink/ai-session-tidy
|
|
40
|
+
|
|
41
|
+
ai-session-tidy # Scan for orphaned sessions
|
|
42
|
+
ai-session-tidy clean # Move to trash
|
|
43
|
+
ai-session-tidy watch start # Auto-cleanup daemon
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
## Use Cases
|
|
49
|
+
|
|
50
|
+
### Git Worktree Workflows
|
|
51
|
+
|
|
52
|
+
[Git worktrees](https://git-scm.com/docs/git-worktree) let you work on multiple branches simultaneously. But when you remove a worktree, session data persists.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
git worktree add ../feature-branch feature
|
|
56
|
+
cd ../feature-branch && claude # Session data created
|
|
57
|
+
|
|
58
|
+
git worktree remove ../feature-branch
|
|
59
|
+
# ~/.claude/projects/-...-feature-branch/ still exists
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**With watch mode**, cleanup is automatic:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
ai-session-tidy watch start # Run once, auto-starts at login
|
|
66
|
+
|
|
67
|
+
git worktree remove ../feature # Watch detects → cleans after 5 min
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Multi-Agent Orchestration
|
|
71
|
+
|
|
72
|
+
[Modern AI workflows](https://www.anthropic.com/engineering/multi-agent-research-system) run multiple agents in parallel, each in isolated worktrees.
|
|
73
|
+
|
|
74
|
+
This multiplies session data accumulation. Watch mode keeps your system clean automatically.
|
|
75
|
+
|
|
76
|
+
## Supported Tools
|
|
77
|
+
|
|
78
|
+
| Tool | Status |
|
|
79
|
+
|------|--------|
|
|
80
|
+
| Claude Code | ✅ Supported |
|
|
81
|
+
| Cursor | ✅ Supported |
|
|
82
|
+
|
|
83
|
+
## Commands
|
|
84
|
+
|
|
85
|
+
### `scan` (default)
|
|
86
|
+
|
|
87
|
+
Find orphaned sessions without deleting.
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
ai-session-tidy # Basic scan
|
|
91
|
+
ai-session-tidy -v # Verbose output
|
|
92
|
+
ai-session-tidy --json # JSON output
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### `clean`
|
|
96
|
+
|
|
97
|
+
Remove orphaned sessions.
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
ai-session-tidy clean # Move to trash (with confirmation)
|
|
101
|
+
ai-session-tidy clean -i # Interactive selection
|
|
102
|
+
ai-session-tidy clean -f # Skip confirmation
|
|
103
|
+
ai-session-tidy clean -n # Dry-run (show what would be deleted)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+

|
|
107
|
+
|
|
108
|
+
### `watch`
|
|
109
|
+
|
|
110
|
+
Monitor and auto-clean.
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
ai-session-tidy watch # Foreground mode
|
|
114
|
+
ai-session-tidy watch start # Background daemon (auto-starts at login)
|
|
115
|
+
ai-session-tidy watch stop # Stop daemon
|
|
116
|
+
ai-session-tidy watch status # Check status
|
|
117
|
+
ai-session-tidy watch status -l # Show recent logs
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### `config`
|
|
121
|
+
|
|
122
|
+
Manage settings.
|
|
123
|
+
|
|
124
|
+
```bash
|
|
125
|
+
ai-session-tidy config show # Show all settings
|
|
126
|
+
ai-session-tidy config paths add ~/projects # Add watch path
|
|
127
|
+
ai-session-tidy config paths list # List watch paths
|
|
128
|
+
ai-session-tidy config delay 1 # Set cleanup delay (minutes)
|
|
129
|
+
ai-session-tidy config depth 5 # Set watch depth
|
|
130
|
+
ai-session-tidy config reset # Reset to defaults
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## What Gets Cleaned
|
|
134
|
+
|
|
135
|
+
### Claude Code
|
|
136
|
+
|
|
137
|
+
| Location | Description | Condition |
|
|
138
|
+
|----------|-------------|-----------|
|
|
139
|
+
| `~/.claude/projects/{path}/` | Session folders | Project deleted |
|
|
140
|
+
| `~/.claude.json` | Config entries | Project deleted |
|
|
141
|
+
| `~/.claude/session-env/{uuid}/` | Session environment | Empty folder |
|
|
142
|
+
| `~/.claude/todos/{uuid}-*.json` | Todo files | Session gone |
|
|
143
|
+
| `~/.claude/file-history/{uuid}/` | Rewind snapshots | Session gone |
|
|
144
|
+
|
|
145
|
+
### Cursor
|
|
146
|
+
|
|
147
|
+
| Location | Description | Condition |
|
|
148
|
+
|----------|-------------|-----------|
|
|
149
|
+
| `~/Library/.../workspaceStorage/{hash}/` | Workspace data | Project deleted |
|
|
150
|
+
|
|
151
|
+
## Safety
|
|
152
|
+
|
|
153
|
+
> [!NOTE]
|
|
154
|
+
> All operations are safe by default—nothing is permanently deleted without explicit action.
|
|
155
|
+
|
|
156
|
+
- **Scan is read-only** — `scan` never deletes anything
|
|
157
|
+
- **Trash first** — `clean` moves to trash (recoverable)
|
|
158
|
+
- **Confirmation required** — prompts before deletion unless `-f`
|
|
159
|
+
- **5-minute delay** — watch mode waits before cleanup (configurable)
|
|
160
|
+
|
|
161
|
+
## Development
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
git clone https://github.com/sooink/ai-session-tidy.git
|
|
165
|
+
cd ai-session-tidy
|
|
166
|
+
pnpm install
|
|
167
|
+
pnpm build
|
|
168
|
+
pnpm test
|
|
169
|
+
```
|
|
Binary file
|
package/assets/demo.gif
ADDED
|
Binary file
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|