@0perator/operator 0.1.158 → 0.1.159

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/CHANGELOG.md CHANGED
@@ -4,6 +4,16 @@ Operator is AXE's terminal coding agent (npm `@0perator/operator`), running on A
4
4
  Newest first. Every release bumps `src/cli.tsx` VERSION + `package.json`, adds an entry here, and ships to
5
5
  npm + both git remotes (memjar/kode, axetechnologies/kode). Test counts are the full suite at that release.
6
6
 
7
+ ## 0.1.159 — 2026-09-29 — fix: checkpoint no longer wedges on a stale git index lock
8
+ - **The recurring "checkpoints don't work" bug, root-caused + fixed.** The 0.1.148 SIGKILL-on-timeout
9
+ hardening made checkpoints un-hangable — but a `git` killed mid-add/commit leaves `.git/index.lock`
10
+ orphaned, and git never clears it, so **every subsequent checkpoint** died with `fatal: Unable to create
11
+ '.git/index.lock': File exists` (seen live on JL2, 0.1.151). Now `clearStaleCheckpointLock()` removes the
12
+ lock before committing, but **only when it's older than 30s** — a live add/commit holds it for well under
13
+ a second, so an aged lock is provably orphaned by a prior killed run, while a concurrent op's fresh lock
14
+ is never touched (worktree-safe via `git rev-parse --git-dir`). Real-git test proves both: stale lock
15
+ cleared + commits; fresh lock preserved + the lock error still surfaces. Suite 721 green (+2).
16
+
7
17
  ## 0.1.158 — 2026-09-29 — fix: TUI capability-detection review findings
8
18
  - Adversarial review of the 0.1.156 TUI foundation surfaced real gaps, now fixed: (1) `truecolor` was
9
19
  conflated with the graphics-protocol flag, under-detecting VS Code/Warp/Hyper/Tabby — split into an
@@ -449,6 +449,27 @@ function checkpointGitEnv() {
449
449
  async function checkpointGit(gitArgs, cwd, timeout) {
450
450
  return pexecFile("git", gitArgs, { cwd, timeout, killSignal: "SIGKILL", env: checkpointGitEnv(), maxBuffer: 16 * 1024 * 1024 });
451
451
  }
452
+ // Our own SIGKILL-on-timeout hardening (above) fixed checkpoint HANGS but introduced a failure mode: a
453
+ // `git` killed mid-add/commit leaves its `.git/index.lock` orphaned, and EVERY later checkpoint then dies
454
+ // with "fatal: Unable to create '.git/index.lock': File exists" (seen live on JL2, 0.1.151). git never
455
+ // clears it. So before committing we remove a STALE lock — one older than any live index op could hold
456
+ // (a real add/commit holds it well under a second; a lock this old is orphaned by a prior killed run).
457
+ // Age-gated so a concurrent legit git op's fresh lock is never touched. Best-effort: any error → proceed.
458
+ const STALE_LOCK_MS = 30_000;
459
+ async function clearStaleCheckpointLock(workspace) {
460
+ try {
461
+ const gitDir = (await checkpointGit(["rev-parse", "--git-dir"], workspace, 10_000)).stdout.trim();
462
+ if (!gitDir)
463
+ return;
464
+ const { isAbsolute, join } = (await nodeImport("node:path"));
465
+ const lock = join(isAbsolute(gitDir) ? gitDir : join(workspace, gitDir), "index.lock");
466
+ const fs = (await nodeImport("node:fs/promises"));
467
+ const st = await fs.stat(lock).catch(() => null);
468
+ if (st && Date.now() - st.mtimeMs > STALE_LOCK_MS)
469
+ await fs.unlink(lock).catch(() => { });
470
+ }
471
+ catch { /* best-effort — if this fails the checkpoint just proceeds and may error as before */ }
472
+ }
452
473
  // checkpoint = git add+commit in workspace + a memory note, one call (SPEC §8). Never adds
453
474
  // Co-Authored-By / AI attribution — the commit message is exactly the caller's summary.
454
475
  async function checkpoint(args) {
@@ -470,6 +491,10 @@ async function checkpoint(args) {
470
491
  await checkpointGit(["init"], workspace, 10_000);
471
492
  initialized = true;
472
493
  }
494
+ else {
495
+ // Clear a lock orphaned by a PRIOR killed checkpoint before it dooms this one (see helper above).
496
+ await clearStaleCheckpointLock(workspace);
497
+ }
473
498
  await checkpointGit(["add", "-A"], workspace, 120_000);
474
499
  try {
475
500
  await checkpointGit(["commit", "--no-verify", "-m", summary], workspace, 60_000);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0perator/operator",
3
- "version": "0.1.158",
3
+ "version": "0.1.159",
4
4
  "description": "Operator (KODE) — TypeScript + Ink terminal coding agent. Full-frame render, single-engine core shared across CLI/web/mobile; runs against a local Aurora model.",
5
5
  "type": "module",
6
6
  "bin": {