pi-note 0.33.1 → 0.33.3

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 CHANGED
@@ -96,8 +96,11 @@ Pi's working directory before exiting, so Kitty closes its dedicated tab (or the
96
96
  standalone window's last tab). It never merges, rebases or stashes local changes.
97
97
  If Git fails, times out (30 seconds), or the session/draft changes, Pi stays open;
98
98
  the task remains completed and is not retried. Check Git manually, then `/quit`.
99
- Non-Git directories or branches without an upstream also stay open after the
100
- failed pull. `/quit` and Exit without completing do not pull.
99
+ With pi-note 0.33.3+, directories outside Git, repositories without remotes, and
100
+ branches without a configured upstream skip the pull and exit without a warning.
101
+ Broken Git configuration, detached HEAD in a remote-backed repository, and failures
102
+ to pull a configured upstream still keep Pi open.
103
+ `/quit` and Exit without completing do not pull.
101
104
  This ownership survives `/reload`, but not `/new`, resume, fork, tree navigation
102
105
  or process restart. Completing a different task or an externally completed task
103
106
  does not pull or close Pi; failed/uncertain completion stays open.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-note",
3
- "version": "0.33.1",
3
+ "version": "0.33.3",
4
4
  "description": "Persistent pinote tasks, Markdown handoffs, and task status for Pi",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/remote/exit.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { spawnSync } from 'node:child_process';
1
2
  import { CustomEditor, type ExtensionAPI, type ExtensionContext } from '@earendil-works/pi-coding-agent';
2
3
  import { truncateToWidth } from '@earendil-works/pi-tui';
3
4
  import { clean } from './protocol.ts';
@@ -10,8 +11,24 @@ export async function pullBeforeExit(pi: ExtensionAPI, ctx: ExtensionContext, si
10
11
  const unchanged = () => current() && !signal.aborted && ctx.isIdle() &&
11
12
  ctx.sessionManager.getSessionId() === sessionId && ctx.sessionManager.getLeafId() === branch && ctx.ui.getEditorText() === draft;
12
13
  if (!unchanged()) return false;
13
- ctx.ui.notify('Task completed. Running git pull --ff-only before closing Pi…', 'info');
14
14
  try {
15
+ const git = (args: string[]) => spawnSync('git', args, {
16
+ cwd: ctx.cwd, encoding: 'utf8', timeout: 3000, env: { ...process.env, LC_ALL: 'C' },
17
+ });
18
+ const repository = git(['rev-parse', '--show-toplevel']);
19
+ if (!repository.error && repository.status === 128 && repository.stderr.startsWith('fatal: not a git repository (or any ')) return unchanged();
20
+ if (repository.error || repository.status !== 0 || !unchanged()) throw new Error('Git repository check failed');
21
+ const remotes = git(['remote']);
22
+ if (remotes.error || remotes.status !== 0) throw new Error('Git remote check failed');
23
+ if (!remotes.stdout.trim()) return unchanged();
24
+ const branch = git(['symbolic-ref', '--quiet', 'HEAD']);
25
+ if (branch.error || branch.status !== 0 || !branch.stdout.startsWith('refs/heads/')) throw new Error('Git branch check failed');
26
+ const branchName = branch.stdout.trim().slice('refs/heads/'.length);
27
+ const upstream = git(['config', '--get', `branch.${branchName}.merge`]);
28
+ if (upstream.error || (upstream.status !== 0 && upstream.status !== 1)) throw new Error('Git upstream check failed');
29
+ if (upstream.status === 1) return unchanged();
30
+ if (!upstream.stdout.trim() || !unchanged()) throw new Error('Git upstream or session changed');
31
+ ctx.ui.notify('Task completed. Running git pull --ff-only before closing Pi…', 'info');
15
32
  const result = await pi.exec('git', ['pull', '--ff-only', '--no-rebase', '--no-autostash'], { cwd: ctx.cwd, signal, timeout: 30_000 });
16
33
  if (result.code === 0 && !result.killed && unchanged()) return true;
17
34
  } catch { /* Completion succeeded; only the local pull failed. */ }