@kw-yeh/vibeflow 4.11.58 → 4.11.61

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/vibeflow.mjs CHANGED
@@ -211,7 +211,7 @@ var init_pty = __esm({
211
211
  this.scrollbacks.set(key, cur.length > MAX_SCROLLBACK ? cur.slice(-MAX_SCROLLBACK) : cur);
212
212
  }
213
213
  async start(key, options) {
214
- const { cwd, command, onExit, cols = 80, rows = 24, fresh = false } = options;
214
+ const { cwd, command, onExit, fresh = false } = options;
215
215
  const running = this.sessions.get(key);
216
216
  if (running && !command && !fresh && running.cwd === cwd) {
217
217
  running.onExit = onExit;
@@ -221,6 +221,8 @@ var init_pty = __esm({
221
221
  const clearScrollback = Boolean(command) || fresh;
222
222
  const scrollback = clearScrollback ? null : this.scrollbacks.get(key) ?? null;
223
223
  if (clearScrollback) this.scrollbacks.delete(key);
224
+ const cols = options.cols ?? running?.proc.cols ?? 80;
225
+ const rows = options.rows ?? running?.proc.rows ?? 24;
224
226
  this.killNow(key);
225
227
  const shell = defaultShell();
226
228
  const proc = nodePty.spawn(shell, shellArgs(shell, command), {
@@ -421,7 +423,10 @@ var init_tmux_backend = __esm({
421
423
  return stdout.split("\n").map((line) => line.trim()).filter((name) => name.startsWith("vf-")).map((name) => name.slice(3));
422
424
  }
423
425
  async start(key, options) {
424
- const { cwd, command, onExit, cols = 80, rows = 24, fresh = false } = options;
426
+ const { cwd, command, onExit, fresh = false } = options;
427
+ const previous = this.clients.get(key)?.proc;
428
+ const cols = options.cols ?? previous?.cols ?? 80;
429
+ const rows = options.rows ?? previous?.rows ?? 24;
425
430
  this.ensureFiles();
426
431
  const name = this.sessionName(key);
427
432
  const alive = await this.isAlive(key);
@@ -525,6 +530,12 @@ var init_tmux_backend = __esm({
525
530
  isAttached(key) {
526
531
  return this.clients.has(key);
527
532
  }
533
+ async hasForeignClients(key) {
534
+ const { code: code2, stdout } = await this.tmux("list-clients", "-t", `=${this.sessionName(key)}`, "-F", "#{client_pid}");
535
+ if (code2 !== 0) return false;
536
+ const own = this.clients.get(key)?.proc.pid;
537
+ return stdout.split("\n").some((line) => line.trim() && Number(line) !== own);
538
+ }
528
539
  resize(key, cols, rows) {
529
540
  try {
530
541
  this.clients.get(key)?.proc.resize(Math.max(cols, 1), Math.max(rows, 1));
@@ -597,6 +608,10 @@ function claudeResumeOrFresh(sessionId, worktreePath, tail) {
597
608
  const sessionFile = `"$HOME/.claude/projects/${munged}/${sessionId}.jsonl"`;
598
609
  return `if [ -f ${sessionFile} ]; then claude --resume ${sessionId} ${tail}; else claude --session-id ${sessionId} ${tail}; fi\r`;
599
610
  }
611
+ function inboxHookCommand(inboxDir2, event) {
612
+ const dir = toShellPath(inboxDir2);
613
+ return `if ls "${dir}" 2>/dev/null | grep -q .; then node -e '${INBOX_READER}' "${dir}" ${event}; fi; exit 0`;
614
+ }
600
615
  function buildClaudeSettings(worktreePath) {
601
616
  const settings = {
602
617
  theme: "dark",
@@ -613,12 +628,19 @@ function buildClaudeSettings(worktreePath) {
613
628
  const progress = {
614
629
  hooks: [{ type: "command", command: `mkdir -p "${eventsDir}" && cat > "${eventsDir}/$(date +%s)-$$-$RANDOM.json"; exit 0` }]
615
630
  };
631
+ const inboxDir2 = `${toShellPath(worktreePath)}/${INBOX_DIR}`;
632
+ const inbox = (event) => ({
633
+ hooks: [{ type: "command", command: inboxHookCommand(inboxDir2, event) }]
634
+ });
616
635
  settings.hooks = {
617
636
  PreToolUse: [taskHook],
618
- PostToolUse: [taskHook, { matcher: TODO_TOOLS, ...progress }],
619
- Stop: [progress],
637
+ PostToolUse: [taskHook, { matcher: TODO_TOOLS, ...progress }, inbox("PostToolUse")],
638
+ Stop: [progress, inbox("Stop")],
620
639
  Notification: [progress],
621
- UserPromptSubmit: [progress]
640
+ UserPromptSubmit: [progress, inbox("UserPromptSubmit")],
641
+ SessionStart: [{
642
+ hooks: [{ type: "command", command: `mkdir -p "${inboxDir2}" && : > "${inboxDir2}/${INBOX_READY_FILE}"; exit 0` }]
643
+ }]
622
644
  };
623
645
  }
624
646
  return JSON.stringify(settings);
@@ -676,7 +698,7 @@ function masterSystemPrompt(opts) {
676
698
  ' \u9019\u4E9B\u8A0A\u606F\u4EE5 <vibeflow from="\u2026"> \u5305\u4F4F\u3001\u76F4\u63A5\u51FA\u73FE\u5728\u4F60\u7684\u8F38\u5165\u88E1\u3002\u4E0D\u8981\u8F2A\u8A62 task list\uFF1B\u8981\u770B\u7D30\u7BC0\u6642\u624D\u7528 VF task show --store-path "$VIBEFLOW_STORE_DIR" --task <id>\u3002',
677
699
  '5. \u8ABF\u5EA6\uFF1A\u7528 VF task send --store-path "$VIBEFLOW_STORE_DIR" --task <id> --text <\u5167\u5BB9> \u5C0D\u81EA\u5DF1\u7684\u5361\u4E0B\u6307\u793A\uFF1B\u5361\u8207\u5361\u4E4B\u9593\u4E0D\u80FD\u76F4\u63A5\u50B3\u8A71\uFF0C\u4E00\u5F8B\u7D93\u904E\u4F60\u3002',
678
700
  " \u9700\u8981\u7368\u7ACB\u9A57\u6536\u6642\u53E6\u958B\u4E00\u5F35\u9A57\u6536\u5361\u3002\u9A57\u6536\u56DE\u5831\u554F\u984C\u6642\uFF0C\u628A\u5177\u9AD4\u554F\u984C\u8207\u91CD\u73FE\u6B65\u9A5F\u6574\u7406\u597D\u8F49\u7D66\u8CA0\u8CAC\u958B\u767C\u7684\u5361\u4FEE\u6B63\uFF0C\u4FEE\u5B8C\u518D\u8ACB\u9A57\u6536\u5361\u8907\u9A57\uFF0C\u76F4\u5230\u901A\u904E\u3002",
679
- " task send \u56DE TARGET_BLOCKED \u4EE3\u8868\u5C0D\u65B9\u5361\u5728\u6B0A\u9650\u78BA\u8A8D\uFF0C\u8ACB\u4F7F\u7528\u8005\u5230\u90A3\u5F35\u5361\u8655\u7406\u3002",
701
+ ' task send \u56DE via: "queued" \u4EE3\u8868\u8A0A\u606F\u5DF2\u6392\u9032\u5C0D\u65B9\u7684\u6536\u4EF6\u5323\uFF0C\u5C0D\u65B9\u4E0B\u4E00\u6B21\u52D5\u4F5C\u6216\u4F7F\u7528\u8005\u9001\u51FA\u8A0A\u606F\u6642\u5C31\u6703\u770B\u5230\uFF0C\u4E0D\u5FC5\u91CD\u9001\uFF1B\u56DE TARGET_BLOCKED \u4EE3\u8868\u5C0D\u65B9\u5361\u5728\u6B0A\u9650\u78BA\u8A8D\uFF0C\u8ACB\u4F7F\u7528\u8005\u5230\u90A3\u5F35\u5361\u8655\u7406\u3002',
680
702
  "6. PR\uFF1A\u9A57\u6536\u901A\u904E\u5F8C\uFF0C\u4EA4\u4EE3\u958B\u767C\u5361\u7528 pr skill \u958B PR\uFF08\u74B0\u5883\u88E1\u6C92\u6709\u9019\u500B skill \u5C31\u7528 gh pr create\uFF09\uFF0C\u4E26\u56DE\u5831 PR \u9023\u7D50\u7D66\u4F60\u3002",
681
703
  "7. \u4F7F\u7528\u8005\u4E3B\u8981\u53EA\u8DDF\u4F60\u6E9D\u901A\uFF1A\u4E3B\u52D5\u5411\u4F7F\u7528\u8005\u56DE\u5831\u6574\u9AD4\u9032\u5EA6\u8207\u9700\u8981\u4F7F\u7528\u8005\u6C7A\u5B9A\u7684\u4E8B\u3002\u4F60\u4E0D\u6703\u628A\u5361\u7247\u79FB\u5230 Done\u3001\u4E0D\u6703\u5408\u4F75 PR\uFF1B\u5168\u90E8\u5B8C\u6210\u5F8C\u6574\u7406\u6BCF\u5F35\u5361\u7684\u7D50\u679C\u8207 PR \u9023\u7D50\uFF0C\u4EA4\u7D66\u4F7F\u7528\u8005\u505A\u6700\u5F8C\u78BA\u8A8D\u3002",
682
704
  " \u8DDF\u4F7F\u7528\u8005\u63D0\u5230\u4EFB\u4F55\u4E00\u5F35\u5361\u6642\uFF0C\u4E00\u5F8B\u5BEB\u6210 <id>\u300C<\u6A19\u984C>\u300D\u2014\u2014\u5361\u7247\u4E0A\u770B\u5F97\u5230 id\uFF0C\u4F7F\u7528\u8005\u9760\u5B83\u5C0D\u4E0A\u662F\u54EA\u4E00\u5F35\u3002"
@@ -755,7 +777,7 @@ function buildAgentCommand(task, systemPrompt, opts, workspacePath) {
755
777
  const role = task.role === "master" ? masterSystemPrompt({ canWrite, autoMode: opts?.autoMode === true }) : task.masterId ? slaveSystemPrompt({ canWrite }) : null;
756
778
  const sys = task.masterId && task.role !== "master" ? role ?? "" : role ? [custom, role].filter(Boolean).join("\n\n") : custom;
757
779
  const includeTaskPrompt = opts?.includeTaskPrompt !== false;
758
- const prompt = includeTaskPrompt && !opts?.resume ? buildPrompt(task, opts?.preface) : "";
780
+ const prompt = includeTaskPrompt && !opts?.resume ? opts?.continuation ?? buildPrompt(task, opts?.preface) : "";
759
781
  const sessionId = agent === "claude" && includeTaskPrompt ? executorSessionId(task.id, task.runId) : void 0;
760
782
  return boardEnvPrefix(task, opts, workspacePath) + assembleCommand(
761
783
  agent,
@@ -769,7 +791,7 @@ function buildAgentCommand(task, systemPrompt, opts, workspacePath) {
769
791
  workspacePath
770
792
  );
771
793
  }
772
- var ARTIFACTS_DIR_SUFFIX, SCRATCH_DIR_NAME, ARTIFACTS_FALLBACK_DIR, AUTO_PERMISSION_MODE, SUBAGENTS_DIR2, PROGRESS_EVENTS_DIR, TODO_TOOLS, BOARD_CLI_SETUP, AGENT_NAMES, RETIRED_MODELS;
794
+ var ARTIFACTS_DIR_SUFFIX, SCRATCH_DIR_NAME, ARTIFACTS_FALLBACK_DIR, AUTO_PERMISSION_MODE, SUBAGENTS_DIR2, PROGRESS_EVENTS_DIR, INBOX_DIR, INBOX_READY_FILE, INBOX_READER, TODO_TOOLS, BOARD_CLI_SETUP, AGENT_NAMES, RETIRED_MODELS;
773
795
  var init_launch = __esm({
774
796
  "packages/core/src/launch.ts"() {
775
797
  "use strict";
@@ -779,6 +801,19 @@ var init_launch = __esm({
779
801
  AUTO_PERMISSION_MODE = "auto";
780
802
  SUBAGENTS_DIR2 = ".vibeflow-subagents";
781
803
  PROGRESS_EVENTS_DIR = ".vibeflow-events";
804
+ INBOX_DIR = ".vibeflow-inbox";
805
+ INBOX_READY_FILE = ".ready";
806
+ INBOX_READER = [
807
+ 'const fs=require("fs"),path=require("path");',
808
+ "const [dir,event]=process.argv.slice(1);const out=[];",
809
+ 'for(const name of fs.readdirSync(dir).filter((n)=>!n.startsWith(".")).sort()){',
810
+ 'const claimed=path.join(dir,".hook-"+name);',
811
+ "try{fs.renameSync(path.join(dir,name),claimed)}catch{continue}",
812
+ 'out.push(fs.readFileSync(claimed,"utf8"));fs.rmSync(claimed,{force:true})}',
813
+ 'if(out.length){const text=out.join("\\n\\n");',
814
+ 'process.stdout.write(JSON.stringify(event==="Stop"?{decision:"block",reason:text}',
815
+ ":{hookSpecificOutput:{hookEventName:event,additionalContext:text}}))}"
816
+ ].join("");
782
817
  TODO_TOOLS = "TodoWrite|TaskCreate|TaskUpdate";
783
818
  BOARD_CLI_SETUP = [
784
819
  '\u5148\u5B9A\u7FA9\u9019\u500B shell \u51FD\u5F0F\uFF0C\u4E4B\u5F8C\u6240\u6709\u6307\u4EE4\u90FD\u7528\u5B83\uFF0C\u4E26\u4E14\u4E00\u5F8B\u5E36\u4E0A --store-path "$VIBEFLOW_STORE_DIR"\uFF1A',
@@ -1080,6 +1115,17 @@ function reduceClaudeLine(state, line) {
1080
1115
  function claudeUsageTotal(state) {
1081
1116
  return { ...Object.values(state.usageById).reduce(addUsage, emptyUsage()), turns: state.turns };
1082
1117
  }
1118
+ function claudeLastReply(lines) {
1119
+ for (let i = lines.length - 1; i >= 0; i -= 1) {
1120
+ const entry = parseLine(lines[i]);
1121
+ if (!entry || entry.type !== "assistant" || entry.isSidechain) continue;
1122
+ const message2 = entry.message;
1123
+ const content = Array.isArray(message2?.content) ? message2.content : [];
1124
+ const text = content.filter((b) => b?.type === "text" && typeof b.text === "string").map((b) => b.text.trim()).filter(Boolean).join("\n\n");
1125
+ if (text) return text;
1126
+ }
1127
+ return void 0;
1128
+ }
1083
1129
  function initialCodexState() {
1084
1130
  return { todos: null, usage: emptyUsage(), activity: { state: "unknown" } };
1085
1131
  }
@@ -1227,11 +1273,11 @@ var init_progress = __esm({
1227
1273
 
1228
1274
  // packages/tui/src/task-form.ts
1229
1275
  import { spawnSync as spawnSync2 } from "child_process";
1230
- import fs27 from "fs";
1276
+ import fs29 from "fs";
1231
1277
  import os10 from "os";
1232
- import path29 from "path";
1278
+ import path30 from "path";
1233
1279
  import React, { useEffect, useRef, useState } from "react";
1234
- import { Box, Text, render as render2, useApp, useInput } from "ink";
1280
+ import { Box, Text, render as render3, useApp, useInput } from "ink";
1235
1281
  function newFormState(defaultAutoMode, agents) {
1236
1282
  const agentCli = agents && agents.length > 0 && !agents.some((a) => a.id === "claude") ? agents[0].id : "claude";
1237
1283
  return {
@@ -1366,17 +1412,17 @@ function editorCommand(env, platform) {
1366
1412
  return env.VISUAL?.trim() || env.EDITOR?.trim() || (platform === "win32" ? "notepad" : "vi");
1367
1413
  }
1368
1414
  function editInEditor(text) {
1369
- const dir = fs27.mkdtempSync(path29.join(os10.tmpdir(), "vibeflow-"));
1370
- const file = path29.join(dir, "description.md");
1415
+ const dir = fs29.mkdtempSync(path30.join(os10.tmpdir(), "vibeflow-"));
1416
+ const file = path30.join(dir, "description.md");
1371
1417
  try {
1372
- fs27.writeFileSync(file, text);
1418
+ fs29.writeFileSync(file, text);
1373
1419
  const cmd = editorCommand(process.env, process.platform);
1374
1420
  const r = spawnSync2(`${cmd} "${file}"`, { stdio: "inherit", shell: true });
1375
1421
  if (r.error) return { error: `\u7121\u6CD5\u555F\u52D5\u7DE8\u8F2F\u5668\uFF08${cmd}\uFF09\uFF1A${r.error.message}` };
1376
1422
  if (r.status !== 0) return { error: `\u7DE8\u8F2F\u5668\uFF08${cmd}\uFF09\u7D50\u675F\u78BC ${r.status}\uFF0C\u63CF\u8FF0\u672A\u8B8A\u66F4` };
1377
- return { text: fs27.readFileSync(file, "utf8").replace(/\r?\n$/, "") };
1423
+ return { text: fs29.readFileSync(file, "utf8").replace(/\r?\n$/, "") };
1378
1424
  } finally {
1379
- fs27.rmSync(dir, { recursive: true, force: true });
1425
+ fs29.rmSync(dir, { recursive: true, force: true });
1380
1426
  }
1381
1427
  }
1382
1428
  function cycle(list, current, step) {
@@ -1447,10 +1493,10 @@ function FormView({ api, ctx, initial, initialFocus, initialMessage, pristine, o
1447
1493
  if (editing === "title") setS((prev) => ({ ...prev, title: draft }));
1448
1494
  else if (editing === "branch") setS((prev) => ({ ...prev, branch: value2 }));
1449
1495
  else if (editing === "project") {
1450
- if (value2) setProject(path29.resolve(value2.replace(/^~(?=$|\/)/, os10.homedir())));
1496
+ if (value2) setProject(path30.resolve(value2.replace(/^~(?=$|\/)/, os10.homedir())));
1451
1497
  } else if (editing === "attachments" && value2) {
1452
- const file = path29.resolve(value2.replace(/^~(?=$|\/)/, os10.homedir()));
1453
- if (!fs27.existsSync(file) || !fs27.statSync(file).isFile()) {
1498
+ const file = path30.resolve(value2.replace(/^~(?=$|\/)/, os10.homedir()));
1499
+ if (!fs29.existsSync(file) || !fs29.statSync(file).isFile()) {
1454
1500
  setMessage(`\u627E\u4E0D\u5230\u6A94\u6848\uFF1A${file}`);
1455
1501
  return;
1456
1502
  }
@@ -1537,7 +1583,7 @@ function FormView({ api, ctx, initial, initialFocus, initialMessage, pristine, o
1537
1583
  case "branch":
1538
1584
  return s.branch || "\uFF08\u7559\u7A7A\u5247\u81EA\u52D5\u547D\u540D\uFF0C\u4F8B\u5982 feature/login-fix\uFF09";
1539
1585
  case "attachments":
1540
- return s.attachments.length ? s.attachments.map((a) => path29.basename(a)).join("\u3001") : "\uFF08Enter \u8F38\u5165\u6A94\u6848\u8DEF\u5F91\u52A0\u5165\uFF09";
1586
+ return s.attachments.length ? s.attachments.map((a) => path30.basename(a)).join("\u3001") : "\uFF08Enter \u8F38\u5165\u6A94\u6848\u8DEF\u5F91\u52A0\u5165\uFF09";
1541
1587
  case "description": {
1542
1588
  if (!s.description) return "\uFF08Enter \u7528\u7DE8\u8F2F\u5668\u64B0\u5BEB\uFF09";
1543
1589
  const lines = s.description.split("\n");
@@ -1572,7 +1618,7 @@ function FormView({ api, ctx, initial, initialFocus, initialMessage, pristine, o
1572
1618
  if (info && !info.isRepo) return "\u9019\u500B\u8CC7\u6599\u593E\u4E0D\u662F Git repository\u3002\u8ACB\u6539\u9078\u4E00\u500B Git \u5C08\u6848\uFF0C\u6216\u5728\u4E0B\u65B9\u521D\u59CB\u5316\u3002";
1573
1619
  if (s.mode === "edit" && projectChanged(s)) return "\u5206\u652F\u6703\u5728\u65B0\u5C08\u6848\u3001\u5361\u7247\u958B\u59CB\u57F7\u884C\u6642\u624D\u5EFA\u7ACB\u3002";
1574
1620
  if (info?.isRepo && !info.hasRemote) return `\u6B64 repository \u6C92\u6709 remote\uFF0C\u5C07\u4EE5\u76EE\u524D\u5206\u652F (${info.currentBranch ?? "HEAD"}) \u70BA\u57FA\u6E96\u5EFA\u7ACB\u672C\u5730 worktree\u3002`;
1575
- if (info?.isRepo && s.projectPath) return `worktree \u6703\u5EFA\u5728 ${ctx.workstationPath || "~/Desktop"}/${path29.basename(s.projectPath)}`;
1621
+ if (info?.isRepo && s.projectPath) return `worktree \u6703\u5EFA\u5728 ${ctx.workstationPath || "~/Desktop"}/${path30.basename(s.projectPath)}`;
1576
1622
  }
1577
1623
  if (field === "branch") {
1578
1624
  const when = info?.hasRemote ? "\u958B\u59CB\u57F7\u884C\u6642\u6703\u5EFA\u7ACB\u540C\u540D\u5206\u652F\u4E26\u63A8\u5230 origin\uFF1B\u82E5 remote \u5DF2\u6709\u9019\u500B\u5206\u652F\uFF0C\u5247\u76F4\u63A5\u53D6\u56DE\u4E26\u63A5\u7E8C\u4E0A\u9762\u7684\u5DE5\u4F5C\u3002" : "\u958B\u59CB\u57F7\u884C\u6642\u6703\u5EFA\u7ACB\u540C\u540D\u5206\u652F\u3002";
@@ -1619,7 +1665,7 @@ function FormView({ api, ctx, initial, initialFocus, initialMessage, pristine, o
1619
1665
  function showForm(api, ctx, initial, pristine, initialFocus = 0, initialMessage) {
1620
1666
  return new Promise((resolve) => {
1621
1667
  let result = { type: "cancel" };
1622
- const instance = render2(
1668
+ const instance = render3(
1623
1669
  h(FormView, { api, ctx, initial, initialFocus, initialMessage, pristine, onResult: (r) => result = r }),
1624
1670
  { exitOnCtrlC: false }
1625
1671
  );
@@ -1702,9 +1748,9 @@ __export(src_exports, {
1702
1748
  showDiff: () => showDiff
1703
1749
  });
1704
1750
  import { spawnSync as spawnSync3 } from "child_process";
1705
- import path30 from "path";
1751
+ import path31 from "path";
1706
1752
  import React2, { useEffect as useEffect2, useState as useState2 } from "react";
1707
- import { Box as Box2, Text as Text2, render as render3, useApp as useApp2, useInput as useInput2, useStdout } from "ink";
1753
+ import { Box as Box2, Text as Text2, render as render4, useApp as useApp2, useInput as useInput2, useStdout } from "ink";
1708
1754
  function findDetachKey(text) {
1709
1755
  const plain = text.indexOf(DETACH_KEY);
1710
1756
  const m = /\x1b\[\d+;\d+;29;1;\d+;\d+_/.exec(text);
@@ -1975,7 +2021,7 @@ function BoardView({ opts, initial, initialMessage, onAction }) {
1975
2021
  function showBoard(opts, initial, initialMessage) {
1976
2022
  return new Promise((resolve) => {
1977
2023
  let result = { action: { type: "quit" }, sel: initial };
1978
- const instance = render3(
2024
+ const instance = render4(
1979
2025
  h2(BoardView, {
1980
2026
  opts,
1981
2027
  initial,
@@ -2001,7 +2047,7 @@ function showDiff(task) {
2001
2047
  });
2002
2048
  }
2003
2049
  function tmuxAttach(opts, sessionName) {
2004
- const conf = path30.join(opts.userDataDir, "tmux.conf");
2050
+ const conf = path31.join(opts.userDataDir, "tmux.conf");
2005
2051
  const inOurServer = (process.env.TMUX ?? "").split(",")[0].endsWith(`/${TMUX_SOCKET}`);
2006
2052
  const args = inOurServer ? ["-L", TMUX_SOCKET, "-f", conf, "switch-client", "-t", `=${sessionName}`] : ["-L", TMUX_SOCKET, "-f", conf, "attach-session", "-t", `=${sessionName}`];
2007
2053
  spawnSync3("tmux", args, { stdio: "inherit", env: { ...process.env, TMUX: inOurServer ? process.env.TMUX : "" } });
@@ -2132,8 +2178,8 @@ var init_src = __esm({
2132
2178
  });
2133
2179
 
2134
2180
  // packages/cli/src/main.ts
2135
- import fs28 from "fs";
2136
- import path31 from "path";
2181
+ import fs30 from "fs";
2182
+ import path32 from "path";
2137
2183
  import { fileURLToPath as fileURLToPath2 } from "url";
2138
2184
  import { parseArgs as parseArgs2 } from "node:util";
2139
2185
  import { spawn as spawn9 } from "node:child_process";
@@ -2664,6 +2710,13 @@ function createBridge(t) {
2664
2710
  updateTask: (payload) => t.invoke("vibeflow:updateTask", payload),
2665
2711
  /** Move a Backlog card to In Progress and start its agent on the host. */
2666
2712
  startTask: (taskId) => t.invoke("vibeflow:startTask", taskId),
2713
+ /**
2714
+ * Carry a running card on in a new agent session. It starts from a brief core
2715
+ * builds from the card's own facts, not from the old conversation; `force`
2716
+ * interrupts an agent that is still working. Refusals carry a code
2717
+ * (`NOT_IN_PROGRESS`, `NOT_LAUNCHED`, `NO_WORKTREE`, `AGENT_BUSY`, `ALREADY_CONTINUING`).
2718
+ */
2719
+ continueTask: (payload) => t.invoke("vibeflow:continueTask", payload),
2667
2720
  /** Cards as a master sees them; filter by master or a single card. */
2668
2721
  taskSummaries: (filter) => t.invoke("task:summaries", filter),
2669
2722
  /** Type a message into another card's agent: a master to its cards, a card to its master. */
@@ -2755,9 +2808,9 @@ function createBridge(t) {
2755
2808
  },
2756
2809
  // Interactive terminal bridge (Phase 3).
2757
2810
  term: {
2758
- readFile: (sessionKey, path32) => t.invoke("terminal:readFile", { sessionKey, path: path32 }),
2811
+ readFile: (sessionKey, path33) => t.invoke("terminal:readFile", { sessionKey, path: path33 }),
2759
2812
  existingFiles: (sessionKey, paths) => t.invoke("terminal:existingFiles", { sessionKey, paths }),
2760
- openFile: (sessionKey, path32) => t.invoke("terminal:openFile", { sessionKey, path: path32 }),
2813
+ openFile: (sessionKey, path33) => t.invoke("terminal:openFile", { sessionKey, path: path33 }),
2761
2814
  /**
2762
2815
  * Start a terminal for a task: its agent when `launch` is given, else an
2763
2816
  * interactive shell. Core resolves the cwd and builds the command.
@@ -2868,11 +2921,6 @@ function spawnHelperFixCommand(failures) {
2868
2921
  // packages/cli/src/task-command.ts
2869
2922
  import { parseArgs } from "node:util";
2870
2923
 
2871
- // packages/core/src/tasks.ts
2872
- import path13 from "path";
2873
- import { randomUUID as randomUUID2 } from "crypto";
2874
- import fs10 from "fs/promises";
2875
-
2876
2924
  // packages/core/src/branch-name.ts
2877
2925
  import os2 from "os";
2878
2926
 
@@ -2953,7 +3001,8 @@ ${description ?? ""}`;
2953
3001
  if (slug) return `${branchPrefix(title, description)}/${slug}`;
2954
3002
  return null;
2955
3003
  }
2956
- async function translateTitleToSlug(title) {
3004
+ var NON_ASCII_LETTER_RE = new RegExp("(?![\\x00-\\x7F])\\p{L}", "u");
3005
+ var claudeTitleTranslator = async (title) => {
2957
3006
  const prompt = `Translate this software task title into a short English git branch slug: 2-6 lowercase words joined by hyphens, no prefix, no quotes, no explanation. Output ONLY the slug.
2958
3007
  Title: ${title}`;
2959
3008
  try {
@@ -2969,15 +3018,25 @@ Title: ${title}`;
2969
3018
  } catch {
2970
3019
  return null;
2971
3020
  }
2972
- }
2973
- async function generateBranchName(title, description) {
3021
+ };
3022
+ async function generateBranchName(title, description, translate) {
2974
3023
  const local = buildCandidateBranch(title, description);
2975
3024
  if (local) return local;
2976
- const translated = await translateTitleToSlug(title);
2977
- if (translated) return `${branchPrefix(title, description)}/${translated}`;
3025
+ if (!translate || !NON_ASCII_LETTER_RE.test(title)) return null;
3026
+ try {
3027
+ const translated = await translate(title);
3028
+ const slug = translated ? slugify(translated) : null;
3029
+ if (slug) return `${branchPrefix(title, description)}/${slug}`;
3030
+ } catch {
3031
+ }
2978
3032
  return null;
2979
3033
  }
2980
3034
 
3035
+ // packages/core/src/tasks.ts
3036
+ import path13 from "path";
3037
+ import { randomUUID as randomUUID2 } from "crypto";
3038
+ import fs10 from "fs/promises";
3039
+
2981
3040
  // packages/core/src/git.ts
2982
3041
  import { execFile as execFile5 } from "child_process";
2983
3042
  import { promisify as promisify2 } from "util";
@@ -3050,11 +3109,11 @@ function timestampFromName(name) {
3050
3109
  }
3051
3110
  function reduceRuns(events) {
3052
3111
  const runs = [];
3053
- let seq = 0;
3112
+ let seq2 = 0;
3054
3113
  for (const ev of events) {
3055
3114
  if (ev.kind === "pre") {
3056
3115
  runs.push({
3057
- id: `sa-${seq++}`,
3116
+ id: `sa-${seq2++}`,
3058
3117
  prompt: ev.prompt,
3059
3118
  description: ev.description,
3060
3119
  subagentType: ev.subagentType,
@@ -3071,7 +3130,7 @@ function reduceRuns(events) {
3071
3130
  }
3072
3131
  if (!target) {
3073
3132
  target = {
3074
- id: `sa-${seq++}`,
3133
+ id: `sa-${seq2++}`,
3075
3134
  prompt: ev.prompt,
3076
3135
  description: ev.description,
3077
3136
  subagentType: ev.subagentType,
@@ -3870,7 +3929,7 @@ async function resolveBranchName(projectPath, workspacePath, taskId, preferredBr
3870
3929
  }
3871
3930
  return preferredBranch;
3872
3931
  }
3873
- var RUNTIME_ARTIFACT_DENYLIST = /* @__PURE__ */ new Set([SUBAGENTS_DIR, PROGRESS_EVENTS_DIR]);
3932
+ var RUNTIME_ARTIFACT_DENYLIST = /* @__PURE__ */ new Set([SUBAGENTS_DIR, PROGRESS_EVENTS_DIR, INBOX_DIR]);
3874
3933
  var MAX_IGNORED_COPY_BYTES = 10 * 1024 * 1024;
3875
3934
  var MAX_IGNORED_COPY_FILES = 200;
3876
3935
  var HEAVY_IGNORED_DIR_NAMES = /* @__PURE__ */ new Set([
@@ -4212,7 +4271,7 @@ async function buildDiffEntries(cwd, query) {
4212
4271
  }
4213
4272
  }
4214
4273
  const entries = Array.from(entryMap.values()).filter(
4215
- (e) => ![SUBAGENTS_DIR, PROGRESS_EVENTS_DIR].some(
4274
+ (e) => ![SUBAGENTS_DIR, PROGRESS_EVENTS_DIR, INBOX_DIR].some(
4216
4275
  (dir) => e.path === dir || e.path.startsWith(`${dir}/`)
4217
4276
  )
4218
4277
  );
@@ -4396,12 +4455,13 @@ async function captureTaskOutcome(worktreePath, baseBranch) {
4396
4455
  capturedAt: Date.now()
4397
4456
  };
4398
4457
  }
4399
- async function getPrStatus(worktreePath) {
4458
+ async function getPrStatus(worktreePath, timeoutMs) {
4400
4459
  try {
4401
4460
  const { stdout } = await pexec2(
4402
4461
  "gh",
4403
4462
  ["pr", "view", "--json", "url,number,state"],
4404
- { cwd: worktreePath, env: execEnv() }
4463
+ // A lookup that outlives its caller must not keep the worktree open as a process's cwd.
4464
+ { cwd: worktreePath, env: execEnv(), ...timeoutMs ? { timeout: timeoutMs } : {} }
4405
4465
  );
4406
4466
  const parsed = JSON.parse(stdout.toString().trim());
4407
4467
  if (parsed.url) return parsed;
@@ -4460,11 +4520,11 @@ ${commits || "(none)"}`,
4460
4520
  "",
4461
4521
  "Output ONLY the commit message text, nothing else. Start directly with [What]."
4462
4522
  ].join("\n");
4463
- const cliFlags = {
4464
- claude: ["-p"],
4465
- codex: ["-p"]
4523
+ const cliArgs = {
4524
+ claude: ["-p", "--model", "haiku"],
4525
+ codex: ["exec", "--model", "gpt-5.6-luna", "--sandbox", "read-only", "-"]
4466
4526
  };
4467
- const flags = cliFlags[agentCli] ?? ["-p"];
4527
+ const flags = cliArgs[agentCli] ?? ["-p"];
4468
4528
  const bin = agentCli;
4469
4529
  const stdout = await runAgentPrint(bin, flags, prompt, { cwd: worktreePath });
4470
4530
  const result = stdout.trim();
@@ -4550,7 +4610,7 @@ async function assertDirectory(dir) {
4550
4610
  throw taskError(`\u627E\u4E0D\u5230\u8CC7\u6599\u593E\uFF1A${dir}`, "WORK_DIR_NOT_FOUND");
4551
4611
  }
4552
4612
  }
4553
- async function createTaskFromInput(input) {
4613
+ async function createTaskFromInput(input, options = {}) {
4554
4614
  if (input.role === "master") return createMasterTask(input);
4555
4615
  const projectPath = input.projectPath;
4556
4616
  if (!projectPath) throw taskError("\u5C1A\u672A\u9078\u64C7\u5C08\u6848\u8CC7\u6599\u593E", "PROJECT_NOT_FOUND");
@@ -4579,7 +4639,7 @@ async function createTaskFromInput(input) {
4579
4639
  if (explicitBranch) {
4580
4640
  await assertBranchAvailable(projectPath, workspacePath, explicitBranch);
4581
4641
  }
4582
- const branch = explicitBranch ?? await generateBranchName(input.title, input.description);
4642
+ const branch = explicitBranch ?? await generateBranchName(input.title, input.description, options.translateTitle);
4583
4643
  const draft = {
4584
4644
  id: taskId,
4585
4645
  title: input.title.trim() || `Task ${taskId}`,
@@ -4926,6 +4986,12 @@ task update options:
4926
4986
  task start / list / show / send (need the running VibeFlow host):
4927
4987
  start --task <id> Move a Backlog card to In Progress and start its agent,
4928
4988
  the same as dragging it in the app
4989
+ start --task <id> --new-session [--force]
4990
+ An In Progress card that has run carries on in a NEW agent
4991
+ session: it starts from a short brief (card text, branch and
4992
+ PR state, todos, the last reply), not the old conversation,
4993
+ and its usage so far is kept. Nothing the card produced is
4994
+ touched. --force interrupts an agent that is still working
4929
4995
  list [--master <id>] Every card, or one master's cards, with column, whether
4930
4996
  its agent is running, todo progress, activity and PR
4931
4997
  show --task <id> The same summary for one card
@@ -5015,6 +5081,7 @@ async function taskCommand(argv) {
5015
5081
  text: { type: "string" },
5016
5082
  from: { type: "string" },
5017
5083
  force: { type: "boolean" },
5084
+ "new-session": { type: "boolean" },
5018
5085
  "store-path": { type: "string" },
5019
5086
  profile: { type: "string" },
5020
5087
  help: { type: "boolean", short: "h" }
@@ -5044,6 +5111,8 @@ async function taskCommand(argv) {
5044
5111
  if (!task2) fail("TASK_NOT_FOUND", `Task not found: ${taskId}`);
5045
5112
  return { taskId, path: addTaskArtifact(task2, values.file) };
5046
5113
  }
5114
+ if (values["new-session"] && sub !== "start") fail("INVALID_ARGUMENT", "--new-session only goes with task start");
5115
+ if (sub === "start" && values.force && !values["new-session"]) fail("INVALID_ARGUMENT", "--force goes with task start --new-session");
5047
5116
  if (HOST_COMMANDS.includes(sub)) return hostCommand(sub, values, storePath);
5048
5117
  if (sub === "update") {
5049
5118
  if (!values.task) fail("MISSING_ARGUMENT", "Missing required arguments: --task");
@@ -5112,7 +5181,7 @@ async function taskCommand(argv) {
5112
5181
  autoMode: values["auto-mode"] ? values["auto-mode"] === "on" : void 0,
5113
5182
  attachments,
5114
5183
  storePath
5115
- });
5184
+ }, { translateTitle: claudeTitleTranslator });
5116
5185
  return {
5117
5186
  storePath: resolvedPath,
5118
5187
  task: {
@@ -5142,6 +5211,15 @@ async function hostCommand(sub, values, storePath) {
5142
5211
  if (!lock) fail("HOST_NOT_RUNNING", `No VibeFlow host is running for ${storePath}. Start it with \`vibeflow\` first.`);
5143
5212
  const remote = connectToHost(lock);
5144
5213
  try {
5214
+ if (sub === "start" && values["new-session"]) {
5215
+ try {
5216
+ const { task } = await remote.api.continueTask({ taskId: values.task, force: values.force === true });
5217
+ return { task: { id: task.id, title: task.title, worktreePath: task.worktreePath ?? null }, newSession: true };
5218
+ } catch (err) {
5219
+ const e = err;
5220
+ fail(e.code ?? "HOST_ERROR", e.message ?? String(err));
5221
+ }
5222
+ }
5145
5223
  if (sub === "start") {
5146
5224
  const { task } = await remote.api.startTask(values.task);
5147
5225
  return { task: { id: task.id, title: task.title, worktreePath: task.worktreePath ?? null } };
@@ -5168,8 +5246,8 @@ async function hostCommand(sub, values, storePath) {
5168
5246
  }
5169
5247
 
5170
5248
  // packages/cli/src/host.ts
5171
- import fs25 from "fs";
5172
- import path27 from "path";
5249
+ import fs27 from "fs";
5250
+ import path28 from "path";
5173
5251
  import { randomBytes as randomBytes2 } from "crypto";
5174
5252
 
5175
5253
  // packages/core/src/events.ts
@@ -5707,7 +5785,7 @@ async function syncBuiltinsAtStartup() {
5707
5785
  }
5708
5786
 
5709
5787
  // packages/core/src/service.ts
5710
- import fs21 from "fs";
5788
+ import fs23 from "fs";
5711
5789
 
5712
5790
  // packages/core/src/terminal-files.ts
5713
5791
  import { constants } from "fs";
@@ -5800,7 +5878,7 @@ async function readTerminalFile(cwd, input, metadataOnly = false) {
5800
5878
 
5801
5879
  // packages/core/src/service.ts
5802
5880
  import os9 from "os";
5803
- import path23 from "path";
5881
+ import path24 from "path";
5804
5882
  import { randomUUID as randomUUID5 } from "crypto";
5805
5883
 
5806
5884
  // packages/core/src/agent-models.ts
@@ -6606,7 +6684,7 @@ ${children(item).map((child) => render(child)).join("").trimEnd()}
6606
6684
  if (type === "listItem") return body();
6607
6685
  if (type === "table") {
6608
6686
  const rows = children(item).map((row) => {
6609
- const cells = children(record(row) ?? {}).map((cell) => render(cell).trim().replace(/\|/g, "\\|").replace(/\n+/g, " "));
6687
+ const cells = children(record(row) ?? {}).map((cell2) => render(cell2).trim().replace(/\|/g, "\\|").replace(/\n+/g, " "));
6610
6688
  return `| ${cells.join(" | ")} |`;
6611
6689
  });
6612
6690
  if (rows.length === 0) return "";
@@ -6908,7 +6986,7 @@ var SHA_RE = /^[0-9a-f]{4,40}$/i;
6908
6986
  function isCommitSha(value) {
6909
6987
  return typeof value === "string" && SHA_RE.test(value);
6910
6988
  }
6911
- var isMetadataPath = (p) => [SUBAGENTS_DIR, PROGRESS_EVENTS_DIR].some((dir) => p === dir || p.startsWith(`${dir}/`));
6989
+ var isMetadataPath = (p) => [SUBAGENTS_DIR, PROGRESS_EVENTS_DIR, INBOX_DIR].some((dir) => p === dir || p.startsWith(`${dir}/`));
6912
6990
  var COMMIT_LOG_FORMAT = "%x01%H%x00%h%x00%s%x00%at%x00%P";
6913
6991
  async function listBranchCommits(worktreePath, baseRef) {
6914
6992
  const out = await git(worktreePath, [
@@ -7307,7 +7385,7 @@ ${attachmentLines.join("\n")}` : text;
7307
7385
  });
7308
7386
  let accumulated = "";
7309
7387
  let buffer = "";
7310
- let seq = 0;
7388
+ let seq2 = 0;
7311
7389
  const toolNames = /* @__PURE__ */ new Map();
7312
7390
  const push = (chunk) => {
7313
7391
  if (!sender.isDestroyed()) sender.send("chat:chunk", chunk);
@@ -7341,7 +7419,7 @@ ${attachmentLines.join("\n")}` : text;
7341
7419
  } else if (block.type === "thinking" && block.thinking) {
7342
7420
  pushPhase({
7343
7421
  taskId,
7344
- id: `${taskId}-${seq++}`,
7422
+ id: `${taskId}-${seq2++}`,
7345
7423
  phaseType: "thinking",
7346
7424
  phaseSummary: "Thinking\u2026",
7347
7425
  phaseDetail: block.thinking,
@@ -7353,7 +7431,7 @@ ${attachmentLines.join("\n")}` : text;
7353
7431
  const { summary, detail } = summarizeToolUse(block.name, block.input ?? {});
7354
7432
  pushPhase({
7355
7433
  taskId,
7356
- id: `${taskId}-${seq++}`,
7434
+ id: `${taskId}-${seq2++}`,
7357
7435
  phaseType: "tool_use",
7358
7436
  phaseSummary: summary,
7359
7437
  phaseDetail: detail,
@@ -7370,7 +7448,7 @@ ${attachmentLines.join("\n")}` : text;
7370
7448
  const detail = typeof raw2 === "string" ? raw2 : Array.isArray(raw2) ? raw2.map((c) => c.text ?? "").join("\n") : "";
7371
7449
  pushPhase({
7372
7450
  taskId,
7373
- id: `${taskId}-${seq++}`,
7451
+ id: `${taskId}-${seq2++}`,
7374
7452
  phaseType: "tool_result",
7375
7453
  phaseSummary: `Got result from \`${toolName}\``,
7376
7454
  phaseDetail: detail,
@@ -7724,6 +7802,180 @@ function createProgressTracker(opts) {
7724
7802
  };
7725
7803
  }
7726
7804
 
7805
+ // packages/core/src/continuation.ts
7806
+ init_launch();
7807
+ init_progress();
7808
+ import fs21 from "fs";
7809
+ var MAX_BRIEF_CHARS = 8e3;
7810
+ var MAX_REPLY_CHARS = 2e3;
7811
+ var MAX_DESCRIPTION_CHARS = 4e3;
7812
+ var TAIL_BYTES = 256 * 1024;
7813
+ var CUT = "\u2026\uFF08\u5DF2\u622A\u65B7\uFF09";
7814
+ var LIMITS = [
7815
+ { reply: MAX_REPLY_CHARS, commits: 20, files: 30, todos: 40, cards: 30 },
7816
+ { reply: 800, commits: 10, files: 15, todos: 25, cards: 20 },
7817
+ { reply: 0, commits: 5, files: 8, todos: 15, cards: 10 },
7818
+ { reply: 0, commits: 0, files: 0, todos: 8, cards: 5 }
7819
+ ];
7820
+ function clipText(text, max) {
7821
+ return text.length <= max ? text : `${text.slice(0, Math.max(0, max - CUT.length)).trimEnd()}${CUT}`;
7822
+ }
7823
+ function more(total, shown) {
7824
+ return total > shown ? [` - \u2026\uFF08\u9084\u6709 ${total - shown} \u9805\u672A\u5217\u51FA\uFF09`] : [];
7825
+ }
7826
+ function gitSection(git2, limits) {
7827
+ const lines = ["", "## \u5206\u652F\u8207\u7A0B\u5F0F\u78BC", `- \u5206\u652F\uFF1A\`${git2.branch}\`${git2.baseBranch ? `\uFF0Cbase\uFF1A\`${git2.baseBranch}\`` : ""}`];
7828
+ lines.push(
7829
+ git2.unpushed === null ? "- push \u72C0\u614B\uFF1A\u9019\u500B\u5206\u652F\u9084\u6C92\u6709 upstream\uFF08\u5F9E\u672A push\uFF09" : git2.unpushed > 0 ? `- push \u72C0\u614B\uFF1A\u9818\u5148 upstream ${git2.unpushed} \u500B commit\uFF0C\u5C1A\u672A push` : "- push \u72C0\u614B\uFF1A\u8207 upstream \u540C\u6B65"
7830
+ );
7831
+ if (git2.commits.length === 0) {
7832
+ lines.push("- \u9019\u500B\u5206\u652F\u9084\u6C92\u6709 commit");
7833
+ } else if (limits.commits > 0) {
7834
+ lines.push(`- \`base..HEAD\` \u7684 commit\uFF08\u65B0\u5230\u820A\uFF0C\u5171 ${git2.commits.length} \u7B46\uFF09\uFF1A`);
7835
+ for (const c of git2.commits.slice(0, limits.commits)) lines.push(` - \`${c.shortSha}\` ${c.subject}`);
7836
+ lines.push(...more(git2.commits.length, limits.commits));
7837
+ } else {
7838
+ lines.push(`- \`base..HEAD\` \u5171 ${git2.commits.length} \u7B46 commit\uFF08\u7528 git log \u67E5\u770B\uFF09`);
7839
+ }
7840
+ if (git2.uncommitted.length === 0) {
7841
+ lines.push("- \u6C92\u6709\u672A commit \u7684\u8B8A\u66F4");
7842
+ } else if (limits.files > 0) {
7843
+ lines.push(`- \u672A commit \u7684\u8B8A\u66F4\uFF08${git2.uncommitted.length} \u500B\u6A94\u6848\uFF09\uFF1A`);
7844
+ for (const f of git2.uncommitted.slice(0, limits.files)) lines.push(` - \`${f.status}\` ${f.path}`);
7845
+ lines.push(...more(git2.uncommitted.length, limits.files));
7846
+ } else {
7847
+ lines.push(`- \u6709 ${git2.uncommitted.length} \u500B\u6A94\u6848\u672A commit\uFF08\u7528 git status \u67E5\u770B\uFF09`);
7848
+ }
7849
+ return lines;
7850
+ }
7851
+ function prSection(pr) {
7852
+ return [
7853
+ "",
7854
+ "## PR",
7855
+ pr ? `- #${pr.number} ${pr.state} ${pr.url}` : "- PR \u72C0\u614B\u672A\u77E5\uFF08\u5C1A\u672A\u958B PR\uFF0C\u6216 `gh` \u7121\u6CD5\u4F7F\u7528\u3001\u903E\u6642\uFF09"
7856
+ ];
7857
+ }
7858
+ var TODO_MARK = { completed: "[x]", in_progress: "[~]", pending: "[ ]" };
7859
+ function todoSection(todos, limit) {
7860
+ const lines = ["", "## \u524D\u4E00\u500B session \u7684 todo"];
7861
+ for (const t of todos.slice(0, limit)) lines.push(`- ${TODO_MARK[t.status]} ${t.content}`);
7862
+ if (todos.length > limit) lines.push(`- \u2026\uFF08\u9084\u6709 ${todos.length - limit} \u9805\u672A\u5217\u51FA\uFF09`);
7863
+ return lines;
7864
+ }
7865
+ function replySection(reply, limit) {
7866
+ return ["", "## \u524D\u4E00\u500B session \u7684\u6700\u5F8C\u4E00\u5247\u56DE\u8986", ...clipText(reply, limit).split("\n").map((l) => `> ${l}`)];
7867
+ }
7868
+ var cell = (text) => text.replace(/\|/g, "\\|").replace(/\s+/g, " ");
7869
+ function cardSection(cards, limit) {
7870
+ const lines = ["", "## \u5E95\u4E0B\u7684\u5361\u7247", "| id | \u6A19\u984C | \u6B04\u4F4D | \u57F7\u884C\u4E2D | todo | PR |", "| --- | --- | --- | --- | --- | --- |"];
7871
+ for (const c of cards.slice(0, limit)) {
7872
+ const todos = c.todos ? `${c.todos.done}/${c.todos.total}` : "-";
7873
+ const pr = c.pr ? `#${c.pr.number} ${c.pr.state}` : "-";
7874
+ lines.push(`| ${c.id} | ${cell(c.title)} | ${c.column} | ${c.running ? "\u662F" : "\u5426"} | ${todos} | ${pr} |`);
7875
+ }
7876
+ if (cards.length > limit) lines.push(`\uFF08\u9084\u6709 ${cards.length - limit} \u5F35\u672A\u5217\u51FA\uFF0C\u7528 task list \u67E5\u770B\uFF09`);
7877
+ return lines;
7878
+ }
7879
+ function render2(head, facts, limits) {
7880
+ const lines = [
7881
+ head,
7882
+ "",
7883
+ "\u9019\u662F\u540C\u4E00\u5F35\u5361\u7684\u65B0 session\uFF1A\u524D\u4E00\u500B session \u5DF2\u7D50\u675F\uFF0C\u5B83\u7684\u5C0D\u8A71\u4F60\u770B\u4E0D\u5230\u3002\u4EE5\u4E0B\u662F\u63A5\u7E8C\u6240\u9700\u7684\u4E8B\u5BE6\uFF1B\u539F\u672C\u7684\u6A94\u6848\u3001\u5206\u652F\u8207\u8B8A\u66F4\u90FD\u9084\u5728\u539F\u8655\uFF0C\u6C92\u6709\u4EFB\u4F55\u6771\u897F\u88AB\u4E1F\u68C4\u3002"
7884
+ ];
7885
+ if (facts.git) lines.push(...gitSection(facts.git, limits));
7886
+ if (facts.pr !== void 0) lines.push(...prSection(facts.pr));
7887
+ if (facts.todos?.length) lines.push(...todoSection(facts.todos, limits.todos));
7888
+ if (facts.lastReply && limits.reply > 0) lines.push(...replySection(facts.lastReply, limits.reply));
7889
+ if (facts.cards) lines.push(...cardSection(facts.cards, limits.cards));
7890
+ lines.push(
7891
+ "",
7892
+ "## \u63A5\u7E8C\u6307\u793A",
7893
+ facts.cards ? "\u5148\u78BA\u8A8D\u5E95\u4E0B\u5361\u7247\u7684\u76EE\u524D\u72C0\u614B\uFF1B\u6709\u9700\u8981\u4F60\u8655\u7406\u7684\u5C31\u63A5\u8457\u8655\u7406\uFF0C\u6C92\u6709\u5C31\u7C21\u77ED\u56DE\u5831\u6574\u9AD4\u72C0\u614B\uFF0C\u7136\u5F8C\u7B49\u5F85\u6307\u793A\u3002" : "\u5148\u78BA\u8A8D git status \u8207 PR \u72C0\u614B\uFF1B\u6709\u672A\u5B8C\u6210\u7684 todo \u5C31\u63A5\u8457\u505A\uFF0C\u6C92\u6709\u5C31\u7C21\u77ED\u56DE\u5831\u76EE\u524D\u72C0\u614B\uFF0C\u7136\u5F8C\u7B49\u5F85\u6307\u793A\u3002"
7894
+ );
7895
+ return lines.join("\n");
7896
+ }
7897
+ function buildContinuationPrompt(facts) {
7898
+ const description = facts.description?.trim();
7899
+ const head = buildPrompt({
7900
+ title: facts.title,
7901
+ description: description ? clipText(description, MAX_DESCRIPTION_CHARS) : void 0
7902
+ });
7903
+ for (const limits of LIMITS) {
7904
+ const text = render2(head, facts, limits);
7905
+ if (text.length <= MAX_BRIEF_CHARS) return text;
7906
+ }
7907
+ return clipText(render2(head, facts, LIMITS[LIMITS.length - 1]), MAX_BRIEF_CHARS);
7908
+ }
7909
+ function readLastClaudeReply(file, maxChars) {
7910
+ let fd;
7911
+ try {
7912
+ fd = fs21.openSync(file, "r");
7913
+ const size = fs21.fstatSync(fd).size;
7914
+ const start = Math.max(0, size - TAIL_BYTES);
7915
+ const buf = Buffer.alloc(size - start);
7916
+ fs21.readSync(fd, buf, 0, buf.length, start);
7917
+ let text = buf.toString("utf8");
7918
+ if (start > 0) {
7919
+ const newline = text.indexOf("\n");
7920
+ text = newline === -1 ? "" : text.slice(newline + 1);
7921
+ }
7922
+ const reply = claudeLastReply(text.split("\n").filter((l) => l.trim()));
7923
+ return reply ? clipText(reply, maxChars) : void 0;
7924
+ } catch {
7925
+ return void 0;
7926
+ } finally {
7927
+ if (fd !== void 0) fs21.closeSync(fd);
7928
+ }
7929
+ }
7930
+
7931
+ // packages/core/src/inbox.ts
7932
+ init_launch();
7933
+ import fs22 from "fs";
7934
+ import path23 from "path";
7935
+ var seq = 0;
7936
+ function inboxDir(worktreePath) {
7937
+ return path23.join(worktreePath, INBOX_DIR);
7938
+ }
7939
+ function inboxReady(dir) {
7940
+ return fs22.existsSync(path23.join(dir, INBOX_READY_FILE));
7941
+ }
7942
+ function prepareInbox(dir) {
7943
+ fs22.mkdirSync(dir, { recursive: true });
7944
+ fs22.writeFileSync(path23.join(dir, ".gitignore"), "*\n");
7945
+ fs22.rmSync(path23.join(dir, INBOX_READY_FILE), { force: true });
7946
+ }
7947
+ function messageNames(dir) {
7948
+ try {
7949
+ return fs22.readdirSync(dir).filter((n) => !n.startsWith(".")).sort();
7950
+ } catch {
7951
+ return [];
7952
+ }
7953
+ }
7954
+ function pendingMessages(dir) {
7955
+ return messageNames(dir).length;
7956
+ }
7957
+ function postMessage(dir, text) {
7958
+ fs22.mkdirSync(dir, { recursive: true });
7959
+ const name = `${String(Date.now()).padStart(13, "0")}-${String(seq++ % 1e6).padStart(6, "0")}`;
7960
+ const tmp = path23.join(dir, `.tmp-${name}`);
7961
+ fs22.writeFileSync(tmp, text);
7962
+ fs22.renameSync(tmp, path23.join(dir, name));
7963
+ }
7964
+ function takeMessages(dir) {
7965
+ const texts = [];
7966
+ for (const name of messageNames(dir)) {
7967
+ const claimed = path23.join(dir, `.host-${name}`);
7968
+ try {
7969
+ fs22.renameSync(path23.join(dir, name), claimed);
7970
+ } catch {
7971
+ continue;
7972
+ }
7973
+ texts.push(fs22.readFileSync(claimed, "utf8"));
7974
+ fs22.rmSync(claimed, { force: true });
7975
+ }
7976
+ return texts;
7977
+ }
7978
+
7727
7979
  // packages/core/src/mailbox.ts
7728
7980
  var PASTE_START = "\x1B[200~";
7729
7981
  var PASTE_END = "\x1B[201~";
@@ -7751,25 +8003,77 @@ function quietFromEnv() {
7751
8003
  return Number.isFinite(n) && n >= 0 ? n : DEFAULT_QUIET_MS;
7752
8004
  }
7753
8005
  var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
8006
+ var PASTED = /\x1b\[200~[\s\S]*?(\x1b\[201~|$)/g;
8007
+ var ESCAPES = /\x1b(\[[0-9;?<=>]*[ -\/]*[@-~]|O.|.)?/g;
8008
+ var CLEARS_INPUT = /[\r\n\x03\x15]/;
8009
+ function draftAfter(before, data) {
8010
+ const keys = data.replace(PASTED, "x").replace(ESCAPES, "");
8011
+ let draft = before;
8012
+ for (const ch of keys) {
8013
+ if (CLEARS_INPUT.test(ch)) draft = false;
8014
+ else if (ch >= " " && ch !== "\x7F") draft = true;
8015
+ }
8016
+ return draft;
8017
+ }
8018
+ var isIdle = (a) => !a || a.state === "unknown" || a.state === "waiting" && a.waitingFor === "input";
7754
8019
  function createMailbox(options) {
7755
8020
  const lastInput = /* @__PURE__ */ new Map();
8021
+ const drafts = /* @__PURE__ */ new Set();
7756
8022
  const held = /* @__PURE__ */ new Map();
7757
8023
  const turns = /* @__PURE__ */ new Map();
8024
+ function noteInput(key, data) {
8025
+ lastInput.set(key, Date.now());
8026
+ if (draftAfter(drafts.has(key), data)) drafts.add(key);
8027
+ else drafts.delete(key);
8028
+ }
7758
8029
  async function waitForQuiet(key, started) {
7759
8030
  const quiet = options.quietMs ?? quietFromEnv();
7760
8031
  const timeout = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
7761
8032
  for (; ; ) {
7762
- const left = (lastInput.get(key) ?? 0) + quiet - Date.now();
8033
+ const left = drafts.has(key) ? 250 : (lastInput.get(key) ?? 0) + quiet - Date.now();
7763
8034
  if (left <= 0) return;
7764
- if (Date.now() - started > timeout) throw coded("TIMEOUT", "the terminal never went quiet");
8035
+ if (Date.now() - started > timeout) {
8036
+ throw coded("TIMEOUT", drafts.has(key) ? "the input box still holds unsent text" : "the terminal never went quiet");
8037
+ }
8038
+ await sleep(Math.min(left, 250));
8039
+ }
8040
+ }
8041
+ function enqueue(key, job) {
8042
+ const run3 = (turns.get(key) ?? Promise.resolve()).catch(() => {
8043
+ }).then(job);
8044
+ turns.set(key, run3);
8045
+ void run3.finally(() => {
8046
+ if (turns.get(key) === run3) turns.delete(key);
8047
+ }).catch(() => {
8048
+ });
8049
+ return run3;
8050
+ }
8051
+ async function canWake(key) {
8052
+ if (!isIdle(options.activity(key)) || drafts.has(key)) return false;
8053
+ return !await options.typedElsewhere?.(key);
8054
+ }
8055
+ async function wake(key, dir) {
8056
+ const quiet = options.quietMs ?? quietFromEnv();
8057
+ for (; ; ) {
8058
+ if (!await canWake(key)) return "queued";
8059
+ const left = (lastInput.get(key) ?? 0) + quiet - Date.now();
8060
+ if (left <= 0) break;
7765
8061
  await sleep(Math.min(left, 250));
7766
8062
  }
8063
+ const texts = takeMessages(dir);
8064
+ if (!texts.length) return "hook";
8065
+ await write(key, texts.join("\n\n"));
8066
+ return "typed";
7767
8067
  }
7768
8068
  async function type(key, text, opts, started) {
7769
8069
  await waitForQuiet(key, started);
7770
8070
  if (!opts.force && isBlocked(options.activity(key))) {
7771
8071
  throw coded("TARGET_BLOCKED", "the agent is on a permission dialog; typing could answer it");
7772
8072
  }
8073
+ await write(key, text);
8074
+ return { queuedMs: Date.now() - started, via: "typed" };
8075
+ }
8076
+ async function write(key, text) {
7773
8077
  held.set(key, []);
7774
8078
  try {
7775
8079
  options.write(key, bracketedPaste(text));
@@ -7778,36 +8082,38 @@ function createMailbox(options) {
7778
8082
  } finally {
7779
8083
  const keys = held.get(key) ?? [];
7780
8084
  held.delete(key);
7781
- if (keys.length) {
7782
- options.write(key, keys.join(""));
7783
- lastInput.set(key, Date.now());
7784
- }
8085
+ if (keys.length) options.write(key, keys.join(""));
7785
8086
  }
7786
- return { queuedMs: Date.now() - started };
7787
8087
  }
7788
8088
  return {
7789
8089
  userInput(key, data) {
8090
+ noteInput(key, data);
7790
8091
  const buffer = held.get(key);
7791
8092
  if (buffer) {
7792
8093
  buffer.push(data);
7793
8094
  return;
7794
8095
  }
7795
- lastInput.set(key, Date.now());
7796
8096
  options.write(key, data);
7797
8097
  },
7798
8098
  deliver(key, text, opts = {}) {
7799
8099
  const started = Date.now();
7800
- const run3 = (turns.get(key) ?? Promise.resolve()).catch(() => {
7801
- }).then(() => type(key, text, opts, started));
7802
- turns.set(key, run3);
7803
- void run3.finally(() => {
7804
- if (turns.get(key) === run3) turns.delete(key);
7805
- }).catch(() => {
8100
+ return enqueue(key, async () => {
8101
+ const dir = options.inbox?.(key);
8102
+ if (!dir) return type(key, text, opts, started);
8103
+ postMessage(dir, text);
8104
+ const via = await wake(key, dir);
8105
+ return { queuedMs: Date.now() - started, via };
8106
+ });
8107
+ },
8108
+ poke(key) {
8109
+ const dir = options.inbox?.(key);
8110
+ if (!dir || !pendingMessages(dir) || turns.has(key)) return;
8111
+ void enqueue(key, () => wake(key, dir)).catch(() => {
7806
8112
  });
7807
- return run3;
7808
8113
  },
7809
8114
  forget(key) {
7810
8115
  lastInput.delete(key);
8116
+ drafts.delete(key);
7811
8117
  held.delete(key);
7812
8118
  }
7813
8119
  };
@@ -7941,6 +8247,8 @@ function obj(value, name) {
7941
8247
  if (!value || typeof value !== "object" || Array.isArray(value)) invalid(`${name} must be an object`);
7942
8248
  return value;
7943
8249
  }
8250
+ var PR_LOOKUP_MS = 5e3;
8251
+ var lookUpPr = (worktreePath) => getPrStatus(worktreePath, PR_LOOKUP_MS);
7944
8252
  var LIBRARY_KINDS2 = ["skill", "prompt", "script"];
7945
8253
  var AGENT_IDS2 = ["claude", "codex"];
7946
8254
  var COLUMNS = ["backlog", "in_progress", "done"];
@@ -7978,7 +8286,7 @@ function validBoard(value) {
7978
8286
  }
7979
8287
  return next;
7980
8288
  }
7981
- function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatus, acliRunner, jiraAuthStatus, modelCatalog, jevRouter }) {
8289
+ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatus, acliRunner, jiraAuthStatus, modelCatalog, jevRouter, titleTranslator, prStatus = lookUpPr }) {
7982
8290
  const sink = bus.sink();
7983
8291
  const models = modelCatalog ?? createModelCatalog({ version });
7984
8292
  const router = jevRouter ?? createJevRouter({ getApiKey: readJevApiKey });
@@ -7993,11 +8301,12 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
7993
8301
  const home = homeDir ?? os9.homedir();
7994
8302
  const progress = createProgressTracker({
7995
8303
  homeDir: home,
7996
- codexHomes: () => [path23.join(home, ".codex"), ...libraryCodexHome ? [libraryCodexHome] : []],
8304
+ codexHomes: () => [path24.join(home, ".codex"), ...libraryCodexHome ? [libraryCodexHome] : []],
7997
8305
  onUpdate: (taskId, value) => {
7998
8306
  bus.emit("progress:update", { taskId, progress: value });
7999
8307
  notifier.activity(taskId, value.activity);
8000
8308
  notifier.retry(taskId);
8309
+ mailbox.poke(taskId);
8001
8310
  },
8002
8311
  onNotify: (taskId, list) => {
8003
8312
  const prefs = resolveNotificationSettings(getSettings());
@@ -8016,7 +8325,14 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
8016
8325
  const agentActivity = (key) => progress.isTracking(key) ? progress.snapshot(key)?.activity ?? null : null;
8017
8326
  const mailbox = createMailbox({
8018
8327
  write: (key, data) => sessions.write(key, data),
8019
- activity: agentActivity
8328
+ activity: agentActivity,
8329
+ inbox: (key) => {
8330
+ const worktree = findTask(key)?.worktreePath;
8331
+ if (!worktree) return null;
8332
+ const dir = inboxDir(worktree);
8333
+ return inboxReady(dir) ? dir : null;
8334
+ },
8335
+ typedElsewhere: async (key) => await sessions.hasForeignClients?.(key) ?? false
8020
8336
  });
8021
8337
  const notifier = createNotifier({
8022
8338
  cardOf: (taskId) => {
@@ -8062,6 +8378,99 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
8062
8378
  if (!wasTracking) progress.untrack(task.id);
8063
8379
  return snapshot?.totalUsage ?? task.usage;
8064
8380
  }
8381
+ const continuing = /* @__PURE__ */ new Set();
8382
+ function executorTranscript(task) {
8383
+ if (!task.worktreePath) return void 0;
8384
+ const file = `${executorSessionId(task.id, task.runId)}.jsonl`;
8385
+ let resolved = task.worktreePath;
8386
+ try {
8387
+ resolved = fs23.realpathSync(task.worktreePath);
8388
+ } catch {
8389
+ }
8390
+ for (const cwd of /* @__PURE__ */ new Set([task.worktreePath, resolved])) {
8391
+ const candidate = path24.join(claudeProjectDir(home, cwd), file);
8392
+ if (fs23.existsSync(candidate)) return candidate;
8393
+ }
8394
+ return void 0;
8395
+ }
8396
+ async function continuationFacts(task) {
8397
+ trackProgress(task);
8398
+ const todos = progress.snapshot(task.id)?.todos;
8399
+ const transcript = taskAgent(task) === "claude" ? executorTranscript(task) : void 0;
8400
+ const lastReply = transcript ? readLastClaudeReply(transcript, MAX_REPLY_CHARS) : void 0;
8401
+ const facts = {
8402
+ title: task.title,
8403
+ description: task.description,
8404
+ ...todos?.length ? { todos } : {},
8405
+ ...lastReply ? { lastReply } : {}
8406
+ };
8407
+ if (isMasterTask(task)) {
8408
+ facts.cards = (await summarizeTasks({ masterId: task.id })).map((c) => ({
8409
+ id: c.id,
8410
+ title: c.title,
8411
+ column: c.column,
8412
+ running: c.running,
8413
+ ...c.todos ? { todos: { done: c.todos.done, total: c.todos.total } } : {},
8414
+ ...c.pr ? { pr: { number: c.pr.number, state: c.pr.state } } : {}
8415
+ }));
8416
+ return facts;
8417
+ }
8418
+ const worktree = gitWorktree(task);
8419
+ if (!worktree) return facts;
8420
+ const [commits, uncommitted, unpushed, pr] = await Promise.all([
8421
+ getBranchCommits(worktree, task.baseBranch ?? "main").catch(() => null),
8422
+ collectWorkingEntries(worktree).catch(() => null),
8423
+ git(worktree, ["rev-list", "--count", "@{u}..HEAD"]).then((n) => Number.parseInt(n, 10) || 0, () => null),
8424
+ prStatus(worktree).catch(() => null)
8425
+ ]);
8426
+ if (commits || uncommitted) {
8427
+ facts.git = {
8428
+ branch: task.branch,
8429
+ ...task.baseBranch ? { baseBranch: task.baseBranch } : {},
8430
+ commits: (commits?.commits ?? []).map((c) => ({ shortSha: c.shortSha, subject: c.subject })),
8431
+ uncommitted: (uncommitted ?? []).map((e) => ({ path: e.path, status: e.status })),
8432
+ unpushed
8433
+ };
8434
+ }
8435
+ facts.pr = pr;
8436
+ return facts;
8437
+ }
8438
+ async function continueTask(taskId, force) {
8439
+ const task = requireTask(taskId);
8440
+ if (continuing.has(task.id)) throw coded2("ALREADY_CONTINUING", "\u9019\u5F35\u5361\u6B63\u5728\u63DB\u65B0 session");
8441
+ const column = columnOf(task.id);
8442
+ if (column !== "in_progress") throw coded2("NOT_IN_PROGRESS", `\u53EA\u6709 In Progress \u7684\u5361\u7247\u53EF\u4EE5\u63DB\u65B0 session\uFF08\u76EE\u524D\u5728 ${column}\uFF09`);
8443
+ if (!task.launchedAt) throw coded2("NOT_LAUNCHED", "\u9019\u5F35\u5361\u9084\u6C92\u6709\u57F7\u884C\u904E\uFF0C\u8ACB\u76F4\u63A5\u555F\u52D5");
8444
+ if (!task.worktreePath) throw coded2("NO_WORKTREE", "\u9019\u5F35\u5361\u6C92\u6709 worktree");
8445
+ continuing.add(task.id);
8446
+ try {
8447
+ if (!force && await sessions.isAlive(task.id)) {
8448
+ trackProgress(task);
8449
+ const activity = agentActivity(task.id);
8450
+ if (activity?.state === "working" || isBlocked(activity)) {
8451
+ throw coded2("AGENT_BUSY", "agent \u6B63\u5728\u57F7\u884C\u6216\u7B49\u5F85\u6B0A\u9650\u78BA\u8A8D\uFF1B\u52A0\u4E0A force \u624D\u6703\u4E2D\u65B7\u5B83\u4E26\u63DB\u65B0 session");
8452
+ }
8453
+ }
8454
+ const brief = buildContinuationPrompt(await continuationFacts(task));
8455
+ const usage = usageThroughCurrentRun(task);
8456
+ updateTask(task.id, { runId: randomUUID5(), launchedAt: Date.now(), ...usage ? { usage } : {} });
8457
+ resetSubAgents(task.worktreePath);
8458
+ bus.emit("subagents:update", { taskId: task.id, subAgents: [] });
8459
+ const next = requireTask(task.id);
8460
+ try {
8461
+ await startTaskSession(next, next.id, { taskId: next.id, launch: {} }, brief);
8462
+ } catch (err) {
8463
+ updateTask(task.id, { runId: task.runId, launchedAt: task.launchedAt, usage: task.usage });
8464
+ trackProgress(findTask(task.id) ?? task);
8465
+ bus.emit("state:changed", getState());
8466
+ throw err;
8467
+ }
8468
+ bus.emit("state:changed", getState());
8469
+ return { state: getState(), task: findTask(task.id) ?? next };
8470
+ } finally {
8471
+ continuing.delete(task.id);
8472
+ }
8473
+ }
8065
8474
  try {
8066
8475
  for (const task of getState().board.in_progress) trackProgress(task);
8067
8476
  } catch {
@@ -8123,12 +8532,12 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
8123
8532
  function settledRoute(task) {
8124
8533
  return task.jevRoute?.status === "routing" ? void 0 : task.jevRoute;
8125
8534
  }
8126
- async function launchCommand(task, intent) {
8535
+ async function launchCommand(task, intent, continuation) {
8127
8536
  const settings = getSettings();
8128
8537
  const library = await libraryLaunchInfo(task.worktreePath);
8129
8538
  const boardCli = await boardCliLaunchInfo();
8130
8539
  let route = settledRoute(task);
8131
- const needsRoute = !taskModel(task) || task.effort === "auto";
8540
+ const needsRoute = !continuation && (!taskModel(task) || task.effort === "auto");
8132
8541
  if (needsRoute && !intent.resume && intent.includeTaskPrompt !== false) {
8133
8542
  let pending = routing.get(task.id);
8134
8543
  if (!pending) {
@@ -8165,20 +8574,21 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
8165
8574
  library: library ?? void 0,
8166
8575
  boardCli,
8167
8576
  autoMode: task.autoMode ?? settings.autoMode,
8168
- preface
8577
+ preface,
8578
+ continuation
8169
8579
  },
8170
8580
  task.workspacePath
8171
8581
  );
8172
8582
  }
8173
8583
  function claudeSessionFile(cwd, sessionId) {
8174
8584
  const munged = cwd.replace(/[^a-zA-Z0-9]/g, "-");
8175
- return path23.join(os9.homedir(), ".claude", "projects", munged, `${sessionId}.jsonl`);
8585
+ return path24.join(os9.homedir(), ".claude", "projects", munged, `${sessionId}.jsonl`);
8176
8586
  }
8177
8587
  async function removeTaskWorktree(task) {
8178
8588
  if (!task.projectPath || !task.worktreePath) return;
8179
8589
  const branch = task.branch || fallbackBranchName(task.id);
8180
8590
  await removeWorktree(task.projectPath, task.worktreePath);
8181
- deleteArtifacts(task.workspacePath ?? path23.dirname(task.worktreePath), task.worktreePath);
8591
+ deleteArtifacts(task.workspacePath ?? path24.dirname(task.worktreePath), task.worktreePath);
8182
8592
  await deleteBranch(task.projectPath, branch);
8183
8593
  }
8184
8594
  function columnOf(taskId) {
@@ -8232,7 +8642,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
8232
8642
  authStatus: jiraAuthStatus ?? (() => getJiraAuthStatus(acliRunner)),
8233
8643
  pointFields: () => getSettings().jira?.storyPointsFields?.length ? getSettings().jira.storyPointsFields : DEFAULT_POINT_FIELDS
8234
8644
  });
8235
- async function startTaskSession(requested, key, p) {
8645
+ async function startTaskSession(requested, key, p, continuation) {
8236
8646
  const pending = provisioning.get(requested.id);
8237
8647
  const task = p.launch ? await ensureProvisioned(requested) : pending ? await pending : requested;
8238
8648
  const cwd = task.worktreePath;
@@ -8244,7 +8654,8 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
8244
8654
  if (intent.resume && await sessions.isAlive(key)) {
8245
8655
  fresh = false;
8246
8656
  } else {
8247
- command = (await launchCommand(task, intent)).replace(/\r$/, "");
8657
+ command = (await launchCommand(task, intent, continuation)).replace(/\r$/, "");
8658
+ if (key === task.id) prepareInbox(inboxDir(cwd));
8248
8659
  }
8249
8660
  }
8250
8661
  if (p.launch) ensureTaskArtifactDirs(task);
@@ -8422,8 +8833,8 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
8422
8833
  "projects:listRecent": () => listRecentProjects(getStore()),
8423
8834
  // `vibeflow open <path>` while a host runs: only the host writes the store.
8424
8835
  "projects:record": (projectPath) => {
8425
- const p = path23.resolve(str(projectPath, "projectPath"));
8426
- if (!fs21.existsSync(p) || !fs21.statSync(p).isDirectory()) invalid(`not a directory: ${p}`);
8836
+ const p = path24.resolve(str(projectPath, "projectPath"));
8837
+ if (!fs23.existsSync(p) || !fs23.statSync(p).isDirectory()) invalid(`not a directory: ${p}`);
8427
8838
  recordRecentProject(getStore(), p);
8428
8839
  return listRecentProjects(getStore());
8429
8840
  },
@@ -8458,7 +8869,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
8458
8869
  attachments: p.attachments,
8459
8870
  github: p.github,
8460
8871
  jira: p.jira
8461
- });
8872
+ }, { translateTitle: titleTranslator });
8462
8873
  return { state: getState(), task };
8463
8874
  },
8464
8875
  "vibeflow:removeTask": (taskId) => {
@@ -8496,7 +8907,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
8496
8907
  if (!task.baseBranch) throw new Error("\u4EFB\u52D9\u6C92\u6709\u8A18\u9304 base branch\uFF0C\u7121\u6CD5\u9084\u539F worktree");
8497
8908
  await teardownTask(task.id);
8498
8909
  await resetWorktreeToBase(task.worktreePath, task.baseBranch);
8499
- const workspacePath = task.workspacePath ?? path23.dirname(task.worktreePath);
8910
+ const workspacePath = task.workspacePath ?? path24.dirname(task.worktreePath);
8500
8911
  deleteArtifacts(workspacePath, task.worktreePath);
8501
8912
  deleteDecisions(workspacePath, decisionsKey(task.worktreePath, task.branch));
8502
8913
  resetSubAgents(task.worktreePath);
@@ -8548,7 +8959,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
8548
8959
  }
8549
8960
  const info = await getGitInfo(nextProject);
8550
8961
  if (!info.isRepo) throw new Error("\u76EE\u6A19\u8CC7\u6599\u593E\u4E0D\u662F git repository");
8551
- const projectName = path23.basename(nextProject);
8962
+ const projectName = path24.basename(nextProject);
8552
8963
  const workspacePath = projectWorkstationPath(resolveWorkstationPath(getSettings()), projectName);
8553
8964
  await teardownTask(existing.id);
8554
8965
  await removeTaskWorktree(existing);
@@ -8607,6 +9018,14 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
8607
9018
  await startTaskSession(started, task.id, { taskId: task.id, launch: {} });
8608
9019
  return { state: getState(), task: findTask(task.id) ?? started };
8609
9020
  },
9021
+ // A running card carries on in a new agent session: same worktree and branch,
9022
+ // nothing discarded, first message built by core from the card's own facts.
9023
+ // Only an id and `force` come from the client — never the brief's text.
9024
+ "vibeflow:continueTask": async (payload) => {
9025
+ const p = obj(payload, "payload");
9026
+ if (p.force !== void 0 && typeof p.force !== "boolean") invalid("force must be a boolean");
9027
+ return continueTask(str(p.taskId, "taskId"), p.force === true);
9028
+ },
8610
9029
  // Every card on the board, or one master's cards, as the CLI and a master's
8611
9030
  // agent read them.
8612
9031
  "task:summaries": (payload) => {
@@ -8631,8 +9050,8 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
8631
9050
  if (!await sessions.isAlive(to.id)) throw coded2("NOT_RUNNING", `\u5361\u7247 ${to.id} \u7684 agent \u6C92\u6709\u5728\u57F7\u884C`);
8632
9051
  if (isMasterTask(to)) notifier.reported(from.id);
8633
9052
  await attachAgent(to.id);
8634
- const { queuedMs } = await mailbox.deliver(to.id, frameMessage({ id: from.id, title: from.title }, text), { force: p.force === true });
8635
- return { delivered: true, queuedMs };
9053
+ const { queuedMs, via } = await mailbox.deliver(to.id, frameMessage({ id: from.id, title: from.title }, text), { force: p.force === true });
9054
+ return { delivered: true, queuedMs, via };
8636
9055
  },
8637
9056
  "terminal:start": async (payload) => {
8638
9057
  const p = obj(payload, "payload");
@@ -8660,10 +9079,10 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
8660
9079
  } else {
8661
9080
  cwd = os9.homedir();
8662
9081
  }
8663
- if (!path23.isAbsolute(cwd) || !fs21.existsSync(cwd) || !fs21.statSync(cwd).isDirectory()) {
9082
+ if (!path24.isAbsolute(cwd) || !fs23.existsSync(cwd) || !fs23.statSync(cwd).isDirectory()) {
8664
9083
  invalid("terminal directory must be an existing absolute directory");
8665
9084
  }
8666
- const title = (typeof p.title === "string" ? p.title.trim() : "") || saved?.title || (projectPath ? path23.basename(projectPath) : "~");
9085
+ const title = (typeof p.title === "string" ? p.title.trim() : "") || saved?.title || (projectPath ? path24.basename(projectPath) : "~");
8667
9086
  saveTerminal({
8668
9087
  sessionKey: key,
8669
9088
  title,
@@ -8738,7 +9157,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
8738
9157
  "claude:sessionExists": (taskId) => {
8739
9158
  const task = requireTask(taskId);
8740
9159
  if (!task.worktreePath) return false;
8741
- return fs21.existsSync(claudeSessionFile(task.worktreePath, executorSessionId(task.id, task.runId)));
9160
+ return fs23.existsSync(claudeSessionFile(task.worktreePath, executorSessionId(task.id, task.runId)));
8742
9161
  },
8743
9162
  "sessions:list": async () => {
8744
9163
  const keys = await sessions.list();
@@ -8827,7 +9246,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
8827
9246
  const task = requireTask(taskId);
8828
9247
  if (!task.worktreePath || !task.workspacePath) return "task has no worktree";
8829
9248
  const dir = agentArtifactsPath(task.workspacePath, task.worktreePath);
8830
- if (!fs21.existsSync(dir)) return "artifacts directory does not exist yet";
9249
+ if (!fs23.existsSync(dir)) return "artifacts directory does not exist yet";
8831
9250
  return getPlatform().openPath(dir);
8832
9251
  },
8833
9252
  "board:getCliLaunchInfo": () => boardCliLaunchInfo(),
@@ -8958,10 +9377,10 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
8958
9377
  }
8959
9378
  await removeTaskWorktree(task);
8960
9379
  if (task.workspacePath) {
8961
- fs21.rmSync(taskAttachmentStagingPath(task.workspacePath, task.id), { recursive: true, force: true });
9380
+ fs23.rmSync(taskAttachmentStagingPath(task.workspacePath, task.id), { recursive: true, force: true });
8962
9381
  }
8963
9382
  if (isMasterTask(task) && task.workspacePath) {
8964
- fs21.rmSync(task.workspacePath, { recursive: true, force: true });
9383
+ fs23.rmSync(task.workspacePath, { recursive: true, force: true });
8965
9384
  }
8966
9385
  clearConversation(task.id);
8967
9386
  removeTask(task.id);
@@ -9014,9 +9433,9 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
9014
9433
  // Watch the containing directory, not the file: JsonStore renames a temp
9015
9434
  // file over the target and so replaces the inode on every save.
9016
9435
  watchStore() {
9017
- const file = path23.basename(getStorePath());
9436
+ const file = path24.basename(getStorePath());
9018
9437
  let debounce = null;
9019
- storeWatcher = fs21.watch(path23.dirname(getStorePath()), (_event, filename) => {
9438
+ storeWatcher = fs23.watch(path24.dirname(getStorePath()), (_event, filename) => {
9020
9439
  if (filename !== file) return;
9021
9440
  if (debounce) clearTimeout(debounce);
9022
9441
  debounce = setTimeout(() => {
@@ -9053,9 +9472,9 @@ function createSessionBackend(sink, choice) {
9053
9472
  }
9054
9473
 
9055
9474
  // packages/core/src/web-server.ts
9056
- import fs22 from "fs";
9475
+ import fs24 from "fs";
9057
9476
  import http from "http";
9058
- import path24 from "path";
9477
+ import path25 from "path";
9059
9478
  import { timingSafeEqual } from "crypto";
9060
9479
  import { WebSocketServer } from "ws";
9061
9480
  var TOKEN_COOKIE = "vf_token";
@@ -9110,14 +9529,14 @@ function resolveStatic(root, urlPath) {
9110
9529
  return null;
9111
9530
  }
9112
9531
  if (decoded.includes("\0")) return null;
9113
- const rel = path24.posix.normalize(decoded).replace(/^\/+/, "");
9114
- const base2 = path24.resolve(root);
9115
- const candidates = [rel, path24.posix.join(rel, "index.html"), `${rel}.html`];
9532
+ const rel = path25.posix.normalize(decoded).replace(/^\/+/, "");
9533
+ const base2 = path25.resolve(root);
9534
+ const candidates = [rel, path25.posix.join(rel, "index.html"), `${rel}.html`];
9116
9535
  for (const c of candidates) {
9117
- const full = path24.resolve(base2, c);
9118
- if (full !== base2 && !full.startsWith(base2 + path24.sep)) return null;
9536
+ const full = path25.resolve(base2, c);
9537
+ if (full !== base2 && !full.startsWith(base2 + path25.sep)) return null;
9119
9538
  try {
9120
- if (fs22.statSync(full).isFile()) return full;
9539
+ if (fs24.statSync(full).isFile()) return full;
9121
9540
  } catch {
9122
9541
  }
9123
9542
  }
@@ -9178,7 +9597,7 @@ async function startWebServer(options) {
9178
9597
  send(res, 404, "Not found");
9179
9598
  return;
9180
9599
  }
9181
- const ext = path24.extname(file).toLowerCase();
9600
+ const ext = path25.extname(file).toLowerCase();
9182
9601
  const immutable = url.pathname.startsWith("/_next/static/");
9183
9602
  res.writeHead(200, {
9184
9603
  "Content-Type": CONTENT_TYPES[ext] ?? "application/octet-stream",
@@ -9191,7 +9610,7 @@ async function startWebServer(options) {
9191
9610
  res.end();
9192
9611
  return;
9193
9612
  }
9194
- fs22.createReadStream(file).pipe(res);
9613
+ fs24.createReadStream(file).pipe(res);
9195
9614
  }
9196
9615
  const wss = new WebSocketServer({ noServer: true, maxPayload: MAX_PAYLOAD });
9197
9616
  function reject(socket, status, reason) {
@@ -9290,8 +9709,8 @@ Content-Length: 0\r
9290
9709
  }
9291
9710
 
9292
9711
  // packages/cli/src/update-command.ts
9293
- import fs23 from "node:fs";
9294
- import path25 from "node:path";
9712
+ import fs25 from "node:fs";
9713
+ import path26 from "node:path";
9295
9714
  import { spawnSync } from "node:child_process";
9296
9715
  function npmRunner(args, inherit) {
9297
9716
  const spawnOpts = {
@@ -9303,7 +9722,7 @@ function npmRunner(args, inherit) {
9303
9722
  }
9304
9723
  function packageName(packageRoot) {
9305
9724
  try {
9306
- const pkg = JSON.parse(fs23.readFileSync(path25.join(packageRoot, "package.json"), "utf8"));
9725
+ const pkg = JSON.parse(fs25.readFileSync(path26.join(packageRoot, "package.json"), "utf8"));
9307
9726
  if (typeof pkg.name !== "string") return null;
9308
9727
  return /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/i.test(pkg.name) ? pkg.name : null;
9309
9728
  } catch {
@@ -9318,7 +9737,7 @@ function runUpdate(options) {
9318
9737
  error("vibeflow update \u53EA\u9069\u7528\u65BC\u5168\u57DF npm \u5B89\u88DD\uFF1B\u76EE\u524D\u662F\u539F\u59CB\u78BC\u7248\u672C\u3002");
9319
9738
  return 1;
9320
9739
  }
9321
- const packageRoot = path25.dirname(path25.dirname(options.cliEntry));
9740
+ const packageRoot = path26.dirname(path26.dirname(options.cliEntry));
9322
9741
  const name = packageName(packageRoot);
9323
9742
  if (!name) {
9324
9743
  error("\u7121\u6CD5\u8FA8\u8B58\u76EE\u524D VibeFlow \u7684 npm \u5957\u4EF6\u540D\u7A31\uFF0C\u5DF2\u53D6\u6D88\u66F4\u65B0\u3002");
@@ -9330,8 +9749,8 @@ function runUpdate(options) {
9330
9749
  return 1;
9331
9750
  }
9332
9751
  try {
9333
- const globalPackage = path25.join(String(root.stdout).trim(), ...name.split("/"));
9334
- if (fs23.lstatSync(globalPackage).isSymbolicLink() || fs23.realpathSync(globalPackage) !== fs23.realpathSync(packageRoot)) {
9752
+ const globalPackage = path26.join(String(root.stdout).trim(), ...name.split("/"));
9753
+ if (fs25.lstatSync(globalPackage).isSymbolicLink() || fs25.realpathSync(globalPackage) !== fs25.realpathSync(packageRoot)) {
9335
9754
  error("vibeflow update \u53EA\u9069\u7528\u65BC\u5168\u57DF npm \u5B89\u88DD\uFF1B\u76EE\u524D\u57F7\u884C\u7684\u5957\u4EF6\u4F86\u81EA\u5176\u4ED6\u4F4D\u7F6E\u3002");
9336
9755
  return 1;
9337
9756
  }
@@ -9476,8 +9895,8 @@ async function openUpdateTerminal(platform = process.platform, run3 = launch) {
9476
9895
  }
9477
9896
 
9478
9897
  // packages/cli/src/self-update.ts
9479
- import fs24 from "node:fs";
9480
- import path26 from "node:path";
9898
+ import fs26 from "node:fs";
9899
+ import path27 from "node:path";
9481
9900
  import { execFile as execFile10 } from "node:child_process";
9482
9901
  import { promisify as promisify7 } from "node:util";
9483
9902
  var execFileAsync2 = promisify7(execFile10);
@@ -9486,7 +9905,7 @@ var PROBE_RETRY_MS = 3e4;
9486
9905
  var HOST_TOKEN_ENV = "VIBEFLOW_HOST_TOKEN";
9487
9906
  function readInstalledVersion(packageRoot) {
9488
9907
  try {
9489
- const pkg = JSON.parse(fs24.readFileSync(path26.join(packageRoot, "package.json"), "utf8"));
9908
+ const pkg = JSON.parse(fs26.readFileSync(path27.join(packageRoot, "package.json"), "utf8"));
9490
9909
  return typeof pkg.version === "string" ? pkg.version : null;
9491
9910
  } catch {
9492
9911
  return null;
@@ -9579,10 +9998,10 @@ async function startHost(options) {
9579
9998
  prefer: options.backend,
9580
9999
  stateDir: options.userDataDir
9581
10000
  });
9582
- const core = createCore({ sessions, bus, version: options.version });
10001
+ const core = createCore({ sessions, bus, version: options.version, titleTranslator: claudeTitleTranslator });
9583
10002
  let updateTimer = null;
9584
10003
  let installTimer = null;
9585
- const packageRoot = options.cliEntry ? path27.dirname(path27.dirname(options.cliEntry)) : null;
10004
+ const packageRoot = options.cliEntry ? path28.dirname(path28.dirname(options.cliEntry)) : null;
9586
10005
  const updates = createUpdateMonitor({
9587
10006
  packageName: options.sourceRoot || !packageRoot ? null : packageName(packageRoot),
9588
10007
  currentVersion: options.version,
@@ -9670,12 +10089,12 @@ function loginUrl(lock, pathname = "/home/") {
9670
10089
  return `http://127.0.0.1:${lock.port}${pathname}?token=${encodeURIComponent(lock.token)}`;
9671
10090
  }
9672
10091
  function isWebDir(dir) {
9673
- return fs25.existsSync(path27.join(dir, "home", "index.html"));
10092
+ return fs27.existsSync(path28.join(dir, "home", "index.html"));
9674
10093
  }
9675
10094
 
9676
10095
  // packages/cli/src/doctor.ts
9677
- import fs26 from "fs";
9678
- import path28 from "path";
10096
+ import fs28 from "fs";
10097
+ import path29 from "path";
9679
10098
  import { execFile as execFile11 } from "child_process";
9680
10099
  import { promisify as promisify8 } from "util";
9681
10100
  init_env();
@@ -9815,10 +10234,10 @@ async function runDoctor(options) {
9815
10234
  });
9816
10235
  }
9817
10236
  try {
9818
- fs26.mkdirSync(options.userDataDir, { recursive: true });
9819
- const probe = path28.join(options.userDataDir, `.doctor-${process.pid}`);
9820
- fs26.writeFileSync(probe, "");
9821
- fs26.rmSync(probe);
10237
+ fs28.mkdirSync(options.userDataDir, { recursive: true });
10238
+ const probe = path29.join(options.userDataDir, `.doctor-${process.pid}`);
10239
+ fs28.writeFileSync(probe, "");
10240
+ fs28.rmSync(probe);
9822
10241
  checks.push({ id: "data", name: "\u8CC7\u6599\u76EE\u9304", level: "ok", detail: options.userDataDir });
9823
10242
  } catch (err) {
9824
10243
  checks.push({
@@ -9873,24 +10292,24 @@ Options:
9873
10292
  `.trim();
9874
10293
  function detectLayout() {
9875
10294
  const file = fileURLToPath2(import.meta.url);
9876
- const here = path31.dirname(file);
9877
- const bundledWeb = path31.join(here, "web");
9878
- if (isWebDir(bundledWeb) || path31.basename(here) === "dist") {
10295
+ const here = path32.dirname(file);
10296
+ const bundledWeb = path32.join(here, "web");
10297
+ if (isWebDir(bundledWeb) || path32.basename(here) === "dist") {
9879
10298
  return {
9880
- version: readVersion(path31.join(here, "..", "package.json")),
10299
+ version: readVersion(path32.join(here, "..", "package.json")),
9881
10300
  webDir: isWebDir(bundledWeb) ? bundledWeb : null,
9882
10301
  sourceRoot: null,
9883
10302
  cliEntry: file
9884
10303
  };
9885
10304
  }
9886
- const root = path31.resolve(here, "..", "..", "..");
10305
+ const root = path32.resolve(here, "..", "..", "..");
9887
10306
  const override = process.env.VIBEFLOW_WEB_DIR;
9888
- const webDir = override && isWebDir(override) ? override : isWebDir(path31.join(root, "app")) ? path31.join(root, "app") : null;
9889
- return { version: readVersion(path31.join(root, "package.json")), webDir, sourceRoot: root, cliEntry: null };
10307
+ const webDir = override && isWebDir(override) ? override : isWebDir(path32.join(root, "app")) ? path32.join(root, "app") : null;
10308
+ return { version: readVersion(path32.join(root, "package.json")), webDir, sourceRoot: root, cliEntry: null };
9890
10309
  }
9891
10310
  function readVersion(pkgPath) {
9892
10311
  try {
9893
- return JSON.parse(fs28.readFileSync(pkgPath, "utf8")).version;
10312
+ return JSON.parse(fs30.readFileSync(pkgPath, "utf8")).version;
9894
10313
  } catch {
9895
10314
  return "0.0.0";
9896
10315
  }
@@ -10128,8 +10547,8 @@ async function cmdOpen(values, target, layout, userDataDir) {
10128
10547
  console.error("\u7528\u6CD5\uFF1Avibeflow open <path>");
10129
10548
  return 1;
10130
10549
  }
10131
- const dir = path31.resolve(target);
10132
- if (!fs28.existsSync(dir) || !fs28.statSync(dir).isDirectory()) {
10550
+ const dir = path32.resolve(target);
10551
+ if (!fs30.existsSync(dir) || !fs30.statSync(dir).isDirectory()) {
10133
10552
  console.error(`\u4E0D\u662F\u8CC7\u6599\u593E\uFF1A${dir}`);
10134
10553
  return 1;
10135
10554
  }