@kw-yeh/vibeflow 4.11.57 → 4.11.60
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/README.md +2 -2
- package/dist/vibeflow.mjs +548 -214
- package/dist/web/404/index.html +1 -1
- package/dist/web/404.html +1 -1
- package/dist/web/_next/static/{E9TScKrKuQo0KJ8w6MXO4 → DDcUTYxPTa0eFKJZ3xGl4}/_buildManifest.js +1 -1
- package/dist/web/_next/static/chunks/{8175-5d01c7c50275534e.js → 2362-46f5f7e798186269.js} +2 -2
- package/dist/web/_next/static/chunks/pages/_app-afd9eb2814f60818.js +1 -0
- package/dist/web/_next/static/chunks/pages/home-1b4098f1ae4f1d9b.js +13 -0
- package/dist/web/_next/static/css/{b72127b4ac8224ee.css → 775ca0d5cedbe9ea.css} +1 -1
- package/dist/web/home/index.html +1 -1
- package/package.json +1 -1
- package/dist/web/_next/static/chunks/pages/_app-ba514e8a4a55baf5.js +0 -1
- package/dist/web/_next/static/chunks/pages/home-e16012828aaa8389.js +0 -13
- /package/dist/web/_next/static/{E9TScKrKuQo0KJ8w6MXO4 → DDcUTYxPTa0eFKJZ3xGl4}/_ssgManifest.js +0 -0
package/dist/vibeflow.mjs
CHANGED
|
@@ -525,6 +525,12 @@ var init_tmux_backend = __esm({
|
|
|
525
525
|
isAttached(key) {
|
|
526
526
|
return this.clients.has(key);
|
|
527
527
|
}
|
|
528
|
+
async hasForeignClients(key) {
|
|
529
|
+
const { code: code2, stdout } = await this.tmux("list-clients", "-t", `=${this.sessionName(key)}`, "-F", "#{client_pid}");
|
|
530
|
+
if (code2 !== 0) return false;
|
|
531
|
+
const own = this.clients.get(key)?.proc.pid;
|
|
532
|
+
return stdout.split("\n").some((line) => line.trim() && Number(line) !== own);
|
|
533
|
+
}
|
|
528
534
|
resize(key, cols, rows) {
|
|
529
535
|
try {
|
|
530
536
|
this.clients.get(key)?.proc.resize(Math.max(cols, 1), Math.max(rows, 1));
|
|
@@ -597,6 +603,10 @@ function claudeResumeOrFresh(sessionId, worktreePath, tail) {
|
|
|
597
603
|
const sessionFile = `"$HOME/.claude/projects/${munged}/${sessionId}.jsonl"`;
|
|
598
604
|
return `if [ -f ${sessionFile} ]; then claude --resume ${sessionId} ${tail}; else claude --session-id ${sessionId} ${tail}; fi\r`;
|
|
599
605
|
}
|
|
606
|
+
function inboxHookCommand(inboxDir2, event) {
|
|
607
|
+
const dir = toShellPath(inboxDir2);
|
|
608
|
+
return `if ls "${dir}" 2>/dev/null | grep -q .; then node -e '${INBOX_READER}' "${dir}" ${event}; fi; exit 0`;
|
|
609
|
+
}
|
|
600
610
|
function buildClaudeSettings(worktreePath) {
|
|
601
611
|
const settings = {
|
|
602
612
|
theme: "dark",
|
|
@@ -613,12 +623,19 @@ function buildClaudeSettings(worktreePath) {
|
|
|
613
623
|
const progress = {
|
|
614
624
|
hooks: [{ type: "command", command: `mkdir -p "${eventsDir}" && cat > "${eventsDir}/$(date +%s)-$$-$RANDOM.json"; exit 0` }]
|
|
615
625
|
};
|
|
626
|
+
const inboxDir2 = `${toShellPath(worktreePath)}/${INBOX_DIR}`;
|
|
627
|
+
const inbox = (event) => ({
|
|
628
|
+
hooks: [{ type: "command", command: inboxHookCommand(inboxDir2, event) }]
|
|
629
|
+
});
|
|
616
630
|
settings.hooks = {
|
|
617
631
|
PreToolUse: [taskHook],
|
|
618
|
-
PostToolUse: [taskHook, { matcher: TODO_TOOLS, ...progress }],
|
|
619
|
-
Stop: [progress],
|
|
632
|
+
PostToolUse: [taskHook, { matcher: TODO_TOOLS, ...progress }, inbox("PostToolUse")],
|
|
633
|
+
Stop: [progress, inbox("Stop")],
|
|
620
634
|
Notification: [progress],
|
|
621
|
-
UserPromptSubmit: [progress]
|
|
635
|
+
UserPromptSubmit: [progress, inbox("UserPromptSubmit")],
|
|
636
|
+
SessionStart: [{
|
|
637
|
+
hooks: [{ type: "command", command: `mkdir -p "${inboxDir2}" && : > "${inboxDir2}/${INBOX_READY_FILE}"; exit 0` }]
|
|
638
|
+
}]
|
|
622
639
|
};
|
|
623
640
|
}
|
|
624
641
|
return JSON.stringify(settings);
|
|
@@ -676,7 +693,7 @@ function masterSystemPrompt(opts) {
|
|
|
676
693
|
' \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
694
|
'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
695
|
" \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
|
-
|
|
696
|
+
' 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
697
|
"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
698
|
"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
699
|
" \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"
|
|
@@ -769,7 +786,7 @@ function buildAgentCommand(task, systemPrompt, opts, workspacePath) {
|
|
|
769
786
|
workspacePath
|
|
770
787
|
);
|
|
771
788
|
}
|
|
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;
|
|
789
|
+
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
790
|
var init_launch = __esm({
|
|
774
791
|
"packages/core/src/launch.ts"() {
|
|
775
792
|
"use strict";
|
|
@@ -779,6 +796,19 @@ var init_launch = __esm({
|
|
|
779
796
|
AUTO_PERMISSION_MODE = "auto";
|
|
780
797
|
SUBAGENTS_DIR2 = ".vibeflow-subagents";
|
|
781
798
|
PROGRESS_EVENTS_DIR = ".vibeflow-events";
|
|
799
|
+
INBOX_DIR = ".vibeflow-inbox";
|
|
800
|
+
INBOX_READY_FILE = ".ready";
|
|
801
|
+
INBOX_READER = [
|
|
802
|
+
'const fs=require("fs"),path=require("path");',
|
|
803
|
+
"const [dir,event]=process.argv.slice(1);const out=[];",
|
|
804
|
+
'for(const name of fs.readdirSync(dir).filter((n)=>!n.startsWith(".")).sort()){',
|
|
805
|
+
'const claimed=path.join(dir,".hook-"+name);',
|
|
806
|
+
"try{fs.renameSync(path.join(dir,name),claimed)}catch{continue}",
|
|
807
|
+
'out.push(fs.readFileSync(claimed,"utf8"));fs.rmSync(claimed,{force:true})}',
|
|
808
|
+
'if(out.length){const text=out.join("\\n\\n");',
|
|
809
|
+
'process.stdout.write(JSON.stringify(event==="Stop"?{decision:"block",reason:text}',
|
|
810
|
+
":{hookSpecificOutput:{hookEventName:event,additionalContext:text}}))}"
|
|
811
|
+
].join("");
|
|
782
812
|
TODO_TOOLS = "TodoWrite|TaskCreate|TaskUpdate";
|
|
783
813
|
BOARD_CLI_SETUP = [
|
|
784
814
|
'\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',
|
|
@@ -1227,7 +1257,7 @@ var init_progress = __esm({
|
|
|
1227
1257
|
|
|
1228
1258
|
// packages/tui/src/task-form.ts
|
|
1229
1259
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
1230
|
-
import
|
|
1260
|
+
import fs28 from "fs";
|
|
1231
1261
|
import os10 from "os";
|
|
1232
1262
|
import path30 from "path";
|
|
1233
1263
|
import React, { useEffect, useRef, useState } from "react";
|
|
@@ -1366,17 +1396,17 @@ function editorCommand(env, platform) {
|
|
|
1366
1396
|
return env.VISUAL?.trim() || env.EDITOR?.trim() || (platform === "win32" ? "notepad" : "vi");
|
|
1367
1397
|
}
|
|
1368
1398
|
function editInEditor(text) {
|
|
1369
|
-
const dir =
|
|
1399
|
+
const dir = fs28.mkdtempSync(path30.join(os10.tmpdir(), "vibeflow-"));
|
|
1370
1400
|
const file = path30.join(dir, "description.md");
|
|
1371
1401
|
try {
|
|
1372
|
-
|
|
1402
|
+
fs28.writeFileSync(file, text);
|
|
1373
1403
|
const cmd = editorCommand(process.env, process.platform);
|
|
1374
1404
|
const r = spawnSync2(`${cmd} "${file}"`, { stdio: "inherit", shell: true });
|
|
1375
1405
|
if (r.error) return { error: `\u7121\u6CD5\u555F\u52D5\u7DE8\u8F2F\u5668\uFF08${cmd}\uFF09\uFF1A${r.error.message}` };
|
|
1376
1406
|
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:
|
|
1407
|
+
return { text: fs28.readFileSync(file, "utf8").replace(/\r?\n$/, "") };
|
|
1378
1408
|
} finally {
|
|
1379
|
-
|
|
1409
|
+
fs28.rmSync(dir, { recursive: true, force: true });
|
|
1380
1410
|
}
|
|
1381
1411
|
}
|
|
1382
1412
|
function cycle(list, current, step) {
|
|
@@ -1450,7 +1480,7 @@ function FormView({ api, ctx, initial, initialFocus, initialMessage, pristine, o
|
|
|
1450
1480
|
if (value2) setProject(path30.resolve(value2.replace(/^~(?=$|\/)/, os10.homedir())));
|
|
1451
1481
|
} else if (editing === "attachments" && value2) {
|
|
1452
1482
|
const file = path30.resolve(value2.replace(/^~(?=$|\/)/, os10.homedir()));
|
|
1453
|
-
if (!
|
|
1483
|
+
if (!fs28.existsSync(file) || !fs28.statSync(file).isFile()) {
|
|
1454
1484
|
setMessage(`\u627E\u4E0D\u5230\u6A94\u6848\uFF1A${file}`);
|
|
1455
1485
|
return;
|
|
1456
1486
|
}
|
|
@@ -2132,7 +2162,7 @@ var init_src = __esm({
|
|
|
2132
2162
|
});
|
|
2133
2163
|
|
|
2134
2164
|
// packages/cli/src/main.ts
|
|
2135
|
-
import
|
|
2165
|
+
import fs29 from "fs";
|
|
2136
2166
|
import path32 from "path";
|
|
2137
2167
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
2138
2168
|
import { parseArgs as parseArgs2 } from "node:util";
|
|
@@ -2678,6 +2708,14 @@ function createBridge(t) {
|
|
|
2678
2708
|
getDiffEntries: (taskId, opts) => t.invoke("git:getDiffEntries", taskId, opts),
|
|
2679
2709
|
/** Content for one changed file, loaded when its row is expanded. */
|
|
2680
2710
|
getDiffFile: (taskId, filePath) => t.invoke("git:getDiffFile", taskId, filePath),
|
|
2711
|
+
/** A running card's commits and its uncommitted summary; null without a worktree. */
|
|
2712
|
+
listCommits: (taskId) => t.invoke("git:listCommits", taskId),
|
|
2713
|
+
/** Files of one branch commit, or of `'working'` (the uncommitted changes). */
|
|
2714
|
+
getCommitEntries: (taskId, ref) => t.invoke("git:getCommitEntries", taskId, ref),
|
|
2715
|
+
getCommitFile: (taskId, ref, filePath) => t.invoke("git:getCommitFile", taskId, ref, filePath),
|
|
2716
|
+
/** One commit a done card recorded: from the base, else from its PR via gh. */
|
|
2717
|
+
getDoneCommitDiff: (taskId, sha) => t.invoke("git:getDoneCommitDiff", taskId, sha),
|
|
2718
|
+
getDoneCommitFile: (taskId, sha, filePath) => t.invoke("git:getDoneCommitFile", taskId, sha, filePath),
|
|
2681
2719
|
/** Temporary artifacts the agent wrote for this task (metadata only). */
|
|
2682
2720
|
listArtifacts: (taskId) => t.invoke("task:listArtifacts", taskId),
|
|
2683
2721
|
/** Content of one artifact, by its name relative to the artifacts dir. */
|
|
@@ -2687,8 +2725,6 @@ function createBridge(t) {
|
|
|
2687
2725
|
* in-app preview will not inline. Resolves to '' on success, else a reason.
|
|
2688
2726
|
*/
|
|
2689
2727
|
openArtifactsDir: (taskId) => t.invoke("task:openArtifactsDir", taskId),
|
|
2690
|
-
/** Every spec.md the task's branch added or changed; empty when there is none. */
|
|
2691
|
-
getSpecs: (taskId) => t.invoke("task:getSpecs", taskId),
|
|
2692
2728
|
/** Store dir + CLI paths for launch injection, so an agent can write cards. */
|
|
2693
2729
|
getBoardCliLaunchInfo: () => t.invoke("board:getCliLaunchInfo"),
|
|
2694
2730
|
/** VibeFlow's own skill / prompt / script store. */
|
|
@@ -3044,11 +3080,11 @@ function timestampFromName(name) {
|
|
|
3044
3080
|
}
|
|
3045
3081
|
function reduceRuns(events) {
|
|
3046
3082
|
const runs = [];
|
|
3047
|
-
let
|
|
3083
|
+
let seq2 = 0;
|
|
3048
3084
|
for (const ev of events) {
|
|
3049
3085
|
if (ev.kind === "pre") {
|
|
3050
3086
|
runs.push({
|
|
3051
|
-
id: `sa-${
|
|
3087
|
+
id: `sa-${seq2++}`,
|
|
3052
3088
|
prompt: ev.prompt,
|
|
3053
3089
|
description: ev.description,
|
|
3054
3090
|
subagentType: ev.subagentType,
|
|
@@ -3065,7 +3101,7 @@ function reduceRuns(events) {
|
|
|
3065
3101
|
}
|
|
3066
3102
|
if (!target) {
|
|
3067
3103
|
target = {
|
|
3068
|
-
id: `sa-${
|
|
3104
|
+
id: `sa-${seq2++}`,
|
|
3069
3105
|
prompt: ev.prompt,
|
|
3070
3106
|
description: ev.description,
|
|
3071
3107
|
subagentType: ev.subagentType,
|
|
@@ -3864,7 +3900,7 @@ async function resolveBranchName(projectPath, workspacePath, taskId, preferredBr
|
|
|
3864
3900
|
}
|
|
3865
3901
|
return preferredBranch;
|
|
3866
3902
|
}
|
|
3867
|
-
var RUNTIME_ARTIFACT_DENYLIST = /* @__PURE__ */ new Set([SUBAGENTS_DIR, PROGRESS_EVENTS_DIR]);
|
|
3903
|
+
var RUNTIME_ARTIFACT_DENYLIST = /* @__PURE__ */ new Set([SUBAGENTS_DIR, PROGRESS_EVENTS_DIR, INBOX_DIR]);
|
|
3868
3904
|
var MAX_IGNORED_COPY_BYTES = 10 * 1024 * 1024;
|
|
3869
3905
|
var MAX_IGNORED_COPY_FILES = 200;
|
|
3870
3906
|
var HEAVY_IGNORED_DIR_NAMES = /* @__PURE__ */ new Set([
|
|
@@ -4167,7 +4203,7 @@ async function fetchBase(worktreePath, baseBranch) {
|
|
|
4167
4203
|
} catch {
|
|
4168
4204
|
}
|
|
4169
4205
|
}
|
|
4170
|
-
async function
|
|
4206
|
+
async function buildDiffEntries(cwd, query) {
|
|
4171
4207
|
const entryMap = /* @__PURE__ */ new Map();
|
|
4172
4208
|
function parseNameStatus(output) {
|
|
4173
4209
|
for (const line of output.split("\n").map((l) => l.trim()).filter(Boolean)) {
|
|
@@ -4193,40 +4229,31 @@ async function collectDiffEntries(worktreePath, baseRef) {
|
|
|
4193
4229
|
entry.deletions = Number.parseInt(parts[1], 10) || 0;
|
|
4194
4230
|
}
|
|
4195
4231
|
}
|
|
4196
|
-
|
|
4197
|
-
await git(
|
|
4198
|
-
|
|
4199
|
-
|
|
4200
|
-
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
"ls-files",
|
|
4207
|
-
"--others",
|
|
4208
|
-
"--exclude-standard"
|
|
4209
|
-
]).catch(() => "");
|
|
4210
|
-
for (const p of untracked.split("\n").map((l) => l.trim()).filter(Boolean)) {
|
|
4211
|
-
if (!entryMap.has(p)) {
|
|
4212
|
-
entryMap.set(p, {
|
|
4213
|
-
path: p,
|
|
4214
|
-
status: "?",
|
|
4215
|
-
additions: 0,
|
|
4216
|
-
deletions: 0,
|
|
4217
|
-
revision: ""
|
|
4218
|
-
});
|
|
4232
|
+
for (const args of query.nameStatus) {
|
|
4233
|
+
parseNameStatus(await git(cwd, args).catch(() => ""));
|
|
4234
|
+
}
|
|
4235
|
+
parseNumstat(await git(cwd, query.numstat).catch(() => ""));
|
|
4236
|
+
if (query.untracked) {
|
|
4237
|
+
const untracked = await git(cwd, ["ls-files", "--others", "--exclude-standard"]).catch(() => "");
|
|
4238
|
+
for (const p of untracked.split("\n").map((l) => l.trim()).filter(Boolean)) {
|
|
4239
|
+
if (!entryMap.has(p)) {
|
|
4240
|
+
entryMap.set(p, { path: p, status: "?", additions: 0, deletions: 0, revision: "" });
|
|
4241
|
+
}
|
|
4219
4242
|
}
|
|
4220
4243
|
}
|
|
4221
4244
|
const entries = Array.from(entryMap.values()).filter(
|
|
4222
|
-
(e) => ![SUBAGENTS_DIR, PROGRESS_EVENTS_DIR].some(
|
|
4245
|
+
(e) => ![SUBAGENTS_DIR, PROGRESS_EVENTS_DIR, INBOX_DIR].some(
|
|
4223
4246
|
(dir) => e.path === dir || e.path.startsWith(`${dir}/`)
|
|
4224
4247
|
)
|
|
4225
4248
|
);
|
|
4249
|
+
if (query.revision !== void 0) {
|
|
4250
|
+
for (const entry of entries) entry.revision = `${query.revision}:${entry.path}`;
|
|
4251
|
+
return entries;
|
|
4252
|
+
}
|
|
4226
4253
|
await Promise.all(
|
|
4227
4254
|
entries.map(async (entry) => {
|
|
4228
4255
|
try {
|
|
4229
|
-
const stat = await fs9.stat(path12.join(
|
|
4256
|
+
const stat = await fs9.stat(path12.join(cwd, entry.path));
|
|
4230
4257
|
entry.revision = `${stat.mtimeMs}:${stat.size}`;
|
|
4231
4258
|
} catch {
|
|
4232
4259
|
entry.revision = `${entry.status}:${entry.additions}:${entry.deletions}`;
|
|
@@ -4235,20 +4262,50 @@ async function collectDiffEntries(worktreePath, baseRef) {
|
|
|
4235
4262
|
);
|
|
4236
4263
|
return entries;
|
|
4237
4264
|
}
|
|
4238
|
-
|
|
4265
|
+
function collectDiffEntries(worktreePath, baseRef) {
|
|
4266
|
+
return buildDiffEntries(worktreePath, {
|
|
4267
|
+
nameStatus: [
|
|
4268
|
+
["diff", "--name-status", `${baseRef}...HEAD`],
|
|
4269
|
+
["diff", "--name-status", "HEAD"]
|
|
4270
|
+
],
|
|
4271
|
+
numstat: ["diff", "--numstat", baseRef],
|
|
4272
|
+
untracked: true
|
|
4273
|
+
});
|
|
4274
|
+
}
|
|
4275
|
+
function collectWorkingEntries(worktreePath) {
|
|
4276
|
+
return buildDiffEntries(worktreePath, {
|
|
4277
|
+
nameStatus: [["diff", "--name-status", "HEAD"]],
|
|
4278
|
+
numstat: ["diff", "--numstat", "HEAD"],
|
|
4279
|
+
untracked: true
|
|
4280
|
+
});
|
|
4281
|
+
}
|
|
4282
|
+
async function firstParent(cwd, sha) {
|
|
4283
|
+
return git(cwd, ["rev-parse", "--verify", "--quiet", `${sha}^1`]).catch(() => `${sha}^1`);
|
|
4284
|
+
}
|
|
4285
|
+
function collectCommitEntries(cwd, sha) {
|
|
4286
|
+
const show = ["show", "--format=", "--diff-merges=first-parent"];
|
|
4287
|
+
return buildDiffEntries(cwd, {
|
|
4288
|
+
nameStatus: [[...show, "--name-status", sha]],
|
|
4289
|
+
numstat: [...show, "--numstat", sha],
|
|
4290
|
+
untracked: false,
|
|
4291
|
+
revision: sha
|
|
4292
|
+
});
|
|
4293
|
+
}
|
|
4294
|
+
async function readEntryFile(cwd, oldRef, newRef, entry) {
|
|
4239
4295
|
let oldValue = "";
|
|
4240
4296
|
if (entry.status !== "A" && entry.status !== "?") {
|
|
4241
|
-
oldValue = await git(
|
|
4242
|
-
"show",
|
|
4243
|
-
`${baseRef}:${entry.path}`
|
|
4244
|
-
]).catch(() => "");
|
|
4297
|
+
oldValue = await git(cwd, ["show", `${oldRef}:${entry.path}`]).catch(() => "");
|
|
4245
4298
|
}
|
|
4246
4299
|
let newValue = "";
|
|
4247
4300
|
if (entry.status !== "D") {
|
|
4248
|
-
|
|
4249
|
-
newValue = await
|
|
4250
|
-
}
|
|
4251
|
-
|
|
4301
|
+
if (newRef) {
|
|
4302
|
+
newValue = await git(cwd, ["show", `${newRef}:${entry.path}`]).catch(() => "");
|
|
4303
|
+
} else {
|
|
4304
|
+
try {
|
|
4305
|
+
newValue = await fs9.readFile(path12.join(cwd, entry.path), "utf8");
|
|
4306
|
+
} catch {
|
|
4307
|
+
newValue = await git(cwd, ["show", `HEAD:${entry.path}`]).catch(() => "");
|
|
4308
|
+
}
|
|
4252
4309
|
}
|
|
4253
4310
|
}
|
|
4254
4311
|
const oldClip = clip(oldValue);
|
|
@@ -4260,6 +4317,9 @@ async function readDiffFile(worktreePath, baseRef, entry) {
|
|
|
4260
4317
|
truncated: oldClip.truncated || newClip.truncated
|
|
4261
4318
|
};
|
|
4262
4319
|
}
|
|
4320
|
+
function readDiffFile(worktreePath, baseRef, entry) {
|
|
4321
|
+
return readEntryFile(worktreePath, baseRef, null, entry);
|
|
4322
|
+
}
|
|
4263
4323
|
async function getWorktreeDiffEntries(worktreePath, baseBranch, opts) {
|
|
4264
4324
|
if (opts?.fetch !== false) await fetchBase(worktreePath, baseBranch);
|
|
4265
4325
|
const baseRef = await resolveBaseRef(worktreePath, baseBranch);
|
|
@@ -5138,7 +5198,7 @@ async function hostCommand(sub, values, storePath) {
|
|
|
5138
5198
|
}
|
|
5139
5199
|
|
|
5140
5200
|
// packages/cli/src/host.ts
|
|
5141
|
-
import
|
|
5201
|
+
import fs26 from "fs";
|
|
5142
5202
|
import path28 from "path";
|
|
5143
5203
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
5144
5204
|
|
|
@@ -5677,7 +5737,7 @@ async function syncBuiltinsAtStartup() {
|
|
|
5677
5737
|
}
|
|
5678
5738
|
|
|
5679
5739
|
// packages/core/src/service.ts
|
|
5680
|
-
import
|
|
5740
|
+
import fs22 from "fs";
|
|
5681
5741
|
|
|
5682
5742
|
// packages/core/src/terminal-files.ts
|
|
5683
5743
|
import { constants } from "fs";
|
|
@@ -6870,24 +6930,233 @@ function createJiraService(options) {
|
|
|
6870
6930
|
};
|
|
6871
6931
|
}
|
|
6872
6932
|
|
|
6873
|
-
// packages/core/src/
|
|
6933
|
+
// packages/core/src/commit-diff.ts
|
|
6934
|
+
init_launch();
|
|
6874
6935
|
import fs17 from "fs";
|
|
6936
|
+
var WORKING_CHANGES = "working";
|
|
6937
|
+
var SHA_RE = /^[0-9a-f]{4,40}$/i;
|
|
6938
|
+
function isCommitSha(value) {
|
|
6939
|
+
return typeof value === "string" && SHA_RE.test(value);
|
|
6940
|
+
}
|
|
6941
|
+
var isMetadataPath = (p) => [SUBAGENTS_DIR, PROGRESS_EVENTS_DIR, INBOX_DIR].some((dir) => p === dir || p.startsWith(`${dir}/`));
|
|
6942
|
+
var COMMIT_LOG_FORMAT = "%x01%H%x00%h%x00%s%x00%at%x00%P";
|
|
6943
|
+
async function listBranchCommits(worktreePath, baseRef) {
|
|
6944
|
+
const out = await git(worktreePath, [
|
|
6945
|
+
"log",
|
|
6946
|
+
`--format=${COMMIT_LOG_FORMAT}`,
|
|
6947
|
+
"--numstat",
|
|
6948
|
+
"--diff-merges=first-parent",
|
|
6949
|
+
`--max-count=${MAX_OUTCOME_COMMITS + 1}`,
|
|
6950
|
+
`${baseRef}..HEAD`
|
|
6951
|
+
]).catch(() => "");
|
|
6952
|
+
const commits = [];
|
|
6953
|
+
for (const record2 of out.split("")) {
|
|
6954
|
+
const lines = record2.split("\n");
|
|
6955
|
+
const header = lines[0]?.split("\0");
|
|
6956
|
+
if (!header || header.length < 5) continue;
|
|
6957
|
+
const [sha, shortSha, subject, at, parents] = header;
|
|
6958
|
+
let additions = 0;
|
|
6959
|
+
let deletions = 0;
|
|
6960
|
+
let fileCount = 0;
|
|
6961
|
+
for (const line of lines.slice(1)) {
|
|
6962
|
+
const parts = line.split(" ");
|
|
6963
|
+
if (parts.length < 3 || isMetadataPath(parts[parts.length - 1])) continue;
|
|
6964
|
+
fileCount++;
|
|
6965
|
+
additions += Number.parseInt(parts[0], 10) || 0;
|
|
6966
|
+
deletions += Number.parseInt(parts[1], 10) || 0;
|
|
6967
|
+
}
|
|
6968
|
+
commits.push({
|
|
6969
|
+
sha,
|
|
6970
|
+
shortSha,
|
|
6971
|
+
subject,
|
|
6972
|
+
authoredAt: (Number.parseInt(at, 10) || 0) * 1e3,
|
|
6973
|
+
isMerge: parents.trim().split(/\s+/).filter(Boolean).length > 1,
|
|
6974
|
+
additions,
|
|
6975
|
+
deletions,
|
|
6976
|
+
fileCount
|
|
6977
|
+
});
|
|
6978
|
+
}
|
|
6979
|
+
return {
|
|
6980
|
+
commits: commits.slice(0, MAX_OUTCOME_COMMITS),
|
|
6981
|
+
truncated: commits.length > MAX_OUTCOME_COMMITS
|
|
6982
|
+
};
|
|
6983
|
+
}
|
|
6984
|
+
function summarize(entries) {
|
|
6985
|
+
if (entries.length === 0) return null;
|
|
6986
|
+
return {
|
|
6987
|
+
fileCount: entries.length,
|
|
6988
|
+
additions: entries.reduce((sum, e) => sum + e.additions, 0),
|
|
6989
|
+
deletions: entries.reduce((sum, e) => sum + e.deletions, 0)
|
|
6990
|
+
};
|
|
6991
|
+
}
|
|
6992
|
+
async function getBranchCommits(worktreePath, baseBranch) {
|
|
6993
|
+
const baseRef = await resolveBaseRef(worktreePath, baseBranch);
|
|
6994
|
+
const [{ commits, truncated }, working] = await Promise.all([
|
|
6995
|
+
listBranchCommits(worktreePath, baseRef),
|
|
6996
|
+
collectWorkingEntries(worktreePath)
|
|
6997
|
+
]);
|
|
6998
|
+
return { commits, working: summarize(working), truncated };
|
|
6999
|
+
}
|
|
7000
|
+
async function resolveCommit(cwd, sha) {
|
|
7001
|
+
return git(cwd, ["rev-parse", "--verify", "--quiet", `${sha}^{commit}`]).catch(() => null);
|
|
7002
|
+
}
|
|
7003
|
+
async function isAncestor(cwd, sha, ref) {
|
|
7004
|
+
return git(cwd, ["merge-base", "--is-ancestor", sha, ref]).then(
|
|
7005
|
+
() => true,
|
|
7006
|
+
() => false
|
|
7007
|
+
);
|
|
7008
|
+
}
|
|
7009
|
+
async function resolveBranchCommit(worktreePath, baseBranch, sha) {
|
|
7010
|
+
const full = await resolveCommit(worktreePath, sha);
|
|
7011
|
+
if (!full) return null;
|
|
7012
|
+
const baseRef = await resolveBaseRef(worktreePath, baseBranch);
|
|
7013
|
+
if (!await isAncestor(worktreePath, full, "HEAD")) return null;
|
|
7014
|
+
if (await isAncestor(worktreePath, full, baseRef)) return null;
|
|
7015
|
+
return full;
|
|
7016
|
+
}
|
|
7017
|
+
async function getCommitEntries(worktreePath, baseBranch, ref) {
|
|
7018
|
+
if (ref === WORKING_CHANGES) {
|
|
7019
|
+
return (await collectWorkingEntries(worktreePath)).slice(0, MAX_DIFF_FILES);
|
|
7020
|
+
}
|
|
7021
|
+
const full = await resolveBranchCommit(worktreePath, baseBranch, ref);
|
|
7022
|
+
if (!full) return null;
|
|
7023
|
+
return (await collectCommitEntries(worktreePath, full)).slice(0, MAX_DIFF_FILES);
|
|
7024
|
+
}
|
|
7025
|
+
async function getCommitFile(worktreePath, baseBranch, ref, filePath) {
|
|
7026
|
+
if (ref === WORKING_CHANGES) {
|
|
7027
|
+
const entry2 = (await collectWorkingEntries(worktreePath)).find((e) => e.path === filePath);
|
|
7028
|
+
return entry2 ? readEntryFile(worktreePath, "HEAD", null, entry2) : null;
|
|
7029
|
+
}
|
|
7030
|
+
const full = await resolveBranchCommit(worktreePath, baseBranch, ref);
|
|
7031
|
+
if (!full) return null;
|
|
7032
|
+
const entry = (await collectCommitEntries(worktreePath, full)).find((e) => e.path === filePath);
|
|
7033
|
+
if (!entry) return null;
|
|
7034
|
+
return readEntryFile(worktreePath, await firstParent(worktreePath, full), full, entry);
|
|
7035
|
+
}
|
|
7036
|
+
async function resolveCommitInBase(projectPath, baseBranch, sha, opts) {
|
|
7037
|
+
if (!fs17.existsSync(projectPath)) return null;
|
|
7038
|
+
if (opts?.fetch) await fetchBase(projectPath, baseBranch);
|
|
7039
|
+
const full = await resolveCommit(projectPath, sha);
|
|
7040
|
+
if (!full) return null;
|
|
7041
|
+
const baseRef = await resolveBaseRef(projectPath, baseBranch);
|
|
7042
|
+
return await isAncestor(projectPath, full, baseRef) ? full : null;
|
|
7043
|
+
}
|
|
7044
|
+
var PR_URL_RE = /^https:\/\/github\.com\/([A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+)\/pull\/(\d+)(?:[/?#].*)?$/;
|
|
7045
|
+
function parsePrUrl(url) {
|
|
7046
|
+
const match = PR_URL_RE.exec(url);
|
|
7047
|
+
if (!match || match[1].split("/").some((part) => part === "." || part === "..")) return null;
|
|
7048
|
+
return { repo: match[1], number: Number(match[2]) };
|
|
7049
|
+
}
|
|
7050
|
+
var GITHUB_STATUS = {
|
|
7051
|
+
added: "A",
|
|
7052
|
+
removed: "D",
|
|
7053
|
+
modified: "M",
|
|
7054
|
+
renamed: "R",
|
|
7055
|
+
copied: "C",
|
|
7056
|
+
changed: "M",
|
|
7057
|
+
unchanged: "M"
|
|
7058
|
+
};
|
|
7059
|
+
function parseGithubCommitFiles(json) {
|
|
7060
|
+
const parsed = JSON.parse(json);
|
|
7061
|
+
const raw = Array.isArray(parsed?.files) ? parsed.files : [];
|
|
7062
|
+
const files = [];
|
|
7063
|
+
for (const f of raw) {
|
|
7064
|
+
if (typeof f?.filename !== "string" || isMetadataPath(f.filename)) continue;
|
|
7065
|
+
const file = {
|
|
7066
|
+
path: f.filename,
|
|
7067
|
+
status: GITHUB_STATUS[String(f.status)] ?? "M",
|
|
7068
|
+
additions: typeof f.additions === "number" ? f.additions : 0,
|
|
7069
|
+
deletions: typeof f.deletions === "number" ? f.deletions : 0
|
|
7070
|
+
};
|
|
7071
|
+
if (typeof f.patch === "string") {
|
|
7072
|
+
const clipped = clip(f.patch);
|
|
7073
|
+
file.patch = clipped.value;
|
|
7074
|
+
if (clipped.truncated) file.truncated = true;
|
|
7075
|
+
}
|
|
7076
|
+
files.push(file);
|
|
7077
|
+
}
|
|
7078
|
+
return { files: files.slice(0, MAX_DIFF_FILES), truncated: files.length > MAX_DIFF_FILES };
|
|
7079
|
+
}
|
|
7080
|
+
function ghError(err) {
|
|
7081
|
+
const e = err;
|
|
7082
|
+
if (e?.code === "ENOENT") return "\u627E\u4E0D\u5230 gh \u6307\u4EE4";
|
|
7083
|
+
const text = String(e?.stderr || e?.message || err).trim();
|
|
7084
|
+
return text.split("\n")[0] || "gh \u57F7\u884C\u5931\u6557";
|
|
7085
|
+
}
|
|
7086
|
+
async function readGithubCommit(pr, sha, runGh) {
|
|
7087
|
+
let shas;
|
|
7088
|
+
try {
|
|
7089
|
+
const out = await runGh([
|
|
7090
|
+
"api",
|
|
7091
|
+
`repos/${pr.repo}/pulls/${pr.number}/commits?per_page=100`,
|
|
7092
|
+
"--paginate",
|
|
7093
|
+
"--jq",
|
|
7094
|
+
".[].sha"
|
|
7095
|
+
]);
|
|
7096
|
+
shas = out.split("\n").map((l) => l.trim().toLowerCase()).filter(Boolean);
|
|
7097
|
+
} catch (err) {
|
|
7098
|
+
return { source: "none", reason: `base \u4E2D\u627E\u4E0D\u5230\u9019\u500B commit\uFF0C\u900F\u904E gh \u8B80\u53D6 PR #${pr.number} \u4E5F\u5931\u6557\uFF1A${ghError(err)}` };
|
|
7099
|
+
}
|
|
7100
|
+
const matches = [...new Set(shas.filter((s) => s.startsWith(sha.toLowerCase())))];
|
|
7101
|
+
if (matches.length !== 1) {
|
|
7102
|
+
return {
|
|
7103
|
+
source: "none",
|
|
7104
|
+
reason: matches.length === 0 ? `base \u4E2D\u627E\u4E0D\u5230\u9019\u500B commit\uFF0CPR #${pr.number} \u7684 commit \u4E2D\u4E5F\u6C92\u6709\u5B83\u3002` : `PR #${pr.number} \u4E2D\u6709\u591A\u500B commit \u7B26\u5408 ${sha}\uFF0C\u7121\u6CD5\u5224\u65B7\u662F\u54EA\u4E00\u500B\u3002`
|
|
7105
|
+
};
|
|
7106
|
+
}
|
|
7107
|
+
try {
|
|
7108
|
+
const json = await runGh(["api", `repos/${pr.repo}/commits/${matches[0]}`]);
|
|
7109
|
+
const { files, truncated } = parseGithubCommitFiles(json);
|
|
7110
|
+
return { source: "github", sha: matches[0], files, truncated };
|
|
7111
|
+
} catch (err) {
|
|
7112
|
+
return { source: "none", reason: `\u900F\u904E gh \u8B80\u53D6\u9019\u500B commit \u5931\u6557\uFF1A${ghError(err)}` };
|
|
7113
|
+
}
|
|
7114
|
+
}
|
|
7115
|
+
async function getDoneCommitDiff(input) {
|
|
7116
|
+
if (input.projectPath) {
|
|
7117
|
+
const full = await resolveCommitInBase(input.projectPath, input.baseBranch, input.sha, {
|
|
7118
|
+
fetch: true
|
|
7119
|
+
});
|
|
7120
|
+
if (full) {
|
|
7121
|
+
const entries = await collectCommitEntries(input.projectPath, full);
|
|
7122
|
+
return {
|
|
7123
|
+
source: "git",
|
|
7124
|
+
sha: full,
|
|
7125
|
+
files: entries.slice(0, MAX_DIFF_FILES),
|
|
7126
|
+
truncated: entries.length > MAX_DIFF_FILES
|
|
7127
|
+
};
|
|
7128
|
+
}
|
|
7129
|
+
}
|
|
7130
|
+
const pr = input.prUrl ? parsePrUrl(input.prUrl) : null;
|
|
7131
|
+
if (!pr) return { source: "none", reason: "\u6B64\u5361\u6C92\u6709 PR\uFF0C\u4E14 base \u4E2D\u627E\u4E0D\u5230\u9019\u500B commit\u3002" };
|
|
7132
|
+
return readGithubCommit(pr, input.sha, input.runGh ?? defaultGhRunner);
|
|
7133
|
+
}
|
|
7134
|
+
async function getDoneCommitFile(projectPath, baseBranch, sha, filePath) {
|
|
7135
|
+
const full = await resolveCommitInBase(projectPath, baseBranch, sha);
|
|
7136
|
+
if (!full) return null;
|
|
7137
|
+
const entry = (await collectCommitEntries(projectPath, full)).find((e) => e.path === filePath);
|
|
7138
|
+
if (!entry) return null;
|
|
7139
|
+
return readEntryFile(projectPath, await firstParent(projectPath, full), full, entry);
|
|
7140
|
+
}
|
|
7141
|
+
|
|
7142
|
+
// packages/core/src/board-cli.ts
|
|
7143
|
+
import fs18 from "fs";
|
|
6875
7144
|
import path20 from "path";
|
|
6876
7145
|
import { pathToFileURL } from "url";
|
|
6877
7146
|
async function boardCliLaunchInfo() {
|
|
6878
7147
|
const storeDir = path20.dirname(getStorePath());
|
|
6879
7148
|
const entry = getPlatform().cliEntry?.();
|
|
6880
|
-
if (entry &&
|
|
7149
|
+
if (entry && fs18.existsSync(entry)) return { storeDir, cliPath: entry };
|
|
6881
7150
|
const root = getPlatform().sourceRoot();
|
|
6882
7151
|
if (!root) return { storeDir };
|
|
6883
7152
|
const cliPath = path20.join(root, "scripts", "vibeflow.mjs");
|
|
6884
7153
|
const loaderPath = path20.join(root, "test", "support", "register.mjs");
|
|
6885
|
-
if (!
|
|
7154
|
+
if (!fs18.existsSync(cliPath) || !fs18.existsSync(loaderPath)) return { storeDir };
|
|
6886
7155
|
return { storeDir, cliPath, loaderPath: pathToFileURL(loaderPath).href };
|
|
6887
7156
|
}
|
|
6888
7157
|
|
|
6889
7158
|
// packages/core/src/decisions.ts
|
|
6890
|
-
import
|
|
7159
|
+
import fs19 from "fs";
|
|
6891
7160
|
import path21 from "path";
|
|
6892
7161
|
var DECISIONS_FILE_SUFFIX = ".DECISIONS.md";
|
|
6893
7162
|
function decisionsKey(worktreePath, branch) {
|
|
@@ -6898,95 +7167,9 @@ function decisionsPath(workspacePath, key) {
|
|
|
6898
7167
|
}
|
|
6899
7168
|
function deleteDecisions(workspacePath, key) {
|
|
6900
7169
|
try {
|
|
6901
|
-
|
|
6902
|
-
} catch {
|
|
6903
|
-
}
|
|
6904
|
-
}
|
|
6905
|
-
|
|
6906
|
-
// packages/core/src/specs.ts
|
|
6907
|
-
import fs19 from "fs";
|
|
6908
|
-
import path22 from "path";
|
|
6909
|
-
var SPEC_FILE_NAME = "spec.md";
|
|
6910
|
-
var MAX_SPEC_BYTES = 256 * 1024;
|
|
6911
|
-
function isSpecPath(p) {
|
|
6912
|
-
return path22.posix.basename(p) === SPEC_FILE_NAME;
|
|
6913
|
-
}
|
|
6914
|
-
function clip2(buf) {
|
|
6915
|
-
return {
|
|
6916
|
-
markdown: buf.subarray(0, MAX_SPEC_BYTES).toString("utf8"),
|
|
6917
|
-
...buf.byteLength > MAX_SPEC_BYTES ? { truncated: true } : {}
|
|
6918
|
-
};
|
|
6919
|
-
}
|
|
6920
|
-
async function readWorktreeSpecs(worktreePath, baseBranch) {
|
|
6921
|
-
const baseRef = await resolveBaseRef(worktreePath, baseBranch);
|
|
6922
|
-
const entries = await collectDiffEntries(worktreePath, baseRef);
|
|
6923
|
-
const specs = [];
|
|
6924
|
-
for (const entry of entries) {
|
|
6925
|
-
if (entry.status === "D" || !isSpecPath(entry.path)) continue;
|
|
6926
|
-
try {
|
|
6927
|
-
const full = path22.join(worktreePath, entry.path);
|
|
6928
|
-
const stat = fs19.statSync(full);
|
|
6929
|
-
if (!stat.isFile()) continue;
|
|
6930
|
-
specs.push({ path: entry.path, ...clip2(fs19.readFileSync(full)), updatedAt: stat.mtimeMs });
|
|
6931
|
-
} catch {
|
|
6932
|
-
}
|
|
6933
|
-
}
|
|
6934
|
-
return specs.sort((a, b) => a.path.localeCompare(b.path));
|
|
6935
|
-
}
|
|
6936
|
-
async function readBranchSpecs(projectPath, branch, baseBranch, changedPaths, launchedAt) {
|
|
6937
|
-
for (const ref of [`refs/heads/${branch}`, `refs/remotes/origin/${branch}`]) {
|
|
6938
|
-
if (!await refExists(projectPath, ref)) continue;
|
|
6939
|
-
const paths = changedPaths ?? await diffNames(projectPath, `${await resolveBaseRef(projectPath, baseBranch)}...${ref}`);
|
|
6940
|
-
const specs = await readSpecsAt(projectPath, ref, paths);
|
|
6941
|
-
if (specs.length > 0) return specs;
|
|
6942
|
-
}
|
|
6943
|
-
const merge = await findPullRequestMerge(projectPath, branch, baseBranch, launchedAt);
|
|
6944
|
-
if (!merge) return [];
|
|
6945
|
-
return readSpecsAt(projectPath, `${merge}^2`, await diffNames(projectPath, `${merge}^1`, merge));
|
|
6946
|
-
}
|
|
6947
|
-
async function refExists(cwd, ref) {
|
|
6948
|
-
try {
|
|
6949
|
-
await git(cwd, ["rev-parse", "--verify", "--quiet", ref]);
|
|
6950
|
-
return true;
|
|
7170
|
+
fs19.rmSync(decisionsPath(workspacePath, key), { force: true });
|
|
6951
7171
|
} catch {
|
|
6952
|
-
return false;
|
|
6953
|
-
}
|
|
6954
|
-
}
|
|
6955
|
-
async function diffNames(cwd, ...range) {
|
|
6956
|
-
const names = await git(cwd, ["diff", "--name-only", "--diff-filter=d", ...range]).catch(() => "");
|
|
6957
|
-
return names.split("\n").map((l) => l.trim());
|
|
6958
|
-
}
|
|
6959
|
-
async function findPullRequestMerge(cwd, branch, baseBranch, launchedAt) {
|
|
6960
|
-
const baseRef = await resolveBaseRef(cwd, baseBranch);
|
|
6961
|
-
const log = await git(cwd, [
|
|
6962
|
-
"log",
|
|
6963
|
-
"--merges",
|
|
6964
|
-
"--first-parent",
|
|
6965
|
-
"--format=%H %s",
|
|
6966
|
-
...launchedAt ? [`--since=${new Date(launchedAt).toISOString()}`] : [],
|
|
6967
|
-
baseRef
|
|
6968
|
-
]).catch(() => "");
|
|
6969
|
-
for (const line of log.split("\n")) {
|
|
6970
|
-
const match = /^(\S+) Merge pull request #\d+ from [^/\s]+\/(\S+)$/.exec(line.trim());
|
|
6971
|
-
if (match && match[2] === branch) return match[1];
|
|
6972
|
-
}
|
|
6973
|
-
return null;
|
|
6974
|
-
}
|
|
6975
|
-
async function readSpecsAt(cwd, ref, paths) {
|
|
6976
|
-
const specs = [];
|
|
6977
|
-
for (const p of paths.filter(isSpecPath)) {
|
|
6978
|
-
try {
|
|
6979
|
-
const content = await git(cwd, ["show", `${ref}:${p}`]);
|
|
6980
|
-
const ct = await git(cwd, ["log", "-1", "--format=%ct", ref, "--", p]);
|
|
6981
|
-
specs.push({
|
|
6982
|
-
path: p,
|
|
6983
|
-
...clip2(Buffer.from(content, "utf8")),
|
|
6984
|
-
...ct ? { updatedAt: Number(ct) * 1e3 } : {}
|
|
6985
|
-
});
|
|
6986
|
-
} catch {
|
|
6987
|
-
}
|
|
6988
7172
|
}
|
|
6989
|
-
return specs.sort((a, b) => a.path.localeCompare(b.path));
|
|
6990
7173
|
}
|
|
6991
7174
|
|
|
6992
7175
|
// packages/core/src/chat-session.ts
|
|
@@ -7154,7 +7337,7 @@ ${attachmentLines.join("\n")}` : text;
|
|
|
7154
7337
|
});
|
|
7155
7338
|
let accumulated = "";
|
|
7156
7339
|
let buffer = "";
|
|
7157
|
-
let
|
|
7340
|
+
let seq2 = 0;
|
|
7158
7341
|
const toolNames = /* @__PURE__ */ new Map();
|
|
7159
7342
|
const push = (chunk) => {
|
|
7160
7343
|
if (!sender.isDestroyed()) sender.send("chat:chunk", chunk);
|
|
@@ -7188,7 +7371,7 @@ ${attachmentLines.join("\n")}` : text;
|
|
|
7188
7371
|
} else if (block.type === "thinking" && block.thinking) {
|
|
7189
7372
|
pushPhase({
|
|
7190
7373
|
taskId,
|
|
7191
|
-
id: `${taskId}-${
|
|
7374
|
+
id: `${taskId}-${seq2++}`,
|
|
7192
7375
|
phaseType: "thinking",
|
|
7193
7376
|
phaseSummary: "Thinking\u2026",
|
|
7194
7377
|
phaseDetail: block.thinking,
|
|
@@ -7200,7 +7383,7 @@ ${attachmentLines.join("\n")}` : text;
|
|
|
7200
7383
|
const { summary, detail } = summarizeToolUse(block.name, block.input ?? {});
|
|
7201
7384
|
pushPhase({
|
|
7202
7385
|
taskId,
|
|
7203
|
-
id: `${taskId}-${
|
|
7386
|
+
id: `${taskId}-${seq2++}`,
|
|
7204
7387
|
phaseType: "tool_use",
|
|
7205
7388
|
phaseSummary: summary,
|
|
7206
7389
|
phaseDetail: detail,
|
|
@@ -7217,7 +7400,7 @@ ${attachmentLines.join("\n")}` : text;
|
|
|
7217
7400
|
const detail = typeof raw2 === "string" ? raw2 : Array.isArray(raw2) ? raw2.map((c) => c.text ?? "").join("\n") : "";
|
|
7218
7401
|
pushPhase({
|
|
7219
7402
|
taskId,
|
|
7220
|
-
id: `${taskId}-${
|
|
7403
|
+
id: `${taskId}-${seq2++}`,
|
|
7221
7404
|
phaseType: "tool_result",
|
|
7222
7405
|
phaseSummary: `Got result from \`${toolName}\``,
|
|
7223
7406
|
phaseDetail: detail,
|
|
@@ -7281,13 +7464,13 @@ init_progress();
|
|
|
7281
7464
|
init_launch();
|
|
7282
7465
|
import fs20 from "fs";
|
|
7283
7466
|
import os8 from "os";
|
|
7284
|
-
import
|
|
7467
|
+
import path22 from "path";
|
|
7285
7468
|
var SINCE_SLACK_MS = 5e3;
|
|
7286
7469
|
function claudeProjectDir(home, cwd) {
|
|
7287
|
-
return
|
|
7470
|
+
return path22.join(home, ".claude", "projects", cwd.replace(/[^a-zA-Z0-9]/g, "-"));
|
|
7288
7471
|
}
|
|
7289
7472
|
function pathAliases(p) {
|
|
7290
|
-
const resolved =
|
|
7473
|
+
const resolved = path22.resolve(p);
|
|
7291
7474
|
try {
|
|
7292
7475
|
const real = fs20.realpathSync(resolved);
|
|
7293
7476
|
return real === resolved ? [resolved] : [resolved, real];
|
|
@@ -7305,7 +7488,7 @@ function samePath(a, b) {
|
|
|
7305
7488
|
}
|
|
7306
7489
|
function listFiles(dir, test) {
|
|
7307
7490
|
try {
|
|
7308
|
-
return fs20.readdirSync(dir).filter(test).map((name) =>
|
|
7491
|
+
return fs20.readdirSync(dir).filter(test).map((name) => path22.join(dir, name));
|
|
7309
7492
|
} catch {
|
|
7310
7493
|
return [];
|
|
7311
7494
|
}
|
|
@@ -7375,14 +7558,14 @@ function codexDayDirs(sessionsRoot, since) {
|
|
|
7375
7558
|
const cur = new Date(start.getFullYear(), start.getMonth(), start.getDate());
|
|
7376
7559
|
while (cur <= end) {
|
|
7377
7560
|
const pad = (n) => String(n).padStart(2, "0");
|
|
7378
|
-
days.push(
|
|
7561
|
+
days.push(path22.join(sessionsRoot, String(cur.getFullYear()), pad(cur.getMonth() + 1), pad(cur.getDate())));
|
|
7379
7562
|
cur.setDate(cur.getDate() + 1);
|
|
7380
7563
|
}
|
|
7381
7564
|
return days;
|
|
7382
7565
|
}
|
|
7383
7566
|
function createProgressTracker(opts) {
|
|
7384
7567
|
const home = opts.homeDir ?? os8.homedir();
|
|
7385
|
-
const codexHomes = opts.codexHomes ?? (() => [
|
|
7568
|
+
const codexHomes = opts.codexHomes ?? (() => [path22.join(home, ".codex")]);
|
|
7386
7569
|
const pollMs = opts.pollMs ?? 2e3;
|
|
7387
7570
|
const entries = /* @__PURE__ */ new Map();
|
|
7388
7571
|
const belongsToRun = (target, startedAt) => target.since == null || startedAt != null && startedAt >= target.since - SINCE_SLACK_MS;
|
|
@@ -7391,7 +7574,7 @@ function createProgressTracker(opts) {
|
|
|
7391
7574
|
const dirs = pathAliases(target.worktreePath).map((p) => claudeProjectDir(home, p));
|
|
7392
7575
|
for (const file of dirs.flatMap((dir) => listFiles(dir, (n) => n.endsWith(".jsonl")))) {
|
|
7393
7576
|
if (entry.claude.has(file) || entry.rejected.has(file)) continue;
|
|
7394
|
-
const session =
|
|
7577
|
+
const session = path22.basename(file, ".jsonl");
|
|
7395
7578
|
if (session !== target.sessionId) {
|
|
7396
7579
|
const head = firstLine(file);
|
|
7397
7580
|
if (head == null) continue;
|
|
@@ -7404,8 +7587,8 @@ function createProgressTracker(opts) {
|
|
|
7404
7587
|
entry.claude.set(file, newCursor(initialClaudeState()));
|
|
7405
7588
|
}
|
|
7406
7589
|
for (const file of Array.from(entry.claude.keys())) {
|
|
7407
|
-
if (file.includes(`${
|
|
7408
|
-
const sub =
|
|
7590
|
+
if (file.includes(`${path22.sep}subagents${path22.sep}`)) continue;
|
|
7591
|
+
const sub = path22.join(file.slice(0, -".jsonl".length), "subagents");
|
|
7409
7592
|
for (const f of listFiles(sub, (n) => n.endsWith(".jsonl"))) {
|
|
7410
7593
|
if (!entry.claude.has(f)) entry.claude.set(f, newCursor(initialClaudeState()));
|
|
7411
7594
|
}
|
|
@@ -7414,7 +7597,7 @@ function createProgressTracker(opts) {
|
|
|
7414
7597
|
function discoverCodex(entry) {
|
|
7415
7598
|
const { target } = entry;
|
|
7416
7599
|
for (const codexHome of codexHomes()) {
|
|
7417
|
-
for (const day of codexDayDirs(
|
|
7600
|
+
for (const day of codexDayDirs(path22.join(codexHome, "sessions"), target.since)) {
|
|
7418
7601
|
for (const file of listFiles(day, (n) => n.startsWith("rollout-") && n.endsWith(".jsonl"))) {
|
|
7419
7602
|
if (entry.codex.has(file) || entry.rejected.has(file)) continue;
|
|
7420
7603
|
const head = firstLine(file);
|
|
@@ -7431,7 +7614,7 @@ function createProgressTracker(opts) {
|
|
|
7431
7614
|
}
|
|
7432
7615
|
}
|
|
7433
7616
|
function drainHooks(entry) {
|
|
7434
|
-
const dir =
|
|
7617
|
+
const dir = path22.join(entry.target.worktreePath, PROGRESS_EVENTS_DIR);
|
|
7435
7618
|
for (const file of listFiles(dir, (n) => n.endsWith(".json")).sort()) {
|
|
7436
7619
|
try {
|
|
7437
7620
|
const at = fs20.statSync(file).mtimeMs;
|
|
@@ -7455,8 +7638,8 @@ function createProgressTracker(opts) {
|
|
|
7455
7638
|
if (target.agent === "claude") {
|
|
7456
7639
|
for (const [file, cursor] of entry.claude) {
|
|
7457
7640
|
runUsage = addUsage(runUsage, claudeUsageTotal(cursor.state));
|
|
7458
|
-
if (file.includes(`${
|
|
7459
|
-
const isExecutor =
|
|
7641
|
+
if (file.includes(`${path22.sep}subagents${path22.sep}`)) continue;
|
|
7642
|
+
const isExecutor = path22.basename(file, ".jsonl") === target.sessionId;
|
|
7460
7643
|
const s = cursor.state;
|
|
7461
7644
|
if (isExecutor || !target.sessionId && (!primary || (s.startedAt ?? 0) > (primary.startedAt ?? 0))) {
|
|
7462
7645
|
primary = { todos: s.todos, contextTokens: s.contextTokens, activity: s.activity, startedAt: s.startedAt };
|
|
@@ -7535,7 +7718,7 @@ function createProgressTracker(opts) {
|
|
|
7535
7718
|
};
|
|
7536
7719
|
entry.timer.unref?.();
|
|
7537
7720
|
entries.set(target.taskId, entry);
|
|
7538
|
-
const eventsDir =
|
|
7721
|
+
const eventsDir = path22.join(target.worktreePath, PROGRESS_EVENTS_DIR);
|
|
7539
7722
|
try {
|
|
7540
7723
|
fs20.mkdirSync(eventsDir, { recursive: true });
|
|
7541
7724
|
entry.watcher = fs20.watch(eventsDir, () => {
|
|
@@ -7571,6 +7754,54 @@ function createProgressTracker(opts) {
|
|
|
7571
7754
|
};
|
|
7572
7755
|
}
|
|
7573
7756
|
|
|
7757
|
+
// packages/core/src/inbox.ts
|
|
7758
|
+
init_launch();
|
|
7759
|
+
import fs21 from "fs";
|
|
7760
|
+
import path23 from "path";
|
|
7761
|
+
var seq = 0;
|
|
7762
|
+
function inboxDir(worktreePath) {
|
|
7763
|
+
return path23.join(worktreePath, INBOX_DIR);
|
|
7764
|
+
}
|
|
7765
|
+
function inboxReady(dir) {
|
|
7766
|
+
return fs21.existsSync(path23.join(dir, INBOX_READY_FILE));
|
|
7767
|
+
}
|
|
7768
|
+
function prepareInbox(dir) {
|
|
7769
|
+
fs21.mkdirSync(dir, { recursive: true });
|
|
7770
|
+
fs21.writeFileSync(path23.join(dir, ".gitignore"), "*\n");
|
|
7771
|
+
fs21.rmSync(path23.join(dir, INBOX_READY_FILE), { force: true });
|
|
7772
|
+
}
|
|
7773
|
+
function messageNames(dir) {
|
|
7774
|
+
try {
|
|
7775
|
+
return fs21.readdirSync(dir).filter((n) => !n.startsWith(".")).sort();
|
|
7776
|
+
} catch {
|
|
7777
|
+
return [];
|
|
7778
|
+
}
|
|
7779
|
+
}
|
|
7780
|
+
function pendingMessages(dir) {
|
|
7781
|
+
return messageNames(dir).length;
|
|
7782
|
+
}
|
|
7783
|
+
function postMessage(dir, text) {
|
|
7784
|
+
fs21.mkdirSync(dir, { recursive: true });
|
|
7785
|
+
const name = `${String(Date.now()).padStart(13, "0")}-${String(seq++ % 1e6).padStart(6, "0")}`;
|
|
7786
|
+
const tmp = path23.join(dir, `.tmp-${name}`);
|
|
7787
|
+
fs21.writeFileSync(tmp, text);
|
|
7788
|
+
fs21.renameSync(tmp, path23.join(dir, name));
|
|
7789
|
+
}
|
|
7790
|
+
function takeMessages(dir) {
|
|
7791
|
+
const texts = [];
|
|
7792
|
+
for (const name of messageNames(dir)) {
|
|
7793
|
+
const claimed = path23.join(dir, `.host-${name}`);
|
|
7794
|
+
try {
|
|
7795
|
+
fs21.renameSync(path23.join(dir, name), claimed);
|
|
7796
|
+
} catch {
|
|
7797
|
+
continue;
|
|
7798
|
+
}
|
|
7799
|
+
texts.push(fs21.readFileSync(claimed, "utf8"));
|
|
7800
|
+
fs21.rmSync(claimed, { force: true });
|
|
7801
|
+
}
|
|
7802
|
+
return texts;
|
|
7803
|
+
}
|
|
7804
|
+
|
|
7574
7805
|
// packages/core/src/mailbox.ts
|
|
7575
7806
|
var PASTE_START = "\x1B[200~";
|
|
7576
7807
|
var PASTE_END = "\x1B[201~";
|
|
@@ -7598,25 +7829,77 @@ function quietFromEnv() {
|
|
|
7598
7829
|
return Number.isFinite(n) && n >= 0 ? n : DEFAULT_QUIET_MS;
|
|
7599
7830
|
}
|
|
7600
7831
|
var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
7832
|
+
var PASTED = /\x1b\[200~[\s\S]*?(\x1b\[201~|$)/g;
|
|
7833
|
+
var ESCAPES = /\x1b(\[[0-9;?<=>]*[ -\/]*[@-~]|O.|.)?/g;
|
|
7834
|
+
var CLEARS_INPUT = /[\r\n\x03\x15]/;
|
|
7835
|
+
function draftAfter(before, data) {
|
|
7836
|
+
const keys = data.replace(PASTED, "x").replace(ESCAPES, "");
|
|
7837
|
+
let draft = before;
|
|
7838
|
+
for (const ch of keys) {
|
|
7839
|
+
if (CLEARS_INPUT.test(ch)) draft = false;
|
|
7840
|
+
else if (ch >= " " && ch !== "\x7F") draft = true;
|
|
7841
|
+
}
|
|
7842
|
+
return draft;
|
|
7843
|
+
}
|
|
7844
|
+
var isIdle = (a) => !a || a.state === "unknown" || a.state === "waiting" && a.waitingFor === "input";
|
|
7601
7845
|
function createMailbox(options) {
|
|
7602
7846
|
const lastInput = /* @__PURE__ */ new Map();
|
|
7847
|
+
const drafts = /* @__PURE__ */ new Set();
|
|
7603
7848
|
const held = /* @__PURE__ */ new Map();
|
|
7604
7849
|
const turns = /* @__PURE__ */ new Map();
|
|
7850
|
+
function noteInput(key, data) {
|
|
7851
|
+
lastInput.set(key, Date.now());
|
|
7852
|
+
if (draftAfter(drafts.has(key), data)) drafts.add(key);
|
|
7853
|
+
else drafts.delete(key);
|
|
7854
|
+
}
|
|
7605
7855
|
async function waitForQuiet(key, started) {
|
|
7606
7856
|
const quiet = options.quietMs ?? quietFromEnv();
|
|
7607
7857
|
const timeout = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
7608
7858
|
for (; ; ) {
|
|
7609
|
-
const left = (lastInput.get(key) ?? 0) + quiet - Date.now();
|
|
7859
|
+
const left = drafts.has(key) ? 250 : (lastInput.get(key) ?? 0) + quiet - Date.now();
|
|
7610
7860
|
if (left <= 0) return;
|
|
7611
|
-
if (Date.now() - started > timeout)
|
|
7861
|
+
if (Date.now() - started > timeout) {
|
|
7862
|
+
throw coded("TIMEOUT", drafts.has(key) ? "the input box still holds unsent text" : "the terminal never went quiet");
|
|
7863
|
+
}
|
|
7864
|
+
await sleep(Math.min(left, 250));
|
|
7865
|
+
}
|
|
7866
|
+
}
|
|
7867
|
+
function enqueue(key, job) {
|
|
7868
|
+
const run3 = (turns.get(key) ?? Promise.resolve()).catch(() => {
|
|
7869
|
+
}).then(job);
|
|
7870
|
+
turns.set(key, run3);
|
|
7871
|
+
void run3.finally(() => {
|
|
7872
|
+
if (turns.get(key) === run3) turns.delete(key);
|
|
7873
|
+
}).catch(() => {
|
|
7874
|
+
});
|
|
7875
|
+
return run3;
|
|
7876
|
+
}
|
|
7877
|
+
async function canWake(key) {
|
|
7878
|
+
if (!isIdle(options.activity(key)) || drafts.has(key)) return false;
|
|
7879
|
+
return !await options.typedElsewhere?.(key);
|
|
7880
|
+
}
|
|
7881
|
+
async function wake(key, dir) {
|
|
7882
|
+
const quiet = options.quietMs ?? quietFromEnv();
|
|
7883
|
+
for (; ; ) {
|
|
7884
|
+
if (!await canWake(key)) return "queued";
|
|
7885
|
+
const left = (lastInput.get(key) ?? 0) + quiet - Date.now();
|
|
7886
|
+
if (left <= 0) break;
|
|
7612
7887
|
await sleep(Math.min(left, 250));
|
|
7613
7888
|
}
|
|
7889
|
+
const texts = takeMessages(dir);
|
|
7890
|
+
if (!texts.length) return "hook";
|
|
7891
|
+
await write(key, texts.join("\n\n"));
|
|
7892
|
+
return "typed";
|
|
7614
7893
|
}
|
|
7615
7894
|
async function type(key, text, opts, started) {
|
|
7616
7895
|
await waitForQuiet(key, started);
|
|
7617
7896
|
if (!opts.force && isBlocked(options.activity(key))) {
|
|
7618
7897
|
throw coded("TARGET_BLOCKED", "the agent is on a permission dialog; typing could answer it");
|
|
7619
7898
|
}
|
|
7899
|
+
await write(key, text);
|
|
7900
|
+
return { queuedMs: Date.now() - started, via: "typed" };
|
|
7901
|
+
}
|
|
7902
|
+
async function write(key, text) {
|
|
7620
7903
|
held.set(key, []);
|
|
7621
7904
|
try {
|
|
7622
7905
|
options.write(key, bracketedPaste(text));
|
|
@@ -7625,36 +7908,38 @@ function createMailbox(options) {
|
|
|
7625
7908
|
} finally {
|
|
7626
7909
|
const keys = held.get(key) ?? [];
|
|
7627
7910
|
held.delete(key);
|
|
7628
|
-
if (keys.length)
|
|
7629
|
-
options.write(key, keys.join(""));
|
|
7630
|
-
lastInput.set(key, Date.now());
|
|
7631
|
-
}
|
|
7911
|
+
if (keys.length) options.write(key, keys.join(""));
|
|
7632
7912
|
}
|
|
7633
|
-
return { queuedMs: Date.now() - started };
|
|
7634
7913
|
}
|
|
7635
7914
|
return {
|
|
7636
7915
|
userInput(key, data) {
|
|
7916
|
+
noteInput(key, data);
|
|
7637
7917
|
const buffer = held.get(key);
|
|
7638
7918
|
if (buffer) {
|
|
7639
7919
|
buffer.push(data);
|
|
7640
7920
|
return;
|
|
7641
7921
|
}
|
|
7642
|
-
lastInput.set(key, Date.now());
|
|
7643
7922
|
options.write(key, data);
|
|
7644
7923
|
},
|
|
7645
7924
|
deliver(key, text, opts = {}) {
|
|
7646
7925
|
const started = Date.now();
|
|
7647
|
-
|
|
7648
|
-
|
|
7649
|
-
|
|
7650
|
-
|
|
7651
|
-
|
|
7652
|
-
|
|
7926
|
+
return enqueue(key, async () => {
|
|
7927
|
+
const dir = options.inbox?.(key);
|
|
7928
|
+
if (!dir) return type(key, text, opts, started);
|
|
7929
|
+
postMessage(dir, text);
|
|
7930
|
+
const via = await wake(key, dir);
|
|
7931
|
+
return { queuedMs: Date.now() - started, via };
|
|
7932
|
+
});
|
|
7933
|
+
},
|
|
7934
|
+
poke(key) {
|
|
7935
|
+
const dir = options.inbox?.(key);
|
|
7936
|
+
if (!dir || !pendingMessages(dir) || turns.has(key)) return;
|
|
7937
|
+
void enqueue(key, () => wake(key, dir)).catch(() => {
|
|
7653
7938
|
});
|
|
7654
|
-
return run3;
|
|
7655
7939
|
},
|
|
7656
7940
|
forget(key) {
|
|
7657
7941
|
lastInput.delete(key);
|
|
7942
|
+
drafts.delete(key);
|
|
7658
7943
|
held.delete(key);
|
|
7659
7944
|
}
|
|
7660
7945
|
};
|
|
@@ -7769,6 +8054,17 @@ function coded2(code2, message2) {
|
|
|
7769
8054
|
function invalid(message2) {
|
|
7770
8055
|
throw new InvalidRequestError(message2);
|
|
7771
8056
|
}
|
|
8057
|
+
function commitRef(value) {
|
|
8058
|
+
if (value === WORKING_CHANGES || isCommitSha(value)) return value;
|
|
8059
|
+
invalid('ref must be a commit sha or "working"');
|
|
8060
|
+
}
|
|
8061
|
+
function outcomeCommit(task, value) {
|
|
8062
|
+
if (isMasterTask(task)) invalid("a master card has no commits");
|
|
8063
|
+
if (!isCommitSha(value) || !task.outcome?.commits.some((c) => c.sha === value)) {
|
|
8064
|
+
invalid("sha is not one of this card's commits");
|
|
8065
|
+
}
|
|
8066
|
+
return value;
|
|
8067
|
+
}
|
|
7772
8068
|
function str(value, name) {
|
|
7773
8069
|
if (typeof value !== "string") invalid(`${name} must be a string`);
|
|
7774
8070
|
return value;
|
|
@@ -7834,6 +8130,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
7834
8130
|
bus.emit("progress:update", { taskId, progress: value });
|
|
7835
8131
|
notifier.activity(taskId, value.activity);
|
|
7836
8132
|
notifier.retry(taskId);
|
|
8133
|
+
mailbox.poke(taskId);
|
|
7837
8134
|
},
|
|
7838
8135
|
onNotify: (taskId, list) => {
|
|
7839
8136
|
const prefs = resolveNotificationSettings(getSettings());
|
|
@@ -7852,7 +8149,14 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
7852
8149
|
const agentActivity = (key) => progress.isTracking(key) ? progress.snapshot(key)?.activity ?? null : null;
|
|
7853
8150
|
const mailbox = createMailbox({
|
|
7854
8151
|
write: (key, data) => sessions.write(key, data),
|
|
7855
|
-
activity: agentActivity
|
|
8152
|
+
activity: agentActivity,
|
|
8153
|
+
inbox: (key) => {
|
|
8154
|
+
const worktree = findTask(key)?.worktreePath;
|
|
8155
|
+
if (!worktree) return null;
|
|
8156
|
+
const dir = inboxDir(worktree);
|
|
8157
|
+
return inboxReady(dir) ? dir : null;
|
|
8158
|
+
},
|
|
8159
|
+
typedElsewhere: async (key) => await sessions.hasForeignClients?.(key) ?? false
|
|
7856
8160
|
});
|
|
7857
8161
|
const notifier = createNotifier({
|
|
7858
8162
|
cardOf: (taskId) => {
|
|
@@ -8081,6 +8385,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8081
8385
|
fresh = false;
|
|
8082
8386
|
} else {
|
|
8083
8387
|
command = (await launchCommand(task, intent)).replace(/\r$/, "");
|
|
8388
|
+
if (key === task.id) prepareInbox(inboxDir(cwd));
|
|
8084
8389
|
}
|
|
8085
8390
|
}
|
|
8086
8391
|
if (p.launch) ensureTaskArtifactDirs(task);
|
|
@@ -8259,7 +8564,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8259
8564
|
// `vibeflow open <path>` while a host runs: only the host writes the store.
|
|
8260
8565
|
"projects:record": (projectPath) => {
|
|
8261
8566
|
const p = path24.resolve(str(projectPath, "projectPath"));
|
|
8262
|
-
if (!
|
|
8567
|
+
if (!fs22.existsSync(p) || !fs22.statSync(p).isDirectory()) invalid(`not a directory: ${p}`);
|
|
8263
8568
|
recordRecentProject(getStore(), p);
|
|
8264
8569
|
return listRecentProjects(getStore());
|
|
8265
8570
|
},
|
|
@@ -8467,8 +8772,8 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8467
8772
|
if (!await sessions.isAlive(to.id)) throw coded2("NOT_RUNNING", `\u5361\u7247 ${to.id} \u7684 agent \u6C92\u6709\u5728\u57F7\u884C`);
|
|
8468
8773
|
if (isMasterTask(to)) notifier.reported(from.id);
|
|
8469
8774
|
await attachAgent(to.id);
|
|
8470
|
-
const { queuedMs } = await mailbox.deliver(to.id, frameMessage({ id: from.id, title: from.title }, text), { force: p.force === true });
|
|
8471
|
-
return { delivered: true, queuedMs };
|
|
8775
|
+
const { queuedMs, via } = await mailbox.deliver(to.id, frameMessage({ id: from.id, title: from.title }, text), { force: p.force === true });
|
|
8776
|
+
return { delivered: true, queuedMs, via };
|
|
8472
8777
|
},
|
|
8473
8778
|
"terminal:start": async (payload) => {
|
|
8474
8779
|
const p = obj(payload, "payload");
|
|
@@ -8496,7 +8801,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8496
8801
|
} else {
|
|
8497
8802
|
cwd = os9.homedir();
|
|
8498
8803
|
}
|
|
8499
|
-
if (!path24.isAbsolute(cwd) || !
|
|
8804
|
+
if (!path24.isAbsolute(cwd) || !fs22.existsSync(cwd) || !fs22.statSync(cwd).isDirectory()) {
|
|
8500
8805
|
invalid("terminal directory must be an existing absolute directory");
|
|
8501
8806
|
}
|
|
8502
8807
|
const title = (typeof p.title === "string" ? p.title.trim() : "") || saved?.title || (projectPath ? path24.basename(projectPath) : "~");
|
|
@@ -8574,7 +8879,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8574
8879
|
"claude:sessionExists": (taskId) => {
|
|
8575
8880
|
const task = requireTask(taskId);
|
|
8576
8881
|
if (!task.worktreePath) return false;
|
|
8577
|
-
return
|
|
8882
|
+
return fs22.existsSync(claudeSessionFile(task.worktreePath, executorSessionId(task.id, task.runId)));
|
|
8578
8883
|
},
|
|
8579
8884
|
"sessions:list": async () => {
|
|
8580
8885
|
const keys = await sessions.list();
|
|
@@ -8606,6 +8911,45 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8606
8911
|
if (!worktree) return null;
|
|
8607
8912
|
return getWorktreeDiffFile(worktree, task.baseBranch ?? "HEAD", str(filePath, "filePath"));
|
|
8608
8913
|
},
|
|
8914
|
+
/** A running card's commits (`base..HEAD`) plus a summary of what is uncommitted. Local only. */
|
|
8915
|
+
"git:listCommits": (taskId) => {
|
|
8916
|
+
const task = requireTask(taskId);
|
|
8917
|
+
const worktree = gitWorktree(task);
|
|
8918
|
+
if (!worktree) return null;
|
|
8919
|
+
return getBranchCommits(worktree, task.baseBranch ?? "HEAD");
|
|
8920
|
+
},
|
|
8921
|
+
"git:getCommitEntries": (taskId, ref) => {
|
|
8922
|
+
const task = requireTask(taskId);
|
|
8923
|
+
const worktree = gitWorktree(task);
|
|
8924
|
+
if (!worktree) return null;
|
|
8925
|
+
return getCommitEntries(worktree, task.baseBranch ?? "HEAD", commitRef(ref));
|
|
8926
|
+
},
|
|
8927
|
+
"git:getCommitFile": (taskId, ref, filePath) => {
|
|
8928
|
+
const task = requireTask(taskId);
|
|
8929
|
+
const worktree = gitWorktree(task);
|
|
8930
|
+
if (!worktree) return null;
|
|
8931
|
+
return getCommitFile(worktree, task.baseBranch ?? "HEAD", commitRef(ref), str(filePath, "filePath"));
|
|
8932
|
+
},
|
|
8933
|
+
/**
|
|
8934
|
+
* One commit of a finished card: from the project's base, else from its PR
|
|
8935
|
+
* through `gh`. Only commits the card recorded in its outcome are read.
|
|
8936
|
+
*/
|
|
8937
|
+
"git:getDoneCommitDiff": (taskId, sha) => {
|
|
8938
|
+
const task = requireTask(taskId);
|
|
8939
|
+
const commit = outcomeCommit(task, sha);
|
|
8940
|
+
return getDoneCommitDiff({
|
|
8941
|
+
projectPath: task.projectPath || void 0,
|
|
8942
|
+
baseBranch: task.baseBranch ?? "main",
|
|
8943
|
+
sha: commit,
|
|
8944
|
+
prUrl: task.outcome?.pr?.url
|
|
8945
|
+
});
|
|
8946
|
+
},
|
|
8947
|
+
"git:getDoneCommitFile": (taskId, sha, filePath) => {
|
|
8948
|
+
const task = requireTask(taskId);
|
|
8949
|
+
const commit = outcomeCommit(task, sha);
|
|
8950
|
+
if (!task.projectPath) return null;
|
|
8951
|
+
return getDoneCommitFile(task.projectPath, task.baseBranch ?? "main", commit, str(filePath, "filePath"));
|
|
8952
|
+
},
|
|
8609
8953
|
"task:listArtifacts": (taskId) => {
|
|
8610
8954
|
const task = requireTask(taskId);
|
|
8611
8955
|
if (!task.worktreePath || !task.workspacePath) return [];
|
|
@@ -8624,19 +8968,9 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8624
8968
|
const task = requireTask(taskId);
|
|
8625
8969
|
if (!task.worktreePath || !task.workspacePath) return "task has no worktree";
|
|
8626
8970
|
const dir = agentArtifactsPath(task.workspacePath, task.worktreePath);
|
|
8627
|
-
if (!
|
|
8971
|
+
if (!fs22.existsSync(dir)) return "artifacts directory does not exist yet";
|
|
8628
8972
|
return getPlatform().openPath(dir);
|
|
8629
8973
|
},
|
|
8630
|
-
"task:getSpecs": async (taskId) => {
|
|
8631
|
-
const task = requireTask(taskId);
|
|
8632
|
-
const base2 = task.baseBranch ?? "main";
|
|
8633
|
-
if (isMasterTask(task)) return [];
|
|
8634
|
-
if (task.worktreePath) return readWorktreeSpecs(task.worktreePath, base2);
|
|
8635
|
-
const since = task.provisionedAt ?? task.launchedAt ?? (task.pushed !== void 0 ? task.createdAt : void 0);
|
|
8636
|
-
if (!task.projectPath || !since) return [];
|
|
8637
|
-
const changed = task.outcome?.files.filter((f) => f.status !== "D").map((f) => f.path);
|
|
8638
|
-
return readBranchSpecs(task.projectPath, task.branch, base2, changed, since);
|
|
8639
|
-
},
|
|
8640
8974
|
"board:getCliLaunchInfo": () => boardCliLaunchInfo(),
|
|
8641
8975
|
"library:list": async () => listLibrary(await libraryRoot(), builtinSkillsDir()),
|
|
8642
8976
|
// The source path was picked by the user (native picker or typed path).
|
|
@@ -8765,10 +9099,10 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8765
9099
|
}
|
|
8766
9100
|
await removeTaskWorktree(task);
|
|
8767
9101
|
if (task.workspacePath) {
|
|
8768
|
-
|
|
9102
|
+
fs22.rmSync(taskAttachmentStagingPath(task.workspacePath, task.id), { recursive: true, force: true });
|
|
8769
9103
|
}
|
|
8770
9104
|
if (isMasterTask(task) && task.workspacePath) {
|
|
8771
|
-
|
|
9105
|
+
fs22.rmSync(task.workspacePath, { recursive: true, force: true });
|
|
8772
9106
|
}
|
|
8773
9107
|
clearConversation(task.id);
|
|
8774
9108
|
removeTask(task.id);
|
|
@@ -8823,7 +9157,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8823
9157
|
watchStore() {
|
|
8824
9158
|
const file = path24.basename(getStorePath());
|
|
8825
9159
|
let debounce = null;
|
|
8826
|
-
storeWatcher =
|
|
9160
|
+
storeWatcher = fs22.watch(path24.dirname(getStorePath()), (_event, filename) => {
|
|
8827
9161
|
if (filename !== file) return;
|
|
8828
9162
|
if (debounce) clearTimeout(debounce);
|
|
8829
9163
|
debounce = setTimeout(() => {
|
|
@@ -8860,7 +9194,7 @@ function createSessionBackend(sink, choice) {
|
|
|
8860
9194
|
}
|
|
8861
9195
|
|
|
8862
9196
|
// packages/core/src/web-server.ts
|
|
8863
|
-
import
|
|
9197
|
+
import fs23 from "fs";
|
|
8864
9198
|
import http from "http";
|
|
8865
9199
|
import path25 from "path";
|
|
8866
9200
|
import { timingSafeEqual } from "crypto";
|
|
@@ -8924,7 +9258,7 @@ function resolveStatic(root, urlPath) {
|
|
|
8924
9258
|
const full = path25.resolve(base2, c);
|
|
8925
9259
|
if (full !== base2 && !full.startsWith(base2 + path25.sep)) return null;
|
|
8926
9260
|
try {
|
|
8927
|
-
if (
|
|
9261
|
+
if (fs23.statSync(full).isFile()) return full;
|
|
8928
9262
|
} catch {
|
|
8929
9263
|
}
|
|
8930
9264
|
}
|
|
@@ -8998,7 +9332,7 @@ async function startWebServer(options) {
|
|
|
8998
9332
|
res.end();
|
|
8999
9333
|
return;
|
|
9000
9334
|
}
|
|
9001
|
-
|
|
9335
|
+
fs23.createReadStream(file).pipe(res);
|
|
9002
9336
|
}
|
|
9003
9337
|
const wss = new WebSocketServer({ noServer: true, maxPayload: MAX_PAYLOAD });
|
|
9004
9338
|
function reject(socket, status, reason) {
|
|
@@ -9097,7 +9431,7 @@ Content-Length: 0\r
|
|
|
9097
9431
|
}
|
|
9098
9432
|
|
|
9099
9433
|
// packages/cli/src/update-command.ts
|
|
9100
|
-
import
|
|
9434
|
+
import fs24 from "node:fs";
|
|
9101
9435
|
import path26 from "node:path";
|
|
9102
9436
|
import { spawnSync } from "node:child_process";
|
|
9103
9437
|
function npmRunner(args, inherit) {
|
|
@@ -9110,7 +9444,7 @@ function npmRunner(args, inherit) {
|
|
|
9110
9444
|
}
|
|
9111
9445
|
function packageName(packageRoot) {
|
|
9112
9446
|
try {
|
|
9113
|
-
const pkg = JSON.parse(
|
|
9447
|
+
const pkg = JSON.parse(fs24.readFileSync(path26.join(packageRoot, "package.json"), "utf8"));
|
|
9114
9448
|
if (typeof pkg.name !== "string") return null;
|
|
9115
9449
|
return /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/i.test(pkg.name) ? pkg.name : null;
|
|
9116
9450
|
} catch {
|
|
@@ -9138,7 +9472,7 @@ function runUpdate(options) {
|
|
|
9138
9472
|
}
|
|
9139
9473
|
try {
|
|
9140
9474
|
const globalPackage = path26.join(String(root.stdout).trim(), ...name.split("/"));
|
|
9141
|
-
if (
|
|
9475
|
+
if (fs24.lstatSync(globalPackage).isSymbolicLink() || fs24.realpathSync(globalPackage) !== fs24.realpathSync(packageRoot)) {
|
|
9142
9476
|
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");
|
|
9143
9477
|
return 1;
|
|
9144
9478
|
}
|
|
@@ -9283,7 +9617,7 @@ async function openUpdateTerminal(platform = process.platform, run3 = launch) {
|
|
|
9283
9617
|
}
|
|
9284
9618
|
|
|
9285
9619
|
// packages/cli/src/self-update.ts
|
|
9286
|
-
import
|
|
9620
|
+
import fs25 from "node:fs";
|
|
9287
9621
|
import path27 from "node:path";
|
|
9288
9622
|
import { execFile as execFile10 } from "node:child_process";
|
|
9289
9623
|
import { promisify as promisify7 } from "node:util";
|
|
@@ -9293,7 +9627,7 @@ var PROBE_RETRY_MS = 3e4;
|
|
|
9293
9627
|
var HOST_TOKEN_ENV = "VIBEFLOW_HOST_TOKEN";
|
|
9294
9628
|
function readInstalledVersion(packageRoot) {
|
|
9295
9629
|
try {
|
|
9296
|
-
const pkg = JSON.parse(
|
|
9630
|
+
const pkg = JSON.parse(fs25.readFileSync(path27.join(packageRoot, "package.json"), "utf8"));
|
|
9297
9631
|
return typeof pkg.version === "string" ? pkg.version : null;
|
|
9298
9632
|
} catch {
|
|
9299
9633
|
return null;
|
|
@@ -9477,11 +9811,11 @@ function loginUrl(lock, pathname = "/home/") {
|
|
|
9477
9811
|
return `http://127.0.0.1:${lock.port}${pathname}?token=${encodeURIComponent(lock.token)}`;
|
|
9478
9812
|
}
|
|
9479
9813
|
function isWebDir(dir) {
|
|
9480
|
-
return
|
|
9814
|
+
return fs26.existsSync(path28.join(dir, "home", "index.html"));
|
|
9481
9815
|
}
|
|
9482
9816
|
|
|
9483
9817
|
// packages/cli/src/doctor.ts
|
|
9484
|
-
import
|
|
9818
|
+
import fs27 from "fs";
|
|
9485
9819
|
import path29 from "path";
|
|
9486
9820
|
import { execFile as execFile11 } from "child_process";
|
|
9487
9821
|
import { promisify as promisify8 } from "util";
|
|
@@ -9622,10 +9956,10 @@ async function runDoctor(options) {
|
|
|
9622
9956
|
});
|
|
9623
9957
|
}
|
|
9624
9958
|
try {
|
|
9625
|
-
|
|
9959
|
+
fs27.mkdirSync(options.userDataDir, { recursive: true });
|
|
9626
9960
|
const probe = path29.join(options.userDataDir, `.doctor-${process.pid}`);
|
|
9627
|
-
|
|
9628
|
-
|
|
9961
|
+
fs27.writeFileSync(probe, "");
|
|
9962
|
+
fs27.rmSync(probe);
|
|
9629
9963
|
checks.push({ id: "data", name: "\u8CC7\u6599\u76EE\u9304", level: "ok", detail: options.userDataDir });
|
|
9630
9964
|
} catch (err) {
|
|
9631
9965
|
checks.push({
|
|
@@ -9697,7 +10031,7 @@ function detectLayout() {
|
|
|
9697
10031
|
}
|
|
9698
10032
|
function readVersion(pkgPath) {
|
|
9699
10033
|
try {
|
|
9700
|
-
return JSON.parse(
|
|
10034
|
+
return JSON.parse(fs29.readFileSync(pkgPath, "utf8")).version;
|
|
9701
10035
|
} catch {
|
|
9702
10036
|
return "0.0.0";
|
|
9703
10037
|
}
|
|
@@ -9936,7 +10270,7 @@ async function cmdOpen(values, target, layout, userDataDir) {
|
|
|
9936
10270
|
return 1;
|
|
9937
10271
|
}
|
|
9938
10272
|
const dir = path32.resolve(target);
|
|
9939
|
-
if (!
|
|
10273
|
+
if (!fs29.existsSync(dir) || !fs29.statSync(dir).isDirectory()) {
|
|
9940
10274
|
console.error(`\u4E0D\u662F\u8CC7\u6599\u593E\uFF1A${dir}`);
|
|
9941
10275
|
return 1;
|
|
9942
10276
|
}
|