@0perator/operator 0.1.157 → 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,26 @@ 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
+
17
+ ## 0.1.158 — 2026-09-29 — fix: TUI capability-detection review findings
18
+ - Adversarial review of the 0.1.156 TUI foundation surfaced real gaps, now fixed: (1) `truecolor` was
19
+ conflated with the graphics-protocol flag, under-detecting VS Code/Warp/Hyper/Tabby — split into an
20
+ independent per-terminal field; (2) `tmux` was detected but never consumed — now gates `graphics` OFF
21
+ under tmux (inline images break without allow-passthrough); (3) Alacritty `osc8` was stale-false → true
22
+ (shipped in v0.13, 2024); (4) `mouse` no longer requires a non-empty `TERM` (isTTY already excludes
23
+ non-terminals; SGR mouse is universal); (5) `hyperlinkHint` doc corrected to inline-boot-only. Tests
24
+ +7 (truecolor independence, tmux gate, all known terminals, case-insensitivity, `caps()` caching,
25
+ empty-env). Suite 719 green. Also indexed the sandbox + TUI docs in `_ai-docs` (kiyoko).
26
+
7
27
  ## 0.1.157 — 2026-09-29 — remote: RC auto-start default ON for every session
8
28
  - `rcAutostart()` no longer gates on the admin tier — **every Operator session self-hosts Remote Control
9
29
  by default**, so mobile SessionsView + the desktop RemotePane attach with no config ("default on for
@@ -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);
@@ -7,19 +7,20 @@
7
7
  // feature misbehave, a false "unsupported" only forgoes a nicety. OSC 8 hyperlinks in particular
8
8
  // DEGRADE safely everywhere (osc.ts already emits them; an unsupporting terminal shows the label), so
9
9
  // `osc8` here drives HINTS/affordances, not whether links are emitted.
10
- // Known emulators keyed by the lowercased TERM_PROGRAM value, with a display name and whether they
11
- // honor OSC 8 clicks. Apple_Terminal is the notable OSC-8 holdout among common macOS terminals.
10
+ // Known emulators keyed by the lowercased TERM_PROGRAM value. `osc8`/`graphics`/`truecolor` are tracked
11
+ // INDEPENDENTLY — a terminal can do 24-bit color without an inline-image protocol (e.g. VS Code, Warp).
12
+ // Apple_Terminal is the notable holdout: no OSC 8, no truecolor (256-color only).
12
13
  const KNOWN = {
13
- "iterm.app": { name: "iTerm2", osc8: true, graphics: true },
14
- "apple_terminal": { name: "Terminal.app", osc8: false, graphics: false },
15
- "ghostty": { name: "Ghostty", osc8: true, graphics: true },
16
- "wezterm": { name: "WezTerm", osc8: true, graphics: true },
17
- "vscode": { name: "VS Code", osc8: true, graphics: false },
18
- "hyper": { name: "Hyper", osc8: true, graphics: false },
19
- "tabby": { name: "Tabby", osc8: true, graphics: false },
20
- "rio": { name: "Rio", osc8: true, graphics: true },
21
- "warpterminal": { name: "Warp", osc8: true, graphics: false },
22
- "alacritty": { name: "Alacritty", osc8: false, graphics: false }, // OSC 8 landed only very recently; treat as no
14
+ "iterm.app": { name: "iTerm2", osc8: true, graphics: true, truecolor: true },
15
+ "apple_terminal": { name: "Terminal.app", osc8: false, graphics: false, truecolor: false },
16
+ "ghostty": { name: "Ghostty", osc8: true, graphics: true, truecolor: true },
17
+ "wezterm": { name: "WezTerm", osc8: true, graphics: true, truecolor: true },
18
+ "vscode": { name: "VS Code", osc8: true, graphics: false, truecolor: true },
19
+ "hyper": { name: "Hyper", osc8: true, graphics: false, truecolor: true },
20
+ "tabby": { name: "Tabby", osc8: true, graphics: false, truecolor: true },
21
+ "rio": { name: "Rio", osc8: true, graphics: true, truecolor: true },
22
+ "warpterminal": { name: "Warp", osc8: true, graphics: false, truecolor: true },
23
+ "alacritty": { name: "Alacritty", osc8: true, graphics: false, truecolor: true }, // OSC 8 since v0.13 (2024)
23
24
  };
24
25
  /** Pure detection from an explicit env + TTY flag. Exported for unit tests; production reads via caps(). */
25
26
  export function detectCaps(env, isTTY) {
@@ -33,12 +34,15 @@ export function detectCaps(env, isTTY) {
33
34
  const name = known?.name ?? (isKitty ? "Kitty" : tp || term || "terminal");
34
35
  // OSC 8: a known-supporting emulator, or Kitty. Unknown terminals → false for HINTS only (links are
35
36
  // still emitted by osc.ts and degrade to the label). Non-TTY is never "supported".
36
- const osc8 = isTTY && (known?.osc8 ?? isKitty ?? false) === true;
37
- const truecolor = isTTY && (colorterm === "truecolor" || colorterm === "24bit" || isKitty || known?.graphics === true);
37
+ const osc8 = isTTY && (known?.osc8 ?? isKitty);
38
+ // Truecolor is INDEPENDENT of graphics: COLORTERM wins, else the per-terminal flag, else Kitty.
39
+ const truecolor = isTTY && (colorterm === "truecolor" || colorterm === "24bit" || isKitty || known?.truecolor === true);
38
40
  // SGR mouse reporting is universal on modern terminals; the only real exclusions are non-TTY and
39
41
  // the legacy dumb terminal. We stay permissive here and gate mouse USE on `fullscreen` + this flag.
40
- const mouse = isTTY && term !== "dumb" && term !== "";
41
- const graphics = isTTY && (isKitty || known?.graphics === true);
42
+ const mouse = isTTY && term !== "dumb"; // isTTY already excludes non-terminals; SGR mouse is universal otherwise
43
+ // Inline-image protocols break under tmux without `allow-passthrough` (murky to detect), so gate
44
+ // graphics OFF inside tmux — the one place the tmux flag is actually consumed (matches the doc above).
45
+ const graphics = isTTY && !tmux && (isKitty || known?.graphics === true);
42
46
  return { isTTY, termProgram: tp, termName: name, osc8, truecolor, mouse, graphics, tmux };
43
47
  }
44
48
  let _caps = null;
@@ -51,7 +55,8 @@ export function caps() {
51
55
  }
52
56
  /** One-line hint when the current terminal won't render clickable links — so the owner knows switching
53
57
  * to iTerm2/Ghostty/Kitty/WezTerm makes URLs + artifact links clickable. Empty string when links work
54
- * (or output isn't a TTY). Shown once at boot by the CLI, never mid-stream. */
58
+ * (or output isn't a TTY). Printed once after the INLINE boot masthead (cli.tsx); fullscreen/alt-screen
59
+ * sessions skip it here — they'll surface it via the status rule with the Phase 1 mouse-layer work. */
55
60
  export function hyperlinkHint(c = caps()) {
56
61
  if (!c.isTTY || c.osc8)
57
62
  return "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0perator/operator",
3
- "version": "0.1.157",
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": {