z-clean 0.1.1 → 0.3.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/LICENSE +1 -1
- package/README.ko.md +118 -0
- package/README.md +241 -97
- package/README.zh.md +118 -0
- package/assets/zclean-hero.png +0 -0
- package/bin/zclean.js +95 -59
- package/package.json +45 -8
- package/src/audit-actions.js +88 -0
- package/src/audit-candidates.js +86 -0
- package/src/audit-history.js +69 -0
- package/src/audit-printer.js +83 -0
- package/src/audit-report.js +135 -0
- package/src/audit.js +35 -0
- package/src/cache.js +256 -0
- package/src/commands/scheduler.js +58 -0
- package/src/commands/trust.js +157 -0
- package/src/config.js +125 -20
- package/src/detector/orphan.js +21 -131
- package/src/detector/patterns.js +97 -14
- package/src/detector/whitelist.js +26 -105
- package/src/doctor/checks.js +229 -0
- package/src/doctor/render.js +37 -0
- package/src/doctor.js +22 -0
- package/src/installer/bin-path.js +106 -0
- package/src/installer/hook.js +15 -4
- package/src/installer/launchd.js +57 -28
- package/src/installer/systemd.js +18 -29
- package/src/installer/taskscheduler.js +29 -36
- package/src/killer.js +68 -52
- package/src/process-tree.js +338 -0
- package/src/reporter.js +61 -2
- package/src/scanner.js +97 -241
- package/src/windows-processes.js +257 -0
package/LICENSE
CHANGED
package/README.ko.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# zclean
|
|
2
|
+
|
|
3
|
+
**Claude Code, Codex, Cursor, Windsurf, MCP 서버, agent browser, 로컬 개발 캐시를 위한 AI 코딩 런타임 위생 CLI입니다.**
|
|
4
|
+
|
|
5
|
+
[English](README.md) | [한국어](README.ko.md) | [中文](README.zh.md)
|
|
6
|
+
|
|
7
|
+
## zclean이 해결하는 문제
|
|
8
|
+
|
|
9
|
+
AI 코딩 도구는 작업 중 많은 임시 런타임을 만듭니다.
|
|
10
|
+
|
|
11
|
+
- MCP 서버
|
|
12
|
+
- Claude Code sub-agent
|
|
13
|
+
- Codex sandbox
|
|
14
|
+
- headless browser / Playwright
|
|
15
|
+
- `npm exec`, `tsx`, `bun`, `deno`, Python helper
|
|
16
|
+
- Vite, Next.js, webpack, esbuild 같은 개발 서버와 watcher
|
|
17
|
+
|
|
18
|
+
세션이 종료되거나 강제 종료되면 일부 프로세스가 orphan/zombie처럼 남아 메모리, 포트, 파일 핸들을 계속 잡을 수 있습니다. `zclean`은 이런 잔재를 찾아 설명하고, 안전 조건을 통과한 경우에만 정리합니다.
|
|
19
|
+
|
|
20
|
+
## zclean이 하는 일
|
|
21
|
+
|
|
22
|
+
1. **AI 런타임 zombie process 정리**
|
|
23
|
+
- Claude Code, Codex, Cursor/Windsurf 계열 agent, MCP server, agent browser 잔재를 탐지합니다.
|
|
24
|
+
- 기본은 dry-run입니다.
|
|
25
|
+
- 실제 kill은 `--yes`가 있어야 합니다.
|
|
26
|
+
|
|
27
|
+
2. **안전한 workspace cache 정리**
|
|
28
|
+
- `.next/cache`
|
|
29
|
+
- `.turbo`
|
|
30
|
+
- `.vite`
|
|
31
|
+
- `.parcel-cache`
|
|
32
|
+
- `node_modules/.cache`
|
|
33
|
+
- `.pytest_cache`
|
|
34
|
+
- `.ruff_cache`
|
|
35
|
+
- `.mypy_cache`
|
|
36
|
+
- `__pycache__`
|
|
37
|
+
|
|
38
|
+
3. **리포트와 자동화용 JSON**
|
|
39
|
+
- `zclean report --json`
|
|
40
|
+
- `zclean history --json`
|
|
41
|
+
- `zclean cache --json`
|
|
42
|
+
- `zclean doctor --json`
|
|
43
|
+
|
|
44
|
+
## zclean이 하지 않는 일
|
|
45
|
+
|
|
46
|
+
`zclean`은 일반적인 시스템 클리너가 아닙니다.
|
|
47
|
+
|
|
48
|
+
- 앱을 삭제하지 않습니다.
|
|
49
|
+
- 전체 디스크를 훑지 않습니다.
|
|
50
|
+
- 문서/다운로드/사진 같은 사용자 파일을 건드리지 않습니다.
|
|
51
|
+
- 텔레메트리를 보내지 않습니다.
|
|
52
|
+
- 임의 폴더를 추측해서 지우지 않습니다.
|
|
53
|
+
|
|
54
|
+
목표는 좁고 명확합니다. **AI 코딩 런타임 정리와 개발 workspace cache hygiene**입니다.
|
|
55
|
+
|
|
56
|
+
## 설치
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm install -g z-clean
|
|
60
|
+
zclean init
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
설치 없이 1회 실행:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npx --yes z-clean
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 자주 쓰는 명령
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
zclean # zombie process dry-run scan
|
|
73
|
+
zclean --yes # 검증된 zombie process 정리
|
|
74
|
+
zclean report # 읽기 전용 hygiene report
|
|
75
|
+
zclean report --json # 자동화용 JSON report
|
|
76
|
+
zclean cache # workspace cache dry-run scan
|
|
77
|
+
zclean cache --yes # 지원되는 cache directory 삭제
|
|
78
|
+
zclean cache --json # cache 후보 JSON 출력
|
|
79
|
+
zclean history --json # 정리 이력 JSON
|
|
80
|
+
zclean protect list # 보호 목록 확인
|
|
81
|
+
zclean protect add mcp-server-keep
|
|
82
|
+
zclean doctor --json # 설치/탐지/스케줄러 상태 점검
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
다른 workspace cache를 확인하려면:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
zclean cache --path=/path/to/project
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## 안전 설계
|
|
92
|
+
|
|
93
|
+
- 기본은 dry-run입니다.
|
|
94
|
+
- 실제 정리는 `--yes`가 있어야 합니다.
|
|
95
|
+
- 살아 있는 parent process가 있으면 건드리지 않습니다.
|
|
96
|
+
- tmux, screen, PM2, Forever, Docker, VS Code child process는 보호합니다.
|
|
97
|
+
- kill 직전 PID identity를 다시 확인합니다.
|
|
98
|
+
- 프로세스 탐지 실패는 “깨끗함”으로 숨기지 않고 오류로 표시합니다.
|
|
99
|
+
- JSON 출력은 raw command와 로컬 절대경로 노출을 피합니다.
|
|
100
|
+
|
|
101
|
+
## 지원 플랫폼
|
|
102
|
+
|
|
103
|
+
| 플랫폼 | 상태 |
|
|
104
|
+
|--------|------|
|
|
105
|
+
| macOS | launchd scheduler, Claude Code hook, dry-run/cleanup |
|
|
106
|
+
| Linux | systemd user timer, Claude Code hook, dry-run/cleanup |
|
|
107
|
+
| Windows | Task Scheduler installer, 비파괴 CI coverage, `zclean doctor` 권장 |
|
|
108
|
+
|
|
109
|
+
## 제거
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
zclean uninstall
|
|
113
|
+
npm uninstall -g z-clean
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## 라이선스
|
|
117
|
+
|
|
118
|
+
MIT - [LICENSE](LICENSE)
|
package/README.md
CHANGED
|
@@ -1,120 +1,240 @@
|
|
|
1
|
+
# zclean
|
|
2
|
+
|
|
1
3
|
<div align="center">
|
|
2
4
|
|
|
3
5
|
<pre>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
███ ██ ██ █████ ███████ ██ ██ ██
|
|
7
|
-
███ ██ ██ ██ ██ ██ ██ ██ ██
|
|
8
|
-
███████ ██████ ███████ ███████ ██ ██ ██ ████
|
|
6
|
+
zclean
|
|
7
|
+
AI coding runtime hygiene
|
|
9
8
|
</pre>
|
|
10
9
|
|
|
11
|
-
**
|
|
10
|
+
**AI coding runtime hygiene for Claude Code, Codex, Cursor, Windsurf, MCP servers, agent browsers, and local dev caches.**
|
|
12
11
|
|
|
13
|
-
[](https://www.npmjs.com/package/z-clean)
|
|
13
|
+
[](https://www.npmjs.com/package/z-clean)
|
|
14
14
|
[](https://opensource.org/licenses/MIT)
|
|
15
|
-
[](#)
|
|
16
|
+
[](#platform-status)
|
|
17
|
+
[](#)
|
|
18
|
+
[](#)
|
|
19
|
+
[](https://github.com/TheStack-ai/zclean)
|
|
20
|
+
[](https://github.com/rohitg00/awesome-claude-code-toolkit)
|
|
21
|
+
|
|
22
|
+
[English](README.md) | [한국어](README.ko.md) | [中文](README.zh.md)
|
|
16
23
|
|
|
17
24
|
</div>
|
|
18
25
|
|
|
19
26
|
<p align="center">
|
|
20
|
-
<img src="assets/
|
|
27
|
+
<img src="assets/zclean-hero.png" alt="zclean AI coding runtime hygiene banner" width="960">
|
|
21
28
|
</p>
|
|
22
29
|
|
|
23
30
|
---
|
|
24
31
|
|
|
25
|
-
##
|
|
32
|
+
## What zclean is
|
|
33
|
+
|
|
34
|
+
`zclean` is a zero-dependency CLI that keeps AI coding sessions from leaving runtime mess behind.
|
|
35
|
+
|
|
36
|
+
It helps with two local hygiene problems:
|
|
37
|
+
|
|
38
|
+
1. **Zombie AI runtime processes**.
|
|
39
|
+
Orphaned MCP servers, sub-agents, headless browsers, package runners, sandboxes, and dev servers left behind by Claude Code, Codex, Cursor-style agents, Windsurf, and other AI coding tools.
|
|
40
|
+
|
|
41
|
+
2. **Safe workspace cache cleanup**.
|
|
42
|
+
Common project cache directories such as `.next/cache`, `.turbo`, `.vite`, `.parcel-cache`, `node_modules/.cache`, `.pytest_cache`, `.ruff_cache`, `.mypy_cache`, and Python `__pycache__`.
|
|
43
|
+
|
|
44
|
+
It is local-only, dry-run first, and requires `--yes` before destructive cleanup.
|
|
45
|
+
|
|
46
|
+
## What zclean is not
|
|
47
|
+
|
|
48
|
+
`zclean` is not an app uninstaller, system optimizer, disk map, telemetry agent, or whole-disk cleaner. It does not crawl your entire Mac, delete documents, remove applications, or touch arbitrary folders.
|
|
49
|
+
|
|
50
|
+
The goal is narrower: **AI coding cleanup and developer workspace hygiene**.
|
|
51
|
+
|
|
52
|
+
## Quick Start
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
npm install -g z-clean
|
|
56
|
+
zclean init
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
One-off dry run without installation:
|
|
26
60
|
|
|
27
|
-
|
|
61
|
+
```bash
|
|
62
|
+
npx --yes z-clean
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Review before cleaning:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
zclean report
|
|
69
|
+
zclean report --json
|
|
70
|
+
```
|
|
28
71
|
|
|
29
|
-
|
|
72
|
+
Clean only when you decide:
|
|
30
73
|
|
|
74
|
+
```bash
|
|
75
|
+
zclean --yes
|
|
76
|
+
zclean cache --yes
|
|
31
77
|
```
|
|
32
|
-
$ zclean
|
|
33
78
|
|
|
34
|
-
|
|
79
|
+
## Why developers use it
|
|
80
|
+
|
|
81
|
+
AI coding tools spawn many short-lived runtimes while they work:
|
|
82
|
+
|
|
83
|
+
- MCP servers
|
|
84
|
+
- Claude Code sub-agents
|
|
85
|
+
- Codex sandboxes
|
|
86
|
+
- headless Chromium or Playwright sessions
|
|
87
|
+
- `npm exec`, `tsx`, `bun`, `deno`, and Python helpers
|
|
88
|
+
- build watchers such as Vite, Next.js, webpack, and esbuild
|
|
89
|
+
|
|
90
|
+
When an agent crashes, a terminal closes, or a session ends abruptly, those child processes can keep running. They hold memory, ports, file handles, and CPU. zclean finds them, explains why they are candidates, and cleans them only when the safety checks pass.
|
|
91
|
+
|
|
92
|
+
## Core commands
|
|
93
|
+
|
|
94
|
+
| Command | What it does |
|
|
95
|
+
|---------|--------------|
|
|
96
|
+
| `zclean` | Dry-run scan for AI runtime zombie processes |
|
|
97
|
+
| `zclean --yes` | Kill verified zombie runtime processes |
|
|
98
|
+
| `zclean report` | Human-readable AI runtime hygiene report |
|
|
99
|
+
| `zclean report --json` | Machine-readable report for CI, local dashboards, or agents |
|
|
100
|
+
| `zclean audit` | Alias for `zclean report` |
|
|
101
|
+
| `zclean cache` | Dry-run scan for supported workspace cache directories |
|
|
102
|
+
| `zclean cache --yes` | Remove supported workspace cache directories |
|
|
103
|
+
| `zclean cache --json` | Machine-readable cache hygiene report |
|
|
104
|
+
| `zclean history` | Recent cleanup history |
|
|
105
|
+
| `zclean history --json` | Sanitized cleanup history and cumulative stats |
|
|
106
|
+
| `zclean protect list` | Show protected process patterns |
|
|
107
|
+
| `zclean protect add <entry>` | Add a protected process pattern |
|
|
108
|
+
| `zclean protect remove <entry>` | Remove a protected process pattern |
|
|
109
|
+
| `zclean protect remove --index=N` | Remove a protected entry by index |
|
|
110
|
+
| `zclean doctor` | Check hook, scheduler, config, and process enumeration health |
|
|
111
|
+
| `zclean doctor --json` | Structured health check output |
|
|
112
|
+
| `zclean init` | Install Claude Code hook and OS scheduler |
|
|
113
|
+
| `zclean status` | Show current zombie status and recent cleanup |
|
|
114
|
+
| `zclean logs` | Show detailed cleanup log |
|
|
115
|
+
| `zclean config` | Show current configuration |
|
|
116
|
+
| `zclean uninstall` | Remove hooks and schedulers |
|
|
117
|
+
|
|
118
|
+
## Runtime cleanup
|
|
119
|
+
|
|
120
|
+
Dry run:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
zclean
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Example output:
|
|
127
|
+
|
|
128
|
+
```text
|
|
129
|
+
zclean - scanning for zombie processes...
|
|
35
130
|
|
|
36
|
-
|
|
131
|
+
Found 12 zombie processes:
|
|
37
132
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
PID 23096 node 355 MB (orphan, 6h) was: claude sub-agent
|
|
42
|
-
... 8 more
|
|
133
|
+
PID 26413 node 367 MB 18h claude mcp-server
|
|
134
|
+
PID 62830 chrome 200 MB 3h agent-browser
|
|
135
|
+
PID 26221 npm 142 MB 2d npm exec task-master-ai
|
|
43
136
|
|
|
44
|
-
|
|
137
|
+
Total memory reclaimable: 2.4 GB
|
|
138
|
+
Run zclean --yes to clean up these processes.
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Actual cleanup:
|
|
45
142
|
|
|
46
|
-
|
|
143
|
+
```bash
|
|
144
|
+
zclean --yes
|
|
47
145
|
```
|
|
48
146
|
|
|
49
|
-
|
|
147
|
+
Safety rules:
|
|
148
|
+
|
|
149
|
+
- Manual scans are dry-run by default.
|
|
150
|
+
- Cleanup requires `--yes`.
|
|
151
|
+
- Active parent sessions are protected.
|
|
152
|
+
- tmux, screen, PM2, Forever, Docker, and VS Code child processes are skipped.
|
|
153
|
+
- PID identity is re-verified before every kill to avoid PID recycling accidents.
|
|
154
|
+
- Process enumeration failures are reported as errors, not as a fake "clean" state.
|
|
50
155
|
|
|
156
|
+
## Workspace cache cleanup
|
|
157
|
+
|
|
158
|
+
Dry run:
|
|
159
|
+
|
|
160
|
+
```bash
|
|
161
|
+
zclean cache
|
|
51
162
|
```
|
|
52
|
-
$ zclean --yes
|
|
53
163
|
|
|
54
|
-
|
|
164
|
+
Clean supported cache directories:
|
|
55
165
|
|
|
56
|
-
|
|
166
|
+
```bash
|
|
167
|
+
zclean cache --yes
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Scan another workspace:
|
|
57
171
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
SessionEnd hook: registered
|
|
61
|
-
Hourly scheduler: running
|
|
172
|
+
```bash
|
|
173
|
+
zclean cache --path=/path/to/project
|
|
62
174
|
```
|
|
63
175
|
|
|
64
|
-
|
|
176
|
+
Supported default cache targets:
|
|
65
177
|
|
|
66
|
-
|
|
178
|
+
| Cache path | Common source |
|
|
179
|
+
|------------|---------------|
|
|
180
|
+
| `.next/cache` | Next.js |
|
|
181
|
+
| `.nuxt` | Nuxt |
|
|
182
|
+
| `.turbo` | Turborepo |
|
|
183
|
+
| `.vite` | Vite |
|
|
184
|
+
| `.parcel-cache` | Parcel |
|
|
185
|
+
| `node_modules/.cache` | JavaScript tooling |
|
|
186
|
+
| `.pytest_cache` | pytest |
|
|
187
|
+
| `.ruff_cache` | Ruff |
|
|
188
|
+
| `.mypy_cache` | mypy |
|
|
189
|
+
| `__pycache__` | Python bytecode |
|
|
67
190
|
|
|
68
|
-
|
|
191
|
+
`zclean cache --json` emits relative paths only. It does not expose absolute local paths and does not remove anything unless `--yes` is present.
|
|
69
192
|
|
|
70
|
-
|
|
193
|
+
## Report and JSON surfaces
|
|
71
194
|
|
|
72
|
-
|
|
195
|
+
`zclean report --json` is designed for scripts, CI notes, local dashboards, and other agents:
|
|
73
196
|
|
|
74
197
|
```bash
|
|
75
|
-
|
|
198
|
+
zclean report --json
|
|
76
199
|
```
|
|
77
200
|
|
|
78
|
-
|
|
79
|
-
1. Detects your OS (macOS / Linux / Windows)
|
|
80
|
-
2. Registers a Claude Code `SessionEnd` hook for instant cleanup
|
|
81
|
-
3. Sets up an hourly background scan as a safety net
|
|
82
|
-
4. Creates your config at `~/.zclean/config.json`
|
|
201
|
+
The report includes:
|
|
83
202
|
|
|
84
|
-
|
|
203
|
+
- `schemaVersion: 1`
|
|
204
|
+
- AI runtime hygiene status
|
|
205
|
+
- candidate count and reclaimable memory
|
|
206
|
+
- top candidates by risk
|
|
207
|
+
- scan warnings and errors
|
|
208
|
+
- cleanup history summary
|
|
209
|
+
- safety guardrails
|
|
210
|
+
- recommended next actions
|
|
85
211
|
|
|
86
|
-
|
|
87
|
-
When a Claude Code session ends, `zclean` immediately cleans up that session's orphaned children. Fast and targeted.
|
|
212
|
+
Raw command lines and local filesystem paths are omitted from public JSON surfaces.
|
|
88
213
|
|
|
89
|
-
|
|
90
|
-
A lightweight background scan catches anything the hook missed: crash leftovers, Codex orphans, stale browser daemons, and processes from tools that don't support hooks.
|
|
214
|
+
## History, protection, and doctor
|
|
91
215
|
|
|
92
|
-
|
|
216
|
+
Machine-readable history:
|
|
93
217
|
|
|
94
|
-
|
|
218
|
+
```bash
|
|
219
|
+
zclean history --json
|
|
220
|
+
```
|
|
95
221
|
|
|
96
|
-
|
|
222
|
+
Protection list management:
|
|
97
223
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
- Logs every action with full command line for manual recovery
|
|
224
|
+
```bash
|
|
225
|
+
zclean protect list
|
|
226
|
+
zclean protect add "mcp-server-keep"
|
|
227
|
+
zclean protect remove "mcp-server-keep"
|
|
228
|
+
```
|
|
104
229
|
|
|
105
|
-
|
|
230
|
+
Health checks:
|
|
106
231
|
|
|
107
|
-
|
|
232
|
+
```bash
|
|
233
|
+
zclean doctor
|
|
234
|
+
zclean doctor --json
|
|
235
|
+
```
|
|
108
236
|
|
|
109
|
-
|
|
110
|
-
|---------|-------------|
|
|
111
|
-
| `zclean` | Scan for zombies (dry-run, shows what would be cleaned) |
|
|
112
|
-
| `zclean --yes` | Scan and clean zombie processes |
|
|
113
|
-
| `zclean init` | Install SessionEnd hook + hourly scheduler |
|
|
114
|
-
| `zclean status` | Show protection status and cleanup history |
|
|
115
|
-
| `zclean logs` | View detailed cleanup log |
|
|
116
|
-
| `zclean config` | Show current configuration |
|
|
117
|
-
| `zclean uninstall` | Remove all hooks and schedulers |
|
|
237
|
+
`doctor --json` exits `0` only when the setup is healthy. Warnings and errors exit `1` so automation can treat non-healthy states honestly.
|
|
118
238
|
|
|
119
239
|
## Configuration
|
|
120
240
|
|
|
@@ -125,62 +245,86 @@ Your `node server.js` running in a terminal tab? Untouched. Your `vite dev` in t
|
|
|
125
245
|
"whitelist": [],
|
|
126
246
|
"maxAge": "24h",
|
|
127
247
|
"memoryThreshold": "500MB",
|
|
128
|
-
"
|
|
248
|
+
"maxKillBatch": 20,
|
|
129
249
|
"sigterm_timeout": 10,
|
|
130
250
|
"dryRunDefault": true,
|
|
131
|
-
"logRetention": "30d"
|
|
251
|
+
"logRetention": "30d",
|
|
252
|
+
"customAiDirs": []
|
|
132
253
|
}
|
|
133
254
|
```
|
|
134
255
|
|
|
135
256
|
| Option | Default | Description |
|
|
136
257
|
|--------|---------|-------------|
|
|
137
|
-
| `whitelist` | `[]` | Process name patterns to never kill |
|
|
138
|
-
| `maxAge` | `"24h"` |
|
|
139
|
-
| `memoryThreshold` | `"500MB"` | Flag orphans above this
|
|
258
|
+
| `whitelist` | `[]` | Process name patterns to never kill; manage with `zclean protect` |
|
|
259
|
+
| `maxAge` | `"24h"` | Flag orphaned AI-path runtime processes only after this age |
|
|
260
|
+
| `memoryThreshold` | `"500MB"` | Flag AI-path runtime orphans above this memory usage |
|
|
261
|
+
| `maxKillBatch` | `20` | Maximum process kills per invocation |
|
|
140
262
|
| `sigterm_timeout` | `10` | Seconds to wait after SIGTERM before SIGKILL |
|
|
141
|
-
| `dryRunDefault` | `true` | Manual
|
|
263
|
+
| `dryRunDefault` | `true` | Manual scans stay dry-run by default; cleanup still requires `--yes` |
|
|
264
|
+
| `logRetention` | `"30d"` | Cleanup history retention |
|
|
265
|
+
| `customAiDirs` | `[]` | Additional AI tool directories to detect, such as `[".mytool"]` |
|
|
266
|
+
|
|
267
|
+
## Supported tools
|
|
268
|
+
|
|
269
|
+
| Tool or runtime | Coverage |
|
|
270
|
+
|-----------------|----------|
|
|
271
|
+
| Claude Code | MCP servers, sub-agents, sessions, agent browsers, Playwright |
|
|
272
|
+
| Codex | `codex exec`, Codex sandboxes |
|
|
273
|
+
| Cursor and Windsurf-style agents | AI-path runtime leftovers and browser helpers |
|
|
274
|
+
| Aider | Orphaned Aider/Python processes |
|
|
275
|
+
| Gemini CLI | Orphaned Gemini processes |
|
|
276
|
+
| MCP servers | `mcp-server-*` patterns |
|
|
277
|
+
| JavaScript runtimes | `node`, `tsx`, `ts-node`, `bun`, `deno` on AI paths |
|
|
278
|
+
| Build tools | Vite, Next.js, webpack, esbuild on AI paths |
|
|
279
|
+
| Workspace caches | Next.js, Nuxt, Turborepo, Vite, Parcel, Python, JS tooling caches |
|
|
280
|
+
|
|
281
|
+
## Platform status
|
|
282
|
+
|
|
283
|
+
| Platform | Status |
|
|
284
|
+
|----------|--------|
|
|
285
|
+
| macOS | launchd scheduler, Claude Code hook, dry-run and cleanup paths |
|
|
286
|
+
| Linux | systemd user timer, Claude Code hook, dry-run and cleanup paths |
|
|
287
|
+
| Windows | Task Scheduler installer and non-destructive CI coverage; run `zclean doctor` after install to confirm local scheduler and process enumeration health |
|
|
142
288
|
|
|
143
289
|
## FAQ
|
|
144
290
|
|
|
145
|
-
### Will
|
|
146
|
-
|
|
291
|
+
### Will zclean kill my running Claude Code session?
|
|
292
|
+
|
|
293
|
+
Manual and scheduled scans protect active sessions by checking whether the parent process is alive. The Claude Code `SessionEnd` hook passes `--session-pid` so cleanup is scoped to descendants of the session that just ended.
|
|
294
|
+
|
|
295
|
+
### Will zclean delete my project files?
|
|
296
|
+
|
|
297
|
+
No. Runtime cleanup kills verified zombie processes. Cache cleanup only removes supported cache directories and only with `zclean cache --yes`.
|
|
298
|
+
|
|
299
|
+
### Is zclean a general Mac cleaner?
|
|
300
|
+
|
|
301
|
+
No. zclean focuses on AI coding runtime cleanup and safe developer workspace cache cleanup. It does not uninstall apps, draw disk maps, or scan the whole disk.
|
|
147
302
|
|
|
148
|
-
###
|
|
149
|
-
If you started it in a terminal, tmux, or VS Code — it has a living parent and won't be touched. Only orphaned dev servers (parent process dead for 24h+) are candidates.
|
|
303
|
+
### Does the scheduler slow my machine?
|
|
150
304
|
|
|
151
|
-
|
|
152
|
-
|
|
305
|
+
No. The scheduler runs a single scan and exits. There is no persistent background daemon.
|
|
306
|
+
|
|
307
|
+
### How do I remove zclean?
|
|
153
308
|
|
|
154
|
-
### How do I stop zclean completely?
|
|
155
309
|
```bash
|
|
156
310
|
zclean uninstall
|
|
157
|
-
npm uninstall -g
|
|
311
|
+
npm uninstall -g z-clean
|
|
158
312
|
```
|
|
159
313
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
| Tool | Cleanup Coverage |
|
|
163
|
-
|------|-----------------|
|
|
164
|
-
| Claude Code | MCP servers, sub-agents, agent-browser, playwright |
|
|
165
|
-
| Codex | codex exec, background node workers |
|
|
166
|
-
| Build tools | esbuild, vite, webpack, next dev (orphaned only) |
|
|
167
|
-
| MCP servers | Any `mcp-server-*` pattern |
|
|
168
|
-
| Runtimes | node, tsx, ts-node, bun, deno, python (AI tool paths only) |
|
|
314
|
+
If you only used `npx --yes z-clean`, there is no global package to uninstall.
|
|
169
315
|
|
|
170
316
|
## Contributing
|
|
171
317
|
|
|
172
|
-
See [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
318
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
173
319
|
|
|
174
|
-
Adding a
|
|
320
|
+
Adding a process pattern? Edit `src/detector/patterns.js`.
|
|
321
|
+
|
|
322
|
+
Adding a cache target? Keep it deterministic, workspace-scoped, and dry-run first.
|
|
175
323
|
|
|
176
324
|
## License
|
|
177
325
|
|
|
178
|
-
MIT
|
|
326
|
+
MIT - see [LICENSE](LICENSE).
|
|
179
327
|
|
|
180
328
|
---
|
|
181
329
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
Built by [whynowlab](https://github.com/whynowlab) — the team behind [Swing](https://github.com/whynowlab/swing-skills).
|
|
185
|
-
|
|
186
|
-
</div>
|
|
330
|
+
Built by [TheStack-ai](https://github.com/TheStack-ai).
|
package/README.zh.md
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
# zclean
|
|
2
|
+
|
|
3
|
+
**面向 Claude Code、Codex、Cursor、Windsurf、MCP server、agent browser 和本地开发缓存的 AI 编程运行时清理 CLI。**
|
|
4
|
+
|
|
5
|
+
[English](README.md) | [한국어](README.ko.md) | [中文](README.zh.md)
|
|
6
|
+
|
|
7
|
+
## zclean 解决什么问题
|
|
8
|
+
|
|
9
|
+
AI 编程工具在工作时会启动很多临时运行时:
|
|
10
|
+
|
|
11
|
+
- MCP server
|
|
12
|
+
- Claude Code sub-agent
|
|
13
|
+
- Codex sandbox
|
|
14
|
+
- headless browser / Playwright
|
|
15
|
+
- `npm exec`、`tsx`、`bun`、`deno`、Python helper
|
|
16
|
+
- Vite、Next.js、webpack、esbuild 等开发服务器和 watcher
|
|
17
|
+
|
|
18
|
+
当会话崩溃、终端关闭或 agent 强制退出时,一些子进程可能会继续运行,占用内存、端口、CPU 和文件句柄。`zclean` 会找出这些候选项,解释原因,并且只在你明确确认后清理。
|
|
19
|
+
|
|
20
|
+
## zclean 可以做什么
|
|
21
|
+
|
|
22
|
+
1. **清理 AI 运行时 zombie process**
|
|
23
|
+
- 覆盖 Claude Code、Codex、Cursor/Windsurf 类 agent、MCP server、agent browser 等遗留进程。
|
|
24
|
+
- 默认只做 dry-run。
|
|
25
|
+
- 只有传入 `--yes` 才会真正清理。
|
|
26
|
+
|
|
27
|
+
2. **安全清理 workspace cache**
|
|
28
|
+
- `.next/cache`
|
|
29
|
+
- `.turbo`
|
|
30
|
+
- `.vite`
|
|
31
|
+
- `.parcel-cache`
|
|
32
|
+
- `node_modules/.cache`
|
|
33
|
+
- `.pytest_cache`
|
|
34
|
+
- `.ruff_cache`
|
|
35
|
+
- `.mypy_cache`
|
|
36
|
+
- `__pycache__`
|
|
37
|
+
|
|
38
|
+
3. **提供报告和自动化 JSON**
|
|
39
|
+
- `zclean report --json`
|
|
40
|
+
- `zclean history --json`
|
|
41
|
+
- `zclean cache --json`
|
|
42
|
+
- `zclean doctor --json`
|
|
43
|
+
|
|
44
|
+
## zclean 不是什么
|
|
45
|
+
|
|
46
|
+
`zclean` 不是通用系统清理器。
|
|
47
|
+
|
|
48
|
+
- 不卸载应用。
|
|
49
|
+
- 不扫描整个磁盘。
|
|
50
|
+
- 不删除文档、下载、照片等用户文件。
|
|
51
|
+
- 不发送遥测数据。
|
|
52
|
+
- 不猜测并删除任意文件夹。
|
|
53
|
+
|
|
54
|
+
它的定位很明确:**AI 编程运行时清理和开发 workspace cache hygiene**。
|
|
55
|
+
|
|
56
|
+
## 安装
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npm install -g z-clean
|
|
60
|
+
zclean init
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
无需安装的一次性运行:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
npx --yes z-clean
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## 常用命令
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
zclean # zombie process dry-run scan
|
|
73
|
+
zclean --yes # 清理已验证的 zombie process
|
|
74
|
+
zclean report # 只读 hygiene report
|
|
75
|
+
zclean report --json # 自动化 JSON report
|
|
76
|
+
zclean cache # workspace cache dry-run scan
|
|
77
|
+
zclean cache --yes # 删除支持的 cache directory
|
|
78
|
+
zclean cache --json # 输出 cache 候选 JSON
|
|
79
|
+
zclean history --json # 清理历史 JSON
|
|
80
|
+
zclean protect list # 查看保护列表
|
|
81
|
+
zclean protect add mcp-server-keep
|
|
82
|
+
zclean doctor --json # 检查安装、调度器和进程枚举状态
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
扫描另一个 workspace:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
zclean cache --path=/path/to/project
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## 安全设计
|
|
92
|
+
|
|
93
|
+
- 默认 dry-run。
|
|
94
|
+
- 真正清理需要 `--yes`。
|
|
95
|
+
- 如果父进程仍然存在,不会触碰该进程。
|
|
96
|
+
- 保护 tmux、screen、PM2、Forever、Docker、VS Code child process。
|
|
97
|
+
- kill 前会重新验证 PID identity,降低 PID recycling 风险。
|
|
98
|
+
- 进程枚举失败会报告错误,不会伪装成“系统干净”。
|
|
99
|
+
- JSON 输出避免暴露 raw command 和本地绝对路径。
|
|
100
|
+
|
|
101
|
+
## 平台状态
|
|
102
|
+
|
|
103
|
+
| 平台 | 状态 |
|
|
104
|
+
|------|------|
|
|
105
|
+
| macOS | launchd scheduler、Claude Code hook、dry-run/cleanup |
|
|
106
|
+
| Linux | systemd user timer、Claude Code hook、dry-run/cleanup |
|
|
107
|
+
| Windows | Task Scheduler installer、非破坏性 CI coverage,建议运行 `zclean doctor` |
|
|
108
|
+
|
|
109
|
+
## 卸载
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
zclean uninstall
|
|
113
|
+
npm uninstall -g z-clean
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## 许可证
|
|
117
|
+
|
|
118
|
+
MIT - [LICENSE](LICENSE)
|
|
Binary file
|