@kw-yeh/vibeflow 4.11.62 → 4.11.64
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 +1 -1
- package/dist/vibeflow.mjs +395 -272
- package/dist/web/404/index.html +1 -1
- package/dist/web/404.html +1 -1
- package/dist/web/_next/static/chunks/pages/{home-1b55b5bcebcaafa1.js → home-b0f4bea0ace9742e.js} +3 -3
- package/dist/web/_next/static/{TULkjf0SGRJklXVvxpUwi → lSfG-VkAAfRoqKE6SZgoL}/_buildManifest.js +1 -1
- package/dist/web/home/index.html +1 -1
- package/package.json +1 -1
- /package/dist/web/_next/static/{TULkjf0SGRJklXVvxpUwi → lSfG-VkAAfRoqKE6SZgoL}/_ssgManifest.js +0 -0
package/dist/vibeflow.mjs
CHANGED
|
@@ -649,31 +649,39 @@ function resolveSystemPrompt(custom) {
|
|
|
649
649
|
return custom && custom.trim() ? custom : "";
|
|
650
650
|
}
|
|
651
651
|
function slaveSystemPrompt(opts) {
|
|
652
|
+
const master = opts.context?.master;
|
|
652
653
|
const lines = [
|
|
653
|
-
|
|
654
|
-
|
|
654
|
+
master ? `\u9019\u5F35\u5361\u7247\u662F VibeFlow Master \u5361 ${master.id}\u300C${master.title}\u300D\u8A08\u756B\u4E2D\u7684\u4E00\u5F35\uFF08master \u7684 id \u5728 $VIBEFLOW_MASTER_ID\uFF09\u3002` : "\u9019\u5F35\u5361\u7247\u662F VibeFlow Master \u5361\u8A08\u756B\u4E2D\u7684\u4E00\u5F35\uFF08master \u7684 id \u5728 $VIBEFLOW_MASTER_ID\uFF09\u3002",
|
|
655
|
+
"\u4F7F\u7528\u8005\u6703\u76F4\u63A5\u5728\u9019\u5F35\u5361\u8DDF\u4F60\u5354\u4F5C\uFF0C\u7167\u4F7F\u7528\u8005\u7684\u6307\u793A\u505A\u3002"
|
|
655
656
|
];
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
657
|
+
const siblings = opts.context?.siblings ?? [];
|
|
658
|
+
if (siblings.length) {
|
|
659
|
+
lines.push("", "\u540C\u4E00\u500B\u8A08\u756B\u7684\u5176\u4ED6\u5361\u7247\uFF08\u8B93\u4F60\u77E5\u9053\u5206\u5DE5\u8207\u4ECB\u9762\uFF0C\u4E0D\u662F\u4F60\u7684\u5DE5\u4F5C\uFF09\uFF1A");
|
|
660
|
+
for (const s of siblings) lines.push(`- ${s.id}\u300C${s.title}\u300D${s.summary ? `\uFF1A${s.summary}` : ""}`);
|
|
661
|
+
}
|
|
662
|
+
if (opts.context?.after?.length) {
|
|
663
|
+
lines.push("", `\u9019\u5F35\u5361\u6392\u5728\u9019\u4E9B\u5361\u4E4B\u5F8C\uFF1A${opts.context.after.join("\u3001")}\u3002`);
|
|
664
|
+
}
|
|
665
|
+
lines.push("", '\u4F60\u6536\u5230\u7684 <vibeflow from="\u2026"> \u8A0A\u606F\u4F86\u81EA master \u6216 VibeFlow \u672C\u8EAB\u3002');
|
|
666
|
+
if (opts.canWrite) {
|
|
667
|
+
lines.push(
|
|
668
|
+
"\u53EA\u6709\u771F\u7684\u9700\u8981 master \u6C7A\u5B9A\u624D\u80FD\u7E7C\u7E8C\u6642\u624D\u554F\u5B83\uFF0C\u505A\u5B8C\u5DE5\u4F5C\u4E0D\u5FC5\u56DE\u5831\uFF1A",
|
|
669
|
+
...BOARD_CLI_SETUP,
|
|
670
|
+
' VF task send --store-path "$VIBEFLOW_STORE_DIR" --task "$VIBEFLOW_MASTER_ID" --text "<\u554F\u984C>"'
|
|
671
|
+
);
|
|
659
672
|
}
|
|
660
|
-
lines.push(
|
|
661
|
-
"",
|
|
662
|
-
...BOARD_CLI_SETUP,
|
|
663
|
-
"",
|
|
664
|
-
"\u56DE\u5831\uFF1A\u4EFB\u52D9\u5B8C\u6210\u3001\u9700\u8981 master \u6C7A\u5B9A\u3001\u6216\u5361\u4F4F\u7121\u6CD5\u7E7C\u7E8C\u6642\uFF0C\u7ACB\u523B\u7528\u9019\u500B\u6307\u4EE4\u56DE\u5831\uFF0C\u7136\u5F8C\u505C\u4E0B\u4F86\u7B49\u4E0B\u4E00\u6B65\u6307\u793A\uFF1A",
|
|
665
|
-
' VF task send --store-path "$VIBEFLOW_STORE_DIR" --task "$VIBEFLOW_MASTER_ID" --text "<\u56DE\u5831\u5167\u5BB9>"',
|
|
666
|
-
"\u56DE\u5831\u5167\u5BB9\u8981\u81EA\u5305\u542B\uFF1A\u505A\u4E86\u4EC0\u9EBC\u3001\u600E\u9EBC\u9A57\u8B49\u3001\u7D50\u679C\uFF1B\u9A57\u6536\u985E\u5DE5\u4F5C\u9010\u9805\u5217\u51FA\u901A\u904E\u8207\u672A\u901A\u904E\u7684\u9805\u76EE\u53CA\u91CD\u73FE\u6B65\u9A5F\uFF1B\u958B\u4E86 PR \u5C31\u9644\u4E0A\u9023\u7D50\u3002",
|
|
667
|
-
"\u6C92\u6709 master \u8981\u6C42\u5C31\u4E0D\u8981\u958B PR\u3002"
|
|
668
|
-
);
|
|
669
673
|
return lines.join("\n");
|
|
670
674
|
}
|
|
671
675
|
function masterSystemPrompt(opts) {
|
|
672
676
|
const lines = [
|
|
673
677
|
"\u4F60\u662F VibeFlow \u7684 Master agent\uFF0C\u4E0D\u5C6C\u65BC\u4EFB\u4F55 repo\uFF0C\u5DE5\u4F5C\u76EE\u9304\u53EA\u662F\u4F60\u7684\u7B46\u8A18\u5340\u3002",
|
|
674
|
-
"\u4F60\u7684\u5DE5\u4F5C\u662F\
|
|
675
|
-
""
|
|
678
|
+
"\u4F60\u7684\u5DE5\u4F5C\u662F\u7406\u89E3\u4F7F\u7528\u8005\u7684\u4EFB\u52D9\u3001\u62C6\u89E3\u6210\u5361\u7247\u3001\u6D3E\u5DE5\u4E26\u6392\u597D\u5148\u5F8C\uFF0C\u800C\u4E0D\u662F\u81EA\u5DF1\u6539\u7A0B\u5F0F\u78BC\u3002",
|
|
679
|
+
"\u6D3E\u5DE5\u4E4B\u5F8C\u4F7F\u7528\u8005\u6703\u76F4\u63A5\u8DDF\u6BCF\u5F35\u5361\u5354\u4F5C\uFF1A\u4F60\u4E0D\u76E3\u5DE5\u3001\u4E0D\u8F49\u50B3\u3001\u4E0D\u8FFD\u8E64\u9032\u5EA6\u3002"
|
|
676
680
|
];
|
|
681
|
+
if (opts.projects?.length) {
|
|
682
|
+
lines.push("", "\u76F8\u95DC\u5C08\u6848\uFF08\u53EF\u4EE5\u76F4\u63A5\u552F\u8B80\u67E5\u770B\uFF09\uFF1A", ...opts.projects.map((dir) => `- ${dir}`));
|
|
683
|
+
}
|
|
684
|
+
lines.push("");
|
|
677
685
|
if (!opts.canWrite) {
|
|
678
686
|
lines.push(
|
|
679
687
|
"\u9019\u6B21\u555F\u52D5\u7121\u6CD5\u4F7F\u7528 board CLI\uFF08\u627E\u4E0D\u5230 VIBEFLOW_CLI\uFF09\uFF0C\u4F60\u4E0D\u80FD\u5EFA\u7ACB\u6216\u555F\u52D5\u5361\u7247\u3002",
|
|
@@ -684,23 +692,18 @@ function masterSystemPrompt(opts) {
|
|
|
684
692
|
lines.push(
|
|
685
693
|
...BOARD_CLI_SETUP,
|
|
686
694
|
"",
|
|
687
|
-
"1. \
|
|
688
|
-
|
|
689
|
-
|
|
695
|
+
"1. \u898F\u5283\uFF1A\u5148\u552F\u8B80\u4E86\u89E3\u9700\u6C42\u8207\u76F8\u95DC repo\uFF0C\u4E0D\u6539\u4EFB\u4F55\u7A0B\u5F0F\u78BC\u3002\u4E00\u5F35\u5361\u505A\u5F97\u5B8C\u5C31\u53EA\u5EFA\u4E00\u5F35\uFF1B\u6D89\u53CA\u591A\u500B repo \u6216\u53EF\u5E73\u884C\u7684\u7368\u7ACB\u5DE5\u4F5C\u624D\u62C6\u6210\u591A\u5F35\u3002\u6BCF\u5F35\u53EA\u52D5\u4E00\u500B repo\uFF0C\u5404\u81EA\u80FD\u7368\u7ACB\u9A57\u6536\u3002",
|
|
696
|
+
" \u5F7C\u6B64\u6709\u7A0B\u5F0F\u78BC\u76F8\u4F9D\u7684\u5DE5\u4F5C\u76E1\u91CF\u653E\u5728\u540C\u4E00\u5F35\uFF1B\u5FC5\u9808\u5206\u958B\u6642\u7528 --after \u6392\u5148\u5F8C\uFF0C\u4E26\u63D0\u9192\u4F7F\u7528\u8005\u524D\u7F6E\u5361\u8981\u5148 merge\uFF0C\u5F8C\u9762\u7684\u5361\u624D\u6703\u5F9E\u542B\u5B83\u7684 base \u958B\u59CB\u3002",
|
|
697
|
+
'2. \u8A08\u756B\uFF1A\u628A\u62C6\u89E3\u5BEB\u9032 "$VIBEFLOW_ARTIFACTS_DIR/plan.md"\u2014\u2014\u6BCF\u5F35\u5361\u7684\u6A19\u984C\u3001\u5C08\u6848\u3001\u8981\u505A\u4EC0\u9EBC\u3001\u76F8\u4F9D\u3001\u5361\u8207\u5361\u4E4B\u9593\u7684\u4ECB\u9762\u7D04\u5B9A\u2014\u2014\u4E26\u5728 terminal \u6458\u8981\u3002',
|
|
698
|
+
opts.autoMode ? "3. \u78BA\u8A8D\uFF1Aauto mode \u958B\u8457\uFF0C\u4E0D\u5FC5\u7B49\u4F7F\u7528\u8005\u78BA\u8A8D\uFF0C\u5BEB\u5B8C\u8A08\u756B\u5C31\u5EFA\u5361\u3002" : "3. \u78BA\u8A8D\uFF1A\u5BEB\u5B8C\u8A08\u756B\u5C31\u505C\u4E0B\u4F86\uFF0C\u7B49\u4F7F\u7528\u8005\u540C\u610F\u6216\u4FEE\u6539\uFF1B\u4F7F\u7528\u8005\u540C\u610F\u4E4B\u524D\u4E0D\u8981\u5EFA\u4EFB\u4F55\u5361\u3002",
|
|
699
|
+
'4. \u5EFA\u5361\uFF1AVF task create --store-path "$VIBEFLOW_STORE_DIR" --master "$VIBEFLOW_TASK_ID" --project <repo \u7D55\u5C0D\u8DEF\u5F91> --title <\u6A19\u984C> --prompt <\u5167\u5BB9> [--after <\u524D\u7F6E\u5361 id>]',
|
|
700
|
+
" prompt \u5FC5\u9808\u81EA\u5305\u542B\uFF1A\u80CC\u666F\u3001\u7BC4\u570D\u3001\u9A57\u6536\u689D\u4EF6\u3001\u8207\u5176\u4ED6\u5361\u7684\u4ECB\u9762\u7D04\u5B9A\u2014\u2014\u5361\u7247\u770B\u4E0D\u5230\u4F60\u7684\u5C0D\u8A71\u3002",
|
|
690
701
|
" \u6A19\u984C\u8981\u77ED\u3001\u5F7C\u6B64\u4E00\u773C\u5206\u5F97\u51FA\u4F86\uFF1A\u4EE5\u9019\u5F35\u5361\u8CA0\u8CAC\u7684\u90E8\u5206\u958B\u982D\uFF08\u4F8B\u5982\u300C\u5F8C\u7AEF\uFF1A\u2026\u300D\u300C\u9A57\u6536\uFF1A\u2026\u300D\uFF09\uFF0C\u4E0D\u8981\u8B93\u591A\u5F35\u5361\u5171\u7528\u540C\u4E00\u6BB5\u958B\u982D\u3002",
|
|
691
|
-
" \u9810\u8A2D\u4E0D\u8981\u52A0 --model / --effort\uFF1A\u6C92\u6307\u5B9A\u6642 Jev \u6703\u4F9D\u4EFB\u52D9\u8907\u96DC\u5EA6\u6311\u6A21\u578B\u8207 effort\uFF1B\u53EA\u6709\u4EFB\u52D9\u660E\u78BA\u9700\u8981\u7279\u5B9A\u6A21\u578B\u6216 effort \u6642\u624D\u6307\u5B9A\u3002\u9700\u8981\u6642\u53EF\u52A0 --agent / --base-branch\u3002"
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
lines.push(
|
|
697
|
-
"4. \u56DE\u5831\u6703\u81EA\u5DF1\u9001\u4F86\uFF1Aslave \u505A\u5B8C\u3001\u8981\u4F60\u6C7A\u5B9A\u6216\u5361\u4F4F\u6642\u6703\u7528 task send \u56DE\u5831\uFF1Bslave \u5361\u5728\u6B0A\u9650\u78BA\u8A8D\u3001\u555F\u52D5\u5931\u6557\u3001session \u7D50\u675F\u3001\u6216\u56DE\u5408\u7D50\u675F\u537B\u6C92\u56DE\u5831\u6642\uFF0CVibeFlow \u4E5F\u6703\u901A\u77E5\u4F60\u3002",
|
|
698
|
-
' \u9019\u4E9B\u8A0A\u606F\u4EE5 <vibeflow from="\u2026"> \u5305\u4F4F\u3001\u76F4\u63A5\u51FA\u73FE\u5728\u4F60\u7684\u8F38\u5165\u88E1\u3002\u4E0D\u8981\u8F2A\u8A62 task list\uFF1B\u8981\u770B\u7D30\u7BC0\u6642\u624D\u7528 VF task show --store-path "$VIBEFLOW_STORE_DIR" --task <id>\u3002',
|
|
699
|
-
'5. \u8ABF\u5EA6\uFF1A\u7528 VF task send --store-path "$VIBEFLOW_STORE_DIR" --task <id> --text <\u5167\u5BB9> \u5C0D\u81EA\u5DF1\u7684\u5361\u4E0B\u6307\u793A\uFF1B\u5361\u8207\u5361\u4E4B\u9593\u4E0D\u80FD\u76F4\u63A5\u50B3\u8A71\uFF0C\u4E00\u5F8B\u7D93\u904E\u4F60\u3002',
|
|
700
|
-
" \u9700\u8981\u7368\u7ACB\u9A57\u6536\u6642\u53E6\u958B\u4E00\u5F35\u9A57\u6536\u5361\u3002\u9A57\u6536\u56DE\u5831\u554F\u984C\u6642\uFF0C\u628A\u5177\u9AD4\u554F\u984C\u8207\u91CD\u73FE\u6B65\u9A5F\u6574\u7406\u597D\u8F49\u7D66\u8CA0\u8CAC\u958B\u767C\u7684\u5361\u4FEE\u6B63\uFF0C\u4FEE\u5B8C\u518D\u8ACB\u9A57\u6536\u5361\u8907\u9A57\uFF0C\u76F4\u5230\u901A\u904E\u3002",
|
|
701
|
-
' task send \u56DE via: "queued" \u4EE3\u8868\u8A0A\u606F\u5DF2\u6392\u9032\u5C0D\u65B9\u7684\u6536\u4EF6\u5323\uFF0C\u5C0D\u65B9\u4E0B\u4E00\u6B21\u52D5\u4F5C\u6216\u4F7F\u7528\u8005\u9001\u51FA\u8A0A\u606F\u6642\u5C31\u6703\u770B\u5230\uFF0C\u4E0D\u5FC5\u91CD\u9001\uFF1B\u56DE TARGET_BLOCKED \u4EE3\u8868\u5C0D\u65B9\u5361\u5728\u6B0A\u9650\u78BA\u8A8D\uFF0C\u8ACB\u4F7F\u7528\u8005\u5230\u90A3\u5F35\u5361\u8655\u7406\u3002',
|
|
702
|
-
"6. PR\uFF1A\u9A57\u6536\u901A\u904E\u5F8C\uFF0C\u4EA4\u4EE3\u958B\u767C\u5361\u7528 pr skill \u958B PR\uFF08\u74B0\u5883\u88E1\u6C92\u6709\u9019\u500B skill \u5C31\u7528 gh pr create\uFF09\uFF0C\u4E26\u56DE\u5831 PR \u9023\u7D50\u7D66\u4F60\u3002",
|
|
703
|
-
"7. \u4F7F\u7528\u8005\u4E3B\u8981\u53EA\u8DDF\u4F60\u6E9D\u901A\uFF1A\u4E3B\u52D5\u5411\u4F7F\u7528\u8005\u56DE\u5831\u6574\u9AD4\u9032\u5EA6\u8207\u9700\u8981\u4F7F\u7528\u8005\u6C7A\u5B9A\u7684\u4E8B\u3002\u4F60\u4E0D\u6703\u628A\u5361\u7247\u79FB\u5230 Done\u3001\u4E0D\u6703\u5408\u4F75 PR\uFF1B\u5168\u90E8\u5B8C\u6210\u5F8C\u6574\u7406\u6BCF\u5F35\u5361\u7684\u7D50\u679C\u8207 PR \u9023\u7D50\uFF0C\u4EA4\u7D66\u4F7F\u7528\u8005\u505A\u6700\u5F8C\u78BA\u8A8D\u3002",
|
|
702
|
+
" \u9810\u8A2D\u4E0D\u8981\u52A0 --model / --effort\uFF1A\u6C92\u6307\u5B9A\u6642 Jev \u6703\u4F9D\u4EFB\u52D9\u8907\u96DC\u5EA6\u6311\u6A21\u578B\u8207 effort\uFF1B\u53EA\u6709\u4EFB\u52D9\u660E\u78BA\u9700\u8981\u7279\u5B9A\u6A21\u578B\u6216 effort \u6642\u624D\u6307\u5B9A\u3002\u9700\u8981\u6642\u53EF\u52A0 --agent / --base-branch\u3002",
|
|
703
|
+
opts.autoMode ? '5. \u555F\u52D5\uFF1A\u6C92\u6709 --after \u7684\u5361\u76F4\u63A5 VF task start --store-path "$VIBEFLOW_STORE_DIR" --task <id>\uFF1B\u6709 --after \u7684\u5361\u4E0D\u7528\u7BA1\uFF0C\u524D\u7F6E\u5361\u5168\u90E8 Done \u5F8C VibeFlow \u6703\u81EA\u52D5\u555F\u52D5\u5B83\u3002' : "5. \u555F\u52D5\uFF1A\u4E0D\u8981\u81EA\u5DF1\u555F\u52D5\u5361\u7247\u3002\u5217\u51FA\u4F60\u5EFA\u4E86\u54EA\u4E9B\u5361\u8207\u5EFA\u8B70\u7684\u555F\u52D5\u9806\u5E8F\uFF0C\u7B49\u4F7F\u7528\u8005\u5728 VibeFlow \u6309\u958B\u59CB\u3002",
|
|
704
|
+
"6. \u7D50\u675F\uFF1A\u6D3E\u5DE5\u5B8C\u5C31\u7D50\u675F\u9019\u4E00\u56DE\u5408\uFF0C\u5217\u51FA\u6BCF\u5F35\u5361\u8207\u76F8\u4F9D\u3002\u4E0D\u8981\u8F2A\u8A62 task list\uFF0C\u4E5F\u4E0D\u8981\u7B49\u5361\u7247\u56DE\u5831\u3002",
|
|
705
|
+
' VibeFlow \u53EA\u6703\u5728\u5169\u7A2E\u60C5\u6CC1\u518D\u53EB\u4F60\uFF1A\u67D0\u5F35\u5361\u555F\u52D5\u5931\u6557\uFF0C\u6216\u4F60\u7684\u5361\u5168\u90E8\u90FD\u5DF2 Done\u3002\u5168\u90E8 Done \u6642\uFF0C\u7528 VF task list --store-path "$VIBEFLOW_STORE_DIR" --master "$VIBEFLOW_TASK_ID" \u8207 VF task show \u6574\u7406\u6BCF\u5F35\u5361\u7684\u7D50\u679C\u8207 PR \u9023\u7D50\u4EA4\u7D66\u4F7F\u7528\u8005\u3002',
|
|
706
|
+
' \u4F7F\u7528\u8005\u8981\u4F60\u8F49\u9054\u6642\u624D\u7528 VF task send --store-path "$VIBEFLOW_STORE_DIR" --task <id> --text <\u5167\u5BB9> \u5C0D\u5361\u7247\u4E0B\u6307\u793A\u3002\u4F60\u4E0D\u6703\u628A\u5361\u7247\u79FB\u5230 Done\u3001\u4E0D\u6703\u5408\u4F75 PR\u3002',
|
|
704
707
|
" \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"
|
|
705
708
|
);
|
|
706
709
|
return lines.join("\n");
|
|
@@ -731,11 +734,12 @@ function namespaceHash(namespace) {
|
|
|
731
734
|
}
|
|
732
735
|
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
733
736
|
}
|
|
734
|
-
function assembleCommand(agent, systemPrompt, prompt, model, effort, opts, worktreePath, sessionId, workspacePath) {
|
|
737
|
+
function assembleCommand(agent, systemPrompt, prompt, model, effort, opts, worktreePath, sessionId, workspacePath, readDirs = []) {
|
|
735
738
|
let cmd;
|
|
739
|
+
const readDirFlags = readDirs.map((dir) => `--add-dir ${shellQuote(toShellPath(dir))}`);
|
|
736
740
|
if (agent === "claude") {
|
|
737
741
|
const settings = ` --settings ${shellQuote(buildClaudeSettings(worktreePath))}`;
|
|
738
|
-
const addDir = workspacePath ? ` --add-dir ${shellQuote(toShellPath(workspacePath))}` : "";
|
|
742
|
+
const addDir = (workspacePath ? ` --add-dir ${shellQuote(toShellPath(workspacePath))}` : "") + readDirFlags.map((flag) => ` ${flag}`).join("");
|
|
739
743
|
const modelFlag = model ? ` --model ${model}` : "";
|
|
740
744
|
const effortFlag = effort && effort !== "auto" ? ` --effort ${effort}` : "";
|
|
741
745
|
const library = opts?.library;
|
|
@@ -752,6 +756,7 @@ function assembleCommand(agent, systemPrompt, prompt, model, effort, opts, workt
|
|
|
752
756
|
codexAutoFlag(opts?.autoMode).trim(),
|
|
753
757
|
codexEffortFlag.trim(),
|
|
754
758
|
model ? `--model ${model}` : "",
|
|
759
|
+
...readDirFlags,
|
|
755
760
|
combined ? shellQuote(combined) : ""
|
|
756
761
|
].filter(Boolean);
|
|
757
762
|
const codexHome = opts?.library ? `CODEX_HOME=${shellQuote(toShellPath(opts.library.codexHome))} ` : "";
|
|
@@ -774,8 +779,8 @@ function buildAgentCommand(task, systemPrompt, opts, workspacePath) {
|
|
|
774
779
|
const model = taskModel(task);
|
|
775
780
|
const custom = [opts?.library?.promptText?.trim(), resolveSystemPrompt(systemPrompt)].filter(Boolean).join("\n\n");
|
|
776
781
|
const canWrite = Boolean(opts?.boardCli?.cliPath);
|
|
777
|
-
const role = task.role === "master" ? masterSystemPrompt({ canWrite, autoMode: opts?.autoMode === true }) : task.masterId ? slaveSystemPrompt({ canWrite }) : null;
|
|
778
|
-
const sys =
|
|
782
|
+
const role = task.role === "master" ? masterSystemPrompt({ canWrite, autoMode: opts?.autoMode === true, projects: task.projects }) : task.masterId ? slaveSystemPrompt({ canWrite, context: opts?.masterContext }) : null;
|
|
783
|
+
const sys = [custom, role].filter(Boolean).join("\n\n");
|
|
779
784
|
const includeTaskPrompt = opts?.includeTaskPrompt !== false;
|
|
780
785
|
const prompt = includeTaskPrompt && !opts?.resume ? opts?.continuation ?? buildPrompt(task, opts?.preface) : "";
|
|
781
786
|
const sessionId = agent === "claude" && includeTaskPrompt ? executorSessionId(task.id, task.runId) : void 0;
|
|
@@ -788,7 +793,8 @@ function buildAgentCommand(task, systemPrompt, opts, workspacePath) {
|
|
|
788
793
|
opts,
|
|
789
794
|
task.worktreePath,
|
|
790
795
|
sessionId,
|
|
791
|
-
workspacePath
|
|
796
|
+
workspacePath,
|
|
797
|
+
task.role === "master" ? task.projects ?? [] : []
|
|
792
798
|
);
|
|
793
799
|
}
|
|
794
800
|
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;
|
|
@@ -1008,6 +1014,13 @@ function isClaudePrompt(entry, message2) {
|
|
|
1008
1014
|
if (origin && typeof origin === "object") return origin.kind === "human";
|
|
1009
1015
|
return !CLAUDE_MACHINE_PROMPT.test(text);
|
|
1010
1016
|
}
|
|
1017
|
+
function isClaudeInterrupt(entry, message2) {
|
|
1018
|
+
if (entry.isSidechain) return false;
|
|
1019
|
+
const content = message2.content;
|
|
1020
|
+
const blocks = Array.isArray(content) ? content : [];
|
|
1021
|
+
const text = typeof content === "string" ? content : blocks.find((b) => b?.type === "text")?.text;
|
|
1022
|
+
return typeof text === "string" && text.startsWith("[Request interrupted");
|
|
1023
|
+
}
|
|
1011
1024
|
function claudeUsage(u) {
|
|
1012
1025
|
const details = u.output_tokens_details;
|
|
1013
1026
|
return {
|
|
@@ -1107,7 +1120,7 @@ function reduceClaudeLine(state, line) {
|
|
|
1107
1120
|
}
|
|
1108
1121
|
next.pendingTasks = pending;
|
|
1109
1122
|
if (isClaudePrompt(entry, message2)) next.turns = state.turns + 1;
|
|
1110
|
-
next.activity = { state: "working", at };
|
|
1123
|
+
next.activity = isClaudeInterrupt(entry, message2) ? { state: "waiting", waitingFor: "input", at } : { state: "working", at };
|
|
1111
1124
|
return next;
|
|
1112
1125
|
}
|
|
1113
1126
|
return next;
|
|
@@ -1275,7 +1288,7 @@ var init_progress = __esm({
|
|
|
1275
1288
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
1276
1289
|
import fs29 from "fs";
|
|
1277
1290
|
import os10 from "os";
|
|
1278
|
-
import
|
|
1291
|
+
import path31 from "path";
|
|
1279
1292
|
import React, { useEffect, useRef, useState } from "react";
|
|
1280
1293
|
import { Box, Text, render as render3, useApp, useInput } from "ink";
|
|
1281
1294
|
function newFormState(defaultAutoMode, agents) {
|
|
@@ -1412,8 +1425,8 @@ function editorCommand(env, platform) {
|
|
|
1412
1425
|
return env.VISUAL?.trim() || env.EDITOR?.trim() || (platform === "win32" ? "notepad" : "vi");
|
|
1413
1426
|
}
|
|
1414
1427
|
function editInEditor(text) {
|
|
1415
|
-
const dir = fs29.mkdtempSync(
|
|
1416
|
-
const file =
|
|
1428
|
+
const dir = fs29.mkdtempSync(path31.join(os10.tmpdir(), "vibeflow-"));
|
|
1429
|
+
const file = path31.join(dir, "description.md");
|
|
1417
1430
|
try {
|
|
1418
1431
|
fs29.writeFileSync(file, text);
|
|
1419
1432
|
const cmd = editorCommand(process.env, process.platform);
|
|
@@ -1493,9 +1506,9 @@ function FormView({ api, ctx, initial, initialFocus, initialMessage, pristine, o
|
|
|
1493
1506
|
if (editing === "title") setS((prev) => ({ ...prev, title: draft }));
|
|
1494
1507
|
else if (editing === "branch") setS((prev) => ({ ...prev, branch: value2 }));
|
|
1495
1508
|
else if (editing === "project") {
|
|
1496
|
-
if (value2) setProject(
|
|
1509
|
+
if (value2) setProject(path31.resolve(value2.replace(/^~(?=$|\/)/, os10.homedir())));
|
|
1497
1510
|
} else if (editing === "attachments" && value2) {
|
|
1498
|
-
const file =
|
|
1511
|
+
const file = path31.resolve(value2.replace(/^~(?=$|\/)/, os10.homedir()));
|
|
1499
1512
|
if (!fs29.existsSync(file) || !fs29.statSync(file).isFile()) {
|
|
1500
1513
|
setMessage(`\u627E\u4E0D\u5230\u6A94\u6848\uFF1A${file}`);
|
|
1501
1514
|
return;
|
|
@@ -1583,7 +1596,7 @@ function FormView({ api, ctx, initial, initialFocus, initialMessage, pristine, o
|
|
|
1583
1596
|
case "branch":
|
|
1584
1597
|
return s.branch || "\uFF08\u7559\u7A7A\u5247\u81EA\u52D5\u547D\u540D\uFF0C\u4F8B\u5982 feature/login-fix\uFF09";
|
|
1585
1598
|
case "attachments":
|
|
1586
|
-
return s.attachments.length ? s.attachments.map((a) =>
|
|
1599
|
+
return s.attachments.length ? s.attachments.map((a) => path31.basename(a)).join("\u3001") : "\uFF08Enter \u8F38\u5165\u6A94\u6848\u8DEF\u5F91\u52A0\u5165\uFF09";
|
|
1587
1600
|
case "description": {
|
|
1588
1601
|
if (!s.description) return "\uFF08Enter \u7528\u7DE8\u8F2F\u5668\u64B0\u5BEB\uFF09";
|
|
1589
1602
|
const lines = s.description.split("\n");
|
|
@@ -1618,7 +1631,7 @@ function FormView({ api, ctx, initial, initialFocus, initialMessage, pristine, o
|
|
|
1618
1631
|
if (info && !info.isRepo) return "\u9019\u500B\u8CC7\u6599\u593E\u4E0D\u662F Git repository\u3002\u8ACB\u6539\u9078\u4E00\u500B Git \u5C08\u6848\uFF0C\u6216\u5728\u4E0B\u65B9\u521D\u59CB\u5316\u3002";
|
|
1619
1632
|
if (s.mode === "edit" && projectChanged(s)) return "\u5206\u652F\u6703\u5728\u65B0\u5C08\u6848\u3001\u5361\u7247\u958B\u59CB\u57F7\u884C\u6642\u624D\u5EFA\u7ACB\u3002";
|
|
1620
1633
|
if (info?.isRepo && !info.hasRemote) return `\u6B64 repository \u6C92\u6709 remote\uFF0C\u5C07\u4EE5\u76EE\u524D\u5206\u652F (${info.currentBranch ?? "HEAD"}) \u70BA\u57FA\u6E96\u5EFA\u7ACB\u672C\u5730 worktree\u3002`;
|
|
1621
|
-
if (info?.isRepo && s.projectPath) return `worktree \u6703\u5EFA\u5728 ${ctx.workstationPath || "~/Desktop"}/${
|
|
1634
|
+
if (info?.isRepo && s.projectPath) return `worktree \u6703\u5EFA\u5728 ${ctx.workstationPath || "~/Desktop"}/${path31.basename(s.projectPath)}`;
|
|
1622
1635
|
}
|
|
1623
1636
|
if (field === "branch") {
|
|
1624
1637
|
const when = info?.hasRemote ? "\u958B\u59CB\u57F7\u884C\u6642\u6703\u5EFA\u7ACB\u540C\u540D\u5206\u652F\u4E26\u63A8\u5230 origin\uFF1B\u82E5 remote \u5DF2\u6709\u9019\u500B\u5206\u652F\uFF0C\u5247\u76F4\u63A5\u53D6\u56DE\u4E26\u63A5\u7E8C\u4E0A\u9762\u7684\u5DE5\u4F5C\u3002" : "\u958B\u59CB\u57F7\u884C\u6642\u6703\u5EFA\u7ACB\u540C\u540D\u5206\u652F\u3002";
|
|
@@ -1748,7 +1761,7 @@ __export(src_exports, {
|
|
|
1748
1761
|
showDiff: () => showDiff
|
|
1749
1762
|
});
|
|
1750
1763
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
1751
|
-
import
|
|
1764
|
+
import path32 from "path";
|
|
1752
1765
|
import React2, { useEffect as useEffect2, useState as useState2 } from "react";
|
|
1753
1766
|
import { Box as Box2, Text as Text2, render as render4, useApp as useApp2, useInput as useInput2, useStdout } from "ink";
|
|
1754
1767
|
function findDetachKey(text) {
|
|
@@ -1996,7 +2009,8 @@ function BoardView({ opts, initial, initialMessage, onAction }) {
|
|
|
1996
2009
|
const role = t.role === "master" ? "\u25C6 " : t.masterId ? "\u21B3 " : "";
|
|
1997
2010
|
const masterTitle = t.masterId ? COLUMNS2.flatMap((c) => board[c]).find((m) => m.id === t.masterId)?.title : void 0;
|
|
1998
2011
|
const detail = t.role === "master" ? `Master \xB7 ${COLUMNS2.flatMap((c) => board[c]).filter((x) => x.masterId === t.id).length} \u500B slave` : `${t.projectName ?? ""} \xB7 ${t.branch}${masterTitle ? ` \xB7 \u25C6 ${masterTitle}` : ""}`;
|
|
1999
|
-
const
|
|
2012
|
+
const waitingOn = col === "backlog" ? (t.after ?? []).filter((id) => !board.done.some((d) => d.id === id)) : [];
|
|
2013
|
+
const summary = col === "backlog" ? waitingOn.length ? `\u7B49\u5F85 ${waitingOn.join("\u3001")}` : "" : progressSummary(col === "in_progress" ? progress[t.id] : null, t.usage);
|
|
2000
2014
|
return h2(
|
|
2001
2015
|
Box2,
|
|
2002
2016
|
{ key: t.id, flexDirection: "column" },
|
|
@@ -2047,7 +2061,7 @@ function showDiff(task) {
|
|
|
2047
2061
|
});
|
|
2048
2062
|
}
|
|
2049
2063
|
function tmuxAttach(opts, sessionName) {
|
|
2050
|
-
const conf =
|
|
2064
|
+
const conf = path32.join(opts.userDataDir, "tmux.conf");
|
|
2051
2065
|
const inOurServer = (process.env.TMUX ?? "").split(",")[0].endsWith(`/${TMUX_SOCKET}`);
|
|
2052
2066
|
const args = inOurServer ? ["-L", TMUX_SOCKET, "-f", conf, "switch-client", "-t", `=${sessionName}`] : ["-L", TMUX_SOCKET, "-f", conf, "attach-session", "-t", `=${sessionName}`];
|
|
2053
2067
|
spawnSync3("tmux", args, { stdio: "inherit", env: { ...process.env, TMUX: inOurServer ? process.env.TMUX : "" } });
|
|
@@ -2179,7 +2193,7 @@ var init_src = __esm({
|
|
|
2179
2193
|
|
|
2180
2194
|
// packages/cli/src/main.ts
|
|
2181
2195
|
import fs30 from "fs";
|
|
2182
|
-
import
|
|
2196
|
+
import path33 from "path";
|
|
2183
2197
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
2184
2198
|
import { parseArgs as parseArgs2 } from "node:util";
|
|
2185
2199
|
import { spawn as spawn9 } from "node:child_process";
|
|
@@ -2639,10 +2653,19 @@ function updateTask(taskId, patch) {
|
|
|
2639
2653
|
});
|
|
2640
2654
|
getStore().set("board", board);
|
|
2641
2655
|
}
|
|
2656
|
+
function withoutRef(task, removedId) {
|
|
2657
|
+
let next = task;
|
|
2658
|
+
if (next.masterId === removedId) next = { ...next, masterId: void 0, after: void 0 };
|
|
2659
|
+
if (next.after?.includes(removedId)) {
|
|
2660
|
+
const after = next.after.filter((id) => id !== removedId);
|
|
2661
|
+
next = { ...next, after: after.length ? after : void 0 };
|
|
2662
|
+
}
|
|
2663
|
+
return next;
|
|
2664
|
+
}
|
|
2642
2665
|
function removeTask(taskId) {
|
|
2643
2666
|
const board = getStore().get("board");
|
|
2644
2667
|
Object.keys(board).forEach((col) => {
|
|
2645
|
-
board[col] = board[col].filter((t) => t.id !== taskId).map((t) => t
|
|
2668
|
+
board[col] = board[col].filter((t) => t.id !== taskId).map((t) => withoutRef(t, taskId));
|
|
2646
2669
|
});
|
|
2647
2670
|
getStore().set("board", board);
|
|
2648
2671
|
}
|
|
@@ -2808,9 +2831,9 @@ function createBridge(t) {
|
|
|
2808
2831
|
},
|
|
2809
2832
|
// Interactive terminal bridge (Phase 3).
|
|
2810
2833
|
term: {
|
|
2811
|
-
readFile: (sessionKey,
|
|
2834
|
+
readFile: (sessionKey, path34) => t.invoke("terminal:readFile", { sessionKey, path: path34 }),
|
|
2812
2835
|
existingFiles: (sessionKey, paths) => t.invoke("terminal:existingFiles", { sessionKey, paths }),
|
|
2813
|
-
openFile: (sessionKey,
|
|
2836
|
+
openFile: (sessionKey, path34) => t.invoke("terminal:openFile", { sessionKey, path: path34 }),
|
|
2814
2837
|
/**
|
|
2815
2838
|
* Start a terminal for a task: its agent when `launch` is given, else an
|
|
2816
2839
|
* interactive shell. Core resolves the cwd and builds the command.
|
|
@@ -2920,6 +2943,7 @@ function spawnHelperFixCommand(failures) {
|
|
|
2920
2943
|
|
|
2921
2944
|
// packages/cli/src/task-command.ts
|
|
2922
2945
|
import { parseArgs } from "node:util";
|
|
2946
|
+
import path14 from "node:path";
|
|
2923
2947
|
|
|
2924
2948
|
// packages/core/src/branch-name.ts
|
|
2925
2949
|
import os2 from "os";
|
|
@@ -4159,6 +4183,7 @@ async function provisionWorktree(projectPath, workspacePath, taskId, baseBranch,
|
|
|
4159
4183
|
await git(projectPath, [
|
|
4160
4184
|
"worktree",
|
|
4161
4185
|
"add",
|
|
4186
|
+
"--no-track",
|
|
4162
4187
|
"-b",
|
|
4163
4188
|
branch,
|
|
4164
4189
|
worktreePath,
|
|
@@ -4169,20 +4194,9 @@ async function provisionWorktree(projectPath, workspacePath, taskId, baseBranch,
|
|
|
4169
4194
|
await deleteBranch(projectPath, branch);
|
|
4170
4195
|
throw err;
|
|
4171
4196
|
}
|
|
4172
|
-
const
|
|
4173
|
-
(async () => {
|
|
4174
|
-
if (!info.hasRemote) return false;
|
|
4175
|
-
try {
|
|
4176
|
-
await git(worktreePath, ["push", "-u", "origin", branch]);
|
|
4177
|
-
return true;
|
|
4178
|
-
} catch {
|
|
4179
|
-
return false;
|
|
4180
|
-
}
|
|
4181
|
-
})(),
|
|
4182
|
-
copySmallIgnoredFiles(projectPath, worktreePath)
|
|
4183
|
-
]);
|
|
4197
|
+
const ignoredEntries = await copySmallIgnoredFiles(projectPath, worktreePath);
|
|
4184
4198
|
copyIgnoredDependenciesInBackground(projectPath, worktreePath, ignoredEntries);
|
|
4185
|
-
return { branch, worktreePath, pushed, baseBranch: base2 };
|
|
4199
|
+
return { branch, worktreePath, pushed: false, baseBranch: base2 };
|
|
4186
4200
|
}
|
|
4187
4201
|
async function removeWorktree(projectPath, worktreePath) {
|
|
4188
4202
|
try {
|
|
@@ -4407,7 +4421,7 @@ async function commitAndPush(worktreePath, message2) {
|
|
|
4407
4421
|
}
|
|
4408
4422
|
let pushed = false;
|
|
4409
4423
|
try {
|
|
4410
|
-
await git(worktreePath, ["push"]);
|
|
4424
|
+
await git(worktreePath, ["push", "-u", "origin", "HEAD"]);
|
|
4411
4425
|
pushed = true;
|
|
4412
4426
|
} catch {
|
|
4413
4427
|
pushed = false;
|
|
@@ -4626,6 +4640,41 @@ function assertMasterRef(board, masterId, taskId) {
|
|
|
4626
4640
|
if (!isMasterTask(master)) throw taskError(`\u5361\u7247 ${masterId} \u4E0D\u662F master`, "NOT_A_MASTER");
|
|
4627
4641
|
if (taskId && masterId === taskId) throw taskError("\u5361\u7247\u4E0D\u80FD\u6307\u5B9A\u81EA\u5DF1\u70BA master", "NOT_A_MASTER");
|
|
4628
4642
|
}
|
|
4643
|
+
function assertDependencies(board, taskId, masterId, after) {
|
|
4644
|
+
if (after.length === 0) return;
|
|
4645
|
+
if (!masterId) throw taskError("\u53EA\u6709\u96B8\u5C6C master \u7684\u5361\u7247\u53EF\u4EE5\u8A2D\u5B9A --after", "INVALID_DEPENDENCY");
|
|
4646
|
+
const all = Object.values(board).flat();
|
|
4647
|
+
const byId = new Map(all.map((t) => [t.id, t]));
|
|
4648
|
+
for (const id of after) {
|
|
4649
|
+
if (id === taskId) throw taskError("\u5361\u7247\u4E0D\u80FD\u7B49\u5F85\u81EA\u5DF1", "INVALID_DEPENDENCY");
|
|
4650
|
+
const dep = byId.get(id);
|
|
4651
|
+
if (!dep) throw taskError(`\u627E\u4E0D\u5230\u524D\u7F6E\u5361\u7247\uFF1A${id}`, "INVALID_DEPENDENCY");
|
|
4652
|
+
if (dep.masterId !== masterId) throw taskError(`\u524D\u7F6E\u5361\u7247 ${id} \u4E0D\u5C6C\u65BC\u540C\u4E00\u5F35 master`, "INVALID_DEPENDENCY");
|
|
4653
|
+
}
|
|
4654
|
+
const waitsOn = (id) => id === taskId ? after : byId.get(id)?.after ?? [];
|
|
4655
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4656
|
+
const stack = [...after];
|
|
4657
|
+
while (stack.length) {
|
|
4658
|
+
const id = stack.pop();
|
|
4659
|
+
if (id === taskId) throw taskError("\u524D\u7F6E\u5361\u7247\u5F62\u6210\u5FAA\u74B0", "INVALID_DEPENDENCY");
|
|
4660
|
+
if (seen.has(id)) continue;
|
|
4661
|
+
seen.add(id);
|
|
4662
|
+
stack.push(...waitsOn(id));
|
|
4663
|
+
}
|
|
4664
|
+
}
|
|
4665
|
+
function uniqueIds(ids) {
|
|
4666
|
+
return [...new Set((ids ?? []).map((id) => id.trim()).filter(Boolean))];
|
|
4667
|
+
}
|
|
4668
|
+
async function resolveProjects(projects) {
|
|
4669
|
+
const unique = [...new Set((projects ?? []).map((dir) => dir.trim()).filter(Boolean))];
|
|
4670
|
+
for (const dir of unique) {
|
|
4671
|
+
const stat = await fs10.stat(dir).catch(() => null);
|
|
4672
|
+
if (!path13.isAbsolute(dir) || !stat?.isDirectory()) {
|
|
4673
|
+
throw taskError(`\u627E\u4E0D\u5230\u5C08\u6848\u8CC7\u6599\u593E\uFF1A${dir}`, "PROJECT_NOT_FOUND");
|
|
4674
|
+
}
|
|
4675
|
+
}
|
|
4676
|
+
return unique;
|
|
4677
|
+
}
|
|
4629
4678
|
async function assertDirectory(dir) {
|
|
4630
4679
|
const stat = await fs10.stat(dir).catch(() => null);
|
|
4631
4680
|
if (!path13.isAbsolute(dir) || !stat?.isDirectory()) {
|
|
@@ -4634,6 +4683,7 @@ async function assertDirectory(dir) {
|
|
|
4634
4683
|
}
|
|
4635
4684
|
async function createTaskFromInput(input, options = {}) {
|
|
4636
4685
|
if (input.role === "master") return createMasterTask(input);
|
|
4686
|
+
if (input.projects?.length) throw taskError("\u76F8\u95DC\u5C08\u6848\u53EA\u80FD\u8A2D\u5B9A\u5728 master \u5361\u7247", "INVALID_ARGUMENT");
|
|
4637
4687
|
const projectPath = input.projectPath;
|
|
4638
4688
|
if (!projectPath) throw taskError("\u5C1A\u672A\u9078\u64C7\u5C08\u6848\u8CC7\u6599\u593E", "PROJECT_NOT_FOUND");
|
|
4639
4689
|
try {
|
|
@@ -4653,6 +4703,8 @@ async function createTaskFromInput(input, options = {}) {
|
|
|
4653
4703
|
const explicitBranch = noBranch ? null : input.branch?.trim() || null;
|
|
4654
4704
|
const store = input.storePath ? getStoreAtPath(input.storePath) : getStore();
|
|
4655
4705
|
if (input.masterId) assertMasterRef(store.get("board"), input.masterId);
|
|
4706
|
+
const after = uniqueIds(input.after);
|
|
4707
|
+
assertDependencies(store.get("board"), taskId, input.masterId, after);
|
|
4656
4708
|
const projectName = path13.basename(projectPath);
|
|
4657
4709
|
const workspacePath = projectWorkstationPath(
|
|
4658
4710
|
resolveWorkstationPath(store.get("settings")),
|
|
@@ -4696,6 +4748,7 @@ async function createTaskFromInput(input, options = {}) {
|
|
|
4696
4748
|
effort: input.effort ?? DEFAULT_TASK_EFFORT,
|
|
4697
4749
|
autoMode: input.autoMode,
|
|
4698
4750
|
...input.masterId ? { masterId: input.masterId } : {},
|
|
4751
|
+
...after.length ? { after } : {},
|
|
4699
4752
|
...input.github ? { github: input.github } : {},
|
|
4700
4753
|
...input.jira ? { jira: input.jira } : {}
|
|
4701
4754
|
};
|
|
@@ -4714,8 +4767,10 @@ async function createTaskFromInput(input, options = {}) {
|
|
|
4714
4767
|
}
|
|
4715
4768
|
async function createMasterTask(input) {
|
|
4716
4769
|
if (input.masterId) throw taskError("master \u5361\u7247\u4E0D\u80FD\u518D\u96B8\u5C6C\u5176\u4ED6 master", "NOT_A_MASTER");
|
|
4770
|
+
if (input.after?.length) throw taskError("master \u5361\u7247\u4E0D\u80FD\u8A2D\u5B9A --after", "INVALID_DEPENDENCY");
|
|
4717
4771
|
const workDir = input.workDir?.trim() || void 0;
|
|
4718
4772
|
if (workDir) await assertDirectory(workDir);
|
|
4773
|
+
const projects = await resolveProjects(input.projects);
|
|
4719
4774
|
const store = input.storePath ? getStoreAtPath(input.storePath) : getStore();
|
|
4720
4775
|
const taskId = randomUUID2().slice(0, 8);
|
|
4721
4776
|
const workspacePath = path13.join(mastersRoot(store.path), taskId);
|
|
@@ -4725,7 +4780,8 @@ async function createMasterTask(input) {
|
|
|
4725
4780
|
branch: "",
|
|
4726
4781
|
role: "master",
|
|
4727
4782
|
workspacePath,
|
|
4728
|
-
...workDir ? { workDir } : {}
|
|
4783
|
+
...workDir ? { workDir } : {},
|
|
4784
|
+
...projects.length ? { projects } : {}
|
|
4729
4785
|
};
|
|
4730
4786
|
const col = input.status ?? "backlog";
|
|
4731
4787
|
const provisioned = col === "backlog" ? null : await provisionTaskWorktree(draft);
|
|
@@ -4827,12 +4883,17 @@ function updateTaskFromInput(input) {
|
|
|
4827
4883
|
}
|
|
4828
4884
|
const title = input.title?.trim();
|
|
4829
4885
|
const description = input.description?.trim();
|
|
4886
|
+
const masterId = input.masterId !== void 0 ? input.masterId || void 0 : current.masterId;
|
|
4887
|
+
const after = input.after !== void 0 ? uniqueIds(input.after) : masterId === current.masterId ? current.after ?? [] : [];
|
|
4888
|
+
assertDependencies(board, current.id, masterId, after);
|
|
4830
4889
|
const task = {
|
|
4831
4890
|
...current,
|
|
4832
4891
|
...title ? { title } : {},
|
|
4833
4892
|
...input.description !== void 0 ? { description: description || void 0 } : {},
|
|
4834
|
-
...input.masterId !== void 0 ? { masterId
|
|
4893
|
+
...input.masterId !== void 0 ? { masterId } : {},
|
|
4894
|
+
...after.length ? { after } : {}
|
|
4835
4895
|
};
|
|
4896
|
+
if (!after.length) delete task.after;
|
|
4836
4897
|
const to = input.status ?? from;
|
|
4837
4898
|
if (to === from) {
|
|
4838
4899
|
board[from] = board[from].map((t) => t.id === task.id ? task : t);
|
|
@@ -4989,11 +5050,16 @@ Usage:
|
|
|
4989
5050
|
task create options:
|
|
4990
5051
|
--role <role> ${ROLES.join(" | ")} (default: slave). A master has no project:
|
|
4991
5052
|
it runs in its own folder and dispatches other cards.
|
|
4992
|
-
--project <path> Target project directory (required for a slave)
|
|
5053
|
+
--project <path> Target project directory (required for a slave). For a
|
|
5054
|
+
master: a related project its agent may read while
|
|
5055
|
+
planning; repeat the flag for several
|
|
4993
5056
|
--work-dir <path> Master only: run in this existing folder (git or not)
|
|
4994
5057
|
instead of one VibeFlow creates
|
|
4995
5058
|
--master <id> Dispatch the new card under this master card (default: the
|
|
4996
5059
|
calling card, when a master runs this from its own shell)
|
|
5060
|
+
--after <id> Start this card only once that card of the same master is
|
|
5061
|
+
Done (repeat for several); the host starts it then when the
|
|
5062
|
+
master runs in auto mode
|
|
4997
5063
|
--title <text> Task title (required)
|
|
4998
5064
|
--prompt <text> Task prompt / description (required)
|
|
4999
5065
|
--status <column> ${STATUSES.join(" | ")} (default: backlog)
|
|
@@ -5020,10 +5086,12 @@ task update options:
|
|
|
5020
5086
|
--prompt <text> New card description (empty string clears it)
|
|
5021
5087
|
--status <column> ${STATUSES.join(" | ")} \u2014 moves the card between columns
|
|
5022
5088
|
--master <id|none> Put the card under a master, or "none" to take it out
|
|
5089
|
+
--after <id|none> Cards of the same master this one waits on (repeat for
|
|
5090
|
+
several), or "none" to clear them
|
|
5023
5091
|
--store-path <dir> Explicit store directory
|
|
5024
5092
|
--profile <name> dev | prod \u2014 shorthand for common store paths
|
|
5025
5093
|
|
|
5026
|
-
At least one of --title / --prompt / --status / --master is required. Branch,
|
|
5094
|
+
At least one of --title / --prompt / --status / --master / --after is required. Branch,
|
|
5027
5095
|
worktree and project path are provisioned on disk and cannot be changed here.
|
|
5028
5096
|
|
|
5029
5097
|
task start / list / show / send (need the running VibeFlow host):
|
|
@@ -5104,7 +5172,8 @@ async function taskCommand(argv) {
|
|
|
5104
5172
|
parsed = parseArgs({
|
|
5105
5173
|
args: argv,
|
|
5106
5174
|
options: {
|
|
5107
|
-
project: { type: "string" },
|
|
5175
|
+
project: { type: "string", multiple: true },
|
|
5176
|
+
after: { type: "string", multiple: true },
|
|
5108
5177
|
role: { type: "string" },
|
|
5109
5178
|
"work-dir": { type: "string" },
|
|
5110
5179
|
master: { type: "string" },
|
|
@@ -5161,15 +5230,17 @@ async function taskCommand(argv) {
|
|
|
5161
5230
|
if (sub === "update") {
|
|
5162
5231
|
if (!values.task) fail("MISSING_ARGUMENT", "Missing required arguments: --task");
|
|
5163
5232
|
requireOneOf("--status", values.status, STATUSES);
|
|
5164
|
-
if (values.title === void 0 && values.prompt === void 0 && values.status === void 0 && values.master === void 0) {
|
|
5165
|
-
fail("MISSING_ARGUMENT", "task update needs at least one of: --title, --prompt, --status, --master");
|
|
5233
|
+
if (values.title === void 0 && values.prompt === void 0 && values.status === void 0 && values.master === void 0 && values.after === void 0) {
|
|
5234
|
+
fail("MISSING_ARGUMENT", "task update needs at least one of: --title, --prompt, --status, --master, --after");
|
|
5166
5235
|
}
|
|
5236
|
+
if (values.project !== void 0) fail("INVALID_ARGUMENT", "task update cannot change --project");
|
|
5167
5237
|
const { task: task2, storePath: resolvedPath2 } = updateTaskFromInput({
|
|
5168
5238
|
taskId: values.task,
|
|
5169
5239
|
title: values.title,
|
|
5170
5240
|
description: values.prompt,
|
|
5171
5241
|
status: values.status,
|
|
5172
5242
|
masterId: values.master === void 0 ? void 0 : values.master === "none" ? null : values.master,
|
|
5243
|
+
after: values.after === void 0 ? void 0 : values.after.filter((id) => id !== "none"),
|
|
5173
5244
|
storePath
|
|
5174
5245
|
});
|
|
5175
5246
|
return {
|
|
@@ -5180,16 +5251,19 @@ async function taskCommand(argv) {
|
|
|
5180
5251
|
description: task2.description,
|
|
5181
5252
|
branch: task2.branch,
|
|
5182
5253
|
worktreePath: task2.worktreePath ?? null,
|
|
5183
|
-
masterId: task2.masterId ?? null
|
|
5254
|
+
masterId: task2.masterId ?? null,
|
|
5255
|
+
after: task2.after ?? []
|
|
5184
5256
|
}
|
|
5185
5257
|
};
|
|
5186
5258
|
}
|
|
5187
5259
|
requireOneOf("--role", values.role, ROLES);
|
|
5188
5260
|
const master = values.role === "master";
|
|
5189
5261
|
if (!master && values["work-dir"] !== void 0) fail("INVALID_ARGUMENT", "--work-dir is only for --role master");
|
|
5190
|
-
if (master && (values
|
|
5191
|
-
fail("INVALID_ARGUMENT", "A master card has no project: drop --
|
|
5262
|
+
if (master && (values["base-branch"] || values.branch || values.mode)) {
|
|
5263
|
+
fail("INVALID_ARGUMENT", "A master card has no project of its own: drop --base-branch / --branch / --mode");
|
|
5192
5264
|
}
|
|
5265
|
+
if (master && values.after) fail("INVALID_ARGUMENT", "A master card cannot wait on other cards: drop --after");
|
|
5266
|
+
if (!master && (values.project?.length ?? 0) > 1) fail("INVALID_ARGUMENT", "A card has one project: give --project once");
|
|
5193
5267
|
if (master && values["no-branch"]) fail("INVALID_ARGUMENT", "A master card has no branch already: drop --no-branch");
|
|
5194
5268
|
if (values["no-branch"] && values.branch !== void 0) fail("INVALID_ARGUMENT", "--branch and --no-branch cannot be used together");
|
|
5195
5269
|
const missing = [];
|
|
@@ -5211,7 +5285,9 @@ async function taskCommand(argv) {
|
|
|
5211
5285
|
const caller = process.env.VIBEFLOW_TASK_ID ? findTask(process.env.VIBEFLOW_TASK_ID) : void 0;
|
|
5212
5286
|
const masterId = values.master ?? (!master && caller && isMasterTask(caller) ? caller.id : void 0);
|
|
5213
5287
|
const { task, storePath: resolvedPath } = await createTaskFromInput({
|
|
5214
|
-
projectPath: values.project,
|
|
5288
|
+
projectPath: master ? void 0 : values.project?.[0],
|
|
5289
|
+
projects: master ? values.project?.map((dir) => path14.resolve(dir)) : void 0,
|
|
5290
|
+
after: values.after,
|
|
5215
5291
|
role: master ? "master" : void 0,
|
|
5216
5292
|
workDir: values["work-dir"],
|
|
5217
5293
|
masterId,
|
|
@@ -5236,6 +5312,8 @@ async function taskCommand(argv) {
|
|
|
5236
5312
|
title: task.title,
|
|
5237
5313
|
role: task.role ?? "slave",
|
|
5238
5314
|
masterId: task.masterId ?? null,
|
|
5315
|
+
after: task.after ?? [],
|
|
5316
|
+
projects: task.projects ?? [],
|
|
5239
5317
|
projectPath: task.projectPath ?? null,
|
|
5240
5318
|
branch: task.branch,
|
|
5241
5319
|
noBranch: task.noBranch === true,
|
|
@@ -5295,7 +5373,7 @@ async function hostCommand(sub, values, storePath) {
|
|
|
5295
5373
|
|
|
5296
5374
|
// packages/cli/src/host.ts
|
|
5297
5375
|
import fs27 from "fs";
|
|
5298
|
-
import
|
|
5376
|
+
import path29 from "path";
|
|
5299
5377
|
import { randomBytes as randomBytes2 } from "crypto";
|
|
5300
5378
|
|
|
5301
5379
|
// packages/core/src/events.ts
|
|
@@ -5323,13 +5401,13 @@ var EventBus = class {
|
|
|
5323
5401
|
|
|
5324
5402
|
// packages/core/src/library-builtins.ts
|
|
5325
5403
|
import fs12 from "fs";
|
|
5326
|
-
import
|
|
5404
|
+
import path16 from "path";
|
|
5327
5405
|
|
|
5328
5406
|
// packages/core/src/library.ts
|
|
5329
5407
|
import { createHash } from "crypto";
|
|
5330
5408
|
import fs11 from "fs";
|
|
5331
5409
|
import os3 from "os";
|
|
5332
|
-
import
|
|
5410
|
+
import path15 from "path";
|
|
5333
5411
|
var LIBRARY_DIR = "library";
|
|
5334
5412
|
var LIBRARY_KINDS = ["skill", "prompt", "script"];
|
|
5335
5413
|
var KIND_DIR = {
|
|
@@ -5342,15 +5420,15 @@ var MAX_NAME_BYTES = 100;
|
|
|
5342
5420
|
function libraryPaths(root) {
|
|
5343
5421
|
return {
|
|
5344
5422
|
root,
|
|
5345
|
-
skills:
|
|
5346
|
-
prompts:
|
|
5347
|
-
scripts:
|
|
5348
|
-
plugin:
|
|
5349
|
-
codexHome:
|
|
5423
|
+
skills: path15.join(root, KIND_DIR.skill),
|
|
5424
|
+
prompts: path15.join(root, KIND_DIR.prompt),
|
|
5425
|
+
scripts: path15.join(root, KIND_DIR.script),
|
|
5426
|
+
plugin: path15.join(root, "plugin"),
|
|
5427
|
+
codexHome: path15.join(root, "codex-home")
|
|
5350
5428
|
};
|
|
5351
5429
|
}
|
|
5352
5430
|
async function libraryRoot() {
|
|
5353
|
-
return
|
|
5431
|
+
return path15.join(getPlatform().userDataDir(), LIBRARY_DIR);
|
|
5354
5432
|
}
|
|
5355
5433
|
function truncateUtf82(value, maxBytes) {
|
|
5356
5434
|
let result = "";
|
|
@@ -5372,7 +5450,7 @@ function entryKey(kind, name) {
|
|
|
5372
5450
|
return `${kind}/${name}`;
|
|
5373
5451
|
}
|
|
5374
5452
|
function indexPath(root) {
|
|
5375
|
-
return
|
|
5453
|
+
return path15.join(root, INDEX_FILE);
|
|
5376
5454
|
}
|
|
5377
5455
|
function readIndexFile(root) {
|
|
5378
5456
|
let raw;
|
|
@@ -5409,7 +5487,7 @@ function writeIndex(root, index) {
|
|
|
5409
5487
|
function ensureLibrary(root) {
|
|
5410
5488
|
const paths = libraryPaths(root);
|
|
5411
5489
|
for (const kind of LIBRARY_KINDS) {
|
|
5412
|
-
fs11.mkdirSync(
|
|
5490
|
+
fs11.mkdirSync(path15.join(root, KIND_DIR[kind]), { recursive: true });
|
|
5413
5491
|
}
|
|
5414
5492
|
return paths;
|
|
5415
5493
|
}
|
|
@@ -5431,23 +5509,23 @@ function readSkillDescription(skillMdPath) {
|
|
|
5431
5509
|
return void 0;
|
|
5432
5510
|
}
|
|
5433
5511
|
function entryPath(root, kind, name) {
|
|
5434
|
-
return
|
|
5512
|
+
return path15.join(root, KIND_DIR[kind], name);
|
|
5435
5513
|
}
|
|
5436
5514
|
var HASH_IGNORED = /* @__PURE__ */ new Set(["__pycache__", ".DS_Store"]);
|
|
5437
5515
|
function hashSkillDir(dir) {
|
|
5438
5516
|
const files = [];
|
|
5439
5517
|
const walk = (rel) => {
|
|
5440
|
-
for (const dirent of fs11.readdirSync(
|
|
5518
|
+
for (const dirent of fs11.readdirSync(path15.join(dir, rel), { withFileTypes: true })) {
|
|
5441
5519
|
if (HASH_IGNORED.has(dirent.name)) continue;
|
|
5442
5520
|
const child = rel ? `${rel}/${dirent.name}` : dirent.name;
|
|
5443
|
-
if (fs11.statSync(
|
|
5521
|
+
if (fs11.statSync(path15.join(dir, child)).isDirectory()) walk(child);
|
|
5444
5522
|
else files.push(child);
|
|
5445
5523
|
}
|
|
5446
5524
|
};
|
|
5447
5525
|
walk("");
|
|
5448
5526
|
const hash = createHash("sha256");
|
|
5449
5527
|
for (const rel of files.sort()) {
|
|
5450
|
-
hash.update(rel).update("\0").update(fs11.readFileSync(
|
|
5528
|
+
hash.update(rel).update("\0").update(fs11.readFileSync(path15.join(dir, rel))).update("\0");
|
|
5451
5529
|
}
|
|
5452
5530
|
return hash.digest("hex");
|
|
5453
5531
|
}
|
|
@@ -5456,8 +5534,8 @@ function builtinStatus(full, name, recorded, builtinDir) {
|
|
|
5456
5534
|
const modified = hashSkillDir(full) !== recorded;
|
|
5457
5535
|
let updateAvailable = false;
|
|
5458
5536
|
if (modified && builtinDir) {
|
|
5459
|
-
const shipped =
|
|
5460
|
-
if (fs11.existsSync(
|
|
5537
|
+
const shipped = path15.join(builtinDir, name);
|
|
5538
|
+
if (fs11.existsSync(path15.join(shipped, "SKILL.md"))) {
|
|
5461
5539
|
updateAvailable = hashSkillDir(shipped) !== recorded;
|
|
5462
5540
|
}
|
|
5463
5541
|
}
|
|
@@ -5470,7 +5548,7 @@ function listLibrary(root, builtinDir) {
|
|
|
5470
5548
|
const index = readIndex(root);
|
|
5471
5549
|
const entries = [];
|
|
5472
5550
|
for (const kind of LIBRARY_KINDS) {
|
|
5473
|
-
const dir =
|
|
5551
|
+
const dir = path15.join(root, KIND_DIR[kind]);
|
|
5474
5552
|
let dirents;
|
|
5475
5553
|
try {
|
|
5476
5554
|
dirents = fs11.readdirSync(dir, { withFileTypes: true });
|
|
@@ -5482,14 +5560,14 @@ function listLibrary(root, builtinDir) {
|
|
|
5482
5560
|
const wantsDirectory = kind === "skill";
|
|
5483
5561
|
let stat;
|
|
5484
5562
|
try {
|
|
5485
|
-
stat = fs11.statSync(
|
|
5563
|
+
stat = fs11.statSync(path15.join(dir, dirent.name));
|
|
5486
5564
|
} catch {
|
|
5487
5565
|
continue;
|
|
5488
5566
|
}
|
|
5489
5567
|
if (stat.isDirectory() !== wantsDirectory) continue;
|
|
5490
5568
|
const name = dirent.name;
|
|
5491
|
-
const full =
|
|
5492
|
-
if (wantsDirectory && !fs11.existsSync(
|
|
5569
|
+
const full = path15.join(dir, name);
|
|
5570
|
+
if (wantsDirectory && !fs11.existsSync(path15.join(full, "SKILL.md"))) continue;
|
|
5493
5571
|
const key = entryKey(kind, name);
|
|
5494
5572
|
const record2 = index.entries[key] ?? {};
|
|
5495
5573
|
entries.push({
|
|
@@ -5497,7 +5575,7 @@ function listLibrary(root, builtinDir) {
|
|
|
5497
5575
|
kind,
|
|
5498
5576
|
name,
|
|
5499
5577
|
path: full,
|
|
5500
|
-
description: wantsDirectory ? readSkillDescription(
|
|
5578
|
+
description: wantsDirectory ? readSkillDescription(path15.join(full, "SKILL.md")) : record2.description,
|
|
5501
5579
|
sourcePath: record2.sourcePath,
|
|
5502
5580
|
importedAt: record2.importedAt,
|
|
5503
5581
|
enabled: record2.enabled !== false,
|
|
@@ -5514,17 +5592,17 @@ function annotate(root, key, patch) {
|
|
|
5514
5592
|
}
|
|
5515
5593
|
function importEntry(root, kind, sourcePath) {
|
|
5516
5594
|
ensureLibrary(root);
|
|
5517
|
-
const resolved =
|
|
5595
|
+
const resolved = path15.resolve(sourcePath);
|
|
5518
5596
|
const stat = fs11.statSync(resolved);
|
|
5519
5597
|
if (kind === "skill") {
|
|
5520
5598
|
if (!stat.isDirectory()) throw new Error("skill \u5FC5\u9808\u662F\u542B SKILL.md \u7684\u76EE\u9304");
|
|
5521
|
-
if (!fs11.existsSync(
|
|
5599
|
+
if (!fs11.existsSync(path15.join(resolved, "SKILL.md"))) {
|
|
5522
5600
|
throw new Error("\u76EE\u9304\u5167\u627E\u4E0D\u5230 SKILL.md");
|
|
5523
5601
|
}
|
|
5524
5602
|
} else if (!stat.isFile()) {
|
|
5525
5603
|
throw new Error(`${kind} \u5FC5\u9808\u662F\u55AE\u4E00\u6A94\u6848`);
|
|
5526
5604
|
}
|
|
5527
|
-
const name = safeLibraryName(
|
|
5605
|
+
const name = safeLibraryName(path15.basename(resolved));
|
|
5528
5606
|
const target = entryPath(root, kind, name);
|
|
5529
5607
|
fs11.rmSync(target, { recursive: true, force: true });
|
|
5530
5608
|
fs11.cpSync(resolved, target, { recursive: kind === "skill", dereference: true });
|
|
@@ -5543,7 +5621,7 @@ function createEntry(root, kind, rawName, content, description) {
|
|
|
5543
5621
|
if (fs11.existsSync(target)) throw new Error(`\u5DF2\u5B58\u5728\u540C\u540D\u9805\u76EE\uFF1A${name}`);
|
|
5544
5622
|
if (kind === "skill") {
|
|
5545
5623
|
fs11.mkdirSync(target, { recursive: true });
|
|
5546
|
-
fs11.writeFileSync(
|
|
5624
|
+
fs11.writeFileSync(path15.join(target, "SKILL.md"), content);
|
|
5547
5625
|
} else {
|
|
5548
5626
|
fs11.writeFileSync(target, content);
|
|
5549
5627
|
if (kind === "script") fs11.chmodSync(target, 493);
|
|
@@ -5561,12 +5639,12 @@ function setEntryDescription(root, kind, name, description) {
|
|
|
5561
5639
|
function updateEntry(root, kind, name, content) {
|
|
5562
5640
|
const target = entryPath(root, kind, name);
|
|
5563
5641
|
if (!fs11.existsSync(target)) throw new Error(`\u627E\u4E0D\u5230\u9805\u76EE\uFF1A${name}`);
|
|
5564
|
-
fs11.writeFileSync(kind === "skill" ?
|
|
5642
|
+
fs11.writeFileSync(kind === "skill" ? path15.join(target, "SKILL.md") : target, content);
|
|
5565
5643
|
return requireEntry(root, kind, name);
|
|
5566
5644
|
}
|
|
5567
5645
|
function readEntryContent(root, kind, name) {
|
|
5568
5646
|
const target = entryPath(root, kind, name);
|
|
5569
|
-
return fs11.readFileSync(kind === "skill" ?
|
|
5647
|
+
return fs11.readFileSync(kind === "skill" ? path15.join(target, "SKILL.md") : target, "utf8");
|
|
5570
5648
|
}
|
|
5571
5649
|
function markBuiltinDeleted(root, key) {
|
|
5572
5650
|
const index = readIndex(root);
|
|
@@ -5595,23 +5673,23 @@ function requireEntry(root, kind, name) {
|
|
|
5595
5673
|
}
|
|
5596
5674
|
function skillNamesIn(dir) {
|
|
5597
5675
|
try {
|
|
5598
|
-
return fs11.readdirSync(dir, { withFileTypes: true }).filter((d) => !d.name.startsWith(".")).map((d) => d.name).filter((name) => fs11.existsSync(
|
|
5676
|
+
return fs11.readdirSync(dir, { withFileTypes: true }).filter((d) => !d.name.startsWith(".")).map((d) => d.name).filter((name) => fs11.existsSync(path15.join(dir, name, "SKILL.md"))).sort();
|
|
5599
5677
|
} catch {
|
|
5600
5678
|
return [];
|
|
5601
5679
|
}
|
|
5602
5680
|
}
|
|
5603
5681
|
function projectSkillsDir(worktreePath) {
|
|
5604
|
-
return
|
|
5682
|
+
return path15.join(worktreePath, ".claude", "skills");
|
|
5605
5683
|
}
|
|
5606
5684
|
var PLUGIN_MANIFEST_DIR = ".claude-plugin";
|
|
5607
5685
|
function buildPluginDir(root) {
|
|
5608
5686
|
const paths = libraryPaths(root);
|
|
5609
5687
|
const enabled = listLibrary(root).filter((e) => e.kind === "skill" && e.enabled);
|
|
5610
|
-
fs11.rmSync(
|
|
5611
|
-
fs11.mkdirSync(
|
|
5612
|
-
fs11.mkdirSync(
|
|
5688
|
+
fs11.rmSync(path15.join(paths.plugin, "skills"), { recursive: true, force: true });
|
|
5689
|
+
fs11.mkdirSync(path15.join(paths.plugin, PLUGIN_MANIFEST_DIR), { recursive: true });
|
|
5690
|
+
fs11.mkdirSync(path15.join(paths.plugin, "skills"), { recursive: true });
|
|
5613
5691
|
fs11.writeFileSync(
|
|
5614
|
-
|
|
5692
|
+
path15.join(paths.plugin, PLUGIN_MANIFEST_DIR, "plugin.json"),
|
|
5615
5693
|
`${JSON.stringify(
|
|
5616
5694
|
{
|
|
5617
5695
|
name: "vibeflow-library",
|
|
@@ -5624,7 +5702,7 @@ function buildPluginDir(root) {
|
|
|
5624
5702
|
`
|
|
5625
5703
|
);
|
|
5626
5704
|
for (const entry of enabled) {
|
|
5627
|
-
fs11.cpSync(entry.path,
|
|
5705
|
+
fs11.cpSync(entry.path, path15.join(paths.plugin, "skills", entry.name), {
|
|
5628
5706
|
recursive: true,
|
|
5629
5707
|
dereference: true
|
|
5630
5708
|
});
|
|
@@ -5633,7 +5711,7 @@ function buildPluginDir(root) {
|
|
|
5633
5711
|
}
|
|
5634
5712
|
function linkOrSkip(target, linkPath) {
|
|
5635
5713
|
if (!fs11.existsSync(target)) return false;
|
|
5636
|
-
const source =
|
|
5714
|
+
const source = path15.resolve(target);
|
|
5637
5715
|
const attempts = fs11.statSync(source).isDirectory() ? [
|
|
5638
5716
|
() => fs11.symlinkSync(source, linkPath, "junction"),
|
|
5639
5717
|
() => fs11.cpSync(source, linkPath, { recursive: true, dereference: true })
|
|
@@ -5652,13 +5730,13 @@ function linkOrSkip(target, linkPath) {
|
|
|
5652
5730
|
}
|
|
5653
5731
|
return false;
|
|
5654
5732
|
}
|
|
5655
|
-
function buildCodexHome(root, worktreePath, userCodexHome =
|
|
5733
|
+
function buildCodexHome(root, worktreePath, userCodexHome = path15.join(os3.homedir(), ".codex")) {
|
|
5656
5734
|
const paths = libraryPaths(root);
|
|
5657
|
-
const skillsDir =
|
|
5735
|
+
const skillsDir = path15.join(paths.codexHome, "skills");
|
|
5658
5736
|
fs11.rmSync(skillsDir, { recursive: true, force: true });
|
|
5659
5737
|
fs11.mkdirSync(skillsDir, { recursive: true });
|
|
5660
5738
|
for (const file of ["auth.json", "config.toml"]) {
|
|
5661
|
-
linkOrSkip(
|
|
5739
|
+
linkOrSkip(path15.join(userCodexHome, file), path15.join(paths.codexHome, file));
|
|
5662
5740
|
}
|
|
5663
5741
|
const result = {
|
|
5664
5742
|
codexHome: paths.codexHome,
|
|
@@ -5671,20 +5749,20 @@ function buildCodexHome(root, worktreePath, userCodexHome = path14.join(os3.home
|
|
|
5671
5749
|
const projectDir = worktreePath ? projectSkillsDir(worktreePath) : void 0;
|
|
5672
5750
|
if (projectDir) {
|
|
5673
5751
|
for (const name of skillNamesIn(projectDir)) {
|
|
5674
|
-
if (linkOrSkip(
|
|
5752
|
+
if (linkOrSkip(path15.join(projectDir, name), path15.join(skillsDir, name))) {
|
|
5675
5753
|
result.project.push(name);
|
|
5676
5754
|
claimed.set(name, "project");
|
|
5677
5755
|
}
|
|
5678
5756
|
}
|
|
5679
5757
|
}
|
|
5680
|
-
const userDir =
|
|
5758
|
+
const userDir = path15.join(userCodexHome, "skills");
|
|
5681
5759
|
for (const name of skillNamesIn(userDir)) {
|
|
5682
5760
|
const owner = claimed.get(name);
|
|
5683
5761
|
if (owner) {
|
|
5684
5762
|
result.shadowed.push({ name, keptFrom: owner, dropped: "user" });
|
|
5685
5763
|
continue;
|
|
5686
5764
|
}
|
|
5687
|
-
if (linkOrSkip(
|
|
5765
|
+
if (linkOrSkip(path15.join(userDir, name), path15.join(skillsDir, name))) {
|
|
5688
5766
|
result.user.push(name);
|
|
5689
5767
|
claimed.set(name, "user");
|
|
5690
5768
|
}
|
|
@@ -5696,7 +5774,7 @@ function buildCodexHome(root, worktreePath, userCodexHome = path14.join(os3.home
|
|
|
5696
5774
|
result.shadowed.push({ name: entry.name, keptFrom: owner, dropped: "library" });
|
|
5697
5775
|
continue;
|
|
5698
5776
|
}
|
|
5699
|
-
fs11.cpSync(entry.path,
|
|
5777
|
+
fs11.cpSync(entry.path, path15.join(skillsDir, entry.name), {
|
|
5700
5778
|
recursive: true,
|
|
5701
5779
|
dereference: true
|
|
5702
5780
|
});
|
|
@@ -5739,10 +5817,10 @@ function installBuiltin(root, builtinDir, name) {
|
|
|
5739
5817
|
const staging = entryPath(root, "skill", `.${name}.installing`);
|
|
5740
5818
|
fs12.rmSync(staging, { recursive: true, force: true });
|
|
5741
5819
|
try {
|
|
5742
|
-
fs12.cpSync(
|
|
5820
|
+
fs12.cpSync(path16.join(builtinDir, name), staging, {
|
|
5743
5821
|
recursive: true,
|
|
5744
5822
|
dereference: true,
|
|
5745
|
-
filter: (src) =>
|
|
5823
|
+
filter: (src) => path16.basename(src) !== "__pycache__"
|
|
5746
5824
|
});
|
|
5747
5825
|
fs12.rmSync(target, { recursive: true, force: true });
|
|
5748
5826
|
fs12.renameSync(staging, target);
|
|
@@ -5785,11 +5863,11 @@ function syncOne(root, builtinDir, name, result) {
|
|
|
5785
5863
|
result.installed.push(name);
|
|
5786
5864
|
return;
|
|
5787
5865
|
}
|
|
5788
|
-
if (!fs12.existsSync(
|
|
5866
|
+
if (!fs12.existsSync(path16.join(target, "SKILL.md"))) {
|
|
5789
5867
|
markBuiltinDeleted(root, key);
|
|
5790
5868
|
return;
|
|
5791
5869
|
}
|
|
5792
|
-
if (hashSkillDir(
|
|
5870
|
+
if (hashSkillDir(path16.join(builtinDir, name)) === record2.builtinHash) return;
|
|
5793
5871
|
if (hashSkillDir(target) !== record2.builtinHash) return;
|
|
5794
5872
|
annotate(root, key, { builtinHash: installBuiltin(root, builtinDir, name) });
|
|
5795
5873
|
result.updated.push(name);
|
|
@@ -5839,7 +5917,7 @@ import fs23 from "fs";
|
|
|
5839
5917
|
import { constants } from "fs";
|
|
5840
5918
|
import fs13 from "fs/promises";
|
|
5841
5919
|
import os4 from "os";
|
|
5842
|
-
import
|
|
5920
|
+
import path17 from "path";
|
|
5843
5921
|
import { fileURLToPath } from "url";
|
|
5844
5922
|
var MAX_PREVIEW_IMAGE_BYTES = 20 * 1024 * 1024;
|
|
5845
5923
|
var MAX_TEXT_BYTES2 = 256 * 1024;
|
|
@@ -5863,9 +5941,9 @@ function resolveTerminalFile(cwd, input) {
|
|
|
5863
5941
|
} else if (/^[a-z][a-z\d+.-]*:/i.test(target) && !/^[a-z]:[\\/]/i.test(target)) {
|
|
5864
5942
|
throw new Error("\u53EA\u652F\u63F4\u672C\u6A5F\u6A94\u6848\u8DEF\u5F91\u3002");
|
|
5865
5943
|
}
|
|
5866
|
-
if (target.startsWith("~/") || target.startsWith("~\\")) target =
|
|
5944
|
+
if (target.startsWith("~/") || target.startsWith("~\\")) target = path17.join(os4.homedir(), target.slice(2));
|
|
5867
5945
|
if (target.includes("\0")) throw new Error("\u6A94\u6848\u8DEF\u5F91\u7121\u6548\u3002");
|
|
5868
|
-
return
|
|
5946
|
+
return path17.resolve(cwd, target);
|
|
5869
5947
|
}
|
|
5870
5948
|
var MAX_FILE_CANDIDATES = 128;
|
|
5871
5949
|
async function existingTerminalFiles(cwd, inputs) {
|
|
@@ -5892,7 +5970,7 @@ async function readTerminalFile(cwd, input, metadataOnly = false) {
|
|
|
5892
5970
|
const stat = await handle.stat();
|
|
5893
5971
|
if (!stat.isFile()) return { ok: false, error: "not_file", message: "\u9019\u500B\u8DEF\u5F91\u4E0D\u662F\u4E00\u822C\u6A94\u6848\u3002" };
|
|
5894
5972
|
if (metadataOnly) return { ok: true, path: target, kind: "binary", reason: "" };
|
|
5895
|
-
const extension =
|
|
5973
|
+
const extension = path17.extname(target).toLowerCase();
|
|
5896
5974
|
const imageMime = IMAGE_MIME2[extension];
|
|
5897
5975
|
const videoMime = VIDEO_MIME[extension];
|
|
5898
5976
|
const mime = imageMime ?? videoMime;
|
|
@@ -5926,19 +6004,19 @@ async function readTerminalFile(cwd, input, metadataOnly = false) {
|
|
|
5926
6004
|
|
|
5927
6005
|
// packages/core/src/service.ts
|
|
5928
6006
|
import os9 from "os";
|
|
5929
|
-
import
|
|
6007
|
+
import path25 from "path";
|
|
5930
6008
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
5931
6009
|
|
|
5932
6010
|
// packages/core/src/agent-models.ts
|
|
5933
6011
|
import fs15 from "fs";
|
|
5934
6012
|
import os7 from "os";
|
|
5935
|
-
import
|
|
6013
|
+
import path19 from "path";
|
|
5936
6014
|
|
|
5937
6015
|
// packages/core/src/claude-models.ts
|
|
5938
6016
|
init_effort();
|
|
5939
6017
|
import fs14 from "fs";
|
|
5940
6018
|
import os5 from "os";
|
|
5941
|
-
import
|
|
6019
|
+
import path18 from "path";
|
|
5942
6020
|
|
|
5943
6021
|
// packages/core/src/json-lines-process.ts
|
|
5944
6022
|
import { spawn as spawn4 } from "child_process";
|
|
@@ -6042,7 +6120,7 @@ var CLAUDE_MODELS_TIMEOUT_MS = 15e3;
|
|
|
6042
6120
|
var REQUEST_ID = "vibeflow-models";
|
|
6043
6121
|
var CLAUDE_ARGS = ["-p", "--input-format", "stream-json", "--output-format", "stream-json", "--verbose"];
|
|
6044
6122
|
function openClaude() {
|
|
6045
|
-
const cwd = fs14.mkdtempSync(
|
|
6123
|
+
const cwd = fs14.mkdtempSync(path18.join(os5.tmpdir(), "vf-claude-models-"));
|
|
6046
6124
|
return spawnJsonLines("claude", CLAUDE_ARGS, {
|
|
6047
6125
|
cwd,
|
|
6048
6126
|
timeoutMs: CLAUDE_MODELS_TIMEOUT_MS,
|
|
@@ -6195,7 +6273,7 @@ function builtinModels(id) {
|
|
|
6195
6273
|
}
|
|
6196
6274
|
function defaultCodexHome() {
|
|
6197
6275
|
const configured = process.env.CODEX_HOME?.trim();
|
|
6198
|
-
return configured ? configured :
|
|
6276
|
+
return configured ? configured : path19.join(os7.homedir(), ".codex");
|
|
6199
6277
|
}
|
|
6200
6278
|
function parseCodexCatalog(raw) {
|
|
6201
6279
|
const body = JSON.parse(raw);
|
|
@@ -6221,7 +6299,7 @@ function errorMessage(err) {
|
|
|
6221
6299
|
return err instanceof Error ? err.message : String(err);
|
|
6222
6300
|
}
|
|
6223
6301
|
async function readCodexCache(codexHome) {
|
|
6224
|
-
const cachePath =
|
|
6302
|
+
const cachePath = path19.join(codexHome, "models_cache.json");
|
|
6225
6303
|
try {
|
|
6226
6304
|
const raw = await fs15.promises.readFile(cachePath, "utf8");
|
|
6227
6305
|
return { models: parseCodexCatalog(raw), source: "codex-cache" };
|
|
@@ -6468,10 +6546,10 @@ function effortDescription(level) {
|
|
|
6468
6546
|
|
|
6469
6547
|
// packages/core/src/jev-credentials.ts
|
|
6470
6548
|
import fs16 from "fs";
|
|
6471
|
-
import
|
|
6549
|
+
import path20 from "path";
|
|
6472
6550
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
6473
6551
|
function keyPath(dir) {
|
|
6474
|
-
return
|
|
6552
|
+
return path20.join(dir, "jev-api-key");
|
|
6475
6553
|
}
|
|
6476
6554
|
function dataDir() {
|
|
6477
6555
|
return getPlatform().userDataDir();
|
|
@@ -7237,29 +7315,29 @@ async function getDoneCommitFile(projectPath, baseBranch, sha, filePath) {
|
|
|
7237
7315
|
|
|
7238
7316
|
// packages/core/src/board-cli.ts
|
|
7239
7317
|
import fs18 from "fs";
|
|
7240
|
-
import
|
|
7318
|
+
import path21 from "path";
|
|
7241
7319
|
import { pathToFileURL } from "url";
|
|
7242
7320
|
async function boardCliLaunchInfo() {
|
|
7243
|
-
const storeDir =
|
|
7321
|
+
const storeDir = path21.dirname(getStorePath());
|
|
7244
7322
|
const entry = getPlatform().cliEntry?.();
|
|
7245
7323
|
if (entry && fs18.existsSync(entry)) return { storeDir, cliPath: entry };
|
|
7246
7324
|
const root = getPlatform().sourceRoot();
|
|
7247
7325
|
if (!root) return { storeDir };
|
|
7248
|
-
const cliPath =
|
|
7249
|
-
const loaderPath =
|
|
7326
|
+
const cliPath = path21.join(root, "scripts", "vibeflow.mjs");
|
|
7327
|
+
const loaderPath = path21.join(root, "test", "support", "register.mjs");
|
|
7250
7328
|
if (!fs18.existsSync(cliPath) || !fs18.existsSync(loaderPath)) return { storeDir };
|
|
7251
7329
|
return { storeDir, cliPath, loaderPath: pathToFileURL(loaderPath).href };
|
|
7252
7330
|
}
|
|
7253
7331
|
|
|
7254
7332
|
// packages/core/src/decisions.ts
|
|
7255
7333
|
import fs19 from "fs";
|
|
7256
|
-
import
|
|
7334
|
+
import path22 from "path";
|
|
7257
7335
|
var DECISIONS_FILE_SUFFIX = ".DECISIONS.md";
|
|
7258
7336
|
function decisionsKey(worktreePath, branch) {
|
|
7259
|
-
return worktreePath ?
|
|
7337
|
+
return worktreePath ? path22.basename(worktreePath) : branch.replace(/\//g, "-");
|
|
7260
7338
|
}
|
|
7261
7339
|
function decisionsPath(workspacePath, key) {
|
|
7262
|
-
return
|
|
7340
|
+
return path22.join(workspacePath, `${key}${DECISIONS_FILE_SUFFIX}`);
|
|
7263
7341
|
}
|
|
7264
7342
|
function deleteDecisions(workspacePath, key) {
|
|
7265
7343
|
try {
|
|
@@ -7560,13 +7638,13 @@ init_progress();
|
|
|
7560
7638
|
init_launch();
|
|
7561
7639
|
import fs20 from "fs";
|
|
7562
7640
|
import os8 from "os";
|
|
7563
|
-
import
|
|
7641
|
+
import path23 from "path";
|
|
7564
7642
|
var SINCE_SLACK_MS = 5e3;
|
|
7565
7643
|
function claudeProjectDir(home, cwd) {
|
|
7566
|
-
return
|
|
7644
|
+
return path23.join(home, ".claude", "projects", cwd.replace(/[^a-zA-Z0-9]/g, "-"));
|
|
7567
7645
|
}
|
|
7568
7646
|
function pathAliases(p) {
|
|
7569
|
-
const resolved =
|
|
7647
|
+
const resolved = path23.resolve(p);
|
|
7570
7648
|
try {
|
|
7571
7649
|
const real = fs20.realpathSync(resolved);
|
|
7572
7650
|
return real === resolved ? [resolved] : [resolved, real];
|
|
@@ -7584,7 +7662,7 @@ function samePath(a, b) {
|
|
|
7584
7662
|
}
|
|
7585
7663
|
function listFiles(dir, test) {
|
|
7586
7664
|
try {
|
|
7587
|
-
return fs20.readdirSync(dir).filter(test).map((name) =>
|
|
7665
|
+
return fs20.readdirSync(dir).filter(test).map((name) => path23.join(dir, name));
|
|
7588
7666
|
} catch {
|
|
7589
7667
|
return [];
|
|
7590
7668
|
}
|
|
@@ -7654,14 +7732,14 @@ function codexDayDirs(sessionsRoot, since) {
|
|
|
7654
7732
|
const cur = new Date(start.getFullYear(), start.getMonth(), start.getDate());
|
|
7655
7733
|
while (cur <= end) {
|
|
7656
7734
|
const pad = (n) => String(n).padStart(2, "0");
|
|
7657
|
-
days.push(
|
|
7735
|
+
days.push(path23.join(sessionsRoot, String(cur.getFullYear()), pad(cur.getMonth() + 1), pad(cur.getDate())));
|
|
7658
7736
|
cur.setDate(cur.getDate() + 1);
|
|
7659
7737
|
}
|
|
7660
7738
|
return days;
|
|
7661
7739
|
}
|
|
7662
7740
|
function createProgressTracker(opts) {
|
|
7663
7741
|
const home = opts.homeDir ?? os8.homedir();
|
|
7664
|
-
const codexHomes = opts.codexHomes ?? (() => [
|
|
7742
|
+
const codexHomes = opts.codexHomes ?? (() => [path23.join(home, ".codex")]);
|
|
7665
7743
|
const pollMs = opts.pollMs ?? 2e3;
|
|
7666
7744
|
const entries = /* @__PURE__ */ new Map();
|
|
7667
7745
|
const belongsToRun = (target, startedAt) => target.since == null || startedAt != null && startedAt >= target.since - SINCE_SLACK_MS;
|
|
@@ -7670,7 +7748,7 @@ function createProgressTracker(opts) {
|
|
|
7670
7748
|
const dirs = pathAliases(target.worktreePath).map((p) => claudeProjectDir(home, p));
|
|
7671
7749
|
for (const file of dirs.flatMap((dir) => listFiles(dir, (n) => n.endsWith(".jsonl")))) {
|
|
7672
7750
|
if (entry.claude.has(file) || entry.rejected.has(file)) continue;
|
|
7673
|
-
const session =
|
|
7751
|
+
const session = path23.basename(file, ".jsonl");
|
|
7674
7752
|
if (session !== target.sessionId) {
|
|
7675
7753
|
const head = firstLine(file);
|
|
7676
7754
|
if (head == null) continue;
|
|
@@ -7683,8 +7761,8 @@ function createProgressTracker(opts) {
|
|
|
7683
7761
|
entry.claude.set(file, newCursor(initialClaudeState()));
|
|
7684
7762
|
}
|
|
7685
7763
|
for (const file of Array.from(entry.claude.keys())) {
|
|
7686
|
-
if (file.includes(`${
|
|
7687
|
-
const sub =
|
|
7764
|
+
if (file.includes(`${path23.sep}subagents${path23.sep}`)) continue;
|
|
7765
|
+
const sub = path23.join(file.slice(0, -".jsonl".length), "subagents");
|
|
7688
7766
|
for (const f of listFiles(sub, (n) => n.endsWith(".jsonl"))) {
|
|
7689
7767
|
if (!entry.claude.has(f)) entry.claude.set(f, newCursor(initialClaudeState()));
|
|
7690
7768
|
}
|
|
@@ -7693,7 +7771,7 @@ function createProgressTracker(opts) {
|
|
|
7693
7771
|
function discoverCodex(entry) {
|
|
7694
7772
|
const { target } = entry;
|
|
7695
7773
|
for (const codexHome of codexHomes()) {
|
|
7696
|
-
for (const day of codexDayDirs(
|
|
7774
|
+
for (const day of codexDayDirs(path23.join(codexHome, "sessions"), target.since)) {
|
|
7697
7775
|
for (const file of listFiles(day, (n) => n.startsWith("rollout-") && n.endsWith(".jsonl"))) {
|
|
7698
7776
|
if (entry.codex.has(file) || entry.rejected.has(file)) continue;
|
|
7699
7777
|
const head = firstLine(file);
|
|
@@ -7710,7 +7788,7 @@ function createProgressTracker(opts) {
|
|
|
7710
7788
|
}
|
|
7711
7789
|
}
|
|
7712
7790
|
function drainHooks(entry) {
|
|
7713
|
-
const dir =
|
|
7791
|
+
const dir = path23.join(entry.target.worktreePath, PROGRESS_EVENTS_DIR);
|
|
7714
7792
|
for (const file of listFiles(dir, (n) => n.endsWith(".json")).sort()) {
|
|
7715
7793
|
try {
|
|
7716
7794
|
const at = fs20.statSync(file).mtimeMs;
|
|
@@ -7734,8 +7812,8 @@ function createProgressTracker(opts) {
|
|
|
7734
7812
|
if (target.agent === "claude") {
|
|
7735
7813
|
for (const [file, cursor] of entry.claude) {
|
|
7736
7814
|
runUsage = addUsage(runUsage, claudeUsageTotal(cursor.state));
|
|
7737
|
-
if (file.includes(`${
|
|
7738
|
-
const isExecutor =
|
|
7815
|
+
if (file.includes(`${path23.sep}subagents${path23.sep}`)) continue;
|
|
7816
|
+
const isExecutor = path23.basename(file, ".jsonl") === target.sessionId;
|
|
7739
7817
|
const s = cursor.state;
|
|
7740
7818
|
if (isExecutor || !target.sessionId && (!primary || (s.startedAt ?? 0) > (primary.startedAt ?? 0))) {
|
|
7741
7819
|
primary = { todos: s.todos, contextTokens: s.contextTokens, activity: s.activity, startedAt: s.startedAt };
|
|
@@ -7814,7 +7892,7 @@ function createProgressTracker(opts) {
|
|
|
7814
7892
|
};
|
|
7815
7893
|
entry.timer.unref?.();
|
|
7816
7894
|
entries.set(target.taskId, entry);
|
|
7817
|
-
const eventsDir =
|
|
7895
|
+
const eventsDir = path23.join(target.worktreePath, PROGRESS_EVENTS_DIR);
|
|
7818
7896
|
try {
|
|
7819
7897
|
fs20.mkdirSync(eventsDir, { recursive: true });
|
|
7820
7898
|
entry.watcher = fs20.watch(eventsDir, () => {
|
|
@@ -7979,18 +8057,18 @@ function readLastClaudeReply(file, maxChars) {
|
|
|
7979
8057
|
// packages/core/src/inbox.ts
|
|
7980
8058
|
init_launch();
|
|
7981
8059
|
import fs22 from "fs";
|
|
7982
|
-
import
|
|
8060
|
+
import path24 from "path";
|
|
7983
8061
|
var seq = 0;
|
|
7984
8062
|
function inboxDir(worktreePath) {
|
|
7985
|
-
return
|
|
8063
|
+
return path24.join(worktreePath, INBOX_DIR);
|
|
7986
8064
|
}
|
|
7987
8065
|
function inboxReady(dir) {
|
|
7988
|
-
return fs22.existsSync(
|
|
8066
|
+
return fs22.existsSync(path24.join(dir, INBOX_READY_FILE));
|
|
7989
8067
|
}
|
|
7990
8068
|
function prepareInbox(dir) {
|
|
7991
8069
|
fs22.mkdirSync(dir, { recursive: true });
|
|
7992
|
-
fs22.writeFileSync(
|
|
7993
|
-
fs22.rmSync(
|
|
8070
|
+
fs22.writeFileSync(path24.join(dir, ".gitignore"), "*\n");
|
|
8071
|
+
fs22.rmSync(path24.join(dir, INBOX_READY_FILE), { force: true });
|
|
7994
8072
|
}
|
|
7995
8073
|
function messageNames(dir) {
|
|
7996
8074
|
try {
|
|
@@ -8005,16 +8083,16 @@ function pendingMessages(dir) {
|
|
|
8005
8083
|
function postMessage(dir, text) {
|
|
8006
8084
|
fs22.mkdirSync(dir, { recursive: true });
|
|
8007
8085
|
const name = `${String(Date.now()).padStart(13, "0")}-${String(seq++ % 1e6).padStart(6, "0")}`;
|
|
8008
|
-
const tmp =
|
|
8086
|
+
const tmp = path24.join(dir, `.tmp-${name}`);
|
|
8009
8087
|
fs22.writeFileSync(tmp, text);
|
|
8010
|
-
fs22.renameSync(tmp,
|
|
8088
|
+
fs22.renameSync(tmp, path24.join(dir, name));
|
|
8011
8089
|
}
|
|
8012
8090
|
function takeMessages(dir) {
|
|
8013
8091
|
const texts = [];
|
|
8014
8092
|
for (const name of messageNames(dir)) {
|
|
8015
|
-
const claimed =
|
|
8093
|
+
const claimed = path24.join(dir, `.host-${name}`);
|
|
8016
8094
|
try {
|
|
8017
|
-
fs22.renameSync(
|
|
8095
|
+
fs22.renameSync(path24.join(dir, name), claimed);
|
|
8018
8096
|
} catch {
|
|
8019
8097
|
continue;
|
|
8020
8098
|
}
|
|
@@ -8030,6 +8108,7 @@ var PASTE_END = "\x1B[201~";
|
|
|
8030
8108
|
var PASTE_GAP_MS = 200;
|
|
8031
8109
|
var DEFAULT_QUIET_MS = 3e3;
|
|
8032
8110
|
var DEFAULT_TIMEOUT_MS = 12e4;
|
|
8111
|
+
var DEFAULT_RETRY_MS = 5e3;
|
|
8033
8112
|
function coded(code2, message2) {
|
|
8034
8113
|
return Object.assign(new Error(message2), { code: code2 });
|
|
8035
8114
|
}
|
|
@@ -8069,10 +8148,28 @@ function createMailbox(options) {
|
|
|
8069
8148
|
const drafts = /* @__PURE__ */ new Set();
|
|
8070
8149
|
const held = /* @__PURE__ */ new Map();
|
|
8071
8150
|
const turns = /* @__PURE__ */ new Map();
|
|
8151
|
+
const retries = /* @__PURE__ */ new Map();
|
|
8072
8152
|
function noteInput(key, data) {
|
|
8073
8153
|
lastInput.set(key, Date.now());
|
|
8074
|
-
|
|
8154
|
+
const had = drafts.has(key);
|
|
8155
|
+
if (draftAfter(had, data)) drafts.add(key);
|
|
8075
8156
|
else drafts.delete(key);
|
|
8157
|
+
return had && !drafts.has(key);
|
|
8158
|
+
}
|
|
8159
|
+
function retryLater(key) {
|
|
8160
|
+
if (retries.has(key)) return;
|
|
8161
|
+
const timer = setTimeout(() => {
|
|
8162
|
+
retries.delete(key);
|
|
8163
|
+
poke(key);
|
|
8164
|
+
}, options.retryMs ?? DEFAULT_RETRY_MS);
|
|
8165
|
+
timer.unref?.();
|
|
8166
|
+
retries.set(key, timer);
|
|
8167
|
+
}
|
|
8168
|
+
function poke(key) {
|
|
8169
|
+
const dir = options.inbox?.(key);
|
|
8170
|
+
if (!dir || !pendingMessages(dir) || turns.has(key)) return;
|
|
8171
|
+
void enqueue(key, () => wake(key, dir)).catch(() => {
|
|
8172
|
+
});
|
|
8076
8173
|
}
|
|
8077
8174
|
async function waitForQuiet(key, started) {
|
|
8078
8175
|
const quiet = options.quietMs ?? quietFromEnv();
|
|
@@ -8103,7 +8200,10 @@ function createMailbox(options) {
|
|
|
8103
8200
|
async function wake(key, dir) {
|
|
8104
8201
|
const quiet = options.quietMs ?? quietFromEnv();
|
|
8105
8202
|
for (; ; ) {
|
|
8106
|
-
if (!await canWake(key))
|
|
8203
|
+
if (!await canWake(key)) {
|
|
8204
|
+
retryLater(key);
|
|
8205
|
+
return "queued";
|
|
8206
|
+
}
|
|
8107
8207
|
const left = (lastInput.get(key) ?? 0) + quiet - Date.now();
|
|
8108
8208
|
if (left <= 0) break;
|
|
8109
8209
|
await sleep(Math.min(left, 250));
|
|
@@ -8135,7 +8235,7 @@ function createMailbox(options) {
|
|
|
8135
8235
|
}
|
|
8136
8236
|
return {
|
|
8137
8237
|
userInput(key, data) {
|
|
8138
|
-
noteInput(key, data);
|
|
8238
|
+
if (noteInput(key, data)) queueMicrotask(() => poke(key));
|
|
8139
8239
|
const buffer = held.get(key);
|
|
8140
8240
|
if (buffer) {
|
|
8141
8241
|
buffer.push(data);
|
|
@@ -8153,13 +8253,10 @@ function createMailbox(options) {
|
|
|
8153
8253
|
return { queuedMs: Date.now() - started, via };
|
|
8154
8254
|
});
|
|
8155
8255
|
},
|
|
8156
|
-
poke
|
|
8157
|
-
const dir = options.inbox?.(key);
|
|
8158
|
-
if (!dir || !pendingMessages(dir) || turns.has(key)) return;
|
|
8159
|
-
void enqueue(key, () => wake(key, dir)).catch(() => {
|
|
8160
|
-
});
|
|
8161
|
-
},
|
|
8256
|
+
poke,
|
|
8162
8257
|
forget(key) {
|
|
8258
|
+
clearTimeout(retries.get(key));
|
|
8259
|
+
retries.delete(key);
|
|
8163
8260
|
lastInput.delete(key);
|
|
8164
8261
|
drafts.delete(key);
|
|
8165
8262
|
held.delete(key);
|
|
@@ -8168,38 +8265,20 @@ function createMailbox(options) {
|
|
|
8168
8265
|
}
|
|
8169
8266
|
|
|
8170
8267
|
// packages/core/src/notifier.ts
|
|
8171
|
-
function
|
|
8172
|
-
|
|
8173
|
-
const look = `\u67E5\u770B\uFF1AVF task show --store-path "$VIBEFLOW_STORE_DIR" --task ${id}`;
|
|
8174
|
-
switch (kind) {
|
|
8175
|
-
case "blocked":
|
|
8176
|
-
return `${card} \u5361\u5728\u6B0A\u9650\u78BA\u8A8D\uFF0C\u7B49\u4F7F\u7528\u8005\u5141\u8A31\u624D\u6703\u7E7C\u7E8C\u3002${look}`;
|
|
8177
|
-
case "launch_failed":
|
|
8178
|
-
return `${card} \u555F\u52D5\u5931\u6557\uFF0C\u5DF2\u9000\u56DE Backlog\uFF1A${detail ?? "\u539F\u56E0\u4E0D\u660E"}\u3002${look}`;
|
|
8179
|
-
case "exited":
|
|
8180
|
-
return `${card} \u7684 agent session \u5DF2\u7D50\u675F\u3002${look}`;
|
|
8181
|
-
case "turn_unreported":
|
|
8182
|
-
return `${card} \u9019\u4E00\u56DE\u5408\u7D50\u675F\u4E86\uFF0C\u4F46\u6C92\u6709\u56DE\u5831\u7D50\u679C\uFF08\u53EF\u80FD\u5728\u7B49\u4EBA\u56DE\u7B54\u554F\u984C\uFF09\u3002${look}`;
|
|
8183
|
-
}
|
|
8268
|
+
function cardLabel(id, title) {
|
|
8269
|
+
return `\u5361\u7247 ${id}\u300C${title}\u300D`;
|
|
8184
8270
|
}
|
|
8185
8271
|
function createNotifier(options) {
|
|
8186
|
-
const
|
|
8187
|
-
const inTurn = /* @__PURE__ */ new Set();
|
|
8188
|
-
const reportedThisTurn = /* @__PURE__ */ new Set();
|
|
8189
|
-
const told = /* @__PURE__ */ new Map();
|
|
8272
|
+
const told = /* @__PURE__ */ new Set();
|
|
8190
8273
|
const pending = /* @__PURE__ */ new Map();
|
|
8191
8274
|
const flushing = /* @__PURE__ */ new Set();
|
|
8192
|
-
function
|
|
8193
|
-
|
|
8194
|
-
|
|
8195
|
-
const
|
|
8196
|
-
|
|
8197
|
-
|
|
8198
|
-
|
|
8199
|
-
const queue = pending.get(card.masterId) ?? [];
|
|
8200
|
-
queue.push(describe(kind, taskId, card.title, detail));
|
|
8201
|
-
pending.set(card.masterId, queue);
|
|
8202
|
-
schedule(card.masterId);
|
|
8275
|
+
function push(masterId, key, text) {
|
|
8276
|
+
if (told.has(key)) return;
|
|
8277
|
+
told.add(key);
|
|
8278
|
+
const queue = pending.get(masterId) ?? [];
|
|
8279
|
+
queue.push(text);
|
|
8280
|
+
pending.set(masterId, queue);
|
|
8281
|
+
schedule(masterId);
|
|
8203
8282
|
}
|
|
8204
8283
|
function schedule(masterId) {
|
|
8205
8284
|
setTimeout(() => void flush(masterId), 0);
|
|
@@ -8226,37 +8305,26 @@ function createNotifier(options) {
|
|
|
8226
8305
|
}
|
|
8227
8306
|
if (pending.get(masterId)?.length) schedule(masterId);
|
|
8228
8307
|
}
|
|
8229
|
-
function turnStarted(taskId) {
|
|
8230
|
-
inTurn.add(taskId);
|
|
8231
|
-
reportedThisTurn.delete(taskId);
|
|
8232
|
-
told.delete(taskId);
|
|
8233
|
-
}
|
|
8234
8308
|
return {
|
|
8235
|
-
activity(taskId, activity) {
|
|
8236
|
-
const before = states.get(taskId);
|
|
8237
|
-
states.set(taskId, activity);
|
|
8238
|
-
const wasBlocked = before?.state === "waiting" && before.waitingFor === "permission";
|
|
8239
|
-
if (activity.state === "working") {
|
|
8240
|
-
if (wasBlocked) told.get(taskId)?.delete("blocked");
|
|
8241
|
-
else if (before?.state !== "working") turnStarted(taskId);
|
|
8242
|
-
return;
|
|
8243
|
-
}
|
|
8244
|
-
if (activity.state !== "waiting") return;
|
|
8245
|
-
if (activity.waitingFor === "permission") {
|
|
8246
|
-
note(taskId, "blocked");
|
|
8247
|
-
return;
|
|
8248
|
-
}
|
|
8249
|
-
if (inTurn.delete(taskId) && !reportedThisTurn.has(taskId)) note(taskId, "turn_unreported");
|
|
8250
|
-
},
|
|
8251
8309
|
launchFailed(taskId, reason) {
|
|
8252
|
-
|
|
8253
|
-
|
|
8254
|
-
|
|
8255
|
-
|
|
8256
|
-
|
|
8310
|
+
const card = options.cardOf(taskId);
|
|
8311
|
+
if (!card) return;
|
|
8312
|
+
told.delete(`launch_failed:${taskId}`);
|
|
8313
|
+
const look = `\u67E5\u770B\uFF1AVF task show --store-path "$VIBEFLOW_STORE_DIR" --task ${taskId}`;
|
|
8314
|
+
push(
|
|
8315
|
+
card.masterId,
|
|
8316
|
+
`launch_failed:${taskId}`,
|
|
8317
|
+
`${cardLabel(taskId, card.title)} \u555F\u52D5\u5931\u6557\uFF0C\u5DF2\u9000\u56DE Backlog\uFF1A${reason || "\u539F\u56E0\u4E0D\u660E"}\u3002\u7B49\u5B83\u7684\u5361\u4E5F\u4E0D\u6703\u958B\u59CB\u3002${look}`
|
|
8318
|
+
);
|
|
8257
8319
|
},
|
|
8258
|
-
|
|
8259
|
-
|
|
8320
|
+
allDone(masterId, cardIds) {
|
|
8321
|
+
if (cardIds.length === 0) return;
|
|
8322
|
+
const key = `all_done:${masterId}:${[...cardIds].sort().join(",")}`;
|
|
8323
|
+
push(
|
|
8324
|
+
masterId,
|
|
8325
|
+
key,
|
|
8326
|
+
`\u4F60\u7684 ${cardIds.length} \u5F35\u5361\u7247\u90FD\u5DF2 Done\uFF1A${cardIds.join("\u3001")}\u3002\u8ACB\u6574\u7406\u6BCF\u5F35\u5361\u7684\u7D50\u679C\u8207 PR \u9023\u7D50\u4EA4\u7D66\u4F7F\u7528\u8005\uFF1AVF task list --store-path "$VIBEFLOW_STORE_DIR" --master ${masterId}`
|
|
8327
|
+
);
|
|
8260
8328
|
},
|
|
8261
8329
|
retry(masterId) {
|
|
8262
8330
|
if (pending.get(masterId)?.length) schedule(masterId);
|
|
@@ -8264,6 +8332,14 @@ function createNotifier(options) {
|
|
|
8264
8332
|
};
|
|
8265
8333
|
}
|
|
8266
8334
|
|
|
8335
|
+
// packages/core/src/dependencies.ts
|
|
8336
|
+
function readyDependents(board, masterId) {
|
|
8337
|
+
const done = new Set(board.done.map((t) => t.id));
|
|
8338
|
+
return board.backlog.filter(
|
|
8339
|
+
(t) => t.masterId === masterId && (t.after?.length ?? 0) > 0 && (t.after ?? []).every((id) => done.has(id))
|
|
8340
|
+
);
|
|
8341
|
+
}
|
|
8342
|
+
|
|
8267
8343
|
// packages/core/src/service.ts
|
|
8268
8344
|
var InvalidRequestError = class extends Error {
|
|
8269
8345
|
code = "INVALID_REQUEST";
|
|
@@ -8291,6 +8367,10 @@ function str(value, name) {
|
|
|
8291
8367
|
if (typeof value !== "string") invalid(`${name} must be a string`);
|
|
8292
8368
|
return value;
|
|
8293
8369
|
}
|
|
8370
|
+
function strList(value, name) {
|
|
8371
|
+
if (!Array.isArray(value) || !value.every((v) => typeof v === "string")) invalid(`${name} must be a list of strings`);
|
|
8372
|
+
return value;
|
|
8373
|
+
}
|
|
8294
8374
|
function obj(value, name) {
|
|
8295
8375
|
if (!value || typeof value !== "object" || Array.isArray(value)) invalid(`${name} must be an object`);
|
|
8296
8376
|
return value;
|
|
@@ -8349,10 +8429,9 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8349
8429
|
const home = homeDir ?? os9.homedir();
|
|
8350
8430
|
const progress = createProgressTracker({
|
|
8351
8431
|
homeDir: home,
|
|
8352
|
-
codexHomes: () => [
|
|
8432
|
+
codexHomes: () => [path25.join(home, ".codex"), ...libraryCodexHome ? [libraryCodexHome] : []],
|
|
8353
8433
|
onUpdate: (taskId, value) => {
|
|
8354
8434
|
bus.emit("progress:update", { taskId, progress: value });
|
|
8355
|
-
notifier.activity(taskId, value.activity);
|
|
8356
8435
|
notifier.retry(taskId);
|
|
8357
8436
|
mailbox.poke(taskId);
|
|
8358
8437
|
},
|
|
@@ -8436,7 +8515,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8436
8515
|
} catch {
|
|
8437
8516
|
}
|
|
8438
8517
|
for (const cwd of /* @__PURE__ */ new Set([task.worktreePath, resolved])) {
|
|
8439
|
-
const candidate =
|
|
8518
|
+
const candidate = path25.join(claudeProjectDir(home, cwd), file);
|
|
8440
8519
|
if (fs23.existsSync(candidate)) return candidate;
|
|
8441
8520
|
}
|
|
8442
8521
|
return void 0;
|
|
@@ -8623,19 +8702,50 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8623
8702
|
boardCli,
|
|
8624
8703
|
autoMode: task.autoMode ?? settings.autoMode,
|
|
8625
8704
|
preface,
|
|
8626
|
-
continuation
|
|
8705
|
+
continuation,
|
|
8706
|
+
masterContext: masterContextOf(task)
|
|
8627
8707
|
},
|
|
8628
8708
|
task.workspacePath
|
|
8629
8709
|
);
|
|
8630
8710
|
}
|
|
8711
|
+
async function carryOnAfterDone(taskId) {
|
|
8712
|
+
const task = findTask(taskId);
|
|
8713
|
+
if (!task?.masterId || columnOf(task.id) !== "done") return;
|
|
8714
|
+
const master = findTask(task.masterId);
|
|
8715
|
+
if (!master) return;
|
|
8716
|
+
const board = getState().board;
|
|
8717
|
+
const cards = Object.values(board).flat().filter((t) => t.masterId === master.id);
|
|
8718
|
+
if (cards.every((t) => columnOf(t.id) === "done")) {
|
|
8719
|
+
notifier.allDone(master.id, cards.map((t) => t.id));
|
|
8720
|
+
return;
|
|
8721
|
+
}
|
|
8722
|
+
if (columnOf(master.id) !== "in_progress" || !(master.autoMode ?? getSettings().autoMode)) return;
|
|
8723
|
+
for (const next of readyDependents(board, master.id)) {
|
|
8724
|
+
try {
|
|
8725
|
+
await handlers["vibeflow:startTask"](next.id);
|
|
8726
|
+
} catch (err) {
|
|
8727
|
+
if (!findTask(next.id)?.launchError) returnUnstarted(next.id, err.message);
|
|
8728
|
+
}
|
|
8729
|
+
}
|
|
8730
|
+
}
|
|
8731
|
+
function masterContextOf(task) {
|
|
8732
|
+
const master = task.masterId ? findTask(task.masterId) : void 0;
|
|
8733
|
+
if (!master) return void 0;
|
|
8734
|
+
const siblings = Object.values(getState().board).flat().filter((t) => t.masterId === master.id && t.id !== task.id).map((t) => {
|
|
8735
|
+
const line = t.description?.split("\n").map((l) => l.trim()).find(Boolean);
|
|
8736
|
+
const summary = line && line.length > 80 ? `${line.slice(0, 80)}\u2026` : line;
|
|
8737
|
+
return { id: t.id, title: t.title, ...summary ? { summary } : {} };
|
|
8738
|
+
});
|
|
8739
|
+
return { master: { id: master.id, title: master.title }, siblings, ...task.after?.length ? { after: task.after } : {} };
|
|
8740
|
+
}
|
|
8631
8741
|
function claudeSessionFile(cwd, sessionId) {
|
|
8632
8742
|
const munged = cwd.replace(/[^a-zA-Z0-9]/g, "-");
|
|
8633
|
-
return
|
|
8743
|
+
return path25.join(os9.homedir(), ".claude", "projects", munged, `${sessionId}.jsonl`);
|
|
8634
8744
|
}
|
|
8635
8745
|
async function removeTaskWorktree(task) {
|
|
8636
8746
|
if (!task.projectPath || !task.worktreePath || task.inPlace) return;
|
|
8637
8747
|
await removeWorktree(task.projectPath, task.worktreePath);
|
|
8638
|
-
deleteArtifacts(task.workspacePath ??
|
|
8748
|
+
deleteArtifacts(task.workspacePath ?? path25.dirname(task.worktreePath), task.worktreePath);
|
|
8639
8749
|
if (!task.noBranch) await deleteBranch(task.projectPath, task.branch || fallbackBranchName(task.id));
|
|
8640
8750
|
}
|
|
8641
8751
|
function columnOf(taskId) {
|
|
@@ -8715,7 +8825,6 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8715
8825
|
// Session ended (natural exit included), so stop its watcher.
|
|
8716
8826
|
onExit: () => {
|
|
8717
8827
|
unwatchSubAgents(key);
|
|
8718
|
-
if (key === task.id) notifier.exited(task.id);
|
|
8719
8828
|
}
|
|
8720
8829
|
});
|
|
8721
8830
|
terminalDirectories.set(key, cwd);
|
|
@@ -8754,12 +8863,15 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8754
8863
|
const todos = snapshot?.todos;
|
|
8755
8864
|
const current = todos?.find((t) => t.status === "in_progress");
|
|
8756
8865
|
const pr = task.outcome?.pr;
|
|
8866
|
+
const waiting = task.worktreePath ? pendingMessages(inboxDir(task.worktreePath)) : 0;
|
|
8757
8867
|
summaries.push({
|
|
8758
8868
|
id: task.id,
|
|
8759
8869
|
title: task.title,
|
|
8760
8870
|
column,
|
|
8761
8871
|
...task.role ? { role: task.role } : {},
|
|
8762
8872
|
...task.masterId ? { masterId: task.masterId } : {},
|
|
8873
|
+
...task.after?.length ? { after: task.after } : {},
|
|
8874
|
+
...task.projects?.length ? { projects: task.projects } : {},
|
|
8763
8875
|
...task.projectName ? { projectName: task.projectName } : {},
|
|
8764
8876
|
...task.branch ? { branch: task.branch } : {},
|
|
8765
8877
|
...launchChoice(task),
|
|
@@ -8774,6 +8886,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8774
8886
|
}
|
|
8775
8887
|
} : {},
|
|
8776
8888
|
...snapshot ? { activity: snapshot.activity } : {},
|
|
8889
|
+
...waiting ? { inbox: waiting } : {},
|
|
8777
8890
|
...pr ? { pr: { number: pr.number, url: pr.url, state: pr.state } } : {},
|
|
8778
8891
|
...task.outcome ? {
|
|
8779
8892
|
outcome: {
|
|
@@ -8880,7 +8993,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8880
8993
|
"projects:listRecent": () => listRecentProjects(getStore()),
|
|
8881
8994
|
// `vibeflow open <path>` while a host runs: only the host writes the store.
|
|
8882
8995
|
"projects:record": (projectPath) => {
|
|
8883
|
-
const p =
|
|
8996
|
+
const p = path25.resolve(str(projectPath, "projectPath"));
|
|
8884
8997
|
if (!fs23.existsSync(p) || !fs23.statSync(p).isDirectory()) invalid(`not a directory: ${p}`);
|
|
8885
8998
|
recordRecentProject(getStore(), p);
|
|
8886
8999
|
return listRecentProjects(getStore());
|
|
@@ -8894,6 +9007,8 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8894
9007
|
}
|
|
8895
9008
|
if (p.workDir !== void 0) str(p.workDir, "workDir");
|
|
8896
9009
|
if (p.masterId !== void 0) str(p.masterId, "masterId");
|
|
9010
|
+
if (p.after !== void 0) strList(p.after, "after");
|
|
9011
|
+
if (p.projects !== void 0) strList(p.projects, "projects");
|
|
8897
9012
|
str(p.title ?? "", "title");
|
|
8898
9013
|
if (p.effort !== void 0 && !AGENT_EFFORTS.includes(p.effort)) invalid("unknown effort");
|
|
8899
9014
|
if (p.agentCli !== void 0 && !AGENT_IDS2.includes(p.agentCli)) invalid("unknown agent");
|
|
@@ -8905,6 +9020,8 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8905
9020
|
role: p.role,
|
|
8906
9021
|
workDir: p.workDir,
|
|
8907
9022
|
masterId: p.masterId,
|
|
9023
|
+
after: p.after,
|
|
9024
|
+
projects: p.projects,
|
|
8908
9025
|
title: p.title,
|
|
8909
9026
|
description: p.description,
|
|
8910
9027
|
baseBranch: p.baseBranch,
|
|
@@ -8956,7 +9073,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8956
9073
|
if (!task.baseBranch) throw new Error("\u4EFB\u52D9\u6C92\u6709\u8A18\u9304 base branch\uFF0C\u7121\u6CD5\u9084\u539F worktree");
|
|
8957
9074
|
await teardownTask(task.id);
|
|
8958
9075
|
await resetWorktreeToBase(task.worktreePath, task.baseBranch);
|
|
8959
|
-
const workspacePath = task.workspacePath ??
|
|
9076
|
+
const workspacePath = task.workspacePath ?? path25.dirname(task.worktreePath);
|
|
8960
9077
|
deleteArtifacts(workspacePath, task.worktreePath);
|
|
8961
9078
|
deleteDecisions(workspacePath, decisionsKey(task.worktreePath, task.branch));
|
|
8962
9079
|
resetSubAgents(task.worktreePath);
|
|
@@ -8987,7 +9104,13 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
8987
9104
|
if (isMasterTask(existing)) invalid("a master cannot belong to another master");
|
|
8988
9105
|
assertMasterRef(getState().board, str(p.masterId, "masterId"), existing.id);
|
|
8989
9106
|
}
|
|
8990
|
-
|
|
9107
|
+
const masterId = p.masterId || void 0;
|
|
9108
|
+
masterPatch = masterId === existing.masterId ? {} : { masterId, after: void 0 };
|
|
9109
|
+
}
|
|
9110
|
+
if (p.projects !== void 0) {
|
|
9111
|
+
if (!isMasterTask(existing)) invalid("only a master has related projects");
|
|
9112
|
+
const projects = await resolveProjects(strList(p.projects, "projects"));
|
|
9113
|
+
masterPatch = { ...masterPatch, projects: projects.length ? projects : void 0 };
|
|
8991
9114
|
}
|
|
8992
9115
|
let gitPatch = {};
|
|
8993
9116
|
const nextProject = isMasterTask(existing) ? void 0 : p.projectPath || existing.projectPath;
|
|
@@ -9008,7 +9131,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
9008
9131
|
}
|
|
9009
9132
|
const info = await getGitInfo(nextProject);
|
|
9010
9133
|
if (!info.isRepo && !existing.noBranch) throw new Error("\u76EE\u6A19\u8CC7\u6599\u593E\u4E0D\u662F git repository");
|
|
9011
|
-
const projectName =
|
|
9134
|
+
const projectName = path25.basename(nextProject);
|
|
9012
9135
|
const workspacePath = projectWorkstationPath(resolveWorkstationPath(getSettings()), projectName);
|
|
9013
9136
|
await teardownTask(existing.id);
|
|
9014
9137
|
await removeTaskWorktree(existing);
|
|
@@ -9098,7 +9221,6 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
9098
9221
|
if (!text) invalid("text must not be empty");
|
|
9099
9222
|
if (text.length > MAX_MESSAGE_LENGTH) invalid(`text must be at most ${MAX_MESSAGE_LENGTH} characters`);
|
|
9100
9223
|
if (!await sessions.isAlive(to.id)) throw coded2("NOT_RUNNING", `\u5361\u7247 ${to.id} \u7684 agent \u6C92\u6709\u5728\u57F7\u884C`);
|
|
9101
|
-
if (isMasterTask(to)) notifier.reported(from.id);
|
|
9102
9224
|
await attachAgent(to.id);
|
|
9103
9225
|
const { queuedMs, via } = await mailbox.deliver(to.id, frameMessage({ id: from.id, title: from.title }, text), { force: p.force === true });
|
|
9104
9226
|
return { delivered: true, queuedMs, via };
|
|
@@ -9129,10 +9251,10 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
9129
9251
|
} else {
|
|
9130
9252
|
cwd = os9.homedir();
|
|
9131
9253
|
}
|
|
9132
|
-
if (!
|
|
9254
|
+
if (!path25.isAbsolute(cwd) || !fs23.existsSync(cwd) || !fs23.statSync(cwd).isDirectory()) {
|
|
9133
9255
|
invalid("terminal directory must be an existing absolute directory");
|
|
9134
9256
|
}
|
|
9135
|
-
const title = (typeof p.title === "string" ? p.title.trim() : "") || saved?.title || (projectPath ?
|
|
9257
|
+
const title = (typeof p.title === "string" ? p.title.trim() : "") || saved?.title || (projectPath ? path25.basename(projectPath) : "~");
|
|
9136
9258
|
saveTerminal({
|
|
9137
9259
|
sessionKey: key,
|
|
9138
9260
|
title,
|
|
@@ -9413,6 +9535,7 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
9413
9535
|
...outcome ? { outcome } : {},
|
|
9414
9536
|
...usage ? { usage } : {}
|
|
9415
9537
|
});
|
|
9538
|
+
await carryOnAfterDone(task.id);
|
|
9416
9539
|
return getState();
|
|
9417
9540
|
},
|
|
9418
9541
|
// Delete: cleanup (PTY + worktree) AND drop the card from the board.
|
|
@@ -9483,9 +9606,9 @@ function createCore({ sessions, bus, version, homeDir, ghRunner, githubAuthStatu
|
|
|
9483
9606
|
// Watch the containing directory, not the file: JsonStore renames a temp
|
|
9484
9607
|
// file over the target and so replaces the inode on every save.
|
|
9485
9608
|
watchStore() {
|
|
9486
|
-
const file =
|
|
9609
|
+
const file = path25.basename(getStorePath());
|
|
9487
9610
|
let debounce = null;
|
|
9488
|
-
storeWatcher = fs23.watch(
|
|
9611
|
+
storeWatcher = fs23.watch(path25.dirname(getStorePath()), (_event, filename) => {
|
|
9489
9612
|
if (filename !== file) return;
|
|
9490
9613
|
if (debounce) clearTimeout(debounce);
|
|
9491
9614
|
debounce = setTimeout(() => {
|
|
@@ -9524,7 +9647,7 @@ function createSessionBackend(sink, choice) {
|
|
|
9524
9647
|
// packages/core/src/web-server.ts
|
|
9525
9648
|
import fs24 from "fs";
|
|
9526
9649
|
import http from "http";
|
|
9527
|
-
import
|
|
9650
|
+
import path26 from "path";
|
|
9528
9651
|
import { timingSafeEqual } from "crypto";
|
|
9529
9652
|
import { WebSocketServer } from "ws";
|
|
9530
9653
|
var TOKEN_COOKIE = "vf_token";
|
|
@@ -9579,12 +9702,12 @@ function resolveStatic(root, urlPath) {
|
|
|
9579
9702
|
return null;
|
|
9580
9703
|
}
|
|
9581
9704
|
if (decoded.includes("\0")) return null;
|
|
9582
|
-
const rel =
|
|
9583
|
-
const base2 =
|
|
9584
|
-
const candidates = [rel,
|
|
9705
|
+
const rel = path26.posix.normalize(decoded).replace(/^\/+/, "");
|
|
9706
|
+
const base2 = path26.resolve(root);
|
|
9707
|
+
const candidates = [rel, path26.posix.join(rel, "index.html"), `${rel}.html`];
|
|
9585
9708
|
for (const c of candidates) {
|
|
9586
|
-
const full =
|
|
9587
|
-
if (full !== base2 && !full.startsWith(base2 +
|
|
9709
|
+
const full = path26.resolve(base2, c);
|
|
9710
|
+
if (full !== base2 && !full.startsWith(base2 + path26.sep)) return null;
|
|
9588
9711
|
try {
|
|
9589
9712
|
if (fs24.statSync(full).isFile()) return full;
|
|
9590
9713
|
} catch {
|
|
@@ -9647,7 +9770,7 @@ async function startWebServer(options) {
|
|
|
9647
9770
|
send(res, 404, "Not found");
|
|
9648
9771
|
return;
|
|
9649
9772
|
}
|
|
9650
|
-
const ext =
|
|
9773
|
+
const ext = path26.extname(file).toLowerCase();
|
|
9651
9774
|
const immutable = url.pathname.startsWith("/_next/static/");
|
|
9652
9775
|
res.writeHead(200, {
|
|
9653
9776
|
"Content-Type": CONTENT_TYPES[ext] ?? "application/octet-stream",
|
|
@@ -9760,7 +9883,7 @@ Content-Length: 0\r
|
|
|
9760
9883
|
|
|
9761
9884
|
// packages/cli/src/update-command.ts
|
|
9762
9885
|
import fs25 from "node:fs";
|
|
9763
|
-
import
|
|
9886
|
+
import path27 from "node:path";
|
|
9764
9887
|
import { spawnSync } from "node:child_process";
|
|
9765
9888
|
function npmRunner(args, inherit) {
|
|
9766
9889
|
const spawnOpts = {
|
|
@@ -9772,7 +9895,7 @@ function npmRunner(args, inherit) {
|
|
|
9772
9895
|
}
|
|
9773
9896
|
function packageName(packageRoot) {
|
|
9774
9897
|
try {
|
|
9775
|
-
const pkg = JSON.parse(fs25.readFileSync(
|
|
9898
|
+
const pkg = JSON.parse(fs25.readFileSync(path27.join(packageRoot, "package.json"), "utf8"));
|
|
9776
9899
|
if (typeof pkg.name !== "string") return null;
|
|
9777
9900
|
return /^(?:@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*$/i.test(pkg.name) ? pkg.name : null;
|
|
9778
9901
|
} catch {
|
|
@@ -9787,7 +9910,7 @@ function runUpdate(options) {
|
|
|
9787
9910
|
error("vibeflow update \u53EA\u9069\u7528\u65BC\u5168\u57DF npm \u5B89\u88DD\uFF1B\u76EE\u524D\u662F\u539F\u59CB\u78BC\u7248\u672C\u3002");
|
|
9788
9911
|
return 1;
|
|
9789
9912
|
}
|
|
9790
|
-
const packageRoot =
|
|
9913
|
+
const packageRoot = path27.dirname(path27.dirname(options.cliEntry));
|
|
9791
9914
|
const name = packageName(packageRoot);
|
|
9792
9915
|
if (!name) {
|
|
9793
9916
|
error("\u7121\u6CD5\u8FA8\u8B58\u76EE\u524D VibeFlow \u7684 npm \u5957\u4EF6\u540D\u7A31\uFF0C\u5DF2\u53D6\u6D88\u66F4\u65B0\u3002");
|
|
@@ -9799,7 +9922,7 @@ function runUpdate(options) {
|
|
|
9799
9922
|
return 1;
|
|
9800
9923
|
}
|
|
9801
9924
|
try {
|
|
9802
|
-
const globalPackage =
|
|
9925
|
+
const globalPackage = path27.join(String(root.stdout).trim(), ...name.split("/"));
|
|
9803
9926
|
if (fs25.lstatSync(globalPackage).isSymbolicLink() || fs25.realpathSync(globalPackage) !== fs25.realpathSync(packageRoot)) {
|
|
9804
9927
|
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");
|
|
9805
9928
|
return 1;
|
|
@@ -9946,7 +10069,7 @@ async function openUpdateTerminal(platform = process.platform, run3 = launch) {
|
|
|
9946
10069
|
|
|
9947
10070
|
// packages/cli/src/self-update.ts
|
|
9948
10071
|
import fs26 from "node:fs";
|
|
9949
|
-
import
|
|
10072
|
+
import path28 from "node:path";
|
|
9950
10073
|
import { execFile as execFile10 } from "node:child_process";
|
|
9951
10074
|
import { promisify as promisify7 } from "node:util";
|
|
9952
10075
|
var execFileAsync2 = promisify7(execFile10);
|
|
@@ -9955,7 +10078,7 @@ var PROBE_RETRY_MS = 3e4;
|
|
|
9955
10078
|
var HOST_TOKEN_ENV = "VIBEFLOW_HOST_TOKEN";
|
|
9956
10079
|
function readInstalledVersion(packageRoot) {
|
|
9957
10080
|
try {
|
|
9958
|
-
const pkg = JSON.parse(fs26.readFileSync(
|
|
10081
|
+
const pkg = JSON.parse(fs26.readFileSync(path28.join(packageRoot, "package.json"), "utf8"));
|
|
9959
10082
|
return typeof pkg.version === "string" ? pkg.version : null;
|
|
9960
10083
|
} catch {
|
|
9961
10084
|
return null;
|
|
@@ -10051,7 +10174,7 @@ async function startHost(options) {
|
|
|
10051
10174
|
const core = createCore({ sessions, bus, version: options.version, titleTranslator: claudeTitleTranslator });
|
|
10052
10175
|
let updateTimer = null;
|
|
10053
10176
|
let installTimer = null;
|
|
10054
|
-
const packageRoot = options.cliEntry ?
|
|
10177
|
+
const packageRoot = options.cliEntry ? path29.dirname(path29.dirname(options.cliEntry)) : null;
|
|
10055
10178
|
const updates = createUpdateMonitor({
|
|
10056
10179
|
packageName: options.sourceRoot || !packageRoot ? null : packageName(packageRoot),
|
|
10057
10180
|
currentVersion: options.version,
|
|
@@ -10139,12 +10262,12 @@ function loginUrl(lock, pathname = "/home/") {
|
|
|
10139
10262
|
return `http://127.0.0.1:${lock.port}${pathname}?token=${encodeURIComponent(lock.token)}`;
|
|
10140
10263
|
}
|
|
10141
10264
|
function isWebDir(dir) {
|
|
10142
|
-
return fs27.existsSync(
|
|
10265
|
+
return fs27.existsSync(path29.join(dir, "home", "index.html"));
|
|
10143
10266
|
}
|
|
10144
10267
|
|
|
10145
10268
|
// packages/cli/src/doctor.ts
|
|
10146
10269
|
import fs28 from "fs";
|
|
10147
|
-
import
|
|
10270
|
+
import path30 from "path";
|
|
10148
10271
|
import { execFile as execFile11 } from "child_process";
|
|
10149
10272
|
import { promisify as promisify8 } from "util";
|
|
10150
10273
|
init_env();
|
|
@@ -10285,7 +10408,7 @@ async function runDoctor(options) {
|
|
|
10285
10408
|
}
|
|
10286
10409
|
try {
|
|
10287
10410
|
fs28.mkdirSync(options.userDataDir, { recursive: true });
|
|
10288
|
-
const probe =
|
|
10411
|
+
const probe = path30.join(options.userDataDir, `.doctor-${process.pid}`);
|
|
10289
10412
|
fs28.writeFileSync(probe, "");
|
|
10290
10413
|
fs28.rmSync(probe);
|
|
10291
10414
|
checks.push({ id: "data", name: "\u8CC7\u6599\u76EE\u9304", level: "ok", detail: options.userDataDir });
|
|
@@ -10342,20 +10465,20 @@ Options:
|
|
|
10342
10465
|
`.trim();
|
|
10343
10466
|
function detectLayout() {
|
|
10344
10467
|
const file = fileURLToPath2(import.meta.url);
|
|
10345
|
-
const here =
|
|
10346
|
-
const bundledWeb =
|
|
10347
|
-
if (isWebDir(bundledWeb) ||
|
|
10468
|
+
const here = path33.dirname(file);
|
|
10469
|
+
const bundledWeb = path33.join(here, "web");
|
|
10470
|
+
if (isWebDir(bundledWeb) || path33.basename(here) === "dist") {
|
|
10348
10471
|
return {
|
|
10349
|
-
version: readVersion(
|
|
10472
|
+
version: readVersion(path33.join(here, "..", "package.json")),
|
|
10350
10473
|
webDir: isWebDir(bundledWeb) ? bundledWeb : null,
|
|
10351
10474
|
sourceRoot: null,
|
|
10352
10475
|
cliEntry: file
|
|
10353
10476
|
};
|
|
10354
10477
|
}
|
|
10355
|
-
const root =
|
|
10478
|
+
const root = path33.resolve(here, "..", "..", "..");
|
|
10356
10479
|
const override = process.env.VIBEFLOW_WEB_DIR;
|
|
10357
|
-
const webDir = override && isWebDir(override) ? override : isWebDir(
|
|
10358
|
-
return { version: readVersion(
|
|
10480
|
+
const webDir = override && isWebDir(override) ? override : isWebDir(path33.join(root, "app")) ? path33.join(root, "app") : null;
|
|
10481
|
+
return { version: readVersion(path33.join(root, "package.json")), webDir, sourceRoot: root, cliEntry: null };
|
|
10359
10482
|
}
|
|
10360
10483
|
function readVersion(pkgPath) {
|
|
10361
10484
|
try {
|
|
@@ -10597,7 +10720,7 @@ async function cmdOpen(values, target, layout, userDataDir) {
|
|
|
10597
10720
|
console.error("\u7528\u6CD5\uFF1Avibeflow open <path>");
|
|
10598
10721
|
return 1;
|
|
10599
10722
|
}
|
|
10600
|
-
const dir =
|
|
10723
|
+
const dir = path33.resolve(target);
|
|
10601
10724
|
if (!fs30.existsSync(dir) || !fs30.statSync(dir).isDirectory()) {
|
|
10602
10725
|
console.error(`\u4E0D\u662F\u8CC7\u6599\u593E\uFF1A${dir}`);
|
|
10603
10726
|
return 1;
|