@kw-yeh/vibeflow 4.11.60 → 4.11.62
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/builtin-skills/address-review/scripts/pr-lib.mjs +1 -0
- package/dist/builtin-skills/pr-watch/SKILL.md +19 -8
- package/dist/builtin-skills/pr-watch/scripts/pr-lib.mjs +1 -0
- package/dist/builtin-skills/pr-watch/scripts/pr-watch.mjs +34 -10
- package/dist/vibeflow.mjs +437 -109
- package/dist/web/404/index.html +1 -1
- package/dist/web/404.html +1 -1
- package/dist/web/_next/static/{DDcUTYxPTa0eFKJZ3xGl4 → TULkjf0SGRJklXVvxpUwi}/_buildManifest.js +1 -1
- package/dist/web/_next/static/chunks/pages/{_app-afd9eb2814f60818.js → _app-cc5f3a5ded198d58.js} +1 -1
- package/dist/web/_next/static/chunks/pages/home-1b55b5bcebcaafa1.js +14 -0
- package/dist/web/_next/static/css/{775ca0d5cedbe9ea.css → 72b287592be5d3f0.css} +1 -1
- package/dist/web/home/index.html +1 -1
- package/package.json +1 -1
- package/dist/web/_next/static/chunks/pages/home-1b4098f1ae4f1d9b.js +0 -13
- /package/dist/web/_next/static/{DDcUTYxPTa0eFKJZ3xGl4 → TULkjf0SGRJklXVvxpUwi}/_ssgManifest.js +0 -0
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,
|
|
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,
|
|
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);
|
|
@@ -772,7 +777,7 @@ function buildAgentCommand(task, systemPrompt, opts, workspacePath) {
|
|
|
772
777
|
const role = task.role === "master" ? masterSystemPrompt({ canWrite, autoMode: opts?.autoMode === true }) : task.masterId ? slaveSystemPrompt({ canWrite }) : null;
|
|
773
778
|
const sys = task.masterId && task.role !== "master" ? role ?? "" : role ? [custom, role].filter(Boolean).join("\n\n") : custom;
|
|
774
779
|
const includeTaskPrompt = opts?.includeTaskPrompt !== false;
|
|
775
|
-
const prompt = includeTaskPrompt && !opts?.resume ? buildPrompt(task, opts?.preface) : "";
|
|
780
|
+
const prompt = includeTaskPrompt && !opts?.resume ? opts?.continuation ?? buildPrompt(task, opts?.preface) : "";
|
|
776
781
|
const sessionId = agent === "claude" && includeTaskPrompt ? executorSessionId(task.id, task.runId) : void 0;
|
|
777
782
|
return boardEnvPrefix(task, opts, workspacePath) + assembleCommand(
|
|
778
783
|
agent,
|
|
@@ -1110,6 +1115,17 @@ function reduceClaudeLine(state, line) {
|
|
|
1110
1115
|
function claudeUsageTotal(state) {
|
|
1111
1116
|
return { ...Object.values(state.usageById).reduce(addUsage, emptyUsage()), turns: state.turns };
|
|
1112
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
|
+
}
|
|
1113
1129
|
function initialCodexState() {
|
|
1114
1130
|
return { todos: null, usage: emptyUsage(), activity: { state: "unknown" } };
|
|
1115
1131
|
}
|
|
@@ -1257,11 +1273,11 @@ var init_progress = __esm({
|
|
|
1257
1273
|
|
|
1258
1274
|
// packages/tui/src/task-form.ts
|
|
1259
1275
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
1260
|
-
import
|
|
1276
|
+
import fs29 from "fs";
|
|
1261
1277
|
import os10 from "os";
|
|
1262
1278
|
import path30 from "path";
|
|
1263
1279
|
import React, { useEffect, useRef, useState } from "react";
|
|
1264
|
-
import { Box, Text, render as
|
|
1280
|
+
import { Box, Text, render as render3, useApp, useInput } from "ink";
|
|
1265
1281
|
function newFormState(defaultAutoMode, agents) {
|
|
1266
1282
|
const agentCli = agents && agents.length > 0 && !agents.some((a) => a.id === "claude") ? agents[0].id : "claude";
|
|
1267
1283
|
return {
|
|
@@ -1396,17 +1412,17 @@ function editorCommand(env, platform) {
|
|
|
1396
1412
|
return env.VISUAL?.trim() || env.EDITOR?.trim() || (platform === "win32" ? "notepad" : "vi");
|
|
1397
1413
|
}
|
|
1398
1414
|
function editInEditor(text) {
|
|
1399
|
-
const dir =
|
|
1415
|
+
const dir = fs29.mkdtempSync(path30.join(os10.tmpdir(), "vibeflow-"));
|
|
1400
1416
|
const file = path30.join(dir, "description.md");
|
|
1401
1417
|
try {
|
|
1402
|
-
|
|
1418
|
+
fs29.writeFileSync(file, text);
|
|
1403
1419
|
const cmd = editorCommand(process.env, process.platform);
|
|
1404
1420
|
const r = spawnSync2(`${cmd} "${file}"`, { stdio: "inherit", shell: true });
|
|
1405
1421
|
if (r.error) return { error: `\u7121\u6CD5\u555F\u52D5\u7DE8\u8F2F\u5668\uFF08${cmd}\uFF09\uFF1A${r.error.message}` };
|
|
1406
1422
|
if (r.status !== 0) return { error: `\u7DE8\u8F2F\u5668\uFF08${cmd}\uFF09\u7D50\u675F\u78BC ${r.status}\uFF0C\u63CF\u8FF0\u672A\u8B8A\u66F4` };
|
|
1407
|
-
return { text:
|
|
1423
|
+
return { text: fs29.readFileSync(file, "utf8").replace(/\r?\n$/, "") };
|
|
1408
1424
|
} finally {
|
|
1409
|
-
|
|
1425
|
+
fs29.rmSync(dir, { recursive: true, force: true });
|
|
1410
1426
|
}
|
|
1411
1427
|
}
|
|
1412
1428
|
function cycle(list, current, step) {
|
|
@@ -1480,7 +1496,7 @@ function FormView({ api, ctx, initial, initialFocus, initialMessage, pristine, o
|
|
|
1480
1496
|
if (value2) setProject(path30.resolve(value2.replace(/^~(?=$|\/)/, os10.homedir())));
|
|
1481
1497
|
} else if (editing === "attachments" && value2) {
|
|
1482
1498
|
const file = path30.resolve(value2.replace(/^~(?=$|\/)/, os10.homedir()));
|
|
1483
|
-
if (!
|
|
1499
|
+
if (!fs29.existsSync(file) || !fs29.statSync(file).isFile()) {
|
|
1484
1500
|
setMessage(`\u627E\u4E0D\u5230\u6A94\u6848\uFF1A${file}`);
|
|
1485
1501
|
return;
|
|
1486
1502
|
}
|
|
@@ -1649,7 +1665,7 @@ function FormView({ api, ctx, initial, initialFocus, initialMessage, pristine, o
|
|
|
1649
1665
|
function showForm(api, ctx, initial, pristine, initialFocus = 0, initialMessage) {
|
|
1650
1666
|
return new Promise((resolve) => {
|
|
1651
1667
|
let result = { type: "cancel" };
|
|
1652
|
-
const instance =
|
|
1668
|
+
const instance = render3(
|
|
1653
1669
|
h(FormView, { api, ctx, initial, initialFocus, initialMessage, pristine, onResult: (r) => result = r }),
|
|
1654
1670
|
{ exitOnCtrlC: false }
|
|
1655
1671
|
);
|
|
@@ -1734,7 +1750,7 @@ __export(src_exports, {
|
|
|
1734
1750
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
1735
1751
|
import path31 from "path";
|
|
1736
1752
|
import React2, { useEffect as useEffect2, useState as useState2 } from "react";
|
|
1737
|
-
import { Box as Box2, Text as Text2, render as
|
|
1753
|
+
import { Box as Box2, Text as Text2, render as render4, useApp as useApp2, useInput as useInput2, useStdout } from "ink";
|
|
1738
1754
|
function findDetachKey(text) {
|
|
1739
1755
|
const plain = text.indexOf(DETACH_KEY);
|
|
1740
1756
|
const m = /\x1b\[\d+;\d+;29;1;\d+;\d+_/.exec(text);
|
|
@@ -2005,7 +2021,7 @@ function BoardView({ opts, initial, initialMessage, onAction }) {
|
|
|
2005
2021
|
function showBoard(opts, initial, initialMessage) {
|
|
2006
2022
|
return new Promise((resolve) => {
|
|
2007
2023
|
let result = { action: { type: "quit" }, sel: initial };
|
|
2008
|
-
const instance =
|
|
2024
|
+
const instance = render4(
|
|
2009
2025
|
h2(BoardView, {
|
|
2010
2026
|
opts,
|
|
2011
2027
|
initial,
|
|
@@ -2162,7 +2178,7 @@ var init_src = __esm({
|
|
|
2162
2178
|
});
|
|
2163
2179
|
|
|
2164
2180
|
// packages/cli/src/main.ts
|
|
2165
|
-
import
|
|
2181
|
+
import fs30 from "fs";
|
|
2166
2182
|
import path32 from "path";
|
|
2167
2183
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
2168
2184
|
import { parseArgs as parseArgs2 } from "node:util";
|
|
@@ -2694,6 +2710,13 @@ function createBridge(t) {
|
|
|
2694
2710
|
updateTask: (payload) => t.invoke("vibeflow:updateTask", payload),
|
|
2695
2711
|
/** Move a Backlog card to In Progress and start its agent on the host. */
|
|
2696
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),
|
|
2697
2720
|
/** Cards as a master sees them; filter by master or a single card. */
|
|
2698
2721
|
taskSummaries: (filter) => t.invoke("task:summaries", filter),
|
|
2699
2722
|
/** Type a message into another card's agent: a master to its cards, a card to its master. */
|
|
@@ -2898,11 +2921,6 @@ function spawnHelperFixCommand(failures) {
|
|
|
2898
2921
|
// packages/cli/src/task-command.ts
|
|
2899
2922
|
import { parseArgs } from "node:util";
|
|
2900
2923
|
|
|
2901
|
-
// packages/core/src/tasks.ts
|
|
2902
|
-
import path13 from "path";
|
|
2903
|
-
import { randomUUID as randomUUID2 } from "crypto";
|
|
2904
|
-
import fs10 from "fs/promises";
|
|
2905
|
-
|
|
2906
2924
|
// packages/core/src/branch-name.ts
|
|
2907
2925
|
import os2 from "os";
|
|
2908
2926
|
|
|
@@ -2983,7 +3001,8 @@ ${description ?? ""}`;
|
|
|
2983
3001
|
if (slug) return `${branchPrefix(title, description)}/${slug}`;
|
|
2984
3002
|
return null;
|
|
2985
3003
|
}
|
|
2986
|
-
|
|
3004
|
+
var NON_ASCII_LETTER_RE = new RegExp("(?![\\x00-\\x7F])\\p{L}", "u");
|
|
3005
|
+
var claudeTitleTranslator = async (title) => {
|
|
2987
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.
|
|
2988
3007
|
Title: ${title}`;
|
|
2989
3008
|
try {
|
|
@@ -2999,15 +3018,25 @@ Title: ${title}`;
|
|
|
2999
3018
|
} catch {
|
|
3000
3019
|
return null;
|
|
3001
3020
|
}
|
|
3002
|
-
}
|
|
3003
|
-
async function generateBranchName(title, description) {
|
|
3021
|
+
};
|
|
3022
|
+
async function generateBranchName(title, description, translate) {
|
|
3004
3023
|
const local = buildCandidateBranch(title, description);
|
|
3005
3024
|
if (local) return local;
|
|
3006
|
-
|
|
3007
|
-
|
|
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
|
+
}
|
|
3008
3032
|
return null;
|
|
3009
3033
|
}
|
|
3010
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
|
+
|
|
3011
3040
|
// packages/core/src/git.ts
|
|
3012
3041
|
import { execFile as execFile5 } from "child_process";
|
|
3013
3042
|
import { promisify as promisify2 } from "util";
|
|
@@ -4078,6 +4107,44 @@ async function adoptRemoteBranch(projectPath, worktreePath, branch, base2) {
|
|
|
4078
4107
|
copyIgnoredDependenciesInBackground(projectPath, worktreePath, ignoredEntries);
|
|
4079
4108
|
return { branch, worktreePath, pushed: true, baseBranch: base2 };
|
|
4080
4109
|
}
|
|
4110
|
+
async function freshStartPoint(projectPath, base2, hasRemote) {
|
|
4111
|
+
if (!hasRemote) return base2;
|
|
4112
|
+
try {
|
|
4113
|
+
await git(projectPath, ["fetch", "origin", `${base2}:${base2}`]);
|
|
4114
|
+
} catch {
|
|
4115
|
+
try {
|
|
4116
|
+
await git(projectPath, ["fetch", "origin", base2]);
|
|
4117
|
+
} catch {
|
|
4118
|
+
}
|
|
4119
|
+
}
|
|
4120
|
+
try {
|
|
4121
|
+
await git(projectPath, ["rev-parse", "--verify", `origin/${base2}`]);
|
|
4122
|
+
return `origin/${base2}`;
|
|
4123
|
+
} catch {
|
|
4124
|
+
return base2;
|
|
4125
|
+
}
|
|
4126
|
+
}
|
|
4127
|
+
async function provisionDetachedWorktree(projectPath, workspacePath, taskId, baseBranch) {
|
|
4128
|
+
await ensureLocalExclude(projectPath);
|
|
4129
|
+
const worktreePath = path12.join(workspacePath, fallbackBranchName(taskId));
|
|
4130
|
+
if (await fs9.access(worktreePath).then(() => true, () => false)) {
|
|
4131
|
+
throw Object.assign(new Error(`\u5DE5\u4F5C\u5340\u8CC7\u6599\u593E\u5DF2\u5B58\u5728\uFF1A${fallbackBranchName(taskId)}`), {
|
|
4132
|
+
code: "WORKTREE_DIR_EXISTS"
|
|
4133
|
+
});
|
|
4134
|
+
}
|
|
4135
|
+
const info = await getGitInfo(projectPath);
|
|
4136
|
+
const base2 = baseBranch || info.defaultBase || info.currentBranch || "HEAD";
|
|
4137
|
+
const startPoint = await freshStartPoint(projectPath, base2, info.hasRemote);
|
|
4138
|
+
try {
|
|
4139
|
+
await git(projectPath, ["worktree", "add", "--detach", worktreePath, startPoint]);
|
|
4140
|
+
} catch (err) {
|
|
4141
|
+
await removeWorktree(projectPath, worktreePath);
|
|
4142
|
+
throw err;
|
|
4143
|
+
}
|
|
4144
|
+
const ignoredEntries = await copySmallIgnoredFiles(projectPath, worktreePath);
|
|
4145
|
+
copyIgnoredDependenciesInBackground(projectPath, worktreePath, ignoredEntries);
|
|
4146
|
+
return { worktreePath, pushed: false, baseBranch: base2 };
|
|
4147
|
+
}
|
|
4081
4148
|
async function provisionWorktree(projectPath, workspacePath, taskId, baseBranch, preferredBranch, opts = {}) {
|
|
4082
4149
|
await ensureLocalExclude(projectPath);
|
|
4083
4150
|
const branch = opts.explicitBranch && preferredBranch ? preferredBranch : await resolveBranchName(projectPath, workspacePath, taskId, preferredBranch);
|
|
@@ -4087,23 +4154,7 @@ async function provisionWorktree(projectPath, workspacePath, taskId, baseBranch,
|
|
|
4087
4154
|
if (opts.explicitBranch && info.hasRemote && await remoteBranchExists(projectPath, branch)) {
|
|
4088
4155
|
return adoptRemoteBranch(projectPath, worktreePath, branch, base2);
|
|
4089
4156
|
}
|
|
4090
|
-
|
|
4091
|
-
if (info.hasRemote) {
|
|
4092
|
-
try {
|
|
4093
|
-
await git(projectPath, ["fetch", "origin", `${base2}:${base2}`]);
|
|
4094
|
-
} catch {
|
|
4095
|
-
try {
|
|
4096
|
-
await git(projectPath, ["fetch", "origin", base2]);
|
|
4097
|
-
} catch {
|
|
4098
|
-
}
|
|
4099
|
-
}
|
|
4100
|
-
try {
|
|
4101
|
-
await git(projectPath, ["rev-parse", "--verify", `origin/${base2}`]);
|
|
4102
|
-
startPoint = `origin/${base2}`;
|
|
4103
|
-
} catch {
|
|
4104
|
-
startPoint = base2;
|
|
4105
|
-
}
|
|
4106
|
-
}
|
|
4157
|
+
const startPoint = await freshStartPoint(projectPath, base2, info.hasRemote);
|
|
4107
4158
|
try {
|
|
4108
4159
|
await git(projectPath, [
|
|
4109
4160
|
"worktree",
|
|
@@ -4426,12 +4477,13 @@ async function captureTaskOutcome(worktreePath, baseBranch) {
|
|
|
4426
4477
|
capturedAt: Date.now()
|
|
4427
4478
|
};
|
|
4428
4479
|
}
|
|
4429
|
-
async function getPrStatus(worktreePath) {
|
|
4480
|
+
async function getPrStatus(worktreePath, timeoutMs) {
|
|
4430
4481
|
try {
|
|
4431
4482
|
const { stdout } = await pexec2(
|
|
4432
4483
|
"gh",
|
|
4433
4484
|
["pr", "view", "--json", "url,number,state"],
|
|
4434
|
-
|
|
4485
|
+
// A lookup that outlives its caller must not keep the worktree open as a process's cwd.
|
|
4486
|
+
{ cwd: worktreePath, env: execEnv(), ...timeoutMs ? { timeout: timeoutMs } : {} }
|
|
4435
4487
|
);
|
|
4436
4488
|
const parsed = JSON.parse(stdout.toString().trim());
|
|
4437
4489
|
if (parsed.url) return parsed;
|
|
@@ -4490,11 +4542,11 @@ ${commits || "(none)"}`,
|
|
|
4490
4542
|
"",
|
|
4491
4543
|
"Output ONLY the commit message text, nothing else. Start directly with [What]."
|
|
4492
4544
|
].join("\n");
|
|
4493
|
-
const
|
|
4494
|
-
claude: ["-p"],
|
|
4495
|
-
codex: ["-
|
|
4545
|
+
const cliArgs = {
|
|
4546
|
+
claude: ["-p", "--model", "haiku"],
|
|
4547
|
+
codex: ["exec", "--model", "gpt-5.6-luna", "--sandbox", "read-only", "-"]
|
|
4496
4548
|
};
|
|
4497
|
-
const flags =
|
|
4549
|
+
const flags = cliArgs[agentCli] ?? ["-p"];
|
|
4498
4550
|
const bin = agentCli;
|
|
4499
4551
|
const stdout = await runAgentPrint(bin, flags, prompt, { cwd: worktreePath });
|
|
4500
4552
|
const result = stdout.trim();
|
|
@@ -4580,7 +4632,7 @@ async function assertDirectory(dir) {
|
|
|
4580
4632
|
throw taskError(`\u627E\u4E0D\u5230\u8CC7\u6599\u593E\uFF1A${dir}`, "WORK_DIR_NOT_FOUND");
|
|
4581
4633
|
}
|
|
4582
4634
|
}
|
|
4583
|
-
async function createTaskFromInput(input) {
|
|
4635
|
+
async function createTaskFromInput(input, options = {}) {
|
|
4584
4636
|
if (input.role === "master") return createMasterTask(input);
|
|
4585
4637
|
const projectPath = input.projectPath;
|
|
4586
4638
|
if (!projectPath) throw taskError("\u5C1A\u672A\u9078\u64C7\u5C08\u6848\u8CC7\u6599\u593E", "PROJECT_NOT_FOUND");
|
|
@@ -4592,12 +4644,13 @@ async function createTaskFromInput(input) {
|
|
|
4592
4644
|
if (input.mode === "new") {
|
|
4593
4645
|
await initRepository(projectPath);
|
|
4594
4646
|
}
|
|
4647
|
+
const noBranch = input.createBranch === false;
|
|
4595
4648
|
const info = await getGitInfo(projectPath);
|
|
4596
|
-
if (!info.isRepo) {
|
|
4649
|
+
if (!info.isRepo && !noBranch) {
|
|
4597
4650
|
throw Object.assign(new Error("\u76EE\u6A19\u8DEF\u5F91\u4E0D\u662F git repository"), { code: "PROJECT_NOT_GIT_REPO" });
|
|
4598
4651
|
}
|
|
4599
4652
|
const taskId = randomUUID2().slice(0, 8);
|
|
4600
|
-
const explicitBranch = input.branch?.trim() || null;
|
|
4653
|
+
const explicitBranch = noBranch ? null : input.branch?.trim() || null;
|
|
4601
4654
|
const store = input.storePath ? getStoreAtPath(input.storePath) : getStore();
|
|
4602
4655
|
if (input.masterId) assertMasterRef(store.get("board"), input.masterId);
|
|
4603
4656
|
const projectName = path13.basename(projectPath);
|
|
@@ -4609,16 +4662,18 @@ async function createTaskFromInput(input) {
|
|
|
4609
4662
|
if (explicitBranch) {
|
|
4610
4663
|
await assertBranchAvailable(projectPath, workspacePath, explicitBranch);
|
|
4611
4664
|
}
|
|
4612
|
-
const branch = explicitBranch ?? await generateBranchName(input.title, input.description);
|
|
4665
|
+
const branch = noBranch ? "" : explicitBranch ?? await generateBranchName(input.title, input.description, options.translateTitle) ?? fallbackBranchName(taskId);
|
|
4613
4666
|
const draft = {
|
|
4614
4667
|
id: taskId,
|
|
4615
4668
|
title: input.title.trim() || `Task ${taskId}`,
|
|
4616
|
-
branch
|
|
4669
|
+
branch,
|
|
4617
4670
|
branchExplicit: explicitBranch ? true : void 0,
|
|
4618
4671
|
projectPath,
|
|
4619
4672
|
projectName,
|
|
4620
4673
|
workspacePath,
|
|
4621
|
-
baseBranch: input.baseBranch || info.defaultBase || info.currentBranch || void 0
|
|
4674
|
+
baseBranch: info.isRepo ? input.baseBranch || info.defaultBase || info.currentBranch || void 0 : void 0,
|
|
4675
|
+
...noBranch ? { noBranch: true } : {},
|
|
4676
|
+
...noBranch && !info.isRepo ? { inPlace: true } : {}
|
|
4622
4677
|
};
|
|
4623
4678
|
const col = input.status ?? "backlog";
|
|
4624
4679
|
const provisioned = col === "backlog" ? null : await provisionTaskWorktree(draft);
|
|
@@ -4712,7 +4767,23 @@ async function provisionTaskWorktree(task) {
|
|
|
4712
4767
|
code: "WORKTREE_CREATE_FAILED"
|
|
4713
4768
|
});
|
|
4714
4769
|
}
|
|
4770
|
+
if (task.inPlace) {
|
|
4771
|
+
return { branch: "", worktreePath: task.projectPath, provisionedAt: Date.now() };
|
|
4772
|
+
}
|
|
4715
4773
|
await fs10.mkdir(task.workspacePath, { recursive: true });
|
|
4774
|
+
if (task.noBranch) {
|
|
4775
|
+
try {
|
|
4776
|
+
const result = await provisionDetachedWorktree(
|
|
4777
|
+
task.projectPath,
|
|
4778
|
+
task.workspacePath,
|
|
4779
|
+
task.id,
|
|
4780
|
+
task.baseBranch ?? null
|
|
4781
|
+
);
|
|
4782
|
+
return { branch: "", ...result, provisionedAt: Date.now() };
|
|
4783
|
+
} catch (err) {
|
|
4784
|
+
throw taskError(`Worktree \u5EFA\u7ACB\u5931\u6557\uFF1A${err.message}`, "WORKTREE_CREATE_FAILED");
|
|
4785
|
+
}
|
|
4786
|
+
}
|
|
4716
4787
|
if (task.branchExplicit) {
|
|
4717
4788
|
await assertBranchAvailable(task.projectPath, task.workspacePath, task.branch);
|
|
4718
4789
|
}
|
|
@@ -4930,6 +5001,8 @@ task create options:
|
|
|
4930
5001
|
--branch <name> Branch to create for the task (default: derived from the title).
|
|
4931
5002
|
If origin already publishes it, the branch is fetched and
|
|
4932
5003
|
checked out instead of being created.
|
|
5004
|
+
--no-branch Do not create a branch: a git project gets a detached
|
|
5005
|
+
worktree, any other folder is used as is.
|
|
4933
5006
|
--mode <mode> ${MODES.join(" | ")} (default: existing; "new" runs git init first)
|
|
4934
5007
|
--agent <id> Task agent: ${AGENT_IDS.join(" | ")} (default: claude)
|
|
4935
5008
|
--model <id> Task model (default: the agent's own default)
|
|
@@ -4956,6 +5029,12 @@ task update options:
|
|
|
4956
5029
|
task start / list / show / send (need the running VibeFlow host):
|
|
4957
5030
|
start --task <id> Move a Backlog card to In Progress and start its agent,
|
|
4958
5031
|
the same as dragging it in the app
|
|
5032
|
+
start --task <id> --new-session [--force]
|
|
5033
|
+
An In Progress card that has run carries on in a NEW agent
|
|
5034
|
+
session: it starts from a short brief (card text, branch and
|
|
5035
|
+
PR state, todos, the last reply), not the old conversation,
|
|
5036
|
+
and its usage so far is kept. Nothing the card produced is
|
|
5037
|
+
touched. --force interrupts an agent that is still working
|
|
4959
5038
|
list [--master <id>] Every card, or one master's cards, with column, whether
|
|
4960
5039
|
its agent is running, todo progress, activity and PR
|
|
4961
5040
|
show --task <id> The same summary for one card
|
|
@@ -5035,6 +5114,7 @@ async function taskCommand(argv) {
|
|
|
5035
5114
|
status: { type: "string" },
|
|
5036
5115
|
"base-branch": { type: "string" },
|
|
5037
5116
|
branch: { type: "string" },
|
|
5117
|
+
"no-branch": { type: "boolean" },
|
|
5038
5118
|
mode: { type: "string" },
|
|
5039
5119
|
agent: { type: "string" },
|
|
5040
5120
|
model: { type: "string" },
|
|
@@ -5045,6 +5125,7 @@ async function taskCommand(argv) {
|
|
|
5045
5125
|
text: { type: "string" },
|
|
5046
5126
|
from: { type: "string" },
|
|
5047
5127
|
force: { type: "boolean" },
|
|
5128
|
+
"new-session": { type: "boolean" },
|
|
5048
5129
|
"store-path": { type: "string" },
|
|
5049
5130
|
profile: { type: "string" },
|
|
5050
5131
|
help: { type: "boolean", short: "h" }
|
|
@@ -5074,6 +5155,8 @@ async function taskCommand(argv) {
|
|
|
5074
5155
|
if (!task2) fail("TASK_NOT_FOUND", `Task not found: ${taskId}`);
|
|
5075
5156
|
return { taskId, path: addTaskArtifact(task2, values.file) };
|
|
5076
5157
|
}
|
|
5158
|
+
if (values["new-session"] && sub !== "start") fail("INVALID_ARGUMENT", "--new-session only goes with task start");
|
|
5159
|
+
if (sub === "start" && values.force && !values["new-session"]) fail("INVALID_ARGUMENT", "--force goes with task start --new-session");
|
|
5077
5160
|
if (HOST_COMMANDS.includes(sub)) return hostCommand(sub, values, storePath);
|
|
5078
5161
|
if (sub === "update") {
|
|
5079
5162
|
if (!values.task) fail("MISSING_ARGUMENT", "Missing required arguments: --task");
|
|
@@ -5107,6 +5190,8 @@ async function taskCommand(argv) {
|
|
|
5107
5190
|
if (master && (values.project || values["base-branch"] || values.branch || values.mode)) {
|
|
5108
5191
|
fail("INVALID_ARGUMENT", "A master card has no project: drop --project / --base-branch / --branch / --mode");
|
|
5109
5192
|
}
|
|
5193
|
+
if (master && values["no-branch"]) fail("INVALID_ARGUMENT", "A master card has no branch already: drop --no-branch");
|
|
5194
|
+
if (values["no-branch"] && values.branch !== void 0) fail("INVALID_ARGUMENT", "--branch and --no-branch cannot be used together");
|
|
5110
5195
|
const missing = [];
|
|
5111
5196
|
if (!master && !values.project) missing.push("--project");
|
|
5112
5197
|
if (!values.title) missing.push("--title");
|
|
@@ -5135,6 +5220,7 @@ async function taskCommand(argv) {
|
|
|
5135
5220
|
status: values.status ?? "backlog",
|
|
5136
5221
|
baseBranch: values["base-branch"] ?? null,
|
|
5137
5222
|
branch: values.branch,
|
|
5223
|
+
createBranch: values["no-branch"] ? false : void 0,
|
|
5138
5224
|
mode: values.mode ?? "existing",
|
|
5139
5225
|
agentCli: values.agent,
|
|
5140
5226
|
model: values.model,
|
|
@@ -5142,7 +5228,7 @@ async function taskCommand(argv) {
|
|
|
5142
5228
|
autoMode: values["auto-mode"] ? values["auto-mode"] === "on" : void 0,
|
|
5143
5229
|
attachments,
|
|
5144
5230
|
storePath
|
|
5145
|
-
});
|
|
5231
|
+
}, { translateTitle: claudeTitleTranslator });
|
|
5146
5232
|
return {
|
|
5147
5233
|
storePath: resolvedPath,
|
|
5148
5234
|
task: {
|
|
@@ -5152,6 +5238,7 @@ async function taskCommand(argv) {
|
|
|
5152
5238
|
masterId: task.masterId ?? null,
|
|
5153
5239
|
projectPath: task.projectPath ?? null,
|
|
5154
5240
|
branch: task.branch,
|
|
5241
|
+
noBranch: task.noBranch === true,
|
|
5155
5242
|
worktreePath: task.worktreePath ?? null,
|
|
5156
5243
|
baseBranch: task.baseBranch,
|
|
5157
5244
|
agentCli: task.agentCli,
|
|
@@ -5172,6 +5259,15 @@ async function hostCommand(sub, values, storePath) {
|
|
|
5172
5259
|
if (!lock) fail("HOST_NOT_RUNNING", `No VibeFlow host is running for ${storePath}. Start it with \`vibeflow\` first.`);
|
|
5173
5260
|
const remote = connectToHost(lock);
|
|
5174
5261
|
try {
|
|
5262
|
+
if (sub === "start" && values["new-session"]) {
|
|
5263
|
+
try {
|
|
5264
|
+
const { task } = await remote.api.continueTask({ taskId: values.task, force: values.force === true });
|
|
5265
|
+
return { task: { id: task.id, title: task.title, worktreePath: task.worktreePath ?? null }, newSession: true };
|
|
5266
|
+
} catch (err) {
|
|
5267
|
+
const e = err;
|
|
5268
|
+
fail(e.code ?? "HOST_ERROR", e.message ?? String(err));
|
|
5269
|
+
}
|
|
5270
|
+
}
|
|
5175
5271
|
if (sub === "start") {
|
|
5176
5272
|
const { task } = await remote.api.startTask(values.task);
|
|
5177
5273
|
return { task: { id: task.id, title: task.title, worktreePath: task.worktreePath ?? null } };
|
|
@@ -5198,7 +5294,7 @@ async function hostCommand(sub, values, storePath) {
|
|
|
5198
5294
|
}
|
|
5199
5295
|
|
|
5200
5296
|
// packages/cli/src/host.ts
|
|
5201
|
-
import
|
|
5297
|
+
import fs27 from "fs";
|
|
5202
5298
|
import path28 from "path";
|
|
5203
5299
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
5204
5300
|
|
|
@@ -5737,7 +5833,7 @@ async function syncBuiltinsAtStartup() {
|
|
|
5737
5833
|
}
|
|
5738
5834
|
|
|
5739
5835
|
// packages/core/src/service.ts
|
|
5740
|
-
import
|
|
5836
|
+
import fs23 from "fs";
|
|
5741
5837
|
|
|
5742
5838
|
// packages/core/src/terminal-files.ts
|
|
5743
5839
|
import { constants } from "fs";
|
|
@@ -6636,7 +6732,7 @@ ${children(item).map((child) => render(child)).join("").trimEnd()}
|
|
|
6636
6732
|
if (type === "listItem") return body();
|
|
6637
6733
|
if (type === "table") {
|
|
6638
6734
|
const rows = children(item).map((row) => {
|
|
6639
|
-
const cells = children(record(row) ?? {}).map((
|
|
6735
|
+
const cells = children(record(row) ?? {}).map((cell2) => render(cell2).trim().replace(/\|/g, "\\|").replace(/\n+/g, " "));
|
|
6640
6736
|
return `| ${cells.join(" | ")} |`;
|
|
6641
6737
|
});
|
|
6642
6738
|
if (rows.length === 0) return "";
|
|
@@ -7754,25 +7850,151 @@ function createProgressTracker(opts) {
|
|
|
7754
7850
|
};
|
|
7755
7851
|
}
|
|
7756
7852
|
|
|
7757
|
-
// packages/core/src/
|
|
7853
|
+
// packages/core/src/continuation.ts
|
|
7758
7854
|
init_launch();
|
|
7855
|
+
init_progress();
|
|
7759
7856
|
import fs21 from "fs";
|
|
7857
|
+
var MAX_BRIEF_CHARS = 8e3;
|
|
7858
|
+
var MAX_REPLY_CHARS = 2e3;
|
|
7859
|
+
var MAX_DESCRIPTION_CHARS = 4e3;
|
|
7860
|
+
var TAIL_BYTES = 256 * 1024;
|
|
7861
|
+
var CUT = "\u2026\uFF08\u5DF2\u622A\u65B7\uFF09";
|
|
7862
|
+
var LIMITS = [
|
|
7863
|
+
{ reply: MAX_REPLY_CHARS, commits: 20, files: 30, todos: 40, cards: 30 },
|
|
7864
|
+
{ reply: 800, commits: 10, files: 15, todos: 25, cards: 20 },
|
|
7865
|
+
{ reply: 0, commits: 5, files: 8, todos: 15, cards: 10 },
|
|
7866
|
+
{ reply: 0, commits: 0, files: 0, todos: 8, cards: 5 }
|
|
7867
|
+
];
|
|
7868
|
+
function clipText(text, max) {
|
|
7869
|
+
return text.length <= max ? text : `${text.slice(0, Math.max(0, max - CUT.length)).trimEnd()}${CUT}`;
|
|
7870
|
+
}
|
|
7871
|
+
function more(total, shown) {
|
|
7872
|
+
return total > shown ? [` - \u2026\uFF08\u9084\u6709 ${total - shown} \u9805\u672A\u5217\u51FA\uFF09`] : [];
|
|
7873
|
+
}
|
|
7874
|
+
function gitSection(git2, limits) {
|
|
7875
|
+
const lines = ["", "## \u5206\u652F\u8207\u7A0B\u5F0F\u78BC", `- \u5206\u652F\uFF1A\`${git2.branch}\`${git2.baseBranch ? `\uFF0Cbase\uFF1A\`${git2.baseBranch}\`` : ""}`];
|
|
7876
|
+
lines.push(
|
|
7877
|
+
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"
|
|
7878
|
+
);
|
|
7879
|
+
if (git2.commits.length === 0) {
|
|
7880
|
+
lines.push("- \u9019\u500B\u5206\u652F\u9084\u6C92\u6709 commit");
|
|
7881
|
+
} else if (limits.commits > 0) {
|
|
7882
|
+
lines.push(`- \`base..HEAD\` \u7684 commit\uFF08\u65B0\u5230\u820A\uFF0C\u5171 ${git2.commits.length} \u7B46\uFF09\uFF1A`);
|
|
7883
|
+
for (const c of git2.commits.slice(0, limits.commits)) lines.push(` - \`${c.shortSha}\` ${c.subject}`);
|
|
7884
|
+
lines.push(...more(git2.commits.length, limits.commits));
|
|
7885
|
+
} else {
|
|
7886
|
+
lines.push(`- \`base..HEAD\` \u5171 ${git2.commits.length} \u7B46 commit\uFF08\u7528 git log \u67E5\u770B\uFF09`);
|
|
7887
|
+
}
|
|
7888
|
+
if (git2.uncommitted.length === 0) {
|
|
7889
|
+
lines.push("- \u6C92\u6709\u672A commit \u7684\u8B8A\u66F4");
|
|
7890
|
+
} else if (limits.files > 0) {
|
|
7891
|
+
lines.push(`- \u672A commit \u7684\u8B8A\u66F4\uFF08${git2.uncommitted.length} \u500B\u6A94\u6848\uFF09\uFF1A`);
|
|
7892
|
+
for (const f of git2.uncommitted.slice(0, limits.files)) lines.push(` - \`${f.status}\` ${f.path}`);
|
|
7893
|
+
lines.push(...more(git2.uncommitted.length, limits.files));
|
|
7894
|
+
} else {
|
|
7895
|
+
lines.push(`- \u6709 ${git2.uncommitted.length} \u500B\u6A94\u6848\u672A commit\uFF08\u7528 git status \u67E5\u770B\uFF09`);
|
|
7896
|
+
}
|
|
7897
|
+
return lines;
|
|
7898
|
+
}
|
|
7899
|
+
function prSection(pr) {
|
|
7900
|
+
return [
|
|
7901
|
+
"",
|
|
7902
|
+
"## PR",
|
|
7903
|
+
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"
|
|
7904
|
+
];
|
|
7905
|
+
}
|
|
7906
|
+
var TODO_MARK = { completed: "[x]", in_progress: "[~]", pending: "[ ]" };
|
|
7907
|
+
function todoSection(todos, limit) {
|
|
7908
|
+
const lines = ["", "## \u524D\u4E00\u500B session \u7684 todo"];
|
|
7909
|
+
for (const t of todos.slice(0, limit)) lines.push(`- ${TODO_MARK[t.status]} ${t.content}`);
|
|
7910
|
+
if (todos.length > limit) lines.push(`- \u2026\uFF08\u9084\u6709 ${todos.length - limit} \u9805\u672A\u5217\u51FA\uFF09`);
|
|
7911
|
+
return lines;
|
|
7912
|
+
}
|
|
7913
|
+
function replySection(reply, limit) {
|
|
7914
|
+
return ["", "## \u524D\u4E00\u500B session \u7684\u6700\u5F8C\u4E00\u5247\u56DE\u8986", ...clipText(reply, limit).split("\n").map((l) => `> ${l}`)];
|
|
7915
|
+
}
|
|
7916
|
+
var cell = (text) => text.replace(/\|/g, "\\|").replace(/\s+/g, " ");
|
|
7917
|
+
function cardSection(cards, limit) {
|
|
7918
|
+
const lines = ["", "## \u5E95\u4E0B\u7684\u5361\u7247", "| id | \u6A19\u984C | \u6B04\u4F4D | \u57F7\u884C\u4E2D | todo | PR |", "| --- | --- | --- | --- | --- | --- |"];
|
|
7919
|
+
for (const c of cards.slice(0, limit)) {
|
|
7920
|
+
const todos = c.todos ? `${c.todos.done}/${c.todos.total}` : "-";
|
|
7921
|
+
const pr = c.pr ? `#${c.pr.number} ${c.pr.state}` : "-";
|
|
7922
|
+
lines.push(`| ${c.id} | ${cell(c.title)} | ${c.column} | ${c.running ? "\u662F" : "\u5426"} | ${todos} | ${pr} |`);
|
|
7923
|
+
}
|
|
7924
|
+
if (cards.length > limit) lines.push(`\uFF08\u9084\u6709 ${cards.length - limit} \u5F35\u672A\u5217\u51FA\uFF0C\u7528 task list \u67E5\u770B\uFF09`);
|
|
7925
|
+
return lines;
|
|
7926
|
+
}
|
|
7927
|
+
function render2(head, facts, limits) {
|
|
7928
|
+
const lines = [
|
|
7929
|
+
head,
|
|
7930
|
+
"",
|
|
7931
|
+
"\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"
|
|
7932
|
+
];
|
|
7933
|
+
if (facts.git) lines.push(...gitSection(facts.git, limits));
|
|
7934
|
+
if (facts.pr !== void 0) lines.push(...prSection(facts.pr));
|
|
7935
|
+
if (facts.todos?.length) lines.push(...todoSection(facts.todos, limits.todos));
|
|
7936
|
+
if (facts.lastReply && limits.reply > 0) lines.push(...replySection(facts.lastReply, limits.reply));
|
|
7937
|
+
if (facts.cards) lines.push(...cardSection(facts.cards, limits.cards));
|
|
7938
|
+
lines.push(
|
|
7939
|
+
"",
|
|
7940
|
+
"## \u63A5\u7E8C\u6307\u793A",
|
|
7941
|
+
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"
|
|
7942
|
+
);
|
|
7943
|
+
return lines.join("\n");
|
|
7944
|
+
}
|
|
7945
|
+
function buildContinuationPrompt(facts) {
|
|
7946
|
+
const description = facts.description?.trim();
|
|
7947
|
+
const head = buildPrompt({
|
|
7948
|
+
title: facts.title,
|
|
7949
|
+
description: description ? clipText(description, MAX_DESCRIPTION_CHARS) : void 0
|
|
7950
|
+
});
|
|
7951
|
+
for (const limits of LIMITS) {
|
|
7952
|
+
const text = render2(head, facts, limits);
|
|
7953
|
+
if (text.length <= MAX_BRIEF_CHARS) return text;
|
|
7954
|
+
}
|
|
7955
|
+
return clipText(render2(head, facts, LIMITS[LIMITS.length - 1]), MAX_BRIEF_CHARS);
|
|
7956
|
+
}
|
|
7957
|
+
function readLastClaudeReply(file, maxChars) {
|
|
7958
|
+
let fd;
|
|
7959
|
+
try {
|
|
7960
|
+
fd = fs21.openSync(file, "r");
|
|
7961
|
+
const size = fs21.fstatSync(fd).size;
|
|
7962
|
+
const start = Math.max(0, size - TAIL_BYTES);
|
|
7963
|
+
const buf = Buffer.alloc(size - start);
|
|
7964
|
+
fs21.readSync(fd, buf, 0, buf.length, start);
|
|
7965
|
+
let text = buf.toString("utf8");
|
|
7966
|
+
if (start > 0) {
|
|
7967
|
+
const newline = text.indexOf("\n");
|
|
7968
|
+
text = newline === -1 ? "" : text.slice(newline + 1);
|
|
7969
|
+
}
|
|
7970
|
+
const reply = claudeLastReply(text.split("\n").filter((l) => l.trim()));
|
|
7971
|
+
return reply ? clipText(reply, maxChars) : void 0;
|
|
7972
|
+
} catch {
|
|
7973
|
+
return void 0;
|
|
7974
|
+
} finally {
|
|
7975
|
+
if (fd !== void 0) fs21.closeSync(fd);
|
|
7976
|
+
}
|
|
7977
|
+
}
|
|
7978
|
+
|
|
7979
|
+
// packages/core/src/inbox.ts
|
|
7980
|
+
init_launch();
|
|
7981
|
+
import fs22 from "fs";
|
|
7760
7982
|
import path23 from "path";
|
|
7761
7983
|
var seq = 0;
|
|
7762
7984
|
function inboxDir(worktreePath) {
|
|
7763
7985
|
return path23.join(worktreePath, INBOX_DIR);
|
|
7764
7986
|
}
|
|
7765
7987
|
function inboxReady(dir) {
|
|
7766
|
-
return
|
|
7988
|
+
return fs22.existsSync(path23.join(dir, INBOX_READY_FILE));
|
|
7767
7989
|
}
|
|
7768
7990
|
function prepareInbox(dir) {
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7991
|
+
fs22.mkdirSync(dir, { recursive: true });
|
|
7992
|
+
fs22.writeFileSync(path23.join(dir, ".gitignore"), "*\n");
|
|
7993
|
+
fs22.rmSync(path23.join(dir, INBOX_READY_FILE), { force: true });
|
|
7772
7994
|
}
|
|
7773
7995
|
function messageNames(dir) {
|
|
7774
7996
|
try {
|
|
7775
|
-
return
|
|
7997
|
+
return fs22.readdirSync(dir).filter((n) => !n.startsWith(".")).sort();
|
|
7776
7998
|
} catch {
|
|
7777
7999
|
return [];
|
|
7778
8000
|
}
|
|
@@ -7781,23 +8003,23 @@ function pendingMessages(dir) {
|
|
|
7781
8003
|
return messageNames(dir).length;
|
|
7782
8004
|
}
|
|
7783
8005
|
function postMessage(dir, text) {
|
|
7784
|
-
|
|
8006
|
+
fs22.mkdirSync(dir, { recursive: true });
|
|
7785
8007
|
const name = `${String(Date.now()).padStart(13, "0")}-${String(seq++ % 1e6).padStart(6, "0")}`;
|
|
7786
8008
|
const tmp = path23.join(dir, `.tmp-${name}`);
|
|
7787
|
-
|
|
7788
|
-
|
|
8009
|
+
fs22.writeFileSync(tmp, text);
|
|
8010
|
+
fs22.renameSync(tmp, path23.join(dir, name));
|
|
7789
8011
|
}
|
|
7790
8012
|
function takeMessages(dir) {
|
|
7791
8013
|
const texts = [];
|
|
7792
8014
|
for (const name of messageNames(dir)) {
|
|
7793
8015
|
const claimed = path23.join(dir, `.host-${name}`);
|
|
7794
8016
|
try {
|
|
7795
|
-
|
|
8017
|
+
fs22.renameSync(path23.join(dir, name), claimed);
|
|
7796
8018
|
} catch {
|
|
7797
8019
|
continue;
|
|
7798
8020
|
}
|
|
7799
|
-
texts.push(
|
|
7800
|
-
|
|
8021
|
+
texts.push(fs22.readFileSync(claimed, "utf8"));
|
|
8022
|
+
fs22.rmSync(claimed, { force: true });
|
|
7801
8023
|
}
|
|
7802
8024
|
return texts;
|
|
7803
8025
|
}
|
|
@@ -8073,6 +8295,8 @@ function obj(value, name) {
|
|
|
8073
8295
|
if (!value || typeof value !== "object" || Array.isArray(value)) invalid(`${name} must be an object`);
|
|
8074
8296
|
return value;
|
|
8075
8297
|
}
|
|
8298
|
+
var PR_LOOKUP_MS = 5e3;
|
|
8299
|
+
var lookUpPr = (worktreePath) => getPrStatus(worktreePath, PR_LOOKUP_MS);
|
|
8076
8300
|
var LIBRARY_KINDS2 = ["skill", "prompt", "script"];
|
|
8077
8301
|
var AGENT_IDS2 = ["claude", "codex"];
|
|
8078
8302
|
var COLUMNS = ["backlog", "in_progress", "done"];
|
|
@@ -8110,7 +8334,7 @@ function validBoard(value) {
|
|
|
8110
8334
|
}
|
|
8111
8335
|
return next;
|
|
8112
8336
|
}
|
|
8113
|
-
function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatus, acliRunner, jiraAuthStatus, modelCatalog, jevRouter }) {
|
|
8337
|
+
function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatus, acliRunner, jiraAuthStatus, modelCatalog, jevRouter, titleTranslator, prStatus = lookUpPr }) {
|
|
8114
8338
|
const sink = bus.sink();
|
|
8115
8339
|
const models = modelCatalog ?? createModelCatalog({ version });
|
|
8116
8340
|
const router = jevRouter ?? createJevRouter({ getApiKey: readJevApiKey });
|
|
@@ -8175,7 +8399,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8175
8399
|
}
|
|
8176
8400
|
});
|
|
8177
8401
|
function gitWorktree(task) {
|
|
8178
|
-
return isMasterTask(task) ? void 0 : task.worktreePath;
|
|
8402
|
+
return isMasterTask(task) || task.inPlace ? void 0 : task.worktreePath;
|
|
8179
8403
|
}
|
|
8180
8404
|
function progressTarget(task) {
|
|
8181
8405
|
if (!task.worktreePath) return null;
|
|
@@ -8202,6 +8426,99 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8202
8426
|
if (!wasTracking) progress.untrack(task.id);
|
|
8203
8427
|
return snapshot?.totalUsage ?? task.usage;
|
|
8204
8428
|
}
|
|
8429
|
+
const continuing = /* @__PURE__ */ new Set();
|
|
8430
|
+
function executorTranscript(task) {
|
|
8431
|
+
if (!task.worktreePath) return void 0;
|
|
8432
|
+
const file = `${executorSessionId(task.id, task.runId)}.jsonl`;
|
|
8433
|
+
let resolved = task.worktreePath;
|
|
8434
|
+
try {
|
|
8435
|
+
resolved = fs23.realpathSync(task.worktreePath);
|
|
8436
|
+
} catch {
|
|
8437
|
+
}
|
|
8438
|
+
for (const cwd of /* @__PURE__ */ new Set([task.worktreePath, resolved])) {
|
|
8439
|
+
const candidate = path24.join(claudeProjectDir(home, cwd), file);
|
|
8440
|
+
if (fs23.existsSync(candidate)) return candidate;
|
|
8441
|
+
}
|
|
8442
|
+
return void 0;
|
|
8443
|
+
}
|
|
8444
|
+
async function continuationFacts(task) {
|
|
8445
|
+
trackProgress(task);
|
|
8446
|
+
const todos = progress.snapshot(task.id)?.todos;
|
|
8447
|
+
const transcript = taskAgent(task) === "claude" ? executorTranscript(task) : void 0;
|
|
8448
|
+
const lastReply = transcript ? readLastClaudeReply(transcript, MAX_REPLY_CHARS) : void 0;
|
|
8449
|
+
const facts = {
|
|
8450
|
+
title: task.title,
|
|
8451
|
+
description: task.description,
|
|
8452
|
+
...todos?.length ? { todos } : {},
|
|
8453
|
+
...lastReply ? { lastReply } : {}
|
|
8454
|
+
};
|
|
8455
|
+
if (isMasterTask(task)) {
|
|
8456
|
+
facts.cards = (await summarizeTasks({ masterId: task.id })).map((c) => ({
|
|
8457
|
+
id: c.id,
|
|
8458
|
+
title: c.title,
|
|
8459
|
+
column: c.column,
|
|
8460
|
+
running: c.running,
|
|
8461
|
+
...c.todos ? { todos: { done: c.todos.done, total: c.todos.total } } : {},
|
|
8462
|
+
...c.pr ? { pr: { number: c.pr.number, state: c.pr.state } } : {}
|
|
8463
|
+
}));
|
|
8464
|
+
return facts;
|
|
8465
|
+
}
|
|
8466
|
+
const worktree = gitWorktree(task);
|
|
8467
|
+
if (!worktree) return facts;
|
|
8468
|
+
const [commits, uncommitted, unpushed, pr] = await Promise.all([
|
|
8469
|
+
getBranchCommits(worktree, task.baseBranch ?? "main").catch(() => null),
|
|
8470
|
+
collectWorkingEntries(worktree).catch(() => null),
|
|
8471
|
+
git(worktree, ["rev-list", "--count", "@{u}..HEAD"]).then((n) => Number.parseInt(n, 10) || 0, () => null),
|
|
8472
|
+
prStatus(worktree).catch(() => null)
|
|
8473
|
+
]);
|
|
8474
|
+
if (commits || uncommitted) {
|
|
8475
|
+
facts.git = {
|
|
8476
|
+
branch: task.branch,
|
|
8477
|
+
...task.baseBranch ? { baseBranch: task.baseBranch } : {},
|
|
8478
|
+
commits: (commits?.commits ?? []).map((c) => ({ shortSha: c.shortSha, subject: c.subject })),
|
|
8479
|
+
uncommitted: (uncommitted ?? []).map((e) => ({ path: e.path, status: e.status })),
|
|
8480
|
+
unpushed
|
|
8481
|
+
};
|
|
8482
|
+
}
|
|
8483
|
+
facts.pr = pr;
|
|
8484
|
+
return facts;
|
|
8485
|
+
}
|
|
8486
|
+
async function continueTask(taskId, force) {
|
|
8487
|
+
const task = requireTask(taskId);
|
|
8488
|
+
if (continuing.has(task.id)) throw coded2("ALREADY_CONTINUING", "\u9019\u5F35\u5361\u6B63\u5728\u63DB\u65B0 session");
|
|
8489
|
+
const column = columnOf(task.id);
|
|
8490
|
+
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`);
|
|
8491
|
+
if (!task.launchedAt) throw coded2("NOT_LAUNCHED", "\u9019\u5F35\u5361\u9084\u6C92\u6709\u57F7\u884C\u904E\uFF0C\u8ACB\u76F4\u63A5\u555F\u52D5");
|
|
8492
|
+
if (!task.worktreePath) throw coded2("NO_WORKTREE", "\u9019\u5F35\u5361\u6C92\u6709 worktree");
|
|
8493
|
+
continuing.add(task.id);
|
|
8494
|
+
try {
|
|
8495
|
+
if (!force && await sessions.isAlive(task.id)) {
|
|
8496
|
+
trackProgress(task);
|
|
8497
|
+
const activity = agentActivity(task.id);
|
|
8498
|
+
if (activity?.state === "working" || isBlocked(activity)) {
|
|
8499
|
+
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");
|
|
8500
|
+
}
|
|
8501
|
+
}
|
|
8502
|
+
const brief = buildContinuationPrompt(await continuationFacts(task));
|
|
8503
|
+
const usage = usageThroughCurrentRun(task);
|
|
8504
|
+
updateTask(task.id, { runId: randomUUID5(), launchedAt: Date.now(), ...usage ? { usage } : {} });
|
|
8505
|
+
resetSubAgents(task.worktreePath);
|
|
8506
|
+
bus.emit("subagents:update", { taskId: task.id, subAgents: [] });
|
|
8507
|
+
const next = requireTask(task.id);
|
|
8508
|
+
try {
|
|
8509
|
+
await startTaskSession(next, next.id, { taskId: next.id, launch: {} }, brief);
|
|
8510
|
+
} catch (err) {
|
|
8511
|
+
updateTask(task.id, { runId: task.runId, launchedAt: task.launchedAt, usage: task.usage });
|
|
8512
|
+
trackProgress(findTask(task.id) ?? task);
|
|
8513
|
+
bus.emit("state:changed", getState());
|
|
8514
|
+
throw err;
|
|
8515
|
+
}
|
|
8516
|
+
bus.emit("state:changed", getState());
|
|
8517
|
+
return { state: getState(), task: findTask(task.id) ?? next };
|
|
8518
|
+
} finally {
|
|
8519
|
+
continuing.delete(task.id);
|
|
8520
|
+
}
|
|
8521
|
+
}
|
|
8205
8522
|
try {
|
|
8206
8523
|
for (const task of getState().board.in_progress) trackProgress(task);
|
|
8207
8524
|
} catch {
|
|
@@ -8263,12 +8580,12 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8263
8580
|
function settledRoute(task) {
|
|
8264
8581
|
return task.jevRoute?.status === "routing" ? void 0 : task.jevRoute;
|
|
8265
8582
|
}
|
|
8266
|
-
async function launchCommand(task, intent) {
|
|
8583
|
+
async function launchCommand(task, intent, continuation) {
|
|
8267
8584
|
const settings = getSettings();
|
|
8268
8585
|
const library = await libraryLaunchInfo(task.worktreePath);
|
|
8269
8586
|
const boardCli = await boardCliLaunchInfo();
|
|
8270
8587
|
let route = settledRoute(task);
|
|
8271
|
-
const needsRoute = !taskModel(task) || task.effort === "auto";
|
|
8588
|
+
const needsRoute = !continuation && (!taskModel(task) || task.effort === "auto");
|
|
8272
8589
|
if (needsRoute && !intent.resume && intent.includeTaskPrompt !== false) {
|
|
8273
8590
|
let pending = routing.get(task.id);
|
|
8274
8591
|
if (!pending) {
|
|
@@ -8305,7 +8622,8 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8305
8622
|
library: library ?? void 0,
|
|
8306
8623
|
boardCli,
|
|
8307
8624
|
autoMode: task.autoMode ?? settings.autoMode,
|
|
8308
|
-
preface
|
|
8625
|
+
preface,
|
|
8626
|
+
continuation
|
|
8309
8627
|
},
|
|
8310
8628
|
task.workspacePath
|
|
8311
8629
|
);
|
|
@@ -8315,11 +8633,10 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8315
8633
|
return path24.join(os9.homedir(), ".claude", "projects", munged, `${sessionId}.jsonl`);
|
|
8316
8634
|
}
|
|
8317
8635
|
async function removeTaskWorktree(task) {
|
|
8318
|
-
if (!task.projectPath || !task.worktreePath) return;
|
|
8319
|
-
const branch = task.branch || fallbackBranchName(task.id);
|
|
8636
|
+
if (!task.projectPath || !task.worktreePath || task.inPlace) return;
|
|
8320
8637
|
await removeWorktree(task.projectPath, task.worktreePath);
|
|
8321
8638
|
deleteArtifacts(task.workspacePath ?? path24.dirname(task.worktreePath), task.worktreePath);
|
|
8322
|
-
await deleteBranch(task.projectPath, branch);
|
|
8639
|
+
if (!task.noBranch) await deleteBranch(task.projectPath, task.branch || fallbackBranchName(task.id));
|
|
8323
8640
|
}
|
|
8324
8641
|
function columnOf(taskId) {
|
|
8325
8642
|
const board = getState().board;
|
|
@@ -8372,7 +8689,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8372
8689
|
authStatus: jiraAuthStatus ?? (() => getJiraAuthStatus(acliRunner)),
|
|
8373
8690
|
pointFields: () => getSettings().jira?.storyPointsFields?.length ? getSettings().jira.storyPointsFields : DEFAULT_POINT_FIELDS
|
|
8374
8691
|
});
|
|
8375
|
-
async function startTaskSession(requested, key, p) {
|
|
8692
|
+
async function startTaskSession(requested, key, p, continuation) {
|
|
8376
8693
|
const pending = provisioning.get(requested.id);
|
|
8377
8694
|
const task = p.launch ? await ensureProvisioned(requested) : pending ? await pending : requested;
|
|
8378
8695
|
const cwd = task.worktreePath;
|
|
@@ -8384,7 +8701,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8384
8701
|
if (intent.resume && await sessions.isAlive(key)) {
|
|
8385
8702
|
fresh = false;
|
|
8386
8703
|
} else {
|
|
8387
|
-
command = (await launchCommand(task, intent)).replace(/\r$/, "");
|
|
8704
|
+
command = (await launchCommand(task, intent, continuation)).replace(/\r$/, "");
|
|
8388
8705
|
if (key === task.id) prepareInbox(inboxDir(cwd));
|
|
8389
8706
|
}
|
|
8390
8707
|
}
|
|
@@ -8564,7 +8881,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8564
8881
|
// `vibeflow open <path>` while a host runs: only the host writes the store.
|
|
8565
8882
|
"projects:record": (projectPath) => {
|
|
8566
8883
|
const p = path24.resolve(str(projectPath, "projectPath"));
|
|
8567
|
-
if (!
|
|
8884
|
+
if (!fs23.existsSync(p) || !fs23.statSync(p).isDirectory()) invalid(`not a directory: ${p}`);
|
|
8568
8885
|
recordRecentProject(getStore(), p);
|
|
8569
8886
|
return listRecentProjects(getStore());
|
|
8570
8887
|
},
|
|
@@ -8582,6 +8899,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8582
8899
|
if (p.agentCli !== void 0 && !AGENT_IDS2.includes(p.agentCli)) invalid("unknown agent");
|
|
8583
8900
|
if (p.github !== void 0 && !isGithubRef(p.github)) invalid("github must be an issue or pr ref on github.com");
|
|
8584
8901
|
if (p.jira !== void 0 && !isJiraRef(p.jira)) invalid("jira must be a Jira ticket ref");
|
|
8902
|
+
if (p.createBranch !== void 0 && typeof p.createBranch !== "boolean") invalid("createBranch must be a boolean");
|
|
8585
8903
|
const { task } = await createTaskFromInput({
|
|
8586
8904
|
projectPath: p.projectPath,
|
|
8587
8905
|
role: p.role,
|
|
@@ -8592,6 +8910,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8592
8910
|
baseBranch: p.baseBranch,
|
|
8593
8911
|
branch: p.branch,
|
|
8594
8912
|
mode: p.mode,
|
|
8913
|
+
createBranch: p.createBranch,
|
|
8595
8914
|
agentCli: p.agentCli,
|
|
8596
8915
|
model: p.model,
|
|
8597
8916
|
effort: p.effort,
|
|
@@ -8599,7 +8918,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8599
8918
|
attachments: p.attachments,
|
|
8600
8919
|
github: p.github,
|
|
8601
8920
|
jira: p.jira
|
|
8602
|
-
});
|
|
8921
|
+
}, { translateTitle: titleTranslator });
|
|
8603
8922
|
return { state: getState(), task };
|
|
8604
8923
|
},
|
|
8605
8924
|
"vibeflow:removeTask": (taskId) => {
|
|
@@ -8614,7 +8933,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8614
8933
|
// were new. Launching again is the caller's decision.
|
|
8615
8934
|
"vibeflow:resetTaskRun": async (taskId) => {
|
|
8616
8935
|
const task = requireTask(taskId);
|
|
8617
|
-
if (isMasterTask(task) && task.worktreePath) {
|
|
8936
|
+
if ((isMasterTask(task) || task.inPlace) && task.worktreePath) {
|
|
8618
8937
|
await teardownTask(task.id);
|
|
8619
8938
|
if (task.workspacePath) deleteArtifacts(task.workspacePath, task.worktreePath);
|
|
8620
8939
|
resetSubAgents(task.worktreePath);
|
|
@@ -8672,12 +8991,12 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8672
8991
|
}
|
|
8673
8992
|
let gitPatch = {};
|
|
8674
8993
|
const nextProject = isMasterTask(existing) ? void 0 : p.projectPath || existing.projectPath;
|
|
8675
|
-
const nextBranch = p.branch === void 0 ? "" : str(p.branch, "branch").trim();
|
|
8994
|
+
const nextBranch = p.branch === void 0 || existing.noBranch ? "" : str(p.branch, "branch").trim();
|
|
8676
8995
|
const projectChanged2 = Boolean(p.projectPath && p.projectPath !== existing.projectPath);
|
|
8677
8996
|
const baseChanged = p.baseBranch != null && p.baseBranch !== (existing.baseBranch ?? null);
|
|
8678
8997
|
const branchChanged = Boolean(nextBranch && nextBranch !== existing.branch);
|
|
8679
8998
|
if (nextProject && (projectChanged2 || baseChanged || branchChanged)) {
|
|
8680
|
-
if (existing.worktreePath) {
|
|
8999
|
+
if (existing.worktreePath && !existing.inPlace) {
|
|
8681
9000
|
const diff = await getWorktreeDiffEntries(
|
|
8682
9001
|
existing.worktreePath,
|
|
8683
9002
|
existing.baseBranch ?? "HEAD",
|
|
@@ -8688,7 +9007,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8688
9007
|
}
|
|
8689
9008
|
}
|
|
8690
9009
|
const info = await getGitInfo(nextProject);
|
|
8691
|
-
if (!info.isRepo) throw new Error("\u76EE\u6A19\u8CC7\u6599\u593E\u4E0D\u662F git repository");
|
|
9010
|
+
if (!info.isRepo && !existing.noBranch) throw new Error("\u76EE\u6A19\u8CC7\u6599\u593E\u4E0D\u662F git repository");
|
|
8692
9011
|
const projectName = path24.basename(nextProject);
|
|
8693
9012
|
const workspacePath = projectWorkstationPath(resolveWorkstationPath(getSettings()), projectName);
|
|
8694
9013
|
await teardownTask(existing.id);
|
|
@@ -8699,7 +9018,8 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8699
9018
|
projectPath: nextProject,
|
|
8700
9019
|
projectName,
|
|
8701
9020
|
workspacePath,
|
|
8702
|
-
baseBranch: (p.baseBranch ?? (projectChanged2 ? null : existing.baseBranch)) || info.defaultBase || info.currentBranch || void 0,
|
|
9021
|
+
baseBranch: info.isRepo ? (p.baseBranch ?? (projectChanged2 ? null : existing.baseBranch)) || info.defaultBase || info.currentBranch || void 0 : void 0,
|
|
9022
|
+
inPlace: existing.noBranch && !info.isRepo ? true : void 0,
|
|
8703
9023
|
...branchChanged ? { branch: nextBranch, branchExplicit: true } : {},
|
|
8704
9024
|
worktreePath: void 0,
|
|
8705
9025
|
pushed: void 0,
|
|
@@ -8748,6 +9068,14 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8748
9068
|
await startTaskSession(started, task.id, { taskId: task.id, launch: {} });
|
|
8749
9069
|
return { state: getState(), task: findTask(task.id) ?? started };
|
|
8750
9070
|
},
|
|
9071
|
+
// A running card carries on in a new agent session: same worktree and branch,
|
|
9072
|
+
// nothing discarded, first message built by core from the card's own facts.
|
|
9073
|
+
// Only an id and `force` come from the client — never the brief's text.
|
|
9074
|
+
"vibeflow:continueTask": async (payload) => {
|
|
9075
|
+
const p = obj(payload, "payload");
|
|
9076
|
+
if (p.force !== void 0 && typeof p.force !== "boolean") invalid("force must be a boolean");
|
|
9077
|
+
return continueTask(str(p.taskId, "taskId"), p.force === true);
|
|
9078
|
+
},
|
|
8751
9079
|
// Every card on the board, or one master's cards, as the CLI and a master's
|
|
8752
9080
|
// agent read them.
|
|
8753
9081
|
"task:summaries": (payload) => {
|
|
@@ -8801,7 +9129,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8801
9129
|
} else {
|
|
8802
9130
|
cwd = os9.homedir();
|
|
8803
9131
|
}
|
|
8804
|
-
if (!path24.isAbsolute(cwd) || !
|
|
9132
|
+
if (!path24.isAbsolute(cwd) || !fs23.existsSync(cwd) || !fs23.statSync(cwd).isDirectory()) {
|
|
8805
9133
|
invalid("terminal directory must be an existing absolute directory");
|
|
8806
9134
|
}
|
|
8807
9135
|
const title = (typeof p.title === "string" ? p.title.trim() : "") || saved?.title || (projectPath ? path24.basename(projectPath) : "~");
|
|
@@ -8879,7 +9207,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8879
9207
|
"claude:sessionExists": (taskId) => {
|
|
8880
9208
|
const task = requireTask(taskId);
|
|
8881
9209
|
if (!task.worktreePath) return false;
|
|
8882
|
-
return
|
|
9210
|
+
return fs23.existsSync(claudeSessionFile(task.worktreePath, executorSessionId(task.id, task.runId)));
|
|
8883
9211
|
},
|
|
8884
9212
|
"sessions:list": async () => {
|
|
8885
9213
|
const keys = await sessions.list();
|
|
@@ -8968,7 +9296,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8968
9296
|
const task = requireTask(taskId);
|
|
8969
9297
|
if (!task.worktreePath || !task.workspacePath) return "task has no worktree";
|
|
8970
9298
|
const dir = agentArtifactsPath(task.workspacePath, task.worktreePath);
|
|
8971
|
-
if (!
|
|
9299
|
+
if (!fs23.existsSync(dir)) return "artifacts directory does not exist yet";
|
|
8972
9300
|
return getPlatform().openPath(dir);
|
|
8973
9301
|
},
|
|
8974
9302
|
"board:getCliLaunchInfo": () => boardCliLaunchInfo(),
|
|
@@ -9078,7 +9406,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
9078
9406
|
progress.untrack(task.id);
|
|
9079
9407
|
if (task.projectPath && task.worktreePath) {
|
|
9080
9408
|
await removeTaskWorktree(task);
|
|
9081
|
-
await syncBaseBranch(task.projectPath, task.baseBranch ?? "main");
|
|
9409
|
+
if (!task.inPlace) await syncBaseBranch(task.projectPath, task.baseBranch ?? "main");
|
|
9082
9410
|
}
|
|
9083
9411
|
updateTask(task.id, {
|
|
9084
9412
|
worktreePath: void 0,
|
|
@@ -9099,10 +9427,10 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
9099
9427
|
}
|
|
9100
9428
|
await removeTaskWorktree(task);
|
|
9101
9429
|
if (task.workspacePath) {
|
|
9102
|
-
|
|
9430
|
+
fs23.rmSync(taskAttachmentStagingPath(task.workspacePath, task.id), { recursive: true, force: true });
|
|
9103
9431
|
}
|
|
9104
9432
|
if (isMasterTask(task) && task.workspacePath) {
|
|
9105
|
-
|
|
9433
|
+
fs23.rmSync(task.workspacePath, { recursive: true, force: true });
|
|
9106
9434
|
}
|
|
9107
9435
|
clearConversation(task.id);
|
|
9108
9436
|
removeTask(task.id);
|
|
@@ -9157,7 +9485,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
9157
9485
|
watchStore() {
|
|
9158
9486
|
const file = path24.basename(getStorePath());
|
|
9159
9487
|
let debounce = null;
|
|
9160
|
-
storeWatcher =
|
|
9488
|
+
storeWatcher = fs23.watch(path24.dirname(getStorePath()), (_event, filename) => {
|
|
9161
9489
|
if (filename !== file) return;
|
|
9162
9490
|
if (debounce) clearTimeout(debounce);
|
|
9163
9491
|
debounce = setTimeout(() => {
|
|
@@ -9194,7 +9522,7 @@ function createSessionBackend(sink, choice) {
|
|
|
9194
9522
|
}
|
|
9195
9523
|
|
|
9196
9524
|
// packages/core/src/web-server.ts
|
|
9197
|
-
import
|
|
9525
|
+
import fs24 from "fs";
|
|
9198
9526
|
import http from "http";
|
|
9199
9527
|
import path25 from "path";
|
|
9200
9528
|
import { timingSafeEqual } from "crypto";
|
|
@@ -9258,7 +9586,7 @@ function resolveStatic(root, urlPath) {
|
|
|
9258
9586
|
const full = path25.resolve(base2, c);
|
|
9259
9587
|
if (full !== base2 && !full.startsWith(base2 + path25.sep)) return null;
|
|
9260
9588
|
try {
|
|
9261
|
-
if (
|
|
9589
|
+
if (fs24.statSync(full).isFile()) return full;
|
|
9262
9590
|
} catch {
|
|
9263
9591
|
}
|
|
9264
9592
|
}
|
|
@@ -9332,7 +9660,7 @@ async function startWebServer(options) {
|
|
|
9332
9660
|
res.end();
|
|
9333
9661
|
return;
|
|
9334
9662
|
}
|
|
9335
|
-
|
|
9663
|
+
fs24.createReadStream(file).pipe(res);
|
|
9336
9664
|
}
|
|
9337
9665
|
const wss = new WebSocketServer({ noServer: true, maxPayload: MAX_PAYLOAD });
|
|
9338
9666
|
function reject(socket, status, reason) {
|
|
@@ -9431,7 +9759,7 @@ Content-Length: 0\r
|
|
|
9431
9759
|
}
|
|
9432
9760
|
|
|
9433
9761
|
// packages/cli/src/update-command.ts
|
|
9434
|
-
import
|
|
9762
|
+
import fs25 from "node:fs";
|
|
9435
9763
|
import path26 from "node:path";
|
|
9436
9764
|
import { spawnSync } from "node:child_process";
|
|
9437
9765
|
function npmRunner(args, inherit) {
|
|
@@ -9444,7 +9772,7 @@ function npmRunner(args, inherit) {
|
|
|
9444
9772
|
}
|
|
9445
9773
|
function packageName(packageRoot) {
|
|
9446
9774
|
try {
|
|
9447
|
-
const pkg = JSON.parse(
|
|
9775
|
+
const pkg = JSON.parse(fs25.readFileSync(path26.join(packageRoot, "package.json"), "utf8"));
|
|
9448
9776
|
if (typeof pkg.name !== "string") return null;
|
|
9449
9777
|
return /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/i.test(pkg.name) ? pkg.name : null;
|
|
9450
9778
|
} catch {
|
|
@@ -9472,7 +9800,7 @@ function runUpdate(options) {
|
|
|
9472
9800
|
}
|
|
9473
9801
|
try {
|
|
9474
9802
|
const globalPackage = path26.join(String(root.stdout).trim(), ...name.split("/"));
|
|
9475
|
-
if (
|
|
9803
|
+
if (fs25.lstatSync(globalPackage).isSymbolicLink() || fs25.realpathSync(globalPackage) !== fs25.realpathSync(packageRoot)) {
|
|
9476
9804
|
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");
|
|
9477
9805
|
return 1;
|
|
9478
9806
|
}
|
|
@@ -9617,7 +9945,7 @@ async function openUpdateTerminal(platform = process.platform, run3 = launch) {
|
|
|
9617
9945
|
}
|
|
9618
9946
|
|
|
9619
9947
|
// packages/cli/src/self-update.ts
|
|
9620
|
-
import
|
|
9948
|
+
import fs26 from "node:fs";
|
|
9621
9949
|
import path27 from "node:path";
|
|
9622
9950
|
import { execFile as execFile10 } from "node:child_process";
|
|
9623
9951
|
import { promisify as promisify7 } from "node:util";
|
|
@@ -9627,7 +9955,7 @@ var PROBE_RETRY_MS = 3e4;
|
|
|
9627
9955
|
var HOST_TOKEN_ENV = "VIBEFLOW_HOST_TOKEN";
|
|
9628
9956
|
function readInstalledVersion(packageRoot) {
|
|
9629
9957
|
try {
|
|
9630
|
-
const pkg = JSON.parse(
|
|
9958
|
+
const pkg = JSON.parse(fs26.readFileSync(path27.join(packageRoot, "package.json"), "utf8"));
|
|
9631
9959
|
return typeof pkg.version === "string" ? pkg.version : null;
|
|
9632
9960
|
} catch {
|
|
9633
9961
|
return null;
|
|
@@ -9720,7 +10048,7 @@ async function startHost(options) {
|
|
|
9720
10048
|
prefer: options.backend,
|
|
9721
10049
|
stateDir: options.userDataDir
|
|
9722
10050
|
});
|
|
9723
|
-
const core = createCore({ sessions, bus, version: options.version });
|
|
10051
|
+
const core = createCore({ sessions, bus, version: options.version, titleTranslator: claudeTitleTranslator });
|
|
9724
10052
|
let updateTimer = null;
|
|
9725
10053
|
let installTimer = null;
|
|
9726
10054
|
const packageRoot = options.cliEntry ? path28.dirname(path28.dirname(options.cliEntry)) : null;
|
|
@@ -9811,11 +10139,11 @@ function loginUrl(lock, pathname = "/home/") {
|
|
|
9811
10139
|
return `http://127.0.0.1:${lock.port}${pathname}?token=${encodeURIComponent(lock.token)}`;
|
|
9812
10140
|
}
|
|
9813
10141
|
function isWebDir(dir) {
|
|
9814
|
-
return
|
|
10142
|
+
return fs27.existsSync(path28.join(dir, "home", "index.html"));
|
|
9815
10143
|
}
|
|
9816
10144
|
|
|
9817
10145
|
// packages/cli/src/doctor.ts
|
|
9818
|
-
import
|
|
10146
|
+
import fs28 from "fs";
|
|
9819
10147
|
import path29 from "path";
|
|
9820
10148
|
import { execFile as execFile11 } from "child_process";
|
|
9821
10149
|
import { promisify as promisify8 } from "util";
|
|
@@ -9956,10 +10284,10 @@ async function runDoctor(options) {
|
|
|
9956
10284
|
});
|
|
9957
10285
|
}
|
|
9958
10286
|
try {
|
|
9959
|
-
|
|
10287
|
+
fs28.mkdirSync(options.userDataDir, { recursive: true });
|
|
9960
10288
|
const probe = path29.join(options.userDataDir, `.doctor-${process.pid}`);
|
|
9961
|
-
|
|
9962
|
-
|
|
10289
|
+
fs28.writeFileSync(probe, "");
|
|
10290
|
+
fs28.rmSync(probe);
|
|
9963
10291
|
checks.push({ id: "data", name: "\u8CC7\u6599\u76EE\u9304", level: "ok", detail: options.userDataDir });
|
|
9964
10292
|
} catch (err) {
|
|
9965
10293
|
checks.push({
|
|
@@ -10031,7 +10359,7 @@ function detectLayout() {
|
|
|
10031
10359
|
}
|
|
10032
10360
|
function readVersion(pkgPath) {
|
|
10033
10361
|
try {
|
|
10034
|
-
return JSON.parse(
|
|
10362
|
+
return JSON.parse(fs30.readFileSync(pkgPath, "utf8")).version;
|
|
10035
10363
|
} catch {
|
|
10036
10364
|
return "0.0.0";
|
|
10037
10365
|
}
|
|
@@ -10270,7 +10598,7 @@ async function cmdOpen(values, target, layout, userDataDir) {
|
|
|
10270
10598
|
return 1;
|
|
10271
10599
|
}
|
|
10272
10600
|
const dir = path32.resolve(target);
|
|
10273
|
-
if (!
|
|
10601
|
+
if (!fs30.existsSync(dir) || !fs30.statSync(dir).isDirectory()) {
|
|
10274
10602
|
console.error(`\u4E0D\u662F\u8CC7\u6599\u593E\uFF1A${dir}`);
|
|
10275
10603
|
return 1;
|
|
10276
10604
|
}
|