sisyphi 1.2.21 → 1.2.23

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/daemon.js CHANGED
@@ -1793,7 +1793,7 @@ function planSendKeys(state) {
1793
1793
  return { action: "send" };
1794
1794
  }
1795
1795
  function getPaneState(paneTarget) {
1796
- const out = execSafe(`tmux display-message -t ${t(paneTarget)} -p '#{pane_dead} #{pane_in_mode}'`, void 0, TMUX_TIMEOUT_MS);
1796
+ const out = texecSafe(`tmux display-message -t ${t(paneTarget)} -p '#{pane_dead} #{pane_in_mode}'`, void 0, TMUX_TIMEOUT_MS);
1797
1797
  if (out === null) return { exists: false, dead: false, inMode: false };
1798
1798
  const [deadStr, modeStr] = out.split(" ");
1799
1799
  return { exists: true, dead: deadStr === "1", inMode: modeStr === "1" };
@@ -1804,8 +1804,8 @@ function createPane(windowTarget, cwd, position = "right") {
1804
1804
  const target = position === "left" ? panes[0]?.paneId : panes[panes.length - 1]?.paneId;
1805
1805
  const targetFlag = target ? ` -t ${t(target)}` : ` -t ${t(windowTarget)}`;
1806
1806
  const beforeFlag = position === "left" ? "b" : "";
1807
- const paneId = exec(`tmux split-window -h${beforeFlag}${targetFlag}${cwdFlag} -P -F "#{pane_id}"`);
1808
- execSafe(`tmux select-layout -t ${t(windowTarget)} even-horizontal`);
1807
+ const paneId = texec(`tmux split-window -h${beforeFlag}${targetFlag}${cwdFlag} -P -F "#{pane_id}"`);
1808
+ texecSafe(`tmux select-layout -t ${t(windowTarget)} even-horizontal`);
1809
1809
  return paneId;
1810
1810
  }
1811
1811
  function sendKeys(paneTarget, command) {
@@ -1813,16 +1813,16 @@ function sendKeys(paneTarget, command) {
1813
1813
  const { action } = planSendKeys(state);
1814
1814
  if (action === "abort") throw new PaneUnavailableError(paneTarget, state);
1815
1815
  if (action === "cancel-then-send") {
1816
- execSafe(`tmux send-keys -t ${t(paneTarget)} -X cancel`, void 0, TMUX_TIMEOUT_MS);
1816
+ texecSafe(`tmux send-keys -t ${t(paneTarget)} -X cancel`, void 0, TMUX_TIMEOUT_MS);
1817
1817
  }
1818
- exec(`tmux send-keys -t ${t(paneTarget)} ${shellQuote(command)} Enter`, void 0, TMUX_TIMEOUT_MS);
1818
+ texec(`tmux send-keys -t ${t(paneTarget)} ${shellQuote(command)} Enter`, void 0, TMUX_TIMEOUT_MS);
1819
1819
  }
1820
1820
  function pasteToPane(paneTarget, text, submit) {
1821
1821
  const state = getPaneState(paneTarget);
1822
1822
  const { action } = planSendKeys(state);
1823
1823
  if (action === "abort") throw new PaneUnavailableError(paneTarget, state);
1824
1824
  if (action === "cancel-then-send") {
1825
- execSafe(`tmux send-keys -t ${t(paneTarget)} -X cancel`, void 0, TMUX_TIMEOUT_MS);
1825
+ texecSafe(`tmux send-keys -t ${t(paneTarget)} -X cancel`, void 0, TMUX_TIMEOUT_MS);
1826
1826
  }
1827
1827
  const bufName = `sisyphus-tell-${Math.random().toString(36).slice(2, 10)}`;
1828
1828
  execSync3(`tmux load-buffer -b ${shellQuote(bufName)} -`, {
@@ -1832,47 +1832,47 @@ function pasteToPane(paneTarget, text, submit) {
1832
1832
  stdio: ["pipe", "pipe", "pipe"]
1833
1833
  });
1834
1834
  try {
1835
- exec(`tmux paste-buffer -t ${t(paneTarget)} -b ${shellQuote(bufName)} -d`, void 0, TMUX_TIMEOUT_MS);
1835
+ texec(`tmux paste-buffer -t ${t(paneTarget)} -b ${shellQuote(bufName)} -d`, void 0, TMUX_TIMEOUT_MS);
1836
1836
  } catch (err) {
1837
- execSafe(`tmux delete-buffer -b ${shellQuote(bufName)}`);
1837
+ texecSafe(`tmux delete-buffer -b ${shellQuote(bufName)}`);
1838
1838
  throw err;
1839
1839
  }
1840
1840
  if (submit) {
1841
- exec(`tmux send-keys -t ${t(paneTarget)} Enter`, void 0, TMUX_TIMEOUT_MS);
1841
+ texec(`tmux send-keys -t ${t(paneTarget)} Enter`, void 0, TMUX_TIMEOUT_MS);
1842
1842
  }
1843
1843
  }
1844
1844
  function killPane(paneTarget) {
1845
- execSafe(`tmux kill-pane -t ${t(paneTarget)}`);
1845
+ texecSafe(`tmux kill-pane -t ${t(paneTarget)}`);
1846
1846
  }
1847
1847
  function killWindow(windowTarget) {
1848
- execSafe(`tmux kill-window -t ${t(windowTarget)}`);
1848
+ texecSafe(`tmux kill-window -t ${t(windowTarget)}`);
1849
1849
  }
1850
1850
  function createSession2(sessionName, cwd) {
1851
- const sessionId = exec(`tmux new-session -d -s ${t(sessionName)} -n main -c ${shellQuote(cwd)} -P -F "#{session_id}"`);
1852
- const windowId = exec(`tmux display-message -t ${t(sessionId + ":main")} -p "#{window_id}"`);
1853
- const initialPaneId = exec(`tmux display-message -t ${t(sessionId + ":main")} -p "#{pane_id}"`);
1851
+ const sessionId = texec(`tmux new-session -d -s ${t(sessionName)} -n main -c ${shellQuote(cwd)} -P -F "#{session_id}"`);
1852
+ const windowId = texec(`tmux display-message -t ${t(sessionId + ":main")} -p "#{window_id}"`);
1853
+ const initialPaneId = texec(`tmux display-message -t ${t(sessionId + ":main")} -p "#{pane_id}"`);
1854
1854
  configureSessionDefaults(sessionId, windowId);
1855
1855
  return { windowId, initialPaneId, sessionId };
1856
1856
  }
1857
1857
  function paneExists(paneTarget) {
1858
- return execSafe(`tmux display-message -t ${t(paneTarget)} -p "#{pane_id}"`) !== null;
1858
+ return texecSafe(`tmux display-message -t ${t(paneTarget)} -p "#{pane_id}"`) !== null;
1859
1859
  }
1860
1860
  function getPanePid(paneTarget) {
1861
- const out = execSafe(`tmux display-message -t ${t(paneTarget)} -p "#{pane_pid}"`, void 0, TMUX_TIMEOUT_MS);
1861
+ const out = texecSafe(`tmux display-message -t ${t(paneTarget)} -p "#{pane_pid}"`, void 0, TMUX_TIMEOUT_MS);
1862
1862
  if (!out) return null;
1863
1863
  const pid = parseInt(out.trim(), 10);
1864
1864
  return Number.isFinite(pid) ? pid : null;
1865
1865
  }
1866
1866
  function sessionExistsById(tmuxSessionId) {
1867
- return execSafe(`tmux has-session -t ${t(tmuxSessionId)}`) !== null;
1867
+ return texecSafe(`tmux has-session -t ${t(tmuxSessionId)}`) !== null;
1868
1868
  }
1869
1869
  function sessionNameTaken(sessionName) {
1870
- const output = execSafe('tmux list-sessions -F "#{session_name}"');
1870
+ const output = texecSafe('tmux list-sessions -F "#{session_name}"');
1871
1871
  if (!output) return false;
1872
1872
  return output.split("\n").some((line) => line === sessionName);
1873
1873
  }
1874
1874
  function resolveSessionId(sessionName) {
1875
- const output = execSafe('tmux list-sessions -F "#{session_id} #{session_name}"');
1875
+ const output = texecSafe('tmux list-sessions -F "#{session_id} #{session_name}"');
1876
1876
  if (!output) return null;
1877
1877
  for (const line of output.split("\n").filter(Boolean)) {
1878
1878
  const { sessionId, name } = parseSessionLine(line);
@@ -1890,43 +1890,43 @@ function initSessionMeta(tmuxTarget, cwd, sisyphusSessionId) {
1890
1890
  setSessionOption(tmuxTarget, "@sisyphus_session_id", sisyphusSessionId);
1891
1891
  }
1892
1892
  function killSession(target) {
1893
- execSafe(`tmux kill-session -t ${t(target)}`);
1893
+ texecSafe(`tmux kill-session -t ${t(target)}`);
1894
1894
  }
1895
1895
  function renameSession(target, newName) {
1896
- exec(`tmux rename-session -t ${t(target)} ${t(newName)}`);
1896
+ texec(`tmux rename-session -t ${t(target)} ${t(newName)}`);
1897
1897
  }
1898
1898
  function setSessionOption(target, option, value) {
1899
- execSafe(`tmux set-option -t ${t(target)} ${option} ${shellQuote(value)}`);
1899
+ texecSafe(`tmux set-option -t ${t(target)} ${option} ${shellQuote(value)}`);
1900
1900
  }
1901
1901
  function parseSessionLine(line) {
1902
1902
  const spaceIdx = line.indexOf(" ");
1903
1903
  return { sessionId: line.slice(0, spaceIdx), name: line.slice(spaceIdx + 1) };
1904
1904
  }
1905
1905
  function findHomeSession(cwd) {
1906
- const output = execSafe('tmux list-sessions -F "#{session_id} #{session_name}"');
1906
+ const output = texecSafe('tmux list-sessions -F "#{session_id} #{session_name}"');
1907
1907
  if (!output) return null;
1908
1908
  const normalizedCwd = cwd.replace(/\/+$/, "");
1909
1909
  for (const line of output.split("\n").filter(Boolean)) {
1910
1910
  const { sessionId: sessId, name } = parseSessionLine(line);
1911
1911
  if (name.startsWith("ssyph_")) continue;
1912
- const val = execSafe(`tmux show-options -t ${t(sessId)} -v @sisyphus_cwd`);
1912
+ const val = texecSafe(`tmux show-options -t ${t(sessId)} -v @sisyphus_cwd`);
1913
1913
  if (val?.trim() === normalizedCwd) return sessId;
1914
1914
  }
1915
1915
  return null;
1916
1916
  }
1917
1917
  function switchAttachedClients(sourceTarget, destTarget) {
1918
- if (execSafe(`tmux has-session -t ${t(destTarget)}`) === null) return;
1919
- const output = execSafe(`tmux list-clients -t ${t(sourceTarget)} -F "#{client_tty}"`);
1918
+ if (texecSafe(`tmux has-session -t ${t(destTarget)}`) === null) return;
1919
+ const output = texecSafe(`tmux list-clients -t ${t(sourceTarget)} -F "#{client_tty}"`);
1920
1920
  if (!output) return;
1921
1921
  for (const tty of output.split("\n").filter(Boolean)) {
1922
- execSafe(`tmux switch-client -c ${t(tty)} -t ${t(destTarget)}`);
1922
+ texecSafe(`tmux switch-client -c ${t(tty)} -t ${t(destTarget)}`);
1923
1923
  }
1924
1924
  }
1925
1925
  function getFirstWindowId(sessionTarget) {
1926
- return execSafe(`tmux list-windows -t ${t(sessionTarget)} -F "#{window_id}" -f "#{==:#{window_index},0}"`)?.trim() || null;
1926
+ return texecSafe(`tmux list-windows -t ${t(sessionTarget)} -F "#{window_id}" -f "#{==:#{window_index},0}"`)?.trim() || null;
1927
1927
  }
1928
1928
  function listPanes(windowTarget) {
1929
- const output = execSafe(`tmux list-panes -t ${t(windowTarget)} -F "#{pane_id} #{pane_pid}"`, void 0, TMUX_TIMEOUT_MS);
1929
+ const output = texecSafe(`tmux list-panes -t ${t(windowTarget)} -F "#{pane_id} #{pane_pid}"`, void 0, TMUX_TIMEOUT_MS);
1930
1930
  if (!output) return [];
1931
1931
  return output.split("\n").filter(Boolean).map((line) => {
1932
1932
  const [paneId, panePid] = line.split(" ");
@@ -1934,7 +1934,7 @@ function listPanes(windowTarget) {
1934
1934
  });
1935
1935
  }
1936
1936
  function listAllPanesByWindow() {
1937
- const output = execSafe('tmux list-panes -a -F "#{window_id} #{pane_id} #{pane_pid}"', void 0, TMUX_TIMEOUT_MS);
1937
+ const output = texecSafe('tmux list-panes -a -F "#{window_id} #{pane_id} #{pane_pid}"', void 0, TMUX_TIMEOUT_MS);
1938
1938
  const map = /* @__PURE__ */ new Map();
1939
1939
  if (!output) return map;
1940
1940
  for (const line of output.split("\n")) {
@@ -1948,17 +1948,17 @@ function listAllPanesByWindow() {
1948
1948
  return map;
1949
1949
  }
1950
1950
  function setPaneTitle(paneTarget, title) {
1951
- execSafe(`tmux select-pane -t ${t(paneTarget)} -T ${shellQuote(title)}`);
1951
+ texecSafe(`tmux select-pane -t ${t(paneTarget)} -T ${shellQuote(title)}`);
1952
1952
  }
1953
1953
  function setPaneStyle(paneTarget, color, meta) {
1954
1954
  const gitBranch = `#(cd #{pane_current_path} && git branch --show-current 2>/dev/null)`;
1955
1955
  const branchSuffix = `#(cd #{pane_current_path} && git branch --show-current 2>/dev/null | grep -q . && echo ' |') ${gitBranch}`;
1956
1956
  const homePath = `#(echo '#{pane_current_path}' | sed "s|^$HOME|~|")`;
1957
- execSafe(`tmux set -p -t ${t(paneTarget)} @pane_role ${shellQuote(meta.role)}`);
1958
- execSafe(`tmux set -p -t ${t(paneTarget)} @pane_session ${shellQuote(meta.session)}`);
1959
- execSafe(`tmux set -p -t ${t(paneTarget)} @pane_cycle ${shellQuote(meta.cycle)}`);
1957
+ texecSafe(`tmux set -p -t ${t(paneTarget)} @pane_role ${shellQuote(meta.role)}`);
1958
+ texecSafe(`tmux set -p -t ${t(paneTarget)} @pane_session ${shellQuote(meta.session)}`);
1959
+ texecSafe(`tmux set -p -t ${t(paneTarget)} @pane_cycle ${shellQuote(meta.cycle)}`);
1960
1960
  if (meta.mode) {
1961
- execSafe(`tmux set -p -t ${t(paneTarget)} @pane_mode ${shellQuote(meta.mode)}`);
1961
+ texecSafe(`tmux set -p -t ${t(paneTarget)} @pane_mode ${shellQuote(meta.mode)}`);
1962
1962
  }
1963
1963
  const modeSegment = `#{?#{@pane_mode}, #[fg=${color}\\,italics]#{@pane_mode}#[default],}`;
1964
1964
  const fmt = [
@@ -1969,30 +1969,30 @@ function setPaneStyle(paneTarget, color, meta) {
1969
1969
  ` ${homePath}${branchSuffix}`,
1970
1970
  `#[default]`
1971
1971
  ].join("");
1972
- execSafe(`tmux set -p -t ${t(paneTarget)} pane-border-format ${shellQuote(fmt)}`);
1972
+ texecSafe(`tmux set -p -t ${t(paneTarget)} pane-border-format ${shellQuote(fmt)}`);
1973
1973
  }
1974
1974
  function updatePaneMeta(paneTarget, updates) {
1975
- if (updates.role !== void 0) execSafe(`tmux set -p -t ${t(paneTarget)} @pane_role ${shellQuote(updates.role)}`);
1976
- if (updates.session !== void 0) execSafe(`tmux set -p -t ${t(paneTarget)} @pane_session ${shellQuote(updates.session)}`);
1977
- if (updates.cycle !== void 0) execSafe(`tmux set -p -t ${t(paneTarget)} @pane_cycle ${shellQuote(updates.cycle)}`);
1978
- if (updates.mode !== void 0) execSafe(`tmux set -p -t ${t(paneTarget)} @pane_mode ${shellQuote(updates.mode)}`);
1975
+ if (updates.role !== void 0) texecSafe(`tmux set -p -t ${t(paneTarget)} @pane_role ${shellQuote(updates.role)}`);
1976
+ if (updates.session !== void 0) texecSafe(`tmux set -p -t ${t(paneTarget)} @pane_session ${shellQuote(updates.session)}`);
1977
+ if (updates.cycle !== void 0) texecSafe(`tmux set -p -t ${t(paneTarget)} @pane_cycle ${shellQuote(updates.cycle)}`);
1978
+ if (updates.mode !== void 0) texecSafe(`tmux set -p -t ${t(paneTarget)} @pane_mode ${shellQuote(updates.mode)}`);
1979
1979
  }
1980
1980
  function selectLayout(windowTarget, layout = "even-horizontal") {
1981
- execSafe(`tmux select-layout -t ${t(windowTarget)} ${layout}`);
1981
+ texecSafe(`tmux select-layout -t ${t(windowTarget)} ${layout}`);
1982
1982
  }
1983
1983
  function setWindowOption(windowTarget, option, value) {
1984
- execSafe(`tmux set-option -w -t ${t(windowTarget)} ${option} ${shellQuote(value)}`);
1984
+ texecSafe(`tmux set-option -w -t ${t(windowTarget)} ${option} ${shellQuote(value)}`);
1985
1985
  }
1986
1986
  function getSessionOption(target, option) {
1987
- return execSafe(`tmux show-options -t ${t(target)} -v ${option}`);
1987
+ return texecSafe(`tmux show-options -t ${t(target)} -v ${option}`);
1988
1988
  }
1989
1989
  function listAllSessions() {
1990
- const output = execSafe('tmux list-sessions -F "#{session_id} #{session_name}"');
1990
+ const output = texecSafe('tmux list-sessions -F "#{session_id} #{session_name}"');
1991
1991
  if (!output) return [];
1992
1992
  return output.split("\n").filter(Boolean).map(parseSessionLine);
1993
1993
  }
1994
1994
  function listAllPanes() {
1995
- const output = execSafe('tmux list-panes -a -F "#{session_name} #{pane_id}"');
1995
+ const output = texecSafe('tmux list-panes -a -F "#{session_name} #{pane_id}"');
1996
1996
  if (!output) return [];
1997
1997
  return output.split("\n").filter(Boolean).map((line) => {
1998
1998
  const spaceIdx = line.indexOf(" ");
@@ -2000,7 +2000,7 @@ function listAllPanes() {
2000
2000
  });
2001
2001
  }
2002
2002
  function listAllWindowsBySession() {
2003
- const output = execSafe('tmux list-windows -a -F "#{session_name} #{window_index} #{window_id} #{window_name}"', void 0, TMUX_TIMEOUT_MS);
2003
+ const output = texecSafe('tmux list-windows -a -F "#{session_name} #{window_index} #{window_id} #{window_name}"', void 0, TMUX_TIMEOUT_MS);
2004
2004
  const map = /* @__PURE__ */ new Map();
2005
2005
  if (!output) return map;
2006
2006
  for (const line of output.split("\n")) {
@@ -2017,13 +2017,13 @@ function listAllWindowsBySession() {
2017
2017
  return map;
2018
2018
  }
2019
2019
  function configureSessionDefaults(sessionTarget, windowId) {
2020
- execSafe(`tmux set -w -t ${t(windowId)} pane-border-status top`);
2021
- execSafe(`tmux set -w -t ${t(windowId)} allow-rename off`);
2022
- execSafe(`tmux set -w -t ${t(windowId)} automatic-rename off`);
2023
- execSafe(`tmux set-hook -t ${t(sessionTarget)} after-kill-pane "select-layout even-horizontal"`);
2024
- execSafe(`tmux set-hook -t ${t(sessionTarget)} pane-exited "select-layout even-horizontal"`);
2020
+ texecSafe(`tmux set -w -t ${t(windowId)} pane-border-status top`);
2021
+ texecSafe(`tmux set -w -t ${t(windowId)} allow-rename off`);
2022
+ texecSafe(`tmux set -w -t ${t(windowId)} automatic-rename off`);
2023
+ texecSafe(`tmux set-hook -t ${t(sessionTarget)} after-kill-pane "select-layout even-horizontal"`);
2024
+ texecSafe(`tmux set-hook -t ${t(sessionTarget)} pane-exited "select-layout even-horizontal"`);
2025
2025
  }
2026
- var t, TMUX_TIMEOUT_MS, PaneUnavailableError;
2026
+ var t, TMUX_TIMEOUT_MS, texec, texecSafe, PaneUnavailableError;
2027
2027
  var init_tmux = __esm({
2028
2028
  "src/daemon/tmux.ts"() {
2029
2029
  "use strict";
@@ -2032,6 +2032,8 @@ var init_tmux = __esm({
2032
2032
  init_exec();
2033
2033
  t = (target) => shellQuote(target);
2034
2034
  TMUX_TIMEOUT_MS = 5e3;
2035
+ texec = (cmd, cwd, timeoutMs = TMUX_TIMEOUT_MS) => exec(cmd, cwd, timeoutMs);
2036
+ texecSafe = (cmd, cwd, timeoutMs = TMUX_TIMEOUT_MS) => execSafe(cmd, cwd, timeoutMs);
2035
2037
  PaneUnavailableError = class extends Error {
2036
2038
  constructor(paneTarget, state) {
2037
2039
  super(`pane ${paneTarget} unavailable (exists=${state.exists}, dead=${state.dead}, inMode=${state.inMode})`);