on main help sign in
feat: added list and clean cli cmd
commitc98bc78f55534a15534aa45911acb0d69e33d042 authorrobcholz <84130577+robcholz@users.noreply.github.com> dateSat 7 Feb 2026, 16:20 (8 months ago) parentb3ac485
7 files changed+594−263
Cargo.lock+169−244 Cargo.toml+2−5 src/bin/vibebox-cli.rs+155−6 src/config.rs+60−4 src/session_manager.rs+96 src/tui.rs+62−1 src/vm_manager.rs+50−3
Cargo.lock+169−244
@@ -32,6 +32,56 @@ version = "0.2.21"
3232source = "registry+https://github.com/rust-lang/crates.io-index"
3333checksum = "683d7910e743518b0e34f1186f92494becacb047c7b6bf616c96772180fef923"
3434
35+[[package]]
36+name = "anstream"
37+version = "0.6.21"
38+source = "registry+https://github.com/rust-lang/crates.io-index"
39+checksum = "43d5b281e737544384e969a5ccad3f1cdd24b48086a0fc1b2a5262a26b8f4f4a"
40+dependencies = [
41+ "anstyle",
42+ "anstyle-parse",
43+ "anstyle-query",
44+ "anstyle-wincon",
45+ "colorchoice",
46+ "is_terminal_polyfill",
47+ "utf8parse",
48+]
49+
50+[[package]]
51+name = "anstyle"
52+version = "1.0.13"
53+source = "registry+https://github.com/rust-lang/crates.io-index"
54+checksum = "5192cca8006f1fd4f7237516f40fa183bb07f8fbdfedaa0036de5ea9b0b45e78"
55+
56+[[package]]
57+name = "anstyle-parse"
58+version = "0.2.7"
59+source = "registry+https://github.com/rust-lang/crates.io-index"
60+checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2"
61+dependencies = [
62+ "utf8parse",
63+]
64+
65+[[package]]
66+name = "anstyle-query"
67+version = "1.1.5"
68+source = "registry+https://github.com/rust-lang/crates.io-index"
69+checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
70+dependencies = [
71+ "windows-sys 0.61.2",
72+]
73+
74+[[package]]
75+name = "anstyle-wincon"
76+version = "3.0.11"
77+source = "registry+https://github.com/rust-lang/crates.io-index"
78+checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
79+dependencies = [
80+ "anstyle",
81+ "once_cell_polyfill",
82+ "windows-sys 0.61.2",
83+]
84+
3585[[package]]
3686name = "backtrace"
3787version = "0.3.76"
@@ -68,12 +118,6 @@ version = "3.19.1"
68118source = "registry+https://github.com/rust-lang/crates.io-index"
69119checksum = "5dd9dc738b7a8311c7ade152424974d8115f2cdad61e8dab8dac9f2362298510"
70120
71−[[package]]
72−name = "bytes"
73−version = "1.11.1"
74−source = "registry+https://github.com/rust-lang/crates.io-index"
75−checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33"
76−
77121[[package]]
78122name = "cassowary"
79123version = "0.3.0"
@@ -95,6 +139,46 @@ version = "1.0.4"
95139source = "registry+https://github.com/rust-lang/crates.io-index"
96140checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
97141
142+[[package]]
143+name = "clap"
144+version = "4.5.57"
145+source = "registry+https://github.com/rust-lang/crates.io-index"
146+checksum = "6899ea499e3fb9305a65d5ebf6e3d2248c5fab291f300ad0a704fbe142eae31a"
147+dependencies = [
148+ "clap_builder",
149+ "clap_derive",
150+]
151+
152+[[package]]
153+name = "clap_builder"
154+version = "4.5.57"
155+source = "registry+https://github.com/rust-lang/crates.io-index"
156+checksum = "7b12c8b680195a62a8364d16b8447b01b6c2c8f9aaf68bee653be34d4245e238"
157+dependencies = [
158+ "anstream",
159+ "anstyle",
160+ "clap_lex",
161+ "strsim",
162+]
163+
164+[[package]]
165+name = "clap_derive"
166+version = "4.5.55"
167+source = "registry+https://github.com/rust-lang/crates.io-index"
168+checksum = "a92793da1a46a5f2a02a6f4c46c6496b28c43638adea8306fcb0caa1634f24e5"
169+dependencies = [
170+ "heck",
171+ "proc-macro2",
172+ "quote",
173+ "syn",
174+]
175+
176+[[package]]
177+name = "clap_lex"
178+version = "0.7.7"
179+source = "registry+https://github.com/rust-lang/crates.io-index"
180+checksum = "c3e64b0cc0439b12df2fa678eae89a1c56a529fd067a9115f7827f1fffd22b32"
181+
98182[[package]]
99183name = "color-eyre"
100184version = "0.6.5"
@@ -122,6 +206,12 @@ dependencies = [
122206 "tracing-error",
123207]
124208
209+[[package]]
210+name = "colorchoice"
211+version = "1.0.4"
212+source = "registry+https://github.com/rust-lang/crates.io-index"
213+checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75"
214+
125215[[package]]
126216name = "compact_str"
127217version = "0.8.1"
@@ -136,6 +226,19 @@ dependencies = [
136226 "static_assertions",
137227]
138228
229+[[package]]
230+name = "console"
231+version = "0.16.2"
232+source = "registry+https://github.com/rust-lang/crates.io-index"
233+checksum = "03e45a4a8926227e4197636ba97a9fc9b00477e9f4bd711395687c5f0734bec4"
234+dependencies = [
235+ "encode_unicode",
236+ "libc",
237+ "once_cell",
238+ "unicode-width 0.2.0",
239+ "windows-sys 0.61.2",
240+]
241+
139242[[package]]
140243name = "crossterm"
141244version = "0.28.1"
@@ -206,6 +309,18 @@ dependencies = [
206309 "serde_core",
207310]
208311
312+[[package]]
313+name = "dialoguer"
314+version = "0.12.0"
315+source = "registry+https://github.com/rust-lang/crates.io-index"
316+checksum = "25f104b501bf2364e78d0d3974cbc774f738f5865306ed128e1e0d7499c0ad96"
317+dependencies = [
318+ "console",
319+ "shell-words",
320+ "tempfile",
321+ "zeroize",
322+]
323+
209324[[package]]
210325name = "dispatch2"
211326version = "0.3.0"
@@ -224,6 +339,12 @@ version = "1.15.0"
224339source = "registry+https://github.com/rust-lang/crates.io-index"
225340checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
226341
342+[[package]]
343+name = "encode_unicode"
344+version = "1.0.0"
345+source = "registry+https://github.com/rust-lang/crates.io-index"
346+checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0"
347+
227348[[package]]
228349name = "equivalent"
229350version = "1.0.2"
@@ -262,95 +383,12 @@ version = "0.1.5"
262383source = "registry+https://github.com/rust-lang/crates.io-index"
263384checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2"
264385
265−[[package]]
266−name = "futures"
267−version = "0.3.31"
268−source = "registry+https://github.com/rust-lang/crates.io-index"
269−checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876"
270−dependencies = [
271− "futures-channel",
272− "futures-core",
273− "futures-executor",
274− "futures-io",
275− "futures-sink",
276− "futures-task",
277− "futures-util",
278−]
279−
280−[[package]]
281−name = "futures-channel"
282−version = "0.3.31"
283−source = "registry+https://github.com/rust-lang/crates.io-index"
284−checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10"
285−dependencies = [
286− "futures-core",
287− "futures-sink",
288−]
289−
290386[[package]]
291387name = "futures-core"
292388version = "0.3.31"
293389source = "registry+https://github.com/rust-lang/crates.io-index"
294390checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
295391
296−[[package]]
297−name = "futures-executor"
298−version = "0.3.31"
299−source = "registry+https://github.com/rust-lang/crates.io-index"
300−checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f"
301−dependencies = [
302− "futures-core",
303− "futures-task",
304− "futures-util",
305−]
306−
307−[[package]]
308−name = "futures-io"
309−version = "0.3.31"
310−source = "registry+https://github.com/rust-lang/crates.io-index"
311−checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6"
312−
313−[[package]]
314−name = "futures-macro"
315−version = "0.3.31"
316−source = "registry+https://github.com/rust-lang/crates.io-index"
317−checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650"
318−dependencies = [
319− "proc-macro2",
320− "quote",
321− "syn",
322−]
323−
324−[[package]]
325−name = "futures-sink"
326−version = "0.3.31"
327−source = "registry+https://github.com/rust-lang/crates.io-index"
328−checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7"
329−
330−[[package]]
331−name = "futures-task"
332−version = "0.3.31"
333−source = "registry+https://github.com/rust-lang/crates.io-index"
334−checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988"
335−
336−[[package]]
337−name = "futures-util"
338−version = "0.3.31"
339−source = "registry+https://github.com/rust-lang/crates.io-index"
340−checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81"
341−dependencies = [
342− "futures-channel",
343− "futures-core",
344− "futures-io",
345− "futures-macro",
346− "futures-sink",
347− "futures-task",
348− "memchr",
349− "pin-project-lite",
350− "pin-utils",
351− "slab",
352−]
353−
354392[[package]]
355393name = "getrandom"
356394version = "0.3.4"
@@ -436,6 +474,12 @@ dependencies = [
436474 "syn",
437475]
438476
477+[[package]]
478+name = "is_terminal_polyfill"
479+version = "1.70.2"
480+source = "registry+https://github.com/rust-lang/crates.io-index"
481+checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
482+
439483[[package]]
440484name = "itertools"
441485version = "0.13.0"
@@ -467,12 +511,6 @@ version = "1.5.0"
467511source = "registry+https://github.com/rust-lang/crates.io-index"
468512checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
469513
470−[[package]]
471−name = "lexopt"
472−version = "0.3.1"
473−source = "registry+https://github.com/rust-lang/crates.io-index"
474−checksum = "9fa0e2a1fcbe2f6be6c42e342259976206b383122fc152e872795338b5a3f3a7"
475−
476514[[package]]
477515name = "libc"
478516version = "0.2.180"
@@ -557,7 +595,7 @@ version = "0.50.3"
557595source = "registry+https://github.com/rust-lang/crates.io-index"
558596checksum = "7957b9740744892f114936ab4a57b3f487491bbeafaf8083688b16841a4240e5"
559597dependencies = [
560− "windows-sys 0.59.0",
598+ "windows-sys 0.61.2",
561599]
562600
563601[[package]]
@@ -646,6 +684,12 @@ version = "1.21.3"
646684source = "registry+https://github.com/rust-lang/crates.io-index"
647685checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
648686
687+[[package]]
688+name = "once_cell_polyfill"
689+version = "1.70.2"
690+source = "registry+https://github.com/rust-lang/crates.io-index"
691+checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
692+
649693[[package]]
650694name = "owo-colors"
651695version = "4.2.3"
@@ -687,12 +731,6 @@ version = "0.2.16"
687731source = "registry+https://github.com/rust-lang/crates.io-index"
688732checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
689733
690−[[package]]
691−name = "pin-utils"
692−version = "0.1.0"
693−source = "registry+https://github.com/rust-lang/crates.io-index"
694−checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
695−
696734[[package]]
697735name = "powerfmt"
698736version = "0.2.0"
@@ -868,6 +906,12 @@ dependencies = [
868906 "lazy_static",
869907]
870908
909+[[package]]
910+name = "shell-words"
911+version = "1.1.1"
912+source = "registry+https://github.com/rust-lang/crates.io-index"
913+checksum = "dc6fe69c597f9c37bfeeeeeb33da3530379845f10be461a66d16d03eca2ded77"
914+
871915[[package]]
872916name = "signal-hook"
873917version = "0.3.18"
@@ -899,28 +943,12 @@ dependencies = [
899943 "libc",
900944]
901945
902−[[package]]
903−name = "slab"
904−version = "0.4.12"
905−source = "registry+https://github.com/rust-lang/crates.io-index"
906−checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
907−
908946[[package]]
909947name = "smallvec"
910948version = "1.15.1"
911949source = "registry+https://github.com/rust-lang/crates.io-index"
912950checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
913951
914−[[package]]
915−name = "socket2"
916−version = "0.6.2"
917−source = "registry+https://github.com/rust-lang/crates.io-index"
918−checksum = "86f4aa3ad99f2088c990dfa82d367e19cb29268ed67c574d10d0a4bfe71f07e0"
919−dependencies = [
920− "libc",
921− "windows-sys 0.60.2",
922−]
923−
924952[[package]]
925953name = "static_assertions"
926954version = "1.1.0"
@@ -1039,34 +1067,6 @@ dependencies = [
10391067 "time-core",
10401068]
10411069
1042−[[package]]
1043−name = "tokio"
1044−version = "1.49.0"
1045−source = "registry+https://github.com/rust-lang/crates.io-index"
1046−checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86"
1047−dependencies = [
1048− "bytes",
1049− "libc",
1050− "mio",
1051− "parking_lot",
1052− "pin-project-lite",
1053− "signal-hook-registry",
1054− "socket2",
1055− "tokio-macros",
1056− "windows-sys 0.61.2",
1057−]
1058−
1059−[[package]]
1060−name = "tokio-macros"
1061−version = "2.6.0"
1062−source = "registry+https://github.com/rust-lang/crates.io-index"
1063−checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5"
1064−dependencies = [
1065− "proc-macro2",
1066− "quote",
1067− "syn",
1068−]
1069−
10701070[[package]]
10711071name = "toml"
10721072version = "0.9.11+spec-1.1.0"
@@ -1177,16 +1177,6 @@ dependencies = [
11771177 "tracing-log",
11781178]
11791179
1180−[[package]]
1181−name = "tui-textarea"
1182−version = "0.7.0"
1183−source = "registry+https://github.com/rust-lang/crates.io-index"
1184−checksum = "0a5318dd619ed73c52a9417ad19046724effc1287fb75cdcc4eca1d6ac1acbae"
1185−dependencies = [
1186− "ratatui",
1187− "unicode-width 0.2.0",
1188−]
1189−
11901180[[package]]
11911181name = "unicode-ident"
11921182version = "1.0.22"
@@ -1222,6 +1212,12 @@ version = "0.2.0"
12221212source = "registry+https://github.com/rust-lang/crates.io-index"
12231213checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd"
12241214
1215+[[package]]
1216+name = "utf8parse"
1217+version = "0.2.2"
1218+source = "registry+https://github.com/rust-lang/crates.io-index"
1219+checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
1220+
12251221[[package]]
12261222name = "uuid"
12271223version = "1.20.0"
@@ -1245,11 +1241,11 @@ name = "vibebox"
12451241version = "0.1.0"
12461242dependencies = [
12471243 "block2",
1244+ "clap",
12481245 "color-eyre",
12491246 "crossterm",
1247+ "dialoguer",
12501248 "dispatch2",
1251− "futures",
1252− "lexopt",
12531249 "libc",
12541250 "objc2",
12551251 "objc2-foundation",
@@ -1259,12 +1255,9 @@ dependencies = [
12591255 "tempfile",
12601256 "thiserror",
12611257 "time",
1262− "tokio",
12631258 "toml",
12641259 "tracing",
12651260 "tracing-subscriber",
1266− "tui-textarea",
1267− "unicode-width 0.2.0",
12681261 "uuid",
12691262]
12701263
@@ -1362,16 +1355,7 @@ version = "0.59.0"
13621355source = "registry+https://github.com/rust-lang/crates.io-index"
13631356checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
13641357dependencies = [
1365− "windows-targets 0.52.6",
1366−]
1367−
1368−[[package]]
1369−name = "windows-sys"
1370−version = "0.60.2"
1371−source = "registry+https://github.com/rust-lang/crates.io-index"
1372−checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb"
1373−dependencies = [
1374− "windows-targets 0.53.5",
1358+ "windows-targets",
13751359]
13761360
13771361[[package]]
@@ -1389,31 +1373,14 @@ version = "0.52.6"
13891373source = "registry+https://github.com/rust-lang/crates.io-index"
13901374checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
13911375dependencies = [
1392− "windows_aarch64_gnullvm 0.52.6",
1393− "windows_aarch64_msvc 0.52.6",
1394− "windows_i686_gnu 0.52.6",
1395− "windows_i686_gnullvm 0.52.6",
1396− "windows_i686_msvc 0.52.6",
1397− "windows_x86_64_gnu 0.52.6",
1398− "windows_x86_64_gnullvm 0.52.6",
1399− "windows_x86_64_msvc 0.52.6",
1400−]
1401−
1402−[[package]]
1403−name = "windows-targets"
1404−version = "0.53.5"
1405−source = "registry+https://github.com/rust-lang/crates.io-index"
1406−checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"
1407−dependencies = [
1408− "windows-link",
1409− "windows_aarch64_gnullvm 0.53.1",
1410− "windows_aarch64_msvc 0.53.1",
1411− "windows_i686_gnu 0.53.1",
1412− "windows_i686_gnullvm 0.53.1",
1413− "windows_i686_msvc 0.53.1",
1414− "windows_x86_64_gnu 0.53.1",
1415− "windows_x86_64_gnullvm 0.53.1",
1416− "windows_x86_64_msvc 0.53.1",
1376+ "windows_aarch64_gnullvm",
1377+ "windows_aarch64_msvc",
1378+ "windows_i686_gnu",
1379+ "windows_i686_gnullvm",
1380+ "windows_i686_msvc",
1381+ "windows_x86_64_gnu",
1382+ "windows_x86_64_gnullvm",
1383+ "windows_x86_64_msvc",
14171384]
14181385
14191386[[package]]
@@ -1422,96 +1389,48 @@ version = "0.52.6"
14221389source = "registry+https://github.com/rust-lang/crates.io-index"
14231390checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
14241391
1425−[[package]]
1426−name = "windows_aarch64_gnullvm"
1427−version = "0.53.1"
1428−source = "registry+https://github.com/rust-lang/crates.io-index"
1429−checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53"
1430−
14311392[[package]]
14321393name = "windows_aarch64_msvc"
14331394version = "0.52.6"
14341395source = "registry+https://github.com/rust-lang/crates.io-index"
14351396checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
14361397
1437−[[package]]
1438−name = "windows_aarch64_msvc"
1439−version = "0.53.1"
1440−source = "registry+https://github.com/rust-lang/crates.io-index"
1441−checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006"
1442−
14431398[[package]]
14441399name = "windows_i686_gnu"
14451400version = "0.52.6"
14461401source = "registry+https://github.com/rust-lang/crates.io-index"
14471402checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
14481403
1449−[[package]]
1450−name = "windows_i686_gnu"
1451−version = "0.53.1"
1452−source = "registry+https://github.com/rust-lang/crates.io-index"
1453−checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3"
1454−
14551404[[package]]
14561405name = "windows_i686_gnullvm"
14571406version = "0.52.6"
14581407source = "registry+https://github.com/rust-lang/crates.io-index"
14591408checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
14601409
1461−[[package]]
1462−name = "windows_i686_gnullvm"
1463−version = "0.53.1"
1464−source = "registry+https://github.com/rust-lang/crates.io-index"
1465−checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c"
1466−
14671410[[package]]
14681411name = "windows_i686_msvc"
14691412version = "0.52.6"
14701413source = "registry+https://github.com/rust-lang/crates.io-index"
14711414checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
14721415
1473−[[package]]
1474−name = "windows_i686_msvc"
1475−version = "0.53.1"
1476−source = "registry+https://github.com/rust-lang/crates.io-index"
1477−checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2"
1478−
14791416[[package]]
14801417name = "windows_x86_64_gnu"
14811418version = "0.52.6"
14821419source = "registry+https://github.com/rust-lang/crates.io-index"
14831420checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
14841421
1485−[[package]]
1486−name = "windows_x86_64_gnu"
1487−version = "0.53.1"
1488−source = "registry+https://github.com/rust-lang/crates.io-index"
1489−checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499"
1490−
14911422[[package]]
14921423name = "windows_x86_64_gnullvm"
14931424version = "0.52.6"
14941425source = "registry+https://github.com/rust-lang/crates.io-index"
14951426checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
14961427
1497−[[package]]
1498−name = "windows_x86_64_gnullvm"
1499−version = "0.53.1"
1500−source = "registry+https://github.com/rust-lang/crates.io-index"
1501−checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1"
1502−
15031428[[package]]
15041429name = "windows_x86_64_msvc"
15051430version = "0.52.6"
15061431source = "registry+https://github.com/rust-lang/crates.io-index"
15071432checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
15081433
1509−[[package]]
1510−name = "windows_x86_64_msvc"
1511−version = "0.53.1"
1512−source = "registry+https://github.com/rust-lang/crates.io-index"
1513−checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
1514−
15151434[[package]]
15161435name = "winnow"
15171436version = "0.7.14"
@@ -1523,3 +1442,9 @@ name = "wit-bindgen"
15231442version = "0.51.0"
15241443source = "registry+https://github.com/rust-lang/crates.io-index"
15251444checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"
1445+
1446+[[package]]
1447+name = "zeroize"
1448+version = "1.8.2"
1449+source = "registry+https://github.com/rust-lang/crates.io-index"
1450+checksum = "b97154e67e32c85465826e8bcc1c59429aaaf107c1e4a9e53c8d8ccd5eff88d0"
Cargo.toml+2−5
@@ -20,7 +20,7 @@ objc2-virtualization = "*"
2020block2 = "*"
2121dispatch2 = "*"
2222libc = "*"
23−lexopt = "0.3"
23+clap = { version = "4", features = ["derive"] }
2424serde = { version = "1", features = ["derive"] }
2525tempfile = "3"
2626thiserror = "2.0.18"
@@ -29,10 +29,7 @@ toml = "0.9.8"
2929uuid = { version = "1", features = ["v7", "serde"] }
3030color-eyre = "0.6.3"
3131crossterm = { version = "0.28.1", features = ["event-stream"] }
32−futures = "0.3.31"
3332ratatui = { version = "0.29.0", features = ["unstable-rendered-line-info"] }
34−tokio = { version = "1.40.0", features = ["full"] }
35−tui-textarea = { version = "0.7.0", default-features = false, features = ["ratatui"] }
36−unicode-width = "0.2"
3733tracing = "0.1"
3834tracing-subscriber = { version = "0.3", features = ["env-filter"] }
35+dialoguer = "0.12.0"
src/bin/vibebox-cli.rs+155−6
@@ -2,24 +2,52 @@ use std::{
22 env,
33 ffi::OsString,
44 io::{self, IsTerminal, Write},
5+ path::PathBuf,
56 sync::{Arc, Mutex},
67};
78
9+use clap::Parser;
810use color_eyre::Result;
11+use dialoguer::Confirm;
12+use time::OffsetDateTime;
13+use time::format_description::well_known::Rfc3339;
914use tracing_subscriber::EnvFilter;
1015
1116use vibebox::tui::{AppState, VmInfo};
12−use vibebox::{SessionManager, commands, config, instance, tui, vm, vm_manager};
17+use vibebox::{SessionManager, commands, config, instance, session_manager, tui, vm, vm_manager};
18+
19+#[derive(Debug, Parser)]
20+#[command(name = "vibebox", version, about = "Vibebox CLI")]
21+struct Cli {
22+ /// Path to vibebox.toml (relative to the current directory)
23+ #[arg(short = 'c', long = "config", value_name = "PATH", global = true)]
24+ config: Option<PathBuf>,
25+ #[command(subcommand)]
26+ command: Option<Command>,
27+}
28+
29+#[derive(Debug, clap::Subcommand)]
30+enum Command {
31+ /// List all sessions
32+ List,
33+ /// Delete the current project's .vibebox directory
34+ Clean,
35+}
1336
1437fn main() -> Result<()> {
1538 init_tracing();
1639 color_eyre::install()?;
1740
18− let raw_args: Vec<OsString> = env::args_os().collect();
19−
41+ let cli = Cli::parse();
2042 let cwd = env::current_dir().map_err(|err| color_eyre::eyre::eyre!(err.to_string()))?;
2143 tracing::info!(cwd = %cwd.display(), "starting vibebox cli");
22− let config = config::load_config(&cwd);
44+ if let Some(command) = cli.command {
45+ return handle_command(command, &cwd);
46+ }
47+
48+ let config_override = cli.config.clone();
49+ let raw_args: Vec<OsString> = env::args_os().collect();
50+ let config = config::load_config_with_path(&cwd, config_override.as_deref());
2351
2452 if env::var("VIBEBOX_VM_MANAGER").as_deref() == Ok("1") {
2553 tracing::info!("starting vm manager mode");
@@ -74,14 +102,135 @@ fn main() -> Result<()> {
74102 }
75103
76104 tracing::info!(auto_shutdown_ms, "auto shutdown config");
77− let manager_conn = vm_manager::ensure_manager(&raw_args, auto_shutdown_ms)
78− .map_err(|err| color_eyre::eyre::eyre!(err.to_string()))?;
105+ let manager_conn =
106+ vm_manager::ensure_manager(&raw_args, auto_shutdown_ms, config_override.as_deref())
107+ .map_err(|err| color_eyre::eyre::eyre!(err.to_string()))?;
79108
80109 instance::run_with_ssh(manager_conn).map_err(|err| color_eyre::eyre::eyre!(err.to_string()))?;
81110
82111 Ok(())
83112}
84113
114+fn handle_command(command: Command, cwd: &PathBuf) -> Result<()> {
115+ match command {
116+ Command::List => {
117+ let manager = SessionManager::new()?;
118+ let sessions = manager.list_sessions()?;
119+ if sessions.is_empty() {
120+ println!("No sessions were found.");
121+ return Ok(());
122+ }
123+ let rows: Vec<tui::SessionListRow> = sessions
124+ .into_iter()
125+ .map(|session| tui::SessionListRow {
126+ name: project_name(&session.directory),
127+ id: session.id,
128+ directory: relative_to_home(&session.directory),
129+ last_active: format_last_active(session.last_active.as_deref()),
130+ active: if session.active {
131+ "yes".to_string()
132+ } else {
133+ "no".to_string()
134+ },
135+ })
136+ .collect();
137+ tui::render_sessions_table(&rows)?;
138+ Ok(())
139+ }
140+ Command::Clean => {
141+ let instance_dir = cwd.join(session_manager::INSTANCE_DIR_NAME);
142+ if !instance_dir.exists() {
143+ println!("No .vibebox directory found at {}", instance_dir.display());
144+ return Ok(());
145+ }
146+ let confirmed = Confirm::new()
147+ .with_prompt(format!(
148+ "Delete {} and all its contents?",
149+ instance_dir.display()
150+ ))
151+ .default(false)
152+ .interact()?;
153+ if !confirmed {
154+ println!("Cancelled.");
155+ return Ok(());
156+ }
157+ let manager = SessionManager::new()?;
158+ let summary = manager.clean_project(cwd)?;
159+ println!(
160+ "Deleted {} (removed={}, session_records_removed={})",
161+ summary.instance_dir.display(),
162+ summary.removed_instance_dir,
163+ summary.removed_sessions
164+ );
165+ Ok(())
166+ }
167+ }
168+}
169+
170+fn project_name(directory: &PathBuf) -> String {
171+ directory
172+ .file_name()
173+ .and_then(|name| name.to_str())
174+ .unwrap_or("-")
175+ .to_string()
176+}
177+
178+fn relative_to_home(directory: &PathBuf) -> String {
179+ let Ok(home) = env::var("HOME") else {
180+ return directory.display().to_string();
181+ };
182+ let home_path = PathBuf::from(home);
183+ if let Ok(stripped) = directory.strip_prefix(&home_path) {
184+ if stripped.components().next().is_none() {
185+ return "~".to_string();
186+ }
187+ return format!("~/{}", stripped.display());
188+ }
189+ directory.display().to_string()
190+}
191+
192+fn format_last_active(value: Option<&str>) -> String {
193+ let Some(raw) = value else {
194+ return "-".to_string();
195+ };
196+ let parsed = OffsetDateTime::parse(raw, &Rfc3339);
197+ let Ok(timestamp) = parsed else {
198+ return raw.to_string();
199+ };
200+ let now = OffsetDateTime::now_utc();
201+ let mut seconds = (now - timestamp).whole_seconds();
202+ if seconds < 0 {
203+ seconds = 0;
204+ }
205+ let seconds = seconds as i64;
206+ let week_seconds = 7 * 24 * 60 * 60;
207+ if seconds >= week_seconds {
208+ let formatted =
209+ match time::format_description::parse("[year]-[month]-[day] [hour]:[minute]Z") {
210+ Ok(format) => timestamp
211+ .format(&format)
212+ .unwrap_or_else(|_| raw.to_string()),
213+ Err(_) => timestamp
214+ .format(&Rfc3339)
215+ .unwrap_or_else(|_| raw.to_string()),
216+ };
217+ return formatted;
218+ }
219+ if seconds < 60 {
220+ return "just now".to_string();
221+ }
222+ if seconds < 60 * 60 {
223+ let mins = seconds / 60;
224+ return format!("{} min{} ago", mins, if mins == 1 { "" } else { "s" });
225+ }
226+ if seconds < 60 * 60 * 24 {
227+ let hours = seconds / (60 * 60);
228+ return format!("{} hour{} ago", hours, if hours == 1 { "" } else { "s" });
229+ }
230+ let days = seconds / (60 * 60 * 24);
231+ format!("{} day{} ago", days, if days == 1 { "" } else { "s" })
232+}
233+
85234fn init_tracing() {
86235 let filter = EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("info"));
87236 let ansi = std::io::stderr().is_terminal() && env::var("VIBEBOX_LOG_NO_COLOR").is_err();
src/config.rs+60−4
@@ -1,5 +1,5 @@
11use std::{
2− fs, io,
2+ env, fs, io,
33 path::{Path, PathBuf},
44};
55
@@ -8,6 +8,7 @@ use serde::{Deserialize, Serialize};
88use crate::vm::DirectoryShare;
99
1010pub const CONFIG_FILENAME: &str = "vibebox.toml";
11+pub const CONFIG_PATH_ENV: &str = "VIBEBOX_CONFIG_PATH";
1112
1213const DEFAULT_CPU_COUNT: usize = 2;
1314const DEFAULT_RAM_MB: u64 = 2048;
@@ -93,8 +94,11 @@ pub fn config_path(project_root: &Path) -> PathBuf {
9394 project_root.join(CONFIG_FILENAME)
9495}
9596
96−pub fn ensure_config_file(project_root: &Path) -> Result<PathBuf, io::Error> {
97− let path = config_path(project_root);
97+pub fn ensure_config_file(
98+ project_root: &Path,
99+ override_path: Option<&Path>,
100+) -> Result<PathBuf, io::Error> {
101+ let path = resolve_config_path(project_root, override_path);
98102 if !path.exists() {
99103 let default_config = Config::default();
100104 let contents = toml::to_string_pretty(&default_config).unwrap_or_default();
@@ -105,7 +109,11 @@ pub fn ensure_config_file(project_root: &Path) -> Result<PathBuf, io::Error> {
105109}
106110
107111pub fn load_config(project_root: &Path) -> Config {
108− let path = match ensure_config_file(project_root) {
112+ load_config_with_path(project_root, None)
113+}
114+
115+pub fn load_config_with_path(project_root: &Path, override_path: Option<&Path>) -> Config {
116+ let path = match ensure_config_file(project_root, override_path) {
109117 Ok(path) => path,
110118 Err(err) => die(&format!("failed to create config: {err}")),
111119 };
@@ -144,6 +152,54 @@ pub fn load_config(project_root: &Path) -> Config {
144152 config
145153}
146154
155+fn resolve_config_path(project_root: &Path, override_path: Option<&Path>) -> PathBuf {
156+ let root = match fs::canonicalize(project_root) {
157+ Ok(root) => root,
158+ Err(err) => die(&format!("failed to resolve project root: {err}")),
159+ };
160+
161+ let override_path = override_path
162+ .map(PathBuf::from)
163+ .or_else(|| env::var_os(CONFIG_PATH_ENV).map(PathBuf::from));
164+ let raw_path = if let Some(path) = override_path {
165+ if path.is_absolute() {
166+ path
167+ } else {
168+ project_root.join(path)
169+ }
170+ } else {
171+ config_path(project_root)
172+ };
173+
174+ let normalized = normalize_path(&raw_path);
175+ if !normalized.starts_with(&root) {
176+ die(&format!(
177+ "config path must be within {}: {}",
178+ root.display(),
179+ normalized.display()
180+ ));
181+ }
182+ normalized
183+}
184+
185+fn normalize_path(path: &Path) -> PathBuf {
186+ let mut normalized = PathBuf::new();
187+ for component in path.components() {
188+ match component {
189+ std::path::Component::Prefix(prefix) => normalized.push(prefix.as_os_str()),
190+ std::path::Component::RootDir => {
191+ normalized.push(std::path::MAIN_SEPARATOR.to_string());
192+ }
193+ std::path::Component::CurDir => {}
194+ std::path::Component::ParentDir => {
195+ let _ = normalized.pop();
196+ }
197+ std::path::Component::Normal(part) => normalized.push(part),
198+ }
199+ }
200+ normalized
201+}
202+
147203fn validate_schema(value: &toml::Value) -> Vec<String> {
148204 let mut errors = Vec::new();
149205 let root = match value.as_table() {
src/session_manager.rs+96
@@ -1,6 +1,7 @@
11use std::{
22 env, fs,
33 io::{self, Write},
4+ os::unix::fs::FileTypeExt,
45 path::{Path, PathBuf},
56};
67
@@ -13,6 +14,8 @@ pub const GLOBAL_CACHE_DIR_NAME: &str = "vibebox";
1314pub const GLOBAL_DIR_NAME: &str = ".vibebox";
1415pub const INSTANCE_FILENAME: &str = "instance.toml";
1516pub const SESSION_TOML_SUFFIX: &str = ".toml";
17+pub const VM_MANAGER_SOCKET_NAME: &str = "vm.sock";
18+pub const VM_MANAGER_PID_NAME: &str = "vm.pid";
1619const SESSIONS_DIR_NAME: &str = "sessions";
1720
1821#[derive(Debug, Clone, PartialEq, Eq)]
@@ -20,6 +23,7 @@ pub struct SessionRecord {
2023 pub directory: PathBuf,
2124 pub id: String,
2225 pub last_active: Option<String>,
26+ pub active: bool,
2327}
2428
2529#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
@@ -41,6 +45,13 @@ pub struct SessionManager {
4145 sessions_dir: PathBuf,
4246}
4347
48+#[derive(Debug, Clone, PartialEq, Eq)]
49+pub struct CleanSummary {
50+ pub instance_dir: PathBuf,
51+ pub removed_instance_dir: bool,
52+ pub removed_sessions: usize,
53+}
54+
4455#[derive(Debug, thiserror::Error)]
4556pub enum SessionError {
4657 #[error("HOME environment variable is not set")]
@@ -138,15 +149,33 @@ impl SessionManager {
138149 let mut records = Vec::with_capacity(sessions.len());
139150 for session in sessions {
140151 let meta = read_instance_metadata(&session.directory)?;
152+ let active = is_session_active(&session.directory);
141153 records.push(SessionRecord {
142154 directory: session.directory,
143155 id: session.id,
144156 last_active: meta.last_active,
157+ active,
145158 });
146159 }
147160 Ok(records)
148161 }
149162
163+ pub fn clean_project(&self, directory: &Path) -> Result<CleanSummary, SessionError> {
164+ let directory = self.normalize_directory(directory)?;
165+ let instance_dir = directory.join(INSTANCE_DIR_NAME);
166+ let mut removed_instance_dir = false;
167+ if instance_dir.exists() {
168+ fs::remove_dir_all(&instance_dir)?;
169+ removed_instance_dir = true;
170+ }
171+ let removed_sessions = self.remove_session_records_for_directory(&directory)?;
172+ Ok(CleanSummary {
173+ instance_dir,
174+ removed_instance_dir,
175+ removed_sessions,
176+ })
177+ }
178+
150179 fn normalize_directory(&self, directory: &Path) -> Result<PathBuf, SessionError> {
151180 if !directory.is_absolute() {
152181 return Err(SessionError::NonAbsoluteDirectory(directory.to_path_buf()));
@@ -206,6 +235,36 @@ impl SessionManager {
206235
207236 Ok((sessions, removed))
208237 }
238+
239+ fn remove_session_records_for_directory(
240+ &self,
241+ directory: &Path,
242+ ) -> Result<usize, SessionError> {
243+ if !self.sessions_dir.exists() {
244+ return Ok(0);
245+ }
246+ let mut removed = 0usize;
247+ for entry in fs::read_dir(&self.sessions_dir)? {
248+ let entry = entry?;
249+ let path = entry.path();
250+ if !path.is_file() {
251+ continue;
252+ }
253+ let record = read_session_file(&path)?;
254+ if record.directory == directory {
255+ fs::remove_file(&path)?;
256+ removed += 1;
257+ }
258+ }
259+ if removed > 0 {
260+ tracing::info!(
261+ directory = %directory.display(),
262+ removed,
263+ "removed session records"
264+ );
265+ }
266+ Ok(removed)
267+ }
209268}
210269
211270fn is_vibebox_dir(directory: &Path) -> bool {
@@ -215,6 +274,43 @@ fn is_vibebox_dir(directory: &Path) -> bool {
215274 directory.join(CONFIG_FILENAME).is_file()
216275}
217276
277+fn is_session_active(directory: &Path) -> bool {
278+ let instance_dir = directory.join(INSTANCE_DIR_NAME);
279+ let pid_path = instance_dir.join(VM_MANAGER_PID_NAME);
280+ let socket_path = instance_dir.join(VM_MANAGER_SOCKET_NAME);
281+
282+ let pid = read_pid(&pid_path);
283+ let is_alive = pid.map(pid_is_alive).unwrap_or(false);
284+ if !is_alive {
285+ let _ = fs::remove_file(&pid_path);
286+ return false;
287+ }
288+
289+ if let Ok(metadata) = fs::metadata(&socket_path) {
290+ return metadata.file_type().is_socket();
291+ }
292+
293+ true
294+}
295+
296+fn read_pid(path: &Path) -> Option<u32> {
297+ let content = fs::read_to_string(path).ok()?;
298+ content.trim().parse::<u32>().ok()
299+}
300+
301+fn pid_is_alive(pid: u32) -> bool {
302+ let pid = pid as libc::pid_t;
303+ let result = unsafe { libc::kill(pid, 0) };
304+ if result == 0 {
305+ return true;
306+ }
307+ match std::io::Error::last_os_error().raw_os_error() {
308+ Some(code) if code == libc::EPERM => true,
309+ Some(code) if code == libc::ESRCH => false,
310+ _ => false,
311+ }
312+}
313+
218314fn read_session_file(path: &Path) -> Result<SessionEntry, SessionError> {
219315 let raw = fs::read_to_string(path)?;
220316 let record: SessionEntry = toml::from_str(&raw)?;
src/tui.rs+62−1
@@ -20,7 +20,7 @@ use ratatui::{
2020 layout::{Constraint, Direction, Layout, Rect},
2121 style::{Color, Style},
2222 text::{Line, Span, Text},
23− widgets::{Block, Borders, List, ListItem, Paragraph, Widget},
23+ widgets::{Block, Borders, Cell, List, ListItem, Paragraph, Row, Table, Widget},
2424};
2525
2626use crate::vm;
@@ -98,6 +98,15 @@ pub struct VibeboxCommand {
9898 pub description: String,
9999}
100100
101+#[derive(Debug, Clone)]
102+pub struct SessionListRow {
103+ pub name: String,
104+ pub directory: String,
105+ pub last_active: String,
106+ pub active: String,
107+ pub id: String,
108+}
109+
101110#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
102111struct PageLayout {
103112 header: Rect,
@@ -174,6 +183,58 @@ pub fn render_commands_component(app: &mut AppState) -> Result<()> {
174183 Ok(())
175184}
176185
186+pub fn render_sessions_table(rows: &[SessionListRow]) -> Result<()> {
187+ let (width, _) = crossterm::terminal::size()?;
188+ if width == 0 {
189+ return Ok(());
190+ }
191+
192+ let height = (rows.len() as u16).saturating_add(3);
193+ let mut buffer = Buffer::empty(Rect::new(0, 0, width, height));
194+ let area = Rect::new(0, 0, width, height);
195+
196+ let header = Row::new(vec![
197+ Cell::from("Name"),
198+ Cell::from("Last Active"),
199+ Cell::from("Active"),
200+ Cell::from("ID"),
201+ Cell::from("Directory"),
202+ ])
203+ .style(Style::default().fg(Color::Cyan));
204+
205+ let table_rows = rows.iter().map(|row| {
206+ Row::new(vec![
207+ Cell::from(row.name.clone()),
208+ Cell::from(row.last_active.clone()),
209+ Cell::from(row.active.clone()),
210+ Cell::from(row.id.clone()),
211+ Cell::from(row.directory.clone()),
212+ ])
213+ });
214+
215+ let table = Table::new(
216+ table_rows,
217+ [
218+ Constraint::Length(16),
219+ Constraint::Length(14),
220+ Constraint::Length(8),
221+ Constraint::Length(36),
222+ Constraint::Min(24),
223+ ],
224+ )
225+ .header(header)
226+ .block(Block::default().title("Sessions").borders(Borders::ALL))
227+ .column_spacing(2);
228+
229+ table.render(area, &mut buffer);
230+
231+ let mut stdout = io::stdout();
232+ execute!(stdout, Clear(ClearType::All), MoveTo(0, 0), Show)?;
233+ write_buffer_with_style(&buffer, &mut stdout)?;
234+ stdout.flush()?;
235+ Ok(())
236+}
237+
177238pub fn passthrough_vm_io(
178239 app: Arc<Mutex<AppState>>,
179240 output_monitor: Arc<vm::OutputMonitor>,
src/vm_manager.rs+50−3
@@ -15,26 +15,30 @@ use std::{
1515};
1616
1717use crate::{
18+ config::CONFIG_PATH_ENV,
1819 instance::SERIAL_LOG_NAME,
1920 instance::{
2021 InstanceConfig, build_ssh_login_actions, ensure_instance_dir, ensure_ssh_keypair,
2122 extract_ipv4, load_or_create_instance_config, write_instance_config,
2223 },
23− session_manager::{GLOBAL_DIR_NAME, INSTANCE_FILENAME},
24+ session_manager::{
25+ GLOBAL_DIR_NAME, INSTANCE_FILENAME, VM_MANAGER_PID_NAME, VM_MANAGER_SOCKET_NAME,
26+ },
2427 vm::{self, DirectoryShare, LoginAction, VmInput},
2528};
2629
27−const VM_MANAGER_SOCKET_NAME: &str = "vm.sock";
2830const VM_MANAGER_LOCK_NAME: &str = "vm.lock";
2931const VM_MANAGER_LOG_NAME: &str = "vm_manager.log";
3032
3133pub fn ensure_manager(
3234 raw_args: &[std::ffi::OsString],
3335 auto_shutdown_ms: u64,
36+ config_path: Option<&Path>,
3437) -> Result<UnixStream, Box<dyn std::error::Error>> {
3538 let project_root = env::current_dir()?;
3639 tracing::debug!(root = %project_root.display(), "ensure vm manager");
3740 let instance_dir = ensure_instance_dir(&project_root)?;
41+ cleanup_stale_manager(&instance_dir);
3842 let socket_path = instance_dir.join(VM_MANAGER_SOCKET_NAME);
3943
4044 if let Ok(stream) = UnixStream::connect(&socket_path) {
@@ -47,7 +51,7 @@ pub fn ensure_manager(
4751 let mut lock_file = acquire_spawn_lock(&lock_path)?;
4852 if lock_file.is_some() {
4953 tracing::info!(path = %socket_path.display(), "spawning vm manager");
50− spawn_manager_process(raw_args, auto_shutdown_ms, &instance_dir)?;
54+ spawn_manager_process(raw_args, auto_shutdown_ms, &instance_dir, config_path)?;
5155 } else {
5256 tracing::info!(
5357 path = %socket_path.display(),
@@ -96,6 +100,7 @@ pub fn run_manager(
96100) -> Result<(), Box<dyn std::error::Error>> {
97101 let project_root = env::current_dir()?;
98102 tracing::info!(root = %project_root.display(), "vm manager starting");
103+ let _pid_guard = ensure_pid_file(&project_root)?;
99104 run_manager_with(
100105 &project_root,
101106 args,
@@ -113,6 +118,7 @@ fn spawn_manager_process(
113118 raw_args: &[std::ffi::OsString],
114119 auto_shutdown_ms: u64,
115120 instance_dir: &Path,
121+ config_path: Option<&Path>,
116122) -> Result<(), Box<dyn std::error::Error>> {
117123 let exe = env::current_exe()?;
118124 let mut supervisor_exe = exe.clone();
@@ -133,6 +139,9 @@ fn spawn_manager_process(
133139 }
134140 cmd.env("VIBEBOX_LOG_NO_COLOR", "1");
135141 cmd.env("VIBEBOX_AUTO_SHUTDOWN_MS", auto_shutdown_ms.to_string());
142+ if let Some(path) = config_path {
143+ cmd.env(CONFIG_PATH_ENV, path);
144+ }
136145 tracing::info!(auto_shutdown_ms, "vm manager process spawn requested");
137146 let log_path = instance_dir.join(VM_MANAGER_LOG_NAME);
138147 let log_file = fs::OpenOptions::new()
@@ -155,6 +164,44 @@ fn spawn_manager_process(
155164 Ok(())
156165}
157166
167+fn ensure_pid_file(project_root: &Path) -> Result<PidFileGuard, Box<dyn std::error::Error>> {
168+ let instance_dir = ensure_instance_dir(project_root)?;
169+ let pid_path = instance_dir.join(VM_MANAGER_PID_NAME);
170+ if let Ok(content) = fs::read_to_string(&pid_path) {
171+ if let Ok(pid) = content.trim().parse::<u32>() {
172+ if pid_is_alive(pid) {
173+ return Err(format!("vm manager already running (pid {pid})").into());
174+ }
175+ }
176+ let _ = fs::remove_file(&pid_path);
177+ }
178+ fs::write(&pid_path, format!("{}\n", std::process::id()))?;
179+ let _ = fs::set_permissions(&pid_path, fs::Permissions::from_mode(0o600));
180+ Ok(PidFileGuard { path: pid_path })
181+}
182+
183+fn cleanup_stale_manager(instance_dir: &Path) {
184+ let pid_path = instance_dir.join(VM_MANAGER_PID_NAME);
185+ if let Ok(content) = fs::read_to_string(&pid_path) {
186+ if let Ok(pid) = content.trim().parse::<u32>() {
187+ if pid_is_alive(pid) {
188+ return;
189+ }
190+ }
191+ }
192+ let _ = fs::remove_file(&pid_path);
193+}
194+
195+struct PidFileGuard {
196+ path: PathBuf,
197+}
198+
199+impl Drop for PidFileGuard {
200+ fn drop(&mut self) {
201+ let _ = fs::remove_file(&self.path);
202+ }
203+}
204+
158205fn detach_from_terminal() {
159206 unsafe {
160207 libc::setsid();