mintree 0.1.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/README.md +188 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +12 -0
- package/dist/commands/dashboard.d.ts +2 -0
- package/dist/commands/dashboard.js +849 -0
- package/dist/commands/doctor.d.ts +2 -0
- package/dist/commands/doctor.js +327 -0
- package/dist/commands/helpers/index.d.ts +1 -0
- package/dist/commands/helpers/index.js +1 -0
- package/dist/commands/helpers/session-signal/end.d.ts +2 -0
- package/dist/commands/helpers/session-signal/end.js +9 -0
- package/dist/commands/helpers/session-signal/index.d.ts +1 -0
- package/dist/commands/helpers/session-signal/index.js +1 -0
- package/dist/commands/helpers/session-signal/install.d.ts +2 -0
- package/dist/commands/helpers/session-signal/install.js +25 -0
- package/dist/commands/helpers/session-signal/notification.d.ts +2 -0
- package/dist/commands/helpers/session-signal/notification.js +9 -0
- package/dist/commands/helpers/session-signal/prompt.d.ts +2 -0
- package/dist/commands/helpers/session-signal/prompt.js +9 -0
- package/dist/commands/helpers/session-signal/stop.d.ts +2 -0
- package/dist/commands/helpers/session-signal/stop.js +9 -0
- package/dist/commands/helpers/shell-init.d.ts +11 -0
- package/dist/commands/helpers/shell-init.js +111 -0
- package/dist/commands/index.d.ts +2 -0
- package/dist/commands/index.js +6 -0
- package/dist/commands/init.d.ts +2 -0
- package/dist/commands/init.js +129 -0
- package/dist/commands/worktree/clean.d.ts +11 -0
- package/dist/commands/worktree/clean.js +206 -0
- package/dist/commands/worktree/create.d.ts +18 -0
- package/dist/commands/worktree/create.js +93 -0
- package/dist/commands/worktree/index.d.ts +1 -0
- package/dist/commands/worktree/index.js +1 -0
- package/dist/commands/worktree/list.d.ts +10 -0
- package/dist/commands/worktree/list.js +143 -0
- package/dist/commands/worktree/remove.d.ts +12 -0
- package/dist/commands/worktree/remove.js +46 -0
- package/dist/commands/worktree/work.d.ts +15 -0
- package/dist/commands/worktree/work.js +192 -0
- package/dist/lib/branch.d.ts +26 -0
- package/dist/lib/branch.js +57 -0
- package/dist/lib/claude.d.ts +26 -0
- package/dist/lib/claude.js +67 -0
- package/dist/lib/dashboard.d.ts +50 -0
- package/dist/lib/dashboard.js +139 -0
- package/dist/lib/exec.d.ts +2 -0
- package/dist/lib/exec.js +15 -0
- package/dist/lib/git.d.ts +110 -0
- package/dist/lib/git.js +320 -0
- package/dist/lib/github.d.ts +7 -0
- package/dist/lib/github.js +15 -0
- package/dist/lib/markers.d.ts +21 -0
- package/dist/lib/markers.js +43 -0
- package/dist/lib/metadata.d.ts +18 -0
- package/dist/lib/metadata.js +44 -0
- package/dist/lib/session-signal.d.ts +63 -0
- package/dist/lib/session-signal.js +160 -0
- package/dist/lib/worktreeCreate.d.ts +36 -0
- package/dist/lib/worktreeCreate.js +184 -0
- package/dist/lib/worktreeRemove.d.ts +21 -0
- package/dist/lib/worktreeRemove.js +84 -0
- package/package.json +63 -0
- package/shell/init.bash +106 -0
- package/shell/init.zsh +125 -0
package/shell/init.zsh
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
# Mintree Shell Integration for Zsh
|
|
2
|
+
# ==================================
|
|
3
|
+
#
|
|
4
|
+
# Generated by `mintree helpers shell-init zsh`. Eval this in your ~/.zshrc:
|
|
5
|
+
# eval "$(mintree helpers shell-init zsh)"
|
|
6
|
+
#
|
|
7
|
+
# What it does:
|
|
8
|
+
# 1. Wraps the `mintree` binary so the parent shell can `cd` into a freshly
|
|
9
|
+
# created worktree. The binary itself can't change the parent's cwd, so
|
|
10
|
+
# it emits `MINTREE_CD:<path>` markers on stdout that this wrapper picks
|
|
11
|
+
# up and translates into a real `cd`.
|
|
12
|
+
# 2. When `worktree create --work` is used, also reads `MINTREE_WORK:1`,
|
|
13
|
+
# `MINTREE_WORK_PROMPT_FILE:<path>`, and `MINTREE_PERMISSION_MODE:<mode>`
|
|
14
|
+
# and chains a `mintree worktree work` invocation right after the cd.
|
|
15
|
+
# 3. Recovers the current shell when its cwd was deleted (e.g. after
|
|
16
|
+
# `mintree worktree remove`) — falls back to the main repo, then to $HOME.
|
|
17
|
+
# 4. Exposes the `mt` / `mtw` / `mtn` aliases (`mtn` prompts for a branch).
|
|
18
|
+
# 5. Exports MINTREE_SHELL_INTEGRATION=1 so `mintree doctor` can verify the
|
|
19
|
+
# wrapper is loaded.
|
|
20
|
+
|
|
21
|
+
export MINTREE_SHELL_INTEGRATION=1
|
|
22
|
+
|
|
23
|
+
function mintree() {
|
|
24
|
+
# Recover from a deleted cwd. If the current directory was a mintree
|
|
25
|
+
# worktree that was just removed, return to the main repo; otherwise
|
|
26
|
+
# bounce to $HOME so subsequent commands don't error out cryptically.
|
|
27
|
+
if [[ ! -d "$(pwd 2>/dev/null)" ]]; then
|
|
28
|
+
local current_path="$(pwd 2>/dev/null)"
|
|
29
|
+
if [[ "$current_path" == */.mintree/worktrees/* ]]; then
|
|
30
|
+
local main_repo="${current_path%%/.mintree/worktrees/*}"
|
|
31
|
+
if [[ -d "$main_repo" ]]; then
|
|
32
|
+
echo "⚠ Worktree directory deleted. Returning to main repo."
|
|
33
|
+
cd "$main_repo" || cd ~ || return 1
|
|
34
|
+
else
|
|
35
|
+
cd ~ || return 1
|
|
36
|
+
fi
|
|
37
|
+
else
|
|
38
|
+
echo "⚠ Current directory no longer exists. Returning to home."
|
|
39
|
+
cd ~ || return 1
|
|
40
|
+
fi
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
# Walks a marker block (whatever `worktree create` emitted, captured into
|
|
44
|
+
# $1 with no ANSI) and turns the markers into shell side-effects: cd to
|
|
45
|
+
# the new worktree, then optionally chain `worktree work` with the right
|
|
46
|
+
# flags. Returns 0 when the cd succeeded, 1 when there was nothing to do.
|
|
47
|
+
_mintree_handle_markers() {
|
|
48
|
+
local clean_output="$1"
|
|
49
|
+
local target_dir
|
|
50
|
+
target_dir=$(echo "$clean_output" | grep "MINTREE_CD:" | sed 's/.*MINTREE_CD://')
|
|
51
|
+
if [[ -z "$target_dir" || ! -d "$target_dir" ]]; then
|
|
52
|
+
return 1
|
|
53
|
+
fi
|
|
54
|
+
cd "$target_dir" && echo "Switched to: $target_dir"
|
|
55
|
+
|
|
56
|
+
if [[ "$clean_output" != *MINTREE_WORK:* ]]; then
|
|
57
|
+
return 0
|
|
58
|
+
fi
|
|
59
|
+
local extra=()
|
|
60
|
+
local prompt_file
|
|
61
|
+
prompt_file=$(echo "$clean_output" | grep "MINTREE_WORK_PROMPT_FILE:" | sed 's/.*MINTREE_WORK_PROMPT_FILE://')
|
|
62
|
+
local perm_mode
|
|
63
|
+
perm_mode=$(echo "$clean_output" | grep "MINTREE_PERMISSION_MODE:" | sed 's/.*MINTREE_PERMISSION_MODE://')
|
|
64
|
+
[[ -n "$prompt_file" ]] && extra+=(--prompt-file "$prompt_file")
|
|
65
|
+
[[ -n "$perm_mode" ]] && extra+=(--permission-mode "$perm_mode")
|
|
66
|
+
command mintree worktree work "${extra[@]}"
|
|
67
|
+
return $?
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
# `worktree create`: capture stdout so we can grep for markers, print the
|
|
71
|
+
# rest to the user, then run the side-effects.
|
|
72
|
+
if [[ "$1" == "worktree" && "$2" == "create" ]]; then
|
|
73
|
+
local output
|
|
74
|
+
output=$(command mintree "$@" 2>&1)
|
|
75
|
+
local exit_code=$?
|
|
76
|
+
|
|
77
|
+
if [[ "$output" == *MINTREE_CD:* ]]; then
|
|
78
|
+
echo "$output" | grep -vE "MINTREE_(CD|WORK|WORK_PROMPT_FILE|PERMISSION_MODE):"
|
|
79
|
+
local clean_output=$(echo "$output" | sed 's/\x1b\[[0-9;]*m//g')
|
|
80
|
+
_mintree_handle_markers "$clean_output"
|
|
81
|
+
else
|
|
82
|
+
echo "$output"
|
|
83
|
+
fi
|
|
84
|
+
return $exit_code
|
|
85
|
+
fi
|
|
86
|
+
|
|
87
|
+
# `dashboard`: the TUI owns the TTY, so we can't capture stdout without
|
|
88
|
+
# breaking rendering. Instead, hand the binary a temp file via env var
|
|
89
|
+
# and let it write markers there directly. Once the dashboard exits we
|
|
90
|
+
# read whatever's in the file and run the same side-effects as create.
|
|
91
|
+
if [[ "$1" == "dashboard" ]]; then
|
|
92
|
+
local marker_file
|
|
93
|
+
marker_file=$(mktemp -t mintree-markers)
|
|
94
|
+
MINTREE_MARKER_FILE="$marker_file" command mintree "$@"
|
|
95
|
+
local exit_code=$?
|
|
96
|
+
if [[ -s "$marker_file" ]]; then
|
|
97
|
+
local clean_output=$(cat "$marker_file" | sed 's/\x1b\[[0-9;]*m//g')
|
|
98
|
+
_mintree_handle_markers "$clean_output"
|
|
99
|
+
fi
|
|
100
|
+
rm -f "$marker_file"
|
|
101
|
+
return $exit_code
|
|
102
|
+
fi
|
|
103
|
+
|
|
104
|
+
command mintree "$@"
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
# Aliases as functions so they survive `eval` (zsh expands aliases at
|
|
108
|
+
# parse time, which is too early when the eval and the call live on the
|
|
109
|
+
# same script line). Functions are looked up at call time and always work.
|
|
110
|
+
function mt() {
|
|
111
|
+
mintree "$@"
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function mtw() {
|
|
115
|
+
mintree worktree "$@"
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
# `mtn` — interactive shortcut: prompt for a branch then create the worktree
|
|
119
|
+
# and start working on it. Equivalent to santree's `stn`.
|
|
120
|
+
function mtn() {
|
|
121
|
+
local branch
|
|
122
|
+
vared -p "Branch name: " branch
|
|
123
|
+
[[ -z "$branch" ]] && echo "Branch name required" && return 1
|
|
124
|
+
mintree worktree create "$branch" --work
|
|
125
|
+
}
|