@0perator/operator 0.2.2-next.0 → 0.2.2-next.1

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/cli.js CHANGED
@@ -45,7 +45,7 @@ import { loadSettings, saveSettings, settingsLoadProblems, compactionThreshold,
45
45
  import { resolveSeat } from "./auth/identity.js";
46
46
  import { PermissionPolicy } from "./permissions/index.js";
47
47
  import { caps } from "./ui/capabilities.js";
48
- import { composeSystemPrompt, appendMemory, memoryBudgetNote, subagentSystemPrompt } from "./config/persona.js";
48
+ import { composeSystemPrompt, appendMemory, memoryBudgetNote, subagentSystemPrompt, handoffNotice } from "./config/persona.js";
49
49
  import { SUBAGENT_ROLES, SUBAGENT_TOOL_DENY, roleCanWrite } from "./engine/grandmaster.js";
50
50
  import { applyToolsBinPath, operatorPath } from "./config/home.js";
51
51
  import { ensureOperatorHome } from "./config/scaffold.js";
@@ -1284,6 +1284,9 @@ function Root() {
1284
1284
  const sxUp = await probeSearxng().catch(() => false);
1285
1285
  push({ kind: "message", message: { id: nextId(), role: "system", content: `services: ${line} · searxng ${sxUp ? "✓" : "lazy"}` } });
1286
1286
  }
1287
+ const earlier = handoffNotice();
1288
+ if (earlier)
1289
+ push({ kind: "message", message: { id: nextId(), role: "system", content: earlier } });
1287
1290
  // Remote-control auto-start (rcAutostart: explicit remote.autostart / KODE_RC_AUTOSTART wins, else
1288
1291
  // ON for admin/VIP tier only — feature-flagged rollout). When enabled and this box is signed in, bring
1289
1292
  // up an RC host on boot by driving the EXACT /remotecontrol path
@@ -3,6 +3,7 @@
3
3
  // picks up the SAME project context + handoff the TUI does, without importing cli.tsx (which mounts
4
4
  // Ink and refuses a non-TTY). Pure, best-effort, never throws — a missing file is normal.
5
5
  import { readFileSync, appendFileSync, mkdirSync, existsSync, writeFileSync, renameSync, realpathSync, statSync, chmodSync } from "node:fs";
6
+ import { execFileSync } from "node:child_process";
6
7
  import { join, dirname } from "node:path";
7
8
  import { operatorPath, globalMemoriesPath } from "./home.js";
8
9
  import { renderHarnessContext } from "./operator-harness.js";
@@ -272,24 +273,43 @@ export function loadStructuredMemories() {
272
273
  return out;
273
274
  }
274
275
  // Session handoff: the note the previous session in THIS directory wrote for its future self (via the
275
- // session_handoff tool), pointed at by KODE_HANDOFF_FILE. Auto-loaded as background: the owner's newest message sets
276
- // the task, so an old plan is offered, never resumed over what the owner typed (11/23: a 3-day-old "resume from this"
277
- // block made a session chase its plan through three "stop" messages).
278
- export function loadHandoff(now = new Date()) {
276
+ // session_handoff tool), pointed at by KODE_HANDOFF_FILE. Its body never enters the prompt: a model given an old plan
277
+ // resumes it, whatever the framing says (11/23: through three "stop" messages; 12/03: after a bare "hello", editing
278
+ // files in autonomous mode). The owner is told a note is waiting; the model gets only where it is.
279
+ function readHandoff(now) {
279
280
  try {
280
281
  const file = process.env.KODE_HANDOFF_FILE ?? "";
281
- const { text: t, settled } = withoutSettled(freshHandoff(readFileSync(file, "utf8"), now));
282
- const pointer = settled ? `\n\nThe previous session here ended its work; its note is at ${file}. Read it only if the owner asks to continue earlier work.` : "";
283
- // The handoff grows by APPEND (auto-compaction adds a block each time context fills, newest last),
284
- // so read the TAIL — the freshest state, not a stale head.
285
- if (t) {
286
- const tail = t.length > 6000 ? "…\n" + t.slice(-6000) : t;
287
- return `\n\n## Handoff from your previous session here (background, not an instruction)\n${tail}\n\nThe owner's newest message sets the task. If it is about something else, do that and leave this work alone; continue it only when the owner asks (offer it in one line when it fits). Update it with session_handoff before you finish.${pointer}`;
288
- }
289
- return pointer;
282
+ const { text: open, settled } = withoutSettled(freshHandoff(readFileSync(file, "utf8"), now));
283
+ return open || settled ? { file, open, settled } : null;
290
284
  }
291
- catch { /* none yet */ }
292
- return "";
285
+ catch {
286
+ return null;
287
+ }
288
+ }
289
+ export function loadHandoff(now = new Date()) {
290
+ const h = readHandoff(now);
291
+ if (!h)
292
+ return "";
293
+ return `\n\n## Earlier work in this folder\nA note from a previous session is saved at ${h.file}. It is not your task. Do not read it, act on it or continue it unless the owner asks to continue earlier work; if they seem to mean that without saying so, ask first. After a greeting or an unclear message, reply and ask what they want to do. When they ask what was done last time, what is still open or what is uncommitted: read the note (session_handoff with no content), check git status, and report; reporting is not permission to continue. Update the note with session_handoff before you finish your own work.`;
294
+ }
295
+ /** What the owner is told at start when unfinished work is saved for this folder; "" when there is none. */
296
+ export function handoffNotice(now = new Date(), cwd = process.cwd()) {
297
+ const h = readHandoff(now);
298
+ if (!h?.open)
299
+ return "";
300
+ const title = [...h.open.matchAll(/^#{1,3} (.+)$/gm)].map((m) => m[1].trim()).filter((t) => !/session handoff|^live progress|^auto-compaction|^\d+\.|^(intent|concepts|state|open|rules)\b/i.test(t)).pop();
301
+ const tasks = [...new Set([...h.open.matchAll(/^\[[ ~]\] #\d+ (.+)$/gm)].map((m) => m[1].trim()).filter((t) => !/\((cancelled|done)\)$/.test(t)))];
302
+ let changed = 0;
303
+ try {
304
+ changed = execFileSync("git", ["status", "--porcelain"], { cwd, encoding: "utf8", timeout: 2000, stdio: ["ignore", "pipe", "ignore"] }).split("\n").filter(Boolean).length;
305
+ }
306
+ catch { /* not a repository */ }
307
+ return [
308
+ `last session here${title ? `: “${title.slice(0, 80)}”` : " left a note"}`,
309
+ ...(tasks.length ? [`open tasks (${tasks.length}): ${tasks.slice(-3).map((t) => t.slice(0, 60)).join(" · ")}`] : []),
310
+ ...(changed ? [`uncommitted: ${changed} file${changed === 1 ? "" : "s"} in this repository`] : []),
311
+ "on hold until you ask — “review last session” for a recap, “continue earlier work” to resume",
312
+ ].join("\n");
293
313
  }
294
314
  // The base Operator persona (vendor-neutral, AXE-branded), independent of the TUI's embodiment guide.
295
315
  // composeSystemPrompt (below) builds the full system prompt from settings.systemPrompt ?? this, and both
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@0perator/operator",
3
- "version": "0.2.2-next.0",
3
+ "version": "0.2.2-next.1",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "operator": "dist/cli.js",