@hydra-acp/cli 0.1.47 → 0.1.48
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/dist/cli.js +51 -28
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -9983,6 +9983,9 @@ uncaught: ${err.stack ?? err.message}
|
|
|
9983
9983
|
});
|
|
9984
9984
|
|
|
9985
9985
|
// src/tui/picker.ts
|
|
9986
|
+
function createPickerPrefs() {
|
|
9987
|
+
return { filters: { cwdOnly: false, hostFilter: "__local" } };
|
|
9988
|
+
}
|
|
9986
9989
|
async function pickSession(term, opts) {
|
|
9987
9990
|
process.stdout.write("\x1B[<u");
|
|
9988
9991
|
process.stdout.write("\x1B[?2004l");
|
|
@@ -10008,18 +10011,25 @@ async function pickSession(term, opts) {
|
|
|
10008
10011
|
return b.updatedAt.slice(0, 16).localeCompare(a.updatedAt.slice(0, 16));
|
|
10009
10012
|
});
|
|
10010
10013
|
};
|
|
10011
|
-
|
|
10012
|
-
|
|
10013
|
-
if (opts.currentSessionId !== void 0) {
|
|
10014
|
+
const prefs = opts.prefs ?? createPickerPrefs();
|
|
10015
|
+
if (opts.prefs === void 0 && opts.currentSessionId !== void 0) {
|
|
10014
10016
|
const current = opts.sessions.find(
|
|
10015
10017
|
(s) => s.sessionId === opts.currentSessionId
|
|
10016
10018
|
);
|
|
10017
10019
|
if (current?.importedFromMachine) {
|
|
10018
|
-
hostFilter = "__all";
|
|
10020
|
+
prefs.filters.hostFilter = "__all";
|
|
10019
10021
|
}
|
|
10020
10022
|
}
|
|
10021
10023
|
let allSessions = sortSessions(opts.sessions);
|
|
10022
|
-
|
|
10024
|
+
const applyPrefsFilters = (sessions) => {
|
|
10025
|
+
let base = sessions;
|
|
10026
|
+
if (prefs.filters.cwdOnly) {
|
|
10027
|
+
base = base.filter((s) => s.cwd === opts.cwd);
|
|
10028
|
+
}
|
|
10029
|
+
base = filterByHost(base, prefs.filters.hostFilter);
|
|
10030
|
+
return base;
|
|
10031
|
+
};
|
|
10032
|
+
let visible = applyPrefsFilters(allSessions);
|
|
10023
10033
|
let rows = visible.map((s) => toRow(s, Date.now()));
|
|
10024
10034
|
let widths = computeWidths(rows);
|
|
10025
10035
|
let total = 1 + visible.length;
|
|
@@ -10087,11 +10097,7 @@ async function pickSession(term, opts) {
|
|
|
10087
10097
|
computeLayout();
|
|
10088
10098
|
};
|
|
10089
10099
|
const applyFilter = () => {
|
|
10090
|
-
|
|
10091
|
-
if (cwdOnly) {
|
|
10092
|
-
base = base.filter((s) => s.cwd === opts.cwd);
|
|
10093
|
-
}
|
|
10094
|
-
base = filterByHost(base, hostFilter);
|
|
10100
|
+
const base = applyPrefsFilters(allSessions);
|
|
10095
10101
|
if (searchActive && searchTerm.length > 0) {
|
|
10096
10102
|
visible = base.filter((s) => matchesSearch(s, searchTerm));
|
|
10097
10103
|
} else {
|
|
@@ -10177,12 +10183,12 @@ async function pickSession(term, opts) {
|
|
|
10177
10183
|
const above = scrollOffset;
|
|
10178
10184
|
const below = Math.max(0, visible.length - scrollOffset - viewportSize);
|
|
10179
10185
|
const parts = [];
|
|
10180
|
-
if (cwdOnly) {
|
|
10186
|
+
if (prefs.filters.cwdOnly) {
|
|
10181
10187
|
parts.push("cwd-only");
|
|
10182
10188
|
}
|
|
10183
|
-
if (hostFilter !== "__all") {
|
|
10189
|
+
if (prefs.filters.hostFilter !== "__all") {
|
|
10184
10190
|
parts.push(
|
|
10185
|
-
hostFilter === "__local" ? "host: local" : `host: ${hostFilter}`
|
|
10191
|
+
prefs.filters.hostFilter === "__local" ? "host: local" : `host: ${prefs.filters.hostFilter}`
|
|
10186
10192
|
);
|
|
10187
10193
|
}
|
|
10188
10194
|
if (above > 0) {
|
|
@@ -10812,7 +10818,7 @@ ${cells}`;
|
|
|
10812
10818
|
}
|
|
10813
10819
|
if (name === "o" || name === "O") {
|
|
10814
10820
|
const keepId = selectedIdx > 0 ? visible[selectedIdx - 1]?.sessionId : void 0;
|
|
10815
|
-
cwdOnly = !cwdOnly;
|
|
10821
|
+
prefs.filters.cwdOnly = !prefs.filters.cwdOnly;
|
|
10816
10822
|
applyFilter();
|
|
10817
10823
|
if (keepId !== void 0) {
|
|
10818
10824
|
const idx = visible.findIndex((s) => s.sessionId === keepId);
|
|
@@ -10826,7 +10832,10 @@ ${cells}`;
|
|
|
10826
10832
|
}
|
|
10827
10833
|
if (name === "h" || name === "H") {
|
|
10828
10834
|
const keepId = selectedIdx > 0 ? visible[selectedIdx - 1]?.sessionId : void 0;
|
|
10829
|
-
hostFilter = nextHostFilter(
|
|
10835
|
+
prefs.filters.hostFilter = nextHostFilter(
|
|
10836
|
+
prefs.filters.hostFilter,
|
|
10837
|
+
allSessions
|
|
10838
|
+
);
|
|
10830
10839
|
applyFilter();
|
|
10831
10840
|
if (keepId !== void 0) {
|
|
10832
10841
|
const idx = visible.findIndex((s) => s.sessionId === keepId);
|
|
@@ -11225,7 +11234,7 @@ async function promptForImportCwd(term, session, opts = {}) {
|
|
|
11225
11234
|
const contentHeight = 9;
|
|
11226
11235
|
layout = drawBox(term, {
|
|
11227
11236
|
contentHeight,
|
|
11228
|
-
title: "
|
|
11237
|
+
title: "Fork locally \u2014 choose cwd"
|
|
11229
11238
|
});
|
|
11230
11239
|
const innerW = layout.contentW;
|
|
11231
11240
|
const headerRows = [
|
|
@@ -11464,7 +11473,10 @@ async function promptForImportAction(term, session) {
|
|
|
11464
11473
|
const shortId2 = stripHydraSessionPrefix(session.sessionId);
|
|
11465
11474
|
const fromMachine = session.importedFromMachine ?? "another machine";
|
|
11466
11475
|
const originalCwd = shortenHomePath(session.cwd);
|
|
11467
|
-
let selected =
|
|
11476
|
+
let selected = ACTION_CHOICES.findIndex((c) => c.key === "view");
|
|
11477
|
+
if (selected < 0) {
|
|
11478
|
+
selected = 0;
|
|
11479
|
+
}
|
|
11468
11480
|
const render = () => {
|
|
11469
11481
|
const choiceRows = ACTION_CHOICES.length * 2;
|
|
11470
11482
|
const contentHeight = 7 + choiceRows + 2;
|
|
@@ -11509,7 +11521,7 @@ async function promptForImportAction(term, session) {
|
|
|
11509
11521
|
}
|
|
11510
11522
|
row++;
|
|
11511
11523
|
term.moveTo(layout.contentX, layout.contentY + row);
|
|
11512
|
-
term.dim.noFormat(" \u2191/\u2193 navigate \xB7 Enter select \xB7
|
|
11524
|
+
term.dim.noFormat(" \u2191/\u2193 navigate \xB7 Enter select \xB7 f/v jump \xB7 Esc back");
|
|
11513
11525
|
return layout;
|
|
11514
11526
|
};
|
|
11515
11527
|
render();
|
|
@@ -11610,10 +11622,10 @@ var init_import_action_prompt = __esm({
|
|
|
11610
11622
|
init_prompt_utils();
|
|
11611
11623
|
ACTION_CHOICES = [
|
|
11612
11624
|
{
|
|
11613
|
-
key: "
|
|
11614
|
-
label: "
|
|
11615
|
-
hotkey: "
|
|
11616
|
-
description: "spawn
|
|
11625
|
+
key: "fork-local",
|
|
11626
|
+
label: "Fork locally",
|
|
11627
|
+
hotkey: "f",
|
|
11628
|
+
description: "spawn a local fork \u2014 original imported copy stays as-is"
|
|
11617
11629
|
},
|
|
11618
11630
|
{
|
|
11619
11631
|
key: "view",
|
|
@@ -12487,6 +12499,7 @@ async function runTuiApp(opts) {
|
|
|
12487
12499
|
const viewPrefs = {
|
|
12488
12500
|
showThoughts: config.tui.showThoughts
|
|
12489
12501
|
};
|
|
12502
|
+
const pickerPrefs = createPickerPrefs();
|
|
12490
12503
|
let altScreenEngaged = false;
|
|
12491
12504
|
const enterAltScreen = () => {
|
|
12492
12505
|
if (altScreenEngaged) {
|
|
@@ -12514,7 +12527,15 @@ async function runTuiApp(opts) {
|
|
|
12514
12527
|
let nextOpts = opts;
|
|
12515
12528
|
try {
|
|
12516
12529
|
while (nextOpts !== null) {
|
|
12517
|
-
nextOpts = await runSession(
|
|
12530
|
+
nextOpts = await runSession(
|
|
12531
|
+
term,
|
|
12532
|
+
config,
|
|
12533
|
+
target,
|
|
12534
|
+
nextOpts,
|
|
12535
|
+
exitHint,
|
|
12536
|
+
viewPrefs,
|
|
12537
|
+
pickerPrefs
|
|
12538
|
+
);
|
|
12518
12539
|
}
|
|
12519
12540
|
} finally {
|
|
12520
12541
|
leaveAltScreen();
|
|
@@ -12534,8 +12555,8 @@ async function runTuiApp(opts) {
|
|
|
12534
12555
|
);
|
|
12535
12556
|
}
|
|
12536
12557
|
}
|
|
12537
|
-
async function runSession(term, config, target, opts, exitHint, viewPrefs) {
|
|
12538
|
-
const ctx = await resolveSession(term, config, target, opts);
|
|
12558
|
+
async function runSession(term, config, target, opts, exitHint, viewPrefs, pickerPrefs) {
|
|
12559
|
+
const ctx = await resolveSession(term, config, target, opts, pickerPrefs);
|
|
12539
12560
|
if (!ctx) {
|
|
12540
12561
|
term.grabInput(false);
|
|
12541
12562
|
return null;
|
|
@@ -13454,7 +13475,8 @@ async function runSession(term, config, target, opts, exitHint, viewPrefs) {
|
|
|
13454
13475
|
sessions,
|
|
13455
13476
|
config,
|
|
13456
13477
|
target,
|
|
13457
|
-
currentSessionId: resolvedSessionId
|
|
13478
|
+
currentSessionId: resolvedSessionId,
|
|
13479
|
+
prefs: pickerPrefs
|
|
13458
13480
|
});
|
|
13459
13481
|
if (choice2.kind === "abort") {
|
|
13460
13482
|
screen.start({ skipFullscreen: true });
|
|
@@ -14596,7 +14618,7 @@ connection lost: ${err.message}
|
|
|
14596
14618
|
}
|
|
14597
14619
|
return await sessionDone;
|
|
14598
14620
|
}
|
|
14599
|
-
async function resolveSession(term, config, target, opts) {
|
|
14621
|
+
async function resolveSession(term, config, target, opts, pickerPrefs) {
|
|
14600
14622
|
const cwd = opts.cwd ?? process.cwd();
|
|
14601
14623
|
if (opts.sessionId) {
|
|
14602
14624
|
const ctx = {
|
|
@@ -14632,7 +14654,8 @@ async function resolveSession(term, config, target, opts) {
|
|
|
14632
14654
|
cwd,
|
|
14633
14655
|
sessions,
|
|
14634
14656
|
config,
|
|
14635
|
-
target
|
|
14657
|
+
target,
|
|
14658
|
+
prefs: pickerPrefs
|
|
14636
14659
|
});
|
|
14637
14660
|
if (choice.kind === "abort") {
|
|
14638
14661
|
return null;
|