@thanaen/worktree-cleanup 0.1.0

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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +72 -0
  3. package/package.json +67 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Thanaen
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.md ADDED
@@ -0,0 +1,72 @@
1
+ # worktree-cleanup
2
+
3
+ Safely remove stale Git worktrees created by coding agents and other tooling.
4
+ The command is conservative: a worktree must be registered, clean, unlocked,
5
+ and already merged into a trusted base branch before it can be offered for
6
+ deletion.
7
+
8
+ > The npm package will be published as `@thanaen/worktree-cleanup`. npm package
9
+ > scopes are lowercase even though the GitHub account is displayed as Thanaen.
10
+
11
+ ## Install
12
+
13
+ ```bash
14
+ pnpm add -g @thanaen/worktree-cleanup
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```bash
20
+ # Inspect smart defaults below the current directory
21
+ worktree-cleanup
22
+
23
+ # Equivalent shorter executable
24
+ worktree-clean
25
+
26
+ # Inspect exactly one root and ignore smart defaults
27
+ worktree-cleanup --dir ../agent-worktrees
28
+
29
+ # Approve the displayed plan without prompting
30
+ worktree-cleanup --yes
31
+ ```
32
+
33
+ Smart defaults are `worktrees`, `.claude/worktrees`, and `.codex/worktrees`.
34
+ Only their immediate child directories are inspected.
35
+
36
+ The command never force-removes a worktree and never deletes its branch. It
37
+ asks once before deletion unless `-y` or `--yes` is passed. If stdin is not an
38
+ interactive terminal, `--yes` is required.
39
+
40
+ ## What counts as stale?
41
+
42
+ A worktree is removable only when all of these are true:
43
+
44
+ - Git lists it as a registered worktree.
45
+ - It is not the main or currently executing worktree.
46
+ - It is unlocked and clean, including untracked files.
47
+ - Its HEAD is an ancestor of the detected base ref.
48
+
49
+ Base detection prefers `origin/HEAD`, then local `main`, local `master`, and
50
+ finally the main worktree's current branch. Uncertain state is always skipped.
51
+ Every candidate is revalidated immediately before removal.
52
+
53
+ ## Development
54
+
55
+ This repository follows GitHub Spec Kit. The feature contract is in
56
+ `specs/001-core-cleanup/`. Effect's official source is vendored under `repos/`
57
+ as a Git subtree and used as read-only reference material.
58
+
59
+ ```bash
60
+ pnpm install
61
+ pnpm check
62
+ ```
63
+
64
+ To update the Effect reference subtree:
65
+
66
+ ```bash
67
+ git subtree pull --prefix=repos https://github.com/Effect-TS/effect.git main --squash
68
+ ```
69
+
70
+ ## License
71
+
72
+ MIT
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@thanaen/worktree-cleanup",
3
+ "version": "0.1.0",
4
+ "description": "Safely discover and remove stale Git worktrees.",
5
+ "keywords": [
6
+ "cleanup",
7
+ "effect",
8
+ "git",
9
+ "worktree"
10
+ ],
11
+ "homepage": "https://github.com/Thanaen/worktree-cleanup#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/Thanaen/worktree-cleanup/issues"
14
+ },
15
+ "license": "MIT",
16
+ "author": "Thanaen",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/Thanaen/worktree-cleanup.git"
20
+ },
21
+ "bin": {
22
+ "worktree-clean": "dist/main.mjs",
23
+ "worktree-cleanup": "dist/main.mjs"
24
+ },
25
+ "files": [
26
+ "dist",
27
+ "README.md",
28
+ "LICENSE"
29
+ ],
30
+ "type": "module",
31
+ "exports": {
32
+ ".": {
33
+ "types": "./dist/index.d.mts",
34
+ "import": "./dist/index.mjs"
35
+ }
36
+ },
37
+ "publishConfig": {
38
+ "access": "public",
39
+ "provenance": true
40
+ },
41
+ "dependencies": {
42
+ "@effect/platform-node": "4.0.0-rc.108",
43
+ "effect": "4.0.0-rc.108"
44
+ },
45
+ "devDependencies": {
46
+ "@effect/tsgo": "0.36.4",
47
+ "@effect/vitest": "4.0.0-rc.108",
48
+ "@types/node": "26.2.0",
49
+ "oxfmt": "0.63.0",
50
+ "tsdown": "0.22.14",
51
+ "typescript": "7.0.2",
52
+ "vitest": "4.1.10"
53
+ },
54
+ "engines": {
55
+ "node": ">=22"
56
+ },
57
+ "scripts": {
58
+ "build": "tsdown",
59
+ "check": "pnpm format:check && pnpm diagnostics && pnpm typecheck && pnpm test && pnpm build",
60
+ "diagnostics": "effect-tsgo diagnostics --project tsconfig.json",
61
+ "format": "oxfmt --ignore-path=.oxfmtignore .",
62
+ "format:check": "oxfmt --check --ignore-path=.oxfmtignore .",
63
+ "test": "vitest run",
64
+ "test:watch": "vitest",
65
+ "typecheck": "tsc --noEmit -p tsconfig.json"
66
+ }
67
+ }