@sideboard-ai/core 0.1.338 → 0.1.339
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agents-MM6VNDOI.js → agents-6MSZHZOM.js} +3 -3
- package/dist/{agents-4ZABRO2T.js → agents-QFXIBIKJ.js} +3 -3
- package/dist/{chunk-5MXLDDYF.js → chunk-5KH3EQ2C.js} +7 -0
- package/dist/{chunk-LJESHMFJ.js → chunk-6ABL7HZN.js} +14 -4
- package/dist/{chunk-T76WCIQN.js → chunk-BD7QARIJ.js} +3 -2
- package/dist/{chunk-OOXRMTU6.js → chunk-DYUAVL5S.js} +7 -0
- package/dist/{chunk-JGJIR66Z.js → chunk-ELDHERAD.js} +14 -11
- package/dist/{chunk-BR3C3EX5.js → chunk-EVYOONTE.js} +3 -2
- package/dist/{chunk-UPZD4SYD.js → chunk-EZZY3EAZ.js} +13 -10
- package/dist/{chunk-QJGAWDAX.js → chunk-NHLTTT5G.js} +3 -3
- package/dist/{chunk-2QN74PVY.js → chunk-PEJ3N5VE.js} +3 -3
- package/dist/{chunk-X3W3HBLK.js → chunk-VHHEQP5V.js} +14 -4
- package/dist/{conductor-HKZKX2JD.js → conductor-AUUXCJZT.js} +3 -3
- package/dist/{conductor-OTYQMFNT.js → conductor-LEPTWN2U.js} +3 -3
- package/dist/{coordinator-prompt-AHR54RWJ.js → coordinator-prompt-CIWWP2P6.js} +1 -1
- package/dist/{coordinator-prompt-GMGYQ5XT.js → coordinator-prompt-VO42IZWS.js} +1 -1
- package/dist/{global-workspace-WRME3OJ5.js → global-workspace-FKXLFKYX.js} +1 -1
- package/dist/{global-workspace-TDR6OHL6.js → global-workspace-MCAREQI7.js} +1 -1
- package/dist/index.cjs +2301 -977
- package/dist/index.d.cts +271 -3
- package/dist/index.d.ts +271 -3
- package/dist/index.js +1455 -195
- package/dist/mcp/run-stdio.cjs +1330 -163
- package/dist/mcp/run-stdio.js +1294 -152
- package/dist/{orchestrator-NXLV3FF4.js → orchestrator-JTFCNXVR.js} +5 -5
- package/dist/{orchestrator-CJBYJVD7.js → orchestrator-NOQDMYLB.js} +5 -5
- package/dist/{workspaces-7ZB6GUXB.js → workspaces-D6FQCZRK.js} +1 -1
- package/dist/{workspaces-XXO2T45C.js → workspaces-Y25L2EPV.js} +1 -1
- package/package.json +1 -1
package/dist/mcp/run-stdio.js
CHANGED
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
syncBoardPins,
|
|
46
46
|
workspaceTagTargetRef,
|
|
47
47
|
writeAgentBlock
|
|
48
|
-
} from "../chunk-
|
|
48
|
+
} from "../chunk-EZZY3EAZ.js";
|
|
49
49
|
import "../chunk-DC3VZXMA.js";
|
|
50
50
|
import {
|
|
51
51
|
SIDEBOARD_THREAD_ID_ENV,
|
|
@@ -55,7 +55,7 @@ import {
|
|
|
55
55
|
shouldRegisterMcpWaitForTurn,
|
|
56
56
|
sideboardMcpProfile,
|
|
57
57
|
worktreeMcpToolNames
|
|
58
|
-
} from "../chunk-
|
|
58
|
+
} from "../chunk-VHHEQP5V.js";
|
|
59
59
|
import {
|
|
60
60
|
mcpWaitForJobTimeoutMs,
|
|
61
61
|
mcpWaitForTurnTimeoutMs,
|
|
@@ -66,14 +66,14 @@ import {
|
|
|
66
66
|
waitForDetachedJob,
|
|
67
67
|
waitForTurnToolResult,
|
|
68
68
|
workspaceAgentChatSummaries
|
|
69
|
-
} from "../chunk-
|
|
69
|
+
} from "../chunk-NHLTTT5G.js";
|
|
70
70
|
import {
|
|
71
71
|
HUGE_TOOL_RESULT_SUMMARY,
|
|
72
72
|
clipToolResultForStore,
|
|
73
73
|
formatUnknownDetail,
|
|
74
74
|
isInternalAgentStatusText,
|
|
75
75
|
looksLikeHugeToolResultDump
|
|
76
|
-
} from "../chunk-
|
|
76
|
+
} from "../chunk-5KH3EQ2C.js";
|
|
77
77
|
import "../chunk-LX5R5JOR.js";
|
|
78
78
|
import {
|
|
79
79
|
commentAbleTimeTask,
|
|
@@ -97,13 +97,14 @@ import "../chunk-HNW5KMGK.js";
|
|
|
97
97
|
import {
|
|
98
98
|
PRESENT_PLAN_REQUIRES_PLAN_MODE,
|
|
99
99
|
PRESENT_PLAN_TOOL_DESCRIPTION,
|
|
100
|
+
readPlanFile,
|
|
100
101
|
shouldRegisterPresentPlan,
|
|
101
102
|
threadMayPresentPlan
|
|
102
103
|
} from "../chunk-4GK32AYX.js";
|
|
103
104
|
import {
|
|
104
105
|
GLOBAL_WORKSPACE_ID,
|
|
105
106
|
isCloudCoordinatorThread
|
|
106
|
-
} from "../chunk-
|
|
107
|
+
} from "../chunk-EVYOONTE.js";
|
|
107
108
|
import {
|
|
108
109
|
canonicalizeRepoPath,
|
|
109
110
|
formatGhLandError,
|
|
@@ -161,6 +162,7 @@ import {
|
|
|
161
162
|
deleteSchedule,
|
|
162
163
|
getSchedule,
|
|
163
164
|
listSchedules,
|
|
165
|
+
listThreads,
|
|
164
166
|
normalizeWorkspaceTags,
|
|
165
167
|
parseWeeklyDays,
|
|
166
168
|
readThread,
|
|
@@ -181,7 +183,9 @@ import {
|
|
|
181
183
|
resolveViewerProfile,
|
|
182
184
|
resolveViewerProfileForRepo
|
|
183
185
|
} from "../chunk-N6TGSJVC.js";
|
|
184
|
-
import
|
|
186
|
+
import {
|
|
187
|
+
writePrivateFile
|
|
188
|
+
} from "../chunk-NSTQ6QKD.js";
|
|
185
189
|
import {
|
|
186
190
|
dropNestedElectronEnvFromProcess
|
|
187
191
|
} from "../chunk-WWUABK6B.js";
|
|
@@ -298,8 +302,8 @@ function createClippedMcpServer() {
|
|
|
298
302
|
}
|
|
299
303
|
|
|
300
304
|
// src/mcp/server.ts
|
|
301
|
-
import { z as
|
|
302
|
-
import { randomUUID as
|
|
305
|
+
import { z as z9 } from "zod";
|
|
306
|
+
import { randomUUID as randomUUID4 } from "crypto";
|
|
303
307
|
import { basename } from "path";
|
|
304
308
|
|
|
305
309
|
// src/integrations/github-issue-attachments.ts
|
|
@@ -2621,8 +2625,1145 @@ function registerScheduleTools(server) {
|
|
|
2621
2625
|
);
|
|
2622
2626
|
}
|
|
2623
2627
|
|
|
2624
|
-
// src/
|
|
2628
|
+
// src/mcp/order-tools.ts
|
|
2629
|
+
import { z as z8 } from "zod";
|
|
2630
|
+
|
|
2631
|
+
// src/order/order.ts
|
|
2625
2632
|
import { randomUUID } from "crypto";
|
|
2633
|
+
import { existsSync, readFileSync } from "fs";
|
|
2634
|
+
import { join as join2 } from "path";
|
|
2635
|
+
|
|
2636
|
+
// src/order/order-model.ts
|
|
2637
|
+
function parseOrderGate(value) {
|
|
2638
|
+
const s = value.trim().toLowerCase().replace(/[\s_-]+/g, "");
|
|
2639
|
+
if (s === "inmain" || s === "main" || s === "merged") return "in-main";
|
|
2640
|
+
if (s === "inprod" || s === "prod" || s === "production") return "in-prod";
|
|
2641
|
+
throw new Error("gate must be in-main or in-prod");
|
|
2642
|
+
}
|
|
2643
|
+
function parseOrderHold(value) {
|
|
2644
|
+
const s = value.trim().toLowerCase().replace(/[\s_-]+/g, "");
|
|
2645
|
+
if (s === "start" || s === "beforestart") return "start";
|
|
2646
|
+
if (s === "merge" || s === "beforemerge") return "merge";
|
|
2647
|
+
throw new Error("hold must be start or merge");
|
|
2648
|
+
}
|
|
2649
|
+
function parseOrderKind(value) {
|
|
2650
|
+
const s = value.trim().toLowerCase().replace(/[\s_-]+/g, "");
|
|
2651
|
+
if (s === "pr" || s === "pull" || s === "pullrequest") return "pr";
|
|
2652
|
+
if (s === "issue" || s === "ticket" || s === "task") return "issue";
|
|
2653
|
+
if (s === "workspace" || s === "worktree" || s === "checkout") return "workspace";
|
|
2654
|
+
if (s === "orchestration" || s === "orchestrator" || s === "agent") return "orchestration";
|
|
2655
|
+
throw new Error("kind must be pr, issue, workspace, or orchestration");
|
|
2656
|
+
}
|
|
2657
|
+
function normalizeOrderTarget(input) {
|
|
2658
|
+
const kind = parseOrderKind(input.kind);
|
|
2659
|
+
const raw = input.ref.trim();
|
|
2660
|
+
if (!raw) throw new Error(`${kind} ref is required`);
|
|
2661
|
+
let ref = raw;
|
|
2662
|
+
if (kind === "pr") {
|
|
2663
|
+
const match = raw.match(/(\d+)/);
|
|
2664
|
+
if (!match) throw new Error("PR ref must be a number");
|
|
2665
|
+
ref = match[1];
|
|
2666
|
+
} else if (kind === "issue") {
|
|
2667
|
+
ref = raw.replace(/^#/, "");
|
|
2668
|
+
}
|
|
2669
|
+
const repoPath = input.repoPath?.trim().replace(/\/+$/, "") || void 0;
|
|
2670
|
+
const label = input.label?.trim() || void 0;
|
|
2671
|
+
const target = { kind, ref };
|
|
2672
|
+
if (repoPath) target.repoPath = repoPath;
|
|
2673
|
+
if (label) target.label = label;
|
|
2674
|
+
return target;
|
|
2675
|
+
}
|
|
2676
|
+
function targetKey(target) {
|
|
2677
|
+
const ref = target.ref.trim().replace(/^#/, "").toLowerCase();
|
|
2678
|
+
const repo = (target.repoPath ?? "").replace(/\/+$/, "").toLowerCase();
|
|
2679
|
+
if (target.kind === "issue" && !repo) return `issue:${ref}`;
|
|
2680
|
+
if (target.kind === "orchestration") return `orchestration:${ref}`;
|
|
2681
|
+
return `${target.kind}:${repo}:${ref}`;
|
|
2682
|
+
}
|
|
2683
|
+
function samePath(a, b) {
|
|
2684
|
+
return a.trim().replace(/\/+$/, "") === b.trim().replace(/\/+$/, "");
|
|
2685
|
+
}
|
|
2686
|
+
function repoMatches(target, thread) {
|
|
2687
|
+
if (!target.repoPath || !thread.repoPath) return true;
|
|
2688
|
+
return samePath(target.repoPath, thread.repoPath);
|
|
2689
|
+
}
|
|
2690
|
+
function orderPrNumber(thread) {
|
|
2691
|
+
if (thread.sourceType === "pr") {
|
|
2692
|
+
const n = Number(String(thread.sourceRef).replace(/^#/, ""));
|
|
2693
|
+
if (Number.isInteger(n) && n >= 1) return n;
|
|
2694
|
+
}
|
|
2695
|
+
const match = (thread.prUrl ?? "").match(/\/pull\/(\d+)(?:\/|$|[?#])/i);
|
|
2696
|
+
return match ? Number(match[1]) : null;
|
|
2697
|
+
}
|
|
2698
|
+
function orderTargetMatches(target, thread) {
|
|
2699
|
+
if (!repoMatches(target, thread)) return false;
|
|
2700
|
+
if (target.kind === "pr") {
|
|
2701
|
+
const n = Number(target.ref);
|
|
2702
|
+
return Number.isInteger(n) && orderPrNumber(thread) === n;
|
|
2703
|
+
}
|
|
2704
|
+
if (target.kind === "issue") {
|
|
2705
|
+
if (thread.sourceType !== "ticket") return false;
|
|
2706
|
+
return thread.sourceRef.trim().replace(/^#/, "").toLowerCase() === target.ref.trim().toLowerCase();
|
|
2707
|
+
}
|
|
2708
|
+
if (target.kind === "orchestration") {
|
|
2709
|
+
const orchestrator = thread.sourceType === "orchestration" || thread.repoPath === "__global__";
|
|
2710
|
+
if (!orchestrator) return false;
|
|
2711
|
+
const ref2 = target.ref.trim();
|
|
2712
|
+
if (thread.id === ref2) return true;
|
|
2713
|
+
return ref2.length >= 8 && !ref2.includes("/") && thread.id.startsWith(ref2);
|
|
2714
|
+
}
|
|
2715
|
+
const ref = target.ref.trim();
|
|
2716
|
+
if (thread.id === ref) return true;
|
|
2717
|
+
if (thread.worktreePath && samePath(thread.worktreePath, ref)) return true;
|
|
2718
|
+
return ref.length >= 8 && !ref.includes("/") && thread.id.startsWith(ref);
|
|
2719
|
+
}
|
|
2720
|
+
function orderSnapshotFromThread(thread) {
|
|
2721
|
+
return {
|
|
2722
|
+
id: thread.id,
|
|
2723
|
+
title: thread.title,
|
|
2724
|
+
sourceType: thread.sourceType,
|
|
2725
|
+
sourceRef: thread.sourceRef,
|
|
2726
|
+
repoPath: thread.repoPath,
|
|
2727
|
+
worktreePath: thread.worktreePath,
|
|
2728
|
+
prUrl: thread.prUrl ?? null,
|
|
2729
|
+
prState: thread.prState ?? null,
|
|
2730
|
+
prTitle: thread.prTitle ?? null,
|
|
2731
|
+
status: thread.status,
|
|
2732
|
+
parentThreadId: "parentThreadId" in thread ? thread.parentThreadId ?? null : null
|
|
2733
|
+
};
|
|
2734
|
+
}
|
|
2735
|
+
function defaultOrderSubject(thread, hold) {
|
|
2736
|
+
const pr = orderPrNumber(thread);
|
|
2737
|
+
if (hold === "merge" && pr) {
|
|
2738
|
+
const target2 = {
|
|
2739
|
+
kind: "pr",
|
|
2740
|
+
ref: String(pr),
|
|
2741
|
+
label: thread.prTitle || thread.title
|
|
2742
|
+
};
|
|
2743
|
+
if (thread.repoPath) target2.repoPath = thread.repoPath;
|
|
2744
|
+
return target2;
|
|
2745
|
+
}
|
|
2746
|
+
if (hold === "start" && thread.sourceType === "ticket" && thread.sourceRef.trim()) {
|
|
2747
|
+
const target2 = {
|
|
2748
|
+
kind: "issue",
|
|
2749
|
+
ref: thread.sourceRef.trim().replace(/^#/, ""),
|
|
2750
|
+
label: thread.title
|
|
2751
|
+
};
|
|
2752
|
+
if (thread.repoPath) target2.repoPath = thread.repoPath;
|
|
2753
|
+
return target2;
|
|
2754
|
+
}
|
|
2755
|
+
const target = {
|
|
2756
|
+
kind: "workspace",
|
|
2757
|
+
ref: thread.worktreePath || thread.id,
|
|
2758
|
+
label: thread.title
|
|
2759
|
+
};
|
|
2760
|
+
if (thread.repoPath) target.repoPath = thread.repoPath;
|
|
2761
|
+
return target;
|
|
2762
|
+
}
|
|
2763
|
+
function assertCallerOwnsSubject(caller, subject) {
|
|
2764
|
+
if (!orderTargetMatches(subject, caller)) {
|
|
2765
|
+
throw new Error(
|
|
2766
|
+
"This checkout can only set a dependency on its own workspace, PR, or ticket."
|
|
2767
|
+
);
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
function shortName(target) {
|
|
2771
|
+
if (target.label?.trim()) return target.label.trim();
|
|
2772
|
+
if (target.kind === "pr") return `PR #${target.ref}`;
|
|
2773
|
+
if (target.kind === "issue") return target.ref;
|
|
2774
|
+
if (target.kind === "orchestration") return "that orchestration";
|
|
2775
|
+
return "that workspace";
|
|
2776
|
+
}
|
|
2777
|
+
function dependencyIdentity(edge) {
|
|
2778
|
+
return `${targetKey(edge.waitsOn)}|${edge.gate}|${targetKey(edge.subject)}|${edge.hold}`;
|
|
2779
|
+
}
|
|
2780
|
+
function dependencyWouldCycle(edges, next) {
|
|
2781
|
+
const start = targetKey(next.subject);
|
|
2782
|
+
const goal = targetKey(next.waitsOn);
|
|
2783
|
+
if (start === goal) return true;
|
|
2784
|
+
const adj = /* @__PURE__ */ new Map();
|
|
2785
|
+
for (const edge of edges) {
|
|
2786
|
+
const from = targetKey(edge.waitsOn);
|
|
2787
|
+
const to = targetKey(edge.subject);
|
|
2788
|
+
const list = adj.get(from) ?? [];
|
|
2789
|
+
list.push(to);
|
|
2790
|
+
adj.set(from, list);
|
|
2791
|
+
}
|
|
2792
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2793
|
+
const stack = [start];
|
|
2794
|
+
while (stack.length) {
|
|
2795
|
+
const cur = stack.pop();
|
|
2796
|
+
if (cur === goal) return true;
|
|
2797
|
+
if (seen.has(cur)) continue;
|
|
2798
|
+
seen.add(cur);
|
|
2799
|
+
for (const nextKey of adj.get(cur) ?? []) stack.push(nextKey);
|
|
2800
|
+
}
|
|
2801
|
+
return false;
|
|
2802
|
+
}
|
|
2803
|
+
function cycleDependencyMessage(next) {
|
|
2804
|
+
if (targetKey(next.subject) === targetKey(next.waitsOn)) {
|
|
2805
|
+
return "A step cannot wait on itself.";
|
|
2806
|
+
}
|
|
2807
|
+
return `That dependency loops: ${shortName(next.subject)} already has to finish before ${shortName(next.waitsOn)}.`;
|
|
2808
|
+
}
|
|
2809
|
+
function subjectDepths(edges) {
|
|
2810
|
+
const depth = /* @__PURE__ */ new Map();
|
|
2811
|
+
const touch = (key) => {
|
|
2812
|
+
if (!depth.has(key)) depth.set(key, 0);
|
|
2813
|
+
};
|
|
2814
|
+
for (const edge of edges) {
|
|
2815
|
+
touch(targetKey(edge.waitsOn));
|
|
2816
|
+
touch(targetKey(edge.subject));
|
|
2817
|
+
}
|
|
2818
|
+
for (let pass = 0; pass < depth.size; pass++) {
|
|
2819
|
+
let changed = false;
|
|
2820
|
+
for (const edge of edges) {
|
|
2821
|
+
const from = targetKey(edge.waitsOn);
|
|
2822
|
+
const to = targetKey(edge.subject);
|
|
2823
|
+
const next = (depth.get(from) ?? 0) + 1;
|
|
2824
|
+
if (next > (depth.get(to) ?? 0)) {
|
|
2825
|
+
depth.set(to, next);
|
|
2826
|
+
changed = true;
|
|
2827
|
+
}
|
|
2828
|
+
}
|
|
2829
|
+
if (!changed) break;
|
|
2830
|
+
}
|
|
2831
|
+
return depth;
|
|
2832
|
+
}
|
|
2833
|
+
function threadFor(target, threads) {
|
|
2834
|
+
const live = threads.filter((thread) => thread.status !== "archived");
|
|
2835
|
+
return live.find((thread) => orderTargetMatches(target, thread)) ?? threads.find((thread) => orderTargetMatches(target, thread));
|
|
2836
|
+
}
|
|
2837
|
+
function orderTargetLabel(target, threads) {
|
|
2838
|
+
const hit = threadFor(target, threads);
|
|
2839
|
+
if (target.kind === "pr") {
|
|
2840
|
+
const title = target.label?.trim() || hit?.prTitle?.trim() || "";
|
|
2841
|
+
const base = `PR #${target.ref}`;
|
|
2842
|
+
return title && title !== base ? `${base} \xB7 ${title}` : base;
|
|
2843
|
+
}
|
|
2844
|
+
if (target.kind === "issue") {
|
|
2845
|
+
const title = target.label?.trim() || (hit?.sourceType === "ticket" ? hit.title.trim() : "");
|
|
2846
|
+
return title && title !== target.ref ? `${target.ref} \xB7 ${title}` : target.ref;
|
|
2847
|
+
}
|
|
2848
|
+
if (target.kind === "orchestration") {
|
|
2849
|
+
return target.label?.trim() || hit?.title?.trim() || "Orchestration";
|
|
2850
|
+
}
|
|
2851
|
+
return target.label?.trim() || hit?.title?.trim() || "Workspace";
|
|
2852
|
+
}
|
|
2853
|
+
function prMerged(target, threads) {
|
|
2854
|
+
return threads.some(
|
|
2855
|
+
(thread) => orderTargetMatches(target, thread) && (thread.prState ?? "").toUpperCase() === "MERGED"
|
|
2856
|
+
);
|
|
2857
|
+
}
|
|
2858
|
+
function orderGateStatus(edge, threads, marks) {
|
|
2859
|
+
const key = targetKey(edge.waitsOn);
|
|
2860
|
+
const marked = marks.some((mark) => mark.key === key && mark.gate === edge.gate);
|
|
2861
|
+
if (edge.gate === "in-prod") {
|
|
2862
|
+
return marked ? { met: true, marked: true, detail: "marked in production" } : { met: false, marked: false, detail: "waiting to be marked in production" };
|
|
2863
|
+
}
|
|
2864
|
+
if (marked) return { met: true, marked: true, detail: "marked in main" };
|
|
2865
|
+
if (prMerged(edge.waitsOn, threads)) {
|
|
2866
|
+
return { met: true, marked: false, detail: "merged to main" };
|
|
2867
|
+
}
|
|
2868
|
+
const known = threads.some((thread) => orderTargetMatches(edge.waitsOn, thread));
|
|
2869
|
+
return known ? { met: false, marked: false, detail: "open \u2014 not in main" } : { met: false, marked: false, detail: "not on the board yet" };
|
|
2870
|
+
}
|
|
2871
|
+
function resolveOrderRows(edges, threads, marks = []) {
|
|
2872
|
+
const depths = subjectDepths(edges);
|
|
2873
|
+
return edges.map((edge) => {
|
|
2874
|
+
const status = orderGateStatus(edge, threads, marks);
|
|
2875
|
+
return {
|
|
2876
|
+
id: edge.id,
|
|
2877
|
+
waitsOn: edge.waitsOn,
|
|
2878
|
+
subject: edge.subject,
|
|
2879
|
+
gate: edge.gate,
|
|
2880
|
+
hold: edge.hold,
|
|
2881
|
+
note: edge.note,
|
|
2882
|
+
loop: edge.loop === true,
|
|
2883
|
+
depth: depths.get(targetKey(edge.subject)) ?? 1,
|
|
2884
|
+
met: status.met,
|
|
2885
|
+
marked: status.marked,
|
|
2886
|
+
detail: status.detail,
|
|
2887
|
+
waitsOnLabel: orderTargetLabel(edge.waitsOn, threads),
|
|
2888
|
+
subjectLabel: orderTargetLabel(edge.subject, threads)
|
|
2889
|
+
};
|
|
2890
|
+
}).sort(
|
|
2891
|
+
(a, b) => a.depth - b.depth || a.waitsOnLabel.localeCompare(b.waitsOnLabel) || a.subjectLabel.localeCompare(b.subjectLabel)
|
|
2892
|
+
);
|
|
2893
|
+
}
|
|
2894
|
+
|
|
2895
|
+
// src/order/order-board.ts
|
|
2896
|
+
function buildWaterfall(rows) {
|
|
2897
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
2898
|
+
const links = [];
|
|
2899
|
+
const depthOf = /* @__PURE__ */ new Map();
|
|
2900
|
+
for (const row of rows) {
|
|
2901
|
+
const to = targetKey(row.subject);
|
|
2902
|
+
depthOf.set(to, Math.max(depthOf.get(to) ?? 0, row.depth));
|
|
2903
|
+
if (!depthOf.has(targetKey(row.waitsOn))) depthOf.set(targetKey(row.waitsOn), 0);
|
|
2904
|
+
}
|
|
2905
|
+
function ensure(target, label) {
|
|
2906
|
+
const key = targetKey(target);
|
|
2907
|
+
let node = nodes.get(key);
|
|
2908
|
+
if (!node) {
|
|
2909
|
+
node = {
|
|
2910
|
+
key,
|
|
2911
|
+
label,
|
|
2912
|
+
kind: target.kind,
|
|
2913
|
+
ref: target.ref,
|
|
2914
|
+
...target.repoPath ? { repoPath: target.repoPath } : {},
|
|
2915
|
+
depth: depthOf.get(key) ?? 0,
|
|
2916
|
+
incoming: []
|
|
2917
|
+
};
|
|
2918
|
+
nodes.set(key, node);
|
|
2919
|
+
}
|
|
2920
|
+
return node;
|
|
2921
|
+
}
|
|
2922
|
+
for (const row of rows) {
|
|
2923
|
+
ensure(row.waitsOn, row.waitsOnLabel);
|
|
2924
|
+
const subject = ensure(row.subject, row.subjectLabel);
|
|
2925
|
+
subject.depth = Math.max(subject.depth, row.depth);
|
|
2926
|
+
subject.incoming.push({
|
|
2927
|
+
edgeId: row.id,
|
|
2928
|
+
fromKey: targetKey(row.waitsOn),
|
|
2929
|
+
gate: row.gate,
|
|
2930
|
+
hold: row.hold,
|
|
2931
|
+
met: row.met,
|
|
2932
|
+
marked: row.marked,
|
|
2933
|
+
detail: row.detail,
|
|
2934
|
+
fromLabel: row.waitsOnLabel,
|
|
2935
|
+
note: row.note,
|
|
2936
|
+
loop: row.loop === true
|
|
2937
|
+
});
|
|
2938
|
+
links.push({ from: targetKey(row.waitsOn), to: targetKey(row.subject) });
|
|
2939
|
+
}
|
|
2940
|
+
const parent = /* @__PURE__ */ new Map();
|
|
2941
|
+
const find = (key) => {
|
|
2942
|
+
const current = parent.get(key) ?? key;
|
|
2943
|
+
if (current === key) return key;
|
|
2944
|
+
const root = find(current);
|
|
2945
|
+
parent.set(key, root);
|
|
2946
|
+
return root;
|
|
2947
|
+
};
|
|
2948
|
+
for (const key of nodes.keys()) parent.set(key, key);
|
|
2949
|
+
for (const link of links) {
|
|
2950
|
+
const left = find(link.from);
|
|
2951
|
+
const right = find(link.to);
|
|
2952
|
+
if (left !== right) parent.set(left, right);
|
|
2953
|
+
}
|
|
2954
|
+
const groups = /* @__PURE__ */ new Map();
|
|
2955
|
+
for (const node of nodes.values()) {
|
|
2956
|
+
const root = find(node.key);
|
|
2957
|
+
const list = groups.get(root) ?? [];
|
|
2958
|
+
list.push(node);
|
|
2959
|
+
groups.set(root, list);
|
|
2960
|
+
}
|
|
2961
|
+
return [...groups.values()].map((list) => ({
|
|
2962
|
+
nodes: list.sort(
|
|
2963
|
+
(a, b) => a.depth - b.depth || a.label.localeCompare(b.label)
|
|
2964
|
+
)
|
|
2965
|
+
})).sort((a, b) => (a.nodes[0]?.label ?? "").localeCompare(b.nodes[0]?.label ?? ""));
|
|
2966
|
+
}
|
|
2967
|
+
function gatePhrase(gate) {
|
|
2968
|
+
return gate === "in-prod" ? "in production" : "in main";
|
|
2969
|
+
}
|
|
2970
|
+
function holdPhrase(hold) {
|
|
2971
|
+
return hold === "merge" ? "can merge" : "can start";
|
|
2972
|
+
}
|
|
2973
|
+
function ownerMatches(ref, ownerThreadId) {
|
|
2974
|
+
const left = ref.trim();
|
|
2975
|
+
const right = ownerThreadId.trim();
|
|
2976
|
+
if (!left || !right) return false;
|
|
2977
|
+
if (left === right) return true;
|
|
2978
|
+
return left.length >= 8 && !left.includes("/") && right.startsWith(left);
|
|
2979
|
+
}
|
|
2980
|
+
function resolveOrchestrationGates(plans, edges, threads, marks = []) {
|
|
2981
|
+
const rows = resolveOrderRows(edges, threads, marks);
|
|
2982
|
+
const planOf = new Map(edges.map((edge) => [edge.id, edge.planId ?? ""]));
|
|
2983
|
+
for (let pass = 0; pass < 8; pass++) {
|
|
2984
|
+
let changed = false;
|
|
2985
|
+
const clearByOwner = /* @__PURE__ */ new Map();
|
|
2986
|
+
for (const plan of plans) {
|
|
2987
|
+
if (!plan.ownerThreadId) continue;
|
|
2988
|
+
const mine = rows.filter((row) => planOf.get(row.id) === plan.id);
|
|
2989
|
+
clearByOwner.set(plan.ownerThreadId, mine.length > 0 && mine.every((row) => row.met));
|
|
2990
|
+
}
|
|
2991
|
+
for (const row of rows) {
|
|
2992
|
+
if (row.gate !== "in-main" || row.waitsOn.kind !== "orchestration" || row.marked) continue;
|
|
2993
|
+
const plan = plans.find((item) => ownerMatches(row.waitsOn.ref, item.ownerThreadId));
|
|
2994
|
+
const count = plan ? rows.filter((item) => planOf.get(item.id) === plan.id).length : 0;
|
|
2995
|
+
const clear = plan ? clearByOwner.get(plan.ownerThreadId) === true : false;
|
|
2996
|
+
const detail = !plan ? "no plan yet" : count === 0 ? "plan has no steps" : clear ? "plan is clear" : "plan still waiting";
|
|
2997
|
+
if (row.met !== clear || row.detail !== detail) {
|
|
2998
|
+
row.met = clear;
|
|
2999
|
+
row.detail = detail;
|
|
3000
|
+
row.marked = false;
|
|
3001
|
+
changed = true;
|
|
3002
|
+
}
|
|
3003
|
+
}
|
|
3004
|
+
if (!changed) break;
|
|
3005
|
+
}
|
|
3006
|
+
return rows;
|
|
3007
|
+
}
|
|
3008
|
+
|
|
3009
|
+
// src/order/order-present.ts
|
|
3010
|
+
function formatOrderPlace(rows, you) {
|
|
3011
|
+
const mine = (target) => orderTargetMatches(target, you);
|
|
3012
|
+
const waitingOn = rows.filter((row) => mine(row.subject) && !row.met && !row.loop);
|
|
3013
|
+
const looping = rows.filter((row) => mine(row.subject) && row.loop && !row.met);
|
|
3014
|
+
const ready = rows.filter((row) => mine(row.subject) && row.met);
|
|
3015
|
+
const blocking = rows.filter((row) => mine(row.waitsOn) && !row.met && !row.loop);
|
|
3016
|
+
if (!waitingOn.length && !looping.length && !ready.length && !blocking.length) {
|
|
3017
|
+
return "This checkout is not in the planner. set_dependency records what you wait on (omit subject). clear_dependency removes a step you are part of.";
|
|
3018
|
+
}
|
|
3019
|
+
const gate = (row) => row.gate === "in-prod" ? "in prod" : "in main";
|
|
3020
|
+
const lines = ["Where you are in the planner:"];
|
|
3021
|
+
for (const row of waitingOn) {
|
|
3022
|
+
lines.push(
|
|
3023
|
+
`- Waiting: ${row.waitsOnLabel} must be ${gate(row)} before you can ${row.hold}. id: ${row.id.slice(0, 8)}`
|
|
3024
|
+
);
|
|
3025
|
+
}
|
|
3026
|
+
for (const row of looping) {
|
|
3027
|
+
lines.push(
|
|
3028
|
+
`- Loop: returns to ${row.waitsOnLabel} once you are ${gate(row)}. The first pass is not blocked. id: ${row.id.slice(0, 8)}`
|
|
3029
|
+
);
|
|
3030
|
+
}
|
|
3031
|
+
for (const row of ready) {
|
|
3032
|
+
lines.push(`- Clear: you can ${row.hold}. ${row.detail}. id: ${row.id.slice(0, 8)}`);
|
|
3033
|
+
}
|
|
3034
|
+
for (const row of blocking) {
|
|
3035
|
+
lines.push(
|
|
3036
|
+
`- Blocking: ${row.subjectLabel} cannot ${row.hold} until you are ${gate(row)}. id: ${row.id.slice(0, 8)}`
|
|
3037
|
+
);
|
|
3038
|
+
}
|
|
3039
|
+
return lines.join("\n");
|
|
3040
|
+
}
|
|
3041
|
+
function executionSlice(rows) {
|
|
3042
|
+
return {
|
|
3043
|
+
ready: rows.filter((row) => row.met || row.loop),
|
|
3044
|
+
waiting: rows.filter((row) => !row.met && !row.loop)
|
|
3045
|
+
};
|
|
3046
|
+
}
|
|
3047
|
+
function orderEdgeTouches(edge, you) {
|
|
3048
|
+
return orderTargetMatches(edge.subject, you) || orderTargetMatches(edge.waitsOn, you);
|
|
3049
|
+
}
|
|
3050
|
+
function formatOrderText(rows, plan) {
|
|
3051
|
+
if (rows.length === 0) {
|
|
3052
|
+
if (plan) {
|
|
3053
|
+
const goal = plan.goal ? ` Goal: ${plan.goal}.` : "";
|
|
3054
|
+
const summary = plan.summary ? ` ${plan.summary}` : "";
|
|
3055
|
+
return `Plan \u201C${plan.title}\u201D is ${plan.status}.${goal}${summary} No steps yet. set_dependency records each gate.`.replace(/\s+/g, " ").trim();
|
|
3056
|
+
}
|
|
3057
|
+
return "No orchestration plan yet. set_dependency records an order \u2014 for example PR 1 in prod before PR 2 can merge, or PR 3 in main before issue 4 can start. The Orchestration row in the sidebar opens that chat.";
|
|
3058
|
+
}
|
|
3059
|
+
const lines = [
|
|
3060
|
+
plan ? `Plan \u201C${plan.title}\u201D is ${plan.status}. ${plan.goal ? `Goal: ${plan.goal}. ` : ""}${plan.summary}`.trim() : "Orchestration. Steps can wait on a gate or loop back to an earlier step. in-main clears when that PR is merged. in-prod stays waiting until satisfy_dependency.",
|
|
3061
|
+
""
|
|
3062
|
+
];
|
|
3063
|
+
rows.forEach((row, index) => {
|
|
3064
|
+
const gate = row.gate === "in-prod" ? "in prod" : "in main";
|
|
3065
|
+
const hold = row.hold === "merge" ? "merge" : "start";
|
|
3066
|
+
const state = row.loop ? "loop" : row.met ? "clear" : "waiting";
|
|
3067
|
+
lines.push(
|
|
3068
|
+
row.loop ? `${index + 1}. ${state} ${row.subjectLabel} returns to ${row.waitsOnLabel} once it is ${gate}` : `${index + 1}. ${state} ${row.waitsOnLabel} must be ${gate} before ${row.subjectLabel} can ${hold}`
|
|
3069
|
+
);
|
|
3070
|
+
lines.push(` ${row.detail}`);
|
|
3071
|
+
if (row.note) lines.push(` ${row.note}`);
|
|
3072
|
+
lines.push(` id: ${row.id.slice(0, 8)}`);
|
|
3073
|
+
});
|
|
3074
|
+
return lines.join("\n");
|
|
3075
|
+
}
|
|
3076
|
+
function escapeHtml(value) {
|
|
3077
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
3078
|
+
}
|
|
3079
|
+
var WATERFALL_KIND = {
|
|
3080
|
+
pr: "Pull request",
|
|
3081
|
+
issue: "Issue",
|
|
3082
|
+
workspace: "Workspace",
|
|
3083
|
+
orchestration: "Orchestration"
|
|
3084
|
+
};
|
|
3085
|
+
function markWorkingChains(chains, threads) {
|
|
3086
|
+
const active = threads.filter(
|
|
3087
|
+
(thread) => thread.status === "running" || thread.status === "queued"
|
|
3088
|
+
);
|
|
3089
|
+
if (active.length === 0) return chains;
|
|
3090
|
+
return chains.map((chain) => ({
|
|
3091
|
+
nodes: chain.nodes.map((node) => {
|
|
3092
|
+
const working = active.some(
|
|
3093
|
+
(thread) => orderTargetMatches(
|
|
3094
|
+
{
|
|
3095
|
+
kind: node.kind,
|
|
3096
|
+
ref: node.ref,
|
|
3097
|
+
...node.repoPath ? { repoPath: node.repoPath } : {}
|
|
3098
|
+
},
|
|
3099
|
+
thread
|
|
3100
|
+
)
|
|
3101
|
+
);
|
|
3102
|
+
return working ? { ...node, working: true } : node;
|
|
3103
|
+
})
|
|
3104
|
+
}));
|
|
3105
|
+
}
|
|
3106
|
+
function nodeIsYou(node, you) {
|
|
3107
|
+
if (!you) return false;
|
|
3108
|
+
return orderTargetMatches(
|
|
3109
|
+
{
|
|
3110
|
+
kind: node.kind,
|
|
3111
|
+
ref: node.ref,
|
|
3112
|
+
...node.repoPath ? { repoPath: node.repoPath } : {}
|
|
3113
|
+
},
|
|
3114
|
+
you
|
|
3115
|
+
);
|
|
3116
|
+
}
|
|
3117
|
+
function formatWaterfallHtml(chains, opts) {
|
|
3118
|
+
const plan = opts?.plan ?? null;
|
|
3119
|
+
const you = opts?.you ?? null;
|
|
3120
|
+
const title = plan?.title?.trim() || "Planner";
|
|
3121
|
+
const status = plan ? plan.status === "active" ? "Running. Ready steps can start. Waiting steps stay held." : "Draft. Discuss this and change it. Nothing runs until you agree." : "Later steps wait until the one above reaches its gate. In main clears when that pull request is merged. In production stays waiting until it is marked.";
|
|
3122
|
+
const body = chains.length === 0 ? '<p class="empty">No order yet.</p>' : chains.map((chain) => {
|
|
3123
|
+
const nodes = chain.nodes.map((node) => {
|
|
3124
|
+
const waiting = node.incoming.some((edge) => !edge.met && !edge.loop);
|
|
3125
|
+
const clear = node.incoming.some((edge) => !edge.loop) && !waiting;
|
|
3126
|
+
const yours = nodeIsYou(node, you);
|
|
3127
|
+
const working = node.working === true;
|
|
3128
|
+
const state = `${waiting ? " waiting" : clear ? " clear" : ""}${yours ? " you" : ""}${working ? " current" : ""}`;
|
|
3129
|
+
const drops = node.incoming.map((edge) => {
|
|
3130
|
+
const tone = edge.loop ? "loop" : edge.met ? "clear" : "waiting";
|
|
3131
|
+
const note = edge.note ? `<span>${escapeHtml(edge.note)}</span>` : "";
|
|
3132
|
+
return `<div class="drop"><span>After ${escapeHtml(edge.fromLabel)} is ${escapeHtml(gatePhrase(edge.gate))}, this ${escapeHtml(holdPhrase(edge.hold))}</span><span class="${tone}">${escapeHtml(edge.detail)}</span>${note}</div>`;
|
|
3133
|
+
}).join("");
|
|
3134
|
+
const kicker = `${WATERFALL_KIND[node.kind]}${working ? " \xB7 Working" : ""}${yours ? " \xB7 You" : ""}`;
|
|
3135
|
+
return `<li class="node" style="margin-left:${node.depth * 28}px">${drops}<div class="bar${state}"><span class="kicker">${kicker}</span><strong>${escapeHtml(node.label)}</strong></div></li>`;
|
|
3136
|
+
}).join("");
|
|
3137
|
+
return `<ol class="chain">${nodes}</ol>`;
|
|
3138
|
+
}).join("");
|
|
3139
|
+
const summary = plan?.summary?.trim() ? `<p class="lead">${escapeHtml(plan.summary.trim())}</p>` : "";
|
|
3140
|
+
return `<!DOCTYPE html>
|
|
3141
|
+
<html lang="en">
|
|
3142
|
+
<head>
|
|
3143
|
+
<meta charset="utf-8">
|
|
3144
|
+
<title>${escapeHtml(title)}</title>
|
|
3145
|
+
<style>
|
|
3146
|
+
:root { color-scheme: dark; }
|
|
3147
|
+
body { margin: 0; padding: 20px 22px 32px; background: #141414; color: #ececec; font: 13px/1.4 ui-sans-serif, system-ui, sans-serif; }
|
|
3148
|
+
h1 { font-size: 15px; font-weight: 600; margin: 0 0 6px; }
|
|
3149
|
+
.lead, .empty, .status { color: #9a9a9a; margin: 0 0 18px; max-width: 62ch; }
|
|
3150
|
+
.chain { list-style: none; margin: 0 0 28px; padding: 0; }
|
|
3151
|
+
.drop { margin: 0 0 0 16px; padding: 8px 0 8px 12px; border-left: 1px solid #333; color: #9a9a9a; font-size: 12px; display: flex; flex-direction: column; gap: 3px; }
|
|
3152
|
+
.drop .waiting { color: #e2b340; }
|
|
3153
|
+
.drop .clear, .drop .loop { color: #6fbf73; }
|
|
3154
|
+
.bar { border: 1px solid #333; border-radius: 10px; padding: 10px 12px; background: #1c1c1c; display: flex; flex-direction: column; gap: 2px; }
|
|
3155
|
+
.bar.waiting { border-color: #6a5420; background: #221c10; }
|
|
3156
|
+
.bar.clear { border-color: #2d5a32; background: #142016; }
|
|
3157
|
+
.bar.you { outline: 1px solid #8ab4ff; }
|
|
3158
|
+
.bar.current { border-color: #8ab4ff; box-shadow: inset 3px 0 0 #8ab4ff; }
|
|
3159
|
+
.bar.current .kicker { color: #ececec; }
|
|
3160
|
+
.kicker { font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; color: #9a9a9a; }
|
|
3161
|
+
</style>
|
|
3162
|
+
</head>
|
|
3163
|
+
<body>
|
|
3164
|
+
<h1>${escapeHtml(title)}</h1>
|
|
3165
|
+
<p class="status">${escapeHtml(status)}</p>
|
|
3166
|
+
${summary}
|
|
3167
|
+
${body}
|
|
3168
|
+
</body>
|
|
3169
|
+
</html>`;
|
|
3170
|
+
}
|
|
3171
|
+
function checkoutPlanTitle(markdown) {
|
|
3172
|
+
const match = /^#{1,6}[ \t]+(.+?)[ \t]*$/m.exec(markdown);
|
|
3173
|
+
const title = match?.[1]?.replace(/\s+#+\s*$/, "").trim() ?? "";
|
|
3174
|
+
return title.slice(0, 80) || "Implementation plan";
|
|
3175
|
+
}
|
|
3176
|
+
function showPlanDocuments(input) {
|
|
3177
|
+
const docs = [];
|
|
3178
|
+
const markdown = input.checkoutMarkdown ?? "";
|
|
3179
|
+
if (markdown.trim()) {
|
|
3180
|
+
docs.push({
|
|
3181
|
+
title: checkoutPlanTitle(markdown),
|
|
3182
|
+
type: "markdown",
|
|
3183
|
+
artifact_id: "checkout-plan",
|
|
3184
|
+
content: markdown
|
|
3185
|
+
});
|
|
3186
|
+
}
|
|
3187
|
+
const html = input.diagramHtml ?? "";
|
|
3188
|
+
if (html.trim()) {
|
|
3189
|
+
docs.push({
|
|
3190
|
+
title: input.diagramTitle?.trim() || "Planner",
|
|
3191
|
+
type: "html",
|
|
3192
|
+
artifact_id: "plan",
|
|
3193
|
+
content: html
|
|
3194
|
+
});
|
|
3195
|
+
}
|
|
3196
|
+
return docs;
|
|
3197
|
+
}
|
|
3198
|
+
function showPlanMessage(docs, worktree) {
|
|
3199
|
+
const diagram = docs.some((doc) => doc.artifact_id === "plan");
|
|
3200
|
+
const checkout = docs.some((doc) => doc.artifact_id === "checkout-plan");
|
|
3201
|
+
if (diagram && checkout) {
|
|
3202
|
+
return "Opened the orchestration plan and this checkout's implementation plan.";
|
|
3203
|
+
}
|
|
3204
|
+
if (checkout) return "Opened this checkout's implementation plan.";
|
|
3205
|
+
return worktree ? "Opened the orchestration plan in the side column, with this checkout marked." : "Opened the plan in the side column.";
|
|
3206
|
+
}
|
|
3207
|
+
|
|
3208
|
+
// src/order/order.ts
|
|
3209
|
+
function orderPath() {
|
|
3210
|
+
return join2(appDataDir(), "order.json");
|
|
3211
|
+
}
|
|
3212
|
+
function emptyFile() {
|
|
3213
|
+
return { plans: [], edges: [], marks: [] };
|
|
3214
|
+
}
|
|
3215
|
+
function asPlan(value, fallbackId) {
|
|
3216
|
+
if (!value || typeof value !== "object") return null;
|
|
3217
|
+
const row = value;
|
|
3218
|
+
const title = typeof row.title === "string" ? row.title.trim().slice(0, 120) : "";
|
|
3219
|
+
if (!title) return null;
|
|
3220
|
+
const summary = typeof row.summary === "string" ? row.summary.trim().slice(0, 600) : "";
|
|
3221
|
+
const goal = typeof row.goal === "string" ? row.goal.trim().slice(0, 400) : "";
|
|
3222
|
+
const status = row.status === "active" ? "active" : "draft";
|
|
3223
|
+
const updatedAt = typeof row.updatedAt === "string" && row.updatedAt ? row.updatedAt : (/* @__PURE__ */ new Date()).toISOString();
|
|
3224
|
+
const id = typeof row.id === "string" && row.id.trim() ? row.id.trim() : fallbackId;
|
|
3225
|
+
const ownerThreadId = typeof row.ownerThreadId === "string" ? row.ownerThreadId.trim() : "";
|
|
3226
|
+
return { id, ownerThreadId, title, summary, goal, status, updatedAt };
|
|
3227
|
+
}
|
|
3228
|
+
function asTarget(value) {
|
|
3229
|
+
if (!value || typeof value !== "object") return null;
|
|
3230
|
+
const row = value;
|
|
3231
|
+
if (row.kind !== "pr" && row.kind !== "issue" && row.kind !== "workspace" && row.kind !== "orchestration") {
|
|
3232
|
+
return null;
|
|
3233
|
+
}
|
|
3234
|
+
if (typeof row.ref !== "string" || !row.ref.trim()) return null;
|
|
3235
|
+
try {
|
|
3236
|
+
return normalizeOrderTarget(row);
|
|
3237
|
+
} catch {
|
|
3238
|
+
return null;
|
|
3239
|
+
}
|
|
3240
|
+
}
|
|
3241
|
+
function asEdge(value) {
|
|
3242
|
+
if (!value || typeof value !== "object") return null;
|
|
3243
|
+
const row = value;
|
|
3244
|
+
if (typeof row.id !== "string" || !row.id.trim()) return null;
|
|
3245
|
+
const waitsOn = asTarget(row.waitsOn);
|
|
3246
|
+
const subject = asTarget(row.subject);
|
|
3247
|
+
if (!waitsOn || !subject) return null;
|
|
3248
|
+
if (row.gate !== "in-main" && row.gate !== "in-prod") return null;
|
|
3249
|
+
if (row.hold !== "start" && row.hold !== "merge") return null;
|
|
3250
|
+
return {
|
|
3251
|
+
id: row.id,
|
|
3252
|
+
waitsOn,
|
|
3253
|
+
gate: row.gate,
|
|
3254
|
+
subject,
|
|
3255
|
+
hold: row.hold,
|
|
3256
|
+
...row.loop === true ? { loop: true } : {},
|
|
3257
|
+
note: typeof row.note === "string" ? row.note.slice(0, 400) : "",
|
|
3258
|
+
createdByThreadId: row.createdByThreadId?.trim() || null,
|
|
3259
|
+
createdAt: typeof row.createdAt === "string" ? row.createdAt : (/* @__PURE__ */ new Date()).toISOString(),
|
|
3260
|
+
...typeof row.planId === "string" && row.planId.trim() ? { planId: row.planId.trim() } : {}
|
|
3261
|
+
};
|
|
3262
|
+
}
|
|
3263
|
+
function asMark(value) {
|
|
3264
|
+
if (!value || typeof value !== "object") return null;
|
|
3265
|
+
const row = value;
|
|
3266
|
+
if (typeof row.key !== "string" || !row.key.trim()) return null;
|
|
3267
|
+
if (row.gate !== "in-main" && row.gate !== "in-prod") return null;
|
|
3268
|
+
if (typeof row.at !== "string" || !row.at) return null;
|
|
3269
|
+
return { key: row.key, gate: row.gate, at: row.at };
|
|
3270
|
+
}
|
|
3271
|
+
function readFile() {
|
|
3272
|
+
const path = orderPath();
|
|
3273
|
+
if (!existsSync(path)) return emptyFile();
|
|
3274
|
+
try {
|
|
3275
|
+
const parsed = JSON.parse(readFileSync(path, "utf8"));
|
|
3276
|
+
if (!parsed || typeof parsed !== "object") return emptyFile();
|
|
3277
|
+
const raw = parsed;
|
|
3278
|
+
const edges = Array.isArray(raw.edges) ? raw.edges.map(asEdge).filter((row) => Boolean(row)) : [];
|
|
3279
|
+
const listed = Array.isArray(raw.plans) ? raw.plans.map((row, index) => asPlan(row, `plan-${index + 1}`)).filter((row) => Boolean(row)) : [];
|
|
3280
|
+
const legacy = listed.length ? null : asPlan(raw.plan, "legacy");
|
|
3281
|
+
let plans = legacy ? [legacy] : listed;
|
|
3282
|
+
if (!plans.length && edges.length) {
|
|
3283
|
+
plans = [
|
|
3284
|
+
{
|
|
3285
|
+
id: "legacy",
|
|
3286
|
+
ownerThreadId: "",
|
|
3287
|
+
title: "Planner",
|
|
3288
|
+
summary: "",
|
|
3289
|
+
goal: "",
|
|
3290
|
+
status: "draft",
|
|
3291
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3292
|
+
}
|
|
3293
|
+
];
|
|
3294
|
+
}
|
|
3295
|
+
const fallbackId = plans[0]?.id ?? "";
|
|
3296
|
+
return {
|
|
3297
|
+
plans,
|
|
3298
|
+
edges: edges.map((edge) => ({ ...edge, planId: edge.planId || fallbackId })),
|
|
3299
|
+
marks: Array.isArray(raw.marks) ? raw.marks.map(asMark).filter((row) => Boolean(row)) : []
|
|
3300
|
+
};
|
|
3301
|
+
} catch {
|
|
3302
|
+
return emptyFile();
|
|
3303
|
+
}
|
|
3304
|
+
}
|
|
3305
|
+
function pruneMarks(edges, marks) {
|
|
3306
|
+
const live = new Set(edges.map((edge) => `${targetKey(edge.waitsOn)}|${edge.gate}`));
|
|
3307
|
+
return marks.filter((mark) => live.has(`${mark.key}|${mark.gate}`));
|
|
3308
|
+
}
|
|
3309
|
+
function writeFile(file) {
|
|
3310
|
+
const next = {
|
|
3311
|
+
plans: file.plans,
|
|
3312
|
+
edges: file.edges,
|
|
3313
|
+
marks: pruneMarks(file.edges, file.marks)
|
|
3314
|
+
};
|
|
3315
|
+
writePrivateFile(orderPath(), `${JSON.stringify(next, null, 2)}
|
|
3316
|
+
`);
|
|
3317
|
+
}
|
|
3318
|
+
function planByOwner(file, ownerThreadId) {
|
|
3319
|
+
const owner = ownerThreadId?.trim() ?? "";
|
|
3320
|
+
if (owner) return file.plans.find((plan) => plan.ownerThreadId === owner) ?? null;
|
|
3321
|
+
return file.plans.length === 1 ? file.plans[0] : null;
|
|
3322
|
+
}
|
|
3323
|
+
function getOrderPlan(ownerThreadId) {
|
|
3324
|
+
return planByOwner(readFile(), ownerThreadId);
|
|
3325
|
+
}
|
|
3326
|
+
function setOrderPlan(input) {
|
|
3327
|
+
const title = input.title.trim().slice(0, 120);
|
|
3328
|
+
if (!title) throw new Error("Plan title is required");
|
|
3329
|
+
const file = readFile();
|
|
3330
|
+
const owner = input.ownerThreadId?.trim() ?? "";
|
|
3331
|
+
const existing = file.plans.find((plan2) => plan2.ownerThreadId === owner);
|
|
3332
|
+
const plan = {
|
|
3333
|
+
id: existing?.id ?? randomUUID(),
|
|
3334
|
+
ownerThreadId: owner,
|
|
3335
|
+
title,
|
|
3336
|
+
summary: input.summary?.trim().slice(0, 600) ?? existing?.summary ?? "",
|
|
3337
|
+
goal: input.goal === void 0 ? existing?.goal ?? "" : input.goal?.trim().slice(0, 400) ?? "",
|
|
3338
|
+
status: existing?.status === "active" ? "active" : "draft",
|
|
3339
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3340
|
+
};
|
|
3341
|
+
if (existing) {
|
|
3342
|
+
const index = file.plans.findIndex((row) => row.id === existing.id);
|
|
3343
|
+
file.plans[index] = plan;
|
|
3344
|
+
} else {
|
|
3345
|
+
file.plans.push(plan);
|
|
3346
|
+
}
|
|
3347
|
+
writeFile(file);
|
|
3348
|
+
return plan;
|
|
3349
|
+
}
|
|
3350
|
+
function executeOrderPlan(ownerThreadId) {
|
|
3351
|
+
const file = readFile();
|
|
3352
|
+
const current = planByOwner(file, ownerThreadId);
|
|
3353
|
+
if (!current) throw new Error("set_plan first. This chat has no plan yet.");
|
|
3354
|
+
const edges = file.edges.filter((edge) => edge.planId === current.id);
|
|
3355
|
+
if (edges.length === 0) {
|
|
3356
|
+
throw new Error("The planner is empty. set_plan and set_dependency first.");
|
|
3357
|
+
}
|
|
3358
|
+
const plan = { ...current, status: "active", updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
3359
|
+
const index = file.plans.findIndex((row) => row.id === current.id);
|
|
3360
|
+
file.plans[index] = plan;
|
|
3361
|
+
writeFile(file);
|
|
3362
|
+
const ids = new Set(edges.map((edge) => edge.id));
|
|
3363
|
+
const rows = resolveOrchestrationGates(file.plans, file.edges, threadSnapshots(), file.marks);
|
|
3364
|
+
const slice = executionSlice(rows.filter((row) => ids.has(row.id)));
|
|
3365
|
+
return { plan, ready: slice.ready, waiting: slice.waiting };
|
|
3366
|
+
}
|
|
3367
|
+
function threadSnapshots() {
|
|
3368
|
+
try {
|
|
3369
|
+
return listThreads({ includeArchived: true }).map(orderSnapshotFromThread);
|
|
3370
|
+
} catch {
|
|
3371
|
+
return [];
|
|
3372
|
+
}
|
|
3373
|
+
}
|
|
3374
|
+
function listOrderRows(planId) {
|
|
3375
|
+
const file = readFile();
|
|
3376
|
+
const rows = resolveOrchestrationGates(file.plans, file.edges, threadSnapshots(), file.marks);
|
|
3377
|
+
if (!planId) return rows;
|
|
3378
|
+
const ids = new Set(file.edges.filter((edge) => edge.planId === planId).map((edge) => edge.id));
|
|
3379
|
+
return rows.filter((row) => ids.has(row.id));
|
|
3380
|
+
}
|
|
3381
|
+
function listWaterfall(planId) {
|
|
3382
|
+
return markWorkingChains(buildWaterfall(listOrderRows(planId)), threadSnapshots());
|
|
3383
|
+
}
|
|
3384
|
+
function selectPlan(file, input) {
|
|
3385
|
+
const planId = input.planId?.trim();
|
|
3386
|
+
if (planId) {
|
|
3387
|
+
const hit = file.plans.find((plan) => plan.id === planId);
|
|
3388
|
+
if (!hit) throw new Error("No plan with that id.");
|
|
3389
|
+
return hit;
|
|
3390
|
+
}
|
|
3391
|
+
const owner = input.ownerThreadId?.trim();
|
|
3392
|
+
if (owner) {
|
|
3393
|
+
const hit = file.plans.find((plan) => plan.ownerThreadId === owner);
|
|
3394
|
+
if (!hit) throw new Error("set_plan first. This chat has no plan yet.");
|
|
3395
|
+
return hit;
|
|
3396
|
+
}
|
|
3397
|
+
if (file.plans.length === 1) return file.plans[0];
|
|
3398
|
+
if (file.plans.length === 0) {
|
|
3399
|
+
const plan = {
|
|
3400
|
+
id: randomUUID(),
|
|
3401
|
+
ownerThreadId: "",
|
|
3402
|
+
title: "Planner",
|
|
3403
|
+
summary: "",
|
|
3404
|
+
goal: "",
|
|
3405
|
+
status: "draft",
|
|
3406
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3407
|
+
};
|
|
3408
|
+
file.plans.push(plan);
|
|
3409
|
+
return plan;
|
|
3410
|
+
}
|
|
3411
|
+
throw new Error("More than one plan is open. Pass the orchestration chat.");
|
|
3412
|
+
}
|
|
3413
|
+
function findEdge(id, edges) {
|
|
3414
|
+
const key = id.trim();
|
|
3415
|
+
if (!key) return null;
|
|
3416
|
+
return edges.find((edge) => edge.id === key || key.length >= 8 && edge.id.startsWith(key)) ?? null;
|
|
3417
|
+
}
|
|
3418
|
+
function setOrderDependency(input) {
|
|
3419
|
+
const waitsOn = normalizeOrderTarget(input.waitsOn);
|
|
3420
|
+
const subject = normalizeOrderTarget(input.subject);
|
|
3421
|
+
const gate = parseOrderGate(input.gate);
|
|
3422
|
+
const hold = parseOrderHold(input.hold);
|
|
3423
|
+
const file = readFile();
|
|
3424
|
+
const plan = selectPlan(file, input);
|
|
3425
|
+
const scoped = file.edges.filter((edge2) => edge2.planId === plan.id);
|
|
3426
|
+
const draft = { waitsOn, subject, gate, hold };
|
|
3427
|
+
const existing = scoped.find((edge2) => dependencyIdentity(edge2) === dependencyIdentity(draft));
|
|
3428
|
+
if (existing) return { edge: existing, created: false };
|
|
3429
|
+
if (targetKey(subject) === targetKey(waitsOn)) {
|
|
3430
|
+
throw new Error(cycleDependencyMessage(draft));
|
|
3431
|
+
}
|
|
3432
|
+
const loop = dependencyWouldCycle(scoped, draft);
|
|
3433
|
+
const edge = {
|
|
3434
|
+
id: randomUUID(),
|
|
3435
|
+
planId: plan.id,
|
|
3436
|
+
waitsOn,
|
|
3437
|
+
gate,
|
|
3438
|
+
subject,
|
|
3439
|
+
hold,
|
|
3440
|
+
...loop ? { loop: true } : {},
|
|
3441
|
+
note: input.note?.trim().slice(0, 400) ?? "",
|
|
3442
|
+
createdByThreadId: input.createdByThreadId?.trim() || null,
|
|
3443
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
3444
|
+
};
|
|
3445
|
+
file.edges.push(edge);
|
|
3446
|
+
writeFile(file);
|
|
3447
|
+
return { edge, created: true };
|
|
3448
|
+
}
|
|
3449
|
+
function clearOrderDependency(id, caller, ownerThreadId) {
|
|
3450
|
+
const file = readFile();
|
|
3451
|
+
const edge = findEdge(id, file.edges);
|
|
3452
|
+
if (!edge) throw new Error(`No planner step ${id}`);
|
|
3453
|
+
if (caller && !orderEdgeTouches(edge, caller)) {
|
|
3454
|
+
throw new Error("This checkout can only change a step it is part of.");
|
|
3455
|
+
}
|
|
3456
|
+
const owner = ownerThreadId?.trim();
|
|
3457
|
+
if (owner) {
|
|
3458
|
+
const plan = file.plans.find((row) => row.ownerThreadId === owner);
|
|
3459
|
+
if (!plan || edge.planId !== plan.id) {
|
|
3460
|
+
throw new Error("This plan belongs to another orchestration chat.");
|
|
3461
|
+
}
|
|
3462
|
+
}
|
|
3463
|
+
file.edges = file.edges.filter((row) => row.id !== edge.id);
|
|
3464
|
+
writeFile(file);
|
|
3465
|
+
}
|
|
3466
|
+
function satisfyOrderDependency(id, satisfied = true) {
|
|
3467
|
+
const file = readFile();
|
|
3468
|
+
const edge = findEdge(id, file.edges);
|
|
3469
|
+
if (!edge) throw new Error(`No planner step ${id}`);
|
|
3470
|
+
const key = targetKey(edge.waitsOn);
|
|
3471
|
+
file.marks = file.marks.filter((mark) => !(mark.key === key && mark.gate === edge.gate));
|
|
3472
|
+
if (satisfied) file.marks.push({ key, gate: edge.gate, at: (/* @__PURE__ */ new Date()).toISOString() });
|
|
3473
|
+
writeFile(file);
|
|
3474
|
+
return edge;
|
|
3475
|
+
}
|
|
3476
|
+
|
|
3477
|
+
// src/mcp/order-tools.ts
|
|
3478
|
+
var kindSchema = z8.enum(["pr", "issue", "workspace", "orchestration"]);
|
|
3479
|
+
function callerThread() {
|
|
3480
|
+
const id = process.env[SIDEBOARD_THREAD_ID_ENV]?.trim();
|
|
3481
|
+
if (!id) return null;
|
|
3482
|
+
return readThread(id);
|
|
3483
|
+
}
|
|
3484
|
+
function readCheckoutPlan(caller) {
|
|
3485
|
+
if (!caller) return null;
|
|
3486
|
+
if (caller.sourceType === "orchestration" || caller.repoPath === GLOBAL_WORKSPACE_ID) return null;
|
|
3487
|
+
const root = caller.worktreePath?.trim();
|
|
3488
|
+
if (!root) return null;
|
|
3489
|
+
return readPlanFile(root);
|
|
3490
|
+
}
|
|
3491
|
+
function orchestrationOwnerId(worktree) {
|
|
3492
|
+
const caller = callerThread();
|
|
3493
|
+
if (!caller) {
|
|
3494
|
+
throw new Error(
|
|
3495
|
+
worktree ? "No worktree chat is bound to this tool." : "No orchestration chat is bound to this tool."
|
|
3496
|
+
);
|
|
3497
|
+
}
|
|
3498
|
+
if (!worktree) return caller.id;
|
|
3499
|
+
let current = caller.parentThreadId?.trim() || "";
|
|
3500
|
+
const seen = /* @__PURE__ */ new Set([caller.id]);
|
|
3501
|
+
for (let hop = 0; hop < 6 && current && !seen.has(current); hop++) {
|
|
3502
|
+
seen.add(current);
|
|
3503
|
+
const row = readThread(current);
|
|
3504
|
+
if (!row) break;
|
|
3505
|
+
if (row.sourceType === "orchestration" || row.repoPath === GLOBAL_WORKSPACE_ID) return row.id;
|
|
3506
|
+
current = row.parentThreadId?.trim() || "";
|
|
3507
|
+
}
|
|
3508
|
+
throw new Error("This checkout is not connected to an orchestration chat.");
|
|
3509
|
+
}
|
|
3510
|
+
function targetFrom(kind, ref, repoPath, label) {
|
|
3511
|
+
return {
|
|
3512
|
+
kind: parseOrderKind(kind),
|
|
3513
|
+
ref: ref.trim(),
|
|
3514
|
+
...repoPath?.trim() ? { repoPath: repoPath.trim() } : {},
|
|
3515
|
+
...label?.trim() ? { label: label.trim() } : {}
|
|
3516
|
+
};
|
|
3517
|
+
}
|
|
3518
|
+
function registerOrderTools(server) {
|
|
3519
|
+
const worktree = sideboardMcpProfile() === "worktree";
|
|
3520
|
+
server.tool(
|
|
3521
|
+
"list_order",
|
|
3522
|
+
worktree ? "Read where this checkout sits in its orchestrator's plan: what you are waiting on, what is clear, and what you are blocking. Call show_plan when the user should see it. Change your step with set_dependency or clear_dependency." : "Read this chat's plan. Call show_plan when the user should see it. Draft with set_plan and set_dependency, revise from their feedback, then execute_plan only after they agree. Do not start planned work while the plan is draft.",
|
|
3523
|
+
{},
|
|
3524
|
+
async () => {
|
|
3525
|
+
try {
|
|
3526
|
+
const owner = orchestrationOwnerId(worktree);
|
|
3527
|
+
const plan = getOrderPlan(owner);
|
|
3528
|
+
const caller = callerThread();
|
|
3529
|
+
if (!plan) {
|
|
3530
|
+
const text5 = worktree ? "This checkout's orchestrator has no plan yet." : "This chat has no plan. set_plan drafts one. Then show_plan so the user sees it.";
|
|
3531
|
+
return { content: [{ type: "text", text: text5 }] };
|
|
3532
|
+
}
|
|
3533
|
+
const rows = listOrderRows(plan.id);
|
|
3534
|
+
const place = worktree && caller ? `${formatOrderPlace(rows, orderSnapshotFromThread(caller))}
|
|
3535
|
+
|
|
3536
|
+
` : "";
|
|
3537
|
+
return {
|
|
3538
|
+
content: [{ type: "text", text: `${place}${formatOrderText(rows, plan)}` }]
|
|
3539
|
+
};
|
|
3540
|
+
} catch (err) {
|
|
3541
|
+
return mcpJson({ error: err instanceof Error ? err.message : String(err) }, true);
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3544
|
+
);
|
|
3545
|
+
server.tool(
|
|
3546
|
+
"set_dependency",
|
|
3547
|
+
worktree ? "Change what this checkout waits on. Omit subject to mean this workspace (hold=merge uses this PR; hold=start on a ticket uses this issue). gate=in-main (met when that PR is merged) or in-prod (stays waiting until satisfy_dependency). hold=start means do not begin; hold=merge means do not merge. You cannot set a dependency for a different checkout. show_plan so the user sees the change." : "Record a step on this orchestration plan. waitsOn must reach gate before subject can hold. gate=in-main is met when that PR is merged; gate=in-prod stays waiting until satisfy_dependency. hold=start blocks starting the subject; hold=merge blocks merging it. Example: PR 1 in prod before PR 2 can merge; PR 3 in main before issue 4 can start. Pass repoPath when the same PR number exists in more than one project. Worktree agents set their own checkout and can omit subject. Then show_plan so the user sees it.",
|
|
3548
|
+
{
|
|
3549
|
+
waitsOnKind: kindSchema.describe("What must happen first: pr, issue, workspace, or orchestration"),
|
|
3550
|
+
waitsOnRef: z8.string().describe("PR number (12), issue id (ENG-4), or workspace chat id / worktree path"),
|
|
3551
|
+
waitsOnRepoPath: z8.string().optional().describe("Project path when a PR or issue number is not unique"),
|
|
3552
|
+
waitsOnLabel: z8.string().optional().describe("Short label on the planner"),
|
|
3553
|
+
gate: z8.enum(["in-main", "in-prod"]).describe("in-main: merged to the default branch. in-prod: deployed; mark with satisfy_dependency"),
|
|
3554
|
+
hold: z8.enum(["start", "merge"]).describe("start: subject cannot begin. merge: subject cannot merge"),
|
|
3555
|
+
subjectKind: kindSchema.optional().describe("What is held. Required from orchestration. Omit on a worktree to mean this checkout."),
|
|
3556
|
+
subjectRef: z8.string().optional().describe("PR number, issue id, or workspace ref for the subject"),
|
|
3557
|
+
subjectRepoPath: z8.string().optional(),
|
|
3558
|
+
subjectLabel: z8.string().optional(),
|
|
3559
|
+
note: z8.string().optional().describe("Why this order matters")
|
|
3560
|
+
},
|
|
3561
|
+
async (args) => {
|
|
3562
|
+
try {
|
|
3563
|
+
const hasKind = Boolean(args.subjectKind);
|
|
3564
|
+
const hasRef = Boolean(args.subjectRef?.trim());
|
|
3565
|
+
if (hasKind !== hasRef) {
|
|
3566
|
+
throw new Error("Pass subjectKind and subjectRef together, or omit both on a worktree.");
|
|
3567
|
+
}
|
|
3568
|
+
const caller = callerThread();
|
|
3569
|
+
let subject;
|
|
3570
|
+
const hold = parseOrderHold(args.hold);
|
|
3571
|
+
if (!hasKind) {
|
|
3572
|
+
if (!worktree) {
|
|
3573
|
+
throw new Error(
|
|
3574
|
+
"Pass subjectKind and subjectRef. A worktree agent can omit them to mean this checkout."
|
|
3575
|
+
);
|
|
3576
|
+
}
|
|
3577
|
+
if (!caller) throw new Error("No worktree chat is bound to this tool.");
|
|
3578
|
+
subject = defaultOrderSubject(orderSnapshotFromThread(caller), hold);
|
|
3579
|
+
} else {
|
|
3580
|
+
subject = targetFrom(
|
|
3581
|
+
args.subjectKind,
|
|
3582
|
+
args.subjectRef,
|
|
3583
|
+
args.subjectRepoPath,
|
|
3584
|
+
args.subjectLabel
|
|
3585
|
+
);
|
|
3586
|
+
if (worktree) {
|
|
3587
|
+
if (!caller) throw new Error("No worktree chat is bound to this tool.");
|
|
3588
|
+
assertCallerOwnsSubject(orderSnapshotFromThread(caller), subject);
|
|
3589
|
+
}
|
|
3590
|
+
}
|
|
3591
|
+
const result = setOrderDependency({
|
|
3592
|
+
waitsOn: targetFrom(
|
|
3593
|
+
args.waitsOnKind,
|
|
3594
|
+
args.waitsOnRef,
|
|
3595
|
+
args.waitsOnRepoPath,
|
|
3596
|
+
args.waitsOnLabel
|
|
3597
|
+
),
|
|
3598
|
+
gate: parseOrderGate(args.gate),
|
|
3599
|
+
subject,
|
|
3600
|
+
hold,
|
|
3601
|
+
note: args.note,
|
|
3602
|
+
createdByThreadId: caller?.id ?? null,
|
|
3603
|
+
ownerThreadId: orchestrationOwnerId(worktree)
|
|
3604
|
+
});
|
|
3605
|
+
return mcpJson({
|
|
3606
|
+
created: result.created,
|
|
3607
|
+
id: result.edge.id,
|
|
3608
|
+
gate: result.edge.gate,
|
|
3609
|
+
hold: result.edge.hold,
|
|
3610
|
+
waitsOn: result.edge.waitsOn,
|
|
3611
|
+
subject: result.edge.subject
|
|
3612
|
+
});
|
|
3613
|
+
} catch (err) {
|
|
3614
|
+
return mcpJson({ error: err instanceof Error ? err.message : String(err) }, true);
|
|
3615
|
+
}
|
|
3616
|
+
}
|
|
3617
|
+
);
|
|
3618
|
+
if (!worktree) {
|
|
3619
|
+
server.tool(
|
|
3620
|
+
"set_plan",
|
|
3621
|
+
"Draft or retitle this chat's plan. It stays draft until execute_plan. Pass goal for the outcome the steps are trying to reach. Then set_dependency for each gate. A step may loop back to an earlier one. Call show_plan so the user sees it. Do not paste the diagram in chat. Do not start workspaces while it is draft.",
|
|
3622
|
+
{
|
|
3623
|
+
title: z8.string().describe("Short name for the plan"),
|
|
3624
|
+
summary: z8.string().optional().describe("What this order is for, in a sentence or two"),
|
|
3625
|
+
goal: z8.string().optional().describe("Outcome the steps are trying to reach")
|
|
3626
|
+
},
|
|
3627
|
+
async ({ title, summary, goal }) => {
|
|
3628
|
+
try {
|
|
3629
|
+
const plan = setOrderPlan({
|
|
3630
|
+
title,
|
|
3631
|
+
summary,
|
|
3632
|
+
goal,
|
|
3633
|
+
ownerThreadId: orchestrationOwnerId(false)
|
|
3634
|
+
});
|
|
3635
|
+
return mcpJson({ ok: true, ...plan });
|
|
3636
|
+
} catch (err) {
|
|
3637
|
+
return mcpJson({ error: err instanceof Error ? err.message : String(err) }, true);
|
|
3638
|
+
}
|
|
3639
|
+
}
|
|
3640
|
+
);
|
|
3641
|
+
server.tool(
|
|
3642
|
+
"execute_plan",
|
|
3643
|
+
"Mark the plan active after the user has seen it and told you to run it. Returns ready steps (start those with create_workspace or send_to_chat) and waiting steps (leave them alone). Does not create workspaces. Pass agreed: true only after they agree. Merge only if they asked.",
|
|
3644
|
+
{
|
|
3645
|
+
agreed: z8.literal(true).describe("True only after the user has seen the plan and told you to run it")
|
|
3646
|
+
},
|
|
3647
|
+
async () => {
|
|
3648
|
+
try {
|
|
3649
|
+
const result = executeOrderPlan(orchestrationOwnerId(false));
|
|
3650
|
+
const brief = (row) => ({
|
|
3651
|
+
id: row.id,
|
|
3652
|
+
hold: row.hold,
|
|
3653
|
+
gate: row.gate,
|
|
3654
|
+
waitsOn: row.waitsOnLabel,
|
|
3655
|
+
subject: row.subjectLabel,
|
|
3656
|
+
detail: row.detail,
|
|
3657
|
+
...row.loop ? { loop: true } : {}
|
|
3658
|
+
});
|
|
3659
|
+
return mcpJson({
|
|
3660
|
+
ok: true,
|
|
3661
|
+
status: result.plan.status,
|
|
3662
|
+
title: result.plan.title,
|
|
3663
|
+
ready: result.ready.map(brief),
|
|
3664
|
+
waiting: result.waiting.map(brief),
|
|
3665
|
+
message: "Plan is active. Start ready steps with create_workspace or send_to_chat. Leave waiting steps alone. Merge only if the user asked."
|
|
3666
|
+
});
|
|
3667
|
+
} catch (err) {
|
|
3668
|
+
return mcpJson({ error: err instanceof Error ? err.message : String(err) }, true);
|
|
3669
|
+
}
|
|
3670
|
+
}
|
|
3671
|
+
);
|
|
3672
|
+
}
|
|
3673
|
+
server.tool(
|
|
3674
|
+
"show_plan",
|
|
3675
|
+
worktree ? "Open the plans for this checkout in the side column. That is the orchestration diagram, with this checkout marked, and this checkout's implementation plan (plan.md) when the file exists. Does not write either plan. Change a step with set_dependency or clear_dependency, then show it again. Do not paste the diagram in chat." : "Open this chat's plan in the side column. Call it after set_plan or set_dependency so the user sees the plan. A worktree show_plan also opens that checkout's implementation plan (plan.md) when the file exists. Does not write either plan. Do not paste the diagram in chat.",
|
|
3676
|
+
{},
|
|
3677
|
+
async () => {
|
|
3678
|
+
const caller = callerThread();
|
|
3679
|
+
let diagramHtml = null;
|
|
3680
|
+
let diagramTitle = "Planner";
|
|
3681
|
+
let diagramError = null;
|
|
3682
|
+
try {
|
|
3683
|
+
const owner = orchestrationOwnerId(worktree);
|
|
3684
|
+
const plan = getOrderPlan(owner);
|
|
3685
|
+
diagramTitle = plan?.title || "Planner";
|
|
3686
|
+
diagramHtml = formatWaterfallHtml(plan ? listWaterfall(plan.id) : [], {
|
|
3687
|
+
plan,
|
|
3688
|
+
you: caller ? orderSnapshotFromThread(caller) : null
|
|
3689
|
+
});
|
|
3690
|
+
} catch (err) {
|
|
3691
|
+
diagramError = err instanceof Error ? err.message : String(err);
|
|
3692
|
+
}
|
|
3693
|
+
const artifacts = showPlanDocuments({
|
|
3694
|
+
diagramTitle,
|
|
3695
|
+
diagramHtml,
|
|
3696
|
+
checkoutMarkdown: readCheckoutPlan(caller)
|
|
3697
|
+
});
|
|
3698
|
+
if (!artifacts.length) {
|
|
3699
|
+
return mcpJson({ error: diagramError || "Nothing to show." }, true);
|
|
3700
|
+
}
|
|
3701
|
+
const primary = artifacts.find((doc) => doc.artifact_id === "plan") ?? artifacts[0];
|
|
3702
|
+
return mcpJson({
|
|
3703
|
+
ok: true,
|
|
3704
|
+
title: primary.title,
|
|
3705
|
+
type: primary.type,
|
|
3706
|
+
artifact_id: primary.artifact_id,
|
|
3707
|
+
content: primary.content,
|
|
3708
|
+
artifacts,
|
|
3709
|
+
message: showPlanMessage(artifacts, worktree)
|
|
3710
|
+
});
|
|
3711
|
+
}
|
|
3712
|
+
);
|
|
3713
|
+
server.tool(
|
|
3714
|
+
"clear_dependency",
|
|
3715
|
+
worktree ? "Remove a planner step this checkout is part of. Pass id from list_order. Then show_plan so the user sees it." : "Remove one planner step. Pass id from list_order. Then show_plan so the user sees it.",
|
|
3716
|
+
{ id: z8.string().describe("Step id from list_order") },
|
|
3717
|
+
async ({ id }) => {
|
|
3718
|
+
try {
|
|
3719
|
+
const caller = callerThread();
|
|
3720
|
+
clearOrderDependency(
|
|
3721
|
+
id,
|
|
3722
|
+
worktree && caller ? orderSnapshotFromThread(caller) : null,
|
|
3723
|
+
orchestrationOwnerId(worktree)
|
|
3724
|
+
);
|
|
3725
|
+
return mcpJson({ ok: true, id });
|
|
3726
|
+
} catch (err) {
|
|
3727
|
+
return mcpJson({ error: err instanceof Error ? err.message : String(err) }, true);
|
|
3728
|
+
}
|
|
3729
|
+
}
|
|
3730
|
+
);
|
|
3731
|
+
server.tool(
|
|
3732
|
+
"satisfy_dependency",
|
|
3733
|
+
"Mark a planner gate met. Use this when a PR is in production \u2014 Sideboard cannot see deploys. in-main also clears on its own once that PR is merged. Pass satisfied=false to undo a manual mark. One mark covers every step waiting on that same gate.",
|
|
3734
|
+
{
|
|
3735
|
+
id: z8.string().describe("Step id from list_order"),
|
|
3736
|
+
satisfied: z8.boolean().optional().describe("false clears the manual mark. Default true.")
|
|
3737
|
+
},
|
|
3738
|
+
async ({ id, satisfied }) => {
|
|
3739
|
+
try {
|
|
3740
|
+
const owner = orchestrationOwnerId(worktree);
|
|
3741
|
+
const plan = getOrderPlan(owner);
|
|
3742
|
+
if (!plan) throw new Error("set_plan first. This chat has no plan yet.");
|
|
3743
|
+
const rows = listOrderRows(plan.id);
|
|
3744
|
+
const hit = rows.find((row) => row.id === id || id.length >= 8 && row.id.startsWith(id));
|
|
3745
|
+
if (!hit) throw new Error("That step is on another orchestration chat's plan.");
|
|
3746
|
+
const caller = callerThread();
|
|
3747
|
+
if (worktree && caller && !orderEdgeTouches(hit, orderSnapshotFromThread(caller))) {
|
|
3748
|
+
throw new Error("This checkout can only change a step it is part of.");
|
|
3749
|
+
}
|
|
3750
|
+
const edge = satisfyOrderDependency(id, satisfied !== false);
|
|
3751
|
+
return mcpJson({
|
|
3752
|
+
ok: true,
|
|
3753
|
+
id: edge.id,
|
|
3754
|
+
satisfied: satisfied !== false,
|
|
3755
|
+
gate: edge.gate,
|
|
3756
|
+
waitsOn: edge.waitsOn
|
|
3757
|
+
});
|
|
3758
|
+
} catch (err) {
|
|
3759
|
+
return mcpJson({ error: err instanceof Error ? err.message : String(err) }, true);
|
|
3760
|
+
}
|
|
3761
|
+
}
|
|
3762
|
+
);
|
|
3763
|
+
}
|
|
3764
|
+
|
|
3765
|
+
// src/agent-rpc/handlers.ts
|
|
3766
|
+
import { randomUUID as randomUUID2 } from "crypto";
|
|
2626
3767
|
import { isAbsolute } from "path";
|
|
2627
3768
|
|
|
2628
3769
|
// src/remote/phone-permission.ts
|
|
@@ -2658,7 +3799,7 @@ setToolPermissionPublisher({
|
|
|
2658
3799
|
|
|
2659
3800
|
// src/agent-rpc/handlers.ts
|
|
2660
3801
|
function presentArtifactResult(input) {
|
|
2661
|
-
const id = input.artifact_id?.trim() || `artifact_${Date.now().toString(36)}_${
|
|
3802
|
+
const id = input.artifact_id?.trim() || `artifact_${Date.now().toString(36)}_${randomUUID2().slice(0, 8)}`;
|
|
2662
3803
|
return {
|
|
2663
3804
|
ok: true,
|
|
2664
3805
|
artifact_id: id,
|
|
@@ -2672,23 +3813,23 @@ function presentArtifactResult(input) {
|
|
|
2672
3813
|
}
|
|
2673
3814
|
|
|
2674
3815
|
// src/board/load-home-board.ts
|
|
2675
|
-
import { existsSync as
|
|
2676
|
-
import { join as
|
|
3816
|
+
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readFileSync as readFileSync3, unlinkSync as unlinkSync2, writeFileSync as writeFileSync3 } from "fs";
|
|
3817
|
+
import { join as join4 } from "path";
|
|
2677
3818
|
|
|
2678
3819
|
// src/board/board-pins.ts
|
|
2679
|
-
import { randomUUID as
|
|
2680
|
-
import { existsSync, mkdirSync as mkdirSync2, readFileSync, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
|
|
2681
|
-
import { join as
|
|
3820
|
+
import { randomUUID as randomUUID3 } from "crypto";
|
|
3821
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as readFileSync2, unlinkSync, writeFileSync as writeFileSync2 } from "fs";
|
|
3822
|
+
import { join as join3 } from "path";
|
|
2682
3823
|
var FILE = "home-board-pins.json";
|
|
2683
3824
|
var VERSION = 1;
|
|
2684
3825
|
function pinsFile() {
|
|
2685
|
-
return
|
|
3826
|
+
return join3(appDataDir(), FILE);
|
|
2686
3827
|
}
|
|
2687
3828
|
function readDisk() {
|
|
2688
3829
|
const path = pinsFile();
|
|
2689
|
-
if (!
|
|
3830
|
+
if (!existsSync2(path)) return [];
|
|
2690
3831
|
try {
|
|
2691
|
-
const raw = JSON.parse(
|
|
3832
|
+
const raw = JSON.parse(readFileSync2(path, "utf8"));
|
|
2692
3833
|
if (raw?.version !== VERSION || !Array.isArray(raw.items)) return [];
|
|
2693
3834
|
return raw.items.filter((item) => item?.id && item.kind && item.ref);
|
|
2694
3835
|
} catch {
|
|
@@ -2717,7 +3858,7 @@ function homeBoardWorkspaceKey(workspaces) {
|
|
|
2717
3858
|
return workspaces.map((w) => w.path).filter(Boolean).sort().join("\n");
|
|
2718
3859
|
}
|
|
2719
3860
|
function cacheFile() {
|
|
2720
|
-
return
|
|
3861
|
+
return join4(appDataDir(), "home-board-cache.json");
|
|
2721
3862
|
}
|
|
2722
3863
|
function emptyInputs() {
|
|
2723
3864
|
return {
|
|
@@ -2743,9 +3884,9 @@ function shouldCacheHomeBoardInputs(inputs) {
|
|
|
2743
3884
|
}
|
|
2744
3885
|
function readDiskCache() {
|
|
2745
3886
|
const path = cacheFile();
|
|
2746
|
-
if (!
|
|
3887
|
+
if (!existsSync3(path)) return null;
|
|
2747
3888
|
try {
|
|
2748
|
-
const raw = JSON.parse(
|
|
3889
|
+
const raw = JSON.parse(readFileSync3(path, "utf8"));
|
|
2749
3890
|
if (raw?.version !== CACHE_VERSION || typeof raw.fetchedAt !== "number") {
|
|
2750
3891
|
return null;
|
|
2751
3892
|
}
|
|
@@ -3027,18 +4168,18 @@ async function startMcpServer() {
|
|
|
3027
4168
|
);
|
|
3028
4169
|
server.tool(
|
|
3029
4170
|
"list_board",
|
|
3030
|
-
"Home Kanban of workspaces (New, Draft, Review, Approved, Merged) \u2014 one card per checkout; sibling chats on that card are separate agents. Same cards as desktop Home. Path to merge: no PR \u2192 draft PR \u2192 open PR \u2192 approved \u2192 merged. Archive removes the card to Settings \u2192 History (list_archive to browse, restore_workspace to bring it back). Queued/running are activity on the card, not
|
|
4171
|
+
"Home Kanban of workspaces (New, Draft, Review, Approved, Merged) \u2014 one card per checkout; sibling chats on that card are separate agents. Same cards as desktop Home. Path to merge: no PR \u2192 draft PR \u2192 open PR \u2192 approved \u2192 merged. Archive removes the card to Settings \u2192 History (list_archive to browse, restore_workspace to bring it back). Queued/running are activity on the card, not stages. Orchestration chats are not on the board. Filters: query, repoPath, kind (ticket/PR/branch source), ownership (mine = your PRs / WIP; reviewing = someone else's PR), column, limit (default 40). create_workspace adds a workspace (and a Home card), or returns the live checkout if that ticket/PR/named branch is already checked out. That reuse is one checkout, not one agent \u2014 fork_chat to add another.",
|
|
3031
4172
|
{
|
|
3032
|
-
query:
|
|
3033
|
-
repoPath:
|
|
3034
|
-
kind:
|
|
3035
|
-
ownership:
|
|
4173
|
+
query: z9.string().optional().describe("Case-insensitive token search across title, id, labels, workspace tags, repo"),
|
|
4174
|
+
repoPath: z9.string().optional().describe("Limit to one project path from list_projects"),
|
|
4175
|
+
kind: z9.enum(["all", "tickets", "prs", "branches", "threads"]).optional().describe("Filter by worktree source (default all)"),
|
|
4176
|
+
ownership: z9.enum(["all", "mine", "reviewing"]).optional().describe(
|
|
3036
4177
|
"Mine = PRs you authored or local WIP; reviewing = someone else's PR. Uses the gh login."
|
|
3037
4178
|
),
|
|
3038
|
-
column:
|
|
4179
|
+
column: z9.enum(["new", "draft", "review", "approved", "done", "needs_you"]).optional().describe(
|
|
3039
4180
|
"Return cards for this column only (totals still include the rest). approved is an open PR GitHub has approved. needs_you is a legacy alias for new."
|
|
3040
4181
|
),
|
|
3041
|
-
limit:
|
|
4182
|
+
limit: z9.number().int().positive().optional().describe("Max cards per column (default 40). hidden counts the remainder.")
|
|
3042
4183
|
},
|
|
3043
4184
|
async ({ query, repoPath, kind, ownership, column, limit }) => {
|
|
3044
4185
|
const workspaces = orch.listWorkspaces();
|
|
@@ -3068,7 +4209,7 @@ async function startMcpServer() {
|
|
|
3068
4209
|
server.tool(
|
|
3069
4210
|
"get_chat",
|
|
3070
4211
|
"Get a compact chat summary by id/ref. Includes last message preview, parentChatId, and child workspace chats (status + lastText). While running, includes progress (last tool/thinking) and lastActivityAt. Includes usage (billed token + costUsd totals when providers reported cost) and lastTurnUsage. blockedReason is why that agent is waiting on a person (question, plan approval, or a reported block).",
|
|
3071
|
-
{ ref:
|
|
4212
|
+
{ ref: z9.string() },
|
|
3072
4213
|
async ({ ref }) => {
|
|
3073
4214
|
const t = orch.getThread(ref);
|
|
3074
4215
|
if (!t) {
|
|
@@ -3115,17 +4256,17 @@ async function startMcpServer() {
|
|
|
3115
4256
|
"present_artifact",
|
|
3116
4257
|
"Show a document or live log in Sideboard\u2019s side column. For html/svg/markdown/react, pass the FULL document and do not also fence that same body in chat. For type=log, pass only NEW lines (same artifact_id appends). Prefer type=log for long-running job output \u2014 do not resend HTML. type=react is a single default-export component (JSX/TSX); only react/react-dom imports.",
|
|
3117
4258
|
{
|
|
3118
|
-
title:
|
|
3119
|
-
type:
|
|
4259
|
+
title: z9.string().describe("Short title shown in the artifact pane header"),
|
|
4260
|
+
type: z9.enum(["html", "svg", "markdown", "react", "log"]).describe(
|
|
3120
4261
|
"html/svg/markdown/react replace the pane. log appends content to the same artifact_id (new lines only)."
|
|
3121
4262
|
),
|
|
3122
|
-
content:
|
|
4263
|
+
content: z9.string().describe(
|
|
3123
4264
|
"html/svg/markdown/react: full document. log: only the new lines since the last call (empty is ok for a status-only update)."
|
|
3124
4265
|
),
|
|
3125
|
-
artifact_id:
|
|
3126
|
-
status:
|
|
3127
|
-
phase:
|
|
3128
|
-
mode:
|
|
4266
|
+
artifact_id: z9.string().optional().describe("Stable id. Required for type=log so later calls append to the same pane."),
|
|
4267
|
+
status: z9.enum(["running", "ok", "failed", "idle"]).optional().describe("Log header pill: running (working), ok (done), failed, idle"),
|
|
4268
|
+
phase: z9.string().optional().describe("Log subtitle (Signing, Notarizing, \u2026)"),
|
|
4269
|
+
mode: z9.enum(["append", "replace"]).optional().describe("log only: append (default) or replace the buffer")
|
|
3129
4270
|
},
|
|
3130
4271
|
async ({ title, type, artifact_id, status, phase, mode }) => {
|
|
3131
4272
|
return mcpJson(
|
|
@@ -3138,15 +4279,15 @@ async function startMcpServer() {
|
|
|
3138
4279
|
"ask_user",
|
|
3139
4280
|
"Ask the user a clarifying multiple-choice question in Sideboard\u2019s composer. Call only when work is blocked on choosing among a few concrete options (approach fork, which API, auth vs cookies). Do not call for greetings, check-ins, \u201Chello\u201D, open-ended how-can-I-help, or to invent a menu of possible next tasks \u2014 reply in chat instead. If one option is the obvious default, proceed without asking. Before calling, write a short chat message explaining the decision and what each option means. Include a description on every option. After calling, stop and wait for answers. Not for \u201Cis the plan ready?\u201D.",
|
|
3140
4281
|
{
|
|
3141
|
-
questions:
|
|
3142
|
-
|
|
3143
|
-
question:
|
|
3144
|
-
header:
|
|
3145
|
-
multiSelect:
|
|
3146
|
-
options:
|
|
3147
|
-
|
|
3148
|
-
label:
|
|
3149
|
-
description:
|
|
4282
|
+
questions: z9.array(
|
|
4283
|
+
z9.object({
|
|
4284
|
+
question: z9.string().describe("Full question text ending with ?"),
|
|
4285
|
+
header: z9.string().max(24).optional().describe("Short label shown above the question"),
|
|
4286
|
+
multiSelect: z9.boolean().optional().describe("Allow selecting multiple options"),
|
|
4287
|
+
options: z9.array(
|
|
4288
|
+
z9.object({
|
|
4289
|
+
label: z9.string(),
|
|
4290
|
+
description: z9.string().optional().describe("What this option means / when to choose it (strongly preferred)")
|
|
3150
4291
|
})
|
|
3151
4292
|
).min(2).max(6).describe("2\u20136 choices (Sideboard also offers Other)")
|
|
3152
4293
|
})
|
|
@@ -3172,9 +4313,9 @@ async function startMcpServer() {
|
|
|
3172
4313
|
"present_plan",
|
|
3173
4314
|
PRESENT_PLAN_TOOL_DESCRIPTION,
|
|
3174
4315
|
{
|
|
3175
|
-
title:
|
|
3176
|
-
content:
|
|
3177
|
-
thread_id:
|
|
4316
|
+
title: z9.string().optional().describe("Short plan title (defaults to Plan)"),
|
|
4317
|
+
content: z9.string().min(1).describe("Full plan markdown (headings, steps, risks, open questions)"),
|
|
4318
|
+
thread_id: z9.string().optional().describe("Sideboard thread id when cwd is not the worktree")
|
|
3178
4319
|
},
|
|
3179
4320
|
async ({ title, content, thread_id }) => {
|
|
3180
4321
|
const { writePlanFile } = await import("../plan-file-VAHV5WBB.js");
|
|
@@ -3203,15 +4344,15 @@ async function startMcpServer() {
|
|
|
3203
4344
|
"present_schema",
|
|
3204
4345
|
"Open Sideboard\u2019s schema-driven side column (filterable table and/or form) when the user needs to filter, edit, publish, or persist records. Do not call this just to re-display rows you already wrote as a markdown table. If the user asks for an editable / interactive table, call this even if chat already showed those rows. Pass JSON Schema + optional schemaUi. Prefer datasource=inline with embedded resource/records. Use datasource=brightsy with resource_id only when the user is logged into Brightsy.",
|
|
3205
4346
|
{
|
|
3206
|
-
title:
|
|
3207
|
-
mode:
|
|
3208
|
-
datasource:
|
|
3209
|
-
resource_id:
|
|
3210
|
-
record_id:
|
|
3211
|
-
resource:
|
|
3212
|
-
record:
|
|
3213
|
-
records:
|
|
3214
|
-
pane_id:
|
|
4347
|
+
title: z9.string().describe("Pane title"),
|
|
4348
|
+
mode: z9.enum(["table", "form"]).optional().describe("table = list/filter records; form = edit one record"),
|
|
4349
|
+
datasource: z9.enum(["brightsy", "inline"]).optional().describe("brightsy resolves via login; inline uses embedded resource/records"),
|
|
4350
|
+
resource_id: z9.string().optional().describe("Brightsy record type UUID (or generic resource id)"),
|
|
4351
|
+
record_id: z9.string().optional().describe("Record id when opening form mode"),
|
|
4352
|
+
resource: z9.record(z9.unknown()).optional().describe("Inline { id, title, schema, schemaUi?, slug? }"),
|
|
4353
|
+
record: z9.record(z9.unknown()).optional().describe("Inline record { id, data, published_at? }"),
|
|
4354
|
+
records: z9.array(z9.record(z9.unknown())).optional().describe("Inline records for table mode"),
|
|
4355
|
+
pane_id: z9.string().optional().describe("Stable pane id across updates")
|
|
3215
4356
|
},
|
|
3216
4357
|
async (args) => {
|
|
3217
4358
|
const id = args.pane_id?.trim() || `schema_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
@@ -3232,10 +4373,10 @@ async function startMcpServer() {
|
|
|
3232
4373
|
"present_files",
|
|
3233
4374
|
"Open Sideboard\u2019s Files column (CMS-style file manager: browse, upload, pick). Use datasource=brightsy when the user is logged into Brightsy account storage; datasource=memory for a session-local demo store. Prefer this over claiming a file manager UI is unavailable. Pair with present_schema when editing records that need media.",
|
|
3234
4375
|
{
|
|
3235
|
-
title:
|
|
3236
|
-
datasource:
|
|
3237
|
-
path:
|
|
3238
|
-
pane_id:
|
|
4376
|
+
title: z9.string().optional().describe("Pane title (default: Files)"),
|
|
4377
|
+
datasource: z9.enum(["brightsy", "memory"]).optional().describe("brightsy = account storage via login; memory = session demo store"),
|
|
4378
|
+
path: z9.string().optional().describe("Initial folder path (e.g. public)"),
|
|
4379
|
+
pane_id: z9.string().optional().describe("Stable pane id across updates")
|
|
3239
4380
|
},
|
|
3240
4381
|
async (args) => {
|
|
3241
4382
|
const id = args.pane_id?.trim() || `files_${Date.now().toString(36)}_${Math.random().toString(36).slice(2, 8)}`;
|
|
@@ -3255,8 +4396,8 @@ async function startMcpServer() {
|
|
|
3255
4396
|
"wait_for_job",
|
|
3256
4397
|
"Wait on a detached long job (tests, pack, deploy, connector CLI) started with detached-job.cjs. MCP clients kill tools around 60s, so this returns within 45s. Sideboard opens a type=log pane from this result (artifact_id = job id, content = delta). stillRunning is the source of truth \u2014 if true, call wait_for_job again. If the job is hanging, producing no useful output, or doing the wrong thing, call stop_job instead of looping forever. Do not end the turn or tell the user you will let them know later. If false, ok/failed is the result.",
|
|
3257
4398
|
{
|
|
3258
|
-
id:
|
|
3259
|
-
timeoutMs:
|
|
4399
|
+
id: z9.string().describe("Detached job id (same kebab-case id passed to detached-job.cjs start)"),
|
|
4400
|
+
timeoutMs: z9.number().optional()
|
|
3260
4401
|
},
|
|
3261
4402
|
async ({ id, timeoutMs }) => {
|
|
3262
4403
|
const result = await waitForDetachedJob(process.cwd(), id, {
|
|
@@ -3269,8 +4410,8 @@ async function startMcpServer() {
|
|
|
3269
4410
|
"stop_job",
|
|
3270
4411
|
"Stop a detached job you started with detached-job.cjs when it is hanging, producing no useful output, buffering forever, or doing the wrong thing (wrong project, infinite watch, huge dump). Do not stop a pack/test/deploy that is clearly making progress. The type=log pane updates to status=failed with the last delta. Then decide the next step.",
|
|
3271
4412
|
{
|
|
3272
|
-
id:
|
|
3273
|
-
reason:
|
|
4413
|
+
id: z9.string().describe("Detached job id (same kebab-case id passed to detached-job.cjs start)"),
|
|
4414
|
+
reason: z9.string().optional().describe("Why you are stopping (hanging, no progress, wrong output, already have the answer)")
|
|
3274
4415
|
},
|
|
3275
4416
|
async ({ id, reason }) => {
|
|
3276
4417
|
const result = await stopDetachedJob(process.cwd(), id, { reason });
|
|
@@ -3282,7 +4423,7 @@ async function startMcpServer() {
|
|
|
3282
4423
|
"list_run_scripts",
|
|
3283
4424
|
"List .sideboard/.conductor run scripts for this thread (same menu as the desktop Dev button) and which are active. Each script and active run includes preview: url (open http://localhost:<SIDEBOARD_PORT>) or window (Electron: native window is the app; url is renderer/HMR only). Never guess :3000. Worktree turns may omit ref (uses cwd).",
|
|
3284
4425
|
{
|
|
3285
|
-
ref:
|
|
4426
|
+
ref: z9.string().optional().describe("Thread id. Omit on a worktree turn (uses cwd).")
|
|
3286
4427
|
},
|
|
3287
4428
|
async ({ ref }) => {
|
|
3288
4429
|
try {
|
|
@@ -3312,8 +4453,8 @@ async function startMcpServer() {
|
|
|
3312
4453
|
"run_dev_script",
|
|
3313
4454
|
"Start a .sideboard/.conductor run script (same as the desktop Dev / play button). Several named scripts can run at once; each gets its own port, and starting one does not stop the others. Logs and Stop appear in the thread UI \u2014 do not detached-job or shell-spawn the same command. Returns {port, ports, url, preview}. preview=url \u2192 open url (browser, curl, Playwright). preview=window \u2192 Electron: the native window is the app; url is renderer/HMR only (no preload/IPC in a browser). The port is allocated SIDEBOARD_PORT, not 3000. Worktree turns may omit ref (uses cwd). Omit name for the default script.",
|
|
3314
4455
|
{
|
|
3315
|
-
ref:
|
|
3316
|
-
name:
|
|
4456
|
+
ref: z9.string().optional().describe("Thread id. Omit on a worktree turn (uses cwd)."),
|
|
4457
|
+
name: z9.string().optional().describe("Script name from list_run_scripts (default script if omitted).")
|
|
3317
4458
|
},
|
|
3318
4459
|
async ({ ref, name }) => {
|
|
3319
4460
|
try {
|
|
@@ -3341,8 +4482,8 @@ async function startMcpServer() {
|
|
|
3341
4482
|
"stop_dev_script",
|
|
3342
4483
|
"Stop a run script started with run_dev_script or the desktop Dev button (same as UI Stop). Omit name to stop all scripts on this worktree. Worktree turns may omit ref (uses cwd).",
|
|
3343
4484
|
{
|
|
3344
|
-
ref:
|
|
3345
|
-
name:
|
|
4485
|
+
ref: z9.string().optional().describe("Thread id. Omit on a worktree turn (uses cwd)."),
|
|
4486
|
+
name: z9.string().optional().describe("Script name to stop; omit to stop all active scripts.")
|
|
3346
4487
|
},
|
|
3347
4488
|
async ({ ref, name }) => {
|
|
3348
4489
|
try {
|
|
@@ -3359,9 +4500,9 @@ async function startMcpServer() {
|
|
|
3359
4500
|
"get_run_log",
|
|
3360
4501
|
"Read the Run-tab terminal for a worktree script (same stdout/stderr as the desktop Dev pane). Default is a tail \u2014 raise `tail` only if the error is missing. Worktree turns may omit ref (uses cwd). Omit name for the default script.",
|
|
3361
4502
|
{
|
|
3362
|
-
ref:
|
|
3363
|
-
name:
|
|
3364
|
-
tail:
|
|
4503
|
+
ref: z9.string().optional().describe("Thread id. Omit on a worktree turn (uses cwd)."),
|
|
4504
|
+
name: z9.string().optional().describe("Script name from list_run_scripts (default script if omitted)."),
|
|
4505
|
+
tail: z9.number().int().min(1).max(MAX_RUN_LOG_CHARS).optional().describe(
|
|
3365
4506
|
`Max characters to return from the end (default ${DEFAULT_RUN_LOG_TAIL_CHARS}). Do not request the full buffer unless the tail is truncated and you still need more.`
|
|
3366
4507
|
)
|
|
3367
4508
|
},
|
|
@@ -3424,8 +4565,8 @@ async function startMcpServer() {
|
|
|
3424
4565
|
"notify_orchestrator",
|
|
3425
4566
|
"Wake the parent Global orchestrator with a short status so it does not have to poll wait_for_turn. Use when you are blocked and the parent may have moved on (missing access, waiting on something the coordinator must handle). The message is shown on the sidebar and board until the next user message in this chat. ask_user already notifies for input-required \u2014 do not call this for the same question. Information only: never a git command. Do not use this to steer other worktrees.",
|
|
3426
4567
|
{
|
|
3427
|
-
message:
|
|
3428
|
-
reason:
|
|
4568
|
+
message: z9.string().min(1).max(1500).describe("Why you are blocked / what the parent should know (short)."),
|
|
4569
|
+
reason: z9.enum(["input-required", "blocked"]).optional().describe(
|
|
3429
4570
|
"input-required = waiting on the user in this chat; blocked = need the coordinator (default)."
|
|
3430
4571
|
)
|
|
3431
4572
|
},
|
|
@@ -3458,15 +4599,16 @@ async function startMcpServer() {
|
|
|
3458
4599
|
);
|
|
3459
4600
|
}
|
|
3460
4601
|
registerScheduleTools(server);
|
|
4602
|
+
registerOrderTools(server);
|
|
3461
4603
|
server.tool(
|
|
3462
4604
|
"set_workspace_tags",
|
|
3463
4605
|
worktreeProfile ? "Update tags on this workspace (the checkout you are in). Omit ref to use this chat. mode=replace (default), add, or remove. Short labels \u2014 the same ones the orchestrator used for this task. You cannot retag a different checkout." : "Label a project workspace so related checkouts stay recognizable in the sidebar and on the phone. Pass any chat id on that workspace. Use the same tags on every workspace from one task. mode=replace is the default; add and remove change the set. create_workspace tags= sets them at create time. Not for orchestration chats.",
|
|
3464
4606
|
{
|
|
3465
|
-
ref:
|
|
4607
|
+
ref: z9.string().optional().describe(
|
|
3466
4608
|
worktreeProfile ? "Omit for this chat. Another chat id only if it is on this same checkout." : "Chat id on the workspace to label."
|
|
3467
4609
|
),
|
|
3468
|
-
tags:
|
|
3469
|
-
mode:
|
|
4610
|
+
tags: z9.union([z9.string(), z9.array(z9.string())]).describe("Labels to set. A string may be comma-separated."),
|
|
4611
|
+
mode: z9.enum(["replace", "add", "remove"]).optional()
|
|
3470
4612
|
},
|
|
3471
4613
|
async ({ ref, tags, mode }) => {
|
|
3472
4614
|
try {
|
|
@@ -3500,7 +4642,7 @@ async function startMcpServer() {
|
|
|
3500
4642
|
"set_caffeinate",
|
|
3501
4643
|
"Keep this Mac awake with caffeinate across turns \u2014 independent of Settings toggles. A connected phone already holds caffeinate (lid can close on power), so do not turn this on just because they are on the phone. Turn ON when the user will be away and no phone is connected, or they ask you to keep the machine awake. Turn OFF when they say they are done, wrapping up, going to sleep, or no longer need the Mac awake. Closing or archiving this orchestration chat also releases the hold. macOS only.",
|
|
3502
4644
|
{
|
|
3503
|
-
enabled:
|
|
4645
|
+
enabled: z9.boolean().describe("true = hold caffeinate on; false = release and let the Mac sleep")
|
|
3504
4646
|
},
|
|
3505
4647
|
async ({ enabled }) => {
|
|
3506
4648
|
const threadId = process.env.SIDEBOARD_ORCHESTRATOR_THREAD_ID?.trim() || null;
|
|
@@ -3526,24 +4668,24 @@ async function startMcpServer() {
|
|
|
3526
4668
|
"create_workspace",
|
|
3527
4669
|
`Create a workspace (isolated git checkout + first chat) from branch, pr, or ticket. A ticket, PR, or named branch has one checkout \u2014 if one already matches, returns it (alreadyStarted=true) instead of a second checkout. That is not one agent: chats lists every agent on that checkout. Add another with fork_chat; send_to_chat only the chat that should do this job. Creating from the default branch still opens a new isolated checkout. Pass repoPath from list_projects. cowboy=true uses the project folder on the default branch (no isolated worktree; land is commit+push). From an orchestration chat, omit parentChatId (Sideboard binds the child to this chat) or pass the exact id from the turn reminder \u2014 never invent a uuid. Omit agent/model \u2014 Sideboard applies ${accountDefaultsHint}. Do not pass your own agent or agent=cursor; those are ignored. Setup (settings.toml, .cursor/worktrees.json, or script/setup) runs in the background in parallel with the first turn (skipped for cowboy). Pass the same tags on every workspace you open for one task (short labels such as "phone-sync") so they still match in the sidebar the next day. Reusing a checkout adds those tags.`,
|
|
3528
4670
|
{
|
|
3529
|
-
sourceType:
|
|
3530
|
-
sourceRef:
|
|
3531
|
-
agent:
|
|
4671
|
+
sourceType: z9.enum(["branch", "pr", "ticket"]),
|
|
4672
|
+
sourceRef: z9.string(),
|
|
4673
|
+
agent: z9.enum(["claude", "codex", "opencode", "brightsy", "cursor"]).optional().describe(
|
|
3532
4674
|
`Usually omit. Sideboard uses Account default agent (${accountDefaults.agent}). Passing your own agent or cursor is ignored.`
|
|
3533
4675
|
),
|
|
3534
|
-
model:
|
|
4676
|
+
model: z9.string().nullable().optional().describe(
|
|
3535
4677
|
`Usually omit to use Account default model (${accountDefaults.model?.trim() || "Auto"}). Pass null only to force Auto / agent-default.`
|
|
3536
4678
|
),
|
|
3537
|
-
repoPath:
|
|
3538
|
-
title:
|
|
3539
|
-
cowboy:
|
|
4679
|
+
repoPath: z9.string(),
|
|
4680
|
+
title: z9.string().optional(),
|
|
4681
|
+
cowboy: z9.boolean().optional().describe(
|
|
3540
4682
|
"If true, work in the project folder on the default branch (no thread/* worktree). Requires Settings \u2192 Advanced \u2192 Cowboy mode. Land is commit+push to that branch. Archive does not delete the folder."
|
|
3541
4683
|
),
|
|
3542
|
-
parentChatId:
|
|
4684
|
+
parentChatId: z9.string().optional().describe(
|
|
3543
4685
|
"Orchestration: omit (preferred) or pass YOUR chat id from the turn reminder / AGENTS.md. Do not invent uuids."
|
|
3544
4686
|
),
|
|
3545
|
-
parentThreadId:
|
|
3546
|
-
tags:
|
|
4687
|
+
parentThreadId: z9.string().optional().describe("Legacy alias for parentChatId."),
|
|
4688
|
+
tags: z9.union([z9.string(), z9.array(z9.string())]).optional().describe(
|
|
3547
4689
|
"Short labels for this workspace (or a comma-separated string). Use the same tags on every checkout for one task. Added when the checkout already exists."
|
|
3548
4690
|
)
|
|
3549
4691
|
},
|
|
@@ -3559,11 +4701,11 @@ async function startMcpServer() {
|
|
|
3559
4701
|
"start_board_card",
|
|
3560
4702
|
"Same as create_workspace for a ticket, PR, or named branch (attaches issue text when Sideboard can resolve it). Does not create a second checkout when one already matches \u2014 returns that workspace (alreadyStarted) and its chats. A workspace can have many agents. fork_chat to add one; send_to_chat only the chat that should do this job.",
|
|
3561
4703
|
{
|
|
3562
|
-
kind:
|
|
3563
|
-
ref:
|
|
3564
|
-
repoPath:
|
|
3565
|
-
title:
|
|
3566
|
-
tags:
|
|
4704
|
+
kind: z9.enum(["ticket", "pr", "branch"]),
|
|
4705
|
+
ref: z9.string().describe("Ticket identifier (ENG-12), PR number (44), or branch name from list_board"),
|
|
4706
|
+
repoPath: z9.string().describe("Project path from list_projects / list_board"),
|
|
4707
|
+
title: z9.string().optional(),
|
|
4708
|
+
tags: z9.union([z9.string(), z9.array(z9.string())]).optional().describe(
|
|
3567
4709
|
"Short labels for this workspace. Same tags on every checkout for one task. Added when the checkout already exists."
|
|
3568
4710
|
)
|
|
3569
4711
|
},
|
|
@@ -3619,7 +4761,7 @@ async function startMcpServer() {
|
|
|
3619
4761
|
const ident = issue?.identifier ?? ref.trim();
|
|
3620
4762
|
const attachments = issue ? [
|
|
3621
4763
|
{
|
|
3622
|
-
id:
|
|
4764
|
+
id: randomUUID4(),
|
|
3623
4765
|
name: issue.identifier,
|
|
3624
4766
|
kind: "issue",
|
|
3625
4767
|
content: [
|
|
@@ -3668,9 +4810,9 @@ async function startMcpServer() {
|
|
|
3668
4810
|
"send_to_chat",
|
|
3669
4811
|
'Steer a prompt on a workspace chat (Settings \u2192 Follow-up, default steer: interrupt the in-flight turn and start now, same as the workspace composer). Use after create_workspace to start or continue a conversation. For commit/push/PR, prefer ask_git (canonical desktop-button phrases). Send "Merge PR." / ask_git merge only when the user explicitly asked to merge. force_stop=true kills the in-flight turn and clears the queue before this prompt \u2014 only when the current request is wrong and must be replaced. Do not send_to_chat to check in, resume after a halt notice, or because wait_for_turn returned stillRunning; that interrupts the child mid-thought. Call wait_for_turn again instead.',
|
|
3670
4812
|
{
|
|
3671
|
-
ref:
|
|
3672
|
-
prompt:
|
|
3673
|
-
force_stop:
|
|
4813
|
+
ref: z9.string(),
|
|
4814
|
+
prompt: z9.string(),
|
|
4815
|
+
force_stop: z9.boolean().optional()
|
|
3674
4816
|
},
|
|
3675
4817
|
async ({ ref, prompt, force_stop }) => {
|
|
3676
4818
|
if (force_stop) {
|
|
@@ -3695,8 +4837,8 @@ async function startMcpServer() {
|
|
|
3695
4837
|
"wait_for_turn",
|
|
3696
4838
|
"Wait until the chat finishes its current/queued turn, or return early with a live progress snapshot. MCP clients often kill tools around 60s, so this returns within 45s even while the child is still working. taskState is the A2A-style lifecycle: submitted (queued, not started), working, input-required (ask_user), completed, failed, canceled. stillRunning is true only for submitted/working. blockedReason is why the child is waiting on a person (the question, plan approval, or a reported block) \u2014 read it and do not send_to_chat a check-in. If stillRunning, text and usage are empty (they would be the previous turn) \u2014 read progress and call wait_for_turn again. Do not send_to_chat a check-in (that steers / interrupts). On failed, lastError/text is the failure. On canceled, the child did not finish \u2014 resume with send_to_chat or tell the user. On input-required, wait for the user in that chat. When finished, text is this turn\u2019s assistant reply and usage is that turn\u2019s tokens + costUsd (this turn, not the Claude session total; sessionCostUsd is the provider session total when present).",
|
|
3697
4839
|
{
|
|
3698
|
-
ref:
|
|
3699
|
-
timeoutMs:
|
|
4840
|
+
ref: z9.string(),
|
|
4841
|
+
timeoutMs: z9.number().optional()
|
|
3700
4842
|
},
|
|
3701
4843
|
async ({ ref, timeoutMs }) => {
|
|
3702
4844
|
const thread = await orch.waitForTurn(ref, mcpWaitForTurnTimeoutMs(timeoutMs), {
|
|
@@ -3724,7 +4866,7 @@ async function startMcpServer() {
|
|
|
3724
4866
|
server.tool(
|
|
3725
4867
|
"get_turn_result",
|
|
3726
4868
|
"Assistant message and last-turn usage when the turn finished. While stillRunning (submitted/working), text and usage are empty so a previous reply cannot be mistaken for this turn \u2014 use progress for tools/thinking. Not the full transcript. Includes taskState (A2A lifecycle) and blockedReason (why the agent is waiting on a person).",
|
|
3727
|
-
{ ref:
|
|
4869
|
+
{ ref: z9.string() },
|
|
3728
4870
|
async ({ ref }) => {
|
|
3729
4871
|
const result = orch.getTurnResult(ref);
|
|
3730
4872
|
const hint = mcpWaitTaskHint(result.taskState, result.status, result.blockedReason);
|
|
@@ -3740,9 +4882,9 @@ async function startMcpServer() {
|
|
|
3740
4882
|
"stop_chat",
|
|
3741
4883
|
"Force-stop a thread: kill any in-flight agent turn AND clear queued prompts so drainQueue cannot continue. Does not archive the worktree. Optional force defaults to true. Pass reason \u2014 a short note on why this chat is stopping. It is stored on the thread and kept when the turn unwinds. If you omit it, Sideboard still records that the queue was cleared.",
|
|
3742
4884
|
{
|
|
3743
|
-
ref:
|
|
3744
|
-
force:
|
|
3745
|
-
reason:
|
|
4885
|
+
ref: z9.string(),
|
|
4886
|
+
force: z9.boolean().optional(),
|
|
4887
|
+
reason: z9.string().optional().describe("Why this chat is stopping. Stored on the thread for the next session.")
|
|
3746
4888
|
},
|
|
3747
4889
|
async ({ ref, force, reason }) => {
|
|
3748
4890
|
const t = orch.getThread(ref);
|
|
@@ -3768,8 +4910,8 @@ async function startMcpServer() {
|
|
|
3768
4910
|
"get_diff",
|
|
3769
4911
|
"Compact diff summary (capped hunks, paginated)",
|
|
3770
4912
|
{
|
|
3771
|
-
ref:
|
|
3772
|
-
maxFiles:
|
|
4913
|
+
ref: z9.string(),
|
|
4914
|
+
maxFiles: z9.number().optional()
|
|
3773
4915
|
},
|
|
3774
4916
|
async ({ ref, maxFiles }) => {
|
|
3775
4917
|
const summary = await orch.diffSummary(ref);
|
|
@@ -3782,7 +4924,7 @@ async function startMcpServer() {
|
|
|
3782
4924
|
server.tool(
|
|
3783
4925
|
"get_pr_checks",
|
|
3784
4926
|
"Snapshot of GitHub PR checks for a worktree thread (`gh pr checks` plus merge/review gates). null = no PR. If the user gave a goal (Greptile 5/5, CI green), the worktree agent watches with `gh pr checks --watch` via /long-running \u2014 this tool is a snapshot, not a waiter. Coordinators: do not run gh from the orchestration cwd.",
|
|
3785
|
-
{ ref:
|
|
4927
|
+
{ ref: z9.string().describe("Worktree thread id/ref") },
|
|
3786
4928
|
async ({ ref }) => {
|
|
3787
4929
|
try {
|
|
3788
4930
|
const checks = await orch.getPrChecks(ref);
|
|
@@ -3796,7 +4938,7 @@ async function startMcpServer() {
|
|
|
3796
4938
|
server.tool(
|
|
3797
4939
|
"request_review",
|
|
3798
4940
|
'Start a merge-readiness Review on a worktree agent thread (same as the desktop Review button). If that worktree has a single unused idle agent (no messages), runs the review there; otherwise opens a new Review chat tab. Attaches .claude/skills/review/SKILL.md when present (else copies .sideboard/review.md into .context/review.md, or seeds that file from the stock template), and sends "Review changes in this workspace." Expect Approve / Approve with nits / Request changes / Needs more information in that chat. The review stays there so the user can read it and type next steps \u2014 do not comment on or update the PR or ticket, and do not ask_user after the review, until they ask. Pass a worktree thread ref \u2014 not the orchestrator. Then wait_for_turn (loop while stillRunning) / get_turn_result on the returned review thread id.',
|
|
3799
|
-
{ ref:
|
|
4941
|
+
{ ref: z9.string().describe("Worktree thread id/ref to review") },
|
|
3800
4942
|
async ({ ref }) => {
|
|
3801
4943
|
try {
|
|
3802
4944
|
const tab = await orch.requestReview(ref);
|
|
@@ -3818,8 +4960,8 @@ async function startMcpServer() {
|
|
|
3818
4960
|
"ask_git",
|
|
3819
4961
|
"Commit & push, open a draft PR, mark ready for review, resolve conflicts, or merge \u2014 same prompts as the desktop git buttons (including Resolve). Always steers the worktree agent; does not push or open the PR locally. Then wait_for_turn (loop while stillRunning). Do not start a checks loop on a plain push \u2014 only if the user gave a goal (CI green, a review score, until checks pass). A push can wake a third-party PR review; the worktree agent acknowledges it only inside that goal. Pass a worktree thread ref (not the orchestrator). action=ready-for-review and action=merge only when the user explicitly asked (or clicked the desktop button). Do not run git or gh from the orchestration cwd.",
|
|
3820
4962
|
{
|
|
3821
|
-
ref:
|
|
3822
|
-
action:
|
|
4963
|
+
ref: z9.string().describe("Worktree thread id/ref"),
|
|
4964
|
+
action: z9.enum(AGENT_GIT_ACTIONS).describe(
|
|
3823
4965
|
"commit-push | create-draft | create-web | resolve-conflicts | ready-for-review | merge"
|
|
3824
4966
|
)
|
|
3825
4967
|
},
|
|
@@ -3848,7 +4990,7 @@ async function startMcpServer() {
|
|
|
3848
4990
|
}
|
|
3849
4991
|
}
|
|
3850
4992
|
);
|
|
3851
|
-
const agentEnum =
|
|
4993
|
+
const agentEnum = z9.enum(["claude", "codex", "opencode", "brightsy", "cursor"]);
|
|
3852
4994
|
server.tool(
|
|
3853
4995
|
"list_models",
|
|
3854
4996
|
"List models for an agent. Prefer Auto: do not call this unless you have a reason to pin a specific model (user request, cost/latency, capability). Omit agent to list all.",
|
|
@@ -3869,11 +5011,11 @@ async function startMcpServer() {
|
|
|
3869
5011
|
"fork_workspace",
|
|
3870
5012
|
"Fork a worktree agent chat into a NEW git worktree + chat (desktop \u201CFork to new workspace\u201D). Seeds a transcript (through through_index, default all). Optional agent override. Leave model unset for Auto (default) \u2014 only pass model when you have a reason. Not for the orchestrator. Then send_to_chat / wait_for_turn (loop while stillRunning) on the returned id.",
|
|
3871
5013
|
{
|
|
3872
|
-
ref:
|
|
3873
|
-
through_index:
|
|
5014
|
+
ref: z9.string().describe("Worktree thread id/ref to fork"),
|
|
5015
|
+
through_index: z9.number().optional().describe("Inclusive message index to include in the transcript (default: all)"),
|
|
3874
5016
|
agent: agentEnum.optional().describe("Agent for the forked chat (default: same as source)"),
|
|
3875
|
-
model:
|
|
3876
|
-
title:
|
|
5017
|
+
model: z9.string().nullable().optional().describe("Usually omit (Auto). Only set from list_models when you need a specific model"),
|
|
5018
|
+
title: z9.string().optional()
|
|
3877
5019
|
},
|
|
3878
5020
|
async ({ ref, through_index, agent, model, title }) => {
|
|
3879
5021
|
try {
|
|
@@ -3907,11 +5049,11 @@ async function startMcpServer() {
|
|
|
3907
5049
|
"fork_chat",
|
|
3908
5050
|
"Add another agent chat on the SAME workspace (same files, Run, and git). Also forks a Global orchestration chat into a new orchestration tab. Pass agent when the new chat should use a different harness. Leave model unset for Auto unless you have a reason. Orchestration forks require an MCP-capable agent (claude, cursor, codex, opencode \u2014 not brightsy). Use this for a second agent on a checkout (review, another harness, parallel work on the same branch). Do not create_workspace again for that \u2014 it returns the existing checkout. Then send_to_chat / wait_for_turn (loop while stillRunning) on the returned id. Use fork_workspace only when the work needs its own git checkout.",
|
|
3909
5051
|
{
|
|
3910
|
-
ref:
|
|
3911
|
-
through_index:
|
|
5052
|
+
ref: z9.string().describe("Thread id/ref to fork (worktree agent or orchestration chat)"),
|
|
5053
|
+
through_index: z9.number().optional().describe("Inclusive message index to include in the transcript (default: all)"),
|
|
3912
5054
|
agent: agentEnum.optional().describe("Agent for the forked chat (default: same as source)"),
|
|
3913
|
-
model:
|
|
3914
|
-
title:
|
|
5055
|
+
model: z9.string().nullable().optional().describe("Usually omit (Auto). Only set from list_models when you need a specific model"),
|
|
5056
|
+
title: z9.string().optional()
|
|
3915
5057
|
},
|
|
3916
5058
|
async ({ ref, through_index, agent, model, title }) => {
|
|
3917
5059
|
try {
|
|
@@ -3949,7 +5091,7 @@ async function startMcpServer() {
|
|
|
3949
5091
|
server.tool(
|
|
3950
5092
|
"run_setup",
|
|
3951
5093
|
"Re-run workspace setup (Sideboard/Conductor settings, .cursor/worktrees.json, or script/setup). New worktrees already run this automatically.",
|
|
3952
|
-
{ ref:
|
|
5094
|
+
{ ref: z9.string() },
|
|
3953
5095
|
async ({ ref }) => {
|
|
3954
5096
|
const result = await orch.runSetup(ref);
|
|
3955
5097
|
return mcpJson(result);
|
|
@@ -3958,7 +5100,7 @@ async function startMcpServer() {
|
|
|
3958
5100
|
server.tool(
|
|
3959
5101
|
"add_project",
|
|
3960
5102
|
"Register a git repo as a Sideboard workspace",
|
|
3961
|
-
{ repoPath:
|
|
5103
|
+
{ repoPath: z9.string() },
|
|
3962
5104
|
async ({ repoPath }) => {
|
|
3963
5105
|
const ws = await orch.addWorkspace(repoPath);
|
|
3964
5106
|
return mcpJson(ws);
|
|
@@ -3967,7 +5109,7 @@ async function startMcpServer() {
|
|
|
3967
5109
|
server.tool(
|
|
3968
5110
|
"remove_project",
|
|
3969
5111
|
"Unregister a Sideboard workspace and archive its chats",
|
|
3970
|
-
{ repoPath:
|
|
5112
|
+
{ repoPath: z9.string() },
|
|
3971
5113
|
async ({ repoPath }) => {
|
|
3972
5114
|
await orch.removeWorkspace(repoPath);
|
|
3973
5115
|
return { content: [{ type: "text", text: "ok" }] };
|
|
@@ -3977,12 +5119,12 @@ async function startMcpServer() {
|
|
|
3977
5119
|
"fanout",
|
|
3978
5120
|
"Best-of-n: create one thread per agent with the same prompt (parallel attempts)",
|
|
3979
5121
|
{
|
|
3980
|
-
prompt:
|
|
3981
|
-
agents:
|
|
3982
|
-
repoPath:
|
|
3983
|
-
sourceType:
|
|
3984
|
-
sourceRef:
|
|
3985
|
-
title:
|
|
5122
|
+
prompt: z9.string(),
|
|
5123
|
+
agents: z9.array(z9.enum(["claude", "codex", "opencode", "brightsy", "cursor"])),
|
|
5124
|
+
repoPath: z9.string(),
|
|
5125
|
+
sourceType: z9.enum(["branch", "pr", "ticket"]).optional(),
|
|
5126
|
+
sourceRef: z9.string().optional(),
|
|
5127
|
+
title: z9.string().optional()
|
|
3986
5128
|
},
|
|
3987
5129
|
async (args) => {
|
|
3988
5130
|
const threads = await orch.bestOfN(args);
|
|
@@ -4000,8 +5142,8 @@ async function startMcpServer() {
|
|
|
4000
5142
|
"list_branches",
|
|
4001
5143
|
"List git branches in a registered workspace. Pass repoPath from list_projects (unmerged into the default branch by default \u2014 for create_workspace sourceType=branch).",
|
|
4002
5144
|
{
|
|
4003
|
-
repoPath:
|
|
4004
|
-
unmergedOnly:
|
|
5145
|
+
repoPath: z9.string(),
|
|
5146
|
+
unmergedOnly: z9.boolean().optional()
|
|
4005
5147
|
},
|
|
4006
5148
|
async ({ repoPath, unmergedOnly }) => {
|
|
4007
5149
|
const root = await resolveRepoRoot(repoPath);
|
|
@@ -4022,19 +5164,19 @@ async function startMcpServer() {
|
|
|
4022
5164
|
"list_prs",
|
|
4023
5165
|
`List GitHub PRs for a registered workspace (the review surface for assigned ticket work \u2014 not the tickets). Pass repoPath from list_projects. "Get me N tickets to review" \u2192 queue=review and limit=N: open non-draft PRs labeled with this project's ready-for-review GitHub label (Settings \u2192 Projects; default eng-review) with no individual user reviewer. Prefer teams that match Settings \u2192 Agents / Projects roles for this repo. A team like engineering-team is not a claim (you are on that team). Also: state (open|closed|merged|all|review), label, reviewer (me|unassigned|login), query, limit (default 40, max 250). Then create_workspace with sourceType=pr.`,
|
|
4024
5166
|
{
|
|
4025
|
-
repoPath:
|
|
4026
|
-
query:
|
|
4027
|
-
queue:
|
|
5167
|
+
repoPath: z9.string(),
|
|
5168
|
+
query: z9.string().optional().describe("GitHub search tokens (title, draft:true, \u2026)"),
|
|
5169
|
+
queue: z9.enum(["review", "mine", "approved", "changes"]).optional().describe(
|
|
4028
5170
|
"review = unclaimed ready-for-review inbox (Settings \u2192 Projects label, default eng-review). mine = review-requested:@me. approved / changes = eng-approved / eng-requested-changes."
|
|
4029
5171
|
),
|
|
4030
|
-
state:
|
|
4031
|
-
label:
|
|
5172
|
+
state: z9.enum(["open", "closed", "merged", "all", "review"]).optional().describe("GitHub PR state (default open). review is an alias for queue=review."),
|
|
5173
|
+
label: z9.string().optional().describe(
|
|
4032
5174
|
"GitHub label / workflow tag. Comma-separated AND. Examples: eng-review, eng-approved, eng-requested-changes"
|
|
4033
5175
|
),
|
|
4034
|
-
reviewer:
|
|
5176
|
+
reviewer: z9.string().optional().describe(
|
|
4035
5177
|
"me (review requested of you), unassigned (no individual reviewer; team queues like engineering-team still count), all, or a GitHub login"
|
|
4036
5178
|
),
|
|
4037
|
-
limit:
|
|
5179
|
+
limit: z9.number().int().positive().max(250).optional().describe("Page size (default 40, max 250). Raise when truncated is true.")
|
|
4038
5180
|
},
|
|
4039
5181
|
async ({ repoPath, query, queue, state, label, reviewer, limit }) => {
|
|
4040
5182
|
const root = await resolveRepoRoot(repoPath);
|
|
@@ -4067,7 +5209,7 @@ async function startMcpServer() {
|
|
|
4067
5209
|
server.tool(
|
|
4068
5210
|
"get_pr_stack",
|
|
4069
5211
|
"Load the GitHub PR stack for a thread worktree (`gh stack view --json`). Returns null JSON when the branch is not stacked. Prefer this before ask_git merge on stacked PRs (and only merge when the user explicitly asked).",
|
|
4070
|
-
{ ref:
|
|
5212
|
+
{ ref: z9.string() },
|
|
4071
5213
|
async ({ ref }) => {
|
|
4072
5214
|
const stack = await orch.getPrStack(ref);
|
|
4073
5215
|
return mcpJson(stack);
|
|
@@ -4077,8 +5219,8 @@ async function startMcpServer() {
|
|
|
4077
5219
|
"open_pr_stack_layers",
|
|
4078
5220
|
"Materialize one worktree+thread per stack layer (or a single 1-based layer). Pass a thread ref already on the stack.",
|
|
4079
5221
|
{
|
|
4080
|
-
ref:
|
|
4081
|
-
layer:
|
|
5222
|
+
ref: z9.string(),
|
|
5223
|
+
layer: z9.number().int().positive().optional()
|
|
4082
5224
|
},
|
|
4083
5225
|
async ({ ref, layer }) => {
|
|
4084
5226
|
const result = await orch.openPrStackLayers(ref, { layer });
|
|
@@ -4101,9 +5243,9 @@ async function startMcpServer() {
|
|
|
4101
5243
|
"add_stack_layer",
|
|
4102
5244
|
"Add a branch on top of the current stack (`gh stack add`) and open a worktree+thread for it.",
|
|
4103
5245
|
{
|
|
4104
|
-
ref:
|
|
4105
|
-
branchName:
|
|
4106
|
-
title:
|
|
5246
|
+
ref: z9.string(),
|
|
5247
|
+
branchName: z9.string(),
|
|
5248
|
+
title: z9.string().optional()
|
|
4107
5249
|
},
|
|
4108
5250
|
async ({ ref, branchName, title }) => {
|
|
4109
5251
|
const result = await orch.addStackLayer(ref, branchName, { title });
|
|
@@ -4121,11 +5263,11 @@ async function startMcpServer() {
|
|
|
4121
5263
|
"create_pr_stack",
|
|
4122
5264
|
"Create a new GitHub PR stack with one Sideboard worktree per layer (bottom\u2192top branch names). Requires `gh extension install github/gh-stack`.",
|
|
4123
5265
|
{
|
|
4124
|
-
repoPath:
|
|
4125
|
-
branches:
|
|
4126
|
-
agent:
|
|
4127
|
-
base:
|
|
4128
|
-
title:
|
|
5266
|
+
repoPath: z9.string(),
|
|
5267
|
+
branches: z9.array(z9.string()).min(1),
|
|
5268
|
+
agent: z9.enum(["claude", "codex", "opencode", "brightsy", "cursor"]),
|
|
5269
|
+
base: z9.string().optional(),
|
|
5270
|
+
title: z9.string().optional()
|
|
4129
5271
|
},
|
|
4130
5272
|
async (args) => {
|
|
4131
5273
|
const result = await orch.createPrStack({
|
|
@@ -4153,10 +5295,10 @@ async function startMcpServer() {
|
|
|
4153
5295
|
"list_issues",
|
|
4154
5296
|
"List or search issues (Linear, AbleTime, or GitHub; falls back to GitHub). Cursor Origin has no issue tracker \u2014 a Cursor repo returns unavailableReason unless Linear or AbleTime is the source. Entire tickets are Trails (`entire trail`), not GitHub Issues, so an Entire repo does the same unless Linear or AbleTime is the source. Use Settings \u2192 Agents / Projects notes and roles to pick tickets relevant to the viewer (query + assignee=me or unassigned as the notes say). Default 40; pass query and/or limit (max 250) when truncated. assignee: me (Linear default), unassigned, all, or a user id. Pass updatedSince for new/updated tickets and new comments (\u201Cany updates since yesterday?\u201D). Then create_workspace with sourceType=ticket.",
|
|
4155
5297
|
{
|
|
4156
|
-
repoPath:
|
|
4157
|
-
query:
|
|
4158
|
-
assignee:
|
|
4159
|
-
limit:
|
|
5298
|
+
repoPath: z9.string(),
|
|
5299
|
+
query: z9.string().optional().describe("Search title, identifier, or description"),
|
|
5300
|
+
assignee: z9.string().optional().describe("me (Linear default), unassigned, all, a user id, or a GitHub login"),
|
|
5301
|
+
limit: z9.number().int().positive().max(250).optional().describe("Page size (default 40, max 250). Raise when truncated is true."),
|
|
4160
5302
|
updatedSince: mcpIssueUpdatedSinceSchema
|
|
4161
5303
|
},
|
|
4162
5304
|
async ({ repoPath, query, assignee, limit, updatedSince }) => {
|