pantheon-cli 0.2.101 → 0.2.103

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 (2) hide show
  1. package/dist/pantheon.mjs +72 -3
  2. package/package.json +1 -1
package/dist/pantheon.mjs CHANGED
@@ -47734,6 +47734,7 @@ async function connect(opts) {
47734
47734
  }
47735
47735
  async function syncVault2(home, cloneUrl, auth2, quiet2) {
47736
47736
  retarget(home, cloneUrl, quiet2);
47737
+ abortInterruptedUpdate(home, quiet2);
47737
47738
  const updating = step("Updating the vault");
47738
47739
  try {
47739
47740
  execFileSync3("git", [...auth2, "-C", home, "pull", "--ff-only"], quiet2);
@@ -47753,20 +47754,80 @@ async function syncVault2(home, cloneUrl, auth2, quiet2) {
47753
47754
  (percent, phase) => updating.progress(percent, phase)
47754
47755
  );
47755
47756
  } catch (error2) {
47757
+ if (shouldPreserveAndReclone(error2)) {
47758
+ abortInterruptedUpdate(home, quiet2);
47759
+ return preserveAndReclone(
47760
+ home,
47761
+ cloneUrl,
47762
+ auth2,
47763
+ updating,
47764
+ "local and remote work kept separate"
47765
+ );
47766
+ }
47756
47767
  updating.fail();
47757
- throw error2;
47768
+ throw new Error(vaultUpdateMessage(error2));
47758
47769
  }
47759
47770
  updating.done("merged");
47760
47771
  return "";
47761
47772
  }
47773
+ return preserveAndReclone(
47774
+ home,
47775
+ cloneUrl,
47776
+ auth2,
47777
+ updating,
47778
+ "belongs to a different account"
47779
+ );
47780
+ }
47781
+ async function preserveAndReclone(home, cloneUrl, auth2, updating, note) {
47762
47782
  const archive = workspaceArchivePath(home);
47763
- updating.done("belongs to a different account");
47783
+ updating.done(note);
47764
47784
  renameSync4(home, archive);
47765
47785
  const aside = step("Setting the old vault aside");
47766
47786
  aside.done(archive);
47767
47787
  await clone2(cloneUrl, home, auth2, "Cloning the new vault");
47768
47788
  return archive;
47769
47789
  }
47790
+ function abortInterruptedUpdate(home, quiet2) {
47791
+ if (existsSync9(join10(home, ".git", "rebase-merge")) || existsSync9(join10(home, ".git", "rebase-apply"))) {
47792
+ try {
47793
+ execFileSync3("git", ["-C", home, "rebase", "--abort"], quiet2);
47794
+ } catch {
47795
+ }
47796
+ }
47797
+ if (existsSync9(join10(home, ".git", "MERGE_HEAD"))) {
47798
+ try {
47799
+ execFileSync3("git", ["-C", home, "merge", "--abort"], quiet2);
47800
+ } catch {
47801
+ }
47802
+ }
47803
+ }
47804
+ function gitFailureText(error2) {
47805
+ if (error2 instanceof Error) return error2.message;
47806
+ return String(error2);
47807
+ }
47808
+ function shouldPreserveAndReclone(error2) {
47809
+ const text2 = gitFailureText(error2).toLowerCase();
47810
+ return [
47811
+ "git reset --hard",
47812
+ "would be overwritten by merge",
47813
+ "automatic merge failed",
47814
+ "merge conflict",
47815
+ "conflict (",
47816
+ "cannot rebase onto multiple branches",
47817
+ "cannot fast-forward to multiple branches",
47818
+ "refusing to merge unrelated histories"
47819
+ ].some((signal) => text2.includes(signal));
47820
+ }
47821
+ function vaultUpdateMessage(error2) {
47822
+ const text2 = gitFailureText(error2).toLowerCase();
47823
+ if (text2.includes("authentication") || text2.includes("repository not found") || text2.includes("403") || text2.includes("401")) {
47824
+ return "Pantheon could not authenticate with the GitHub vault. Reconnect GitHub in Pantheon and generate a new pairing code.";
47825
+ }
47826
+ if (text2.includes("could not resolve host") || text2.includes("failed to connect") || text2.includes("network")) {
47827
+ return "Pantheon could not reach GitHub while updating the vault. Your local vault was left unchanged.";
47828
+ }
47829
+ return "Pantheon could not safely reconcile the local and GitHub vaults. Your local vault was left unchanged; generate a new pairing code and run connect again.";
47830
+ }
47770
47831
  async function clone2(cloneUrl, home, auth2, label) {
47771
47832
  const cloning = step(label);
47772
47833
  try {
@@ -47993,13 +48054,21 @@ function readStdin() {
47993
48054
 
47994
48055
  // src/errors.ts
47995
48056
  function printError(error2) {
47996
- const message = error2 instanceof Error ? error2.message : String(error2);
48057
+ const raw = error2 instanceof Error ? error2.message : String(error2);
48058
+ const message = publicErrorMessage(raw);
47997
48059
  const fix = hint2(message);
47998
48060
  console.error(`
47999
48061
  Error ${message}`);
48000
48062
  if (fix) console.error(` Next ${fix}`);
48001
48063
  console.error("");
48002
48064
  }
48065
+ function publicErrorMessage(message) {
48066
+ const text2 = message.toLowerCase();
48067
+ if (text2.includes("git reset --hard") || text2.includes("cannot rebase onto multiple branches") || text2.includes("cannot fast-forward to multiple branches")) {
48068
+ return "Pantheon could not safely reconcile the local and GitHub vaults. Your local files were preserved; generate a new pairing code and run connect again.";
48069
+ }
48070
+ return message;
48071
+ }
48003
48072
  function hint2(message) {
48004
48073
  const text2 = message.toLowerCase();
48005
48074
  if (text2.includes("expired") || text2.includes("already used")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pantheon-cli",
3
- "version": "0.2.101",
3
+ "version": "0.2.103",
4
4
  "description": "Carry agent conscience between AI coding agents. Hand off a conversation in one agent, resume it in another.",
5
5
  "license": "MIT",
6
6
  "type": "module",